diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 10 | ||||
-rw-r--r-- | src/gui/browserbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/browserbox.h | 2 | ||||
-rw-r--r-- | src/gui/buy.cpp | 13 | ||||
-rw-r--r-- | src/gui/buy.h | 3 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 1 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/item_amount.cpp | 3 | ||||
-rw-r--r-- | src/gui/item_amount.h | 2 | ||||
-rw-r--r-- | src/gui/login.cpp | 3 | ||||
-rw-r--r-- | src/gui/menuwindow.cpp | 2 | ||||
-rw-r--r-- | src/gui/npc_text.h | 2 | ||||
-rw-r--r-- | src/gui/playerbox.cpp | 6 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 1 | ||||
-rw-r--r-- | src/gui/sell.cpp | 4 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_keyboard.cpp | 12 | ||||
-rw-r--r-- | src/gui/trade.cpp | 2 | ||||
-rw-r--r-- | src/gui/window.cpp | 14 | ||||
-rw-r--r-- | src/gui/window.h | 23 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/net/messagein.h | 4 | ||||
-rw-r--r-- | src/net/network.cpp | 46 | ||||
-rw-r--r-- | src/resources/npcdb.cpp | 1 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 6 | ||||
-rw-r--r-- | src/utils/xml.cpp | 15 | ||||
-rw-r--r-- | src/utils/xml.h | 10 |
27 files changed, 89 insertions, 105 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 5cf1a6e8..d3926a70 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -250,14 +250,14 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ resources/iteminfo.cpp \ resources/mapreader.cpp \ resources/mapreader.h \ - resources/monsterdb.h \ resources/monsterdb.cpp \ - resources/monsterinfo.h \ + resources/monsterdb.h \ resources/monsterinfo.cpp \ - resources/music.h \ + resources/monsterinfo.h \ resources/music.cpp \ - resources/npcdb.h \ + resources/music.h \ resources/npcdb.cpp \ + resources/npcdb.h \ resources/resource.cpp \ resources/resource.h \ resources/resourcemanager.cpp \ @@ -276,8 +276,8 @@ tmw_SOURCES = gui/widgets/avatar.cpp \ utils/minmax.h \ utils/sha256.h \ utils/sha256.cpp \ - utils/strprintf.h \ utils/strprintf.cpp \ + utils/strprintf.h \ utils/tostring.h \ utils/trim.h \ utils/mutex.h \ diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp index b0b6f48e..03540d31 100644 --- a/src/gui/browserbox.cpp +++ b/src/gui/browserbox.cpp @@ -142,7 +142,7 @@ void BrowserBox::addRow(const std::string &row) { unsigned int y = 0; unsigned int nextChar; - char const *hyphen = "~"; + const char *hyphen = "~"; int hyphenWidth = font->getWidth(hyphen); int x = 0; diff --git a/src/gui/browserbox.h b/src/gui/browserbox.h index 465ff497..cb4c23ed 100644 --- a/src/gui/browserbox.h +++ b/src/gui/browserbox.h @@ -25,8 +25,8 @@ #include <iosfwd> #include <vector> -#include <guichan/widget.hpp> #include <guichan/mouselistener.hpp> +#include <guichan/widget.hpp> #include "../guichanfwd.h" #include "../main.h" diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 008c7bb9..cc2262ec 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -165,15 +165,15 @@ void BuyDialog::action(const gcn::ActionEvent &event) Net::GameServer::Player::tradeWithNPC (mShopItems->at(selectedItem)->getId(), mAmountItems); - // Reset selection - mAmountItems = 1; - mSlider->setValue(1); - mSlider->gcn::Slider::setScale(1, mMaxItems); - // Update money and adjust the max number of items that can be bought mMaxItems -= mAmountItems; setMoney(mMoney - mAmountItems * mShopItems->at(selectedItem)->getPrice()); + + // Reset selection + mAmountItems = 1; + mSlider->setValue(1); + mSlider->gcn::Slider::setScale(1, mMaxItems); } } @@ -187,8 +187,7 @@ void BuyDialog::valueChanged(const gcn::SelectionEvent &event) mSlider->gcn::Slider::setScale(1, mMaxItems); } -void -BuyDialog::updateButtonsAndLabels() +void BuyDialog::updateButtonsAndLabels() { const int selectedItem = mShopItemList->getSelected(); int price = 0; diff --git a/src/gui/buy.h b/src/gui/buy.h index 24f18742..a80ffed7 100644 --- a/src/gui/buy.h +++ b/src/gui/buy.h @@ -92,8 +92,7 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Updates the state of buttons and labels. */ - void - updateButtonsAndLabels(); + void updateButtonsAndLabels(); private: gcn::Button *mBuyButton; diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 67cb3c7b..f800c266 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -134,7 +134,6 @@ CharSelectDialog::CharSelectDialog(LockedArray<LocalPlayer*> *charInfo, setVisible(true); mSelectButton->requestFocus(); updatePlayerInfo(); - } void CharSelectDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 1765eeea..b4a96394 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -102,9 +102,8 @@ void InventoryWindow::logic() void InventoryWindow::action(const gcn::ActionEvent &event) { Item *item = mItems->getItem(); - if (!item) { + if (!item) return; - } if (event.getId() == "use") { diff --git a/src/gui/item_amount.cpp b/src/gui/item_amount.cpp index c6763014..cae681d4 100644 --- a/src/gui/item_amount.cpp +++ b/src/gui/item_amount.cpp @@ -75,8 +75,7 @@ ItemAmountWindow::ItemAmountWindow(int usage, Window *parent, Item *item, resetAmount(); - switch (usage) - { + switch (usage) { case AMOUNT_TRADE_ADD: setCaption(_("Select amount of items to trade.")); okButton->setActionEventId("AddTrade"); diff --git a/src/gui/item_amount.h b/src/gui/item_amount.h index dd1026b7..c0d2b2c0 100644 --- a/src/gui/item_amount.h +++ b/src/gui/item_amount.h @@ -38,7 +38,7 @@ class Item; #define AMOUNT_ITEM_SPLIT 3 /** - * Window used for selecting the amount of items to drop. + * Window used for selecting the amount of items to drop, trade or split. * * \ingroup Interface */ diff --git a/src/gui/login.cpp b/src/gui/login.cpp index b4289984..615045b6 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -38,7 +38,8 @@ #include "../utils/gettext.h" -LoginDialog::LoginDialog(LoginData *loginData) : Window(_("Login")), mLoginData(loginData) +LoginDialog::LoginDialog(LoginData *loginData): + Window(_("Login")), mLoginData(loginData) { gcn::Label *userLabel = new gcn::Label(_("Name:")); gcn::Label *passLabel = new gcn::Label(_("Password:")); diff --git a/src/gui/menuwindow.cpp b/src/gui/menuwindow.cpp index f74dfa41..9415188e 100644 --- a/src/gui/menuwindow.cpp +++ b/src/gui/menuwindow.cpp @@ -58,7 +58,7 @@ MenuWindow::MenuWindow(): setTitleBarHeight(0); // Buttons - static char const *buttonNames[] = + static const char *buttonNames[] = { N_("Status"), N_("Equipment"), diff --git a/src/gui/npc_text.h b/src/gui/npc_text.h index 76161f88..b6eccf95 100644 --- a/src/gui/npc_text.h +++ b/src/gui/npc_text.h @@ -45,7 +45,7 @@ class NpcTextDialog : public Window, public gcn::ActionListener NpcTextDialog(); /** - * Called when resizing the window + * Called when resizing the window. * * @param event The calling event */ diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp index 0a0c8a17..6888d69a 100644 --- a/src/gui/playerbox.cpp +++ b/src/gui/playerbox.cpp @@ -74,8 +74,7 @@ PlayerBox::~PlayerBox() } } -void -PlayerBox::draw(gcn::Graphics *graphics) +void PlayerBox::draw(gcn::Graphics *graphics) { if (mPlayer) { @@ -87,8 +86,7 @@ PlayerBox::draw(gcn::Graphics *graphics) } } -void -PlayerBox::drawFrame(gcn::Graphics *graphics) +void PlayerBox::drawFrame(gcn::Graphics *graphics) { int w, h, bs; bs = getFrameSize(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 59ca0867..a430ff10 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -75,7 +75,6 @@ void PopupMenu::showPopup(int x, int y, Being *being) // add as buddy will be options in this menu. const std::string &name = mBeing->getName(); mBrowserBox->addRow(strprintf(_("@@trade|Trade With %s@@"), name.c_str())); - mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); //mBrowserBox->addRow("@@follow|Follow " + name + "@@"); //mBrowserBox->addRow("@@buddy|Add " + name + " to Buddy List@@"); diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 24391458..9aee4bee 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -202,8 +202,7 @@ void SellDialog::setMoney(int amount) mShopItemList->setPlayersMoney(amount); } -void -SellDialog::updateButtonsAndLabels() +void SellDialog::updateButtonsAndLabels() { int selectedItem = mShopItemList->getSelected(); int income = 0; @@ -211,7 +210,6 @@ SellDialog::updateButtonsAndLabels() if (selectedItem > -1) { const ItemInfo &info = mShopItems->at(selectedItem)->getInfo(); - mItemDescLabel->setCaption (strprintf(_("Description: %s"), info.getDescription().c_str())); mItemEffectLabel->setCaption diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index e062f674..59b54be0 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -53,7 +53,7 @@ Setup::Setup(): int height = 265; setContentSize(width, height); - static char const *buttonNames[] = { + static const char *buttonNames[] = { N_("Apply"), N_("Cancel"), N_("Reset Windows"), 0 }; int x = width; diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index 270f4a0e..e4d1af0c 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -32,6 +32,7 @@ #include "../configuration.h" #include "../keyboardconfig.h" +#include "../utils/gettext.h" #include "../utils/tostring.h" #include <SDL_keyboard.h> @@ -85,13 +86,13 @@ Setup_Keyboard::Setup_Keyboard(): scrollArea->setDimension(gcn::Rectangle(10, 10, 200, 140)); add(scrollArea); - mAssignKeyButton = new Button("Assign", "assign", this); + mAssignKeyButton = new Button(_("Assign"), "assign", this); mAssignKeyButton->setPosition(165, 155); mAssignKeyButton->addActionListener(this); mAssignKeyButton->setEnabled(false); add(mAssignKeyButton); - mMakeDefaultButton = new Button("Default", "makeDefault", this); + mMakeDefaultButton = new Button(_("Default"), "makeDefault", this); mMakeDefaultButton->setPosition(10, 155); mMakeDefaultButton->addActionListener(this); add(mMakeDefaultButton); @@ -112,8 +113,9 @@ void Setup_Keyboard::apply() if (keyboard.hasConflicts()) { - new OkDialog("Key Conflict(s) Detected.", - "Resolve them, or gameplay may result in strange behaviour."); + new OkDialog(_("Key Conflict(s) Detected."), + _("Resolve them, or gameplay may result in strange " + "behaviour.")); } keyboard.setEnabled(true); keyboard.store(); @@ -171,7 +173,7 @@ void Setup_Keyboard::newKeyCallback(int index) void Setup_Keyboard::refreshKeys() { - for(int i = 0; i < keyboard.KEY_TOTAL; i++) + for (int i = 0; i < keyboard.KEY_TOTAL; i++) { refreshAssignedKey(i); } diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 7d5051c7..0592c485 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -188,9 +188,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) if (event.getId() == "add") { if (!item) - { return; - } if (mMyInventory->contains(item)) { chatWindow->chatLog("Failed adding item. You can not " diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 582e4a67..64607243 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -31,7 +31,6 @@ #include "window.h" #include "gui.h" -#include "gccontainer.h" #include "windowcontainer.h" #include "widgets/layout.h" @@ -87,8 +86,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent): { logger->log("Window::Window(\"%s\")", caption.c_str()); - if (!windowContainer) - { + if (!windowContainer) { throw GCN_EXCEPTION("Window::Window(): no windowContainer set"); } @@ -128,17 +126,15 @@ Window::Window(const std::string& caption, bool modal, Window *parent): Window::~Window() { logger->log("UNLOAD: Window::~Window(\"%s\")", getCaption().c_str()); - const std::string &name = mWindowName; - if (!name.empty()) - { - // Saving X, Y and Width and Height for resizables in the config + + // Saving X, Y and Width and Height for resizables in the config + if (!name.empty()) { config.setValue(name + "WinX", getX()); config.setValue(name + "WinY", getY()); config.setValue(name + "Visible", isVisible()); - if (mGrip) - { + if (mGrip) { config.setValue(name + "WinWidth", getWidth()); config.setValue(name + "WinHeight", getHeight()); } diff --git a/src/gui/window.h b/src/gui/window.h index 6f49e062..50a206f0 100644 --- a/src/gui/window.h +++ b/src/gui/window.h @@ -222,17 +222,6 @@ class Window : public gcn::Window, gcn::WidgetListener */ void resetToDefaultSize(); - enum ResizeHandles - { - TOP = 0x01, - RIGHT = 0x02, - BOTTOM = 0x04, - LEFT = 0x08 - }; - - /** The window container windows add themselves to. */ - static WindowContainer *windowContainer; - /** * Gets the layout handler for this window. */ @@ -263,7 +252,19 @@ class Window : public gcn::Window, gcn::WidgetListener */ void loadSkin(const std::string &fileName); + protected: + /** The window container windows add themselves to. */ + static WindowContainer *windowContainer; + private: + enum ResizeHandles + { + TOP = 0x01, + RIGHT = 0x02, + BOTTOM = 0x04, + LEFT = 0x08 + }; + /** * Determines if the mouse is in a resize area and returns appropriate * resize handles. Also initializes drag offset in case the resize diff --git a/src/main.cpp b/src/main.cpp index 2d6b08a8..39a0fb37 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -315,7 +315,7 @@ void initEngine(const Options &options) if (!resman->setWriteDir(homeDir)) { std::cout << homeDir - << " couldn't be set as home directory! Exitting." + << " couldn't be set as home directory! Exiting." << std::endl; exit(1); } diff --git a/src/net/messagein.h b/src/net/messagein.h index 444699c8..f2390baa 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -61,13 +61,13 @@ class MessageIn * Returns the message length. */ unsigned int - getLength() { return mLength; } + getLength() const { return mLength; } /** * Returns the length of unread data. */ unsigned int - getUnreadLength() { return mLength - mPos; } + getUnreadLength() const { return mLength - mPos; } private: const char* mData; /**< The message data. */ diff --git a/src/net/network.cpp b/src/net/network.cpp index a4ea3def..57e368e2 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -83,8 +83,7 @@ Net::Connection *Net::getConnection() return new Net::Connection(client); } -void -Net::registerHandler(MessageHandler *handler) +void Net::registerHandler(MessageHandler *handler) { for (const Uint16 *i = handler->handledMessages; *i; i++) { @@ -92,8 +91,7 @@ Net::registerHandler(MessageHandler *handler) } } -void -Net::unregisterHandler(MessageHandler *handler) +void Net::unregisterHandler(MessageHandler *handler) { for (const Uint16 *i = handler->handledMessages; *i; i++) { @@ -101,8 +99,7 @@ Net::unregisterHandler(MessageHandler *handler) } } -void -Net::clearHandlers() +void Net::clearHandlers() { mMessageHandlers.clear(); } @@ -114,26 +111,25 @@ Net::clearHandlers() */ namespace { - void - dispatchMessage(ENetPacket *packet) - { - MessageIn msg((const char *)packet->data, packet->dataLength); - - MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); - - if (iter != mMessageHandlers.end()) { - //logger->log("Received packet %x (%i B)", - // msg.getId(), msg.getLength()); - iter->second->handleMessage(msg); - } - else { - logger->log("Unhandled packet %x (%i B)", - msg.getId(), msg.getLength()); - } - - // Clean up the packet now that we're done using it. - enet_packet_destroy(packet); + void dispatchMessage(ENetPacket *packet) + { + MessageIn msg((const char *)packet->data, packet->dataLength); + + MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); + + if (iter != mMessageHandlers.end()) { + //logger->log("Received packet %x (%i B)", + // msg.getId(), msg.getLength()); + iter->second->handleMessage(msg); } + else { + logger->log("Unhandled packet %x (%i B)", + msg.getId(), msg.getLength()); + } + + // Clean up the packet now that we're done using it. + enet_packet_destroy(packet); + } } void Net::flush() diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 5cd6d20d..2f8d78d4 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -132,4 +132,3 @@ NPCDB::get(int id) return *(i->second); } } - diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index bebd17f8..3d42d92e 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -95,11 +95,15 @@ ResourceManager::~ResourceManager() void ResourceManager::cleanUp(Resource *res) { - logger->log("ResourceManager::~ResourceManager() cleaning up %d " + if (res->mRefCount > 0) + { + logger->log("ResourceManager::~ResourceManager() cleaning up %d " "reference%s to %s", res->mRefCount, (res->mRefCount == 1) ? "" : "s", res->mIdPath.c_str()); + } + delete res; } diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 47f1bd04..05df9f1d 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -26,7 +26,7 @@ namespace XML { Document::Document(const std::string &filename): - mDoc(NULL) + mDoc(0) { int size; ResourceManager *resman = ResourceManager::getInstance(); @@ -59,8 +59,7 @@ namespace XML return mDoc ? xmlDocGetRootElement(mDoc) : 0; } - int - getProperty(xmlNodePtr node, const char* name, int def) + int getProperty(xmlNodePtr node, const char* name, int def) { int &ret = def; @@ -73,8 +72,7 @@ namespace XML return ret; } - double - getFloatProperty(xmlNodePtr node, const char* name, double def) + double getFloatProperty(xmlNodePtr node, const char* name, double def) { double &ret = def; @@ -87,8 +85,8 @@ namespace XML return ret; } - std::string - getProperty(xmlNodePtr node, const char *name, const std::string &def) + std::string getProperty(xmlNodePtr node, const char *name, + const std::string &def) { xmlChar *prop = xmlGetProp(node, BAD_CAST name); if (prop) { @@ -108,4 +106,5 @@ namespace XML return NULL; } -} + +} // namespace XML diff --git a/src/utils/xml.h b/src/utils/xml.h index 5a5c756b..d0aba62e 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -71,20 +71,18 @@ namespace XML /** * Gets an integer property from an xmlNodePtr. */ - int - getProperty(xmlNodePtr node, const char *name, int def); + int getProperty(xmlNodePtr node, const char *name, int def); /** * Gets an floating point property from an xmlNodePtr. */ - double - getFloatProperty(xmlNodePtr node, const char *name, double def); + double getFloatProperty(xmlNodePtr node, const char *name, double def); /** * Gets a string property from an xmlNodePtr. */ - std::string - getProperty(xmlNodePtr node, const char *name, const std::string &def); + std::string getProperty(xmlNodePtr node, const char *name, + const std::string &def); /** * Finds the first child node with the given name |