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 | |
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')
357 files changed, 1946 insertions, 1948 deletions
diff --git a/src/actor.cpp b/src/actor.cpp index 63bded0d..e1fffaf9 100644 --- a/src/actor.cpp +++ b/src/actor.cpp @@ -25,12 +25,12 @@ #include "resources/image.h" Actor::Actor(): - mMap(NULL) + mMap(nullptr) {} Actor::~Actor() { - setMap(NULL); + setMap(nullptr); } void Actor::setMap(Map *map) diff --git a/src/actor.h b/src/actor.h index 843b3d96..9d5886e8 100644 --- a/src/actor.h +++ b/src/actor.h @@ -30,7 +30,7 @@ class Graphics; class Image; class Map; -typedef std::list<Actor*> Actors; +using Actors = std::list<Actor *>; class Actor { diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 3b3a83ef..58ffa6e7 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -51,14 +51,14 @@ ActorSprite::ActorSprite(int id): mStatusParticleEffects(&mStunParticleEffects, false), mChildParticleEffects(&mStatusParticleEffects, false), mMustResetParticles(false), - mUsedTargetCursor(NULL) + mUsedTargetCursor(nullptr) {} ActorSprite::~ActorSprite() { - setMap(NULL); + setMap(nullptr); - mUsedTargetCursor = NULL; + mUsedTargetCursor = nullptr; // Notify listeners of the destruction. Event event(Event::Destroyed); @@ -112,7 +112,7 @@ void ActorSprite::logic() if (mMustResetParticles) { mMustResetParticles = false; - for (std::set<int>::iterator it = mStatusEffects.begin(); + for (auto it = mStatusEffects.begin(); it != mStatusEffects.end(); it++) { const StatusEffect *effect = StatusEffect::getStatusEffect(*it, true); @@ -161,13 +161,13 @@ struct EffectDescription { std::string mSFXEffect; }; -static EffectDescription *default_effect = NULL; +static EffectDescription *default_effect = nullptr; static std::map<int, EffectDescription *> effects; static bool effects_initialized = false; static EffectDescription *getEffectDescription(xmlNodePtr node, int *id) { - EffectDescription *ed = new EffectDescription; + auto *ed = new EffectDescription; *id = atoi(XML::getProperty(node, "id", "-1").c_str()); ed->mSFXEffect = XML::getProperty(node, "audio", ""); @@ -187,7 +187,7 @@ static EffectDescription *getEffectDescription(int effectId) { logger->log("Error loading being effects file: " EFFECTS_FILE); - return NULL; + return nullptr; } for_each_xml_child_node(node, root) @@ -449,7 +449,7 @@ void ActorSprite::loadTargetCursor(const std::string &filename, return; } - Animation *anim = new Animation; + auto *anim = new Animation; for (unsigned int i = 0; i < currentImageSet->size(); ++i) { @@ -458,7 +458,7 @@ void ActorSprite::loadTargetCursor(const std::string &filename, -(currentImageSet->getHeight() / 2)); } - SimpleAnimation *currentCursor = new SimpleAnimation(anim); + auto *currentCursor = new SimpleAnimation(anim); targetCursorImages[type][size] = currentImageSet; targetCursor[type][size] = currentCursor; diff --git a/src/actorsprite.h b/src/actorsprite.h index ab327e16..f657d5cb 100644 --- a/src/actorsprite.h +++ b/src/actorsprite.h @@ -63,7 +63,7 @@ public: ActorSprite(int id); - ~ActorSprite(); + ~ActorSprite() override; int getId() const { return mId; } @@ -75,9 +75,9 @@ public: */ virtual Type getType() const { return UNKNOWN; } - virtual int getDrawOrder() const; + int getDrawOrder() const override; - virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const; + bool draw(Graphics *graphics, int offsetX, int offsetY) const override; virtual bool drawSpriteAt(Graphics *graphics, int x, int y) const; @@ -85,7 +85,7 @@ public: static void actorLogic(); - void setMap(Map* map); + void setMap(Map* map) override; /** * Gets the way the object blocks pathfinding for other objects @@ -112,7 +112,7 @@ public: /** * Untargets the actor. */ - void untarget() { mUsedTargetCursor = NULL; } + void untarget() { mUsedTargetCursor = nullptr; } /** * Triggers a visual effect, such as `level up'. Only draws the visual @@ -146,16 +146,16 @@ public: */ void setStatusEffectBlock(int offset, uint16_t flags); - virtual void setAlpha(float alpha) + void setAlpha(float alpha) override { CompoundSprite::setAlpha(alpha); } - virtual float getAlpha() const + float getAlpha() const override { return CompoundSprite::getAlpha(); } - virtual int getWidth() const + int getWidth() const override { return CompoundSprite::getWidth(); } - virtual int getHeight() const + int getHeight() const override { return CompoundSprite::getHeight(); } static void load(); diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 7da9fe10..88823d34 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -42,7 +42,7 @@ class FindBeingFunctor if (!game) return false; - Being* b = static_cast<Being*>(actor); + auto* b = static_cast<Being*>(actor); uint16_t other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0); const Vector &pos = b->getPosition(); @@ -59,7 +59,7 @@ class FindBeingFunctor class PlayerNamesLister : public AutoCompleteLister { - void getAutoCompleteList(std::vector<std::string>& names) const + void getAutoCompleteList(std::vector<std::string>& names) const override { names.clear(); @@ -69,7 +69,7 @@ class PlayerNamesLister : public AutoCompleteLister if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *being = static_cast<Being*>(*it); + auto *being = static_cast<Being*>(*it); if (being->getType() == Being::PLAYER && being->getName() != "") names.push_back(being->getName()); } @@ -78,7 +78,7 @@ class PlayerNamesLister : public AutoCompleteLister class PlayerNPCNamesLister : public AutoCompleteLister { - void getAutoCompleteList(std::vector<std::string>& names) const + void getAutoCompleteList(std::vector<std::string>& names) const override { names.clear(); @@ -88,7 +88,7 @@ class PlayerNPCNamesLister : public AutoCompleteLister if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *being = static_cast<Being*>(*it); + auto *being = static_cast<Being*>(*it); if ((being->getType() == Being::PLAYER || being->getType() == Being::NPC) && being->getName() != "") @@ -124,7 +124,7 @@ void ActorSpriteManager::setPlayer(LocalPlayer *player) Being *ActorSpriteManager::createBeing(int id, ActorSprite::Type type, int subtype) { - Being *being = new Being(id, type, subtype, mMap); + auto *being = new Being(id, type, subtype, mMap); mActors.insert(being); return being; @@ -132,7 +132,7 @@ Being *ActorSpriteManager::createBeing(int id, ActorSprite::Type type, int subty FloorItem *ActorSpriteManager::createItem(int id, int itemId, const Vector &pos) { - FloorItem *floorItem = new FloorItem(id, itemId, pos, mMap); + auto *floorItem = new FloorItem(id, itemId, pos, mMap); mActors.insert(floorItem); return floorItem; @@ -163,7 +163,7 @@ Being *ActorSpriteManager::findBeing(int id) const return static_cast<Being*>(actor); } - return NULL; + return nullptr; } Being *ActorSpriteManager::findBeing(int x, int y, ActorSprite::Type type) const @@ -172,21 +172,21 @@ Being *ActorSpriteManager::findBeing(int x, int y, ActorSprite::Type type) const beingFinder.y = y; beingFinder.type = type; - ActorSpritesConstIterator it = find_if(mActors.begin(), mActors.end(), + auto it = find_if(mActors.begin(), mActors.end(), beingFinder); - return (it == mActors.end()) ? NULL : static_cast<Being*>(*it); + return (it == mActors.end()) ? nullptr : static_cast<Being*>(*it); } Being *ActorSpriteManager::findBeingByPixel(int x, int y) const { - Map *map = Game::instance() ? Game::instance()->getCurrentMap() : 0; + Map *map = Game::instance() ? Game::instance()->getCurrentMap() : nullptr; if (!map) - return 0; + return nullptr; const int halfTileHeight = map->getTileHeight() / 2; - Being *closest = 0; + Being *closest = nullptr; int closestDist = 0; for_actors @@ -194,7 +194,7 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y) const if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *being = static_cast<Being*>(*it); + auto *being = static_cast<Being*>(*it); const int halfWidth = std::max(16, being->getWidth() / 2); const int height = std::max(32, being->getHeight()); @@ -233,12 +233,12 @@ FloorItem *ActorSpriteManager::findItem(int id) const } } - return NULL; + return nullptr; } FloorItem *ActorSpriteManager::findItem(int x, int y, int maxDist) const { - FloorItem *item = 0; + FloorItem *item = nullptr; int smallestDist = 0; for_actors { @@ -263,12 +263,12 @@ Being *ActorSpriteManager::findBeingByName(const std::string &name, if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *being = static_cast<Being*>(*it); + auto *being = static_cast<Being*>(*it); if (being->getName() == name && (type == ActorSprite::UNKNOWN || type == being->getType())) return being; } - return NULL; + return nullptr; } const ActorSprites &ActorSpriteManager::getAll() const @@ -312,9 +312,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, { Game *game = Game::instance(); if (!game) - return 0; + return nullptr; - Being *closestBeing = 0; + Being *closestBeing = nullptr; int dist = 0; const int maxDist = maxTileDist * game->getCurrentTileWidth(); @@ -324,7 +324,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *being = static_cast<Being*>(*it); + auto *being = static_cast<Being*>(*it); const Vector &pos = being->getPosition(); int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y); @@ -338,7 +338,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, } } - return (maxDist >= dist) ? closestBeing : 0; + return (maxDist >= dist) ? closestBeing : nullptr; } Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, @@ -378,7 +378,7 @@ void ActorSpriteManager::updatePlayerNames() if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *being = static_cast<Being*>(*it); + auto *being = static_cast<Being*>(*it); if (being->getType() == ActorSprite::PLAYER && being->getName() != "") being->updateName(); } diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h index 76364ea5..de674a78 100644 --- a/src/actorspritemanager.h +++ b/src/actorspritemanager.h @@ -31,9 +31,9 @@ class LocalPlayer; class Map; -typedef std::set<ActorSprite*> ActorSprites; -typedef ActorSprites::iterator ActorSpritesIterator; -typedef ActorSprites::const_iterator ActorSpritesConstIterator; +using ActorSprites = std::set<ActorSprite *>; +using ActorSpritesIterator = ActorSprites::iterator; +using ActorSpritesConstIterator = ActorSprites::const_iterator; class ActorSpriteManager { @@ -115,7 +115,7 @@ class ActorSpriteManager */ Being *findNearestLivingBeing(int x, int y, int maxTileDist, ActorSprite::Type type = Being::UNKNOWN, - Being *excluded = 0) const; + Being *excluded = nullptr) const; /** * Returns a being nearest to another being. diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 54a11d87..a9138e36 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -36,9 +36,9 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite): mFrameIndex(0), mFrameTime(0), mSprite(sprite), - mAction(0), - mAnimation(0), - mFrame(0) + mAction(nullptr), + mAnimation(nullptr), + mFrame(nullptr) { assert(mSprite); @@ -56,8 +56,8 @@ AnimatedSprite *AnimatedSprite::load(const std::string &filename, int variant) ResourceManager *resman = ResourceManager::getInstance(); SpriteDef *s = resman->getSprite(filename, variant); if (!s) - return NULL; - AnimatedSprite *as = new AnimatedSprite(s); + return nullptr; + auto *as = new AnimatedSprite(s); s->decRef(); return as; } @@ -145,8 +145,8 @@ bool AnimatedSprite::updateCurrentAnimation(unsigned int time) if (Animation::isTerminator(*mFrame)) { - mAnimation = 0; - mFrame = 0; + mAnimation = nullptr; + mFrame = nullptr; return false; } } @@ -229,5 +229,5 @@ int AnimatedSprite::getOffsetY() const const Image* AnimatedSprite::getImage() const { - return mFrame ? mFrame->image : 0; + return mFrame ? mFrame->image : nullptr; } diff --git a/src/animatedsprite.h b/src/animatedsprite.h index 32a63bf6..67d3f300 100644 --- a/src/animatedsprite.h +++ b/src/animatedsprite.h @@ -52,27 +52,27 @@ class AnimatedSprite : public Sprite static AnimatedSprite *load(const std::string &filename, int variant = 0); - virtual ~AnimatedSprite(); + ~AnimatedSprite() override; - bool reset(); + bool reset() override; - bool play(std::string action); + bool play(std::string action) override; - bool update(int time); + bool update(int time) override; - bool draw(Graphics* graphics, int posX, int posY) const; + bool draw(Graphics* graphics, int posX, int posY) const override; - int getWidth() const; + int getWidth() const override; - int getHeight() const; + int getHeight() const override; - int getOffsetX() const; + int getOffsetX() const override; - int getOffsetY() const; + int getOffsetY() const override; - const Image* getImage() const; + const Image* getImage() const override; - bool setDirection(SpriteDirection direction); + bool setDirection(SpriteDirection direction) override; int getNumberOfLayers() { return 1; } @@ -80,7 +80,7 @@ class AnimatedSprite : public Sprite virtual bool drawnWhenBehind() const { return true; } - int getDuration() const; + int getDuration() const override; private: bool updateCurrentAnimation(unsigned int dt); diff --git a/src/animationparticle.cpp b/src/animationparticle.cpp index f7683ee6..1c79556f 100644 --- a/src/animationparticle.cpp +++ b/src/animationparticle.cpp @@ -25,14 +25,14 @@ #include "simpleanimation.h" AnimationParticle::AnimationParticle(Map *map, Animation *animation): - ImageParticle(map, NULL), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animation)) { } AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode, const std::string& dyePalettes): - ImageParticle(map, 0), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animationNode, dyePalettes)) { } @@ -40,7 +40,7 @@ AnimationParticle::AnimationParticle(Map *map, xmlNodePtr animationNode, AnimationParticle::~AnimationParticle() { delete mAnimation; - mImage = NULL; + mImage = nullptr; } bool AnimationParticle::update() diff --git a/src/animationparticle.h b/src/animationparticle.h index f1c8e353..16cc12a5 100644 --- a/src/animationparticle.h +++ b/src/animationparticle.h @@ -38,9 +38,9 @@ class AnimationParticle : public ImageParticle AnimationParticle(Map *map, xmlNodePtr animationNode, const std::string& dyePalettes = std::string()); - ~AnimationParticle(); + ~AnimationParticle() override; - virtual bool update(); + bool update() override; private: SimpleAnimation *mAnimation; /**< Used animation for this particle */ diff --git a/src/being.cpp b/src/being.cpp index 21d48ed2..d6b36cc6 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -76,12 +76,12 @@ Being::Being(int id, Type type, int subtype, Map *map): mSubType(0xFFFF), mDirection(DOWN), mSpriteDirection(DIRECTION_DOWN), - mDispName(0), + mDispName(nullptr), mShowName(false), - mEquippedWeapon(NULL), - mText(0), + mEquippedWeapon(nullptr), + mText(nullptr), mGender(GENDER_UNSPECIFIED), - mParty(NULL), + mParty(nullptr), mIsGM(false), mType(type), mSpeedPixelsPerTick(Vector(0.0f, 0.0f, 0.0f)), @@ -111,9 +111,9 @@ Being::~Being() delete mSpeechBubble; delete mDispName; delete mText; - mSpeechBubble = 0; - mDispName = 0; - mText = 0; + mSpeechBubble = nullptr; + mDispName = nullptr; + mText = nullptr; } void Being::setSubtype(Uint16 subtype) @@ -391,7 +391,7 @@ void Being::takeDamage(Being *attacker, int amount, // Init the particle effect path based on current weapon or default. int hitEffectId = 0; const ItemInfo *attackerWeapon = attacker ? - attacker->getEquippedWeapon() : 0; + attacker->getEquippedWeapon() : nullptr; if (attackerWeapon && attacker->getType() == PLAYER) { @@ -473,7 +473,7 @@ void Being::setShowName(bool doShowName) else { delete mDispName; - mDispName = 0; + mDispName = nullptr; } } @@ -524,7 +524,7 @@ Guild *Being::getGuild(const std::string &guildName) const } } - return NULL; + return nullptr; } Guild *Being::getGuild(int id) const @@ -536,7 +536,7 @@ Guild *Being::getGuild(int id) const return itr->second; } - return NULL; + return nullptr; } void Being::clearGuilds() @@ -791,7 +791,7 @@ void Being::logic() if (mSpeechTime == 0 && mText) { delete mText; - mText = 0; + mText = nullptr; } if ((mAction != DEAD) && !mSpeedPixelsPerTick.isNull()) @@ -915,7 +915,7 @@ void Being::drawSpeech(int offsetX, int offsetY) if (mText) { delete mText; - mText = NULL; + mText = nullptr; } mSpeechBubble->setCaption(showName ? mName : "", mTextColor); @@ -946,7 +946,7 @@ void Being::drawSpeech(int offsetX, int offsetY) if (mText) delete mText; - mText = NULL; + mText = nullptr; } } @@ -971,10 +971,10 @@ void Being::flashName(int time) void Being::showName() { delete mDispName; - mDispName = 0; + mDispName = nullptr; std::string mDisplayName(mName); - Being* player = static_cast<Being*>(this); + auto* player = static_cast<Being*>(this); if (player) { if (config.getBoolValue("showgender")) @@ -1001,7 +1001,7 @@ void Being::showName() } } - gcn::Font *font = 0; + gcn::Font *font = nullptr; if (local_player && local_player->getTarget() == this && getType() != MONSTER) { @@ -1074,12 +1074,12 @@ void Being::setSprite(unsigned int slot, int id, const std::string &color, removeSprite(slot); if (isWeapon) - mEquippedWeapon = 0; + mEquippedWeapon = nullptr; } else { std::string filename = itemDb->get(id).getSprite(mGender); - AnimatedSprite *equipmentSprite = 0; + AnimatedSprite *equipmentSprite = nullptr; if (!filename.empty()) { diff --git a/src/being.h b/src/being.h index 0287dc6e..5bf85a72 100644 --- a/src/being.h +++ b/src/being.h @@ -112,9 +112,9 @@ class Being : public ActorSprite, public EventListener */ Being(int id, Type type, int subtype, Map *map); - virtual ~Being(); + ~Being() override; - Type getType() const + Type getType() const override { return mType; } /** @@ -136,13 +136,13 @@ class Being : public ActorSprite, public EventListener /** * Returns the tile x coord */ - int getTileX() const + int getTileX() const override { return mPos.x / mMap->getTileWidth(); } /** * Returns the tile y coord */ - int getTileY() const + int getTileY() const override { return mPos.y / mMap->getTileHeight(); } /** @@ -248,7 +248,7 @@ class Being : public ActorSprite, public EventListener { return mGuilds.size(); } bool isInParty() const - { return mParty != NULL; } + { return mParty != nullptr; } void setParty(Party *party); @@ -269,15 +269,15 @@ class Being : public ActorSprite, public EventListener /** * Get the number of layers used to draw the being */ - int getNumberOfLayers() const; + int getNumberOfLayers() const override; - virtual bool drawnWhenBehind() const + bool drawnWhenBehind() const override { return CompoundSprite::drawnWhenBehind(); } /** * Performs being logic. */ - virtual void logic(); + void logic() override; /** * Draws the speech text above the being. @@ -294,7 +294,7 @@ class Being : public ActorSprite, public EventListener const BeingInfo *getInfo() const { return mInfo; } - TargetCursorSize getTargetCursorSize() const; + TargetCursorSize getTargetCursorSize() const override; /** * Gets the way the object is blocked by other objects. @@ -304,7 +304,7 @@ class Being : public ActorSprite, public EventListener /** * Gets the way the monster blocks pathfinding for other objects */ - Map::BlockType getBlockType() const; + Map::BlockType getBlockType() const override; /** * Sets the move speed. @@ -364,7 +364,7 @@ class Being : public ActorSprite, public EventListener SpriteDirection getSpriteDirection() const { return SpriteDirection(mSpriteDirection); } - void setPosition(const Vector &pos); + void setPosition(const Vector &pos) override; /** * Overloaded method provided for convenience. @@ -434,9 +434,9 @@ class Being : public ActorSprite, public EventListener void talkTo(); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; - void setMap(Map *map); + void setMap(Map *map) override; /** * Make the being look at a given pixel position. diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp index 06d2215d..3e285889 100644 --- a/src/channelmanager.cpp +++ b/src/channelmanager.cpp @@ -37,8 +37,8 @@ ChannelManager::~ChannelManager() Channel *ChannelManager::findById(int id) const { - Channel *channel = 0; - for (std::list<Channel*>::const_iterator itr = mChannels.begin(), + Channel *channel = nullptr; + for (auto itr = mChannels.begin(), end = mChannels.end(); itr != end; itr++) @@ -55,10 +55,10 @@ Channel *ChannelManager::findById(int id) const Channel *ChannelManager::findByName(const std::string &name) const { - Channel *channel = 0; + Channel *channel = nullptr; if (!name.empty()) { - for (std::list<Channel*>::const_iterator itr = mChannels.begin(), + for (auto itr = mChannels.begin(), end = mChannels.end(); itr != end; itr++) diff --git a/src/client.cpp b/src/client.cpp index 986b65fa..6bbba39b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -175,19 +175,19 @@ bool isDoubleClick(int selected) } -Client *Client::mInstance = 0; +Client *Client::mInstance = nullptr; Client::Client(const Options &options): mOptions(options), - mGame(0), - mCurrentDialog(0), - mQuitDialog(0), - mDesktop(0), - mSetupButton(0), + mGame(nullptr), + mCurrentDialog(nullptr), + mQuitDialog(nullptr), + mDesktop(nullptr), + mSetupButton(nullptr), mState(STATE_CHOOSE_SERVER), mOldState(STATE_START), mStateAfterOkDialog(mState), - mIcon(0), + mIcon(nullptr), mLogicCounterId(0), mSecondsCounterId(0), mLimitFps(false) @@ -419,8 +419,8 @@ Client::Client(const Options &options): // Initialize logic and seconds counters tick_time = 0; - mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, NULL); - mSecondsCounterId = SDL_AddTimer(1000, nextSecond, NULL); + mLogicCounterId = SDL_AddTimer(MILLISECONDS_IN_A_TICK, nextTick, nullptr); + mSecondsCounterId = SDL_AddTimer(1000, nextSecond, nullptr); // Initialize frame limiting SDL_initFramerate(&mFpsManager); @@ -470,7 +470,7 @@ Client::~Client() delete logger; - mInstance = 0; + mInstance = nullptr; } int Client::exec() @@ -567,7 +567,7 @@ int Client::exec() else if (mOldState == STATE_START || (mOldState == STATE_GAME && mState != STATE_GAME)) { - gcn::Container *top = static_cast<gcn::Container*>(gui->getTop()); + auto *top = static_cast<gcn::Container*>(gui->getTop()); mDesktop = new Desktop; top->add(mDesktop); @@ -598,7 +598,7 @@ int Client::exec() if (mOldState == STATE_GAME) { delete mGame; - mGame = 0; + mGame = nullptr; } mOldState = mState; @@ -607,7 +607,7 @@ int Client::exec() if (mCurrentDialog) { delete mCurrentDialog; - mCurrentDialog = NULL; + mCurrentDialog = nullptr; } // State has changed, while the quitDialog was active, it might // not be correct anymore @@ -702,7 +702,7 @@ int Client::exec() if (mOptions.chooseDefault) { ((WorldSelectDialog*) mCurrentDialog)->action( - gcn::ActionEvent(NULL, "ok")); + gcn::ActionEvent(nullptr, "ok")); } } } @@ -766,7 +766,7 @@ int Client::exec() break; default: // Nothing - itemDb = 0; + itemDb = nullptr; break; } assert(itemDb); @@ -846,10 +846,10 @@ int Client::exec() delete mSetupButton; delete mDesktop; - mSetupButton = NULL; - mDesktop = NULL; + mSetupButton = nullptr; + mDesktop = nullptr; - mCurrentDialog = NULL; + mCurrentDialog = nullptr; logger->log("State: GAME"); mGame = new Game; @@ -1010,7 +1010,7 @@ void Client::showOkDialog(const std::string &title, const std::string &message, State state) { - OkDialog *okDialog = new OkDialog(title, message); + auto *okDialog = new OkDialog(title, message); okDialog->addActionListener(this); mStateAfterOkDialog = state; } @@ -1036,7 +1036,7 @@ void Client::event(Event::Channel channel, const Event &event) void Client::action(const gcn::ActionEvent &event) { - Window *window = 0; + Window *window = nullptr; if (event.getId() == "Setup") window = setupWindow; @@ -1218,7 +1218,7 @@ void Client::initConfiguration() // Checking if the configuration file exists... otherwise create it with // default options. - FILE *configFile = 0; + FILE *configFile = nullptr; std::string configPath; configPath = mConfigDir + "/config.xml"; diff --git a/src/client.h b/src/client.h index 28fd4445..fbfcabf8 100644 --- a/src/client.h +++ b/src/client.h @@ -159,7 +159,7 @@ public: }; Client(const Options &options); - ~Client(); + ~Client() override; /** * Provides access to the client instance. @@ -200,8 +200,8 @@ public: static const std::string &getScreenshotDirectory() { return instance()->mScreenshotDir; } - void event(Event::Channel channel, const Event &event); - void action(const gcn::ActionEvent &event); + void event(Event::Channel channel, const Event &event) override; + void action(const gcn::ActionEvent &event) override; /** * Should be called after the window has been resized by the user. diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 0f231535..982ea9fb 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -30,8 +30,8 @@ #include <SDL.h> CompoundSprite::CompoundSprite(): - mImage(NULL), - mAlphaImage(NULL), + mImage(nullptr), + mAlphaImage(nullptr), mWidth(0), mHeight(0), mOffsetX(0), @@ -187,7 +187,7 @@ void CompoundSprite::removeSprite(int layer) return; delete mSprites.at(layer); - mSprites.at(layer) = NULL; + mSprites.at(layer) = nullptr; mNeedsRedraw = true; } diff --git a/src/compoundsprite.h b/src/compoundsprite.h index eed40231..e5b41973 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -32,43 +32,43 @@ class CompoundSprite : public Sprite public: CompoundSprite(); - ~CompoundSprite(); + ~CompoundSprite() override; - virtual bool reset(); + bool reset() override; - virtual bool play(std::string action); + bool play(std::string action) override; - virtual bool update(int time); + bool update(int time) override; - virtual bool draw(Graphics *graphics, int posX, int posY) const; + bool draw(Graphics *graphics, int posX, int posY) const override; /** * Gets the width in pixels of the first sprite in the list. */ - virtual int getWidth() const + int getWidth() const override { return mWidth; } /** * Gets the height in pixels of the first sprite in the list. */ - virtual int getHeight() const + int getHeight() const override { return mHeight; } - int getOffsetX() const + int getOffsetX() const override { return mOffsetX; } - int getOffsetY() const + int getOffsetY() const override { return mOffsetY; } - virtual const Image *getImage() const; + const Image *getImage() const override; - virtual bool setDirection(SpriteDirection direction); + bool setDirection(SpriteDirection direction) override; int getNumberOfLayers() const; virtual bool drawnWhenBehind() const; - int getDuration() const; + int getDuration() const override; size_t size() const { return mSprites.size(); } @@ -90,8 +90,8 @@ public: { mNeedsRedraw = true; } private: - typedef std::vector<Sprite*>::iterator SpriteIterator; - typedef std::vector<Sprite*>::const_iterator SpriteConstIterator; + using SpriteIterator = std::vector<Sprite *>::iterator; + using SpriteConstIterator = std::vector<Sprite *>::const_iterator; void redraw() const; diff --git a/src/configuration.cpp b/src/configuration.cpp index 0b1d9ae7..34febf22 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -46,27 +46,27 @@ void Configuration::setValue(const std::string &key, const std::string &value) std::string ConfigurationObject::getValue(const std::string &key, const std::string &deflt) const { - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); return ((iter != mOptions.end()) ? iter->second : deflt); } int ConfigurationObject::getValue(const std::string &key, int deflt) const { - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); return (iter != mOptions.end()) ? atoi(iter->second.c_str()) : deflt; } unsigned ConfigurationObject::getValue(const std::string &key, unsigned deflt) const { - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); return (iter != mOptions.end()) ? atol(iter->second.c_str()) : deflt; } double ConfigurationObject::getValue(const std::string &key, double deflt) const { - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); return (iter != mOptions.end()) ? atof(iter->second.c_str()) : deflt; } @@ -108,7 +108,7 @@ void Configuration::cleanDefaults() delete iter->second; } delete mDefaultsData; - mDefaultsData = 0; + mDefaultsData = nullptr; } } @@ -142,13 +142,13 @@ VariableData* Configuration::getDefault(const std::string &key, mConfigPath.c_str(), key.c_str()); } } - return NULL; + return nullptr; } int Configuration::getIntValue(const std::string &key) const { int defaultValue = 0; - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); if (iter == mOptions.end()) { VariableData* vd = getDefault(key, VariableData::DATA_INT); @@ -165,7 +165,7 @@ int Configuration::getIntValue(const std::string &key) const std::string Configuration::getStringValue(const std::string &key) const { std::string defaultValue = ""; - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); if (iter == mOptions.end()) { VariableData* vd = getDefault(key, @@ -185,7 +185,7 @@ std::string Configuration::getStringValue(const std::string &key) const float Configuration::getFloatValue(const std::string &key) const { float defaultValue = 0.0f; - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); if (iter == mOptions.end()) { VariableData* vd = getDefault(key, @@ -204,7 +204,7 @@ float Configuration::getFloatValue(const std::string &key) const bool Configuration::getBoolValue(const std::string &key) const { bool defaultValue = false; - Options::const_iterator iter = mOptions.find(key); + auto iter = mOptions.find(key); if (iter == mOptions.end()) { VariableData* vd = getDefault(key, @@ -237,7 +237,7 @@ void ConfigurationObject::initFromXML(xmlNodePtr parent_node) if (xmlStrEqual(subnode->name, BAD_CAST name.c_str()) && subnode->type == XML_ELEMENT_NODE) { - ConfigurationObject *cobj = new ConfigurationObject; + auto *cobj = new ConfigurationObject; cobj->initFromXML(subnode); // Recurse @@ -306,7 +306,7 @@ void ConfigurationObject::writeToXML(xmlTextWriterPtr writer) xmlTextWriterWriteAttribute(writer, BAD_CAST "name", BAD_CAST name); // Recurse on all elements - for (ConfigurationList::const_iterator + for (auto elt_it = it->second.begin(); elt_it != it->second.end(); elt_it++) { xmlTextWriterStartElement(writer, BAD_CAST name); @@ -344,7 +344,7 @@ void Configuration::write() logger->log("Configuration::write() writing configuration..."); xmlTextWriterSetIndent(writer, 1); - xmlTextWriterStartDocument(writer, NULL, NULL, NULL); + xmlTextWriterStartDocument(writer, nullptr, nullptr, nullptr); xmlTextWriterStartElement(writer, BAD_CAST "configuration"); writeToXML(writer); diff --git a/src/configuration.h b/src/configuration.h index 16ee6236..49ea7c20 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -126,7 +126,7 @@ class ConfigurationObject void setList(const std::string &name, IT begin, IT end, ConfigurationListManager<T, CONT> *manager) { - ConfigurationObject *nextobj = new ConfigurationObject; + auto *nextobj = new ConfigurationObject; deleteList(name); ConfigurationList *list = &(mContainerOptions[name]); @@ -177,10 +177,10 @@ class ConfigurationObject void deleteList(const std::string &name); - typedef std::map<std::string, std::string> Options; + using Options = std::map<std::string, std::string>; Options mOptions; - typedef std::list<ConfigurationObject *> ConfigurationList; + using ConfigurationList = std::list<ConfigurationObject *>; std::map<std::string, ConfigurationList> mContainerOptions; }; @@ -192,9 +192,9 @@ class ConfigurationObject class Configuration : public ConfigurationObject { public: - Configuration() : mDefaultsData(0) {} + Configuration() : mDefaultsData(nullptr) {} - ~Configuration(); + ~Configuration() override; /** * Reads config file and parse all options into memory. @@ -216,7 +216,7 @@ class Configuration : public ConfigurationObject */ void write(); - void setValue(const std::string &key, const std::string &value); + void setValue(const std::string &key, const std::string &value) override; void setValue(const std::string &key, const char *value) { setValue(key, std::string(value)); } diff --git a/src/defaults.cpp b/src/defaults.cpp index 2cd81cd2..99b9d6a0 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -63,7 +63,7 @@ VariableData* createData(bool defData) DefaultsData* getConfigDefaults() { - DefaultsData* configData = new DefaultsData; + auto* configData = new DefaultsData; // Init main config defaults AddDEF(configData, "OverlayDetail", 2); AddDEF(configData, "speechBubblecolor", "000000"); @@ -125,7 +125,7 @@ DefaultsData* getConfigDefaults() DefaultsData* getBrandingDefaults() { - DefaultsData* brandingData = new DefaultsData; + auto* brandingData = new DefaultsData; // Init config defaults AddDEF(brandingData, "wallpapersPath", ""); AddDEF(brandingData, "wallpaperFile", ""); @@ -150,7 +150,7 @@ DefaultsData* getBrandingDefaults() DefaultsData* getPathsDefaults() { - DefaultsData *pathsData = new DefaultsData; + auto *pathsData = new DefaultsData; // Init paths.xml defaults AddDEF(pathsData, "itemIcons", "graphics/items/"); AddDEF(pathsData, "unknownItemFile", "unknown-item.png"); diff --git a/src/defaults.h b/src/defaults.h index c2372df1..a9532459 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -25,7 +25,7 @@ #include <string> #include "variabledata.h" -typedef std::map<std::string, VariableData*> DefaultsData; +using DefaultsData = std::map<std::string, VariableData *>; DefaultsData* getConfigDefaults(); DefaultsData* getBrandingDefaults(); diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index b842245c..4fd7d7e6 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -67,7 +67,7 @@ EffectManager::~EffectManager() bool EffectManager::trigger(int id, Being* being, int rotation) { bool rValue = false; - for (std::list<EffectDescription>::iterator i = mEffects.begin(); i != mEffects.end(); ++i) + for (auto i = mEffects.begin(); i != mEffects.end(); ++i) { if ((*i).id == id) { @@ -89,7 +89,7 @@ bool EffectManager::trigger(int id, Being* being, int rotation) bool EffectManager::trigger(int id, int x, int y, int rotation) { bool rValue = false; - for (std::list<EffectDescription>::iterator i = mEffects.begin(); i != mEffects.end(); ++i) + for (auto i = mEffects.begin(); i != mEffects.end(); ++i) { if ((*i).id == id) { diff --git a/src/equipment.h b/src/equipment.h index 00f9d410..71a15734 100644 --- a/src/equipment.h +++ b/src/equipment.h @@ -29,9 +29,9 @@ class Item; class Equipment { public: - Equipment(): mBackend(0) {} + Equipment(): mBackend(nullptr) {} - ~Equipment() { mBackend = 0; } + ~Equipment() { mBackend = nullptr; } class Backend { public: @@ -52,7 +52,7 @@ class Equipment * Get equipment at the given slot. */ Item *getEquipment(int slotIndex) const - { return mBackend ? mBackend->getEquipment(slotIndex) : 0; } + { return mBackend ? mBackend->getEquipment(slotIndex) : nullptr; } const std::string getSlotName(int slotIndex) const { return mBackend ? mBackend->getSlotName(slotIndex) : std::string(); } diff --git a/src/event.cpp b/src/event.cpp index 73099cc3..aba2996f 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -27,7 +27,7 @@ Event::ListenMap Event::mBindings; Event::~Event() { - VariableMap::iterator it = mData.begin(); + auto it = mData.begin(); while (it != mData.end()) { delete it->second; @@ -47,7 +47,7 @@ void Event::setInt(const std::string &key, int value) int Event::getInt(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); if (it == mData.end()) throw BAD_KEY; @@ -59,7 +59,7 @@ int Event::getInt(const std::string &key) const bool Event::hasInt(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); return !(it == mData.end() || it->second->getType() != VariableData::DATA_INT); } @@ -76,7 +76,7 @@ void Event::setString(const std::string &key, const std::string &value) const std::string &Event::getString(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); if (it == mData.end()) throw BAD_KEY; @@ -89,7 +89,7 @@ const std::string &Event::getString(const std::string &key) const bool Event::hasString(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); return !(it == mData.end() || it->second->getType() != VariableData::DATA_STRING); } @@ -106,7 +106,7 @@ void Event::setFloat(const std::string &key, double value) double Event::getFloat(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); if (it == mData.end()) throw BAD_KEY; @@ -118,7 +118,7 @@ double Event::getFloat(const std::string &key) const bool Event::hasFloat(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); return !(it == mData.end() || it->second->getType() != VariableData::DATA_FLOAT); } @@ -135,7 +135,7 @@ void Event::setBool(const std::string &key, bool value) bool Event::getBool(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); if (it == mData.end()) throw BAD_KEY; @@ -147,7 +147,7 @@ bool Event::getBool(const std::string &key) const bool Event::hasBool(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); return !(it == mData.end() || it->second->getType() != VariableData::DATA_BOOL); } @@ -164,7 +164,7 @@ void Event::setItem(const std::string &key, Item *value) Item *Event::getItem(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); if (it == mData.end()) throw BAD_KEY; @@ -176,7 +176,7 @@ Item *Event::getItem(const std::string &key) const bool Event::hasItem(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); return !(it == mData.end() || it->second->getType() != VariableData::DATA_ITEM); } @@ -193,7 +193,7 @@ void Event::setActor(const std::string &key, ActorSprite *value) ActorSprite *Event::getActor(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); if (it == mData.end()) throw BAD_KEY; @@ -205,7 +205,7 @@ ActorSprite *Event::getActor(const std::string &key) const bool Event::hasActor(const std::string &key) const { - VariableMap::const_iterator it = mData.find(key); + auto it = mData.find(key); return !(it == mData.end() || it->second->getType() != VariableData::DATA_ACTOR); } @@ -214,14 +214,14 @@ bool Event::hasActor(const std::string &key) const void Event::trigger(Channel channel, const Event &event) { - ListenMap::iterator it = mBindings.find(channel); + auto it = mBindings.find(channel); // Make sure something is listening if (it == mBindings.end()) return; // Loop though all listeners - ListenerSet::iterator lit = it->second.begin(); + auto lit = it->second.begin(); while (lit != it->second.end()) { (*lit)->event(channel, event); @@ -241,7 +241,7 @@ void Event::unbind(EventListener *listener, Channel channel) void Event::remove(EventListener *listener) { - ListenMap::iterator it = mBindings.begin(); + auto it = mBindings.begin(); while (it != mBindings.end()) { it->second.erase(listener); diff --git a/src/event.h b/src/event.h index b785b16f..d20f172f 100644 --- a/src/event.h +++ b/src/event.h @@ -37,9 +37,9 @@ enum BadEvent { class EventListener; -typedef std::set<EventListener *> ListenerSet; +using ListenerSet = std::set<EventListener *>; class VariableData; -typedef std::map<std::string, VariableData *> VariableMap; +using VariableMap = std::map<std::string, VariableData *>; class Event { @@ -315,7 +315,7 @@ protected: static void remove(EventListener *listener); private: - typedef std::map<Channel, ListenerSet > ListenMap; + using ListenMap = std::map<Channel, ListenerSet>; static ListenMap mBindings; Type mType; diff --git a/src/flooritem.h b/src/flooritem.h index b4feecb5..8326982f 100644 --- a/src/flooritem.h +++ b/src/flooritem.h @@ -45,7 +45,7 @@ class FloorItem : public ActorSprite const Vector &position, Map *map); - Type getType() const { return FLOOR_ITEM; } + Type getType() const override { return FLOOR_ITEM; } /** * Returns the item ID. @@ -59,10 +59,10 @@ class FloorItem : public ActorSprite */ const ItemInfo &getInfo() const; - virtual int getTileX() const + int getTileX() const override { return mX; } - virtual int getTileY() const + int getTileY() const override { return mY; } private: diff --git a/src/game.cpp b/src/game.cpp index c934ed69..49f33db0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -88,11 +88,11 @@ #include <sstream> #include <string> -Joystick *joystick = NULL; +Joystick *joystick = nullptr; -OkDialog *weightNotice = NULL; -OkDialog *deathNotice = NULL; -QuitDialog *quitDialog = NULL; +OkDialog *weightNotice = nullptr; +OkDialog *deathNotice = nullptr; +QuitDialog *quitDialog = nullptr; ChatWindow *chatWindow; StatusWindow *statusWindow; @@ -110,14 +110,14 @@ OutfitWindow *outfitWindow; SpecialsWindow *specialsWindow; SocialWindow *socialWindow; -ActorSpriteManager *actorSpriteManager = NULL; -ChannelManager *channelManager = NULL; -CommandHandler *commandHandler = NULL; -Particle *particleEngine = NULL; -EffectManager *effectManager = NULL; -Viewport *viewport = NULL; /**< Viewport on the map. */ +ActorSpriteManager *actorSpriteManager = nullptr; +ChannelManager *channelManager = nullptr; +CommandHandler *commandHandler = nullptr; +Particle *particleEngine = nullptr; +EffectManager *effectManager = nullptr; +Viewport *viewport = nullptr; /**< Viewport on the map. */ -ChatTab *localChatTab = NULL; +ChatTab *localChatTab = nullptr; /** * Initialize every game sub-engines in the right order @@ -131,7 +131,7 @@ static void initEngines() channelManager = new ChannelManager; effectManager = new EffectManager; - particleEngine = new Particle(NULL); + particleEngine = new Particle(nullptr); particleEngine->setupEngine(); Event::trigger(Event::GameChannel, Event::EnginesInitialized); @@ -203,12 +203,12 @@ static void destroyGuiWindows() Event::trigger(Event::GameChannel, Event::GuiWindowsUnloaded); } -Game *Game::mInstance = 0; +Game *Game::mInstance = nullptr; Game::Game(): mLastTarget(ActorSprite::UNKNOWN), mDisconnected(false), - mCurrentMap(0) + mCurrentMap(nullptr) { assert(!mInstance); mInstance = this; @@ -217,7 +217,7 @@ Game::Game(): viewport = new Viewport; viewport->setSize(graphics->getWidth(), graphics->getHeight()); - gcn::Container *top = static_cast<gcn::Container*>(gui->getTop()); + auto *top = static_cast<gcn::Container*>(gui->getTop()); top->add(viewport); viewport->requestMoveToBottom(); @@ -260,7 +260,7 @@ Game::~Game() del_0(viewport) del_0(mCurrentMap) - mInstance = 0; + mInstance = nullptr; Event::trigger(Event::GameChannel, Event::Destructed); } @@ -347,7 +347,7 @@ void Game::logic() if (mCurrentMap) mCurrentMap->update(); - cur_time = time(NULL); + cur_time = time(nullptr); // Handle network stuff if (!Net::getGameHandler()->isConnected() && !mDisconnected) @@ -404,7 +404,7 @@ void Game::handleInput() // Keyboard events (for discontinuous keys) else if (event.type == SDL_KEYDOWN) { - gcn::Window *requestedWindow = NULL; + gcn::Window *requestedWindow = nullptr; if (setupWindow->isVisible() && keyboard.getNewKeyIndex() > keyboard.KEY_NO_VALUE) @@ -456,9 +456,9 @@ void Game::handleInput() helpWindow->setVisible(false); // Close the config window, cancelling changes if opened else if (setupWindow->isVisible()) - setupWindow->action(gcn::ActionEvent(NULL, "cancel")); + setupWindow->action(gcn::ActionEvent(nullptr, "cancel")); else if (dialog) - dialog->action(gcn::ActionEvent(NULL, "ok")); + dialog->action(gcn::ActionEvent(nullptr, "ok")); } if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) { @@ -914,7 +914,7 @@ void Game::changeMap(const std::string &mapPath) // Unset the map of the player so that its particles are cleared before // being deleted in the next step if (local_player) - local_player->setMap(0); + local_player->setMap(nullptr); particleEngine->clear(); diff --git a/src/graphics.cpp b/src/graphics.cpp index b4c65b0a..b3f3050e 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -310,7 +310,7 @@ SDL_Surface *Graphics::getScreenshot() SDL_Surface *screenshot = SDL_CreateRGBSurface(0, mWidth, mHeight, 24, rmask, gmask, bmask, amask); - SDL_RenderReadPixels(mRenderer, NULL, SDL_PIXELFORMAT_RGB888, screenshot->pixels, screenshot->pitch); + SDL_RenderReadPixels(mRenderer, nullptr, SDL_PIXELFORMAT_RGB888, screenshot->pixels, screenshot->pitch); return screenshot; } @@ -332,7 +332,7 @@ void Graphics::updateSDLClipRect() { if (mClipStack.empty()) { - SDL_RenderSetClipRect(mRenderer, NULL); + SDL_RenderSetClipRect(mRenderer, nullptr); return; } diff --git a/src/graphics.h b/src/graphics.h index 813d4200..6239bd23 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -77,7 +77,7 @@ class Graphics : public gcn::Graphics public: Graphics() = default; - virtual ~Graphics(); + ~Graphics() override; /** * Sets the target SDL_Window to draw to. This funtion also pushes a @@ -214,32 +214,32 @@ class Graphics : public gcn::Graphics gcn::Font *getFont() const { return mFont; } - virtual bool pushClipArea(gcn::Rectangle area); + bool pushClipArea(gcn::Rectangle area) override; - virtual void popClipArea(); + void popClipArea() override; - virtual void drawImage(const gcn::Image *image, + void drawImage(const gcn::Image *image, int srcX, int srcY, int dstX, int dstY, int width, - int height) {} // not used + int height) override {} // not used - virtual void drawPoint(int x, int y); + void drawPoint(int x, int y) override; - virtual void drawLine(int x1, int y1, int x2, int y2); + void drawLine(int x1, int y1, int x2, int y2) override; - virtual void drawRectangle(const gcn::Rectangle &rectangle); + void drawRectangle(const gcn::Rectangle &rectangle) override; - virtual void fillRectangle(const gcn::Rectangle &rectangle); + void fillRectangle(const gcn::Rectangle &rectangle) override; - virtual void setColor(const gcn::Color &color) + void setColor(const gcn::Color &color) override { mColor = color; } - virtual const gcn::Color &getColor() const + const gcn::Color &getColor() const override { return mColor; } diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h index 7022ebbe..45169464 100644 --- a/src/gui/beingpopup.h +++ b/src/gui/beingpopup.h @@ -34,7 +34,7 @@ class BeingPopup : public Popup public: BeingPopup(); - ~BeingPopup(); + ~BeingPopup() override; /** * Sets the info to be displayed given a particular player. diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index e1f99f5a..56c3c261 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -295,8 +295,8 @@ void BuyDialog::setVisible(bool visible) void BuyDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h index 7dd00019..b1126225 100644 --- a/src/gui/buydialog.h +++ b/src/gui/buydialog.h @@ -44,7 +44,7 @@ class BuyDialog : public Window, public gcn::ActionListener, public: BuyDialog(int npcId); - ~BuyDialog(); + ~BuyDialog() override; /** * Resets the dialog, clearing shop inventory. @@ -64,7 +64,7 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Returns the number of items in the shop inventory. @@ -74,12 +74,12 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Updates the labels according to the selected item. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Allows for quick-buying by extending double-click events. */ - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; /** * Returns the name of item number i in the shop inventory. @@ -94,7 +94,7 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Sets the visibility of this window. */ - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Closes all instances. @@ -102,7 +102,7 @@ class BuyDialog : public Window, public gcn::ActionListener, static void closeAll(); private: - typedef std::list<BuyDialog*> DialogList; + using DialogList = std::list<BuyDialog *>; static DialogList instances; int mNpcId; diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index e22607f0..be49ba58 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -37,20 +37,20 @@ BuySellDialog::DialogList BuySellDialog::instances; BuySellDialog::BuySellDialog(int npcId): Window(_("Shop")), mNpcId(npcId), - mBuyButton(0) + mBuyButton(nullptr) { setWindowName("BuySell"); //setupWindow->registerWindowForReset(this); setCloseButton(true); static const char *buttonNames[] = { - N_("Buy"), N_("Sell"), N_("Cancel"), 0 + N_("Buy"), N_("Sell"), N_("Cancel"), nullptr }; int x = 10, y = 10; for (const char **curBtn = buttonNames; *curBtn; curBtn++) { - Button *btn = new Button(gettext(*curBtn), *curBtn, this); + auto *btn = new Button(gettext(*curBtn), *curBtn, this); if (!mBuyButton) mBuyButton = btn; // For focus request btn->setPosition(x, y); @@ -109,8 +109,8 @@ void BuySellDialog::action(const gcn::ActionEvent &event) void BuySellDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/buyselldialog.h b/src/gui/buyselldialog.h index f296126e..2e324d42 100644 --- a/src/gui/buyselldialog.h +++ b/src/gui/buyselldialog.h @@ -42,14 +42,14 @@ class BuySellDialog : public Window, public gcn::ActionListener */ BuySellDialog(int npcId); - ~BuySellDialog(); + ~BuySellDialog() override; - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Closes all instances. @@ -57,7 +57,7 @@ class BuySellDialog : public Window, public gcn::ActionListener static void closeAll(); private: - typedef std::list<BuySellDialog*> DialogList; + using DialogList = std::list<BuySellDialog *>; static DialogList instances; int mNpcId; diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index c42cecc3..ce83087b 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -153,7 +153,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + auto *dlg = new OkDialog(_("Error"), errorMessage.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index 7715db8c..37d3ce01 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -40,12 +40,12 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener public: ChangeEmailDialog(LoginData *loginData); - ~ChangeEmailDialog(); + ~ChangeEmailDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * This is used to pass the pointer to where the new email should be diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 6b668496..437a8c90 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -146,7 +146,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mSecondPassField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + auto *dlg = new OkDialog(_("Error"), errorMessage.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 308a6970..22d449d1 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -40,12 +40,12 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener public: ChangePasswordDialog(LoginData *loginData); - ~ChangePasswordDialog(); + ~ChangePasswordDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::TextField *mOldPassField; diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 26383d48..8cec4279 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -54,7 +54,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mCharSelectDialog(parent), mSlot(slot) { - mPlayer = new Being(0, ActorSprite::PLAYER, 0, NULL); + mPlayer = new Being(0, ActorSprite::PLAYER, 0, nullptr); mPlayer->setGender(GENDER_MALE); const std::vector<int> &items = CharDB::getDefaultItems(); @@ -160,7 +160,7 @@ CharCreateDialog::~CharCreateDialog() delete mPlayer; // Make sure the char server handler knows that we're gone - Net::getCharHandler()->setCharCreateDialog(0); + Net::getCharHandler()->setCharCreateDialog(nullptr); } void CharCreateDialog::action(const gcn::ActionEvent &event) @@ -330,18 +330,18 @@ void CharCreateDialog::setAttributes(const std::vector<std::string> &labels, { const int y = 140 + i * 20; - Label *attributeLabel = new Label(labels[i]); + auto *attributeLabel = new Label(labels[i]); attributeLabel->setWidth(70); attributeLabel->setPosition(5, y); add(attributeLabel); - Slider *attributeSlider = new Slider(min, max); + auto *attributeSlider = new Slider(min, max); attributeSlider->setDimension(gcn::Rectangle(75, y, 100, 10)); attributeSlider->setActionEventId("statslider"); attributeSlider->addActionListener(this); add(attributeSlider); - Label *attributeValue = new Label(toString(min)); + auto *attributeValue = new Label(toString(min)); attributeValue->setPosition(180, y); add(attributeValue); diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index 9f49f6c5..89706b54 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -48,9 +48,9 @@ class CharCreateDialog : public Window, public gcn::ActionListener public: CharCreateDialog(CharSelectDialog *parent, int slot); - ~CharCreateDialog(); + ~CharCreateDialog() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Unlocks the dialog, enabling the create character button again. diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index dff648ec..e4d5f371 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -74,7 +74,7 @@ class CharDeleteConfirm : public ConfirmDialog { } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "yes") mMaster->attemptCharacterDelete(mIndex); @@ -97,7 +97,7 @@ class CharacterDisplay : public Container Net::Character *getCharacter() const { return mCharacter; } - void requestFocus(); + void requestFocus() override; void setActive(bool active); @@ -117,8 +117,8 @@ class CharacterDisplay : public Container CharSelectDialog::CharSelectDialog(LoginData *loginData): Window(_("Account and Character Management")), mLocked(false), - mUnregisterButton(0), - mChangeEmailButton(0), + mUnregisterButton(nullptr), + mChangeEmailButton(nullptr), mCharacterEntries(0), mLoginData(loginData), mCharHandler(Net::getCharHandler()) @@ -203,7 +203,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) && !mCharacterEntries[selected]->getCharacter()) { // Start new character dialog - CharCreateDialog *charCreateDialog = + auto *charCreateDialog = new CharCreateDialog(this, selected); mCharHandler->setCharCreateDialog(charCreateDialog); } @@ -273,7 +273,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) std::vector<CharacterDisplay*>::iterator iter, iter_end; for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); iter != iter_end; ++iter) - (*iter)->setCharacter(0); + (*iter)->setCharacter(nullptr); Net::Characters::const_iterator i, i_end = characters.end(); for (i = characters.begin(); i != i_end; ++i) @@ -347,7 +347,7 @@ bool CharSelectDialog::selectByName(const std::string &name, CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): - mCharacter(0), + mCharacter(nullptr), mPlayerBox(new PlayerBox) { mButton = new Button("", "go", charSelectDialog); @@ -376,7 +376,7 @@ void CharacterDisplay::setCharacter(Net::Character *character) return; mCharacter = character; - mPlayerBox->setPlayer(character ? character->dummy : 0); + mPlayerBox->setPlayer(character ? character->dummy : nullptr); update(); } diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index a0307b00..d30e4e68 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -52,11 +52,11 @@ class CharSelectDialog : public Window, public gcn::ActionListener, CharSelectDialog(LoginData *loginData); - ~CharSelectDialog(); + ~CharSelectDialog() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; enum SelectAction { Focus, diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index cc09d19e..1ae2fcbd 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -71,7 +71,7 @@ class ChatInput : public TextField, public gcn::FocusListener * Called if the chat input loses focus. It will set itself to * invisible as result. */ - void focusLost(const gcn::Event &event) + void focusLost(const gcn::Event &event) override { setVisible(false); } @@ -79,9 +79,9 @@ class ChatInput : public TextField, public gcn::FocusListener class ChatAutoComplete : public AutoCompleteLister { - void getAutoCompleteList(std::vector<std::string> &list) const + void getAutoCompleteList(std::vector<std::string> &list) const override { - ChatTab *tab = static_cast<ChatTab*>(chatWindow->mChatTabs + auto *tab = static_cast<ChatTab*>(chatWindow->mChatTabs ->getSelectedTab()); return tab->getAutoCompleteList(list); @@ -278,7 +278,7 @@ void ChatWindow::removeAllWhispers() tabs.push_back(iter->second); } - for (std::list<ChatTab*>::iterator it = tabs.begin(); + for (auto it = tabs.begin(); it != tabs.end(); ++it) { delete *it; @@ -299,7 +299,7 @@ void ChatWindow::doPresent() std::string response = ""; int playercount = 0; - for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); + for (auto it = actors.begin(), it_end = actors.end(); it != it_end; it++) { if ((*it)->getType() == ActorSprite::PLAYER) @@ -471,7 +471,7 @@ void ChatWindow::whisper(const std::string &nick, if (tempNick.compare(playerName) == 0) return; - ChatTab *tab = 0; + ChatTab *tab = nullptr; TabMap::const_iterator i = mWhispers.find(tempNick); if (i != mWhispers.end()) @@ -521,7 +521,7 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo) if (mWhispers.find(tempNick) != mWhispers.end() || tempNick.compare(playerName) == 0) - return NULL; + return nullptr; ChatTab *ret = new WhisperTab(nick); mWhispers[tempNick] = ret; diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 77c42cc0..b3072d4a 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -85,13 +85,13 @@ class ChatWindow : public Window, /** * Destructor: used to write back values to the config file */ - ~ChatWindow(); + ~ChatWindow() override; /** * Reset the chat window and recorder window attached to it to their * default positions. */ - void resetToDefaultSize(); + void resetToDefaultSize() override; /** * Gets the focused tab. @@ -121,7 +121,7 @@ class ChatWindow : public Window, /** * Performs action. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Request focus for typing chat message. @@ -150,12 +150,12 @@ class ChatWindow : public Window, void addItemText(const std::string &item); /** Override to reset mTmpVisible */ - void setVisible(bool visible); + void setVisible(bool visible) override; - void mousePressed(gcn::MouseEvent &event); - void mouseDragged(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseDragged(gcn::MouseEvent &event) override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; /** * Scrolls the chat window @@ -214,7 +214,7 @@ class ChatWindow : public Window, /** Tabbed area for holding each channel. */ TabbedArea *mChatTabs; - typedef std::map<const std::string, ChatTab*> TabMap; + using TabMap = std::map<const std::string, ChatTab *>; /** Manage whisper tabs */ TabMap mWhispers; diff --git a/src/gui/confirmdialog.h b/src/gui/confirmdialog.h index af769a42..8eb3f46b 100644 --- a/src/gui/confirmdialog.h +++ b/src/gui/confirmdialog.h @@ -37,12 +37,12 @@ class ConfirmDialog : public Window, public gcn::ActionListener { public: ConfirmDialog(const std::string &title, const std::string &msg, - Window *parent = NULL); + Window *parent = nullptr); /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: TextBox *mTextBox; diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp index 237269c8..963005cf 100644 --- a/src/gui/connectiondialog.cpp +++ b/src/gui/connectiondialog.cpp @@ -39,9 +39,9 @@ ConnectionDialog::ConnectionDialog(const std::string &text, setMovable(false); setMinWidth(0); - ProgressIndicator *progressIndicator = new ProgressIndicator; + auto *progressIndicator = new ProgressIndicator; gcn::Label *label = new Label(text); - Button *cancelButton = new Button(_("Cancel"), "cancelButton", this); + auto *cancelButton = new Button(_("Cancel"), "cancelButton", this); place(0, 0, progressIndicator); place(0, 1, label); diff --git a/src/gui/connectiondialog.h b/src/gui/connectiondialog.h index 129fe5c6..e76a0a3e 100644 --- a/src/gui/connectiondialog.h +++ b/src/gui/connectiondialog.h @@ -50,9 +50,9 @@ class ConnectionDialog : public Window, gcn::ActionListener * Called when the user presses Cancel. Restores the global state to * the previous one. */ - void action(const gcn::ActionEvent &); + void action(const gcn::ActionEvent &) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: gcn::Label *mLabel; diff --git a/src/gui/customserverdialog.cpp b/src/gui/customserverdialog.cpp index e0d25928..733a6b5c 100644 --- a/src/gui/customserverdialog.cpp +++ b/src/gui/customserverdialog.cpp @@ -53,13 +53,13 @@ CustomServerDialog::CustomServerDialog(ServerDialog *parent, int index): { setWindowName("CustomServerDialog"); - Label *nameLabel = new Label(_("Name:")); - Label *serverAdressLabel = new Label(_("Address:")); - Label *portLabel = new Label(_("Port:")); + auto *nameLabel = new Label(_("Name:")); + auto *serverAdressLabel = new Label(_("Address:")); + auto *portLabel = new Label(_("Port:")); #ifdef MANASERV_SUPPORT - Label *typeLabel = new Label(_("Server type:")); + auto *typeLabel = new Label(_("Server type:")); #endif - Label *descriptionLabel = new Label(_("Description:")); + auto *descriptionLabel = new Label(_("Description:")); mServerAddressField = new TextField(std::string()); mPortField = new TextField(std::string()); @@ -163,7 +163,7 @@ void CustomServerDialog::action(const gcn::ActionEvent &event) // Check the given information if (mServerAddressField->getText().empty()) { - OkDialog *dlg = new OkDialog(_("Error"), + auto *dlg = new OkDialog(_("Error"), _("Please type in at least the address of the server.")); dlg->addActionListener(this); } @@ -220,6 +220,6 @@ void CustomServerDialog::keyPressed(gcn::KeyEvent &keyEvent) } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mOkButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId())); } } diff --git a/src/gui/customserverdialog.h b/src/gui/customserverdialog.h index 19812875..59c1d2cc 100644 --- a/src/gui/customserverdialog.h +++ b/src/gui/customserverdialog.h @@ -48,12 +48,12 @@ class TypeListModel : public gcn::ListModel /** * Used to get number of line in the list */ - int getNumberOfElements() { return 2; } + int getNumberOfElements() override { return 2; } /** * Used to get an element from the list */ - std::string getElementAt(int elementIndex); + std::string getElementAt(int elementIndex) override; }; /** @@ -68,16 +68,16 @@ class CustomServerDialog : public Window, public: CustomServerDialog(ServerDialog *parent, int index = -1); - ~CustomServerDialog(); + ~CustomServerDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; - void logic(); + void logic() override; private: TextField *mServerAddressField; diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 37c68673..43d84f61 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -79,7 +79,7 @@ public: h.reflowLayout(0, 0); } - void logic() + void logic() override { if (!isVisible()) return; @@ -130,7 +130,7 @@ class DebugSwitches : public Container, public gcn::ActionListener public: DebugSwitches() { - Label *showLabel = new Label(_("Show:")); + auto *showLabel = new Label(_("Show:")); mGrid = new CheckBox(_("Grid")); mCollisionTiles = new CheckBox(_("Collision tiles")); mBeingCollisionRadius = new CheckBox(_("Being collision radius")); @@ -139,7 +139,7 @@ public: mMousePath = new CheckBox(_("Mouse path")); mBeingIds = new CheckBox(_("Being Ids")); - Label *specialsLabel = new Label(_("Specials:")); + auto *specialsLabel = new Label(_("Specials:")); mSpecialNormal = new RadioButton(_("Normal"), "mapdebug"); mSpecial1 = new RadioButton(_("Special 1"), "mapdebug"); mSpecial2 = new RadioButton(_("Special 2"), "mapdebug"); @@ -179,7 +179,7 @@ public: mSpecial3->addActionListener(this); } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { int flags = 0; @@ -233,7 +233,7 @@ DebugWindow::DebugWindow() setMinHeight(100); setDefaultSize(0, 120, 300, 190); - TabbedArea *tabs = new TabbedArea; + auto *tabs = new TabbedArea; place(0, 0, tabs, 2, 2); loadWindowState(); diff --git a/src/gui/emotepopup.h b/src/gui/emotepopup.h index 9a7b3f3e..cb1c7b89 100644 --- a/src/gui/emotepopup.h +++ b/src/gui/emotepopup.h @@ -50,15 +50,15 @@ class EmotePopup : public Popup */ EmotePopup(); - virtual ~EmotePopup(); + ~EmotePopup() override; /** * Draws the emotes. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void mousePressed(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; /** * Returns the selected emote. @@ -113,7 +113,7 @@ class EmotePopup : public Popup int mRowCount; int mColumnCount; - typedef std::list<gcn::SelectionListener*> Listeners; + using Listeners = std::list<gcn::SelectionListener *>; Listeners mListeners; diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 85a4c766..d646b78c 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -52,7 +52,7 @@ static const int BOX_HEIGHT = 36; EquipmentWindow::EquipmentWindow(Equipment *equipment): Window(_("Equipment")), - mEquipBox(0), + mEquipBox(nullptr), mSelected(-1), mEquipment(equipment), mBoxesNumber(0) @@ -61,7 +61,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): setupWindow->registerWindowForReset(this); // Control that shows the Player - PlayerBox *playerBox = new PlayerBox; + auto *playerBox = new PlayerBox; playerBox->setDimension(gcn::Rectangle(50, 80, 74, 123)); playerBox->setPlayer(local_player); @@ -122,7 +122,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) Window::drawChildren(graphics); // Draw equipment boxes - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); for (int i = 0; i < mBoxesNumber; i++) { @@ -194,7 +194,7 @@ Item *EquipmentWindow::getItem(int x, int y) const if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); } - return 0; + return nullptr; } std::string EquipmentWindow::getSlotName(int x, int y) const @@ -216,7 +216,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) const int x = mouseEvent.getX(); const int y = mouseEvent.getY(); - Item *item = 0; + Item *item = nullptr; // Checks if any of the presses were in the equip boxes. for (int i = 0; i < mBoxesNumber; ++i) diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 29814dc5..1bfc5f00 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -43,16 +43,16 @@ class EquipmentWindow : public Window, public gcn::ActionListener public: EquipmentWindow(Equipment *equipment); - ~EquipmentWindow(); + ~EquipmentWindow() override; /** * Draws the equipment window. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; /** * Loads the correct amount of displayed equip boxes. @@ -74,7 +74,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener EquipBox() : posX(0), posY(0), - backgroundImage(0) + backgroundImage(nullptr) {} int posX; @@ -89,8 +89,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener int mBoxesNumber; /**< Number of equipment boxes to display */ private: - void mouseExited(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; Item *getItem(int x, int y) const; std::string getSlotName(int x, int y) const; diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index ba6c834b..bef00125 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -31,7 +31,7 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget) if (mModalFocusedWidget && mModalFocusedWidget != widget) { mModalStack.push_front(mModalFocusedWidget); - mModalFocusedWidget = NULL; + mModalFocusedWidget = nullptr; } gcn::FocusHandler::requestModalFocus(widget); @@ -85,7 +85,7 @@ void FocusHandler::checkForWindow() while (widget) { - Window *window = dynamic_cast<Window*>(widget); + auto *window = dynamic_cast<Window*>(widget); if (window) { diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index debfefe8..eb59bcf3 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -39,27 +39,27 @@ class FocusHandler : public gcn::FocusHandler * then that widget loses modal focus and will regain it after this * widget releases his modal focus. */ - void requestModalFocus(gcn::Widget *widget); + void requestModalFocus(gcn::Widget *widget) override; /** * Releases modal focus of a widget. When this widget had modal focus * and there are other widgets that had also requested modal focus, * then modal focus will be transfered to the last of those. */ - void releaseModalFocus(gcn::Widget *widget); + void releaseModalFocus(gcn::Widget *widget) override; /** * Removes a widget from the focus handler. Also makes sure no dangling * pointers remain in modal focus stack. */ - void remove(gcn::Widget *widget); + void remove(gcn::Widget *widget) override; /** * Overloaded to allow windows to move to the top when one of their * widgets is tabbed to when tabbing through focusable elements. */ - void tabNext(); - void tabPrevious(); + void tabNext() override; + void tabPrevious() override; private: /** diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 64509e21..e0487d95 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -45,14 +45,14 @@ #include <guichan/image.hpp> // Guichan stuff -Gui *gui = 0; -SDLInput *guiInput = 0; +Gui *gui = nullptr; +SDLInput *guiInput = nullptr; // Bolded font -gcn::Font *boldFont = 0; +gcn::Font *boldFont = nullptr; // Mono font -gcn::Font *monoFont = 0; +gcn::Font *monoFont = nullptr; class GuiConfigListener : public EventListener { @@ -61,7 +61,7 @@ class GuiConfigListener : public EventListener mGui(g) {} - void event(Event::Channel channel, const Event &event) + void event(Event::Channel channel, const Event &event) override { if (channel == Event::ConfigChannel) { @@ -79,7 +79,7 @@ class GuiConfigListener : public EventListener Gui::Gui(Graphics *graphics): mCustomCursor(false), - mMouseCursors(NULL), + mMouseCursors(nullptr), mMouseCursorAlpha(1.0f), mMouseInactivityTimer(0), mCursorType(CURSOR_POINTER) @@ -97,7 +97,7 @@ Gui::Gui(Graphics *graphics): mFocusHandler = new FocusHandler; // Initialize top GUI widget - WindowContainer *guiTop = new WindowContainer; + auto *guiTop = new WindowContainer; guiTop->setFocusable(true); guiTop->setSize(graphics->getWidth(), graphics->getHeight()); guiTop->setOpaque(false); @@ -225,7 +225,7 @@ void Gui::draw() void Gui::videoResized() { - WindowContainer *top = static_cast<WindowContainer*>(getTop()); + auto *top = static_cast<WindowContainer*>(getTop()); int oldWidth = top->getWidth(); int oldHeight = top->getHeight(); @@ -260,7 +260,7 @@ void Gui::setUseCustomCursor(bool customCursor) if (mMouseCursors) { mMouseCursors->decRef(); - mMouseCursors = NULL; + mMouseCursors = nullptr; } } } diff --git a/src/gui/gui.h b/src/gui/gui.h index 998b6ec8..c70ed9ad 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -50,19 +50,19 @@ class Gui : public gcn::Gui public: Gui(Graphics *screen); - ~Gui(); + ~Gui() override; /** * Performs logic of the GUI. Overridden to track mouse pointer * activity. */ - void logic(); + void logic() override; /** * Draws the whole Gui by calling draw functions down in the * Gui hierarchy. It also draws the mouse pointer. */ - void draw(); + void draw() override; /** * Called when the application window has been resized. @@ -114,7 +114,7 @@ class Gui : public gcn::Gui }; protected: - void handleMouseMoved(const gcn::MouseInput &mouseInput); + void handleMouseMoved(const gcn::MouseInput &mouseInput) override; void handleTextInput(const TextInput &textInput); private: diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index e4ded03a..077f3091 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -49,7 +49,7 @@ HelpWindow::HelpWindow(): mBrowserBox = new BrowserBox; mBrowserBox->setOpaque(false); mScrollArea = new ScrollArea(mBrowserBox); - Button *okButton = new Button(_("Close"), "close", this); + auto *okButton = new Button(_("Close"), "close", this); mScrollArea->setDimension(gcn::Rectangle(5, 5, 445, 335 - okButton->getHeight())); diff --git a/src/gui/helpwindow.h b/src/gui/helpwindow.h index 0295db7d..30fa450e 100644 --- a/src/gui/helpwindow.h +++ b/src/gui/helpwindow.h @@ -42,12 +42,12 @@ class HelpWindow : public Window, public LinkHandler, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Handles link action. */ - void handleLink(const std::string &link); + void handleLink(const std::string &link) override; /** * Loads help in the dialog. diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index c6b93723..e5f6b00c 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -452,8 +452,8 @@ bool InventoryWindow::isInputFocused() const bool InventoryWindow::isAnyInputFocused() { - WindowList::iterator it = instances.begin(); - WindowList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 39876e53..389312b3 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -54,12 +54,12 @@ class InventoryWindow : public Window, public: InventoryWindow(Inventory *inventory); - ~InventoryWindow(); + ~InventoryWindow() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Returns the selected item. @@ -69,27 +69,27 @@ class InventoryWindow : public Window, /** * Handles closing of the window */ - virtual void widgetHidden(const gcn::Event &event); + void widgetHidden(const gcn::Event &event) override; /** * Handles the mouse clicks. */ - void mouseClicked(gcn::MouseEvent &event); + void mouseClicked(gcn::MouseEvent &event) override; /** * Handles the key presses. */ - void keyPressed(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event) override; /** * Handles the key releases. */ - void keyReleased(gcn::KeyEvent &event); + void keyReleased(gcn::KeyEvent &event) override; /** * Updates labels to currently selected item. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Sets whether the split button should be shown. @@ -100,7 +100,7 @@ class InventoryWindow : public Window, * Closes the Storage Window, as well as telling the server that the * window has been closed. */ - void close(); + void close() override; /** * Updates the buttons. @@ -111,11 +111,11 @@ class InventoryWindow : public Window, static bool isAnyInputFocused(); - void slotsChanged(Inventory* inventory); + void slotsChanged(Inventory* inventory) override; bool isMainInventory() { return mInventory->isMainInventory(); } - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; private: /** @@ -124,7 +124,7 @@ class InventoryWindow : public Window, void updateWeight(); - typedef std::list<InventoryWindow*> WindowList; + using WindowList = std::list<InventoryWindow *>; static WindowList instances; Inventory *mInventory; diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index a2c2ca55..285936a5 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -108,11 +108,11 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, mItemIcon = new Icon(image); // Buttons - Button *minusButton = new Button(_("-"), "dec", this); - Button *plusButton = new Button(_("+"), "inc", this); - Button *okButton = new Button(_("OK"), "ok", this); - Button *cancelButton = new Button(_("Cancel"), "cancel", this); - Button *addAllButton = new Button(_("All"), "all", this); + auto *minusButton = new Button(_("-"), "dec", this); + auto *plusButton = new Button(_("+"), "inc", this); + auto *okButton = new Button(_("OK"), "ok", this); + auto *cancelButton = new Button(_("Cancel"), "cancel", this); + auto *addAllButton = new Button(_("All"), "all", this); minusButton->adjustSize(); minusButton->setWidth(plusButton->getWidth()); diff --git a/src/gui/itemamountwindow.h b/src/gui/itemamountwindow.h index cf18d72a..d0ac52d5 100644 --- a/src/gui/itemamountwindow.h +++ b/src/gui/itemamountwindow.h @@ -53,7 +53,7 @@ class ItemAmountWindow : public Window, /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Sets default amount value. @@ -61,15 +61,15 @@ class ItemAmountWindow : public Window, void resetAmount(); // MouseListener - void mouseMoved(gcn::MouseEvent &event); - void mouseExited(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; + void mouseExited(gcn::MouseEvent &event) override; /** * Schedules the Item Amount window for deletion. */ - void close(); + void close() override; - void keyReleased(gcn::KeyEvent &keyEvent); + void keyReleased(gcn::KeyEvent &keyEvent) override; /** * Creates the dialog, or bypass it if there aren't enough items. @@ -77,7 +77,7 @@ class ItemAmountWindow : public Window, static void showWindow(Usage usage, Window *parent, Item *item, int maxRange = 0); - ~ItemAmountWindow(); + ~ItemAmountWindow() override; private: static void finish(Item *item, int amount, Usage usage); diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index c09a0504..f096e5ca 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -83,7 +83,7 @@ static gcn::Color getColorFromItemType(ItemType type) ItemPopup::ItemPopup(): Popup("ItemPopup"), - mIcon(0) + mIcon(nullptr) { // Item Name mItemName = new Label; @@ -102,7 +102,7 @@ ItemPopup::ItemPopup(): mItemWeight = new TextBox; mItemWeight->setEditable(false); - mIcon = new Icon(0); + mIcon = new Icon(nullptr); add(mItemName); add(mItemDesc); @@ -130,7 +130,7 @@ void ItemPopup::setEquipmentText(const std::string& text) void ItemPopup::setNoItem() { - mIcon->setImage(0); + mIcon->setImage(nullptr); std::string caption = _("No item"); if (!mItemEquipSlot.empty()) @@ -180,7 +180,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) } else { - mIcon->setImage(0); + mIcon->setImage(nullptr); } mItemType = item.getItemType(); @@ -198,7 +198,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) { const std::vector<std::string> &effect = item.getEffect(); std::string temp = ""; - for (std::vector<std::string>::const_iterator it = effect.begin(), + for (auto it = effect.begin(), it_end = effect.end(); it != it_end; ++it) temp += temp.empty() ? *it : "\n" + *it; mItemEffect->setTextWrapped(temp, ITEMPOPUP_WRAP_WIDTH); diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index ca1b4179..3b213633 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -46,7 +46,7 @@ class ItemPopup : public Popup /** * Destructor. Cleans up the item popup on deletion. */ - ~ItemPopup(); + ~ItemPopup() override; /** * Tells the item popup to say: No Item. @@ -63,7 +63,7 @@ class ItemPopup : public Popup */ void setItem(const ItemInfo &item, bool showImage = false); - void mouseMoved(gcn::MouseEvent &mouseEvent); + void mouseMoved(gcn::MouseEvent &mouseEvent) override; private: gcn::Label *mItemName; diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 5c73c27f..4d065d65 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -138,11 +138,11 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) { - action(gcn::ActionEvent(NULL, mServerButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId())); } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mLoginButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId())); } else { diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index 87281b00..5761f4a6 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -44,17 +44,17 @@ class LoginDialog : public Window, public gcn::ActionListener, public: LoginDialog(LoginData *loginData); - ~LoginDialog(); + ~LoginDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; private: /** diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 59e385c4..1682b972 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -43,8 +43,8 @@ bool Minimap::mShow = true; Minimap::Minimap(): Window(_("Map")), - mMap(0), - mMapImage(0), + mMap(nullptr), + mMapImage(nullptr), mWidthProportion(0.5), mHeightProportion(0.5) { @@ -92,7 +92,7 @@ void Minimap::setMap(Map *map) if (mMapImage) { mMapImage->decRef(); - mMapImage = 0; + mMapImage = nullptr; } if (map) @@ -192,7 +192,7 @@ void Minimap::draw(gcn::Graphics *graphics) const ActorSprites &actors = actorSpriteManager->getAll(); - for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); + for (auto it = actors.begin(), it_end = actors.end(); it != it_end; it++) { if ((*it)->getType() == ActorSprite::FLOOR_ITEM) diff --git a/src/gui/minimap.h b/src/gui/minimap.h index e44753e3..3a122230 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -40,7 +40,7 @@ class Minimap : public Window { public: Minimap(); - ~Minimap(); + ~Minimap() override; /** * Sets the map image that should be displayed. @@ -55,7 +55,7 @@ class Minimap : public Window /** * Draws the minimap. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: Map *mMap; diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index a4fd358f..3cd97a6d 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -64,7 +64,7 @@ MiniStatusWindow::MiniStatusWindow(): StatusWindow::updateMPBar(mMpBar); } else - mMpBar = 0; + mMpBar = nullptr; mXpBar = new ProgressBar(0, 100, 20, Theme::PROG_EXP); StatusWindow::updateXPBar(mXpBar); diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index b4392b6f..db9e4c69 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -45,15 +45,15 @@ class MiniStatusWindow : public Popup, public EventListener void drawIcons(Graphics *graphics); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; - void logic(); // Updates icons + void logic() override; // Updates icons - void draw(gcn::Graphics *graphics) + void draw(gcn::Graphics *graphics) override { drawChildren(graphics); } - void mouseMoved(gcn::MouseEvent &mouseEvent); - void mouseExited(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &mouseEvent) override; + void mouseExited(gcn::MouseEvent &event) override; private: bool isInBar(ProgressBar *bar, int x, int y) const; diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 74d8a4aa..8b348480 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -51,12 +51,12 @@ #define CAPTION_CLOSE _("Close") #define CAPTION_SUBMIT _("Submit") -typedef std::map<int, NpcDialog*> NpcDialogs; +using NpcDialogs = std::map<int, NpcDialog *>; class NpcEventListener : public EventListener { public: - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; NpcDialog *getDialog(int id, bool make = true); @@ -66,7 +66,7 @@ private: NpcDialogs mNpcDialogs; }; -static NpcEventListener *npcListener = NULL; +static NpcEventListener *npcListener = nullptr; NpcDialog::DialogList NpcDialog::instances; @@ -333,8 +333,8 @@ bool NpcDialog::isInputFocused() const bool NpcDialog::isAnyInputFocused() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { @@ -425,8 +425,8 @@ NpcDialog *NpcDialog::getActive() if (instances.size() == 1) return instances.front(); - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { @@ -436,13 +436,13 @@ NpcDialog *NpcDialog::getActive() } } - return 0; + return nullptr; } void NpcDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { @@ -623,8 +623,8 @@ void NpcEventListener::event(Event::Channel channel, NpcDialog *NpcEventListener::getDialog(int id, bool make) { - NpcDialogs::iterator diag = mNpcDialogs.find(id); - NpcDialog *dialog = 0; + auto diag = mNpcDialogs.find(id); + NpcDialog *dialog = nullptr; if (diag == mNpcDialogs.end()) { @@ -645,7 +645,7 @@ NpcDialog *NpcEventListener::getDialog(int id, bool make) void NpcEventListener::removeDialog(int id) { - NpcDialogs::iterator it = mNpcDialogs.find(id); + auto it = mNpcDialogs.find(id); if (it != mNpcDialogs.end()) mNpcDialogs.erase(it); } diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 9c6839b0..49ec5f8a 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -52,12 +52,12 @@ class NpcDialog : public Window, public: NpcDialog(int npcId); - ~NpcDialog(); + ~NpcDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Sets the text shows in the dialog. @@ -94,17 +94,17 @@ class NpcDialog : public Window, * Notifies the server that the client has performed a close action. * @overrides Window::close() */ - void close(); + void close() override; /** * Returns the number of items in the choices list. */ - int getNumberOfElements(); + int getNumberOfElements() override; /** * Returns the name of item number i of the choices list. */ - std::string getElementAt(int i); + std::string getElementAt(int i) override; /** * Makes this dialog request a choice selection from the user. @@ -144,13 +144,13 @@ class NpcDialog : public Window, * * @param event The calling event */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; - void setVisible(bool visible); + void setVisible(bool visible) override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; /** * Returns the first active instance. Useful for pushing user @@ -169,7 +169,7 @@ class NpcDialog : public Window, static void setup(); private: - typedef std::list<NpcDialog*> DialogList; + using DialogList = std::list<NpcDialog *>; static DialogList instances; void buildLayout(); diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 6f673f5c..3567472a 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -51,10 +51,10 @@ NpcPostDialog::NpcPostDialog(int npcId): mSender->setWidth(65); // create button for sending - Button *sendButton = new Button(_("Send"), "send", this); + auto *sendButton = new Button(_("Send"), "send", this); sendButton->setPosition(400 - sendButton->getWidth(), 170 - sendButton->getHeight()); - Button *cancelButton = new Button(_("Cancel"), "cancel", this); + auto *cancelButton = new Button(_("Cancel"), "cancel", this); cancelButton->setPosition(sendButton->getX() - (cancelButton->getWidth() + 2), sendButton->getY()); @@ -64,7 +64,7 @@ NpcPostDialog::NpcPostDialog(int npcId): mText->setEditable(true); // create scroll box for letter text - ScrollArea *scrollArea = new ScrollArea(mText); + auto *scrollArea = new ScrollArea(mText); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle( 5, mSender->getHeight() + 5, @@ -124,8 +124,8 @@ void NpcPostDialog::setVisible(bool visible) void NpcPostDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/npcpostdialog.h b/src/gui/npcpostdialog.h index cda44a66..61c17ca6 100644 --- a/src/gui/npcpostdialog.h +++ b/src/gui/npcpostdialog.h @@ -34,14 +34,14 @@ class NpcPostDialog : public Window, public gcn::ActionListener public: NpcPostDialog(int npcId); - ~NpcPostDialog(); + ~NpcPostDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Closes all instances. @@ -49,7 +49,7 @@ public: static void closeAll(); private: - typedef std::list<NpcPostDialog*> DialogList; + using DialogList = std::list<NpcPostDialog *>; static DialogList instances; int mNpcId; diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index 72f923b7..fcb327a9 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -37,12 +37,12 @@ class OkDialog : public Window, public gcn::ActionListener { public: OkDialog(const std::string &title, const std::string &msg, - bool modal = true, Window *parent = NULL); + bool modal = true, Window *parent = nullptr); /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: TextBox *mTextBox; diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index d9730441..cd6c7d3d 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -54,7 +54,7 @@ OutfitWindow::OutfitWindow(): mGridWidth(3), mGridHeight(3), mItemClicked(false), - mItemMoved(NULL), + mItemMoved(nullptr), mItemSelected(-1), mCurrentOutfit(0) { @@ -188,7 +188,7 @@ void OutfitWindow::copyOutfit(int outfit) void OutfitWindow::draw(gcn::Graphics *graphics) { Window::draw(graphics); - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); for (int i = 0; i < OUTFIT_ITEM_COUNT; i++) { @@ -295,13 +295,13 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event) const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - mItemMoved = NULL; + mItemMoved = nullptr; return; } if (mItemMoved) { mItems[mCurrentOutfit][index] = mItemMoved->getId(); - mItemMoved = NULL; + mItemMoved = nullptr; } if (mItemClicked) mItemClicked = false; diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 65b22235..c5e24b9b 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -39,17 +39,17 @@ class OutfitWindow : public Window, gcn::ActionListener public: OutfitWindow(); - ~OutfitWindow(); + ~OutfitWindow() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; void load(); diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index db51db4b..23ba75ee 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -77,8 +77,8 @@ const gcn::Color& Palette::getColor(char c, bool &valid) void Palette::advanceGradients() { - Palettes::iterator it = mInstances.begin(); - Palettes::iterator it_end = mInstances.end(); + auto it = mInstances.begin(); + auto it_end = mInstances.end(); for (; it != it_end; it++) { diff --git a/src/gui/palette.h b/src/gui/palette.h index a6347a5b..1ea7c467 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -124,7 +124,7 @@ class Palette /** Time tick, that gradient-type colors were updated the last time. */ int mRainbowTime; - typedef std::set<Palette*> Palettes; + using Palettes = std::set<Palette *>; static Palettes mInstances; Palette(int size); @@ -163,7 +163,7 @@ class Palette committedColor.b; } }; - typedef std::vector<ColorElem> Colors; + using Colors = std::vector<ColorElem>; /** Vector containing the colors. */ Colors mColors; std::vector<ColorElem*> mGradVector; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 41b62bad..d63fe2f3 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -57,8 +57,8 @@ std::string tradePartnerName; PopupMenu::PopupMenu(): Popup("PopupMenu"), mBeingId(0), - mFloorItem(NULL), - mItem(NULL) + mFloorItem(nullptr), + mItem(nullptr) { mBrowserBox = new BrowserBox; mBrowserBox->setPosition(4, 4); @@ -348,8 +348,8 @@ void PopupMenu::handleLink(const std::string &link) setVisible(false); mBeingId = 0; - mFloorItem = NULL; - mItem = NULL; + mFloorItem = nullptr; + mItem = nullptr; } void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index d1526da2..c5be561d 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -60,7 +60,7 @@ class PopupMenu : public Popup, public LinkHandler /** * Handles link action. */ - void handleLink(const std::string &link); + void handleLink(const std::string &link) override; private: BrowserBox* mBrowserBox; diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 21c9fdc1..4262f9cc 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -37,7 +37,7 @@ #include <assert.h> QuitDialog::QuitDialog(QuitDialog** pointerToMe): - Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) + Window(_("Quit"), true, nullptr), mMyPointer(pointerToMe) { mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); @@ -90,7 +90,7 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): QuitDialog::~QuitDialog() { - if (mMyPointer) *mMyPointer = NULL; + if (mMyPointer) *mMyPointer = nullptr; // Optional widgets, so delete them by hand. delete mForceQuit; delete mLogoutQuit; @@ -138,10 +138,10 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) switch (key.getValue()) { case Key::ENTER: - action(gcn::ActionEvent(NULL, mOkButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId())); break; case Key::ESCAPE: - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); break; case Key::UP: dir = -1; @@ -153,7 +153,7 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) if (dir != 0) { - std::vector<gcn::RadioButton*>::iterator it = mOptions.begin(); + auto it = mOptions.begin(); for (; it < mOptions.end(); it++) { diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index f3852642..d62d5c51 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -47,14 +47,14 @@ class QuitDialog : public Window, public gcn::ActionListener, */ QuitDialog(QuitDialog **pointerToMe); - ~QuitDialog(); + ~QuitDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; private: void placeOption(ContainerPlacer &place, gcn::RadioButton *option); diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index 8c71c63a..a7a9b25a 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -42,7 +42,7 @@ Recorder::Recorder(ChatWindow *chat, const std::string &title, const int offsetY = getTitleBarHeight() + getPadding() + 10; mChat = chat; - Button *button = new Button(buttonTxt, "activate", this); + auto *button = new Button(buttonTxt, "activate", this); // 123 is the default chat window height. If you change this in Chat, please // change it here as well diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 79a2b60e..efd73021 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -39,7 +39,7 @@ class Recorder : public Window, public gcn::ActionListener Recorder(ChatWindow *chat, const std::string &title = _("Recording..."), const std::string &buttonTxt = _("Stop recording")); - virtual ~Recorder(); + ~Recorder() override; /** * Outputs the message to the recorder file @@ -65,7 +65,7 @@ class Recorder : public Window, public gcn::ActionListener * * @param event is the event that is generated */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: ChatWindow *mChat; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index c220ab0c..e394e59b 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -56,9 +56,9 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) RegisterDialog::RegisterDialog(LoginData *loginData): Window(_("Register")), - mEmailField(0), - mMaleButton(0), - mFemaleButton(0), + mEmailField(nullptr), + mMaleButton(nullptr), + mFemaleButton(nullptr), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { @@ -215,7 +215,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage); + auto *dlg = new OkDialog(_("Error"), errorMessage); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/register.h b/src/gui/register.h index dbab8e62..a8f875cb 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -41,7 +41,7 @@ class WrongDataNoticeListener : public gcn::ActionListener { public: void setTarget(gcn::TextField *textField); - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::TextField *mTarget; }; @@ -63,17 +63,17 @@ class RegisterDialog : public Window, public gcn::ActionListener, */ RegisterDialog(LoginData *loginData); - ~RegisterDialog(); + ~RegisterDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; private: /** diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 41ee349a..76a4b3ac 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -316,8 +316,8 @@ void SellDialog::setVisible(bool visible) void SellDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/selldialog.h b/src/gui/selldialog.h index c94e7250..7e37d860 100644 --- a/src/gui/selldialog.h +++ b/src/gui/selldialog.h @@ -41,7 +41,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener public: SellDialog(int npcId); - virtual ~SellDialog(); + ~SellDialog() override; /** * Resets the dialog, clearing inventory. @@ -56,19 +56,19 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Updates labels according to selected item. * * @see SelectionListener::selectionChanged */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Allows for quick-selling by extending double-click events. */ - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; /** * Gives Player's Money amount @@ -78,7 +78,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener /** * Sets the visibility of this window. */ - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Closes all instances. @@ -86,7 +86,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener static void closeAll(); private: - typedef std::list<SellDialog*> DialogList; + using DialogList = std::list<SellDialog *>; static DialogList instances; /** diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 3ea978e1..f0016322 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -112,12 +112,12 @@ public: { } - void draw(gcn::Graphics *graphics) + void draw(gcn::Graphics *graphics) override { if (!mListModel) return; - ServersListModel *model = static_cast<ServersListModel*>(mListModel); + auto *model = static_cast<ServersListModel*>(mListModel); updateAlpha(); @@ -165,7 +165,7 @@ public: } } - unsigned int getRowHeight() const + unsigned int getRowHeight() const override { return 2 * getFont()->getHeight(); } @@ -188,7 +188,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mServersList = new ServersListBox(mServersListModel); - ScrollArea *usedScroll = new ScrollArea(mServersList); + auto *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mDescription = new Label(std::string()); @@ -252,7 +252,7 @@ ServerDialog::~ServerDialog() { mDownload->cancel(); delete mDownload; - mDownload = 0; + mDownload = nullptr; } delete mServersListModel; } @@ -275,7 +275,7 @@ void ServerDialog::action(const gcn::ActionEvent &event) #endif ) { - OkDialog *dlg = new OkDialog(_("Error"), + auto *dlg = new OkDialog(_("Error"), _("Please select a valid server.")); dlg->addActionListener(this); } @@ -319,7 +319,7 @@ void ServerDialog::action(const gcn::ActionEvent &event) // Check whether a server is selected. if (index < 0) { - OkDialog *dlg = new OkDialog(_("Error"), + auto *dlg = new OkDialog(_("Error"), _("Please select a custom server.")); dlg->addActionListener(this); } @@ -348,7 +348,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mConnectButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mConnectButton->getActionEventId())); } } @@ -523,7 +523,7 @@ void ServerDialog::loadServers() // Add the server to the local list if it's not already present bool found = false; int i = 0; - for (ServerInfos::iterator it = mServers.begin(); it != mServers.end(); + for (auto it = mServers.begin(); it != mServers.end(); ++it) { if (*it == server) @@ -641,7 +641,7 @@ int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status, if (status == DOWNLOAD_STATUS_CANCELLED) return -1; - ServerDialog *sd = reinterpret_cast<ServerDialog*>(ptr); + auto *sd = reinterpret_cast<ServerDialog*>(ptr); bool finished = false; if (status == DOWNLOAD_STATUS_COMPLETE) diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index cf9e62e7..d0ef0e55 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -50,19 +50,19 @@ class DropDown; class ServersListModel : public gcn::ListModel { public: - typedef std::pair<int, std::string> VersionString; + using VersionString = std::pair<int, std::string>; ServersListModel(ServerInfos *servers, ServerDialog *parent); /** * Used to get number of line in the list */ - int getNumberOfElements(); + int getNumberOfElements() override; /** * Used to get an element from the list */ - std::string getElementAt(int elementIndex); + std::string getElementAt(int elementIndex) override; /** * Used to get the corresponding Server struct @@ -73,7 +73,7 @@ class ServersListModel : public gcn::ListModel void setVersionString(int index, const std::string &version); private: - typedef std::vector<VersionString> VersionStrings; + using VersionStrings = std::vector<VersionString>; ServerInfos *mServers; VersionStrings mVersionStrings; @@ -93,23 +93,23 @@ class ServerDialog : public Window, public: ServerDialog(ServerInfo *serverInfo, const std::string &dir); - ~ServerDialog(); + ~ServerDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; /** * Called when the selected value changed in the servers list box. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; - void logic(); + void logic() override; protected: friend class ServersListModel; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 930408ac..daced0fa 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -51,12 +51,12 @@ Setup::Setup(): setContentSize(width, height); static const char *buttonNames[] = { - N_("Apply"), N_("Cancel"), N_("Reset Windows"), 0 + N_("Apply"), N_("Cancel"), N_("Reset Windows"), nullptr }; int x = width; for (const char **curBtn = buttonNames; *curBtn; ++curBtn) { - Button *btn = new Button(gettext(*curBtn), *curBtn, this); + auto *btn = new Button(gettext(*curBtn), *curBtn, this); x -= btn->getWidth() + 5; btn->setPosition(x, height - btn->getHeight() - 5); add(btn); @@ -66,7 +66,7 @@ Setup::Setup(): mResetWindows = btn; } - TabbedArea *panel = new TabbedArea; + auto *panel = new TabbedArea; panel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40)); mTabs.push_back(new Setup_Video); @@ -77,7 +77,7 @@ Setup::Setup(): mTabs.push_back(new Setup_Colors); mTabs.push_back(new Setup_Players); - for (std::list<SetupTab*>::iterator i = mTabs.begin(), i_end = mTabs.end(); + for (auto i = mTabs.begin(), i_end = mTabs.end(); i != i_end; ++i) { SetupTab *tab = *i; @@ -86,7 +86,7 @@ Setup::Setup(): add(panel); - Label *version = new Label(FULL_VERSION); + auto *version = new Label(FULL_VERSION); version->setPosition(9, height - version->getHeight() - 9); add(version); @@ -119,7 +119,7 @@ void Setup::action(const gcn::ActionEvent &event) if (!statusWindow) return; - for (std::list<Window*>::iterator it = mWindowsToReset.begin(); + for (auto it = mWindowsToReset.begin(); it != mWindowsToReset.end(); it++) { (*it)->resetToDefaultSize(); diff --git a/src/gui/setup.h b/src/gui/setup.h index c2f1ac04..d510267d 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -48,12 +48,12 @@ class Setup : public Window, public gcn::ActionListener { public: Setup(); - ~Setup(); + ~Setup() override; /** * Event handling method. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Enables the reset button when in game. diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index ac81bdb7..4ee277ef 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -33,10 +33,10 @@ class Setup_Audio : public SetupTab, public gcn::ActionListener public: Setup_Audio(); - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: int mMusicVolume; diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index cf234eb3..bf86a93b 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -63,7 +63,7 @@ Setup_Colors::Setup_Colors() : mPreview->setOpaque(false); // don't do anything with links - mPreview->setLinkHandler(NULL); + mPreview->setLinkHandler(nullptr); mPreviewBox = new ScrollArea(mPreview); mPreviewBox->setHeight(20); @@ -234,7 +234,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event) mPreviewBox->setContent(mTextPreview); mTextPreview->setFont(boldFont); mTextPreview->setTextColor(col); - mTextPreview->setTextBGColor(NULL); + mTextPreview->setTextBGColor(nullptr); mTextPreview->setOpaque(false); mTextPreview->setShadow(true); mTextPreview->setOutline(true); @@ -348,7 +348,7 @@ void Setup_Colors::updateColor() return; int type = userPalette->getColorTypeAt(mSelected); - Palette::GradientType grad = static_cast<Palette::GradientType>((int) + auto grad = static_cast<Palette::GradientType>((int) mGradTypeSlider->getValue()); int delay = (int) mGradDelaySlider->getValue(); userPalette->setGradient(type, grad); diff --git a/src/gui/setup_colors.h b/src/gui/setup_colors.h index e9144c73..b534ca8a 100644 --- a/src/gui/setup_colors.h +++ b/src/gui/setup_colors.h @@ -41,14 +41,14 @@ class Setup_Colors : public SetupTab, { public: Setup_Colors(); - ~Setup_Colors(); + ~Setup_Colors() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; private: static const std::string rawmsg; diff --git a/src/gui/setup_interface.cpp b/src/gui/setup_interface.cpp index b35a30fe..619a250c 100644 --- a/src/gui/setup_interface.cpp +++ b/src/gui/setup_interface.cpp @@ -65,14 +65,14 @@ const char *SIZE_NAME[4] = class FontSizeChoiceListModel : public gcn::ListModel { public: - virtual ~FontSizeChoiceListModel() { } + ~FontSizeChoiceListModel() override { } - virtual int getNumberOfElements() + int getNumberOfElements() override { return 4; } - virtual std::string getElementAt(int i) + std::string getElementAt(int i) override { if (i >= getNumberOfElements()) return _("???"); @@ -120,7 +120,7 @@ Setup_Interface::Setup_Interface(): setName(_("Interface")); // Create widgets - Spacer *space = new Spacer(0,10); + auto *space = new Spacer(0,10); mShowMonsterDamageCheckBox = new CheckBox(_("Show damage"), mShowMonsterDamageEnabled); @@ -260,7 +260,7 @@ void Setup_Interface::action(const gcn::ActionEvent &event) } else if (id == "speech") { - Being::Speech val = (Being::Speech)mSpeechSlider->getValue(); + auto val = (Being::Speech)mSpeechSlider->getValue(); mSpeechLabel->setCaption(speechModeToString(val)); mSpeechSlider->setValue(val); config.setValue("speech", val); diff --git a/src/gui/setup_interface.h b/src/gui/setup_interface.h index 2b1de5b7..530d575a 100644 --- a/src/gui/setup_interface.h +++ b/src/gui/setup_interface.h @@ -37,12 +37,12 @@ class Setup_Interface : public SetupTab, public gcn::ActionListener, { public: Setup_Interface(); - ~Setup_Interface(); + ~Setup_Interface() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: bool mShowMonsterDamageEnabled; diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h index 2329ab4d..e51ccbe8 100644 --- a/src/gui/setup_joystick.h +++ b/src/gui/setup_joystick.h @@ -33,10 +33,10 @@ class Setup_Joystick : public SetupTab, public gcn::ActionListener public: Setup_Joystick(); - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::Label *mCalibrateLabel; diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index b66ba3aa..0ac64447 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -51,12 +51,12 @@ class KeyListModel : public gcn::ListModel /** * Returns the number of elements in container. */ - int getNumberOfElements() { return keyboard.KEY_TOTAL; } + int getNumberOfElements() override { return keyboard.KEY_TOTAL; } /** * Returns element from container. */ - std::string getElementAt(int i) { return mKeyFunctions[i]; } + std::string getElementAt(int i) override { return mKeyFunctions[i]; } /** * Sets element from container. @@ -83,7 +83,7 @@ Setup_Keyboard::Setup_Keyboard(): mKeyList->addActionListener(this); mKeyList->setFont(monoFont); - ScrollArea *scrollArea = new ScrollArea(mKeyList); + auto *scrollArea = new ScrollArea(mKeyList); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mAssignKeyButton = new Button(_("Assign"), "assign", this); diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h index 14eee5b9..1ecb5ea3 100644 --- a/src/gui/setup_keyboard.h +++ b/src/gui/setup_keyboard.h @@ -36,12 +36,12 @@ class Setup_Keyboard : public SetupTab, public gcn::ActionListener public: Setup_Keyboard(); - ~Setup_Keyboard(); + ~Setup_Keyboard() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Get an update on the assigned key. diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index ad50baad..a3b0ef53 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -70,14 +70,14 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = class PlayerRelationListModel : public gcn::ListModel { public: - virtual ~PlayerRelationListModel() { } + ~PlayerRelationListModel() override { } - virtual int getNumberOfElements() + int getNumberOfElements() override { return PlayerRelation::RELATIONS_NR; } - virtual std::string getElementAt(int i) + std::string getElementAt(int i) override { if (i >= getNumberOfElements() || i < 0) return ""; @@ -89,35 +89,35 @@ class PlayerTableModel : public TableModel { public: PlayerTableModel() : - mPlayers(NULL), + mPlayers(nullptr), mListModel(new PlayerRelationListModel) { playerRelationsUpdated(); } - virtual ~PlayerTableModel() + ~PlayerTableModel() override { freeWidgets(); delete mListModel; delete mPlayers; } - virtual int getRows() const + int getRows() const override { return mPlayers->size(); } - virtual int getColumns() const + int getColumns() const override { return COLUMNS_NR; } - virtual int getRowHeight() const + int getRowHeight() const override { return ROW_HEIGHT; } - virtual int getColumnWidth(int index) const + int getColumnWidth(int index) const override { if (index == NAME_COLUMN) return NAME_COLUMN_WIDTH; @@ -151,7 +151,7 @@ public: virtual void updateModelInRow(int row) { - gcn::DropDown *choicebox = static_cast<gcn::DropDown *>( + auto *choicebox = static_cast<gcn::DropDown *>( getElementAt(row, RELATION_CHOICE_COLUMN)); player_relations.setRelation(getPlayerAt(row), static_cast<PlayerRelation::Relation>( @@ -159,7 +159,7 @@ public: } - virtual gcn::Widget *getElementAt(int row, int column) const + gcn::Widget *getElementAt(int row, int column) const override { return mWidgets[WIDGET_AT(row, column)]; } @@ -168,7 +168,7 @@ public: { if (mPlayers) delete mPlayers; - mPlayers = NULL; + mPlayers = nullptr; delete_all(mWidgets); mWidgets.clear(); @@ -191,14 +191,14 @@ protected: class IgnoreChoicesListModel : public gcn::ListModel { public: - virtual ~IgnoreChoicesListModel() { } + ~IgnoreChoicesListModel() override { } - virtual int getNumberOfElements() + int getNumberOfElements() override { return player_relations.getPlayerIgnoreStrategies()->size(); } - virtual std::string getElementAt(int i) + std::string getElementAt(int i) override { if (i >= getNumberOfElements()) return _("???"); diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index ed2361b9..90663029 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -39,16 +39,16 @@ class Setup_Players : public SetupTab, { public: Setup_Players(); - virtual ~Setup_Players(); + ~Setup_Players() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; void reset(); - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - virtual void updatedPlayer(const std::string &name); + void updatedPlayer(const std::string &name) override; private: StaticTableModel *mPlayerTableTitleModel; diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 709a7685..2d4835ec 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -61,17 +61,17 @@ class ModeListModel : public gcn::ListModel public: ModeListModel(); - virtual ~ModeListModel() { } + ~ModeListModel() override { } /** * Returns the number of elements in container. */ - int getNumberOfElements() { return mVideoModes.size(); } + int getNumberOfElements() override { return mVideoModes.size(); } /** * Returns element from container. */ - std::string getElementAt(int i) { return mVideoModes[i]; } + std::string getElementAt(int i) override { return mVideoModes[i]; } /** * Returns the index corresponding to the given video mode. @@ -173,9 +173,9 @@ Setup_Video::Setup_Video(): { setName(_("Video")); - Spacer *space = new Spacer(0,10); + auto *space = new Spacer(0,10); - ScrollArea *scrollArea = new ScrollArea(mModeList); + auto *scrollArea = new ScrollArea(mModeList); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setSize(100, 200); diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 7002a936..1352aa53 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -37,12 +37,12 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, { public: Setup_Video(); - ~Setup_Video(); + ~Setup_Video() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; static const char *overlayDetailToString(int detail = -1); diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index f33ddf50..6fdafcb8 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -37,7 +37,7 @@ class ShortcutWindow : public Window public: ShortcutWindow(const std::string &title, ShortcutContainer *content); - ~ShortcutWindow(); + ~ShortcutWindow() override; private: ShortcutWindow(); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index a0c3e46b..09bde167 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -77,7 +77,7 @@ struct SkillInfo gcn::Color color; SkillInfo() : - icon(NULL) + icon(nullptr) {} ~SkillInfo() @@ -106,18 +106,18 @@ struct SkillInfo void draw(Graphics *graphics, int y, int width); }; -typedef std::vector<SkillInfo*> SkillList; +using SkillList = std::vector<SkillInfo *>; class SkillModel : public gcn::ListModel { public: - int getNumberOfElements() + int getNumberOfElements() override { return mVisibleSkills.size(); } SkillInfo *getSkillAt(int i) const { return mVisibleSkills.at(i); } - std::string getElementAt(int i) + std::string getElementAt(int i) override { return getSkillAt(i)->name; } void updateVisibilities(); @@ -141,21 +141,21 @@ public: { const int selected = getSelected(); if (selected < 0 || selected > mListModel->getNumberOfElements()) - return 0; + return nullptr; return static_cast<SkillModel*>(mListModel)->getSkillAt(selected); } - void draw(gcn::Graphics *gcnGraphics) + void draw(gcn::Graphics *gcnGraphics) override { if (!mListModel) return; - SkillModel* model = static_cast<SkillModel*>(mListModel); + auto* model = static_cast<SkillModel*>(mListModel); updateAlpha(); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, (int) (mAlpha * 255.0f))); @@ -183,7 +183,7 @@ public: } } - unsigned int getRowHeight() const { return 34; } + unsigned int getRowHeight() const override { return 34; } }; class SkillTab : public Tab @@ -195,10 +195,10 @@ public: setCaption(name); } - ~SkillTab() + ~SkillTab() override { delete mListBox; - mListBox = 0; + mListBox = nullptr; } SkillInfo *getSelectedInfo() @@ -245,7 +245,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "inc") { - SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab()); + auto *tab = static_cast<SkillTab*>(mTabs->getSelectedTab()); if (SkillInfo *info = tab->getSelectedInfo()) Net::getPlayerHandler()->increaseSkill(info->id); } @@ -257,7 +257,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) std::string SkillDialog::update(int id) { - SkillMap::iterator i = mSkills.find(id); + auto i = mSkills.find(id); if (i != mSkills.end()) { @@ -275,7 +275,7 @@ void SkillDialog::update() PlayerInfo::getAttribute(SKILL_POINTS))); mPointsLabel->adjustSize(); - for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); it++) + for (auto it = mSkills.begin(); it != mSkills.end(); it++) { (*it).second->update(); } @@ -292,7 +292,7 @@ void SkillDialog::event(Event::Channel channel, const Event &event) } else if (event.getType() == Event::UpdateStat) { - SkillMap::iterator it = mSkills.find(event.getInt("id")); + auto it = mSkills.find(event.getInt("id")); if (it != mSkills.end()) it->second->update(); } @@ -336,8 +336,8 @@ void SkillDialog::loadSkills() if (Net::getNetworkType() == ServerInfo::TMWATHENA) { - SkillModel *model = new SkillModel(); - SkillInfo *skill = new SkillInfo; + auto *model = new SkillModel(); + auto *skill = new SkillInfo; skill->id = 1; skill->name = "basic"; skill->setIcon(""); @@ -374,7 +374,7 @@ void SkillDialog::loadSkills() setCount++; setName = XML::getProperty(set, "name", strprintf(_("Skill Set %d"), setCount)); - SkillModel *model = new SkillModel(); + auto *model = new SkillModel(); for_each_xml_child_node(node, set) { @@ -384,7 +384,7 @@ void SkillDialog::loadSkills() std::string name = XML::getProperty(node, "name", strprintf(_("Skill %d"), id)); std::string icon = XML::getProperty(node, "icon", ""); - SkillInfo *skill = new SkillInfo; + auto *skill = new SkillInfo; skill->id = id; skill->name = name; skill->setIcon(icon); @@ -417,7 +417,7 @@ void SkillDialog::loadSkills() void SkillDialog::setModifiable(int id, bool modifiable) { - SkillMap::iterator it = mSkills.find(id); + auto it = mSkills.find(id); if (it != mSkills.end()) { @@ -431,7 +431,7 @@ void SkillModel::updateVisibilities() { mVisibleSkills.clear(); - for (SkillList::iterator it = mSkills.begin(); it != mSkills.end(); it++) + for (auto it = mSkills.begin(); it != mSkills.end(); it++) { if ((*it)->visible) { diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 8487c1ae..ebf29ff8 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -47,14 +47,14 @@ class SkillDialog : public Window, public gcn::ActionListener, public EventListe public: SkillDialog(); - ~SkillDialog(); + ~SkillDialog() override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Update the given skill's display @@ -75,7 +75,7 @@ class SkillDialog : public Window, public gcn::ActionListener, public EventListe bool hasSkills() { return !mSkills.empty(); } private: - typedef std::map<int, SkillInfo*> SkillMap; + using SkillMap = std::map<int, SkillInfo *>; SkillMap mSkills; TabbedArea *mTabs; Label *mPointsLabel; diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 437f9d01..d58d12ad 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -54,25 +54,25 @@ protected: friend class SocialWindow; SocialTab(): - mInviteDialog(NULL), - mConfirmDialog(NULL) + mInviteDialog(nullptr), + mConfirmDialog(nullptr) {} - virtual ~SocialTab() + ~SocialTab() override { // Cleanup dialogs if (mInviteDialog) { mInviteDialog->close(); mInviteDialog->scheduleDelete(); - mInviteDialog = NULL; + mInviteDialog = nullptr; } if (mConfirmDialog) { mConfirmDialog->close(); mConfirmDialog->scheduleDelete(); - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } @@ -103,15 +103,15 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); } - ~GuildTab() + ~GuildTab() override { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "do invite") { @@ -124,27 +124,27 @@ public: name.c_str(), mGuild->getName().c_str())) } - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "~do invite") { - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "yes") { Net::getGuildHandler()->leave(mGuild->getId()); SERVER_NOTICE(strprintf(_("Guild %s quit requested."), mGuild->getName().c_str())) - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } else if (event.getId() == "no") { - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } protected: - void invite() + void invite() override { // TODO - Give feedback on whether the invite succeeded mInviteDialog = new TextDialog(_("Member Invite to Guild"), @@ -155,7 +155,7 @@ protected: mInviteDialog->addActionListener(this); } - void leave() + void leave() override { mConfirmDialog = new ConfirmDialog(_("Leave Guild?"), strprintf(_("Are you sure you want to leave guild %s?"), @@ -186,15 +186,15 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); } - ~PartyTab() + ~PartyTab() override { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "do invite") { @@ -203,27 +203,27 @@ public: if (!name.empty()) SERVER_NOTICE(strprintf(_("Invited user %s to party."), name.c_str())) - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "~do invite") { - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "yes") { Net::getPartyHandler()->leave(); SERVER_NOTICE(strprintf(_("Party %s quit requested."), mParty->getName().c_str())) - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } else if (event.getId() == "no") { - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } protected: - void invite() + void invite() override { // TODO - Give feedback on whether the invite succeeded mInviteDialog = new TextDialog(_("Member Invite to Party"), @@ -234,7 +234,7 @@ protected: mInviteDialog->addActionListener(this); } - void leave() + void leave() override { mConfirmDialog = new ConfirmDialog(_("Leave Party?"), strprintf(_("Are you sure you want to leave party %s?"), @@ -277,7 +277,7 @@ public: mBrowserBox->getHeight() + 8); } - void handleLink(const std::string &link) + void handleLink(const std::string &link) override { if (link == "guild") { @@ -308,8 +308,8 @@ private: SocialWindow::SocialWindow() : Window(_("Social")), mGuildInvited(0), - mGuildAcceptDialog(NULL), - mPartyAcceptDialog(NULL) + mGuildAcceptDialog(nullptr), + mPartyAcceptDialog(nullptr) { setWindowName("Social"); setVisible(false); @@ -334,7 +334,7 @@ SocialWindow::SocialWindow() : place(2, 0, mLeaveButton); place(0, 1, mTabs, 4, 4); - widgetResized(NULL); + widgetResized(nullptr); mCreatePopup = new CreatePopup(); @@ -353,7 +353,7 @@ SocialWindow::~SocialWindow() { mGuildAcceptDialog->close(); mGuildAcceptDialog->scheduleDelete(); - mGuildAcceptDialog = NULL; + mGuildAcceptDialog = nullptr; mGuildInvited = 0; } @@ -362,7 +362,7 @@ SocialWindow::~SocialWindow() { mPartyAcceptDialog->close(); mPartyAcceptDialog->scheduleDelete(); - mPartyAcceptDialog = NULL; + mPartyAcceptDialog = nullptr; mPartyInviter = ""; } @@ -374,7 +374,7 @@ bool SocialWindow::addTab(Guild *guild) if (mGuilds.find(guild) != mGuilds.end()) return false; - GuildTab *tab = new GuildTab(guild); + auto *tab = new GuildTab(guild); mGuilds[guild] = tab; mTabs->addTab(tab, tab->mScroll); @@ -386,7 +386,7 @@ bool SocialWindow::addTab(Guild *guild) bool SocialWindow::removeTab(Guild *guild) { - GuildMap::iterator it = mGuilds.find(guild); + auto it = mGuilds.find(guild); if (it == mGuilds.end()) return false; @@ -404,7 +404,7 @@ bool SocialWindow::addTab(Party *party) if (mParties.find(party) != mParties.end()) return false; - PartyTab *tab = new PartyTab(party); + auto *tab = new PartyTab(party); mParties[party] = tab; mTabs->addTab(tab, tab->mScroll); @@ -416,7 +416,7 @@ bool SocialWindow::addTab(Party *party) bool SocialWindow::removeTab(Party *party) { - PartyMap::iterator it = mParties.find(party); + auto it = mParties.find(party); if (it == mParties.end()) return false; @@ -450,7 +450,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) } mPartyInviter = ""; - mPartyAcceptDialog = NULL; + mPartyAcceptDialog = nullptr; } else if (event.getSource() == mGuildAcceptDialog) { @@ -467,7 +467,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) } mGuildInvited = 0; - mGuildAcceptDialog = NULL; + mGuildAcceptDialog = nullptr; } else if (event.getId() == "create") { @@ -501,11 +501,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) name.c_str())); } - mGuildCreateDialog = NULL; + mGuildCreateDialog = nullptr; } else if (event.getId() == "~create guild") { - mGuildCreateDialog = NULL; + mGuildCreateDialog = nullptr; } else if (event.getId() == "create party") { @@ -524,11 +524,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) name.c_str())); } - mPartyCreateDialog = NULL; + mPartyCreateDialog = nullptr; } else if (event.getId() == "~create party") { - mPartyCreateDialog = NULL; + mPartyCreateDialog = nullptr; } } diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index 0964c999..495d9b54 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -49,7 +49,7 @@ class SocialWindow : public Window, gcn::ActionListener public: SocialWindow(); - ~SocialWindow(); + ~SocialWindow() override; bool addTab(Guild *guild); @@ -62,7 +62,7 @@ public: /** * Handle events. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; void showGuildInvite(const std::string &guildName, const int guildId, const std::string &inviterName); @@ -87,10 +87,10 @@ protected: ConfirmDialog *mPartyAcceptDialog; TextDialog *mPartyCreateDialog; - typedef std::map<Guild*, SocialTab*> GuildMap; + using GuildMap = std::map<Guild *, SocialTab *>; GuildMap mGuilds; - typedef std::map<Party*, SocialTab*> PartyMap; + using PartyMap = std::map<Party *, SocialTab *>; PartyMap mParties; CreatePopup *mCreatePopup; diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index ac1f460b..d114d6e3 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -94,7 +94,7 @@ void SpecialsWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "use") { - SpecialEntry *disp = dynamic_cast<SpecialEntry*>(event.getSource()->getParent()); + auto *disp = dynamic_cast<SpecialEntry*>(event.getSource()->getParent()); if (disp) { @@ -127,10 +127,10 @@ void SpecialsWindow::draw(gcn::Graphics *graphics) bool foundNew = false; unsigned int found = 0; // number of entries in specialData which match mEntries - for (std::map<int, Special>::iterator it = specialData.begin(); + for (auto it = specialData.begin(); it != specialData.end(); ++it) { - std::map<int, SpecialEntry *>::iterator e = mEntries.find(it->first); + auto e = mEntries.find(it->first); if (e == mEntries.end()) { // found a new special - abort update and rebuild from scratch @@ -158,7 +158,7 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData) mEntries.clear(); int vPos = 0; //vertical position of next placed element - for (std::map<int, Special>::const_iterator it = specialData.begin(); + for (auto it = specialData.begin(); it != specialData.end(); ++it) { logger->log("Updating special GUI for %d", it->first); @@ -168,7 +168,7 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData) { info->rechargeCurrent = it->second.currentMana; info->rechargeNeeded = it->second.neededMana; - SpecialEntry* entry = new SpecialEntry(info); + auto* entry = new SpecialEntry(info); entry->setPosition(0, vPos); vPos += entry->getHeight() + 3; add(entry); @@ -184,10 +184,10 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData) SpecialEntry::SpecialEntry(SpecialInfo *info) : mInfo(info), - mIcon(NULL), - mLevelLabel(NULL), - mUse(NULL), - mRechargeBar(NULL) + mIcon(nullptr), + mLevelLabel(nullptr), + mUse(nullptr), + mRechargeBar(nullptr) { setSize(SPECIALS_WIDTH, SPECIALS_HEIGHT); diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h index 75ad3ef0..1da05c5c 100644 --- a/src/gui/specialswindow.h +++ b/src/gui/specialswindow.h @@ -38,14 +38,14 @@ class SpecialsWindow : public Window, public gcn::ActionListener public: SpecialsWindow(); - ~SpecialsWindow(); + ~SpecialsWindow() override; /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &actionEvent); + void action(const gcn::ActionEvent &actionEvent) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; bool hasSpecials() const { return !mEntries.empty(); } diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 430d47ed..eee832ec 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -54,7 +54,7 @@ class AttrDisplay : public Container DERIVED, CHANGEABLE, UNKNOWN }; - ~AttrDisplay(); + ~AttrDisplay() override; virtual std::string update(); virtual Type getType() { return UNKNOWN; } @@ -73,19 +73,19 @@ class DerDisplay : public AttrDisplay { public: DerDisplay(int id, const std::string &name); - virtual Type getType() { return DERIVED; } + Type getType() override { return DERIVED; } }; class ChangeDisplay : public AttrDisplay, gcn::ActionListener { public: ChangeDisplay(int id, const std::string &name); - std::string update(); - virtual Type getType() { return CHANGEABLE; } + std::string update() override; + Type getType() override { return CHANGEABLE; } void setPointsNeeded(int needed); private: - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; int mNeeded; @@ -284,7 +284,7 @@ void StatusWindow::event(Event::Channel channel, } else { - Attrs::iterator it = mAttrs.find(id); + auto it = mAttrs.find(id); if (it != mAttrs.end()) { it->second->update(); @@ -301,7 +301,7 @@ void StatusWindow::event(Event::Channel channel, void StatusWindow::updateAttrs() { - for (Attrs::iterator it = mAttrs.begin(); it != mAttrs.end(); it++) + for (auto it = mAttrs.begin(); it != mAttrs.end(); it++) { it->second->update(); } @@ -309,7 +309,7 @@ void StatusWindow::updateAttrs() void StatusWindow::setPointsNeeded(int id, int needed) { - Attrs::iterator it = mAttrs.find(id); + auto it = mAttrs.find(id); if (it != mAttrs.end()) { @@ -481,7 +481,7 @@ ChangeDisplay::ChangeDisplay(int id, const std::string &name): } else { - mDec = 0; + mDec = nullptr; } update(); diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index f866c56d..d1350bec 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -45,7 +45,7 @@ class StatusWindow : public Window, public EventListener public: StatusWindow(); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; void updateAttrs(); @@ -81,7 +81,7 @@ class StatusWindow : public Window, public EventListener gcn::Label *mCharacterPointsLabel; gcn::Label *mCorrectionPointsLabel; - typedef std::map<int, AttrDisplay*> Attrs; + using Attrs = std::map<int, AttrDisplay *>; Attrs mAttrs; }; diff --git a/src/gui/textdialog.h b/src/gui/textdialog.h index 51cb3eba..66ab3e53 100644 --- a/src/gui/textdialog.h +++ b/src/gui/textdialog.h @@ -37,14 +37,14 @@ class TextDialog : public Window, public gcn::ActionListener { public: TextDialog(const std::string &title, const std::string &msg, - Window *parent = NULL, bool autoCompleteEnabled = false); + Window *parent = nullptr, bool autoCompleteEnabled = false); - ~TextDialog(); + ~TextDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Get the text in the textfield diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h index 374435fb..cda8d14a 100644 --- a/src/gui/textpopup.h +++ b/src/gui/textpopup.h @@ -38,7 +38,7 @@ class TextPopup : public Popup public: TextPopup(); - ~TextPopup(); + ~TextPopup() override; /** * Sets the text to be displayed. @@ -51,7 +51,7 @@ class TextPopup : public Popup */ void show(int x, int y, const std::string &str1, const std::string &str2); - void mouseMoved(gcn::MouseEvent &mouseEvent); + void mouseMoved(gcn::MouseEvent &mouseEvent) override; private: gcn::Label *mText1; diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index ae38f023..cf237d5a 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -86,13 +86,13 @@ TradeWindow::TradeWindow(): mMyItemContainer = new ItemContainer(mMyInventory.get()); mMyItemContainer->addSelectionListener(this); - ScrollArea *myScroll = new ScrollArea(mMyItemContainer); + auto *myScroll = new ScrollArea(mMyItemContainer); myScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mPartnerItemContainer = new ItemContainer(mPartnerInventory.get()); mPartnerItemContainer->addSelectionListener(this); - ScrollArea *partnerScroll = new ScrollArea(mPartnerItemContainer); + auto *partnerScroll = new ScrollArea(mPartnerItemContainer); partnerScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mMoneyLabel = new Label(strprintf(_("You get %s"), "")); diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h index 20da4574..cf2bb70e 100644 --- a/src/gui/tradewindow.h +++ b/src/gui/tradewindow.h @@ -44,7 +44,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener public: TradeWindow(); - ~TradeWindow(); + ~TradeWindow() override; /** * Displays expected money in the trade window. @@ -90,18 +90,18 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener * Updates the labels and makes sure only one item is selected in * either my inventory or partner inventory. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Closes the Trade Window, as well as telling the server that the * window has been closed. */ - void close(); + void close() override; private: enum Status @@ -117,7 +117,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener */ void setStatus(Status s); - typedef const std::unique_ptr<Inventory> InventoryPtr; + using InventoryPtr = const std::unique_ptr<Inventory>; InventoryPtr mMyInventory; InventoryPtr mPartnerInventory; diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp index 443adaa5..76706849 100644 --- a/src/gui/truetypefont.cpp +++ b/src/gui/truetypefont.cpp @@ -37,7 +37,7 @@ class TextChunk { public: TextChunk(const std::string &text, const gcn::Color &color) : - img(NULL), text(text), color(color) + img(nullptr), text(text), color(color) { } @@ -66,7 +66,7 @@ class TextChunk if (!surface) { - img = 0; + img = nullptr; return; } @@ -80,7 +80,7 @@ class TextChunk gcn::Color color; }; -typedef std::list<TextChunk>::iterator CacheIterator; +using CacheIterator = std::list<TextChunk>::iterator; static int fontCounter; @@ -120,7 +120,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, if (text.empty()) return; - Graphics *g = dynamic_cast<Graphics *>(graphics); + auto *g = dynamic_cast<Graphics *>(graphics); if (!g) throw "Not a valid graphics object!"; @@ -137,7 +137,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, bool found = false; - for (CacheIterator i = mCache.begin(); i != mCache.end(); ++i) + for (auto i = mCache.begin(); i != mCache.end(); ++i) { if (chunk == (*i)) { @@ -166,7 +166,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, int TrueTypeFont::getWidth(const std::string &text) const { - for (CacheIterator i = mCache.begin(); i != mCache.end(); i++) + for (auto i = mCache.begin(); i != mCache.end(); i++) { if (i->text == text) { diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h index a01e2a62..d42400d8 100644 --- a/src/gui/truetypefont.h +++ b/src/gui/truetypefont.h @@ -52,11 +52,11 @@ class TrueTypeFont : public gcn::Font */ TrueTypeFont(const std::string &filename, int size, int style = 0); - ~TrueTypeFont(); + ~TrueTypeFont() override; - virtual int getWidth(const std::string &text) const; + int getWidth(const std::string &text) const override; - virtual int getHeight() const; + int getHeight() const override; /** * Returns the height of a line of text. This is not the visual height @@ -70,7 +70,7 @@ class TrueTypeFont : public gcn::Font */ void drawString(gcn::Graphics *graphics, const std::string &text, - int x, int y); + int x, int y) override; private: TTF_Font *mFont; diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 1d510760..787865ae 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -130,7 +130,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + auto *dlg = new OkDialog(_("Error"), errorMessage.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/unregisterdialog.h b/src/gui/unregisterdialog.h index 1c926082..c82d7a78 100644 --- a/src/gui/unregisterdialog.h +++ b/src/gui/unregisterdialog.h @@ -40,12 +40,12 @@ class UnRegisterDialog : public Window, public gcn::ActionListener public: UnRegisterDialog(LoginData *loginData); - ~UnRegisterDialog(); + ~UnRegisterDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::TextField *mPasswordField; diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index fe036814..1964c1bf 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -133,8 +133,8 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mDownloadComplete(true), mUserCancel(false), mDownloadedBytes(0), - mMemoryBuffer(NULL), - mDownload(NULL), + mMemoryBuffer(nullptr), + mDownload(nullptr), mUpdateIndex(0), mLoadUpdates(applyUpdates) { @@ -184,7 +184,7 @@ UpdaterWindow::~UpdaterWindow() mDownload->cancel(); delete mDownload; - mDownload = 0; + mDownload = nullptr; } free(mMemoryBuffer); } @@ -235,7 +235,7 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) { - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); Client::setState(STATE_WORLD_SELECT); } else if (key.getValue() == Key::ENTER) @@ -243,11 +243,11 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) if (mDownloadStatus == UPDATE_COMPLETE || mDownloadStatus == UPDATE_ERROR) { - action(gcn::ActionEvent(NULL, mPlayButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mPlayButton->getActionEventId())); } else { - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); } } } @@ -271,12 +271,12 @@ void UpdaterWindow::loadNews() while (line) { mBrowserBox->addRow(line); - line = strtok(NULL, "\n"); + line = strtok(nullptr, "\n"); } // Free the memory buffer now that we don't need it anymore free(mMemoryBuffer); - mMemoryBuffer = NULL; + mMemoryBuffer = nullptr; mScrollArea->setVerticalScrollAmount(0); } @@ -284,7 +284,7 @@ void UpdaterWindow::loadNews() int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status, size_t dt, size_t dn) { - UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(ptr); + auto *uw = reinterpret_cast<UpdaterWindow *>(ptr); if (status == DOWNLOAD_STATUS_COMPLETE) { @@ -320,7 +320,7 @@ int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status, size_t UpdaterWindow::memoryWrite(void *ptr, size_t size, size_t nmemb, void *stream) { - UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(stream); + auto *uw = reinterpret_cast<UpdaterWindow *>(stream); size_t totalMem = size * nmemb; uw->mMemoryBuffer = (char*) realloc(uw->mMemoryBuffer, uw->mDownloadedBytes + totalMem); diff --git a/src/gui/updaterwindow.h b/src/gui/updaterwindow.h index 95a7600e..faf7a9a5 100644 --- a/src/gui/updaterwindow.h +++ b/src/gui/updaterwindow.h @@ -71,7 +71,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener, const std::string &updatesDir, bool applyUpdates); - ~UpdaterWindow(); + ~UpdaterWindow() override; /** * Set's progress bar status @@ -94,11 +94,11 @@ class UpdaterWindow : public Window, public gcn::ActionListener, */ void loadNews(); - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; - void logic(); + void logic() override; int updateState; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index b4ad1b1d..96a1d79c 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -48,7 +48,7 @@ extern volatile int tick_time; Viewport::Viewport(): - mMap(0), + mMap(nullptr), mMouseX(0), mMouseY(0), mPixelViewX(0.0f), @@ -56,8 +56,8 @@ Viewport::Viewport(): mDebugFlags(0), mPlayerFollowMouse(false), mLocalWalkTime(-1), - mHoverBeing(0), - mHoverItem(0) + mHoverBeing(nullptr), + mHoverItem(nullptr) { setOpaque(false); addMouseListener(this); @@ -109,7 +109,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) return; } - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); // Avoid freaking out when tick_time overflows if (tick_time < lastTick) @@ -153,7 +153,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) } // manage shake effect - for (ShakeEffects::iterator i = mShakeEffects.begin(); + for (auto i = mShakeEffects.begin(); i != mShakeEffects.end(); i++) { @@ -239,13 +239,13 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) // Draw player names, speech, and emotion sprite as needed const ActorSprites &actors = actorSpriteManager->getAll(); - for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); + for (auto it = actors.begin(), it_end = actors.end(); it != it_end; it++) { if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *b = static_cast<Being*>(*it); + auto *b = static_cast<Being*>(*it); b->drawSpeech((int) mPixelViewX, (int) mPixelViewY); } @@ -256,7 +256,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) const ActorSprites &actors = actorSpriteManager->getAll(); for (it = actors.begin(), it_end = actors.end(); it != it_end; ++it) { - Being *being = dynamic_cast<Being*>(*it); + auto *being = dynamic_cast<Being*>(*it); if (!being) continue; @@ -310,8 +310,8 @@ void Viewport::_followMouse() if (mPlayerFollowMouse && button & SDL_BUTTON(1)) { // We create a mouse event and send it to mouseDragged. - const Uint8 *keys = SDL_GetKeyboardState(NULL); - gcn::MouseEvent mouseEvent(NULL, + const Uint8 *keys = SDL_GetKeyboardState(nullptr); + gcn::MouseEvent mouseEvent(nullptr, (keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]), false, false, @@ -386,7 +386,7 @@ void Viewport::_drawDebugPath(Graphics *graphics) const ActorSprites &actors = actorSpriteManager->getAll(); for (it = actors.begin(), it_end = actors.end(); it != it_end; it++) { - Being *being = dynamic_cast<Being*>(*it); + auto *being = dynamic_cast<Being*>(*it); if (!being) continue; @@ -428,7 +428,7 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path, { graphics->setColor(color); - for (Path::const_iterator i = path.begin(); i != path.end(); ++i) + for (auto i = path.begin(); i != path.end(); ++i) { int squareX = i->x - (int) mPixelViewX; int squareY = i->y - (int) mPixelViewY; @@ -648,10 +648,10 @@ void Viewport::event(Event::Channel channel, const Event &event) ActorSprite *actor = event.getActor("source"); if (mHoverBeing == actor) - mHoverBeing = 0; + mHoverBeing = nullptr; if (mHoverItem == actor) - mHoverItem = 0; + mHoverItem = nullptr; } else if (channel == Event::ConfigChannel && event.getType() == Event::ConfigOptionChanged) diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 0d0f057a..f3f82ce5 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -59,7 +59,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, public: Viewport(); - ~Viewport(); + ~Viewport() override; /** * Sets the map displayed by the viewport. @@ -69,12 +69,12 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Draws the viewport. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Implements player to keep following mouse. */ - void logic(); + void logic() override; /** * Sets whether the path debug graphics are shown @@ -84,22 +84,22 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Handles mouse press on map. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Handles mouse move on map */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Handles mouse button release on map. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; /** * Handles mouse move on map. */ - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** * Shows a popup for an item. @@ -165,7 +165,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, void shakeScreenStop() { mShakeEffects.clear(); } - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; private: /** @@ -209,7 +209,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, float decay; unsigned duration; }; - typedef std::list<ShakeEffect> ShakeEffects; + using ShakeEffects = std::list<ShakeEffect>; ShakeEffects mShakeEffects; bool mPlayerFollowMouse; diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index eac7ad13..d397ecfb 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -34,8 +34,8 @@ #include <guichan/font.hpp> int AvatarListBox::instances = 0; -Image *AvatarListBox::onlineIcon = 0; -Image *AvatarListBox::offlineIcon = 0; +Image *AvatarListBox::onlineIcon = nullptr; +Image *AvatarListBox::offlineIcon = nullptr; AvatarListBox::AvatarListBox(AvatarListModel *model): ListBox(model) @@ -67,11 +67,11 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) if (!mListModel) return; - AvatarListModel* model = static_cast<AvatarListModel*>(mListModel); + auto* model = static_cast<AvatarListModel*>(mListModel); updateAlpha(); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, (int) (mAlpha * 255.0f))); diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index ec6cc6c5..ab402329 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -36,7 +36,7 @@ class AvatarListModel : public gcn::ListModel public: virtual Avatar *getAvatarAt(int i) = 0; - std::string getElementAt(int i) + std::string getElementAt(int i) override { return getAvatarAt(i)->getName(); } }; @@ -45,14 +45,14 @@ class AvatarListBox : public ListBox public: AvatarListBox(AvatarListModel *model); - ~AvatarListBox(); + ~AvatarListBox() override; /** * Draws the list box. */ - void draw(gcn::Graphics *gcnGraphics); + void draw(gcn::Graphics *gcnGraphics) override; - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; private: static int instances; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 29847639..d5b853b2 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -86,7 +86,7 @@ void BrowserBox::addRow(const std::string &row) const int fontHeight = font->getHeight(); int lineHeight = fontHeight; - if (TrueTypeFont *ttf = dynamic_cast<TrueTypeFont*>(font)) + if (auto *ttf = dynamic_cast<TrueTypeFont*>(font)) lineHeight = ttf->getLineHeight(); // Use links and user defined colors @@ -185,7 +185,7 @@ void BrowserBox::addRow(const std::string &row) int tildeWidth = font->getWidth(tilde); int x = 0; - for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++) + for (auto i = mTextRows.begin(); i != mTextRows.end(); i++) { std::string row = *i; for (unsigned int j = 0; j < row.size(); ++j) @@ -259,7 +259,7 @@ struct MouseOverLink void BrowserBox::mousePressed(gcn::MouseEvent &event) { if (!mLinkHandler) return; - LinkIterator i = find_if(mLinks.begin(), mLinks.end(), + auto i = find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); if (i != mLinks.end()) @@ -268,7 +268,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event) void BrowserBox::mouseMoved(gcn::MouseEvent &event) { - LinkIterator i = find_if(mLinks.begin(), mLinks.end(), + auto i = find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); mSelectedLink = (i != mLinks.end()) @@ -316,7 +316,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) } } - for (LinePartIterator i = mLineParts.begin(); + for (auto i = mLineParts.begin(); i != mLineParts.end(); i ++) { @@ -377,7 +377,7 @@ int BrowserBox::calcHeight() const int tildeWidth = font->getWidth("~"); int lineHeight = fontHeight; - if (TrueTypeFont *ttf = dynamic_cast<TrueTypeFont*>(font)) + if (auto *ttf = dynamic_cast<TrueTypeFont*>(font)) lineHeight = ttf->getLineHeight(); gcn::Color selColor = Theme::getThemeColor(Theme::TEXT); @@ -385,7 +385,7 @@ int BrowserBox::calcHeight() mLineParts.clear(); - for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++) + for (auto i = mTextRows.begin(); i != mTextRows.end(); i++) { const std::string row = *(i); bool wrapped = false; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 46af14ab..5f29e72a 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -74,7 +74,7 @@ class BrowserBox : public gcn::Widget, public: BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true); - ~BrowserBox(); + ~BrowserBox() override; /** * Sets the handler for links. @@ -124,13 +124,13 @@ class BrowserBox : public gcn::Widget, /** * Handles mouse actions. */ - void mousePressed(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; /** * Draws the browser box. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; void updateHeight(); @@ -176,7 +176,7 @@ class BrowserBox : public gcn::Widget, BACKGROUND = 2 }; - typedef std::list<std::string> TextRows; + using TextRows = std::list<std::string>; TextRows &getRows() { return mTextRows; } @@ -187,15 +187,15 @@ class BrowserBox : public gcn::Widget, private: int calcHeight(); - typedef TextRows::iterator TextRowIterator; + using TextRowIterator = TextRows::iterator; TextRows mTextRows; - typedef std::list<LinePart> LinePartList; - typedef LinePartList::iterator LinePartIterator; + using LinePartList = std::list<LinePart>; + using LinePartIterator = LinePartList::iterator; LinePartList mLineParts; - typedef std::vector<BrowserLink> Links; - typedef Links::iterator LinkIterator; + using Links = std::vector<BrowserLink>; + using LinkIterator = Links::iterator; Links mLinks; LinkHandler *mLinkHandler; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 9247f67a..fb0d4cbe 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -38,7 +38,7 @@ int Button::mInstances = 0; float Button::mAlpha = 1.0; ImageRect *Button::mButton; -TextPopup *Button::mTextPopup = 0; +TextPopup *Button::mTextPopup = nullptr; enum{ BUTTON_STANDARD, // 0 @@ -63,7 +63,7 @@ static ButtonData const data[BUTTON_COUNT] = { }; Button::Button(): - mButtonIcon(0) + mButtonIcon(nullptr) { init(); adjustSize(); @@ -72,7 +72,7 @@ Button::Button(): Button::Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener): gcn::Button(caption), - mButtonIcon(0) + mButtonIcon(nullptr) { init(); setActionEventId(actionEventId); @@ -127,10 +127,10 @@ void Button::removeButtonIcon(bool adjustButtonSize) for (int mode = 0; mode < BUTTON_COUNT; ++mode) { delete mButtonIcon[mode]; - mButtonIcon[mode] = 0; + mButtonIcon[mode] = nullptr; } delete[] mButtonIcon; - mButtonIcon = 0; + mButtonIcon = nullptr; if (adjustButtonSize) adjustSize(); @@ -189,7 +189,7 @@ Button::~Button() // Remove the popup delete mTextPopup; - mTextPopup = 0; + mTextPopup = nullptr; } // Don' try to readjust the size when it's about to be deleted. removeButtonIcon(false); diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index f31c3436..e4a28d80 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -48,12 +48,12 @@ class Button : public gcn::Button Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener); - ~Button(); + ~Button() override; /** * Draws the button. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Update the alpha value to the button components. @@ -82,9 +82,9 @@ class Button : public gcn::Button void setButtonPopupText(const std::string &text) { mPopupText = text; } - void logic(); - void mouseMoved(gcn::MouseEvent &event); - void mouseExited(gcn::MouseEvent &event); + void logic() override; + void mouseMoved(gcn::MouseEvent &event) override; + void mouseExited(gcn::MouseEvent &event) override; private: void init(); diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index ad27c4c8..ec8af1cd 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -35,19 +35,19 @@ class ChannelTab : public ChatTab Channel *getChannel() const { return mChannel; } - void showHelp(); + void showHelp() override; bool handleCommand(const std::string &type, - const std::string &args); + const std::string &args) override; protected: friend class Channel; ChannelTab(Channel *channel); - ~ChannelTab(); + ~ChannelTab() override; - void handleInput(const std::string &msg); + void handleInput(const std::string &msg) override; private: Channel *mChannel; diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 200ad55a..3d19a9ad 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -38,7 +38,7 @@ class ChatTab : public Tab, public AutoCompleteLister, public EventListener { public: ChatTab(const std::string &name); - ~ChatTab(); + ~ChatTab() override; /** * Adds a line of text to our message list. Parameters: @@ -98,17 +98,17 @@ class ChatTab : public Tab, public AutoCompleteLister, public EventListener { return false; } - void getAutoCompleteList(std::vector<std::string> &names) const; + void getAutoCompleteList(std::vector<std::string> &names) const override; virtual void saveToLogFile(std::string &msg); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; protected: friend class ChatWindow; friend class WhisperWindow; - virtual void setCurrent() { setFlash(false); } + void setCurrent() override { setFlash(false); } virtual void handleInput(const std::string &msg); diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 62e196c8..6eb53c38 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -36,12 +36,12 @@ class CheckBox : public gcn::CheckBox public: CheckBox(const std::string &caption, bool selected = false); - ~CheckBox(); + ~CheckBox() override; /** * Draws the caption, then calls drawBox to draw the check box. */ - void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics* graphics) override; /** * Update the alpha value to the checkbox components. @@ -51,17 +51,17 @@ class CheckBox : public gcn::CheckBox /** * Draws the check box, not the caption. */ - void drawBox(gcn::Graphics* graphics); + void drawBox(gcn::Graphics* graphics) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; private: static int instances; diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index e1b99af7..74b82f07 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -24,7 +24,7 @@ #include "gui/widgets/layouthelper.h" Container::Container(): - mLayoutHelper(0) + mLayoutHelper(nullptr) { setOpaque(false); } diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 46b719a1..6c5caa3a 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -42,7 +42,7 @@ class Container : public gcn::Container { public: Container(); - ~Container(); + ~Container() override; protected: /** diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 07d1d887..3b26ef3a 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -37,7 +37,7 @@ #include "utils/stringutils.h" Desktop::Desktop() - : mWallpaper(0) + : mWallpaper(nullptr) { addWidgetListener(this); @@ -74,7 +74,7 @@ void Desktop::widgetResized(const gcn::Event &) void Desktop::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics *>(graphics); + auto *g = static_cast<Graphics *>(graphics); if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || getHeight() > mWallpaper->getHeight())) diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 8ecb7e03..e10813ef 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -47,16 +47,16 @@ class Desktop : public Container, gcn::WidgetListener { public: Desktop(); - ~Desktop(); + ~Desktop() override; /** * Has to be called after updates have been loaded. */ void reloadWallpaper(); - void widgetResized(const gcn::Event &); + void widgetResized(const gcn::Event &) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: void setBestFittingWallpaper(); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index ebc76184..f0b721f6 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -43,34 +43,34 @@ class DropDown : public gcn::DropDown * @param listModel the ListModel to use. * @see ListModel */ - DropDown(gcn::ListModel *listModel = 0); + DropDown(gcn::ListModel *listModel = nullptr); - ~DropDown(); + ~DropDown() override; /** * Update the alpha value to the graphic components. */ void updateAlpha(); - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; // Inherited from FocusListener - void focusLost(const gcn::Event& event); + void focusLost(const gcn::Event& event) override; // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent); + void keyPressed(gcn::KeyEvent& keyEvent) override; // Inherited from MouseListener - void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override; protected: /** @@ -78,7 +78,7 @@ class DropDown : public gcn::DropDown * * @param graphics a Graphics object to draw with. */ - void drawButton(gcn::Graphics *graphics); + void drawButton(gcn::Graphics *graphics) override; // Add own Images. static int instances; diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index cdb2d3c4..fa74cf20 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -79,7 +79,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); graphics->setFont(getFont()); diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index cc388580..2d62b500 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -38,27 +38,27 @@ class EmoteShortcutContainer : public ShortcutContainer public: EmoteShortcutContainer(); - virtual ~EmoteShortcutContainer(); + ~EmoteShortcutContainer() override; /** * Draws the items. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; private: std::vector<const ImageSprite*> mEmoteImg; diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index d04c5153..bf34c4c7 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -57,7 +57,7 @@ void FlowContainer::widgetResized(const gcn::Event &event) int i = 0; height = 0; - for (WidgetList::iterator it = mWidgets.begin(); it != mWidgets.end(); it++) + for (auto it = mWidgets.begin(); it != mWidgets.end(); it++) { int x = i % mGridWidth * mBoxWidth; (*it)->setPosition(x, height); @@ -73,5 +73,5 @@ void FlowContainer::add(gcn::Widget *widget) { Container::add(widget); widget->setSize(mBoxWidth, mBoxHeight); - widgetResized(NULL); + widgetResized(nullptr); } diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index 0109ab64..28d148d5 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -40,7 +40,7 @@ class FlowContainer : public Container, * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; int getBoxWidth() const { return mBoxWidth; } @@ -48,7 +48,7 @@ class FlowContainer : public Container, int getBoxHeight() const { return mBoxHeight; } - void add(gcn::Widget *widget); + void add(gcn::Widget *widget) override; private: int mBoxWidth; diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 6b5120e6..5d7d62f7 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -27,7 +27,7 @@ #include "resources/resourcemanager.h" Icon::Icon(const std::string &file) - : mImage(0) + : mImage(nullptr) { mImage = ResourceManager::getInstance()->getImage(file); if (mImage) @@ -52,7 +52,7 @@ void Icon::draw(gcn::Graphics *g) { if (mImage) { - Graphics *graphics = static_cast<Graphics*>(g); + auto *graphics = static_cast<Graphics*>(g); const int x = (getWidth() - mImage->getWidth()) / 2; const int y = (getHeight() - mImage->getHeight()) / 2; graphics->drawImage(mImage, x, y); diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 6945e4c9..896b26c1 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -59,7 +59,7 @@ class Icon : public gcn::Widget /** * Draws the Icon. */ - void draw(gcn::Graphics *g); + void draw(gcn::Graphics *g) override; private: Image *mImage; diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h index 19058a46..d5829404 100644 --- a/src/gui/widgets/inttextfield.h +++ b/src/gui/widgets/inttextfield.h @@ -63,7 +63,7 @@ class IntTextField : public TextField /** * Responds to key presses. */ - void keyPressed(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event) override; private: int mMin; /**< Minimum value */ diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index f15fe682..5b373bb6 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -96,7 +96,7 @@ void ItemContainer::logic() void ItemContainer::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); g->setFont(getFont()); @@ -209,7 +209,7 @@ Item *ItemContainer::getSelectedItem() const Item *ItemContainer::getItemAt(int index) const { - std::map<int, Item*>::const_iterator i = mFilteredMap.find(index); + auto i = mFilteredMap.find(index); return i == mFilteredMap.end() ? 0 : i->second; } diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index aba12644..fe5b73e5 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -57,33 +57,33 @@ class ItemContainer : public gcn::Widget, */ ItemContainer(Inventory *inventory); - virtual ~ItemContainer(); + ~ItemContainer() override; void hidePopup(); /** * Necessary for checking how full the inventory is. */ - void logic(); + void logic() override; /** * Draws the items. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; // KeyListener - void keyPressed(gcn::KeyEvent &event); - void keyReleased(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event) override; + void keyReleased(gcn::KeyEvent &event) override; // MouseListener - void mousePressed(gcn::MouseEvent &event); - void mouseDragged(gcn::MouseEvent &event); - void mouseReleased(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); - void mouseExited(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseDragged(gcn::MouseEvent &event) override; + void mouseReleased(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; + void mouseExited(gcn::MouseEvent &event) override; // WidgetListener - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; /** * Returns the selected item. @@ -191,8 +191,8 @@ class ItemContainer : public gcn::Widget, ItemPopup *mItemPopup; - typedef std::list<gcn::SelectionListener*> SelectionListenerList; - typedef SelectionListenerList::iterator SelectionListenerIterator; + using SelectionListenerList = std::list<gcn::SelectionListener *>; + using SelectionListenerIterator = SelectionListenerList::iterator; SelectionListenerList mSelectionListeners; }; diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h index e499f3e4..dd9eeedc 100644 --- a/src/gui/widgets/itemlinkhandler.h +++ b/src/gui/widgets/itemlinkhandler.h @@ -30,8 +30,8 @@ class ItemLinkHandler : public LinkHandler { public: ItemLinkHandler(); - ~ItemLinkHandler(); - void handleLink(const std::string &link); + ~ItemLinkHandler() override; + void handleLink(const std::string &link) override; private: ItemPopup *mItemPopup; diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 396de3bd..a43596f8 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -43,7 +43,7 @@ ItemShortcutContainer::ItemShortcutContainer(): ShortcutContainer(), mItemClicked(false), - mItemMoved(NULL) + mItemMoved(nullptr) { addMouseListener(this); addWidgetListener(this); @@ -73,7 +73,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); graphics->setFont(getFont()); @@ -196,7 +196,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) // Convert relative to the window coordinates to absolute screen // coordinates. - viewport->showPopup(NULL, viewport->getMouseX(), viewport->getMouseY(), item); + viewport->showPopup(nullptr, viewport->getMouseX(), viewport->getMouseY(), item); } } @@ -210,13 +210,13 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - mItemMoved = NULL; + mItemMoved = nullptr; return; } if (mItemMoved) { itemShortcut->setItems(index, mItemMoved->getId()); - mItemMoved = NULL; + mItemMoved = nullptr; } else if (itemShortcut->getItem(index) && mItemClicked) { diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 2441d2f8..55d14977 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -40,31 +40,31 @@ class ItemShortcutContainer : public ShortcutContainer public: ItemShortcutContainer(); - virtual ~ItemShortcutContainer(); + ~ItemShortcutContainer() override; /** * Draws the items. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; private: - void mouseExited(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; bool mItemClicked; Item *mItemMoved; diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index f30308cd..cb7a8b1c 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -44,7 +44,7 @@ class Label : public gcn::Label /** * Draws the label. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; }; #endif diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 68783ddc..ac8488e0 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -71,11 +71,11 @@ void LayoutCell::computeSizes() { assert(mType == ARRAY); - for (std::vector< std::vector< LayoutCell * > >::iterator + for (auto i = mArray->mCells.begin(), i_end = mArray->mCells.end(); i != i_end; ++i) { - for (std::vector< LayoutCell * >::iterator + for (auto j = i->begin(), j_end = i->end(); j != j_end; ++j) { LayoutCell *cell = *j; @@ -93,10 +93,10 @@ LayoutArray::LayoutArray(): mSpacing(4) LayoutArray::~LayoutArray() { - for (std::vector< std::vector< LayoutCell * > >::iterator + for (auto i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i) { - for (std::vector< LayoutCell * >::iterator + for (auto j = i->begin(), j_end = i->end(); j != j_end; ++j) { delete *j; @@ -133,10 +133,10 @@ void LayoutArray::resizeGrid(int w, int h) mSizes[0].resize(w, Layout::AUTO_DEF); } - for (std::vector< std::vector< LayoutCell * > >::iterator + for (auto i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i) { - i->resize(w, NULL); + i->resize(w, nullptr); } } diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 5652bdf5..8fd7a405 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -34,7 +34,7 @@ class LayoutCell; class ContainerPlacer { public: - ContainerPlacer(gcn::Container *c = NULL, LayoutCell *l = NULL): + ContainerPlacer(gcn::Container *c = nullptr, LayoutCell *l = nullptr): mContainer(c), mCell(l) {} diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index b8512212..26360a9a 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -36,7 +36,7 @@ class LayoutHelper : public gcn::WidgetListener public: explicit LayoutHelper(gcn::Container *container); - ~LayoutHelper(); + ~LayoutHelper() override; /** * Gets the layout handler. @@ -68,7 +68,7 @@ class LayoutHelper : public gcn::WidgetListener /** * Called whenever the managed container changes size. */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; private: Layout mLayout; /**< Layout handler */ diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index bc22da30..25787ca7 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -38,7 +38,7 @@ class ListBox : public gcn::ListBox public: ListBox(gcn::ListModel *listModel); - ~ListBox(); + ~ListBox() override; /** * Sets the font to render the text in. @@ -53,7 +53,7 @@ class ListBox : public gcn::ListBox /** * Draws the list box. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Update the alpha value to the graphic components. @@ -62,17 +62,17 @@ class ListBox : public gcn::ListBox // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent); + void keyPressed(gcn::KeyEvent& keyEvent) override; // Inherited from MouseListener - void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override; - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; private: gcn::Font *mFont; diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h index 83e7e53b..4bed0e05 100644 --- a/src/gui/widgets/passwordfield.h +++ b/src/gui/widgets/passwordfield.h @@ -40,7 +40,7 @@ class PasswordField : public TextField /** * Draws the password field. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; }; #endif diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 4f341af0..1d3325ee 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -71,7 +71,7 @@ PlayerBox::~PlayerBox() { instances--; - mBeing = 0; + mBeing = nullptr; if (instances == 0) { diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 070bd82b..68dd670e 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -39,9 +39,9 @@ class PlayerBox : public gcn::ScrollArea * Constructor. Takes the initial player character that this box should * display, which defaults to <code>NULL</code>. */ - PlayerBox(const Being *being = 0); + PlayerBox(const Being *being = nullptr); - ~PlayerBox(); + ~PlayerBox() override; /** * Sets a new player character to be displayed by this box. Setting the @@ -54,12 +54,12 @@ class PlayerBox : public gcn::ScrollArea /** * Draws the scroll area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Draws the background and border of the scroll area. */ - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; private: const Being *mBeing; /**< The character used for display */ diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 1c7cfdd1..298443e7 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -73,7 +73,7 @@ void Popup::setWindowContainer(WindowContainer *wc) void Popup::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 5ec6ecd0..af37b211 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -62,7 +62,7 @@ class Popup : public Container, public gcn::MouseListener /** * Destructor. Deletes all the added widgets. */ - ~Popup(); + ~Popup() override; /** * Sets the window container to be used by new popups. @@ -72,7 +72,7 @@ class Popup : public Container, public gcn::MouseListener /** * Draws the popup. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Sets the size of this popup. @@ -84,7 +84,7 @@ class Popup : public Container, public gcn::MouseListener */ void setLocationRelativeTo(gcn::Widget *widget); - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** * Sets the minimum width of the popup. @@ -142,7 +142,7 @@ class Popup : public Container, public gcn::MouseListener // Inherited from BasicContainer - virtual gcn::Rectangle getChildrenArea(); + gcn::Rectangle getChildrenArea() override; /** * Sets the location to display the popup. Tries to horizontally center diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 56b2fe92..d3a4c100 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -44,12 +44,12 @@ class ProgressBar : public gcn::Widget int width = 40, int height = 7, int color = -1); - ~ProgressBar(); + ~ProgressBar() override; /** * Performs progress bar logic (fading colors) */ - void logic(); + void logic() override; /** * Update the alpha value to the graphic components. @@ -59,7 +59,7 @@ class ProgressBar : public gcn::Widget /** * Draws the progress bar. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Sets the current progress. diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 9971d144..2495a62d 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -35,7 +35,7 @@ ProgressIndicator::ProgressIndicator() ImageSet *images = Theme::getImageSetFromTheme("progress-indicator.png", 32, 32); - Animation *anim = new Animation; + auto *anim = new Animation; for (ImageSet::size_type i = 0; i < images->size(); ++i) anim->addFrame(images->get(i), 100, 0, 0); diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index cb469c07..13cab227 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -33,10 +33,10 @@ class ProgressIndicator : public gcn::Widget { public: ProgressIndicator(); - ~ProgressIndicator(); + ~ProgressIndicator() override; - void logic(); - void draw(gcn::Graphics *graphics); + void logic() override; + void draw(gcn::Graphics *graphics) override; private: SimpleAnimation *mIndicator; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index b0a92784..676daede 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -88,7 +88,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) radioCheckedHi->setAlpha(mAlpha); } - Image *box = NULL; + Image *box = nullptr; if (isEnabled()) if (isSelected()) diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index 5a868fea..014acd06 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -35,28 +35,28 @@ class RadioButton : public gcn::RadioButton RadioButton(const std::string &caption,const std::string &group, bool marked = false); - ~RadioButton(); + ~RadioButton() override; /** * Draws the radiobutton, not the caption. */ - void drawBox(gcn::Graphics* graphics); + void drawBox(gcn::Graphics* graphics) override; /** * Implementation of the draw methods. * Thus, avoiding the rhomb around the radio button. */ - void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics* graphics) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; private: static int instances; diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index da97ac69..1770fcb1 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -29,7 +29,7 @@ #include <guichan/graphics.hpp> -Image *ResizeGrip::gripImage = 0; +Image *ResizeGrip::gripImage = nullptr; int ResizeGrip::mInstances = 0; float ResizeGrip::mAlpha = 1.0; diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 9e478cd9..d2f8ca4d 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -38,12 +38,12 @@ class ResizeGrip : public gcn::Widget public: ResizeGrip(const std::string &image = "resize.png"); - ~ResizeGrip(); + ~ResizeGrip() override; /** * Draws the resize grip. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: static Image *gripImage; /**< Resize grip image */ diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index d3e308c7..266b5a31 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -56,13 +56,13 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Destructor. Also deletes the content. */ - ~ScrollArea(); + ~ScrollArea() override; /** * Logic function optionally adapts width or height of contents. This * depends on the scrollbar settings. */ - void logic(); + void logic() override; /** * Update the alpha value to the graphic components. @@ -72,12 +72,12 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Draws the scroll area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Draws the background and border of the scroll area. */ - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; /** * Sets whether the widget should draw its background or not. @@ -92,19 +92,19 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Called when the mouse moves in the widget area. */ - void mouseMoved(gcn::MouseEvent& event); + void mouseMoved(gcn::MouseEvent& event) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; protected: enum BUTTON_DIR { @@ -120,14 +120,14 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener void init(); void drawButton(gcn::Graphics *graphics, BUTTON_DIR dir); - void drawUpButton(gcn::Graphics *graphics); - void drawDownButton(gcn::Graphics *graphics); - void drawLeftButton(gcn::Graphics *graphics); - void drawRightButton(gcn::Graphics *graphics); - void drawVBar(gcn::Graphics *graphics); - void drawHBar(gcn::Graphics *graphics); - void drawVMarker(gcn::Graphics *graphics); - void drawHMarker(gcn::Graphics *graphics); + void drawUpButton(gcn::Graphics *graphics) override; + void drawDownButton(gcn::Graphics *graphics) override; + void drawLeftButton(gcn::Graphics *graphics) override; + void drawRightButton(gcn::Graphics *graphics) override; + void drawVBar(gcn::Graphics *graphics) override; + void drawHBar(gcn::Graphics *graphics) override; + void drawVMarker(gcn::Graphics *graphics) override; + void drawHMarker(gcn::Graphics *graphics) override; static int instances; static float mAlpha; diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index 59711754..91829131 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -52,7 +52,7 @@ void ShopItems::addItem(int id, int amount, int price) void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price) { - ShopItem *item = 0; + ShopItem *item = nullptr; if (mMergeDuplicates) { item = findItem(id); @@ -99,5 +99,5 @@ ShopItem *ShopItems::findItem(int id) } } - return 0; + return nullptr; } diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index 338dc0cd..e213f67c 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -49,7 +49,7 @@ class ShopItems : public gcn::ListModel */ ShopItems(bool mergeDuplicates = false); - ~ShopItems(); + ~ShopItems() override; /** * Adds an item to the list. @@ -70,14 +70,14 @@ class ShopItems : public gcn::ListModel /** * Returns the number of items in the shop. */ - int getNumberOfElements(); + int getNumberOfElements() override; /** * Returns the name of item number i in the shop. * * @param i the index to retrieve */ - std::string getElementAt(int i); + std::string getElementAt(int i) override; /** * Returns the item number i in the shop. diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index e2e03e18..d6dd087a 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -87,7 +87,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) const gcn::Color &textColor = Theme::getThemeColor(Theme::TEXT); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); graphics->setFont(getFont()); const int fontHeight = getFont()->getHeight(); @@ -97,7 +97,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) i < mListModel->getNumberOfElements(); ++i, y += mRowHeight) { - ShopItem *shopItem = mShopItems ? mShopItems->at(i) : 0; + ShopItem *shopItem = mShopItems ? mShopItems->at(i) : nullptr; if (shopItem && mPlayerMoney < shopItem->getPrice() && mPriceCheck) { diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index a1554c6e..c3d10a4a 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -44,17 +44,17 @@ class ShopListBox : public ListBox */ ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel); - ~ShopListBox(); + ~ShopListBox() override; /** * Draws the list box. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Returns the height of a row. */ - unsigned int getRowHeight() const { return mRowHeight; } + unsigned int getRowHeight() const override { return mRowHeight; } /** * gives information about the current player's money @@ -75,12 +75,12 @@ class ShopListBox : public ListBox /** ** Show ItemTooltip */ - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** ** Hide ItemTooltip */ - void mouseExited(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; private: int mPlayerMoney; diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index e7f05c48..f0f9b730 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -40,33 +40,33 @@ class ShortcutContainer : public gcn::Widget, public: ShortcutContainer(); - ~ShortcutContainer() {} + ~ShortcutContainer() override {} /** * Draws the shortcuts */ - virtual void draw(gcn::Graphics *graphics) = 0; + void draw(gcn::Graphics *graphics) override = 0; /** * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - virtual void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; /** * Handles mouse when dragged. */ - virtual void mouseDragged(gcn::MouseEvent &event) = 0; + void mouseDragged(gcn::MouseEvent &event) override = 0; /** * Handles mouse when pressed. */ - virtual void mousePressed(gcn::MouseEvent &event) = 0; + void mousePressed(gcn::MouseEvent &event) override = 0; /** * Handles mouse release. */ - virtual void mouseReleased(gcn::MouseEvent &event) = 0; + void mouseReleased(gcn::MouseEvent &event) override = 0; int getMaxItems() const { return mMaxItems; } diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index a7ad6abf..d5b9d5ec 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -47,7 +47,7 @@ class Slider : public gcn::Slider */ Slider(double scaleStart, double scaleEnd); - ~Slider(); + ~Slider() override; /** * Update the alpha value to the graphic components. @@ -57,22 +57,22 @@ class Slider : public gcn::Slider /** * Draws the slider. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Draws the marker. */ - void drawMarker(gcn::Graphics *graphics); + void drawMarker(gcn::Graphics *graphics) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; private: /** diff --git a/src/gui/widgets/spacer.h b/src/gui/widgets/spacer.h index 75a83afd..11e0ac66 100644 --- a/src/gui/widgets/spacer.h +++ b/src/gui/widgets/spacer.h @@ -47,7 +47,7 @@ class Spacer : public gcn::Widget /** * Draws nothing. */ - void draw(gcn::Graphics *g) {} + void draw(gcn::Graphics *g) override {} }; #endif // SPACER_H diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 49537e76..9dc5291e 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -35,7 +35,7 @@ class Tab : public gcn::Tab { public: Tab(); - ~Tab(); + ~Tab() override; /** * Update the alpha value to the graphic components. @@ -45,7 +45,7 @@ class Tab : public gcn::Tab /** * Draw the tabbed area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Set the normal color fo the tab's text. diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 52690657..cd2c0f03 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -41,7 +41,7 @@ TabbedArea::TabbedArea() : gcn::TabbedArea(), add(mArrowButton[0]); add(mArrowButton[1]); - widgetResized(NULL); + widgetResized(nullptr); } int TabbedArea::getNumberOfTabs() const @@ -51,7 +51,7 @@ int TabbedArea::getNumberOfTabs() const Tab *TabbedArea::getTab(const std::string &name) const { - TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end(); + auto itr = mTabs.begin(), itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) @@ -59,7 +59,7 @@ Tab *TabbedArea::getTab(const std::string &name) const ++itr; } - return NULL; + return nullptr; } void TabbedArea::draw(gcn::Graphics *graphics) @@ -72,7 +72,7 @@ void TabbedArea::draw(gcn::Graphics *graphics) gcn::Widget *TabbedArea::getWidget(const std::string &name) const { - TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end(); + auto itr = mTabs.begin(), itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) @@ -81,7 +81,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const ++itr; } - return NULL; + return nullptr; } gcn::Widget *TabbedArea::getCurrentWidget() @@ -89,7 +89,7 @@ gcn::Widget *TabbedArea::getCurrentWidget() if (gcn::Tab *tab = getSelectedTab()) return getWidget(tab->getCaption()); - return NULL; + return nullptr; } void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget) @@ -119,7 +119,7 @@ void TabbedArea::removeTab(Tab *tab) if (getNumberOfTabs() > 1) setSelectedTab(std::max(0, getSelectedTabIndex() - 1)); else - mSelectedTab = 0; + mSelectedTab = nullptr; } TabContainer::iterator iter; @@ -163,7 +163,7 @@ void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) { gcn::Widget *widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); - gcn::Tab *tab = dynamic_cast<gcn::Tab*>(widget); + auto *tab = dynamic_cast<gcn::Tab*>(widget); if (tab) { @@ -180,7 +180,7 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab) if (Tab *newTab = dynamic_cast<Tab*>(tab)) newTab->setCurrent(); - widgetResized(NULL); + widgetResized(nullptr); } void TabbedArea::widgetResized(const gcn::Event &event) diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index b43078a4..53bb2bb2 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -44,7 +44,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener /** * Draw the tabbed area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Return how many tabs have been created. @@ -74,7 +74,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener * @param tab The tab widget for the tab. * @param widget The widget to view when the tab is selected. */ - void addTab(gcn::Tab* tab, gcn::Widget* widget); + void addTab(gcn::Tab* tab, gcn::Widget* widget) override; /** * Add a tab. Overridden since it needs to create an instance of Tab @@ -83,7 +83,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener * @param caption The Caption to display * @param widget The widget to show when tab is selected */ - void addTab(const std::string &caption, gcn::Widget *widget); + void addTab(const std::string &caption, gcn::Widget *widget) override; /** * Overload the remove tab function as it's broken in guichan 0.8. @@ -93,27 +93,27 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener /** * Overload the logic function since it's broken in guichan 0.8. */ - void logic(); + void logic() override; int getContainerHeight() const { return mWidgetContainer->getHeight(); } - void setSelectedTab(unsigned int index) + void setSelectedTab(unsigned int index) override { gcn::TabbedArea::setSelectedTab(index); } - void setSelectedTab(gcn::Tab *tab); + void setSelectedTab(gcn::Tab *tab) override; - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; void adjustTabPositions(); - void action(const gcn::ActionEvent& actionEvent); + void action(const gcn::ActionEvent& actionEvent) override; // Inherited from MouseListener - void mousePressed(gcn::MouseEvent &mouseEvent); + void mousePressed(gcn::MouseEvent &mouseEvent) override; private: - typedef std::vector< std::pair<gcn::Tab*, gcn::Widget*> > TabContainer; + using TabContainer = std::vector<std::pair<gcn::Tab *, gcn::Widget *>>; /** The tab arrows */ Button *mArrowButton[2]; diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp index 08aae006..465fbc61 100644 --- a/src/gui/widgets/table.cpp +++ b/src/gui/widgets/table.cpp @@ -40,9 +40,9 @@ class GuiTableActionListener : public gcn::ActionListener public: GuiTableActionListener(GuiTable *_table, gcn::Widget *_widget, int _row, int _column); - virtual ~GuiTableActionListener(); + ~GuiTableActionListener() override; - virtual void action(const gcn::ActionEvent& actionEvent); + void action(const gcn::ActionEvent& actionEvent) override; protected: GuiTable *mTable; @@ -70,7 +70,7 @@ GuiTableActionListener::~GuiTableActionListener() if (mWidget) { mWidget->removeActionListener(this); - mWidget->_setParent(NULL); + mWidget->_setParent(nullptr); } } @@ -87,10 +87,10 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, mWrappingEnabled(false), mOpaque(opacity), mBackgroundColor(background), - mModel(NULL), + mModel(nullptr), mSelectedRow(0), mSelectedColumn(0), - mTopWidget(NULL) + mTopWidget(nullptr) { setModel(initial_model); setFocusable(true); @@ -367,7 +367,7 @@ void GuiTable::moveToBottom(gcn::Widget *widget) { gcn::Widget::moveToBottom(widget); if (widget == mTopWidget) - mTopWidget = NULL; + mTopWidget = nullptr; } gcn::Rectangle GuiTable::getChildrenArea() const @@ -484,7 +484,7 @@ void GuiTable::modelUpdated(bool completed) } else { // before the update? - mTopWidget = NULL; // No longer valid in general + mTopWidget = nullptr; // No longer valid in general uninstallActionListeners(); } } @@ -503,10 +503,10 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y) const if (w && w->isFocusable()) return w; else - return NULL; // Grab the event locally + return nullptr; // Grab the event locally } else - return NULL; + return nullptr; } int GuiTable::getRowForY(int y) const diff --git a/src/gui/widgets/table.h b/src/gui/widgets/table.h index 1a412b6f..a9202022 100644 --- a/src/gui/widgets/table.h +++ b/src/gui/widgets/table.h @@ -50,10 +50,10 @@ class GuiTable : public gcn::Widget, friend class GuiTableActionListener; public: - GuiTable(TableModel * initial_model = NULL, gcn::Color background = 0xffffff, + GuiTable(TableModel * initial_model = nullptr, gcn::Color background = 0xffffff, bool opacity = true); - virtual ~GuiTable(); + ~GuiTable() override; /** * Retrieves the active table model @@ -101,18 +101,18 @@ public: void setLinewiseSelection(bool linewise); // Inherited from Widget - virtual void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics* graphics) override; virtual gcn::Widget *getWidgetAt(int x, int y) const; - virtual void moveToTop(gcn::Widget *child); + void moveToTop(gcn::Widget *child) override; - virtual void moveToBottom(gcn::Widget *child); + void moveToBottom(gcn::Widget *child) override; - virtual void _setFocusHandler(gcn::FocusHandler* focusHandler); + void _setFocusHandler(gcn::FocusHandler* focusHandler) override; // Inherited from KeyListener - virtual void keyPressed(gcn::KeyEvent& keyEvent); + void keyPressed(gcn::KeyEvent& keyEvent) override; /** * Sets the table to be opaque, that is sets the table @@ -131,16 +131,16 @@ public: virtual bool isOpaque() const {return mOpaque;} // Inherited from MouseListener - virtual void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; - virtual void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override; - virtual void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override; - virtual void mouseDragged(gcn::MouseEvent& mouseEvent); + void mouseDragged(gcn::MouseEvent& mouseEvent) override; // Constraints inherited from TableModelListener - virtual void modelUpdated(bool); + void modelUpdated(bool) override; protected: /** Frees all action listeners on inner widgets. */ diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index 501e9c31..5273e929 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -37,13 +37,13 @@ void TableModel::removeListener(TableModelListener *listener) void TableModel::signalBeforeUpdate() { - for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++) + for (auto it = listeners.begin(); it != listeners.end(); it++) (*it)->modelUpdated(false); } void TableModel::signalAfterUpdate() { - for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++) + for (auto it = listeners.begin(); it != listeners.end(); it++) (*it)->modelUpdated(true); } diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h index ca657415..2e36992a 100644 --- a/src/gui/widgets/tablemodel.h +++ b/src/gui/widgets/tablemodel.h @@ -101,7 +101,7 @@ class StaticTableModel : public TableModel { public: StaticTableModel(int width, int height); - virtual ~StaticTableModel(); + ~StaticTableModel() override; /** * Inserts a widget into the table model. @@ -130,13 +130,13 @@ public: */ virtual void resize(); - virtual int getRows() const; - virtual int getColumns() const; - virtual int getRowHeight() const; + int getRows() const override; + int getColumns() const override; + int getRowHeight() const override; virtual int getWidth() const; virtual int getHeight() const; - virtual int getColumnWidth(int index) const; - virtual gcn::Widget *getElementAt(int row, int column) const; + int getColumnWidth(int index) const override; + gcn::Widget *getElementAt(int row, int column) const override; protected: int mRows, mColumns; diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index dc003036..bcf09ee2 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -52,7 +52,7 @@ class TextBox : public gcn::TextBox /** * Draws the text. */ - void draw(gcn::Graphics *graphics) + void draw(gcn::Graphics *graphics) override { setForegroundColor(*mTextColor); gcn::TextBox::draw(graphics); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 35ce09c5..1609e002 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -46,8 +46,8 @@ ImageRect TextField::skin; TextField::TextField(const std::string &text, bool loseFocusOnTab): gcn::TextField(text), mNumeric(false), - mAutoComplete(NULL), - mHistory(NULL) + mAutoComplete(nullptr), + mHistory(nullptr) { setFrameSize(2); @@ -203,7 +203,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) if (mHistory && !mHistory->atEnd()) { // Move forward through the history - TextHistoryIterator prevHist = mHistory->current++; + auto prevHist = mHistory->current++; if (!mHistory->atEnd()) { @@ -324,7 +324,7 @@ void TextField::autoComplete() if (newName == "" && mHistory) { - TextHistoryIterator i = mHistory->history.begin(); + auto i = mHistory->history.begin(); std::vector<std::string> nameList; while (i != mHistory->history.end()) diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index bf60cbc3..b1b7a6a4 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -30,8 +30,8 @@ class TextInput; class ImageRect; class TextField; -typedef std::list<std::string> TextHistoryList; -typedef TextHistoryList::iterator TextHistoryIterator; +using TextHistoryList = std::list<std::string>; +using TextHistoryIterator = TextHistoryList::iterator; struct TextHistory { TextHistoryList history; /**< Command history. */ @@ -80,12 +80,12 @@ class TextField : public gcn::TextField * Constructor, initializes the text field with the given string. */ TextField(const std::string &text = "", bool loseFocusOnTab = true); - ~TextField(); + ~TextField() override; /** * Draws the text field. */ - virtual void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Update the alpha value to the graphic components. @@ -95,7 +95,7 @@ class TextField : public gcn::TextField /** * Draws the background and border. */ - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; /** * Determine whether the field should be numeric or not @@ -114,7 +114,7 @@ class TextField : public gcn::TextField /** * Processes one keypress. */ - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; /** * Handle text input (should possibly be new event in Guichan). diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index b0963d30..d6ef172c 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -38,7 +38,7 @@ TextPreview::TextPreview(const std::string &text): mTextAlpha = false; mFont = gui->getFont(); mTextColor = &Theme::getThemeColor(Theme::TEXT); - mTextBGColor = NULL; + mTextBGColor = nullptr; mBGColor = &Theme::getThemeColor(Theme::BACKGROUND); mOpaque = false; } @@ -64,7 +64,7 @@ void TextPreview::draw(gcn::Graphics* graphics) if (mTextBGColor && typeid(*mFont) == typeid(TrueTypeFont)) { - TrueTypeFont *font = static_cast<TrueTypeFont*>(mFont); + auto *font = static_cast<TrueTypeFont*>(mFont); int x = font->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); graphics->setColor(gcn::Color((int) mTextBGColor->r, diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 6a0cb28b..0cda7c8b 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -110,7 +110,7 @@ class TextPreview : public gcn::Widget * * @param graphics graphics to draw into */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Set opacity for this widget (whether or not to show the background diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index e21e9d75..ad87788f 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -45,7 +45,7 @@ void VertContainer::clear() void VertContainer::widgetResized(const gcn::Event &event) { - for (WidgetListIterator it = mWidgets.begin(); it != mWidgets.end(); it++) + for (auto it = mWidgets.begin(); it != mWidgets.end(); it++) { (*it)->setWidth(getWidth()); } diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index c2403afb..439f7ca1 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -34,9 +34,9 @@ class VertContainer : public Container, public gcn::WidgetListener { public: VertContainer(int spacing); - virtual void add(gcn::Widget *widget); - virtual void clear(); - void widgetResized(const gcn::Event &event); + void add(gcn::Widget *widget) override; + void clear() override; + void widgetResized(const gcn::Event &event) override; private: int mSpacing; diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index a0dcfc14..0f01bacc 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -34,12 +34,12 @@ class WhisperTab : public ChatTab public: const std::string &getNick() const { return mNick; } - void showHelp(); + void showHelp() override; bool handleCommand(const std::string &type, - const std::string &args); + const std::string &args) override; - void saveToLogFile(std::string &msg); + void saveToLogFile(std::string &msg) override; protected: friend class ChatWindow; @@ -51,13 +51,13 @@ class WhisperTab : public ChatTab */ WhisperTab(const std::string &nick); - ~WhisperTab(); + ~WhisperTab() override; - void handleInput(const std::string &msg); + void handleInput(const std::string &msg) override; - void handleCommand(const std::string &msg); + void handleCommand(const std::string &msg) override; - bool checkNotify(Own) const + bool checkNotify(Own) const override { return true; } private: diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c8788c75..05638470 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -44,9 +44,9 @@ int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, const std::string &skin): gcn::Window(caption), - mGrip(0), + mGrip(nullptr), mParent(parent), - mLayout(NULL), + mLayout(nullptr), mWindowName("window"), mShowTitle(true), mModal(modal), @@ -114,7 +114,7 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); @@ -260,7 +260,7 @@ void Window::setResizable(bool r) { remove(mGrip); delete mGrip; - mGrip = 0; + mGrip = nullptr; } } @@ -757,7 +757,7 @@ void Window::reflowLayout(int w, int h) assert(mLayout); mLayout->reflow(w, h); delete mLayout; - mLayout = NULL; + mLayout = nullptr; setContentSize(w, h); } diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index fc44ec5f..fe2b217c 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -57,12 +57,12 @@ class Window : public gcn::Window, gcn::WidgetListener * @param skin The location where the window's skin XML can be found. */ Window(const std::string &caption = "Window", bool modal = false, - Window *parent = NULL, const std::string &skin = "window.xml"); + Window *parent = nullptr, const std::string &skin = "window.xml"); /** * Destructor. Deletes all the added widgets. */ - ~Window(); + ~Window() override; /** * Sets the window container to be used by new windows. @@ -72,7 +72,7 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Draws the window. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Sets the size of this window. @@ -100,12 +100,12 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Called whenever the widget changes size. */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; /** * Called whenever the widget is hidden. */ - virtual void widgetHidden(const gcn::Event &event); + void widgetHidden(const gcn::Event &event) override; /** * Sets whether or not the window has a close button. @@ -215,31 +215,31 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Starts window resizing when appropriate. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Implements window resizing and makes sure the window is not * dragged/resized outside of the screen. */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Implements custom cursor image changing context, based on mouse * relative position. */ - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** * When the mouse button has been let go, this ensures that the mouse * custom cursor is restored back to it's standard image. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; /** * When the mouse leaves the window this ensures that the custom cursor * is restored back to it's standard image. */ - void mouseExited(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; /** * Sets the name of the window. This is not the window title. diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 5cff4999..c7ac5d99 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -25,7 +25,7 @@ #include "utils/dtor.h" -WindowContainer *windowContainer = NULL; +WindowContainer *windowContainer = nullptr; void WindowContainer::logic() { @@ -43,7 +43,7 @@ void WindowContainer::scheduleDelete(gcn::Widget *widget) void WindowContainer::adjustAfterResize(int oldScreenWidth, int oldScreenHeight) { - for (WidgetListIterator i = mWidgets.begin(); i != mWidgets.end(); ++i) - if (Window *window = dynamic_cast<Window*>(*i)) + for (auto i = mWidgets.begin(); i != mWidgets.end(); ++i) + if (auto *window = dynamic_cast<Window*>(*i)) window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight); } diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index 1da5a2cd..3e01bb36 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -37,7 +37,7 @@ class WindowContainer : public Container * Do GUI logic. This functions adds automatic deletion of objects that * volunteered to be deleted. */ - void logic(); + void logic() override; /** * Schedule a widget for deletion. It will be deleted at the start of @@ -55,8 +55,8 @@ class WindowContainer : public Container /** * List of widgets that are scheduled to be deleted. */ - typedef std::list<gcn::Widget*> Widgets; - typedef Widgets::iterator WidgetIterator; + using Widgets = std::list<gcn::Widget *>; + using WidgetIterator = Widgets::iterator; Widgets mDeathList; }; diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 9a53479e..5b13d0f3 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -46,7 +46,7 @@ extern Window *statusWindow; extern Window *socialWindow; WindowMenu::WindowMenu(): - mEmotePopup(0) + mEmotePopup(nullptr) { int x = 0, h = 0; @@ -84,7 +84,7 @@ WindowMenu::~WindowMenu() void WindowMenu::action(const gcn::ActionEvent &event) { - Window *window = 0; + Window *window = nullptr; if (event.getId() == ":-)") { @@ -104,7 +104,7 @@ void WindowMenu::action(const gcn::ActionEvent &event) else { windowContainer->scheduleDelete(mEmotePopup); - mEmotePopup = 0; + mEmotePopup = nullptr; } } else if (event.getId() == "Status") @@ -159,7 +159,7 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event) Net::getPlayerHandler()->emote(emote); windowContainer->scheduleDelete(mEmotePopup); - mEmotePopup = 0; + mEmotePopup = nullptr; } } @@ -180,7 +180,7 @@ void WindowMenu::addButton(const std::string& text, int &x, int &h, const std::string& iconPath, KeyboardConfig::KeyAction key) { - Button *btn = new Button("", text, this); + auto *btn = new Button("", text, this); if (!iconPath.empty() && btn->setButtonIcon(iconPath)) { btn->setButtonPopupText(createShortcutCaption(text, key)); @@ -199,9 +199,9 @@ void WindowMenu::addButton(const std::string& text, int &x, int &h, void WindowMenu::updatePopUpCaptions() { - for (WidgetList::iterator it = mWidgets.begin(); it != mWidgets.end(); ++it) + for (auto it = mWidgets.begin(); it != mWidgets.end(); ++it) { - Button *button = dynamic_cast<Button*> (*it); + auto *button = dynamic_cast<Button*> (*it); if (!button) continue; diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index ed2ea8df..92b3b9b4 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -43,11 +43,11 @@ class WindowMenu : public Container, { public: WindowMenu(); - ~WindowMenu(); + ~WindowMenu() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Update the pop-up captions with new key shortcuts. diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index f6084f32..f2b31085 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -51,14 +51,14 @@ class WorldListModel : public gcn::ListModel { } - virtual ~WorldListModel() {} + ~WorldListModel() override {} - int getNumberOfElements() + int getNumberOfElements() override { return mWorlds.size(); } - std::string getElementAt(int i) + std::string getElementAt(int i) override { const WorldInfo *si = mWorlds[i]; return si->name + " (" + toString(si->online_users) + ")"; @@ -72,7 +72,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds): { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); - ScrollArea *worldsScroll = new ScrollArea(mWorldList); + auto *worldsScroll = new ScrollArea(mWorldList); mChangeLoginButton = new Button(_("Change Login"), "login", this); mChooseWorld = new Button(_("Choose World"), "world", this); @@ -130,11 +130,11 @@ void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) { - action(gcn::ActionEvent(NULL, mChangeLoginButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mChangeLoginButton->getActionEventId())); } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mChooseWorld->getActionEventId())); + action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId())); } } diff --git a/src/gui/worldselectdialog.h b/src/gui/worldselectdialog.h index 368b005b..f2b74582 100644 --- a/src/gui/worldselectdialog.h +++ b/src/gui/worldselectdialog.h @@ -45,16 +45,16 @@ class WorldSelectDialog : public Window, public gcn::ActionListener, public: WorldSelectDialog(Worlds worlds); - ~WorldSelectDialog(); + ~WorldSelectDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; private: WorldListModel *mWorldListModel; diff --git a/src/guild.cpp b/src/guild.cpp index 714ca010..f21f015a 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -74,7 +74,7 @@ GuildMember *Guild::addMember(const std::string &name) GuildMember *Guild::getMember(int id) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -83,12 +83,12 @@ GuildMember *Guild::getMember(int id) const ++itr; } - return NULL; + return nullptr; } GuildMember *Guild::getMember(const std::string &name) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -99,12 +99,12 @@ GuildMember *Guild::getMember(const std::string &name) const ++itr; } - return NULL; + return nullptr; } void Guild::removeMember(GuildMember *member) { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -119,7 +119,7 @@ void Guild::removeMember(GuildMember *member) void Guild::removeMember(int id) { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -131,7 +131,7 @@ void Guild::removeMember(int id) void Guild::removeMember(const std::string &name) { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -145,7 +145,7 @@ void Guild::removeMember(const std::string &name) void Guild::removeFromMembers() { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while(itr != itr_end) { @@ -172,7 +172,7 @@ bool Guild::isMember(GuildMember *member) const if (member->mGuild != nullptr && member->mGuild != this) return false; - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -189,7 +189,7 @@ bool Guild::isMember(GuildMember *member) const bool Guild::isMember(int id) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -203,7 +203,7 @@ bool Guild::isMember(int id) const bool Guild::isMember(const std::string &name) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -220,7 +220,7 @@ bool Guild::isMember(const std::string &name) const void Guild::getNames(std::vector<std::string> &names) const { names.clear(); - MemberList::const_iterator it = mMembers.begin(), + auto it = mMembers.begin(), it_end = mMembers.end(); while (it != it_end) { @@ -231,7 +231,7 @@ void Guild::getNames(std::vector<std::string> &names) const Guild *Guild::getGuild(int id) { - GuildMap::iterator it = guilds.find(id); + auto it = guilds.find(id); if (it != guilds.end()) return it->second; diff --git a/src/guild.h b/src/guild.h index 75c93d18..deee8e7b 100644 --- a/src/guild.h +++ b/src/guild.h @@ -129,11 +129,11 @@ public: * Get size of members list. * @return Returns the number of members in the guild. */ - int getNumberOfElements() { + int getNumberOfElements() override { return mMembers.size(); } - Avatar *getAvatarAt(int i); + Avatar *getAvatarAt(int i) override; /** * Get whether user can invite users to this guild. @@ -157,7 +157,7 @@ public: static Guild *getGuild(int id); private: - typedef std::map<int, Guild*> GuildMap; + using GuildMap = std::map<int, Guild *>; static GuildMap guilds; /** @@ -165,7 +165,7 @@ private: */ Guild(short id); - typedef std::vector<GuildMember*> MemberList; + using MemberList = std::vector<GuildMember *>; MemberList mMembers; std::string mName; short mId; diff --git a/src/imageparticle.h b/src/imageparticle.h index cd98c2ba..ac677389 100644 --- a/src/imageparticle.h +++ b/src/imageparticle.h @@ -41,12 +41,12 @@ class ImageParticle : public Particle */ ImageParticle(Map *map, Image *image); - ~ImageParticle(); + ~ImageParticle() override; /** * Draws the particle image */ - virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const; + bool draw(Graphics *graphics, int offsetX, int offsetY) const override; protected: Image *mImage; /**< The image used for this particle. */ diff --git a/src/imagesprite.h b/src/imagesprite.h index 3ee8fc61..c9b5175e 100644 --- a/src/imagesprite.h +++ b/src/imagesprite.h @@ -32,35 +32,35 @@ class ImageSprite : public Sprite public: ImageSprite(Image *image); - ~ImageSprite(); + ~ImageSprite() override; - bool reset() + bool reset() override { return false; } - bool play(std::string action) + bool play(std::string action) override { return false; } - bool update(int time) + bool update(int time) override { return false; } - bool draw(Graphics* graphics, int posX, int posY) const; + bool draw(Graphics* graphics, int posX, int posY) const override; - int getWidth() const + int getWidth() const override { return mImage->getWidth(); } - int getHeight() const + int getHeight() const override { return mImage->getHeight(); } - const Image* getImage() const + const Image* getImage() const override { return mImage; } - virtual bool setDirection(SpriteDirection direction) + bool setDirection(SpriteDirection direction) override { return false; } int getNumberOfLayers() { return 1; } - int getDuration() const + int getDuration() const override { return 0; } private: diff --git a/src/inventory.cpp b/src/inventory.cpp index a88ab96b..a7418175 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -42,7 +42,7 @@ Inventory::Inventory(Type type, int size): mUsed(0) { mItems = new Item*[mSize]; - std::fill_n(mItems, mSize, (Item*) 0); + std::fill_n(mItems, mSize, (Item*) nullptr); } Inventory::~Inventory() @@ -56,7 +56,7 @@ Inventory::~Inventory() Item *Inventory::getItem(int index) const { if (index < 0 || index >= mSize || !mItems[index] || mItems[index]->getQuantity() <= 0) - return 0; + return nullptr; return mItems[index]; } @@ -67,7 +67,7 @@ Item *Inventory::findItem(int itemId) const if (mItems[i] && mItems[i]->getId() == itemId) return mItems[i]; - return NULL; + return nullptr; } void Inventory::addItem(int id, int quantity) @@ -118,7 +118,7 @@ void Inventory::removeItem(int id) void Inventory::removeItemAt(int index) { delete mItems[index]; - mItems[index] = 0; + mItems[index] = nullptr; if (mUsed > 0) { mUsed--; distributeSlotsChangedEvent(); diff --git a/src/inventory.h b/src/inventory.h index 71950be5..b4253b72 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -135,7 +135,7 @@ class Inventory { return mType == INVENTORY; } protected: - typedef std::list<InventoryListener*> InventoryListenerList; + using InventoryListenerList = std::list<InventoryListener *>; InventoryListenerList mInventoryListeners; void distributeSlotsChangedEvent(); diff --git a/src/item.cpp b/src/item.cpp index e2759d4b..d904a0ab 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -30,8 +30,8 @@ #include "resources/theme.h" Item::Item(int id, int quantity, bool equipped): - mImage(0), - mDrawImage(0), + mImage(nullptr), + mDrawImage(nullptr), mQuantity(quantity), mEquipped(equipped), mInEquipment(false) { diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 76168f66..dfd461db 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -233,5 +233,5 @@ bool KeyboardConfig::isKeyActive(int index) const void KeyboardConfig::refreshActiveKeys() { - mActiveKeys = SDL_GetKeyboardState(NULL); + mActiveKeys = SDL_GetKeyboardState(nullptr); } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index d37c1364..ca639317 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -61,22 +61,22 @@ const int AWAY_LIMIT_TIMER = 60; -LocalPlayer *local_player = 0; +LocalPlayer *local_player = nullptr; LocalPlayer::LocalPlayer(int id, int subtype): - Being(id, PLAYER, subtype, 0), + Being(id, PLAYER, subtype, nullptr), mAttackRange(-1), mTargetTime(-1), mLastTargetTime(-1), - mTarget(0), - mPickUpTarget(0), + mTarget(nullptr), + mPickUpTarget(nullptr), mGoingToTarget(false), mKeepAttacking(false), mLastActionTime(-1), mWalkingDir(0), mPathSetByMouse(false), mMessageTime(0), mShowIp(false), - mAwayDialog(0), + mAwayDialog(nullptr), mAfkTime(0), mAwayMode(false) { @@ -188,7 +188,7 @@ void LocalPlayer::logic() && withinRange(mPickUpTarget, Net::getGameHandler()->getPickupRange())) { Net::getPlayerHandler()->pickUp(mPickUpTarget); - mPickUpTarget = 0; + mPickUpTarget = nullptr; } Being::logic(); @@ -199,7 +199,7 @@ void LocalPlayer::setAction(Action action, int attackId) if (action == DEAD) { mLastTargetTime = -1; - setTarget(0); + setTarget(nullptr); } Being::setAction(action, attackId); @@ -607,8 +607,8 @@ void LocalPlayer::inviteToGuild(Being *being) // TODO: Allow user to choose which guild to invite being to // For now, just invite to the first guild you have permissions to invite with - std::map<int, Guild*>::iterator itr = mGuilds.begin(); - std::map<int, Guild*>::iterator itr_end = mGuilds.end(); + auto itr = mGuilds.begin(); + auto itr_end = mGuilds.end(); for (; itr != itr_end; ++itr) { if (checkInviteRights(itr->second->getName())) @@ -633,7 +633,7 @@ void LocalPlayer::pickUp(FloorItem *item) // if the player does not move if (getDestination() == getPosition()) lookAt(item->getPosition()); - mPickUpTarget = 0; + mPickUpTarget = nullptr; } else { @@ -669,7 +669,7 @@ void LocalPlayer::setTarget(Being *target) mTargetTime = -1; } - Being *oldTarget = 0; + Being *oldTarget = nullptr; if (mTarget) { mTarget->untarget(); @@ -895,7 +895,7 @@ void LocalPlayer::stopAttack() { if (mAction == ATTACK) setAction(STAND); - setTarget(0); + setTarget(nullptr); } mLastTargetTime = -1; cancelGoToTarget(); @@ -1013,10 +1013,10 @@ void LocalPlayer::event(Event::Channel channel, const Event &event) ActorSprite *actor = event.getActor("source"); if (mPickUpTarget == actor) - mPickUpTarget = 0; + mPickUpTarget = nullptr; if (mTarget == actor) - mTarget = 0; + mTarget = nullptr; } } else if (channel == Event::AttributesChannel) @@ -1073,7 +1073,7 @@ void LocalPlayer::changeAwayMode() mAwayDialog->addActionListener(mAwayListener); } - mAwayDialog = 0; + mAwayDialog = nullptr; } void LocalPlayer::setAway(const std::string &message) diff --git a/src/localplayer.h b/src/localplayer.h index 0d7b6077..7a9020d6 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -41,7 +41,7 @@ class OkDialog; class AwayListener : public gcn::ActionListener { public: - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; }; /** @@ -66,11 +66,11 @@ class LocalPlayer : public Being public: LocalPlayer(int id= 65535, int subtype = 0); - ~LocalPlayer(); + ~LocalPlayer() override; - virtual void logic(); + void logic() override; - virtual void setAction(Action action, int attackId = 1); + void setAction(Action action, int attackId = 1) override; /** * Check the player has permission to invite users to specific guild @@ -95,7 +95,7 @@ class LocalPlayer : public Being int getAttackRange() const { return mAttackRange; } - void attack(Being *target = NULL, bool keep = false); + void attack(Being *target = nullptr, bool keep = false); void setGMLevel(int level); @@ -197,7 +197,7 @@ class LocalPlayer : public Being void addMessageToQueue(const std::string &message, int color = UserPalette::EXP_INFO); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; /** * Tells the engine wether to check @@ -252,7 +252,7 @@ class LocalPlayer : public Being int mWalkingDir; /**< The direction the player is walking in. */ bool mPathSetByMouse; /**< Tells if the path was set using mouse */ - typedef std::pair<std::string, int> MessagePair; + using MessagePair = std::pair<std::string, int>; /** Queued messages*/ std::list<MessagePair> mMessages; int mMessageTime; diff --git a/src/log.cpp b/src/log.cpp index eae0a82b..74246b7e 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -71,7 +71,7 @@ void Logger::log(const char *log_text, ...) // Get the current system time timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Print the log entry std::stringstream timeStr; diff --git a/src/main.cpp b/src/main.cpp index e3225d63..eecb60e7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,28 +77,28 @@ static void parseOptions(int argc, char *argv[], Client::Options &options) const char *optstring = "hvud:U:P:Dc:s:p:C:"; const struct option long_options[] = { - { "config-dir", required_argument, 0, 'C' }, - { "data", required_argument, 0, 'd' }, - { "default", no_argument, 0, 'D' }, - { "password", required_argument, 0, 'P' }, - { "character", required_argument, 0, 'c' }, - { "help", no_argument, 0, 'h' }, - { "localdata-dir", required_argument, 0, 'L' }, - { "update-host", required_argument, 0, 'H' }, - { "port", required_argument, 0, 'p' }, - { "server", required_argument, 0, 's' }, - { "skip-update", no_argument, 0, 'u' }, - { "username", required_argument, 0, 'U' }, - { "no-opengl", no_argument, 0, 'O' }, - { "chat-log-dir", required_argument, 0, 'T' }, - { "version", no_argument, 0, 'v' }, - { "screenshot-dir", required_argument, 0, 'i' }, - { 0 } + { "config-dir", required_argument, nullptr, 'C' }, + { "data", required_argument, nullptr, 'd' }, + { "default", no_argument, nullptr, 'D' }, + { "password", required_argument, nullptr, 'P' }, + { "character", required_argument, nullptr, 'c' }, + { "help", no_argument, nullptr, 'h' }, + { "localdata-dir", required_argument, nullptr, 'L' }, + { "update-host", required_argument, nullptr, 'H' }, + { "port", required_argument, nullptr, 'p' }, + { "server", required_argument, nullptr, 's' }, + { "skip-update", no_argument, nullptr, 'u' }, + { "username", required_argument, nullptr, 'U' }, + { "no-opengl", no_argument, nullptr, 'O' }, + { "chat-log-dir", required_argument, nullptr, 'T' }, + { "version", no_argument, nullptr, 'v' }, + { "screenshot-dir", required_argument, nullptr, 'i' }, + { nullptr } }; while (optind < argc) { - int result = getopt_long(argc, argv, optstring, long_options, NULL); + int result = getopt_long(argc, argv, optstring, long_options, nullptr); if (result == -1) break; diff --git a/src/map.cpp b/src/map.cpp index b9bcb284..76ddc56a 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -63,7 +63,7 @@ struct Location }; TileAnimation::TileAnimation(Animation *ani): - mLastImage(NULL) + mLastImage(nullptr) { mAnimation = new SimpleAnimation(ani); } @@ -85,7 +85,7 @@ void TileAnimation::update(int ticks) Image *img = mAnimation->getCurrentImage(); if (img != mLastImage) { - for (std::list<std::pair<MapLayer*, int> >::iterator i = + for (auto i = mAffected.begin(); i != mAffected.end(); i++) { i->first->setTile(i->second, img); @@ -103,7 +103,7 @@ MapLayer::MapLayer(int x, int y, int width, int height, bool isFringeLayer, { const int size = mWidth * mHeight; mTiles = new Image*[size]; - std::fill_n(mTiles, size, (Image*) 0); + std::fill_n(mTiles, size, (Image*) nullptr); } MapLayer::~MapLayer() @@ -132,7 +132,7 @@ void MapLayer::draw(Graphics *graphics, if (endX > mWidth) endX = mWidth; if (endY > mHeight) endY = mHeight; - Actors::const_iterator ai = actors.begin(); + auto ai = actors.begin(); int dx = (mX * mMap->getTileWidth()) - scrollX; int dy = (mY * mMap->getTileHeight()) - scrollY + mMap->getTileHeight(); @@ -336,7 +336,7 @@ bool actorCompare(const Actor *a, const Actor *b) void Map::update(int ticks) { // Update animated tiles - for (std::map<int, TileAnimation*>::iterator iAni = mTileAnimations.begin(); + for (auto iAni = mTileAnimations.begin(); iAni != mTileAnimations.end(); iAni++) { @@ -538,7 +538,7 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type, } // Draw overlays - for (std::list<AmbientLayer*>::iterator i = layers->begin(); + for (auto i = layers->begin(); i != layers->end(); i++) { (*i)->draw(graphics, graphics->getWidth(), graphics->getHeight()); @@ -551,8 +551,8 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type, Tileset *Map::getTilesetWithGid(unsigned gid) const { - Tileset *s = NULL; - for (Tilesets::const_iterator it = mTilesets.begin(), + Tileset *s = nullptr; + for (auto it = mTilesets.begin(), it_end = mTilesets.end(); it < it_end && (*it)->getFirstGid() <= gid; it++) s = *it; @@ -739,7 +739,7 @@ Path Map::findTilePath(int startPixelX, int startPixelY, int endPixelX, return myPath; // Convert the map path to pixels from the tile position - Path::iterator it = myPath.begin(); + auto it = myPath.begin(); while (it != myPath.end()) { // The new pixel position will be the tile center. @@ -777,7 +777,7 @@ Path Map::findPixelPath(int startPixelX, int startPixelY, int endPixelX, // Convert the map path to pixels over tiles // And add interpolation between the starting and ending offsets - Path::iterator it = myPath.begin(); + auto it = myPath.begin(); int i = 0; while (it != myPath.end()) { @@ -1022,7 +1022,7 @@ void Map::initializeParticleEffects(Particle *particleEngine) if (config.getBoolValue("particleeffects")) { - for (std::list<ParticleEffectData>::iterator i = particleEffects.begin(); + for (auto i = particleEffects.begin(); i != particleEffects.end(); i++ ) @@ -1038,6 +1038,6 @@ void Map::initializeParticleEffects(Particle *particleEngine) TileAnimation *Map::getAnimationForGid(int gid) const { - std::map<int, TileAnimation*>::const_iterator i = mTileAnimations.find(gid); + auto i = mTileAnimations.find(gid); return (i == mTileAnimations.end()) ? NULL : i->second; } @@ -37,8 +37,8 @@ class Particle; class SimpleAnimation; class Tileset; -typedef std::vector<Tileset*> Tilesets; -typedef std::vector<MapLayer*> Layers; +using Tilesets = std::vector<Tileset *>; +using Layers = std::vector<MapLayer *>; const int DEFAULT_TILE_LENGTH = 32; @@ -181,7 +181,7 @@ class Map : public Properties */ Map(int width, int height, int tileWidth, int tileHeight); - ~Map(); + ~Map() override; /** * Initialize ambient layers. Has to be called after all the properties diff --git a/src/net/charhandler.h b/src/net/charhandler.h index 1835ceb9..4b108cac 100644 --- a/src/net/charhandler.h +++ b/src/net/charhandler.h @@ -40,7 +40,7 @@ struct Character { Character() : slot(0), - dummy(0) + dummy(nullptr) { } @@ -54,7 +54,7 @@ struct Character PlayerInfoBackend data; }; -typedef std::list<Character*> Characters; +using Characters = std::list<Character *>; class CharHandler { @@ -97,9 +97,9 @@ class CharHandler protected: CharHandler(): - mSelectedCharacter(0), - mCharSelectDialog(0), - mCharCreateDialog(0) + mSelectedCharacter(nullptr), + mCharSelectDialog(nullptr), + mCharCreateDialog(nullptr) {} void updateCharSelectDialog(); diff --git a/src/net/download.cpp b/src/net/download.cpp index 61cdf114..d15eb18d 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -66,11 +66,11 @@ Download::Download(void *ptr, const std::string &url, mPtr(ptr), mUrl(url), mFileName(""), - mWriteFunction(NULL), + mWriteFunction(nullptr), mUpdateFunction(updateFunction), - mThread(NULL), - mCurl(NULL), - mHeaders(NULL) + mThread(nullptr), + mCurl(nullptr), + mHeaders(nullptr) { mError = (char*) malloc(CURL_ERROR_SIZE); @@ -145,8 +145,8 @@ void Download::cancel() mOptions.cancel = true; if (mThread && SDL_GetThreadID(mThread) != 0) { - SDL_WaitThread(mThread, NULL); - mThread = NULL; + SDL_WaitThread(mThread, nullptr); + mThread = nullptr; } } @@ -158,7 +158,7 @@ char *Download::getError() int Download::downloadProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) { - Download *d = reinterpret_cast<Download*>(clientp); + auto *d = reinterpret_cast<Download*>(clientp); if (d->mOptions.cancel) { @@ -174,7 +174,7 @@ int Download::downloadThread(void *ptr) { int attempts = 0; bool complete = false; - Download *d = reinterpret_cast<Download*>(ptr); + auto *d = reinterpret_cast<Download*>(ptr); CURLcode res; std::string outFilename; @@ -189,13 +189,13 @@ int Download::downloadThread(void *ptr) while (attempts < 3 && !complete && !d->mOptions.cancel) { - FILE *file = NULL; + FILE *file = nullptr; d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_STARTING, 0, 0); if (d->mOptions.cancel) { - d->mThread = NULL; + d->mThread = nullptr; return 0; } @@ -309,7 +309,7 @@ int Download::downloadThread(void *ptr) } if (d->mOptions.cancel) { - d->mThread = NULL; + d->mThread = nullptr; return 0; } attempts++; @@ -328,7 +328,7 @@ int Download::downloadThread(void *ptr) d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_COMPLETE, 0, 0); } - d->mThread = NULL; + d->mThread = nullptr; return 0; } diff --git a/src/net/download.h b/src/net/download.h index 26810f3f..b3501363 100644 --- a/src/net/download.h +++ b/src/net/download.h @@ -35,15 +35,13 @@ enum DownloadStatus DOWNLOAD_STATUS_COMPLETE }; -typedef int (*DownloadUpdate)(void *ptr, DownloadStatus status, - size_t total, size_t remaining); +using DownloadUpdate = int (*)(void *, DownloadStatus, size_t, size_t); // Matches what CURL expects -typedef size_t (*WriteFunction)( void *ptr, size_t size, size_t nmemb, - void *stream); +using WriteFunction = size_t (*)(void *, size_t, size_t, void *); struct SDL_Thread; -typedef void CURL; +using CURL = void; struct curl_slist; namespace Net { 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; diff --git a/src/net/net.cpp b/src/net/net.cpp index 8946945b..c060d2e8 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -44,19 +44,19 @@ #include "utils/gettext.h" -Net::AdminHandler *adminHandler = NULL; -Net::CharHandler *charHandler = NULL; -Net::ChatHandler *chatHandler = NULL; -Net::GeneralHandler *generalHandler = NULL; -Net::InventoryHandler *inventoryHandler = NULL; -Net::LoginHandler *loginHandler = NULL; -Net::GameHandler *gameHandler = NULL; -Net::GuildHandler *guildHandler = NULL; -Net::NpcHandler *npcHandler = NULL; -Net::PartyHandler *partyHandler = NULL; -Net::PlayerHandler *playerHandler = NULL; -Net::SpecialHandler *specialHandler = NULL; -Net::TradeHandler *tradeHandler = NULL; +Net::AdminHandler *adminHandler = nullptr; +Net::CharHandler *charHandler = nullptr; +Net::ChatHandler *chatHandler = nullptr; +Net::GeneralHandler *generalHandler = nullptr; +Net::InventoryHandler *inventoryHandler = nullptr; +Net::LoginHandler *loginHandler = nullptr; +Net::GameHandler *gameHandler = nullptr; +Net::GuildHandler *guildHandler = nullptr; +Net::NpcHandler *npcHandler = nullptr; +Net::PartyHandler *partyHandler = nullptr; +Net::PlayerHandler *playerHandler = nullptr; +Net::SpecialHandler *specialHandler = nullptr; +Net::TradeHandler *tradeHandler = nullptr; Net::AdminHandler *Net::getAdminHandler() { @@ -141,13 +141,13 @@ void connectToServer(ServerInfo &server) logger->error(_("Unknown Server Type! Exiting.")); } - if (networkType == server.type && getGeneralHandler() != NULL) + if (networkType == server.type && getGeneralHandler() != nullptr) { getGeneralHandler()->reload(); } else { - if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != NULL) + if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != nullptr) { getGeneralHandler()->unload(); } diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index 8d697e46..0d638ac1 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -74,7 +74,7 @@ class PlayerHandler * Convert the original server-dependant speed for internal use. */ virtual Vector getPixelsPerTickMoveSpeed(const Vector &speed, - Map *map = 0) = 0; + Map *map = nullptr) = 0; /** * Tells whether the client has to use pixel paths. diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 98881931..f9119d19 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -36,7 +36,7 @@ public: TMWATHENA }; - typedef std::pair<int, std::string> VersionString; + using VersionString = std::pair<int, std::string>; Type type = UNKNOWN; std::string name; @@ -96,6 +96,6 @@ public: } }; -typedef std::deque<ServerInfo> ServerInfos; +using ServerInfos = std::deque<ServerInfo>; #endif // SERVERINFO_H diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index 71c37a09..f91a093d 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -34,27 +34,27 @@ class AdminHandler : public MessageHandler, public Net::AdminHandler 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 TmwAthena diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 12c97feb..3027efc8 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -90,7 +90,7 @@ static Being *createBeing(int id, short job) else if (job > 1000 && job <= 2000) type = ActorSprite::MONSTER; else if (job == 45) - return NULL; // Skip portals + return nullptr; // Skip portals Being *being = actorSpriteManager->createBeing(id, type, job); diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index 81bbad74..1ec1583c 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -31,7 +31,7 @@ class BeingHandler : public MessageHandler public: BeingHandler(bool enableSync); - virtual void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; private: // Should we honor server "Stop Walking" packets diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 908e1d6d..00a36f15 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -88,7 +88,7 @@ void BuySellHandler::handleMessage(MessageIn &msg) n_items = (msg.getLength() - 4) / 10; if (n_items > 0) { - SellDialog *dialog = new SellDialog(mNpcId); + auto *dialog = new SellDialog(mNpcId); dialog->setMoney(PlayerInfo::getAttribute(MONEY)); for (int k = 0; k < n_items; k++) diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h index b5229e0f..6e22b4af 100644 --- a/src/net/tmwa/buysellhandler.h +++ b/src/net/tmwa/buysellhandler.h @@ -33,7 +33,7 @@ class BuySellHandler : public MessageHandler public: BuySellHandler(); - virtual void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; private: int mNpcId; diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index a8e87622..45c07bec 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -87,7 +87,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) for (int i = 0; i < count; ++i) { - Net::Character *character = new Net::Character; + auto *character = new Net::Character; readPlayerData(msg, character); mCharacters.push_back(character); logger->log("CharServer: Player: %s (%d)", @@ -117,7 +117,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) case SMSG_CHAR_CREATE_SUCCEEDED: { - Net::Character *character = new Net::Character; + auto *character = new Net::Character; readPlayerData(msg, character); mCharacters.push_back(character); @@ -127,7 +127,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) if (mCharCreateDialog) { mCharCreateDialog->scheduleDelete(); - mCharCreateDialog = 0; + mCharCreateDialog = nullptr; } } break; @@ -142,7 +142,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) case SMSG_CHAR_DELETE_SUCCEEDED: delete mSelectedCharacter; mCharacters.remove(mSelectedCharacter); - mSelectedCharacter = 0; + mSelectedCharacter = nullptr; updateCharSelectDialog(); unlockCharSelectDialog(); new OkDialog(_("Info"), _("Character deleted.")); @@ -156,7 +156,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) case SMSG_CHAR_MAP_INFO: { msg.skip(4); // CharID, must be the same as local_player->charID - GameHandler *gh = static_cast<GameHandler*>(Net::getGameHandler()); + auto *gh = static_cast<GameHandler*>(Net::getGameHandler()); gh->setMap(msg.readString(16)); const auto ip = msg.readInt32(); @@ -172,7 +172,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) PlayerInfo::setBackend(mSelectedCharacter->data); // Prevent the selected local player from being deleted - mSelectedCharacter->dummy = 0; + mSelectedCharacter->dummy = nullptr; delete_all(mCharacters); mCharacters.clear(); @@ -185,7 +185,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) case SMSG_CHANGE_MAP_SERVER: { - GameHandler *gh = static_cast<GameHandler*>(Net::getGameHandler()); + auto *gh = static_cast<GameHandler*>(Net::getGameHandler()); gh->setMap(msg.readString(16)); int x = msg.readInt16(); int y = msg.readInt16(); @@ -199,7 +199,7 @@ void CharServerHandler::handleMessage(MessageIn &msg) const int tileHeight = map->getTileHeight(); local_player->setPosition(Vector(x * tileWidth + tileWidth / 2, y * tileHeight + tileHeight / 2)); - local_player->setMap(0); + local_player->setMap(nullptr); } break; } @@ -210,7 +210,7 @@ void CharServerHandler::readPlayerData(MessageIn &msg, Net::Character *character const Token &token = static_cast<LoginHandler*>(Net::getLoginHandler())->getToken(); - LocalPlayer *tempPlayer = new LocalPlayer(msg.readInt32(), 0); + auto *tempPlayer = new LocalPlayer(msg.readInt32(), 0); tempPlayer->setGender(token.sex); character->data.mAttributes[EXP] = msg.readInt32(); @@ -309,7 +309,7 @@ void CharServerHandler::requestCharacters() void CharServerHandler::chooseCharacter(Net::Character *character) { mSelectedCharacter = character; - mCharSelectDialog = 0; + mCharSelectDialog = nullptr; MessageOut outMsg(CMSG_CHAR_SELECT); outMsg.writeInt8(mSelectedCharacter->slot); diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h index 7e4fc2d9..cf673a4d 100644 --- a/src/net/tmwa/charserverhandler.h +++ b/src/net/tmwa/charserverhandler.h @@ -40,37 +40,37 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler public: CharServerHandler(); - virtual 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; - int getCharCreateMaxHairColorId() const; - int getCharCreateMaxHairStyleId() const; + int getCharCreateMaxHairColorId() const override; + int getCharCreateMaxHairStyleId() const override; void connect(); diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index fa3a8ec3..682a3743 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -36,36 +36,36 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler public: ChatHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - 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: - typedef std::queue<std::string> WhisperQueue; + using WhisperQueue = std::queue<std::string>; WhisperQueue mSentWhispers; }; diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index 68ed62b0..44ce6bc0 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -93,7 +93,7 @@ void GameHandler::handleMessage(MessageIn &msg) if (msg.readInt8()) { new OkDialog(_("Game"), _("Request to quit denied!"), false, - NULL); + nullptr); } break; } diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h index a6bcde0a..8859c9c6 100644 --- a/src/net/tmwa/gamehandler.h +++ b/src/net/tmwa/gamehandler.h @@ -39,32 +39,32 @@ class GameHandler : public MessageHandler, public Net::GameHandler, public: GameHandler(); - 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; - void connect(); + void connect() override; - bool isConnected(); + bool isConnected() override; - void disconnect(); + void disconnect() override; - void who(); + void who() override; - void quit(); + void quit() override; - bool removeDeadBeings() const { return true; } + bool removeDeadBeings() const override { return true; } void clear(); void setMap(const std::string map); /** The tmwAthena protocol is making use of the MP status bar. */ - bool canUseMagicBar() const { return true; } + bool canUseMagicBar() const override { return true; } - int getPickupRange() const; + int getPickupRange() const override; - int getNpcTalkRange() const { return DEFAULT_TILE_LENGTH * 30; } + int getNpcTalkRange() const override { return DEFAULT_TILE_LENGTH * 30; } private: std::string mMap; ///< Keeps the map filename. diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 5e445eaf..4053e17c 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -184,8 +184,8 @@ void GeneralHandler::reload() mNetwork->disconnect(); static_cast<LoginHandler*>(mLoginHandler.get())->clearWorlds(); - static_cast<CharServerHandler*>(mCharHandler.get())->setCharCreateDialog(0); - static_cast<CharServerHandler*>(mCharHandler.get())->setCharSelectDialog(0); + static_cast<CharServerHandler*>(mCharHandler.get())->setCharCreateDialog(nullptr); + static_cast<CharServerHandler*>(mCharHandler.get())->setCharSelectDialog(nullptr); } void GeneralHandler::unload() @@ -255,10 +255,10 @@ void GeneralHandler::event(Event::Channel channel, socialWindow->removeTab(taParty); delete guildTab; - guildTab = 0; + guildTab = nullptr; delete partyTab; - partyTab = 0; + partyTab = nullptr; } } } diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index a34852fd..22c6b650 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -37,21 +37,21 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler, public: GeneralHandler(); - ~GeneralHandler(); + ~GeneralHandler() override; - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - 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/tmwa/gui/guildtab.h b/src/net/tmwa/gui/guildtab.h index 0e208e93..e7d7b7cc 100644 --- a/src/net/tmwa/gui/guildtab.h +++ b/src/net/tmwa/gui/guildtab.h @@ -33,18 +33,18 @@ class GuildTab : public ChatTab { public: GuildTab(); - ~GuildTab(); + ~GuildTab() override; - void showHelp(); + void showHelp() override; - bool handleCommand(const std::string &type, const std::string &args); + bool handleCommand(const std::string &type, const std::string &args) override; - void saveToLogFile(std::string &msg); + void saveToLogFile(std::string &msg) override; protected: - void handleInput(const std::string &msg); + void handleInput(const std::string &msg) override; - void getAutoCompleteList(std::vector<std::string> &names) const; + void getAutoCompleteList(std::vector<std::string> &names) const override; }; extern GuildTab *guildTab; diff --git a/src/net/tmwa/gui/partytab.h b/src/net/tmwa/gui/partytab.h index 1049b770..61ccf37a 100644 --- a/src/net/tmwa/gui/partytab.h +++ b/src/net/tmwa/gui/partytab.h @@ -33,18 +33,18 @@ class PartyTab : public ChatTab { public: PartyTab(); - ~PartyTab(); + ~PartyTab() override; - void showHelp(); + void showHelp() override; - bool handleCommand(const std::string &type, const std::string &args); + bool handleCommand(const std::string &type, const std::string &args) override; - void saveToLogFile(std::string &msg); + void saveToLogFile(std::string &msg) override; protected: - void handleInput(const std::string &msg); + void handleInput(const std::string &msg) override; - virtual void getAutoCompleteList(std::vector<std::string>&) const; + void getAutoCompleteList(std::vector<std::string>&) const override; }; extern PartyTab *partyTab; diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index a3194991..180d1dfb 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -39,7 +39,7 @@ extern Net::GuildHandler *guildHandler; namespace TmwAthena { -GuildTab *guildTab = 0; +GuildTab *guildTab = nullptr; Guild *taGuild; GuildHandler::GuildHandler() @@ -83,7 +83,7 @@ GuildHandler::GuildHandler() GuildHandler::~GuildHandler() { delete guildTab; - guildTab = 0; + guildTab = nullptr; } void GuildHandler::handleMessage(MessageIn &msg) diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h index 4a74a26b..5f8c987c 100644 --- a/src/net/tmwa/guildhandler.h +++ b/src/net/tmwa/guildhandler.h @@ -32,34 +32,34 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler public: GuildHandler(); - ~GuildHandler(); + ~GuildHandler() override; - 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 guildId, Being *being); + void invite(int guildId, Being *being) override; - void inviteResponse(int guildId, bool response); + void inviteResponse(int guildId, 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; private: // TmwAthena (and eAthena) only supports one guild per player diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 256e7159..6f32fb3d 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -107,8 +107,8 @@ InventoryHandler::InventoryHandler() handledMessages = _messages; inventoryHandler = this; - mStorage = 0; - mStorageWindow = 0; + mStorage = nullptr; + mStorageWindow = nullptr; listen(Event::ItemChannel); } @@ -118,7 +118,7 @@ InventoryHandler::~InventoryHandler() if (mStorageWindow) { mStorageWindow->close(); - mStorageWindow = 0; + mStorageWindow = nullptr; } delete mStorage; @@ -312,8 +312,8 @@ void InventoryHandler::handleMessage(MessageIn &msg) if (!mStorage) mStorage = new Inventory(Inventory::STORAGE, size); - InventoryItems::iterator it = mInventoryItems.begin(); - InventoryItems::iterator it_end = mInventoryItems.end(); + auto it = mInventoryItems.begin(); + auto it_end = mInventoryItems.end(); for (; it != it_end; it++) mStorage->setItem((*it).slot, (*it).id, (*it).quantity); mInventoryItems.clear(); @@ -359,11 +359,11 @@ void InventoryHandler::handleMessage(MessageIn &msg) // Storage access has been closed // Storage window deletes itself - mStorageWindow = 0; + mStorageWindow = nullptr; mStorage->clear(); delete mStorage; - mStorage = 0; + mStorage = nullptr; break; case SMSG_PLAYER_EQUIPMENT: diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 3eefdd9b..6224b572 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -51,13 +51,13 @@ class EquipBackend : public Equipment::Backend memset(mEquipment, -1, sizeof(mEquipment)); } - Item *getEquipment(int index) const + Item *getEquipment(int index) const override { int invyIndex = mEquipment[index]; return PlayerInfo::getInventory()->getItem(invyIndex); } - std::string getSlotName(int slotIndex) const + std::string getSlotName(int slotIndex) const override { switch (slotIndex) { @@ -88,7 +88,7 @@ class EquipBackend : public Equipment::Backend } } - void clear() + void clear() override { for (int i = 0; i < EQUIP_VECTOR_END; i++) { @@ -126,14 +126,14 @@ class EquipBackend : public Equipment::Backend inventoryWindow->updateButtons(); } - void triggerUnequip(int slotIndex) const + void triggerUnequip(int slotIndex) const override { Item *item = getEquipment(slotIndex); if (item) item->doEvent(Event::DoUnequip); } - int getSlotNumber() const + int getSlotNumber() const override { return EQUIP_VECTOR_END; } // Note the slot type id is equal to the slot Index for tA. @@ -172,7 +172,7 @@ class InventoryItem } }; -typedef std::list<InventoryItem> InventoryItems; +using InventoryItems = std::list<InventoryItem>; class InventoryHandler : public MessageHandler, public Net::InventoryHandler, public EventListener @@ -185,20 +185,20 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler, InventoryHandler(); - ~InventoryHandler(); + ~InventoryHandler() override; - 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 mEquips.isWeaponSlot(slotTypeId); } - bool isAmmoSlot(unsigned int slotTypeId) const + bool isAmmoSlot(unsigned int slotTypeId) const override { return mEquips.isAmmoSlot(slotTypeId); } private: diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h index 3f58a172..29ed8246 100644 --- a/src/net/tmwa/itemhandler.h +++ b/src/net/tmwa/itemhandler.h @@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler public: ItemHandler(); - virtual void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; }; } // namespace TmwAthena diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 2fbc02d4..3e742f88 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -127,7 +127,7 @@ void LoginHandler::handleMessage(MessageIn &msg) for (int i = 0; i < worldCount; i++) { - WorldInfo *world = new WorldInfo; + auto *world = new WorldInfo; world->address = msg.readInt32(); world->port = msg.readInt16(); diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h index fcc7c5cc..92a268f1 100644 --- a/src/net/tmwa/loginhandler.h +++ b/src/net/tmwa/loginhandler.h @@ -38,43 +38,43 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler public: LoginHandler(); - ~LoginHandler(); + ~LoginHandler() override; - 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 SetGenderOnRegister; } - bool isRegistrationEnabled(); + bool isRegistrationEnabled() override; - void getRegistrationDetails(); + void getRegistrationDetails() override; - unsigned int getMaxPasswordLength() const { return 25; } + unsigned int getMaxPasswordLength() const override { return 25; } - 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 clearWorlds(); const Token &getToken() const { return mToken; } diff --git a/src/net/tmwa/messagehandler.cpp b/src/net/tmwa/messagehandler.cpp index b22b623e..e9ce33b1 100644 --- a/src/net/tmwa/messagehandler.cpp +++ b/src/net/tmwa/messagehandler.cpp @@ -28,7 +28,7 @@ namespace TmwAthena { MessageHandler::MessageHandler() - : mNetwork(NULL) + : mNetwork(nullptr) { } diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h index b598f896..0d278c15 100644 --- a/src/net/tmwa/messagehandler.h +++ b/src/net/tmwa/messagehandler.h @@ -39,7 +39,7 @@ class MessageHandler : public Net::MessageHandler public: MessageHandler(); - ~MessageHandler(); + ~MessageHandler() override; virtual void handleMessage(MessageIn &msg) = 0; @@ -49,7 +49,7 @@ class MessageHandler : public Net::MessageHandler Network *mNetwork; }; -typedef const std::unique_ptr<MessageHandler> MessageHandlerPtr; +using MessageHandlerPtr = const std::unique_ptr<MessageHandler>; } diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 5ff4f7e5..c1ba615f 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -91,7 +91,7 @@ namespace TmwAthena { int networkThread(void *data) { - Network *network = static_cast<Network*>(data); + auto *network = static_cast<Network*>(data); if (!network->realConnect()) return -1; @@ -101,16 +101,16 @@ int networkThread(void *data) return 0; } -Network *Network::mInstance = 0; +Network *Network::mInstance = nullptr; Network::Network(): - mSocket(0), + mSocket(nullptr), mInBuffer(new char[BUFFER_SIZE]), mOutBuffer(new char[BUFFER_SIZE]), mInSize(0), mOutSize(0), mToSkip(0), mState(IDLE), - mWorkerThread(0) + mWorkerThread(nullptr) { SDLNet_Init(); @@ -124,7 +124,7 @@ Network::~Network() if (mState != IDLE && mState != NET_ERROR) disconnect(); - mInstance = 0; + mInstance = nullptr; delete[] mInBuffer; delete[] mOutBuffer; @@ -175,14 +175,14 @@ void Network::disconnect() if (mWorkerThread) { - SDL_WaitThread(mWorkerThread, NULL); - mWorkerThread = NULL; + SDL_WaitThread(mWorkerThread, nullptr); + mWorkerThread = nullptr; } if (mSocket) { SDLNet_TCP_Close(mSocket); - mSocket = 0; + mSocket = nullptr; } } @@ -203,7 +203,7 @@ void Network::unregisterHandler(MessageHandler *handler) mMessageHandlers.erase(*i); } - handler->setNetwork(0); + handler->setNetwork(nullptr); } void Network::clearHandlers() @@ -211,7 +211,7 @@ void Network::clearHandlers() MessageHandlerIterator i; for (i = mMessageHandlers.begin(); i != mMessageHandlers.end(); ++i) { - i->second->setNetwork(0); + i->second->setNetwork(nullptr); } mMessageHandlers.clear(); } @@ -222,7 +222,7 @@ void Network::dispatchMessages() { MessageIn msg = getNextMessage(); - MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); + auto iter = mMessageHandlers.find(msg.getId()); if (msg.getLength() == 0) logger->error("Zero length packet received. Exiting."); diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 079e71ca..97c7970f 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -120,8 +120,8 @@ class Network SDL_Thread *mWorkerThread; Mutex mMutex; - typedef std::map<Uint16, MessageHandler*> MessageHandlers; - typedef MessageHandlers::iterator MessageHandlerIterator; + using MessageHandlers = std::map<Uint16, MessageHandler *>; + using MessageHandlerIterator = MessageHandlers::iterator; MessageHandlers mMessageHandlers; static Network *mInstance; diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 2b0a5b0a..9bd15572 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -76,7 +76,7 @@ void NpcHandler::handleMessage(MessageIn &msg) } int npcId = msg.readInt32(); - Event *event = 0; + Event *event = nullptr; switch (msg.getId()) { diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h index 71486a40..0a0cd130 100644 --- a/src/net/tmwa/npchandler.h +++ b/src/net/tmwa/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/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 4753dac1..b8d9c3c7 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -43,7 +43,7 @@ extern Net::PartyHandler *partyHandler; namespace TmwAthena { -PartyTab *partyTab = 0; +PartyTab *partyTab = nullptr; Party *taParty; PartyHandler::PartyHandler(): @@ -70,7 +70,7 @@ PartyHandler::PartyHandler(): PartyHandler::~PartyHandler() { delete partyTab; - partyTab = 0; + partyTab = nullptr; } void PartyHandler::handleMessage(MessageIn &msg) @@ -237,7 +237,7 @@ void PartyHandler::handleMessage(MessageIn &msg) if (partyTab) { delete partyTab; - partyTab = 0; + partyTab = nullptr; } socialWindow->removeTab(taParty); } @@ -248,7 +248,7 @@ void PartyHandler::handleMessage(MessageIn &msg) if (Being *b = actorSpriteManager->findBeing(id)) { - b->setParty(NULL); + b->setParty(nullptr); } taParty->removeMember(id); diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h index 9a3570a8..5268f395 100644 --- a/src/net/tmwa/partyhandler.h +++ b/src/net/tmwa/partyhandler.h @@ -36,37 +36,37 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler public: PartyHandler(); - ~PartyHandler(); + ~PartyHandler() override; - 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 mShareExp; } + PartyShare getShareExperience() override { return mShareExp; } - void setShareExperience(PartyShare share); + void setShareExperience(PartyShare share) override; - PartyShare getShareItems() { return mShareItems; } + PartyShare getShareItems() override { return mShareItems; } - void setShareItems(PartyShare share); + void setShareItems(PartyShare share) override; private: PartyShare mShareExp, mShareItems; diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index c598c5f9..6ef669e4 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -60,9 +60,9 @@ namespace { */ struct WeightListener : public gcn::ActionListener { - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { - weightNotice = NULL; + weightNotice = nullptr; } } weightListener; @@ -71,10 +71,10 @@ namespace { */ struct DeathListener : public gcn::ActionListener { - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { Net::getPlayerHandler()->respawn(); - deathNotice = NULL; + deathNotice = nullptr; BuyDialog::closeAll(); BuySellDialog::closeAll(); diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 2c4b6194..24284ee4 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -34,35 +34,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 false; } }; diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h index bb772ff1..f43c900e 100644 --- a/src/net/tmwa/specialhandler.h +++ b/src/net/tmwa/specialhandler.h @@ -34,15 +34,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 TmwAthena diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index a02056a4..2441d83a 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -51,9 +51,9 @@ ConfirmDialog *confirmDlg; namespace { struct RequestTradeListener : public gcn::ActionListener { - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { - confirmDlg = 0; + confirmDlg = nullptr; Net::getTradeHandler()->respond(event.getId() == "yes"); } } listener; @@ -77,7 +77,7 @@ TradeHandler::TradeHandler() }; handledMessages = _messages; tradeHandler = this; - confirmDlg = 0; + confirmDlg = nullptr; } diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h index 60ee4444..d4f2494f 100644 --- a/src/net/tmwa/tradehandler.h +++ b/src/net/tmwa/tradehandler.h @@ -34,23 +34,23 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler public: TradeHandler(); - void handleMessage(MessageIn &msg); + void handleMessage(MessageIn &msg) override; - 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 mTrading; diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h index 2bc3b316..d9596239 100644 --- a/src/net/worldinfo.h +++ b/src/net/worldinfo.h @@ -33,6 +33,6 @@ struct WorldInfo { std::string updateHost; }; -typedef std::vector<WorldInfo*> Worlds; +using Worlds = std::vector<WorldInfo *>; #endif // WORLD_INFO_H diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index d831d9ff..008f1daa 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -379,8 +379,8 @@ void OpenGLGraphics::drawImagePattern(Image *image, int x, int y, int w, int h) if (iw == 0 || ih == 0) return; - const float tw = static_cast<float>(image->getTextureWidth()); - const float th = static_cast<float>(image->getTextureHeight()); + const auto tw = static_cast<float>(image->getTextureWidth()); + const auto th = static_cast<float>(image->getTextureHeight()); glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha); @@ -528,8 +528,8 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, // Draw a set of textured rectangles if (image->getTextureType() == GL_TEXTURE_2D) { - const float tw = static_cast<float>(image->getTextureWidth()); - const float th = static_cast<float>(image->getTextureHeight()); + const auto tw = static_cast<float>(image->getTextureWidth()); + const auto th = static_cast<float>(image->getTextureHeight()); const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; @@ -706,7 +706,7 @@ SDL_Surface* OpenGLGraphics::getScreenshot() // Flip the screenshot, as OpenGL has 0,0 in bottom left unsigned int lineSize = 3 * w; - GLubyte* buf = (GLubyte*)malloc(lineSize); + auto* buf = (GLubyte*)malloc(lineSize); for (int i = 0; i < (h / 2); i++) { diff --git a/src/openglgraphics.h b/src/openglgraphics.h index 01bca360..d300dfd7 100644 --- a/src/openglgraphics.h +++ b/src/openglgraphics.h @@ -34,7 +34,7 @@ class OpenGLGraphics : public Graphics public: OpenGLGraphics(); - ~OpenGLGraphics(); + ~OpenGLGraphics() override; /** * Sets whether vertical refresh syncing is enabled. Takes effect @@ -53,15 +53,15 @@ class OpenGLGraphics : public Graphics void setReduceInputLag(bool reduceInputLag); bool getReduceInputLag() const { return mReduceInputLag; } - bool setVideoMode(int w, int h, bool fs); + bool setVideoMode(int w, int h, bool fs) override; - void videoResized(int w, int h); + void videoResized(int w, int h) override; bool drawImage(Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, - bool useColor); + bool useColor) override; /** * Draws a rescaled version of the image @@ -70,43 +70,43 @@ class OpenGLGraphics : public Graphics int dstX, int dstY, int width, int height, int desiredWidth, int desiredHeight, - bool useColor); + bool useColor) override; void drawImagePattern(Image *image, int x, int y, - int w, int h); + int w, int h) override; /** * Draw a pattern based on a rescaled version of the given image... */ void drawRescaledImagePattern(Image *image, int x, int y, int w, int h, - int scaledWidth, int scaledHeight); + int scaledWidth, int scaledHeight) override; - void updateScreen(); + void updateScreen() override; - void _beginDraw(); - void _endDraw(); + void _beginDraw() override; + void _endDraw() override; - bool pushClipArea(gcn::Rectangle area); - void popClipArea(); + bool pushClipArea(gcn::Rectangle area) override; + void popClipArea() override; - void setColor(const gcn::Color &color); + void setColor(const gcn::Color &color) override; - void drawPoint(int x, int y); + void drawPoint(int x, int y) override; - void drawLine(int x1, int y1, int x2, int y2); + void drawLine(int x1, int y1, int x2, int y2) override; void drawRectangle(const gcn::Rectangle &rect, bool filled); - void drawRectangle(const gcn::Rectangle &rect); + void drawRectangle(const gcn::Rectangle &rect) override; - void fillRectangle(const gcn::Rectangle &rect); + void fillRectangle(const gcn::Rectangle &rect) override; /** * Takes a screenshot and returns it as SDL surface. */ - SDL_Surface *getScreenshot(); + SDL_Surface *getScreenshot() override; static void bindTexture(GLenum target, GLuint texture); diff --git a/src/particle.cpp b/src/particle.cpp index f84bb2ed..64f25999 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -70,7 +70,7 @@ Particle::Particle(Map *map): mRandomness(0), mBounce(0.0f), mFollow(false), - mTarget(NULL), + mTarget(nullptr), mAcceleration(0.0f), mInvDieDistance(-1.0f), mMomentum(1.0f) @@ -195,11 +195,11 @@ bool Particle::update() // Update child emitters if ((mLifetimePast-1)%Particle::emitterSkip == 0) { - for (EmitterIterator e = mChildEmitters.begin(); + for (auto e = mChildEmitters.begin(); e != mChildEmitters.end(); e++) { Particles newParticles = (*e)->createParticles(mLifetimePast); - for (ParticleIterator p = newParticles.begin(); + for (auto p = newParticles.begin(); p != newParticles.end(); p++) { (*p)->moveBy(mPos); @@ -224,7 +224,7 @@ bool Particle::update() // Update child particles - for (ParticleIterator p = mChildParticles.begin(); + for (auto p = mChildParticles.begin(); p != mChildParticles.end();) { //move particle with its parent if desired @@ -254,7 +254,7 @@ bool Particle::update() void Particle::moveBy(const Vector &change) { mPos += change; - for (ParticleIterator p = mChildParticles.begin(); + for (auto p = mChildParticles.begin(); p != mChildParticles.end(); p++) { if ((*p)->doesFollow()) @@ -271,7 +271,7 @@ void Particle::moveTo(float x, float y) Particle *Particle::createChild() { - Particle *newParticle = new Particle(mMap); + auto *newParticle = new Particle(mMap); mChildParticles.push_back(newParticle); return newParticle; } @@ -279,7 +279,7 @@ Particle *Particle::createChild() Particle *Particle::addEffect(const std::string &particleEffectFile, int pixelX, int pixelY, int rotation) { - Particle *newParticle = NULL; + Particle *newParticle = nullptr; std::string::size_type pos = particleEffectFile.find('|'); std::string dyePalettes; @@ -292,7 +292,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "effect")) { logger->log("Error loading particle: %s", particleEffectFile.c_str()); - return NULL; + return nullptr; } ResourceManager *resman = ResourceManager::getInstance(); @@ -432,7 +432,7 @@ void Particle::adjustEmitterSize(int w, int h) { if (mAllowSizeAdjust) { - for (EmitterIterator e = mChildEmitters.begin(); + for (auto e = mChildEmitters.begin(); e != mChildEmitters.end(); e++) { (*e)->adjustSize(w, h); diff --git a/src/particle.h b/src/particle.h index 18deb5c7..24ab74ce 100644 --- a/src/particle.h +++ b/src/particle.h @@ -33,10 +33,10 @@ class Map; class Particle; class ParticleEmitter; -typedef std::list<Particle *> Particles; -typedef Particles::iterator ParticleIterator; -typedef std::list<ParticleEmitter *> Emitters; -typedef Emitters::iterator EmitterIterator; +using Particles = std::list<Particle *>; +using ParticleIterator = Particles::iterator; +using Emitters = std::list<ParticleEmitter *>; +using EmitterIterator = Emitters::iterator; /** * A particle spawned by a ParticleEmitter. @@ -68,7 +68,7 @@ class Particle : public Actor */ Particle(Map *map); - ~Particle(); + ~Particle() override; /** * Deletes all child particles and emitters. @@ -90,12 +90,12 @@ class Particle : public Actor /** * Draws the particle image. */ - virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const; + bool draw(Graphics *graphics, int offsetX, int offsetY) const override; /** * Do not draw particles when beind other objects */ - virtual bool drawnWhenBehind() const + bool drawnWhenBehind() const override { return false; } /** @@ -251,13 +251,13 @@ class Particle : public Actor { mAutoDelete = false; } /** We consider particles (at least for now) to be one layer-sprites */ - virtual int getNumberOfLayers() const + int getNumberOfLayers() const override { return 1; } - virtual float getAlpha() const + float getAlpha() const override { return 1.0f; } - virtual void setAlpha(float alpha) {} + void setAlpha(float alpha) override {} virtual void setDeathEffect(const std::string &effectFile, char conditions) { mDeathEffect = effectFile; mDeathEffectConditions = conditions; } diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index f48f1f44..002d4488 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -87,7 +87,7 @@ void ParticleList::removeLocally(Particle *particle) void ParticleList::clearLocally() { - for (std::list<Particle *>::iterator it = mElements.begin(); + for (auto it = mElements.begin(); it != mElements.end(); it++) (*it)->kill(); @@ -98,7 +98,7 @@ void ParticleList::moveTo(float x, float y) { ParticleContainer::moveTo(x, y); - for (std::list<Particle *>::iterator it = mElements.begin(); + for (auto it = mElements.begin(); it != mElements.end();) { (*it)->moveTo(x, y); @@ -145,7 +145,7 @@ void ParticleVector::delLocally(int index) Particle *p = mIndexedElements[index]; if (p) { - mIndexedElements[index] = NULL; + mIndexedElements[index] = nullptr; p->kill(); } } @@ -160,7 +160,7 @@ void ParticleVector::moveTo(float x, float y) { ParticleContainer::moveTo(x, y); - for (std::vector<Particle *>::iterator it = mIndexedElements.begin(); + for (auto it = mIndexedElements.begin(); it != mIndexedElements.end(); it++) { if (*it) diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index a8b22e97..ec646f97 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -43,7 +43,7 @@ ParticleEmitter::ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map, int rotation, const std::string& dyePalettes): mOutputPauseLeft(0), - mParticleImage(0) + mParticleImage(nullptr) { mMap = map; mParticleTarget = target; @@ -464,12 +464,12 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick) } else if (mParticleRotation.getLength() > 0) { - Animation *newAnimation = new Animation(mParticleRotation); + auto *newAnimation = new Animation(mParticleRotation); newParticle = new RotationalParticle(mMap, newAnimation); } else if (mParticleAnimation.getLength() > 0) { - Animation *newAnimation = new Animation(mParticleAnimation); + auto *newAnimation = new Animation(mParticleAnimation); newParticle = new AnimationParticle(mMap, newAnimation); } else @@ -506,7 +506,7 @@ std::list<Particle *> ParticleEmitter::createParticles(int tick) newParticle->setFadeIn(mParticleFadeIn.value(tick)); newParticle->setAlpha(mParticleAlpha.value(tick)); - for (std::list<ParticleEmitter>::iterator i = mParticleChildEmitters.begin(); + for (auto i = mParticleChildEmitters.begin(); i != mParticleChildEmitters.end(); i++) { diff --git a/src/party.cpp b/src/party.cpp index 126a63c1..cb9541e8 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -60,7 +60,7 @@ PartyMember *Party::addMember(int id, const std::string &name) PartyMember *Party::getMember(int id) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -71,12 +71,12 @@ PartyMember *Party::getMember(int id) const ++itr; } - return NULL; + return nullptr; } PartyMember *Party::getMember(const std::string &name) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -87,12 +87,12 @@ PartyMember *Party::getMember(const std::string &name) const ++itr; } - return NULL; + return nullptr; } void Party::removeMember(PartyMember *member) { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while(itr != itr_end) { @@ -109,7 +109,7 @@ void Party::removeMember(PartyMember *member) void Party::removeMember(int id) { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while(itr != itr_end) { @@ -125,7 +125,7 @@ void Party::removeMember(int id) void Party::removeMember(const std::string &name) { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while(itr != itr_end) { @@ -141,13 +141,13 @@ void Party::removeMember(const std::string &name) void Party::removeFromMembers() { - MemberList::iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while(itr != itr_end) { Being *b = actorSpriteManager->findBeing((*itr)->getID()); if (b) - b->setParty(NULL); + b->setParty(nullptr); ++itr; } } @@ -171,7 +171,7 @@ bool Party::isMember(PartyMember *member) const if (member->mParty != nullptr && member->mParty != this) return false; - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -188,7 +188,7 @@ bool Party::isMember(PartyMember *member) const bool Party::isMember(int id) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -204,7 +204,7 @@ bool Party::isMember(int id) const bool Party::isMember(const std::string &name) const { - MemberList::const_iterator itr = mMembers.begin(), + auto itr = mMembers.begin(), itr_end = mMembers.end(); while (itr != itr_end) { @@ -221,7 +221,7 @@ bool Party::isMember(const std::string &name) const void Party::getNames(std::vector<std::string> &names) const { names.clear(); - MemberList::const_iterator it = mMembers.begin(), + auto it = mMembers.begin(), it_end = mMembers.end(); while (it != it_end) { @@ -232,7 +232,7 @@ void Party::getNames(std::vector<std::string> &names) const Party *Party::getParty(int id) { - PartyMap::iterator it = parties.find(id); + auto it = parties.find(id); if (it != parties.end()) return it->second; diff --git a/src/party.h b/src/party.h index 90e9d784..ac421fd9 100644 --- a/src/party.h +++ b/src/party.h @@ -128,11 +128,11 @@ public: * Get size of members list. * @return Returns the number of members in the party. */ - int getNumberOfElements() { + int getNumberOfElements() override { return mMembers.size(); } - Avatar *getAvatarAt(int i); + Avatar *getAvatarAt(int i) override; /** * Get whether user can invite users to this party. @@ -156,7 +156,7 @@ public: static Party *getParty(int id); private: - typedef std::map<int, Party*> PartyMap; + using PartyMap = std::map<int, Party *>; static PartyMap parties; /** @@ -164,9 +164,9 @@ private: */ Party(short id); - ~Party(); + ~Party() override; - typedef std::vector<PartyMember*> MemberList; + using MemberList = std::vector<PartyMember *>; MemberList mMembers; std::string mName; short mId; diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 03c48340..22c01516 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -33,12 +33,12 @@ namespace PlayerInfo { class PlayerLogic; -static PlayerLogic *mListener = 0; +static PlayerLogic *mListener = nullptr; static PlayerInfoBackend mData; -static Inventory *mInventory = 0; -static Equipment *mEquipment = 0; +static Inventory *mInventory = nullptr; +static Equipment *mEquipment = nullptr; static bool mStorageCount = 0; @@ -63,7 +63,7 @@ void triggerAttr(int id, int old) void triggerStat(int id, const std::string &changed, int old1, int old2 = 0) { - StatMap::iterator it = mData.mStats.find(id); + auto it = mData.mStats.find(id); Event event(Event::UpdateStat); event.setInt("id", id); event.setInt("base", it->second.base); @@ -319,7 +319,7 @@ void logic() if ((mSpecialRechargeUpdateNeeded%11) == 0) { mSpecialRechargeUpdateNeeded = 0; - for (SpecialsMap::iterator it = mSpecials.begin(), + for (auto it = mSpecials.begin(), it_end = mSpecials.end(); it != it_end; it++) { it->second.currentMana += it->second.recharge; @@ -341,7 +341,7 @@ public: listen(Event::GameChannel); } - void event(Event::Channel channel, const Event &event) + void event(Event::Channel channel, const Event &event) override { if (channel == Event::ClientChannel) { @@ -351,7 +351,7 @@ public: if (newState == STATE_GAME) { - if (mInventory == 0) + if (mInventory == nullptr) { mInventory = new Inventory(Inventory::INVENTORY); mEquipment = new Equipment(); @@ -366,8 +366,8 @@ public: delete mInventory; delete mEquipment; - mInventory = 0; - mEquipment = 0; + mInventory = nullptr; + mEquipment = nullptr; } } } diff --git a/src/playerinfo.h b/src/playerinfo.h index e228ec7e..69434d5b 100644 --- a/src/playerinfo.h +++ b/src/playerinfo.h @@ -50,8 +50,8 @@ struct Stat int expNeed; }; -typedef std::map<int, int> IntMap; -typedef std::map<int, Stat> StatMap; +using IntMap = std::map<int, int>; +using StatMap = std::map<int, Stat>; /** * Backend for core player information. @@ -84,7 +84,7 @@ struct Special int recharge; }; -typedef std::map<int, Special> SpecialsMap; +using SpecialsMap = std::map<int, Special>; /** * A database like namespace which holds global info about the localplayer diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp index 47bc1913..f65b1fc7 100644 --- a/src/playerrelations.cpp +++ b/src/playerrelations.cpp @@ -40,26 +40,26 @@ class PlayerConfSerialiser : public ConfigurationListManager<std::pair<std::string, PlayerRelation *>, std::map<std::string, PlayerRelation *> *> { - virtual ConfigurationObject *writeConfigItem(std::pair<std::string, PlayerRelation *> value, - ConfigurationObject *cobj) + ConfigurationObject *writeConfigItem(std::pair<std::string, PlayerRelation *> value, + ConfigurationObject *cobj) override { if (!value.second) - return NULL; + return nullptr; cobj->setValue(NAME, value.first); cobj->setValue(RELATION, toString(value.second->mRelation)); return cobj; } - virtual std::map<std::string, PlayerRelation *> * + std::map<std::string, PlayerRelation *> * readConfigItem(ConfigurationObject *cobj, - std::map<std::string, PlayerRelation *> *container) + std::map<std::string, PlayerRelation *> *container) override { std::string name = cobj->getValue(NAME, ""); if (name.empty()) return container; - std::map<std::string, PlayerRelation *>::iterator it = + auto it = (*container).find(name); if (it != (*container).end()) { @@ -89,7 +89,7 @@ PlayerRelation::PlayerRelation(Relation relation) PlayerRelationsManager::PlayerRelationsManager() : mPersistIgnores(false), mDefaultPermissions(PlayerRelation::DEFAULT), - mIgnoreStrategy(0) + mIgnoreStrategy(nullptr) { } @@ -187,7 +187,7 @@ unsigned int PlayerRelationsManager::checkPermissionSilently( const std::string &playerName, unsigned int flags) { - PlayerRelation *r = 0; + PlayerRelation *r = nullptr; std::map<std::string, PlayerRelation *>::const_iterator it = mRelations.find(playerName); @@ -247,9 +247,9 @@ bool PlayerRelationsManager::hasPermission(const std::string &name, void PlayerRelationsManager::setRelation(const std::string &playerName, PlayerRelation::Relation relation) { - PlayerRelation *r = 0; + PlayerRelation *r = nullptr; - std::map<std::string, PlayerRelation *>::iterator it = + auto it = mRelations.find(playerName); if (it != mRelations.end()) r = it->second; @@ -263,9 +263,9 @@ void PlayerRelationsManager::setRelation(const std::string &playerName, std::vector<std::string> * PlayerRelationsManager::getPlayers() const { - std::vector<std::string> *retval = new std::vector<std::string>(); + auto *retval = new std::vector<std::string>(); - for (std::map<std::string, PlayerRelation *>::const_iterator it = mRelations.begin(); it != mRelations.end(); it++) + for (auto it = mRelations.begin(); it != mRelations.end(); it++) if (it->second) retval->push_back(it->first); @@ -276,7 +276,7 @@ std::vector<std::string> * PlayerRelationsManager::getPlayers() const void PlayerRelationsManager::removePlayer(const std::string &name) { - std::map<std::string, PlayerRelation *>::iterator it = + auto it = mRelations.find(name); if (it != mRelations.end()) { @@ -291,7 +291,7 @@ void PlayerRelationsManager::removePlayer(const std::string &name) PlayerRelation::Relation PlayerRelationsManager::getRelation(const std::string &name) const { - std::map<std::string, PlayerRelation *>::const_iterator it = mRelations.find(name); + auto it = mRelations.find(name); if (it != mRelations.end()) return it->second->mRelation; @@ -328,7 +328,7 @@ public: mShortName = PLAYER_IGNORE_STRATEGY_NOP; } - virtual void ignore(Being *being, unsigned int flags) + void ignore(Being *being, unsigned int flags) override { } }; @@ -342,7 +342,7 @@ public: mShortName = "dotdotdot"; } - virtual void ignore(Being *being, unsigned int flags) + void ignore(Being *being, unsigned int flags) override { being->setSpeech("...", 500); } @@ -358,7 +358,7 @@ public: mShortName = "blinkname"; } - virtual void ignore(Being *being, unsigned int flags) + void ignore(Being *being, unsigned int flags) override { being->flashName(200); } diff --git a/src/position.cpp b/src/position.cpp index f41f2c4f..64cf2225 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -29,7 +29,7 @@ std::ostream& operator <<(std::ostream &os, const Position &p) std::ostream& operator <<(std::ostream &os, const Path &path) { - Path::const_iterator i = path.begin(), i_end = path.end(); + auto i = path.begin(), i_end = path.end(); os << "("; while (i != i_end) diff --git a/src/position.h b/src/position.h index af36dd81..4622b8ed 100644 --- a/src/position.h +++ b/src/position.h @@ -38,8 +38,8 @@ struct Position int y; }; -typedef std::list<Position> Path; -typedef Path::iterator PathIterator; +using Path = std::list<Position>; +using PathIterator = Path::iterator; /** * Appends a string representation of a position to the output stream. diff --git a/src/properties.h b/src/properties.h index 59318b80..40be8d7f 100644 --- a/src/properties.h +++ b/src/properties.h @@ -45,7 +45,7 @@ class Properties std::string getProperty(const std::string &name, const std::string &def = "") const { - PropertyMap::const_iterator i = mProperties.find(name); + auto i = mProperties.find(name); return (i != mProperties.end()) ? i->second : def; } @@ -59,7 +59,7 @@ class Properties */ float getFloatProperty(const std::string &name, float def = 0.0f) const { - PropertyMap::const_iterator i = mProperties.find(name); + auto i = mProperties.find(name); float ret = def; if (i != mProperties.end()) { @@ -80,7 +80,7 @@ class Properties */ bool getBoolProperty(const std::string &name, bool def = false) const { - PropertyMap::const_iterator i = mProperties.find(name); + auto i = mProperties.find(name); bool ret = def; if (i != mProperties.end()) { @@ -116,7 +116,7 @@ class Properties } private: - typedef std::map<std::string, std::string> PropertyMap; + using PropertyMap = std::map<std::string, std::string>; PropertyMap mProperties; }; diff --git a/src/resources/action.cpp b/src/resources/action.cpp index bfc130c8..c35498a4 100644 --- a/src/resources/action.cpp +++ b/src/resources/action.cpp @@ -36,7 +36,7 @@ Action::~Action() Animation *Action::getAnimation(int direction) const { - Animations::const_iterator i = mAnimations.find(direction); + auto i = mAnimations.find(direction); // When the given direction is not available, return the first one. // (either DEFAULT, or more usually DOWN). diff --git a/src/resources/action.h b/src/resources/action.h index 1d85bf62..bf229abd 100644 --- a/src/resources/action.h +++ b/src/resources/action.h @@ -43,8 +43,8 @@ class Action Animation *getAnimation(int direction) const; protected: - typedef std::map<int, Animation*> Animations; - typedef Animations::iterator AnimationIterator; + using Animations = std::map<int, Animation *>; + using AnimationIterator = Animations::iterator; Animations mAnimations; }; diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index e4837e44..8ab7cc44 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -37,10 +37,10 @@ void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY) void Animation::addTerminator() { - addFrame(NULL, 0, 0, 0); + addFrame(nullptr, 0, 0, 0); } bool Animation::isTerminator(const Frame &candidate) { - return (candidate.image == NULL); + return (candidate.image == nullptr); } diff --git a/src/resources/attributes.cpp b/src/resources/attributes.cpp index 58bff6f1..82871b2f 100644 --- a/src/resources/attributes.cpp +++ b/src/resources/attributes.cpp @@ -40,7 +40,7 @@ namespace Attributes { - typedef struct + using Attribute = struct { unsigned int id; std::string name; @@ -51,14 +51,14 @@ namespace Attributes { std::string scope; /** The playerInfo core Id the attribute is linked with or -1 if not */ int playerInfoId; - } Attribute; + }; /** Map for attributes. */ - typedef std::map<unsigned int, Attribute> AttributeMap; + using AttributeMap = std::map<unsigned int, Attribute>; static AttributeMap attributes; /** tags = effects on attributes. */ - typedef std::map< std::string, std::string > TagMap; + using TagMap = std::map<std::string, std::string>; static TagMap tags; /** List of modifiable attribute names used at character's creation. */ @@ -355,7 +355,7 @@ namespace Attributes { fillLabels(); // Sanity checks on starting points - float modifiableAttributeCount = (float) attributeLabels.size(); + auto modifiableAttributeCount = (float) attributeLabels.size(); float averageValue = ((float) creationPoints) / modifiableAttributeCount; if (averageValue > attributeMaximum || averageValue < attributeMinimum || creationPoints < 1) diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 5a277770..539254ac 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -86,20 +86,20 @@ const std::string &BeingInfo::getSound(SoundEvent event) const { static const std::string empty; - SoundEvents::const_iterator i = mSounds.find(event); + auto i = mSounds.find(event); return (i == mSounds.end()) ? empty : i->second->at(rand() % i->second->size()); } const Attack *BeingInfo::getAttack(int id) const { - static Attack *empty = new Attack(SpriteAction::ATTACK, + static auto *empty = new Attack(SpriteAction::ATTACK, -1, // Default strike effect on monster paths.getIntValue("hitEffectId"), paths.getIntValue("criticalHitEffectId"), std::string()); - Attacks::const_iterator it = mAttacks.find(id); + auto it = mAttacks.find(id); return (it == mAttacks.end()) ? empty : it->second; } @@ -107,7 +107,7 @@ void BeingInfo::addAttack(int id, std::string action, int effectId, int hitEffectId, int criticalHitEffectId, const std::string &missileParticleFilename) { - Attacks::iterator it = mAttacks.find(id); + auto it = mAttacks.find(id); if (it != mAttacks.end()) delete it->second; diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index b2cae5e2..3fa5b8b6 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -47,7 +47,7 @@ struct Attack { } }; -typedef std::map<int, Attack*> Attacks; +using Attacks = std::map<int, Attack *>; enum SoundEvent { @@ -57,7 +57,7 @@ enum SoundEvent SOUND_EVENT_DIE }; -typedef std::map<SoundEvent, std::vector<std::string>* > SoundEvents; +using SoundEvents = std::map<SoundEvent, std::vector<std::string> *>; /** * Holds information about a certain type of monster. This includes the name @@ -128,7 +128,7 @@ class BeingInfo Map::BlockType mBlockType; }; -typedef std::map<int, BeingInfo*> BeingInfos; -typedef BeingInfos::iterator BeingInfoIterator; +using BeingInfos = std::map<int, BeingInfo *>; +using BeingInfoIterator = BeingInfos::iterator; #endif // BEINGINFO_H diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 4e4016e4..ba2ad4b5 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -179,7 +179,7 @@ void DyePalette::getColor(double intensity, int color[3]) const Dye::Dye(const std::string &description) { for (int i = 0; i < 7; ++i) - mDyePalettes[i] = 0; + mDyePalettes[i] = nullptr; if (description.empty()) return; diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 04dd4bbb..fde7030a 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -60,7 +60,7 @@ void EmoteDB::readEmoteNode(xmlNodePtr node, const std::string &filename) return; } - Emote *currentEmote = new Emote; + auto *currentEmote = new Emote; currentEmote->name = XML::getProperty(node, "name", "unknown"); currentEmote->effect = XML::getProperty(node, "effectid", -1); diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h index 33195d82..cdcb5cf6 100644 --- a/src/resources/emotedb.h +++ b/src/resources/emotedb.h @@ -36,7 +36,7 @@ struct Emote int effect; }; -typedef std::map<int, Emote*> Emotes; +using Emotes = std::map<int, Emote *>; /** * Emote information database. @@ -55,7 +55,7 @@ namespace EmoteDB int getLast(); - typedef Emotes::iterator EmotesIterator; + using EmotesIterator = Emotes::iterator; } #endif // EMOTE_DB_H diff --git a/src/resources/hairdb.cpp b/src/resources/hairdb.cpp index 2e9747a2..4ca4fa5c 100644 --- a/src/resources/hairdb.cpp +++ b/src/resources/hairdb.cpp @@ -96,7 +96,7 @@ const std::string &HairDB::getHairColor(int id) std::vector<int> HairDB::getHairStyleIds(int maxId) const { std::vector<int> hairStylesIds; - for (HairStylesConstIterator it = mHairStyles.begin(), + for (auto it = mHairStyles.begin(), it_end = mHairStyles.end(); it != it_end; ++it) { // Don't give ids higher than the requested maximum. @@ -110,7 +110,7 @@ std::vector<int> HairDB::getHairStyleIds(int maxId) const std::vector<int> HairDB::getHairColorIds(int maxId) const { std::vector<int> hairColorsIds; - for (ColorConstIterator it = mHairColors.begin(), + for (auto it = mHairColors.begin(), it_end = mHairColors.end(); it != it_end; ++it) { // Don't give ids higher than the requested maximum. diff --git a/src/resources/hairdb.h b/src/resources/hairdb.h index 502d7c21..48354243 100644 --- a/src/resources/hairdb.h +++ b/src/resources/hairdb.h @@ -88,14 +88,14 @@ class HairDB void loadHairStylesNode(xmlNodePtr stylesNode); // Hair colors Db - typedef std::map<int, std::string> Colors; - typedef Colors::iterator ColorIterator; - typedef Colors::const_iterator ColorConstIterator; + using Colors = std::map<int, std::string>; + using ColorIterator = Colors::iterator; + using ColorConstIterator = Colors::const_iterator; Colors mHairColors; - typedef std::set<int> HairStyles; - typedef HairStyles::iterator HairStylesIterator; - typedef HairStyles::const_iterator HairStylesConstIterator; + using HairStyles = std::set<int>; + using HairStylesIterator = HairStyles::iterator; + using HairStylesConstIterator = HairStyles::const_iterator; HairStyles mHairStyles; bool mLoaded; diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 6f2609b0..c05b03aa 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -69,7 +69,7 @@ Image::Image(SDL_Texture *texture, int width, int height): #ifdef USE_OPENGL Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight): mAlpha(1.0f), - mTexture(0), + mTexture(nullptr), mGLImage(glimage), mTexWidth(texWidth), mTexHeight(texHeight) @@ -102,7 +102,7 @@ Resource *Image::load(SDL_RWops *rw) if (!tmpImage) { logger->log("Error, image load failed: %s", IMG_GetError()); - return NULL; + return nullptr; } Image *image = load(tmpImage); @@ -118,11 +118,11 @@ Resource *Image::load(SDL_RWops *rw, Dye const &dye) if (!tmpImage) { logger->log("Error, image load failed: %s", IMG_GetError()); - return NULL; + return nullptr; } SDL_PixelFormat rgba; - rgba.palette = NULL; + rgba.palette = nullptr; rgba.BitsPerPixel = 32; rgba.BytesPerPixel = 4; rgba.Rmask = 0xFF000000; rgba.Rloss = 0; rgba.Rshift = 24; @@ -133,7 +133,7 @@ Resource *Image::load(SDL_RWops *rw, Dye const &dye) SDL_Surface *surf = SDL_ConvertSurface(tmpImage, &rgba, 0); SDL_FreeSurface(tmpImage); - Uint32 *pixels = static_cast< Uint32 * >(surf->pixels); + auto *pixels = static_cast< Uint32 * >(surf->pixels); for (Uint32 *p_end = pixels + surf->w * surf->h; pixels != p_end; ++pixels) { int alpha = *pixels & 255; @@ -167,7 +167,7 @@ void Image::unload() if (mTexture) { SDL_DestroyTexture(mTexture); - mTexture = NULL; + mTexture = nullptr; } #ifdef USE_OPENGL @@ -210,7 +210,7 @@ void Image::setAlpha(float alpha) Image *Image::_SDLload(SDL_Surface *image) { if (!image || !mRenderer) - return NULL; + return nullptr; SDL_Texture *texture = SDL_CreateTextureFromSurface(mRenderer, image); return new Image(texture, image->w, image->h); @@ -269,12 +269,12 @@ Image *Image::_GLload(SDL_Surface *image) if (!image) { logger->log("Error, image convert failed: out of memory"); - return NULL; + return nullptr; } // Make sure the alpha channel is not used, but copied to destination SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE); - SDL_BlitSurface(oldImage, NULL, image, NULL); + SDL_BlitSurface(oldImage, nullptr, image, nullptr); } GLuint texture; @@ -325,7 +325,7 @@ Image *Image::_GLload(SDL_Surface *image) break; } logger->log("Error: Image GL import failed: %s", errmsg.c_str()); - return NULL; + return nullptr; } return new Image(texture, width, height, realWidth, realHeight); diff --git a/src/resources/image.h b/src/resources/image.h index efe2262e..66c3ff78 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -51,7 +51,7 @@ class Image : public Resource #endif public: - virtual ~Image(); + ~Image() override; /** * Loads an image from an SDL_RWops structure. @@ -224,7 +224,7 @@ class SubImage : public Image int width, int height, int texWidth, int textHeight); #endif - ~SubImage(); + ~SubImage() override; private: Image *mParent; diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 9fe75395..74b4034f 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -53,7 +53,7 @@ Image* ImageSet::get(size_type i) const if (i >= mImages.size()) { logger->log("Warning: No sprite %d in this image set", (int) i); - return NULL; + return nullptr; } else { diff --git a/src/resources/imageset.h b/src/resources/imageset.h index 5d9bdc2e..c73e7e37 100644 --- a/src/resources/imageset.h +++ b/src/resources/imageset.h @@ -39,7 +39,7 @@ class ImageSet : public Resource */ ImageSet(Image *img, int w, int h, int margin = 0, int spacing = 0); - ~ImageSet(); + ~ImageSet() override; /** * Returns the width of the images in the image set. @@ -51,7 +51,7 @@ class ImageSet : public Resource */ int getHeight() const { return mHeight; } - typedef std::vector<Image*>::size_type size_type; + using size_type = std::vector<Image *>::size_type; Image* get(size_type i) const; size_type size() const { return mImages.size(); } diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index 7257e1b9..ddf1fbee 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -39,7 +39,7 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename) if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface); - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr); if (!png_ptr) { logger->log("Had trouble creating png_structp"); @@ -49,14 +49,14 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename) info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); + png_destroy_write_struct(&png_ptr, (png_infopp)nullptr); logger->log("Could not create png_info"); return false; } if (setjmp(png_jmpbuf(png_ptr))) { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); + png_destroy_write_struct(&png_ptr, (png_infopp)nullptr); logger->log("problem writing to %s", filename.c_str()); return false; } @@ -100,7 +100,7 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename) delete [] row_pointers; - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); + png_destroy_write_struct(&png_ptr, (png_infopp)nullptr); if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface); diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 8c1a8d15..225bdb71 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -180,7 +180,7 @@ void ItemDB::unload() logger->log("Unloading item database..."); delete mUnknown; - mUnknown = NULL; + mUnknown = nullptr; delete_all(mItemInfos); mItemInfos.clear(); @@ -330,7 +330,7 @@ void TaItemDB::init() void TaItemDB::readItemNode(xmlNodePtr node, const std::string &filename) { - TaItemInfo *itemInfo = new TaItemInfo; + auto *itemInfo = new TaItemInfo; loadCommonRef(itemInfo, node, filename); @@ -348,7 +348,7 @@ void TaItemDB::readItemNode(xmlNodePtr node, const std::string &filename) continue; effect.push_back(strprintf(gettext(fields[i][1]), value)); } - for (std::list<ItemStat>::iterator it = extraStats.begin(); + for (auto it = extraStats.begin(); it != extraStats.end(); it++) { int value = XML::getProperty(node, it->mTag.c_str(), 0); @@ -421,7 +421,7 @@ void ManaServItemDB::init() void ManaServItemDB::readItemNode(xmlNodePtr node, const std::string &filename) { - ManaServItemInfo *itemInfo = new ManaServItemInfo; + auto *itemInfo = new ManaServItemInfo; loadCommonRef(itemInfo, node, filename); diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 2f19339d..016e6194 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -74,7 +74,7 @@ class ItemDB { public: ItemDB() : - mUnknown(0), + mUnknown(nullptr), mLoaded(false) {} @@ -147,8 +147,8 @@ class ItemDB void loadFloorSprite(SpriteDisplay *display, xmlNodePtr node); // Items database - typedef std::map<int, ItemInfo*> ItemInfos; - typedef std::map<std::string, ItemInfo*> NamedItemInfos; + using ItemInfos = std::map<int, ItemInfo *>; + using NamedItemInfos = std::map<std::string, ItemInfo *>; ItemInfos mItemInfos; NamedItemInfos mNamedItemInfos; @@ -167,14 +167,14 @@ class TaItemDB: public ItemDB TaItemDB() : ItemDB() { } - ~TaItemDB() + ~TaItemDB() override { unload(); } - virtual void init(); + void init() override; - virtual void readItemNode(xmlNodePtr node, const std::string &filename); + void readItemNode(xmlNodePtr node, const std::string &filename) override; - virtual void checkStatus(); + void checkStatus() override; private: /** * Check items id specific hard limits and log errors found. @@ -183,7 +183,7 @@ class TaItemDB: public ItemDB void checkHairWeaponsRacesSpecialIds() {} - void checkItemInfo(ItemInfo* itemInfo); + void checkItemInfo(ItemInfo* itemInfo) override; }; } // namespace TmwAthena @@ -201,17 +201,17 @@ class ManaServItemDB: public ItemDB ManaServItemDB() : ItemDB() { } - ~ManaServItemDB() + ~ManaServItemDB() override { unload(); } - virtual void init(); + void init() override; - virtual void readItemNode(xmlNodePtr node, const std::string &filename); + void readItemNode(xmlNodePtr node, const std::string &filename) override; - virtual void checkStatus(); + void checkStatus() override; private: - void checkItemInfo(ItemInfo* itemInfo); + void checkItemInfo(ItemInfo* itemInfo) override; }; } // namespace ManaServ diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 3583bb27..9e7fd6b7 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -34,7 +34,7 @@ const std::string &ItemInfo::getSprite(Gender gender) const else { static const std::string empty; - std::map<int, std::string>::const_iterator i = + auto i = mAnimationFiles.find(gender); return (i != mAnimationFiles.end()) ? i->second : empty; diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index b2642ae8..af41da12 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -68,7 +68,7 @@ static std::string resolveRelativePath(std::string base, std::string relative) Map *MapReader::readMap(const std::string &filename) { logger->log("Attempting to read map %s", filename.c_str()); - Map *map = NULL; + Map *map = nullptr; XML::Document doc(filename); @@ -111,7 +111,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path) logger->log("MapReader: Warning: " "Unitialized tile width or height value for map: %s", path.c_str()); - return 0; + return nullptr; } Map *map = new Map(w, h, tilew, tileh); @@ -237,7 +237,7 @@ static void setTile(Map *map, MapLayer *layer, int x, int y, unsigned gid) if (layer) { // Set regular tile on a layer - Image * const img = set ? set->get(gid - set->getFirstGid()) : 0; + Image * const img = set ? set->get(gid - set->getFirstGid()) : nullptr; layer->setTile(x, y, img); } else @@ -261,7 +261,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) const bool isFringeLayer = (name.substr(0,6) == "fringe"); const bool isCollisionLayer = (name.substr(0,9) == "collision"); - MapLayer *layer = 0; + MapLayer *layer = nullptr; if (!isCollisionLayer) { @@ -300,7 +300,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map) continue; int len = strlen((const char*)dataChild->content) + 1; - unsigned char *charData = new unsigned char[len + 1]; + auto *charData = new unsigned char[len + 1]; const char *charStart = (const char*) xmlNodeGetContent(dataChild); unsigned char *charIndex = charData; @@ -440,8 +440,8 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, unsigned firstGid = XML::getProperty(node, "firstgid", 0); int margin = XML::getProperty(node, "margin", 0); int spacing = XML::getProperty(node, "spacing", 0); - XML::Document* doc = NULL; - Tileset *set = NULL; + XML::Document* doc = nullptr; + Tileset *set = nullptr; std::string pathDir(path); if (xmlHasProp(node, BAD_CAST "source")) @@ -507,7 +507,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, // create animation if (!set) continue; - Animation *ani = new Animation; + auto *ani = new Animation; for (int i = 0; ;i++) { std::map<std::string, int>::iterator iFrame, iDelay; diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 8415b6ae..5fd74c24 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -63,7 +63,7 @@ void MonsterDB::init() */ void MonsterDB::readMonsterNode(xmlNodePtr node, const std::string &filename) { - BeingInfo *currentInfo = new BeingInfo; + auto *currentInfo = new BeingInfo; currentInfo->setWalkMask(Map::BLOCKMASK_WALL | Map::BLOCKMASK_CHARACTER @@ -171,7 +171,7 @@ void MonsterDB::unload() BeingInfo *MonsterDB::get(int id) { - BeingInfoIterator i = mMonsterInfos.find(id); + auto i = mMonsterInfos.find(id); if (i == mMonsterInfos.end()) { diff --git a/src/resources/music.cpp b/src/resources/music.cpp index 73ef2f85..c6760865 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -49,7 +49,7 @@ Resource *Music::load(SDL_RWops *rw) } #else SDL_FreeRW(rw); - return 0; + return nullptr; #endif } diff --git a/src/resources/music.h b/src/resources/music.h index d370f0a5..0c445b2b 100644 --- a/src/resources/music.h +++ b/src/resources/music.h @@ -32,7 +32,7 @@ class Music : public Resource { public: - virtual ~Music(); + ~Music() override; /** * Loads a music from a buffer in memory. diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 7d0f72b0..fa12eced 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -52,7 +52,7 @@ void NPCDB::readNPCNode(xmlNodePtr node, const std::string &filename) return; } - BeingInfo *currentInfo = new BeingInfo; + auto *currentInfo = new BeingInfo; currentInfo->setTargetCursorSize(XML::getProperty(node, "targetCursor", "medium")); @@ -94,7 +94,7 @@ void NPCDB::unload() BeingInfo *NPCDB::get(int id) { - BeingInfoIterator i = mNPCInfos.find(id); + auto i = mNPCInfos.find(id); if (i == mNPCInfos.end()) { diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index a9e7e565..46e1ab30 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -43,7 +43,7 @@ #include <sys/time.h> -ResourceManager *ResourceManager::instance = NULL; +ResourceManager *ResourceManager::instance = nullptr; ResourceManager::ResourceManager() : mOldestOrphan(0) @@ -56,13 +56,13 @@ ResourceManager::~ResourceManager() mResources.insert(mOrphanedResources.begin(), mOrphanedResources.end()); // Release any remaining spritedefs first because they depend on image sets - ResourceIterator iter = mResources.begin(); + auto iter = mResources.begin(); while (iter != mResources.end()) { - if (dynamic_cast<SpriteDef*>(iter->second) != 0) + if (dynamic_cast<SpriteDef*>(iter->second) != nullptr) { cleanUp(iter->second); - ResourceIterator toErase = iter; + auto toErase = iter; ++iter; mResources.erase(toErase); } @@ -76,10 +76,10 @@ ResourceManager::~ResourceManager() iter = mResources.begin(); while (iter != mResources.end()) { - if (dynamic_cast<ImageSet*>(iter->second) != 0) + if (dynamic_cast<ImageSet*>(iter->second) != nullptr) { cleanUp(iter->second); - ResourceIterator toErase = iter; + auto toErase = iter; ++iter; mResources.erase(toErase); } @@ -115,7 +115,7 @@ void ResourceManager::cleanUp(Resource *res) void ResourceManager::cleanOrphans() { timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); // Delete orphaned resources after 30 seconds. time_t oldest = tv.tv_sec; time_t threshold = oldest - 30; @@ -123,7 +123,7 @@ void ResourceManager::cleanOrphans() if (mOrphanedResources.empty() || mOldestOrphan >= threshold) return; - ResourceIterator iter = mOrphanedResources.begin(); + auto iter = mOrphanedResources.begin(); while (iter != mOrphanedResources.end()) { Resource *res = iter->second; @@ -137,7 +137,7 @@ void ResourceManager::cleanOrphans() else { logger->log("ResourceManager::release(%s)", res->mIdPath.c_str()); - ResourceIterator toErase = iter; + auto toErase = iter; ++iter; mOrphanedResources.erase(toErase); delete res; // delete only after removal from list, to avoid issues in recursion @@ -239,20 +239,20 @@ bool ResourceManager::addResource(const std::string &idPath, Resource *ResourceManager::get(const std::string &idPath) { - ResourceIterator resIter = mResources.find(idPath); + auto resIter = mResources.find(idPath); if (resIter != mResources.end()) { resIter->second->incRef(); return resIter->second; } - return 0; + return nullptr; } Resource *ResourceManager::get(const std::string &idPath, generator fun, void *data) { // Check if the id exists, and return the value if it does. - ResourceIterator resIter = mResources.find(idPath); + auto resIter = mResources.find(idPath); if (resIter != mResources.end()) { resIter->second->incRef(); @@ -291,10 +291,10 @@ struct ResourceLoader static Resource *load(void *v) { - ResourceLoader *l = static_cast< ResourceLoader * >(v); + auto *l = static_cast< ResourceLoader * >(v); SDL_RWops *rw = PHYSFSRWOPS_openRead(l->path.c_str()); if (!rw) - return NULL; + return nullptr; Resource *res = l->fun(rw); return res; } @@ -322,10 +322,10 @@ struct DyedImageLoader std::string path; static Resource *load(void *v) { - DyedImageLoader *l = static_cast< DyedImageLoader * >(v); + auto *l = static_cast< DyedImageLoader * >(v); std::string path = l->path; std::string::size_type p = path.find('|'); - Dye *d = NULL; + Dye *d = nullptr; if (p != std::string::npos) { d = new Dye(path.substr(p + 1)); @@ -335,7 +335,7 @@ struct DyedImageLoader if (!rw) { delete d; - return NULL; + return nullptr; } Resource *res = d ? Image::load(rw, *d) : Image::load(rw); @@ -357,10 +357,10 @@ struct ImageSetLoader int w, h; static Resource *load(void *v) { - ImageSetLoader *l = static_cast< ImageSetLoader * >(v); + auto *l = static_cast< ImageSetLoader * >(v); Image *img = l->manager->getImage(l->path); - if (!img) return NULL; - ImageSet *res = new ImageSet(img, l->w, l->h); + if (!img) return nullptr; + auto *res = new ImageSet(img, l->w, l->h); img->decRef(); return res; } @@ -381,7 +381,7 @@ struct SpriteDefLoader int variant; static Resource *load(void *v) { - SpriteDefLoader *l = static_cast< SpriteDefLoader * >(v); + auto *l = static_cast< SpriteDefLoader * >(v); return SpriteDef::load(l->path, l->variant); } }; @@ -396,13 +396,13 @@ SpriteDef *ResourceManager::getSprite(const std::string &path, int variant) void ResourceManager::release(Resource *res) { - ResourceIterator resIter = mResources.find(res->mIdPath); + auto resIter = mResources.find(res->mIdPath); // The resource has to exist assert(resIter != mResources.end() && resIter->second == res); timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); time_t timestamp = tv.tv_sec; res->mTimeStamp = timestamp; @@ -429,7 +429,7 @@ ResourceManager *ResourceManager::getInstance() void ResourceManager::deleteInstance() { delete instance; - instance = NULL; + instance = nullptr; } void *ResourceManager::loadFile(const std::string &filename, int &filesize, @@ -439,11 +439,11 @@ void *ResourceManager::loadFile(const std::string &filename, int &filesize, PHYSFS_file *file = PHYSFS_openRead(filename.c_str()); // If the handler is an invalid pointer indicate failure - if (file == NULL) + if (file == nullptr) { logger->log("Warning: Failed to load %s: %s", filename.c_str(), PHYSFS_getLastError()); - return NULL; + return nullptr; } // Log the real dir of the file @@ -471,11 +471,11 @@ void *ResourceManager::loadFile(const std::string &filename, int &filesize, inflateMemory((unsigned char*) buffer, filesize, inflated); free(buffer); - if (inflated == NULL) + if (inflated == nullptr) { logger->log("Could not decompress file: %s", filename.c_str()); - return NULL; + return nullptr; } filesize = inflatedSize; @@ -539,7 +539,7 @@ std::vector<std::string> ResourceManager::loadTextFile( SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename) { - SDL_Surface *surface = 0; + SDL_Surface *surface = nullptr; if (SDL_RWops *rw = PHYSFSRWOPS_openRead(filename.c_str())) surface = IMG_Load_RW(rw, 1); return surface; @@ -552,7 +552,7 @@ void ResourceManager::scheduleDelete(SDL_Surface* surface) void ResourceManager::clearScheduled() { - for (std::set<SDL_Surface*>::iterator i = mDeletedSurfaces.begin(), + for (auto i = mDeletedSurfaces.begin(), i_end = mDeletedSurfaces.end(); i != i_end; ++i) { SDL_FreeSurface(*i); diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 5abc81e2..a087082d 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -47,8 +47,8 @@ class ResourceManager public: - typedef Resource *(*loader)(SDL_RWops *); - typedef Resource *(*generator)(void *); + using loader = Resource *(*)(SDL_RWops *); + using generator = Resource *(*)(void *); ResourceManager(); @@ -249,8 +249,8 @@ class ResourceManager void cleanOrphans(); static ResourceManager *instance; - typedef std::map<std::string, Resource*> Resources; - typedef Resources::iterator ResourceIterator; + using Resources = std::map<std::string, Resource *>; + using ResourceIterator = Resources::iterator; std::set<SDL_Surface*> mDeletedSurfaces; Resources mResources; Resources mOrphanedResources; diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index d1b0227b..782d79d1 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -40,7 +40,7 @@ Resource *SoundEffect::load(SDL_RWops *rw) else { logger->log("Error, failed to load sound effect: %s", Mix_GetError()); - return NULL; + return nullptr; } } diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 38d58681..eada80b5 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -32,7 +32,7 @@ class SoundEffect : public Resource { public: - virtual ~SoundEffect(); + ~SoundEffect() override; /** * Loads a sample from a buffer in memory. diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 6601b586..b72c059f 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -55,7 +55,7 @@ void SpecialDB::readSpecialSetNode(xmlNodePtr node, const std::string &filename) { if (xmlStrEqual(special->name, BAD_CAST "special")) { - SpecialInfo *info = new SpecialInfo(); + auto *info = new SpecialInfo(); int id = XML::getProperty(special, "id", 0); info->id = id; info->set = setName; @@ -98,16 +98,16 @@ void SpecialDB::unload() SpecialInfo *SpecialDB::get(int id) { - SpecialInfos::iterator i = mSpecialInfos.find(id); + auto i = mSpecialInfos.find(id); if (i == mSpecialInfos.end()) { - return NULL; + return nullptr; } else { return i->second; } - return NULL; + return nullptr; } diff --git a/src/resources/specialdb.h b/src/resources/specialdb.h index f6987b71..71aae0ba 100644 --- a/src/resources/specialdb.h +++ b/src/resources/specialdb.h @@ -65,6 +65,6 @@ namespace SpecialDB SpecialInfo::TargetMode targetModeFromString(const std::string& str); } -typedef std::map<int, SpecialInfo *> SpecialInfos; +using SpecialInfos = std::map<int, SpecialInfo *>; #endif diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index 7ccf1ff6..f33ade55 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -41,12 +41,12 @@ std::set<std::string> processedFiles; Action *SpriteDef::getAction(const std::string &action) const { - Actions::const_iterator i = mActions.find(action); + auto i = mActions.find(action); if (i == mActions.end()) { logger->log("Warning: no action \"%s\" defined!", action.c_str()); - return NULL; + return nullptr; } return i->second; @@ -77,11 +77,11 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant) } else { - return NULL; + return nullptr; } } - SpriteDef *def = new SpriteDef; + auto *def = new SpriteDef; def->loadSprite(rootNode, variant, palettes); def->substituteActions(); return def; @@ -91,7 +91,7 @@ void SpriteDef::substituteAction(std::string complete, std::string with) { if (mActions.find(complete) == mActions.end()) { - Actions::iterator i = mActions.find(with); + auto i = mActions.find(with); if (i != mActions.end()) { mActions[complete] = i->second; @@ -175,7 +175,7 @@ void SpriteDef::loadAction(xmlNodePtr node, int variant_offset) const std::string actionName = XML::getProperty(node, "name", ""); const std::string imageSetName = XML::getProperty(node, "imageset", ""); - ImageSetIterator si = mImageSets.find(imageSetName); + auto si = mImageSets.find(imageSetName); if (si == mImageSets.end()) { logger->log("Warning: imageset \"%s\" not defined in %s", @@ -190,7 +190,7 @@ void SpriteDef::loadAction(xmlNodePtr node, int variant_offset) actionName.c_str(), getIdPath().c_str()); return; } - Action *action = new Action; + auto *action = new Action; mActions[actionName] = action; // When first action set it as default direction @@ -224,7 +224,7 @@ void SpriteDef::loadAnimation(xmlNodePtr animationNode, return; } - Animation *animation = new Animation; + auto *animation = new Animation; action->setAnimation(directionType, animation); // Get animation frames @@ -327,13 +327,13 @@ SpriteDef::~SpriteDef() actions.insert(i->second); } - for (std::set< Action * >::const_iterator i = actions.begin(), + for (auto i = actions.begin(), i_end = actions.end(); i != i_end; ++i) { delete *i; } - for (ImageSetIterator i = mImageSets.begin(); + for (auto i = mImageSets.begin(); i != mImageSets.end(); ++i) { i->second->decRef(); diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 5ece1308..b044e7b6 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -53,7 +53,7 @@ struct SpriteDisplay std::list<std::string> particles; }; -typedef std::list<SpriteReference>::const_iterator SpriteRefs; +using SpriteRefs = std::list<SpriteReference>::const_iterator; /* * Remember those are the main action. @@ -115,7 +115,7 @@ class SpriteDef : public Resource private: SpriteDef() {} - ~SpriteDef(); + ~SpriteDef() override; /** * Loads a sprite element. @@ -156,10 +156,10 @@ class SpriteDef : public Resource */ void substituteAction(std::string complete, std::string with); - typedef std::map<std::string, ImageSet*> ImageSets; - typedef ImageSets::iterator ImageSetIterator; + using ImageSets = std::map<std::string, ImageSet *>; + using ImageSetIterator = ImageSets::iterator; - typedef std::map<std::string, Action*> Actions; + using Actions = std::map<std::string, Action *>; ImageSets mImageSets; Actions mActions; diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp index 1490dbf5..c44b7401 100644 --- a/src/resources/theme.cpp +++ b/src/resources/theme.cpp @@ -42,7 +42,7 @@ static std::string defaultThemePath; std::string Theme::mThemePath; -Theme *Theme::mInstance = 0; +Theme *Theme::mInstance = nullptr; // Set the theme path... static void initDefaultThemePath() @@ -144,7 +144,7 @@ Theme *Theme::instance() void Theme::deleteInstance() { delete mInstance; - mInstance = 0; + mInstance = nullptr; } gcn::Color Theme::getProgressColor(int type, float progress) @@ -160,7 +160,7 @@ gcn::Color Theme::getProgressColor(int type, float progress) Skin *Theme::load(const std::string &filename, const std::string &defaultPath) { // Check if this skin was already loaded - SkinIterator skinIterator = mSkins.find(filename); + auto skinIterator = mSkins.find(filename); if (mSkins.end() != skinIterator) { skinIterator->second->instances++; @@ -204,7 +204,7 @@ void Theme::setMinimumOpacity(float minimumOpacity) void Theme::updateAlpha() { - for (SkinIterator iter = mSkins.begin(); iter != mSkins.end(); ++iter) + for (auto iter = mSkins.begin(); iter != mSkins.end(); ++iter) iter->second->updateAlpha(mMinimumOpacity); } @@ -221,7 +221,7 @@ void Theme::event(Event::Channel channel, const Event &event) Skin *Theme::readSkin(const std::string &filename) { if (filename.empty()) - return 0; + return nullptr; logger->log("Loading skin '%s'.", filename.c_str()); @@ -229,14 +229,14 @@ Skin *Theme::readSkin(const std::string &filename) xmlNodePtr rootNode = doc.rootNode(); if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset")) - return 0; + return nullptr; const std::string skinSetImage = XML::getProperty(rootNode, "image", ""); if (skinSetImage.empty()) { logger->log("Theme::readSkin(): Skinset does not define an image!"); - return 0; + return nullptr; } logger->log("Theme::load(): <skinset> defines '%s' as a skin image.", diff --git a/src/resources/theme.h b/src/resources/theme.h index b2dd10de..9e7c4c3e 100644 --- a/src/resources/theme.h +++ b/src/resources/theme.h @@ -218,17 +218,17 @@ class Theme : public Palette, public EventListener */ void setMinimumOpacity(float minimumOpacity); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; private: Theme(); - ~Theme(); + ~Theme() override; Skin *readSkin(const std::string &filename); // Map containing all window skins - typedef std::map<std::string, Skin*> Skins; - typedef Skins::iterator SkinIterator; + using Skins = std::map<std::string, Skin *>; + using SkinIterator = Skins::iterator; Skins mSkins; @@ -245,7 +245,7 @@ class Theme : public Palette, public EventListener */ float mMinimumOpacity; - typedef std::vector<DyePalette*> ProgressColors; + using ProgressColors = std::vector<DyePalette *>; ProgressColors mProgressColors; }; diff --git a/src/resources/userpalette.cpp b/src/resources/userpalette.cpp index 073f5b03..8bc681b3 100644 --- a/src/resources/userpalette.cpp +++ b/src/resources/userpalette.cpp @@ -115,7 +115,7 @@ UserPalette::UserPalette(): UserPalette::~UserPalette() { - for (Colors::iterator col = mColors.begin(), + for (auto col = mColors.begin(), colEnd = mColors.end(); col != colEnd; ++col) { const std::string &configName = ColorTypeNames[col->type]; @@ -176,7 +176,7 @@ std::string UserPalette::getElementAt(int i) void UserPalette::commit(bool commitNonStatic) { - for (Colors::iterator i = mColors.begin(), iEnd = mColors.end(); + for (auto i = mColors.begin(), iEnd = mColors.end(); i != iEnd; ++i) { i->committedGrad = i->grad; @@ -194,7 +194,7 @@ void UserPalette::commit(bool commitNonStatic) void UserPalette::rollback() { - for (Colors::iterator i = mColors.begin(), iEnd = mColors.end(); + for (auto i = mColors.begin(), iEnd = mColors.end(); i != iEnd; ++i) { if (i->grad != i->committedGrad) diff --git a/src/resources/userpalette.h b/src/resources/userpalette.h index fa295f40..93056867 100644 --- a/src/resources/userpalette.h +++ b/src/resources/userpalette.h @@ -58,7 +58,7 @@ class UserPalette : public Palette, public gcn::ListModel UserPalette(); - ~UserPalette(); + ~UserPalette() override; /** * Gets the committed color associated with the specified type. @@ -123,7 +123,7 @@ class UserPalette : public Palette, public gcn::ListModel * * @return the number of colors known */ - int getNumberOfElements() { return mColors.size(); } + int getNumberOfElements() override { return mColors.size(); } /** * Returns the name of the ith color. @@ -132,7 +132,7 @@ class UserPalette : public Palette, public gcn::ListModel * * @return the name of the color */ - std::string getElementAt(int i); + std::string getElementAt(int i) override; /** * Commit the colors diff --git a/src/rotationalparticle.cpp b/src/rotationalparticle.cpp index e45ffb9d..f06172a5 100644 --- a/src/rotationalparticle.cpp +++ b/src/rotationalparticle.cpp @@ -26,14 +26,14 @@ #define PI 3.14159265 RotationalParticle::RotationalParticle(Map *map, Animation *animation): - ImageParticle(map, NULL), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animation)) { } RotationalParticle::RotationalParticle(Map *map, xmlNodePtr animationNode, const std::string& dyePalettes): - ImageParticle(map, 0), + ImageParticle(map, nullptr), mAnimation(new SimpleAnimation(animationNode, dyePalettes)) { } @@ -41,7 +41,7 @@ RotationalParticle::RotationalParticle(Map *map, xmlNodePtr animationNode, RotationalParticle::~RotationalParticle() { delete mAnimation; - mImage = NULL; + mImage = nullptr; } bool RotationalParticle::update() diff --git a/src/rotationalparticle.h b/src/rotationalparticle.h index 34471666..465be989 100644 --- a/src/rotationalparticle.h +++ b/src/rotationalparticle.h @@ -38,9 +38,9 @@ class RotationalParticle : public ImageParticle RotationalParticle(Map *map, xmlNodePtr animationNode, const std::string& dyePalettes = std::string()); - ~RotationalParticle(); + ~RotationalParticle() override; - virtual bool update(); + bool update() override; private: SimpleAnimation *mAnimation; /**< Used animation for this particle */ diff --git a/src/shopitem.cpp b/src/shopitem.cpp index ad9990a2..6eb52d18 100644 --- a/src/shopitem.cpp +++ b/src/shopitem.cpp @@ -56,7 +56,7 @@ ShopItem::~ShopItem() void ShopItem::addDuplicate(int inventoryIndex, int quantity) { - DuplicateItem* di = new DuplicateItem; + auto* di = new DuplicateItem; di->inventoryIndex = inventoryIndex; di->quantity = quantity; mDuplicates.push(di); @@ -65,7 +65,7 @@ void ShopItem::addDuplicate(int inventoryIndex, int quantity) void ShopItem::addDuplicate() { - DuplicateItem* di = new DuplicateItem; + auto* di = new DuplicateItem; di->inventoryIndex = -1; di->quantity = 0; mDuplicates.push(di); diff --git a/src/shopitem.h b/src/shopitem.h index 74521789..996e04ec 100644 --- a/src/shopitem.h +++ b/src/shopitem.h @@ -52,7 +52,7 @@ class ShopItem : public Item */ ShopItem(int id, int price); - ~ShopItem(); + ~ShopItem() override; /** * Add a duplicate. Id and price will be taken from this item. @@ -126,10 +126,10 @@ class ShopItem : public Item /** * Struct to keep track of duplicates. */ - typedef struct { + using DuplicateItem = struct { int inventoryIndex; int quantity; - } DuplicateItem; + }; std::stack<DuplicateItem*> mDuplicates; /** <-- Stores duplicates */ }; diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index d6bc5bd8..5ab7cf63 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -115,7 +115,7 @@ Image *SimpleAnimation::getCurrentImage() const if (mCurrentFrame) return mCurrentFrame->image; else - return NULL; + return nullptr; } void SimpleAnimation::initializeAnimation(xmlNodePtr animationNode, diff --git a/src/sound.cpp b/src/sound.cpp index 44f55cba..60cc2c10 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -54,7 +54,7 @@ Sound::Sound(): mSfxVolume(100), mNotificationsVolume(100), mMusicVolume(60), - mMusic(NULL) + mMusic(nullptr) { // This set up our callback function used to // handle fade outs endings. @@ -65,7 +65,7 @@ Sound::Sound(): Sound::~Sound() { // Unlink the callback function. - Mix_HookMusicFinished(NULL); + Mix_HookMusicFinished(nullptr); } void Sound::init() @@ -252,7 +252,7 @@ void Sound::logic() if (mMusic) { mMusic->decRef(); - mMusic = 0; + mMusic = nullptr; } sFadingOutEnded = false; @@ -327,5 +327,5 @@ void Sound::haltMusic() Mix_HaltMusic(); mMusic->decRef(); - mMusic = 0; + mMusic = nullptr; } diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index bdaaf566..42b48783 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -55,7 +55,7 @@ void StatusEffect::deliverMessage() Particle *StatusEffect::getParticle() { if (mParticleEffect.empty()) - return NULL; + return nullptr; else return particleEngine->addEffect(mParticleEffect, 0, 0); } @@ -63,7 +63,7 @@ Particle *StatusEffect::getParticle() AnimatedSprite *StatusEffect::getIcon() { if (mIcon.empty()) - return NULL; + return nullptr; else { AnimatedSprite *sprite = AnimatedSprite::load( @@ -120,7 +120,7 @@ void StatusEffect::init() void StatusEffect::readStatusEffectNode(xmlNodePtr node, const std::string &filename) { - status_effect_map *the_map = NULL; + status_effect_map *the_map = nullptr; int index = atoi(XML::getProperty(node, "id", "-1").c_str()); if (xmlStrEqual(node->name, BAD_CAST "status-effect")) { @@ -135,8 +135,8 @@ void StatusEffect::readStatusEffectNode(xmlNodePtr node, const std::string &file if (the_map) { - StatusEffect *startEffect = new StatusEffect; - StatusEffect *endEffect = new StatusEffect; + auto *startEffect = new StatusEffect; + auto *endEffect = new StatusEffect; startEffect->mMessage = XML::getProperty(node, "start-message", ""); startEffect->mSFXEffect = XML::getProperty(node, "start-audio", ""); diff --git a/src/text.cpp b/src/text.cpp index 0b619836..14ae747b 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -50,7 +50,7 @@ Text::Text(const std::string &text, int x, int y, else mFont = font; - if (textManager == 0) + if (textManager == nullptr) { textManager = new TextManager; Image *sbImage = Theme::getImageFromTheme("bubble.png|W:#" @@ -100,7 +100,7 @@ Text::~Text() if (--mInstances == 0) { delete textManager; - textManager = 0; + textManager = nullptr; delete mBubble.grid[0]; delete mBubble.grid[1]; delete mBubble.grid[2]; @@ -40,7 +40,7 @@ class Text Text(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color *color, bool isSpeech = false, - gcn::Font *font = 0); + gcn::Font *font = nullptr); /** * Destructor. The text is removed from the screen. @@ -85,12 +85,12 @@ class FlashText : public Text FlashText(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color* color, - gcn::Font *font = 0); + gcn::Font *font = nullptr); /** * Remove the text from the screen */ - virtual ~FlashText() {} + ~FlashText() override {} /** * Flash the text for so many refreshes. @@ -100,7 +100,7 @@ class FlashText : public Text /** * Draws the text. */ - virtual void draw(gcn::Graphics *graphics, int xOff, int yOff); + void draw(gcn::Graphics *graphics, int xOff, int yOff) override; private: int mTime; /**< Time left for flashing */ diff --git a/src/textmanager.cpp b/src/textmanager.cpp index 00bdd49c..5f87bd29 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -25,7 +25,7 @@ #include <cstring> -TextManager *textManager = 0; +TextManager *textManager = nullptr; TextManager::TextManager() { @@ -33,7 +33,7 @@ TextManager::TextManager() void TextManager::addText(Text *text) { - place(text, 0, text->mX, text->mY, text->mHeight); + place(text, nullptr, text->mX, text->mY, text->mHeight); mTextList.push_back(text); } @@ -46,7 +46,7 @@ void TextManager::moveText(Text *text, int x, int y) void TextManager::removeText(const Text *text) { - for (TextList::iterator ptr = mTextList.begin(), + for (auto ptr = mTextList.begin(), pEnd = mTextList.end(); ptr != pEnd; ++ptr) { if (*ptr == text) @@ -63,7 +63,7 @@ TextManager::~TextManager() void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff) { - for (TextList::iterator bPtr = mTextList.begin(), ePtr = mTextList.end(); + for (auto bPtr = mTextList.begin(), ePtr = mTextList.end(); bPtr != ePtr; ++bPtr) { (*bPtr)->draw(graphics, xOff, yOff); diff --git a/src/textmanager.h b/src/textmanager.h index 74428108..9043e583 100644 --- a/src/textmanager.h +++ b/src/textmanager.h @@ -65,7 +65,7 @@ class TextManager void place(const Text *textObj, const Text *omit, int &x, int &y, int h); - typedef std::list<Text *> TextList; /**< The container type */ + using TextList = std::list<Text *>; /**< The container type */ TextList mTextList; /**< The container */ }; diff --git a/src/textparticle.h b/src/textparticle.h index ef79314d..d70cc5b9 100644 --- a/src/textparticle.h +++ b/src/textparticle.h @@ -34,17 +34,17 @@ class TextParticle : public Particle /** * Draws the particle image. */ - virtual bool draw(Graphics *graphics, int offsetX, int offsetY) const; + bool draw(Graphics *graphics, int offsetX, int offsetY) const override; // hack to improve text visibility - virtual int getDrawOrder() const + int getDrawOrder() const override { return (int) (mPos.y) + 32; } /** In contrary to other particles, text particles should not be * obscured by objects, because their information is too * important. */ - virtual bool drawnWhenBehind() const + bool drawnWhenBehind() const override { return true; } private: diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 57a9fc84..cf10c8fd 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -46,7 +46,7 @@ unsigned char *php3_base64_encode(const unsigned char *string, int length, int * { const unsigned char *current = string; int i = 0; - unsigned char *result = (unsigned char *)malloc(((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char)); + auto *result = (unsigned char *)malloc(((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char)); while (length > 2) { /* keep going until we have less than 24 bits */ @@ -91,11 +91,11 @@ unsigned char *php3_base64_decode(const unsigned char *string, int length, int * int ch, i = 0, j = 0, k; char *chp; - unsigned char *result = (unsigned char *)malloc(length + 1); + auto *result = (unsigned char *)malloc(length + 1); - if (result == NULL) + if (result == nullptr) { - return NULL; + return nullptr; } /* run through the whole string, converting as we go */ @@ -113,7 +113,7 @@ unsigned char *php3_base64_decode(const unsigned char *string, int length, int * if (ch == ' ') ch = '+'; chp = strchr(base64_table, ch); - if (chp == NULL) continue; + if (chp == nullptr) continue; ch = chp - base64_table; switch(i % 4) @@ -145,7 +145,7 @@ unsigned char *php3_base64_decode(const unsigned char *string, int length, int * case 0: case 1: free(result); - return NULL; + return nullptr; case 2: k++; case 3: diff --git a/src/utils/mutex.h b/src/utils/mutex.h index d0120cfa..ad95b17b 100644 --- a/src/utils/mutex.h +++ b/src/utils/mutex.h @@ -96,7 +96,7 @@ inline MutexLocker::MutexLocker(Mutex *mutex): inline MutexLocker::MutexLocker(MutexLocker&& rhs): mMutex(rhs.mMutex) { - rhs.mMutex = NULL; + rhs.mMutex = nullptr; } inline MutexLocker::~MutexLocker() diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index 761f4edb..a97dce3c 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -78,8 +78,8 @@ #ifdef HAVE_STDINT_H #include <stdint.h> #else -typedef unsigned char uint8_t; -typedef unsigned int uint32_t; +using uint8_t = unsigned char; +using uint32_t = unsigned int; #endif #define SHA256_BLOCK_SIZE (512 / 8) diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 05f1bf7b..59a3f17d 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -194,7 +194,7 @@ bool getBoolFromString(const std::string &text, bool def) std::string autocomplete(std::vector<std::string> &candidates, std::string base) { - std::vector<std::string>::iterator i = candidates.begin(); + auto i = candidates.begin(); toLower(base); std::string newName(""); diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index 839479d7..d0f51230 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -46,7 +46,7 @@ namespace XML }; Document::Document(const std::string &filename, bool useResman): - mDoc(0) + mDoc(nullptr) { XMLContext ctx; ctx.file = filename; @@ -54,7 +54,7 @@ namespace XML xmlSetStructuredErrorFunc(&ctx, xmlLogger); int size; - char *data = NULL; + char *data = nullptr; if (useResman) { ResourceManager *resman = ResourceManager::getInstance(); @@ -78,7 +78,7 @@ namespace XML logger->log("Error loading %s", filename.c_str()); } - xmlSetStructuredErrorFunc(NULL, xmlLogger); + xmlSetStructuredErrorFunc(nullptr, xmlLogger); } Document::~Document() @@ -89,7 +89,7 @@ namespace XML xmlNodePtr Document::rootNode() { - return mDoc ? xmlDocGetRootElement(mDoc) : 0; + return mDoc ? xmlDocGetRootElement(mDoc) : nullptr; } int getProperty(xmlNodePtr node, const char* name, int def) @@ -152,12 +152,12 @@ namespace XML if (xmlStrEqual(child->name, BAD_CAST name)) return child; - return NULL; + return nullptr; } static void xmlLogger(void *ctx, xmlErrorPtr error) { - XMLContext *context = static_cast<XMLContext*>(ctx); + auto *context = static_cast<XMLContext*>(ctx); if (context) logger->log("Error in XML file '%s' on line %d", @@ -180,7 +180,7 @@ namespace XML LIBXML_TEST_VERSION; // Handle libxml2 error messages - xmlSetStructuredErrorFunc(NULL, xmlLogger); + xmlSetStructuredErrorFunc(nullptr, xmlLogger); } } // namespace XML diff --git a/src/utils/zlib.cpp b/src/utils/zlib.cpp index 7a5421fd..8234766e 100644 --- a/src/utils/zlib.cpp +++ b/src/utils/zlib.cpp @@ -57,7 +57,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, do { - if (strm.next_out == NULL) + if (strm.next_out == nullptr) { inflateEnd(&strm); return Z_MEM_ERROR; @@ -80,7 +80,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, { out = (unsigned char*) realloc(out, bufferSize * 2); - if (out == NULL) + if (out == nullptr) { inflateEnd(&strm); return Z_MEM_ERROR; @@ -105,7 +105,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, unsigned int outLength = 0; int ret = inflateMemory(in, inLength, out, outLength); - if (ret != Z_OK || out == NULL) + if (ret != Z_OK || out == nullptr) { if (ret == Z_MEM_ERROR) { @@ -125,7 +125,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength, } free(out); - out = NULL; + out = nullptr; outLength = 0; } @@ -163,7 +163,7 @@ void *loadCompressedFile(const std::string &filename, int &filesize) { logger->log("Could not decompress file: %s", filename.c_str()); - return NULL; + return nullptr; } filesize = inflatedSize; @@ -179,5 +179,5 @@ void *loadCompressedFile(const std::string &filename, int &filesize) logger->log("Error loading file from drive: %s", filename.c_str()); } - return NULL; + return nullptr; } diff --git a/src/variabledata.h b/src/variabledata.h index 90eca967..be822050 100644 --- a/src/variabledata.h +++ b/src/variabledata.h @@ -52,7 +52,7 @@ public: int getData() const { return mData; } - int getType() const { return DATA_INT; } + int getType() const override { return DATA_INT; } private: int mData; @@ -65,7 +65,7 @@ public: const std::string &getData() const { return mData; } - int getType() const { return DATA_STRING; } + int getType() const override { return DATA_STRING; } private: std::string mData; @@ -78,7 +78,7 @@ public: double getData() const { return mData; } - int getType() const { return DATA_FLOAT; } + int getType() const override { return DATA_FLOAT; } private: double mData; @@ -91,7 +91,7 @@ public: bool getData() const { return mData; } - int getType() const { return DATA_BOOL; } + int getType() const override { return DATA_BOOL; } private: bool mData; @@ -104,7 +104,7 @@ public: Item *getData() const { return mData; } - int getType() const { return DATA_ITEM; } + int getType() const override { return DATA_ITEM; } private: Item *mData; @@ -117,7 +117,7 @@ public: ActorSprite *getData() const { return mData; } - int getType() const { return DATA_ACTOR; } + int getType() const override { return DATA_ACTOR; } private: ActorSprite *mData; |