diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-10-17 22:07:24 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-10-17 22:07:24 +0300 |
commit | d14bb7a27ee23cc83b3af1db2f1976eaaa55d78a (patch) | |
tree | 5f128768c66436eefd70632f02889607596609d4 /src | |
parent | f1e92aca00a4859047e83fab76220767b9a2f814 (diff) | |
parent | e93e6beb456d105987da3190c2a80847b6900081 (diff) | |
download | manaverse-d14bb7a27ee23cc83b3af1db2f1976eaaa55d78a.tar.gz manaverse-d14bb7a27ee23cc83b3af1db2f1976eaaa55d78a.tar.bz2 manaverse-d14bb7a27ee23cc83b3af1db2f1976eaaa55d78a.tar.xz manaverse-d14bb7a27ee23cc83b3af1db2f1976eaaa55d78a.zip |
Merge branch 'master' into strippedstripped1.1.10.16
Conflicts:
data/fonts/mplus-1p-bold.ttf
data/fonts/mplus-1p-regular.ttf
Diffstat (limited to 'src')
69 files changed, 483 insertions, 333 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 827d46f29..cc18cfbee 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -118,7 +118,21 @@ class SortBeingFunctor return w1 < w2; } if (being1->getDistance() != being2->getDistance()) + { + if (specialDistance && being1->getDistance() <= 2 + && being2->getDistance() <= attackRange + && being2->getDistance() > 2) + { + return false; + } + else if (specialDistance && being2->getDistance() <= 2 + && being1->getDistance() <= attackRange + && being1->getDistance() > 2) + { + return true; + } return being1->getDistance() < being2->getDistance(); + } int d1, d2; #ifdef MANASERV_SUPPORT @@ -164,7 +178,8 @@ class SortBeingFunctor int defaultAttackIndex; std::map<std::string, int> *priorityBeings; int defaultPriorityIndex; - + bool specialDistance; + int attackRange; } beingSorter; ActorSpriteManager::ActorSpriteManager() : @@ -764,6 +779,14 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, std::map<std::string, int> priorityMobsMap; int defaultAttackIndex = 10000; int defaultPriorityIndex = 10000; + const int attackRange = player_node->getAttackRange(); + + bool specialDistance = false; + if (player_node->getMoveToTargetType() == 7 + && player_node->getAttackRange() > 2) + { + specialDistance = true; + } maxDist = maxDist * maxDist; @@ -783,6 +806,8 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, priorityMobsMap = mPriorityAttackMobsMap; beingSorter.attackBeings = &attackMobsMap; beingSorter.priorityBeings = &priorityMobsMap; + beingSorter.specialDistance = specialDistance; + beingSorter.attackRange = attackRange; if (ignoreAttackMobs.find("") != ignoreAttackMobs.end()) ignoreDefault = true; std::map<std::string, int>::const_iterator @@ -861,8 +886,15 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, if (player_node->getTarget() == NULL) { - // if no selected being, return first nearest being - return sortedBeings.at(0); + Being *target = sortedBeings.at(0); + + if (specialDistance && target->getType() == Being::MONSTER + && target->getDistance() <= 2) + { + return 0; + } + // if no selected being in vector, return first nearest being + return target; } beingEqualFinder.findBeing = player_node->getTarget(); @@ -928,6 +960,12 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, if (!valid) continue; + if (specialDistance && being->getDistance() <= 2 + && being->getType() == Being::MONSTER) + { + continue; + } + // logger->log("being name:" + being->getName()); // logger->log("index:" + toString(index)); // logger->log("d:" + toString(d)); diff --git a/src/being.cpp b/src/being.cpp index 2ed05449a..5eac242fd 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -229,6 +229,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): mGender(GENDER_UNSPECIFIED), mParty(0), mIsGM(false), + mAttackRange(1), mType(type), mX(0), mY(0), mDamageTaken(0), @@ -1623,7 +1624,9 @@ void Being::updateColors() mNameColor = &userPalette->getColor(UserPalette::FRIEND); } else if (player_relations.getRelation(mName) == - PlayerRelation::DISREGARDED) + PlayerRelation::DISREGARDED + || player_relations.getRelation(mName) == + PlayerRelation::BLACKLISTED) { mNameColor = &userPalette->getColor(UserPalette::DISREGARDED); } @@ -1992,7 +1995,11 @@ bool Being::drawSpriteAt(Graphics *graphics, int x, int y) const if (mHighlightMonsterAttackRange && mType == ActorSprite::MONSTER && isAlive()) { - const int attackRange = 32; + int attackRange; + if (mAttackRange) + attackRange = 32 * mAttackRange; + else + attackRange = 32; graphics->setColor(userPalette->getColorWithAlpha( UserPalette::MONSTER_ATTACK_RANGE)); diff --git a/src/being.h b/src/being.h index 2c37ffeb5..9b38e1479 100644 --- a/src/being.h +++ b/src/being.h @@ -540,7 +540,7 @@ class Being : public ActorSprite, public ConfigListener const Path &getPath() const { return mPath; } - int getDistance() + int getDistance() const { return mDistance; } void setDistance(int n) @@ -755,6 +755,18 @@ class Being : public ActorSprite, public ConfigListener bool isShopEnabled() { return mShop; } + /** + * Sets the attack range. + */ + void setAttackRange(int range) + { mAttackRange = range; } + + void attack(Being *target = NULL, bool keep = false, + bool dontChangeEquipment = false); + + void attack2(Being *target = NULL, bool keep = false, + bool dontChangeEquipment = false); + protected: /** * Sets the new path for this being. @@ -823,6 +835,7 @@ class Being : public ActorSprite, public ConfigListener Party *mParty; bool mIsGM; + int mAttackRange; private: diff --git a/src/client.cpp b/src/client.cpp index 8497d337b..c90d1886f 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1145,7 +1145,7 @@ int Client::exec() { logger->log("Memorizing selected character %s", player_node->getName().c_str()); - config.setValue("lastCharacter", + serverConfig.setValue("lastCharacter", player_node->getName()); if (mumbleManager) mumbleManager->setPlayer(player_node->getName()); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 189485461..f1b7518c5 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -112,6 +112,8 @@ void CommandHandler::handleCommand(const std::string &command, ChatTab *tab) handleDisregard(args, tab); else if (type == "neutral") handleNeutral(args, tab); + else if (type == "blacklist") + handleBlackList(args, tab); else if (type == "erase") handleErase(args, tab); else if (type == "join") @@ -523,9 +525,10 @@ void CommandHandler::handleUnignore(const std::string &args, ChatTab *tab) return; } - if (player_relations.getRelation(args) == PlayerRelation::IGNORED) + if (player_relations.getRelation(args) != PlayerRelation::NEUTRAL + && player_relations.getRelation(args) != PlayerRelation::FRIEND) { - player_relations.removePlayer(args); + player_relations.setRelation(args, PlayerRelation::NEUTRAL); } else { @@ -536,13 +539,17 @@ void CommandHandler::handleUnignore(const std::string &args, ChatTab *tab) if (tab) { - if (player_relations.getRelation(args) != PlayerRelation::IGNORED) + if (player_relations.getRelation(args) == PlayerRelation::NEUTRAL) tab->chatLog(_("Player no longer ignored!"), BY_SERVER); else tab->chatLog(_("Player could not be unignored!"), BY_SERVER); } } +void CommandHandler::handleBlackList(const std::string &args, ChatTab *tab) +{ + changeRelation(args, PlayerRelation::BLACKLISTED, _("blacklisted"), tab); +} void CommandHandler::handleErase(const std::string &args, ChatTab *tab) { diff --git a/src/commandhandler.h b/src/commandhandler.h index 64f0288c3..52080dfcd 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -172,6 +172,11 @@ class CommandHandler void handleNeutral(const std::string &args, ChatTab *tab); /** + * Handle an blacklist command. + */ + void handleBlackList(const std::string &args, ChatTab *tab); + + /** * Handle an erase command. */ void handleErase(const std::string &args, ChatTab *tab); diff --git a/src/defaults.cpp b/src/defaults.cpp index d7fa07a07..c5397a7d5 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -97,7 +97,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "imitationMode", 0); AddDEF(configData, "syncPlayerMove", false); AddDEF(configData, "drawPath", false); - AddDEF(configData, "moveToTargetType", 0); + AddDEF(configData, "moveToTargetType", 6); AddDEF(configData, "crazyMoveProgram", "mumrsonmdmlon"); AddDEF(configData, "disableGameModifiers", false); AddDEF(configData, "targetDeadPlayers", false); @@ -219,6 +219,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "seflMouseHeal", true); AddDEF(configData, "enableLazyScrolling", true); AddDEF(configData, "extMouseTargeting", true); + AddDEF(configData, "showMVP", false); return configData; } diff --git a/src/game.cpp b/src/game.cpp index 0527e8481..6ed2c2239 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -568,6 +568,7 @@ void Game::logic() map->saveExtraLayer(); } Client::closeDialogs(); + Client::setFramerate(config.getIntValue("fpslimit")); disconnectedDialog = new OkDialog(_("Network Error"), errorMessage, false); disconnectedDialog->addActionListener(&errorListener); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 82d6c2ff5..59bd173bd 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -293,6 +293,7 @@ void ChatWindow::fillCommands() mCommands.push_back("/addpriorityattack "); mCommands.push_back("/removeattack "); mCommands.push_back("/addignoreattack "); + mCommands.push_back("/blacklist "); } void ChatWindow::resetToDefaultSize() diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 16e3d9ec7..d7c7e54df 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -144,12 +144,21 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBrowserBox->addRow("friend", _("Be friend")); mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); + mBrowserBox->addRow("erase", _("Erase")); + break; + + case PlayerRelation::BLACKLISTED: + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); mBrowserBox->addRow("erase", _("Erase")); break; @@ -369,12 +378,21 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mBrowserBox->addRow("friend", _("Be friend")); mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); + mBrowserBox->addRow("erase", _("Erase")); + break; + + case PlayerRelation::BLACKLISTED: + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); mBrowserBox->addRow("erase", _("Erase")); break; @@ -606,12 +624,21 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) mBrowserBox->addRow("friend", _("Be friend")); mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: mBrowserBox->addRow("disregard", _("Disregard")); mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("blacklist", _("Black list")); + mBrowserBox->addRow("erase", _("Erase")); + break; + + case PlayerRelation::BLACKLISTED: + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); mBrowserBox->addRow("erase", _("Erase")); break; @@ -857,6 +884,17 @@ void PopupMenu::handleLink(const std::string &link, { player_relations.setRelation(mNick, PlayerRelation::IGNORED); } + + else if (link == "blacklist" && being && + being->getType() == ActorSprite::PLAYER) + { + player_relations.setRelation(being->getName(), + PlayerRelation::BLACKLISTED); + } + else if (link == "blacklist" && !mNick.empty()) + { + player_relations.setRelation(mNick, PlayerRelation::BLACKLISTED); + } else if (link == "erase" && being && being->getType() == ActorSprite::PLAYER) { diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index 9e75b9c0a..1b8209c8f 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -125,6 +125,9 @@ Setup_Chat::Setup_Chat() new SetupItemTextField(_("Highlight words (separated by comma)"), "", "highlightWords", this, "highlightWordsEvent"); + new SetupItemCheckBox(_("Show MVP messages"), "", + "showMVP", this, "showMVPEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 57a51e435..6c57d981e 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -71,7 +71,8 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = N_("Friend"), N_("Disregarded"), N_("Ignored"), - N_("Erased") + N_("Erased"), + N_("Blacklisted") }; class PlayerRelationListModel : public gcn::ListModel diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 28dbca939..8f45be5d1 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -598,3 +598,11 @@ SkillInfo* SkillDialog::getSkill(int id) { return mSkills[id]; } + +void SkillDialog::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + + if (mTabs) + mTabs->fixSize(); +} diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 55dfafc38..21ee56f5e 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -86,6 +86,8 @@ class SkillDialog : public Window, public gcn::ActionListener bool hasSkills() { return !mSkills.empty(); } + void widgetResized(const gcn::Event &event); + private: typedef std::map<int, SkillInfo*> SkillMap; SkillMap mSkills; diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index ab19e501b..a728d4051 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1632,3 +1632,11 @@ void SocialWindow::updateAttackFilter() if (mAttackFilter) mAttackFilter->updateList(); } + +void SocialWindow::widgetResized(const gcn::Event &event) +{ + Window::widgetResized(event); + + if (mTabs) + mTabs->fixSize(); +} diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index 04692d843..7dc962316 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -123,6 +123,8 @@ public: void updateAttackFilter(); + void widgetResized(const gcn::Event &event); + protected: friend class SocialTab; diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index fee6450df..a0c8e06d4 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -284,6 +284,11 @@ void StatusPopup::updateLabels() _("(A) moves to target in attack range"), keyboard.KEY_CHANGE_MOVE_TO_TARGET); break; + case 7: + setLabelText(mMoveToTargetType, + _("(a) archer attack range"), + keyboard.KEY_CHANGE_MOVE_TO_TARGET); + break; default: setLabelText(mMoveToTargetType, _("(?) move to target"), keyboard.KEY_CHANGE_MOVE_TO_TARGET); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 170fd6ab4..c746eb82d 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -702,6 +702,9 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) case 6: str += translateLetter(N_("(A)")); break; + case 7: + str += translateLetter(N_("(a)")); + break; default: str += translateLetter(N_("(?)")); break; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 461dd581d..97a467add 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -195,8 +195,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) { if (player_x <= 0 || player_y <= 0) { - if (debugChatTab) - debugChatTab->chatLog("incorrect player position!"); +// if (debugChatTab) +// debugChatTab->chatLog("incorrect player position!"); logger->log("incorrect player position: %d, %d, %d, %d", player_x, player_y, (int)mPixelViewX, (int)mPixelViewY); if (player_node) diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index a14e99afc..3fb63a105 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -278,6 +278,7 @@ void WhoIsOnline::loadList() break; case PlayerRelation::DISREGARDED: + case PlayerRelation::BLACKLISTED: disregard.push_back(prepareNick(nick, level, "8")); break; @@ -492,6 +493,7 @@ void WhoIsOnline::logic() setCaption(_("Who Is Online - error")); mUpdateButton->setEnabled(true); mUpdateTimer = cur_time + 240; + updateSize(); break; case UPDATE_LIST: if (mDownloadComplete == true) diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 485e96e74..9a29ae204 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -281,21 +281,15 @@ void ChatTab::chatLog(std::string line, Own own, { if (getFlash() == 0) { - if (player_node) - { - if (chatWindow && chatWindow->findHighlight(tmp.text)) - setFlash(2); - else - setFlash(1); - } + if (chatWindow && chatWindow->findHighlight(tmp.text)) + setFlash(2); else - { setFlash(1); - } } } - if (getAllowHighlight() && (this != getTabbedArea()->getSelectedTab() + if ((getAllowHighlight() || own == BY_GM) + && (this != getTabbedArea()->getSelectedTab() || (Client::getIsMinimized() || (!Client::getMouseFocused() && !Client::getInputFocused())))) { diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 3ad113b4c..af241d7c5 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -153,6 +153,9 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener bool getFollowDownScroll() { return mFollowDownScroll; } + void fixSize() + { adjustSize(); } + private: typedef std::vector< std::pair<gcn::Tab*, gcn::Widget*> > TabContainer; diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 28ffc4cf5..f33a72bb0 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -98,7 +98,6 @@ extern SkillDialog *skillDialog; LocalPlayer::LocalPlayer(int id, int subtype): Being(id, PLAYER, subtype, 0), - mAttackRange(0), mTargetTime(-1), mLastTarget(-1), mTarget(NULL), @@ -130,6 +129,8 @@ LocalPlayer::LocalPlayer(int id, int subtype): { logger->log1("LocalPlayer::LocalPlayer"); + mAttackRange = 0; + listen(Mana::CHANNEL_ATTRIBUTES); mLevel = 1; @@ -1764,6 +1765,7 @@ void LocalPlayer::moveToTarget(unsigned int dist) dist = 7; break; case 6: + case 7: dist = mAttackRange; if (dist == 1) dist = 2; @@ -2946,7 +2948,7 @@ void LocalPlayer::tryMagic(std::string spell, int baseMagic, void LocalPlayer::changeMoveToTargetType() { mMoveToTargetType++; - if (mMoveToTargetType > 6) + if (mMoveToTargetType > 7) mMoveToTargetType = 0; config.setValue("moveToTargetType", mMoveToTargetType); diff --git a/src/localplayer.h b/src/localplayer.h index 447306994..414933e70 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -130,11 +130,6 @@ class LocalPlayer : public Being, public ActorSpriteListener, void actorSpriteDestroyed(const ActorSprite &actorSprite); /** - * Sets the attack range. - */ - void setAttackRange(int range) { mAttackRange = range; } - - /** * Gets the attack range. */ int getAttackRange(); @@ -506,8 +501,6 @@ class LocalPlayer : public Being, public ActorSpriteListener, bool mInStorage; /**< Whether storage is currently accessible */ - int mAttackRange; - int mTargetTime; /** How long the being has been targeted **/ int mLastTarget; /** Time stamp of last targeting action, -1 if none. */ diff --git a/src/main.cpp b/src/main.cpp index 5c13b10ec..5eceee77b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,10 +44,11 @@ static void printHelp() using std::endl; std::cout - << _("manaplus [options] [mana-file]") << endl << endl - << _("[mana-file] : The mana file is an XML file (.mana)") << endl - << _(" used to set custom parameters") << endl - << _(" to the manaplus client.") + << _("manaplus [options] [manaplus-file]") << endl << endl + << _("[manaplus-file] : The manaplus file is an XML file (.manaplus)") + << endl + << _(" used to set custom parameters") << endl + << _(" to the manaplus client.") << endl << endl << _("Options:") << endl << _(" -l --log-file : Log file to use") << endl diff --git a/src/main.h b/src/main.h index 95a1b1698..548c3283f 100644 --- a/src/main.h +++ b/src/main.h @@ -45,12 +45,15 @@ * different interfaces, which have different implementations for each server. */ +#define SMALL_VERSION "1.1.10.16" +#define CHECK_VERSION "01.01.10.16" + #ifdef HAVE_CONFIG_H #include "../config.h" #elif defined WIN32 #include "winver.h" -#elif defined __APPLE__ -#define PACKAGE_VERSION "1.0.0" +#else +#define PACKAGE_VERSION SMALL_VERSION #endif #if defined __APPLE__ @@ -85,10 +88,6 @@ //define DEBUG_ALPHA_CACHE 1 //define DEBUG_OPENGL_LEAKS 1 -#define SMALL_VERSION "1.1.10.2" -#define CHECK_VERSION "01.01.10.02" - - #define PACKAGE_EXTENDED_VERSION "ManaPlus (" PACKAGE_OS \ "; %s; 4144 v" SMALL_VERSION ")" #define PACKAGE_VERSION_4144 "ManaPlus 4144-" SMALL_VERSION "" diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h index d063c4eb1..6899f85f4 100644 --- a/src/net/adminhandler.h +++ b/src/net/adminhandler.h @@ -31,7 +31,8 @@ namespace Net class AdminHandler { public: - virtual ~AdminHandler() {} + virtual ~AdminHandler() + { } virtual void announce(const std::string &text) = 0; diff --git a/src/net/buysellhandler.h b/src/net/buysellhandler.h index ad70c2884..c41e918e1 100644 --- a/src/net/buysellhandler.h +++ b/src/net/buysellhandler.h @@ -38,10 +38,14 @@ class BuySellHandler { } virtual void handleMessage(Net::MessageIn &msg) = 0; + virtual void requestSellList(std::string nick) = 0; + virtual void requestBuyList(std::string nick) = 0; + virtual void sendBuyRequest(std::string nick, ShopItem* item, int amount) = 0; + virtual void sendSellRequest(std::string nick, ShopItem* item, int amount) = 0; }; diff --git a/src/net/charhandler.h b/src/net/charhandler.h index b362a623c..72a81684c 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -91,7 +91,7 @@ class CharHandler virtual unsigned int maxSprite() const = 0; protected: - CharHandler(): + CharHandler() : mSelectedCharacter(0), mCharSelectDialog(0), mCharCreateDialog(0) diff --git a/src/net/chathandler.h b/src/net/chathandler.h index 0553ea0ac..a0e232027 100644 --- a/src/net/chathandler.h +++ b/src/net/chathandler.h @@ -64,8 +64,6 @@ class ChatHandler virtual void who() = 0; virtual void sendRaw(const std::string &args) = 0; - -// virtual ~ChatHandler() {} }; } diff --git a/src/net/download.cpp b/src/net/download.cpp index 93417197e..969318b19 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -49,17 +49,17 @@ namespace Net { Download::Download(void *ptr, const std::string &url, - DownloadUpdate updateFunction, bool ignoreError): - mPtr(ptr), - mUrl(url), - mFileName(""), - mWriteFunction(NULL), - mAdler(0), - mUpdateFunction(updateFunction), - mThread(NULL), - mCurl(NULL), - mHeaders(NULL), - mIgnoreError(ignoreError) + DownloadUpdate updateFunction, bool ignoreError) : + mPtr(ptr), + mUrl(url), + mFileName(""), + mWriteFunction(NULL), + mAdler(0), + mUpdateFunction(updateFunction), + mThread(NULL), + mCurl(NULL), + mHeaders(NULL), + mIgnoreError(ignoreError) { mError = static_cast<char*>(calloc(CURL_ERROR_SIZE + 1, 1)); mError[0] = 0; @@ -72,6 +72,7 @@ Download::~Download() if (mHeaders) curl_slist_free_all(mHeaders); + mHeaders = 0; int status; if (mThread && SDL_GetThreadID(mThread)) SDL_WaitThread(mThread, &status); @@ -261,7 +262,7 @@ int Download::downloadThread(void *ptr) case CURLE_COULDNT_CONNECT: default: logger->log("curl error %d: %s host: %s", - res, d->mError, d->mUrl.c_str()); + res, d->mError, d->mUrl.c_str()); break; } diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h index fcf1e25b2..2e311881f 100644 --- a/src/net/ea/adminhandler.h +++ b/src/net/ea/adminhandler.h @@ -38,7 +38,8 @@ namespace Ea class AdminHandler : public Net::AdminHandler { public: - virtual ~AdminHandler() { } + virtual ~AdminHandler() + { } virtual void kick(const std::string &name); diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 4a5cfb841..8fca76353 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -58,7 +58,7 @@ namespace Ea { const int EMOTION_TIME = 500; /**< Duration of emotion icon */ -BeingHandler::BeingHandler(bool enableSync): +BeingHandler::BeingHandler(bool enableSync) : mSync(enableSync), mSpawnId(0) { @@ -133,8 +133,7 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) speed = msg.readInt16(); stunMode = msg.readInt16(); // opt1 statusEffects = msg.readInt16(); // opt2 - statusEffects |= (static_cast<Uint32>( - msg.readInt16())) << 16; // option + statusEffects |= (static_cast<Uint32>(msg.readInt16())) << 16; // option job = msg.readInt16(); // class dstBeing = actorSpriteManager->findBeing(id); @@ -210,14 +209,22 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) if (dstBeing->getType() == ActorSprite::MONSTER) { - int hp = msg.readInt32(); - int maxHP = msg.readInt32(); - if (hp && maxHP) + if (serverVersion > 0) { - int oldHP = dstBeing->getHP(); - if (!oldHP || oldHP > hp) - dstBeing->setHP(hp); - dstBeing->setMaxHP(maxHP); + int hp = msg.readInt32(); + int maxHP = msg.readInt32(); + if (hp && maxHP) + { + int oldHP = dstBeing->getHP(); + if (!oldHP || oldHP > hp) + dstBeing->setHP(hp); + dstBeing->setMaxHP(maxHP); + } + } + else + { + msg.readInt32(); + msg.readInt32(); } gloves = 0; } @@ -237,19 +244,26 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) msg.readInt16(); // manner dstBeing->setStatusEffectBlock(32, msg.readInt16()); // opt3 - msg.readInt8(); // karma + if (serverVersion > 0 && dstBeing->getType() == ActorSprite::MONSTER) + { + int attackRange = msg.readInt8(); // karma + dstBeing->setAttackRange(attackRange); + } + else + { + msg.readInt8(); // karma + } gender = msg.readInt8(); // reserving bits for future usage - gender &= 1; if (dstBeing->getType() == ActorSprite::PLAYER) { - dstBeing->setGender((gender == 0) - ? GENDER_FEMALE : GENDER_MALE); + gender &= 1; + dstBeing->setGender((gender == 0) ? GENDER_FEMALE : GENDER_MALE); // Set these after the gender, as the sprites may be gender-specific setSprite(dstBeing, EA_SPRITE_HAIR, hairStyle * -1, - ColorDB::getHairColor(hairColor)); + ColorDB::getHairColor(hairColor)); setSprite(dstBeing, EA_SPRITE_BOTTOMCLOTHES, headBottom); setSprite(dstBeing, EA_SPRITE_TOPCLOTHES, headMid); setSprite(dstBeing, EA_SPRITE_HAT, headTop); @@ -283,8 +297,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) dstBeing->setAction(Being::STAND); dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); -// if (player_node && player_node->getTarget() == dstBeing) -// player_node->targetMoved(); } else { @@ -293,7 +305,6 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, bool visible) msg.readCoordinates(x, y, dir); dstBeing->setTileCoords(x, y); - if (job == 45 && socialWindow && outfitWindow) { int num = socialWindow->getPortalIndex(x, y); @@ -379,7 +390,7 @@ void BeingHandler::processBeingRemove(Net::MessageIn &msg) return; player_node->followMoveTo(dstBeing, player_node->getNextDestX(), - player_node->getNextDestY()); + player_node->getNextDestY()); // If this is player's current target, clear it. if (dstBeing == player_node->getTarget()) @@ -464,20 +475,15 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) if (!actorSpriteManager) return; - Being *srcBeing; - Being *dstBeing; - int param1; - int type; - - srcBeing = actorSpriteManager->findBeing(msg.readInt32()); - dstBeing = actorSpriteManager->findBeing(msg.readInt32()); + Being *srcBeing = actorSpriteManager->findBeing(msg.readInt32()); + Being *dstBeing = actorSpriteManager->findBeing(msg.readInt32()); msg.readInt32(); // server tick int srcSpeed = msg.readInt32(); // src speed msg.readInt32(); // dst speed - param1 = msg.readInt16(); + int param1 = msg.readInt16(); msg.readInt16(); // param 2 - type = msg.readInt8(); + int type = msg.readInt8(); msg.readInt16(); // param 3 switch (type) @@ -513,10 +519,7 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) { srcBeing->setMoveTime(); if (player_node) - { - player_node->imitateAction( - srcBeing, Being::SIT); - } + player_node->imitateAction(srcBeing, Being::SIT); } } break; @@ -529,23 +532,18 @@ void BeingHandler::processBeingAction(Net::MessageIn &msg) { srcBeing->setMoveTime(); if (player_node) - { - player_node->imitateAction( - srcBeing, Being::STAND); - } + player_node->imitateAction(srcBeing, Being::STAND); } } break; default: - break; -/* logger->log("QQQ1 SMSG_BEING_ACTION:"); if (srcBeing) logger->log("srcBeing:" + toString(srcBeing->getId())); if (dstBeing) logger->log("dstBeing:" + toString(dstBeing->getId())); logger->log("type: " + toString(type)); -*/ + break; } } @@ -584,8 +582,7 @@ void BeingHandler::processBeingEmotion(Net::MessageIn &msg) if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32()))) return; - if (player_relations.hasPermission(dstBeing, - PlayerRelation::EMOTE)) + if (player_relations.hasPermission(dstBeing, PlayerRelation::EMOTE)) { unsigned char emote = msg.readInt8(); if (emote) @@ -626,8 +623,7 @@ void BeingHandler::processNameResponse(Net::MessageIn &msg) Party *party = player_node->getParty(); if (party && party->isMember(dstBeing->getId())) { - PartyMember *member = party->getMember( - dstBeing->getId()); + PartyMember *member = party->getMember(dstBeing->getId()); if (member) member->setName(dstBeing->getName()); diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h index 60931ef9b..196626b0d 100644 --- a/src/net/ea/buysellhandler.h +++ b/src/net/ea/buysellhandler.h @@ -40,9 +40,12 @@ class BuySellHandler : public Net::BuySellHandler BuySellHandler(); virtual void requestSellList(std::string nick); + virtual void requestBuyList(std::string nick); + virtual void sendBuyRequest(std::string nick, ShopItem* item, int amount); + virtual void sendSellRequest(std::string nick, ShopItem* item, int amount); diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index a0e5b392a..08c9a43c8 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -136,7 +136,7 @@ void CharServerHandler::processCharCreateFailed(Net::MessageIn &msg) case 0: default: errorMessage = _("Failed to create character. Most " - "likely the name is already taken."); + "likely the name is already taken."); break; case 2: errorMessage = _("Wrong name."); diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index c18b1bb9a..60af645be 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -168,13 +168,11 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) return; } - if (player_relations.hasPermission( - nick, PlayerRelation::WHISPER)) + if (player_relations.hasPermission(nick, PlayerRelation::WHISPER)) { bool tradeBot = config.getBoolValue("tradebot"); bool showMsg = !config.getBoolValue("hideShopMessages"); - if (player_relations.hasPermission( - nick, PlayerRelation::TRADE)) + if (player_relations.hasPermission(nick, PlayerRelation::TRADE)) { if (shopWindow) { //commands to shop from player @@ -184,8 +182,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) { if (showMsg && chatWindow) chatWindow->addWhisper(nick, chatMsg); - shopWindow->giveList(nick, - ShopWindow::SELL); + shopWindow->giveList(nick, ShopWindow::SELL); } } else if (chatMsg.find("!buylist ") == 0) @@ -194,8 +191,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) { if (showMsg && chatWindow) chatWindow->addWhisper(nick, chatMsg); - shopWindow->giveList(nick, - ShopWindow::BUY); + shopWindow->giveList(nick, ShopWindow::BUY); } } else if (chatMsg.find("!buyitem ") == 0) @@ -205,7 +201,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { shopWindow->processRequest(nick, chatMsg, - ShopWindow::BUY); + ShopWindow::BUY); } } else if (chatMsg.find("!sellitem ") == 0) @@ -215,7 +211,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { shopWindow->processRequest(nick, chatMsg, - ShopWindow::SELL); + ShopWindow::SELL); } } else if (chatMsg.length() > 3 @@ -224,11 +220,8 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) chatMsg = chatMsg.erase(0, 2); if (showMsg && chatWindow) chatWindow->addWhisper(nick, chatMsg); - if (chatMsg.find("B1") == 0 - || chatMsg.find("S1") == 0) - { + if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) shopWindow->showList(nick, chatMsg); - } } else if (chatWindow) { @@ -242,9 +235,8 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) } else { - if (chatWindow && (showMsg - || (chatMsg.find("!selllist") - != 0 && chatMsg.find("!buylist") != 0))) + if (chatWindow && (showMsg || (chatMsg.find("!selllist") != 0 + && chatMsg.find("!buylist") != 0))) { chatWindow->addWhisper(nick, chatMsg); } @@ -277,8 +269,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) std::string sender_name = ((pos == std::string::npos) ? "" : chatMsg.substr(0, pos)); - if (sender_name != being->getName() - && being->getType() == Being::PLAYER) + if (sender_name != being->getName() && being->getType() == Being::PLAYER) { if (!being->getName().empty()) sender_name = being->getName(); @@ -296,8 +287,8 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) if (player_relations.checkPermissionSilently(sender_name, PlayerRelation::SPEECH_LOG) && chatWindow) { - chatWindow->resortChatLog(removeColors(sender_name) + " : " - + chatMsg, BY_OTHER); + chatWindow->resortChatLog(removeColors(sender_name) + + " : " + chatMsg, BY_OTHER); } if (player_relations.hasPermission(sender_name, @@ -347,7 +338,7 @@ void ChatHandler::processMVP(Net::MessageIn &msg) { // Display MVP player int id = msg.readInt32(); // id - if (localChatTab && actorSpriteManager) + if (localChatTab && actorSpriteManager && config.getBoolValue("showMVP")) { Being *being = actorSpriteManager->findBeing(id); if (!being) @@ -363,4 +354,3 @@ void ChatHandler::processMVP(Net::MessageIn &msg) } } // namespace Ea - diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index f4b87f8a2..2aad4a564 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -44,7 +44,8 @@ class GuildTab : public ChatTab void saveToLogFile(std::string &msg); - int getType() const { return ChatTab::TAB_GUILD; } + int getType() const + { return ChatTab::TAB_GUILD; } protected: void handleInput(const std::string &msg); diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index f34d51370..3a544d8db 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -35,13 +35,15 @@ class PartyTab : public ChatTab { public: PartyTab(); + ~PartyTab(); void showHelp(); bool handleCommand(const std::string &type, const std::string &args); - int getType() const { return ChatTab::TAB_PARTY; } + int getType() const + { return ChatTab::TAB_PARTY; } void saveToLogFile(std::string &msg); diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 2accb1f1d..66488d5fb 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -177,24 +177,22 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg) if (guildTab && showBasicInfo) { showBasicInfo = false; - guildTab->chatLog(strprintf( - _("Guild name: %s"), name.c_str()), BY_SERVER); - guildTab->chatLog(strprintf( - _("Guild master: %s"), master.c_str()), BY_SERVER); - guildTab->chatLog(strprintf( - _("Guild level: %d"), level), BY_SERVER); - guildTab->chatLog(strprintf( - _("Online members: %d"), members), BY_SERVER); - guildTab->chatLog(strprintf( - _("Max members: %d"), maxMembers), BY_SERVER); - guildTab->chatLog(strprintf( - _("Average level: %d"), avgLevel), BY_SERVER); - guildTab->chatLog(strprintf( - _("Guild exp: %d"), exp), BY_SERVER); - guildTab->chatLog(strprintf( - _("Guild next exp: %d"), nextExp), BY_SERVER); - guildTab->chatLog(strprintf( - _("Guild castle: %s"), castle.c_str()), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild name: %s"), + name.c_str()), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild master: %s"), + master.c_str()), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild level: %d"), level), BY_SERVER); + guildTab->chatLog(strprintf(_("Online members: %d"), + members), BY_SERVER); + guildTab->chatLog(strprintf(_("Max members: %d"), + maxMembers), BY_SERVER); + guildTab->chatLog(strprintf(_("Average level: %d"), + avgLevel), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild exp: %d"), exp), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild next exp: %d"), + nextExp), BY_SERVER); + guildTab->chatLog(strprintf(_("Guild castle: %s"), + castle.c_str()), BY_SERVER); } Guild *g = Guild::getGuild(static_cast<short int>(guildId)); @@ -206,6 +204,8 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg) void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg) { int length = msg.readInt16(); + if (length < 4) + return; int count = (length - 4) / 32; for (int i = 0; i < count; i++) @@ -219,6 +219,8 @@ void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg) void GuildHandler::processGuildMemberList(Net::MessageIn &msg) { int length = msg.readInt16(); + if (length < 4) + return; int count = (length - 4) / 104; if (!taGuild) { @@ -260,7 +262,6 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg) m->setExp(exp); m->setPos(pos); m->setRace(race); -// m->setDisplayBold(!pos); if (actorSpriteManager) { Being *being = actorSpriteManager->findBeingByName( @@ -294,6 +295,8 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg) } int length = msg.readInt16(); + if (length < 4) + return; int count = (length - 4) / 28; for (int i = 0; i < count; i++) @@ -307,6 +310,8 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg) void GuildHandler::processGuildPosInfoList(Net::MessageIn &msg) { int length = msg.readInt16(); + if (length < 4) + return; int count = (length - 4) / 16; for (int i = 0; i < count; i++) @@ -348,6 +353,8 @@ void GuildHandler::processGuildEmblem(Net::MessageIn &msg) msg.readInt32(); // Guild ID msg.readInt32(); // Emblem ID + if (length < 12) + return; msg.skip(length - 12); // Emblem data (unknown format) } @@ -358,6 +365,8 @@ void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg) msg.readInt16(); // 'Skill point' + if (length < 6) + return; for (int i = 0; i < count; i++) { msg.readInt16(); // ID @@ -429,7 +438,10 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) if (taGuild) taGuild->removeMember(nick); - if (player_node && nick == player_node->getName()) + if (!player_node) + return; + + if (nick == player_node->getName()) { if (taGuild) { @@ -449,8 +461,7 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) { if (guildTab) { - guildTab->chatLog(strprintf( - _("%s has left your guild."), + guildTab->chatLog(strprintf(_("%s has left your guild."), nick.c_str()), BY_SERVER); } if (actorSpriteManager) @@ -474,7 +485,10 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) if (taGuild) taGuild->removeMember(nick); - if (player_node && nick == player_node->getName()) + if (!player_node) + return; + + if (nick == player_node->getName()) { if (taGuild) { @@ -514,6 +528,9 @@ void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) void GuildHandler::processGuildExpulsionList(Net::MessageIn &msg) { int length = msg.readInt16(); + if (length < 4) + return; + int count = (length - 4) / 88; for (int i = 0; i < count; i++) @@ -540,7 +557,7 @@ void GuildHandler::processGuildMessage(Net::MessageIn &msg) std::string sender_name = ((pos == std::string::npos) ? "" : chatMsg.substr(0, pos)); - chatMsg.erase(0, pos + 3); + chatMsg.erase(0, pos + 3); trim(chatMsg); guildTab->chatLog(sender_name, chatMsg); diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 1de681007..788b7f0fc 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -316,10 +316,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) if (err) { if (player_node) - { - player_node->pickedUp(itemInfo, 0, identified, - floorId, err); - } + player_node->pickedUp(itemInfo, 0, identified, floorId, err); } else { @@ -334,13 +331,13 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) Item *item = inventory->getItem(index); if (item && item->getId() == itemId) - amount += inventory->getItem(index)->getQuantity(); + amount += item->getQuantity(); if (serverVersion < 1 && identified > 1) identified = 1; inventory->setItem(index, itemId, amount, refine, - identified, equipType != 0); + identified, equipType != 0); } } } @@ -451,7 +448,6 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) { int index, amount, itemId, refine; unsigned char identified; -// int cards[4]; // Move an item into storage index = msg.readInt16() - STORAGE_OFFSET; @@ -475,8 +471,8 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) if (serverVersion < 1 && identified > 1) identified = 1; - mStorage->setItem(index, itemId, amount, refine, - identified, false); + mStorage->setItem(index, itemId, amount, + refine, identified, false); } } } @@ -502,7 +498,6 @@ void InventoryHandler::processPlayerStorageRemove(Net::MessageIn &msg) void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED) { // Storage access has been closed - // Storage window deletes itself mStorageWindow = 0; @@ -569,12 +564,9 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) void InventoryHandler::processPlayerEquip(Net::MessageIn &msg) { - int index, equipType; - int flag; - - index = msg.readInt16() - INVENTORY_OFFSET; - equipType = msg.readInt16(); - flag = msg.readInt8(); + int index = msg.readInt16() - INVENTORY_OFFSET; + int equipType = msg.readInt16(); + int flag = msg.readInt8(); if (!flag) SERVER_NOTICE(_("Unable to equip.")) @@ -584,12 +576,9 @@ void InventoryHandler::processPlayerEquip(Net::MessageIn &msg) void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg) { - int equipType; - int flag; - msg.readInt16(); // inder val - INVENTORY_OFFSET; - equipType = msg.readInt16(); - flag = msg.readInt8(); + int equipType = msg.readInt16(); + int flag = msg.readInt8(); if (flag) mEquips.setEquipment(getSlot(equipType), -1); diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index cb1e84673..3a99bc47f 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -60,16 +60,22 @@ class EquipBackend : public Equipment::Backend if (invyIndex == -1) return NULL; - return PlayerInfo::getInventory()->getItem(invyIndex); + if (PlayerInfo::getInventory()) + return PlayerInfo::getInventory()->getItem(invyIndex); + else + return 0; } void clear() { + Inventory *inv = PlayerInfo::getInventory(); + if (!inv) + return; for (int i = 0; i < EQUIPMENT_SIZE; i++) { if (mEquipment[i] != -1) { - Item* item = PlayerInfo::getInventory()->getItem(i); + Item* item = inv->getItem(i); if (item) item->setEquipped(false); } @@ -80,16 +86,19 @@ class EquipBackend : public Equipment::Backend void setEquipment(int index, int inventoryIndex) { + Inventory *inv = PlayerInfo::getInventory(); + if (!inv) + return; + // Unequip existing item - Item* item = PlayerInfo::getInventory() - ->getItem(mEquipment[index]); + Item* item = inv->getItem(mEquipment[index]); if (item) item->setEquipped(false); mEquipment[index] = inventoryIndex; - item = PlayerInfo::getInventory()->getItem(inventoryIndex); + item = inv->getItem(inventoryIndex); if (item) item->setEquipped(true); @@ -115,14 +124,14 @@ class InventoryItem bool equip; InventoryItem(int slot0, int id0, int quantity0, int refine0, - unsigned char color0, bool equip0) + unsigned char color0, bool equip0) : + slot(slot0), + id(id0), + quantity(quantity0), + color(color0), + refine(refine0), + equip(equip0) { - slot = slot0; - id = id0; - quantity = quantity0; - refine = refine0; - color = color0; - equip = equip0; } }; diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 9f7a5f07d..b11e60d4d 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -34,7 +34,7 @@ namespace Ea { -LoginHandler::LoginHandler(): +LoginHandler::LoginHandler() : mVersionResponse(false), mRegistrationEnabled(true) { @@ -184,10 +184,8 @@ void LoginHandler::processLoginData(Net::MessageIn &msg) world->updateHost = mUpdateHost; msg.skip(2); // unknown - logger->log("Network: Server: %s (%s:%d)", - world->name.c_str(), - ipToString(world->address), - world->port); + logger->log("Network: Server: %s (%s:%d)", world->name.c_str(), + ipToString(world->address), world->port); mWorlds.push_back(world); } diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 36e192ce8..35cc77fbf 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -40,7 +40,7 @@ namespace Ea PartyTab *partyTab = 0; Party *taParty = 0; -PartyHandler::PartyHandler(): +PartyHandler::PartyHandler() : mShareExp(PARTY_SHARE_UNKNOWN), mShareItems(PARTY_SHARE_UNKNOWN) { @@ -344,7 +344,10 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg) int id = msg.readInt32(); std::string nick = msg.readString(24); msg.readInt8(); // fail - if (player_node && id == player_node->getId()) + if (!player_node) + return; + + if (id == player_node->getId()) { if (Ea::taParty) { @@ -431,21 +434,18 @@ void PartyHandler::processPartyMessage(Net::MessageIn &msg) int id = msg.readInt32(); std::string chatMsg = msg.readString(msgLength); - if (Ea::taParty) + if (Ea::taParty && Ea::partyTab) { PartyMember *member = Ea::taParty->getMember(id); - if (Ea::partyTab) + if (member) { - if (member) - { - Ea::partyTab->chatLog(member->getName(), chatMsg); - } - else - { - Ea::partyTab->chatLog(strprintf( - _("An unknown member tried to say: %s"), - chatMsg.c_str()), BY_SERVER); - } + Ea::partyTab->chatLog(member->getName(), chatMsg); + } + else + { + Ea::partyTab->chatLog(strprintf( + _("An unknown member tried to say: %s"), + chatMsg.c_str()), BY_SERVER); } } } diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 3af237b5b..81e520415 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -70,7 +70,8 @@ namespace { void action(const gcn::ActionEvent &event A_UNUSED) { - Net::getPlayerHandler()->respawn(); + if (Net::getPlayerHandler()) + Net::getPlayerHandler()->respawn(); deathNotice = NULL; Client::closeDialogs(); @@ -326,13 +327,11 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) case 0x0018: if (!weightNotice) { - const int max - = PlayerInfo::getAttribute(MAX_WEIGHT) / 2; - const int total - = PlayerInfo::getAttribute(TOTAL_WEIGHT); + const int max = PlayerInfo::getAttribute(MAX_WEIGHT) / 2; + const int total = PlayerInfo::getAttribute(TOTAL_WEIGHT); if (value >= max && total < max) { - weightNoticeTime = cur_time + 10; + weightNoticeTime = cur_time + 5; weightNotice = new OkDialog(_("Message"), _("You are carrying more than " "half your weight. You are " @@ -342,7 +341,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) } else if (value < max && total >= max) { - weightNoticeTime = cur_time + 10; + weightNoticeTime = cur_time + 5; weightNotice = new OkDialog(_("Message"), _("You are carrying less than " "half your weight. You " diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp index b78531434..fe56db52a 100644 --- a/src/net/ea/specialhandler.cpp +++ b/src/net/ea/specialhandler.cpp @@ -134,11 +134,8 @@ void SpecialHandler::processSkillFailed(Net::MessageIn &msg) std::string txt; if (success == SKILL_FAILED && skillId == SKILL_BASIC) { - if (player_node && bskill == BSKILL_EMOTE - && reason == RFAIL_SKILLDEP) - { + if (player_node && bskill == BSKILL_EMOTE && reason == RFAIL_SKILLDEP) player_node->stopAdvert(); - } switch (bskill) { @@ -171,8 +168,7 @@ void SpecialHandler::processSkillFailed(Net::MessageIn &msg) switch (reason) { case RFAIL_SKILLDEP: - txt += _("You have not yet reached a high enough " - "lvl!"); + txt += _("You have not yet reached a high enough lvl!"); break; case RFAIL_INSUFHP: txt += _("Insufficient HP!"); diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index a03782db2..bdbba9715 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -84,7 +84,7 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg) // special message about the player being occupied. std::string tradePartnerNameTemp = msg.readString(24); - if (player_relations.hasPermission(tradePartnerName, + if (player_relations.hasPermission(tradePartnerNameTemp, PlayerRelation::TRADE)) { if (PlayerInfo::isTrading() || confirmDlg) @@ -97,16 +97,13 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg) PlayerInfo::setTrading(true); if (tradeWindow) { - if (tradePartnerName.empty() - || tradeWindow->getAutoTradeNick() + if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick() != tradePartnerName) { tradeWindow->clear(); - confirmDlg = new ConfirmDialog( - _("Request for Trade"), + confirmDlg = new ConfirmDialog(_("Request for Trade"), strprintf(_("%s wants to trade with you, do" - " you accept?"), tradePartnerName.c_str()), - true); + " you accept?"), tradePartnerName.c_str()), true); confirmDlg->addActionListener(&listener); } else @@ -128,22 +125,20 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg) { case 0: // Too far away SERVER_NOTICE(_("Trading isn't possible. Trade " - "partner is too far away.")) + "partner is too far away.")) break; case 1: // Character doesn't exist SERVER_NOTICE(_("Trading isn't possible. Character " - "doesn't exist.")) + "doesn't exist.")) break; case 2: // Invite request check failed... - SERVER_NOTICE(_("Trade cancelled due to an unknown " - "reason.")) + SERVER_NOTICE(_("Trade cancelled due to an unknown reason.")) break; case 3: // Trade accepted if (tradeWindow) { tradeWindow->reset(); - tradeWindow->setCaption(strprintf( - _("Trade: You and %s"), + tradeWindow->setCaption(strprintf(_("Trade: You and %s"), tradePartnerName.c_str())); tradeWindow->initTrade(tradePartnerName); tradeWindow->setVisible(true); @@ -201,7 +196,10 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) { // Trade: New Item add response (was 0x00ea, now 01b1) const int index = msg.readInt16() - INVENTORY_OFFSET; - Item *item = PlayerInfo::getInventory()->getItem(index); + Item *item = 0; + if (PlayerInfo::getInventory()) + item = PlayerInfo::getInventory()->getItem(index); + if (!item) { if (tradeWindow) diff --git a/src/net/generalhandler.h b/src/net/generalhandler.h index 4d68faffc..1a15e6929 100644 --- a/src/net/generalhandler.h +++ b/src/net/generalhandler.h @@ -44,6 +44,7 @@ class GeneralHandler virtual void flushNetwork() = 0; virtual void clearHandlers() = 0; + virtual void reloadPartially() = 0; }; diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h index 06c73d288..360f141fa 100644 --- a/src/net/inventoryhandler.h +++ b/src/net/inventoryhandler.h @@ -64,8 +64,6 @@ class InventoryHandler virtual size_t getSize(int type) const = 0; virtual int convertFromServerSlot(int eAthenaSlot) const = 0; - -// virtual ~InventoryHandler() {} }; } // namespace Net diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 8f177f906..0fbf7162b 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -77,6 +77,7 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y) void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) { + Uint8 serverDir = 0; if (mPos + 3 <= mLength) { const char *data = mData + mPos; @@ -87,10 +88,10 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f); y = static_cast<unsigned short>(temp >> 4); - direction = data[2] & 0x000f; + serverDir = data[2] & 0x000f; // Translate from eAthena format - switch (direction) + switch (serverDir) { case 0: direction = 1; @@ -134,7 +135,8 @@ void MessageIn::readCoordinates(Uint16 &x, Uint16 &y, Uint8 &direction) mPos += 3; PacketCounters::incInBytes(3); DEBUGLOG("readCoordinates: " + toString(static_cast<int>(x)) - + "," + toString(static_cast<int>(y))); + + "," + toString(static_cast<int>(y)) + "," + toString( + static_cast<int>(serverDir))); } void MessageIn::readCoordinatePair(Uint16 &srcX, Uint16 &srcY, @@ -227,7 +229,7 @@ std::string MessageIn::readRawString(int length) char const *stringEnd2 = static_cast<char const *>(memchr(stringBeg2, '\0', len2)); std::string hiddenPart = std::string(stringBeg2, - stringEnd2 ? stringEnd2 - stringBeg2 : len2); + stringEnd2 ? stringEnd2 - stringBeg2 : len2); if (hiddenPart.length() > 0) { DEBUGLOG("readString2: " + hiddenPart); diff --git a/src/net/messagein.h b/src/net/messagein.h index eea298f4d..6d7038d4a 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -54,10 +54,12 @@ class MessageIn * Returns the length of unread data. */ unsigned int getUnreadLength() const - { return mLength - mPos; } + { return mLength > mPos ? mLength - mPos : 0; } virtual unsigned char readInt8(); /**< Reads a byte. */ + virtual Sint16 readInt16() = 0; /**< Reads a short. */ + virtual int readInt32() = 0; /**< Reads a long. */ /** diff --git a/src/net/messageout.h b/src/net/messageout.h index 3da92ab28..39a2e68bd 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -45,7 +45,9 @@ class MessageOut { public: virtual void writeInt8(Sint8 value); /**< Writes a byte. */ + virtual void writeInt16(Sint16 value) = 0; /**< Writes a short. */ + virtual void writeInt32(Sint32 value) = 0; /**< Writes a long. */ /** diff --git a/src/net/packetcounters.h b/src/net/packetcounters.h index 1af928be8..35d5d64bc 100644 --- a/src/net/packetcounters.h +++ b/src/net/packetcounters.h @@ -26,15 +26,22 @@ class PacketCounters { public: -// PacketCounters(); static void incInBytes(int cnt); + static void incInPackets(); + static int getInBytes(); + static int getInPackets(); + static void incOutBytes(int cnt); + static void incOutPackets(); + static int getOutBytes(); + static int getOutPackets(); + static void update(); static int mInCurrentSec; diff --git a/src/net/partyhandler.h b/src/net/partyhandler.h index 246987eb1..14f06060d 100644 --- a/src/net/partyhandler.h +++ b/src/net/partyhandler.h @@ -74,10 +74,6 @@ class PartyHandler virtual void setShareItems(PartyShare share) = 0; virtual void clear() = 0; - - // virtual void options() = 0; - - // virtual void message() = 0; }; } // namespace Net diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 845c30f19..02267e20e 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -132,20 +132,16 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_SKILL_DAMAGE: - { processSkillDamage(msg); break; - } + case SMSG_BEING_ACTION: - { processBeingAction(msg); break; - } + case SMSG_BEING_SELFEFFECT: - { processBeingSelfEffect(msg); break; - } case SMSG_BEING_EMOTION: processBeingEmotion(msg); @@ -509,13 +505,9 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) if (!guildManager || !GuildManager::getEnableGuildBot()) { if (guild == 0) - { dstBeing->clearGuilds(); - } else - { dstBeing->setGuild(Guild::getGuild(static_cast<short>(guild))); - } } msg.readInt16(); // emblem @@ -659,6 +651,4 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) dstBeing->setMoveTime(); } - - } // namespace TmwAthena diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index 7aa68e617..03b63aa16 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -157,7 +157,7 @@ void CharServerHandler::handleMessage(Net::MessageIn &msg) break; default: - break; + break; } } @@ -165,8 +165,11 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, Net::Character *character, bool withColors) { + if (!character) + return; + const Token &token = - static_cast<LoginHandler*>(Net::getLoginHandler())->getToken(); + static_cast<LoginHandler*>(Net::getLoginHandler())->getToken(); LocalPlayer *tempPlayer = new LocalPlayer(msg.readInt32(), 0); tempPlayer->setGender(token.sex); @@ -264,6 +267,9 @@ void CharServerHandler::readPlayerData(Net::MessageIn &msg, void CharServerHandler::chooseCharacter(Net::Character *character) { + if (!character) + return; + mSelectedCharacter = character; mCharSelectDialog = 0; @@ -338,10 +344,8 @@ void CharServerHandler::processCharLogin(Net::MessageIn &msg) msg.skip(2); // Length word int slots = msg.readInt16(); if (slots > 0 && slots < 30) - { - loginData.characterSlots - = static_cast<short unsigned int>(slots); - } + loginData.characterSlots = static_cast<short unsigned int>(slots); + bool version = msg.readInt8() == 1 && serverVersion > 0; msg.skip(17); // Unused diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 90acf0f90..4e4318595 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -107,7 +107,6 @@ void ChatHandler::talk(const std::string &text) return; std::string mes = player_node->getName() + " : " + text; -// std::string mes = player_node->getName() + "zzzz : " + text; MessageOut outMsg(CMSG_CHAT_MESSAGE); // Added + 1 in order to let eAthena parse admin commands correctly @@ -227,7 +226,7 @@ void ChatHandler::processRaw(MessageOut &outMsg, std::string &line) if (pos != std::string::npos) { unsigned short x = static_cast<unsigned short>( - atoi(data.substr(0, pos).c_str())); + atoi(data.substr(0, pos).c_str())); data = data.substr(pos + 1); pos = line.find(","); if (pos == std::string::npos) diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 242e9f9de..adaaa067b 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -107,9 +107,16 @@ void GameHandler::connect() if (Client::getState() == STATE_CONNECT_GAME) { - mCharID = player_node->getId(); // Change the player's ID to the account ID to match what eAthena uses - player_node->setId(token.account_ID); + if (player_node) + { + mCharID = player_node->getId(); + player_node->setId(token.account_ID); + } + else + { + mCharID = 0; + } } // Send login infos diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index c6ebc000c..0a9541477 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -143,10 +143,14 @@ void GeneralHandler::handleMessage(Net::MessageIn &msg) break; case 2: if (Client::getState() == STATE_GAME) + { errorMessage = _("Someone else is trying to use this " "account."); + } else + { errorMessage = _("This account is already logged in."); + } break; case 3: errorMessage = _("Speed hack detected."); diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index 5e6c9f18f..9ab8d64b4 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -40,7 +40,7 @@ namespace TmwAthena { class GeneralHandler : public MessageHandler, public Net::GeneralHandler, - public Mana::Listener + public Mana::Listener { public: GeneralHandler(); diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 640a6fd78..7ea97eb49 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -79,8 +79,6 @@ GuildHandler::~GuildHandler() void GuildHandler::handleMessage(Net::MessageIn &msg) { - DEBUGLOG("guild message"); - switch (msg.getId()) { case SMSG_GUILD_CREATE_RESPONSE: @@ -92,10 +90,8 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_GUILD_MEMBER_LOGIN: - { processGuildMemberLogin(msg); break; - } case SMSG_GUILD_MASTER_OR_MEMBER: processGuildMasterOrMember(msg); diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 9a0978bd0..989ced27a 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -59,8 +59,7 @@ class InventoryHandler : public MessageHandler, public Ea::InventoryHandler void closeStorage(int type); - void moveItem(int source, int slot, int amount, - int destination); + void moveItem(int source, int slot, int amount, int destination); }; } // namespace TmwAthena diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 029c379a0..cac8df623 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -146,12 +146,10 @@ ServerInfo *LoginHandler::getCharServer() void LoginHandler::processServerVersion(Net::MessageIn &msg) { - // TODO: verify these! - char b1 = msg.readInt8(); // -1 - char b2 = msg.readInt8(); // T - char b3 = msg.readInt8(); // M - char b4 = msg.readInt8(); // W + char b2 = msg.readInt8(); // E + char b3 = msg.readInt8(); // V + char b4 = msg.readInt8(); // L if (b1 == -1 && b2 == 'E' && b3 == 'V' && b4 == 'L') { unsigned int options = msg.readInt8(); diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index 6071e0ab6..d5d9d82f9 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -46,6 +46,7 @@ MessageOut::MessageOut(short id): { mNetwork = TmwAthena::Network::instance(); mData = mNetwork->mOutBuffer + mNetwork->mOutSize; + writeInt16(id); } diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h index 32cb803e2..da86f06f6 100644 --- a/src/net/tmwa/messageout.h +++ b/src/net/tmwa/messageout.h @@ -47,6 +47,7 @@ class MessageOut : public Net::MessageOut MessageOut(short id); void writeInt16(Sint16 value); /**< Writes a short. */ + void writeInt32(Sint32 value); /**< Writes a long. */ /** diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 8ecf04d36..0af74c295 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -42,49 +42,49 @@ short packet_lengths[] = { - 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // #0x0040 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 50, 3, -1, 55, 17, 3, 37, 46, -1, 23, -1, 3, 108, 3, 2, - 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 50, 3, -1, 55, 17, 3, 37, 46, -1, 23, -1, 3, 108, 3, 2, + 3, 28, 19, 11, 3, -1, 9, 5, 54, 53, 58, 60, 41, 2, 6, 6, // #0x0080 - 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 23, -1, -1, -1, 0, - 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6, - 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6, - 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3, + 7, 3, 2, 2, 2, 5, 16, 12, 10, 7, 29, 23, -1, -1, -1, 0, + 7, 22, 28, 2, 6, 30, -1, -1, 3, -1, -1, 5, 9, 17, 17, 6, + 23, 6, 6, -1, -1, -1, -1, 8, 7, 6, 7, 4, 7, 0, -1, 6, + 8, 8, 3, 3, -1, 6, 6, -1, 7, 6, 2, 5, 6, 44, 5, 3, // #0x00C0 - 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 6, 2, 27, - 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1, - 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2, - 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10, + 7, 2, 6, 8, 6, 7, -1, -1, -1, -1, 3, 3, 6, 6, 2, 27, + 3, 4, 4, 2, -1, -1, 3, -1, 6, 14, 3, -1, 28, 29, -1, -1, + 30, 30, 26, 2, 6, 26, 3, 3, 8, 19, 5, 2, 3, 2, 2, 2, + 3, 2, 6, 8, 21, 8, 8, 2, 2, 26, 3, -1, 6, 27, 30, 10, // #0x0100 - 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1, - 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16, - 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1, - 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26, + 2, 6, 6, 30, 79, 31, 10, 10, -1, -1, 4, 6, 6, 2, 11, -1, + 10, 39, 4, 10, 31, 35, 10, 18, 2, 13, 15, 20, 68, 2, 3, 16, + 6, 14, -1, -1, 21, 8, 8, 8, 8, 8, 2, 2, 3, 4, 2, -1, + 6, 86, 6, -1, -1, 7, -1, 6, 3, 16, 4, 4, 4, 6, 24, 26, // #0x0140 - 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6, - 110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42, - -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14, 186, 182, - 14, 30, 10, 3, -1, 6, 106, -1, 4, 5, 4, -1, 6, 7, -1, -1, + 22, 14, 6, 10, 23, 19, 6, 39, 8, 9, 6, 27, -1, 2, 6, 6, +110, 6, -1, -1, -1, -1, -1, 6, -1, 54, 66, 54, 90, 42, 6, 42, + -1, -1, -1, -1, -1, 30, -1, 3, 14, 3, 30, 10, 43, 14, 186, 182, + 14, 30, 10, 3, -1, 6, 106, -1, 4, 5, 4, -1, 6, 7, -1, -1, // #0x0180 - 6, 3, 106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6, - 90, 86, 24, 6, 30, 102, 9, 4, 8, 4, 14, 10, 4, 6, 2, 6, - 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4, - 11, 7, -1, 67, 12, 18, 114, 6, 3, 6, 26, 26, 26, 26, 2, 3, + 6, 3, 106, 10, 10, 34, 0, 6, 8, 4, 4, 4, 29, -1, 10, 6, + 90, 86, 24, 6, 30, 102, 9, 4, 8, 4, 14, 10, 4, 6, 2, 6, + 3, 3, 35, 5, 11, 26, -1, 4, 4, 6, 10, 12, 6, -1, 4, 4, + 11, 7, -1, 67, 12, 18, 114, 6, 3, 6, 26, 26, 26, 26, 2, 3, // #0x01C0 - 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 0, 9, 9, 29, 6, 28, - 8, 14, 10, 35, 6, 8, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6, - 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1, - -1, -1, 20, 10, 32, 9, 34, 14, 2, 6, 48, 56, -1, 4, 5, 10, + 2, 14, 10, -1, 22, 22, 4, 2, 13, 97, 0, 9, 9, 29, 6, 28, + 8, 14, 10, 35, 6, 8, 4, 11, 54, 53, 60, 2, -1, 47, 33, 6, + 30, 8, 34, 14, 2, 6, 26, 2, 28, 81, 6, 10, 26, 2, -1, -1, + -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, - -1,122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 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, + -1, 122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; const unsigned int BUFFER_SIZE = 655360; @@ -106,7 +106,7 @@ int networkThread(void *data) Network *Network::mInstance = 0; -Network::Network(): +Network::Network() : mSocket(0), mInBuffer(new char[BUFFER_SIZE]), mOutBuffer(new char[BUFFER_SIZE]), @@ -153,8 +153,8 @@ bool Network::connect(ServerInfo server) return false; } - logger->log("Network::Connecting to %s:%i", server.hostname.c_str(), - server.port); + logger->log("Network::Connecting to %s:%i", + server.hostname.c_str(), server.port); mServer.hostname = server.hostname; mServer.port = server.port; @@ -263,7 +263,7 @@ void Network::flush() if (ret < static_cast<int>(mOutSize)) { setError("Error in SDLNet_TCP_Send(): " + - std::string(SDLNet_GetError())); + std::string(SDLNet_GetError())); } mOutSize = 0; SDL_mutexV(mMutex); @@ -308,7 +308,6 @@ bool Network::messageReady() if (len == -1 && mInSize > 4) len = readWord(2); - } bool ret = (mInSize >= static_cast<unsigned int>(len)); @@ -354,7 +353,7 @@ bool Network::realConnect() mServer.port) == -1) { std::string errorMessage = _("Unable to resolve host \"") + - mServer.hostname + "\""; + mServer.hostname + "\""; setError(errorMessage); logger->log("SDLNet_ResolveHost: %s", errorMessage.c_str()); return false; @@ -371,7 +370,7 @@ bool Network::realConnect() } logger->log("Network::Started session with %s:%i", - ipToString(ipAddress.host), ipAddress.port); + ipToString(ipAddress.host), ipAddress.port); mState = CONNECTED; @@ -385,14 +384,14 @@ void Network::receive() if (!(set = SDLNet_AllocSocketSet(1))) { setError("Error in SDLNet_AllocSocketSet(): " + - std::string(SDLNet_GetError())); + std::string(SDLNet_GetError())); return; } if (SDLNet_TCP_AddSocket(set, mSocket) == -1) { setError("Error in SDLNet_AddSocket(): " + - std::string(SDLNet_GetError())); + std::string(SDLNet_GetError())); } while (mState == CONNECTED) diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp index 509c5ecd1..c75d954dc 100644 --- a/src/net/tmwa/specialhandler.cpp +++ b/src/net/tmwa/specialhandler.cpp @@ -53,10 +53,9 @@ void SpecialHandler::handleMessage(Net::MessageIn &msg) switch (msg.getId()) { case SMSG_PLAYER_SKILLS: - { processPlayerSkills(msg); break; - } + case SMSG_PLAYER_SKILL_UP: processPlayerSkillUp(msg); break; diff --git a/src/particle.h b/src/particle.h index c360a5e94..7220ad258 100644 --- a/src/particle.h +++ b/src/particle.h @@ -111,7 +111,7 @@ class Particle : public Actor * Necessary for sorting with the other sprites. */ virtual int getPixelY() const - { return static_cast<int>(mPos.y) - 64; } + { return static_cast<int>(mPos.y) - 16; } /** * Creates a blank particle as a child of the current particle diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 00a9d1cad..d7532b884 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -103,11 +103,12 @@ class PlayerConfSerialiser : static PlayerConfSerialiser player_conf_serialiser; // stateless singleton const unsigned int PlayerRelation::RELATION_PERMISSIONS[RELATIONS_NR] = { - /* NEUTRAL */ 0, // we always fall back to the defaults anyway - /* FRIEND */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE, - /* DISREGARDED*/ EMOTE | SPEECH_FLOAT, - /* IGNORED */ 0, - /* ERASED */ INVISIBLE + /* NEUTRAL */ 0, // we always fall back to the defaults anyway + /* FRIEND */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE, + /* DISREGARDED*/ EMOTE | SPEECH_FLOAT, + /* IGNORED */ 0, + /* ERASED */ INVISIBLE, + /* BLACKLISTED */ SPEECH_LOG | WHISPER }; PlayerRelation::PlayerRelation(Relation relation) @@ -278,6 +279,7 @@ unsigned int PlayerRelationsManager::checkPermissionSilently( case PlayerRelation::DISREGARDED: case PlayerRelation::IGNORED: case PlayerRelation::ERASED: + case PlayerRelation::BLACKLISTED: default: permissions &= mDefaultPermissions; // narrow } @@ -395,13 +397,14 @@ void PlayerRelationsManager::ignoreTrade(std::string name) if (relation == PlayerRelation::IGNORED || relation == PlayerRelation::DISREGARDED + || relation == PlayerRelation::BLACKLISTED || relation == PlayerRelation::ERASED) { return; } else { - player_relations.setRelation(name, PlayerRelation::DISREGARDED); + player_relations.setRelation(name, PlayerRelation::BLACKLISTED); } } diff --git a/src/playerrelations.h b/src/playerrelations.h index bb483a793..41ca14b40 100644 --- a/src/playerrelations.h +++ b/src/playerrelations.h @@ -44,8 +44,9 @@ struct PlayerRelation static const unsigned int WHISPER = (1 << 3); static const unsigned int TRADE = (1 << 4); static const unsigned int INVISIBLE = (1 << 5); + static const unsigned int BLACKLIST = (1 << 6); - static const unsigned int RELATIONS_NR = 5; + static const unsigned int RELATIONS_NR = 6; static const unsigned int RELATION_PERMISSIONS[RELATIONS_NR]; static const unsigned int DEFAULT = EMOTE @@ -59,7 +60,8 @@ struct PlayerRelation FRIEND = 1, DISREGARDED = 2, IGNORED = 3, - ERASED = 4 + ERASED = 4, + BLACKLISTED = 5 }; PlayerRelation(Relation relation); |