From b028cce25b16cd619e47008a2c9d2a20468400d3 Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 11 Aug 2017 23:43:53 +0000 Subject: [PATCH] Move object ammo init into drop_powerup This backports into Descent 1 the special-case that loads a Vulcan cannon when it is dropped. It also fixes a longstanding bug that a robot that drops more than one of the powerup would fill only one of them. --- similar/main/fireball.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/similar/main/fireball.cpp b/similar/main/fireball.cpp index e93a6cd31..1c71976a9 100644 --- a/similar/main/fireball.cpp +++ b/similar/main/fireball.cpp @@ -809,7 +809,6 @@ void maybe_replace_powerup_with_energy(const vmobjptr_t del_obj) } #if defined(DXX_BUILD_DESCENT_I) -#define drop_powerup(id, num, init_vel, pos, segnum, player) (drop_powerup)(id, num, init_vel, pos, segnum) static #endif imobjptridx_t drop_powerup(int id, const unsigned num, const vms_vector &init_vel, const vms_vector &pos, const vmsegptridx_t segnum, const bool player) @@ -893,6 +892,17 @@ imobjptridx_t drop_powerup(int id, const unsigned num, const vms_vector &init_ve if (Game_mode & GM_MULTI) obj->lifeleft /= 2; break; +#if defined(DXX_BUILD_DESCENT_II) + case POW_OMEGA_WEAPON: + if (!player) + obj->ctype.powerup_info.count = MAX_OMEGA_CHARGE; + break; + case POW_GAUSS_WEAPON: +#endif + case POW_VULCAN_WEAPON: + if (!player) + obj->ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT; + break; default: // if (Game_mode & GM_MULTI) // obj->lifeleft = (d_rand() + F1_0*3) * 64; // Lives for 5 to 5.5 binary minutes (a binary minute is 64 seconds) @@ -1025,20 +1035,7 @@ imobjptridx_t object_create_robot_egg(const int type, const int id, const int nu } } #endif - const auto &&rval = drop_robot_egg(type, id, num, init_vel, pos, segnum); -#if defined(DXX_BUILD_DESCENT_II) - if (rval != object_none) - { - if (type == OBJ_POWERUP) - { - if (id == POW_VULCAN_WEAPON || id == POW_GAUSS_WEAPON) - rval->ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT; - else if (id == POW_OMEGA_WEAPON) - rval->ctype.powerup_info.count = MAX_OMEGA_CHARGE; - } - } -#endif - return rval; + return drop_robot_egg(type, id, num, init_vel, pos, segnum); } imobjptridx_t object_create_robot_egg(const vmobjptr_t objp)