summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-04 17:00:09 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-04 17:00:09 +0300
commite668ab141d6b006b790d2b0a8fc515d13b78317e (patch)
treeb4aa71e9a4af62c948183328bbf74c2e1bf4eb84
parent98cc93d2321b9be0a2a5ae6bf67aecf6adcdd2fb (diff)
downloadplus-e668ab141d6b006b790d2b0a8fc515d13b78317e.tar.gz
plus-e668ab141d6b006b790d2b0a8fc515d13b78317e.tar.bz2
plus-e668ab141d6b006b790d2b0a8fc515d13b78317e.tar.xz
plus-e668ab141d6b006b790d2b0a8fc515d13b78317e.zip
Cleanup part list and beinginfo.
-rw-r--r--src/being.cpp2
-rw-r--r--src/client.cpp7
-rw-r--r--src/party.cpp13
-rw-r--r--src/party.h2
-rw-r--r--src/resources/beinginfo.cpp13
-rw-r--r--src/resources/beinginfo.h5
-rw-r--r--src/resources/monsterdb.cpp2
-rw-r--r--src/resources/npcdb.cpp2
8 files changed, 37 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 944a05cb8..35fe6052c 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -183,7 +183,7 @@ std::list<BeingCacheEntry*> beingInfoCache;
// TODO: mWalkTime used by eAthena only
Being::Being(int id, Type type, Uint16 subtype, Map *map):
ActorSprite(id),
- mInfo(BeingInfo::Unknown),
+ mInfo(BeingInfo::unknown),
mActionTime(0),
mEmotion(0), mEmotionTime(0),
mSpeechTime(0),
diff --git a/src/client.cpp b/src/client.cpp
index eaf6cb309..fbebfb2c3 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -25,17 +25,18 @@
#include "chatlog.h"
#include "configuration.h"
+#include "dropshortcut.h"
#include "emoteshortcut.h"
#include "event.h"
#include "game.h"
#include "graphicsvertexes.h"
#include "itemshortcut.h"
-#include "dropshortcut.h"
#include "keyboardconfig.h"
#ifdef USE_OPENGL
#include "openglgraphics.h"
#include "opengl1graphics.h"
#endif
+#include "party.h"
#include "playerrelations.h"
#include "sound.h"
#include "statuseffect.h"
@@ -77,6 +78,7 @@
#include "net/packetcounters.h"
#include "net/worldinfo.h"
+#include "resources/beinginfo.h"
#include "resources/colordb.h"
#include "resources/emotedb.h"
#include "resources/image.h"
@@ -601,6 +603,8 @@ Client::~Client()
logger->log1("Quitting5");
+ BeingInfo::clear();
+
// Shutdown sound
sound.close();
@@ -799,6 +803,7 @@ int Client::exec()
ResourceManager *resman = ResourceManager::getInstance();
if (resman)
resman->cleanOrphans();
+ Party::clearParties();
}
mOldState = mState;
diff --git a/src/party.cpp b/src/party.cpp
index e3ea497ac..f3f787807 100644
--- a/src/party.cpp
+++ b/src/party.cpp
@@ -292,4 +292,15 @@ Party *Party::getParty(short id)
void Party::sort()
{
std::sort(mMembers.begin(), mMembers.end(), partySorter);
-} \ No newline at end of file
+}
+
+void Party::clearParties()
+{
+ PartyMap::iterator it = parties.begin();
+ while (it != parties.end())
+ {
+ delete (*it).second;
+ ++ it;
+ }
+ parties.clear();
+}
diff --git a/src/party.h b/src/party.h
index 581410f7f..466f63a19 100644
--- a/src/party.h
+++ b/src/party.h
@@ -151,6 +151,8 @@ public:
static Party *getParty(short id);
+ static void clearParties();
+
private:
typedef std::map<int, Party*> PartyMap;
static PartyMap parties;
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 80f416b91..d6865449e 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -29,7 +29,8 @@
#include "debug.h"
-BeingInfo *BeingInfo::Unknown = new BeingInfo;
+BeingInfo *BeingInfo::unknown = new BeingInfo;
+Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, "", "");
BeingInfo::BeingInfo():
mName(_("unnamed")),
@@ -102,8 +103,6 @@ const std::string &BeingInfo::getSound(SoundEvent event) const
const Attack *BeingInfo::getAttack(int type) const
{
- // need remove in destructor?
- static Attack *empty = new Attack(SpriteAction::ATTACK, "", "");
Attacks::const_iterator i = mAttacks.find(type);
return (i == mAttacks.end()) ? empty : (*i).second;
@@ -118,3 +117,11 @@ void BeingInfo::addAttack(int id, std::string action,
mAttacks[id] = new Attack(action, particleEffect, missileParticle);
}
+
+void BeingInfo::clear()
+{
+ delete unknown;
+ unknown = 0;
+ delete empty;
+ empty = 0;
+}
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h
index 192a4c3b5..a61483940 100644
--- a/src/resources/beinginfo.h
+++ b/src/resources/beinginfo.h
@@ -72,7 +72,8 @@ typedef std::map<SoundEvent, std::vector<std::string>* > SoundEvents;
class BeingInfo
{
public:
- static BeingInfo *Unknown;
+ static BeingInfo *unknown;
+ static Attack *empty;
BeingInfo();
@@ -146,6 +147,8 @@ class BeingInfo
void setStaticMaxHP(bool n)
{ mStaticMaxHP = n; }
+ static void clear();
+
private:
SpriteDisplay mDisplay;
std::string mName;
diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp
index f0739296a..7a0494fc9 100644
--- a/src/resources/monsterdb.cpp
+++ b/src/resources/monsterdb.cpp
@@ -220,7 +220,7 @@ BeingInfo *MonsterDB::get(int id)
{
logger->log("MonsterDB: Warning, unknown monster ID %d requested",
id);
- return BeingInfo::Unknown;
+ return BeingInfo::unknown;
}
else
{
diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp
index 6f539e17b..49eab5bf2 100644
--- a/src/resources/npcdb.cpp
+++ b/src/resources/npcdb.cpp
@@ -124,7 +124,7 @@ BeingInfo *NPCDB::get(int id)
if (i == mNPCInfos.end())
{
logger->log("NPCDB: Warning, unknown NPC ID %d requested", id);
- return BeingInfo::Unknown;
+ return BeingInfo::unknown;
}
else
{