summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actorsprite.cpp5
-rw-r--r--src/actorsprite.h7
-rw-r--r--src/being.cpp37
-rw-r--r--src/being.h38
-rw-r--r--src/compoundsprite.cpp2
-rw-r--r--src/gui/charselectdialog.cpp5
-rw-r--r--src/gui/itempopup.cpp3
-rw-r--r--src/gui/recorder.cpp1
-rw-r--r--src/gui/skilldialog.cpp3
-rw-r--r--src/gui/socialwindow.cpp2
-rw-r--r--src/gui/specialswindow.cpp10
-rw-r--r--src/gui/widgets/avatarlistbox.cpp1
-rw-r--r--src/gui/widgets/avatarlistbox.h3
-rw-r--r--src/gui/widgets/button.cpp3
-rw-r--r--src/gui/widgets/button.h8
-rw-r--r--src/gui/widgets/channeltab.cpp4
-rw-r--r--src/gui/widgets/channeltab.h1
-rw-r--r--src/gui/widgets/chattab.cpp1
-rw-r--r--src/gui/widgets/checkbox.cpp5
-rw-r--r--src/gui/widgets/checkbox.h2
-rw-r--r--src/gui/widgets/container.cpp3
-rw-r--r--src/gui/widgets/container.h2
-rw-r--r--src/gui/widgets/desktop.cpp3
-rw-r--r--src/gui/widgets/desktop.h2
-rw-r--r--src/gui/widgets/dropdown.cpp6
-rw-r--r--src/gui/widgets/dropdown.h2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp13
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.h4
-rw-r--r--src/gui/widgets/flowcontainer.cpp4
-rw-r--r--src/gui/widgets/flowcontainer.h3
-rw-r--r--src/gui/widgets/icon.cpp8
-rw-r--r--src/gui/widgets/itemcontainer.cpp24
-rw-r--r--src/gui/widgets/itemcontainer.h22
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp12
-rw-r--r--src/gui/widgets/itemshortcutcontainer.h4
-rw-r--r--src/gui/widgets/layout.cpp14
-rw-r--r--src/gui/widgets/layout.h2
-rw-r--r--src/gui/widgets/listbox.cpp1
-rw-r--r--src/gui/widgets/listbox.h2
-rw-r--r--src/gui/widgets/playerbox.cpp13
-rw-r--r--src/gui/widgets/popup.cpp12
-rw-r--r--src/gui/widgets/popup.h5
-rw-r--r--src/gui/widgets/progressbar.cpp5
-rw-r--r--src/gui/widgets/progressbar.h6
-rw-r--r--src/gui/widgets/radiobutton.cpp4
-rw-r--r--src/gui/widgets/radiobutton.h2
-rw-r--r--src/gui/widgets/scrollarea.cpp26
-rw-r--r--src/gui/widgets/scrollarea.h9
-rw-r--r--src/gui/widgets/shoplistbox.cpp5
-rw-r--r--src/gui/widgets/shoplistbox.h2
-rw-r--r--src/gui/widgets/shortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/shortcutcontainer.h12
-rw-r--r--src/gui/widgets/slider.cpp6
-rw-r--r--src/gui/widgets/slider.h4
-rw-r--r--src/gui/widgets/spacer.h1
-rw-r--r--src/gui/widgets/tab.cpp12
-rw-r--r--src/gui/widgets/tab.h2
-rw-r--r--src/gui/widgets/tabbedarea.cpp19
-rw-r--r--src/gui/widgets/tabbedarea.h6
-rw-r--r--src/gui/widgets/table.cpp10
-rw-r--r--src/gui/widgets/textfield.cpp30
-rw-r--r--src/gui/widgets/textfield.h11
-rw-r--r--src/gui/widgets/textpreview.cpp4
-rw-r--r--src/gui/widgets/textpreview.h10
-rw-r--r--src/gui/widgets/vertcontainer.cpp3
-rw-r--r--src/gui/widgets/vertcontainer.h2
-rw-r--r--src/gui/widgets/whispertab.cpp1
-rw-r--r--src/gui/widgets/window.cpp23
-rw-r--r--src/gui/widgets/window.h26
-rw-r--r--src/guild.cpp105
-rw-r--r--src/guild.h7
-rw-r--r--src/localplayer.cpp29
-rw-r--r--src/localplayer.h37
-rw-r--r--src/net/logindata.h7
-rw-r--r--src/net/manaserv/network.cpp4
-rw-r--r--src/net/tmwa/inventoryhandler.h22
-rw-r--r--src/net/tmwa/loginhandler.h2
-rw-r--r--src/net/tmwa/messageout.cpp7
-rw-r--r--src/net/tmwa/messageout.h6
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/particle.cpp4
-rw-r--r--src/particlecontainer.cpp2
-rw-r--r--src/particlecontainer.h18
-rw-r--r--src/party.cpp104
-rw-r--r--src/party.h7
-rw-r--r--src/playerinfo.cpp16
-rw-r--r--src/resources/emotedb.cpp8
-rw-r--r--src/resources/emotedb.h2
-rw-r--r--src/resources/image.cpp18
-rw-r--r--src/resources/image.h11
-rw-r--r--src/resources/itemdb.h5
-rw-r--r--src/resources/iteminfo.h14
-rw-r--r--src/resources/monsterdb.cpp6
-rw-r--r--src/utils/mutex.h11
94 files changed, 348 insertions, 663 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 1db68d31..67b086ca 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -47,11 +47,8 @@ bool ActorSprite::loaded = false;
ActorSprite::ActorSprite(int id):
mId(id),
- mStunMode(0),
mStatusParticleEffects(&mStunParticleEffects, false),
- mChildParticleEffects(&mStatusParticleEffects, false),
- mMustResetParticles(false),
- mUsedTargetCursor(nullptr)
+ mChildParticleEffects(&mStatusParticleEffects, false)
{}
ActorSprite::~ActorSprite()
diff --git a/src/actorsprite.h b/src/actorsprite.h
index f657d5cb..b3e14830 100644
--- a/src/actorsprite.h
+++ b/src/actorsprite.h
@@ -28,7 +28,6 @@
#include <cstdint>
#include <set>
-#include <list>
class SimpleAnimation;
class StatusEffect;
@@ -196,7 +195,7 @@ protected:
bool forceDisplay = true);
int mId;
- uint16_t mStunMode; /**< Stun mode; zero if not stunned */
+ uint16_t mStunMode = 0; /**< Stun mode; zero if not stunned */
std::set<int> mStatusEffects; /**< set of active status effects */
ParticleList mStunParticleEffects;
@@ -205,7 +204,7 @@ protected:
private:
/** Reset particle status effects on next redraw? */
- bool mMustResetParticles;
+ bool mMustResetParticles = false;
/** Load the target cursors into memory */
static void initTargetCursor();
@@ -228,7 +227,7 @@ private:
static bool loaded;
/** Target cursor being used */
- SimpleAnimation *mUsedTargetCursor;
+ SimpleAnimation *mUsedTargetCursor = nullptr;
};
#endif // ACTORSPRITE_H
diff --git a/src/being.cpp b/src/being.cpp
index ef07684f..9549b625 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -28,7 +28,6 @@
#include "effectmanager.h"
#include "event.h"
#include "game.h"
-#include "graphics.h"
#include "guild.h"
#include "localplayer.h"
#include "log.h"
@@ -36,7 +35,6 @@
#include "particle.h"
#include "party.h"
#include "playerrelations.h"
-#include "simpleanimation.h"
#include "sound.h"
#include "text.h"
@@ -51,8 +49,6 @@
#include "net/npchandler.h"
#include "resources/beinginfo.h"
-#include "resources/hairdb.h"
-#include "resources/emotedb.h"
#include "resources/image.h"
#include "resources/itemdb.h"
#include "resources/iteminfo.h"
@@ -63,30 +59,12 @@
#include "utils/stringutils.h"
-#include <cassert>
#include <cmath>
Being::Being(int id, Type type, int subtype, Map *map):
ActorSprite(id),
mInfo(BeingInfo::Unknown),
- mActionTime(0),
- mSpeechTime(0),
- mAttackSpeed(350),
- mAction(STAND),
- mSubType(0xFFFF),
- mDirection(DOWN),
- mSpriteDirection(DIRECTION_DOWN),
- mDispName(nullptr),
- mShowName(false),
- mEquippedWeapon(nullptr),
- mText(nullptr),
- mGender(GENDER_UNSPECIFIED),
- mParty(nullptr),
- mIsGM(false),
- mType(type),
- mSpeedPixelsPerTick(Vector(0.0f, 0.0f, 0.0f)),
- mDamageTaken(0),
- mIp(0)
+ mType(type)
{
setMap(map);
setSubtype(subtype);
@@ -512,15 +490,9 @@ void Being::removeGuild(int id)
Guild *Being::getGuild(const std::string &guildName) const
{
- std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end();
- for (itr = mGuilds.begin(); itr != itr_end; ++itr)
- {
- Guild *guild = itr->second;
+ for (auto &[_, guild] : mGuilds)
if (guild->getName() == guildName)
- {
return guild;
- }
- }
return nullptr;
}
@@ -539,11 +511,8 @@ Guild *Being::getGuild(int id) const
void Being::clearGuilds()
{
- std::map<int, Guild*>::const_iterator itr, itr_end = mGuilds.end();
- for (itr = mGuilds.begin(); itr != itr_end; ++itr)
+ for (auto &[_, guild] : mGuilds)
{
- Guild *guild = itr->second;
-
if (this == local_player && socialWindow)
socialWindow->removeTab(guild);
diff --git a/src/being.h b/src/being.h
index 5bf85a72..1c3e250d 100644
--- a/src/being.h
+++ b/src/being.h
@@ -46,7 +46,7 @@ class ItemInfo;
class Item;
class Particle;
class Party;
-class Position;
+struct Position;
class SpeechBubble;
class Text;
@@ -465,49 +465,49 @@ class Being : public ActorSprite, public EventListener
*/
int getSpeechTextYPosition() const;
- BeingInfo *mInfo;
+ const BeingInfo *mInfo;
- int mActionTime; /**< Time spent in current action. TODO: Remove use of it */
+ int mActionTime = 0; /**< Time spent in current action. TODO: Remove use of it */
/** Time until the last speech sentence disappears */
- int mSpeechTime;
+ int mSpeechTime = 0;
- int mAttackSpeed; /**< Attack speed */
+ int mAttackSpeed = 350; /**< Attack speed */
- Action mAction; /**< Action the being is performing */
- uint16_t mSubType; /**< Subtype (graphical view, basically) */
+ Action mAction = STAND; /**< Action the being is performing */
+ uint16_t mSubType = 0xFFFF; /**< Subtype (graphical view, basically) */
- uint8_t mDirection; /**< Facing direction */
- uint8_t mSpriteDirection; /**< Facing direction */
+ uint8_t mDirection = DOWN; /**< Facing direction */
+ uint8_t mSpriteDirection = DIRECTION_DOWN; /**< Facing direction */
std::string mName; /**< Name of character */
std::string mPartyName;
/**
- * Holds a text object when the being displays it's name, 0 otherwise
+ * Holds a text object when the being displays its name, 0 otherwise
*/
- FlashText *mDispName;
+ FlashText *mDispName = nullptr;
const gcn::Color *mNameColor;
- bool mShowName;
+ bool mShowName = false;
/** Engine-related infos about weapon. */
- const ItemInfo *mEquippedWeapon;
+ const ItemInfo *mEquippedWeapon = nullptr;
Path mPath;
std::string mSpeech;
- Text *mText;
+ Text *mText = nullptr;
const gcn::Color *mTextColor;
Vector mDest; /**< destination coordinates. */
std::vector<int> mSpriteIDs;
std::vector<std::string> mSpriteColors;
- Gender mGender;
+ Gender mGender = GENDER_UNSPECIFIED;
// Character guild information
std::map<int, Guild*> mGuilds;
- Party *mParty;
+ Party *mParty = nullptr;
- bool mIsGM;
+ bool mIsGM = false;
private:
@@ -529,9 +529,9 @@ class Being : public ActorSprite, public EventListener
*/
Vector mSpeedPixelsPerTick;
- int mDamageTaken;
+ int mDamageTaken = 0;
- int mIp;
+ int mIp = 0;
};
#endif
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 982ea9fb..2ab911fa 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -264,7 +264,7 @@ void CompoundSprite::redraw() const
#endif
mWidth = mHeight = mOffsetX = mOffsetY = 0;
- Sprite *s = NULL;
+ Sprite *s = nullptr;
SpriteConstIterator it, it_end = mSprites.end();
int posX = 0;
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 1637d001..02a89ff2 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -22,7 +22,6 @@
#include "gui/charselectdialog.h"
#include "client.h"
-#include "game.h"
#include "localplayer.h"
#include "units.h"
#include "log.h"
@@ -31,7 +30,6 @@
#include "gui/changepassworddialog.h"
#include "gui/charcreatedialog.h"
#include "gui/confirmdialog.h"
-#include "gui/okdialog.h"
#include "gui/sdlinput.h"
#include "gui/unregisterdialog.h"
@@ -40,15 +38,12 @@
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/playerbox.h"
-#include "gui/widgets/textfield.h"
#include "net/charhandler.h"
#include "net/logindata.h"
#include "net/loginhandler.h"
#include "net/net.h"
-#include "resources/hairdb.h"
-
#include "utils/gettext.h"
#include "utils/stringutils.h"
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 3979c4f2..30d5c5c4 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -22,6 +22,7 @@
#include "gui/itempopup.h"
+#include "configuration.h"
#include "graphics.h"
#include "units.h"
@@ -34,8 +35,6 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include "net/net.h"
-
#include "resources/image.h"
#include "resources/resourcemanager.h"
#include "resources/theme.h"
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index a7a9b25a..566b160c 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -28,7 +28,6 @@
#include "gui/widgets/button.h"
#include "gui/widgets/layout.h"
-#include "gui/widgets/windowcontainer.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 74a5b2c4..6ec7f011 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -24,12 +24,10 @@
#include "log.h"
#include "playerinfo.h"
#include "configuration.h"
-#include "eventlistener.h"
#include "gui/setup.h"
#include "gui/widgets/button.h"
-#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/progressbar.h"
@@ -52,7 +50,6 @@
#include <guichan/font.hpp>
-#include <set>
#include <string>
#define SKILLS_FILE "skills.xml"
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 5a1e8989..3fda9aa0 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -563,7 +563,7 @@ void SocialWindow::showPartyInvite(const std::string &inviter,
const std::string &partyName)
{
// check there isnt already an invite showing
- if (mPartyInviter != "")
+ if (!mPartyInviter.empty())
{
SERVER_NOTICE(_("Received party request, but one already exists."))
return;
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 1104aa05..17705b47 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -130,12 +130,10 @@ void SpecialsWindow::draw(gcn::Graphics *graphics)
foundNew = true;
break;
}
- else
- {
- // update progress bar of special
- e->second->update(special.second.currentMana, special.second.neededMana);
- found++;
- }
+
+ // update progress bar of special
+ e->second->update(special.second.currentMana, special.second.neededMana);
+ found++;
}
// a rebuild is needed when a) the number of specials changed or b) an existing entry isn't found anymore
if (foundNew || found != mEntries.size())
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index d397ecfb..6fd0fcfb 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -23,7 +23,6 @@
#include "graphics.h"
#include "gui/gui.h"
-#include "gui/palette.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h
index ab402329..7ee36d1e 100644
--- a/src/gui/widgets/avatarlistbox.h
+++ b/src/gui/widgets/avatarlistbox.h
@@ -25,9 +25,7 @@
#include "gui/widgets/listbox.h"
-#include <map>
#include <string>
-#include <vector>
class Image;
@@ -58,7 +56,6 @@ private:
static int instances;
static Image *onlineIcon;
static Image *offlineIcon;
-
};
#endif
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 0c5fca68..d40a54fb 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -70,8 +70,7 @@ Button::Button():
Button::Button(const std::string &caption, const std::string &actionEventId,
gcn::ActionListener *listener):
- gcn::Button(caption),
- mButtonIcon(nullptr)
+ gcn::Button(caption)
{
init();
setActionEventId(actionEventId);
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index e4a28d80..a09b4445 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -91,18 +91,18 @@ class Button : public gcn::Button
void removeButtonIcon(bool adjustButtonSize = true);
- static ImageRect* mButton; /**< Button state graphics */
- static int mInstances; /**< Number of button instances */
+ static ImageRect* mButton; /**< Button state graphics */
+ static int mInstances; /**< Number of button instances */
static float mAlpha;
- Image** mButtonIcon; /**< Button Icons graphics */
+ Image** mButtonIcon = nullptr; /**< Button Icons graphics */
/**
* The buttons popup
* @note: This is a global object. One for all the buttons.
*/
static TextPopup* mTextPopup;
- std::string mPopupText; /**< the current button text */
+ std::string mPopupText; /**< the current button text */
};
#endif
diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp
index 074ec6fb..e692ff71 100644
--- a/src/gui/widgets/channeltab.cpp
+++ b/src/gui/widgets/channeltab.cpp
@@ -108,14 +108,14 @@ bool ChannelTab::handleCommand(const std::string &type,
else if (type == "op")
{
// set the user mode 'o' to op a user
- if (args != "")
+ if (!args.empty())
Net::getChatHandler()->setUserMode(mChannel->getId(), args, 'o');
else
chatLog(_("Need a user to op!"), BY_CHANNEL);
}
else if (type == "kick")
{
- if (args != "")
+ if (!args.empty())
Net::getChatHandler()->kickUser(mChannel->getId(), args);
else
chatLog(_("Need a user to kick!"), BY_CHANNEL);
diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h
index ec8af1cd..2894dacd 100644
--- a/src/gui/widgets/channeltab.h
+++ b/src/gui/widgets/channeltab.h
@@ -32,7 +32,6 @@ class Channel;
class ChannelTab : public ChatTab
{
public:
-
Channel *getChannel() const { return mChannel; }
void showHelp() override;
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 6687198e..166ad102 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -29,7 +29,6 @@
#include "localplayer.h"
#include "sound.h"
-#include "gui/gui.h"
#include "gui/recorder.h"
#include "gui/widgets/browserbox.h"
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index f4b377c0..0554bad6 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -24,8 +24,6 @@
#include "configuration.h"
#include "graphics.h"
-#include "gui/palette.h"
-
#include "resources/image.h"
#include "resources/theme.h"
@@ -39,8 +37,7 @@ Image *CheckBox::checkBoxNormalHi;
Image *CheckBox::checkBoxCheckedHi;
CheckBox::CheckBox(const std::string &caption, bool selected):
- gcn::CheckBox(caption, selected),
- mHasMouse(false)
+ gcn::CheckBox(caption, selected)
{
if (instances == 0)
{
diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h
index 6eb53c38..f77b1761 100644
--- a/src/gui/widgets/checkbox.h
+++ b/src/gui/widgets/checkbox.h
@@ -66,7 +66,7 @@ class CheckBox : public gcn::CheckBox
private:
static int instances;
static float mAlpha;
- bool mHasMouse;
+ bool mHasMouse = false;
static Image *checkBoxNormal;
static Image *checkBoxChecked;
static Image *checkBoxDisabled;
diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp
index 74b82f07..582b294b 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -23,8 +23,7 @@
#include "gui/widgets/layouthelper.h"
-Container::Container():
- mLayoutHelper(nullptr)
+Container::Container()
{
setOpaque(false);
}
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index 6c5caa3a..ef44c8cd 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -61,7 +61,7 @@ class Container : public gcn::Container
ContainerPlacer getPlacer(int x, int y);
private:
- LayoutHelper *mLayoutHelper;
+ LayoutHelper *mLayoutHelper = nullptr;
};
#endif
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 3b26ef3a..474aadb0 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -26,8 +26,6 @@
#include "log.h"
#include "main.h"
-#include "gui/palette.h"
-
#include "gui/widgets/label.h"
#include "resources/image.h"
@@ -37,7 +35,6 @@
#include "utils/stringutils.h"
Desktop::Desktop()
- : mWallpaper(nullptr)
{
addWidgetListener(this);
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index e10813ef..97294423 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -61,7 +61,7 @@ class Desktop : public Container, gcn::WidgetListener
private:
void setBestFittingWallpaper();
- Image *mWallpaper;
+ Image *mWallpaper = nullptr;
gcn::Label *mVersionLabel;
};
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 234d6676..a4b02fe5 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -68,11 +68,11 @@ DropDown::DropDown(gcn::ListModel *listModel):
Image *boxBorder = Theme::getImageFromTheme("deepbox.png");
int gridx[4] = {0, 3, 28, 31};
int gridy[4] = {0, 3, 28, 31};
- int a = 0, x, y;
+ int a = 0;
- for (y = 0; y < 3; y++)
+ for (int y = 0; y < 3; y++)
{
- for (x = 0; x < 3; x++)
+ for (int x = 0; x < 3; x++)
{
skin.grid[a] = boxBorder->getSubImage(gridx[x], gridy[y],
gridx[x + 1] -
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index f0b721f6..f92c7dd5 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -50,7 +50,7 @@ class DropDown : public gcn::DropDown
/**
* Update the alpha value to the graphic components.
*/
- void updateAlpha();
+ static void updateAlpha();
void draw(gcn::Graphics *graphics) override;
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index fa74cf20..b719bc5f 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -24,28 +24,17 @@
#include "configuration.h"
#include "emoteshortcut.h"
#include "graphics.h"
-#include "inventory.h"
#include "imagesprite.h"
#include "item.h"
-#include "itemshortcut.h"
#include "keyboardconfig.h"
-#include "localplayer.h"
-#include "log.h"
-
-#include "gui/palette.h"
#include "resources/emotedb.h"
#include "resources/image.h"
#include "resources/theme.h"
-#include "utils/dtor.h"
-
static const int MAX_ITEMS = 12;
-EmoteShortcutContainer::EmoteShortcutContainer():
- ShortcutContainer(),
- mEmoteClicked(false),
- mEmoteMoved(0)
+EmoteShortcutContainer::EmoteShortcutContainer()
{
addMouseListener(this);
addWidgetListener(this);
diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h
index 2d62b500..209a3725 100644
--- a/src/gui/widgets/emoteshortcutcontainer.h
+++ b/src/gui/widgets/emoteshortcutcontainer.h
@@ -63,8 +63,8 @@ class EmoteShortcutContainer : public ShortcutContainer
private:
std::vector<const ImageSprite*> mEmoteImg;
- bool mEmoteClicked;
- int mEmoteMoved;
+ bool mEmoteClicked = false;
+ int mEmoteMoved = 0;
};
#endif
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 0110c534..087a2a92 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -21,8 +21,8 @@
#include "flowcontainer.h"
FlowContainer::FlowContainer(int boxWidth, int boxHeight):
- mBoxWidth(boxWidth), mBoxHeight(boxHeight),
- mGridWidth(1), mGridHeight(1)
+ mBoxWidth(boxWidth),
+ mBoxHeight(boxHeight)
{
addWidgetListener(this);
}
diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h
index 28d148d5..21daae16 100644
--- a/src/gui/widgets/flowcontainer.h
+++ b/src/gui/widgets/flowcontainer.h
@@ -53,7 +53,8 @@ class FlowContainer : public Container,
private:
int mBoxWidth;
int mBoxHeight;
- int mGridWidth, mGridHeight;
+ int mGridWidth = 1;
+ int mGridHeight = 1;
};
#endif
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index 5d7d62f7..eaf5be1c 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -27,12 +27,8 @@
#include "resources/resourcemanager.h"
Icon::Icon(const std::string &file)
- : mImage(nullptr)
-{
- mImage = ResourceManager::getInstance()->getImage(file);
- if (mImage)
- setSize(mImage->getWidth(), mImage->getHeight());
-}
+ : Icon(ResourceManager::getInstance()->getImage(file))
+{}
Icon::Icon(Image *image)
: mImage(image)
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 5b373bb6..37a61c80 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -30,13 +30,8 @@
#include "gui/chatwindow.h"
#include "gui/itempopup.h"
#include "gui/outfitwindow.h"
-#include "gui/palette.h"
-#include "gui/sdlinput.h"
#include "gui/viewport.h"
-#include "net/net.h"
-#include "net/inventoryhandler.h"
-
#include "resources/image.h"
#include "resources/iteminfo.h"
#include "resources/theme.h"
@@ -53,15 +48,7 @@ static const int BOX_WIDTH = 35;
static const int BOX_HEIGHT = 43;
ItemContainer::ItemContainer(Inventory *inventory):
- mInventory(inventory),
- mGridColumns(1),
- mGridRows(1),
- mSelectedIndex(-1),
- mHighlightedIndex(-1),
- mLastUsedSlot(-1),
- mSelectionStatus(SEL_NONE),
- mSwapItems(false),
- mDescItems(false)
+ mInventory(inventory)
{
mItemPopup = new ItemPopup;
setFocusable(true);
@@ -112,7 +99,7 @@ void ItemContainer::draw(gcn::Graphics *graphics)
if (!item || item->getId() == 0)
continue;
- if (mFilter.size() > 0)
+ if (!mFilter.empty())
{
if (normalize(item->getInfo().getName()).find(mFilter) == std::string::npos)
continue;
@@ -220,13 +207,10 @@ void ItemContainer::setFilter(const std::string &filter)
void ItemContainer::distributeValueChangedEvent()
{
- SelectionListenerIterator i, i_end;
-
- for (i = mSelectionListeners.begin(), i_end = mSelectionListeners.end();
- i != i_end; ++i)
+ for (auto listener : mSelectionListeners)
{
gcn::SelectionEvent event(this);
- (*i)->valueChanged(event);
+ listener->valueChanged(event);
}
}
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index fe5b73e5..51807aba 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -176,14 +176,17 @@ class ItemContainer : public gcn::Widget,
Item *getItemAt(int) const;
Inventory *mInventory;
- int mGridColumns, mGridRows;
+ int mGridColumns = 1;
+ int mGridRows = 1;
Image *mSelImg;
- int mSelectedIndex, mHighlightedIndex;
- int mLastUsedSlot;
- SelectionState mSelectionStatus;
- bool mSwapItems;
- bool mDescItems;
- int mDragPosX, mDragPosY;
+ int mSelectedIndex = -1;
+ int mHighlightedIndex = -1;
+ int mLastUsedSlot = -1;
+ SelectionState mSelectionStatus = SEL_NONE;
+ bool mSwapItems = false;
+ bool mDescItems = false;
+ int mDragPosX = 0;
+ int mDragPosY = 0;
std::map<int, Item*> mFilteredMap;
@@ -191,10 +194,7 @@ class ItemContainer : public gcn::Widget,
ItemPopup *mItemPopup;
- using SelectionListenerList = std::list<gcn::SelectionListener *>;
- using SelectionListenerIterator = SelectionListenerList::iterator;
-
- SelectionListenerList mSelectionListeners;
+ std::list<gcn::SelectionListener *> mSelectionListeners;
};
#endif // ITEMCONTAINER_H
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index a43596f8..6c57bd00 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -31,19 +31,14 @@
#include "gui/inventorywindow.h"
#include "gui/itempopup.h"
-#include "gui/palette.h"
#include "gui/viewport.h"
#include "resources/image.h"
-#include "resources/iteminfo.h"
#include "resources/theme.h"
#include "utils/stringutils.h"
-ItemShortcutContainer::ItemShortcutContainer():
- ShortcutContainer(),
- mItemClicked(false),
- mItemMoved(nullptr)
+ItemShortcutContainer::ItemShortcutContainer()
{
addMouseListener(this);
addWidgetListener(this);
@@ -86,7 +81,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
// Draw item keyboard shortcut.
const char *key = SDL_GetKeyName(
- (SDL_Scancode) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i));
+ (SDL_Scancode) keyboard.getKeyValue(KeyboardConfig::KEY_SHORTCUT_1 + i));
graphics->setColor(Theme::getThemeColor(Theme::TEXT));
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
@@ -122,8 +117,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
if (mItemMoved)
{
// Draw the item image being dragged by the cursor.
- Image* image = mItemMoved->getImage();
- if (image)
+ if (Image* image = mItemMoved->getImage())
{
const int tPosX = mCursorPosX - (image->getWidth() / 2);
const int tPosY = mCursorPosY - (image->getHeight() / 2);
diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h
index 55d14977..243920a0 100644
--- a/src/gui/widgets/itemshortcutcontainer.h
+++ b/src/gui/widgets/itemshortcutcontainer.h
@@ -66,8 +66,8 @@ class ItemShortcutContainer : public ShortcutContainer
void mouseExited(gcn::MouseEvent &event) override;
void mouseMoved(gcn::MouseEvent &event) override;
- bool mItemClicked;
- Item *mItemMoved;
+ bool mItemClicked = false;
+ Item *mItemMoved = nullptr;
ItemPopup *mItemPopup;
};
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 3659baa1..f7941889 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -175,14 +175,15 @@ LayoutCell &LayoutArray::place(gcn::Widget *widget, int x, int y, int w, int h)
cell.mPadding = 0;
cell.mAlign[0] = LayoutCell::FILL;
cell.mAlign[1] = LayoutCell::FILL;
- short &cs = mSizes[0][x], &rs = mSizes[1][y];
+ short &cs = mSizes[0][x];
+ short &rs = mSizes[1][y];
if (cs == Layout::AUTO_DEF && w == 1) cs = 0;
if (rs == Layout::AUTO_DEF && h == 1) rs = 0;
return cell;
}
void LayoutArray::align(int &pos, int &size, int dim,
- LayoutCell const &cell, short *sizes) const
+ LayoutCell const &cell, const short *sizes) const
{
int size_max = sizes[0];
for (int i = 1; i < cell.mExtent[dim]; ++i)
@@ -207,7 +208,8 @@ void LayoutArray::align(int &pos, int &size, int dim,
std::vector< short > LayoutArray::getSizes(int dim, int upp) const
{
- int gridW = mSizes[0].size(), gridH = mSizes[1].size();
+ int gridW = mSizes[0].size();
+ int gridH = mSizes[1].size();
std::vector< short > sizes = mSizes[dim];
// Compute minimum sizes.
@@ -251,7 +253,8 @@ std::vector< short > LayoutArray::getSizes(int dim, int upp) const
for (int i = 0; i < nb; ++i)
{
- if (mSizes[dim][i] > Layout::AUTO_DEF) continue;
+ if (mSizes[dim][i] > Layout::AUTO_DEF)
+ continue;
int s = upp / nbFill;
sizes[i] += s;
upp -= s;
@@ -276,7 +279,8 @@ int LayoutArray::getSize(int dim) const
void LayoutArray::reflow(int nx, int ny, int nw, int nh)
{
- int gridW = mSizes[0].size(), gridH = mSizes[1].size();
+ int gridW = mSizes[0].size();
+ int gridH = mSizes[1].size();
std::vector< short > widths = getSizes(0, nw);
std::vector< short > heights = getSizes(1, nh);
diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h
index 1c6faf89..4e4b28c5 100644
--- a/src/gui/widgets/layout.h
+++ b/src/gui/widgets/layout.h
@@ -125,7 +125,7 @@ class LayoutArray
* Gets the position and size of a widget along a given axis
*/
void align(int &pos, int &size, int dim,
- LayoutCell const &cell, short *sizes) const;
+ LayoutCell const &cell, const short *sizes) const;
/**
* Ensures the private vectors are large enough.
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index e696d934..8e2c8311 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -23,7 +23,6 @@
#include "configuration.h"
-#include "gui/palette.h"
#include "gui/sdlinput.h"
#include "resources/theme.h"
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index 25787ca7..a453b618 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -58,7 +58,7 @@ class ListBox : public gcn::ListBox
/**
* Update the alpha value to the graphic components.
*/
- void updateAlpha();
+ static void updateAlpha();
// Inherited from KeyListener
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 4379b4d9..671fad36 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -45,11 +45,11 @@ PlayerBox::PlayerBox(const Being *being):
Image *textbox = Theme::getImageFromTheme("deepbox.png");
int bggridx[4] = {0, 3, 28, 31};
int bggridy[4] = {0, 3, 28, 31};
- int a = 0, x, y;
+ int a = 0;
- for (y = 0; y < 3; y++)
+ for (int y = 0; y < 3; y++)
{
- for (x = 0; x < 3; x++)
+ for (int x = 0; x < 3; x++)
{
background.grid[a] = textbox->getSubImage(
bggridx[x], bggridy[y],
@@ -98,10 +98,9 @@ void PlayerBox::draw(gcn::Graphics *graphics)
void PlayerBox::drawFrame(gcn::Graphics *graphics)
{
- int w, h, bs;
- bs = getFrameSize();
- w = getWidth() + bs * 2;
- h = getHeight() + bs * 2;
+ const int bs = getFrameSize();
+ const int w = getWidth() + bs * 2;
+ const int h = getHeight() + bs * 2;
static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, background);
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 298443e7..b79f1370 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -22,7 +22,6 @@
#include "gui/widgets/popup.h"
-#include "configuration.h"
#include "graphics.h"
#include "log.h"
@@ -30,15 +29,12 @@
#include "gui/widgets/windowcontainer.h"
-#include "resources/image.h"
#include "resources/theme.h"
#include <guichan/exception.hpp>
Popup::Popup(const std::string &name, const std::string &skin):
mPopupName(name),
- mMinWidth(100),
- mMinHeight(40),
mMaxWidth(graphics->getWidth()),
mMaxHeight(graphics->getHeight())
{
@@ -105,10 +101,12 @@ void Popup::setContentSize(int width, int height)
void Popup::setLocationRelativeTo(gcn::Widget *widget)
{
- int wx, wy;
- int x, y;
-
+ int wx;
+ int wy;
widget->getAbsolutePosition(wx, wy);
+
+ int x;
+ int y;
getAbsolutePosition(x, y);
setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x),
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index af37b211..2aaa63f7 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -23,7 +23,6 @@
#ifndef POPUP_H
#define POPUP_H
-#include "configuration.h"
#include "guichanfwd.h"
#include "gui/widgets/container.h"
@@ -154,8 +153,8 @@ class Popup : public Container, public gcn::MouseListener
private:
std::string mPopupName; /**< Name of the popup */
- int mMinWidth; /**< Minimum popup width */
- int mMinHeight; /**< Minimum popup height */
+ int mMinWidth = 100; /**< Minimum popup width */
+ int mMinHeight = 40; /**< Minimum popup height */
int mMaxWidth; /**< Maximum popup width */
int mMaxHeight; /**< Maximum popup height */
int mPadding; /**< Holds the padding of the popup. */
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 4190c0e4..523dde1c 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -41,10 +41,7 @@ float ProgressBar::mAlpha = 1.0;
ProgressBar::ProgressBar(float progress,
int width, int height,
int color):
- gcn::Widget(),
- mSmoothProgress(true),
- mProgressPalette(color),
- mSmoothColorChange(true)
+ mProgressPalette(color)
{
// The progress value is directly set at load time:
if (progress > 1.0f || progress < 0.0f)
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index d3a4c100..d7289816 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -54,7 +54,7 @@ class ProgressBar : public gcn::Widget
/**
* Update the alpha value to the graphic components.
*/
- void updateAlpha();
+ static void updateAlpha();
/**
* Draws the progress bar.
@@ -120,12 +120,12 @@ class ProgressBar : public gcn::Widget
private:
float mProgress, mProgressToGo;
- bool mSmoothProgress;
+ bool mSmoothProgress = true;
int mProgressPalette; /** < Entry in ProgressPalette or -1 for none. */
gcn::Color mColor;
gcn::Color mColorToGo;
- bool mSmoothColorChange;
+ bool mSmoothColorChange = true;
std::string mText;
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 676daede..bb96d77c 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -38,8 +38,7 @@ Image *RadioButton::radioCheckedHi;
RadioButton::RadioButton(const std::string &caption, const std::string &group,
bool marked):
- gcn::RadioButton(caption, group, marked),
- mHasMouse(false)
+ gcn::RadioButton(caption, group, marked)
{
if (instances == 0)
{
@@ -136,4 +135,3 @@ void RadioButton::mouseExited(gcn::MouseEvent& event)
{
mHasMouse = false;
}
-
diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h
index 014acd06..2a96ff6e 100644
--- a/src/gui/widgets/radiobutton.h
+++ b/src/gui/widgets/radiobutton.h
@@ -61,7 +61,7 @@ class RadioButton : public gcn::RadioButton
private:
static int instances;
static float mAlpha;
- bool mHasMouse;
+ bool mHasMouse = false;
static Image *radioNormal;
static Image *radioChecked;
static Image *radioDisabled;
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index f4d8007a..e153ba65 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -36,23 +36,14 @@ ImageRect ScrollArea::vMarker;
ImageRect ScrollArea::vMarkerHi;
Image *ScrollArea::buttons[4][2];
-ScrollArea::ScrollArea():
- gcn::ScrollArea(),
- mX(0),
- mY(0),
- mHasMouse(false),
- mOpaque(true)
+ScrollArea::ScrollArea()
{
addWidgetListener(this);
init();
}
ScrollArea::ScrollArea(gcn::Widget *widget):
- gcn::ScrollArea(widget),
- mX(0),
- mY(0),
- mHasMouse(false),
- mOpaque(true)
+ gcn::ScrollArea(widget)
{
init();
}
@@ -97,11 +88,11 @@ void ScrollArea::init()
Image *textbox = Theme::getImageFromTheme("deepbox.png");
const int bggridx[4] = {0, 3, 28, 31};
const int bggridy[4] = {0, 3, 28, 31};
- int a = 0, x, y;
+ int a = 0;
- for (y = 0; y < 3; y++)
+ for (int y = 0; y < 3; y++)
{
- for (x = 0; x < 3; x++)
+ for (int x = 0; x < 3; x++)
{
background.grid[a] = textbox->getSubImage(
bggridx[x], bggridy[y],
@@ -122,9 +113,9 @@ void ScrollArea::init()
int vsgridy[4] = {0, 4, 15, 19};
a = 0;
- for (y = 0; y < 3; y++)
+ for (int y = 0; y < 3; y++)
{
- for (x = 0; x < 3; x++)
+ for (int x = 0; x < 3; x++)
{
vMarker.grid[a] = vscroll->getSubImage(
vsgridx[x], vsgridy[y],
@@ -384,5 +375,6 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event)
void ScrollArea::widgetResized(const gcn::Event &event)
{
- getContent()->setSize(getWidth() - 2 * getFrameSize(), getHeight() - 2 * getFrameSize());
+ getContent()->setSize(getWidth() - 2 * getFrameSize(),
+ getHeight() - 2 * getFrameSize());
}
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 266b5a31..2fae2d4b 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -67,7 +67,7 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
/**
* Update the alpha value to the graphic components.
*/
- void updateAlpha();
+ static void updateAlpha();
/**
* Draws the scroll area.
@@ -136,9 +136,10 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
static ImageRect vMarkerHi;
static Image *buttons[4][2];
- int mX,mY;
- bool mHasMouse;
- bool mOpaque;
+ int mX = 0;
+ int mY = 0;
+ bool mHasMouse = false;
+ bool mOpaque = true;
};
#endif
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index d6dd087a..d0c79af2 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -39,8 +39,7 @@
float ShopListBox::mAlpha = 1.0;
ShopListBox::ShopListBox(gcn::ListModel *listModel):
- ListBox(listModel),
- mPlayerMoney(0)
+ ListBox(listModel)
{
mRowHeight = getFont()->getHeight();
mPriceCheck = true;
@@ -50,7 +49,6 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel):
ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel):
ListBox(listModel),
- mPlayerMoney(0),
mShopItems(shopListModel)
{
mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE);
@@ -192,4 +190,3 @@ void ShopListBox::mouseExited(gcn::MouseEvent &event)
{
mItemPopup->setVisible(false);
}
-
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
index c3d10a4a..b5718ed3 100644
--- a/src/gui/widgets/shoplistbox.h
+++ b/src/gui/widgets/shoplistbox.h
@@ -83,7 +83,7 @@ class ShopListBox : public ListBox
void mouseExited(gcn::MouseEvent &event) override;
private:
- int mPlayerMoney;
+ int mPlayerMoney = 0;
/**
* Keeps another pointer to the same listModel, permitting to
diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp
index 5edd88bc..5925752e 100644
--- a/src/gui/widgets/shortcutcontainer.cpp
+++ b/src/gui/widgets/shortcutcontainer.cpp
@@ -21,17 +21,9 @@
#include "gui/widgets/shortcutcontainer.h"
-#include "configuration.h"
-
-#include "resources/image.h"
-
-#include "utils/stringutils.h"
-
float ShortcutContainer::mAlpha = 1.0;
-ShortcutContainer::ShortcutContainer():
- mGridWidth(1),
- mGridHeight(1)
+ShortcutContainer::ShortcutContainer()
{
}
@@ -52,8 +44,8 @@ void ShortcutContainer::widgetResized(const gcn::Event &event)
int ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const
{
- const gcn::Rectangle tRect = gcn::Rectangle(0, 0, mGridWidth * mBoxWidth,
- mGridHeight * mBoxHeight);
+ const gcn::Rectangle tRect(0, 0, mGridWidth * mBoxWidth,
+ mGridHeight * mBoxHeight);
int index = ((pointY / mBoxHeight) * mGridWidth) + pointX / mBoxWidth;
diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h
index f0f9b730..449a06f3 100644
--- a/src/gui/widgets/shortcutcontainer.h
+++ b/src/gui/widgets/shortcutcontainer.h
@@ -91,11 +91,13 @@ class ShortcutContainer : public gcn::Widget,
static float mAlpha;
- int mMaxItems;
- int mBoxWidth;
- int mBoxHeight;
- int mCursorPosX, mCursorPosY;
- int mGridWidth, mGridHeight;
+ int mMaxItems = 0;
+ int mBoxWidth = 0;
+ int mBoxHeight = 0;
+ int mCursorPosX = 0;
+ int mCursorPosY = 0;
+ int mGridWidth = 1;
+ int mGridHeight = 1;
};
#endif
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 3852159b..fd21becf 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -35,15 +35,13 @@ float Slider::mAlpha = 1.0;
int Slider::mInstances = 0;
Slider::Slider(double scaleEnd):
- gcn::Slider(scaleEnd),
- mHasMouse(false)
+ gcn::Slider(scaleEnd)
{
init();
}
Slider::Slider(double scaleStart, double scaleEnd):
- gcn::Slider(scaleStart, scaleEnd),
- mHasMouse(false)
+ gcn::Slider(scaleStart, scaleEnd)
{
init();
}
diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h
index d5b9d5ec..3896cb52 100644
--- a/src/gui/widgets/slider.h
+++ b/src/gui/widgets/slider.h
@@ -52,7 +52,7 @@ class Slider : public gcn::Slider
/**
* Update the alpha value to the graphic components.
*/
- void updateAlpha();
+ static void updateAlpha();
/**
* Draws the slider.
@@ -84,7 +84,7 @@ class Slider : public gcn::Slider
static Image *vStart, *vMid, *vEnd, *vGrip;
static Image *hStartHi, *hMidHi, *hEndHi, *hGripHi;
static Image *vStartHi, *vMidHi, *vEndHi, *vGripHi;
- bool mHasMouse;
+ bool mHasMouse = false;
static float mAlpha;
static int mInstances;
};
diff --git a/src/gui/widgets/spacer.h b/src/gui/widgets/spacer.h
index 11e0ac66..f6a210dc 100644
--- a/src/gui/widgets/spacer.h
+++ b/src/gui/widgets/spacer.h
@@ -23,7 +23,6 @@
#define SPACER_H
#include "guichan/graphics.hpp"
-#include "guichan/platform.hpp"
#include "guichan/widget.hpp"
/**
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 223d91ec..08acd245 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -60,7 +60,7 @@ static TabData const data[TAB_COUNT] = {
ImageRect Tab::tabImg[TAB_COUNT];
-Tab::Tab() : gcn::Tab(),
+Tab::Tab() :
mTabColor(&Theme::getThemeColor(Theme::TAB))
{
init();
@@ -90,15 +90,13 @@ void Tab::init()
// Load the skin
Image *tab[TAB_COUNT];
- int a, x, y, mode;
-
- for (mode = 0; mode < TAB_COUNT; mode++)
+ for (int mode = 0; mode < TAB_COUNT; mode++)
{
tab[mode] = Theme::getImageFromTheme(data[mode].file);
- a = 0;
- for (y = 0; y < 3; y++)
+ int a = 0;
+ for (int y = 0; y < 3; y++)
{
- for (x = 0; x < 3; x++)
+ for (int x = 0; x < 3; x++)
{
tabImg[mode].grid[a] = tab[mode]->getSubImage(
data[mode].gridX[x], data[mode].gridY[y],
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 9dc5291e..86650257 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -40,7 +40,7 @@ class Tab : public gcn::Tab
/**
* Update the alpha value to the graphic components.
*/
- void updateAlpha();
+ static void updateAlpha();
/**
* Draw the tabbed area.
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 1fdd276f..644adf07 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -25,10 +25,7 @@
#include <guichan/widgets/container.hpp>
-TabbedArea::TabbedArea() : gcn::TabbedArea(),
- mTabsWidth(0),
- mVisibleTabsWidth(0),
- mTabScrollIndex(0)
+TabbedArea::TabbedArea()
{
mWidgetContainer->setOpaque(false);
addWidgetListener(this);
@@ -51,13 +48,10 @@ int TabbedArea::getNumberOfTabs() const
Tab *TabbedArea::getTab(const std::string &name) const
{
- auto itr = mTabs.begin(), itr_end = mTabs.end();
- while (itr != itr_end)
+ for (auto itr = mTabs.begin(); itr != mTabs.end(); ++itr)
{
if ((*itr).first->getCaption() == name)
return static_cast<Tab*>((*itr).first);
-
- ++itr;
}
return nullptr;
}
@@ -72,13 +66,10 @@ void TabbedArea::draw(gcn::Graphics *graphics)
gcn::Widget *TabbedArea::getWidget(const std::string &name) const
{
- auto itr = mTabs.begin(), itr_end = mTabs.end();
- while (itr != itr_end)
+ for (const auto &[tab, widget] : mTabs)
{
- if ((*itr).first->getCaption() == name)
- return (*itr).second;
-
- ++itr;
+ if (tab->getCaption() == name)
+ return widget;
}
return nullptr;
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 53bb2bb2..18e923bf 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -130,7 +130,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
/**
* The overall width of all tab.
*/
- int mTabsWidth;
+ int mTabsWidth = 0;
/**
* Update the overall width of visible tab. Used to know whether
@@ -141,7 +141,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
/**
* The overall width of visible tab.
*/
- int mVisibleTabsWidth;
+ int mVisibleTabsWidth = 0;
/**
@@ -150,7 +150,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
* So the first tab displayed may not be the first in the list.
* @note the index must start at 0.
*/
- unsigned mTabScrollIndex;
+ unsigned mTabScrollIndex = 0;
};
#endif
diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp
index 465fbc61..a74fc09e 100644
--- a/src/gui/widgets/table.cpp
+++ b/src/gui/widgets/table.cpp
@@ -173,18 +173,16 @@ void GuiTable::setLinewiseSelection(bool linewise)
int GuiTable::getRowHeight() const
{
- if (mModel)
- return mModel->getRowHeight() + 1; // border
- else
+ if (!mModel)
return 0;
+ return mModel->getRowHeight() + 1; // border
}
int GuiTable::getColumnWidth(int i) const
{
- if (mModel)
- return mModel->getColumnWidth(i) + 1; // border
- else
+ if (!mModel)
return 0;
+ return mModel->getColumnWidth(i) + 1; // border
}
void GuiTable::setSelectedRow(int selected)
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 2239bed4..872227ea 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -44,10 +44,7 @@ float TextField::mAlpha = 1.0;
ImageRect TextField::skin;
TextField::TextField(const std::string &text, bool loseFocusOnTab):
- gcn::TextField(text),
- mNumeric(false),
- mAutoComplete(nullptr),
- mHistory(nullptr)
+ gcn::TextField(text)
{
setFrameSize(2);
@@ -59,11 +56,11 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab):
Image *textbox = Theme::getImageFromTheme("deepbox.png");
int gridx[4] = {0, 3, 28, 31};
int gridy[4] = {0, 3, 28, 31};
- int a = 0, x, y;
+ int a = 0;
- for (y = 0; y < 3; y++)
+ for (int y = 0; y < 3; y++)
{
- for (x = 0; x < 3; x++)
+ for (int x = 0; x < 3; x++)
{
skin.grid[a] = textbox->getSubImage(
gridx[x], gridy[y],
@@ -120,10 +117,9 @@ void TextField::drawFrame(gcn::Graphics *graphics)
{
//updateAlpha(); -> Not useful...
- int w, h, bs;
- bs = getFrameSize();
- w = getWidth() + bs * 2;
- h = getHeight() + bs * 2;
+ int bs = getFrameSize();
+ int w = getWidth() + bs * 2;
+ int h = getHeight() + bs * 2;
static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin);
}
@@ -215,7 +211,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
mHistory->current = prevHist;
}
}
- else if (getText() != "")
+ else if (!getText().empty())
{
// Always clear (easy access to useful function)
setText("");
@@ -294,13 +290,13 @@ void TextField::textInput(const TextInput &textInput)
void TextField::autoComplete()
{
- if (mAutoComplete && mText.size() > 0)
+ if (mAutoComplete && !mText.empty())
{
const int caretPos = getCaretPosition();
int startName = 0;
const std::string inputText = getText();
std::string name = inputText.substr(0, caretPos);
- std::string newName("");
+ std::string newName;
for (int f = caretPos - 1; f > -1; f--)
{
@@ -320,7 +316,7 @@ void TextField::autoComplete()
mAutoComplete->getAutoCompleteList(nameList);
newName = autocomplete(nameList, name);
- if (newName == "" && mHistory)
+ if (newName.empty() && mHistory)
{
auto i = mHistory->history.begin();
@@ -335,7 +331,7 @@ void TextField::autoComplete()
f++;
}
line = line.substr(0, f);
- if (line != "")
+ if (!line.empty())
{
nameList.push_back(line);
}
@@ -345,7 +341,7 @@ void TextField::autoComplete()
newName = autocomplete(nameList, name);
}
- if (newName != "")
+ if (!newName.empty())
{
if(inputText[0] == '@' || inputText[0] == '/')
newName = "\"" + newName + "\"";
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index b1b7a6a4..bb39810b 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -33,7 +33,8 @@ class TextField;
using TextHistoryList = std::list<std::string>;
using TextHistoryIterator = TextHistoryList::iterator;
-struct TextHistory {
+struct TextHistory
+{
TextHistoryList history; /**< Command history. */
TextHistoryIterator current; /**< History iterator. */
@@ -90,7 +91,7 @@ class TextField : public gcn::TextField
/**
* Update the alpha value to the graphic components.
*/
- void updateAlpha();
+ static void updateAlpha();
/**
* Draws the background and border.
@@ -168,14 +169,14 @@ class TextField : public gcn::TextField
static int instances;
static float mAlpha;
static ImageRect skin;
- bool mNumeric;
+ bool mNumeric = false;
int mMinimum;
int mMaximum;
bool mLoseFocusOnTab;
- AutoCompleteLister *mAutoComplete;
+ AutoCompleteLister *mAutoComplete = nullptr;
- TextHistory *mHistory; /**< Text history. */
+ TextHistory *mHistory = nullptr; /**< Text history. */
};
#endif
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index d6ef172c..8b2c3a75 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -25,7 +25,6 @@
#include "textrenderer.h"
#include "gui/gui.h"
-#include "gui/palette.h"
#include "gui/truetypefont.h"
#include <typeinfo>
@@ -35,12 +34,9 @@ float TextPreview::mAlpha = 1.0;
TextPreview::TextPreview(const std::string &text):
mText(text)
{
- mTextAlpha = false;
mFont = gui->getFont();
mTextColor = &Theme::getThemeColor(Theme::TEXT);
- mTextBGColor = nullptr;
mBGColor = &Theme::getThemeColor(Theme::BACKGROUND);
- mOpaque = false;
}
void TextPreview::draw(gcn::Graphics* graphics)
diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h
index 0cda7c8b..7e88248f 100644
--- a/src/gui/widgets/textpreview.h
+++ b/src/gui/widgets/textpreview.h
@@ -131,12 +131,12 @@ class TextPreview : public gcn::Widget
std::string mText;
const gcn::Color *mTextColor;
const gcn::Color *mBGColor;
- const gcn::Color *mTextBGColor;
+ const gcn::Color *mTextBGColor = nullptr;
static float mAlpha;
- bool mTextAlpha;
- bool mOpaque;
- bool mShadow;
- bool mOutline;
+ bool mTextAlpha = false;
+ bool mOpaque = false;
+ bool mShadow = false;
+ bool mOutline = false;
};
#endif
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index a0c227ab..89f3abc9 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -21,8 +21,7 @@
#include "gui/widgets/vertcontainer.h"
VertContainer::VertContainer(int spacing):
- mSpacing(spacing),
- mCount(0)
+ mSpacing(spacing)
{
addWidgetListener(this);
}
diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h
index 439f7ca1..b66957d3 100644
--- a/src/gui/widgets/vertcontainer.h
+++ b/src/gui/widgets/vertcontainer.h
@@ -40,7 +40,7 @@ class VertContainer : public Container, public gcn::WidgetListener
private:
int mSpacing;
- int mCount;
+ int mCount = 0;
};
#endif
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 31f81e62..636f48dd 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -31,7 +31,6 @@
#include "resources/theme.h"
#include "utils/gettext.h"
-#include "utils/stringutils.h"
WhisperTab::WhisperTab(const std::string &nick) :
ChatTab(nick),
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 05638470..6d970b0b 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -25,7 +25,6 @@
#include "log.h"
#include "gui/gui.h"
-#include "gui/palette.h"
#include "gui/viewport.h"
#include "gui/widgets/layout.h"
@@ -44,19 +43,8 @@ int Window::mouseResize = 0;
Window::Window(const std::string &caption, bool modal, Window *parent,
const std::string &skin):
gcn::Window(caption),
- mGrip(nullptr),
mParent(parent),
- mLayout(nullptr),
- mWindowName("window"),
- mShowTitle(true),
mModal(modal),
- mCloseButton(false),
- mDefaultVisible(false),
- mSaveVisible(false),
- mStickyButton(false),
- mSticky(false),
- mMinWinWidth(100),
- mMinWinHeight(40),
mMaxWinWidth(graphics->getWidth()),
mMaxWinHeight(graphics->getHeight())
{
@@ -167,10 +155,12 @@ void Window::setContentSize(int width, int height)
void Window::setLocationRelativeTo(gcn::Widget *widget)
{
- int wx, wy;
- int x, y;
-
+ int wx;
+ int wy;
widget->getAbsolutePosition(wx, wy);
+
+ int x;
+ int y;
getAbsolutePosition(x, y);
setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x),
@@ -611,7 +601,8 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight,
ImageRect::ImagePosition position,
int offsetX, int offsetY)
{
- int x = 0, y = 0;
+ int x = 0;
+ int y = 0;
if (position == ImageRect::UPPER_LEFT)
{
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index fe2b217c..ef529a9f 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -345,9 +345,9 @@ class Window : public gcn::Window, gcn::WidgetListener
virtual void close();
/**
- * Gets the alpha value used by the window, in a GUIChan usable format.
+ * Gets the alpha value used by the window, in a Guichan usable format.
*/
- int getGuiAlpha();
+ static int getGuiAlpha();
private:
enum ResizeHandles
@@ -374,19 +374,19 @@ class Window : public gcn::Window, gcn::WidgetListener
*/
int getResizeHandles(gcn::MouseEvent &event);
- ResizeGrip *mGrip; /**< Resize grip */
+ ResizeGrip *mGrip = nullptr; /**< Resize grip */
Window *mParent; /**< The parent window */
- Layout *mLayout; /**< Layout handler */
- std::string mWindowName; /**< Name of the window */
- bool mShowTitle; /**< Window has a title bar */
+ Layout *mLayout = nullptr; /**< Layout handler */
+ std::string mWindowName = "window"; /**< Name of the window */
+ bool mShowTitle = true; /**< Window has a title bar */
bool mModal; /**< Window is modal */
- bool mCloseButton; /**< Window has a close button */
- bool mDefaultVisible; /**< Window's default visibility */
- bool mSaveVisible; /**< Window will save visibility */
- bool mStickyButton; /**< Window has a sticky button */
- bool mSticky; /**< Window resists hiding*/
- int mMinWinWidth; /**< Minimum window width */
- int mMinWinHeight; /**< Minimum window height */
+ bool mCloseButton = false; /**< Window has a close button */
+ bool mDefaultVisible = false; /**< Window's default visibility */
+ bool mSaveVisible = false; /**< Window will save visibility */
+ bool mStickyButton = false; /**< Window has a sticky button */
+ bool mSticky = false; /**< Window resists hiding*/
+ int mMinWinWidth = 100; /**< Minimum window width */
+ int mMinWinHeight = 40; /**< Minimum window height */
int mMaxWinWidth; /**< Maximum window width */
int mMaxWinHeight; /**< Maximum window height */
int mDefaultX; /**< Default window X position */
diff --git a/src/guild.cpp b/src/guild.cpp
index f21f015a..a6f783d4 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -24,20 +24,19 @@
#include "actorspritemanager.h"
GuildMember::GuildMember(Guild *guild, int id, const std::string &name):
- Avatar(name), mId(id), mGuild(guild)
+ Avatar(name), mId(id), mGuild(guild)
{
}
GuildMember::GuildMember(Guild *guild, const std::string &name):
- Avatar(name), mId(0), mGuild(guild)
+ Avatar(name), mGuild(guild)
{
}
Guild::GuildMap Guild::guilds;
Guild::Guild(short id):
- mId(id),
- mCanInviteUsers(false)
+ mId(id)
{
guilds[id] = this;
}
@@ -74,84 +73,63 @@ GuildMember *Guild::addMember(const std::string &name)
GuildMember *Guild::getMember(int id) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->mId == id)
- return (*itr);
- ++itr;
- }
+ for (auto member : mMembers)
+ if (member->mId == id)
+ return member;
return nullptr;
}
GuildMember *Guild::getMember(const std::string &name) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->getName() == name)
- {
- return (*itr);
- }
- ++itr;
- }
+ for (auto member : mMembers)
+ if (member->getName() == name)
+ return member;
return nullptr;
}
void Guild::removeMember(GuildMember *member)
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
+ for (auto itr = mMembers.begin(), itr_end = mMembers.end();
+ itr != itr_end; ++itr)
{
- if((*itr)->mId == member->mId &&
- (*itr)->getName() == member->getName())
+ if ((*itr)->mId == member->mId &&
+ (*itr)->getName() == member->getName())
{
mMembers.erase(itr);
}
- ++itr;
}
}
void Guild::removeMember(int id)
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
+ for (auto itr = mMembers.begin(), itr_end = mMembers.end();
+ itr != itr_end; ++itr)
{
if ((*itr)->mId == id)
mMembers.erase(itr);
- ++itr;
}
}
void Guild::removeMember(const std::string &name)
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
+ for (auto itr = mMembers.begin(), itr_end = mMembers.end();
+ itr != itr_end; ++itr)
{
- if((*itr)->getName() == name)
+ if ((*itr)->getName() == name)
{
mMembers.erase(itr);
}
- ++itr;
}
}
void Guild::removeFromMembers()
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while(itr != itr_end)
+ for (auto member : mMembers)
{
- Being *b = actorSpriteManager->findBeing((*itr)->getID());
+ Being *b = actorSpriteManager->findBeing(member->getID());
b->removeGuild(getId());
- ++itr;
}
}
@@ -172,16 +150,13 @@ bool Guild::isMember(GuildMember *member) const
if (member->mGuild != nullptr && member->mGuild != this)
return false;
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
+ for (auto mMember : mMembers)
{
- if ((*itr)->mId == member->mId &&
- (*itr)->getName() == member->getName())
+ if (mMember->mId == member->mId &&
+ mMember->getName() == member->getName())
{
return true;
}
- ++itr;
}
return false;
@@ -189,44 +164,20 @@ bool Guild::isMember(GuildMember *member) const
bool Guild::isMember(int id) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->mId == id)
- return true;
- ++itr;
- }
-
- return false;
+ return getMember(id) != nullptr;
}
bool Guild::isMember(const std::string &name) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->getName() == name)
- {
- return true;
- }
- ++itr;
- }
-
- return false;
+ return getMember(name) != nullptr;
}
void Guild::getNames(std::vector<std::string> &names) const
{
names.clear();
- auto it = mMembers.begin(),
- it_end = mMembers.end();
- while (it != it_end)
- {
- names.push_back((*it)->getName());
- ++it;
- }
+
+ for (auto member : mMembers)
+ names.push_back(member->getName());
}
Guild *Guild::getGuild(int id)
diff --git a/src/guild.h b/src/guild.h
index deee8e7b..e24893b4 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -48,7 +48,7 @@ protected:
GuildMember(Guild *guild, const std::string &name);
- int mId;
+ int mId = 0;
Guild *mGuild;
};
@@ -165,11 +165,10 @@ private:
*/
Guild(short id);
- using MemberList = std::vector<GuildMember *>;
- MemberList mMembers;
+ std::vector<GuildMember *> mMembers;
std::string mName;
short mId;
- bool mCanInviteUsers;
+ bool mCanInviteUsers = false;
};
#endif // GUILD_H
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index ca639317..95fbd6f4 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -25,13 +25,11 @@
#include "configuration.h"
#include "event.h"
#include "flooritem.h"
-#include "graphics.h"
#include "guild.h"
#include "item.h"
#include "map.h"
#include "particle.h"
#include "playerinfo.h"
-#include "simpleanimation.h"
#include "sound.h"
#include "gui/gui.h"
@@ -42,43 +40,22 @@
#include "net/chathandler.h"
#include "net/gamehandler.h"
#include "net/guildhandler.h"
-#include "net/inventoryhandler.h"
#include "net/net.h"
#include "net/partyhandler.h"
#include "net/playerhandler.h"
-#include "net/specialhandler.h"
-#include "net/tradehandler.h"
-#include "resources/animation.h"
-#include "resources/imageset.h"
#include "resources/iteminfo.h"
#include "resources/userpalette.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <cassert>
-
const int AWAY_LIMIT_TIMER = 60;
LocalPlayer *local_player = nullptr;
LocalPlayer::LocalPlayer(int id, int subtype):
- Being(id, PLAYER, subtype, nullptr),
- mAttackRange(-1),
- mTargetTime(-1),
- mLastTargetTime(-1),
- mTarget(nullptr),
- mPickUpTarget(nullptr),
- mGoingToTarget(false), mKeepAttacking(false),
- mLastActionTime(-1),
- mWalkingDir(0),
- mPathSetByMouse(false),
- mMessageTime(0),
- mShowIp(false),
- mAwayDialog(nullptr),
- mAfkTime(0),
- mAwayMode(false)
+ Being(id, PLAYER, subtype, nullptr)
{
listen(Event::AttributesChannel);
@@ -216,9 +193,9 @@ void LocalPlayer::setGMLevel(int level)
Position LocalPlayer::getNextWalkPosition(unsigned char dir)
{
-
// Compute where the next tile will be set.
- int dx = 0, dy = 0;
+ int dx = 0;
+ int dy = 0;
if (dir & Being::UP)
dy--;
if (dir & Being::DOWN)
diff --git a/src/localplayer.h b/src/localplayer.h
index 7a9020d6..82e38b5b 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -28,9 +28,6 @@
#include <guichan/actionlistener.hpp>
-#include <memory>
-#include <vector>
-
class ChatTab;
class FloorItem;
class ImageSet;
@@ -187,7 +184,7 @@ class LocalPlayer : public Being
void changeAwayMode();
- bool getAwayMode()
+ bool getAwayMode() const
{ return mAwayMode; }
void setAway(const std::string &message);
@@ -234,35 +231,35 @@ class LocalPlayer : public Being
*/
Position getNextWalkPosition(unsigned char dir);
- int mAttackRange;
+ int mAttackRange = -1;
- int mTargetTime; /**< How long the being has been targeted **/
+ int mTargetTime = -1; /**< How long the being has been targeted **/
/** Time stamp of last targeting action, -1 if none. */
- int mLastTargetTime;
+ int mLastTargetTime = -1;
- int mGMLevel;
+ int mGMLevel = 0;
- Being *mTarget;
+ Being *mTarget = nullptr;
- FloorItem *mPickUpTarget;
+ FloorItem *mPickUpTarget = nullptr;
- bool mGoingToTarget;
- bool mKeepAttacking; /**< Whether or not to continue to attack */
- int mLastActionTime; /**< Time stamp of the last action, -1 if none. */
- int mWalkingDir; /**< The direction the player is walking in. */
- bool mPathSetByMouse; /**< Tells if the path was set using mouse */
+ bool mGoingToTarget = false;
+ bool mKeepAttacking = false; /**< Whether or not to continue to attack */
+ int mLastActionTime = -1; /**< Time stamp of the last action, -1 if none. */
+ int mWalkingDir = 0; /**< The direction the player is walking in. */
+ bool mPathSetByMouse = false; /**< Tells if the path was set using mouse */
using MessagePair = std::pair<std::string, int>;
/** Queued messages*/
std::list<MessagePair> mMessages;
- int mMessageTime;
+ int mMessageTime = 0;
- bool mShowIp;
+ bool mShowIp = false;
AwayListener *mAwayListener;
- OkDialog *mAwayDialog;
- int mAfkTime;
- bool mAwayMode;
+ OkDialog *mAwayDialog = nullptr;
+ int mAfkTime = 0;
+ bool mAwayMode = false;
};
extern LocalPlayer *local_player;
diff --git a/src/net/logindata.h b/src/net/logindata.h
index 162ba1fa..380f9061 100644
--- a/src/net/logindata.h
+++ b/src/net/logindata.h
@@ -29,10 +29,7 @@
class LoginData
{
public:
- LoginData()
- {
- characterSlots = 3;
- }
+ LoginData() = default;
std::string username;
std::string password;
@@ -48,7 +45,7 @@ public:
bool remember; /**< Whether to store the username. */
bool registerLogin; /**< Whether an account is being registered. */
- unsigned short characterSlots; /**< The number of character slots */
+ unsigned short characterSlots = 3; /**< The number of character slots */
/**
* Initialize character slots to 3 for backwards compatibility
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index 7f354fa1..b8d3fa93 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -42,9 +42,7 @@ namespace {
namespace ManaServ
{
-using MessageHandlers = std::map<unsigned short, MessageHandler *>;
-using MessageHandlerIterator = MessageHandlers::iterator;
-static MessageHandlers mMessageHandlers;
+static std::map<unsigned short, MessageHandler *> mMessageHandlers;
void initialize()
{
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 6224b572..6bf11f54 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -136,18 +136,6 @@ class EquipBackend : public Equipment::Backend
int getSlotNumber() const override
{ return EQUIP_VECTOR_END; }
- // Note the slot type id is equal to the slot Index for tA.
- bool isWeaponSlot(unsigned int slotTypeId) const
- {
- return (slotTypeId == EQUIP_FIGHT1_SLOT
- || slotTypeId == EQUIP_FIGHT1_SLOT);
- }
-
- bool isAmmoSlot(unsigned int slotTypeId) const
- {
- return (slotTypeId == EQUIP_PROJECTILE_SLOT);
- }
-
private:
int mEquipment[EQUIP_VECTOR_END];
};
@@ -195,11 +183,17 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
size_t getSize(int type) const override;
+ // Note the slot type id is equal to the slot Index for tA.
bool isWeaponSlot(unsigned int slotTypeId) const override
- { return mEquips.isWeaponSlot(slotTypeId); }
+ {
+ return (slotTypeId == EQUIP_FIGHT1_SLOT
+ || slotTypeId == EQUIP_FIGHT1_SLOT);
+ }
bool isAmmoSlot(unsigned int slotTypeId) const override
- { return mEquips.isAmmoSlot(slotTypeId); }
+ {
+ return (slotTypeId == EQUIP_PROJECTILE_SLOT);
+ }
private:
EquipBackend mEquips;
diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h
index 92a268f1..3ff33e83 100644
--- a/src/net/tmwa/loginhandler.h
+++ b/src/net/tmwa/loginhandler.h
@@ -29,7 +29,7 @@
#include <string>
-struct LoginData;
+class LoginData;
namespace TmwAthena {
diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp
index ae5f6dba..19f5ee49 100644
--- a/src/net/tmwa/messageout.cpp
+++ b/src/net/tmwa/messageout.cpp
@@ -31,12 +31,9 @@
namespace TmwAthena {
MessageOut::MessageOut(uint16_t id):
- mDataSize(0),
- mPos(0)
+ mNetwork(TmwAthena::Network::instance()),
+ mData(mNetwork->mOutBuffer + mNetwork->mOutSize)
{
- mNetwork = TmwAthena::Network::instance();
- mData = mNetwork->mOutBuffer + mNetwork->mOutSize;
-
writeInt16(id);
}
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index dd2b84cc..4f1faa9d 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/messageout.h
@@ -88,9 +88,9 @@ class MessageOut
Network *mNetwork;
- char *mData; /**< Data building up. */
- unsigned int mDataSize; /**< Size of data. */
- unsigned int mPos; /**< Position in the data. */
+ char *mData; /**< Data building up. */
+ unsigned int mDataSize = 0; /**< Size of data. */
+ unsigned int mPos = 0; /**< Position in the data. */
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index c1862f00..f5aeaf91 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -23,8 +23,6 @@
#include "log.h"
-#include "net/messagehandler.h"
-
#include "net/tmwa/messagein.h"
#include "net/tmwa/protocol.h"
diff --git a/src/particle.cpp b/src/particle.cpp
index 5edb11e1..3e958417 100644
--- a/src/particle.cpp
+++ b/src/particle.cpp
@@ -19,9 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <algorithm>
-#include <cmath>
-
#include "animationparticle.h"
#include "configuration.h"
#include "resources/dye.h"
@@ -41,7 +38,6 @@
#include <guichan/color.hpp>
-#include <algorithm>
#include <cmath>
#define SIN45 0.707106781f
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index b3798a33..f19ad6e3 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -168,7 +168,7 @@ void ParticleVector::moveTo(float x, float y)
if (indexedElement->isExtinct())
{
indexedElement->kill();
- indexedElement = NULL;
+ indexedElement = nullptr;
}
}
}
diff --git a/src/particlecontainer.h b/src/particlecontainer.h
index 84401ed7..f01618e1 100644
--- a/src/particlecontainer.h
+++ b/src/particlecontainer.h
@@ -41,7 +41,7 @@ public:
*
* delParent means that the destructor should also free the parent.
*/
- ParticleContainer(ParticleContainer *parent = NULL, bool delParent = true);
+ ParticleContainer(ParticleContainer *parent = nullptr, bool delParent = true);
virtual ~ParticleContainer();
/**
@@ -70,8 +70,8 @@ protected:
class ParticleList : public ParticleContainer
{
public:
- ParticleList(ParticleContainer *parent = NULL, bool delParent = true);
- virtual ~ParticleList();
+ ParticleList(ParticleContainer *parent = nullptr, bool delParent = true);
+ ~ParticleList() override;
/**
* Takes control of and adds a particle
@@ -83,9 +83,9 @@ public:
*/
void removeLocally(Particle *);
- virtual void clearLocally();
+ void clearLocally() override;
- virtual void moveTo(float x, float y);
+ void moveTo(float x, float y) override;
protected:
std::list<Particle *> mElements; /**< Contained particle effects */
@@ -97,8 +97,8 @@ protected:
class ParticleVector : public ParticleContainer
{
public:
- ParticleVector(ParticleContainer *parent = NULL, bool delParent = true);
- virtual ~ParticleVector();
+ ParticleVector(ParticleContainer *parent = nullptr, bool delParent = true);
+ ~ParticleVector() override;
/**
* Sets a particle at a specified index. Kills the previous particle
@@ -111,8 +111,8 @@ public:
*/
virtual void delLocally(int index);
- virtual void clearLocally();
- virtual void moveTo(float x, float y);
+ void clearLocally() override;
+ void moveTo(float x, float y) override;
protected:
std::vector<Particle *> mIndexedElements;
diff --git a/src/party.cpp b/src/party.cpp
index cb9541e8..bfa867bf 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -25,15 +25,14 @@
#include "net/net.h"
PartyMember::PartyMember(Party *party, int id, const std::string &name):
- Avatar(name), mId(id), mParty(party), mLeader(false)
+ Avatar(name), mId(id), mParty(party)
{
}
Party::PartyMap Party::parties;
Party::Party(short id):
- mId(id),
- mCanInviteUsers(false)
+ mId(id)
{
parties[id] = this;
}
@@ -60,41 +59,26 @@ PartyMember *Party::addMember(int id, const std::string &name)
PartyMember *Party::getMember(int id) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->mId == id)
- {
- return (*itr);
- }
- ++itr;
- }
+ for (auto member : mMembers)
+ if (member->mId == id)
+ return member;
return nullptr;
}
PartyMember *Party::getMember(const std::string &name) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->getName() == name)
- {
- return (*itr);
- }
- ++itr;
- }
+ for (auto member : mMembers)
+ if (member->getName() == name)
+ return member;
return nullptr;
}
void Party::removeMember(PartyMember *member)
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while(itr != itr_end)
+ for (auto itr = mMembers.begin(), itr_end = mMembers.end();
+ itr != itr_end; ++itr)
{
if((*itr)->mId == member->mId &&
(*itr)->getName() == member->getName())
@@ -103,53 +87,42 @@ void Party::removeMember(PartyMember *member)
mMembers.erase(itr);
delete member;
}
- ++itr;
}
}
void Party::removeMember(int id)
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while(itr != itr_end)
+ for (auto itr = mMembers.begin(), itr_end = mMembers.end();
+ itr != itr_end; ++itr)
{
- if((*itr)->mId == id)
+ if ((*itr)->mId == id)
{
PartyMember *member = (*itr);
mMembers.erase(itr);
delete member;
}
- ++itr;
}
}
void Party::removeMember(const std::string &name)
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while(itr != itr_end)
+ for (auto itr = mMembers.begin(), itr_end = mMembers.end();
+ itr != itr_end; ++itr)
{
- if((*itr)->getName() == name)
+ if ((*itr)->getName() == name)
{
PartyMember *member = (*itr);
mMembers.erase(itr);
delete member;
}
- ++itr;
}
}
void Party::removeFromMembers()
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while(itr != itr_end)
- {
- Being *b = actorSpriteManager->findBeing((*itr)->getID());
- if (b)
+ for (auto member : mMembers)
+ if (Being *b = actorSpriteManager->findBeing(member->getID()))
b->setParty(nullptr);
- ++itr;
- }
}
Avatar *Party::getAvatarAt(int index)
@@ -171,16 +144,14 @@ bool Party::isMember(PartyMember *member) const
if (member->mParty != nullptr && member->mParty != this)
return false;
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
+
+ for (auto mMember : mMembers)
{
- if ((*itr)->mId == member->mId &&
- (*itr)->getName() == member->getName())
+ if (mMember->mId == member->mId &&
+ mMember->getName() == member->getName())
{
return true;
}
- ++itr;
}
return false;
@@ -188,32 +159,18 @@ bool Party::isMember(PartyMember *member) const
bool Party::isMember(int id) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->mId == id)
- {
+ for (auto member : mMembers)
+ if (member->mId == id)
return true;
- }
- ++itr;
- }
return false;
}
bool Party::isMember(const std::string &name) const
{
- auto itr = mMembers.begin(),
- itr_end = mMembers.end();
- while (itr != itr_end)
- {
- if ((*itr)->getName() == name)
- {
+ for (auto member : mMembers)
+ if (member->getName() == name)
return true;
- }
- ++itr;
- }
return false;
}
@@ -221,13 +178,8 @@ bool Party::isMember(const std::string &name) const
void Party::getNames(std::vector<std::string> &names) const
{
names.clear();
- auto it = mMembers.begin(),
- it_end = mMembers.end();
- while (it != it_end)
- {
- names.push_back((*it)->getName());
- ++it;
- }
+ for (auto member : mMembers)
+ names.push_back(member->getName());
}
Party *Party::getParty(int id)
diff --git a/src/party.h b/src/party.h
index ac421fd9..d96500ca 100644
--- a/src/party.h
+++ b/src/party.h
@@ -53,7 +53,7 @@ protected:
int mId;
Party *mParty;
- bool mLeader;
+ bool mLeader = false;
};
class Party : public AvatarListModel
@@ -166,11 +166,10 @@ private:
~Party() override;
- using MemberList = std::vector<PartyMember *>;
- MemberList mMembers;
+ std::vector<PartyMember *> mMembers;
std::string mName;
short mId;
- bool mCanInviteUsers;
+ bool mCanInviteUsers = false;
};
#endif // PARTY_H
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 708dfc9a..a937d71e 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -81,8 +81,8 @@ int getAttribute(int id)
IntMap::const_iterator it = mData.mAttributes.find(id);
if (it != mData.mAttributes.end())
return it->second;
- else
- return 0;
+
+ return 0;
}
void setAttribute(int id, int value, bool notify)
@@ -100,8 +100,8 @@ int getStatBase(int id)
StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
return it->second.base;
- else
- return 0;
+
+ return 0;
}
void setStatBase(int id, int value, bool notify)
@@ -117,8 +117,8 @@ int getStatMod(int id)
StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
return it->second.mod;
- else
- return 0;
+
+ return 0;
}
void setStatMod(int id, int value, bool notify)
@@ -134,8 +134,8 @@ int getStatEffective(int id)
StatMap::const_iterator it = mData.mStats.find(id);
if (it != mData.mStats.end())
return it->second.base + it->second.mod;
- else
- return 0;
+
+ return 0;
}
std::pair<int, int> getStatExperience(int id)
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index fde7030a..752f7b4f 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -21,12 +21,10 @@
#include "resources/emotedb.h"
-#include "configuration.h"
#include "log.h"
#include "imagesprite.h"
#include "resources/resourcemanager.h"
-#include "resources/image.h"
#include "resources/imageset.h"
namespace
@@ -134,10 +132,8 @@ const Emote *EmoteDB::get(int id)
logger->log("EmoteDB: Warning, unknown emote ID %d requested", id);
return &mUnknown;
}
- else
- {
- return i->second;
- }
+
+ return i->second;
}
int EmoteDB::getLast()
diff --git a/src/resources/emotedb.h b/src/resources/emotedb.h
index cdcb5cf6..cc3b30f7 100644
--- a/src/resources/emotedb.h
+++ b/src/resources/emotedb.h
@@ -22,9 +22,9 @@
#ifndef EMOTE_DB_H
#define EMOTE_DB_H
-#include <list>
#include <map>
#include <string>
+
#include "utils/xml.h"
class ImageSprite;
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index c05b03aa..e643143b 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -45,20 +45,14 @@ bool Image::mDisableTransparency = false;
SDL_Renderer *Image::mRenderer;
Image::Image(SDL_Texture *texture, int width, int height):
- mAlpha(1.0f),
+ mLoaded(texture != nullptr),
mTexture(texture)
{
-#ifdef USE_OPENGL
- mGLImage = 0;
-#endif
-
mBounds.x = 0;
mBounds.y = 0;
mBounds.w = width;
mBounds.h = height;
- mLoaded = mTexture != nullptr;
-
if (!mLoaded)
{
logger->log(
@@ -68,8 +62,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(nullptr),
+ mLoaded(glimage != 0),
mGLImage(glimage),
mTexWidth(texWidth),
mTexHeight(texHeight)
@@ -79,13 +72,10 @@ Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight)
mBounds.w = width;
mBounds.h = height;
- if (mGLImage)
- mLoaded = true;
- else
+ if (!mLoaded)
{
logger->log(
- "Image::Image(GLuint*, ...): Couldn't load invalid Surface!");
- mLoaded = false;
+ "Image::Image(GLuint, ...): Couldn't load invalid Surface!");
}
}
#endif
diff --git a/src/resources/image.h b/src/resources/image.h
index 66c3ff78..662c0393 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -38,7 +38,6 @@
#endif
class Dye;
-class Position;
/**
* Defines a class for loading and storing images.
@@ -87,7 +86,7 @@ class Image : public Resource
/**
* Tells is the image is loaded
*/
- bool isLoaded()
+ bool isLoaded() const
{ return mLoaded; }
/**
@@ -164,8 +163,8 @@ class Image : public Resource
// -----------------------
SDL_Rect mBounds;
- bool mLoaded;
- float mAlpha;
+ bool mLoaded = false;
+ float mAlpha = 1.0f;
// -----------------------
// SDL protected members
@@ -177,7 +176,7 @@ class Image : public Resource
/** SDL_Surface to SDL_Texture Image loader */
static Image *_SDLload(SDL_Surface *tmpImage);
- SDL_Texture *mTexture;
+ SDL_Texture *mTexture = nullptr;
/** Stores whether the transparency is disabled */
static bool mDisableTransparency;
@@ -201,7 +200,7 @@ class Image : public Resource
static Image *_GLload(SDL_Surface *image);
- GLuint mGLImage;
+ GLuint mGLImage = 0;
int mTexWidth, mTexHeight;
static bool mUseOpenGL;
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index d8d37bc4..412e64ce 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -161,7 +161,7 @@ class TaItemInfo;
class TaItemDB: public ItemDB
{
public:
- TaItemDB() : ItemDB()
+ TaItemDB()
{ }
~TaItemDB() override
@@ -172,6 +172,7 @@ class TaItemDB: public ItemDB
void readItemNode(xmlNodePtr node, const std::string &filename) override;
void checkStatus() override;
+
private:
/**
* Check items id specific hard limits and log errors found.
@@ -195,7 +196,7 @@ class ManaServItemInfo;
class ManaServItemDB: public ItemDB
{
public:
- ManaServItemDB() : ItemDB()
+ ManaServItemDB()
{ }
~ManaServItemDB() override
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index df559d69..5763e423 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -161,8 +161,8 @@ class ItemInfo
int mView = 0; /**< Item ID of how this item looks. */
int mId = 0; /**< Item ID */
- bool mEquippable; /**< Whether this item can be equipped. */
- bool mActivatable; /**< Whether this item can be activated. */
+ bool mEquippable = false; /**< Whether this item can be equipped. */
+ bool mActivatable = false; /**< Whether this item can be activated. */
// Equipment related members.
/** Attack type, in case of weapon.
@@ -172,12 +172,12 @@ class ItemInfo
std::string mAttackAction;
/** Attack range, will be equal to ATTACK_RANGE_NOT_SET if no weapon. */
- int mAttackRange;
+ int mAttackRange = 0;
/** Effects to be shown when weapon attacks - see also effects.xml */
std::string mMissileParticleFile;
- int mHitEffectId;
- int mCriticalHitEffectId;
+ int mHitEffectId = 0;
+ int mCriticalHitEffectId = 0;
/** Maps gender to sprite filenames. */
std::map<int, std::string> mAnimationFiles;
@@ -230,7 +230,7 @@ class TaItemInfo: public ItemInfo
friend class TaItemDB;
public:
- TaItemInfo() : ItemInfo()
+ TaItemInfo()
{}
// Declare TmwAthena Specific item info here
@@ -247,7 +247,7 @@ namespace ManaServ {
class ManaServItemInfo: public ItemInfo
{
public:
- ManaServItemInfo() : ItemInfo()
+ ManaServItemInfo()
{}
// Declare Manaserv Specific item info here
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index c4abeecf..5f62f418 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -182,8 +182,6 @@ BeingInfo *MonsterDB::get(int id)
logger->log("MonsterDB: Warning, unknown monster ID %d requested", id);
return BeingInfo::Unknown;
}
- else
- {
- return i->second;
- }
+
+ return i->second;
}
diff --git a/src/utils/mutex.h b/src/utils/mutex.h
index ad95b17b..b4661c70 100644
--- a/src/utils/mutex.h
+++ b/src/utils/mutex.h
@@ -35,14 +35,14 @@ class Mutex
public:
Mutex();
~Mutex();
+ Mutex(Mutex&&) = delete; // prevent moving
+ Mutex(const Mutex&) = delete; // prevent copying
+ Mutex& operator=(const Mutex&) = delete;
void lock();
void unlock();
private:
- Mutex(const Mutex&); // prevent copying
- Mutex& operator=(const Mutex&);
-
SDL_mutex *mMutex;
};
@@ -54,12 +54,11 @@ class MutexLocker
public:
MutexLocker(Mutex *mutex);
MutexLocker(MutexLocker&&);
+ MutexLocker(const MutexLocker&) = delete; // prevent copying
+ MutexLocker& operator=(const MutexLocker&) = delete;
~MutexLocker();
private:
- MutexLocker(const MutexLocker&); // prevent copying
- MutexLocker& operator=(const MutexLocker&);
-
Mutex *mMutex;
};