diff options
65 files changed, 136 insertions, 231 deletions
diff --git a/src/actor.cpp b/src/actor.cpp index e1fffaf9..a644c1e0 100644 --- a/src/actor.cpp +++ b/src/actor.cpp @@ -22,11 +22,7 @@ #include "map.h" -#include "resources/image.h" - -Actor::Actor(): - mMap(nullptr) -{} +Actor::Actor() = default; Actor::~Actor() { diff --git a/src/actor.h b/src/actor.h index 9d5886e8..8384593d 100644 --- a/src/actor.h +++ b/src/actor.h @@ -131,7 +131,7 @@ public: { return mMap; } protected: - Map *mMap; + Map *mMap = nullptr; Vector mPos; /**< Position in pixels relative to map. */ private: diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp index 1c79556f..a5461ecd 100644 --- a/src/animationparticle.cpp +++ b/src/animationparticle.cpp @@ -21,7 +21,6 @@ #include "animationparticle.h" -#include "graphics.h" #include "simpleanimation.h" AnimationParticle::AnimationParticle(Map *map, Animation *animation): diff --git a/src/being.cpp b/src/being.cpp index 46b499af..2d198dbd 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -100,19 +100,18 @@ void Being::setSubtype(Uint16 subtype) mSubType = subtype; - if (getType() == MONSTER) + switch (getType()) { + case MONSTER: mInfo = MonsterDB::get(mSubType); setName(mInfo->getName()); setupSpriteDisplay(mInfo->getDisplay()); - } - else if (getType() == NPC) - { + break; + case NPC: mInfo = NPCDB::get(mSubType); setupSpriteDisplay(mInfo->getDisplay(), false); - } - else if (getType() == PLAYER) - { + break; + case PLAYER: { int id = -100 - subtype; // Prevent showing errors when sprite doesn't exist @@ -120,6 +119,11 @@ void Being::setSubtype(Uint16 subtype) id = -100; setSprite(Net::getCharHandler()->baseSprite(), id); + break; + } + case FLOOR_ITEM: + case UNKNOWN: + break; } } diff --git a/src/being.h b/src/being.h index 32cfcf99..dbfd82f1 100644 --- a/src/being.h +++ b/src/being.h @@ -116,7 +116,7 @@ class Being : public ActorSprite, public EventListener ~Being() override; - Type getType() const override + Type getType() const final { return mType; } /** @@ -369,7 +369,7 @@ class Being : public ActorSprite, public EventListener SpriteDirection getSpriteDirection() const { return SpriteDirection(mSpriteDirection); } - void setPosition(const Vector &pos) override; + void setPosition(const Vector &pos) final; /** * Overloaded method provided for convenience. @@ -441,7 +441,7 @@ class Being : public ActorSprite, public EventListener void event(Event::Channel channel, const Event &event) override; - void setMap(Map *map) override; + void setMap(Map *map) final; /** * Make the being look at a given pixel position. diff --git a/src/client.cpp b/src/client.cpp index 15ebcf96..df360d17 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -179,18 +179,7 @@ Client *Client::mInstance = nullptr; Client::Client(const Options &options): mOptions(options), - mGame(nullptr), - mCurrentDialog(nullptr), - mQuitDialog(nullptr), - mDesktop(nullptr), - mSetupButton(nullptr), - mState(STATE_CHOOSE_SERVER), - mOldState(STATE_START), - mStateAfterOkDialog(mState), - mIcon(nullptr), - mLogicCounterId(0), - mSecondsCounterId(0), - mLimitFps(false) + mStateAfterOkDialog(mState) { assert(!mInstance); mInstance = this; @@ -682,7 +671,7 @@ int Client::exec() { Worlds worlds = Net::getLoginHandler()->getWorlds(); - if (worlds.size() == 0) + if (worlds.empty()) { // Trust that the netcode knows what it's doing mState = STATE_UPDATE; diff --git a/src/client.h b/src/client.h index dfcc3e70..5b88dd5a 100644 --- a/src/client.h +++ b/src/client.h @@ -121,7 +121,7 @@ enum State { * The core part of the client. This class initializes all subsystems, runs * the event loop, and shuts everything down again. */ -class Client : public EventListener, public gcn::ActionListener +class Client final : public EventListener, public gcn::ActionListener { public: /** @@ -234,22 +234,22 @@ private: ServerInfo mCurrentServer; Video mVideo; - Game *mGame; - Window *mCurrentDialog; - QuitDialog *mQuitDialog; - Desktop *mDesktop; - Button *mSetupButton; + Game *mGame = nullptr; + Window *mCurrentDialog = nullptr; + QuitDialog *mQuitDialog = nullptr; + Desktop *mDesktop = nullptr; + Button *mSetupButton = nullptr; - State mState; - State mOldState; + State mState = STATE_CHOOSE_SERVER; + State mOldState = STATE_START; State mStateAfterOkDialog; - SDL_Surface *mIcon; + SDL_Surface *mIcon = nullptr; - SDL_TimerID mLogicCounterId; - SDL_TimerID mSecondsCounterId; + SDL_TimerID mLogicCounterId = 0; + SDL_TimerID mSecondsCounterId = 0; - bool mLimitFps; + bool mLimitFps = false; FPSmanager mFpsManager; }; diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index a0a14c65..7792813c 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -111,10 +111,6 @@ class CharacterDisplay : public Container CharSelectDialog::CharSelectDialog(LoginData *loginData): Window(_("Account and Character Management")), - mLocked(false), - mUnregisterButton(nullptr), - mChangeEmailButton(nullptr), - mCharacterEntries(0), mLoginData(loginData), mCharHandler(Net::getCharHandler()) { @@ -168,9 +164,7 @@ CharSelectDialog::CharSelectDialog(LoginData *loginData): mCharacterEntries[0]->requestFocus(); } -CharSelectDialog::~CharSelectDialog() -{ -} +CharSelectDialog::~CharSelectDialog() = default; void CharSelectDialog::action(const gcn::ActionEvent &event) { @@ -265,20 +259,14 @@ void CharSelectDialog::attemptCharacterSelect(int index) void CharSelectDialog::setCharacters(const Net::Characters &characters) { // Reset previous characters - std::vector<CharacterDisplay*>::iterator iter, iter_end; - for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); - iter != iter_end; ++iter) - (*iter)->setCharacter(nullptr); + for (auto *characterEntry : mCharacterEntries) + characterEntry->setCharacter(nullptr); - Net::Characters::const_iterator i, i_end = characters.end(); - for (i = characters.begin(); i != i_end; ++i) + for (auto character : characters) { - Net::Character *character = *i; - // Slots Number start at 1 for Manaserv, so we offset them by one. int characterSlot = character->slot; - if (Net::getNetworkType() == ServerType::MANASERV - && characterSlot > 0) + if (Net::getNetworkType() == ServerType::MANASERV && characterSlot > 0) --characterSlot; if (characterSlot >= (int)mCharacterEntries.size()) diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index d30e4e68..2deb5a7d 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -84,14 +84,14 @@ class CharSelectDialog : public Window, public gcn::ActionListener, void unlock(); void setLocked(bool locked); - bool mLocked; + bool mLocked = false; gcn::Label *mAccountNameLabel; gcn::Button *mSwitchLoginButton; gcn::Button *mChangePasswordButton; - gcn::Button *mUnregisterButton; - gcn::Button *mChangeEmailButton; + gcn::Button *mUnregisterButton = nullptr; + gcn::Button *mChangeEmailButton = nullptr; /** The player boxes */ std::vector<CharacterDisplay*> mCharacterEntries; diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index bad2c2b5..5b8372ee 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -26,7 +26,6 @@ #include "configuration.h" #include "gui.h" #include "log.h" -#include "main.h" #include "gui/customserverdialog.h" #include "gui/okdialog.h" @@ -40,8 +39,6 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/textfield.h" -#include "net/net.h" - #include "resources/theme.h" #include "utils/gettext.h" @@ -474,8 +471,7 @@ void ServerDialog::loadServers() std::string version = XML::getProperty(serverNode, "minimumVersion", std::string()); - bool meetsMinimumVersion = (compareStrI(version, PACKAGE_VERSION) - <= 0); + bool meetsMinimumVersion = compareStrI(version, PACKAGE_VERSION) <= 0; // For display in the list if (meetsMinimumVersion) diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 57f80275..4e8272d6 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -24,15 +24,10 @@ #include "gui/textpopup.h" #include "gui/gui.h" -#include "gui/palette.h" #include "gui/widgets/label.h" #include "graphics.h" -#include "units.h" - -#include "utils/gettext.h" -#include "utils/stringutils.h" #include <guichan/font.hpp> #include <guichan/widgets/label.hpp> @@ -53,10 +48,6 @@ TextPopup::TextPopup(): addMouseListener(this); } -TextPopup::~TextPopup() -{ -} - void TextPopup::show(int x, int y, const std::string &str1, const std::string &str2) { mText1->setCaption(str1); diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h index cda8d14a..b12d4475 100644 --- a/src/gui/textpopup.h +++ b/src/gui/textpopup.h @@ -38,8 +38,6 @@ class TextPopup : public Popup public: TextPopup(); - ~TextPopup() override; - /** * Sets the text to be displayed. */ diff --git a/src/localplayer.h b/src/localplayer.h index de588402..43a1fe6d 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -58,7 +58,7 @@ enum /** * The local player character. */ -class LocalPlayer : public Being +class LocalPlayer final : public Being { public: LocalPlayer(int id= 65535, int subtype = 0); @@ -69,7 +69,7 @@ class TileAnimation ~TileAnimation(); void update(int ticks = 1); void addAffectedTile(MapLayer *layer, int index) - { mAffected.push_back(std::make_pair(layer, index)); } + { mAffected.emplace_back(layer, index); } private: std::list<std::pair<MapLayer*, int> > mAffected; SimpleAnimation *mAnimation; diff --git a/src/net/charhandler.h b/src/net/charhandler.h index cebf0b93..72e67739 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -25,7 +25,6 @@ #include "localplayer.h" #include "playerinfo.h" -#include <iosfwd> #include <vector> class CharCreateDialog; @@ -53,7 +52,7 @@ using Characters = std::list<Character *>; class CharHandler { public: - virtual ~CharHandler() {} + virtual ~CharHandler() = default; virtual void setCharSelectDialog(CharSelectDialog *window) = 0; diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 5f75cf50..43d15b77 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -26,9 +26,6 @@ #include "net/serverinfo.h" #include "net/worldinfo.h" -#include <iosfwd> -#include <vector> - namespace Net { class LoginHandler @@ -94,7 +91,7 @@ class LoginHandler virtual Worlds getWorlds() const = 0; - virtual ~LoginHandler () {} + virtual ~LoginHandler () = default; protected: ServerInfo mServer; diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp index 8ba7c47d..78e6acb2 100644 --- a/src/net/manaserv/adminhandler.cpp +++ b/src/net/manaserv/adminhandler.cpp @@ -22,8 +22,6 @@ #include "net/manaserv/adminhandler.h" #include "net/manaserv/connection.h" -#include "net/manaserv/messageout.h" -#include "net/manaserv/manaserv_protocol.h" extern Net::AdminHandler *adminHandler; diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h index e3bd02e0..fd0c7de0 100644 --- a/src/net/manaserv/adminhandler.h +++ b/src/net/manaserv/adminhandler.h @@ -28,7 +28,7 @@ namespace ManaServ { -class AdminHandler : public Net::AdminHandler, public MessageHandler +class AdminHandler final : public Net::AdminHandler, public MessageHandler { public: AdminHandler(); diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h index 3d80f45f..63424de9 100644 --- a/src/net/manaserv/beinghandler.h +++ b/src/net/manaserv/beinghandler.h @@ -23,8 +23,6 @@ #define NET_MANASERV_BEINGHANDLER_H #include "net/manaserv/messagehandler.h" -#include "vector.h" -#include "map.h" namespace ManaServ { @@ -38,7 +36,7 @@ enum SpriteLayer FIXED_SPRITE_LAYER_SIZE }; -class BeingHandler : public MessageHandler +class BeingHandler final : public MessageHandler { public: BeingHandler(); diff --git a/src/net/manaserv/buysellhandler.h b/src/net/manaserv/buysellhandler.h index f0ae9ab3..0629bd7b 100644 --- a/src/net/manaserv/buysellhandler.h +++ b/src/net/manaserv/buysellhandler.h @@ -26,7 +26,7 @@ namespace ManaServ { -class BuySellHandler : public MessageHandler +class BuySellHandler final : public MessageHandler { public: BuySellHandler(); diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 83919d4e..e7afa173 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -333,9 +333,8 @@ void CharHandler::newCharacter(const std::string &name, msg.writeInt8(gender); msg.writeInt8(slot); - std::vector<int>::const_iterator it, it_end; - for (it = stats.begin(), it_end = stats.end(); it != it_end; it++) - msg.writeInt16((*it)); + for (int stat : stats) + msg.writeInt16(stat); accountServerConnection->send(msg); } diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h index 262d8a01..9ec5cdbb 100644 --- a/src/net/manaserv/charhandler.h +++ b/src/net/manaserv/charhandler.h @@ -37,7 +37,7 @@ namespace ManaServ { /** * Deals with incoming messages related to character selection. */ -class CharHandler : public MessageHandler, public Net::CharHandler +class CharHandler final : public MessageHandler, public Net::CharHandler { public: CharHandler(); diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h index 4ad04a70..c4dc6861 100644 --- a/src/net/manaserv/chathandler.h +++ b/src/net/manaserv/chathandler.h @@ -28,7 +28,7 @@ namespace ManaServ { -class ChatHandler : public MessageHandler, public Net::ChatHandler +class ChatHandler final : public MessageHandler, public Net::ChatHandler { public: ChatHandler(); diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h index 268e2725..4ba711d7 100644 --- a/src/net/manaserv/effecthandler.h +++ b/src/net/manaserv/effecthandler.h @@ -26,7 +26,7 @@ namespace ManaServ { -class EffectHandler : public MessageHandler +class EffectHandler final : public MessageHandler { public: EffectHandler(); diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h index 01d23b43..019c2dfa 100644 --- a/src/net/manaserv/gamehandler.h +++ b/src/net/manaserv/gamehandler.h @@ -23,7 +23,6 @@ #define NET_MANASERV_MAPHANDLER_H #include "net/gamehandler.h" -#include "net/serverinfo.h" #include "net/manaserv/messagehandler.h" @@ -31,7 +30,7 @@ namespace ManaServ { -class GameHandler : public MessageHandler, public Net::GameHandler +class GameHandler final : public MessageHandler, public Net::GameHandler { public: GameHandler(); diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h index 8fbb15d1..666ae862 100644 --- a/src/net/manaserv/guildhandler.h +++ b/src/net/manaserv/guildhandler.h @@ -28,7 +28,7 @@ namespace ManaServ { -class GuildHandler : public Net::GuildHandler, public MessageHandler +class GuildHandler final : public Net::GuildHandler, public MessageHandler { public: GuildHandler(); diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h index 7ed1b9d5..452ccf3e 100644 --- a/src/net/manaserv/inventoryhandler.h +++ b/src/net/manaserv/inventoryhandler.h @@ -33,7 +33,7 @@ namespace ManaServ { -class EquipBackend : public Equipment::Backend, public EventListener +class EquipBackend final : public Equipment::Backend, public EventListener { public: EquipBackend(); @@ -110,7 +110,7 @@ class EquipBackend : public Equipment::Backend, public EventListener std::vector<std::string> mBoxesBackgroundFile; }; -class InventoryHandler : public MessageHandler, Net::InventoryHandler, +class InventoryHandler final : public MessageHandler, Net::InventoryHandler, public EventListener { public: diff --git a/src/net/manaserv/itemhandler.h b/src/net/manaserv/itemhandler.h index 4396886f..22adf8fb 100644 --- a/src/net/manaserv/itemhandler.h +++ b/src/net/manaserv/itemhandler.h @@ -26,7 +26,7 @@ namespace ManaServ { -class ItemHandler : public MessageHandler +class ItemHandler final : public MessageHandler { public: ItemHandler(); diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index e10c8a9e..b9a56834 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -345,7 +345,7 @@ void LoginHandler::readServerInfo(MessageIn &msg) logger->log("Warning: server does not have an update host set!"); // Read the client data folder for dynamic data loading. - // This is only used by the QT client. + // This is only used by the Qt client. msg.readString(); // Read the number of character slots diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h index cdfbe222..87fbe9bc 100644 --- a/src/net/manaserv/loginhandler.h +++ b/src/net/manaserv/loginhandler.h @@ -23,7 +23,6 @@ #define NET_MANASERV_LOGINHANDLER_H #include "net/loginhandler.h" -#include "net/serverinfo.h" #include "net/manaserv/messagehandler.h" @@ -31,7 +30,7 @@ class LoginData; namespace ManaServ { -class LoginHandler : public MessageHandler, public Net::LoginHandler +class LoginHandler final : public MessageHandler, public Net::LoginHandler { public: LoginHandler(); diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h index 8d397253..ee3a9a12 100644 --- a/src/net/manaserv/npchandler.h +++ b/src/net/manaserv/npchandler.h @@ -22,17 +22,13 @@ #ifndef NET_MANASERV_NPCHANDLER_H #define NET_MANASERV_NPCHANDLER_H -#include "eventlistener.h" - #include "net/npchandler.h" #include "net/manaserv/messagehandler.h" -#include <map> - namespace ManaServ { -class NpcHandler : public MessageHandler, public Net::NpcHandler +class NpcHandler final : public MessageHandler, public Net::NpcHandler { public: NpcHandler(); diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h index 1462ead8..ac4249a9 100644 --- a/src/net/manaserv/partyhandler.h +++ b/src/net/manaserv/partyhandler.h @@ -28,11 +28,9 @@ #include "party.h" -#include <string> - namespace ManaServ { -class PartyHandler : public MessageHandler, public Net::PartyHandler +class PartyHandler final : public MessageHandler, public Net::PartyHandler { public: PartyHandler(); @@ -66,6 +64,7 @@ public: PartyShare getShareItems() override { return PARTY_SHARE_NO; } void setShareItems(PartyShare share) override {} + private: Party *mParty; }; diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index 15b0eb5c..0b098ea8 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -31,14 +31,11 @@ #include "playerinfo.h" #include "configuration.h" -#include "gui/gui.h" -#include "gui/okdialog.h" #include "gui/viewport.h" #include "net/net.h" #include "net/manaserv/connection.h" -#include "net/manaserv/defines.h" #include "net/manaserv/messagein.h" #include "net/manaserv/messageout.h" #include "net/manaserv/manaserv_protocol.h" diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index e2a52d4d..a14e3ed5 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -30,13 +30,13 @@ namespace ManaServ { -struct RespawnRequestListener : public gcn::ActionListener +struct RespawnRequestListener final : public gcn::ActionListener { void action(const gcn::ActionEvent &event) override; }; static RespawnRequestListener respawnListener; -class PlayerHandler : public MessageHandler, public Net::PlayerHandler +class PlayerHandler final : public MessageHandler, public Net::PlayerHandler { public: PlayerHandler(); diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h index 55b5225b..dbd203d8 100644 --- a/src/net/manaserv/specialhandler.h +++ b/src/net/manaserv/specialhandler.h @@ -28,7 +28,7 @@ namespace ManaServ { -class SpecialHandler : public MessageHandler, public Net::SpecialHandler +class SpecialHandler final : public MessageHandler, public Net::SpecialHandler { public: SpecialHandler(); diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h index 094b3c17..928a62d9 100644 --- a/src/net/manaserv/tradehandler.h +++ b/src/net/manaserv/tradehandler.h @@ -28,7 +28,7 @@ namespace ManaServ { -class TradeHandler : public MessageHandler, public Net::TradeHandler +class TradeHandler final : public MessageHandler, public Net::TradeHandler { public: TradeHandler(); diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index ce74fd8d..17d547a8 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -29,7 +29,7 @@ namespace TmwAthena { -class AdminHandler : public MessageHandler, public Net::AdminHandler +class AdminHandler final : public MessageHandler, public Net::AdminHandler { public: AdminHandler(); diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index 1ec1583c..f1c8887f 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -26,7 +26,7 @@ namespace TmwAthena { -class BeingHandler : public MessageHandler +class BeingHandler final : public MessageHandler { public: BeingHandler(bool enableSync); diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h index 6e22b4af..8f7a324f 100644 --- a/src/net/tmwa/buysellhandler.h +++ b/src/net/tmwa/buysellhandler.h @@ -28,7 +28,7 @@ class BuyDialog; namespace TmwAthena { -class BuySellHandler : public MessageHandler +class BuySellHandler final : public MessageHandler { public: BuySellHandler(); diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index d6b1f5a0..636b58ce 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -74,7 +74,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) { switch (msg.getId()) { - case SMSG_CHAR_LOGIN: + case SMSG_CHAR_LOGIN: { msg.skip(2); // Length word msg.skip(20); // Unused @@ -280,12 +280,12 @@ void CharServerHandler::setCharCreateDialog(CharCreateDialog *window) return; std::vector<std::string> attributes; - attributes.push_back(_("Strength:")); - attributes.push_back(_("Agility:")); - attributes.push_back(_("Vitality:")); - attributes.push_back(_("Intelligence:")); - attributes.push_back(_("Dexterity:")); - attributes.push_back(_("Luck:")); + attributes.emplace_back(_("Strength:")); + attributes.emplace_back(_("Agility:")); + attributes.emplace_back(_("Vitality:")); + attributes.emplace_back(_("Intelligence:")); + attributes.emplace_back(_("Dexterity:")); + attributes.emplace_back(_("Luck:")); const Token &token = static_cast<LoginHandler*>(Net::getLoginHandler())->getToken(); diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index c8ba4f6f..9633c8d9 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -34,7 +34,7 @@ namespace TmwAthena { /** * Deals with incoming messages from the character server. */ -class CharServerHandler : public MessageHandler, public Net::CharHandler +class CharServerHandler final : public MessageHandler, public Net::CharHandler { public: CharServerHandler(); diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index a21692c9..9f838b2c 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -31,7 +31,7 @@ namespace TmwAthena { -class ChatHandler : public MessageHandler, public Net::ChatHandler +class ChatHandler final : public MessageHandler, public Net::ChatHandler { public: ChatHandler(); @@ -67,8 +67,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler bool whoSupported() const override { return false; } private: - using WhisperQueue = std::queue<std::string>; - WhisperQueue mSentWhispers; + std::queue<std::string> mSentWhispers; }; } // namespace TmwAthena diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 6f276e66..dc0644e9 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -161,7 +161,7 @@ void GameHandler::quit() MessageOut outMsg(CMSG_CLIENT_QUIT); } -void GameHandler::setMap(const std::string map) +void GameHandler::setMap(const std::string &map) { mMap = map.substr(0, map.rfind(".")); } diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h index d1722669..ecd8df2d 100644 --- a/src/net/tmwa/gamehandler.h +++ b/src/net/tmwa/gamehandler.h @@ -26,14 +26,13 @@ #include "net/gamehandler.h" #include "net/net.h" -#include "net/serverinfo.h" #include "net/tmwa/messagehandler.h" #include "net/tmwa/token.h" namespace TmwAthena { -class GameHandler : public MessageHandler, public Net::GameHandler, +class GameHandler final : public MessageHandler, public Net::GameHandler, public EventListener { public: @@ -55,7 +54,7 @@ class GameHandler : public MessageHandler, public Net::GameHandler, void clear(); - void setMap(const std::string map); + void setMap(const std::string &map); /** The tmwAthena protocol is making use of the MP status bar. */ bool canUseMagicBar() const override { return true; } diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 4053e17c..832d6973 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -25,9 +25,7 @@ #include "configuration.h" #include "log.h" -#include "gui/charselectdialog.h" #include "gui/inventorywindow.h" -#include "gui/register.h" #include "gui/skilldialog.h" #include "gui/socialwindow.h" #include "gui/statuswindow.h" @@ -57,7 +55,6 @@ #include "net/tmwa/gui/guildtab.h" #include "net/tmwa/gui/partytab.h" -#include "resources/attributes.h" #include "resources/itemdb.h" #include "utils/gettext.h" @@ -99,12 +96,12 @@ GeneralHandler::GeneralHandler(): generalHandler = this; std::list<ItemStat> stats; - stats.push_back(ItemStat("str", _("Strength %+d"))); - stats.push_back(ItemStat("agi", _("Agility %+d"))); - stats.push_back(ItemStat("vit", _("Vitality %+d"))); - stats.push_back(ItemStat("int", _("Intelligence %+d"))); - stats.push_back(ItemStat("dex", _("Dexterity %+d"))); - stats.push_back(ItemStat("luck", _("Luck %+d"))); + stats.emplace_back("str", _("Strength %+d")); + stats.emplace_back("agi", _("Agility %+d")); + stats.emplace_back("vit", _("Vitality %+d")); + stats.emplace_back("int", _("Intelligence %+d")); + stats.emplace_back("dex", _("Dexterity %+d")); + stats.emplace_back("luck", _("Luck %+d")); setStatsList(stats); diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index 22c6b650..f105da96 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -31,7 +31,7 @@ namespace TmwAthena { -class GeneralHandler : public MessageHandler, public Net::GeneralHandler, +class GeneralHandler final : public MessageHandler, public Net::GeneralHandler, public EventListener { public: diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h index 4cbdd286..9bbe9b4a 100644 --- a/src/net/tmwa/guildhandler.h +++ b/src/net/tmwa/guildhandler.h @@ -27,7 +27,7 @@ namespace TmwAthena { -class GuildHandler : public Net::GuildHandler, public MessageHandler +class GuildHandler final : public Net::GuildHandler, public MessageHandler { public: GuildHandler(); diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 6bf11f54..2df5a699 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -43,7 +43,7 @@ namespace TmwAthena { -class EquipBackend : public Equipment::Backend +class EquipBackend final : public Equipment::Backend { public: EquipBackend() @@ -160,9 +160,7 @@ class InventoryItem } }; -using InventoryItems = std::list<InventoryItem>; - -class InventoryHandler : public MessageHandler, public Net::InventoryHandler, +class InventoryHandler final : public MessageHandler, public Net::InventoryHandler, public EventListener { public: @@ -197,7 +195,7 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler, private: EquipBackend mEquips; - InventoryItems mInventoryItems; + std::list<InventoryItem> mInventoryItems; Inventory *mStorage; InventoryWindow *mStorageWindow; }; diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h index 29ed8246..0c6175d8 100644 --- a/src/net/tmwa/itemhandler.h +++ b/src/net/tmwa/itemhandler.h @@ -26,7 +26,7 @@ namespace TmwAthena { -class ItemHandler : public MessageHandler +class ItemHandler final : public MessageHandler { public: ItemHandler(); diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h index 4d137c05..25dd414d 100644 --- a/src/net/tmwa/loginhandler.h +++ b/src/net/tmwa/loginhandler.h @@ -33,7 +33,7 @@ class LoginData; namespace TmwAthena { -class LoginHandler : public MessageHandler, public Net::LoginHandler +class LoginHandler final : public MessageHandler, public Net::LoginHandler { public: LoginHandler(); diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h index 0a0cd130..b55a8155 100644 --- a/src/net/tmwa/npchandler.h +++ b/src/net/tmwa/npchandler.h @@ -22,17 +22,13 @@ #ifndef NET_TA_NPCHANDLER_H #define NET_TA_NPCHANDLER_H -#include "eventlistener.h" - #include "net/npchandler.h" #include "net/tmwa/messagehandler.h" -#include <map> - namespace TmwAthena { -class NpcHandler : public MessageHandler, public Net::NpcHandler +class NpcHandler final : public MessageHandler, public Net::NpcHandler { public: NpcHandler(); diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 7b7e2420..14c6d9f3 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -29,7 +29,7 @@ namespace TmwAthena { -class PartyHandler : public MessageHandler, public Net::PartyHandler +class PartyHandler final : public MessageHandler, public Net::PartyHandler { public: PartyHandler(); diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 24284ee4..f2a1b40e 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -29,7 +29,7 @@ namespace TmwAthena { -class PlayerHandler : public MessageHandler, public Net::PlayerHandler +class PlayerHandler final : public MessageHandler, public Net::PlayerHandler { public: PlayerHandler(); diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h index f43c900e..09b6ce8d 100644 --- a/src/net/tmwa/specialhandler.h +++ b/src/net/tmwa/specialhandler.h @@ -29,7 +29,7 @@ namespace TmwAthena { -class SpecialHandler : public MessageHandler, public Net::SpecialHandler +class SpecialHandler final : public MessageHandler, public Net::SpecialHandler { public: SpecialHandler(); diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h index d4f2494f..fa7ec034 100644 --- a/src/net/tmwa/tradehandler.h +++ b/src/net/tmwa/tradehandler.h @@ -29,7 +29,7 @@ namespace TmwAthena { -class TradeHandler : public MessageHandler, public Net::TradeHandler +class TradeHandler final : public MessageHandler, public Net::TradeHandler { public: TradeHandler(); diff --git a/src/particle.cpp b/src/particle.cpp index 3e958417..3062de51 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -237,12 +237,8 @@ bool Particle::update() p = mChildParticles.erase(p); } } - if (mAlive != ALIVE && mChildParticles.empty() && mAutoDelete) - { - return false; - } - return true; + return !(mAlive != ALIVE && mChildParticles.empty() && mAutoDelete); } void Particle::moveBy(const Vector &change) diff --git a/src/particle.h b/src/particle.h index 24ab74ce..68b1efd9 100644 --- a/src/particle.h +++ b/src/particle.h @@ -34,9 +34,7 @@ class Particle; class ParticleEmitter; using Particles = std::list<Particle *>; -using ParticleIterator = Particles::iterator; using Emitters = std::list<ParticleEmitter *>; -using EmitterIterator = Emitters::iterator; /** * A particle spawned by a ParticleEmitter. @@ -201,7 +199,7 @@ class Particle : public Actor /** * Gets the flag if the particle is supposed to be moved by its parent */ - bool doesFollow() + bool doesFollow() const { return mFollow; } /** diff --git a/src/resources/hairdb.h b/src/resources/hairdb.h index 1f75a33a..7da08b8f 100644 --- a/src/resources/hairdb.h +++ b/src/resources/hairdb.h @@ -57,7 +57,7 @@ public: * @param maxId the max permited id. If not 0, the hairDb won't * return ids > to the parameter. */ - std::vector<int> getHairStyleIds(int maxId = 0) const; + std::vector<int> getHairStyleIds(int maxId) const; /** * Returns the available hair color ids @@ -86,11 +86,8 @@ private: void loadHairStylesNode(xmlNodePtr stylesNode); // Hair colors Db - using Colors = std::map<int, std::string>; - Colors mHairColors; - - using HairStyles = std::set<int>; - HairStyles mHairStyles; + std::map<int, std::string> mHairColors; + std::set<int> mHairStyles; bool mLoaded = false; }; diff --git a/src/resources/imageset.h b/src/resources/imageset.h index 6c7d59ab..a6501cc9 100644 --- a/src/resources/imageset.h +++ b/src/resources/imageset.h @@ -39,6 +39,9 @@ class ImageSet : public Resource */ ImageSet(Image *img, int w, int h, int margin = 0, int spacing = 0); + ImageSet(const ImageSet&) = delete; + ImageSet& operator=(const ImageSet&) = delete; + ~ImageSet() override; /** diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 77fda11b..6ff3f58c 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -84,12 +84,11 @@ bool ItemDB::exists(int id) const return mItemInfos.find(id) != mItemInfos.end(); } -const ItemInfo &ItemDB::get(int id) +const ItemInfo &ItemDB::get(int id) const { assert(mLoaded); - ItemInfos::const_iterator i = mItemInfos.find(id); - + auto i = mItemInfos.find(id); if (i == mItemInfos.end()) { logger->log("ItemDB: Warning, unknown item ID# %d", id); @@ -99,12 +98,11 @@ const ItemInfo &ItemDB::get(int id) return *(i->second); } -const ItemInfo &ItemDB::get(const std::string &name) +const ItemInfo &ItemDB::get(const std::string &name) const { assert(mLoaded); - NamedItemInfos::const_iterator i = mNamedItemInfos.find(normalize(name)); - + auto i = mNamedItemInfos.find(normalize(name)); if (i == mNamedItemInfos.end()) { if (!name.empty()) @@ -268,7 +266,7 @@ void ItemDB::addItem(ItemInfo *itemInfo) { std::string temp = normalize(itemName); - NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp); + auto itr = mNamedItemInfos.find(temp); if (itr == mNamedItemInfos.end()) mNamedItemInfos[temp] = itemInfo; else @@ -448,8 +446,7 @@ void ManaServItemDB::readItemNode(xmlNodePtr node, const std::string &filename) if (trigger == "activation") itemInfo->mActivatable = true; - std::map<std::string, const char* >::const_iterator triggerLabel = - triggerTable.find(trigger); + auto triggerLabel = triggerTable.find(trigger); if (triggerLabel == triggerTable.end()) { logger->log("Warning: unknown trigger %s in item %d!", @@ -472,9 +469,8 @@ void ManaServItemDB::readItemNode(xmlNodePtr node, const std::string &filename) logger->log("Warning: incomplete modifier definition in %s, skipping.", filename.c_str()); continue; } - std::list<ItemStat>::const_iterator - it = extraStats.begin(), - it_end = extraStats.end(); + auto it = extraStats.cbegin(); + auto it_end = extraStats.cend(); while (it != it_end && !(*it == attribute)) ++it; if (it == extraStats.end()) @@ -495,7 +491,7 @@ void ManaServItemDB::readItemNode(xmlNodePtr node, const std::string &filename) effect.push_back(strprintf("This will be consumed%s.", triggerLabel->second)); else if (xmlStrEqual(effectChild->name, BAD_CAST "label")) - effect.push_back( + effect.emplace_back( (const char*)effectChild->xmlChildrenNode->content); } } diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 6a9988d0..84fcf210 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -75,8 +75,7 @@ class ItemDB public: ItemDB() = default; - virtual ~ItemDB() - {} + virtual ~ItemDB() = default; /** * Frees item data. @@ -91,8 +90,8 @@ class ItemDB bool exists(int id) const; - const ItemInfo &get(int id); - const ItemInfo &get(const std::string &name); + const ItemInfo &get(int id) const; + const ItemInfo &get(const std::string &name) const; virtual void init() = 0; @@ -144,11 +143,8 @@ class ItemDB void loadFloorSprite(SpriteDisplay *display, xmlNodePtr node); // Items database - using ItemInfos = std::map<int, ItemInfo *>; - using NamedItemInfos = std::map<std::string, ItemInfo *>; - - ItemInfos mItemInfos; - NamedItemInfos mNamedItemInfos; + std::map<int, ItemInfo *> mItemInfos; + std::map<std::string, ItemInfo *> mNamedItemInfos; }; namespace TmwAthena { @@ -161,8 +157,7 @@ class TaItemInfo; class TaItemDB: public ItemDB { public: - TaItemDB() - { } + TaItemDB() = default; ~TaItemDB() override { unload(); } @@ -196,8 +191,7 @@ class ManaServItemInfo; class ManaServItemDB: public ItemDB { public: - ManaServItemDB() - { } + ManaServItemDB() = default; ~ManaServItemDB() override { unload(); } diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 7344d668..5922b6c1 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -229,8 +229,7 @@ class TaItemInfo: public ItemInfo friend class TaItemDB; public: - TaItemInfo() - {} + TaItemInfo() = default; // Declare TmwAthena Specific item info here }; @@ -246,8 +245,7 @@ namespace ManaServ { class ManaServItemInfo: public ItemInfo { public: - ManaServItemInfo() - {} + ManaServItemInfo() = default; // Declare Manaserv Specific item info here }; diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 3a5195cc..ec41aec0 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -75,10 +75,8 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) { return load(errorFile, 0); } - else - { - return nullptr; - } + + return nullptr; } auto *def = new SpriteDef; @@ -162,7 +160,7 @@ void SpriteDef::loadImageSet(xmlNodePtr node, const std::string &palettes) if (!imageSet) { logger->error(strprintf("Couldn't load imageset (%s)!", - imageSrc.c_str()).c_str()); + imageSrc.c_str())); } imageSet->setOffsetX(XML::getProperty(node, "offsetX", 0)); @@ -341,14 +339,14 @@ SpriteDirection SpriteDef::makeSpriteDirection(const std::string &direction) { if (direction.empty() || direction == "default") return DIRECTION_DEFAULT; - else if (direction == "up") + if (direction == "up") return DIRECTION_UP; - else if (direction == "left") + if (direction == "left") return DIRECTION_LEFT; - else if (direction == "right") + if (direction == "right") return DIRECTION_RIGHT; - else if (direction == "down") + if (direction == "down") return DIRECTION_DOWN; - else - return DIRECTION_INVALID; + + return DIRECTION_INVALID; } diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index dff3f2a0..fafd6a41 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -156,13 +156,8 @@ class SpriteDef : public Resource */ void substituteAction(std::string complete, std::string with); - using ImageSets = std::map<std::string, ImageSet *>; - using ImageSetIterator = ImageSets::iterator; - - using Actions = std::map<std::string, Action *>; - - ImageSets mImageSets; - Actions mActions; + std::map<std::string, ImageSet *> mImageSets; + std::map<std::string, Action *> mActions; }; #endif // SPRITEDEF_H diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp index f06172a5..c7c70974 100644 --- a/src/rotationalparticle.cpp +++ b/src/rotationalparticle.cpp @@ -20,7 +20,6 @@ */ #include "rotationalparticle.h" -#include "graphics.h" #include "simpleanimation.h" #define PI 3.14159265 |