Changeset 9869 in orxonox.OLD for trunk/src/util/multiplayer_team_deathmatch.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/multiplayer_team_deathmatch.cc
r9656 r9869 24 24 #include "render2D/image_plane.h" 25 25 #include "state.h" 26 #include "class_list.h"27 26 28 27 #include "player.h" … … 33 32 #include "shared_network_data.h" 34 33 #include "terrain.h" 35 #include "class_list.h"36 34 #include "space_ships/space_ship.h" 37 35 … … 50 48 51 49 52 53 54 CREATE_FACTORY(MultiplayerTeamDeathmatch, CL_MULTIPLAYER_TEAM_DEATHMATCH); 55 56 50 #include "class_id_DEPRECATED.h" 51 52 ObjectListDefinitionID(MultiplayerTeamDeathmatch, CL_MULTIPLAYER_TEAM_DEATHMATCH); 53 CREATE_FACTORY(MultiplayerTeamDeathmatch); 57 54 /** 58 55 * constructor 59 56 */ 60 57 MultiplayerTeamDeathmatch::MultiplayerTeamDeathmatch(const TiXmlElement* root) 61 : NetworkGameRules(root)62 { 63 this-> setClassID(CL_MULTIPLAYER_TEAM_DEATHMATCH, "MultiplayerTeamDeathmatch");58 : NetworkGameRules(root) 59 { 60 this->registerObject(this, MultiplayerTeamDeathmatch::_objectList); 64 61 65 62 this->bLocalPlayerDead = false; … … 114 111 115 112 LoadParam(root, "death-penalty-timeout", this, MultiplayerTeamDeathmatch, setDeathPenaltyTimeout) 116 113 .describe("sets the time in seconds a player has to wait for respawn"); 117 114 118 115 LoadParam(root, "max-kills", this, MultiplayerTeamDeathmatch, setMaxKills) 119 116 .describe("sets the maximal kills for winning condition"); 120 117 121 118 LoadParam(root, "num-teams", this, MultiplayerTeamDeathmatch, setNumTeams) 122 119 .describe("sets number of teams"); 123 120 124 121 } … … 192 189 } 193 190 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 // }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 // } 198 195 199 196 // check if the menu should be removed and the game state should be entered … … 273 270 if( unlikely( this->bLocalPlayerDead)) 274 271 { 275 276 272 } 277 273 } … … 308 304 { 309 305 if ( team == TEAM_NOTEAM || team == TEAM_SPECTATOR ) 310 return CL_SPECTATOR;306 return ObjectListBase::retrieveIdentity("Spectator"); 311 307 312 308 if ( team == 0 || team == 1 ) 313 return CL_TURBINE_HOVER;309 return ObjectListBase::retrieveIdentity("TurbineHover"); 314 310 315 311 assert( false ); … … 317 313 318 314 319 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, ClassIDclassId )315 std::string MultiplayerTeamDeathmatch::getPlayableModelFileName( int userId, int team, const ClassID& classId ) 320 316 { 321 317 if (classId == CL_TURBINE_HOVER) 322 return "models/ships/hoverglider_mainbody.obj";318 return "models/ships/hoverglider_mainbody.obj"; 323 319 if ( team == 0 ) 324 320 return "models/creatures/doom_guy.md2"; … … 329 325 } 330 326 331 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, ClassIDclassId )327 std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, const ClassID& classId ) 332 328 { 333 329 if ( classId == CL_FPS_PLAYER ) … … 342 338 } 343 339 344 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, ClassIDclassId )345 { 346 if ( classId == CL_FPS_PLAYER)340 float MultiplayerTeamDeathmatch::getPlayableScale( int userId, int team, const ClassID& classId ) 341 { 342 if ( classId == ObjectListBase::retrieveIdentity(CL_FPS_PLAYER)) 347 343 { 348 344 return 10.0f; … … 362 358 teamScore[i] = 0; 363 359 364 365 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 366 367 if ( !list ) 368 return; 369 370 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 371 { 372 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 360 for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 361 it != PlayerStats::objectList().end(); 362 ++it) 363 { 364 PlayerStats & stats = *(*it); 373 365 374 366 if ( stats.getTeamId() >= 0 ) … … 390 382 playersInTeam[i] = 0; 391 383 392 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 393 394 if ( !list ) 395 return 0; 396 397 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 398 { 399 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 384 for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 385 it != PlayerStats::objectList().end(); 386 ++it) 387 { 388 PlayerStats & stats = *(*it); 400 389 401 390 if ( stats.getTeamId() >= 0 ) … … 453 442 void MultiplayerTeamDeathmatch::handleTeamChanges( ) 454 443 { 455 const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS ); 456 457 if ( !list ) 458 return; 459 460 //first server players with choices 461 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 462 { 463 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 444 for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 445 it != PlayerStats::objectList().end(); 446 ++it) 447 { 448 PlayerStats & stats = *(*it); 464 449 465 450 if ( stats.getTeamId() != stats.getPreferedTeamId() ) … … 473 458 474 459 //now serve player who want join a random team 475 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 476 { 477 PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it); 460 for (ObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin(); 461 it != PlayerStats::objectList().end(); 462 ++it) 463 { 464 PlayerStats & stats = *(*it); 478 465 479 466 if ( stats.getTeamId() != stats.getPreferedTeamId() ) … … 587 574 if ( event.bPressed ) 588 575 this->bShowTeamChange = true; 589 } else if ( event.type == SDLK_F1 ) 576 } 577 else if ( event.type == SDLK_F1 ) 590 578 { 591 579 if ( this->statsBox && !this->bLocalPlayerDead && event.bPressed ) … … 683 671 void MultiplayerTeamDeathmatch::hideStats( ) 684 672 { 685 686 687 688 689 673 if ( statsBox ) 674 { 675 delete statsBox; 676 statsBox = NULL; 677 } 690 678 } 691 679 … … 822 810 void MultiplayerTeamDeathmatch::respawnPlayable( Playable * playable, int teamId, float delay ) 823 811 { 824 const std::list<BaseObject*> * list = ClassList::getList( CL_SPAWNING_POINT );825 826 assert( list );827 812 828 813 std::vector<SpawningPoint*> spList; 829 814 830 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 831 { 832 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 815 for (ObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin(); 816 it != SpawningPoint::objectList().end(); 817 ++it) 818 { 819 SpawningPoint * sp = (*it); 833 820 834 821 if ( sp->getTeamId() == teamId ) … … 838 825 if ( spList.size() == 0 ) 839 826 { 840 for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ ) 841 { 842 SpawningPoint * sp = dynamic_cast<SpawningPoint*>(*it); 827 for (ObjectList<SpawningPoint>::const_iterator it = SpawningPoint::objectList().begin(); 828 it != SpawningPoint::objectList().end(); 829 ++it) 830 { 831 SpawningPoint * sp = (*it); 843 832 844 833 if ( sp->getTeamId() < 0 )
Note: See TracChangeset
for help on using the changeset viewer.