Changeset 9705 in orxonox.OLD for branches/new_class_id/src/util/multiplayer_team_deathmatch.cc
- Timestamp:
- Aug 25, 2006, 9:44:53 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/util/multiplayer_team_deathmatch.cc
r9704 r9705 56 56 */ 57 57 MultiplayerTeamDeathmatch::MultiplayerTeamDeathmatch(const TiXmlElement* root) 58 : NetworkGameRules(root)58 : NetworkGameRules(root) 59 59 { 60 60 this->registerObject(this, MultiplayerTeamDeathmatch::_objectList); … … 111 111 112 112 LoadParam(root, "death-penalty-timeout", this, MultiplayerTeamDeathmatch, setDeathPenaltyTimeout) 113 113 .describe("sets the time in seconds a player has to wait for respawn"); 114 114 115 115 LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills) 116 116 .describe("sets the maximal kills for winning condition"); 117 117 118 118 LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams) 119 119 .describe("sets number of teams"); 120 120 121 121 } … … 189 189 } 190 190 191 // if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) )192 // {193 // PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM);194 // }191 // if( PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() ) ) 192 // { 193 // PRINTF(0)("prefered team id: %i, noteam: %i\n", PlayerStats::getStats( SharedNetworkData::getInstance()->getHostID() )->getPreferedTeamId(), TEAM_NOTEAM); 194 // } 195 195 196 196 // check if the menu should be removed and the game state should be entered … … 270 270 if( unlikely( this->bLocalPlayerDead)) 271 271 { 272 273 272 } 274 273 } … … 305 304 { 306 305 if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR ) 307 return CL_SPECTATOR;306 return NewObjectListBase::retrieveIdentity("Spectator"); 308 307 309 308 if ( team == 0 || team == 1 ) 310 return CL_TURBINE_HOVER;309 return NewObjectListBase::retrieveIdentity("TurbineHover"); 311 310 312 311 assert( false ); … … 314 313 315 314 316 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassIDclassId )315 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, const NewClassID& classId ) 317 316 { 318 317 if (classId == CL_TURBINE_HOVER) 319 return "models/ships/hoverglider_mainbody.obj";318 return "models/ships/hoverglider_mainbody.obj"; 320 319 if ( team == 0 ) 321 320 return "models/creatures/doom_guy.md2"; … … 326 325 } 327 326 328 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, ClassIDclassId )327 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, const NewClassID& classId ) 329 328 { 330 329 if ( classId == CL_FPS_PLAYER ) … … 339 338 } 340 339 341 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, ClassIDclassId )342 { 343 if ( classId == CL_FPS_PLAYER)340 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, const NewClassID& classId ) 341 { 342 if ( classId == NewObjectListBase::retrieveIdentity(CL_FPS_PLAYER)) 344 343 { 345 344 return 10.0f; … … 359 358 teamScore[i] = 0; 360 359 361 362 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 363 364 if ( !list ) 365 return; 366 367 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 368 { 369 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 360 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 361 it != PlayerStats::objectList().end(); 362 ++it) 363 { 364 PlayerStats & stats = *(*it); 370 365 371 366 if ( stats.getTeamId() >= 0 ) … … 387 382 playersInTeam[i] = 0; 388 383 389 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 390 391 if ( !list ) 392 return 0; 393 394 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 395 { 396 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 384 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 385 it != PlayerStats::objectList().end(); 386 ++it) 387 { 388 PlayerStats & stats = *(*it); 397 389 398 390 if ( stats.getTeamId() >= 0 ) … … 450 442 void MultiplayerTeamDeathmatch::handleTeamChanges( ) 451 443 { 452 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 453 454 if ( !list ) 455 return; 456 457 //first server players with choices 458 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 459 { 460 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 444 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 445 it != PlayerStats::objectList().end(); 446 ++it) 447 { 448 PlayerStats & stats = *(*it); 461 449 462 450 if ( stats.getTeamId() != stats.getPreferedTeamId() ) … … 470 458 471 459 //now serve player who want join a random team 472 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 473 { 474 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 460 for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 461 it != PlayerStats::objectList().end(); 462 ++it) 463 { 464 PlayerStats & stats = *(*it); 475 465 476 466 if ( stats.getTeamId() != stats.getPreferedTeamId() ) … … 501 491 502 492 503 ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );493 NewClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() ); 504 494 std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId ); 505 495 std::string playableTexture = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId ); … … 584 574 if ( event.bPressed ) 585 575 this->bShowTeamChange = true; 586 } else if ( event.type == SDLK_F1 ) 576 } 577 else if ( event.type == SDLK_F1 ) 587 578 { 588 579 if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed ) … … 680 671 void MultiplayerTeamDeathmatch::hideStats( ) 681 672 { 682 683 684 685 686 673 if ( statsBox ) 674 { 675 delete statsBox; 676 statsBox = NULL; 677 } 687 678 } 688 679 … … 819 810 void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay ) 820 811 { 821 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );822 823 assert( list );824 812 825 813 std::vector<SpawningPoint*> spList; 826 814 827 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 828 { 829 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 815 for (NewObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin(); 816 it != SpawningPoint::objectList().end(); 817 ++it) 818 { 819 SpawningPoint * sp = (*it); 830 820 831 821 if ( sp->getTeamId() == teamId ) … … 835 825 if ( spList.size() == 0 ) 836 826 { 837 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 838 { 839 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 827 for (NewObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin(); 828 it != SpawningPoint::objectList().end(); 829 ++it) 830 { 831 SpawningPoint * sp = (*it); 840 832 841 833 if ( sp->getTeamId() < 0 )
Note: See TracChangeset
for help on using the changeset viewer.