diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-01 18:06:25 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-01 18:06:25 +0000 |
commit | f07dbf97c27aef7630782052ba6021359294cd86 (patch) | |
tree | ee6ae70e936c6e634a920cd215d3a2249c417dbd /src/game-server | |
parent | d44476beb6736faafe6480cfbe527aef7e88427a (diff) | |
download | manaserv-f07dbf97c27aef7630782052ba6021359294cd86.tar.gz manaserv-f07dbf97c27aef7630782052ba6021359294cd86.tar.bz2 manaserv-f07dbf97c27aef7630782052ba6021359294cd86.tar.xz manaserv-f07dbf97c27aef7630782052ba6021359294cd86.zip |
Added assertions to detect insertion and removal of objects at updating time.
Diffstat (limited to 'src/game-server')
-rw-r--r-- | src/game-server/state.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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()); |