[Scummvm-cvs-logs] scummvm master -> 9834d37b33e3b02d3632a9b1806a065a0146b2c1

Strangerke Strangerke at scummvm.org
Tue Dec 29 13:37:16 CET 2015


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:
9834d37b33 LAB: Reduce the scope of some variables


Commit: 9834d37b33e3b02d3632a9b1806a065a0146b2c1
    https://github.com/scummvm/scummvm/commit/9834d37b33e3b02d3632a9b1806a065a0146b2c1
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-29T13:31:34+01:00

Commit Message:
LAB: Reduce the scope of some variables

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 42587eb..cd47342 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -380,12 +380,6 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 }
 
 void LabEngine::mainGameLoop() {
-	uint16 actionMode = 4;
-	uint16 curInv = kItemMap;
-
-	bool forceDraw = false;
-	bool gotMessage = true;
-
 	_graphics->setPalette(initColors, 8);
 
 	_closeDataPtr = nullptr;
@@ -407,6 +401,7 @@ void LabEngine::mainGameLoop() {
 	_graphics->_longWinInFront = false;
 	_graphics->drawPanel();
 
+	uint16 actionMode = 4;
 	perFlipButton(actionMode);
 
 	// Load saved slot from the launcher, if requested
@@ -421,6 +416,9 @@ void LabEngine::mainGameLoop() {
 		_music->checkRoomMusic();
 	}
 
+	uint16 curInv = kItemMap;
+	bool forceDraw = false;
+	bool gotMessage = true;
 	// Set up initial picture.
 	while (1) {
 		_event->processInput();
@@ -549,6 +547,10 @@ void LabEngine::showLab2Teaser() {
 
 bool LabEngine::processEvent(MessageClass tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
 			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode) {
+
+	if (shouldQuit())
+		return false;
+
 	MessageClass msgClass = tmpClass;
 	Common::Point curPos = tmpPos;
 	uint16 oldDirection = 0;
@@ -562,9 +564,6 @@ bool LabEngine::processEvent(MessageClass tmpClass, uint16 code, uint16 qualifie
 
 	_anim->_doBlack = false;
 
-	if (shouldQuit())
-		return false;
-
 	if (_graphics->_longWinInFront) {
 		if (msgClass == kMessageRawKey || leftButtonClick || rightButtonClick) {
 			_graphics->_longWinInFront = false;
@@ -704,9 +703,6 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 msgClass, uint16 &qualif
 }
 
 void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode) {
-	uint16 newDir;
-	uint16 oldRoomNum;
-
 	switch (buttonId) {
 	case kButtonPickup:
 	case kButtonUse:
@@ -753,7 +749,7 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi
 		break;
 
 	case kButtonLeft:
-	case kButtonRight:
+	case kButtonRight: {
 		_closeDataPtr = nullptr;
 		if (buttonId == kButtonLeft)
 			drawStaticMessage(kTextTurnLeft);
@@ -763,17 +759,18 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi
 		_curFileName = " ";
 		oldDirection = _direction;
 
-		newDir = processArrow(_direction, buttonId - 6);
+		uint16 newDir = processArrow(_direction, buttonId - 6);
 		doTurn(_direction, newDir);
 		_anim->_doBlack = true;
 		_direction = newDir;
 		forceDraw = true;
 		mayShowCrumbIndicator();
+		}
 		break;
 
-	case kButtonForward:
+	case kButtonForward: {
 		_closeDataPtr = nullptr;
-		oldRoomNum = _roomNum;
+		int oldRoomNum = _roomNum;
 
 		if (doGoForward()) {
 			if (oldRoomNum == _roomNum)
@@ -831,6 +828,7 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi
 		}
 
 		mayShowCrumbIndicator();
+		}
 		break;
 
 	case kButtonMap:
@@ -844,8 +842,6 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi
 }
 
 void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode) {
-	bool saveRestoreSuccessful = true;
-
 	_anim->_doBlack = true;
 
 	switch (buttonId) {
@@ -861,12 +857,12 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		drawRoomMessage(curInv, _closeDataPtr);
 		break;
 
-	case kButtonSaveLoad:
+	case kButtonSaveLoad: {
 		interfaceOff();
 		_anim->stopDiff();
 		_curFileName = " ";
 
-		saveRestoreSuccessful = saveRestoreGame();
+		bool saveRestoreSuccessful = saveRestoreGame();
 		_closeDataPtr = nullptr;
 		_mainDisplay = true;
 
@@ -880,6 +876,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 			_graphics->setPalette(initColors, 8);
 			_system->delayMillis(1000);
 		}
+		}
 		break;
 
 	case kButtonUseItem:
@@ -1006,8 +1003,8 @@ void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &c
 			_closeDataPtr = tmpClosePtr;
 		} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 			drawStaticMessage(kTextNothing);
-	}
-			break;
+		}
+		break;
 
 	case 5:
 		if (_conditions->in(curInv)) {






More information about the Scummvm-git-logs mailing list