Changeset 9869 in orxonox.OLD for trunk/src/story_entities/game_world_data.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/game_world_data.cc
r9406 r9869 21 21 #include "game_world_data.h" 22 22 23 #include "state.h" 24 #include "substring.h" 25 26 #include "util/loading/game_loader.h" 23 27 #include "util/loading/resource_manager.h" 24 #include "state.h"25 #include "class_list.h"26 #include "substring.h"27 28 #include "util/loading/game_loader.h"29 28 30 29 #include "world_entity.h" … … 41 40 42 41 #include "util/loading/factory.h" 43 #include " fast_factory.h"44 #include "util/loading/load_param .h"42 #include "loading/fast_factory.h" 43 #include "util/loading/load_param_xml.h" 45 44 46 45 #include "graphics_engine.h" 47 #include "effects/atmospheric_engine.h" 46 #include "graphics_effect.h" 47 #include "weather_effects/atmospheric_engine.h" 48 48 #include "event_handler.h" 49 49 #include "sound_engine.h" … … 51 51 #include "network_manager.h" 52 52 #include "physics_engine.h" 53 #include "fields.h"54 53 55 54 #include "glmenu_imagescreen.h" … … 61 60 62 61 63 64 65 62 ObjectListDefinition(GameWorldData); 66 63 /** 67 64 * constructor of the GameWorldData … … 69 66 GameWorldData::GameWorldData() 70 67 { 71 this-> setClassID(CL_GAME_WORLD_DATA, "GameWorldData");68 this->registerObject(this, GameWorldData::_objectList); 72 69 73 70 this->glmis = NULL; … … 119 116 ErrorMessage GameWorldData::loadData(const TiXmlElement* root) 120 117 { 118 assert (root != NULL); 121 119 // load the parameters 122 120 // name 123 std::string string = grabParameter( root, "name");121 std::string string = LoadParamBase::grabParameter( root, "name"); 124 122 if( string.empty() ) 125 123 { … … 194 192 ErrorMessage GameWorldData::loadWorldEntities(const TiXmlElement* root) 195 193 { 196 197 194 const TiXmlElement* element = root->FirstChildElement("WorldEntities"); 198 195 bool mouseCaptured = EventHandler::getInstance()->grabbedEvents(); … … 215 212 216 213 //todo do this more elegant 217 if( element->Value() == "SkyBox" && created->isA( CL_SKYBOX))214 if( element->Value() == "SkyBox" && created->isA(SkyBox::staticClassID())) 218 215 { 219 216 this->sky = dynamic_cast<WorldEntity*>(created); 220 217 State::setSkyBox(dynamic_cast<SkyBox*>(this->sky)); 221 218 } 222 if( element->Value() == "Terrain" && created->isA( CL_TERRAIN))219 if( element->Value() == "Terrain" && created->isA(Terrain::staticClassID())) 223 220 { 224 221 this->terrain = dynamic_cast<Terrain*>(created); … … 236 233 237 234 Playable* playable; 238 const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 239 if (playableList != NULL && !playableList->empty()) 235 if (!Playable::objectList().empty()) 240 236 { 241 237 /// TODO Make this also loadable 242 playable = dynamic_cast<Playable*>(playableList->front()); 243 this->localPlayer->setPlayable(playable); 238 this->localPlayer->setPlayable(Playable::objectList().front()); 244 239 } 245 240 … … 280 275 GraphicsEngine::getInstance()->displayFPS(false); 281 276 // erease everything that is left. 282 // delete PNode::getNullParent(); // not needed as this is also done in the next step (and also much cleaner)283 const std::list<BaseObject*>* nodeList;284 277 //secondary cleanup of PNodes; 285 nodeList = ClassList::getList(CL_PARENT_NODE); 286 if (nodeList != NULL) 287 while (!nodeList->empty()) 288 { 289 // ClassList::debug( 3, CL_PARENT_NODE); 290 // PNode::getNullParent()->debugNode(0); 291 // printf("%s::%s\n", nodeList->front()->getClassCName(), nodeList->front()->getName()); 292 delete nodeList->front(); 293 } 278 while (!PNode::objectList().empty()) 279 delete PNode::objectList().front(); 280 294 281 /* remove the player object */ 295 282 if( this->localPlayer) … … 302 289 this->terrain = NULL; 303 290 304 nodeList = ClassList::getList(CL_GRAPHICS_EFFECT); 305 if (nodeList != NULL) 306 while (!nodeList->empty()) 307 delete nodeList->front(); 308 309 310 nodeList = ClassList::getList(CL_ELEMENT_2D); 311 if (nodeList != NULL) 312 while (!nodeList->empty()) 313 delete nodeList->front(); 291 while (!GraphicsEffect::objectList().empty()) 292 delete GraphicsEffect::objectList().front(); 293 294 295 while (!Element2D::objectList().empty()) 296 delete Element2D::objectList().front(); 314 297 315 298 // At this Point all the WorldEntites should be unloaded. … … 318 301 319 302 // unload the resources loaded in this Level !! 320 ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 303 /// FIXME TODO HACK!! 304 // ResourceManager::getInstance()->unloadAllByPriority(RP_LEVEL); 321 305 322 306 if (State::getObjectManager() == this->objectManager) … … 395 379 { 396 380 PRINTF(3)("Setting Sound Track to %s\n", name.c_str()); 397 std::string oggFile = Resource Manager::getFullName(name);381 std::string oggFile = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(name); 398 382 this->music = new OrxSound::OggPlayer(oggFile); 399 383 if (this->localPlayer != NULL) … … 414 398 PRINTF(2)("creating %s\n", element->Value()); 415 399 BaseObject* created = Factory::fabricate(element); 416 if (created != NULL && created->isA( CL_GAME_RULES))400 if (created != NULL && created->isA(GameRules::staticClassID())) 417 401 { 418 402 this->gameRule = dynamic_cast<GameRules*>(created);
Note: See TracChangeset
for help on using the changeset viewer.