diff options
-rw-r--r-- | actor.cpp | 82 | ||||
-rw-r--r-- | actor.h | 12 | ||||
-rw-r--r-- | script_v1.cpp | 10 | ||||
-rw-r--r-- | script_v2.cpp | 10 | ||||
-rw-r--r-- | scumm.h | 1 | ||||
-rw-r--r-- | scummvm.cpp | 6 |
6 files changed, 65 insertions, 56 deletions
@@ -271,7 +271,7 @@ int Actor::updateActorDirection() return dir; } -void Actor::setActorBox(int box) +void Actor::setBox(int box) { walkbox = box; mask = _vm->getMaskFromBox(box); @@ -302,7 +302,7 @@ int Actor::actorWalkStep() actorY = y; if (walkbox != walkdata.curbox && _vm->checkXYInBoxBounds(walkdata.curbox, actorX, actorY)) { - setActorBox(walkdata.curbox); + setBox(walkdata.curbox); } distX = abs(walkdata.newx - walkdata.x); @@ -478,7 +478,7 @@ void Actor::animateActor(int anim) break; case 3: moving &= ~MF_TURN; - setActorDirection(dir); + setDirection(dir); break; case 4: turnToDirection(dir); @@ -488,7 +488,7 @@ void Actor::animateActor(int anim) } } -void Actor::setActorDirection(int direction) +void Actor::setDirection(int direction) { uint aMask; int i; @@ -517,35 +517,35 @@ void Actor::setActorDirection(int direction) needBgReset = true; } -void Scumm::putActor(Actor *a, int dstX, int dstY, byte room) +void Actor::putActor(int dstX, int dstY, byte newRoom) { - if (a->visible && _currentRoom != room && _vars[VAR_TALK_ACTOR] == a->number) { - clearMsgQueue(); + if (visible && _vm->_currentRoom != newRoom && _vm->_vars[_vm->VAR_TALK_ACTOR] == number) { + _vm->clearMsgQueue(); } - a->x = dstX; - a->y = dstY; - a->room = room; - a->needRedraw = true; - a->needBgReset = true; + x = dstX; + y = dstY; + room = newRoom; + needRedraw = true; + needBgReset = true; - if (_vars[VAR_EGO] == a->number) { - _egoPositioned = true; + if (_vm->_vars[_vm->VAR_EGO] == number) { + _vm->_egoPositioned = true; } - if (a->visible) { - if (a->isInCurrentRoom()) { - if (a->moving) { - a->startAnimActor(a->standFrame); - a->moving = 0; + if (visible) { + if (isInCurrentRoom()) { + if (moving) { + startAnimActor(standFrame); + moving = 0; } - a->adjustActorPos(); + adjustActorPos(); } else { - a->hideActor(); + hideActor(); } } else { - if (a->isInCurrentRoom()) - a->showActor(); + if (isInCurrentRoom()) + showActor(); } } @@ -606,13 +606,15 @@ AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom) if (i == -1) continue; - // FIXME - we check here if the box suggested by getPathToDestBox - // is locked or not. This prevents us from walking thru - // closed doors in some cases in Zak256. However a better fix - // would be to recompute the box matrix whenever flags change. - flags = _vm->getBoxFlags(i); - if (flags & 0x80 && (!(flags & 0x20) || isInClass(0x1F))) - continue; + if (_vm->_features & GF_OLD256) { + // FIXME - we check here if the box suggested by getPathToDestBox + // is locked or not. This prevents us from walking thru + // closed doors in some cases in Zak256. However a better fix + // would be to recompute the box matrix whenever flags change. + flags = _vm->getBoxFlags(i); + if (flags & 0x80 && (!(flags & 0x20) || isInClass(0x1F))) + continue; + } } if (!_vm->inBoxQuickReject(j, dstX, dstY, threshold)) @@ -663,7 +665,7 @@ void Actor::adjustActorPos() y = abr.y; walkdata.destbox = (byte)abr.dist; - setActorBox(abr.dist); + setBox(abr.dist); walkdata.destx = -1; @@ -1077,7 +1079,7 @@ void Actor::startWalkActor(int destX, int destY, int dir) x = abr.x; y = abr.y; if (dir != -1) - setActorDirection(dir); + setDirection(dir); return; } @@ -1130,11 +1132,11 @@ void Actor::startWalkAnim(int cmd, int angle) } else*/ { switch (cmd) { case 1: /* start walk */ - setActorDirection(angle); + setDirection(angle); startAnimActor(walkFrame); break; case 2: /* change dir only */ - setActorDirection(angle); + setDirection(angle); break; case 3: /* stop walk */ turnToDirection(angle); @@ -1157,7 +1159,7 @@ void Actor::walkActor() if (moving & MF_LAST_LEG) { moving = 0; - setActorBox(walkdata.destbox); + setBox(walkdata.destbox); startWalkAnim(3, walkdata.destdir); return; } @@ -1165,20 +1167,20 @@ void Actor::walkActor() if (moving & MF_TURN) { j = updateActorDirection(); if (facing != j) - setActorDirection(j); + setDirection(j); else moving = 0; return; } - setActorBox(walkdata.curbox); + setBox(walkdata.curbox); moving &= MF_IN_LEG; } do { moving &= ~MF_NEW_LEG; if ((!walkbox && (!(_vm->_features & GF_SMALL_HEADER)))) { - setActorBox(walkdata.destbox); + setBox(walkdata.destbox); walkdata.curbox = walkdata.destbox; break; } @@ -1197,7 +1199,7 @@ void Actor::walkActor() if (calcMovementFactor(_vm->_foundPathX, _vm->_foundPathY)) return; - setActorBox(walkdata.curbox); + setBox(walkdata.curbox); } while (1); moving |= MF_LAST_LEG; @@ -1277,7 +1279,7 @@ void Actor::walkActorOld() if (moving & MF_TURN) { new_dir = updateActorDirection(); if (facing != new_dir) { - setActorDirection(new_dir); + setDirection(new_dir); return; } moving = 0; @@ -119,22 +119,30 @@ public: void showActor(); void initActor(int mode); + void putActor(int x, int y, byte room); void setActorWalkSpeed(uint newSpeedX, uint newSpeedY); +protected: int calcMovementFactor(int newx, int newy); int actorWalkStep(); int remapDirection(int dir); void setupActorScale(); +public: void stopActorMoving(); void startWalkAnim(int cmd, int angle); void startAnimActor(int frame); - void setActorBox(int box); +protected: + void setBox(int box); int updateActorDirection(); - void setActorDirection(int direction); + +public: + void setDirection(int direction); int getActorXYPos(int &x, int &y); AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom); +protected: void adjustActorPos(); +public: void turnToDirection(int newdir); void walkActor(); void drawActorCostume(); diff --git a/script_v1.cpp b/script_v1.cpp index 03a21e591c..e9bea054e6 100644 --- a/script_v1.cpp +++ b/script_v1.cpp @@ -813,7 +813,7 @@ void Scumm::o5_actorSet() a->forceClip = 0; FixRoom: if (a->isInCurrentRoom()) - putActor(a, a->x, a->y, a->room); + a->putActor(a->x, a->y, a->room); break; case 21: /* followboxes */ a->ignoreBoxes = 0; @@ -1575,7 +1575,7 @@ void Scumm::o5_loadRoomWithEgo() a = derefActorSafe(_vars[VAR_EGO], "o5_loadRoomWithEgo"); /* Warning: used previously _xPos, _yPos from a previous update of those */ - putActor(a, a->x, a->y, room); + a->putActor(a->x, a->y, room); x = (int16)fetchScriptWord(); y = (int16)fetchScriptWord(); @@ -1726,7 +1726,7 @@ void Scumm::o5_putActor() x = getVarOrDirectWord(0x40); y = getVarOrDirectWord(0x20); - putActor(a, x, y, a->room); + a->putActor(x, y, a->room); } @@ -1743,7 +1743,7 @@ void Scumm::o5_putActorAtObject() x = 240; y = 120; } - putActor(a, x, y, a->room); + a->putActor(x, y, a->room); } void Scumm::o5_putActorInRoom() @@ -1758,7 +1758,7 @@ void Scumm::o5_putActorInRoom() } a->room = room; if (!room) - putActor(a, 0, 0, 0); + a->putActor(0, 0, 0); } void Scumm::o5_quitPauseRestart() diff --git a/script_v2.cpp b/script_v2.cpp index 784535092c..0d3d66b8e6 100644 --- a/script_v2.cpp +++ b/script_v2.cpp @@ -1393,7 +1393,7 @@ void Scumm::o6_putActorInRoom() if (room != 0) a->room = room; } - putActor(a, x, y, room); + a->putActor(x, y, room); } @@ -1413,7 +1413,7 @@ void Scumm::o6_putActorAtObject() } if (room == 0xFF) room = a->room; - putActor(a, x, y, room); + a->putActor(x, y, room); } void Scumm::o6_faceActor() @@ -1489,7 +1489,7 @@ void Scumm::o6_loadRoomWithEgo() a = derefActorSafe(_vars[VAR_EGO], "o_loadRoomWithEgo"); - putActor(a, 0, 0, room); + a->putActor(0, 0, room); _egoPositioned = false; _vars[VAR_WALKTO_OBJ] = obj; @@ -1997,7 +1997,7 @@ void Scumm::o6_actorSet() a->forceClip = 0; FixRooms:; if (a->isInCurrentRoom()) - putActor(a, a->x, a->y, a->room); + a->putActor(a->x, a->y, a->room); break; case 96: a->ignoreBoxes = 0; @@ -2045,7 +2045,7 @@ void Scumm::o6_actorSet() break; case 230: /* set direction */ a->moving &= ~MF_TURN; - a->setActorDirection(pop()); + a->setDirection(pop()); break; case 231: /* turn to direction */ a->turnToDirection(pop()); @@ -779,7 +779,6 @@ public: Actor *derefActor(int id); Actor *derefActorSafe(int id, const char *errmsg); Actor *getFirstActor() { return _actors; } - void putActor(Actor *a, int x, int y, byte room); void showActors(); uint32 *_classData; diff --git a/scummvm.cpp b/scummvm.cpp index d9b9a8cae9..4c8f9aa963 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -491,8 +491,8 @@ void Scumm::startScene(int room, Actor * a, int objectNr) _currentRoom); int x, y, dir; getObjectXYPos(objectNr, x, y, dir); - putActor(a, x, y, _currentRoom); - a->setActorDirection(dir + 180); + a->putActor(x, y, _currentRoom); + a->setDirection(dir + 180); a->moving = 0; } @@ -505,7 +505,7 @@ void Scumm::startScene(int room, Actor * a, int objectNr) if (a && !_egoPositioned) { int x, y; getObjectXYPos(objectNr, x, y); - putActor(a, x, y, _currentRoom); + a->putActor(x, y, _currentRoom); a->moving = 0; } } else { |