MCPcopy Create free account
hub / github.com/ddnet/ddnet / ConBanExt

Method ConBanExt

src/engine/server/server.cpp:145–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145void CServerBan::ConBanExt(IConsole::IResult *pResult, void *pUser)
146{
147 CServerBan *pThis = static_cast<CServerBan *>(pUser);
148
149 const char *pStr = pResult->GetString(0);
150 int Minutes = pResult->NumArguments() > 1 ? std::clamp(pResult->GetInteger(1), 0, 525600) : 10;
151 const char *pReason = pResult->NumArguments() > 2 ? pResult->GetString(2) : "Follow the server rules. Type /rules into the chat.";
152
153 if(str_isallnum(pStr))
154 {
155 int ClientId = str_toint(pStr);
156 if(ClientId < 0 || ClientId >= MAX_CLIENTS || pThis->Server()->m_aClients[ClientId].m_State == CServer::CClient::STATE_EMPTY)
157 pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "ban error (invalid client id)");
158 else
159 pThis->BanAddr(pThis->Server()->ClientAddr(ClientId), Minutes * 60, pReason, false);
160 }
161 else
162 ConBan(pResult, pUser);
163}
164
165void CServerBan::ConBanRegion(IConsole::IResult *pResult, void *pUser)
166{

Callers

nothing calls this directly

Calls 10

str_isallnumFunction · 0.85
str_tointFunction · 0.85
NumArgumentsMethod · 0.80
GetStringMethod · 0.45
GetIntegerMethod · 0.45
ServerMethod · 0.45
PrintMethod · 0.45
ConsoleMethod · 0.45
BanAddrMethod · 0.45
ClientAddrMethod · 0.45

Tested by

no test coverage detected