From 712ca58c011123505c807266dcc8d9d84ca1aa44 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 19:44:23 +0100 Subject: Made eAthena's Network class statically accessible Now the instance doesn't need to be passed into the MessageOut class anymore. Expect a lot of cleanup in the next commit. --- src/engine.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/engine.cpp') diff --git a/src/engine.cpp b/src/engine.cpp index da4eb336..13563e66 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -151,8 +151,7 @@ void Engine::changeMap(const std::string &mapPath) #ifdef EATHENA_SUPPORT // Send "map loaded" - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_MAP_LOADED); + MessageOut outMsg(CMSG_MAP_LOADED); #endif } -- cgit v1.2.3-70-g09d2 From 60f10c242fc4f99b0ab0f8d8c6d4b4acde0022cd Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 27 Mar 2009 21:13:02 +0100 Subject: Clean up of most of the Network pointers Now that messages can be sent without requiring a pointer to the Network instance, a lot of cleanup was possible. --- src/beingmanager.cpp | 7 ++----- src/beingmanager.h | 10 +--------- src/commandhandler.cpp | 5 ----- src/commandhandler.h | 12 ------------ src/engine.cpp | 6 ------ src/engine.h | 10 ---------- src/game.cpp | 34 ++++++---------------------------- src/gui/buy.cpp | 7 ------- src/gui/buy.h | 10 ---------- src/gui/buysell.cpp | 4 ++-- src/gui/buysell.h | 7 +------ src/gui/char_select.cpp | 17 +++++++---------- src/gui/char_select.h | 14 ++------------ src/gui/chat.cpp | 7 +------ src/gui/chat.h | 8 -------- src/gui/npc_text.cpp | 7 ------- src/gui/npc_text.h | 10 ---------- src/gui/npcintegerdialog.cpp | 7 ------- src/gui/npcintegerdialog.h | 10 ---------- src/gui/npclistdialog.cpp | 7 ------- src/gui/npclistdialog.h | 11 ----------- src/gui/npcstringdialog.cpp | 7 ------- src/gui/npcstringdialog.h | 11 ----------- src/gui/sell.cpp | 6 ------ src/gui/sell.h | 10 ---------- src/gui/storagewindow.cpp | 3 +-- src/gui/storagewindow.h | 4 +--- src/gui/trade.cpp | 5 ----- src/gui/trade.h | 11 ----------- src/localplayer.cpp | 1 - src/localplayer.h | 8 -------- src/main.cpp | 2 +- src/net/ea/network.h | 2 -- src/npc.cpp | 9 --------- src/npc.h | 14 +++----------- src/party.cpp | 5 ++--- src/party.h | 11 ++++------- 37 files changed, 34 insertions(+), 285 deletions(-) (limited to 'src/engine.cpp') diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index ae9ee787..9c671808 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -59,12 +59,9 @@ class FindBeingFunctor Being::Type type; } beingFinder; -#ifdef EATHENA_SUPPORT -BeingManager::BeingManager(Network *network): - mNetwork(network) +BeingManager::BeingManager() { } -#endif BeingManager::~BeingManager() { @@ -111,7 +108,7 @@ Being *BeingManager::createBeing(int id, Uint16 job) if (job <= 25 || (job >= 4001 && job <= 4049)) being = new Player(id, job, mMap); else if (job >= 46 && job <= 1000) - being = new NPC(id, job, mMap, mNetwork); + being = new NPC(id, job, mMap); else if (job > 1000 && job <= 2000) being = new Monster(id, job, mMap); else diff --git a/src/beingmanager.h b/src/beingmanager.h index 109564fa..891a8ccb 100644 --- a/src/beingmanager.h +++ b/src/beingmanager.h @@ -26,9 +26,6 @@ class LocalPlayer; class Map; -#ifdef EATHENA_SUPPORT -class Network; -#endif typedef std::list Beings; typedef Beings::iterator BeingIterator; @@ -36,9 +33,7 @@ typedef Beings::iterator BeingIterator; class BeingManager { public: -#ifdef EATHENA_SUPPORT - BeingManager(Network *network); -#endif + BeingManager(); ~BeingManager(); @@ -130,9 +125,6 @@ class BeingManager protected: Beings mBeings; Map *mMap; -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif }; extern BeingManager *beingManager; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 73e41554..a2de2c63 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -43,12 +43,7 @@ #include "utils/stringutils.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT CommandHandler::CommandHandler() -#else -CommandHandler::CommandHandler(Network *network): - mNetwork(network) -#endif {} void CommandHandler::handleCommand(const std::string &command) diff --git a/src/commandhandler.h b/src/commandhandler.h index 2adf4e1b..43ce172f 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -24,10 +24,6 @@ #include -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * A class to parse and handle user commands */ @@ -37,11 +33,7 @@ class CommandHandler /** * Constructor */ -#ifdef TMWSERV_SUPPORT CommandHandler(); -#else - CommandHandler(Network *network); -#endif /** * Destructor @@ -143,10 +135,6 @@ class CommandHandler * Handle a present command. */ void handlePresent(const std::string &args); - -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif }; extern CommandHandler *commandHandler; diff --git a/src/engine.cpp b/src/engine.cpp index 13563e66..d13fbf3f 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -44,14 +44,8 @@ #include "utils/stringutils.h" -#ifdef TMWSERV_SUPPORT Engine::Engine(): mCurrentMap(NULL) -#else -Engine::Engine(Network *network): - mCurrentMap(NULL), - mNetwork(network) -#endif { } diff --git a/src/engine.h b/src/engine.h index 60b1f6c8..eafce3b9 100644 --- a/src/engine.h +++ b/src/engine.h @@ -25,9 +25,6 @@ #include class Map; -#ifdef EATHENA_SUPPORT -class Network; -#endif /** * Game engine. Actually hardly does anything anymore except keeping track of @@ -39,11 +36,7 @@ class Engine /** * Constructor. */ -#ifdef EATHENA_SUPPORT - Engine(Network *network); -#else Engine(); -#endif /** * Destructor. @@ -69,9 +62,6 @@ class Engine private: Map *mCurrentMap; -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif std::string mMapName; }; diff --git a/src/game.cpp b/src/game.cpp index 5b389c3f..856a5c11 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -239,14 +239,9 @@ int get_elapsed_time(int start_time) /** * Create all the various globally accessible gui windows */ -#ifdef TMWSERV_SUPPORT -void createGuiWindows() -#else -void createGuiWindows(Network *network) -#endif +static void createGuiWindows() { // Create dialogs -#ifdef TMWSERV_SUPPORT chatWindow = new ChatWindow; buyDialog = new BuyDialog; sellDialog = new SellDialog; @@ -255,6 +250,7 @@ void createGuiWindows(Network *network) npcIntegerDialog = new NpcIntegerDialog; npcListDialog = new NpcListDialog; npcStringDialog = new NpcStringDialog; +#ifdef TMWSERV_SUPPORT npcPostDialog = new NpcPostDialog; magicDialog = new MagicDialog; equipmentWindow = new EquipmentWindow(player_node->mEquipment.get()); @@ -262,17 +258,9 @@ void createGuiWindows(Network *network) guildWindow = new GuildWindow; partyWindow = new PartyWindow; #else - chatWindow = new ChatWindow(network); - buyDialog = new BuyDialog(network); - sellDialog = new SellDialog(network); - buySellDialog = new BuySellDialog(network); - tradeWindow = new TradeWindow(network); + buySellDialog = new BuySellDialog; equipmentWindow = new EquipmentWindow; - npcTextDialog = new NpcTextDialog(network); - npcIntegerDialog = new NpcIntegerDialog(network); - npcListDialog = new NpcListDialog(network); - npcStringDialog = new NpcStringDialog(network); - storageWindow = new StorageWindow(network); + storageWindow = new StorageWindow; #endif menuWindow = new MenuWindow; statusWindow = new StatusWindow(player_node); @@ -328,7 +316,7 @@ void createGuiWindows(Network *network) /** * Destroy all the globally accessible gui windows */ -void destroyGuiWindows() +static void destroyGuiWindows() { logger->setChatWindow(NULL); delete localChatTab; // Need to do this first, so it can remove itself @@ -392,20 +380,11 @@ Game::Game(Network *network): { done = false; -#ifdef TMWSERV_SUPPORT createGuiWindows(); engine = new Engine; beingManager = new BeingManager; commandHandler = new CommandHandler; -#else - createGuiWindows(network); - engine = new Engine(network); - - beingManager = new BeingManager(network); - commandHandler = new CommandHandler(network); -#endif - floorItemManager = new FloorItemManager; channelManager = new ChannelManager; effectManager = new EffectManager; @@ -425,8 +404,7 @@ Game::Game(Network *network): // Initialize beings beingManager->setPlayer(player_node); #ifdef EATHENA_SUPPORT - player_node->setNetwork(network); - playerParty = new Party(network); + playerParty = new Party; #endif Joystick::init(); diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 003e730e..6d336e4c 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -46,15 +46,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT BuyDialog::BuyDialog(): -#else -BuyDialog::BuyDialog(Network *network): -#endif Window(_("Buy")), -#ifndef TMWSERV_SUPPORT - mNetwork(network), -#endif mMoney(0), mAmountItems(0), mMaxItems(0) { setWindowName("Buy"); diff --git a/src/gui/buy.h b/src/gui/buy.h index 200394b9..1e022652 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -29,9 +29,6 @@ #include "../guichanfwd.h" -#ifndef TMWSERV_SUPPORT -class Network; -#endif class ShopItems; class ShopListBox; class ListBox; @@ -50,11 +47,7 @@ class BuyDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT BuyDialog(); -#else - BuyDialog(Network *network); -#endif /** * Destructor @@ -116,9 +109,6 @@ class BuyDialog : public Window, public gcn::ActionListener, */ void close(); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mBuyButton; gcn::Button *mQuitButton; gcn::Button *mAddMaxButton; diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index f45a5adb..8fffd3d5 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -31,8 +31,8 @@ #include "../utils/gettext.h" -BuySellDialog::BuySellDialog(Network *network): - Window(_("Shop")), mNetwork(network) +BuySellDialog::BuySellDialog(): + Window(_("Shop")) { setWindowName("BuySell"); Button *buyButton = 0; diff --git a/src/gui/buysell.h b/src/gui/buysell.h index 4b137554..ff956e09 100644 --- a/src/gui/buysell.h +++ b/src/gui/buysell.h @@ -26,8 +26,6 @@ #include "window.h" -class Network; - /** * A dialog to choose between buying or selling at a shop. * @@ -42,7 +40,7 @@ class BuySellDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - BuySellDialog(Network *network); + BuySellDialog(); /** * Check for current NPC @@ -55,9 +53,6 @@ class BuySellDialog : public Window, public gcn::ActionListener * Called when receiving actions from the widgets. */ void action(const gcn::ActionEvent &event); - - private: - Network *mNetwork; }; extern BuySellDialog *buySellDialog; diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index b6cd47d4..a0f7230e 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -100,12 +100,13 @@ void CharDeleteConfirm::action(const gcn::ActionEvent &event) CharSelectDialog::CharSelectDialog(LockedArray *charInfo, LoginData *loginData): Window(_("Account and Character Management")), - mCharInfo(charInfo), mCharSelected(false), mLoginData(loginData) + mCharInfo(charInfo), + mCharSelected(false), + mLoginData(loginData) #else -CharSelectDialog::CharSelectDialog(Network *network, - LockedArray *charInfo, +CharSelectDialog::CharSelectDialog(LockedArray *charInfo, Gender gender): - Window(_("Select Character")), mNetwork(network), + Window(_("Select Character")), mCharInfo(charInfo), mCharSelected(false), mGender(gender) @@ -261,8 +262,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) { // Start new character dialog CharCreateDialog *charCreateDialog = - new CharCreateDialog(this, mCharInfo->getPos(), - mNetwork, mGender); + new CharCreateDialog(this, mCharInfo->getPos(), mGender); charServerHandler.setCharCreateDialog(charCreateDialog); } } @@ -398,13 +398,10 @@ bool CharSelectDialog::selectByName(const std::string &name) #ifdef TMWSERV_SUPPORT CharCreateDialog::CharCreateDialog(Window *parent, int slot): #else -CharCreateDialog::CharCreateDialog(Window *parent, int slot, Network *network, +CharCreateDialog::CharCreateDialog(Window *parent, int slot, Gender gender): #endif Window(_("Create Character"), true, parent), -#ifndef TMWSERV_SUPPORT - mNetwork(network), -#endif mSlot(slot) { mPlayer = new Player(0, 0, NULL); diff --git a/src/gui/char_select.h b/src/gui/char_select.h index b29953d3..cf770010 100644 --- a/src/gui/char_select.h +++ b/src/gui/char_select.h @@ -32,8 +32,6 @@ #ifdef TMWSERV_SUPPORT #include "../logindata.h" -#else -class Network; #endif class LocalPlayer; @@ -56,8 +54,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener CharSelectDialog(LockedArray *charInfo, LoginData *loginData); #else - CharSelectDialog(Network *network, - LockedArray *charInfo, + CharSelectDialog(LockedArray *charInfo, Gender gender); #endif @@ -70,9 +67,6 @@ class CharSelectDialog : public Window, public gcn::ActionListener bool selectByName(const std::string &name); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif LockedArray *mCharInfo; gcn::Button *mSelectButton; @@ -129,8 +123,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener #ifdef TMWSERV_SUPPORT CharCreateDialog(Window *parent, int slot); #else - CharCreateDialog(Window *parent, int slot, Network *network, - Gender gender); + CharCreateDialog(Window *parent, int slot, Gender gender); #endif /** @@ -162,9 +155,6 @@ class CharCreateDialog : public Window, public gcn::ActionListener */ void attemptCharCreate(); -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::TextField *mNameField; gcn::Label *mNameLabel; gcn::Button *mNextHairColorButton; diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 5b07980b..987de11e 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -40,13 +40,8 @@ #include -#ifdef TMWSERV_SUPPORT ChatWindow::ChatWindow(): - Window("Chat"), -#else -ChatWindow::ChatWindow(Network * network): - Window(""), mNetwork(network), -#endif + Window(_("Chat")), mTmpVisible(false) { setWindowName("Chat"); diff --git a/src/gui/chat.h b/src/gui/chat.h index ac4e491e..54270055 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -40,9 +40,6 @@ class Recorder; class ScrollArea; class TabbedArea; class ItemLinkHandler; -#ifdef EATHENA_SUPPORT -class Network; -#endif class Tab; class WhisperTab; @@ -69,11 +66,7 @@ class ChatWindow : public Window, /** * Constructor. */ -#ifdef TMWSERV_SUPPORT ChatWindow(); -#else - ChatWindow(Network *network); -#endif /** * Destructor: used to write back values to the config file @@ -190,7 +183,6 @@ class ChatWindow : public Window, void adjustTabSize(); #ifdef EATHENA_SUPPORT - Network *mNetwork; char mPartyPrefix; /**< Messages beginning with the prefix are sent to the party */ #endif diff --git a/src/gui/npc_text.cpp b/src/gui/npc_text.cpp index bf7b60ed..31f48486 100644 --- a/src/gui/npc_text.cpp +++ b/src/gui/npc_text.cpp @@ -37,15 +37,8 @@ #include "../utils/gettext.h" -#ifdef TMWSERV_SUPPORT NpcTextDialog::NpcTextDialog() -#else -NpcTextDialog::NpcTextDialog(Network *network) -#endif : Window(_("NPC")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif , mState(NPC_TEXT_STATE_WAITING) { setWindowName("NPCText"); diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 16c1d5fd..231ac684 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -30,9 +30,6 @@ #include "../npc.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class TextBox; /** @@ -48,11 +45,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcTextDialog(); -#else - NpcTextDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -101,9 +94,6 @@ class NpcTextDialog : public Window, public gcn::ActionListener void widgetResized(const gcn::Event &event); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::ScrollArea *mScrollArea; TextBox *mTextBox; gcn::Button *mButton; diff --git a/src/gui/npcintegerdialog.cpp b/src/gui/npcintegerdialog.cpp index 4dae8d83..4d2ae1ce 100644 --- a/src/gui/npcintegerdialog.cpp +++ b/src/gui/npcintegerdialog.cpp @@ -36,15 +36,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcIntegerDialog::NpcIntegerDialog() -#else -NpcIntegerDialog::NpcIntegerDialog(Network *network) -#endif : Window(_("NPC Number Request")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCInteger"); mValueField = new IntTextField; diff --git a/src/gui/npcintegerdialog.h b/src/gui/npcintegerdialog.h index df74c904..bb3a8e20 100644 --- a/src/gui/npcintegerdialog.h +++ b/src/gui/npcintegerdialog.h @@ -26,9 +26,6 @@ #include "window.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class IntTextField; /** @@ -44,11 +41,7 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcIntegerDialog(); -#else - NpcIntegerDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -93,9 +86,6 @@ class NpcIntegerDialog : public Window, public gcn::ActionListener void setVisible(bool visible); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mDecButton; gcn::Button *mIncButton; IntTextField *mValueField; diff --git a/src/gui/npclistdialog.cpp b/src/gui/npclistdialog.cpp index 6df0979f..efac8954 100644 --- a/src/gui/npclistdialog.cpp +++ b/src/gui/npclistdialog.cpp @@ -41,15 +41,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcListDialog::NpcListDialog() -#else -NpcListDialog::NpcListDialog(Network *network) -#endif : Window("NPC") -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCList"); setResizable(true); diff --git a/src/gui/npclistdialog.h b/src/gui/npclistdialog.h index 6c1e02e3..fa297304 100644 --- a/src/gui/npclistdialog.h +++ b/src/gui/npclistdialog.h @@ -29,10 +29,6 @@ #include -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * The npc list dialog. * @@ -47,11 +43,7 @@ class NpcListDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcListDialog(); -#else - NpcListDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -94,9 +86,6 @@ class NpcListDialog : public Window, public gcn::ActionListener, void requestFocus(); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::ListBox *mItemList; std::vector mItems; diff --git a/src/gui/npcstringdialog.cpp b/src/gui/npcstringdialog.cpp index 7297d7e8..e5137d9c 100644 --- a/src/gui/npcstringdialog.cpp +++ b/src/gui/npcstringdialog.cpp @@ -36,15 +36,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT NpcStringDialog::NpcStringDialog() -#else -NpcStringDialog::NpcStringDialog(Network *network) -#endif : Window(_("NPC Text Request")) -#ifdef EATHENA_SUPPORT - , mNetwork(network) -#endif { setWindowName("NPCString"); mValueField = new TextField(""); diff --git a/src/gui/npcstringdialog.h b/src/gui/npcstringdialog.h index 94cd59b2..37d46cc0 100644 --- a/src/gui/npcstringdialog.h +++ b/src/gui/npcstringdialog.h @@ -26,10 +26,6 @@ #include -#ifdef EATHENA_SUPPORT -class Network; -#endif - /** * The npc integer input dialog. * @@ -43,11 +39,7 @@ class NpcStringDialog : public Window, public gcn::ActionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT NpcStringDialog(); -#else - NpcStringDialog(Network *network); -#endif /** * Called when receiving actions from the widgets. @@ -79,9 +71,6 @@ class NpcStringDialog : public Window, public gcn::ActionListener void setVisible(bool visible); private: -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::TextField *mValueField; std::string mDefault; }; diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 648bff08..1e1155a7 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -46,14 +46,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -#ifdef TMWSERV_SUPPORT SellDialog::SellDialog(): Window(_("Sell")), -#else -SellDialog::SellDialog(Network *network): - Window(_("Sell")), - mNetwork(network), -#endif mMaxItems(0), mAmountItems(0) { setWindowName("Sell"); diff --git a/src/gui/sell.h b/src/gui/sell.h index b6388a1f..b3e59b4f 100644 --- a/src/gui/sell.h +++ b/src/gui/sell.h @@ -30,9 +30,6 @@ #include "window.h" class Item; -#ifdef EATHENA_SUPPORT -class Network; -#endif class ShopItems; class ShopListBox; @@ -49,11 +46,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener * * @see Window::Window */ -#ifdef TMWSERV_SUPPORT SellDialog(); -#else - SellDialog(Network *network); -#endif /** * Destructor @@ -111,9 +104,6 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener */ void updateButtonsAndLabels(); -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif gcn::Button *mSellButton; gcn::Button *mQuitButton; gcn::Button *mAddMaxButton; diff --git a/src/gui/storagewindow.cpp b/src/gui/storagewindow.cpp index 847886cb..690758ed 100644 --- a/src/gui/storagewindow.cpp +++ b/src/gui/storagewindow.cpp @@ -51,9 +51,8 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -StorageWindow::StorageWindow(Network *network, int invSize): +StorageWindow::StorageWindow(int invSize): Window(_("Storage")), - mNetwork(network), mMaxSlots(invSize), mItemDesc(false) { diff --git a/src/gui/storagewindow.h b/src/gui/storagewindow.h index cc0df2af..de0937b5 100644 --- a/src/gui/storagewindow.h +++ b/src/gui/storagewindow.h @@ -31,7 +31,6 @@ class Item; class ItemContainer; -class Network; class ProgressBar; class TextBox; @@ -47,7 +46,7 @@ class StorageWindow : public Window, gcn::ActionListener, /** * Constructor. */ - StorageWindow(Network *network, int invSize = (STORAGE_SIZE - 1)); + StorageWindow(int invSize = (STORAGE_SIZE - 1)); /** * Destructor. @@ -88,7 +87,6 @@ class StorageWindow : public Window, gcn::ActionListener, void close(); private: - Network *mNetwork; ItemContainer *mItems; int mSlots; diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 6cba1c41..6926eb82 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -51,14 +51,9 @@ #include "../utils/stringutils.h" #include "../utils/strprintf.h" -#ifdef TMWSERV_SUPPORT TradeWindow::TradeWindow(): -#else -TradeWindow::TradeWindow(Network *network): -#endif Window(_("Trade: You")), #ifdef EATHENA_SUPPORT - mNetwork(network), mMyInventory(new Inventory(INVENTORY_SIZE, 2)), mPartnerInventory(new Inventory(INVENTORY_SIZE, 2)) #else diff --git a/src/gui/trade.h b/src/gui/trade.h index 4c215ba6..e2767c5b 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -34,9 +34,6 @@ class Inventory; class Item; class ItemContainer; -#ifdef EATHENA_SUPPORT -class Network; -#endif class ScrollArea; /** @@ -50,11 +47,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener /** * Constructor. */ -#ifdef TMWSERV_SUPPORT TradeWindow(); -#else - TradeWindow(Network *network); -#endif /** * Destructor. @@ -139,10 +132,6 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener void setStatus(Status); #endif -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif - typedef const std::auto_ptr InventoryPtr; InventoryPtr mMyInventory; InventoryPtr mPartnerInventory; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 8b2d6907..68f9e4bc 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -96,7 +96,6 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mStatPoint(0), mSkillPoint(0), mStatsPointsToAttribute(0), mEquipment(new Equipment), - mNetwork(0), mXp(0), mInStorage(false), mTargetTime(-1), diff --git a/src/localplayer.h b/src/localplayer.h index 77e9ac02..bff38796 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -33,9 +33,6 @@ class ImageSet; class Inventory; class Item; class Map; -#ifdef EATHENA_SUPPORT -class Network; -#endif #ifdef TMWSERV_SUPPORT @@ -155,10 +152,6 @@ class LocalPlayer : public Player virtual void setName(const std::string &name); -#ifdef EATHENA_SUPPORT - void setNetwork(Network *network) { mNetwork = network; } - Network *getNetwork() {return mNetwork; } -#endif virtual void logic(); /** @@ -500,7 +493,6 @@ class LocalPlayer : public Player void walk(unsigned char dir); #ifdef EATHENA_SUPPORT - Network *mNetwork; int mXp; /**< Experience points. */ bool mInStorage; /**< Whether storage is currently accessible */ int mTargetTime; /** How long the being has been targeted **/ diff --git a/src/main.cpp b/src/main.cpp index bd17ce9c..ad3063f6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1653,7 +1653,7 @@ int main(int argc, char *argv[]) break; case STATE_CHAR_SELECT: logger->log("State: CHAR_SELECT"); - currentDialog = new CharSelectDialog(network, &charInfo, + currentDialog = new CharSelectDialog(&charInfo, (loginData.sex == 0) ? GENDER_FEMALE : GENDER_MALE); positionDialog(currentDialog, screenWidth, screenHeight); diff --git a/src/net/ea/network.h b/src/net/ea/network.h index 40d563aa..c246ab8e 100644 --- a/src/net/ea/network.h +++ b/src/net/ea/network.h @@ -36,8 +36,6 @@ class MessageHandler; class MessageIn; -class Network; - class Network { public: diff --git a/src/npc.cpp b/src/npc.cpp index 98c3e0eb..359546e2 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -40,14 +40,8 @@ bool NPC::isTalking = false; int current_npc = 0; -#ifdef TMWSERV_SUPPORT NPC::NPC(int id, int job, Map *map): Player(id, job, map) -#else -NPC::NPC(int id, int job, Map *map, Network *network): - Player(id, job, map), - mNetwork(network) -#endif { NPCInfo info = NPCDB::get(job); @@ -126,9 +120,6 @@ void NPC::talk() #ifdef TMWSERV_SUPPORT Net::GameServer::Player::talkToNPC(mId, true); #else - if (!mNetwork) - return; - MessageOut outMsg(CMSG_NPC_TALK); outMsg.writeInt32(mId); outMsg.writeInt8(0); diff --git a/src/npc.h b/src/npc.h index c2cab6f0..57e6d5a8 100644 --- a/src/npc.h +++ b/src/npc.h @@ -24,20 +24,13 @@ #include "player.h" -#ifdef EATHENA_SUPPORT -class Network; -#endif class Graphics; class Text; class NPC : public Player { public: -#ifdef TMWSERV_SUPPORT - NPC(int id, int sprite, Map *map); -#else - NPC(int id, int job, Map *map, Network *network); -#endif + NPC(int id, int job, Map *map); ~NPC(); @@ -56,6 +49,7 @@ class NPC : public Player { return 0x83; } // blocked like a monster by walls, monsters and characters ( bin 1000 0011) static bool isTalking; + protected: /** * Gets the way a monster blocks pathfinding for other objects @@ -63,10 +57,8 @@ class NPC : public Player virtual Map::BlockType getBlockType() const { return Map::BLOCKTYPE_CHARACTER; } //blocks like a player character -#ifdef EATHENA_SUPPORT - Network *mNetwork; -#endif void updateCoords(); + private: Text *mName; }; diff --git a/src/party.cpp b/src/party.cpp index 4a7912ee..2295cb81 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -33,9 +33,8 @@ #include "utils/gettext.h" #include "utils/strprintf.h" -Party::Party(Network *network) : - mNetwork(network), - mInviteListener(network, &mInParty) +Party::Party() : + mInviteListener(&mInParty) { } diff --git a/src/party.h b/src/party.h index d73b4a0f..25af80b3 100644 --- a/src/party.h +++ b/src/party.h @@ -29,12 +29,11 @@ class PartyHandler; class Being; class ChatWindow; -class Network; class Party { public: - Party(Network *network); + Party(); void respond(const std::string &command, const std::string &args); void create(const std::string &party); @@ -43,7 +42,7 @@ class Party void createResponse(bool ok); void inviteResponse(const std::string &nick, int status); void invitedAsk(const std::string &nick, int gender, - const std::string &partyName); + const std::string &partyName); void leftResponse(const std::string &nick); void receiveChat(Being *being, const std::string &msg); @@ -51,7 +50,6 @@ class Party private: std::string mPartyName; - Network *mNetwork; bool mInParty; bool mCreating; /**< Used to give an appropriate response to failure */ @@ -60,12 +58,11 @@ class Party class InviteListener : public gcn::ActionListener { public: - InviteListener(Network *network, bool *inParty) : - mNetwork(network), + InviteListener(bool *inParty) : mInParty(inParty) {} void action(const gcn::ActionEvent &event); - Network *mNetwork; + private: bool *mInParty; }; -- cgit v1.2.3-70-g09d2 From f67237cb69599753192c301f0f2eb38b88f7b57a Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 27 Mar 2009 16:24:01 -0600 Subject: Clean up some ifdefs and start cleanup of parties --- src/Makefile.am | 6 +- src/commandhandler.cpp | 2 +- src/engine.cpp | 16 +-- src/engine.h | 2 +- src/game.cpp | 5 +- src/gui/widgets/whispertab.cpp | 1 - src/map.cpp | 4 - src/net/ea/gui/partytab.cpp | 53 ++++++++++ src/net/ea/gui/partytab.h | 49 +++++++++ src/net/ea/party.cpp | 215 ++++++++++++++++++++++++++++++++++++++ src/net/ea/party.h | 74 +++++++++++++ src/net/ea/playerhandler.cpp | 5 +- src/net/tmwserv/playerhandler.cpp | 3 - src/party.cpp | 215 -------------------------------------- src/party.h | 74 ------------- 15 files changed, 404 insertions(+), 320 deletions(-) create mode 100644 src/net/ea/gui/partytab.cpp create mode 100644 src/net/ea/gui/partytab.h create mode 100644 src/net/ea/party.cpp create mode 100644 src/net/ea/party.h delete mode 100644 src/party.cpp delete mode 100644 src/party.h (limited to 'src/engine.cpp') diff --git a/src/Makefile.am b/src/Makefile.am index 4c5893ac..3768b7cd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -461,6 +461,8 @@ tmw_SOURCES += \ net/ea/network.h \ net/ea/npchandler.cpp \ net/ea/npchandler.h \ + net/ea/party.cpp \ + net/ea/party.h \ net/ea/partyhandler.cpp \ net/ea/partyhandler.h \ net/ea/playerhandler.cpp \ @@ -470,9 +472,7 @@ tmw_SOURCES += \ net/ea/skillhandler.cpp \ net/ea/skillhandler.h \ net/ea/tradehandler.cpp \ - net/ea/tradehandler.h \ - party.cpp \ - party.h + net/ea/tradehandler.h endif # set the include path found by configure diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index a2de2c63..5431cf88 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -34,8 +34,8 @@ #include "net/tmwserv/chatserver/chatserver.h" #include "net/tmwserv/gameserver/player.h" #else -#include "party.h" #include "net/messageout.h" +#include "net/ea/party.h" #include "net/ea/protocol.h" #endif diff --git a/src/engine.cpp b/src/engine.cpp index d13fbf3f..04d06e38 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -33,11 +33,6 @@ #include "gui/minimap.h" #include "gui/viewport.h" -#ifdef EATHENA_SUPPORT -#include "net/messageout.h" -#include "net/ea/protocol.h" -#endif - #include "resources/mapreader.h" #include "resources/monsterdb.h" #include "resources/resourcemanager.h" @@ -54,7 +49,7 @@ Engine::~Engine() delete mCurrentMap; } -void Engine::changeMap(const std::string &mapPath) +bool Engine::changeMap(const std::string &mapPath) { // Clean up floor items, beings and particles floorItemManager->clear(); @@ -71,11 +66,7 @@ void Engine::changeMap(const std::string &mapPath) mMapName = mapPath; // Store full map path in global var -#ifdef TMWSERV_SUPPORT map_path = "maps/" + mapPath + ".tmx"; -#else - map_path = "maps/" + mapPath.substr(0, mapPath.rfind(".")) + ".tmx"; -#endif ResourceManager *resman = ResourceManager::getInstance(); if (!resman->exists(map_path)) map_path += ".gz"; @@ -143,10 +134,7 @@ void Engine::changeMap(const std::string &mapPath) mCurrentMap = newMap; -#ifdef EATHENA_SUPPORT - // Send "map loaded" - MessageOut outMsg(CMSG_MAP_LOADED); -#endif + return true; } void Engine::logic() diff --git a/src/engine.h b/src/engine.h index eafce3b9..963270e8 100644 --- a/src/engine.h +++ b/src/engine.h @@ -53,7 +53,7 @@ class Engine /** * Sets the currently active map. */ - void changeMap(const std::string &mapName); + bool changeMap(const std::string &mapName); /** * Performs engine logic. This method is called 100 times per second. diff --git a/src/game.cpp b/src/game.cpp index 856a5c11..6b9a829f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -43,9 +43,6 @@ #include "log.h" #include "npc.h" #include "particle.h" -#ifdef EATHENA_SUPPORT -#include "party.h" -#endif #include "player_relations.h" #include "gui/widgets/chattab.h" @@ -110,6 +107,7 @@ #include "net/ea/inventoryhandler.h" #include "net/ea/itemhandler.h" #include "net/ea/npchandler.h" +#include "net/ea/party.h" #include "net/ea/playerhandler.h" #include "net/ea/tradehandler.h" #include "net/ea/protocol.h" @@ -450,6 +448,7 @@ Game::Game(Network *network): msg.writeInt32(tick_time); engine->changeMap(map_path); + MessageOut outMsg(CMSG_MAP_LOADED); #endif setupWindow->setInGame(true); diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 1621e965..9e6d9336 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -28,7 +28,6 @@ #ifdef TMWSERV_SUPPORT #include "net/tmwserv/chatserver/chatserver.h" #else -#include "party.h" #include "net/messageout.h" #include "net/ea/protocol.h" #endif diff --git a/src/map.cpp b/src/map.cpp index 59e6201f..8f736424 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -141,11 +141,7 @@ void MapLayer::draw(Graphics *graphics, int startX, int startY, // tiles have been drawn if (mIsFringeLayer) { -#ifdef TMWSERV_SUPPORT while (si != sprites.end() && (*si)->getPixelY() <= y * 32) -#else - while (si != sprites.end() && (*si)->getPixelY() <= y * 32) -#endif { (*si)->draw(graphics, -scrollX, -scrollY); si++; diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp new file mode 100644 index 00000000..a55d2492 --- /dev/null +++ b/src/net/ea/gui/partytab.cpp @@ -0,0 +1,53 @@ +/* + * The Mana World + * Copyright (C) 2008 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "partytab.h" + +#include "net/messageout.h" + +#include "net/ea/party.h" +#include "net/ea/protocol.h" + +#include "resources/iteminfo.h" +#include "resources/itemdb.h" + +#include "utils/dtor.h" +#include "utils/gettext.h" +#include "utils/strprintf.h" +#include "utils/stringutils.h" + +PartyTab::PartyTab() : ChatTab(_("Party")) +{ +} + +PartyTab::~PartyTab() +{ +} + +void PartyTab::handleInput(std::string &msg) { + // TODO +} + +void PartyTab::handleCommand(std::string &msg) { + // TODO +} diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h new file mode 100644 index 00000000..b2aaca68 --- /dev/null +++ b/src/net/ea/gui/partytab.h @@ -0,0 +1,49 @@ +/* + * The Mana World + * Copyright (C) 2009 The Mana World Development Team + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef CHANNELTAB_H +#define CHANNELTAB_H + +#include "gui/widgets/chattab.h" + +/** + * A tab for a chat channel. + */ +class PartyTab : public ChatTab +{ + public: + /** + * Constructor. + */ + PartyTab(); + + /** + * Destructor. + */ + ~PartyTab(); + + protected: + void handleInput(const std::string &msg); + + void handleCommand(std::string msg); +}; + +#endif // CHANNELTAB_H diff --git a/src/net/ea/party.cpp b/src/net/ea/party.cpp new file mode 100644 index 00000000..2295cb81 --- /dev/null +++ b/src/net/ea/party.cpp @@ -0,0 +1,215 @@ +/* + * The Mana World + * Copyright (C) 2008 Lloyd Bryant + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "being.h" +#include "localplayer.h" +#include "party.h" + +#include "gui/widgets/chattab.h" +#include "gui/chat.h" +#include "gui/confirm_dialog.h" + +#include "net/messageout.h" +#include "net/ea/protocol.h" + +#include "utils/gettext.h" +#include "utils/strprintf.h" + +Party::Party() : + mInviteListener(&mInParty) +{ +} + +void Party::respond(const std::string &command, const std::string &args) +{ + if (command == "new" || command == "create") + { + create(args); + return; + } + if (command == "leave") + { + leave(args); + return; + } + if (command == "settings") + { + localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER); + return; + /* + MessageOut outMsg(CMSG_PARTY_SETTINGS); + outMsg.writeInt16(0); // Experience + outMsg.writeInt16(0); // Item + */ + } + localChatTab->chatLog(_("Party command not known."), BY_SERVER); +} + +void Party::create(const std::string &party) +{ + if (party.empty()) + { + localChatTab->chatLog(_("Party name is missing."), BY_SERVER); + return; + } + MessageOut outMsg(CMSG_PARTY_CREATE); + outMsg.writeString(party.substr(0, 23), 24); + mCreating = true; +} + +void Party::leave(const std::string &args) +{ + MessageOut outMsg(CMSG_PARTY_LEAVE); + localChatTab->chatLog(_("Left party."), BY_SERVER); + mInParty = false; +} + +void Party::createResponse(bool ok) +{ + if (ok) + { + localChatTab->chatLog(_("Party successfully created."), BY_SERVER); + mInParty = true; + } + else + { + localChatTab->chatLog(_("Could not create party."), BY_SERVER); + } +} + +void Party::inviteResponse(const std::string &nick, int status) +{ + switch (status) + { + case 0: + localChatTab->chatLog(strprintf(_("%s is already a member of a party."), + nick.c_str()), BY_SERVER); + break; + case 1: + localChatTab->chatLog(strprintf(_("%s refused your invitation."), + nick.c_str()), BY_SERVER); + break; + case 2: + localChatTab->chatLog(strprintf(_("%s is now a member of your party."), + nick.c_str()), BY_SERVER); + break; + } +} + +void Party::invitedAsk(const std::string &nick, int gender, + const std::string &partyName) +{ + mPartyName = partyName; /* Quick and nasty - needs redoing */ + if (nick.empty()) + { + localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); + return; + } + mCreating = false; + ConfirmDialog *dlg = new ConfirmDialog(_("Invite to party"), + strprintf(_("%s invites you to join" + " the %s party, do you accept?"), + nick.c_str(), partyName.c_str())); + dlg->addActionListener(&mInviteListener); +} + +void Party::InviteListener::action(const gcn::ActionEvent &event) +{ + MessageOut outMsg(CMSG_PARTY_INVITED); + outMsg.writeInt32(player_node->getId()); + bool accept = event.getId() == "yes"; + outMsg.writeInt32(accept ? 1 : 0); + *mInParty = *mInParty || accept; +} + +void Party::leftResponse(const std::string &nick) +{ + localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), + BY_SERVER); +} + +void Party::receiveChat(Being *being, const std::string &msg) +{ + if (!being) + { + return; + } + if (being->getType() != Being::PLAYER) + { + localChatTab->chatLog(_("Party chat received, but being is not a player"), + BY_SERVER); + return; + } + being->setSpeech(msg, SPEECH_TIME); + localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY); +} + +void Party::help(const std::string &args) +{ + // Strip "party " from the front + std::string msg = args.substr(6, args.length()); + + if (msg.empty()) + { + localChatTab->chatLog(_("Command: /party "), BY_SERVER); + localChatTab->chatLog(_("where can be one of:"), BY_SERVER); + localChatTab->chatLog(_(" /new"), BY_SERVER); + localChatTab->chatLog(_(" /create"), BY_SERVER); + localChatTab->chatLog(_(" /prefix"), BY_SERVER); + localChatTab->chatLog(_(" /leave"), BY_SERVER); + localChatTab->chatLog(_("This command implements the partying function."), + BY_SERVER); + localChatTab->chatLog(_("Type /help party for further help."), + BY_SERVER); + return; + } + if (msg == "new" || msg == "create") + { + localChatTab->chatLog(_("Command: /party new "), BY_SERVER); + localChatTab->chatLog(_("Command: /party create "), BY_SERVER); + localChatTab->chatLog(_("These commands create a new party chatLog(_("Command: /party prefix "), BY_SERVER); + localChatTab->chatLog(_("This command sets the party prefix character."), + BY_SERVER); + localChatTab->chatLog(_("Any message preceded by is sent to " + "the party instead of everyone."), BY_SERVER); + localChatTab->chatLog(_("Command: /party prefix"), BY_SERVER); + localChatTab->chatLog(_("This command reports the current party prefix " + "character."), BY_SERVER); + return; + } + //if (msg == "settings") + //if (msg == "info") + if (msg == "leave") + { + localChatTab->chatLog(_("Command: /party leave"), BY_SERVER); + localChatTab->chatLog(_("This command causes the player to leave the party."), + BY_SERVER); + return; + } + localChatTab->chatLog(_("Unknown /party command."), BY_SERVER); + localChatTab->chatLog(_("Type /help party for a list of options."), BY_SERVER); +} diff --git a/src/net/ea/party.h b/src/net/ea/party.h new file mode 100644 index 00000000..25af80b3 --- /dev/null +++ b/src/net/ea/party.h @@ -0,0 +1,74 @@ +/* + * The Mana World + * Copyright (C) 2008 Lloyd Bryant + * + * This file is part of The Mana World. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PARTY_H +#define PARTY_H + +#include + +#include + +class PartyHandler; +class Being; +class ChatWindow; + +class Party +{ + public: + Party(); + void respond(const std::string &command, const std::string &args); + + void create(const std::string &party); + void leave(const std::string &args); + + void createResponse(bool ok); + void inviteResponse(const std::string &nick, int status); + void invitedAsk(const std::string &nick, int gender, + const std::string &partyName); + void leftResponse(const std::string &nick); + void receiveChat(Being *being, const std::string &msg); + + void help(const std::string &args); + + private: + std::string mPartyName; + bool mInParty; + bool mCreating; /**< Used to give an appropriate response to + failure */ + PartyHandler *handler; + + class InviteListener : public gcn::ActionListener + { + public: + InviteListener(bool *inParty) : + mInParty(inParty) + {} + void action(const gcn::ActionEvent &event); + + private: + bool *mInParty; + }; + InviteListener mInviteListener; +}; + +extern Party *playerParty; + +#endif diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index bf775f51..05f74630 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -24,6 +24,7 @@ #include "net/ea/protocol.h" #include "net/messagein.h" +#include "net/messageout.h" #include "engine.h" #include "localplayer.h" @@ -193,7 +194,9 @@ void PlayerHandler::handleMessage(MessageIn &msg) nearby = (engine->getCurrentMapName() == mapPath); // Switch the actual map, deleting the previous one if necessary - engine->changeMap(mapPath); + mapPath = mapPath.substr(0, mapPath.rfind(".")); + if (engine->changeMap(mapPath)) + MessageOut outMsg(CMSG_MAP_LOADED); float scrollOffsetX = 0.0f; float scrollOffsetY = 0.0f; diff --git a/src/net/tmwserv/playerhandler.cpp b/src/net/tmwserv/playerhandler.cpp index f02ed4c1..106894a1 100644 --- a/src/net/tmwserv/playerhandler.cpp +++ b/src/net/tmwserv/playerhandler.cpp @@ -85,9 +85,6 @@ namespace { npcTextDialog->setVisible(false); buyDialog->setVisible(false); sellDialog->setVisible(false); -#ifdef EATHENA_SUPPORT - buySellDialog->setVisible(false); -#endif current_npc = 0; } } deathListener; diff --git a/src/party.cpp b/src/party.cpp deleted file mode 100644 index 2295cb81..00000000 --- a/src/party.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * The Mana World - * Copyright (C) 2008 Lloyd Bryant - * - * This file is part of The Mana World. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "being.h" -#include "localplayer.h" -#include "party.h" - -#include "gui/widgets/chattab.h" -#include "gui/chat.h" -#include "gui/confirm_dialog.h" - -#include "net/messageout.h" -#include "net/ea/protocol.h" - -#include "utils/gettext.h" -#include "utils/strprintf.h" - -Party::Party() : - mInviteListener(&mInParty) -{ -} - -void Party::respond(const std::string &command, const std::string &args) -{ - if (command == "new" || command == "create") - { - create(args); - return; - } - if (command == "leave") - { - leave(args); - return; - } - if (command == "settings") - { - localChatTab->chatLog(_("Not yet implemented!"), BY_SERVER); - return; - /* - MessageOut outMsg(CMSG_PARTY_SETTINGS); - outMsg.writeInt16(0); // Experience - outMsg.writeInt16(0); // Item - */ - } - localChatTab->chatLog(_("Party command not known."), BY_SERVER); -} - -void Party::create(const std::string &party) -{ - if (party.empty()) - { - localChatTab->chatLog(_("Party name is missing."), BY_SERVER); - return; - } - MessageOut outMsg(CMSG_PARTY_CREATE); - outMsg.writeString(party.substr(0, 23), 24); - mCreating = true; -} - -void Party::leave(const std::string &args) -{ - MessageOut outMsg(CMSG_PARTY_LEAVE); - localChatTab->chatLog(_("Left party."), BY_SERVER); - mInParty = false; -} - -void Party::createResponse(bool ok) -{ - if (ok) - { - localChatTab->chatLog(_("Party successfully created."), BY_SERVER); - mInParty = true; - } - else - { - localChatTab->chatLog(_("Could not create party."), BY_SERVER); - } -} - -void Party::inviteResponse(const std::string &nick, int status) -{ - switch (status) - { - case 0: - localChatTab->chatLog(strprintf(_("%s is already a member of a party."), - nick.c_str()), BY_SERVER); - break; - case 1: - localChatTab->chatLog(strprintf(_("%s refused your invitation."), - nick.c_str()), BY_SERVER); - break; - case 2: - localChatTab->chatLog(strprintf(_("%s is now a member of your party."), - nick.c_str()), BY_SERVER); - break; - } -} - -void Party::invitedAsk(const std::string &nick, int gender, - const std::string &partyName) -{ - mPartyName = partyName; /* Quick and nasty - needs redoing */ - if (nick.empty()) - { - localChatTab->chatLog(_("You can\'t have a blank party name!"), BY_SERVER); - return; - } - mCreating = false; - ConfirmDialog *dlg = new ConfirmDialog(_("Invite to party"), - strprintf(_("%s invites you to join" - " the %s party, do you accept?"), - nick.c_str(), partyName.c_str())); - dlg->addActionListener(&mInviteListener); -} - -void Party::InviteListener::action(const gcn::ActionEvent &event) -{ - MessageOut outMsg(CMSG_PARTY_INVITED); - outMsg.writeInt32(player_node->getId()); - bool accept = event.getId() == "yes"; - outMsg.writeInt32(accept ? 1 : 0); - *mInParty = *mInParty || accept; -} - -void Party::leftResponse(const std::string &nick) -{ - localChatTab->chatLog(strprintf(_("%s has left your party."), nick.c_str()), - BY_SERVER); -} - -void Party::receiveChat(Being *being, const std::string &msg) -{ - if (!being) - { - return; - } - if (being->getType() != Being::PLAYER) - { - localChatTab->chatLog(_("Party chat received, but being is not a player"), - BY_SERVER); - return; - } - being->setSpeech(msg, SPEECH_TIME); - localChatTab->chatLog(being->getName() + " : " + msg, BY_PARTY); -} - -void Party::help(const std::string &args) -{ - // Strip "party " from the front - std::string msg = args.substr(6, args.length()); - - if (msg.empty()) - { - localChatTab->chatLog(_("Command: /party "), BY_SERVER); - localChatTab->chatLog(_("where can be one of:"), BY_SERVER); - localChatTab->chatLog(_(" /new"), BY_SERVER); - localChatTab->chatLog(_(" /create"), BY_SERVER); - localChatTab->chatLog(_(" /prefix"), BY_SERVER); - localChatTab->chatLog(_(" /leave"), BY_SERVER); - localChatTab->chatLog(_("This command implements the partying function."), - BY_SERVER); - localChatTab->chatLog(_("Type /help party for further help."), - BY_SERVER); - return; - } - if (msg == "new" || msg == "create") - { - localChatTab->chatLog(_("Command: /party new "), BY_SERVER); - localChatTab->chatLog(_("Command: /party create "), BY_SERVER); - localChatTab->chatLog(_("These commands create a new party chatLog(_("Command: /party prefix "), BY_SERVER); - localChatTab->chatLog(_("This command sets the party prefix character."), - BY_SERVER); - localChatTab->chatLog(_("Any message preceded by is sent to " - "the party instead of everyone."), BY_SERVER); - localChatTab->chatLog(_("Command: /party prefix"), BY_SERVER); - localChatTab->chatLog(_("This command reports the current party prefix " - "character."), BY_SERVER); - return; - } - //if (msg == "settings") - //if (msg == "info") - if (msg == "leave") - { - localChatTab->chatLog(_("Command: /party leave"), BY_SERVER); - localChatTab->chatLog(_("This command causes the player to leave the party."), - BY_SERVER); - return; - } - localChatTab->chatLog(_("Unknown /party command."), BY_SERVER); - localChatTab->chatLog(_("Type /help party for a list of options."), BY_SERVER); -} diff --git a/src/party.h b/src/party.h deleted file mode 100644 index 25af80b3..00000000 --- a/src/party.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The Mana World - * Copyright (C) 2008 Lloyd Bryant - * - * This file is part of The Mana World. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef PARTY_H -#define PARTY_H - -#include - -#include - -class PartyHandler; -class Being; -class ChatWindow; - -class Party -{ - public: - Party(); - void respond(const std::string &command, const std::string &args); - - void create(const std::string &party); - void leave(const std::string &args); - - void createResponse(bool ok); - void inviteResponse(const std::string &nick, int status); - void invitedAsk(const std::string &nick, int gender, - const std::string &partyName); - void leftResponse(const std::string &nick); - void receiveChat(Being *being, const std::string &msg); - - void help(const std::string &args); - - private: - std::string mPartyName; - bool mInParty; - bool mCreating; /**< Used to give an appropriate response to - failure */ - PartyHandler *handler; - - class InviteListener : public gcn::ActionListener - { - public: - InviteListener(bool *inParty) : - mInParty(inParty) - {} - void action(const gcn::ActionEvent &event); - - private: - bool *mInParty; - }; - InviteListener mInviteListener; -}; - -extern Party *playerParty; - -#endif -- cgit v1.2.3-70-g09d2