float bonusNades = getstatf(STAT_NADE_BONUS);
float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE);
float bonusType = getstati(STAT_NADE_BONUS_TYPE);
- vector nadeColor = Nades[bonusType].m_color;
- string nadeIcon = Nades[bonusType].m_icon;
+ Nade def = Nades_from(bonusType);
+ vector nadeColor = def.m_color;
+ string nadeIcon = def.m_icon;
vector iconPos, textPos;
drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
}
}
- entity icon = RadarIcons[tm.teamradar_icon];
+ entity icon = RadarIcons_from(tm.teamradar_icon);
draw_teamradar_icon(tm.origin, icon, tm, spritelookupcolor(tm, icon.netname, tm.teamradar_color), panel_fg_alpha);
}
for(tm = world; (tm = find(tm, classname, "entcs_receiver")); )
hud_draw_maximized = 0;
// draw panels in the order specified by panel_order array
for(i = hud_panels_COUNT - 1; i >= 0; --i)
- HUD_Panel_Draw(hud_panels[panel_order[i]]);
+ HUD_Panel_Draw(hud_panels_from(panel_order[i]));
HUD_Vehicle();
void HUD_Radar_Mouse();
REGISTRY(hud_panels, BITS(6))
+#define hud_panels_from(i) _hud_panels_from(i, NULL)
REGISTER_REGISTRY(Registerhud_panels)
#define REGISTER_HUD_PANEL(id, draw_func, name, configflags, showflags) \
// common cvars for all panels
for (int i = 0; i < hud_panels_COUNT; ++i)
{
- panel = hud_panels[i];
+ panel = hud_panels_from(i);
HUD_Write_PanelCvar_n("");
HUD_Write_PanelCvar_q("_pos");
vector myTarget = myPos;
int i;
for (i = 0; i < hud_panels_COUNT; ++i) {
- panel = hud_panels[i];
+ panel = hud_panels_from(i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
if(panel == highlightedPanel) continue;
HUD_Panel_UpdatePosSize();
float ratio = mySize.x/mySize.y;
int i;
for (i = 0; i < hud_panels_COUNT; ++i) {
- panel = hud_panels[i];
+ panel = hud_panels_from(i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
if(panel == highlightedPanel) continue;
HUD_Panel_UpdatePosSize();
{
for(i = 0; i < hud_panels_COUNT; ++i)
{
- panel = hud_panels[i];
+ panel = hud_panels_from(i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
continue;
if (panel == tab_panels[i] || panel == starting_panel)
i = panel_order[j];
j += 1;
- panel = hud_panels[i];
+ panel = hud_panels_from(i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
HUD_Panel_UpdatePosSize();
i = panel_order[j];
j += 1;
- panel = hud_panels[i];
+ panel = hud_panels_from(i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN))
continue;
HUD_Panel_UpdatePosSize();
// move
if(allow_move && mousepos.x > panel_pos.x && mousepos.y > panel_pos.y && mousepos.x < panel_pos.x + panel_size.x && mousepos.y < panel_pos.y + panel_size.y)
{
- highlightedPanel = hud_panels[i];
+ highlightedPanel = hud_panels_from(i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 1;
panel_click_distance = mousepos - panel_pos;
// resize from topleft border
else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
{
- highlightedPanel = hud_panels[i];
+ highlightedPanel = hud_panels_from(i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 1;
// resize from topright border
else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y - border && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + 0.5 * panel_size.y)
{
- highlightedPanel = hud_panels[i];
+ highlightedPanel = hud_panels_from(i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 2;
// resize from bottomleft border
else if(mousepos.x >= panel_pos.x - border && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + 0.5 * panel_size.x && mousepos.y <= panel_pos.y + panel_size.y + border)
{
- highlightedPanel = hud_panels[i];
+ highlightedPanel = hud_panels_from(i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 3;
// resize from bottomright border
else if(mousepos.x >= panel_pos.x + 0.5 * panel_size.x && mousepos.y >= panel_pos.y + 0.5 * panel_size.y && mousepos.x <= panel_pos.x + panel_size.x + border && mousepos.y <= panel_pos.y + panel_size.y + border)
{
- highlightedPanel = hud_panels[i];
+ highlightedPanel = hud_panels_from(i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 4;
setcursormode(1);
hudShiftState = 0;
for(i = hud_panels_COUNT - 1; i >= 0; --i)
- hud_panels[panel_order[i]].update_time = time;
+ hud_panels_from(panel_order[i]).update_time = time;
}
// NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
if (this.traileffect)
{
particles_alphamin = particles_alphamax = particles_fade = sqrt(this.alpha);
- boxparticles(particleeffectnum(Effects[this.traileffect]), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
+ boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
}
}
#include "../util.qh"
REGISTRY(Buffs, BITS(4))
+#define Buffs_from(i) _Buffs_from(i, BUFF_Null)
REGISTER_REGISTRY(RegisterBuffs)
#define REGISTER_BUFF(id) \
#include "command.qh"
REGISTRY(GENERIC_COMMANDS, BITS(7))
+#define GENERIC_COMMANDS_from(i) _GENERIC_COMMANDS_from(i, NULL)
REGISTER_REGISTRY(RegisterGENERIC_COMMANDS)
REGISTRY_SORT(GENERIC_COMMANDS, m_name, 0)
string Deathtype_Name(int deathtype)
{
if (DEATH_ISSPECIAL(deathtype)) {
- entity deathent = Deathtypes[deathtype - DT_FIRST];
+ entity deathent = Deathtypes_from(deathtype - DT_FIRST);
if (!deathent) { backtrace("Deathtype_Name: Could not find deathtype entity!\n"); return ""; }
return deathent.nent_name;
}
#include "../notifications.qh"
REGISTRY(Deathtypes, BITS(8))
+#define Deathtypes_from(i) _Deathtypes_from(i, NULL)
REGISTER_REGISTRY(RegisterDeathtypes)
.entity death_msgself;
const int DT_FIRST = BIT(13);
#define DEATH_ISSPECIAL(t) (t >= DT_FIRST)
-#define DEATH_IS(t, dt) (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]) == dt)
-#define DEATH_ENT(t) (DEATH_ISSPECIAL(t) ? (Deathtypes[t - DT_FIRST]) : NULL)
-#define DEATH_ISVEHICLE(t) (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]).death_msgextra == "vehicle")
-#define DEATH_ISTURRET(t) (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]).death_msgextra == "turret")
-#define DEATH_ISMONSTER(t) (DEATH_ISSPECIAL(t) && (Deathtypes[t - DT_FIRST]).death_msgextra == "monster")
+#define DEATH_IS(t, dt) (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)) == dt)
+#define DEATH_ENT(t) (DEATH_ISSPECIAL(t) ? (Deathtypes_from(t - DT_FIRST)) : NULL)
+#define DEATH_ISVEHICLE(t) (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "vehicle")
+#define DEATH_ISTURRET(t) (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "turret")
+#define DEATH_ISMONSTER(t) (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "monster")
#define DEATH_WEAPONOF(t) (DEATH_ISSPECIAL(t) ? WEP_Null : get_weaponinfo((t) & DEATH_WEAPONMASK))
#define DEATH_ISWEAPON(t, w) (DEATH_WEAPONOF(t) == (w))
{
int net_name = (Effects_COUNT >= 255) ? ReadShort() : ReadByte();
- entity eff = Effects[net_name];
+ entity eff = Effects_from(net_name);
vector v, vel = '0 0 0';
int eff_cnt = 1;
#endif
REGISTRY(Effects, BITS(8))
+#define Effects_from(i) _Effects_from(i, EFFECT_Null)
REGISTER_REGISTRY(RegisterEffects)
#define EFFECT(istrail, name, realname) \
REGISTER(RegisterEffects, EFFECT, Effects, name, m_id, Create_Effect_Entity(realname, istrail));
REGISTRY(EffectInfos, BITS(9))
+#define EffectInfos_from(i) _EffectInfos_from(i, NULL)
REGISTER_REGISTRY(RegisterEffectInfos)
#define EFFECTINFO(name) \
[[accumulate]] void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
#include "item.qh"
REGISTRY(Items, BITS(5))
+#define Items_from(i) _Items_from(i, NULL)
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, id, m_id, NEW(class))
ENDCLASS(Gametype)
REGISTRY(Gametypes, BITS(4))
+#define Gametypes_from(i) _Gametypes_from(i, NULL)
REGISTER_REGISTRY(RegisterGametypes)
int MAPINFO_TYPE_ALL;
#define REGISTER_GAMETYPE(hname, sname, g_name, NAME, gteamplay, mutators, defaults, gdescription) \
REGISTRY(Minigames, BITS(3))
+#define Minigames_from(i) _Minigames_from(i, NULL)
REGISTER_REGISTRY(RegisterMinigames)
#define REGISTER_MINIGAME(name,nicename) \
REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, spawn()); \
bool minigame_SendEntity(entity this, entity to, int sf);
REGISTRY(Minigames, BITS(3))
+#define Minigames_from(i) _Minigames_from(i, NULL)
REGISTER_REGISTRY(RegisterMinigames)
#define REGISTER_MINIGAME(name,nicename) \
REGISTER(RegisterMinigames, MINIGAME, Minigames, name, m_id, spawn()); \
MODEL(GIB_ROBO_8, "models/gibs/robo8.md3");
Model MDL_GIB_ROBO_RANDOM() {
int i = floor(random() * 8);
- return Models[MDL_GIB_ROBO_1.m_id + i];
+ return Models_from(MDL_GIB_ROBO_1.m_id + i);
}
MODEL(CASING_SHELL, "models/casing_shell.mdl");
MODEL(10, "models/sprites/10.spr32");
Model MDL_NUM(int i) {
if ((i >= 0 && i <= 10))
- return Models[MDL_0.m_id + i];
+ return Models_from(MDL_0.m_id + i);
return MDL_Null;
}
#include "model.qh"
REGISTRY(Models, BITS(9))
+#define Models_from(i) _Models_from(i, MDL_Null)
REGISTER_REGISTRY(RegisterModels)
#define MODEL(name, path) \
string M_Model(string m_mdl);
REGISTRY(Monsters, BITS(5))
+#define Monsters_from(i) _Monsters_from(i, MON_Null)
+#define get_monsterinfo(i) Monsters_from(i)
REGISTER_REGISTRY(RegisterMonsters)
const int MON_FIRST = 1;
#define MON_LAST (Monsters_COUNT - 1)
REGISTER_MONSTER(Null, NEW(Monster));
-Monster get_monsterinfo(int id)
-{
- if (id >= MON_FIRST && id <= MON_LAST) {
- Monster m = Monsters[id];
- if (m) return m;
- }
- return MON_Null;
-}
#include "all.inc"
ENDCLASS(Mutator)
REGISTRY(Mutators, BITS(6))
+#define Mutators_from(i) _Mutators_from(i, NULL)
Mutator loaded_mutators[Mutators_MAX];
bool Mutator_Add(Mutator mut)
SOUND(BRASS2, W_Sound("brass2"));
SOUND(BRASS3, W_Sound("brass3"));
Sound SND_BRASS_RANDOM() {
- return Sounds[SND_BRASS1.m_id + floor(prandom() * 3)];
+ return Sounds_from(SND_BRASS1.m_id + floor(prandom() * 3));
}
SOUND(CASINGS1, W_Sound("casings1"));
SOUND(CASINGS2, W_Sound("casings2"));
SOUND(CASINGS3, W_Sound("casings3"));
Sound SND_CASINGS_RANDOM() {
- return Sounds[SND_CASINGS1.m_id + floor(prandom() * 3)];
+ return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3));
}
void Casing_Touch()
#include "waypointsprites.qh"
REGISTRY(Waypoints, BITS(6))
+#define Waypoints_from(i) _Waypoints_from(i, WP_Null)
REGISTER_REGISTRY(RegisterWaypoints)
/** If you register a new waypoint, make sure to add it to all.inc */
#define REGISTER_WAYPOINT_(id, init) REGISTER(RegisterWaypoints, WP, Waypoints, id, m_id, init)
#define REGISTER_WAYPOINT(id, text, color, blink) REGISTER_WAYPOINT_(id, NEW(Waypoint, #id, text, color, blink))
REGISTRY(RadarIcons, BITS(7))
+#define RadarIcons_from(i) _RadarIcons_from(i, RADARICON_NONE)
REGISTER_REGISTRY(RegisterRadarIcons)
.int m_radaricon;
#define REGISTER_RADARICON(id, num) REGISTER(RegisterRadarIcons, RADARICON, RadarIcons, id, m_id, new(RadarIcon)) { this.m_radaricon = num; this.netname = #id; }
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_from(self.wp_extra).m_waypointblink;
return 1;
}
vector spritelookupcolor(entity this, string s, vector def)
{
if (s == WP_Weapon.netname || s == RADARICON_Weapon.netname) return get_weaponinfo(this.wp_extra).wpcolor;
- if (s == WP_Item.netname || s == RADARICON_Item.netname) return Items[this.wp_extra].m_color;
- if (s == WP_Buff.netname || s == RADARICON_Buff.netname) return Buffs[this.wp_extra].m_color;
+ if (s == WP_Item.netname || s == RADARICON_Item.netname) return Items_from(this.wp_extra).m_color;
+ if (s == WP_Buff.netname || s == RADARICON_Buff.netname) return Buffs_from(this.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).m_name;
- 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_Item.netname) return Items_from(self.wp_extra).m_waypoint;
+ if (s == WP_Buff.netname) return Buffs_from(self.wp_extra).m_prettyName;
if (s == WP_Monster.netname) return get_monsterinfo(self.wp_extra).monster_name;
// need to loop, as our netname could be one of three
const int PROJECTILE_NADE_MONSTER_BURN = 83;
REGISTRY(Nades, BITS(4))
+#define Nades_from(i) _Nades_from(i, NADE_TYPE_Null)
REGISTER_REGISTRY(RegisterNades)
#define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade))
ARG_CASE(ARG_CS_SV, "spree_end", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-1, "", "", f1) : "")) \
ARG_CASE(ARG_CS_SV, "spree_lost", (autocvar_notification_show_sprees ? notif_arg_spree_inf(-2, "", "", f1) : "")) \
ARG_CASE(ARG_CS_SV, "item_wepname", WEP_NAME(f1)) \
- ARG_CASE(ARG_CS_SV, "item_buffname", sprintf("%s%s", rgb_to_hexcolor(Buffs[f1].m_color), Buffs[f1].m_prettyName)) \
- ARG_CASE(ARG_CS_SV, "f3buffname", sprintf("%s%s", rgb_to_hexcolor(Buffs[f3].m_color), Buffs[f3].m_prettyName)) \
+ ARG_CASE(ARG_CS_SV, "item_buffname", sprintf("%s%s", rgb_to_hexcolor(Buffs_from(f1).m_color), Buffs_from(f1).m_prettyName)) \
+ ARG_CASE(ARG_CS_SV, "f3buffname", sprintf("%s%s", rgb_to_hexcolor(Buffs_from(f3).m_color), Buffs_from(f3).m_prettyName)) \
ARG_CASE(ARG_CS_SV, "item_wepammo", (s1 != "" ? sprintf(_(" with %s"), s1) : "")) \
ARG_CASE(ARG_DC, "item_centime", ftos(autocvar_notification_item_centerprinttime)) \
ARG_CASE(ARG_SV, "death_team", Team_ColoredFullName(f1)) \
SOUND(GRENADE_BOUNCE5, W_Sound("grenade_bounce5"));
SOUND(GRENADE_BOUNCE6, W_Sound("grenade_bounce6"));
Sound SND_GRENADE_BOUNCE_RANDOM() {
- return Sounds[SND_GRENADE_BOUNCE1.m_id + rint(random() * 5)];
+ return Sounds_from(SND_GRENADE_BOUNCE1.m_id + rint(random() * 5));
}
SOUND(GRENADE_FIRE, W_Sound("grenade_fire"));
SOUND(GRENADE_IMPACT, W_Sound("grenade_impact"));
SOUND(HAGEXP2, W_Sound("hagexp2"));
SOUND(HAGEXP3, W_Sound("hagexp3"));
Sound SND_HAGEXP_RANDOM() {
- return Sounds[SND_HAGEXP1.m_id + rint(random() * 2)];
+ return Sounds_from(SND_HAGEXP1.m_id + rint(random() * 2));
}
SOUND(HOOKBOMB_FIRE, W_Sound("hookbomb_fire"));
SOUND(NEXWHOOSH2, W_Sound("nexwhoosh2"));
SOUND(NEXWHOOSH3, W_Sound("nexwhoosh3"));
Sound SND_NEXWHOOSH_RANDOM() {
- return Sounds[SND_NEXWHOOSH1.m_id + rint(random() * 2)];
+ return Sounds_from(SND_NEXWHOOSH1.m_id + rint(random() * 2));
}
SOUND(RELOAD, W_Sound("reload")); // until weapons have individual reload sounds, precache the reload sound here
SOUND(RIC2, W_Sound("ric2"));
SOUND(RIC3, W_Sound("ric3"));
Sound SND_RIC_RANDOM() {
- return Sounds[SND_RIC1.m_id + rint(random() * 2)];
+ return Sounds_from(SND_RIC1.m_id + rint(random() * 2));
}
SOUND(ROCKET_DET, W_Sound("rocket_det"));
SOUND(GIB_SPLAT03, "misc/gib_splat03.wav");
SOUND(GIB_SPLAT04, "misc/gib_splat04.wav");
Sound SND_GIB_SPLAT_RANDOM() {
- return Sounds[SND_GIB_SPLAT01.m_id + floor(prandom() * 4)];
+ return Sounds_from(SND_GIB_SPLAT01.m_id + floor(prandom() * 4));
}
SOUND(HIT, "misc/hit.wav");
#include "sound.qh"
REGISTRY(Sounds, BITS(8))
+#define Sounds_from(i) _Sounds_from(i, SND_Null)
REGISTER_REGISTRY(RegisterSounds)
#define SOUND(name, path) \
#include "turret.qh"
REGISTRY(Turrets, BITS(5))
+#define Turrets_from(i) _Turrets_from(i, TUR_Null)
+#define get_turretinfo(i) Turrets_from(i)
REGISTER_REGISTRY(RegisterTurrets)
REGISTER_TURRET(Null, NEW(Turret));
-Turret get_turretinfo(int id)
-{
- if (id >= TUR_FIRST && id <= TUR_LAST) {
- Turret t = Turrets[id];
- if (t) return t;
- }
- return TUR_Null;
-}
-
#include "all.inc"
#endif
#include "vehicle.qh"
REGISTRY(Vehicles, BITS(3))
+#define Vehicles_from(i) _Vehicles_from(i, VEH_Null)
+#define get_vehicleinfo(i) Vehicles_from(i)
REGISTER_REGISTRY(RegisterVehicles)
const int VEH_FIRST = 1;
#define VEH_LAST (Vehicles_COUNT - 1)
REGISTER_VEHICLE(Null, NEW(Vehicle));
-Vehicle get_vehicleinfo(int id)
-{
- if (id >= VEH_FIRST && id <= VEH_LAST) {
- Vehicle v = Vehicles[id];
- if (v) return v;
- }
- return VEH_Null;
-}
-
#include "all.inc"
#endif
if(self.total_damages < time)
{
- boxparticles(particleeffectnum(Effects[self.traileffect]), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
+ boxparticles(particleeffectnum(Effects_from(self.traileffect)), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
self.total_damages = time + 0.1;
}
#endif
REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
+#define Weapons_from(i) _Weapons_from(i, WEP_Null)
+#define get_weaponinfo(i) Weapons_from(i)
REGISTER_REGISTRY(RegisterWeapons)
STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, LAMBDA(it.m_pickup = NEW(WeaponPickup, it))); }
-entity get_weaponinfo(int id);
GENERIC_COMMAND(dumpweapons, "Dump all weapons into weapons_dump.txt") // WEAPONTODO: make this work with other progs than just server
#include "all.inc"
-entity get_weaponinfo(int id)
-{
- if (id >= WEP_FIRST && id <= WEP_LAST) {
- Weapon w = Weapons[id];
- if (w) return w;
- }
- return WEP_Null;
-}
-
// TODO: remove after 0.8.2. Retains impulse number compatibility because 0.8.1 clients don't reload the weapons.cfg
#define WEP_HARDCODED_IMPULSES 22
#endif
weaponorder_byid = "";
for (int i = Weapons_MAX - 1; i >= 1; --i)
- if (Weapons[i])
+ if (Weapons_from(i))
weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
weaponorder_byid = strzone(substring(weaponorder_byid, 1, strlen(weaponorder_byid) - 1));
}
#endif
REGISTRY(LinkedEntities, BITS(4))
+#define LinkedEntities_from(i) _LinkedEntities_from(i, NULL)
REGISTER_REGISTRY(RegisterLinkedEntities)
REGISTRY_SORT(LinkedEntities, netname, 0)
STATIC_INIT(RegisterLinkedEntities_renumber)
{
for (int i = 0; i < LinkedEntities_COUNT; ++i)
- LinkedEntities[i].m_id = 100 + i;
+ LinkedEntities_from(i).m_id = 100 + i;
}
#ifdef CSQC
#endif
REGISTRY(TempEntities, BITS(4))
+#define TempEntities_from(i) _TempEntities_from(i, NULL)
REGISTER_REGISTRY(RegisterTempEntities)
REGISTRY_SORT(TempEntities, netname, 0)
STATIC_INIT(RegisterTempEntities_renumber)
{
for (int i = 0; i < TempEntities_COUNT; ++i)
- TempEntities[i].m_id = 115 + i;
+ TempEntities_from(i).m_id = 115 + i;
}
#ifndef MENUQC
#define REGISTRY(id, max) \
void Register##id() {} \
const int id##_MAX = max; \
- noref entity id[id##_MAX], id##_first, id##_last; \
- int id##_COUNT;
+ noref entity _##id[id##_MAX], id##_first, id##_last; \
+ int id##_COUNT; \
+ entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _##id[i]; if (e) return e; } return null; }
/**
* Register a new entity with a global constructor.
entity this = inst; \
ns##_##id = this; \
this.fld = array##_COUNT; \
- array[array##_COUNT++] = this; \
+ _##array[array##_COUNT++] = this; \
if (!array##_first) array##_first = this; \
- if (array##_last) array##_last.REGISTRY_NEXT = this; \
+ if (array##_last) array##_last.REGISTRY_NEXT = this; \
array##_last = this; \
Register_##ns##_##id##_init(this); \
Register_##ns##_##id##_init_post(this); \
{ \
i += skip; j += skip; \
\
- entity a = id[i], b = id[j]; \
- id[i] = b; \
- id[j] = a; \
+ entity a = _##id[i], b = _##id[j]; \
+ _##id[i] = b; \
+ _##id[j] = a; \
\
entity a_next = a.REGISTRY_NEXT, b_next = b.REGISTRY_NEXT; \
a.REGISTRY_NEXT = b_next; \
b.REGISTRY_NEXT = a_next; \
\
if (i == 0) id##_first = b; \
- else id[i - 1].REGISTRY_NEXT = b; \
+ else _##id[i - 1].REGISTRY_NEXT = b; \
\
if (j == 0) id##_first = a; \
- else id[j - 1].REGISTRY_NEXT = a; \
+ else _##id[j - 1].REGISTRY_NEXT = a; \
} \
float _REGISTRY_CMP_##id(int i, int j, entity pass) \
{ \
i += skip; j += skip; \
- string a = id[i].field; \
- string b = id[j].field; \
+ string a = _##id[i].field; \
+ string b = _##id[j].field; \
return strcasecmp(a, b); \
} \
STATIC_INIT(Registry_sort_##id) \
#include "xonotic/tab.qc"
REGISTRY(Settings, BITS(3))
+#define Settings_from(i) _Settings_from(i, NULL)
REGISTER_REGISTRY(RegisterSettings)
#define REGISTER_SETTINGS(id, impl) \
LAZY_NEW(id, impl) \
CLASS(SettingSource, DataSource)
METHOD(SettingSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
{
- Lazy l = Settings[i];
+ Lazy l = Settings_from(i);
entity it = l.m_get();
if (returns) returns(it.title, string_null);
return it;
}
METHOD(SettingSource, getEntryTooltip, entity(entity this, int i, void(string theTooltip) returns))
{
- Lazy l = Settings[i];
+ Lazy l = Settings_from(i);
entity it = l.m_get();
if (returns) returns(it.tooltip);
return it;
{
if(DEATH_ISSPECIAL(deathtype))
{
- entity deathent = Deathtypes[deathtype - DT_FIRST];
+ entity deathent = Deathtypes_from(deathtype - DT_FIRST);
if (!deathent) { backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n"); return; }
if(murder)
case "l": replacement = NearestLocation(self.origin); break;
case "y": replacement = NearestLocation(cursor); break;
case "d": replacement = NearestLocation(self.death_origin); break;
- case "w": replacement = WEP_NAME((!self.weapon) ? (!self.switchweapon ? self.cnt : self.switchweapon) : self.weapon); break;
+ case "w": replacement = WEP_NAME(((!self.weapon) ? (!self.switchweapon ? self.cnt : self.switchweapon) : self.weapon)); break;
case "W": replacement = ammoitems; break;
case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break;
case "s": replacement = ftos(vlen(self.velocity - self.velocity_z * '0 0 1')); break;
void nade_burn_spawn(entity _nade)
{
- CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[true], true);
+ CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[true], true);
}
void nade_spawn(entity _nade)
_nade.effects |= EF_LOWPRECISION;
- CSQCProjectile(_nade, true, Nades[_nade.nade_type].m_projectile[false], true);
+ CSQCProjectile(_nade, true, Nades_from(_nade.nade_type).m_projectile[false], true);
}
void napalm_damage(float dist, float damage, float edgedamage, float burntime)
entity expef = NULL;
bool nade_blast = true;
- switch ( Nades[self.nade_type] )
+ switch ( Nades_from(self.nade_type) )
{
case NADE_TYPE_NAPALM:
nade_blast = autocvar_g_nades_napalm_blast;
}
if(self.takedamage)
- switch ( Nades[self.nade_type] )
+ switch ( Nades_from(self.nade_type) )
{
case NADE_TYPE_NAPALM: nade_napalm_boom(); break;
case NADE_TYPE_ICE: nade_ice_boom(); break;
{
//self.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
if(!self.traileffectnum)
- self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[self.nade_type].m_projectile[false], self.team).eent_eff_name);
+ self.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(self.nade_type).m_projectile[false], self.team).eent_eff_name);
self.alpha = 1;
}
//setattachment(n, self, "bip01 l hand");
n.exteriormodeltoclient = self;
n.customizeentityforclient = nade_customize;
- n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades[n.nade_type].m_projectile[false], self.team).eent_eff_name);
- n.colormod = Nades[n.nade_type].m_color;
+ n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(n.nade_type).m_projectile[false], self.team).eent_eff_name);
+ n.colormod = Nades_from(n.nade_type).m_color;
n.realowner = self;
n.colormap = self.colormap;
n.glowmod = self.glowmod;
int slot = 0; // TODO: unhardcode
setattachment(fn, self.weaponentity[slot], "");
fn.realowner = fn.owner = self;
- fn.colormod = Nades[n.nade_type].m_color;
+ fn.colormod = Nades_from(n.nade_type).m_color;
fn.colormap = self.colormap;
fn.glowmod = self.glowmod;
fn.think = SUB_Remove;