Changeset 3620 in orxonox.OLD for orxonox/trunk/src/story_entities
- Timestamp:
- Mar 21, 2005, 5:37:58 PM (20 years ago)
- Location:
- orxonox/trunk/src/story_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/story_entities/world.cc
r3614 r3620 20 20 21 21 #include "orxonox.h" 22 22 23 #include "p_node.h" 23 24 #include "null_parent.h" … … 33 34 #include "terrain.h" 34 35 #include "light.h" 36 35 37 #include "command_node.h" 36 38 #include "glmenu_imagescreen.h" … … 41 43 42 44 using namespace std; 45 46 47 WorldInterface* WorldInterface::singletonRef = 0; 48 49 50 /** 51 \brief private constructor because of singleton 52 */ 53 WorldInterface::WorldInterface() 54 { 55 this->worldIsInitialized = false; 56 this->worldReference = NULL; 57 } 58 59 /** 60 \brief public deconstructor 61 */ 62 WorldInterface::~WorldInterface() 63 { 64 this->singletonRef = NULL; 65 this->worldIsInitialized = false; 66 this->worldReference = NULL; 67 } 68 69 /** 70 \brief gets the singleton instance 71 \returns singleton instance 72 */ 73 WorldInterface* WorldInterface::getInstance() 74 { 75 if( singletonRef == NULL) 76 singletonRef = new WorldInterface(); 77 return singletonRef; 78 } 79 80 81 /** 82 \brief initializes the interface 83 \param reference to the world 84 85 if the worldinterface is not initilizes, there wont be any 86 useable interface 87 */ 88 void WorldInterface::init(World* world) 89 { 90 this->worldReference = world; 91 if( world!= NULL) 92 { 93 this->worldIsInitialized = true; 94 PRINTF(3)("WorldInterface up and running\n"); 95 } 96 } 97 98 99 /** 100 \brief gets the entity list from the world 101 \return entity list 102 */ 103 tList<WorldEntity>* WorldInterface::getEntityList() 104 { 105 if( this->worldIsInitialized) 106 return this->worldReference->getEntities(); 107 PRINT(1)("Someone tried to use the WorldInterface before it has been initizlized! this can result in SEGFAULTs!\n"); 108 return NULL; 109 } 110 43 111 44 112 … … 76 144 cn->reset(); 77 145 146 delete WorldInterface::getInstance(); 147 78 148 delete this->nullParent; 79 149 delete this->entities; … … 89 159 this->setClassName ("World"); 90 160 161 91 162 this->worldName = name; 92 163 this->debugWorldNr = worldID; 93 164 this->entities = new tList<WorldEntity>(); 165 166 /* init the world interface */ 167 WorldInterface* wi = WorldInterface::getInstance(); 168 wi->init(this); 94 169 95 170 // Enable default GL stuff … … 406 481 SDL_Delay(500); 407 482 PRINTF(3)("World::releaseLoadScreen - end\n"); 483 } 484 485 486 /** 487 \brief gets the list of entities from the world 488 \returns entity list 489 */ 490 tList<WorldEntity>* World::getEntities() 491 { 492 return this->entities; 408 493 } 409 494 -
orxonox/trunk/src/story_entities/world.h
r3608 r3620 12 12 #include "p_node.h" 13 13 14 15 class World; 16 class WorldEntity; 17 18 //! The game world Interface 19 /** 20 this is a singleton interface, that enables world_entities to access the 21 world. for those objects, there is no easier way than over this interface! 22 */ 23 class WorldInterface : BaseObject { 24 25 public: 26 ~WorldInterface(); 27 static WorldInterface* getInstance(); 28 void init(World* world); 29 tList<WorldEntity>* getEntityList(); 30 31 private: 32 WorldInterface(); 33 static WorldInterface* singletonRef; //!< singleton reference to this object 34 bool worldIsInitialized; //!< true if the world has been initialized 35 World* worldReference; //!< this is a reference to the running world 36 37 }; 38 39 14 40 class TrackManager; 15 class WorldEntity;16 41 class Camera; 17 42 class PNode; … … 50 75 /* command node functions */ 51 76 bool command (Command* cmd); 77 78 tList<WorldEntity>* getEntities(); 52 79 53 80 /* interface to world */
Note: See TracChangeset
for help on using the changeset viewer.