From 98c74738f21d7ae256f1273b6c1614ee64e2a3ad Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 19 Oct 2018 06:55:28 +0300 Subject: Fix code style. --- src/gui/models/tablemodel.cpp | 6 +++--- src/gui/popups/beingpopup.cpp | 1 + src/gui/widgets/characterviewnormal.cpp | 2 +- src/gui/widgets/tabbedarea.cpp | 12 +++++++----- src/gui/widgets/tabs/socialnavigationtab.h | 2 +- src/gui/windows/charcreatedialog.cpp | 6 +++--- src/gui/windows/ministatuswindow.cpp | 6 +++--- src/progs/manaplus/client.cpp | 3 +-- src/render/vertexes/openglgraphicsvertexes.cpp | 6 ++---- src/resources/map/map.cpp | 3 +-- 10 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp index 3f9c262c7..7399ca31f 100644 --- a/src/gui/models/tablemodel.cpp +++ b/src/gui/models/tablemodel.cpp @@ -168,12 +168,12 @@ int StaticTableModel::getColumns() const int StaticTableModel::getWidth() const { - int width = 0; + size_t width = 0; for (size_t i = 0, sz = mWidths.size(); i < sz; i++) - width += mWidths[i]; + width += CAST_SIZE(mWidths[i]); - return width; + return CAST_S32(width); } int StaticTableModel::getHeight() const diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 5ba770f2e..557472d57 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -61,6 +61,7 @@ BeingPopup::BeingPopup() : BeingPopup::~BeingPopup() { + mBeingName = nullptr; } void BeingPopup::postInit() diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp index d001a2175..b2ff5dff7 100644 --- a/src/gui/widgets/characterviewnormal.cpp +++ b/src/gui/widgets/characterviewnormal.cpp @@ -101,7 +101,7 @@ void CharacterViewNormal::resize() if (sz == 0) return; const CharacterDisplay *const firtChar = (*mCharacterEntries)[0]; - int y = 0; + unsigned int y = 0; const int width = firtChar->getWidth(); const int height = firtChar->getHeight(); int x = 0; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 6e9fa5e19..37fb7637e 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -555,13 +555,14 @@ void TabbedArea::updateTabsWidth() void TabbedArea::updateVisibleTabsWidth() { - mVisibleTabsWidth = 0; + unsigned int visibleTabsWidth = 0; for (size_t i = mTabScrollIndex, sz = mTabs.size(); i < sz; ++i) { Tab *const tab = mTabs[i].first; - if ((tab != nullptr) && tab->mVisible == Visible_true) - mVisibleTabsWidth += CAST_S32(tab->getWidth()); + if (tab != nullptr && tab->mVisible == Visible_true) + visibleTabsWidth += CAST_S32(tab->getWidth()); } + mVisibleTabsWidth = visibleTabsWidth; } void TabbedArea::adjustSize() @@ -616,8 +617,9 @@ void TabbedArea::adjustTabPositions() } } - int x = (mEnableScrollButtons && mArrowButton[0]->mVisible == Visible_true) - ? mArrowButton[0]->getWidth() : 0; + unsigned int x = (mEnableScrollButtons && + mArrowButton[0]->mVisible == Visible_true) ? + mArrowButton[0]->getWidth() : 0U; for (size_t i = mTabScrollIndex; i < sz; ++i) { Tab *const tab = mTabs[i].first; diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index a3eb8f8b2..f58bc4200 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -175,7 +175,7 @@ class SocialNavigationTab final : public SocialTab return; const Avatar *const ava = avatars->at(num); - if ((ava != nullptr) && (localPlayer != nullptr)) + if (ava != nullptr) localPlayer->navigateTo(ava->getX(), ava->getY()); } diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index be5756102..49dcd8314 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -649,11 +649,11 @@ void CharCreateDialog::unlock() int CharCreateDialog::getDistributedPoints() const { - int points = 0; + unsigned int points = 0; for (size_t i = 0, sz = mAttributeSlider.size(); i < sz; i++) - points += CAST_S32(mAttributeSlider[i]->getValue()); - return points; + points += CAST_U32(mAttributeSlider[i]->getValue()); + return CAST_S32(points); } void CharCreateDialog::setAttributes(const StringVect &labels, diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index e98e607be..69dbcbf45 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -253,14 +253,14 @@ void MiniStatusWindow::eraseIcon(const int index) void MiniStatusWindow::drawIcons(Graphics *const graphics) { // Draw icons - int icon_x = mMaxX + mIconPadding; + unsigned int icon_x = mMaxX + mIconPadding; for (size_t i = 0, sz = mIcons.size(); i < sz; i ++) { const AnimatedSprite *const icon = mIcons[i]; if (icon != nullptr) { - icon->draw(graphics, icon_x, mIconPadding); - icon_x += mIconSpacing + icon->getWidth(); + icon->draw(graphics, CAST_S32(icon_x), mIconPadding); + icon_x += CAST_U32(mIconSpacing + icon->getWidth()); } } } diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp index 3ae4c2f76..dabfe293b 100644 --- a/src/progs/manaplus/client.cpp +++ b/src/progs/manaplus/client.cpp @@ -880,8 +880,7 @@ void Client::stateConnectServer1() config.write(); } } - else if (mOldState != State::CHOOSE_SERVER && - (loginHandler != nullptr) && + else if (loginHandler != nullptr && loginHandler->isConnected()) { mState = State::PRE_LOGIN; diff --git a/src/render/vertexes/openglgraphicsvertexes.cpp b/src/render/vertexes/openglgraphicsvertexes.cpp index 4acde987b..79ed66b1d 100644 --- a/src/render/vertexes/openglgraphicsvertexes.cpp +++ b/src/render/vertexes/openglgraphicsvertexes.cpp @@ -169,8 +169,7 @@ GLfloat *OpenGLGraphicsVertexes::continueFloatTexArray() restrict2 { if (mFloatTexPool.empty()) { - mFloatTexArray = new GLfloat[CAST_SIZE( - vertexBufSize * 4 + 30)]; + mFloatTexArray = new GLfloat[CAST_SIZE(vertexBufSize) * 4 + 30]; mFloatTexPool.push_back(mFloatTexArray); } else @@ -198,8 +197,7 @@ GLshort *OpenGLGraphicsVertexes::continueShortVertArray() restrict2 { if (mShortVertPool.empty()) { - mShortVertArray = new GLshort[CAST_SIZE( - vertexBufSize * 4 + 30)]; + mShortVertArray = new GLshort[CAST_SIZE(vertexBufSize) * 4 + 30]; mShortVertPool.push_back(mShortVertArray); } else diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index adda1bcb7..bcec1a4a3 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -1598,8 +1598,7 @@ void Map::reduce() restrict2 ++ ri; continue; } - const size_t pos = CAST_SIZE( - x + y * layer2->mWidth); + const size_t pos = x + y * CAST_SIZE(layer2->mWidth); img = layer2->mTiles[pos].image; if (img != nullptr) { -- cgit v1.2.3-70-g09d2