From c462a59f1d4d9ec5977a13ace77e8632cb003e3b Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 7 Oct 2015 11:43:57 +1100 Subject: [PATCH] Itemstime: fix regression introduced by 0c071920ffd10ccebde36092b7b91eb1673ae856 --- qcsrc/common/items/all.qh | 1 - qcsrc/common/items/inventory.qh | 14 +++++----- qcsrc/common/mutators/mutator/itemstime.qc | 30 +++++++++++----------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh index b2b0dc1e4..8097ab50f 100644 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@ -7,7 +7,6 @@ REGISTRY(Items, 24) REGISTER_REGISTRY(RegisterItems) /** If you register a new item, make sure to add it to all.inc */ #define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, Items, Items_COUNT, id, m_id, NEW(class)) -REGISTER_REGISTRY(RegisterItems) void Dump_Items(); diff --git a/qcsrc/common/items/inventory.qh b/qcsrc/common/items/inventory.qh index 64fa29cfc..ba137a8f9 100644 --- a/qcsrc/common/items/inventory.qh +++ b/qcsrc/common/items/inventory.qh @@ -15,11 +15,11 @@ class(Inventory) .int inv_items[Items_MAX]; void Inventory_Read(Inventory data) { const int bits = ReadInt24_t(); - FOREACH(Items, bits & BIT(i), LAMBDA( - .int fld = inv_items[i]; + FOREACH(Items, bits & BIT(it.m_id), LAMBDA( + .int fld = inv_items[it.m_id]; int prev = data.(fld); int next = data.(fld) = ReadByte(); - LOG_TRACEF("%s: %.0f -> %.0f\n", Items[i].m_name, prev, next); + LOG_TRACEF("%s: %.0f -> %.0f\n", it.m_name, prev, next); )); } #endif @@ -29,12 +29,12 @@ void Inventory_Write(Inventory data) { int bits = 0; FOREACH(Items, true, LAMBDA( - .int fld = inv_items[i]; - bits = BITSET(bits, BIT(i), data.inventory.(fld) != (data.inventory.(fld) = data.(fld))); + .int fld = inv_items[it.m_id]; + bits = BITSET(bits, BIT(it.m_id), data.inventory.(fld) != (data.inventory.(fld) = data.(fld))); )); WriteInt24_t(MSG_ENTITY, bits); - FOREACH(Items, bits & BIT(i), LAMBDA( - WriteByte(MSG_ENTITY, data.inv_items[i]); + FOREACH(Items, bits & BIT(it.m_id), LAMBDA( + WriteByte(MSG_ENTITY, data.inv_items[it.m_id]); )); } #endif diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index 1f17450e2..1d615b7c0 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -266,15 +266,15 @@ void HUD_ItemsTime() int count = 0; if (autocvar_hud_panel_itemstime_hidespawned == 1) FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( - count += (ItemsTime_time[i] > time || -ItemsTime_time[i] > time); + count += (ItemsTime_time[it.m_id] > time || -ItemsTime_time[it.m_id] > time); )); else if (autocvar_hud_panel_itemstime_hidespawned == 2) FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( - count += (ItemsTime_time[i] > time); + count += (ItemsTime_time[it.m_id] > time); )); else FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA( - count += (ItemsTime_time[i] != -1); + count += (ItemsTime_time[it.m_id] != -1); )); if (count == 0) return; @@ -346,8 +346,8 @@ void HUD_ItemsTime() float row = 0, column = 0; bool item_available; - FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0') && ItemsTime_time[i] != -1, LAMBDA( - float item_time = ItemsTime_time[i]; + FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0') && ItemsTime_time[it.m_id] != -1, LAMBDA( + float item_time = ItemsTime_time[it.m_id]; if (item_time < -1) { item_available = true; @@ -356,25 +356,25 @@ void HUD_ItemsTime() else item_available = (item_time <= time); - if (ItemsTime_time[i] >= 0) + if (ItemsTime_time[it.m_id] >= 0) { - if (time <= ItemsTime_time[i]) - ItemsTime_availableTime[i] = 0; - else if (ItemsTime_availableTime[i] == 0) - ItemsTime_availableTime[i] = time; + if (time <= ItemsTime_time[it.m_id]) + ItemsTime_availableTime[it.m_id] = 0; + else if (ItemsTime_availableTime[it.m_id] == 0) + ItemsTime_availableTime[it.m_id] = time; } - else if (ItemsTime_availableTime[i] == 0) - ItemsTime_availableTime[i] = time; + else if (ItemsTime_availableTime[it.m_id] == 0) + ItemsTime_availableTime[it.m_id] = time; - float f = (time - ItemsTime_availableTime[i]) * 2; + float f = (time - ItemsTime_availableTime[it.m_id]) * 2; f = (f > 1) ? 0 : bound(0, f, 1); if (autocvar_hud_panel_itemstime_hidespawned == 1) - if (!(ItemsTime_time[i] > time || -ItemsTime_time[i] > time)) + if (!(ItemsTime_time[it.m_id] > time || -ItemsTime_time[it.m_id] > time)) continue; if (autocvar_hud_panel_itemstime_hidespawned == 2) - if (!(ItemsTime_time[i] > time)) + if (!(ItemsTime_time[it.m_id] > time)) continue; DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, it, item_time, item_available, f); -- 2.39.2