summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actorspritemanager.cpp9
-rw-r--r--src/actorspritemanager.h7
-rw-r--r--src/being.cpp2
-rw-r--r--src/net/manaserv/beinghandler.cpp2
-rw-r--r--src/net/manaserv/itemhandler.cpp2
-rw-r--r--src/net/tmwa/beinghandler.cpp2
-rw-r--r--src/net/tmwa/itemhandler.cpp2
7 files changed, 19 insertions, 7 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 31b6d8f0..7da9fe10 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -138,7 +138,14 @@ FloorItem *ActorSpriteManager::createItem(int id, int itemId, const Vector &pos)
return floorItem;
}
-void ActorSpriteManager::destroy(ActorSprite *actor)
+void ActorSpriteManager::destroyActor(ActorSprite *actor)
+{
+ mActors.erase(actor);
+ mDeleteActors.erase(actor);
+ delete actor;
+}
+
+void ActorSpriteManager::scheduleDelete(ActorSprite *actor)
{
if (!actor || actor == local_player)
return;
diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h
index 8ff9ff39..76364ea5 100644
--- a/src/actorspritemanager.h
+++ b/src/actorspritemanager.h
@@ -67,10 +67,15 @@ class ActorSpriteManager
FloorItem *createItem(int id, int itemId, const Vector &position);
/**
+ * Immediately destroys the given \a actor.
+ */
+ void destroyActor(ActorSprite *actor);
+
+ /**
* Destroys the given ActorSprite at the end of
* ActorSpriteManager::logic.
*/
- void destroy(ActorSprite *actor);
+ void scheduleDelete(ActorSprite *actor);
/**
* Returns a specific Being, by id;
diff --git a/src/being.cpp b/src/being.cpp
index 62081bb4..21d48ed2 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -892,7 +892,7 @@ void Being::logic()
{
if (getType() != PLAYER)
- actorSpriteManager->destroy(this);
+ actorSpriteManager->scheduleDelete(this);
}
}
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index 52f6dab4..61b4ef81 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -176,7 +176,7 @@ void BeingHandler::handleBeingLeaveMessage(MessageIn &msg)
if (!being)
return;
- actorSpriteManager->destroy(being);
+ actorSpriteManager->destroyActor(being);
}
void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp
index 4e29bb4f..de5b36fa 100644
--- a/src/net/manaserv/itemhandler.cpp
+++ b/src/net/manaserv/itemhandler.cpp
@@ -60,7 +60,7 @@ void ItemHandler::handleMessage(MessageIn &msg)
}
else if (FloorItem *item = actorSpriteManager->findItem(id))
{
- actorSpriteManager->destroy(item);
+ actorSpriteManager->destroyActor(item);
}
}
} break;
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index fb01990a..12c97feb 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -327,7 +327,7 @@ void BeingHandler::handleMessage(MessageIn &msg)
if (msg.readInt8() == 1)
dstBeing->setAction(Being::DEAD);
else
- actorSpriteManager->destroy(dstBeing);
+ actorSpriteManager->destroyActor(dstBeing);
break;
diff --git a/src/net/tmwa/itemhandler.cpp b/src/net/tmwa/itemhandler.cpp
index f05bb899..6ad0ad4c 100644
--- a/src/net/tmwa/itemhandler.cpp
+++ b/src/net/tmwa/itemhandler.cpp
@@ -67,7 +67,7 @@ void ItemHandler::handleMessage(MessageIn &msg)
case SMSG_ITEM_REMOVE:
if (FloorItem *item = actorSpriteManager->findItem(msg.readInt32()))
- actorSpriteManager->destroy(item);
+ actorSpriteManager->destroyActor(item);
break;
}
}