[Scummvm-git-logs] scummvm master -> 1c8a7800da74cd531ec92c1f04919660963b7609

Strangerke Strangerke at scummvm.org
Fri Sep 6 08:18:49 CEST 2019


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

Summary:
d1b9e1db7a HDB: Initialize some more uninitialized variables.
5b01ca8694 HDB: Reduce the scope of some variables
1c8a7800da HDB: More missing initializations


Commit: d1b9e1db7a7bf8394492d3c82a9598d2ba2a98cf
    https://github.com/scummvm/scummvm/commit/d1b9e1db7a7bf8394492d3c82a9598d2ba2a98cf
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-06T08:16:04+02:00

Commit Message:
HDB: Initialize some more uninitialized variables.

Changed paths:
    engines/hdb/file-manager.cpp
    engines/hdb/hdb.cpp
    engines/hdb/hdb.h
    engines/hdb/map.cpp


diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index bc75174..9c2eca1 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -31,6 +31,8 @@ namespace HDB {
 
 FileMan::FileMan() {
 	_mpcFile = new Common::File;
+	_dataHeader.id = 0;
+	_dataHeader.dirSize = 0;
 }
 
 FileMan::~FileMan() {
@@ -40,23 +42,17 @@ FileMan::~FileMan() {
 }
 
 void FileMan::openMPC(const Common::String &filename) {
-	if (!_mpcFile->open(filename)) {
+	if (!_mpcFile->open(filename))
 		error("FileMan::openMPC(): Error reading the MSD/MPC file %s", filename.c_str());
-	}
 
 	_dataHeader.id = _mpcFile->readUint32BE();
 
-	if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C')) {
+	if (_dataHeader.id == MKTAG('M', 'P', 'C', 'C'))
 		error("FileMan::openMPC: Compressed MPC File");
-	} else if (_dataHeader.id == MKTAG('M', 'P', 'C', 'U')) {
-		// we're fine
-	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'C')) {
-		// we're fine
-	} else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U')) {
+	else if (_dataHeader.id == MKTAG('M', 'S', 'D', 'U'))
 		error("FileMan::openMPC: Uncompressed MSD File");
-	} else {
+	else if (_dataHeader.id != MKTAG('M', 'P', 'C', 'U') && _dataHeader.id != MKTAG('M', 'S', 'D', 'C'))
 		error("FileMan::openMPC: Invalid MPC/MSD File.");
-	}
 
 	// read the directory
 	uint32 offset = _mpcFile->readUint32LE();
@@ -72,9 +68,8 @@ void FileMan::openMPC(const Common::String &filename) {
 	for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) {
 		MPCEntry *dirEntry = new MPCEntry();
 
-		for (int i = 0; i < 64; i++) {
+		for (int i = 0; i < 64; i++)
 			dirEntry->filename[i] = tolower(_mpcFile->readByte());
-		}
 
 		dirEntry->offset = _mpcFile->readUint32LE();
 		dirEntry->length = _mpcFile->readUint32LE();
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index c7c206c..5b09f3d 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -90,6 +90,27 @@ HDBGame::HDBGame(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst
 	_monkeystone14 = STARS_MONKEYSTONE_14_FAKE;
 	_monkeystone21 = STARS_MONKEYSTONE_21_FAKE;
 
+	_gameShutdown = false;
+	_progressGfx = nullptr;
+	_progressMarkGfx = nullptr;
+	_loadingScreenGfx = nullptr;
+	_logoGfx = nullptr;
+	_progressCurrent = -1;
+	_progressXOffset = -1;
+	_progressMax = -1;
+	_gameState = GAME_TITLE;
+	_actionMode = -1;
+	_pauseFlag = false;
+	_debugFlag = -1;
+	_debugLogo = nullptr;
+	_dx = 0;
+	_dy = 0;
+	_changeLevel = false;
+	_saveInfo.active = false;
+	_saveInfo.slot = 0;
+	_loadInfo.active = false;
+	_loadInfo.slot = 0;
+
 	syncSoundSettings();
 }
 
@@ -159,7 +180,7 @@ bool HDBGame::init() {
 	_menu->startTitle();
 
 	_gameShutdown = false;
-	_pauseFlag = 0;
+	_pauseFlag = false;
 	_systemInit = true;
 	if (!g_hdb->isPPC())
 		_loadingScreenGfx = _gfx->loadPic(PIC_LOADSCREEN);
@@ -355,11 +376,10 @@ void HDBGame::paint() {
 	}
 
 	// Draw FPS on Screen in Debug Mode
-	if (_debugFlag == 1) {
+	if (_debugFlag == 1)
 		_gfx->drawDebugInfo(_debugLogo, _frames.size());
-	} else if (_debugFlag == 2) {
+	else if (_debugFlag == 2)
 		_debugLogo->drawMasked(_screenWidth - 32, 0);
-	}
 
 	_gfx->updateVideo();
 }
diff --git a/engines/hdb/hdb.h b/engines/hdb/hdb.h
index eb3a818..8a23bdb 100644
--- a/engines/hdb/hdb.h
+++ b/engines/hdb/hdb.h
@@ -248,10 +248,10 @@ public:
 	}
 
 	void togglePause() {
-		_pauseFlag ^= 1;
+		_pauseFlag ^= true;
 	}
 
-	int getPause() {
+	bool getPause() {
 		return _pauseFlag;
 	}
 
@@ -345,7 +345,7 @@ private:
 	int _actionMode; // 0 or 1
 
 	// Misc Variables
-	int _pauseFlag;
+	bool _pauseFlag;
 	bool _cheating;
 	int _debugFlag;
 	Tile *_debugLogo;
diff --git a/engines/hdb/map.cpp b/engines/hdb/map.cpp
index a0eedcb..0edc513 100644
--- a/engines/hdb/map.cpp
+++ b/engines/hdb/map.cpp
@@ -55,6 +55,20 @@ Map::Map() {
 	_background = NULL;
 	_foreground = NULL;
 	_iconList = NULL;
+
+	_width = 0;
+	_height = 0;
+	_mapX = 0;
+	_mapY = 0;
+	_mapTileX = 0;
+	_mapTileY = 0;
+	_mapTileXOff = 0;
+	_mapTileYOff = 0;
+	_backgroundOffset = 0;
+	_foregroundOffset = 0;
+	_iconNum = 0;
+	_iconListOffset = 0;
+	_infoNum = 0;
 }
 
 Map::~Map() {


Commit: 5b01ca8694c37dcddd58d0bbbbb9fd16409e28d0
    https://github.com/scummvm/scummvm/commit/5b01ca8694c37dcddd58d0bbbbb9fd16409e28d0
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-06T08:16:04+02:00

Commit Message:
HDB: Reduce the scope of some variables

Changed paths:
    engines/hdb/hdb.cpp


diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index 5b09f3d..82e377d 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -387,10 +387,6 @@ void HDBGame::paint() {
 // builds a waypoint list if an entity is not next to player,
 //	or gives info on an entity, or actually uses an entity
 void HDBGame::setTargetXY(int x, int y) {
-	AIEntity *e, *p;
-	int px, py;
-	bool oneTileAway;
-
 	// if ANY button is pressed
 	if (_input->getButtons() || _ai->_playerEmerging)
 		return;
@@ -403,14 +399,14 @@ void HDBGame::setTargetXY(int x, int y) {
 	if (!x)
 		return;
 
-	e = _ai->findEntity(x, y);
-	p = _ai->getPlayer();
+	AIEntity *e = _ai->findEntity(x, y);
+	AIEntity *p = _ai->getPlayer();
 
 	if (!p)
 		return;
 
-	px = p->x / kTileWidth;
-	py = p->y / kTileHeight;
+	int px = p->x / kTileWidth;
+	int py = p->y / kTileHeight;
 
 	// Are we on a touchplate and trying to move within the waiting period?
 	if (p->touchpWait)
@@ -428,7 +424,7 @@ void HDBGame::setTargetXY(int x, int y) {
 			return;
 	}
 
-	oneTileAway = (abs(px - x) + abs(py - y) < 2);
+	bool oneTileAway = (abs(px - x) + abs(py - y) < 2);
 
 	// If any entity has been targeted
 	if (e && !_ai->waypointsLeft()) {
@@ -549,7 +545,6 @@ void HDBGame::startMoveMap(int x, int y) {
 
 void HDBGame::moveMap(int x, int y) {
 	int	ox, oy;
-
 	g_hdb->_map->getMapXY(&ox, &oy);
 
 	ox += (_dx - x) / 8;
@@ -570,19 +565,15 @@ void HDBGame::moveMap(int x, int y) {
 
 // PLAYER is trying to use this entity
 void HDBGame::useEntity(AIEntity *e) {
-
-	AIEntity *p, temp;
-	bool added;
-
-	p = _ai->getPlayer();
+	AIEntity *p = _ai->getPlayer();
 	// Check if entity is on same level or if its a stairtop
-	if ((p->level != e->level) && !(_map->getMapBGTileFlags(p->tileX, p->tileY) & kFlagStairTop)) {
+	if ((p->level != e->level) && !(_map->getMapBGTileFlags(p->tileX, p->tileY) & kFlagStairTop))
 		return;
-	}
 
-	added = false;
+	bool added = false;
 
 	if (_ai->getTableEnt(e->type)) {
+		AIEntity temp;
 		memcpy(&temp, e, sizeof(AIEntity));
 
 		_ai->getItemSound(e->type);
@@ -591,37 +582,27 @@ void HDBGame::useEntity(AIEntity *e) {
 		if (added) {
 			e = &temp;
 
-			if (temp.aiUse) {
+			if (temp.aiUse)
 				temp.aiUse(&temp);
-			}
 
-			if (temp.luaFuncUse[0]) {
+			if (temp.luaFuncUse[0])
 				_lua->callFunction(temp.luaFuncUse, 0);
-			}
 		}
-
 	} else {
 		// These should be run over or run through
-		if (_ai->walkThroughEnt(e->type) || e->type == AI_NONE) {
+		if (_ai->walkThroughEnt(e->type) || e->type == AI_NONE)
 			return;
-		}
 
-		if (e->aiUse) {
+		if (e->aiUse)
 			e->aiUse(e);
-		}
 
-		if (e->luaFuncUse[0]) {
+		if (e->luaFuncUse[0])
 			_lua->callFunction(e->luaFuncUse, 0);
-		}
 	}
 
 	// PUSHING
 	// If its a pushable object, push it. Unless it's in/on water.
 	if (e->type == AI_CRATE || e->type == AI_LIGHTBARREL || e->type == AI_BOOMBARREL || e->type == AI_MAGIC_EGG || e->type == AI_ICE_BLOCK || e->type == AI_FROGSTATUE || e->type == AI_DIVERTER) {
-		int	xDir, yDir, chX, chY;
-		uint32 flags;
-		AIEntity *e2;
-
 		// if it's floating, don't touch!
 		if (e->state >= STATE_FLOATING && e->state <= STATE_FLOATRIGHT) {
 			g_hdb->_ai->lookAtEntity(e);
@@ -630,7 +611,8 @@ void HDBGame::useEntity(AIEntity *e) {
 			return;
 		}
 
-		xDir = yDir = 0;
+		int xDir = 0;
+		int yDir = 0;
 		if (p->tileX > e->tileX)
 			xDir = -2;
 		else if (p->tileX < e->tileX)
@@ -645,9 +627,9 @@ void HDBGame::useEntity(AIEntity *e) {
 		if (xDir && yDir)
 			return;
 
-		chX = p->tileX + xDir;
-		chY = p->tileY + yDir;
-
+		int chX = p->tileX + xDir;
+		int chY = p->tileY + yDir;
+		uint32 flags;
 		// are we going to push this over a sliding surface? (ok)
 		// are we going to push this into a blocking tile? (not ok)
 		if (e->level == 2) {
@@ -700,7 +682,7 @@ void HDBGame::useEntity(AIEntity *e) {
 
 		// are we going to push this into a gem?
 		// if it's a goodfairy, make it move!
-		e2 = g_hdb->_ai->findEntityIgnore(chX, chY, &g_hdb->_ai->_dummyLaser);
+		AIEntity *e2 = g_hdb->_ai->findEntityIgnore(chX, chY, &g_hdb->_ai->_dummyLaser);
 		if (e2 && e2->type == ITEM_GEM_WHITE) {
 			g_hdb->_ai->addAnimateTarget(e2->x, e2->y, 0, 3, ANIM_NORMAL, false, false, GEM_FLASH);
 			g_hdb->_ai->removeEntity(e2);
@@ -819,19 +801,16 @@ void HDBGame::useEntity(AIEntity *e) {
 	}
 
 	// Look at Entity
-	if (e->type != AI_RAILRIDER_ON) {
+	if (e->type != AI_RAILRIDER_ON)
 		_ai->lookAtEntity(e);
-	}
 
 	// Grab animation
-	if (added) {
+	if (added)
 		_ai->animGrabbing();
-	}
 
 	// Can't push it - make a sound
-	if (e->type == AI_HEAVYBARREL) {
+	if (e->type == AI_HEAVYBARREL)
 		g_hdb->_sound->playSound(SND_GUY_UHUH);
-	}
 }
 
 void HDBGame::setupProgressBar(int maxCount) {


Commit: 1c8a7800da74cd531ec92c1f04919660963b7609
    https://github.com/scummvm/scummvm/commit/1c8a7800da74cd531ec92c1f04919660963b7609
Author: Strangerke (strangerke at scummvm.org)
Date: 2019-09-06T08:16:04+02:00

Commit Message:
HDB: More missing initializations

Changed paths:
    engines/hdb/lua-script.cpp
    engines/hdb/window.cpp


diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index b19feb6..13f4066 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -115,6 +115,11 @@ LuaScript::LuaScript() {
 
 	_state = NULL;
 	_systemInit = false;
+
+
+	_pcallErrorhandlerRegistryIndex = 0;
+	_globalLuaStream = nullptr;
+	_globalLuaLength = 0;
 }
 
 LuaScript::~LuaScript() {
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 0f89c36..b4a34bd 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -76,6 +76,33 @@ Window::Window() {
 	}
 
 	_pauseY = (g_hdb->_screenHeight / 2 - 64);
+
+	_gGfxTM = nullptr;
+	_gGfxTR = nullptr;
+	_gGfxL = nullptr;
+	_gGfxM = nullptr;
+	_gGfxR = nullptr;
+	_gGfxBL = nullptr;
+	_gGfxBM = nullptr;
+	_gGfxBR = nullptr;
+	_gGfxTitleL = nullptr;
+	_gGfxTitleM = nullptr;
+	_gGfxTitleR = nullptr;
+	_gfxIndent = nullptr;
+	_gfxArrowTo = nullptr;
+	_gfxHandright = nullptr;
+	_gfxTry = nullptr;
+	_gfxAgain = nullptr;
+	_gfxInvSelect = nullptr;
+	_gfxLevelRestart = nullptr;
+	_gfxPausePlaque = nullptr;
+	_gemGfx = nullptr;
+	_mstoneGfx = nullptr;
+	_gfxResources = nullptr;
+	_gfxDeliveries = nullptr;
+	_gfxInfobar = nullptr;
+	_gfxDarken = nullptr;
+	_infobarDimmed = 0;
 }
 
 Window::~Window() {





More information about the Scummvm-git-logs mailing list