summaryrefslogtreecommitdiff
path: root/src/net/playerhandler.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-08-28 18:32:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-13 20:21:56 +0100
commit0a2fc4d340911b28b9dc6b3b23c69e9fe7729082 (patch)
treebddecd4581bb8591d0ac079a48eec3a66c411238 /src/net/playerhandler.cpp
parent5c4b6363d5065fb98a53b6981f5a590aaa37829b (diff)
downloadmana-0a2fc4d340911b28b9dc6b3b23c69e9fe7729082.tar.gz
mana-0a2fc4d340911b28b9dc6b3b23c69e9fe7729082.tar.bz2
mana-0a2fc4d340911b28b9dc6b3b23c69e9fe7729082.tar.xz
mana-0a2fc4d340911b28b9dc6b3b23c69e9fe7729082.zip
Added support for being effects through the eAthena levelup message, and check
whether the being exists before referencing it. Re-enabled proper MP bar display. Improved handling of a warp to the same map. (patch by Fate) (cherry picked from eAthena client, the part about the levelup message doesn't apply, and we now seem to have a second "effect manager"...) Conflicts: ChangeLog src/being.cpp src/being.h src/engine.cpp src/engine.h src/gui/ministatus.cpp src/net/beinghandler.cpp src/net/playerhandler.cpp src/net/protocol.h
Diffstat (limited to 'src/net/playerhandler.cpp')
-rw-r--r--src/net/playerhandler.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp
index ad271f15..beb59250 100644
--- a/src/net/playerhandler.cpp
+++ b/src/net/playerhandler.cpp
@@ -50,6 +50,11 @@ extern BuyDialog *buyDialog;
extern SellDialog *sellDialog;
extern Window *buySellDialog;
+/* Max. distance we are willing to scroll after a teleport;
+ * everything beyond will reset the port hard.
+ */
+static const int MAP_TELEPORT_SCROLL_DISTANCE = 8 * 32;
+
/**
* Listener used for handling the overweigth message.
*/
@@ -292,6 +297,7 @@ PlayerHandler::handleMapChangeMessage(MessageIn &msg)
const std::string mapName = msg.readString();
const unsigned short x = msg.readInt16();
const unsigned short y = msg.readInt16();
+ const bool nearby = (engine->getCurrentMapName() == mapName);
logger->log("Changing map to %s (%d, %d)", mapName.c_str(), x, y);
@@ -301,8 +307,16 @@ PlayerHandler::handleMapChangeMessage(MessageIn &msg)
current_npc = 0;
const Vector &playerPos = player_node->getPosition();
- const float scrollOffsetX = x - (int) playerPos.x;
- const float scrollOffsetY = y - (int) playerPos.y;
+ float scrollOffsetX = 0.0f;
+ float scrollOffsetY = 0.0f;
+
+ /* Scroll if neccessary */
+ if (!nearby
+ || (abs(x - (int) playerPos.x) > MAP_TELEPORT_SCROLL_DISTANCE)
+ || (abs(y - (int) playerPos.y) > MAP_TELEPORT_SCROLL_DISTANCE)) {
+ scrollOffsetX = x - (int) playerPos.x;
+ scrollOffsetY = y - (int) playerPos.y;
+ }
player_node->setAction(Being::STAND);
player_node->setPosition(x, y);