diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-09-03 20:57:06 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-09-03 20:57:06 +0000 |
commit | 2f0e3106582a3442220b2fbf5580d3d1659efc17 (patch) | |
tree | 02ed605b85667039367a4d67060865aa4fa829e3 /src | |
parent | 7b1bef8072307e6b5f1a37c35e113251a4f91bf4 (diff) | |
download | manaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.tar.gz manaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.tar.bz2 manaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.tar.xz manaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.zip |
Fixed desynchronization due to wrong cost of diagonal moves.
Diffstat (limited to 'src')
-rw-r--r-- | src/object.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/object.cpp b/src/object.cpp index f94b5ace..6f4c7ac6 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -48,23 +48,31 @@ void MovingObject::move() mActionTime = 0; return; } - // last tile center is skipped - path.pop_back(); + } + else + { + // moving while staying on the same tile is free + setPosition(mDst); + mActionTime = 0; + return; } + PATH_NODE prev(tileSX, tileSY); Point pos; do { - mActionTime += mSpeed; + PATH_NODE next = path.front(); + path.pop_front(); + mActionTime += (prev.x != next.x && prev.y != next.y) + ? mSpeed * 362 / 256 : mSpeed; if (path.empty()) { // skip last tile center pos = mDst; break; } - pos.x = path.front().x * 32 + 16; - pos.y = path.front().y * 32 + 16; - path.pop_front(); + pos.x = next.x * 32 + 16; + pos.y = next.y * 32 + 16; } while (mActionTime < 100); setPosition(pos); |