From 4fb390a44431f3984cf21a4b719803a1977593c2 Mon Sep 17 00:00:00 2001 From: No Name Date: Thu, 22 Apr 2010 05:41:08 -0700 Subject: Fix keyboard target selection to allow player targeting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modifies BeingManager::findNearestLivingBeing() behaviour to exclude an optional being from the search. Signed-off-by: Thorbjørn Lindeijer Signed-off-by: Jared Adams --- src/beingmanager.cpp | 12 +++++++----- src/beingmanager.h | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 26672de0..656b297e 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -213,8 +213,8 @@ void BeingManager::clear() } Being *BeingManager::findNearestLivingBeing(int x, int y, - int maxTileDist, - Being::Type type) const + int maxTileDist, Being::Type type, + Being *excluded) const { Being *closestBeing = 0; int dist = 0; @@ -231,8 +231,9 @@ Being *BeingManager::findNearestLivingBeing(int x, int y, int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y); if ((being->getType() == type || type == Being::UNKNOWN) - && (d < dist || !closestBeing) // it is closer - && being->isAlive()) // no dead beings + && (d < dist || !closestBeing) // it is closer + && being->isAlive() // no dead beings + && being != excluded) { dist = d; closestBeing = being; @@ -246,7 +247,8 @@ Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxDist, Being::Type type) const { const Vector &pos = aroundBeing->getPosition(); - return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type); + return findNearestLivingBeing((int)pos.x, (int)pos.y, maxDist, type, + aroundBeing); } bool BeingManager::hasBeing(Being *being) const diff --git a/src/beingmanager.h b/src/beingmanager.h index d81db668..7fd63afe 100644 --- a/src/beingmanager.h +++ b/src/beingmanager.h @@ -75,9 +75,11 @@ class BeingManager * @param maxTileDist Maximal distance in tiles. If minimal distance is * larger, no being is returned. * @param type The type of being to look for. + * @param excluded The being to exclude from the search. */ Being *findNearestLivingBeing(int x, int y, int maxTileDist, - Being::Type type = Being::UNKNOWN) const; + Being::Type type = Being::UNKNOWN, + Being *excluded = 0) const; /** * Returns a being nearest to another being. @@ -88,7 +90,7 @@ class BeingManager * @param type The type of being to look for. */ Being *findNearestLivingBeing(Being *aroundBeing, int maxTileDist, - Being::Type type = Being::UNKNOWN) const; + Being::Type type = Being::UNKNOWN) const; /** * Finds a being by name and (optionally) by type. -- cgit v1.2.3-70-g09d2 From 7070be634b756cb98659cd788d64ef8a912b1858 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Fri, 23 Apr 2010 11:21:09 +0200 Subject: Fixed remoitnane mentioned as "No Name" in the shortlog --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index 629fc8ac..d9e31ee6 100644 --- a/.mailmap +++ b/.mailmap @@ -8,4 +8,5 @@ Falkreon Ira Rice Majin Sniper Maximilian Philipps +remoitnane Victor Fury -- cgit v1.2.3-70-g09d2 From f07260b4a1c43611c0839b5adf735a2c13ad8348 Mon Sep 17 00:00:00 2001 From: Bertram Date: Sun, 25 Apr 2010 21:35:52 +0200 Subject: Fixed the VideoMode listBox logic in the setup window. Reviewed by: Jaxad0127 --- src/gui/setup_video.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 8ce6eebd..ebe53261 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -81,6 +81,13 @@ class ModeListModel : public gcn::ListModel */ std::string getElementAt(int i) { return mVideoModes[i]; } + /** + * Returns the index corresponding to the given video mode. + * E.g.: "800x600". + * or -1 if not found. + */ + int getIndexOf(const std::string &widthXHeightMode); + private: std::vector mVideoModes; }; @@ -108,6 +115,20 @@ ModeListModel::ModeListModel() } } +int ModeListModel::getIndexOf(const std::string &widthXHeightMode) +{ + std::string currentMode = ""; + for (int i = 0; i < getNumberOfElements(); i++) + { + currentMode = getElementAt(i); + if (currentMode == widthXHeightMode) + { + return i; + } + } + return -1; +} + const char *SIZE_NAME[4] = { N_("Tiny"), @@ -256,6 +277,11 @@ Setup_Video::Setup_Video(): mFpsSlider->setEnabled(mFps > 0); mFpsCheckBox->setSelected(mFps > 0); + // Pre-select the current video mode. + std::string videoMode = toString(graphics->getWidth()) + "x" + + toString(graphics->getHeight()); + mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); + mModeList->setActionEventId("videomode"); mCustomCursorCheckBox->setActionEventId("customcursor"); mShowMonsterDamageCheckBox->setActionEventId("monsterdamage"); @@ -462,6 +488,14 @@ void Setup_Video::cancel() mFpsLabel->setCaption(text); config.setValue("screen", mFullScreenEnabled); + + // Set back to the current video mode. + std::string videoMode = toString(graphics->getWidth()) + "x" + + toString(graphics->getHeight()); + mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); + config.setValue("screenwidth", graphics->getWidth()); + config.setValue("screenheight", graphics->getHeight()); + config.setValue("customcursor", mCustomCursorEnabled); config.setValue("showMonstersTakedDamage", mShowMonsterDamageEnabled); config.setValue("visiblenames", mVisibleNamesEnabled); -- cgit v1.2.3-70-g09d2 From 33481831b44f7e6fded6b9be29f1ea56bf74bfa2 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sat, 24 Apr 2010 18:26:50 -0600 Subject: Fix some storage bugs Reviewed-by: Bertram --- src/gui/inventorywindow.cpp | 30 +++++++++++++++--------------- src/gui/inventorywindow.h | 2 ++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index f214fde5..591ebd2f 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -60,7 +60,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mInventory(inventory), mSplit(false) { - setWindowName(inventory->isMainInventory() ? "Inventory" : "Storage"); + setWindowName(isMainInventory() ? "Inventory" : "Storage"); setupWindow->registerWindowForReset(this); setResizable(true); setCloseButton(true); @@ -80,7 +80,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mSlotsLabel = new Label(_("Slots:")); mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS); - if (inventory->isMainInventory()) + if (isMainInventory()) { std::string equip = _("Equip"); std::string use = _("Use"); @@ -137,7 +137,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): loadWindowState(); slotsChanged(mInventory); - if (!inventory->isMainInventory()) + if (!isMainInventory()) setVisible(true); } @@ -158,6 +158,17 @@ void InventoryWindow::action(const gcn::ActionEvent &event) outfitWindow->requestMoveToTop(); } } + else if (event.getId() == "store") + { + if (!inventoryWindow->isVisible()) return; + + Item *item = inventoryWindow->getSelectedItem(); + + if (!item) + return; + + ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, this, item); + } Item *item = mItems->getSelectedItem(); @@ -185,17 +196,6 @@ void InventoryWindow::action(const gcn::ActionEvent &event) ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item, (item->getQuantity() - 1)); } - else if (event.getId() == "store") - { - if (!inventoryWindow->isVisible()) return; - - Item *item = inventoryWindow->getSelectedItem(); - - if (!item) - return; - - ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, this, item); - } else if (event.getId() == "retrieve") { Item *item = mItems->getSelectedItem(); @@ -229,7 +229,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) */ const int mx = event.getX() + getX(); const int my = event.getY() + getY(); - viewport->showPopup(this, mx, my, item); + viewport->showPopup(this, mx, my, item, isMainInventory()); } if (event.getButton() == gcn::MouseEvent::LEFT) diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 948482f5..f611e934 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -108,6 +108,8 @@ class InventoryWindow : public Window, void slotsChanged(Inventory* inventory); + bool isMainInventory() { return mInventory->isMainInventory(); } + /** * Returns true if any instances exist. */ -- cgit v1.2.3-70-g09d2 From 88524a71b8d3727b5ad4a8a60e146fd8e786b7ad Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 23 Apr 2010 22:15:26 -0600 Subject: Make ManaServ player stats softcoded A new stats.xml file is parsed for player stats for ManaServ. The old hardcoded stats remain as backup. Reviewed-by: Bertram --- mana.cbp | 2 + mana.files | 2 + src/CMakeLists.txt | 2 + src/Makefile.am | 2 + src/gui/statuswindow.cpp | 3 +- src/gui/statuswindow.h | 3 +- src/net/manaserv/generalhandler.cpp | 27 ++--- src/net/manaserv/stats.cpp | 202 ++++++++++++++++++++++++++++++++++++ src/net/manaserv/stats.h | 36 +++++++ src/net/tmwa/generalhandler.cpp | 40 +++---- 10 files changed, 280 insertions(+), 39 deletions(-) create mode 100644 src/net/manaserv/stats.cpp create mode 100644 src/net/manaserv/stats.h diff --git a/mana.cbp b/mana.cbp index 3d3b85e0..cc12f237 100644 --- a/mana.cbp +++ b/mana.cbp @@ -469,6 +469,8 @@ + + diff --git a/mana.files b/mana.files index 552ab8a6..1a6026f3 100644 --- a/mana.files +++ b/mana.files @@ -407,6 +407,8 @@ ./src/net/manaserv/protocol.h ./src/net/manaserv/specialhandler.cpp ./src/net/manaserv/specialhandler.h +./src/net/manaserv/stats.cpp +./src/net/manaserv/stats.h ./src/net/manaserv/tradehandler.cpp ./src/net/manaserv/tradehandler.h ./src/net/messagehandler.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 02a08bfe..8172311e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -599,6 +599,8 @@ SET(SRCS_MANA net/manaserv/protocol.h net/manaserv/specialhandler.cpp net/manaserv/specialhandler.h + net/manaserv/stats.cpp + net/manaserv/stats.h net/manaserv/tradehandler.cpp net/manaserv/tradehandler.h ) diff --git a/src/Makefile.am b/src/Makefile.am index 9748dd67..d12a9a56 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -451,6 +451,8 @@ mana_SOURCES += \ net/manaserv/protocol.h \ net/manaserv/specialhandler.cpp \ net/manaserv/specialhandler.h \ + net/manaserv/stats.cpp \ + net/manaserv/stats.h \ net/manaserv/tradehandler.cpp \ net/manaserv/tradehandler.h diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 498a4523..2439a213 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -283,7 +283,8 @@ void StatusWindow::setPointsNeeded(int id, int needed) } void StatusWindow::addAttribute(int id, const std::string &name, - bool modifiable) + bool modifiable, + const std::string &description) { AttrDisplay *disp; diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 13ee9a68..a1fc4b4b 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -61,7 +61,8 @@ class StatusWindow : public Window void setPointsNeeded(int id, int needed); - void addAttribute(int id, const std::string &name, bool modifiable); + void addAttribute(int id, const std::string &name, bool modifiable, + const std::string &description); static void updateHPBar(ProgressBar *bar, bool showMax = false); static void updateMPBar(ProgressBar *bar, bool showMax = false); diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 454052f7..09f68c1e 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -29,7 +29,6 @@ #include "gui/register.h" #include "gui/skilldialog.h" #include "gui/specialswindow.h" -#include "gui/statuswindow.h" #include "net/manaserv/beinghandler.h" #include "net/manaserv/buysellhandler.h" @@ -47,6 +46,7 @@ #include "net/manaserv/partyhandler.h" #include "net/manaserv/playerhandler.h" #include "net/manaserv/specialhandler.h" +#include "net/manaserv/stats.h" #include "net/manaserv/tradehandler.h" #include "utils/gettext.h" @@ -90,16 +90,6 @@ GeneralHandler::GeneralHandler(): chatServerConnection = getConnection(); generalHandler = this; - - std::list stats; - stats.push_back(ItemDB::Stat("str", N_("Strength %+d"))); - stats.push_back(ItemDB::Stat("agi", N_("Agility %+d"))); - stats.push_back(ItemDB::Stat("dex", N_("Dexterity %+d"))); - stats.push_back(ItemDB::Stat("vit", N_("Vitality %+d"))); - stats.push_back(ItemDB::Stat("int", N_("Intelligence %+d"))); - stats.push_back(ItemDB::Stat("will", N_("Willpower %+d"))); - - ItemDB::setStatsList(stats); } void GeneralHandler::load() @@ -118,6 +108,9 @@ void GeneralHandler::load() registerHandler(mPartyHandler.get()); registerHandler(mPlayerHandler.get()); registerHandler(mTradeHandler.get()); + + Stats::load(); + Stats::informItemDB(); } void GeneralHandler::reload() @@ -136,6 +129,10 @@ void GeneralHandler::reload() netToken.clear(); gameServer.clear(); chatServer.clear(); + + Stats::unload(); + Stats::load(); + Stats::informItemDB(); } void GeneralHandler::unload() @@ -153,6 +150,7 @@ void GeneralHandler::unload() delete gameServerConnection; delete chatServerConnection; + Stats::unload(); finalize(); } @@ -176,12 +174,7 @@ void GeneralHandler::guiWindowsLoaded() player_node->setExpNeeded(100); - statusWindow->addAttribute(16, _("Strength"), true); - statusWindow->addAttribute(17, _("Agility"), true); - statusWindow->addAttribute(18, _("Dexterity"), true); - statusWindow->addAttribute(19, _("Vitality"), true); - statusWindow->addAttribute(20, _("Intelligence"), true); - statusWindow->addAttribute(21, _("Willpower"), true); + Stats::informStatusWindow(); } void GeneralHandler::guiWindowsUnloaded() diff --git a/src/net/manaserv/stats.cpp b/src/net/manaserv/stats.cpp new file mode 100644 index 00000000..b79b1fd9 --- /dev/null +++ b/src/net/manaserv/stats.cpp @@ -0,0 +1,202 @@ +/* + * The Mana Client + * Copyright (C) 2010 The Mana Developers + * + * This file is part of The Mana Client. + * + * 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, see . + */ + +#include "net/manaserv/stats.h" + +#include "log.h" + +#include "gui/statuswindow.h" + +#include "resources/itemdb.h" + +#include "utils/gettext.h" +#include "utils/xml.h" + +#include +#include + +namespace ManaServ { +namespace Stats { + typedef struct { + unsigned int id; + std::string name; + std::string tag; + std::string effect; + std::string description; + bool modifiable; + } Stat; + + typedef std::map StatMap; + StatMap stats; + + static void loadBuiltins() + { + { + Stat s; + s.id = 16; + s.name = _("Strength"); + s.tag = "str"; + s.effect = _("Strength %+d"); + s.description = ""; + s.modifiable = true; + + stats[s.id] = s; + } + + { + Stat s; + s.id = 17; + s.name = _("Agility"); + s.tag = "agi"; + s.effect = _("Agility %+d"); + s.description = ""; + s.modifiable = true; + + stats[s.id] = s; + } + + { + Stat s; + s.id = 18; + s.name = _("Dexterity"); + s.tag = "dex"; + s.effect = _("Dexterity %+d"); + s.description = ""; + s.modifiable = true; + + stats[s.id] = s; + } + + { + Stat s; + s.id = 19; + s.name = _("Vitality"); + s.tag = "vit"; + s.effect = _("Vitality %+d"); + s.description = ""; + s.modifiable = true; + + stats[s.id] = s; + } + + { + Stat s; + s.id = 20; + s.name = _("Intelligence"); + s.tag = "int"; + s.effect = _("Intelligence %+d"); + s.description = ""; + s.modifiable = true; + + stats[s.id] = s; + } + + { + Stat s; + s.id = 21; + s.name = _("Willpower"); + s.tag = "will"; + s.effect = _("Willpower %+d"); + s.description = ""; + s.modifiable = true; + + stats[s.id] = s; + } + } + + void load() + { + XML::Document doc("stats.xml"); + xmlNodePtr rootNode = doc.rootNode(); + + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "stats")) + { + logger->log("Stats: Error while loading stats.xml!"); + loadBuiltins(); + return; + } + + for_each_xml_child_node(node, rootNode) + { + if (!xmlStrEqual(node->name, BAD_CAST "stat")) + continue; + + int id = XML::getProperty(node, "id", 0); + + if (id == 0) + { + logger->log("Stats: Invalid or missing stat ID in stats.xml!"); + continue; + } + else if (stats.find(id) != stats.end()) + { + logger->log("Stats: Redefinition of stat ID %d", id); + } + + std::string name = XML::getProperty(node, "name", ""); + + if (name.empty()) + { + logger->log("Stats: Invalid or missing stat name in " + "stats.xml!"); + continue; + } + + Stat s; + s.id = id; + s.name = name; + s.tag = XML::getProperty(node, "tag", ""); + s.effect = XML::getProperty(node, "effect", ""); + s.description = XML::getProperty(node, "desc", ""); + s.modifiable = XML::getProperty(node, "modifiable", "false") + == "true"; + + stats[id] = s; + } + } + + void unload() + { + stats.clear(); + } + + void informItemDB() + { + std::list dbStats; + + StatMap::const_iterator it, it_end; + for (it = stats.begin(), it_end = stats.end(); it != it_end; it++) + if (!it->second.tag.empty()) + dbStats.push_back(ItemDB::Stat(it->second.tag, + it->second.effect)); + + ItemDB::setStatsList(dbStats); + } + + void informStatusWindow() + { + StatMap::const_iterator it, it_end; + for (it = stats.begin(), it_end = stats.end(); it != it_end; it++) + statusWindow->addAttribute(it->second.id, it->second.name, + it->second.modifiable, + it->second.description); + } +} // namespace Stats +} // namespace ManaServ diff --git a/src/net/manaserv/stats.h b/src/net/manaserv/stats.h new file mode 100644 index 00000000..c4afbd79 --- /dev/null +++ b/src/net/manaserv/stats.h @@ -0,0 +1,36 @@ +/* + * The Mana Client + * Copyright (C) 2010 The Mana Developers + * + * This file is part of The Mana Client. + * + * 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, see . + */ + +#ifndef NET_MANASERV_STATS_H +#define NET_MANASERV_STATS_H + +namespace ManaServ { +namespace Stats { + void load(); + + void unload(); + + void informItemDB(); + + void informStatusWindow(); +} // namespace Stats +} // namespace ManaServ + +#endif // NET_MANASERV_STATS_H diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index a975abe8..14f48055 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -98,12 +98,12 @@ GeneralHandler::GeneralHandler(): generalHandler = this; std::list stats; - stats.push_back(ItemDB::Stat("str", N_("Strength %+d"))); - stats.push_back(ItemDB::Stat("agi", N_("Agility %+d"))); - stats.push_back(ItemDB::Stat("vit", N_("Vitality %+d"))); - stats.push_back(ItemDB::Stat("int", N_("Intelligence %+d"))); - stats.push_back(ItemDB::Stat("dex", N_("Dexterity %+d"))); - stats.push_back(ItemDB::Stat("luck", N_("Luck %+d"))); + stats.push_back(ItemDB::Stat("str", _("Strength %+d"))); + stats.push_back(ItemDB::Stat("agi", _("Agility %+d"))); + stats.push_back(ItemDB::Stat("vit", _("Vitality %+d"))); + stats.push_back(ItemDB::Stat("int", _("Intelligence %+d"))); + stats.push_back(ItemDB::Stat("dex", _("Dexterity %+d"))); + stats.push_back(ItemDB::Stat("luck", _("Luck %+d"))); ItemDB::setStatsList(stats); } @@ -214,20 +214,20 @@ void GeneralHandler::guiWindowsLoaded() inventoryWindow->setSplitAllowed(false); skillDialog->loadSkills("ea-skills.xml"); - statusWindow->addAttribute(STR, _("Strength"), true); - statusWindow->addAttribute(AGI, _("Agility"), true); - statusWindow->addAttribute(VIT, _("Vitality"), true); - statusWindow->addAttribute(INT, _("Intelligence"), true); - statusWindow->addAttribute(DEX, _("Dexterity"), true); - statusWindow->addAttribute(LUK, _("Luck"), true); - - statusWindow->addAttribute(ATK, _("Attack"), false); - statusWindow->addAttribute(DEF, _("Defense"), false); - statusWindow->addAttribute(MATK, _("M.Attack"), false); - statusWindow->addAttribute(MDEF, _("M.Defense"), false); - statusWindow->addAttribute(HIT, _("% Accuracy"), false); - statusWindow->addAttribute(FLEE, _("% Evade"), false); - statusWindow->addAttribute(CRIT, _("% Critical"), false); + statusWindow->addAttribute(STR, _("Strength"), true, ""); + statusWindow->addAttribute(AGI, _("Agility"), true, ""); + statusWindow->addAttribute(VIT, _("Vitality"), true, ""); + statusWindow->addAttribute(INT, _("Intelligence"), true, ""); + statusWindow->addAttribute(DEX, _("Dexterity"), true, ""); + statusWindow->addAttribute(LUK, _("Luck"), true, ""); + + statusWindow->addAttribute(ATK, _("Attack"), false, ""); + statusWindow->addAttribute(DEF, _("Defense"), false, ""); + statusWindow->addAttribute(MATK, _("M.Attack"), false, ""); + statusWindow->addAttribute(MDEF, _("M.Defense"), false, ""); + statusWindow->addAttribute(HIT, _("% Accuracy"), false, ""); + statusWindow->addAttribute(FLEE, _("% Evade"), false, ""); + statusWindow->addAttribute(CRIT, _("% Critical"), false, ""); } void GeneralHandler::guiWindowsUnloaded() -- cgit v1.2.3-70-g09d2 From 5e75167f64473d645e40d7f6eb58eb1ef8f6cdea Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 25 Apr 2010 20:06:53 -0600 Subject: Fix some button issues in SocialWindow The invite and leave buttons are now only enabled when there are tabs. Also, the code to handle them will do nothing if no tab is selected (backup logic). Reviewed-by: Chuck Miller --- src/gui/socialwindow.cpp | 21 +++++++++++++++++++-- src/gui/socialwindow.h | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 10ed680e..468a94c4 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -328,6 +328,8 @@ SocialWindow::SocialWindow() : { addTab(player_node->getParty()); } + else + updateButtons(); } SocialWindow::~SocialWindow() @@ -362,6 +364,8 @@ bool SocialWindow::addTab(Guild *guild) mTabs->addTab(tab, tab->mScroll); + updateButtons(); + return true; } @@ -375,6 +379,8 @@ bool SocialWindow::removeTab(Guild *guild) delete it->second; mGuilds.erase(it); + updateButtons(); + return true; } @@ -388,6 +394,8 @@ bool SocialWindow::addTab(Party *party) mTabs->addTab(tab, tab->mScroll); + updateButtons(); + return true; } @@ -401,6 +409,8 @@ bool SocialWindow::removeTab(Party *party) delete it->second; mParties.erase(it); + updateButtons(); + return true; } @@ -453,11 +463,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) else showPartyCreate(); } - else if (event.getId() == "invite") + else if (event.getId() == "invite" && mTabs->getSelectedTabIndex() > -1) { static_cast(mTabs->getSelectedTab())->invite(); } - else if (event.getId() == "leave") + else if (event.getId() == "leave" && mTabs->getSelectedTabIndex() > -1) { static_cast(mTabs->getSelectedTab())->leave(); } @@ -596,3 +606,10 @@ void SocialWindow::showPartyCreate() mPartyCreateDialog->setActionEventId("create party"); mPartyCreateDialog->addActionListener(this); } + +void SocialWindow::updateButtons() +{ + bool hasTabs = mTabs->getNumberOfTabs() > 0; + mInviteButton->setEnabled(hasTabs); + mLeaveButton->setEnabled(hasTabs); +} diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index d3e69cc5..885c0e54 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -77,6 +77,8 @@ public: protected: friend class SocialTab; + void updateButtons(); + int mGuildInvited; ConfirmDialog *mGuildAcceptDialog; TextDialog *mGuildCreateDialog; -- cgit v1.2.3-70-g09d2 From bba1a7e5a92f0df2ae879f0ea0cd064a25c915ab Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 25 Apr 2010 19:17:03 -0600 Subject: Fix resource errors when chaning servers Reviewed-by: Freeyorp --- src/client.cpp | 16 ++++++++-------- src/statuseffect.cpp | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 44df362e..8d916add 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -435,14 +435,6 @@ Client::~Client() // Shutdown sound sound.close(); - // Unload XML databases - ColorDB::unload(); - EmoteDB::unload(); - ItemDB::unload(); - MonsterDB::unload(); - NPCDB::unload(); - StatusEffect::unload(); - ResourceManager::deleteInstance(); SDL_FreeSurface(mIcon); @@ -583,6 +575,14 @@ int Client::exec() { delete game; game = 0; + + // Unload XML databases + ColorDB::unload(); + EmoteDB::unload(); + ItemDB::unload(); + MonsterDB::unload(); + NPCDB::unload(); + StatusEffect::unload(); } mOldState = mState; diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 66e8010d..49619f8a 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -169,6 +169,8 @@ void unloadMap(std::map map) for (it = map.begin(); it != map.end(); it++) delete (*it).second; + + map.clear(); } void StatusEffect::unload() -- cgit v1.2.3-70-g09d2 From 4f55e04014375922d41347e6d5816c91a0dfe349 Mon Sep 17 00:00:00 2001 From: Bernd Wachter Date: Sun, 2 May 2010 18:29:24 +0300 Subject: Add some basic CPack stuff --- CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2836d1ef..15a55d91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,3 +54,20 @@ ENDIF() If(UNIX) INSTALL(FILES mana.desktop DESTINATION share/applications) ENDIF() + +SET(CPACK_PACKAGE_NAME "mana") +SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Mana") +SET(CPACK_PACKAGE_VENDOR "Mana Development Team") +SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") +SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") +SET(CPACK_PACKAGE_INSTALL_DIRECTORY "Mana") +SET(CPACK_PACKAGE_VERSION_MAJOR ${VER_MAJOR}) +SET(CPACK_PACKAGE_VERSION_MINOR ${VER_MINOR}) +SET(CPACK_PACKAGE_VERSION_PATCH ${VER_RELEASE}) +IF(WIN32) + SET(CPACK_NSIS_DISPLAY_NAME "Mana") + SET(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/data/icons/mana.ico") + SET(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/packaging/windows/setup_welcome.bmp") + SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.manasource.org") +ENDIF() +INCLUDE(CPack) \ No newline at end of file -- cgit v1.2.3-70-g09d2 From b5bf64c2106709b41ddd966e53e22fc87f47413c Mon Sep 17 00:00:00 2001 From: Bernd Wachter Date: Sun, 2 May 2010 18:29:42 +0300 Subject: Fix cmake builds for OS X --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8172311e..b15948d3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,6 +41,8 @@ ENDIF() IF (WIN32) SET(EXTRA_LIBRARIES ws2_32 winmm) FIND_PACKAGE(LibIntl REQUIRED) +ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + FIND_PACKAGE(LibIntl REQUIRED) ELSEIF (CMAKE_SYSTEM_NAME STREQUAL SunOS) # explicit linking to libintl is required on Solaris SET(EXTRA_LIBRARIES intl) -- cgit v1.2.3-70-g09d2 From 5cc53c54b43e663e65b74e959543aa02a03cf2ea Mon Sep 17 00:00:00 2001 From: Maximilian Philipps Date: Mon, 3 May 2010 16:57:01 +0200 Subject: synchronised protocol.h between manaserv, mana and manamobile --- src/net/manaserv/charhandler.cpp | 6 +-- src/net/manaserv/loginhandler.cpp | 8 ++-- src/net/manaserv/protocol.h | 94 ++++++++++++++++++++++++++++++--------- 3 files changed, 79 insertions(+), 29 deletions(-) diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index c070ab23..fdf0a02c 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -150,13 +150,13 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg) case CREATE_INVALID_GENDER: errorMessage = _("Invalid gender."); break; - case CREATE_RAW_STATS_TOO_HIGH: + case CREATE_ATTRIBUTES_TOO_HIGH: errorMessage = _("Character's stats are too high."); break; - case CREATE_RAW_STATS_TOO_LOW: + case CREATE_ATTRIBUTES_TOO_LOW: errorMessage = _("Character's stats are too low."); break; - case CREATE_RAW_STATS_EQUAL_TO_ZERO: + case CREATE_ATTRIBUTES_EQUAL_TO_ZERO: errorMessage = _("One stat is zero."); break; default: diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index e51aef6f..cb25f584 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -89,8 +89,8 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) case ERRMSG_FAILURE: errorMessage = _("Already logged in."); break; - case LOGIN_SERVER_FULL: - errorMessage = _("Server is full."); + case LOGIN_BANNED: + errorMessage = _("Account banned."); break; default: errorMessage = _("Unknown error."); @@ -268,8 +268,8 @@ void LoginHandler::handleLoginResponse(Net::MessageIn &msg) case ERRMSG_FAILURE: errorMessage = _("Already logged in."); break; - case LOGIN_SERVER_FULL: - errorMessage = _("Server is full."); + case LOGIN_BANNED: + errorMessage = _("Account banned"); break; case LOGIN_INVALID_TIME: errorMessage = _("Login attempt too soon after previous " diff --git a/src/net/manaserv/protocol.h b/src/net/manaserv/protocol.h index dc120fa2..2654da74 100644 --- a/src/net/manaserv/protocol.h +++ b/src/net/manaserv/protocol.h @@ -31,23 +31,26 @@ * - CPMSG_*: from chat server to client * - PGMSG_*: from client to game server * - GPMSG_*: from game server to client + * - GAMSG_*: from game server to account server * * Components: B byte, W word, D double word, S variable-size string * C tile-based coordinates (B*3) * * Hosts: P (player's client), A (account server), C (char server), * G (game server) + * + * TODO - Document specific error codes for each packet */ enum { // Login/Register - PAMSG_REGISTER = 0x0000, // L version, S username, S password, S email, S captcha response - APMSG_REGISTER_RESPONSE = 0x0002, // B error [, S updatehost] - PAMSG_UNREGISTER = 0x0003, // - + PAMSG_REGISTER = 0x0000, // D version, S username, S password, S email, S captcha response + APMSG_REGISTER_RESPONSE = 0x0002, // B error, [S updatehost] + PAMSG_UNREGISTER = 0x0003, // S username, S password APMSG_UNREGISTER_RESPONSE = 0x0004, // B error PAMSG_REQUEST_REGISTER_INFO = 0x0005, // - APMSG_REGISTER_INFO_RESPONSE = 0x0006, // B byte registrationAllowed, byte minNameLength, byte maxNameLength, string captchaURL, string captchaInstructions - PAMSG_LOGIN = 0x0010, // L version, S username, S password - APMSG_LOGIN_RESPONSE = 0x0012, // B error [, S updatehost] + APMSG_REGISTER_INFO_RESPONSE = 0x0006, // B byte registration Allowed, byte minNameLength, byte maxNameLength, string captchaURL, string captchaInstructions + PAMSG_LOGIN = 0x0010, // D version, S username, S password + APMSG_LOGIN_RESPONSE = 0x0012, // B error, [S updatehost] PAMSG_LOGOUT = 0x0013, // - APMSG_LOGOUT_RESPONSE = 0x0014, // B error PAMSG_CHAR_CREATE = 0x0020, // S name, B hair style, B hair color, B gender, W*6 stats @@ -87,7 +90,7 @@ enum { GPMSG_INVENTORY_FULL = 0x0121, // { B slot, W item id [, B amount] }* GPMSG_PLAYER_ATTRIBUTE_CHANGE = 0x0130, // { W attribute, W base value, W modified value }* GPMSG_PLAYER_EXP_CHANGE = 0x0140, // { W skill, D exp got, D exp needed }* - GPMSG_LEVELUP = 0x0150, // W new level + GPMSG_LEVELUP = 0x0150, // W new level, W character points, W correction points GPMSG_LEVEL_PROGRESS = 0x0151, // B percent completed to next levelup PGMSG_RAISE_ATTRIBUTE = 0x0160, // B attribute GPMSG_RAISE_ATTRIBUTE_RESPONSE = 0x0161, // B error, B attribute @@ -95,7 +98,7 @@ enum { GPMSG_LOWER_ATTRIBUTE_RESPONSE = 0x0171, // B error, B attribute PGMSG_RESPAWN = 0x0180, // - GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position - // player: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }* + // character: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }* // monster: W type id // npc: W type id GPMSG_BEING_LEAVE = 0x0201, // W being id @@ -106,12 +109,13 @@ enum { GPMSG_BEING_ACTION_CHANGE = 0x0271, // W being id, B action PGMSG_DIRECTION_CHANGE = 0x0272, // B Direction GPMSG_BEING_DIR_CHANGE = 0x0273, // W being id, B direction + GPMSG_BEING_HEALTH_CHANGE = 0x0274, // W being id, W health GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, W*2 position, B speed] }* GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }* PGMSG_ATTACK = 0x0290, // W being id - GPMSG_BEING_ATTACK = 0x0291, // W being id + GPMSG_BEING_ATTACK = 0x0291, // W being id, B direction, B attacktype PGMSG_USE_SPECIAL = 0x0292, // B specialID - GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, L current, L max, L recharge } + GPMSG_SPECIAL_STATUS = 0x0293, // { B specialID, D current, D max, D recharge } PGMSG_SAY = 0x02A0, // S text GPMSG_SAY = 0x02A1, // W being id, S text GPMSG_NPC_CHOICE = 0x02B0, // W being id, { S text }* @@ -125,11 +129,11 @@ enum { GPMSG_NPC_ERROR = 0x02B8, // B error GPMSG_NPC_CLOSE = 0x02B9, // W being id GPMSG_NPC_POST = 0x02D0, // W being id - PGMSG_NPC_POST_SEND = 0x02D1, // S name, S text, W item id + PGMSG_NPC_POST_SEND = 0x02D1, // W being id, { S name, S text, W item id } GPMSG_NPC_POST_GET = 0x02D2, // W being id, { S name, S text, W item id } - PGMSG_NPC_NUMBER = 0x02D3, // W being id, L number + PGMSG_NPC_NUMBER = 0x02D3, // W being id, D number PGMSG_NPC_STRING = 0x02D4, // W being id, S string - GPMSG_NPC_NUMBER = 0x02D5, // W being id, L max, L min, L default + GPMSG_NPC_NUMBER = 0x02D5, // W being id, D max, D min, D default GPMSG_NPC_STRING = 0x02D6, // W being id PGMSG_TRADE_REQUEST = 0x02C0, // W being id GPMSG_TRADE_REQUEST = 0x02C1, // W being id @@ -143,8 +147,8 @@ enum { GPMSG_TRADE_CONFIRM = 0x02C9, // - PGMSG_TRADE_ADD_ITEM = 0x02CA, // B slot, B amount GPMSG_TRADE_ADD_ITEM = 0x02CB, // W item id, B amount - PGMSG_TRADE_SET_MONEY = 0x02CC, // L amount - GPMSG_TRADE_SET_MONEY = 0x02CD, // L amount + PGMSG_TRADE_SET_MONEY = 0x02CC, // D amount + GPMSG_TRADE_SET_MONEY = 0x02CD, // D amount GPMSG_TRADE_BOTH_CONFIRM = 0x02CE, // - PGMSG_USE_ITEM = 0x0300, // B slot GPMSG_USE_RESPONSE = 0x0301, // B error @@ -174,7 +178,7 @@ enum { // Party PCMSG_PARTY_INVITE = 0x03A0, // S name - CPMSG_PARTY_INVITE_RESPONSE = 0x03A1, // B error + CPMSG_PARTY_INVITE_RESPONSE = 0x03A1, // B error, S name CPMSG_PARTY_INVITED = 0x03A2, // S name PCMSG_PARTY_ACCEPT_INVITE = 0x03A5, // S name CPMSG_PARTY_ACCEPT_INVITE_RESPONSE = 0x03A6, // B error, { S name } @@ -207,10 +211,34 @@ enum { PCMSG_LIST_CHANNELUSERS = 0x0460, // S channel CPMSG_LIST_CHANNELUSERS_RESPONSE = 0x0461, // S channel, { S user, B mode } PCMSG_TOPIC_CHANGE = 0x0462, // W channel id, S topic - // -- User mode + // -- User modes PCMSG_USER_MODE = 0x0465, // W channel id, S name, B mode PCMSG_KICK_USER = 0x0466, // W channel id, S name + // Inter-server + GAMSG_REGISTER = 0x0500, // S address, W port, S password, D items db revision, { W map id }* + AGMSG_REGISTER_RESPONSE = 0x0501, // C item version, C password response + AGMSG_ACTIVE_MAP = 0x0502, // W map id + AGMSG_PLAYER_ENTER = 0x0510, // B*32 token, D id, S name, serialised character data + GAMSG_PLAYER_DATA = 0x0520, // D id, serialised character data + GAMSG_REDIRECT = 0x0530, // D id + AGMSG_REDIRECT_RESPONSE = 0x0531, // D id, B*32 token, S game address, W game port + GAMSG_PLAYER_RECONNECT = 0x0532, // D id, B*32 token + GAMSG_PLAYER_SYNC = 0x0533, // serialised sync data + GAMSG_SET_QUEST = 0x0540, // D id, S name, S value + GAMSG_GET_QUEST = 0x0541, // D id, S name + AGMSG_GET_QUEST_RESPONSE = 0x0542, // D id, S name, S value + GAMSG_BAN_PLAYER = 0x0550, // D id, W duration + GAMSG_CHANGE_PLAYER_LEVEL = 0x0555, // D id, W level + GAMSG_CHANGE_ACCOUNT_LEVEL = 0x0556, // D id, W level + GAMSG_STATISTICS = 0x0560, // { W map id, W thing nb, W monster nb, W player nb, { D character id }* }* + CGMSG_CHANGED_PARTY = 0x0590, // D character id, D party id + GCMSG_REQUEST_POST = 0x05A0, // D character id + CGMSG_POST_RESPONSE = 0x05A1, // D receiver id, { S sender name, S letter, W num attachments { W attachment item id, W quantity } } + GCMSG_STORE_POST = 0x05A5, // D sender id, S receiver name, S letter, { W attachment item id, W quantity } + CGMSG_STORE_POST_RESPONSE = 0x05A6, // D id, B error + GAMSG_TRANSACTION = 0x0600, // D character id, D action, S message + XXMSG_INVALID = 0x7FFF }; @@ -226,14 +254,35 @@ enum { ERRMSG_EMAIL_ALREADY_EXISTS, // The Email Address already exists ERRMSG_ALREADY_TAKEN, // name used was already taken ERRMSG_SERVER_FULL, // the server is overloaded - ERRMSG_TIME_OUT // data failed to arrive in due time + ERRMSG_TIME_OUT, // data failed to arrive in due time + ERRMSG_LIMIT_REACHED // limit reached +}; + +// used in AGMSG_REGISTER_RESPONSE to show state of item db +enum { + DATA_VERSION_OK = 0x00, + DATA_VERSION_OUTDATED = 0x01 +}; + +// used in AGMSG_REGISTER_RESPNSE to show if password was accepted +enum { + PASSWORD_OK = 0x00, + PASSWORD_BAD = 0x01 +}; + +// used to identify part of sync message +enum { + SYNC_CHARACTER_POINTS = 0x01, // D charId, D charPoints, D corrPoints, B attribute id, D attribute value + SYNC_CHARACTER_SKILL = 0x02, // D charId, B skillId, D skill value + SYNC_ONLINE_STATUS = 0x03, // D charId, B 0x00 = offline, 0x01 = online + SYNC_END_OF_BUFFER = 0xFF // shows, that the buffer ends here. }; // Login specific return values enum { LOGIN_INVALID_VERSION = 0x40, // the user is using an incompatible protocol LOGIN_INVALID_TIME = 0x50, // the user tried logging in too fast - LOGIN_SERVER_FULL // the server is overloaded + LOGIN_BANNED // the user is currently banned }; // Account register specific return values @@ -249,9 +298,9 @@ enum { CREATE_INVALID_HAIRSTYLE = 0x40, CREATE_INVALID_HAIRCOLOR, CREATE_INVALID_GENDER, - CREATE_RAW_STATS_TOO_HIGH, - CREATE_RAW_STATS_TOO_LOW, - CREATE_RAW_STATS_EQUAL_TO_ZERO, + CREATE_ATTRIBUTES_TOO_HIGH, + CREATE_ATTRIBUTES_TOO_LOW, + CREATE_ATTRIBUTES_EQUAL_TO_ZERO, CREATE_EXISTS_NAME, CREATE_TOO_MUCH_CHARACTERS }; @@ -263,6 +312,7 @@ enum AttribmodResponseCode { ATTRIBMOD_NO_POINTS_LEFT, ATTRIBMOD_DENIED }; + // Object type enumeration enum { // A simple item -- cgit v1.2.3-70-g09d2 From 22a7ac0b9ed82d09460d791016a990b327b61fc4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 3 May 2010 23:57:06 +0300 Subject: Fix mouse attack (tmwa) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Thorbjørn Lindeijer --- src/localplayer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 9729f55d..0b0e22f5 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1296,13 +1296,11 @@ bool LocalPlayer::withinAttackRange(Being *target) } else { - int dist_x = abs(target->getTileX() - getTileY()); - int dist_y = abs(target->getTileY() - getTileX()); + int dist_x = abs(target->getTileX() - getTileX()); + int dist_y = abs(target->getTileY() - getTileY()); if (dist_x > getAttackRange() || dist_y > getAttackRange()) - { return false; - } return true; } -- cgit v1.2.3-70-g09d2 From 375ceb6c78f79e0144c2d63e0f9cda170288da8b Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Mon, 26 Apr 2010 21:56:31 -0600 Subject: Clear NPC dialogs when the player dies Reviewed-by: Freeyorp --- src/net/manaserv/npchandler.cpp | 5 +++++ src/net/manaserv/npchandler.h | 2 ++ src/net/manaserv/playerhandler.cpp | 5 +++++ src/net/tmwa/npchandler.cpp | 5 +++++ src/net/tmwa/npchandler.h | 2 ++ src/net/tmwa/playerhandler.cpp | 5 +++++ 6 files changed, 24 insertions(+) diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp index 258c72c0..392ec4fd 100644 --- a/src/net/manaserv/npchandler.cpp +++ b/src/net/manaserv/npchandler.cpp @@ -225,4 +225,9 @@ void NpcHandler::endShopping(int beingId) // TODO } +void NpcHandler::clearDialogs() +{ + mNpcDialogs.clear(); +} + } // namespace ManaServ diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h index 7f48c738..689fdc1d 100644 --- a/src/net/manaserv/npchandler.h +++ b/src/net/manaserv/npchandler.h @@ -66,6 +66,8 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler void endShopping(int beingId); + void clearDialogs(); + private: typedef struct { NpcDialog* dialog; diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index 3a5d68a2..f6207800 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -40,6 +40,7 @@ #include "net/manaserv/connection.h" #include "net/manaserv/messagein.h" #include "net/manaserv/messageout.h" +#include "net/manaserv/npchandler.h" #include "net/manaserv/protocol.h" /** @@ -57,6 +58,10 @@ namespace ManaServ { void RespawnRequestListener::action(const gcn::ActionEvent &event) { Net::getPlayerHandler()->respawn(); + + ManaServ::NpcHandler *handler = + static_cast(Net::getNpcHandler()); + handler->clearDialogs(); } extern Connection *gameServerConnection; diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index e6b16f2d..5888c679 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -223,4 +223,9 @@ void NpcHandler::endShopping(int beingId) // TODO } +void NpcHandler::clearDialogs() +{ + mNpcDialogs.clear(); +} + } // namespace TmwAthena diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h index a40371a6..bd696bdd 100644 --- a/src/net/tmwa/npchandler.h +++ b/src/net/tmwa/npchandler.h @@ -67,6 +67,8 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler void endShopping(int beingId); + void clearDialogs(); + private: typedef struct { NpcDialog* dialog; diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index afa2c71b..5aab94b8 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -42,6 +42,7 @@ #include "net/messageout.h" #include "net/tmwa/protocol.h" +#include "net/tmwa/npchandler.h" #include "utils/stringutils.h" #include "utils/gettext.h" @@ -86,6 +87,10 @@ namespace { SellDialog::closeAll(); viewport->closePopupMenu(); + + TmwAthena::NpcHandler *handler = + static_cast(Net::getNpcHandler()); + handler->clearDialogs(); } } deathListener; -- cgit v1.2.3-70-g09d2 From afc816e3001104653982de25099fcc634d7ed686 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 5 May 2010 01:08:59 +0300 Subject: Allow start game if update server is down. Small code style changes. Signed-off-by: Jared Adams --- src/gui/updatewindow.cpp | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp index 975fdcff..7448a102 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -45,6 +45,9 @@ #include #include +const std::string xmlUpdateFile = "resources.xml"; +const std::string txtUpdateFile = "resources2.txt"; + /** * Load the given file into a vector of updateFiles. */ @@ -72,13 +75,10 @@ std::vector loadXMLFile(const std::string &fileName) file.type = XML::getProperty(fileNode, "type", "data"); file.desc = XML::getProperty(fileNode, "description", ""); if (XML::getProperty(fileNode, "required", "yes") == "yes") - { file.required = true; - } else - { file.required = false; - } + files.push_back(file); } @@ -344,7 +344,8 @@ void UpdaterWindow::download() { if (mDownloadStatus == UPDATE_RESOURCES) { - mDownload->setFile(mUpdatesDir + "/" + mCurrentFile, mCurrentChecksum); + mDownload->setFile(mUpdatesDir + "/" + mCurrentFile, + mCurrentChecksum); } else { @@ -353,9 +354,7 @@ void UpdaterWindow::download() } if (mDownloadStatus != UPDATE_RESOURCES) - { mDownload->noCache(); - } setLabel(mCurrentFile + " (0%)"); mDownloadComplete = false; @@ -368,9 +367,22 @@ void UpdaterWindow::loadUpdates() { ResourceManager *resman = ResourceManager::getInstance(); + if (!mUpdateFiles.size()) + { // updates not downloaded + mUpdateFiles = loadXMLFile(mUpdatesDir + "/" + xmlUpdateFile); + if (!mUpdateFiles.size()) + { + logger->log("Warning this server does not have a" + " %s file falling back to %s", xmlUpdateFile.c_str(), + txtUpdateFile.c_str()); + mUpdateFiles = loadTxtFile(mUpdatesDir + "/" + txtUpdateFile); + } + } + for (mUpdateIndex = 0; mUpdateIndex < mUpdateFiles.size(); mUpdateIndex++) { - resman->addToSearchPath(mUpdatesDir + "/" + mUpdateFiles[mUpdateIndex].name, false); + resman->addToSearchPath(mUpdatesDir + "/" + + mUpdateFiles[mUpdateIndex].name, false); } } @@ -433,7 +445,9 @@ void UpdaterWindow::logic() mUpdateFiles = loadXMLFile(mUpdatesDir + "/" + xmlUpdateFile); if (mUpdateFiles.size() == 0) { - logger->log("Warning this server does not have a %s file falling back to %s",xmlUpdateFile.c_str(),txtUpdateFile.c_str()); + logger->log("Warning this server does not have a %s" + " file falling back to %s", + xmlUpdateFile.c_str(), txtUpdateFile.c_str()); // If the resources.xml file fails, fall back onto a older version mCurrentFile = txtUpdateFile; -- cgit v1.2.3-70-g09d2 From ed4c141a666ffa8221da2a8143d51189d12cd60c Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 5 May 2010 13:03:45 -0600 Subject: Fix showing the type of the default server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Thorbjørn Lindeijer --- src/client.cpp | 2 +- src/gui/serverdialog.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client.cpp b/src/client.cpp index 8d916add..b27caadc 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -397,7 +397,7 @@ Client::Client(const Options &options): mCurrentServer.port = (short) branding.getValue("defaultPort", DEFAULT_PORT); mCurrentServer.type = ServerInfo::parseType( - branding.getValue("defaultServerType", "eathena")); + branding.getValue("defaultServerType", "tmwathena")); } if (loginData.username.empty() && loginData.remember) diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 0fba5638..c79925b3 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -219,6 +219,8 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mTypeListModel = new TypeListModel(); mTypeField = new DropDown(mTypeListModel); + mTypeField->setSelected((serverInfo->type == ServerInfo::MANASERV) ? + 1 : 0); mDescription = new Label(std::string()); -- cgit v1.2.3-70-g09d2 From 1c995f8f62be0e6af4a5351eaf7bd32ae9e6ae1e Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Sat, 24 Apr 2010 12:11:25 +0200 Subject: Fixed some copy/pasted documentation --- src/gui/widgets/window.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index a8eb4e62..e62f4d92 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -180,12 +180,12 @@ class Window : public gcn::Window, gcn::WidgetListener void setVisible(bool visible, bool forceSticky); /** - * Returns whether the window will save it's visibility. + * Returns whether the window is visible by default. */ bool isDefaultVisible() const { return mDefaultVisible; } /** - * Returns whether the window will save it's visibility. + * Sets whether the window is visible by default. */ void setDefaultVisible(bool save) { mDefaultVisible = save; } @@ -195,7 +195,7 @@ class Window : public gcn::Window, gcn::WidgetListener bool willSaveVisible() const { return mSaveVisible; } /** - * Returns whether the window will save it's visibility. + * Sets whether the window will save it's visibility. */ void setSaveVisible(bool save) { mSaveVisible = save; } -- cgit v1.2.3-70-g09d2 From d9e5e4b2d683e1691d23e5dfee667ef20dc7e047 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 6 May 2010 00:46:11 +0200 Subject: Make the logic for collision tiles more strict Only recognize the collision tile as colliding, since having everything except the empty non-collision tile collide is confusing. Should also be changed on the server and in the tmwAthena exporter of Tiled. Reviewed-by: Dennis Friis --- src/resources/mapreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 219eb317..e8a2bd20 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -369,7 +369,7 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, int gid) else { // Set collision tile - if (set && (gid - set->getFirstGid() != 0)) + if (set && (gid - set->getFirstGid() == 1)) map->blockTile(x, y, Map::BLOCKTYPE_WALL); } } -- cgit v1.2.3-70-g09d2 From 6be46ffba086d4b211efa3baaeb999d98f2c20e9 Mon Sep 17 00:00:00 2001 From: seeseekey Date: Thu, 6 May 2010 12:36:25 +0200 Subject: Remove hardcoded standard server urls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thorbjørn Lindeijer --- src/client.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index b27caadc..aa48591f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -389,7 +389,7 @@ Client::Client(const Options &options): if (mCurrentServer.hostname.empty()) { mCurrentServer.hostname = branding.getValue("defaultServer", - "server.themanaworld.org").c_str(); + "").c_str(); } if (mCurrentServer.port == 0) @@ -1095,8 +1095,7 @@ void Client::initConfiguration() config.setValue("sfxVolume", 100); config.setValue("musicVolume", 60); config.setValue("fpslimit", 60); - std::string defaultUpdateHost = branding.getValue("defaultUpdateHost", - "http://updates.themanaworld.org"); + std::string defaultUpdateHost = branding.getValue("defaultUpdateHost", ""); config.setValue("updatehost", defaultUpdateHost); config.setValue("customcursor", true); config.setValue("useScreenshotDirectorySuffix", true); @@ -1139,8 +1138,7 @@ void Client::initUpdatesDir() // If updatesHost is currently empty, fill it from config file if (mUpdateHost.empty()) { - mUpdateHost = - config.getValue("updatehost", "http://updates.themanaworld.org/"); + mUpdateHost = config.getValue("updatehost", ""); } // Remove any trailing slash at the end of the update host -- cgit v1.2.3-70-g09d2 From 43de94e81348f8b1e0318924c35bb7f3c58eb092 Mon Sep 17 00:00:00 2001 From: Hong Hao Date: Thu, 6 May 2010 21:03:30 +0800 Subject: Add missing colors.xml to CMakefiles.txt. Signed-off-by: Jared Adams --- data/graphics/gui/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt index fc825139..a7c21e5e 100644 --- a/data/graphics/gui/CMakeLists.txt +++ b/data/graphics/gui/CMakeLists.txt @@ -8,6 +8,7 @@ SET (FILES circle-gray.png circle-green.png close_button.png + colors.xml deepbox.png hscroll_left_default.png hscroll_left_highlight.png -- cgit v1.2.3-70-g09d2 From 46cd4e737a5a74f823877c1fd00a6af84005612f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 7 May 2010 03:58:26 +0300 Subject: Fix reading arrays at index -1. Signed-off-by: Jared Adams --- src/gui/widgets/emoteshortcutcontainer.cpp | 3 ++- src/gui/widgets/itemshortcutcontainer.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 2b07ad1e..82fb9f8d 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -124,11 +124,12 @@ void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event) if (!mEmoteMoved && mEmoteClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); - const int emoteId = emoteShortcut->getEmote(index); if (index == -1) return; + const int emoteId = emoteShortcut->getEmote(index); + if (emoteId) { mEmoteMoved = emoteId; diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 92e3e2e5..83efd4d4 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -142,9 +142,13 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) if (!mItemMoved && mItemClicked) { const int index = getIndexFromGrid(event.getX(), event.getY()); + + if (index == -1) + return; + const int itemId = itemShortcut->getItem(index); - if (index == -1 || itemId < 0) + if (itemId < 0) return; Item *item = player_node->getInventory()->findItem(itemId); @@ -227,9 +231,13 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); + + if (index == -1) + return; + const int itemId = itemShortcut->getItem(index); - if (index == -1 || itemId < 0) + if (itemId < 0) return; Item *item = player_node->getInventory()->findItem(itemId); -- cgit v1.2.3-70-g09d2 From da50354af7fffe79ee7137a3f3dd9d8b9f34afda Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 5 May 2010 00:36:41 +0300 Subject: Draw item image in item popups. Now draw image only in chat item popup. Reviewed-by: Bertram --- src/gui/itempopup.cpp | 47 ++++++++++++++++++++++++++++++++++--- src/gui/itempopup.h | 4 +++- src/gui/widgets/icon.cpp | 10 ++++---- src/gui/widgets/itemlinkhandler.cpp | 5 ++-- 4 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 3f22c442..2618810b 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -28,17 +28,22 @@ #include "gui/gui.h" #include "gui/theme.h" +#include "gui/widgets/icon.h" #include "gui/widgets/textbox.h" #include "utils/gettext.h" #include "utils/stringutils.h" +#include "resources/image.h" +#include "resources/resourcemanager.h" + #include #include ItemPopup::ItemPopup(): - Popup("ItemPopup") + Popup("ItemPopup"), + mIcon(0) { // Item Name mItemName = new gcn::Label; @@ -62,28 +67,62 @@ ItemPopup::ItemPopup(): mItemWeight->setEditable(false); mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding()); + mIcon = new Icon(0); + add(mItemName); add(mItemDesc); add(mItemEffect); add(mItemWeight); + add(mIcon); addMouseListener(this); } ItemPopup::~ItemPopup() { + if (mIcon) + { + Image *image = mIcon->getImage(); + if (image) + image->decRef(); + } } -void ItemPopup::setItem(const ItemInfo &item) +void ItemPopup::setItem(const ItemInfo &item, bool showImage) { if (item.getName() == mItemName->getCaption()) return; + int space = 0; + + Image *oldImage = mIcon->getImage(); + if (oldImage) + oldImage->decRef(); + + if (showImage) + { + ResourceManager *resman = ResourceManager::getInstance(); + Image *image = resman->getImage("graphics/items/" + item.getImageName()); + mIcon->setImage(image); + if (image) + { + int x = getPadding(); + int y = getPadding(); + mIcon->setPosition(x, y); + space = mIcon->getWidth(); + } + } + else + { + mIcon->setImage(0); + } + mItemType = item.getType(); mItemName->setCaption(item.getName()); mItemName->adjustSize(); mItemName->setForegroundColor(getColor(mItemType)); + mItemName->setPosition(getPadding() + space, getPadding()); mItemDesc->setTextWrapped(item.getDescription(), 196); mItemEffect->setTextWrapped(item.getEffect(), 196); @@ -91,7 +130,7 @@ void ItemPopup::setItem(const ItemInfo &item) Units::formatWeight(item.getWeight()).c_str()), 196); - int minWidth = mItemName->getWidth(); + int minWidth = mItemName->getWidth() + space; if (mItemDesc->getMinWidth() > minWidth) minWidth = mItemDesc->getMinWidth(); @@ -127,6 +166,7 @@ void ItemPopup::setItem(const ItemInfo &item) mItemDesc->setPosition(getPadding(), 2 * height); mItemEffect->setPosition(getPadding(), (numRowsDesc + getPadding()) * height); + } gcn::Color ItemPopup::getColor(ItemType type) @@ -171,3 +211,4 @@ void ItemPopup::mouseMoved(gcn::MouseEvent &event) // When the mouse moved on top of the popup, hide it setVisible(false); } + diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 67d1eb2f..a3976a11 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -29,6 +29,7 @@ #include +class Icon; class TextBox; /** @@ -50,7 +51,7 @@ class ItemPopup : public Popup /** * Sets the info to be displayed given a particular item. */ - void setItem(const ItemInfo &item); + void setItem(const ItemInfo &item, bool showImage = false); void mouseMoved(gcn::MouseEvent &mouseEvent); @@ -60,6 +61,7 @@ class ItemPopup : public Popup TextBox *mItemEffect; TextBox *mItemWeight; ItemType mItemType; + Icon *mIcon; static gcn::Color getColor(ItemType type); }; diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index ef22c37d..4e590212 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -30,20 +30,22 @@ Icon::Icon(const std::string &file) : mImage(0) { mImage = ResourceManager::getInstance()->getImage(file); - setSize(mImage->getWidth(), mImage->getHeight()); - + if (mImage) + setSize(mImage->getWidth(), mImage->getHeight()); } Icon::Icon(Image *image) : mImage(image) { - setSize(mImage->getWidth(), mImage->getHeight()); + if (mImage) + setSize(mImage->getWidth(), mImage->getHeight()); } void Icon::setImage(Image *image) { mImage = image; - setSize(mImage->getWidth(), mImage->getHeight()); + if (mImage) + setSize(mImage->getWidth(), mImage->getHeight()); } void Icon::draw(gcn::Graphics *g) diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 0c51aeb3..b7341084 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -49,9 +49,8 @@ void ItemLinkHandler::handleLink(const std::string &link) if (id > 0) { - const ItemInfo &iteminfo = ItemDB::get(id); - - mItemPopup->setItem(iteminfo); + const ItemInfo &itemInfo = ItemDB::get(id); + mItemPopup->setItem(itemInfo, true); if (mItemPopup->isVisible()) mItemPopup->setVisible(false); -- cgit v1.2.3-70-g09d2 From d34dda737ed8af5135c49e269f5ad608cea8d511 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Fri, 7 May 2010 00:26:28 +0200 Subject: Merge protocol from manaserv about thing types. Reviewed-by: Jaxad0127 (A few days ago...) --- src/net/manaserv/beinghandler.cpp | 2 +- src/net/manaserv/protocol.h | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index bab5471b..b08af749 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -160,7 +160,7 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg) switch (type) { - case OBJECT_PLAYER: + case OBJECT_CHARACTER: { std::string name = msg.readString(); if (player_node->getName() == name) diff --git a/src/net/manaserv/protocol.h b/src/net/manaserv/protocol.h index 2654da74..226a27a0 100644 --- a/src/net/manaserv/protocol.h +++ b/src/net/manaserv/protocol.h @@ -314,17 +314,24 @@ enum AttribmodResponseCode { }; // Object type enumeration -enum { - // A simple item +enum ThingType +{ + // A simple item. OBJECT_ITEM = 0, - // An item that can be activated (doors, switchs, sign, ...) + // An item that toggle map/quest actions (doors, switchs, ...) + // and can speak (map panels). OBJECT_ACTOR, - // Non-Playable-Character is an actor capable of movement and maybe actions + // Non-Playable-Character is an actor capable of movement and maybe actions. OBJECT_NPC, - // A monster (moving actor with AI. able to toggle map/quest actions, too) + // A monster (moving actor with AI. Should be able to toggle map/quest + // actions, too). OBJECT_MONSTER, - // A player - OBJECT_PLAYER + // A normal being. + OBJECT_CHARACTER, + // A effect to be shown. + OBJECT_EFFECT, + // Server-only object. + OBJECT_OTHER }; // Moving object flags -- cgit v1.2.3-70-g09d2 From 910ea1476664d8a11d57eaf8ff7f281bcfacd184 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 6 May 2010 23:11:21 -0600 Subject: Fix some issues found by Cppcheck --- src/client.h | 8 ++++---- src/item.h | 2 +- src/localplayer.cpp | 11 ++++++----- src/particlecontainer.cpp | 9 ++++++--- src/resources/resourcemanager.cpp | 6 +++++- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/client.h b/src/client.h index c120b248..3c52ea37 100644 --- a/src/client.h +++ b/src/client.h @@ -22,17 +22,17 @@ #ifndef CLIENT_H #define CLIENT_H -#include "net/serverinfo.h" - #include "configlistener.h" -#include +#include "net/serverinfo.h" -#include +#include #include #include +#include + class Button; class Desktop; class LoginData; diff --git a/src/item.h b/src/item.h index 89b8e59e..17be8f04 100644 --- a/src/item.h +++ b/src/item.h @@ -41,7 +41,7 @@ class Item /** * Destructor. */ - ~Item(); + virtual ~Item(); /** * Sets the item id, identifying the item type. diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 0b0e22f5..b06ea456 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -135,6 +135,9 @@ LocalPlayer::~LocalPlayer() mTargetCursorImages[0][i]->decRef(); mTargetCursorImages[1][i]->decRef(); } + + delete mAwayDialog; + delete mAwayListener; } void LocalPlayer::logic() @@ -1433,10 +1436,8 @@ void LocalPlayer::changeAwayMode() config.getValue("afkMessage", "I am away from keyboard")); mAwayDialog->addActionListener(mAwayListener); } - else - { - mAwayDialog = 0; - } + + mAwayDialog = 0; } void LocalPlayer::setAway(const std::string &message) @@ -1478,4 +1479,4 @@ void AwayListener::action(const gcn::ActionEvent &event) { player_node->changeAwayMode(); } -} \ No newline at end of file +} diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 175c1e87..6900539d 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -71,14 +71,17 @@ void ParticleList::addLocally(Particle *particle) void ParticleList::removeLocally(Particle *particle) { - for (std::list::iterator it = mElements.begin(); - it != mElements.end(); it++) + std::list::iterator it, it_end; + for (it = mElements.begin(), it_end = mElements.end(); + it != it_end;) { if (*it == particle) { (*it)->kill(); - mElements.erase(it); + it = mElements.erase(it); } + else + it++; } } diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 24f346f7..f785f20a 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -316,7 +316,11 @@ struct DyedImageLoader } int fileSize; void *buffer = l->manager->loadFile(path, fileSize); - if (!buffer) return NULL; + if (!buffer) + { + delete d; + return NULL; + } Resource *res = d ? Image::load(buffer, fileSize, *d) : Image::load(buffer, fileSize); free(buffer); -- cgit v1.2.3-70-g09d2 From 2953a3f92c5097bd99ff21f4536fe167a32d90c5 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Fri, 21 May 2010 13:26:42 -0600 Subject: Fix a crash dealing with rescaled overlays under SDL Reviewed-by: Philipp Sehmisch --- src/resources/ambientlayer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 780baf00..50fe8bd9 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -51,6 +51,7 @@ AmbientLayer::AmbientLayer(Image *img, float parallax, std::string idPath = mImage->getIdPath() + "_rescaled"; ResourceManager::getInstance()->addResource(idPath, rescaledOverlay); mImage = rescaledOverlay; + rescaledOverlay->incRef(); } else mImage->incRef(); -- cgit v1.2.3-70-g09d2