void Dump_Items()
{
- FOREACH(ITEMS, true, LAMBDA(
+ FOREACH(Items, true, LAMBDA(
ITEM_HANDLE(Show, it);
));
}
#ifndef ITEMS_ALL_H
#define ITEMS_ALL_H
-void RegisterItems();
-const int MAX_ITEMS = 24;
-entity ITEMS[MAX_ITEMS], ITEMS_first, ITEMS_last;
-int ITEM_COUNT;
+#include "item.qh"
+
+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, ITEM_COUNT, id, m_id, NEW(class))
+#define REGISTER_ITEM(id, class) REGISTER(RegisterItems, ITEM, Items, Items_COUNT, id, m_id, NEW(class))
REGISTER_REGISTRY(RegisterItems)
void Dump_Items();
entityclass(Inventory);
/** Stores counts of items, the id being the index */
-class(Inventory) .int inv_items[MAX_ITEMS];
+class(Inventory) .int inv_items[Items_MAX];
/** Player inventory; Inventories also have one inventory for storing the previous state */
.Inventory inventory;
void Inventory_Read(Inventory data)
{
const int bits = ReadInt24_t();
- FOREACH(ITEMS, bits & BIT(i), LAMBDA(
+ FOREACH(Items, bits & BIT(i), LAMBDA(
.int fld = inv_items[i];
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", Items[i].m_name, prev, next);
));
}
#endif
void Inventory_Write(Inventory data)
{
int bits = 0;
- FOREACH(ITEMS, true, LAMBDA(
+ FOREACH(Items, true, LAMBDA(
.int fld = inv_items[i];
bits = BITSET(bits, BIT(i), data.inventory.(fld) != (data.inventory.(fld) = data.(fld)));
));
WriteInt24_t(MSG_ENTITY, bits);
- FOREACH(ITEMS, bits & BIT(i), LAMBDA(
+ FOREACH(Items, bits & BIT(i), LAMBDA(
WriteByte(MSG_ENTITY, data.inv_items[i]);
));
}
#endif
#ifdef CSQC
-float ItemsTime_time[MAX_ITEMS];
-float ItemsTime_availableTime[MAX_ITEMS];
+float ItemsTime_time[Items_MAX];
+float ItemsTime_availableTime[Items_MAX];
MUTATOR_HOOKFUNCTION(itemstime, CSQC_Parse_TempEntity) {
if (MUTATOR_RETURNVALUE) return false;
if (!ReadMutatorEquals(mutator_argv_int_0, itemstime)) return false;
#ifdef SVQC
-float it_times[MAX_ITEMS];
+float it_times[Items_MAX];
void Item_ItemsTime_Init()
{
- FOREACH(ITEMS, true, LAMBDA(
+ FOREACH(Items, true, LAMBDA(
it_times[it.m_id] = -1;
));
}
void Item_ItemsTime_ResetTimes()
{
- FOREACH(ITEMS, true, LAMBDA(
+ FOREACH(Items, true, LAMBDA(
it_times[it.m_id] = (it_times[it.m_id] == -1) ? -1 : 0;
));
}
void Item_ItemsTime_ResetTimesForPlayer(entity e)
{
- FOREACH(ITEMS, true, LAMBDA(
+ FOREACH(Items, true, LAMBDA(
IT_Write(e, it.m_id, (it_times[it.m_id] == -1) ? -1 : 0);
));
}
void Item_ItemsTime_SetTimesForPlayer(entity e)
{
- FOREACH(ITEMS, true, LAMBDA(
+ FOREACH(Items, true, LAMBDA(
IT_Write(e, it.m_id, it_times[it.m_id]);
));
}
int count = 0;
if (autocvar_hud_panel_itemstime_hidespawned == 1)
- FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA(
+ 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)
- FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA(
count += (ItemsTime_time[i] > time);
));
else
- FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA(
+ FOREACH(Items, Item_ItemsTime_Allow(it, '0 0 0'), LAMBDA(
count += (ItemsTime_time[i] != -1);
));
if (count == 0)
float row = 0, column = 0;
bool item_available;
- FOREACH(ITEMS, Item_ItemsTime_Allow(it, '0 0 0') && 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)
{
if (get_weaponinfo(self.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
return 2;
}
- if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_waypointblink;
+ if (s == WP_Item.netname) return Items[self.wp_extra].m_waypointblink;
return 1;
}
vector spritelookupcolor(string s, vector def)
{SELFPARAM();
if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).wpcolor;
- if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_color;
+ if (s == WP_Item.netname) return Items[self.wp_extra].m_color;
if (s == WP_Buff.netname) return BUFFS[self.wp_extra].m_color;
return def;
}
{SELFPARAM();
if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
if (s == WP_Weapon.netname) return get_weaponinfo(self.wp_extra).message;
- if (s == WP_Item.netname) return ITEMS[self.wp_extra].m_waypoint;
+ if (s == WP_Item.netname) return Items[self.wp_extra].m_waypoint;
if (s == WP_Buff.netname) return BUFFS[self.wp_extra].m_prettyName;
if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;