Changeset 6498 in orxonox.OLD for trunk/src/story_entities
- Timestamp:
- Jan 11, 2006, 9:58:22 PM (19 years ago)
- Location:
- trunk/src/story_entities
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/story_entities/game_world.cc
r6457 r6498 131 131 this->shell = new Shell(); 132 132 133 State::setCurrentStoryEntity(dynamic_cast<StoryEntity*>(this)); 133 134 this->dataTank->init(); 134 135 } -
trunk/src/story_entities/game_world.h
r6424 r6498 9 9 10 10 #include "story_entity.h" 11 11 #include "game_world_data.h" 12 12 13 13 class TiXmlElement; … … 56 56 57 57 58 inline void setSky(WorldEntity* sky) { this->dataTank->sky = sky; } 59 60 58 61 protected: 59 62 /* world - running functions */ -
trunk/src/story_entities/multi_player_world.cc
r6424 r6498 21 21 #include "factory.h" 22 22 #include "load_param.h" 23 #include "shell_command.h" 23 24 24 25 #include "network_manager.h" … … 26 27 27 28 using namespace std; 29 30 31 //! Register a command to print some multiplayer world infos 32 SHELL_COMMAND(debug, MultiPlayerWorld, debug); 28 33 29 34 … … 79 84 } 80 85 86 87 /** 88 * some debug ouptut - shell command 89 */ 90 void MultiPlayerWorld::debug() 91 { 92 ((MultiPlayerWorldData*)this->dataTank)->debug(); 93 } -
trunk/src/story_entities/multi_player_world.h
r6424 r6498 27 27 void loadParams(const TiXmlElement* root); 28 28 29 void debug(); 30 29 31 protected: 30 32 virtual void synchronize(); -
trunk/src/story_entities/multi_player_world_data.cc
r6434 r6498 50 50 51 51 52 52 53 using namespace std; 53 54 … … 58 59 MultiPlayerWorldData::MultiPlayerWorldData() 59 60 : GameWorldData() 60 {} 61 { 62 this->toggle = false; 63 } 61 64 62 65 … … 157 160 } 158 161 } 159 /* clients only spawn the SpaceShip */160 /// FIXME it is not said to be a SpaceShip161 else if( !strcmp( element->Value(), "SpaceShip"))162 {163 BaseObject* created = Factory::fabricate(element);164 if( created != NULL )165 PRINTF(1)("Created a %s: %s (%8.u)\n", created->getClassName(), created->getName(), created->getLeafClassID());166 else167 PRINTF(1)("NetworkWorld: could not create this entity\n");168 }169 162 element = element->NextSiblingElement(); 163 170 164 171 165 glmis->step(); … … 173 167 } 174 168 175 176 /* create a Player */ 177 this->localPlayer = new Player(); 178 Playable* playable; 179 const list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 180 if (playableList != NULL) 181 { 182 playable = dynamic_cast<Playable*>(playableList->front()); 183 this->localPlayer->setControllable(playable); 169 if( NetworkManager::getInstance()->isGameServer()) 170 { 171 this->localPlayer = new Player(); 172 State::setPlayer(this->localPlayer); 173 174 Playable* playable; 175 const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 176 assert( playableList != NULL); 177 178 if (playableList != NULL) 179 { 180 playable = dynamic_cast<Playable*>(playableList->front()); 181 this->localPlayer->setControllable(playable); 182 } 183 } 184 else 185 { 186 /* create a Player */ 187 this->localPlayer = new Player(); 188 State::setPlayer(this->localPlayer); 184 189 } 185 190 … … 221 226 } 222 227 228 229 /** 230 * some debug output 231 */ 232 void MultiPlayerWorldData::debug() 233 { 234 PRINT(0)("==================================================\n"); 235 Playable* playable; 236 const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 237 assert(playableList != NULL); 238 std::list<BaseObject*>::const_iterator entity; 239 240 241 242 for (entity = playableList->begin(); entity != playableList->end(); entity++) 243 { 244 Playable* p = dynamic_cast<Playable*>(*entity); 245 PRINTF(0)("Got a playable, class: %s, name: %s, uid: %i\n", (*entity)->getClassName(), (*entity)->getName(), p->getUniqueID()); 246 } 247 248 249 if( this->toggle) 250 { 251 playable = dynamic_cast<Playable*>(playableList->front()); 252 this->localPlayer->disconnectControllable(); 253 this->localPlayer->setControllable(playable); 254 this->toggle = !this->toggle; 255 } 256 else 257 { 258 playable = dynamic_cast<Playable*>(playableList->back()); 259 this->localPlayer->disconnectControllable(); 260 this->localPlayer->setControllable(playable); 261 this->toggle = !this->toggle; 262 } 263 264 265 266 PNode* cam = State::getCameraTarget(); 267 PRINT(0)("Camera has target - class: %s, name: %s, uid: %i\n", cam->getClassName(), cam->getName(), cam->getUniqueID()); 268 269 PRINT(0)("==================================================\n"); 270 271 } 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 -
trunk/src/story_entities/multi_player_world_data.h
r6424 r6498 24 24 virtual ErrorMessage init(); 25 25 26 void debug(); 27 26 28 27 29 protected: … … 33 35 virtual ErrorMessage unloadWorldEntities(); 34 36 virtual ErrorMessage unloadScene(); 37 38 private: 39 bool toggle; 35 40 }; 36 41
Note: See TracChangeset
for help on using the changeset viewer.