diff options
58 files changed, 341 insertions, 373 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 0161b6890..dbd9c6692 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -181,17 +181,16 @@ class SortBeingFunctor } beingSorter; ActorSpriteManager::ActorSpriteManager() : - mMap(nullptr) + mMap(nullptr), + mSpellHeal1(serverConfig.getValue("spellHeal1", "#lum")), + mSpellHeal2(serverConfig.getValue("spellHeal2", "#inma")), + mSpellItenplz(serverConfig.getValue("spellItenplz", "#itenplz")), + mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")), + mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")), + mCyclePlayers(config.getBoolValue("cyclePlayers")), + mCycleMonsters(config.getBoolValue("cycleMonsters")), + mExtMouseTargeting(config.getBoolValue("extMouseTargeting")) { - mSpellHeal1 = serverConfig.getValue("spellHeal1", "#lum"); - mSpellHeal2 = serverConfig.getValue("spellHeal2", "#inma"); - mSpellItenplz = serverConfig.getValue("spellItenplz", "#itenplz"); - mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers"); - mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable"); - mCyclePlayers = config.getBoolValue("cyclePlayers"); - mCycleMonsters = config.getBoolValue("cycleMonsters"); - mExtMouseTargeting = config.getBoolValue("extMouseTargeting"); - config.addListener("targetDeadPlayers", this); config.addListener("targetOnlyReachable", this); config.addListener("cyclePlayers", this); diff --git a/src/being.cpp b/src/being.cpp index a9aade448..9aee21c4e 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -249,6 +249,8 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): mMaxHit(0), mCriticalHit(0), mPvpRank(0), + mSpriteRemap(new int[20]), + mSpriteHide(new int[20]), mComment(""), mGotComment(false), mAdvanced(false), @@ -257,8 +259,6 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): mInactive(false), mNumber(100) { - mSpriteRemap = new int[20]; - mSpriteHide = new int[20]; for (int f = 0; f < 20; f ++) { diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index e1d5d6b76..f4890fe2b 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -52,12 +52,12 @@ CompoundSprite::CompoundSprite() : mAlphaImage(nullptr), mOffsetX(0), mOffsetY(0), - mNeedsRedraw(false) + mNeedsRedraw(false), + mEnableAlphaFix(config.getBoolValue("enableAlphaFix")), + mDisableAdvBeingCaching(config.getBoolValue("disableAdvBeingCaching")), + mDisableBeingCaching(config.getBoolValue("disableBeingCaching")) { mAlpha = 1.0f; - mEnableAlphaFix = config.getBoolValue("enableAlphaFix"); - mDisableAdvBeingCaching = config.getBoolValue("disableAdvBeingCaching"); - mDisableBeingCaching = config.getBoolValue("disableBeingCaching"); } CompoundSprite::~CompoundSprite() diff --git a/src/depricatedevent.h b/src/depricatedevent.h index a353b3de8..6e7eed448 100644 --- a/src/depricatedevent.h +++ b/src/depricatedevent.h @@ -121,8 +121,8 @@ class DepricatedEvent // String passed can be retivered with getName() // and is to used to identify what type of event // this is. - DepricatedEvent(DepricatedEvents name) - { mDepricatedEventName = name; } + DepricatedEvent(DepricatedEvents name) : mDepricatedEventName(name) + { } ~DepricatedEvent(); diff --git a/src/flooritem.cpp b/src/flooritem.cpp index acbfe8363..0bb75fb1f 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -89,9 +89,6 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const if (!mMap) return false; - const int dx = 32; - const int dy = 32; - const int x = mX * mMap->getTileWidth() + offsetX; const int y = mY * mMap->getTileHeight() + offsetY; gcn::Font *font = nullptr; @@ -102,6 +99,9 @@ bool FloorItem::draw(Graphics *graphics, int offsetX, int offsetY) const font = gui->getFont(); if (mDropTime < curTime) { + const int dx = 32; + const int dy = 32; + if (curTime > mDropTime + 28 && curTime < mDropTime + 50) { graphics->setColor(gcn::Color(80, 200, 20, 200)); diff --git a/src/game.cpp b/src/game.cpp index 4ed04a20f..f67fac098 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1027,10 +1027,10 @@ void Game::updateHistory(SDL_Event &event) if (!player_node || !player_node->getAttackType()) return; - bool old = false; - if (event.key.keysym.sym != -1) { + bool old = false; + int key = keyboard.getKeyIndex(event); int time = cur_time; int idx = -1; diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index c58cca626..879b50245 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -41,27 +41,27 @@ #include "debug.h" BeingPopup::BeingPopup() : - Popup("BeingPopup", "beingpopup.xml") + Popup("BeingPopup", "beingpopup.xml"), + mBeingName(new Label("A")), + mBeingParty(new Label("A")), + mBeingGuild(new Label("A")), + mBeingRank(new Label("A")), + mBeingComment(new Label("A")) { // Being Name - mBeingName = new Label("A"); mBeingName->setFont(boldFont); mBeingName->setPosition(getPadding(), getPadding()); const int fontHeight = mBeingName->getHeight() + getPadding(); // Being's party - mBeingParty = new Label("A"); mBeingParty->setPosition(getPadding(), fontHeight); // Being's party - mBeingGuild = new Label("A"); mBeingGuild->setPosition(getPadding(), 2 * fontHeight); - mBeingRank = new Label("A"); mBeingRank->setPosition(getPadding(), 3 * fontHeight); - mBeingComment = new Label("A"); mBeingComment->setPosition(getPadding(), 4 * fontHeight); add(mBeingName); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index a18f3d383..38a58c03c 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -550,15 +550,13 @@ bool CharSelectDialog::selectByName(const std::string &name, CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): mCharacter(nullptr), - mPlayerBox(new PlayerBox) + mPlayerBox(new PlayerBox), + mName(new Label("wwwwwwwwwwwwwwwwwwwwwwww")), + mLevel(new Label("(888)")), + mMoney(new Label("wwwwwwwww")), + mButton(new Button("wwwwwwwww", "go", charSelectDialog)), + mDelete(new Button(_("Delete"), "delete", charSelectDialog)) { - mButton = new Button("wwwwwwwww", "go", charSelectDialog); - mName = new Label("wwwwwwwwwwwwwwwwwwwwwwww"); - mLevel = new Label("(888)"); - mMoney = new Label("wwwwwwwww"); - - mDelete = new Button(_("Delete"), "delete", charSelectDialog); - LayoutHelper h(this); ContainerPlacer placer = h.getPlacer(0, 0); @@ -571,7 +569,6 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): update(); - // Setting the width so that the largest label fits. mName->adjustSize(); mMoney->adjustSize(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 8d05fc26d..feabd79d5 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -323,10 +323,10 @@ bool Gui::handleKeyInput2() continue; } - bool keyEventConsumed = false; - if (mFocusHandler) { + bool keyEventConsumed = false; + // Send key inputs to the focused widgets if (mFocusHandler->getFocused()) { diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 192a5e116..f9cbb92dd 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -51,34 +51,32 @@ ItemPopup::ItemPopup(): Popup("ItemPopup", "itempopup.xml"), - mIcon(nullptr), + mItemName(new Label), + mItemDesc(new TextBox), + mItemEffect(new TextBox), + mItemWeight(new TextBox), + mIcon(new Icon(nullptr)), mLastName(""), mLastColor(1) { // Item Name - mItemName = new Label; mItemName->setFont(boldFont); mItemName->setPosition(getPadding(), getPadding()); const int fontHeight = getFont()->getHeight(); // Item Description - mItemDesc = new TextBox; mItemDesc->setEditable(false); mItemDesc->setPosition(getPadding(), fontHeight); // Item Effect - mItemEffect = new TextBox; mItemEffect->setEditable(false); mItemEffect->setPosition(getPadding(), 2 * fontHeight + 2 * getPadding()); // Item Weight - mItemWeight = new TextBox; mItemWeight->setEditable(false); mItemWeight->setPosition(getPadding(), 3 * fontHeight + 4 * getPadding()); - mIcon = new Icon(nullptr); - add(mItemName); add(mItemDesc); add(mItemEffect); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 1552d793f..2a46cf2ce 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -539,10 +539,10 @@ void OutfitWindow::showCurrentOutfit() void OutfitWindow::wearNextOutfit(bool all) { - bool fromStart = false; next(); if (!all && mCurrentOutfit < OUTFITS_COUNT) { + bool fromStart = false; while (!mItemsUnequip[mCurrentOutfit]) { next(); @@ -560,10 +560,10 @@ void OutfitWindow::wearNextOutfit(bool all) void OutfitWindow::wearPreviousOutfit(bool all) { - bool fromStart = false; previous(); if (!all && mCurrentOutfit < OUTFITS_COUNT) { + bool fromStart = false; while (!mItemsUnequip[mCurrentOutfit]) { previous(); diff --git a/src/gui/palette.h b/src/gui/palette.h index 7d5d93830..235070990 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -152,19 +152,19 @@ class Palette struct ColorElem { - ColorElem() + ColorElem() : + type(0), + color(0), + testColor(0), + committedColor(0), + text(), + ch(0), + grad(STATIC), + committedGrad(STATIC), + gradientIndex(0), + delay(0), + committedDelay(0) { - type = 0; - color = 0; - testColor = 0; - committedColor = 0; - text = ""; - ch = 0; - grad = STATIC; - committedGrad = STATIC; - gradientIndex = 0; - delay = 0; - committedDelay = 0; } int type; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index dfaf4122a..b4d5ec22a 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -86,6 +86,7 @@ std::string tradePartnerName(""); PopupMenu::PopupMenu(): Popup("PopupMenu", "popupmenu.xml"), + mBrowserBox(new BrowserBox), mBeingId(0), mFloorItemId(0), mItem(nullptr), @@ -101,7 +102,6 @@ PopupMenu::PopupMenu(): mX(0), mY(0) { - mBrowserBox = new BrowserBox; mBrowserBox->setPosition(4, 4); mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND); mBrowserBox->setOpaque(false); @@ -2139,7 +2139,7 @@ void PopupMenu::addPlayerMisc() mBrowserBox->addRow("addcomment", _("Add comment")); } -void PopupMenu::addPickupFilter(const std::string name) +void PopupMenu::addPickupFilter(const std::string &name) { if (actorSpriteManager->isInPickupList(name) || actorSpriteManager->isInIgnorePickupList(name)) diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index b5d0e956c..094d3ae44 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -172,7 +172,7 @@ class PopupMenu : public Popup, public LinkHandler void addPlayerMisc(); - void addPickupFilter(const std::string name); + void addPickupFilter(const std::string &name); BrowserBox* mBrowserBox; diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index c5257b99b..c3368ca8a 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -47,15 +47,14 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): Window(_("Quit"), true, nullptr, "quit.xml"), + mLogoutQuit(new RadioButton(_("Quit"), "quitdialog")), + mForceQuit(new RadioButton(_("Quit"), "quitdialog")), + mSwitchAccountServer(new RadioButton(_("Switch server"), "quitdialog")), + mSwitchCharacter(new RadioButton(_("Switch character"), "quitdialog")), + mOkButton(new Button(_("OK"), "ok", this)), + mCancelButton(new Button(_("Cancel"), "cancel", this)), mMyPointer(pointerToMe) { - mForceQuit = new RadioButton(_("Quit"), "quitdialog"); - mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); - mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog"); - mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog"); - mOkButton = new Button(_("OK"), "ok", this); - mCancelButton = new Button(_("Cancel"), "cancel", this); - addKeyListener(this); ContainerPlacer placer = getPlacer(0, 0); diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 6828158d2..55a4e0e6c 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -64,10 +64,10 @@ #include <guichan/exception.hpp> -SDLInput::SDLInput() +SDLInput::SDLInput() : + mMouseDown(false), + mMouseInWindow(true) { - mMouseInWindow = true; - mMouseDown = false; } bool SDLInput::isKeyQueueEmpty() diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 838e52c84..c2045effa 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -145,13 +145,13 @@ void ServersListModel::setVersionString(int index, const std::string &version) class ServersListBox : public ListBox { public: - ServersListBox(ServersListModel *model): - ListBox(model) + ServersListBox(ServersListModel *model) : + ListBox(model), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mTextColor(Theme::getThemeColor(Theme::TEXT)), + mNotSupportedColor(Theme::getThemeColor( + Theme::SERVER_VERSION_NOT_SUPPORTED)) { - mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); - mTextColor = Theme::getThemeColor(Theme::TEXT); - mNotSupportedColor = Theme::getThemeColor( - Theme::SERVER_VERSION_NOT_SUPPORTED); } void draw(gcn::Graphics *graphics) diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index f0e332529..6ba80ea4e 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -420,10 +420,9 @@ public: class SocialPlayersTab : public SocialTab { public: - SocialPlayersTab(std::string name) + SocialPlayersTab(std::string name) : + mBeings(new BeingsListModal()) { - mBeings = new BeingsListModal(); - mList = new AvatarListBox(mBeings); mScroll = new ScrollArea(mList); @@ -586,10 +585,9 @@ private: class SocialNavigationTab : public SocialTab { public: - SocialNavigationTab() + SocialNavigationTab() : + mBeings(new BeingsListModal()) { - mBeings = new BeingsListModal(); - mList = new AvatarListBox(mBeings); mScroll = new ScrollArea(mList); @@ -919,10 +917,9 @@ protected: class SocialAttackTab : public SocialTab { public: - SocialAttackTab() + SocialAttackTab() : + mBeings(new BeingsListModal()) { - mBeings = new BeingsListModal(); - mList = new AvatarListBox(mBeings); mScroll = new ScrollArea(mList); @@ -974,10 +971,9 @@ private: class SocialPickupTab : public SocialTab { public: - SocialPickupTab() + SocialPickupTab() : + mBeings(new BeingsListModal()) { - mBeings = new BeingsListModal(); - mList = new AvatarListBox(mBeings); mScroll = new ScrollArea(mList); @@ -1029,10 +1025,9 @@ private: class SocialFriendsTab : public SocialTab { public: - SocialFriendsTab(std::string name) + SocialFriendsTab(std::string name) : + mBeings(new BeingsListModal()) { - mBeings = new BeingsListModal(); - mList = new AvatarListBox(mBeings); mScroll = new ScrollArea(mList); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index c3025f516..67e2be0c8 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -164,13 +164,41 @@ public: }; -TextCommandEditor::TextCommandEditor(TextCommand *command): - Window(_("Command Editor"), false, nullptr, "commandeditor.xml") +TextCommandEditor::TextCommandEditor(TextCommand *command) : + Window(_("Command Editor"), false, nullptr, "commandeditor.xml"), + mIsMagicCommand(command->getCommandType() == TEXT_COMMAND_MAGIC), + mCommand(command), + mIsMagic(new RadioButton(_("magic"), "magic", mIsMagicCommand)), + mIsOther(new RadioButton(_("other"), "magic", !mIsMagicCommand)), + mSymbolLabel(new Label(_("Symbol:"))), + mSymbolTextField(new TextField()), + mCommandLabel(new Label(_("Command:"))), + mCommandTextField(new TextField()), + mCommentLabel(new Label(_("Comment:"))), + mCommentTextField(new TextField), + mTargetTypeModel(new TargetTypeModel), + mTypeLabel(new Label(_("Target Type:"))), + mTypeDropDown(new DropDown(mTargetTypeModel)), + mIconsModal(new IconsModal), + mIconLabel(new Label(_("Icon:"))), + mIconDropDown(new DropDown(mIconsModal)), + mManaLabel(new Label(_("Mana:"))), + mManaField(new IntTextField(0)), + mMagicLvlLabel(new Label(_("Magic level:"))), + mMagicLvlField(new IntTextField(0)), + mMagicSchoolModel(new MagicSchoolModel), + mSchoolLabel(new Label(_("Magic School:"))), + mSchoolDropDown(new DropDown(mMagicSchoolModel)), + mSchoolLvlLabel(new Label(_("School level:"))), + mSchoolLvlField(new IntTextField(0)), + mCancelButton(new Button(_("Cancel"), "cancel", this)), + mSaveButton(new Button(_("Save"), "save", this)), + mDeleteButton(new Button(_("Delete"), "delete", this)), + mEnabledKeyboard(keyboard.isEnabled()) { int w = 350; int h = 370; - mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); setWindowName("TextCommandEditor"); @@ -178,70 +206,35 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): setDefaultSize(w, h, ImageRect::CENTER); mAdvanced = false; - mCommand = command; - mIsMagicCommand = (command->getCommandType() == TEXT_COMMAND_MAGIC); - - mIsMagic = new RadioButton(_("magic"), "magic", mIsMagicCommand); mIsMagic->setActionEventId("magic"); mIsMagic->addActionListener(this); - mIsOther = new RadioButton(_("other"), "magic", !mIsMagicCommand); mIsOther->setActionEventId("other"); mIsOther->addActionListener(this); - - mSymbolLabel = new Label(_("Symbol:")); - mSymbolTextField = new TextField(); - - mCommandLabel = new Label(_("Command:")); - mCommandTextField = new TextField(); - - mCommentLabel = new Label(_("Comment:")); - mCommentTextField = new TextField(); - - mManaLabel = new Label(_("Mana:")); - mManaField = new IntTextField(0); mManaField->setRange(0, 500); mManaField->setWidth(20); - mTargetTypeModel = new TargetTypeModel; - mTypeLabel = new Label(_("Target Type:")); - mTypeDropDown = new DropDown(mTargetTypeModel); mTypeDropDown->setActionEventId("type"); mTypeDropDown->addActionListener(this); - mIconsModal = new IconsModal; - mIconLabel = new Label(_("Icon:")); - mIconDropDown = new DropDown(mIconsModal); mIconDropDown->setActionEventId("icon"); mIconDropDown->addActionListener(this); mIconDropDown->setSelectedString(mCommand->getIcon()); - mMagicLvlLabel = new Label(_("Magic level:")); - mMagicLvlField = new IntTextField(0); mMagicLvlField->setRange(0, 5); mMagicLvlField->setWidth(20); - mMagicSchoolModel = new MagicSchoolModel; - mSchoolLabel = new Label(_("Magic School:")); - mSchoolDropDown = new DropDown(mMagicSchoolModel); mSchoolDropDown->setActionEventId("school"); mSchoolDropDown->addActionListener(this); mSchoolDropDown->setSelected(0); - mSchoolLvlLabel = new Label(_("School level:")); - mSchoolLvlField = new IntTextField(0); mSchoolLvlField->setRange(0, 5); mSchoolLvlField->setWidth(20); - mSaveButton = new Button(_("Save"), "save", this); mSaveButton->adjustSize(); - - mCancelButton = new Button(_("Cancel"), "cancel", this); mCancelButton->adjustSize(); - - mDeleteButton = new Button(_("Delete"), "delete", this); mDeleteButton->adjustSize(); if (command->getCommandType() == TEXT_COMMAND_MAGIC) diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index 39952f353..2221a9507 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -72,6 +72,7 @@ class TextCommandEditor : public Window, public gcn::ActionListener void deleteCommand(); + bool mIsMagicCommand; TextCommand *mCommand; bool mAdvanced; @@ -85,29 +86,27 @@ class TextCommandEditor : public Window, public gcn::ActionListener Label *mCommentLabel; TextField *mCommentTextField; + TargetTypeModel *mTargetTypeModel; Label *mTypeLabel; DropDown *mTypeDropDown; + IconsModal *mIconsModal; Label *mIconLabel; DropDown *mIconDropDown; Label *mManaLabel; IntTextField *mManaField; Label *mMagicLvlLabel; IntTextField *mMagicLvlField; + MagicSchoolModel *mMagicSchoolModel; Label *mSchoolLabel; DropDown *mSchoolDropDown; Label *mSchoolLvlLabel; IntTextField *mSchoolLvlField; - IconsModal *mIconsModal; - TargetTypeModel *mTargetTypeModel; - MagicSchoolModel *mMagicSchoolModel; - //Button *mAdvancedButton; Button *mCancelButton; Button *mSaveButton; Button *mDeleteButton; bool mEnabledKeyboard; - bool mIsMagicCommand; }; #endif diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index c46131379..5994b1e1a 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -61,10 +61,9 @@ static const int BOX_HEIGHT = 43; class ItemIdPair { public: - ItemIdPair(int id, Item* item) + ItemIdPair(int id, Item* item) : + mId(id), mItem(item) { - mId = id; - mItem = item; } int mId; @@ -166,18 +165,17 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mDescItems(false), mTag(0), mSortType(0), - mShowMatrix(nullptr) + mItemPopup(new ItemPopup), + mShowMatrix(nullptr), + mEquipedColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)), + mUnEquipedColor(Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED)) { - mItemPopup = new ItemPopup; setFocusable(true); mSelImg = Theme::getImageFromTheme("selection.png"); if (!mSelImg) logger->log1("Error: Unable to load selection.png"); - mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); - mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); - addKeyListener(this); addMouseListener(this); addWidgetListener(this); diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 61d929f0b..98d820164 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -34,9 +34,9 @@ #include "debug.h" -ItemLinkHandler::ItemLinkHandler() +ItemLinkHandler::ItemLinkHandler() : + mItemPopup(new ItemPopup) { - mItemPopup = new ItemPopup; } ItemLinkHandler::~ItemLinkHandler() diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index 13c2668f5..d7ff749d2 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -29,10 +29,10 @@ SetupTabScroll::SetupTabScroll() : SetupTab(), + mContainer(new VertContainer(25, false, 8)), + mScroll(new ScrollArea(mContainer)), mPreferredFirstItemSize(200) { - mContainer = new VertContainer(25, false, 8); - mScroll = new ScrollArea(mContainer); mScroll->setOpaque(false); mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index ab6400149..3031460c4 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -47,29 +47,33 @@ float ShopListBox::mAlpha = 1.0; ShopListBox::ShopListBox(gcn::ListModel *listModel): ListBox(listModel), mPlayerMoney(0), - mShopItems(nullptr) + mShopItems(nullptr), + mItemPopup(new ItemPopup), + mRowHeight(getFont()->getHeight()), + mPriceCheck(true), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND)), + mWarningColor(Theme::getThemeColor(Theme::SHOP_WARNING)) { - mRowHeight = getFont()->getHeight(); - init(); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): ListBox(listModel), mPlayerMoney(0), - mShopItems(shopListModel) + mShopItems(shopListModel), + mItemPopup(new ItemPopup), + mRowHeight(std::max(getFont()->getHeight(), ITEM_ICON_SIZE)), + mPriceCheck(true), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND)), + mWarningColor(Theme::getThemeColor(Theme::SHOP_WARNING)) { - mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE); - init(); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } void ShopListBox::init() { - mPriceCheck = true; - mItemPopup = new ItemPopup; - mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); - mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); - mWarningColor = Theme::getThemeColor(Theme::SHOP_WARNING); - setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } void ShopListBox::setPlayersMoney(int money) diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 694fdb92e..75598aa94 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -94,13 +94,13 @@ class ShopListBox : public ListBox unsigned int mRowHeight; /**< Row Height */ - static float mAlpha; - bool mPriceCheck; gcn::Color mHighlightColor; gcn::Color mBackgroundColor; gcn::Color mWarningColor; + + static float mAlpha; }; #endif // SHOPLISTBOX_H diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index f3ea962bc..36533864e 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -37,16 +37,16 @@ float TextPreview::mAlpha = 1.0; TextPreview::TextPreview(const std::string &text): + mFont(gui->getFont()), mText(text), + mTextColor(&Theme::getThemeColor(Theme::TEXT)), + mBGColor(&Theme::getThemeColor(Theme::BACKGROUND)), + mTextBGColor(nullptr), + mTextAlpha(false), + mOpaque(false), mShadow(false), mOutline(false) { - 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 81e27fd06..06c588215 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -121,11 +121,11 @@ class TextPreview : public gcn::Widget const gcn::Color *mTextColor; const gcn::Color *mBGColor; const gcn::Color *mTextBGColor; - static float mAlpha; bool mTextAlpha; bool mOpaque; bool mShadow; bool mOutline; + static float mAlpha; }; #endif diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index d1b97c82f..16253c26e 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -77,13 +77,13 @@ class WorldListModel : public gcn::ListModel }; WorldSelectDialog::WorldSelectDialog(Worlds worlds): - Window(_("Select World"), false, nullptr, "world.xml") + Window(_("Select World"), false, nullptr, "world.xml"), + mWorldListModel(new WorldListModel(worlds)), + mWorldList(new ListBox(mWorldListModel)), + mChangeLoginButton(new Button(_("Change Login"), "login", this)), + mChooseWorld(new Button(_("Choose World"), "world", this)) { - mWorldListModel = new WorldListModel(worlds); - mWorldList = new ListBox(mWorldListModel); ScrollArea *worldsScroll = new ScrollArea(mWorldList); - mChangeLoginButton = new Button(_("Change Login"), "login", this); - mChooseWorld = new Button(_("Choose World"), "world", this); worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp index 42b33f203..e05736870 100644 --- a/src/guichan/cliprectangle.cpp +++ b/src/guichan/cliprectangle.cpp @@ -52,25 +52,25 @@ namespace gcn { - ClipRectangle::ClipRectangle() + ClipRectangle::ClipRectangle() : + xOffset(0), + yOffset(0) { x = 0; y = 0; width = 0; height = 0; - xOffset = 0; - yOffset = 0; } ClipRectangle::ClipRectangle(int x0, int y0, int width0, int height0, - int xOffset0, int yOffset0) + int xOffset0, int yOffset0) : + xOffset(xOffset0), + yOffset(yOffset0) { x = x0; y = y0; width = width0; height = height0; - xOffset = xOffset0; - yOffset = yOffset0; } const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp index 9e0229f05..0a24d8b17 100644 --- a/src/guichan/gui.cpp +++ b/src/guichan/gui.cpp @@ -67,6 +67,7 @@ namespace gcn mTop(nullptr), mGraphics(nullptr), mInput(nullptr), + mFocusHandler(new FocusHandler()), mTabbing(true), mShiftPressed(false), mMetaPressed(false), @@ -79,7 +80,6 @@ namespace gcn mClickCount(1), mLastMouseDragButton(0) { - mFocusHandler = new FocusHandler(); } Gui::~Gui() diff --git a/src/guichan/include/guichan/widgets/radiobutton.hpp b/src/guichan/include/guichan/widgets/radiobutton.hpp index 06a42b5a5..fc9377787 100644 --- a/src/guichan/include/guichan/widgets/radiobutton.hpp +++ b/src/guichan/include/guichan/widgets/radiobutton.hpp @@ -127,7 +127,7 @@ namespace gcn * @param caption The caption of the radio button. * @see getCaption, adjustSize */ - void setCaption(const std::string caption); + void setCaption(const std::string &caption); /** * Sets the group the radio button should belong to. Note that diff --git a/src/guichan/sdl/sdlimage.cpp b/src/guichan/sdl/sdlimage.cpp index cf8505c4e..f00db27f9 100644 --- a/src/guichan/sdl/sdlimage.cpp +++ b/src/guichan/sdl/sdlimage.cpp @@ -55,10 +55,10 @@ namespace gcn { - SDLImage::SDLImage(SDL_Surface* surface, bool autoFree) + SDLImage::SDLImage(SDL_Surface* surface, bool autoFree) : + mSurface(surface), + mAutoFree(autoFree) { - mAutoFree = autoFree; - mSurface = surface; } SDLImage::~SDLImage() diff --git a/src/guichan/widgets/container.cpp b/src/guichan/widgets/container.cpp index b3edc0bcb..d6951f06a 100644 --- a/src/guichan/widgets/container.cpp +++ b/src/guichan/widgets/container.cpp @@ -56,9 +56,9 @@ namespace gcn { - Container::Container() + Container::Container() : + mOpaque(true) { - mOpaque = true; } Container::~Container() diff --git a/src/guichan/widgets/icon.cpp b/src/guichan/widgets/icon.cpp index d3d4d65ff..26139716d 100644 --- a/src/guichan/widgets/icon.cpp +++ b/src/guichan/widgets/icon.cpp @@ -64,11 +64,9 @@ namespace gcn } Icon::Icon(const std::string& filename) : - mImage(nullptr), - mInternalImage(false) + mImage(Image::load(filename)), + mInternalImage(true) { - mImage = Image::load(filename); - mInternalImage = true; setSize(mImage->getWidth(), mImage->getHeight()); } diff --git a/src/guichan/widgets/label.cpp b/src/guichan/widgets/label.cpp index 03ca04576..3e0eecb3c 100644 --- a/src/guichan/widgets/label.cpp +++ b/src/guichan/widgets/label.cpp @@ -56,16 +56,14 @@ namespace gcn { - Label::Label() + Label::Label() : mAlignment(Graphics::LEFT) { - mAlignment = Graphics::LEFT; } - Label::Label(const std::string& caption) + Label::Label(const std::string& caption) : + mCaption(caption), + mAlignment(Graphics::LEFT) { - mCaption = caption; - mAlignment = Graphics::LEFT; - setWidth(getFont()->getWidth(caption)); setHeight(getFont()->getHeight()); } diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp index 7811ea558..c5c0b1ebd 100644 --- a/src/guichan/widgets/radiobutton.cpp +++ b/src/guichan/widgets/radiobutton.cpp @@ -123,7 +123,7 @@ namespace gcn return mCaption; } - void RadioButton::setCaption(const std::string caption) + void RadioButton::setCaption(const std::string &caption) { mCaption = caption; } diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp index 21f7b5930..a9d84dd98 100644 --- a/src/guichan/widgets/scrollarea.cpp +++ b/src/guichan/widgets/scrollarea.cpp @@ -55,84 +55,81 @@ namespace gcn { - ScrollArea::ScrollArea() + ScrollArea::ScrollArea() : + mVScroll(0), + mHScroll(0), + mScrollbarWidth(12), + mHPolicy(SHOW_AUTO), + mVPolicy(SHOW_AUTO), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mUpButtonScrollAmount(10), + mDownButtonScrollAmount(10), + mLeftButtonScrollAmount(10), + mRightButtonScrollAmount(10), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mHorizontalMarkerDragOffset(0), + mVerticalMarkerDragOffset(0), + mOpaque(true) { - mVScroll = 0; - mHScroll = 0; - mHPolicy = SHOW_AUTO; - mVPolicy = SHOW_AUTO; - mVBarVisible = false; - mHBarVisible = false; - mScrollbarWidth = 12; - mUpButtonPressed = false; - mDownButtonPressed = false; - mLeftButtonPressed = false; - mRightButtonPressed = false; - mUpButtonScrollAmount = 10; - mDownButtonScrollAmount = 10; - mLeftButtonScrollAmount = 10; - mRightButtonScrollAmount = 10; - mIsVerticalMarkerDragged = false; - mIsHorizontalMarkerDragged = false; - mHorizontalMarkerDragOffset = 0; - mVerticalMarkerDragOffset = 0; - mOpaque = true; - addMouseListener(this); } - ScrollArea::ScrollArea(Widget *content) + ScrollArea::ScrollArea(Widget *content) : + mVScroll(0), + mHScroll(0), + mScrollbarWidth(12), + mHPolicy(SHOW_AUTO), + mVPolicy(SHOW_AUTO), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mUpButtonScrollAmount(10), + mDownButtonScrollAmount(10), + mLeftButtonScrollAmount(10), + mRightButtonScrollAmount(10), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mHorizontalMarkerDragOffset(0), + mVerticalMarkerDragOffset(0), + mOpaque(true) { - mVScroll = 0; - mHScroll = 0; - mHPolicy = SHOW_AUTO; - mVPolicy = SHOW_AUTO; - mVBarVisible = false; - mHBarVisible = false; - mScrollbarWidth = 12; - mUpButtonPressed = false; - mDownButtonPressed = false; - mLeftButtonPressed = false; - mRightButtonPressed = false; - mUpButtonScrollAmount = 10; - mDownButtonScrollAmount = 10; - mLeftButtonScrollAmount = 10; - mRightButtonScrollAmount = 10; - mIsVerticalMarkerDragged = false; - mIsHorizontalMarkerDragged = false; - mHorizontalMarkerDragOffset = 0; - mVerticalMarkerDragOffset = 0; - mOpaque = true; - setContent(content); addMouseListener(this); } ScrollArea::ScrollArea(Widget *content, ScrollPolicy hPolicy, - ScrollPolicy vPolicy) + ScrollPolicy vPolicy) : + mVScroll(0), + mHScroll(0), + mScrollbarWidth(12), + mHPolicy(hPolicy), + mVPolicy(vPolicy), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mUpButtonScrollAmount(10), + mDownButtonScrollAmount(10), + mLeftButtonScrollAmount(10), + mRightButtonScrollAmount(10), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mHorizontalMarkerDragOffset(0), + mVerticalMarkerDragOffset(0), + mOpaque(true) { - mVScroll = 0; - mHScroll = 0; - mHPolicy = hPolicy; - mVPolicy = vPolicy; - mScrollbarWidth = 12; - mVBarVisible = false; - mHBarVisible = false; - mUpButtonPressed = false; - mDownButtonPressed = false; - mLeftButtonPressed = false; - mRightButtonPressed = false; - mUpButtonScrollAmount = 10; - mDownButtonScrollAmount = 10; - mLeftButtonScrollAmount = 10; - mRightButtonScrollAmount = 10; - mIsVerticalMarkerDragged = false; - mIsHorizontalMarkerDragged = false; - mHorizontalMarkerDragOffset = 0; - mVerticalMarkerDragOffset = 0; - mOpaque = true; - setContent(content); addMouseListener(this); } diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp index d7e8084cc..189ee6e7b 100644 --- a/src/guichan/widgets/slider.cpp +++ b/src/guichan/widgets/slider.cpp @@ -56,13 +56,11 @@ namespace gcn { - Slider::Slider(double scaleEnd) + Slider::Slider(double scaleEnd) : + mDragged(false), + mScaleStart(0), + mScaleEnd(scaleEnd) { - mDragged = false; - - mScaleStart = 0; - mScaleEnd = scaleEnd; - setFocusable(true); setFrameSize(1); setOrientation(HORIZONTAL); @@ -74,13 +72,11 @@ namespace gcn addKeyListener(this); } - Slider::Slider(double scaleStart, double scaleEnd) + Slider::Slider(double scaleStart, double scaleEnd) : + mDragged(false), + mScaleStart(scaleStart), + mScaleEnd(scaleEnd) { - mDragged = false; - - mScaleStart = scaleStart; - mScaleEnd = scaleEnd; - setFocusable(true); setFrameSize(1); setOrientation(HORIZONTAL); diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp index 8afc248c5..fa70f1e08 100644 --- a/src/guichan/widgets/tab.cpp +++ b/src/guichan/widgets/tab.cpp @@ -59,10 +59,10 @@ namespace gcn { Tab::Tab() : + mLabel(new Label()), mHasMouse(false), mTabbedArea(nullptr) { - mLabel = new Label(); mLabel->setPosition(4, 4); add(mLabel); diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp index 44fb5d718..fc133ba9b 100644 --- a/src/guichan/widgets/textbox.cpp +++ b/src/guichan/widgets/textbox.cpp @@ -58,15 +58,13 @@ namespace gcn { - TextBox::TextBox() + TextBox::TextBox() : + mCaretColumn(0), + mCaretRow(0), + mEditable(true), + mOpaque(true) { - mCaretColumn = 0; - mCaretRow = 0; - mEditable = true; - mOpaque = true; - setText(""); - setFocusable(true); addMouseListener(this); @@ -74,15 +72,13 @@ namespace gcn adjustSize(); } - TextBox::TextBox(const std::string& text) + TextBox::TextBox(const std::string& text) : + mCaretColumn(0), + mCaretRow(0), + mEditable(true), + mOpaque(true) { - mCaretColumn = 0; - mCaretRow = 0; - mEditable = true; - mOpaque = true; - setText(text); - setFocusable(true); addMouseListener(this); diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp index c0e89cf1c..b23722cc4 100644 --- a/src/guichan/widgets/textfield.cpp +++ b/src/guichan/widgets/textfield.cpp @@ -57,23 +57,21 @@ namespace gcn { - TextField::TextField() + TextField::TextField() : + mCaretPosition(0), + mXScroll(0) { - mCaretPosition = 0; - mXScroll = 0; - setFocusable(true); addMouseListener(this); addKeyListener(this); } - TextField::TextField(const std::string& text) + TextField::TextField(const std::string& text) : + mText(text), + mCaretPosition(0), + mXScroll(0) { - mCaretPosition = 0; - mXScroll = 0; - - mText = text; adjustSize(); setFocusable(true); diff --git a/src/map.cpp b/src/map.cpp index 6afaaa727..43c5f406d 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -84,9 +84,9 @@ class ActorFunctuator } actorCompare; TileAnimation::TileAnimation(Animation *ani): + mAnimation(new SimpleAnimation(ani)), mLastImage(nullptr) { - mAnimation = new SimpleAnimation(ani); } TileAnimation::~TileAnimation() @@ -123,6 +123,7 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): mWidth(width), mHeight(height), mTileWidth(tileWidth), mTileHeight(tileHeight), mMaxTileHeight(height), + mMetaTiles(new MetaTile[mWidth * mHeight]), mHasWarps(false), mDebugFlags(MAP_NORMAL), mOnClosedList(1), mOnOpenList(2), @@ -135,6 +136,10 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): mIndexedTilesetsSize(0), mActorFixX(0), mActorFixY(0), + mVersion(0), + mSpecialLayer(new SpecialLayer(width, height)), + mTempLayer(new SpecialLayer(width, height, true)), + mObjects(new ObjectsLayer(width, height)), mFringeLayer(nullptr), mLastX(-1), mLastY(-1), @@ -148,17 +153,11 @@ Map::Map(int width, int height, int tileWidth, int tileHeight): mBeingOpacity(false) { const int size = mWidth * mHeight; - - mDebugFlags = 0; - mMetaTiles = new MetaTile[size]; for (int i = 0; i < NB_BLOCKTYPES; i++) { mOccupation[i] = new unsigned[size]; memset(mOccupation[i], 0, size * sizeof(unsigned)); } - mSpecialLayer = new SpecialLayer(width, height); - mTempLayer = new SpecialLayer(width, height, true); - mObjects = new ObjectsLayer(width, height); config.addListener("OverlayDetail", this); config.addListener("guialpha", this); @@ -351,7 +350,6 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) graphics->mWidth, graphics->mHeight)); } - bool overFringe = false; int updateFlag = 0; if (mOpenGL == 1) @@ -389,6 +387,8 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) } else { + bool overFringe = false; + for (LayersCIter layeri = mLayers.begin(), layeri_end = mLayers.end(); layeri != layeri_end && !overFringe; ++ layeri) { diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 28976e099..52b43ac4b 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -43,12 +43,10 @@ MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer): mX(x), mY(y), mWidth(width), mHeight(height), mIsFringeLayer(fringeLayer), - mHighlightAttackRange(config.getBoolValue("highlightAttackRange")) + mHighlightAttackRange(config.getBoolValue("highlightAttackRange")), + mTiles(new Image*[mWidth * mHeight]) { - const int size = mWidth * mHeight; - mTiles = new Image*[size]; - - std::fill_n(mTiles, size, static_cast<Image*>(nullptr)); + std::fill_n(mTiles, mWidth * mHeight, static_cast<Image*>(nullptr)); config.addListener("highlightAttackRange", this); } @@ -520,12 +518,12 @@ int MapLayer::getTileDrawWidth(Image *img, int endX, int &width) const } SpecialLayer::SpecialLayer(int width, int height, bool drawSprites): - mWidth(width), mHeight(height) + mWidth(width), mHeight(height), + mDrawSprites(drawSprites) { const int size = mWidth * mHeight; mTiles = new MapItem*[size]; std::fill_n(mTiles, size, static_cast<MapItem*>(nullptr)); - mDrawSprites = drawSprites; } SpecialLayer::~SpecialLayer() diff --git a/src/maplayer.h b/src/maplayer.h index 327a6baa0..c8dc08238 100644 --- a/src/maplayer.h +++ b/src/maplayer.h @@ -54,10 +54,9 @@ class MapRowVertexes class MapObject { public: - MapObject(int type0, std::string data0) + MapObject(int type0, std::string data0) : + type(type0), data(data0) { - type = type0; - data = data0; } int type; diff --git a/src/net/download.cpp b/src/net/download.cpp index 1acb4b59b..a4eb31603 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -64,9 +64,9 @@ Download::Download(void *ptr, const std::string &url, mThread(nullptr), mCurl(nullptr), mHeaders(nullptr), + mError(static_cast<char*>(calloc(CURL_ERROR_SIZE + 1, 1))), mIgnoreError(ignoreError) { - mError = static_cast<char*>(calloc(CURL_ERROR_SIZE + 1, 1)); mError[0] = 0; mOptions.cancel = 0; diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 71110984d..fe6c39645 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -39,10 +39,9 @@ namespace Ea { -GameHandler::GameHandler() +GameHandler::GameHandler() : + mCharID(0) { - mCharID = 0; - listen(CHANNEL_GAME); } diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index f28e9b396..a03ea45af 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -76,11 +76,11 @@ const Equipment::Slot EQUIP_CONVERT[] = namespace Ea { -InventoryHandler::InventoryHandler() +InventoryHandler::InventoryHandler() : + mStorage(nullptr), + mStorageWindow(nullptr), + mDebugInventory(true) { - mStorage = nullptr; - mStorageWindow = nullptr; - mDebugInventory = true; } InventoryHandler::~InventoryHandler() diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp index 2467eb198..7ac05b484 100644 --- a/src/net/manaserv/connection.cpp +++ b/src/net/manaserv/connection.cpp @@ -33,9 +33,10 @@ namespace ManaServ { Connection::Connection(ENetHost *client): - mConnection(0), mClient(client) + mPort(0), + mConnection(0), + mClient(client) { - mPort = 0; connections++; } diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index f93d8e44c..dc8f37d36 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -44,7 +44,10 @@ namespace ManaServ extern Connection *accountServerConnection; extern std::string netToken; -LoginHandler::LoginHandler() +LoginHandler::LoginHandler() : + mLoginData(0), + mMinUserNameLength(4), + mMaxUserNameLength(10) { static const Uint16 _messages[] = { @@ -60,9 +63,6 @@ LoginHandler::LoginHandler() }; handledMessages = _messages; loginHandler = this; - mMinUserNameLength = 4; - mMaxUserNameLength = 10; - mLoginData = 0; } void LoginHandler::handleMessage(Net::MessageIn &msg) diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index b4bb1a2d8..d3c33d19f 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -51,24 +51,24 @@ public: bool save; - ServerInfo() + ServerInfo() : + type(TMWATHENA), + port(6901), + save(false) { - type = TMWATHENA; - port = 6901; - save = false; version.first = 0; } - ServerInfo(const ServerInfo &info) + ServerInfo(const ServerInfo &info) : + type(info.type), + name(info.name), + hostname(info.hostname), + port(info.port), + description(info.description), + save(info.save) { - type = info.type; - name = info.name; - hostname = info.hostname; - port = info.port; - description = info.description; version.first = info.version.first; version.second = info.version.second; - save = info.save; } bool isValid() const diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index bcadb8c67..298580e63 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -47,14 +47,18 @@ const unsigned int vertexBufSize = 500; GLuint OpenGLGraphics::mLastImage = 0; OpenGLGraphics::OpenGLGraphics(): - mAlpha(false), mTexture(false), mColorAlpha(false), - mFboId(0), mTextureId(0), mRboId(0) + mFloatTexArray(new GLfloat[vertexBufSize * 4 + 30]), + mIntTexArray(new GLint[vertexBufSize * 4 + 30]), + mIntVertArray(new GLint[vertexBufSize * 4 + 30]), + mAlpha(false), + mTexture(false), + mColorAlpha(false), + mFboId(0), + mTextureId(0), + mRboId(0) { mOpenGL = 1; mName = "fast OpenGL"; - mFloatTexArray = new GLfloat[vertexBufSize * 4 + 30]; - mIntTexArray = new GLint[vertexBufSize * 4 + 30]; - mIntVertArray = new GLint[vertexBufSize * 4 + 30]; } OpenGLGraphics::~OpenGLGraphics() diff --git a/src/party.cpp b/src/party.cpp index 6c7934c78..56c0b0de9 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -60,9 +60,9 @@ PartyMember::PartyMember(Party *party, int id, const std::string &name): Party::PartyMap Party::parties; Party::Party(short id): + mId(id), mCanInviteUsers(false) { - mId = id; parties[id] = this; } diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index 8142cc194..4aa8f96c8 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -37,11 +37,11 @@ struct Attack std::string missileParticle; Attack(std::string action0, std::string particleEffect0, - std::string missileParticle0) + std::string missileParticle0) : + action(action0), + particleEffect(particleEffect0), + missileParticle(missileParticle0) { - action = action0; - particleEffect = particleEffect0; - missileParticle = missileParticle0; } }; diff --git a/src/resources/resource.h b/src/resources/resource.h index c0ea7ca23..1b62c0206 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -39,11 +39,14 @@ class Resource /** * Constructor */ - Resource(): mRefCount(0) - { + Resource() : #ifdef DEBUG_DUMP_LEAKS - mDumped = false; + mRefCount(0), + mDumped(false) +#else + mRefCount(0) #endif + { } /** diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index b0cb5f1b6..461e60230 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -44,10 +44,9 @@ struct SpriteReference sprite(""), variant(0) {} - SpriteReference(std::string sprite0, int variant0) + SpriteReference(std::string sprite0, int variant0) : + sprite(sprite0), variant(variant0) { - sprite = sprite0; - variant = variant0; } std::string sprite; diff --git a/src/spellshortcut.cpp b/src/spellshortcut.cpp index 0f8697f79..ad506e6d5 100644 --- a/src/spellshortcut.cpp +++ b/src/spellshortcut.cpp @@ -37,9 +37,9 @@ SpellShortcut *spellShortcut; -SpellShortcut::SpellShortcut() +SpellShortcut::SpellShortcut() : + mItemSelected(-1) { - mItemSelected = -1; load(); } diff --git a/src/utils/mutex.h b/src/utils/mutex.h index a97a8d3f8..61129b4a9 100644 --- a/src/utils/mutex.h +++ b/src/utils/mutex.h @@ -61,9 +61,9 @@ private: }; -inline Mutex::Mutex() +inline Mutex::Mutex() : + mMutex(SDL_CreateMutex()) { - mMutex = SDL_CreateMutex(); } inline Mutex::~Mutex() diff --git a/src/variabledata.h b/src/variabledata.h index c306d43ed..c06c16e58 100644 --- a/src/variabledata.h +++ b/src/variabledata.h @@ -45,8 +45,8 @@ class VariableData class IntData : public VariableData { public: - IntData(int value) - { mData = value; } + IntData(int value) : mData(value) + { } int getData() const { return mData; } @@ -61,8 +61,8 @@ class IntData : public VariableData class StringData : public VariableData { public: - StringData(const std::string &value) - { mData = value; } + StringData(const std::string &value) : mData(value) + { } const std::string &getData() const { return mData; } @@ -77,8 +77,8 @@ class StringData : public VariableData class FloatData : public VariableData { public: - FloatData(double value) - { mData = value; } + FloatData(double value) : mData(value) + { } double getData() const { return mData; } @@ -93,8 +93,8 @@ class FloatData : public VariableData class BoolData : public VariableData { public: - BoolData(bool value) - { mData = value; } + BoolData(bool value) : mData(value) + { } bool getData() const { return mData; } |