[Orxonox-commit 5910] r10569 - code/branches/core7/src/orxonox/gamestates
landauf at orxonox.net
landauf at orxonox.net
Tue Sep 8 22:18:05 CEST 2015
Author: landauf
Date: 2015-09-08 22:18:05 +0200 (Tue, 08 Sep 2015)
New Revision: 10569
Modified:
code/branches/core7/src/orxonox/gamestates/GSLevel.cc
Log:
fixed bug which was introduced in r10563: when unloading in client mode, the Level object was not destroyed because it was still referenced by MeshLodInformation instances (which are not Synchronizables). Now the level is unloaded correctly even in client mode.
Modified: code/branches/core7/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/core7/src/orxonox/gamestates/GSLevel.cc 2015-09-08 20:02:46 UTC (rev 10568)
+++ code/branches/core7/src/orxonox/gamestates/GSLevel.cc 2015-09-08 20:18:05 UTC (rev 10569)
@@ -46,6 +46,7 @@
#include "core/command/ConsoleCommandIncludes.h"
#include "LevelManager.h"
+#include "Level.h"
#include "PlayerManager.h"
#include "GSRoot.h"
@@ -213,15 +214,19 @@
*/
void GSLevel::unloadLevelAsClient()
{
- ObjectList<Synchronisable>::iterator it;
- for(it = ObjectList<Synchronisable>::begin(); it; )
+ for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); )
{
- if( it->getSyncMode() != 0x0 )
+ StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it
+ for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); )
(it++)->destroy();
+ }
+
+ for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); )
+ {
+ if (it->getSyncMode() != 0x0)
+ (it++)->destroy();
else
- {
++it;
- }
}
}
More information about the Orxonox-commit
mailing list