summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/being.cpp2
-rw-r--r--src/commands.cpp7
-rw-r--r--src/gui/popups/popupmenu.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp3
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp9
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/scrollarea.cpp6
-rw-r--r--src/gui/widgets/shoplistbox.cpp2
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp11
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp6
-rw-r--r--src/gui/widgets/tabs/tab.cpp55
-rw-r--r--src/gui/windows/buydialog.cpp7
-rw-r--r--src/gui/windows/changeemaildialog.cpp2
-rw-r--r--src/gui/windows/changepassworddialog.cpp2
-rw-r--r--src/gui/windows/shopwindow.cpp2
-rw-r--r--src/net/tmwa/network.cpp4
-rw-r--r--src/render/mobileopenglgraphics.cpp2
-rw-r--r--src/render/normalopenglgraphics.cpp2
-rw-r--r--src/render/nullopenglgraphics.cpp2
-rw-r--r--src/spellmanager.cpp12
-rw-r--r--src/utils/langs.cpp27
21 files changed, 87 insertions, 80 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 03ed2ad89..7758abd4d 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -1197,7 +1197,7 @@ void Being::setAction(const Action &action, const int attackId)
rotation = 270;
break;
}
- if (Particle::enabled && effectManager && effectId >= 0)
+ if (effectManager && effectId >= 0)
effectManager->trigger(effectId, this, rotation);
}
}
diff --git a/src/commands.cpp b/src/commands.cpp
index 8cb71739b..2119bdb50 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -146,11 +146,8 @@ static void changeRelation(const std::string &args,
if (args.empty())
{
- if (tab)
- {
- // TRANSLATORS: change relation
- tab->chatLog(_("Please specify a name."), BY_SERVER);
- }
+ // TRANSLATORS: change relation
+ tab->chatLog(_("Please specify a name."), BY_SERVER);
return;
}
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index c048e74f1..3655451d3 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1060,7 +1060,7 @@ void PopupMenu::handleLink(const std::string &link,
}
}
}
- else if (link == "whisper" && !mNick.empty() && chatWindow)
+ else if (link == "whisper" && !mNick.empty())
{
if (chatWindow)
{
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 023c3298d..35c647d43 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -610,8 +610,7 @@ int BrowserBox::calcHeight()
else
end = idx2;
- if (mUseLinksAndUserColors ||
- (!mUseLinksAndUserColors && (start == 0)))
+ if (start == 0 || mUseLinksAndUserColors)
{
// Check for color change in format "##x", x = [L,P,0..9]
if (row.find("##", start) == start && row.size() > start + 2)
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 6afa5fae4..8ce8fad17 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -103,9 +103,12 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
return;
BLOCK_START("EmoteShortcutContainer::draw")
- mAlpha = client->getGuiAlpha();
- if (client->getGuiAlpha() != mAlpha && mBackgroundImg)
- mBackgroundImg->setAlpha(mAlpha);
+ if (client->getGuiAlpha() != mAlpha)
+ {
+ if (mBackgroundImg)
+ mBackgroundImg->setAlpha(mAlpha);
+ mAlpha = client->getGuiAlpha();
+ }
Graphics *const g = static_cast<Graphics *const>(graphics);
gcn::Font *const font = getFont();
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index aeae7dd95..87ce28fe0 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -119,11 +119,11 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
return;
}
- mAlpha = client->getGuiAlpha();
if (client->getGuiAlpha() != mAlpha)
{
if (mBackgroundImg)
mBackgroundImg->setAlpha(mAlpha);
+ mAlpha = client->getGuiAlpha();
}
Graphics *const g = static_cast<Graphics*>(graphics);
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 3d79a2a2e..b537dd2ed 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -857,7 +857,7 @@ gcn::Rectangle ScrollArea::getHorizontalBarDimension() const
if (!mHBarVisible)
return gcn::Rectangle(0, 0, 0, 0);
- const int width = (mHBarVisible && mShowButtons) ? mScrollbarWidth : 0;
+ const int width = mShowButtons ? mScrollbarWidth : 0;
if (mVBarVisible)
{
return gcn::Rectangle(width,
@@ -879,7 +879,7 @@ gcn::Rectangle ScrollArea::getVerticalMarkerDimension()
int length, pos;
int height;
- const int h2 = (mVBarVisible && mShowButtons)
+ const int h2 = mShowButtons
? mScrollbarWidth : mMarkerSize / 2;
const gcn::Widget *content;
if (!mWidgets.empty())
@@ -937,7 +937,7 @@ gcn::Rectangle ScrollArea::getHorizontalMarkerDimension()
int length, pos;
int width;
- const int w2 = (mHBarVisible && mShowButtons)
+ const int w2 = mShowButtons
? mScrollbarWidth : mMarkerSize / 2;
const gcn::Widget *content;
if (!mWidgets.empty())
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 263a94d95..d0ff4e746 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -192,7 +192,7 @@ void ShopListBox::setPriceCheck(const bool check)
void ShopListBox::mouseMoved(gcn::MouseEvent &event)
{
- if (!mItemPopup)
+ if (!mItemPopup || !mRowHeight)
return;
if (!mShopItems)
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 648a493b1..6e1db9cbd 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -235,13 +235,10 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event)
{
const int oldIndex = dragDrop.getTag();
const int idx = mNumber * SPELL_SHORTCUT_ITEMS;
- if (spellManager)
- {
- spellManager->swap(idx + index, idx + oldIndex);
- spellManager->save();
- dragDrop.clear();
- dragDrop.deselect();
- }
+ spellManager->swap(idx + index, idx + oldIndex);
+ spellManager->save();
+ dragDrop.clear();
+ dragDrop.deselect();
}
}
else
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index 15b6959a9..571d53b6f 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -178,10 +178,8 @@ void Setup_Joystick::apply()
if (!joystick)
return;
- config.setValue("joystickEnabled",
- joystick ? joystick->isEnabled() : false);
+ config.setValue("joystickEnabled", joystick->isEnabled());
config.setValue("useInactiveJoystick", mUseInactiveCheckBox->isSelected());
- if (joystick)
- joystick->setUseInactive(mUseInactiveCheckBox->isSelected());
+ joystick->setUseInactive(mUseInactiveCheckBox->isSelected());
}
diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp
index 8c25e7b1d..733d030d2 100644
--- a/src/gui/widgets/tabs/tab.cpp
+++ b/src/gui/widgets/tabs/tab.cpp
@@ -215,47 +215,44 @@ void Tab::draw(gcn::Graphics *graphics)
Graphics *const g = static_cast<Graphics*>(graphics);
- if (skin)
+ // draw tab
+ if (openGLMode != RENDER_SAFE_OPENGL)
{
- // draw tab
- if (openGLMode != RENDER_SAFE_OPENGL)
+ const ImageRect &rect = skin->getBorder();
+ if (mRedraw || mode != mMode || g->getRedraw())
{
- const ImageRect &rect = skin->getBorder();
- if (mRedraw || mode != mMode || g->getRedraw())
- {
- mMode = mode;
- mRedraw = false;
- mVertexes->clear();
- g->calcWindow(mVertexes, 0, 0,
- mDimension.width, mDimension.height, rect);
-
- if (mImage)
- {
- const Skin *const skin1 = tabImg[TAB_STANDARD];
- if (skin1)
- {
- const int padding = skin1->getPadding();
- g->calcTile(mVertexes, mImage, padding, padding);
- }
- }
- }
+ mMode = mode;
+ mRedraw = false;
+ mVertexes->clear();
+ g->calcWindow(mVertexes, 0, 0,
+ mDimension.width, mDimension.height, rect);
- g->drawTile(mVertexes);
- }
- else
- {
- g->drawImageRect(0, 0,
- mDimension.width, mDimension.height, skin->getBorder());
if (mImage)
{
const Skin *const skin1 = tabImg[TAB_STANDARD];
if (skin1)
{
const int padding = skin1->getPadding();
- g->drawImage(mImage, padding, padding);
+ g->calcTile(mVertexes, mImage, padding, padding);
}
}
}
+
+ g->drawTile(mVertexes);
+ }
+ else
+ {
+ g->drawImageRect(0, 0,
+ mDimension.width, mDimension.height, skin->getBorder());
+ if (mImage)
+ {
+ const Skin *const skin1 = tabImg[TAB_STANDARD];
+ if (skin1)
+ {
+ const int padding = skin1->getPadding();
+ g->drawImage(mImage, padding, padding);
+ }
+ }
}
drawChildren(graphics);
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 39255a632..b7e49ab3f 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -474,11 +474,8 @@ void BuyDialog::action(const gcn::ActionEvent &event)
{
Net::getBuySellHandler()->sendBuyRequest(mNick,
item, mAmountItems);
- if (tradeWindow)
- {
- tradeWindow->addAutoMoney(mNick,
- item->getPrice() * mAmountItems);
- }
+ tradeWindow->addAutoMoney(mNick,
+ item->getPrice() * mAmountItems);
}
}
}
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
index 61ff7ef3d..a5c47e090 100644
--- a/src/gui/windows/changeemaildialog.cpp
+++ b/src/gui/windows/changeemaildialog.cpp
@@ -161,7 +161,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
{
if (error == 1)
mWrongDataNoticeListener->setTarget(this->mFirstEmailField);
- else if (error == 2)
+ else // if (error == 2)
mWrongDataNoticeListener->setTarget(this->mSecondEmailField);
// TRANSLATORS: change email error header
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
index 365ee19a8..5d520e95f 100644
--- a/src/gui/windows/changepassworddialog.cpp
+++ b/src/gui/windows/changepassworddialog.cpp
@@ -151,7 +151,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
mWrongDataNoticeListener->setTarget(this->mOldPassField);
else if (error == 2)
mWrongDataNoticeListener->setTarget(this->mFirstPassField);
- else if (error == 3)
+ else // if (error == 3)
mWrongDataNoticeListener->setTarget(this->mSecondPassField);
// TRANSLATORS: change password error header
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 082ebddb0..1c854c9fd 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -622,7 +622,7 @@ void ShopWindow::sendMessage(const std::string &nick,
if (config.getBoolValue("hideShopMessages"))
Net::getChatHandler()->privateMessage(nick, data);
- else if (chatWindow)
+ else
chatWindow->addWhisper(nick, data, BY_PLAYER);
}
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 9c1508ccb..515b66c89 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -144,12 +144,12 @@ void Network::dispatchMessages()
SDL_mutexP(mMutexIn);
BLOCK_START("Network::dispatchMessages 2")
const int msgId = readWord(0);
- int len;
+ int len = -1;
if (msgId == SMSG_SERVER_VERSION_RESPONSE)
len = 10;
else if (msgId == SMSG_UPDATE_HOST2)
len = -1;
- else
+ else if (msgId >= 0 && msgId < messagesSize)
len = packet_lengths[msgId];
if (len == -1)
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 972bcc89a..3fec19f15 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -533,7 +533,7 @@ void MobileOpenGLGraphics::calcImagePattern(ImageVertexes *const vert,
const int x, const int y,
const int w, const int h) const
{
- if (!image)
+ if (!image || !vert)
return;
const SDL_Rect &imageRect = image->mBounds;
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index b5abcf30e..d78cad4ad 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -670,7 +670,7 @@ void NormalOpenGLGraphics::calcImagePattern(ImageVertexes* const vert,
const int x, const int y,
const int w, const int h) const
{
- if (!image)
+ if (!image || !vert)
return;
const SDL_Rect &imageRect = image->mBounds;
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index ed3dcd02f..c81b93990 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -573,7 +573,7 @@ void NullOpenGLGraphics::calcImagePattern(ImageVertexes* const vert,
const int x, const int y,
const int w, const int h) const
{
- if (!image)
+ if (!image || !vert)
return;
const SDL_Rect &imageRect = image->mBounds;
diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp
index c8f6fd836..5d465e244 100644
--- a/src/spellmanager.cpp
+++ b/src/spellmanager.cpp
@@ -203,20 +203,20 @@ std::string SpellManager::parseCommand(std::string command,
bool found = false;
- int idx = static_cast<int>(command.find("<TARGET>"));
- if (idx >= 0)
+ size_t idx = command.find("<TARGET>");
+ if (idx != std::string::npos)
{
found = true;
command = replaceAll(command, "<TARGET>", name);
}
- idx = static_cast<int>(command.find("<TARGETID>"));
- if (idx >= 0)
+ idx = command.find("<TARGETID>");
+ if (idx != std::string::npos)
{
found = true;
command = replaceAll(command, "<TARGETID>", id);
}
- idx = static_cast<int>(command.find("<TARGETORSELF>"));
- if (idx >= 0)
+ idx = command.find("<TARGETORSELF>");
+ if (idx != std::string::npos)
{
found = true;
command = replaceAll(command, "<TARGETORSELF>", name2);
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index 6e0390494..7c514ac9c 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -24,18 +24,29 @@
#include "debug.h"
+static char *getLangName()
+{
+ const char *const lang = getenv("LANG");
+ if (lang && strlen(lang) > 1000)
+ return nullptr;
+ return lang;
+}
+
LangVect getLang()
{
LangVect langs;
-
std::string lang = config.getStringValue("lang").c_str();
if (lang.empty())
{
- const char *const lng = getenv("LANG");
+ const char *const lng = getLangName();
if (!lng)
return langs;
lang = lng;
}
+ else if (lang.size() > 1000)
+ {
+ return langs;
+ }
size_t dot = lang.find(".");
if (dot != std::string::npos)
@@ -52,11 +63,15 @@ std::string getLangSimple()
const std::string lang = config.getStringValue("lang").c_str();
if (lang.empty())
{
- const char *const lng = getenv("LANG");
+ const char *const lng = getLangName();
if (!lng)
return "";
return lng;
}
+ else if (lang.size() > 1000)
+ {
+ return "";
+ }
return lang;
}
@@ -65,11 +80,15 @@ std::string getLangShort()
std::string lang = config.getStringValue("lang").c_str();
if (lang.empty())
{
- const char *const lng = getenv("LANG");
+ const char *const lng = getLangName();
if (!lng)
return "";
lang = lng;
}
+ else if (lang.size() > 1000)
+ {
+ return "";
+ }
size_t dot = lang.find(".");
if (dot != std::string::npos)