]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
continue macrofication
authordrjaska <drjaska83@gmail.com>
Thu, 29 Dec 2022 12:24:14 +0000 (14:24 +0200)
committerdrjaska <drjaska83@gmail.com>
Thu, 29 Dec 2022 12:24:14 +0000 (14:24 +0200)
qcsrc/client/hud/panel/weapons.qc
qcsrc/common/notifications/all.qh
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/all.qh
qcsrc/common/weapons/weapon.qh
qcsrc/server/compat/quake3.qh
qcsrc/server/items/items.qc

index 720a739910054d03e621202853283e96f76f61b4..cb7c95482254047a102429ba2c9ccad6dda6bac8 100644 (file)
@@ -171,7 +171,7 @@ void HUD_Weapons()
        {
                weapons_orderbyimpulse_old = autocvar_hud_panel_weapons_orderbyimpulse;
                strcpy(cl_weaponpriority_old, autocvar_cl_weaponpriority);
-               string weporder = W_FIXWEAPNORDER_FORCECOMPLETE(W_NUMBERWEAPONORDER(cl_weaponpriority_old));
+               string weporder = W_FIXWEAPONORDER_FORCECOMPLETE(W_NUMBERWEAPONORDER(cl_weaponpriority_old));
                if(autocvar_hud_panel_weapons_orderbyimpulse)
                {
                        weporder = W_FixWeaponOrder_BuildImpulseList(weporder);
index e9eb9895ca6c3300045173db92b25accb11b534d..2df383ce2743292058f0caf10315ea37d15a4e76 100644 (file)
@@ -632,8 +632,8 @@ string notif_arg_item_wepammo(float f1, float f2)
 {
        string ammoitems = "";
        Weapon wep = REGISTRY_GET(Weapons, f1);
-       if (wep.ammo_type.m_name)
-               ammoitems = wep.ammo_type.m_name;
+       if (GETAMMONAME(wep.ammo_type))
+               ammoitems = GETAMMONAME(wep.ammo_type);
        return sprintf(_(" with %d %s"), f2, ammoitems);
 }
 
index 27ab16644322c420936c7a2cb19957adeb996b55..369cf720814bde9e0fe178333a0145518d580e4b 100644 (file)
@@ -170,7 +170,7 @@ WepSet W_RandomWeapons(entity e, WepSet remaining, int n)
 
 // TODO: registry handles for below functions
 // drjaska: made these functions into macros in
-// common/weapons/weapon.qh
+// common/weapons/all.qh
 // instead of registry handles
 #if 0
 string GetAmmoPicture(Resource ammotype)
@@ -200,9 +200,8 @@ string GetAmmoName(Resource ammotype)
                default:          return "batteries";
        }
 }
-#endif
 
-entity GetAmmoItem(Resource ammotype)
+entity GETAMMOITEM(Resource ammotype)
 {
        switch (ammotype)
        {
@@ -218,6 +217,7 @@ entity GetAmmoItem(Resource ammotype)
        // WEAPONTODO: use this generic func to reduce duplication ?
        // GETAMMOPICTURE  GETAMMONAME  notif_arg_item_wepammo  ammo_pickupevalfunc ?
 }
+#endif
 
 string W_Sound(string w_snd)
 {
@@ -770,9 +770,9 @@ NET_HANDLE(w_muzzleflash, bool isNew)
 #endif
 
 #ifdef SVQC
-string W_FIXWEAPNORDER_FORCECOMPLETE_AndBuildImpulseList(entity this, string wo)
+string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo)
 {
-       string o = W_FIXWEAPNORDER_FORCECOMPLETE(wo);
+       string o = W_FIXWEAPONORDER_FORCECOMPLETE(wo);
        strcpy(CS_CVAR(this).weaponorder_byimpulse, W_FixWeaponOrder_BuildImpulseList(o));
        return o;
 }
@@ -788,7 +788,7 @@ REPLICATE(cvar_cl_gunalign, int, "cl_gunalign");
 REPLICATE(cvar_cl_weapon_switch_reload, bool, "cl_weapon_switch_reload");
 REPLICATE(cvar_cl_weapon_switch_fallback_to_impulse, bool, "cl_weapon_switch_fallback_to_impulse");
 REPLICATE(cvar_cl_weaponimpulsemode, int, "cl_weaponimpulsemode");
-REPLICATE(cvar_cl_weaponpriority, string, "cl_weaponpriority", W_FIXWEAPNORDER_FORCECOMPLETE_AndBuildImpulseList);
+REPLICATE(cvar_cl_weaponpriority, string, "cl_weaponpriority", W_FixWeaponOrder_ForceComplete_AndBuildImpulseList);
 REPLICATE(cvar_cl_weaponpriorities[0], string, "cl_weaponpriority0", W_FixWeaponOrder_AllowIncomplete);
 REPLICATE(cvar_cl_weaponpriorities[1], string, "cl_weaponpriority1", W_FixWeaponOrder_AllowIncomplete);
 REPLICATE(cvar_cl_weaponpriorities[2], string, "cl_weaponpriority2", W_FixWeaponOrder_AllowIncomplete);
index 1618b1dc6c3b43dbe958915ae294e60024fe19df..30e442eee894a553b74db093f2185aefc3867197 100644 (file)
 void WriteWepSet(float dest, WepSet w);
 #endif
 
+#define GETAMMOPICTURE(ammotype) GETAMMOITEM(ammotype).m_icon
+#define GETAMMONAME(ammotype) GETAMMOITEM(ammotype).m_name
+#define GETAMMOITEM(ammotype) \
+       (ammotype == RES_SHELLS ? ITEM_Shells : \
+       ammotype == RES_BULLETS ? ITEM_Bullets : \
+       ammotype == RES_ROCKETS ? ITEM_Rockets : \
+       ammotype == RES_CELLS ? ITEM_Cells : \
+       ammotype == RES_PLASMA ? ITEM_Plasma : \
+       ammotype == RES_FUEL ? ITEM_JetpackFuel : NULL)
+
 #ifdef CSQC
 WepSet WepSet_GetFromStat();
 WepSet WepSet_GetFromStat_InMap();
@@ -409,7 +419,7 @@ void wframe_send(entity actor, entity weaponentity, int wepframe, float attackra
 
 void W_MuzzleFlash(Weapon thiswep, entity actor, .entity weaponentity, vector shotorg, vector shotdir);
 
-string W_FIXWEAPNORDER_FORCECOMPLETE_AndBuildImpulseList(entity this, string wo);
+string W_FixWeaponOrder_ForceComplete_AndBuildImpulseList(entity this, string wo);
 string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
 #endif
 
index b2cc8434b420e81b6828e117c475ac43bfe7b18b..717c1f6161b6b7788c71570f2d0956b96bed7a02 100644 (file)
@@ -233,13 +233,9 @@ string W_NumberWeaponOrder_MapFunc(string s);
 string W_FixWeaponOrder_BuildImpulseList(string o);
 string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
 WepSet W_RandomWeapons(entity e, WepSet remaining, int n);
-#define W_FIXWEAPNORDER_FORCECOMPLETE(order) \
+#define W_FIXWEAPONORDER_FORCECOMPLETE(order) \
        W_FIXWEAPONORDER(((order == "") ? W_NUMBERWEAPONORDER(cvar_defstring("cl_weaponpriority")) : order), 1)
 
-#define GETAMMOPICTURE(ammotype) GetAmmoItem(ammotype).m_icon
-#define GETAMMONAME(ammotype) GetAmmoItem(ammotype).m_name
-entity GetAmmoItem(Resource ammotype);
-
 #ifdef CSQC
 #define GETAMMOTYPEFROMNUM(i) \
        i == 0 ? RES_SHELLS : \
index d2c547b6f6e9d3bacce6388c7f5eed703c642be1..165b79a70d7df6c411cc536a5086c6fd5c237a4d 100644 (file)
@@ -21,7 +21,7 @@ int GetAmmoConsumptionQ3(string netname);
        { \
                if(this.count && xonwep.ammo_type) \
                        SetResource(this, xonwep.ammo_type, this.count * GetAmmoConsumptionQ3(xonwep.netname)); \
-       SPAWNFUNC_BODY(GetAmmoItem(xonwep.ammo_type)) \
+       SPAWNFUNC_BODY(GETAMMOITEM(xonwep.ammo_type)) \
        }
 
 // Ammo only, conditional
index 5a973264b2e1baff24c02d5b658ebe743e2ee8b0..7f3c7e8f6972cb7a1d59bf7d35f78257908a61a7 100644 (file)
@@ -1273,22 +1273,23 @@ spawnfunc(target_items)
        {
                for(int j = 0; j < n; ++j)
                {
+                       string s = argv(j);
                        // this is from a time when unlimited superweapons were handled together with ammo in some parts of the code
-                       if     (argv(j) == "unlimited_ammo")         this.items |= IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS;
-                       else if(argv(j) == "unlimited_weapon_ammo")  this.items |= IT_UNLIMITED_AMMO;
-                       else if(argv(j) == "unlimited_superweapons") this.items |= IT_UNLIMITED_SUPERWEAPONS;
-                       else if(argv(j) == "strength")               this.items |= ITEM_Strength.m_itemid;
-                       else if(argv(j) == "invincible")             this.items |= ITEM_Shield.m_itemid;
-                       else if(argv(j) == "speed")                  this.items |= ITEM_Speed.m_itemid;
-                       else if(argv(j) == "invisibility")           this.items |= ITEM_Invisibility.m_itemid;
-                       else if(argv(j) == "superweapons")           this.items |= IT_SUPERWEAPON;
-                       else if(argv(j) == "jetpack")                this.items |= ITEM_Jetpack.m_itemid;
-                       else if(argv(j) == "fuel_regen")             this.items |= ITEM_JetpackRegen.m_itemid;
+                       if     (s == "unlimited_ammo")         this.items |= IT_UNLIMITED_AMMO | IT_UNLIMITED_SUPERWEAPONS;
+                       else if(s == "unlimited_weapon_ammo")  this.items |= IT_UNLIMITED_AMMO;
+                       else if(s == "unlimited_superweapons") this.items |= IT_UNLIMITED_SUPERWEAPONS;
+                       else if(s == "strength")               this.items |= ITEM_Strength.m_itemid;
+                       else if(s == "invincible")             this.items |= ITEM_Shield.m_itemid;
+                       else if(s == "speed")                  this.items |= ITEM_Speed.m_itemid;
+                       else if(s == "invisibility")           this.items |= ITEM_Invisibility.m_itemid;
+                       else if(s == "superweapons")           this.items |= IT_SUPERWEAPON;
+                       else if(s == "jetpack")                this.items |= ITEM_Jetpack.m_itemid;
+                       else if(s == "fuel_regen")             this.items |= ITEM_JetpackRegen.m_itemid;
                        else
                        {
                                FOREACH(StatusEffect, it.instanceOfBuff,
                                {
-                                       string s = Buff_UndeprecateName(argv(j));
+                                       s = Buff_UndeprecateName(s);
                                        if(s == it.netname)
                                        {
                                                this.buffdef = it;
@@ -1298,7 +1299,7 @@ spawnfunc(target_items)
                                        }
                                });
                                FOREACH(Weapons, it != WEP_Null, {
-                                       string s = W_UNDEPRECATENAME(argv(j));
+                                       s = W_UNDEPRECATENAME(s);
                                        if(s == it.netname)
                                        {
                                                STAT(WEAPONS, this) |= (it.m_wepset);
@@ -1364,7 +1365,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 s = argv(j);
+               FOREACH(Weapons, it != WEP_Null && W_UNDEPRECATENAME(s) == it.netname, {
                        it.wr_init(it);
                        break;
                });
@@ -1669,8 +1671,8 @@ float GiveItems(entity e, float beginarg, float endarg)
                                        break;
                                });
                                FOREACH(Weapons, it != WEP_Null && W_UNDEPRECATENAME(cmd) == it.netname, {
-                    got += GiveWeapon(e, it.m_id, op, val);
-                    break;
+                                       got += GiveWeapon(e, it.m_id, op, val);
+                                       break;
                                });
                                break;
                }