DREAMWEB: Move checkDest() to DreamBase

This commit is contained in:
Max Horn 2011-12-07 15:37:59 +01:00
parent c6ec610d5c
commit 8b0ecc7462
3 changed files with 11 additions and 12 deletions

View File

@ -60,6 +60,9 @@ public:
} }
public: public:
// from pathfind.cpp
void checkDest(const RoomPaths *roomsPaths);
// from print.cpp // from print.cpp
uint8 getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount); uint8 getNextWord(const Frame *charSet, const uint8 *string, uint8 *totalWidth, uint8 *charCount);
uint8 getNumber(const Frame *charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16 *offset); uint8 getNumber(const Frame *charSet, const uint8 *string, uint16 maxWidth, bool centered, uint16 *offset);

View File

@ -105,8 +105,7 @@ void DreamGenContext::setWalk() {
} }
void DreamGenContext::autoSetWalk() { void DreamGenContext::autoSetWalk() {
al = data.byte(kManspath); if (data.byte(kFinaldest) == data.byte(kManspath))
if (data.byte(kFinaldest) == al)
return; return;
const RoomPaths *roomsPaths = getRoomsPaths(); const RoomPaths *roomsPaths = getRoomsPaths();
checkDest(roomsPaths); checkDest(roomsPaths);
@ -123,21 +122,19 @@ void DreamGenContext::autoSetWalk() {
data.byte(kLinepointer) = 0; data.byte(kLinepointer) = 0;
} }
void DreamGenContext::checkDest(const RoomPaths *roomsPaths) { void DreamBase::checkDest(const RoomPaths *roomsPaths) {
const PathSegment *segments = roomsPaths->segments; const PathSegment *segments = roomsPaths->segments;
ah = data.byte(kManspath) << 4; const uint8 tmp = data.byte(kManspath) << 4;
al = data.byte(kDestination);
uint8 destination = data.byte(kDestination); uint8 destination = data.byte(kDestination);
for (size_t i = 0; i < 24; ++i) { for (size_t i = 0; i < 24; ++i) {
dh = segments[i].b0 & 0xf0; if ((segments[i].b0 & 0xf0) == tmp &&
dl = segments[i].b0 & 0x0f; (segments[i].b0 & 0x0f) == data.byte(kDestination)) {
if (ax == dx) {
data.byte(kDestination) = segments[i].b1 & 0x0f; data.byte(kDestination) = segments[i].b1 & 0x0f;
return; return;
} }
dl = (segments[i].b0 & 0xf0) >> 4;
dh = (segments[i].b0 & 0x0f) << 4; if (((segments[i].b0 & 0x0f) << 4) == tmp &&
if (ax == dx) { ((segments[i].b0 & 0xf0) >> 4) == data.byte(kDestination)) {
destination = segments[i].b1 & 0x0f; destination = segments[i].b1 & 0x0f;
} }
} }

View File

@ -102,7 +102,6 @@
void faceRightWay(); void faceRightWay();
void walking(Sprite *sprite); void walking(Sprite *sprite);
void autoSetWalk(); void autoSetWalk();
void checkDest(const RoomPaths *roomsPaths);
void aboutTurn(Sprite *sprite); void aboutTurn(Sprite *sprite);
void backObject(Sprite *sprite); void backObject(Sprite *sprite);
void backObject(); void backObject();