diff options
Diffstat (limited to 'src/net')
40 files changed, 289 insertions, 281 deletions
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; |