diff options
author | Max Horn | 2006-12-25 15:03:36 +0000 |
---|---|---|
committer | Max Horn | 2006-12-25 15:03:36 +0000 |
commit | 4ce7b7408584bd12989e4d309f9280bf4222c44f (patch) | |
tree | a0883269bcbbb68735d6a4c9fbc882deb5e031fa /engines/scumm | |
parent | d1f0ca423c600f213e9d67d425880ca9436bf6a0 (diff) | |
download | scummvm-rg350-4ce7b7408584bd12989e4d309f9280bf4222c44f.tar.gz scummvm-rg350-4ce7b7408584bd12989e4d309f9280bf4222c44f.tar.bz2 scummvm-rg350-4ce7b7408584bd12989e4d309f9280bf4222c44f.zip |
Changed ScummEngine::_actors from an Actor array to a an array of Actor points (i.e. indirection)
svn-id: r24922
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/actor.cpp | 80 | ||||
-rw-r--r-- | engines/scumm/camera.cpp | 4 | ||||
-rw-r--r-- | engines/scumm/debugger.cpp | 6 | ||||
-rw-r--r-- | engines/scumm/object.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/room.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/saveload.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 25 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 2 |
8 files changed, 63 insertions, 60 deletions
diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 1e2a3b504d..63b0a8d7fc 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -199,11 +199,11 @@ void ScummEngine::walkActors() { int i; for (i = 1; i < _numActors; i++) { - if (_actors[i].isInCurrentRoom()) + if (_actors[i]->isInCurrentRoom()) if (_game.version <= 3) - _actors[i].walkActorOld(); + _actors[i]->walkActorOld(); else - _actors[i].walkActor(); + _actors[i]->walkActor(); } } @@ -871,7 +871,7 @@ void ScummEngine::putActors() { int i; for (i = 1; i < _numActors; i++) { - a = &_actors[i]; + a = _actors[i]; if (a && a->isInCurrentRoom()) a->putActor(); } @@ -1051,7 +1051,7 @@ int ScummEngine::getActorFromPos(int x, int y) { for (i = 1; i < _numActors; i++) { if (testGfxUsageBit(x / 8, i) && !getClass(i, kObjectClassUntouchable) - && y >= _actors[i]._top && y <= _actors[i]._bottom) { + && y >= _actors[i]->_top && y <= _actors[i]->_bottom) { if (_game.version > 2 || i != VAR(VAR_EGO)) return i; } @@ -1070,8 +1070,8 @@ int ScummEngine_v70he::getActorFromPos(int x, int y) { curActor = 0; for (i = 1; i < _numActors; i++) { if (testGfxUsageBit(x / 8, i) && !getClass(i, kObjectClassUntouchable) - && y >= _actors[i]._top && y <= _actors[i]._bottom - && (_actors[i].getPos().y > _actors[curActor].getPos().y || curActor == 0)) + && y >= _actors[i]->_top && y <= _actors[i]->_bottom + && (_actors[i]->getPos().y > _actors[curActor]->getPos().y || curActor == 0)) curActor = i; } @@ -1129,8 +1129,8 @@ void ScummEngine::showActors() { int i; for (i = 1; i < _numActors; i++) { - if (_actors[i].isInCurrentRoom()) - _actors[i].showActor(); + if (_actors[i]->isInCurrentRoom()) + _actors[i]->showActor(); } } @@ -1139,11 +1139,11 @@ void ScummEngine::playActorSounds() { int i; for (i = 1; i < _numActors; i++) { - if (_actors[i]._cost.soundCounter && _actors[i].isInCurrentRoom() && _actors[i]._sound) { + if (_actors[i]->_cost.soundCounter && _actors[i]->isInCurrentRoom() && _actors[i]->_sound) { _currentScript = 0xFF; - _sound->addSoundToQueue(_actors[i]._sound[0]); + _sound->addSoundToQueue(_actors[i]->_sound[0]); for (i = 1; i < _numActors; i++) { - _actors[i]._cost.soundCounter = 0; + _actors[i]->_cost.soundCounter = 0; } return; } @@ -1151,7 +1151,7 @@ void ScummEngine::playActorSounds() { } bool ScummEngine::isValidActor(int id) const { - return id >= 0 && id < _numActors && _actors[id]._number == id; + return id >= 0 && id < _numActors && _actors[id]->_number == id; } Actor *ScummEngine::derefActor(int id, const char *errmsg) const { @@ -1165,7 +1165,7 @@ Actor *ScummEngine::derefActor(int id, const char *errmsg) const { else error("Invalid actor %d", id); } - return &_actors[id]; + return _actors[id]; } Actor *ScummEngine::derefActorSafe(int id, const char *errmsg) const { @@ -1178,7 +1178,7 @@ Actor *ScummEngine::derefActorSafe(int id, const char *errmsg) const { id, errmsg, vm.slot[_currentScript].number, _opcode); return NULL; } - return &_actors[id]; + return _actors[id]; } @@ -1192,10 +1192,10 @@ void ScummEngine::processActors() { // Make a list of all actors in this room for (int i = 1; i < _numActors; i++) { - if (_game.version == 8 && _actors[i]._layer < 0) + if (_game.version == 8 && _actors[i]->_layer < 0) continue; - if (_actors[i].isInCurrentRoom()) { - _sortedActors[numactors++] = &_actors[i]; + if (_actors[i]->isInCurrentRoom()) { + _sortedActors[numactors++] = _actors[i]; } } if (!numactors) { @@ -1304,9 +1304,9 @@ void ScummEngine::processUpperActors() { int i; for (i = 1; i < _numActors; i++) { - if (_actors[i].isInCurrentRoom() && _actors[i]._costume && _actors[i]._layer < 0) { - _actors[i].drawActorCostume(); - _actors[i].animateCostume(); + if (_actors[i]->isInCurrentRoom() && _actors[i]->_costume && _actors[i]->_layer < 0) { + _actors[i]->drawActorCostume(); + _actors[i]->animateCostume(); } } } @@ -1602,11 +1602,11 @@ void Actor::animateLimb(int limb, int f) { #endif void ScummEngine::redrawAllActors() { - int j; + int i; - for (j = 1; j < _numActors; j++) { - _actors[j]._needRedraw = true; - _actors[j]._needBgReset = true; + for (i = 1; i < _numActors; ++i) { + _actors[i]->_needRedraw = true; + _actors[i]->_needBgReset = true; } } @@ -1617,7 +1617,7 @@ void ScummEngine::setActorRedrawFlags() { // Also redraw all actors in COMI (see bug #1066329 for details). if (_fullRedraw || _game.version == 8 || (VAR_REDRAW_ALL_ACTORS != 0xFF && VAR(VAR_REDRAW_ALL_ACTORS) != 0)) { for (j = 1; j < _numActors; j++) { - _actors[j]._needRedraw = true; + _actors[j]->_needRedraw = true; } } else { for (i = 0; i < _gdi->_numStrips; i++) { @@ -1625,7 +1625,7 @@ void ScummEngine::setActorRedrawFlags() { if (testGfxAnyUsageBits(strip)) { for (j = 1; j < _numActors; j++) { if (testGfxUsageBit(strip, j) && testGfxOtherUsageBits(strip, j)) { - _actors[j]._needRedraw = true; + _actors[j]->_needRedraw = true; } } } @@ -1641,20 +1641,20 @@ void ScummEngine::resetActorBgs() { clearGfxUsageBit(strip, USAGE_BIT_DIRTY); clearGfxUsageBit(strip, USAGE_BIT_RESTORED); for (j = 1; j < _numActors; j++) { - if (_actors[j]._heFlags & 1) + if (_actors[j]->_heFlags & 1) continue; if (testGfxUsageBit(strip, j) && - ((_actors[j]._top != 0x7fffffff && _actors[j]._needRedraw) || _actors[j]._needBgReset)) { + ((_actors[j]->_top != 0x7fffffff && _actors[j]->_needRedraw) || _actors[j]->_needBgReset)) { clearGfxUsageBit(strip, j); - if ((_actors[j]._bottom - _actors[j]._top) >= 0) - _gdi->resetBackground(_actors[j]._top, _actors[j]._bottom, i); + if ((_actors[j]->_bottom - _actors[j]->_top) >= 0) + _gdi->resetBackground(_actors[j]->_top, _actors[j]->_bottom, i); } } } for (i = 1; i < _numActors; i++) { - _actors[i]._needBgReset = false; + _actors[i]->_needBgReset = false; } } @@ -1697,14 +1697,14 @@ int ScummEngine::getTalkingActor() { return VAR(VAR_TALK_ACTOR); } -void ScummEngine::setTalkingActor(int value) { +void ScummEngine::setTalkingActor(int i) { - if (value == 255) { + if (i == 255) { _system->clearFocusRectangle(); } else { // Work out the screen co-ordinates of the actor - int x = _actors[value].getPos().x - (camera._cur.x - (_screenWidth >> 1)); - int y = _actors[value]._top - (camera._cur.y - (_screenHeight >> 1)); + int x = _actors[i]->getPos().x - (camera._cur.x - (_screenWidth >> 1)); + int y = _actors[i]->_top - (camera._cur.y - (_screenHeight >> 1)); // Set the focus area to the calculated position // TODO: Make the size adjust depending on what it's focusing on. @@ -1713,9 +1713,9 @@ void ScummEngine::setTalkingActor(int value) { } if (_game.id == GID_MANIAC && _game.version <= 1 && !(_game.platform == Common::kPlatformNES)) - _V1TalkingActor = value; + _V1TalkingActor = i; else - VAR(VAR_TALK_ACTOR) = value; + VAR(VAR_TALK_ACTOR) = i; } static const int c64MMActorTalkColor[25] = { @@ -1730,9 +1730,9 @@ void ScummEngine::resetV1ActorTalkColor() { for (i = 1; i < _numActors; i++) { if (_game.platform == Common::kPlatformC64) { - _actors[i]._talkColor = c64MMActorTalkColor[i]; + _actors[i]->_talkColor = c64MMActorTalkColor[i]; } else { - _actors[i]._talkColor = v1MMActorTalkColor[i]; + _actors[i]->_talkColor = v1MMActorTalkColor[i]; } } } diff --git a/engines/scumm/camera.cpp b/engines/scumm/camera.cpp index e3f0396ea6..52fbac01c5 100644 --- a/engines/scumm/camera.cpp +++ b/engines/scumm/camera.cpp @@ -79,8 +79,8 @@ void ScummEngine::setCameraFollows(Actor *a, bool setCamera) { setCameraAt(a->getPos().x, 0); for (i = 1; i < _numActors; i++) { - if (_actors[i].isInCurrentRoom()) - _actors[i]._needRedraw = true; + if (_actors[i]->isInCurrentRoom()) + _actors[i]->_needRedraw = true; } runInventoryScript(0); } diff --git a/engines/scumm/debugger.cpp b/engines/scumm/debugger.cpp index 6ca16821e4..a7637c6970 100644 --- a/engines/scumm/debugger.cpp +++ b/engines/scumm/debugger.cpp @@ -189,7 +189,7 @@ bool ScummDebugger::Cmd_IMuse(int argc, const char **argv) { bool ScummDebugger::Cmd_Room(int argc, const char **argv) { if (argc > 1) { int room = atoi(argv[1]); - _vm->_actors[_vm->VAR(_vm->VAR_EGO)]._room = room; + _vm->_actors[_vm->VAR(_vm->VAR_EGO)]->_room = room; _vm->_sound->stopAllSounds(); _vm->startScene(room, 0, 0); _vm->_fullRedraw = true; @@ -367,7 +367,7 @@ bool ScummDebugger::Cmd_Actor(int argc, const char **argv) { return true; } - a = &_vm->_actors[actnum]; + a = _vm->_actors[actnum]; if (argc > 3) value = atoi(argv[3]); if (argc > 4) @@ -424,7 +424,7 @@ bool ScummDebugger::Cmd_PrintActor(int argc, const char **argv) { DebugPrintf("|# | x | y | w |elev|cos|box|mov| zp|frm|scl|dir| cls |\n"); DebugPrintf("+--+----+----+---+----+---+---+---+---+---+---+---+---------+\n"); for (i = 1; i < _vm->_numActors; i++) { - a = &_vm->_actors[i]; + a = _vm->_actors[i]; if (a->_visible) DebugPrintf("|%2d|%4d|%4d|%3d|%4d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|$%08x|\n", a->_number, a->getPos().x, a->getPos().y, a->_width, a->getElevation(), diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index e3afdec0de..4a48c44467 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -249,7 +249,7 @@ void ScummEngine::putClass(int obj, int cls, bool set) { _classData[obj] &= ~(1 << (cls - 1)); if (_game.version <= 4 && obj >= 1 && obj < _numActors) { - _actors[obj].classChanged(cls, set); + _actors[obj]->classChanged(cls, set); } } diff --git a/engines/scumm/room.cpp b/engines/scumm/room.cpp index a98547dca3..1ac12e39d3 100644 --- a/engines/scumm/room.cpp +++ b/engines/scumm/room.cpp @@ -96,7 +96,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) { nukeArrays(0xFF); for (i = 1; i < _numActors; i++) { - _actors[i].hideActor(); + _actors[i]->hideActor(); } if (_game.version >= 7) { diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index d47701c0ee..2720a95ab4 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -934,7 +934,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { // Save/load actors // for (i = 0; i < _numActors; i++) - _actors[i].saveLoadWithSerializer(s); + _actors[i]->saveLoadWithSerializer(s); // diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index dd60877827..c71e78d509 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -512,6 +512,8 @@ ScummEngine::~ScummEngine() { _mixer->stopAll(); + for (int i = 0; i < _numActors; ++i) + delete _actors[i]; delete [] _actors; delete [] _sortedActors; @@ -1241,15 +1243,16 @@ void ScummEngine::resetScumm() { // Allocate and Initialize actors Actor::initActorClass(this); - _actors = new Actor[_numActors]; + _actors = new Actor * [_numActors]; _sortedActors = new Actor * [_numActors]; - for (i = 0; i < _numActors; i++) { - _actors[i]._number = i; - _actors[i].initActor(1); + for (i = 0; i < _numActors; ++i) { + _actors[i] = new Actor(); + _actors[i]->_number = i; + _actors[i]->initActor(1); // this is from IDB if ((_game.version <= 1) || (_game.id == GID_MANIAC && (_game.features & GF_DEMO))) - _actors[i].setActorCostume(i); + _actors[i]->setActorCostume(i); } if (_game.id == GID_MANIAC && _game.version <= 1) { @@ -1257,12 +1260,12 @@ void ScummEngine::resetScumm() { } else if (_game.id == GID_MANIAC && _game.version == 2 && (_game.features & GF_DEMO)) { // HACK Some palette changes needed for demo script // in Maniac Mansion (Enhanced) - _actors[3].setPalette(3, 1); - _actors[9]._talkColor = 15; - _actors[10]._talkColor = 7; - _actors[11]._talkColor = 2; - _actors[13]._talkColor = 5; - _actors[23]._talkColor = 14; + _actors[3]->setPalette(3, 1); + _actors[9]->_talkColor = 15; + _actors[10]->_talkColor = 7; + _actors[11]->_talkColor = 2; + _actors[13]->_talkColor = 5; + _actors[23]->_talkColor = 14; } vm.numNestedScripts = 0; diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index a1c36b47f0..3fd614edce 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -527,7 +527,7 @@ protected: byte _fastMode; byte _numActors; - Actor *_actors; // Has _numActors elements + Actor **_actors; // Has _numActors elements Actor **_sortedActors; byte *_arraySlot; |