MCPcopy Create free account
hub / github.com/demoth/jake2 / ClientConnect

Method ClientConnect

game/src/main/java/jake2/game/PlayerClient.java:988–1048  ·  view source on GitHub ↗

Run checks before the clients is allowed to connect and then connect the client @return if client successfully connected

(SubgameEntity ent, String userinfo, GameExportsImpl gameExports)

Source from the content-addressed store, hash-verified

986 * @return if client successfully connected
987 */
988 static boolean ClientConnect(SubgameEntity ent, String userinfo, GameExportsImpl gameExports) {
989 // check to see if they are on the banned IP list
990 String ip = Info.Info_ValueForKey(userinfo, "ip");
991 if (GameSVCmds.SV_FilterPacket(ip, gameExports.gameCvars.filterban.value)) {
992 Info.Info_SetValueForKey(userinfo, "rejmsg", "Banned.");
993 return false;
994 }
995
996 // check for a spectator
997 String spectator = Info.Info_ValueForKey(userinfo, "spectator");
998 if (gameExports.gameCvars.deathmatch.value != 0 && spectator.length() != 0 && !"0".equals(spectator)) {
999
1000 // check for spectator password
1001 if (!passwdOK(gameExports.gameCvars.spectator_password.string, spectator)) {
1002 Info.Info_SetValueForKey(userinfo, "rejmsg", "Spectator password required or incorrect.");
1003 return false;
1004 }
1005
1006 // check spectators limit
1007 int numspec;
1008 for (int i = numspec = 0; i < gameExports.game.maxclients; i++) {
1009 gclient_t other = gameExports.g_edicts[i + 1].getClient();
1010 if (gameExports.g_edicts[i + 1].inuse && other.pers.spectator)
1011 numspec++;
1012 }
1013
1014 if (numspec >= gameExports.gameCvars.maxspectators.value) {
1015 Info.Info_SetValueForKey(userinfo, "rejmsg", "Server spectator limit is full.");
1016 return false;
1017 }
1018 } else {
1019 // check for a password
1020 String password = Info.Info_ValueForKey(userinfo, "password");
1021 if (!passwdOK(gameExports.gameCvars.spectator_password.string, password)) {
1022 Info.Info_SetValueForKey(userinfo, "rejmsg", "Password required or incorrect.");
1023 return false;
1024 }
1025 }
1026
1027 // they can connect
1028 ent.setClient(gameExports.game.clients[ent.index - 1]);
1029
1030 // if there is already a body waiting for us (a loadgame), just
1031 // take it, otherwise spawn one from scratch
1032 gclient_t client = ent.getClient();
1033 if (!ent.inuse) {
1034 // clear the respawning variables
1035 client.InitClientResp(gameExports);
1036 if (!gameExports.game.autosaved || null == client.pers.weapon)
1037 InitClientPersistant(client, gameExports);
1038 }
1039
1040 ClientUserinfoChanged(ent, userinfo, gameExports);
1041
1042 if (gameExports.game.maxclients > 1)
1043 gameExports.gameImports.dprintf(client.pers.netname + " connected\n");
1044
1045 ent.svflags = 0; // make sure we start with known default

Callers 1

ClientConnectMethod · 0.95

Calls 11

Info_ValueForKeyMethod · 0.95
SV_FilterPacketMethod · 0.95
Info_SetValueForKeyMethod · 0.95
passwdOKMethod · 0.95
InitClientRespMethod · 0.95
InitClientPersistantMethod · 0.95
ClientUserinfoChangedMethod · 0.95
setClientMethod · 0.80
dprintfMethod · 0.65
equalsMethod · 0.45
getClientMethod · 0.45

Tested by

no test coverage detected