From: Samual Lenks Date: Tue, 26 Feb 2013 16:26:47 +0000 (-0500) Subject: New way to check if server is local or dedicated in code X-Git-Tag: xonotic-v0.7.0~62^2~23^2~107 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bf2a17d163117cacd806fc245cfad514fe4f6559;p=xonotic%2Fxonotic-data.pk3dir.git New way to check if server is local or dedicated in code --- diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 07a6942ae..277f0dd16 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1375,16 +1375,6 @@ void ClientConnect (void) self.flags = FL_CLIENT; self.version_nagtime = time + 10 + random() * 10; - if(self.netaddress == "local") - { - //print("^3server is local!\n"); - - if(server_is_local) - error("Multiple local clients???"); - else - server_is_local = TRUE; - } - if(player_count<0) { dprint("BUG player count is lower than zero, this cannot happen!\n"); diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 71fda2ea9..25f00a739 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -57,7 +57,9 @@ float team1_score, team2_score, team3_score, team4_score; float maxclients; -float server_is_local; // innocent until proven guilty by ClientConnect() in cl_client.qc +// flags set on worldspawn so that the code knows if it is dedicated or not +float server_is_dedicated; +float server_is_local; // Fields diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 4589639cd..8ff2ac8a5 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -555,6 +555,8 @@ void spawnfunc___init_dedicated_server(void) MapInfo_Enumerate(); MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0); + + print("^1YO SAMUAL, CHECK THIS SHIT OUT MOTHERFUCKER! _init spawnfunc was called!\n"); } void Map_MarkAsRecent(string m); @@ -595,6 +597,17 @@ void spawnfunc_worldspawn (void) head = nextent(head); } + if(cvar_defstring("is_dedicated")) + { + server_is_dedicated = TRUE; + server_is_local = FALSE; + } + else + { + server_is_dedicated = FALSE; + server_is_local = TRUE; + } + // needs to be done so early because of the constants they create CALL_ACCUMULATED_FUNCTION(RegisterWeapons); CALL_ACCUMULATED_FUNCTION(RegisterGametypes);