From 4922055063b0a72069ffdbbe9e95c5b11f47bd71 Mon Sep 17 00:00:00 2001 From: Tobias Gunkel Date: Fri, 10 Feb 2012 22:58:59 +0100 Subject: SCUMM: cleanup and separation of objIsActor()/objToActor()/actorToObj() for v0 and other engines --- engines/scumm/actor.cpp | 6 ------ engines/scumm/object.cpp | 33 ++++++++++++++++++--------------- engines/scumm/scumm.h | 6 +++--- engines/scumm/scumm_v0.h | 4 ++++ 4 files changed, 25 insertions(+), 24 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index 3989d0f803..9e1b91c338 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -657,15 +657,11 @@ void Actor_v2::walkActor() { if (_moving & MF_TURN) { new_dir = updateActorDirection(false); - if (_facing != new_dir) { - setDirection(new_dir); - } else { _moving = 0; } - return; } @@ -674,7 +670,6 @@ void Actor_v2::walkActor() { if (_moving & MF_IN_LEG) { actorWalkStep(); - } else { if (_moving & MF_LAST_LEG) { _moving = 0; @@ -1423,7 +1418,6 @@ void Actor::showActor() { _cost.reset(); - // 0x39DF a->_animFrameRepeat = 1; a->_speaking = 0; diff --git a/engines/scumm/object.cpp b/engines/scumm/object.cpp index e38552c8f3..399cd91324 100644 --- a/engines/scumm/object.cpp +++ b/engines/scumm/object.cpp @@ -437,8 +437,8 @@ void ScummEngine::getObjectXYPos(int object, int &x, int &y, int &dir) { x = od.walk_x; y = od.walk_y; } else { - x = od.x_pos + od.width/2; - y = od.y_pos + od.height/2; + x = od.x_pos + od.width / 2; + y = od.y_pos + od.height / 2; } x = x >> V12_X_SHIFT; y = y >> V12_Y_SHIFT; @@ -1488,26 +1488,29 @@ void ScummEngine::findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint id, } } -bool ScummEngine::objIsActor(int obj) { +bool ScummEngine_v0::objIsActor(int obj) { // object IDs < _numActors are used in v0 for objects too (e.g. hamster) - if (_game.version == 0) - return OBJECT_V0_TYPE(obj) == kObjectV0TypeActor; - else - return obj < _numActors; + return OBJECT_V0_TYPE(obj) == kObjectV0TypeActor; +} + +int ScummEngine_v0::objToActor(int obj) { + return OBJECT_V0_ID(obj); +} + +int ScummEngine_v0::actorToObj(int actor) { + return OBJECT_V0(actor, kObjectV0TypeActor); +} + +bool ScummEngine::objIsActor(int obj) { + return obj < _numActors; } int ScummEngine::objToActor(int obj) { - if (_game.version == 0) - return OBJECT_V0_ID(obj); - else - return obj; + return obj; } int ScummEngine::actorToObj(int actor) { - if (_game.version == 0) - return OBJECT_V0(actor, kObjectV0TypeActor); - else - return actor; + return actor; } int ScummEngine::getObjX(int obj) { diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index f67536d3ed..2f1e536f0a 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -800,9 +800,9 @@ protected: void setOwnerOf(int obj, int owner); void clearOwnerOf(int obj); int getObjectRoom(int obj) const; - bool objIsActor(int obj); - int objToActor(int obj); - int actorToObj(int actor); + virtual bool objIsActor(int obj); + virtual int objToActor(int obj); + virtual int actorToObj(int actor); int getObjX(int obj); int getObjY(int obj); void getObjectXYPos(int object, int &x, int &y) { int dir; getObjectXYPos(object, x, y, dir); } diff --git a/engines/scumm/scumm_v0.h b/engines/scumm/scumm_v0.h index 1341b9ed15..144dd701d4 100644 --- a/engines/scumm/scumm_v0.h +++ b/engines/scumm/scumm_v0.h @@ -81,6 +81,10 @@ protected: virtual void saveOrLoad(Serializer *s); + virtual bool objIsActor(int obj); + virtual int objToActor(int obj); + virtual int actorToObj(int actor); + // V0 MM Verb commands int getVerbPrepId(); int activeVerbPrep(); -- cgit v1.2.3