From 2f3856a7ffb72e1d8a86433450f80c6b0953eda9 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 25 Aug 2015 10:02:05 +1000 Subject: [PATCH] Fix itemstime regressions with hidespawned 0, panel displays all kind of items including ammo with hidespawned 0, there are free spots in the panel --- qcsrc/common/mutators/mutator/itemstime.qc | 23 +++++++++++----------- qcsrc/server/t_items.qc | 6 +++--- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index f0db281af..b90bd3c26 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -24,19 +24,18 @@ MUTATOR_HOOKFUNCTION(itemstime, CSQC_Parse_TempEntity) { } #endif -#ifdef SVQC - -bool Item_ItemsTime_Allow(entity e) +bool Item_ItemsTime_Allow(GameItem it, WepSet _weapons) { - GameItem it = e.itemdef; return (false || it.instanceOfPowerup || it == ITEM_ArmorMega || it == ITEM_ArmorLarge || it == ITEM_HealthMega || it == ITEM_HealthLarge - || (e.weapons & WEPSET_SUPERWEAPONS) + || (_weapons & WEPSET_SUPERWEAPONS) ); } +#ifdef SVQC + float it_times[MAX_ITEMS]; void Item_ItemsTime_Init() @@ -222,17 +221,19 @@ void HUD_ItemsTime() ItemsTime_time[ITEM_Shield.m_id] = time + 4; } - float i; - float count = 0; + int count = 0; if (autocvar_hud_panel_itemstime_hidespawned == 1) - for (i = 0; i < MAX_ITEMS; ++i) + FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( count += (ItemsTime_time[i] > time || -ItemsTime_time[i] > time); + )); else if (autocvar_hud_panel_itemstime_hidespawned == 2) - for (i = 0; i < MAX_ITEMS; ++i) + FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( count += (ItemsTime_time[i] > time); + )); else - for (i = 0; i < MAX_ITEMS; ++i) + FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( count += (ItemsTime_time[i] != -1); + )); if (count == 0) return; @@ -303,7 +304,7 @@ void HUD_ItemsTime() float row = 0, column = 0; bool item_available; - FOREACH(ITEMS, ItemsTime_time[i] != -1, LAMBDA( + FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0') && ItemsTime_time[i] != -1, LAMBDA( float item_time = ItemsTime_time[i]; if (item_time < -1) { diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 3c944619b..821399414 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -412,7 +412,7 @@ void Item_Think() } } -bool Item_ItemsTime_Allow(entity e); +bool Item_ItemsTime_Allow(GameItem it, WepSet _weapons); float Item_ItemsTime_UpdateTime(entity e, float t); void Item_ItemsTime_SetTime(entity e, float t); void Item_ItemsTime_SetTimesForAllPlayers(); @@ -429,7 +429,7 @@ void Item_Respawn (void) sound (self, CH_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTEN_NORM); // play respawn sound setorigin (self, self.origin); - if (Item_ItemsTime_Allow(self)) + if (Item_ItemsTime_Allow(self.itemdef, self.weapons)) { float t = Item_ItemsTime_UpdateTime(self, 0); Item_ItemsTime_SetTime(self, t); @@ -529,7 +529,7 @@ void Item_RespawnThink() void Item_ScheduleRespawnIn(entity e, float t) { - if (Item_ItemsTime_Allow(e)) + if (Item_ItemsTime_Allow(e.itemdef, e.weapons)) { e.think = Item_RespawnCountdown; e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS); -- 2.39.2