Changeset 9656 in orxonox.OLD for trunk/src/util/multiplayer_team_deathmatch.cc
- Timestamp:
- Aug 4, 2006, 11:01:28 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/multiplayer_team_deathmatch.cc
r9494 r9656 138 138 if ( currentGameState == GAMESTATE_PRE_GAME || currentGameState == GAMESTATE_GAME ) 139 139 { 140 if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) 141 && box == NULL 142 && (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM 143 || bShowTeamChange ) 140 if ( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) && 141 box == NULL && 142 (PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() == TEAM_NOTEAM || bShowTeamChange ) 144 143 145 144 ) … … 193 192 } 194 193 195 if ( box != NULL 196 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) 197 && PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM 198 && !bShowTeamChange 194 // if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) ) 195 // { 196 // PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM); 197 // } 198 199 // check if the menu should be removed and the game state should be entered 200 if ( box != NULL && 201 PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) && 202 PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId() != TEAM_NOTEAM && 203 !bShowTeamChange 199 204 ) 200 205 { … … 310 315 assert( false ); 311 316 } 317 312 318 313 319 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassID classId ) … … 442 448 } 443 449 450 /** 451 * this handles team changes but only on the master server 452 */ 444 453 void MultiplayerTeamDeathmatch::handleTeamChanges( ) 445 454 { … … 458 467 if ( stats.getPreferedTeamId() == TEAM_SPECTATOR || ( stats.getPreferedTeamId() >= 0 && stats.getPreferedTeamId() < numTeams ) ) 459 468 { 460 teamChange( stats.get UserId() );469 teamChange( stats.getAssignedUserId() ); 461 470 } 462 471 } … … 473 482 { 474 483 stats.setPreferedTeamId( getRandomTeam() ); 475 teamChange( stats.get UserId() );484 teamChange( stats.getAssignedUserId() ); 476 485 } 477 486 } … … 479 488 } 480 489 490 491 492 /** 493 * changes the team 494 * @param userId the user changing team (userId) 495 */ 481 496 void MultiplayerTeamDeathmatch::teamChange( int userId ) 482 497 { … … 489 504 490 505 491 ClassID playableClassId= getPlayableClassId( userId, stats.getPreferedTeamId() );492 std::string playableModel= getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );493 std::string playableTexture= getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId );494 float playableScale= getPlayableScale( userId, stats.getPreferedTeamId(), playableClassId );506 ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() ); 507 std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId ); 508 std::string playableTexture = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId ); 509 float playableScale = getPlayableScale( userId, stats.getPreferedTeamId(), playableClassId ); 495 510 496 511 BaseObject * bo = Factory::fabricate( playableClassId ); … … 507 522 playable.setSynchronized( true ); 508 523 509 stats.setTeamId( stats.getPreferedTeamId() );510 524 stats.setPlayableClassId( playableClassId ); 511 525 stats.setPlayableUniqueId( playable.getUniqueID() ); 512 526 stats.setModelFileName( playableModel ); 527 stats.setTeamId( stats.getPreferedTeamId() ); 528 529 playable.setTeam(stats.getPreferedTeamId()); 530 513 531 514 532 this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f ); … … 516 534 if ( oldPlayable ) 517 535 { 518 //if ( userId == SharedNetworkData::getInstance()->getHostID() )519 // State::getPlayer()->setPlayable( NULL );520 536 delete oldPlayable; 521 537 } 522 538 } 539 523 540 524 541 void MultiplayerTeamDeathmatch::onButtonExit( ) … … 558 575 } 559 576 560 /** 561 * function that processes events from the handler 562 * @param event: the event 563 * @todo replace SDLK_o with something from KeyMapper 564 */ 577 578 /** 579 * function that processes events from the handler 580 * @param event: the event 581 * @todo replace SDLK_o with something from KeyMapper 582 */ 565 583 void MultiplayerTeamDeathmatch::process( const Event & event ) 566 584 { … … 573 591 if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed ) 574 592 { 575 PRINTF( 0)("hide stats\n");593 PRINTF(5)("hide stats\n"); 576 594 this->hideStats(); 577 595 } 578 596 else if ( !this->statsBox && event.bPressed ) 579 597 { 580 PRINTF( 0)("show stats\n");598 PRINTF(5)("show stats\n"); 581 599 this->showStats(); 582 600 } … … 740 758 PlayerStats & killerStats = *PlayerStats::getStats( killerUserId ); 741 759 742 if ( killerStats.getPlayable() != killer || victimStats.getPlayable() != victim)743 { 744 PRINTF(0)("killerStats.getPlayable() != killer || victimStats.getPlayable() != victim\n");760 if ( killerStats.getPlayable() == NULL || victimStats.getPlayable() == NULL) 761 { 762 PRINTF(0)("killerStats.getPlayable() != NULL || victimStats.getPlayable() != NULL\n"); 745 763 PRINTF(0)("%x %x %x %x\n", killerStats.getPlayable(), killer, victimStats.getPlayable(), victim ); 746 764 PRINTF(0)("%d %d %d %d\n", killerStats.getPlayable()->getUniqueID(), killer->getUniqueID(), victimStats.getPlayable()->getUniqueID(), victim->getUniqueID() ); … … 796 814 797 815 816 /** 817 * respawns a playable in the world via spawning points 818 * @param playable the playable to respawn 819 * @param teamId the teamId to use 820 * @param delay time delay for delayed spawning 821 */ 798 822 void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay ) 799 823 {
Note: See TracChangeset
for help on using the changeset viewer.