]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_world.qc
Merge branch 'TimePath/bot_api' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_world.qc
index 3233f241a45ca454f758ae6727f7aacc5e5c91b2..b202f284f6b664903899c35c0514824928592481 100644 (file)
@@ -3,7 +3,6 @@
 
 #include "anticheat.qh"
 #include "antilag.qh"
-#include "bot/bot.qh"
 #include "campaign.qh"
 #include "cheats.qh"
 #include "cl_client.qh"
 #include "scores.qh"
 #include "teamplay.qh"
 #include "weapons/weaponstats.qh"
-#include "../common/buffs.qh"
+#include "../common/buffs/all.qh"
 #include "../common/constants.qh"
 #include "../common/deathtypes.qh"
-#include "../common/effects.qh"
+#include "../common/effects/effects.qh"
 #include "../common/mapinfo.qh"
 #include "../common/monsters/all.qh"
 #include "../common/monsters/sv_monsters.qh"
@@ -512,8 +511,8 @@ void detect_maptype()
 }
 
 entity randomseed;
-float RandomSeed_Send(entity to, int sf)
-{SELFPARAM();
+bool RandomSeed_Send(entity this, entity to, int sf)
+{
        WriteByte(MSG_ENTITY, ENT_CLIENT_RANDOMSEED);
        WriteShort(MSG_ENTITY, self.cnt);
        return true;
@@ -531,15 +530,11 @@ void RandomSeed_Spawn()
        randomseed.think = RandomSeed_Think;
        Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
 
-       entity oldself;
-       oldself = self;
-       self = randomseed;
-       self.think(); // sets random seed and nextthink
-       self = oldself;
+       WITH(entity, self, randomseed, randomseed.think()); // sets random seed and nextthink
 }
 
-void spawnfunc___init_dedicated_server(void)
-{SELFPARAM();
+spawnfunc(__init_dedicated_server)
+{
        // handler for _init/_init map (only for dedicated server initialization)
 
        world_initialized = -1; // don't complain
@@ -561,7 +556,6 @@ void spawnfunc___init_dedicated_server(void)
 
        // needs to be done so early because of the constants they create
        static_init();
-       CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
 
@@ -576,8 +570,8 @@ void ClientInit_Spawn();
 void WeaponStats_Init();
 void WeaponStats_Shutdown();
 void Physics_AddStats();
-void spawnfunc_worldspawn (void)
-{SELFPARAM();
+spawnfunc(worldspawn)
+{
        float fd, l, j, n;
        string s;
 
@@ -608,12 +602,9 @@ void spawnfunc_worldspawn (void)
 
        // needs to be done so early because of the constants they create
        static_init();
-       CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
        CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
        CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
 
-       initialize_minigames();
-
        ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid));
 
        TemporaryDB = db_create();
@@ -666,7 +657,6 @@ void spawnfunc_worldspawn (void)
 
        PlayerStats_GameReport_Init(); // we need this to be initiated before InitGameplayMode
 
-       precache_model ("null"); // we need this one before InitGameplayMode
        InitGameplayMode();
        readlevelcvars();
        GrappleHookInit();
@@ -697,10 +687,6 @@ void spawnfunc_worldspawn (void)
                MUTATOR_CALLHOOK(BuildMutatorsString, s);
                s = ret_string;
 
-               // simple, probably not good in the mutator system
-               if(autocvar_g_grappling_hook)
-                       s = strcat(s, ":grappling_hook");
-
                // initialiation stuff, not good in the mutator system
                if(!autocvar_g_use_ammunition)
                        s = strcat(s, ":no_use_ammunition");
@@ -925,8 +911,8 @@ void spawnfunc_worldspawn (void)
        world_initialized = 1;
 }
 
-void spawnfunc_light (void)
-{SELFPARAM();
+spawnfunc(light)
+{
        //makestatic (self); // Who the f___ did that?
        remove(self);
 }
@@ -1013,22 +999,6 @@ string Map_Filename(float position)
        return strcat("maps/", argv(position), ".bsp");
 }
 
-string strwords(string s, float w)
-{
-       float endpos;
-       for(endpos = 0; w && endpos >= 0; --w)
-               endpos = strstrofs(s, " ", endpos + 1);
-       if(endpos < 0)
-               return s;
-       else
-               return substring(s, 0, endpos);
-}
-
-float strhasword(string s, string w)
-{
-       return strstrofs(strcat(" ", s, " "), strcat(" ", w, " "), 0) >= 0;
-}
-
 void Map_MarkAsRecent(string m)
 {
        cvar_set("g_maplist_mostrecent", strwords(strcat(m, " ", autocvar_g_maplist_mostrecent), max(0, autocvar_g_maplist_mostrecent_count)));
@@ -1727,11 +1697,7 @@ float WinningCondition_Assault()
                        }
                        else
                        {
-                               entity oldself;
-                               oldself = self;
-                               self = ent;
-                               assault_new_round();
-                               self = oldself;
+                               WITH(entity, self, ent, assault_new_round());
                        }
                }
        }
@@ -2206,15 +2172,16 @@ void EndFrame()
        anticheat_endframe();
 
        float altime;
-       FOR_EACH_REALCLIENT(self)
+       entity e_;
+       FOR_EACH_REALCLIENT(e_)
        {
-               entity e = IS_SPEC(self) ? self.enemy : self;
+               entity e = IS_SPEC(e_) ? e_.enemy : e_;
                if(e.typehitsound)
-                       self.typehit_time = time;
+                       e_.typehit_time = time;
                else if(e.damage_dealt)
                {
-                       self.hit_time = time;
-                       self.damage_dealt_total += ceil(e.damage_dealt);
+                       e_.hit_time = time;
+                       e_.damage_dealt_total += ceil(e.damage_dealt);
                }
        }
        altime = time + frametime * (1 + autocvar_g_antilag_nudge);
@@ -2223,14 +2190,18 @@ void EndFrame()
        // add another frametime because client shows everything with
        // 1 frame of lag (cl_nolerp 0). The last +1 however should not be
        // needed!
-       FOR_EACH_CLIENT(self)
+       FOR_EACH_CLIENT(e_)
        {
-               self.typehitsound = false;
-               self.damage_dealt = 0;
-               antilag_record(self, altime);
+               e_.typehitsound = false;
+               e_.damage_dealt = 0;
+               setself(e_);
+               antilag_record(e_, altime);
+       }
+       FOR_EACH_MONSTER(e_)
+       {
+               setself(e_);
+               antilag_record(e_, altime);
        }
-       FOR_EACH_MONSTER(self)
-               antilag_record(self, altime);
 }
 
 
@@ -2263,8 +2234,10 @@ float RedirectionThink()
        redirection_nextthink = time + 1;
 
        clients_found = 0;
-       FOR_EACH_REALCLIENT(self)
+       entity e;
+       FOR_EACH_REALCLIENT(e)
        {
+               setself(e);
                // TODO add timer
                LOG_INFO("Redirecting: sending connect command to ", self.netname, "\n");
                if(redirection_target == "self")