UFO: Alien Invasion
Loading...
Searching...
No Matches
TerrainDefs Class Reference

#include <q_shared.h>

Collaboration diagram for TerrainDefs:
Collaboration graph

Public Member Functions

 TerrainDefs ()
 ~TerrainDefs ()
bool add (const TerrainDef *tdef)
 Translate color value to terrain type to random weather code.
const char * getWeather (const byte *const color)
 Translate color value to terrain type to random weather code.
float getSurvivalChance (const byte *const color) const
 Translate color value to terrain type and then to survival probability.
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.

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::TerrainDefs ( )
inline

Definition at line 417 of file q_shared.h.

References terrainDefTable.

◆ ~TerrainDefs()

TerrainDefs::~TerrainDefs ( )
inline

Definition at line 420 of file q_shared.h.

References i, MAX_TERRAINDEFS, and terrainDefTable.

Member Function Documentation

◆ add()

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.

◆ findByColor() [1/2]

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

◆ findByColor() [2/2]

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

Definition at line 393 of file q_shared.h.

References findByColor().

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

◆ findByName()

const TerrainDef * TerrainDefs::findByName ( const char * tname) const
inlineprivate

Definition at line 406 of file q_shared.h.

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

Referenced by add().

◆ getRainChance()

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().

◆ getSnowChance()

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().

◆ getSurvivalChance()

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.

◆ getTerrainName()

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.

◆ getWeather()

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().

Field Documentation

◆ terrainDefTable

const TerrainDef* TerrainDefs::terrainDefTable[MAX_TERRAINDEFS]
private

Definition at line 391 of file q_shared.h.

Referenced by add(), findByColor(), findByName(), TerrainDefs(), and ~TerrainDefs().


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