TINSEL: Reset more global vars upon engine destruction

This commit is contained in:
Filippos Karapetis 2020-10-03 20:31:26 +03:00
parent 9c9fc0cf2b
commit ae91b7e056
4 changed files with 25 additions and 8 deletions

View File

@ -74,7 +74,7 @@ HPOLYGON InitExtraBlock(PMOVER ca, PMOVER ta);
//----------------- LOCAL GLOBAL DATA --------------------
// FIXME: Avoid non-const global vars
// These vars are reset upon engine destruction
#if SLOW_RINCE_DOWN
static int g_Interlude = 0; // For slowing down walking, for testing
@ -107,6 +107,12 @@ void AddInterlude(int n) {
}
#endif
void ResetVarsMove() {
g_DefaultRefer = 0;
g_lastLeadXdest = g_lastLeadYdest = 0;
g_hSlowVar = 0;
}
/**
* Given (x, y) of a click within a path polygon, checks that the
* co-ordinates are not within a blocking polygon. If it is not, the

View File

@ -35,13 +35,13 @@
namespace Tinsel {
// FIXME: Avoid non-const global vars
// These vars are reset upon engine destruction
// list of all objects
static OBJECT *objectList = 0;
static OBJECT *objectList = nullptr;
// pointer to free object list
static OBJECT *pFreeObjects = 0;
static OBJECT *pFreeObjects = nullptr;
#ifdef DEBUG
// diagnostic object counters

View File

@ -287,7 +287,7 @@ void Poly::nextPoly() {
//----------------- LOCAL GLOBAL DATA --------------------
// FIXME: Avoid non-const global vars
// These vars are reset upon engine destruction
static int MaxPolys = MAX_POLY;
@ -320,6 +320,16 @@ static POLY_VOLATILE volatileStuff[MAX_POLY];
//-------------------- METHODS ----------------------
void ResetVarsPolygons() {
DropPolygons();
MaxPolys = MAX_POLY;
pHandle = 0;
memset(&extraBlock, 0, sizeof(extraBlock));
memset(volatileStuff, 0, sizeof(volatileStuff));
}
static HPOLYGON PolygonIndex(const POLYGON *pp) {
for (int i = 0; i <= MAX_POLY; ++i) {
if (Polys[i] == pp)

View File

@ -76,10 +76,12 @@ extern SCNHANDLE GetSceneHandle();
extern void ResetVarsDrives();
extern void ResetVarsEvents();
extern void RebootScalingReels();
extern void ResetVarsMove();
extern void ResetVarsPalette();
extern void ResetVarsPCode();
extern void ResetVarsPDisplay();
extern void ResetVarsPlay();
extern void ResetVarsPolygons();
extern void RebootMovers();
extern void ResetVarsSaveLoad();
extern void ResetVarsSaveScn();
@ -915,13 +917,12 @@ TinselEngine::~TinselEngine() {
ResetVarsEvents(); // events.cpp
// TODO: heapmem.cpp
RebootScalingReels(); // mareels.cpp
// TODO: move.cpp
// TODO: object.cpp
ResetVarsMove();
ResetVarsPalette(); // palette.cpp
ResetVarsPCode();
ResetVarsPDisplay(); // pdisplay.cpp
ResetVarsPlay(); // play.cpp
// TODO: polygons.cpp
ResetVarsPolygons(); // polygons.cpp
RebootMovers(); // rince.cpp
ResetVarsSaveLoad();
ResetVarsSaveScn(); // savescn.cpp