MCPcopy Create free account
hub / github.com/assaultcube/AC / disc_reason

Function disc_reason

source/src/protocol.cpp:645–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

643}
644
645const char *disc_reason(int reason)
646{
647 static const char *prot[] = { "terminated by enet", "end of packet", "client num", "tag type", "duplicate connection", "overflow", "random", "voodoo", "sync", "auth failed" },
648 *refused[] = { "connection refused", "due to ban", "due to blacklisting", "wrong password", "server FULL", "server mastermode is \"private\"", "server overloaded" },
649 *removed[] = { "removed from server", "failed admin login", "inappropriate nickname", "annoyance limit exceeded", "SPAM", "DOS", "ludicrous speed", "fishslapped", "afk" },
650 *kick[] = { "kicked", "banned", "kicked by vote", "banned by vote", "kicked by server operator", "banned by server operator",
651 "auto kicked - teamkilling", "auto banned - teamkilling", "auto kicked - friendly fire", "auto banned - friendly fire", "auto kick", "auto ban" };
652 static string res;
653 const int prot_n = constarraysize(prot), ref_n = constarraysize(refused), rem_n = constarraysize(removed), kick_n = constarraysize(kick);
654 if(reason >= DISC_PROTOCOL && reason < DISC_REFUSED)
655 { // protocol related errors
656 if(reason < DISC_PROTOCOL + prot_n) return prot[reason];
657 else formatstring(res)("network protocol error '%d'", reason);
658 }
659 else if(reason >= DISC_REFUSED && reason < DISC_REMOVED)
660 { // connection refused
661 if(reason < DISC_REFUSED + ref_n) return refused[reason - DISC_REFUSED];
662 else formatstring(res)("connection refused '%d'", reason);
663 }
664 else if(reason >= DISC_REMOVED && reason < DISC_KICK)
665 { // player removed from server
666 if(reason < DISC_REMOVED + rem_n) return removed[reason - DISC_REMOVED];
667 else formatstring(res)("removed from server '%d'", reason);
668 }
669 else if(reason >= DISC_KICK && reason < DISC_UNKNOWN)
670 { // kicks & bans
671 reason -= DISC_KICK;
672 if(reason < kick_n) return kick[reason];
673 else formatstring(res)("%s '%d'", reason & 1 ? "banned" : "kicked", reason + DISC_KICK);
674 }
675 else
676 { // unknown reasons
677 formatstring(res)("unknown '%d'", reason);
678 }
679 return res;
680}
681

Callers 2

gets2cFunction · 0.85
disconnect_clientFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected