[Scummvm-cvs-logs] scummvm master -> dab5cd387dd10e7c75987bac97e974216806bba3

Strangerke Strangerke at scummvm.org
Mon Sep 14 00:27:17 CEST 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:
dab5cd387d SHERLOCK: Reduce the scope of several variables.


Commit: dab5cd387dd10e7c75987bac97e974216806bba3
    https://github.com/scummvm/scummvm/commit/dab5cd387dd10e7c75987bac97e974216806bba3
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-09-14T00:23:07+02:00

Commit Message:
SHERLOCK: Reduce the scope of several variables.

Changed paths:
    engines/sherlock/scalpel/scalpel.cpp
    engines/sherlock/scene.cpp
    engines/sherlock/tattoo/tattoo_darts.cpp
    engines/sherlock/tattoo/tattoo_inventory.cpp
    engines/sherlock/tattoo/tattoo_journal.cpp
    engines/sherlock/tattoo/tattoo_people.cpp
    engines/sherlock/tattoo/tattoo_scene.cpp
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/widget_files.cpp
    engines/sherlock/tattoo/widget_lab.cpp
    engines/sherlock/tattoo/widget_talk.cpp
    engines/sherlock/tattoo/widget_verbs.cpp



diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index affd0e9..a76b73e 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -1269,7 +1269,6 @@ bool ScalpelEngine::play3doMovie(const Common::String &filename, const Common::P
 	Graphics::Surface tempSurface;
 
 	Common::Point framePos(pos.x, pos.y);
-	ImageFile3DO *frameImageFile = nullptr;
 	ImageFrame *frameImage = nullptr;
 	bool frameShown = false;
 
@@ -1286,7 +1285,7 @@ bool ScalpelEngine::play3doMovie(const Common::String &filename, const Common::P
 			framePos.y -= 8; // frame is 8 pixels on left + top, and 7 pixels on right + bottom
 		}
 
-		frameImageFile = new ImageFile3DO("vidframe.cel", kImageFile3DOType_Cel);
+		ImageFile3DO *frameImageFile = new ImageFile3DO("vidframe.cel", kImageFile3DOType_Cel);
 		frameImage = &(*frameImageFile)[0];
 	}
 
diff --git a/engines/sherlock/scene.cpp b/engines/sherlock/scene.cpp
index d3f5ade..ea12faf 100644
--- a/engines/sherlock/scene.cpp
+++ b/engines/sherlock/scene.cpp
@@ -1091,9 +1091,9 @@ void Scene::checkSceneFlags(bool flag) {
 
 	for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
 		Object &o = _bgShapes[idx];
-		bool objectFlag = true;
 
 		if (o._requiredFlag[0] || o._requiredFlag[1]) {
+			bool objectFlag = true;
 			if (o._requiredFlag[0] != 0)
 				objectFlag = _vm->readFlags(o._requiredFlag[0]);
 			if (o._requiredFlag[1] != 0)
diff --git a/engines/sherlock/tattoo/tattoo_darts.cpp b/engines/sherlock/tattoo/tattoo_darts.cpp
index cb4b52b..6d6c74d 100644
--- a/engines/sherlock/tattoo/tattoo_darts.cpp
+++ b/engines/sherlock/tattoo/tattoo_darts.cpp
@@ -77,7 +77,6 @@ void Darts::playDarts(GameType gameType) {
 	Screen &screen = *_vm->_screen;
 	int oldFontType = screen.fontNumber();
 	int playerNum = 0;
-	int roundStart, score;
 	int lastDart;
 	int numHits = 0;
 	bool gameOver = false;
@@ -92,6 +91,7 @@ void Darts::playDarts(GameType gameType) {
 	initDarts();
 
 	while (!done && !_vm->shouldQuit()) {
+		int roundStart, score;
 		roundStart = score = (playerNum == 0) ? _score1 : _score2;
 
 		showNames(playerNum);
@@ -143,7 +143,6 @@ void Darts::playDarts(GameType gameType) {
 			} else {
 				// check for cricket game over
 				bool allClosed = true;
-				int nOtherScore;
 
 				for (int y = 0; y < 7; y++) {
 					if (_cricketScore[playerNum][y] < 3)
@@ -151,7 +150,7 @@ void Darts::playDarts(GameType gameType) {
 				}
 
 				if (allClosed) {
-					nOtherScore = (playerNum == 0) ? _score2 : _score1;
+					int nOtherScore = (playerNum == 0) ? _score2 : _score1;
 					if (score >= nOtherScore)
 						gameOver = true;
 				}
@@ -561,11 +560,10 @@ void Darts::drawDartThrow(const Common::Point &dartPos, int computer) {
 	Events &events = *_vm->_events;
 	Screen &screen = *_vm->_screen;
 	int cx, cy;
-	int handCy;
 	int drawX = 0, drawY = 0, oldDrawX = 0, oldDrawY = 0;
 	int xSize = 0, ySize = 0, oldxSize = 0, oldySize = 0;
-	int handOCx, handOCy;
-	int ocx, ocy;
+	int handOCx = 0, handOCy = 0;
+	int ocx = 0, ocy = 0;
 	int handOldxSize, handOldySize;
 	int delta = 9;
 	int dartNum;
@@ -576,7 +574,6 @@ void Darts::drawDartThrow(const Common::Point &dartPos, int computer) {
 	ImageFile &hands = !computer ? *_hand1 : *_hand2;
 	int numFrames = !computer ? 14 : 13;
 
-	ocx = ocy = handOCx = handOCy = 0;
 	oldxSize = oldySize = handOldxSize = handOldySize = 1;
 	cx = dartPos.x;
 	cy = SHERLOCK_SCREEN_HEIGHT - _handSize.y - 20;
@@ -590,7 +587,7 @@ void Darts::drawDartThrow(const Common::Point &dartPos, int computer) {
 	for (int idx = 0; idx < numFrames; ++idx) {
 		_handSize.x = hands[idx]._offset.x + hands[idx]._width;
 		_handSize.y = hands[idx]._offset.y + hands[idx]._height;
-		handCy = SHERLOCK_SCREEN_HEIGHT - _handSize.y;
+		int handCy = SHERLOCK_SCREEN_HEIGHT - _handSize.y;
 
 		screen._backBuffer1.transBlitFrom(hands[idx], Common::Point(_handX, handCy));
 		screen.slamArea(_handX, handCy, _handSize.x + 1, _handSize.y);
@@ -787,8 +784,6 @@ void Darts::getComputerNumber(int playerNum, Common::Point &targetPos) {
 	int score;
 	int aim = 0;
 	Common::Point pt;
-	bool done = false;
-	int cricketaimset = false;
 	bool shootBull = false;
 
 	score = (playerNum == 0) ? _score1 : _score2;
@@ -799,6 +794,7 @@ void Darts::getComputerNumber(int playerNum, Common::Point &targetPos) {
 		if(score > 60)
 			shootBull = true;
 	} else {
+		bool cricketaimset = false;
 		if (_cricketScore[playerNum][6] < 3) {
 			// shoot at bull first
 			aim = CRICKET_VALUE[6];
@@ -842,6 +838,7 @@ void Darts::getComputerNumber(int playerNum, Common::Point &targetPos) {
 		}
 	} else {
 		// Loop in case number does not exist on board
+		bool done = false;
 		do {
 			done = findNumberOnBoard(aim, pt);
 			--aim;
diff --git a/engines/sherlock/tattoo/tattoo_inventory.cpp b/engines/sherlock/tattoo/tattoo_inventory.cpp
index 6bd1822..14e79e9 100644
--- a/engines/sherlock/tattoo/tattoo_inventory.cpp
+++ b/engines/sherlock/tattoo/tattoo_inventory.cpp
@@ -43,10 +43,10 @@ void TattooInventory::loadInv() {
 	Common::SeekableReadStream *stream = _vm->_res->load("invent.txt");
 
 	int count = stream->readByte();
-	char c;
 
 	for (int idx = 0; idx < count; ++idx) {
 		Common::String name;
+		char c;
 		while ((c = stream->readByte()) != 0)
 			name += c;
 
diff --git a/engines/sherlock/tattoo/tattoo_journal.cpp b/engines/sherlock/tattoo/tattoo_journal.cpp
index b45d669..abe3e54 100644
--- a/engines/sherlock/tattoo/tattoo_journal.cpp
+++ b/engines/sherlock/tattoo/tattoo_journal.cpp
@@ -345,9 +345,9 @@ void TattooJournal::handleButtons() {
 			disableControls();
 
 			bool notFound = false;
-			int dir;
 
 			do {
+				int dir;
 				if ((dir = getFindName(notFound)) != 0) {
 					_savedIndex = _index;
 					_savedSub = _sub;
diff --git a/engines/sherlock/tattoo/tattoo_people.cpp b/engines/sherlock/tattoo/tattoo_people.cpp
index e3e957e..fe60189 100644
--- a/engines/sherlock/tattoo/tattoo_people.cpp
+++ b/engines/sherlock/tattoo/tattoo_people.cpp
@@ -1010,7 +1010,6 @@ void TattooPerson::walkHolmesToNPC() {
 	Screen &screen = *_vm->_screen;
 	Talk &talk = *_vm->_talk;
 	TattooPerson &holmes = people[HOLMES];
-	int facing;
 
 	// Save the character's details
 	pushNPCPath();
@@ -1073,9 +1072,8 @@ void TattooPerson::walkHolmesToNPC() {
 
 	if (!talk._talkToAbort) {
 		// Setup correct direction for Holmes to face
-
 		// See where Holmes is with respect to the NPC (x coords)
-		facing = (holmes._position.x < _position.x) ? STOP_RIGHT : STOP_LEFT;
+		int facing = (holmes._position.x < _position.x) ? STOP_RIGHT : STOP_LEFT;
 
 		// See where Holmes is with respect to the NPC (y coords)
 		if (holmes._position.y < (_position.y - (10 * FIXED_INT_MULTIPLIER))) {
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index f13d058..8162203 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -809,13 +809,12 @@ void TattooScene::synchronize(Serializer &s) {
 int TattooScene::closestZone(const Common::Point &pt) {
 	int zone = -1;
 	int dist = 9999;
-	int d;
 
 	for (uint idx = 0; idx < _zones.size(); ++idx) {
 		Common::Rect &r = _zones[idx];
 
 		// Check the distance from the point to the center of the zone
-		d = ABS(r.left + (r.width() / 2) - pt.x) + ABS(r.top + (r.height() / 2) - pt.y);
+		int d = ABS(r.left + (r.width() / 2) - pt.x) + ABS(r.top + (r.height() / 2) - pt.y);
 		if (d < dist) {
 			dist = d;
 			zone = idx;
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 6ed0bf6..da4a277 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -85,7 +85,6 @@ void TattooUserInterface::lookAtObject() {
 	Talk &talk = *_vm->_talk;
 	Common::Point mousePos = events.mousePos();
 	Common::String desc;
-	int cAnimSpeed = 0;
 
 	_lookPos = mousePos;
 	_menuMode = LOOK_MODE;
@@ -95,7 +94,7 @@ void TattooUserInterface::lookAtObject() {
 	} else {
 		// Check if there is a Look animation
 		if (_bgShape->_lookcAnim != 0) {
-			cAnimSpeed = _bgShape->_lookcAnim & 0xe0;
+			int cAnimSpeed = _bgShape->_lookcAnim & 0xe0;
 			cAnimSpeed >>= 5;
 			++cAnimSpeed;
 
@@ -377,7 +376,6 @@ void TattooUserInterface::doStandardControl() {
 	TattooScene &scene = *(TattooScene *)_vm->_scene;
 	Talk &talk = *_vm->_talk;
 	Common::Point mousePos = events.mousePos();
-	bool noDesc = false;
 
 	// Don't do any input processing whilst the prolog is running
 	if (vm._runningProlog)
@@ -458,6 +456,7 @@ void TattooUserInterface::doStandardControl() {
 		if (_arrowZone == -1 || events._rightReleased)
 			freeMenu();
 
+		bool noDesc = false;
 		if (_personFound) {
 			if (people[_bgFound - 1000]._description.empty() || people[_bgFound - 1000]._description.hasPrefix(" "))
 				noDesc = true;
diff --git a/engines/sherlock/tattoo/widget_files.cpp b/engines/sherlock/tattoo/widget_files.cpp
index c9a20b0..0f5e679 100644
--- a/engines/sherlock/tattoo/widget_files.cpp
+++ b/engines/sherlock/tattoo/widget_files.cpp
@@ -253,7 +253,6 @@ bool WidgetFiles::getFilename() {
 	int done = 0;
 	bool blinkFlag = false;
 	int blinkCountdown = 0;
-	int width;
 	int cursorColor = 192;
 	byte color, textColor;
 	bool insert = true;
@@ -285,7 +284,7 @@ bool WidgetFiles::getFilename() {
 
 		char currentChar = (index == (int)filename.size()) ? ' ' : filename[index];
 		Common::String charString = Common::String::format("%c", currentChar);
-		width = screen.charWidth(currentChar);
+		int width = screen.charWidth(currentChar);
 
 		// Wait for keypress
 		while (!events.kbHit()) {
diff --git a/engines/sherlock/tattoo/widget_lab.cpp b/engines/sherlock/tattoo/widget_lab.cpp
index 2873b12..eb32e2e 100644
--- a/engines/sherlock/tattoo/widget_lab.cpp
+++ b/engines/sherlock/tattoo/widget_lab.cpp
@@ -45,7 +45,6 @@ void WidgetLab::handleEvents() {
 	Common::Point mousePos = events.mousePos();
 
 	WidgetBase::handleEvents();
-	bool noDesc = false;
 
 	// Handle drawing tooltips. If the user is dragging a lab item, display a tooltip for using the item
 	// on another. Otherwise, fall back on showing standard tooltips
@@ -65,6 +64,7 @@ void WidgetLab::handleEvents() {
 		if (ui._arrowZone == -1 || events._rightReleased)
 			ui._tooltipWidget.setText("");
 
+		bool noDesc = false;
 		if (ui._bgFound != -1) {
 			if (ui._bgShape->_description.hasPrefix(" ") || ui._bgShape->_description.empty())
 				noDesc = true;
diff --git a/engines/sherlock/tattoo/widget_talk.cpp b/engines/sherlock/tattoo/widget_talk.cpp
index 00e8233..6e7bde2 100644
--- a/engines/sherlock/tattoo/widget_talk.cpp
+++ b/engines/sherlock/tattoo/widget_talk.cpp
@@ -369,11 +369,11 @@ void WidgetTalk::handleEvents() {
 
 void WidgetTalk::render(Highlight highlightMode) {
 	TattooTalk &talk = *(TattooTalk *)_vm->_talk;
-	int yp = 5;
-	int statementNum = 1;
-	byte color;
 
 	if (highlightMode != HL_SCROLLBAR_ONLY) {
+		int yp = 5;
+		int statementNum = 1;
+
 		// Draw all the statements
 		// Check whether scrolling has occurred, and if so, figure out what the starting
 		// number for the first visible statement will be
@@ -392,7 +392,7 @@ void WidgetTalk::render(Highlight highlightMode) {
 				_surface.fillRect(Common::Rect(3, yp, _surface.w() - BUTTON_SIZE - 3, yp + _surface.fontHeight()), TRANSPARENCY);
 
 				// Different coloring based on whether the option has been previously chosen or not
-				color = (!talk._talkHistory[talk._converseNum][_statementLines[idx]._num]) ?
+				byte color = (!talk._talkHistory[talk._converseNum][_statementLines[idx]._num]) ?
 					INFO_TOP : INFO_BOTTOM;
 
 				if (_statementLines[idx]._num == _selector && highlightMode == HL_CHANGED_HIGHLIGHTS)
diff --git a/engines/sherlock/tattoo/widget_verbs.cpp b/engines/sherlock/tattoo/widget_verbs.cpp
index 0b523a9..09d2795 100644
--- a/engines/sherlock/tattoo/widget_verbs.cpp
+++ b/engines/sherlock/tattoo/widget_verbs.cpp
@@ -158,7 +158,6 @@ void WidgetVerbs::handleEvents() {
 	Talk &talk = *_vm->_talk;
 	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
 	Common::Point mousePos = events.mousePos();
-	bool noDesc = false;
 
 	Common::String strLook = fixedText.getText(kFixedText_Look);
 	Common::String strTalk = fixedText.getText(kFixedText_Talk);
@@ -184,6 +183,7 @@ void WidgetVerbs::handleEvents() {
 					ui._personFound = ui._bgFound >= 1000;
 					ui._bgShape = ui._personFound || ui._bgFound == -1 ? nullptr : &scene._bgShapes[ui._bgFound];
 
+					bool noDesc = false;
 					if (ui._personFound) {
 						if (people[ui._bgFound - 1000]._description.empty() || people[ui._bgFound - 1000]._description.hasPrefix(" "))
 							noDesc = true;






More information about the Scummvm-git-logs mailing list