MCPcopy Create free account
hub / github.com/cppla/ServerStatus / MakeBanInfo

Method MakeBanInfo

server/src/netban.cpp:238–278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236
237template<class T>
238void CNetBan::MakeBanInfo(const CBan<T> *pBan, char *pBuf, unsigned BuffSize, int Type) const
239{
240 if(pBan == 0 || pBuf == 0)
241 {
242 if(BuffSize > 0)
243 pBuf[0] = 0;
244 return;
245 }
246
247 // build type based part
248 char aBuf[256];
249 if(Type == MSGTYPE_PLAYER)
250 str_copy(aBuf, "You have been banned", sizeof(aBuf));
251 else
252 {
253 char aTemp[256];
254 switch(Type)
255 {
256 case MSGTYPE_LIST:
257 str_format(aBuf, sizeof(aBuf), "%s banned", NetToString(&pBan->m_Data, aTemp, sizeof(aTemp))); break;
258 case MSGTYPE_BANADD:
259 str_format(aBuf, sizeof(aBuf), "banned %s", NetToString(&pBan->m_Data, aTemp, sizeof(aTemp))); break;
260 case MSGTYPE_BANREM:
261 str_format(aBuf, sizeof(aBuf), "unbanned %s", NetToString(&pBan->m_Data, aTemp, sizeof(aTemp))); break;
262 default:
263 aBuf[0] = 0;
264 }
265 }
266
267 // add info part
268 if(pBan->m_Info.m_Expires != CBanInfo::EXPIRES_NEVER)
269 {
270 int Mins = ((pBan->m_Info.m_Expires-time_timestamp()) + 59) / 60;
271 if(Mins <= 1)
272 str_format(pBuf, BuffSize, "%s for 1 minute (%s)", aBuf, pBan->m_Info.m_aReason);
273 else
274 str_format(pBuf, BuffSize, "%s for %d minutes (%s)", aBuf, Mins, pBan->m_Info.m_aReason);
275 }
276 else
277 str_format(pBuf, BuffSize, "%s for life (%s)", aBuf, pBan->m_Info.m_aReason);
278}
279
280template<class T>
281int CNetBan::Ban(T *pBanPool, const typename T::CDataType *pData, int Seconds, const char *pReason)

Callers

nothing calls this directly

Calls 3

str_copyFunction · 0.85
str_formatFunction · 0.85
time_timestampFunction · 0.85

Tested by

no test coverage detected