Changeset 6493 in orxonox.OLD for branches/network/src/lib/network/network_game_manager.cc
- Timestamp:
- Jan 11, 2006, 5:06:43 PM (18 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.