]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an intrusive list for monsters
authorMario <mario@smbclan.net>
Wed, 27 Jul 2016 17:00:28 +0000 (03:00 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 28 Jul 2016 09:57:49 +0000 (19:57 +1000)
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/server/_all.qh
qcsrc/server/command/common.qc
qcsrc/server/defs.qh
qcsrc/server/g_subs.qc
qcsrc/server/g_world.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc
qcsrc/server/weapons/tracing.qc

index ae7dc51570700f2124e6ba7f6b3cbd8daf3fba2e..2855ac4298fccb8db88cbb9a74ad8eee1057ff62 100644 (file)
@@ -1290,6 +1290,8 @@ bool Monster_Spawn(entity this, int mon_id)
 
        if(!autocvar_g_monsters) { Monster_Remove(this); return false; }
 
+       IL_PUSH(g_monsters, this);
+
        if(Monster_Appear_Check(this, mon_id)) { return true; } // return true so the monster isn't removed
 
        if(!this.monster_skill)
index 9536605948a4b42b637a826e4f317c50091c64e2..d464da57068043f5ba38fc8223d5d558b441917f 100644 (file)
@@ -407,9 +407,9 @@ void W_Shockwave_Attack(entity actor)
        if(lag)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_takeback(it, CS(it), time - lag));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if (it != actor)
-                               antilag_takeback(it, it, time - lag);
+               IL_EACH(g_monsters, it != actor,
+               {
+                       antilag_takeback(it, it, time - lag);
                });
        }
 
@@ -687,9 +687,9 @@ void W_Shockwave_Attack(entity actor)
        if(lag)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && it != actor, antilag_restore(it, CS(it)));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if (it != actor)
-                               antilag_restore(it, it);
+               IL_EACH(g_monsters, it != actor,
+               {
+                       antilag_restore(it, it);
                });
        }
 }
index a32f8b5832cf01e9ecccc534be2d794d6672118f..ed3083a1203fd94c69943efb17341c80c45127d1 100644 (file)
@@ -43,7 +43,7 @@ const string STR_OBSERVER = "observer";
 
 #define FOREACH_CLIENT(cond, body) FOREACH_CLIENTSLOT(IS_CLIENT(it) && (cond), body)
 
-// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, { code; });
+// NOTE: FOR_EACH_MONSTER deprecated! Use the following instead: IL_EACH(g_monsters, true, { code; });
 
 #include <common/effects/all.qh>
 #include <common/models/all.qh>
index 3c97737e541d559ab13723d0091a6d361986adcd..81dc1a60ea1549d58c4f909b03ff2cbee4b030f6 100644 (file)
@@ -364,10 +364,10 @@ void CommonCommand_editmob(int request, entity caller, int argc)
 
                                        if (arg_lower == "list") { print_to(caller, monsterlist_reply); return; }
 
-                                       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
-                                               if(it.realowner == caller)
-                                                       ++tmp_moncount;
-                                       ));
+                                       IL_EACH(g_monsters, it.realowner == caller,
+                                       {
+                                               ++tmp_moncount;
+                                       });
 
                                        if (!autocvar_g_monsters) { print_to(caller, "Monsters are disabled"); return; }
                                        if (autocvar_g_monsters_max <= 0 || autocvar_g_monsters_max_perplayer <= 0) { print_to(caller, "Monster spawning is disabled"); return; }
@@ -436,10 +436,12 @@ void CommonCommand_editmob(int request, entity caller, int argc)
 
                                        int tmp_remcount = 0;
 
-                                       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
+                                       IL_EACH(g_monsters, true,
+                                       {
                                                Monster_Remove(it);
                                                ++tmp_remcount;
-                                       ));
+                                       });
+                                       IL_CLEAR(g_monsters);
 
                                        monsters_total = monsters_killed = totalspawned = 0;
 
index df791a62627fa7986966e1e3d15b94334bef1a07..30c9bb44949d8b5ca413a574e46eb17005020ae9 100644 (file)
@@ -443,3 +443,6 @@ const int MIF_GUIDED_CONFUSABLE = MIF_GUIDED_HEAT | MIF_GUIDED_AI;
 
 .bool init_for_player_needed;
 .void(entity this, entity player) init_for_player;
+
+IntrusiveList g_monsters;
+STATIC_INIT(g_monsters) { g_monsters = IL_NEW(); }
index f3fb1a3224ad9ebd186bdd630476baa733b6e980..e4affe265f8b7dd768089358b36198fa027c1ce1 100644 (file)
@@ -51,9 +51,9 @@ void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma,
        {
                // take players back into the past
                FOREACH_CLIENT(IS_PLAYER(it) && it != forent, antilag_takeback(it, CS(it), time - lag));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if(it != forent)
-                               antilag_takeback(it, it, time - lag);
+               IL_EACH(g_monsters, it != forent,
+               {
+                       antilag_takeback(it, it, time - lag);
                });
        }
 
@@ -67,9 +67,9 @@ void tracebox_antilag_force_wz (entity source, vector v1, vector mi, vector ma,
        if (lag)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && it != forent, antilag_restore(it, CS(it)));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if (it != forent)
-                               antilag_restore(it, it);
+               IL_EACH(g_monsters, it != forent,
+               {
+                       antilag_restore(it, it);
                });
        }
 
index 2eff929b8b9828c58aafa1ff9cea5eb5593e4744..5102aecdf69e6ff2dd931611274a2630db91897a 100644 (file)
@@ -2051,7 +2051,8 @@ void EndFrame()
                it.damage_dealt = 0;
                antilag_record(it, CS(it), altime);
        });
-       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
+       IL_EACH(g_monsters, true,
+       {
                antilag_record(it, it, altime);
        });
        FOREACH_CLIENT(PS(it), {
index 9d31506e6dfe77134f2dcf8fb225fa1e2a53f475..ffbd29cdfa6a375ef0b49f954c8552364b609e63 100644 (file)
@@ -193,7 +193,11 @@ float Invasion_CheckWinner()
 {
        if(round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0)
        {
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(Monster_Remove(it)));
+               IL_EACH(g_monsters, true,
+               {
+                       Monster_Remove(it);
+               });
+               IL_CLEAR(g_monsters);
 
                Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER);
                Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER);
@@ -203,23 +207,21 @@ float Invasion_CheckWinner()
 
        float total_alive_monsters = 0, supermonster_count = 0, red_alive = 0, blue_alive = 0, yellow_alive = 0, pink_alive = 0;
 
-       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(
-               if(it.health > 0)
-               {
-                       if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
-                               ++supermonster_count;
-                       ++total_alive_monsters;
+       IL_EACH(g_monsters, it.health > 0,
+       {
+               if((get_monsterinfo(it.monsterid)).spawnflags & MON_FLAG_SUPERMONSTER)
+                       ++supermonster_count;
+               ++total_alive_monsters;
 
-                       if(teamplay)
-                       switch(it.team)
-                       {
-                               case NUM_TEAM_1: ++red_alive; break;
-                               case NUM_TEAM_2: ++blue_alive; break;
-                               case NUM_TEAM_3: ++yellow_alive; break;
-                               case NUM_TEAM_4: ++pink_alive; break;
-                       }
+               if(teamplay)
+               switch(it.team)
+               {
+                       case NUM_TEAM_1: ++red_alive; break;
+                       case NUM_TEAM_2: ++blue_alive; break;
+                       case NUM_TEAM_3: ++yellow_alive; break;
+                       case NUM_TEAM_4: ++pink_alive; break;
                }
-       ));
+       });
 
        if((total_alive_monsters + inv_numkilled) < inv_maxspawned && inv_maxcurrent < inv_maxspawned)
        {
@@ -272,7 +274,11 @@ float Invasion_CheckWinner()
                ));
        }
 
-       FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, LAMBDA(Monster_Remove(it)));
+       IL_EACH(g_monsters, true,
+       {
+               Monster_Remove(it);
+       });
+       IL_CLEAR(g_monsters);
 
        if(teamplay)
        {
index 5c64a0ec64d3ff6e89f5d7f2efbf8d0ac7383355..6e7279618cc497a2b0ae99d6baa6785a112851bd 100644 (file)
@@ -377,9 +377,9 @@ void fireBullet(entity this, vector start, vector dir, float spread, float max_s
        if(lag)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && it != this, antilag_takeback(it, CS(it), time - lag));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if (it != this)
-                               antilag_takeback(it, it, time - lag);
+               IL_EACH(g_monsters, it != this,
+               {
+                       antilag_takeback(it, it, time - lag);
                });
        }
 
@@ -492,9 +492,9 @@ void fireBullet(entity this, vector start, vector dir, float spread, float max_s
        if(lag)
        {
                FOREACH_CLIENT(IS_PLAYER(it) && it != this, antilag_restore(it, CS(it)));
-               FOREACH_ENTITY_FLAGS(flags, FL_MONSTER, {
-                       if (it != this)
-                               antilag_restore(it, it);
+               IL_EACH(g_monsters, it != this,
+               {
+                       antilag_restore(it, it);
                });
        }