diff options
author | Andrei Karas <akaras@inbox.ru> | 2020-02-23 09:30:51 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2020-02-23 09:30:51 +0300 |
commit | 1e2a88e975019929c4c7e3154537865cc09550a6 (patch) | |
tree | ae8bc68ad3a3f6b61a5e2d511d7fc17daa22bd0e | |
parent | 6941fd4eeb1dce20aba8c42fd030c2690c37b731 (diff) | |
download | manaverse-1e2a88e975019929c4c7e3154537865cc09550a6.tar.gz manaverse-1e2a88e975019929c4c7e3154537865cc09550a6.tar.bz2 manaverse-1e2a88e975019929c4c7e3154537865cc09550a6.tar.xz manaverse-1e2a88e975019929c4c7e3154537865cc09550a6.zip |
Fix some code style issues
38 files changed, 113 insertions, 100 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp index 0459d83e9..072d1f30a 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -650,11 +650,11 @@ void Being::setSpeech(const std::string &restrict text) restrict2 } else { - const bool isShowName = (speech == BeingSpeech::NAME_IN_BUBBLE); if (mSpeechBubble == nullptr) createSpeechBubble(); if (mSpeechBubble != nullptr) { + const bool isShowName = (speech == BeingSpeech::NAME_IN_BUBBLE); mSpeechBubble->setCaption(isShowName ? mName : "", &theme->getColor(ThemeColorId::BUBBLE_NAME, 255), &theme->getColor(ThemeColorId::BUBBLE_NAME_OUTLINE, 255)); diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 55808ecda..449032a40 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -1101,9 +1101,11 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect, if (!found) { // add new - const int offset = CAST_S32(mStatusEffectIcons.size()); if (miniStatusWindow != nullptr) + { + const int offset = CAST_S32(mStatusEffectIcons.size()); miniStatusWindow->setIcon(offset, sprite); + } mStatusEffectIcons.push_back(effectId); } } diff --git a/src/fs/virtfs/fsziprwops.cpp b/src/fs/virtfs/fsziprwops.cpp index db95b602e..22a19385d 100644 --- a/src/fs/virtfs/fsziprwops.cpp +++ b/src/fs/virtfs/fsziprwops.cpp @@ -47,8 +47,8 @@ namespace FsZip return -1; File *const handle = static_cast<File *>( rw->hidden.unknown.data1); - size_t mPos = handle->mPos; - size_t mSize = handle->mSize; + const size_t mPos = handle->mPos; + const size_t mSize = handle->mSize; RWOPSINT pos = 0; diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index 0e9dd031f..3cb80b7ac 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -294,7 +294,6 @@ void ItemPopup::setItem(const ItemInfo &item, minWidth = mItemOptions->getMinWidth(); const int numRowsDesc = mItemDesc->getNumberOfRows(); - const int numRowsEffect = mItemEffect->getNumberOfRows(); const int numRowsWeight = mItemWeight->getNumberOfRows(); const int numRowsCards = mItemCards->getNumberOfRows(); const int numRowsOptions = mItemOptions->getNumberOfRows(); @@ -312,6 +311,7 @@ void ItemPopup::setItem(const ItemInfo &item, } else { + const int numRowsEffect = mItemEffect->getNumberOfRows(); setContentSize(minWidth, (numRowsDesc + numRowsEffect + 2 + numRowsWeight + numRowsCards + numRowsOptions) * height); mItemEffect->setPosition(0, (numRowsDesc + 2) * height); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index dcba43e1f..6ecbd6a9f 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1393,10 +1393,10 @@ void PopupMenu::handleLink(const std::string &link, { if (localPlayer != nullptr) { - const int num = atoi(link.substr(10).c_str()); const Guild *const guild = localPlayer->getGuild(); if (guild != nullptr) { + const int num = atoi(link.substr(10).c_str()); guildHandler->changeMemberPostion( guild->getMember(mName), num); } diff --git a/src/gui/popups/skillpopup.cpp b/src/gui/popups/skillpopup.cpp index f7d86d85c..8d5950b11 100644 --- a/src/gui/popups/skillpopup.cpp +++ b/src/gui/popups/skillpopup.cpp @@ -209,7 +209,6 @@ void SkillPopup::show(const SkillInfo *const skill, minWidth = mSkillCastType->getMinWidth(); const int numRowsDesc = mSkillDesc->getNumberOfRows(); - const int numRowsEffect = mSkillEffect->getNumberOfRows(); const int numRowsLevel = mSkillLevel->getNumberOfRows(); const int numRowsCast = mSkillCastType->getNumberOfRows(); const int height = getFont()->getHeight(); @@ -223,6 +222,7 @@ void SkillPopup::show(const SkillInfo *const skill, } else { + const int numRowsEffect = mSkillEffect->getNumberOfRows(); setContentSize(minWidth, (numRowsDesc + numRowsLevel + numRowsEffect + numRowsCast + 1) * height); diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp index 51c1532bb..60d6ef72d 100644 --- a/src/gui/shortcut/itemshortcut.cpp +++ b/src/gui/shortcut/itemshortcut.cpp @@ -120,9 +120,9 @@ void ItemShortcut::save() const for (unsigned int i = 0; i < SHORTCUT_ITEMS; i++) { const int itemId = mItems[i] != 0 ? mItems[i] : -1; - const int itemColor = toInt(mItemColors[i], int); if (itemId != -1) { + const int itemColor = toInt(mItemColors[i], int); const std::string itemData = mItemData[i]; serverConfig.setValue(name + toString(i), itemId); serverConfig.setValue(color + toString(i), itemColor); diff --git a/src/gui/shortcut/shortcutbase.cpp b/src/gui/shortcut/shortcutbase.cpp index e6e1a5923..3fe0250fa 100644 --- a/src/gui/shortcut/shortcutbase.cpp +++ b/src/gui/shortcut/shortcutbase.cpp @@ -76,11 +76,11 @@ void ShortcutBase::save() const for (size_t i = 0; i < mMaxSize; i++) { const int itemId = mItems[i] != 0 ? mItems[i] : -1; - const int itemColor = (mItemColors[i] != ItemColor_zero) - ? toInt(mItemColors[i], int) : 1; const std::string num = toString(CAST_S32(i)); if (itemId != -1) { + const int itemColor = (mItemColors[i] != ItemColor_zero) + ? toInt(mItemColors[i], int) : 1; serverConfig.setValue(mItemName + num, itemId); serverConfig.setValue(mColorName + num, itemColor); } diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index cfacab828..cac97c092 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -174,9 +174,9 @@ void AvatarListBox::draw(Graphics *const graphics) text = strprintf("%s %d/%d", a->getComplexName().c_str(), a->getHp(), a->getMaxHp()); } - const bool isPoison = a->getPoison(); if (a->getMaxHp() != 0) { + const bool isPoison = a->getPoison(); const ProgressColorIdT themeColor = (isPoison ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP); @@ -412,9 +412,9 @@ void AvatarListBox::safeDraw(Graphics *const graphics) text = strprintf("%s %d/%d", a->getComplexName().c_str(), a->getHp(), a->getMaxHp()); } - const bool isPoison = a->getPoison(); if (a->getMaxHp() != 0) { + const bool isPoison = a->getPoison(); const ProgressColorIdT themeColor = (isPoison ? ProgressColorId::PROG_HP_POISON : ProgressColorId::PROG_HP); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 1f51d8ba9..44e41be5a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -805,12 +805,16 @@ void Button::adjustSize() if (mImages != nullptr) { - const int spacing = mSpacing[BUTTON_STANDARD]; const int width = font->getWidth(mCaption); if (width != 0) + { + const int spacing = mSpacing[BUTTON_STANDARD]; setWidth(width + mImageWidth + spacing + 2 * padding); + } else + { setWidth(mImageWidth + 2 * padding); + } int height = font->getHeight(); if (height < mImageHeight) height = mImageHeight; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 1d09d5c97..f4fb56f9e 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -226,7 +226,6 @@ void DropDown::draw(Graphics *const graphics) updateAlpha(); const unsigned int alpha = CAST_U32(mAlpha * 255.0F); - const int pad = 2 * mPadding; mHighlightColor.a = alpha; mShadowColor.a = alpha; @@ -272,6 +271,7 @@ void DropDown::draw(Graphics *const graphics) if (isFocused()) { + const int pad = 2 * mPadding; graphics->setColor(mHighlightColor); graphics->drawRectangle(Rect(mPadding, mPadding, mDimension.width - h - pad, h - pad)); @@ -321,11 +321,10 @@ void DropDown::safeDrawFrame(Graphics *const graphics) void DropDown::drawButton(Graphics *const graphics) { - const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height; - - Image *image = buttons[mDroppedDown][mPushed]; + Image *const image = buttons[mDroppedDown][mPushed]; if (image != nullptr) { + const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height; graphics->drawImage(image, mDimension.width - image->getWidth() - mImagePadding, (height - image->getHeight()) / 2); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 036c42ac3..b19e18fc8 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -141,9 +141,9 @@ void ExtendedListBox::draw(Graphics *const graphics) for (size_t f = 0; f < itemsSz; ++f) { const ExtendedListBoxItem &item = mListItems[f]; - const int row1 = item.row; if (item.image) { + const int row1 = item.row; const Image *const image = model->getImageAt(row1); if (image != nullptr) { @@ -201,9 +201,9 @@ void ExtendedListBox::draw(Graphics *const graphics) for (size_t f = 0; f < selSz; ++f) { const ExtendedListBoxItem &item = mSelectedItems[f]; - const int row1 = item.row; if (item.image) { + const int row1 = item.row; const Image *const image = model->getImageAt(row1); if (image != nullptr) { diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 9c566c9c7..e60e70332 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -365,8 +365,6 @@ void ItemContainer::draw(Graphics *const graphics) int itemIndex = j * mGridColumns - 1; for (int i = 0; i < mGridColumns; i++) { - int itemX = i * mBoxWidth; - int itemY = intY0; itemIndex ++; if (mShowMatrix[itemIndex] < 0) continue; @@ -380,6 +378,8 @@ void ItemContainer::draw(Graphics *const graphics) Image *const image = item->getImage(); if (image != nullptr) { + int itemX = i * mBoxWidth; + int itemY = intY0; if (mShowMatrix[itemIndex] == mSelectedIndex) { if (mSelImg != nullptr) @@ -487,8 +487,6 @@ void ItemContainer::safeDraw(Graphics *const graphics) int itemIndex = j * mGridColumns - 1; for (int i = 0; i < mGridColumns; i++) { - int itemX = i * mBoxWidth; - int itemY = intY0; itemIndex ++; if (mShowMatrix[itemIndex] < 0) continue; @@ -502,6 +500,8 @@ void ItemContainer::safeDraw(Graphics *const graphics) Image *const image = item->getImage(); if (image != nullptr) { + int itemX = i * mBoxWidth; + int itemY = intY0; if (mShowMatrix[itemIndex] == mSelectedIndex) { if (mSelImg != nullptr) @@ -1148,9 +1148,9 @@ void ItemContainer::adjustHeight() mGridRows = maxRows; } - const int num = updateMatrix(); if (mShowEmptyRows == ShowEmptyRows_false) { + const int num = updateMatrix(); mDrawRows = num / mGridColumns; if (mDrawRows == 0 || num % mGridColumns > 0) ++mDrawRows; diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 193c28ec6..9dfa7ce4d 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -152,7 +152,6 @@ void Label::draw(Graphics *const graphics) BLOCK_START("Label::draw") int textX; const Rect &rect = mDimension; - const int textY = rect.height / 2 - getFont()->getHeight() / 2; Font *const font = getFont(); switch (mAlignment) @@ -185,7 +184,10 @@ void Label::draw(Graphics *const graphics) const Image *const image = mTextChunk.img; if (image != nullptr) + { + const int textY = rect.height / 2 - font->getHeight() / 2; graphics->drawImage(image, textX, textY); + } BLOCK_END("Label::draw") } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 27e21593d..172461e64 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -457,14 +457,13 @@ void ScrollArea::drawFrame(Graphics *const graphics) BLOCK_START("ScrollArea::drawFrame") if (mOpaque == Opaque_true) { - const int bs = mFrameSize * 2; - const int w = mDimension.width + bs; - const int h = mDimension.height + bs; - updateCalcFlag(graphics); if (mRedraw) { + const int bs = mFrameSize * 2; + const int w = mDimension.width + bs; + const int h = mDimension.height + bs; mVertexes2->clear(); graphics->calcWindow(mVertexes2, 0, 0, @@ -759,10 +758,10 @@ void ScrollArea::mouseExited(MouseEvent& event A_UNUSED) void ScrollArea::widgetResized(const Event &event A_UNUSED) { mRedraw = true; - const unsigned int frameSize = 2 * mFrameSize; Widget *const content = getContent(); if (content != nullptr) { + const unsigned int frameSize = 2 * mFrameSize; content->setSize(mDimension.width - frameSize, mDimension.height - frameSize); } @@ -935,13 +934,12 @@ void ScrollArea::mouseDragged(MouseEvent &event) if (mIsVerticalMarkerDragged) { const Rect barDim = getVerticalBarDimension(); - - const int pos = event.getY() - barDim.y - - mVerticalMarkerDragOffset; const int length = getVerticalMarkerDimension().height; if ((barDim.height - length) > 0) { + const int pos = event.getY() - barDim.y + - mVerticalMarkerDragOffset; setVerticalScrollAmount((getVerticalMaxScroll() * pos) / (barDim.height - length)); } @@ -954,13 +952,12 @@ void ScrollArea::mouseDragged(MouseEvent &event) if (mIsHorizontalMarkerDragged) { const Rect barDim = getHorizontalBarDimension(); - - const int pos = event.getX() - barDim.x - - mHorizontalMarkerDragOffset; const int length = getHorizontalMarkerDimension().width; if ((barDim.width - length) > 0) { + const int pos = event.getX() - barDim.x + - mHorizontalMarkerDragOffset; setHorizontalScrollAmount((getHorizontalMaxScroll() * pos) / (barDim.width - length)); } diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 32da8e700..3900be438 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -478,7 +478,6 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) const int widgetFrameSize = 2 * mWidgetContainer->getFrameSize(); const int w1 = mDimension.width; const int h1 = mDimension.height; - const int width = w1 - frameSize - widgetFrameSize; const int height = h1 - frameSize - mWidgetContainer->getY() - widgetFrameSize; @@ -529,6 +528,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) if (mArrowButton[1] != nullptr) { + const int width = w1 - frameSize - widgetFrameSize; // Move the right arrow to fit the windows content. newWidth = width - mArrowButton[1]->getWidth() - mRightMargin; if (newWidth < 0) diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index acd6ffcef..63b2b132d 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -242,7 +242,6 @@ Setup_Theme::~Setup_Theme() delete2(mFontSizeListModel) delete2(mNpcFontSizeListModel) delete2(mLangListModel) - delete2(mInfo) } void Setup_Theme::updateInfo() diff --git a/src/gui/widgets/virtshortcutcontainer.cpp b/src/gui/widgets/virtshortcutcontainer.cpp index a6553b132..229bdf2de 100644 --- a/src/gui/widgets/virtshortcutcontainer.cpp +++ b/src/gui/widgets/virtshortcutcontainer.cpp @@ -100,17 +100,18 @@ void VirtShortcutContainer::draw(Graphics *const graphics) for (unsigned i = 0; i < mMaxItems; i++) { - const int itemX = (i % mGridWidth) * mBoxWidth; - const int itemY = (i / mGridWidth) * mBoxHeight; - - if (mShortcut->getItem(i) < 0) + const int itemId = mShortcut->getItem(i); + if (itemId < 0) continue; - const Item *const item = inv->findItem(mShortcut->getItem(i), + const Item *const item = inv->findItem(itemId, mShortcut->getItemColor(i)); if (item != nullptr) { + const int itemX = (i % mGridWidth) * mBoxWidth; + const int itemY = (i / mGridWidth) * mBoxHeight; + // Draw item icon. Image *const image = item->getImage(); @@ -176,13 +177,14 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics) for (unsigned i = 0; i < mMaxItems; i++) { - const int itemX = (i % mGridWidth) * mBoxWidth; - const int itemY = (i / mGridWidth) * mBoxHeight; + const int itemId = mShortcut->getItem(i); + if (itemId < 0) + continue; - if (mShortcut->getItem(i) < 0) + if (itemId < 0) continue; - const Item *const item = inv->findItem(mShortcut->getItem(i), + const Item *const item = inv->findItem(itemId, mShortcut->getItemColor(i)); if (item != nullptr) @@ -192,6 +194,9 @@ void VirtShortcutContainer::safeDraw(Graphics *const graphics) if (image != nullptr) { + const int itemX = (i % mGridWidth) * mBoxWidth; + const int itemY = (i / mGridWidth) * mBoxHeight; + std::string caption; if (item->getQuantity() > 1) caption = toString(item->getQuantity()); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index deebfd5ef..2d51a49c0 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -1011,7 +1011,6 @@ void Window::mouseDragged(MouseEvent &event) if ((mouseResize != 0) && !mMoved) { - const int dx = event.getX() - mDragOffsetX; const int dy = event.getY() - mDragOffsetY; Rect newDim = getDimension(); @@ -1028,6 +1027,7 @@ void Window::mouseDragged(MouseEvent &event) if ((mouseResize & (LEFT | RIGHT)) != 0) { + const int dx = event.getX() - mDragOffsetX; const int newWidth = newDim.width + ((mouseResize & LEFT) != 0 ? -dx : dx); newDim.width = std::min(mMaxWinWidth, diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index f96cf976d..ad7fc1573 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1883,12 +1883,12 @@ void ChatWindow::loadState() if (nick.empty()) break; - const int flags = serverConfig.getValue( - "chatWhisperFlags" + toString(num), 1); - ChatTab *const tab = addChatTab(nick, false, false); if (tab != nullptr) { + const int flags = serverConfig.getValue( + "chatWhisperFlags" + toString(num), 1); + tab->setAllowHighlight((flags & 1) != 0); tab->setRemoveNames(((flags & 2) / 2) != 0); tab->setNoAway(((flags & 4) / 4) != 0); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 8722e35e3..28d83b10f 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -643,11 +643,11 @@ void InventoryWindow::mouseClicked(MouseEvent &event) /* Convert relative to the window coordinates to absolute screen * coordinates. */ - const int mx = event.getX() + getX(); - const int my = event.getY() + getY(); - if (popupMenu != nullptr) { + const int mx = event.getX() + getX(); + const int my = event.getY() + getY(); + popupMenu->showPopup(this, mx, my, item, diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 2a1b3e16c..42e7d8804 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -432,7 +432,6 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) Attributes::PLAYER_JOB_LEVEL); const std::string expStr = toString(CAST_U64(exp)); const std::string expNeedStr = toString(CAST_U64(expNeed)); - const std::string expLeftStr = toString(CAST_U64(expNeed - exp)); // TRANSLATORS: job bar label const std::string level = strprintf(_("Job level: %d"), @@ -447,6 +446,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) } else { + const std::string expLeftStr = toString(CAST_U64(expNeed - exp)); textPopup->show(x + rect.x, y + rect.y, level, diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index eb28639f8..6bd298e2b 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -439,7 +439,6 @@ void ShopWindow::updateButtonsAndLabels() { bool allowDel(false); bool allowAdd(false); - const bool sellNotEmpty = mSellShopItems->getNumberOfElements() > 0; if (isBuySelected) { allowAdd = !mEnableBuyingStore; @@ -467,6 +466,7 @@ void ShopWindow::updateButtonsAndLabels() } else { + const bool sellNotEmpty = mSellShopItems->getNumberOfElements() > 0; allowAdd = !mEnableVending && mSelectedItem != -1; allowDel = !mEnableVending && mSellShopItemList->getSelected() != -1 diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index e45ca266c..faa8e6fa5 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -78,9 +78,9 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title, setMinWidth(32); setMinHeight(32); - const int border = SCROLL_PADDING * 2 + getPadding() * 2; if (mItems != nullptr) { + const int border = SCROLL_PADDING * 2 + getPadding() * 2; const int bw = mItems->getBoxWidth(); const int bh = mItems->getBoxHeight(); const int maxItems = mItems->getMaxItems(); diff --git a/src/input/touch/touchmanager.cpp b/src/input/touch/touchmanager.cpp index e4a271797..fe70a0685 100644 --- a/src/input/touch/touchmanager.cpp +++ b/src/input/touch/touchmanager.cpp @@ -428,7 +428,6 @@ void TouchManager::loadPad() restrict2 void TouchManager::loadButtons() restrict2 { - const int sz = (mButtonsSize + 1) * 50; if (theme == nullptr) return; Skin *const skin = theme->load("dbutton.xml", @@ -438,6 +437,7 @@ void TouchManager::loadButtons() restrict2 if (skin != nullptr) { + const int sz = (mButtonsSize + 1) * 50; const int x = skin->getOption("x", 10); const int y = skin->getOption("y", 10); const int pad = skin->getPadding(); diff --git a/src/logger.cpp b/src/logger.cpp index 366dda561..b7d3b422e 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -485,7 +485,7 @@ void Logger::error(const std::string &error_text) // StandardAlert(kAlertStopAlert, // (const unsigned char*)"\pError", // (ConstStr255Param) msg, nullptr, nullptr); -#elif defined(__linux__) || defined(_linux) +#elif defined(__linux__) || defined(__linux) std::cerr << "Error: " << error_text << std::endl; const std::string msg("xmessage \"Error happened. " "Please see log file for more information.\""); diff --git a/src/net/ea/charserverrecv.cpp b/src/net/ea/charserverrecv.cpp index 5f91f23a7..0d4ed157a 100644 --- a/src/net/ea/charserverrecv.cpp +++ b/src/net/ea/charserverrecv.cpp @@ -119,9 +119,9 @@ void CharServerRecv::processCharCreateFailed(Net::MessageIn &msg) void CharServerRecv::processCharDelete(Net::MessageIn &msg A_UNUSED) { BLOCK_START("CharServerRecv::processCharDelete") - delete Net::CharServerHandler::mSelectedCharacter; Net::CharServerHandler::mCharacters.remove( Net::CharServerHandler::mSelectedCharacter); + delete Net::CharServerHandler::mSelectedCharacter; Net::CharServerHandler::mSelectedCharacter = nullptr; Net::CharServerHandler::updateCharSelectDialog(); Net::CharServerHandler::unlockCharSelectDialog(); diff --git a/src/progs/manaplus/actions/actions.cpp b/src/progs/manaplus/actions/actions.cpp index 1a351d268..4606137f3 100644 --- a/src/progs/manaplus/actions/actions.cpp +++ b/src/progs/manaplus/actions/actions.cpp @@ -1274,9 +1274,11 @@ impHandler(undress) if (sz == 2) { - const int itemId = atoi(pars[1].c_str()); if (target != nullptr) + { + const int itemId = atoi(pars[1].c_str()); target->undressItemById(itemId); + } } else { diff --git a/src/progs/manaplus/actions/commands.cpp b/src/progs/manaplus/actions/commands.cpp index dd58c221b..711816eac 100644 --- a/src/progs/manaplus/actions/commands.cpp +++ b/src/progs/manaplus/actions/commands.cpp @@ -1036,9 +1036,11 @@ impHandler(homunEmote) event.action >= InputAction::HOMUN_EMOTE_1 && event.action <= InputAction::HOMUN_EMOTE_48) { - const int emotion = event.action - InputAction::HOMUN_EMOTE_1; if (emoteShortcut != nullptr) + { + const int emotion = event.action - InputAction::HOMUN_EMOTE_1; homunculusHandler->emote(emoteShortcut->getEmote(emotion)); + } if (Game::instance() != nullptr) Game::instance()->setValidSpeed(); return true; diff --git a/src/progs/manaplus/actions/pets.cpp b/src/progs/manaplus/actions/pets.cpp index bb8ec4591..fd8c959f8 100644 --- a/src/progs/manaplus/actions/pets.cpp +++ b/src/progs/manaplus/actions/pets.cpp @@ -102,9 +102,11 @@ impHandler(petEmote) if (event.action >= InputAction::PET_EMOTE_1 && event.action <= InputAction::PET_EMOTE_48) { - const int emotion = event.action - InputAction::PET_EMOTE_1; if (emoteShortcut != nullptr) + { + const int emotion = event.action - InputAction::PET_EMOTE_1; petHandler->emote(emoteShortcut->getEmote(emotion)); + } if (Game::instance() != nullptr) Game::instance()->setValidSpeed(); return true; diff --git a/src/progs/manaplus/gui/viewport.cpp b/src/progs/manaplus/gui/viewport.cpp index 73a8db226..5483b3d0e 100644 --- a/src/progs/manaplus/gui/viewport.cpp +++ b/src/progs/manaplus/gui/viewport.cpp @@ -567,8 +567,6 @@ void Viewport::mousePressed(MouseEvent &event) mMousePressX = event.getX(); mMousePressY = event.getY(); const MouseButtonT eventButton = event.getButton(); - const int pixelX = mMousePressX + mPixelViewX; - const int pixelY = mMousePressY + mPixelViewY; // Right click might open a popup if (eventButton == MouseButton::RIGHT) @@ -601,6 +599,8 @@ void Viewport::mousePressed(MouseEvent &event) // Find the being nearest to the clicked position if (actorManager != nullptr) { + const int pixelX = mMousePressX + mPixelViewX; + const int pixelY = mMousePressY + mPixelViewY; Being *const target = actorManager->findNearestLivingBeing( pixelX, pixelY, 20, ActorType::Monster, nullptr); diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index d3f49fd39..87b6a8a2a 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -493,9 +493,6 @@ void NormalOpenGLGraphics::drawImageCached(const Image *restrict const image, const int srcX = imageRect.x; const int srcY = imageRect.y; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); - const unsigned int vLimit = mMaxVertices * 4; unsigned int vp = mVpCached; @@ -503,6 +500,9 @@ void NormalOpenGLGraphics::drawImageCached(const Image *restrict const image, // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); + const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; @@ -567,14 +567,14 @@ void NormalOpenGLGraphics::drawPatternCached(const Image *restrict const image, if (iw == 0 || ih == 0) return; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); - unsigned int vp = mVpCached; const unsigned int vLimit = mMaxVertices * 4; // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); + const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; @@ -708,9 +708,6 @@ void NormalOpenGLGraphics::drawPatternInline(const Image *restrict const image, if (iw == 0 || ih == 0) return; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); - setColorAlpha(image->mAlpha); #ifdef DEBUG_BIND_TEXTURE @@ -726,6 +723,9 @@ void NormalOpenGLGraphics::drawPatternInline(const Image *restrict const image, // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); + const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; @@ -990,8 +990,6 @@ void NormalOpenGLGraphics::calcPatternInline(ImageVertexes * const int srcX = imageRect.x; const int srcY = imageRect.y; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); const unsigned int vLimit = mMaxVertices * 4; @@ -1001,6 +999,8 @@ void NormalOpenGLGraphics::calcPatternInline(ImageVertexes * // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; @@ -1159,9 +1159,6 @@ void NormalOpenGLGraphics::calcTileVertexesInline(ImageVertexes * const int srcX = imageRect.x; const int srcY = imageRect.y; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); - const unsigned int vLimit = mMaxVertices * 4; OpenGLGraphicsVertexes &ogl = vert->ogl; @@ -1172,6 +1169,9 @@ void NormalOpenGLGraphics::calcTileVertexesInline(ImageVertexes * // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); + const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 81a65d82a..6a97e77e1 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -271,9 +271,6 @@ void NullOpenGLGraphics::drawPatternInline(const Image *restrict const image, if (iw == 0 || ih == 0) return; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); - setColorAlpha(image->mAlpha); #ifdef DEBUG_BIND_TEXTURE @@ -289,6 +286,9 @@ void NullOpenGLGraphics::drawPatternInline(const Image *restrict const image, // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); + const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; @@ -610,9 +610,6 @@ void NullOpenGLGraphics::calcPatternInline(ImageVertexes *restrict const vert, const int srcX = imageRect.x; const int srcY = imageRect.y; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); - const unsigned int vLimit = mMaxVertices * 4; OpenGLGraphicsVertexes &ogl = vert->ogl; @@ -621,6 +618,9 @@ void NullOpenGLGraphics::calcPatternInline(ImageVertexes *restrict const vert, // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); + const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; @@ -816,9 +816,6 @@ void NullOpenGLGraphics::calcTileVertexesInline(ImageVertexes * const int srcX = imageRect.x; const int srcY = imageRect.y; - const float tw = static_cast<float>(image->mTexWidth); - const float th = static_cast<float>(image->mTexHeight); - const unsigned int vLimit = mMaxVertices * 4; OpenGLGraphicsVertexes &ogl = vert->ogl; @@ -829,6 +826,9 @@ void NullOpenGLGraphics::calcTileVertexesInline(ImageVertexes * // Draw a set of textured rectangles if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D) { + const float tw = static_cast<float>(image->mTexWidth); + const float th = static_cast<float>(image->mTexHeight); + const float texX1 = static_cast<float>(srcX) / tw; const float texY1 = static_cast<float>(srcY) / th; diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index e5b13f9bb..e6e3cc323 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -988,12 +988,11 @@ static void loadSoundRef(ItemInfo *const itemInfo, XmlNodeConstPtr node) return; } const std::string event = XML::getProperty(node, "event", ""); - const int delay = XML::getProperty(node, "delay", 0); - const std::map<std::string, ItemSoundEvent::Type>::const_iterator it = mSoundNames.find(event); if (it != mSoundNames.end()) { + const int delay = XML::getProperty(node, "delay", 0); const std::string filename = XmlChildContent(node); itemInfo->addSound((*it).second, filename, delay); } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index d697dc215..e8f1927b8 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -1196,10 +1196,10 @@ Tileset *MapReader::readTileset(XmlNodePtr node, haveAnimation = true; const std::string name = XML::getProperty( propertyNode, "name", ""); - const int value = XML::getProperty( - propertyNode, "value", 0); if (!name.empty()) { + const int value = XML::getProperty( + propertyNode, "value", 0); tileProperties[name] = value; logger->log("Tile Prop of %d \"%s\" = \"%d\"", tileGID, name.c_str(), value); @@ -1241,13 +1241,13 @@ Tileset *MapReader::readTileset(XmlNodePtr node, if (!xmlNameEqual(frameNode, "frame")) continue; - const int tileId = XML::getProperty( - frameNode, "tileid", 0); - const int duration = XML::getProperty( - frameNode, "duration", 0) / 10; - if (set != nullptr) { + const int tileId = XML::getProperty( + frameNode, "tileid", 0); + const int duration = XML::getProperty( + frameNode, "duration", 0) / 10; + ani->addFrame(set->get(tileId), duration, 0, 0, 100); diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp index ff68a7835..233fb709d 100644 --- a/src/resources/memorymanager.cpp +++ b/src/resources/memorymanager.cpp @@ -88,9 +88,9 @@ void MemoryManager::printAllMemory(ChatTab *const tab A_DYECMD_UNUSED) ResourceManager::calcMemory(0); #else // DYECMD - int sz = ResourceManager::calcMemory(0); if (tab != nullptr) { + int sz = ResourceManager::calcMemory(0); // TRANSLATORS: memory usage chat message tab->chatLog(strprintf(_("Calculated memory usage: %d"), sz), ChatMsgType::BY_SERVER, diff --git a/src/resources/sdlgfxblitfunc.cpp b/src/resources/sdlgfxblitfunc.cpp index 6c0b9fa08..9aa45e2e7 100644 --- a/src/resources/sdlgfxblitfunc.cpp +++ b/src/resources/sdlgfxblitfunc.cpp @@ -433,7 +433,7 @@ static int _SDL_gfxBlitRGBACall(const SDL_Surface *const src, return 0; } -int SDLgfxBlitRGBA(SDL_Surface *const src, +int SDLgfxBlitRGBA(const SDL_Surface *const src, const SDL_Rect *const srcrect, SDL_Surface *const dst, const SDL_Rect *const dstrect) diff --git a/src/resources/sdlgfxblitfunc.h b/src/resources/sdlgfxblitfunc.h index b01627dc8..298d04b70 100644 --- a/src/resources/sdlgfxblitfunc.h +++ b/src/resources/sdlgfxblitfunc.h @@ -34,7 +34,7 @@ struct SDL_Rect; // src surface can be any format (most time 32 bit surface with any masks) // dst surface always correct 32 sufraces (shared format for all) -int SDLgfxBlitRGBA(SDL_Surface *const src, +int SDLgfxBlitRGBA(const SDL_Surface *const src, const SDL_Rect *const srcrect, SDL_Surface *const dst, const SDL_Rect *const dstrect); |