summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorChuck Miller <shadowmil@gmail.com>2009-07-27 19:32:32 -0400
committerChuck Miller <shadowmil@gmail.com>2009-07-27 19:33:40 -0400
commit5a27795be5450add2cf3da3c03b2fe8771325e3e (patch)
treedaedd1beba82a87966317b81c92f9662caae2dda /src/net
parent99648c2c8693de68ebe0449e139413864e5dd6f1 (diff)
downloadmana-5a27795be5450add2cf3da3c03b2fe8771325e3e.tar.gz
mana-5a27795be5450add2cf3da3c03b2fe8771325e3e.tar.bz2
mana-5a27795be5450add2cf3da3c03b2fe8771325e3e.tar.xz
mana-5a27795be5450add2cf3da3c03b2fe8771325e3e.zip
Makes mX and mY in the being class private
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/beinghandler.cpp23
-rw-r--r--src/net/ea/maphandler.cpp9
-rw-r--r--src/net/ea/playerhandler.cpp11
3 files changed, 24 insertions, 19 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index f149f15f..1d780a60 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -194,14 +194,15 @@ void BeingHandler::handleMessage(MessageIn &msg)
Uint16 srcX, srcY, dstX, dstY;
msg.readCoordinatePair(srcX, srcY, dstX, dstY);
dstBeing->setAction(Being::STAND);
- dstBeing->mX = srcX;
- dstBeing->mY = srcY;
+ dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
}
else
{
Uint8 dir;
- msg.readCoordinates(dstBeing->mX, dstBeing->mY, dir);
+ Uint16 x, y;
+ msg.readCoordinates(x, y, dir);
+ dstBeing->setTileCoords(x, y);
dstBeing->setDirection(dir);
}
@@ -234,8 +235,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
if (dstBeing) {
dstBeing->setAction(Being::STAND);
- dstBeing->mX = srcX;
- dstBeing->mY = srcY;
+ dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
}
@@ -515,14 +515,15 @@ void BeingHandler::handleMessage(MessageIn &msg)
{
Uint16 srcX, srcY, dstX, dstY;
msg.readCoordinatePair(srcX, srcY, dstX, dstY);
- dstBeing->mX = srcX;
- dstBeing->mY = srcY;
+ dstBeing->setTileCoords(srcX, srcY);
dstBeing->setDestination(dstX, dstY);
}
else
{
Uint8 dir;
- msg.readCoordinates(dstBeing->mX, dstBeing->mY, dir);
+ Uint16 x, y;
+ msg.readCoordinates(x, y, dir);
+ dstBeing->setTileCoords(x, y);
dstBeing->setDirection(dir);
}
@@ -577,8 +578,10 @@ void BeingHandler::handleMessage(MessageIn &msg)
if (mSync || id != player_node->getId()) {
dstBeing = beingManager->findBeing(id);
if (dstBeing) {
- dstBeing->mX = msg.readInt16();
- dstBeing->mY = msg.readInt16();
+ Uint16 x, y;
+ x = msg.readInt16();
+ y = msg.readInt16();
+ dstBeing->setTileCoords(x, y);
if (dstBeing->mAction == Being::WALK) {
dstBeing->mFrame = 0;
dstBeing->setAction(Being::STAND);
diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp
index a466e022..3036612e 100644
--- a/src/net/ea/maphandler.cpp
+++ b/src/net/ea/maphandler.cpp
@@ -61,14 +61,17 @@ void MapHandler::handleMessage(MessageIn &msg)
switch (msg.getId())
{
case SMSG_MAP_LOGIN_SUCCESS:
+ {
+ Uint16 x, y;
msg.readInt32(); // server tick
- msg.readCoordinates(player_node->mX, player_node->mY, direction);
+ msg.readCoordinates(x, y, direction);
msg.skip(2); // unknown
logger->log("Protocol: Player start position: (%d, %d), Direction: %d",
- player_node->mX, player_node->mY, direction);
+ x, y, direction);
state = STATE_GAME;
+ player_node->setTileCoords(x, y);
game = new Game;
- break;
+ } break;
case SMSG_SERVER_PING:
// We ignore this for now
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 3bc11b83..edd58562 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -200,17 +200,16 @@ void PlayerHandler::handleMessage(MessageIn &msg)
/* Scroll if neccessary */
if (!nearby
- || (abs(x - player_node->mX) > MAP_TELEPORT_SCROLL_DISTANCE)
- || (abs(y - player_node->mY) > MAP_TELEPORT_SCROLL_DISTANCE))
+ || (abs(x - player_node->getTileX()) > MAP_TELEPORT_SCROLL_DISTANCE)
+ || (abs(y - player_node->getTileY()) > MAP_TELEPORT_SCROLL_DISTANCE))
{
- scrollOffsetX = (x - player_node->mX) * 32;
- scrollOffsetY = (y - player_node->mY) * 32;
+ scrollOffsetX = (x - player_node->getTileX()) * 32;
+ scrollOffsetY = (y - player_node->getTileY()) * 32;
}
player_node->setAction(Being::STAND);
player_node->mFrame = 0;
- player_node->mX = x;
- player_node->mY = y;
+ player_node->setTileCoords(x, y);
logger->log("Adjust scrolling by %d:%d", (int) scrollOffsetX,
(int) scrollOffsetY);