Use array<> for ActiveDoors

This commit is contained in:
Kp 2014-04-27 23:12:34 +00:00
parent 2e95d8c0a8
commit 5af9e8d5b2
4 changed files with 8 additions and 14 deletions

View file

@ -231,8 +231,8 @@ static inline ssize_t operator-(wall *w, array<wall, MAX_WALLS> &W)
return w - static_cast<wall *>(&*W.begin());
}
extern active_door ActiveDoors[MAX_DOORS]; // Master doors array
extern int Num_open_doors; // Number of open doors
extern array<active_door, MAX_DOORS> ActiveDoors; // Master doors array
extern unsigned Num_open_doors; // Number of open doors
extern unsigned Num_wall_anims;
extern array<wclip, MAX_WALL_ANIMS> WallAnims;

View file

@ -1630,14 +1630,6 @@ static int save_game_data(PHYSFS_file *SaveFile)
range_for (auto &w, partial_range(Walls, Num_walls))
wall_write(&w, game_top_fileinfo_version, SaveFile);
//==================== SAVE DOOR INFO =============================
#if 0
doors_offset = PHYSFS_tell(SaveFile);
for (i = 0; i < Num_open_doors; i++)
door_write(&ActiveDoors[i], game_top_fileinfo_version, SaveFile);
#endif
//==================== SAVE TRIGGER INFO =============================
triggers_offset = PHYSFS_tell(SaveFile);

View file

@ -1177,7 +1177,8 @@ int state_save_all_sub(const char *filename, const char *desc)
//Save door info
i = Num_open_doors;
PHYSFS_write(fp, &i, sizeof(int), 1);
PHYSFS_write(fp, ActiveDoors, sizeof(active_door), i);
range_for (auto &ad, partial_range(ActiveDoors, Num_open_doors))
PHYSFS_write(fp, &ad, sizeof(ad), 1);
#if defined(DXX_BUILD_DESCENT_II)
//Save cloaking wall info
@ -1657,7 +1658,8 @@ int state_restore_all_sub(const char *filename, int secret_restore)
//Restore door info
Num_open_doors = PHYSFSX_readSXE32(fp, swap);
active_door_read_n_swap(ActiveDoors, Num_open_doors, swap, fp);
range_for (auto &ad, partial_range(ActiveDoors, Num_open_doors))
active_door_read_n_swap(&ad, 1, swap, fp);
#if defined(DXX_BUILD_DESCENT_II)
if (version >= 14) { //Restore cloaking wall info

View file

@ -45,8 +45,8 @@ unsigned Num_walls; // Number of walls
unsigned Num_wall_anims;
array<wclip, MAX_WALL_ANIMS> WallAnims; // Wall animations
active_door ActiveDoors[MAX_DOORS];
int Num_open_doors; // Number of open doors
array<active_door, MAX_DOORS> ActiveDoors;
unsigned Num_open_doors; // Number of open doors
#if defined(DXX_BUILD_DESCENT_II)
#include "collide.h"