void LocalCommand_macro_write_aliases(int fh);
REGISTRY(CLIENT_COMMANDS, BITS(7))
-#define CLIENT_COMMANDS_from(i) _CLIENT_COMMANDS_from(i, NULL)
REGISTER_REGISTRY(CLIENT_COMMANDS)
REGISTRY_SORT(CLIENT_COMMANDS)
+REGISTRY_DEFINE_GET(CLIENT_COMMANDS, NULL)
+
#define CLIENT_COMMAND(id, description) \
CLASS(clientcommand_##id, Command) \
ATTRIB(clientcommand_##id, m_name, string, #id); \
if(hud == HUD_BUMBLEBEE_GUN)
CSQC_BUMBLE_GUN_HUD();
else {
- Vehicle info = Vehicles_from(hud);
+ Vehicle info = REGISTRY_GET(Vehicles, hud);
info.vr_hud(info);
}
hud_draw_maximized = 0;
// draw panels in the order specified by panel_order array
for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
- HUD_Panel_Draw(hud_panels_from(panel_order[i]));
+ HUD_Panel_Draw(REGISTRY_GET(hud_panels, panel_order[i]));
HUD_Vehicle();
bool QuickMenu_IsOpened();
REGISTRY(hud_panels, BITS(6))
-#define hud_panels_from(i) _hud_panels_from(i, NULL)
REGISTER_REGISTRY(hud_panels)
+REGISTRY_DEFINE_GET(hud_panels, NULL)
+
#define _REGISTER_HUD_PANEL(id, draw_func, export_func, configflags, showflags) \
void draw_func(); \
void export_func(int fh); \
// common cvars for all panels
for (int i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
{
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, i);
HUD_Write_PanelCvar("_pos");
HUD_Write_PanelCvar("_size");
vector myTarget = myPos;
int i;
for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, 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 < REGISTRY_COUNT(hud_panels); ++i) {
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
if(panel == highlightedPanel) continue;
HUD_Panel_UpdatePosSize();
{
for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
{
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, 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_from(i);
+ panel = REGISTRY_GET(hud_panels, i);
if(!(panel.panel_configflags & PANEL_CONFIG_MAIN)) continue;
HUD_Panel_UpdatePosSize();
i = panel_order[j];
j += 1;
- panel = hud_panels_from(i);
+ panel = REGISTRY_GET(hud_panels, 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_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, 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_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, 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_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, 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_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, 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_from(i);
+ highlightedPanel = REGISTRY_GET(hud_panels, i);
HUD_Panel_FirstInDrawQ(i);
highlightedAction = 2;
resizeCorner = 4;
{
hudShiftState = 0;
for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
- hud_panels_from(panel_order[i]).update_time = time;
+ REGISTRY_GET(hud_panels, panel_order[i]).update_time = time;
}
// NOTE this check is necessary because _menu_alpha isn't updated the frame the menu gets enabled
{
attacker = sprintf(_("Player %d"), count + 1);
victim = sprintf(_("Player %d"), count + 2);
- icon = Weapons_from(min(WEP_FIRST + count * 2, WEP_LAST)).model2;
+ icon = REGISTRY_GET(Weapons, min(WEP_FIRST + count * 2, WEP_LAST)).model2;
alpha = bound(0, 1.2 - count / entry_count, 1);
}
else
drawpic(coord - '8 8 0', "gfx/teamradar_icon_glow", '16 16 0', brightcolor, panel_fg_alpha, 0);
}
}
- entity icon = RadarIcons_from(it.teamradar_icon);
+ entity icon = REGISTRY_GET(RadarIcons, it.teamradar_icon);
draw_teamradar_icon(it.origin, icon, it, spritelookupcolor(it, icon.netname, it.teamradar_color), panel_fg_alpha);
});
AL_EACH(_entcs, e, it != NULL, {
NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
{
int weapon_id = ReadByte();
- complain_weapon = Weapons_from(weapon_id);
+ complain_weapon = REGISTRY_GET(Weapons, weapon_id);
complain_weapon_type = ReadByte();
return = true;
{
if(hud != HUD_BUMBLEBEE_GUN)
{
- Vehicle info = Vehicles_from(hud);
+ Vehicle info = REGISTRY_GET(Vehicles, hud);
vehicle_viewdist = info.height;
vehicle_viewofs = info.view_ofs;
if(vehicle_viewdist < 0) // when set below 0, this vehicle doesn't use third person view (gunner slots)
{
if(hud != HUD_BUMBLEBEE_GUN)
{
- Vehicle info = Vehicles_from(hud);
+ Vehicle info = REGISTRY_GET(Vehicles, hud);
info.vr_crosshair(info, this);
}
}
vector splash_size = '0 0 0';
splash_size.x = max(vid_conwidth, vid_conheight) * SPECIALCOMMAND_SIZE;
splash_size.y = max(vid_conwidth, vid_conheight) * SPECIALCOMMAND_SIZE;
- entity wep = Weapons_from(slot.z);
+ entity wep = REGISTRY_GET(Weapons, slot.z);
if(wep == WEP_Null)
drawpic(vec2(slot), "gfx/smile", vec2(splash_size), specialcommand_colors[j], 0.95, DRAWFLAG_NORMAL);
else
if (this.traileffect)
{
particles_alphamin = particles_alphamax = particles_fade = sqrt(this.alpha);
- boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
+ entity eff = REGISTRY_GET(Effects, this.traileffect);
+ boxparticles(particleeffectnum(eff), this, from, to, this.velocity, this.velocity, 1, PARTICLES_USEALPHA | PARTICLES_USEFADE | PARTICLES_DRAWASTRAIL);
}
}
REGISTRY(Animations, BITS(8))
REGISTER_REGISTRY(Animations)
-#define Animations_from(id) _Animations_from(id, NULL)
+
+REGISTRY_DEFINE_GET(Animations, NULL)
#define WriteAnimation(to, it) WriteRegistered(Animations, to, it)
#define ReadAnimation() ReadRegistered(Animations)
#define REGISTER_ANIMATION(id, framenames) \
#include "command.qh"
REGISTRY(GENERIC_COMMANDS, BITS(7))
-#define GENERIC_COMMANDS_from(i) _GENERIC_COMMANDS_from(i, NULL)
REGISTER_REGISTRY(GENERIC_COMMANDS)
REGISTRY_SORT(GENERIC_COMMANDS)
+REGISTRY_DEFINE_GET(GENERIC_COMMANDS, NULL)
+
.bool m_menubased; // switch to tell whether this alias should be registered as a menu or client based command
#define GENERIC_COMMAND(id, description, menubased) \
string Deathtype_Name(int deathtype)
{
if (DEATH_ISSPECIAL(deathtype)) {
- entity deathent = Deathtypes_from(deathtype - DT_FIRST);
+ entity deathent = REGISTRY_GET(Deathtypes, deathtype - DT_FIRST);
if (!deathent) { backtrace("Deathtype_Name: Could not find deathtype entity!\n"); return ""; }
return deathent.nent_name;
}
#include <common/notifications/all.qh>
REGISTRY(Deathtypes, BITS(8))
-#define Deathtypes_from(i) _Deathtypes_from(i, NULL)
REGISTER_REGISTRY(Deathtypes)
REGISTRY_CHECK(Deathtypes)
+REGISTRY_DEFINE_GET(Deathtypes, NULL)
+
.entity death_msgself;
.entity death_msgmurder;
.string death_msgextra;
const int DT_FIRST = BIT(13);
#define DEATH_ISSPECIAL(t) (t >= DT_FIRST)
-#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 : Weapons_from((t) & DEATH_WEAPONMASK))
+#define DEATH_IS(t, dt) (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)) == dt)
+#define DEATH_ENT(t) (DEATH_ISSPECIAL(t) ? (REGISTRY_GET(Deathtypes, t - DT_FIRST)) : NULL)
+#define DEATH_ISVEHICLE(t) (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)).death_msgextra == "vehicle")
+#define DEATH_ISTURRET(t) (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)).death_msgextra == "turret")
+#define DEATH_ISMONSTER(t) (DEATH_ISSPECIAL(t) && (REGISTRY_GET(Deathtypes, t - DT_FIRST)).death_msgextra == "monster")
+#define DEATH_WEAPONOF(t) (DEATH_ISSPECIAL(t) ? WEP_Null : REGISTRY_GET(Weapons, (t) & DEATH_WEAPONMASK))
#define DEATH_ISWEAPON(t, w) (DEATH_WEAPONOF(t) == (w))
string Deathtype_Name(int deathtype);
{
int net_name = (REGISTRY_COUNT(Effects) >= 255) ? ReadShort() : ReadByte();
- entity eff = Effects_from(net_name);
+ entity eff = REGISTRY_GET(Effects, net_name);
vector vel = '0 0 0';
int eff_cnt = 1;
#endif
REGISTRY(Effects, BITS(8))
-#define Effects_from(i) _Effects_from(i, EFFECT_Null)
REGISTER_REGISTRY(Effects)
REGISTRY_CHECK(Effects)
#define EFFECT(istrail, name, realname) \
REGISTER(Effects, EFFECT, name, m_id, Create_Effect_Entity(realname, istrail));
EFFECT(0, Null, string_null)
+REGISTRY_DEFINE_GET(Effects, EFFECT_Null)
#include "all.inc"
REGISTRY(EffectInfos, BITS(9))
-#define EffectInfos_from(i) _EffectInfos_from(i, NULL)
REGISTER_REGISTRY(EffectInfos)
+
+REGISTRY_DEFINE_GET(EffectInfos, NULL)
#define EFFECTINFO(name) \
ACCUMULATE void effectinfo_##name(EffectInfoGroup parent, EffectInfo this) { } \
REGISTER(EffectInfos, EFFECTINFO, name, m_id, NEW(EffectInfoGroup)) { \
SOUND(BRASS2, W_Sound("brass2"));
SOUND(BRASS3, W_Sound("brass3"));
Sound SND_BRASS_RANDOM() {
- return Sounds_from(SND_BRASS1.m_id + floor(prandom() * 3));
+ return REGISTRY_GET(Sounds, 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_from(SND_CASINGS1.m_id + floor(prandom() * 3));
+ return REGISTRY_GET(Sounds, SND_CASINGS1.m_id + floor(prandom() * 3));
}
void Casing_Touch(entity this, entity toucher)
NET_HANDLE(globalsound, bool isnew)
{
- entity gs = GlobalSounds_from(ReadByte());
+ entity gs = REGISTRY_GET(GlobalSounds, ReadByte());
float r = ReadByte() / 255;
string sample = GlobalSound_sample(gs.m_globalsoundstr, r);
int who = ReadByte();
NET_HANDLE(playersound, bool isnew)
{
- entity ps = PlayerSounds_from(ReadByte());
+ entity ps = REGISTRY_GET(PlayerSounds, ReadByte());
float r = ReadByte() / 255;
int who = ReadByte();
entity e = entcs_receiver(who - 1);
..string m_playersoundfld;
REGISTRY(PlayerSounds, BITS(8) - 1)
-#define PlayerSounds_from(i) _PlayerSounds_from(i, NULL)
#define REGISTER_PLAYERSOUND(id) \
.string _playersound_##id; \
REGISTER(PlayerSounds, playersound, id, m_id, new_pure(PlayerSound)) \
}
REGISTER_REGISTRY(PlayerSounds)
REGISTRY_SORT(PlayerSounds)
+
+REGISTRY_DEFINE_GET(PlayerSounds, NULL)
STATIC_INIT(PlayerSounds_renumber)
{
FOREACH(PlayerSounds, true, it.m_id = i);
.string m_globalsoundstr;
REGISTRY(GlobalSounds, BITS(8) - 1)
-#define GlobalSounds_from(i) _GlobalSounds_from(i, NULL)
#define REGISTER_GLOBALSOUND(id, str) \
REGISTER(GlobalSounds, GS, id, m_id, new_pure(GlobalSound)) \
{ \
}
REGISTER_REGISTRY(GlobalSounds)
REGISTRY_SORT(GlobalSounds)
+
+REGISTRY_DEFINE_GET(GlobalSounds, NULL)
STATIC_INIT(GlobalSounds_renumber)
{
FOREACH(GlobalSounds, true, it.m_id = i);
#endif
REGISTRY(EntCSProps, BITS(16) - 1)
-#define EntCSProps_from(i) _EntCSProps_from(i, NULL)
REGISTER_REGISTRY(EntCSProps)
REGISTRY_SORT(EntCSProps)
REGISTRY_CHECK(EntCSProps)
+
+REGISTRY_DEFINE_GET(EntCSProps, NULL)
STATIC_INIT(EntCSProps_renumber) { FOREACH(EntCSProps, true, it.m_id = i); }
// these entcs_props ids need to be referenced directly
REGISTRY(IMPULSES, 255)
REGISTER_REGISTRY(IMPULSES)
REGISTRY_SORT(IMPULSES)
+
+REGISTRY_DEFINE_GET(IMPULSES, NULL)
STATIC_INIT(IMPULSES_renumber)
{
FOREACH(IMPULSES, true, it.m_id = i);
// 24 so it matches the limit for the .items field
REGISTRY(Items, 24)
-#define Items_from(i) _Items_from(i, NULL)
#ifdef GAMEQC
REGISTRY_DEPENDS(Items, Models)
#endif
REGISTRY_SORT(Items)
REGISTRY_CHECK(Items)
+
+REGISTRY_DEFINE_GET(Items, NULL)
STATIC_INIT(Items) { FOREACH(Items, true, it.m_id = i); }
void Dump_Items();
if (!(minorBits & BIT(j))) {
continue;
}
- const GameItem it = Items_from(Inventory_groups_minor * i + j);
+ const GameItem it = REGISTRY_GET(Items, Inventory_groups_minor * i + j);
.int fld = inv_items[it.m_id];
int prev = this.(fld);
int next = this.(fld) = ReadByte();
if (!(minorBits & BIT(j)))
continue;
- const entity it = Items_from(Inventory_groups_minor * i + j);
+ const entity it = REGISTRY_GET(Items, Inventory_groups_minor * i + j);
WriteByte(MSG_ENTITY, data.inv_items[it.m_id]);
}
}
Gametype MapInfo_CurrentGametype()
{
- Gametype prev = Gametypes_from(cvar("gamecfg"));
+ Gametype prev = REGISTRY_GET(Gametypes, cvar("gamecfg"));
FOREACH(Gametypes, cvar(it.netname) && it != prev, return it);
return prev ? prev : MAPINFO_TYPE_DEATHMATCH;
}
ENDCLASS(Gametype)
REGISTRY(Gametypes, 24)
-#define Gametypes_from(i) _Gametypes_from(i, NULL)
REGISTER_REGISTRY(Gametypes)
REGISTRY_CHECK(Gametypes)
+
+REGISTRY_DEFINE_GET(Gametypes, NULL)
#define REGISTER_GAMETYPE(NAME, inst) REGISTER(Gametypes, MAPINFO_TYPE, NAME, m_id, inst)
#define IS_GAMETYPE(NAME) (MapInfo_LoadedGametype == MAPINFO_TYPE_##NAME)
REGISTRY(Minigames, BITS(4))
-#define Minigames_from(i) _Minigames_from(i, NULL)
REGISTER_REGISTRY(Minigames)
REGISTRY_CHECK(Minigames)
+
+REGISTRY_DEFINE_GET(Minigames, NULL)
#define REGISTER_MINIGAME(name,nicename) \
REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
void name##_hud_board(vector, vector); \
bool minigame_SendEntity(entity this, entity to, int sf);
REGISTRY(Minigames, BITS(4))
-#define Minigames_from(i) _Minigames_from(i, NULL)
REGISTER_REGISTRY(Minigames)
REGISTRY_CHECK(Minigames)
+
+REGISTRY_DEFINE_GET(Minigames, NULL)
#define REGISTER_MINIGAME(name,nicename) \
REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
int name##_server_event(entity, string, ...); \
MODEL(GIB_ROBO_8, "models/gibs/robo8.md3");
Model MDL_GIB_ROBO_RANDOM() {
int i = floor(random() * 8);
- return Models_from(MDL_GIB_ROBO_1.m_id + i);
+ return REGISTRY_GET(Models, 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_from(MDL_0.m_id + i);
+ return REGISTRY_GET(Models, 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(Models)
#define MODEL(name, path) \
}
MODEL(Null, "null");
+REGISTRY_DEFINE_GET(Models, MDL_Null)
#include "all.inc"
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)
+#define get_monsterinfo(i) REGISTRY_GET(Monsters, i)
REGISTER_REGISTRY(Monsters)
REGISTRY_CHECK(Monsters)
const int MON_FIRST = 1;
#include "monster.qh"
REGISTER_MONSTER(Null, NEW(Monster));
+REGISTRY_DEFINE_GET(Monsters, MON_Null)
if((targ == this)
|| (autocvar_g_monsters_lineofsight && !checkpvs(this.origin + this.view_ofs, targ)) // enemy cannot be seen
- || (IS_VEHICLE(targ) && !((Monsters_from(this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
+ || (IS_VEHICLE(targ) && !((REGISTRY_GET(Monsters, this.monsterid)).spawnflags & MON_FLAG_RANGED)) // melee vs vehicle is useless
|| (time < game_starttime) // monsters do nothing before match has started
|| (targ.takedamage == DAMAGE_NO)
|| (game_stopped)
void Monster_Sounds_Precache(entity this)
{
- string m = (Monsters_from(this.monsterid)).m_model.model_str();
+ string m = (REGISTRY_GET(Monsters, this.monsterid)).m_model.model_str();
float globhandle, n, i;
string f;
this.anim_die2 = animfixfps(this, '9 1 0.01', '0 0 0');*/
// then get the real values
- Monster mon = Monsters_from(this.monsterid);
+ Monster mon = REGISTRY_GET(Monsters, this.monsterid);
mon.mr_anim(mon, this);
}
CSQCModel_UnlinkEntity(this);
- Monster mon = Monsters_from(this.monsterid);
+ Monster mon = REGISTRY_GET(Monsters, this.monsterid);
mon.mr_death(mon, this);
if(this.candrop && this.weapon)
float take = v.x;
//float save = v.y;
- Monster mon = Monsters_from(this.monsterid);
+ Monster mon = REGISTRY_GET(Monsters, this.monsterid);
take = mon.mr_pain(mon, this, take, attacker, deathtype);
if(take)
this.last_enemycheck = time + 1; // check for enemies every second
}
- Monster mon = Monsters_from(this.monsterid);
+ Monster mon = REGISTRY_GET(Monsters, this.monsterid);
if(mon.mr_think(mon, this))
{
Monster_Move(this, this.speed2, this.speed, this.stopspeed);
bool Monster_Spawn_Setup(entity this)
{
- Monster mon = Monsters_from(this.monsterid);
+ Monster mon = REGISTRY_GET(Monsters, this.monsterid);
mon.mr_setup(mon, this);
// ensure some basic needs are met
bool Monster_Spawn(entity this, bool check_appear, int mon_id)
{
// setup the basic required properties for a monster
- entity mon = Monsters_from(mon_id);
+ entity mon = REGISTRY_GET(Monsters, mon_id);
if(!mon.monsterid) { return false; } // invalid monster
if(!autocvar_g_monsters) { Monster_Remove(this); return false; }
ENDCLASS(Mutator)
REGISTRY(Mutators, BITS(7))
-#define Mutators_from(i) _Mutators_from(i, NULL)
+
+REGISTRY_DEFINE_GET(Mutators, NULL)
bool Mutator_Add(Mutator mut);
void Mutator_Remove(Mutator mut);
bool mutator_log = false;
string BUFF_NAME(int i)
{
- Buff b = Buffs_from(i);
+ Buff b = REGISTRY_GET(Buffs, i);
return strcat(rgb_to_hexcolor(b.m_color), b.m_name);
}
#endif
REGISTRY(Buffs, BITS(5))
-#define Buffs_from(i) _Buffs_from(i, BUFF_Null)
REGISTER_REGISTRY(Buffs)
REGISTRY_CHECK(Buffs)
REGISTER_BUFF(Null);
BUFF_SPAWNFUNCS(random, BUFF_Null)
+REGISTRY_DEFINE_GET(Buffs, BUFF_Null)
#include "all.inc"
string s = M_ARGV(1, string);
if (s == WP_Buff.netname || s == RADARICON_Buff.netname)
{
- Buff b = Buffs_from(this.wp_extra);
+ Buff b = REGISTRY_GET(Buffs, this.wp_extra);
M_ARGV(2, vector) = b.m_color;
M_ARGV(3, string) = b.m_name;
M_ARGV(4, string) = strcat("buff_", b.netname);
float bonusNades = STAT(NADE_BONUS);
float bonusProgress = STAT(NADE_BONUS_SCORE);
float bonusType = STAT(NADE_BONUS_TYPE);
- Nade def = Nades_from(bonusType);
+ Nade def = REGISTRY_GET(Nades, bonusType);
vector nadeColor = def.m_color;
string nadeIcon = def.m_icon;
void nade_burn_spawn(entity _nade)
{
- CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
+ CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[true], true);
}
void nade_spawn(entity _nade)
_nade.effects |= EF_LOWPRECISION;
- CSQCProjectile(_nade, true, Nades_from(STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
+ CSQCProjectile(_nade, true, REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, _nade)).m_projectile[false], true);
}
void napalm_damage(entity this, float dist, float damage, float edgedamage, float burntime)
entity expef = NULL;
bool nade_blast = true;
- switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
+ switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
{
case NADE_TYPE_NAPALM:
nade_blast = autocvar_g_nades_napalm_blast;
}
if(this.takedamage)
- switch ( Nades_from(STAT(NADE_BONUS_TYPE, this)) )
+ switch ( REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this)) )
{
case NADE_TYPE_NAPALM: nade_napalm_boom(this); break;
case NADE_TYPE_ICE: nade_ice_boom(this); break;
{
//this.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
if(!this.traileffectnum)
- this.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, this)).m_projectile[false], this.team).eent_eff_name);
+ {
+ entity nade = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, this));
+ this.traileffectnum = _particleeffectnum(Nade_TrailEffect(nade.m_projectile[false], this.team).eent_eff_name);
+ }
this.alpha = 1;
}
STAT(NADE_BONUS_TYPE, n) = max(1, ntype);
n.pokenade_type = pntype;
- if(Nades_from(STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
+ if(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)) == NADE_TYPE_Null)
STAT(NADE_BONUS_TYPE, n) = NADE_TYPE_NORMAL.m_id;
.entity weaponentity = weaponentities[0]; // TODO: unhardcode
//setattachment(n, player, "bip01 l hand");
n.exteriormodeltoclient = player;
setcefc(n, nade_customize);
- n.traileffectnum = _particleeffectnum(Nade_TrailEffect(Nades_from(STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
- n.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
+ n.traileffectnum = _particleeffectnum(Nade_TrailEffect(REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_projectile[false], player.team).eent_eff_name);
+ n.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
n.realowner = nowner;
n.colormap = player.colormap;
n.glowmod = player.glowmod;
n.projectiledeathtype = DEATH_NADE.m_id;
n.weaponentity_fld = weaponentity;
n.nade_lifetime = ntime;
- n.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
+ n.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
setmodel(fn, MDL_NADE_VIEW);
//setattachment(fn, player.(weaponentity), "");
fn.viewmodelforclient = player;
fn.realowner = fn.owner = player;
- fn.colormod = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_color;
+ fn.colormod = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_color;
fn.colormap = player.colormap;
fn.glowmod = player.glowmod;
setthink(fn, SUB_Remove);
fn.nextthink = n.wait;
fn.weaponentity_fld = weaponentity;
- fn.alpha = Nades_from(STAT(NADE_BONUS_TYPE, n)).m_alpha;
+ fn.alpha = REGISTRY_GET(Nades, STAT(NADE_BONUS_TYPE, n)).m_alpha;
player.nade = n;
player.fake_nade = fn;
const int PROJECTILE_NADE_VEIL_BURN = 87;
REGISTRY(Nades, BITS(4))
-#define Nades_from(i) _Nades_from(i, NADE_TYPE_Null)
REGISTER_REGISTRY(Nades)
REGISTRY_CHECK(Nades)
ENDCLASS(Nade)
REGISTER_NADE(Null);
+REGISTRY_DEFINE_GET(Nades, NADE_TYPE_Null)
Nade Nade_FromProjectile(int proj)
{
bool NIX_CanChooseWeapon(int wpn)
{
- entity e = Weapons_from(wpn);
+ entity e = REGISTRY_GET(Weapons, wpn);
if (e == WEP_Null) return false; // skip dummies
if(g_weaponarena)
{
nix_nextchange = time; // start the first round now!
else
nix_nextchange = time + autocvar_g_balance_nix_roundtime;
- // Weapon w = Weapons_from(nix_weapon);
+ // Weapon w = REGISTRY_GET(Weapons, nix_weapon);
// w.wr_init(w); // forget it, too slow
}
// get weapon info
- entity wpn = Weapons_from(nix_weapon);
+ entity wpn = REGISTRY_GET(Weapons, nix_weapon);
if(nix_nextchange != this.nix_lastchange_id) // this shall only be called once per round!
{
#include "waypointsprites.qh"
REGISTRY(Waypoints, BITS(7))
-#define Waypoints_from(i) _Waypoints_from(i, WP_Null)
REGISTER_REGISTRY(Waypoints)
REGISTRY_CHECK(Waypoints)
#define REGISTER_WAYPOINT(id, text, icon, color, blink) REGISTER_WAYPOINT_(id, NEW(Waypoint, #id, text, icon, color, blink))
REGISTRY(RadarIcons, BITS(7))
-#define RadarIcons_from(i) _RadarIcons_from(i, RADARICON_NONE)
REGISTER_REGISTRY(RadarIcons)
REGISTRY_CHECK(RadarIcons)
#define REGISTER_RADARICON(id, num) REGISTER(RadarIcons, RADARICON, id, m_id, new_pure(RadarIcon)) { this.m_radaricon = num; this.netname = #id; }
REGISTER_WAYPOINT(Null, "", "", '0 0 0', 1);
+REGISTRY_DEFINE_GET(Waypoints, WP_Null)
REGISTER_RADARICON(NONE, 0);
+REGISTRY_DEFINE_GET(RadarIcons, RADARICON_NONE)
+
REGISTER_RADARICON(FLAG, 1);
REGISTER_RADARICON(FLAGCARRIER, 1);
float spritelookupblinkvalue(entity this, string s)
{
if (s == WP_Weapon.netname) {
- if (Weapons_from(this.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
+ if (REGISTRY_GET(Weapons, this.wp_extra).spawnflags & WEP_FLAG_SUPERWEAPON)
return 2;
}
- if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypointblink;
+ if (s == WP_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_waypointblink;
if(s == WP_FlagReturn.netname) return 2;
return 1;
vector spritelookupcolor(entity this, string s, vector def)
{
- if (s == WP_Weapon.netname || s == RADARICON_Weapon.netname) return Weapons_from(this.wp_extra).wpcolor;
- if (s == WP_Item.netname || s == RADARICON_Item.netname) return Items_from(this.wp_extra).m_color;
+ if (s == WP_Weapon.netname || s == RADARICON_Weapon.netname) return REGISTRY_GET(Weapons, this.wp_extra).wpcolor;
+ if (s == WP_Item.netname || s == RADARICON_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_color;
if (MUTATOR_CALLHOOK(WP_Format, this, s))
{
return M_ARGV(2, vector);
if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
return "Spam"; // no need to translate this debug string
if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
- if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).m_name;
- if (s == WP_Item.netname) return Items_from(this.wp_extra).m_waypoint;
+ if (s == WP_Weapon.netname) return REGISTRY_GET(Weapons, this.wp_extra).m_name;
+ if (s == WP_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_waypoint;
if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).monster_name;
if (MUTATOR_CALLHOOK(WP_Format, this, s))
{
string spritelookupicon(entity this, string s)
{
// TODO: needs icons! //if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start");
- if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).model2;
- if (s == WP_Item.netname) return Items_from(this.wp_extra).m_icon;
- if (s == WP_Vehicle.netname) return Vehicles_from(this.wp_extra).m_icon;
+ if (s == WP_Weapon.netname) return REGISTRY_GET(Weapons, this.wp_extra).model2;
+ if (s == WP_Item.netname) return REGISTRY_GET(Items, this.wp_extra).m_icon;
+ if (s == WP_Vehicle.netname) return REGISTRY_GET(Vehicles, this.wp_extra).m_icon;
//if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).m_icon;
if (MUTATOR_CALLHOOK(WP_Format, this, s))
{
ARG_CASE(ARG_CS_SV, "spree_inf", (autocvar_notification_show_sprees ? notif_arg_spree_inf(1, input, s2, f2) : "")) \
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", Weapons_from(f1).m_name) \
+ ARG_CASE(ARG_CS_SV, "item_wepname", REGISTRY_GET(Weapons, f1).m_name) \
ARG_CASE(ARG_CS_SV, "item_buffname", BUFF_NAME(f1)) \
ARG_CASE(ARG_CS_SV, "f3buffname", BUFF_NAME(f3)) \
ARG_CASE(ARG_CS_SV, "item_wepammo", (f2 > 0 ? notif_arg_item_wepammo(f1, f2) : "")) \
string notif_arg_item_wepammo(float f1, float f2)
{
string ammoitems = "";
- Weapon wep = Weapons_from(f1);
+ Weapon wep = REGISTRY_GET(Weapons, f1);
switch (wep.ammo_type)
{
case RES_SHELLS: ammoitems = ITEM_Shells.m_name; break;
REGISTRY(Notifications, BITS(11))
REGISTER_REGISTRY(Notifications)
REGISTRY_SORT(Notifications);
+
+REGISTRY_DEFINE_GET(Notifications, NULL)
STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); }
REGISTRY_CHECK(Notifications)
Notification Get_Notif_Ent(MSG net_type, int net_name)
{
- Notification it = _Notifications_from(net_name, NULL);
+ Notification it = REGISTRY_GET(Notifications, net_name);
if (it.nent_type != net_type) {
LOG_WARNF("Get_Notif_Ent(%s (%d), %s (%d)): Improper net type '%s'!",
Get_Notif_TypeName(net_type), net_type,
#define REGISTER_SP(id) REGISTER(Scores, SP, id, m_id, new_pure(PlayerScoreField))
REGISTRY(Scores, MAX_SCORE);
-#define Scores_from(i) _Scores_from(i, NULL)
REGISTER_REGISTRY(Scores)
REGISTRY_SORT(Scores);
REGISTRY_CHECK(Scores);
+
+REGISTRY_DEFINE_GET(Scores, NULL)
STATIC_INIT(Scores_renumber) { FOREACH(Scores, true, it.m_id = i); }
/*
SOUND(GRENADE_BOUNCE5, W_Sound("grenade_bounce5"));
SOUND(GRENADE_BOUNCE6, W_Sound("grenade_bounce6"));
Sound SND_GRENADE_BOUNCE_RANDOM() {
- return Sounds_from(SND_GRENADE_BOUNCE1.m_id + rint(random() * 5));
+ return REGISTRY_GET(Sounds, 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_from(SND_HAGEXP1.m_id + rint(random() * 2));
+ return REGISTRY_GET(Sounds, 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_from(SND_NEXWHOOSH1.m_id + rint(random() * 2));
+ return REGISTRY_GET(Sounds, 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_from(SND_RIC1.m_id + rint(random() * 2));
+ return REGISTRY_GET(Sounds, SND_RIC1.m_id + rint(random() * 2));
}
SOUND(ROCKET_DET, W_Sound("rocket_det"));
SOUND(GIB_SPLAT03, "misc/gib_splat03");
SOUND(GIB_SPLAT04, "misc/gib_splat04");
Sound SND_GIB_SPLAT_RANDOM() {
- return Sounds_from(SND_GIB_SPLAT01.m_id + floor(prandom() * 4));
+ return REGISTRY_GET(Sounds, SND_GIB_SPLAT01.m_id + floor(prandom() * 4));
}
SOUND(HIT, "misc/hit");
#include "sound.qh"
REGISTRY(Sounds, BITS(9))
-#define Sounds_from(i) _Sounds_from(i, SND_Null)
REGISTER_REGISTRY(Sounds)
#define SOUND(name, path) \
}
SOUND(Null, "misc/null");
+REGISTRY_DEFINE_GET(Sounds, SND_Null)
#include "all.inc"
#include "all.qc"
{
do {
{
- entity wi = Weapons_from(this.weapon);
+ entity wi = REGISTRY_GET(Weapons, this.weapon);
if (wi != WEP_Null) {
entity wp = WaypointSprite_Spawn(WP_Weapon, 0, 0, this, '0 0 64', NULL, 0, this, waypointsprite_attached, true, RADARICON_Weapon);
wp.wp_extra = wi.m_id;
{
.entity weaponentity = weaponentities[slot];
if(player.(weaponentity).m_weapon != WEP_Null || slot == 0)
- W_SwitchWeapon_Force(player, Weapons_from(item.weapon), weaponentity);
+ W_SwitchWeapon_Force(player, REGISTRY_GET(Weapons, item.weapon), weaponentity);
}
return true;
}
}
if(weaponid)
- STAT(WEAPONS, this) = WepSet_FromWeapon(Weapons_from(weaponid));
+ STAT(WEAPONS, this) = WepSet_FromWeapon(REGISTRY_GET(Weapons, weaponid));
this.flags = FL_ITEM | itemflags;
IL_PUSH(g_items, this);
this.is_item = true;
}
- weaponsInMap |= WepSet_FromWeapon(Weapons_from(weaponid));
+ weaponsInMap |= WepSet_FromWeapon(REGISTRY_GET(Weapons, weaponid));
if ( def.instanceOfPowerup
|| def.instanceOfWeaponPickup
float GiveWeapon(entity e, float wpn, float op, float val)
{
WepSet v0, v1;
- WepSet s = WepSet_FromWeapon(Weapons_from(wpn));
+ WepSet s = WepSet_FromWeapon(REGISTRY_GET(Weapons, wpn));
v0 = (STAT(WEAPONS, e) & s);
switch(op)
{
#include "turret.qh"
REGISTRY(Turrets, BITS(5))
-#define Turrets_from(i) _Turrets_from(i, TUR_Null)
-#define get_turretinfo(i) Turrets_from(i)
+#define get_turretinfo(i) REGISTRY_GET(Turrets, i)
REGISTER_REGISTRY(Turrets)
REGISTRY_CHECK(Turrets)
#define REGISTER_TURRET(id, inst) REGISTER(Turrets, TUR, id, m_id, inst)
REGISTER_TURRET(Null, NEW(Turret));
+REGISTRY_DEFINE_GET(Turrets, TUR_Null)
#include "turret/_mod.qh"
n = tokenize_console(neworder);
for(w = to; w >= from; --w)
{
- int wflags = Weapons_from(w).spawnflags;
+ int wflags = REGISTRY_GET(Weapons, w).spawnflags;
if(wflags & WEP_FLAG_SPECIALATTACK)
continue;
for(i = 0; i < n; ++i)
#include "vehicle.qh"
REGISTRY(Vehicles, BITS(4))
-#define Vehicles_from(i) _Vehicles_from(i, VEH_Null)
REGISTER_REGISTRY(Vehicles)
REGISTRY_CHECK(Vehicles)
#endif
REGISTER_VEHICLE(Null, NEW(Vehicle));
+REGISTRY_DEFINE_GET(Vehicles, VEH_Null)
#include "vehicle/_mod.qh"
AuxiliaryXhair[0].axh_image = vCROSS_BURST; // Plasma cannons
AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Raygun
} else {
- Vehicle info = Vehicles_from(hud_id);
+ Vehicle info = REGISTRY_GET(Vehicles, hud_id);
info.vr_setup(info, NULL);
}
}
this.velocity = '0 0 0';
this.effects = eff;
- Vehicle info = Vehicles_from(this.vehicleid);
+ Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
info.vr_setcolors(info, this);
}
antilag_clear(this, this);
- Vehicle info = Vehicles_from(this.vehicleid);
+ Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
info.vr_death(info, this);
vehicles_setreturn(this);
}
}
if(this.play_time < time) {
- Vehicle info = Vehicles_from(this.vehicleid);
+ Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
info.vr_impact(info, this);
}
|| (pl.vehicle)
) { return; }
- Vehicle info = Vehicles_from(veh.vehicleid);
+ Vehicle info = REGISTRY_GET(Vehicles, veh.vehicleid);
if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO)
if(veh.vehicle_flags & VHF_MULTISLOT)
if(this.owner)
STAT(VEHICLESTAT_W2MODE, this.owner) = STAT(VEHICLESTAT_W2MODE, this);
- Vehicle info = Vehicles_from(this.vehicleid);
+ Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
info.vr_think(info, this);
vehicles_painframe(this);
});
- Vehicle info = Vehicles_from(this.vehicleid);
+ Vehicle info = REGISTRY_GET(Vehicles, this.vehicleid);
info.vr_spawn(info, this);
vehicles_reset_colors(this, NULL);
if(this.bumble_raygun_nextdraw < time)
{
- boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, this.origin, this.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
+ entity eff = REGISTRY_GET(Effects, this.traileffect);
+ boxparticles(particleeffectnum(eff), this, this.origin, this.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
boxparticles(this.lip, this, this.bumble_origin, this.bumble_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
this.bumble_raygun_nextdraw = time + 0.1;
}
int i = stof(s);
if (s == "0" || i)
{
- entity wi = Weapons_from(i);
+ entity wi = REGISTRY_GET(Weapons, i);
if (wi != WEP_Null) return wi.netname;
}
return s;
float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass)
{
int si = W_FixWeaponOrder_BuildImpulseList_buf[i];
- Weapon e1 = Weapons_from(si);
+ Weapon e1 = REGISTRY_GET(Weapons, si);
int sj = W_FixWeaponOrder_BuildImpulseList_buf[j];
- Weapon e2 = Weapons_from(sj);
+ Weapon e2 = REGISTRY_GET(Weapons, sj);
int d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10;
if (d != 0) return -d; // high impulse first!
return strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "),
#include <common/util.qh>
REGISTRY(Weapons, 72) // Increase as needed. Can be up to 72.
-#define Weapons_from(i) _Weapons_from(i, WEP_Null)
REGISTER_REGISTRY(Weapons)
STATIC_INIT(WeaponPickup) { FOREACH(Weapons, true, it.m_pickup = NEW(WeaponPickup, it)); }
[[alias("WEP_" #id)]] Weapon _wep_##sname
REGISTER_WEAPON(Null, NEW(Weapon));
+REGISTRY_DEFINE_GET(Weapons, WEP_Null)
Weapon Weapons_fromstr(string s)
{
.void(Weapon this, int i) wr_net;
NET_HANDLE(WeaponUpdate, bool isnew)
{
- Weapon w = Weapons_from(ReadByte());
+ Weapon w = REGISTRY_GET(Weapons, ReadByte());
for (int i; (i = ReadByte()); )
{
w.wr_net(w, i);
#endif
weaponorder_byid = "";
for (int i = REGISTRY_MAX(Weapons) - 1; i >= 1; --i)
- if (Weapons_from(i))
+ if (REGISTRY_GET(Weapons, i))
weaponorder_byid = strcat(weaponorder_byid, " ", ftos(i));
weaponorder_byid = strzone(substring(weaponorder_byid, 1, -1));
}
#define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
{ WriteByte(chan, this.m_switchweapon.m_id); }, \
- { (viewmodels[this.m_wepent_slot]).switchweapon = Weapons_from(ReadByte()); }) \
+ { (viewmodels[this.m_wepent_slot]).switchweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
\
PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
{ WriteByte(chan, this.m_switchingweapon.m_id); }, \
- { (viewmodels[this.m_wepent_slot]).switchingweapon = Weapons_from(ReadByte()); }) \
+ { (viewmodels[this.m_wepent_slot]).switchingweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
\
PROP(false, m_weapon, WEPENT_SET_NORMAL, \
{ WriteByte(chan, this.m_weapon.m_id); }, \
- { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
+ { (viewmodels[this.m_wepent_slot]).activeweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
\
PROP(false, m_alpha, WEPENT_SET_NORMAL, \
{ WriteByte(chan, rint(bound(-1, 254 * this.m_alpha, 254) - -1)); }, \
#define REGISTER_NET_S2C(id) REGISTER_NET_TEMP(id)
REGISTRY(TempEntities, BITS(8) - 80)
-#define TempEntities_from(i) _TempEntities_from(i, NULL)
REGISTER_REGISTRY(TempEntities)
REGISTRY_SORT(TempEntities)
REGISTRY_CHECK(TempEntities)
+
+REGISTRY_DEFINE_GET(TempEntities, NULL)
STATIC_INIT(TempEntities_renumber) { FOREACH(TempEntities, true, it.m_id = 80 + i); }
#endif
REGISTRY(LinkedEntities, BITS(8) - 1)
-#define LinkedEntities_from(i) _LinkedEntities_from(i, NULL)
REGISTER_REGISTRY(LinkedEntities)
REGISTRY_SORT(LinkedEntities)
REGISTRY_CHECK(LinkedEntities)
+
+REGISTRY_DEFINE_GET(LinkedEntities, NULL)
STATIC_INIT(LinkedEntities_renumber) { FOREACH(LinkedEntities, true, it.m_id = 1 + i); }
#endif
REGISTRY(C2S_Protocol, BITS(8) - 1)
-#define C2S_Protocol_from(i) _C2S_Protocol_from(i, NULL)
REGISTER_REGISTRY(C2S_Protocol)
REGISTRY_SORT(C2S_Protocol)
REGISTRY_CHECK(C2S_Protocol)
+
+REGISTRY_DEFINE_GET(C2S_Protocol, NULL)
STATIC_INIT(C2S_Protocol_renumber) { FOREACH(C2S_Protocol, true, it.m_id = i); }
#ifdef SVQC
STRING_ITERATOR_SET(g_buf, buf, 0);
for (int C2S; (C2S = ReadByte()) >= 0; )
{
- entity reader = C2S_Protocol_from(C2S);
+ entity reader = REGISTRY_GET(C2S_Protocol, C2S);
if (reader && reader.m_read && reader.m_read(NULL, sender, true)) continue;
LOG_SEVEREF("Net_ClientCommand() with malformed C2S=%d", C2S);
return;
// serialization: old
-#define ReadRegistered(r) r##_from(Read_byte())
+#define ReadRegistered(r) REGISTRY_GET(r, Read_byte())
#define WriteRegistered(r, to, it) Write_byte(to, it.m_id)
#define Read_byte() ReadByte()
noref entity id##_first, id##_last; \
_R_MAP(_##id, id##_MAX); \
SHUTDOWN(id) { _R_DEL(_##id); } \
- entity _##id##_from(int i, entity null) { if (i >= 0 && i < id##_COUNT) { entity e = _R_GET(_##id, i); if (e) return e; } return null; }
+
+#define REGISTRY_DEFINE_GET(id, null) \
+ entity id##_from(int i) { if (i >= 0 && i < id##_COUNT) { entity e = _R_GET(_##id, i); if (e) return e; } return null; }
+
+#define REGISTRY_GET(id, i) id##_from(i)
/** Add registry dependencies to a registry */
#define REGISTRY_DEPENDS(id, dep) void Register##dep(); void REGISTRY_DEPENDS_(id) { Register##dep(); }
REGISTER_REGISTRY(Stats)
REGISTRY_SORT(Stats)
REGISTRY_CHECK(Stats)
+
+REGISTRY_DEFINE_GET(Stats, NULL)
STATIC_INIT(Stats_renumber)
{
FOREACH(Stats, true, {
#include "xonotic/tab.qh"
REGISTRY(Settings, BITS(3))
-#define Settings_from(i) _Settings_from(i, NULL)
REGISTER_REGISTRY(Settings)
+
+REGISTRY_DEFINE_GET(Settings, NULL)
#define REGISTER_SETTINGS(id, impl) \
LAZY_NEW(id, impl) \
REGISTER(Settings, MENU, id, m_id, NEW(Lazy, LAZY(id)))
me.TDempty(me, 0.1); // fix initial position
for(i = WEP_FIRST, j = 0; i <= WEP_LAST; ++i)
{
- w = Weapons_from(i);
+ w = REGISTRY_GET(Weapons, i);
if (w.spawnflags & (WEP_FLAG_HIDDEN | WEP_FLAG_SPECIALATTACK))
continue;
if ((j % 3) == 0)
METHOD(SettingSource, getEntry, entity(entity this, int i, void(string name, string icon) returns))
{
- Lazy l = Settings_from(i);
+ Lazy l = REGISTRY_GET(Settings, 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_from(i);
+ Lazy l = REGISTRY_GET(Settings, i);
entity it = l.m_get();
if (returns) returns(it.titleTooltip);
return it;
// the type was found
// choose the next one
flag = true;
- s = MapInfo_Type_ToString(Gametypes_from(it.m_id + 1));
+ s = MapInfo_Type_ToString(REGISTRY_GET(Gametypes, it.m_id + 1));
if (s == "") s = MapInfo_Type_ToString(first);
break;
});
s = "";
for(i = 0; i < n; ++i)
{
- e = Weapons_from(stof(argv(i)));
+ e = REGISTRY_GET(Weapons, stof(argv(i)));
s = strcat(s, e.m_name, ", ");
}
return substring(s, 0, strlen(s) - 2);
me.focusedItemAlpha = getFadedAlpha(me.focusedItemAlpha, SKINALPHA_LISTBOX_FOCUSED, SKINFADEALPHA_LISTBOX_FOCUSED);
draw_Fill('0 0 0', '1 1 0', SKINCOLOR_LISTBOX_FOCUSED, me.focusedItemAlpha);
}
- e = Weapons_from(stof(argv(i)));
+ e = REGISTRY_GET(Weapons, stof(argv(i)));
string msg = e.m_name;
if(e.spawnflags & WEP_FLAG_MUTATORBLOCKED)
msg = strcat(msg, "*");
if ( distance > bot_distance_far ) {
for(i=0; i < REGISTRY_COUNT(Weapons) && bot_weapons_far[i] != -1 ; ++i){
w = bot_weapons_far[i];
- if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
+ if ( client_hasweapon(this, REGISTRY_GET(Weapons, w), weaponentity, true, false) )
{
if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
continue;
- this.(weaponentity).m_switchweapon = Weapons_from(w);
+ this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, w);
return;
}
}
if ( distance > bot_distance_close) {
for(i=0; i < REGISTRY_COUNT(Weapons) && bot_weapons_mid[i] != -1 ; ++i){
w = bot_weapons_mid[i];
- if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
+ if ( client_hasweapon(this, REGISTRY_GET(Weapons, w), weaponentity, true, false) )
{
if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
continue;
- this.(weaponentity).m_switchweapon = Weapons_from(w);
+ this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, w);
return;
}
}
// Choose weapons for close distance
for(i=0; i < REGISTRY_COUNT(Weapons) && bot_weapons_close[i] != -1 ; ++i){
w = bot_weapons_close[i];
- if ( client_hasweapon(this, Weapons_from(w), weaponentity, true, false) )
+ if ( client_hasweapon(this, REGISTRY_GET(Weapons, w), weaponentity, true, false) )
{
if ((this.(weaponentity).m_weapon.m_id == w && combo) || havocbot_chooseweapon_checkreload(this, weaponentity, w))
continue;
- this.(weaponentity).m_switchweapon = Weapons_from(w);
+ this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, w);
return;
}
}
if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
continue;
- if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
+ if(client_hasweapon(this, REGISTRY_GET(Weapons, id), weaponentity, true, false))
{
success = true;
- this.(weaponentity).m_switchweapon = Weapons_from(id);
+ this.(weaponentity).m_switchweapon = REGISTRY_GET(Weapons, id);
}
}
#include <common/command/_mod.qh>
REGISTRY(COMMON_COMMANDS, BITS(7))
-#define COMMON_COMMANDS_from(i) _COMMON_COMMANDS_from(i, NULL)
REGISTER_REGISTRY(COMMON_COMMANDS)
REGISTRY_SORT(COMMON_COMMANDS)
+REGISTRY_DEFINE_GET(COMMON_COMMANDS, NULL)
+
#define COMMON_COMMAND(id, description) \
CLASS(commoncommand_##id, Command) \
ATTRIB(commoncommand_##id, m_name, string, #id); \
#pragma once
REGISTRY(SERVER_COMMANDS, BITS(7))
-#define SERVER_COMMANDS_from(i) _SERVER_COMMANDS_from(i, NULL)
REGISTER_REGISTRY(SERVER_COMMANDS)
REGISTRY_SORT(SERVER_COMMANDS)
+REGISTRY_DEFINE_GET(SERVER_COMMANDS, NULL)
+
#define SERVER_COMMAND(id, description) \
CLASS(servercommand_##id, Command) \
ATTRIB(servercommand_##id, m_name, string, #id); \
return;
}
- entity deathent = Deathtypes_from(deathtype - DT_FIRST);
+ entity deathent = REGISTRY_GET(Deathtypes, deathtype - DT_FIRST);
if (!deathent)
{
backtrace("Obituary_SpecialDeath: Could not find deathtype entity!\n");
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \
{ \
.entity weaponentity = weaponentities[slot]; \
- W_SwitchWeapon_TryOthers(this, Weapons_from(WEP_FIRST + i), weaponentity); \
+ W_SwitchWeapon_TryOthers(this, REGISTRY_GET(Weapons, WEP_FIRST + i), weaponentity); \
if(autocvar_g_weaponswitch_debug != 1) \
break; \
} \
return wepent.m_weapon.m_name;
else if(wepent.m_switchweapon != WEP_Null)
return wepent.m_switchweapon.m_name;
- return "none"; //Weapons_from(wepent.cnt).m_name;
+ return "none"; //REGISTRY_GET(Weapons, wepent.cnt).m_name;
}
string formatmessage(entity this, string msg)
{
if (!wep) return;
- STAT(WEAPONS, e) |= WepSet_FromWeapon(Weapons_from(wep));
+ STAT(WEAPONS, e) |= WepSet_FromWeapon(REGISTRY_GET(Weapons, wep));
if (IS_PLAYER(e)) {
Send_Notification(NOTIF_ONE, e, MSG_MULTI, ITEM_WEAPON_GOT, wep);
while(rest != "")
{
weaponwant = stof(car(rest)); rest = cdr(rest);
- wep = Weapons_from(weaponwant);
+ wep = REGISTRY_GET(Weapons, weaponwant);
wepset = wep.m_wepset;
if(imp >= 0)
if(wep.impulse != imp)
while(rest != "")
{
weaponwant = stof(car(rest)); rest = cdr(rest);
- wep = Weapons_from(weaponwant);
+ wep = REGISTRY_GET(Weapons, weaponwant);
wepset = wep.m_wepset;
if(imp >= 0)
if(wep.impulse != imp)
float w;
w = W_GetCycleWeapon(this, weaponorder, dir, -1, 1, true, weaponentity);
if(w > 0)
- W_SwitchWeapon(this, Weapons_from(w), weaponentity);
+ W_SwitchWeapon(this, REGISTRY_GET(Weapons, w), weaponentity);
}
void W_NextWeaponOnImpulse(entity this, float imp, .entity weaponentity)
float w;
w = W_GetCycleWeapon(this, CS(this).cvar_cl_weaponpriority, +1, imp, 1, (CS(this).cvar_cl_weaponimpulsemode == 0), weaponentity);
if(w > 0)
- W_SwitchWeapon(this, Weapons_from(w), weaponentity);
+ W_SwitchWeapon(this, REGISTRY_GET(Weapons, w), weaponentity);
}
// next weapon
// previously used if exists and has ammo, (second) best otherwise
void W_LastWeapon(entity this, .entity weaponentity)
{
- Weapon wep = Weapons_from(this.(weaponentity).cnt);
+ Weapon wep = REGISTRY_GET(Weapons, this.(weaponentity).cnt);
if (client_hasweapon(this, wep, weaponentity, true, false))
W_SwitchWeapon(this, wep, weaponentity);
else
.int weaponcomplainindex;
float W_GetCycleWeapon(entity this, string weaponorder, float dir, float imp, float complain, float skipmissing, .entity weaponentity);
-#define w_getbestweapon(ent,wepent) Weapons_from(W_GetCycleWeapon(ent, CS(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent))
+#define w_getbestweapon(ent,wepent) REGISTRY_GET(Weapons, W_GetCycleWeapon(ent, CS(ent).cvar_cl_weaponpriority, 0, -1, false, true, wepent))
void W_SwitchWeapon_Force(Player this, Weapon w, .entity weaponentity);
// returns amount of ammo used, or -1 for failure, or 0 for no ammo count
float W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo, .entity weaponentity)
{
- Weapon info = Weapons_from(wpn);
+ Weapon info = REGISTRY_GET(Weapons, wpn);
int ammotype = info.ammo_type;
entity wep = spawn();
W_DropEvent(wr_drop,own,wpn,wep,weaponentity);
- if(WepSet_FromWeapon(Weapons_from(wpn)) & WEPSET_SUPERWEAPONS)
+ if(WepSet_FromWeapon(REGISTRY_GET(Weapons, wpn)) & WEPSET_SUPERWEAPONS)
{
Item_SetExpiring(wep, true);
if(own.items & IT_UNLIMITED_SUPERWEAPONS)
if (w == WEP_Null.m_id)
return false;
- return (Weapons_from(w)).weaponthrowable;
+ return (REGISTRY_GET(Weapons, w)).weaponthrowable;
}
// toss current weapon
vector CL_Weapon_GetShotOrg(int wpn)
{
- entity wi = Weapons_from(wpn);
+ entity wi = REGISTRY_GET(Weapons, wpn);
entity e = spawn();
CL_WeaponEntity_SetModel(e, wi.mdl, false);
vector ret = e.movedir;
void W_DropEvent(.void(Weapon, entity actor, .entity) event, entity player, float weapon_type, entity weapon_item, .entity weaponentity)
{
- Weapon w = Weapons_from(weapon_type);
+ Weapon w = REGISTRY_GET(Weapons, weapon_type);
weapon_dropevent_item = weapon_item;
w.event(w, player, weaponentity);
}