got rid of _xPos, _yPos, _dir members in class Scumm
svn-id: r4578
This commit is contained in:
parent
0d943903c7
commit
32e81beb45
8 changed files with 61 additions and 72 deletions
10
actor.cpp
10
actor.cpp
|
@ -548,15 +548,13 @@ void Scumm::putActor(Actor *a, int dstX, int dstY, byte room)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scumm::getActorXYPos(Actor *a)
|
int Actor::getActorXYPos(int &xPos, int &yPos)
|
||||||
{
|
{
|
||||||
if (!a)
|
if (!isInCurrentRoom())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!a->isInCurrentRoom())
|
xPos = x;
|
||||||
return -1;
|
yPos = y;
|
||||||
_xPos = a->x;
|
|
||||||
_yPos = a->y;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
actor.h
1
actor.h
|
@ -131,6 +131,7 @@ public:
|
||||||
|
|
||||||
int updateActorDirection();
|
int updateActorDirection();
|
||||||
void setActorDirection(int direction);
|
void setActorDirection(int direction);
|
||||||
|
int getActorXYPos(int &x, int &y);
|
||||||
|
|
||||||
AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom);
|
AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom);
|
||||||
void adjustActorPos();
|
void adjustActorPos();
|
||||||
|
|
67
object.cpp
67
object.cpp
|
@ -135,34 +135,33 @@ int Scumm::whereIsObject(int object)
|
||||||
return WIO_NOT_FOUND;
|
return WIO_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scumm::getObjectOrActorXY(int object)
|
int Scumm::getObjectOrActorXY(int object, int &x, int &y)
|
||||||
{
|
{
|
||||||
if (object < NUM_ACTORS)
|
if (object < NUM_ACTORS)
|
||||||
return getActorXYPos(derefActorSafe(object, "getObjectOrActorXY"));
|
return derefActorSafe(object, "getObjectOrActorXY")->getActorXYPos(x, y);
|
||||||
|
|
||||||
switch (whereIsObject(object)) {
|
switch (whereIsObject(object)) {
|
||||||
case WIO_NOT_FOUND:
|
case WIO_NOT_FOUND:
|
||||||
return -1;
|
return -1;
|
||||||
case WIO_INVENTORY:
|
case WIO_INVENTORY:
|
||||||
if (_objectOwnerTable[object] < NUM_ACTORS)
|
if (_objectOwnerTable[object] < NUM_ACTORS)
|
||||||
return getActorXYPos(derefActorSafe(_objectOwnerTable[object], "getObjectOrActorXY(2)"));
|
return derefActorSafe(_objectOwnerTable[object], "getObjectOrActorXY(2)")->getActorXYPos(x, y);
|
||||||
else
|
else
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
getObjectXYPos(object);
|
getObjectXYPos(object, x, y);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the position of an object.
|
/* Return the position of an object.
|
||||||
Returns X, Y and direction in angles
|
Returns X, Y and direction in angles
|
||||||
*/
|
*/
|
||||||
void Scumm::getObjectXYPos(int object)
|
void Scumm::getObjectXYPos(int object, int &x, int &y, int &dir)
|
||||||
{
|
{
|
||||||
ObjectData *od = &_objs[getObjectIndex(object)];
|
ObjectData *od = &_objs[getObjectIndex(object)];
|
||||||
int state;
|
int state;
|
||||||
byte *ptr;
|
byte *ptr;
|
||||||
ImageHeader *imhd;
|
ImageHeader *imhd;
|
||||||
int x, y;
|
|
||||||
|
|
||||||
if (!(_features & GF_SMALL_HEADER)) {
|
if (!(_features & GF_SMALL_HEADER)) {
|
||||||
if (_features & GF_AFTER_V6) {
|
if (_features & GF_AFTER_V6) {
|
||||||
|
@ -190,22 +189,17 @@ void Scumm::getObjectXYPos(int object)
|
||||||
x = od->walk_x;
|
x = od->walk_x;
|
||||||
y = od->walk_y;
|
y = od->walk_y;
|
||||||
}
|
}
|
||||||
_xPos = x;
|
dir = oldDirToNewDir(od->actordir & 3);
|
||||||
_yPos = y;
|
|
||||||
_dir = oldDirToNewDir(od->actordir & 3);
|
|
||||||
} else {
|
} else {
|
||||||
x = od->walk_x;
|
x = od->walk_x;
|
||||||
y = od->walk_y;
|
y = od->walk_y;
|
||||||
_xPos = x;
|
dir = oldDirToNewDir(od->actordir & 3);
|
||||||
_yPos = y;
|
|
||||||
_dir = oldDirToNewDir(od->actordir & 3);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Scumm::getObjActToObjActDist(int a, int b)
|
int Scumm::getObjActToObjActDist(int a, int b)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y, x2, y2;
|
||||||
Actor *acta = NULL;
|
Actor *acta = NULL;
|
||||||
Actor *actb = NULL;
|
Actor *actb = NULL;
|
||||||
|
|
||||||
|
@ -218,23 +212,20 @@ int Scumm::getObjActToObjActDist(int a, int b)
|
||||||
if (acta && actb && acta->getRoom() == actb->getRoom() && acta->getRoom() && !acta->isInCurrentRoom())
|
if (acta && actb && acta->getRoom() == actb->getRoom() && acta->getRoom() && !acta->isInCurrentRoom())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (getObjectOrActorXY(a) == -1)
|
if (getObjectOrActorXY(a, x, y) == -1)
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
|
|
||||||
x = _xPos;
|
if (getObjectOrActorXY(b, x2, y2) == -1)
|
||||||
y = _yPos;
|
|
||||||
|
|
||||||
if (getObjectOrActorXY(b) == -1)
|
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
|
|
||||||
if (acta) {
|
if (acta) {
|
||||||
AdjustBoxResult r = acta->adjustXYToBeInBox(_xPos, _yPos, -1);
|
AdjustBoxResult r = acta->adjustXYToBeInBox(x2, y2, -1);
|
||||||
_xPos = r.x;
|
x2 = r.x;
|
||||||
_yPos = r.y;
|
y2 = r.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
y = abs(y - _yPos);
|
y = abs(y - y2);
|
||||||
x = abs(x - _xPos);
|
x = abs(x - x2);
|
||||||
|
|
||||||
if (y > x)
|
if (y > x)
|
||||||
x = y;
|
x = y;
|
||||||
|
@ -965,8 +956,9 @@ int Scumm::getObjX(int obj)
|
||||||
} else {
|
} else {
|
||||||
if (whereIsObject(obj) == WIO_NOT_FOUND)
|
if (whereIsObject(obj) == WIO_NOT_FOUND)
|
||||||
return -1;
|
return -1;
|
||||||
getObjectOrActorXY(obj);
|
int x, y;
|
||||||
return _xPos;
|
getObjectOrActorXY(obj, x, y);
|
||||||
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,8 +971,9 @@ int Scumm::getObjY(int obj)
|
||||||
} else {
|
} else {
|
||||||
if (whereIsObject(obj) == WIO_NOT_FOUND)
|
if (whereIsObject(obj) == WIO_NOT_FOUND)
|
||||||
return -1;
|
return -1;
|
||||||
getObjectOrActorXY(obj);
|
int x, y;
|
||||||
return _yPos;
|
getObjectOrActorXY(obj, x, y);
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -989,8 +982,9 @@ int Scumm::getObjOldDir(int obj)
|
||||||
if (obj < NUM_ACTORS) {
|
if (obj < NUM_ACTORS) {
|
||||||
return newDirToOldDir(derefActorSafe(obj, "getObjOldDir")->facing);
|
return newDirToOldDir(derefActorSafe(obj, "getObjOldDir")->facing);
|
||||||
} else {
|
} else {
|
||||||
getObjectXYPos(obj);
|
int x, y, dir;
|
||||||
return _dir;
|
getObjectXYPos(obj, x, y, dir);
|
||||||
|
return dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,8 +993,9 @@ int Scumm::getObjNewDir(int obj)
|
||||||
if (obj < NUM_ACTORS) {
|
if (obj < NUM_ACTORS) {
|
||||||
return derefActorSafe(obj, "getObjNewDir")->facing;
|
return derefActorSafe(obj, "getObjNewDir")->facing;
|
||||||
} else {
|
} else {
|
||||||
getObjectXYPos(obj);
|
int x, y, dir;
|
||||||
return oldDirToNewDir(_dir);
|
getObjectXYPos(obj, x, y, dir);
|
||||||
|
return oldDirToNewDir(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1064,24 +1059,20 @@ int Scumm::getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e,
|
||||||
j = i = 0xFF;
|
j = i = 0xFF;
|
||||||
|
|
||||||
if (is_obj_1) {
|
if (is_obj_1) {
|
||||||
if (getObjectOrActorXY(b) == -1)
|
if (getObjectOrActorXY(b, x, y) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
if (b < NUM_ACTORS)
|
if (b < NUM_ACTORS)
|
||||||
i = derefActorSafe(b, "unkObjProc1")->scalex;
|
i = derefActorSafe(b, "unkObjProc1")->scalex;
|
||||||
x = _xPos;
|
|
||||||
y = _yPos;
|
|
||||||
} else {
|
} else {
|
||||||
x = b;
|
x = b;
|
||||||
y = c;
|
y = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_obj_2) {
|
if (is_obj_2) {
|
||||||
if (getObjectOrActorXY(e) == -1)
|
if (getObjectOrActorXY(e, x2, y2) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
if (e < NUM_ACTORS)
|
if (e < NUM_ACTORS)
|
||||||
j = derefActorSafe(e, "unkObjProc1(2)")->scalex;
|
j = derefActorSafe(e, "unkObjProc1(2)")->scalex;
|
||||||
x2 = _xPos;
|
|
||||||
y2 = _yPos;
|
|
||||||
} else {
|
} else {
|
||||||
x2 = e;
|
x2 = e;
|
||||||
y2 = f;
|
y2 = f;
|
||||||
|
|
10
script.cpp
10
script.cpp
|
@ -855,17 +855,15 @@ void Scumm::cutscene(int16 *args)
|
||||||
|
|
||||||
void Scumm::faceActorToObj(int act, int obj)
|
void Scumm::faceActorToObj(int act, int obj)
|
||||||
{
|
{
|
||||||
int x, dir;
|
int x, x2, y, dir;
|
||||||
|
|
||||||
if (getObjectOrActorXY(act) == -1)
|
if (getObjectOrActorXY(act, x, y) == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x = _xPos;
|
if (getObjectOrActorXY(obj, x2, y) == -1)
|
||||||
|
|
||||||
if (getObjectOrActorXY(obj) == -1)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dir = (_xPos > x) ? 90 : 270;
|
dir = (x2 > x) ? 90 : 270;
|
||||||
derefActorSafe(act, "faceActorToObj")->turnToDirection(dir);
|
derefActorSafe(act, "faceActorToObj")->turnToDirection(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1732,18 +1732,18 @@ void Scumm::o5_putActor()
|
||||||
|
|
||||||
void Scumm::o5_putActorAtObject()
|
void Scumm::o5_putActorAtObject()
|
||||||
{
|
{
|
||||||
int obj;
|
int obj, x, y;
|
||||||
Actor *a;
|
Actor *a;
|
||||||
|
|
||||||
a = derefActorSafe(getVarOrDirectByte(0x80), "o5_putActorAtObject");
|
a = derefActorSafe(getVarOrDirectByte(0x80), "o5_putActorAtObject");
|
||||||
obj = getVarOrDirectWord(0x40);
|
obj = getVarOrDirectWord(0x40);
|
||||||
if (whereIsObject(obj) != WIO_NOT_FOUND)
|
if (whereIsObject(obj) != WIO_NOT_FOUND)
|
||||||
getObjectXYPos(obj);
|
getObjectXYPos(obj, x, y);
|
||||||
else {
|
else {
|
||||||
_xPos = 240;
|
x = 240;
|
||||||
_yPos = 120;
|
y = 120;
|
||||||
}
|
}
|
||||||
putActor(a, _xPos, _yPos, a->room);
|
putActor(a, x, y, a->room);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::o5_putActorInRoom()
|
void Scumm::o5_putActorInRoom()
|
||||||
|
@ -2611,8 +2611,9 @@ void Scumm::o5_walkActorToObject()
|
||||||
a = derefActorSafe(getVarOrDirectByte(0x80), "o5_walkActorToObject");
|
a = derefActorSafe(getVarOrDirectByte(0x80), "o5_walkActorToObject");
|
||||||
obj = getVarOrDirectWord(0x40);
|
obj = getVarOrDirectWord(0x40);
|
||||||
if (whereIsObject(obj) != WIO_NOT_FOUND) {
|
if (whereIsObject(obj) != WIO_NOT_FOUND) {
|
||||||
getObjectXYPos(obj);
|
int x, y, dir;
|
||||||
a->startWalkActor(_xPos, _yPos, _dir);
|
getObjectXYPos(obj, x, y, dir);
|
||||||
|
a->startWalkActor(x, y, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1341,8 +1341,9 @@ void Scumm::o6_walkActorToObj()
|
||||||
if (obj >= NUM_ACTORS) {
|
if (obj >= NUM_ACTORS) {
|
||||||
if (whereIsObject(obj) == WIO_NOT_FOUND)
|
if (whereIsObject(obj) == WIO_NOT_FOUND)
|
||||||
return;
|
return;
|
||||||
getObjectXYPos(obj);
|
int x, y, dir;
|
||||||
a->startWalkActor(_xPos, _yPos, _dir);
|
getObjectXYPos(obj, x, y, dir);
|
||||||
|
a->startWalkActor(x, y, dir);
|
||||||
} else {
|
} else {
|
||||||
a2 = derefActorSafe(obj, "o6_walkActorToObj(2)");
|
a2 = derefActorSafe(obj, "o6_walkActorToObj(2)");
|
||||||
if (!a2)
|
if (!a2)
|
||||||
|
@ -1397,16 +1398,14 @@ void Scumm::o6_putActorInRoom()
|
||||||
|
|
||||||
void Scumm::o6_putActorAtObject()
|
void Scumm::o6_putActorAtObject()
|
||||||
{
|
{
|
||||||
int room, obj, x, y;
|
int room, obj, x, y, dir;
|
||||||
Actor *a;
|
Actor *a;
|
||||||
|
|
||||||
obj = popRoomAndObj(&room);
|
obj = popRoomAndObj(&room);
|
||||||
|
|
||||||
a = derefActorSafe(pop(), "o6_putActorAtObject");
|
a = derefActorSafe(pop(), "o6_putActorAtObject");
|
||||||
if (whereIsObject(obj) != WIO_NOT_FOUND) {
|
if (whereIsObject(obj) != WIO_NOT_FOUND) {
|
||||||
getObjectXYPos(obj);
|
getObjectXYPos(obj, x, y);
|
||||||
x = _xPos;
|
|
||||||
y = _yPos;
|
|
||||||
} else {
|
} else {
|
||||||
x = 160;
|
x = 160;
|
||||||
y = 120;
|
y = 120;
|
||||||
|
|
7
scumm.h
7
scumm.h
|
@ -565,7 +565,6 @@ public:
|
||||||
VirtScreen *_curVirtScreen;
|
VirtScreen *_curVirtScreen;
|
||||||
|
|
||||||
bool _egoPositioned;
|
bool _egoPositioned;
|
||||||
int _xPos, _yPos, _dir;
|
|
||||||
int _keyPressed;
|
int _keyPressed;
|
||||||
uint16 _lastKeyHit;
|
uint16 _lastKeyHit;
|
||||||
uint16 _mouseButStat;
|
uint16 _mouseButStat;
|
||||||
|
@ -788,14 +787,15 @@ public:
|
||||||
int getObjectRoom(int obj);
|
int getObjectRoom(int obj);
|
||||||
int getObjX(int obj);
|
int getObjX(int obj);
|
||||||
int getObjY(int obj);
|
int getObjY(int obj);
|
||||||
void getObjectXYPos(int object);
|
void getObjectXYPos(int object, int &x, int &y) { int dir; getObjectXYPos(object, x, y, dir); }
|
||||||
|
void getObjectXYPos(int object, int &x, int &y, int &dir);
|
||||||
int getObjOldDir(int obj);
|
int getObjOldDir(int obj);
|
||||||
int getObjNewDir(int obj);
|
int getObjNewDir(int obj);
|
||||||
int getObjectIndex(int object);
|
int getObjectIndex(int object);
|
||||||
int whereIsObject(int object);
|
int whereIsObject(int object);
|
||||||
int findObject(int x, int y);
|
int findObject(int x, int y);
|
||||||
void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room);
|
void findObjectInRoom(FindObjectInRoom *fo, byte findWhat, uint object, uint room);
|
||||||
int getObjectOrActorXY(int object); // Object and Actor...
|
int getObjectOrActorXY(int object, int &x, int &y); // Object and Actor...
|
||||||
int getObjActToObjActDist(int a, int b); // Not sure how to handle
|
int getObjActToObjActDist(int a, int b); // Not sure how to handle
|
||||||
byte *getObjOrActorName(int obj); // these three..
|
byte *getObjOrActorName(int obj); // these three..
|
||||||
|
|
||||||
|
@ -935,7 +935,6 @@ public:
|
||||||
void startAnimActorEx(Actor *a, int frame, int direction);
|
void startAnimActorEx(Actor *a, int frame, int direction);
|
||||||
int getProgrDirChange(Actor *a, int mode);
|
int getProgrDirChange(Actor *a, int mode);
|
||||||
|
|
||||||
int getActorXYPos(Actor *a);
|
|
||||||
void walkActors();
|
void walkActors();
|
||||||
void playActorSounds();
|
void playActorSounds();
|
||||||
void setActorRedrawFlags();
|
void setActorRedrawFlags();
|
||||||
|
|
12
scummvm.cpp
12
scummvm.cpp
|
@ -489,9 +489,10 @@ void Scumm::startScene(int room, Actor * a, int objectNr)
|
||||||
if (where != WIO_ROOM && where != WIO_FLOBJECT)
|
if (where != WIO_ROOM && where != WIO_FLOBJECT)
|
||||||
error("startScene: Object %d is not in room %d", objectNr,
|
error("startScene: Object %d is not in room %d", objectNr,
|
||||||
_currentRoom);
|
_currentRoom);
|
||||||
getObjectXYPos(objectNr);
|
int x, y, dir;
|
||||||
putActor(a, _xPos, _yPos, _currentRoom);
|
getObjectXYPos(objectNr, x, y, dir);
|
||||||
a->setActorDirection(_dir + 180);
|
putActor(a, x, y, _currentRoom);
|
||||||
|
a->setActorDirection(dir + 180);
|
||||||
a->moving = 0;
|
a->moving = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,8 +503,9 @@ void Scumm::startScene(int room, Actor * a, int objectNr)
|
||||||
|
|
||||||
if (!(_features & GF_AFTER_V7)) {
|
if (!(_features & GF_AFTER_V7)) {
|
||||||
if (a && !_egoPositioned) {
|
if (a && !_egoPositioned) {
|
||||||
getObjectXYPos(objectNr);
|
int x, y;
|
||||||
putActor(a, _xPos, _yPos, _currentRoom);
|
getObjectXYPos(objectNr, x, y);
|
||||||
|
putActor(a, x, y, _currentRoom);
|
||||||
a->moving = 0;
|
a->moving = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue