Changeset 10566 for code/branches/core7/src/orxonox/gamestates
- Timestamp:
- Sep 8, 2015, 3:42:30 PM (9 years ago)
- Location:
- code/branches/core7/src/orxonox/gamestates
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/orxonox/gamestates/GSLevel.cc
r10508 r10566 95 95 } 96 96 97 this->prepareObjectTracking(); 98 97 99 if (GameMode::isMaster()) 98 100 { … … 128 130 if (GameMode::isMaster()) 129 131 this->unloadLevel(); 132 else 133 this->unloadLevelAsClient(); 134 135 this->performObjectTracking(); 130 136 131 137 if (GameMode::showsGraphics()) … … 161 167 } 162 168 163 void GSLevel:: loadLevel()169 void GSLevel::prepareObjectTracking() 164 170 { 165 171 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 166 172 this->staticObjects_.insert(*it); 167 168 // call the loader 169 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 170 bool loaded = Loader::getInstance().load(startFile_); 171 172 Core::getInstance().getConfig()->updateLastLevelTimestamp(); 173 if(!loaded) 174 GSRoot::delayedStartMainMenu(); 175 } 176 177 void GSLevel::unloadLevel() 178 { 179 Loader::getInstance().unload(startFile_); 180 delete startFile_; 181 173 } 174 175 void GSLevel::performObjectTracking() 176 { 182 177 orxout(internal_info) << "Remaining objects:" << endl; 183 178 unsigned int i = 0; … … 187 182 if (find == this->staticObjects_.end()) 188 183 { 189 orxout(internal_ info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;184 orxout(internal_warning) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl; 190 185 } 191 186 } … … 194 189 else 195 190 orxout(internal_warning) << i << " objects remaining. Try harder!" << endl; 191 } 192 193 void GSLevel::loadLevel() 194 { 195 // call the loader 196 startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel()); 197 bool loaded = Loader::getInstance().load(startFile_); 198 199 Core::getInstance().getConfig()->updateLastLevelTimestamp(); 200 if(!loaded) 201 GSRoot::delayedStartMainMenu(); 202 } 203 204 void GSLevel::unloadLevel() 205 { 206 Loader::getInstance().unload(startFile_); 207 delete startFile_; 208 } 209 210 /** 211 * Unloads a level when the game instance is (or was) a client in a multiplayer session. 212 * In this case, cleanup after unloading a level is done differently because certain things (e.g. the xml file) are unknown. 213 */ 214 void GSLevel::unloadLevelAsClient() 215 { 216 ObjectList<Synchronisable>::iterator it; 217 for(it = ObjectList<Synchronisable>::begin(); it; ) 218 { 219 if( it->getSyncMode() != 0x0 ) 220 (it++)->destroy(); 221 else 222 { 223 ++it; 224 } 225 } 196 226 } 197 227 -
code/branches/core7/src/orxonox/gamestates/GSLevel.h
r10281 r10566 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
Note: See TracChangeset
for help on using the changeset viewer.