]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/miscfunctions.qc
protected the current entity chain from remove() calls
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / miscfunctions.qc
index 32d9bc176012e912d9f316fe66c0b07b52c17f89..8bb269f4497e4d572cb38d21a4bb29a5d290baa4 100644 (file)
@@ -880,7 +880,9 @@ float want_weapon(string cvarprefix, entity weaponinfo, float allguns)
                        t = (weaponinfo.spawnflags & WEP_FLAG_NORMAL);
                else if(t < -1)
                        t = 0;
-               else if (g_race || g_cts)
+               else if (g_race)
+                       t = (i == WEP_LASER || i == WEP_SHOTGUN);
+               else if (g_cts)
                        t = (i == WEP_SHOTGUN);
                else if (g_nexball)
                        t = 0; // weapon is set a few lines later
@@ -1295,6 +1297,9 @@ void readlevelcvars(void)
        if (!g_weapon_stay && (cvar("deathmatch") == 2))
                g_weapon_stay = 1;
 
+       if (!g_weapon_stay && g_cts)
+               g_weapon_stay = 1;
+
        g_ghost_items = cvar("g_ghost_items");
 
        if(g_ghost_items >= 1)
@@ -1743,6 +1748,14 @@ void objerror(string s)
     objerror_builtin(s);
 }
 
+.float remove_except_protected_forbidden;
+void remove_except_protected(entity e)
+{
+       if(e.remove_except_protected_forbidden)
+               error("not allowed to remove this at this point");
+       remove_builtin(e);
+}
+
 void remove_unsafely(entity e)
 {
     remove_builtin(e);
@@ -1793,6 +1806,11 @@ void InitializeEntitiesRun()
     entity startoflist;
     startoflist = initialize_entity_first;
     initialize_entity_first = world;
+    remove = remove_except_protected;
+    for (self = startoflist; self; self = self.initialize_entity_next)
+    {
+       self.remove_except_protected_forbidden = 1;
+    }
     for (self = startoflist; self; )
     {
         entity e;
@@ -1802,6 +1820,7 @@ void InitializeEntitiesRun()
         self.initialize_entity_order = 0;
         self.initialize_entity = func_null;
         self.initialize_entity_next = world;
+       self.remove_except_protected_forbidden = 0;
         if (self.classname == "initialize_entity")
         {
             entity e_old;
@@ -1819,6 +1838,7 @@ void InitializeEntitiesRun()
         }
         self = e;
     }
+    remove = remove_unsafely;
 }
 
 .float uncustomizeentityforclient_set;