else
{
row = column = 0;
- // disabling new-style loop for now to restore original order of ammo types
- //FOREACH(Resources, it.instanceOfAmmoResource && !it.m_hidden,
- for(int j = 0; j < AMMO_COUNT; ++j)
+ IL_EACH(default_order_resources, it.instanceOfAmmoResource && !it.m_hidden,
{
- Resource ammotype = GetAmmoTypeFromNum(j);
DrawAmmoItem(
pos + vec2(column * (ammo_size.x + offset.x), row * (ammo_size.y + offset.y)),
ammo_size,
- ammotype,
- (wep.ammo_type == ammotype),
+ it,
+ (wep.ammo_type == it),
infinite_ammo
);
row = 0;
column = column + 1;
}
- }
+ });
}
if (draw_nades)
#define REGISTER_RESOURCE(id, inst) REGISTER(Resources, RES, id, m_id, inst)
REGISTRY(Resources, BITS(4));
REGISTER_REGISTRY(Resources)
+
+#ifdef CSQC
+// Copy Resources registry here before it gets sorted alphabetically by REGISTRY_SORT
+// so we can keep resources sorted by categories (as they appear in the code)
+IntrusiveList default_order_resources;
+STATIC_INIT(default_order_resources)
+{
+ default_order_resources = IL_NEW();
+ FOREACH(Resources, true, {
+ IL_PUSH(default_order_resources, it);
+ });
+}
+#endif
+
REGISTRY_SORT(Resources);
REGISTRY_CHECK(Resources);
}
#ifdef CSQC
-Resource GetAmmoTypeFromNum(int i)
-{
- switch (i)
- {
- case 0: return RES_SHELLS;
- case 1: return RES_BULLETS;
- case 2: return RES_ROCKETS;
- case 3: return RES_CELLS;
- case 4: return RES_PLASMA;
- case 5: return RES_FUEL;
- default: return RES_NONE;
- }
-}
-
int GetAmmoStat(Resource ammotype)
{
switch (ammotype)
entity GetAmmoItem(Resource ammotype);
#ifdef CSQC
-Resource GetAmmoTypeFromNum(int i);
-
int GetAmmoStat(Resource ammotype);
#endif