summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-20 16:13:56 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-20 16:13:56 +0300
commitb2c6603542af1d5c34a3e252d9454ddf0b21fcc5 (patch)
treeb9863b6532d6d92bd8c8ab29866e87b7e6fe4c24
parent32b055d5738256c4a3e653a3e7b41d86739a3b74 (diff)
downloadmv-b2c6603542af1d5c34a3e252d9454ddf0b21fcc5.tar.gz
mv-b2c6603542af1d5c34a3e252d9454ddf0b21fcc5.tar.bz2
mv-b2c6603542af1d5c34a3e252d9454ddf0b21fcc5.tar.xz
mv-b2c6603542af1d5c34a3e252d9454ddf0b21fcc5.zip
Add missing checks or attribute to other files.
-rw-r--r--src/effectmanager.cpp2
-rw-r--r--src/gui/widgets/guitable.cpp64
-rw-r--r--src/gui/widgets/guitable.h10
-rw-r--r--src/gui/widgets/popup.h2
-rw-r--r--src/gui/widgets/progressbar.h2
-rw-r--r--src/item.cpp2
6 files changed, 30 insertions, 52 deletions
diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp
index 38e29c739..e88dc0a74 100644
--- a/src/effectmanager.cpp
+++ b/src/effectmanager.cpp
@@ -182,7 +182,7 @@ bool EffectManager::trigger(const int id, const int x, const int y,
if (effect.id == id)
{
rValue = true;
- if (!effect.gfx.empty() && particleEngine)
+ if (!effect.gfx.empty())
particleEngine->addEffect(effect.gfx, x, y, rotation);
if (!effect.sfx.empty())
soundManager.playSfx(effect.sfx);
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index 6fa605c8b..0ab245695 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -89,11 +89,8 @@ void GuiTable::setModel(TableModel *const new_model)
mModel = new_model;
installActionListeners();
- if (new_model)
- {
- new_model->installListener(this);
- recomputeDimensions();
- }
+ new_model->installListener(this);
+ recomputeDimensions();
}
void GuiTable::recomputeDimensions()
@@ -139,23 +136,17 @@ int GuiTable::getSelectedColumn() const
int GuiTable::getRowHeight() const
{
- if (mModel)
- return mModel->getRowHeight() + 4; // border
- else
- return 0;
+ return mModel->getRowHeight() + 4; // border
}
int GuiTable::getColumnWidth(const int i) const
{
- if (mModel)
- return mModel->getColumnWidth(i) + 4; // border
- else
- return 0;
+ return mModel->getColumnWidth(i) + 4; // border
}
void GuiTable::setSelectedRow(const int selected)
{
- if (!mModel || !mSelectable)
+ if (!mSelectable)
{
mSelectedRow = -1;
}
@@ -184,27 +175,20 @@ void GuiTable::setSelectedRow(const int selected)
void GuiTable::setSelectedColumn(const int selected)
{
- if (!mModel)
+ const int columns = mModel->getColumns();
+ if ((selected >= columns && mWrappingEnabled) ||
+ (selected < 0 && !mWrappingEnabled))
+ {
+ mSelectedColumn = 0;
+ }
+ else if ((selected >= columns && !mWrappingEnabled) ||
+ (selected < 0 && mWrappingEnabled))
{
- mSelectedColumn = -1;
+ mSelectedColumn = columns - 1;
}
else
{
- const int columns = mModel->getColumns();
- if ((selected >= columns && mWrappingEnabled) ||
- (selected < 0 && !mWrappingEnabled))
- {
- mSelectedColumn = 0;
- }
- else if ((selected >= columns && !mWrappingEnabled) ||
- (selected < 0 && mWrappingEnabled))
- {
- mSelectedColumn = columns - 1;
- }
- else
- {
- mSelectedColumn = selected;
- }
+ mSelectedColumn = selected;
}
}
@@ -216,9 +200,6 @@ void GuiTable::uninstallActionListeners()
void GuiTable::installActionListeners()
{
- if (!mModel)
- return;
-
const int rows = mModel->getRows();
const int columns = mModel->getColumns();
@@ -241,7 +222,7 @@ void GuiTable::installActionListeners()
// -- widget ops
void GuiTable::draw(Graphics* graphics)
{
- if (!mModel || !getRowHeight())
+ if (!getRowHeight())
return;
BLOCK_START("GuiTable::draw")
@@ -347,7 +328,7 @@ void GuiTable::draw(Graphics* graphics)
void GuiTable::safeDraw(Graphics* graphics)
{
- if (!mModel || !getRowHeight())
+ if (!getRowHeight())
return;
BLOCK_START("GuiTable::draw")
@@ -516,7 +497,7 @@ void GuiTable::keyPressed(KeyEvent& event)
// -- MouseListener notifications
void GuiTable::mousePressed(MouseEvent& event)
{
- if (!mModel || !mSelectable)
+ if (!mSelectable)
return;
if (event.getButton() == MouseButton::LEFT)
@@ -611,7 +592,7 @@ int GuiTable::getRowForY(int y) const
if (rowHeight > 0)
row = y / rowHeight;
- if (!mModel || row < 0 || row >= mModel->getRows())
+ if (row < 0 || row >= mModel->getRows())
return -1;
else
return row;
@@ -619,9 +600,6 @@ int GuiTable::getRowForY(int y) const
int GuiTable::getColumnForX(int x) const
{
- if (!mModel)
- return -1;
-
int column;
int delta = 0;
@@ -641,9 +619,9 @@ int GuiTable::getColumnForX(int x) const
void GuiTable::setFocusHandler(FocusHandler *const focusHandler)
{
-// add check for focusHandler. may be need remove it?
+ // add check for focusHandler. may be need remove it?
- if (!mModel || !focusHandler)
+ if (!focusHandler)
return;
Widget::setFocusHandler(focusHandler);
diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h
index 1743f06c6..51905b441 100644
--- a/src/gui/widgets/guitable.h
+++ b/src/gui/widgets/guitable.h
@@ -61,11 +61,6 @@ class GuiTable final : public Widget,
~GuiTable();
/**
- * Retrieves the active table model
- */
- const TableModel *getModel() const A_WARN_UNUSED;
-
- /**
* Sets the table model
*
* Note that actions issued by widgets returned from the model will
@@ -75,6 +70,11 @@ class GuiTable final : public Widget,
*/
void setModel(TableModel *const m);
+ /**
+ * Retrieves the active table model
+ */
+ const TableModel *getModel() const A_WARN_UNUSED RETURNS_NONNULL;
+
void setSelected(const int row, const int column);
int getSelectedRow() const A_WARN_UNUSED;
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 9f043114e..1a9d8d508 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -182,7 +182,7 @@ class Popup notfinal : public Container,
private:
std::string mPopupName; /**< Name of the popup */
- ImageCollection *mVertexes;
+ ImageCollection *mVertexes A_NONNULLPOINTER;
int mMinWidth; /**< Minimum popup width */
int mMinHeight; /**< Minimum popup height */
int mMaxWidth; /**< Maximum popup width */
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index 4b45f1aab..f9a5f1e62 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -145,7 +145,7 @@ class ProgressBar final : public Widget,
Color mBackgroundColorToGo;
std::string mText;
- ImageCollection *mVertexes;
+ ImageCollection *mVertexes A_NONNULLPOINTER;
ProgressColorIdT mProgressPalette;
unsigned int mPadding;
unsigned int mFillPadding;
diff --git a/src/item.cpp b/src/item.cpp
index d0c30371a..a03cb4437 100644
--- a/src/item.cpp
+++ b/src/item.cpp
@@ -178,6 +178,6 @@ void Item::addCard(const int card)
void Item::updateColor()
{
- if (serverFeatures->haveItemColors())
+ if (serverFeatures && serverFeatures->haveItemColors())
setId(mId, ItemColorManager::getColorFromCards(&mCards[0]));
}