summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-01 20:04:35 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-01 20:04:35 +0300
commitb8cdabbd20690d57930dce9dda949fca21a6233a (patch)
treeddd3d0a3bb4d83206b92ede95b330430e803e26b
parentab1f66527863c7fcce6c3ccedda0d5560dc063c7 (diff)
downloadplus-b8cdabbd20690d57930dce9dda949fca21a6233a.tar.gz
plus-b8cdabbd20690d57930dce9dda949fca21a6233a.tar.bz2
plus-b8cdabbd20690d57930dce9dda949fca21a6233a.tar.xz
plus-b8cdabbd20690d57930dce9dda949fca21a6233a.zip
Eliminate asserts from most files.
-rw-r--r--src/actorsprite.cpp4
-rw-r--r--src/animatedsprite.cpp4
-rw-r--r--src/being.cpp1
-rw-r--r--src/client.cpp2
-rw-r--r--src/graphics.cpp2
-rw-r--r--src/gui/charselectdialog.cpp5
-rw-r--r--src/gui/popupmenu.cpp2
-rw-r--r--src/gui/quitdialog.cpp15
-rw-r--r--src/gui/widgets/layout.cpp7
-rw-r--r--src/gui/widgets/window.cpp3
-rw-r--r--src/joystick.cpp5
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/net/manaserv/messagehandler.cpp2
-rw-r--r--src/net/tmwa/generalhandler.cpp1
-rw-r--r--src/particlecontainer.cpp2
-rw-r--r--src/resources/imageloader.cpp4
-rw-r--r--src/resources/itemdb.cpp14
-rw-r--r--src/resources/mapreader.cpp6
-rw-r--r--src/resources/resource.cpp2
19 files changed, 26 insertions, 57 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 848e84e0f..2b133eca5 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -477,9 +477,6 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
if (size < TC_SMALL || size >= NUM_TC)
return;
-// assert(size > -1);
-// assert(size < 3);
-
ResourceManager *resman = ResourceManager::getInstance();
ImageSet *currentImageSet = resman->getImageSet(filename, width, height);
@@ -493,7 +490,6 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
for (unsigned int i = 0; i < currentImageSet->size(); ++i)
{
-// anim->addFrame(currentImageSet->get(i), 0,
anim->addFrame(currentImageSet->get(i), 75,
(16 - (currentImageSet->getWidth() / 2)),
(16 - (currentImageSet->getHeight() / 2)),
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 7414c94bc..27be02e36 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -32,8 +32,6 @@
#include "utils/xml.h"
-#include <cassert>
-
#include "debug.h"
AnimatedSprite::AnimatedSprite(SpriteDef *sprite):
@@ -46,8 +44,6 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite):
mAnimation(0),
mFrame(0)
{
-// assert(mSprite);
-
mAlpha = 1.0f;
// Take possession of the sprite
diff --git a/src/being.cpp b/src/being.cpp
index 2d9194c6e..6d35f1df0 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -79,7 +79,6 @@
#include "utils/stringutils.h"
#include "utils/xml.h"
-#include <cassert>
#include <cmath>
#include "debug.h"
diff --git a/src/client.cpp b/src/client.cpp
index 843f7c961..ab176c00b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -114,7 +114,6 @@
#endif
#include <sys/stat.h>
-#include <cassert>
#include <iostream>
#include <fstream>
@@ -260,7 +259,6 @@ Client::Client(const Options &options):
mMouseFocused(true),
mGuiAlpha(1.0f)
{
- assert(!mInstance);
mInstance = this;
logger = new Logger;
diff --git a/src/graphics.cpp b/src/graphics.cpp
index c5dc38b72..abd7341e2 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cassert>
-
#include "graphics.h"
#include "graphicsvertexes.h"
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 28c7a083c..1942ebaeb 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -60,7 +60,6 @@
#include <guichan/font.hpp>
#include <string>
-#include <cassert>
#include "debug.h"
@@ -342,8 +341,8 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
void CharSelectDialog::lock()
{
- assert(!mLocked);
- setLocked(true);
+ if (!mLocked)
+ setLocked(true);
}
void CharSelectDialog::unlock()
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 6db4a408f..0eac0a4f9 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -78,8 +78,6 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <cassert>
-
#include "debug.h"
std::string tradePartnerName("");
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index f66872b5d..04f43fb88 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -41,23 +41,17 @@
#include "utils/gettext.h"
-#include <assert.h>
-
#include "debug.h"
QuitDialog::QuitDialog(QuitDialog** pointerToMe):
Window(_("Quit"), true, NULL), mMyPointer(pointerToMe)
{
-// int width = 200;
-// int height = 120;
-
mForceQuit = new RadioButton(_("Quit"), "quitdialog");
mLogoutQuit = new RadioButton(_("Quit"), "quitdialog");
mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog");
mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog");
mOkButton = new Button(_("OK"), "ok", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
-// setContentSize(width, height);
addKeyListener(this);
@@ -149,10 +143,11 @@ void QuitDialog::action(const gcn::ActionEvent &event)
}
else if (mSwitchCharacter->isSelected())
{
- assert(Client::getState() == STATE_GAME);
-
- Net::getCharHandler()->switchCharacter();
- Client::closeDialogs();
+ if (Client::getState() == STATE_GAME)
+ {
+ Net::getCharHandler()->switchCharacter();
+ Client::closeDialogs();
+ }
}
}
scheduleDelete();
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 382d169dc..a14b416ce 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -68,7 +68,9 @@ LayoutArray &LayoutCell::getArray()
void LayoutCell::reflow(int nx, int ny, int nw, int nh)
{
- assert(mType != NONE);
+ if (mType == NONE)
+ return;
+
nx += mHPadding;
ny += mVPadding;
nw -= 2 * mHPadding;
@@ -81,7 +83,8 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh)
void LayoutCell::computeSizes()
{
- assert(mType == ARRAY);
+ if (mType != ARRAY)
+ return;
std::vector< std::vector< LayoutCell * > >::iterator
i = mArray->mCells.begin();
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 7508d4e4b..0a3779307 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -663,7 +663,8 @@ void Window::setModal(bool modal)
void Window::loadWindowState()
{
const std::string &name = mWindowName;
- assert(!name.empty());
+ if (name.empty())
+ return;
setPosition(config.getValueInt(name + "WinX", mDefaultX),
config.getValueInt(name + "WinY", mDefaultY));
diff --git a/src/joystick.cpp b/src/joystick.cpp
index 8f808a2d1..f45729351 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -24,8 +24,6 @@
#include "joystick.h"
#include "logger.h"
-#include <cassert>
-
#include "debug.h"
int Joystick::joystickCount = 0;
@@ -48,7 +46,8 @@ Joystick::Joystick(int no):
mCalibrating(false),
mEnabled(false)
{
- assert(no < joystickCount);
+ if (no >= joystickCount)
+ no = joystickCount;
mJoystick = SDL_JoystickOpen(no);
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 5192390bc..e9386a5ee 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -78,8 +78,6 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <cassert>
-
#include "mumblemanager.h"
#include "debug.h"
diff --git a/src/net/manaserv/messagehandler.cpp b/src/net/manaserv/messagehandler.cpp
index 7524c95e8..2e9603f19 100644
--- a/src/net/manaserv/messagehandler.cpp
+++ b/src/net/manaserv/messagehandler.cpp
@@ -24,8 +24,6 @@
#include "net/manaserv/network.h"
-#include <cassert>
-
namespace ManaServ
{
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 746cb6620..5ebeb5da9 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -67,7 +67,6 @@
#include "utils/gettext.h"
-#include <assert.h>
#include <list>
#include "debug.h"
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index d00c68a63..70b1e2c84 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cassert>
-
#include "particle.h"
#include "particlecontainer.h"
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index c63d33c00..72a839573 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -29,8 +29,6 @@
#include <guichan/sdl/sdlpixel.hpp>
-#include <cassert>
-
#include "debug.h"
#ifdef free
@@ -79,12 +77,10 @@ int ProxyImage::getHeight() const
return mImage->mBounds.h;
else
return 0;
-// return mSDLImage ? mSDLImage->h : mImage->getHeight();
}
gcn::Color ProxyImage::getPixel(int x, int y)
{
- assert(mSDLImage);
return gcn::SDLgetPixel(mSDLImage, x, y);
}
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 394aa74be..733c12958 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -36,8 +36,6 @@
#include <libxml/tree.h>
-#include <cassert>
-
#include "debug.h"
namespace
@@ -435,7 +433,8 @@ void ItemDB::unload()
bool ItemDB::exists(int id)
{
- assert(mLoaded);
+ if (!mLoaded)
+ return false;
ItemInfos::const_iterator i = mItemInfos.find(id);
@@ -444,7 +443,8 @@ bool ItemDB::exists(int id)
const ItemInfo &ItemDB::get(int id)
{
- assert(mLoaded);
+ if (!mLoaded)
+ load();
ItemInfos::const_iterator i = mItemInfos.find(id);
@@ -459,7 +459,8 @@ const ItemInfo &ItemDB::get(int id)
const ItemInfo &ItemDB::get(const std::string &name)
{
- assert(mLoaded);
+ if (!mLoaded)
+ load();
NamedItemInfos::const_iterator i = mNamedItemInfos.find(normalize(name));
@@ -597,7 +598,7 @@ void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node)
else
{
logger->log("ItemDB: Ignoring unknown sound event '%s'",
- event.c_str());
+ event.c_str());
}
}
@@ -656,7 +657,6 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode)
}
case -2:
{
- logger->log("parse -2");
for_each_xml_child_node(itemNode, replaceNode)
{
if (xmlStrEqual(itemNode->name, BAD_CAST "item"))
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 70c45054f..685d415ff 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -37,7 +37,6 @@
#include "utils/stringutils.h"
#include "utils/xml.h"
-#include <cassert>
#include <iostream>
#include <zlib.h>
@@ -110,7 +109,8 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
}
ret = inflate(&strm, Z_NO_FLUSH);
- assert(ret != Z_STREAM_ERROR);
+ if (ret == Z_STREAM_ERROR)
+ return ret;
switch (ret)
{
@@ -140,7 +140,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
}
}
while (ret != Z_STREAM_END);
- assert(strm.avail_in == 0);
+// assert(strm.avail_in == 0);
outLength = bufferSize - strm.avail_out;
(void) inflateEnd(&strm);
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
index b180712c1..552af06ec 100644
--- a/src/resources/resource.cpp
+++ b/src/resources/resource.cpp
@@ -27,8 +27,6 @@
#include "resources/resourcemanager.h"
-#include <cassert>
-
#include "debug.h"
Resource::~Resource()