From dd996d01676d7dca3eec442b14c4966ba0bb0935 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 Oct 2012 01:40:58 +0300 Subject: Delete copy constructor from net classes. --- src/net/charhandler.h | 4 ++++ src/net/download.h | 2 ++ src/net/ea/adminhandler.h | 5 +++++ src/net/ea/beinghandler.h | 2 ++ src/net/ea/buysellhandler.h | 2 ++ src/net/ea/charserverhandler.h | 2 ++ src/net/ea/chathandler.h | 2 ++ src/net/ea/gamehandler.h | 2 ++ src/net/ea/gui/guildtab.h | 2 ++ src/net/ea/gui/partytab.h | 2 ++ src/net/ea/guildhandler.h | 2 ++ src/net/ea/inventoryhandler.cpp | 2 +- src/net/ea/inventoryhandler.h | 4 ++++ src/net/ea/itemhandler.h | 2 ++ src/net/ea/loginhandler.h | 2 ++ src/net/ea/network.h | 2 ++ src/net/ea/npchandler.h | 2 ++ src/net/ea/partyhandler.h | 2 ++ src/net/ea/playerhandler.h | 2 ++ src/net/ea/specialhandler.h | 2 ++ src/net/ea/tradehandler.h | 2 ++ src/net/eathena/adminhandler.h | 2 ++ src/net/eathena/beinghandler.h | 2 ++ src/net/eathena/buysellhandler.h | 2 ++ src/net/eathena/charserverhandler.h | 2 ++ src/net/eathena/chathandler.h | 2 ++ src/net/eathena/gamehandler.h | 2 ++ src/net/eathena/generalhandler.h | 2 ++ src/net/eathena/gui/guildtab.h | 2 ++ src/net/eathena/gui/partytab.h | 2 ++ src/net/eathena/guildhandler.h | 2 ++ src/net/eathena/inventoryhandler.h | 2 ++ src/net/eathena/itemhandler.h | 2 ++ src/net/eathena/loginhandler.h | 2 ++ src/net/eathena/messagehandler.h | 2 ++ src/net/eathena/messagein.h | 2 ++ src/net/eathena/messageout.h | 2 ++ src/net/eathena/network.cpp | 18 ++++++++++-------- src/net/eathena/network.h | 4 +++- src/net/eathena/npchandler.h | 2 ++ src/net/eathena/partyhandler.h | 2 ++ src/net/eathena/playerhandler.h | 2 ++ src/net/eathena/specialhandler.h | 2 ++ src/net/eathena/tradehandler.h | 2 ++ src/net/logindata.h | 4 +++- src/net/messagein.h | 4 ++++ src/net/messageout.h | 5 ++++- src/net/tmwa/adminhandler.h | 2 ++ src/net/tmwa/beinghandler.h | 2 ++ src/net/tmwa/buysellhandler.h | 2 ++ src/net/tmwa/charserverhandler.h | 2 ++ src/net/tmwa/chathandler.h | 2 ++ src/net/tmwa/gamehandler.h | 2 ++ src/net/tmwa/generalhandler.h | 2 ++ src/net/tmwa/gui/guildtab.h | 2 ++ src/net/tmwa/gui/partytab.h | 2 ++ src/net/tmwa/guildhandler.h | 2 ++ src/net/tmwa/inventoryhandler.h | 2 ++ src/net/tmwa/itemhandler.h | 2 ++ src/net/tmwa/loginhandler.h | 2 ++ src/net/tmwa/messagehandler.h | 2 ++ src/net/tmwa/messagein.h | 2 ++ src/net/tmwa/messageout.h | 2 ++ src/net/tmwa/network.cpp | 18 ++++++++++-------- src/net/tmwa/network.h | 4 +++- src/net/tmwa/npchandler.h | 2 ++ src/net/tmwa/partyhandler.h | 2 ++ src/net/tmwa/playerhandler.h | 2 ++ src/net/tmwa/questhandler.h | 2 ++ src/net/tmwa/specialhandler.h | 2 ++ src/net/tmwa/tradehandler.h | 2 ++ 71 files changed, 171 insertions(+), 21 deletions(-) diff --git a/src/net/charhandler.h b/src/net/charhandler.h index 092e0f135..ecaabfebb 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -47,6 +47,8 @@ struct Character { } + A_DELETE_COPY(Character); + ~Character() { delete dummy; @@ -63,6 +65,8 @@ typedef std::list Characters; class CharHandler { public: + A_DELETE_COPY(CharHandler); + virtual ~CharHandler() { } diff --git a/src/net/download.h b/src/net/download.h index cb74e5e0a..fdc048447 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -59,6 +59,8 @@ class Download final Download(void *ptr, const std::string &url, DownloadUpdate updateFunction, bool ignoreError = false); + A_DELETE_COPY(Download); + ~Download(); void addHeader(const std::string &header); diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h index 5b5224174..a6c88f8c5 100644 --- a/src/net/ea/adminhandler.h +++ b/src/net/ea/adminhandler.h @@ -32,6 +32,11 @@ namespace Ea class AdminHandler : public Net::AdminHandler { public: + AdminHandler() + { } + + A_DELETE_COPY(AdminHandler); + virtual ~AdminHandler() { } diff --git a/src/net/ea/beinghandler.h b/src/net/ea/beinghandler.h index b4fd5f93f..f49dbb427 100644 --- a/src/net/ea/beinghandler.h +++ b/src/net/ea/beinghandler.h @@ -34,6 +34,8 @@ class BeingHandler : public Net::BeingHandler public: BeingHandler(bool enableSync); + A_DELETE_COPY(BeingHandler); + protected: virtual void requestNameById(int id) = 0; diff --git a/src/net/ea/buysellhandler.h b/src/net/ea/buysellhandler.h index 26f0d2716..3119d5d18 100644 --- a/src/net/ea/buysellhandler.h +++ b/src/net/ea/buysellhandler.h @@ -39,6 +39,8 @@ class BuySellHandler : public Net::BuySellHandler public: BuySellHandler(); + A_DELETE_COPY(BuySellHandler); + virtual void requestSellList(std::string nick); virtual void requestBuyList(std::string nick); diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index c0978157c..b2cbd3044 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -40,6 +40,8 @@ class CharServerHandler : public Net::CharHandler public: CharServerHandler(); + A_DELETE_COPY(CharServerHandler); + virtual void setCharSelectDialog(CharSelectDialog *window); /** diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index baa9a01b5..f7bf0e861 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -38,6 +38,8 @@ class ChatHandler : public Net::ChatHandler public: ChatHandler(); + A_DELETE_COPY(ChatHandler); + virtual void talk(const std::string &text) = 0; virtual void talkRaw(const std::string &text) = 0; diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h index 969abbbbb..89546301b 100644 --- a/src/net/ea/gamehandler.h +++ b/src/net/ea/gamehandler.h @@ -37,6 +37,8 @@ class GameHandler : public Net::GameHandler, public Listener public: GameHandler(); + A_DELETE_COPY(GameHandler); + virtual void processEvent(Channels channel, const DepricatedEvent &event) override; diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index 07b9831ec..986231cd3 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -36,6 +36,8 @@ class GuildTab : public ChatTab public: GuildTab(); + A_DELETE_COPY(GuildTab); + ~GuildTab(); bool handleCommand(const std::string &type, diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index 7b503fd71..e80840dc5 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -36,6 +36,8 @@ class PartyTab : public ChatTab public: PartyTab(); + A_DELETE_COPY(PartyTab); + ~PartyTab(); void showHelp() override; diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h index 5b7442a40..e518a290e 100644 --- a/src/net/ea/guildhandler.h +++ b/src/net/ea/guildhandler.h @@ -35,6 +35,8 @@ class GuildHandler : public Net::GuildHandler public: GuildHandler(); + A_DELETE_COPY(GuildHandler); + ~GuildHandler(); void requestAlliance(int guildId, int otherGuildId); diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 1da1fe4ea..193e4a7b6 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -219,7 +219,7 @@ void InventoryHandler::processPlayerInventory(Net::MessageIn &msg, if (inventory) { inventory->setItem(index, itemId, amount, - 0, identified, isEquipment); + 0, identified, isEquipment); } } else diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 15c2e0994..cd56dd31f 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -46,6 +46,8 @@ class EquipBackend : public Equipment::Backend memset(mEquipment, -1, sizeof(mEquipment)); } + A_DELETE_COPY(EquipBackend); + Item *getEquipment(int index) const { int invyIndex = mEquipment[index]; @@ -140,6 +142,8 @@ class InventoryHandler : public Net::InventoryHandler InventoryHandler(); + A_DELETE_COPY(InventoryHandler); + ~InventoryHandler(); bool canSplit(const Item *item) const; diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h index d5c268d2e..c5193dda6 100644 --- a/src/net/ea/itemhandler.h +++ b/src/net/ea/itemhandler.h @@ -34,6 +34,8 @@ class ItemHandler public: ItemHandler(); + A_DELETE_COPY(ItemHandler); + void processItemVisible(Net::MessageIn &msg); void processItemRemove(Net::MessageIn &msg); diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index c3bd2a4e8..02789a999 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -41,6 +41,8 @@ class LoginHandler : public Net::LoginHandler public: LoginHandler(); + A_DELETE_COPY(LoginHandler); + ~LoginHandler(); int supportedOptionalActions() const diff --git a/src/net/ea/network.h b/src/net/ea/network.h index d61332fe1..ab21fab37 100644 --- a/src/net/ea/network.h +++ b/src/net/ea/network.h @@ -42,6 +42,8 @@ class Network public: Network(); + A_DELETE_COPY(Network); + ~Network(); bool connect(ServerInfo server); diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index be0465375..93978c62e 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -39,6 +39,8 @@ class NpcHandler : public Net::NpcHandler public: NpcHandler(); + A_DELETE_COPY(NpcHandler); + void sendLetter(int npcId, const std::string &recipient, const std::string &text); diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index f08930e8c..8c10bb71e 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -38,6 +38,8 @@ class PartyHandler : public Net::PartyHandler public: PartyHandler(); + A_DELETE_COPY(PartyHandler); + ~PartyHandler(); void join(int partyId); diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index 3e9d14804..168bd2a89 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -35,6 +35,8 @@ class PlayerHandler : public Net::PlayerHandler public: PlayerHandler(); + A_DELETE_COPY(PlayerHandler); + void decreaseAttribute(int attr); void ignorePlayer(const std::string &player, bool ignore); diff --git a/src/net/ea/specialhandler.h b/src/net/ea/specialhandler.h index c2b05399e..fefef91b8 100644 --- a/src/net/ea/specialhandler.h +++ b/src/net/ea/specialhandler.h @@ -35,6 +35,8 @@ class SpecialHandler : public Net::SpecialHandler public: SpecialHandler(); + A_DELETE_COPY(SpecialHandler); + void handleMessage(Net::MessageIn &msg); void use(int id); diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h index 07e9cc23b..a97f066ec 100644 --- a/src/net/ea/tradehandler.h +++ b/src/net/ea/tradehandler.h @@ -35,6 +35,8 @@ class TradeHandler : public Net::TradeHandler public: TradeHandler(); + A_DELETE_COPY(TradeHandler); + void removeItem(int slotNum, int amount); void processTradeRequest(Net::MessageIn &msg); diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h index ce341e53f..f6a3bc961 100644 --- a/src/net/eathena/adminhandler.h +++ b/src/net/eathena/adminhandler.h @@ -38,6 +38,8 @@ class AdminHandler final : public MessageHandler, public Ea::AdminHandler public: AdminHandler(); + A_DELETE_COPY(AdminHandler); + void handleMessage(Net::MessageIn &msg); void announce(const std::string &text); diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index 956b3758a..f278ef72a 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -38,6 +38,8 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler public: BeingHandler(bool enableSync); + A_DELETE_COPY(BeingHandler); + virtual void handleMessage(Net::MessageIn &msg); virtual void requestNameById(int id); diff --git a/src/net/eathena/buysellhandler.h b/src/net/eathena/buysellhandler.h index 3985aa184..337e0e8c2 100644 --- a/src/net/eathena/buysellhandler.h +++ b/src/net/eathena/buysellhandler.h @@ -37,6 +37,8 @@ class BuySellHandler final : public MessageHandler, public Ea::BuySellHandler public: BuySellHandler(); + A_DELETE_COPY(BuySellHandler); + virtual void handleMessage(Net::MessageIn &msg); virtual void processNpcBuy(Net::MessageIn &msg); diff --git a/src/net/eathena/charserverhandler.h b/src/net/eathena/charserverhandler.h index aa24318cf..d5362be28 100644 --- a/src/net/eathena/charserverhandler.h +++ b/src/net/eathena/charserverhandler.h @@ -45,6 +45,8 @@ class CharServerHandler final : public MessageHandler, public: CharServerHandler(); + A_DELETE_COPY(CharServerHandler); + virtual void handleMessage(Net::MessageIn &msg); void chooseCharacter(Net::Character *character); diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index ab8f81659..61d926240 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -38,6 +38,8 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler public: ChatHandler(); + A_DELETE_COPY(ChatHandler); + void handleMessage(Net::MessageIn &msg); void talk(const std::string &text); diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h index ec0c99c91..05a61a18a 100644 --- a/src/net/eathena/gamehandler.h +++ b/src/net/eathena/gamehandler.h @@ -38,6 +38,8 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler public: GameHandler(); + A_DELETE_COPY(GameHandler); + void handleMessage(Net::MessageIn &msg); void connect(); diff --git a/src/net/eathena/generalhandler.h b/src/net/eathena/generalhandler.h index 7e3a1ad9e..f20fec9f9 100644 --- a/src/net/eathena/generalhandler.h +++ b/src/net/eathena/generalhandler.h @@ -40,6 +40,8 @@ class GeneralHandler final : public MessageHandler, public: GeneralHandler(); + A_DELETE_COPY(GeneralHandler); + ~GeneralHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/eathena/gui/guildtab.h b/src/net/eathena/gui/guildtab.h index 55a622c9d..e06e76cf3 100644 --- a/src/net/eathena/gui/guildtab.h +++ b/src/net/eathena/gui/guildtab.h @@ -36,6 +36,8 @@ class GuildTab : public Ea::GuildTab public: GuildTab(); + A_DELETE_COPY(GuildTab); + ~GuildTab(); }; diff --git a/src/net/eathena/gui/partytab.h b/src/net/eathena/gui/partytab.h index 5e9a42e59..ba093fa2d 100644 --- a/src/net/eathena/gui/partytab.h +++ b/src/net/eathena/gui/partytab.h @@ -36,6 +36,8 @@ class PartyTab : public Ea::PartyTab public: PartyTab(); + A_DELETE_COPY(PartyTab); + ~PartyTab(); }; diff --git a/src/net/eathena/guildhandler.h b/src/net/eathena/guildhandler.h index fdcb88368..a1c1c5b0c 100644 --- a/src/net/eathena/guildhandler.h +++ b/src/net/eathena/guildhandler.h @@ -36,6 +36,8 @@ class GuildHandler final : public Ea::GuildHandler, public MessageHandler public: GuildHandler(); + A_DELETE_COPY(GuildHandler); + ~GuildHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index 5a83e7b87..9291aef89 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -40,6 +40,8 @@ class InventoryHandler final : public MessageHandler, public: InventoryHandler(); + A_DELETE_COPY(InventoryHandler); + ~InventoryHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/eathena/itemhandler.h b/src/net/eathena/itemhandler.h index 60e65d27a..0c0fea12f 100644 --- a/src/net/eathena/itemhandler.h +++ b/src/net/eathena/itemhandler.h @@ -35,6 +35,8 @@ class ItemHandler final : public MessageHandler, public Ea::ItemHandler public: ItemHandler(); + A_DELETE_COPY(ItemHandler); + virtual void handleMessage(Net::MessageIn &msg); }; diff --git a/src/net/eathena/loginhandler.h b/src/net/eathena/loginhandler.h index 26cafb5c7..de46e890a 100644 --- a/src/net/eathena/loginhandler.h +++ b/src/net/eathena/loginhandler.h @@ -41,6 +41,8 @@ class LoginHandler final : public MessageHandler, public Ea::LoginHandler public: LoginHandler(); + A_DELETE_COPY(LoginHandler); + ~LoginHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/eathena/messagehandler.h b/src/net/eathena/messagehandler.h index a8dfa1b5b..4252ed948 100644 --- a/src/net/eathena/messagehandler.h +++ b/src/net/eathena/messagehandler.h @@ -44,6 +44,8 @@ class MessageHandler : public Net::MessageHandler public: MessageHandler(); + A_DELETE_COPY(MessageHandler); + ~MessageHandler(); void setNetwork(Network *network); diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h index f6a1ec7ba..b2538313c 100644 --- a/src/net/eathena/messagein.h +++ b/src/net/eathena/messagein.h @@ -46,6 +46,8 @@ class MessageIn final : public Net::MessageIn */ MessageIn(const char *data, unsigned int length); + A_DELETE_COPY(MessageIn); + int16_t readInt16(); /**< Reads a short. */ int readInt32(); /**< Reads a long. */ }; diff --git a/src/net/eathena/messageout.h b/src/net/eathena/messageout.h index 530702e7d..79d858c07 100644 --- a/src/net/eathena/messageout.h +++ b/src/net/eathena/messageout.h @@ -48,6 +48,8 @@ class MessageOut final : public Net::MessageOut */ MessageOut(short id); + A_DELETE_COPY(MessageOut); + void writeInt16(int16_t value); /**< Writes a short. */ void writeInt32(int32_t value); /**< Writes a long. */ diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp index 8a9a010f8..a240a3a74 100644 --- a/src/net/eathena/network.cpp +++ b/src/net/eathena/network.cpp @@ -159,24 +159,26 @@ void Network::dispatchMessages() { while (messageReady()) { - MessageIn msg = getNextMessage(); + MessageIn *const msg = getNextMessage(); - const MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); + const MessageHandlerIterator iter = mMessageHandlers.find( + msg->getId()); - if (msg.getLength() == 0) + if (msg->getLength() == 0) logger->safeError("Zero length packet received. Exiting."); if (iter != mMessageHandlers.end()) { if (iter->second) - iter->second->handleMessage(msg); + iter->second->handleMessage(*msg); } else { - logger->log("Unhandled packet: %x", msg.getId()); + logger->log("Unhandled packet: %x", msg->getId()); } - skip(msg.getLength()); + skip(msg->getLength()); + delete msg; } } @@ -205,7 +207,7 @@ bool Network::messageReady() return ret; } -MessageIn Network::getNextMessage() +MessageIn *Network::getNextMessage() { while (!messageReady()) { @@ -241,7 +243,7 @@ MessageIn Network::getNextMessage() msgId, len)); #endif - MessageIn msg(mInBuffer, len); + MessageIn *msg = new MessageIn(mInBuffer, len); SDL_mutexV(mMutex); return msg; diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h index 63ec5a20b..b9cbff28e 100644 --- a/src/net/eathena/network.h +++ b/src/net/eathena/network.h @@ -48,6 +48,8 @@ class Network final : public Ea::Network public: Network(); + A_DELETE_COPY(Network); + ~Network(); void registerHandler(MessageHandler *handler); @@ -58,7 +60,7 @@ class Network final : public Ea::Network bool messageReady(); - MessageIn getNextMessage(); + MessageIn *getNextMessage(); void dispatchMessages(); diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h index 2417629e3..4a98f3aa5 100644 --- a/src/net/eathena/npchandler.h +++ b/src/net/eathena/npchandler.h @@ -42,6 +42,8 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler public: NpcHandler(); + A_DELETE_COPY(NpcHandler); + void handleMessage(Net::MessageIn &msg); void talk(int npcId); diff --git a/src/net/eathena/partyhandler.h b/src/net/eathena/partyhandler.h index 22433c668..b9a9f9d56 100644 --- a/src/net/eathena/partyhandler.h +++ b/src/net/eathena/partyhandler.h @@ -37,6 +37,8 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler public: PartyHandler(); + A_DELETE_COPY(PartyHandler); + ~PartyHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h index 0dc5d3a17..130a22019 100644 --- a/src/net/eathena/playerhandler.h +++ b/src/net/eathena/playerhandler.h @@ -38,6 +38,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler public: PlayerHandler(); + A_DELETE_COPY(PlayerHandler); + void handleMessage(Net::MessageIn &msg); void attack(int id, bool keep = false); diff --git a/src/net/eathena/specialhandler.h b/src/net/eathena/specialhandler.h index e8603ac2e..17989fae2 100644 --- a/src/net/eathena/specialhandler.h +++ b/src/net/eathena/specialhandler.h @@ -38,6 +38,8 @@ class SpecialHandler final : public MessageHandler, public Ea::SpecialHandler public: SpecialHandler(); + A_DELETE_COPY(SpecialHandler); + void handleMessage(Net::MessageIn &msg); void useBeing(int id, int level, int beingId); diff --git a/src/net/eathena/tradehandler.h b/src/net/eathena/tradehandler.h index acd282961..dcff97340 100644 --- a/src/net/eathena/tradehandler.h +++ b/src/net/eathena/tradehandler.h @@ -38,6 +38,8 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler public: TradeHandler(); + A_DELETE_COPY(TradeHandler); + void handleMessage(Net::MessageIn &msg); void request(Being *being); diff --git a/src/net/logindata.h b/src/net/logindata.h index 8988c5890..3d8a2bea3 100644 --- a/src/net/logindata.h +++ b/src/net/logindata.h @@ -30,7 +30,7 @@ class LoginData final { public: - LoginData(): + LoginData() : username(""), password(""), newPassword(""), @@ -45,6 +45,8 @@ class LoginData final resetCharacterSlots(); } + A_DELETE_COPY(LoginData); + enum UpdateType { Upd_Normal = 0, diff --git a/src/net/messagein.h b/src/net/messagein.h index 37caa7731..5713ab4ee 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -27,6 +27,8 @@ #include +#include "localconsts.h" + namespace Net { @@ -38,6 +40,8 @@ namespace Net class MessageIn { public: + A_DELETE_COPY(MessageIn); + /** * Returns the message ID. */ diff --git a/src/net/messageout.h b/src/net/messageout.h index 793fe04b9..81f805014 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -26,9 +26,10 @@ #include #include - #include +#include "localconsts.h" + namespace Net { @@ -40,6 +41,8 @@ namespace Net class MessageOut { public: + A_DELETE_COPY(MessageOut); + virtual void writeInt8(int8_t value); /**< Writes a byte. */ virtual void writeInt16(int16_t value) = 0; /**< Writes a short. */ diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index 6bb1b9fd0..34d009f05 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -38,6 +38,8 @@ class AdminHandler final : public MessageHandler, public Ea::AdminHandler public: AdminHandler(); + A_DELETE_COPY(AdminHandler); + void handleMessage(Net::MessageIn &msg); void announce(const std::string &text); diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index a5732166c..94ba5b234 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -38,6 +38,8 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler public: BeingHandler(bool enableSync); + A_DELETE_COPY(BeingHandler); + virtual void handleMessage(Net::MessageIn &msg); virtual void requestNameById(int id); diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h index 4c9736cf2..942a00c11 100644 --- a/src/net/tmwa/buysellhandler.h +++ b/src/net/tmwa/buysellhandler.h @@ -37,6 +37,8 @@ class BuySellHandler final : public MessageHandler, public Ea::BuySellHandler public: BuySellHandler(); + A_DELETE_COPY(BuySellHandler); + virtual void handleMessage(Net::MessageIn &msg); virtual void processNpcBuy(Net::MessageIn &msg); diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index f85d128b6..61cf6333d 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -45,6 +45,8 @@ class CharServerHandler final : public MessageHandler, public: CharServerHandler(); + A_DELETE_COPY(CharServerHandler); + virtual void handleMessage(Net::MessageIn &msg); void chooseCharacter(Net::Character *character); diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index 4d46bbeac..95af1068d 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -38,6 +38,8 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler public: ChatHandler(); + A_DELETE_COPY(ChatHandler); + void handleMessage(Net::MessageIn &msg); void talk(const std::string &text); diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h index 9dac38d19..117555bda 100644 --- a/src/net/tmwa/gamehandler.h +++ b/src/net/tmwa/gamehandler.h @@ -38,6 +38,8 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler public: GameHandler(); + A_DELETE_COPY(GameHandler); + void handleMessage(Net::MessageIn &msg); void connect(); diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index 1438ce4db..0358b6020 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -39,6 +39,8 @@ class GeneralHandler final : public MessageHandler, public Net::GeneralHandler, public: GeneralHandler(); + A_DELETE_COPY(GeneralHandler); + ~GeneralHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/tmwa/gui/guildtab.h b/src/net/tmwa/gui/guildtab.h index 351dadfd6..5fe71f236 100644 --- a/src/net/tmwa/gui/guildtab.h +++ b/src/net/tmwa/gui/guildtab.h @@ -36,6 +36,8 @@ class GuildTab : public Ea::GuildTab public: GuildTab(); + A_DELETE_COPY(GuildTab); + ~GuildTab(); }; diff --git a/src/net/tmwa/gui/partytab.h b/src/net/tmwa/gui/partytab.h index 0bdc11372..e1a5e94b1 100644 --- a/src/net/tmwa/gui/partytab.h +++ b/src/net/tmwa/gui/partytab.h @@ -36,6 +36,8 @@ class PartyTab : public Ea::PartyTab public: PartyTab(); + A_DELETE_COPY(PartyTab); + ~PartyTab(); }; diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h index bea2b2c3b..8a4bae92b 100644 --- a/src/net/tmwa/guildhandler.h +++ b/src/net/tmwa/guildhandler.h @@ -36,6 +36,8 @@ class GuildHandler final : public Ea::GuildHandler, public MessageHandler public: GuildHandler(); + A_DELETE_COPY(GuildHandler); + ~GuildHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 7e3fabf42..a84e43f5f 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -40,6 +40,8 @@ class InventoryHandler final : public MessageHandler, public: InventoryHandler(); + A_DELETE_COPY(InventoryHandler); + ~InventoryHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h index 02fbba796..a66169015 100644 --- a/src/net/tmwa/itemhandler.h +++ b/src/net/tmwa/itemhandler.h @@ -35,6 +35,8 @@ class ItemHandler final : public MessageHandler, public Ea::ItemHandler public: ItemHandler(); + A_DELETE_COPY(ItemHandler); + virtual void handleMessage(Net::MessageIn &msg); }; diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h index 108b5fbd3..b2149caff 100644 --- a/src/net/tmwa/loginhandler.h +++ b/src/net/tmwa/loginhandler.h @@ -41,6 +41,8 @@ class LoginHandler final : public MessageHandler, public Ea::LoginHandler public: LoginHandler(); + A_DELETE_COPY(LoginHandler); + ~LoginHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h index 930fe4858..b5012d906 100644 --- a/src/net/tmwa/messagehandler.h +++ b/src/net/tmwa/messagehandler.h @@ -44,6 +44,8 @@ class MessageHandler : public Net::MessageHandler public: MessageHandler(); + A_DELETE_COPY(MessageHandler); + ~MessageHandler(); void setNetwork(Network *network); diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h index adc79a6b8..8c5fc7c77 100644 --- a/src/net/tmwa/messagein.h +++ b/src/net/tmwa/messagein.h @@ -46,6 +46,8 @@ class MessageIn final : public Net::MessageIn */ MessageIn(const char *data, unsigned int length); + A_DELETE_COPY(MessageIn); + int16_t readInt16(); /**< Reads a short. */ int readInt32(); /**< Reads a long. */ }; diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h index 72341c4c1..6ebcca8e3 100644 --- a/src/net/tmwa/messageout.h +++ b/src/net/tmwa/messageout.h @@ -48,6 +48,8 @@ class MessageOut final : public Net::MessageOut */ MessageOut(short id); + A_DELETE_COPY(MessageOut); + void writeInt16(int16_t value); /**< Writes a short. */ void writeInt32(int32_t value); /**< Writes a long. */ diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 15200fa50..278f8e2fd 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -137,24 +137,26 @@ void Network::dispatchMessages() { while (messageReady()) { - MessageIn msg = getNextMessage(); + MessageIn *const msg = getNextMessage(); - const MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); + const MessageHandlerIterator iter = mMessageHandlers.find( + msg->getId()); - if (msg.getLength() == 0) + if (msg->getLength() == 0) logger->safeError("Zero length packet received. Exiting."); if (iter != mMessageHandlers.end()) { if (iter->second) - iter->second->handleMessage(msg); + iter->second->handleMessage(*msg); } else { - logger->log("Unhandled packet: %x", msg.getId()); + logger->log("Unhandled packet: %x", msg->getId()); } - skip(msg.getLength()); + skip(msg->getLength()); + delete msg; } } @@ -193,7 +195,7 @@ bool Network::messageReady() return ret; } -MessageIn Network::getNextMessage() +MessageIn *Network::getNextMessage() { while (!messageReady()) { @@ -219,7 +221,7 @@ MessageIn Network::getNextMessage() // msgId, len)); #endif - MessageIn msg(mInBuffer, len); + MessageIn *msg = new MessageIn(mInBuffer, len); SDL_mutexV(mMutex); return msg; diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 4db67e92c..2ec62d25c 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -49,6 +49,8 @@ class Network final : public Ea::Network public: Network(); + A_DELETE_COPY(Network); + ~Network(); void registerHandler(MessageHandler *handler); @@ -59,7 +61,7 @@ class Network final : public Ea::Network bool messageReady(); - MessageIn getNextMessage(); + MessageIn *getNextMessage(); void dispatchMessages(); diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h index a10c455f3..3b0f29d64 100644 --- a/src/net/tmwa/npchandler.h +++ b/src/net/tmwa/npchandler.h @@ -42,6 +42,8 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler public: NpcHandler(); + A_DELETE_COPY(NpcHandler); + void handleMessage(Net::MessageIn &msg); void talk(int npcId); diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 61b873d5d..3b92b7c33 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -37,6 +37,8 @@ class PartyHandler final : public MessageHandler, public Ea::PartyHandler public: PartyHandler(); + A_DELETE_COPY(PartyHandler); + ~PartyHandler(); void handleMessage(Net::MessageIn &msg); diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 6633eb506..923e3e934 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -38,6 +38,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler public: PlayerHandler(); + A_DELETE_COPY(PlayerHandler); + void handleMessage(Net::MessageIn &msg); void attack(int id, bool keep = false); diff --git a/src/net/tmwa/questhandler.h b/src/net/tmwa/questhandler.h index a2f7ad9a7..09e6ef362 100644 --- a/src/net/tmwa/questhandler.h +++ b/src/net/tmwa/questhandler.h @@ -38,6 +38,8 @@ class QuestHandler final : public MessageHandler public: QuestHandler(); + A_DELETE_COPY(QuestHandler); + void handleMessage(Net::MessageIn &msg); void processSetQuestVar(Net::MessageIn &msg); diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h index 3fbca307c..9213f270f 100644 --- a/src/net/tmwa/specialhandler.h +++ b/src/net/tmwa/specialhandler.h @@ -38,6 +38,8 @@ class SpecialHandler final : public MessageHandler, public Ea::SpecialHandler public: SpecialHandler(); + A_DELETE_COPY(SpecialHandler); + void handleMessage(Net::MessageIn &msg); void useBeing(int id, int level, int beingId); diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h index 8ac152e71..c16172a83 100644 --- a/src/net/tmwa/tradehandler.h +++ b/src/net/tmwa/tradehandler.h @@ -38,6 +38,8 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler public: TradeHandler(); + A_DELETE_COPY(TradeHandler); + void handleMessage(Net::MessageIn &msg); void request(Being *being); -- cgit v1.2.3-70-g09d2