diff options
-rw-r--r-- | engines/hopkins/globals.cpp | 2 | ||||
-rw-r--r-- | engines/hopkins/globals.h | 27 | ||||
-rw-r--r-- | engines/hopkins/hopkins.cpp | 6 |
3 files changed, 31 insertions, 4 deletions
diff --git a/engines/hopkins/globals.cpp b/engines/hopkins/globals.cpp index 1f192748cd..d6f2c49a35 100644 --- a/engines/hopkins/globals.cpp +++ b/engines/hopkins/globals.cpp @@ -181,7 +181,7 @@ void Globals::clearAll() { _vm->_objectsMan->clearAll(); _saveData = (Savegame *)malloc(sizeof(Savegame)); - memset(_saveData, 0, sizeof(Savegame)); + _saveData->reset(); _vm->_events->clearAll(); } diff --git a/engines/hopkins/globals.h b/engines/hopkins/globals.h index 2e17389a45..ae69524b5d 100644 --- a/engines/hopkins/globals.h +++ b/engines/hopkins/globals.h @@ -25,6 +25,7 @@ #include "common/scummsys.h" #include "common/str.h" +#include "common/util.h" #include "common/events.h" namespace Hopkins { @@ -39,6 +40,16 @@ struct CharacterLocation { int _startSpriteIndex; int _location; int _zoomFactor; + + void reset() { + _pos.x = 0; + _pos.y = 0; + _startSpriteIndex = 0; + _location = 0; + _zoomFactor = 0; + } + + CharacterLocation() { reset(); } }; enum SauvegardeOffset { @@ -115,6 +126,22 @@ struct Savegame { int16 _inventory[35]; // Originally at offset 1300 of data array int16 _mapCarPosX; int16 _mapCarPosY; + + void reset() { + for (uint16 i = 0; i < ARRAYSIZE(_data); i++) { + _data[i] = 0; + } + _cloneHopkins.reset(); + _realHopkins.reset(); + _samantha.reset(); + for (uint16 i = 0; i < ARRAYSIZE(_inventory); i++) { + _inventory[i] = 0; + } + _mapCarPosX = 0; + _mapCarPosY = 0; + } + + Savegame() { reset(); } }; struct CreditItem { diff --git a/engines/hopkins/hopkins.cpp b/engines/hopkins/hopkins.cpp index 8f301fdc0f..545af51ebc 100644 --- a/engines/hopkins/hopkins.cpp +++ b/engines/hopkins/hopkins.cpp @@ -167,7 +167,7 @@ bool HopkinsEngine::runWin95Demo() { _globals->_characterType = CHARACTER_HOPKINS; _objectsMan->_mapCarPosX = _objectsMan->_mapCarPosY = 0; - memset(_globals->_saveData, 0, sizeof(Savegame)); + _globals->_saveData->reset(); _globals->_exitId = 0; if (getLanguage() != Common::PL_POL) @@ -471,7 +471,7 @@ bool HopkinsEngine::runLinuxDemo() { _globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR"); _globals->_characterType = CHARACTER_HOPKINS; _objectsMan->_mapCarPosX = _objectsMan->_mapCarPosY = 0; - memset(_globals->_saveData, 0, sizeof(Savegame)); + _globals->_saveData->reset(); _globals->_exitId = 0; if (_startGameSlot != -1) @@ -838,7 +838,7 @@ bool HopkinsEngine::runFull() { _globals->_characterSpriteBuf = _fileIO->loadFile("PERSO.SPR"); _globals->_characterType = CHARACTER_HOPKINS; _objectsMan->_mapCarPosX = _objectsMan->_mapCarPosY = 0; - memset(_globals->_saveData, 0, sizeof(Savegame)); + _globals->_saveData->reset(); _globals->_exitId = 0; |