summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-27 17:46:14 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-27 17:46:14 +0000
commitc8c6b8870852dac9c744d4a897db67821d9cbc62 (patch)
treec6f98d86303f6a15053781744e5667ed271c1ce7
parentbd0a58997677f4a73a2f5a3c5f4a30835d79c91b (diff)
downloadmanaserv-c8c6b8870852dac9c744d4a897db67821d9cbc62.tar.gz
manaserv-c8c6b8870852dac9c744d4a897db67821d9cbc62.tar.bz2
manaserv-c8c6b8870852dac9c744d4a897db67821d9cbc62.tar.xz
manaserv-c8c6b8870852dac9c744d4a897db67821d9cbc62.zip
Still got rid of ps, pn, po and oo, and fixed efficiency issue.
-rw-r--r--src/state.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/state.cpp b/src/state.cpp
index dc21e766..fb5ff7f5 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -74,9 +74,6 @@ State::update()
for (Players::iterator p = players.begin(),
p_end = players.end(); p != p_end; ++p)
{
- Point ps = (*p)->getXY();
- Point pn = (*p)->getNextPosition();
- bool po = !(*p)->isNew(); // Is p old?
MessageOut msg(GPMSG_BEINGS_MOVE);
for (Movings::iterator o = movings.begin(),
@@ -84,12 +81,13 @@ State::update()
{
Point os = (*o)->getXY();
Point on = (*o)->getNextPosition();
- bool oo = po && !(*o)->isNew(); // Are p and o both old?
- /* Look whether p and o "were" around the last time and whether
- they "will" be around the next time. */
- bool wereInRange = ps.inRangeOf(os) && oo;
- bool willBeInRange = pn.inRangeOf(on);
+ /* Check whether this player and this moving object were around
+ * the last time and whether they will be around the next time.
+ */
+ bool wereInRange = (*p)->getXY().inRangeOf(os) &&
+ !(*p)->isNew() && !(*o)->isNew();
+ bool willBeInRange = (*p)->getNextPosition().inRangeOf(on);
if (!wereInRange)
{
@@ -188,6 +186,7 @@ State::removeObject(ObjectPtr objectPtr)
msg.writeByte(OBJECT_PLAYER);
msg.writeLong(objectPtr->getID());
+ Point objectPosition = objectPtr->getXY();
Players &players = maps[mapId].players;
Players::iterator p_end = players.end(), j = p_end;
for (Players::iterator p = players.begin(); p != p_end; ++p)
@@ -196,7 +195,7 @@ State::removeObject(ObjectPtr objectPtr)
{
j = p;
}
- else if (objectPtr->getXY().inRangeOf((*p)->getXY()))
+ else if (objectPosition.inRangeOf((*p)->getXY()))
{
gameHandler->sendTo(*p, msg);
}