summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-23 00:10:43 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-23 00:10:43 +0300
commitd97189f055798b5b2051c1c5770a3def62747461 (patch)
treed66a891dba33d2ce1c882e0de7d6145bb2e0326b
parent25dce1399e40f24809842303d48ef090439de1e5 (diff)
downloadmanaplus-d97189f055798b5b2051c1c5770a3def62747461.tar.gz
manaplus-d97189f055798b5b2051c1c5770a3def62747461.tar.bz2
manaplus-d97189f055798b5b2051c1c5770a3def62747461.tar.xz
manaplus-d97189f055798b5b2051c1c5770a3def62747461.zip
Improve perfomance in some object constructors.
-rw-r--r--src/actor.cpp3
-rw-r--r--src/being.cpp19
-rw-r--r--src/being.h9
-rw-r--r--src/dropshortcut.cpp6
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/widgets/avatarlistbox.cpp9
-rw-r--r--src/gui/widgets/browserbox.cpp8
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/chattab.h2
-rw-r--r--src/gui/widgets/desktop.cpp7
-rw-r--r--src/gui/widgets/dropdown.cpp6
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp9
-rw-r--r--src/gui/widgets/icon.cpp3
-rw-r--r--src/gui/widgets/itemcontainer.cpp6
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp11
-rw-r--r--src/gui/widgets/listbox.cpp2
-rw-r--r--src/gui/widgets/sliderlist.cpp2
-rw-r--r--src/gui/widgets/tab.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp3
-rw-r--r--src/inventory.cpp2
-rw-r--r--src/inventory.h2
-rw-r--r--src/localplayer.cpp6
-rw-r--r--src/map.cpp12
-rw-r--r--src/particleemitter.cpp7
-rw-r--r--src/playerrelations.cpp4
-rw-r--r--src/resources/image.cpp12
-rw-r--r--src/resources/imageset.cpp4
-rw-r--r--src/resources/imageset.h2
-rw-r--r--src/resources/wallpaper.cpp3
29 files changed, 73 insertions, 99 deletions
diff --git a/src/actor.cpp b/src/actor.cpp
index 6a11c6e91..5af1f47d3 100644
--- a/src/actor.cpp
+++ b/src/actor.cpp
@@ -31,7 +31,8 @@
Actor::Actor():
mMap(nullptr),
mYDiff(0)
-{}
+{
+}
Actor::~Actor()
{
diff --git a/src/being.cpp b/src/being.cpp
index 924ffd9e0..094f01c66 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -80,9 +80,6 @@
#define CACHE_SIZE 50
-static const int DEFAULT_BEING_WIDTH = 32;
-static const int DEFAULT_BEING_HEIGHT = 32;
-
class BeingCacheEntry
{
public:
@@ -228,6 +225,8 @@ Being::Being(int id, Type type, uint16_t subtype, Map *map):
mIsGM(false),
mAttackRange(1),
mType(type),
+ mSpeechBubble(new SpeechBubble),
+ mWalkSpeed(Net::getPlayerHandler()->getDefaultWalkSpeed()),
mX(0),
mY(0),
mDamageTaken(0),
@@ -264,10 +263,6 @@ Being::Being(int id, Type type, uint16_t subtype, Map *map):
setMap(map);
setSubtype(subtype);
- mSpeechBubble = new SpeechBubble;
-
- mWalkSpeed = Net::getPlayerHandler()->getDefaultWalkSpeed();
-
if (mType == PLAYER)
mShowName = config.getBoolValue("visiblenames");
else if (mType != NPC)
@@ -1503,16 +1498,6 @@ int Being::getOffset(char pos, char neg) const
return offset;
}
-int Being::getWidth() const
-{
- return std::max(CompoundSprite::getWidth(), DEFAULT_BEING_WIDTH);
-}
-
-int Being::getHeight() const
-{
- return std::max(CompoundSprite::getHeight(), DEFAULT_BEING_HEIGHT);
-}
-
void Being::updateCoords()
{
if (!mDispName)
diff --git a/src/being.h b/src/being.h
index 289c15e9d..d09e97225 100644
--- a/src/being.h
+++ b/src/being.h
@@ -46,6 +46,9 @@
#define SPEECH_MIN_TIME 200
#define SPEECH_MAX_TIME 800
+static const int DEFAULT_BEING_WIDTH = 32;
+static const int DEFAULT_BEING_HEIGHT = 32;
+
class AnimatedSprite;
class BeingCacheEntry;
class Being;
@@ -539,12 +542,14 @@ class Being : public ActorSprite, public ConfigListener
/**
* Returns the horizontal size of the current base sprite of the being.
*/
- virtual int getWidth() const;
+ virtual int getWidth() const
+ { return std::max(CompoundSprite::getWidth(), DEFAULT_BEING_WIDTH); }
/**
* Returns the vertical size of the current base sprite of the being.
*/
- virtual int getHeight() const;
+ virtual int getHeight() const
+ { return std::max(CompoundSprite::getHeight(), DEFAULT_BEING_HEIGHT); }
/**
* Returns the being's pixel radius used to detect collisions.
diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp
index b0202f04d..03450718b 100644
--- a/src/dropshortcut.cpp
+++ b/src/dropshortcut.cpp
@@ -39,13 +39,13 @@
DropShortcut *dropShortcut;
-DropShortcut::DropShortcut():
+DropShortcut::DropShortcut() :
mItemSelected(-1),
- mItemColorSelected(1)
+ mItemColorSelected(1),
+ mLastDropIndex(0)
{
clear();
load();
- mLastDropIndex = 0;
}
DropShortcut::~DropShortcut()
diff --git a/src/game.cpp b/src/game.cpp
index e5a86f4a3..db9486699 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -367,6 +367,7 @@ Game::Game():
mLastAction(0),
mNextAdjustTime(cur_time + adjustDelay),
mAdjustLevel(0),
+ mAdjustPerfomance(config.getBoolValue("adjustPerfomance")),
mLowerCounter(0),
mPing(0)
{
@@ -378,8 +379,6 @@ Game::Game():
disconnectedDialog = nullptr;
- mAdjustPerfomance = config.getBoolValue("adjustPerfomance");
-
// Create the viewport
viewport = new Viewport;
viewport->setSize(mainGraphics->mWidth, mainGraphics->mHeight);
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index c648c56dd..914437281 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -50,8 +50,9 @@ Image *AvatarListBox::offlineIcon = nullptr;
AvatarListBox::AvatarListBox(AvatarListModel *model):
ListBox(model),
- mShowGender(false),
- mShowLevel(false)
+ mShowGender(config.getBoolValue("showgender")),
+ mShowLevel(config.getBoolValue("showlevel")),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT))
{
instances++;
@@ -63,13 +64,9 @@ AvatarListBox::AvatarListBox(AvatarListModel *model):
setWidth(200);
- mShowGender = config.getBoolValue("showgender");
- mShowLevel = config.getBoolValue("showlevel");
-
config.addListener("showgender", this);
config.addListener("showlevel", this);
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 6954f781f..534bd1d19 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -63,14 +63,14 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque):
mUpdateTime(-1),
mAlwaysUpdate(true),
mProcessVersion(false),
- mEnableImages(false)
+ mEnableImages(false),
+ mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND)),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)),
+ mHyperLinkColor(Theme::getThemeColor(Theme::HYPERLINK))
{
setFocusable(true);
addMouseListener(this);
- mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
- mHyperLinkColor = Theme::getThemeColor(Theme::HYPERLINK);
mColors[RED] = Theme::getThemeColor(Theme::RED);
mColors[GREEN] = Theme::getThemeColor(Theme::GREEN);
mColors[BLUE] = Theme::getThemeColor(Theme::BLUE);
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index f120cfb06..f67b75107 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -54,20 +54,20 @@
ChatTab::ChatTab(const std::string &name) :
Tab(),
+ mTextOutput(new BrowserBox(BrowserBox::AUTO_WRAP)),
+ mScrollArea(new ScrollArea(mTextOutput)),
mAllowHightlight(true),
mRemoveNames(false),
mNoAway(false)
{
setCaption(name);
- mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP);
mTextOutput->setOpaque(false);
mTextOutput->setMaxRow(config.getIntValue("ChatLogLength"));
if (chatWindow)
mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
mTextOutput->setAlwaysUpdate(false);
- mScrollArea = new ScrollArea(mTextOutput);
mScrollArea->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER,
gcn::ScrollArea::SHOW_ALWAYS);
mScrollArea->setScrollAmount(0, 1);
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index e1e2c211d..3d591cf3c 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -184,8 +184,8 @@ class ChatTab : public Tab
void addRow(std::string &line);
- ScrollArea *mScrollArea;
BrowserBox *mTextOutput;
+ ScrollArea *mScrollArea;
bool mAllowHightlight;
bool mRemoveNames;
bool mNoAway;
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index d3a2e8c50..a25a9ef7e 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -41,7 +41,9 @@
#include "debug.h"
Desktop::Desktop() :
- mWallpaper(nullptr)
+ mWallpaper(nullptr),
+ mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND, 128)),
+ mBackgroundGrayColor(Theme::getThemeColor(Theme::BACKGROUND_GRAY))
{
addWidgetListener(this);
@@ -62,9 +64,6 @@ Desktop::Desktop() :
mVersionLabel->setBackgroundColor(
Theme::getThemeColor(Theme::BACKGROUND, 128));
add(mVersionLabel, 25, 2);
-
- mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 128);
- mBackgroundGrayColor = Theme::getThemeColor(Theme::BACKGROUND_GRAY);
}
Desktop::~Desktop()
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index a52f70926..dd9bbb4e5 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -58,7 +58,9 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
std::string eventId):
gcn::DropDown::DropDown(listModel,
new ScrollArea,
- new ListBox(listModel))
+ new ListBox(listModel)),
+ mShadowColor(Theme::getThemeColor(Theme::DROPDOWN_SHADOW)),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT))
{
setFrameSize(2);
@@ -101,8 +103,6 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
instances++;
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
- mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
if (!eventId.empty())
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index fca1af17f..d70f153d7 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -48,13 +48,14 @@
DropShortcutContainer::DropShortcutContainer():
ShortcutContainer(),
mItemClicked(false),
- mItemMoved(nullptr)
+ mItemMoved(nullptr),
+ mItemPopup(new ItemPopup),
+ mEquipedColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)),
+ mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED))
{
addMouseListener(this);
addWidgetListener(this);
- mItemPopup = new ItemPopup;
-
mBackgroundImg = Theme::getImageFromThemeXml(
"item_shortcut_background.xml");
if (dropShortcut)
@@ -73,8 +74,6 @@ DropShortcutContainer::DropShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
- mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
- mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
DropShortcutContainer::~DropShortcutContainer()
diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp
index b35eb1d95..9cb42a9f7 100644
--- a/src/gui/widgets/icon.cpp
+++ b/src/gui/widgets/icon.cpp
@@ -30,9 +30,8 @@
#include "debug.h"
Icon::Icon(const std::string &file)
- : mImage(nullptr)
+ : mImage(ResourceManager::getInstance()->getImage(file))
{
- mImage = ResourceManager::getInstance()->getImage(file);
if (mImage)
setSize(mImage->mBounds.w, mImage->mBounds.h);
}
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index c5118ce44..6963bad31 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -157,6 +157,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mInventory(inventory),
mGridColumns(1),
mGridRows(1),
+ mSelImg(Theme::getImageFromThemeXml("item_selection.xml")),
mSelectedIndex(-1),
mHighlightedIndex(-1),
mLastUsedSlot(-1),
@@ -173,11 +174,6 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED))
{
setFocusable(true);
-
- mSelImg = Theme::getImageFromThemeXml("item_selection.xml");
- if (!mSelImg)
- logger->log1("Error: Unable to load selection.png");
-
addKeyListener(this);
addMouseListener(this);
addWidgetListener(this);
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 735cea43d..e27d5efd6 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -54,14 +54,15 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number):
ShortcutContainer(),
mItemClicked(false),
mItemMoved(nullptr),
- mNumber(number)
+ mNumber(number),
+ mItemPopup(new ItemPopup),
+ mSpellPopup(new SpellPopup),
+ mEquipedColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)),
+ mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED))
{
addMouseListener(this);
addWidgetListener(this);
- mItemPopup = new ItemPopup;
- mSpellPopup = new SpellPopup;
-
mBackgroundImg = Theme::getImageFromThemeXml(
"item_shortcut_background.xml");
if (itemShortcut[mNumber])
@@ -81,8 +82,6 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number):
mBoxWidth = 1;
}
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
- mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
- mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
ItemShortcutContainer::~ItemShortcutContainer()
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index f803e91b4..8e5bc0c78 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -43,9 +43,9 @@ float ListBox::mAlpha = 1.0;
ListBox::ListBox(gcn::ListModel *listModel):
gcn::ListBox(listModel),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)),
mDistributeMousePressed(true)
{
- mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp
index 9dba00cee..50af87205 100644
--- a/src/gui/widgets/sliderlist.cpp
+++ b/src/gui/widgets/sliderlist.cpp
@@ -42,6 +42,7 @@ static const int sliderHeight = 30;
SliderList::SliderList(gcn::ListModel *listModel,
gcn::ActionListener* listener,
std::string eventId) :
+ mLabel(new Label),
mListModel(listModel),
mOldWidth(0),
mSelectedIndex(0)
@@ -53,7 +54,6 @@ SliderList::SliderList(gcn::ListModel *listModel,
mButtons[0] = new Button("<", mPrevEventId, this);
mButtons[1] = new Button(">", mNextEventId, this);
- mLabel = new Label("");
add(mButtons[0]);
add(mLabel);
add(mButtons[1]);
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index ebc288b43..3faa874ca 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -68,11 +68,11 @@ Tab::Tab() :
mTabColor(&Theme::getThemeColor(Theme::TAB)),
mVertexes(new GraphicsVertexes()),
mRedraw(true),
- mMode(0)
+ mMode(0),
+ mFlashColor(Theme::getThemeColor(Theme::TAB_FLASH)),
+ mPlayerFlashColor(Theme::getThemeColor(Theme::TAB_PLAYER_FLASH))
{
init();
- mFlashColor = Theme::getThemeColor(Theme::TAB_FLASH);
- mPlayerFlashColor = Theme::getThemeColor(Theme::TAB_PLAYER_FLASH);
}
Tab::~Tab()
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index f0df5eb57..1c054f04b 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -57,12 +57,11 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab,
mNumeric(false),
mMinimum(0),
mMaximum(0),
+ mLoseFocusOnTab(loseFocusOnTab),
mLastEventPaste(false)
{
setFrameSize(2);
- mLoseFocusOnTab = loseFocusOnTab;
-
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
if (instances == 0)
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 9aff286ff..8569dc8fb 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -49,9 +49,9 @@ Inventory::Inventory(int type, int size):
mSize(size == -1 ? static_cast<unsigned>(
Net::getInventoryHandler()->getSize(type))
: static_cast<unsigned>(size)),
+ mItems(new Item*[mSize]),
mUsed(0)
{
- mItems = new Item*[mSize];
std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
}
diff --git a/src/inventory.h b/src/inventory.h
index 85756b66f..74f3e695d 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -161,8 +161,8 @@ class Inventory
void distributeSlotsChangedEvent();
int mType;
- Item **mItems; /**< The holder of items */
unsigned mSize; /**< The max number of inventory items */
+ Item **mItems; /**< The holder of items */
int mUsed; /**< THe number of slots in use */
};
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 52d154231..dc5c697db 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -92,6 +92,7 @@ extern SkillDialog *skillDialog;
LocalPlayer::LocalPlayer(int id, int subtype):
Being(id, PLAYER, subtype, nullptr),
+ mUpdateName(true),
mTargetTime(-1),
mLastTarget(-1),
mTarget(nullptr),
@@ -105,6 +106,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mPathSetByMouse(false),
mLocalWalkTime(-1),
mMessageTime(0),
+ mAwayListener(new AwayListener),
mAwayDialog(nullptr),
mAfkTime(0),
mAwayMode(false),
@@ -136,10 +138,6 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mAdvanced = true;
- mAwayListener = new AwayListener();
-
- mUpdateName = true;
-
mTextColor = &Theme::getThemeColor(Theme::PLAYER);
if (userPalette)
mNameColor = &userPalette->getColor(UserPalette::SELF);
diff --git a/src/map.cpp b/src/map.cpp
index 574b70e41..242162429 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -131,6 +131,11 @@ Map::Map(int width, int height, int tileWidth, int tileHeight):
mLastAScrollX(0.0f), mLastAScrollY(0.0f),
mOverlayDetail(config.getIntValue("OverlayDetail")),
mOpacity(config.getFloatValue("guialpha")),
+#ifdef USE_OPENGL
+ mOpenGL(config.getIntValue("opengl")),
+#else
+ mOpenGL(0),
+#endif
mPvp(0),
mTilesetsIndexed(false),
mIndexedTilesets(nullptr),
@@ -165,17 +170,10 @@ Map::Map(int width, int height, int tileWidth, int tileHeight):
config.addListener("guialpha", this);
config.addListener("beingopacity", this);
- mOpacity = config.getFloatValue("guialpha");
if (mOpacity != 1.0f)
mBeingOpacity = config.getBoolValue("beingopacity");
else
mBeingOpacity = false;
-
-#ifdef USE_OPENGL
- mOpenGL = config.getIntValue("opengl");
-#else
- mOpenGL = 0;
-#endif
}
Map::~Map()
diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp
index 4ba8c9c6b..918f25570 100644
--- a/src/particleemitter.cpp
+++ b/src/particleemitter.cpp
@@ -41,13 +41,12 @@
ParticleEmitter::ParticleEmitter(XmlNodePtr emitterNode, Particle *target,
Map *map, int rotation,
- const std::string& dyePalettes):
+ const std::string& dyePalettes) :
+ mParticleTarget(target),
+ mMap(map),
mOutputPauseLeft(0),
mParticleImage(nullptr)
{
- mMap = map;
- mParticleTarget = target;
-
// Initializing default values
mParticlePosX.set(0.0f);
mParticlePosY.set(0.0f);
diff --git a/src/playerrelations.cpp b/src/playerrelations.cpp
index 602ceb7ad..59e7de05e 100644
--- a/src/playerrelations.cpp
+++ b/src/playerrelations.cpp
@@ -119,9 +119,9 @@ const unsigned int PlayerRelation::RELATION_PERMISSIONS[RELATIONS_NR] =
/* ENEMY2 */ EMOTE | SPEECH_FLOAT | SPEECH_LOG | WHISPER | TRADE
};
-PlayerRelation::PlayerRelation(Relation relation)
+PlayerRelation::PlayerRelation(Relation relation) :
+ mRelation(relation)
{
- mRelation = relation;
}
PlayerRelationsManager::PlayerRelationsManager() :
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 4b5fa4f40..7cfb11822 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -51,15 +51,15 @@ Image::Image(SDL_Surface *image, bool hasAlphaChannel0, uint8_t *alphaChannel):
mHasAlphaChannel(hasAlphaChannel0),
mSDLSurface(image),
mAlphaChannel(alphaChannel),
+ mUseAlphaCache(SDLImageHelper::mEnableAlphaCache),
mIsAlphaVisible(hasAlphaChannel0),
- mIsAlphaCalculated(false)
-{
#ifdef USE_OPENGL
- mGLImage = 0;
+ mIsAlphaCalculated(false),
+ mGLImage(0)
+#else
+ mIsAlphaCalculated(false)
#endif
-
- mUseAlphaCache = SDLImageHelper::mEnableAlphaCache;
-
+{
mBounds.x = 0;
mBounds.y = 0;
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 9e3513e91..4b63d0883 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -32,6 +32,8 @@
ImageSet::ImageSet(Image *img, int width, int height,
int margin, int spacing) :
+ mWidth(width),
+ mHeight(height),
mOffsetX(0),
mOffsetY(0)
{
@@ -47,8 +49,6 @@ ImageSet::ImageSet(Image *img, int width, int height,
}
}
}
- mWidth = width;
- mHeight = height;
}
ImageSet::~ImageSet()
diff --git a/src/resources/imageset.h b/src/resources/imageset.h
index edfc4b123..aef4bf694 100644
--- a/src/resources/imageset.h
+++ b/src/resources/imageset.h
@@ -78,8 +78,8 @@ class ImageSet : public Resource
private:
std::vector<Image*> mImages;
- int mHeight; /**< Height of the images in the image set. */
int mWidth; /**< Width of the images in the image set. */
+ int mHeight; /**< Height of the images in the image set. */
int mOffsetX;
int mOffsetY;
};
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 2f5fd9dca..316419627 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -33,6 +33,7 @@
#include <algorithm>
#include <cstring>
#include <time.h>
+#include <iostream>
#include "debug.h"
@@ -84,7 +85,7 @@ bool wallpaperCompare(WallpaperData a, WallpaperData b)
return (aa > ab || (aa == ab && a.width > b.width));
}
-#include <iostream>
+
void Wallpaper::loadWallpapers()
{
wallpaperData.clear();