mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
HUGO: Reduce the scope of some variables
This commit is contained in:
parent
a1ab4cb062
commit
fd50556d1e
@ -184,13 +184,12 @@ SaveStateList HugoMetaEngine::listSaves(const char *target) const {
|
|||||||
|
|
||||||
SaveStateList saveList;
|
SaveStateList saveList;
|
||||||
char slot[3];
|
char slot[3];
|
||||||
int slotNum = 0;
|
|
||||||
for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
|
for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
|
||||||
slot[0] = filename->c_str()[filename->size() - 6];
|
slot[0] = filename->c_str()[filename->size() - 6];
|
||||||
slot[1] = filename->c_str()[filename->size() - 5];
|
slot[1] = filename->c_str()[filename->size() - 5];
|
||||||
slot[2] = '\0';
|
slot[2] = '\0';
|
||||||
// Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot
|
// 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()) {
|
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
|
||||||
Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
|
Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
|
||||||
if (file) {
|
if (file) {
|
||||||
|
@ -160,7 +160,6 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int16 inventObjId = _vm->_inventory->getInventoryObjId();
|
int16 inventObjId = _vm->_inventory->getInventoryObjId();
|
||||||
bool foundFl = false; // TRUE if route found to object
|
|
||||||
// Check if this was over iconbar
|
// Check if this was over iconbar
|
||||||
if ((_vm->_inventory->getInventoryState() == kInventoryActive) && (cy < kInvDy + kDibOffY)) { // Clicked over iconbar object
|
if ((_vm->_inventory->getInventoryState() == kInventoryActive) && (cy < kInvDy + kDibOffY)) { // Clicked over iconbar object
|
||||||
if (inventObjId == -1)
|
if (inventObjId == -1)
|
||||||
@ -172,12 +171,14 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in
|
|||||||
} else { // Clicked over viewport object
|
} else { // Clicked over viewport object
|
||||||
Object *obj = &_vm->_object->_objects[objId];
|
Object *obj = &_vm->_object->_objects[objId];
|
||||||
int16 x, y;
|
int16 x, y;
|
||||||
switch (obj->_viewx) { // Where to walk to
|
switch (obj->_viewx) { // Where to walk to
|
||||||
case -1: // Walk to object position
|
case -1: { // Walk to object position
|
||||||
|
bool foundFl = false;
|
||||||
if (_vm->_object->findObjectSpace(obj, &x, &y))
|
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
|
if (!foundFl) // Can't get there, try to use from here
|
||||||
_vm->_object->useObject(objId);
|
_vm->_object->useObject(objId);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0: // Immediate use
|
case 0: // Immediate use
|
||||||
_vm->_object->useObject(objId); // Pick up or use object
|
_vm->_object->useObject(objId); // Pick up or use object
|
||||||
|
@ -134,19 +134,19 @@ void ObjectHandler::restoreSeq(Object *obj) {
|
|||||||
void ObjectHandler::useObject(int16 objId) {
|
void ObjectHandler::useObject(int16 objId) {
|
||||||
debugC(1, kDebugObject, "useObject(%d)", objId);
|
debugC(1, kDebugObject, "useObject(%d)", objId);
|
||||||
|
|
||||||
const char *verb; // Background verb to use directly
|
|
||||||
int16 inventObjId = _vm->_inventory->getInventoryObjId();
|
int16 inventObjId = _vm->_inventory->getInventoryObjId();
|
||||||
Object *obj = &_objects[objId]; // Ptr to object
|
Object *obj = &_objects[objId]; // Ptr to object
|
||||||
if (inventObjId == -1) {
|
if (inventObjId == -1) {
|
||||||
|
const char *verb; // Background verb to use directly
|
||||||
// Get or use objid directly
|
// Get or use objid directly
|
||||||
if ((obj->_genericCmd & TAKE) || obj->_objValue) // Get collectible item
|
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));
|
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));
|
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)
|
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));
|
sprintf(_vm->_line, "%s %s", verb, _vm->_text->getNoun(obj->_nounIndex, 0));
|
||||||
else
|
else
|
||||||
return; // Can't use object directly
|
return; // Can't use object directly
|
||||||
} else {
|
} else {
|
||||||
// Use status.objid on objid
|
// Use status.objid on objid
|
||||||
// Default to first cmd verb
|
// Default to first cmd verb
|
||||||
@ -540,10 +540,8 @@ void ObjectHandler::setCarriedScreen(int screenNum) {
|
|||||||
* Load _numObj from Hugo.dat
|
* Load _numObj from Hugo.dat
|
||||||
*/
|
*/
|
||||||
void ObjectHandler::loadNumObj(Common::ReadStream &in) {
|
void ObjectHandler::loadNumObj(Common::ReadStream &in) {
|
||||||
int numElem;
|
|
||||||
|
|
||||||
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
||||||
numElem = in.readUint16BE();
|
int numElem = in.readUint16BE();
|
||||||
if (varnt == _vm->_gameVariant)
|
if (varnt == _vm->_gameVariant)
|
||||||
_numObj = numElem;
|
_numObj = numElem;
|
||||||
}
|
}
|
||||||
|
@ -384,9 +384,9 @@ bool Route::findRoute(const int16 cx, const int16 cy) {
|
|||||||
_segment[_segmentNumb]._x2 = herox2;
|
_segment[_segmentNumb]._x2 = herox2;
|
||||||
_segmentNumb++;
|
_segmentNumb++;
|
||||||
|
|
||||||
Common::Point *routeNode; // Ptr to route node
|
|
||||||
// Look in segments[] for straight lines from destination to hero
|
// Look in segments[] for straight lines from destination to hero
|
||||||
for (i = 0, _routeListIndex = 0; i < _segmentNumb - 1; i++) {
|
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
|
if ((routeNode = newNode()) == 0) // New node for new segment
|
||||||
return false; // Too many nodes
|
return false; // Too many nodes
|
||||||
routeNode->y = _segment[i]._y;
|
routeNode->y = _segment[i]._y;
|
||||||
@ -438,7 +438,7 @@ bool Route::findRoute(const int16 cx, const int16 cy) {
|
|||||||
void Route::processRoute() {
|
void Route::processRoute() {
|
||||||
debugC(1, kDebugRoute, "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)
|
if (_routeIndex < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -254,9 +254,8 @@ void Scheduler::waitForRefresh() {
|
|||||||
void Scheduler::loadAlNewscrIndex(Common::ReadStream &in) {
|
void Scheduler::loadAlNewscrIndex(Common::ReadStream &in) {
|
||||||
debugC(6, kDebugSchedule, "loadAlNewscrIndex(&in)");
|
debugC(6, kDebugSchedule, "loadAlNewscrIndex(&in)");
|
||||||
|
|
||||||
int numElem;
|
|
||||||
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
||||||
numElem = in.readUint16BE();
|
int numElem = in.readUint16BE();
|
||||||
if (varnt == _vm->_gameVariant)
|
if (varnt == _vm->_gameVariant)
|
||||||
_alNewscrIndex = numElem;
|
_alNewscrIndex = numElem;
|
||||||
}
|
}
|
||||||
@ -568,9 +567,9 @@ void Scheduler::loadActListArr(Common::ReadStream &in) {
|
|||||||
|
|
||||||
Act tmpAct;
|
Act tmpAct;
|
||||||
|
|
||||||
int numElem, numSubElem;
|
int numSubElem;
|
||||||
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
||||||
numElem = in.readUint16BE();
|
int numElem = in.readUint16BE();
|
||||||
if (varnt == _vm->_gameVariant) {
|
if (varnt == _vm->_gameVariant) {
|
||||||
_actListArrSize = numElem;
|
_actListArrSize = numElem;
|
||||||
_actListArr = (Act **)malloc(sizeof(Act *) * _actListArrSize);
|
_actListArr = (Act **)malloc(sizeof(Act *) * _actListArrSize);
|
||||||
@ -1214,8 +1213,6 @@ Event *Scheduler::doAction(Event *curEvent) {
|
|||||||
Act *action = curEvent->_action;
|
Act *action = curEvent->_action;
|
||||||
Object *obj1;
|
Object *obj1;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
Event *wrkEvent; // Save ev_p->nextEvent for return
|
|
||||||
|
|
||||||
switch (action->_a0._actType) {
|
switch (action->_a0._actType) {
|
||||||
case ANULL: // Big NOP from DEL_EVENTS
|
case ANULL: // Big NOP from DEL_EVENTS
|
||||||
break;
|
break;
|
||||||
@ -1444,7 +1441,7 @@ Event *Scheduler::doAction(Event *curEvent) {
|
|||||||
if (action->_a0._actType == NEW_SCREEN) { // New_screen() deletes entire list
|
if (action->_a0._actType == NEW_SCREEN) { // New_screen() deletes entire list
|
||||||
return nullptr; // nextEvent = nullptr since list now empty
|
return nullptr; // nextEvent = nullptr since list now empty
|
||||||
} else {
|
} else {
|
||||||
wrkEvent = curEvent->_nextEvent;
|
Event *wrkEvent = curEvent->_nextEvent;
|
||||||
delQueue(curEvent); // Return event to free list
|
delQueue(curEvent); // Return event to free list
|
||||||
return wrkEvent; // Return next event ptr
|
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]));
|
debug(1, "doAction(act3), expecting answer %s", _vm->_file->fetchString(action->_a3._responsePtr[0]));
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
const char *tmpStr; // General purpose string ptr
|
|
||||||
|
|
||||||
for (int dx = 0; !found && (action->_a3._responsePtr[dx] != -1); dx++) {
|
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))
|
if (response.contains(tmpStr))
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
@ -91,16 +91,14 @@ char **TextHandler::getVerbArray(int idx1) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char **TextHandler::loadTextsVariante(Common::ReadStream &in, uint16 *arraySize) {
|
char **TextHandler::loadTextsVariante(Common::ReadStream &in, uint16 *arraySize) {
|
||||||
int numTexts;
|
|
||||||
int entryLen;
|
|
||||||
int len;
|
int len;
|
||||||
char **res = nullptr;
|
char **res = nullptr;
|
||||||
char *pos = nullptr;
|
char *pos = nullptr;
|
||||||
char *posBck = nullptr;
|
char *posBck = nullptr;
|
||||||
|
|
||||||
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
for (int varnt = 0; varnt < _vm->_numVariant; varnt++) {
|
||||||
numTexts = in.readUint16BE();
|
int numTexts = in.readUint16BE();
|
||||||
entryLen = in.readUint16BE();
|
int entryLen = in.readUint16BE();
|
||||||
pos = (char *)malloc(entryLen);
|
pos = (char *)malloc(entryLen);
|
||||||
if (varnt == _vm->_gameVariant) {
|
if (varnt == _vm->_gameVariant) {
|
||||||
if (arraySize)
|
if (arraySize)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user