diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-04-30 16:57:31 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-04-30 16:57:31 +0200 |
commit | 908dceb882723460cde35ec8ef22927b702ab874 (patch) | |
tree | 0598a9cb5d720c66c619fd350d64453490b35143 /src | |
parent | 8a67e721880959b431d220e2d1fd5b60a4f11ad7 (diff) | |
parent | 0b1c6eb3c4941dc2d47ad3207bab4509ae1014cc (diff) | |
download | mana-client-908dceb882723460cde35ec8ef22927b702ab874.tar.gz mana-client-908dceb882723460cde35ec8ef22927b702ab874.tar.bz2 mana-client-908dceb882723460cde35ec8ef22927b702ab874.tar.xz mana-client-908dceb882723460cde35ec8ef22927b702ab874.zip |
Merge branch '0.5'
Conflicts:
CMakeLists.txt
po/fi.po
po/fr.po
src/gui/skilldialog.cpp
src/localplayer.cpp
src/net/manaserv/generalhandler.cpp
src/net/tmwa/buysellhandler.cpp
src/net/tmwa/generalhandler.cpp
src/net/tmwa/playerhandler.cpp
src/net/tmwa/specialhandler.cpp
src/winver.h
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/buy.cpp | 6 | ||||
-rw-r--r-- | src/gui/skilldialog.cpp | 17 | ||||
-rw-r--r-- | src/gui/skilldialog.h | 4 | ||||
-rw-r--r-- | src/log.cpp | 5 | ||||
-rw-r--r-- | src/main.h | 2 | ||||
-rw-r--r-- | src/net/manaserv/generalhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/buysellhandler.cpp | 1 | ||||
-rw-r--r-- | src/net/tmwa/generalhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/tmwa/loginhandler.cpp | 9 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 39 | ||||
-rw-r--r-- | src/net/tmwa/specialhandler.cpp | 3 | ||||
-rw-r--r-- | src/resources/spritedef.cpp | 2 | ||||
-rw-r--r-- | src/utils/mkdir.cpp | 12 |
13 files changed, 64 insertions, 40 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 4a8dae17..8e9f13e8 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -208,11 +208,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) if (price < 0) price = 0; setMoney(mMoney - mAmountItems * price); - - // Reset selection - mAmountItems = 1; - mSlider->setValue(1); - mSlider->gcn::Slider::setScale(1, mMaxItems); + valueChanged(gcn::SelectionEvent(mShopItemList)); } } diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index c7976caa..19bd06d6 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -56,6 +56,8 @@ #include <set> #include <string> +#define SKILLS_FILE "skills.xml" + class SkillModel; class SkillEntry; @@ -235,8 +237,7 @@ SkillDialog::SkillDialog(): SkillDialog::~SkillDialog() { - // Clear gui - loadSkills(""); + clearSkills(); } void SkillDialog::action(const gcn::ActionEvent &event) @@ -291,7 +292,7 @@ void SkillDialog::event(Event::Channel channel, const Event &event) } } -void SkillDialog::loadSkills(const std::string &file) +void SkillDialog::clearSkills() { // Fixes issues with removing tabs if (mTabs->getSelectedTabIndex() != -1) @@ -308,11 +309,13 @@ void SkillDialog::loadSkills(const std::string &file) delete_all(mSkills); mSkills.clear(); +} - if (file.length() == 0) - return; +void SkillDialog::loadSkills() +{ + clearSkills(); - XML::Document doc(file); + XML::Document doc(SKILLS_FILE); xmlNodePtr root = doc.rootNode(); int setCount = 0; @@ -323,7 +326,7 @@ void SkillDialog::loadSkills(const std::string &file) if (!root || !xmlStrEqual(root->name, BAD_CAST "skills")) { - logger->log("Error loading skills file: %s", file.c_str()); + logger->log("Error loading skills file: %s", SKILLS_FILE); if (Net::getNetworkType() == ServerInfo::TMWATHENA) { diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index a49c537b..ba908697 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -66,7 +66,9 @@ class SkillDialog : public Window, public gcn::ActionListener, public EventListe */ void update(); - void loadSkills(const std::string &file); + void loadSkills(); + + void clearSkills(); void setModifiable(int id, bool modifiable); diff --git a/src/log.cpp b/src/log.cpp index a147c107..bb8a78bb 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -60,12 +60,13 @@ void Logger::setLogFile(const std::string &logFilename) void Logger::log(const char *log_text, ...) { - char* buf = new char[1024]; + const size_t bufSize = 1024; + char* buf = new char[bufSize]; va_list ap; // Use a temporary buffer to fill in the variables va_start(ap, log_text); - vsprintf(buf, log_text, ap); + vsnprintf(buf, bufSize, log_text, ap); va_end(ap); // Get the current system time @@ -55,7 +55,7 @@ #elif defined WIN32 #include "winver.h" #elif defined __APPLE__ -#define PACKAGE_VERSION "0.5.1" +#define PACKAGE_VERSION "0.5.2" #endif #ifdef PACKAGE_VERSION diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 68d5ee9e..a1ba746f 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -197,7 +197,7 @@ void GeneralHandler::event(Event::Channel channel, if (event.getType() == Event::GuiWindowsLoaded) { inventoryWindow->setSplitAllowed(true); - skillDialog->loadSkills("mana-skills.xml"); + skillDialog->loadSkills(); PlayerInfo::setAttribute(EXP_NEEDED, 100); diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 5368ba9d..8daebdec 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -129,7 +129,6 @@ void BuySellHandler::handleMessage(Net::MessageIn &msg) SERVER_NOTICE(_("Thanks for selling.")) else SERVER_NOTICE(_("Unable to sell.")) - break; } } diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index ef59ee12..b03fb3b8 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -225,7 +225,7 @@ void GeneralHandler::event(Event::Channel channel, if (event.getType() == Event::GuiWindowsLoaded) { inventoryWindow->setSplitAllowed(false); - skillDialog->loadSkills("ea-skills.xml"); + skillDialog->loadSkills(); statusWindow->addAttribute(STR, _("Strength"), true, ""); statusWindow->addAttribute(AGI, _("Agility"), true, ""); diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 00b7b145..e03ff042 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -168,6 +168,9 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) errorMessage = _("You have been permanently banned from " "the game. Please contact the GM team."); break; + case 5: + errorMessage = _("Client too old."); + break; case 6: errorMessage = strprintf(_("You have been temporarily " "banned from the game until " @@ -175,9 +178,15 @@ void LoginHandler::handleMessage(Net::MessageIn &msg) "team via the forums."), msg.readString(20).c_str()); break; + case 7: + errorMessage = _("Server overpopulated."); + break; case 9: errorMessage = _("This user name is already taken."); break; + case 99: + errorMessage = _("Username permanently erased."); + break; default: errorMessage = _("Unknown error."); break; diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 4bd637c3..ab63cc1d 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -22,8 +22,7 @@ #include "net/tmwa/playerhandler.h" #include "net/tmwa/beinghandler.h" -#include "client.h" -#include "event.h" +#include "configuration.h" #include "game.h" #include "localplayer.h" #include "log.h" @@ -227,6 +226,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) case SMSG_PLAYER_STAT_UPDATE_1: { + if (!player_node) + break; int type = msg.readInt16(); int value = msg.readInt32(); @@ -312,14 +313,24 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) PlayerInfo::setStatExperience(JOB, msg.readInt32(), PlayerInfo::getStatExperience(JOB).second); break; - case 0x0014: { + + case 0x0014: + { int oldMoney = PlayerInfo::getAttribute(MONEY); int newMoney = msg.readInt32(); + std::string money = Units::formatCurrency( + newMoney - oldMoney); PlayerInfo::setAttribute(MONEY, newMoney); if (newMoney > oldMoney) - SERVER_NOTICE(strprintf(_("You picked up %s."), - Units::formatCurrency(newMoney - - oldMoney).c_str())) + { + if (config.getBoolValue("showpickupchat")) + SERVER_NOTICE(strprintf(_("You picked up %s."), + Units::formatCurrency(newMoney - + oldMoney).c_str())) + if (config.getBoolValue("showpickupparticle")) + player_node->addMessageToQueue(money, + UserPalette::PICKUP_INFO); + } } break; case 0x0016: @@ -543,11 +554,17 @@ void PlayerHandler::increaseSkill(int skillId) void PlayerHandler::pickUp(FloorItem *floorItem) { - if (floorItem) - { - MessageOut outMsg(CMSG_ITEM_PICKUP); - outMsg.writeInt32(floorItem->getId()); - } + static Uint32 lastTime = 0; + + // Avoid spamming the server with pick-up requests to prevent the player + // from being kicked. + if (!floorItem || SDL_GetTicks() < lastTime + 100) + return; + + MessageOut outMsg(CMSG_ITEM_PICKUP); + outMsg.writeInt32(floorItem->getId()); + + lastTime = SDL_GetTicks(); } void PlayerHandler::setDirection(char direction) diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp index 577bda7e..661d9e2c 100644 --- a/src/net/tmwa/specialhandler.cpp +++ b/src/net/tmwa/specialhandler.cpp @@ -105,7 +105,8 @@ void SpecialHandler::handleMessage(Net::MessageIn &msg) int up = msg.readInt8(); PlayerInfo::setStatBase(skillId, level); - skillDialog->setModifiable(skillId, up); + if (skillDialog) + skillDialog->setModifiable(skillId, up); } break; diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 311c9d1a..51e7ae8e 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -268,7 +268,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, if (!img) { logger->log("No image at index %d", start + variant_offset); - continue; + break; } animation->addFrame(img, delay, offsetX, offsetY); diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp index 549e77a2..75ab8595 100644 --- a/src/utils/mkdir.cpp +++ b/src/utils/mkdir.cpp @@ -36,17 +36,13 @@ #include "mkdir.h" +/// Create a directory, making leading components first if necessary int mkdir_r(const char *pathname) { - char tmp[PATH_MAX]; + size_t len = strlen(pathname); + char tmp[len+2]; char *p; - if (strlen(pathname) >= PATH_MAX-2) - return -1; - - strncpy(tmp, pathname, sizeof(tmp)-1); - tmp[PATH_MAX-1] = '\0'; - - int len=strlen(tmp); + strcpy(tmp, pathname); // terminate the pathname with '/' if (tmp[len-1] != '/') { |