diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-26 16:07:54 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-26 16:07:54 +0100 |
commit | 5afe88df2538274859a162ffd63ed52118e80c19 (patch) | |
tree | b610dfd58dc748fd63f49565b2a43eea2316714f /src/net/manaserv | |
parent | 73ba2a95f5bd4a0dd09af52d5864800be2b0a4c6 (diff) | |
download | mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.gz mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.bz2 mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.xz mana-5afe88df2538274859a162ffd63ed52118e80c19.zip |
Apply C++11 fixits
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
Diffstat (limited to 'src/net/manaserv')
32 files changed, 222 insertions, 222 deletions
diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h index 83fbb854..1edcf6b6 100644 --- a/src/net/manaserv/adminhandler.h +++ b/src/net/manaserv/adminhandler.h @@ -33,27 +33,27 @@ class AdminHandler : public Net::AdminHandler, public MessageHandler public: AdminHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void announce(const std::string &text); + void announce(const std::string &text) override; - void localAnnounce(const std::string &text); + void localAnnounce(const std::string &text) override; - void hide(bool hide); + void hide(bool hide) override; - void kick(int playerId); + void kick(int playerId) override; - void kick(const std::string &name); + void kick(const std::string &name) override; - void ban(int playerId); + void ban(int playerId) override; - void ban(const std::string &name); + void ban(const std::string &name) override; - void unban(int playerId); + void unban(int playerId) override; - void unban(const std::string &name); + void unban(const std::string &name) override; - void mute(int playerId, int type, int limit); + void mute(int playerId, int type, int limit) override; }; } // namespace ManaServ diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 61b4ef81..6be90d51 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -113,10 +113,10 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg) { int type = msg.readInt8(); int id = msg.readInt16(); - Being::Action action = (Being::Action)msg.readInt8(); + auto action = (Being::Action)msg.readInt8(); int px = msg.readInt16(); int py = msg.readInt16(); - BeingDirection direction = (BeingDirection)msg.readInt8(); + auto direction = (BeingDirection)msg.readInt8(); Gender gender; int genderAsInt = msg.readInt8(); if (genderAsInt == ::GENDER_FEMALE) @@ -241,7 +241,7 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg) void BeingHandler::handleBeingAttackMessage(MessageIn &msg) { Being *being = actorSpriteManager->findBeing(msg.readInt16()); - const BeingDirection direction = (BeingDirection) msg.readInt8(); + const auto direction = (BeingDirection) msg.readInt8(); const int attackId = msg.readInt8(); if (!being) @@ -260,7 +260,7 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg) int damage = msg.readInt16(); if (being) { - being->takeDamage(0, damage, Being::HIT); + being->takeDamage(nullptr, damage, Being::HIT); } } } @@ -268,7 +268,7 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg) void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg) { Being *being = actorSpriteManager->findBeing(msg.readInt16()); - Being::Action action = (Being::Action) msg.readInt8(); + auto action = (Being::Action) msg.readInt8(); if (!being) return; @@ -299,7 +299,7 @@ void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg) }; std::string message(deadMsg[rand()%13]); message.append(std::string(" ") + _("Press OK to respawn.")); - OkDialog *dlg = new OkDialog(_("You Died"), message, false); + auto *dlg = new OkDialog(_("You Died"), message, false); dlg->addActionListener(&(ManaServ::respawnListener)); } } diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h index 94cf20c4..3d80f45f 100644 --- a/src/net/manaserv/beinghandler.h +++ b/src/net/manaserv/beinghandler.h @@ -43,7 +43,7 @@ class BeingHandler : public MessageHandler public: BeingHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; private: void handleBeingAttackMessage(MessageIn &msg); diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp index 2e7cf26d..5395adb8 100644 --- a/src/net/manaserv/buysellhandler.cpp +++ b/src/net/manaserv/buysellhandler.cpp @@ -57,7 +57,7 @@ void BuySellHandler::handleMessage(MessageIn &msg) { case GPMSG_NPC_BUY: { - BuyDialog* dialog = new BuyDialog(npcId); + auto* dialog = new BuyDialog(npcId); dialog->reset(); dialog->setMoney(PlayerInfo::getAttribute(MONEY)); @@ -74,7 +74,7 @@ void BuySellHandler::handleMessage(MessageIn &msg) case GPMSG_NPC_SELL: { - SellDialog* dialog = new SellDialog(npcId); + auto* dialog = new SellDialog(npcId); dialog->reset(); dialog->setMoney(PlayerInfo::getAttribute(MONEY)); diff --git a/src/net/manaserv/buysellhandler.h b/src/net/manaserv/buysellhandler.h index 88432842..f0ae9ab3 100644 --- a/src/net/manaserv/buysellhandler.h +++ b/src/net/manaserv/buysellhandler.h @@ -31,7 +31,7 @@ class BuySellHandler : public MessageHandler public: BuySellHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; }; } // namespace ManaServ diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index ece8e108..d5a5497e 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -187,7 +187,7 @@ void CharHandler::handleCharacterCreateResponse(MessageIn &msg) if (mCharCreateDialog) { mCharCreateDialog->scheduleDelete(); - mCharCreateDialog = 0; + mCharCreateDialog = nullptr; } } } @@ -228,7 +228,7 @@ void CharHandler::handleCharacterDeleteResponse(MessageIn &msg) } new OkDialog(_("Error"), errorMessage); } - mSelectedCharacter = 0; + mSelectedCharacter = nullptr; unlockCharSelectDialog(); } @@ -254,7 +254,7 @@ void CharHandler::handleCharacterSelectResponse(MessageIn &msg) // Prevent the selected local player from being deleted local_player = mSelectedCharacter->dummy; PlayerInfo::setBackend(mSelectedCharacter->data); - mSelectedCharacter->dummy = 0; + mSelectedCharacter->dummy = nullptr; Client::setState(STATE_CONNECT_GAME); } @@ -386,7 +386,7 @@ void CharHandler::updateCharacters() { const CachedCharacterInfo &info = mCachedCharacterInfos.at(i); - Net::Character *character = new Net::Character; + auto *character = new Net::Character; character->slot = info.slot; LocalPlayer *player = character->dummy = new LocalPlayer; player->setName(info.name); @@ -397,7 +397,7 @@ void CharHandler::updateCharacters() character->data.mAttributes[CHAR_POINTS] = info.characterPoints; character->data.mAttributes[CORR_POINTS] = info.correctionPoints; - for (CachedAttributes::const_iterator it = info.attribute.begin(), + for (auto it = info.attribute.begin(), it_end = info.attribute.end(); it != it_end; it++) { character->data.mStats[i].base = it->second.base; @@ -412,8 +412,8 @@ void CharHandler::updateCharacters() void CharHandler::clear() { - setCharCreateDialog(0); - setCharSelectDialog(0); + setCharCreateDialog(nullptr); + setCharSelectDialog(nullptr); mCachedCharacterInfos.clear(); updateCharacters(); diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h index d2159204..262d8a01 100644 --- a/src/net/manaserv/charhandler.h +++ b/src/net/manaserv/charhandler.h @@ -42,43 +42,43 @@ class CharHandler : public MessageHandler, public Net::CharHandler public: CharHandler(); - ~CharHandler(); + ~CharHandler() override; - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void setCharSelectDialog(CharSelectDialog *window); + void setCharSelectDialog(CharSelectDialog *window) override; /** * Sets the character create dialog. The handler will clean up this * dialog when a new character is succesfully created, and will unlock * the dialog when a new character failed to be created. */ - void setCharCreateDialog(CharCreateDialog *window); + void setCharCreateDialog(CharCreateDialog *window) override; - void requestCharacters(); + void requestCharacters() override; - void chooseCharacter(Net::Character *character); + void chooseCharacter(Net::Character *character) override; void newCharacter(const std::string &name, int slot, bool gender, int hairstyle, int hairColor, - const std::vector<int> &stats); + const std::vector<int> &stats) override; - void deleteCharacter(Net::Character *character); + void deleteCharacter(Net::Character *character) override; - void switchCharacter(); + void switchCharacter() override; - unsigned int baseSprite() const; + unsigned int baseSprite() const override; - unsigned int hairSprite() const; + unsigned int hairSprite() const override; - unsigned int maxSprite() const; + unsigned int maxSprite() const override; // No limitation on Manaserv - int getCharCreateMaxHairColorId() const + int getCharCreateMaxHairColorId() const override { return 0; } // No limitation on Manaserv - int getCharCreateMaxHairStyleId() const + int getCharCreateMaxHairStyleId() const override { return 0; } void clear(); @@ -94,7 +94,7 @@ class CharHandler : public MessageHandler, public Net::CharHandler double mod; }; - typedef std::map<int, CachedAttrbiute> CachedAttributes; + using CachedAttributes = std::map<int, CachedAttrbiute>; struct CachedCharacterInfo { int slot; diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp index d777fa35..6d0b6b4e 100644 --- a/src/net/manaserv/chathandler.cpp +++ b/src/net/manaserv/chathandler.cpp @@ -184,7 +184,7 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg) short channelId = msg.readInt16(); std::string channelName = msg.readString(); std::string announcement = msg.readString(); - Channel *channel = new Channel(channelId, channelName, announcement); + auto *channel = new Channel(channelId, channelName, announcement); channelManager->addChannel(channel); ChatTab *tab = channel->getTab(); tab->chatLog(strprintf(_("Topic: %s"), announcement.c_str()), BY_CHANNEL); diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h index 7ae4227b..f9602407 100644 --- a/src/net/manaserv/chathandler.h +++ b/src/net/manaserv/chathandler.h @@ -37,7 +37,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler /** * Handle the given message appropriately. */ - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; void connect(); @@ -45,31 +45,31 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler void disconnect(); - void talk(const std::string &text); + void talk(const std::string &text) override; - void me(const std::string &text); + void me(const std::string &text) override; void privateMessage(const std::string &recipient, - const std::string &text); + const std::string &text) override; - void channelList(); + void channelList() override; void enterChannel(const std::string &channel, - const std::string &password); + const std::string &password) override; - void quitChannel(int channelId); + void quitChannel(int channelId) override; - void sendToChannel(int channelId, const std::string &text); + void sendToChannel(int channelId, const std::string &text) override; - void userList(const std::string &channel); + void userList(const std::string &channel) override; - void setChannelTopic(int channelId, const std::string &text); + void setChannelTopic(int channelId, const std::string &text) override; - void setUserMode(int channelId, const std::string &name, int mode); + void setUserMode(int channelId, const std::string &name, int mode) override; - void kickUser(int channelId, const std::string &name); + void kickUser(int channelId, const std::string &name) override; - void who(); + void who() override; private: /** diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp index 5d869b9d..4bc57695 100644 --- a/src/net/manaserv/connection.cpp +++ b/src/net/manaserv/connection.cpp @@ -32,7 +32,7 @@ namespace ManaServ { Connection::Connection(ENetHost *client): - mConnection(0), mClient(client) + mConnection(nullptr), mClient(client) { mPort = 0; connections++; @@ -83,7 +83,7 @@ void Connection::disconnect() enet_host_flush(mClient); enet_peer_reset(mConnection); - mConnection = 0; + mConnection = nullptr; } bool Connection::isConnected() diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h index f5f31b11..268e2725 100644 --- a/src/net/manaserv/effecthandler.h +++ b/src/net/manaserv/effecthandler.h @@ -31,7 +31,7 @@ class EffectHandler : public MessageHandler public: EffectHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; private: void handleCreateEffectPos(MessageIn &msg); diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h index 454cae43..2bc56ef0 100644 --- a/src/net/manaserv/gamehandler.h +++ b/src/net/manaserv/gamehandler.h @@ -36,32 +36,32 @@ class GameHandler : public MessageHandler, public Net::GameHandler public: GameHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void connect(); + void connect() override; - bool isConnected(); + bool isConnected() override; - void disconnect(); + void disconnect() override; - void who(); + void who() override; void quit(bool reconnectAccount); - void quit() { quit(false); } + void quit() override { quit(false); } - bool removeDeadBeings() const { return false; } + bool removeDeadBeings() const override { return false; } void clear(); void gameLoading(); /** The ManaServ protocol doesn't use the MP status bar. */ - bool canUseMagicBar() const { return false; } + bool canUseMagicBar() const override { return false; } - int getPickupRange() const { return PICKUP_RANGE; } + int getPickupRange() const override { return PICKUP_RANGE; } - int getNpcTalkRange() const { return NPC_TALK_RANGE; } + int getNpcTalkRange() const override { return NPC_TALK_RANGE; } }; } // namespace ManaServ diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 1e39410c..aa62dff1 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -61,9 +61,9 @@ extern ManaServ::LoginHandler *loginHandler; namespace ManaServ { -Connection *accountServerConnection = 0; -Connection *chatServerConnection = 0; -Connection *gameServerConnection = 0; +Connection *accountServerConnection = nullptr; +Connection *chatServerConnection = nullptr; +Connection *gameServerConnection = nullptr; std::string netToken = ""; ServerInfo gameServer; ServerInfo chatServer; @@ -181,7 +181,7 @@ void GeneralHandler::event(Event::Channel channel, if (newState == STATE_GAME) { - GameHandler *game = static_cast<GameHandler*>(Net::getGameHandler()); + auto *game = static_cast<GameHandler*>(Net::getGameHandler()); game->gameLoading(); } } diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h index ce511587..582c1796 100644 --- a/src/net/manaserv/generalhandler.h +++ b/src/net/manaserv/generalhandler.h @@ -36,17 +36,17 @@ class GeneralHandler : public Net::GeneralHandler, public EventListener public: GeneralHandler(); - void load(); + void load() override; - void reload(); + void reload() override; - void unload(); + void unload() override; - void flushNetwork(); + void flushNetwork() override; - void clearHandlers(); + void clearHandlers() override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; protected: MessageHandlerPtr mAdminHandler; diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp index 19fa03ca..be2a5ec8 100644 --- a/src/net/manaserv/guildhandler.cpp +++ b/src/net/manaserv/guildhandler.cpp @@ -285,7 +285,7 @@ void GuildHandler::joinedGuild(MessageIn &msg) // Automatically create the guild channel // COMMENT: Should this go here?? - Channel *channel = new Channel(channelId, guildName, announcement); + auto *channel = new Channel(channelId, guildName, announcement); channelManager->addChannel(channel); channel->getTab()->chatLog(strprintf(_("Topic: %s"), announcement.c_str()), BY_CHANNEL); diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h index d1232a6f..b14bb203 100644 --- a/src/net/manaserv/guildhandler.h +++ b/src/net/manaserv/guildhandler.h @@ -33,34 +33,34 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler public: GuildHandler(); - bool isSupported() { return true; } + bool isSupported() override { return true; } - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void create(const std::string &name); + void create(const std::string &name) override; - void invite(int guildId, const std::string &name); + void invite(int guildId, const std::string &name) override; - void invite(int guidId, Being *being); + void invite(int guidId, Being *being) override; - void inviteResponse(int guidId, bool response); + void inviteResponse(int guidId, bool response) override; - void leave(int guildId); + void leave(int guildId) override; - void kick(GuildMember *member, std::string reason = ""); + void kick(GuildMember *member, std::string reason = "") override; - void chat(int guildId, const std::string &text); + void chat(int guildId, const std::string &text) override; - void memberList(int guildId); + void memberList(int guildId) override; - void changeMemberPostion(GuildMember *member, int level); + void changeMemberPostion(GuildMember *member, int level) override; - void requestAlliance(int guildId, int otherGuildId); + void requestAlliance(int guildId, int otherGuildId) override; void requestAllianceResponse(int guildId, int otherGuildId, - bool response); + bool response) override; - void endAlliance(int guildId, int otherGuildId); + void endAlliance(int guildId, int otherGuildId) override; protected: void joinedGuild(MessageIn &msg); diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp index b306869e..af482400 100644 --- a/src/net/manaserv/inventoryhandler.cpp +++ b/src/net/manaserv/inventoryhandler.cpp @@ -72,20 +72,20 @@ EquipBackend::~EquipBackend() Item *EquipBackend::getEquipment(int slotIndex) const { - Slots::const_iterator it = mSlots.find(slotIndex); - return it == mSlots.end() ? 0 : it->second.item; + auto it = mSlots.find(slotIndex); + return it == mSlots.end() ? nullptr : it->second.item; } std::string EquipBackend::getSlotName(int slotIndex) const { - Slots::const_iterator it = mSlots.find(slotIndex); + auto it = mSlots.find(slotIndex); return it == mSlots.end() ? std::string() : it->second.name; } void EquipBackend::triggerUnequip(int slotIndex) const { // First get the itemInstance - Slots::const_iterator it = mSlots.find(slotIndex); + auto it = mSlots.find(slotIndex); if (it == mSlots.end() || it->second.itemInstance == 0 || !it->second.item) return; @@ -99,13 +99,13 @@ void EquipBackend::triggerUnequip(int slotIndex) const void EquipBackend::clear() { - for (Slots::iterator i = mSlots.begin(), i_end = mSlots.end(); + for (auto i = mSlots.begin(), i_end = mSlots.end(); i != i_end; ++i) { if (i->second.item) { delete i->second.item; - i->second.item = 0; + i->second.item = nullptr; } } mSlots.clear(); @@ -121,8 +121,8 @@ void EquipBackend::equip(int itemId, int slotTypeId, int amountUsed, return; } - Slots::iterator it = mSlots.begin(); - Slots::iterator it_end = mSlots.end(); + auto it = mSlots.begin(); + auto it_end = mSlots.end(); bool slotTypeFound = false; for (; it != it_end; ++it) if (it->second.slotTypeId == (unsigned)slotTypeId) @@ -161,8 +161,8 @@ void EquipBackend::equip(int itemId, int slotTypeId, int amountUsed, void EquipBackend::unequip(int itemInstance) { - Slots::iterator it = mSlots.begin(); - Slots::iterator it_end = mSlots.end(); + auto it = mSlots.begin(); + auto it_end = mSlots.end(); bool itemInstanceFound = false; for (; it != it_end; ++it) if (it->second.itemInstance == (unsigned)itemInstance) @@ -187,7 +187,7 @@ void EquipBackend::unequip(int itemInstance) if (it->second.item) { delete it->second.item; - it->second.item = 0; + it->second.item = nullptr; } } } @@ -280,7 +280,7 @@ void EquipBackend::readBoxNode(xmlNodePtr slotNode) bool EquipBackend::isWeaponSlot(int slotTypeId) const { - for (Slots::const_iterator it = mSlots.begin(), it_end = mSlots.end(); + for (auto it = mSlots.begin(), it_end = mSlots.end(); it != it_end; ++it) { if (it->second.slotTypeId == (unsigned)slotTypeId) @@ -291,7 +291,7 @@ bool EquipBackend::isWeaponSlot(int slotTypeId) const bool EquipBackend::isAmmoSlot(int slotTypeId) const { - for (Slots::const_iterator it = mSlots.begin(), it_end = mSlots.end(); + for (auto it = mSlots.begin(), it_end = mSlots.end(); it != it_end; ++it) { if (it->second.slotTypeId == (unsigned)slotTypeId) diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h index 808acb96..3659286b 100644 --- a/src/net/manaserv/inventoryhandler.h +++ b/src/net/manaserv/inventoryhandler.h @@ -38,25 +38,25 @@ class EquipBackend : public Equipment::Backend, public EventListener public: EquipBackend(); - ~EquipBackend(); + ~EquipBackend() override; - Item *getEquipment(int slotIndex) const; - std::string getSlotName(int slotIndex) const; - void clear(); + Item *getEquipment(int slotIndex) const override; + std::string getSlotName(int slotIndex) const override; + void clear() override; void equip(int itemId, int slotTypeId, int amountUsed = 1, int itemInstance = 0); void unequip(int slotTypeId); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; - int getSlotNumber() const + int getSlotNumber() const override { return mSlots.size(); } unsigned int getVisibleSlotsNumber() const { return mVisibleSlots; } - void triggerUnequip(int slotIndex) const; + void triggerUnequip(int slotIndex) const override; bool isWeaponSlot(int slotTypeId) const; bool isAmmoSlot(int slotTypeId) const; @@ -66,13 +66,13 @@ class EquipBackend : public Equipment::Backend, public EventListener const std::string& getBoxBackground(unsigned int slotIndex) const; private: - void readEquipFile(); + void readEquipFile() override; void readBoxNode(xmlNodePtr slotNode); struct Slot { Slot(): - item(0), + item(nullptr), slotTypeId(0), subId(0), itemInstance(0), @@ -113,7 +113,7 @@ class EquipBackend : public Equipment::Backend, public EventListener unsigned int mVisibleSlots; // slot client index, slot info - typedef std::map<unsigned int, Slot> Slots; + using Slots = std::map<unsigned int, Slot>; Slots mSlots; std::vector<Position> mBoxesPositions; std::vector<std::string> mBoxesBackgroundFile; @@ -125,27 +125,27 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler, public: InventoryHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; - bool canSplit(const Item *item); + bool canSplit(const Item *item) override; - size_t getSize(int type) const; + size_t getSize(int type) const override; - bool isWeaponSlot(unsigned int slotTypeId) const + bool isWeaponSlot(unsigned int slotTypeId) const override { return mEquipBackend.isWeaponSlot(slotTypeId); } - bool isAmmoSlot(unsigned int slotTypeId) const + bool isAmmoSlot(unsigned int slotTypeId) const override { return mEquipBackend.isAmmoSlot(slotTypeId); } - unsigned int getVisibleSlotsNumber() const + unsigned int getVisibleSlotsNumber() const override { return mEquipBackend.getVisibleSlotsNumber(); } - Position getBoxPosition(unsigned int slotIndex) const + Position getBoxPosition(unsigned int slotIndex) const override { return mEquipBackend.getBoxPosition(slotIndex); } - const std::string& getBoxBackground(unsigned int slotIndex) const + const std::string& getBoxBackground(unsigned int slotIndex) const override { return mEquipBackend.getBoxBackground(slotIndex); } private: diff --git a/src/net/manaserv/itemhandler.h b/src/net/manaserv/itemhandler.h index e45db269..4396886f 100644 --- a/src/net/manaserv/itemhandler.h +++ b/src/net/manaserv/itemhandler.h @@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler public: ItemHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; }; } // namespace ManaServ diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h index 33cc83ad..cdfbe222 100644 --- a/src/net/manaserv/loginhandler.h +++ b/src/net/manaserv/loginhandler.h @@ -36,43 +36,43 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler public: LoginHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void connect(); + void connect() override; - bool isConnected(); + bool isConnected() override; - void disconnect(); + void disconnect() override; - int supportedOptionalActions() const + int supportedOptionalActions() const override { return Unregister | ChangeEmail | SetEmailOnRegister; } - bool isRegistrationEnabled(); + bool isRegistrationEnabled() override; - void getRegistrationDetails(); + void getRegistrationDetails() override; - unsigned int getMinUserNameLength() const; + unsigned int getMinUserNameLength() const override; - unsigned int getMaxUserNameLength() const; + unsigned int getMaxUserNameLength() const override; - void loginAccount(LoginData *loginData); + void loginAccount(LoginData *loginData) override; - void logout(); + void logout() override; - void changeEmail(const std::string &email); + void changeEmail(const std::string &email) override; void changePassword(const std::string &username, const std::string &oldPassword, - const std::string &newPassword); + const std::string &newPassword) override; - void chooseServer(unsigned int server); + void chooseServer(unsigned int server) override; - void registerAccount(LoginData *loginData); + void registerAccount(LoginData *loginData) override; void unregisterAccount(const std::string &username, - const std::string &password); + const std::string &password) override; - Worlds getWorlds() const; + Worlds getWorlds() const override; void reconnect(); diff --git a/src/net/manaserv/messagehandler.h b/src/net/manaserv/messagehandler.h index 8949d34e..f9ee09ab 100644 --- a/src/net/manaserv/messagehandler.h +++ b/src/net/manaserv/messagehandler.h @@ -36,12 +36,12 @@ class MessageIn; class MessageHandler : public Net::MessageHandler { public: - ~MessageHandler(); + ~MessageHandler() override; virtual void handleMessage(MessageIn &msg) = 0; }; -typedef const std::unique_ptr<MessageHandler> MessageHandlerPtr; +using MessageHandlerPtr = const std::unique_ptr<MessageHandler>; } // namespace ManaServ diff --git a/src/net/manaserv/messageout.cpp b/src/net/manaserv/messageout.cpp index 1197176f..3dc2c1b2 100644 --- a/src/net/manaserv/messageout.cpp +++ b/src/net/manaserv/messageout.cpp @@ -28,7 +28,7 @@ namespace ManaServ { MessageOut::MessageOut(uint16_t id): - mData(0), + mData(nullptr), mPos(0), mDataSize(0), mDebugMode(false) diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index 30dfb243..7f354fa1 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -42,8 +42,8 @@ namespace { namespace ManaServ { -typedef std::map<unsigned short, MessageHandler*> MessageHandlers; -typedef MessageHandlers::iterator MessageHandlerIterator; +using MessageHandlers = std::map<unsigned short, MessageHandler *>; +using MessageHandlerIterator = MessageHandlers::iterator; static MessageHandlers mMessageHandlers; void initialize() @@ -53,7 +53,7 @@ void initialize() logger->error("Failed to initialize ENet."); } - client = enet_host_create(NULL, 3, 0, 0, 0); + client = enet_host_create(nullptr, 3, 0, 0, 0); if (!client) { @@ -119,7 +119,7 @@ namespace { MessageIn msg((const char *)packet->data, packet->dataLength); - MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); + auto iter = mMessageHandlers.find(msg.getId()); if (iter != mMessageHandlers.end()) { @@ -150,7 +150,7 @@ void flush() case ENET_EVENT_TYPE_CONNECT: logger->log("Connected to port %d.", event.peer->address.port); // Store any relevant server information here. - event.peer->data = 0; + event.peer->data = nullptr; break; case ENET_EVENT_TYPE_RECEIVE: @@ -160,7 +160,7 @@ void flush() case ENET_EVENT_TYPE_DISCONNECT: logger->log("Disconnected."); // Reset the server information. - event.peer->data = 0; + event.peer->data = nullptr; break; case ENET_EVENT_TYPE_NONE: diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp index 502df13d..bd131d55 100644 --- a/src/net/manaserv/npchandler.cpp +++ b/src/net/manaserv/npchandler.cpp @@ -62,7 +62,7 @@ void NpcHandler::handleMessage(MessageIn &msg) } int npcId = being->getId(), count = 0; - Event *event = 0; + Event *event = nullptr; switch (msg.getId()) { diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h index 0f42385d..8d397253 100644 --- a/src/net/manaserv/npchandler.h +++ b/src/net/manaserv/npchandler.h @@ -37,34 +37,34 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler public: NpcHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void startShopping(int beingId); + void startShopping(int beingId) override; - void buy(int beingId); + void buy(int beingId) override; - void sell(int beingId); + void sell(int beingId) override; - void buyItem(int beingId, int itemId, int amount); + void buyItem(int beingId, int itemId, int amount) override; - void sellItem(int beingId, int itemId, int amount); + void sellItem(int beingId, int itemId, int amount) override; - void endShopping(int beingId); + void endShopping(int beingId) override; - void talk(int npcId); + void talk(int npcId) override; - void nextDialog(int npcId); + void nextDialog(int npcId) override; - void closeDialog(int npcId); + void closeDialog(int npcId) override; - void menuSelect(int npcId, int choice); + void menuSelect(int npcId, int choice) override; - void integerInput(int npcId, int value); + void integerInput(int npcId, int value) override; - void stringInput(int npcId, const std::string &value); + void stringInput(int npcId, const std::string &value) override; void sendLetter(int npcId, const std::string &recipient, - const std::string &text); + const std::string &text) override; }; diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp index a0d4b6d9..e0ee91a7 100644 --- a/src/net/manaserv/partyhandler.cpp +++ b/src/net/manaserv/partyhandler.cpp @@ -113,7 +113,7 @@ void PartyHandler::handleMessage(MessageIn &msg) if (msg.readInt8() == ERRMSG_OK) { mParty->clearMembers(); - local_player->setParty(NULL); + local_player->setParty(nullptr); } } break; diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h index 6c526f73..ed8a1f25 100644 --- a/src/net/manaserv/partyhandler.h +++ b/src/net/manaserv/partyhandler.h @@ -37,35 +37,35 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler public: PartyHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void create(const std::string &name = ""); + void create(const std::string &name = "") override; - void join(int partyId); + void join(int partyId) override; - void invite(Being *being); + void invite(Being *being) override; - void invite(const std::string &name); + void invite(const std::string &name) override; - void inviteResponse(const std::string &inviter, bool accept); + void inviteResponse(const std::string &inviter, bool accept) override; - void leave(); + void leave() override; - void kick(Being *being); + void kick(Being *being) override; - void kick(const std::string &name); + void kick(const std::string &name) override; - void chat(const std::string &text); + void chat(const std::string &text) override; - void requestPartyMembers(); + void requestPartyMembers() override; - PartyShare getShareExperience() { return PARTY_SHARE_NO; } + PartyShare getShareExperience() override { return PARTY_SHARE_NO; } - void setShareExperience(PartyShare share) {} + void setShareExperience(PartyShare share) override {} - PartyShare getShareItems() { return PARTY_SHARE_NO; } + PartyShare getShareItems() override { return PARTY_SHARE_NO; } - void setShareItems(PartyShare share) {} + void setShareItems(PartyShare share) override {} private: Party *mParty; }; diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index c1f78f67..15b0eb5c 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -105,7 +105,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) gameServerConnection->disconnect(); Client::setState(STATE_CHANGE_MAP); - local_player->setMap(0); + local_player->setMap(nullptr); } break; case GPMSG_PLAYER_ATTRIBUTE_CHANGE: diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index abb29e9b..e2a52d4d 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -32,7 +32,7 @@ namespace ManaServ { struct RespawnRequestListener : public gcn::ActionListener { - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; }; static RespawnRequestListener respawnListener; @@ -41,35 +41,35 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler public: PlayerHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void attack(int id); - void emote(int emoteId); + void attack(int id) override; + void emote(int emoteId) override; - void increaseAttribute(int attr); - void decreaseAttribute(int attr); - void increaseSkill(int skillId); + void increaseAttribute(int attr) override; + void decreaseAttribute(int attr) override; + void increaseSkill(int skillId) override; - void pickUp(FloorItem *floorItem); - void setDirection(char direction); - void setDestination(int x, int y, int direction = -1); - void changeAction(Being::Action action); + void pickUp(FloorItem *floorItem) override; + void setDirection(char direction) override; + void setDestination(int x, int y, int direction = -1) override; + void changeAction(Being::Action action) override; - void respawn(); + void respawn() override; - void ignorePlayer(const std::string &player, bool ignore); - void ignoreAll(bool ignore); + void ignorePlayer(const std::string &player, bool ignore) override; + void ignoreAll(bool ignore) override; - bool canUseMagic(); - bool canCorrectAttributes(); + bool canUseMagic() override; + bool canCorrectAttributes() override; - int getJobLocation(); + int getJobLocation() override; - Vector getDefaultMoveSpeed() const; + Vector getDefaultMoveSpeed() const override; - Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0); + Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = nullptr) override; - bool usePixelPrecision() + bool usePixelPrecision() override { return true; } private: diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h index ee26b3b7..55b5225b 100644 --- a/src/net/manaserv/specialhandler.h +++ b/src/net/manaserv/specialhandler.h @@ -33,15 +33,15 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler public: SpecialHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - void use(int id); + void use(int id) override; - void use(int id, int level, int beingId); + void use(int id, int level, int beingId) override; - void use(int id, int level, int x, int y); + void use(int id, int level, int x, int y) override; - void use(int id, const std::string &map); + void use(int id, const std::string &map) override; }; } // namespace ManaServ diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp index ff7849ff..9537909c 100644 --- a/src/net/manaserv/tradehandler.cpp +++ b/src/net/manaserv/tradehandler.cpp @@ -55,7 +55,7 @@ extern Connection *gameServerConnection; namespace { struct RequestTradeListener : public gcn::ActionListener { - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "yes") { @@ -112,7 +112,7 @@ void TradeHandler::handleMessage(MessageIn &msg) mTrading = true; tradePartnerName = being->getName(); tradePartnerID = being->getId(); - ConfirmDialog *dlg = new ConfirmDialog(_("Request for Trade"), + auto *dlg = new ConfirmDialog(_("Request for Trade"), strprintf(_("%s wants to trade with you, do you accept?"), tradePartnerName.c_str())); dlg->addActionListener(&listener); diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h index 5d20c14e..094b3c17 100644 --- a/src/net/manaserv/tradehandler.h +++ b/src/net/manaserv/tradehandler.h @@ -33,7 +33,7 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler public: TradeHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; /** * Returns whether trade requests are accepted. @@ -50,21 +50,21 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler */ void setAcceptTradeRequests(bool acceptTradeRequests); - void request(Being *being); + void request(Being *being) override; - void respond(bool accept); + void respond(bool accept) override; - void addItem(Item *item, int amount); + void addItem(Item *item, int amount) override; - void removeItem(int slotNum, int amount); + void removeItem(int slotNum, int amount) override; - void setMoney(int amount); + void setMoney(int amount) override; - void confirm(); + void confirm() override; - void finish(); + void finish() override; - void cancel(); + void cancel() override; private: bool mAcceptTradeRequests; |