summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2009-05-20 15:07:41 +0100
committerDavid Athay <ko2fan@gmail.com>2009-05-20 15:07:41 +0100
commit2e1b6ac8453cd1579908f8712ca9a0069787b82f (patch)
tree38f44262a47cc8789fe70a6dc2a9d118ab76224a /src
parentd75912b44b311a0d6734d558f494f1d2ce1649e2 (diff)
downloadmanaserv-2e1b6ac8453cd1579908f8712ca9a0069787b82f.tar.gz
manaserv-2e1b6ac8453cd1579908f8712ca9a0069787b82f.tar.bz2
manaserv-2e1b6ac8453cd1579908f8712ca9a0069787b82f.tar.xz
manaserv-2e1b6ac8453cd1579908f8712ca9a0069787b82f.zip
Fix crash caused by non-removal of target.
Diffstat (limited to 'src')
-rw-r--r--src/game-server/mapcomposite.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index df252761..448b3e45 100644
--- a/src/game-server/mapcomposite.cpp
+++ b/src/game-server/mapcomposite.cpp
@@ -512,6 +512,23 @@ bool MapComposite::insert(Thing *ptr)
void MapComposite::remove(Thing *ptr)
{
+ for (std::vector<Thing*>::iterator i = mContent->things.begin(),
+ i_end = mContent->things.end(); i != i_end; ++i)
+ {
+ if ((*i)->canFight())
+ {
+ Being *being = static_cast<Being*>(*i);
+ if (being->getTarget() == ptr)
+ {
+ being->setTarget(NULL);
+ }
+ }
+ if (*i == ptr)
+ {
+ i = mContent->things.erase(i);
+ }
+ }
+
if (ptr->isVisible())
{
Actor *obj = static_cast< Actor * >(ptr);
@@ -525,18 +542,6 @@ void MapComposite::remove(Thing *ptr)
mContent->deallocate(static_cast< Being * >(ptr));
}
}
-
- for (std::vector< Thing * >::iterator i = mContent->things.begin(),
- i_end = mContent->things.end(); i != i_end; ++i)
- {
- if (*i == ptr)
- {
- *i = *(i_end - 1);
- mContent->things.pop_back();
- return;
- }
- }
- assert(false);
}
void MapComposite::setMap(Map *m)