fix for #583166 (hoagie doesn't enter mansion correctly); moved putActor into class Actor
svn-id: r4587
This commit is contained in:
parent
4968bc7a21
commit
37921ed5b7
6 changed files with 65 additions and 56 deletions
68
actor.cpp
68
actor.cpp
|
@ -271,7 +271,7 @@ int Actor::updateActorDirection()
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::setActorBox(int box)
|
void Actor::setBox(int box)
|
||||||
{
|
{
|
||||||
walkbox = box;
|
walkbox = box;
|
||||||
mask = _vm->getMaskFromBox(box);
|
mask = _vm->getMaskFromBox(box);
|
||||||
|
@ -302,7 +302,7 @@ int Actor::actorWalkStep()
|
||||||
actorY = y;
|
actorY = y;
|
||||||
|
|
||||||
if (walkbox != walkdata.curbox && _vm->checkXYInBoxBounds(walkdata.curbox, actorX, actorY)) {
|
if (walkbox != walkdata.curbox && _vm->checkXYInBoxBounds(walkdata.curbox, actorX, actorY)) {
|
||||||
setActorBox(walkdata.curbox);
|
setBox(walkdata.curbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
distX = abs(walkdata.newx - walkdata.x);
|
distX = abs(walkdata.newx - walkdata.x);
|
||||||
|
@ -478,7 +478,7 @@ void Actor::animateActor(int anim)
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
moving &= ~MF_TURN;
|
moving &= ~MF_TURN;
|
||||||
setActorDirection(dir);
|
setDirection(dir);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
turnToDirection(dir);
|
turnToDirection(dir);
|
||||||
|
@ -488,7 +488,7 @@ void Actor::animateActor(int anim)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::setActorDirection(int direction)
|
void Actor::setDirection(int direction)
|
||||||
{
|
{
|
||||||
uint aMask;
|
uint aMask;
|
||||||
int i;
|
int i;
|
||||||
|
@ -517,35 +517,35 @@ void Actor::setActorDirection(int direction)
|
||||||
needBgReset = true;
|
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) {
|
if (visible && _vm->_currentRoom != newRoom && _vm->_vars[_vm->VAR_TALK_ACTOR] == number) {
|
||||||
clearMsgQueue();
|
_vm->clearMsgQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
a->x = dstX;
|
x = dstX;
|
||||||
a->y = dstY;
|
y = dstY;
|
||||||
a->room = room;
|
room = newRoom;
|
||||||
a->needRedraw = true;
|
needRedraw = true;
|
||||||
a->needBgReset = true;
|
needBgReset = true;
|
||||||
|
|
||||||
if (_vars[VAR_EGO] == a->number) {
|
if (_vm->_vars[_vm->VAR_EGO] == number) {
|
||||||
_egoPositioned = true;
|
_vm->_egoPositioned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a->visible) {
|
if (visible) {
|
||||||
if (a->isInCurrentRoom()) {
|
if (isInCurrentRoom()) {
|
||||||
if (a->moving) {
|
if (moving) {
|
||||||
a->startAnimActor(a->standFrame);
|
startAnimActor(standFrame);
|
||||||
a->moving = 0;
|
moving = 0;
|
||||||
}
|
}
|
||||||
a->adjustActorPos();
|
adjustActorPos();
|
||||||
} else {
|
} else {
|
||||||
a->hideActor();
|
hideActor();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (a->isInCurrentRoom())
|
if (isInCurrentRoom())
|
||||||
a->showActor();
|
showActor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,6 +606,7 @@ AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom)
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (_vm->_features & GF_OLD256) {
|
||||||
// FIXME - we check here if the box suggested by getPathToDestBox
|
// FIXME - we check here if the box suggested by getPathToDestBox
|
||||||
// is locked or not. This prevents us from walking thru
|
// is locked or not. This prevents us from walking thru
|
||||||
// closed doors in some cases in Zak256. However a better fix
|
// closed doors in some cases in Zak256. However a better fix
|
||||||
|
@ -614,6 +615,7 @@ AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom)
|
||||||
if (flags & 0x80 && (!(flags & 0x20) || isInClass(0x1F)))
|
if (flags & 0x80 && (!(flags & 0x20) || isInClass(0x1F)))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!_vm->inBoxQuickReject(j, dstX, dstY, threshold))
|
if (!_vm->inBoxQuickReject(j, dstX, dstY, threshold))
|
||||||
continue;
|
continue;
|
||||||
|
@ -663,7 +665,7 @@ void Actor::adjustActorPos()
|
||||||
y = abr.y;
|
y = abr.y;
|
||||||
walkdata.destbox = (byte)abr.dist;
|
walkdata.destbox = (byte)abr.dist;
|
||||||
|
|
||||||
setActorBox(abr.dist);
|
setBox(abr.dist);
|
||||||
|
|
||||||
walkdata.destx = -1;
|
walkdata.destx = -1;
|
||||||
|
|
||||||
|
@ -1077,7 +1079,7 @@ void Actor::startWalkActor(int destX, int destY, int dir)
|
||||||
x = abr.x;
|
x = abr.x;
|
||||||
y = abr.y;
|
y = abr.y;
|
||||||
if (dir != -1)
|
if (dir != -1)
|
||||||
setActorDirection(dir);
|
setDirection(dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1130,11 +1132,11 @@ void Actor::startWalkAnim(int cmd, int angle)
|
||||||
} else*/ {
|
} else*/ {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case 1: /* start walk */
|
case 1: /* start walk */
|
||||||
setActorDirection(angle);
|
setDirection(angle);
|
||||||
startAnimActor(walkFrame);
|
startAnimActor(walkFrame);
|
||||||
break;
|
break;
|
||||||
case 2: /* change dir only */
|
case 2: /* change dir only */
|
||||||
setActorDirection(angle);
|
setDirection(angle);
|
||||||
break;
|
break;
|
||||||
case 3: /* stop walk */
|
case 3: /* stop walk */
|
||||||
turnToDirection(angle);
|
turnToDirection(angle);
|
||||||
|
@ -1157,7 +1159,7 @@ void Actor::walkActor()
|
||||||
|
|
||||||
if (moving & MF_LAST_LEG) {
|
if (moving & MF_LAST_LEG) {
|
||||||
moving = 0;
|
moving = 0;
|
||||||
setActorBox(walkdata.destbox);
|
setBox(walkdata.destbox);
|
||||||
startWalkAnim(3, walkdata.destdir);
|
startWalkAnim(3, walkdata.destdir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1165,20 +1167,20 @@ void Actor::walkActor()
|
||||||
if (moving & MF_TURN) {
|
if (moving & MF_TURN) {
|
||||||
j = updateActorDirection();
|
j = updateActorDirection();
|
||||||
if (facing != j)
|
if (facing != j)
|
||||||
setActorDirection(j);
|
setDirection(j);
|
||||||
else
|
else
|
||||||
moving = 0;
|
moving = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setActorBox(walkdata.curbox);
|
setBox(walkdata.curbox);
|
||||||
moving &= MF_IN_LEG;
|
moving &= MF_IN_LEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
moving &= ~MF_NEW_LEG;
|
moving &= ~MF_NEW_LEG;
|
||||||
if ((!walkbox && (!(_vm->_features & GF_SMALL_HEADER)))) {
|
if ((!walkbox && (!(_vm->_features & GF_SMALL_HEADER)))) {
|
||||||
setActorBox(walkdata.destbox);
|
setBox(walkdata.destbox);
|
||||||
walkdata.curbox = walkdata.destbox;
|
walkdata.curbox = walkdata.destbox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1199,7 @@ void Actor::walkActor()
|
||||||
if (calcMovementFactor(_vm->_foundPathX, _vm->_foundPathY))
|
if (calcMovementFactor(_vm->_foundPathX, _vm->_foundPathY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setActorBox(walkdata.curbox);
|
setBox(walkdata.curbox);
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
moving |= MF_LAST_LEG;
|
moving |= MF_LAST_LEG;
|
||||||
|
@ -1277,7 +1279,7 @@ void Actor::walkActorOld()
|
||||||
if (moving & MF_TURN) {
|
if (moving & MF_TURN) {
|
||||||
new_dir = updateActorDirection();
|
new_dir = updateActorDirection();
|
||||||
if (facing != new_dir) {
|
if (facing != new_dir) {
|
||||||
setActorDirection(new_dir);
|
setDirection(new_dir);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
moving = 0;
|
moving = 0;
|
||||||
|
|
12
actor.h
12
actor.h
|
@ -119,22 +119,30 @@ public:
|
||||||
void showActor();
|
void showActor();
|
||||||
|
|
||||||
void initActor(int mode);
|
void initActor(int mode);
|
||||||
|
void putActor(int x, int y, byte room);
|
||||||
void setActorWalkSpeed(uint newSpeedX, uint newSpeedY);
|
void setActorWalkSpeed(uint newSpeedX, uint newSpeedY);
|
||||||
|
protected:
|
||||||
int calcMovementFactor(int newx, int newy);
|
int calcMovementFactor(int newx, int newy);
|
||||||
int actorWalkStep();
|
int actorWalkStep();
|
||||||
int remapDirection(int dir);
|
int remapDirection(int dir);
|
||||||
void setupActorScale();
|
void setupActorScale();
|
||||||
|
public:
|
||||||
void stopActorMoving();
|
void stopActorMoving();
|
||||||
void startWalkAnim(int cmd, int angle);
|
void startWalkAnim(int cmd, int angle);
|
||||||
void startAnimActor(int frame);
|
void startAnimActor(int frame);
|
||||||
void setActorBox(int box);
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setBox(int box);
|
||||||
int updateActorDirection();
|
int updateActorDirection();
|
||||||
void setActorDirection(int direction);
|
|
||||||
|
public:
|
||||||
|
void setDirection(int direction);
|
||||||
int getActorXYPos(int &x, int &y);
|
int getActorXYPos(int &x, int &y);
|
||||||
|
|
||||||
AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom);
|
AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom);
|
||||||
|
protected:
|
||||||
void adjustActorPos();
|
void adjustActorPos();
|
||||||
|
public:
|
||||||
void turnToDirection(int newdir);
|
void turnToDirection(int newdir);
|
||||||
void walkActor();
|
void walkActor();
|
||||||
void drawActorCostume();
|
void drawActorCostume();
|
||||||
|
|
|
@ -813,7 +813,7 @@ void Scumm::o5_actorSet()
|
||||||
a->forceClip = 0;
|
a->forceClip = 0;
|
||||||
FixRoom:
|
FixRoom:
|
||||||
if (a->isInCurrentRoom())
|
if (a->isInCurrentRoom())
|
||||||
putActor(a, a->x, a->y, a->room);
|
a->putActor(a->x, a->y, a->room);
|
||||||
break;
|
break;
|
||||||
case 21: /* followboxes */
|
case 21: /* followboxes */
|
||||||
a->ignoreBoxes = 0;
|
a->ignoreBoxes = 0;
|
||||||
|
@ -1575,7 +1575,7 @@ void Scumm::o5_loadRoomWithEgo()
|
||||||
a = derefActorSafe(_vars[VAR_EGO], "o5_loadRoomWithEgo");
|
a = derefActorSafe(_vars[VAR_EGO], "o5_loadRoomWithEgo");
|
||||||
|
|
||||||
/* Warning: used previously _xPos, _yPos from a previous update of those */
|
/* 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();
|
x = (int16)fetchScriptWord();
|
||||||
y = (int16)fetchScriptWord();
|
y = (int16)fetchScriptWord();
|
||||||
|
@ -1726,7 +1726,7 @@ void Scumm::o5_putActor()
|
||||||
x = getVarOrDirectWord(0x40);
|
x = getVarOrDirectWord(0x40);
|
||||||
y = getVarOrDirectWord(0x20);
|
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;
|
x = 240;
|
||||||
y = 120;
|
y = 120;
|
||||||
}
|
}
|
||||||
putActor(a, x, y, a->room);
|
a->putActor(x, y, a->room);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::o5_putActorInRoom()
|
void Scumm::o5_putActorInRoom()
|
||||||
|
@ -1758,7 +1758,7 @@ void Scumm::o5_putActorInRoom()
|
||||||
}
|
}
|
||||||
a->room = room;
|
a->room = room;
|
||||||
if (!room)
|
if (!room)
|
||||||
putActor(a, 0, 0, 0);
|
a->putActor(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::o5_quitPauseRestart()
|
void Scumm::o5_quitPauseRestart()
|
||||||
|
|
|
@ -1393,7 +1393,7 @@ void Scumm::o6_putActorInRoom()
|
||||||
if (room != 0)
|
if (room != 0)
|
||||||
a->room = room;
|
a->room = room;
|
||||||
}
|
}
|
||||||
putActor(a, x, y, room);
|
a->putActor(x, y, room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1413,7 +1413,7 @@ void Scumm::o6_putActorAtObject()
|
||||||
}
|
}
|
||||||
if (room == 0xFF)
|
if (room == 0xFF)
|
||||||
room = a->room;
|
room = a->room;
|
||||||
putActor(a, x, y, room);
|
a->putActor(x, y, room);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::o6_faceActor()
|
void Scumm::o6_faceActor()
|
||||||
|
@ -1489,7 +1489,7 @@ void Scumm::o6_loadRoomWithEgo()
|
||||||
|
|
||||||
a = derefActorSafe(_vars[VAR_EGO], "o_loadRoomWithEgo");
|
a = derefActorSafe(_vars[VAR_EGO], "o_loadRoomWithEgo");
|
||||||
|
|
||||||
putActor(a, 0, 0, room);
|
a->putActor(0, 0, room);
|
||||||
_egoPositioned = false;
|
_egoPositioned = false;
|
||||||
|
|
||||||
_vars[VAR_WALKTO_OBJ] = obj;
|
_vars[VAR_WALKTO_OBJ] = obj;
|
||||||
|
@ -1997,7 +1997,7 @@ void Scumm::o6_actorSet()
|
||||||
a->forceClip = 0;
|
a->forceClip = 0;
|
||||||
FixRooms:;
|
FixRooms:;
|
||||||
if (a->isInCurrentRoom())
|
if (a->isInCurrentRoom())
|
||||||
putActor(a, a->x, a->y, a->room);
|
a->putActor(a->x, a->y, a->room);
|
||||||
break;
|
break;
|
||||||
case 96:
|
case 96:
|
||||||
a->ignoreBoxes = 0;
|
a->ignoreBoxes = 0;
|
||||||
|
@ -2045,7 +2045,7 @@ void Scumm::o6_actorSet()
|
||||||
break;
|
break;
|
||||||
case 230: /* set direction */
|
case 230: /* set direction */
|
||||||
a->moving &= ~MF_TURN;
|
a->moving &= ~MF_TURN;
|
||||||
a->setActorDirection(pop());
|
a->setDirection(pop());
|
||||||
break;
|
break;
|
||||||
case 231: /* turn to direction */
|
case 231: /* turn to direction */
|
||||||
a->turnToDirection(pop());
|
a->turnToDirection(pop());
|
||||||
|
|
1
scumm.h
1
scumm.h
|
@ -779,7 +779,6 @@ public:
|
||||||
Actor *derefActor(int id);
|
Actor *derefActor(int id);
|
||||||
Actor *derefActorSafe(int id, const char *errmsg);
|
Actor *derefActorSafe(int id, const char *errmsg);
|
||||||
Actor *getFirstActor() { return _actors; }
|
Actor *getFirstActor() { return _actors; }
|
||||||
void putActor(Actor *a, int x, int y, byte room);
|
|
||||||
void showActors();
|
void showActors();
|
||||||
|
|
||||||
uint32 *_classData;
|
uint32 *_classData;
|
||||||
|
|
|
@ -491,8 +491,8 @@ void Scumm::startScene(int room, Actor * a, int objectNr)
|
||||||
_currentRoom);
|
_currentRoom);
|
||||||
int x, y, dir;
|
int x, y, dir;
|
||||||
getObjectXYPos(objectNr, x, y, dir);
|
getObjectXYPos(objectNr, x, y, dir);
|
||||||
putActor(a, x, y, _currentRoom);
|
a->putActor(x, y, _currentRoom);
|
||||||
a->setActorDirection(dir + 180);
|
a->setDirection(dir + 180);
|
||||||
a->moving = 0;
|
a->moving = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ void Scumm::startScene(int room, Actor * a, int objectNr)
|
||||||
if (a && !_egoPositioned) {
|
if (a && !_egoPositioned) {
|
||||||
int x, y;
|
int x, y;
|
||||||
getObjectXYPos(objectNr, x, y);
|
getObjectXYPos(objectNr, x, y);
|
||||||
putActor(a, x, y, _currentRoom);
|
a->putActor(x, y, _currentRoom);
|
||||||
a->moving = 0;
|
a->moving = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue