From: Mario Date: Sun, 21 Aug 2016 09:31:58 +0000 (+1000) Subject: Add an intrusive list for items X-Git-Tag: xonotic-v0.8.2~663^2~31 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=a3a702a1a9fdd00ead6d0b88a55a9299c8d39707;p=xonotic%2Fxonotic-data.pk3dir.git Add an intrusive list for items --- diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 570bc3645..2af0dd010 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index d9223b302..73f6b6393 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -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; diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index ebc971141..507ba9e0b 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -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 { diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 8a689e051..717a002cb 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -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)) diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 771ab282d..04cf043ae 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -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; diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 8475640ac..efcd5ba37 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -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. diff --git a/qcsrc/server/cheats.qc b/qcsrc/server/cheats.qc index 71e0cd2e8..185fe8fb4 100644 --- a/qcsrc/server/cheats.qc +++ b/qcsrc/server/cheats.qc @@ -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 diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index a6bd1552d..e2e73c58d 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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(); } diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index 4660a433b..d3b212700 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -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"); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 58cd94929..c1288b569 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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; } diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 017fb265b..79ac99946 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -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) diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 6ad5d4849..1d229f3a3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -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); diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index a430ab536..6fa76d6c5 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -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); diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index 86d76e431..c4e17bf7c 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -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; diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 8c6c0eaac..56df6c3a2 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -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,