gArena Class Reference

#include <gArena.h>

Collaboration diagram for gArena:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void NewSpawnPoint (const eCoord &loc, const eCoord &dir)
 gArena ()
virtual ~gArena ()
virtual void PrepareGrid (eGrid *grid, gParser *aParser)
virtual eCoord GetRandomPos (REAL factor) const
gSpawnPointLeastDangerousSpawnPoint ()
void RemoveAllSpawn ()

Static Public Member Functions

static float SizeMultiplier ()
static void SetSizeMultiplier (float mult)
static float GetSizeMultiplier ()

Private Attributes

tList< gSpawnPointspawnPoints
 the list of active spawn points

Friends

class gSpawnPoint
class gParser


Detailed Description

Definition at line 40 of file gArena.h.


Constructor & Destructor Documentation

gArena::gArena (  ) 

Definition at line 46 of file gArena.cpp.

00046               :spawnPoints()
00047 {
00048 }

gArena::~gArena (  )  [virtual]

Definition at line 64 of file gArena.cpp.

References gSpawnPoint::id, GrowingArrayBase::Len(), tList< T, MALLOC, REFERENCE >::Remove(), and spawnPoints.

00065 {
00066     // usually, we would write this:
00067     // RemoveAllSpawn();
00068 
00069     // but because of a bug in GCC version 3.3.5 to 3.4.x (4.0 is unaffected),
00070     // we have to dublicate the code of the function.
00071     while (spawnPoints.Len())
00072     {
00073         gSpawnPoint *s=spawnPoints(0);
00074         spawnPoints.Remove(s,s->id);
00075         delete s;
00076     }
00077 }

Here is the call graph for this function:


Member Function Documentation

void gArena::NewSpawnPoint ( const eCoord &  loc,
const eCoord &  dir 
)

Definition at line 50 of file gArena.cpp.

References tList< T, MALLOC, REFERENCE >::Add(), gSpawnPoint::id, spawnPoints, and tNEW.

Referenced by gParser::parseSpawn().

00050                                                              {
00051     gSpawnPoint *s=tNEW(gSpawnPoint) (loc,dir);
00052     spawnPoints.Add(s,s->id);
00053 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gArena::PrepareGrid ( eGrid grid,
gParser aParser 
) [virtual]

Definition at line 96 of file gArena.cpp.

References axes, tArray< T, MALLOC >::Clear(), eGrid::Create(), init_grid_in_process, GrowingArrayBase::Len(), gParser::Parse(), RemoveAllSpawn(), gParser::setSizeMultiplier(), eGrid::SetWinding(), sizeMultiplier, spawnPoints, and eWallRim::UpdateBounds().

Referenced by init_game_grid().

00097 {
00098     RemoveAllSpawn();
00099 
00100     init_grid_in_process=true;
00101     grid->Create();
00102     grid->SetWinding(axes);
00103 
00104     aParser->setSizeMultiplier(sizeMultiplier);
00105     aParser->Parse();
00106 
00107     init_grid_in_process=false;
00108 
00109     int i;
00110     for(i=0;i<spawnPoints.Len();i++)
00111         spawnPoints(i)->Clear();
00112 
00113     // update arena bounds
00114     eWallRim::UpdateBounds();
00115 }

Here is the call graph for this function:

Here is the caller graph for this function:

eCoord gArena::GetRandomPos ( REAL  factor  )  const [virtual]

Definition at line 84 of file gArena.cpp.

References eCoord, tRandomizer::Get(), eWallRim::GetBounds(), tReproducibleRandomizer::GetInstance(), eRectangle::GetPoint(), REAL, and x.

Referenced by gGame::Analysis().

00085 {
00086     tRandomizer & randomizer = tReproducibleRandomizer::GetInstance();
00087     REAL x = randomizer.Get();
00088     REAL y = randomizer.Get();
00089     //  REAL x = REAL(rand())/RAND_MAX;
00090     //  REAL y = REAL(rand())/RAND_MAX;
00091 
00092     //    return eCoord( sizeMultiplier * 500.0 * ( x * factor + .5f * ( 1 - factor ) ), sizeMultiplier * 500.0 * ( y * factor + .5f * ( 1 - factor ) ) );
00093     return eWallRim::GetBounds().GetPoint( eCoord( x * factor + .5f * ( 1 - factor ), y * factor + .5f * ( 1 - factor ) ) );
00094 }

Here is the call graph for this function:

Here is the caller graph for this function:

gSpawnPoint * gArena::LeastDangerousSpawnPoint (  ) 

Definition at line 118 of file gArena.cpp.

References EPS, GrowingArrayBase::Len(), NULL, REAL, spawnPoints, and tERR_ERROR.

Referenced by init_game_objects(), and sg_RespawnPlayer().

00119 {
00120     REAL mindanger=1E+30;
00121     gSpawnPoint *ret=NULL;
00122 
00123     for(int i=0;i<spawnPoints.Len();i++)
00124     {
00125         REAL newDanger = spawnPoints(i)->Danger();
00126         if (newDanger < mindanger - EPS )
00127         {
00128             ret = spawnPoints(i);
00129             mindanger = newDanger;
00130         }
00131     }
00132 
00133     if (!ret)
00134         tERR_ERROR("No spawnpoint available!");
00135 
00136 #ifdef DEBUG
00137     //  std::cout << "Spawn at " << ret->location << "\n";
00138 #endif
00139 
00140     return ret;
00141 }

Here is the call graph for this function:

Here is the caller graph for this function:

float gArena::SizeMultiplier (  )  [static]

Definition at line 143 of file gArena.cpp.

References sizeMultiplier.

Referenced by gAIPlayer::EmergencySurvive(), gAIPlayer::NewObject(), gCycle::Render(), and gSpawnPoint::Spawn().

00144 {
00145     return sizeMultiplier;
00146 }

Here is the caller graph for this function:

void gArena::SetSizeMultiplier ( float  mult  )  [static]

Definition at line 148 of file gArena.cpp.

References conf_mult.

Referenced by sg_copySettings().

00149 {
00150     conf_mult.Set( mult );
00151 }

Here is the caller graph for this function:

float gArena::GetSizeMultiplier (  )  [static]

Definition at line 153 of file gArena.cpp.

References sizeMultiplier.

Referenced by gParser::parseSettings().

00154 {
00155     return sizeMultiplier;
00156 }

Here is the caller graph for this function:

void gArena::RemoveAllSpawn (  ) 

Definition at line 56 of file gArena.cpp.

References gSpawnPoint::id, GrowingArrayBase::Len(), tList< T, MALLOC, REFERENCE >::Remove(), and spawnPoints.

Referenced by PrepareGrid().

00056                             {
00057     while (spawnPoints.Len()){
00058         gSpawnPoint *s=spawnPoints(0);
00059         spawnPoints.Remove(s,s->id);
00060         delete s;
00061     }
00062 }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class gSpawnPoint [friend]

Definition at line 41 of file gArena.h.

friend class gParser [friend]

Definition at line 42 of file gArena.h.


Member Data Documentation

tList<gSpawnPoint> gArena::spawnPoints [private]

the list of active spawn points

Definition at line 67 of file gArena.h.

Referenced by LeastDangerousSpawnPoint(), NewSpawnPoint(), PrepareGrid(), RemoveAllSpawn(), and ~gArena().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:33:48 2008 for Armagetron Advanced by  doxygen 1.5.4