Expand local aliases to their target variables
This makes the code easier to read, at the price of a bit of churn.
This commit is contained in:
parent
148fe47d82
commit
28d9358b00
|
@ -580,11 +580,10 @@ static icobjidx_t exists_in_mine_2(const unique_segment &segp, const int objtype
|
|||
auto &Robot_info = LevelSharedRobotInfoState.Robot_info;
|
||||
range_for (const auto curobjp, objects_in(segp, vcobjptridx, vcsegptr))
|
||||
{
|
||||
const auto &objnum = curobjp;
|
||||
if (special == ESCORT_GOAL_PLAYER_SPEW && curobjp->type == OBJ_POWERUP)
|
||||
{
|
||||
if (curobjp->flags & OF_PLAYER_DROPPED)
|
||||
return objnum;
|
||||
return curobjp;
|
||||
}
|
||||
|
||||
if (curobjp->type == objtype) {
|
||||
|
@ -592,16 +591,16 @@ static icobjidx_t exists_in_mine_2(const unique_segment &segp, const int objtype
|
|||
if ((curobjp->type == OBJ_ROBOT) && (Robot_info[get_robot_id(curobjp)].companion))
|
||||
;
|
||||
else if (objid == -1) {
|
||||
return objnum;
|
||||
return curobjp;
|
||||
} else if (curobjp->id == objid)
|
||||
return objnum;
|
||||
return curobjp;
|
||||
}
|
||||
|
||||
if (objtype == OBJ_POWERUP && curobjp->type == OBJ_ROBOT)
|
||||
if (curobjp->contains_count)
|
||||
if (curobjp->contains_type == OBJ_POWERUP)
|
||||
if (curobjp->contains_id == objid)
|
||||
return objnum;
|
||||
return curobjp;
|
||||
}
|
||||
return object_none;
|
||||
}
|
||||
|
|
|
@ -1334,7 +1334,6 @@ static void add_segment_edges(fvcsegptr &vcsegptr, fvcwallptr &vcwallptr, automa
|
|||
auto &vmobjptr = Objects.vmptr;
|
||||
#endif
|
||||
ubyte color;
|
||||
const auto &segnum = seg;
|
||||
|
||||
for (unsigned sn = 0; sn < MAX_SIDES_PER_SEGMENT; ++sn)
|
||||
{
|
||||
|
@ -1428,7 +1427,7 @@ static void add_segment_edges(fvcsegptr &vcsegptr, fvcwallptr &vcwallptr, automa
|
|||
}
|
||||
}
|
||||
|
||||
if (segnum==Player_init[Player_num].segnum)
|
||||
if (seg==Player_init[Player_num].segnum)
|
||||
color = BM_XRGB(31,0,31);
|
||||
|
||||
if ( color != 255 ) {
|
||||
|
@ -1438,22 +1437,22 @@ static void add_segment_edges(fvcsegptr &vcsegptr, fvcwallptr &vcwallptr, automa
|
|||
if (!Automap_debug_show_all_segments)
|
||||
{
|
||||
auto &player_info = get_local_plrobj().ctype.player_info;
|
||||
if ((cheats.fullautomap || player_info.powerup_flags & PLAYER_FLAGS_MAP_ALL) && !LevelUniqueAutomapState.Automap_visited[segnum])
|
||||
if ((cheats.fullautomap || player_info.powerup_flags & PLAYER_FLAGS_MAP_ALL) && !LevelUniqueAutomapState.Automap_visited[seg])
|
||||
color = am->wall_revealed_color;
|
||||
}
|
||||
Here:
|
||||
#endif
|
||||
const auto vertex_list = get_side_verts(segnum,sn);
|
||||
const auto vertex_list = get_side_verts(seg,sn);
|
||||
const uint8_t flags = hidden_flag | no_fade;
|
||||
add_one_edge(am, vertex_list[0], vertex_list[1], color, sn, segnum, flags);
|
||||
add_one_edge(am, vertex_list[1], vertex_list[2], color, sn, segnum, flags);
|
||||
add_one_edge(am, vertex_list[2], vertex_list[3], color, sn, segnum, flags);
|
||||
add_one_edge(am, vertex_list[3], vertex_list[0], color, sn, segnum, flags);
|
||||
add_one_edge(am, vertex_list[0], vertex_list[1], color, sn, seg, flags);
|
||||
add_one_edge(am, vertex_list[1], vertex_list[2], color, sn, seg, flags);
|
||||
add_one_edge(am, vertex_list[2], vertex_list[3], color, sn, seg, flags);
|
||||
add_one_edge(am, vertex_list[3], vertex_list[0], color, sn, seg, flags);
|
||||
|
||||
if ( is_grate ) {
|
||||
const uint8_t grate_flags = flags | EF_GRATE;
|
||||
add_one_edge(am, vertex_list[0], vertex_list[2], color, sn, segnum, grate_flags);
|
||||
add_one_edge(am, vertex_list[1], vertex_list[3], color, sn, segnum, grate_flags);
|
||||
add_one_edge(am, vertex_list[0], vertex_list[2], color, sn, seg, grate_flags);
|
||||
add_one_edge(am, vertex_list[1], vertex_list[3], color, sn, seg, grate_flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,11 +195,10 @@ void fuelcen_activate(const vmsegptridx_t segp)
|
|||
|
||||
//------------------------------------------------------------
|
||||
// Trigger (enable) the materialization center in segment segnum
|
||||
void trigger_matcen(const vmsegptridx_t segnum)
|
||||
void trigger_matcen(const vmsegptridx_t segp)
|
||||
{
|
||||
auto &RobotCenters = LevelSharedRobotcenterState.RobotCenters;
|
||||
auto &Station = LevelUniqueFuelcenterState.Station;
|
||||
const auto &segp = segnum;
|
||||
FuelCenter *robotcen;
|
||||
|
||||
Assert(segp->special == SEGMENT_IS_ROBOTMAKER);
|
||||
|
@ -230,9 +229,9 @@ void trigger_matcen(const vmsegptridx_t segnum)
|
|||
auto &Vertices = LevelSharedVertexState.get_vertices();
|
||||
auto &vcvertptr = Vertices.vcptr;
|
||||
auto &&pos = compute_segment_center(vcvertptr, segp);
|
||||
const auto &&delta = vm_vec_sub(vcvertptr(segnum->verts[0]), pos);
|
||||
const auto &&delta = vm_vec_sub(vcvertptr(segp->verts[0]), pos);
|
||||
vm_vec_scale_add2(pos, delta, F1_0/2);
|
||||
auto objnum = obj_create( OBJ_LIGHT, 0, segnum, pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
|
||||
auto objnum = obj_create( OBJ_LIGHT, 0, segp, pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
|
||||
if (objnum != object_none) {
|
||||
objnum->lifeleft = MATCEN_LIFE;
|
||||
objnum->ctype.light_info.intensity = i2f(8); // Light cast by a fuelcen.
|
||||
|
|
|
@ -815,8 +815,6 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
if (flags&FQ_GET_SEGLIST)
|
||||
seglist.emplace_back(startseg);
|
||||
|
||||
auto &seg = startseg; //the segment we're looking at
|
||||
|
||||
const unsigned cur_nest_level = fvi_nest_count;
|
||||
fvi_nest_count++;
|
||||
|
||||
|
@ -824,7 +822,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
if (flags & FQ_CHECK_OBJS)
|
||||
{
|
||||
const auto &collision = CollisionResult[likely(thisobjnum != object_none) ? thisobjnum->type : 0];
|
||||
range_for (const auto objnum, objects_in(*seg, vcobjptridx, vcsegptr))
|
||||
range_for (const auto objnum, objects_in(*startseg, vcobjptridx, vcsegptr))
|
||||
{
|
||||
if (objnum->flags & OF_SHOULD_BE_DEAD)
|
||||
continue;
|
||||
|
@ -849,26 +847,25 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
#endif
|
||||
|
||||
// If this is a robot:robot collision, only do it if both of them have attack_type != 0 (eg, green guy)
|
||||
const auto &thisobjp = thisobjnum;
|
||||
if (thisobjp->type == OBJ_ROBOT)
|
||||
if (thisobjnum->type == OBJ_ROBOT)
|
||||
if (objnum->type == OBJ_ROBOT)
|
||||
#if defined(DXX_BUILD_DESCENT_I)
|
||||
if (!(Robot_info[get_robot_id(objnum)].attack_type && Robot_info[get_robot_id(thisobjp)].attack_type))
|
||||
if (!(Robot_info[get_robot_id(objnum)].attack_type && Robot_info[get_robot_id(thisobjnum)].attack_type))
|
||||
#endif
|
||||
// -- MK: 11/18/95, 4claws glomming together...this is easy. -- if (!(Robot_info[Objects[objnum].id].attack_type && Robot_info[Objects[thisobjnum].id].attack_type))
|
||||
continue;
|
||||
|
||||
if (thisobjp->type == OBJ_ROBOT && Robot_info[get_robot_id(thisobjp)].attack_type)
|
||||
if (thisobjnum->type == OBJ_ROBOT && Robot_info[get_robot_id(thisobjnum)].attack_type)
|
||||
fudged_rad = (rad*3)/4;
|
||||
|
||||
//if obj is player, and bumping into other player or a weapon of another coop player, reduce radius
|
||||
if (thisobjp->type == OBJ_PLAYER &&
|
||||
if (thisobjnum->type == OBJ_PLAYER &&
|
||||
((objnum->type == OBJ_PLAYER) ||
|
||||
((Game_mode&GM_MULTI_COOP) && objnum->type == OBJ_WEAPON && objnum->ctype.laser_info.parent_type == OBJ_PLAYER)))
|
||||
fudged_rad = rad/2; //(rad*3)/4;
|
||||
|
||||
vms_vector hit_point;
|
||||
const auto &&d = check_vector_to_object(hit_point,p0,p1,fudged_rad,objnum, thisobjp);
|
||||
const auto &&d = check_vector_to_object(hit_point,p0,p1,fudged_rad,objnum, thisobjnum);
|
||||
|
||||
if (d) //we have intersection
|
||||
if (d < closest_d) {
|
||||
|
@ -904,7 +901,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
//for each face we are on the back of, check if intersected
|
||||
|
||||
for (side=0,bit=1;side<6 && endmask>=bit;side++) {
|
||||
const unsigned nv = get_side_is_quad(seg->shared_segment::sides[side]) ? 4 : 3;
|
||||
const unsigned nv = get_side_is_quad(startseg->shared_segment::sides[side]) ? 4 : 3;
|
||||
// commented out by mk on 02/13/94:: if ((num_faces=seg->sides[side].num_faces)==0) num_faces=1;
|
||||
|
||||
for (face=0;face<2;face++,bit<<=1) {
|
||||
|
@ -913,7 +910,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
int face_hit_type; //in what way did we hit the face?
|
||||
|
||||
|
||||
if (seg->children[side] == entry_seg)
|
||||
if (startseg->children[side] == entry_seg)
|
||||
continue; //don't go back through entry side
|
||||
|
||||
//did we go through this wall/door?
|
||||
|
@ -921,13 +918,13 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
vms_vector hit_point;
|
||||
if (startmask & bit) //start was also though. Do extra check
|
||||
face_hit_type = special_check_line_to_face(hit_point,
|
||||
p0,p1,seg,side,
|
||||
p0,p1,startseg,side,
|
||||
face,
|
||||
nv,rad);
|
||||
else
|
||||
//NOTE LINK TO ABOVE!!
|
||||
face_hit_type = check_line_to_face(hit_point,
|
||||
p0,p1,seg,side,
|
||||
p0,p1,startseg,side,
|
||||
face,
|
||||
nv,rad);
|
||||
|
||||
|
@ -935,13 +932,13 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
if (face_hit_type) { //through this wall/door
|
||||
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
||||
auto &vcwallptr = Walls.vcptr;
|
||||
auto wid_flag = WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, seg, seg, side);
|
||||
auto wid_flag = WALL_IS_DOORWAY(GameBitmaps, Textures, vcwallptr, startseg, startseg, side);
|
||||
|
||||
//if what we have hit is a door, check the adjoining seg
|
||||
|
||||
if (thisobjnum == get_local_player().objnum && cheats.ghostphysics)
|
||||
{
|
||||
if (IS_CHILD(seg->children[side]))
|
||||
if (IS_CHILD(startseg->children[side]))
|
||||
wid_flag |= WID_FLY_FLAG;
|
||||
}
|
||||
|
||||
|
@ -952,7 +949,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
#elif defined(DXX_BUILD_DESCENT_II)
|
||||
((wid_flag & WID_RENDER_FLAG) && (wid_flag & WID_RENDPAST_FLAG)) &&
|
||||
#endif
|
||||
((flags & FQ_TRANSWALL) || (flags & FQ_TRANSPOINT && check_trans_wall(hit_point,seg,side,face))))) {
|
||||
((flags & FQ_TRANSWALL) || (flags & FQ_TRANSPOINT && check_trans_wall(hit_point,startseg,side,face))))) {
|
||||
|
||||
segnum_t newsegnum,sub_hit_seg;
|
||||
vms_vector sub_hit_point;
|
||||
|
@ -962,7 +959,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
|
||||
//do the check recursively on the next seg.
|
||||
|
||||
newsegnum = seg->children[side];
|
||||
newsegnum = startseg->children[side];
|
||||
|
||||
if (!visited[newsegnum]) { //haven't visited here yet
|
||||
visited[newsegnum] = true;
|
||||
|
@ -1016,7 +1013,7 @@ static int fvi_sub(vms_vector &intp, segnum_t &ints, const vms_vector &p0, const
|
|||
closest_d = d;
|
||||
closest_hit_point = hit_point;
|
||||
hit_type = HIT_WALL;
|
||||
wall_norm = &seg->shared_segment::sides[side].normals[face];
|
||||
wall_norm = &startseg->shared_segment::sides[side].normals[face];
|
||||
if (get_seg_masks(vcvertptr, hit_point, startseg, rad).centermask == 0)
|
||||
hit_seg = startseg; //hit in this segment
|
||||
else
|
||||
|
@ -1219,15 +1216,13 @@ int check_trans_wall(const vms_vector &pnt,const vcsegptridx_t seg,int sidenum,i
|
|||
|
||||
//new function for Mike
|
||||
//note: n_segs_visited must be set to zero before this is called
|
||||
static sphere_intersects_wall_result sphere_intersects_wall(fvcvertptr &vcvertptr, const vms_vector &pnt, const vcsegptridx_t segnum, const fix rad, fvi_segments_visited_t &visited)
|
||||
static sphere_intersects_wall_result sphere_intersects_wall(fvcvertptr &vcvertptr, const vms_vector &pnt, const vcsegptridx_t seg, const fix rad, fvi_segments_visited_t &visited)
|
||||
{
|
||||
int facemask;
|
||||
visited[segnum] = true;
|
||||
visited[seg] = true;
|
||||
++visited.count;
|
||||
|
||||
facemask = get_seg_masks(vcvertptr, pnt, segnum, rad).facemask;
|
||||
|
||||
const auto &seg = segnum;
|
||||
facemask = get_seg_masks(vcvertptr, pnt, seg, rad).facemask;
|
||||
|
||||
if (facemask != 0) { //on the back of at least one face
|
||||
|
||||
|
@ -1259,7 +1254,7 @@ static sphere_intersects_wall_result sphere_intersects_wall(fvcvertptr &vcvertpt
|
|||
|
||||
if (!IS_CHILD(child))
|
||||
{
|
||||
return {static_cast<const segment *>(segnum), side};
|
||||
return {static_cast<const segment *>(seg), side};
|
||||
}
|
||||
else if (!visited[child]) { //haven't visited here yet
|
||||
const auto &&r = sphere_intersects_wall(vcvertptr, pnt, seg.absolute_sibling(child), rad, visited);
|
||||
|
|
|
@ -461,13 +461,11 @@ static void create_omega_blobs(const imsegptridx_t firing_segnum, const vms_vect
|
|||
const auto &&segnum = find_point_seg(LevelSharedSegmentState, LevelUniqueSegmentState, temp_pos, last_segnum);
|
||||
if (segnum != segment_none) {
|
||||
last_segnum = segnum;
|
||||
auto blob_objnum = obj_create(OBJ_WEAPON, weapon_id_type::OMEGA_ID, segnum, temp_pos, NULL, 0, CT_WEAPON, MT_PHYSICS, RT_WEAPON_VCLIP );
|
||||
if (blob_objnum == object_none)
|
||||
auto objp = obj_create(OBJ_WEAPON, weapon_id_type::OMEGA_ID, segnum, temp_pos, NULL, 0, CT_WEAPON, MT_PHYSICS, RT_WEAPON_VCLIP );
|
||||
if (objp == object_none)
|
||||
break;
|
||||
|
||||
last_created_objnum = blob_objnum;
|
||||
|
||||
auto &objp = blob_objnum;
|
||||
last_created_objnum = objp;
|
||||
|
||||
objp->lifeleft = OMEGA_BASE_TIME+(d_rand()/8); // add little randomness so the lighting effect becomes a little more interesting
|
||||
objp->mtype.phys_info.velocity = vec_to_goal;
|
||||
|
|
|
@ -1669,16 +1669,15 @@ static void multi_do_fire(fvmobjptridx &vmobjptridx, const playernum_t pnum, con
|
|||
if (weapon == primary_weapon_index_t::FUSION_INDEX) {
|
||||
obj->ctype.player_info.Fusion_charge = flags << 12;
|
||||
}
|
||||
auto &objp = obj;
|
||||
if (weapon == weapon_id_type::LASER_ID) {
|
||||
auto &powerup_flags = objp->ctype.player_info.powerup_flags;
|
||||
auto &powerup_flags = obj->ctype.player_info.powerup_flags;
|
||||
if (flags & LASER_QUAD)
|
||||
powerup_flags |= PLAYER_FLAGS_QUAD_LASERS;
|
||||
else
|
||||
powerup_flags &= ~PLAYER_FLAGS_QUAD_LASERS;
|
||||
}
|
||||
|
||||
do_laser_firing(objp, weapon, static_cast<int>(buf[3]), flags, static_cast<int>(buf[5]), shot_orientation, Network_laser_track);
|
||||
do_laser_firing(obj, weapon, static_cast<int>(buf[3]), flags, static_cast<int>(buf[5]), shot_orientation, Network_laser_track);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3788,7 +3787,7 @@ int multi_all_players_alive()
|
|||
return (1);
|
||||
}
|
||||
|
||||
void multi_send_drop_weapon(const vmobjptridx_t objnum, int seed)
|
||||
void multi_send_drop_weapon(const vmobjptridx_t objp, int seed)
|
||||
{
|
||||
auto &Objects = LevelUniqueObjectState.Objects;
|
||||
auto &vmobjptridx = Objects.vmptridx;
|
||||
|
@ -3796,7 +3795,6 @@ void multi_send_drop_weapon(const vmobjptridx_t objnum, int seed)
|
|||
int ammo_count;
|
||||
|
||||
multi_send_position(vmobjptridx(get_local_player().objnum));
|
||||
const auto &objp = objnum;
|
||||
ammo_count = objp->ctype.powerup_info.count;
|
||||
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
|
@ -3809,12 +3807,12 @@ void multi_send_drop_weapon(const vmobjptridx_t objnum, int seed)
|
|||
count++;
|
||||
multi_command<MULTI_DROP_WEAPON> multibuf;
|
||||
multibuf[count++]=static_cast<char>(get_powerup_id(objp));
|
||||
PUT_INTEL_SHORT(&multibuf[count], objnum); count += 2;
|
||||
PUT_INTEL_SHORT(&multibuf[count], objp); count += 2;
|
||||
PUT_INTEL_SHORT(&multibuf[count], static_cast<uint16_t>(ammo_count)); count += 2;
|
||||
PUT_INTEL_INT(&multibuf[count], seed);
|
||||
count += 4;
|
||||
|
||||
map_objnum_local_to_local(objnum);
|
||||
map_objnum_local_to_local(objp);
|
||||
|
||||
multi_send_data(multibuf, 2);
|
||||
}
|
||||
|
|
|
@ -906,15 +906,15 @@ static bool do_door_close(active_door &d)
|
|||
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
||||
auto &vmwallptr = Walls.vmptr;
|
||||
auto &w0 = *vmwallptr(d.front_wallnum[0]);
|
||||
const auto &&wsegp = vmsegptridx(w0.segnum);
|
||||
const auto &&seg = vmsegptridx(w0.segnum);
|
||||
|
||||
//check for objects in doorway before closing
|
||||
if (w0.flags & WALL_DOOR_AUTO)
|
||||
if (is_door_obstructed(vcobjptridx, vcsegptr, wsegp, w0.sidenum))
|
||||
if (is_door_obstructed(vcobjptridx, vcsegptr, seg, w0.sidenum))
|
||||
{
|
||||
#if defined(DXX_BUILD_DESCENT_II)
|
||||
digi_kill_sound_linked_to_segment(w0.segnum, w0.sidenum, -1);
|
||||
wall_open_door(wsegp, w0.sidenum); //re-open door
|
||||
wall_open_door(seg, w0.sidenum); //re-open door
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -929,7 +929,6 @@ static bool do_door_close(active_door &d)
|
|||
|
||||
auto &wp = *vmwallptr(p);
|
||||
|
||||
const auto &seg = wsegp;
|
||||
side = wp.sidenum;
|
||||
|
||||
if (seg->shared_segment::sides[side].wall_num == wall_none) {
|
||||
|
|
Loading…
Reference in a new issue