summaryrefslogtreecommitdiff
path: root/src/being/being.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-28 00:39:12 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-28 11:04:23 +0300
commit0c35dab0ba366f85b40ef1795125521f1df8c264 (patch)
treedde6abde3288f543ae96a2468b2275af8a03e704 /src/being/being.cpp
parent47cc515695fcd0b16467506e4984d2ec38fad4e4 (diff)
downloadmanaverse-0c35dab0ba366f85b40ef1795125521f1df8c264.tar.gz
manaverse-0c35dab0ba366f85b40ef1795125521f1df8c264.tar.bz2
manaverse-0c35dab0ba366f85b40ef1795125521f1df8c264.tar.xz
manaverse-0c35dab0ba366f85b40ef1795125521f1df8c264.zip
simplify variables cleanup.
Diffstat (limited to 'src/being/being.cpp')
-rw-r--r--src/being/being.cpp58
1 files changed, 15 insertions, 43 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 611263dff..d1a1d8906 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -70,6 +70,7 @@
#include "gui/widgets/tabs/langtab.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/timer.h"
@@ -232,17 +233,11 @@ Being::~Being()
delete [] mSpriteDraw;
mSpriteDraw = nullptr;
- delete mSpeechBubble;
- mSpeechBubble = nullptr;
- delete mDispName;
- mDispName = nullptr;
- delete mText;
- mText = nullptr;
-
- delete mEmotionSprite;
- mEmotionSprite = nullptr;
- delete mAnimationEffect;
- mAnimationEffect = nullptr;
+ delete2(mSpeechBubble);
+ delete2(mDispName);
+ delete2(mText);
+ delete2(mEmotionSprite);
+ delete2(mAnimationEffect);
if (mOwner)
mOwner->unassignPet(this);
@@ -469,7 +464,6 @@ void Being::setSpeech(const std::string &text, const std::string &channel,
if (speech == TEXT_OVERHEAD && userPalette)
{
delete mText;
-
mText = new Text(mSpeech,
getPixelX(), getPixelY() - getHeight(),
Graphics::CENTER,
@@ -821,14 +815,9 @@ void Being::setShowName(const bool doShowName)
mShowName = doShowName;
if (doShowName)
- {
showName();
- }
else
- {
- delete mDispName;
- mDispName = nullptr;
- }
+ delete2(mDispName)
}
void Being::setGuildName(const std::string &name)
@@ -1365,10 +1354,7 @@ void Being::logic()
// Remove text and speechbubbles if speech boxes aren't being used
if (mSpeechTime == 0 && mText)
- {
- delete mText;
- mText = nullptr;
- }
+ delete2(mText)
const int time = tick_time * MILLISECONDS_IN_A_TICK;
if (mEmotionSprite)
@@ -1378,10 +1364,7 @@ void Being::logic()
{
mAnimationEffect->update(time);
if (mAnimationEffect->isTerminated())
- {
- delete mAnimationEffect;
- mAnimationEffect = nullptr;
- }
+ delete2(mAnimationEffect)
}
int frameCount = static_cast<int>(getFrameCount());
@@ -1453,10 +1436,7 @@ void Being::logic()
{
mEmotionTime--;
if (mEmotionTime == 0)
- {
- delete mEmotionSprite;
- mEmotionSprite = nullptr;
- }
+ delete2(mEmotionSprite)
}
ActorSprite::logic();
@@ -1695,8 +1675,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY)
else if (mSpeechTime > 0 && (speech == NAME_IN_BUBBLE ||
speech == NO_NAME_IN_BUBBLE))
{
- delete mText;
- mText = nullptr;
+ delete2(mText)
mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2),
py - getHeight() - (mSpeechBubble->getHeight()));
@@ -1717,9 +1696,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY)
else if (speech == NO_SPEECH)
{
mSpeechBubble->setVisible(false);
-
- delete mText;
- mText = nullptr;
+ delete2(mText)
}
}
@@ -1831,8 +1808,7 @@ void Being::showName()
if (mName.empty())
return;
- delete mDispName;
- mDispName = nullptr;
+ delete2(mDispName);
if (mHideErased && player_relations.getRelation(mName) ==
PlayerRelation::ERASED)
@@ -2967,8 +2943,7 @@ void Being::setEmote(const uint8_t emotion, const int emote_time)
const int emotionIndex = emotion - 1;
if (emotionIndex >= 0 && emotionIndex <= EmoteDB::getLast())
{
- delete mEmotionSprite;
- mEmotionSprite = nullptr;
+ delete2(mEmotionSprite)
const EmoteInfo *const info = EmoteDB::get2(emotionIndex, true);
if (info)
{
@@ -3076,8 +3051,7 @@ void Being::removeSpecialEffect()
mChildParticleEffects.removeLocally(mSpecialParticle);
mSpecialParticle = nullptr;
}
- delete mAnimationEffect;
- mAnimationEffect = nullptr;
+ delete2(mAnimationEffect);
}
void Being::updateAwayEffect()
@@ -3322,9 +3296,7 @@ void Being::setMap(Map *const map)
void Being::removeAllItemsParticles()
{
FOR_EACH (SpriteParticleInfoIter, it, mSpriteParticles)
- {
delete (*it).second;
- }
mSpriteParticles.clear();
}