aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2019-08-26 05:58:02 +0100
committerD G Turner2019-08-26 05:58:02 +0100
commit5f901676ff0e9007f74a80327e787ae424cfd063 (patch)
tree9381bf5dff487c96b067dbdf168bf4b1d333d237
parent5035c81857839ba86127f18ae66bfed3ee71a85f (diff)
downloadscummvm-rg350-5f901676ff0e9007f74a80327e787ae424cfd063.tar.gz
scummvm-rg350-5f901676ff0e9007f74a80327e787ae424cfd063.tar.bz2
scummvm-rg350-5f901676ff0e9007f74a80327e787ae424cfd063.zip
HOPKINS: Fix GCC Compiler Warnings
These were from using memset to clear non-trivial structures.
-rw-r--r--engines/hopkins/globals.cpp2
-rw-r--r--engines/hopkins/globals.h27
-rw-r--r--engines/hopkins/hopkins.cpp6
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;