diff options
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/beingrecv.cpp | 20 | ||||
-rw-r--r-- | src/net/eathena/charserverrecv.cpp | 19 | ||||
-rw-r--r-- | src/net/eathena/guildrecv.cpp | 13 | ||||
-rw-r--r-- | src/net/eathena/npcrecv.cpp | 15 | ||||
-rw-r--r-- | src/net/eathena/partyrecv.cpp | 9 | ||||
-rw-r--r-- | src/net/eathena/skillrecv.cpp | 95 |
6 files changed, 66 insertions, 105 deletions
diff --git a/src/net/eathena/beingrecv.cpp b/src/net/eathena/beingrecv.cpp index da175c2e8..9d8c65389 100644 --- a/src/net/eathena/beingrecv.cpp +++ b/src/net/eathena/beingrecv.cpp @@ -222,16 +222,17 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) Being *dstBeing = nullptr; int cards[maxCards]; + const BeingId beingId = msg.readBeingId("being id"); + if (actorManager == nullptr) { // here can be look from char server Net::Characters &chars = Net::CharServerHandler::mCharacters; - const BeingId id = msg.readBeingId("being id"); FOR_EACH (Net::Characters::iterator, it, chars) { const Net::Character *const character = *it; if (character->dummy != nullptr && - character->dummy->getId() == id) + character->dummy->getId() == beingId) { dstBeing = character->dummy; break; @@ -240,8 +241,7 @@ void BeingRecv::processBeingChangeLookCards(Net::MessageIn &msg) } else { - dstBeing = actorManager->findBeing( - msg.readBeingId("being id")); + dstBeing = actorManager->findBeing(beingId); } const uint8_t type = msg.readUInt8("type"); @@ -1496,14 +1496,12 @@ void BeingRecv::processBeingSpecialEffect(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); Being *const being = actorManager->findBeing(id); - if (being == nullptr) - { - msg.readInt32("effect type"); - return; - } const int effectType = msg.readInt32("effect type"); + if (being == nullptr) + return; + if (ParticleEngine::enabled) effectManager->trigger(effectType, being, 0); @@ -1895,15 +1893,15 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) const BeingId id = msg.readBeingId("being id"); Being *const being = actorManager->findBeing(id); + const int effectType = msg.readInt32("effect type"); + if (being == nullptr) { DEBUGLOGSTR("insible player?"); - msg.readInt32("effect type"); BLOCK_END("BeingRecv::processBeingSelfEffect") return; } - const int effectType = msg.readInt32("effect type"); if (ParticleEngine::enabled) effectManager->trigger(effectType, being, 0); diff --git a/src/net/eathena/charserverrecv.cpp b/src/net/eathena/charserverrecv.cpp index c591e2ebd..b5e2d5235 100644 --- a/src/net/eathena/charserverrecv.cpp +++ b/src/net/eathena/charserverrecv.cpp @@ -273,15 +273,13 @@ void CharServerRecv::processCharMapInfo(Net::MessageIn &restrict msg) BLOCK_START("CharServerRecv::processCharMapInfo") PlayerInfo::setCharId(msg.readInt32("char id")); GameHandler::setMap(msg.readString(16, "map name")); + + const int mapIpAddress = msg.readInt32("map ip address"); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) - { - msg.readInt32("map ip address"); server.hostname = settings.serverName; - } else - { - server.hostname = ipToString(msg.readInt32("map ip address")); - } + server.hostname = ipToString(mapIpAddress); + server.port = msg.readInt16("map ip port"); if (msg.getVersion() >= 20170329) { @@ -320,15 +318,12 @@ void CharServerRecv::processChangeMapServer(Net::MessageIn &msg) GameHandler::setMap(msg.readString(16, "map name")); const int x = msg.readInt16("x"); const int y = msg.readInt16("y"); + const int mapIpAddress = msg.readInt32("map ip address"); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) - { - msg.readInt32("host"); server.hostname = settings.serverName; - } else - { - server.hostname = ipToString(msg.readInt32("host")); - } + server.hostname = ipToString(mapIpAddress); + server.port = msg.readInt16("port"); if (msg.getVersion() >= 20170315) { diff --git a/src/net/eathena/guildrecv.cpp b/src/net/eathena/guildrecv.cpp index 3d402c5b9..a07d28d2e 100644 --- a/src/net/eathena/guildrecv.cpp +++ b/src/net/eathena/guildrecv.cpp @@ -423,15 +423,9 @@ void GuildRecv::processGuildInvite(Net::MessageIn &msg) { const int guildId = msg.readInt32("guild id"); + const std::string guildName = msg.readString(24, "guild name"); if (socialWindow != nullptr) - { - const std::string guildName = msg.readString(24, "guild name"); socialWindow->showGuildInvite(guildName, guildId, ""); - } - else - { - msg.readString(24, "guild name"); - } } void GuildRecv::processGuildInviteAck(Net::MessageIn &msg) @@ -564,9 +558,11 @@ void GuildRecv::processGuildMessage(Net::MessageIn &msg) if (msgLength <= 0) return; + + std::string chatMsg = msg.readString(msgLength, "message"); + if (guildTab != nullptr) { - std::string chatMsg = msg.readString(msgLength, "message"); const size_t pos = chatMsg.find(" : ", 0); if (pos != std::string::npos) { @@ -586,7 +582,6 @@ void GuildRecv::processGuildMessage(Net::MessageIn &msg) else { DEBUGLOGSTR("invisible guild?"); - msg.readString(msgLength, "message"); } } diff --git a/src/net/eathena/npcrecv.cpp b/src/net/eathena/npcrecv.cpp index 206db497e..257420533 100644 --- a/src/net/eathena/npcrecv.cpp +++ b/src/net/eathena/npcrecv.cpp @@ -46,12 +46,6 @@ namespace NpcRecv void NpcRecv::processNpcCutin(Net::MessageIn &msg) { Ea::NpcRecv::mRequestLang = false; - if (cutInWindow == nullptr) - { - msg.readString(64, "image name"); - msg.readUInt8("type"); - return; - } const std::string image = msg.readString(64, "image name"); const CutInT cutin = static_cast<CutInT>(msg.readUInt8("type")); if (cutInWindow != nullptr) @@ -130,15 +124,10 @@ void NpcRecv::processNpcSkin(Net::MessageIn &msg) { const int len = msg.readInt16("len"); npcHandler->getNpc(msg, NpcAction::Other); + + const std::string skin = msg.readString(len - 8, "skin"); if (Ea::NpcRecv::mDialog != nullptr) - { - const std::string skin = msg.readString(len - 8, "skin"); Ea::NpcRecv::mDialog->setSkin(skin); - } - else - { - msg.readString(len - 8, "skin"); - } } void NpcRecv::processPrivateAirShipResponse(Net::MessageIn &msg) diff --git a/src/net/eathena/partyrecv.cpp b/src/net/eathena/partyrecv.cpp index 481c9f36f..0599d3732 100644 --- a/src/net/eathena/partyrecv.cpp +++ b/src/net/eathena/partyrecv.cpp @@ -183,15 +183,10 @@ void PartyRecv::processPartyInfo(Net::MessageIn &msg) Ea::taParty->clearMembers(); const int length = msg.readInt16("len"); + const std::string name = msg.readString(24, "party name"); + if (Ea::taParty != nullptr) - { - const std::string name = msg.readString(24, "party name"); Ea::taParty->setName(name); - } - else - { - msg.readString(24, "party name"); - } int partySize = 0; const int offset = 28; diff --git a/src/net/eathena/skillrecv.cpp b/src/net/eathena/skillrecv.cpp index 3f3e8efb1..8be8df445 100644 --- a/src/net/eathena/skillrecv.cpp +++ b/src/net/eathena/skillrecv.cpp @@ -281,6 +281,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) const int itemId = msg.readItemId("item id"); const signed char success = msg.readUInt8("success"); const signed char reason = msg.readUInt8("reason"); + if (success != CAST_S32(SKILL_FAILED) && bskill == CAST_S32(BSKILL_EMOTE)) { @@ -289,7 +290,9 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) if (localPlayer != nullptr) localPlayer->stopCast(true); - std::string txt; + + int skillErrorCode = skillId; + if (success == CAST_S32(SKILL_FAILED) && bskill != 0) { if ((localPlayer != nullptr) && bskill == CAST_S32(BSKILL_EMOTE) @@ -297,125 +300,110 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) { localPlayer->stopAdvert(); } - - const SkillInfo *const info = skillDialog->getSkill(bskill); - if (info != nullptr) - { - txt = info->errorText; - } - else - { - // TRANSLATORS: skill error message - txt = strprintf(_("Unknown skill error: %d"), bskill); - } + skillErrorCode = bskill; } + + const SkillInfo *const info = skillDialog ? skillDialog->getSkill(skillId) + : nullptr; + + std::string txt; + if (info != nullptr) + txt = info->errorText + "."; else { - const SkillInfo *const info = skillDialog->getSkill(skillId); - if (info != nullptr) - { - txt = info->errorText + "."; - } - else - { - // TRANSLATORS: skill error message - txt = strprintf(_("Unknown skill error: %d."), skillId); - } + // TRANSLATORS: skill fail error message + txt = strprintf(_("Unknown skill error: %d."), skillErrorCode); } txt.append(" "); switch (reason) { case RFAIL_SKILLDEP: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("You have not yet reached a high enough lvl!")); break; case RFAIL_INSUFHP: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("Insufficient HP!")); break; case RFAIL_INSUFSP: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("Insufficient SP!")); break; case RFAIL_NOMEMO: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("You have no memos!")); break; case RFAIL_SKILLDELAY: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("You cannot do that right now!")); break; case RFAIL_ZENY: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("Seems you need more money... ;-)")); break; case RFAIL_WEAPON: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("You cannot use this skill with that " - "kind of weapon!")); + "kind of weapon!")); break; case RFAIL_REDGEM: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("You need another red gem!")); break; case RFAIL_BLUEGEM: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("You need another blue gem!")); break; case RFAIL_OVERWEIGHT: - // TRANSLATORS: error message - txt.append(_("You're carrying to much to do this!")); + // TRANSLATORS: skill fail error message + txt.append(_("You're carrying too much to do this!")); break; case RFAIL_SUMMON: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("Fail summon.")); break; case RFAIL_SPIRITS: - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("Need spirits.")); break; case RFAIL_NEED_EQUIPMENT: { const int amount = bskill; - const ItemInfo &info = ItemDB::get(itemId); + const char* const link = ItemDB::get(itemId).getLink().c_str(); if (amount == 1) { - // TRANSLATORS: skill error message - txt.append(strprintf(_("Need equipment %s."), - info.getLink().c_str())); + // TRANSLATORS: skill fail error message + txt.append(strprintf(_("Need equipment %s."), link)); } else { - // TRANSLATORS: skill error message - txt.append(strprintf(_("Need equipment %s and amount %d"), - info.getLink().c_str(), - amount)); + // TRANSLATORS: skill fail error message + txt.append(strprintf(_("Need %d of equipment %s"), + amount, link)); } break; } case RFAIL_NEED_ITEM: { const int amount = bskill; - const ItemInfo &info = ItemDB::get(itemId); + const char* const link = ItemDB::get(itemId).getLink().c_str(); if (amount == 1) { - // TRANSLATORS: skill error message - txt.append(strprintf(_("Need item %s."), - info.getLink().c_str())); + // TRANSLATORS: skill fail error message + txt.append(strprintf(_("Need item %s."), link)); } else { - // TRANSLATORS: skill error message - txt.append(strprintf(_("Need item %s and amount %d"), - info.getLink().c_str(), - amount)); + // TRANSLATORS: skill fail error message + txt.append(strprintf(_("Need %d of item %s"), + amount, link)); } break; } case RFAIL: { - // TRANSLATORS: error message + // TRANSLATORS: skill fail error message txt.append(_("Skill failed!")); break; } @@ -424,6 +412,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) UNIMPLEMENTEDPACKETFIELD(reason); break; } + if (debugChatTab != nullptr) debugChatTab->chatLog("SKILL: " + txt, |