Simplify multiplayer powerup creation

Instead of creating the powerup from a player, then overwriting the
location and velocity of the powerup, and fixing up its segment, create
the powerup directly where it should be, with the intended velocity.
This commit is contained in:
Kp 2022-01-09 15:25:42 +00:00
parent 94cfeede5c
commit b8a8a61ff8
6 changed files with 7 additions and 15 deletions

View file

@ -410,6 +410,8 @@ static inline void vm_angvec_make(vms_angvec *v, fixang p, fixang b, fixang h)
v->h = h;
}
extern const vms_vector vmd_zero_vector;
}
#endif

View file

@ -90,9 +90,9 @@ enum class explosion_vclip_stage : int
namespace dsx {
int get_explosion_vclip(const object_base &obj, explosion_vclip_stage stage);
#if defined(DXX_BUILD_DESCENT_II)
imobjptridx_t drop_powerup(const d_vclip_array &Vclip, int id, unsigned num, const vms_vector &init_vel, const vms_vector &pos, vmsegptridx_t segnum, bool player);
#if defined(DXX_BUILD_DESCENT_II)
// creates afterburner blobs behind the specified object
void drop_afterburner_blobs(object &obj, int count, fix size_scale, fix lifetime);

View file

@ -24,6 +24,7 @@ namespace dcx {
//#define USE_ISQRT 1
constexpr vms_matrix vmd_identity_matrix = IDENTITY_MATRIX;
constexpr vms_vector vmd_zero_vector{};
//adds two vectors, fills in dest, returns ptr to dest
//ok for dest to equal either source, but should use vm_vec_add2() if so

View file

@ -105,8 +105,6 @@ namespace {
#define FLY_ACCEL i2f(5)
#define MAX_FLY_OBJECTS 2
constexpr vms_vector vmd_zero_vector{};
d_unique_endlevel_state UniqueEndlevelState;
static void generate_starfield(d_unique_endlevel_state::starfield_type &stars);
static void draw_stars(grs_canvas &, const d_unique_endlevel_state::starfield_type &stars);

View file

@ -1040,9 +1040,6 @@ void maybe_replace_powerup_with_energy(object_base &del_obj)
}
}
#if defined(DXX_BUILD_DESCENT_I)
static
#endif
imobjptridx_t drop_powerup(const d_vclip_array &Vclip, int id, const unsigned num, const vms_vector &init_vel, const vms_vector &pos, const vmsegptridx_t segnum, const bool player)
{
imobjptridx_t objnum = object_none;

View file

@ -2167,7 +2167,7 @@ static void multi_do_controlcen_fire(const ubyte *buf)
Laser_create_new_easy(to_target, objp->ctype.reactor_info.gun_pos[gun_num], objp, weapon_id_type::CONTROLCEN_WEAPON_NUM, 1);
}
static void multi_do_create_powerup(fvmobjptr &vmobjptr, fvmsegptridx &vmsegptridx, const playernum_t pnum, const uint8_t *const buf)
static void multi_do_create_powerup(fvmsegptridx &vmsegptridx, const playernum_t pnum, const uint8_t *const buf)
{
auto &LevelUniqueControlCenterState = LevelUniqueObjectState.ControlCenterState;
int count = 1;
@ -2194,7 +2194,7 @@ static void multi_do_create_powerup(fvmobjptr &vmobjptr, fvmsegptridx &vmsegptri
}
Net_create_loc = 0;
const auto &&my_objnum = call_object_create_egg(vmobjptr(vcplayerptr(pnum)->objnum), 1, powerup_type);
const auto &&my_objnum = drop_powerup(Vclip, powerup_type, 1, vmd_zero_vector, new_pos, segnum, true);
if (my_objnum == object_none) {
return;
@ -2205,12 +2205,6 @@ static void multi_do_create_powerup(fvmobjptr &vmobjptr, fvmsegptridx &vmsegptri
Network_send_objnum = -1;
}
my_objnum->pos = new_pos;
vm_vec_zero(my_objnum->mtype.phys_info.velocity);
obj_relink(vmobjptr, vmsegptr, my_objnum, segnum);
map_objnum_local_to_remote(my_objnum, objnum, pnum);
object_create_explosion(segnum, new_pos, i2f(5), VCLIP_POWERUP_DISAPPEARANCE);
@ -5809,7 +5803,7 @@ static void multi_process_data(const playernum_t pnum, const ubyte *buf, const u
case MULTI_CONTROLCEN_FIRE:
multi_do_controlcen_fire(buf); break;
case MULTI_CREATE_POWERUP:
multi_do_create_powerup(vmobjptr, vmsegptridx, pnum, buf);
multi_do_create_powerup(vmsegptridx, pnum, buf);
break;
case MULTI_PLAY_SOUND:
multi_do_play_sound(Objects, pnum, buf);