]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add an intrusive list for items
authorMario <mario@smbclan.net>
Sun, 21 Aug 2016 09:31:58 +0000 (19:31 +1000)
committerMario <mario@smbclan.net>
Sun, 21 Aug 2016 09:31:58 +0000 (19:31 +1000)
15 files changed:
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/mutators/mutator/buffs/sv_buffs.qc
qcsrc/common/t_items.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/cheats.qc
qcsrc/server/defs.qh
qcsrc/server/impulse.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/weapons/selection.qc

index 570bc3645fdbbe1104e201b0a2a94fce3a410e44..2af0dd010c3676ba80b7b804c140e0d51ddce9f9 100644 (file)
@@ -1182,7 +1182,7 @@ void havocbot_goalrating_ons_offenseitems(entity this, float ratingscale, vector
        LOG_DEBUG(this.netname, " needs armor ", ftos(needarmor));
 
        // See what is around
-       FOREACH_ENTITY_FLOAT(bot_pickup, true,
+       IL_EACH(g_items, it.bot_pickup,
        {
                // gather health and armor only
                if (it.solid)
index d9223b302a13b771f34e11b55c8bb7077e08f01c..73f6b63935f6999fc47cda077473659c5634220b 100644 (file)
@@ -345,6 +345,10 @@ void buff_Init(entity this)
        this.classname = "item_buff";
        this.solid = SOLID_TRIGGER;
        this.flags = FL_ITEM;
+       this.bot_pickup = true;
+       this.bot_pickupevalfunc = commodity_pickupevalfunc;
+       this.bot_pickupbasevalue = 1000;
+       IL_PUSH(g_items, this);
        setthink(this, buff_Think);
        settouch(this, buff_Touch);
        this.reset = buff_Reset;
@@ -822,7 +826,7 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink)
        if(player.buffs & BUFF_MAGNET.m_itemid)
        {
                vector pickup_size;
-               FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
+               IL_EACH(g_items, true,
                {
                        if(it.buffs)
                                pickup_size = '1 1 1' * autocvar_g_buffs_magnet_range_buff;
index ebc971141447e77c2a5a72ad18f11e05746b392b..507ba9e0b2ad4187c7c455f59d4e89abee036395 100644 (file)
@@ -880,9 +880,8 @@ void Item_FindTeam(entity this)
                // marker for item team search
                LOG_TRACE("Initializing item team ", ftos(this.team));
                RandomSelection_Init();
-               FOREACH_ENTITY_FLOAT(team, this.team,
+               IL_EACH(g_items, it.team == this.team,
                {
-                       if(it.flags & FL_ITEM)
                        if(it.classname != "item_flag_team" && it.classname != "item_key_team")
                                RandomSelection_Add(it, 0, string_null, it.cnt, 0);
                });
@@ -891,9 +890,8 @@ void Item_FindTeam(entity this)
                e.state = 0;
                Item_Show(e, 1);
 
-               FOREACH_ENTITY_FLOAT(team, this.team,
+               IL_EACH(g_items, it.team == this.team,
                {
-                       if(it.flags & FL_ITEM)
                        if(it.classname != "item_flag_team" && it.classname != "item_key_team")
                        {
                                if(it != e)
@@ -1076,6 +1074,7 @@ void _StartItem(entity this, entity def, float defaultrespawntime, float default
                this.weapons = WepSet_FromWeapon(Weapons_from(weaponid));
 
        this.flags = FL_ITEM | itemflags;
+       IL_PUSH(g_items, this);
 
        if(MUTATOR_CALLHOOK(FilterItem, this)) // error means we do not want the item
        {
index 8a689e05109086704ecf726a751aafea27463aee..717a002cbb86ed7aaf379978b023390a65173f1e 100644 (file)
@@ -90,6 +90,7 @@ void W_Porto_Fail(entity this, float failhard)
                if(move_out_of_solid(this))
                {
                        this.flags = FL_ITEM;
+                       IL_PUSH(g_items, this);
                        this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128);
                        tracetoss(this, this);
                        if(vdist(trace_endpos - this.realowner.origin, <, 128))
index 771ab282ddd49039f36fcfbed52a8cb24ccb18c1..04cf043ae547ced56edc56cc0bcd3d010413508d 100644 (file)
@@ -19,7 +19,7 @@ void havocbot_goalrating_items(entity this, float ratingscale, vector org, float
        vector o;
        ratingscale = ratingscale * 0.0001; // items are rated around 10000 already
 
-       FOREACH_ENTITY_FLOAT(bot_pickup, true,
+       IL_EACH(g_items, it.bot_pickup,
        {
                o = (it.absmin + it.absmax) * 0.5;
                friend_distance = 10000; enemy_distance = 10000;
index 8475640ac7086462ab73f087d6b8fc9603f285c5..efcd5ba3731243acd0260c36d43c0e451d856829 100644 (file)
@@ -1012,7 +1012,7 @@ void botframe_autowaypoints_fix(entity p, float walkfromwp, .entity fld)
 
 void botframe_deleteuselesswaypoints()
 {
-       FOREACH_ENTITY_FLOAT(bot_pickup, true,
+       IL_EACH(g_items, it.bot_pickup,
        {
                // NOTE: this protects waypoints if they're the ONLY nearest
                // waypoint. That's the intention.
index 71e0cd2e861805db6342b4203e39066b85ac39bc..185fe8fb4e0f3cf44f473f1c3526714995900a2b 100644 (file)
@@ -913,7 +913,7 @@ void Drag_Finish(entity dragger)
                        break;
        }
 
-       if((draggee.flags & FL_ITEM) && (vlen(draggee.velocity) < 32))
+       if((draggee.flags & FL_ITEM) && (vdist(draggee.velocity, <, 32)))
        {
                draggee.velocity = '0 0 0';
                SET_ONGROUND(draggee); // floating items are FUN
index a6bd1552d2250d7c0a2ee1895173586b4f9ab81f..e2e73c58d88ca53080800d423f88af2ffdf98a3a 100644 (file)
@@ -446,3 +446,6 @@ STATIC_INIT(g_mines) { g_mines = IL_NEW(); }
 
 IntrusiveList g_projectiles;
 STATIC_INIT(g_projectiles) { g_projectiles = IL_NEW(); }
+
+IntrusiveList g_items;
+STATIC_INIT(g_items) { g_items = IL_NEW(); }
index 4660a433ba543fee479e6c053a4d629d3a926ad5..d3b212700996c2d23d6e9fdb5182f9069dd73b91 100644 (file)
@@ -578,12 +578,12 @@ IMPULSE(navwaypoint_unreachable)
        if (j) LOG_INFOF("%d spawnpoints have no nearest waypoint (marked by player model)\n", j);
 
        j = 0;
-       FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
+       IL_EACH(g_items, true,
        {
                it.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
                it.colormod = '0.5 0.5 0.5';
        });
-       FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
+       IL_EACH(g_items, true,
        {
                if (navigation_findnearestwaypoint(it, false)) continue;
                LOG_INFO("item without waypoint: ", etos(it), " ", vtos(it.origin), "\n");
@@ -594,7 +594,7 @@ IMPULSE(navwaypoint_unreachable)
        if (j) LOG_INFOF("%d items have no nearest waypoint and cannot be walked away from (marked with red light)\n", j);
 
        j = 0;
-       FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
+       IL_EACH(g_items, true,
        {
                if (navigation_findnearestwaypoint(it, true)) continue;
                LOG_INFO("item without waypoint: ", etos(it), " ", vtos(it.origin), "\n");
index 58cd949297acefe1af5e3e48d65f8f098f6c58b4..c1288b5691b590c3776ade3c746ec9b4b3ffce32 100644 (file)
@@ -1206,10 +1206,15 @@ float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundma
                                break;
        if(!sp)
        {
-               for(sp = NULL; (sp = findflags(sp, flags, FL_ITEM)); )
-                       if(checkpvs(mstart, sp))
-                               if((traceline(mstart, sp.origin + (sp.mins + sp.maxs) * 0.5, MOVE_NORMAL, e), trace_fraction) >= 1)
-                                       break;
+               IL_EACH(g_items, checkpvs(mstart, it),
+               {
+                       if((traceline(mstart, it.origin + (it.mins + it.maxs) * 0.5, MOVE_NORMAL, e), trace_fraction) >= 1)
+                       {
+                               sp = it;
+                               break;
+                       }
+               });
+
                if(!sp)
                        continue;
        }
index 017fb265b9adc89fcb7aa5d63ab61d8c66e8dff6..79ac9994625de1b4a1f05da3ad540dee3d75d876 100644 (file)
@@ -1234,6 +1234,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e
        flag.classname = "item_flag_team";
        flag.target = "###item###"; // wut?
        flag.flags = FL_ITEM | FL_NOTARGET;
+       IL_PUSH(g_items, flag);
        flag.solid = SOLID_TRIGGER;
        flag.takedamage = DAMAGE_NO;
        flag.damageforcescale = autocvar_g_ctf_flag_damageforcescale;
@@ -1527,7 +1528,7 @@ void havocbot_goalrating_ctf_droppedflags(entity this, float ratingscale, vector
 
 void havocbot_goalrating_ctf_carrieritems(entity this, float ratingscale, vector org, float sradius)
 {
-       FOREACH_ENTITY_FLOAT(bot_pickup, true,
+       IL_EACH(g_items, it.bot_pickup,
        {
                // gather health and armor only
                if (it.solid)
index 6ad5d4849910f19f468c193dcd4c51707586cb28..1d229f3a338403202db1a6bd801a51da6638e475 100644 (file)
@@ -284,6 +284,7 @@ void dom_controlpoint_setup(entity this)
        settouch(this, dompointtouch);
        this.solid = SOLID_TRIGGER;
        this.flags = FL_ITEM;
+       IL_PUSH(g_items, this);
        setsize(this, '-32 -32 -32', '32 32 32');
        setorigin(this, this.origin + '0 0 20');
        droptofloor(this);
index a430ab5368b0fc92049d5b6e885ad7bee7d5402b..6fa76d6c5c1e140fb15382fffbd15118979f8b23 100644 (file)
@@ -451,6 +451,7 @@ void ka_SpawnBall() // loads various values for the ball, runs only once at star
        e.glow_color = autocvar_g_keepawayball_trail_color;
        e.glow_trail = true;
        e.flags = FL_ITEM;
+       IL_PUSH(g_items, e);
        e.pushable = true;
        e.reset = ka_Reset;
        settouch(e, ka_TouchEvent);
index 86d76e4312c87aff1aa80e8b3602fe020e84b18b..c4e17bf7cc57a611e649a404611eaee952fb9d54 100644 (file)
@@ -283,6 +283,7 @@ void kh_Key_Detach(entity key) // runs every time a key is dropped or lost. Runs
        key.angles_y += key.owner.angles.y;
 #endif
        key.flags = FL_ITEM;
+       IL_PUSH(g_items, key);
        key.solid = SOLID_TRIGGER;
        set_movetype(key, MOVETYPE_TOSS);
        key.pain_finished = time + autocvar_g_balance_keyhunt_delay_return;
index 8c6c0eaac6f4283f231ff11fc4438e22f523801f..56df6c3a2c47e615562c1bd190eba45241536c3f 100644 (file)
@@ -21,12 +21,10 @@ void Send_WeaponComplain(entity e, float wpn, float type)
 void Weapon_whereis(Weapon this, entity cl)
 {
        if (!autocvar_g_showweaponspawns) return;
-       FOREACH_ENTITY_FLOAT(weapon, this.m_id,
+       IL_EACH(g_items, it.weapon == this.m_id,
        {
                if (it.classname == "droppedweapon" && autocvar_g_showweaponspawns < 2)
                        continue;
-               if (!(it.flags & FL_ITEM))
-                       continue;
                entity wp = WaypointSprite_Spawn(
                        WP_Weapon,
                        -2, 0,