diff options
author | Max Horn | 2002-07-16 18:51:27 +0000 |
---|---|---|
committer | Max Horn | 2002-07-16 18:51:27 +0000 |
commit | 32e81beb4567d6d8b58fa583558082e8b42ccb42 (patch) | |
tree | 36ade7b1fa124d7a8828c36407c14eaebb7b8e59 | |
parent | 0d943903c748fbaf7e780b9c94b31d69d523618c (diff) | |
download | scummvm-rg350-32e81beb4567d6d8b58fa583558082e8b42ccb42.tar.gz scummvm-rg350-32e81beb4567d6d8b58fa583558082e8b42ccb42.tar.bz2 scummvm-rg350-32e81beb4567d6d8b58fa583558082e8b42ccb42.zip |
got rid of _xPos, _yPos, _dir members in class Scumm
svn-id: r4578
-rw-r--r-- | actor.cpp | 10 | ||||
-rw-r--r-- | actor.h | 1 | ||||
-rw-r--r-- | object.cpp | 67 | ||||
-rw-r--r-- | script.cpp | 10 | ||||
-rw-r--r-- | script_v1.cpp | 15 | ||||
-rw-r--r-- | script_v2.cpp | 11 | ||||
-rw-r--r-- | scumm.h | 7 | ||||
-rw-r--r-- | scummvm.cpp | 12 |
8 files changed, 61 insertions, 72 deletions
@@ -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; - if (!a->isInCurrentRoom()) - return -1; - _xPos = a->x; - _yPos = a->y; + xPos = x; + yPos = y; return 0; } @@ -131,6 +131,7 @@ public: int updateActorDirection(); void setActorDirection(int direction); + int getActorXYPos(int &x, int &y); AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom); void adjustActorPos(); diff --git a/object.cpp b/object.cpp index 628d14b3d9..2b968dd71b 100644 --- a/object.cpp +++ b/object.cpp @@ -135,34 +135,33 @@ int Scumm::whereIsObject(int object) return WIO_NOT_FOUND; } -int Scumm::getObjectOrActorXY(int object) +int Scumm::getObjectOrActorXY(int object, int &x, int &y) { if (object < NUM_ACTORS) - return getActorXYPos(derefActorSafe(object, "getObjectOrActorXY")); + return derefActorSafe(object, "getObjectOrActorXY")->getActorXYPos(x, y); switch (whereIsObject(object)) { case WIO_NOT_FOUND: return -1; case WIO_INVENTORY: if (_objectOwnerTable[object] < NUM_ACTORS) - return getActorXYPos(derefActorSafe(_objectOwnerTable[object], "getObjectOrActorXY(2)")); + return derefActorSafe(_objectOwnerTable[object], "getObjectOrActorXY(2)")->getActorXYPos(x, y); else return 0xFF; } - getObjectXYPos(object); + getObjectXYPos(object, x, y); return 0; } /* Return the position of an object. 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)]; int state; byte *ptr; ImageHeader *imhd; - int x, y; if (!(_features & GF_SMALL_HEADER)) { if (_features & GF_AFTER_V6) { @@ -190,22 +189,17 @@ void Scumm::getObjectXYPos(int object) x = od->walk_x; y = od->walk_y; } - _xPos = x; - _yPos = y; - _dir = oldDirToNewDir(od->actordir & 3); + dir = oldDirToNewDir(od->actordir & 3); } else { x = od->walk_x; y = od->walk_y; - _xPos = x; - _yPos = y; - _dir = oldDirToNewDir(od->actordir & 3); - + dir = oldDirToNewDir(od->actordir & 3); } } int Scumm::getObjActToObjActDist(int a, int b) { - int x, y; + int x, y, x2, y2; Actor *acta = 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()) return 0; - if (getObjectOrActorXY(a) == -1) + if (getObjectOrActorXY(a, x, y) == -1) return 0xFF; - x = _xPos; - y = _yPos; - - if (getObjectOrActorXY(b) == -1) + if (getObjectOrActorXY(b, x2, y2) == -1) return 0xFF; if (acta) { - AdjustBoxResult r = acta->adjustXYToBeInBox(_xPos, _yPos, -1); - _xPos = r.x; - _yPos = r.y; + AdjustBoxResult r = acta->adjustXYToBeInBox(x2, y2, -1); + x2 = r.x; + y2 = r.y; } - y = abs(y - _yPos); - x = abs(x - _xPos); + y = abs(y - y2); + x = abs(x - x2); if (y > x) x = y; @@ -965,8 +956,9 @@ int Scumm::getObjX(int obj) } else { if (whereIsObject(obj) == WIO_NOT_FOUND) return -1; - getObjectOrActorXY(obj); - return _xPos; + int x, y; + getObjectOrActorXY(obj, x, y); + return x; } } @@ -979,8 +971,9 @@ int Scumm::getObjY(int obj) } else { if (whereIsObject(obj) == WIO_NOT_FOUND) return -1; - getObjectOrActorXY(obj); - return _yPos; + int x, y; + getObjectOrActorXY(obj, x, y); + return y; } } @@ -989,8 +982,9 @@ int Scumm::getObjOldDir(int obj) if (obj < NUM_ACTORS) { return newDirToOldDir(derefActorSafe(obj, "getObjOldDir")->facing); } else { - getObjectXYPos(obj); - return _dir; + int x, y, dir; + getObjectXYPos(obj, x, y, dir); + return dir; } } @@ -999,8 +993,9 @@ int Scumm::getObjNewDir(int obj) if (obj < NUM_ACTORS) { return derefActorSafe(obj, "getObjNewDir")->facing; } else { - getObjectXYPos(obj); - return oldDirToNewDir(_dir); + int x, y, 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; if (is_obj_1) { - if (getObjectOrActorXY(b) == -1) + if (getObjectOrActorXY(b, x, y) == -1) return -1; if (b < NUM_ACTORS) i = derefActorSafe(b, "unkObjProc1")->scalex; - x = _xPos; - y = _yPos; } else { x = b; y = c; } if (is_obj_2) { - if (getObjectOrActorXY(e) == -1) + if (getObjectOrActorXY(e, x2, y2) == -1) return -1; if (e < NUM_ACTORS) j = derefActorSafe(e, "unkObjProc1(2)")->scalex; - x2 = _xPos; - y2 = _yPos; } else { x2 = e; y2 = f; diff --git a/script.cpp b/script.cpp index 048532342c..9b33a1cd63 100644 --- a/script.cpp +++ b/script.cpp @@ -855,17 +855,15 @@ void Scumm::cutscene(int16 *args) 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; - x = _xPos; - - if (getObjectOrActorXY(obj) == -1) + if (getObjectOrActorXY(obj, x2, y) == -1) return; - dir = (_xPos > x) ? 90 : 270; + dir = (x2 > x) ? 90 : 270; derefActorSafe(act, "faceActorToObj")->turnToDirection(dir); } diff --git a/script_v1.cpp b/script_v1.cpp index 37d9796b0b..ea3b0eaf2b 100644 --- a/script_v1.cpp +++ b/script_v1.cpp @@ -1732,18 +1732,18 @@ void Scumm::o5_putActor() void Scumm::o5_putActorAtObject() { - int obj; + int obj, x, y; Actor *a; a = derefActorSafe(getVarOrDirectByte(0x80), "o5_putActorAtObject"); obj = getVarOrDirectWord(0x40); if (whereIsObject(obj) != WIO_NOT_FOUND) - getObjectXYPos(obj); + getObjectXYPos(obj, x, y); else { - _xPos = 240; - _yPos = 120; + x = 240; + y = 120; } - putActor(a, _xPos, _yPos, a->room); + putActor(a, x, y, a->room); } void Scumm::o5_putActorInRoom() @@ -2611,8 +2611,9 @@ void Scumm::o5_walkActorToObject() a = derefActorSafe(getVarOrDirectByte(0x80), "o5_walkActorToObject"); obj = getVarOrDirectWord(0x40); if (whereIsObject(obj) != WIO_NOT_FOUND) { - getObjectXYPos(obj); - a->startWalkActor(_xPos, _yPos, _dir); + int x, y, dir; + getObjectXYPos(obj, x, y, dir); + a->startWalkActor(x, y, dir); } } diff --git a/script_v2.cpp b/script_v2.cpp index 37ff8be4e9..59e548828a 100644 --- a/script_v2.cpp +++ b/script_v2.cpp @@ -1341,8 +1341,9 @@ void Scumm::o6_walkActorToObj() if (obj >= NUM_ACTORS) { if (whereIsObject(obj) == WIO_NOT_FOUND) return; - getObjectXYPos(obj); - a->startWalkActor(_xPos, _yPos, _dir); + int x, y, dir; + getObjectXYPos(obj, x, y, dir); + a->startWalkActor(x, y, dir); } else { a2 = derefActorSafe(obj, "o6_walkActorToObj(2)"); if (!a2) @@ -1397,16 +1398,14 @@ void Scumm::o6_putActorInRoom() void Scumm::o6_putActorAtObject() { - int room, obj, x, y; + int room, obj, x, y, dir; Actor *a; obj = popRoomAndObj(&room); a = derefActorSafe(pop(), "o6_putActorAtObject"); if (whereIsObject(obj) != WIO_NOT_FOUND) { - getObjectXYPos(obj); - x = _xPos; - y = _yPos; + getObjectXYPos(obj, x, y); } else { x = 160; y = 120; @@ -565,7 +565,6 @@ public: VirtScreen *_curVirtScreen; bool _egoPositioned; - int _xPos, _yPos, _dir; int _keyPressed; uint16 _lastKeyHit; uint16 _mouseButStat; @@ -788,14 +787,15 @@ public: int getObjectRoom(int obj); int getObjX(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 getObjNewDir(int obj); int getObjectIndex(int object); int whereIsObject(int object); int findObject(int x, int y); 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 byte *getObjOrActorName(int obj); // these three.. @@ -935,7 +935,6 @@ public: void startAnimActorEx(Actor *a, int frame, int direction); int getProgrDirChange(Actor *a, int mode); - int getActorXYPos(Actor *a); void walkActors(); void playActorSounds(); void setActorRedrawFlags(); diff --git a/scummvm.cpp b/scummvm.cpp index 8dbb01cf49..486078fc83 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -489,9 +489,10 @@ void Scumm::startScene(int room, Actor * a, int objectNr) if (where != WIO_ROOM && where != WIO_FLOBJECT) error("startScene: Object %d is not in room %d", objectNr, _currentRoom); - getObjectXYPos(objectNr); - putActor(a, _xPos, _yPos, _currentRoom); - a->setActorDirection(_dir + 180); + int x, y, dir; + getObjectXYPos(objectNr, x, y, dir); + putActor(a, x, y, _currentRoom); + a->setActorDirection(dir + 180); a->moving = 0; } @@ -502,8 +503,9 @@ void Scumm::startScene(int room, Actor * a, int objectNr) if (!(_features & GF_AFTER_V7)) { if (a && !_egoPositioned) { - getObjectXYPos(objectNr); - putActor(a, _xPos, _yPos, _currentRoom); + int x, y; + getObjectXYPos(objectNr, x, y); + putActor(a, x, y, _currentRoom); a->moving = 0; } } else { |