diff options
author | Fedja Beader <fedja@protonmail.ch> | 2024-08-28 15:15:27 +0000 |
---|---|---|
committer | Fedja Beader <fedja@protonmail.ch> | 2024-08-28 15:15:27 +0000 |
commit | 7929b1dc48116522b6ed82b05e864a5b15910de9 (patch) | |
tree | 9b3af9baa08a9dd500f5dbc8d11b3725420f15f2 /src | |
parent | e304e3feb771f3e1000addce04e7557f1211192a (diff) | |
download | plus-7929b1dc48116522b6ed82b05e864a5b15910de9.tar.gz plus-7929b1dc48116522b6ed82b05e864a5b15910de9.tar.bz2 plus-7929b1dc48116522b6ed82b05e864a5b15910de9.tar.xz plus-7929b1dc48116522b6ed82b05e864a5b15910de9.zip |
Remove silly msg.read* duplication
& shaves ~5KB from debug binary.
previd=""; while read -r line; do if [[ $line =~ .*"msg.read"[^\"]*"\""([^\"]*).* ]]; then id="${BASH_REMATCH[1]}"; if [[ "$id" == "$previd" ]]; then printf "%s\n" "$line"; fi; previd="$id"; fi; done < <(grep -r 'msg.read.*' src/net/)
****
mana/plus!91
Diffstat (limited to 'src')
-rw-r--r-- | src/net/ea/beingrecv.cpp | 5 | ||||
-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 | 1 | ||||
-rw-r--r-- | src/net/tmwa/beingrecv.cpp | 25 | ||||
-rw-r--r-- | src/net/tmwa/charserverrecv.cpp | 19 | ||||
-rw-r--r-- | src/net/tmwa/chatrecv.cpp | 12 | ||||
-rw-r--r-- | src/net/tmwa/partyrecv.cpp | 8 |
11 files changed, 46 insertions, 100 deletions
diff --git a/src/net/ea/beingrecv.cpp b/src/net/ea/beingrecv.cpp index a618f5aa6..e1990ec86 100644 --- a/src/net/ea/beingrecv.cpp +++ b/src/net/ea/beingrecv.cpp @@ -252,15 +252,16 @@ void BeingRecv::processBeingEmotion(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); + + const uint8_t emote = msg.readUInt8("emote"); + if (dstBeing == nullptr) { DEBUGLOGSTR("invisible player?"); - msg.readUInt8("emote"); BLOCK_END("BeingRecv::processBeingEmotion") return; } - const uint8_t emote = msg.readUInt8("emote"); if ((emote != 0U) && playerRelations.hasPermission(dstBeing, PlayerRelation::EMOTE)) { 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 dc24b15b4..35c19e953 100644 --- a/src/net/eathena/skillrecv.cpp +++ b/src/net/eathena/skillrecv.cpp @@ -289,6 +289,7 @@ void SkillRecv::processSkillFailed(Net::MessageIn &msg) if (localPlayer != nullptr) localPlayer->stopCast(true); + std::string txt; if (success == CAST_S32(SKILL_FAILED) && bskill != 0) { diff --git a/src/net/tmwa/beingrecv.cpp b/src/net/tmwa/beingrecv.cpp index 012042b00..ae0b8df26 100644 --- a/src/net/tmwa/beingrecv.cpp +++ b/src/net/tmwa/beingrecv.cpp @@ -113,16 +113,11 @@ void BeingRecv::processBeingChangeLook2(Net::MessageIn &msg) msg.readBeingId("being id")); const uint8_t type = msg.readUInt8("type"); - int id2 = 0; const int16_t id = msg.readInt16("id1"); - if (type == 2) + int id2 = msg.readInt16("id2"); + if (type != 2) { - id2 = msg.readInt16("id2"); - } - else - { - msg.readInt16("id2"); id2 = 1; } @@ -1360,17 +1355,16 @@ void BeingRecv::processBeingSelfEffect(Net::MessageIn &msg) } const BeingId id = msg.readBeingId("being id"); + const int effectType = msg.readInt32("effect type"); + Being *const being = actorManager->findBeing(id); if (being == nullptr) { - DEBUGLOGSTR("insible player?"); - msg.readInt32("effect type"); + DEBUGLOGSTR("invisible player?"); BLOCK_END("BeingRecv::processBeingSelfEffect") return; } - const int effectType = msg.readInt32("effect type"); - if (ParticleEngine::enabled) effectManager->trigger(effectType, being, 0); @@ -1399,16 +1393,11 @@ void BeingRecv::processIpResponse(Net::MessageIn &msg) Being *const dstBeing = actorManager->findBeing( msg.readBeingId("being id")); + const int ipAddress = msg.readInt32("ip address"); if (dstBeing != nullptr) - { - const std::string ip = ipToString(msg.readInt32("ip address")); - dstBeing->setIp(ip); - } + dstBeing->setIp(ipToString(ipAddress)); else - { - msg.readInt32("ip address"); DEBUGLOGSTR("invisible player?"); - } BLOCK_END("BeingRecv::processIpResponse") } diff --git a/src/net/tmwa/charserverrecv.cpp b/src/net/tmwa/charserverrecv.cpp index 6b8cf27c6..15f9ccdb7 100644 --- a/src/net/tmwa/charserverrecv.cpp +++ b/src/net/tmwa/charserverrecv.cpp @@ -207,15 +207,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 ipAddress = msg.readInt32("ip address"); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) - { - msg.readInt32("ip address"); server.hostname = settings.serverName; - } else - { - server.hostname = ipToString(msg.readInt32("ip address")); - } + server.hostname = ipToString(ipAddress); + server.port = msg.readInt16("port"); server.althostname = charServer.althostname; @@ -247,15 +245,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 ipAddress = msg.readInt32("ip address"); if (config.getBoolValue("usePersistentIP") || settings.persistentIp) - { - msg.readInt32("ip address"); server.hostname = settings.serverName; - } else - { - server.hostname = ipToString(msg.readInt32("ip address")); - } + server.hostname = ipToString(ipAddress); + server.port = msg.readInt16("port"); network->disconnect(); diff --git a/src/net/tmwa/chatrecv.cpp b/src/net/tmwa/chatrecv.cpp index 920676827..d16cd1c61 100644 --- a/src/net/tmwa/chatrecv.cpp +++ b/src/net/tmwa/chatrecv.cpp @@ -132,16 +132,10 @@ void ChatRecv::processGmChat(Net::MessageIn &msg) return; } - if (localChatTab != nullptr && - chatWindow != nullptr) - { - std::string chatMsg = msg.readRawString(chatMsgLength, "message"); + std::string chatMsg = msg.readRawString(chatMsgLength, "message"); + if (localChatTab != nullptr && chatWindow != nullptr) chatWindow->addGlobalMessage(chatMsg); - } - else - { - msg.readRawString(chatMsgLength, "message"); - } + BLOCK_END("ChatRecv::processChat") } diff --git a/src/net/tmwa/partyrecv.cpp b/src/net/tmwa/partyrecv.cpp index 1f5990377..19245ef34 100644 --- a/src/net/tmwa/partyrecv.cpp +++ b/src/net/tmwa/partyrecv.cpp @@ -237,15 +237,9 @@ void PartyRecv::processPartyInvited(Net::MessageIn &msg) } } + const std::string partyName = msg.readString(24, "party name"); if (socialWindow != nullptr) - { - const std::string partyName = msg.readString(24, "party name"); socialWindow->showPartyInvite(partyName, nick, 0); - } - else - { - msg.readString(24, "party name"); - } } void PartyRecv::processPartyMove(Net::MessageIn &msg) |