summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/game-server/state.cpp14
2 files changed, 16 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 92b2ba5f..cb1faf23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@
Removed new inventory code, as it was not doing anything.
* src/inventory.cpp: Reverted to the old code, as it was working just
fine.
+ * src/game-server/state.cpp: Added assertions to detect insertion and
+ removal of objects at updating time.
2007-06-28 Philipp Sehmisch <tmw@crushnet.org>
diff --git a/src/game-server/state.cpp b/src/game-server/state.cpp
index c27f9209..645906c1 100644
--- a/src/game-server/state.cpp
+++ b/src/game-server/state.cpp
@@ -277,8 +277,16 @@ void State::informPlayer(MapComposite *map, Character *p)
gameHandler->sendTo(p, itemMsg);
}
+#ifndef NDEBUG
+static bool dbgLockObjects;
+#endif
+
void State::update()
{
+# ifndef NDEBUG
+ dbgLockObjects = true;
+# endif
+
// Update game state (update AI, etc.)
for (Maps::iterator m = maps.begin(), m_end = maps.end(); m != m_end; ++m)
{
@@ -301,6 +309,10 @@ void State::update()
}
}
+# ifndef NDEBUG
+ dbgLockObjects = false;
+# endif
+
// Take care of events that were delayed because of their side effects.
for (DelayedEvents::iterator i = delayedEvents.begin(),
i_end = delayedEvents.end(); i != i_end; ++i)
@@ -359,6 +371,7 @@ void State::update()
void State::insert(Thing *ptr)
{
+ assert(!dbgLockObjects);
int mapId = ptr->getMapId();
MapComposite *map = loadMap(mapId);
if (!map || !map->insert(ptr))
@@ -386,6 +399,7 @@ void State::insert(Thing *ptr)
void State::remove(Thing *ptr)
{
+ assert(!dbgLockObjects);
int mapId = ptr->getMapId();
Maps::iterator m = maps.find(mapId);
assert(m != maps.end());