Changeset 8838 in orxonox.OLD for branches/multi_player_map/src/util
- Timestamp:
- Jun 28, 2006, 12:44:07 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/multi_player_map/src/util/multiplayer_team_deathmatch.cc
r8827 r8838 85 85 subscribeEvent( ES_MENU, SDLK_F1 ); 86 86 subscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 ); 87 87 88 88 this->notifier = new OrxGui::GLGuiNotifier(); 89 89 this->notifier->show(); … … 106 106 unsubscribeEvent( ES_MENU, SDLK_F1 ); 107 107 unsubscribeEvent( ES_MENU, KeyMapper::PEV_FIRE1 ); 108 108 109 109 if ( this->notifier ) 110 110 { … … 219 219 if ( !SharedNetworkData::getInstance()->isGameServer() ) 220 220 return; 221 221 222 222 //handle kills 223 223 for ( std::vector<Kill>::iterator it = this->killList.begin(); it != this->killList.end(); ) 224 224 { 225 225 std::vector<Kill>::iterator delit = it; 226 226 227 227 onKill( it->getKiller()->getOwner(), it->getVictim()->getOwner() ); 228 228 229 229 it++; 230 230 killList.erase( delit ); 231 231 } 232 232 233 233 gameStateTimer -= dt; 234 234 //PRINTF(0)("TICK %f\n", gameStateTimer); … … 482 482 playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() ); 483 483 playable.setSynchronized( true ); 484 484 485 485 stats.setTeamId( stats.getPreferedTeamId() ); 486 486 stats.setPlayableClassId( playableClassId ); 487 487 stats.setPlayableUniqueId( playable.getUniqueID() ); 488 488 stats.setModelFileName( playableModel ); 489 489 490 490 this->respawnPlayable( &playable, stats.getPreferedTeamId(), 0.0f ); 491 491 … … 629 629 statsBox = new OrxGui::GLGuiBox(); 630 630 statsBox->setAbsCoor2D( 300, 100 ); 631 631 632 632 this->table = new OrxGui::GLGuiTable(0,0); 633 633 … … 647 647 statsBox = NULL; 648 648 } 649 649 650 650 EventHandler::getInstance()->popState(); 651 651 } … … 666 666 headers.push_back(""); 667 667 this->table->setHeader(headers); 668 668 669 669 std::map<int,std::string> fragsTeam0; 670 670 std::map<int,std::string> fragsTeam1; 671 671 672 672 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 673 673 674 674 if ( !list ) 675 675 return; 676 676 677 677 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 678 678 { 679 679 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 680 680 681 681 if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 ) 682 682 { … … 687 687 } 688 688 } 689 689 690 690 char st[10]; 691 691 int i = 0; 692 693 692 693 694 694 i = 2; 695 695 for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ ) … … 701 701 i++; 702 702 } 703 703 704 704 i = 2; 705 705 for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ ) … … 714 714 /** 715 715 * this function is called when a player kills another one or himself 716 * @param killedUserId 717 * @param userId 716 * @param killedUserId 717 * @param userId 718 718 */ 719 719 void MultiplayerTeamDeathmatch::onKill( int killedUserId, int userId ) … … 721 721 assert( PlayerStats::getStats( killedUserId ) ); 722 722 assert( PlayerStats::getStats( userId ) ); 723 723 724 724 PlayerStats & killedStats = *PlayerStats::getStats( killedUserId ); 725 725 PlayerStats & stats = *PlayerStats::getStats( userId ); 726 726 727 727 if ( killedUserId != userId ) 728 728 stats.setScore( stats.getScore() + 1 ); 729 729 else 730 730 stats.setScore( stats.getScore() - 1 ); 731 731 732 732 if ( killedUserId == SharedNetworkData::getInstance()->getHostID() ) 733 733 { … … 735 735 this->showStats(); 736 736 } 737 737 738 738 this->respawnPlayable( killedStats.getPlayable(), killedStats.getTeamId(), 3.0f ); 739 739 } … … 741 741 /** 742 742 * this function is called on player respawn 743 * @param userId 743 * @param userId 744 744 */ 745 745 void MultiplayerTeamDeathmatch::onRespawn( int userId ) … … 754 754 /** 755 755 * this function is called on player respawn 756 * @param we 756 * @param we 757 757 */ 758 758 void MultiplayerTeamDeathmatch::registerSpawn( WorldEntity * we ) … … 761 761 } 762 762 763 763 764 void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay ) 764 765 { 765 766 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT ); 766 767 767 768 assert( list ); 768 769 769 770 std::vector<SpawningPoint*> spList; 770 771 771 772 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 772 773 { 773 774 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 774 775 775 776 if ( sp->getTeamId() == teamId ) 776 777 spList.push_back( sp ); 777 778 } 778 779 779 780 if ( spList.size() == 0 ) 780 781 { … … 782 783 { 783 784 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 784 785 785 786 if ( sp->getTeamId() < 0 ) 786 787 spList.push_back( sp ); 787 788 } 788 789 } 789 790 790 791 assert( spList.size() != 0 ); 791 792 792 793 int n = (int)((float)spList.size() * (float)rand()/(float)RAND_MAX); 793 794 794 795 spList[n]->pushEntity( playable, delay ); 795 796 }
Note: See TracChangeset
for help on using the changeset viewer.