From f6c61962952b2d51d19177d42a92855b07d33178 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 10 Jan 2006 21:39:14 +0000 Subject: [PATCH] Get rid of unused variables and removed them from the save data ; FloodFill.unk1C and _curExecScript. Concerning _curExecScript, I checked several interpreters (even one with windex compiled in), the only function where it's used is runAllScripts. svn-id: r19977 --- scumm/actor.cpp | 6 +++--- scumm/floodfill_he.h | 1 - scumm/resource_v7he.cpp | 4 ++-- scumm/saveload.cpp | 4 ++-- scumm/saveload.h | 2 +- scumm/script.cpp | 10 +++------- scumm/script_v100he.cpp | 2 +- scumm/script_v90he.cpp | 2 +- scumm/scumm.cpp | 1 - scumm/scumm.h | 1 - 10 files changed, 13 insertions(+), 20 deletions(-) diff --git a/scumm/actor.cpp b/scumm/actor.cpp index 69639d76648..5f459cec8e5 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -912,7 +912,7 @@ void ScummEngine::playActorSounds() { Actor *ScummEngine::derefActor(int id, const char *errmsg) const { if (id == 0) debugC(DEBUG_ACTORS, "derefActor(0, \"%s\") in script %d, opcode 0x%x", - errmsg, vm.slot[_curExecScript].number, _opcode); + errmsg, vm.slot[_currentScript].number, _opcode); if (id < 0 || id >= _numActors || _actors[id]._number != id) { if (errmsg) @@ -926,11 +926,11 @@ Actor *ScummEngine::derefActor(int id, const char *errmsg) const { Actor *ScummEngine::derefActorSafe(int id, const char *errmsg) const { if (id == 0) debugC(DEBUG_ACTORS, "derefActorSafe(0, \"%s\") in script %d, opcode 0x%x", - errmsg, vm.slot[_curExecScript].number, _opcode); + errmsg, vm.slot[_currentScript].number, _opcode); if (id < 0 || id >= _numActors || _actors[id]._number != id) { debugC(DEBUG_ACTORS, "Invalid actor %d in %s (script %d, opcode 0x%x)", - id, errmsg, vm.slot[_curExecScript].number, _opcode); + id, errmsg, vm.slot[_currentScript].number, _opcode); return NULL; } return &_actors[id]; diff --git a/scumm/floodfill_he.h b/scumm/floodfill_he.h index 0023cd2a15e..75d83bc7a0a 100644 --- a/scumm/floodfill_he.h +++ b/scumm/floodfill_he.h @@ -32,7 +32,6 @@ struct FloodFillParameters { int32 x; int32 y; int32 flags; - int32 unk1C; /* unused */ }; struct FloodFillLine { diff --git a/scumm/resource_v7he.cpp b/scumm/resource_v7he.cpp index 7b278660589..edef2ac5cc0 100644 --- a/scumm/resource_v7he.cpp +++ b/scumm/resource_v7he.cpp @@ -37,8 +37,8 @@ namespace Scumm { -ResExtractor::ResExtractor(ScummEngine_v70he *scumm) { - _vm = scumm; +ResExtractor::ResExtractor(ScummEngine_v70he *scumm) + : _vm(scumm) { _fileName[0] = 0; memset(_cursorCache, 0, sizeof(_cursorCache)); diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 34f423c9cec..637d99cddbb 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -701,7 +701,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { MKARRAY_OLD(ScummEngine, _charsetData[0][0], sleByte, 10 * 16, VER(8), VER(9)), MKARRAY(ScummEngine, _charsetData[0][0], sleByte, 15 * 16, VER(10)), - MKLINE(ScummEngine, _curExecScript, sleUint16, VER(8)), + MK_OBSOLETE(ScummEngine, _curExecScript, sleUint16, VER(8), VER(62)), MKLINE(ScummEngine, camera._dest.x, sleInt16, VER(8)), MKLINE(ScummEngine, camera._dest.y, sleInt16, VER(8)), @@ -1280,7 +1280,7 @@ void ScummEngine_v90he::saveOrLoad(Serializer *s) { MKLINE(FloodFillParameters, x, sleInt32, VER(51)), MKLINE(FloodFillParameters, y, sleInt32, VER(51)), MKLINE(FloodFillParameters, flags, sleInt32, VER(51)), - MKLINE(FloodFillParameters, unk1C, sleInt32, VER(51)), + MK_OBSOLETE(FloodFillParameters, unk1C, sleInt32, VER(51), VER(62)), MKEND() }; diff --git a/scumm/saveload.h b/scumm/saveload.h index 3b10c874654..2cc4a2074a6 100644 --- a/scumm/saveload.h +++ b/scumm/saveload.h @@ -45,7 +45,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 62 +#define CURRENT_VER 63 /** * An auxillary macro, used to specify savegame versions. We use this instead diff --git a/scumm/script.cpp b/scumm/script.cpp index 239acf4e864..534d34074ee 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -889,17 +889,13 @@ void ScummEngine::runAllScripts() { for (i = 0; i < NUM_SCRIPT_SLOT; i++) vm.slot[i].didexec = 0; - // FIXME - why is _curExecScript?!? The only place it is ever set is here. - // The outer world will only see it as consequence of the calls made in the following - // for loop. But in that case, _curExecScript will be equal to _currentScript. Hence - // it would seem we can replace all occurances of _curExecScript by _currentScript. _currentScript = 0xFF; int numCycles = (_heversion >= 90) ? VAR(VAR_NUM_SCRIPT_CYCLES) : 1; for (int cycle = 1; cycle <= numCycles; cycle++) { - for (_curExecScript = 0; _curExecScript < NUM_SCRIPT_SLOT; _curExecScript++) { - if (vm.slot[_curExecScript].cycle == cycle && vm.slot[_curExecScript].status == ssRunning && vm.slot[_curExecScript].didexec == 0) { - _currentScript = (byte)_curExecScript; + for (i = 0; i < NUM_SCRIPT_SLOT; i++) { + if (vm.slot[i].cycle == cycle && vm.slot[i].status == ssRunning && vm.slot[i].didexec == 0) { + _currentScript = (byte)i; getScriptBaseAddress(); getScriptEntryPoint(); executeScript(); diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp index 0b2f1f8e653..3a1d64f49ec 100644 --- a/scumm/script_v100he.cpp +++ b/scumm/script_v100he.cpp @@ -887,7 +887,7 @@ void ScummEngine_v100he::o100_floodFill() { _floodFillParams.flags = pop(); break; case 67: - _floodFillParams.unk1C = pop(); + pop(); break; case 92: floodFill(&_floodFillParams, this); diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp index 2f2a01abe0e..691e2dd01c9 100644 --- a/scumm/script_v90he.cpp +++ b/scumm/script_v90he.cpp @@ -1767,7 +1767,7 @@ void ScummEngine_v90he::o90_floodFill() { switch (subOp) { case 0: - _floodFillParams.unk1C = pop(); + pop(); break; case 3: memset(&_floodFillParams, 0, sizeof(_floodFillParams)); diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index e04399fb36d..395763e1ef6 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -1104,7 +1104,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS _scriptOrgPointer = NULL; _opcode = 0; vm.numNestedScripts = 0; - _curExecScript = 0; _lastCodePtr = NULL; _resultVarNumber = 0; _scummStackPos = 0; diff --git a/scumm/scumm.h b/scumm/scumm.h index 091f90d8289..ca370a5b3cf 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -616,7 +616,6 @@ protected: uint32 _localScriptOffsets[1024]; const byte *_scriptPointer, *_scriptOrgPointer; byte _opcode, _currentScript; - uint16 _curExecScript; const byte * const *_lastCodePtr; int _resultVarNumber, _scummStackPos; int _vmStack[150];