- Timestamp:
- Jan 11, 2006, 5:06:43 PM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_game_manager.cc
r6483 r6493 28 28 #include "game_world.h" 29 29 #include "world_entity.h" 30 #include "playable.h" 31 #include "player.h" 30 32 #include "network_manager.h" 31 33 … … 166 168 return SYNCHELP_WRITE_N; 167 169 } 170 168 171 for ( int i = 0; i<outBuffer.size(); i++ ) 169 172 { … … 216 219 * @param classID: The ID of the class of which an entity should be created 217 220 */ 218 void NetworkGameManager::createEntity( ClassID classID, int owner ) 219 { 221 int NetworkGameManager::createEntity( ClassID classID, int owner ) 222 { 223 220 224 if ( this->isServer() ) 221 225 { … … 223 227 { 224 228 PRINTF(1)("Cannot create entity! There are no more uniqueIDs left!\n"); 225 return ;226 } 227 228 this->executeCreateEntity( classID, newUniqueID++, owner );229 return -1; 230 } 231 232 return this->executeCreateEntity( classID, newUniqueID++, owner ); 229 233 } 230 234 else 231 235 { 232 236 this->requestCreateEntity( classID ); 237 return -1; 233 238 } 234 239 } … … 331 336 * @param classID: The ID of the class of which an entity should be created 332 337 */ 333 voidNetworkGameManager::executeCreateEntity(ClassID classID, int uniqueID, int owner)338 int NetworkGameManager::executeCreateEntity(ClassID classID, int uniqueID, int owner) 334 339 { 335 340 if ( !writeToClientBuffer( allOutBuffer, (byte)CREATE_ENTITY ) ) 336 return ;341 return -1; 337 342 if ( !writeToClientBuffer( allOutBuffer, (int)classID ) ) 338 return ;343 return -1; 339 344 if ( !writeToClientBuffer( allOutBuffer, uniqueID ) ) 340 return ;345 return -1; 341 346 if ( !writeToClientBuffer( allOutBuffer, owner ) ) 342 return ;347 return -1; 343 348 344 349 doCreateEntity( classID, uniqueID, owner ); 350 351 return uniqueID; 345 352 } 346 353 … … 412 419 } 413 420 414 415 } 421 signalNewPlayer( userID ); 422 } 423 424 425 426 bool NetworkGameManager::signalNewPlayer(int userId) 427 { 428 429 /* create new playable for Player*/ 430 PRINTF(0)("Request for creation: %i\n", userId); 431 int uniqueId = this->createEntity(CL_SPACE_SHIP, userId); 432 PRINTF(0)("Request for creation: userid: %i, uniqueid: %i\n", userId, uniqueId); 433 this->sendYouAre(uniqueId, userId); 434 435 } 436 416 437 417 438 /** … … 571 592 void NetworkGameManager::doYouAre( int uniqueID ) 572 593 { 573 //TODO: what has to be done 594 595 SynchronizeableList::const_iterator it = this->networkStream->getSyncBegin(); 596 597 Playable *p = NULL; 598 599 for ( ; it !=networkStream->getSyncEnd(); it++ ) 600 { 601 if ( (*it)->getUniqueID()==uniqueID ) 602 { 603 if ( (*it)->isA( CL_PLAYABLE ) ) 604 { 605 p = dynamic_cast<Playable*>(*it); 606 break; 607 } else 608 { 609 PRINTF(1)("UniqueID is not a Playable\n"); 610 } 611 } 612 } 613 614 Player* player = State::getPlayer(); 615 assert(p != NULL); 616 assert(player != NULL); 617 618 player->setControllable(p); 619 620 574 621 } 575 622 -
branches/network/src/lib/network/network_game_manager.h
r6424 r6493 74 74 virtual void readDebug() const; 75 75 76 voidcreateEntity( ClassID classID, int owner = 0 );76 int createEntity( ClassID classID, int owner = 0 ); 77 77 BaseObject* createEntity(const TiXmlElement* element); 78 78 void removeEntity( int uniqueID ); … … 87 87 88 88 void requestCreateEntity(ClassID classID); 89 voidexecuteCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0);89 int executeCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0); 90 90 91 91 void requestRemoveEntity(int uniqueID); … … 100 100 101 101 bool canCreateEntity(ClassID classID); 102 103 bool signalNewPlayer(int userId); 102 104 103 105 void resizeBufferVector(int n); -
branches/network/src/lib/network/network_stream.cc
r6483 r6493 192 192 else 193 193 { 194 //this->networkGameManager->sendEntityList( i ); 194 195 195 } 196 196 PRINT(0)("handshake finished id=%d\n", handshakes[i]->getNetworkGameManagerId()); -
branches/network/src/story_entities/multi_player_world_data.cc
r6466 r6493 160 160 } 161 161 } 162 else if( !strcmp( element->Value(), "SpaceShip")) /// FIXME it is not said to be a SpaceShip163 {164 BaseObject* created = NetworkGameManager::getInstance()->createEntity(element);165 if( created != NULL )166 PRINTF(1)("Created a %s: %s (%8.u)\n", created->getClassName(), created->getName(), created->getLeafClassID());167 else168 PRINTF(1)("MultiPlayerWorld: could not create this entity\n");169 }170 162 element = element->NextSiblingElement(); 163 171 164 172 165 glmis->step(); … … 174 167 } 175 168 176 177 /* create a Player */ 178 this->localPlayer = new Player(); 179 // Playable* playable; 180 // const std::list<BaseObject*>* playableList = ClassList::getList(CL_PLAYABLE); 181 // assert( playableList != NULL); 182 // 183 // if (playableList != NULL) 184 // { 185 // playable = dynamic_cast<Playable*>(playableList->front()); 186 // this->localPlayer->setControllable(playable); 187 // } 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); 189 } 190 188 191 189 192 /* init the pnode tree */ -
branches/network/src/util/state.cc
r6459 r6493 33 33 StoryEntity* State::storyEntity = NULL; 34 34 35 Player* State::player = NULL; 36 35 37 /** 36 38 * sets camera and target of the current Camera -
branches/network/src/util/state.h
r6459 r6493 11 11 class PNode; 12 12 class WorldEntity; 13 class Player; 13 14 class ObjectManager; 14 15 class StoryEntity; … … 49 50 static inline StoryEntity* getCurrentStoryEntity() { return State::storyEntity; }; 50 51 52 ////////////// 53 /// PLAYER /// 54 ////////////// 55 /** @param storyEntity sets the current StoryEntity that is been played */ 56 static inline void setPlayer(Player* player) { State::player = player; }; 57 /** @returns the current StoryEntity played */ 58 static inline Player* getPlayer() { return State::player; }; 51 59 52 60 ///////////////////////// … … 62 70 static ObjectManager* objectManager; //!< A reference to the current ObjectManager 63 71 static StoryEntity* storyEntity; //!< A reference to the current StoryEntity played 72 static Player* player; //!< A reference to the Player 64 73 65 74 }; -
branches/network/src/world_entities/power_ups/power_up.cc
r6424 r6493 96 96 } 97 97 98 99 100 /******************************************************************************************** 101 NETWORK STUFF 102 ********************************************************************************************/ 103 104 98 105 /** 99 106 * data copied in data will bee sent to another host … … 108 115 return SYNCHELP_WRITE_N; 109 116 } 117 110 118 111 119 /** -
branches/network/src/world_entities/power_ups/turret_power_up.cc
r6424 r6493 119 119 } 120 120 121 122 123 124 /******************************************************************************************** 125 NETWORK STUFF 126 ********************************************************************************************/ 127 128 121 129 int TurretPowerUp::writeBytes( const byte * data, int length, int sender ) 122 130 { … … 130 138 return SYNCHELP_READ_N; 131 139 } 132 133 140 134 141 -
branches/network/src/world_entities/world_entity.cc
r6469 r6493 370 370 371 371 372 373 374 /******************************************************************************************** 375 NETWORK STUFF 376 ********************************************************************************************/ 377 378 372 379 /** 373 380 * Writes data from network containing information about the state … … 417 424 } 418 425 426 419 427 /** 420 428 * data copied in data will bee sent to another host
Note: See TracChangeset
for help on using the changeset viewer.