From: Mario Date: Fri, 30 Dec 2022 14:32:07 +0000 (+0000) Subject: Add a registry field for renamed weapons to define their previous name to maintain... X-Git-Tag: xonotic-v0.8.6~238^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=83aa41f3c3059b7987a0310feb6cb64fa81ee6fb;p=xonotic%2Fxonotic-data.pk3dir.git Add a registry field for renamed weapons to define their previous name to maintain compatibility --- diff --git a/qcsrc/common/mutators/mutator/buffs/all.inc b/qcsrc/common/mutators/mutator/buffs/all.inc index 1572a75e5..92602d892 100644 --- a/qcsrc/common/mutators/mutator/buffs/all.inc +++ b/qcsrc/common/mutators/mutator/buffs/all.inc @@ -1,4 +1,4 @@ -string Buff_UndeprecateName(string buffname) +string Buff_CompatName(string buffname) { switch(buffname) { diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qh b/qcsrc/common/mutators/mutator/buffs/buffs.qh index 163176d5b..ae465dfdb 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qh @@ -67,7 +67,7 @@ STATIC_INIT(REGISTER_BUFFS) { #define BUFF_SPAWNFUNC_Q3COMPAT(o, r) #endif -string Buff_UndeprecateName(string buffname); +string Buff_CompatName(string buffname); BUFF_SPAWNFUNCS(random, NULL) diff --git a/qcsrc/common/mutators/mutator/overkill/okhmg.qh b/qcsrc/common/mutators/mutator/overkill/okhmg.qh index 8f597e01b..55fea8ca7 100644 --- a/qcsrc/common/mutators/mutator/overkill/okhmg.qh +++ b/qcsrc/common/mutators/mutator/overkill/okhmg.qh @@ -20,6 +20,7 @@ CLASS(OverkillHeavyMachineGun, Weapon) /* wepimg */ ATTRIB(OverkillHeavyMachineGun, model2, string, "weaponhmg"); /* refname */ ATTRIB(OverkillHeavyMachineGun, netname, string, "okhmg"); /* wepname */ ATTRIB(OverkillHeavyMachineGun, m_name, string, _("Overkill Heavy Machine Gun")); +/* legacy */ ATTRIB(OverkillHeavyMachineGun, m_deprecated_netname, string, "hmg"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/common/mutators/mutator/overkill/okrpc.qh b/qcsrc/common/mutators/mutator/overkill/okrpc.qh index 60c0c9a2d..23421d2f5 100644 --- a/qcsrc/common/mutators/mutator/overkill/okrpc.qh +++ b/qcsrc/common/mutators/mutator/overkill/okrpc.qh @@ -20,6 +20,7 @@ CLASS(OverkillRocketPropelledChainsaw, Weapon) /* wepimg */ ATTRIB(OverkillRocketPropelledChainsaw, model2, string, "weaponrpc"); /* refname */ ATTRIB(OverkillRocketPropelledChainsaw, netname, string, "okrpc"); /* wepname */ ATTRIB(OverkillRocketPropelledChainsaw, m_name, string, _("Overkill Rocket Propelled Chainsaw")); +/* legacy */ ATTRIB(OverkillRocketPropelledChainsaw, m_deprecated_netname, string, "rpc"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 6bf2d105f..07c51f18d 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -107,21 +107,6 @@ string W_NameWeaponOrder_MapFunc(string s) return s; } -string W_UndeprecateName(string s) -{ - switch (s) - { - case "nex": return "vortex"; - case "rocketlauncher": return "devastator"; - case "laser": return "blaster"; - case "minstanex": return "vaporizer"; - case "grenadelauncher": return "mortar"; - case "uzi": return "machinegun"; - case "hmg": return "okhmg"; - case "rpc": return "okrpc"; - default: return s; - } -} string W_NameWeaponOrder(string order) { return mapPriorityList(order, W_NameWeaponOrder_MapFunc); @@ -129,8 +114,7 @@ string W_NameWeaponOrder(string order) string W_NumberWeaponOrder_MapFunc(string s) { if (s == "0" || stof(s)) return s; - s = W_UndeprecateName(s); - FOREACH(Weapons, it != WEP_Null && it.netname == s, return ftos(i)); + FOREACH(Weapons, it != WEP_Null && (it.netname == s || it.m_deprecated_netname == s), return ftos(i)); return s; } string W_NumberWeaponOrder(string order) diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 70009b15f..677d5d1b2 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -76,6 +76,8 @@ CLASS(Weapon, Object) ATTRIB(Weapon, netname, string, ""); /** M: wepname : human readable name */ ATTRIB(Weapon, m_name, string, "AOL CD Thrower"); + /** M: deprecated refname : old reference name for compatibility with weapons that were renamed */ + ATTRIB(Weapon, m_deprecated_netname, string, ""); ATTRIB(Weapon, m_pickup, entity); @@ -215,7 +217,6 @@ string weaponorder_byid; // functions: string W_FixWeaponOrder(string order, float complete); -string W_UndeprecateName(string s); string W_NameWeaponOrder(string order); string W_NumberWeaponOrder(string order); string W_FixWeaponOrder_BuildImpulseList(string o); diff --git a/qcsrc/common/weapons/weapon/blaster.qh b/qcsrc/common/weapons/weapon/blaster.qh index d768abfaf..6eebd4c39 100644 --- a/qcsrc/common/weapons/weapon/blaster.qh +++ b/qcsrc/common/weapons/weapon/blaster.qh @@ -18,6 +18,7 @@ CLASS(Blaster, Weapon) /* wepimg */ ATTRIB(Blaster, model2, string, "weaponlaser"); /* refname */ ATTRIB(Blaster, netname, string, "blaster"); /* wepname */ ATTRIB(Blaster, m_name, string, _("Blaster")); +/* legacy */ ATTRIB(Blaster, m_deprecated_netname, string, "laser"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/common/weapons/weapon/devastator.qh b/qcsrc/common/weapons/weapon/devastator.qh index 70c72f52c..7a10bf62a 100644 --- a/qcsrc/common/weapons/weapon/devastator.qh +++ b/qcsrc/common/weapons/weapon/devastator.qh @@ -18,6 +18,7 @@ CLASS(Devastator, Weapon) /* wepimg */ ATTRIB(Devastator, model2, string, "weaponrocketlauncher"); /* refname */ ATTRIB(Devastator, netname, string, "devastator"); /* wepname */ ATTRIB(Devastator, m_name, string, _("Devastator")); +/* legacy */ ATTRIB(Devastator, m_deprecated_netname, string, "rocketlauncher"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/common/weapons/weapon/machinegun.qh b/qcsrc/common/weapons/weapon/machinegun.qh index 9a2adf46c..a4097f947 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qh +++ b/qcsrc/common/weapons/weapon/machinegun.qh @@ -18,6 +18,7 @@ CLASS(MachineGun, Weapon) /* wepimg */ ATTRIB(MachineGun, model2, string, "weaponuzi"); /* refname */ ATTRIB(MachineGun, netname, string, "machinegun"); /* wepname */ ATTRIB(MachineGun, m_name, string, _("MachineGun")); +/* legacy */ ATTRIB(MachineGun, m_deprecated_netname, string, "uzi"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/common/weapons/weapon/mortar.qh b/qcsrc/common/weapons/weapon/mortar.qh index 118e5c5f0..6d44e7564 100644 --- a/qcsrc/common/weapons/weapon/mortar.qh +++ b/qcsrc/common/weapons/weapon/mortar.qh @@ -18,6 +18,7 @@ CLASS(Mortar, Weapon) /* wepimg */ ATTRIB(Mortar, model2, string, "weapongrenadelauncher"); /* refname */ ATTRIB(Mortar, netname, string, "mortar"); /* wepname */ ATTRIB(Mortar, m_name, string, _("Mortar")); +/* legacy */ ATTRIB(Mortar, m_deprecated_netname, string, "grenadelauncher"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/common/weapons/weapon/vaporizer.qh b/qcsrc/common/weapons/weapon/vaporizer.qh index 277557e9c..87249f736 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qh +++ b/qcsrc/common/weapons/weapon/vaporizer.qh @@ -19,6 +19,7 @@ CLASS(Vaporizer, Weapon) /* wepimg */ ATTRIB(Vaporizer, model2, string, "weaponminstanex"); /* refname */ ATTRIB(Vaporizer, netname, string, "vaporizer"); /* wepname */ ATTRIB(Vaporizer, m_name, string, _("Vaporizer")); +/* legacy */ ATTRIB(Vaporizer, m_deprecated_netname, string, "minstanex"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/common/weapons/weapon/vortex.qh b/qcsrc/common/weapons/weapon/vortex.qh index babbfe51b..2d80a7a61 100644 --- a/qcsrc/common/weapons/weapon/vortex.qh +++ b/qcsrc/common/weapons/weapon/vortex.qh @@ -19,6 +19,7 @@ CLASS(Vortex, Weapon) /* wepimg */ ATTRIB(Vortex, model2, string, "weaponnex"); /* refname */ ATTRIB(Vortex, netname, string, "vortex"); /* wepname */ ATTRIB(Vortex, m_name, string, _("Vortex")); +/* legacy */ ATTRIB(Vortex, m_deprecated_netname, string, "nex"); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ diff --git a/qcsrc/server/items/items.qc b/qcsrc/server/items/items.qc index 5e900a603..33e6edc01 100644 --- a/qcsrc/server/items/items.qc +++ b/qcsrc/server/items/items.qc @@ -1288,7 +1288,7 @@ spawnfunc(target_items) { FOREACH(StatusEffect, it.instanceOfBuff, { - string s = Buff_UndeprecateName(argv(j)); + string s = Buff_CompatName(argv(j)); if(s == it.netname) { this.buffdef = it; @@ -1298,8 +1298,8 @@ spawnfunc(target_items) } }); FOREACH(Weapons, it != WEP_Null, { - string s = W_UndeprecateName(argv(j)); - if(s == it.netname) + string s = argv(j); + if(s == it.netname || s == it.m_deprecated_netname) { STAT(WEAPONS, this) |= (it.m_wepset); if(this.spawnflags == 0 || this.spawnflags == 2) @@ -1364,7 +1364,8 @@ spawnfunc(target_items) n = tokenize_console(this.netname); for(int j = 0; j < n; ++j) { - FOREACH(Weapons, it != WEP_Null && W_UndeprecateName(argv(j)) == it.netname, { + string cmd = argv(j); + FOREACH(Weapons, it != WEP_Null && (cmd == it.netname || cmd == it.m_deprecated_netname), { it.wr_init(it); break; }); @@ -1663,12 +1664,12 @@ float GiveItems(entity e, float beginarg, float endarg) got += GiveResourceValue(e, RES_FUEL, op, val); break; default: - FOREACH(StatusEffect, it.instanceOfBuff && buff_Available(it) && Buff_UndeprecateName(cmd) == it.netname, + FOREACH(StatusEffect, it.instanceOfBuff && buff_Available(it) && Buff_CompatName(cmd) == it.netname, { got += GiveBuff(e, it, op, val); break; }); - FOREACH(Weapons, it != WEP_Null && W_UndeprecateName(cmd) == it.netname, { + FOREACH(Weapons, it != WEP_Null && (cmd == it.netname || cmd == it.m_deprecated_netname), { got += GiveWeapon(e, it.m_id, op, val); break; });