diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/game.cpp | 58 | ||||
-rw-r--r-- | src/inventory.h | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 16 | ||||
-rw-r--r-- | src/localplayer.h | 12 | ||||
-rw-r--r-- | src/main.cpp | 25 | ||||
-rw-r--r-- | src/net/ea/generalhandler.cpp | 30 | ||||
-rw-r--r-- | src/net/ea/generalhandler.h | 6 | ||||
-rw-r--r-- | src/net/generalhandler.h | 4 | ||||
-rw-r--r-- | src/net/tmwserv/generalhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/tmwserv/generalhandler.h | 4 |
12 files changed, 81 insertions, 94 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d1dd1ea..82a0267d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -219,6 +219,8 @@ SET(SRCS gui/skin.h gui/speechbubble.cpp gui/speechbubble.h + gui/storagewindow.cpp + gui/storagewindow.h gui/table.cpp gui/table.h gui/table_model.cpp @@ -418,8 +420,6 @@ SET(SRCS_EA gui/skill.h gui/status.cpp gui/status.h - gui/storagewindow.cpp - gui/storagewindow.h net/ea/gui/partytab.cpp net/ea/gui/partytab.h net/ea/adminhandler.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 6bef1960..2d093127 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -172,6 +172,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ gui/skin.h \ gui/speechbubble.cpp \ gui/speechbubble.h \ + gui/storagewindow.cpp \ + gui/storagewindow.h \ gui/table.cpp \ gui/table.h \ gui/table_model.cpp \ @@ -466,8 +468,6 @@ tmw_SOURCES += \ gui/skill.h \ gui/status.cpp \ gui/status.h \ - gui/storagewindow.cpp \ - gui/storagewindow.h \ net/ea/gui/partytab.cpp \ net/ea/gui/partytab.h \ net/ea/adminhandler.cpp \ diff --git a/src/game.cpp b/src/game.cpp index 76d2d883..f264ad27 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -79,11 +79,10 @@ #include "gui/buddywindow.h" #include "gui/guildwindow.h" #include "gui/magic.h" -#include "gui/npcpostdialog.h" #include "gui/quitdialog.h" -#else -#include "gui/storagewindow.h" #endif +#include "gui/npcpostdialog.h" +#include "gui/storagewindow.h" #include "net/generalhandler.h" #include "net/maphandler.h" @@ -92,34 +91,6 @@ #include "net/tmwserv/inventoryhandler.h" #include "net/ea/inventoryhandler.h" -#ifdef TMWSERV_SUPPORT -#include "net/tmwserv/chathandler.h" -#include "net/tmwserv/itemhandler.h" -#include "net/tmwserv/npchandler.h" -#include "net/tmwserv/playerhandler.h" -#include "net/tmwserv/tradehandler.h" -#include "net/tmwserv/network.h" -#include "net/tmwserv/beinghandler.h" -#include "net/tmwserv/buysellhandler.h" -#include "net/tmwserv/effecthandler.h" -#include "net/tmwserv/guildhandler.h" -#include "net/tmwserv/partyhandler.h" -#else -#include "net/ea/adminhandler.h" -#include "net/ea/chathandler.h" -#include "net/ea/beinghandler.h" -#include "net/ea/buysellhandler.h" -#include "net/ea/equipmenthandler.h" -#include "net/ea/itemhandler.h" -#include "net/ea/maphandler.h" -#include "net/ea/npchandler.h" -#include "net/ea/network.h" -#include "net/ea/playerhandler.h" -#include "net/ea/partyhandler.h" -#include "net/ea/tradehandler.h" -#include "net/ea/skillhandler.h" -#endif - #include "resources/imagewriter.h" #include "utils/gettext.h" @@ -165,10 +136,9 @@ PartyWindow *partyWindow; BuddyWindow *buddyWindow; GuildWindow *guildWindow; MagicDialog *magicDialog; +#endif NpcPostDialog *npcPostDialog; -#else StorageWindow *storageWindow; -#endif Minimap *minimap; EquipmentWindow *equipmentWindow; TradeWindow *tradeWindow; @@ -252,7 +222,6 @@ static void createGuiWindows() npcStringDialog = new NpcStringDialog; partyWindow = new PartyWindow; #ifdef TMWSERV_SUPPORT - npcPostDialog = new NpcPostDialog; magicDialog = new MagicDialog; equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); buddyWindow = new BuddyWindow; @@ -260,8 +229,9 @@ static void createGuiWindows() #else buySellDialog = new BuySellDialog; equipmentWindow = new EquipmentWindow; - storageWindow = new StorageWindow; #endif + npcPostDialog = new NpcPostDialog; + storageWindow = new StorageWindow; menuWindow = new MenuWindow; statusWindow = new StatusWindow(player_node); miniStatusWindow = new MiniStatusWindow; @@ -320,6 +290,7 @@ static void createGuiWindows() */ static void destroyGuiWindows() { + Net::getGeneralHandler()->guiWindowsUnloaded(); logger->setChatWindow(NULL); delete localChatTab; // Need to do this first, so it can remove itself delete chatWindow; @@ -338,8 +309,8 @@ static void destroyGuiWindows() delete npcTextDialog; delete npcStringDialog; delete partyWindow; -#ifdef TMWSERV_SUPPORT delete npcPostDialog; +#ifdef TMWSERV_SUPPORT delete magicDialog; delete buddyWindow; delete guildWindow; @@ -352,9 +323,7 @@ static void destroyGuiWindows() delete debugWindow; delete itemShortcutWindow; delete emoteShortcutWindow; -#ifdef EATHENA_SUPPORT delete storageWindow; -#endif } Game::Game(): @@ -549,7 +518,6 @@ void Game::logic() // Handle network stuff Net::getGeneralHandler()->flushNetwork(); -#ifdef EATHENA_SUPPORT // TODO: TMWServ notification if (!Net::getGeneralHandler()->isNetworkConnected()) { if (!disconnectedDialog) @@ -562,7 +530,6 @@ void Game::logic() disconnectedDialog->requestMoveToTop(); } } -#endif } } @@ -591,7 +558,6 @@ void Game::handleInput() return; } -#ifdef TMWSERV_SUPPORT // send straight to gui for certain windows if (npcPostDialog->isVisible()) { @@ -606,7 +572,6 @@ void Game::handleInput() } return; } -#endif // Mode switch to emotes if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) @@ -928,10 +893,7 @@ void Game::handleInput() return; // Moving player around - if (player_node->mAction != Being::DEAD && -#ifdef EATHENA_SUPPORT - current_npc == 0 && -#endif + if (player_node->mAction != Being::DEAD && current_npc == 0 && !chatWindow->isInputFocused()) { // Get the state of the keyboard keys @@ -1075,13 +1037,11 @@ void Game::handleInput() } } -#ifdef EATHENA_SUPPORT - // Stop attacking if shift is pressed + // Stop attacking if the right key is pressed if (keyboard.isKeyActive(keyboard.KEY_TARGET)) { player_node->stopAttack(); } -#endif if (joystick) { diff --git a/src/inventory.h b/src/inventory.h index 358c93e3..cfd72089 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -26,10 +26,10 @@ class Item; #ifdef EATHENA_SUPPORT const int INVENTORY_SIZE = 102; -const int STORAGE_SIZE = 301; #else const int INVENTORY_SIZE = 50; #endif +const int STORAGE_SIZE = 301; class Inventory { diff --git a/src/localplayer.cpp b/src/localplayer.cpp index d44e28c0..0c5bde22 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -102,10 +102,10 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mStatsPointsToAttribute(0), mEquipment(new Equipment), mXp(0), - mInStorage(false), mTargetTime(-1), - mLastTarget(-1), #endif + mLastTarget(-1), + mInStorage(false), mLevel(1), mMoney(0), mTotalWeight(1), mMaxWeight(1), @@ -118,10 +118,9 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mInventory(new Inventory(INVENTORY_SIZE)), #ifdef TMWSERV_SUPPORT mLocalWalkTime(-1), - mExpMessageTime(0) -#else - mStorage(new Inventory(STORAGE_SIZE)) + mExpMessageTime(0), #endif + mStorage(new Inventory(STORAGE_SIZE)) { // Variable to keep the local player from doing certain actions before a map // is initialized. e.g. drawing a player's name using the TextManager, since @@ -789,6 +788,8 @@ void LocalPlayer::attack(Being *target, bool keep) stopAttack(); } +#endif // no TMWSERV_SUPPORT + void LocalPlayer::stopAttack() { if (mTarget) @@ -800,8 +801,6 @@ void LocalPlayer::stopAttack() mLastTarget = -1; } -#endif // no TMWSERV_SUPPORT - void LocalPlayer::revive() { Net::getPlayerHandler()->respawn(); @@ -949,20 +948,19 @@ bool LocalPlayer::withinAttackRange(Being *target) void LocalPlayer::setGotoTarget(Being *target) { + mLastTarget = -1; #ifdef TMWSERV_SUPPORT mTarget = target; mGoingToTarget = true; const Vector &targetPos = target->getPosition(); setDestination(targetPos.x, targetPos.y); #else - mLastTarget = -1; setTarget(target); mGoingToTarget = true; setDestination(target->mX, target->mY); #endif } - extern MiniStatusWindow *miniStatusWindow; void LocalPlayer::handleStatusEffect(StatusEffect *effect, int effectId) diff --git a/src/localplayer.h b/src/localplayer.h index c93368a5..1f3be912 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -165,12 +165,10 @@ class LocalPlayer : public Player */ Inventory *getInventory() const { return mInventory; } -#ifdef EATHENA_SUPPORT /** * Returns the player's storage */ Inventory *getStorage() const { return mStorage; } -#endif #ifdef TMWSERV_SUPPORT /** @@ -268,9 +266,7 @@ class LocalPlayer : public Player */ virtual void setGM(); -#ifdef EATHENA_SUPPORT void stopAttack(); -#endif /** * Overridden to do nothing. The attacks of the local player are @@ -356,13 +352,13 @@ class LocalPlayer : public Player */ void pickedUp(const std::string &item); -#ifdef EATHENA_SUPPORT /** * Accessors for mInStorage */ bool getInStorage() { return mInStorage; } void setInStorage(bool inStorage); +#ifdef EATHENA_SUPPORT /** * Sets the amount of XP. Shows XP gaining effect if the player is on * a map. @@ -488,12 +484,12 @@ class LocalPlayer : public Player void walk(unsigned char dir); + bool mInStorage; /**< Whether storage is currently accessible */ #ifdef EATHENA_SUPPORT int mXp; /**< Experience points. */ - bool mInStorage; /**< Whether storage is currently accessible */ int mTargetTime; /** How long the being has been targeted **/ - int mLastTarget; /** Time stamp of last targeting action, -1 if none. */ #endif + int mLastTarget; /** Time stamp of last targeting action, -1 if none. */ #ifdef TMWSERV_SUPPORT // Character status: @@ -532,9 +528,7 @@ class LocalPlayer : public Player messages flooding */ #endif -#ifdef EATHENA_SUPPORT Inventory *mStorage; -#endif // Load the target cursors into memory void initTargetCursor(); diff --git a/src/main.cpp b/src/main.cpp index 913b7ae9..5bd82e33 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -974,7 +974,7 @@ int main(int argc, char *argv[]) #ifdef TMWSERV_SUPPORT Net::initialize(); - new TmwServ::GeneralHandler; // Currently registers itself + new TmwServ::GeneralHandler; // Currently doesn't need registration #else Network *network = new Network; EAthena::GeneralHandler *generalHandler = new EAthena::GeneralHandler; @@ -1029,25 +1029,10 @@ int main(int argc, char *argv[]) guiInput->pushInput(event); } -#ifdef TMWSERV_SUPPORT - Net::flush(); -#else - network->flush(); - network->dispatchMessages(); -#endif + Net::getGeneralHandler()->flushNetwork(); gui->logic(); -#ifdef EATHENA_SUPPORT - if (network->getState() == Network::NET_ERROR) - { - state = STATE_ERROR; - - if (!network->getError().empty()) - errorMessage = network->getError(); - else - errorMessage = _("Got disconnected from server!"); - } -#endif + Net::getGeneralHandler()->tick(); if (progressBar->isVisible()) { @@ -1595,9 +1580,7 @@ int main(int argc, char *argv[]) delete guiPalette; -#ifdef EATHENA_SUPPORT - delete network; -#endif + //delete Net::getGeneralHandler(); logger->log("Quitting"); exitEngine(); diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp index 91406278..7d5a7d40 100644 --- a/src/net/ea/generalhandler.cpp +++ b/src/net/ea/generalhandler.cpp @@ -82,6 +82,11 @@ GeneralHandler::GeneralHandler(): generalHandler = this; } +GeneralHandler::~GeneralHandler() +{ + delete mNetwork; +} + void GeneralHandler::handleMessage(MessageIn &msg) { int code; @@ -140,11 +145,13 @@ void GeneralHandler::load() void GeneralHandler::unload() { mNetwork->clearHandlers(); - delete partyTab; } void GeneralHandler::flushNetwork() { + if (!mNetwork) + return; + mNetwork->flush(); mNetwork->dispatchMessages(); } @@ -154,9 +161,30 @@ bool GeneralHandler::isNetworkConnected() return mNetwork->isConnected(); } +void GeneralHandler::tick() +{ + if (!mNetwork) + return; + + if (mNetwork->getState() == Network::NET_ERROR) + { + state = STATE_ERROR; + + if (!mNetwork->getError().empty()) + errorMessage = mNetwork->getError(); + else + errorMessage = _("Got disconnected from server!"); + } +} + void GeneralHandler::guiWindowsLoaded() { partyTab = new PartyTab; } +void GeneralHandler::guiWindowsUnloaded() +{ + delete partyTab; +} + } // namespace EAthena diff --git a/src/net/ea/generalhandler.h b/src/net/ea/generalhandler.h index 3e2a6707..ebbc84ca 100644 --- a/src/net/ea/generalhandler.h +++ b/src/net/ea/generalhandler.h @@ -33,6 +33,8 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler public: GeneralHandler(); + ~GeneralHandler(); + void handleMessage(MessageIn &msg); void load(); @@ -43,8 +45,12 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler bool isNetworkConnected(); + void tick(); + void guiWindowsLoaded(); + void guiWindowsUnloaded(); + protected: MessageHandlerPtr mAdminHandler; MessageHandlerPtr mBeingHandler; diff --git a/src/net/generalhandler.h b/src/net/generalhandler.h index 08c08b13..57599ba1 100644 --- a/src/net/generalhandler.h +++ b/src/net/generalhandler.h @@ -34,7 +34,11 @@ class GeneralHandler virtual bool isNetworkConnected() = 0; + virtual void tick() = 0; + virtual void guiWindowsLoaded() = 0; + + virtual void guiWindowsUnloaded() = 0; }; } diff --git a/src/net/tmwserv/generalhandler.cpp b/src/net/tmwserv/generalhandler.cpp index e9b06270..98c764c5 100644 --- a/src/net/tmwserv/generalhandler.cpp +++ b/src/net/tmwserv/generalhandler.cpp @@ -120,9 +120,19 @@ bool GeneralHandler::isNetworkConnected() return true; } +void GeneralHandler::tick() +{ + // TODO +} + void GeneralHandler::guiWindowsLoaded() { // TODO } +void GeneralHandler::guiWindowsUnloaded() +{ + // TODO +} + } // namespace TmwServ diff --git a/src/net/tmwserv/generalhandler.h b/src/net/tmwserv/generalhandler.h index 81a41608..08e18850 100644 --- a/src/net/tmwserv/generalhandler.h +++ b/src/net/tmwserv/generalhandler.h @@ -41,8 +41,12 @@ class GeneralHandler : public Net::GeneralHandler bool isNetworkConnected(); + void tick(); + void guiWindowsLoaded(); + void guiWindowsUnloaded(); + protected: MessageHandlerPtr mBeingHandler; MessageHandlerPtr mBuySellHandler; |