[Scummvm-git-logs] scummvm master -> 482f835ad6c1260fb2fc2609ecca70f3ac618fc5

digitall dgturner at iee.org
Sun Aug 25 06:59:13 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
482f835ad6 AGI: Fix GCC Compiler Warnings from memset of Game State Structures


Commit: 482f835ad6c1260fb2fc2609ecca70f3ac618fc5
    https://github.com/scummvm/scummvm/commit/482f835ad6c1260fb2fc2609ecca70f3ac618fc5
Author: D G Turner (digitall at scummvm.org)
Date: 2019-08-25T05:55:54+01:00

Commit Message:
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.

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/logic.h
    engines/agi/picture.h
    engines/agi/preagi.cpp
    engines/agi/view.h


diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 93e1187..2277005 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 71ba8e9..8627d2d 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 b463620..5e8700d 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 2cb5bfa..1380aae 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 6262ee9..e2751cd 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 1c57d5d..e4adfdc 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 {





More information about the Scummvm-git-logs mailing list