summaryrefslogtreecommitdiff
path: root/src/beingmanager.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-06-09 13:37:16 -0600
committerJared Adams <jaxad0127@gmail.com>2010-06-09 15:14:18 -0600
commit35e024b85a5448cba235fa400f9412fd4e289ec0 (patch)
tree58736ebdff483bf7db1398855e514a735ddf075e /src/beingmanager.cpp
parentec980b3c586fc64d02ad02f31497013908056d52 (diff)
downloadmana-35e024b85a5448cba235fa400f9412fd4e289ec0.tar.gz
mana-35e024b85a5448cba235fa400f9412fd4e289ec0.tar.bz2
mana-35e024b85a5448cba235fa400f9412fd4e289ec0.tar.xz
mana-35e024b85a5448cba235fa400f9412fd4e289ec0.zip
Fix dead Beings not being removed using tmwAthena
Rename mWalkTime to mActionTime in Being and have Being manage death. Reviewed-by: 4144
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r--src/beingmanager.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 79591ce6..b2a9f07b 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -25,9 +25,6 @@
#include "gui/viewport.h"
-#include "net/gamehandler.h"
-#include "net/net.h"
-
#include "utils/stringutils.h"
#include "utils/dtor.h"
@@ -83,6 +80,7 @@ Being *BeingManager::createBeing(int id, ActorSprite::Type type, int subtype)
void BeingManager::destroyBeing(Being *being)
{
mBeings.remove(being);
+ mDeleteBeings.remove(being);
viewport->clearHoverBeing(being);
delete being;
}
@@ -158,25 +156,18 @@ const Beings &BeingManager::getAll() const
void BeingManager::logic()
{
- Beings::iterator i = mBeings.begin();
- while (i != mBeings.end())
- {
- Being *being = (*i);
-
- being->logic();
+ Beings::iterator it, it_end;
+ for (it = mBeings.begin(), it_end = mBeings.end(); it != it_end; it++)
+ (*it)->logic();
- if (!being->isAlive() &&
- Net::getGameHandler()->removeDeadBeings() &&
- being->getCurrentFrame() >= 20)
- {
- delete being;
- i = mBeings.erase(i);
- }
- else
- {
- ++i;
- }
+ for (it = mDeleteBeings.begin(), it_end = mDeleteBeings.end();
+ it != it_end; it++)
+ {
+ mBeings.remove(*it);
+ delete *it;
}
+
+ mDeleteBeings.clear();
}
void BeingManager::clear()
@@ -189,6 +180,7 @@ void BeingManager::clear()
delete_all(mBeings);
mBeings.clear();
+ mDeleteBeings.clear();
if (player_node)
mBeings.push_back(player_node);
@@ -277,3 +269,8 @@ void BeingManager::updatePlayerNames()
++i;
}
}
+
+void BeingManager::scheduleDelete(Being *being)
+{
+ mDeleteBeings.push_back(being);
+}