AGS: Move troom to Globals

This commit is contained in:
Paul Gilbert 2021-02-27 15:50:41 -08:00
parent 0c21e1fac2
commit 80bfa0510d
9 changed files with 28 additions and 30 deletions

View File

@ -151,7 +151,6 @@ extern IGraphicsDriver *gfxDriver;
//=============================================================================
GameSetup usetup;
RoomStatus troom; // used for non-saveable rooms, eg. intro
RoomObject *objs;
RoomStatus *croom = nullptr;
RoomStruct thisroom;
@ -1338,13 +1337,13 @@ void restore_game_displayed_room_status(Stream *in, RestoredData &r_data) {
raw_saved_screen = read_serialized_bitmap(in);
// get the current troom, in case they save in room 600 or whatever
ReadRoomStatus_Aligned(&troom, in);
ReadRoomStatus_Aligned(&_GP(troom), in);
if (troom.tsdatasize > 0) {
troom.tsdata = (char *)malloc(troom.tsdatasize + 5);
in->Read(&troom.tsdata[0], troom.tsdatasize);
if (_GP(troom).tsdatasize > 0) {
_GP(troom).tsdata = (char *)malloc(_GP(troom).tsdatasize + 5);
in->Read(&_GP(troom).tsdata[0], _GP(troom).tsdatasize);
} else
troom.tsdata = nullptr;
_GP(troom).tsdata = nullptr;
}
}

View File

@ -90,7 +90,6 @@ extern GameSetup usetup;
extern RoomStatus *croom;
extern RoomStatus troom; // used for non-saveable rooms, eg. intro
extern int displayed_room;
extern RoomObject *objs;
extern ccInstance *roominst;
@ -551,15 +550,15 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
// setup objects
if (forchar != nullptr) {
// if not restoring a game, always reset this room
troom.beenhere = 0;
troom.FreeScriptData();
troom.FreeProperties();
memset(&troom.hotspot_enabled[0], 1, MAX_ROOM_HOTSPOTS);
memset(&troom.region_enabled[0], 1, MAX_ROOM_REGIONS);
_GP(troom).beenhere = 0;
_GP(troom).FreeScriptData();
_GP(troom).FreeProperties();
memset(&_GP(troom).hotspot_enabled[0], 1, MAX_ROOM_HOTSPOTS);
memset(&_GP(troom).region_enabled[0], 1, MAX_ROOM_REGIONS);
}
if ((newnum >= 0) & (newnum < MAX_ROOMS))
croom = getRoomStatus(newnum);
else croom = &troom;
else croom = &_GP(troom);
if (croom->beenhere > 0) {
// if we've been here before, save the Times Run information

View File

@ -35,12 +35,7 @@ using namespace AGS::Shared;
using namespace AGS::Engine;
RoomStatus::RoomStatus() {
beenhere = 0;
numobj = 0;
memset(&flagstates, 0, sizeof(flagstates));
tsdatasize = 0;
tsdata = nullptr;
memset(&hotspot_enabled, 0, sizeof(hotspot_enabled));
memset(&region_enabled, 0, sizeof(region_enabled));
memset(&walkbehind_base, 0, sizeof(walkbehind_base));

View File

@ -43,12 +43,12 @@ using AGS::Shared::Interaction;
// This struct is saved in the save games - it contains everything about
// a room that could change
struct RoomStatus {
int beenhere;
int numobj;
int beenhere = 0;
int numobj = 0;
RoomObject obj[MAX_ROOM_OBJECTS];
short flagstates[MAX_FLAGS];
int tsdatasize;
char *tsdata;
int tsdatasize = 0;
char *tsdata = nullptr;
Interaction intrHotspot[MAX_ROOM_HOTSPOTS];
Interaction intrObject[MAX_ROOM_OBJECTS];
Interaction intrRegion[MAX_ROOM_REGIONS];
@ -61,7 +61,7 @@ struct RoomStatus {
#ifdef UNUSED_CODE
EventBlock hscond[MAX_ROOM_HOTSPOTS];
EventBlock objcond[MAX_ROOM_OBJECTS];
EventBlock misccond;
EventBlock misccond = 0;
#endif
char hotspot_enabled[MAX_ROOM_HOTSPOTS];
char region_enabled[MAX_ROOM_REGIONS];

View File

@ -78,7 +78,7 @@ extern AGS::Engine::IDriverDependantBitmap **guibgbmp;
extern AGS::Engine::IGraphicsDriver *gfxDriver;
extern Bitmap *dynamicallyCreatedSurfaces[MAX_DYNAMIC_SURFACES];
extern Bitmap *raw_saved_screen;
extern RoomStatus troom;
extern RoomStatus *croom;
@ -381,8 +381,8 @@ void DoBeforeRestore(PreservedParams &pp) {
dialogScriptsInst = nullptr;
resetRoomStatuses();
troom.FreeScriptData();
troom.FreeProperties();
_GP(troom).FreeScriptData();
_GP(troom).FreeProperties();
free_do_once_tokens();
// unregister gui controls from API exports

View File

@ -71,7 +71,7 @@ extern int numAnimButs;
extern ViewStruct *views;
extern Bitmap *dynamicallyCreatedSurfaces[MAX_DYNAMIC_SURFACES];
extern RoomStruct thisroom;
extern RoomStatus troom;
extern Bitmap *raw_saved_screen;
extern MoveList *mls;
@ -930,7 +930,7 @@ HSaveError WriteThisRoom(PStream out) {
out->WriteBool(persist);
// write the current troom state, in case they save in temporary room
if (!persist)
troom.WriteToSavegame(out.get());
_GP(troom).WriteToSavegame(out.get());
return HSaveError::None();
}
@ -976,7 +976,7 @@ HSaveError ReadThisRoom(PStream in, int32_t cmp_ver, const PreservedParams &pp,
// read the current troom state, in case they saved in temporary room
if (!in->ReadBool())
troom.ReadFromSavegame(in.get());
_GP(troom).ReadFromSavegame(in.get());
return HSaveError::None();
}

View File

@ -57,7 +57,7 @@ using namespace AGS::Engine;
extern RoomStruct thisroom;
extern RoomStatus troom; // used for non-saveable rooms, eg. intro
// used for non-saveable rooms, eg. intro
extern int our_eip;
extern GameSetup usetup;
extern char pexbuf[STD_BUFFER_SIZE];

View File

@ -24,6 +24,7 @@
#include "ags/shared/ac/gamesetupstruct.h"
#include "ags/shared/ac/spritecache.h"
#include "ags/engine/ac/gamestate.h"
#include "ags/engine/ac/roomstatus.h"
namespace AGS3 {
@ -37,6 +38,7 @@ Globals::Globals() {
_play = new GameState();
_game = new GameSetupStruct();
_spriteset = new SpriteCache(_game->SpriteInfos);
_troom = new RoomStatus();
}
Globals::~Globals() {
@ -44,6 +46,7 @@ Globals::~Globals() {
delete _game;
delete _play;
delete _spriteset;
delete _troom;
}
} // namespace AGS3

View File

@ -43,6 +43,7 @@ class Bitmap;
struct IAGSEditorDebugger;
struct GameSetupStruct;
struct GameState;
struct RoomStatus;
class SpriteCache;
class Globals {
@ -80,6 +81,7 @@ public:
GameSetupStruct *_game = nullptr;
GameState *_play = nullptr;
SpriteCache *_spriteset = nullptr;
RoomStatus *_troom = nullptr; // used for non-saveable rooms, eg. intro
/**@}*/