diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-01-22 02:20:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-01-22 02:20:43 +0300 |
commit | e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914 (patch) | |
tree | 4e9f65c3ef67e6e06e1e1dca140e2d7ef6a22ff7 /src | |
parent | b6eb53b9abdf48b88cb1978b9af97f2a879d2717 (diff) | |
parent | acc25a7dffefb8b8b4e8022af918794d26048453 (diff) | |
download | plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.tar.gz plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.tar.bz2 plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.tar.xz plus-e71376322cbe85d59ca7d1a9d7f2a3db9ae9b914.zip |
Merge commit 'v1.2.1.22' into stripped
Conflicts:
data/fonts/mplus-1p-bold.ttf
data/fonts/mplus-1p-regular.ttf
src/CMakeLists.txt
src/Makefile.am
src/guichan/gui.cpp
Diffstat (limited to 'src')
575 files changed, 3084 insertions, 1219 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d4ae8079b..6c612629c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -452,8 +452,8 @@ SET(SRCS utils/mathutils.h utils/paths.cpp utils/paths.h - utils/sha256.cpp - utils/sha256.h + utils/process.cpp + utils/process.h utils/stringutils.cpp utils/stringutils.h utils/mutex.h @@ -461,6 +461,10 @@ SET(SRCS utils/mkdir.h utils/xml.cpp utils/xml.h + test/testlauncher.cpp + test/testlauncher.h + test/testmain.cpp + test/testmain.h actor.cpp actor.h actorsprite.cpp @@ -685,6 +689,8 @@ SET(SRCS_TMWA ) SET(SRCS_MANASERV + utils/sha256.cpp + utils/sha256.h net/manaserv/attributes.cpp net/manaserv/attributes.h net/manaserv/adminhandler.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 6ab63bc70..1893adb80 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -362,8 +362,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ utils/mkdir.h \ utils/paths.cpp \ utils/paths.h \ - utils/sha256.cpp \ - utils/sha256.h \ + utils/process.cpp \ + utils/process.h \ utils/specialfolder.cpp \ utils/specialfolder.h \ utils/stringutils.cpp \ @@ -371,6 +371,10 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ utils/mutex.h \ utils/xml.cpp \ utils/xml.h \ + test/testlauncher.cpp \ + test/testlauncher.h \ + test/testmain.cpp \ + test/testmain.h \ actor.cpp \ actor.h \ actorsprite.cpp \ @@ -507,7 +511,9 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ if ENABLE_MANASERV manaplus_CXXFLAGS += -DMANASERV_SUPPORT -manaplus_SOURCES += net/manaserv/attributes.cpp \ +manaplus_SOURCES += utils/sha256.cpp \ + utils/sha256.h \ + net/manaserv/attributes.cpp \ net/manaserv/attributes.h \ net/manaserv/adminhandler.cpp \ net/manaserv/adminhandler.h \ diff --git a/src/actor.cpp b/src/actor.cpp index 150f6042b..6a11c6e91 100644 --- a/src/actor.cpp +++ b/src/actor.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/actor.h b/src/actor.h index 9afaff93d..51cba0c60 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 2a92cf506..c1c139bb9 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -164,7 +164,7 @@ static EffectDescription *default_effect = nullptr; static std::map<int, EffectDescription *> effects; static bool effects_initialized = false; -static EffectDescription *getEffectDescription(xmlNodePtr node, int *id) +static EffectDescription *getEffectDescription(XmlNodePtr node, int *id) { EffectDescription *ed = new EffectDescription; @@ -180,9 +180,9 @@ static EffectDescription *getEffectDescription(int effectId) if (!effects_initialized) { XML::Document doc(EFFECTS_FILE); - xmlNodePtr root = doc.rootNode(); + XmlNodePtr root = doc.rootNode(); - if (!root || !xmlStrEqual(root->name, BAD_CAST "being-effects")) + if (!root || !xmlNameEqual(root, "being-effects")) { logger->log1("Error loading being effects file: " EFFECTS_FILE); @@ -193,13 +193,13 @@ static EffectDescription *getEffectDescription(int effectId) { int id; - if (xmlStrEqual(node->name, BAD_CAST "effect")) + if (xmlNameEqual(node, "effect")) { EffectDescription *EffectDescription = getEffectDescription(node, &id); effects[id] = EffectDescription; } - else if (xmlStrEqual(node->name, BAD_CAST "default")) + else if (xmlNameEqual(node, "default")) { EffectDescription *effectDescription = getEffectDescription(node, &id); @@ -437,7 +437,7 @@ static const char *cursorSize(int size) void ActorSprite::initTargetCursor() { - static std::string targetCursorFile = "graphics/target-cursor-%s-%s.png"; + static std::string targetCursorFile = "target-cursor-%s-%s.png"; static int targetWidths[NUM_TC] = {44, 62, 82}; static int targetHeights[NUM_TC] = {35, 44, 60}; @@ -479,8 +479,8 @@ void ActorSprite::loadTargetCursor(const std::string &filename, if (size < TC_SMALL || size >= NUM_TC) return; - ResourceManager *resman = ResourceManager::getInstance(); - ImageSet *currentImageSet = resman->getImageSet(filename, width, height); + ImageSet *currentImageSet = Theme::getImageSetFromTheme( + filename, width, height); if (!currentImageSet) { diff --git a/src/actorsprite.h b/src/actorsprite.h index e130269bf..29df6954c 100644 --- a/src/actorsprite.h +++ b/src/actorsprite.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/actorspritelistener.h b/src/actorspritelistener.h index 88082af20..314825fc7 100644 --- a/src/actorspritelistener.h +++ b/src/actorspritelistener.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 4403738f9..fa6d49d38 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -406,13 +406,12 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y, } } -void ActorSpriteManager::findBeingsByPixel(std::vector<Being*> &beings, +void ActorSpriteManager::findBeingsByPixel(std::vector<ActorSprite*> &beings, int x, int y, bool allPlayers) const { if (!mMap) return; - bool targetDead = mTargetDeadPlayers; const int xtol = 16; const int uptol = 32; @@ -421,25 +420,24 @@ void ActorSpriteManager::findBeingsByPixel(std::vector<Being*> &beings, if (!*it) continue; - if ((*it)->getType() == ActorSprite::FLOOR_ITEM - || (*it)->getType() == ActorSprite::PORTAL) - { + if ((*it)->getType() == ActorSprite::PORTAL) continue; - } - Being *being = static_cast<Being*>(*it); + Being *being = dynamic_cast<Being*>(*it); + ActorSprite *actor = *it; - if ((being->isAlive() - || (targetDead && being->getType() == Being::PLAYER)) + if ((being && (being->isAlive() + || (mTargetDeadPlayers && being->getType() == Being::PLAYER)) && (allPlayers || being != player_node)) + || actor->getType() == ActorSprite::FLOOR_ITEM) { - if ((being->getPixelX() - xtol <= x) && - (being->getPixelX() + xtol > x) && - (being->getPixelY() - uptol <= y) && - (being->getPixelY() > y)) + if ((actor->getPixelX() - xtol <= x) && + (actor->getPixelX() + xtol > x) && + (actor->getPixelY() - uptol <= y) && + (actor->getPixelY() > y)) { - beings.push_back(being); + beings.push_back(actor); } } } diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h index f1f83634d..7960c6301 100644 --- a/src/actorspritemanager.h +++ b/src/actorspritemanager.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -94,7 +94,7 @@ class ActorSpriteManager: public ConfigListener /** * Returns a beings at the specific pixel. */ - void findBeingsByPixel(std::vector<Being*> &beings, int x, int y, + void findBeingsByPixel(std::vector<ActorSprite*> &beings, int x, int y, bool allPlayers) const; /** @@ -123,7 +123,7 @@ class ActorSpriteManager: public ConfigListener */ Being *findNearestLivingBeing(int x, int y, int maxTileDist, ActorSprite::Type type = Being::UNKNOWN, - Being *excluded = 0) const; + Being *excluded = nullptr) const; /** * Returns a being nearest to another being. @@ -292,12 +292,12 @@ class ActorSpriteManager: public ConfigListener protected: bool validateBeing(Being *aroundBeing, Being* being, - Being::Type type, Being* excluded = 0, + Being::Type type, Being* excluded = nullptr, int maxCost = 20) const; Being *findNearestLivingBeing(Being *aroundBeing, int maxdist, Being::Type type, int x, int y, - Being *excluded = 0) const; + Being *excluded = nullptr) const; void loadAttackList(); void storeAttackList(); diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 5277ddf33..f4f3451cb 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 16bcdf2da..4a41eac52 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp index ef2e0a680..c1bf251af 100644 --- a/src/animationparticle.cpp +++ b/src/animationparticle.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -33,7 +33,7 @@ AnimationParticle::AnimationParticle(Map *map, Animation *animation): { } -AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode, +AnimationParticle::AnimationParticle(Map *map, XmlNodePtr animationNode, const std::string& dyePalettes): ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animationNode, dyePalettes)) diff --git a/src/animationparticle.h b/src/animationparticle.h index 984d3dc14..933f2d164 100644 --- a/src/animationparticle.h +++ b/src/animationparticle.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -25,7 +25,7 @@ #include "imageparticle.h" -#include <libxml/tree.h> +#include "utils/xml.h" class Animation; class Map; @@ -36,7 +36,7 @@ class AnimationParticle : public ImageParticle public: AnimationParticle(Map *map, Animation *animation); - AnimationParticle(Map *map, xmlNodePtr animationNode, + AnimationParticle(Map *map, XmlNodePtr animationNode, const std::string& dyePalettes = std::string()); ~AnimationParticle(); diff --git a/src/auctionmanager.cpp b/src/auctionmanager.cpp index 900d47e29..9e4752e9b 100644 --- a/src/auctionmanager.cpp +++ b/src/auctionmanager.cpp @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/auctionmanager.h b/src/auctionmanager.h index bdc0497ae..35b233abf 100644 --- a/src/auctionmanager.h +++ b/src/auctionmanager.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/avatar.h b/src/avatar.h index 6c79dd96a..5ff0a8f75 100644 --- a/src/avatar.h +++ b/src/avatar.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/being.cpp b/src/being.cpp index 736d64f1a..39d0bd450 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -2071,30 +2071,47 @@ void Being::drawHpBar(Graphics *graphics, int maxHP, int hp, int damage, int dx = static_cast<int>(static_cast<float>(width) / p); - if (!damage || (!hp && maxHP == damage)) - { - graphics->setColor(userPalette->getColorWithAlpha(color1)); - - graphics->fillRectangle(gcn::Rectangle( - x, y, dx, height)); - return; + if (serverVersion < 1) + { // old servers + if ((!damage && (this != player_node || hp == maxHP)) + || (!hp && maxHP == damage)) + { + graphics->setColor(userPalette->getColorWithAlpha(color1)); + graphics->fillRectangle(gcn::Rectangle( + x, y, dx, height)); + return; + } + else if (width - dx <= 0) + { + graphics->setColor(userPalette->getColorWithAlpha(color2)); + graphics->fillRectangle(gcn::Rectangle( + x, y, width, height)); + return; + } } - else if (width - dx <= 0) - { - graphics->setColor(userPalette->getColorWithAlpha(color2)); - - graphics->fillRectangle(gcn::Rectangle( - x, y, width, height)); - return; + else + { // evol servers + if (hp == maxHP) + { + graphics->setColor(userPalette->getColorWithAlpha(color1)); + graphics->fillRectangle(gcn::Rectangle( + x, y, dx, height)); + return; + } + else if (width - dx <= 0) + { + graphics->setColor(userPalette->getColorWithAlpha(color2)); + graphics->fillRectangle(gcn::Rectangle( + x, y, width, height)); + return; + } } graphics->setColor(userPalette->getColorWithAlpha(color1)); - graphics->fillRectangle(gcn::Rectangle( x, y, dx, height)); graphics->setColor(userPalette->getColorWithAlpha(color2)); - graphics->fillRectangle(gcn::Rectangle( x + dx, y, width - dx, height)); } @@ -2186,6 +2203,12 @@ void Being::recalcSpritesOrder() { std::map<int, int>::const_iterator repIt = itemReplacer.find(mSpriteIDs[remSprite]); + if (repIt == itemReplacer.end()) + { + repIt = itemReplacer.find(0); + if (repIt->second == 0) + repIt = itemReplacer.end(); + } if (repIt != itemReplacer.end()) { mSpriteHide[remSprite] = repIt->second; @@ -2526,10 +2549,9 @@ void Being::updatePercentHP() { if (!mMaxHP || !serverVersion) return; - unsigned num = 0; if (mHP) { - num = mHP * 100 / mMaxHP; + unsigned num = mHP * 100 / mMaxHP; if (num != mNumber) { mNumber = num; diff --git a/src/being.h b/src/being.h index f1cae8df7..6052644c9 100644 --- a/src/being.h +++ b/src/being.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/channel.cpp b/src/channel.cpp index 19859f4ef..dd52fe75d 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/channel.h b/src/channel.h index 078ea3a5e..559002296 100644 --- a/src/channel.h +++ b/src/channel.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index 4ae1ebe2a..83229b454 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/channelmanager.h b/src/channelmanager.h index e90408032..6798bdfa8 100644 --- a/src/channelmanager.h +++ b/src/channelmanager.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp index 0299a6fe3..ad86de8e9 100644 --- a/src/chatlogger.cpp +++ b/src/chatlogger.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -142,11 +142,13 @@ std::string ChatLogger::secureName(std::string &name) const { for (unsigned int f = 0; f < name.length(); f ++) { - if (name[f] < '0' && name[f] > '9' && name[f] < 'a' && name[f] > 'z' - && name[f] < 'A' && name[f] > 'Z' + if ((name[f] < '0' || name[f] > '9') + && (name[f] < 'a' || name[f] > 'z') + && (name[f] < 'A' || name[f] > 'Z') && name[f] != '-' && name[f] != '+' && name[f] != '=' && name[f] != '.' && name[f] != ',' && name[f] != ')' - && name[f] != '(' && name[f] != '[' && name[f] != ']') + && name[f] != '(' && name[f] != '[' && name[f] != ']' + && name[f] != '#') { name[f] = '_'; } diff --git a/src/chatlogger.h b/src/chatlogger.h index 23d5d4a86..91805a8bc 100644 --- a/src/chatlogger.h +++ b/src/chatlogger.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * Copyright (C) 2009-2010 Andrei Karas * * This file is part of The ManaPlus Client. diff --git a/src/client.cpp b/src/client.cpp index d8bb747fb..1c4629178 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -101,6 +101,9 @@ #include "utils/paths.h" #include "utils/stringutils.h" +#include "test/testlauncher.h" +#include "test/testmain.h" + #ifdef __APPLE__ #include <CoreFoundation/CFBundle.h> #endif @@ -259,8 +262,8 @@ Client::Client(const Options &options): mState(STATE_CHOOSE_SERVER), mOldState(STATE_START), mIcon(nullptr), - mLogicCounterId(0), - mSecondsCounterId(0), + mLogicCounterId(nullptr), + mSecondsCounterId(nullptr), mLimitFps(false), mConfigAutoSaved(false), mIsMinimized(false), @@ -269,7 +272,25 @@ Client::Client(const Options &options): mGuiAlpha(1.0f) { mInstance = this; +} + +void Client::testsInit() +{ + printf ("testInit\n"); + if (!mOptions.test.empty()) + { + gameInit(); + } + else + { + logger = new Logger; + initLocalDataDir(); + initConfigDir(); + } +} +void Client::gameInit() +{ logger = new Logger; // Load branding information @@ -295,7 +316,7 @@ Client::Client(const Options &options): #if ENABLE_NLS std::string lang = config.getValue("lang", ""); #ifdef WIN32 - if (!lang.empty()) + if (lang.empty()) lang = std::string(_nl_locale_name_default()); putenv((char*)("LANG=" + lang).c_str()); @@ -644,7 +665,31 @@ Client::Client(const Options &options): Client::~Client() { - logger->log1("Quitting1"); + if (!mOptions.testMode) + gameClear(); + else + testsClear(); +} + +void Client::testsClear() +{ + if (!mOptions.test.empty()) + { + gameClear(); + } + else + { + BeingInfo::clear(); + + //delete logger; + //logger = nullptr; + } +} + +void Client::gameClear() +{ + if (logger) + logger->log1("Quitting1"); config.removeListener("fpslimit", this); config.removeListener("guialpha", this); @@ -681,39 +726,45 @@ Client::~Client() player_relations.store(); - logger->log1("Quitting2"); + if (logger) + logger->log1("Quitting2"); delete gui; gui = nullptr; - logger->log1("Quitting3"); + if (logger) + logger->log1("Quitting3"); delete mainGraphics; mainGraphics = nullptr; - logger->log1("Quitting4"); + if (logger) + logger->log1("Quitting4"); - // Shutdown libxml - xmlCleanupParser(); + XML::cleanupXML(); - logger->log1("Quitting5"); + if (logger) + logger->log1("Quitting5"); BeingInfo::clear(); // Shutdown sound sound.close(); - logger->log1("Quitting6"); + if (logger) + logger->log1("Quitting6"); ActorSprite::unload(); ResourceManager::deleteInstance(); - logger->log1("Quitting8"); + if (logger) + logger->log1("Quitting8"); SDL_FreeSurface(mIcon); - logger->log1("Quitting9"); + if (logger) + logger->log1("Quitting9"); delete userPalette; userPalette = nullptr; @@ -721,7 +772,8 @@ Client::~Client() delete joystick; joystick = nullptr; - logger->log1("Quitting10"); + if (logger) + logger->log1("Quitting10"); config.write(); serverConfig.write(); @@ -729,18 +781,34 @@ Client::~Client() config.clear(); serverConfig.clear(); - logger->log1("Quitting11"); + if (logger) + logger->log1("Quitting11"); delete chatLogger; chatLogger = nullptr; - delete logger; - logger = nullptr; + //delete logger; + //logger = nullptr; mInstance = nullptr; } -int Client::exec() +int Client::testsExec() +{ + if (mOptions.test.empty()) + { + TestMain test; + return test.exec(); + } + else + { + TestLauncher launcher(mOptions.test); + return launcher.exec(); + } + return 0; +} + +int Client::gameExec() { int lastTickTime = tick_time; @@ -1481,6 +1549,12 @@ void Client::initRootDir() */ void Client::initHomeDir() { + initLocalDataDir(); + initConfigDir(); +} + +void Client::initLocalDataDir() +{ mLocalDataDir = mOptions.localDataDir; if (mLocalDataDir.empty()) @@ -1509,7 +1583,10 @@ void Client::initHomeDir() logger->error(strprintf(_("%s doesn't exist and can't be created! " "Exiting."), mLocalDataDir.c_str())); } +} +void Client::initConfigDir() +{ mConfigDir = mOptions.configDir; if (mConfigDir.empty()) @@ -1611,6 +1688,8 @@ void Client::initConfiguration() config.setValue("musicVolume", 60); config.setValue("fpslimit", 60); std::string defaultUpdateHost = branding.getValue("defaultUpdateHost", ""); + if (!checkPath(defaultUpdateHost)) + defaultUpdateHost = ""; config.setValue("updatehost", defaultUpdateHost); config.setValue("customcursor", true); config.setValue("useScreenshotDirectorySuffix", true); @@ -1623,7 +1702,10 @@ void Client::initConfiguration() // bool oldConfig = false; // int emptySize = config.getSize(); - configPath = mConfigDir + "/config.xml"; + if (mOptions.test.empty()) + configPath = mConfigDir + "/config.xml"; + else + configPath = mConfigDir + "/test.xml"; configFile = fopen(configPath.c_str(), "r"); @@ -1660,6 +1742,8 @@ void Client::initUpdatesDir() // If updatesHost is currently empty, fill it from config file if (mUpdateHost.empty()) mUpdateHost = config.getStringValue("updatehost"); + if (!checkPath(mUpdateHost)) + return; // Don't go out of range int he next check if (mUpdateHost.length() < 2) @@ -2055,6 +2139,11 @@ void Client::initPacketLimiter() mPacketLimits[PACKET_STOPATTACK].cntLimit = 1; mPacketLimits[PACKET_STOPATTACK].cnt = 0; + mPacketLimits[PACKET_ONLINELIST].timeLimit = 1800; + mPacketLimits[PACKET_ONLINELIST].lastTime = 0; + mPacketLimits[PACKET_ONLINELIST].cntLimit = 1; + mPacketLimits[PACKET_ONLINELIST].cnt = 0; + if (!mServerConfigDir.empty()) { std::string packetLimitsName = @@ -2091,7 +2180,7 @@ void Client::initPacketLimiter() mPacketLimits[f].timeLimit = atoi(line); } inPacketFile.close(); - if (ver < 3) + if (ver < 4) writePacketLimits(packetLimitsName); } } @@ -2106,7 +2195,7 @@ void Client::writePacketLimits(std::string packetLimitsName) outPacketFile.close(); return; } - outPacketFile << "3" << std::endl; + outPacketFile << "4" << std::endl; for (int f = 0; f < PACKET_SIZE; f ++) { outPacketFile << toString(mPacketLimits[f].timeLimit) @@ -2233,6 +2322,14 @@ void Client::setFramerate(int fpsLimit) SDL_setFramerate(&instance()->mFpsManager, fpsLimit); } +int Client::getFramerate() +{ + if (!instance()->mLimitFps) + return 0; + + return SDL_getFramerate(&instance()->mFpsManager); +} + void Client::closeDialogs() { Net::getNpcHandler()->clearDialogs(); diff --git a/src/client.h b/src/client.h index b3fc0d676..27e6249bd 100644 --- a/src/client.h +++ b/src/client.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -131,6 +131,7 @@ enum PacketTypes PACKET_DIRECTION = 8, PACKET_ATTACK = 9, PACKET_STOPATTACK = 10, + PACKET_ONLINELIST = 11, PACKET_SIZE }; @@ -162,6 +163,7 @@ public: chooseDefault(false), noOpenGL(false), safeMode(false), + testMode(false), serverPort(0) {} @@ -183,6 +185,8 @@ public: std::string localDataDir; std::string screenshotDir; bool safeMode; + bool testMode; + std::string test; std::string serverName; short serverPort; @@ -197,7 +201,13 @@ public: static Client *instance() { return mInstance; } - int exec(); + void gameInit(); + + void testsInit(); + + int gameExec(); + + int testsExec(); static void setState(State state) { instance()->mState = state; } @@ -255,6 +265,8 @@ public: static void setFramerate(int fpsLimit); + static int getFramerate(); + static bool isTmw(); void optionChanged(const std::string &name); @@ -277,19 +289,33 @@ public: private: void initRootDir(); + void initHomeDir(); + void initConfiguration(); + + void initLocalDataDir(); + + void initConfigDir(); + void initUpdatesDir(); + void initScreenshotDir(); + void initServerConfig(std::string serverName); bool copyFile(std::string &configPath, std::string &oldConfigPath); + bool createConfig(std::string &configPath); void accountLogin(LoginData *data); void storeSafeParameters(); + void gameClear(); + + void testsClear(); + static Client *mInstance; Options mOptions; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index d04fda150..0f1e60a25 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -32,6 +32,7 @@ #include "localplayer.h" #include "logger.h" #include "main.h" +#include "party.h" #include "gui/chatwindow.h" #include "gui/helpwindow.h" @@ -201,6 +202,8 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) handleServerUnIgnoreAll(args, tab); else if (type == "dumpg") handleDumpGraphics(args, tab); + else if (type == "dumpt") + handleDumpTests(args, tab); else if (tab->handleCommand(type, args)) ; else if (type == "hack") @@ -405,7 +408,6 @@ void CommandHandler::handleParty(const std::string &args, ChatTab *tab) void CommandHandler::handleMe(const std::string &args, ChatTab *tab) { - const std::string str = strprintf("*%s*", args.c_str()); outString(tab, strprintf("*%s*", args.c_str()), args); } @@ -1110,7 +1112,7 @@ void CommandHandler::handleDumpGraphics(const std::string &args A_UNUSED, str += ",0"; #endif - str += strprintf(",%f,", Client::getGuiAlpha()); + str += strprintf(",%f,", static_cast<double>(Client::getGuiAlpha())); str += config.getBoolValue("adjustPerfomance") ? "1" : "0"; str += config.getBoolValue("alphaCache") ? "1" : "0"; str += config.getBoolValue("enableMapReduce") ? "1" : "0"; @@ -1122,7 +1124,60 @@ void CommandHandler::handleDumpGraphics(const std::string &args A_UNUSED, str += config.getBoolValue("particleeffects") ? "1" : "0"; str += strprintf(",%d-%d", fps, config.getIntValue("fpslimit")); - outString(tab, str, str); + outStringNormal(tab, str, str); +} + +void CommandHandler::handleDumpTests(const std::string &args A_UNUSED, + ChatTab *tab) +{ + std::string str = config.getStringValue("testInfo"); + outStringNormal(tab, str, str); +} + +void CommandHandler::outStringNormal(ChatTab *tab, const std::string &str, + const std::string &def) +{ + if (!player_node) + return; + + if (!tab) + { + Net::getChatHandler()->talk(str); + return; + } + + switch (tab->getType()) + { + case ChatTab::TAB_PARTY: + { + Net::getPartyHandler()->chat(str); + break; + } + case ChatTab::TAB_GUILD: + { + if (!player_node) + return; + const Guild *guild = player_node->getGuild(); + if (guild) + { + if (guild->getServerGuild()) + Net::getGuildHandler()->chat(guild->getId(), str); + else if (guildManager) + guildManager->chat(str); + } + break; + } + case ChatTab::TAB_WHISPER: + { + WhisperTab *whisper = static_cast<WhisperTab*>(tab); + tab->chatLog(player_node->getName(), str); + Net::getChatHandler()->privateMessage(whisper->getNick(), str); + break; + } + default: + Net::getChatHandler()->talk(def); + break; + } } #ifdef DEBUG_DUMP_LEAKS @@ -1194,3 +1249,82 @@ void CommandHandler::handleDump(const std::string &args A_UNUSED, { } #endif + +void CommandHandler::replaceVars(std::string &str) +{ + if (!player_node || !actorSpriteManager) + return; + + if (str.find("<PLAYER>") != std::string::npos) + { + Being *target = player_node->getTarget(); + if (!target || target->getType() != ActorSprite::PLAYER) + { + target = actorSpriteManager->findNearestLivingBeing( + player_node, 20, ActorSprite::PLAYER); + } + if (target) + replaceAll(str, "<PLAYER>", target->getName()); + else + replaceAll(str, "<PLAYER>", ""); + } + if (str.find("<MONSTER>") != std::string::npos) + { + Being *target = player_node->getTarget(); + if (!target || target->getType() != ActorSprite::MONSTER) + { + target = actorSpriteManager->findNearestLivingBeing( + player_node, 20, ActorSprite::MONSTER); + } + if (target) + replaceAll(str, "<MONSTER>", target->getName()); + else + replaceAll(str, "<MONSTER>", ""); + } + if (str.find("<PEOPLE>") != std::string::npos) + { + std::vector<std::string> names; + std::string newStr = ""; + actorSpriteManager->getPlayerNames(names, false); + std::vector<std::string>::const_iterator it = names.begin(); + std::vector<std::string>::const_iterator it_end = names.end(); + for (; it != it_end; ++ it) + { + if (*it != player_node->getName()) + newStr += *it + ","; + } + if (newStr[newStr.size() - 1] == ',') + newStr = newStr.substr(0, newStr.size() - 1); + if (!newStr.empty()) + replaceAll(str, "<PEOPLE>", newStr); + else + replaceAll(str, "<PEOPLE>", ""); + } + if (str.find("<PARTY>") != std::string::npos) + { + std::vector<std::string> names; + std::string newStr = ""; + Party *party = nullptr; + if (player_node->isInParty() && (party = player_node->getParty())) + { + party->getNames(names); + std::vector<std::string>::const_iterator it = names.begin(); + std::vector<std::string>::const_iterator it_end = names.end(); + for (; it != it_end; ++ it) + { + if (*it != player_node->getName()) + newStr += *it + ","; + } + if (newStr[newStr.size() - 1] == ',') + newStr = newStr.substr(0, newStr.size() - 1); + if (!newStr.empty()) + replaceAll(str, "<PARTY>", newStr); + else + replaceAll(str, "<PARTY>", ""); + } + else + { + replaceAll(str, "<PARTY>", ""); + } + } +} diff --git a/src/commandhandler.h b/src/commandhandler.h index f8b44e04f..16e5e94ce 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -59,6 +59,8 @@ class CommandHandler void handleCommands(const std::string &command, ChatTab *tab = localChatTab); + void replaceVars(std::string &str); + static char parseBoolean(const std::string &value); protected: @@ -297,9 +299,14 @@ class CommandHandler void handleDumpGraphics(const std::string &args, ChatTab *tab); + void handleDumpTests(const std::string &args, ChatTab *tab); + void outString(ChatTab *tab, const std::string &str, const std::string &def); + void outStringNormal(ChatTab *tab, const std::string &str, + const std::string &def); + void handleCacheInfo(const std::string &args, ChatTab *tab); bool parse2Int(const std::string &args, int *x, int *y); diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 912c51404..e76a55dcf 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/compoundsprite.h b/src/compoundsprite.h index f29bece7f..1c04e44d2 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/configlistener.h b/src/configlistener.h index bf94b1df5..e4bbbee53 100644 --- a/src/configlistener.h +++ b/src/configlistener.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/configuration.cpp b/src/configuration.cpp index b8b742f53..39e0c75d4 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -27,9 +27,6 @@ #include "utils/paths.h" #include "utils/stringutils.h" -#include "utils/xml.h" - -#include <libxml/encoding.h> #include <stdlib.h> @@ -429,13 +426,13 @@ bool Configuration::resetBoolValue(const std::string &key) return defaultValue; } -void ConfigurationObject::initFromXML(xmlNodePtr parent_node) +void ConfigurationObject::initFromXML(XmlNodePtr parent_node) { clear(); for_each_xml_child_node(node, parent_node) { - if (xmlStrEqual(node->name, BAD_CAST "list")) + if (xmlNameEqual(node, "list")) { // list option handling @@ -443,7 +440,7 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node) for_each_xml_child_node(subnode, node) { - if (xmlStrEqual(subnode->name, BAD_CAST name.c_str()) + if (xmlNameEqual(subnode, name.c_str()) && subnode->type == XML_ELEMENT_NODE) { ConfigurationObject *cobj = new ConfigurationObject; @@ -455,7 +452,7 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node) } } - else if (xmlStrEqual(node->name, BAD_CAST "option")) + else if (xmlNameEqual(node, "option")) { // single option handling @@ -492,9 +489,9 @@ void Configuration::init(const std::string &filename, bool useResManager) return; } - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "configuration")) + if (!rootNode || !xmlNameEqual(rootNode, "configuration")) { logger->log("Warning: No configuration file (%s)", filename.c_str()); return; @@ -503,7 +500,7 @@ void Configuration::init(const std::string &filename, bool useResManager) initFromXML(rootNode); } -void ConfigurationObject::writeToXML(xmlTextWriterPtr writer) +void ConfigurationObject::writeToXML(XmlTextWriterPtr writer) { for (Options::const_iterator i = mOptions.begin(), i_end = mOptions.end(); i != i_end; ++i) @@ -554,7 +551,7 @@ void Configuration::write() fclose(testFile); } - xmlTextWriterPtr writer = xmlNewTextWriterFilename(mConfigPath.c_str(), 0); + XmlTextWriterPtr writer = xmlNewTextWriterFilename(mConfigPath.c_str(), 0); if (!writer) { diff --git a/src/configuration.h b/src/configuration.h index 1f03b7387..00479933e 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -24,9 +24,10 @@ #define CONFIGURATION_H #include "utils/stringutils.h" -#include "defaults.h" +#include "utils/xml.h" -#include <libxml/xmlwriter.h> +#include "defaults.h" +#include "localconsts.h" #include <cassert> #include <list> @@ -158,7 +159,7 @@ class ConfigurationObject } delete nextobj; - nextobj = 0; + nextobj = nullptr; } /** @@ -192,8 +193,8 @@ class ConfigurationObject } protected: - virtual void initFromXML(xmlNodePtr node); - virtual void writeToXML(xmlTextWriterPtr writer); + virtual void initFromXML(XmlNodePtr node); + virtual void writeToXML(XmlTextWriterPtr writer); void deleteList(const std::string &name); diff --git a/src/debug.h b/src/debug.h index 00a0ec3d0..4b3934922 100644 --- a/src/debug.h +++ b/src/debug.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/defaults.cpp b/src/defaults.cpp index f18e0f432..8c0b84ae2 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -224,6 +224,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "lang", ""); AddDEF(configData, "selectedJoystick", 0); AddDEF(configData, "useInactiveJoystick", false); + AddDEF(configData, "testInfo", ""); return configData; } @@ -240,7 +241,7 @@ DefaultsData* getBrandingDefaults() AddDEF(brandingData, "defaultPort", DEFAULT_PORT); AddDEF(brandingData, "defaultServerType", "tmwathena"); AddDEF(brandingData, "onlineServerList", - "http://manasource.org/serverlist.xml"); + "http://manaplus.evolonline.org/serverlist.xml"); AddDEF(brandingData, "appShort", "mana"); AddDEF(brandingData, "defaultUpdateHost", ""); AddDEF(brandingData, "helpPath", ""); diff --git a/src/defaults.h b/src/defaults.h index 8a6ec7f60..1d979e928 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 55bf692cd..de12ecaa5 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -32,9 +32,9 @@ EffectManager::EffectManager() { XML::Document doc("effects.xml"); - xmlNodePtr root = doc.rootNode(); + XmlNodePtr root = doc.rootNode(); - if (!root || !xmlStrEqual(root->name, BAD_CAST "being-effects")) + if (!root || !xmlNameEqual(root, "being-effects")) { logger->log1("Error loading being effects file: effects.xml"); return; @@ -46,7 +46,7 @@ EffectManager::EffectManager() for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "effect")) + if (xmlNameEqual(node, "effect")) { EffectDescription ed; ed.id = XML::getProperty(node, "id", -1); diff --git a/src/equipment.h b/src/equipment.h index 2b6dae3ce..6e4d04c21 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/event.cpp b/src/event.cpp index 9d27a081a..4f77967bc 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/event.h b/src/event.h index 9ff02f3d0..61bf31e14 100644 --- a/src/event.h +++ b/src/event.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/flooritem.cpp b/src/flooritem.cpp index cf1ee16dc..6e4926f2e 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/flooritem.h b/src/flooritem.h index fb929268a..7e7da33a0 100644 --- a/src/flooritem.h +++ b/src/flooritem.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/game.cpp b/src/game.cpp index 683ba418b..14a988700 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -216,7 +216,9 @@ static void createGuiWindows() minimap = new Minimap; helpWindow = new HelpWindow; debugWindow = new DebugWindow; - itemShortcutWindow = new ShortcutWindow("ItemShortcut", "items.xml"); + itemShortcutWindow = new ShortcutWindow( + "ItemShortcut", "items.xml", 83, 460); + for (int f = 0; f < SHORTCUT_TABS; f ++) { itemShortcutWindow->addTab(toString(f + 1), @@ -551,9 +553,9 @@ void Game::logic() if (Client::getState() != STATE_ERROR) { - errorMessage = _("The connection to the server was lost."); if (!disconnectedDialog) { + errorMessage = _("The connection to the server was lost."); disconnectedDialog = new OkDialog(_("Network Error"), errorMessage, false); disconnectedDialog->addActionListener(&errorListener); @@ -561,14 +563,20 @@ void Game::logic() } } - if (viewport) + if (viewport && !errorMessage.empty()) { Map *map = viewport->getCurrentMap(); if (map) + { + logger->log("state: %d", Client::getState()); map->saveExtraLayer(); + } } closeDialogs(); Client::setFramerate(config.getIntValue("fpslimit")); + mNextAdjustTime = cur_time + adjustDelay; + if (Client::getState() != STATE_ERROR) + errorMessage = ""; } else { @@ -598,7 +606,10 @@ void Game::adjustPerfomance() return; } - int maxFps = config.getIntValue("fpslimit"); + int maxFps = Client::getFramerate(); + if (maxFps != config.getIntValue("fpslimit")) + return; + if (!maxFps) maxFps = 30; else if (maxFps < 10) @@ -1087,6 +1098,7 @@ bool Game::handleSwitchKeys(SDL_Event &event, bool &used) gcn::Window *requestedWindow = nullptr; if (!NpcDialog::isAnyInputFocused() + && !InventoryWindow::isAnyInputFocused() && !keyboard.isKeyActive(keyboard.KEY_TARGET) && !keyboard.isKeyActive(keyboard.KEY_UNTARGET)) { @@ -1507,8 +1519,7 @@ void Game::handleMoveAndAttack(SDL_Event &event, bool wasDown) } // Talk to the nearest NPC if 't' pressed - if (event.type == SDL_KEYDOWN && - keyboard.getKeyIndex(event.key.keysym.sym) + if (wasDown && keyboard.getKeyIndex(event.key.keysym.sym) == KeyboardConfig::KEY_TALK && !keyboard.isKeyActive(keyboard.KEY_EMOTE)) { @@ -1574,7 +1585,6 @@ void Game::handleActive(SDL_Event &event) player_node->setHalfAway(true); } } - Client::setFramerate(fpsLimit); } if (player_node) player_node->updateName(); @@ -1584,19 +1594,22 @@ void Game::handleActive(SDL_Event &event) if (event.active.state & SDL_APPMOUSEFOCUS) Client::setMouseFocused(event.active.gain); - if (player_node && player_node->getAway()) + if (!fpsLimit) { - if (Client::getInputFocused() || Client::getMouseFocused()) - fpsLimit = config.getIntValue("fpslimit"); + if (player_node && player_node->getAway()) + { + if (Client::getInputFocused() || Client::getMouseFocused()) + fpsLimit = config.getIntValue("fpslimit"); + else + fpsLimit = config.getIntValue("altfpslimit"); + } else - fpsLimit = config.getIntValue("altfpslimit"); - Client::setFramerate(fpsLimit); - } - else - { - fpsLimit = config.getIntValue("fpslimit"); - Client::setFramerate(fpsLimit); + { + fpsLimit = config.getIntValue("fpslimit"); + } } + Client::setFramerate(fpsLimit); + mNextAdjustTime = cur_time + adjustDelay; } /** diff --git a/src/game.h b/src/game.h index 4e5337d29..c6d942fe1 100644 --- a/src/game.h +++ b/src/game.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/graphics.cpp b/src/graphics.cpp index 47b0cae3d..bbd398aa5 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/graphics.h b/src/graphics.h index 2502c0418..4c47e690d 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp index 0e28c2b76..4a299620d 100644 --- a/src/graphicsvertexes.cpp +++ b/src/graphicsvertexes.cpp @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h index 13b7bf0c8..046bf90ce 100644 --- a/src/graphicsvertexes.h +++ b/src/graphicsvertexes.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index 759d4c245..eff4652ce 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h index 2aeb6c20c..a029f739a 100644 --- a/src/gui/beingpopup.h +++ b/src/gui/beingpopup.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index bff9ad31a..2043b4fe3 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -193,14 +193,14 @@ public: attackBot = true; // attacking but not talking more than 2 minutes - if (talk > 2 * 60 && talk > 2 * 60) + if (talk > 2 * 60) { talkBot = true; str += toString((talk) / 60) + " "; } // attacking but not moving more than 2 minutes - if (move > 2 * 60 && move > 2 * 60) + if (move > 2 * 60) { moveBot = true; str += toString((move) / 60); diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index f5e556848..c41f22de7 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h index 6bc10a103..57f66c922 100644 --- a/src/gui/buydialog.h +++ b/src/gui/buydialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index 2a614ed74..5aa421bad 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/buyselldialog.h b/src/gui/buyselldialog.h index 2c7e5c101..d8e4444d8 100644 --- a/src/gui/buyselldialog.h +++ b/src/gui/buyselldialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 3c412b424..518ed3da1 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index fccb5cb1c..acbd6b55a 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index a7ebaebca..8082b8d58 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index fca8b4946..525384a09 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index d621caa96..a1233fdcc 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -124,24 +124,24 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mAttributesLeft = new Label( strprintf(_("Please distribute %d points"), 99)); - int w = 200; + int w = 280; int h = 330; setContentSize(w, h); - mPlayerBox->setDimension(gcn::Rectangle(80, 30, 110, 85)); + mPlayerBox->setDimension(gcn::Rectangle(145, 35, 110, 87)); mNameLabel->setPosition(5, 5); mNameField->setDimension( - gcn::Rectangle(45, 5, w - 45 - 7, mNameField->getHeight())); - mPrevHairColorButton->setPosition(90, 35); - mNextHairColorButton->setPosition(165, 35); + gcn::Rectangle(60, 5, w - 60 - 7, mNameField->getHeight())); + mPrevHairColorButton->setPosition(155, 35); + mNextHairColorButton->setPosition(230, 35); mHairColorLabel->setPosition(5, 40); - mPrevHairStyleButton->setPosition(90, 64); - mNextHairStyleButton->setPosition(165, 64); + mPrevHairStyleButton->setPosition(155, 64); + mNextHairStyleButton->setPosition(230, 64); mHairStyleLabel->setPosition(5, 70); if (serverVersion >= 2) { - mPrevRaceButton->setPosition(90, 93); - mNextRaceButton->setPosition(165, 93); + mPrevRaceButton->setPosition(155, 93); + mNextRaceButton->setPosition(230, 93); mRaceLabel->setPosition(5, 100); } @@ -365,17 +365,18 @@ void CharCreateDialog::setAttributes(const std::vector<std::string> &labels, mAttributeLabel[i] = new Label(labels[i]); mAttributeLabel[i]->setWidth(70); mAttributeLabel[i]->setPosition(5, 140 + i*20); + mAttributeLabel[i]->adjustSize(); add(mAttributeLabel[i]); mAttributeSlider[i] = new Slider(min, max); - mAttributeSlider[i]->setDimension(gcn::Rectangle(75, 140 + i * 20, + mAttributeSlider[i]->setDimension(gcn::Rectangle(140, 140 + i * 20, 100, 10)); mAttributeSlider[i]->setActionEventId("statslider"); mAttributeSlider[i]->addActionListener(this); add(mAttributeSlider[i]); mAttributeValue[i] = new Label(toString(min)); - mAttributeValue[i]->setPosition(180, 140 + i*20); + mAttributeValue[i]->setPosition(245, 140 + i*20); add(mAttributeValue[i]); } diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index c7010d6b1..e369f1777 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 15d1e6e0e..638691bab 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -135,6 +135,7 @@ CharSelectDialog::CharSelectDialog(LoginData *data): setCloseButton(false); mAccountNameLabel = new Label(mLoginData->username); + mLastLoginLabel = new Label(mLoginData->lastLogin); mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); mChangePasswordButton = new Button(_("Change Password"), "change_password", this); @@ -145,6 +146,7 @@ CharSelectDialog::CharSelectDialog(LoginData *data): placer = getPlacer(0, 0); placer(0, 0, mAccountNameLabel, 2); + placer(2, 0, mLastLoginLabel); placer(0, 1, mSwitchLoginButton); if (optionalActions & Net::LoginHandler::Unregister) diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index 0dfe90733..1e32fb311 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -100,6 +100,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener, bool mLocked; gcn::Label *mAccountNameLabel; + gcn::Label *mLastLoginLabel; gcn::Button *mSwitchLoginButton; gcn::Button *mChangePasswordButton; diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 35b89b839..899bbdc36 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -24,6 +24,7 @@ #include "actorspritemanager.h" #include "client.h" +#include "commandhandler.h" #include "configuration.h" #include "guild.h" #include "keyboardconfig.h" @@ -55,10 +56,13 @@ #include "net/playerhandler.h" #include "net/net.h" +#include "utils/copynpaste.h" #include "utils/dtor.h" #include "utils/gettext.h" #include "utils/stringutils.h" +#include "resources/resourcemanager.h" + #include <guichan/focushandler.hpp> #include <guichan/focuslistener.hpp> @@ -151,7 +155,8 @@ public: ChatWindow::ChatWindow(): Window(_("Chat"), false, nullptr, "chat.xml"), mTmpVisible(false), - mChatHistoryIndex(0) + mChatHistoryIndex(0), + mGMLoaded(false) { listen(CHANNEL_NOTICES); listen(Mana::CHANNEL_ATTRIBUTES); @@ -211,6 +216,8 @@ ChatWindow::ChatWindow(): mColorPicker->setVisible(config.getBoolValue("showChatColorsList")); fillCommands(); + if (player_node && player_node->isGM()) + loadGMCommands(); initTradeFilter(); loadCustomList(); parseHighlights(); @@ -298,7 +305,35 @@ void ChatWindow::fillCommands() mCommands.push_back("/serverignoreall"); mCommands.push_back("/serverunignoreall"); mCommands.push_back("/dumpg"); + mCommands.push_back("/dumpt"); mCommands.push_back("/pseudoaway "); + mCommands.push_back("<PLAYER>"); + mCommands.push_back("<MONSTER>"); + mCommands.push_back("<PEOPLE>"); + mCommands.push_back("<PARTY>"); +} + +void ChatWindow::loadGMCommands() +{ + if (mGMLoaded) + return; + + const char *fileName = "gmcommands.txt"; + ResourceManager *resman = ResourceManager::getInstance(); + std::vector<std::string> list; + resman->loadTextFile(fileName, list); + std::vector<std::string>::const_iterator it = list.begin(); + std::vector<std::string>::const_iterator it_end = list.end(); + + while (it != it_end) + { + const std::string str = *it; + if (!str.empty()) + mCommands.push_back(str); + + ++ it; + } + mGMLoaded = true; } void ChatWindow::resetToDefaultSize() @@ -385,11 +420,11 @@ void ChatWindow::prevTab() int tab = mChatTabs->getSelectedTabIndex(); - if (tab == 0) + if (tab <= 0) tab = mChatTabs->getNumberOfTabs(); tab--; - mChatTabs->setSelectedTab(tab); + mChatTabs->setSelectedTabByPos(tab); } void ChatWindow::nextTab() @@ -403,7 +438,7 @@ void ChatWindow::nextTab() if (tab == mChatTabs->getNumberOfTabs()) tab = 0; - mChatTabs->setSelectedTab(tab); + mChatTabs->setSelectedTabByPos(tab); } void ChatWindow::closeTab() @@ -425,7 +460,7 @@ void ChatWindow::closeTab() void ChatWindow::defaultTab() { if (mChatTabs) - mChatTabs->setSelectedTab(static_cast<unsigned>(0)); + mChatTabs->setSelectedTabByPos(static_cast<unsigned>(0)); } void ChatWindow::action(const gcn::ActionEvent &event) @@ -1145,7 +1180,8 @@ void ChatWindow::autoComplete() ChatTab *cTab = static_cast<ChatTab*>(mChatTabs->getSelectedTab()); std::vector<std::string> nameList; - cTab->getAutoCompleteList(nameList); + if (cTab) + cTab->getAutoCompleteList(nameList); newName = autoComplete(nameList, name); if (newName == "" && actorSpriteManager) @@ -1540,4 +1576,18 @@ void ChatWindow::parseHighlights() bool ChatWindow::findHighlight(std::string &str) { return findI(str, mHighlights) != std::string::npos; -}
\ No newline at end of file +} + +void ChatWindow::copyToClipboard(int x, int y) +{ + ChatTab *tab = getFocused(); + if (!tab) + return; + + BrowserBox *text = tab->mTextOutput; + if (!text) + return; + + std::string str = text->getTextAtPos(x, y); + sendBuffer(str); +} diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index ad5229ffe..82e3d31f2 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -243,6 +243,8 @@ class ChatWindow : public Window, void loadCustomList(); + void loadGMCommands(); + std::string doReplace(const std::string &msg); void adjustTabSize(); @@ -258,6 +260,8 @@ class ChatWindow : public Window, bool findHighlight(std::string &str); + void copyToClipboard(int x, int y); + protected: friend class ChatTab; friend class WhisperTab; @@ -328,6 +332,7 @@ class ChatWindow : public Window, unsigned int mChatHistoryIndex; std::list<std::string> mAwayLog; std::vector<std::string> mHighlights; + bool mGMLoaded; }; extern ChatWindow *chatWindow; diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index 298855563..cf9d541ad 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/confirmdialog.h b/src/gui/confirmdialog.h index 2b5febed0..421be7f96 100644 --- a/src/gui/confirmdialog.h +++ b/src/gui/confirmdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp index da98ea5ac..ba1330881 100644 --- a/src/gui/connectiondialog.cpp +++ b/src/gui/connectiondialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/connectiondialog.h b/src/gui/connectiondialog.h index 7c0b59faf..76d8a952b 100644 --- a/src/gui/connectiondialog.h +++ b/src/gui/connectiondialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 56a63c72d..d13545bea 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h index b955209a5..ff86eaf74 100644 --- a/src/gui/debugwindow.h +++ b/src/gui/debugwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index 9a913a305..db0878360 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -138,16 +138,16 @@ void DidYouKnowWindow::loadFile(int num) { std::string name = helpPath + langs[0] + "/" + file + ".txt"; if (resman->exists(name)) - lines = resman->loadTextFile(name); + resman->loadTextFile(name, lines); if (lines.empty() && langs.size() > 1) { name = helpPath + langs[1] + "/" + file + ".txt"; - lines = resman->loadTextFile(name); + resman->loadTextFile(name, lines); } } if (lines.empty()) - lines = resman->loadTextFile(helpPath + file + ".txt"); + resman->loadTextFile(helpPath + file + ".txt", lines); for (unsigned int i = 0; i < lines.size(); ++i) mBrowserBox->addRow(lines[i]); diff --git a/src/gui/didyouknowwindow.h b/src/gui/didyouknowwindow.h index d9734e8fe..f3fb61c70 100644 --- a/src/gui/didyouknowwindow.h +++ b/src/gui/didyouknowwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp index a8c92ed47..a286f78e8 100644 --- a/src/gui/emotepopup.cpp +++ b/src/gui/emotepopup.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2009 Aethyra Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/emotepopup.h b/src/gui/emotepopup.h index a80562fea..453c4e669 100644 --- a/src/gui/emotepopup.h +++ b/src/gui/emotepopup.h @@ -3,7 +3,7 @@ * Copyright (C) 2009 Aethyra Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index cb3ace0c7..275bf19bb 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -65,7 +65,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, mEquipment(equipment), mSelected(-1), mForing(foring), - mImageSet(0) + mImageSet(nullptr) { mBeing = being; mItemPopup = new ItemPopup; @@ -355,7 +355,7 @@ void EquipmentWindow::resetBeing(Being *being) void EquipmentWindow::fillBoxes() { XML::Document *doc = new XML::Document("equipmentwindow.xml"); - xmlNodePtr root = doc->rootNode(); + XmlNodePtr root = doc->rootNode(); if (!root) { delete doc; @@ -371,23 +371,23 @@ void EquipmentWindow::fillBoxes() for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "window")) + if (xmlNameEqual(node, "window")) loadWindow(node); - else if (xmlStrEqual(node->name, BAD_CAST "playerbox")) + else if (xmlNameEqual(node, "playerbox")) loadPlayerBox(node); - else if (xmlStrEqual(node->name, BAD_CAST "slot")) + else if (xmlNameEqual(node, "slot")) loadSlot(node, mImageSet); } delete doc; } -void EquipmentWindow::loadWindow(xmlNodePtr windowNode) +void EquipmentWindow::loadWindow(XmlNodePtr windowNode) { setDefaultSize(XML::getProperty(windowNode, "width", 180), XML::getProperty(windowNode, "height", 345), ImageRect::CENTER); } -void EquipmentWindow::loadPlayerBox(xmlNodePtr playerBoxNode) +void EquipmentWindow::loadPlayerBox(XmlNodePtr playerBoxNode) { mPlayerBox->setDimension(gcn::Rectangle( XML::getProperty(playerBoxNode, "x", 50), @@ -396,7 +396,7 @@ void EquipmentWindow::loadPlayerBox(xmlNodePtr playerBoxNode) XML::getProperty(playerBoxNode, "height", 168))); } -void EquipmentWindow::loadSlot(xmlNodePtr slotNode, ImageSet *imageset) +void EquipmentWindow::loadSlot(XmlNodePtr slotNode, ImageSet *imageset) { int slot = parseSlotName(XML::getProperty(slotNode, "name", "")); if (slot < 0) diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 0a3c2da20..daeaeb3d7 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -85,7 +85,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener void mousePressed(gcn::MouseEvent& mouseEvent); Item* getEquipment(int i) - { return mEquipment ? mEquipment->getEquipment(i) : 0; } + { return mEquipment ? mEquipment->getEquipment(i) : nullptr; } void setBeing(Being *being); @@ -108,11 +108,11 @@ class EquipmentWindow : public Window, public gcn::ActionListener void addBox(int idx, int x, int y, int imageIndex); - void loadWindow(xmlNodePtr windowNode); + void loadWindow(XmlNodePtr windowNode); - void loadPlayerBox(xmlNodePtr playerBoxNode); + void loadPlayerBox(XmlNodePtr playerBoxNode); - void loadSlot(xmlNodePtr slotNode, ImageSet *imageset); + void loadSlot(XmlNodePtr slotNode, ImageSet *imageset); int parseSlotName(std::string name); diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index 40fa2f4ed..0e98c3473 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 9d814bb69..064f04697 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index b3154fb25..bd855a598 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/gui.h b/src/gui/gui.h index 578202b17..cadcc89ac 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index 49f309bca..a099c7a7a 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -114,16 +114,16 @@ void HelpWindow::loadFile(const std::string &file) { std::string name = helpPath + langs[0] + "/" + file + ".txt"; if (resman->exists(name)) - lines = resman->loadTextFile(name); + resman->loadTextFile(name, lines); if (lines.empty() && langs.size() > 1) { name = helpPath + langs[1] + "/" + file + ".txt"; - lines = resman->loadTextFile(name); + resman->loadTextFile(name, lines); } } if (lines.empty()) - lines = resman->loadTextFile(helpPath + file + ".txt"); + resman->loadTextFile(helpPath + file + ".txt", lines); for (unsigned int i = 0; i < lines.size(); ++i) mBrowserBox->addRow(lines[i]); diff --git a/src/gui/helpwindow.h b/src/gui/helpwindow.h index 178ae1e16..a6d83e91d 100644 --- a/src/gui/helpwindow.h +++ b/src/gui/helpwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 8ffebebff..01e2bdd17 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -98,7 +98,7 @@ InventoryWindow::WindowList InventoryWindow::instances; InventoryWindow::InventoryWindow(Inventory *inventory): Window("Inventory", false, nullptr, "inventory.xml"), mInventory(inventory), - mDropButton(0), + mDropButton(nullptr), mSplit(false), mCompactMode(false) { diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index aa78705b8..2b35ec9c4 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -128,7 +128,7 @@ class InventoryWindow : public Window, void processEvent(Mana::Channels channel, const Mana::Event &event); - void updateButtons(Item *item = 0); + void updateButtons(Item *item = nullptr); bool isInputFocused() const; diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index a80434ac0..9e2a97681 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/itemamountwindow.h b/src/gui/itemamountwindow.h index bacd4cfd0..076101c0f 100644 --- a/src/gui/itemamountwindow.h +++ b/src/gui/itemamountwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 2e87cd544..9a9e5f50d 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index 66d7e91a2..89f6355fe 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index fa6241ef6..972c660ec 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -70,8 +70,8 @@ KillStats::KillStats(): xpNextLevel = 1; mLine1 = new Label(strprintf(_("Level: %d at %f%%"), - player_node->getLevel(), static_cast<float>(xp) - / static_cast<float>(xpNextLevel) * 100.0f)); + player_node->getLevel(), static_cast<double>(xp) + / static_cast<double>(xpNextLevel) * 100.0)); mLine2 = new Label(strprintf(_("Exp: %d/%d Left: %d"), xp, xpNextLevel, xpNextLevel - xp)); @@ -206,9 +206,9 @@ void KillStats::gainXp(int xp) timeDiff = 1; mLine1->setCaption(strprintf(_("Level: %d at %f%%"), - player_node->getLevel(), static_cast<float>( - PlayerInfo::getAttribute(EXP)) / static_cast<float>( - xpNextLevel) * 100.0f)); + player_node->getLevel(), static_cast<double>( + PlayerInfo::getAttribute(EXP)) / static_cast<double>( + xpNextLevel) * 100.0)); mLine2->setCaption(strprintf(_("Exp: %d/%d Left: %d"), PlayerInfo::getAttribute(EXP), xpNextLevel, diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 86b3dc28b..b1c80b102 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -184,8 +184,16 @@ void LoginDialog::action(const gcn::ActionEvent &event) serverConfig.setValue("customUpdateHost", mUpdateHostText->getText()); - mLoginData->updateHost = mUpdateHostText->getText(); - *mUpdateHost = mUpdateHostText->getText(); + if (checkPath(mUpdateHostText->getText())) + { + mLoginData->updateHost = mUpdateHostText->getText(); + *mUpdateHost = mUpdateHostText->getText(); + } + else + { + mLoginData->updateHost = ""; + *mUpdateHost = ""; + } } mLoginData->updateType = updateType; serverConfig.setValue("updateType", updateType); diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index 0696bc680..08799b1c2 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index d890a462f..74da37341 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/minimap.h b/src/gui/minimap.h index 86996f51c..8b7da5849 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 665d2b61b..00df97813 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -188,7 +188,7 @@ void MiniStatusWindow::updateBars() void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite) { if (index >= static_cast<int>(mIcons.size())) - mIcons.resize(index + 1, 0); + mIcons.resize(index + 1, nullptr); delete mIcons[index]; diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 6fb8f7652..ca18e1b92 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 66a30c8a7..265748b6f 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -48,7 +48,7 @@ #include "debug.h" -#define CAPTION_WAITING _("Waiting for server") +#define CAPTION_WAITING _("Stop waiting") #define CAPTION_NEXT _("Next") #define CAPTION_CLOSE _("Close") #define CAPTION_SUBMIT _("Submit") @@ -220,9 +220,9 @@ void NpcDialog::action(const gcn::ActionEvent &event) return; nextDialog(); - addText(_("> Next"), false); } - else if (mActionState == NPC_ACTION_CLOSE) + else if (mActionState == NPC_ACTION_CLOSE + || mActionState == NPC_ACTION_WAIT) { closeDialog(); } @@ -501,8 +501,6 @@ void NpcDialog::buildLayout() Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); - mButton->setEnabled(mActionState != NPC_ACTION_WAIT); - redraw(); mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 7e9ea7e10..e76897499 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index ada48e832..6bcb62baf 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/npcpostdialog.h b/src/gui/npcpostdialog.h index bc329096b..b00f7bda0 100644 --- a/src/gui/npcpostdialog.h +++ b/src/gui/npcpostdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index 5a6ee4846..4a3bdf731 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index 2f32d0d65..5705be568 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index c33c753bc..74e8dbe46 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -985,3 +985,12 @@ void OutfitWindow::setItemSelected(Item *item) mItemColorSelected = 1; } } + +void OutfitWindow::clearCurrentOutfit() +{ + for (unsigned f = 0; f < OUTFIT_ITEM_COUNT; f++) + { + mItems[mCurrentOutfit][f] = -1; + mItemColors[mCurrentOutfit][f] = 1; + } +} diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 8dd5fd6a3..b2b46c7e7 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -108,6 +108,8 @@ class OutfitWindow : public Window, gcn::ActionListener std::string keyName(int number) A_PURE; + void clearCurrentOutfit(); + private: Button *mPreviousButton; Button *mNextButton; diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index f3046264f..fe14cd2d4 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -65,15 +65,13 @@ Palette::~Palette() const gcn::Color& Palette::getColor(char c, bool &valid) { - for (Colors::const_iterator col = mColors.begin(), - colEnd = mColors.end(); col != colEnd; ++col) + CharColors::const_iterator it = mCharColors.find(c); + if (it != mCharColors.end()) { - if (col->ch == c) - { - valid = true; - return col->color; - } + valid = true; + return mColors[(*it).second].color; } + valid = false; return BLACK; } diff --git a/src/gui/palette.h b/src/gui/palette.h index 645260280..36d87e305 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -30,6 +30,7 @@ #include <guichan/color.hpp> #include <cstdlib> +#include <map> #include <string> #include <set> #include <vector> @@ -200,8 +201,10 @@ class Palette } }; typedef std::vector<ColorElem> Colors; + typedef std::map<unsigned char, int> CharColors; /** Vector containing the colors. */ Colors mColors; + CharColors mCharColors; std::vector<ColorElem*> mGradVector; }; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index b133f66fc..cd3a4c5ad 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -85,7 +85,7 @@ std::string tradePartnerName(""); PopupMenu::PopupMenu(): Popup("PopupMenu", "popupmenu.xml"), mBeingId(0), - mFloorItem(nullptr), + mFloorItemId(0), mItem(nullptr), mItemId(0), mItemColor(1), @@ -95,7 +95,9 @@ PopupMenu::PopupMenu(): mDialog(nullptr), mButton(nullptr), mNick(""), - mType(Being::UNKNOWN) + mType(Being::UNKNOWN), + mX(0), + mY(0) { mBrowserBox = new BrowserBox; mBrowserBox->setPosition(4, 4); @@ -120,6 +122,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) mNick = being->getName(); mType = being->getType(); mBrowserBox->clearRows(); + mX = x; + mY = y; const std::string &name = mNick; @@ -346,20 +350,36 @@ void PopupMenu::showPopup(int x, int y, Being *being) showPopup(x, y); } -void PopupMenu::showPopup(int x, int y, std::vector<Being*> &beings) +void PopupMenu::showPopup(int x, int y, std::vector<ActorSprite*> &beings) { + mX = x; + mY = y; mBrowserBox->clearRows(); - mBrowserBox->addRow("Players"); - std::vector<Being*>::const_iterator it, it_end; + mBrowserBox->addRow(_("Players")); + std::vector<ActorSprite*>::const_iterator it, it_end; for (it = beings.begin(), it_end = beings.end(); it != it_end; ++it) { - Being *being = *it; - if (!being->getName().empty()) + Being *being = dynamic_cast<Being*>(*it); + ActorSprite *actor = *it; + if (being && !being->getName().empty()) { mBrowserBox->addRow(strprintf("@@player_%u|%s >@@", being->getId(), (being->getName() + being->getGenderSignWithSpace()).c_str())); } + else if (actor->getType() == ActorSprite::FLOOR_ITEM) + { + FloorItem *floorItem = static_cast<FloorItem*>(actor); + const ItemInfo &info = floorItem->getInfo(); + std::string name; + + if (serverVersion > 0) + name = info.getName(floorItem->getColor()); + else + name = info.getName(); + mBrowserBox->addRow(strprintf("@@flooritem_%u|%s >@@", + actor->getId(), name.c_str())); + } } mBrowserBox->addRow("##3---"); mBrowserBox->addRow("cancel", _("Cancel")); @@ -374,6 +394,8 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mNick = nick; mBeingId = 0; mType = Being::PLAYER; + mX = x; + mY = y; mBrowserBox->clearRows(); const std::string &name = mNick; @@ -507,7 +529,9 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) if (!floorItem) return; - mFloorItem = floorItem; + mFloorItemId = floorItem->getId(); + mX = x; + mY = y; const ItemInfo &info = floorItem->getInfo(); mBrowserBox->clearRows(); std::string name; @@ -534,6 +558,8 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem) return; mMapItem = mapItem; + mX = x; + mY = y; mBrowserBox->clearRows(); @@ -554,10 +580,13 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem) void PopupMenu::showOutfitsPopup(int x, int y) { + mX = x; + mY = y; + mBrowserBox->clearRows(); mBrowserBox->addRow(_("Outfits")); - mBrowserBox->addRow("load old outfits", _("Load old outfits")); + mBrowserBox->addRow("clear outfit", _("Clear outfit")); mBrowserBox->addRow("##3---"); mBrowserBox->addRow("cancel", _("Cancel")); @@ -573,6 +602,9 @@ void PopupMenu::showSpellPopup(int x, int y, TextCommand *cmd) mBrowserBox->clearRows(); mSpell = cmd; + mX = x; + mY = y; + mBrowserBox->addRow(_("Spells")); mBrowserBox->addRow("load old spells", _("Load old spells")); mBrowserBox->addRow("edit spell", _("Edit spell")); @@ -589,6 +621,8 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) return; mTab = tab; + mX = x; + mY = y; mBrowserBox->clearRows(); @@ -617,6 +651,8 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) mBrowserBox->addRow("leave party", _("Leave")); mBrowserBox->addRow("##3---"); } + mBrowserBox->addRow("chat clipboard", _("Copy to clipboard")); + mBrowserBox->addRow("##3---"); if (tab->getType() == ChatTab::TAB_WHISPER) { @@ -815,6 +851,8 @@ void PopupMenu::showChangePos(int x, int y) if (!player_node) return; + mX = x; + mY = y; const Guild *guild = player_node->getGuild(); if (guild) { @@ -833,11 +871,13 @@ void PopupMenu::showChangePos(int x, int y) else { mBeingId = 0; - mFloorItem = nullptr; + mFloorItemId = 0; mItem = nullptr; mMapItem = nullptr; mNick = ""; mType = Being::UNKNOWN; + mX = 0; + mY = 0; setVisible(false); } } @@ -998,10 +1038,14 @@ void PopupMenu::handleLink(const std::string &link, player_node->setImitate(mNick); } // Pick Up Floor Item action - else if ((link == "pickup") && mFloorItem) + else if ((link == "pickup") && mFloorItemId) { - if (player_node) - player_node->pickUp(mFloorItem); + if (player_node && actorSpriteManager) + { + FloorItem *item = actorSpriteManager->findItem(mFloorItemId); + if (item) + player_node->pickUp(item); + } } // Look To action else if (link == "look") @@ -1066,16 +1110,21 @@ void PopupMenu::handleLink(const std::string &link, chatWindow->addItemText(mItem->getInfo().getName()); } } - else if (mFloorItem) + else if (mFloorItemId && actorSpriteManager) { - if (serverVersion > 0) - { - chatWindow->addItemText(mFloorItem->getInfo().getName( - mFloorItem->getColor())); - } - else + FloorItem *item = actorSpriteManager->findItem(mFloorItemId); + + if (item) { - chatWindow->addItemText(mFloorItem->getInfo().getName()); + if (serverVersion > 0) + { + chatWindow->addItemText(item->getInfo().getName( + item->getColor())); + } + else + { + chatWindow->addItemText(item->getInfo().getName()); + } } } } @@ -1291,11 +1340,6 @@ void PopupMenu::handleLink(const std::string &link, mDialog->setActionEventId("ok"); mDialog->addActionListener(&mRenameListener); } - else if (link == "load old outfits") - { - if (outfitWindow) - outfitWindow->load(true); - } else if (link == "load old spells") { if (spellManager) @@ -1404,6 +1448,11 @@ void PopupMenu::handleLink(const std::string &link, if (chatWindow) chatWindow->saveState(); } + else if (link == "chat clipboard" && mTab) + { + if (chatWindow) + chatWindow->copyToClipboard(mX, mY); + } else if (link == "remove attack" && being) { if (actorSpriteManager && being->getType() == Being::MONSTER) @@ -1628,6 +1677,11 @@ void PopupMenu::handleLink(const std::string &link, showChangePos(getX(), getY()); return; } + else if (link == "clear outfit") + { + if (outfitWindow) + outfitWindow->clearCurrentOutfit(); + } else if (!link.compare(0, 10, "guild-pos-")) { if (player_node) @@ -1654,6 +1708,23 @@ void PopupMenu::handleLink(const std::string &link, } } } + else if (!link.compare(0, 10, "flooritem_")) + { + if (actorSpriteManager) + { + int id = atoi(link.substr(10).c_str()); + if (id) + { + FloorItem *item = actorSpriteManager->findItem(id); + if (item) + { + mFloorItemId = item->getId(); + showPopup(getX(), getY(), item); + return; + } + } + } + } else if (!link.compare(0, 12, "hide button_")) { if (windowMenu) @@ -1683,13 +1754,15 @@ void PopupMenu::handleLink(const std::string &link, setVisible(false); mBeingId = 0; - mFloorItem = nullptr; + mFloorItemId = 0; mItem = nullptr; mItemId = 0; mItemColor = 1; mMapItem = nullptr; mNick = ""; mType = Being::UNKNOWN; + mX = 0; + mY = 0; } void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, @@ -1700,6 +1773,8 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, mItem = item; mWindow = parent; + mX = x; + mY = y; mBrowserBox->clearRows(); int cnt = item->getQuantity(); @@ -1793,6 +1868,8 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color) mItem = nullptr; mItemId = itemId; mItemColor = color; + mX = x; + mY = y; mBrowserBox->clearRows(); mBrowserBox->addRow("use", _("Use")); @@ -1809,6 +1886,8 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color) void PopupMenu::showItemPopup(int x, int y, Item *item) { mItem = item; + mX = x; + mY = y; if (item) { mItemId = item->getId(); @@ -1864,6 +1943,8 @@ void PopupMenu::showItemPopup(int x, int y, Item *item) void PopupMenu::showDropPopup(int x, int y, Item *item) { mItem = item; + mX = x; + mY = y; mBrowserBox->clearRows(); if (item) @@ -1912,6 +1993,8 @@ void PopupMenu::showPopup(int x, int y, Button *button) return; mButton = button; + mX = x; + mY = y; mBrowserBox->clearRows(); std::vector <gcn::Button*> names = windowMenu->getButtons(); @@ -1947,6 +2030,8 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) return; mNick = b->text(); + mX = x; + mY = y; mBrowserBox->clearRows(); std::vector <ProgressBar*> bars = miniStatusWindow->getBars(); @@ -1988,6 +2073,8 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, mNick = name; mType = Being::MONSTER; + mX = x; + mY = y; mBrowserBox->clearRows(); @@ -2041,6 +2128,8 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item) mItem = item; mItemId = item->getId(); mItemColor = item->getColor(); + mX = x; + mY = y; mBrowserBox->clearRows(); diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 4bbe2c46c..8b9107300 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -26,6 +26,8 @@ #include "gui/widgets/linkhandler.h" #include "gui/widgets/popup.h" +#include "actorsprite.h" + #include <guichan/actionlistener.hpp> #include "localconsts.h" @@ -102,7 +104,7 @@ class PopupMenu : public Popup, public LinkHandler /** * Shows the beings related popup menu at the specified mouse coords. */ - void showPopup(int x, int y, std::vector<Being*> &beings); + void showPopup(int x, int y, std::vector<ActorSprite*> &beings); void showPlayerPopup(int x, int y, std::string nick); @@ -158,7 +160,7 @@ class PopupMenu : public Popup, public LinkHandler BrowserBox* mBrowserBox; int mBeingId; - FloorItem* mFloorItem; + int mFloorItemId; Item *mItem; int mItemId; unsigned char mItemColor; @@ -172,6 +174,8 @@ class PopupMenu : public Popup, public LinkHandler Button *mButton; std::string mNick; int mType; + int mX; + int mY; /** * Shared code for the various showPopup functions. diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 450cfd86e..dff5a570c 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index 5456be26b..dd881d283 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 29030aa72..2122e0d6b 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/register.h b/src/gui/register.h index b0137f141..ecda27d28 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 001a8671a..0e69db026 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers * Copyright (C) 2009 Aethyra Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index e0aac7785..6fcad34d4 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * Copyright (C) 2009 Aethyra Development Team * * This file is part of The ManaPlus Client. diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 7c5ddb055..e8660f861 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -8,7 +8,7 @@ * * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson * Copyright (C) 2007-2010 The Mana World Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * Js_./ * Per Larsson a.k.a finalman _RqZ{a<^_aa diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index e1a77f6c9..0e1b16de7 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/selldialog.h b/src/gui/selldialog.h index a775cf0e0..877b74cd8 100644 --- a/src/gui/selldialog.h +++ b/src/gui/selldialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 3fd298159..39ff19a89 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -365,7 +365,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mConnectButton->requestFocus(); } - loadServers(false); + loadServers(true); if (mServers.empty()) downloadServerList(); @@ -558,7 +558,7 @@ void ServerDialog::logic() else if (mDownloadStatus == DOWNLOADING_IN_PROGRESS) { mDescription->setCaption(strprintf(_("Downloading server list..." - "%2.2f%%"), mDownloadProgress * 100)); + "%2.2f%%"), static_cast<double>(mDownloadProgress * 100))); } else if (mDownloadStatus == DOWNLOADING_IDLE) { @@ -609,9 +609,12 @@ void ServerDialog::downloadServerList() if (listFile.empty()) listFile = config.getStringValue("onlineServerList"); - // Fall back to manasource.org when neither branding nor config set it + // Fall back to manaplus.evolonline.org when neither branding nor config set it if (listFile.empty()) - listFile = "http://manasource.org/serverlist.xml"; + { + listFile = "http://manaplus.evolonline.org/" + "serverlist.xml/serverlist.xml"; + } if (mDownload) { @@ -628,9 +631,9 @@ void ServerDialog::downloadServerList() void ServerDialog::loadServers(bool addNew) { XML::Document doc(mDir + "/serverlist.xml", false); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "serverlist")) + if (!rootNode || !xmlNameEqual(rootNode, "serverlist")) { logger->log1("Error loading server list!"); return; @@ -646,7 +649,7 @@ void ServerDialog::loadServers(bool addNew) for_each_xml_child_node(serverNode, rootNode) { - if (!xmlStrEqual(serverNode->name, BAD_CAST "server")) + if (!xmlNameEqual(serverNode, "server")) continue; ServerInfo server; @@ -681,7 +684,7 @@ void ServerDialog::loadServers(bool addNew) for_each_xml_child_node(subNode, serverNode) { - if (xmlStrEqual(subNode->name, BAD_CAST "connection")) + if (xmlNameEqual(subNode, "connection")) { server.hostname = XML::getProperty(subNode, "hostname", ""); server.port = static_cast<short unsigned>( @@ -693,7 +696,7 @@ void ServerDialog::loadServers(bool addNew) server.port = defaultPortForServerType(server.type); } } - else if (xmlStrEqual(subNode->name, BAD_CAST "description")) + else if (xmlNameEqual(subNode, "description")) { server.description = reinterpret_cast<const char*>( subNode->xmlChildrenNode->content); diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index 39c6f94f7..d2fe0d25b 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index d305824d5..bac474950 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -201,7 +201,7 @@ void Setup::doCancel() void Setup::activateTab(const std::string &name) { std::string tmp = gettext(name.c_str()); - mPanel->setSelectedTab(tmp); + mPanel->setSelectedTabByName(tmp); /* for (std::list<SetupTab*>::const_iterator it = mTabs.begin(); it != mTabs.end(); ++it) @@ -212,7 +212,7 @@ void Setup::activateTab(const std::string &name) logger->log("check tab: " + tab->getName()); if (tab->getName() == tmp) { - mPanel->setSelectedTab(name); + mPanel->setSelectedTabByName(name); return; } } diff --git a/src/gui/setup.h b/src/gui/setup.h index b499da4ee..3a6f66297 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 1737e9004..bc058faf9 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index 53aa017b6..88869d730 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index 1b8209c8f..7e81acaa9 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_chat.h b/src/gui/setup_chat.h index 402235d99..238021cca 100644 --- a/src/gui/setup_chat.h +++ b/src/gui/setup_chat.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 6f1a4afce..d5885143c 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -1,7 +1,7 @@ /* * Configurable text colors * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_colors.h b/src/gui/setup_colors.h index b6d5209e2..cbcca6dfa 100644 --- a/src/gui/setup_colors.h +++ b/src/gui/setup_colors.h @@ -1,7 +1,7 @@ /* * Configurable text colors * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index 7899247e3..290607be4 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h index 5bd72cdad..d93d7e821 100644 --- a/src/gui/setup_joystick.h +++ b/src/gui/setup_joystick.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index fa7a63b8c..bdd7c2083 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au> * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index bd445cfa0..d6f5e9972 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_other.h b/src/gui/setup_other.h index a13bf4ba3..4144a02ab 100644 --- a/src/gui/setup_other.h +++ b/src/gui/setup_other.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp index dd634d1f3..95703fa4c 100644 --- a/src/gui/setup_perfomance.cpp +++ b/src/gui/setup_perfomance.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_perfomance.h b/src/gui/setup_perfomance.h index f355c9691..097c1e28c 100644 --- a/src/gui/setup_perfomance.h +++ b/src/gui/setup_perfomance.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index a6bf5b81c..f0bf4c0ea 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index c9ce7b3b3..ebfc78db6 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 8ac61f90c..9ddef9e1a 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_relations.h b/src/gui/setup_relations.h index 2c23d4dba..76ea26875 100644 --- a/src/gui/setup_relations.h +++ b/src/gui/setup_relations.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 3b1c1d932..67936f698 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -138,7 +138,7 @@ struct Language std::string value; }; -const int langs_count = 14; +const int langs_count = 15; const Language LANG_NAME[langs_count] = { @@ -150,6 +150,7 @@ const Language LANG_NAME[langs_count] = {N_("French"), "fr_FR"}, {N_("German"), "de_DE"}, {N_("Indonesian"), "id_ID"}, + {N_("Polish"), "pl_PL"}, {N_("Japanese"), "ja_JP.utf8"}, {N_("Dutch (Belgium/Flemish)"), "nl_BE"}, {N_("Portuguese"), "pt_PT"}, diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 794fd3324..259388fd0 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 509deb2fd..0c82ab272 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index a50a485ec..b6b87edb7 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h index e1fd8a2a0..53ed7690c 100644 --- a/src/gui/shopwindow.h +++ b/src/gui/shopwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index eff28def7..0e968efef 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -23,6 +23,7 @@ #include "gui/shortcutwindow.h" #include "configuration.h" +#include "logger.h" #include "gui/setup.h" @@ -58,12 +59,15 @@ ShortcutWindow::ShortcutWindow(const std::string &title, { setWindowName(title); // no title presented, title bar is padding so window can be moved. - gcn::Window::setTitleBarHeight(gcn::Window::getPadding()); + gcn::Window::setTitleBarHeight(gcn::Window::getPadding() + 1); setShowTitle(false); setResizable(true); setDefaultVisible(false); setSaveVisible(true); + mDragOffsetX = 0; + mDragOffsetY = 0; + setupWindow->registerWindowForReset(this); mTabs = nullptr; @@ -104,12 +108,15 @@ ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, { setWindowName(title); // no title presented, title bar is padding so window can be moved. - gcn::Window::setTitleBarHeight(gcn::Window::getPadding()); + gcn::Window::setTitleBarHeight(gcn::Window::getPadding() + 1); setShowTitle(false); setResizable(true); setDefaultVisible(false); setSaveVisible(true); + mDragOffsetX = 0; + mDragOffsetY = 0; + setupWindow->registerWindowForReset(this); mTabs = new TabbedArea; @@ -178,3 +185,34 @@ void ShortcutWindow::widgetHidden(const gcn::Event &event) } } } + +void ShortcutWindow::mousePressed(gcn::MouseEvent &event) +{ + Window::mousePressed(event); + + if (event.isConsumed()) + return; + + if (event.getButton() == gcn::MouseEvent::LEFT) + { + mDragOffsetX = event.getX(); + mDragOffsetY = event.getY(); + } +} + +void ShortcutWindow::mouseDragged(gcn::MouseEvent &event) +{ + Window::mouseDragged(event); + + if (event.isConsumed()) + return; + + if (canMove() && isMovable() && mMoved) + { + int newX = std::max(0, getX() + event.getX() - mDragOffsetX); + int newY = std::max(0, getY() + event.getY() - mDragOffsetY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); + setPosition(newX, newY); + } +} diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index 8627a5dce..bdff5ab0d 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -58,6 +58,10 @@ class ShortcutWindow : public Window void widgetHidden(const gcn::Event &event); + void mousePressed(gcn::MouseEvent &event); + + void mouseDragged(gcn::MouseEvent &event); + private: ShortcutWindow(); ShortcutContainer *mItems; diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 072a9cb85..4ee674325 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -362,7 +362,7 @@ void SkillDialog::loadSkills(const std::string &file) return; XML::Document doc(file); - xmlNodePtr root = doc.rootNode(); + XmlNodePtr root = doc.rootNode(); int setCount = 0; std::string setName; @@ -370,7 +370,7 @@ void SkillDialog::loadSkills(const std::string &file) SkillListBox *listbox; SkillTab *tab; - if (!root || !xmlStrEqual(root->name, BAD_CAST "skills")) + if (!root || !xmlNameEqual(root, "skills")) { logger->log("Error loading skills file: %s", file.c_str()); @@ -413,7 +413,7 @@ void SkillDialog::loadSkills(const std::string &file) for_each_xml_child_node(set, root) { - if (xmlStrEqual(set->name, BAD_CAST "set")) + if (xmlNameEqual(set, "set")) { setCount++; setName = XML::getProperty(set, "name", @@ -425,7 +425,7 @@ void SkillDialog::loadSkills(const std::string &file) for_each_xml_child_node(node, set) { - if (xmlStrEqual(node->name, BAD_CAST "skill")) + if (xmlNameEqual(node, "skill")) { int id = atoi(XML::getProperty(node, "id", "-1").c_str()); std::string name = XML::getProperty(node, "name", diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 63f7d1790..dcb40927a 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 2bc8aba9b..3988c819c 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -29,6 +29,8 @@ #include "logger.h" #include "map.h" #include "party.h" +#include "playerrelations.h" +#include "gui/whoisonline.h" #include "gui/confirmdialog.h" #include "gui/okdialog.h" @@ -60,6 +62,30 @@ #include "debug.h" +class SortFriendsFunctor +{ + public: + bool operator() (Avatar* m1, Avatar* m2) + { + if (!m1 || !m2) + return false; + + if (m1->getOnline() != m2->getOnline()) + return m1->getOnline() > m2->getOnline(); + + if (m1->getName() != m2->getName()) + { + std::string s1 = m1->getName(); + std::string s2 = m2->getName(); + toLower(s1); + toLower(s2); + return s1 < s2; + } + return false; + } +} friendSorter; + + class SocialTab : public Tab { protected: @@ -457,7 +483,6 @@ public: mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); -// mBeings->getMembers().push_back(new Avatar("test")); updateList(); setCaption(name); } @@ -550,7 +575,6 @@ public: if (actorSpriteManager) { -// std::list<Being*> beings = actorSpriteManager->getAll(); std::vector<std::string> names; actorSpriteManager->getPlayerNames(names, false); @@ -650,7 +674,7 @@ public: return; Map* map = socialWindow->getMap(); - if (!map) + if (!map || map->empty()) return; if (socialWindow->getProcessedPortals()) @@ -848,11 +872,11 @@ public: std::vector<Avatar*> *avatars = mBeings->getMembers(); - std::vector<Avatar*>::iterator i = avatars->begin(); - if (!avatars) return; + std::vector<Avatar*>::iterator i = avatars->begin(); + while (i != avatars->end()) { Avatar *ava = (*i); @@ -1058,6 +1082,103 @@ private: }; + +class SocialFriendsTab : public SocialTab +{ +public: + SocialFriendsTab(std::string name) + { + mBeings = new BeingsListModal(); + + mList = new AvatarListBox(mBeings); + mScroll = new ScrollArea(mList); + + mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); + mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); + + updateList(); + setCaption(name); + } + + ~SocialFriendsTab() + { + delete mList; + mList = nullptr; + delete mScroll; + mScroll = nullptr; + delete mBeings; + mBeings = nullptr; + } + + void updateList() + { + getPlayersAvatars(); + } + + void updateAvatar(std::string name A_UNUSED) + { + } + + void resetDamage(std::string name A_UNUSED) + { + } + + void getPlayersAvatars() + { + if (!actorSpriteManager) + return; + + std::vector<Avatar*> *avatars = mBeings->getMembers(); + if (!avatars) + return; + + std::vector<Avatar*>::iterator ia = avatars->begin(); + while (ia != avatars->end()) + { + delete *ia; + ++ ia; + } + avatars->clear(); + + std::vector<std::string> *players + = player_relations.getPlayersByRelation(PlayerRelation::FRIEND); + + std::set<std::string> players2 = whoIsOnline->getOnlinePlayers(); + + if (!players) + return; + + std::vector<std::string>::iterator it = players->begin(); + std::vector<std::string>::iterator it_end = players->end(); + for (; it != it_end; ++ it) + { + Avatar *ava = nullptr; + ava = new Avatar(*it); + if (actorSpriteManager->findBeingByName(*it, Being::PLAYER) + || players2.find(*it) != players2.end()) + { + ava->setOnline(true); + } + avatars->push_back(ava); + } + std::sort(avatars->begin(), avatars->end(), friendSorter); + delete players; + } + +protected: + void invite() + { + } + + void leave() + { + } + +private: + BeingsListModal *mBeings; +}; + + class CreatePopup : public Popup, public LinkHandler { public: @@ -1155,6 +1276,9 @@ SocialWindow::SocialWindow() : mPlayers = new SocialPlayersTab("P"); mTabs->addTab(mPlayers, mPlayers->mScroll); + mFriends = new SocialFriendsTab("F"); + mTabs->addTab(mFriends, mFriends->mScroll); + mNavigation = new SocialNavigationTab(); mTabs->addTab(mNavigation, mNavigation->mScroll); @@ -1205,6 +1329,8 @@ SocialWindow::~SocialWindow() mNavigation = nullptr; delete mAttackFilter; mAttackFilter = nullptr; + delete mFriends; + mFriends = nullptr; } bool SocialWindow::addTab(Guild *guild) @@ -1523,6 +1649,7 @@ void SocialWindow::logic() if (mNeedUpdate && nowTime - mLastUpdateTime > 1) { mPlayers->updateList(); + mFriends->updateList(); mNeedUpdate = false; mLastUpdateTime = nowTime; } @@ -1610,7 +1737,7 @@ void SocialWindow::nextTab() if (tab == mTabs->getNumberOfTabs()) tab = 0; - mTabs->setSelectedTab(tab); + mTabs->setSelectedTabByPos(tab); } void SocialWindow::prevTab() @@ -1624,7 +1751,7 @@ void SocialWindow::prevTab() tab = mTabs->getNumberOfTabs(); tab--; - mTabs->setSelectedTab(tab); + mTabs->setSelectedTabByPos(tab); } void SocialWindow::updateAttackFilter() diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index dec8a6c26..1429866ee 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -141,6 +141,7 @@ protected: SocialTab *mAttackFilter; SocialTab *mPlayers; SocialTab *mNavigation; + SocialTab *mFriends; CreatePopup *mCreatePopup; diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 6abff3796..4dd53cee1 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h index 4350a656b..a7eeeb5d5 100644 --- a/src/gui/specialswindow.h +++ b/src/gui/specialswindow.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 7356cc633..877715137 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h index 170f619e8..5342bd49e 100644 --- a/src/gui/speechbubble.h +++ b/src/gui/speechbubble.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 5ac14d132..410ee08e2 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -431,10 +431,20 @@ void StatusWindow::addAttribute(int id, const std::string &name, disp = new DerDisplay(id, name); mDAttrCont->add(disp); } - mAttrs[id] = disp; } +void StatusWindow::clearAttributes() +{ + mAttrCont->clear(); + mDAttrCont->clear(); + Attrs::iterator it = mAttrs.begin(); + Attrs::iterator it_end = mAttrs.end(); + for (; it != it_end; ++ it) + delete (*it).second; + mAttrs.clear(); +} + void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax) { if (!bar) @@ -512,7 +522,7 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max, / static_cast<float>(max); if (percent) - bar->setText(strprintf("%2.5f", 100 * progress) + "%"); + bar->setText(strprintf("%2.5f%%", static_cast<double>(100 * progress))); else bar->setText(toString(value) + "/" + toString(max)); diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index d3a619bcb..8e110a354 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -75,6 +75,8 @@ class StatusWindow : public Window, void action(const gcn::ActionEvent &event); + void clearAttributes(); + private: static std::string translateLetter(const char* letters); diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp index a32b13aa4..b30c9eb82 100644 --- a/src/gui/textdialog.cpp +++ b/src/gui/textdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/textdialog.h b/src/gui/textdialog.h index aed26c1e9..03deae8f6 100644 --- a/src/gui/textdialog.h +++ b/src/gui/textdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -44,7 +44,7 @@ public: * @see Window::Window */ TextDialog(const std::string &title, const std::string &msg, - Window *parent = 0, bool isPassword = false); + Window *parent = nullptr, bool isPassword = false); ~TextDialog(); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 15b2618da..8cdbfa430 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h index 9ac041389..6f418152c 100644 --- a/src/gui/textpopup.h +++ b/src/gui/textpopup.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 9aa6bb956..85fd215ac 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2009 Aethyra Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -162,6 +162,18 @@ Theme::Theme(): mColors[SERVER].ch = 'S'; mColors[LOGGER].ch = 'L'; mColors[HYPERLINK].ch = '<'; + mCharColors['H'] = HIGHLIGHT; + mCharColors['C'] = CHAT; + mCharColors['G'] = GM; + mCharColors['Y'] = PLAYER; + mCharColors['W'] = WHISPER; + mCharColors['w'] = WHISPER_OFFLINE; + mCharColors['I'] = IS; + mCharColors['P'] = PARTY_CHAT_TAB; + mCharColors['U'] = GUILD_CHAT_TAB; + mCharColors['S'] = SERVER; + mCharColors['L'] = LOGGER; + mCharColors['<'] = HYPERLINK; } Theme::~Theme() @@ -303,9 +315,9 @@ Skin *Theme::readSkin(const std::string &filename) // filename = resman->mapPathToSkin(filename0); XML::Document doc(resolveThemePath(filename)); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset")) + if (!rootNode || !xmlNameEqual(rootNode, "skinset")) return nullptr; const std::string skinSetImage = XML::getProperty(rootNode, "image", ""); @@ -327,7 +339,7 @@ Skin *Theme::readSkin(const std::string &filename) // iterate <widget>'s for_each_xml_child_node(widgetNode, rootNode) { - if (!xmlStrEqual(widgetNode->name, BAD_CAST "widget")) + if (!xmlNameEqual(widgetNode, "widget")) continue; const std::string widgetType = @@ -336,7 +348,7 @@ Skin *Theme::readSkin(const std::string &filename) { for_each_xml_child_node(partNode, widgetNode) { - if (xmlStrEqual(partNode->name, BAD_CAST "part")) + if (xmlNameEqual(partNode, "part")) { const std::string partType = XML::getProperty(partNode, "type", "unknown"); @@ -465,7 +477,7 @@ Skin *Theme::readSkin(const std::string &filename) "'%s'", partType.c_str()); } } - else if (xmlStrEqual(partNode->name, BAD_CAST "option")) + else if (xmlNameEqual(partNode, "option")) { const std::string name = XML::getProperty( partNode, "name", ""); @@ -806,9 +818,9 @@ void Theme::loadColors(std::string file) file += "/colors.xml"; XML::Document doc(resolveThemePath(file)); - xmlNodePtr root = doc.rootNode(); + XmlNodePtr root = doc.rootNode(); - if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) + if (!root || !xmlNameEqual(root, "colors")) { logger->log("Error loading colors file: %s", file.c_str()); return; @@ -823,7 +835,7 @@ void Theme::loadColors(std::string file) for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "color")) + if (xmlNameEqual(node, "color")) { type = readColorType(XML::getProperty(node, "id", "")); if (type < 0) // invalid or no type given @@ -838,7 +850,7 @@ void Theme::loadColors(std::string file) mColors[type].set(type, color, grad, 10); } - else if (xmlStrEqual(node->name, BAD_CAST "progressbar")) + else if (xmlNameEqual(node, "progressbar")) { type = readProgressType(XML::getProperty(node, "id", "")); if (type < 0) // invalid or no type given diff --git a/src/gui/theme.h b/src/gui/theme.h index 92b2c8878..3be6882a3 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -4,7 +4,7 @@ * Copyright (C) 2009 Aethyra Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 506bf65c9..43393fc09 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h index 16b3d9d6f..b055c90ce 100644 --- a/src/gui/tradewindow.h +++ b/src/gui/tradewindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index c43f28400..ca21263f1 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/unregisterdialog.h b/src/gui/unregisterdialog.h index e68741e22..a89b3231b 100644 --- a/src/gui/unregisterdialog.h +++ b/src/gui/unregisterdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index ac51cc76f..39dde65c3 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -67,9 +67,9 @@ std::vector<updateFile> loadXMLFile(const std::string &fileName) { std::vector<updateFile> files; XML::Document doc(fileName, false); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "updates")) + if (!rootNode || !xmlNameEqual(rootNode, "updates")) { logger->log("Error loading update file: %s", fileName.c_str()); return files; @@ -78,7 +78,7 @@ std::vector<updateFile> loadXMLFile(const std::string &fileName) for_each_xml_child_node(fileNode, rootNode) { // Ignore all tags except for the "update" tags - if (!xmlStrEqual(fileNode->name, BAD_CAST "update")) + if (!xmlNameEqual(fileNode, "update")) continue; updateFile file; @@ -91,7 +91,8 @@ std::vector<updateFile> loadXMLFile(const std::string &fileName) else file.required = false; - files.push_back(file); + if (checkPath(file.name)) + files.push_back(file); } return files; @@ -118,7 +119,7 @@ std::vector<updateFile> loadTxtFile(const std::string &fileName) thisFile.required = true; thisFile.desc = ""; - if (!thisFile.name.empty()) + if (!thisFile.name.empty() && checkPath(thisFile.name)) files.push_back(thisFile); } } diff --git a/src/gui/updaterwindow.h b/src/gui/updaterwindow.h index e9a45241f..f8ee4e29c 100644 --- a/src/gui/updaterwindow.h +++ b/src/gui/updaterwindow.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 62fd03c70..a3299fb7b 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index 3bf9c782a..cb0593fa7 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 3086a027f..1407415fd 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -432,7 +432,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { if (actorSpriteManager) { - std::vector<Being*> beings; + std::vector<ActorSprite*> beings; const int x = getMouseX() + static_cast<int>(mPixelViewX); const int y = getMouseY() + static_cast<int>(mPixelViewY); actorSpriteManager->findBeingsByPixel(beings, x, y, true); @@ -481,6 +481,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (mHoverBeing->canTalk()) { mHoverBeing->talkTo(); + return; } else { @@ -490,6 +491,9 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { if (player_node != mHoverBeing || mSelfMouseHeal) actorSpriteManager->heal(mHoverBeing); + if (player_node == mHoverBeing && mHoverItem) + player_node->pickUp(mHoverItem); + return; } } else if (player_node->withinAttackRange(mHoverBeing) || @@ -499,17 +503,21 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { player_node->attack(mHoverBeing, !keyboard.isKeyActive(keyboard.KEY_TARGET)); + return; } } else if (!keyboard.isKeyActive(keyboard.KEY_ATTACK)) { if (player_node != mHoverBeing) + { player_node->setGotoTarget(mHoverBeing); + return; + } } } - // Picks up a item if we clicked on one } - else if (mHoverItem) + // Picks up a item if we clicked on one + if (mHoverItem) { player_node->pickUp(mHoverItem); } @@ -739,7 +747,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) } mHoverItem = nullptr; - if (!mHoverBeing && actorSpriteManager) + if (actorSpriteManager) { mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(), y / mMap->getTileHeight()); diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 938988198..b25f51242 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index e0fa4ebcf..a80fb4c89 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -21,14 +21,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "whoisonline.h" +#include "gui/whoisonline.h" #include <SDL.h> #include <SDL_thread.h> #include <vector> #include <algorithm> +#include "gui/socialwindow.h" #include "gui/viewport.h" + #include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/scrollarea.h" @@ -41,6 +43,9 @@ #include "playerrelations.h" #include "main.h" +#include "net/net.h" +#include "net/playerhandler.h" + #include "gui/chatwindow.h" #include "utils/gettext.h" @@ -181,7 +186,120 @@ void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event) } } -void WhoIsOnline::loadList() +void WhoIsOnline::updateWindow(std::vector<std::string> &friends, + std::vector<std::string> &neutral, + std::vector<std::string> &disregard, + std::vector<std::string> enemy, + int numOnline) +{ + //Set window caption + setCaption(_("Who Is Online - ") + toString(numOnline)); + + //List the online people + sort(friends.begin(), friends.end(), nameCompare); + sort(neutral.begin(), neutral.end(), nameCompare); + sort(disregard.begin(), disregard.end(), nameCompare); + bool addedFromSection(false); + for (int i = 0; i < static_cast<int>(friends.size()); i++) + { + mBrowserBox->addRow(friends.at(i)); + addedFromSection = true; + } + if (addedFromSection == true) + { + mBrowserBox->addRow("---"); + addedFromSection = false; + } + for (int i = 0; i < static_cast<int>(enemy.size()); i++) + { + mBrowserBox->addRow(enemy.at(i)); + addedFromSection = true; + } + if (addedFromSection == true) + { + mBrowserBox->addRow("---"); + addedFromSection = false; + } + for (int i = 0; i < static_cast<int>(neutral.size()); i++) + { + mBrowserBox->addRow(neutral.at(i)); + addedFromSection = true; + } + if (addedFromSection == true && !disregard.empty()) + { + mBrowserBox->addRow("---"); + addedFromSection = false; + } + for (int i = 0; i < static_cast<int>(disregard.size()); i++) + { + mBrowserBox->addRow(disregard.at(i)); + } + + if (mScrollArea->getVerticalMaxScroll() < + mScrollArea->getVerticalScrollAmount()) + { + mScrollArea->setVerticalScrollAmount( + mScrollArea->getVerticalMaxScroll()); + } +} + +void WhoIsOnline::loadList(std::vector<std::string> &list) +{ + mBrowserBox->clearRows(); + int numOnline = list.size(); + std::vector<std::string> friends; + std::vector<std::string> neutral; + std::vector<std::string> disregard; + std::vector<std::string> enemy; + + mOnlinePlayers.clear(); + mShowLevel = config.getBoolValue("showlevel"); + + std::vector<std::string>::const_iterator it = list.begin(); + std::vector<std::string>::const_iterator it_end = list.end(); + for (; it != it_end; ++ it) + { + std::string nick = *it; + mOnlinePlayers.insert(nick); + + switch (player_relations.getRelation(nick)) + { + case PlayerRelation::NEUTRAL: + default: + neutral.push_back(prepareNick(nick, 0, "0")); + break; + + case PlayerRelation::FRIEND: + friends.push_back(prepareNick(nick, 0, "2")); + break; + + case PlayerRelation::DISREGARDED: + case PlayerRelation::BLACKLISTED: + disregard.push_back(prepareNick(nick, 0, "8")); + break; + + case PlayerRelation::ENEMY2: + enemy.push_back(prepareNick(nick, 0, "1")); + break; + + case PlayerRelation::IGNORED: + case PlayerRelation::ERASED: + //Ignore the ignored. + break; + } + } + + updateWindow(friends, neutral, disregard, enemy, numOnline); + if (!mOnlinePlayers.empty()) + { + if (chatWindow) + chatWindow->updateOnline(mOnlinePlayers); + if (socialWindow) + socialWindow->updateActiveList(); + } +} + +void WhoIsOnline::loadWebList() { if (!mMemoryBuffer) return; @@ -303,59 +421,11 @@ void WhoIsOnline::loadList() line = strtok(nullptr, "\n"); } - //Set window caption - setCaption(_("Who Is Online - ") + toString(numOnline)); - - //List the online people - sort(friends.begin(), friends.end(), nameCompare); - sort(neutral.begin(), neutral.end(), nameCompare); - sort(disregard.begin(), disregard.end(), nameCompare); - bool addedFromSection(false); - for (int i = 0; i < static_cast<int>(friends.size()); i++) - { - mBrowserBox->addRow(friends.at(i)); - addedFromSection = true; - } - if (addedFromSection == true) - { - mBrowserBox->addRow("---"); - addedFromSection = false; - } - for (int i = 0; i < static_cast<int>(enemy.size()); i++) - { - mBrowserBox->addRow(enemy.at(i)); - addedFromSection = true; - } - if (addedFromSection == true) - { - mBrowserBox->addRow("---"); - addedFromSection = false; - } - for (int i = 0; i < static_cast<int>(neutral.size()); i++) - { - mBrowserBox->addRow(neutral.at(i)); - addedFromSection = true; - } - if (addedFromSection == true && !disregard.empty()) - { - mBrowserBox->addRow("---"); - addedFromSection = false; - } - for (int i = 0; i < static_cast<int>(disregard.size()); i++) - { - mBrowserBox->addRow(disregard.at(i)); - } + updateWindow(friends, neutral, disregard, enemy, numOnline); // Free the memory buffer now that we don't need it anymore free(mMemoryBuffer); mMemoryBuffer = nullptr; - - if (mScrollArea->getVerticalMaxScroll() < - mScrollArea->getVerticalScrollAmount()) - { - mScrollArea->setVerticalScrollAmount( - mScrollArea->getVerticalMaxScroll()); - } } size_t WhoIsOnline::memoryWrite(void *ptr, size_t size, @@ -461,15 +531,23 @@ int WhoIsOnline::downloadThread(void *ptr) void WhoIsOnline::download() { - mDownloadComplete = true; - if (mThread && SDL_GetThreadID(mThread)) - SDL_WaitThread(mThread, nullptr); + if (serverVersion < 3) + { + mDownloadComplete = true; + if (mThread && SDL_GetThreadID(mThread)) + SDL_WaitThread(mThread, nullptr); - mDownloadComplete = false; - mThread = SDL_CreateThread(WhoIsOnline::downloadThread, this); + mDownloadComplete = false; + mThread = SDL_CreateThread(WhoIsOnline::downloadThread, this); - if (mThread == nullptr) - mDownloadStatus = UPDATE_ERROR; + if (mThread == nullptr) + mDownloadStatus = UPDATE_ERROR; + } + else + { + if (Client::limitPackets(PACKET_ONLINELIST)) + Net::getPlayerHandler()->requestOnlineList(); + } } void WhoIsOnline::logic() @@ -513,13 +591,18 @@ void WhoIsOnline::logic() case UPDATE_LIST: if (mDownloadComplete == true) { - loadList(); + loadWebList(); mDownloadStatus = UPDATE_COMPLETE; mUpdateButton->setEnabled(true); mUpdateTimer = 0; updateSize(); - if (!mOnlinePlayers.empty() && chatWindow) - chatWindow->updateOnline(mOnlinePlayers); + if (!mOnlinePlayers.empty()) + { + if (chatWindow) + chatWindow->updateOnline(mOnlinePlayers); + if (socialWindow) + socialWindow->updateActiveList(); + } } break; case UPDATE_COMPLETE: @@ -532,18 +615,29 @@ void WhoIsOnline::action(const gcn::ActionEvent &event) { if (event.getId() == "update") { - if (mDownloadStatus == UPDATE_COMPLETE) + if (serverVersion < 3) + { + if (mDownloadStatus == UPDATE_COMPLETE) + { + mUpdateTimer = cur_time - 20; + if (mUpdateButton) + mUpdateButton->setEnabled(false); + setCaption(_("Who Is Online - Update")); + if (mThread && SDL_GetThreadID(mThread)) + { + SDL_WaitThread(mThread, nullptr); + mThread = nullptr; + } + mDownloadComplete = true; + } + } + else { - mUpdateTimer = cur_time - 20; - if (mUpdateButton) - mUpdateButton->setEnabled(false); - setCaption(_("Who Is Online - Update")); - if (mThread && SDL_GetThreadID(mThread)) + if (Client::limitPackets(PACKET_ONLINELIST)) { - SDL_WaitThread(mThread, nullptr); - mThread = nullptr; + mUpdateTimer = cur_time; + Net::getPlayerHandler()->requestOnlineList(); } - mDownloadComplete = true; } } } diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index 72063b183..ade391d5a 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -26,6 +26,7 @@ #include <string> #include <set> +#include <vector> #include "configlistener.h" @@ -65,7 +66,9 @@ class WhoIsOnline : public Window, /** * Loads and display online list from the memory buffer. */ - void loadList(); + void loadWebList(); + + void loadList(std::vector<std::string> &list); void handleLink(const std::string& link, gcn::MouseEvent *event); @@ -83,6 +86,10 @@ class WhoIsOnline : public Window, void optionChanged(const std::string &name); + void updateList(std::vector<std::string> &list); + + void readFromWeb(); + private: void download(); @@ -101,6 +108,13 @@ private: const std::string prepareNick(std::string nick, int level, std::string color) const; + + void updateWindow(std::vector<std::string> &friends, + std::vector<std::string> &neutral, + std::vector<std::string> &disregard, + std::vector<std::string> enemy, + int numOnline); + enum DownloadStatus { UPDATE_ERROR = 0, @@ -137,4 +151,6 @@ private: bool mUpdateOnlineList; }; +extern WhoIsOnline *whoIsOnline; + #endif diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 8264f0fb9..1bf897301 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index afb4abdf5..526db6ef5 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/battletab.cpp b/src/gui/widgets/battletab.cpp index c5500e801..5ac13c78e 100644 --- a/src/gui/widgets/battletab.cpp +++ b/src/gui/widgets/battletab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/battletab.h b/src/gui/widgets/battletab.h index 03c63da2c..8d85e739e 100644 --- a/src/gui/widgets/battletab.h +++ b/src/gui/widgets/battletab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 5ded29c55..5856a91b1 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * Copyright (C) 2009 Aethyra Development Team * * This file is part of The ManaPlus Client. @@ -79,6 +79,7 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque): mColors[PURPLE] = Theme::getThemeColor(Theme::PURPLE); mColors[GRAY] = Theme::getThemeColor(Theme::GRAY); mColors[BROWN] = Theme::getThemeColor(Theme::BROWN); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } BrowserBox::~BrowserBox() @@ -406,8 +407,8 @@ int BrowserBox::calcHeight() char const *hyphen = "~"; int hyphenWidth = font->getWidth(hyphen); - gcn::Color selColor = Theme::getThemeColor(Theme::TEXT); - const gcn::Color textColor = Theme::getThemeColor(Theme::TEXT); + gcn::Color selColor = getForegroundColor(); + const gcn::Color textColor = getForegroundColor(); ResourceManager *resman = ResourceManager::getInstance(); mLineParts.clear(); @@ -450,6 +451,7 @@ int BrowserBox::calcHeight() } gcn::Color prevColor = selColor; + bold = false; // TODO: Check if we must take texture size limits into account here // TODO: Check if some of the O(n) calls can be removed @@ -465,8 +467,6 @@ int BrowserBox::calcHeight() wrapped = false; } - bold = false; - // "Tokenize" the string at control sequences if (mUseLinksAndUserColors) end = row.find("##", start + 1); @@ -645,6 +645,35 @@ void BrowserBox::updateHeight() } } +std::string BrowserBox::getTextAtPos(const int x, const int y) +{ + int textX = 0; + int textY = 0; + + getAbsolutePosition(textX, textY); + if (x < textX || y < textY) + return ""; // mouse position ourside of correct widget (outside of tab) + + textX = x - textX; + textY = y - textY; + + std::string str = ""; + + for (LinePartIterator i = mLineParts.begin(); + i != mLineParts.end(); + ++i) + { + const LinePart &part = *i; + if (part.mY + 50 < mYStart) + continue; + if (part.mY > textY) + break; + str = part.mText; + } + + return str; +} + LinePart::~LinePart() { if (mImage) diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 06609b318..ab3049c0b 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * Copyright (C) 2009 Aethyra Development Team * * This file is part of The ManaPlus Client. @@ -137,6 +137,7 @@ class BrowserBox : public gcn::Widget, * Handles mouse actions. */ void mousePressed(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event); /** @@ -198,6 +199,8 @@ class BrowserBox : public gcn::Widget, void setEnableImages(bool n) { mEnableImages = n; } + std::string getTextAtPos(const int x, const int y); + private: int calcHeight(); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 85e4eca17..2867e3d39 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 1b62179b3..aed46bb55 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp index 87d87f7d1..f362cc28c 100644 --- a/src/gui/widgets/channeltab.cpp +++ b/src/gui/widgets/channeltab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index 5d3b78094..4b56d2e05 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 0a224605a..aea367482 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -205,8 +205,7 @@ void ChatTab::chatLog(std::string line, Own own, // if configured, move magic messages log to debug chat tab if (localChatTab && this == localChatTab - && ((config.getBoolValue("showMagicInDebug") - && own == BY_PLAYER && tmp.text.length() > 1 + && ((config.getBoolValue("showMagicInDebug") && own == BY_PLAYER && tmp.text.length() > 1 && tmp.text.at(0) == '#' && tmp.text.at(1) != '#') || (config.getBoolValue("serverMsgInDebug") && (own == BY_SERVER @@ -350,6 +349,9 @@ void ChatTab::chatInput(const std::string &message) start = msg.find('[', start + 1); } + if (commandHandler) + commandHandler->replaceVars(msg); + // Prepare ordinary message if (msg[0] != '/') handleInput(msg); diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 962c0b363..ddf10bf5e 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index dcedc8951..0689c5395 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index af38065f5..0c8e48553 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 558257507..80028a62f 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index c011b8925..d927f5379 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 2a17320de..91c983f26 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 3559b634a..a769678ca 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -48,7 +48,7 @@ class DropDown : public gcn::DropDown * @param listBox the listBox to use. * @see ListModel, ScrollArea, ListBox. */ - DropDown(gcn::ListModel *listModel = 0, + DropDown(gcn::ListModel *listModel = nullptr, gcn::ActionListener* listener = nullptr, std::string eventId = ""); diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 7d3ddc0b4..acda5ad88 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index d1f276b3c..677dd3661 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp index 0353ac23f..a95fca3cf 100644 --- a/src/gui/widgets/guildchattab.cpp +++ b/src/gui/widgets/guildchattab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h index 4f5ee3a8e..bebdaa1f3 100644 --- a/src/gui/widgets/guildchattab.h +++ b/src/gui/widgets/guildchattab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 78ce14e56..d620cbb8d 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 17f517644..d5810fcbf 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index dbb02498a..c128ea550 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index 2a3f77d2b..7439672dc 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index b8cc2ac3a..b35eb1d95 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 4b0d12342..6f05da3f7 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index 89544e108..8a075000b 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h index b36b088a6..7284c9d03 100644 --- a/src/gui/widgets/inttextfield.h +++ b/src/gui/widgets/inttextfield.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/inventoryfilter.cpp b/src/gui/widgets/inventoryfilter.cpp index 795f0d31e..216c2bea0 100644 --- a/src/gui/widgets/inventoryfilter.cpp +++ b/src/gui/widgets/inventoryfilter.cpp @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/inventoryfilter.h b/src/gui/widgets/inventoryfilter.h index c3762189e..c4f2b6242 100644 --- a/src/gui/widgets/inventoryfilter.h +++ b/src/gui/widgets/inventoryfilter.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 57c64093b..669d05a66 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 2c465fdee..ae6e4a35d 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 549aa1616..61d929f0b 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h index bc3bdc51c..9f66da991 100644 --- a/src/gui/widgets/itemlinkhandler.h +++ b/src/gui/widgets/itemlinkhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 3682ec448..130d641fe 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 587723279..59e52b5ae 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index f0359062e..453e62a50 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 754d13a0b..02fed43b5 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 54c41635f..2b79609b9 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index a01051595..b0f4d435d 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h index f8f195f2d..366899ffc 100644 --- a/src/gui/widgets/linkhandler.h +++ b/src/gui/widgets/linkhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 53299ca46..28fe9daa1 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 8ac0bbc3b..e4b6dd54e 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h index 9484be0a5..e41ed46b8 100644 --- a/src/gui/widgets/mouseevent.h +++ b/src/gui/widgets/mouseevent.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp index 34639b063..6f339ddd7 100644 --- a/src/gui/widgets/passwordfield.cpp +++ b/src/gui/widgets/passwordfield.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h index 5ba08094d..eca95e6ad 100644 --- a/src/gui/widgets/passwordfield.h +++ b/src/gui/widgets/passwordfield.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index fb72176bd..5e2412d3b 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 2bf010618..d2393ca08 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -25,6 +25,8 @@ #include <guichan/widgets/scrollarea.hpp> +#include "localconsts.h" + class Being; class ImageRect; @@ -40,7 +42,7 @@ class PlayerBox : public gcn::ScrollArea * Constructor. Takes the initial player character that this box should * display, which defaults to <code>NULL</code>. */ - PlayerBox(const Being *being = 0); + PlayerBox(const Being *being = nullptr); /** * Destructor. diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 78557d481..e206a3246 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * Copyright (C) 2009 Aethyra Development Team * * This file is part of The ManaPlus Client. diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 64e4b52ac..8ff21149a 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * Copyright (C) 2009 Aethyra Development Team * * This file is part of The ManaPlus Client. diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index f9b6da153..8b2beb8d5 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 36ed96bd2..163310245 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index e885aa0ec..6adb5a2fa 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -51,7 +51,7 @@ ProgressIndicator::ProgressIndicator() } else { - mIndicator = 0; + mIndicator = nullptr; } setSize(32, 32); @@ -60,7 +60,7 @@ ProgressIndicator::ProgressIndicator() ProgressIndicator::~ProgressIndicator() { delete mIndicator; - mIndicator = 0; + mIndicator = nullptr; } void ProgressIndicator::logic() diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index e5fcaefda..6d55fd3ce 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 7d344b09d..94152a716 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index d1c347acb..7692d478a 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index c8822eea9..4a6adadb6 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 873d74058..ce4eb0770 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 0ec4a2027..021bd3d15 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 105791080..86902b5c9 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 8081f5d7b..92ff625c2 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 5b8a9df87..eb2680ede 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/setuptab.cpp b/src/gui/widgets/setuptab.cpp index e98e9c3ac..b3863c134 100644 --- a/src/gui/widgets/setuptab.cpp +++ b/src/gui/widgets/setuptab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/setuptab.h b/src/gui/widgets/setuptab.h index ddc0c8958..e47af8995 100644 --- a/src/gui/widgets/setuptab.h +++ b/src/gui/widgets/setuptab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index 4fb092070..ab8f61a40 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h index 2b0c6f65e..4ad1f464b 100644 --- a/src/gui/widgets/setuptabscroll.h +++ b/src/gui/widgets/setuptabscroll.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index d3aac5c56..5f13e5f71 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index 29d24cb64..c013f1810 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index b649a81ef..71e373d70 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index c5acbbefc..9b416d3a3 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 36f88da08..6c8397bbb 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 8587950c6..72f8b9cac 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 3822d40c9..ed667e194 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 9ac45d0a0..8eed984b1 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 8e4b1fe6f..c09fb423d 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index ba51e6c74..40b46ede5 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index fb9279343..fc6526a13 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -197,7 +197,7 @@ void TabbedArea::removeTab(gcn::Tab *tab) } else { - setSelectedTab(tabIndexToBeSelected); + setSelectedTabByPos(tabIndexToBeSelected); } adjustSize(); @@ -241,7 +241,7 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab) widgetResized(nullptr); } -void TabbedArea::setSelectedTab(const std::string &name) +void TabbedArea::setSelectedTabByName(const std::string &name) { for (TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end(); itr != itr_end; ++itr) @@ -254,6 +254,11 @@ void TabbedArea::setSelectedTab(const std::string &name) } } +void TabbedArea::setSelectedTabByPos(int tab) +{ + gcn::TabbedArea::setSelectedTab(tab); +} + void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) { int width = getWidth() - 2 * getFrameSize() @@ -459,8 +464,7 @@ void TabbedArea::removeAll() { if (getSelectedTabIndex() != -1) { - setSelectedTab(static_cast<unsigned int>(0)); - + setSelectedTabByPos(static_cast<unsigned int>(0)); } while (getNumberOfTabs() > 0) { diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index d71109dd3..b202dfc9d 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -78,8 +78,6 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener */ gcn::Widget *getCurrentWidget(); - using gcn::TabbedArea::addTab; - /** * Add a tab. Overridden since it needs to size the widget. * @@ -112,11 +110,11 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener int getContainerHeight() const { return mWidgetContainer->getHeight(); } - using gcn::TabbedArea::setSelectedTab; - void setSelectedTab(gcn::Tab *tab); - void setSelectedTab(const std::string &name); + void setSelectedTabByPos(int tab); + + void setSelectedTabByName(const std::string &name); void widgetResized(const gcn::Event &event); diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index f54b4281a..5216fb89c 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h index 810b2f4ac..40a350163 100644 --- a/src/gui/widgets/tablemodel.h +++ b/src/gui/widgets/tablemodel.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index f31c8d129..a4bc3bc09 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 27525fc85..6d2467b38 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index b4584947a..03fdb5378 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index e530cfef2..bc1123f19 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 9be2d5b3f..f3ea962bc 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index a3f623177..81e27fd06 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/tradetab.cpp b/src/gui/widgets/tradetab.cpp index deec2aea6..5c893de1f 100644 --- a/src/gui/widgets/tradetab.cpp +++ b/src/gui/widgets/tradetab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/tradetab.h b/src/gui/widgets/tradetab.h index f061778f3..06add3ee0 100644 --- a/src/gui/widgets/tradetab.h +++ b/src/gui/widgets/tradetab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index 5e79b7c19..305343d1a 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -69,6 +69,7 @@ void VertContainer::clear() Container::clear(); mCount = 0; + mNextY = 0; } void VertContainer::widgetResized(const gcn::Event &event A_UNUSED) diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index 08546aa47..6e1305a06 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index 33859d8be..625c8a392 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index 8678c932c..72d407ac2 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 273695a1a..3858b0d81 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 6249626d3..65dbf196b 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 34a6b68c7..43aaea8a4 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index b27ba927f..00ef04c19 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 3f41be466..e954340f8 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 3f02ea851..8abc5e87a 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index ae5345031..917605281 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/gui/worldselectdialog.h b/src/gui/worldselectdialog.h index 61bcc4b51..1a469757f 100644 --- a/src/gui/worldselectdialog.h +++ b/src/gui/worldselectdialog.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/guichanfwd.h b/src/guichanfwd.h index be5708863..b3808d8ba 100644 --- a/src/guichanfwd.h +++ b/src/guichanfwd.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/guild.cpp b/src/guild.cpp index 0e629e2be..e569bed65 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/guild.h b/src/guild.h index 915dda5e7..e95677ec6 100644 --- a/src/guild.h +++ b/src/guild.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 16edb369a..9dc9d7b73 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/guildmanager.h b/src/guildmanager.h index 5cd5e19cc..368b2456c 100644 --- a/src/guildmanager.h +++ b/src/guildmanager.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp index 8634702ce..5e0b93d7a 100644 --- a/src/imageparticle.cpp +++ b/src/imageparticle.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/imageparticle.h b/src/imageparticle.h index 73005a526..16b4b8cb7 100644 --- a/src/imageparticle.h +++ b/src/imageparticle.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp index 6ccaeb5fc..f969717f2 100644 --- a/src/imagesprite.cpp +++ b/src/imagesprite.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/imagesprite.h b/src/imagesprite.h index 9dad0f743..7537faef3 100644 --- a/src/imagesprite.h +++ b/src/imagesprite.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/inventory.cpp b/src/inventory.cpp index 4521613ba..47a32bce1 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/inventory.h b/src/inventory.h index f94568739..d210c65e2 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/item.cpp b/src/item.cpp index d4b41b6cb..cc7d666b5 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/item.h b/src/item.h index 29700f27a..ad051846d 100644 --- a/src/item.h +++ b/src/item.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 625e8d90a..f267dd755 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/itemshortcut.h b/src/itemshortcut.h index b735e899c..55c6d1165 100644 --- a/src/itemshortcut.h +++ b/src/itemshortcut.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/joystick.cpp b/src/joystick.cpp index 29e16dff4..035232e41 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/joystick.h b/src/joystick.h index be23599c9..87d1e81a9 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/listener.cpp b/src/listener.cpp index cf7c209d6..ea125013f 100644 --- a/src/listener.cpp +++ b/src/listener.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/listener.h b/src/listener.h index cccc026c6..dc968672a 100644 --- a/src/listener.h +++ b/src/listener.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/localconsts.h b/src/localconsts.h index e135a4108..2d0eb5dea 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -21,6 +21,9 @@ #ifndef __GXX_EXPERIMENTAL_CXX0X__ #undef nullptr #define nullptr 0 +#else +#undef Z_NULL +#define Z_NULL nullptr #endif #ifdef __GNUC__ diff --git a/src/localplayer.cpp b/src/localplayer.cpp index cbf75a5f9..0da291711 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -98,7 +98,7 @@ extern MiniStatusWindow *miniStatusWindow; extern SkillDialog *skillDialog; LocalPlayer::LocalPlayer(int id, int subtype): - Being(id, PLAYER, subtype, 0), + Being(id, PLAYER, subtype, nullptr), mTargetTime(-1), mLastTarget(-1), mTarget(nullptr), @@ -112,7 +112,7 @@ LocalPlayer::LocalPlayer(int id, int subtype): mPathSetByMouse(false), mLocalWalkTime(-1), mMessageTime(0), - mAwayDialog(0), + mAwayDialog(nullptr), mAfkTime(0), mAwayMode(false), mPseudoAwayMode(false), @@ -151,12 +151,12 @@ LocalPlayer::LocalPlayer(int id, int subtype): if (userPalette) mNameColor = &userPalette->getColor(UserPalette::SELF); else - mNameColor = 0; + mNameColor = nullptr; mLastTargetX = 0; mLastTargetY = 0; - mInvertDirection = config.getIntValue("invertMoveDirection"); + mInvertDirection = 0; mCrazyMoveType = config.getIntValue("crazyMoveType"); mCrazyMoveState = 0; mAttackWeaponType = config.getIntValue("attackWeaponType"); @@ -381,7 +381,8 @@ void LocalPlayer::setAction(Action action, int attackType) mLastTarget = -1; if (!mLastHitFrom.empty()) { - debugMsg(_("You were killed by ") + mLastHitFrom); + debugMsg(strprintf(_("You were killed by %s"), + mLastHitFrom.c_str())); mLastHitFrom = ""; } setTarget(nullptr); @@ -397,7 +398,11 @@ void LocalPlayer::setGMLevel(int level) mGMLevel = level; if (level > 0) + { setGM(true); + if (chatWindow) + chatWindow->loadGMCommands(); + } } @@ -1433,13 +1438,17 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, case PICKUP_BAD_ITEM: msg = N_("Tried to pick up nonexistent item."); break; - case PICKUP_TOO_HEAVY: msg = N_("Item is too heavy."); + case PICKUP_TOO_HEAVY: + msg = N_("Item is too heavy."); break; - case PICKUP_TOO_FAR: msg = N_("Item is too far away."); + case PICKUP_TOO_FAR: + msg = N_("Item is too far away."); break; - case PICKUP_INV_FULL: msg = N_("Inventory is full."); + case PICKUP_INV_FULL: + msg = N_("Inventory is full."); break; - case PICKUP_STACK_FULL: msg = N_("Stack is too big."); + case PICKUP_STACK_FULL: + msg = N_("Stack is too big."); break; case PICKUP_DROP_STEAL: msg = N_("Item belongs to someone else."); @@ -1862,12 +1871,14 @@ void LocalPlayer::moveToHome() static const unsigned invertDirectionSize = 5; void LocalPlayer::changeMode(unsigned *var, unsigned limit, const char *conf, - std::string (LocalPlayer::*func)(), unsigned def) + std::string (LocalPlayer::*func)(), unsigned def, + bool save) { (*var) ++; if (*var >= limit) *var = def; - config.setValue(conf, *var); + if (save) + config.setValue(conf, *var); if (miniStatusWindow) miniStatusWindow->updateStatus(); const std::string str = (this->*func)(); @@ -1879,7 +1890,7 @@ void LocalPlayer::invertDirection() { mMoveState = 0; changeMode(&mInvertDirection, invertDirectionSize, "invertMoveDirection", - &LocalPlayer::getInvertDirectionString); + &LocalPlayer::getInvertDirectionString, 0, false); } static const char *invertDirectionStrings[] = @@ -4118,7 +4129,7 @@ void LocalPlayer::checkNewName(Being *being) void LocalPlayer::resetYellowBar() { - mInvertDirection = config.resetIntValue("invertMoveDirection"); + mInvertDirection = 0; mCrazyMoveType = config.resetIntValue("crazyMoveType"); mMoveToTargetType = config.resetIntValue("moveToTargetType"); mFollowMode = config.resetIntValue("followMode"); diff --git a/src/localplayer.h b/src/localplayer.h index 5b755e4f6..ed181e3d0 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -523,7 +523,8 @@ class LocalPlayer : public Being, public ActorSpriteListener, const char *getVarItem(const char **arr, unsigned index, unsigned sz); void changeMode(unsigned *var, unsigned limit, const char *conf, - std::string (LocalPlayer::*func)(), unsigned def = 0); + std::string (LocalPlayer::*func)(), unsigned def = 0, + bool save = true); void crazyMove1(); void crazyMove2(); diff --git a/src/logger.cpp b/src/logger.cpp index c2eb1cc46..a2df9a911 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/logger.h b/src/logger.h index 4ce89f759..db618b275 100644 --- a/src/logger.h +++ b/src/logger.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/main.cpp b/src/main.cpp index b49b38300..5025d6d29 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -27,18 +27,21 @@ #include "client.h" #include "logger.h" -#include <libxml/parser.h> - #include <getopt.h> #include <iostream> #include <physfs.h> +#include "utils/stringutils.h" +#include "utils/xml.h" + #ifdef __MINGW32__ #include <windows.h> #endif #include "debug.h" +char *selfName = nullptr; + static void printHelp() { using std::endl; @@ -71,6 +74,8 @@ static void printHelp() " directory") << endl << _(" --screenshot-dir : Directory to store screenshots") << endl << _(" --safemode : Start game in safe mode") << endl + << _(" -T --tests : Start testing drivers and " + "auto configuring") << endl #ifdef USE_OPENGL << _(" --no-opengl : Disable OpenGL for this session") << endl #endif @@ -84,30 +89,32 @@ static void printVersion() static void parseOptions(int argc, char *argv[], Client::Options &options) { - const char *optstring = "hvud:U:P:Dc:p:l:L:C:"; + const char *optstring = "hvud:U:P:Dc:p:l:L:C:s:t:T"; const struct option long_options[] = { - { "config-dir", required_argument, 0, 'C' }, - { "data", required_argument, 0, 'd' }, - { "default", no_argument, 0, 'D' }, - { "password", required_argument, 0, 'P' }, - { "character", required_argument, 0, 'c' }, - { "help", no_argument, 0, 'h' }, - { "localdata-dir", required_argument, 0, 'L' }, - { "update-host", required_argument, 0, 'H' }, - { "port", required_argument, 0, 'p' }, - { "server", required_argument, 0, 's' }, - { "skip-update", no_argument, 0, 'u' }, - { "username", required_argument, 0, 'U' }, - { "no-opengl", no_argument, 0, 'O' }, - { "chat-log-dir", required_argument, 0, 'l' }, - { "version", no_argument, 0, 'v' }, - { "log-file", required_argument, 0, 'l' }, - { "chat-log-dir", required_argument, 0, 'L' }, - { "screenshot-dir", required_argument, 0, 'i' }, - { "safemode", no_argument, 0, 'm' }, - { nullptr, 0, 0, 0 } + { "config-dir", required_argument, nullptr, 'C' }, + { "data", required_argument, nullptr, 'd' }, + { "default", no_argument, nullptr, 'D' }, + { "password", required_argument, nullptr, 'P' }, + { "character", required_argument, nullptr, 'c' }, + { "help", no_argument, nullptr, 'h' }, + { "localdata-dir", required_argument, nullptr, 'L' }, + { "update-host", required_argument, nullptr, 'H' }, + { "port", required_argument, nullptr, 'p' }, + { "server", required_argument, nullptr, 's' }, + { "skip-update", no_argument, nullptr, 'u' }, + { "username", required_argument, nullptr, 'U' }, + { "no-opengl", no_argument, nullptr, 'O' }, + { "chat-log-dir", required_argument, nullptr, 'l' }, + { "version", no_argument, nullptr, 'v' }, + { "log-file", required_argument, nullptr, 'l' }, + { "chat-log-dir", required_argument, nullptr, 'L' }, + { "screenshot-dir", required_argument, nullptr, 'i' }, + { "safemode", no_argument, nullptr, 'm' }, + { "tests", no_argument, nullptr, 'T' }, + { "test", required_argument, nullptr, 't' }, + { nullptr, 0, nullptr, 0 } }; while (optind < argc) @@ -134,7 +141,10 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) options.printHelp = true; break; case 'H': - options.updateHost = optarg; + if (checkPath(optarg)) + options.updateHost = optarg; + else + options.updateHost = ""; break; case 'c': options.character = optarg; @@ -174,6 +184,14 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) case 'm': options.safeMode = true; break; + case 'T': + options.testMode = true; + options.test = ""; + break; + case 't': + options.testMode = true; + options.test = std::string(optarg); + break; default: break; } @@ -191,23 +209,6 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) extern "C" char const *_nl_locale_name_default(void); #endif -static void xmlNullLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...) -{ - // Does nothing, that's the whole point of it -} - -// Initialize libxml2 and check for potential ABI mismatches between -// compiled version and the shared library actually used. -static void initXML() -{ - xmlInitParser(); - LIBXML_TEST_VERSION; - - // Suppress libxml2 error messages - xmlSetGenericErrorFunc(nullptr, xmlNullLogger); -} - - int main(int argc, char *argv[]) { #if defined(__MINGW32__) @@ -216,6 +217,8 @@ int main(int argc, char *argv[]) LoadLibrary("exchndl.dll"); #endif + selfName = argv[0]; + // Parse command line options Client::Options options; parseOptions(argc, argv, options); @@ -241,11 +244,20 @@ int main(int argc, char *argv[]) atexit((void(*)()) PHYSFS_deinit); - initXML(); + XML::initXML(); #ifdef WIN32 SetCurrentDirectory(PHYSFS_getBaseDir()); #endif Client client(options); - return client.exec(); + if (!options.testMode) + { + client.gameInit(); + return client.gameExec(); + } + else + { + client.testsInit(); + return client.testsExec(); + } } diff --git a/src/main.h b/src/main.h index 6f7c0980a..541296d22 100644 --- a/src/main.h +++ b/src/main.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -45,8 +45,8 @@ * different interfaces, which have different implementations for each server. */ -#define SMALL_VERSION "1.1.11.27" -#define CHECK_VERSION "01.01.11.27" +#define SMALL_VERSION "1.2.1.22" +#define CHECK_VERSION "01.02.01.22" #ifdef HAVE_CONFIG_H #include "../config.h" diff --git a/src/map.cpp b/src/map.cpp index e706f120b..211504504 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -1392,6 +1392,9 @@ Path Map::findPath(int startX, int startY, int destX, int destY, // Reset starting tile's G cost to 0 MetaTile *startTile = &mMetaTiles[startX + startY * mWidth]; + if (!startTile) + return path; + startTile->Gcost = 0; // Add the start point to the open list @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -498,6 +498,9 @@ class Map : public Properties, public ConfigListener void redrawMap(); + bool empty() + { return mLayers.empty(); } + protected: friend class Actor; friend class Minimap; diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h index 6899f85f4..f6d8606ce 100644 --- a/src/net/adminhandler.h +++ b/src/net/adminhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/buysellhandler.h b/src/net/buysellhandler.h index c41e918e1..8a49a68cd 100644 --- a/src/net/buysellhandler.h +++ b/src/net/buysellhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/charhandler.cpp b/src/net/charhandler.cpp index f3a02fc3b..016b72cbf 100644 --- a/src/net/charhandler.cpp +++ b/src/net/charhandler.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/charhandler.h b/src/net/charhandler.h index 848354e96..492e27e55 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -44,14 +44,14 @@ struct Character { Character() : slot(0), - dummy(0) + dummy(nullptr) { } ~Character() { delete dummy; - dummy = 0; + dummy = nullptr; } int slot; /**< The index in the list of characters */ @@ -94,9 +94,9 @@ class CharHandler protected: CharHandler() : - mSelectedCharacter(0), - mCharSelectDialog(0), - mCharCreateDialog(0) + mSelectedCharacter(nullptr), + mCharSelectDialog(nullptr), + mCharCreateDialog(nullptr) {} void updateCharSelectDialog(); diff --git a/src/net/chathandler.h b/src/net/chathandler.h index fc6c10376..f8a9e4ccf 100644 --- a/src/net/chathandler.h +++ b/src/net/chathandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/download.cpp b/src/net/download.cpp index 5141c022e..22af389f3 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -180,7 +180,6 @@ int Download::downloadProgress(void *clientp, double dltotal, double dlnow, return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_CANCELLED, static_cast<size_t>(dltotal), static_cast<size_t>(dlnow)); - return -5; } return d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_IDLE, diff --git a/src/net/download.h b/src/net/download.h index 8339dee30..b31350eff 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp index bdd43b3f8..556629458 100644 --- a/src/net/ea/adminhandler.cpp +++ b/src/net/ea/adminhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h index 5d1b7aa14..70c458514 100644 --- a/src/net/ea/adminhandler.h +++ b/src/net/ea/adminhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 1c2983137..84bd03bb1 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h index f47385a61..b4fd5f93f 100644 --- a/src/net/ea/beinghandler.h +++ b/src/net/ea/beinghandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 28584d97f..73d4090b7 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h index 196626b0d..14d39ea02 100644 --- a/src/net/ea/buysellhandler.h +++ b/src/net/ea/buysellhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 63e267584..2dc51acf3 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -163,6 +163,9 @@ void CharServerHandler::processCharCreateFailed(Net::MessageIn &msg) case 5: errorMessage = _("Incorrect slot."); break; + case 6: + errorMessage = _("Incorrect race."); + break; } new OkDialog(_("Error"), errorMessage); if (mCharCreateDialog) diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index bacde67b6..bec8d2011 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 35e8597f0..e31f68596 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index d39e6788a..baa9a01b5 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/eaprotocol.h b/src/net/ea/eaprotocol.h index d34cba0ca..62b61a956 100644 --- a/src/net/ea/eaprotocol.h +++ b/src/net/ea/eaprotocol.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index b74f2384d..b7566e271 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -52,9 +52,14 @@ void GameHandler::processEvent(Mana::Channels channel, if (channel == Mana::CHANNEL_GAME) { if (event.getName() == Mana::EVENT_ENGINESINITALIZED) - Game::instance()->changeMap(mMap); + { + if (mMap != "") + Game::instance()->changeMap(mMap); + } else if (event.getName() == Mana::EVENT_MAPLOADED) + { mapLoadedEvent(); + } } } @@ -73,7 +78,7 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) Uint16 x, y; msg.readInt32(); // server tick msg.readCoordinates(x, y, direction); - msg.skip(2); // unknown + msg.skip(2); // 0x0505 logger->log("Protocol: Player start position: (%d, %d)," " Direction: %d", x, y, direction); // Switch now or we'll have problems diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h index 511efe357..248175617 100644 --- a/src/net/ea/gamehandler.h +++ b/src/net/ea/gamehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 9836f5fa9..87fc34d94 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index 2aad4a564..81d971161 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 23eab361c..cf62af459 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index 3a544d8db..029d71ac7 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 907fa13db..96a361838 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -168,7 +168,7 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg) int avgLevel = msg.readInt32(); // Average level int exp = msg.readInt32(); // Exp int nextExp = msg.readInt32(); // Next exp - msg.skip(16); // unused + msg.skip(16); // 0 unused std::string name = msg.readString(24); // Name std::string master = msg.readString(24); // Master's name std::string castle = msg.readString(20); // Castles @@ -242,7 +242,7 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg) int exp = msg.readInt32(); // Exp int online = msg.readInt32(); // Online int pos = msg.readInt32(); // Position - msg.skip(50); // unused + msg.skip(50); // 0 unused std::string name = msg.readString(24); // Name GuildMember *m = taGuild->addMember(id, charId, name); @@ -371,11 +371,11 @@ void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg) { msg.readInt16(); // ID msg.readInt16(); // 'Info' (unknown atm) - msg.readInt16(); // unused + msg.readInt16(); // 0 unused msg.readInt16(); // Level msg.readInt16(); // SP msg.readInt16(); // 'Range' - msg.skip(24); // unused + msg.skip(24); // 0 unused msg.readInt8(); // Can be increased } } @@ -479,9 +479,10 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) { + msg.skip(2); // size (can be many explusions in list) std::string nick = msg.readString(24); // Name (of expulsed?) - msg.readString(40); // Message - msg.skip(24); // unused ("dummy") + msg.skip(24); // acc + msg.readString(44); // Message if (taGuild) taGuild->removeMember(nick); @@ -495,7 +496,7 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) taGuild->removeFromMembers(); taGuild->clearMembers(); } - SERVER_NOTICE(_("You was kicked from guild.")); + SERVER_NOTICE(_("You were kicked from guild.")); delete guildTab; guildTab = nullptr; diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h index 5b090ec41..5b7442a40 100644 --- a/src/net/ea/guildhandler.h +++ b/src/net/ea/guildhandler.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index d2a1fb4f0..4c4fb760c 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 6db6b18ed..c2e076751 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp index 38d6f7be9..e08fe2cd1 100644 --- a/src/net/ea/itemhandler.cpp +++ b/src/net/ea/itemhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h index dabf61b5d..1d0747c61 100644 --- a/src/net/ea/itemhandler.h +++ b/src/net/ea/itemhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index b11e60d4d..291a92906 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -150,6 +150,11 @@ void LoginHandler::processUpdateHost(Net::MessageIn &msg) len = msg.readInt16() - 4; mUpdateHost = msg.readString(len); + if (!checkPath(mUpdateHost)) + { + mUpdateHost = ""; + logger->log1("Warning: incorrect update server name"); + } loginData.updateHost = mUpdateHost; logger->log("Received update host \"%s\" from login server.", @@ -159,7 +164,7 @@ void LoginHandler::processUpdateHost(Net::MessageIn &msg) void LoginHandler::processLoginData(Net::MessageIn &msg) { // Skip the length word - msg.skip(2); + msg.skip(2); // size clearWorlds(); @@ -168,7 +173,11 @@ void LoginHandler::processLoginData(Net::MessageIn &msg) mToken.session_ID1 = msg.readInt32(); mToken.account_ID = msg.readInt32(); mToken.session_ID2 = msg.readInt32(); - msg.skip(30); // unknown + msg.skip(4); // old ip + loginData.lastLogin = msg.readString(24); + msg.skip(2); // 0 unused bytes + +// msg.skip(30); // unknown // reserve bits for future usage mToken.sex = (msg.readInt8() & 1) ? GENDER_MALE : GENDER_FEMALE; @@ -179,10 +188,11 @@ void LoginHandler::processLoginData(Net::MessageIn &msg) world->address = msg.readInt32(); world->port = msg.readInt16(); world->name = msg.readString(20); - world->online_users = msg.readInt32(); + world->online_users = msg.readInt16(); config.setValue("updatehost", mUpdateHost); world->updateHost = mUpdateHost; - msg.skip(2); // unknown + msg.skip(2); // maintenance + msg.skip(2); // new logger->log("Network: Server: %s (%s:%d)", world->name.c_str(), ipToString(world->address), world->port); diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index 62ace31c8..555de6385 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index e8e1014d4..18b0ca39a 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index 3e68c2321..be0465375 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 8373cb1c4..556e72c8d 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -320,7 +320,7 @@ void PartyHandler::processPartyMove(Net::MessageIn &msg) m = Ea::taParty->getMember(id); if (m) { - msg.skip(4); + msg.skip(4); // 0 m->setX(msg.readInt16()); // x m->setY(msg.readInt16()); // y m->setOnline(msg.readInt8()); // online (if 0) @@ -330,7 +330,7 @@ void PartyHandler::processPartyMove(Net::MessageIn &msg) } else { - msg.skip(4); + msg.skip(4); // 0 msg.readInt16(); // x msg.readInt16(); // y msg.readInt8(); // online (if 0) diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 02af3dbb4..6a841415f 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index ceb4aba0b..d0402ecfc 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp index fe56db52a..7b2ef601a 100644 --- a/src/net/ea/specialhandler.cpp +++ b/src/net/ea/specialhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -87,11 +87,11 @@ void SpecialHandler::processPlayerSkills(Net::MessageIn &msg) { int skillId = msg.readInt16(); msg.readInt16(); // target type - msg.skip(2); // unused + msg.skip(2); // skill pool flags int level = msg.readInt16(); msg.readInt16(); // sp msg.readInt16(); // range - msg.skip(24); // unused + msg.skip(24); // 0 unused int up = msg.readInt8(); PlayerInfo::setStatBase(skillId, level); diff --git a/src/net/ea/specialhandler.h b/src/net/ea/specialhandler.h index 47b412f3e..c2b05399e 100644 --- a/src/net/ea/specialhandler.h +++ b/src/net/ea/specialhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/token.h b/src/net/ea/token.h index 40a7058ff..86871647f 100644 --- a/src/net/ea/token.h +++ b/src/net/ea/token.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 5aaa09f91..0ba3925a8 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h index 6d623f60d..07e9cc23b 100644 --- a/src/net/ea/tradehandler.h +++ b/src/net/ea/tradehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/gamehandler.h b/src/net/gamehandler.h index 14203fb20..fd051234f 100644 --- a/src/net/gamehandler.h +++ b/src/net/gamehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/generalhandler.h b/src/net/generalhandler.h index 1a15e6929..9864ba654 100644 --- a/src/net/generalhandler.h +++ b/src/net/generalhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/guildhandler.h b/src/net/guildhandler.h index 4070abad5..b8af633de 100644 --- a/src/net/guildhandler.h +++ b/src/net/guildhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h index 360f141fa..ec2f3db47 100644 --- a/src/net/inventoryhandler.h +++ b/src/net/inventoryhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/logindata.h b/src/net/logindata.h index 647a04abf..e5d3fc97a 100644 --- a/src/net/logindata.h +++ b/src/net/logindata.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -59,6 +59,7 @@ class LoginData std::string password; std::string newPassword; std::string updateHost; + std::string lastLogin; int updateType; std::string email; @@ -82,6 +83,7 @@ class LoginData email.clear(); captchaResponse.clear(); gender = GENDER_UNSPECIFIED; + lastLogin.clear(); resetCharacterSlots(); } /** diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 5607ca1e2..1366e30dd 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp index a7bcf6355..609c9e4f1 100644 --- a/src/net/manaserv/adminhandler.cpp +++ b/src/net/manaserv/adminhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h index 5a71db35e..a4157b3b0 100644 --- a/src/net/manaserv/adminhandler.h +++ b/src/net/manaserv/adminhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/attributes.cpp b/src/net/manaserv/attributes.cpp index 25c75f9d8..662032e29 100644 --- a/src/net/manaserv/attributes.cpp +++ b/src/net/manaserv/attributes.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -238,9 +238,9 @@ namespace Attributes logger->log("Initializing attributes database..."); XML::Document doc(DEFAULT_ATTRIBUTESDB_FILE); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "attributes")) + if (!rootNode || !xmlNameEqual(rootNode, "attributes")) { logger->log("Attributes: Error while loading " DEFAULT_ATTRIBUTESDB_FILE ". Using Built-ins."); @@ -251,7 +251,7 @@ namespace Attributes for_each_xml_child_node(node, rootNode) { - if (xmlStrEqual(node->name, BAD_CAST "attribute")) + if (xmlNameEqual(node, "attribute")) { int id = XML::getProperty(node, "id", 0); @@ -290,7 +290,7 @@ namespace Attributes unsigned int count = 0; for_each_xml_child_node(effectNode, node) { - if (!xmlStrEqual(effectNode->name, BAD_CAST "modifier")) + if (!xmlNameEqual(effectNode, "modifier")) continue; ++count; std::string tag = XML::getProperty(effectNode, "tag", ""); @@ -334,7 +334,7 @@ namespace Attributes logger->log("Found %d tags for attribute %d.", count, id); }// End attribute - else if (xmlStrEqual(node->name, BAD_CAST "points")) + else if (xmlNameEqual(node, "points")) { creationPoints = XML::getProperty( node, "start", DEFAULT_POINTS); diff --git a/src/net/manaserv/attributes.h b/src/net/manaserv/attributes.h index 35eeaef88..ba5931b8c 100644 --- a/src/net/manaserv/attributes.h +++ b/src/net/manaserv/attributes.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index d14cdcadf..cef4f497a 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h index 59797f8f5..70d61545c 100644 --- a/src/net/manaserv/beinghandler.h +++ b/src/net/manaserv/beinghandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp index 7cc0e70f2..25db86cf0 100644 --- a/src/net/manaserv/buysellhandler.cpp +++ b/src/net/manaserv/buysellhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/buysellhandler.h b/src/net/manaserv/buysellhandler.h index e1a9c91e5..3c983ac08 100644 --- a/src/net/manaserv/buysellhandler.h +++ b/src/net/manaserv/buysellhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 42db6e621..300af5a2b 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h index ea44ae23e..134b8447b 100644 --- a/src/net/manaserv/charhandler.h +++ b/src/net/manaserv/charhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp index 1757b565d..f0a23127c 100644 --- a/src/net/manaserv/chathandler.cpp +++ b/src/net/manaserv/chathandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h index e93c2dd87..029d5fe83 100644 --- a/src/net/manaserv/chathandler.h +++ b/src/net/manaserv/chathandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp index 33d6f28cf..2467eb198 100644 --- a/src/net/manaserv/connection.cpp +++ b/src/net/manaserv/connection.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/connection.h b/src/net/manaserv/connection.h index 933822a85..4263ae21f 100644 --- a/src/net/manaserv/connection.h +++ b/src/net/manaserv/connection.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/defines.h b/src/net/manaserv/defines.h index e2fe27839..aaf29bff2 100644 --- a/src/net/manaserv/defines.h +++ b/src/net/manaserv/defines.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp index 92cf66302..59fb1e4f5 100644 --- a/src/net/manaserv/effecthandler.cpp +++ b/src/net/manaserv/effecthandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h index 774411041..ceb48fd22 100644 --- a/src/net/manaserv/effecthandler.h +++ b/src/net/manaserv/effecthandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/gamehandler.cpp b/src/net/manaserv/gamehandler.cpp index 21bd526d8..4a03dff0f 100644 --- a/src/net/manaserv/gamehandler.cpp +++ b/src/net/manaserv/gamehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h index 323b2566a..443533bba 100644 --- a/src/net/manaserv/gamehandler.h +++ b/src/net/manaserv/gamehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 2eea6cdf6..584faa368 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h index c6614707f..fcb28c846 100644 --- a/src/net/manaserv/generalhandler.h +++ b/src/net/manaserv/generalhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp index 306a15be4..dfd2ed3cf 100644 --- a/src/net/manaserv/guildhandler.cpp +++ b/src/net/manaserv/guildhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h index 6a8db27c8..893a7157b 100644 --- a/src/net/manaserv/guildhandler.h +++ b/src/net/manaserv/guildhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/internal.cpp b/src/net/manaserv/internal.cpp index 6d2c99712..37148b101 100644 --- a/src/net/manaserv/internal.cpp +++ b/src/net/manaserv/internal.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/internal.h b/src/net/manaserv/internal.h index 14a728727..9c0529a79 100644 --- a/src/net/manaserv/internal.h +++ b/src/net/manaserv/internal.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp index ce837b5e1..47f149eca 100644 --- a/src/net/manaserv/inventoryhandler.cpp +++ b/src/net/manaserv/inventoryhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h index ba4535d79..8471b1caf 100644 --- a/src/net/manaserv/inventoryhandler.h +++ b/src/net/manaserv/inventoryhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp index 89826a33f..021d57cf3 100644 --- a/src/net/manaserv/itemhandler.cpp +++ b/src/net/manaserv/itemhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/itemhandler.h b/src/net/manaserv/itemhandler.h index 0fdd8c333..cfdc30083 100644 --- a/src/net/manaserv/itemhandler.h +++ b/src/net/manaserv/itemhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index bf823562f..8b8ac831f 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -341,9 +341,18 @@ void LoginHandler::readServerInfo(Net::MessageIn &msg) // Set the update host when included in the message const std::string updateHost = msg.readString(); if (!updateHost.empty()) + { + if (!checkPath(updateHost)) + { + logger->log1("Warning: incorrect update server name"); + updateHost = ""; + } mLoginData->updateHost = updateHost; + } else + { logger->log1("Warning: server does not have an update host set!"); + } // Read the client data folder for dynamic data loading. // This is only used by the QT client. diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h index 0e8f2a4e6..72c43aec0 100644 --- a/src/net/manaserv/loginhandler.h +++ b/src/net/manaserv/loginhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/messagehandler.cpp b/src/net/manaserv/messagehandler.cpp index 2e9603f19..769f2a3b6 100644 --- a/src/net/manaserv/messagehandler.cpp +++ b/src/net/manaserv/messagehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/messagehandler.h b/src/net/manaserv/messagehandler.h index c1011cef7..c09d59439 100644 --- a/src/net/manaserv/messagehandler.h +++ b/src/net/manaserv/messagehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/messagein.cpp b/src/net/manaserv/messagein.cpp index 92bfa7d2c..bc97155a9 100644 --- a/src/net/manaserv/messagein.cpp +++ b/src/net/manaserv/messagein.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/messagein.h b/src/net/manaserv/messagein.h index 6b0464a44..f22cdabca 100644 --- a/src/net/manaserv/messagein.h +++ b/src/net/manaserv/messagein.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/messageout.cpp b/src/net/manaserv/messageout.cpp index c80ba6593..0bb1c0f77 100644 --- a/src/net/manaserv/messageout.cpp +++ b/src/net/manaserv/messageout.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/messageout.h b/src/net/manaserv/messageout.h index 772b108f3..dc583ab3d 100644 --- a/src/net/manaserv/messageout.h +++ b/src/net/manaserv/messageout.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index 44478fb4c..84e71eaf3 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/network.h b/src/net/manaserv/network.h index 63ba7b11a..506d44b4f 100644 --- a/src/net/manaserv/network.h +++ b/src/net/manaserv/network.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp index 8ff2c5d21..24a58ebd8 100644 --- a/src/net/manaserv/npchandler.cpp +++ b/src/net/manaserv/npchandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h index f91858614..d71cd4d18 100644 --- a/src/net/manaserv/npchandler.h +++ b/src/net/manaserv/npchandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp index 660657f44..60dcaaaff 100644 --- a/src/net/manaserv/partyhandler.cpp +++ b/src/net/manaserv/partyhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h index 087936d72..5497d5e34 100644 --- a/src/net/manaserv/partyhandler.h +++ b/src/net/manaserv/partyhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index da8958044..5ebf840bc 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -443,4 +443,9 @@ Vector PlayerHandler::getDefaultWalkSpeed() const return ManaServ::BeingHandler::giveSpeedInPixelsPerTicks(6.0f); } +void PlayerHandler::requestOnlineList() +{ + +} + } // namespace ManaServ diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index 21bbac516..0255406a8 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -70,6 +70,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler int getJobLocation() const; int getAttackLocation() const; + void requestOnlineList(); + Vector getDefaultWalkSpeed() const; private: diff --git a/src/net/manaserv/protocol.h b/src/net/manaserv/protocol.h index 7f5e03871..58103ffb1 100644 --- a/src/net/manaserv/protocol.h +++ b/src/net/manaserv/protocol.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/specialhandler.cpp b/src/net/manaserv/specialhandler.cpp index 85fe7271f..13c6f7613 100644 --- a/src/net/manaserv/specialhandler.cpp +++ b/src/net/manaserv/specialhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h index ccbe59fd9..f6a20e4ac 100644 --- a/src/net/manaserv/specialhandler.h +++ b/src/net/manaserv/specialhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp index 383da9fe6..e827c2cec 100644 --- a/src/net/manaserv/tradehandler.cpp +++ b/src/net/manaserv/tradehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h index 2ca542f78..39d691982 100644 --- a/src/net/manaserv/tradehandler.h +++ b/src/net/manaserv/tradehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/messagehandler.h b/src/net/messagehandler.h index 64483c8cd..9867ffd65 100644 --- a/src/net/messagehandler.h +++ b/src/net/messagehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 0fbf7162b..4fb61dc6a 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -241,4 +241,29 @@ std::string MessageIn::readRawString(int length) return str; } +char *MessageIn::readBytes(int length) +{ + // Get string length + if (length < 0) + length = readInt16(); + + // Make sure the string isn't erroneous + if (length < 0 || mPos + length > mLength) + { + mPos = mLength + 1; + DEBUGLOG("readBytesString error"); + return nullptr; + } + + char *buf = new char[length + 2]; + + memcpy (buf, mData + mPos, length); + buf[length] = 0; + buf[length + 1] = 0; + mPos += length; + + PacketCounters::incInBytes(length); + return buf; +} + } diff --git a/src/net/messagein.h b/src/net/messagein.h index 6d7038d4a..8dd43a1a0 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -95,6 +95,8 @@ class MessageIn virtual std::string readRawString(int length); + char *readBytes(int length); + virtual ~MessageIn() { } diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index b1e0c2295..9ec45c7cc 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/messageout.h b/src/net/messageout.h index a169bfe2d..6ac6f81e2 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/net.cpp b/src/net/net.cpp index 933f7686b..713b6aa7e 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/net.h b/src/net/net.h index a6adef44e..ce320591f 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/npchandler.h b/src/net/npchandler.h index 40b97deef..2e32e5986 100644 --- a/src/net/npchandler.h +++ b/src/net/npchandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/packetcounters.cpp b/src/net/packetcounters.cpp index 8cd2e4627..dc504768e 100644 --- a/src/net/packetcounters.cpp +++ b/src/net/packetcounters.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/packetcounters.h b/src/net/packetcounters.h index 35d5d64bc..936217c95 100644 --- a/src/net/packetcounters.h +++ b/src/net/packetcounters.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h index 14f06060d..dd92f78d1 100644 --- a/src/net/partyhandler.h +++ b/src/net/partyhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index 47d666036..f62acc0c9 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -71,6 +71,8 @@ class PlayerHandler virtual int getAttackLocation() const = 0; virtual Vector getDefaultWalkSpeed() const = 0; + + virtual void requestOnlineList() = 0; }; } // namespace Net diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index eb07f766e..fb6a99a33 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/specialhandler.h b/src/net/specialhandler.h index 64b11fdda..7ed3673cf 100644 --- a/src/net/specialhandler.h +++ b/src/net/specialhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index 5d5034938..65f4d6f2c 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index d81e2421a..4063a7fba 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 02267e20e..627db1402 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index 5e741aaa8..a45e33d36 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 552aa1d51..629aa54f6 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -69,7 +69,7 @@ BuySellHandler::BuySellHandler() }; handledMessages = _messages; buySellHandler = this; - mBuyDialog = 0; + mBuyDialog = nullptr; } void BuySellHandler::handleMessage(Net::MessageIn &msg) diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h index 65067f7e0..e4d07511f 100644 --- a/src/net/tmwa/buysellhandler.h +++ b/src/net/tmwa/buysellhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 69f7165ec..717df1284 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -190,7 +190,7 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, msg.readInt32(); // option msg.readInt32(); // karma msg.readInt32(); // manner - msg.skip(2); // unknown + msg.readInt16(); // character points left character->data.mAttributes[HP] = msg.readInt16(); character->data.mAttributes[MAX_HP] = msg.readInt16(); @@ -347,7 +347,7 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg) loginData.characterSlots = static_cast<short unsigned int>(slots); bool version = msg.readInt8() == 1 && serverVersion > 0; - msg.skip(17); // Unused + msg.skip(17); // 0 Unused delete_all(mCharacters); mCharacters.clear(); diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index f1256e409..915c6dba5 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 5af248e5c..368421285 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index 9a88b7478..8652d297d 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index adaaa067b..5acf9ae6c 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h index ddb381058..d48fabdcc 100644 --- a/src/net/tmwa/gamehandler.h +++ b/src/net/tmwa/gamehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 293986bde..a666fa5f4 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -201,9 +201,9 @@ void GeneralHandler::reload() static_cast<LoginHandler*>(mLoginHandler.get())->clearWorlds(); static_cast<CharServerHandler*>( - mCharHandler.get())->setCharCreateDialog(0); + mCharHandler.get())->setCharCreateDialog(nullptr); static_cast<CharServerHandler*>( - mCharHandler.get())->setCharSelectDialog(0); + mCharHandler.get())->setCharSelectDialog(nullptr); static_cast<PartyHandler*>(mPartyHandler.get())->reload(); } @@ -259,6 +259,9 @@ void GeneralHandler::processEvent(Mana::Channels channel, if (!statusWindow) return; + // protection against double addition attributes. + statusWindow->clearAttributes(); + statusWindow->addAttribute(STR, _("Strength"), true, ""); statusWindow->addAttribute(AGI, _("Agility"), true, ""); statusWindow->addAttribute(VIT, _("Vitality"), true, ""); diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index e0f29fd1d..b250ddfd4 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/gui/guildtab.cpp b/src/net/tmwa/gui/guildtab.cpp index 05a93bff8..af90f5c6b 100644 --- a/src/net/tmwa/gui/guildtab.cpp +++ b/src/net/tmwa/gui/guildtab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/gui/guildtab.h b/src/net/tmwa/gui/guildtab.h index 21c56c4ed..351dadfd6 100644 --- a/src/net/tmwa/gui/guildtab.h +++ b/src/net/tmwa/gui/guildtab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/gui/partytab.cpp b/src/net/tmwa/gui/partytab.cpp index 373fcca31..d0738e79c 100644 --- a/src/net/tmwa/gui/partytab.cpp +++ b/src/net/tmwa/gui/partytab.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/gui/partytab.h b/src/net/tmwa/gui/partytab.h index d865995f7..0bdc11372 100644 --- a/src/net/tmwa/gui/partytab.h +++ b/src/net/tmwa/gui/partytab.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 7ea97eb49..5e2ac528f 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h index d8d291bdd..e1d2d7c29 100644 --- a/src/net/tmwa/guildhandler.h +++ b/src/net/tmwa/guildhandler.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 14a15e59f..7fa26f5ed 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index d924e8713..d2ecc4b6d 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp index ee33cd230..ce03044c7 100644 --- a/src/net/tmwa/itemhandler.cpp +++ b/src/net/tmwa/itemhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h index 3e948547e..0f2459fbf 100644 --- a/src/net/tmwa/itemhandler.h +++ b/src/net/tmwa/itemhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index bdc944d63..3b53bbf7c 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -154,7 +154,7 @@ void LoginHandler::processServerVersion(Net::MessageIn &msg) { unsigned int options = msg.readInt8(); mRegistrationEnabled = options; - msg.skip(2); + msg.skip(2); // 0 unused serverVersion = msg.readInt8(); } else diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h index c13c882a7..e2b8beec7 100644 --- a/src/net/tmwa/loginhandler.h +++ b/src/net/tmwa/loginhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/messagehandler.cpp b/src/net/tmwa/messagehandler.cpp index 830b3bc4f..d4b3c03a4 100644 --- a/src/net/tmwa/messagehandler.cpp +++ b/src/net/tmwa/messagehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h index fef9e2004..7607e5c80 100644 --- a/src/net/tmwa/messagehandler.h +++ b/src/net/tmwa/messagehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp index 5a9d39211..b8bba342f 100644 --- a/src/net/tmwa/messagein.cpp +++ b/src/net/tmwa/messagein.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h index bf8debf54..29b17d8ba 100644 --- a/src/net/tmwa/messagein.h +++ b/src/net/tmwa/messagein.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index d5d9d82f9..790611381 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h index d97851d4a..5d1e911b6 100644 --- a/src/net/tmwa/messageout.h +++ b/src/net/tmwa/messageout.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 3181ec898..addc737ee 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -83,7 +83,7 @@ short packet_lengths[] = -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10, // #0x0200 26, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 19, 10, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 757358c25..17a4f7370 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 6b6ffcbb6..574f34d55 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h index 548346205..967829ddc 100644 --- a/src/net/tmwa/npchandler.h +++ b/src/net/tmwa/npchandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index c34c661e8..d5f0641eb 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -30,6 +30,8 @@ #include "net/tmwa/npchandler.h" #include "net/tmwa/inventoryhandler.h" +#include "gui/whoisonline.h" + #include "debug.h" extern Net::PlayerHandler *playerHandler; @@ -50,6 +52,7 @@ PlayerHandler::PlayerHandler() SMSG_PLAYER_STAT_UPDATE_5, SMSG_PLAYER_STAT_UPDATE_6, SMSG_PLAYER_ARROW_MESSAGE, + SMSG_ONLINE_LIST, 0 }; handledMessages = _messages; @@ -97,6 +100,9 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) processPlayerArrowMessage(msg); break; + case SMSG_ONLINE_LIST: + processOnlineList(msg); + default: break; } @@ -201,4 +207,40 @@ void PlayerHandler::respawn() outMsg.writeInt8(0); } +void PlayerHandler::requestOnlineList() +{ + MessageOut outMsg(CMSG_ONLINE_LIST); +} + +void PlayerHandler::processOnlineList(Net::MessageIn &msg) +{ + if (!whoIsOnline) + return; + + int size = msg.readInt16() - 4; + std::vector<std::string> arr; + + if (!size) + { + if (whoIsOnline) + whoIsOnline->loadList(arr); + return; + } + + const char *start = msg.readBytes(size); + const char *buf = start; + + while (buf - start + 1 < size && *(buf + 1)) + { +// char status = *buf; // now unused + buf ++; + arr.push_back(buf); + buf += strlen(buf) + 1; + } + + if (whoIsOnline) + whoIsOnline->loadList(arr); + delete [] start; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index bf8e861ff..0fa524d51 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -51,6 +51,8 @@ class PlayerHandler : public MessageHandler, public Ea::PlayerHandler void setDirection(char direction); void setDestination(int x, int y, int direction = -1); void changeAction(Being::Action action); + void processOnlineList(Net::MessageIn &msg); + void requestOnlineList(); void respawn(); }; diff --git a/src/net/tmwa/protocol.h b/src/net/tmwa/protocol.h index caf3c8e53..0f124cc20 100644 --- a/src/net/tmwa/protocol.h +++ b/src/net/tmwa/protocol.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -333,5 +333,7 @@ enum #define SMSG_PVP_SET 0x019a #define CMSG_IGNORE_ALL 0x00d0 #define SMSG_IGNORE_ALL_RESPONSE 0x00d2 +#define CMSG_ONLINE_LIST 0x0210 +#define SMSG_ONLINE_LIST 0x0211 #endif diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp index c75d954dc..9fa7b6dfa 100644 --- a/src/net/tmwa/specialhandler.cpp +++ b/src/net/tmwa/specialhandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h index 50bf31c0b..f17ef4c44 100644 --- a/src/net/tmwa/specialhandler.h +++ b/src/net/tmwa/specialhandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index 2280079ea..1a44e4956 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h index 3a4c8c1fc..b5a06ef6a 100644 --- a/src/net/tmwa/tradehandler.h +++ b/src/net/tmwa/tradehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h index 57219e675..06a431ec6 100644 --- a/src/net/tradehandler.h +++ b/src/net/tradehandler.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h index b02e9fa21..26733a0da 100644 --- a/src/net/worldinfo.h +++ b/src/net/worldinfo.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index 1f1a0231d..6f712f698 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -377,6 +377,9 @@ void OpenGL1Graphics::drawRescaledImagePattern(Image *image, int x, int y, // Draw a set of textured rectangles glBegin(GL_QUADS); + const float scaleFactorW = (float) scaledWidth / image->getWidth(); + const float scaleFactorH = (float) scaledHeight / image->getHeight(); + for (int py = 0; py < h; py += ih) { const int height = (py + ih >= h) ? h - py : ih; @@ -387,7 +390,8 @@ void OpenGL1Graphics::drawRescaledImagePattern(Image *image, int x, int y, int dstX = x + px; drawRescaledQuad(image, srcX, srcY, dstX, dstY, - width, height, scaledWidth, scaledHeight); + width / scaleFactorW, height / scaleFactorH, + scaledWidth, scaledHeight); } } @@ -474,6 +478,7 @@ SDL_Surface* OpenGL1Graphics::getScreenshot() { int h = mTarget->h; int w = mTarget->w; + GLint pack = 1; SDL_Surface *screenshot = SDL_CreateRGBSurface( SDL_SWSURFACE, @@ -484,6 +489,7 @@ SDL_Surface* OpenGL1Graphics::getScreenshot() SDL_LockSurface(screenshot); // Grap the pixel buffer and write it to the SDL surface + glGetIntegerv(GL_PACK_ALIGNMENT, &pack); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels); @@ -505,6 +511,8 @@ SDL_Surface* OpenGL1Graphics::getScreenshot() free(buf); + glPixelStorei(GL_PACK_ALIGNMENT, pack); + if (SDL_MUSTLOCK(screenshot)) SDL_UnlockSurface(screenshot); diff --git a/src/opengl1graphics.h b/src/opengl1graphics.h index 11df607f8..87458d8b9 100644 --- a/src/opengl1graphics.h +++ b/src/opengl1graphics.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index f5e9f8107..b744a3caf 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -588,22 +588,25 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, const int height = (py + scaledHeight >= h) ? h - py : scaledHeight; const int dstY = y + py; + const int scaledY = srcY + height / scaleFactorH; for (int px = 0; px < w; px += scaledWidth) { - int width = (px + scaledWidth >= w) ? w - px : scaledWidth; - int dstX = x + px; + const int width = (px + scaledWidth >= w) + ? w - px : scaledWidth; + const int dstX = x + px; + const int scaledX = srcX + width / scaleFactorW; mIntTexArray[vp + 0] = srcX; mIntTexArray[vp + 1] = srcY; - mIntTexArray[vp + 2] = srcX + width / scaleFactorW; + mIntTexArray[vp + 2] = scaledX; mIntTexArray[vp + 3] = srcY; - mIntTexArray[vp + 4] = srcX + width / scaleFactorW; - mIntTexArray[vp + 5] = srcY + height / scaleFactorH; + mIntTexArray[vp + 4] = scaledX; + mIntTexArray[vp + 5] = scaledY; mIntTexArray[vp + 6] = srcX; - mIntTexArray[vp + 7] = srcY + height / scaleFactorH; + mIntTexArray[vp + 7] = scaledY; mIntVertArray[vp + 0] = dstX; mIntVertArray[vp + 1] = dstY; @@ -1020,6 +1023,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot() { int h = mTarget->h; int w = mTarget->w; + GLint pack = 1; SDL_Surface *screenshot = SDL_CreateRGBSurface( SDL_SWSURFACE, @@ -1033,6 +1037,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot() SDL_LockSurface(screenshot); // Grap the pixel buffer and write it to the SDL surface + glGetIntegerv(GL_PACK_ALIGNMENT, &pack); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, screenshot->pixels); @@ -1054,6 +1059,8 @@ SDL_Surface* OpenGLGraphics::getScreenshot() free(buf); + glPixelStorei(GL_PACK_ALIGNMENT, pack); + if (SDL_MUSTLOCK(screenshot)) SDL_UnlockSurface(screenshot); diff --git a/src/openglgraphics.h b/src/openglgraphics.h index d12810203..1047223ad 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/particle.cpp b/src/particle.cpp index e71791ce8..a0acb4f73 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -291,9 +291,9 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, dyePalettes = particleEffectFile.substr(pos + 1); XML::Document doc(particleEffectFile.substr(0, pos)); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "effect")) + if (!rootNode || !xmlNameEqual(rootNode, "effect")) { logger->log("Error loading particle: %s", particleEffectFile.c_str()); return nullptr; @@ -305,11 +305,11 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, for_each_xml_child_node(effectChildNode, rootNode) { // We're only interested in particles - if (!xmlStrEqual(effectChildNode->name, BAD_CAST "particle")) + if (!xmlNameEqual(effectChildNode, "particle")) continue; // Determine the exact particle type - xmlNodePtr node; + XmlNodePtr node; // Animation if ((node = XML::findFirstChildByName(effectChildNode, "animation"))) @@ -361,14 +361,14 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, // Look for additional emitters for this particle for_each_xml_child_node(emitterNode, effectChildNode) { - if (xmlStrEqual(emitterNode->name, BAD_CAST "emitter")) + if (xmlNameEqual(emitterNode, "emitter")) { ParticleEmitter *newEmitter; newEmitter = new ParticleEmitter(emitterNode, newParticle, mMap, rotation, dyePalettes); newParticle->addEmitter(newEmitter); } - else if (xmlStrEqual(emitterNode->name, BAD_CAST "deatheffect")) + else if (xmlNameEqual(emitterNode, "deatheffect")) { std::string deathEffect = reinterpret_cast<const char*>( emitterNode->xmlChildrenNode->content); diff --git a/src/particle.h b/src/particle.h index ad448a054..a79181498 100644 --- a/src/particle.h +++ b/src/particle.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 40ab68865..e39f4dd86 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/particlecontainer.h b/src/particlecontainer.h index 2219bd67c..a8af163fd 100644 --- a/src/particlecontainer.h +++ b/src/particlecontainer.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index 1add452a0..c6c819e92 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -39,11 +39,11 @@ #define SIN45 0.707106781f #define DEG_RAD_FACTOR 0.017453293f -ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, +ParticleEmitter::ParticleEmitter(XmlNodePtr emitterNode, Particle *target, Map *map, int rotation, const std::string& dyePalettes): mOutputPauseLeft(0), - mParticleImage(0) + mParticleImage(nullptr) { mMap = map; mParticleTarget = target; @@ -71,7 +71,7 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, for_each_xml_child_node(propertyNode, emitterNode) { - if (xmlStrEqual(propertyNode->name, BAD_CAST "property")) + if (xmlNameEqual(propertyNode, "property")) { std::string name = XML::getProperty(propertyNode, "name", ""); @@ -197,13 +197,13 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, name.c_str()); } } - else if (xmlStrEqual(propertyNode->name, BAD_CAST "emitter")) + else if (xmlNameEqual(propertyNode, "emitter")) { ParticleEmitter newEmitter(propertyNode, mParticleTarget, map, rotation, dyePalettes); mParticleChildEmitters.push_back(newEmitter); } - else if (xmlStrEqual(propertyNode->name, BAD_CAST "rotation")) + else if (xmlNameEqual(propertyNode, "rotation")) { ImageSet *imageset = ResourceManager::getInstance()->getImageSet( XML::getProperty(propertyNode, "imageset", ""), @@ -229,7 +229,7 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, offsetY -= imageset->getHeight() - 32; offsetX -= imageset->getWidth() / 2 - 16; - if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) + if (xmlNameEqual(frameNode, "frame")) { int index = XML::getProperty(frameNode, "index", -1); @@ -250,7 +250,7 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, mParticleRotation.addFrame(img, delay, offsetX, offsetY, rand); } - else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence")) + else if (xmlNameEqual(frameNode, "sequence")) { int start = XML::getProperty(frameNode, "start", -1); int end = XML::getProperty(frameNode, "end", -1); @@ -276,13 +276,13 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, start++; } } - else if (xmlStrEqual(frameNode->name, BAD_CAST "end")) + else if (xmlNameEqual(frameNode, "end")) { mParticleRotation.addTerminator(rand); } } // for frameNode } - else if (xmlStrEqual(propertyNode->name, BAD_CAST "animation")) + else if (xmlNameEqual(propertyNode, "animation")) { ImageSet *imageset = ResourceManager::getInstance()->getImageSet( XML::getProperty(propertyNode, "imageset", ""), @@ -307,7 +307,7 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, offsetY -= imageset->getHeight() - 32; offsetX -= imageset->getWidth() / 2 - 16; - if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) + if (xmlNameEqual(frameNode, "frame")) { int index = XML::getProperty(frameNode, "index", -1); @@ -328,7 +328,7 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, mParticleAnimation.addFrame(img, delay, offsetX, offsetY, rand); } - else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence")) + else if (xmlNameEqual(frameNode, "sequence")) { int start = XML::getProperty(frameNode, "start", -1); int end = XML::getProperty(frameNode, "end", -1); @@ -354,13 +354,13 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, start++; } } - else if (xmlStrEqual(frameNode->name, BAD_CAST "end")) + else if (xmlNameEqual(frameNode, "end")) { mParticleAnimation.addTerminator(rand); } } // for frameNode } - else if (xmlStrEqual(propertyNode->name, BAD_CAST "deatheffect")) + else if (xmlNameEqual(propertyNode, "deatheffect")) { mDeathEffect = reinterpret_cast<const char*>( propertyNode->xmlChildrenNode->content); @@ -460,13 +460,13 @@ ParticleEmitter::~ParticleEmitter() if (mParticleImage) { mParticleImage->decRef(); - mParticleImage = 0; + mParticleImage = nullptr; } } template <typename T> ParticleEmitterProp<T> -ParticleEmitter::readParticleEmitterProp(xmlNodePtr propertyNode, T def) +ParticleEmitter::readParticleEmitterProp(XmlNodePtr propertyNode, T def) { ParticleEmitterProp<T> retval; diff --git a/src/particleemitter.h b/src/particleemitter.h index 49826d0f6..faa54dd12 100644 --- a/src/particleemitter.h +++ b/src/particleemitter.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -43,7 +43,7 @@ class Particle; class ParticleEmitter { public: - ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map, + ParticleEmitter(XmlNodePtr emitterNode, Particle *target, Map *map, int rotation = 0, const std::string& dyePalettes = std::string()); @@ -82,7 +82,7 @@ class ParticleEmitter private: template <typename T> ParticleEmitterProp<T> - readParticleEmitterProp(xmlNodePtr propertyNode, T def); + readParticleEmitterProp(XmlNodePtr propertyNode, T def); /** * initial position of particles: diff --git a/src/particleemitterprop.h b/src/particleemitterprop.h index 76c855e4f..cadfa0f3a 100644 --- a/src/particleemitterprop.h +++ b/src/particleemitterprop.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/party.cpp b/src/party.cpp index b462c94a7..1a693ddd6 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/party.h b/src/party.h index 73c45214a..1f616319d 100644 --- a/src/party.h +++ b/src/party.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 93e704302..0b9d16de2 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/playerinfo.h b/src/playerinfo.h index b90e47ce9..cff145d2d 100644 --- a/src/playerinfo.h +++ b/src/playerinfo.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 1bf63aa81..6b5cb0199 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -361,6 +361,24 @@ std::vector<std::string> * PlayerRelationsManager::getPlayers() return retval; } +std::vector<std::string> *PlayerRelationsManager::getPlayersByRelation( + PlayerRelation::Relation rel) +{ + std::vector<std::string> *retval = new std::vector<std::string>(); + + for (std::map<std::string, + PlayerRelation *>::const_iterator it = mRelations.begin(); + it != mRelations.end(); ++it) + { + if (it->second && it->second->mRelation == rel) + retval->push_back(it->first); + } + + sort(retval->begin(), retval->end(), playersSorter); + + return retval; +} + void PlayerRelationsManager::removePlayer(const std::string &name) { if (mRelations[name]) @@ -574,14 +592,24 @@ bool PlayerRelationsManager::checkName(const std::string &name) const const int size = name.size(); std::string check = config.getStringValue("unsecureChars"); - if (name.substr(0, 1) == " " || name.substr(size - 1, 1) == " ") + std::string lastChar = name.substr(size - 1, 1); + if (name.substr(0, 1) == " " || lastChar == " " || lastChar == "." + || name.find(" ") != std::string::npos) + { return false; + } else if (check.empty()) + { return true; + } else if (name.find_first_of(check) != std::string::npos) + { return false; + } else + { return true; + } } PlayerRelationsManager player_relations; diff --git a/src/playerrelations.h b/src/playerrelations.h index 5eb1b3c64..143a82477 100644 --- a/src/playerrelations.h +++ b/src/playerrelations.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -202,6 +202,9 @@ class PlayerRelationsManager */ std::vector<std::string> *getPlayers(); + std::vector<std::string> *getPlayersByRelation(PlayerRelation::Relation + rel); + /** * Removes all recorded player info. */ diff --git a/src/position.cpp b/src/position.cpp index 8e9baf272..7bd6cfe50 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/position.h b/src/position.h index 973a774f0..2e10aebe2 100644 --- a/src/position.h +++ b/src/position.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/properties.h b/src/properties.h index 19354b9ab..406477c73 100644 --- a/src/properties.h +++ b/src/properties.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/action.cpp b/src/resources/action.cpp index f940bffcb..e1f88ecb7 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/action.h b/src/resources/action.h index 9ab6f98d5..1e3965363 100644 --- a/src/resources/action.h +++ b/src/resources/action.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -23,7 +23,7 @@ #ifndef ACTION_H #define ACTION_H -#include <libxml/tree.h> +#include "utils/xml.h" #include <map> diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 2ad25dcd0..b5640904c 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h index c90ef7c79..54a764841 100644 --- a/src/resources/ambientlayer.h +++ b/src/resources/ambientlayer.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index 1f3336a8b..1c1da6ca5 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/animation.h b/src/resources/animation.h index 19b17eb54..33bfd76e9 100644 --- a/src/resources/animation.h +++ b/src/resources/animation.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -23,7 +23,7 @@ #ifndef ANIMATION_H #define ANIMATION_H -#include <libxml/tree.h> +#include "utils/xml.h" #include <vector> #include <string> diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 0b2aaa8fa..0fa815181 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index b93c11ba6..0f62ba5ea 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/chardb.cpp b/src/resources/chardb.cpp index d944f280e..f38f13224 100644 --- a/src/resources/chardb.cpp +++ b/src/resources/chardb.cpp @@ -1,7 +1,7 @@ /* * Color database * Copyright (C) 2008 Aethyra Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -24,10 +24,6 @@ #include "client.h" #include "logger.h" -#include "utils/xml.h" - -#include <libxml/tree.h> - #include "debug.h" namespace @@ -48,9 +44,9 @@ void CharDB::load() unload(); XML::Document *doc = new XML::Document("charcreation.xml"); - xmlNodePtr root = doc->rootNode(); + XmlNodePtr root = doc->rootNode(); - if (!root || !xmlStrEqual(root->name, BAD_CAST "chars")) + if (!root || !xmlNameEqual(root, "chars")) { logger->log1("CharDB: Failed to parse charcreation.xml."); @@ -60,15 +56,15 @@ void CharDB::load() for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "haircolor")) + if (xmlNameEqual(node, "haircolor")) { loadMinMax(node, &mMinHairColor, &mMaxHairColor); } - else if (xmlStrEqual(node->name, BAD_CAST "hairstyle")) + else if (xmlNameEqual(node, "hairstyle")) { loadMinMax(node, &mMinHairStyle, &mMaxHairStyle); } - else if (xmlStrEqual(node->name, BAD_CAST "stat")) + else if (xmlNameEqual(node, "stat")) { loadMinMax(node, &mMinStat, &mMaxStat); mSumStat = XML::getProperty(node, "sum", 0); @@ -80,7 +76,7 @@ void CharDB::load() mLoaded = true; } -void CharDB::loadMinMax(xmlNodePtr node, unsigned *min, unsigned *max) +void CharDB::loadMinMax(XmlNodePtr node, unsigned *min, unsigned *max) { *min = XML::getProperty(node, "min", 1); *max = XML::getProperty(node, "max", 10); diff --git a/src/resources/chardb.h b/src/resources/chardb.h index 769dedb56..60ff31084 100644 --- a/src/resources/chardb.h +++ b/src/resources/chardb.h @@ -1,7 +1,7 @@ /* * Color database * Copyright (C) 2008 Aethyra Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -25,7 +25,7 @@ #include <map> #include <string> -#include <libxml/tree.h> +#include "utils/xml.h" /** * Char information database. @@ -42,7 +42,7 @@ namespace CharDB */ void unload(); - void loadMinMax(xmlNodePtr node, unsigned *min, unsigned *max); + void loadMinMax(XmlNodePtr node, unsigned *min, unsigned *max); unsigned getMinHairColor(); diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 3b8c9d573..1ffe507b2 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -1,7 +1,7 @@ /* * Color database * Copyright (C) 2008 Aethyra Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -26,8 +26,6 @@ #include "utils/xml.h" -#include <libxml/tree.h> - #include "debug.h" namespace @@ -51,10 +49,10 @@ void ColorDB::load() void ColorDB::loadHair() { XML::Document *doc = new XML::Document("hair.xml"); - xmlNodePtr root = doc->rootNode(); + XmlNodePtr root = doc->rootNode(); bool hairXml = true; - if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) + if (!root || !xmlNameEqual(root, "colors")) { logger->log1("Trying to fall back on colors.xml"); @@ -64,7 +62,7 @@ void ColorDB::loadHair() doc = new XML::Document("colors.xml"); root = doc->rootNode(); - if (!root || !xmlStrEqual(root->name, BAD_CAST "colors")) + if (!root || !xmlNameEqual(root, "colors")) { logger->log1("ColorDB: Failed to find any color files."); mHairColors[0] = mFail; @@ -78,7 +76,7 @@ void ColorDB::loadHair() for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "color")) + if (xmlNameEqual(node, "color")) { int id = XML::getProperty(node, "id", 0); @@ -99,7 +97,7 @@ void ColorDB::loadHair() void ColorDB::loadColorLists() { XML::Document *doc = new XML::Document("itemcolors.xml"); - xmlNodePtr root = doc->rootNode(); + XmlNodePtr root = doc->rootNode(); if (!root) { delete doc; @@ -108,7 +106,7 @@ void ColorDB::loadColorLists() for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "list")) + if (xmlNameEqual(node, "list")) { std::string name = XML::getProperty(node, "name", ""); if (name.empty()) @@ -122,7 +120,7 @@ void ColorDB::loadColorLists() for_each_xml_child_node(colorNode, node) { - if (xmlStrEqual(colorNode->name, BAD_CAST "color")) + if (xmlNameEqual(colorNode, "color")) { ItemColor c(XML::getProperty(colorNode, "id", -1), XML::getProperty(colorNode, "name", ""), diff --git a/src/resources/colordb.h b/src/resources/colordb.h index f4cc88a59..36907095e 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -1,7 +1,7 @@ /* * Color database * Copyright (C) 2008 Aethyra Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 29b1c864e..6800c5170 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/dye.h b/src/resources/dye.h index 85192041a..94bee3b58 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index c456c49e4..c6126a57b 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -52,9 +52,9 @@ void EmoteDB::load() logger->log1("Initializing emote database..."); XML::Document doc("emotes.xml"); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "emotes")) + if (!rootNode || !xmlNameEqual(rootNode, "emotes")) { logger->log1("Emote Database: Error while loading emotes.xml!"); return; @@ -63,7 +63,7 @@ void EmoteDB::load() //iterate <emote>s for_each_xml_child_node(emoteNode, rootNode) { - if (!xmlStrEqual(emoteNode->name, BAD_CAST "emote")) + if (!xmlNameEqual(emoteNode, "emote")) continue; int id = XML::getProperty(emoteNode, "id", -1); @@ -81,7 +81,7 @@ void EmoteDB::load() if (!spriteNode->xmlChildrenNode) continue; - if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + if (xmlNameEqual(spriteNode, "sprite")) { EmoteSprite *currentSprite = new EmoteSprite; std::string file = paths.getStringValue("sprites") @@ -92,7 +92,7 @@ void EmoteDB::load() currentSprite->name = XML::getProperty(spriteNode, "name", ""); currentInfo->sprites.push_back(currentSprite); } - else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) + else if (xmlNameEqual(spriteNode, "particlefx")) { std::string particlefx = reinterpret_cast<const char*>( spriteNode->xmlChildrenNode->content); @@ -108,7 +108,7 @@ void EmoteDB::load() XML::Document doc2("graphics/sprites/manaplus_emotes.xml"); rootNode = doc2.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "emotes")) + if (!rootNode || !xmlNameEqual(rootNode, "emotes")) { logger->log1("Emote Database: Error while loading" " manaplus_emotes.xml!"); @@ -118,7 +118,7 @@ void EmoteDB::load() //iterate <emote>s for_each_xml_child_node(emoteNode, rootNode) { - if (!xmlStrEqual(emoteNode->name, BAD_CAST "emote")) + if (!xmlNameEqual(emoteNode, "emote")) continue; int id = XML::getProperty(emoteNode, "id", -1); @@ -136,7 +136,7 @@ void EmoteDB::load() if (!spriteNode->xmlChildrenNode) continue; - if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + if (xmlNameEqual(spriteNode, "sprite")) { EmoteSprite *currentSprite = new EmoteSprite; std::string file = paths.getStringValue("sprites") @@ -147,7 +147,7 @@ void EmoteDB::load() currentSprite->name = XML::getProperty(spriteNode, "name", ""); currentInfo->sprites.push_back(currentSprite); } - else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) + else if (xmlNameEqual(spriteNode, "particlefx")) { std::string particlefx = reinterpret_cast<const char*>( spriteNode->xmlChildrenNode->content); diff --git a/src/resources/image.cpp b/src/resources/image.cpp index df07c16a2..d94967631 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -473,10 +473,10 @@ Image* Image::SDLmerge(Image *image, int x, int y) static_cast<Uint16>(mBounds.h - y)); // for each pixel lines of a source image - for (offset_x = (x > 0 ? 0 : -x); offset_x < maxX; offset_x++) + for (offset_x = ((x > 0) ? 0 : -x); offset_x < maxX; offset_x++) { const int x1 = x0 + offset_x; - for (offset_y = (y > 0 ? 0 : -y); offset_y < maxY; offset_y++) + for (offset_y = ((y > 0) ? 0 : -y); offset_y < maxY; offset_y++) { // Computing offset on both images current_offset = (offset_y * getWidth()) + x1; diff --git a/src/resources/image.h b/src/resources/image.h index 333dc63f9..a9f5722cd 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp index a8563c679..decf17189 100644 --- a/src/resources/imageloader.cpp +++ b/src/resources/imageloader.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/imageloader.h b/src/resources/imageloader.h index 5c3d29c74..1dcd046ca 100644 --- a/src/resources/imageloader.h +++ b/src/resources/imageloader.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 09b57be28..9e3513e91 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/imageset.h b/src/resources/imageset.h index fd320295a..69ebebdc0 100644 --- a/src/resources/imageset.h +++ b/src/resources/imageset.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index a3a35cfd1..9501c98a5 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/imagewriter.h b/src/resources/imagewriter.h index ae94730f2..ca8150694 100644 --- a/src/resources/imagewriter.h +++ b/src/resources/imagewriter.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 2911fa06f..5fa68a88f 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -23,6 +23,7 @@ #include "resources/itemdb.h" #include "client.h" +#include "configuration.h" #include "logger.h" #include "resources/iteminfo.h" @@ -32,9 +33,6 @@ #include "utils/gettext.h" #include "utils/stringutils.h" #include "utils/xml.h" -#include "configuration.h" - -#include <libxml/tree.h> #include "debug.h" @@ -49,11 +47,11 @@ namespace } // Forward declarations -static void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node); -static void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node); -static void loadFloorSprite(SpriteDisplay *display, xmlNodePtr node); -static void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode); -static void loadOrderSprite(ItemInfo *itemInfo, xmlNodePtr node, +static void loadSpriteRef(ItemInfo *itemInfo, XmlNodePtr node); +static void loadSoundRef(ItemInfo *itemInfo, XmlNodePtr node); +static void loadFloorSprite(SpriteDisplay *display, XmlNodePtr node); +static void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode); +static void loadOrderSprite(ItemInfo *itemInfo, XmlNodePtr node, bool drawAfter); static int parseSpriteName(std::string name); static int parseDirectionName(std::string name); @@ -174,9 +172,9 @@ void ItemDB::load() mUnknown->addTag(mTags["All"]); XML::Document doc("items.xml"); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items")) + if (!rootNode || !xmlNameEqual(rootNode, "items")) { logger->log("ItemDB: Error while loading items.xml!"); mLoaded = true; @@ -185,7 +183,7 @@ void ItemDB::load() for_each_xml_child_node(node, rootNode) { - if (!xmlStrEqual(node->name, BAD_CAST "item")) + if (!xmlNameEqual(node, "item")) continue; int id = XML::getProperty(node, "id", 0); @@ -326,7 +324,7 @@ void ItemDB::load() for_each_xml_child_node(itemChild, node) { - if (xmlStrEqual(itemChild->name, BAD_CAST "sprite")) + if (xmlNameEqual(itemChild, "sprite")) { std::string attackParticle = XML::getProperty( itemChild, "particle-effect", ""); @@ -334,23 +332,23 @@ void ItemDB::load() loadSpriteRef(itemInfo, itemChild); } - else if (xmlStrEqual(itemChild->name, BAD_CAST "sound")) + else if (xmlNameEqual(itemChild, "sound")) { loadSoundRef(itemInfo, itemChild); } - else if (xmlStrEqual(itemChild->name, BAD_CAST "floor")) + else if (xmlNameEqual(itemChild, "floor")) { loadFloorSprite(&display, itemChild); } - else if (xmlStrEqual(itemChild->name, BAD_CAST "replace")) + else if (xmlNameEqual(itemChild, "replace")) { loadReplaceSprite(itemInfo, itemChild); } - else if (xmlStrEqual(itemChild->name, BAD_CAST "drawAfter")) + else if (xmlNameEqual(itemChild, "drawAfter")) { loadOrderSprite(itemInfo, itemChild, true); } - else if (xmlStrEqual(itemChild->name, BAD_CAST "drawBefore")) + else if (xmlNameEqual(itemChild, "drawBefore")) { loadOrderSprite(itemInfo, itemChild, false); } @@ -595,7 +593,7 @@ int parseDirectionName(std::string name) return id; } -void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node) +void loadSpriteRef(ItemInfo *itemInfo, XmlNodePtr node) { std::string gender = XML::getProperty(node, "gender", "unisex"); std::string filename = reinterpret_cast<const char*>( @@ -607,7 +605,7 @@ void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node) itemInfo->setSprite(filename, GENDER_FEMALE); } -void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node) +void loadSoundRef(ItemInfo *itemInfo, XmlNodePtr node) { std::string event = XML::getProperty(node, "event", ""); std::string filename = reinterpret_cast<const char*>( @@ -628,11 +626,11 @@ void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node) } } -void loadFloorSprite(SpriteDisplay *display, xmlNodePtr floorNode) +void loadFloorSprite(SpriteDisplay *display, XmlNodePtr floorNode) { for_each_xml_child_node(spriteNode, floorNode) { - if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + if (xmlNameEqual(spriteNode, "sprite")) { SpriteReference *currentSprite = new SpriteReference; currentSprite->sprite = reinterpret_cast<const char*>( @@ -641,7 +639,7 @@ void loadFloorSprite(SpriteDisplay *display, xmlNodePtr floorNode) = XML::getProperty(spriteNode, "variant", 0); display->sprites.push_back(currentSprite); } - else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) + else if (xmlNameEqual(spriteNode, "particlefx")) { std::string particlefx = reinterpret_cast<const char*>( spriteNode->xmlChildrenNode->content); @@ -650,7 +648,7 @@ void loadFloorSprite(SpriteDisplay *display, xmlNodePtr floorNode) } } -void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) +void loadReplaceSprite(ItemInfo *itemInfo, XmlNodePtr replaceNode) { std::string removeSprite = XML::getProperty(replaceNode, "sprite", ""); int direction = parseDirectionName(XML::getProperty( @@ -671,7 +669,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) continue; for_each_xml_child_node(itemNode, replaceNode) { - if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + if (xmlNameEqual(itemNode, "item")) { int from = XML::getProperty(itemNode, "from", 0); int to = XML::getProperty(itemNode, "to", 1); @@ -693,7 +691,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) for_each_xml_child_node(itemNode, replaceNode) { - if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + if (xmlNameEqual(itemNode, "item")) { int from = XML::getProperty(itemNode, "from", 0); int to = XML::getProperty(itemNode, "to", 1); @@ -726,7 +724,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) for_each_xml_child_node(itemNode, replaceNode) { - if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + if (xmlNameEqual(itemNode, "item")) { int from = XML::getProperty(itemNode, "from", 0); int to = XML::getProperty(itemNode, "to", 1); @@ -756,7 +754,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) return; for_each_xml_child_node(itemNode, replaceNode) { - if (xmlStrEqual(itemNode->name, BAD_CAST "item")) + if (xmlNameEqual(itemNode, "item")) { int from = XML::getProperty(itemNode, "from", 0); int to = XML::getProperty(itemNode, "to", 1); @@ -768,7 +766,7 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode) } } -void loadOrderSprite(ItemInfo *itemInfo, xmlNodePtr node, bool drawAfter) +void loadOrderSprite(ItemInfo *itemInfo, XmlNodePtr node, bool drawAfter) { int sprite = parseSpriteName(XML::getProperty(node, "name", "")); int priority = XML::getProperty(node, "priority", 0); diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 71f0a490e..e56840c16 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index dfcff3f76..f163fc590 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 1fe8f3bad..8c5e2dd8f 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp index e7288e039..b186ad658 100644 --- a/src/resources/mapdb.cpp +++ b/src/resources/mapdb.cpp @@ -1,7 +1,7 @@ /* * Color database * Copyright (C) 2008 Aethyra Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -27,8 +27,6 @@ #include "utils/xml.h" -#include <libxml/tree.h> - #include "debug.h" namespace @@ -45,7 +43,7 @@ void MapDB::load() XML::Document *doc = new XML::Document( paths.getStringValue("maps") + "remap.xml"); - xmlNodePtr root = doc->rootNode(); + XmlNodePtr root = doc->rootNode(); if (!root) { delete doc; @@ -54,7 +52,7 @@ void MapDB::load() for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "map")) + if (xmlNameEqual(node, "map")) { std::string name = XML::getProperty(node, "name", ""); if (name.empty()) diff --git a/src/resources/mapdb.h b/src/resources/mapdb.h index 2ba084297..d249a5cc6 100644 --- a/src/resources/mapdb.h +++ b/src/resources/mapdb.h @@ -1,7 +1,7 @@ /* * Color database * Copyright (C) 2008 Aethyra Development Team - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 68d39f0ae..8d71779f2 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -35,7 +35,6 @@ #include "utils/base64.h" #include "utils/gettext.h" #include "utils/stringutils.h" -#include "utils/xml.h" #include <iostream> #include <zlib.h> @@ -223,12 +222,12 @@ Map *MapReader::readMap(const std::string &filename, XML::Document doc(reinterpret_cast<char*>(inflated), inflatedSize); free(inflated); - xmlNodePtr node = doc.rootNode(); + XmlNodePtr node = doc.rootNode(); // Parse the inflated map data if (node) { - if (!xmlStrEqual(node->name, BAD_CAST "map")) + if (!xmlNameEqual(node, "map")) logger->log("Error: Not a map file (%s)!", realFilename.c_str()); else map = readMap(node, realFilename); @@ -248,7 +247,7 @@ Map *MapReader::readMap(const std::string &filename, return map; } -Map *MapReader::readMap(xmlNodePtr node, const std::string &path) +Map *MapReader::readMap(XmlNodePtr node, const std::string &path) { if (!node) return nullptr; @@ -277,23 +276,23 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path) for_each_xml_child_node(childNode, node) { - if (xmlStrEqual(childNode->name, BAD_CAST "tileset")) + if (xmlNameEqual(childNode, "tileset")) { Tileset *tileset = readTileset(childNode, pathDir, map); if (tileset) map->addTileset(tileset); } - else if (xmlStrEqual(childNode->name, BAD_CAST "layer")) + else if (xmlNameEqual(childNode, "layer")) { readLayer(childNode, map); } - else if (xmlStrEqual(childNode->name, BAD_CAST "properties")) + else if (xmlNameEqual(childNode, "properties")) { readProperties(childNode, map); map->setVersion(atoi(map->getProperty( "manaplus version").c_str())); } - else if (xmlStrEqual(childNode->name, BAD_CAST "objectgroup")) + else if (xmlNameEqual(childNode, "objectgroup")) { // The object group offset is applied to each object individually const int tileOffsetX = XML::getProperty(childNode, "x", 0); @@ -303,7 +302,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path) for_each_xml_child_node(objectNode, childNode) { - if (xmlStrEqual(objectNode->name, BAD_CAST "object")) + if (xmlNameEqual(objectNode, "object")) { std::string objType = XML::getProperty( objectNode, "type", ""); @@ -380,14 +379,14 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path) return map; } -void MapReader::readProperties(xmlNodePtr node, Properties *props) +void MapReader::readProperties(XmlNodePtr node, Properties *props) { if (!node || !props) return; for_each_xml_child_node(childNode, node) { - if (!xmlStrEqual(childNode->name, BAD_CAST "property")) + if (!xmlNameEqual(childNode, "property")) continue; // Example: <property name="name" value="value"/> @@ -443,7 +442,7 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid) } } -void MapReader::readLayer(xmlNodePtr node, Map *map) +void MapReader::readLayer(XmlNodePtr node, Map *map) { // Layers are not necessarily the same size as the map const int w = XML::getProperty(node, "width", map->getWidth()); @@ -473,7 +472,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) // Load the tile data for_each_xml_child_node(childNode, node) { - if (!xmlStrEqual(childNode->name, BAD_CAST "data")) + if (!xmlNameEqual(childNode, "data")) continue; const std::string encoding = @@ -492,7 +491,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) } // Read base64 encoded map file - xmlNodePtr dataChild = childNode->xmlChildrenNode; + XmlNodePtr dataChild = childNode->xmlChildrenNode; if (!dataChild) continue; @@ -577,7 +576,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) } else if (encoding == "csv") { - xmlNodePtr dataChild = childNode->xmlChildrenNode; + XmlNodePtr dataChild = childNode->xmlChildrenNode; if (!dataChild) continue; @@ -620,7 +619,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) // Read plain XML map file for_each_xml_child_node(childNode2, childNode) { - if (!xmlStrEqual(childNode2->name, BAD_CAST "tile")) + if (!xmlNameEqual(childNode2, "tile")) continue; const int gid = XML::getProperty(childNode2, "gid", -1); @@ -647,7 +646,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) } -Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, +Tileset *MapReader::readTileset(XmlNodePtr node, const std::string &path, Map *map) { if (!map) @@ -679,7 +678,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, for_each_xml_child_node(childNode, node) { - if (xmlStrEqual(childNode->name, BAD_CAST "image")) + if (xmlNameEqual(childNode, "image")) { const std::string source = XML::getProperty( childNode, "source", ""); @@ -704,11 +703,11 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, } } } - else if (xmlStrEqual(childNode->name, BAD_CAST "tile")) + else if (xmlNameEqual(childNode, "tile")) { for_each_xml_child_node(tileNode, childNode) { - if (!xmlStrEqual(tileNode->name, BAD_CAST "properties")) + if (!xmlNameEqual(tileNode, "properties")) continue; int tileGID = firstGid + XML::getProperty(childNode, "id", 0); @@ -717,7 +716,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, std::map<std::string, int> tileProperties; for_each_xml_child_node(propertyNode, tileNode) { - if (!xmlStrEqual(propertyNode->name, BAD_CAST "property")) + if (!xmlNameEqual(propertyNode, "property")) continue; std::string name = XML::getProperty( propertyNode, "name", ""); diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index c15a83b6f..c9c742ecd 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -23,7 +23,7 @@ #ifndef MAPREADER_H #define MAPREADER_H -#include <libxml/tree.h> +#include "utils/xml.h" #include <string> @@ -47,7 +47,7 @@ class MapReader * Read an XML map from a parsed XML tree. The path is used to find the * location of referenced tileset images. */ - static Map *readMap(xmlNodePtr node, const std::string &path); + static Map *readMap(XmlNodePtr node, const std::string &path); private: /** @@ -57,17 +57,17 @@ class MapReader * @param props The Properties instance to which the properties will * be assigned. */ - static void readProperties(xmlNodePtr node, Properties* props); + static void readProperties(XmlNodePtr node, Properties* props); /** * Reads a map layer and adds it to the given map. */ - static void readLayer(xmlNodePtr node, Map *map); + static void readLayer(XmlNodePtr node, Map *map); /** * Reads a tile set. */ - static Tileset *readTileset(xmlNodePtr node, const std::string &path, + static Tileset *readTileset(XmlNodePtr node, const std::string &path, Map *map); }; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index dbf9d3e9a..9d295db35 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -52,9 +52,9 @@ void MonsterDB::load() logger->log1("Initializing monster database..."); XML::Document doc("monsters.xml"); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "monsters")) + if (!rootNode || !xmlNameEqual(rootNode, "monsters")) { logger->log("Monster Database: Error while loading monster.xml!"); mLoaded = true; @@ -71,7 +71,7 @@ void MonsterDB::load() //iterate <monster>s for_each_xml_child_node(monsterNode, rootNode) { - if (!xmlStrEqual(monsterNode->name, BAD_CAST "monster")) + if (!xmlNameEqual(monsterNode, "monster")) continue; BeingInfo *currentInfo = new BeingInfo; @@ -119,7 +119,7 @@ void MonsterDB::load() if (!spriteNode->xmlChildrenNode) continue; - if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + if (xmlNameEqual(spriteNode, "sprite")) { SpriteReference *currentSprite = new SpriteReference; currentSprite->sprite = reinterpret_cast<const char*>( @@ -129,7 +129,7 @@ void MonsterDB::load() spriteNode, "variant", 0); display.sprites.push_back(currentSprite); } - else if (xmlStrEqual(spriteNode->name, BAD_CAST "sound")) + else if (xmlNameEqual(spriteNode, "sound")) { std::string event = XML::getProperty(spriteNode, "event", ""); const char *filename; @@ -172,7 +172,7 @@ void MonsterDB::load() currentInfo->getName().c_str()); } } - else if (xmlStrEqual(spriteNode->name, BAD_CAST "attack")) + else if (xmlNameEqual(spriteNode, "attack")) { const int id = XML::getProperty(spriteNode, "id", 0); const std::string particleEffect = XML::getProperty( @@ -185,7 +185,7 @@ void MonsterDB::load() currentInfo->addAttack(id, spriteAction, particleEffect, missileParticle); } - else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) + else if (xmlNameEqual(spriteNode, "particlefx")) { display.particles.push_back(reinterpret_cast<const char*>( spriteNode->xmlChildrenNode->content)); diff --git a/src/resources/monsterdb.h b/src/resources/monsterdb.h index 1a9d0e64f..3ddc68c08 100644 --- a/src/resources/monsterdb.h +++ b/src/resources/monsterdb.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/music.cpp b/src/resources/music.cpp index 099d030b0..6e752ab60 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/music.h b/src/resources/music.h index a4b5b4973..428c02572 100644 --- a/src/resources/music.h +++ b/src/resources/music.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index d04a2518f..832fa26d6 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -46,9 +46,9 @@ void NPCDB::load() logger->log1("Initializing NPC database..."); XML::Document doc("npcs.xml"); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "npcs")) + if (!rootNode || !xmlNameEqual(rootNode, "npcs")) { logger->log("NPC Database: Error while loading npcs.xml!"); mLoaded = true; @@ -58,7 +58,7 @@ void NPCDB::load() //iterate <npc>s for_each_xml_child_node(npcNode, rootNode) { - if (!xmlStrEqual(npcNode->name, BAD_CAST "npc")) + if (!xmlNameEqual(npcNode, "npc")) continue; int id = XML::getProperty(npcNode, "id", 0); @@ -84,7 +84,7 @@ void NPCDB::load() if (!spriteNode->xmlChildrenNode) continue; - if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) + if (xmlNameEqual(spriteNode, "sprite")) { SpriteReference *currentSprite = new SpriteReference; currentSprite->sprite = reinterpret_cast<const char*>( @@ -93,7 +93,7 @@ void NPCDB::load() XML::getProperty(spriteNode, "variant", 0); display.sprites.push_back(currentSprite); } - else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) + else if (xmlNameEqual(spriteNode, "particlefx")) { std::string particlefx = reinterpret_cast<const char*>( spriteNode->xmlChildrenNode->content); diff --git a/src/resources/npcdb.h b/src/resources/npcdb.h index 1d8a72aa6..9b686691a 100644 --- a/src/resources/npcdb.h +++ b/src/resources/npcdb.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index 552af06ec..e9449f0c9 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/resource.h b/src/resources/resource.h index 7196fa916..b8e06aaa7 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index a99ca622e..3376394bc 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -456,7 +456,7 @@ struct DyedImageLoader if (!buffer) { delete d; - return 0; + return nullptr; } Resource *res = d ? Image::load(buffer, fileSize, *d) : Image::load(buffer, fileSize); @@ -634,18 +634,17 @@ bool ResourceManager::copyFile(const std::string &src, const std::string &dst) return true; } -std::vector<std::string> ResourceManager::loadTextFile( - const std::string &fileName) +bool ResourceManager::loadTextFile(const std::string &fileName, + std::vector<std::string> &lines) { int contentsLength; char *fileContents = static_cast<char*>( loadFile(fileName, contentsLength)); - std::vector<std::string> lines; if (!fileContents) { logger->log("Couldn't load text file: %s", fileName.c_str()); - return lines; + return false; } std::istringstream iss(std::string(fileContents, contentsLength)); @@ -655,7 +654,7 @@ std::vector<std::string> ResourceManager::loadTextFile( lines.push_back(line); free(fileContents); - return lines; + return true; } std::vector<std::string> ResourceManager::loadTextFileLocal( diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index f70fbece4..f0146b8b4 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -217,7 +217,8 @@ class ResourceManager /** * Retrieves the contents of a text file (PhysFS). */ - std::vector<std::string> loadTextFile(const std::string &fileName); + bool loadTextFile(const std::string &fileName, + std::vector<std::string> &lines); /** * Retrieves the contents of a text file. diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index a8da8dd80..eaa323bd6 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index fdd4bd275..91ca3bb59 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 51ba4bc74..b1a3a9c4d 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -55,9 +55,9 @@ void SpecialDB::load() logger->log("Initializing special database..."); XML::Document doc("specials.xml"); - xmlNodePtr root = doc.rootNode(); + XmlNodePtr root = doc.rootNode(); - if (!root || !xmlStrEqual(root->name, BAD_CAST "specials")) + if (!root || !xmlNameEqual(root, "specials")) { logger->log("Error loading specials file specials.xml"); return; @@ -67,13 +67,13 @@ void SpecialDB::load() for_each_xml_child_node(set, root) { - if (xmlStrEqual(set->name, BAD_CAST "set")) + if (xmlNameEqual(set, "set")) { setName = XML::getProperty(set, "name", "Actions"); for_each_xml_child_node(special, set) { - if (xmlStrEqual(special->name, BAD_CAST "special")) + if (xmlNameEqual(special, "special")) { SpecialInfo *info = new SpecialInfo(); int id = XML::getProperty(special, "id", 0); diff --git a/src/resources/specialdb.h b/src/resources/specialdb.h index 8a9e6bb23..f6ef73862 100644 --- a/src/resources/specialdb.h +++ b/src/resources/specialdb.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 32d18b6b8..0d9b95f6f 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -33,8 +33,6 @@ #include "configuration.h" -#include "utils/xml.h" - #include "debug.h" SpriteReference *SpriteReference::Empty = nullptr; @@ -83,9 +81,9 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) palettes = animationFile.substr(pos + 1); XML::Document doc(animationFile.substr(0, pos)); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) + if (!rootNode || !xmlNameEqual(rootNode, "sprite")) { logger->log("Error, failed to parse %s", animationFile.c_str()); @@ -136,7 +134,7 @@ void SpriteDef::substituteActions() substituteAction(SpriteAction::SPAWN, SpriteAction::STAND); } -void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant, +void SpriteDef::loadSprite(XmlNodePtr spriteNode, int variant, const std::string &palettes) { // Get the variant @@ -151,16 +149,16 @@ void SpriteDef::loadSprite(xmlNodePtr spriteNode, int variant, for_each_xml_child_node(node, spriteNode) { - if (xmlStrEqual(node->name, BAD_CAST "imageset")) + if (xmlNameEqual(node, "imageset")) loadImageSet(node, palettes); - else if (xmlStrEqual(node->name, BAD_CAST "action")) + else if (xmlNameEqual(node, "action")) loadAction(node, variant_offset); - else if (xmlStrEqual(node->name, BAD_CAST "include")) + else if (xmlNameEqual(node, "include")) includeSprite(node); } } -void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes) +void SpriteDef::loadImageSet(XmlNodePtr node, const std::string &palettes) { const std::string name = XML::getProperty(node, "name", ""); @@ -188,7 +186,7 @@ void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes) mImageSets[name] = imageSet; } -void SpriteDef::loadAction(xmlNodePtr node, int variant_offset) +void SpriteDef::loadAction(XmlNodePtr node, int variant_offset) { const std::string actionName = XML::getProperty(node, "name", ""); const std::string imageSetName = XML::getProperty(node, "imageset", ""); @@ -225,12 +223,12 @@ void SpriteDef::loadAction(xmlNodePtr node, int variant_offset) // Load animations for_each_xml_child_node(animationNode, node) { - if (xmlStrEqual(animationNode->name, BAD_CAST "animation")) + if (xmlNameEqual(animationNode, "animation")) loadAnimation(animationNode, action, imageSet, variant_offset); } } -void SpriteDef::loadAnimation(xmlNodePtr animationNode, +void SpriteDef::loadAnimation(XmlNodePtr animationNode, Action *action, ImageSet *imageSet, int variant_offset) { @@ -264,7 +262,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, offsetY -= imageSet->getHeight() - 32; offsetX -= imageSet->getWidth() / 2 - 16; - if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) + if (xmlNameEqual(frameNode, "frame")) { const int index = XML::getProperty(frameNode, "index", -1); @@ -284,7 +282,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, animation->addFrame(img, delay, offsetX, offsetY, rand); } - else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence")) + else if (xmlNameEqual(frameNode, "sequence")) { const int start = XML::getProperty(frameNode, "start", -1); const int end = XML::getProperty(frameNode, "end", -1); @@ -324,22 +322,22 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, repeat --; } } - else if (xmlStrEqual(frameNode->name, BAD_CAST "end")) + else if (xmlNameEqual(frameNode, "end")) { animation->addTerminator(rand); } - else if (xmlStrEqual(frameNode->name, BAD_CAST "jump")) + else if (xmlNameEqual(frameNode, "jump")) { animation->addJump(XML::getProperty( frameNode, "action", ""), rand); } - else if (xmlStrEqual(frameNode->name, BAD_CAST "label")) + else if (xmlNameEqual(frameNode, "label")) { std::string name = XML::getProperty(frameNode, "name", ""); if (!name.empty()) animation->addLabel(name); } - else if (xmlStrEqual(frameNode->name, BAD_CAST "goto")) + else if (xmlNameEqual(frameNode, "goto")) { std::string name = XML::getProperty(frameNode, "label", ""); if (!name.empty()) @@ -348,7 +346,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, } // for frameNode } -void SpriteDef::includeSprite(xmlNodePtr includeNode) +void SpriteDef::includeSprite(XmlNodePtr includeNode) { std::string filename = XML::getProperty(includeNode, "file", ""); @@ -365,9 +363,9 @@ void SpriteDef::includeSprite(xmlNodePtr includeNode) mProcessedFiles.insert(filename); XML::Document doc(filename); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "sprite")) + if (!rootNode || !xmlNameEqual(rootNode, "sprite")) { logger->log("Error, no sprite root node in %s", filename.c_str()); return; diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 3aa6369dd..0490bdcb3 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -25,7 +25,7 @@ #include "resources/resource.h" -#include <libxml/tree.h> +#include "utils/xml.h" #include <list> #include <map> @@ -145,30 +145,30 @@ class SpriteDef : public Resource /** * Loads a sprite element. */ - void loadSprite(xmlNodePtr spriteNode, int variant, + void loadSprite(XmlNodePtr spriteNode, int variant, const std::string &palettes = ""); /** * Loads an imageset element. */ - void loadImageSet(xmlNodePtr node, const std::string &palettes); + void loadImageSet(XmlNodePtr node, const std::string &palettes); /** * Loads an action element. */ - void loadAction(xmlNodePtr node, int variant_offset); + void loadAction(XmlNodePtr node, int variant_offset); /** * Loads an animation element. */ - void loadAnimation(xmlNodePtr animationNode, + void loadAnimation(XmlNodePtr animationNode, Action *action, ImageSet *imageSet, int variant_offset); /** * Include another sprite into this one. */ - void includeSprite(xmlNodePtr includeNode); + void includeSprite(XmlNodePtr includeNode); /** * Complete missing actions by copying existing ones. diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index c8cd5ad60..7ebc5a11a 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/resources/wallpaper.h b/src/resources/wallpaper.h index 55f5eec93..7123cfd96 100644 --- a/src/resources/wallpaper.h +++ b/src/resources/wallpaper.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp index c7c0d10bf..f92b0f3eb 100644 --- a/src/rotationalparticle.cpp +++ b/src/rotationalparticle.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -34,9 +34,9 @@ RotationalParticle::RotationalParticle(Map *map, Animation *animation): { } -RotationalParticle::RotationalParticle(Map *map, xmlNodePtr animationNode, +RotationalParticle::RotationalParticle(Map *map, XmlNodePtr animationNode, const std::string& dyePalettes): - ImageParticle(map, 0), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animationNode, dyePalettes)) { } @@ -61,12 +61,12 @@ bool RotationalParticle::update() float rad = static_cast<float>(atan2(mVelocity.x, mVelocity.y)); if (rad < 0) - rad = static_cast<float>(PI + (PI + rad)); + rad = static_cast<float>(PI) + static_cast<float>(PI) + rad; float range = static_cast<float>(PI / size); // Determines which frame the particle should play - if (rad < range || rad > ((PI*2) - range)) + if (rad < range || rad > ((static_cast<float>(PI)*2) - range)) { mAnimation->setFrame(0); } diff --git a/src/rotationalparticle.h b/src/rotationalparticle.h index d5b91bc63..251e3769c 100644 --- a/src/rotationalparticle.h +++ b/src/rotationalparticle.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -25,7 +25,7 @@ #include "imageparticle.h" -#include <libxml/tree.h> +#include "utils/xml.h" class Animation; class Map; @@ -36,7 +36,7 @@ class RotationalParticle : public ImageParticle public: RotationalParticle(Map *map, Animation *animation); - RotationalParticle(Map *map, xmlNodePtr animationNode, + RotationalParticle(Map *map, XmlNodePtr animationNode, const std::string& dyePalettes = std::string()); ~RotationalParticle(); diff --git a/src/shopitem.cpp b/src/shopitem.cpp index db84d30df..083c2836f 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/shopitem.h b/src/shopitem.h index 188698438..61d23a4ab 100644 --- a/src/shopitem.h +++ b/src/shopitem.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 31f0c7af0..2b7cc328d 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -44,7 +44,7 @@ SimpleAnimation::SimpleAnimation(Animation *animation): { } -SimpleAnimation::SimpleAnimation(xmlNodePtr animationNode, +SimpleAnimation::SimpleAnimation(XmlNodePtr animationNode, const std::string& dyePalettes): mAnimation(new Animation), mAnimationTime(0), @@ -136,7 +136,7 @@ Image *SimpleAnimation::getCurrentImage() const return nullptr; } -void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, +void SimpleAnimation::initializeAnimation(XmlNodePtr animationNode, const std::string& dyePalettes) { mInitialized = false; @@ -161,7 +161,7 @@ void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, return; // Get animation frames - for (xmlNodePtr frameNode = animationNode->xmlChildrenNode; + for (XmlNodePtr frameNode = animationNode->xmlChildrenNode; frameNode; frameNode = frameNode->next) { int delay = XML::getProperty(frameNode, "delay", 0); @@ -171,7 +171,7 @@ void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, offsetY -= imageset->getHeight() - 32; offsetX -= imageset->getWidth() / 2 - 16; - if (xmlStrEqual(frameNode->name, BAD_CAST "frame")) + if (xmlNameEqual(frameNode, "frame")) { int index = XML::getProperty(frameNode, "index", -1); @@ -192,7 +192,7 @@ void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, if (mAnimation) mAnimation->addFrame(img, delay, offsetX, offsetY, rand); } - else if (xmlStrEqual(frameNode->name, BAD_CAST "sequence")) + else if (xmlNameEqual(frameNode, "sequence")) { int start = XML::getProperty(frameNode, "start", -1); int end = XML::getProperty(frameNode, "end", -1); @@ -218,7 +218,7 @@ void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, start++; } } - else if (xmlStrEqual(frameNode->name, BAD_CAST "end")) + else if (xmlNameEqual(frameNode, "end")) { if (mAnimation) mAnimation->addTerminator(rand); diff --git a/src/simpleanimation.h b/src/simpleanimation.h index 44aab9a25..de1203662 100644 --- a/src/simpleanimation.h +++ b/src/simpleanimation.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -47,7 +47,7 @@ class SimpleAnimation /** * Creates a simple animation that creates its animation from XML Data. */ - SimpleAnimation(xmlNodePtr animationNode, + SimpleAnimation(XmlNodePtr animationNode, const std::string& dyePalettes = std::string()); ~SimpleAnimation(); @@ -68,7 +68,7 @@ class SimpleAnimation Image *getCurrentImage() const; private: - void initializeAnimation(xmlNodePtr animationNode, const std::string& + void initializeAnimation(XmlNodePtr animationNode, const std::string& dyePalettes = std::string()); /** The hosted animation. */ diff --git a/src/sound.cpp b/src/sound.cpp index a573458ef..123a66567 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -349,9 +349,13 @@ void Sound::playGuiSfx(const std::string &path) if (!mInstalled || path.empty() || !mPlayGui) return; + std::string tmpPath; + if (!path.compare(0, 4, "sfx/")) + tmpPath = path; + else + tmpPath = paths.getValue("sfx", "sfx/") + path; ResourceManager *resman = ResourceManager::getInstance(); - SoundEffect *sample = resman->getSoundEffect( - paths.getStringValue("sfx") + path); + SoundEffect *sample = resman->getSoundEffect(tmpPath); if (sample) { logger->log("Sound::playGuiSfx() Playing: %s", path.c_str()); diff --git a/src/sound.h b/src/sound.h index 16fff161b..6ac361cac 100644 --- a/src/sound.h +++ b/src/sound.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/sprite.h b/src/sprite.h index 64721b740..ffee97d49 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index f7bffc31f..a7e06a2f4 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -37,7 +37,7 @@ #define STATUS_EFFECTS_FILE "status-effects.xml" -void unloadMap(std::map<int, StatusEffect *> map); +void unloadMap(std::map<int, StatusEffect *> &map); bool StatusEffect::mLoaded = false; @@ -130,9 +130,9 @@ void StatusEffect::load() unload(); XML::Document doc(STATUS_EFFECTS_FILE); - xmlNodePtr rootNode = doc.rootNode(); + XmlNodePtr rootNode = doc.rootNode(); - if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "status-effects")) + if (!rootNode || !xmlNameEqual(rootNode, "status-effects")) { logger->log1("Error loading status effects file: " STATUS_EFFECTS_FILE); @@ -145,7 +145,7 @@ void StatusEffect::load() int index = atoi(XML::getProperty(node, "id", "-1").c_str()); - if (xmlStrEqual(node->name, BAD_CAST "status-effect")) + if (xmlNameEqual(node, "status-effect")) { the_map = &statusEffects; int block_index = atoi(XML::getProperty( @@ -155,8 +155,10 @@ void StatusEffect::load() blockEffectIndexMap[block_index] = index; } - else if (xmlStrEqual(node->name, BAD_CAST "stun-effect")) + else if (xmlNameEqual(node, "stun-effect")) + { the_map = &stunEffects; + } if (the_map) { @@ -187,7 +189,7 @@ void StatusEffect::load() mLoaded = true; } -void unloadMap(std::map<int, StatusEffect *> map) +void unloadMap(std::map<int, StatusEffect *> &map) { std::map<int, StatusEffect *>::iterator it; diff --git a/src/statuseffect.h b/src/statuseffect.h index 8af1607a5..326a0d3c1 100644 --- a/src/statuseffect.h +++ b/src/statuseffect.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp new file mode 100644 index 000000000..d3caa8938 --- /dev/null +++ b/src/test/testlauncher.cpp @@ -0,0 +1,172 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. + */ + +#include "test/testlauncher.h" + +#include "client.h" +#include "configuration.h" +#include "graphics.h" +#include "localconsts.h" +#include "logger.h" +#include "sound.h" + +#include "gui/theme.h" + +#include "utils/gettext.h" +#include "utils/mkdir.h" +#include "utils/stringutils.h" + +#include "resources/image.h" +#include "resources/wallpaper.h" + +#include <unistd.h> + +#ifdef WIN32 +#include <windows.h> +#define sleep(seconds) Sleep((seconds) * 1000) +#endif + +//#include <unistd.h> + +#include "debug.h" + +TestLauncher::TestLauncher(std::string test) : + mTest(test) +{ + file.open((Client::getLocalDataDirectory() + + std::string("/test.log")).c_str(), std::ios::out); +} + +TestLauncher::~TestLauncher() +{ + file.close(); +} + +int TestLauncher::exec() +{ + if (mTest == "1" || mTest == "2" || mTest == "3") + return testBackend(); + else if (mTest == "4") + return testSound(); + else if (mTest == "5" || mTest == "6" || mTest == "7") + return testRescale(); + else if (mTest == "8" || mTest == "9" || mTest == "10") + return testFps(); + + return -1; +} + +int TestLauncher::testBackend() +{ + Image *img = Theme::getImageFromTheme("graphics/sprites/arrow_up.gif"); + if (!img) + return 1; + int cnt = 100; + + for (int f = 0; f < cnt; f ++) + { + mainGraphics->drawImage(img, cnt * 7, cnt * 5); + mainGraphics->updateScreen(); + } + + sleep(1); + return 0; +} + +int TestLauncher::testSound() +{ + sound.playGuiSfx("system/newmessage.ogg"); + sleep(1); + sound.playSfx("system/newmessage.ogg", 0, 0); + sound.playMusic("sfx/system/newmessage.ogg"); + sleep(3); + sound.stopMusic(); + return 0; +} + +int TestLauncher::testRescale() +{ + Wallpaper::loadWallpapers(); + const std::string wallpaperName = Wallpaper::getWallpaper(800, 600); + volatile Image *img = Theme::getImageFromTheme(wallpaperName); + if (!img) + return 1; + + sleep(1); + return 0; +} + +int TestLauncher::testFps() +{ + timeval start; + timeval end; + + Wallpaper::loadWallpapers(); + Wallpaper::getWallpaper(800, 600); + Image *img[4]; + + img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_up.gif"); + img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_down.gif"); + img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_left.gif"); + img[3] = Theme::getImageFromTheme("graphics/sprites/arrow_right.gif"); + int idx = 0; + + int cnt = 500; + + gettimeofday(&start, nullptr); + for (int k = 0; k < cnt; k ++) + { + for (int x = 0; x < 800; x += 20) + { + for (int y = 0; y < 600; y += 25) + { + mainGraphics->drawImage(img[idx], x, y); + idx ++; + if (idx > 3) + idx = 0; + } + } + mainGraphics->updateScreen(); + } + + gettimeofday(&end, nullptr); + int tFps = calcFps(&start, &end, cnt); + file << mTest << std::endl; + file << tFps << std::endl; + + sleep(1); + return 0; +} + +int TestLauncher::calcFps(timeval *start, timeval *end, int calls) +{ + long mtime; + long seconds; + long useconds; + + seconds = end->tv_sec - start->tv_sec; + useconds = end->tv_usec - start->tv_usec; + + mtime = (seconds * 1000 + useconds / 1000.0) + 0.5; + if (mtime == 0) + return 100000; + + return static_cast<long>(calls) * 1000 / mtime; +} diff --git a/src/test/testlauncher.h b/src/test/testlauncher.h new file mode 100644 index 000000000..b1031a9c1 --- /dev/null +++ b/src/test/testlauncher.h @@ -0,0 +1,54 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_TESTLAUNCHER_H +#define TEST_TESTLAUNCHER_H + +#include "logger.h" + +#include <string> +#include <sys/time.h> + +class TestLauncher +{ + public: + TestLauncher(std::string test); + + ~TestLauncher(); + + int exec(); + + int calcFps(timeval *start, timeval *end, int calls); + + int testBackend(); + + int testSound(); + + int testRescale(); + + int testFps(); + + private: + std::string mTest; + + std::ofstream file; +}; + +#endif // TEST_TESTLAUNCHER_H diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp new file mode 100644 index 000000000..70fcfc346 --- /dev/null +++ b/src/test/testmain.cpp @@ -0,0 +1,287 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. + */ + +#include "test/testmain.h" + +#include "utils/gettext.h" + +#include "client.h" +#include "configuration.h" +#include "localconsts.h" + +#include "utils/gettext.h" +#include "utils/mkdir.h" +#include "utils/stringutils.h" +#include "utils/process.h" + +#include <iostream> + +#include "debug.h" + +std::string fileName = ""; +extern char *selfName; + +TestMain::TestMain() +{ +#ifdef WIN32 + fileName = "manaplus.exe"; +#else + fileName = selfName; +#endif + + log = new Logger; +// log->setLogFile(Client::getLocalDataDirectory() +// + std::string("/test.log")); + log->setLogFile(Client::getLocalDataDirectory() + + std::string("/manaplustest.log")); +} + +void TestMain::initConfig() +{ + config.init(Client::getConfigDirectory() + "/test.xml"); +// config.setDefaultValues(getConfigDefaults()); + + config.setValue("hwaccel", false); + config.setValue("screen", false); + config.setValue("sound", false); + config.setValue("guialpha", 0.8f); + config.setValue("remember", true); + config.setValue("sfxVolume", 50); + config.setValue("musicVolume", 60); + config.setValue("fpslimit", 0); + config.setValue("customcursor", true); + config.setValue("useScreenshotDirectorySuffix", true); + config.setValue("ChatLogLength", 128); + config.setValue("screenwidth", 800); + config.setValue("screenheight", 600); +} + +int TestMain::exec() +{ + initConfig(); + int softwareTest = invokeSoftwareRenderTest("1"); + int fastOpenGLTest = invokeFastOpenGLRenderTest("2"); + int safeOpenGLTest = invokeSafeOpenGLRenderTest("3"); + int soundTest = invokeTest4(); + int rescaleTest[3]; + int softFps = 0; + int fastOpenGLFps = 0; + int safeOpenGLFps = 0; + + int openGLMode = 0; + int maxFps = 0; + rescaleTest[0] = -1; + rescaleTest[1] = -1; + rescaleTest[2] = -1; + std::string info; + + info += strprintf("%d.%d,%d,%d.", soundTest, softwareTest, + fastOpenGLTest, safeOpenGLTest); + + if (!softwareTest) + { + int softFpsTest = invokeSoftwareRenderTest("8"); + info += strprintf ("%d", softFpsTest); + if (!softFpsTest) + { + softFps = readValue(8); + info += strprintf (",%d", softFps); + if (!softFps) + { + softwareTest = -1; + softFpsTest = -1; + } + else + { + rescaleTest[0] = invokeSoftwareRenderTest("5"); + info += strprintf (",%d", rescaleTest[0]); + } + } + else + { + softwareTest = -1; + } + } + info += "."; + if (!fastOpenGLTest) + { + int fastOpenGLFpsTest = invokeFastOpenGLRenderTest("9"); + info += strprintf ("%d", fastOpenGLFpsTest); + if (!fastOpenGLFpsTest) + { + fastOpenGLFps = readValue(9); + info += strprintf (",%d", fastOpenGLFps); + if (!fastOpenGLFps) + { + fastOpenGLTest = -1; + fastOpenGLFpsTest = -1; + } + else + { + rescaleTest[1] = invokeFastOpenGLRenderTest("6"); + info += strprintf (",%d", rescaleTest[1]); + } + } + else + { + fastOpenGLTest = -1; + } + } + info += "."; + if (!safeOpenGLTest) + { + int safeOpenGLFpsTest = invokeSafeOpenGLRenderTest("10"); + info += strprintf ("%d", safeOpenGLFpsTest); + if (!safeOpenGLFpsTest) + { + safeOpenGLFps = readValue(10); + info += strprintf (",%d", safeOpenGLFps); + if (!safeOpenGLFps) + { + safeOpenGLTest = -1; + safeOpenGLFpsTest = -1; + } + else + { + rescaleTest[2] = invokeSafeOpenGLRenderTest("7"); + info += strprintf (",%d", rescaleTest[2]); + } + } + else + { + safeOpenGLTest = -1; + } + } + info += "."; + + maxFps = softFps; + if (maxFps < fastOpenGLFps) + { + openGLMode = 1; + maxFps = fastOpenGLFps; + } + if (maxFps < safeOpenGLFps) + { + openGLMode = 2; + maxFps = safeOpenGLFps; + } + + writeConfig(openGLMode, rescaleTest[openGLMode], soundTest, info); + return 0; +} + +void TestMain::writeConfig(int openGLMode, int rescale, + int sound, std::string info) +{ + config.init(Client::getConfigDirectory() + "/config.xml"); + + // searched values + config.setValue("opengl", openGLMode); + config.setValue("showBackground", !rescale); + config.setValue("sound", !sound); + + // better perfomance + config.setValue("hwaccel", true); + config.setValue("fpslimit", 60); + config.setValue("altfpslimit", 2); + config.setValue("safemode", false); + config.setValue("enableMapReduce", true); + + // stats + config.setValue("testInfo", info); + + config.write(); +} + +int TestMain::readValue(int ver, int def) +{ + std::string tmp; + int var; + file.open((Client::getLocalDataDirectory() + + std::string("/test.log")).c_str(), std::ios::in); + if (!getline(file, tmp)) + { + file.close(); + return def; + } + var = atoi(tmp.c_str()); + if (ver != var || !getline(file, tmp)) + { + file.close(); + return def; + } + def = atoi(tmp.c_str()); + file.close(); + log->log("value for %d = %d", ver, def); + return def; +} + +int TestMain::invokeTest(std::string test) +{ + config.setValue("opengl", 0); + + config.write(); + int ret = execFile(fileName, fileName, "-t", test); + return ret; +} + +int TestMain::invokeTest4() +{ + config.setValue("sound", true); + int ret = invokeTest("4"); + + log->log("4: %d", ret); + return ret; +} + +int TestMain::invokeSoftwareRenderTest(std::string test) +{ + config.setValue("opengl", 0); + config.write(); + int ret = execFile(fileName, fileName, "-t", test, 30); + log->log("%s: %d", test.c_str(), ret); + return ret; +} + +int TestMain::invokeFastOpenGLRenderTest(std::string test) +{ +#if defined USE_OPENGL + config.setValue("opengl", 1); + config.write(); + int ret = execFile(fileName, fileName, "-t", test, 30); + log->log("%s: %d", test.c_str(), ret); + return ret; +#else + return -1; +#endif +} + +int TestMain::invokeSafeOpenGLRenderTest(std::string test) +{ +#if defined USE_OPENGL + config.setValue("opengl", 2); + config.write(); + int ret = execFile(fileName, fileName, "-t", test, 30); + log->log("%s: %d", test.c_str(), ret); + return ret; +#else + return -1; +#endif +} diff --git a/src/test/testmain.h b/src/test/testmain.h new file mode 100644 index 000000000..8e5ce162f --- /dev/null +++ b/src/test/testmain.h @@ -0,0 +1,64 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef TEST_TESTMAIN_H +#define TEST_TESTMAIN_H + +#include "logger.h" + +#include <string> + +class TestMain +{ + public: + TestMain(); + + int exec(); + + private: + void initConfig(); + + int readValue(int ver, int def = 0); + + int invokeTest(std::string test); + + int invokeTest3(); + + int invokeTest4(); + + int invokeTest7(); + + int invokeSoftwareRenderTest(std::string test); + + int invokeFastOpenGLRenderTest(std::string test); + + int invokeSafeOpenGLRenderTest(std::string test); + + void testsMain(); + + void writeConfig(int openGLMode, int rescale, + int sound, std::string info); + + Logger *log; + + std::ifstream file; +}; + +#endif // TEST_TESTMAIN_H diff --git a/src/text.cpp b/src/text.cpp index bb480811f..4d54dd431 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/text.h b/src/text.h index 2b0eaa97b..25fbe66f0 100644 --- a/src/text.h +++ b/src/text.h @@ -3,7 +3,7 @@ * Copyright (C) 2008 Douglas Boffey <DougABoffey@netscape.net> * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -26,6 +26,7 @@ #include "graphics.h" #include "guichanfwd.h" +#include "localconsts.h" #include <guichan/color.hpp> @@ -42,7 +43,7 @@ class Text Text(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color *color, bool isSpeech = false, - gcn::Font *font = 0); + gcn::Font *font = nullptr); /** * Destructor. The text is removed from the screen. @@ -90,7 +91,7 @@ class FlashText : public Text FlashText(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color* color, - gcn::Font *font = 0); + gcn::Font *font = nullptr); /** * Remove the text from the screen diff --git a/src/textparticle.cpp b/src/textparticle.cpp index 02cc97459..d8c0b7a8e 100644 --- a/src/textparticle.cpp +++ b/src/textparticle.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/textparticle.h b/src/textparticle.h index b37f25732..c85aff476 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2006-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/textrenderer.h b/src/textrenderer.h index 8fe2c5954..9309c5415 100644 --- a/src/textrenderer.h +++ b/src/textrenderer.h @@ -2,7 +2,7 @@ * Text Renderer * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/tileset.h b/src/tileset.h index 0867e5716..c21d6948a 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/units.cpp b/src/units.cpp index edf9c749a..804512dbd 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -2,7 +2,7 @@ * Support for custom units * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -100,9 +100,9 @@ void Units::loadUnits() } XML::Document doc("units.xml"); - xmlNodePtr root = doc.rootNode(); + XmlNodePtr root = doc.rootNode(); - if (!root || !xmlStrEqual(root->name, BAD_CAST "units")) + if (!root || !xmlNameEqual(root, "units")) { logger->log1("Error loading unit definition file: units.xml"); return; @@ -110,7 +110,7 @@ void Units::loadUnits() for_each_xml_child_node(node, root) { - if (xmlStrEqual(node->name, BAD_CAST "unit")) + if (xmlNameEqual(node, "unit")) { struct UnitDescription ud; int level = 1; @@ -127,7 +127,7 @@ void Units::loadUnits() for_each_xml_child_node(uLevel, node) { - if (xmlStrEqual(uLevel->name, BAD_CAST "level")) + if (xmlNameEqual(uLevel, "level")) { struct UnitLevel ul; ul.symbol = XML::getProperty(uLevel, "symbol", diff --git a/src/units.h b/src/units.h index 7705a9bd4..ba1f720e3 100644 --- a/src/units.h +++ b/src/units.h @@ -2,7 +2,7 @@ * Support for custom units * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 843a0b534..24a3a58e3 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -108,7 +108,8 @@ unsigned char *php3_base64_decode(const unsigned char *string, /* run through the whole string, converting as we go */ while ((ch = *current++) != '\0') { - if (ch == base64_pad) break; + if (ch == base64_pad) + break; /* When Base64 gets POSTed, all pluses are interpreted as spaces. This line changes them back. It's not exactly the Base64 spec, diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 3e37afd9d..3e9e09a5c 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -407,8 +407,17 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) return false; } +bool runxsel(std::string& text, const char *p1, const char *p2 = nullptr); + bool sendBuffer(std::string& text) { + runxsel(text, "-i"); + runxsel(text, "-b", "-i"); + return true; +} + +bool runxsel(std::string& text, const char *p1, const char *p2) +{ pid_t pid; int fd[2]; @@ -432,7 +441,11 @@ bool sendBuffer(std::string& text) } close(fd[0]); } - execl("/usr/bin/xsel", "xsel", "-i", (char *)nullptr); + if (p2) + execl("/usr/bin/xsel", "xsel", p1, p2, (char *)nullptr); + else + execl("/usr/bin/xsel", "xsel", p1, (char *)nullptr); + exit(1); } diff --git a/src/utils/dtor.h b/src/utils/dtor.h index fbe903ced..54fa11549 100644 --- a/src/utils/dtor.h +++ b/src/utils/dtor.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/gettext.h b/src/utils/gettext.h index 696f0d4bf..8bb41a4cb 100644 --- a/src/utils/gettext.h +++ b/src/utils/gettext.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h index 40a9e5d79..9f6818146 100644 --- a/src/utils/mathutils.h +++ b/src/utils/mathutils.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp index 84c205b33..582c9c7dc 100644 --- a/src/utils/mkdir.cpp +++ b/src/utils/mkdir.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -43,6 +43,7 @@ int mkdir_r(const char *pathname) { char tmp[PATH_MAX]; + char tmp2[PATH_MAX]; char *p; if (strlen(pathname) >= PATH_MAX - 2) @@ -72,9 +73,13 @@ int mkdir_r(const char *pathname) continue; } + strcpy(tmp2, tmp); + char *p2 = tmp2 + strlen(tmp2) - 1; + if (*p2 == '/' || *p2 == '\\') + *p2 = 0; // check if the name already exists, but not as directory struct stat statbuf; - if (!stat(tmp, &statbuf)) + if (!stat(tmp2, &statbuf)) { if (S_ISDIR(statbuf.st_mode)) { @@ -85,13 +90,12 @@ int mkdir_r(const char *pathname) return -1; } - if (!CreateDirectory(tmp, 0)) + if (!CreateDirectory(tmp2, 0)) { // hack, hack. just assume that x: might be a drive // letter, and try again - if (!(strlen(tmp) == 2 && - !strcmp(tmp + 1, ":"))) - return -1; + if (!(strlen(tmp2) == 2 && !strcmp(tmp2 + 1, ":"))) + return -1; } #ifdef M_MKDIR_TEST_ diff --git a/src/utils/mkdir.h b/src/utils/mkdir.h index deff75475..8c5ab4ca2 100644 --- a/src/utils/mkdir.h +++ b/src/utils/mkdir.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/mutex.h b/src/utils/mutex.h index 03dac2e7a..a97a8d3f8 100644 --- a/src/utils/mutex.h +++ b/src/utils/mutex.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index 3cc35cb55..8decb6e95 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -43,6 +43,8 @@ std::string getRealPath(const std::string &str) #else char *realPath = realpath(str.c_str(), nullptr); #endif + if (!realPath) + return ""; path = realPath; free(realPath); return path; diff --git a/src/utils/paths.h b/src/utils/paths.h index 1723bf6c4..804900587 100644 --- a/src/utils/paths.h +++ b/src/utils/paths.h @@ -1,6 +1,6 @@ /* * The ManaPlus Client - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/process.cpp b/src/utils/process.cpp new file mode 100644 index 000000000..4a2081514 --- /dev/null +++ b/src/utils/process.cpp @@ -0,0 +1,172 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. + */ + +#include "utils/process.h" + +#include <string.h> +#include <cstdarg> +#include <cstdio> + +#include <stdlib.h> +#include <unistd.h> + +#include "localconsts.h" + +#include "debug.h" + +const int timeOut = 10; + +#ifdef WIN32 + +#include <windows.h> + +int execFile(std::string pathName, std::string name, + std::string arg1, std::string arg2, int waitTime) +{ + if (!waitTime) + waitTime = timeOut; + + STARTUPINFO siStartupInfo; + PROCESS_INFORMATION piProcessInfo; + memset(&siStartupInfo, 0, sizeof(siStartupInfo)); + memset(&piProcessInfo, 0, sizeof(piProcessInfo)); + siStartupInfo.cb = sizeof(siStartupInfo); + DWORD ret = -1; + std::string args(pathName + " " + arg1); + if (!arg2.empty()) + args += " " + arg2; + + if (CreateProcess(pathName.c_str(), (char*)args.c_str(), 0, 0, false, + CREATE_DEFAULT_ERROR_MODE, 0, 0, &siStartupInfo, + &piProcessInfo) != false) + { + if (!WaitForSingleObject(piProcessInfo.hProcess, timeOut * 1000)) + { + if (GetExitCodeProcess(piProcessInfo.hProcess, &ret)) + { + CloseHandle(piProcessInfo.hProcess); + CloseHandle(piProcessInfo.hThread); + return ret; + } + } + TerminateProcess(piProcessInfo.hProcess, -1); + } + + CloseHandle(piProcessInfo.hProcess); + CloseHandle(piProcessInfo.hThread); + return -1; +} + +#elif defined(__APPLE__) + +int execFile(std::string pathName, std::string name, + std::string arg1, std::string arg2, int waitTime) +{ + return -1; +} + +#elif defined __linux__ || defined __linux + +#include <sys/types.h> +#include <sys/wait.h> + +int execFile(std::string pathName, std::string name, + std::string arg1, std::string arg2, int waitTime) +{ + pid_t mon_pid; + int status; + + if (!waitTime) + waitTime = timeOut; + + if ((mon_pid = fork()) == -1) + { // fork error + return -1; + } + else if (!mon_pid) + { // monitoring child + pid_t pid; + if ((pid = fork()) == -1) + { // fork error + return -1; + } + else if (!pid) + { // work child + if (arg2.empty()) + { + execl(pathName.c_str(), name.c_str(), + arg1.c_str(), (char *)nullptr); + } + else + { + execl(pathName.c_str(), name.c_str(), + arg1.c_str(), arg2.c_str(), (char *)nullptr); + } + exit(-1); + } + + // monitoring process + pid_t sleep_pid; + if ((sleep_pid = fork()) == -1) + { // fork error + return -1; + } + else if (!sleep_pid) + { // sleep pid + sleep (timeOut); +// printf ("time out\n"); + exit(-1); + } + + // monitoring process + pid_t exited_pid = wait(&status); + int ret = -1; + if (exited_pid == pid) + { + kill(sleep_pid, SIGKILL); + if (WIFEXITED(status)) + ret = WEXITSTATUS(status); + } + else + { + kill(pid, SIGKILL); + ret = -1; + } + wait(nullptr); + exit(ret); + } + + // monitoring parent + waitpid(mon_pid, &status, 0); + if (WIFEXITED(status)) + return WEXITSTATUS(status); + + return -1; +} + +#else + +int execFile(std::string pathName, std::string name, + std::string arg1, std::string arg2, int waitTime) +{ + return -1; +} + +#endif diff --git a/src/utils/process.h b/src/utils/process.h new file mode 100644 index 000000000..12421729f --- /dev/null +++ b/src/utils/process.h @@ -0,0 +1,29 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef UTILS_PROCESS_H +#define UTILS_PROCESS_H + +#include <string> + +int execFile(std::string pathName, std::string name, + std::string arg1, std::string arg2, int waitTime = 0); + +#endif // UTILS_PROCESS_H diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index 523c021a4..ac9c78b2a 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file has been slighly modified as part of The ManaPlus Client. * diff --git a/src/utils/sha256.h b/src/utils/sha256.h index aa2468d56..54bb92f3c 100644 --- a/src/utils/sha256.h +++ b/src/utils/sha256.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/specialfolder.cpp b/src/utils/specialfolder.cpp index fae0fbf47..9690a9fb7 100644 --- a/src/utils/specialfolder.cpp +++ b/src/utils/specialfolder.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/specialfolder.h b/src/utils/specialfolder.h index 571817370..8eb00a637 100644 --- a/src/utils/specialfolder.h +++ b/src/utils/specialfolder.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 39f14a646..b855e3b04 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -612,3 +612,13 @@ std::string &removeProtocol(std::string &url) url = url.substr(i + 3); return url; } + +bool checkPath(std::string path) +{ + if (path.empty()) + return true; + return path.find("../") == std::string::npos + && path.find("..\\") == std::string::npos + && path.find("/..") == std::string::npos + && path.find("\\..") == std::string::npos; +} diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 273fa0c8c..c6eb08a6c 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -206,4 +206,6 @@ bool findCutFirst(std::string &str1, std::string str2); std::string &removeProtocol(std::string &url); +bool checkPath(std::string path); + #endif // UTILS_STRINGUTILS_H diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 10436067f..420915d8f 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -32,6 +32,11 @@ #include "debug.h" +static void xmlNullLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...) +{ + // Does nothing, that's the whole point of it +} + namespace XML { Document::Document(const std::string &filename, bool useResman): @@ -96,12 +101,12 @@ namespace XML xmlFreeDoc(mDoc); } - xmlNodePtr Document::rootNode() + XmlNodePtr Document::rootNode() { return mDoc ? xmlDocGetRootElement(mDoc) : nullptr; } - int getProperty(xmlNodePtr node, const char* name, int def) + int getProperty(XmlNodePtr node, const char* name, int def) { int &ret = def; @@ -115,7 +120,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; @@ -129,7 +134,7 @@ namespace XML return ret; } - std::string getProperty(xmlNodePtr node, const char *name, + std::string getProperty(XmlNodePtr node, const char *name, const std::string &def) { xmlChar *prop = xmlGetProp(node, BAD_CAST name); @@ -143,7 +148,7 @@ namespace XML return def; } - bool getBoolProperty(xmlNodePtr node, const char* name, bool def) + bool getBoolProperty(XmlNodePtr node, const char* name, bool def) { xmlChar *prop = xmlGetProp(node, BAD_CAST name); @@ -154,15 +159,32 @@ namespace XML return def; } - xmlNodePtr findFirstChildByName(xmlNodePtr parent, const char *name) + XmlNodePtr findFirstChildByName(XmlNodePtr parent, const char *name) { for_each_xml_child_node(child, parent) { - if (xmlStrEqual(child->name, BAD_CAST name)) + if (xmlNameEqual(child, name)) return child; } return nullptr; } + // Initialize libxml2 and check for potential ABI mismatches between + // compiled version and the shared library actually used. + void initXML() + { + xmlInitParser(); + LIBXML_TEST_VERSION; + + // Suppress libxml2 error messages + xmlSetGenericErrorFunc(nullptr, xmlNullLogger); + } + + // Shutdown libxml + void cleanupXML() + { + xmlCleanupParser(); + } + } // namespace XML diff --git a/src/utils/xml.h b/src/utils/xml.h index 7bcec2c83..f623fa618 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2004-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -23,10 +23,16 @@ #ifndef XML_H #define XML_H +#include <libxml/encoding.h> +#include <libxml/xmlwriter.h> #include <libxml/tree.h> #include <string> +#define XmlNodePtr xmlNodePtr +#define xmlNameEqual(node, str) xmlStrEqual((node)->name, BAD_CAST (str)) +#define XmlTextWriterPtr xmlTextWriterPtr + /** * XML helper functions. */ @@ -63,40 +69,44 @@ namespace XML * Returns the root node of the document (or NULL if there was a * load error). */ - xmlNodePtr rootNode(); + XmlNodePtr rootNode(); private: xmlDocPtr mDoc; }; /** - * Gets an floating point property from an xmlNodePtr. + * 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 an integer property from an xmlNodePtr. + * 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 a string property from an xmlNodePtr. + * Gets a string property from an XmlNodePtr. */ - std::string getProperty(xmlNodePtr node, const char *name, + std::string getProperty(XmlNodePtr node, const char *name, const std::string &def); /** - * Gets a boolean property from an xmlNodePtr. + * Gets a boolean property from an XmlNodePtr. */ - bool getBoolProperty(xmlNodePtr node, const char *name, bool def); + bool getBoolProperty(XmlNodePtr node, const char *name, bool def); /** * Finds the first child node with the given name */ - xmlNodePtr findFirstChildByName(xmlNodePtr parent, const char *name); + XmlNodePtr findFirstChildByName(XmlNodePtr parent, const char *name); + + void initXML(); + + void cleanupXML(); } #define for_each_xml_child_node(var, parent) \ - for (xmlNodePtr var = parent->xmlChildrenNode; var; var = var->next) + for (XmlNodePtr var = parent->xmlChildrenNode; var; var = var->next) #endif // XML_H diff --git a/src/variabledata.h b/src/variabledata.h index 73eca2198..e5516bd9f 100644 --- a/src/variabledata.h +++ b/src/variabledata.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/vector.cpp b/src/vector.cpp index c234dea4c..e134a777a 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * diff --git a/src/vector.h b/src/vector.h index 0f10bae96..744b235c0 100644 --- a/src/vector.h +++ b/src/vector.h @@ -2,7 +2,7 @@ * The ManaPlus Client * Copyright (C) 2007-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers + * Copyright (C) 2011-2012 The ManaPlus Developers * * This file is part of The ManaPlus Client. * |