diff options
author | Max Horn | 2003-05-26 02:26:13 +0000 |
---|---|---|
committer | Max Horn | 2003-05-26 02:26:13 +0000 |
commit | 2f9ff35badc889a8b2480c0a34442b42763efc39 (patch) | |
tree | 1746fe9e3954663127f18fdfbcc3a3552ae67367 /scumm | |
parent | c2d065d896a13f810ec9c4d484d1e2ec3713f3c2 (diff) | |
download | scummvm-rg350-2f9ff35badc889a8b2480c0a34442b42763efc39.tar.gz scummvm-rg350-2f9ff35badc889a8b2480c0a34442b42763efc39.tar.bz2 scummvm-rg350-2f9ff35badc889a8b2480c0a34442b42763efc39.zip |
moved Actor SaveLoadEntry definition to actor.cpp; made findPathTowards/findPathTowardsOld members of Actor; cleanup
svn-id: r7988
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/actor.cpp | 88 | ||||
-rw-r--r-- | scumm/actor.h | 21 | ||||
-rw-r--r-- | scumm/boxes.cpp | 54 | ||||
-rw-r--r-- | scumm/saveload.cpp | 78 | ||||
-rw-r--r-- | scumm/scumm.h | 4 |
5 files changed, 130 insertions, 115 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp index b8e591acdb..9955621abf 100644 --- a/scumm/actor.cpp +++ b/scumm/actor.cpp @@ -27,6 +27,7 @@ #include "charset.h" #include "costume.h" #include "resource.h" +#include "saveload.h" #include "sound.h" #include "usage_bits.h" @@ -592,7 +593,7 @@ void Actor::putActor(int dstX, int dstY, byte newRoom) { } } -int Actor::getActorXYPos(int &xPos, int &yPos) { +int Actor::getActorXYPos(int &xPos, int &yPos) const { if (!isInCurrentRoom()) return -1; @@ -1308,7 +1309,7 @@ void Actor::walkActor() { walkdata.curbox = box; - if (_vm->findPathTowards(this, walkbox, box, walkdata.destbox, foundPathX, foundPathY)) + if (findPathTowards(walkbox, box, walkdata.destbox, foundPathX, foundPathY)) break; if (calcMovementFactor(foundPathX, foundPathY)) @@ -1389,7 +1390,7 @@ void Actor::walkActorOld() { walkdata.curbox = next_box; - _vm->findPathTowardsOld(this, walkbox, next_box, walkdata.destbox, gateLoc); + findPathTowardsOld(walkbox, next_box, walkdata.destbox, gateLoc); if (gateLoc[2].x == 32000 && gateLoc[3].x == 32000) { break; } @@ -1521,3 +1522,84 @@ bool Actor::isPlayer() { } +const SaveLoadEntry *Actor::getSaveLoadEntries() { + static const SaveLoadEntry actorEntries[] = { + MKLINE(Actor, x, sleInt16, VER_V8), + MKLINE(Actor, y, sleInt16, VER_V8), + MKLINE(Actor, top, sleInt16, VER_V8), + MKLINE(Actor, bottom, sleInt16, VER_V8), + MKLINE(Actor, elevation, sleInt16, VER_V8), + MKLINE(Actor, width, sleUint16, VER_V8), + MKLINE(Actor, facing, sleUint16, VER_V8), + MKLINE(Actor, costume, sleUint16, VER_V8), + MKLINE(Actor, room, sleByte, VER_V8), + MKLINE(Actor, talkColor, sleByte, VER_V8), + MKLINE(Actor, talkFrequency, sleInt16, VER_V16), + MKLINE(Actor, scalex, sleByte, VER_V8), + MKLINE(Actor, scaley, sleByte, VER_V8), + MKLINE(Actor, charset, sleByte, VER_V8), + MKARRAY(Actor, sound[0], sleByte, 8, VER_V8), + MKARRAY(Actor, animVariable[0], sleUint16, 8, VER_V8), + MKLINE(Actor, newDirection, sleUint16, VER_V8), + MKLINE(Actor, moving, sleByte, VER_V8), + MKLINE(Actor, ignoreBoxes, sleByte, VER_V8), + MKLINE(Actor, forceClip, sleByte, VER_V8), + MKLINE(Actor, initFrame, sleByte, VER_V8), + MKLINE(Actor, walkFrame, sleByte, VER_V8), + MKLINE(Actor, standFrame, sleByte, VER_V8), + MKLINE(Actor, talkStartFrame, sleByte, VER_V8), + MKLINE(Actor, talkStopFrame, sleByte, VER_V8), + MKLINE(Actor, speedx, sleUint16, VER_V8), + MKLINE(Actor, speedy, sleUint16, VER_V8), + MKLINE(Actor, cost.animCounter1, sleUint16, VER_V8), + MKLINE(Actor, cost.animCounter2, sleByte, VER_V8), + + // Actor palette grew from 64 to 256 bytes + MKARRAY_OLD(Actor, palette[0], sleByte, 64, VER_V8, VER_V9), + MKARRAY(Actor, palette[0], sleByte, 256, VER_V10), + + MK_OBSOLETE(Actor, mask, sleByte, VER_V8, VER_V9), + MKLINE(Actor, shadow_mode, sleByte, VER_V8), + MKLINE(Actor, visible, sleByte, VER_V8), + MKLINE(Actor, frame, sleByte, VER_V8), + MKLINE(Actor, animSpeed, sleByte, VER_V8), + MKLINE(Actor, animProgress, sleByte, VER_V8), + MKLINE(Actor, walkbox, sleByte, VER_V8), + MKLINE(Actor, needRedraw, sleByte, VER_V8), + MKLINE(Actor, needBgReset, sleByte, VER_V8), + MKLINE(Actor, costumeNeedsInit, sleByte, VER_V8), + + MKLINE(Actor, talkPosY, sleInt16, VER_V8), + MKLINE(Actor, talkPosX, sleInt16, VER_V8), + MKLINE(Actor, ignoreTurns, sleByte, VER_V8), + + MKLINE(Actor, layer, sleByte, VER_V8), + + MKLINE(Actor, talk_script, sleUint16, VER_V8), + MKLINE(Actor, walk_script, sleUint16, VER_V8), + + MKLINE(Actor, walkdata.destx, sleInt16, VER_V8), + MKLINE(Actor, walkdata.desty, sleInt16, VER_V8), + MKLINE(Actor, walkdata.destbox, sleByte, VER_V8), + MKLINE(Actor, walkdata.destdir, sleUint16, VER_V8), + MKLINE(Actor, walkdata.curbox, sleByte, VER_V8), + MKLINE(Actor, walkdata.x, sleInt16, VER_V8), + MKLINE(Actor, walkdata.y, sleInt16, VER_V8), + MKLINE(Actor, walkdata.newx, sleInt16, VER_V8), + MKLINE(Actor, walkdata.newy, sleInt16, VER_V8), + MKLINE(Actor, walkdata.deltaXFactor, sleInt32, VER_V8), + MKLINE(Actor, walkdata.deltaYFactor, sleInt32, VER_V8), + MKLINE(Actor, walkdata.xfrac, sleUint16, VER_V8), + MKLINE(Actor, walkdata.yfrac, sleUint16, VER_V8), + + MKARRAY(Actor, cost.active[0], sleByte, 16, VER_V8), + MKLINE(Actor, cost.stopped, sleUint16, VER_V8), + MKARRAY(Actor, cost.curpos[0], sleUint16, 16, VER_V8), + MKARRAY(Actor, cost.start[0], sleUint16, 16, VER_V8), + MKARRAY(Actor, cost.end[0], sleUint16, 16, VER_V8), + MKARRAY(Actor, cost.frame[0], sleUint16, 16, VER_V8), + MKEND() + }; + + return actorEntries; +} diff --git a/scumm/actor.h b/scumm/actor.h index fc8aad6be4..e554871163 100644 --- a/scumm/actor.h +++ b/scumm/actor.h @@ -67,6 +67,8 @@ struct CostumeData { } }; +class SaveLoadEntry; + class Actor { public: @@ -102,12 +104,13 @@ public: uint16 talk_script, walk_script; bool ignoreTurns; // TODO - we do not honor this flag at all currently! int8 layer; - ActorWalkData walkdata; - int16 animVariable[16]; uint16 sound[8]; CostumeData cost; byte palette[256]; protected: + ActorWalkData walkdata; + int16 animVariable[16]; + static Scumm *_vm; public: @@ -173,17 +176,17 @@ public: void animateActor(int anim); - bool isInCurrentRoom() { + bool isInCurrentRoom() const { return room == _vm->_currentRoom; } - int getActorXYPos(int &x, int &y); + int getActorXYPos(int &x, int &y) const ; - int getRoom() { + int getRoom() const { return room; } - int getAnimVar(byte var) { + int getAnimVar(byte var) const { return animVariable[var]; } void setAnimVar(byte var, int value) { @@ -192,10 +195,16 @@ public: void classChanged(int cls, bool value); + // Used by the save/load syste: + static const SaveLoadEntry *getSaveLoadEntries(); + protected: bool isInClass(int cls); bool isPlayer(); + + bool findPathTowards(byte box, byte box2, byte box3, int16 &foundPathX, int16 &foundPathY); + void findPathTowardsOld(byte box, byte box2, byte box3, ScummVM::Point gateLoc[5]); }; #endif diff --git a/scumm/boxes.cpp b/scumm/boxes.cpp index a7acd0c139..1ce65d6448 100644 --- a/scumm/boxes.cpp +++ b/scumm/boxes.cpp @@ -86,7 +86,9 @@ struct PathVertex { /* Linked list of walkpath nodes */ #define BOX_MATRIX_SIZE 2000 -PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node); +static bool compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3); +static ScummVM::Point closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y); +static PathVertex *unkMatrixProc1(PathVertex *vtx, PathNode *node); byte Scumm::getMaskFromBox(int box) { @@ -397,7 +399,12 @@ uint Scumm::distanceFromPt(int x, int y, int ptx, int pty) { return diffx + diffy; } -ScummVM::Point Scumm::closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y) { + +bool compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3) { + return (Y2 - Y1) * (X3 - X1) <= (Y3 - Y1) * (X2 - X1); +} + +ScummVM::Point closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y) { int lydiff, lxdiff; int32 dist, a, b, c; int x2, y2; @@ -611,7 +618,7 @@ int Scumm::getPathToDestBox(byte from, byte to) { * Computes the next point actor a has to walk towards in a straight * line in order to get from box1 to box3 via box2. */ -bool Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr, int16 &foundPathX, int16 &foundPathY) { +bool Actor::findPathTowards(byte box1nr, byte box2nr, byte box3nr, int16 &foundPathX, int16 &foundPathY) { BoxCoords box1; BoxCoords box2; ScummVM::Point tmp; @@ -619,8 +626,8 @@ bool Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr, int int flag; int q, pos; - getBoxCoordinates(box1nr, &box1); - getBoxCoordinates(box2nr, &box2); + _vm->getBoxCoordinates(box1nr, &box1); + _vm->getBoxCoordinates(box2nr, &box2); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { @@ -644,11 +651,11 @@ bool Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr, int if (flag & 2) SWAP(box2.ul.y, box2.ur.y); } else { - pos = a->y; + pos = y; if (box2nr == box3nr) { - int diffX = a->walkdata.destx - a->x; - int diffY = a->walkdata.desty - a->y; - int boxDiffX = box1.ul.x - a->x; + int diffX = walkdata.destx - x; + int diffY = walkdata.desty - y; + int boxDiffX = box1.ul.x - x; if (diffX != 0) { int t; @@ -658,7 +665,7 @@ bool Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr, int if (t == 0 && (diffY <= 0 || diffX <= 0) && (diffY >= 0 || diffX >= 0)) t = -1; - pos = a->y + t; + pos = y + t; } } @@ -701,16 +708,16 @@ bool Scumm::findPathTowards(Actor *a, byte box1nr, byte box2nr, byte box3nr, int } else { if (box2nr == box3nr) { - int diffX = a->walkdata.destx - a->x; - int diffY = a->walkdata.desty - a->y; - int boxDiffY = box1.ul.y - a->y; + int diffX = walkdata.destx - x; + int diffY = walkdata.desty - y; + int boxDiffY = box1.ul.y - y; - pos = a->x; + pos = x; if (diffY != 0) { pos += diffX * boxDiffY / diffY; } } else { - pos = a->x; + pos = x; } q = pos; @@ -1053,24 +1060,24 @@ PathVertex *Scumm::addPathVertex() { return (PathVertex *)addToBoxVertexHeap(sizeof(PathVertex)); } -void Scumm::findPathTowardsOld(Actor *actor, byte trap1, byte trap2, byte final_trap, ScummVM::Point gateLoc[5]) { +void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, ScummVM::Point gateLoc[5]) { ScummVM::Point pt; ScummVM::Point gateA[2]; ScummVM::Point gateB[2]; - getGates(trap1, trap2, gateA, gateB); + _vm->getGates(trap1, trap2, gateA, gateB); - gateLoc[1].x = actor->x; - gateLoc[1].y = actor->y; + gateLoc[1].x = x; + gateLoc[1].y = y; gateLoc[2].x = 32000; gateLoc[3].x = 32000; gateLoc[4].x = 32000; if (trap2 == final_trap) { /* next = final box? */ - gateLoc[4].x = actor->walkdata.destx; - gateLoc[4].y = actor->walkdata.desty; + gateLoc[4].x = walkdata.destx; + gateLoc[4].y = walkdata.desty; - if (getMaskFromBox(trap1) == getMaskFromBox(trap2) || 1) { + if (_vm->getMaskFromBox(trap1) == _vm->getMaskFromBox(trap2) || 1) { if (compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateA[0].x, gateA[0].y) != compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateB[0].x, gateB[0].y) && compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateA[1].x, gateA[1].y) != @@ -1200,6 +1207,3 @@ void Scumm::getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Poi } } -bool Scumm::compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3) { - return (Y2 - Y1) * (X3 - X1) <= (Y3 - Y1) * (X2 - X1); -} diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index a3c4dbb5d8..c0bb7e7f4f 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -272,83 +272,7 @@ void Scumm::saveOrLoad(Serializer *s, uint32 savegameVersion) { MKEND() }; - const SaveLoadEntry actorEntries[] = { - MKLINE(Actor, x, sleInt16, VER_V8), - MKLINE(Actor, y, sleInt16, VER_V8), - MKLINE(Actor, top, sleInt16, VER_V8), - MKLINE(Actor, bottom, sleInt16, VER_V8), - MKLINE(Actor, elevation, sleInt16, VER_V8), - MKLINE(Actor, width, sleUint16, VER_V8), - MKLINE(Actor, facing, sleUint16, VER_V8), - MKLINE(Actor, costume, sleUint16, VER_V8), - MKLINE(Actor, room, sleByte, VER_V8), - MKLINE(Actor, talkColor, sleByte, VER_V8), - MKLINE(Actor, talkFrequency, sleInt16, VER_V16), - MKLINE(Actor, scalex, sleByte, VER_V8), - MKLINE(Actor, scaley, sleByte, VER_V8), - MKLINE(Actor, charset, sleByte, VER_V8), - MKARRAY(Actor, sound[0], sleByte, 8, VER_V8), - MKARRAY(Actor, animVariable[0], sleUint16, 8, VER_V8), - MKLINE(Actor, newDirection, sleUint16, VER_V8), - MKLINE(Actor, moving, sleByte, VER_V8), - MKLINE(Actor, ignoreBoxes, sleByte, VER_V8), - MKLINE(Actor, forceClip, sleByte, VER_V8), - MKLINE(Actor, initFrame, sleByte, VER_V8), - MKLINE(Actor, walkFrame, sleByte, VER_V8), - MKLINE(Actor, standFrame, sleByte, VER_V8), - MKLINE(Actor, talkStartFrame, sleByte, VER_V8), - MKLINE(Actor, talkStopFrame, sleByte, VER_V8), - MKLINE(Actor, speedx, sleUint16, VER_V8), - MKLINE(Actor, speedy, sleUint16, VER_V8), - MKLINE(Actor, cost.animCounter1, sleUint16, VER_V8), - MKLINE(Actor, cost.animCounter2, sleByte, VER_V8), - - // Actor palette grew from 64 to 256 bytes - MKARRAY_OLD(Actor, palette[0], sleByte, 64, VER_V8, VER_V9), - MKARRAY(Actor, palette[0], sleByte, 256, VER_V10), - - MK_OBSOLETE(Actor, mask, sleByte, VER_V8, VER_V9), - MKLINE(Actor, shadow_mode, sleByte, VER_V8), - MKLINE(Actor, visible, sleByte, VER_V8), - MKLINE(Actor, frame, sleByte, VER_V8), - MKLINE(Actor, animSpeed, sleByte, VER_V8), - MKLINE(Actor, animProgress, sleByte, VER_V8), - MKLINE(Actor, walkbox, sleByte, VER_V8), - MKLINE(Actor, needRedraw, sleByte, VER_V8), - MKLINE(Actor, needBgReset, sleByte, VER_V8), - MKLINE(Actor, costumeNeedsInit, sleByte, VER_V8), - - MKLINE(Actor, talkPosY, sleInt16, VER_V8), - MKLINE(Actor, talkPosX, sleInt16, VER_V8), - MKLINE(Actor, ignoreTurns, sleByte, VER_V8), - - MKLINE(Actor, layer, sleByte, VER_V8), - - MKLINE(Actor, talk_script, sleUint16, VER_V8), - MKLINE(Actor, walk_script, sleUint16, VER_V8), - - MKLINE(Actor, walkdata.destx, sleInt16, VER_V8), - MKLINE(Actor, walkdata.desty, sleInt16, VER_V8), - MKLINE(Actor, walkdata.destbox, sleByte, VER_V8), - MKLINE(Actor, walkdata.destdir, sleUint16, VER_V8), - MKLINE(Actor, walkdata.curbox, sleByte, VER_V8), - MKLINE(Actor, walkdata.x, sleInt16, VER_V8), - MKLINE(Actor, walkdata.y, sleInt16, VER_V8), - MKLINE(Actor, walkdata.newx, sleInt16, VER_V8), - MKLINE(Actor, walkdata.newy, sleInt16, VER_V8), - MKLINE(Actor, walkdata.deltaXFactor, sleInt32, VER_V8), - MKLINE(Actor, walkdata.deltaYFactor, sleInt32, VER_V8), - MKLINE(Actor, walkdata.xfrac, sleUint16, VER_V8), - MKLINE(Actor, walkdata.yfrac, sleUint16, VER_V8), - - MKARRAY(Actor, cost.active[0], sleByte, 16, VER_V8), - MKLINE(Actor, cost.stopped, sleUint16, VER_V8), - MKARRAY(Actor, cost.curpos[0], sleUint16, 16, VER_V8), - MKARRAY(Actor, cost.start[0], sleUint16, 16, VER_V8), - MKARRAY(Actor, cost.end[0], sleUint16, 16, VER_V8), - MKARRAY(Actor, cost.frame[0], sleUint16, 16, VER_V8), - MKEND() - }; + const SaveLoadEntry *actorEntries = Actor::getSaveLoadEntries(); const SaveLoadEntry verbEntries[] = { MKLINE(VerbSlot, x, sleInt16, VER_V8), diff --git a/scumm/scumm.h b/scumm/scumm.h index b88036dbc4..ded3889288 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -993,8 +993,6 @@ public: byte getNumBoxes(); byte *getBoxMatrixBaseAddr(); int getPathToDestBox(byte from, byte to); - bool findPathTowards(Actor *a, byte box, byte box2, byte box3, int16 &foundPathX, int16 &foundPathY); - void findPathTowardsOld(Actor *a, byte box, byte box2, byte box3, ScummVM::Point gateLoc[5]); void getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Point gateB[2]); bool inBoxQuickReject(int box, int x, int y, int threshold); AdjustBoxResult getClosestPtOnBox(int box, int x, int y); @@ -1005,7 +1003,6 @@ public: bool checkXYInBoxBounds(int box, int x, int y); uint distanceFromPt(int x, int y, int ptx, int pty); - ScummVM::Point closestPtOnLine(int ulx, int uly, int llx, int lly, int x, int y); void getBoxCoordinates(int boxnum, BoxCoords *bc); byte getMaskFromBox(int box); Box *getBoxBaseAddr(int box); @@ -1027,7 +1024,6 @@ protected: void createBoxMatrix(); void addToBoxMatrix(byte b); - bool compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3); PathNode *unkMatrixProc2(PathVertex *vtx, int i); void *addToBoxVertexHeap(int size); PathVertex *addPathVertex(); |