// find the best gSpawnPoint gSpawnPoint * gArena::LeastDangerousSpawnPoint() { REAL mindanger=1E+30; gSpawnPoint *ret=NULL; for(int i=0;i<spawnPoints.Len();i++) { REAL newDanger = spawnPoints(i)->Danger(); if (newDanger < mindanger - EPS ) { ret = spawnPoints(i); mindanger = newDanger; } } if (!ret) { throw tGenericException( "No spawnpoint available." ); } #ifdef DEBUG // std::cout << "Spawn at " << ret->location << "\n"; #endif return ret; }
void gArena::RemoveAllSpawn() { while (spawnPoints.Len()){ gSpawnPoint *s=spawnPoints(0); spawnPoints.Remove(s,s->id); delete s; } }
std::auto_ptr<Actor> CtfSoldierSpawnSystem::Spawn( ::core::ClientData& clientData, Team::Type team ) { map::SpawnPoints_t spawnPoints( map::ctf::CtfSoldierSpawnPointMapElementSystem::Get()->GetActiveSpawnPoints( team ) ); map::SpawnPoint spawnPoint( spawnPoints[rand() % spawnPoints.size()] ); std::auto_ptr<Actor> player( mActorFactory( mPlayerAutoId ) ); Opt<ITeamComponent> teamC( player->Get<ITeamComponent>() ); if ( teamC.IsValid() ) { teamC->SetTeam( team ); } return SoldierSpawnSystem::Get()->Spawn( clientData, spawnPoint, player ); }
gArena::~gArena() { // usually, we would write this: // RemoveAllSpawn(); // but because of a bug in GCC version 3.3.5 to 3.4.x (4.0 is unaffected), // we have to dublicate the code of the function. while (spawnPoints.Len()) { gSpawnPoint *s=spawnPoints(0); spawnPoints.Remove(s,s->id); delete s; } }
void gArena::PrepareGrid(eGrid *grid, gParser *aParser) { RemoveAllSpawn(); init_grid_in_process=true; grid->Create(); grid->SetWinding(axes); aParser->setSizeMultiplier(sizeMultiplier); aParser->Parse(); init_grid_in_process=false; int i; for(i=0;i<spawnPoints.Len();i++) spawnPoints(i)->Clear(); // update arena bounds eWallRim::UpdateBounds(); }
std::auto_ptr<Actor> SoldierSpawnSystem::Spawn( core::ClientData& clientData ) { map::SpawnPoints_t spawnPoints( map::SoldierSpawnPointMapElementSystem::Get()->GetActiveSpawnPoints() ); map::SpawnPoint spawnPoint( spawnPoints[RandomGenerator::global()() % spawnPoints.size()] ); return Spawn( clientData, spawnPoint ); }