]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a registry field for renamed weapons to define their previous name to maintain...
authorMario <mario.mario@y7mail.com>
Fri, 30 Dec 2022 14:32:07 +0000 (14:32 +0000)
committerterencehill <piuntn@gmail.com>
Fri, 30 Dec 2022 14:32:07 +0000 (14:32 +0000)
13 files changed:
qcsrc/common/mutators/mutator/buffs/all.inc
qcsrc/common/mutators/mutator/buffs/buffs.qh
qcsrc/common/mutators/mutator/overkill/okhmg.qh
qcsrc/common/mutators/mutator/overkill/okrpc.qh
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/blaster.qh
qcsrc/common/weapons/weapon/devastator.qh
qcsrc/common/weapons/weapon/machinegun.qh
qcsrc/common/weapons/weapon/mortar.qh
qcsrc/common/weapons/weapon/vaporizer.qh
qcsrc/common/weapons/weapon/vortex.qh
qcsrc/server/items/items.qc

index 1572a75e55d9d9dc0599b05946f0c7a3eb84a542..92602d892d03d290f052f92bbc06db0cf3254380 100644 (file)
@@ -1,4 +1,4 @@
-string Buff_UndeprecateName(string buffname)
+string Buff_CompatName(string buffname)
 {
     switch(buffname)
     {
index 163176d5b5fa33f71cf4be53ff52aa72bbed1e5b..ae465dfdb3a5e8bfd0049894e403bb74a718dab6 100644 (file)
@@ -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)
 
index 8f597e01b2924b182338d8705522a1a9dc116e19..55fea8ca754e4570ab99293d8d86476296e07fb6 100644 (file)
@@ -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) \
index 60c0c9a2df1d55790da28557a884fe9015c3e85c..23421d2f542dfd4f467994ec04d34ab605c2b89e 100644 (file)
@@ -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) \
index 6bf2d105f8d85c4c82299c9a216f3e20cd818062..07c51f18ddcf7853c19538d3f3784aaf959e1bb4 100644 (file)
@@ -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)
index 70009b15ffc32152ddf3a1c769e534146aebc4b7..677d5d1b2ad813809c02e2b09a60f19bfa329282 100644 (file)
@@ -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);
index d768abfafe46ada390d6f4dfea6c4b3558c3c961..6eebd4c39e6d6b60e34b4b051910c89430ce0f97 100644 (file)
@@ -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) \
index 70c72f52cba160dbcad5ab19e82e476f102f090c..7a10bf62a17358ff085a8464d70fcdc24f1b7bfb 100644 (file)
@@ -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) \
index 9a2adf46c94d42d17dfda956578c249857e09181..a4097f947e252dfa01d49ba4c99459d7ca3cc962 100644 (file)
@@ -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) \
index 118e5c5f0010ee03ce619f2f4b915d8895db3db0..6d44e75644ca0f2efe5865a2f855d46cec3f2c46 100644 (file)
@@ -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) \
index 277557e9cf290554a8fad90596758eabef26f42c..87249f7364b9b6525e9ac74153d4d3902cecd1dd 100644 (file)
@@ -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) \
index babbfe51bb0f25a8a0777ce78cbfc3da08470ce7..2d80a7a61ae89b1266299984f8a783605d9426ab 100644 (file)
@@ -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) \
index 5e900a603977c0b12cc1eb6d834dd545aa699e6e..33e6edc01b780b6ae5410c449b314260e0a116f5 100644 (file)
@@ -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;
                                });