From c6c4eef4e49bb4de90845408af9f642a1a4e224b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 17 Aug 2012 16:34:36 +0300 Subject: Improve size calculations. --- src/gui/widgets/emoteshortcutcontainer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gui/widgets/emoteshortcutcontainer.cpp') diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 17d825909..2347edd0c 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -131,17 +131,18 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) graphics->setColor(getForegroundColor()); g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT); } + unsigned sz = mEmoteImg.size(); for (unsigned i = 0; i < mMaxItems; i++) { - if (i < mEmoteImg.size() && mEmoteImg[i] && mEmoteImg[i]->sprite) + if (i < sz && mEmoteImg[i] && mEmoteImg[i]->sprite) { mEmoteImg[i]->sprite->draw(g, (i % mGridWidth) * mBoxWidth + 2, (i / mGridWidth) * mBoxHeight + 10); } } - if (mEmoteMoved && mEmoteMoved < static_cast( - mEmoteImg.size()) + 1 && mEmoteMoved > 0) + if (mEmoteMoved && mEmoteMoved < static_cast(sz) + 1 + && mEmoteMoved > 0) { // Draw the emote image being dragged by the cursor. const EmoteSprite* sprite = mEmoteImg[mEmoteMoved - 1]; -- cgit v1.2.3-70-g09d2