]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
q3compat: Fix null function crash when a weapon has no ammo_type
authorbones_was_here <bones_was_here@xa.org.au>
Wed, 23 Sep 2020 14:05:51 +0000 (00:05 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Wed, 23 Sep 2020 14:05:51 +0000 (00:05 +1000)
qcsrc/common/items/item.qh
qcsrc/common/weapons/all.qc
qcsrc/server/compat/quake3.qc

index 5c6ec494a3d33bd92536aa5a701d7d8da2971514..26f89cad5f45f598e7f13ae119db9eadab882ae5 100644 (file)
@@ -65,7 +65,7 @@ const int ITS_GLOW              = BIT(6);
 .float invincible_finished; // ditto
 
 #define spawnfunc_body(item) \
-       if (!Item_IsDefinitionAllowed(item)) \
+       if (!(item) || !Item_IsDefinitionAllowed(item)) \
        { \
                startitem_failed = true; \
                delete(this); \
index 606090db315cedf59e314fd29f411ddb1ea8b087..5de760d4854fd81422e9112c571723005e896aa5 100644 (file)
@@ -254,14 +254,15 @@ entity GetAmmoItem(int ammotype)
 #ifdef SVQC
 int GetAmmoConsumptionPrimary(string netname)
 // Returns ammo consumed per shot by the primary/default fire mode
+// Returns 0 if the netname has no ammo cvar
 {
        switch (netname)
        {
-               case "arc":        return cvar("g_balance_arc_beam_ammo");
-               case "devastator": return cvar("g_balance_devastator_ammo");
-               case "machinegun": return cvar("g_balance_machinegun_sustained_ammo");
-               case "minelayer":  return cvar("g_balance_minelayer_ammo");
-               case "seeker":     return cvar("g_balance_seeker_tag_ammo");
+               case "arc":        return autocvar_g_balance_arc_beam_ammo;
+               case "devastator": return autocvar_g_balance_devastator_ammo;
+               case "machinegun": return autocvar_g_balance_machinegun_sustained_ammo;
+               case "minelayer":  return autocvar_g_balance_minelayer_ammo;
+               case "seeker":     return autocvar_g_balance_seeker_tag_ammo;
                default:           return cvar(strcat("g_balance_", netname, "_primary_ammo"));
        }
 }
index 85219b1c8de98e67065cd9e42b63978d314cc30f..f850b84b6080cea22b3fdc52860781728b259630 100644 (file)
@@ -78,6 +78,7 @@ SPAWNFUNC_Q3(weapon_railgun, ammo_slugs, WEP_VORTEX)
 
 // BFG -> Crylink || Fireball
 SPAWNFUNC_Q3_COND(weapon_bfg, ammo_bfg, cvar_string("g_mod_balance") == "XDF", WEP_CRYLINK, WEP_FIREBALL)
+       // FIXME: WEP_FIREBALL has no ammo_type field so ammo_bfg is deleted by spawnfunc_body
 
 // grappling hook -> hook
 SPAWNFUNC_WEAPON(weapon_grapplinghook, WEP_HOOK)