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

Strangerke Strangerke at scummvm.org
Sun Feb 9 11:38:59 CET 2014


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:
fd50556d1e HUGO: Reduce the scope of some variables


Commit: fd50556d1e8cb1e34e7f33d13788266d0fdbfa37
    https://github.com/scummvm/scummvm/commit/fd50556d1e8cb1e34e7f33d13788266d0fdbfa37
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-02-09T02:37:30-08:00

Commit Message:
HUGO: Reduce the scope of some variables

Changed paths:
    engines/hugo/detection.cpp
    engines/hugo/mouse.cpp
    engines/hugo/object.cpp
    engines/hugo/route.cpp
    engines/hugo/schedule.cpp
    engines/hugo/text.cpp



diff --git a/engines/hugo/detection.cpp b/engines/hugo/detection.cpp
index ede4ab2..ee41fe33 100644
--- a/engines/hugo/detection.cpp
+++ b/engines/hugo/detection.cpp
@@ -184,13 +184,12 @@ SaveStateList HugoMetaEngine::listSaves(const char *target) const {
 
 	SaveStateList saveList;
 	char slot[3];
-	int slotNum = 0;
 	for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
 		slot[0] = filename->c_str()[filename->size() - 6];
 		slot[1] = filename->c_str()[filename->size() - 5];
 		slot[2] = '\0';
 		// Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot
-		slotNum = atoi(slot);
+		int slotNum = atoi(slot);
 		if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
 			Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
 			if (file) {
diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp
index 4ef3db3..4b87475 100644
--- a/engines/hugo/mouse.cpp
+++ b/engines/hugo/mouse.cpp
@@ -160,7 +160,6 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in
 		return;
 
 	int16 inventObjId = _vm->_inventory->getInventoryObjId();
-	bool foundFl = false;                           // TRUE if route found to object
 	// Check if this was over iconbar
 	if ((_vm->_inventory->getInventoryState() == kInventoryActive) && (cy < kInvDy + kDibOffY)) { // Clicked over iconbar object
 		if (inventObjId == -1)
@@ -172,12 +171,14 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in
 	} else {                                        // Clicked over viewport object
 		Object *obj = &_vm->_object->_objects[objId];
 		int16 x, y;
-		switch (obj->_viewx) {                       // Where to walk to
-		case -1:                                    // Walk to object position
+		switch (obj->_viewx) {                      // Where to walk to
+		case -1: {                                  // Walk to object position
+			bool foundFl = false;
 			if (_vm->_object->findObjectSpace(obj, &x, &y))
-				foundFl = _vm->_route->startRoute(kRouteGet, objId, x, y);
+				foundFl = _vm->_route->startRoute(kRouteGet, objId, x, y);  // TRUE if route found to object
 			if (!foundFl)                           // Can't get there, try to use from here
 				_vm->_object->useObject(objId);
+			}
 			break;
 		case 0:                                     // Immediate use
 			_vm->_object->useObject(objId);         // Pick up or use object
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index 44f46d2..315214c 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -134,19 +134,19 @@ void ObjectHandler::restoreSeq(Object *obj) {
 void ObjectHandler::useObject(int16 objId) {
 	debugC(1, kDebugObject, "useObject(%d)", objId);
 
-	const char *verb;                               // Background verb to use directly
 	int16 inventObjId = _vm->_inventory->getInventoryObjId();
-	Object *obj = &_objects[objId];               // Ptr to object
+	Object *obj = &_objects[objId];                       // Ptr to object
 	if (inventObjId == -1) {
+		const char *verb;                                 // Background verb to use directly
 		// Get or use objid directly
 		if ((obj->_genericCmd & TAKE) || obj->_objValue)  // Get collectible item
 			sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_take, 0), _vm->_text->getNoun(obj->_nounIndex, 0));
-		else if (obj->_cmdIndex != 0)                // Use non-collectible item if able
+		else if (obj->_cmdIndex != 0)                     // Use non-collectible item if able
 			sprintf(_vm->_line, "%s %s", _vm->_text->getVerb(_vm->_parser->getCmdDefaultVerbIdx(obj->_cmdIndex), 0), _vm->_text->getNoun(obj->_nounIndex, 0));
 		else if ((verb = _vm->_parser->useBG(_vm->_text->getNoun(obj->_nounIndex, 0))) != 0)
 			sprintf(_vm->_line, "%s %s", verb, _vm->_text->getNoun(obj->_nounIndex, 0));
 		else
-			return;                                 // Can't use object directly
+			return;                                       // Can't use object directly
 	} else {
 		// Use status.objid on objid
 		// Default to first cmd verb
@@ -540,10 +540,8 @@ void ObjectHandler::setCarriedScreen(int screenNum) {
  * Load _numObj from Hugo.dat
  */
 void ObjectHandler::loadNumObj(Common::ReadStream &in) {
-	int numElem;
-
 	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
-		numElem = in.readUint16BE();
+		int numElem = in.readUint16BE();
 		if (varnt == _vm->_gameVariant)
 			_numObj = numElem;
 	}
diff --git a/engines/hugo/route.cpp b/engines/hugo/route.cpp
index dc3c41d..c4ffa6c 100644
--- a/engines/hugo/route.cpp
+++ b/engines/hugo/route.cpp
@@ -384,9 +384,9 @@ bool Route::findRoute(const int16 cx, const int16 cy) {
 	_segment[_segmentNumb]._x2 = herox2;
 	_segmentNumb++;
 
-	Common::Point *routeNode;                       // Ptr to route node
 	// Look in segments[] for straight lines from destination to hero
 	for (i = 0, _routeListIndex = 0; i < _segmentNumb - 1; i++) {
+		Common::Point *routeNode;                   // Ptr to route node
 		if ((routeNode = newNode()) == 0)           // New node for new segment
 			return false;                           // Too many nodes
 		routeNode->y = _segment[i]._y;
@@ -438,7 +438,7 @@ bool Route::findRoute(const int16 cx, const int16 cy) {
 void Route::processRoute() {
 	debugC(1, kDebugRoute, "processRoute");
 
-	static bool turnedFl = false;                   // Used to get extra cylce for turning
+	static bool turnedFl = false;                   // Used to get extra cycle for turning
 
 	if (_routeIndex < 0)
 		return;
diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp
index 17ffa9d..e8359bf 100644
--- a/engines/hugo/schedule.cpp
+++ b/engines/hugo/schedule.cpp
@@ -254,9 +254,8 @@ void Scheduler::waitForRefresh() {
 void Scheduler::loadAlNewscrIndex(Common::ReadStream &in) {
 	debugC(6, kDebugSchedule, "loadAlNewscrIndex(&in)");
 
-	int numElem;
 	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
-		numElem = in.readUint16BE();
+		int numElem = in.readUint16BE();
 		if (varnt == _vm->_gameVariant)
 			_alNewscrIndex = numElem;
 	}
@@ -568,9 +567,9 @@ void Scheduler::loadActListArr(Common::ReadStream &in) {
 
 	Act tmpAct;
 
-	int numElem, numSubElem;
+	int numSubElem;
 	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
-		numElem = in.readUint16BE();
+		int numElem = in.readUint16BE();
 		if (varnt == _vm->_gameVariant) {
 			_actListArrSize = numElem;
 			_actListArr = (Act **)malloc(sizeof(Act *) * _actListArrSize);
@@ -1214,8 +1213,6 @@ Event *Scheduler::doAction(Event *curEvent) {
 	Act    *action = curEvent->_action;
 	Object *obj1;
 	int     dx, dy;
-	Event  *wrkEvent;                                 // Save ev_p->nextEvent for return
-
 	switch (action->_a0._actType) {
 	case ANULL:                                       // Big NOP from DEL_EVENTS
 		break;
@@ -1444,7 +1441,7 @@ Event *Scheduler::doAction(Event *curEvent) {
 	if (action->_a0._actType == NEW_SCREEN) {         // New_screen() deletes entire list
 		return nullptr;                               // nextEvent = nullptr since list now empty
 	} else {
-		wrkEvent = curEvent->_nextEvent;
+		Event *wrkEvent = curEvent->_nextEvent;
 		delQueue(curEvent);                             // Return event to free list
 		return wrkEvent;                                // Return next event ptr
 	}
@@ -1601,10 +1598,9 @@ void Scheduler_v2d::promptAction(Act *action) {
 	debug(1, "doAction(act3), expecting answer %s", _vm->_file->fetchString(action->_a3._responsePtr[0]));
 
 	bool  found = false;
-	const char *tmpStr;                               // General purpose string ptr
 
 	for (int dx = 0; !found && (action->_a3._responsePtr[dx] != -1); dx++) {
-		tmpStr = _vm->_file->fetchString(action->_a3._responsePtr[dx]);
+		const char *tmpStr = _vm->_file->fetchString(action->_a3._responsePtr[dx]);
 		if (response.contains(tmpStr))
 			found = true;
 	}
diff --git a/engines/hugo/text.cpp b/engines/hugo/text.cpp
index 538a034..5e75057 100644
--- a/engines/hugo/text.cpp
+++ b/engines/hugo/text.cpp
@@ -91,16 +91,14 @@ char **TextHandler::getVerbArray(int idx1) const {
 }
 
 char **TextHandler::loadTextsVariante(Common::ReadStream &in, uint16 *arraySize) {
-	int  numTexts;
-	int  entryLen;
 	int  len;
 	char **res = nullptr;
 	char *pos = nullptr;
 	char *posBck = nullptr;
 
 	for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
-		numTexts = in.readUint16BE();
-		entryLen = in.readUint16BE();
+		int numTexts = in.readUint16BE();
+		int entryLen = in.readUint16BE();
 		pos = (char *)malloc(entryLen);
 		if (varnt == _vm->_gameVariant) {
 			if (arraySize)






More information about the Scummvm-git-logs mailing list