Use enumerate when traversing Station
This commit is contained in:
parent
3e02f99bcd
commit
d463b4beba
|
@ -248,8 +248,8 @@ void fuelcen_delete(shared_segment &segp)
|
|||
Restart: ;
|
||||
segp.special = segment_special::nothing;
|
||||
|
||||
for (uint_fast32_t i = 0; i < Num_fuelcenters; i++ ) {
|
||||
FuelCenter &fi = Station[i];
|
||||
for (auto &&[i, fi] : enumerate(partial_range(Station, Num_fuelcenters)))
|
||||
{
|
||||
if (vmsegptr(fi.segnum) == &segp)
|
||||
{
|
||||
|
||||
|
@ -282,9 +282,10 @@ Restart: ;
|
|||
j.fuelcen_num--;
|
||||
Assert(Num_fuelcenters > 0);
|
||||
Num_fuelcenters--;
|
||||
for (uint_fast32_t j = i; j < Num_fuelcenters; j++ ) {
|
||||
Station[j] = Station[j+1];
|
||||
Segments[Station[j].segnum].station_idx = j;
|
||||
for (auto &&[j, fj] : enumerate(partial_range(Station, i, Num_fuelcenters)))
|
||||
{
|
||||
fj = std::move(Station[j + 1]);
|
||||
Segments[fj.segnum].station_idx = j;
|
||||
}
|
||||
goto Restart;
|
||||
}
|
||||
|
@ -426,14 +427,14 @@ static void robotmaker_proc(const d_vclip_array &Vclip, fvmsegptridx &vmsegptrid
|
|||
|
||||
if (robotcen->Timer > top_time ) {
|
||||
int count=0;
|
||||
int my_station_num = numrobotcen;
|
||||
const auto biased_matcen_creator = numrobotcen ^ 0x80;
|
||||
|
||||
// Make sure this robotmaker hasn't put out its max without having any of them killed.
|
||||
range_for (const auto &&objp, vcobjptr)
|
||||
{
|
||||
auto &obj = *objp;
|
||||
if (obj.type == OBJ_ROBOT)
|
||||
if ((obj.matcen_creator ^ 0x80) == my_station_num)
|
||||
if (obj.matcen_creator == biased_matcen_creator)
|
||||
count++;
|
||||
}
|
||||
if (count > GameUniqueState.Difficulty_level + 3) {
|
||||
|
@ -646,18 +647,18 @@ void init_all_matcens(void)
|
|||
auto &Station = LevelUniqueFuelcenterState.Station;
|
||||
const auto Num_fuelcenters = LevelUniqueFuelcenterState.Num_fuelcenters;
|
||||
const auto &&robot_range = partial_const_range(RobotCenters, LevelSharedRobotcenterState.Num_robot_centers);
|
||||
for (uint_fast32_t i = 0; i < Num_fuelcenters; i++)
|
||||
if (Station[i].Type == segment_special::robotmaker)
|
||||
for (auto &&[i, station] : enumerate(partial_range(Station, Num_fuelcenters)))
|
||||
if (station.Type == segment_special::robotmaker)
|
||||
{
|
||||
Station[i].Lives = 3;
|
||||
Station[i].Enabled = 0;
|
||||
Station[i].Disable_time = 0;
|
||||
station.Lives = 3;
|
||||
station.Enabled = 0;
|
||||
station.Disable_time = 0;
|
||||
// Make sure this fuelcen is pointed at by a matcen.
|
||||
if (std::find_if(robot_range.begin(), robot_range.end(), [i](const matcen_info &mi) {
|
||||
return mi.fuelcen_num == i;
|
||||
}) == robot_range.end())
|
||||
{
|
||||
Station[i].Lives = 0;
|
||||
station.Lives = 0;
|
||||
LevelError("Station %" PRIuFAST32 " has type robotmaker, but no robotmaker uses it; ignoring.", i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1022,8 +1022,6 @@ void multi_do_create_robot(const d_vclip_array &Vclip, const playernum_t pnum, c
|
|||
const uint_fast32_t fuelcen_num = buf[2];
|
||||
int type = buf[5];
|
||||
|
||||
FuelCenter *robotcen;
|
||||
|
||||
objnum_t objnum;
|
||||
objnum = GET_INTEL_SHORT(buf + 3);
|
||||
|
||||
|
@ -1033,11 +1031,17 @@ void multi_do_create_robot(const d_vclip_array &Vclip, const playernum_t pnum, c
|
|||
return;
|
||||
}
|
||||
|
||||
robotcen = &Station[fuelcen_num];
|
||||
auto &robotcen = Station[fuelcen_num];
|
||||
|
||||
// Play effect and sound
|
||||
|
||||
const auto &&robotcen_segp = vmsegptridx(robotcen->segnum);
|
||||
// Set robot center flags, in case we become the master for the next one
|
||||
|
||||
robotcen.Flag = 0;
|
||||
robotcen.Capacity -= EnergyToCreateOneRobot;
|
||||
robotcen.Timer = 0;
|
||||
|
||||
const auto &&robotcen_segp = vmsegptridx(robotcen.segnum);
|
||||
auto &vcvertptr = Vertices.vcptr;
|
||||
const auto &&cur_object_loc = compute_segment_center(vcvertptr, robotcen_segp);
|
||||
if (const auto &&obj = object_create_explosion(robotcen_segp, cur_object_loc, i2f(10), VCLIP_MORPHING_ROBOT))
|
||||
|
@ -1045,13 +1049,7 @@ void multi_do_create_robot(const d_vclip_array &Vclip, const playernum_t pnum, c
|
|||
if (Vclip[VCLIP_MORPHING_ROBOT].sound_num > -1)
|
||||
digi_link_sound_to_pos(Vclip[VCLIP_MORPHING_ROBOT].sound_num, robotcen_segp, 0, cur_object_loc, 0, F1_0);
|
||||
|
||||
// Set robot center flags, in case we become the master for the next one
|
||||
|
||||
robotcen->Flag = 0;
|
||||
robotcen->Capacity -= EnergyToCreateOneRobot;
|
||||
robotcen->Timer = 0;
|
||||
|
||||
const auto &&obj = create_morph_robot(vmsegptridx(robotcen->segnum), cur_object_loc, type);
|
||||
const auto &&obj = create_morph_robot(robotcen_segp, cur_object_loc, type);
|
||||
if (obj == object_none)
|
||||
return; // Cannot create object!
|
||||
|
||||
|
|
Loading…
Reference in a new issue