diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-05 22:15:43 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-06 21:25:37 +0100 |
commit | 242e3bb8d92def67d5c30f2f2fd974cfb117ec04 (patch) | |
tree | 7f247e04e238a0edc0281ec8ed85539b2be81137 /src/net/ea | |
parent | 51e14c9d7aab75fe60f68d4943759eef66eafe9a (diff) | |
download | mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.tar.gz mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.tar.bz2 mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.tar.xz mana-242e3bb8d92def67d5c30f2f2fd974cfb117ec04.zip |
Merged the Engine class into the Game class
There was little point in keeping the Engine class separate. It wasn't
an engine at all, but only kept track of the currently active map, a job
more suitable for the Game class anyway.
Diffstat (limited to 'src/net/ea')
-rw-r--r-- | src/net/ea/itemhandler.cpp | 25 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 16 |
2 files changed, 19 insertions, 22 deletions
diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp index 2f65c064..8b8f2b22 100644 --- a/src/net/ea/itemhandler.cpp +++ b/src/net/ea/itemhandler.cpp @@ -21,7 +21,6 @@ #include "net/ea/itemhandler.h" -#include "engine.h" #include "flooritemmanager.h" #include "net/messagein.h" @@ -43,28 +42,24 @@ ItemHandler::ItemHandler() void ItemHandler::handleMessage(Net::MessageIn &msg) { - Uint32 id; - Uint16 x, y; - int itemId; - switch (msg.getId()) { case SMSG_ITEM_VISIBLE: case SMSG_ITEM_DROPPED: - id = msg.readInt32(); - itemId = msg.readInt16(); - msg.readInt8(); // identify flag - x = msg.readInt16(); - y = msg.readInt16(); - msg.skip(4); // amount,subX,subY / subX,subY,amount + { + int id = msg.readInt32(); + int itemId = msg.readInt16(); + msg.readInt8(); // identify flag + int x = msg.readInt16(); + int y = msg.readInt16(); + msg.skip(4); // amount,subX,subY / subX,subY,amount - floorItemManager->create(id, itemId, x, y, engine->getCurrentMap()); + floorItemManager->create(id, itemId, x, y); + } break; case SMSG_ITEM_REMOVE: - FloorItem *item; - item = floorItemManager->findById(msg.readInt32()); - if (item) + if (FloorItem *item = floorItemManager->findById(msg.readInt32())) floorItemManager->destroy(item); break; } diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 156e8b26..0c290815 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -21,7 +21,7 @@ #include "net/ea/playerhandler.h" -#include "engine.h" +#include "game.h" #include "localplayer.h" #include "log.h" #include "npc.h" @@ -179,9 +179,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) case SMSG_PLAYER_WARP: { std::string mapPath = msg.readString(16); - bool nearby; - Uint16 x = msg.readInt16(); - Uint16 y = msg.readInt16(); + int x = msg.readInt16(); + int y = msg.readInt16(); logger->log("Warping to %s (%d, %d)", mapPath.c_str(), x, y); @@ -191,17 +190,20 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) */ player_node->stopAttack(); - nearby = (engine->getCurrentMapName() == mapPath); + Game *game = Game::instance(); + + const std::string ¤tMap = game->getCurrentMapName(); + bool sameMap = (currentMap == mapPath); // Switch the actual map, deleting the previous one if necessary mapPath = mapPath.substr(0, mapPath.rfind(".")); - engine->changeMap(mapPath); + game->changeMap(mapPath); float scrollOffsetX = 0.0f; float scrollOffsetY = 0.0f; /* Scroll if neccessary */ - if (!nearby + if (!sameMap || (abs(x - player_node->getTileX()) > MAP_TELEPORT_SCROLL_DISTANCE) || (abs(y - player_node->getTileY()) > MAP_TELEPORT_SCROLL_DISTANCE)) { |