UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
TerrainDefs Class Reference

#include <q_shared.h>

Public Member Functions

 TerrainDefs ()
 
 ~TerrainDefs ()
 
bool add (const TerrainDef *tdef)
 Translate color value to terrain type to random weather code. More...
 
const char * getWeather (const byte *const color)
 Translate color value to terrain type to random weather code. More...
 
float getSurvivalChance (const byte *const color) const
 Translate color value to terrain type and then to survival probability. More...
 
float getRainChance (const byte *const color) const
 
float getSnowChance (const byte *const color) const
 
const char * getTerrainName (const byte *const color) const
 Translate color value to terrain type. More...
 

Private Member Functions

const TerrainDeffindByColor (const byte *const color) const
 
const TerrainDeffindByColor (byte red, byte green, byte blue) const
 
const TerrainDeffindByName (const char *tname) const
 

Private Attributes

const TerrainDefterrainDefTable [MAX_TERRAINDEFS]
 

Detailed Description

Definition at line 389 of file q_shared.h.

Constructor & Destructor Documentation

TerrainDefs::TerrainDefs ( )
inline

Definition at line 417 of file q_shared.h.

TerrainDefs::~TerrainDefs ( )
inline

Definition at line 420 of file q_shared.h.

References i, and MAX_TERRAINDEFS.

Member Function Documentation

bool TerrainDefs::add ( const TerrainDef tdef)

Translate color value to terrain type to random weather code.

Parameters
[in]tdefThe terrain definition to add

Definition at line 53 of file q_shared.cpp.

References findByColor(), findByName(), i, MAX_TERRAINDEFS, TerrainDef::rgbBlue, TerrainDef::rgbGreen, TerrainDef::rgbRed, terrainDefTable, and TerrainDef::terrainName.

Referenced by Com_ParseTerrainDefinition().

const TerrainDef* TerrainDefs::findByColor ( const byte *const  color) const
inlineprivate

Definition at line 393 of file q_shared.h.

Referenced by add(), getRainChance(), getSnowChance(), getSurvivalChance(), and getTerrainName().

const TerrainDef* TerrainDefs::findByColor ( byte  red,
byte  green,
byte  blue 
) const
inlineprivate
const TerrainDef* TerrainDefs::findByName ( const char *  tname) const
inlineprivate

Definition at line 406 of file q_shared.h.

References i, MAX_TERRAINDEFS, Q_streq, and TerrainDef::terrainName.

Referenced by add().

float TerrainDefs::getRainChance ( const byte *const  color) const
inline

Definition at line 439 of file q_shared.h.

References findByColor(), and TerrainDef::rainChance.

Referenced by getWeather().

float TerrainDefs::getSnowChance ( const byte *const  color) const
inline

Definition at line 443 of file q_shared.h.

References findByColor(), and TerrainDef::snowChance.

Referenced by getWeather().

float TerrainDefs::getSurvivalChance ( const byte *const  color) const
inline

Translate color value to terrain type and then to survival probability.

Parameters
[in]colorthe color value from the terrain mask
Returns
the relative probability for survival (of pilots) in such a terrain

Definition at line 435 of file q_shared.h.

References findByColor(), and TerrainDef::survivalChance.

Referenced by AIR_PilotSurvivedCrash().

const char* TerrainDefs::getTerrainName ( const byte *const  color) const
inline

Translate color value to terrain type.

Parameters
[in]colorthe color value from the terrain mask
Returns
returns the zone name
Note
never may return a null pointer or an empty string
Make sure that there are textures with the same name in base/textures/tex_terrain

Definition at line 455 of file q_shared.h.

References findByColor(), and TerrainDef::terrainName.

Referenced by AIRFIGHT_ActionsAfterAirfight(), CP_CreateBattleParameters(), and GEO_GetTerrainTypeByPos().

const char * TerrainDefs::getWeather ( const byte *const  color)

Translate color value to terrain type to random weather code.

Parameters
[in]colorThe color value from the terrain mask
Returns
returns The weather code as a string. "0"= sunny, "1" = rain,...
Note
never may return a null pointer or an empty string

Definition at line 78 of file q_shared.cpp.

References EQUAL_EPSILON, frand(), getRainChance(), and getSnowChance().

Referenced by CP_CreateBattleParameters().

Field Documentation

const TerrainDef* TerrainDefs::terrainDefTable[MAX_TERRAINDEFS]
private

Definition at line 391 of file q_shared.h.

Referenced by add().


The documentation for this class was generated from the following files: