summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-14 03:23:49 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-14 03:23:49 +0300
commiteedeca17b9867762093e330d68bf21aea9e75fba (patch)
treee1acce6753ffedeff5ea4c80dc3399f6dd0260c9
parent1a04f34a62dc82833dbe994a9f11d543b6a78928 (diff)
downloadplus-eedeca17b9867762093e330d68bf21aea9e75fba.tar.gz
plus-eedeca17b9867762093e330d68bf21aea9e75fba.tar.bz2
plus-eedeca17b9867762093e330d68bf21aea9e75fba.tar.xz
plus-eedeca17b9867762093e330d68bf21aea9e75fba.zip
Add missing checks.
-rw-r--r--src/actorsprite.cpp6
-rw-r--r--src/animatedsprite.cpp8
-rw-r--r--src/being.cpp16
-rw-r--r--src/client.cpp15
4 files changed, 22 insertions, 23 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 90536e364..23f229217 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -66,7 +66,7 @@ ActorSprite::~ActorSprite()
// Notify listeners of the destruction.
for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(),
- end = mActorSpriteListeners.end(); iter != end; ++iter)
+ end = mActorSpriteListeners.end(); iter != end; ++iter)
{
(*iter)->actorSpriteDestroyed(*this);
}
@@ -414,8 +414,6 @@ static const char *cursorType(int type)
default:
case ActorSprite::TCT_NORMAL:
return "normal";
-// default:
-// assert(false);
}
}
@@ -430,8 +428,6 @@ static const char *cursorSize(int size)
default:
case ActorSprite::TC_SMALL:
return "s";
-// default:
-// assert(false);
}
}
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index f58ef62cc..5d5c1ee18 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -268,16 +268,16 @@ unsigned int AnimatedSprite::getFrameCount() const
int AnimatedSprite::getWidth() const
{
- if (mFrame)
- return mFrame->image ? mFrame->image->getWidth() : 0;
+ if (mFrame && mFrame->image)
+ return mFrame->image->getWidth();
else
return 0;
}
int AnimatedSprite::getHeight() const
{
- if (mFrame)
- return mFrame->image ? mFrame->image->getHeight() : 0;
+ if (mFrame && mFrame->image)
+ return mFrame->image->getHeight();
else
return 0;
}
diff --git a/src/being.cpp b/src/being.cpp
index 383d392f8..688e838ee 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -522,7 +522,6 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
}
else if (!amount)
{
-
if (attacker == player_node)
{
// This is intended to be the wrong direction to visually
@@ -581,8 +580,7 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
{
// Show damage number
particleEngine->addTextSplashEffect(damage,
- getPixelX(), getPixelY() - 16,
- color, font, true);
+ getPixelX(), getPixelY() - 16, color, font, true);
}
attacker->updateHit(amount);
@@ -595,15 +593,9 @@ void Being::takeDamage(Being *attacker, int amount, AttackType type)
mDamageTaken += amount;
if (mInfo)
{
- if (attacker)
- {
- sound.playSfx(mInfo->getSound(SOUND_EVENT_HURT),
- attacker->getTileX(), attacker->getTileY());
- }
- else
- {
- sound.playSfx(mInfo->getSound(SOUND_EVENT_HURT));
- }
+ sound.playSfx(mInfo->getSound(SOUND_EVENT_HURT),
+ attacker->getTileX(), attacker->getTileY());
+
if (!mInfo->isStaticMaxHP())
{
if (!mHP && mInfo->getMaxHP() < mDamageTaken)
diff --git a/src/client.cpp b/src/client.cpp
index 4bd321712..2e44b94b3 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -673,7 +673,8 @@ int Client::exec()
while (get_elapsed_time(lastTickTime) > 0)
{
- gui->logic();
+ if (gui)
+ gui->logic();
if (game)
game->logic();
@@ -689,7 +690,8 @@ int Client::exec()
if (SDL_GetAppState() & SDL_APPACTIVE)
{
frame_count++;
- gui->draw();
+ if (gui)
+ gui->draw();
graphics->updateScreen();
// logger->log("active");
}
@@ -745,8 +747,14 @@ int Client::exec()
else if (mOldState == STATE_START ||
(mOldState == STATE_GAME && mState != STATE_GAME))
{
+ if (!gui)
+ break;
+
gcn::Container *top = static_cast<gcn::Container*>(gui->getTop());
+ if (!top)
+ break;
+
mDesktop = new Desktop;
top->add(mDesktop);
mSetupButton = new Button(_("Setup"), "Setup", this);
@@ -1635,6 +1643,9 @@ void Client::initScreenshotDir()
void Client::accountLogin(LoginData *loginData)
{
+ if (!loginData)
+ return;
+
logger->log("Username is %s", loginData->username.c_str());
// Send login infos