[Orxonox-commit 5965] r10624 - in code/trunk: . cmake cmake/tools data/levels src src/libraries/core src/libraries/core/class src/libraries/core/command src/libraries/core/config src/libraries/core/input src/libraries/core/object src/libraries/network src/libraries/network/packet src/libraries/network/synchronisable src/libraries/tools src/libraries/tools/interfaces src/libraries/util src/libraries/util/output src/modules/designtools src/modules/docking src/modules/dodgerace src/modules/gametypes src/modules/invader src/modules/jump src/modules/mini4dgame src/modules/notifications src/modules/objects src/modules/objects/collisionshapes src/modules/objects/triggers src/modules/overlays/hud src/modules/pickup src/modules/pickup/items src/modules/pong src/modules/questsystem src/modules/questsystem/effects src/modules/tetris src/modules/towerdefense src/modules/weapons/projectiles src/orxonox src/orxonox/chat src/orxonox/collisionshapes src/orxonox/controllers src/orxonox/gamestates src/orxonox/gametypes src/orxonox/infos src/orxonox/interfaces src/orxonox/items src/orxonox/overlays src/orxonox/sound src/orxonox/weaponsystem src/orxonox/worldentities src/orxonox/worldentities/pawns test/core test/core/class test/core/command test/core/object test/util test/util/output

landauf at orxonox.net landauf at orxonox.net
Sun Oct 4 21:12:23 CEST 2015


Author: landauf
Date: 2015-10-04 21:12:21 +0200 (Sun, 04 Oct 2015)
New Revision: 10624

Added:
   code/trunk/src/libraries/core/ApplicationPaths.cc
   code/trunk/src/libraries/core/ApplicationPaths.h
   code/trunk/src/libraries/core/ConfigurablePaths.cc
   code/trunk/src/libraries/core/ConfigurablePaths.h
   code/trunk/src/libraries/core/CoreConfig.cc
   code/trunk/src/libraries/core/CoreConfig.h
   code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc
   code/trunk/src/libraries/core/CoreStaticInitializationHandler.h
   code/trunk/src/libraries/core/GameConfig.cc
   code/trunk/src/libraries/core/GameConfig.h
   code/trunk/src/libraries/core/UpdateListener.cc
   code/trunk/src/libraries/core/UpdateListener.h
   code/trunk/src/libraries/core/command/ConsoleCommandIncludes.cc
   code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h
   code/trunk/src/libraries/core/command/ConsoleCommandManager.cc
   code/trunk/src/libraries/core/command/ConsoleCommandManager.h
   code/trunk/src/libraries/core/commandline/
   code/trunk/src/libraries/core/module/
   code/trunk/src/libraries/core/object/DestroyLaterManager.cc
   code/trunk/src/libraries/core/object/DestroyLaterManager.h
   code/trunk/src/libraries/core/object/StrongPtr.h
   code/trunk/src/libraries/core/singleton/
   code/trunk/src/libraries/network/NetworkFunctionIncludes.cc
   code/trunk/src/libraries/network/NetworkFunctionIncludes.h
   code/trunk/src/libraries/network/NetworkFunctionManager.cc
   code/trunk/src/libraries/network/NetworkFunctionManager.h
   code/trunk/src/libraries/network/NetworkStaticInitializationHandler.cc
   code/trunk/src/libraries/network/NetworkStaticInitializationHandler.h
   code/trunk/test/core/class/IdentifierNestedClassHierarchyTest.cc
   code/trunk/test/core/object/StrongPtrTest.cc
   code/trunk/test/core/singleton/
Removed:
   code/trunk/src/libraries/core/DynLib.cc
   code/trunk/src/libraries/core/DynLib.h
   code/trunk/src/libraries/core/DynLibManager.cc
   code/trunk/src/libraries/core/DynLibManager.h
   code/trunk/src/libraries/core/PathConfig.cc
   code/trunk/src/libraries/core/PathConfig.h
   code/trunk/src/libraries/core/config/CommandLineParser.cc
   code/trunk/src/libraries/core/config/CommandLineParser.h
   code/trunk/src/libraries/core/object/SmartPtr.h
   code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.cc
   code/trunk/src/libraries/util/Scope.cc
   code/trunk/src/libraries/util/Scope.h
   code/trunk/src/libraries/util/ScopedSingletonManager.cc
   code/trunk/src/libraries/util/ScopedSingletonManager.h
   code/trunk/src/orxonox/PawnManager.cc
   code/trunk/src/orxonox/PawnManager.h
   code/trunk/src/orxonox/ShipPartManager.cc
   code/trunk/src/orxonox/ShipPartManager.h
   code/trunk/test/core/object/SmartPtrTest.cc
   code/trunk/test/util/ScopeTest.cc
Modified:
   code/trunk/
   code/trunk/CMakeLists.txt
   code/trunk/cmake/InstallConfig.cmake
   code/trunk/cmake/tools/FindVLD.cmake
   code/trunk/cmake/tools/TargetUtilities.cmake
   code/trunk/data/levels/4Dtest.oxw
   code/trunk/data/levels/DodgeRace.oxw
   code/trunk/data/levels/Invaders.oxw
   code/trunk/data/levels/Spacerace2.oxw
   code/trunk/data/levels/SurfaceRacePresentation.oxw
   code/trunk/data/levels/jump.oxw
   code/trunk/data/levels/pong.oxw
   code/trunk/data/levels/presentationHS12.oxw
   code/trunk/data/levels/spaceRace.oxw
   code/trunk/data/levels/surfaceRace.oxw
   code/trunk/data/levels/tetris.oxw
   code/trunk/data/levels/towerDefense.oxw
   code/trunk/src/CMakeLists.txt
   code/trunk/src/SpecialConfig.h.in
   code/trunk/src/libraries/core/BaseObject.cc
   code/trunk/src/libraries/core/BaseObject.h
   code/trunk/src/libraries/core/CMakeLists.txt
   code/trunk/src/libraries/core/ClassTreeMask.cc
   code/trunk/src/libraries/core/Core.cc
   code/trunk/src/libraries/core/Core.h
   code/trunk/src/libraries/core/CoreIncludes.h
   code/trunk/src/libraries/core/CorePrereqs.h
   code/trunk/src/libraries/core/GUIManager.cc
   code/trunk/src/libraries/core/Game.cc
   code/trunk/src/libraries/core/Game.h
   code/trunk/src/libraries/core/GraphicsManager.cc
   code/trunk/src/libraries/core/GraphicsManager.h
   code/trunk/src/libraries/core/Language.cc
   code/trunk/src/libraries/core/Language.h
   code/trunk/src/libraries/core/Loader.cc
   code/trunk/src/libraries/core/Loader.h
   code/trunk/src/libraries/core/Namespace.cc
   code/trunk/src/libraries/core/ViewportEventListener.cc
   code/trunk/src/libraries/core/WindowEventListener.cc
   code/trunk/src/libraries/core/XMLNameListener.cc
   code/trunk/src/libraries/core/XMLPort.cc
   code/trunk/src/libraries/core/class/Identifiable.cc
   code/trunk/src/libraries/core/class/Identifier.cc
   code/trunk/src/libraries/core/class/Identifier.h
   code/trunk/src/libraries/core/class/IdentifierManager.cc
   code/trunk/src/libraries/core/class/IdentifierManager.h
   code/trunk/src/libraries/core/class/OrxonoxInterface.cc
   code/trunk/src/libraries/core/class/Super.h
   code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
   code/trunk/src/libraries/core/command/CMakeLists.txt
   code/trunk/src/libraries/core/command/CommandEvaluation.cc
   code/trunk/src/libraries/core/command/CommandExecutor.cc
   code/trunk/src/libraries/core/command/ConsoleCommand.cc
   code/trunk/src/libraries/core/command/ConsoleCommand.h
   code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
   code/trunk/src/libraries/core/command/IRC.cc
   code/trunk/src/libraries/core/command/Shell.cc
   code/trunk/src/libraries/core/command/Shell.h
   code/trunk/src/libraries/core/command/TclBind.cc
   code/trunk/src/libraries/core/command/TclThreadManager.cc
   code/trunk/src/libraries/core/config/CMakeLists.txt
   code/trunk/src/libraries/core/config/ConfigFile.cc
   code/trunk/src/libraries/core/config/Configurable.cc
   code/trunk/src/libraries/core/config/SettingsConfigFile.cc
   code/trunk/src/libraries/core/input/InputManager.cc
   code/trunk/src/libraries/core/input/JoyStick.cc
   code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc
   code/trunk/src/libraries/core/input/KeyBinder.cc
   code/trunk/src/libraries/core/input/KeyBinderManager.cc
   code/trunk/src/libraries/core/input/KeyDetector.cc
   code/trunk/src/libraries/core/input/Mouse.cc
   code/trunk/src/libraries/core/object/CMakeLists.txt
   code/trunk/src/libraries/core/object/Context.cc
   code/trunk/src/libraries/core/object/Context.h
   code/trunk/src/libraries/core/object/Destroyable.cc
   code/trunk/src/libraries/core/object/Destroyable.h
   code/trunk/src/libraries/core/object/Iterator.h
   code/trunk/src/libraries/core/object/IteratorBase.h
   code/trunk/src/libraries/core/object/Listable.cc
   code/trunk/src/libraries/core/object/ObjectList.h
   code/trunk/src/libraries/core/object/ObjectListIterator.h
   code/trunk/src/libraries/core/object/WeakPtr.h
   code/trunk/src/libraries/network/CMakeLists.txt
   code/trunk/src/libraries/network/Client.cc
   code/trunk/src/libraries/network/ClientConnectionListener.cc
   code/trunk/src/libraries/network/FunctionCall.cc
   code/trunk/src/libraries/network/FunctionCall.h
   code/trunk/src/libraries/network/FunctionCallManager.cc
   code/trunk/src/libraries/network/FunctionCallManager.h
   code/trunk/src/libraries/network/Host.cc
   code/trunk/src/libraries/network/LANDiscovery.cc
   code/trunk/src/libraries/network/MasterServer.cc
   code/trunk/src/libraries/network/NetworkFunction.cc
   code/trunk/src/libraries/network/NetworkFunction.h
   code/trunk/src/libraries/network/NetworkPrereqs.h
   code/trunk/src/libraries/network/WANDiscoverable.cc
   code/trunk/src/libraries/network/WANDiscovery.cc
   code/trunk/src/libraries/network/packet/FunctionCalls.cc
   code/trunk/src/libraries/network/packet/FunctionCalls.h
   code/trunk/src/libraries/network/packet/FunctionIDs.cc
   code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
   code/trunk/src/libraries/network/synchronisable/Serialise.h
   code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
   code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
   code/trunk/src/libraries/tools/ParticleInterface.cc
   code/trunk/src/libraries/tools/ParticleInterface.h
   code/trunk/src/libraries/tools/ResourceLocation.cc
   code/trunk/src/libraries/tools/Timer.cc
   code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
   code/trunk/src/libraries/util/CMakeLists.txt
   code/trunk/src/libraries/util/SharedPtr.h
   code/trunk/src/libraries/util/Singleton.h
   code/trunk/src/libraries/util/UtilPrereqs.h
   code/trunk/src/libraries/util/output/OutputDefinitions.h
   code/trunk/src/modules/designtools/ScreenshotManager.cc
   code/trunk/src/modules/designtools/SkyboxGenerator.cc
   code/trunk/src/modules/docking/Dock.cc
   code/trunk/src/modules/docking/DockingAnimation.cc
   code/trunk/src/modules/docking/DockingEffect.cc
   code/trunk/src/modules/dodgerace/CMakeLists.txt
   code/trunk/src/modules/dodgerace/DodgeRace.cc
   code/trunk/src/modules/dodgerace/DodgeRace.h
   code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc
   code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h
   code/trunk/src/modules/dodgerace/DodgeRaceCube.cc
   code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc
   code/trunk/src/modules/dodgerace/DodgeRaceShip.cc
   code/trunk/src/modules/dodgerace/DodgeRaceShip.h
   code/trunk/src/modules/gametypes/CMakeLists.txt
   code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc
   code/trunk/src/modules/gametypes/SpaceRaceManager.cc
   code/trunk/src/modules/invader/CMakeLists.txt
   code/trunk/src/modules/invader/Invader.cc
   code/trunk/src/modules/invader/Invader.h
   code/trunk/src/modules/invader/InvaderCenterPoint.cc
   code/trunk/src/modules/invader/InvaderCenterPoint.h
   code/trunk/src/modules/invader/InvaderEnemy.cc
   code/trunk/src/modules/invader/InvaderEnemy.h
   code/trunk/src/modules/invader/InvaderHUDinfo.cc
   code/trunk/src/modules/invader/InvaderShip.cc
   code/trunk/src/modules/invader/InvaderShip.h
   code/trunk/src/modules/invader/InvaderWeapon.cc
   code/trunk/src/modules/jump/CMakeLists.txt
   code/trunk/src/modules/jump/JumpCenterpoint.cc
   code/trunk/src/modules/jump/JumpCenterpoint.h
   code/trunk/src/modules/jump/JumpEnemy.cc
   code/trunk/src/modules/jump/JumpEnemy.h
   code/trunk/src/modules/jump/JumpItem.cc
   code/trunk/src/modules/jump/JumpItem.h
   code/trunk/src/modules/jump/JumpPlatform.cc
   code/trunk/src/modules/jump/JumpPlatform.h
   code/trunk/src/modules/jump/JumpProjectile.cc
   code/trunk/src/modules/jump/JumpProjectile.h
   code/trunk/src/modules/jump/JumpScore.cc
   code/trunk/src/modules/mini4dgame/CMakeLists.txt
   code/trunk/src/modules/mini4dgame/Mini4Dgame.cc
   code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc
   code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h
   code/trunk/src/modules/notifications/NotificationDispatcher.cc
   code/trunk/src/modules/notifications/NotificationManager.cc
   code/trunk/src/modules/objects/Planet.cc
   code/trunk/src/modules/objects/Planet.h
   code/trunk/src/modules/objects/Script.cc
   code/trunk/src/modules/objects/SpaceBoundaries.cc
   code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc
   code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
   code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h
   code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
   code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
   code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc
   code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h
   code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
   code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h
   code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc
   code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h
   code/trunk/src/modules/objects/triggers/CheckPoint.cc
   code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
   code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
   code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
   code/trunk/src/modules/objects/triggers/Trigger.cc
   code/trunk/src/modules/overlays/hud/HUDHealthBar.h
   code/trunk/src/modules/overlays/hud/HUDNavigation.cc
   code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc
   code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc
   code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc
   code/trunk/src/modules/pickup/CollectiblePickup.cc
   code/trunk/src/modules/pickup/PickupManager.cc
   code/trunk/src/modules/pickup/PickupManager.h
   code/trunk/src/modules/pickup/PickupSpawner.cc
   code/trunk/src/modules/pickup/items/ShrinkPickup.cc
   code/trunk/src/modules/pong/CMakeLists.txt
   code/trunk/src/modules/pong/PongCenterpoint.cc
   code/trunk/src/modules/pong/PongCenterpoint.h
   code/trunk/src/modules/pong/PongScore.cc
   code/trunk/src/modules/questsystem/Quest.cc
   code/trunk/src/modules/questsystem/QuestEffect.cc
   code/trunk/src/modules/questsystem/QuestManager.cc
   code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
   code/trunk/src/modules/tetris/CMakeLists.txt
   code/trunk/src/modules/tetris/Tetris.cc
   code/trunk/src/modules/tetris/Tetris.h
   code/trunk/src/modules/tetris/TetrisBrick.cc
   code/trunk/src/modules/tetris/TetrisCenterpoint.cc
   code/trunk/src/modules/tetris/TetrisCenterpoint.h
   code/trunk/src/modules/tetris/TetrisScore.cc
   code/trunk/src/modules/towerdefense/CMakeLists.txt
   code/trunk/src/modules/towerdefense/TDCoordinate.h
   code/trunk/src/modules/towerdefense/TowerDefense.cc
   code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
   code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
   code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
   code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
   code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
   code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc
   code/trunk/src/orxonox/CMakeLists.txt
   code/trunk/src/orxonox/CameraManager.cc
   code/trunk/src/orxonox/Level.cc
   code/trunk/src/orxonox/Level.h
   code/trunk/src/orxonox/LevelManager.cc
   code/trunk/src/orxonox/Main.cc
   code/trunk/src/orxonox/MoodManager.cc
   code/trunk/src/orxonox/OrxonoxPrereqs.h
   code/trunk/src/orxonox/PlayerManager.cc
   code/trunk/src/orxonox/Radar.cc
   code/trunk/src/orxonox/Scene.cc
   code/trunk/src/orxonox/Scene.h
   code/trunk/src/orxonox/Test.cc
   code/trunk/src/orxonox/chat/ChatHistory.cc
   code/trunk/src/orxonox/chat/ChatHistory.h
   code/trunk/src/orxonox/chat/ChatInputHandler.cc
   code/trunk/src/orxonox/chat/ChatManager.cc
   code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
   code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
   code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
   code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h
   code/trunk/src/orxonox/controllers/ArtificialController.cc
   code/trunk/src/orxonox/controllers/FormationController.cc
   code/trunk/src/orxonox/controllers/HumanController.cc
   code/trunk/src/orxonox/controllers/HumanController.h
   code/trunk/src/orxonox/controllers/NewHumanController.cc
   code/trunk/src/orxonox/gamestates/GSClient.cc
   code/trunk/src/orxonox/gamestates/GSLevel.cc
   code/trunk/src/orxonox/gamestates/GSLevel.h
   code/trunk/src/orxonox/gamestates/GSMainMenu.cc
   code/trunk/src/orxonox/gamestates/GSRoot.cc
   code/trunk/src/orxonox/gamestates/GSServer.cc
   code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
   code/trunk/src/orxonox/gametypes/Dynamicmatch.h
   code/trunk/src/orxonox/gametypes/Gametype.cc
   code/trunk/src/orxonox/gametypes/Gametype.h
   code/trunk/src/orxonox/gametypes/Mission.cc
   code/trunk/src/orxonox/infos/GametypeInfo.cc
   code/trunk/src/orxonox/infos/HumanPlayer.cc
   code/trunk/src/orxonox/infos/HumanPlayer.h
   code/trunk/src/orxonox/infos/PlayerInfo.cc
   code/trunk/src/orxonox/infos/PlayerInfo.h
   code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
   code/trunk/src/orxonox/interfaces/NotificationListener.cc
   code/trunk/src/orxonox/interfaces/PickupCarrier.cc
   code/trunk/src/orxonox/interfaces/PickupListener.cc
   code/trunk/src/orxonox/interfaces/Pickupable.cc
   code/trunk/src/orxonox/interfaces/Pickupable.h
   code/trunk/src/orxonox/interfaces/PlayerTrigger.h
   code/trunk/src/orxonox/interfaces/RadarViewable.cc
   code/trunk/src/orxonox/interfaces/RadarViewable.h
   code/trunk/src/orxonox/items/ShipPart.cc
   code/trunk/src/orxonox/items/ShipPart.h
   code/trunk/src/orxonox/overlays/InGameConsole.cc
   code/trunk/src/orxonox/overlays/InGameConsole.h
   code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
   code/trunk/src/orxonox/overlays/OverlayGroup.cc
   code/trunk/src/orxonox/overlays/OverlayGroup.h
   code/trunk/src/orxonox/sound/AmbientSound.cc
   code/trunk/src/orxonox/sound/BaseSound.cc
   code/trunk/src/orxonox/sound/SoundBuffer.h
   code/trunk/src/orxonox/sound/SoundManager.cc
   code/trunk/src/orxonox/sound/SoundManager.h
   code/trunk/src/orxonox/sound/WorldAmbientSound.cc
   code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
   code/trunk/src/orxonox/worldentities/ControllableEntity.cc
   code/trunk/src/orxonox/worldentities/ControllableEntity.h
   code/trunk/src/orxonox/worldentities/WorldEntity.cc
   code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc
   code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
   code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
   code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
   code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
   code/trunk/test/core/CMakeLists.txt
   code/trunk/test/core/class/IdentifiableTest.cc
   code/trunk/test/core/class/IdentifierClassHierarchyTest.cc
   code/trunk/test/core/class/IdentifierExternalClassHierarchyTest.cc
   code/trunk/test/core/class/IdentifierSimpleClassHierarchyTest.cc
   code/trunk/test/core/class/IdentifierTest.cc
   code/trunk/test/core/class/OrxonoxClassTest.cc
   code/trunk/test/core/class/OrxonoxInterfaceTest.cc
   code/trunk/test/core/class/SubclassIdentifierTest.cc
   code/trunk/test/core/class/SuperTest.cc
   code/trunk/test/core/command/CommandTest.cc
   code/trunk/test/core/object/ClassFactoryTest.cc
   code/trunk/test/core/object/ContextTest.cc
   code/trunk/test/core/object/IteratorTest.cc
   code/trunk/test/core/object/ListableTest.cc
   code/trunk/test/core/object/ObjectListIteratorTest.cc
   code/trunk/test/core/object/WeakPtrTest.cc
   code/trunk/test/util/CMakeLists.txt
   code/trunk/test/util/output/ConsoleWriterTest.cc
   code/trunk/test/util/output/LogWriterTest.cc
   code/trunk/test/util/output/MemoryWriterTest.cc
   code/trunk/test/util/output/OutputManagerTest.cc
Log:
merged branch core7 back to trunk


Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/ParticleEffectsFS15:10309-10612
/code/branches/Racingbot:9388-9513
/code/branches/SciptableControllerFS15:10308-10613
/code/branches/ScriptableController:9999-10075
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/clangenb:10385-10609
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/core6:9552-9666
/code/branches/core7:10350
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/formationFS15:10320-10610
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudHS14:10083-10241
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/keckslevelHS14:10082-10222
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/leveljoemeHS14:10087-10223
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/minigame4DHS14:10081-10230
/code/branches/miniprojects:2754-2824
/code/branches/modularships:9994-10071
/code/branches/multiplayerFS15:10324-10611
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/pickupsFS14:10000-10259
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationFS14:10069-10215
/code/branches/presentationFS15:10499
/code/branches/presentationFS15merge:10595-10621
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/presentationHS14merge:10222-10257
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/sfxThilo:9691-9917
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/storymodeHS14:10085-10254
/code/branches/surfaceRace:9028-9199
/code/branches/surfaceraceHS14:10080-10236
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/towerdefenseFS15:10283-10614
/code/branches/towerdefenseHS14:10086-10247
/code/branches/turret:9380-9501
/code/branches/turretFS14:9998-10070
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weaponFS15:10302-10615
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
/code/branches/weaponupdateHS14:10084-10237
   + /code/branches/ParticleEffectsFS15:10309-10612
/code/branches/Racingbot:9388-9513
/code/branches/SciptableControllerFS15:10308-10613
/code/branches/ScriptableController:9999-10075
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/clangenb:10385-10609
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/core6:9552-9666
/code/branches/core7:10328-10623
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/formationFS15:10320-10610
/code/branches/formationupdate:9580-9624
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudHS14:10083-10241
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/invaders:9694-9896
/code/branches/ipv6:7293-7458
/code/branches/keckslevelHS14:10082-10222
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/levelElias:9697-9921
/code/branches/levelKaan:9695-9921
/code/branches/levelMichael:9696-9921
/code/branches/leveljoemeHS14:10087-10223
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/libs:9668-9674
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/minigame4DHS14:10081-10230
/code/branches/miniprojects:2754-2824
/code/branches/modularships:9994-10071
/code/branches/multiplayerFS15:10324-10611
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/pickupsFS14:10000-10259
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationFS14:10069-10215
/code/branches/presentationFS15:10499
/code/branches/presentationFS15merge:10595-10621
/code/branches/presentationHS12:9481-9525
/code/branches/presentationHS13:9891-9938
/code/branches/presentationHS14merge:10222-10257
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/radarDreiD:9690-9901
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/sfxThilo:9691-9917
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/spacestationentry:9699-9905
/code/branches/steering:5949-6091,8140-8595
/code/branches/storymodeHS14:10085-10254
/code/branches/surfaceRace:9028-9199
/code/branches/surfaceraceHS14:10080-10236
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/towerdefenseFS15:10283-10614
/code/branches/towerdefenseHS14:10086-10247
/code/branches/turret:9380-9501
/code/branches/turretFS14:9998-10070
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weaponFS15:10302-10615
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
/code/branches/weaponupdateHS14:10084-10237

Modified: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -64,6 +64,7 @@
 SET(DEFAULT_LIBRARY_PATH lib)
 SET(DEFAULT_ARCHIVE_PATH lib/static)
 SET(DEFAULT_MODULE_PATH  lib/modules)
+SET(DEFAULT_PLUGIN_PATH  lib/plugins)
 SET(DEFAULT_DOC_PATH     doc)
 SET(DEFAULT_DATA_PATH    data)
 SET(DEFAULT_CONFIG_PATH  config)
@@ -75,14 +76,28 @@
 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_LIBRARY_PATH})
 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${DEFAULT_ARCHIVE_PATH})
 SET(CMAKE_MODULE_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_MODULE_PATH})
+SET(CMAKE_PLUGIN_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_PLUGIN_PATH})
 SET(CMAKE_DOC_OUTPUT_DIRECTORY     ${CMAKE_BINARY_DIR}/${DEFAULT_DOC_PATH})
 # Data directories are only inputs, no delclaration here
 SET(CMAKE_CONFIG_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR}/${DEFAULT_CONFIG_PATH})
 SET(CMAKE_LOG_OUTPUT_DIRECTORY     ${CMAKE_BINARY_DIR}/${DEFAULT_LOG_PATH})
 
-# Set the extension of the dynamic modules
+# Set the extension of the helper-files for dynamic modules
 SET(ORXONOX_MODULE_EXTENSION ".module")
+SET(ORXONOX_PLUGIN_EXTENSION ".plugin")
 
+# Delete all existing helper-files for dynamic modules
+# modules:
+FILE(GLOB_RECURSE _helper_files ${CMAKE_MODULE_OUTPUT_DIRECTORY}/*${ORXONOX_MODULE_EXTENSION})
+IF(_helper_files)
+  FILE(REMOVE ${_helper_files})
+ENDIF()
+# plugins:
+FILE(GLOB_RECURSE _helper_files ${CMAKE_PLUGIN_OUTPUT_DIRECTORY}/*${ORXONOX_PLUGIN_EXTENSION})
+IF(_helper_files)
+  FILE(REMOVE ${_helper_files})
+ENDIF()
+
 # Sets where to find the external libraries like OgreMain.dll at runtime
 # On Unix you should not have to change this at all.
 # This only applies to development runs in the build tree

Modified: code/trunk/cmake/InstallConfig.cmake
===================================================================
--- code/trunk/cmake/InstallConfig.cmake	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/cmake/InstallConfig.cmake	2015-10-04 19:12:21 UTC (rev 10624)
@@ -48,6 +48,7 @@
 SET(LIBRARY_INSTALL_DIRECTORY ${DEFAULT_LIBRARY_PATH})
 SET(ARCHIVE_INSTALL_DIRECTORY ${DEFAULT_ARCHIVE_PATH})
 SET(MODULE_INSTALL_DIRECTORY  ${DEFAULT_MODULE_PATH})
+SET(PLUGIN_INSTALL_DIRECTORY  ${DEFAULT_PLUGIN_PATH})
 SET(DOC_INSTALL_DIRECTORY     ${DEFAULT_DOC_PATH})
 SET(DATA_INSTALL_DIRECTORY    ${DEFAULT_DATA_PATH})
 SET(CONFIG_INSTALL_DIRECTORY  ${DEFAULT_CONFIG_PATH})
@@ -60,6 +61,7 @@
     SET(LIBRARY_INSTALL_DIRECTORY lib/games/orxonox)
     SET(ARCHIVE_INSTALL_DIRECTORY lib/games/orxonox/static)
     SET(MODULE_INSTALL_DIRECTORY  lib/games/orxonox/modules)
+    SET(PLUGIN_INSTALL_DIRECTORY  lib/games/orxonox/plugins)
     SET(DOC_INSTALL_DIRECTORY     share/doc/orxonox)
     SET(DATA_INSTALL_DIRECTORY    share/games/orxonox)
   ELSEIF(WIN32)
@@ -84,18 +86,21 @@
 
 # The RPATH to be used when installing
 IF(INSTALL_COPYABLE)
-  # Get relative paths from run to lib and from module to lib directory.
+  # Get relative paths from run to lib and from module/plugin to lib directory.
   FILE(RELATIVE_PATH _runtime_rpath "/${RUNTIME_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
   FILE(RELATIVE_PATH _module_rpath  "/${MODULE_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
+  FILE(RELATIVE_PATH _plugin_rpath  "/${PLUGIN_INSTALL_DIRECTORY}" "/${LIBRARY_INSTALL_DIRECTORY}")
   # $ORIGIN (with $ escaped) refers to the actual location of the library
   # The UNIX loader recognises this special variable
   SET(RUNTIME_RPATH "\$ORIGIN/${_runtime_rpath}")
   SET(LIBRARY_RPATH "\$ORIGIN")
   SET(MODULE_RPATH  "\$ORIGIN:\$ORIGIN/${_module_rpath}")
+  SET(PLUGIN_RPATH  "\$ORIGIN:\$ORIGIN/${_plugin_rpath}")
 ELSE()
   SET(RUNTIME_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
   SET(LIBRARY_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIRECTORY}")
   SET(MODULE_RPATH  "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${MODULE_INSTALL_DIRECTORY}")
+  SET(PLUGIN_RPATH  "${LIBRARY_RPATH}:${CMAKE_INSTALL_PREFIX}/${PLUGIN_INSTALL_DIRECTORY}")
 ENDIF()
 
 # Add the automatically determined parts of the RPATH

Modified: code/trunk/cmake/tools/FindVLD.cmake
===================================================================
--- code/trunk/cmake/tools/FindVLD.cmake	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/cmake/tools/FindVLD.cmake	2015-10-04 19:12:21 UTC (rev 10624)
@@ -27,7 +27,7 @@
 
 FIND_LIBRARY(VLD_LIBRARY
   NAMES vld
-  PATH_SUFFIXES "Visual Leak Detector/lib/Win32"
+  PATH_SUFFIXES "Visual Leak Detector/lib/Win32" "../../lib/Win32"
 )
 
 # Handle the REQUIRED argument and set POCO_FOUND

Modified: code/trunk/cmake/tools/TargetUtilities.cmake
===================================================================
--- code/trunk/cmake/tools/TargetUtilities.cmake	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/cmake/tools/TargetUtilities.cmake	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,6 +34,9 @@
  #      NO_DLL_INTERFACE:  Link statically with MSVC
  #      NO_SOURCE_GROUPS:  Don't create msvc source groups
  #      MODULE:            For dynamic module libraries (libraries only)
+ #      PLUGIN:            For dynamic plugin libraries (libraries only)
+ #                         Plugins are a special kind of modules that can be
+ #                         loaded and unloaded during runtime on demand
  #      WIN32:             Inherited from ADD_EXECUTABLE (executables only)
  #      PCH_NO_DEFAULT:    Do not make precompiled header files default if
  #                         specified with PCH_FILE
@@ -76,11 +79,13 @@
 ENDIF()
 
 MACRO(ORXONOX_ADD_LIBRARY _target_name)
-  TU_ADD_TARGET(${_target_name} LIBRARY "MODULE" ${ARGN})
+  SET(_additional_switches MODULE PLUGIN)
+  TU_ADD_TARGET(${_target_name} LIBRARY "${_additional_switches}" ${ARGN})
 ENDMACRO(ORXONOX_ADD_LIBRARY)
 
 MACRO(ORXONOX_ADD_EXECUTABLE _target_name)
-  TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN})
+  SET(_additional_switches WIN32)
+  TU_ADD_TARGET(${_target_name} EXECUTABLE "${_additional_switches}" ${ARGN})
   
   # When using Visual Studio we want to use the output directory as working
   # directory and we also want to specify where the external dlls
@@ -328,11 +333,20 @@
       RUNTIME_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Windows
       LIBRARY_OUTPUT_DIRECTORY ${CMAKE_MODULE_OUTPUT_DIRECTORY} # Unix
     )
-    ADD_MODULE(${_target_name})
+    ADD_MODULE_OR_PLUGIN(${_target_name} ${CMAKE_MODULE_OUTPUT_DIRECTORY} ${MODULE_INSTALL_DIRECTORY} ${ORXONOX_MODULE_EXTENSION})
     # Ensure that the main program depends on the module
     SET(ORXONOX_MODULES ${ORXONOX_MODULES} ${_target_name} CACHE INTERNAL "")
   ENDIF()
 
+  # Configure plugins
+  IF (_arg_PLUGIN)
+    SET_TARGET_PROPERTIES(${_target_name} PROPERTIES
+      RUNTIME_OUTPUT_DIRECTORY ${CMAKE_PLUGIN_OUTPUT_DIRECTORY} # Windows
+      LIBRARY_OUTPUT_DIRECTORY ${CMAKE_PLUGIN_OUTPUT_DIRECTORY} # Unix
+    )
+    ADD_MODULE_OR_PLUGIN(${_target_name} ${CMAKE_PLUGIN_OUTPUT_DIRECTORY} ${PLUGIN_INSTALL_DIRECTORY} ${ORXONOX_PLUGIN_EXTENSION})
+  ENDIF()
+
   # Static library flags are not globally available
   IF(ORXONOX_STATIC_LINKER_FLAGS)
     SET_TARGET_PROPERTIES(${_target_name} PROPERTIES STATIC_LIBRARY_FLAGS ${ORXONOX_STATIC_LINKER_FLAGS})
@@ -371,6 +385,8 @@
   IF("${_target_type}" STREQUAL "LIBRARY")
     IF(_arg_MODULE)
       SET(_rpath "${MODULE_RPATH}")
+    ELSEIF(_arg_PLUGIN)
+      SET(_rpath "${PLUGIN_RPATH}")
     ELSE()
       SET(_rpath "${LIBRARY_RPATH}")
     ENDIF()
@@ -411,6 +427,11 @@
         RUNTIME DESTINATION ${MODULE_INSTALL_DIRECTORY}
         LIBRARY DESTINATION ${MODULE_INSTALL_DIRECTORY}
       )
+    ELSEIF(_arg_PLUGIN)
+      INSTALL(TARGETS ${_target_name}
+        RUNTIME DESTINATION ${PLUGIN_INSTALL_DIRECTORY}
+        LIBRARY DESTINATION ${PLUGIN_INSTALL_DIRECTORY}
+      )
     ELSE()
       INSTALL(TARGETS ${_target_name}
         RUNTIME DESTINATION ${RUNTIME_INSTALL_DIRECTORY}
@@ -427,6 +448,11 @@
             DESTINATION ${MODULE_INSTALL_DIRECTORY}
             CONFIGURATIONS ${_config}
           )
+        ELSEIF(_arg_PLUGIN)
+          INSTALL(FILES ${_location_we}.pdb
+            DESTINATION ${PLUGIN_INSTALL_DIRECTORY}
+            CONFIGURATIONS ${_config}
+          )
         ELSE()
           INSTALL(FILES ${_location_we}.pdb
             DESTINATION ${RUNTIME_INSTALL_DIRECTORY}
@@ -440,42 +466,42 @@
 ENDMACRO(TU_ADD_TARGET)
 
 
-# Creates a helper file with name <name_of_the_library>${ORXONOX_MODULE_EXTENSION}
-# This helps finding dynamically loadable modules at runtime
+# Creates a helper file with name <name_of_the_library>.<extension>
+# This helps finding dynamically loadable modules or plugins at runtime
 
-FUNCTION(ADD_MODULE _target)
+FUNCTION(ADD_MODULE_OR_PLUGIN _target_name _output_dir _install_dir _extension)
   # We use the properties to get the name because the librarys name may differ from
   # the target name (for example orxonox <-> liborxonox)
   IF (POLICY CMP0026)
     CMAKE_POLICY(PUSH)
     CMAKE_POLICY(SET CMP0026 OLD) # we only use the file's name, not its actual location, so the old policy is fine
   ENDIF()
-  GET_TARGET_PROPERTY(_target_loc ${_target} LOCATION)
-  GET_FILENAME_COMPONENT(_target_name ${_target_loc} NAME_WE)
+  GET_TARGET_PROPERTY(_target_loc ${_target_name} LOCATION)
+  GET_FILENAME_COMPONENT(_target_filename ${_target_loc} NAME_WE)
   IF (POLICY CMP0026)
     CMAKE_POLICY(POP) # set policy back to original settings
   ENDIF()
 
   IF(CMAKE_CONFIGURATION_TYPES)
     FOREACH(_config ${CMAKE_CONFIGURATION_TYPES})
-      SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_config}/${_target_name}${ORXONOX_MODULE_EXTENSION})
+      SET(_helper_filename ${_output_dir}/${_config}/${_target_filename}${_extension})
 
-      FILE(WRITE ${_module_filename})
+      FILE(WRITE ${_helper_filename} ${_target_name})
 
       INSTALL(
-        FILES ${_module_filename}
-        DESTINATION ${MODULE_INSTALL_DIRECTORY}
+        FILES ${_helper_filename}
+        DESTINATION ${_install_dir}
         CONFIGURATIONS ${_config}
       )
     ENDFOREACH()
   ELSE()
-    SET(_module_filename ${CMAKE_MODULE_OUTPUT_DIRECTORY}/${_target_name}${ORXONOX_MODULE_EXTENSION})
+    SET(_helper_filename ${_output_dir}/${_target_filename}${_extension})
 
-    FILE(WRITE ${_module_filename})
+    FILE(WRITE ${_helper_filename} ${_target_name})
 
     INSTALL(
-      FILES ${_module_filename}
-      DESTINATION ${MODULE_INSTALL_DIRECTORY}
+      FILES ${_helper_filename}
+      DESTINATION ${_install_dir}
     )
   ENDIF()
-ENDFUNCTION(ADD_MODULE)
+ENDFUNCTION(ADD_MODULE_OR_PLUGIN)

Modified: code/trunk/data/levels/4Dtest.oxw
===================================================================
--- code/trunk/data/levels/4Dtest.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/4Dtest.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -15,6 +15,7 @@
 
 
 <Level
+ plugins=mini4dgame
  gametype=Mini4Dgame
 >
 

Modified: code/trunk/data/levels/DodgeRace.oxw
===================================================================
--- code/trunk/data/levels/DodgeRace.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/DodgeRace.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -18,7 +18,10 @@
   include("overlays/DodgeRaceHUD.oxo")
 ?>
 
-<Level gametype = DodgeRace>
+<Level
+  plugins = dodgerace
+  gametype = DodgeRace
+>
   <templates>
     <Template link=lodtemplate_default />
   </templates>

Modified: code/trunk/data/levels/Invaders.oxw
===================================================================
--- code/trunk/data/levels/Invaders.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/Invaders.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -17,7 +17,10 @@
   include("overlays/InvaderHUD.oxo")
 ?>
 
-<Level gametype = Invader>
+<Level
+  plugins = invader
+  gametype = Invader
+>
   <templates>
     <Template link=lodtemplate_default />
   </templates>

Modified: code/trunk/data/levels/Spacerace2.oxw
===================================================================
--- code/trunk/data/levels/Spacerace2.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/Spacerace2.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -23,7 +23,8 @@
 <Level
  name         = "Spacerace2"
  description  = "Just a few tests"
-gametype = SpaceRace
+ plugins = gametypes
+ gametype = SpaceRace
 >
   <templates>
     <Template link=lodtemplate_default />

Modified: code/trunk/data/levels/SurfaceRacePresentation.oxw
===================================================================
--- code/trunk/data/levels/SurfaceRacePresentation.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/SurfaceRacePresentation.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -19,6 +19,7 @@
 ?>
 
 <Level
+plugins = gametypes
 gametype = SpaceRace
 >
 

Modified: code/trunk/data/levels/jump.oxw
===================================================================
--- code/trunk/data/levels/jump.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/jump.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -191,7 +191,10 @@
   </JumpShield>
 </Template>
 
-<Level gametype = "Jump">
+<Level
+ plugins = "jump"
+ gametype = "Jump"
+>
   <templates>
     <Template link=lodtemplate_default />
   </templates>

Modified: code/trunk/data/levels/pong.oxw
===================================================================
--- code/trunk/data/levels/pong.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/pong.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -52,6 +52,7 @@
 
 
 <Level
+ plugins = "pong"
  gametype = "Pong"
 >
   <templates>

Modified: code/trunk/data/levels/presentationHS12.oxw
===================================================================
--- code/trunk/data/levels/presentationHS12.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/presentationHS12.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -31,6 +31,7 @@
 ?>
 
 <Level
+  plugins = gametypes
   gametype = SpaceRace
 >
   <templates>

Modified: code/trunk/data/levels/spaceRace.oxw
===================================================================
--- code/trunk/data/levels/spaceRace.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/spaceRace.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -17,6 +17,7 @@
 ?>
 
 <Level
+ plugins = "gametypes"
  gametype = "OldSpaceRace"
 >
   <templates>

Modified: code/trunk/data/levels/surfaceRace.oxw
===================================================================
--- code/trunk/data/levels/surfaceRace.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/surfaceRace.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -22,6 +22,7 @@
 
 
 <Level
+  plugins = gametypes
   gametype = SpaceRace
 >
 

Modified: code/trunk/data/levels/tetris.oxw
===================================================================
--- code/trunk/data/levels/tetris.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/tetris.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -54,6 +54,7 @@
 
 
 <Level
+ plugins = "tetris"
  gametype = "Tetris"
 >
   <templates>

Modified: code/trunk/data/levels/towerDefense.oxw
===================================================================
--- code/trunk/data/levels/towerDefense.oxw	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/data/levels/towerDefense.oxw	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,7 +44,10 @@
 
 
 
-<Level gametype = "TowerDefense">
+<Level
+  plugins = "towerdefense"
+  gametype = "TowerDefense"
+>
   <templates>
     <Template link=lodtemplate_default />
   </templates>

Modified: code/trunk/src/CMakeLists.txt
===================================================================
--- code/trunk/src/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,6 +38,7 @@
 ADD_SUBDIRECTORY(libraries)
 ADD_SUBDIRECTORY(orxonox)
 SET(ORXONOX_MODULES CACHE INTERNAL "")
+SET(ORXONOX_PLUGINS CACHE INTERNAL "")
 ADD_SUBDIRECTORY(modules)
 
 ################## Executable ###################
@@ -71,7 +72,7 @@
     ${ORXONOX_MAIN_FILES}
   OUTPUT_NAME orxonox
 )
-# Main executable should depend on all modules
+# Main executable should depend on all modules (but not on plugins)
 ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES})
 
 # Get name to configure the run scripts

Modified: code/trunk/src/SpecialConfig.h.in
===================================================================
--- code/trunk/src/SpecialConfig.h.in	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/SpecialConfig.h.in	2015-10-04 19:12:21 UTC (rev 10624)
@@ -59,6 +59,7 @@
     const char defaultLibraryPath[] = "@DEFAULT_LIBRARY_PATH@";
     const char defaultArchivePath[] = "@DEFAULT_ARCHIVE_PATH@";
     const char defaultModulePath[]  = "@DEFAULT_MODULE_PATH@";
+    const char defaultPluginPath[]  = "@DEFAULT_PLUGIN_PATH@";
     const char defaultDocPath[]     = "@DEFAULT_DOC_PATH@";
     const char defaultDataPath[]    = "@DEFAULT_DATA_PATH@";
     const char defaultConfigPath[]  = "@DEFAULT_CONFIG_PATH@";
@@ -68,6 +69,7 @@
     // INSTALLATION PATHS
     const char dataInstallDirectory[]       = "@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIRECTORY@";
     const char moduleInstallDirectory[]     = "@CMAKE_INSTALL_PREFIX@/@MODULE_INSTALL_DIRECTORY@";
+    const char pluginInstallDirectory[]     = "@CMAKE_INSTALL_PREFIX@/@PLUGIN_INSTALL_DIRECTORY@";
 #endif
 
     // DEVELOPMENT RUN PATHS
@@ -75,10 +77,12 @@
     const char externalDataDevDirectory[]   = "@EXTERNAL_DATA_DIRECTORY@";
 #ifdef CMAKE_CONFIGURATION_TYPES
     const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
+    const char pluginDevDirectory[]         = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
     const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@/" CMAKE_INTDIR;
     const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@/"    CMAKE_INTDIR;
 #else
     const char moduleDevDirectory[]         = "@CMAKE_MODULE_OUTPUT_DIRECTORY@";
+    const char pluginDevDirectory[]         = "@CMAKE_PLUGIN_OUTPUT_DIRECTORY@";
     const char configDevDirectory[]         = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@";
     const char logDevDirectory[]            = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
 #endif
@@ -87,8 +91,9 @@
     const char dependencyLibraryDirectory[] = "@DEP_LIBRARY_DIR@";
 #endif
 
-    // Module extension
+    // Module and plugin extension
     const char moduleExtension[] = "@ORXONOX_MODULE_EXTENSION@";
+    const char pluginExtension[] = "@ORXONOX_PLUGIN_EXTENSION@";
 
     // OGRE PLUGINS
 #ifdef NDEBUG

Copied: code/trunk/src/libraries/core/ApplicationPaths.cc (from rev 10623, code/branches/core7/src/libraries/core/ApplicationPaths.cc)
===================================================================
--- code/trunk/src/libraries/core/ApplicationPaths.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/ApplicationPaths.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,235 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ApplicationPaths.h"
+
+#include <cassert>
+#include <cstdlib>
+#include <cstdio>
+#include <vector>
+#include <boost/filesystem.hpp>
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include <windows.h>
+#  undef min
+#  undef max
+#elif defined(ORXONOX_PLATFORM_APPLE)
+#  include <sys/param.h>
+#  include <mach-o/dyld.h>
+#else /* Linux */
+#  include <sys/types.h>
+#  include <unistd.h>
+#endif
+
+#include "SpecialConfig.h"
+#include "util/Output.h"
+#include "util/Exception.h"
+
+// Differentiate Boost Filesystem v2 and v3
+#if (BOOST_FILESYSTEM_VERSION < 3)
+#  define BF_LEAF leaf
+#  define BF_GENERIC_STRING string
+#else
+#  define BF_LEAF path().filename().string
+#  define BF_GENERIC_STRING generic_string
+#endif
+
+namespace orxonox
+{
+    namespace bf = boost::filesystem;
+
+    //! Static pointer to the singleton
+    ApplicationPaths* ApplicationPaths::singletonPtr_s  = 0;
+
+    ApplicationPaths::ApplicationPaths()
+        : rootPath_(*(new bf::path()))
+        , executablePath_(*(new bf::path()))
+        , modulePath_(*(new bf::path()))
+        , pluginPath_(*(new bf::path()))
+        , bBuildDirectoryRun_(false)
+    {
+        //////////////////////////
+        // FIND EXECUTABLE PATH //
+        //////////////////////////
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+        // get executable module
+        TCHAR buffer[1024];
+        if (GetModuleFileName(NULL, buffer, 1024) == 0)
+            ThrowException(General, "Could not retrieve executable path.");
+
+#elif defined(ORXONOX_PLATFORM_APPLE)
+        char buffer[1024];
+        uint32_t path_len = 1023;
+        if (_NSGetExecutablePath(buffer, &path_len))
+            ThrowException(General, "Could not retrieve executable path.");
+
+#else /* Linux */
+        /* written by Nicolai Haehnle <prefect_ at gmx.net> */
+
+        /* Get our PID and build the name of the link in /proc */
+        char linkname[64]; /* /proc/<pid>/exe */
+        if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)
+        {
+            /* This should only happen on large word systems. I'm not sure
+               what the proper response is here.
+               Since it really is an assert-like condition, aborting the
+               program seems to be in order. */
+            assert(false);
+        }
+
+        /* Now read the symbolic link */
+        char buffer[1024];
+        int ret;
+        ret = readlink(linkname, buffer, 1024);
+        /* In case of an error, leave the handling up to the caller */
+        if (ret == -1)
+            ThrowException(General, "Could not retrieve executable path.");
+
+        /* Ensure proper NUL termination */
+        buffer[ret] = 0;
+#endif
+
+        // Remove executable filename
+        executablePath_ = bf::path(buffer).branch_path();
+
+        /////////////////////////////////
+        // SET MODULE AND PLUGIN PATHS //
+        /////////////////////////////////
+
+        if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))
+        {
+            orxout(internal_info) << "Running from the build tree." << endl;
+            ApplicationPaths::bBuildDirectoryRun_ = true;
+            modulePath_ = specialConfig::moduleDevDirectory;
+            pluginPath_ = specialConfig::pluginDevDirectory;
+        }
+        else
+        {
+
+#ifdef INSTALL_COPYABLE // --> relative paths
+
+            // Also set the root path
+            bf::path relativeExecutablePath(specialConfig::defaultRuntimePath);
+            rootPath_ = executablePath_;
+            while (!bf::equivalent(rootPath_ / relativeExecutablePath, executablePath_) && !rootPath_.empty())
+                rootPath_ = rootPath_.branch_path();
+            if (rootPath_.empty())
+                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
+
+            // Module and plugin paths are fixed as well
+            modulePath_ = rootPath_ / specialConfig::defaultModulePath;
+            pluginPath_ = rootPath_ / specialConfig::defaultPluginPath;
+
+#else
+
+            // There is no root path, so don't set it at all
+            // Module and plugin paths are fixed as well
+            modulePath_ = specialConfig::moduleInstallDirectory;
+            pluginPath_ = specialConfig::pluginInstallDirectory;
+
+#endif
+        }
+    }
+
+    ApplicationPaths::~ApplicationPaths()
+    {
+        delete &rootPath_;
+        delete &executablePath_;
+        delete &modulePath_;
+        delete &pluginPath_;
+    }
+
+    std::vector<std::string> ApplicationPaths::getModulePaths()
+    {
+        return this->getModuleOrPluginPaths(modulePath_, specialConfig::moduleExtension);
+    }
+
+    std::vector<std::string> ApplicationPaths::getPluginPaths()
+    {
+        return this->getModuleOrPluginPaths(pluginPath_, specialConfig::pluginExtension);
+    }
+
+    std::vector<std::string> ApplicationPaths::getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension)
+    {
+        std::vector<std::string> paths;
+
+        // We search for helper files with the following extension
+        size_t extensionlength = extension.size();
+
+        // Make sure the path exists, otherwise don't load modules/plugins
+        if (!boost::filesystem::exists(directory))
+            return paths;
+
+        boost::filesystem::directory_iterator file(directory);
+        boost::filesystem::directory_iterator end;
+
+        // Iterate through all files
+        while (file != end)
+        {
+            std::string filename = file->BF_LEAF();
+
+            // Check if the file ends with the extension in question
+            if (filename.size() > extensionlength)
+            {
+                if (filename.substr(filename.size() - extensionlength) == extension)
+                {
+                    // We've found a helper file
+                    const std::string& library = filename.substr(0, filename.size() - extensionlength);
+                    paths.push_back(directory.BF_GENERIC_STRING() + '/' + library);
+                }
+            }
+            ++file;
+        }
+
+        return paths;
+    }
+
+    /*static*/ std::string ApplicationPaths::getRootPathString()
+    {
+        return getInstance().rootPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ApplicationPaths::getExecutablePathString()
+    {
+        return getInstance().executablePath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ApplicationPaths::getModulePathString()
+    {
+        return getInstance().modulePath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ApplicationPaths::getPluginPathString()
+    {
+        return getInstance().pluginPath_.BF_GENERIC_STRING() + '/';
+    }
+}

Copied: code/trunk/src/libraries/core/ApplicationPaths.h (from rev 10623, code/branches/core7/src/libraries/core/ApplicationPaths.h)
===================================================================
--- code/trunk/src/libraries/core/ApplicationPaths.h	                        (rev 0)
+++ code/trunk/src/libraries/core/ApplicationPaths.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,121 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup Management Resources
+*/
+
+#ifndef _ApplicationPaths_H__
+#define _ApplicationPaths_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <vector>
+#include "util/Singleton.h"
+
+//tolua_begin
+namespace orxonox
+{
+//tolua_end
+    /**
+    @brief
+        The ApplicationPaths class is a singleton which provides static paths of the application.
+    @details
+        The class provides information about the executable, root and module/plugin path.
+        It determines those by the use of platform specific functions.
+    @remarks
+        Not all paths are always available:
+        - root only when installed copyable
+    */
+    class _CoreExport ApplicationPaths //tolua_export
+        : public Singleton<ApplicationPaths>
+    { //tolua_export
+        friend class Singleton<ApplicationPaths>;
+
+        public:
+            /**
+            @brief
+                Retrieves the executable path and sets all hard coded fixed paths (currently only the module and the plugin paths)
+                Also checks for "orxonox_dev_build.keep_me" in the executable directory.
+                If found it means that this is not an installed run, hence we
+                don't write the logs and config files to ~/.orxonox
+            @throw
+                GeneralException
+            */
+            ApplicationPaths();
+            ~ApplicationPaths();
+
+            //! Returns the path to the root folder as boost::filesystem::path
+            static const boost::filesystem::path& getRootPath()
+                { return getInstance().rootPath_; }
+            //! Returns the path to the executable folder as boost::filesystem::path
+            static const boost::filesystem::path& getExecutablePath()
+                { return getInstance().executablePath_; }
+            //! Returns the path to the modules as boost::filesystem::path
+            static const boost::filesystem::path& getModulePath()
+                { return getInstance().modulePath_; }
+            //! Returns the path to the plugins as boost::filesystem::path
+            static const boost::filesystem::path& getPluginPath()
+                { return getInstance().pluginPath_; }
+
+            //! Returns the path to the root folder as std::string
+            static std::string getRootPathString();
+            //! Returns the path to the executable folder as std::string
+            static std::string getExecutablePathString();
+            //! Returns the path to the modules as std::string
+            static std::string getModulePathString();
+            //! Returns the path to the plugins as std::string
+            static std::string getPluginPathString();
+
+            //! Return true for runs in the build directory (not installed)
+            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
+
+            //! Returns a list with all modules declared by a *.module file in the module folder.
+            std::vector<std::string> getModulePaths();
+            //! Returns a list with all plugins declared by a *.plugin file in the plugin folder.
+            std::vector<std::string> getPluginPaths();
+
+        private:
+            ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol)
+
+            std::vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension);
+
+            //! Path to the parent directory of the ones above if program was installed with relative paths
+            boost::filesystem::path& rootPath_;
+            boost::filesystem::path& executablePath_;        //!< Path to the executable
+            boost::filesystem::path& modulePath_;            //!< Path to the modules
+            boost::filesystem::path& pluginPath_;            //!< Path to the plugins
+
+            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
+            static ApplicationPaths* singletonPtr_s;
+    }; //tolua_export
+} //tolua_export
+
+#endif /* _ApplicationPaths_H__ */

Modified: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/BaseObject.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -62,7 +62,6 @@
 
         this->bActive_ = true;
         this->bVisible_ = true;
-        this->oldGametype_ = 0;
         this->bRegisteredEventStates_ = false;
 
         this->lastLoadedXMLElement_ = 0;
@@ -77,19 +76,17 @@
         if (this->creator_)
         {
             this->setFile(this->creator_->getFile());
-            this->setNamespace(this->creator_->getNamespace());
-            this->setScene(this->creator_->getScene(), this->creator_->getSceneID());
-            this->setGametype(this->creator_->getGametype());
-            this->setLevel(this->creator_->getLevel());
+
+            // store strong-pointers on all four base objects by default (can be overwritten with weak-ptr after the constructor if necessary)
+            this->setNamespace(this->creator_->namespace_.createStrongPtr());
+            this->setScene    (this->creator_->scene_    .createStrongPtr(), this->creator_->sceneID_);
+            this->setGametype (this->creator_->gametype_ .createStrongPtr());
+            this->setLevel    (this->creator_->level_    .createStrongPtr());
         }
         else
         {
             this->file_ = 0;
-            this->namespace_ = 0;
-            this->scene_ = 0;
             this->sceneID_ = OBJECTID_UNKNOWN;
-            this->gametype_ = 0;
-            this->level_ = 0;
         }
     }
 

Modified: code/trunk/src/libraries/core/BaseObject.h
===================================================================
--- code/trunk/src/libraries/core/BaseObject.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/BaseObject.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -50,7 +50,7 @@
 #include "util/mbool.h"
 #include "class/OrxonoxClass.h"
 #include "class/Super.h"
-#include "object/SmartPtr.h"
+#include "object/StrongPtr.h"
 
 namespace orxonox
 {
@@ -64,6 +64,23 @@
         template <class T> friend class XMLPortClassParamContainer;
 
         public:
+            template <class T>
+            class StrongOrWeakPtr
+            {
+                public:
+                    inline StrongOrWeakPtr();
+                    inline StrongOrWeakPtr(const StrongPtr<T>& ptr);
+                    inline StrongOrWeakPtr(const WeakPtr<T>& ptr);
+
+                    inline T* get() const;
+                    inline StrongPtr<T> createStrongPtr() const;
+
+                private:
+                    StrongPtr<T> strongPtr_;
+                    WeakPtr<T> weakPtr_;
+            };
+
+        public:
             BaseObject(Context* context);
             virtual ~BaseObject();
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
@@ -137,39 +154,21 @@
             inline const std::set<Template*>& getTemplates() const
                 { return this->templates_; }
 
-            inline void setNamespace(const SmartPtr<Namespace>& ns) { this->namespace_ = ns; }
-            inline const SmartPtr<Namespace>& getNamespace() const { return this->namespace_; }
+            inline void setNamespace(const StrongOrWeakPtr<Namespace>& ns) { this->namespace_ = ns; }
+            inline Namespace* getNamespace() const { return this->namespace_.get(); }
 
             inline void setCreator(BaseObject* creator) { this->creator_ = creator; }
             inline BaseObject* getCreator() const { return this->creator_; }
 
-            inline void setScene(const SmartPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }
-            inline const SmartPtr<Scene>& getScene() const { return this->scene_; }
+            inline void setScene(const StrongOrWeakPtr<Scene>& scene, uint32_t sceneID) { this->scene_ = scene; this->sceneID_=sceneID; }
+            inline Scene* getScene() const { return this->scene_.get(); }
             inline virtual uint32_t getSceneID() const { return this->sceneID_; }
 
-            inline void setGametype(const SmartPtr<Gametype>& gametype)
-            {
-                if (gametype != this->gametype_)
-                {
-                    this->oldGametype_ = this->gametype_;
-                    this->gametype_ = gametype;
-                    this->changedGametype();
-                }
-            }
-            inline const SmartPtr<Gametype>& getGametype() const { return this->gametype_; }
-            inline Gametype* getOldGametype() const { return this->oldGametype_; }
-            virtual void changedGametype() {}
+            inline void setGametype(const StrongOrWeakPtr<Gametype>& gametype) { this->gametype_ = gametype; }
+            inline Gametype* getGametype() const { return this->gametype_.get(); }
 
-            inline void setLevel(const SmartPtr<Level>& level)
-            {
-                if (level != this->level_)
-                {
-                    this->level_ = level;
-                    this->changedLevel();
-                }
-            }
-            inline const SmartPtr<Level>& getLevel() const { return this->level_; }
-            virtual void changedLevel() {}
+            inline void setLevel(const StrongOrWeakPtr<Level>& level) { this->level_ = level; }
+            inline Level* getLevel() const { return this->level_.get(); }
 
             void addEventSource(BaseObject* source, const std::string& state);
             void removeEventSource(BaseObject* source);
@@ -216,19 +215,18 @@
             Template* getTemplate(unsigned int index) const;
             void registerEventStates();
 
-            bool                   bInitialized_;              //!< True if the object was initialized (passed the object registration)
-            const XMLFile*         file_;                      //!< The XMLFile that loaded this object
-            Element*               lastLoadedXMLElement_;      //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map
+            bool                       bInitialized_;          //!< True if the object was initialized (passed the object registration)
+            const XMLFile*             file_;                  //!< The XMLFile that loaded this object
+            Element*                   lastLoadedXMLElement_;  //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map
             std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes
-            std::string            loaderIndentation_;         //!< Indentation of the debug output in the Loader
-            SmartPtr<Namespace>    namespace_;
-            BaseObject*            creator_;
-            SmartPtr<Scene>        scene_;
-            uint32_t               sceneID_;
-            SmartPtr<Gametype>     gametype_;
-            Gametype*              oldGametype_;
-            SmartPtr<Level>        level_;
-            std::set<Template*>    templates_;
+            std::string                loaderIndentation_;     //!< Indentation of the debug output in the Loader
+            StrongOrWeakPtr<Namespace> namespace_;
+            BaseObject*                creator_;
+            StrongOrWeakPtr<Scene>     scene_;
+            uint32_t                   sceneID_;
+            StrongOrWeakPtr<Gametype>  gametype_;
+            StrongOrWeakPtr<Level>     level_;
+            std::set<Template*>        templates_;
 
             std::map<BaseObject*, std::string>  eventSources_;           //!< List of objects which send events to this object, mapped to the state which they affect
             std::set<BaseObject*>               eventListeners_;         //!< List of objects which listen to the events of this object
@@ -242,7 +240,41 @@
     SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
     SUPER_FUNCTION(4, BaseObject, XMLEventPort, false);
     SUPER_FUNCTION(8, BaseObject, changedName, false);
-    SUPER_FUNCTION(9, BaseObject, changedGametype, false);
+
+    template <class T>
+    BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr()
+    {
+    }
+
+    template <class T>
+    BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr(const StrongPtr<T>& ptr) : strongPtr_(ptr)
+    {
+    }
+
+    template <class T>
+    BaseObject::StrongOrWeakPtr<T>::StrongOrWeakPtr(const WeakPtr<T>& ptr) : weakPtr_(ptr)
+    {
+    }
+
+    template <class T>
+    T* BaseObject::StrongOrWeakPtr<T>::get() const
+    {
+        if (this->strongPtr_)
+            return this->strongPtr_;
+        else if (this->weakPtr_)
+            return this->weakPtr_;
+        else
+            return NULL;
+    }
+
+    template <class T>
+    StrongPtr<T> BaseObject::StrongOrWeakPtr<T>::createStrongPtr() const
+    {
+        if (this->strongPtr_)
+            return this->strongPtr_; // creates a copy
+        else
+            return this->weakPtr_; // converts automatically to StrongPtr
+    }
 }
 
 #endif /* _BaseObject_H__ */

Modified: code/trunk/src/libraries/core/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -21,10 +21,9 @@
 
 #BUILD_UNIT CoreStableBuildUnit.cc
   ClassTreeMask.cc
-  DynLib.cc
-  DynLibManager.cc
   Event.cc
   Game.cc
+  GameConfig.cc
   GameMode.cc
   GameState.cc
   Language.cc
@@ -33,6 +32,7 @@
   Namespace.cc
   NamespaceNode.cc
   Template.cc
+  UpdateListener.cc
   ViewportEventListener.cc
   WindowEventListener.cc
   XMLNameListener.cc
@@ -41,6 +41,8 @@
 
   BaseObject.cc
   Core.cc
+  CoreConfig.cc
+  CoreStaticInitializationHandler.cc
 
 BUILD_UNIT OgreBuildUnit.cc
   GraphicsManager.cc
@@ -51,7 +53,8 @@
 BUILD_UNIT FilesystemBuildUnit.cc
   command/ArgumentCompletionFunctions.cc
   config/ConfigFile.cc
-  PathConfig.cc
+  ApplicationPaths.cc
+  ConfigurablePaths.cc
 END_BUILD_UNIT
 
 BUILD_UNIT ThreadBuildUnit.cc
@@ -63,9 +66,12 @@
 
 ADD_SUBDIRECTORY(class)
 ADD_SUBDIRECTORY(command)
+ADD_SUBDIRECTORY(commandline)
 ADD_SUBDIRECTORY(config)
 ADD_SUBDIRECTORY(input)
+ADD_SUBDIRECTORY(module)
 ADD_SUBDIRECTORY(object)
+ADD_SUBDIRECTORY(singleton)
 
 #Add the icon (for the renderwindow)
 IF(WIN32)
@@ -77,13 +83,14 @@
   TOLUA_FILES
     command/CommandExecutor.h
     config/SettingsConfigFile.h
+    ApplicationPaths.h
+    ConfigurablePaths.h
     Game.h
     GameMode.h
     GraphicsManager.h
     GUIManager.h
     Loader.h
     LuaState.h
-    PathConfig.h
     input/InputManager.h
     input/KeyBinder.h
     input/KeyBinderManager.h

Modified: code/trunk/src/libraries/core/ClassTreeMask.cc
===================================================================
--- code/trunk/src/libraries/core/ClassTreeMask.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/ClassTreeMask.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -292,7 +292,7 @@
         else
         {
             // No it's not: Search for classes inheriting from the given class and add the rules for them
-            for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+            for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)
                 if ((*it)->isA(this->root_->getClass()))
                     if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist
                         this->add(this->root_, *it, bInclude, overwrite);
@@ -391,7 +391,7 @@
     {
         if (!subclass)
             return;
-        for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+        for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildren().begin(); it != subclass->getDirectChildren().end(); ++it)
             this->add(*it, this->isIncluded(*it), false, false);
 
         this->add(subclass, bInclude, false, clean);
@@ -942,7 +942,7 @@
                                 this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it2, true));
 
                                 // Insert all directChildren of the directChild
-                                directChildren.insert((*it2)->getDirectChildrenBegin(), (*it2)->getDirectChildrenEnd());
+                                directChildren.insert((*it2)->getDirectChildren().begin(), (*it2)->getDirectChildren().end());
 
                                 // Restart the scan with the expanded set of directChildren
                                 goto scanChildren;

Copied: code/trunk/src/libraries/core/ConfigurablePaths.cc (from rev 10623, code/branches/core7/src/libraries/core/ConfigurablePaths.cc)
===================================================================
--- code/trunk/src/libraries/core/ConfigurablePaths.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/ConfigurablePaths.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,183 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConfigurablePaths.h"
+
+#include <cassert>
+#include <cstdlib>
+#include <cstdio>
+#include <vector>
+#include <boost/filesystem.hpp>
+
+#ifdef ORXONOX_PLATFORM_WINDOWS
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include <windows.h>
+#  undef min
+#  undef max
+#elif defined(ORXONOX_PLATFORM_APPLE)
+#  include <sys/param.h>
+#  include <mach-o/dyld.h>
+#else /* Linux */
+#  include <sys/types.h>
+#  include <unistd.h>
+#endif
+
+#include "SpecialConfig.h"
+#include "util/Output.h"
+#include "util/Exception.h"
+#include "commandline/CommandLineIncludes.h"
+
+// Differentiate Boost Filesystem v2 and v3
+#if (BOOST_FILESYSTEM_VERSION < 3)
+#  define BF_GENERIC_STRING string
+#else
+#  define BF_GENERIC_STRING generic_string
+#endif
+
+namespace orxonox
+{
+    namespace bf = boost::filesystem;
+
+    //! Static pointer to the singleton
+    ConfigurablePaths* ConfigurablePaths::singletonPtr_s  = 0;
+
+    SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
+    SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
+
+    ConfigurablePaths::ConfigurablePaths()
+        : dataPath_(*(new bf::path()))
+        , externalDataPath_(*(new bf::path()))
+        , configPath_(*(new bf::path()))
+        , logPath_(*(new bf::path()))
+    {
+    }
+
+    ConfigurablePaths::~ConfigurablePaths()
+    {
+        delete &dataPath_;
+        delete &externalDataPath_;
+        delete &configPath_;
+        delete &logPath_;
+    }
+
+    void ConfigurablePaths::setConfigurablePaths(const ApplicationPaths& applicationPaths)
+    {
+        if (applicationPaths.buildDirectoryRun())
+        {
+            dataPath_         = specialConfig::dataDevDirectory;
+            configPath_       = specialConfig::configDevDirectory;
+            logPath_          = specialConfig::logDevDirectory;
+
+            // Check for data path override by the command line
+            if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
+                externalDataPath_ = CommandLineParser::getValue("externalDataPath").get<std::string>();
+            else
+                externalDataPath_ = specialConfig::externalDataDevDirectory;
+        }
+        else
+        {
+
+#ifdef INSTALL_COPYABLE // --> relative paths
+
+            // Using paths relative to the install prefix, complete them
+            dataPath_   = applicationPaths.getRootPath() / specialConfig::defaultDataPath;
+            configPath_ = applicationPaths.getRootPath() / specialConfig::defaultConfigPath;
+            logPath_    = applicationPaths.getRootPath() / specialConfig::defaultLogPath;
+
+#else
+
+            dataPath_  = specialConfig::dataInstallDirectory;
+
+            // Get user directory
+#ifdef ORXONOX_PLATFORM_UNIX
+            char* userDataPathPtr(getenv("HOME"));
+#else
+            char* userDataPathPtr(getenv("APPDATA"));
+#endif
+            if (userDataPathPtr == NULL)
+                ThrowException(General, "Could not retrieve user data path.");
+            bf::path userDataPath(userDataPathPtr);
+            userDataPath /= ".orxonox";
+
+            configPath_ = userDataPath / specialConfig::defaultConfigPath;
+            logPath_    = userDataPath / specialConfig::defaultLogPath;
+
+#endif
+
+        }
+
+        // Option to put all the config and log files in a separate folder
+        if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
+        {
+            const std::string& directory(CommandLineParser::getValue("writingPathSuffix").get<std::string>());
+            configPath_ = configPath_ / directory;
+            logPath_    = logPath_    / directory;
+        }
+
+        // Create directories to avoid problems when opening files in non existent folders.
+        std::vector<std::pair<bf::path, std::string> > directories;
+        directories.push_back(std::make_pair(bf::path(configPath_), std::string("config")));
+        directories.push_back(std::make_pair(bf::path(logPath_), std::string("log")));
+
+        for (std::vector<std::pair<bf::path, std::string> >::iterator it = directories.begin();
+            it != directories.end(); ++it)
+        {
+            if (bf::exists(it->first) && !bf::is_directory(it->first))
+            {
+                ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
+                                         Please remove " + it->first.BF_GENERIC_STRING());
+            }
+            if (bf::create_directories(it->first)) // function may not return true at all (bug?)
+            {
+                orxout(internal_info) << "Created " << it->second << " directory" << endl;
+            }
+        }
+    }
+
+    /*static*/ std::string ConfigurablePaths::getDataPathString()
+    {
+        return getInstance().dataPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ConfigurablePaths::getExternalDataPathString()
+    {
+        return getInstance().externalDataPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ConfigurablePaths::getConfigPathString()
+    {
+        return getInstance().configPath_.BF_GENERIC_STRING() + '/';
+    }
+
+    /*static*/ std::string ConfigurablePaths::getLogPathString()
+    {
+        return getInstance().logPath_.BF_GENERIC_STRING() + '/';
+    }
+}

Copied: code/trunk/src/libraries/core/ConfigurablePaths.h (from rev 10623, code/branches/core7/src/libraries/core/ConfigurablePaths.h)
===================================================================
--- code/trunk/src/libraries/core/ConfigurablePaths.h	                        (rev 0)
+++ code/trunk/src/libraries/core/ConfigurablePaths.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @ingroup Management Resources
+*/
+
+#ifndef _ConfigurablePaths_H__
+#define _ConfigurablePaths_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include "util/Singleton.h"
+
+//tolua_begin
+namespace orxonox
+{
+//tolua_end
+    /**
+    @brief
+        The ConfigurablePaths class is a singleton used to configure different paths.
+    @details
+        The class provides information about the data, config, and log path.
+    @remarks
+        Not all paths are always available:
+        - externalData only for development builds in the build tree
+    */
+    class _CoreExport ConfigurablePaths //tolua_export
+        : public Singleton<ConfigurablePaths>
+    { //tolua_export
+        friend class Singleton<ConfigurablePaths>;
+
+        public:
+            ConfigurablePaths();
+            ~ConfigurablePaths();
+
+            //! Returns the path to the data files as boost::filesystem::path
+            static const boost::filesystem::path& getDataPath()
+                { return getInstance().dataPath_; }
+            //! Returns the path to the external data files as boost::filesystem::path
+            static const boost::filesystem::path& getExternalDataPath()
+                { return getInstance().externalDataPath_; }
+            //! Returns the path to the config files as boost::filesystem::path
+            static const boost::filesystem::path& getConfigPath()
+                { return getInstance().configPath_; }
+            //! Returns the path to the log files as boost::filesystem::path
+            static const boost::filesystem::path& getLogPath()
+                { return getInstance().logPath_; }
+
+            //! Returns the path to the data files as std::string
+            static std::string getDataPathString();
+            //! Returns the path to the external data files as std::string
+            static std::string getExternalDataPathString();
+            //! Returns the path to the config files as std::string
+            static std::string getConfigPathString(); //tolua_export
+            //! Returns the path to the log files as std::string
+            static std::string getLogPathString();
+
+            /**
+            @brief
+                Sets config, log and media path and creates the folders if necessary.
+            @throws
+                GeneralException
+            */
+            void setConfigurablePaths(const ApplicationPaths& applicationPaths);
+
+        private:
+            ConfigurablePaths(const ConfigurablePaths&); //!< Don't use (undefined symbol)
+
+            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
+            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
+            boost::filesystem::path& configPath_;            //!< Path to the config files folder
+            boost::filesystem::path& logPath_;               //!< Path to the log files folder
+
+            static ConfigurablePaths* singletonPtr_s;
+    }; //tolua_export
+} //tolua_export
+
+#endif /* _ConfigurablePaths_H__ */

Modified: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Core.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -53,29 +53,31 @@
 #include "util/Clock.h"
 #include "util/Output.h"
 #include "util/Exception.h"
+#include "util/SignalHandler.h"
 #include "util/output/LogWriter.h"
 #include "util/output/OutputManager.h"
-#include "util/Scope.h"
-#include "util/ScopedSingletonManager.h"
-#include "util/SignalHandler.h"
-#include "PathConfig.h"
-#include "config/CommandLineParser.h"
+#include "core/singleton/Scope.h"
+#include "ApplicationPaths.h"
+#include "ConfigurablePaths.h"
+#include "commandline/CommandLineIncludes.h"
 #include "config/ConfigFileManager.h"
-#include "config/ConfigValueIncludes.h"
-#include "CoreIncludes.h"
-#include "DynLibManager.h"
 #include "GameMode.h"
 #include "GraphicsManager.h"
 #include "GUIManager.h"
-#include "class/Identifier.h"
 #include "Language.h"
+#include "Loader.h"
 #include "LuaState.h"
-#include "command/ConsoleCommand.h"
 #include "command/IOConsole.h"
 #include "command/TclBind.h"
 #include "command/TclThreadManager.h"
 #include "input/InputManager.h"
 #include "object/ObjectList.h"
+#include "module/DynLibManager.h"
+#include "module/ModuleInstance.h"
+#include "module/StaticInitializationManager.h"
+#include "module/PluginManager.h"
+#include "CoreStaticInitializationHandler.h"
+#include "UpdateListener.h"
 
 namespace orxonox
 {
@@ -91,15 +93,14 @@
     SetCommandLineArgument(limitToCPU, 0).information("Limits the program to one CPU/core (1, 2, 3, etc.). Default is off = 0.");
 #endif
 
-    // register Core as an abstract class to avoid problems if the class hierarchy is created within Core-constructor
-    RegisterAbstractClass(Core).inheritsFrom(Class(Configurable));
-
     Core::Core(const std::string& cmdLine)
-        : pathConfig_(NULL)
+        : applicationPaths_(NULL)
+        , configurablePaths_(NULL)
         , dynLibManager_(NULL)
         , signalHandler_(NULL)
         , configFileManager_(NULL)
         , languageInstance_(NULL)
+        , loaderInstance_(NULL)
         , ioConsole_(NULL)
         , tclBind_(NULL)
         , tclThreadManager_(NULL)
@@ -109,53 +110,50 @@
         , guiManager_(NULL)
         , graphicsScope_(NULL)
         , bGraphicsLoaded_(false)
-        , bStartIOConsole_(true)
-        , lastLevelTimestamp_(0)
-        , ogreConfigTimestamp_(0)
-        , bDevMode_(false)
+        , staticInitHandler_(NULL)
+        , pluginManager_(NULL)
+        , rootModule_(NULL)
+        , config_(NULL)
         , destructionHelper_(this)
     {
         orxout(internal_status) << "initializing Core object..." << endl;
 
         // Set the hard coded fixed paths
-        this->pathConfig_ = new PathConfig();
+        this->applicationPaths_ = new ApplicationPaths();
 
         // Create a new dynamic library manager
         this->dynLibManager_ = new DynLibManager();
 
-        // Load modules
-        orxout(internal_info) << "Loading modules:" << endl;
-        const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths();
-        for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
-        {
-            try
-            {
-                this->dynLibManager_->load(*it);
-            }
-            catch (...)
-            {
-                orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl;
-            }
-        }
+        // create handler for static initialization
+        new StaticInitializationManager(); // create singleton
+        this->staticInitHandler_ = new CoreStaticInitializationHandler();
+        StaticInitializationManager::getInstance().addHandler(this->staticInitHandler_);
 
+        // load root module (all libraries which are linked to the executable, including core, network, and orxonox)
+        this->rootModule_ = ModuleInstance::getCurrentModuleInstance();
+        StaticInitializationManager::getInstance().loadModule(this->rootModule_);
+
         // Parse command line arguments AFTER the modules have been loaded (static code!)
         CommandLineParser::parse(cmdLine);
 
         // Set configurable paths like log, config and media
-        this->pathConfig_->setConfigurablePaths();
+        this->configurablePaths_ = new ConfigurablePaths();
+        this->configurablePaths_->setConfigurablePaths(ApplicationPaths::getInstance());
 
-        orxout(internal_info) << "Root path:       " << PathConfig::getRootPathString() << endl;
-        orxout(internal_info) << "Executable path: " << PathConfig::getExecutablePathString() << endl;
-        orxout(internal_info) << "Data path:       " << PathConfig::getDataPathString() << endl;
-        orxout(internal_info) << "Ext. data path:  " << PathConfig::getExternalDataPathString() << endl;
-        orxout(internal_info) << "Config path:     " << PathConfig::getConfigPathString() << endl;
-        orxout(internal_info) << "Log path:        " << PathConfig::getLogPathString() << endl;
-        orxout(internal_info) << "Modules path:    " << PathConfig::getModulePathString() << endl;
+        orxout(internal_info) << "Root path:       " << ApplicationPaths::getRootPathString() << endl;
+        orxout(internal_info) << "Executable path: " << ApplicationPaths::getExecutablePathString() << endl;
+        orxout(internal_info) << "Modules path:    " << ApplicationPaths::getModulePathString() << endl;
+        orxout(internal_info) << "Plugins path:    " << ApplicationPaths::getPluginPathString() << endl;
 
-        // create a signal handler (only active for Linux)
+        orxout(internal_info) << "Data path:       " << ConfigurablePaths::getDataPathString() << endl;
+        orxout(internal_info) << "Ext. data path:  " << ConfigurablePaths::getExternalDataPathString() << endl;
+        orxout(internal_info) << "Config path:     " << ConfigurablePaths::getConfigPathString() << endl;
+        orxout(internal_info) << "Log path:        " << ConfigurablePaths::getLogPathString() << endl;
+
+        // create a signal handler
         // This call is placed as soon as possible, but after the directories are set
         this->signalHandler_ = new SignalHandler();
-        this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");
+        this->signalHandler_->doCatch(ApplicationPaths::getExecutablePathString(), ConfigurablePaths::getLogPathString() + "orxonox_crash.log");
 
 #ifdef ORXONOX_PLATFORM_WINDOWS
         // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
@@ -176,23 +174,21 @@
         orxout(internal_info) << "Loading language:" << endl;
         this->languageInstance_ = new Language();
 
+        // initialize root context
+        Context::setRootContext(new Context(NULL));
+
         // Do this soon after the ConfigFileManager has been created to open up the
         // possibility to configure everything below here
-        RegisterObject(Core);
         orxout(internal_info) << "configuring Core" << endl;
-        this->setConfigValues();
+        this->config_ = new CoreConfig();
 
         // Set the correct log path and rewrite the log file with the correct log levels
-        OutputManager::getInstance().getLogWriter()->setLogDirectory(PathConfig::getLogPathString());
+        OutputManager::getInstance().getLogWriter()->setLogDirectory(ConfigurablePaths::getLogPathString());
 
 #if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
         // Create persistent IO console
-        if (CommandLineParser::getValue("noIOConsole").get<bool>())
+        if (CommandLineParser::getValue("noIOConsole").get<bool>() == false && this->config_->getStartIOConsole())
         {
-            ModifyConfigValue(bStartIOConsole_, tset, false);
-        }
-        if (this->bStartIOConsole_)
-        {
             orxout(internal_info) << "creating IO console" << endl;
             this->ioConsole_ = new IOConsole();
         }
@@ -200,19 +196,27 @@
 
         // creates the class hierarchy for all classes with factories
         orxout(internal_info) << "creating class hierarchy" << endl;
-        IdentifierManager::getInstance().createClassHierarchy();
+        this->staticInitHandler_->initInstances(this->rootModule_);
+        this->staticInitHandler_->setInitInstances(true);
 
+        // Create plugin manager and search for plugins
+        this->pluginManager_ = new PluginManager();
+        this->pluginManager_->findPlugins();
+
+        // Loader
+        this->loaderInstance_ = new Loader();
+
         // Load OGRE excluding the renderer and the render window
         orxout(internal_info) << "creating GraphicsManager:" << endl;
         this->graphicsManager_ = new GraphicsManager(false);
 
         // initialise Tcl
-        this->tclBind_ = new TclBind(PathConfig::getDataPathString());
+        this->tclBind_ = new TclBind(ConfigurablePaths::getDataPathString());
         this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
 
         // Create singletons that always exist (in other libraries)
         orxout(internal_info) << "creating root scope:" << endl;
-        this->rootScope_ = new Scope<ScopeID::Root>();
+        this->rootScope_ = new Scope<ScopeID::ROOT>();
 
         // Generate documentation instead of normal run?
         std::string docFilename;
@@ -236,9 +240,6 @@
     {
         orxout(internal_status) << "destroying Core object..." << endl;
 
-        // Remove us from the object lists again to avoid problems when destroying them
-        this->unregisterObject();
-
         safeObjectDelete(&graphicsScope_);
         safeObjectDelete(&guiManager_);
         safeObjectDelete(&inputManager_);
@@ -247,103 +248,92 @@
         safeObjectDelete(&tclThreadManager_);
         safeObjectDelete(&tclBind_);
         safeObjectDelete(&ioConsole_);
+        safeObjectDelete(&loaderInstance_);
+        safeObjectDelete(&config_);
         safeObjectDelete(&languageInstance_);
         safeObjectDelete(&configFileManager_);
-        ConsoleCommand::destroyAll();
-        Context::setRootContext(NULL);
-        IdentifierManager::getInstance().destroyAllIdentifiers();
         safeObjectDelete(&signalHandler_);
+        safeObjectDelete(&pluginManager_);
+        Context::getRootContext()->unregisterObject(); // unregister context from object lists - otherwise the root context would be destroyed while unloading the root module
+        if (this->rootModule_)
+        {
+            StaticInitializationManager::getInstance().unloadModule(this->rootModule_);
+            this->rootModule_->deleteAllStaticallyInitializedInstances();
+        }
+        if (this->staticInitHandler_)
+            StaticInitializationManager::getInstance().removeHandler(this->staticInitHandler_);
+        Context::destroyRootContext();
+        safeObjectDelete(&rootModule_);
+        safeObjectDelete(&staticInitHandler_);
+        delete &StaticInitializationManager::getInstance();
         safeObjectDelete(&dynLibManager_);
-        safeObjectDelete(&pathConfig_);
+        safeObjectDelete(&configurablePaths_);
+        safeObjectDelete(&applicationPaths_);
 
         orxout(internal_status) << "finished destroying Core object" << endl;
     }
 
-    //! Function to collect the SetConfigValue-macro calls.
-    void Core::setConfigValues()
+    void Core::loadModules()
     {
-        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_,
-                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
-                               OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(),
-                               OutputManager::getInstance().getLogWriter()->configurableMaxLevel_)
-            .description("The maximum level of output shown in the log file")
-            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel);
-        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_,
-                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
-                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(),
-                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_)
-            .description("The maximum level of output shown in the log file for additional contexts")
-            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
-        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_,
-                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
-                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(),
-                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_)
-            .description("Additional output contexts shown in the log file")
-            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);
+        orxout(internal_info) << "Loading modules:" << endl;
 
-        SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
-            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
-            .callback(this, &Core::devModeChanged);
-        SetConfigValue(language_, Language::getInstance().defaultLanguage_)
-            .description("The language of the in game text")
-            .callback(this, &Core::languageChanged);
-        SetConfigValue(bInitRandomNumberGenerator_, true)
-            .description("If true, all random actions are different each time you start the game")
-            .callback(this, &Core::initRandomNumberGenerator);
-        SetConfigValue(bStartIOConsole_, true)
-            .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");
-        SetConfigValue(lastLevelTimestamp_, 0)
-            .description("Timestamp when the last level was started.");
-        SetConfigValue(ogreConfigTimestamp_, 0)
-            .description("Timestamp when the ogre config file was changed.");
-    }
+        const std::vector<std::string>& modulePaths = ApplicationPaths::getInstance().getModulePaths();
+        for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
+        {
+            ModuleInstance* module = new ModuleInstance(*it);
+            this->loadModule(module);
+            this->modules_.push_back(module);
+        }
 
-    /** Callback function for changes in the dev mode that affect debug levels.
-        The function behaves according to these rules:
-        - 'normal' mode is defined based on where the program was launched: if
-          the launch path was the build directory, development mode \c on is
-          normal, otherwise normal means development mode \c off.
-        - Debug levels should not be hard configured (\c config instead of
-          \c tconfig) in non 'normal' mode to avoid strange behaviour.
-        - Changing the development mode from 'normal' to the other state will
-          immediately change the debug levels to predefined values which can be
-          reconfigured with \c tconfig.
-    @note
-        The debug levels for the IOConsole and the InGameConsole can be found
-        in the Shell class. The same rules apply.
-    */
-    void Core::devModeChanged()
-    {
-        // Inform listeners
-        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
-        for (; it != ObjectList<DevModeListener>::end(); ++it)
-            it->devModeChanged(bDevMode_);
+        orxout(internal_info) << "finished loading modules" << endl;
     }
 
-    //! Callback function if the language has changed.
-    void Core::languageChanged()
+    void Core::loadModule(ModuleInstance* module)
     {
-        // Read the translation file after the language was configured
-        Language::getInstance().readTranslatedLanguageFile();
+        orxout(internal_info) << "Loading module " << module->getLibraryName() << "..." << endl;
+
+        try
+        {
+            ModuleInstance::setCurrentModuleInstance(module);
+            DynLib* dynLib = this->dynLibManager_->load(module->getLibraryName());
+            module->setDynLib(dynLib);
+
+            StaticInitializationManager::getInstance().loadModule(module);
+        }
+        catch (...)
+        {
+            orxout(user_error) << "Couldn't load module \"" << module->getLibraryName() << "\": " << Exception::handleMessage() << endl;
+        }
     }
 
-    void Core::initRandomNumberGenerator()
+    void Core::unloadModules()
     {
-        static bool bInitialized = false;
-        if (!bInitialized && this->bInitRandomNumberGenerator_)
+        for (std::list<ModuleInstance*>::iterator it = this->modules_.begin(); it != this->modules_.end(); ++it)
         {
-            srand(static_cast<unsigned int>(time(0)));
-            rand();
-            bInitialized = true;
+            ModuleInstance* module = (*it);
+            this->unloadModule(module);
+            delete module;
         }
+        this->modules_.clear();
     }
 
+    void Core::unloadModule(ModuleInstance* module)
+    {
+        orxout(internal_info) << "Unloading module " << module->getLibraryName() << "..." << endl;
+
+        StaticInitializationManager::getInstance().unloadModule(module);
+
+        module->deleteAllStaticallyInitializedInstances();
+        this->dynLibManager_->unload(module->getDynLib());
+        module->setDynLib(NULL);
+    }
+
     void Core::loadGraphics()
     {
         orxout(internal_info) << "loading graphics in Core" << endl;
 
         // Any exception should trigger this, even in upgradeToGraphics (see its remarks)
-        Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics);
+        Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics, true);
 
         // Upgrade OGRE to receive a render window
         try
@@ -384,17 +374,20 @@
 
         // Create singletons associated with graphics (in other libraries)
         orxout(internal_info) << "creating graphics scope:" << endl;
-        graphicsScope_ = new Scope<ScopeID::Graphics>();
+        graphicsScope_ = new Scope<ScopeID::GRAPHICS>();
 
         unloader.Dismiss();
 
         orxout(internal_info) << "finished loading graphics in Core" << endl;
     }
 
-    void Core::unloadGraphics()
+    void Core::unloadGraphics(bool loadGraphicsManagerWithoutRenderer)
     {
         orxout(internal_info) << "unloading graphics in Core" << endl;
 
+        if (this->graphicsManager_)
+            this->graphicsManager_->unloadDebugOverlay();
+
         safeObjectDelete(&graphicsScope_);
         safeObjectDelete(&guiManager_);
         safeObjectDelete(&inputManager_);
@@ -402,7 +395,10 @@
 
         // Load Ogre::Root again, but without the render system
         try
-            { this->graphicsManager_ = new GraphicsManager(false); }
+        {
+            if (loadGraphicsManagerWithoutRenderer)
+                this->graphicsManager_ = new GraphicsManager(false);
+        }
         catch (...)
         {
             orxout(user_error) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << endl
@@ -415,12 +411,6 @@
         GameMode::bShowsGraphics_s = false;
     }
 
-    //! Sets the language in the config-file back to the default.
-    void Core::resetLanguage()
-    {
-        ResetConfigValue(language_);
-    }
-
     /**
     @note
         The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
@@ -469,16 +459,15 @@
 
     void Core::preUpdate(const Clock& time)
     {
-        // Update singletons before general ticking
-        ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
+        // Update UpdateListeners before general ticking
+        for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it)
+            it->preUpdate(time);
         if (this->bGraphicsLoaded_)
         {
             // Process input events
             this->inputManager_->preUpdate(time);
             // Update GUI
             this->guiManager_->preUpdate(time);
-            // Update singletons before general ticking
-            ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
         }
         // Process console events and status line
         if (this->ioConsole_ != NULL)
@@ -489,32 +478,13 @@
 
     void Core::postUpdate(const Clock& time)
     {
-        // Update singletons just before rendering
-        ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
+        // Update UpdateListeners just before rendering
+        for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it)
+            it->postUpdate(time);
         if (this->bGraphicsLoaded_)
         {
-            // Update singletons just before rendering
-            ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);
             // Render (doesn't throw)
             this->graphicsManager_->postUpdate(time);
         }
     }
-
-    void Core::updateLastLevelTimestamp()
-    {
-        ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));
-    }
-
-    void Core::updateOgreConfigTimestamp()
-    {
-        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
-    }
-
-
-    RegisterAbstractClass(DevModeListener).inheritsFrom(Class(Listable));
-
-    DevModeListener::DevModeListener()
-    {
-        RegisterObject(DevModeListener);
-    }
 }

Modified: code/trunk/src/libraries/core/Core.h
===================================================================
--- code/trunk/src/libraries/core/Core.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Core.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -46,29 +46,19 @@
 #include <string>
 #include "util/DestructionHelper.h"
 #include "util/Singleton.h"
-#include "config/Configurable.h"
+#include "CoreConfig.h"
 
 namespace orxonox
 {
-    //! Informs about changes in the Development Mode.
-    class DevModeListener : virtual public Listable
-    {
-    public:
-        DevModeListener();
-        virtual ~DevModeListener() {}
-        virtual void devModeChanged(bool value) = 0;
-    };
-
     /**
     @brief
         The Core class is a singleton used to configure the program basics.
     @remark
         You should only create this singleton once because it destroys the identifiers!
     */
-    class _CoreExport Core : public Singleton<Core>, public Configurable
+    class _CoreExport Core : public Singleton<Core>
     {
         friend class Singleton<Core>;
-        friend class Game;
 
         public:
             /**
@@ -85,67 +75,55 @@
             /// Destructor that also executes when the object fails to construct
             void destroy();
 
-            void setConfigValues();
+            void preUpdate(const Clock& time);
+            void postUpdate(const Clock& time);
 
-            //! Returns the configured language.
-            const std::string& getLanguage()
-                { return this->language_; }
-            void resetLanguage();
+            void loadGraphics();
+            void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true);
 
-            void updateLastLevelTimestamp();
-            inline long long getLastLevelTimestamp() const
-                { return this->lastLevelTimestamp_; }
+            void loadModules();
+            void unloadModules();
+            void loadModule(ModuleInstance* module);
+            void unloadModule(ModuleInstance* module);
 
-            void updateOgreConfigTimestamp();
-            inline long long getOgreConfigTimestamp() const
-                { return this->ogreConfigTimestamp_; }
+            inline CoreConfig* getConfig() const
+                { return this->config_; }
 
-            //! Developers bit. If returns false, some options are not available as to not confuse the normal user.
-            inline bool inDevMode(void) const
-                { return this->bDevMode_; }
-
         private:
             Core(const Core&); //!< Don't use (undefined symbol)
 
-            void devModeChanged();
-            void languageChanged();
-            void initRandomNumberGenerator();
-
-            void preUpdate(const Clock& time);
-            void postUpdate(const Clock& time);
-
-            void loadGraphics();
-            void unloadGraphics();
-
             void setThreadAffinity(int limitToCPU);
 
-            PathConfig*               pathConfig_;
-            DynLibManager*            dynLibManager_;
-            SignalHandler*            signalHandler_;
-            ConfigFileManager*        configFileManager_;
-            Language*                 languageInstance_;
-            IOConsole*                ioConsole_;
-            TclBind*                  tclBind_;
-            TclThreadManager*         tclThreadManager_;
-            Scope<ScopeID::Root>*     rootScope_;
+            ApplicationPaths*                applicationPaths_;
+            ConfigurablePaths*               configurablePaths_;
+            DynLibManager*                   dynLibManager_;
+            SignalHandler*                   signalHandler_;
+            ConfigFileManager*               configFileManager_;
+            Language*                        languageInstance_;
+            Loader*                          loaderInstance_;
+            IOConsole*                       ioConsole_;
+            TclBind*                         tclBind_;
+            TclThreadManager*                tclThreadManager_;
+            Scope<ScopeID::ROOT>*            rootScope_;
             // graphical
-            GraphicsManager*          graphicsManager_;            //!< Interface to OGRE
-            InputManager*             inputManager_;               //!< Interface to OIS
-            GUIManager*               guiManager_;                 //!< Interface to GUI
-            Scope<ScopeID::Graphics>* graphicsScope_;
+            GraphicsManager*                 graphicsManager_;            //!< Interface to OGRE
+            InputManager*                    inputManager_;               //!< Interface to OIS
+            GUIManager*                      guiManager_;                 //!< Interface to GUI
+            Scope<ScopeID::GRAPHICS>*        graphicsScope_;
+            bool                             bGraphicsLoaded_;
 
-            bool                      bGraphicsLoaded_;
-            std::string               language_;                   //!< The language
-            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
-            bool                      bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
-            long long                 lastLevelTimestamp_;         ///< Timestamp when the last level was started
-            long long                 ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
-            bool                      bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
+            CoreStaticInitializationHandler* staticInitHandler_;
+            PluginManager*                   pluginManager_;
+            ModuleInstance*                  rootModule_;
+            std::list<ModuleInstance*>       modules_;
 
+            /// Helper object that stores the config values
+            CoreConfig*                      config_;
+
             /// Helper object that executes the surrogate destructor destroy()
-            DestructionHelper<Core>   destructionHelper_;
+            DestructionHelper<Core>          destructionHelper_;
 
-            static Core*              singletonPtr_s;
+            static Core*                     singletonPtr_s;
     };
 }
 

Copied: code/trunk/src/libraries/core/CoreConfig.cc (from rev 10623, code/branches/core7/src/libraries/core/CoreConfig.cc)
===================================================================
--- code/trunk/src/libraries/core/CoreConfig.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/CoreConfig.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,154 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CoreConfig.h"
+
+#include "util/output/LogWriter.h"
+#include "util/output/OutputManager.h"
+#include "core/CoreIncludes.h"
+#include "core/config/ConfigValueIncludes.h"
+#include "core/Language.h"
+#include "core/ApplicationPaths.h"
+
+namespace orxonox
+{
+    RegisterClassNoArgs(CoreConfig);
+
+    CoreConfig::CoreConfig()
+        : bDevMode_(false)
+        , bStartIOConsole_(true)
+        , lastLevelTimestamp_(0)
+        , ogreConfigTimestamp_(0)
+    {
+        RegisterObject(CoreConfig);
+        this->setConfigValues();
+    }
+
+    //! Function to collect the SetConfigValue-macro calls.
+    void CoreConfig::setConfigValues()
+    {
+        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_,
+                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+                               OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(),
+                               OutputManager::getInstance().getLogWriter()->configurableMaxLevel_)
+            .description("The maximum level of output shown in the log file")
+            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel);
+        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_,
+                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(),
+                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_)
+            .description("The maximum level of output shown in the log file for additional contexts")
+            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
+        SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_,
+                               OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+                               OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(),
+                               OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_)
+            .description("Additional output contexts shown in the log file")
+            .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);
+
+        SetConfigValue(bDevMode_, ApplicationPaths::buildDirectoryRun())
+            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
+            .callback(this, &CoreConfig::devModeChanged);
+        SetConfigValue(language_, Language::getInstance().defaultLanguage_)
+            .description("The language of the in game text")
+            .callback(this, &CoreConfig::languageChanged);
+        SetConfigValue(bInitRandomNumberGenerator_, true)
+            .description("If true, all random actions are different each time you start the game")
+            .callback(this, &CoreConfig::initRandomNumberGenerator);
+        SetConfigValue(bStartIOConsole_, true)
+            .description("Set to false if you don't want to use the IOConsole (for Lua debugging for instance)");
+        SetConfigValue(lastLevelTimestamp_, 0)
+            .description("Timestamp when the last level was started.");
+        SetConfigValue(ogreConfigTimestamp_, 0)
+            .description("Timestamp when the ogre config file was changed.");
+    }
+
+    /** Callback function for changes in the dev mode that affect debug levels.
+        The function behaves according to these rules:
+        - 'normal' mode is defined based on where the program was launched: if
+          the launch path was the build directory, development mode \c on is
+          normal, otherwise normal means development mode \c off.
+        - Debug levels should not be hard configured (\c config instead of
+          \c tconfig) in non 'normal' mode to avoid strange behaviour.
+        - Changing the development mode from 'normal' to the other state will
+          immediately change the debug levels to predefined values which can be
+          reconfigured with \c tconfig.
+    @note
+        The debug levels for the IOConsole and the InGameConsole can be found
+        in the Shell class. The same rules apply.
+    */
+    void CoreConfig::devModeChanged()
+    {
+        // Inform listeners
+        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
+        for (; it != ObjectList<DevModeListener>::end(); ++it)
+            it->devModeChanged(bDevMode_);
+    }
+
+    //! Callback function if the language has changed.
+    void CoreConfig::languageChanged()
+    {
+        // Read the translation file after the language was configured
+        bool success = Language::getInstance().readTranslatedLanguageFile(this->language_);
+        if (!success)
+        {
+            // Set the language in the config-file back to the default.
+            ResetConfigValue(language_);
+            orxout(internal_info, context::language) << "Reset language to " << this->language_ << '.' << endl;
+        }
+    }
+
+    void CoreConfig::initRandomNumberGenerator()
+    {
+        static bool bInitialized = false;
+        if (!bInitialized && this->bInitRandomNumberGenerator_)
+        {
+            srand(static_cast<unsigned int>(time(0)));
+            rand();
+            bInitialized = true;
+        }
+    }
+
+    void CoreConfig::updateLastLevelTimestamp()
+    {
+        ModifyConfigValue(lastLevelTimestamp_, set, static_cast<long long>(time(NULL)));
+    }
+
+    void CoreConfig::updateOgreConfigTimestamp()
+    {
+        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
+    }
+
+
+    RegisterAbstractClass(DevModeListener).inheritsFrom<Listable>();
+
+    DevModeListener::DevModeListener()
+    {
+        RegisterObject(DevModeListener);
+    }
+}

Copied: code/trunk/src/libraries/core/CoreConfig.h (from rev 10623, code/branches/core7/src/libraries/core/CoreConfig.h)
===================================================================
--- code/trunk/src/libraries/core/CoreConfig.h	                        (rev 0)
+++ code/trunk/src/libraries/core/CoreConfig.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,83 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CoreConfig_H__
+#define _CoreConfig_H__
+
+#include "core/CorePrereqs.h"
+
+#include "core/config/Configurable.h"
+
+namespace orxonox
+{
+    class _CoreExport CoreConfig : virtual public Configurable
+    {
+        public:
+            CoreConfig();
+
+            void setConfigValues();
+
+            //! Developers bit. If returns false, some options are not available as to not confuse the normal user.
+            inline bool inDevMode(void) const
+                { return this->bDevMode_; }
+
+            inline bool getStartIOConsole() const
+                { return this->bStartIOConsole_; }
+
+            void updateLastLevelTimestamp();
+            inline long long getLastLevelTimestamp() const
+                { return this->lastLevelTimestamp_; }
+
+            void updateOgreConfigTimestamp();
+            inline long long getOgreConfigTimestamp() const
+                { return this->ogreConfigTimestamp_; }
+
+        private:
+            void devModeChanged();
+            void languageChanged();
+            void initRandomNumberGenerator();
+
+            bool                      bDevMode_;                   //!< Developers bit. If set to false, some options are not available as to not confuse the normal user.
+            std::string               language_;                   //!< The language
+            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
+            bool                      bStartIOConsole_;            //!< Set to false if you don't want to use the IOConsole
+            long long                 lastLevelTimestamp_;         ///< Timestamp when the last level was started
+            long long                 ogreConfigTimestamp_;        ///< Timestamp wehen the ogre config level was modified
+    };
+
+    //! Informs about changes in the Development Mode.
+    class DevModeListener : virtual public Listable
+    {
+    public:
+        DevModeListener();
+        virtual ~DevModeListener() {}
+        virtual void devModeChanged(bool value) = 0;
+    };
+}
+
+#endif /* _CoreConfig_H__ */

Modified: code/trunk/src/libraries/core/CoreIncludes.h
===================================================================
--- code/trunk/src/libraries/core/CoreIncludes.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/CoreIncludes.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -83,6 +83,7 @@
 #include "class/IdentifierManager.h"
 #include "object/ClassFactory.h"
 #include "object/ObjectList.h"
+#include "module/StaticallyInitializedInstance.h"
 
 // resolve macro conflict on windows
 #if defined(ORXONOX_PLATFORM_WINDOWS)
@@ -125,14 +126,14 @@
     @param ClassName The name of the class
 */
 #define RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) \
-    Identifier& _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)
+    orxonox::SI_I& _##ClassName##Identifier = (*new orxonox::SI_I(orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable)))
 
 /**
     @brief Registers a newly created object in the framework. Has to be called at the beginning of the constructor of @a ClassName.
     @param ClassName The name of the class
 */
 #define RegisterObject(ClassName) \
-    if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeObject(this)) \
+    if (ClassIdentifier<ClassName>::getIdentifier()->initializeObject(this)) \
         return; \
     else \
         ((void)0)
@@ -151,7 +152,7 @@
      * @brief Overload of registerClass() which determines T implicitly by the template argument of the ClassFactory.
      */
     template <class T>
-    inline Identifier& registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)
+    inline Identifier* registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)
     {
         return registerClass<T>(name, static_cast<Factory*>(factory), bLoadable);
     }
@@ -163,13 +164,9 @@
      * @param bLoadable Whether the class is allowed to be loaded through XML
      */
     template <class T>
-    inline Identifier& registerClass(const std::string& name, Factory* factory, bool bLoadable = true)
+    inline Identifier* registerClass(const std::string& name, Factory* factory, bool bLoadable = true)
     {
-        orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl;
-        Identifier* identifier = ClassIdentifier<T>::getIdentifier(name);
-        identifier->setFactory(factory);
-        identifier->setLoadable(bLoadable);
-        return *identifier;
+        return new ClassIdentifier<T>(name, factory, bLoadable);
     }
 
     /**
@@ -210,6 +207,54 @@
     {
         return ClassIdentifier<T>::getIdentifier();
     }
+
+
+
+
+    /**
+     * The static initializer stores the parent classes of this identifier. The corresponding identifiers are later loaded. This prevents identifiers from
+     * being used before they are completely initialized.
+     */
+    class _CoreExport StaticallyInitializedIdentifier : public StaticallyInitializedInstance
+    {
+        template <class T>
+        struct InheritsFromClass : public Identifier::InheritsFrom
+        {
+            virtual Identifier* getParent() const { return Class(T); }
+        };
+
+        public:
+            StaticallyInitializedIdentifier(Identifier* identifier)
+                : StaticallyInitializedInstance(StaticInitialization::IDENTIFIER)
+                , identifier_(identifier)
+            {}
+            ~StaticallyInitializedIdentifier() { delete identifier_; }
+
+            virtual void load()
+            {
+                IdentifierManager::getInstance().addIdentifier(this->identifier_);
+            }
+
+            virtual void unload()
+            {
+                IdentifierManager::getInstance().removeIdentifier(this->identifier_);
+            }
+
+            inline Identifier& getIdentifier()
+                { return *this->identifier_; }
+
+            template <class T>
+            inline StaticallyInitializedIdentifier& inheritsFrom()
+                { this->identifier_->inheritsFrom(new InheritsFromClass<T>()); return *this; }
+
+            inline StaticallyInitializedIdentifier& virtualBase()
+                { this->identifier_->setVirtualBase(true); return *this; }
+
+        private:
+            Identifier* identifier_;
+    };
+
+    typedef StaticallyInitializedIdentifier SI_I;
 }
 
 #endif /* _CoreIncludes_H__ */

Modified: code/trunk/src/libraries/core/CorePrereqs.h
===================================================================
--- code/trunk/src/libraries/core/CorePrereqs.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/CorePrereqs.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -76,6 +76,26 @@
 
 namespace orxonox
 {
+    namespace ScopeID
+    {
+        typedef int Value;
+
+        //!A list of available scopes for the Scope template.
+        static const Value ROOT = 1;
+        static const Value GRAPHICS = 2;
+    }
+
+    namespace StaticInitialization
+    {
+        typedef int Type;
+
+        static const Type STATIC_INITIALIZATION_HANDLER = 1;
+        static const Type IDENTIFIER = 2;
+        static const Type SCOPED_SINGLETON_WRAPPER = 3;
+        static const Type COMMAND_LINE_ARGUMENT = 4;
+        static const Type CONSOLE_COMMAND = 5;
+    }
+
     namespace XMLPort
     {
         enum Mode
@@ -122,6 +142,7 @@
     template <class T, class U>
     T orxonox_cast(U*);
 
+    class ApplicationPaths;
     class BaseObject;
     template <class T>
     class ClassFactory;
@@ -142,10 +163,14 @@
     class ConfigFileManager;
     class ConfigFileSection;
     class Configurable;
+    class ConfigurablePaths;
     class ConfigValueContainer;
     class Context;
     class Core;
+    class CoreConfig;
+    class CoreStaticInitializationHandler;
     class Destroyable;
+    class DestroyLaterManager;
     class DestructionListener;
     class DynLib;
     class DynLibManager;
@@ -153,6 +178,7 @@
     class EventState;
     class Factory;
     class Game;
+    class GameConfig;
     class GameState;
     struct GameStateInfo;
     struct GameStateTreeNode;
@@ -164,10 +190,12 @@
     class Iterator;
     class Language;
     class Listable;
+    class Loader;
     class LuaFunctor;
     class LuaState;
     class MemoryArchive;
     class MemoryArchiveFactory;
+    class ModuleInstance;
     class Namespace;
     class NamespaceNode;
     template <class T>
@@ -181,16 +209,26 @@
     class OgreWindowEventListener;
     class OrxonoxClass;
     class OrxonoxInterface;
-    class PathConfig;
+    class Plugin;
+    class PluginManager;
+    class PluginReference;
     struct ResourceInfo;
+    template <ScopeID::Value>
+    class Scope;
+    class ScopeManager;
+    class ScopedSingletonWrapper;
     class SettingsConfigFile;
+    class StaticallyInitializedInstance;
+    class StaticInitializationHandler;
+    class StaticInitializationManager;
     template <class T>
-    class SmartPtr;
+    class StrongPtr;
     template <class T>
     class SubclassIdentifier;
     class Template;
     class Thread;
     class ThreadPool;
+    class UpdateListener;
     class ViewportEventListener;
     template <class T>
     class WeakPtr;
@@ -209,6 +247,7 @@
     class ArgumentCompletionListElement;
     class CommandEvaluation;
     class ConsoleCommand;
+    class ConsoleCommandManager;
     class Executor;
     template <class T>
     class ExecutorMember;

Copied: code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc (from rev 10623, code/branches/core7/src/libraries/core/CoreStaticInitializationHandler.cc)
===================================================================
--- code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/CoreStaticInitializationHandler.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,136 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CoreStaticInitializationHandler.h"
+
+#include "CoreIncludes.h"
+#include "module/ModuleInstance.h"
+#include "object/Iterator.h"
+#include "class/IdentifierManager.h"
+#include "singleton/ScopeManager.h"
+#include "command/ConsoleCommandManager.h"
+#include "commandline/CommandLineParser.h"
+
+namespace orxonox
+{
+    void CoreStaticInitializationHandler::setupHandler()
+    {
+        // initialize singletons
+        new IdentifierManager();
+        new ScopeManager();
+        new CommandLineParser();
+        new ConsoleCommandManager();
+    }
+
+    void CoreStaticInitializationHandler::shutdownHandler()
+    {
+        delete &ConsoleCommandManager::getInstance();
+        delete &CommandLineParser::getInstance();
+        delete &ScopeManager::getInstance();
+        delete &IdentifierManager::getInstance();
+    }
+
+    void CoreStaticInitializationHandler::loadModule(ModuleInstance* module)
+    {
+        this->loadInstances(module);
+        if (this->bInitInstances_)
+            this->initInstances(module);
+    }
+
+    void CoreStaticInitializationHandler::loadInstances(ModuleInstance* module)
+    {
+        // the order of initialization is important: handlers > identifiers > singletons > everything else
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT);
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
+    }
+
+    void CoreStaticInitializationHandler::initInstances(ModuleInstance* module)
+    {
+        IdentifierManager::getInstance().createClassHierarchy();
+    }
+
+    void CoreStaticInitializationHandler::unloadModule(ModuleInstance* module)
+    {
+        // inverted order of initialization
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::COMMAND_LINE_ARGUMENT);
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::SCOPED_SINGLETON_WRAPPER);
+
+        // until now every object (including singletons) of the unloaded identifiers should have been destroyed in a controlled manner.
+        // every remaining object is now destroyed in random order.
+        this->destroyObjects(module);
+
+        // all objects are gone now and we can unload identifiers
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::STATIC_INITIALIZATION_HANDLER);
+    }
+
+    void CoreStaticInitializationHandler::destroyObjects(ModuleInstance* module)
+    {
+        // collect all identifiers that are about to be unloaded
+        std::set<Identifier*> identifiers;
+        const std::set<StaticallyInitializedInstance*>& instances = module->getInstances(StaticInitialization::IDENTIFIER);
+        for (std::set<StaticallyInitializedInstance*>::const_iterator it = instances.begin(); it != instances.end(); ++it)
+            identifiers.insert(&static_cast<StaticallyInitializedIdentifier*>(*it)->getIdentifier());
+
+        // destroy objects. some objects may survive this at first because they still have strong pointers pointing at them. this is
+        // ok as long as those strong pointers are held by objects that are also about to be destroyed in the same loop. this means
+        // that objects within one module may reference each other by strong pointers. but it is not allowed that objects from another
+        // module (which is not unloaded) uses strong pointers to point at objects inside the unloaded module. this will lead to a crash.
+        for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
+            (*it)->destroyObjects();
+
+        // check if all objects were really destroyed. this is not the case if an object is referenced by a strong pointer from another
+        // module (or if two objects inside this module reference each other). this will lead to a crash and must be fixed (e.g. by
+        // changing object dependencies; or by changing the logic that allows modules to be unloaded).
+        for (std::set<Identifier*>::iterator it = identifiers.begin(); it != identifiers.end(); ++it)
+        {
+            ObjectListBase* objectList = Context::getRootContext()->getObjectList(*it);
+            if (objectList->size() > 0)
+            {
+                orxout(internal_error) << "There are still " << objectList->size() << " objects of type " << (*it)->getName()
+                    << " after unloading the Identifier. This may lead to a crash" << endl;
+            }
+        }
+
+        // destroy object-lists in all contexts
+        for (std::set<Identifier*>::iterator it_identifier = identifiers.begin(); it_identifier != identifiers.end(); ++it_identifier)
+        {
+            // only do this if the Identifier is not a Context itself; otherwise we delete the list we're iterating over
+            if (!(*it_identifier)->isExactlyA(Class(Context)))
+            {
+                // iterate over all contexts
+                for (ObjectList<Context>::iterator it_context = ObjectList<Context>::begin(); it_context != ObjectList<Context>::end(); ++it_context)
+                    it_context->destroyObjectList((*it_identifier));
+            }
+        }
+    }
+}

Copied: code/trunk/src/libraries/core/CoreStaticInitializationHandler.h (from rev 10623, code/branches/core7/src/libraries/core/CoreStaticInitializationHandler.h)
===================================================================
--- code/trunk/src/libraries/core/CoreStaticInitializationHandler.h	                        (rev 0)
+++ code/trunk/src/libraries/core/CoreStaticInitializationHandler.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CoreStaticInitializationHandler_H__
+#define _CoreStaticInitializationHandler_H__
+
+#include "core/CorePrereqs.h"
+
+#include "module/StaticInitializationHandler.h"
+
+namespace orxonox
+{
+    class _CoreExport CoreStaticInitializationHandler : public StaticInitializationHandler
+    {
+        friend class Core;
+
+        public:
+            CoreStaticInitializationHandler() : bInitInstances_(false) {}
+
+            virtual void setupHandler();
+            virtual void shutdownHandler();
+
+            virtual void loadModule(ModuleInstance* module);
+            virtual void unloadModule(ModuleInstance* module);
+
+            inline void setInitInstances(bool bInitInstances)
+                { this->bInitInstances_ = bInitInstances; }
+
+        private:
+            void loadInstances(ModuleInstance* module);
+            void initInstances(ModuleInstance* module);
+
+            void destroyObjects(ModuleInstance* module);
+
+            bool bInitInstances_;
+    };
+}
+
+#endif /* _CoreStaticInitializationHandler_H__ */

Deleted: code/trunk/src/libraries/core/DynLib.cc
===================================================================
--- code/trunk/src/libraries/core/DynLib.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/DynLib.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,148 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#include "DynLib.h"
-
-#include "util/Exception.h"
-
-#ifdef ORXONOX_PLATFORM_WINDOWS
-#  define WIN32_LEAN_AND_MEAN
-#  ifndef NOMINMAX
-#    define NOMINMAX // required to stop windows.h messing up std::min
-#  endif
-#  include <windows.h>
-#endif
-
-#ifdef ORXONOX_PLATFORM_UNIX
-#  include <dlfcn.h>
-#endif
-
-#ifdef ORXONOX_PLATFORM_APPLE
-#   include <OSX/macUtils.h> // OGRE include
-#endif
-
-namespace orxonox
-{
-    //-----------------------------------------------------------------------
-    DynLib::DynLib( const std::string& name )
-    {
-        mName = name;
-#if defined(ORXONOX_PLATFORM_WINDOWS)
-        //altered search path doesn't work with paths with forward slashes
-        std::replace(mName.begin(), mName.end(), '/', '\\');
-#endif
-        m_hInst = NULL;
-    }
-
-    //-----------------------------------------------------------------------
-    DynLib::~DynLib()
-    {
-    }
-
-    //-----------------------------------------------------------------------
-    void DynLib::load()
-    {
-        // Log library load
-        orxout(internal_info) << "Loading module " << mName << endl;
-
-        std::string name = mName;
-#ifdef ORXONOX_PLATFORM_LINUX
-        // dlopen() does not add .so to the filename, like windows does for .dll
-        if (name.substr(name.length() - 3, 3) != ".so")
-           name += ".so";
-#elif defined(ORXONOX_PLATFORM_APPLE)
-        // dlopen() does not add .dylib to the filename, like windows does for .dll
-        if (name.substr(name.length() - 6, 6) != ".dylib")
-            name += ".dylib";
-#elif defined(ORXONOX_PLATFORM_WINDOWS)
-        // Although LoadLibraryEx will add .dll itself when you only specify the library name,
-        // if you include a relative path then it does not. So, add it to be sure.
-        if (name.substr(name.length() - 4, 4) != ".dll")
-            name += ".dll";
-#endif
-
-        m_hInst = (DYNLIB_HANDLE)DYNLIB_LOAD( name.c_str() );
-
-        if (!m_hInst)
-            ThrowException(
-                General,
-                "Could not load dynamic library " + mName +
-                ".  System Error: " + dynlibError());
-    }
-
-    //-----------------------------------------------------------------------
-    void DynLib::unload()
-    {
-        // Log library unload
-        orxout(internal_info) << "Unloading module " << mName << endl;
-
-        if (DYNLIB_UNLOAD( m_hInst ))
-        {
-            ThrowException(
-                General,
-                "Could not unload dynamic library " + mName +
-                ".  System Error: " + dynlibError());
-        }
-
-    }
-
-    //-----------------------------------------------------------------------
-    void* DynLib::getSymbol( const std::string& strName ) const throw()
-    {
-        return (void*)DYNLIB_GETSYM( m_hInst, strName.c_str() );
-    }
-    //-----------------------------------------------------------------------
-    std::string DynLib::dynlibError( void )
-    {
-#if defined(ORXONOX_PLATFORM_WINDOWS)
-        LPVOID lpMsgBuf;
-        FormatMessage(
-            FORMAT_MESSAGE_ALLOCATE_BUFFER |
-            FORMAT_MESSAGE_FROM_SYSTEM |
-            FORMAT_MESSAGE_IGNORE_INSERTS,
-            NULL,
-            GetLastError(),
-            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-            (LPTSTR) &lpMsgBuf,
-            0,
-            NULL
-            );
-        std::string ret = (char*)lpMsgBuf;
-        // Free the buffer.
-        LocalFree( lpMsgBuf );
-        return ret;
-#elif defined(ORXONOX_PLATFORM_UNIX)
-        return std::string(dlerror());
-#else
-        return "";
-#endif
-    }
-}

Deleted: code/trunk/src/libraries/core/DynLib.h
===================================================================
--- code/trunk/src/libraries/core/DynLib.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/DynLib.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,119 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-/**
-    @file
-    @ingroup Management CoreGame
-    @brief Declaration of DynLib which represents a dynamically loaded module.
-*/
-
-#ifndef _Core_DynLib_H__
-#define _Core_DynLib_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-
-#if defined(ORXONOX_PLATFORM_WINDOWS)
-#    define DYNLIB_HANDLE hInstance
-#    define DYNLIB_LOAD( a ) LoadLibraryEx( a, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
-#    define DYNLIB_GETSYM( a, b ) GetProcAddress( a, b )
-#    define DYNLIB_UNLOAD( a ) !FreeLibrary( a )
-
-struct HINSTANCE__;
-typedef struct HINSTANCE__* hInstance;
-
-#elif defined(ORXONOX_PLATFORM_UNIX)
-#    define DYNLIB_HANDLE void*
-#    define DYNLIB_LOAD( a ) dlopen( a, RTLD_LAZY | RTLD_GLOBAL)
-#    define DYNLIB_GETSYM( a, b ) dlsym( a, b )
-#    define DYNLIB_UNLOAD( a ) dlclose( a )
-#endif
-
-namespace orxonox
-{
-    /** %Resource holding data about a dynamic library.
-        @remarks
-            This class holds the data required to get symbols from
-            libraries loaded at run-time (i.e. from DLL's for so's)
-        @author
-            Adrian Cearnãu (cearny at cearny.ro)
-        @since
-            27 January 2002
-    */
-    class _CoreExport DynLib
-    {
-    protected:
-        std::string mName;
-        /// Gets the last loading error
-        std::string dynlibError(void);
-    public:
-        /** Default constructor - used by DynLibManager.
-            @warning
-                Do not call directly
-        */
-        DynLib( const std::string& name );
-
-        /** Default destructor.
-        */
-        ~DynLib();
-
-        /** Load the library
-        */
-        void load();
-        /** Unload the library
-        */
-        void unload();
-        /// Get the name of the library
-        const std::string& getName(void) const { return mName; }
-
-        /**
-            Returns the address of the given symbol from the loaded library.
-            @param
-                strName The name of the symbol to search for
-            @returns
-                If the function succeeds, the returned value is a handle to
-                the symbol.
-            @par
-                If the function fails, the returned value is <b>NULL</b>.
-
-        */
-        void* getSymbol( const std::string& strName ) const throw();
-
-    protected:
-
-        /// Handle to the loaded library.
-        DYNLIB_HANDLE m_hInst;
-    };
-
-}
-
-#endif /* _Core_DynLib_H__ */

Deleted: code/trunk/src/libraries/core/DynLibManager.cc
===================================================================
--- code/trunk/src/libraries/core/DynLibManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/DynLibManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,86 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-#include "DynLibManager.h"
-
-#include "DynLib.h"
-
-namespace orxonox
-{
-    //-----------------------------------------------------------------------
-    //! Static pointer to the singleton
-    DynLibManager* DynLibManager::singletonPtr_s  = 0;
-
-    //-----------------------------------------------------------------------
-    DynLibManager::DynLibManager()
-    {
-    }
-    //-----------------------------------------------------------------------
-    DynLib* DynLibManager::load( const std::string& filename)
-    {
-        DynLibList::iterator i = mLibList.find(filename);
-        if (i != mLibList.end())
-        {
-            return i->second;
-        }
-        else
-        {
-            DynLib* pLib = new DynLib(filename);
-            pLib->load();
-            mLibList[filename] = pLib;
-            return pLib;
-        }
-    }
-    //-----------------------------------------------------------------------
-    void DynLibManager::unload(DynLib* lib)
-    {
-        DynLibList::iterator i = mLibList.find(lib->getName());
-        if (i != mLibList.end())
-        {
-            mLibList.erase(i);
-        }
-        lib->unload();
-        delete lib;
-    }
-    //-----------------------------------------------------------------------
-    DynLibManager::~DynLibManager()
-    {
-        // Unload & delete resources in turn
-        for (DynLibList::iterator it = mLibList.begin(); it != mLibList.end(); ++it)
-        {
-            it->second->unload();
-            delete it->second;
-        }
-
-        // Empty the list
-        mLibList.clear();
-    }
-}

Deleted: code/trunk/src/libraries/core/DynLibManager.h
===================================================================
--- code/trunk/src/libraries/core/DynLibManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/DynLibManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,104 +0,0 @@
-/*
------------------------------------------------------------------------------
-This source file is part of OGRE
-    (Object-oriented Graphics Rendering Engine)
-For the latest info, see http://www.ogre3d.org/
-
-Copyright (c) 2000-2006 Torus Knot Software Ltd
-Also see acknowledgements in Readme.html
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free Software
-Foundation; either version 2 of the License, or (at your option) any later
-version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place - Suite 330, Boston, MA 02111-1307, USA, or go to
-http://www.gnu.org/copyleft/lesser.txt.
-
-You may alternatively use this source under the terms of a specific version of
-the OGRE Unrestricted License provided you have obtained such a license from
-Torus Knot Software Ltd.
------------------------------------------------------------------------------
-*/
-
-// 08/11/2009: Small adjustments for Orxonox by Fabian 'x3n' Landau
-
-/**
-    @file
-    @ingroup Management CoreGame
-    @brief Declaration of DynLibManager, used to load modules at runtime.
-*/
-
-#ifndef _Core_DynLibManager_H__
-#define _Core_DynLibManager_H__
-
-#include "CorePrereqs.h"
-
-#include <map>
-#include <string>
-#include "util/Singleton.h"
-
-namespace orxonox
-{
-    /** Manager for Dynamic-loading Libraries.
-        @remarks
-            This manager keeps a track of all the open dynamic-loading
-            libraries, opens them and returns references to already-open
-            libraries.
-    */
-    class _CoreExport DynLibManager: public Singleton<DynLibManager>
-    {
-        friend class Singleton<DynLibManager>;
-
-        protected:
-            typedef std::map<std::string, DynLib*> DynLibList;
-            DynLibList mLibList;
-
-        public:
-            /**
-            @brief
-                Default constructor.
-            @note
-                Should never be called as the singleton is automatically
-                created during the creation of the Root object.
-            @see
-                Root::Root
-            */
-            DynLibManager();
-
-            /**
-            @brief
-                Default destructor.
-            @see
-                Root::~Root
-            */
-            virtual ~DynLibManager();
-
-            /**
-            @brief
-                Loads the passed library.
-            @param filename
-                The name of the library. The extension can be omitted
-            */
-            DynLib* load(const std::string& filename);
-
-            /**
-            @brief
-                Unloads the passed library.
-            @param lib
-                A pointer to the library object
-            */
-            void unload(DynLib* lib);
-
-        private:
-            static DynLibManager* singletonPtr_s;
-    };
-}
-
-#endif /* _Core_DynLibManager_H__ */

Modified: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/GUIManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -105,9 +105,9 @@
 #include "Game.h"
 #include "GraphicsManager.h"
 #include "LuaState.h"
-#include "PathConfig.h"
+#include "ConfigurablePaths.h"
 #include "Resource.h"
-#include "command/ConsoleCommand.h"
+#include "command/ConsoleCommandIncludes.h"
 #include "input/InputManager.h"
 #include "input/InputState.h"
 #include "input/KeyBinderManager.h"
@@ -254,6 +254,8 @@
     SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
     SetConsoleCommand("toggleGUI", &GUIManager::toggleGUI).defaultValue(1, false).defaultValue(2, false);
 
+    RegisterAbstractClass(GUIManager).inheritsFrom<WindowEventListener>();
+
     /**
     @brief
         Constructs the GUIManager by starting up CEGUI
@@ -328,7 +330,7 @@
 
         // Create our own logger to specify the filepath
         std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
-        ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log");
+        ceguiLogger->setLogFilename(ConfigurablePaths::getLogPathString() + "cegui.log");
         ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
         this->ceguiLogger_ = ceguiLogger.release();
 
@@ -832,7 +834,7 @@
     */
     /*static*/ bool GUIManager::inDevMode()
     {
-         return Core::getInstance().inDevMode();
+         return Core::getInstance().getConfig()->inDevMode();
     }
 
     /**

Modified: code/trunk/src/libraries/core/Game.cc
===================================================================
--- code/trunk/src/libraries/core/Game.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Game.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,14 +44,13 @@
 #include "util/Sleep.h"
 #include "util/SubString.h"
 #include "Core.h"
-#include "CoreIncludes.h"
-#include "config/CommandLineParser.h"
-#include "config/ConfigValueIncludes.h"
+#include "commandline/CommandLineParser.h"
+#include "GameConfig.h"
 #include "GameMode.h"
 #include "GameState.h"
 #include "GraphicsManager.h"
 #include "GUIManager.h"
-#include "command/ConsoleCommand.h"
+#include "command/ConsoleCommandIncludes.h"
 
 namespace orxonox
 {
@@ -81,6 +80,7 @@
         , core_(NULL)
         , bChangingState_(false)
         , bAbort_(false)
+        , config_(NULL)
         , destructionHelper_(this)
     {
         orxout(internal_status) << "initializing Game object..." << endl;
@@ -109,10 +109,10 @@
         // Create the Core
         orxout(internal_info) << "creating Core object:" << endl;
         this->core_ = new Core(cmdLine);
+        this->core_->loadModules();
 
         // Do this after the Core creation!
-        RegisterObject(Game);
-        this->setConfigValues();
+        this->config_ = new GameConfig();
 
         // After the core has been created, we can safely instantiate the GameStates that don't require graphics
         for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
@@ -135,31 +135,20 @@
     {
         orxout(internal_status) << "destroying Game object..." << endl;
 
-        // Remove us from the object lists again to avoid problems when destroying them
-        this->unregisterObject();
-
         assert(loadedStates_.size() <= 1); // Just empty root GameState
         // Destroy all GameStates (shared_ptrs take care of actual destruction)
         constructedStates_.clear();
 
         GameStateFactory::getFactories().clear();
+        safeObjectDelete(&config_);
+        if (this->core_)
+            this->core_->unloadModules();
         safeObjectDelete(&core_);
         safeObjectDelete(&gameClock_);
 
         orxout(internal_status) << "finished destroying Game object..." << endl;
     }
 
-    void Game::setConfigValues()
-    {
-        SetConfigValue(statisticsRefreshCycle_, 250000)
-            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
-        SetConfigValue(statisticsAvgLength_, 1000000)
-            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
-
-        SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50)
-            .description("Sets the desired frame rate (0 for no limit).");
-    }
-
     /**
     @brief
         Main loop of the orxonox game.
@@ -228,7 +217,7 @@
 
             // Limit frame rate
             static bool hasVSync = GameMode::showsGraphics() && GraphicsManager::getInstance().hasVSyncEnabled(); // can be static since changes of VSync currently require a restart
-            if (this->fpsLimit_ > 0 && !hasVSync)
+            if (this->config_->getFpsLimit() > 0 && !hasVSync)
                 this->updateFPSLimiter();
         }
 
@@ -310,11 +299,11 @@
         uint64_t currentRealTime = gameClock_->getRealMicroseconds();
         this->statisticsTickTimes_.back().tickLength += (uint32_t)(currentRealTime - currentTime);
         this->periodTickTime_ += (uint32_t)(currentRealTime - currentTime);
-        if (this->periodTime_ > this->statisticsRefreshCycle_)
+        if (this->periodTime_ > this->config_->getStatisticsRefreshCycle())
         {
             std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
             assert(it != this->statisticsTickTimes_.end());
-            int64_t lastTime = currentTime - this->statisticsAvgLength_;
+            int64_t lastTime = currentTime - this->config_->getStatisticsAvgLength();
             if (static_cast<int64_t>(it->tickTime) < lastTime)
             {
                 do
@@ -332,13 +321,13 @@
             this->avgFPS_ = -1 + static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
             this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
 
-            this->periodTime_ -= this->statisticsRefreshCycle_;
+            this->periodTime_ -= this->config_->getStatisticsRefreshCycle();
         }
     }
 
     void Game::updateFPSLimiter()
     {
-        uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / fpsLimit_);
+        uint64_t nextTime = gameClock_->getMicroseconds() - excessSleepTime_ + static_cast<uint32_t>(1000000.0f / this->config_->getFpsLimit());
         uint64_t currentRealTime = gameClock_->getRealMicroseconds();
         while (currentRealTime < nextTime - minimumSleepTime_)
         {
@@ -528,7 +517,7 @@
             orxout(internal_info) << "loading graphics in Game" << endl;
 
             core_->loadGraphics();
-            Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
+            Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true);
 
             // Construct all the GameStates that require graphics
             for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
@@ -549,7 +538,7 @@
         }
     }
 
-    void Game::unloadGraphics()
+    void Game::unloadGraphics(bool loadGraphicsManagerWithoutRenderer)
     {
         if (GameMode::showsGraphics())
         {
@@ -565,7 +554,7 @@
                     ++it;
             }
 
-            core_->unloadGraphics();
+            core_->unloadGraphics(loadGraphicsManagerWithoutRenderer);
         }
     }
 
@@ -586,7 +575,7 @@
         LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState); (void)LOKI_ANONYMOUS_VARIABLE(scopeGuard);
 
         // If state requires graphics, load it
-        Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
+        Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics, true);
         if (gameStateDeclarations_s[name].bGraphicsMode && !GameMode::showsGraphics())
             this->loadGraphics();
         else
@@ -622,14 +611,11 @@
             orxout(internal_warning) << "There might be potential resource leaks involved! To avoid this, improve exception-safety." << endl;
         }
         // Check if graphics is still required
-        if (!bAbort_)
-        {
-            bool graphicsRequired = false;
-            for (unsigned i = 0; i < loadedStates_.size(); ++i)
-                graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
-            if (!graphicsRequired)
-                this->unloadGraphics();
-        }
+        bool graphicsRequired = false;
+        for (unsigned i = 0; i < loadedStates_.size(); ++i)
+            graphicsRequired |= loadedStates_[i]->getInfo().bGraphicsMode;
+        if (!graphicsRequired)
+            this->unloadGraphics(!this->bAbort_); // if abort is false, that means the game is still running while unloading graphics. in this case we load a graphics manager without renderer (to keep all necessary ogre instances alive)
         this->bChangingState_ = false;
     }
 

Modified: code/trunk/src/libraries/core/Game.h
===================================================================
--- code/trunk/src/libraries/core/Game.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Game.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -49,7 +49,6 @@
 #include "util/Output.h"
 #include "util/DestructionHelper.h"
 #include "util/Singleton.h"
-#include "config/Configurable.h"
 
 /**
 @brief
@@ -81,7 +80,7 @@
 // tolua_begin
     class _CoreExport Game
 // tolua_end
-        : public Singleton<Game>, public Configurable
+        : public Singleton<Game>
     { // tolua_export
         friend class Singleton<Game>;
         typedef std::vector<shared_ptr<GameState> > GameStateVector;
@@ -96,8 +95,6 @@
         /// Destructor that also executes when object fails to construct
         void destroy();
 
-        void setConfigValues();
-
         void setStateHierarchy(const std::string& str);
         shared_ptr<GameState> getState(const std::string& name);
 
@@ -150,7 +147,7 @@
         Game(Game&); // don't mess with singletons
 
         void loadGraphics();
-        void unloadGraphics();
+        void unloadGraphics(bool loadGraphicsManagerWithoutRenderer = true);
 
         void parseStates(std::vector<std::pair<std::string, int> >::const_iterator& it, shared_ptr<GameStateTreeNode> currentNode);
         bool checkState(const std::string& name) const;
@@ -188,10 +185,8 @@
         int                                excessSleepTime_;
         unsigned int                       minimumSleepTime_;
 
-        // config values
-        unsigned int                       statisticsRefreshCycle_;
-        unsigned int                       statisticsAvgLength_;
-        unsigned int                       fpsLimit_;
+        /// Helper object that stores the config values
+        GameConfig*                        config_;
 
         /// Helper object that executes the surrogate destructor destroy()
         DestructionHelper<Game>            destructionHelper_;

Copied: code/trunk/src/libraries/core/GameConfig.cc (from rev 10623, code/branches/core7/src/libraries/core/GameConfig.cc)
===================================================================
--- code/trunk/src/libraries/core/GameConfig.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/GameConfig.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "GameConfig.h"
+#include "core/CoreIncludes.h"
+#include "core/config/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    RegisterClassNoArgs(GameConfig);
+
+    GameConfig::GameConfig()
+    {
+        RegisterObject(GameConfig);
+        this->setConfigValues();
+    }
+
+    void GameConfig::setConfigValues()
+    {
+        SetConfigValue(statisticsRefreshCycle_, 250000)
+            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+        SetConfigValue(statisticsAvgLength_, 1000000)
+            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
+
+        SetConfigValueExternal(fpsLimit_, "GraphicsSettings", "fpsLimit", 50)
+            .description("Sets the desired frame rate (0 for no limit).");
+    }
+}

Copied: code/trunk/src/libraries/core/GameConfig.h (from rev 10623, code/branches/core7/src/libraries/core/GameConfig.h)
===================================================================
--- code/trunk/src/libraries/core/GameConfig.h	                        (rev 0)
+++ code/trunk/src/libraries/core/GameConfig.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _GameConfig_H__
+#define _GameConfig_H__
+
+#include "core/CorePrereqs.h"
+
+#include "core/config/Configurable.h"
+
+namespace orxonox
+{
+    class _CoreExport GameConfig : virtual public Configurable
+    {
+        public:
+            GameConfig();
+
+            void setConfigValues();
+
+            inline unsigned int getStatisticsRefreshCycle() const
+                { return this->statisticsRefreshCycle_; }
+            inline unsigned int getStatisticsAvgLength() const
+                { return this->statisticsAvgLength_; }
+            inline unsigned int getFpsLimit() const
+                { return this->fpsLimit_; }
+
+        private:
+            // config values
+            unsigned int statisticsRefreshCycle_;
+            unsigned int statisticsAvgLength_;
+            unsigned int fpsLimit_;
+    };
+}
+
+#endif /* _GameConfig_H__ */

Modified: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/GraphicsManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -58,11 +58,12 @@
 #include "GameMode.h"
 #include "GUIManager.h"
 #include "Loader.h"
-#include "PathConfig.h"
+#include "ApplicationPaths.h"
+#include "ConfigurablePaths.h"
 #include "ViewportEventListener.h"
 #include "WindowEventListener.h"
 #include "XMLFile.h"
-#include "command/ConsoleCommand.h"
+#include "command/ConsoleCommandIncludes.h"
 #include "input/InputManager.h"
 
 namespace orxonox
@@ -93,6 +94,8 @@
 
     GraphicsManager* GraphicsManager::singletonPtr_s = 0;
 
+    RegisterAbstractClass(GraphicsManager).inheritsFrom<Configurable>();
+
     GraphicsManager::GraphicsManager(bool bLoadRenderer)
         : ogreWindowEventListener_(new OgreWindowEventListener())
         , renderWindow_(0)
@@ -110,19 +113,19 @@
         this->loadOgreRoot();
 
         // At first, add the root paths of the data directories as resource locations
-        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getDataPathString(), "FileSystem");
+        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getDataPathString(), "FileSystem");
         // Load resources
         resources_.reset(new XMLFile("DefaultResources.oxr"));
         resources_->setLuaSupport(false);
-        Loader::open(resources_.get(), ClassTreeMask(), false);
+        Loader::getInstance().load(resources_.get(), ClassTreeMask(), false);
 
         // Only for runs in the build directory (not installed)
-        if (PathConfig::buildDirectoryRun())
-            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getExternalDataPathString(), "FileSystem");
+        if (ApplicationPaths::buildDirectoryRun())
+            Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getExternalDataPathString(), "FileSystem");
 
         extResources_.reset(new XMLFile("resources.oxr"));
         extResources_->setLuaSupport(false);
-        Loader::open(extResources_.get(), ClassTreeMask(), false);
+        Loader::getInstance().load(extResources_.get(), ClassTreeMask(), false);
 
         if (bLoadRenderer)
         {
@@ -137,8 +140,6 @@
     {
         orxout(internal_status) << "destroying GraphicsManager..." << endl;
 
-        Loader::unload(debugOverlay_.get());
-
         Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_);
         ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
         ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setScreenResolution_name).resetFunction();
@@ -146,8 +147,8 @@
         ModifyConsoleCommand(__CC_GraphicsManager_group, __CC_setVSync_name).resetFunction();
 
         // Undeclare the resources
-        Loader::unload(resources_.get());
-        Loader::unload(extResources_.get());
+        Loader::getInstance().unload(resources_.get());
+        Loader::getInstance().unload(extResources_.get());
 
         safeObjectDelete(&ogreRoot_);
         safeObjectDelete(&ogreLogger_);
@@ -217,8 +218,8 @@
             ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
         }
 
-        boost::filesystem::path ogreConfigFilepath(PathConfig::getConfigPath() / this->ogreConfigFile_);
-        boost::filesystem::path ogreLogFilepath(PathConfig::getLogPath() / this->ogreLogFile_);
+        boost::filesystem::path ogreConfigFilepath(ConfigurablePaths::getConfigPath() / this->ogreConfigFile_);
+        boost::filesystem::path ogreLogFilepath(ConfigurablePaths::getLogPath() / this->ogreLogFile_);
 
         // create a new logManager
         // Ogre::Root will detect that we've already created a Log
@@ -257,13 +258,13 @@
         // Plugin path can have many different locations...
         std::string pluginPath = specialConfig::ogrePluginsDirectory;
 #ifdef DEPENDENCY_PACKAGE_ENABLE
-        if (!PathConfig::buildDirectoryRun())
+        if (!ApplicationPaths::buildDirectoryRun())
         {
 #  if defined(ORXONOX_PLATFORM_WINDOWS)
-            pluginPath = PathConfig::getExecutablePathString();
+            pluginPath = ApplicationPaths::getExecutablePathString();
 #  elif defined(ORXONOX_PLATFORM_APPLE)
             // TODO: Where are the plugins being installed to?
-            pluginPath = PathConfig::getExecutablePathString();
+            pluginPath = ApplicationPaths::getExecutablePathString();
 #  endif
         }
 #endif
@@ -278,7 +279,7 @@
     {
         orxout(internal_info) << "GraphicsManager: Configuring Renderer" << endl;
 
-        bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp();
+        bool updatedConfig = Core::getInstance().getConfig()->getOgreConfigTimestamp() > Core::getInstance().getConfig()->getLastLevelTimestamp();
         if (updatedConfig)
             orxout(user_info)<< "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << endl;
 
@@ -287,7 +288,7 @@
             if (!ogreRoot_->showConfigDialog())
                 ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue canceled.");
             else
-                Core::getInstance().updateOgreConfigTimestamp();
+                Core::getInstance().getConfig()->updateOgreConfigTimestamp();
         }
 
         orxout(internal_info) << "Creating render window" << endl;
@@ -327,9 +328,14 @@
         // Load debug overlay to show info about fps and tick time
         orxout(internal_info) << "Loading Debug Overlay..." << endl;
         debugOverlay_.reset(new XMLFile("debug.oxo"));
-        Loader::open(debugOverlay_.get(), ClassTreeMask(), false);
+        Loader::getInstance().load(debugOverlay_.get(), ClassTreeMask(), false);
     }
 
+    void GraphicsManager::unloadDebugOverlay()
+    {
+        Loader::getInstance().unload(debugOverlay_.get());
+    }
+
     /**
     @note
         A note about the Ogre::FrameListener: Even though we don't use them,
@@ -513,7 +519,7 @@
         {
             GraphicsManager::getInstance().getRenderWindow()->setFullscreen(fullscreen, width, height);
             this->ogreRoot_->saveConfig();
-            Core::getInstance().updateOgreConfigTimestamp();
+            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
             // Also reload the input devices
             InputManager::getInstance().reload();
         }
@@ -531,7 +537,7 @@
         {
             //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
             this->ogreRoot_->saveConfig();
-            Core::getInstance().updateOgreConfigTimestamp();
+            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
         }
 
         return validate;
@@ -547,7 +553,7 @@
         {
             //this->ogreRoot_->getRenderSystem()->reinitialise(); // can't use this that easily, because it recreates the render window, invalidating renderWindow_
             this->ogreRoot_->saveConfig();
-            Core::getInstance().updateOgreConfigTimestamp();
+            Core::getInstance().getConfig()->updateOgreConfigTimestamp();
         }
 
         return validate;
@@ -556,6 +562,6 @@
     void GraphicsManager::printScreen()
     {
         assert(this->renderWindow_);
-        this->renderWindow_->writeContentsToTimestampedFile(PathConfig::getLogPathString() + "screenShot_", ".png");
+        this->renderWindow_->writeContentsToTimestampedFile(ConfigurablePaths::getLogPathString() + "screenShot_", ".png");
     }
 }

Modified: code/trunk/src/libraries/core/GraphicsManager.h
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/GraphicsManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -94,6 +94,7 @@
 
         void upgradeToGraphics();
         void loadDebugOverlay();
+        void unloadDebugOverlay();
         bool rendererLoaded() const { return renderWindow_ != NULL; }
 
         void setCamera(Ogre::Camera* camera);

Modified: code/trunk/src/libraries/core/Language.cc
===================================================================
--- code/trunk/src/libraries/core/Language.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Language.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,8 +36,7 @@
 #include <fstream>
 #include "util/Output.h"
 #include "util/StringUtils.h"
-#include "Core.h"
-#include "PathConfig.h"
+#include "ConfigurablePaths.h"
 
 namespace orxonox
 {
@@ -202,7 +201,7 @@
     {
         orxout(internal_info, context::language) << "Read default language file." << endl;
 
-        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_);
 
         // This creates the file if it's not existing
         std::ofstream createFile;
@@ -246,12 +245,13 @@
 
     /**
         @brief Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object.
+        @return Returns false if the language file couldn't be found.
     */
-    void Language::readTranslatedLanguageFile()
+    bool Language::readTranslatedLanguageFile(const std::string& language)
     {
-        orxout(internal_info, context::language) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << endl;
+        orxout(internal_info, context::language) << "Read translated language file (" << language << ")." << endl;
 
-        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getLanguage());
+        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(language);
 
         // Open the file
         std::ifstream file;
@@ -260,10 +260,8 @@
         if (!file.is_open())
         {
             orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl;
-            orxout(internal_error, context::language) << "Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << endl;
-            Core::getInstance().resetLanguage();
-            orxout(internal_info, context::language) << "Reset language to " << this->defaultLanguage_ << '.' << endl;
-            return;
+            orxout(internal_error, context::language) << "Couldn't open file " << getFilename(language) << " to read the translated language entries!" << endl;
+            return false;
         }
 
         // Iterate through the file and create the LanguageEntries
@@ -290,12 +288,13 @@
                 }
                 else
                 {
-                    orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << endl;
+                    orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(language) << endl;
                 }
             }
         }
 
         file.close();
+        return true;
     }
 
     /**
@@ -305,7 +304,7 @@
     {
         orxout(verbose, context::language) << "Write default language file." << endl;
 
-        const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
+        const std::string& filepath = ConfigurablePaths::getConfigPathString() + getFilename(this->defaultLanguage_);
 
         // Open the file
         std::ofstream file;

Modified: code/trunk/src/libraries/core/Language.h
===================================================================
--- code/trunk/src/libraries/core/Language.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Language.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -160,7 +160,7 @@
     class _CoreExport Language : public Singleton<Language>
     {
         friend class Singleton<Language>;
-        friend class Core;
+        friend class CoreConfig;
 
         public:
             Language();
@@ -173,7 +173,7 @@
             Language(const Language&);
 
             void readDefaultLanguageFile();
-            void readTranslatedLanguageFile();
+            bool readTranslatedLanguageFile(const std::string& language);
             void writeDefaultLanguageFile() const;
             static std::string getFilename(const std::string& language);
             LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry);

Modified: code/trunk/src/libraries/core/Loader.cc
===================================================================
--- code/trunk/src/libraries/core/Loader.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Loader.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -47,97 +47,10 @@
 
 namespace orxonox
 {
-    std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s;
-    ClassTreeMask Loader::currentMask_s;
+    Loader* Loader::singletonPtr_s = 0;
 
-    bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
-    {
-        Loader::add(file, mask);
-        return Loader::load(file, mask, bVerbose);
-    }
-
-    void Loader::close()
-    {
-        Loader::unload();
-        Loader::files_s.clear();
-    }
-
-    void Loader::close(const XMLFile* file)
-    {
-        Loader::unload(file);
-        Loader::remove(file);
-    }
-
-    void Loader::add(const XMLFile* file, const ClassTreeMask& mask)
-    {
-        if (!file)
-            return;
-        Loader::files_s.insert(Loader::files_s.end(), std::pair<const XMLFile*, ClassTreeMask>(file, mask));
-    }
-
-    void Loader::remove(const XMLFile* file)
-    {
-        if (!file)
-            return;
-        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
-        {
-            if (it->first == file)
-            {
-                Loader::files_s.erase(it);
-                break;
-            }
-        }
-    }
-
     /**
     @brief
-        Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
-    @param mask
-        A ClassTreeMask, which defines which types of classes are loaded and which aren't.
-    @param bVerbose
-        Whether the loader is verbose (prints its progress in a low output level) or not.
-    @return
-        Returns true if successful.
-    */
-    bool Loader::load(const ClassTreeMask& mask, bool bVerbose)
-    {
-        bool success = true;
-        for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
-            if (!Loader::load(it->first, it->second * mask, bVerbose))
-                success = false;
-
-        return success;
-    }
-
-    void Loader::unload(const ClassTreeMask& mask)
-    {
-        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); )
-        {
-            if (mask.isIncluded(it->getIdentifier()))
-                (it++)->destroy();
-            else
-                ++it;
-        }
-    }
-
-    /**
-    @brief
-        Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
-    @param mask
-        A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
-    @param bVerbose
-        Whether the loader is verbose (prints its progress in a low output level) or not.
-    @return
-        Returns true if successful.
-    */
-    bool Loader::reload(const ClassTreeMask& mask, bool bVerbose)
-    {
-        Loader::unload(mask);
-        return Loader::load(mask, bVerbose);
-    }
-
-    /**
-    @brief
         Loads the input file, while conforming to the restrictions given by the input ClassTreeMask.
     @param file
         The file to be loaded.
@@ -155,7 +68,7 @@
         if (!file)
             return false;
 
-        Loader::currentMask_s = file->getMask() * mask;
+        this->currentMask_ = file->getMask() * mask;
 
         std::string xmlInput;
 
@@ -188,7 +101,7 @@
                 // Note: we only need this to speed up parsing of level files at the
                 // start of the program.
                 // Assumption: the LevelInfo tag does not use Lua scripting
-                xmlInput = removeLuaTags(xmlInput);
+                xmlInput = Loader::removeLuaTags(xmlInput);
             }
         }
 
@@ -197,12 +110,12 @@
             if(bVerbose)
             {
                 orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl;
-                orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl;
+                orxout(internal_info, context::loader) << "Mask: " << this->currentMask_ << endl;
             }
             else
             {
                 orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl;
-                orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s << endl;
+                orxout(verbose_more, context::loader) << "Mask: " << this->currentMask_ << endl;
             }
 
             ticpp::Document xmlfile(file->getFilename());
@@ -219,7 +132,6 @@
             Namespace* rootNamespace = new Namespace(Context::getRootContext());
             rootNamespace->setLoaderIndentation("    ");
             rootNamespace->setFile(file);
-            rootNamespace->setNamespace(rootNamespace);
             rootNamespace->setRoot(true);
             rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
 
@@ -304,24 +216,6 @@
         }
     }
 
-    /**
-    @brief
-        Reloads the input file, while conforming to the restrictions given by the input ClassTreeMask.
-    @param file
-        The file to be reloaded.
-    @param mask
-        A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
-    @param bVerbose
-        Whether the loader is verbose (prints its progress in a low output level) or not.
-    @return
-        Returns true if successful.
-    */
-    bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
-    {
-        Loader::unload(file, mask);
-        return Loader::load(file, mask, bVerbose);
-    }
-
     bool Loader::getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags)
     {
         // fill map with all Lua tags

Modified: code/trunk/src/libraries/core/Loader.h
===================================================================
--- code/trunk/src/libraries/core/Loader.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Loader.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -43,38 +43,32 @@
 
 #include <map>
 #include <vector>
+
+#include "util/Singleton.h"
 #include "ClassTreeMask.h"
 
 namespace orxonox
 {
-    class _CoreExport Loader
+    class _CoreExport Loader : public Singleton<Loader>
     {
+        friend class Singleton<Loader>;
+
         public:
-            static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
-            static void close();
-            static void close(const XMLFile* file);
+            bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),
+                      bool bVerbose = true, bool bRemoveLuaTags = false);
+            void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
 
-            static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
-            static void remove(const XMLFile* file);
-
-            static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
-            static void unload(const ClassTreeMask& mask = ClassTreeMask());
-            static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
-
-            static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),
-                             bool bVerbose = true, bool bRemoveLuaTags = false);
-            static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
-            static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
-
             static std::string replaceLuaTags(const std::string& text);
             static std::string removeLuaTags(const std::string& text);
 
-            static ClassTreeMask currentMask_s;
+            ClassTreeMask currentMask_;
 
         private:
             static bool getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags);
 
-            static std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_s;
+            std::vector<std::pair<const XMLFile*, ClassTreeMask> > files_;
+
+            static Loader* singletonPtr_s;
     };
 }
 

Modified: code/trunk/src/libraries/core/Namespace.cc
===================================================================
--- code/trunk/src/libraries/core/Namespace.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/Namespace.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -46,7 +46,7 @@
     {
         RegisterObject(Namespace);
 
-        this->setNamespace(SmartPtr<Namespace>(this, false));
+        this->setNamespace(WeakPtr<Namespace>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
     }
 
     Namespace::~Namespace()
@@ -104,7 +104,6 @@
 
     void Namespace::loadObjects(BaseObject* object)
     {
-        object->setNamespace(this);
     }
 
     const BaseObject* Namespace::saveObjects(unsigned int index) const

Deleted: code/trunk/src/libraries/core/PathConfig.cc
===================================================================
--- code/trunk/src/libraries/core/PathConfig.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/PathConfig.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,324 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "PathConfig.h"
-
-#include <cassert>
-#include <cstdlib>
-#include <cstdio>
-#include <vector>
-#include <boost/filesystem.hpp>
-
-#ifdef ORXONOX_PLATFORM_WINDOWS
-#  ifndef WIN32_LEAN_AND_MEAN
-#    define WIN32_LEAN_AND_MEAN
-#  endif
-#  include <windows.h>
-#  undef min
-#  undef max
-#elif defined(ORXONOX_PLATFORM_APPLE)
-#  include <sys/param.h>
-#  include <mach-o/dyld.h>
-#else /* Linux */
-#  include <sys/types.h>
-#  include <unistd.h>
-#endif
-
-#include "SpecialConfig.h"
-#include "util/Output.h"
-#include "util/Exception.h"
-#include "config/CommandLineParser.h"
-
-// Differentiate Boost Filesystem v2 and v3
-#if (BOOST_FILESYSTEM_VERSION < 3)
-#  define BF_LEAF leaf
-#  define BF_GENERIC_STRING string
-#  define BF_NATIVE_STRING file_string
-#else
-#  define BF_LEAF path().filename().string
-#  define BF_GENERIC_STRING generic_string
-#  define BF_NATIVE_STRING string
-#endif
-
-namespace orxonox
-{
-    namespace bf = boost::filesystem;
-
-    //! Static pointer to the singleton
-    PathConfig* PathConfig::singletonPtr_s  = 0;
-
-    SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
-    SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
-
-    PathConfig::PathConfig()
-        : rootPath_(*(new bf::path()))
-        , executablePath_(*(new bf::path()))
-        , modulePath_(*(new bf::path()))
-        , dataPath_(*(new bf::path()))
-        , externalDataPath_(*(new bf::path()))
-        , configPath_(*(new bf::path()))
-        , logPath_(*(new bf::path()))
-        , bBuildDirectoryRun_(false)
-    {
-        //////////////////////////
-        // FIND EXECUTABLE PATH //
-        //////////////////////////
-
-#ifdef ORXONOX_PLATFORM_WINDOWS
-        // get executable module
-        TCHAR buffer[1024];
-        if (GetModuleFileName(NULL, buffer, 1024) == 0)
-            ThrowException(General, "Could not retrieve executable path.");
-
-#elif defined(ORXONOX_PLATFORM_APPLE)
-        char buffer[1024];
-        uint32_t path_len = 1023;
-        if (_NSGetExecutablePath(buffer, &path_len))
-            ThrowException(General, "Could not retrieve executable path.");
-
-#else /* Linux */
-        /* written by Nicolai Haehnle <prefect_ at gmx.net> */
-
-        /* Get our PID and build the name of the link in /proc */
-        char linkname[64]; /* /proc/<pid>/exe */
-        if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)
-        {
-            /* This should only happen on large word systems. I'm not sure
-               what the proper response is here.
-               Since it really is an assert-like condition, aborting the
-               program seems to be in order. */
-            assert(false);
-        }
-
-        /* Now read the symbolic link */
-        char buffer[1024];
-        int ret;
-        ret = readlink(linkname, buffer, 1024);
-        /* In case of an error, leave the handling up to the caller */
-        if (ret == -1)
-            ThrowException(General, "Could not retrieve executable path.");
-
-        /* Ensure proper NUL termination */
-        buffer[ret] = 0;
-#endif
-
-        // Remove executable filename
-        executablePath_ = bf::path(buffer).branch_path();
-
-        /////////////////////
-        // SET MODULE PATH //
-        /////////////////////
-
-        if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))
-        {
-            orxout(internal_info) << "Running from the build tree." << endl;
-            PathConfig::bBuildDirectoryRun_ = true;
-            modulePath_ = specialConfig::moduleDevDirectory;
-        }
-        else
-        {
-
-#ifdef INSTALL_COPYABLE // --> relative paths
-
-            // Also set the root path
-            bf::path relativeExecutablePath(specialConfig::defaultRuntimePath);
-            rootPath_ = executablePath_;
-            while (!bf::equivalent(rootPath_ / relativeExecutablePath, executablePath_) && !rootPath_.empty())
-                rootPath_ = rootPath_.branch_path();
-            if (rootPath_.empty())
-                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
-
-            // Module path is fixed as well
-            modulePath_ = rootPath_ / specialConfig::defaultModulePath;
-
-#else
-
-            // There is no root path, so don't set it at all
-            // Module path is fixed as well
-            modulePath_ = specialConfig::moduleInstallDirectory;
-
-#endif
-        }
-    }
-
-    PathConfig::~PathConfig()
-    {
-        delete &rootPath_;
-        delete &executablePath_;
-        delete &modulePath_;
-        delete &dataPath_;
-        delete &externalDataPath_;
-        delete &configPath_;
-        delete &logPath_;
-    }
-
-    void PathConfig::setConfigurablePaths()
-    {
-        if (bBuildDirectoryRun_)
-        {
-            dataPath_         = specialConfig::dataDevDirectory;
-            configPath_       = specialConfig::configDevDirectory;
-            logPath_          = specialConfig::logDevDirectory;
-
-            // Check for data path override by the command line
-            if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
-                externalDataPath_ = CommandLineParser::getValue("externalDataPath").get<std::string>();
-            else
-                externalDataPath_ = specialConfig::externalDataDevDirectory;
-        }
-        else
-        {
-
-#ifdef INSTALL_COPYABLE // --> relative paths
-
-            // Using paths relative to the install prefix, complete them
-            dataPath_   = rootPath_ / specialConfig::defaultDataPath;
-            configPath_ = rootPath_ / specialConfig::defaultConfigPath;
-            logPath_    = rootPath_ / specialConfig::defaultLogPath;
-
-#else
-
-            dataPath_  = specialConfig::dataInstallDirectory;
-
-            // Get user directory
-#ifdef ORXONOX_PLATFORM_UNIX
-            char* userDataPathPtr(getenv("HOME"));
-#else
-            char* userDataPathPtr(getenv("APPDATA"));
-#endif
-            if (userDataPathPtr == NULL)
-                ThrowException(General, "Could not retrieve user data path.");
-            bf::path userDataPath(userDataPathPtr);
-            userDataPath /= ".orxonox";
-
-            configPath_ = userDataPath / specialConfig::defaultConfigPath;
-            logPath_    = userDataPath / specialConfig::defaultLogPath;
-
-#endif
-
-        }
-
-        // Option to put all the config and log files in a separate folder
-        if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
-        {
-            const std::string& directory(CommandLineParser::getValue("writingPathSuffix").get<std::string>());
-            configPath_ = configPath_ / directory;
-            logPath_    = logPath_    / directory;
-        }
-
-        // Create directories to avoid problems when opening files in non existent folders.
-        std::vector<std::pair<bf::path, std::string> > directories;
-        directories.push_back(std::make_pair(bf::path(configPath_), std::string("config")));
-        directories.push_back(std::make_pair(bf::path(logPath_), std::string("log")));
-
-        for (std::vector<std::pair<bf::path, std::string> >::iterator it = directories.begin();
-            it != directories.end(); ++it)
-        {
-            if (bf::exists(it->first) && !bf::is_directory(it->first))
-            {
-                ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
-                                         Please remove " + it->first.BF_GENERIC_STRING());
-            }
-            if (bf::create_directories(it->first)) // function may not return true at all (bug?)
-            {
-                orxout(internal_info) << "Created " << it->second << " directory" << endl;
-            }
-        }
-    }
-
-    std::vector<std::string> PathConfig::getModulePaths()
-    {
-        std::vector<std::string> modulePaths;
-
-        // We search for helper files with the following extension
-        const std::string& moduleextension = specialConfig::moduleExtension;
-        size_t moduleextensionlength = moduleextension.size();
-
-        // Make sure the path exists, otherwise don't load modules
-        if (!boost::filesystem::exists(modulePath_))
-            return modulePaths;
-
-        boost::filesystem::directory_iterator file(modulePath_);
-        boost::filesystem::directory_iterator end;
-
-        // Iterate through all files
-        while (file != end)
-        {
-            std::string filename = file->BF_LEAF();
-
-            // Check if the file ends with the extension in question
-            if (filename.size() > moduleextensionlength)
-            {
-                if (filename.substr(filename.size() - moduleextensionlength) == moduleextension)
-                {
-                    // We've found a helper file
-                    const std::string& library = filename.substr(0, filename.size() - moduleextensionlength);
-                    modulePaths.push_back(getModulePathString() + library);
-                }
-            }
-            ++file;
-        }
-
-        return modulePaths;
-    }
-
-    /*static*/ std::string PathConfig::getRootPathString()
-    {
-        return getInstance().rootPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getExecutablePathString()
-    {
-        return getInstance().executablePath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getDataPathString()
-    {
-        return getInstance().dataPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getExternalDataPathString()
-    {
-        return getInstance().externalDataPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getConfigPathString()
-    {
-        return getInstance().configPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getLogPathString()
-    {
-        return getInstance().logPath_.BF_GENERIC_STRING() + '/';
-    }
-
-    /*static*/ std::string PathConfig::getModulePathString()
-    {
-        return getInstance().modulePath_.BF_GENERIC_STRING() + '/';
-    }
-}

Deleted: code/trunk/src/libraries/core/PathConfig.h
===================================================================
--- code/trunk/src/libraries/core/PathConfig.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/PathConfig.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,145 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @ingroup Management Resources
-*/
-
-#ifndef _PathConfig_H__
-#define _PathConfig_H__
-
-#include "CorePrereqs.h"
-
-#include <string>
-#include <vector>
-#include "util/Singleton.h"
-
-//tolua_begin
-namespace orxonox
-{
-//tolua_end
-    /**
-    @brief
-        The PathConfig class is a singleton used to configure different paths.
-    @details
-        The class provides information about the data, config, log, executable,
-        root and module path.
-        It determines those by the use of platform specific functions.
-    @remarks
-        Not all paths are always available:
-        - root only when installed copyable
-        - externalData only for development builds in the build tree
-    */
-    class _CoreExport PathConfig //tolua_export
-        : public Singleton<PathConfig>
-    { //tolua_export
-        friend class Singleton<PathConfig>;
-        friend class Core;
-
-        public:
-            /**
-            @brief
-                Retrieves the executable path and sets all hard coded fixed paths (currently only the module path)
-                Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
-                If found it means that this is not an installed run, hence we
-                don't write the logs and config files to ~/.orxonox
-            @throw
-                GeneralException
-            */
-            PathConfig();
-            ~PathConfig();
-
-            //! Returns the path to the root folder as boost::filesystem::path
-            static const boost::filesystem::path& getRootPath()
-                { return getInstance().rootPath_; }
-            //! Returns the path to the executable folder as boost::filesystem::path
-            static const boost::filesystem::path& getExecutablePath()
-                { return getInstance().executablePath_; }
-            //! Returns the path to the data files as boost::filesystem::path
-            static const boost::filesystem::path& getDataPath()
-                { return getInstance().dataPath_; }
-            //! Returns the path to the external data files as boost::filesystem::path
-            static const boost::filesystem::path& getExternalDataPath()
-                { return getInstance().externalDataPath_; }
-            //! Returns the path to the config files as boost::filesystem::path
-            static const boost::filesystem::path& getConfigPath()
-                { return getInstance().configPath_; }
-            //! Returns the path to the log files as boost::filesystem::path
-            static const boost::filesystem::path& getLogPath()
-                { return getInstance().logPath_; }
-            //! Returns the path to the modules as boost::filesystem::path
-            static const boost::filesystem::path& getModulePath()
-                { return getInstance().modulePath_; }
-
-            //! Returns the path to the root folder as std::string
-            static std::string getRootPathString();
-            //! Returns the path to the executable folder as std::string
-            static std::string getExecutablePathString();
-            //! Returns the path to the data files as std::string
-            static std::string getDataPathString();
-            //! Returns the path to the external data files as std::string
-            static std::string getExternalDataPathString();
-            //! Returns the path to the config files as std::string
-            static std::string getConfigPathString(); //tolua_export
-            //! Returns the path to the log files as std::string
-            static std::string getLogPathString();
-            //! Returns the path to the modules as std::string
-            static std::string getModulePathString();
-
-            //! Return true for runs in the build directory (not installed)
-            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
-
-        private:
-            PathConfig(const PathConfig&); //!< Don't use (undefined symbol)
-
-            /**
-            @brief
-                Sets config, log and media path and creates the folders if necessary.
-            @throws
-                GeneralException
-            */
-            void setConfigurablePaths();
-            //! Returns a list with all modules declared by a *.module file in the module folder.
-            std::vector<std::string> getModulePaths();
-
-            //! Path to the parent directory of the ones above if program was installed with relative paths
-            boost::filesystem::path& rootPath_;
-            boost::filesystem::path& executablePath_;        //!< Path to the executable
-            boost::filesystem::path& modulePath_;            //!< Path to the modules
-            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
-            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
-            boost::filesystem::path& configPath_;            //!< Path to the config files folder
-            boost::filesystem::path& logPath_;               //!< Path to the log files folder
-
-            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
-            static PathConfig* singletonPtr_s;
-    }; //tolua_export
-} //tolua_export
-
-#endif /* _PathConfig_H__ */

Copied: code/trunk/src/libraries/core/UpdateListener.cc (from rev 10623, code/branches/core7/src/libraries/core/UpdateListener.cc)
===================================================================
--- code/trunk/src/libraries/core/UpdateListener.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/UpdateListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,40 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "UpdateListener.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RegisterAbstractClass(UpdateListener).inheritsFrom<Listable>();
+
+    UpdateListener::UpdateListener()
+    {
+        RegisterObject(UpdateListener);
+    }
+}

Copied: code/trunk/src/libraries/core/UpdateListener.h (from rev 10623, code/branches/core7/src/libraries/core/UpdateListener.h)
===================================================================
--- code/trunk/src/libraries/core/UpdateListener.h	                        (rev 0)
+++ code/trunk/src/libraries/core/UpdateListener.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _UpdateListener_H__
+#define _UpdateListener_H__
+
+#include "core/CorePrereqs.h"
+
+#include "core/object/Listable.h"
+
+namespace orxonox
+{
+    /**
+     * Inherit from UpdateListener if you need to receive calls before or after the game is ticked. All classes inheriting from UpdateListener
+     * need to be strictly independent of each other and may not rely on a specific order in which all UpdateListeners are called.
+     *
+     * If you do have such a dependency between two UpdateListeners, e.g. A::preUpdate() always needs to be called before B::preUpdate(), then
+     * you need to create a third class C (which inherits from UpdateListener) with the following implementation:
+     * void C::preUpdate()
+     * {
+     *     A::preUpdate();
+     *     B::preUpdate();
+     * }
+     * This is the only way to ensure that A gets called before B. In this example, only C inherits from UpdateListener, while A and B do not.
+     * Instead they receive the update from C.
+     */
+    class _CoreExport UpdateListener : virtual public Listable
+    {
+        public:
+            UpdateListener();
+
+            /// Gets called by Core before the framework is ticked.
+            virtual void preUpdate(const Clock& time) = 0;
+            /// Gets called by Core after the framework was ticked (but before graphics are drawn).
+            virtual void postUpdate(const Clock& time) = 0;
+    };
+}
+
+#endif /* _UpdateListener_H__ */

Modified: code/trunk/src/libraries/core/ViewportEventListener.cc
===================================================================
--- code/trunk/src/libraries/core/ViewportEventListener.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/ViewportEventListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -31,7 +31,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(ViewportEventListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(ViewportEventListener).inheritsFrom<Listable>();
 
     ViewportEventListener::ViewportEventListener()
     {

Modified: code/trunk/src/libraries/core/WindowEventListener.cc
===================================================================
--- code/trunk/src/libraries/core/WindowEventListener.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/WindowEventListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,7 +34,7 @@
     unsigned int WindowEventListener::windowWidth_s  = 0;
     unsigned int WindowEventListener::windowHeight_s = 0;
 
-    RegisterAbstractClass(WindowEventListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(WindowEventListener).inheritsFrom<Listable>();
 
     WindowEventListener::WindowEventListener()
     {

Modified: code/trunk/src/libraries/core/XMLNameListener.cc
===================================================================
--- code/trunk/src/libraries/core/XMLNameListener.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/XMLNameListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -31,7 +31,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(XMLNameListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(XMLNameListener).inheritsFrom<Listable>();
 
     XMLNameListener::XMLNameListener()
     {

Modified: code/trunk/src/libraries/core/XMLPort.cc
===================================================================
--- code/trunk/src/libraries/core/XMLPort.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/XMLPort.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,7 +39,7 @@
     // ################################
     bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier)
     {
-        return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader::currentMask_s.isIncluded(identifier));
+        return ((!this->bApplyLoaderMask_) || identifier->isA(ClassIdentifier<Namespace>::getIdentifier()) || Loader::getInstance().currentMask_.isIncluded(identifier));
     }
 
     XMLPortObjectContainer& XMLPortObjectContainer::port(BaseObject* object, Element& xmlelement, XMLPort::Mode mode)

Modified: code/trunk/src/libraries/core/class/Identifiable.cc
===================================================================
--- code/trunk/src/libraries/core/class/Identifiable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/class/Identifiable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -40,7 +40,7 @@
 
 namespace orxonox
 {
-    RegisterClassNoArgs(Identifiable);
+    RegisterClassNoArgs(Identifiable).virtualBase();
 
     /**
         @brief Constructor: Sets the default values.

Modified: code/trunk/src/libraries/core/class/Identifier.cc
===================================================================
--- code/trunk/src/libraries/core/class/Identifier.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/class/Identifier.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -43,18 +43,26 @@
 
 namespace orxonox
 {
+    bool Identifier::initConfigValues_s = true;
+
     // ###############################
     // ###       Identifier        ###
     // ###############################
     /**
         @brief Constructor: No factory, no object created, new ObjectList and a unique networkID.
     */
-    Identifier::Identifier()
-        : classID_(IdentifierManager::getInstance().getUniqueClassId())
+    Identifier::Identifier(const std::string& name, Factory* factory, bool bLoadable)
     {
-        this->factory_ = 0;
+        orxout(verbose, context::identifier) << "Create identifier for " << name << endl;
+
+        static unsigned int classIDCounter = 0;
+
+        this->classID_ = classIDCounter++;
+        this->name_ = name;
+        this->factory_ = factory;
+        this->bLoadable_ = bLoadable;
         this->bInitialized_ = false;
-        this->bLoadable_ = false;
+        this->bIsVirtualBase_ = false;
 
         this->bHasConfigValues_ = false;
 
@@ -70,6 +78,19 @@
         if (this->factory_)
             delete this->factory_;
 
+        for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)
+            delete (*it);
+
+        // erase this Identifier from all related identifiers
+        for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
+            const_cast<Identifier*>(*it)->children_.erase(this);
+        for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
+            const_cast<Identifier*>(*it)->directChildren_.erase(this);
+        for (std::set<const Identifier*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
+            const_cast<Identifier*>(*it)->parents_.remove(this);
+        for (std::set<const Identifier*>::const_iterator it = this->directChildren_.begin(); it != this->directChildren_.end(); ++it)
+            const_cast<Identifier*>(*it)->directParents_.remove(this);
+
         for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
             delete (it->second);
         for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)
@@ -78,27 +99,7 @@
             delete (it->second);
     }
 
-    /**
-        @brief Sets the name of the class.
-    */
-    void Identifier::setName(const std::string& name)
-    {
-        if (name != this->name_)
-        {
-            this->name_ = name;
-            IdentifierManager::getInstance().addIdentifierToLookupMaps(this);
-        }
-    }
 
-    void Identifier::setFactory(Factory* factory)
-    {
-        if (this->factory_)
-            delete this->factory_;
-
-        this->factory_ = factory;
-    }
-
-
     /**
         @brief Creates an object of the type the Identifier belongs to.
         @return The new object
@@ -125,27 +126,27 @@
     void Identifier::setNetworkID(uint32_t id)
     {
         this->networkID_ = id;
-        IdentifierManager::getInstance().addIdentifierToLookupMaps(this);
+        IdentifierManager::getInstance().addIdentifier(this);    // add with new id
     }
 
     /**
      * @brief Used to define the direct parents of an Identifier of an abstract class.
      */
-    Identifier& Identifier::inheritsFrom(Identifier* directParent)
+    Identifier& Identifier::inheritsFrom(InheritsFrom* directParent)
     {
-        if (this->parents_.empty())
-            this->directParents_.insert(directParent);
+        if (this->directParents_.empty())
+            this->manualDirectParents_.push_back(directParent);
         else
-            orxout(internal_error) << "Trying to add " << directParent->getName() << " as a direct parent of " << this->getName() << " after the latter was already initialized" << endl;
+            orxout(internal_error) << "Trying to manually add direct parent of " << this->getName() << " after the latter was already initialized" << endl;
 
         return *this;
     }
 
     /**
      * @brief Initializes the parents of this Identifier while creating the class hierarchy.
-     * @param identifiers All identifiers that were used to create an instance of this class (including this identifier itself)
+     * @param initializationTrace All identifiers that were recorded while creating an instance of this class (including nested classes and this identifier itself)
      */
-    void Identifier::initializeParents(const std::set<const Identifier*>& identifiers)
+    void Identifier::initializeParents(const std::list<const Identifier*>& initializationTrace)
     {
         if (!IdentifierManager::getInstance().isCreatingHierarchy())
         {
@@ -153,29 +154,14 @@
             return;
         }
 
-        for (std::set<const Identifier*>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it)
-            if (*it != this)
-                this->parents_.insert(*it);
-    }
-
-    /**
-     * @brief Initializes the direct parents of this Identifier while creating the class hierarchy. This is only intended for abstract classes.
-     */
-    void Identifier::initializeDirectParentsOfAbstractClass()
-    {
-        if (!IdentifierManager::getInstance().isCreatingHierarchy())
+        if (this->directParents_.empty())
         {
-            orxout(internal_warning) << "Identifier::initializeDirectParentsOfAbstractClass() created outside of class hierarchy creation" << endl;
-            return;
+            for (std::list<const Identifier*>::const_iterator it = initializationTrace.begin(); it != initializationTrace.end(); ++it)
+                if (*it != this)
+                    this->parents_.push_back(*it);
         }
-
-        // only Identifiable is allowed to have no parents (even tough it's currently not abstract)
-        if (this->directParents_.empty() && !this->isExactlyA(Class(Identifiable)))
-        {
-            orxout(internal_error) << "Identifier " << this->getName() << " / " << this->getTypeidName() << " is marked as abstract but has no direct parents defined" << endl;
-            orxout(internal_error) << "  If this class is not abstract, use RegisterClass(ThisClass);" << endl;
-            orxout(internal_error) << "  If this class is abstract, use RegisterAbstractClass(ThisClass).inheritsFrom(Class(BaseClass));" << endl;
-        }
+        else
+            orxout(internal_error) << "Trying to add parents to " << this->getName() << " after it was already initialized with manual calls to inheritsFrom<Class>()." << endl;
     }
 
     /**
@@ -192,30 +178,56 @@
         if (this->isInitialized())
             return;
 
-        // if no direct parents were defined, initialize them with the set of all parents
-        if (this->directParents_.empty())
+        if (!this->parents_.empty())
+        {
+            // parents defined -> this class was initialized by creating a sample instance and recording the trace of identifiers
+
+            // initialize all parents
+            for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
+                const_cast<Identifier*>(*it)->finishInitialization(); // initialize parent
+
+            // parents of parents are no direct parents of this identifier
             this->directParents_ = this->parents_;
+            for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
+                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                    this->directParents_.remove(*it_parent_parent);
 
-        // initialize all parents before continuing to initialize this identifier
-        for (std::set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
+            this->verifyIdentifierTrace();
+        }
+        else if (!this->manualDirectParents_.empty())
         {
-            Identifier* directParent = const_cast<Identifier*>(*it);
-            directParent->finishInitialization(); // initialize parent
-            this->parents_.insert(directParent);  // direct parent is also a parent
-            this->parents_.insert(directParent->parents_.begin(), directParent->parents_.end()); // parents of direct parent are also parents
+            // no parents defined -> this class was manually initialized by calling inheritsFrom<Class>()
+
+            // initialize all direct parents
+            for (std::list<const InheritsFrom*>::const_iterator it = this->manualDirectParents_.begin(); it != this->manualDirectParents_.end(); ++it)
+            {
+                Identifier* directParent = (*it)->getParent();
+                this->directParents_.push_back(directParent);
+                directParent->finishInitialization(); // initialize parent
+            }
+
+            // direct parents and their parents are also parents of this identifier (but only add them once)
+            for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
+            {
+                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                    this->addIfNotExists(this->parents_, *it_parent_parent);
+                this->addIfNotExists(this->parents_, *it_parent);
+            }
         }
+        else if (!this->isExactlyA(Class(Identifiable)))
+        {
+            // only Identifiable is allowed to have no parents (even tough it's currently not abstract)
+            orxout(internal_error) << "Identifier " << this->getName() << " / " << this->getTypeInfo().name() << " is marked as abstract but has no direct parents defined" << endl;
+            orxout(internal_error) << "  If this class is not abstract, use RegisterClass(ThisClass);" << endl;
+            orxout(internal_error) << "  If this class is abstract, use RegisterAbstractClass(ThisClass).inheritsFrom(Class(BaseClass));" << endl;
+        }
 
-        // parents of parents are no direct parents of this identifier
-        for (std::set<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
-            for (std::set<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
-                this->directParents_.erase(*it_parent_parent);
-
         // tell all parents that this identifier is a child
-        for (std::set<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
+        for (std::list<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it)
             const_cast<Identifier*>(*it)->children_.insert(this);
 
         // tell all direct parents that this identifier is a direct child
-        for (std::set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
+        for (std::list<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
         {
             const_cast<Identifier*>(*it)->directChildren_.insert(this);
 
@@ -227,12 +239,83 @@
     }
 
     /**
+     * Resets all information about the class hierarchy. The identifier is considered uninitialized afterwards.
+     */
+    void Identifier::reset()
+    {
+        this->directParents_.clear();
+        this->parents_.clear();
+        this->directChildren_.clear();
+        this->children_.clear();
+        this->bInitialized_ = false;
+    }
+
+    /**
+     * Verifies if the recorded trace of parent identifiers matches the expected trace according to the class hierarchy. If it doesn't match, the class
+     * hierarchy is likely wrong, e.g. due to wrong inheritsFrom<>() definitions in abstract classes.
+     */
+    void Identifier::verifyIdentifierTrace() const
+    {
+
+        std::list<const Identifier*> expectedIdentifierTrace;
+
+        // if any parent class is virtual, it will be instantiated first, so we need to add them first.
+        for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
+        {
+            if ((*it_parent)->isVirtualBase())
+            {
+                for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                    this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
+                this->addIfNotExists(expectedIdentifierTrace, *it_parent);
+            }
+        }
+
+        // now all direct parents get created recursively. already added identifiers (e.g. virtual base classes) are not added again.
+        for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
+        {
+            for (std::list<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent)
+                this->addIfNotExists(expectedIdentifierTrace, *it_parent_parent);
+            this->addIfNotExists(expectedIdentifierTrace, *it_parent);
+        }
+
+        // check if the expected trace matches the actual trace (which was defined by creating a sample instance)
+        if (expectedIdentifierTrace != this->parents_)
+        {
+            orxout(internal_warning) << this->getName() << " has an unexpected initialization trace:" << endl;
+
+            orxout(internal_warning) << "  Actual trace (after creating a sample instance):" << endl << "    ";
+            for (std::list<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent)
+                orxout(internal_warning) << " " << (*it_parent)->getName();
+            orxout(internal_warning) << endl;
+
+            orxout(internal_warning) << "  Expected trace (according to class hierarchy definitions):" << endl << "    ";
+            for (std::list<const Identifier*>::const_iterator it_parent = expectedIdentifierTrace.begin(); it_parent != expectedIdentifierTrace.end(); ++it_parent)
+                orxout(internal_warning) << " " << (*it_parent)->getName();
+            orxout(internal_warning) << endl;
+
+            orxout(internal_warning) << "  Direct parents (according to class hierarchy definitions):" << endl << "    ";
+            for (std::list<const Identifier*>::const_iterator it_parent = this->directParents_.begin(); it_parent != this->directParents_.end(); ++it_parent)
+                orxout(internal_warning) << " " << (*it_parent)->getName();
+            orxout(internal_warning) << endl;
+        }
+    }
+
+    /**
+     * Adds @param identifierToAdd to @param list if this identifier is not already contained in the list.
+     */
+    void Identifier::addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const
+    {
+        if (std::find(list.begin(), list.end(), identifierToAdd) == list.end())
+            list.push_back(identifierToAdd);
+    }
+
+    /**
         @brief Returns true, if the Identifier is at least of the given type.
         @param identifier The identifier to compare with
     */
     bool Identifier::isA(const Identifier* identifier) const
     {
-        return (identifier == this || (this->parents_.find(identifier) != this->parents_.end()));
+        return (identifier == this || (this->isChildOf(identifier)));
     }
 
     /**
@@ -250,7 +333,7 @@
     */
     bool Identifier::isChildOf(const Identifier* identifier) const
     {
-        return (this->parents_.find(identifier) != this->parents_.end());
+        return (std::find(this->parents_.begin(), this->parents_.end(),  identifier) != this->parents_.end());
     }
 
     /**
@@ -259,7 +342,7 @@
     */
     bool Identifier::isDirectChildOf(const Identifier* identifier) const
     {
-        return (this->directParents_.find(identifier) != this->directParents_.end());
+        return (std::find(this->directParents_.begin(), this->directParents_.end(), identifier) != this->directParents_.end());
     }
 
     /**

Modified: code/trunk/src/libraries/core/class/Identifier.h
===================================================================
--- code/trunk/src/libraries/core/class/Identifier.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/class/Identifier.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -79,8 +79,11 @@
 #include <string>
 #include <typeinfo>
 #include <loki/TypeTraits.h>
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
 
 #include "util/Output.h"
+#include "util/OrxAssert.h"
 #include "core/object/ObjectList.h"
 #include "core/object/Listable.h"
 #include "core/object/Context.h"
@@ -108,16 +111,22 @@
     class _CoreExport Identifier : public Destroyable
     {
         public:
-            Identifier();
+            struct InheritsFrom //! helper class to manually define inheritance
+            {
+                virtual ~InheritsFrom() {}
+                virtual Identifier* getParent() const = 0;
+            };
+
+        public:
+            Identifier(const std::string& name, Factory* factory, bool bLoadable);
             Identifier(const Identifier& identifier); // don't copy
             virtual ~Identifier();
 
             /// Returns the name of the class the Identifier belongs to.
             inline const std::string& getName() const { return this->name_; }
-            void setName(const std::string& name);
 
-            /// Returns the name of the class as it is returned by typeid(T).name()
-            virtual const std::string& getTypeidName() = 0;
+            /// Returns the type_info of the class as it is returned by typeid(T)
+            virtual const std::type_info& getTypeInfo() = 0;
 
             /// Returns the network ID to identify a class through the network.
             inline uint32_t getNetworkID() const { return this->networkID_; }
@@ -126,8 +135,6 @@
             /// Returns the unique ID of the class.
             ORX_FORCEINLINE unsigned int getClassID() const { return this->classID_; }
 
-            /// Sets the Factory.
-            void setFactory(Factory* factory);
             /// Returns true if the Identifier has a Factory.
             inline bool hasFactory() const { return (this->factory_ != 0); }
 
@@ -135,21 +142,30 @@
 
             /// Returns true if the class can be loaded through XML.
             inline bool isLoadable() const { return this->bLoadable_; }
-            /// Set the class to be loadable through XML or not.
-            inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
 
+            /// Returns true if child classes should inherit virtually from this class.
+            inline bool isVirtualBase() const { return this->bIsVirtualBase_; }
+            /// Defines if child classes should inherit virtually from this class.
+            inline void setVirtualBase(bool bIsVirtualBase) { this->bIsVirtualBase_ = bIsVirtualBase; }
+
             /// Returns true if the Identifier was completely initialized.
             inline bool isInitialized() const { return this->bInitialized_; }
 
+            virtual void destroyObjects() = 0;
 
+            virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const = 0;
+
+            static bool initConfigValues_s; // TODO: this is a hack - remove it as soon as possible
+
+
             /////////////////////////////
             ////// Class Hierarchy //////
             /////////////////////////////
-            Identifier& inheritsFrom(Identifier* directParent);
+            Identifier& inheritsFrom(InheritsFrom* directParent);
 
-            void initializeParents(const std::set<const Identifier*>& identifiers);
-            void initializeDirectParentsOfAbstractClass();
+            void initializeParents(const std::list<const Identifier*>& initializationTrace);
             void finishInitialization();
+            void reset();
 
             bool isA(const Identifier* identifier) const;
             bool isExactlyA(const Identifier* identifier) const;
@@ -158,35 +174,17 @@
             bool isParentOf(const Identifier* identifier) const;
             bool isDirectParentOf(const Identifier* identifier) const;
 
+            /// Returns the direct parents of the class the Identifier belongs to.
+            inline const std::list<const Identifier*>& getDirectParents() const { return this->directParents_; }
             /// Returns the parents of the class the Identifier belongs to.
-            inline const std::set<const Identifier*>& getParents() const { return this->parents_; }
-            /// Returns the begin-iterator of the parents-list.
-            inline std::set<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); }
-            /// Returns the end-iterator of the parents-list.
-            inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); }
+            inline const std::list<const Identifier*>& getParents() const { return this->parents_; }
 
+            /// Returns the direct children the class the Identifier belongs to.
+            inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }
             /// Returns the children of the class the Identifier belongs to.
             inline const std::set<const Identifier*>& getChildren() const { return this->children_; }
-            /// Returns the begin-iterator of the children-list.
-            inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); }
-            /// Returns the end-iterator of the children-list.
-            inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); }
 
-            /// Returns the direct parents of the class the Identifier belongs to.
-            inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; }
-            /// Returns the begin-iterator of the direct-parents-list.
-            inline std::set<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); }
-            /// Returns the end-iterator of the direct-parents-list.
-            inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); }
 
-            /// Returns the direct children the class the Identifier belongs to.
-            inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }
-            /// Returns the begin-iterator of the direct-children-list.
-            inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); }
-            /// Returns the end-iterator of the direct-children-list.
-            inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); }
-
-
             /////////////////////////
             ///// Config Values /////
             /////////////////////////
@@ -222,23 +220,27 @@
             void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
             XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
 
-
         protected:
             virtual void createSuperFunctionCaller() const = 0;
 
         private:
-            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
-            std::set<const Identifier*> children_;                         //!< The children of the class the Identifier belongs to
+            void verifyIdentifierTrace() const;
+            void addIfNotExists(std::list<const Identifier*>& list, const Identifier* identifierToAdd) const;
 
-            std::set<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to
+            std::list<const InheritsFrom*> manualDirectParents_;            //!< Manually defined direct parents
+            std::list<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to (sorted by their order of initialization)
+            std::list<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to (sorted by their order of initialization)
+
             std::set<const Identifier*> directChildren_;                   //!< The direct children of the class the Identifier belongs to
+            std::set<const Identifier*> children_;                         //!< The children of the class the Identifier belongs to
 
             bool bInitialized_;                                            //!< Is true if the Identifier was completely initialized
             bool bLoadable_;                                               //!< False = it's not permitted to load the object through XML
+            bool bIsVirtualBase_;                                          //!< If true, it is recommended to inherit virtually from this class. This changes the order of initialization of child classes, thus this information is necessary to check the class hierarchy.
             std::string name_;                                             //!< The name of the class the Identifier belongs to
             Factory* factory_;                                             //!< The Factory, able to create new objects of the given class (if available)
             uint32_t networkID_;                                           //!< The network ID to identify a class through the network
-            const unsigned int classID_;                                   //!< Uniquely identifies a class (might not be the same as the networkID_)
+            unsigned int classID_;                                         //!< Uniquely identifies a class (might not be the same as the networkID_)
 
             bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
             std::map<std::string, ConfigValueContainer*> configValues_;    //!< A map to link the string of configurable variables with their ConfigValueContainer
@@ -266,46 +268,58 @@
     template <class T>
     class ClassIdentifier : public Identifier
     {
+        BOOST_STATIC_ASSERT((boost::is_base_of<Identifiable, T>::value));
+
         #ifndef DOXYGEN_SHOULD_SKIP_THIS
           #define SUPER_INTRUSIVE_DECLARATION_INCLUDE
           #include "Super.h"
         #endif
 
         public:
-            static ClassIdentifier<T>* getIdentifier();
-            static ClassIdentifier<T>* getIdentifier(const std::string& name);
+            ClassIdentifier(const std::string& name, Factory* factory, bool bLoadable) : Identifier(name, factory, bLoadable)
+            {
+                OrxVerify(ClassIdentifier<T>::classIdentifier_s == NULL, "Assertion failed in ClassIdentifier of type " << typeid(T).name());
+                ClassIdentifier<T>::classIdentifier_s = this;
 
+                SuperFunctionInitialization<0, T>::initialize(this);
+            }
+            ~ClassIdentifier()
+            {
+                SuperFunctionDestruction<0, T>::destroy(this);
+            }
+
             bool initializeObject(T* object);
 
+            virtual void updateConfigValues(bool updateChildren = true) const;
+
+            virtual const std::type_info& getTypeInfo()
+                { return typeid(T); }
+
+            virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const
+                { return dynamic_cast<T*>(object) != 0; }
+
+            virtual void destroyObjects();
+
+            static ClassIdentifier<T>* getIdentifier();
+
+        private:
+            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
+
             void setConfigValues(T* object, Configurable*) const;
             void setConfigValues(T* object, Identifiable*) const;
 
             void addObjectToList(T* object, Listable*);
             void addObjectToList(T* object, Identifiable*);
 
-            virtual void updateConfigValues(bool updateChildren = true) const;
+            void destroyObjects(Listable*);
+            void destroyObjects(void*);
 
-            virtual const std::string& getTypeidName()
-                { return this->typeidName_; }
+            void destroyObject(Destroyable* object);
+            void destroyObject(void* object);
 
-        private:
-            static void initializeIdentifier();
-
-            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
-            ClassIdentifier()
-            {
-                this->typeidName_ = typeid(T).name();
-                SuperFunctionInitialization<0, T>::initialize(this);
-            }
-            ~ClassIdentifier()
-            {
-                SuperFunctionDestruction<0, T>::destroy(this);
-            }
-
             void updateConfigValues(bool updateChildren, Listable*) const;
             void updateConfigValues(bool updateChildren, Identifiable*) const;
 
-            std::string typeidName_;
             static WeakPtr<ClassIdentifier<T> > classIdentifier_s;
     };
 
@@ -317,50 +331,16 @@
         @return The unique Identifier
     */
     template <class T>
-    inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
+    /*static*/ inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
     {
-        // check if the Identifier already exists
-        if (!ClassIdentifier<T>::classIdentifier_s)
-            ClassIdentifier<T>::initializeIdentifier();
+        if (ClassIdentifier<T>::classIdentifier_s == NULL)
+            ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*) IdentifierManager::getInstance().getIdentifierByTypeInfo(typeid(T));
 
+        OrxVerify(ClassIdentifier<T>::classIdentifier_s != NULL, "Did you forget to register the class of type " << typeid(T).name() << "?");
         return ClassIdentifier<T>::classIdentifier_s;
     }
 
     /**
-        @brief Does the same as getIdentifier() but sets the name if this wasn't done yet.
-        @param name The name of this Identifier
-        @return The Identifier
-    */
-    template <class T>
-    inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)
-    {
-        ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
-        identifier->setName(name);
-        return identifier;
-    }
-
-    /**
-        @brief Assigns the static field for the identifier singleton.
-    */
-    template <class T>
-    /*static */ void ClassIdentifier<T>::initializeIdentifier()
-    {
-        // create a new identifier anyway. Will be deleted if not used.
-        ClassIdentifier<T>* proposal = new ClassIdentifier<T>();
-
-        // Get the entry from the map
-        ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getGloballyUniqueIdentifier(proposal);
-
-        if (ClassIdentifier<T>::classIdentifier_s == proposal)
-            orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was not yet existing and got created." << endl;
-        else
-        {
-            orxout(verbose, context::identifier) << "Requested Identifier for " << proposal->getTypeidName() << " was already existing and got assigned." << endl;
-            delete proposal; // delete proposal (it is not used anymore)
-        }
-    }
-
-    /**
         @brief Adds an object of the given type to the ObjectList.
         @param object The object to add
     */
@@ -374,7 +354,9 @@
         {
             IdentifierManager::getInstance().createdObject(object);
 
-            this->setConfigValues(object, object);
+            if (Identifier::initConfigValues_s)
+                this->setConfigValues(object, object);
+
             return true;
         }
         else
@@ -419,6 +401,50 @@
     }
 
     /**
+     * @brief Destroy all objects of this class (must be Listable).
+     * Destroyables are destroyed with destroy(), all other classes with delete.
+     */
+    template <class T>
+    void ClassIdentifier<T>::destroyObjects()
+    {
+        this->destroyObjects((T*)0);
+    }
+
+    /**
+     * @brief Only searches and destroys objects if is a @ref Listable
+     */
+    template <class T>
+    void ClassIdentifier<T>::destroyObjects(Listable*)
+    {
+        ObjectListBase* objectList = Context::getRootContext()->getObjectList(this);
+        ObjectListElement<T>* begin = static_cast<ObjectListElement<T>*>(objectList->begin());
+        ObjectListElement<T>* end = static_cast<ObjectListElement<T>*>(objectList->end());
+        for (typename ObjectList<T>::iterator it = begin; it != end; )
+            this->destroyObject(*(it++));
+    }
+
+    template <class T>
+    void ClassIdentifier<T>::destroyObjects(void*)
+    {
+        // no action
+    }
+
+    /**
+     * @brief Call 'object->destroy()' for Destroyables and 'delete object' for all other types.
+     */
+    template <class T>
+    void ClassIdentifier<T>::destroyObject(Destroyable* object)
+    {
+        object->destroy();
+    }
+
+    template <class T>
+    void ClassIdentifier<T>::destroyObject(void* object)
+    {
+        delete static_cast<Identifiable*>(object);
+    }
+
+    /**
         @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
     */
     template <class T>
@@ -437,7 +463,7 @@
             this->setConfigValues(*it, *it);
 
         if (updateChildren)
-            for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
+            for (std::set<const Identifier*>::const_iterator it = this->getChildren().begin(); it != this->getChildren().end(); ++it)
                 (*it)->updateConfigValues(false);
     }
 

Modified: code/trunk/src/libraries/core/class/IdentifierManager.cc
===================================================================
--- code/trunk/src/libraries/core/class/IdentifierManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/class/IdentifierManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,62 +36,43 @@
 #include <ostream>
 
 #include "util/StringUtils.h"
-#include "core/CoreIncludes.h"
+#include "core/Core.h"
 #include "core/config/ConfigValueContainer.h"
 #include "core/XMLPort.h"
 #include "core/object/ClassFactory.h"
 
 namespace orxonox
 {
-    /* static */ IdentifierManager& IdentifierManager::getInstance()
-    {
-        static IdentifierManager instance;
-        return instance;
-    }
+    IdentifierManager* IdentifierManager::singletonPtr_s = 0;
 
     IdentifierManager::IdentifierManager()
     {
         this->hierarchyCreatingCounter_s = 0;
-        this->classIDCounter_s = 0;
+        this->recordTraceForIdentifier_ = NULL;
     }
 
     /**
-        @brief Returns an identifier by name and adds it if not available
-        @param proposal A pointer to a newly created identifier for the case of non existence in the map
-        @return The identifier (unique instance)
-    */
-    Identifier* IdentifierManager::getGloballyUniqueIdentifier(Identifier* proposal)
+     * Registers the identifier in all maps of the IdentifierManager.
+     */
+    void IdentifierManager::addIdentifier(Identifier* identifier)
     {
-        const std::string& typeidName = proposal->getTypeidName();
-        std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.find(typeidName);
+        orxout(verbose, context::identifier) << "Adding identifier for " << identifier->getName() << " / " << identifier->getTypeInfo().name() << endl;
 
-        if (it != this->identifierByTypeidName_.end())
-        {
-            // There is already an entry: return it
-            return it->second;
-        }
-        else
-        {
-            // There is no entry: put the proposal into the map and return it
-            this->identifierByTypeidName_[typeidName] = proposal;
-            return proposal;
-        }
+        this->identifiers_.insert(identifier);
+        this->identifierByString_[identifier->getName()] = identifier;
+        this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier;
+        this->identifierByNetworkId_[identifier->getNetworkID()] = identifier;
     }
 
     /**
-     * Registers the identifier in all maps of the IdentifierManager.
+     * Unregisters the identifier from all maps of the IdentifierManager.
      */
-    void IdentifierManager::addIdentifierToLookupMaps(Identifier* identifier)
+    void IdentifierManager::removeIdentifier(Identifier* identifier)
     {
-        const std::string& typeidName = identifier->getTypeidName();
-        if (this->identifierByTypeidName_.find(typeidName) != this->identifierByTypeidName_.end())
-        {
-            this->identifierByString_[identifier->getName()] = identifier;
-            this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier;
-            this->identifierByNetworkId_[identifier->getNetworkID()] = identifier;
-        }
-        else
-            orxout(internal_warning) << "Trying to add an identifier to lookup maps which is not known to IdentifierManager" << endl;
+        this->identifiers_.erase(identifier);
+        this->identifierByString_.erase(identifier->getName());
+        this->identifierByLowercaseString_.erase(getLowercase(identifier->getName()));
+        this->identifierByNetworkId_.erase(identifier->getNetworkID());
     }
 
     /**
@@ -111,24 +92,32 @@
         // iterate over all identifiers, create one instance of each class and initialize the identifiers
         {
             Context temporaryContext(NULL);
-            for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it)
+            for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
             {
-                orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << it->second->getName() << ">-Singleton." << endl;
+                Identifier* identifier = (*it);
+                if (identifier->isInitialized())
+                    continue;
+
+                orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << identifier->getName() << ">-Singleton." << endl;
                 // To initialize the identifier, we create a new object and delete it afterwards.
-                if (it->second->hasFactory())
+                if (identifier->hasFactory())
                 {
-                    this->identifiersOfNewObject_.clear();
-                    Identifiable* temp = it->second->fabricate(&temporaryContext);
-                    if (temp->getIdentifier() != it->second)
-                        orxout(internal_error) << "Newly created object of type " << it->second->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl;
+                    this->identifierTraceOfNewObject_.clear();
+                    this->recordTraceForIdentifier_ = identifier;
+
+                    Identifiable* temp = identifier->fabricate(&temporaryContext);
+
+                    this->recordTraceForIdentifier_ = NULL;
+
+                    if (temp->getIdentifier() != identifier)
+                        orxout(internal_error) << "Newly created object of type " << identifier->getName() << " has unexpected identifier. Did you forget to use RegisterObject(classname)?" << endl;
+
+                    identifier->initializeParents(this->identifierTraceOfNewObject_[temp]);
+
                     delete temp;
-
-                    it->second->initializeParents(this->identifiersOfNewObject_);
                 }
-                else
-                    it->second->initializeDirectParentsOfAbstractClass();
 
-                initializedIdentifiers.insert(it->second);
+                initializedIdentifiers.insert(identifier);
             }
 
             size_t numberOfObjects = temporaryContext.getObjectList<Listable>()->size();
@@ -137,39 +126,85 @@
         }
 
         // finish the initialization of all identifiers
-        for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it)
-        {
-            if (initializedIdentifiers.find(it->second) != initializedIdentifiers.end())
-                it->second->finishInitialization();
-            else
-                orxout(internal_error) << "Identifier was registered late and is not initialized: " << it->second->getName() << " / " << it->second->getTypeidName() << endl;
-        }
+        for (std::set<Identifier*>::const_iterator it = initializedIdentifiers.begin(); it != initializedIdentifiers.end(); ++it)
+            (*it)->finishInitialization();
 
+        // only check class hierarchy in dev mode because it's an expensive operation and it requires a developer to fix detected problems anyway.
+        if (!Core::exists() || Core::getInstance().getConfig()->inDevMode())
+            this->verifyClassHierarchy(initializedIdentifiers);
+
         this->stopCreatingHierarchy();
         orxout(internal_status) << "Finished class-hierarchy creation" << endl;
     }
 
     /**
-        @brief Destroys all Identifiers. Called when exiting the program.
-    */
-    void IdentifierManager::destroyAllIdentifiers()
+     * Verifies if the class hierarchy is consistent with the RTTI.
+     */
+    void IdentifierManager::verifyClassHierarchy(const std::set<Identifier*>& initializedIdentifiers)
     {
-        for (std::map<std::string, Identifier*>::iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it)
-            delete (it->second);
+        // check if there are any uninitialized identifiers remaining
+        for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
+            if (!(*it)->isInitialized())
+                orxout(internal_error) << "Identifier was registered late and is not initialized: " << (*it)->getName() << " / " << (*it)->getTypeInfo().name() << endl;
 
-        this->identifierByTypeidName_.clear();
-        this->identifierByString_.clear();
-        this->identifierByLowercaseString_.clear();
-        this->identifierByNetworkId_.clear();
+        // for all initialized identifiers, check if a sample instance behaves as expected according to the class hierarchy
+        Context temporaryContext(NULL);
+        for (std::set<Identifier*>::const_iterator it1 = initializedIdentifiers.begin(); it1 != initializedIdentifiers.end(); ++it1)
+        {
+            if (!(*it1)->hasFactory())
+                continue;
+
+            Identifiable* temp = (*it1)->fabricate(&temporaryContext);
+
+            for (std::set<Identifier*>::const_iterator it2 = this->identifiers_.begin(); it2 != this->identifiers_.end(); ++it2)
+            {
+                bool isA_AccordingToRtti = (*it2)->canDynamicCastObjectToIdentifierClass(temp);
+                bool isA_AccordingToClassHierarchy = temp->isA((*it2));
+
+                if (isA_AccordingToRtti != isA_AccordingToClassHierarchy)
+                {
+                    orxout(internal_error) << "Class hierarchy does not match RTTI: Class hierarchy claims that " << (*it1)->getName() <<
+                        (isA_AccordingToClassHierarchy ? " is a " : " is not a ") << (*it2)->getName() << " but RTTI says the opposite." << endl;
+                }
+            }
+
+            delete temp;
+        }
+        orxout(internal_info) << "Class hierarchy matches RTTI" << endl;
+
+        size_t numberOfObjects = temporaryContext.getObjectList<Listable>()->size();
+        if (numberOfObjects > 0)
+            orxout(internal_warning) << "There are still " << numberOfObjects << " listables left after creating the class hierarchy" << endl;
     }
 
     /**
+     * @brief Resets all Identifiers.
+     */
+    void IdentifierManager::destroyClassHierarchy()
+    {
+        orxout(internal_status) << "Destroy class-hierarchy" << endl;
+        for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
+            (*it)->reset();
+    }
+
+    /**
      * @brief Notifies the IdentifierManager about a newly created object while creating the class hierarchy.
      */
     void IdentifierManager::createdObject(Identifiable* identifiable)
     {
         if (this->isCreatingHierarchy())
-            this->identifiersOfNewObject_.insert(identifiable->getIdentifier());
+        {
+            if (this->recordTraceForIdentifier_)
+            {
+                std::list<const Identifier*>& traceForObject = this->identifierTraceOfNewObject_[identifiable];
+                if (std::find(traceForObject.begin(), traceForObject.end(), identifiable->getIdentifier()) != traceForObject.end())
+                {
+                    orxout(internal_warning) << this->recordTraceForIdentifier_->getName() << " inherits two times from " <<
+                        identifiable->getIdentifier()->getName() << ". Did you forget to use virtual inheritance?" << endl;
+                }
+                traceForObject.push_back(identifiable->getIdentifier());
+            }
+        }
         else
             orxout(internal_warning) << "createdObject() called outside of class hierarchy creation" << endl;
     }
@@ -217,6 +252,20 @@
     }
 
     /**
+        @brief Returns the Identifier with a given typeid-name.
+        @param name The typeid-name of the wanted Identifier
+        @return The Identifier
+    */
+    Identifier* IdentifierManager::getIdentifierByTypeInfo(const std::type_info& typeInfo)
+    {
+        // TODO: use std::type_index and a map to find identifiers by type_info (only with c++11)
+        for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it)
+            if ((*it)->getTypeInfo() == typeInfo)
+                return (*it);
+        return 0;
+    }
+
+    /**
         @brief Cleans the NetworkID map (needed on clients for correct initialization)
     */
     void IdentifierManager::clearNetworkIDs()

Modified: code/trunk/src/libraries/core/class/IdentifierManager.h
===================================================================
--- code/trunk/src/libraries/core/class/IdentifierManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/class/IdentifierManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,27 +38,31 @@
 
 #include <map>
 #include <set>
+#include <list>
 #include <string>
 
+#include "util/Singleton.h"
+
 namespace orxonox
 {
-    class _CoreExport IdentifierManager
+    class _CoreExport IdentifierManager : public Singleton<IdentifierManager>
     {
+        friend class Singleton<IdentifierManager>;
+
         public:
-            static IdentifierManager& getInstance();
+            IdentifierManager();
+            ~IdentifierManager() {}
 
-            Identifier* getGloballyUniqueIdentifier(Identifier* proposal);
-            void addIdentifierToLookupMaps(Identifier* identifier);
+            void addIdentifier(Identifier* identifier);
+            void removeIdentifier(Identifier* identifier);
 
-            unsigned int getUniqueClassId()
-                { return this->classIDCounter_s++; }
 
-
             /////////////////////////////
             ////// Class Hierarchy //////
             /////////////////////////////
             void createClassHierarchy();
-            void destroyAllIdentifiers();
+            void verifyClassHierarchy(const std::set<Identifier*>& initializedIdentifiers);
+            void destroyClassHierarchy();
 
             void createdObject(Identifiable* identifiable);
 
@@ -73,6 +77,7 @@
             Identifier* getIdentifierByString(const std::string& name);
             Identifier* getIdentifierByLowercaseString(const std::string& name);
             Identifier* getIdentifierByID(uint32_t id);
+            Identifier* getIdentifierByTypeInfo(const std::type_info& typeInfo);
 
             void clearNetworkIDs();
 
@@ -87,9 +92,7 @@
                 { return this->identifierByNetworkId_; }
 
         private:
-            IdentifierManager();
-            IdentifierManager(const IdentifierManager&);
-            ~IdentifierManager() {}
+            IdentifierManager(const IdentifierManager&); // not implemented
 
             /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
             inline void startCreatingHierarchy()
@@ -98,15 +101,19 @@
             inline void stopCreatingHierarchy()
                 { hierarchyCreatingCounter_s--; }
 
-            std::map<std::string, Identifier*> identifierByTypeidName_;      //!< Map with the names as received by typeid(). This is only used internally.
-
+            std::set<Identifier*> identifiers_;                              //!< All identifiers. This is only used internally.
             std::map<std::string, Identifier*> identifierByString_;          //!< Map that stores all Identifiers with their names.
             std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase.
             std::map<uint32_t, Identifier*> identifierByNetworkId_;          //!< Returns the map that stores all Identifiers with their network IDs.
 
             int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
-            std::set<const Identifier*> identifiersOfNewObject_;    //!< Used while creating the object hierarchy to keep track of the identifiers of a newly created object
-            unsigned int classIDCounter_s;                          //!< counter for the unique classIDs
+
+            /// Used while creating the object hierarchy to keep track of the identifiers of a newly created object (and all other objects that get created as
+            /// a consequence of this, e.g. nested member objects).
+            std::map<Identifiable*, std::list<const Identifier*> > identifierTraceOfNewObject_;
+            Identifier* recordTraceForIdentifier_; //!< The identifier for which we want to record the trace of identifiers during object creation. If null, no trace is recorded.
+
+            static IdentifierManager* singletonPtr_s;
     };
 }
 

Modified: code/trunk/src/libraries/core/class/OrxonoxInterface.cc
===================================================================
--- code/trunk/src/libraries/core/class/OrxonoxInterface.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/class/OrxonoxInterface.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -31,7 +31,7 @@
 
 namespace orxonox
 {
-    RegisterClassNoArgs(OrxonoxInterface);
+    RegisterClassNoArgs(OrxonoxInterface).virtualBase();
 
     OrxonoxInterface::OrxonoxInterface()
     {

Modified: code/trunk/src/libraries/core/class/Super.h
===================================================================
--- code/trunk/src/libraries/core/class/Super.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/class/Super.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -273,9 +273,6 @@
     #define SUPER_changedName(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
 
-    #define SUPER_changedGametype(classname, functionname, ...) \
-        SUPER_NOARGS(classname, functionname)
-
     #define SUPER_changedUsed(classname, functionname, ...) \
         SUPER_NOARGS(classname, functionname)
 
@@ -554,22 +551,18 @@
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedUsed, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedCarrier, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedCarrier, false)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, changedPickedUp, false)
             ()
         SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
 
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedPickedUp, false)
-            ()
-        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
-
         // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
 
 }
@@ -622,7 +615,6 @@
     SUPER_INTRUSIVE_DECLARATION(changedOwner);
     SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
     SUPER_INTRUSIVE_DECLARATION(changedName);
-    SUPER_INTRUSIVE_DECLARATION(changedGametype);
     SUPER_INTRUSIVE_DECLARATION(changedUsed);
     SUPER_INTRUSIVE_DECLARATION(changedCarrier);
     SUPER_INTRUSIVE_DECLARATION(changedPickedUp);

Modified: code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -43,6 +43,7 @@
 #include "core/config/ConfigValueContainer.h"
 #include "CommandExecutor.h"
 #include "ConsoleCommand.h"
+#include "ConsoleCommandManager.h"
 #include "TclThreadManager.h"
 
 // Differentiate Boost Filesystem v2 and v3
@@ -97,7 +98,7 @@
                 std::string fragmentLC = getLowercase(fragment);
 
                 // get all the groups that are visible (except the shortcut group "")
-                const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommand::getCommands();
+                const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommandManager::getInstance().getCommands();
                 for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
                     if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0))
                         groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
@@ -136,13 +137,13 @@
                 std::string groupLC = getLowercase(group);
 
                 // find the iterator of the given group
-                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommands().begin();
-                for ( ; it_group != ConsoleCommand::getCommands().end(); ++it_group)
+                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().begin();
+                for ( ; it_group != ConsoleCommandManager::getInstance().getCommands().end(); ++it_group)
                     if (getLowercase(it_group->first) == groupLC)
                         break;
 
                 // add all commands in the group to the list
-                if (it_group != ConsoleCommand::getCommands().end())
+                if (it_group != ConsoleCommandManager::getInstance().getCommands().end())
                 {
                     for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
                         if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden)
@@ -205,19 +206,19 @@
             if (tokens.size() == 0)
                 return detail::_groupsandcommands(fragment, true);
 
-            if (ConsoleCommand::getCommandLC(getLowercase(tokens[0])))
+            if (ConsoleCommandManager::getInstance().getCommandLC(getLowercase(tokens[0])))
                 return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
 
             if (tokens.size() == 1)
             {
-                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommands().find(tokens[0]);
-                if (it_group != ConsoleCommand::getCommands().end())
+                std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommands().find(tokens[0]);
+                if (it_group != ConsoleCommandManager::getInstance().getCommands().end())
                     return detail::_subcommands(fragment, tokens[0], true);
                 else
                     return detail::_groupsandcommands(fragment, true);
             }
 
-            if (ConsoleCommand::getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))
+            if (ConsoleCommandManager::getInstance().getCommandLC(getLowercase(tokens[0]), getLowercase(tokens[1])))
                 return ARGUMENT_COMPLETION_FUNCTION_CALL(command)(fragment);
 
             return ArgumentCompletionList();

Modified: code/trunk/src/libraries/core/command/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/command/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -3,6 +3,8 @@
   CommandExecutor.cc
   ConsoleCommand.cc
   ConsoleCommandCompilation.cc
+  ConsoleCommandIncludes.cc
+  ConsoleCommandManager.cc
   Executor.cc
   IOConsole.cc
   IRC.cc

Modified: code/trunk/src/libraries/core/command/CommandEvaluation.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandEvaluation.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/CommandEvaluation.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,6 +36,7 @@
 #include "util/StringUtils.h"
 #include "CommandExecutor.h"
 #include "ConsoleCommand.h"
+#include "ConsoleCommandManager.h"
 
 namespace orxonox
 {
@@ -304,7 +305,7 @@
             {
                 // the user typed 1-2 arguments, check what he tried to type and print a suitable error
                 std::string groupLC = getLowercase(this->getToken(0));
-                for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)
+                for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
                     if (it_group->first == groupLC)
                         return std::string("Error: There is no command in group \"") + this->getToken(0) + "\" starting with \"" + this->getToken(1) + "\".";
 
@@ -326,7 +327,7 @@
         unsigned int nearestDistance = (unsigned int)-1;
 
         // iterate through all groups and their commands and calculate the distance to the current command. keep the best.
-        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().begin(); it_group != ConsoleCommand::getCommandsLC().end(); ++it_group)
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().begin(); it_group != ConsoleCommandManager::getInstance().getCommandsLC().end(); ++it_group)
         {
             if (it_group->first != "")
             {
@@ -344,8 +345,8 @@
         }
 
         // now also iterate through all shortcuts and keep the best if it's better than the one found above.
-        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandsLC().find("");
-        if (it_group !=  ConsoleCommand::getCommandsLC().end())
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommandManager::getInstance().getCommandsLC().find("");
+        if (it_group !=  ConsoleCommandManager::getInstance().getCommandsLC().end())
         {
             for (std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); ++it_name)
             {

Modified: code/trunk/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandExecutor.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/CommandExecutor.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -33,7 +33,7 @@
 
 #include "CommandExecutor.h"
 
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclBind.h"
 #include "Shell.h"
 
@@ -154,19 +154,19 @@
         evaluation.initialize(command);
 
         // assign the fallback-command to get hints about the possible commands and groups
-        evaluation.hintCommand_ = ConsoleCommand::getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name);
+        evaluation.hintCommand_ = ConsoleCommandManager::getInstance().getCommand(__CC_CommandExecutor_name, __CC_autocomplete_name);
 
         // check if there's at least one argument
         if (evaluation.getNumberOfArguments() >= 1)
         {
             // try to get a command from the first token
-            evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0));
+            evaluation.execCommand_ = ConsoleCommandManager::getInstance().getCommandLC(evaluation.getToken(0));
             if (evaluation.execCommand_)
                 evaluation.execArgumentsOffset_ = 1;
             else if (evaluation.getNumberOfArguments() >= 2)
             {
                 // try to get a command from the first two tokens
-                evaluation.execCommand_ = ConsoleCommand::getCommandLC(evaluation.getToken(0), evaluation.getToken(1));
+                evaluation.execCommand_ = ConsoleCommandManager::getInstance().getCommandLC(evaluation.getToken(0), evaluation.getToken(1));
                 if (evaluation.execCommand_)
                     evaluation.execArgumentsOffset_ = 2;
             }
@@ -287,7 +287,7 @@
             SubString tokens(alias, " ");
 
             // check if the alias already exists - print an error and return if it does
-            if ((tokens.size() == 1 && ConsoleCommand::getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommand::getCommand(tokens[0], tokens[1])))
+            if ((tokens.size() == 1 && ConsoleCommandManager::getInstance().getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommandManager::getInstance().getCommand(tokens[0], tokens[1])))
             {
                 orxout(user_error) << "A command with name \"" << alias << "\" already exists." << endl;
                 return;
@@ -295,9 +295,9 @@
 
             // create a new console command with the given alias as its name
             if (tokens.size() == 1)
-                createConsoleCommand(tokens[0], executor);
+                ConsoleCommandManager::getInstance().registerCommand(new ConsoleCommand(tokens[0], executor));
             else if (tokens.size() == 2)
-                createConsoleCommand(tokens[0], tokens[1], executor);
+                ConsoleCommandManager::getInstance().registerCommand(new ConsoleCommand(tokens[0], tokens[1], executor));
             else
                 orxout(user_error) << "\"" << alias << "\" is not a valid alias name (must have one or two words)." << endl;
         }

Modified: code/trunk/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,16 +34,27 @@
 #include "ConsoleCommand.h"
 
 #include "util/Convert.h"
-#include "util/StringUtils.h"
 #include "core/Language.h"
 #include "core/GameMode.h"
 #include "core/input/KeyBinder.h"
 #include "core/input/KeyBinderManager.h"
+#include "ConsoleCommandManager.h"
 
 namespace orxonox
 {
     /**
-        @brief Constructor: Initializes all values and registers the command.
+        @brief Constructor: Initializes all values and registers the command (without a group).
+        @param name The name of the command
+        @param executor The executor of the command
+        @param bInitialized If true, the executor is used for both, the definition of the function-header AND to executute the command. If false, the command is inactive and needs to be assigned a function before it can be used.
+    */
+    ConsoleCommand::ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized)
+    {
+        this->init("", name, executor, bInitialized);
+    }
+
+    /**
+        @brief Constructor: Initializes all values and registers the command (with a group).
         @param group The group of the command
         @param name The name of the command
         @param executor The executor of the command
@@ -51,6 +62,11 @@
     */
     ConsoleCommand::ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
     {
+        this->init(group, name, executor, bInitialized);
+    }
+
+    void ConsoleCommand::init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized)
+    {
         this->bActive_ = true;
         this->bHidden_ = false;
         this->accessLevel_ = AccessLevel::All;
@@ -67,7 +83,7 @@
         if (bInitialized)
             this->executor_ = executor;
 
-        ConsoleCommand::registerCommand(group, name, this);
+        this->names_.push_back(CommandName(group, name));
     }
 
     /**
@@ -75,7 +91,6 @@
     */
     ConsoleCommand::~ConsoleCommand()
     {
-        ConsoleCommand::unregisterCommand(this);
     }
 
     /**
@@ -83,7 +98,7 @@
     */
     ConsoleCommand& ConsoleCommand::addShortcut()
     {
-        ConsoleCommand::registerCommand("", this->baseName_, this);
+        this->names_.push_back(CommandName("", this->baseName_));
         return *this;
     }
 
@@ -92,7 +107,7 @@
     */
     ConsoleCommand& ConsoleCommand::addShortcut(const std::string&  name)
     {
-        ConsoleCommand::registerCommand("", name, this);
+        this->names_.push_back(CommandName("", name));
         return *this;
     }
 
@@ -101,7 +116,7 @@
     */
     ConsoleCommand& ConsoleCommand::addGroup(const std::string& group)
     {
-        ConsoleCommand::registerCommand(group, this->baseName_, this);
+        this->names_.push_back(CommandName(group, this->baseName_));
         return *this;
     }
 
@@ -110,7 +125,7 @@
     */
     ConsoleCommand& ConsoleCommand::addGroup(const std::string& group, const std::string&  name)
     {
-        ConsoleCommand::registerCommand(group, name, this);
+        this->names_.push_back(CommandName(group, name));
         return *this;
     }
 
@@ -586,167 +601,4 @@
         this->keybindMode(mode);
         return *this;
     }
-
-    /**
-        @brief Returns the command with given group an name.
-        @param group The group of the requested command
-        @param name The group of the requested command
-        @param bPrintError If true, an error is printed if the command doesn't exist
-    */
-    /* static */ ConsoleCommand* ConsoleCommand::getCommand(const std::string& group, const std::string& name, bool bPrintError)
-    {
-        // find the group
-        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMap().find(group);
-        if (it_group != ConsoleCommand::getCommandMap().end())
-        {
-            // find the name
-            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(name);
-            if (it_name != it_group->second.end())
-            {
-                // return the pointer
-                return it_name->second;
-            }
-        }
-        if (bPrintError)
-        {
-            if (group == "")
-                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
-            else
-                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
-        }
-        return 0;
-    }
-
-    /**
-        @brief Returns the command with given group an name in lowercase.
-        @param group The group of the requested command in lowercase
-        @param name The group of the requested command in lowercase
-        @param bPrintError If true, an error is printed if the command doesn't exist
-    */
-    /* static */ ConsoleCommand* ConsoleCommand::getCommandLC(const std::string& group, const std::string& name, bool bPrintError)
-    {
-        std::string groupLC = getLowercase(group);
-        std::string nameLC = getLowercase(name);
-
-        // find the group
-        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = ConsoleCommand::getCommandMapLC().find(groupLC);
-        if (it_group != ConsoleCommand::getCommandMapLC().end())
-        {
-            // find the name
-            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC);
-            if (it_name != it_group->second.end())
-            {
-                // return the pointer
-                return it_name->second;
-            }
-        }
-        if (bPrintError)
-        {
-            if (group == "")
-                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
-            else
-                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
-        }
-        return 0;
-    }
-
-    /**
-        @brief Returns the static map that stores all console commands.
-    */
-    /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMap()
-    {
-        static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap;
-        return commandMap;
-    }
-
-    /**
-        @brief Returns the static map that stores all console commands in lowercase.
-    */
-    /* static */ std::map<std::string, std::map<std::string, ConsoleCommand*> >& ConsoleCommand::getCommandMapLC()
-    {
-        static std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC;
-        return commandMapLC;
-    }
-
-    /**
-        @brief Registers a new command with given group an name by adding it to the command map.
-    */
-    /* static */ void ConsoleCommand::registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command)
-    {
-        if (name == "")
-            return;
-
-        // check if a command with this name already exists
-        if (ConsoleCommand::getCommand(group, name) != 0)
-        {
-            if (group == "")
-                orxout(internal_warning, context::commands) << "A console command with shortcut \"" << name << "\" already exists." << endl;
-            else
-                orxout(internal_warning, context::commands) << "A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << endl;
-        }
-        else
-        {
-            // add the command to the map
-            ConsoleCommand::getCommandMap()[group][name] = command;
-            ConsoleCommand::getCommandMapLC()[getLowercase(group)][getLowercase(name)] = command;
-        }
-    }
-
-    /**
-        @brief Removes the command from the command map.
-    */
-    /* static */ void ConsoleCommand::unregisterCommand(ConsoleCommand* command)
-    {
-        // iterate through all groups
-        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMap().begin(); it_group != ConsoleCommand::getCommandMap().end(); )
-        {
-            // iterate through all commands of each group
-            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
-            {
-                // erase the command
-                if (it_name->second == command)
-                    it_group->second.erase(it_name++);
-                else
-                    ++it_name;
-            }
-
-            // erase the group if it is empty now
-            if (it_group->second.empty())
-                ConsoleCommand::getCommandMap().erase(it_group++);
-            else
-                ++it_group;
-        }
-
-        // now the same for the lowercase-map:
-
-        // iterate through all groups
-        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = ConsoleCommand::getCommandMapLC().begin(); it_group != ConsoleCommand::getCommandMapLC().end(); )
-        {
-            // iterate through all commands of each group
-            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
-            {
-                // erase the command
-                if (it_name->second == command)
-                    it_group->second.erase(it_name++);
-                else
-                    ++it_name;
-            }
-
-            // erase the group if it is empty now
-            if (it_group->second.empty())
-                ConsoleCommand::getCommandMapLC().erase(it_group++);
-            else
-                ++it_group;
-        }
-    }
-
-    /**
-        @brief Deletes all commands
-    */
-    /* static */ void ConsoleCommand::destroyAll()
-    {
-        // delete entries until the map is empty
-        while (!ConsoleCommand::getCommandMap().empty() && !ConsoleCommand::getCommandMap().begin()->second.empty())
-            delete ConsoleCommand::getCommandMap().begin()->second.begin()->second;
-    }
 }

Modified: code/trunk/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -27,191 +27,9 @@
  */
 
 /**
-    @defgroup ConsoleCommand Console commands
-    @ingroup Command
-*/
-
-/**
     @file
     @ingroup Command ConsoleCommand
-    @brief Declaration of the orxonox::ConsoleCommand class and the SetConsoleCommand() macro.
-
-    @anchor ConsoleCommandExample
-
-    Console commands can be used to write scripts, use key-bindings or simply to be
-    entered into the shell by the user. Instances of orxonox::ConsoleCommand define
-    the function of a command, and also more information like, for example, if it is
-    active, default values, and possible arguments.
-
-    Commands need to be registered to the system statically on startup by using the
-    SetConsoleCommand() or DeclareConsoleCommand() macros outside of a function.
-    This ensures that commands are known to the system at any time, so they can be
-    evaluated (see orxonox::CommandExecutor::evaluate()), for example for key-bindings.
-
-    Example:
-    @code
-    void myCoutFunction(const std::string& text)        // Define a static function
-    {
-        orxout() << "Text: " << text << endl;           // Print the text to the console
-    }
-
-    SetConsoleCommand("cout", &myCoutFunction);         // Register the function as command with name "cout"
-    @endcode
-
-    Now you can open the shell and execute the command:
-    @code
-    $ cout Hello World
-    @endcode
-
-    Internally this command is now passed to orxonox::CommandExecutor::execute():
-    @code
-    CommandExecutor::execute("cout HelloWorld");
-    @endcode
-
-    CommandExecutor searches for a command with name "cout" and passes the arguments
-    "Hello World" to it. Because we registered myCoutFunction() with this command,
-    as a result the following text will be printed to the console:
-    @code
-    Text: Hello World
-    @endcode
-
-    You can add more attributes to the ConsoleCommand, by using the command-chain feature
-    of SetConsoleCommand(). For example like this:
-    @code
-    SetConsoleCommand("cout", &myCoutFunction)
-        .addGroup("output", "text")
-        .accessLevel(AccessLevel::Offline)
-        .defaultValues("no text");
-    @endcode
-
-    Open the shell again and try it:
-    @code
-    $ cout Hello World
-    Text: Hello World
-    $ output text Hello World
-    Text: Hello World
-    $ cout
-    Text: no text
-    @endcode
-
-    If you execute it online (note: the access level is "Offline"), you will see the
-    following (or something similar):
-    @code
-    $ cout Hello World
-    Error: Can't execute command "cout", access denied.
-    @endcode
-
-    If a command is executed, the arguments are passed to an underlying function,
-    whitch is wrapped by an orxonox::Functor which again is wrapped by an orxonox::Executor.
-    The Functor contains the function-pointer, as well as the object-pointer in
-    case of a non-static member-function. The executor stores possible default-values
-    for each argument of the function.
-
-    The function of a command can be changed at any time. It's possible to just exchange
-    the function-pointer of the underlying Functor if the headers of the functions are
-    exactly the same. But you can also exchange the Functor itself or even completely
-    replace the Executor. Also the other attributes of a ConsoleCommand can be modified
-    during the game, for example it can be activated or deactivated.
-
-    To do so, the function ModifyConsoleCommand() has to be used. It returns an instance
-    of orxonox::ConsoleCommand::ConsoleCommandManipulator which has an interface similar to
-    orxonox::ConsoleCommand, but with slight differences. You can use it the same way like
-    SetConsoleCommand(), meaning you can use command-chains to change different attributes at
-    the same time. ModifyConsoleCommand() must not be executed statically, but rather in a
-    function at some point of the execution of the program.
-
-    Example:
-    @code
-    void myOtherCoutFunction(const std::string& text)                       // Define a new static function
-    {
-        orxout() << "Uppercase: " << getUppercase(text) << endl;            // Print the text in uppercase to the console
-    }
-
-    {
-        // ...                                                              // somewhere in the code
-
-        ModifyConsoleCommand("cout").setFunction(&myOtherCoutFunction);     // Modify the underlying function of the command
-
-        // ...
-    }
-    @endcode
-
-    If you now enter the command into the shell, you'll see a different behavior:
-    @code
-    $ cout Hello World
-    Uppercase: HELLO WORLD
-    $ cout
-    Uppercase: NO TEXT
-    @endcode
-
-    A few important notes about changing functions:
-
-    Instead of changing the function with setFunction(), you can also create a command-stack
-    by using pushFunction() and popFunction(). It's important to note a few things about that,
-    because the underlying structure of Executor and Functor has a few pitfalls:
-     - If you push a new function-pointer, the same executor as before will be used (and, if
-       the headers match, even the same functor can be used, which is very fast)
-     - If you push a new Functor, the same executor as before will be used
-     - If you push a new Executor, everything is changed
-
-    Note that the executor contains the @b default @b values, so if you just exchange the
-    Functor, the default values remain the same. However if you decide to change the default
-    values at any point of the stack, <b>this will also change the default values on all
-    other stack-levels</b> that share the same executor. If you don't like this behavior,
-    you have to explicitly push a new executor before changing the default values, either by
-    calling pushFunction(executor) or by calling pushFunction(void) which pushes a copy of
-    the current executor to the stack.
-
-    Another important point are object pointers in case of non-static member-functions.
-    Whenever you set or push a new function, <b>you must add the object pointer again</b>
-    because objects are stored in the Functor which is usually exchanged if you change
-    the function.
-
-    You can also use a stack for objects, but note that this <b>object-stack is different for each
-    function</b> - so if you set a new function, the object-stack will be cleared. If you push
-    a new function, the old object-stack is stored in the stack, so it can be restored if
-    you pop the function.
-
-    %DeclareConsoleCommand():
-
-    Appart from SetConsoleCommand() you can also call DeclareConsoleCommand(). In contrast
-    to SetConsoleCommand(), this doesn't assign a function to the command. Indeed you have
-    to pass a function-pointer to DeclareConsoleCommand(), but it is only used to determine
-    the header of the future command-function. This allows to declare a command statically,
-    thus it's possible to evaluate key-bindings of this command, but the actual function
-    can be assigned at a later point.
-
-    Example:
-    @code
-    DeclareConsoleCommand("cout", &prototype::void__string);
-    @endcode
-
-    If you try to execute the command now, you see the following (or something similar):
-    @code
-    $ cout Hello World
-    Error: Can't execute command "cout", command is not active.
-    @endcode
-
-    You first have to assign a function to use the command:
-    @code
-    {
-        // ...
-
-        ModifyConsoleCommand("cout").setFunction(&myCoutFunction);
-
-        // ...
-    }
-    @endcode
-
-    Now you can use it:
-    @code
-    $ cout Hello World
-    Text: Hello World
-    @endcode
-
-    Note that the initial function prototype::void__string is defined in the namespace
-    orxonox::prototype. If there's no function with the desired header, you can extend
-    the collection of functions or simply use another function that has the same header.
+    @brief Declaration of the orxonox::ConsoleCommand class.
 */
 
 #ifndef _ConsoleCommand_H__
@@ -222,88 +40,9 @@
 #include <stack>
 #include <vector>
 
-#include "util/VA_NARGS.h"
 #include "ArgumentCompletionFunctions.h"
 #include "Executor.h"
 
-
-/**
-    @brief Defines a console command. The macro is overloaded for 2-4 parameters.
-
-    This is an overloaded macro. Depending on the number of arguments a different
-    overloaded implementation of the macro will be chosen.
-
-    Console commands created with SetConsoleCommand() become active immediately and
-    the given function-pointer (and optionally the object) will be used to execute
-    the command.
-*/
-#define SetConsoleCommand(...) \
-    BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
-/**
-    @brief This macro is executed if you call SetConsoleCommand() with 2 arguments.
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of the corresponding command-function
-*/
-#define SetConsoleCommand2(name, functionpointer) \
-    SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
-/**
-    @brief This macro is executed if you call SetConsoleCommand() with 3 arguments.
-    @param group The group (string) of the console command
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of the corresponding command-function
-*/
-#define SetConsoleCommand3(group, name, functionpointer) \
-    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
-/**
-    @brief This macro is executed if you call SetConsoleCommand() with 4 arguments.
-    @param group The group (string) of the console command
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of the corresponding command-function
-    @param object The object that will be assigned to the command. Used for member-functions.
-*/
-#define SetConsoleCommand4(group, name, functionpointer, object) \
-    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
-
-/// Internal macro
-#define SetConsoleCommandGeneric(group, name, functor) \
-    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor)))
-
-
-/**
-    @brief Declares a console command. The macro is overloaded for 2-3 parameters.
-
-    This is an overloaded macro. Depending on the number of arguments a different
-    overloaded implementation of the macro will be chosen.
-
-    Console commands created with DeclareConsoleCommand() don't use the the given
-    function-pointer to execute the command, it is only used to define the header
-    of the future command-function. The command is inactive until you manually
-    set a function with orxonox::ModifyConsoleCommand(). You can use a different
-    function-pointer than in the final command, as long as it has the same header.
-*/
-#define DeclareConsoleCommand(...) \
-    BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
-/**
-    @brief This macro is executed if you call DeclareConsoleCommand() with 2 arguments.
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
-*/
-#define DeclareConsoleCommand2(name, functionpointer) \
-    DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
-/**
-    @brief This macro is executed if you call DeclareConsoleCommand() with 3 arguments.
-    @param group The group (string) of the console command
-    @param name The name (string) of the console command
-    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
-*/
-#define DeclareConsoleCommand3(group, name, functionpointer) \
-    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
-
-/// Internal macro
-#define DeclareConsoleCommandGeneric(group, name, functor) \
-    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) = (*orxonox::createConsoleCommand(group, name, orxonox::createExecutor(functor), false))
-
-
 namespace orxonox
 {
     /**
@@ -365,6 +104,16 @@
 
         public:
             /**
+             * @brief Defines the name of a command, consisting of an optional group ("" means no group) and the name itself.
+             */
+            struct CommandName
+            {
+                CommandName(const std::string& group, const std::string& name) : group_(group), name_(name) {}
+                std::string group_;
+                std::string name_;
+            };
+
+            /**
                 @brief Helper class that is used to manipulate console commands.
 
                 An instance of this class is returned if you call the ModifyConsoleCommand macro.
@@ -521,6 +270,7 @@
             };
 
         public:
+            ConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
             ConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true);
             ~ConsoleCommand();
 
@@ -619,7 +369,12 @@
             inline ConsoleCommandManipulator getManipulator()
                 { return this; }
 
+            inline const std::vector<CommandName>& getNames()
+                { return this->names_; }
+
         private:
+            void init(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized);
+
             bool headersMatch(const FunctorPtr& functor);
             bool headersMatch(const ExecutorPtr& executor);
 
@@ -640,6 +395,7 @@
             bool bHidden_;                                                  ///< True if the command is hidden (it is still executable, but not visible in the list of available commands)
             AccessLevel::Enum accessLevel_;                                 ///< The access level (the state of the game in which you can access the command)
             std::string baseName_;                                          ///< The name that was first assigned to the command
+            std::vector<CommandName> names_;                                ///< All names and aliases of this command
             FunctorPtr baseFunctor_;                                        ///< The functor that defines the header of the command-function
 
             ExecutorPtr executor_;                                          ///< The Executor that is used to execute the command
@@ -654,72 +410,7 @@
             LanguageEntryLabel description_;                                ///< The description of the command
             LanguageEntryLabel descriptionReturnvalue_;                     ///< A description of the return-value
             LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS];    ///< A description for each argument
-
-        public:
-            /// Returns the map with all groups and commands.
-            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
-                { return ConsoleCommand::getCommandMap(); }
-            /// Returns the map with all groups and commands in lowercase.
-            static inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
-                { return ConsoleCommand::getCommandMapLC(); }
-
-            /// Returns a command (shortcut) with given name. @param name The name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
-            static inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
-                { return ConsoleCommand::getCommand("", name, bPrintError); }
-            /// Returns a command (shortcut) with given name in lowercase. @param name The lowercase name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
-            static inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
-                { return ConsoleCommand::getCommandLC("", name, bPrintError); }
-
-            static ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
-            static ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
-
-            static void destroyAll();
-
-        private:
-            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMap();
-            static std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandMapLC();
-
-            static void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
-            static void unregisterCommand(ConsoleCommand* command);
     };
-
-    /**
-        @brief Creates a new ConsoleCommand.
-        @param name The name of the command
-        @param executor The executor of the command
-        @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.
-    */
-    inline ConsoleCommand* createConsoleCommand(const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
-        { return new ConsoleCommand("", name, executor, bInitialized); }
-    /**
-        @brief Creates a new ConsoleCommand.
-        @param group The group of the command
-        @param name The name of the command
-        @param executor The executor of the command
-        @param bInitialized If true, the command is ready to be executed, otherwise it has to be activated first.
-    */
-    inline ConsoleCommand* createConsoleCommand(const std::string& group, const std::string& name, const ExecutorPtr& executor, bool bInitialized = true)
-        { return new ConsoleCommand(group, name, executor, bInitialized); }
-
-
-    /**
-        @brief Returns a manipulator for a command with the given name.
-
-        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
-        but it can still be used without checks, because all functions of ConsoleCommandManipulator
-        check internally if the command exists.
-    */
-    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name)
-        { return ConsoleCommand::getCommand(name, true); }
-    /**
-        @brief Returns a manipulator for a command with the given group and name.
-
-        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
-        but it can still be used without checks, because all functions of ConsoleCommandManipulator
-        check internally if the command exists.
-    */
-    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name)
-        { return ConsoleCommand::getCommand(group, name, true); }
 }
 
 #endif /* _ConsoleCommand_H__ */

Modified: code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -40,7 +40,7 @@
 #include "util/Output.h"
 #include "util/ExprParser.h"
 #include "util/StringUtils.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "CommandExecutor.h"
 
 namespace orxonox

Copied: code/trunk/src/libraries/core/command/ConsoleCommandIncludes.cc (from rev 10623, code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.cc)
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandIncludes.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/command/ConsoleCommandIncludes.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,44 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConsoleCommandIncludes.h"
+
+#include "ConsoleCommandManager.h"
+
+namespace orxonox
+{
+    void StaticallyInitializedConsoleCommand::load()
+    {
+        ConsoleCommandManager::getInstance().registerCommand(this->command_);
+    }
+
+    void StaticallyInitializedConsoleCommand::unload()
+    {
+        ConsoleCommandManager::getInstance().unregisterCommand(this->command_);
+    }
+}

Copied: code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h (from rev 10623, code/branches/core7/src/libraries/core/command/ConsoleCommandIncludes.h)
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h	                        (rev 0)
+++ code/trunk/src/libraries/core/command/ConsoleCommandIncludes.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,350 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @defgroup ConsoleCommand Console commands
+    @ingroup Command
+*/
+
+/**
+    @file
+    @ingroup Command ConsoleCommand
+    @brief Declaration the SetConsoleCommand() macro.
+
+    @anchor ConsoleCommandExample
+
+    Console commands can be used to write scripts, use key-bindings or simply to be
+    entered into the shell by the user. Instances of orxonox::ConsoleCommand define
+    the function of a command, and also more information like, for example, if it is
+    active, default values, and possible arguments.
+
+    Commands need to be registered to the system statically on startup by using the
+    SetConsoleCommand() or DeclareConsoleCommand() macros outside of a function.
+    This ensures that commands are known to the system at any time, so they can be
+    evaluated (see orxonox::CommandExecutor::evaluate()), for example for key-bindings.
+
+    Example:
+    @code
+    void myCoutFunction(const std::string& text)        // Define a static function
+    {
+        orxout() << "Text: " << text << endl;           // Print the text to the console
+    }
+
+    SetConsoleCommand("cout", &myCoutFunction);         // Register the function as command with name "cout"
+    @endcode
+
+    Now you can open the shell and execute the command:
+    @code
+    $ cout Hello World
+    @endcode
+
+    Internally this command is now passed to orxonox::CommandExecutor::execute():
+    @code
+    CommandExecutor::execute("cout HelloWorld");
+    @endcode
+
+    CommandExecutor searches for a command with name "cout" and passes the arguments
+    "Hello World" to it. Because we registered myCoutFunction() with this command,
+    as a result the following text will be printed to the console:
+    @code
+    Text: Hello World
+    @endcode
+
+    You can add more attributes to the ConsoleCommand, by using the command-chain feature
+    of SetConsoleCommand(). For example like this:
+    @code
+    SetConsoleCommand("cout", &myCoutFunction)
+        .addGroup("output", "text")
+        .accessLevel(AccessLevel::Offline)
+        .defaultValues("no text");
+    @endcode
+
+    Open the shell again and try it:
+    @code
+    $ cout Hello World
+    Text: Hello World
+    $ output text Hello World
+    Text: Hello World
+    $ cout
+    Text: no text
+    @endcode
+
+    If you execute it online (note: the access level is "Offline"), you will see the
+    following (or something similar):
+    @code
+    $ cout Hello World
+    Error: Can't execute command "cout", access denied.
+    @endcode
+
+    If a command is executed, the arguments are passed to an underlying function,
+    whitch is wrapped by an orxonox::Functor which again is wrapped by an orxonox::Executor.
+    The Functor contains the function-pointer, as well as the object-pointer in
+    case of a non-static member-function. The executor stores possible default-values
+    for each argument of the function.
+
+    The function of a command can be changed at any time. It's possible to just exchange
+    the function-pointer of the underlying Functor if the headers of the functions are
+    exactly the same. But you can also exchange the Functor itself or even completely
+    replace the Executor. Also the other attributes of a ConsoleCommand can be modified
+    during the game, for example it can be activated or deactivated.
+
+    To do so, the function ModifyConsoleCommand() has to be used. It returns an instance
+    of orxonox::ConsoleCommand::ConsoleCommandManipulator which has an interface similar to
+    orxonox::ConsoleCommand, but with slight differences. You can use it the same way like
+    SetConsoleCommand(), meaning you can use command-chains to change different attributes at
+    the same time. ModifyConsoleCommand() must not be executed statically, but rather in a
+    function at some point of the execution of the program.
+
+    Example:
+    @code
+    void myOtherCoutFunction(const std::string& text)                       // Define a new static function
+    {
+        orxout() << "Uppercase: " << getUppercase(text) << endl;            // Print the text in uppercase to the console
+    }
+
+    {
+        // ...                                                              // somewhere in the code
+
+        ModifyConsoleCommand("cout").setFunction(&myOtherCoutFunction);     // Modify the underlying function of the command
+
+        // ...
+    }
+    @endcode
+
+    If you now enter the command into the shell, you'll see a different behavior:
+    @code
+    $ cout Hello World
+    Uppercase: HELLO WORLD
+    $ cout
+    Uppercase: NO TEXT
+    @endcode
+
+    A few important notes about changing functions:
+
+    Instead of changing the function with setFunction(), you can also create a command-stack
+    by using pushFunction() and popFunction(). It's important to note a few things about that,
+    because the underlying structure of Executor and Functor has a few pitfalls:
+     - If you push a new function-pointer, the same executor as before will be used (and, if
+       the headers match, even the same functor can be used, which is very fast)
+     - If you push a new Functor, the same executor as before will be used
+     - If you push a new Executor, everything is changed
+
+    Note that the executor contains the @b default @b values, so if you just exchange the
+    Functor, the default values remain the same. However if you decide to change the default
+    values at any point of the stack, <b>this will also change the default values on all
+    other stack-levels</b> that share the same executor. If you don't like this behavior,
+    you have to explicitly push a new executor before changing the default values, either by
+    calling pushFunction(executor) or by calling pushFunction(void) which pushes a copy of
+    the current executor to the stack.
+
+    Another important point are object pointers in case of non-static member-functions.
+    Whenever you set or push a new function, <b>you must add the object pointer again</b>
+    because objects are stored in the Functor which is usually exchanged if you change
+    the function.
+
+    You can also use a stack for objects, but note that this <b>object-stack is different for each
+    function</b> - so if you set a new function, the object-stack will be cleared. If you push
+    a new function, the old object-stack is stored in the stack, so it can be restored if
+    you pop the function.
+
+    %DeclareConsoleCommand():
+
+    Appart from SetConsoleCommand() you can also call DeclareConsoleCommand(). In contrast
+    to SetConsoleCommand(), this doesn't assign a function to the command. Indeed you have
+    to pass a function-pointer to DeclareConsoleCommand(), but it is only used to determine
+    the header of the future command-function. This allows to declare a command statically,
+    thus it's possible to evaluate key-bindings of this command, but the actual function
+    can be assigned at a later point.
+
+    Example:
+    @code
+    DeclareConsoleCommand("cout", &prototype::void__string);
+    @endcode
+
+    If you try to execute the command now, you see the following (or something similar):
+    @code
+    $ cout Hello World
+    Error: Can't execute command "cout", command is not active.
+    @endcode
+
+    You first have to assign a function to use the command:
+    @code
+    {
+        // ...
+
+        ModifyConsoleCommand("cout").setFunction(&myCoutFunction);
+
+        // ...
+    }
+    @endcode
+
+    Now you can use it:
+    @code
+    $ cout Hello World
+    Text: Hello World
+    @endcode
+
+    Note that the initial function prototype::void__string is defined in the namespace
+    orxonox::prototype. If there's no function with the desired header, you can extend
+    the collection of functions or simply use another function that has the same header.
+*/
+
+#ifndef _ConsoleCommandIncludes_H__
+#define _ConsoleCommandIncludes_H__
+
+#include "core/CorePrereqs.h"
+
+#include "ConsoleCommand.h"
+#include "ConsoleCommandManager.h"
+#include "util/VA_NARGS.h"
+#include "core/module/StaticallyInitializedInstance.h"
+
+
+/**
+    @brief Defines a console command. The macro is overloaded for 2-4 parameters.
+
+    This is an overloaded macro. Depending on the number of arguments a different
+    overloaded implementation of the macro will be chosen.
+
+    Console commands created with SetConsoleCommand() become active immediately and
+    the given function-pointer (and optionally the object) will be used to execute
+    the command.
+*/
+#define SetConsoleCommand(...) \
+    BOOST_PP_EXPAND(BOOST_PP_CAT(SetConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
+/**
+    @brief This macro is executed if you call SetConsoleCommand() with 2 arguments.
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of the corresponding command-function
+*/
+#define SetConsoleCommand2(name, functionpointer) \
+    SetConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
+/**
+    @brief This macro is executed if you call SetConsoleCommand() with 3 arguments.
+    @param group The group (string) of the console command
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of the corresponding command-function
+*/
+#define SetConsoleCommand3(group, name, functionpointer) \
+    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
+/**
+    @brief This macro is executed if you call SetConsoleCommand() with 4 arguments.
+    @param group The group (string) of the console command
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of the corresponding command-function
+    @param object The object that will be assigned to the command. Used for member-functions.
+*/
+#define SetConsoleCommand4(group, name, functionpointer, object) \
+    SetConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer, object))
+
+/// Internal macro
+#define SetConsoleCommandGeneric(group, name, functor) \
+    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
+        = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor))))->getCommand()
+
+
+/**
+    @brief Declares a console command. The macro is overloaded for 2-3 parameters.
+
+    This is an overloaded macro. Depending on the number of arguments a different
+    overloaded implementation of the macro will be chosen.
+
+    Console commands created with DeclareConsoleCommand() don't use the the given
+    function-pointer to execute the command, it is only used to define the header
+    of the future command-function. The command is inactive until you manually
+    set a function with orxonox::ModifyConsoleCommand(). You can use a different
+    function-pointer than in the final command, as long as it has the same header.
+*/
+#define DeclareConsoleCommand(...) \
+    BOOST_PP_EXPAND(BOOST_PP_CAT(DeclareConsoleCommand, ORXONOX_VA_NARGS(__VA_ARGS__))(__VA_ARGS__))
+/**
+    @brief This macro is executed if you call DeclareConsoleCommand() with 2 arguments.
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
+*/
+#define DeclareConsoleCommand2(name, functionpointer) \
+    DeclareConsoleCommandGeneric("", name, orxonox::createFunctor(functionpointer))
+/**
+    @brief This macro is executed if you call DeclareConsoleCommand() with 3 arguments.
+    @param group The group (string) of the console command
+    @param name The name (string) of the console command
+    @param functionpointer The function-pointer of an arbitrary function that has the same header as the final function
+*/
+#define DeclareConsoleCommand3(group, name, functionpointer) \
+    DeclareConsoleCommandGeneric(group, name, orxonox::createFunctor(functionpointer))
+
+/// Internal macro
+#define DeclareConsoleCommandGeneric(group, name, functor) \
+    static orxonox::ConsoleCommand& BOOST_PP_CAT(__consolecommand_, __UNIQUE_NUMBER__) \
+        = (new orxonox::SI_CC(new orxonox::ConsoleCommand(group, name, orxonox::createExecutor(functor), false)))->getCommand()
+
+
+namespace orxonox
+{
+    class _CoreExport StaticallyInitializedConsoleCommand : public StaticallyInitializedInstance
+    {
+        public:
+            StaticallyInitializedConsoleCommand(ConsoleCommand* command)
+                : StaticallyInitializedInstance(StaticInitialization::CONSOLE_COMMAND)
+                , command_(command)
+            {}
+            ~StaticallyInitializedConsoleCommand() { delete command_; }
+
+            virtual void load();
+            virtual void unload();
+
+            inline ConsoleCommand& getCommand()
+                { return *this->command_; }
+
+        private:
+            ConsoleCommand* command_;
+    };
+
+    typedef StaticallyInitializedConsoleCommand SI_CC;
+
+    /**
+        @brief Returns a manipulator for a command with the given name.
+
+        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
+        but it can still be used without checks, because all functions of ConsoleCommandManipulator
+        check internally if the command exists.
+    */
+    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& name)
+        { return ConsoleCommandManager::getInstance().getCommand(name, true); }
+    /**
+        @brief Returns a manipulator for a command with the given group and name.
+
+        @note If the command doesn't exist, the manipulator contains a NULL pointer to the command,
+        but it can still be used without checks, because all functions of ConsoleCommandManipulator
+        check internally if the command exists.
+    */
+    inline ConsoleCommand::ConsoleCommandManipulator ModifyConsoleCommand(const std::string& group, const std::string& name)
+        { return ConsoleCommandManager::getInstance().getCommand(group, name, true); }
+}
+
+#endif /* _ConsoleCommandIncludes_H__ */

Copied: code/trunk/src/libraries/core/command/ConsoleCommandManager.cc (from rev 10623, code/branches/core7/src/libraries/core/command/ConsoleCommandManager.cc)
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandManager.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/command/ConsoleCommandManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,189 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the ConsoleCommand class.
+*/
+
+#include "ConsoleCommandManager.h"
+
+#include "ConsoleCommand.h"
+#include "util/StringUtils.h"
+
+namespace orxonox
+{
+    ConsoleCommandManager* ConsoleCommandManager::singletonPtr_s = 0;
+
+    /**
+        @brief Returns the command with given group an name.
+        @param group The group of the requested command
+        @param name The group of the requested command
+        @param bPrintError If true, an error is printed if the command doesn't exist
+    */
+    ConsoleCommand* ConsoleCommandManager::getCommand(const std::string& group, const std::string& name, bool bPrintError)
+    {
+        // find the group
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = this->commandMap_.find(group);
+        if (it_group != this->commandMap_.end())
+        {
+            // find the name
+            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(name);
+            if (it_name != it_group->second.end())
+            {
+                // return the pointer
+                return it_name->second;
+            }
+        }
+        if (bPrintError)
+        {
+            if (group == "")
+                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
+            else
+                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
+        }
+        return 0;
+    }
+
+    /**
+        @brief Returns the command with given group an name in lowercase.
+        @param group The group of the requested command in lowercase
+        @param name The group of the requested command in lowercase
+        @param bPrintError If true, an error is printed if the command doesn't exist
+    */
+    ConsoleCommand* ConsoleCommandManager::getCommandLC(const std::string& group, const std::string& name, bool bPrintError)
+    {
+        std::string groupLC = getLowercase(group);
+        std::string nameLC = getLowercase(name);
+
+        // find the group
+        std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = this->commandMapLC_.find(groupLC);
+        if (it_group != this->commandMapLC_.end())
+        {
+            // find the name
+            std::map<std::string, ConsoleCommand*>::const_iterator it_name = it_group->second.find(nameLC);
+            if (it_name != it_group->second.end())
+            {
+                // return the pointer
+                return it_name->second;
+            }
+        }
+        if (bPrintError)
+        {
+            if (group == "")
+                orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
+            else
+                orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
+        }
+        return 0;
+    }
+
+    /**
+        @brief Registers a new command with the groups and names that are defined by ConsoleCommand::getNames().
+    */
+    void ConsoleCommandManager::registerCommand(ConsoleCommand* command)
+    {
+        for (size_t i = 0; i < command->getNames().size(); ++i)
+        {
+            const ConsoleCommand::CommandName& name = command->getNames()[i];
+            this->registerCommand(name.group_, name.name_, command);
+        }
+    }
+
+    /**
+        @brief Registers a new command with given group an name by adding it to the command map.
+    */
+    void ConsoleCommandManager::registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command)
+    {
+        if (name == "")
+            return;
+
+        // check if a command with this name already exists
+        if (this->getCommand(group, name) != 0)
+        {
+            if (group == "")
+                orxout(internal_warning, context::commands) << "A console command with shortcut \"" << name << "\" already exists." << endl;
+            else
+                orxout(internal_warning, context::commands) << "A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << endl;
+        }
+        else
+        {
+            // add the command to the map
+            this->commandMap_[group][name] = command;
+            this->commandMapLC_[getLowercase(group)][getLowercase(name)] = command;
+        }
+    }
+
+    /**
+        @brief Removes the command from the command map.
+    */
+    void ConsoleCommandManager::unregisterCommand(ConsoleCommand* command)
+    {
+        // iterate through all groups
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = this->commandMap_.begin(); it_group != this->commandMap_.end(); )
+        {
+            // iterate through all commands of each group
+            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
+            {
+                // erase the command
+                if (it_name->second == command)
+                    it_group->second.erase(it_name++);
+                else
+                    ++it_name;
+            }
+
+            // erase the group if it is empty now
+            if (it_group->second.empty())
+                this->commandMap_.erase(it_group++);
+            else
+                ++it_group;
+        }
+
+        // now the same for the lowercase-map:
+
+        // iterate through all groups
+        for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::iterator it_group = this->commandMapLC_.begin(); it_group != this->commandMapLC_.end(); )
+        {
+            // iterate through all commands of each group
+            for (std::map<std::string, ConsoleCommand*>::iterator it_name = it_group->second.begin(); it_name != it_group->second.end(); )
+            {
+                // erase the command
+                if (it_name->second == command)
+                    it_group->second.erase(it_name++);
+                else
+                    ++it_name;
+            }
+
+            // erase the group if it is empty now
+            if (it_group->second.empty())
+                this->commandMapLC_.erase(it_group++);
+            else
+                ++it_group;
+        }
+    }
+}

Copied: code/trunk/src/libraries/core/command/ConsoleCommandManager.h (from rev 10623, code/branches/core7/src/libraries/core/command/ConsoleCommandManager.h)
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandManager.h	                        (rev 0)
+++ code/trunk/src/libraries/core/command/ConsoleCommandManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,80 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @defgroup ConsoleCommand Console commands
+    @ingroup Command
+*/
+
+#ifndef _ConsoleCommandManager_H__
+#define _ConsoleCommandManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include "util/Singleton.h"
+
+namespace orxonox
+{
+    /**
+     * A singleton that stores all existing ConsoleCommands.
+     */
+    class _CoreExport ConsoleCommandManager : public Singleton<ConsoleCommandManager>
+    {
+        friend class Singleton<ConsoleCommandManager>;
+
+        public:
+            void registerCommand(ConsoleCommand* command);
+            void registerCommand(const std::string& group, const std::string& name, ConsoleCommand* command);
+            void unregisterCommand(ConsoleCommand* command);
+
+            /// Returns the map with all groups and commands.
+            inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommands()
+                { return this->commandMap_; }
+            /// Returns the map with all groups and commands in lowercase.
+            inline const std::map<std::string, std::map<std::string, ConsoleCommand*> >& getCommandsLC()
+                { return this->commandMapLC_; }
+
+            /// Returns a command (shortcut) with given name. @param name The name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
+            inline ConsoleCommand* getCommand(const std::string& name, bool bPrintError = false)
+                { return this->getCommand("", name, bPrintError); }
+            /// Returns a command (shortcut) with given name in lowercase. @param name The lowercase name of the command shortcut @param bPrintError If true, an error is printed if the command doesn't exist
+            inline ConsoleCommand* getCommandLC(const std::string& name, bool bPrintError = false)
+                { return this->getCommandLC("", name, bPrintError); }
+
+            ConsoleCommand* getCommand(const std::string& group, const std::string& name, bool bPrintError = false);
+            ConsoleCommand* getCommandLC(const std::string& group, const std::string& name, bool bPrintError = false);
+
+        private:
+            std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMap_;
+            std::map<std::string, std::map<std::string, ConsoleCommand*> > commandMapLC_;
+
+            static ConsoleCommandManager* singletonPtr_s;
+    };
+}
+
+#endif /* _ConsoleCommandManager_H__ */

Modified: code/trunk/src/libraries/core/command/IRC.cc
===================================================================
--- code/trunk/src/libraries/core/command/IRC.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/IRC.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,7 +38,7 @@
 #include "util/Convert.h"
 #include "util/Exception.h"
 #include "util/StringUtils.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclThreadManager.h"
 
 namespace orxonox

Modified: code/trunk/src/libraries/core/command/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/command/Shell.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/Shell.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -41,7 +41,7 @@
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigFileManager.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
 #include "core/input/InputBuffer.h"
 #include "CommandExecutor.h"
 
@@ -83,7 +83,7 @@
         ConfigFileManager::getInstance().setFilename(ConfigFileType::CommandHistory, "commandHistory.ini");
 
         // Choose the default level according to the path Orxonox was started (build directory or not)
-        OutputLevel defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+        OutputLevel defaultDebugLevel = (ApplicationPaths::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
         this->setLevelMax(defaultDebugLevel);
 
         this->setConfigValues();
@@ -163,7 +163,7 @@
     */
     void Shell::devModeChanged(bool value)
     {
-        bool isNormal = (value == PathConfig::buildDirectoryRun());
+        bool isNormal = (value == ApplicationPaths::buildDirectoryRun());
         if (isNormal)
         {
             ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), update);

Modified: code/trunk/src/libraries/core/command/Shell.h
===================================================================
--- code/trunk/src/libraries/core/command/Shell.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/Shell.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -48,7 +48,7 @@
 #include <vector>
 
 #include "util/output/BaseWriter.h"
-#include "core/Core.h"
+#include "core/CoreConfig.h"
 
 namespace orxonox
 {

Modified: code/trunk/src/libraries/core/command/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclBind.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/TclBind.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,9 +36,9 @@
 #include "util/Output.h"
 #include "util/Exception.h"
 #include "util/StringUtils.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
 #include "CommandExecutor.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclThreadManager.h"
 
 namespace orxonox
@@ -142,10 +142,10 @@
     std::string TclBind::getTclLibraryPath()
     {
 #ifdef DEPENDENCY_PACKAGE_ENABLE
-        if (PathConfig::buildDirectoryRun())
+        if (ApplicationPaths::buildDirectoryRun())
             return (std::string(specialConfig::dependencyLibraryDirectory) + "/tcl");
         else
-            return (PathConfig::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");
+            return (ApplicationPaths::getRootPathString() + specialConfig::defaultLibraryPath + "/tcl");
 #else
         return "";
 #endif

Modified: code/trunk/src/libraries/core/command/TclThreadManager.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclThreadManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/command/TclThreadManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -46,7 +46,7 @@
 #include "util/StringUtils.h"
 #include "core/CoreIncludes.h"
 #include "CommandExecutor.h"
-#include "ConsoleCommand.h"
+#include "ConsoleCommandIncludes.h"
 #include "TclBind.h"
 #include "TclThreadList.h"
 

Modified: code/trunk/src/libraries/core/config/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/config/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/config/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,5 +1,4 @@
 ADD_SOURCE_FILES(CORE_SRC_FILES
-  CommandLineParser.cc
 #  ConfigFile.cc is already included in FilesystemBuildUnit.cc
   ConfigFileEntryValue.cc
   ConfigFileEntryVectorValue.cc

Deleted: code/trunk/src/libraries/core/config/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/config/CommandLineParser.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/config/CommandLineParser.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,340 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "CommandLineParser.h"
-
-#include <algorithm>
-#include <sstream>
-
-#include "util/Convert.h"
-#include "util/Output.h"
-#include "util/Exception.h"
-#include "util/StringUtils.h"
-#include "util/SubString.h"
-#include "core/PathConfig.h"
-
-namespace orxonox
-{
-    /**
-    @brief
-        Parses a value string for a command line argument.
-        It simply uses convertValue(Output, Input) to do that.
-        Bools are treated specially. That is necessary
-        so that you can have simple command line switches.
-    */
-    void CommandLineArgument::parse(const std::string& value)
-    {
-        if (value_.isType<bool>())
-        {
-            // simulate command line switch
-            bool temp;
-            if (convertValue(&temp, value))
-            {
-                this->bHasDefaultValue_ = false;
-                this->value_ = temp;
-            }
-            else if (value.empty())
-            {
-                this->bHasDefaultValue_ = false;
-                this->value_ = true;
-            }
-            else
-                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
-        }
-        else
-        {
-            if (!value_.set(value))
-            {
-                value_.set(defaultValue_);
-                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
-            }
-            else
-                this->bHasDefaultValue_ = false;
-        }
-    }
-
-
-    /**
-    @brief
-        Destructor destroys all CommandLineArguments with it.
-    */
-    CommandLineParser::~CommandLineParser()
-    {
-        CommandLineParser::destroyAllArguments();
-    }
-
-    /**
-    @brief
-        Returns a unique instance (Meyers Singleton).
-    */
-    CommandLineParser& CommandLineParser::_getInstance()
-    {
-        static CommandLineParser instance;
-        return instance;
-    }
-
-    /**
-    @brief
-        Destroys all command line arguments. This should be called at the end
-        of main. Do not use before that.
-    */
-    void CommandLineParser::destroyAllArguments()
-    {
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin();
-            it != _getInstance().cmdLineArgs_.end(); ++it)
-            delete it->second;
-        _getInstance().cmdLineArgs_.clear();
-    }
-
-    /** Parses the command line string for arguments and stores these.
-    @note
-        The reason that you have to provide the string to be parsed as
-        space separated list is because of argc and argv. If you only have
-        a whole string, simply use getAllStrings() of SubString.
-    @param cmdLine
-        Command line string WITHOUT the execution path.
-    */
-    void CommandLineParser::_parse(const std::string& cmdLine)
-    {
-        std::vector<std::string> arguments;
-        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
-        for (unsigned i = 0; i < tokens.size(); ++i)
-            arguments.push_back(tokens[i]);
-
-        try
-        {
-            // why this? See bFirstTimeParse_ declaration.
-            if (bFirstTimeParse_)
-            {
-                // first shove all the shortcuts in a map
-                for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
-                    it != cmdLineArgs_.end(); ++it)
-                {
-                    OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
-                        "Cannot have two command line shortcut with the same name.");
-                    if (!it->second->getShortcut().empty())
-                        cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
-                }
-                bFirstTimeParse_ = false;
-            }
-
-            std::string name;
-            std::string shortcut;
-            std::string value;
-            for (unsigned int i = 0; i < arguments.size(); ++i)
-            {
-                if (arguments[i].size() != 0)
-                {
-                    // sure not ""
-                    if (arguments[i][0] == '-')
-                    {
-                        // start with "-"
-                        if (arguments[i].size() == 1)
-                        {
-                            // argument[i] is "-", probably a minus sign
-                            value += "- ";
-                        }
-                        else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
-                        {
-                            // negative number as a value
-                            value += arguments[i] + ' ';
-                        }
-                        else
-                        {
-                            // can be shortcut or full name argument
-
-                            // save old data first
-                            value = removeTrailingWhitespaces(value);
-                            if (!name.empty())
-                            {
-                                checkFullArgument(name, value);
-                                name.clear();
-                                assert(shortcut.empty());
-                            }
-                            else if (!shortcut.empty())
-                            {
-                                checkShortcut(shortcut, value);
-                                shortcut.clear();
-                                assert(name.empty());
-                            }
-
-                            if (arguments[i][1] == '-')
-                            {
-                                // full name argument with "--name"
-                                name = arguments[i].substr(2);
-                            }
-                            else
-                            {
-                                // shortcut with "-s"
-                                shortcut = arguments[i].substr(1);
-                            }
-
-                            // reset value string
-                            value.clear();
-                        }
-                    }
-                    else
-                    {
-                        // value string
-
-                        if (name.empty() && shortcut.empty())
-                        {
-                            ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
-                        }
-
-                        // Concatenate strings as long as there's no new argument by "-" or "--"
-                        value += arguments[i] + ' ';
-                    }
-                }
-            }
-
-            // parse last argument
-            value = removeTrailingWhitespaces(value);
-            if (!name.empty())
-            {
-                checkFullArgument(name, value);
-                assert(shortcut.empty());
-            }
-            else if (!shortcut.empty())
-            {
-                checkShortcut(shortcut, value);
-                assert(name.empty());
-            }
-        }
-        catch (const ArgumentException& ex)
-        {
-            orxout(user_error) << "Could not parse command line: " << ex.what() << endl;
-            orxout(user_error) << CommandLineParser::getUsageInformation() << endl;
-            throw GeneralException("");
-        }
-    }
-
-    /**
-    @brief
-        Parses an argument based on its full name.
-    @param name
-        Full name of the argument
-    @param value
-        String containing the value
-    @param bParsingFile
-        Parsing a file or the command line itself
-    */
-    void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
-        if (it == cmdLineArgs_.end())
-            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
-
-        it->second->parse(value);
-    }
-
-    /**
-    @brief
-        Parses an argument based on its shortcut.
-    @param shortcut
-        Shortcut to the argument
-    @param value
-        String containing the value
-    @param bParsingFile
-        Parsing a file or the command line itself
-    */
-    void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
-        if (it == cmdLineArgsShortcut_.end())
-            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
-
-        it->second->parse(value);
-    }
-
-    std::string CommandLineParser::getUsageInformation()
-    {
-        CommandLineParser& inst = _getInstance();
-        std::ostringstream infoStr;
-
-        // determine maximum name size
-        size_t maxNameSize = 0;
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
-            it != inst.cmdLineArgs_.end(); ++it)
-        {
-            maxNameSize = std::max(it->second->getName().size(), maxNameSize);
-        }
-
-        infoStr << endl;
-        infoStr << "Usage: orxonox [options]" << endl;
-        infoStr << "Available options:" << endl;
-
-        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
-            it != inst.cmdLineArgs_.end(); ++it)
-        {
-            if (!it->second->getShortcut().empty())
-                infoStr << " [-" << it->second->getShortcut() << "] ";
-            else
-                infoStr << "      ";
-            infoStr << "--" << it->second->getName() << ' ';
-            if (it->second->getValue().isType<bool>())
-                infoStr << "    ";
-            else
-                infoStr << "ARG ";
-            // fill with the necessary amount of blanks
-            infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
-            infoStr << ": " << it->second->getInformation();
-            infoStr << endl;
-        }
-        return infoStr.str();
-    }
-
-    void CommandLineParser::generateDoc(std::ofstream& file)
-    {
-        file << "/** @page cmdargspage Command Line Arguments Reference" << endl;
-        file << "    @verbatim"; /*no endl*/
-        file << getUsageInformation(); /*no endl*/
-        file << "    @endverbatim" << endl;
-        file << "*/" << endl;
-    }
-
-    /**
-    @brief
-        Retrieves a CommandLineArgument.
-        The method throws an exception if 'name' was not found or the value could not be converted.
-    @note
-        You should of course not call this method before the command line has been parsed.
-    */
-    const CommandLineArgument* CommandLineParser::getArgument(const std::string& name)
-    {
-        std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
-        if (it == _getInstance().cmdLineArgs_.end())
-        {
-            ThrowException(Argument, "Could find command line argument '" + name + "'.");
-        }
-        else
-        {
-            return it->second;
-        }
-    }
-}

Deleted: code/trunk/src/libraries/core/config/CommandLineParser.h
===================================================================
--- code/trunk/src/libraries/core/config/CommandLineParser.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/config/CommandLineParser.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,227 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @defgroup CmdArgs Commandline arguments
-    @ingroup Config
-    @brief For a reference of all commandline arguments see @ref cmdargspage
-*/
-
-/**
-    @file
-    @ingroup Config CmdArgs
-    @brief Declaration of CommandLineParser and CommandLineArgument, definition of the SetCommandLineArgument() macros.
-*/
-
-#ifndef _CommandLine_H__
-#define _CommandLine_H__
-
-#include "core/CorePrereqs.h"
-
-#include <fstream>
-#include <map>
-#include "util/OrxAssert.h"
-#include "util/MultiType.h"
-
-#define SetCommandLineArgument(name, defaultValue) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, defaultValue)
-#define SetCommandLineSwitch(name) \
-    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
-    = orxonox::CommandLineParser::addArgument(#name, false)
-
-namespace orxonox
-{
-    /**
-    @brief
-        Container class for a command line argument of any type supported by MultiType.
-
-        Whenever you want to have an option specified by a command line switch,
-        you need to first define it with SetCommandLineArgument(name, defaultValue).
-        It is then added to a map and possibly changed when the command line is being parsed.
-        If the option was not given, you can detect this by asking hasDefaultValue().
-
-        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
-        Note the difference between "-" and "--"!
-        Also, there is no restriction to the number of strings you add after --name.
-        So "--startVector {2, 4, 5}" is perfectly legal.
-
-        Retrieving an argument is possible with the getCommandLineArgument function of the
-        CommandLineParser class. It is a Singleton, but the public interface is static.
-    */
-    class _CoreExport CommandLineArgument
-    {
-        friend class CommandLineParser;
-
-    public:
-        //! Tells whether the value has been changed by the command line.
-        bool hasDefaultValue() const { return bHasDefaultValue_; }
-        //! Returns the name of the argument.
-        const std::string& getName() const { return name_; }
-
-        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
-        //! Evaluates to "" if there is none.
-        const std::string& getShortcut() const { return shortcut_; }
-        //! Sets the shortcut for the argument
-        CommandLineArgument& shortcut(const std::string& shortcut)
-        { this->shortcut_ = shortcut; return *this; }
-
-        //! Returns the usage information
-        const std::string& getInformation() const { return this->usageInformation_; }
-        //! Sets the option information when displaying orxonox usage.
-        CommandLineArgument& information(const std::string& usage)
-        { this->usageInformation_ = usage; return *this; }
-
-        //! Returns the actual value of the argument. Can be equal to default value.
-        const MultiType& getValue() const { return value_; }
-        //! Returns the given default value as type T.
-        const MultiType& getDefaultValue() const { return defaultValue_; }
-
-    private:
-        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
-        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
-            : bHasDefaultValue_(true)
-            , name_(name)
-            , value_(defaultValue)
-            , defaultValue_(defaultValue)
-        { }
-
-        //! Undefined copy constructor
-        CommandLineArgument(const CommandLineArgument& instance);
-        ~CommandLineArgument() { }
-
-        //! Parses the value string of a command line argument.
-        void parse(const std::string& value);
-
-        //! Tells whether the value has been changed by the command line.
-        bool bHasDefaultValue_;
-
-    private:
-        std::string name_;             //!< Name of the argument
-        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
-        std::string usageInformation_; //!< Tells about the usage of this parameter
-
-        MultiType   value_;            //!< The actual value
-        MultiType   defaultValue_;     //!< Default value. Should not be changed.
-    };
-
-
-    /**
-    @brief
-        Global interface to command line options.
-        Allows to add and retrieve command line arguments. Also does the parsing.
-    @note
-        Internally it is a Singleton, but the public interface is static.
-    @see
-        CommandLineArgument
-    */
-    class _CoreExport CommandLineParser
-    {
-    public:
-
-        //! Parse redirection to internal member method.
-        static void parse(const std::string& cmdLine)
-        { _getInstance()._parse(cmdLine); }
-
-        static std::string getUsageInformation();
-
-        static const CommandLineArgument* getArgument(const std::string& name);
-        //! Writes the argument value in the given parameter.
-        template <class T>
-        static void getValue(const std::string& name, T* value)
-        { *value = (T)(getArgument(name)->getValue()); }
-        static const MultiType& getValue(const std::string& name)
-        { return getArgument(name)->getValue(); }
-        template <class T>
-        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
-
-        static bool existsArgument(const std::string& name)
-        {
-            std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
-            return !(it == _getInstance().cmdLineArgs_.end());
-        }
-
-        static void destroyAllArguments();
-
-        static void generateDoc(std::ofstream& file);
-
-    private:
-        //! Constructor initialises bFirstTimeParse_ with true.
-        CommandLineParser() : bFirstTimeParse_(true) { }
-        //! Undefined copy constructor
-        CommandLineParser(const CommandLineParser& instance);
-        ~CommandLineParser();
-
-        static CommandLineParser& _getInstance();
-
-        void _parse(const std::string& cmdLine);
-        void checkFullArgument(const std::string& name, const std::string& value);
-        void checkShortcut(const std::string& shortcut, const std::string& value);
-
-        /**
-            Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
-            So when we call parse() the first time, we need to create a map with all shortcuts since these
-            get added after addCommandLineArgument().
-        */
-        bool bFirstTimeParse_;
-
-        //! Holds all pointers to the arguments and serves as a search map by name.
-        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
-        //! Search map by shortcut for the arguments.
-        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
-    };
-
-    template <>
-    inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value)
-    {
-        *value = getArgument(name)->getValue().get<std::string>();
-    }
-
-    /**
-    @brief
-        Adds a new CommandLineArgument to the internal map.
-        Note that only such arguments are actually valid.
-    @param name
-        Name of the argument. Shortcut can be added later.
-    @param defaultValue
-        Default value that is used when argument was not given.
-    */
-    template <class T>
-    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue)
-    {
-        OrxAssert(!_getInstance().existsArgument(name),
-            "Cannot add a command line argument with name '" + name + "' twice.");
-        OrxAssert(!MultiType(defaultValue).isType<bool>() || MultiType(defaultValue).get<bool>() != true,
-               "Boolean command line arguments with positive default values are not supported." << endl
-            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
-
-        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
-    }
-}
-
-#endif /* _CommandLine_H__ */

Modified: code/trunk/src/libraries/core/config/ConfigFile.cc
===================================================================
--- code/trunk/src/libraries/core/config/ConfigFile.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/config/ConfigFile.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,7 +37,7 @@
 
 #include "util/Convert.h"
 #include "util/StringUtils.h"
-#include "core/PathConfig.h"
+#include "core/ConfigurablePaths.h"
 #include "ConfigFileEntryComment.h"
 #include "ConfigFileEntryValue.h"
 
@@ -80,13 +80,13 @@
         boost::filesystem::path filepath(this->filename_);
         if (!filepath.is_complete())
         {
-            filepath = PathConfig::getConfigPath() / filepath;
+            filepath = ConfigurablePaths::getConfigPath() / filepath;
             if (this->bCopyFallbackFile_)
             {
                 // Look for default file in the data folder
                 if (!boost::filesystem::exists(filepath))
                 {
-                    boost::filesystem::path defaultFilepath(PathConfig::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);
+                    boost::filesystem::path defaultFilepath(ConfigurablePaths::getDataPath() / DEFAULT_CONFIG_FOLDER / this->filename_);
                     if (boost::filesystem::exists(defaultFilepath))
                     {
                         // Try to copy default file from the data folder
@@ -215,7 +215,7 @@
     {
         boost::filesystem::path filepath(filename);
         if (!filepath.is_complete())
-            filepath = PathConfig::getConfigPath() / filename;
+            filepath = ConfigurablePaths::getConfigPath() / filename;
         std::ofstream file;
         file.open(filepath.string().c_str(), std::fstream::out);
         file.setf(std::ios::fixed, std::ios::floatfield);

Modified: code/trunk/src/libraries/core/config/Configurable.cc
===================================================================
--- code/trunk/src/libraries/core/config/Configurable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/config/Configurable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -31,7 +31,7 @@
 
 namespace orxonox
 {
-    RegisterClassNoArgs(Configurable);
+    RegisterClassNoArgs(Configurable).virtualBase();
 
     Configurable::Configurable()
     {

Modified: code/trunk/src/libraries/core/config/SettingsConfigFile.cc
===================================================================
--- code/trunk/src/libraries/core/config/SettingsConfigFile.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/config/SettingsConfigFile.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,7 +34,7 @@
 #include "SettingsConfigFile.h"
 
 #include "util/StringUtils.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "ConfigFileManager.h"
 #include "ConfigValueContainer.h"
 

Modified: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/input/InputManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -47,8 +47,8 @@
 #include "core/CoreIncludes.h"
 #include "core/GraphicsManager.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/config/CommandLineParser.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/commandline/CommandLineIncludes.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/command/Functor.h"
 
 #include "InputBuffer.h"
@@ -85,6 +85,8 @@
         return (lval = (InputManager::State)(lval & rval));
     }
 
+    RegisterAbstractClass(InputManager).inheritsFrom<WindowEventListener>();
+
     // ############################################################
     // #####                  Initialisation                  #####
     // ##########                                        ##########

Modified: code/trunk/src/libraries/core/input/JoyStick.cc
===================================================================
--- code/trunk/src/libraries/core/input/JoyStick.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/input/JoyStick.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -47,6 +47,8 @@
 
     std::vector<std::string> JoyStick::deviceNames_s;
 
+    RegisterAbstractClass(JoyStick).inheritsFrom<Configurable>();
+
     JoyStick::JoyStick(unsigned int id, OIS::InputManager* oisInputManager)
         : super(id, oisInputManager)
     {

Modified: code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc
===================================================================
--- code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/input/JoyStickQuantityListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,6 +35,8 @@
 {
     std::vector<JoyStick*> JoyStickQuantityListener::joyStickList_s;
 
+    RegisterAbstractClass(JoyStickQuantityListener).inheritsFrom<Listable>();
+
     JoyStickQuantityListener::JoyStickQuantityListener()
     {
         RegisterObject(JoyStickQuantityListener);

Modified: code/trunk/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinder.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/input/KeyBinder.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,12 +36,15 @@
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/config/ConfigFile.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
+#include "core/ConfigurablePaths.h"
 #include "InputCommands.h"
 #include "JoyStick.h"
 
 namespace orxonox
 {
+    RegisterAbstractClass(KeyBinder).inheritsFrom<JoyStickQuantityListener>();
+
     /**
     @brief
         Constructor that does as little as necessary.
@@ -252,13 +255,13 @@
     {
         orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl;
 
-        this->configFile_ = new ConfigFile(this->filename_, !PathConfig::buildDirectoryRun());
+        this->configFile_ = new ConfigFile(this->filename_, !ApplicationPaths::buildDirectoryRun());
         this->configFile_->load();
 
-        if (PathConfig::buildDirectoryRun())
+        if (ApplicationPaths::buildDirectoryRun())
         {
             // Dev users should have combined key bindings files
-            std::string defaultFilepath(PathConfig::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_);
+            std::string defaultFilepath(ConfigurablePaths::getDataPathString() + ConfigFile::DEFAULT_CONFIG_FOLDER + '/' + this->filename_);
             std::ifstream file(defaultFilepath.c_str());
             if (file.is_open())
             {
@@ -286,7 +289,7 @@
         {
             addButtonToCommand(binding, it->second);
             std::string str = binding;
-            if (PathConfig::buildDirectoryRun() && binding.empty())
+            if (ApplicationPaths::buildDirectoryRun() && binding.empty())
                 str = "NoBinding";
             it->second->setBinding(this->configFile_, this->fallbackConfigFile_, binding, bTemporary);
             return true;

Modified: code/trunk/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -30,17 +30,17 @@
 
 #include "util/Output.h"
 #include "util/Exception.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/LuaState.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "InputManager.h"
 #include "KeyDetector.h"
 
 namespace orxonox
 {
-    ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false);
+    ManageScopedSingleton(KeyBinderManager, ScopeID::GRAPHICS, false);
 
     static const std::string __CC_keybind_name = "keybind";
     static const std::string __CC_tkeybind_name = "tkeybind";
@@ -52,6 +52,8 @@
     SetConsoleCommand(__CC_unbind_name,   &KeyBinderManager::unbind).defaultValues("");
     SetConsoleCommand(__CC_tunbind_name,  &KeyBinderManager::tunbind).defaultValues("");
 
+    RegisterAbstractClass(KeyBinderManager).inheritsFrom<Configurable>();
+
     KeyBinderManager::KeyBinderManager()
         : currentBinder_(NULL)
         , bDefaultFileLoaded_(true)

Modified: code/trunk/src/libraries/core/input/KeyDetector.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyDetector.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/input/KeyDetector.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -28,20 +28,22 @@
 
 #include "KeyDetector.h"
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "Button.h"
 #include "InputManager.h"
 #include "InputState.h"
 
 namespace orxonox
 {
-    ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false);
+    ManageScopedSingleton(KeyDetector, ScopeID::GRAPHICS, false);
 
     static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed";
     DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string).hide();
 
+    RegisterAbstractClass(KeyDetector).inheritsFrom<KeyBinder>();
+
     KeyDetector::KeyDetector()
         : KeyBinder("")
     {

Modified: code/trunk/src/libraries/core/input/Mouse.cc
===================================================================
--- code/trunk/src/libraries/core/input/Mouse.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/input/Mouse.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -30,7 +30,7 @@
 
 #include <ois/OISMouse.h>
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "InputState.h"
 
 #ifdef ORXONOX_PLATFORM_LINUX
@@ -50,6 +50,8 @@
     SetConsoleCommand(__CC_Mouse_name, __CC_ungrab_name, &Mouse::ungrab);
 #endif
 
+    RegisterAbstractClass(Mouse).inheritsFrom<WindowEventListener>();
+
     Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager)
         : super(id, oisInputManager)
     {

Modified: code/trunk/src/libraries/core/object/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/object/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,6 +1,7 @@
 ADD_SOURCE_FILES(CORE_SRC_FILES
   Context.cc
   Destroyable.cc
+  DestroyLaterManager.cc
   Listable.cc
   ObjectListBase.cc
 )

Modified: code/trunk/src/libraries/core/object/Context.cc
===================================================================
--- code/trunk/src/libraries/core/object/Context.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/Context.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -75,15 +75,18 @@
 
     /*static*/ void Context::setRootContext(Context* context)
     {
-        if (Context::rootContext_s)
-            delete Context::rootContext_s;
         Context::rootContext_s = context;
     }
 
+    /*static*/ void Context::destroyRootContext()
+    {
+        delete Context::rootContext_s;
+        Context::rootContext_s = NULL;
+    }
+
     /*static*/ Context* Context::getRootContext()
     {
-        if (!Context::rootContext_s)
-            Context::rootContext_s = new Context(NULL);
+        OrxVerify(Context::rootContext_s != NULL, "Root Context is undefined");
         return Context::rootContext_s;
     }
 
@@ -96,4 +99,11 @@
             this->objectLists_[classID] = new ObjectListBase();
         return this->objectLists_[classID];
     }
+
+    void Context::destroyObjectList(const Identifier* identifier)
+    {
+        ObjectListBase* objectList = this->getObjectList(identifier);
+        delete objectList;
+        this->objectLists_[identifier->getClassID()] = NULL;
+    }
 }

Modified: code/trunk/src/libraries/core/object/Context.h
===================================================================
--- code/trunk/src/libraries/core/object/Context.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/Context.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -46,6 +46,7 @@
     {
         public:
             static void setRootContext(Context* context);
+            static void destroyRootContext();
             static Context* getRootContext();
 
             Context(Context* context);
@@ -70,6 +71,8 @@
                     this->getParentContext()->addObject(object);
             }
 
+            void destroyObjectList(const Identifier* identifier);
+
         private:
             Context* parentContext_;
             std::vector<ObjectListBase*> objectLists_;

Copied: code/trunk/src/libraries/core/object/DestroyLaterManager.cc (from rev 10623, code/branches/core7/src/libraries/core/object/DestroyLaterManager.cc)
===================================================================
--- code/trunk/src/libraries/core/object/DestroyLaterManager.cc	                        (rev 0)
+++ code/trunk/src/libraries/core/object/DestroyLaterManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,56 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "DestroyLaterManager.h"
+
+#include "core/CoreIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+
+namespace orxonox
+{
+    ManageScopedSingleton(DestroyLaterManager, ScopeID::ROOT, false);
+
+    RegisterAbstractClass(DestroyLaterManager).inheritsFrom<UpdateListener>();
+
+    DestroyLaterManager::DestroyLaterManager()
+    {
+        RegisterObject(DestroyLaterManager);
+    }
+
+    DestroyLaterManager::~DestroyLaterManager()
+    {
+        // Be sure to release all instances
+        this->retainedInstances_.clear();
+    }
+
+    void DestroyLaterManager::postUpdate(const Clock& time)
+    {
+        // clearing the list will destroy all strong pointers and thus all retained instances (as long as there are no other strong pointers pointing to them).
+        this->retainedInstances_.clear();
+    }
+}

Copied: code/trunk/src/libraries/core/object/DestroyLaterManager.h (from rev 10623, code/branches/core7/src/libraries/core/object/DestroyLaterManager.h)
===================================================================
--- code/trunk/src/libraries/core/object/DestroyLaterManager.h	                        (rev 0)
+++ code/trunk/src/libraries/core/object/DestroyLaterManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _DestroyLaterManager_H__
+#define _DestroyLaterManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include "util/Singleton.h"
+#include "core/UpdateListener.h"
+#include "StrongPtr.h"
+
+namespace orxonox
+{
+    class _CoreExport DestroyLaterManager : public Singleton<DestroyLaterManager>, public UpdateListener
+    {
+            friend class Singleton<DestroyLaterManager>;
+        public:
+            DestroyLaterManager();
+            virtual ~DestroyLaterManager();
+
+            virtual void preUpdate(const Clock& time) { /*no action*/ }
+            virtual void postUpdate(const Clock& time);
+
+            void retain(Destroyable* instance)
+                { this->retainedInstances_.push_back(instance); }
+
+        private:
+            std::vector<StrongPtr<Destroyable> > retainedInstances_;
+
+            static DestroyLaterManager* singletonPtr_s;
+    };
+}
+
+#endif /* _DestroyLaterManager_H__ */

Modified: code/trunk/src/libraries/core/object/Destroyable.cc
===================================================================
--- code/trunk/src/libraries/core/object/Destroyable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/Destroyable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -32,6 +32,7 @@
 */
 
 #include "Destroyable.h"
+#include "DestroyLaterManager.h"
 
 #include <cassert>
 
@@ -59,8 +60,8 @@
     }
 
     /**
-        @brief Deletes the object if no @ref orxonox::SmartPtr "smart pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.
-        Always call destroy() instead of using 'delete' directly, otherwise smart pointers won't work.
+        @brief Deletes the object if no @ref orxonox::StrongPtr "strong pointers" point to this object. Otherwise schedules the object to be deleted as soon as possible.
+        Always call destroy() instead of using 'delete' directly, otherwise strong pointers won't work.
     */
     void Destroyable::destroy()
     {
@@ -73,4 +74,16 @@
                 delete this;
         }
     }
+
+    /**
+     * Works like @ref destroy() but doesn't destroy the object until the current tick has ended.
+     */
+    void Destroyable::destroyLater()
+    {
+        // register in DestroyLaterManager - this ensures that a strongPtr points to this object and keeps it alive for a while
+        DestroyLaterManager::getInstance().retain(this);
+
+        // request destruction -> object will be deleted after all strongPtrs (including the one in DestroyLaterManager) were destroyed.
+        this->destroy();
+    }
 }

Modified: code/trunk/src/libraries/core/object/Destroyable.h
===================================================================
--- code/trunk/src/libraries/core/object/Destroyable.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/Destroyable.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -29,7 +29,7 @@
 /**
     @file
     @ingroup Object
-    @brief Declaration of Destroyable, the base class of all objects which can be used with SmartPtr and WeakPtr.
+    @brief Declaration of Destroyable, the base class of all objects which can be used with StrongPtr and WeakPtr.
 */
 
 #ifndef _Destroyable_H__
@@ -42,12 +42,12 @@
 namespace orxonox
 {
     /**
-        @brief Classes must inherit from this class if they should be used with SmartPtr or WeakPtr.
+        @brief Classes must inherit from this class if they should be used with StrongPtr or WeakPtr.
     */
     class _CoreExport Destroyable
     {
         template <class T>
-        friend class SmartPtr;
+        friend class StrongPtr;
 
         friend class DestructionListener;
 
@@ -56,21 +56,22 @@
             virtual ~Destroyable();
 
             void destroy();
+            void destroyLater();
 
-            /// Returns the number of @ref orxonox::SmartPtr "smart pointers" that point to this object.
+            /// Returns the number of @ref orxonox::StrongPtr "strong pointers" that point to this object.
             inline unsigned int getReferenceCount() const
                 { return this->referenceCount_; }
 
         protected:
-            /// This virtual function is called if destroy() is called and no SmartPtr points to this object. Used in some cases to create a new SmartPtr to
+            /// This virtual function is called if destroy() is called and no StrongPtr points to this object. Used in some cases to create a new StrongPtr to
             /// prevent destruction. Don't call this function directly - use destroy() instead.
             virtual void preDestroy() {}
 
         private:
-            /// Increments the reference counter (for smart pointers).
+            /// Increments the reference counter (for strong pointers).
             inline void incrementReferenceCount()
                 { ++this->referenceCount_; }
-            /// Decrements the reference counter (for smart pointers).
+            /// Decrements the reference counter (for strong pointers).
             inline void decrementReferenceCount()
             {
                 --this->referenceCount_;
@@ -85,7 +86,7 @@
             inline void unregisterDestructionListener(DestructionListener* pointer)
                 { this->destructionListeners_.erase(pointer); }
 
-            int referenceCount_;                                    //!< Counts the references from smart pointers to this object
+            int referenceCount_;                                    //!< Counts the references from strong pointers to this object
             bool requestedDestruction_;                             //!< Becomes true after someone called delete on this object
             std::set<DestructionListener*> destructionListeners_;   //!< All destruction listeners (for example weak pointers which point to this object and like to get notified if it dies)
     };

Modified: code/trunk/src/libraries/core/object/Iterator.h
===================================================================
--- code/trunk/src/libraries/core/object/Iterator.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/Iterator.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -75,7 +75,7 @@
             /**
                 @brief Constructor: Sets the element, whereon the iterator points, to zero.
             */
-            inline Iterator() : IteratorBase<T, Iterator<T> >(NULL) {}
+            inline Iterator() : IteratorBase<T, Iterator<T> >() {}
 
             /**
                 @brief Constructor: Sets this element to a given element
@@ -87,7 +87,7 @@
                 @brief Constructor: Sets this element to the element of another Iterator.
                 @param other The other Iterator
             */
-            inline Iterator(const Iterator<T>& other) : IteratorBase<T, Iterator<T> >(other) {}
+            inline Iterator(const IteratorBase<T, Iterator<T> >& other) : IteratorBase<T, Iterator<T> >(other) {}
 
             /**
                 @brief Assigns a given element.

Modified: code/trunk/src/libraries/core/object/IteratorBase.h
===================================================================
--- code/trunk/src/libraries/core/object/IteratorBase.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/IteratorBase.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,6 +37,9 @@
 
 #include "core/CorePrereqs.h"
 
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+
 #include "ObjectListBase.h"
 
 namespace orxonox
@@ -48,17 +51,43 @@
     template <class T, class I>
     class IteratorBase : public ObjectListElementRemovalListener
     {
+        BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
+
+        protected:
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to the given element.
+                This constructor is protected and only for internal usage (don't mess with the BaseElements directly).
+            */
+            inline IteratorBase(ObjectListBaseElement* element = NULL)
+            {
+                this->element_ = element;
+                this->registerIterator();
+            }
+
+
         public:
             /**
-                @brief Constructor: Sets the element, whereon the iterator points, to zero.
+                @brief Constructor: Sets the element, whereon the iterator points, to the given element.
             */
-            inline IteratorBase(ObjectListBaseElement* element)
+            inline IteratorBase(ObjectListElement<T>* element)
             {
                 this->element_ = element;
                 this->registerIterator();
             }
 
             /**
+                @brief Constructor: Sets the element, whereon the iterator points, to the given element of another type.
+                The element's type O must be a derivative of the Iterator's type T.
+            */
+            template <class O>
+            inline IteratorBase(ObjectListElement<O>* element)
+            {
+                (void)static_cast<T*>((O*)NULL); // Check type: The element's type O must be a derivative of the Iterator's type T.
+                this->element_ = element;
+                this->registerIterator();
+            }
+
+            /**
                 @brief Constructor: Sets this element to the element of another Iterator.
                 @param other The other Iterator
             */

Modified: code/trunk/src/libraries/core/object/Listable.cc
===================================================================
--- code/trunk/src/libraries/core/object/Listable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/Listable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,7 +38,7 @@
 
 namespace orxonox
 {
-    RegisterClass(Listable);
+    RegisterClass(Listable).virtualBase();
 
     /**
         @brief Constructor: Allocates space in the element list.

Modified: code/trunk/src/libraries/core/object/ObjectList.h
===================================================================
--- code/trunk/src/libraries/core/object/ObjectList.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/ObjectList.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -46,6 +46,9 @@
 
 #include "core/CorePrereqs.h"
 
+#include <boost/static_assert.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+
 #include "ObjectListBase.h"
 #include "ObjectListIterator.h"
 #include "Context.h"
@@ -65,40 +68,57 @@
     template <class T>
     class ObjectList
     {
+        BOOST_STATIC_ASSERT((boost::is_base_of<Listable, T>::value));
+
         public:
             typedef ObjectListIterator<T> iterator;
 
+            /// Returns the size of the list (for the root context)
+            inline static size_t size()
+            {   return size(Context::getRootContext());   }
             /// Returns the size of the list
-            inline static size_t size()
+            inline static size_t size(Context* context)
             {
-                return Context::getRootContext()->getObjectList<T>()->size();
+                return context->getObjectList<T>()->size();
             }
 
+            /// Returns an Iterator to the first element in the list (for the root context).
+            inline static ObjectListElement<T>* begin()
+            {   return begin(Context::getRootContext());   }
             /// Returns an Iterator to the first element in the list.
-            inline static ObjectListElement<T>* begin()
+            inline static ObjectListElement<T>* begin(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->begin());
             }
 
+            /// Returns an Iterator to the element after the last element in the list (for the root context).
+            inline static ObjectListElement<T>* end()
+            {   return end(Context::getRootContext());   }
             /// Returns an Iterator to the element after the last element in the list.
-            inline static ObjectListElement<T>* end()
+            inline static ObjectListElement<T>* end(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->end());
             }
 
+            /// Returns an Iterator to the last element in the list (for the root context).
+            inline static ObjectListElement<T>* rbegin()
+            {   return rbegin(Context::getRootContext());   }
             /// Returns an Iterator to the last element in the list.
-            inline static ObjectListElement<T>* rbegin()
+            inline static ObjectListElement<T>* rbegin(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->rbegin());
             }
 
+            /// Returns an Iterator to the element before the first element in the list (for the root context).
+            inline static ObjectListElement<T>* rend()
+            {   return rend(Context::getRootContext());   }
             /// Returns an Iterator to the element before the first element in the list.
-            inline static ObjectListElement<T>* rend()
+            inline static ObjectListElement<T>* rend(Context* context)
             {
-                ObjectListBase* list = Context::getRootContext()->getObjectList<T>();
+                ObjectListBase* list = context->getObjectList<T>();
                 return static_cast<ObjectListElement<T>*>(list->rend());
             }
     };

Modified: code/trunk/src/libraries/core/object/ObjectListIterator.h
===================================================================
--- code/trunk/src/libraries/core/object/ObjectListIterator.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/ObjectListIterator.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -73,7 +73,7 @@
             /**
                 @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero.
             */
-            inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >(NULL) {}
+            inline ObjectListIterator() : IteratorBase<T, ObjectListIterator<T> >() {}
 
             /**
                 @brief Constructor: Sets this element to a given element.

Deleted: code/trunk/src/libraries/core/object/SmartPtr.h
===================================================================
--- code/trunk/src/libraries/core/object/SmartPtr.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/SmartPtr.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,316 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-// Inspired by boost::intrusive_ptr by Peter Dimov
-
-/**
-    @defgroup SmartPtr SmartPtr<T> and WeakPtr<T>
-    @ingroup Object
-*/
-
-/**
-    @file
-    @ingroup Object SmartPtr
-    @brief Definition of SmartPtr<T>, wraps a pointer to an object and keeps it alive.
-
-    @anchor SmartPtrExample
-
-    orxonox::SmartPtr is an implementation of a smart pointer - it wraps a pointer to an
-    object  and keeps this object alive until no SmartPtr points to this object anymore.
-    In contrast to orxonox::SharedPtr, SmartPtr works only with classes that are derived
-    from orxonox::Destroyable, because it's an intrusive implementation, meaning the
-    reference counter is stored in the object itself.
-
-    It's possible to use normal pointers and smart pointers to an object simultaneously.
-    You don't have to use SmartPtr all the time, you can create a SmartPtr for an object
-    at any time and also convert it back to a normal pointer if you like. This is possible
-    because the reference counter is stored in the object itself and not in SmartPtr (in
-    contrast to SharedPtr).
-
-    @b Important: If you want to delete an object, you must not use @c delete @c object but
-    rather @c object->destroy(). This function will check if there are smart pointers
-    pointing to the object. If yes, the object will be kept alive until all smart pointes
-    are destroyed. If no, the object is deleted instantly.
-
-    If all smart pointers that point to an object are destroyed, but you never called
-    @c object->destroy() before, the object will not be deleted! All a SmartPtr will do
-    is to really just keep an object alive, but it will not delete it automatically
-    unless you tried to destroy it before.
-
-    Example:
-    @code
-    class MyClass                                           // class declaration
-    {
-        public:
-            void setObject(OtherClass* object)              // passes a normal pointer which will be stored in a SmartPtr
-                { this->object_ = object; }
-
-            OtherClass* getObject() const                   // converts the SmartPtr to a normal pointer and returns it
-                { return this->object_; }
-
-        private:
-            SmartPtr<OtherClass> object_;                   // a pointer to an instance of OtherClass is stored in a SmartPtr
-    };
-    @endcode
-    In this example we assume that OtherClass is a child of Destroyable. We don't care
-    about the inheritance of MyClass though.
-
-    Now we create an instance of MyClass and assign a pointer to an instance of OtherClass:
-    @code
-    MyClass* myclass = new MyClass();                       // create an instance of MyClass
-    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
-    myclass->setObject(object);                             // the object is now stored in a SmartPtr inside myclass
-
-    object->destroy();                                      // we try to destroy object, but there's still a SmartPtr pointing at it.
-
-    # object still exists at this point (because a SmartPtr points at it)
-
-    delete myclass;                                         // now we delete myclass, which also destroys the SmartPtr
-
-    # object doesn't exist anymore (because the SmartPtr is now destroyed)
-    @endcode
-
-    Now we look at the same example, but we first delete myclass, then destroy object:
-    @code
-    MyClass* myclass = new MyClass();                       // create an instance of MyClass
-    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
-    myclass->setObject(object);                             // the object is now stored in a SmartPtr inside myclass
-
-    delete myclass;                                         // we delete myclass, which also destroys the SmartPtr
-
-    # object still exists at this point (because destroy() was not called yet)
-
-    object->destroy();                                      // now we try to destroy object, which works instantly
-
-    # object doesn't exist anymore (because we just destroyed it)
-    @endcode
-
-    Note that in any case @c object->destroy() has to be called to delete the object.
-    However if a SmartPtr points at it, the destruction is delayed until all SmartPtr
-    are destroyed.
-*/
-
-#ifndef _SmartPtr_H__
-#define _SmartPtr_H__
-
-#include "core/CorePrereqs.h"
-
-#include <cassert>
-
-#include "core/object/Destroyable.h"
-#include "WeakPtr.h"
-
-namespace orxonox
-{
-    /**
-        @brief A smart pointer which wraps a pointer to an object and keeps this object alive as long as the smart pointer exists.
-
-        @see See @ref SmartPtrExample "this description" for more information and an example.
-    */
-    template <class T>
-    class SmartPtr
-    {
-        public:
-            /// Constructor: Initializes the smart pointer with a null pointer.
-            inline SmartPtr() : pointer_(0), base_(0)
-            {
-            }
-
-            /// Constructor: Used to explicitly initialize the smart pointer with a null pointer
-            inline SmartPtr(int) : pointer_(0), base_(0)
-            {
-            }
-
-            /// Constructor: Initializes the smart pointer with a pointer to an object. @param pointer The pointer @param bAddRef If true, the reference counter is increased. Don't set this to false unless you know exactly what you're doing! (for example to avoid circular references if the @c this pointer of the possessing object is stored)
-            inline SmartPtr(T* pointer, bool bAddRef = true) : pointer_(pointer), base_(pointer)
-            {
-                if (this->base_ && bAddRef)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Copy-constructor
-            inline SmartPtr(const SmartPtr& other) : pointer_(other.pointer_), base_(other.base_)
-            {
-                if (this->base_)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Copy-constructor for smart pointers to objects of another class.
-            template <class O>
-            inline SmartPtr(const SmartPtr<O>& other) : pointer_(other.get()), base_(other.base_)
-            {
-                if (this->base_)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Constructor: Initializes the smart pointer with the pointer that is stored in a WeakPtr.
-            template <class O>
-            inline SmartPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase())
-            {
-                if (this->base_)
-                    this->base_->incrementReferenceCount();
-            }
-
-            /// Destructor: Decrements the reference counter.
-            inline ~SmartPtr()
-            {
-                if (this->base_)
-                    this->base_->decrementReferenceCount();
-            }
-
-            /// Used to assign a null pointer.
-            inline SmartPtr& operator=(int)
-            {
-                SmartPtr(0).swap(*this);
-                return *this;
-            }
-
-            /// Assigns a new pointer.
-            inline SmartPtr& operator=(T* pointer)
-            {
-                SmartPtr(pointer).swap(*this);
-                return *this;
-            }
-
-            /// Assigns the wrapped pointer of another SmartPtr.
-            inline SmartPtr& operator=(const SmartPtr& other)
-            {
-                SmartPtr(other).swap(*this);
-                return *this;
-            }
-
-            /// Assigns the wrapped pointer of a SmartPtr of another class
-            template <class O>
-            inline SmartPtr& operator=(const SmartPtr<O>& other)
-            {
-                SmartPtr(other).swap(*this);
-                return *this;
-            }
-
-            /// Assigns the wrapped pointer of a WeakPtr.
-            template <class O>
-            inline SmartPtr& operator=(const WeakPtr<O>& other)
-            {
-                SmartPtr(other).swap(*this);
-                return *this;
-            }
-
-            /// Returns the wrapped pointer as @c T*
-            inline T* get() const
-            {
-                return this->pointer_;
-            }
-
-            /// Returns the wrapped pointer as @c Destroyable*
-            inline Destroyable* getBase() const
-            {
-                return this->base_;
-            }
-
-            /// Implicitly converts the SmartPtr to a pointer of type @c T*
-            inline operator T*() const
-            {
-                return this->pointer_;
-            }
-
-            /// Overloaded operator, returns a pointer to the stored object.
-            inline T* operator->() const
-            {
-                assert(this->pointer_ != 0);
-                return this->pointer_;
-            }
-
-            /// Overloaded operator, returns a reference to the stored object.
-            inline T& operator*() const
-            {
-                assert(this->pointer_ != 0);
-                return *this->pointer_;
-            }
-
-            /// Returns true if the wrapped pointer is NULL.
-            inline bool operator!() const
-            {
-                return (this->pointer_ == 0);
-            }
-
-            /// Swaps the contents of two smart pointers.
-            inline void swap(SmartPtr& other)
-            {
-                {
-                    T* temp = this->pointer_;
-                    this->pointer_ = other.pointer_;
-                    other.pointer_ = temp;
-                }
-                {
-                    Destroyable* temp = this->base_;
-                    this->base_ = other.base_;
-                    other.base_ = temp;
-                }
-            }
-
-            /// Resets the smart pointer (equivalent to assigning a NULL pointer).
-            inline void reset()
-            {
-                SmartPtr().swap(*this);
-            }
-
-        private:
-            T* pointer_;            ///< The wrapped pointer to an object of type @a T
-            Destroyable* base_;    ///< The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, SmartPtr couln't be used with forward declarations)
-    };
-
-    /// Swaps the contents of two smart pointers.
-    template <class T>
-    void swap(SmartPtr<T>& a, SmartPtr<T>& b)
-    {
-        a.swap(b);
-    }
-
-    /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>.
-    template <class T, class U>
-    SmartPtr<T> static_pointer_cast(const SmartPtr<U>& p)
-    {
-        return static_cast<T*>(p.get());
-    }
-
-    /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>.
-    template <class T, class U>
-    SmartPtr<T> const_pointer_cast(const SmartPtr<U>& p)
-    {
-        return const_cast<T*>(p.get());
-    }
-
-    /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new SmartPtr<T>.
-    template <class T, class U>
-    SmartPtr<T> dynamic_pointer_cast(const SmartPtr<U>& p)
-    {
-        return orxonox_cast<T*>(p.get());
-    }
-}
-
-#endif /* _SmartPtr_H__ */

Copied: code/trunk/src/libraries/core/object/StrongPtr.h (from rev 10623, code/branches/core7/src/libraries/core/object/StrongPtr.h)
===================================================================
--- code/trunk/src/libraries/core/object/StrongPtr.h	                        (rev 0)
+++ code/trunk/src/libraries/core/object/StrongPtr.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,304 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+// Inspired by boost::intrusive_ptr by Peter Dimov
+
+/**
+    @defgroup SmartPtr StrongPtr<T> and WeakPtr<T>
+    @ingroup Object
+*/
+
+/**
+    @file
+    @ingroup Object SmartPtr
+    @brief Definition of StrongPtr<T>, wraps a pointer to an object and keeps it alive.
+
+    @anchor StrongPtrExample
+
+    orxonox::StrongPtr is an implementation of a smart pointer - it wraps a pointer to an
+    object  and keeps this object alive until no StrongPtr points to this object anymore.
+    In contrast to orxonox::SharedPtr, StrongPtr works only with classes that are derived
+    from orxonox::Destroyable, because it's an intrusive implementation, meaning the
+    reference counter is stored in the object itself.
+
+    It's possible to use normal pointers and strong pointers to an object simultaneously.
+    You don't have to use StrongPtr all the time, you can create a StrongPtr for an object
+    at any time and also convert it back to a normal pointer if you like. This is possible
+    because the reference counter is stored in the object itself and not in StrongPtr (in
+    contrast to SharedPtr).
+
+    @b Important: If you want to delete an object, you must not use @c delete @c object but
+    rather @c object->destroy(). This function will check if there are strong pointers
+    pointing to the object. If yes, the object will be kept alive until all strong pointers
+    are destroyed. If no, the object is deleted instantly.
+
+    If all strong pointers that point to an object are destroyed, but you never called
+    @c object->destroy() before, the object will not be deleted! All a StrongPtr will do
+    is to really just keep an object alive, but it will not delete it automatically
+    unless you tried to destroy it before.
+
+    Example:
+    @code
+    class MyClass                                           // class declaration
+    {
+        public:
+            void setObject(OtherClass* object)              // passes a normal pointer which will be stored in a StrongPtr
+                { this->object_ = object; }
+
+            OtherClass* getObject() const                   // converts the StrongPtr to a normal pointer and returns it
+                { return this->object_; }
+
+        private:
+            StrongPtr<OtherClass> object_;                  // a pointer to an instance of OtherClass is stored in a StrongPtr
+    };
+    @endcode
+    In this example we assume that OtherClass is a child of Destroyable. We don't care
+    about the inheritance of MyClass though.
+
+    Now we create an instance of MyClass and assign a pointer to an instance of OtherClass:
+    @code
+    MyClass* myclass = new MyClass();                       // create an instance of MyClass
+    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
+    myclass->setObject(object);                             // the object is now stored in a StrongPtr inside myclass
+
+    object->destroy();                                      // we try to destroy object, but there's still a StrongPtr pointing at it.
+
+    # object still exists at this point (because a StrongPtr points at it)
+
+    delete myclass;                                         // now we delete myclass, which also destroys the StrongPtr
+
+    # object doesn't exist anymore (because the StrongPtr is now destroyed)
+    @endcode
+
+    Now we look at the same example, but we first delete myclass, then destroy object:
+    @code
+    MyClass* myclass = new MyClass();                       // create an instance of MyClass
+    OtherClass* object = new OtherClass();                  // create an instance of OtherClass
+    myclass->setObject(object);                             // the object is now stored in a StrongPtr inside myclass
+
+    delete myclass;                                         // we delete myclass, which also destroys the StrongPtr
+
+    # object still exists at this point (because destroy() was not called yet)
+
+    object->destroy();                                      // now we try to destroy object, which works instantly
+
+    # object doesn't exist anymore (because we just destroyed it)
+    @endcode
+
+    Note that in any case @c object->destroy() has to be called to delete the object.
+    However if a StrongPtr points at it, the destruction is delayed until all StrongPtr
+    are destroyed.
+*/
+
+#ifndef _StrongPtr_H__
+#define _StrongPtr_H__
+
+#include "core/CorePrereqs.h"
+
+#include <cassert>
+
+#include "core/object/Destroyable.h"
+#include "WeakPtr.h"
+
+namespace orxonox
+{
+    /**
+        @brief A strong pointer which wraps a pointer to an object and keeps this object alive as long as the strong pointer exists.
+
+        @see See @ref StrongPtrExample "this description" for more information and an example.
+    */
+    template <class T>
+    class StrongPtr
+    {
+        public:
+            /// Constructor: Initializes the strong pointer with a null pointer.
+            inline StrongPtr() : pointer_(0), base_(0)
+            {
+            }
+
+            /// Constructor: Initializes the strong pointer with a pointer to an object. @param pointer The pointer
+            inline StrongPtr(T* pointer) : pointer_(pointer), base_(pointer)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Copy-constructor
+            inline StrongPtr(const StrongPtr& other) : pointer_(other.pointer_), base_(other.base_)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Copy-constructor for strong pointers to objects of another class.
+            template <class O>
+            inline StrongPtr(const StrongPtr<O>& other) : pointer_(other.get()), base_(other.base_)
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Constructor: Initializes the strong pointer with the pointer that is stored in a WeakPtr.
+            template <class O>
+            inline StrongPtr(const WeakPtr<O>& other) : pointer_(other.get()), base_(other.getBase())
+            {
+                if (this->base_)
+                    this->base_->incrementReferenceCount();
+            }
+
+            /// Destructor: Decrements the reference counter.
+            inline ~StrongPtr()
+            {
+                if (this->base_)
+                    this->base_->decrementReferenceCount();
+            }
+
+            /// Assigns a new pointer.
+            inline StrongPtr& operator=(T* pointer)
+            {
+                StrongPtr(pointer).swap(*this);
+                return *this;
+            }
+
+            /// Assigns the wrapped pointer of another StrongPtr.
+            inline StrongPtr& operator=(const StrongPtr& other)
+            {
+                StrongPtr(other).swap(*this);
+                return *this;
+            }
+
+            /// Assigns the wrapped pointer of a StrongPtr of another class
+            template <class O>
+            inline StrongPtr& operator=(const StrongPtr<O>& other)
+            {
+                StrongPtr(other).swap(*this);
+                return *this;
+            }
+
+            /// Assigns the wrapped pointer of a WeakPtr.
+            template <class O>
+            inline StrongPtr& operator=(const WeakPtr<O>& other)
+            {
+                StrongPtr(other).swap(*this);
+                return *this;
+            }
+
+            /// Returns the wrapped pointer as @c T*
+            inline T* get() const
+            {
+                return this->pointer_;
+            }
+
+            /// Returns the wrapped pointer as @c Destroyable*
+            inline Destroyable* getBase() const
+            {
+                return this->base_;
+            }
+
+            /// Implicitly converts the StrongPtr to a pointer of type @c T*
+            inline operator T*() const
+            {
+                return this->pointer_;
+            }
+
+            /// Overloaded operator, returns a pointer to the stored object.
+            inline T* operator->() const
+            {
+                assert(this->pointer_ != 0);
+                return this->pointer_;
+            }
+
+            /// Overloaded operator, returns a reference to the stored object.
+            inline T& operator*() const
+            {
+                assert(this->pointer_ != 0);
+                return *this->pointer_;
+            }
+
+            /// Returns true if the wrapped pointer is NULL.
+            inline bool operator!() const
+            {
+                return (this->pointer_ == 0);
+            }
+
+            /// Swaps the contents of two strong pointers.
+            inline void swap(StrongPtr& other)
+            {
+                {
+                    T* temp = this->pointer_;
+                    this->pointer_ = other.pointer_;
+                    other.pointer_ = temp;
+                }
+                {
+                    Destroyable* temp = this->base_;
+                    this->base_ = other.base_;
+                    other.base_ = temp;
+                }
+            }
+
+            /// Resets the strong pointer (equivalent to assigning a NULL pointer).
+            inline void reset()
+            {
+                StrongPtr().swap(*this);
+            }
+
+        private:
+            T* pointer_;            ///< The wrapped pointer to an object of type @a T
+            Destroyable* base_;    ///< The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, StrongPtr couln't be used with forward declarations)
+    };
+
+    /// Swaps the contents of two strong pointers.
+    template <class T>
+    void swap(StrongPtr<T>& a, StrongPtr<T>& b)
+    {
+        a.swap(b);
+    }
+
+    /// Uses a static_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>.
+    template <class T, class U>
+    StrongPtr<T> static_pointer_cast(const StrongPtr<U>& p)
+    {
+        return static_cast<T*>(p.get());
+    }
+
+    /// Uses a const_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>.
+    template <class T, class U>
+    StrongPtr<T> const_pointer_cast(const StrongPtr<U>& p)
+    {
+        return const_cast<T*>(p.get());
+    }
+
+    /// Uses a dynamic_cast to cast a pointer of type U* to a pointer of type T* and returns it in a new StrongPtr<T>.
+    template <class T, class U>
+    StrongPtr<T> dynamic_pointer_cast(const StrongPtr<U>& p)
+    {
+        return orxonox_cast<T*>(p.get());
+    }
+}
+
+#endif /* _StrongPtr_H__ */

Modified: code/trunk/src/libraries/core/object/WeakPtr.h
===================================================================
--- code/trunk/src/libraries/core/object/WeakPtr.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/core/object/WeakPtr.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -103,11 +103,6 @@
             {
             }
 
-            /// Constructor: Used to explicitly initialize the weak pointer with a null pointer
-            inline WeakPtr(int) : pointer_(0), base_(0), callback_(0)
-            {
-            }
-
             /// Constructor: Initializes the weak pointer with a pointer to an object.
             inline WeakPtr(T* pointer) : pointer_(pointer), base_(pointer), callback_(0)
             {
@@ -133,13 +128,6 @@
                 this->unregisterAsDestructionListener(this->base_);
             }
 
-            /// Used to assign a null pointer.
-            inline WeakPtr& operator=(int)
-            {
-                WeakPtr(0).swap(*this);
-                return *this;
-            }
-
             /// Assigns a new pointer.
             inline WeakPtr& operator=(T* pointer)
             {

Modified: code/trunk/src/libraries/network/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -33,6 +33,9 @@
   WANDiscovery.cc
   MasterServerComm.cc
   NetworkFunction.cc
+  NetworkFunctionIncludes.cc
+  NetworkFunctionManager.cc
+  NetworkStaticInitializationHandler.cc
   Host.cc
   Server.cc
   MasterServer.cc
@@ -42,38 +45,11 @@
   TrafficControl.cc
 )
 
-SET_SOURCE_FILES(NETWORK_HDR_FILES
-  Client.h
-  ClientConnection.h
-  ClientConnectionListener.h
-  Connection.h
-  FunctionCall.h
-  FunctionCallManager.h
-  #GamestateClient.h
-  GamestateHandler.h
-  GamestateManager.h
-  Host.h
-  LANDiscoverable.h
-  LANDiscovery.h
-  WANDiscoverable.h
-  WANDiscovery.h
-  MasterServerComm.h
-  NetworkChatListener.h
-  NetworkFunction.h
-  NetworkPrecompiledHeaders.h
-  NetworkPrereqs.h
-  Server.h
-  MasterServer.h
-  PeerList.h
-  ServerList.h
-  ServerConnection.h
-  TrafficControl.h
-)
-
 ADD_SUBDIRECTORY(packet)
 ADD_SUBDIRECTORY(synchronisable)
 
 ORXONOX_ADD_LIBRARY(network
+  FIND_HEADER_FILES
   TOLUA_FILES
     Client.h
     LANDiscovery.h
@@ -89,5 +65,5 @@
     util
     core
   SOURCE_FILES
-    ${NETWORK_SRC_FILES} ${NETWORK_HDR_FILES}
+    ${NETWORK_SRC_FILES}
 )

Modified: code/trunk/src/libraries/network/Client.cc
===================================================================
--- code/trunk/src/libraries/network/Client.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/Client.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,19 +44,19 @@
 
 #include "util/Clock.h"
 #include "util/Output.h"
-#include "util/ScopedSingletonManager.h"
 #include "synchronisable/Synchronisable.h"
 #include "packet/Chat.h"
 #include "packet/Gamestate.h"
 #include "FunctionCallManager.h"
 #include "core/CoreIncludes.h"
 #include "core/Game.h"
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineParser.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 namespace orxonox
 {
 
-  ManageScopedSingleton( Client, ScopeID::Root, true );
+  ManageScopedSingleton( Client, ScopeID::ROOT, false );
 
   /**
   * Constructor for the Client class
@@ -193,16 +193,6 @@
 
   void Client::connectionClosed()
   {
-    ObjectList<Synchronisable>::iterator it;
-    for(it = ObjectList<Synchronisable>::begin(); it; )
-    {
-      if( it->getSyncMode() != 0x0 )
-        (it++)->destroy();
-      else
-      {
-        ++it;
-      }
-    }
     Game::getInstance().popState();
     Game::getInstance().popState();
   }

Modified: code/trunk/src/libraries/network/ClientConnectionListener.cc
===================================================================
--- code/trunk/src/libraries/network/ClientConnectionListener.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/ClientConnectionListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,7 +34,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(ClientConnectionListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(ClientConnectionListener).inheritsFrom<Listable>();
 
     ClientConnectionListener::ClientConnectionListener()
     {

Modified: code/trunk/src/libraries/network/FunctionCall.cc
===================================================================
--- code/trunk/src/libraries/network/FunctionCall.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/FunctionCall.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -31,6 +31,7 @@
 #include <cassert>
 #include "util/MultiType.h"
 #include "NetworkFunction.h"
+#include "NetworkFunctionManager.h"
 
 namespace orxonox {
 
@@ -45,167 +46,76 @@
 
 
 bool FunctionCall::execute(){
-  if( this->bIsStatic_ )
+  NetworkFunctionBase* fct = NetworkFunctionManager::getInstance().getFunctionByNetworkId( this->functionID_ );
+  assert( fct != NULL );
+  assert( this->nrOfArguments_==this->arguments_.size() );
+  switch(this->nrOfArguments_)
   {
-    NetworkFunctionStatic *fct = NetworkFunctionStatic::getFunction( this->functionID_ );
-    assert( this->nrOfArguments_==this->arguments_.size() );
-    switch(this->nrOfArguments_)
-    {
-      case 0:
-        fct->call();
-        break;
-      case 1:
-        fct->call(this->arguments_[0]);
-        break;
-      case 2:
-        fct->call(this->arguments_[0], this->arguments_[1]);
-        break;
-      case 3:
-        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2]);
-        break;
-      case 4:
-        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
-        break;
-      case 5:
-        fct->call(this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
-        break;
-      default:
-        assert(0);
-    }
+    case 0:
+      return fct->call(this->objectID_);
+    case 1:
+      return fct->call(this->objectID_, this->arguments_[0]);
+    case 2:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]);
+    case 3:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]);
+    case 4:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]);
+    case 5:
+      return fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]);
+    default:
+      assert(0);
+      return true; // return true to avoid that this functions gets called over and over again
   }
-  else // not a static function, so also handle with the objectID
-  {
-    NetworkMemberFunctionBase *fct = NetworkMemberFunctionBase::getFunction( this->functionID_ );
-    switch(this->nrOfArguments_)
-    {
-      case 0:
-        if( !fct->call(this->objectID_) )
-          return false;
-        break;
-      case 1:
-        if( !fct->call(this->objectID_, this->arguments_[0]) )
-          return false;
-        break;
-      case 2:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1]) )
-          return false;
-        break;
-      case 3:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2]) )
-          return false;
-        break;
-      case 4:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3]) )
-          return false;
-        break;
-      case 5:
-        if( !fct->call(this->objectID_, this->arguments_[0], this->arguments_[1], this->arguments_[2], this->arguments_[3], this->arguments_[4]) )
-          return false;
-        break;
-      default:
-        assert(0);
-    }
-  }
-  return true;
 }
 
-void FunctionCall::setCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
+void FunctionCall::setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){
 
   // first determine the size that has to be reserved for this call
-  uint32_t callsize = 2*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and for bool isStatic
+  uint32_t callsize = 3*sizeof(uint32_t); //size for network-function-id and nrOfArguments and the objectID
   uint32_t nrOfArguments = 0;
-  if(mt1)
+  if(!mt1.null())
   {
     nrOfArguments++;
-    callsize += mt1->getNetworkSize();
-    this->arguments_.push_back(*mt1);
-    if(mt2)
+    callsize += mt1.getNetworkSize();
+    this->arguments_.push_back(mt1);
+    if(!mt2.null())
     {
       nrOfArguments++;
-      callsize += mt2->getNetworkSize();
-      this->arguments_.push_back(*mt2);
-      if(mt3)
+      callsize += mt2.getNetworkSize();
+      this->arguments_.push_back(mt2);
+      if(!mt3.null())
       {
         nrOfArguments++;
-        callsize += mt3->getNetworkSize();
-        this->arguments_.push_back(*mt3);
-        if(mt4)
+        callsize += mt3.getNetworkSize();
+        this->arguments_.push_back(mt3);
+        if(!mt4.null())
         {
           nrOfArguments++;
-          callsize += mt4->getNetworkSize();
-          this->arguments_.push_back(*mt4);
-          if(mt5)
+          callsize += mt4.getNetworkSize();
+          this->arguments_.push_back(mt4);
+          if(!mt5.null())
           {
             nrOfArguments++;
-            callsize += mt5->getNetworkSize();
-            this->arguments_.push_back(*mt5);
+            callsize += mt5.getNetworkSize();
+            this->arguments_.push_back(mt5);
           }
         }
       }
     }
   }
   this->nrOfArguments_ = nrOfArguments;
-  this->size_ = callsize;
-  this->bIsStatic_ = true;
   this->functionID_ = networkID;
-}
-
-void FunctionCall::setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){
-
-  // first determine the size that has to be reserved for this call
-  uint32_t callsize = 3*sizeof(uint32_t)+sizeof(uint8_t); //size for network-function-id and nrOfArguments and the objectID and bIsStatic
-  uint32_t nrOfArguments = 0;
-  if(mt1)
-  {
-    nrOfArguments++;
-    callsize += mt1->getNetworkSize();
-    this->arguments_.push_back(*mt1);
-    if(mt2)
-    {
-      nrOfArguments++;
-      callsize += mt2->getNetworkSize();
-      this->arguments_.push_back(*mt2);
-      if(mt3)
-      {
-        nrOfArguments++;
-        callsize += mt3->getNetworkSize();
-        this->arguments_.push_back(*mt3);
-        if(mt4)
-        {
-          nrOfArguments++;
-          callsize += mt4->getNetworkSize();
-          this->arguments_.push_back(*mt4);
-          if(mt5)
-          {
-            nrOfArguments++;
-            callsize += mt5->getNetworkSize();
-            this->arguments_.push_back(*mt5);
-          }
-        }
-      }
-    }
-  }
-  this->nrOfArguments_ = nrOfArguments;
-  this->bIsStatic_ = false;
-  this->functionID_ = networkID;
-  this->size_ = callsize;
   this->objectID_ = objectID;
+  this->size_ = callsize;
 }
 
 void FunctionCall::loadData(uint8_t*& mem)
 {
   this->functionID_ = *(uint32_t*)mem;
-  this->bIsStatic_ = *(uint8_t*)(mem+sizeof(uint32_t));
-  this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t));
-  if( this->bIsStatic_ )
-  {
-    mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
-  }
-  else
-  {
-    this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t));
-    mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
-  }
+  this->nrOfArguments_ = *(uint32_t*)(mem+sizeof(uint32_t));
+  this->objectID_ = *(uint32_t*)(mem+2*sizeof(uint32_t));
+  mem += 3*sizeof(uint32_t);
   for( unsigned int i=0; i<this->nrOfArguments_; ++i )
   {
     this->arguments_.push_back(MultiType());
@@ -217,17 +127,9 @@
 {
   // now serialise the mt values and copy the function id and isStatic
   *(uint32_t*)mem = this->functionID_;
-  *(uint8_t*)(mem+sizeof(uint32_t)) = this->bIsStatic_;
-  *(uint32_t*)(mem+sizeof(uint32_t)+sizeof(uint8_t)) = this->nrOfArguments_;
-  if( this->bIsStatic_ )
-  {
-    mem += 2*sizeof(uint32_t)+sizeof(uint8_t);
-  }
-  else
-  {
-    *(uint32_t*)(mem+2*sizeof(uint32_t)+sizeof(uint8_t)) = this->objectID_;
-    mem += 3*sizeof(uint32_t)+sizeof(uint8_t);
-  }
+  *(uint32_t*)(mem+sizeof(uint32_t)) = this->nrOfArguments_;
+  *(uint32_t*)(mem+2*sizeof(uint32_t)) = this->objectID_;
+  mem += 3*sizeof(uint32_t);
   for( std::vector<MultiType>::iterator it = this->arguments_.begin(); it!=this->arguments_.end(); ++it )
   {
     it->exportData( mem );

Modified: code/trunk/src/libraries/network/FunctionCall.h
===================================================================
--- code/trunk/src/libraries/network/FunctionCall.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/FunctionCall.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -51,16 +51,14 @@
   inline unsigned int getSize() const { return this->size_; }
   bool execute();
 
-  void setCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
-  void setCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  void setCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
   
   void saveData( uint8_t*& mem );
   void loadData( uint8_t*& mem );
 private:
   uint32_t                  nrOfArguments_;
-  bool                      bIsStatic_;
   uint32_t                  functionID_;
-  uint32_t                  objectID_;
+  uint32_t                  objectID_; // equals OBJECTID_UNKNOWN for static functions
   uint32_t                  size_;
   std::vector<MultiType>    arguments_;
 };

Modified: code/trunk/src/libraries/network/FunctionCallManager.cc
===================================================================
--- code/trunk/src/libraries/network/FunctionCallManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/FunctionCallManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,121 +38,17 @@
 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::sPeerMap_;
 std::vector<std::pair<FunctionCall, std::pair<uint32_t, uint32_t> > > FunctionCallManager::sIncomingFunctionCallBuffer_;
 
-// Static calls
 
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID)
+void FunctionCallManager::addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
 {
   if(sPeerMap_.find(peerID)==sPeerMap_.end())
   {
     FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
     FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
   }
-  FunctionCallManager::sPeerMap_[peerID]->addCallStatic(functionID);
+  FunctionCallManager::sPeerMap_[peerID]->addCall(functionID, objectID, mt1, mt2, mt3, mt4, mt5);
 }
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4);
-}
-void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager:: sPeerMap_[peerID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5);
-}
 
-
-// MemberCalls
-
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4);
-}
-void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
-{
-  if(sPeerMap_.find(peerID)==sPeerMap_.end())
-  {
-    FunctionCallManager::sPeerMap_[peerID] = new packet::FunctionCalls;
-    FunctionCallManager::sPeerMap_[peerID]->setPeerID(peerID);
-  }
-  FunctionCallManager::sPeerMap_[peerID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5);
-}
-
 // Send calls
 
 void FunctionCallManager::sendCalls(orxonox::Host* host)

Modified: code/trunk/src/libraries/network/FunctionCallManager.h
===================================================================
--- code/trunk/src/libraries/network/FunctionCallManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/FunctionCallManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -45,20 +45,8 @@
 class _NetworkExport FunctionCallManager
 {
 public:
-  static void addCallStatic(uint32_t functionID, uint32_t peerID);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
-  static void addCallStatic(uint32_t functionID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
+  static void addCall(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
 
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4);
-  static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t peerID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
-
   static void sendCalls(orxonox::Host* host);
   
   static void bufferIncomingFunctionCall( const FunctionCall& fctCall, uint32_t minGamestateID, uint32_t peerID );

Modified: code/trunk/src/libraries/network/Host.cc
===================================================================
--- code/trunk/src/libraries/network/Host.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/Host.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -33,7 +33,7 @@
 
 #include "core/CoreIncludes.h"
 #include "core/object/ObjectList.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "NetworkChatListener.h"
 
 namespace orxonox {
@@ -142,6 +142,8 @@
   // NetworkChatListener                                                  //
   //////////////////////////////////////////////////////////////////////////
 
+  RegisterAbstractClass(NetworkChatListener).inheritsFrom<Listable>();
+
   NetworkChatListener::NetworkChatListener()
   {
       RegisterObject(NetworkChatListener);

Modified: code/trunk/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/LANDiscovery.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/LANDiscovery.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -31,13 +31,13 @@
 #include <enet/enet.h>
 #include <cstring>
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 
 namespace orxonox
 {
-  ManageScopedSingleton(LANDiscovery, ScopeID::Graphics, true);
+  ManageScopedSingleton(LANDiscovery, ScopeID::GRAPHICS, false);
 
   LANDiscovery::LANDiscovery()
   {

Modified: code/trunk/src/libraries/network/MasterServer.cc
===================================================================
--- code/trunk/src/libraries/network/MasterServer.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/MasterServer.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -27,10 +27,10 @@
  */
 
 #include "MasterServer.h"
-#include "util/ScopedSingletonManager.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/CorePrereqs.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "util/Output.h"
 
 namespace orxonox

Modified: code/trunk/src/libraries/network/NetworkFunction.cc
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/NetworkFunction.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -27,86 +27,21 @@
  */
 
 #include "NetworkFunction.h"
-#include "core/CoreIncludes.h"
+#include "NetworkFunctionManager.h"
 
 namespace orxonox
 {
-  std::map<uint32_t, bool> NetworkFunctionBase::isStaticMap_;
+    NetworkFunctionBase::NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer)
+    {
+        static uint32_t networkID = 0;
+        this->networkID_ = networkID++;
+        this->name_ = name;
+        this->pointer_ = pointer;
+    }
 
-  std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::functorMap_;
-  std::map<uint32_t, NetworkMemberFunctionBase*> NetworkMemberFunctionBase::idMap_;
-
-  // no suitable factory for NetworkFunctionBase (and children), so we declare it abstract
-  RegisterAbstractClass(NetworkFunctionBase).inheritsFrom(Class(Listable));
-  RegisterAbstractClass(NetworkFunctionStatic).inheritsFrom(Class(NetworkFunctionBase));
-  RegisterAbstractClass(NetworkMemberFunctionBase).inheritsFrom(Class(NetworkFunctionBase));
-
-  NetworkFunctionBase::NetworkFunctionBase(const std::string& name)
-  {
-      RegisterObject(NetworkFunctionBase);
-
-    static uint32_t networkID = 0;
-    this->networkID_ = networkID++;
-
-    this->name_ = name;
-    NetworkFunctionBase::getNameMap()[name] = this;
-  }
-  NetworkFunctionBase::~NetworkFunctionBase()
-  {
-  }
-
-
-  void NetworkFunctionBase::destroyAllNetworkFunctions()
-  {
-    std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
-    std::map<std::string, NetworkFunctionBase*>::iterator it;
-    for( it=map.begin(); it!=map.end(); ++it )
-      delete it->second;
-  }
-
-
-  /*static*/ std::map<std::string, NetworkFunctionBase*>& NetworkFunctionBase::getNameMap()
-  {
-    static std::map<std::string, NetworkFunctionBase*> nameMap_;
-    return nameMap_;
-  }
-
-
-  NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p):
-    NetworkFunctionBase(name)
-  {
-    RegisterObject(NetworkFunctionStatic);
-
-    this->functor_ = functor;
-    NetworkFunctionStatic::getFunctorMap()[p] = this;
-    NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this;
-  }
-
-  /*static*/ std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& NetworkFunctionStatic::getFunctorMap()
-  {
-    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*> functorMap_;
-    return functorMap_;
-  }
-
-  /*static*/ std::map<uint32_t, NetworkFunctionStatic*>& NetworkFunctionStatic::getIdMap()
-  {
-    static std::map<uint32_t, NetworkFunctionStatic*> idMap_;
-    return idMap_;
-  }
-
-
-  NetworkMemberFunctionBase::NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p):
-    NetworkFunctionBase(name)
-  {
-    RegisterObject(NetworkMemberFunctionBase);
-
-    this->functorMap_[p] = this;
-    this->idMap_[ this->getNetworkID() ] = this;
-  }
-
-  NetworkMemberFunctionBase::~NetworkMemberFunctionBase()
-  {
-  }
-
-
+    void NetworkFunctionBase::setNetworkID(uint32_t id)
+    {
+        this->networkID_ = id;
+        NetworkFunctionManager::getInstance().registerFunction(this);   // register with new id
+    }
 }

Modified: code/trunk/src/libraries/network/NetworkFunction.h
===================================================================
--- code/trunk/src/libraries/network/NetworkFunction.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/NetworkFunction.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,11 +35,7 @@
 #include <cstring>
 #include <map>
 #include <string>
-#include <boost/preprocessor/cat.hpp>
-#include <boost/static_assert.hpp>
 
-#include "core/object/Listable.h"
-#include "core/class/Identifier.h"
 #include "core/command/Functor.h"
 #include "FunctionCallManager.h"
 #include "synchronisable/Synchronisable.h"
@@ -59,10 +55,24 @@
   bool operator<(const NetworkFunctionPointer& b) const
   {
 #if defined(ORXONOX_COMPILER_GCC) && defined(ORXONOX_ARCH_32)
-    return pointer[0]<b.pointer[0] ? true : pointer[1]<b.pointer[1];
-#else //ORXONOX_COMPILER_GCC
-    return pointer[0]<b.pointer[0] ? true : ( pointer[1]<b.pointer[1] ? true : ( pointer[2]<b.pointer[2] ? true : pointer[3]<b.pointer[3] ) );
-#endif //ORXONOX_COMPILER_GCC
+    if (pointer[0] != b.pointer[0])
+        return pointer[0] < b.pointer[0];
+    else if (pointer[1] != b.pointer[1])
+        return pointer[1] < b.pointer[1];
+    else
+        return false;
+#else
+    if (pointer[0] != b.pointer[0])
+        return pointer[0] < b.pointer[0];
+    else if (pointer[1] != b.pointer[1])
+        return pointer[1] < b.pointer[1];
+    else if (pointer[2] != b.pointer[2])
+        return pointer[2] < b.pointer[2];
+    else if (pointer[3] != b.pointer[3])
+        return pointer[3] < b.pointer[3];
+    else
+        return false;
+#endif
   }
 };
 
@@ -70,59 +80,47 @@
 
 
 
-class _NetworkExport NetworkFunctionBase: virtual public Listable {
+class _NetworkExport NetworkFunctionBase {
   public:
-    NetworkFunctionBase(const std::string& name);
-    ~NetworkFunctionBase();
+    NetworkFunctionBase(const std::string& name, const NetworkFunctionPointer& pointer);
+    virtual ~NetworkFunctionBase() {}
 
-    virtual void        setNetworkID(uint32_t id)       { this->networkID_ = id; }
-    inline uint32_t     getNetworkID() const            { return this->networkID_; }
-    inline const std::string& getName() const           { return name_; }
-    static inline bool  isStatic( uint32_t networkID )  { return isStaticMap_[networkID]; }
+    void setNetworkID(uint32_t id);
+    inline uint32_t     getNetworkID() const                { return this->networkID_; }
+    inline const std::string& getName() const               { return this->name_; }
+    inline const NetworkFunctionPointer& getPointer() const { return this->pointer_; }
 
-    static inline void setNetworkID(const std::string& name, uint32_t id)
-    {
-        std::map<std::string, NetworkFunctionBase*>& map = NetworkFunctionBase::getNameMap();
-        assert( map.find(name)!=map.end() );
-        map[name]->setNetworkID(id);
-    }
+    virtual bool call(uint32_t objectID)=0;
+    virtual bool call(uint32_t objectID, const MultiType& mt1)=0;
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0;
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0;
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
 
-    static void destroyAllNetworkFunctions();
-
-  protected:
-    static std::map<uint32_t, bool> isStaticMap_;
-
   private:
-    static std::map<std::string, NetworkFunctionBase*>& getNameMap();
     uint32_t networkID_;
     std::string name_;
+    NetworkFunctionPointer pointer_;
 
 };
 
 
 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase {
   public:
-    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p);
+    NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkFunctionBase(name, p)
+        , functor_(functor)
+    { }
 
-    inline void call(){ (*this->functor_)(); }
-    inline void call(const MultiType& mt1){ (*this->functor_)(mt1); }
-    inline void call(const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); }
-    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); }
-    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); }
-    inline void call(const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); }
+    // ignore the objectID because its a static function
+    virtual bool call(uint32_t objectID){ (*this->functor_)(); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1){ (*this->functor_)(mt1); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2){ (*this->functor_)(mt1, mt2); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3){ (*this->functor_)(mt1, mt2, mt3); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4){ (*this->functor_)(mt1, mt2, mt3, mt4); return true; }
+    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5){ (*this->functor_)(mt1, mt2, mt3, mt4, mt5); return true; }
 
-    virtual void setNetworkID( uint32_t id )
-        { NetworkFunctionBase::setNetworkID( id ); NetworkFunctionStatic::getIdMap()[id] = this; }
-    static inline NetworkFunctionStatic* getNetworkFunction( uint32_t id)
-        { assert( NetworkFunctionStatic::getIdMap().find(id)!=NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
-    static NetworkFunctionStatic* getFunction( uint32_t id )
-        { assert( NetworkFunctionStatic::getIdMap().find(id) != NetworkFunctionStatic::getIdMap().end() ); return NetworkFunctionStatic::getIdMap()[id]; }
-    static NetworkFunctionStatic* getFunction( const NetworkFunctionPointer& p )
-        { assert( NetworkFunctionStatic::getFunctorMap().find(p) != NetworkFunctionStatic::getFunctorMap().end() ); return NetworkFunctionStatic::getFunctorMap()[p]; }
-
   private:
-    static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap();
-    static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap();
     FunctorStaticPtr functor_;
 
 };
@@ -130,31 +128,18 @@
 
 class _NetworkExport NetworkMemberFunctionBase: public NetworkFunctionBase {
   public:
-    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p);
-    ~NetworkMemberFunctionBase();
-
-    virtual void setNetworkID( uint32_t id ){ NetworkFunctionBase::setNetworkID( id ); idMap_[id] = this; }
-    static inline NetworkMemberFunctionBase* getNetworkFunction( uint32_t id){ assert( idMap_.find(id)!=idMap_.end() ); return idMap_[id]; }
-    static NetworkMemberFunctionBase* getFunction( uint32_t id ){ assert( idMap_.find(id) != idMap_.end() ); return idMap_[id]; }
-    static NetworkMemberFunctionBase* getFunction( const NetworkFunctionPointer& p ){ assert( functorMap_.find(p) != functorMap_.end() ); return functorMap_[p]; }
-
-    //
-    virtual bool call(uint32_t objectID)=0;
-    virtual bool call(uint32_t objectID, const MultiType& mt1)=0;
-    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2)=0;
-    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3)=0;
-    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4)=0;
-    virtual bool call(uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)=0;
-
-  private:
-    static std::map<NetworkFunctionPointer, NetworkMemberFunctionBase*> functorMap_;
-    static std::map<uint32_t, NetworkMemberFunctionBase*> idMap_;
+    NetworkMemberFunctionBase(const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkFunctionBase(name, p)
+    { }
 };
 
 
 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase {
   public:
-    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p);
+    NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p)
+        : NetworkMemberFunctionBase(name, p)
+        , functor_(functor)
+    { }
 
     inline bool call(uint32_t objectID)
     {
@@ -221,59 +206,6 @@
     FunctorMemberPtr<T> functor_;
 };
 
-template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p):
-    NetworkMemberFunctionBase(name, p), functor_(functor)
-{
 }
 
-template<class T> inline void copyPtr( T ptr, NetworkFunctionPointer& destptr)
-{
-  if( sizeof(NetworkFunctionPointer)-sizeof(T) > 0)
-    memset((uint8_t*)&destptr + sizeof(T), 0, sizeof(NetworkFunctionPointer)-sizeof(T));
-  T p2 = ptr;
-  memcpy( &destptr, &p2, sizeof(T) );
-//   for(unsigned int i=0; i<(sizeof(T)-1/4)+1; i++)
-//     *((uint32_t*)destptr+i) = p2>>32*i;
-}
-
-template<class T> inline void* registerStaticNetworkFunctionFct( T ptr, const std::string& name )
-{
-  BOOST_STATIC_ASSERT( sizeof(T)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for static functions than defined above
-  NetworkFunctionPointer destptr;
-  copyPtr( ptr, destptr );
-  new NetworkFunctionStatic( createFunctor(ptr), name, destptr );
-  return 0;
-}
-
-template<class T, class PT> inline void* registerMemberNetworkFunctionFct( PT ptr, const std::string& name )
-{
-  BOOST_STATIC_ASSERT( sizeof(PT)<=sizeof(NetworkFunctionPointer) ); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
-  NetworkFunctionPointer destptr;
-  copyPtr( ptr, destptr );
-  new NetworkMemberFunction<T>( createFunctor(ptr), name, destptr );
-  return 0;
-}
-
-#define registerStaticNetworkFunction( functionPointer ) \
-  static void* BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) = registerStaticNetworkFunctionFct( functionPointer, #functionPointer );
-#define registerMemberNetworkFunction( class, function ) \
-  static void* BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) = registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function);
-  // call it with functionPointer, clientID, args
-#define callStaticNetworkFunction( functionPointer, ...) \
-  { \
-    NetworkFunctionPointer p1; \
-    copyPtr( functionPointer, p1 ); \
-    FunctionCallManager::addCallStatic(NetworkFunctionStatic::getFunction(p1)->getNetworkID(), __VA_ARGS__); \
-  }
-  // call it with class, function, objectID, clientID, args
-#define callMemberNetworkFunction( class, function, objectID, ...) \
-  { \
-    NetworkFunctionPointer p1; \
-    copyPtr( &class::function, p1 ); \
-    FunctionCallManager::addCallMember(NetworkMemberFunctionBase::getFunction(p1)->getNetworkID(), objectID, __VA_ARGS__); \
-  }
-
-
-}
-
 #endif /* _NetworkFunction_H__ */

Copied: code/trunk/src/libraries/network/NetworkFunctionIncludes.cc (from rev 10623, code/branches/core7/src/libraries/network/NetworkFunctionIncludes.cc)
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionIncludes.cc	                        (rev 0)
+++ code/trunk/src/libraries/network/NetworkFunctionIncludes.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,53 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "NetworkFunctionIncludes.h"
+#include "NetworkFunctionManager.h"
+
+#include "core/module/StaticInitializationHandlerIncludes.h"
+#include "NetworkStaticInitializationHandler.h"
+
+namespace orxonox
+{
+    RegisterStaticInitializationHandler(NetworkStaticInitializationHandler);
+
+    void StaticallyInitializedNetworkFunction::load()
+    {
+        NetworkFunctionManager::getInstance().registerFunction(this->function_);
+    }
+
+    void StaticallyInitializedNetworkFunction::unload()
+    {
+        NetworkFunctionManager::getInstance().unregisterFunction(this->function_);
+    }
+
+    uint32_t getNetworkIdForPointer(const NetworkFunctionPointer& pointer)
+    {
+        return NetworkFunctionManager::getInstance().getFunctionByFunctionPointer(pointer)->getNetworkID();
+    }
+}

Copied: code/trunk/src/libraries/network/NetworkFunctionIncludes.h (from rev 10623, code/branches/core7/src/libraries/network/NetworkFunctionIncludes.h)
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionIncludes.h	                        (rev 0)
+++ code/trunk/src/libraries/network/NetworkFunctionIncludes.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,119 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _NetworkFunctionIncludes_H__
+#define _NetworkFunctionIncludes_H__
+
+#include "NetworkPrereqs.h"
+
+#include <boost/preprocessor/cat.hpp>
+#include <boost/static_assert.hpp>
+
+#include "NetworkFunction.h"
+#include "core/module/StaticallyInitializedInstance.h"
+
+#define registerStaticNetworkFunction( functionPointer ) \
+    static orxonox::NetworkFunctionBase& BOOST_PP_CAT( NETWORK_FUNCTION_, __UNIQUE_NUMBER__ ) \
+        = (new orxonox::SI_NF(orxonox::registerStaticNetworkFunctionFct( functionPointer, #functionPointer )))->getFunction()
+
+#define registerMemberNetworkFunction( class, function ) \
+    static orxonox::NetworkFunctionBase& BOOST_PP_CAT( NETWORK_FUNCTION_##class, __UNIQUE_NUMBER__ ) \
+        = (new orxonox::SI_NF(orxonox::registerMemberNetworkFunctionFct<class>( &class::function, #class "_" #function)))->getFunction()
+
+namespace orxonox
+{
+    class _NetworkExport StaticallyInitializedNetworkFunction : public StaticallyInitializedInstance
+    {
+        public:
+            StaticallyInitializedNetworkFunction(NetworkFunctionBase* function)
+                : StaticallyInitializedInstance(StaticInitialization::NETWORK_FUNCTION)
+                , function_(function)
+            {}
+            ~StaticallyInitializedNetworkFunction() { delete function_; }
+
+            virtual void load();
+            virtual void unload();
+
+            inline NetworkFunctionBase& getFunction()
+                { return *this->function_; }
+
+        private:
+            NetworkFunctionBase* function_;
+    };
+
+    typedef StaticallyInitializedNetworkFunction SI_NF;
+
+    template<class PT>
+    inline NetworkFunctionBase* registerStaticNetworkFunctionFct(PT ptr, const std::string& name)
+    {
+        BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for static functions than defined above
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        return new NetworkFunctionStatic(createFunctor(ptr), name, destptr);
+    }
+
+    template<class T, class PT>
+    inline NetworkFunctionBase* registerMemberNetworkFunctionFct(PT ptr, const std::string& name)
+    {
+        BOOST_STATIC_ASSERT(sizeof(PT) <= sizeof(NetworkFunctionPointer)); // if this fails your compiler uses bigger pointers for a specific kind of member functions than defined above
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        return new NetworkMemberFunction<T>(createFunctor(ptr), name, destptr);
+    }
+
+    _NetworkExport uint32_t getNetworkIdForPointer(const NetworkFunctionPointer& pointer);
+
+    // call it with functionPointer, clientID, args
+    template<class PT>
+    void callStaticNetworkFunction(PT ptr, uint32_t clientID, const MultiType& mt1 = MultiType::Null, const MultiType& mt2 = MultiType::Null, const MultiType& mt3 = MultiType::Null, const MultiType& mt4 = MultiType::Null, const MultiType& mt5 = MultiType::Null)
+    {
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        FunctionCallManager::addCall(getNetworkIdForPointer(destptr), OBJECTID_UNKNOWN, clientID, mt1, mt2, mt3, mt4, mt5);
+    }
+
+    // call it with class::function, objectID, clientID, args
+    template<class PT>
+    void callMemberNetworkFunction(PT ptr, uint32_t objectID, uint32_t clientID, const MultiType& mt1 = MultiType::Null, const MultiType& mt2 = MultiType::Null, const MultiType& mt3 = MultiType::Null, const MultiType& mt4 = MultiType::Null, const MultiType& mt5 = MultiType::Null)
+    {
+        NetworkFunctionPointer destptr;
+        copyPtr(ptr, destptr);
+        FunctionCallManager::addCall(getNetworkIdForPointer(destptr), objectID, clientID, mt1, mt2, mt3, mt4, mt5);
+    }
+
+    template<class PT>
+    inline void copyPtr(PT ptr, NetworkFunctionPointer& destptr)
+    {
+        if (sizeof(NetworkFunctionPointer) - sizeof(PT) > 0)
+            memset((uint8_t*)&destptr + sizeof(PT), 0, sizeof(NetworkFunctionPointer) - sizeof(PT));
+        PT p2 = ptr;
+        memcpy(&destptr, &p2, sizeof(PT));
+    }
+}
+
+#endif /* _NetworkFunctionIncludes_H__ */

Copied: code/trunk/src/libraries/network/NetworkFunctionManager.cc (from rev 10623, code/branches/core7/src/libraries/network/NetworkFunctionManager.cc)
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionManager.cc	                        (rev 0)
+++ code/trunk/src/libraries/network/NetworkFunctionManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,83 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "NetworkFunctionManager.h"
+#include "NetworkFunction.h"
+
+namespace orxonox
+{
+    NetworkFunctionManager* NetworkFunctionManager::singletonPtr_s = 0;
+
+    void NetworkFunctionManager::registerFunction(NetworkFunctionBase* function)
+    {
+        this->functions_.insert(function);
+        this->nameMap_[function->getName()] = function;
+        this->idMap_[function->getNetworkID()] = function;
+        this->functorMap_[function->getPointer()] = function;
+    }
+
+    void NetworkFunctionManager::unregisterFunction(NetworkFunctionBase* function)
+    {
+        this->functions_.erase(function);
+        this->nameMap_.erase(function->getName());
+        this->idMap_.erase(function->getNetworkID());
+        this->functorMap_.erase(function->getPointer());
+    }
+
+    NetworkFunctionBase* NetworkFunctionManager::getFunctionByName(const std::string& name)
+    {
+        std::map<std::string, NetworkFunctionBase*>::iterator it = nameMap_.find(name);
+        assert(it != nameMap_.end());
+        return it->second;
+    }
+
+    NetworkFunctionBase* NetworkFunctionManager::getFunctionByFunctionPointer(const NetworkFunctionPointer& p)
+    {
+        std::map<NetworkFunctionPointer, NetworkFunctionBase*>::iterator it = functorMap_.find(p);
+        assert(it != functorMap_.end());
+        return it->second;
+    }
+
+    NetworkFunctionBase* NetworkFunctionManager::getFunctionByNetworkId(uint32_t id)
+    {
+        std::map<uint32_t, NetworkFunctionBase*>::iterator it = idMap_.find(id);
+        assert(it != idMap_.end());
+        if(it != idMap_.end())
+            return it->second;
+        else
+            return NULL;
+    }
+
+    /**
+        @brief Cleans the NetworkID map (needed on clients for correct initialization)
+    */
+    void NetworkFunctionManager::clearNetworkIDs()
+    {
+        this->idMap_.clear();
+    }
+}

Copied: code/trunk/src/libraries/network/NetworkFunctionManager.h (from rev 10623, code/branches/core7/src/libraries/network/NetworkFunctionManager.h)
===================================================================
--- code/trunk/src/libraries/network/NetworkFunctionManager.h	                        (rev 0)
+++ code/trunk/src/libraries/network/NetworkFunctionManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,70 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef __NetworkFunctionManager_H__
+#define __NetworkFunctionManager_H__
+
+#include "NetworkPrereqs.h"
+
+#include <cassert>
+#include <map>
+#include <set>
+
+#include "util/Singleton.h"
+#include "NetworkFunction.h"
+
+namespace orxonox
+{
+    class _NetworkExport NetworkFunctionManager : public Singleton<NetworkFunctionManager>
+    {
+        friend class Singleton<NetworkFunctionManager>;
+
+        public:
+            void registerFunction(NetworkFunctionBase* function);
+            void unregisterFunction(NetworkFunctionBase* function);
+
+            inline const std::set<NetworkFunctionBase*>& getAllFunctions()
+                { return functions_; }
+
+            NetworkFunctionBase* getFunctionByName(const std::string& name);
+            NetworkFunctionBase* getFunctionByFunctionPointer(const NetworkFunctionPointer& p);
+            NetworkFunctionBase* getFunctionByNetworkId(uint32_t id);
+
+            void clearNetworkIDs();
+
+        private:
+            std::set<NetworkFunctionBase*> functions_;
+            std::map<std::string, NetworkFunctionBase*> nameMap_;
+            std::map<NetworkFunctionPointer, NetworkFunctionBase*> functorMap_;
+            std::map<uint32_t, NetworkFunctionBase*> idMap_;
+
+            static NetworkFunctionManager* singletonPtr_s;
+    };
+}
+
+#endif /* __NetworkFunctionManager_H__ */

Modified: code/trunk/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/libraries/network/NetworkPrereqs.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/NetworkPrereqs.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -96,6 +96,12 @@
       };
     }
   }
+
+  namespace StaticInitialization
+  {
+    typedef int Type;
+    static const Type NETWORK_FUNCTION = 6;
+  }
 }
 
 //-----------------------------------------------------------------------

Copied: code/trunk/src/libraries/network/NetworkStaticInitializationHandler.cc (from rev 10623, code/branches/core7/src/libraries/network/NetworkStaticInitializationHandler.cc)
===================================================================
--- code/trunk/src/libraries/network/NetworkStaticInitializationHandler.cc	                        (rev 0)
+++ code/trunk/src/libraries/network/NetworkStaticInitializationHandler.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,56 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "NetworkStaticInitializationHandler.h"
+
+#include "core/module/ModuleInstance.h"
+#include "NetworkFunctionManager.h"
+
+namespace orxonox
+{
+    void NetworkStaticInitializationHandler::setupHandler()
+    {
+        // initialize singleton
+        new NetworkFunctionManager();
+    }
+
+    void NetworkStaticInitializationHandler::shutdownHandler()
+    {
+        delete &NetworkFunctionManager::getInstance();
+    }
+
+    void NetworkStaticInitializationHandler::loadModule(ModuleInstance* module)
+    {
+        module->loadAllStaticallyInitializedInstances(StaticInitialization::NETWORK_FUNCTION);
+    }
+
+    void NetworkStaticInitializationHandler::unloadModule(ModuleInstance* module)
+    {
+        module->unloadAllStaticallyInitializedInstances(StaticInitialization::NETWORK_FUNCTION);
+    }
+}

Copied: code/trunk/src/libraries/network/NetworkStaticInitializationHandler.h (from rev 10623, code/branches/core7/src/libraries/network/NetworkStaticInitializationHandler.h)
===================================================================
--- code/trunk/src/libraries/network/NetworkStaticInitializationHandler.h	                        (rev 0)
+++ code/trunk/src/libraries/network/NetworkStaticInitializationHandler.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,49 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _NetworkStaticInitializationHandler_H__
+#define _NetworkStaticInitializationHandler_H__
+
+#include "network/NetworkPrereqs.h"
+
+#include "core/module/StaticInitializationHandler.h"
+
+namespace orxonox
+{
+    class _NetworkExport NetworkStaticInitializationHandler : public StaticInitializationHandler
+    {
+        public:
+            virtual void setupHandler();
+            virtual void shutdownHandler();
+
+            virtual void loadModule(ModuleInstance* module);
+            virtual void unloadModule(ModuleInstance* module);
+    };
+}
+
+#endif /* _NetworkStaticInitializationHandler_H__ */

Modified: code/trunk/src/libraries/network/WANDiscoverable.cc
===================================================================
--- code/trunk/src/libraries/network/WANDiscoverable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/WANDiscoverable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,6 +38,7 @@
 
 namespace orxonox
 {
+  RegisterAbstractClass(WANDiscoverable).inheritsFrom<Configurable>();
 
   WANDiscoverable::WANDiscoverable(): bActive_(false)
   {

Modified: code/trunk/src/libraries/network/WANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/WANDiscovery.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/WANDiscovery.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,6 +36,8 @@
 
 namespace orxonox
 {
+  RegisterAbstractClass(WANDiscovery).inheritsFrom<Configurable>();
+
   WANDiscovery::WANDiscovery()
   {
     /* debugging output */

Modified: code/trunk/src/libraries/network/packet/FunctionCalls.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionCalls.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/packet/FunctionCalls.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -81,24 +81,15 @@
   return true;
 }
 
-void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
+void FunctionCalls::addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5)
 {
   assert(!isDataENetAllocated());
   
   this->functionCalls_.push(orxonox::FunctionCall());
-  this->functionCalls_.back().setCallStatic( networkID, mt1, mt2, mt3, mt4, mt5 );
+  this->functionCalls_.back().setCall( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
   this->currentSize_ += this->functionCalls_.back().getSize();
 }
 
-void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5)
-{
-  assert(!isDataENetAllocated());
-  
-  this->functionCalls_.push(orxonox::FunctionCall());
-  this->functionCalls_.back().setCallMember( networkID, objectID, mt1, mt2, mt3, mt4, mt5 );
-  this->currentSize_ += this->functionCalls_.back().getSize();
-}
-
 bool FunctionCalls::send(orxonox::Host* host)
 {
   this->minGamestateID_ = host->getCurrentGamestateID();

Modified: code/trunk/src/libraries/network/packet/FunctionCalls.h
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionCalls.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/packet/FunctionCalls.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -55,8 +55,7 @@
     { assert(!this->isDataENetAllocated()); return currentSize_; }
   virtual bool process(orxonox::Host* host);
 
-  void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
-  void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0);
+  void addCall( uint32_t networkID, uint32_t objectID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5);
   virtual bool send(orxonox::Host* host);
 private:
   std::queue<orxonox::FunctionCall> functionCalls_;

Modified: code/trunk/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionIDs.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/packet/FunctionIDs.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,6 +36,7 @@
 #include "util/Output.h"
 #include "core/object/ObjectList.h"
 #include "network/NetworkFunction.h"
+#include "network/NetworkFunctionManager.h"
 
 namespace orxonox {
 namespace packet {
@@ -54,11 +55,12 @@
   std::queue<std::pair<uint32_t, std::string> > tempQueue;
 
   //calculate total needed size (for all strings and integers)
-  ObjectList<NetworkFunctionBase>::iterator it;
-  for(it = ObjectList<NetworkFunctionBase>::begin(); it; ++it)
+  const std::set<NetworkFunctionBase*>& set = NetworkFunctionManager::getInstance().getAllFunctions();
+  std::set<NetworkFunctionBase*>::const_iterator it;
+  for (it = set.begin(); it != set.end(); ++it)
   {
-    const std::string& functionname = it->getName();
-    networkID = it->getNetworkID();
+    const std::string& functionname = (*it)->getName();
+    networkID = (*it)->getNetworkID();
     // now push the network id and the classname to the stack
     tempQueue.push( std::pair<unsigned int, std::string>(networkID, functionname) );
     ++nrOfFunctions;
@@ -125,6 +127,9 @@
   uint32_t stringsize;
   unsigned char *functionname;
 
+  //clear the map of network ids
+  NetworkFunctionManager::getInstance().clearNetworkIDs();
+
   orxout(verbose, context::packets) << "=== processing functionids: " << endl;
   std::pair<uint32_t, std::string> tempPair;
   // read the total number of classes
@@ -137,7 +142,7 @@
     stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
     functionname = temp+2*sizeof(uint32_t);
     orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl;
-    NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
+    NetworkFunctionManager::getInstance().getFunctionByName((const char*)functionname)->setNetworkID(networkID);
     temp += 2*sizeof(uint32_t) + stringsize;
   }
   delete this;

Modified: code/trunk/src/libraries/network/synchronisable/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/synchronisable/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/synchronisable/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,7 +1,6 @@
 ADD_SOURCE_FILES(NETWORK_SRC_FILES
   NetworkCallbackManager.cc
   Synchronisable.cc
-  SynchronisableVariable.cc
 )
 
 ADD_SOURCE_FILES(NETWORK_HDR_FILES

Modified: code/trunk/src/libraries/network/synchronisable/Serialise.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Serialise.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/synchronisable/Serialise.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -77,24 +77,24 @@
             return variable == variable->getSynchronisable(*(uint32_t*)(mem));
     }
 
-    // These functions implement loading / saving / etc. for SmartPtr<T>
+    // These functions implement loading / saving / etc. for StrongPtr<T>
 
     /** @brief returns the size of the objectID needed to synchronise the pointer */
-    template <class T> inline uint32_t returnSize( const SmartPtr<T>& )
+    template <class T> inline uint32_t returnSize( const StrongPtr<T>& )
     {
         return sizeof(uint32_t);
     }
 
     /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */
-    template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
+    template <class T> inline void loadAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem )
     {
 //         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
-        *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
+        *const_cast<typename Loki::TypeTraits<StrongPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
         mem += returnSize( variable );
     }
 
     /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */
-    template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem )
+    template <class T> inline void saveAndIncrease( const StrongPtr<T>& variable, uint8_t*& mem )
     {
         if ( variable.get() )
             *(uint32_t*)(mem) = static_cast<uint32_t>(variable->getObjectID());
@@ -104,7 +104,7 @@
     }
 
     /** @brief checks whether the objectID of the variable is the same as in the bytestream */
-    template <class T> inline  bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem )
+    template <class T> inline  bool checkEquality( const StrongPtr<T>& variable, uint8_t* mem )
     {
         if ( variable.get() )
             return *(uint32_t*)(mem) == variable->getObjectID();
@@ -124,7 +124,7 @@
     template <class T> inline void loadAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem )
     {
         //         *const_cast<typename Loki::TypeTraits<T*>::UnqualifiedType*>(&variable) = dynamic_cast<T*>(variable->getSynchronisable( *(uint32_t*)(mem) ));
-        *const_cast<typename Loki::TypeTraits<SmartPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
+        *const_cast<typename Loki::TypeTraits<WeakPtr<T> >::UnqualifiedType*>(&variable) = orxonox_cast<T*>(T::getSynchronisable(*(uint32_t*)(mem)));
         mem += returnSize( variable );
     }
 

Modified: code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,7 +44,7 @@
 
   uint8_t Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
 
-  RegisterAbstractClass(Synchronisable).inheritsFrom(Class(OrxonoxInterface));
+  RegisterAbstractClass(Synchronisable).inheritsFrom<OrxonoxInterface>();
 
   /**
   * Constructor:
@@ -150,7 +150,7 @@
     {
         for(int i = 0; i<160; i++)
             orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl;
-        orxout(user_error, context::network) << "Assertion failed: id" << endl;
+        orxout(user_error, context::network) << "Assertion failed: Could not find Identifier for ClassID " << header.getClassID() << endl;
         orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl;
         abort();
     }
@@ -181,12 +181,6 @@
     //no->contextID=header.getContextID(); //TODO: remove this
     no->setClassID(header.getClassID());
     assert(no->contextID_ == header.getContextID());
-    if( context )
-    {
-      BaseObject* boContext = orxonox_cast<BaseObject*>(context);
-      if (boContext)
-          bo->setLevel(boContext->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
-    }
     //assert(no->classID_ == header.getClassID());
     orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
           // update data and create object/entity...

Deleted: code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,36 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Oliver Scheuss
- *   Co-authors:
- *      ...
- *
- */
-
-#include "SynchronisableVariable.h"
-
-namespace orxonox{
-
-uint8_t SynchronisableVariableBase::state_ = 0;
-
-
-} //namespace

Modified: code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -64,8 +64,6 @@
       virtual void* getReference()=0;
       virtual uint8_t getMode()=0;
       virtual ~SynchronisableVariableBase() {}
-    protected:
-      static uint8_t state_;
   };
 
   template <class T>
@@ -107,10 +105,6 @@
   template <class T> SynchronisableVariable<T>::SynchronisableVariable(T& variable, uint8_t syncDirection, NetworkCallbackBase *cb):
       variable_( variable ), mode_( syncDirection ), callback_( cb )
   {
-    if ( state_ == 0x0 )
-    {
-      state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
-    }
   }
 
   template <class T> SynchronisableVariable<T>::~SynchronisableVariable()

Modified: code/trunk/src/libraries/tools/ParticleInterface.cc
===================================================================
--- code/trunk/src/libraries/tools/ParticleInterface.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/tools/ParticleInterface.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -48,8 +48,9 @@
 namespace orxonox
 {
     unsigned int ParticleInterface::counter_s = 0;
-    ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
 
+    RegisterAbstractClass(ParticleInterface).inheritsFrom<TimeFactorListener>();
+
     ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel)
     {
         RegisterObject(ParticleInterface);

Modified: code/trunk/src/libraries/tools/ParticleInterface.h
===================================================================
--- code/trunk/src/libraries/tools/ParticleInterface.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/tools/ParticleInterface.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,11 +34,6 @@
 #include "util/OgreForwardRefs.h"
 #include "tools/interfaces/TimeFactorListener.h"
 
-#define getAllEmitters() \
-  storeThisAsCurrentParticleInterface(); \
-  for (unsigned int i = 0; i < ParticleInterface::getCurrentParticleInterface()->getNumEmitters(); ++i) \
-    ParticleInterface::getCurrentParticleInterface()->getEmitter(i)
-
 namespace orxonox
 {
     class _ToolsExport ParticleInterface : public TimeFactorListener
@@ -79,11 +74,6 @@
 
             void setDetailLevel(unsigned int level);
 
-            inline void storeThisAsCurrentParticleInterface()
-                { ParticleInterface::currentParticleInterface_s = this; }
-            inline static ParticleInterface* getCurrentParticleInterface()
-                { return ParticleInterface::currentParticleInterface_s; }
-
         protected:
             virtual void changedTimeFactor(float factor_new, float factor_old);
 
@@ -102,7 +92,6 @@
             // config values
             unsigned int              globalDetailLevel_; //!< Global maximum detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
 
-            static ParticleInterface* currentParticleInterface_s;
             static unsigned int       counter_s;
     };
 }

Modified: code/trunk/src/libraries/tools/ResourceLocation.cc
===================================================================
--- code/trunk/src/libraries/tools/ResourceLocation.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/tools/ResourceLocation.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,7 +34,8 @@
 
 #include "util/Exception.h"
 #include "core/CoreIncludes.h"
-#include "core/PathConfig.h"
+#include "core/ApplicationPaths.h"
+#include "core/ConfigurablePaths.h"
 #include "core/XMLFile.h"
 #include "core/XMLPort.h"
 
@@ -73,10 +74,10 @@
         // Find the path
         namespace bf = boost::filesystem;
         bf::path path;
-        if (bf::exists(PathConfig::getDataPath() / this->getPath()))
-            path = PathConfig::getDataPath() / this->getPath();
-        else if (PathConfig::buildDirectoryRun() && bf::exists(PathConfig::getExternalDataPath() / this->getPath()))
-            path = PathConfig::getExternalDataPath() / this->getPath();
+        if (bf::exists(ConfigurablePaths::getDataPath() / this->getPath()))
+            path = ConfigurablePaths::getDataPath() / this->getPath();
+        else if (ApplicationPaths::buildDirectoryRun() && bf::exists(ConfigurablePaths::getExternalDataPath() / this->getPath()))
+            path = ConfigurablePaths::getExternalDataPath() / this->getPath();
         else
         {
             orxout(internal_warning) << "ResourceLocation '" << this->getPath() << "' does not seem to exist" << endl;

Modified: code/trunk/src/libraries/tools/Timer.cc
===================================================================
--- code/trunk/src/libraries/tools/Timer.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/tools/Timer.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,7 +39,7 @@
 
 #include "util/Clock.h"
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/command/CommandExecutor.h"
 #include "core/command/Executor.h"
 #include "core/command/Functor.h"
@@ -246,6 +246,9 @@
     ///////////////
     // RealTimer //
     ///////////////
+
+    RegisterClassNoArgs(RealTimer);
+
     /// @copydoc Timer::Timer
     RealTimer::RealTimer()
     {

Modified: code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc
===================================================================
--- code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/tools/interfaces/ToolsInterfaceCompilation.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -45,7 +45,7 @@
     //----------------------------
     float TimeFactorListener::timefactor_s = 1.0f;
 
-    RegisterAbstractClass(TimeFactorListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(TimeFactorListener).inheritsFrom<Listable>();
 
     TimeFactorListener::TimeFactorListener()
     {
@@ -66,7 +66,7 @@
     //----------------------------
     // Tickable
     //----------------------------
-    RegisterAbstractClass(Tickable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(Tickable).inheritsFrom<OrxonoxInterface>();
 
     /**
         @brief Constructor: Registers the object in the Tickable-list

Modified: code/trunk/src/libraries/util/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/util/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -25,8 +25,6 @@
   Convert.cc
   CRC32.cc
   ExprParser.cc
-  Scope.cc
-  ScopedSingletonManager.cc
   SharedPtr.cc
   Sleep.cc
   SmallObjectAllocator.cc

Deleted: code/trunk/src/libraries/util/Scope.cc
===================================================================
--- code/trunk/src/libraries/util/Scope.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/Scope.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,40 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Static linkage of the two maps in orxonox::ScopeManager.
-*/
-
-#include "Scope.h"
-
-namespace orxonox
-{
-    std::map<ScopeID::Value, int> ScopeManager::instanceCounts_s;
-    std::map<ScopeID::Value, std::set<ScopeListener*> > ScopeManager::listeners_s;
-}

Deleted: code/trunk/src/libraries/util/Scope.h
===================================================================
--- code/trunk/src/libraries/util/Scope.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/Scope.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,200 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- at file
- at ingroup SingletonScope
- at brief Declaration of the classes that are needed to use Scopes:
-orxonox::Scope, orxonox::ScopeListener, and orxonox::ScopeManager.
-
- at anchor Scope
-
-A virtual scope can be represented by an instance of class orxonox::Scope. orxonox::Scope<@a scope> is a template
-an its template argument defines the name of the virtual scope. See orxonox::ScopeID for an enumeration of the
-available values for @a scope. The orxonox::Scope object for a given @a scope can be activated or deactivated.
-Instances of orxonox::ScopeListener can register for a given @a scope and will get a notification if the
-corresponding orxonox::Scope object changes its state.
-
-To avoid multiple instances of orxonox::Scope<@a scope> in different libraries, each instance of orxonox::Scope
-registers in orxonox::ScopeManager, where they are linked statically in the util library.
-
-Scopes are usually used to control the creation and destruction of Singletons.
-
- at see orxonox::ScopedSingletonManager
- at see orxonox::Singleton
-*/
-
-#ifndef __Util_Scope_H__
-#define __Util_Scope_H__
-
-#include "UtilPrereqs.h"
-
-#include <cassert>
-#include <map>
-#include <set>
-#include <loki/ScopeGuard.h>
-
-#include "Output.h"
-
-namespace orxonox
-{
-    /**
-        @brief The ScopeManager stores the variables of the Scope templates in a statically linked context.
-
-        If all Scope objects are managed by this class, they are statically linked in the util library.
-        Without this, a new instance of Scope<T> for each T would be created in every library of Orxonox,
-        which is of course not the desired behavior.
-
-        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
-    */
-    class _UtilExport ScopeManager
-    {
-        template <ScopeID::Value scope>
-        friend class Scope;
-        friend class ScopeListener;
-
-        private:
-            static std::map<ScopeID::Value, int> instanceCounts_s;                  //!< Counts the number of active instances (>0 means active) for a scope
-            static std::map<ScopeID::Value, std::set<ScopeListener*> > listeners_s; //!< Stores all listeners for a scope
-    };
-
-    /**
-        @brief ScopeListeners register themselves in the corresponding Scope and wait for notifications.
-        Notifications are sent if a Scope is activated or deactivated.
-
-        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
-    */
-    class _UtilExport ScopeListener
-    {
-        template <ScopeID::Value scope>
-        friend class Scope;
-
-        protected:
-            //! Constructor: Registers the instance.
-            ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false)
-                { ScopeManager::listeners_s[this->scope_].insert(this); }
-            //! Destructor: Unregisters the instance.
-            virtual ~ScopeListener()
-                { ScopeManager::listeners_s[this->scope_].erase(this); }
-
-            //! Gets called if the scope is activated
-            virtual void activated() = 0;
-            //! Gets called if the scope is deactivated
-            virtual void deactivated() = 0;
-
-        private:
-            ScopeID::Value scope_; //!< Store the scope to unregister on destruction
-            bool bActivated_;
-    };
-
-    /**
-        @brief A scope for a given template argument is either active or not.
-
-        Objects inheriting from a ScopeListener are registered in a list (different for each scope).
-        If the scope gets activated or deactivated, all objects in this list are notified.
-
-        @see See @ref Scope "this description" for details about the interrelationship of Scope, ScopeListener, and ScopeManager.
-    */
-    template <ScopeID::Value scope>
-    class Scope
-    {
-        public:
-            //! Constructor: Increases the instance counter and activates the scope if the count went from 0 to 1. Counts >1 don't change anything.
-            Scope()
-            {
-                orxout(internal_status) << "creating scope... (" << scope << ")" << endl;
-
-                try
-                {
-                    ScopeManager::instanceCounts_s[scope]++;
-                    assert(ScopeManager::instanceCounts_s[scope] > 0);
-                    if (ScopeManager::instanceCounts_s[scope] == 1)
-                    {
-                        Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateListeners);
-                        for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
-                        {
-                            (*it)->activated();
-                            (*(it++))->bActivated_ = true;
-                        }
-                        deactivator.Dismiss();
-                    }
-                }
-                catch (...)
-                {
-                    ScopeManager::instanceCounts_s[scope]--;
-                    throw;
-                }
-
-                orxout(internal_status) << "created scope (" << scope << ")" << endl;
-            }
-
-            //! Destructor: Decreases the instance counter and deactivates the scope if the count went from 1 to 0. Counts >0 don't change anything.
-            ~Scope()
-            {
-                orxout(internal_status) << "destroying scope... (" << scope << ")" << endl;
-
-                ScopeManager::instanceCounts_s[scope]--;
-
-                // This shouldn't happen but just to be sure: check if the count is positive
-                assert(ScopeManager::instanceCounts_s[scope] >= 0);
-                if (ScopeManager::instanceCounts_s[scope] < 0)
-                    ScopeManager::instanceCounts_s[scope] = 0;
-
-                if (ScopeManager::instanceCounts_s[scope] == 0)
-                    this->deactivateListeners();
-
-                orxout(internal_status) << "destroyed scope (" << scope << ")" << endl;
-            }
-
-            //! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails.
-            void deactivateListeners()
-            {
-                for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); )
-                {
-                    if ((*it)->bActivated_)
-                    {
-                        try
-                            { (*it)->deactivated(); }
-                        catch (...)
-                            { orxout(internal_warning) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << endl; }
-                        (*(it++))->bActivated_ = false;
-                    }
-                    else
-                        ++it;
-                }
-            }
-
-            //! Returns true if the scope is active.
-            static bool isActive()
-            {
-                return (ScopeManager::instanceCounts_s[scope] > 0);
-            }
-    };
-}
-
-#endif /* __Util_Scope_H__ */

Deleted: code/trunk/src/libraries/util/ScopedSingletonManager.cc
===================================================================
--- code/trunk/src/libraries/util/ScopedSingletonManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/ScopedSingletonManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,54 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Static linkage of the ScopedSingletonManager maps.
-*/
-
-#include "ScopedSingletonManager.h"
-
-namespace orxonox
-{
-    /*static*/ std::map<std::string, ScopedSingletonManager*>& ScopedSingletonManager::getManagers()
-    {
-        static std::map<std::string, ScopedSingletonManager*> managers;
-        return managers;
-    }
-    /*static*/ ScopedSingletonManager::ManagerMultiMap& ScopedSingletonManager::getManagersByScope()
-    {
-        static ManagerMultiMap managers;
-        return managers;
-    }
-
-    /*static*/ void ScopedSingletonManager::addManager(ScopedSingletonManager* manager)
-    {
-        getManagers()[manager->className_] = manager;
-        getManagersByScope().insert(std::make_pair(manager->scope_, manager));
-    }
-}

Deleted: code/trunk/src/libraries/util/ScopedSingletonManager.h
===================================================================
--- code/trunk/src/libraries/util/ScopedSingletonManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/ScopedSingletonManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,282 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @ingroup SingletonScope
-    @brief Definition of orxonox::ScopedSingletonManager, orxonox::ClassScopedSingletonManager, and the ManageScopedSingleton macro.
-
-    ScopedSingletonManager is used to create and destroy Singletons that belong to
-    a given Scope. For each one of these singletons, the macro ManageScopedSingleton()
-    has to be called to register the singleton with orxonox::ScopedSingletonManager.
-
-    See @ref SingletonExample "this code" for an example.
-
-    @see orxonox::Singleton
-    @see orxonox::Scope
-*/
-
-#ifndef __ScopedSingletonManager_H__
-#define __ScopedSingletonManager_H__
-
-#include "UtilPrereqs.h"
-
-#include <cassert>
-#include <map>
-#include "util/Exception.h"
-#include "util/Scope.h"
-#include "util/Singleton.h"
-
-/**
-    @brief Registers an orxonox::Singleton with orxonox::ScopedSingletonManager.
-    @param className The name of the singleton class
-    @param scope The scope in which the singleton should exist
-    @param allowedToFail If true, the singleton is allowed to fail and thus a try-catch block is used when creating the singleton.
-
-    If this macro is called for a singleton, it is registered with ScopedSingletonManager
-    and will thus be created if its scope becomes active and destroyed if is deactivated.
-*/
-#define ManageScopedSingleton(className, scope, allowedToFail) \
-    className* className::singletonPtr_s = NULL; \
-    static ClassScopedSingletonManager<className, scope, allowedToFail> className##ScopedSingletonManager(#className)
-
-namespace orxonox
-{
-    class Destroyable;
-
-    /**
-        @brief Base class of ClassScopedSingletonManager, implements some static functions
-        used to dispatch calls to preUpdate and postUpdate to all instances of this class.
-        It also keeps track of all existing ScopedSingletonManagers and stores them in a
-        map, sorted by the scope they belong to.
-    */
-    class _UtilExport ScopedSingletonManager
-    {
-        public:
-            /// Constructor: Initializes all the values
-            ScopedSingletonManager(const std::string& className, ScopeID::Value scope)
-                : className_(className)
-                , scope_(scope)
-            { }
-            virtual ~ScopedSingletonManager() { }
-
-            /// Adds a new instance of ScopedSingletonManager to the map.
-            static void addManager(ScopedSingletonManager* manager);
-
-            /// Calls preUpdate in all instances of ScopedSingletonManager that are registered in the map.
-            template<ScopeID::Value scope>
-            static void preUpdate(const Clock& time)
-            {
-                assert(Scope<scope>::isActive());
-                for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
-                    it->second->preUpdate(time);
-            }
-            virtual void preUpdate(const Clock& time) = 0;
-
-            /// Calls postUpdate in all instances of ScopedSingletonManager that are registered in the map.
-            template<ScopeID::Value scope>
-            static void postUpdate(const Clock& time)
-            {
-                assert(Scope<scope>::isActive());
-                for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
-                    it->second->postUpdate(time);
-            }
-            virtual void postUpdate(const Clock& time) = 0;
-
-            static std::map<std::string, ScopedSingletonManager*>& getManagers();
-            typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap;
-            static ManagerMultiMap& getManagersByScope();
-
-        protected:
-            const std::string className_;   ///< The name of the scoped singleton class that is managed by this object
-            const ScopeID::Value scope_;    ///< The scope of the singleton that is managed by this object
-    };
-
-    /**
-        @anchor ClassScopedSingletonManager
-
-        @brief Manages a scoped singleton for a given scope.
-        @param T The managed singleton class
-        @param scope The scope in which the singleton @a T should be active
-        @param allowedToFail If true, a specialization of this template is used, that uses try-catch blocks to handle possible failures.
-
-        This class inherits from ScopeListener for the given scope and thus its functions
-        activated() and deactivated() are called whenever the Scope changes its state.
-
-        If the Scope is activated, a new instance of @a T (which must be a singleton) is created.
-        If the Scope is deactivated, the singleton is destroyed.
-
-        @see Singleton
-    */
-    template <class T, ScopeID::Value scope, bool allowedToFail>
-    class ClassScopedSingletonManager : public ScopedSingletonManager, public ScopeListener
-    {
-    public:
-        //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
-        ClassScopedSingletonManager(const std::string& className)
-            : ScopedSingletonManager(className, scope)
-            , ScopeListener(scope)
-            , singletonPtr_(NULL)
-        {
-            ScopedSingletonManager::addManager(this);
-        }
-
-        ~ClassScopedSingletonManager()
-        {
-        }
-
-        //! Called if the Scope of the Singleton gets active (creates the instance)
-        void activated()
-        {
-            assert(singletonPtr_ == NULL);
-            singletonPtr_ = new T();
-        }
-
-        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
-        void deactivated()
-        {
-            assert(singletonPtr_ != NULL);
-            this->destroy(singletonPtr_);
-            singletonPtr_ = NULL;
-        }
-
-        //! Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy()
-        void destroy(Destroyable*)
-        {
-            singletonPtr_->destroy();
-        }
-        //! Destroys the singleton instance - overloaded for all other pointers, calls delete
-        void destroy(void*)
-        {
-            delete singletonPtr_;
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void preUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            singletonPtr_->preUpdateSingleton(time);
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void postUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            singletonPtr_->postUpdateSingleton(time);
-        }
-
-    private:
-        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
-    };
-
-    /**
-        @brief This class partially spezializes ClassScopedSingletonManager for classes @a T that are allowed to fail.
-        @param T The managed singleton class
-        @param scope The scope in which the singleton @a T should be active
-
-        Because @a T could fail when being created, this partial spezialization of ClassScopedSingletonManager
-        uses a try-catch block to handle exceptions.
-
-        See @ref ClassScopedSingletonManager for a full documentation of the basis template.
-    */
-    template <class T, ScopeID::Value scope>
-    class ClassScopedSingletonManager<T, scope, true> : public ScopedSingletonManager, public ScopeListener
-    {
-    public:
-        //! Constructor: Initializes the singleton pointer and passes the scope to ScopedSingletonManager and ScopeListener
-        ClassScopedSingletonManager(const std::string& className)
-            : ScopedSingletonManager(className, scope)
-            , ScopeListener(scope)
-            , singletonPtr_(NULL)
-        {
-            ScopedSingletonManager::addManager(this);
-        }
-
-        ~ClassScopedSingletonManager()
-        {
-        }
-
-        //! Called if the Scope of the Singleton gets active (creates the instance)
-        void activated()
-        {
-            assert(singletonPtr_ == NULL);
-            try
-                { singletonPtr_ = new T(); }
-            catch (const InitialisationAbortedException& ex)
-                { orxout(internal_error) << ex.getDescription() << endl; }
-            catch (...)
-                { orxout(internal_error) << "Singleton creation failed: " << Exception::handleMessage() << endl; }
-        }
-
-        //! Called if the Scope of this Singleton gets deactivated (destroys the instance)
-        void deactivated()
-        {
-            if (singletonPtr_ != NULL)
-            {
-                this->destroy(singletonPtr_);
-                singletonPtr_ = NULL;
-            }
-        }
-
-        //! Destroys the singleton instance - overloaded for Destroyable, calls Destroyable::destroy()
-        void destroy(Destroyable*)
-        {
-            singletonPtr_->destroy();
-        }
-        //! Destroys the singleton instance - overloaded for void*, calls delete
-        void destroy(void*)
-        {
-            delete singletonPtr_;
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void preUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            if (singletonPtr_ != NULL)
-                singletonPtr_->preUpdateSingleton(time);
-        }
-
-        //! Called every frame by the ScopedSingletonManager
-        void postUpdate(const Clock& time)
-        {
-            assert(Scope<scope>::isActive());
-            // assuming T inherits Singleton<T>
-            if (singletonPtr_ != NULL)
-                singletonPtr_->postUpdateSingleton(time);
-        }
-
-    private:
-        T* singletonPtr_;   ///< Unique instance of the singleton class @a T
-    };
-}
-
-#endif /* __ScopedSingletonManager_H__ */

Modified: code/trunk/src/libraries/util/SharedPtr.h
===================================================================
--- code/trunk/src/libraries/util/SharedPtr.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/SharedPtr.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -137,7 +137,7 @@
         OtherClass* other2 = new OtherClass(object);        // "
         OtherClass* other3 = new OtherClass(object);        // "
 
-    }                                                       // The SmartPtr "object" is destroyed at the end of the scope,
+    }                                                       // The SharedPtr "object" is destroyed at the end of the scope,
                                                             // but the three instances of OtherClass keep the object alive
                                                             // until they are all destroyed.
     @endcode

Modified: code/trunk/src/libraries/util/Singleton.h
===================================================================
--- code/trunk/src/libraries/util/Singleton.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/Singleton.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -51,7 +51,7 @@
 
         public:
             TestSingleton();                                // public constructor because we may want to manage this singleton
-                                                            //     with an orxonox::ScopedSingletonManager (see below)
+                                                            //     with an orxonox::ScopedSingletonWrapper
             virtual ~TestSingleton();                       // public destructor
 
             void testFunction();                            // put your functions here
@@ -68,24 +68,6 @@
     TestSingleton* TestSingleton::singletonPtr_s = NULL;
     @endcode
 
-    Usually a singleton gets created automatically when it is first used, but it will never
-    be destroyed (unless the singleton explicitly deletes itself). To allow controlled
-    construction and destruction, the singleton can be put within a virtual scope. This is
-    done by registering the singleton class with orxonox::ScopedSingletonManager. To
-    do so, the ManageScopedSingleton() macro has to be called:
-
-    @code
-    ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file
-    @endcode
-
-    @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,
-    because that's already done by the macro.
-
-    Now the singleton TestSingleton gets automatically created if the scope Graphics becomes
-    active and also gets destroyed if the scope is deactivated.
-
-    Note that not all singletons must register with a scope, but it's recommended.
-
     If a class inherits from orxonox::Singleton, it also inherits its functions. The most important
     function is orxonox::Singleton::getInstance() which returns a reference to the only instance
     of the singleton.
@@ -111,9 +93,11 @@
 
 #include "UtilPrereqs.h"
 
-#include <cassert>
 #include <cstring>
+#include <typeinfo>
 
+#include "OrxAssert.h"
+
 namespace orxonox
 {
     /**
@@ -133,7 +117,7 @@
         //! Returns a reference to the singleton instance
         static T& getInstance()
         {
-            assert(T::singletonPtr_s != NULL);
+            OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());
             return *T::singletonPtr_s;
         }
 
@@ -143,27 +127,18 @@
             return (T::singletonPtr_s != NULL);
         }
 
-        //! Update method called by ClassSingletonManager (if used)
-        void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
-        //! Empty update method for the static polymorphism
-        void preUpdate(const Clock& time) { }
-        //! Update method called by ClassSingletonManager (if used)
-        void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
-        //! Empty update method for the static polymorphism
-        void postUpdate(const Clock& time) { }
-
     protected:
         //! Constructor sets the singleton instance pointer
         Singleton()
         {
-            assert(T::singletonPtr_s == NULL);
+            OrxVerify(T::singletonPtr_s == NULL, "T=" << typeid(T).name());
             T::singletonPtr_s = static_cast<T*>(this);
         }
 
         //! Destructor resets the singleton instance pointer
         virtual ~Singleton()
         {
-            assert(T::singletonPtr_s != NULL);
+            OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());
             T::singletonPtr_s = NULL;
         }
 

Modified: code/trunk/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/trunk/src/libraries/util/UtilPrereqs.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/UtilPrereqs.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -61,23 +61,6 @@
 #endif
 
 //-----------------------------------------------------------------------
-// Enums
-//-----------------------------------------------------------------------
-
-namespace orxonox
-{
-    namespace ScopeID
-    {
-        //!A list of available scopes for the Scope template.
-        enum Value
-        {
-            Root,
-            Graphics
-        };
-    }
-}
-
-//-----------------------------------------------------------------------
 // Forward declarations
 //-----------------------------------------------------------------------
 
@@ -95,10 +78,6 @@
     class OutputListener;
     class OutputManager;
     class OutputStream;
-    template <ScopeID::Value>
-    class Scope;
-    template <class, ScopeID::Value>
-    class ScopedSingleton;
     class ScopeListener;
     template <class T>
     class SharedPtr;

Modified: code/trunk/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputDefinitions.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/libraries/util/output/OutputDefinitions.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -169,7 +169,6 @@
             namespace misc
             {
                 REGISTER_OUTPUT_SUBCONTEXT(misc, executor);
-                REGISTER_OUTPUT_SUBCONTEXT(misc, factory);
                 REGISTER_OUTPUT_SUBCONTEXT(misc, gui);
                 REGISTER_OUTPUT_SUBCONTEXT(misc, overlays);
                 REGISTER_OUTPUT_SUBCONTEXT(misc, script);

Modified: code/trunk/src/modules/designtools/ScreenshotManager.cc
===================================================================
--- code/trunk/src/modules/designtools/ScreenshotManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/designtools/ScreenshotManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,10 +44,10 @@
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GraphicsManager.h"
-#include "core/PathConfig.h"
+#include "core/ConfigurablePaths.h"
 #include "core/Resource.h"
-#include "core/command/ConsoleCommand.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "util/StringUtils.h"
 
 #include "CameraManager.h"
@@ -60,8 +60,10 @@
 
     SetConsoleCommand("printScreenHD", &ScreenshotManager::makeScreenshot_s);
     
-    ManageScopedSingleton(ScreenshotManager, ScopeID::Graphics, false);
+    ManageScopedSingleton(ScreenshotManager, ScopeID::GRAPHICS, false);
 
+    RegisterAbstractClass(ScreenshotManager).inheritsFrom<Configurable>();
+
     /**
     @brief
         Constructor. 
@@ -151,7 +153,7 @@
         if(finalImage != NULL)
         {
             // Save it.
-            finalImage->save(PathConfig::getInstance().getLogPathString() + "screenshot_" + getTimestamp() + this->fileExtension_);
+            finalImage->save(ConfigurablePaths::getLogPathString() + "screenshot_" + getTimestamp() + this->fileExtension_);
             delete finalImage;
             orxout(user_info) << "Finished taking " << this->gridSize_*this->windowWidth_ << "x" << this->gridSize_*this->windowHeight_ << " pixel HD screenshot. Storing in log/." << endl;
         }

Modified: code/trunk/src/modules/designtools/SkyboxGenerator.cc
===================================================================
--- code/trunk/src/modules/designtools/SkyboxGenerator.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/designtools/SkyboxGenerator.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,14 +37,14 @@
 #include <OgreRenderWindow.h>
 #include <OgreCamera.h>
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GraphicsManager.h"
-#include "core/PathConfig.h"
+#include "core/ConfigurablePaths.h"
 #include "core/Resource.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/command/CommandExecutor.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 #include "controllers/HumanController.h"
 #include "graphics/Camera.h"
@@ -59,8 +59,10 @@
 
     SetConsoleCommand("SkyboxGenerator", "createSkybox", &SkyboxGenerator::createSkybox).addShortcut();
 
-    ManageScopedSingleton(SkyboxGenerator, ScopeID::Graphics, false);
+    ManageScopedSingleton(SkyboxGenerator, ScopeID::GRAPHICS, false);
 
+    RegisterAbstractClass(SkyboxGenerator).inheritsFrom<Configurable>().inheritsFrom<Tickable>();
+
     /**
     @brief
         Constructor. Registers and initializes the singleton.
@@ -172,7 +174,7 @@
                 // Setup the render window.
                 this->setupRenderWindow(renderWindow);
                 // Add the log path to the standard resource group.
-                Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getInstance().getLogPathString(), "FileSystem", Resource::getDefaultResourceGroup());
+                Ogre::ResourceGroupManager::getSingleton().addResourceLocation(ConfigurablePaths::getLogPathString(), "FileSystem", Resource::getDefaultResourceGroup());
                 
                 orxout(internal_status) << "Setting up SkyboxGenerator..." << endl;
                 
@@ -207,7 +209,7 @@
                 // Restore the render window.
                 this->restoreRenderWindow(renderWindow);
                 // Remove the log path from the standard resource group.
-                Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(PathConfig::getInstance().getLogPathString(), Resource::getDefaultResourceGroup());
+                Ogre::ResourceGroupManager::getSingleton().removeResourceLocation(ConfigurablePaths::getLogPathString(), Resource::getDefaultResourceGroup());
                 
                 // Reset the flow parameters for the next skybox generation.
                 this->bGenerateSkybox_ = false;
@@ -305,14 +307,14 @@
     */
     void SkyboxGenerator::saveImage(Ogre::Image* image, const std::string& name) const
     {
-        image->save(PathConfig::getInstance().getLogPathString()+name);
+        image->save(ConfigurablePaths::getLogPathString()+name);
         delete image;
         // Loading the resizing, then saving again. This seems stupid, but resizing doesn't seem to work otherwise.
         // If someone figures this out, feel free to adjust.
         image = new Ogre::Image();
         image->load(name, Resource::getDefaultResourceGroup());
         image->resize(this->size_, this->size_);
-        image->save(PathConfig::getInstance().getLogPathString()+name);
+        image->save(ConfigurablePaths::getLogPathString()+name);
         delete image;
         ScreenshotManager::getInstance().cleanup(); // Free memory in ScreenshotManager.
     }

Modified: code/trunk/src/modules/docking/Dock.cc
===================================================================
--- code/trunk/src/modules/docking/Dock.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/docking/Dock.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,8 +36,8 @@
 #include "core/CoreIncludes.h"
 #include "core/LuaState.h"
 #include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
-#include "network/NetworkFunction.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "infos/HumanPlayer.h"
 #include "interfaces/PlayerTrigger.h"
@@ -183,7 +183,7 @@
                     GUIManager::showGUI("UndockingDialog");
             }
             else
-                callStaticNetworkFunction(Dock::showDockingDialog, player->getClientID());
+                callStaticNetworkFunction(&Dock::showDockingDialog, player->getClientID());
 
         }
 
@@ -200,7 +200,7 @@
                 GUIManager::showGUI("DockingDialog");
         }
         else
-            callStaticNetworkFunction(Dock::showDockingDialog, player->getClientID());
+            callStaticNetworkFunction(&Dock::showDockingDialog, player->getClientID());
 
     }
 

Modified: code/trunk/src/modules/docking/DockingAnimation.cc
===================================================================
--- code/trunk/src/modules/docking/DockingAnimation.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/docking/DockingAnimation.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,7 +38,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(DockingAnimation).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(DockingAnimation).inheritsFrom<BaseObject>();
 
     DockingAnimation::DockingAnimation(Context* context) : BaseObject(context)
     {

Modified: code/trunk/src/modules/docking/DockingEffect.cc
===================================================================
--- code/trunk/src/modules/docking/DockingEffect.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/docking/DockingEffect.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(DockingEffect).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(DockingEffect).inheritsFrom<BaseObject>();
 
     DockingEffect::DockingEffect(Context* context) : BaseObject(context)
     {

Modified: code/trunk/src/modules/dodgerace/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/dodgerace/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -7,7 +7,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(dodgerace
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
     orxonox

Modified: code/trunk/src/modules/dodgerace/DodgeRace.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRace.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRace.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,6 +34,7 @@
 #include "DodgeRace.h"
 #include "DodgeRaceShip.h" // Necessary for getPlayer function. Do NOT include this in Header!
 #include "DodgeRaceCube.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
 {
@@ -42,15 +43,7 @@
     DodgeRace::DodgeRace(Context* context) : Deathmatch(context)
     {
         RegisterObject(DodgeRace);
-        init();
-        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
-        this->center_ = 0;
 
-        this->setHUDTemplate("DodgeRaceHUD");
-    }
-
-    void DodgeRace::init()
-    {
         bEndGame = false;
         lives = 1;
         level = 1;
@@ -64,6 +57,10 @@
         // spawn enemy every 3.5 seconds
         //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&DodgeRace::spawnEnemy, this)));
         comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&DodgeRace::comboControll, this)));
+        this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
+        this->center_ = 0;
+
+        this->setHUDTemplate("DodgeRaceHUD");
     }
 
     void DodgeRace::levelUp()
@@ -73,7 +70,7 @@
         {
             for (int i = 0; i < 7; i++)
             {
-                WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
+                BigExplosion* chunk = new BigExplosion(this->center_->getContext());
                 chunk->setPosition(Vector3(600, 0, 100.f * i - 300));
                 chunk->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
                 chunk->setScale(20);
@@ -89,8 +86,6 @@
     {
         if (getPlayer() != NULL)
         {
-            //WeakPtr<DodgeRaceShip> ship = getPlayer();
-
             currentPosition = getPlayer()->getWorldPosition().x;
             counter = counter + (currentPosition - lastPosition);
             lastPosition = currentPosition;
@@ -111,7 +106,7 @@
                 counter = 0;
                 for(int i = 0; i<6; i++)
                 {
-                    WeakPtr<DodgeRaceCube> cube = new DodgeRaceCube(this->center_->getContext());
+                    DodgeRaceCube* cube = new DodgeRaceCube(this->center_->getContext());
                     cubeList.push_back(cube);
                     switch(pattern)
                     {
@@ -136,7 +131,7 @@
         SUPER(DodgeRace, tick, dt);
     }
 
-    WeakPtr<DodgeRaceShip> DodgeRace::getPlayer()
+    DodgeRaceShip* DodgeRace::getPlayer()
     {
         if (player == NULL)
         {
@@ -167,7 +162,6 @@
     void DodgeRace::start()
     {
         orxout() << "start" << endl;
-        init();
         for(unsigned int i=0; i< cubeList.size();i++)
         {
             cubeList.at(i)->destroy();
@@ -198,7 +192,6 @@
         // Reset all the cubes
         /*
         orxout() << "prespawn" << endl;
-        init();
         for(int i=0; i< cubeList.size();i++)
         {
             cubeList.at(i)->destroy();

Modified: code/trunk/src/modules/dodgerace/DodgeRace.h
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRace.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRace.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -43,7 +43,6 @@
 //#include "DodgeRaceHUDinfo.h"
 
 
-#include "core/CoreIncludes.h"
 #include "core/EventIncludes.h"
 #include "core/command/Executor.h"
 #include "core/config/ConfigValueIncludes.h"
@@ -69,8 +68,6 @@
        public:
             DodgeRace(Context* context);
 
-            void init();
-
             virtual void start();
             virtual void end();
 
@@ -105,7 +102,7 @@
        private:
             Timer endGameTimer;
 
-            WeakPtr<DodgeRaceShip> getPlayer();
+            DodgeRaceShip* getPlayer();
             WeakPtr<DodgeRaceShip> player;
             std::vector<DodgeRaceCube*> cubeList;
             void toggleShowLevel(){bShowLevel = !bShowLevel;}

Modified: code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -53,19 +53,11 @@
         SUPER(DodgeRaceCenterPoint, XMLPort, xmlelement, mode);
     }
 
-    void DodgeRaceCenterPoint::changedGametype()
-    {
-        SUPER(DodgeRaceCenterPoint, changedGametype);
-
-        // Check, whether it's still DodgeRace.
-        this->checkGametype();
-    }
-
     void DodgeRaceCenterPoint::checkGametype()
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(DodgeRace)))
         {
-            DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype().get());
+            DodgeRace* DodgeRaceGametype = orxonox_cast<DodgeRace*>(this->getGametype());
             DodgeRaceGametype->setCenterpoint(this);
         }
     }

Modified: code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRaceCenterPoint.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -51,7 +51,6 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
         private:
             void checkGametype();
 

Modified: code/trunk/src/modules/dodgerace/DodgeRaceCube.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceCube.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRaceCube.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -32,6 +32,7 @@
 
 #include "DodgeRaceCube.h"
 #include "DodgeRace.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
 {

Modified: code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRaceHUDinfo.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -81,7 +81,7 @@
 
         if (this->getOwner() && this->getOwner()->getGametype())
         {
-            this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype().get());
+            this->DodgeRaceGame = orxonox_cast<DodgeRace*>(this->getOwner()->getGametype());
         }
         else
         {

Modified: code/trunk/src/modules/dodgerace/DodgeRaceShip.cc
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceShip.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRaceShip.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -32,6 +32,7 @@
 */
 
 #include "DodgeRaceShip.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
 {
@@ -88,7 +89,7 @@
 
 
         // Camera
-        WeakPtr<Camera> camera = this->getCamera();
+        Camera* camera = this->getCamera();
         if (camera != NULL)
         {
             // camera->setPosition(Vector3(-pos.z, -posforeward, 0));
@@ -148,7 +149,7 @@
         return false;
     }
 
-    WeakPtr<DodgeRace> DodgeRaceShip::getGame()
+    DodgeRace* DodgeRaceShip::getGame()
     {
         if (game == NULL)
         {

Modified: code/trunk/src/modules/dodgerace/DodgeRaceShip.h
===================================================================
--- code/trunk/src/modules/dodgerace/DodgeRaceShip.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/dodgerace/DodgeRaceShip.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,7 +37,6 @@
 
 #include "dodgerace/DodgeRacePrereqs.h"
 
-#include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "worldentities/pawns/SpaceShip.h"
 #include "graphics/Camera.h"
@@ -78,7 +77,7 @@
 
         private:
             virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
-            WeakPtr<DodgeRace> getGame();
+            DodgeRace* getGame();
             WeakPtr<DodgeRace> game;
             WeakPtr<WorldEntity> lastEntity;
             Camera* camera;

Modified: code/trunk/src/modules/gametypes/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/gametypes/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/gametypes/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -9,7 +9,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(gametypes
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   TOLUA_FILES
   PCH_FILE

Modified: code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc
===================================================================
--- code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/gametypes/OldRaceCheckPoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -60,7 +60,7 @@
     {
         SUPER(OldRaceCheckPoint, tick, dt);
 
-        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype().get());
+        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype());
         assert(gametype);
         if (this->getCheckpointIndex() == gametype->getCheckpointsReached())
             this->setRadarVisibility(true);
@@ -81,7 +81,7 @@
     {
         DistanceTrigger::triggered(bIsTriggered);
 
-        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype().get());
+        OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype());
         if (gametype && this->getCheckpointIndex() == gametype->getCheckpointsReached() && bIsTriggered)
         {
             gametype->clock_.capture();
@@ -106,7 +106,7 @@
         this->bTimeLimit_ = timeLimit;
         if (this->bTimeLimit_ != 0)
         {
-            OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype().get());
+            OldSpaceRace* gametype = orxonox_cast<OldSpaceRace*>(this->getGametype());
             if (gametype)
             {
                 const std::string& message =  "You have " + multi_cast<std::string>(this->bTimeLimit_)

Modified: code/trunk/src/modules/gametypes/SpaceRaceManager.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRaceManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/gametypes/SpaceRaceManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -45,7 +45,7 @@
         BaseObject(context)
     {
         RegisterObject(SpaceRaceManager);
-        this->race_ = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        this->race_ = orxonox_cast<SpaceRace*>(this->getGametype());
         assert(race_);
         //amountOfPlayers=(race_->getPlayers()).size();
         this->firstcheckpointvisible_ = false;
@@ -138,7 +138,7 @@
 
     void SpaceRaceManager::checkpointReached(RaceCheckPoint* newCheckpoint, PlayerInfo* player)
     {
-        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype().get());
+        SpaceRace* gametype = orxonox_cast<SpaceRace*>(this->getGametype());
         assert(gametype);
         if (!gametype)
         return;

Modified: code/trunk/src/modules/invader/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/invader/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -12,7 +12,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(invader
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
     orxonox

Modified: code/trunk/src/modules/invader/Invader.cc
===================================================================
--- code/trunk/src/modules/invader/Invader.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/Invader.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -61,12 +61,6 @@
         RegisterObject(Invader);
         this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
         this->center_ = 0;
-        init();
-        this->setHUDTemplate("InvaderHUD");
-    }
-
-    void Invader::init()
-    {
         bEndGame = false;
         lives = 3;
         level = 1;
@@ -77,6 +71,7 @@
         // spawn enemy every 3.5 seconds
         enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
         comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Invader::comboControll, this)));
+        this->setHUDTemplate("InvaderHUD");
     }
 
     void Invader::levelUp()
@@ -86,7 +81,7 @@
         {
             for (int i = 0; i < 7; i++)
             {
-                WeakPtr<BigExplosion> chunk = new BigExplosion(this->center_->getContext());
+                BigExplosion* chunk = new BigExplosion(this->center_->getContext());
                 chunk->setPosition(Vector3(600, 0, 100.f * i - 300));
                 chunk->setVelocity(Vector3(1000, 0, 0));  //player->getVelocity()
                 chunk->setScale(20);
@@ -98,7 +93,7 @@
         showLevelTimer.setTimer(1.0f, false, createExecutor(createFunctor(&Invader::toggleShowLevel, this)));
     }
 
-    WeakPtr<InvaderShip> Invader::getPlayer()
+    InvaderShip* Invader::getPlayer()
     {
         if (player == NULL)
         {
@@ -115,7 +110,7 @@
 
         for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)
         {
-            WeakPtr<InvaderEnemy> newPawn;
+            InvaderEnemy* newPawn;
             if (rand() % 42/(1 + level*level) == 0)
             {
                 newPawn = new InvaderEnemyShooter(this->center_->getContext());
@@ -154,7 +149,6 @@
 
     void Invader::start()
     {
-        init();
         // Set variable to temporarily force the player to spawn.
         this->bForceSpawn_ = true;
 

Modified: code/trunk/src/modules/invader/Invader.h
===================================================================
--- code/trunk/src/modules/invader/Invader.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/Invader.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -70,14 +70,13 @@
             void addPoints(int numPoints);
             // checks if multiplier should be reset.
             void comboControll();
-            void init();
             int lives;
             int multiplier;
             bool bEndGame;
             bool bShowLevel;
         private:
             void toggleShowLevel(){bShowLevel = !bShowLevel;}
-            WeakPtr<InvaderShip> getPlayer();
+            InvaderShip* getPlayer();
             WeakPtr<InvaderCenterPoint> center_;
             WeakPtr<InvaderShip> player;
 

Modified: code/trunk/src/modules/invader/InvaderCenterPoint.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderCenterPoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderCenterPoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -53,19 +53,11 @@
         SUPER(InvaderCenterPoint, XMLPort, xmlelement, mode);
     }
 
-    void InvaderCenterPoint::changedGametype()
-    {
-        SUPER(InvaderCenterPoint, changedGametype);
-
-        // Check, whether it's still Invader.
-        this->checkGametype();
-    }
-
     void InvaderCenterPoint::checkGametype()
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Invader)))
         {
-            Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype().get());
+            Invader* InvaderGametype = orxonox_cast<Invader*>(this->getGametype());
             InvaderGametype->setCenterpoint(this);
         }
     }

Modified: code/trunk/src/modules/invader/InvaderCenterPoint.h
===================================================================
--- code/trunk/src/modules/invader/InvaderCenterPoint.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderCenterPoint.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -48,7 +48,6 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
         private:
             void checkGametype();
 

Modified: code/trunk/src/modules/invader/InvaderEnemy.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderEnemy.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderEnemy.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -68,7 +68,7 @@
         return false;
     }
 
-    WeakPtr<Invader> InvaderEnemy::getGame()
+    Invader* InvaderEnemy::getGame()
     {
         if (game == NULL)
         {
@@ -84,4 +84,4 @@
         if (getGame() && orxonox_cast<InvaderShip*>(originator) != NULL && getHealth() <= 0)
             getGame()->addPoints(42);
     }
-}
\ No newline at end of file
+}

Modified: code/trunk/src/modules/invader/InvaderEnemy.h
===================================================================
--- code/trunk/src/modules/invader/InvaderEnemy.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderEnemy.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -48,11 +48,11 @@
             virtual void tick(float dt);
             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
             virtual void damage(float damage, float healthdamage, float shielddamage, Pawn* originator);
-            virtual void setPlayer(WeakPtr<InvaderShip> player){this->player = player;}
+            virtual void setPlayer(InvaderShip* player){this->player = player;}
 
             int level;
         protected:
-            WeakPtr<Invader> getGame();
+            Invader* getGame();
             WeakPtr<Invader> game;
             WeakPtr<InvaderShip> player;
             Camera* camera;

Modified: code/trunk/src/modules/invader/InvaderHUDinfo.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderHUDinfo.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderHUDinfo.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -127,7 +127,7 @@
 
         if (this->getOwner() && this->getOwner()->getGametype())
         {
-            this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype().get());
+            this->InvaderGame = orxonox_cast<Invader*>(this->getOwner()->getGametype());
         }
         else
         {

Modified: code/trunk/src/modules/invader/InvaderShip.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderShip.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderShip.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -90,7 +90,7 @@
             ControllableEntity::fire(0);
 
         // Camera
-        WeakPtr<Camera> camera = this->getCamera();
+        Camera* camera = this->getCamera();
         if (camera != NULL)
         {
             camera->setPosition(Vector3(-pos.z, -posforeward, 0));
@@ -141,8 +141,8 @@
     inline bool InvaderShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     {
         // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
-        WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject);
-        WeakPtr<Projectile> shot = orxonox_cast<Projectile*>(otherObject);
+        InvaderEnemy* enemy = orxonox_cast<InvaderEnemy*>(otherObject);
+        Projectile* shot = orxonox_cast<Projectile*>(otherObject);
         // ensure that this gets only called once per enemy.
         if (enemy != NULL && lastEnemy != enemy)
         {
@@ -170,7 +170,7 @@
         // SUPER(InvaderShip, collidesAgainst, otherObject, contactPoint);
     }
 
-    WeakPtr<Invader> InvaderShip::getGame()
+    Invader* InvaderShip::getGame()
     {
         if (game == NULL)
         {

Modified: code/trunk/src/modules/invader/InvaderShip.h
===================================================================
--- code/trunk/src/modules/invader/InvaderShip.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderShip.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -69,7 +69,7 @@
         protected:
             virtual void death();
         private:
-            WeakPtr<Invader> getGame();
+            Invader* getGame();
             WeakPtr<Invader> game;
             Camera* camera;
             bool isFireing;

Modified: code/trunk/src/modules/invader/InvaderWeapon.cc
===================================================================
--- code/trunk/src/modules/invader/InvaderWeapon.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/invader/InvaderWeapon.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -67,7 +67,7 @@
 
         // Create the projectile.projectile
         projectile = new Projectile(this->getContext());
-        WeakPtr<Model> model = new Model(projectile->getContext());
+        Model* model = new Model(projectile->getContext());
         model->setMeshSource(mesh_);
         model->setCastShadows(false);
         projectile->attach(model);

Modified: code/trunk/src/modules/jump/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/jump/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -23,7 +23,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(jump
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
     orxonox

Modified: code/trunk/src/modules/jump/JumpCenterpoint.cc
===================================================================
--- code/trunk/src/modules/jump/JumpCenterpoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpCenterpoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -79,18 +79,11 @@
         XMLPortParam(JumpCenterpoint, "enemy4Template", setEnemy4Template, getEnemy4Template, xmlelement, mode);
     }
 
-    void JumpCenterpoint::changedGametype()
-    {
-        SUPER(JumpCenterpoint, changedGametype);
-
-        checkGametype();
-    }
-
     void JumpCenterpoint::checkGametype()
     {
         if (getGametype() != NULL && this->getGametype()->isA(Class(Jump)))
         {
-            Jump* jumpGametype = orxonox_cast<Jump*>(this->getGametype().get());
+            Jump* jumpGametype = orxonox_cast<Jump*>(this->getGametype());
             jumpGametype->setCenterpoint(this);
         }
     }

Modified: code/trunk/src/modules/jump/JumpCenterpoint.h
===================================================================
--- code/trunk/src/modules/jump/JumpCenterpoint.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpCenterpoint.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -113,7 +113,6 @@
             JumpCenterpoint(Context* context); //!< Constructor. Registers and initializes the object and checks whether the gametype is actually Jump.
             virtual ~JumpCenterpoint() {}
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a JumpCenterpoint through XML.
-            virtual void changedGametype();
             void setPlatformStaticTemplate(const std::string& balltemplate)
                 { this->platformStaticTemplate_ = balltemplate; }
             const std::string& getPlatformStaticTemplate() const

Modified: code/trunk/src/modules/jump/JumpEnemy.cc
===================================================================
--- code/trunk/src/modules/jump/JumpEnemy.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpEnemy.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -150,7 +150,7 @@
     @param bats
         An array (of size 2) of weak pointers, to be set as the new bats.
     */
-    void JumpEnemy::setFigure(WeakPtr<JumpFigure> newFigure)
+    void JumpEnemy::setFigure(JumpFigure* newFigure)
     {
         figure_ = newFigure;
     }

Modified: code/trunk/src/modules/jump/JumpEnemy.h
===================================================================
--- code/trunk/src/modules/jump/JumpEnemy.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpEnemy.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -67,7 +67,7 @@
                 { return height_; }
 
             virtual void setProperties(float newLeftBoundary, float newRightBoundary, float newLowerBoundary, float newUpperBoundary, float newHSpeed, float newVSpeed);
-            void setFigure(WeakPtr<JumpFigure> bats);
+            void setFigure(JumpFigure* newFigure);
             virtual void touchFigure();
             bool dead_;
         protected:

Modified: code/trunk/src/modules/jump/JumpItem.cc
===================================================================
--- code/trunk/src/modules/jump/JumpItem.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpItem.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -108,7 +108,7 @@
         setVelocity(Vector3(newHSpeed,0,newVSpeed));
     }
 
-    void JumpItem::setFigure(WeakPtr<JumpFigure> newFigure)
+    void JumpItem::setFigure(JumpFigure* newFigure)
     {
         figure_ = newFigure;
     }

Modified: code/trunk/src/modules/jump/JumpItem.h
===================================================================
--- code/trunk/src/modules/jump/JumpItem.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpItem.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -52,7 +52,7 @@
             virtual void tick(float dt);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void setProperties(float newLeftBoundary, float newRightBoundary, float newLowerBoundary, float newUpperBoundary, float newHSpeed, float newVSpeed);
-            virtual void setFigure(WeakPtr<JumpFigure> bats);
+            virtual void setFigure(JumpFigure* newFigure);
             virtual void touchFigure();
 
             void setFieldDimension(float width, float height)

Modified: code/trunk/src/modules/jump/JumpPlatform.cc
===================================================================
--- code/trunk/src/modules/jump/JumpPlatform.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpPlatform.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -124,7 +124,7 @@
         }
     }
 
-    void JumpPlatform::setFigure(WeakPtr<JumpFigure> newFigure)
+    void JumpPlatform::setFigure(JumpFigure* newFigure)
     {
         figure_ = newFigure;
     }

Modified: code/trunk/src/modules/jump/JumpPlatform.h
===================================================================
--- code/trunk/src/modules/jump/JumpPlatform.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpPlatform.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -48,7 +48,7 @@
             virtual ~JumpPlatform();
             virtual void tick(float dt);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            void setFigure(WeakPtr<JumpFigure> bats); //!< Set the bats for the ball.
+            void setFigure(JumpFigure* newFigure);
             virtual void touchFigure();
 
             void setDefScoreSound(const std::string& engineSound);

Modified: code/trunk/src/modules/jump/JumpProjectile.cc
===================================================================
--- code/trunk/src/modules/jump/JumpProjectile.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpProjectile.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -83,7 +83,7 @@
         }
     }
 
-    void JumpProjectile::setFigure(WeakPtr<JumpFigure> figure)
+    void JumpProjectile::setFigure(JumpFigure* figure)
     {
         figure_ = figure;
     }

Modified: code/trunk/src/modules/jump/JumpProjectile.h
===================================================================
--- code/trunk/src/modules/jump/JumpProjectile.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpProjectile.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -55,7 +55,7 @@
             Vector2 getFieldDimension() const
                 { return Vector2(this->fieldWidth_, this->fieldHeight_); }
 
-            void setFigure(WeakPtr<JumpFigure> figure);
+            void setFigure(JumpFigure* figure);
 
         protected:
             float fieldWidth_;

Modified: code/trunk/src/modules/jump/JumpScore.cc
===================================================================
--- code/trunk/src/modules/jump/JumpScore.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/jump/JumpScore.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -117,7 +117,7 @@
 
         if (this->getOwner() != NULL && this->getOwner()->getGametype())
         {
-            this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<Jump*>(this->getOwner()->getGametype());
         }
         else
         {

Modified: code/trunk/src/modules/mini4dgame/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/mini4dgame/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/mini4dgame/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -5,7 +5,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(mini4dgame
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
     orxonox

Modified: code/trunk/src/modules/mini4dgame/Mini4Dgame.cc
===================================================================
--- code/trunk/src/modules/mini4dgame/Mini4Dgame.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/mini4dgame/Mini4Dgame.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,7 +44,7 @@
 #include "core/command/Executor.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "infos/PlayerInfo.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "gamestates/GSLevel.h"
 #include "chat/ChatManager.h"

Modified: code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc
===================================================================
--- code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/mini4dgame/Mini4DgameBoard.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -900,25 +900,13 @@
 
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void Mini4DgameBoard::changedGametype()
-    {
-        SUPER(Mini4DgameBoard, changedGametype);
-
-        // Check, whether it's still Mini4Dgame.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is Mini4Dgame and if it is, sets its centerpoint.
     */
     void Mini4DgameBoard::checkGametype()
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Mini4Dgame)))
         {
-            Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype().get());
+            Mini4Dgame* Mini4DgameGametype = orxonox_cast<Mini4Dgame*>(this->getGametype());
             Mini4DgameGametype->setGameboard(this);
         }
     }

Modified: code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h
===================================================================
--- code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/mini4dgame/Mini4DgameBoard.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -80,7 +80,6 @@
             void makeMove(const Mini4DgamePosition& move);
             Mini4DgameWinner getWinner();
 
-            void changedGametype();
             void checkGametype();
 
         private:

Modified: code/trunk/src/modules/notifications/NotificationDispatcher.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationDispatcher.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/notifications/NotificationDispatcher.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 #include "core/CoreIncludes.h"
 #include "core/EventIncludes.h"
 #include "core/XMLPort.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "network/Host.h"
 
 #include "infos/PlayerInfo.h"
@@ -117,7 +117,7 @@
         // Broadcast
         if(!GameMode::isStandalone())
         {
-            callMemberNetworkFunction(NotificationDispatcher, broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST);
+            callMemberNetworkFunction(&NotificationDispatcher::broadcastHelper, this->getObjectID(), NETWORK_PEER_ID_BROADCAST);
         }
     }
 
@@ -147,7 +147,7 @@
         }
         else if(GameMode::isServer())
         {
-            callMemberNetworkFunction(NotificationDispatcher, dispatch, this->getObjectID(), clientId, clientId);
+            callMemberNetworkFunction(&NotificationDispatcher::dispatch, this->getObjectID(), clientId, clientId);
         }
     }
 

Modified: code/trunk/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/notifications/NotificationManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 #include "core/command/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
 #include "core/LuaState.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 #include "interfaces/NotificationListener.h"
 
@@ -46,8 +46,10 @@
 namespace orxonox
 {
 
-    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
+    ManageScopedSingleton(NotificationManager, ScopeID::ROOT, false);
 
+    RegisterAbstractClass(NotificationManager).inheritsFrom<NotificationListener>();
+
     /**
     @brief
         Constructor. Registers the Object.

Modified: code/trunk/src/modules/objects/Planet.cc
===================================================================
--- code/trunk/src/modules/objects/Planet.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/Planet.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -86,10 +86,6 @@
         SUPER(Planet, tick, dt);
     }
 
-    void Planet::init()
-    {
-    }
-
     void Planet::changedMesh()
     {
         if( GameMode::showsGraphics() )

Modified: code/trunk/src/modules/objects/Planet.h
===================================================================
--- code/trunk/src/modules/objects/Planet.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/Planet.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -51,7 +51,6 @@
 
             virtual ~Planet();
 
-            void init();
             virtual void tick(float dt);
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);

Modified: code/trunk/src/modules/objects/Script.cc
===================================================================
--- code/trunk/src/modules/objects/Script.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/Script.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 #include "core/LuaState.h"
 #include "core/XMLPort.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "PlayerManager.h"
 #include "infos/PlayerInfo.h"
@@ -197,7 +197,7 @@
                 const std::map<unsigned int, PlayerInfo*> clients = PlayerManager::getInstance().getClients();
                 for(std::map<unsigned int, PlayerInfo*>::const_iterator it = clients.begin(); it != clients.end(); it++)
                 {
-                    callStaticNetworkFunction(Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
+                    callStaticNetworkFunction(&Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
                     if(this->times_ != Script::INF) // Decrement the number of remaining executions.
                     {
                         this->remainingExecutions_--;
@@ -209,7 +209,7 @@
             // Else we execute the code just for the specified client.
             else
             {
-                callStaticNetworkFunction(Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
+                callStaticNetworkFunction(&Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
                 if(this->times_ != Script::INF) // Decrement the number of remaining executions.
                     this->remainingExecutions_--;
             }
@@ -247,7 +247,7 @@
         // If this is the server and the Script is specified as being 'onLoad'.
         if(GameMode::isServer() && this->isOnLoad())
         {
-            callStaticNetworkFunction(Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
+            callStaticNetworkFunction(&Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
         }
     }
 

Modified: code/trunk/src/modules/objects/SpaceBoundaries.cc
===================================================================
--- code/trunk/src/modules/objects/SpaceBoundaries.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/SpaceBoundaries.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -209,7 +209,7 @@
         bool humanItem;
         for( std::list<WeakPtr<Pawn> >::iterator current = pawnsIn_.begin(); current != pawnsIn_.end(); current++ )
         {
-            Pawn* currentPawn = current->get();
+            Pawn* currentPawn = *current;
             if( currentPawn && currentPawn->getNode() ) 
             {
                 distance = this->computeDistance(currentPawn);

Modified: code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/AbstractRadiusHeightCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,7 +39,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom(Class(CollisionShape));
+    RegisterAbstractClass(AbstractRadiusHeightCollisionShape).inheritsFrom<CollisionShape>();
 
     /**
     @brief

Modified: code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -57,13 +57,6 @@
         this->registerVariables();
     }
 
-    BoxCollisionShape::~BoxCollisionShape()
-    {
-        // TODO: Move to CollisionShape?
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     void BoxCollisionShape::registerVariables()
     {
         registerVariable(this->halfExtents_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));

Modified: code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -57,7 +57,6 @@
     {
         public:
             BoxCollisionShape(Context* context);
-            virtual ~BoxCollisionShape();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 

Modified: code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -53,12 +53,6 @@
         updateShape();
     }
 
-    ConeCollisionShape::~ConeCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     /**
     @brief
         Creates a new internal collision shape for the ConeCollisionShape.

Modified: code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -55,7 +55,6 @@
     {
         public:
             ConeCollisionShape(Context* context);
-            virtual ~ConeCollisionShape();
 
         private:
             btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the ConeCollisionShape.

Modified: code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -53,12 +53,6 @@
         updateShape();
     }
 
-    CylinderCollisionShape::~CylinderCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     /**
     @brief
         Creates a new internal collision shape for the CylinderCollisionShape.

Modified: code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/CylinderCollisionShape.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -52,7 +52,6 @@
     {
         public:
             CylinderCollisionShape(Context* context);
-            virtual ~CylinderCollisionShape();
 
         private:
             btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the CylinderCollisionShape.

Modified: code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -58,12 +58,6 @@
         this->registerVariables();
     }
 
-    PlaneCollisionShape::~PlaneCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     void PlaneCollisionShape::registerVariables()
     {
         registerVariable(this->normal_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));

Modified: code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -57,7 +57,6 @@
     {
         public:
             PlaneCollisionShape(Context* context);
-            virtual ~PlaneCollisionShape();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 

Modified: code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -57,12 +57,6 @@
         this->registerVariables();
     }
 
-    SphereCollisionShape::~SphereCollisionShape()
-    {
-        if (this->isInitialized())
-            delete this->collisionShape_;
-    }
-
     void SphereCollisionShape::registerVariables()
     {
         registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));

Modified: code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -55,7 +55,6 @@
     {
         public:
             SphereCollisionShape(Context* context);
-            virtual ~SphereCollisionShape();
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 

Modified: code/trunk/src/modules/objects/triggers/CheckPoint.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/CheckPoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/triggers/CheckPoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -92,7 +92,7 @@
     {
         DistanceTrigger::triggered(bIsTriggered);
 
-        Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype().get());
+        Asteroids* gametype = orxonox_cast<Asteroids*>(this->getGametype());
         if (gametype)
         {
             gametype->addTime(addTime_);

Modified: code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -99,15 +99,14 @@
         std::queue<MultiTriggerState*>* queue = NULL;
 
         // Check for objects that were in range but no longer are. Iterate through all objects, that are in range.
-        for(std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator it = this->range_.begin(); it != this->range_.end(); )
+        for(std::set<WeakPtr<WorldEntity> >::iterator it = this->range_.begin(); it != this->range_.end(); )
         {
-            WorldEntity* entity = it->second->get();
-            WorldEntity* key = it->first;
-            it++; // Incrementing the iterator in advance, since we don't need the current anymore and we potentially are going to delete the current element thus invalidating the iterator.
+            WorldEntity* entity = *it;
+
             // If the entity no longer exists.
             if(entity == NULL)
             {
-                this->removeFromRange(key);
+                this->range_.erase(it++);
                 continue;
             }
 
@@ -115,9 +114,7 @@
             // If the object is no longer in range.
             if (distanceVec.length() > this->distance_)
             {
-                // If for some reason the entity could not be removed.
-                if(!this->removeFromRange(key))
-                    continue;
+                this->range_.erase(it++);
 
                 // If no queue has been created, yet.
                 if(queue == NULL)
@@ -129,6 +126,10 @@
                 state->originator = entity;
                 queue->push(state);
             }
+            else
+            {
+                ++it;
+            }
         }
 
         // Check for new objects that are in range
@@ -259,33 +260,7 @@
     */
     bool DistanceMultiTrigger::addToRange(WorldEntity* entity)
     {
-        WeakPtr<WorldEntity>* weakptr = new WeakPtr<WorldEntity>(entity);
-        std::pair<std::map<WorldEntity*, WeakPtr<WorldEntity>* >::iterator, bool> pair = this->range_.insert(std::pair<WorldEntity*, WeakPtr<WorldEntity>* >(entity, weakptr));
-
-        if(!pair.second)
-        {
-            delete weakptr;
-            return false;
-        }
-
-        return true;
+        std::pair<std::set<WeakPtr<WorldEntity> >::iterator, bool> pair = this->range_.insert(entity);
+        return pair.second;
     }
-
-    /**
-    @brief
-        Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
-    @param entity
-        A pointer ot the entity.
-    @return
-        Returns true if successful.
-    */
-    bool DistanceMultiTrigger::removeFromRange(WorldEntity* entity)
-    {
-        WeakPtr<WorldEntity>* weakptr = this->range_.find(entity)->second;
-        bool erased = this->range_.erase(entity) > 0;
-        if(erased)
-            delete weakptr;
-        return erased;
-    }
-
 }

Modified: code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -139,7 +139,6 @@
             virtual std::queue<MultiTriggerState*>* letTrigger(void); // This method is called by the MultiTrigger to get information about new trigger events that need to be looked at.
 
             bool addToRange(WorldEntity* entity); // Add a given entity to the entities, that currently are in range of the DistanceMultiTrigger.
-            bool removeFromRange(WorldEntity* entity); // Remove a given entity from the set of entities, that currently are in range of the DistanceMultiTrigger.
 
         private:
             //! Strings for the beacon modes.
@@ -153,7 +152,7 @@
             std::string targetName_; //!< The target name, used in <em>single-target</em> mode.
             ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
 
-            std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
+            std::set<WeakPtr<WorldEntity> > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
 
     };
 

Modified: code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -146,9 +146,9 @@
     bool DistanceTrigger::checkDistance()
     {
         // Check whether there is a cached object, it still exists and whether it is still in range, if so nothing further needs to be done.
-        if(this->cache_.get() != NULL)
+        if(this->cache_ != NULL)
         {
-            if((this->cache_.get()->getWorldPosition() - this->getWorldPosition()).length() < this->distance_)
+            if((this->cache_->getWorldPosition() - this->getWorldPosition()).length() < this->distance_)
                 return true;
             else
                 this->cache_.reset();
@@ -212,7 +212,7 @@
                 }
                 
                 // Add the entity to the cache.
-                this->cache_ = WeakPtr<WorldEntity>(entity);
+                this->cache_ = entity;
 
                 return true;
             }

Modified: code/trunk/src/modules/objects/triggers/Trigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/Trigger.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/objects/triggers/Trigger.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,7 +37,7 @@
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "Scene.h"
 

Modified: code/trunk/src/modules/overlays/hud/HUDHealthBar.h
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDHealthBar.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/overlays/hud/HUDHealthBar.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -114,7 +114,7 @@
 
         private:
             WeakPtr<Pawn> owner_;
-            SmartPtr<OverlayText> textoverlay_;
+            StrongPtr<OverlayText> textoverlay_;
             bool bUseBarColour_;
             ColourValue textColour_;
     };

Modified: code/trunk/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDNavigation.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/overlays/hud/HUDNavigation.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -40,7 +40,7 @@
 
 #include "util/Math.h"
 #include "util/Convert.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "CameraManager.h"

Modified: code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/overlays/hud/LastManStandingInfos.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -86,7 +86,7 @@
         if (this->getOwner() && this->getOwner()->getGametype())
         {
             this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner());
-            this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype().get());
+            this->lms_ = orxonox_cast<LastManStanding*>(this->getOwner()->getGametype());
         }
         else
         {

Modified: code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/overlays/hud/LastTeamStandingInfos.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -86,7 +86,7 @@
         if (this->getOwner() && this->getOwner()->getGametype())
         {
             this->player_ = orxonox_cast<PlayerInfo*>(this->getOwner());
-            this->lts_ = orxonox_cast<LastTeamStanding*>(this->getOwner()->getGametype().get());
+            this->lts_ = orxonox_cast<LastTeamStanding*>(this->getOwner()->getGametype());
         }
         else
         {

Modified: code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/overlays/hud/TeamBaseMatchScore.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -117,7 +117,7 @@
         SUPER(TeamBaseMatchScore, changedOwner);
 
         if (this->getOwner() && this->getOwner()->getGametype())
-            this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<TeamBaseMatch*>(this->getOwner()->getGametype());
         else
             this->owner_ = 0;
     }

Modified: code/trunk/src/modules/pickup/CollectiblePickup.cc
===================================================================
--- code/trunk/src/modules/pickup/CollectiblePickup.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pickup/CollectiblePickup.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,7 +39,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(CollectiblePickup).inheritsFrom(Class(Pickupable));
+    RegisterAbstractClass(CollectiblePickup).inheritsFrom<Pickupable>();
 
     /**
     @brief

Modified: code/trunk/src/modules/pickup/PickupManager.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pickup/PickupManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,9 +37,9 @@
 #include "core/LuaState.h"
 #include "core/GUIManager.h"
 #include "core/class/Identifier.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
-#include "util/ScopedSingletonManager.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "infos/PlayerInfo.h"
 #include "interfaces/PickupCarrier.h"
@@ -50,7 +50,7 @@
 
 namespace orxonox
 {
-    ManageScopedSingleton(PickupManager, ScopeID::Root, false);
+    ManageScopedSingleton(PickupManager, ScopeID::ROOT, false);
 
     // Initialization of the name of the PickupInventory GUI.
     /*static*/ const std::string PickupManager::guiName_s = "PickupInventory";
@@ -61,6 +61,8 @@
     registerStaticNetworkFunction(PickupManager::dropPickupNetworked);
     registerStaticNetworkFunction(PickupManager::usePickupNetworked);
 
+    RegisterAbstractClass(PickupManager).inheritsFrom<PickupListener>();
+
     /**
     @brief
         Constructor. Registers the PickupManager and creates the default PickupRepresentation.
@@ -93,8 +95,6 @@
         this->pickupInventoryContainers_.clear();
 
         // Destroying all the WeakPointers that are still there.
-        for(std::map<uint32_t, WeakPtr<Pickupable>*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
-            delete it->second;
         this->pickups_.clear();
 
         this->indexes_.clear();
@@ -211,7 +211,7 @@
         // If the concerned host is somewhere in the network, we call pickupChangedUsedNetwork() on its PickupManager.
         else
         {
-            callStaticNetworkFunction(PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable());
+            callStaticNetworkFunction(&PickupManager::pickupChangedUsedNetwork, clientId, index, used, pickup->isUsable(), pickup->isUnusable());
         }
     }
 
@@ -285,7 +285,7 @@
             index = this->getPickupIndex(); // Ge a new identifier (index) for the Pickupable.
             // Add the Pickupable to the indexes_ and pickups_ lists.
             this->indexes_[pickup] = index;
-            this->pickups_[index] = new WeakPtr<Pickupable>(pickup);
+            this->pickups_[index] = pickup;
         }
         else // If it was dropped, it is removed from the required lists.
         {
@@ -293,11 +293,9 @@
             std::map<Pickupable*, uint32_t>::iterator it = this->indexes_.find(pickup);
             index = it->second;
 
-            // Remove the Pickupable form the indexes_ and pickups_ list.
-            WeakPtr<Pickupable>* ptr = this->pickups_[index];
+            // Remove the Pickupable from the indexes_ and pickups_ list.
             this->indexes_.erase(it);
             this->pickups_.erase(index);
-            delete ptr;
         }
 
         // If we're either in standalone mode or this is the host whom the change of the pickup's status concerns.
@@ -315,11 +313,11 @@
             // If there is no PickupRepresentation registered the default representation is used.
             if(this->representations_.find(pickup->getRepresentationName()) == this->representations_.end())
             {
-                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
+                callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->defaultRepresentation_->getObjectID(), pickedUp);
             }
             else
             {
-                callStaticNetworkFunction(PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp);
+                callStaticNetworkFunction(&PickupManager::pickupChangedPickedUpNetwork, clientId, index, pickup->isUsable(), this->representations_[pickup->getRepresentationName()]->getObjectID(), pickedUp);
             }
         }
 
@@ -399,14 +397,14 @@
         {
             if(this->pickups_.empty())
                 return;
-            Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
+            Pickupable* pickupable = this->pickups_.find(pickup)->second;
             if(pickupable != NULL)
                 pickupable->drop();
         }
         // If we're neither server nor standalone we drop the pickup by calling dropPickupNetworked() of the PickupManager on the server.
         else
         {
-            callStaticNetworkFunction(PickupManager::dropPickupNetworked, 0, pickup);
+            callStaticNetworkFunction(&PickupManager::dropPickupNetworked, 0, pickup);
         }
     }
 
@@ -442,14 +440,14 @@
         {
             if(this->pickups_.empty())
                 return;
-            Pickupable* pickupable = this->pickups_.find(pickup)->second->get();
+            Pickupable* pickupable = this->pickups_.find(pickup)->second;
             if(pickupable != NULL)
                 pickupable->setUsed(use);
         }
         // If we're neither server nor standalone we change the used status of the pickup by calling usePickupNetworked() of the PickupManager on the server.
         else
         {
-            callStaticNetworkFunction(PickupManager::usePickupNetworked, 0, pickup, use);
+            callStaticNetworkFunction(&PickupManager::usePickupNetworked, 0, pickup, use);
         }
     }
 

Modified: code/trunk/src/modules/pickup/PickupManager.h
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pickup/PickupManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -160,7 +160,7 @@
             std::map<uint32_t, PickupInventoryContainer*> pickupInventoryContainers_; //!< Map linking a number identifying a Pickupable to a PickupInventoryContainer, which contains all necessary information about that Pickupable.
             std::map<uint32_t, PickupInventoryContainer*>::iterator pickupsIterator_; //!< An iterator pointing to the current Pickupable in pickupsList_.
 
-            std::map<uint32_t, WeakPtr<Pickupable>*> pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.
+            std::map<uint32_t, WeakPtr<Pickupable> > pickups_; //!< Map linking a number identifying a Pickupable to a weak pointer of a Pickupable.
             std::map<Pickupable*, uint32_t> indexes_;//!< Map linking Pickupable to the number identifying it.
 
             void updateGUI(void); //!< Updates the PickupInventory GUI.

Modified: code/trunk/src/modules/pickup/PickupSpawner.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupSpawner.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pickup/PickupSpawner.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -144,7 +144,8 @@
         // If the PickupSpawner is active.
         if(GameMode::isMaster() && this->isActive())
         {
-            WeakPtr<PickupSpawner> spawner = this; // Create a smart pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
+            // TODO: why is this a WeakPtr when the comment says StrongPtr?
+            WeakPtr<PickupSpawner> spawner = this; // Create a strong pointer to keep the PickupSpawner alive until we iterated through all Pawns (in case a Pawn takes the last pickup)
 
             // Remove PickupCarriers from the blocked list if they have exceeded their time.
             for(std::map<PickupCarrier*, std::time_t>::iterator it = this->blocked_.begin(); it != this->blocked_.end(); )

Modified: code/trunk/src/modules/pickup/items/ShrinkPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/ShrinkPickup.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pickup/items/ShrinkPickup.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -181,7 +181,7 @@
                 pawn->setMass(pawn->getMass()*factor);
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
                 {
@@ -207,7 +207,7 @@
                 pawn->setMass(pawn->getMass()*this->shrinkFactor_);
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
                 {
@@ -262,7 +262,7 @@
                 pawn->setMass(pawn->getMass()*factor);
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
                 {
@@ -303,7 +303,7 @@
                 pawn->setMass(pawn->getMass()*factor);
 
                 // Iterate over all camera positions and inversely move the camera to create a shrinking sensation.
-                const std::list< SmartPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
+                const std::list< StrongPtr<CameraPosition> >& cameraPositions = pawn->getCameraPositions();
                 int size = cameraPositions.size();
                 for(int index = 0; index < size; index++)
                 {

Modified: code/trunk/src/modules/pong/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/pong/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pong/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -11,7 +11,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(pong
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
     orxonox

Modified: code/trunk/src/modules/pong/PongCenterpoint.cc
===================================================================
--- code/trunk/src/modules/pong/PongCenterpoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pong/PongCenterpoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -79,25 +79,13 @@
 
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void PongCenterpoint::changedGametype()
-    {
-        SUPER(PongCenterpoint, changedGametype);
-
-        // Check, whether it's still Pong.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is Pong and if it is, sets its centerpoint.
     */
     void PongCenterpoint::checkGametype()
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Pong)))
         {
-            Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype().get());
+            Pong* pongGametype = orxonox_cast<Pong*>(this->getGametype());
             pongGametype->setCenterpoint(this);
         }
     }

Modified: code/trunk/src/modules/pong/PongCenterpoint.h
===================================================================
--- code/trunk/src/modules/pong/PongCenterpoint.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pong/PongCenterpoint.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -125,8 +125,6 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a PongCenterpoint through XML.
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
-
             /**
             @brief Set the template for the ball. (e.g. to attach the model of the ball, but also to attach an EventListener to it to detect, when it hits the boundaries, and e.g. display some ParticleEffets, when it does.)
             @param balltemplate The name of the template to be set.

Modified: code/trunk/src/modules/pong/PongScore.cc
===================================================================
--- code/trunk/src/modules/pong/PongScore.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/pong/PongScore.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -169,7 +169,7 @@
         SUPER(PongScore, changedOwner);
 
         if (this->getOwner() != NULL && this->getOwner()->getGametype())
-            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<Pong*>(this->getOwner()->getGametype());
         else
             this->owner_ = 0;
     }

Modified: code/trunk/src/modules/questsystem/Quest.cc
===================================================================
--- code/trunk/src/modules/questsystem/Quest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/questsystem/Quest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,7 +44,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(Quest).inheritsFrom(Class(QuestItem));
+    RegisterAbstractClass(Quest).inheritsFrom<QuestItem>();
 
     /**
     @brief

Modified: code/trunk/src/modules/questsystem/QuestEffect.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestEffect.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/questsystem/QuestEffect.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(QuestEffect).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(QuestEffect).inheritsFrom<BaseObject>();
 
     /**
     @brief

Modified: code/trunk/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/questsystem/QuestManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,7 +35,7 @@
 
 #include "util/Exception.h"
 #include "util/OrxAssert.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/command/ConsoleCommand.h"
 #include "core/GUIManager.h"
 #include "core/LuaState.h"
@@ -48,7 +48,7 @@
 
 namespace orxonox
 {
-    ManageScopedSingleton(QuestManager, ScopeID::Root, false);
+    ManageScopedSingleton(QuestManager, ScopeID::ROOT, false);
 
     /**
     @brief

Modified: code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -41,7 +41,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(ChangeQuestStatus).inheritsFrom(Class(QuestEffect));
+    RegisterAbstractClass(ChangeQuestStatus).inheritsFrom<QuestEffect>();
 
     /**
     @brief

Modified: code/trunk/src/modules/tetris/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/tetris/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/tetris/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -7,7 +7,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(tetris
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
     orxonox

Modified: code/trunk/src/modules/tetris/Tetris.cc
===================================================================
--- code/trunk/src/modules/tetris/Tetris.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/tetris/Tetris.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -103,7 +103,7 @@
             this->futureBrick_ = 0;
         }
 
-        for (std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for (std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
             (*it)->destroy();
         this->stones_.clear();
     }
@@ -135,7 +135,7 @@
         else if(position.x > (this->center_->getWidth()-0.5)*this->center_->getStoneSize()) //!< If the stone touches the right edge of the level
             return false;
 
-        for(std::list<SmartPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
         {
             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
 
@@ -191,7 +191,7 @@
         assert(stone);
 
         // check for collisions with all stones
-        for(std::list<SmartPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for(std::list<StrongPtr<TetrisStone> >::const_iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
         {
             //Vector3 currentStonePosition = rotateVector((*it)->getPosition(), this->activeBrick_->getRotationCount());
             const Vector3& currentStonePosition = (*it)->getPosition(); //!< Saves the position of the currentStone
@@ -468,9 +468,9 @@
         for (unsigned int row = 0; row < this->center_->getHeight(); row++)
         {
             stonesPerRow = 0;
-            for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
+            for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
             {
-                std::list<SmartPtr<TetrisStone> >::iterator it_temp = it++;
+                std::list<StrongPtr<TetrisStone> >::iterator it_temp = it++;
                 correctPosition = static_cast<unsigned int>(((*it_temp)->getPosition().y - 5)/this->center_->getStoneSize());
                 if(correctPosition == row)
                 {
@@ -490,7 +490,7 @@
 
     void Tetris::clearRow(unsigned int row)
     {// clear the full row
-        for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
+        for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); )
         {
             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) == row)
             {
@@ -501,7 +501,7 @@
                 ++it;
         }
       // adjust height of stones above the deleted row //TODO: check if this could be a source of a bug.
-        for(std::list<SmartPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
+        for(std::list<StrongPtr<TetrisStone> >::iterator it = this->stones_.begin(); it != this->stones_.end(); ++it)
         {
             if(static_cast<unsigned int>(((*it)->getPosition().y - 5)/this->center_->getStoneSize()) > row)
                 (*it)->setPosition((*it)->getPosition()-Vector3(0,10,0));

Modified: code/trunk/src/modules/tetris/Tetris.h
===================================================================
--- code/trunk/src/modules/tetris/Tetris.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/tetris/Tetris.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -68,7 +68,7 @@
             void setCenterpoint(TetrisCenterpoint* center);
 
             PlayerInfo* getPlayer(void) const; //!< Get the player.
-            WeakPtr<TetrisCenterpoint> getCenterpoint(void)
+            TetrisCenterpoint* getCenterpoint(void)
                 { return this->center_; }
 
             bool isValidMove(TetrisStone* stone, const Vector3& position);
@@ -92,7 +92,7 @@
             PlayerInfo* player_;
 
             WeakPtr<TetrisCenterpoint> center_; //!< The playing field.
-            std::list<SmartPtr<TetrisStone> > stones_; //!< A list of all stones in play.
+            std::list<StrongPtr<TetrisStone> > stones_; //!< A list of all stones in play.
             WeakPtr<TetrisBrick> activeBrick_;
             WeakPtr<TetrisBrick> futureBrick_;
 

Modified: code/trunk/src/modules/tetris/TetrisBrick.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisBrick.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/tetris/TetrisBrick.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -168,7 +168,7 @@
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
         {
-            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
+            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype());
             return tetrisGametype;
         }
         return NULL;

Modified: code/trunk/src/modules/tetris/TetrisCenterpoint.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisCenterpoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/tetris/TetrisCenterpoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -79,25 +79,13 @@
 
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void TetrisCenterpoint::changedGametype()
-    {
-        SUPER(TetrisCenterpoint, changedGametype);
-
-        // Check, whether it's still Tetris.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is Tetris and if it is, sets its centerpoint.
     */
     void TetrisCenterpoint::checkGametype()
     {
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(Tetris)))
         {
-            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype().get());
+            Tetris* tetrisGametype = orxonox_cast<Tetris*>(this->getGametype());
             tetrisGametype->setCenterpoint(this);
         }
     }

Modified: code/trunk/src/modules/tetris/TetrisCenterpoint.h
===================================================================
--- code/trunk/src/modules/tetris/TetrisCenterpoint.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/tetris/TetrisCenterpoint.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -63,8 +63,6 @@
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method to create a TetrisCenterpoint through XML.
 
-            virtual void changedGametype(); //!< Is called when the gametype has changed.
-            
             /**
             @brief Set the width of the playing field.
             @param width The width in number of tiles.

Modified: code/trunk/src/modules/tetris/TetrisScore.cc
===================================================================
--- code/trunk/src/modules/tetris/TetrisScore.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/tetris/TetrisScore.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -117,7 +117,7 @@
         SUPER(TetrisScore, changedOwner);
 
         if (this->getOwner() != NULL && this->getOwner()->getGametype())
-            this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype().get());
+            this->owner_ = orxonox_cast<Tetris*>(this->getOwner()->getGametype());
         else
             this->owner_ = 0;
     }

Modified: code/trunk/src/modules/towerdefense/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/towerdefense/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -10,7 +10,7 @@
 )
 
 ORXONOX_ADD_LIBRARY(towerdefense
-  MODULE
+  PLUGIN
   FIND_HEADER_FILES
   LINK_LIBRARIES
     orxonox

Modified: code/trunk/src/modules/towerdefense/TDCoordinate.h
===================================================================
--- code/trunk/src/modules/towerdefense/TDCoordinate.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/TDCoordinate.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,7 +1,6 @@
 #ifndef _TDCoordinate_H__
 #define _TDCoordinate_H__
 
-#include "core/CoreIncludes.h"
 #include "TDCoordinate.h"
 //#include "towerdefense/TowerDefense.h"
 #include "gametypes/Deathmatch.h"
@@ -12,7 +11,7 @@
 
 //Class to save the Coordinates in a class instead of struct
 //Convert 2d coordinates to 3d in order to set waypoints
-    class _TowerDefenseExport TDCoordinate : public OrxonoxClass
+    class _TowerDefenseExport TDCoordinate
     {
         public:
             TDCoordinate();

Modified: code/trunk/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefense.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/TowerDefense.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -84,7 +84,7 @@
 #include "chat/ChatManager.h"
 #include "core/CoreIncludes.h"
 /* Part of a temporary hack to allow the player to add towers */
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include <cmath>
 
 

Modified: code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -82,18 +82,6 @@
 
     /**
     @brief
-        Is called when the gametype has changed.
-    */
-    void TowerDefenseCenterpoint::changedGametype()
-    {
-        SUPER(TowerDefenseCenterpoint, changedGametype);
-
-        // Check, whether it's still TowerDefense.
-        this->checkGametype();
-    }
-
-    /**
-    @brief
         Checks whether the gametype is TowerDefense and if it is, sets its centerpoint.
     */
     void TowerDefenseCenterpoint::checkGametype()
@@ -101,7 +89,7 @@
         if (this->getGametype() != NULL && this->getGametype()->isA(Class(TowerDefense)))
         {
             // Sets the centerpoint of the gametype. The gametype uses this to later spawn in towers, he needs the tower template stored in the center point
-            TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype().get());
+            TowerDefense* towerDefenseGametype = orxonox_cast<TowerDefense*>(this->getGametype());
             towerDefenseGametype->setCenterpoint(this);
         }
     }

Modified: code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/TowerDefenseCenterpoint.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -52,7 +52,6 @@
             virtual ~TowerDefenseCenterpoint() {}
 
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            virtual void changedGametype();
 
             /**
             @brief The width and hight in number of tiles. Default is 15 for both.

Modified: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -28,7 +28,7 @@
 
         this->setCollisionType(WorldEntity::Dynamic);
         //needed to keep track of the PlayerStats coded in TowerDefense.h
-        this->td = orxonox_cast<TowerDefense*>(this->getGametype().get());
+        this->td = orxonox_cast<TowerDefense*>(this->getGametype());
         once_=false;
 
     }
@@ -52,7 +52,7 @@
         SUPER(TowerDefenseEnemy, tick, dt);
     }
 
-    WeakPtr<TowerDefense> TowerDefenseEnemy::getGame()
+    TowerDefense* TowerDefenseEnemy::getGame()
     {
         if (game == NULL)
         {

Modified: code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/TowerDefenseEnemy.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -46,7 +46,7 @@
 
 
     private:
-        WeakPtr<TowerDefense> getGame();
+        TowerDefense* getGame();
         WeakPtr<TowerDefense> game;
         TowerDefense* td;
         bool once_;

Modified: code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc
===================================================================
--- code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/towerdefense/TowerDefenseHUDController.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -79,7 +79,7 @@
 
             if (this->getOwner() && this->getOwner()->getGametype())
                     {
-                        this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype().get());
+                        this->td = orxonox_cast<TowerDefense*>(this->getOwner()->getGametype());
                     }
                     else
                     {

Modified: code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -53,7 +53,8 @@
             this->attachOgreObject(this->particles_->getParticleSystem());
             this->particles_->setKeepParticlesInLocalSpace(0);
 
-            this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT);
+            for (unsigned int i = 0; i < this->particles_->getNumEmitters(); ++i)
+                this->particles_->getEmitter(i)->setDirection(-WorldEntity::FRONT);
         }
         else
             this->particles_ = 0;

Modified: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -28,9 +28,7 @@
   LevelManager.cc
   Main.cc
   MoodManager.cc
-  PawnManager.cc
   PlayerManager.cc
-  ShipPartManager.cc
   Radar.cc
 #  Test.cc
 

Modified: code/trunk/src/orxonox/CameraManager.cc
===================================================================
--- code/trunk/src/orxonox/CameraManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/CameraManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,16 +34,16 @@
 #include <OgreViewport.h>
 #include <OgreCompositorManager.h>
 
-#include "util/ScopedSingletonManager.h"
 #include "core/GameMode.h"
 #include "core/GraphicsManager.h"
 #include "core/object/ObjectList.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "tools/Shader.h"
 #include "graphics/Camera.h"
 
 namespace orxonox
 {
-    ManageScopedSingleton(CameraManager, ScopeID::Graphics, false);
+    ManageScopedSingleton(CameraManager, ScopeID::GRAPHICS, false);
 
     CameraManager::CameraManager()
     {

Modified: code/trunk/src/orxonox/Level.cc
===================================================================
--- code/trunk/src/orxonox/Level.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/Level.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -34,6 +34,7 @@
 #include "core/Template.h"
 #include "core/XMLFile.h"
 #include "core/XMLPort.h"
+#include "core/module/PluginReference.h"
 
 #include "infos/PlayerInfo.h"
 #include "gametypes/Gametype.h"
@@ -48,6 +49,7 @@
     {
         RegisterObject(Level);
 
+        this->setLevel(WeakPtr<Level>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
 
         this->registerVariables();
         this->xmlfilename_ = this->getFilename();
@@ -62,7 +64,9 @@
                 LevelManager::getInstance().releaseActivity(this);
 
             if (this->xmlfile_)
-                Loader::unload(this->xmlfile_);
+                Loader::getInstance().unload(this->xmlfile_);
+
+            this->unloadPlugins();
         }
     }
 
@@ -70,6 +74,7 @@
     {
         SUPER(Level, XMLPort, xmlelement, mode);
 
+        XMLPortParam(Level, "plugins",  setPluginsString,  getPluginsString,  xmlelement, mode);
         XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
 
         XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
@@ -94,7 +99,7 @@
 
         this->xmlfile_ = new XMLFile(mask, this->xmlfilename_);
 
-        Loader::open(this->xmlfile_);
+        Loader::getInstance().load(this->xmlfile_);
     }
 
     void Level::networkCallbackTemplatesChanged()
@@ -106,6 +111,33 @@
         }
     }
 
+    void Level::setPluginsString(const std::string& pluginsString)
+    {
+        // unload old plugins
+        this->unloadPlugins();
+
+        // load new plugins
+        this->pluginsString_ = pluginsString;
+        SubString tokens(pluginsString, ",");
+        for (size_t i = 0; i < tokens.size(); ++i)
+            this->plugins_.push_back(new PluginReference(tokens[i]));
+    }
+
+    void Level::unloadPlugins()
+    {
+        // use destroyLater() - this ensures that plugins are not unloaded too early.
+        // Note: When a level gets unloaded, the Level object is usually the last object that gets destroyed. This is because all other
+        //       objects inside a level have a StrongPtr (in BaseObject) that references the Level object. This means that the Level
+        //       object is only destroyed, when all StrongPtrs that pointed to it were destroyed. But at the time when the last StrongPtr
+        //       is destroyed, the other object is not yet fully destroyed because the StrongPtr is destroyed in ~BaseObject (and this
+        //       means that e.g. ~Identifiable was not yet called for this object). This means that technically there are still other
+        //       objects alive when ~Level is called. This is the reason why we cannot directly destroy() the Plugins - instead we need
+        //       to call destroyLater() to ensure that no instances from this plugin exist anymore.
+        for (std::list<PluginReference*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)
+            (*it)->destroyLater();
+        this->plugins_.clear();
+    }
+
     void Level::setGametypeString(const std::string& gametype)
     {
         Identifier* identifier = ClassByString(gametype);
@@ -120,11 +152,12 @@
             this->gametype_ = gametype;
 
         Gametype* rootgametype = orxonox_cast<Gametype*>(identifier->fabricate(this));
-        this->setGametype(rootgametype);
 
-        for (std::list<BaseObject*>::iterator it = this->objects_.begin(); it != this->objects_.end(); ++it)
-            (*it)->setGametype(rootgametype);
+        // store a weak-pointer to the gametype to avoid a circular dependency between this level and the gametype (which has a strong-reference on this level)
+        this->setGametype(WeakPtr<Gametype>(rootgametype));
 
+        rootgametype->init(); // call init() AFTER the gametype was set
+
         if (LevelManager::exists())
             LevelManager::getInstance().requestActivity(this);
     }
@@ -133,8 +166,6 @@
     void Level::addObject(BaseObject* object)
     {
         this->objects_.push_back(object);
-        object->setGametype(this->getGametype());
-        object->setLevel(this);
     }
 
     BaseObject* Level::getObject(unsigned int index) const
@@ -169,12 +200,12 @@
     void Level::playerEntered(PlayerInfo* player)
     {
         orxout(internal_info) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
-        player->setGametype(this->getGametype());
+        player->switchGametype(this->getGametype());
     }
 
     void Level::playerLeft(PlayerInfo* player)
     {
         orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
-        player->setGametype(0);
+        player->switchGametype(0);
     }
 }

Modified: code/trunk/src/orxonox/Level.h
===================================================================
--- code/trunk/src/orxonox/Level.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/Level.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -64,12 +64,21 @@
 //            const MeshLodInformation* getLodInfo(std::string meshName) const;
 //            MeshLodInformation* getLodInfo(unsigned int index) const;
 
+            void setPluginsString(const std::string& pluginsString);
+            inline const std::string& getPluginsString() const
+                { return this->pluginsString_; }
+
+            void unloadPlugins();
+
             void setGametypeString(const std::string& gametype);
             inline const std::string& getGametypeString() const
                 { return this->gametype_; }
 
             void networkcallback_applyXMLFile();
 
+            std::string                    pluginsString_;
+            std::list<PluginReference*>    plugins_;
+
             std::string                    gametype_;
             std::string                    xmlfilename_;
             XMLFile*                       xmlfile_;

Modified: code/trunk/src/orxonox/LevelManager.cc
===================================================================
--- code/trunk/src/orxonox/LevelManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/LevelManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,8 +35,8 @@
 
 #include <map>
 
-#include "util/ScopedSingletonManager.h"
-#include "core/config/CommandLineParser.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/ClassTreeMask.h"
@@ -50,8 +50,10 @@
 {
     SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
 
-    ManageScopedSingleton(LevelManager, ScopeID::Root, false);
+    ManageScopedSingleton(LevelManager, ScopeID::ROOT, false);
 
+    RegisterAbstractClass(LevelManager).inheritsFrom<Configurable>();
+
     /**
     @brief
         Constructor. Registers the object, sets config values and initializes variables.
@@ -273,7 +275,7 @@
 
                 // Load the LevelInfo object from the level file.
                 XMLFile file = XMLFile(*it);
-                Loader::load(&file, mask, false, true);
+                Loader::getInstance().load(&file, mask, false, true);
 
                 // Find the LevelInfo object we've just loaded (if there was one)
                 for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item)
@@ -281,7 +283,7 @@
                         info = item->copy();
 
                 // We don't need the loaded stuff anymore
-                Loader::unload(&file);
+                Loader::getInstance().unload(&file);
 
                 if(info == NULL)
                 {

Modified: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/Main.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,7 +35,7 @@
 
 #include "Main.h"
 
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/Game.h"
 #include "core/LuaState.h"
 

Modified: code/trunk/src/orxonox/MoodManager.cc
===================================================================
--- code/trunk/src/orxonox/MoodManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/MoodManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -28,18 +28,21 @@
 
 #include "MoodManager.h"
 
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/Resource.h"
 
 namespace orxonox
 {
-    ManageScopedSingleton(MoodManager, ScopeID::Root, false);
+    ManageScopedSingleton(MoodManager, ScopeID::ROOT, false);
 
     // Note: I'm (Kevin Young) not entirely sure whether that's good code style:
     const std::string MoodManager::defaultMood_ = "default";
 
+    RegisterAbstractClass(MoodListener).inheritsFrom<OrxonoxInterface>();
+    RegisterAbstractClass(MoodManager).inheritsFrom<Configurable>();
+
     MoodManager::MoodManager()
     {
         RegisterObject(MoodManager);

Modified: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -72,7 +72,6 @@
     class LevelInfo;
     class LevelInfoItem;
     class LevelManager;
-    class PawnManager;
     class PlayerManager;
     class Radar;
     class Scene;

Deleted: code/trunk/src/orxonox/PawnManager.cc
===================================================================
--- code/trunk/src/orxonox/PawnManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/PawnManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,61 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "PawnManager.h"
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "worldentities/pawns/Pawn.h"
-
-namespace orxonox
-{
-    ManageScopedSingleton(PawnManager, ScopeID::Root, false);
-
-    PawnManager::PawnManager()
-    {
-        RegisterObject(PawnManager);
-    }
-
-    PawnManager::~PawnManager()
-    {
-        // Be sure to delete all the pawns
-        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); )
-            (it++)->destroy();
-    }
-
-    void PawnManager::preUpdate(const Clock& time)
-    {
-        for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); )
-        {
-            if (!it->isAlive())
-                (it++)->destroy();
-            else
-                ++it;
-        }
-    }
-}

Deleted: code/trunk/src/orxonox/PawnManager.h
===================================================================
--- code/trunk/src/orxonox/PawnManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/PawnManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,54 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _PawnManager_H__
-#define _PawnManager_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "util/Singleton.h"
-#include "tools/interfaces/Tickable.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport PawnManager : public Singleton<PawnManager>, public Tickable
-    {
-            friend class Singleton<PawnManager>;
-        public:
-            PawnManager();
-            virtual ~PawnManager();
-
-            virtual void preUpdate(const Clock& time);
-
-        private:
-
-            static PawnManager* singletonPtr_s;
-    };
-}
-
-#endif /* _PawnManager_H__ */

Modified: code/trunk/src/orxonox/PlayerManager.cc
===================================================================
--- code/trunk/src/orxonox/PlayerManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/PlayerManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -30,7 +30,7 @@
 
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 
 #include "Level.h"
 #include "LevelManager.h"
@@ -38,8 +38,10 @@
 
 namespace orxonox
 {
-    ManageScopedSingleton(PlayerManager, ScopeID::Root, false);
+    ManageScopedSingleton(PlayerManager, ScopeID::ROOT, false);
 
+    RegisterAbstractClass(PlayerManager).inheritsFrom<ClientConnectionListener>();
+
     PlayerManager::PlayerManager()
     {
         RegisterObject(PlayerManager);

Modified: code/trunk/src/orxonox/Radar.cc
===================================================================
--- code/trunk/src/orxonox/Radar.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/Radar.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,6 +36,7 @@
 #include <cassert>
 
 //#include "util/Math.h"
+#include "core/CoreIncludes.h"
 #include "core/object/ObjectList.h"
 #include "core/command/ConsoleCommand.h"
 #include "interfaces/RadarListener.h"
@@ -44,6 +45,7 @@
 
 namespace orxonox
 {
+    RegisterAbstractClass(Radar).inheritsFrom<Tickable>();
 
     Radar::Radar()
         : itFocus_(0)

Modified: code/trunk/src/orxonox/Scene.cc
===================================================================
--- code/trunk/src/orxonox/Scene.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/Scene.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -43,7 +43,7 @@
 #include "core/GameMode.h"
 #include "core/GUIManager.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "tools/BulletConversions.h"
 #include "tools/BulletDebugDrawer.h"
 #include "tools/DebugDrawer.h"
@@ -61,11 +61,13 @@
     {
         RegisterObject(Scene);
 
-        this->setScene(SmartPtr<Scene>(this, false), OBJECTID_UNKNOWN);
+        this->setScene(WeakPtr<Scene>(this), this->getObjectID()); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
+
         this->bShadows_ = true;
         this->bDebugDrawPhysics_ = false;
         this->debugDrawer_ = NULL;
         this->soundReferenceDistance_ = 20.0;
+        this->bIsUpdatingPhysics_ = false;
 
         if (GameMode::showsGraphics())
         {
@@ -140,7 +142,6 @@
         registerVariable(this->gravity_,            VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
         registerVariable(this->bHasPhysics_,        VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
         registerVariable(this->bShadows_,           VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
-        registerVariable(this->getLevel(),          VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::changedLevel));
     }
 
     void Scene::setNegativeWorldRange(const Vector3& range)
@@ -265,10 +266,12 @@
 
             // Note: 60 means that Bullet will do physics correctly down to 1 frames per seconds.
             //       Under that mark, the simulation will "loose time" and get unusable.
-            physicalWorld_->stepSimulation(dt, 60);
+            this->bIsUpdatingPhysics_ = true;
+            this->physicalWorld_->stepSimulation(dt, 60);
+            this->bIsUpdatingPhysics_ = false;
 
             if (this->bDebugDrawPhysics_)
-                physicalWorld_->debugDrawWorld();
+                this->physicalWorld_->debugDrawWorld();
         }
     }
 
@@ -312,7 +315,6 @@
     void Scene::addObject(BaseObject* object)
     {
         this->objects_.push_back(object);
-        object->setScene(this, this->getObjectID());
     }
 
     BaseObject* Scene::getObject(unsigned int index) const
@@ -362,8 +364,8 @@
                                              int index0, const btCollisionObject* colObj1, int partId1, int index1)
     {
         // get the WorldEntity pointers
-        SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
-        SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
+        StrongPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
+        StrongPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
 
         // get the CollisionShape pointers
         const btCollisionShape* cs0 = colObj0->getCollisionShape();

Modified: code/trunk/src/orxonox/Scene.h
===================================================================
--- code/trunk/src/orxonox/Scene.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/Scene.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -109,7 +109,7 @@
         /////////////
 
         public:
-            inline bool hasPhysics()
+            inline bool hasPhysics() const
                 { return this->physicalWorld_ != 0; }
             void setPhysicalWorld(bool wantsPhysics);
 
@@ -128,6 +128,9 @@
             void addPhysicalObject(WorldEntity* object);
             void removePhysicalObject(WorldEntity* object);
 
+            inline bool isUpdatingPhysics() const
+                { return this->bIsUpdatingPhysics_; }
+
             void setDebugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
 
             static void consoleCommand_debugDrawPhysics(bool bDraw, bool bFill, float fillAlpha);
@@ -162,6 +165,7 @@
 
             BulletDebugDrawer*                   debugDrawer_;
             bool                                 bDebugDrawPhysics_;
+            bool                                 bIsUpdatingPhysics_;
     };
 }
 

Deleted: code/trunk/src/orxonox/ShipPartManager.cc
===================================================================
--- code/trunk/src/orxonox/ShipPartManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/ShipPartManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,61 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#include "ShipPartManager.h"
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "items/ShipPart.h"
-
-namespace orxonox
-{
-    ManageScopedSingleton(ShipPartManager, ScopeID::Root, false);
-
-    ShipPartManager::ShipPartManager()
-    {
-        RegisterObject(ShipPartManager);
-    }
-
-    ShipPartManager::~ShipPartManager()
-    {
-        // Be sure to delete all the pawns
-        for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
-            (it++)->death();
-    }
-
-    void ShipPartManager::preUpdate(const Clock& time)
-    {
-        for (ObjectList<ShipPart>::iterator it = ObjectList<ShipPart>::begin(); it != ObjectList<ShipPart>::end(); )
-        {
-            if (!it->isAlive())
-                (it++)->death();
-            else
-                ++it;
-        }
-    }
-}

Deleted: code/trunk/src/orxonox/ShipPartManager.h
===================================================================
--- code/trunk/src/orxonox/ShipPartManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/ShipPartManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,54 +0,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _ShipPartManager_H__
-#define _ShipPartManager_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "util/Singleton.h"
-#include "tools/interfaces/Tickable.h"
-
-namespace orxonox
-{
-    class _OrxonoxExport ShipPartManager : public Singleton<ShipPartManager>, public Tickable
-    {
-            friend class Singleton<ShipPartManager>;
-        public:
-            ShipPartManager();
-            virtual ~ShipPartManager();
-
-            virtual void preUpdate(const Clock& time);
-
-        private:
-
-            static ShipPartManager* singletonPtr_s;
-    };
-}
-
-#endif /* _ShipPartManager_H__ */

Modified: code/trunk/src/orxonox/Test.cc
===================================================================
--- code/trunk/src/orxonox/Test.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/Test.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -28,8 +28,8 @@
 
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/command/ConsoleCommand.h"
-#include "network/NetworkFunction.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "Test.h"
 #include "util/MultiType.h"
 
@@ -104,13 +104,13 @@
 
   void Test::call(unsigned int clientID)
     {
-        callStaticNetworkFunction( &Test::printV1, clientID );
-        callStaticNetworkFunction( &Test::printV1, clientID );
+        callStaticNetworkFunction(&Test::printV1, clientID );
+        callStaticNetworkFunction(&Test::printV1, clientID );
     }
 
     void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
     {
-        callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
+        callMemberNetworkFunction( &Test::printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
     }
 
     void Test::tick(float dt)
@@ -129,7 +129,7 @@
     //     orxout() << mt2 << endl;
     //     if(!Core::isMaster())
     //       call2(0, "bal", "a", "n", "ce");
-    //       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
+    //       callMemberNetworkFunction( &Test::checkU1, this->getObjectID(), 0 );
     }
 
     void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)

Modified: code/trunk/src/orxonox/chat/ChatHistory.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/chat/ChatHistory.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -27,13 +27,17 @@
  */
 
 #include "ChatHistory.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/ConfigurablePaths.h"
 
 #ifndef CHATTEST
 namespace orxonox
 {
   /* singleton */
-  ManageScopedSingleton( ChatHistory, ScopeID::Root, false );
+  ManageScopedSingleton( ChatHistory, ScopeID::ROOT, false );
+
+  RegisterAbstractClass(ChatHistory).inheritsFrom<ChatListener>();
+
 #endif
 
   /* constructor */
@@ -117,7 +121,7 @@
      *       and set the this->hist_logfile_path variable to it
      */
 #ifndef CHATTEST
-    this->hist_logfile.open( (PathConfig::getInstance().getLogPathString() +
+    this->hist_logfile.open( (ConfigurablePaths::getLogPathString() +
       "chatlog.log").c_str(),
       std::fstream::out | std::fstream::app );
 #else

Modified: code/trunk/src/orxonox/chat/ChatHistory.h
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/chat/ChatHistory.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -40,7 +40,6 @@
 
 #include "util/Singleton.h"
 #include "core/BaseObject.h"
-#include "core/PathConfig.h"
 #include "chat/ChatListener.h"
 #include "infos/PlayerInfo.h"
 #include "PlayerManager.h"

Modified: code/trunk/src/orxonox/chat/ChatInputHandler.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatInputHandler.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -46,10 +46,10 @@
 #   include <elements/CEGUIListboxTextItem.h>
 #endif
 
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/input/InputBuffer.h"
 #include "core/input/InputManager.h"
 #include "core/input/InputState.h"
@@ -61,12 +61,14 @@
 namespace orxonox
 {
   /* singleton */
-  ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
+  ManageScopedSingleton( ChatInputHandler, ScopeID::GRAPHICS, false );
 
   /* add commands to console */
   SetConsoleCommand( "startchat", &ChatInputHandler::activate_static );
   SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static );
 
+  RegisterAbstractClass(ChatInputHandler).inheritsFrom<ChatListener>();
+
   /* constructor */
   ChatInputHandler::ChatInputHandler()
   {

Modified: code/trunk/src/orxonox/chat/ChatManager.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/chat/ChatManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -29,9 +29,9 @@
 #include "ChatManager.h"
 #include "ChatListener.h"
 
-#include "util/ScopedSingletonManager.h"
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "network/Host.h"
 
 #include "PlayerManager.h"
@@ -39,10 +39,12 @@
 
 namespace orxonox
 {
-    ManageScopedSingleton(ChatManager, ScopeID::Root, false);
+    ManageScopedSingleton(ChatManager, ScopeID::ROOT, false);
 
     SetConsoleCommand("chat", &ChatManager::chat).defaultValue(1, NETWORK_PEER_ID_BROADCAST);
 
+    RegisterAbstractClass(ChatManager).inheritsFrom<NetworkChatListener>();
+
     ChatManager::ChatManager()
     {
         RegisterObject(ChatManager);
@@ -112,7 +114,7 @@
     //////////////////////////////////////////////////////////////////////////
     // ChatListener                                                         //
     //////////////////////////////////////////////////////////////////////////
-    RegisterAbstractClass(ChatListener).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(ChatListener).inheritsFrom<Listable>();
 
     ChatListener::ChatListener()
     {

Modified: code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/collisionshapes/CollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -40,10 +40,11 @@
 #include "worldentities/WorldEntity.h"
 #include "CompoundCollisionShape.h"
 #include "WorldEntityCollisionShape.h"
+#include "Scene.h"
 
 namespace orxonox
 {
-    RegisterAbstractClass(CollisionShape).inheritsFrom(Class(BaseObject)).inheritsFrom(Class(Synchronisable));
+    RegisterAbstractClass(CollisionShape).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>();
 
     /**
     @brief
@@ -73,8 +74,17 @@
     CollisionShape::~CollisionShape()
     {
         // Detach from parent CompoundCollisionShape.
-        if (this->isInitialized() && this->parent_)
-            this->parent_->detach(this);
+        if (this->isInitialized())
+        {
+            if (this->getScene() && this->getScene()->isUpdatingPhysics())
+                orxout(internal_error) << "Don't destroy collision shapes while the physics is updated! This will lead to crashes. Try to use destroyLater() instead" << endl;
+
+            if (this->parent_)
+                this->parent_->detach(this);
+
+            if (this->collisionShape_)
+                delete this->collisionShape_;
+        }
     }
 
     void CollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)

Modified: code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -70,9 +70,13 @@
                 // make sure that the child doesn't want to detach itself --> speedup because of the missing update
                 it->first->notifyDetached();
                 it->first->destroy();
+                if (this->collisionShape_ == it->second)
+                    this->collisionShape_ = NULL; // don't destroy it twice
             }
 
             delete this->compoundShape_;
+            if (this->collisionShape_ == this->compoundShape_)
+                this->collisionShape_ = NULL; // don't destroy it twice
         }
     }
 

Modified: code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,6 +36,8 @@
 
 namespace orxonox
 {
+    RegisterClass(WorldEntityCollisionShape);
+
     WorldEntityCollisionShape::WorldEntityCollisionShape(Context* context) : CompoundCollisionShape(context)
     {
         RegisterObject(WorldEntityCollisionShape);
@@ -45,11 +47,6 @@
         this->setSyncMode(ObjectDirection::None);
     }
 
-    WorldEntityCollisionShape::~WorldEntityCollisionShape()
-    {
-        // Called always by WE destructor
-    }
-
     void WorldEntityCollisionShape::updateParent()
     {
         // Note: This shape may also be attached to a CompoundCollisionShape because it's hosting

Modified: code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h
===================================================================
--- code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,7 +38,6 @@
     {
         public:
             WorldEntityCollisionShape(Context* context);
-            virtual ~WorldEntityCollisionShape();
 
             inline void setWorldEntityOwner(WorldEntity* worldEntityOwner)
                 { this->worldEntityOwner_ = worldEntityOwner; }

Modified: code/trunk/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ArtificialController.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/controllers/ArtificialController.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -29,7 +29,7 @@
 #include "ArtificialController.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "worldentities/pawns/Pawn.h"
 #include "worldentities/pawns/SpaceShip.h"
 

Modified: code/trunk/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/FormationController.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/controllers/FormationController.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -32,7 +32,7 @@
 #include "core/CoreIncludes.h"
 
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "worldentities/ControllableEntity.h"
 #include "worldentities/pawns/Pawn.h"

Modified: code/trunk/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/controllers/HumanController.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -29,7 +29,7 @@
 #include "HumanController.h"
 
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "worldentities/ControllableEntity.h"
 #include "worldentities/pawns/Pawn.h"
 #include "gametypes/Gametype.h"
@@ -58,8 +58,6 @@
     SetConsoleCommand("HumanController", "mouseLook",              &HumanController::mouseLook     ).addShortcut();
     SetConsoleCommand("HumanController", __CC_suicide_name,        &HumanController::suicide       ).addShortcut();
     SetConsoleCommand("HumanController", "toggleGodMode",          &HumanController::toggleGodMode ).addShortcut();
-    SetConsoleCommand("HumanController", "addBots",                &HumanController::addBots       ).addShortcut().defaultValues(1);
-    SetConsoleCommand("HumanController", "killBots",               &HumanController::killBots      ).addShortcut().defaultValues(0);
     SetConsoleCommand("HumanController", "cycleNavigationFocus",   &HumanController::cycleNavigationFocus).addShortcut();
     SetConsoleCommand("HumanController", "releaseNavigationFocus", &HumanController::releaseNavigationFocus).addShortcut();
     SetConsoleCommand("HumanController", "myposition",             &HumanController::myposition    ).addShortcut();
@@ -317,18 +315,6 @@
         }
     }
 
-    void HumanController::addBots(unsigned int amount)
-    {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
-            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
-    }
-
-    void HumanController::killBots(unsigned int amount)
-    {
-        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
-            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
-    }
-
     Pawn* HumanController::getLocalControllerEntityAsPawn()
     {
         if (HumanController::localController_s)

Modified: code/trunk/src/orxonox/controllers/HumanController.h
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/controllers/HumanController.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -82,9 +82,6 @@
             static void toggleFormationFlight();
             static void FFChangeMode();
 
-            static void addBots(unsigned int amount);
-            static void killBots(unsigned int amount = 0);
-
             static void pauseControl(); // tolua_export
             static void resumeControl(); // tolua_export
             virtual void doPauseControl() {};

Modified: code/trunk/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/NewHumanController.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/controllers/NewHumanController.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 #include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
 
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/input/KeyBinder.h"
 #include "core/input/KeyBinderManager.h"
 #include "worldentities/ControllableEntity.h"

Modified: code/trunk/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gamestates/GSClient.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -29,7 +29,7 @@
 #include "GSClient.h"
 
 #include "util/Exception.h"
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
 #include "network/Client.h"

Modified: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -43,9 +43,10 @@
 #include "core/GUIManager.h"
 #include "core/Loader.h"
 #include "core/XMLFile.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "LevelManager.h"
+#include "Level.h"
 #include "PlayerManager.h"
 #include "GSRoot.h"
 
@@ -94,6 +95,8 @@
             guiKeysOnlyInputState_->setKeyHandler(&GUIManager::getInstance());
         }
 
+        this->prepareObjectTracking();
+
         if (GameMode::isMaster())
         {
             this->loadLevel();
@@ -127,7 +130,11 @@
 
         if (GameMode::isMaster())
             this->unloadLevel();
+        else
+            this->unloadLevelAsClient();
 
+        this->performObjectTracking();
+
         if (GameMode::showsGraphics())
         {
 #if OGRE_VERSION < 0x010700
@@ -160,25 +167,14 @@
         //    it->tick(time.getDeltaTime() * this->timeFactor_);
     }
 
-    void GSLevel::loadLevel()
+    void GSLevel::prepareObjectTracking()
     {
         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
             this->staticObjects_.insert(*it);
-
-        // call the loader
-        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
-        bool loaded = Loader::open(startFile_);
-
-        Core::getInstance().updateLastLevelTimestamp();
-        if(!loaded)
-            GSRoot::delayedStartMainMenu();
     }
 
-    void GSLevel::unloadLevel()
+    void GSLevel::performObjectTracking()
     {
-        Loader::unload(startFile_);
-        delete startFile_;
-
         orxout(internal_info) << "Remaining objects:" << endl;
         unsigned int i = 0;
         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
@@ -186,7 +182,7 @@
             std::set<BaseObject*>::const_iterator find = this->staticObjects_.find(*it);
             if (find == this->staticObjects_.end())
             {
-                orxout(internal_info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
+                orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
             }
         }
         if (i == 0)
@@ -195,6 +191,45 @@
             orxout(internal_warning) << i << " objects remaining. Try harder!" << endl;
     }
 
+    void GSLevel::loadLevel()
+    {
+        // call the loader
+        startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
+        bool loaded = Loader::getInstance().load(startFile_);
+
+        Core::getInstance().getConfig()->updateLastLevelTimestamp();
+        if(!loaded)
+            GSRoot::delayedStartMainMenu();
+    }
+
+    void GSLevel::unloadLevel()
+    {
+        Loader::getInstance().unload(startFile_);
+        delete startFile_;
+    }
+
+    /**
+     * Unloads a level when the game instance is (or was) a client in a multiplayer session.
+     * In this case, cleanup after unloading a level is done differently because certain things (e.g. the xml file) are unknown.
+     */
+    void GSLevel::unloadLevelAsClient()
+    {
+        for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); )
+        {
+            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;
+        }
+    }
+
     void GSLevel::reloadLevel()
     {
         // export all states
@@ -251,7 +286,7 @@
 
     ///////////////////////////////////////////////////////////////////////////
 
-    RegisterAbstractClass(GSLevelMemento).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(GSLevelMemento).inheritsFrom<OrxonoxInterface>();
 
     GSLevelMemento::GSLevelMemento()
     {

Modified: code/trunk/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gamestates/GSLevel.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -52,10 +52,14 @@
 
         void reloadLevel();
 
-    protected:
+    private:
         void loadLevel();
         void unloadLevel();
+        void unloadLevelAsClient();
 
+        void prepareObjectTracking();
+        void performObjectTracking();
+
         InputState*              gameInputState_;          //!< input state for normal ingame playing
         InputState*              guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
         InputState*              guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI

Modified: code/trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,7 +35,7 @@
 #include "core/Game.h"
 #include "core/GraphicsManager.h"
 #include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/input/KeyBinderManager.h"
 #include "network/Client.h"
 #include "util/StringUtils.h"
@@ -62,6 +62,8 @@
     SetConsoleCommand(__CC_startDedicated_name,       &GSMainMenu::startDedicated ).defaultValues("").deactivate();
     SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide();
 
+    RegisterAbstractClass(GSMainMenu).inheritsFrom<Configurable>();
+
     GSMainMenu::GSMainMenu(const GameStateInfo& info)
         : GameState(info)
     {

Modified: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -32,8 +32,8 @@
 #include "core/BaseObject.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
-#include "core/command/ConsoleCommand.h"
-#include "network/NetworkFunction.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "tools/Timer.h"
 #include "tools/interfaces/Tickable.h"
 
@@ -67,7 +67,6 @@
 
     GSRoot::~GSRoot()
     {
-        NetworkFunctionBase::destroyAllNetworkFunctions();
     }
 
     void GSRoot::printObjects()

Modified: code/trunk/src/orxonox/gamestates/GSServer.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSServer.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gamestates/GSServer.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -29,7 +29,7 @@
 #include "GSServer.h"
 
 #include "util/Output.h"
-#include "core/config/CommandLineParser.h"
+#include "core/commandline/CommandLineIncludes.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
 #include "network/Server.h"

Modified: code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Dynamicmatch.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gametypes/Dynamicmatch.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -309,12 +309,9 @@
         // Give victim boost
         if (spaceship)
         {
-            WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
-            if(ptr == NULL)
-                return;
             spaceship->addSpeedFactor(5);
             ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
-            executor->setDefaultValue(0, ptr);
+            executor->setDefaultValue(0, spaceship);
             new Timer(10, false, executor, true);
         }
     }
@@ -592,13 +589,12 @@
         return this->playerParty_[player];
     }
 
-    void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function
+    void Dynamicmatch::resetSpeedFactor(SpaceShip* spaceship)// helper function
     {
-        if (*ptr)
+        if (spaceship)
         {
-            (*ptr)->addSpeedFactor(1.0f/5.0f);
+            spaceship->addSpeedFactor(1.0f/5.0f);
         }
-        delete ptr;
     }
 
     bool Dynamicmatch::playerChangedName(PlayerInfo* player) //standardfunction

Modified: code/trunk/src/orxonox/gametypes/Dynamicmatch.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Dynamicmatch.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gametypes/Dynamicmatch.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -76,7 +76,7 @@
             virtual void furtherInstructions();*/
             virtual void rewardPig();
             void grantPigBoost(SpaceShip* spaceship); // Grant the piggy a boost.
-            void resetSpeedFactor(WeakPtr<SpaceShip>* ptr);
+            void resetSpeedFactor(SpaceShip* spaceship);
             void tick (float dt);// used to end the game
             SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
 

Modified: code/trunk/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gametypes/Gametype.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -33,7 +33,7 @@
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GameMode.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "gamestates/GSLevel.h"
 
 #include "infos/PlayerInfo.h"
@@ -48,17 +48,24 @@
 
 namespace orxonox
 {
+    static const std::string __CC_addBots_name  = "addBots";
+    static const std::string __CC_killBots_name = "killBots";
+
+    SetConsoleCommand("Gametype", __CC_addBots_name,  &Gametype::addBots ).addShortcut().defaultValues(1);
+    SetConsoleCommand("Gametype", __CC_killBots_name, &Gametype::killBots).addShortcut().defaultValues(0);
+
     RegisterUnloadableClass(Gametype);
 
     Gametype::Gametype(Context* context) : BaseObject(context)
     {
         RegisterObject(Gametype);
 
+        this->setGametype(WeakPtr<Gametype>(this)); // store a weak-pointer to itself (a strong-pointer would create a recursive dependency)
+
         this->gtinfo_ = new GametypeInfo(context);
 
-        this->setGametype(SmartPtr<Gametype>(this, false));
-
         this->defaultControllableEntity_ = Class(Spectator);
+        this->scoreboard_ = 0;
 
         this->bAutoStart_ = false;
         this->bForceSpawn_ = false;
@@ -73,34 +80,36 @@
 
         this->setConfigValues();
 
-        // load the corresponding score board
-        if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty())
-        {
-            this->scoreboard_ = new OverlayGroup(context);
-            this->scoreboard_->addTemplate(this->scoreboardTemplate_);
-            this->scoreboard_->setGametype(this);
-        }
-        else
-            this->scoreboard_ = 0;
-
-        /* HACK HACK HACK */
-        this->dedicatedAddBots_ = createConsoleCommand( "dedicatedAddBots", createExecutor( createFunctor(&Gametype::addBots, this) ) );
-        this->dedicatedKillBots_ = createConsoleCommand( "dedicatedKillBots", createExecutor( createFunctor(&Gametype::killBots, this) ) );
-        /* HACK HACK HACK */
+        ModifyConsoleCommand(__CC_addBots_name).setObject(this);
+        ModifyConsoleCommand(__CC_killBots_name).setObject(this);
     }
 
     Gametype::~Gametype()
     {
         if (this->isInitialized())
         {
-            this->gtinfo_->destroy();
-            if( this->dedicatedAddBots_ )
-                delete this->dedicatedAddBots_;
-            if( this->dedicatedKillBots_ )
-                delete this->dedicatedKillBots_;
+            if (this->gtinfo_)
+                this->gtinfo_->destroy();
+
+            ModifyConsoleCommand(__CC_addBots_name).setObject(NULL);
+            ModifyConsoleCommand(__CC_killBots_name).setObject(NULL);
         }
     }
 
+    /**
+     * @brief Initializes sub-objects of the Gametype. This must be called after the constructor.
+     * At this point, the context is expected to have the current gametype. This allows to pass the current gametype to the sub-objects via constructor.
+     */
+    void Gametype::init()
+    {
+        // load the corresponding score board
+        if (GameMode::showsGraphics() && !this->scoreboardTemplate_.empty())
+        {
+            this->scoreboard_ = new OverlayGroup(this->getContext());
+            this->scoreboard_->addTemplate(this->scoreboardTemplate_);
+        }
+    }
+
     void Gametype::setConfigValues()
     {
         SetConfigValue(initialStartCountdown_, 3.0f);
@@ -405,7 +414,7 @@
                     if (allplayersready && hashumanplayers)
                     {
                         // If in developer's mode, there is no start countdown.
-                        if(Core::getInstance().inDevMode())
+                        if(Core::getInstance().getConfig()->inDevMode())
                             this->start();
                         else
                         {

Modified: code/trunk/src/orxonox/gametypes/Gametype.h
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gametypes/Gametype.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -71,6 +71,8 @@
             Gametype(Context* context);
             virtual ~Gametype();
 
+            virtual void init();
+
             void setConfigValues();
 
             virtual void tick(float dt);
@@ -175,7 +177,7 @@
             virtual GSLevelMementoState* exportMementoState();
             virtual void importMementoState(const std::vector<GSLevelMementoState*>& states);
 
-            SmartPtr<GametypeInfo> gtinfo_;
+            WeakPtr<GametypeInfo> gtinfo_;
 
             bool bAutoStart_;
             bool bForceSpawn_;
@@ -198,10 +200,6 @@
             // Config Values
             std::string scoreboardTemplate_;
 
-            /* HACK HACK HACK */
-            ConsoleCommand* dedicatedAddBots_;
-            ConsoleCommand* dedicatedKillBots_;
-            /* HACK HACK HACK */
             Timer showMenuTimer_;
     };
 

Modified: code/trunk/src/orxonox/gametypes/Mission.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Mission.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/gametypes/Mission.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -32,7 +32,7 @@
 #include "controllers/ArtificialController.h"
 
 #include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "infos/PlayerInfo.h"
 #include "network/Host.h"
 #include "worldentities/pawns/Pawn.h"

Modified: code/trunk/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/trunk/src/orxonox/infos/GametypeInfo.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/infos/GametypeInfo.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "util/Convert.h"
 
 #include "controllers/HumanController.h"
@@ -368,7 +368,7 @@
             if(player->getClientID() == CLIENTID_SERVER)
                 this->changedReadyToSpawn(ready);
             else
-                callMemberNetworkFunction(GametypeInfo, changedReadyToSpawn, this->getObjectID(), player->getClientID(), ready);
+                callMemberNetworkFunction(&GametypeInfo::changedReadyToSpawn, this->getObjectID(), player->getClientID(), ready);
         }
     }
 
@@ -387,7 +387,7 @@
             if(player->getClientID() == CLIENTID_SERVER)
                     this->changedSpawned(spawned);
             else
-                callMemberNetworkFunction(GametypeInfo, changedSpawned, this->getObjectID(), player->getClientID(), spawned);
+                callMemberNetworkFunction(&GametypeInfo::changedSpawned, this->getObjectID(), player->getClientID(), spawned);
         }
     }
 
@@ -398,7 +398,7 @@
     {
         if (GameMode::isMaster())
         {
-            callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), NETWORK_PEER_ID_BROADCAST, message);
+            callMemberNetworkFunction(&GametypeInfo::dispatchAnnounceMessage, this->getObjectID(), NETWORK_PEER_ID_BROADCAST, message);
             this->dispatchAnnounceMessage(message);
         }
     }
@@ -410,7 +410,7 @@
             if (clientID == CLIENTID_SERVER)
                 this->dispatchAnnounceMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchAnnounceMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchAnnounceMessage, this->getObjectID(), clientID, message);
         }
     }
 
@@ -421,7 +421,7 @@
             if (clientID == CLIENTID_SERVER)
                 this->dispatchKillMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchKillMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchKillMessage, this->getObjectID(), clientID, message);
         }
     }
 
@@ -432,7 +432,7 @@
             if (clientID == CLIENTID_SERVER)
                 this->dispatchDeathMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchDeathMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchDeathMessage, this->getObjectID(), clientID, message);
         }
     }
 
@@ -443,7 +443,7 @@
             if (clientID == CLIENTID_SERVER)
                 this->dispatchStaticMessage(message, colour);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchStaticMessage, this->getObjectID(), clientID, message, colour);
+                callMemberNetworkFunction(&GametypeInfo::dispatchStaticMessage, this->getObjectID(), clientID, message, colour);
         }
     }
 
@@ -454,7 +454,7 @@
             if (clientID == CLIENTID_SERVER)
                 this->dispatchFadingMessage(message);
             else
-                callMemberNetworkFunction(GametypeInfo, dispatchFadingMessage, this->getObjectID(), clientID, message);
+                callMemberNetworkFunction(&GametypeInfo::dispatchFadingMessage, this->getObjectID(), clientID, message);
         }
     }
 

Modified: code/trunk/src/orxonox/infos/HumanPlayer.cc
===================================================================
--- code/trunk/src/orxonox/infos/HumanPlayer.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/infos/HumanPlayer.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -159,9 +159,9 @@
         this->networkcallback_clientIDchanged();
     }
 
-    void HumanPlayer::changedGametype()
+    void HumanPlayer::switchGametype(Gametype* gametype)
     {
-        PlayerInfo::changedGametype();
+        PlayerInfo::switchGametype(gametype);
 
         if (this->isInitialized() && this->isLocalPlayer())
         {

Modified: code/trunk/src/orxonox/infos/HumanPlayer.h
===================================================================
--- code/trunk/src/orxonox/infos/HumanPlayer.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/infos/HumanPlayer.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -50,7 +50,7 @@
 
             void setClientID(unsigned int clientID);
 
-            virtual void changedGametype();
+            virtual void switchGametype(Gametype* gametype);
 
             inline void setHumanHUDTemplate(const std::string& name)
             {

Modified: code/trunk/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/trunk/src/orxonox/infos/PlayerInfo.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/infos/PlayerInfo.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,7 +39,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(PlayerInfo).inheritsFrom(Class(Info));
+    RegisterAbstractClass(PlayerInfo).inheritsFrom<Info>();
 
     PlayerInfo::PlayerInfo(Context* context) : Info(context)
     {
@@ -56,7 +56,7 @@
 
         this->gtinfo_ = 0;
         this->gtinfoID_ = OBJECTID_UNKNOWN;
-        this->updateGametypeInfo();
+        this->updateGametypeInfo(this->getGametype());
 
         this->registerVariables();
 
@@ -94,38 +94,43 @@
             this->getGametype()->playerChangedName(this);
     }
 
-    void PlayerInfo::changedGametype()
+    void PlayerInfo::switchGametype(Gametype* gametype)
     {
-        this->updateGametypeInfo();
+        Gametype* oldGametype = this->getGametype();
+        this->setGametype(StrongPtr<Gametype>(gametype));
+        Gametype* newGametype = this->getGametype();
 
+
+        this->updateGametypeInfo(newGametype);
+
         if (this->isInitialized())
         {
-            if (this->getOldGametype())
+            if (oldGametype)
             {
-                if (this->getGametype())
-                    this->getOldGametype()->playerSwitched(this, this->getGametype());
+                if (newGametype)
+                    oldGametype->playerSwitched(this, newGametype);
                 else
-                    this->getOldGametype()->playerLeft(this);
+                    oldGametype->playerLeft(this);
             }
 
-            if (this->getGametype())
+            if (newGametype)
             {
-                if (this->getOldGametype())
-                    this->getGametype()->playerSwitchedBack(this, this->getOldGametype());
+                if (oldGametype)
+                    newGametype->playerSwitchedBack(this, oldGametype);
                 else
-                    this->getGametype()->playerEntered(this);
+                    newGametype->playerEntered(this);
             }
         }
     }
 
-    void PlayerInfo::updateGametypeInfo()
+    void PlayerInfo::updateGametypeInfo(Gametype* gametype)
     {
         this->gtinfo_ = 0;
         this->gtinfoID_ = OBJECTID_UNKNOWN;
 
-        if (this->getGametype() && this->getGametype()->getGametypeInfo())
+        if (gametype && gametype->getGametypeInfo())
         {
-            this->gtinfo_ = this->getGametype()->getGametypeInfo();
+            this->gtinfo_ = gametype->getGametypeInfo();
             this->gtinfoID_ = this->gtinfo_->getObjectID();
         }
     }
@@ -185,7 +190,7 @@
             return;
 
         this->controllableEntity_->destroyHud(); // HACK-ish
-        this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_));
+        this->previousControllableEntity_.push_back(this->controllableEntity_);
         this->controllableEntity_ = entity;
         this->controllableEntityID_ = entity->getObjectID();
 

Modified: code/trunk/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/trunk/src/orxonox/infos/PlayerInfo.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/infos/PlayerInfo.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,7 +44,7 @@
             virtual ~PlayerInfo();
 
             virtual void changedName();
-            virtual void changedGametype();
+            virtual void switchGametype(Gametype* gametype);
 
             virtual void changedController() {}
             virtual void changedControllableEntity() {}
@@ -93,7 +93,7 @@
             void registerVariables();
             void networkcallback_changedcontrollableentityID();
             void networkcallback_changedgtinfoID();
-            void updateGametypeInfo();
+            void updateGametypeInfo(Gametype* gametype);
 
             bool bReadyToSpawn_;
             Controller* controller_;

Modified: code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -49,7 +49,7 @@
     //----------------------------
     // GametypeMessageListener
     //----------------------------
-    RegisterAbstractClass(GametypeMessageListener).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(GametypeMessageListener).inheritsFrom<OrxonoxInterface>();
 
     GametypeMessageListener::GametypeMessageListener()
     {
@@ -59,7 +59,7 @@
     //----------------------------
     // PlayerTrigger
     //----------------------------
-    RegisterAbstractClass(PlayerTrigger).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(PlayerTrigger).inheritsFrom<OrxonoxInterface>();
 
     PlayerTrigger::PlayerTrigger()
     {
@@ -71,15 +71,15 @@
     void PlayerTrigger::setTriggeringPawn(Pawn* pawn)
     {
         assert(pawn);
-        this->pawn_ = WeakPtr<Pawn>(pawn);
+        this->pawn_ = pawn;
         if (pawn)
-            this->player_ = WeakPtr<PlayerInfo>(pawn->getPlayer());
+            this->player_ = pawn->getPlayer();
     }
 
     //----------------------------
     // RadarListener
     //----------------------------
-    RegisterAbstractClass(RadarListener).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(RadarListener).inheritsFrom<OrxonoxInterface>();
 
     RadarListener::RadarListener()
     {
@@ -89,7 +89,7 @@
     //----------------------------
     // TeamColourable
     //----------------------------
-    RegisterAbstractClass(TeamColourable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(TeamColourable).inheritsFrom<OrxonoxInterface>();
 
     TeamColourable::TeamColourable()
     {
@@ -99,7 +99,7 @@
     //----------------------------
     // Rewardable
     //----------------------------
-    RegisterAbstractClass(Rewardable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(Rewardable).inheritsFrom<OrxonoxInterface>();
 
     Rewardable::Rewardable()
     {

Modified: code/trunk/src/orxonox/interfaces/NotificationListener.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/NotificationListener.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/NotificationListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -33,7 +33,7 @@
 
 #include "core/CoreIncludes.h"
 #include "network/Host.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 #include "util/SubString.h"
 
 #include "interfaces/NotificationListener.h"
@@ -50,6 +50,8 @@
     
     registerStaticNetworkFunction(NotificationListener::sendHelper);
     
+    RegisterAbstractClass(NotificationListener).inheritsFrom<OrxonoxInterface>();
+
     NotificationListener::NotificationListener()
     {
         RegisterObject(NotificationListener);
@@ -81,12 +83,12 @@
         // If we're on the server (and the server is not the intended recipient of the notification/command) we send it over the network.
         else if(GameMode::isServer() && sendMode == notificationSendMode::network && Host::getPlayerID() != clientId)
         {
-            callStaticNetworkFunction(NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);
+            callStaticNetworkFunction(&NotificationListener::sendHelper, clientId, message, sender, isCommand, (unsigned int)messageType);
         }
         else if(GameMode::isServer() && sendMode == notificationSendMode::broadcast)
         {
             // TODO: Works as intended?
-            callStaticNetworkFunction(NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);
+            callStaticNetworkFunction(&NotificationListener::sendHelper, NETWORK_PEER_ID_BROADCAST, message, sender, isCommand, (unsigned int)messageType);
         }
     }
 

Modified: code/trunk/src/orxonox/interfaces/PickupCarrier.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupCarrier.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/PickupCarrier.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -40,7 +40,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(PickupCarrier).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(PickupCarrier).inheritsFrom<OrxonoxInterface>();
 
     /**
     @brief

Modified: code/trunk/src/orxonox/interfaces/PickupListener.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupListener.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/PickupListener.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,6 +39,7 @@
 
 namespace orxonox
 {
+    RegisterAbstractClass(PickupListener).inheritsFrom<OrxonoxInterface>();
 
     /**
     @brief

Modified: code/trunk/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/Pickupable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -45,7 +45,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(Pickupable).inheritsFrom(Class(OrxonoxInterface)).inheritsFrom(Class(Rewardable));
+    RegisterAbstractClass(Pickupable).inheritsFrom<OrxonoxInterface>().inheritsFrom<Rewardable>();
 
     /**
     @brief

Modified: code/trunk/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/Pickupable.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -186,9 +186,9 @@
     };
 
     //! SUPER functions.
-    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
-    SUPER_FUNCTION(11, Pickupable, changedCarrier, false);
-    SUPER_FUNCTION(12, Pickupable, changedPickedUp, false);
+    SUPER_FUNCTION(9, Pickupable, changedUsed, false);
+    SUPER_FUNCTION(10, Pickupable, changedCarrier, false);
+    SUPER_FUNCTION(11, Pickupable, changedPickedUp, false);
 }
 
 #endif /* _Pickupable_H__ */

Modified: code/trunk/src/orxonox/interfaces/PlayerTrigger.h
===================================================================
--- code/trunk/src/orxonox/interfaces/PlayerTrigger.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/PlayerTrigger.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -62,7 +62,7 @@
         @return Returns a pointer to the Pawn that triggered the PlayerTrigger.
         */
         inline Pawn* getTriggeringPawn(void) const
-            { return this->pawn_.get(); }
+            { return this->pawn_; }
 
         /**
         @brief Returns the player that triggered the PlayerTrigger.

Modified: code/trunk/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,7 +37,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(RadarViewable).inheritsFrom(Class(OrxonoxInterface));
+    RegisterAbstractClass(RadarViewable).inheritsFrom<OrxonoxInterface>();
 
     /**
         @brief Constructor.

Modified: code/trunk/src/orxonox/interfaces/RadarViewable.h
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 
 #include "util/Math.h"
 #include "core/class/OrxonoxInterface.h"
-#include "core/object/SmartPtr.h"
+#include "core/object/StrongPtr.h"
 
 namespace orxonox
 {
@@ -162,7 +162,7 @@
 
         //Radar
         const WorldEntity* wePtr_;
-        SmartPtr<Radar> radar_;
+        StrongPtr<Radar> radar_;
         float radarObjectCamouflage_;
         Shape radarObjectShape_;
         std::string radarObjectDescription_;

Modified: code/trunk/src/orxonox/items/ShipPart.cc
===================================================================
--- code/trunk/src/orxonox/items/ShipPart.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/items/ShipPart.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -49,17 +49,20 @@
     RegisterClass(ShipPart);
 
     ShipPart::ShipPart(Context* context)
-        : Item(context)
+        : Item(context), parent_(NULL)
     {
         RegisterObject(ShipPart);
-        this->setAlive(true);
-        this->setEventExecution(true);
+        this->eventExecution_ = true;
         this->healthMem_ = 100;
     }
 
     ShipPart::~ShipPart()
     {
-
+        if (this->parent_)
+        {
+            // Remove this ShipPart from the parent.
+            this->parent_->removeShipPart(this);
+        }
     }
 
     void ShipPart::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -85,11 +88,7 @@
     */
     void ShipPart::death()
     {
-        //if (!(this->isAlive()))
-            //return;
-
         this->explode();
-        this->setAlive(false);
 
         if(eventExecution_)
         {
@@ -100,9 +99,7 @@
             }
         }
 
-        // Remove this ShipPart from the parent.
-        this->parent_->removeShipPart(this);
-        delete this;
+        this->destroyLater();
     }
 
     void ShipPart::explode()
@@ -204,12 +201,6 @@
         this->health_ = health;
     }
 
-    void ShipPart::setAlive(bool var)
-    {
-        this->alive_ = var;
-        orxout() << "ShipPart " << this->getName() << " alive_: " << this->alive_ << endl;
-    }
-
     /**
     @brief
         Handles a received hit.
@@ -239,8 +230,7 @@
             }
         }
         if (this->health_ < 0)
-            this->alive_ = false;
-            //this->death();
+            this->death();
 
         // (Ugly) Chatoutput of health, until a GUI for modularspaceships-shipparts is implemented.
         if ((this->health_ < 0.2 * this->maxHealth_) && (this->healthMem_ == 40))

Modified: code/trunk/src/orxonox/items/ShipPart.h
===================================================================
--- code/trunk/src/orxonox/items/ShipPart.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/items/ShipPart.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -71,10 +71,6 @@
             inline ModularSpaceShip* getParent()
                 { return this->parent_; }
 
-            void setAlive(bool var);
-            inline bool isAlive()
-                { return this->alive_; }
-
             inline void setEventExecution(bool var)
                 { this->eventExecution_ = var; }
             inline bool isEventExecution()
@@ -120,7 +116,6 @@
             std::vector<StaticEntity*> entityList_;         // List of all entities which belong to this part
             std::vector<PartDestructionEvent*> eventList_;  // The list of all PartDestructionEvent assigned to this ShipPart.
 
-            bool alive_;
             bool eventExecution_;
 
             float healthMem_;

Modified: code/trunk/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/overlays/InGameConsole.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,12 +44,12 @@
 #include "util/Convert.h"
 #include "util/Math.h"
 #include "util/DisplayStringConversions.h"
-#include "util/ScopedSingletonManager.h"
 #include "util/output/MemoryWriter.h"
 #include "util/output/OutputManager.h"
 #include "core/CoreIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/GUIManager.h"
 #include "core/input/InputManager.h"
 #include "core/input/InputState.h"
@@ -64,8 +64,10 @@
     SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
     SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole);
 
-    ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false);
+    ManageScopedSingleton(InGameConsole, ScopeID::GRAPHICS, false);
 
+    RegisterAbstractClass(InGameConsole).inheritsFrom<WindowEventListener>().inheritsFrom<UpdateListener>();
+
     /**
         @brief Constructor: Creates and initializes the InGameConsole.
     */

Modified: code/trunk/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/overlays/InGameConsole.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -38,10 +38,11 @@
 #include "util/Singleton.h"
 #include "core/WindowEventListener.h"
 #include "core/command/Shell.h"
+#include "core/UpdateListener.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener
+    class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener, public UpdateListener
     {
         friend class Singleton<InGameConsole>;
     public: // functions
@@ -52,6 +53,7 @@
         void setConfigValues();
 
         void preUpdate(const Clock& time);
+        void postUpdate(const Clock& time) { /*no action*/ }
 
         static void openConsole();
         static void closeConsole();

Modified: code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -47,7 +47,7 @@
 #include "core/GameMode.h"
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "OverlayGroup.h"
 

Modified: code/trunk/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OverlayGroup.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/overlays/OverlayGroup.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,8 +35,9 @@
 
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "OrxonoxOverlay.h"
+#include "gametypes/Gametype.h"
 
 namespace orxonox
 {
@@ -60,7 +61,7 @@
 
     OverlayGroup::~OverlayGroup()
     {
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->destroy();
         this->hudElements_.clear();
     }
@@ -84,7 +85,7 @@
     //! Scales every element in the set.
     void OverlayGroup::setScale(const Vector2& scale)
     {
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scale(scale / this->scale_);
         this->scale_ = scale;
     }
@@ -92,7 +93,7 @@
     //! Scrolls every element in the set.
     void OverlayGroup::setScroll(const Vector2& scroll)
     {
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->scroll(scroll - this->scroll_);
         this->scroll_ = scroll;
     }
@@ -105,7 +106,7 @@
     */
     void OverlayGroup::addElement(OrxonoxOverlay* element)
     {
-        hudElements_.insert(SmartPtr<OrxonoxOverlay>(element));
+        hudElements_.insert(element);
         element->setOverlayGroup( this );
         if (this->owner_)
             element->setOwner(this->owner_);
@@ -121,7 +122,7 @@
     */
     bool OverlayGroup::removeElement(OrxonoxOverlay* element)
     {
-        if(this->hudElements_.erase(SmartPtr<OrxonoxOverlay>(element)) == 0)
+        if(this->hudElements_.erase(element) == 0)
             return false;
         return true;
     }
@@ -131,10 +132,10 @@
     {
         if (index < this->hudElements_.size())
         {
-            std::set< SmartPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();
+            std::set< StrongPtr<OrxonoxOverlay> >::const_iterator it = hudElements_.begin();
             for (unsigned int i = 0; i != index; ++it, ++i)
                 ;
-            return it->get();
+            return *it;
         }
         else
             return 0;
@@ -145,24 +146,15 @@
     {
         SUPER( OverlayGroup, changedVisibility );
 
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->changedVisibility(); //inform all Child Overlays that our visibility has changed
     }
 
-    //! Changes the gametype of all elements
-    void OverlayGroup::changedGametype()
-    {
-        SUPER( OverlayGroup, changedGametype );
-
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
-            (*it)->setGametype(this->getGametype());
-    }
-
     void OverlayGroup::setOwner(BaseObject* owner)
     {
         this->owner_ = owner;
 
-        for (std::set< SmartPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+        for (std::set< StrongPtr<OrxonoxOverlay> >::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
             (*it)->setOwner(owner);
     }
 

Modified: code/trunk/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- code/trunk/src/orxonox/overlays/OverlayGroup.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/overlays/OverlayGroup.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -64,11 +64,10 @@
         static void scaleGroup(const std::string& name, float scale);
         static void scrollGroup(const std::string& name, const Vector2& scroll);
 
-        inline const std::set< SmartPtr<OrxonoxOverlay> >& getOverlays() const
+        inline const std::set< StrongPtr<OrxonoxOverlay> >& getOverlays() const
             { return this->hudElements_; }
 
         virtual void changedVisibility();
-        virtual void changedGametype();
 
         void setOwner(BaseObject* owner);
         inline BaseObject* getOwner() const
@@ -91,7 +90,7 @@
         OrxonoxOverlay* getElement(unsigned int index);
 
     private:
-        std::set< SmartPtr<OrxonoxOverlay> > hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
+        std::set< StrongPtr<OrxonoxOverlay> > hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
         Vector2 scale_;                            //!< Current scale (independent of the elements).
         Vector2 scroll_;                           //!< Current scrolling offset.
         BaseObject* owner_;                        //!< The owner of this OverlayGroup

Modified: code/trunk/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/AmbientSound.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/sound/AmbientSound.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,6 +35,8 @@
 
 namespace orxonox
 {
+    RegisterAbstractClass(AmbientSound).inheritsFrom<BaseSound>().inheritsFrom<MoodListener>();
+
     AmbientSound::AmbientSound()
         : bPlayOnLoad_(false)
     {
@@ -48,7 +50,7 @@
     {
         if (GameMode::playsSound())
         {
-            // Smoothly fade out by keeping a SmartPtr
+            // Smoothly fade out by keeping a StrongPtr
             SoundManager::getInstance().unregisterAmbientSound(this);
         }
     }

Modified: code/trunk/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/BaseSound.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/sound/BaseSound.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -42,7 +42,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(BaseSound).inheritsFrom(Class(Listable));
+    RegisterAbstractClass(BaseSound).inheritsFrom<Listable>();
 
     BaseSound::BaseSound()
         : bPooling_(false)

Modified: code/trunk/src/orxonox/sound/SoundBuffer.h
===================================================================
--- code/trunk/src/orxonox/sound/SoundBuffer.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/sound/SoundBuffer.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -45,7 +45,7 @@
     {
         friend class SoundManager;
 #if !defined(_MSC_VER) || _MSC_VER >= 1500
-        // Make sure nobody deletes an instance (using smart pointers)
+        // Make sure nobody deletes an instance (using strong pointers)
         template <class T>
         friend void boost::checked_delete(T*);
 #endif

Modified: code/trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/sound/SoundManager.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -37,7 +37,7 @@
 #include "util/Exception.h"
 #include "util/Math.h"
 #include "util/Clock.h"
-#include "util/ScopedSingletonManager.h"
+#include "core/singleton/ScopedSingletonIncludes.h"
 #include "core/config/ConfigValueIncludes.h"
 #include "core/CoreIncludes.h"
 #include "core/GameMode.h"
@@ -49,7 +49,7 @@
 
 namespace orxonox
 {
-    ManageScopedSingleton(SoundManager, ScopeID::Graphics, true);
+    ManageScopedSingleton(SoundManager, ScopeID::GRAPHICS, true);
 
     std::string SoundManager::getALErrorString(ALenum code)
     {
@@ -65,6 +65,8 @@
         }
     }
 
+    RegisterAbstractClass(SoundManager).inheritsFrom<Configurable>().inheritsFrom<UpdateListener>();
+
     SoundManager::SoundManager()
         : effectsPoolSize_(0)
     {
@@ -162,7 +164,7 @@
 
     SoundManager::~SoundManager()
     {
-        // Erase fade lists because of the smart pointers
+        // Erase fade lists because of the strong pointers
         this->bDestructorCalled_ = true;
         this->fadeInList_.clear();
         this->fadeOutList_.clear();
@@ -416,10 +418,10 @@
         }
     }
 
-    void SoundManager::fadeIn(const SmartPtr<AmbientSound>& sound)
+    void SoundManager::fadeIn(AmbientSound* sound)
     {
         // If we're already fading out --> remove that
-        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
+        for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
         {
             if (*it == sound)
             {
@@ -432,10 +434,10 @@
             this->fadeInList_.push_back(sound);
     }
 
-    void SoundManager::fadeOut(const SmartPtr<AmbientSound>& sound)
+    void SoundManager::fadeOut(AmbientSound* sound)
     {
         // If we're already fading in --> remove that
-        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
+        for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
         {
             if (*it == sound)
             {
@@ -458,7 +460,7 @@
         }
 
         // FADE IN
-        for (std::list<SmartPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
+        for (std::list<StrongPtr<AmbientSound> >::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); )
         {
             if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f)
             {
@@ -473,7 +475,7 @@
         }
 
         // FADE OUT
-        for (std::list<SmartPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
+        for (std::list<StrongPtr<AmbientSound> >::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); )
         {
             if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f)
             {

Modified: code/trunk/src/orxonox/sound/SoundManager.h
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/sound/SoundManager.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,7 +39,8 @@
 
 #include "util/Singleton.h"
 #include "core/config/Configurable.h"
-#include "core/object/SmartPtr.h"
+#include "core/object/StrongPtr.h"
+#include "core/UpdateListener.h"
 
 // tolua_begin
 namespace orxonox
@@ -58,7 +59,7 @@
     //! The SoundManager class manages the OpenAL device, context and listener position.
     class _OrxonoxExport SoundManager
     // tolua_end
-        : public Singleton<SoundManager>, public Configurable
+        : public Singleton<SoundManager>, public Configurable, public UpdateListener
     { // tolua_export
         friend class Singleton<SoundManager>;
 
@@ -67,6 +68,7 @@
         ~SoundManager();
 
         void preUpdate(const Clock& time);
+        void postUpdate(const Clock& time) { /*no action*/ }
         void setConfigValues();
 
         // tolua_begin
@@ -103,8 +105,8 @@
 
     private:
         void processCrossFading(float dt);
-        void fadeIn(const SmartPtr<AmbientSound>& sound);
-        void fadeOut(const SmartPtr<AmbientSound>& sound);
+        void fadeIn(AmbientSound* sound);
+        void fadeOut(AmbientSound* sound);
 
         void checkFadeStepValidity();
 
@@ -126,8 +128,8 @@
         AmbientList                        ambientSounds_;
         //! Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
         float                              crossFadeStep_;
-        std::list<SmartPtr<AmbientSound> > fadeInList_;
-        std::list<SmartPtr<AmbientSound> > fadeOutList_;
+        std::list<StrongPtr<AmbientSound> > fadeInList_;
+        std::list<StrongPtr<AmbientSound> > fadeOutList_;
 
         // Volume related
         float volume_[3];

Modified: code/trunk/src/orxonox/sound/WorldAmbientSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/WorldAmbientSound.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/sound/WorldAmbientSound.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -32,7 +32,7 @@
 #include "core/EventIncludes.h"
 #include "core/XMLPort.h"
 #include "AmbientSound.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include <exception>
 
 

Modified: code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,7 +44,7 @@
 
 namespace orxonox
 {
-    RegisterAbstractClass(WeaponMode).inheritsFrom(Class(BaseObject));
+    RegisterAbstractClass(WeaponMode).inheritsFrom<BaseObject>();
 
     WeaponMode::WeaponMode(Context* context) : BaseObject(context)
     {

Modified: code/trunk/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -35,7 +35,7 @@
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GameMode.h"
 #include "core/XMLPort.h"
-#include "network/NetworkFunction.h"
+#include "network/NetworkFunctionIncludes.h"
 
 #include "Scene.h"
 #include "infos/PlayerInfo.h"
@@ -107,7 +107,7 @@
             if (this->camera_)
                 this->camera_->destroy();
 
-            for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+            for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
                 (*it)->destroy();
 
             if (this->getScene()->getSceneManager())
@@ -164,7 +164,7 @@
     CameraPosition* ControllableEntity::getCameraPosition(unsigned int index) const
     {
         unsigned int i = 0;
-        for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+        for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
         {
             if (i == index)
                 return (*it);
@@ -179,7 +179,7 @@
             return 0;
 
         unsigned int counter = 0;
-        for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+        for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
         {
             if ((*it) == this->currentCameraPosition_)
                 break;
@@ -214,11 +214,11 @@
             if (this->camera_->getParent() == this && this->cameraPositions_.size() > 0)
             {
                 this->cameraPositions_.front()->attachCamera(this->camera_);
-                this->currentCameraPosition_ = this->cameraPositions_.front().get();
+                this->currentCameraPosition_ = this->cameraPositions_.front();
             }
             else if (this->cameraPositions_.size() > 0)
             {
-                for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+                for (std::list<StrongPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
                 {
                     if ((*it) == this->camera_->getParent())
                     {
@@ -306,7 +306,7 @@
         }
         else
         {
-            callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
+            callMemberNetworkFunction(&ControllableEntity::fire, this->getObjectID(), 0, firemode);
         }
     }
 
@@ -322,11 +322,11 @@
         {
             if ( target != 0 )
             {
-                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
+                callMemberNetworkFunction(&ControllableEntity::setTargetInternal, this->getObjectID(), 0, target->getObjectID() );
             }
            else
            {
-                callMemberNetworkFunction(ControllableEntity, setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
+                callMemberNetworkFunction(&ControllableEntity::setTargetInternal, this->getObjectID(), 0, OBJECTID_UNKNOWN );
            }
         }
     }
@@ -476,7 +476,7 @@
         WorldEntity* parent = this->getParent();
         if (parent)
         {
-            for (std::list<SmartPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
+            for (std::list<StrongPtr<CameraPosition> >::iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
                 if ((*it)->getIsAbsolute())
                     parent->attach((*it));
         }

Modified: code/trunk/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.h	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.h	2015-10-04 19:12:21 UTC (rev 10624)
@@ -120,7 +120,7 @@
 
             void addCameraPosition(CameraPosition* position);
             CameraPosition* getCameraPosition(unsigned int index) const;
-            inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const
+            inline const std::list<StrongPtr<CameraPosition> >& getCameraPositions() const
                 { return this->cameraPositions_; }
             unsigned int getCurrentCameraIndex() const;
             bool setCameraPosition(unsigned int index);
@@ -161,13 +161,13 @@
                 { return this->xmlcontroller_; }
 
             inline Controller* getController() const
-                { return this->controller_.get(); }
+                { return this->controller_; }
             void setController(Controller* val);
 
 
             virtual void setTarget( WorldEntity* target );
             virtual WorldEntity* getTarget()
-                { return this->target_.get(); }
+                { return this->target_; }
             void setTargetInternal( uint32_t targetID );
 
             inline void setTeam(int team)
@@ -241,7 +241,7 @@
             Camera* camera_;
             bool bMouseLook_;
             float mouseLookSpeed_;
-            std::list<SmartPtr<CameraPosition> > cameraPositions_;
+            std::list<StrongPtr<CameraPosition> > cameraPositions_;
             CameraPosition* currentCameraPosition_;
             std::string cameraPositionTemplate_;
             Controller* xmlcontroller_;

Modified: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -60,7 +60,7 @@
     BOOST_STATIC_ASSERT((int)Ogre::Node::TS_PARENT == (int)WorldEntity::Parent);
     BOOST_STATIC_ASSERT((int)Ogre::Node::TS_WORLD  == (int)WorldEntity::World);
 
-    RegisterAbstractClass(WorldEntity).inheritsFrom(Class(BaseObject)).inheritsFrom(Class(Synchronisable));
+    RegisterAbstractClass(WorldEntity).inheritsFrom<BaseObject>().inheritsFrom<Synchronisable>();
 
     /**
     @brief
@@ -129,7 +129,7 @@
             {
                 WorldEntity* entity = *it;
 
-                // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to smart pointers pointing to it
+                // do this for all children, because even if getDeleteWithParent() returns true a child might still stay active due to strong pointers pointing to it
                 entity->setPosition(entity->getWorldPosition());
                 this->detach(entity); // detach also erases the element from the children set
 

Modified: code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/pawns/Destroyer.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -39,7 +39,7 @@
     {
         RegisterObject(Destroyer);
 
-        UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype().get());
+        UnderAttack* gametype = orxonox_cast<UnderAttack*>(this->getGametype());
         if (gametype)
         {
             gametype->addDestroyer(this);

Modified: code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/pawns/ModularSpaceShip.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -36,7 +36,7 @@
 #include "core/XMLPort.h"
 #include "util/Math.h"
 #include "gametypes/Gametype.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "items/ShipPart.h"
 #include "items/Engine.h"
@@ -68,7 +68,8 @@
     {
         if (this->isInitialized())
         {
-
+            while (!this->partList_.empty())
+                this->partList_[0]->destroy();
         }
     }
 
@@ -176,7 +177,7 @@
         {
             if (it->second->getName() == name)
             {
-                it->second->setAlive(false);
+                it->second->death();
                 return;
             }
         }
@@ -195,7 +196,7 @@
         {
             if (it->second->getName() == name)
             {
-                it->second->setAlive(false);
+                it->second->death();
                 return;
             }
         }

Modified: code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -325,8 +325,9 @@
         this->setHealth(1);
         if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
         {
-            // Set bAlive_ to false and wait for PawnManager to do the destruction
+            // Set bAlive_ to false and wait for destroyLater() to do the destruction
             this->bAlive_ = false;
+            this->destroyLater();
 
             this->setDestroyWhenPlayerLeft(false);
 

Modified: code/trunk/src/orxonox/worldentities/pawns/Spectator.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Spectator.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/pawns/Spectator.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -33,7 +33,7 @@
 #include "core/config/ConfigValueIncludes.h"
 #include "core/GameMode.h"
 #include "core/command/CommandExecutor.h"
-#include "core/command/ConsoleCommand.h"
+#include "core/command/ConsoleCommandIncludes.h"
 
 #include "tools/BillboardSet.h"
 #include "Scene.h"

Modified: code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/src/orxonox/worldentities/pawns/TeamBaseMatchBase.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,7 +44,7 @@
 
         this->state_ = BaseState::Uncontrolled;
 
-        TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype().get());
+        TeamBaseMatch* gametype = orxonox_cast<TeamBaseMatch*>(this->getGametype());
         if (gametype)
         {
             gametype->addBase(this);
@@ -57,7 +57,7 @@
     {
         this->fireEvent();
 
-        TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype().get());
+        TeamDeathmatch* gametype = orxonox_cast<TeamDeathmatch*>(this->getGametype());
         if (!gametype)
             return;
 

Modified: code/trunk/test/core/CMakeLists.txt
===================================================================
--- code/trunk/test/core/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -11,6 +11,7 @@
     class/IdentifierTest.cc
     class/IdentifierClassHierarchyTest.cc
     class/IdentifierSimpleClassHierarchyTest.cc
+    class/IdentifierNestedClassHierarchyTest.cc
     class/IdentifierExternalClassHierarchyTest.cc
     class/OrxonoxClassTest.cc
     class/OrxonoxInterfaceTest.cc
@@ -24,8 +25,9 @@
     object/ListableTest.cc
     object/ObjectListBaseTest.cc
     object/ObjectListIteratorTest.cc
-    object/SmartPtrTest.cc
+    object/StrongPtrTest.cc
     object/WeakPtrTest.cc
+    singleton/ScopeTest.cc
 )
 ADD_DEPENDENCIES(all_tests core_test)
 

Modified: code/trunk/test/core/class/IdentifiableTest.cc
===================================================================
--- code/trunk/test/core/class/IdentifiableTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/IdentifiableTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,34 +1,54 @@
 #include <gtest/gtest.h>
 #include "core/CoreIncludes.h"
 #include "core/class/Identifiable.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
     namespace
     {
-        class IdentifiableTest : public Identifiable
+        class IdentifiableClass : public Identifiable
         {
             public:
-                IdentifiableTest() { RegisterObject(IdentifiableTest); }
+                IdentifiableClass() { RegisterObject(IdentifiableClass); }
         };
+
+        RegisterClassNoArgs(IdentifiableClass);
+
+        // Fixture
+        class IdentifiableTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                }
+
+                virtual void TearDown()
+                {
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
+                }
+        };
     }
 
-    TEST(IdentifiableTest, CanCreate)
+    TEST_F(IdentifiableTest, CanCreate)
     {
-        IdentifiableTest* test = new IdentifiableTest();
+        IdentifiableClass* test = new IdentifiableClass();
         ASSERT_TRUE(test != NULL);
         delete test;
     }
 
-    TEST(IdentifiableTest, HasIdentifierAssigned)
+    TEST_F(IdentifiableTest, HasIdentifierAssigned)
     {
-        IdentifiableTest test;
+        IdentifiableClass test;
         EXPECT_TRUE(test.getIdentifier());
     }
 
-    TEST(IdentifiableTest, CanBeIdentified)
+    TEST_F(IdentifiableTest, CanBeIdentified)
     {
-        IdentifiableTest test;
-        EXPECT_TRUE(test.isA(Class(IdentifiableTest)));
+        IdentifiableClass test;
+        EXPECT_TRUE(test.isA(Class(IdentifiableClass)));
     }
 }

Modified: code/trunk/test/core/class/IdentifierClassHierarchyTest.cc
===================================================================
--- code/trunk/test/core/class/IdentifierClassHierarchyTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/IdentifierClassHierarchyTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -3,6 +3,7 @@
 #include "core/class/Identifiable.h"
 #include "core/class/OrxonoxClass.h"
 #include "core/class/OrxonoxInterface.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -12,13 +13,13 @@
     //                 +---------------------+-+- Class2b
     //                 +-+-+-- Class3        | |
     //                   | |                 | |
-    // BaseInterface1 <--+---- Interface1 <--´ |
+    // BaseInterface1 <--+---- Interface1 <--´ |
     //                     |                   |
-    // BaseInterface2 <----+-- Interface2 <----´
+    // BaseInterface2 <----+-- Interface2 <----´
 
     namespace
     {
-        class BaseInterface1 : public OrxonoxInterface
+        class BaseInterface1 : virtual public OrxonoxInterface
         {
             public:
                 BaseInterface1()
@@ -29,7 +30,7 @@
                 virtual void test1() = 0;
         };
 
-        class BaseInterface2 : public OrxonoxInterface
+        class BaseInterface2 : virtual public OrxonoxInterface
         {
             public:
                 BaseInterface2()
@@ -123,95 +124,48 @@
                 virtual void test2() {}
         };
 
+        RegisterAbstractClass(BaseInterface1).inheritsFrom<OrxonoxInterface>();
+        RegisterAbstractClass(BaseInterface2).inheritsFrom<OrxonoxInterface>();
+        RegisterAbstractClass(Interface1).inheritsFrom<BaseInterface1>();
+        RegisterAbstractClass(Interface2).inheritsFrom<BaseInterface2>();
+        RegisterClassNoArgs(BaseClass);
+        RegisterClassNoArgs(Class0);
+        RegisterClassNoArgs(Class1);
+        RegisterClassNoArgs(Class2a);
+        RegisterClassNoArgs(Class2b);
+        RegisterClassNoArgs(Class3);
+
         // Fixture
         class IdentifierClassHierarchyTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
-                    registerClass("Context", new ClassFactoryWithContext<Context>());
-                    registerClass("Listable", new ClassFactoryWithContext<Listable>());
-                    registerClass("Configurable", new ClassFactoryNoArgs<Configurable>());
-                    registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>());
-                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
-                    registerClass("BaseInterface1", static_cast<ClassFactory<BaseInterface1>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface));
-                    registerClass("BaseInterface2", static_cast<ClassFactory<BaseInterface2>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface));
-                    registerClass("Interface1", static_cast<ClassFactory<Interface1>*>(NULL), false).inheritsFrom(Class(BaseInterface1));
-                    registerClass("Interface2", static_cast<ClassFactory<Interface2>*>(NULL), false).inheritsFrom(Class(BaseInterface2));
-                    registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>());
-                    registerClass("Class0", new ClassFactoryNoArgs<Class0>());
-                    registerClass("Class1", new ClassFactoryNoArgs<Class1>());
-                    registerClass("Class2a", new ClassFactoryNoArgs<Class2a>());
-                    registerClass("Class2b", new ClassFactoryNoArgs<Class2b>());
-                    registerClass("Class3", new ClassFactoryNoArgs<Class3>());
-
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    Context::setRootContext(new Context(NULL));
+                    Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
                 }
 
                 virtual void TearDown()
                 {
-                    IdentifierManager::getInstance().destroyAllIdentifiers();
+                    IdentifierManager::getInstance().destroyClassHierarchy();
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
 
-        bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier)
+        bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier)
         {
-            return identifiers.find(identifier) != identifiers.end();
+            return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end();
         }
-    }
 
-    TEST(IdentifierClassHierarchyTest_NoFixture, NoInitialization)
-    {
+        bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier)
         {
-            Identifier* identifier = Class(BaseInterface1);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
+            return identifiers.find(identifier) != identifiers.end();
         }
-        {
-            Identifier* identifier = Class(BaseInterface2);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(Interface1);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(Interface2);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(BaseClass);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(Class0);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(Class1);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(Class2a);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(Class2b);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(Class3);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
     }
 
     TEST_F(IdentifierClassHierarchyTest, TestBaseInterface1)

Modified: code/trunk/test/core/class/IdentifierExternalClassHierarchyTest.cc
===================================================================
--- code/trunk/test/core/class/IdentifierExternalClassHierarchyTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/IdentifierExternalClassHierarchyTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,6 +1,7 @@
 #include <gtest/gtest.h>
 #include "core/CoreIncludes.h"
 #include "core/class/Identifiable.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -37,50 +38,41 @@
                 virtual void test() {}
         };
 
+        RegisterAbstractClass(Interface).inheritsFrom<Identifiable>();
+        RegisterClassNoArgs(BaseClass);
+        RegisterClassNoArgs(RealClass);
+
         // Fixture
         class IdentifierExternalClassHierarchyTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
-                    registerClass("Context", new ClassFactoryWithContext<Context>());
-                    registerClass("Listable", new ClassFactoryWithContext<Listable>());
-                    registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(Identifiable));
-                    registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>());
-                    registerClass("RealClass", new ClassFactoryNoArgs<RealClass>());
-
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    Context::setRootContext(new Context(NULL));
+                    Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
                 }
 
                 virtual void TearDown()
                 {
-                    IdentifierManager::getInstance().destroyAllIdentifiers();
+                    IdentifierManager::getInstance().destroyClassHierarchy();
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
 
-        bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier)
+        bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier)
         {
-            return identifiers.find(identifier) != identifiers.end();
+            return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end();
         }
-    }
 
-    TEST(IdentifierExternalClassHierarchyTest_NoFixture, NoInitialization)
-    {
+        bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier)
         {
-            Identifier* identifier = Class(Interface);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
+            return identifiers.find(identifier) != identifiers.end();
         }
-        {
-            Identifier* identifier = Class(BaseClass);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(RealClass);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
     }
 
     TEST_F(IdentifierExternalClassHierarchyTest, TestInterface)

Copied: code/trunk/test/core/class/IdentifierNestedClassHierarchyTest.cc (from rev 10623, code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc)
===================================================================
--- code/trunk/test/core/class/IdentifierNestedClassHierarchyTest.cc	                        (rev 0)
+++ code/trunk/test/core/class/IdentifierNestedClassHierarchyTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,355 @@
+#include <gtest/gtest.h>
+#include "core/CoreIncludes.h"
+#include "core/class/Identifiable.h"
+#include "core/class/OrxonoxClass.h"
+#include "core/class/OrxonoxInterface.h"
+#include "core/module/ModuleInstance.h"
+
+namespace orxonox
+{
+    // Tests the class hierarchy with classes that contain other classes as members.
+    //
+    //                    +------ Nested1         +------ Class1_notNested
+    //                    +------ Nested2         +------ Class2_oneNested
+    // OrxonoxClass <-----+------ BaseClass <-----+------ Class3_twoNested <----------- Class3_Child
+    //                                            +------ Class4_class1Nested
+    //                                            +------ Class5_class2Nested
+    //                                            +------ Class6_class3Nested <-------- Class6_Child
+
+    namespace
+    {
+        class Nested1 : public OrxonoxClass
+        {
+            public:
+                Nested1() { RegisterObject(Nested1); }
+        };
+
+        class Nested2 : public OrxonoxClass
+        {
+            public:
+                Nested2() { RegisterObject(Nested2); }
+        };
+
+        class BaseClass : public OrxonoxClass
+        {
+            public:
+                BaseClass() { RegisterObject(BaseClass); }
+        };
+
+        class Class1_notNested : public BaseClass
+        {
+            public:
+                Class1_notNested() { RegisterObject(Class1_notNested); }
+        };
+
+        class Class2_oneNested : public BaseClass
+        {
+            public:
+                Class2_oneNested() { RegisterObject(Class2_oneNested); }
+                Nested1 nested1_;
+        };
+
+        class Class3_twoNested : public BaseClass
+        {
+            public:
+                Class3_twoNested() { RegisterObject(Class3_twoNested); }
+                Nested1 nested1_;
+                Nested2 nested2_;
+        };
+
+        class Class4_class1Nested : public BaseClass
+        {
+            public:
+                Class4_class1Nested() { RegisterObject(Class4_class1Nested); }
+                Class1_notNested nested_;
+        };
+
+        class Class5_class2Nested : public BaseClass
+        {
+            public:
+                Class5_class2Nested() { RegisterObject(Class5_class2Nested); }
+                Class2_oneNested nested_;
+        };
+
+        class Class6_class3Nested : public BaseClass
+        {
+            public:
+                Class6_class3Nested() { RegisterObject(Class6_class3Nested); }
+                Class3_twoNested nested_;
+        };
+
+        class Class3_Child : public Class3_twoNested
+        {
+            public:
+                Class3_Child() { RegisterObject(Class3_Child); }
+        };
+
+        class Class6_Child : public Class6_class3Nested
+        {
+            public:
+                Class6_Child() { RegisterObject(Class6_Child); }
+        };
+
+        RegisterClassNoArgs(Nested1);
+        RegisterClassNoArgs(Nested2);
+        RegisterClassNoArgs(BaseClass);
+        RegisterClassNoArgs(Class1_notNested);
+        RegisterClassNoArgs(Class2_oneNested);
+        RegisterClassNoArgs(Class3_twoNested);
+        RegisterClassNoArgs(Class4_class1Nested);
+        RegisterClassNoArgs(Class5_class2Nested);
+        RegisterClassNoArgs(Class6_class3Nested);
+        RegisterClassNoArgs(Class3_Child);
+        RegisterClassNoArgs(Class6_Child);
+
+        // Fixture
+        class IdentifierNestedClassHierarchyTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    Context::setRootContext(new Context(NULL));
+                    Identifier::initConfigValues_s = false; // TODO: hack!
+                    IdentifierManager::getInstance().createClassHierarchy();
+                }
+
+                virtual void TearDown()
+                {
+                    IdentifierManager::getInstance().destroyClassHierarchy();
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
+                }
+        };
+
+        bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier)
+        {
+            return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end();
+        }
+
+        bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier)
+        {
+            return identifiers.find(identifier) != identifiers.end();
+        }
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestNested1)
+    {
+        Identifier* identifier = Class(Nested1);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxClass)));
+
+        EXPECT_EQ(4u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestNested2)
+    {
+        Identifier* identifier = Class(Nested2);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxClass)));
+
+        EXPECT_EQ(4u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestBaseClass)
+    {
+        Identifier* identifier = Class(BaseClass);
+
+        EXPECT_EQ(6u, identifier->getDirectChildren().size());
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class1_notNested)));
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class2_oneNested)));
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class3_twoNested)));
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class4_class1Nested)));
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class5_class2Nested)));
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class6_class3Nested)));
+
+        EXPECT_EQ(8u, identifier->getChildren().size());
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class1_notNested)));
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2_oneNested)));
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class3_twoNested)));
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class4_class1Nested)));
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class5_class2Nested)));
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class6_class3Nested)));
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class3_Child)));
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class6_Child)));
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxClass)));
+
+        EXPECT_EQ(4u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass1_notNested)
+    {
+        Identifier* identifier = Class(Class1_notNested);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass)));
+
+        EXPECT_EQ(5u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass2_oneNested)
+    {
+        Identifier* identifier = Class(Class2_oneNested);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass)));
+
+        EXPECT_EQ(5u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass3_twoNested)
+    {
+        Identifier* identifier = Class(Class3_twoNested);
+
+        EXPECT_EQ(1u, identifier->getDirectChildren().size());
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class3_Child)));
+
+        EXPECT_EQ(1u, identifier->getChildren().size());
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class3_Child)));
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass)));
+
+        EXPECT_EQ(5u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass4_class1Nested)
+    {
+        Identifier* identifier = Class(Class4_class1Nested);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass)));
+
+        EXPECT_EQ(5u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass5_class2Nested)
+    {
+        Identifier* identifier = Class(Class5_class2Nested);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass)));
+
+        EXPECT_EQ(5u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass6_class3Nested)
+    {
+        Identifier* identifier = Class(Class6_class3Nested);
+
+        EXPECT_EQ(1u, identifier->getDirectChildren().size());
+        EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class6_Child)));
+
+        EXPECT_EQ(1u, identifier->getChildren().size());
+        EXPECT_TRUE(contains(identifier->getChildren(), Class(Class6_Child)));
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass)));
+
+        EXPECT_EQ(5u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass3_Child)
+    {
+        Identifier* identifier = Class(Class3_Child);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Class3_twoNested)));
+
+        EXPECT_EQ(6u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Class3_twoNested)));
+    }
+
+    TEST_F(IdentifierNestedClassHierarchyTest, TestClass6_Child)
+    {
+        Identifier* identifier = Class(Class6_Child);
+
+        EXPECT_EQ(0u, identifier->getDirectChildren().size());
+        EXPECT_EQ(0u, identifier->getChildren().size());
+
+        EXPECT_EQ(1u, identifier->getDirectParents().size());
+        EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Class6_class3Nested)));
+
+        EXPECT_EQ(6u, identifier->getParents().size());
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Listable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Configurable)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass)));
+        EXPECT_TRUE(contains(identifier->getParents(), Class(Class6_class3Nested)));
+    }
+}

Modified: code/trunk/test/core/class/IdentifierSimpleClassHierarchyTest.cc
===================================================================
--- code/trunk/test/core/class/IdentifierSimpleClassHierarchyTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/IdentifierSimpleClassHierarchyTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -3,12 +3,13 @@
 #include "core/class/Identifiable.h"
 #include "core/class/OrxonoxClass.h"
 #include "core/class/OrxonoxInterface.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
     namespace
     {
-        class Interface : public OrxonoxInterface
+        class Interface : virtual public OrxonoxInterface
         {
             public:
                 Interface()
@@ -39,53 +40,41 @@
                 virtual void test() {}
         };
 
+        RegisterAbstractClass(Interface).inheritsFrom<OrxonoxInterface>();
+        RegisterClassNoArgs(BaseClass);
+        RegisterClassNoArgs(RealClass);
+
         // Fixture
         class IdentifierSimpleClassHierarchyTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
-                    registerClass("Context", new ClassFactoryWithContext<Context>());
-                    registerClass("Listable", new ClassFactoryWithContext<Listable>());
-                    registerClass("Configurable", new ClassFactoryNoArgs<Configurable>());
-                    registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>());
-                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
-                    registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface));
-                    registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>());
-                    registerClass("RealClass", new ClassFactoryNoArgs<RealClass>());
-
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    Context::setRootContext(new Context(NULL));
+                    Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
                 }
 
                 virtual void TearDown()
                 {
-                    IdentifierManager::getInstance().destroyAllIdentifiers();
+                    IdentifierManager::getInstance().destroyClassHierarchy();
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
 
-        bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier)
+        bool contains(const std::list<const Identifier*> identifiers, Identifier* identifier)
         {
-            return identifiers.find(identifier) != identifiers.end();
+            return std::find(identifiers.begin(), identifiers.end(), identifier) != identifiers.end();
         }
-    }
 
-    TEST(IdentifierSimpleClassHierarchyTest_NoFixture, NoInitialization)
-    {
+        bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier)
         {
-            Identifier* identifier = Class(Interface);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
+            return identifiers.find(identifier) != identifiers.end();
         }
-        {
-            Identifier* identifier = Class(BaseClass);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
-        {
-            Identifier* identifier = Class(RealClass);
-            EXPECT_EQ(0u, identifier->getChildren().size());
-            EXPECT_EQ(0u, identifier->getParents().size());
-        }
     }
 
     TEST_F(IdentifierSimpleClassHierarchyTest, TestInterface)

Modified: code/trunk/test/core/class/IdentifierTest.cc
===================================================================
--- code/trunk/test/core/class/IdentifierTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/IdentifierTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,6 +1,7 @@
 #include <gtest/gtest.h>
 #include "core/CoreIncludes.h"
 #include "core/class/Identifiable.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -17,9 +18,29 @@
             public:
                 TestSubclass() { RegisterObject(TestSubclass); }
         };
+
+        RegisterClassNoArgs(TestClass);
+        RegisterClassNoArgs(TestSubclass);
+
+        // Fixture
+        class IdentifierTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                }
+
+                virtual void TearDown()
+                {
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
+                }
+        };
     }
 
-    TEST(IdentifierTest, IdentifierExistsOfClass)
+    TEST_F(IdentifierTest, IdentifierExistsOfClass)
     {
         TestClass test;
 
@@ -27,7 +48,7 @@
         EXPECT_TRUE(identifier != NULL);
     }
 
-    TEST(IdentifierTest, IdentifierExistsOfSubclass)
+    TEST_F(IdentifierTest, IdentifierExistsOfSubclass)
     {
         TestSubclass test;
 
@@ -35,7 +56,7 @@
         EXPECT_TRUE(identifier != NULL);
     }
 
-    TEST(IdentifierTest, HasNameOfClass)
+    TEST_F(IdentifierTest, HasNameOfClass)
     {
         TestClass test;
 
@@ -43,7 +64,7 @@
         EXPECT_EQ("TestClass", identifier->getName());
     }
 
-    TEST(IdentifierTest, HasNameOfSubClass)
+    TEST_F(IdentifierTest, HasNameOfSubClass)
     {
         TestSubclass test;
 

Modified: code/trunk/test/core/class/OrxonoxClassTest.cc
===================================================================
--- code/trunk/test/core/class/OrxonoxClassTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/OrxonoxClassTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,5 +1,6 @@
 #include <gtest/gtest.h>
 #include "core/class/OrxonoxClass.h"
+#include "core/class/IdentifierManager.h"
 #include "core/object/Context.h"
 
 namespace orxonox
@@ -16,12 +17,14 @@
             public:
                 virtual void SetUp()
                 {
+                    new IdentifierManager();
                     Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
+                    Context::destroyRootContext();
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Modified: code/trunk/test/core/class/OrxonoxInterfaceTest.cc
===================================================================
--- code/trunk/test/core/class/OrxonoxInterfaceTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/OrxonoxInterfaceTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,6 +1,7 @@
 #include <gtest/gtest.h>
 #include "core/class/OrxonoxInterface.h"
 #include "core/class/OrxonoxClass.h"
+#include "core/class/IdentifierManager.h"
 #include "core/object/Context.h"
 
 namespace orxonox
@@ -31,12 +32,14 @@
             public:
                 virtual void SetUp()
                 {
+                    new IdentifierManager();
                     Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
+                    Context::destroyRootContext();
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Modified: code/trunk/test/core/class/SubclassIdentifierTest.cc
===================================================================
--- code/trunk/test/core/class/SubclassIdentifierTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/SubclassIdentifierTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -3,6 +3,7 @@
 #include "core/class/Identifiable.h"
 #include "core/class/SubclassIdentifier.h"
 #include "core/class/OrxonoxClass.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -20,26 +21,28 @@
                 TestSubclass(Context* context = NULL) { RegisterObject(TestSubclass); }
         };
 
+        RegisterClass(TestClass);
+        RegisterClass(TestSubclass);
+
         // Fixture
         class SubclassIdentifierTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
-                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
-                    registerClass("TestClass", new ClassFactoryWithContext<TestClass>());
-                    registerClass("TestSubclass", new ClassFactoryWithContext<TestSubclass>());
-
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    Context::setRootContext(new Context(NULL));
+                    Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
-
-                    Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
-
-                    IdentifierManager::getInstance().destroyAllIdentifiers();
+                    IdentifierManager::getInstance().destroyClassHierarchy();
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Modified: code/trunk/test/core/class/SuperTest.cc
===================================================================
--- code/trunk/test/core/class/SuperTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/class/SuperTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -4,6 +4,7 @@
 #include "core/CoreIncludes.h"
 #include "core/BaseObject.h"
 #include "core/class/Super.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -61,29 +62,28 @@
                 XMLPort::Mode modeSubclass_;
         };
 
-       // Fixture
+        RegisterClass(TestClass);
+        RegisterClass(TestSubclass);
+
+        // Fixture
         class SuperTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
-                    IdentifierManager::getInstance().destroyAllIdentifiers();
-
-                    registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>());
-                    registerClass("BaseObject", new ClassFactoryWithContext<BaseObject>());
-                    registerClass("TestClass", new ClassFactoryWithContext<TestClass>());
-                    registerClass("TestSubclass", new ClassFactoryWithContext<TestSubclass>());
-
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    Context::setRootContext(new Context(NULL));
+                    Identifier::initConfigValues_s = false; // TODO: hack!
                     IdentifierManager::getInstance().createClassHierarchy();
-
-                    Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
-
-                    IdentifierManager::getInstance().destroyAllIdentifiers();
+                    IdentifierManager::getInstance().destroyClassHierarchy();
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }
@@ -96,7 +96,7 @@
             EXPECT_EQ(0u, identifier->getDirectChildren().size());
 
             EXPECT_EQ(1u, identifier->getDirectParents().size());
-            EXPECT_TRUE(identifier->getDirectParents().find(Class(TestClass)) != identifier->getDirectParents().end());
+            EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(TestClass)) != identifier->getDirectParents().end());
         }
         {
             Identifier* identifier = Class(TestClass);
@@ -105,7 +105,7 @@
             EXPECT_TRUE(identifier->getDirectChildren().find(Class(TestSubclass)) != identifier->getDirectChildren().end());
 
             EXPECT_EQ(1u, identifier->getDirectParents().size());
-            EXPECT_TRUE(identifier->getDirectParents().find(Class(BaseObject)) != identifier->getDirectParents().end());
+            EXPECT_TRUE(std::find(identifier->getDirectParents().begin(), identifier->getDirectParents().end(), Class(BaseObject)) != identifier->getDirectParents().end());
         }
     }
 

Modified: code/trunk/test/core/command/CommandTest.cc
===================================================================
--- code/trunk/test/core/command/CommandTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/command/CommandTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,7 +1,10 @@
 #include <gtest/gtest.h>
-#include "core/command/ConsoleCommand.h"
+#include "core/class/Identifier.h"
+#include "core/class/IdentifierManager.h"
+#include "core/command/ConsoleCommandIncludes.h"
 #include "core/command/CommandExecutor.h"
 #include "core/object/Destroyable.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -129,6 +132,30 @@
             else if (a == -1)
                 ModifyConsoleCommand("test").popFunction();
         }
+
+        // Fixture
+        class CommandTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    new IdentifierManager();
+                    new ConsoleCommandManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
+                    Context::setRootContext(new Context(NULL));
+                    Identifier::initConfigValues_s = false; // TODO: hack!
+                    IdentifierManager::getInstance().createClassHierarchy();
+                }
+
+                virtual void TearDown()
+                {
+                    IdentifierManager::getInstance().destroyClassHierarchy();
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::CONSOLE_COMMAND);
+                    delete &ConsoleCommandManager::getInstance();
+                    delete &IdentifierManager::getInstance();
+                }
+        };
     }
 
     void test(int function, int b, int c)
@@ -138,7 +165,7 @@
         EXPECT_EQ(c, valueC);
     }
 
-    TEST(CommandTest, ModuleTest)
+    TEST_F(CommandTest, ModuleTest)
     {
         test(0, 0, 0);
         CommandExecutor::execute("test 0", false);

Modified: code/trunk/test/core/object/ClassFactoryTest.cc
===================================================================
--- code/trunk/test/core/object/ClassFactoryTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/object/ClassFactoryTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -2,6 +2,8 @@
 #include "core/object/ClassFactory.h"
 #include "core/BaseObject.h"
 #include "core/object/Context.h"
+#include "core/module/ModuleInstance.h"
+#include "core/CoreIncludes.h"
 
 namespace orxonox
 {
@@ -13,12 +15,16 @@
             public:
                 virtual void SetUp()
                 {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
                     Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Modified: code/trunk/test/core/object/ContextTest.cc
===================================================================
--- code/trunk/test/core/object/ContextTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/object/ContextTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -2,6 +2,7 @@
 #include "core/object/Context.h"
 #include "core/class/OrxonoxClass.h"
 #include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -13,18 +14,24 @@
                 SubclassContext() : Context(NULL) { RegisterObject(SubclassContext); }
         };
 
+        RegisterClassNoArgs(SubclassContext);
+
         // Fixture
         class ContextTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
                     Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Modified: code/trunk/test/core/object/IteratorTest.cc
===================================================================
--- code/trunk/test/core/object/IteratorTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/object/IteratorTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -5,6 +5,7 @@
 #include "core/class/OrxonoxClass.h"
 #include "core/class/OrxonoxInterface.h"
 #include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -23,18 +24,25 @@
                 MOCK_METHOD0(test, void());
         };
 
+        RegisterClassNoArgs(TestInterface);
+        RegisterClassNoArgs(TestClass);
+
         // Fixture
         class IteratorTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
                     Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Modified: code/trunk/test/core/object/ListableTest.cc
===================================================================
--- code/trunk/test/core/object/ListableTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/object/ListableTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,6 +1,7 @@
 #include <gtest/gtest.h>
 #include "core/object/Listable.h"
 #include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -9,7 +10,7 @@
         class ListableClassTest : public Listable
         {
             public:
-            ListableClassTest() { RegisterObject(ListableClassTest); }
+                ListableClassTest() { RegisterObject(ListableClassTest); }
         };
 
         class ListableSubclassTest : public ListableClassTest
@@ -18,6 +19,9 @@
                 ListableSubclassTest() { RegisterObject(ListableSubclassTest); }
         };
 
+        RegisterClassNoArgs(ListableClassTest);
+        RegisterClassNoArgs(ListableSubclassTest);
+
         template <class T>
         bool objectListContains(T* element, Context* context = Context::getRootContext())
         {
@@ -34,12 +38,16 @@
             public:
                 virtual void SetUp()
                 {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
                     Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Modified: code/trunk/test/core/object/ObjectListIteratorTest.cc
===================================================================
--- code/trunk/test/core/object/ObjectListIteratorTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/object/ObjectListIteratorTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -4,6 +4,7 @@
 #include "core/object/ObjectListIterator.h"
 #include "core/object/Listable.h"
 #include "core/CoreIncludes.h"
+#include "core/module/ModuleInstance.h"
 
 namespace orxonox
 {
@@ -16,18 +17,24 @@
                 MOCK_METHOD0(test, void());
         };
 
+        RegisterClassNoArgs(ListableTest);
+
         // Fixture
         class ObjectListIteratorTest : public ::testing::Test
         {
             public:
                 virtual void SetUp()
                 {
+                    new IdentifierManager();
+                    ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
                     Context::setRootContext(new Context(NULL));
                 }
 
                 virtual void TearDown()
                 {
-                    Context::setRootContext(NULL);
+                    Context::destroyRootContext();
+                    ModuleInstance::getCurrentModuleInstance()->unloadAllStaticallyInitializedInstances(StaticInitialization::IDENTIFIER);
+                    delete &IdentifierManager::getInstance();
                 }
         };
     }

Deleted: code/trunk/test/core/object/SmartPtrTest.cc
===================================================================
--- code/trunk/test/core/object/SmartPtrTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/object/SmartPtrTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,93 +0,0 @@
-#include <gtest/gtest.h>
-#include "core/object/SmartPtr.h"
-
-namespace orxonox
-{
-    namespace
-    {
-        class DestroyableTest : public Destroyable
-        {
-            public:
-                DestroyableTest(bool& destroyed) : destroyed_(destroyed) { destroyed_ = false; }
-                virtual ~DestroyableTest() { destroyed_ = true; }
-
-            private:
-                bool& destroyed_;
-        };
-    }
-
-    TEST(SmartPtrTest, CanReferenceObject)
-    {
-        bool bla;
-        DestroyableTest* test = new DestroyableTest(bla);
-        SmartPtr<DestroyableTest> smartPtr = test;
-        EXPECT_EQ(test, smartPtr.get());
-        test->destroy();
-    }
-
-    TEST(SmartPtrTest, IncreasesReferenceCount)
-    {
-        bool bla;
-        DestroyableTest* test = new DestroyableTest(bla);
-        EXPECT_EQ(0u, test->getReferenceCount());
-        {
-            SmartPtr<DestroyableTest> smartPtr = test;
-            EXPECT_EQ(1u, test->getReferenceCount());
-        }
-        EXPECT_EQ(0u, test->getReferenceCount());
-        test->destroy();
-    }
-
-    TEST(SmartPtrTest, DestroyDeletesInstance)
-    {
-        bool destroyed = false;
-        DestroyableTest* test = new DestroyableTest(destroyed);
-        EXPECT_FALSE(destroyed);
-        test->destroy();
-        EXPECT_TRUE(destroyed);
-    }
-
-    TEST(SmartPtrTest, PreventsDestruction)
-    {
-        bool destroyed = false;
-        DestroyableTest* test = new DestroyableTest(destroyed);
-        EXPECT_FALSE(destroyed);
-        SmartPtr<DestroyableTest> smartPtr = test;
-        test->destroy();
-        EXPECT_FALSE(destroyed);
-    }
-
-    TEST(SmartPtrTest, DestroysIfSmartPtrRemoved)
-    {
-        bool destroyed = false;
-        DestroyableTest* test = new DestroyableTest(destroyed);
-        EXPECT_FALSE(destroyed);
-        {
-            SmartPtr<DestroyableTest> smartPtr = test;
-            test->destroy();
-            EXPECT_FALSE(destroyed);
-        }
-        EXPECT_TRUE(destroyed);
-    }
-
-    TEST(SmartPtrTest, DestroysIfAllSmartPtrsRemoved)
-    {
-        bool destroyed = false;
-        DestroyableTest* test = new DestroyableTest(destroyed);
-        EXPECT_FALSE(destroyed);
-        {
-            SmartPtr<DestroyableTest> smartPtr1 = test;
-            {
-                SmartPtr<DestroyableTest> smartPtr2 = test;
-                {
-                    SmartPtr<DestroyableTest> smartPtr3 = test;
-                    test->destroy();
-                    EXPECT_FALSE(destroyed);
-                }
-                EXPECT_FALSE(destroyed);
-            }
-            EXPECT_FALSE(destroyed);
-        }
-        EXPECT_TRUE(destroyed);
-    }
-}

Copied: code/trunk/test/core/object/StrongPtrTest.cc (from rev 10623, code/branches/core7/test/core/object/StrongPtrTest.cc)
===================================================================
--- code/trunk/test/core/object/StrongPtrTest.cc	                        (rev 0)
+++ code/trunk/test/core/object/StrongPtrTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -0,0 +1,143 @@
+#include <gtest/gtest.h>
+#include "core/object/StrongPtr.h"
+
+namespace orxonox
+{
+    namespace
+    {
+        class DestroyableTest : public Destroyable
+        {
+            public:
+                DestroyableTest(bool& destroyed) : destroyed_(destroyed) { destroyed_ = false; }
+                virtual ~DestroyableTest() { destroyed_ = true; }
+
+            private:
+                bool& destroyed_;
+        };
+    }
+
+    TEST(StrongPtrTest, CanReferenceObject)
+    {
+        bool bla;
+        DestroyableTest* test = new DestroyableTest(bla);
+        StrongPtr<DestroyableTest> strongPtr = test;
+        EXPECT_EQ(test, strongPtr.get());
+        test->destroy();
+    }
+
+    TEST(StrongPtrTest, IncreasesReferenceCount)
+    {
+        bool bla;
+        DestroyableTest* test = new DestroyableTest(bla);
+        EXPECT_EQ(0u, test->getReferenceCount());
+        {
+            StrongPtr<DestroyableTest> strongPtr = test;
+            EXPECT_EQ(1u, test->getReferenceCount());
+        }
+        EXPECT_EQ(0u, test->getReferenceCount());
+        test->destroy();
+    }
+
+    TEST(StrongPtrTest, DestroyDeletesInstance)
+    {
+        bool destroyed = false;
+        DestroyableTest* test = new DestroyableTest(destroyed);
+        EXPECT_FALSE(destroyed);
+        test->destroy();
+        EXPECT_TRUE(destroyed);
+    }
+
+    TEST(StrongPtrTest, PreventsDestruction)
+    {
+        bool destroyed = false;
+        DestroyableTest* test = new DestroyableTest(destroyed);
+        EXPECT_FALSE(destroyed);
+        StrongPtr<DestroyableTest> strongPtr = test;
+        test->destroy();
+        EXPECT_FALSE(destroyed);
+    }
+
+    TEST(StrongPtrTest, DestroysIfStrongPtrRemoved)
+    {
+        bool destroyed = false;
+        DestroyableTest* test = new DestroyableTest(destroyed);
+        EXPECT_FALSE(destroyed);
+        {
+            StrongPtr<DestroyableTest> strongPtr = test;
+            test->destroy();
+            EXPECT_FALSE(destroyed);
+        }
+        EXPECT_TRUE(destroyed);
+    }
+
+    TEST(StrongPtrTest, DestroysIfAllStrongPtrsRemoved)
+    {
+        bool destroyed = false;
+        DestroyableTest* test = new DestroyableTest(destroyed);
+        EXPECT_FALSE(destroyed);
+        {
+            StrongPtr<DestroyableTest> strongPtr1 = test;
+            {
+                StrongPtr<DestroyableTest> strongPtr2 = test;
+                {
+                    StrongPtr<DestroyableTest> strongPtr3 = test;
+                    test->destroy();
+                    EXPECT_FALSE(destroyed);
+                }
+                EXPECT_FALSE(destroyed);
+            }
+            EXPECT_FALSE(destroyed);
+        }
+        EXPECT_TRUE(destroyed);
+    }
+
+    void isNull(const StrongPtr<DestroyableTest> strongPtr)
+    {
+        EXPECT_TRUE(strongPtr == NULL);
+        EXPECT_TRUE(strongPtr == 0);
+        EXPECT_TRUE(!strongPtr);
+        EXPECT_FALSE(strongPtr != NULL);
+        EXPECT_FALSE(strongPtr != 0);
+        EXPECT_FALSE(strongPtr);
+    }
+
+    TEST(StrongPtrTest, IsNull)
+    {
+        {
+            StrongPtr<DestroyableTest> strongPtr;
+            isNull(strongPtr);
+        }
+        {
+            StrongPtr<DestroyableTest> strongPtr = NULL;
+            isNull(strongPtr);
+        }
+        {
+            StrongPtr<DestroyableTest> strongPtr;
+            strongPtr = NULL;
+            isNull(strongPtr);
+        }
+        {
+            StrongPtr<DestroyableTest> strongPtr = 0;
+            isNull(strongPtr);
+        }
+        {
+            StrongPtr<DestroyableTest> strongPtr;
+            strongPtr = 0;
+            isNull(strongPtr);
+        }
+    }
+
+    TEST(StrongPtrTest, IsNotNull)
+    {
+        bool destroyed = false;
+        DestroyableTest* test = new DestroyableTest(destroyed);
+        StrongPtr<DestroyableTest> strongPtr = test;
+        EXPECT_FALSE(strongPtr == NULL);
+        EXPECT_FALSE(strongPtr == 0);
+        EXPECT_FALSE(!strongPtr);
+        EXPECT_TRUE(strongPtr != NULL);
+        EXPECT_TRUE(strongPtr != 0);
+        EXPECT_TRUE(strongPtr);
+        test->destroy();
+    }
+}

Modified: code/trunk/test/core/object/WeakPtrTest.cc
===================================================================
--- code/trunk/test/core/object/WeakPtrTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/core/object/WeakPtrTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -44,4 +44,53 @@
         EXPECT_CALL(callback, callback());
         test->destroy();
     }
+
+    void isNull(const WeakPtr<DestroyableTest> weakPtr)
+    {
+        EXPECT_TRUE(weakPtr == NULL);
+        EXPECT_TRUE(weakPtr == 0);
+        EXPECT_TRUE(!weakPtr);
+        EXPECT_FALSE(weakPtr != NULL);
+        EXPECT_FALSE(weakPtr != 0);
+        EXPECT_FALSE(weakPtr);
+    }
+
+    TEST(WeakPtrTest, IsNull)
+    {
+        {
+            WeakPtr<DestroyableTest> weakPtr;
+            isNull(weakPtr);
+        }
+        {
+            WeakPtr<DestroyableTest> weakPtr = NULL;
+            isNull(weakPtr);
+        }
+        {
+            WeakPtr<DestroyableTest> weakPtr;
+            weakPtr = NULL;
+            isNull(weakPtr);
+        }
+        {
+            WeakPtr<DestroyableTest> weakPtr = 0;
+            isNull(weakPtr);
+        }
+        {
+            WeakPtr<DestroyableTest> weakPtr;
+            weakPtr = 0;
+            isNull(weakPtr);
+        }
+    }
+
+    TEST(WeakPtrTest, IsNotNull)
+    {
+        DestroyableTest* test = new DestroyableTest();
+        WeakPtr<DestroyableTest> weakPtr = test;
+        EXPECT_FALSE(weakPtr == NULL);
+        EXPECT_FALSE(weakPtr == 0);
+        EXPECT_FALSE(!weakPtr);
+        EXPECT_TRUE(weakPtr != NULL);
+        EXPECT_TRUE(weakPtr != 0);
+        EXPECT_TRUE(weakPtr);
+        test->destroy();
+    }
 }

Modified: code/trunk/test/util/CMakeLists.txt
===================================================================
--- code/trunk/test/util/CMakeLists.txt	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/util/CMakeLists.txt	2015-10-04 19:12:21 UTC (rev 10624)
@@ -12,7 +12,6 @@
     mboolTest.cc
     MultiTypeTest.cc
     OutputTest.cc
-    ScopeTest.cc
     SharedPtrTest.cc
     SingletonTest.cc
     SmallObjectAllocatorTest.cc

Deleted: code/trunk/test/util/ScopeTest.cc
===================================================================
--- code/trunk/test/util/ScopeTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/util/ScopeTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -1,84 +0,0 @@
-#include <gtest/gtest.h>
-#include "util/ScopedSingletonManager.h"
-
-namespace orxonox
-{
-    namespace
-    {
-        class TestSingletonRoot : public Singleton<TestSingletonRoot>
-        {
-            friend class Singleton<TestSingletonRoot>;
-            static TestSingletonRoot* singletonPtr_s;
-        };
-        class TestSingletonGraphics : public Singleton<TestSingletonGraphics>
-        {
-            friend class Singleton<TestSingletonGraphics>;
-            static TestSingletonGraphics* singletonPtr_s;
-        };
-
-        ManageScopedSingleton(TestSingletonRoot, ScopeID::Root, false);
-        ManageScopedSingleton(TestSingletonGraphics, ScopeID::Graphics, false);
-    }
-
-    TEST(Scope, ScopesDoNotExist)
-    {
-        EXPECT_FALSE(Scope<ScopeID::Root>::isActive());
-        EXPECT_FALSE(Scope<ScopeID::Graphics>::isActive());
-    }
-
-    TEST(Scope, SingletonsDoNotExist)
-    {
-        EXPECT_FALSE(TestSingletonRoot::exists());
-        EXPECT_FALSE(TestSingletonGraphics::exists());
-    }
-
-    TEST(Scope, RootScope)
-    {
-        EXPECT_FALSE(Scope<ScopeID::Root>::isActive());
-        {   // create root scope
-            Scope<ScopeID::Root> scope;
-            EXPECT_TRUE(Scope<ScopeID::Root>::isActive());
-        }   // destroy root scope
-        EXPECT_FALSE(Scope<ScopeID::Root>::isActive());
-    }
-
-    TEST(Scope, RootAndGraphicsScope)
-    {
-        EXPECT_FALSE(Scope<ScopeID::Graphics>::isActive());
-        {   // create root scope
-            Scope<ScopeID::Root> scope;
-            EXPECT_FALSE(Scope<ScopeID::Graphics>::isActive());
-            {   // create graphics scope
-                Scope<ScopeID::Graphics> scope;
-                EXPECT_TRUE(Scope<ScopeID::Graphics>::isActive());
-            }   // destroy graphics scope
-            EXPECT_FALSE(Scope<ScopeID::Graphics>::isActive());
-        }   // destroy root scope
-        EXPECT_FALSE(Scope<ScopeID::Graphics>::isActive());
-    }
-
-    TEST(Scope, RootSingleton)
-    {
-        EXPECT_FALSE(TestSingletonRoot::exists());
-        {   // create root scope
-            Scope<ScopeID::Root> scope;
-            EXPECT_TRUE(TestSingletonRoot::exists());
-        }   // destroy root scope
-        EXPECT_FALSE(TestSingletonRoot::exists());
-    }
-
-    TEST(Scope, RootAndGraphicsSingleton)
-    {
-        EXPECT_FALSE(TestSingletonGraphics::exists());
-        {   // create root scope
-            Scope<ScopeID::Root> scope;
-            EXPECT_FALSE(TestSingletonGraphics::exists());
-            {   // create graphics scope
-                Scope<ScopeID::Graphics> scope;
-                EXPECT_TRUE(TestSingletonGraphics::exists());
-            }   // destroy graphics scope
-            EXPECT_FALSE(TestSingletonGraphics::exists());
-        }   // destroy root scope
-        EXPECT_FALSE(TestSingletonGraphics::exists());
-    }
-}

Modified: code/trunk/test/util/output/ConsoleWriterTest.cc
===================================================================
--- code/trunk/test/util/output/ConsoleWriterTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/util/output/ConsoleWriterTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -6,11 +6,26 @@
 
 namespace orxonox
 {
-    TEST(ConsoleWriterTest, Disable)
+    namespace
     {
-        // reset output manager
-        OutputManager::Testing::getInstancePointer() = new OutputManager();
+        // Fixture
+        class ConsoleWriterTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    // reset output manager
+                    OutputManager::Testing::getInstancePointer() = new OutputManager();
+                }
 
+                virtual void TearDown()
+                {
+                }
+        };
+    }
+
+    TEST_F(ConsoleWriterTest, Disable)
+    {
         std::ostream stream(NULL);
         EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
         ConsoleWriter writer(stream);
@@ -19,11 +34,8 @@
         EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
     }
 
-    TEST(ConsoleWriterTest, Enable)
+    TEST_F(ConsoleWriterTest, Enable)
     {
-        // reset output manager
-        OutputManager::Testing::getInstancePointer() = new OutputManager();
-
         std::ostream stream(NULL);
         ConsoleWriter writer(stream);
         writer.disable();
@@ -32,7 +44,7 @@
         EXPECT_EQ(1U, OutputManager::getInstance().getListeners().size());
     }
 
-    TEST(ConsoleWriterTest, WritesNoOutputToOutputStream)
+    TEST_F(ConsoleWriterTest, WritesNoOutputToOutputStream)
     {
         std::stringbuf buffer;
         std::ostream stream(&buffer);
@@ -43,7 +55,7 @@
         EXPECT_EQ("", buffer.str());
     }
 
-    TEST(ConsoleWriterTest, WritesOutputToOutputStream)
+    TEST_F(ConsoleWriterTest, WritesOutputToOutputStream)
     {
         std::stringbuf buffer;
         std::ostream stream(&buffer);
@@ -62,7 +74,7 @@
         EXPECT_NE(std::string::npos, buffer.str().find("test"));
     }
 
-    TEST(ConsoleWriterTest, DefaultConsoleWriterUsesCout)
+    TEST_F(ConsoleWriterTest, DefaultConsoleWriterUsesCout)
     {
         OutputManager::getInstanceAndCreateListeners();
         EXPECT_EQ(std::cout, OutputManager::getInstance().getConsoleWriter()->getOutputStream());

Modified: code/trunk/test/util/output/LogWriterTest.cc
===================================================================
--- code/trunk/test/util/output/LogWriterTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/util/output/LogWriterTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -2,6 +2,8 @@
 #include "util/Output.h"
 #include "util/output/LogWriter.h"
 #include "util/Convert.h"
+#include "util/output/OutputManager.h"
+#include "util/SharedPtr.h"
 
 namespace orxonox
 {
@@ -13,10 +15,25 @@
                 virtual void printLine(const std::string& line, OutputLevel level)
                     { this->LogWriter::printLine(line, level); }
         };
+
+        // Fixture
+        class LogWriterTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    // reset output manager
+                    OutputManager::Testing::getInstancePointer() = new OutputManager();
+                }
+
+                virtual void TearDown()
+                {
+                }
+        };
     }
 
     // test constructor opens file
-    TEST(LogWriterTest, ConstructorOpensFile)
+    TEST_F(LogWriterTest, ConstructorOpensFile)
     {
         LogWriter logWriter;
         EXPECT_TRUE(logWriter.getFile().is_open());
@@ -63,7 +80,7 @@
         return result;
     }
 
-    TEST(LogWriterTest, SetLogDirectoryOpensNewFile)
+    TEST_F(LogWriterTest, SetLogDirectoryOpensNewFile)
     {
         std::string path = "./orxonox.log";
 
@@ -82,7 +99,7 @@
     }
 
     // prints output to logfile
-    TEST(LogWriterTest, PrintsOutputToLogfile)
+    TEST_F(LogWriterTest, PrintsOutputToLogfile)
     {
         std::string path;
 
@@ -102,7 +119,7 @@
     }
 
     // prints time to logfile
-    TEST(LogWriterTest, PrintsTimestampToLogfile)
+    TEST_F(LogWriterTest, PrintsTimestampToLogfile)
     {
         std::string path;
 
@@ -151,7 +168,7 @@
         deleteFile(path + ".9");
     }
 
-    TEST(LogWriterTest, ArchivesOldLogFile)
+    TEST_F(LogWriterTest, ArchivesOldLogFile)
     {
         deleteAllLogFiles();
 
@@ -195,7 +212,7 @@
         EXPECT_FALSE(fileExists(path + ".3"));
     }
 
-    TEST(LogWriterTest, ArchivesNineLogFiles)
+    TEST_F(LogWriterTest, ArchivesNineLogFiles)
     {
         deleteAllLogFiles();
 

Modified: code/trunk/test/util/output/MemoryWriterTest.cc
===================================================================
--- code/trunk/test/util/output/MemoryWriterTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/util/output/MemoryWriterTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -3,6 +3,7 @@
 #include "util/Output.h"
 #include "util/output/MemoryWriter.h"
 #include "util/output/OutputManager.h"
+#include "util/SharedPtr.h"
 
 namespace orxonox
 {
@@ -13,9 +14,24 @@
             public:
                 MOCK_METHOD3(output, void(OutputLevel, const OutputContextContainer&, const std::vector<std::string>&));
         };
+
+        // Fixture
+        class MemoryWriterTest : public ::testing::Test
+        {
+            public:
+                virtual void SetUp()
+                {
+                    // reset output manager
+                    OutputManager::Testing::getInstancePointer() = new OutputManager();
+                }
+
+                virtual void TearDown()
+                {
+                }
+        };
     }
 
-    TEST(MemoryWriterTest, Disable)
+    TEST_F(MemoryWriterTest, Disable)
     {
         EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
         MemoryWriter writer;
@@ -24,7 +40,7 @@
         EXPECT_EQ(0U, OutputManager::getInstance().getListeners().size());
     }
 
-    TEST(MemoryWriterTest, ResendOutput)
+    TEST_F(MemoryWriterTest, ResendOutput)
     {
         MemoryWriter writer;
 

Modified: code/trunk/test/util/output/OutputManagerTest.cc
===================================================================
--- code/trunk/test/util/output/OutputManagerTest.cc	2015-10-04 18:37:12 UTC (rev 10623)
+++ code/trunk/test/util/output/OutputManagerTest.cc	2015-10-04 19:12:21 UTC (rev 10624)
@@ -97,6 +97,8 @@
         manager.registerListener(&listener);
 
         EXPECT_FALSE(manager.getListeners().empty());
+
+        manager.unregisterListener(&listener);
     }
 
     // test unregisterListener removes listener from list
@@ -122,6 +124,8 @@
         manager.registerListener(&listener);
 
         EXPECT_FALSE(listener.getListeners().empty());
+
+        manager.unregisterListener(&listener);
     }
 
     // test unregisterListener unregisters manager from listener
@@ -155,6 +159,8 @@
         EXPECT_EQ(level::internal_warning, manager.getCombinedLevelMask());
         EXPECT_EQ(level::verbose_more, manager.getCombinedAdditionalContextsLevelMask());
         EXPECT_EQ(context::unittest2().mask, manager.getCombinedAdditionalContextsMask());
+
+        manager.unregisterListener(&listener);
     }
 
     // test unregisterListener adjusts masks
@@ -192,6 +198,8 @@
         listener.setLevelMask(level::internal_warning);
 
         EXPECT_EQ(level::internal_warning, manager.getCombinedLevelMask());
+
+        manager.unregisterListener(&listener);
     }
 
     // test updatedAdditionalContextsLevelMask updates mask
@@ -207,6 +215,8 @@
         listener.setAdditionalContextsLevelMask(level::internal_warning);
 
         EXPECT_EQ(level::internal_warning, manager.getCombinedAdditionalContextsLevelMask());
+
+        manager.unregisterListener(&listener);
     }
 
     // test updatedAdditionalContextsMask updates mask
@@ -222,6 +232,8 @@
         listener.setAdditionalContextsMask(context::unittest2().mask);
 
         EXPECT_EQ(context::unittest2().mask, manager.getCombinedAdditionalContextsMask());
+
+        manager.unregisterListener(&listener);
     }
 
     // test combines masks of all listeners
@@ -253,6 +265,10 @@
         EXPECT_EQ(level::user_error | level::user_warning | level::internal_warning, manager.getCombinedLevelMask());
         EXPECT_EQ(level::verbose | level::verbose_more | level::verbose_ultra, manager.getCombinedAdditionalContextsLevelMask());
         EXPECT_EQ(context::unittest1().mask | context::unittest2().mask | context::unittest3().mask, manager.getCombinedAdditionalContextsMask());
+
+        manager.unregisterListener(&listener1);
+        manager.unregisterListener(&listener2);
+        manager.unregisterListener(&listener3);
     }
 
     // test acceptsOutput
@@ -286,6 +302,8 @@
         EXPECT_FALSE(manager.acceptsOutput(level::internal_status, context::unittest2()));
         EXPECT_TRUE(manager.acceptsOutput(level::verbose_more, context::unittest2()));
         EXPECT_FALSE(manager.acceptsOutput(level::verbose_ultra, context::unittest2()));
+
+        manager.unregisterListener(&listener);
     }
 
     // test pushMessage sends lines to listeners
@@ -301,6 +319,8 @@
         EXPECT_CALL(listener, unfilteredOutput(level::user_status, context::unittest1(), lines));
 
         manager.pushMessage(level::user_status, context::unittest1(), "some output");
+
+        manager.unregisterListener(&listener);
     }
 
     // test pushMessage splits lines by \n
@@ -318,6 +338,8 @@
         EXPECT_CALL(listener, unfilteredOutput(level::user_status, context::unittest1(), lines));
 
         manager.pushMessage(level::user_status, context::unittest1(), "some output\nand some more output\n!!!");
+
+        manager.unregisterListener(&listener);
     }
 
     // test registerContext for new context




More information about the Orxonox-commit mailing list