summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-09-03 20:57:06 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2006-09-03 20:57:06 +0000
commit2f0e3106582a3442220b2fbf5580d3d1659efc17 (patch)
tree02ed605b85667039367a4d67060865aa4fa829e3
parent7b1bef8072307e6b5f1a37c35e113251a4f91bf4 (diff)
downloadmanaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.tar.gz
manaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.tar.bz2
manaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.tar.xz
manaserv-2f0e3106582a3442220b2fbf5580d3d1659efc17.zip
Fixed desynchronization due to wrong cost of diagonal moves.
-rw-r--r--ChangeLog1
-rw-r--r--src/object.cpp20
2 files changed, 15 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 457cacfe..4645e688 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
handling of flags for move messages.
* src/mapcomposite.h, src/state.cpp, src/mapcomposite.cpp: Added map
partitioning to reduce quadratic behavior when checking object ranges.
+ * src/object.cpp: Fixed cost of diagonal moves.
2006-09-02 Bjørn Lindeijer <bjorn@lindeijer.nl>
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);