From 7e256531fd1494a32ac0c5c9805082057ace88fc Mon Sep 17 00:00:00 2001 From: Andrew Kurushin Date: Sun, 13 Mar 2005 17:43:50 +0000 Subject: fixed wrong tile drawing above actors svn-id: r17129 --- saga/actor.cpp | 5 ++--- saga/actor.h | 7 +++++++ saga/isomap.cpp | 12 ++++++------ saga/isomap.h | 12 ++++++------ 4 files changed, 21 insertions(+), 15 deletions(-) (limited to 'saga') diff --git a/saga/actor.cpp b/saga/actor.cpp index 33b005ffa8..ce5db9f7cb 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -1094,8 +1094,7 @@ void Actor::handleActions(int msec, bool setup) { hitZone = NULL; // tiled stuff if (_vm->_scene->getFlags() & kSceneFlagISO) { - hitPoint.x = actor->location.u(); - hitPoint.y = actor->location.v(); + actor->location.toScreenPointUV(hitPoint); } else { actor->location.toScreenPointXY(hitPoint); } @@ -1259,7 +1258,7 @@ int Actor::drawActors() { if (_vm->_scene->getFlags() & kSceneFlagISO) { - _vm->_isoMap->drawSprite(back_buf,*spriteList, frameNumber, drawObject->location, drawObject->screenPosition, drawObject->screenScale); + _vm->_isoMap->drawSprite(back_buf, *spriteList, frameNumber, drawObject->location, drawObject->screenPosition, drawObject->screenScale); } else { _vm->_sprite->drawOccluded(back_buf, *spriteList, frameNumber, drawObject->screenPosition, drawObject->screenScale, drawObject->screenDepth); } diff --git a/saga/actor.h b/saga/actor.h index babc847ef8..0d87b6a4cd 100644 --- a/saga/actor.h +++ b/saga/actor.h @@ -152,6 +152,9 @@ struct Location { int v() const { return y; } + int uv() const { + return u() + v(); + } void delta(const Location &location, Location &result) const { result.x = x - location.x; result.y = y - location.y; @@ -171,6 +174,10 @@ struct Location { screenPoint.x = x / ACTOR_LMULT; screenPoint.y = y / ACTOR_LMULT; } + void toScreenPointUV(Point &screenPoint) const { + screenPoint.x = u(); + screenPoint.y = v(); + } void toScreenPointXYZ(Point &screenPoint) const { screenPoint.x = x / ACTOR_LMULT; screenPoint.y = y / ACTOR_LMULT - z; diff --git a/saga/isomap.cpp b/saga/isomap.cpp index 910f8a3838..a1af26ecac 100644 --- a/saga/isomap.cpp +++ b/saga/isomap.cpp @@ -129,9 +129,9 @@ void IsoMap::loadImages(const byte *resourcePointer, size_t resourceLength) { for (i = 0; i < _tilesCount; i++) { tileData = &_tilesTable[i]; tileData->height = readS.readByte(); - tileData->attributes = readS.readByte(); + tileData->attributes = readS.readSByte(); tileData->offset = readS.readUint16(); - tileData->terrainMask = readS.readSint16(); + tileData->terrainMask = readS.readUint16(); tileData->FGDBGDAttr = readS.readByte(); readS.readByte(); //skip } @@ -638,7 +638,7 @@ void IsoMap::drawSpritePlatform(SURFACE *ds, uint16 platformIndex, const Point & tileIndex = findMulti(tileIndex, absU + u, absU + v, absH); } - drawTile(ds, tileIndex, s, &location); + drawTile(ds, tileIndex, s, ©Location); } } } @@ -791,17 +791,17 @@ void IsoMap::drawTile(SURFACE *ds, uint16 tileIndex, const Point &point, const L } break; case kMaskRuleYMIN: - if (location->u() + location->v() < THRESH0 * 2) { + if (location->uv() < THRESH0 * 2) { return; } break; case kMaskRuleYMID: - if (location->u() + location->v() < THRESH8 * 2) { + if (location->uv() < THRESH8 * 2) { return; } break; case kMaskRuleYMAX: - if (location->u() + location->v() < THRESH16 * 2) { + if (location->uv() < THRESH16 * 2) { return; } break; diff --git a/saga/isomap.h b/saga/isomap.h index 185155d3fb..ebb8aa083c 100644 --- a/saga/isomap.h +++ b/saga/isomap.h @@ -91,19 +91,19 @@ struct IsoTileData { size_t offset; uint16 terrainMask; byte FGDBGDAttr; - int8 GetMaskRule() { + int8 GetMaskRule() const { return attributes & 0x0F; } - byte GetFGDAttr() { + byte GetFGDAttr() const { return FGDBGDAttr >> 4; } - byte GetBGDAttr() { + byte GetBGDAttr() const { return FGDBGDAttr & 0x0F; } - uint16 GetFGDMask() { + uint16 GetFGDMask() const { return 1 << GetFGDAttr(); } - uint16 GetBGDMask() { + uint16 GetBGDMask() const { return 1 << GetBGDAttr(); } }; @@ -160,7 +160,7 @@ public: void adjustScroll(bool jump); void tileCoordsToScreenPoint(const Location &location, Point &position) { position.x = location.u() - location.v() + (128 * SAGA_TILEMAP_W) - _viewScroll.x + 16; - position.y = -((location.u() + location.v()) >> 1) + (128 * SAGA_TILEMAP_W) - _viewScroll.y - location.z; + position.y = -(location.uv() >> 1) + (128 * SAGA_TILEMAP_W) - _viewScroll.y - location.z; } void screenPointToTileCoords(const Point &position, Location &location); void placeOnTileMap(const Location &start, Location &result, int16 distance, uint16 direction); -- cgit v1.2.3