Move Num_fuelcenters to d_level_unique_fuelcenter_state
This commit is contained in:
parent
943e0a8b5f
commit
84fa2cde4a
|
@ -121,6 +121,7 @@ struct d1_matcen_info : public prohibit_void_ptr<d1_matcen_info>
|
||||||
|
|
||||||
struct d_level_unique_fuelcenter_state
|
struct d_level_unique_fuelcenter_state
|
||||||
{
|
{
|
||||||
|
unsigned Num_fuelcenters;
|
||||||
// Original D1 size: 50, Original D2 size: 70
|
// Original D1 size: 50, Original D2 size: 70
|
||||||
array<FuelCenter, 128> Station;
|
array<FuelCenter, 128> Station;
|
||||||
};
|
};
|
||||||
|
@ -181,7 +182,6 @@ void matcen_info_write(PHYSFS_File *fp, const matcen_info &mi, short version);
|
||||||
namespace dcx {
|
namespace dcx {
|
||||||
constexpr std::integral_constant<uint8_t, 0xff> station_none{};
|
constexpr std::integral_constant<uint8_t, 0xff> station_none{};
|
||||||
extern unsigned Num_robot_centers;
|
extern unsigned Num_robot_centers;
|
||||||
extern unsigned Num_fuelcenters;
|
|
||||||
extern const fix EnergyToCreateOneRobot;
|
extern const fix EnergyToCreateOneRobot;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -464,7 +464,6 @@ static void compress_segments(void)
|
||||||
seg = Highest_segment_index;
|
seg = Highest_segment_index;
|
||||||
|
|
||||||
auto &RobotCenters = LevelSharedRobotcenterState.RobotCenters;
|
auto &RobotCenters = LevelSharedRobotcenterState.RobotCenters;
|
||||||
auto &Station = LevelUniqueFuelcenterState.Station;
|
|
||||||
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
auto &Walls = LevelUniqueWallSubsystemState.Walls;
|
||||||
auto &vmwallptr = Walls.vmptr;
|
auto &vmwallptr = Walls.vmptr;
|
||||||
for (hole=0; hole < seg; hole++)
|
for (hole=0; hole < seg; hole++)
|
||||||
|
@ -495,7 +494,7 @@ static void compress_segments(void)
|
||||||
w->segnum = hole;
|
w->segnum = hole;
|
||||||
|
|
||||||
// Fix fuelcenters, robotcens, and triggers... added 2/1/95 -Yuan
|
// Fix fuelcenters, robotcens, and triggers... added 2/1/95 -Yuan
|
||||||
range_for (auto &f, partial_range(Station, Num_fuelcenters))
|
range_for (auto &f, partial_range(LevelUniqueFuelcenterState.Station, LevelUniqueFuelcenterState.Num_fuelcenters))
|
||||||
if (f.segnum == seg)
|
if (f.segnum == seg)
|
||||||
f.segnum = hole;
|
f.segnum = hole;
|
||||||
|
|
||||||
|
|
|
@ -431,6 +431,7 @@ static void write_fuelcen_text(PHYSFS_File *my_file)
|
||||||
PHYSFSX_printf(my_file, "-----------------------------------------------------------------------------\n");
|
PHYSFSX_printf(my_file, "-----------------------------------------------------------------------------\n");
|
||||||
PHYSFSX_printf(my_file, "Fuel Center stuff: (Note: This means fuel, repair, materialize, control centers!)\n");
|
PHYSFSX_printf(my_file, "Fuel Center stuff: (Note: This means fuel, repair, materialize, control centers!)\n");
|
||||||
|
|
||||||
|
const auto Num_fuelcenters = LevelUniqueFuelcenterState.Num_fuelcenters;
|
||||||
for (i=0; i<Num_fuelcenters; i++) {
|
for (i=0; i<Num_fuelcenters; i++) {
|
||||||
PHYSFSX_printf(my_file, "Fuelcenter %i: Type=%i (%s), segment = %3i\n", i, Station[i].Type, Special_names[Station[i].Type], Station[i].segnum);
|
PHYSFSX_printf(my_file, "Fuelcenter %i: Type=%i (%s), segment = %3i\n", i, Station[i].Type, Special_names[Station[i].Type], Station[i].segnum);
|
||||||
if (Segments[Station[i].segnum].special != Station[i].Type)
|
if (Segments[Station[i].segnum].special != Station[i].Type)
|
||||||
|
|
|
@ -70,7 +70,6 @@ constexpr fix Fuelcen_max_amount = i2f(100);
|
||||||
constexpr fix EnergyToCreateOneRobot = i2f(1);
|
constexpr fix EnergyToCreateOneRobot = i2f(1);
|
||||||
|
|
||||||
unsigned Num_robot_centers;
|
unsigned Num_robot_centers;
|
||||||
unsigned Num_fuelcenters;
|
|
||||||
|
|
||||||
static int Num_extry_robots = 15;
|
static int Num_extry_robots = 15;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +96,7 @@ void fuelcen_reset()
|
||||||
auto &Station = LevelUniqueFuelcenterState.Station;
|
auto &Station = LevelUniqueFuelcenterState.Station;
|
||||||
DXX_MAKE_MEM_UNDEFINED(Station.begin(), Station.end());
|
DXX_MAKE_MEM_UNDEFINED(Station.begin(), Station.end());
|
||||||
DXX_MAKE_MEM_UNDEFINED(RobotCenters.begin(), RobotCenters.end());
|
DXX_MAKE_MEM_UNDEFINED(RobotCenters.begin(), RobotCenters.end());
|
||||||
Num_fuelcenters = 0;
|
LevelUniqueFuelcenterState.Num_fuelcenters = 0;
|
||||||
range_for (auto &i, Segments)
|
range_for (auto &i, Segments)
|
||||||
i.special = SEGMENT_IS_NOTHING;
|
i.special = SEGMENT_IS_NOTHING;
|
||||||
|
|
||||||
|
@ -144,8 +143,9 @@ void fuelcen_create(const vmsegptridx_t segp)
|
||||||
Error( "Invalid station type %d in fuelcen.c\n", station_type );
|
Error( "Invalid station type %d in fuelcen.c\n", station_type );
|
||||||
}
|
}
|
||||||
|
|
||||||
segp->station_idx = Num_fuelcenters;
|
const auto next_fuelcenter_idx = LevelUniqueFuelcenterState.Num_fuelcenters++;
|
||||||
auto &station = Station.at(Num_fuelcenters++);
|
segp->station_idx = next_fuelcenter_idx;
|
||||||
|
auto &station = Station.at(next_fuelcenter_idx);
|
||||||
station.Type = station_type;
|
station.Type = station_type;
|
||||||
station.Capacity = Fuelcen_max_amount;
|
station.Capacity = Fuelcen_max_amount;
|
||||||
station.segnum = segp;
|
station.segnum = segp;
|
||||||
|
@ -164,7 +164,7 @@ static void matcen_create(const vmsegptridx_t segp)
|
||||||
|
|
||||||
Assert(station_type == SEGMENT_IS_ROBOTMAKER);
|
Assert(station_type == SEGMENT_IS_ROBOTMAKER);
|
||||||
|
|
||||||
const auto next_fuelcenter_idx = Num_fuelcenters++;
|
const auto next_fuelcenter_idx = LevelUniqueFuelcenterState.Num_fuelcenters++;
|
||||||
segp->station_idx = next_fuelcenter_idx;
|
segp->station_idx = next_fuelcenter_idx;
|
||||||
auto &station = Station.at(next_fuelcenter_idx);
|
auto &station = Station.at(next_fuelcenter_idx);
|
||||||
|
|
||||||
|
@ -177,6 +177,7 @@ static void matcen_create(const vmsegptridx_t segp)
|
||||||
const auto next_robot_center_idx = Num_robot_centers++;
|
const auto next_robot_center_idx = Num_robot_centers++;
|
||||||
segp->matcen_num = next_robot_center_idx;
|
segp->matcen_num = next_robot_center_idx;
|
||||||
auto &robotcenter = RobotCenters[next_robot_center_idx];
|
auto &robotcenter = RobotCenters[next_robot_center_idx];
|
||||||
|
robotcenter.fuelcen_num = next_fuelcenter_idx;
|
||||||
robotcenter.segnum = segp;
|
robotcenter.segnum = segp;
|
||||||
robotcenter.fuelcen_num = next_fuelcenter_idx;
|
robotcenter.fuelcen_num = next_fuelcenter_idx;
|
||||||
}
|
}
|
||||||
|
@ -206,7 +207,7 @@ void trigger_matcen(const vmsegptridx_t segnum)
|
||||||
FuelCenter *robotcen;
|
FuelCenter *robotcen;
|
||||||
|
|
||||||
Assert(segp->special == SEGMENT_IS_ROBOTMAKER);
|
Assert(segp->special == SEGMENT_IS_ROBOTMAKER);
|
||||||
Assert(segp->matcen_num < Num_fuelcenters);
|
assert(segp->matcen_num < LevelUniqueFuelcenterState.Num_fuelcenters);
|
||||||
Assert((segp->matcen_num >= 0) && (segp->matcen_num <= Highest_segment_index));
|
Assert((segp->matcen_num >= 0) && (segp->matcen_num <= Highest_segment_index));
|
||||||
|
|
||||||
robotcen = &Station[RobotCenters[segp->matcen_num].fuelcen_num];
|
robotcen = &Station[RobotCenters[segp->matcen_num].fuelcen_num];
|
||||||
|
@ -251,6 +252,7 @@ void fuelcen_delete(const vmsegptr_t segp)
|
||||||
{
|
{
|
||||||
auto &RobotCenters = LevelSharedRobotcenterState.RobotCenters;
|
auto &RobotCenters = LevelSharedRobotcenterState.RobotCenters;
|
||||||
auto &Station = LevelUniqueFuelcenterState.Station;
|
auto &Station = LevelUniqueFuelcenterState.Station;
|
||||||
|
auto Num_fuelcenters = LevelUniqueFuelcenterState.Num_fuelcenters;
|
||||||
Restart: ;
|
Restart: ;
|
||||||
segp->special = 0;
|
segp->special = 0;
|
||||||
|
|
||||||
|
@ -289,7 +291,7 @@ Restart: ;
|
||||||
goto Restart;
|
goto Restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LevelUniqueFuelcenterState.Num_fuelcenters = Num_fuelcenters;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -541,7 +543,7 @@ static void robotmaker_proc(const d_vclip_array &Vclip, fvmsegptridx &vmsegptrid
|
||||||
void fuelcen_update_all()
|
void fuelcen_update_all()
|
||||||
{
|
{
|
||||||
auto &Station = LevelUniqueFuelcenterState.Station;
|
auto &Station = LevelUniqueFuelcenterState.Station;
|
||||||
range_for (auto &&e, enumerate(partial_range(Station, Num_fuelcenters)))
|
range_for (auto &&e, enumerate(partial_range(Station, LevelUniqueFuelcenterState.Num_fuelcenters)))
|
||||||
{
|
{
|
||||||
auto &i = e.value;
|
auto &i = e.value;
|
||||||
if (i.Type == SEGMENT_IS_ROBOTMAKER)
|
if (i.Type == SEGMENT_IS_ROBOTMAKER)
|
||||||
|
@ -629,7 +631,7 @@ fix repaircen_give_shields(const shared_segment &segp, const fix MaxAmountCanTak
|
||||||
void disable_matcens(void)
|
void disable_matcens(void)
|
||||||
{
|
{
|
||||||
auto &Station = LevelUniqueFuelcenterState.Station;
|
auto &Station = LevelUniqueFuelcenterState.Station;
|
||||||
range_for (auto &s, partial_range(Station, Num_fuelcenters))
|
range_for (auto &s, partial_range(Station, LevelUniqueFuelcenterState.Num_fuelcenters))
|
||||||
if (s.Type == SEGMENT_IS_ROBOTMAKER)
|
if (s.Type == SEGMENT_IS_ROBOTMAKER)
|
||||||
{
|
{
|
||||||
s.Enabled = 0;
|
s.Enabled = 0;
|
||||||
|
@ -644,6 +646,7 @@ void init_all_matcens(void)
|
||||||
{
|
{
|
||||||
auto &RobotCenters = LevelSharedRobotcenterState.RobotCenters;
|
auto &RobotCenters = LevelSharedRobotcenterState.RobotCenters;
|
||||||
auto &Station = LevelUniqueFuelcenterState.Station;
|
auto &Station = LevelUniqueFuelcenterState.Station;
|
||||||
|
const auto Num_fuelcenters = LevelUniqueFuelcenterState.Num_fuelcenters;
|
||||||
const auto &&robot_range = partial_const_range(RobotCenters, Num_robot_centers);
|
const auto &&robot_range = partial_const_range(RobotCenters, Num_robot_centers);
|
||||||
for (uint_fast32_t i = 0; i < Num_fuelcenters; i++)
|
for (uint_fast32_t i = 0; i < Num_fuelcenters; i++)
|
||||||
if (Station[i].Type == SEGMENT_IS_ROBOTMAKER) {
|
if (Station[i].Type == SEGMENT_IS_ROBOTMAKER) {
|
||||||
|
|
|
@ -988,7 +988,7 @@ void multi_do_create_robot(const d_vclip_array &Vclip, const playernum_t pnum, c
|
||||||
objnum_t objnum;
|
objnum_t objnum;
|
||||||
objnum = GET_INTEL_SHORT(buf + 3);
|
objnum = GET_INTEL_SHORT(buf + 3);
|
||||||
|
|
||||||
if (fuelcen_num >= Num_fuelcenters || pnum >= N_players)
|
if (fuelcen_num >= LevelUniqueFuelcenterState.Num_fuelcenters || pnum >= N_players)
|
||||||
{
|
{
|
||||||
Int3(); // Bogus data
|
Int3(); // Bogus data
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1179,6 +1179,7 @@ int state_save_all_sub(const char *filename, const char *desc)
|
||||||
matcen_info_write(fp, r, 0x7f);
|
matcen_info_write(fp, r, 0x7f);
|
||||||
#endif
|
#endif
|
||||||
control_center_triggers_write(&ControlCenterTriggers, fp);
|
control_center_triggers_write(&ControlCenterTriggers, fp);
|
||||||
|
const auto Num_fuelcenters = LevelUniqueFuelcenterState.Num_fuelcenters;
|
||||||
PHYSFS_write(fp, &Num_fuelcenters, sizeof(int), 1);
|
PHYSFS_write(fp, &Num_fuelcenters, sizeof(int), 1);
|
||||||
range_for (auto &s, partial_range(Station, Num_fuelcenters))
|
range_for (auto &s, partial_range(Station, Num_fuelcenters))
|
||||||
{
|
{
|
||||||
|
@ -1781,7 +1782,8 @@ int state_restore_all_sub(const d_level_shared_destructible_light_state &LevelSh
|
||||||
matcen_info_read(fp, r);
|
matcen_info_read(fp, r);
|
||||||
#endif
|
#endif
|
||||||
control_center_triggers_read(&ControlCenterTriggers, fp);
|
control_center_triggers_read(&ControlCenterTriggers, fp);
|
||||||
Num_fuelcenters = PHYSFSX_readSXE32(fp, swap);
|
const unsigned Num_fuelcenters = PHYSFSX_readSXE32(fp, swap);
|
||||||
|
LevelUniqueFuelcenterState.Num_fuelcenters = Num_fuelcenters;
|
||||||
range_for (auto &s, partial_range(Station, Num_fuelcenters))
|
range_for (auto &s, partial_range(Station, Num_fuelcenters))
|
||||||
{
|
{
|
||||||
fuelcen_read(fp, s);
|
fuelcen_read(fp, s);
|
||||||
|
|
Loading…
Reference in a new issue