Split object_create_egg
This commit is contained in:
parent
f5b02ce6a0
commit
1cdc43d71a
|
@ -242,7 +242,8 @@ segnum_t find_object_seg(vobjptr_t obj);
|
|||
void fix_object_segs();
|
||||
|
||||
// Drops objects contained in objp.
|
||||
objptridx_t object_create_egg(vobjptr_t objp);
|
||||
objptridx_t object_create_robot_egg(vobjptr_t objp);
|
||||
objptridx_t object_create_robot_egg(int type, int id, int num, const vms_vector &init_vel, const vms_vector &pos, const vsegptridx_t segnum);
|
||||
|
||||
// Interface to object_create_egg, puts count objects of type type, id
|
||||
// = id in objp and then drops them.
|
||||
|
|
|
@ -946,30 +946,37 @@ static bool skip_create_egg_powerup(powerup_type_t powerup)
|
|||
// ----------------------------------------------------------------------------
|
||||
// Returns created object number.
|
||||
// If object dropped by player, set flag.
|
||||
objptridx_t object_create_egg(const vobjptr_t objp)
|
||||
static objptridx_t object_create_player_egg(int type, int id, int num, const vms_vector &init_vel, const vms_vector &pos, const vsegptridx_t segnum)
|
||||
{
|
||||
const auto rval = drop_powerup(type, id, num, init_vel, pos, segnum);
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
if (rval != object_none)
|
||||
rval->flags |= OF_PLAYER_DROPPED;
|
||||
#endif
|
||||
return rval;
|
||||
}
|
||||
|
||||
objptridx_t object_create_robot_egg(int type, int id, int num, const vms_vector &init_vel, const vms_vector &pos, const vsegptridx_t segnum)
|
||||
{
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
if (!(Game_mode & GM_MULTI) & (objp->type != OBJ_PLAYER))
|
||||
if (!(Game_mode & GM_MULTI))
|
||||
{
|
||||
if (objp->contains_type == OBJ_POWERUP)
|
||||
if (type == OBJ_POWERUP)
|
||||
{
|
||||
if (skip_create_egg_powerup(static_cast<powerup_type_t>(objp->contains_id)))
|
||||
if (skip_create_egg_powerup(static_cast<powerup_type_t>(id)))
|
||||
return object_none;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
const objptridx_t rval = drop_powerup(objp->contains_type, objp->contains_id, objp->contains_count, objp->mtype.phys_info.velocity, objp->pos, objp->segnum);
|
||||
const auto rval = drop_powerup(type, id, num, init_vel, pos, segnum);
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
if (rval != object_none)
|
||||
{
|
||||
if ((objp->type == OBJ_PLAYER) && (objp->id == Player_num))
|
||||
rval->flags |= OF_PLAYER_DROPPED;
|
||||
|
||||
if (objp->type == OBJ_ROBOT && objp->contains_type==OBJ_POWERUP)
|
||||
if (type == OBJ_POWERUP)
|
||||
{
|
||||
if (objp->contains_id==POW_VULCAN_WEAPON || objp->contains_id==POW_GAUSS_WEAPON)
|
||||
if (id == POW_VULCAN_WEAPON || id == POW_GAUSS_WEAPON)
|
||||
rval->ctype.powerup_info.count = VULCAN_WEAPON_AMMO_AMOUNT;
|
||||
else if (objp->contains_id==POW_OMEGA_WEAPON)
|
||||
else if (id == POW_OMEGA_WEAPON)
|
||||
rval->ctype.powerup_info.count = MAX_OMEGA_CHARGE;
|
||||
}
|
||||
}
|
||||
|
@ -977,6 +984,11 @@ objptridx_t object_create_egg(const vobjptr_t objp)
|
|||
return rval;
|
||||
}
|
||||
|
||||
objptridx_t object_create_robot_egg(const vobjptr_t objp)
|
||||
{
|
||||
return object_create_robot_egg(objp->contains_type, objp->contains_id, objp->contains_count, objp->mtype.phys_info.velocity, objp->pos, objp->segnum);
|
||||
}
|
||||
|
||||
// -- extern int Items_destroyed;
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
@ -985,10 +997,7 @@ objptridx_t object_create_egg(const vobjptr_t objp)
|
|||
objptridx_t call_object_create_egg(const vobjptr_t objp, int count, int type, int id)
|
||||
{
|
||||
if (count > 0) {
|
||||
objp->contains_count = count;
|
||||
objp->contains_type = type;
|
||||
objp->contains_id = id;
|
||||
return object_create_egg(objp);
|
||||
return object_create_player_egg(type, id, count, objp->mtype.phys_info.velocity, objp->pos, objp->segnum);
|
||||
}
|
||||
|
||||
return object_none;
|
||||
|
@ -1156,7 +1165,7 @@ void do_explosion_sequence(const vobjptr_t obj)
|
|||
// If dropping a weapon that the player has, drop energy instead, unless it's vulcan, in which case drop vulcan ammo.
|
||||
if (del_obj->contains_type == OBJ_POWERUP)
|
||||
maybe_replace_powerup_with_energy(del_obj);
|
||||
object_create_egg(del_obj);
|
||||
object_create_robot_egg(del_obj);
|
||||
} else if ((del_obj->type == OBJ_ROBOT) && !(Game_mode & GM_MULTI)) { // Multiplayer handled outside this code!!
|
||||
robot_info *robptr = &Robot_info[get_robot_id(del_obj)];
|
||||
if (robptr->contains_count) {
|
||||
|
@ -1165,7 +1174,7 @@ void do_explosion_sequence(const vobjptr_t obj)
|
|||
del_obj->contains_type = robptr->contains_type;
|
||||
del_obj->contains_id = robptr->contains_id;
|
||||
maybe_replace_powerup_with_energy(del_obj);
|
||||
object_create_egg(del_obj);
|
||||
object_create_robot_egg(del_obj);
|
||||
}
|
||||
}
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
|
|
|
@ -3503,7 +3503,7 @@ int multi_delete_extra_objects()
|
|||
// Before deleting object, if it's a robot, drop it's special powerup, if any
|
||||
if (objp->type == OBJ_ROBOT)
|
||||
if (objp->contains_count && (objp->contains_type == OBJ_POWERUP))
|
||||
object_create_egg(objp);
|
||||
object_create_robot_egg(objp);
|
||||
#endif
|
||||
obj_delete(objp);
|
||||
}
|
||||
|
|
|
@ -822,7 +822,7 @@ int multi_explode_robot_sub(const vobjptridx_t robot)
|
|||
// Drop non-random KEY powerups locally only!
|
||||
if ((robot->contains_count > 0) && (robot->contains_type == OBJ_POWERUP) && (Game_mode & GM_MULTI_COOP) && (robot->contains_id >= POW_KEY_BLUE) && (robot->contains_id <= POW_KEY_GOLD))
|
||||
{
|
||||
object_create_egg(robot);
|
||||
object_create_robot_egg(robot);
|
||||
}
|
||||
else if (robot->ctype.ai_info.REMOTE_OWNER == Player_num)
|
||||
{
|
||||
|
@ -1064,21 +1064,18 @@ void multi_do_create_robot_powerups(const playernum_t pnum, const ubyte *buf)
|
|||
// Code to drop remote-controlled robot powerups
|
||||
|
||||
int loc = 1;
|
||||
object del_obj{};
|
||||
del_obj.type = OBJ_ROBOT;
|
||||
|
||||
; loc += 1;
|
||||
del_obj.contains_count = buf[loc]; loc += 1;
|
||||
del_obj.contains_type = buf[loc]; loc += 1;
|
||||
del_obj.contains_id = buf[loc]; loc += 1;
|
||||
del_obj.segnum = GET_INTEL_SHORT(buf + loc); loc += 2;
|
||||
memcpy(&del_obj.pos, buf+loc, sizeof(vms_vector)); loc += 12;
|
||||
uint8_t contains_count = buf[loc]; loc += 1;
|
||||
uint8_t contains_type = buf[loc]; loc += 1;
|
||||
uint8_t contains_id = buf[loc]; loc += 1;
|
||||
segnum_t segnum = GET_INTEL_SHORT(buf + loc); loc += 2;
|
||||
vms_vector pos;
|
||||
memcpy(&pos, &buf[loc], sizeof(pos)); loc += 12;
|
||||
|
||||
vm_vec_zero(del_obj.mtype.phys_info.velocity);
|
||||
|
||||
del_obj.pos.x = (fix)INTEL_INT((int)del_obj.pos.x);
|
||||
del_obj.pos.y = (fix)INTEL_INT((int)del_obj.pos.y);
|
||||
del_obj.pos.z = (fix)INTEL_INT((int)del_obj.pos.z);
|
||||
vms_vector velocity{};
|
||||
pos.x = (fix)INTEL_INT((int)pos.x);
|
||||
pos.y = (fix)INTEL_INT((int)pos.y);
|
||||
pos.z = (fix)INTEL_INT((int)pos.z);
|
||||
|
||||
Assert(pnum < N_players);
|
||||
Assert (pnum!=Player_num); // What? How'd we send ourselves this?
|
||||
|
@ -1086,7 +1083,7 @@ void multi_do_create_robot_powerups(const playernum_t pnum, const ubyte *buf)
|
|||
Net_create_loc = 0;
|
||||
d_srand(1245L);
|
||||
|
||||
auto egg_objnum = object_create_egg(&del_obj);
|
||||
const auto egg_objnum = object_create_robot_egg(contains_type, contains_id, contains_count, velocity, pos, segnum);
|
||||
|
||||
if (egg_objnum == object_none)
|
||||
return; // Object buffer full
|
||||
|
@ -1138,7 +1135,7 @@ void multi_drop_robot_powerups(const vobjptridx_t del_obj)
|
|||
}
|
||||
d_srand(1245L);
|
||||
if (del_obj->contains_count > 0)
|
||||
egg_objnum = object_create_egg(del_obj);
|
||||
egg_objnum = object_create_robot_egg(del_obj);
|
||||
}
|
||||
|
||||
else if (del_obj->ctype.ai_info.REMOTE_OWNER == -1) // No random goodies for robots we weren't in control of
|
||||
|
@ -1159,7 +1156,7 @@ void multi_drop_robot_powerups(const vobjptridx_t del_obj)
|
|||
|
||||
d_srand(1245L);
|
||||
if (del_obj->contains_count > 0)
|
||||
egg_objnum = object_create_egg(del_obj);
|
||||
egg_objnum = object_create_robot_egg(del_obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue