diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-22 13:02:26 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-22 14:32:45 +0100 |
commit | 81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08 (patch) | |
tree | e2619b16a5331e5760d94be389d0a3a01427293f /src/net/tmwa | |
parent | d047db79f7034e0e75a85a656d18f40716d197b9 (diff) | |
download | Mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.gz Mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.bz2 Mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.tar.xz Mana-81e4f170d8ba4ccbcfa1e6c07bd0522dfc3b6e08.zip |
General code cleanups
* Use default member initializers
* Use range-based loops
* Don't use 'else' after 'return'
* Removed some unused includes
* Construct empty strings with std::string() instead of ""
* Clear strings with .clear() instead of assigning ""
* Check whether strings are empty with .empty() instead of comparing to ""
* Removed redundant initializations
Diffstat (limited to 'src/net/tmwa')
-rw-r--r-- | src/net/tmwa/beinghandler.cpp | 19 | ||||
-rw-r--r-- | src/net/tmwa/gui/guildtab.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/gui/partytab.cpp | 3 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/network.cpp | 10 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.cpp | 1 | ||||
-rw-r--r-- | src/net/tmwa/partyhandler.h | 4 |
7 files changed, 10 insertions, 33 deletions
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 4c7e18bb..50585970 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -410,18 +410,6 @@ void BeingHandler::handleMessage(MessageIn &msg) case SMSG_BEING_CHANGE_LOOKS2: { - /* - * SMSG_BEING_CHANGE_LOOKS (0x00c3) and - * SMSG_BEING_CHANGE_LOOKS2 (0x01d7) do basically the same - * thing. The difference is that ...LOOKS carries a single - * 8 bit value, where ...LOOKS2 carries two 16 bit values. - * - * If type = 2, then the first 16 bit value is the weapon ID, - * and the second 16 bit value is the shield ID. If no - * shield is equipped, or type is not 2, then the second - * 16 bit value will be 0. - */ - if (!(dstBeing = actorSpriteManager->findBeing(msg.readInt32()))) { break; @@ -472,7 +460,7 @@ void BeingHandler::handleMessage(MessageIn &msg) dstBeing->setSprite(SPRITE_MISC2, id); break; default: - logger->log("SMSG_BEING_CHANGE_LOOKS: unsupported type: " + logger->log("SMSG_BEING_CHANGE_LOOKS2: unsupported type: " "%d, id: %d", type, id); break; } @@ -530,12 +518,9 @@ void BeingHandler::handleMessage(MessageIn &msg) break; } - if (Party *party = local_player->getParty()){ + if (Party *party = local_player->getParty()) if (party->isMember(id)) - { dstBeing->setParty(party); - } - } // The original speed is ticks per tile * 10 if (speed) diff --git a/src/net/tmwa/gui/guildtab.cpp b/src/net/tmwa/gui/guildtab.cpp index b5a3203b..6014e507 100644 --- a/src/net/tmwa/gui/guildtab.cpp +++ b/src/net/tmwa/gui/guildtab.cpp @@ -29,13 +29,9 @@ #include "net/net.h" #include "net/guildhandler.h" -#include "resources/iteminfo.h" -#include "resources/itemdb.h" #include "resources/theme.h" -#include "utils/dtor.h" #include "utils/gettext.h" -#include "utils/stringutils.h" namespace TmwAthena { diff --git a/src/net/tmwa/gui/partytab.cpp b/src/net/tmwa/gui/partytab.cpp index 19f58777..89f3a769 100644 --- a/src/net/tmwa/gui/partytab.cpp +++ b/src/net/tmwa/gui/partytab.cpp @@ -29,11 +29,8 @@ #include "net/net.h" #include "net/partyhandler.h" -#include "resources/iteminfo.h" -#include "resources/itemdb.h" #include "resources/theme.h" -#include "utils/dtor.h" #include "utils/gettext.h" #include "utils/stringutils.h" diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h index 5f8c987c..4cbdd286 100644 --- a/src/net/tmwa/guildhandler.h +++ b/src/net/tmwa/guildhandler.h @@ -46,7 +46,7 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler void leave(int guildId) override; - void kick(GuildMember *member, std::string reason = "") override; + void kick(GuildMember *member, std::string reason = std::string()) override; void chat(int guildId, const std::string &text) override; diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 17c6b53e..b4ba0b20 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -402,21 +402,21 @@ void Network::dispatchMessages() if (mInSize < len) break; -#ifdef DEBUG - logger->log("Received %s (0x%x) of length %d", packetInfo->name, msgId, len); -#endif - MessageIn message(mInBuffer, len); // Dispatch the message to the appropriate handler auto iter = mMessageHandlers.find(msgId); if (iter != mMessageHandlers.end()) { +#ifdef DEBUG + logger->log("Handling %s (0x%x) of length %d", packetInfo->name, msgId, len); +#endif + iter->second->handleMessage(message); } else { - logger->log("Unhandled packet %s (0x%x)", packetInfo->name, msgId); + logger->log("Unhandled %s (0x%x) of length %d", packetInfo->name, msgId, len); } skip(len); diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 958c8c14..3b636c71 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -25,6 +25,7 @@ #include "event.h" #include "localplayer.h" #include "log.h" +#include "party.h" #include "gui/socialwindow.h" diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 5268f395..7b7e2420 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -27,8 +27,6 @@ #include "net/tmwa/messagehandler.h" -#include "party.h" - namespace TmwAthena { class PartyHandler : public MessageHandler, public Net::PartyHandler @@ -40,7 +38,7 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler void handleMessage(MessageIn &msg) override; - void create(const std::string &name = "") override; + void create(const std::string &name = std::string()) override; void join(int partyId) override; |