diff options
author | D G Turner | 2019-08-25 05:55:54 +0100 |
---|---|---|
committer | D G Turner | 2019-08-25 05:55:54 +0100 |
commit | 482f835ad6c1260fb2fc2609ecca70f3ac618fc5 (patch) | |
tree | 87f96e0681908ba8261b6f30a5470d3b7b0186df | |
parent | 4b6578603d1195f04be230870ab003ed0698d936 (diff) | |
download | scummvm-rg350-482f835ad6c1260fb2fc2609ecca70f3ac618fc5.tar.gz scummvm-rg350-482f835ad6c1260fb2fc2609ecca70f3ac618fc5.tar.bz2 scummvm-rg350-482f835ad6c1260fb2fc2609ecca70f3ac618fc5.zip |
AGI: Fix GCC Compiler Warnings from memset of Game State Structures
This fixes these, but adding constructors causes further memset usage
warnings on the structures which are now "non-trivial" due to the addition
of constructors. Should be able to fix by repeating this process to remove
further memset usage.
-rw-r--r-- | engines/agi/agi.cpp | 1 | ||||
-rw-r--r-- | engines/agi/agi.h | 99 | ||||
-rw-r--r-- | engines/agi/logic.h | 2 | ||||
-rw-r--r-- | engines/agi/picture.h | 2 | ||||
-rw-r--r-- | engines/agi/preagi.cpp | 1 | ||||
-rw-r--r-- | engines/agi/view.h | 8 |
6 files changed, 111 insertions, 2 deletions
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp index 93e1187523..227700561b 100644 --- a/engines/agi/agi.cpp +++ b/engines/agi/agi.cpp @@ -360,7 +360,6 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas DebugMan.addDebugChannel(kDebugLevelText, "Text", "Text output debugging"); DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging"); - memset(&_game, 0, sizeof(struct AgiGame)); memset(&_debug, 0, sizeof(struct AgiDebug)); _game.mouseEnabled = true; diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 71ba8e9298..8627d2d8b1 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -353,6 +353,8 @@ enum { struct AgiControllerKeyMapping { uint16 keycode; byte controllerSlot; + + AgiControllerKeyMapping() : keycode(0), controllerSlot(0) {} }; struct AgiObject { @@ -372,12 +374,16 @@ struct AgiDir { // 3 = in mem, cant be released // 0x40 = was compressed uint8 flags; + + AgiDir() : volume(0), offset(0), len(0), clen(0), flags(0) {} }; struct AgiBlock { bool active; int16 x1, y1; int16 x2, y2; + + AgiBlock() : active(false), x1(0), y1(0), x2(0), y2(0) {} }; struct ScriptPos { @@ -493,6 +499,99 @@ struct AgiGame { int16 nonBlockingTextCyclesLeft; bool automaticRestoreGame; + + AgiGame() { + _vm = nullptr; + + adjMouseX = 0; + adjMouseY = 0; + + for (uint16 i = 0; i < ARRAYSIZE(name); i++) { + name[i] = 0; + } + for (uint16 i = 0; i < ARRAYSIZE(id); i++) { + id[i] = 0; + } + crc = 0; + + for (uint16 i = 0; i < ARRAYSIZE(flags); i++) { + flags[i] = 0; + } + for (uint16 i = 0; i < ARRAYSIZE(vars); i++) { + vars[i] = 0; + } + + horizon = 0; + + cycleInnerLoopActive = false; + cycleInnerLoopType = 0; + + curLogicNr = 0; + + // execStack is defaulted by Common::Array constructor + + playerControl = false; + exitAllLogics = false; + pictureShown = false; + gameFlags = 0; + + // block defaulted by AgiBlock constructor + + gfxMode = false; + + numObjects = 0; + + for (uint16 i = 0; i < ARRAYSIZE(controllerOccured); i++) { + controllerOccured[i] = false; + } + + // controllerKeyMapping defaulted by AgiControllerKeyMapping constructor + + for (uint16 i = 0; i < MAX_STRINGS + 1; i++) { + for (uint16 j = 0; j < MAX_STRINGLEN; j++) { + strings[i][j] = 0; + } + } + + // dirLogic cleared by AgiDir constructor + // dirPic cleared by AgiDir constructor + // dirView cleared by AgiDir constructor + // dirSound cleared by AgiDir constructor + + // pictures cleared by AgiPicture constructor + // logics cleared by AgiLogic constructor + // views cleared by AgiView constructor + for (uint16 i = 0; i < ARRAYSIZE(sounds); i++) { + sounds[i] = nullptr; + } + + _curLogic = nullptr; + + // screenObjTable cleared by ScreenObjEntry constructor + + // addToPicView cleared by ScreenObjEntry constructor + + automaticSave = false; + for (uint16 i = 0; i < ARRAYSIZE(automaticSaveDescription); i++) { + automaticSaveDescription[i] = 0; + } + + // mouseFence cleared by Common::Rect constructor + mouseEnabled = false; + mouseHidden = false; + + testResult = 0; + + max_logics = 0; + for (uint16 i = 0; i < ARRAYSIZE(logic_list); i++) { + logic_list[i] = 0; + } + + nonBlockingTextShown = false; + nonBlockingTextCyclesLeft = 0; + + automaticRestoreGame = false; + } }; class AgiLoader { diff --git a/engines/agi/logic.h b/engines/agi/logic.h index b46362056f..5e8700d9a8 100644 --- a/engines/agi/logic.h +++ b/engines/agi/logic.h @@ -35,6 +35,8 @@ struct AgiLogic { int cIP; /**< current IP */ int numTexts; /**< number of messages */ const char **texts; /**< message list */ + + AgiLogic() : data(nullptr), size(0), sIP(0), cIP(0), numTexts(0), texts(nullptr) {} }; } // End of namespace Agi diff --git a/engines/agi/picture.h b/engines/agi/picture.h index 2cb5bfabc8..1380aae3fc 100644 --- a/engines/agi/picture.h +++ b/engines/agi/picture.h @@ -34,6 +34,8 @@ namespace Agi { struct AgiPicture { uint32 flen; /**< size of raw data */ uint8 *rdata; /**< raw vector image data */ + + AgiPicture() : flen(0), rdata(nullptr) {} }; // AGI picture version diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index 6262ee931f..e2751cd87b 100644 --- a/engines/agi/preagi.cpp +++ b/engines/agi/preagi.cpp @@ -48,7 +48,6 @@ PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : DebugMan.addDebugChannel(kDebugLevelText, "Text", "Text output debugging"); DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging"); - memset(&_game, 0, sizeof(struct AgiGame)); memset(&_debug, 0, sizeof(struct AgiDebug)); _speakerHandle = new Audio::SoundHandle(); diff --git a/engines/agi/view.h b/engines/agi/view.h index 1c57d5d468..e4adfdc014 100644 --- a/engines/agi/view.h +++ b/engines/agi/view.h @@ -47,6 +47,14 @@ struct AgiView { byte *description; int16 loopCount; AgiViewLoop *loop; + + AgiView() { + headerStepSize = 0; + headerCycleTime = 0; + description = nullptr; + loopCount = 0; + loop = nullptr; + } }; enum MotionType { |