Changeset 10624 for code/trunk/src/orxonox/gamestates
- Timestamp:
- Oct 4, 2015, 9:12:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
-
code/trunk/src/orxonox/gamestates/GSClient.cc
r9667 r10624 30 30 31 31 #include "util/Exception.h" 32 #include "core/co nfig/CommandLineParser.h"32 #include "core/commandline/CommandLineIncludes.h" 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r10299 r10624 44 44 #include "core/Loader.h" 45 45 #include "core/XMLFile.h" 46 #include "core/command/ConsoleCommand .h"46 #include "core/command/ConsoleCommandIncludes.h" 47 47 48 48 #include "LevelManager.h" 49 #include "Level.h" 49 50 #include "PlayerManager.h" 50 51 #include "GSRoot.h" … … 95 96 } 96 97 98 this->prepareObjectTracking(); 99 97 100 if (GameMode::isMaster()) 98 101 { … … 128 131 if (GameMode::isMaster()) 129 132 this->unloadLevel(); 133 else 134 this->unloadLevelAsClient(); 135 136 this->performObjectTracking(); 130 137 131 138 if (GameMode::showsGraphics()) … … 161 168 } 162 169 163 void GSLevel:: loadLevel()170 void GSLevel::prepareObjectTracking() 164 171 { 165 172 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 166 173 this->staticObjects_.insert(*it); 167 168 // call the loader 169 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 170 bool loaded = Loader::open(startFile_); 171 172 Core::getInstance().updateLastLevelTimestamp(); 173 if(!loaded) 174 GSRoot::delayedStartMainMenu(); 175 } 176 177 void GSLevel::unloadLevel() 178 { 179 Loader::unload(startFile_); 180 delete startFile_; 181 174 } 175 176 void GSLevel::performObjectTracking() 177 { 182 178 orxout(internal_info) << "Remaining objects:" << endl; 183 179 unsigned int i = 0; … … 187 183 if (find == this->staticObjects_.end()) 188 184 { 189 orxout(internal_ info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;185 orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl; 190 186 } 191 187 } … … 194 190 else 195 191 orxout(internal_warning) << i << " objects remaining. Try harder!" << endl; 192 } 193 194 void GSLevel::loadLevel() 195 { 196 // call the loader 197 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 198 bool loaded = Loader::getInstance().load(startFile_); 199 200 Core::getInstance().getConfig()->updateLastLevelTimestamp(); 201 if(!loaded) 202 GSRoot::delayedStartMainMenu(); 203 } 204 205 void GSLevel::unloadLevel() 206 { 207 Loader::getInstance().unload(startFile_); 208 delete startFile_; 209 } 210 211 /** 212 * Unloads a level when the game instance is (or was) a client in a multiplayer session. 213 * In this case, cleanup after unloading a level is done differently because certain things (e.g. the xml file) are unknown. 214 */ 215 void GSLevel::unloadLevelAsClient() 216 { 217 for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); ) 218 { 219 StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it 220 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); ) 221 (it++)->destroy(); 222 } 223 224 for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ) 225 { 226 if (it->getSyncMode() != 0x0) 227 (it++)->destroy(); 228 else 229 ++it; 230 } 196 231 } 197 232 … … 252 287 /////////////////////////////////////////////////////////////////////////// 253 288 254 RegisterAbstractClass(GSLevelMemento).inheritsFrom (Class(OrxonoxInterface));289 RegisterAbstractClass(GSLevelMemento).inheritsFrom<OrxonoxInterface>(); 255 290 256 291 GSLevelMemento::GSLevelMemento() -
code/trunk/src/orxonox/gamestates/GSLevel.h
r10281 r10624 53 53 void reloadLevel(); 54 54 55 pr otected:55 private: 56 56 void loadLevel(); 57 57 void unloadLevel(); 58 void unloadLevelAsClient(); 59 60 void prepareObjectTracking(); 61 void performObjectTracking(); 58 62 59 63 InputState* gameInputState_; //!< input state for normal ingame playing -
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
r9944 r10624 36 36 #include "core/GraphicsManager.h" 37 37 #include "core/GUIManager.h" 38 #include "core/command/ConsoleCommand .h"38 #include "core/command/ConsoleCommandIncludes.h" 39 39 #include "core/input/KeyBinderManager.h" 40 40 #include "network/Client.h" … … 63 63 SetConsoleCommand(__CC_setMainMenuSoundPath_name, &GSMainMenu::setMainMenuSoundPath).hide(); 64 64 65 RegisterAbstractClass(GSMainMenu).inheritsFrom<Configurable>(); 66 65 67 GSMainMenu::GSMainMenu(const GameStateInfo& info) 66 68 : GameState(info) -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r9348 r10624 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h" 35 #include "core/command/ConsoleCommand .h"36 #include "network/NetworkFunction .h"35 #include "core/command/ConsoleCommandIncludes.h" 36 #include "network/NetworkFunctionIncludes.h" 37 37 #include "tools/Timer.h" 38 38 #include "tools/interfaces/Tickable.h" … … 68 68 GSRoot::~GSRoot() 69 69 { 70 NetworkFunctionBase::destroyAllNetworkFunctions();71 70 } 72 71 -
code/trunk/src/orxonox/gamestates/GSServer.cc
r10197 r10624 30 30 31 31 #include "util/Output.h" 32 #include "core/co nfig/CommandLineParser.h"32 #include "core/commandline/CommandLineIncludes.h" 33 33 #include "core/Game.h" 34 34 #include "core/GameMode.h"
Note: See TracChangeset
for help on using the changeset viewer.