summaryrefslogtreecommitdiff
path: root/src/being
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
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')
-rw-r--r--src/being/actorsprite.cpp6
-rw-r--r--src/being/being.cpp58
-rw-r--r--src/being/compoundsprite.cpp10
-rw-r--r--src/being/localplayer.cpp7
-rw-r--r--src/being/playerinfo.cpp8
5 files changed, 28 insertions, 61 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index 9c1eeddc7..29fa1290c 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -37,6 +37,7 @@
#include "resources/resourcemanager.h"
#include "utils/checkutils.h"
+#include "utils/delete2.h"
#include "utils/timer.h"
#include "debug.h"
@@ -379,10 +380,7 @@ void ActorSprite::cleanupTargetCursors()
for (int type = TCT_NORMAL; type < NUM_TCT; type++)
{
if (targetCursor[type][size])
- {
- delete targetCursor[type][size];
- targetCursor[type][size] = nullptr;
- }
+ delete2(targetCursor[type][size])
}
}
}
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();
}
diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp
index 63dd32fec..6c159821d 100644
--- a/src/being/compoundsprite.cpp
+++ b/src/being/compoundsprite.cpp
@@ -36,6 +36,7 @@
#include "resources/image.h"
#include "resources/imagehelper.h"
+#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/sdlcheckutils.h"
#include "utils/timer.h"
@@ -252,8 +253,7 @@ void CompoundSprite::removeSprite(const int layer)
if (!mSprites.at(layer))
return;
- delete mSprites.at(layer);
- mSprites.at(layer) = nullptr;
+ delete2(mSprites.at(layer));
mNeedsRedraw = true;
}
@@ -268,8 +268,7 @@ void CompoundSprite::clear()
mNeedsRedraw = true;
delete_all(imagesCache);
imagesCache.clear();
- delete mCacheItem;
- mCacheItem = nullptr;
+ delete2(mCacheItem);
}
void CompoundSprite::ensureSize(size_t layerCount)
@@ -361,8 +360,7 @@ void CompoundSprite::redraw() const
drawSpritesSDL(graphics, posX, posY);
- delete graphics;
- graphics = nullptr;
+ delete2(graphics);
SDL_Surface *const surfaceA = MSDL_CreateRGBSurface(SDL_HWSURFACE,
BUFFER_WIDTH, BUFFER_HEIGHT, 32, rmask, gmask, bmask, amask);
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 2e09f1690..c774b985b 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -69,6 +69,7 @@
#include "resources/db/emotedb.h"
#include "resources/db/weaponsdb.h"
+#include "utils/delete2.h"
#include "utils/gettext.h"
#include "utils/timer.h"
@@ -223,11 +224,9 @@ LocalPlayer::~LocalPlayer()
if (mAwayDialog)
{
soundManager.volumeRestore();
- delete mAwayDialog;
- mAwayDialog = nullptr;
+ delete2(mAwayDialog)
}
- delete mAwayListener;
- mAwayListener = nullptr;
+ delete2(mAwayListener);
}
void LocalPlayer::logic()
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index 728fe786f..12ce1e6d3 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -37,6 +37,8 @@
#include "net/net.h"
#include "net/playerhandler.h"
+#include "utils/delete2.h"
+
#include "debug.h"
namespace PlayerInfo
@@ -422,10 +424,8 @@ bool isTalking()
void gameDestroyed()
{
- delete mInventory;
- mInventory = nullptr;
- delete mEquipment;
- mEquipment = nullptr;
+ delete2(mInventory);
+ delete2(mEquipment);
}
void stateChange(const int state)