aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
authorStrangerke2014-02-09 11:37:30 +0100
committerStrangerke2014-02-09 11:37:30 +0100
commitfd50556d1e8cb1e34e7f33d13788266d0fdbfa37 (patch)
tree61480b829bbf9979f11cbdc70062def148f18d40 /engines/hugo
parenta1ab4cb062d5b94c2b0c590816b68770d8989248 (diff)
downloadscummvm-rg350-fd50556d1e8cb1e34e7f33d13788266d0fdbfa37.tar.gz
scummvm-rg350-fd50556d1e8cb1e34e7f33d13788266d0fdbfa37.tar.bz2
scummvm-rg350-fd50556d1e8cb1e34e7f33d13788266d0fdbfa37.zip
HUGO: Reduce the scope of some variables
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/detection.cpp3
-rw-r--r--engines/hugo/mouse.cpp9
-rw-r--r--engines/hugo/object.cpp12
-rw-r--r--engines/hugo/route.cpp4
-rw-r--r--engines/hugo/schedule.cpp14
-rw-r--r--engines/hugo/text.cpp6
6 files changed, 20 insertions, 28 deletions
diff --git a/engines/hugo/detection.cpp b/engines/hugo/detection.cpp
index ede4ab2279..ee41fe33f2 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 4ef3db3e2b..4b874756a0 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 44f46d2d79..315214c5a4 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 dc3c41de9c..c4ffa6c7ca 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 17ffa9d391..e8359bfdfc 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 538a0341e2..5e7505744c 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)