UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_geoscape.cpp File Reference

Geoscape/Map management. More...

#include "../../cl_shared.h"
#include "../../ui/ui_dataids.h"
#include "../../ui/node/ui_node_geoscape.h"
#include "cp_overlay.h"
#include "cp_campaign.h"
#include "cp_geoscape.h"
#include "cp_popup.h"
#include "cp_mapfightequip.h"
#include "cp_missions.h"
#include "cp_ufo.h"
#include "cp_time.h"
#include "cp_xvi.h"

Go to the source code of this file.

Macros

#define GLOBE_ROTATE   -90
 
#define ZOOM_LIMIT   2.5f
 
#define UI_MAP_DIST_SELECTION   15
 maximum distance (in pixel) to get a valid mouse click More...
 
#define CIRCLE_DRAW_POINTS   60
 
#define BULLET_SIZE   1
 
#define SELECT_CIRCLE_RADIUS   1.5f + 3.0f / UI_MAPEXTRADATACONST(node).zoom
 

Functions

static bool GEO_IsPositionSelected (const uiNode_t *node, const vec2_t pos, int x, int y)
 Tell if the specified position is considered clicked. More...
 
bool GEO_IsRadarOverlayActivated (void)
 
static bool GEO_IsNationOverlayActivated (void)
 
static bool GEO_IsXVIOverlayActivated (void)
 
bool GEO_Click (const uiNode_t *node, int x, int y, const vec2_t pos)
 Click on the map/geoscape. More...
 
static bool GEO_3DMapToScreen (const uiNode_t *node, const vec2_t pos, int *x, int *y, int *z)
 Transform a 2D position on the map to screen coordinates. More...
 
static bool GEO_MapToScreen (const uiNode_t *node, const vec2_t pos, int *x, int *y)
 Transform a 2D position on the map to screen coordinates. More...
 
static bool GEO_AllMapToScreen (const uiNode_t *node, const vec2_t pos, int *x, int *y, int *z)
 Call either GEO_MapToScreen or GEO_3DMapToScreen depending on the geoscape you're using. More...
 
static void GEO_Draw3DMarkerIfVisible (const uiNode_t *node, const vec2_t pos, float theta, const char *model, int skin)
 Draws a 3D marker on geoscape if the player can see it. More...
 
void GEO_CalcLine (const vec2_t start, const vec2_t end, mapline_t *line)
 Calculate the shortest way to go from start to end on a sphere. More...
 
static void GEO_MapDrawLine (const uiNode_t *node, const mapline_t *line)
 Draw a path on a menu node (usually the 2D geoscape map) More...
 
static void GEO_3DMapDrawLine (const uiNode_t *node, const mapline_t *line)
 Draw a path on a menu node (usually the 3Dgeoscape map) More...
 
static void GEO_MapDrawEquidistantPoints (const uiNode_t *node, const vec2_t center, const float angle, const vec4_t color)
 Draw equidistant points from a given point on a menu node. More...
 
static float GEO_AngleOfPath3D (const vec2_t start, const vec2_t end, vec3_t direction, vec3_t ortVector)
 Return the angle of a model given its position and destination, on 3D geoscape. More...
 
static float GEO_AngleOfPath2D (const vec2_t start, const vec2_t end, vec3_t direction, vec3_t ortVector)
 Return the angle of a model given its position and destination, on 2D geoscape. More...
 
float GEO_AngleOfPath (const vec2_t start, const vec2_t end, vec3_t direction, vec3_t ortVector)
 Select which function should be used for calculating the direction of model on 2D or 3D geoscape. More...
 
static void GEO_ConvertObjectPositionToGeoscapePosition (bool flatgeoscape, float *vector, const vec2_t objectPos)
 Will set the vector for the geoscape position. More...
 
static void GEO_GetMissionAngle (bool flatgeoscape, float *vector, int id)
 center to a mission More...
 
static void GEO_GetUFOAngle (bool flatgeoscape, float *vector, int idx)
 center to a ufo More...
 
static void GEO_StartCenter (uiNode_t *node)
 Start center to the selected point. More...
 
void GEO_CenterPosition (const vec2_t pos)
 Start to rotate or shift the globe to the given position. More...
 
static void GEO_SelectObject_f (void)
 Center the view and select an object from the geoscape. More...
 
static void GEO_GetGeoscapeAngle (vec2_t pos)
 Returns position of the model corresponding to centerOnEventIdx. More...
 
void GEO_CenterOnPoint_f (void)
 Switch to next model on 2D and 3D geoscape. More...
 
static void GEO_DrawBullets (const uiNode_t *node, const vec3_t pos)
 Draws a bunch of bullets on the geoscape map. More...
 
static void GEO_DrawBeam (const uiNode_t *node, const vec3_t start, const vec3_t end, const vec4_t color)
 Draws a energy beam on the geoscape map (laser/particle) More...
 
static void GEO_RenderImage (int x, int y, const char *image)
 
static void GEO_DrawMapOneMission (const uiNode_t *node, const mission_t *mission)
 Draws one mission on the geoscape map (2D and 3D) More...
 
static void GEO_DrawRadarLineCoverage (const uiNode_t *node, const radar_t *radar, const vec2_t pos)
 Draw only the "wire" Radar coverage. More...
 
static void GEO_DrawRadarInMap (const uiNode_t *node, const radar_t *radar, const vec2_t pos)
 Draw only the "wire" part of the radar coverage in geoscape. More...
 
static void GEO_DrawMapOneInstallation (const uiNode_t *node, const installation_t *installation, bool oneUFOVisible, const char *font)
 Draws one installation on the geoscape map (2D and 3D) More...
 
static void GEO_DrawMapOneBase (const uiNode_t *node, const base_t *base, bool oneUFOVisible, const char *font)
 Draws one base on the geoscape map (2D and 3D) More...
 
static void GEO_DrawAircraftHealthBar (const uiNode_t *node, const aircraft_t *aircraft)
 Draws health bar for an aircraft (either phalanx or ufo) More...
 
static void GEO_DrawMapOnePhalanxAircraft (const uiNode_t *node, aircraft_t *aircraft, bool oneUFOVisible)
 Draws one Phalanx aircraft on the geoscape map (2D and 3D) More...
 
static const char * GEO_GetMissionText (char *buffer, size_t size, const mission_t *mission)
 Assembles a string for a mission that is on the geoscape. More...
 
static const char * GEO_GetAircraftText (char *buffer, size_t size, const aircraft_t *aircraft)
 Assembles a string for an aircraft that is on the geoscape. More...
 
static const char * GEO_GetUFOText (char *buffer, size_t size, const aircraft_t *ufo)
 Assembles a string for a UFO that is on the geoscape. More...
 
void GEO_UpdateGeoscapeDock (void)
 Will add missions and UFOs to the geoscape dock panel. More...
 
void GEO_DrawMarkers (const uiNode_t *node)
 Draws all ufos, aircraft, bases and so on to the geoscape map (2D and 3D) More...
 
void GEO_Draw (geoscapeData_t *data)
 Draw the geoscape. More...
 
void GEO_ResetAction (void)
 No more special action on the geoscape. More...
 
void GEO_SelectUFO (aircraft_t *ufo)
 Select the specified ufo on the geoscape. More...
 
void GEO_SelectAircraft (aircraft_t *aircraft)
 Select the specified aircraft on the geoscape. More...
 
mission_tGEO_SelectMission (mission_t *mission)
 Select the specified mission. More...
 
void GEO_NotifyMissionRemoved (const mission_t *mission)
 Notify that a mission has been removed. More...
 
void GEO_NotifyUFORemoved (const aircraft_t *ufo, bool destroyed)
 Notify that a UFO has been removed. More...
 
void GEO_NotifyAircraftRemoved (const aircraft_t *aircraft)
 Notify that an aircraft has been removed from game. More...
 
nation_tGEO_GetNation (const vec2_t pos)
 Translate nation map color to nation. More...
 
static const char * GEO_GetCultureType (const byte *color)
 Translate color value to culture type. More...
 
static const char * GEO_GetPopulationType (const byte *color)
 Translate color value to population type. More...
 
static const char * GEO_GetTerrainTypeByPos (const vec2_t pos, bool *coast)
 Determine the terrain type under a given position. More...
 
static const char * GEO_GetCultureTypeByPos (const vec2_t pos)
 Determine the culture type under a given position. More...
 
static const char * GEO_GetPopulationTypeByPos (const vec2_t pos)
 Determine the population type under a given position. More...
 
int GEO_GetCivilianNumberByPosition (const vec2_t pos)
 Get number of civilian on a map at given position. More...
 
void GEO_PrintParameterStringByPos (const vec2_t pos)
 Prints positions parameter in console. More...
 
void GEO_CheckPositionBoundaries (float *pos)
 Check that a position (in latitude / longitude) is within boundaries. More...
 
bool GEO_IsNight (const vec2_t pos)
 Check whether given position is Day or Night. More...
 
const byteGEO_GetColor (const vec2_t pos, mapType_t type, bool *coast)
 Returns the color value from geoscape of a certain mask (terrain, culture or population) at a given position. More...
 
base_tGEO_PositionCloseToBase (const vec2_t pos)
 Check if given pos is close to an existing base. More...
 
bool GEO_PositionFitsTCPNTypes (const vec2_t pos, const linkedList_t *terrainTypes, const linkedList_t *cultureTypes, const linkedList_t *populationTypes, const linkedList_t *nations)
 Checks for a given location, if it fulfills all criteria given via parameters (terrain, culture, population, nation type) More...
 
void CP_GetRandomPosOnGeoscape (vec2_t pos, bool noWater)
 Determines a random position on geoscape. More...
 
bool CP_GetRandomPosOnGeoscapeWithParameters (vec2_t pos, const linkedList_t *terrainTypes, const linkedList_t *cultureTypes, const linkedList_t *populationTypes, const linkedList_t *nations)
 Determines a random position on geoscape that fulfills certain criteria given via parameters. More...
 
void GEO_Shutdown (void)
 
void GEO_Init (const char *map)
 
void GEO_Reset (const char *map)
 
void GEO_NotifyUFODisappear (const aircraft_t *ufo)
 Notify that a UFO disappears on radars. More...
 
void GEO_SetOverlay (const char *overlayID, int status)
 Turn overlay on/off. More...
 
static void GEO_SetOverlay_f (void)
 Console command to call GEO_SetOverlay. More...
 
void GEO_InitStartup (void)
 Initialise MAP/Geoscape. More...
 

Variables

static uiNode_tgeoscapeNode
 
static char textStandard [2048]
 
static int centerOnEventIdx
 
static const vec4_t green = {0.0f, 1.0f, 0.0f, 0.8f}
 
static const vec4_t yellow = {1.0f, 0.874f, 0.294f, 1.0f}
 
static const vec4_t red = {1.0f, 0.0f, 0.0f, 0.8f}
 
static const float defaultBaseAngle = -90.0f
 
static byteterrainPic
 
static int terrainWidth
 
static int terrainHeight
 
static byteculturePic
 
static int cultureWidth
 
static int cultureHeight
 
static bytepopulationPic
 
static int populationWidth
 
static int populationHeight
 
static bytenationsPic
 
static int nationsWidth
 
static int nationsHeight
 
static const float MIN_DIST_BASE = 4.0f
 Minimum distance between a new mission and an existing base. More...
 

Detailed Description

Geoscape/Map management.

Definition in file cp_geoscape.cpp.

Macro Definition Documentation

#define BULLET_SIZE   1

Definition at line 987 of file cp_geoscape.cpp.

Referenced by GEO_DrawBullets().

#define CIRCLE_DRAW_POINTS   60

Definition at line 530 of file cp_geoscape.cpp.

Referenced by GEO_MapDrawEquidistantPoints().

#define GLOBE_ROTATE   -90

Definition at line 44 of file cp_geoscape.cpp.

Referenced by GEO_StartCenter().

#define SELECT_CIRCLE_RADIUS   1.5f + 3.0f / UI_MAPEXTRADATACONST(node).zoom
#define UI_MAP_DIST_SELECTION   15

maximum distance (in pixel) to get a valid mouse click

Note
this is for a 1024 * 768 screen

Definition at line 324 of file cp_geoscape.cpp.

Referenced by GEO_IsPositionSelected().

#define ZOOM_LIMIT   2.5f

Definition at line 45 of file cp_geoscape.cpp.

Referenced by GEO_StartCenter().

Function Documentation

void CP_GetRandomPosOnGeoscape ( vec2_t  pos,
bool  noWater 
)

Determines a random position on geoscape.

Parameters
[out]posThe position that will be overwritten. pos[0] is within -180, +180. pos[1] within -90, +90.
[in]noWaterTrue if the position should not be on water
See also
CP_GetRandomPosOnGeoscapeWithParameters
Note
The random positions should be roughly uniform thanks to the non-uniform distribution used.
This function always returns a value.

Definition at line 2084 of file cp_geoscape.cpp.

References cgi, DEBUG_CLIENT, f, frand(), GEO_GetColor(), MapIsWater, MAPTYPE_TERRAIN, and todeg.

Referenced by AB_SetAlienBasePosition(), CP_AttackUFOCarrier_f(), UFO_SetRandomDest(), and UFO_SetRandomPos().

bool CP_GetRandomPosOnGeoscapeWithParameters ( vec2_t  pos,
const linkedList_t terrainTypes,
const linkedList_t cultureTypes,
const linkedList_t populationTypes,
const linkedList_t nations 
)

Determines a random position on geoscape that fulfills certain criteria given via parameters.

Parameters
[out]posThe position that will be overwritten with the random point fulfilling the criteria. pos[0] is within -180, +180. pos[1] within -90, +90.
[in]terrainTypesA linkedList_t containing a list of strings determining the acceptable terrain types (e.g. "grass") May be nullptr.
[in]cultureTypesA linkedList_t containing a list of strings determining the acceptable culture types (e.g. "western") May be nullptr.
[in]populationTypesA linkedList_t containing a list of strings determining the acceptable population types (e.g. "suburban") May be nullptr.
[in]nationsA linkedList_t containing a list of strings determining the acceptable nations (e.g. "asia"). May be nullptr
Returns
true if a location was found, otherwise false
Note
There may be no position fitting the parameters. The higher RASTER, the lower the probability to find a position.
See also
LIST_AddString
LIST_Delete
Note
When all parameters are nullptr, the algorithm assumes that it does not need to include "water" terrains when determining a random position
You should rather use CP_GetRandomPosOnGeoscape if there are no parameters (except water) to choose a random position
Todo:
  • cache the counted hits
Todo:
add EQUAL_EPSILON here?

Definition at line 2108 of file cp_geoscape.cpp.

References cgi, DEBUG_CLIENT, frand(), GEO_PositionFitsTCPNTypes(), RASTER, todeg, and Vector2Set.

Referenced by CP_HarvestMissionGo(), CP_ReconMissionGroundGo(), and TEST_F().

static void GEO_3DMapDrawLine ( const uiNode_t node,
const mapline_t line 
)
static

Draw a path on a menu node (usually the 3Dgeoscape map)

Parameters
[in]nodeThe menu node which will be used for drawing dimensions. This is usually the 3Dgeoscape menu node.
[in]lineThe path which is to be drawn
See also
GEO_CalcLine

Definition at line 507 of file cp_geoscape.cpp.

References cgi, GEO_3DMapToScreen(), i, LINE_MAXPTS, mapline_s::numPoints, mapline_s::point, screenPoint_t::x, and screenPoint_t::y.

Referenced by GEO_DrawMapOnePhalanxAircraft(), and GEO_DrawMarkers().

static bool GEO_3DMapToScreen ( const uiNode_t node,
const vec2_t  pos,
int x,
int y,
int z 
)
static

Transform a 2D position on the map to screen coordinates.

Parameters
[in]nodeMenu node
[in]posvector that holds longitude and latitude
[out]xnormalized (rotated and scaled) x value of mouseclick
[out]ynormalized (rotated and scaled) y value of mouseclick
[out]zz value of the given latitude and longitude - might also be nullptr if not needed
Returns
true if the point is visible, false else (if it's outside the node or on the wrong side of the earth).

Definition at line 228 of file cp_geoscape.cpp.

References mapExtraData_s::angles, GLOBE_RADIUS, int(), mapExtraData_s::mapPos, mapExtraData_s::mapSize, PITCH, PolarToVec(), RotatePointAroundVector(), UI_MAPEXTRADATACONST, v, Vector2Set, VectorSet, and YAW.

Referenced by GEO_3DMapDrawLine(), GEO_AllMapToScreen(), and GEO_DrawAircraftHealthBar().

static bool GEO_AllMapToScreen ( const uiNode_t node,
const vec2_t  pos,
int x,
int y,
int z 
)
static

Call either GEO_MapToScreen or GEO_3DMapToScreen depending on the geoscape you're using.

Parameters
[in]nodeMenu node
[in]posPosition on the map described by longitude and latitude
[out]xPointer to the X coordinate on the screen
[out]yPointer to the Y coordinate on the screen
[out]zPointer to the Z coordinate on the screen (may be nullptr if not needed)
Returns
true if pos corresponds to a point which is visible on the screen. Otherwise returns false.

Definition at line 309 of file cp_geoscape.cpp.

References mapExtraData_s::flatgeoscape, GEO_3DMapToScreen(), GEO_MapToScreen(), and UI_MAPEXTRADATACONST.

Referenced by GEO_Draw3DMarkerIfVisible(), GEO_DrawAircraftHealthBar(), GEO_DrawBeam(), GEO_DrawBullets(), GEO_DrawMapOneBase(), GEO_DrawMapOneInstallation(), GEO_DrawMapOneMission(), GEO_DrawMapOnePhalanxAircraft(), GEO_DrawMarkers(), GEO_DrawRadarInMap(), GEO_IsPositionSelected(), and GEO_MapDrawEquidistantPoints().

float GEO_AngleOfPath ( const vec2_t  start,
const vec2_t  end,
vec3_t  direction,
vec3_t  ortVector 
)

Select which function should be used for calculating the direction of model on 2D or 3D geoscape.

Parameters
[in]startLatitude and longitude of the position of the model.
[in]endLatitude and longitude of aimed point.
[in]directionvec3_t giving current direction of the model (nullptr if the model is idle).
[out]ortVectorIf not nullptr, this will be filled with the normalized vector around which rotation allows to go toward direction.
Returns
Angle (degrees) of rotation around the radius axis of earth for start going toward end. Zero value is the direction of North pole.

Definition at line 716 of file cp_geoscape.cpp.

References mapExtraData_s::flatgeoscape, GEO_AngleOfPath2D(), GEO_AngleOfPath3D(), geoscapeNode, and UI_MAPEXTRADATA.

Referenced by AIRFIGHT_GetNextPointInPath(), GEO_DrawMapOnePhalanxAircraft(), and GEO_DrawMarkers().

static float GEO_AngleOfPath2D ( const vec2_t  start,
const vec2_t  end,
vec3_t  direction,
vec3_t  ortVector 
)
static

Return the angle of a model given its position and destination, on 2D geoscape.

Parameters
[in]startLatitude and longitude of the position of the model.
[in]endLatitude and longitude of aimed point.
[in]directionvec3_t giving current direction of the model (nullptr if the model is idle).
[out]ortVectorIf not nullptr, this will be filled with the normalized vector around which rotation allows to go toward direction.
Returns
Angle (degrees) of rotation around the radius axis of earth for start going toward end. Zero value is the direction of North pole.

Definition at line 660 of file cp_geoscape.cpp.

References CrossProduct(), f, PolarToVec(), RotatePointAroundVector(), todeg, v, VectorCopy, VectorLength(), VectorNormalize(), VectorSet, and VectorSubtract.

Referenced by GEO_AngleOfPath().

static float GEO_AngleOfPath3D ( const vec2_t  start,
const vec2_t  end,
vec3_t  direction,
vec3_t  ortVector 
)
static

Return the angle of a model given its position and destination, on 3D geoscape.

Parameters
[in]startLatitude and longitude of the position of the model.
[in]endLatitude and longitude of aimed point.
[in]directionvec3_t giving current direction of the model (nullptr if the model is idle).
[out]ortVectorIf not nullptr, this will be filled with the normalized vector around which rotation allows to go toward direction.
Returns
Angle (degrees) of rotation around the radius axis of earth for start going toward end. Zero value is the direction of North pole.

< Position of the north pole (used to know where the 'up' side is)

Todo:
Save the value angle instead of direction: we don't need a vector here, we could just compare angle to current angle.

Definition at line 600 of file cp_geoscape.cpp.

References CrossProduct(), DotProduct, PolarToVec(), RotatePointAroundVector(), todeg, v, VectorCopy, VectorLength(), VectorNormalize(), and VectorSubtract.

Referenced by GEO_AngleOfPath().

void GEO_CalcLine ( const vec2_t  start,
const vec2_t  end,
mapline_t line 
)

Calculate the shortest way to go from start to end on a sphere.

Parameters
[in]startThe point you start from
[in]endThe point you go to
[out]lineContains the shortest path to go from start to end
See also
GEO_MapDrawLine

Definition at line 371 of file cp_geoscape.cpp.

References CrossProduct(), mapline_s::distance, i, LINE_MAXPTS, LINE_MAXSEG, M_PI, mapline_s::numPoints, mapline_s::point, PolarToVec(), todeg, torad, v, VecToPolar(), Vector2Set, VectorEqual, VectorNormalize(), and VectorSet.

Referenced by AIR_AircraftReturnToBase(), AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), GEO_Click(), UFO_SearchAircraftTarget(), UFO_SendPursuingAircraft(), and UFO_SendToDestination().

void GEO_CenterOnPoint_f ( void  )

Switch to next model on 2D and 3D geoscape.

Note
Set smoothRotation to true to allow a smooth rotation in GEO_Draw.
This function sets the value of smoothFinalGlobeAngle (for 3D) or smoothFinal2DGeoscapeCenter (for 2D), which contains the final value that ccs.angles or ccs.centre must respectively take.

Definition at line 971 of file cp_geoscape.cpp.

References centerOnEventIdx, cgi, GEO_CenterPosition(), GEO_GetGeoscapeAngle(), geoscapeNode, Q_streq, and cgame_import_s::UI_GetActiveWindowName().

void GEO_CenterPosition ( const vec2_t  pos)

Start to rotate or shift the globe to the given position.

Parameters
[in]posLongitude and latitude of the position to center on

Definition at line 810 of file cp_geoscape.cpp.

References mapExtraData_s::flatgeoscape, GEO_ConvertObjectPositionToGeoscapePosition(), GEO_StartCenter(), geoscapeNode, mapExtraData_s::smoothFinal2DGeoscapeCenter, mapExtraData_s::smoothFinalGlobeAngle, and UI_MAPEXTRADATA.

Referenced by CP_SpawnUFOCarrier_f(), and GEO_CenterOnPoint_f().

void GEO_CheckPositionBoundaries ( float *  pos)

Check that a position (in latitude / longitude) is within boundaries.

Parameters
[in,out]posPointer to the 2 elements vector giving the position.

Definition at line 1890 of file cp_geoscape.cpp.

Referenced by AIR_AircraftMakeMove(), AIR_Move(), and UFO_CampaignRunUFOs().

bool GEO_Click ( const uiNode_t node,
int  x,
int  y,
const vec2_t  pos 
)
static void GEO_ConvertObjectPositionToGeoscapePosition ( bool  flatgeoscape,
float *  vector,
const vec2_t  objectPos 
)
static

Will set the vector for the geoscape position.

Parameters
[in]flatgeoscapeTrue for 2D geoscape
[out]vectorThe output vector. A two-dim vector for the flat geoscape, and a three-dim vector for the 3d geoscape
[in]objectPosThe position vector of the object to transform.

Definition at line 734 of file cp_geoscape.cpp.

References Vector2Set, and VectorSet.

Referenced by GEO_CenterPosition(), GEO_GetMissionAngle(), and GEO_GetUFOAngle().

static void GEO_Draw3DMarkerIfVisible ( const uiNode_t node,
const vec2_t  pos,
float  theta,
const char *  model,
int  skin 
)
static

Draws a 3D marker on geoscape if the player can see it.

Parameters
[in]nodeMenu node.
[in]posLongitude and latitude of the marker to draw.
[in]thetaAngle (degree) of the model to the horizontal.
[in]modelThe name of the model of the marker.
[in]skinNumber of modelskin to draw on marker

Definition at line 348 of file cp_geoscape.cpp.

References mapExtraData_s::angles, cgi, mapExtraData_s::flatgeoscape, GEO_AllMapToScreen(), GLOBE_RADIUS, mapExtraData_s::mapPos, mapExtraData_s::mapSize, UI_MAPEXTRADATACONST, and VectorSet.

Referenced by GEO_DrawMapOneBase(), GEO_DrawMapOneInstallation(), GEO_DrawMapOneMission(), GEO_DrawMapOnePhalanxAircraft(), and GEO_DrawMarkers().

static void GEO_DrawAircraftHealthBar ( const uiNode_t node,
const aircraft_t aircraft 
)
static

Draws health bar for an aircraft (either phalanx or ufo)

Parameters
[in]nodePointer to the meunode to draw in
[in]aircraftPointer to the aircraft to draw for
Note
if max health (AIR_STATS_DAMAGE) <= 0 no healthbar drawn

Definition at line 1224 of file cp_geoscape.cpp.

References AIR_STATS_DAMAGE, cgi, aircraft_s::damage, mapExtraData_s::flatgeoscape, GEO_3DMapToScreen(), GEO_AllMapToScreen(), green, aircraft_s::pos, red, aircraft_s::stats, UI_MAPEXTRADATACONST, Vector4Copy, yellow, and mapExtraData_s::zoom.

Referenced by GEO_DrawMapOnePhalanxAircraft(), and GEO_DrawMarkers().

static void GEO_DrawBeam ( const uiNode_t node,
const vec3_t  start,
const vec3_t  end,
const vec4_t  color 
)
static

Draws a energy beam on the geoscape map (laser/particle)

Parameters
[in]nodePointer to the node in which you want to draw.
[in]startStart position of the shot (on geoscape)
[in]endEnd position of the shot (on geoscape)
[in]colorcolor of the beam
See also
GEO_Draw

Definition at line 1010 of file cp_geoscape.cpp.

References cgi, and GEO_AllMapToScreen().

Referenced by GEO_DrawMarkers().

static void GEO_DrawBullets ( const uiNode_t node,
const vec3_t  pos 
)
static

Draws a bunch of bullets on the geoscape map.

Parameters
[in]nodePointer to the node in which you want to draw the bullets.
[in]pos
See also
GEO_Draw

Definition at line 994 of file cp_geoscape.cpp.

References BULLET_SIZE, cgi, GEO_AllMapToScreen(), and yellow.

Referenced by GEO_DrawMarkers().

static void GEO_DrawMapOneBase ( const uiNode_t node,
const base_t base,
bool  oneUFOVisible,
const char *  font 
)
static

Draws one base on the geoscape map (2D and 3D)

Parameters
[in]nodeThe menu node which will be used for drawing markers.
[in]basePointer to the base to draw.
[in]oneUFOVisibleIs there at least one UFO visible on the geoscape?
[in]fontDefault font.

Definition at line 1172 of file cp_geoscape.cpp.

References AII_BaseCanShoot(), AIR_STATS_WRANGE, ALIGN_UL, aircraftSlot_s::ammo, aircraftSlot_s::ammoLeft, B_IsUnderAttack, base_s::batteries, cgi, objDef_s::craftitem, defaultBaseAngle, GEO_AllMapToScreen(), GEO_Draw3DMarkerIfVisible(), GEO_DrawRadarInMap(), GEO_IsRadarOverlayActivated(), GEO_MapDrawEquidistantPoints(), GEO_MapToScreen(), GEO_RenderImage(), i, aircraftSlot_s::installationTime, aircraftSlot_s::item, base_s::lasers, base_s::name, base_s::numBatteries, base_s::numLasers, base_s::pos, base_s::radar, red, baseWeapon_s::slot, craftitem_s::stats, and UI_MAPEXTRADATACONST.

Referenced by GEO_DrawMarkers().

static void GEO_DrawMapOneInstallation ( const uiNode_t node,
const installation_t installation,
bool  oneUFOVisible,
const char *  font 
)
static
static void GEO_DrawMapOneMission ( const uiNode_t node,
const mission_t mission 
)
static

Draws one mission on the geoscape map (2D and 3D)

Parameters
[in]nodeThe menu node which will be used for drawing markers.
[in]missionPointer to the mission to draw.

Definition at line 1036 of file cp_geoscape.cpp.

References _, mission_s::active, ALIGN_UL, cgi, cgame_import_s::Cvar_Set(), defaultBaseAngle, mapExtraData_s::flatgeoscape, GEO_AllMapToScreen(), GEO_Draw3DMarkerIfVisible(), GEO_IsMissionSelected, GEO_IsNight(), GEO_MapDrawEquidistantPoints(), GEO_RenderImage(), MIS_GetModel(), MIS_GetName(), mission_s::pos, SELECT_CIRCLE_RADIUS, UI_MAPEXTRADATACONST, and yellow.

Referenced by GEO_DrawMarkers().

static void GEO_DrawMapOnePhalanxAircraft ( const uiNode_t node,
aircraft_t aircraft,
bool  oneUFOVisible 
)
static

Draws one Phalanx aircraft on the geoscape map (2D and 3D)

Parameters
[in]nodeThe menu node which will be used for drawing markers.
[in]aircraftPointer to the aircraft to draw.
[in]oneUFOVisibleIs there at least one UFO visible on the geoscape?
Todo:
: check why path.numPoints can be sometime equal to -1
Todo:
we should only show healthbar if the aircraft is fighting but it's a slow algo

Definition at line 1265 of file cp_geoscape.cpp.

References AIR_STATS_WRANGE, AIR_TRANSIT, AIR_UFO, aircraft_s::aircraftTarget, cgi, aircraft_s::direction, mapExtraData_s::flatgeoscape, GEO_3DMapDrawLine(), GEO_AllMapToScreen(), GEO_AngleOfPath(), GEO_Draw3DMarkerIfVisible(), GEO_DrawAircraftHealthBar(), GEO_DrawRadarInMap(), GEO_IsAircraftSelected, GEO_IsRadarOverlayActivated(), GEO_MapDrawEquidistantPoints(), GEO_MapDrawLine(), GEO_RenderImage(), aircraft_s::model, mapline_s::numPoints, mapline_s::point, aircraft_s::point, aircraft_s::pos, aircraft_s::radar, red, aircraft_s::route, SELECT_CIRCLE_RADIUS, aircraft_s::stats, aircraft_s::status, UI_MAPEXTRADATACONST, and yellow.

Referenced by GEO_DrawMarkers().

void GEO_DrawMarkers ( const uiNode_t node)

Draws all ufos, aircraft, bases and so on to the geoscape map (2D and 3D)

Parameters
[in]nodeThe menu node which will be used for drawing markers.
Note
This is a drawing function only, called each time a frame is drawn. Therefore you should not use this function to calculate eg. the distance between 2 items on the geoscape (you should instead calculate it just after one of the items moved – distance is not going to change when you rotate the earth around itself and the time is stopped eg.).
See also
GEO_Draw
Todo:
we should only show healthbar if aircraft is fighting but it's a slow algo

Definition at line 1431 of file cp_geoscape.cpp.

References _, aircraftProjectile_s::aimedAircraft, AIR_Foreach, AIR_IsAircraftOnGeoscape(), aircraftProjectile_s::aircraftItem, ALIGN_UC, aircraftProjectile_s::angle, aircraftProjectile_s::attackerPos, aircraftProjectile_s::attackingAircraft, B_GetNext(), aircraftProjectile_s::beam, craftitem_s::beamColor, aircraftProjectile_s::bullets, ccs, cgi, uiNode_t::color, CP_IsXVIVisible(), objDef_s::craftitem, aircraft_s::direction, f, mapExtraData_s::flatgeoscape, ccs_s::frametime, ccs_s::gameTimeScale, GEO_3DMapDrawLine(), GEO_AllMapToScreen(), GEO_AngleOfPath(), GEO_Draw3DMarkerIfVisible(), GEO_DrawAircraftHealthBar(), GEO_DrawBeam(), GEO_DrawBullets(), GEO_DrawMapOneBase(), GEO_DrawMapOneInstallation(), GEO_DrawMapOneMission(), GEO_DrawMapOnePhalanxAircraft(), GEO_IsUFOSelected, GEO_MapDrawEquidistantPoints(), GEO_MapDrawLine(), GEO_RenderImage(), aircraftProjectile_s::hasMoved, i, aircraftProjectile_s::idleTarget, INS_Foreach, LinearInterpolation, MIS_Foreach, aircraft_s::model, objDef_s::model, NAT_Foreach, NAT_GetCurrentMonthInfo(), aircraftProjectile_s::numInterpolationPoints, mapline_s::numPoints, ccs_s::numProjectiles, mapline_s::point, aircraftProjectile_s::pos, aircraft_s::pos, aircraftProjectile_s::projectedPos, ccs_s::projectiles, Q_strcat(), aircraft_s::route, RS_IsResearched_ptr(), SELECT_CIRCLE_RADIUS, aircraft_s::tech, TEXT_XVI, UFO_GetNextOnGeoscape(), cgame_import_s::UI_GetFontFromNode(), UI_MAPEXTRADATACONST, VectorCopy, nationInfo_s::xviInfection, and yellow.

Referenced by GetCGameAPI().

static void GEO_DrawRadarInMap ( const uiNode_t node,
const radar_t radar,
const vec2_t  pos 
)
static

Draw only the "wire" part of the radar coverage in geoscape.

Parameters
[in]nodeThe menu node where radar coverage will be drawn.
[in]radarPointer to the radar that will be drawn.
[in]posPosition of the radar.

Definition at line 1091 of file cp_geoscape.cpp.

References cgi, GEO_AllMapToScreen(), GEO_DrawRadarLineCoverage(), i, radar_s::numUFOs, aircraft_s::pos, UFO_IsUFOSeenOnGeoscape(), radar_s::ufos, screenPoint_t::x, and screenPoint_t::y.

Referenced by GEO_DrawMapOneBase(), GEO_DrawMapOneInstallation(), and GEO_DrawMapOnePhalanxAircraft().

static void GEO_DrawRadarLineCoverage ( const uiNode_t node,
const radar_t radar,
const vec2_t  pos 
)
static

Draw only the "wire" Radar coverage.

Parameters
[in]nodeThe menu node where radar coverage will be drawn.
[in]radarPointer to the radar that will be drawn.
[in]posPosition of the radar.

Definition at line 1078 of file cp_geoscape.cpp.

References GEO_MapDrawEquidistantPoints(), radar_s::range, and radar_s::trackingRange.

Referenced by GEO_DrawRadarInMap().

static const char* GEO_GetAircraftText ( char *  buffer,
size_t  size,
const aircraft_t aircraft 
)
static

Assembles a string for an aircraft that is on the geoscape.

Parameters
[in]aircraftThe aircraft to get the description for
[out]bufferThe target buffer to store the text in
[in]sizeThe size of the target buffer
Returns
A pointer to the buffer that was given to this function

Definition at line 1350 of file cp_geoscape.cpp.

References _, AIR_AircraftMenuStatsValues(), AIR_AircraftStatusToName(), AIR_GetTeamSize(), AIR_IDLE, AIR_STATS_DAMAGE, AIR_STATS_FUELSIZE, AIR_STATS_SPEED, AIR_UFO, aircraft_s::aircraftTarget, Com_sprintf(), CP_SecondConvert(), aircraft_s::damage, aircraft_s::fuel, GetDistanceOnGlobe(), aircraft_s::maxTeamSize, aircraft_s::name, mapline_s::numPoints, mapline_s::point, aircraft_s::pos, Q_strcat(), aircraft_s::route, SECONDS_PER_HOUR, aircraft_s::stats, and aircraft_s::status.

Referenced by GEO_Draw().

int GEO_GetCivilianNumberByPosition ( const vec2_t  pos)

Get number of civilian on a map at given position.

Parameters
[in]posPosition where the mission takes place.
Returns
Number of civilian.
See also
CP_CreateCivilianTeam

Definition at line 1848 of file cp_geoscape.cpp.

References cgi, ERR_DROP, GEO_GetColor(), MapIsNopopulation, MapIsRural, MapIsSuburban, MapIsUrban, MapIsVillage, MapIsWater, and MAPTYPE_POPULATION.

Referenced by CP_CreateCivilianTeam().

const byte* GEO_GetColor ( const vec2_t  pos,
mapType_t  type,
bool *  coast 
)

Returns the color value from geoscape of a certain mask (terrain, culture or population) at a given position.

Parameters
[in]posvec2_t Value of position on map to get the color value from. pos is longitude and latitude
[in]typedetermine the map to get the color from (there are different masks) one for the climatezone (bases made use of this - there are grass, ice and desert base tiles available) and one for the nations
[out]coastThe function will set this to true if the given position is a coast line. This can be nullptr if you are not interested in this fact.
Returns
Returns the color value at given position.
Note
terrainPic, culturePic and populationPic are pointers to an rgba image in memory
Todo:
add EQUAL_EPSILON here?

Definition at line 1934 of file cp_geoscape.cpp.

References cgi, cultureHeight, culturePic, cultureWidth, ERR_DROP, MapIsWater, MAPTYPE_CULTURE, MAPTYPE_NATIONS, MAPTYPE_POPULATION, MAPTYPE_TERRAIN, nationsHeight, nationsPic, nationsWidth, populationHeight, populationPic, populationWidth, terrainHeight, terrainPic, and terrainWidth.

Referenced by AIR_PilotSurvivedCrash(), AIRFIGHT_ActionsAfterAirfight(), B_MoveAircraftOnGeoscapeToOtherBases(), CP_ChooseMap(), CP_CreateBattleParameters(), CP_GetRandomPosOnGeoscape(), CP_SpawnUFOCarrier_f(), CP_UpdateNationXVIInfection(), GEO_Click(), GEO_GetCivilianNumberByPosition(), GEO_GetCultureTypeByPos(), GEO_GetNation(), GEO_GetPopulationTypeByPos(), GEO_GetTerrainTypeByPos(), GEO_PositionFitsTCPNTypes(), NAT_ScriptSanityCheck(), and TEST_F().

static const char* GEO_GetCultureType ( const byte color)
static

Translate color value to culture type.

See also
GEO_GetColor
Parameters
[in]colorthe color value from the culture mask
Returns
returns the zone name
Note
never may return a null pointer or an empty string

Definition at line 1768 of file cp_geoscape.cpp.

References MapIsAfrican, MapIsEastern, MapIsOriental, MapIsWater, and MapIsWestern.

Referenced by GEO_GetCultureTypeByPos().

static const char* GEO_GetCultureTypeByPos ( const vec2_t  pos)
inlinestatic

Determine the culture type under a given position.

See also
GEO_GetColor
Parameters
[in]posMap Coordinates to get the culture type from
Returns
returns the zone name

Definition at line 1824 of file cp_geoscape.cpp.

References GEO_GetColor(), GEO_GetCultureType(), and MAPTYPE_CULTURE.

Referenced by GEO_PositionFitsTCPNTypes(), and GEO_PrintParameterStringByPos().

static void GEO_GetGeoscapeAngle ( vec2_t  pos)
static
static void GEO_GetMissionAngle ( bool  flatgeoscape,
float *  vector,
int  id 
)
static

center to a mission

Definition at line 745 of file cp_geoscape.cpp.

References GEO_ConvertObjectPositionToGeoscapePosition(), GEO_SelectMission(), MIS_GetByIdx(), and mission_s::pos.

Referenced by GEO_SelectObject_f().

static const char* GEO_GetMissionText ( char *  buffer,
size_t  size,
const mission_t mission 
)
static

Assembles a string for a mission that is on the geoscape.

Parameters
[in]missionThe mission to get the description for
[out]bufferThe target buffer to store the text in
[in]sizeThe size of the target buffer
Returns
A pointer to the buffer that was given to this function

Definition at line 1335 of file cp_geoscape.cpp.

References _, Com_sprintf(), mapDef_s::description, mission_s::mapDef, and MIS_GetName().

Referenced by GEO_Draw().

nation_t* GEO_GetNation ( const vec2_t  pos)

Translate nation map color to nation.

See also
GEO_GetColor
Parameters
[in]posMap Coordinates to get the nation from
Returns
returns the nation pointer with the given color on nationPic at given pos
nullptr if no nation with the given color value was found
Note
The coordinates already have to be transformed to map coordinates via GEO_ScreenToMap

Definition at line 1744 of file cp_geoscape.cpp.

References cgi, DEBUG_CLIENT, GEO_GetColor(), MAPTYPE_NATIONS, NAT_Foreach, and VectorEqualEpsilon.

Referenced by AB_BaseSearchedByNations(), B_BuildBase_f(), CP_BuildBaseGovernmentLeave(), CP_ChangeNationHappiness_f(), CP_CreateCivilianTeam(), CP_MissionGetMessage(), CP_UpdateNationXVIInfection(), GEO_PositionFitsTCPNTypes(), INS_BuildInstallation_f(), INS_FillUFOYardData_f(), MIS_GetName(), NAT_UpdateHappinessForAllNations(), and US_FillUFOTransfer_f().

static const char* GEO_GetPopulationType ( const byte color)
static

Translate color value to population type.

See also
GEO_GetColor
Parameters
[in]colorthe color value from the population mask
Returns
returns the zone name
Note
never may return a null pointer or an empty string

Definition at line 1790 of file cp_geoscape.cpp.

References MapIsRural, MapIsSuburban, MapIsUrban, MapIsVillage, and MapIsWater.

Referenced by GEO_GetPopulationTypeByPos().

static const char* GEO_GetPopulationTypeByPos ( const vec2_t  pos)
inlinestatic

Determine the population type under a given position.

See also
GEO_GetColor
Parameters
[in]posMap Coordinates to get the population type from
Returns
returns the zone name

Definition at line 1836 of file cp_geoscape.cpp.

References GEO_GetColor(), GEO_GetPopulationType(), and MAPTYPE_POPULATION.

Referenced by GEO_PositionFitsTCPNTypes(), and GEO_PrintParameterStringByPos().

static const char* GEO_GetTerrainTypeByPos ( const vec2_t  pos,
bool *  coast 
)
inlinestatic

Determine the terrain type under a given position.

See also
GEO_GetColor
Parameters
[in]posMap Coordinates to get the terrain type from
[out]coastGEO_GetColor will set this to true if the given position is a coast line.
Returns
returns the zone name

Definition at line 1812 of file cp_geoscape.cpp.

References cgi, cgame_import_s::csi, GEO_GetColor(), TerrainDefs::getTerrainName(), MAPTYPE_TERRAIN, and csi_s::terrainDefs.

Referenced by GEO_PositionFitsTCPNTypes(), and GEO_PrintParameterStringByPos().

static void GEO_GetUFOAngle ( bool  flatgeoscape,
float *  vector,
int  idx 
)
static
static const char* GEO_GetUFOText ( char *  buffer,
size_t  size,
const aircraft_t ufo 
)
static

Assembles a string for a UFO that is on the geoscape.

Parameters
[in]ufoThe UFO to get the description for
[out]bufferThe target buffer to store the text in
[in]sizeThe size of the target buffer
Returns
A pointer to the buffer that was given to this function

Definition at line 1387 of file cp_geoscape.cpp.

References _, AIR_AircraftMenuStatsValues(), AIR_STATS_SPEED, Com_sprintf(), Q_strcat(), aircraft_s::stats, and UFO_GetName().

Referenced by GEO_Draw(), and GEO_UpdateGeoscapeDock().

void GEO_InitStartup ( void  )

Initialise MAP/Geoscape.

Definition at line 2293 of file cp_geoscape.cpp.

References cgi, CVAR_DEVELOPER, cgame_import_s::Cvar_Get(), GEO_ResetAction(), GEO_SelectObject_f(), and GEO_SetOverlay_f().

Referenced by CP_InitStartup().

static bool GEO_IsNationOverlayActivated ( void  )
inlinestatic

Definition at line 89 of file cp_geoscape.cpp.

References cgi.

Referenced by GEO_Draw().

bool GEO_IsNight ( const vec2_t  pos)

Check whether given position is Day or Night.

Parameters
[in]posGiven position.
Returns
True if given position is Night.

Definition at line 1907 of file cp_geoscape.cpp.

References ccs, COS_ALPHA, ccs_s::date, date_s::day, DAYS_PER_YEAR_AVG, M_PI, date_s::sec, SECONDS_PER_DAY, SIN_ALPHA, and torad.

Referenced by B_AssembleMap_f(), BATTLE_Start(), and GEO_DrawMapOneMission().

static bool GEO_IsPositionSelected ( const uiNode_t node,
const vec2_t  pos,
int  x,
int  y 
)
static

Tell if the specified position is considered clicked.

Definition at line 328 of file cp_geoscape.cpp.

References GEO_AllMapToScreen(), and UI_MAP_DIST_SELECTION.

Referenced by GEO_Click().

static bool GEO_IsXVIOverlayActivated ( void  )
inlinestatic

Definition at line 94 of file cp_geoscape.cpp.

References cgi.

Referenced by GEO_Draw().

static void GEO_MapDrawEquidistantPoints ( const uiNode_t node,
const vec2_t  center,
const float  angle,
const vec4_t  color 
)
static

Draw equidistant points from a given point on a menu node.

Parameters
[in]nodeThe menu node which will be used for drawing dimensions. This is usually the geoscape menu node.
[in]centerThe latitude and longitude of center point
[in]angleThe angle defining the distance of the equidistant points to center
[in]colorThe color for drawing
See also
RADAR_DrawCoverage

Definition at line 540 of file cp_geoscape.cpp.

References cgi, CIRCLE_DRAW_POINTS, mapExtraData_s::flatgeoscape, GEO_AllMapToScreen(), i, PerpendicularVector(), PolarToVec(), RotatePointAroundVector(), UI_MAPEXTRADATACONST, VecToPolar(), screenPoint_t::x, and screenPoint_t::y.

Referenced by GEO_DrawMapOneBase(), GEO_DrawMapOneInstallation(), GEO_DrawMapOneMission(), GEO_DrawMapOnePhalanxAircraft(), GEO_DrawMarkers(), and GEO_DrawRadarLineCoverage().

static void GEO_MapDrawLine ( const uiNode_t node,
const mapline_t line 
)
static

Draw a path on a menu node (usually the 2D geoscape map)

Parameters
[in]nodeThe menu node which will be used for drawing dimensions. This is usually the geoscape menu node.
[in]lineThe path which is to be drawn
See also
GEO_CalcLine

Definition at line 457 of file cp_geoscape.cpp.

References cgi, GEO_MapToScreen(), i, LINE_MAXPTS, mapExtraData_s::mapSize, mapline_s::numPoints, mapline_s::point, UI_MAPEXTRADATACONST, screenPoint_t::x, screenPoint_t::y, and mapExtraData_s::zoom.

Referenced by GEO_DrawMapOnePhalanxAircraft(), and GEO_DrawMarkers().

static bool GEO_MapToScreen ( const uiNode_t node,
const vec2_t  pos,
int x,
int y 
)
static

Transform a 2D position on the map to screen coordinates.

Parameters
[in]nodeMenu node
[in]posPosition on the map described by longitude and latitude
[out]xX coordinate on the screen
[out]yY coordinate on the screen
Returns
true if the screen position is within the boundaries of the menu node. Otherwise returns false.

Definition at line 278 of file cp_geoscape.cpp.

References mapExtraData_s::center, f, mapExtraData_s::mapPos, mapExtraData_s::mapSize, UI_MAPEXTRADATACONST, and mapExtraData_s::zoom.

Referenced by GEO_AllMapToScreen(), GEO_DrawMapOneBase(), GEO_DrawMapOneInstallation(), and GEO_MapDrawLine().

void GEO_NotifyAircraftRemoved ( const aircraft_t aircraft)

Notify that an aircraft has been removed from game.

Parameters
[in]aircraftPointer to the aircraft that has been removed

Definition at line 1729 of file cp_geoscape.cpp.

References GEO_IsAircraftSelected, GEO_IsInterceptorSelected, and GEO_ResetAction().

Referenced by AIR_DeleteAircraft().

void GEO_NotifyMissionRemoved ( const mission_t mission)

Notify that a mission has been removed.

Definition at line 1696 of file cp_geoscape.cpp.

References GEO_IsMissionSelected, GEO_ResetAction(), and GEO_UpdateGeoscapeDock().

Referenced by CP_BaseAttackMissionIsFailure(), and CP_MissionRemoveFromGeoscape().

void GEO_NotifyUFODisappear ( const aircraft_t ufo)

Notify that a UFO disappears on radars.

Definition at line 2235 of file cp_geoscape.cpp.

References GEO_IsUFOSelected, GEO_ResetAction(), and GEO_UpdateGeoscapeDock().

Referenced by UFO_CampaignCheckEvents().

void GEO_NotifyUFORemoved ( const aircraft_t ufo,
bool  destroyed 
)

Notify that a UFO has been removed.

Parameters
[in]ufoPointer to the ufo has been removed
[in]destroyedTrue if the UFO has been destroyed, false if it's been only set invisible (landed)
Todo:
convert to linked list

Definition at line 1710 of file cp_geoscape.cpp.

References ccs, GEO_GetSelectedUFO, GEO_IsUFOSelected, GEO_ResetAction(), GEO_UpdateGeoscapeDock(), ccs_s::geoscape, and ccs_s::selectedUFO.

Referenced by CP_UFORemoveFromGeoscape().

base_t* GEO_PositionCloseToBase ( const vec2_t  pos)

Check if given pos is close to an existing base.

Returns
Pointer to the base if one base is closer than MIN_DIST_BASE from pos, nullptr else

Definition at line 2029 of file cp_geoscape.cpp.

References B_GetNext(), GetDistanceOnGlobe(), MIN_DIST_BASE, and base_s::pos.

Referenced by AB_SetAlienBasePosition(), CP_HarvestMissionGo(), CP_ReconMissionGroundGo(), and CP_TerrorMissionGo().

bool GEO_PositionFitsTCPNTypes ( const vec2_t  pos,
const linkedList_t terrainTypes,
const linkedList_t cultureTypes,
const linkedList_t populationTypes,
const linkedList_t nations 
)

Checks for a given location, if it fulfills all criteria given via parameters (terrain, culture, population, nation type)

Parameters
[in]posLocation to be tested
[in]terrainTypesA linkedList_t containing a list of strings determining the terrain types to be tested for (e.g. "grass") may be nullptr
[in]cultureTypesA linkedList_t containing a list of strings determining the culture types to be tested for (e.g. "western") may be nullptr
[in]populationTypesA linkedList_t containing a list of strings determining the population types to be tested for (e.g. "suburban") may be nullptr
[in]nationsA linkedList_t containing a list of strings determining the nations to be tested for (e.g. "asia") may be nullptr
Returns
true if a location was found, otherwise false. If the map is over water, return false
Note
The name TCPNTypes comes from terrain, culture, population, nation types

Definition at line 2049 of file cp_geoscape.cpp.

References cgi, GEO_GetColor(), GEO_GetCultureTypeByPos(), GEO_GetNation(), GEO_GetPopulationTypeByPos(), GEO_GetTerrainTypeByPos(), nation_s::id, cgame_import_s::LIST_ContainsString(), MapIsWater, and MAPTYPE_TERRAIN.

Referenced by CP_GetRandomPosOnGeoscapeWithParameters(), CP_MapIsSelectable(), and NAT_ScriptSanityCheck().

void GEO_PrintParameterStringByPos ( const vec2_t  pos)

Prints positions parameter in console.

Parameters
[in]posLocation (latitude, longitude) where you want to check
Note
Used for printing in console, do not translate.
See also
NAT_ScriptSanityCheck

Definition at line 1875 of file cp_geoscape.cpp.

References cgi, GEO_GetCultureTypeByPos(), GEO_GetPopulationTypeByPos(), and GEO_GetTerrainTypeByPos().

Referenced by NAT_ScriptSanityCheck().

static void GEO_RenderImage ( int  x,
int  y,
const char *  image 
)
inlinestatic
void GEO_Reset ( const char *  map)

Definition at line 2224 of file cp_geoscape.cpp.

References GEO_Init(), GEO_ResetAction(), GEO_Shutdown(), and GEO_UpdateGeoscapeDock().

Referenced by CP_CampaignInit(), and CP_LoadXML().

void GEO_SelectAircraft ( aircraft_t aircraft)

Select the specified aircraft on the geoscape.

Definition at line 1673 of file cp_geoscape.cpp.

References GEO_ResetAction(), and GEO_SetSelectedAircraft.

Referenced by AIM_AircraftStart_f(), AIR_GeoSelectAircraft_f(), AIR_MoveAircraftIntoNewHomebase(), CL_DisplayHomebasePopup(), and GEO_GetGeoscapeAngle().

mission_t* GEO_SelectMission ( mission_t mission)

Select the specified mission.

Parameters
[in]missionPointer to the mission to select
Returns
pointer to the selected mission

Definition at line 1684 of file cp_geoscape.cpp.

References GEO_GetSelectedMission, GEO_IsMissionSelected, GEO_ResetAction(), and GEO_SetSelectedMission.

Referenced by AIR_Move(), CP_BaseAttackPrepareBattle(), GEO_GetGeoscapeAngle(), GEO_GetMissionAngle(), and MIS_GeoSelectMission_f().

static void GEO_SelectObject_f ( void  )
static

Center the view and select an object from the geoscape.

Definition at line 830 of file cp_geoscape.cpp.

References cgi, cgame_import_s::Cmd_Argv(), GEO_GetMissionAngle(), GEO_GetUFOAngle(), GEO_StartCenter(), geoscapeNode, Q_streq, type, and UI_MAPEXTRADATA.

Referenced by GEO_InitStartup().

void GEO_SelectUFO ( aircraft_t ufo)

Select the specified ufo on the geoscape.

Definition at line 1664 of file cp_geoscape.cpp.

References GEO_ResetAction(), and GEO_SetSelectedUFO.

Referenced by GEO_GetGeoscapeAngle(), GEO_GetUFOAngle(), and UFO_GeoSelectUFO_f().

void GEO_SetOverlay ( const char *  overlayID,
int  status 
)

Turn overlay on/off.

Parameters
[in]overlayIDName of the overlay you want to switch.
[in]statusOn/Off status to set

Definition at line 2249 of file cp_geoscape.cpp.

References B_AtLeastOneExists, cgi, GEO_IsRadarOverlayActivated(), Q_streq, and RADAR_UpdateWholeRadarOverlay().

Referenced by B_BuildBase_f(), B_SelectBase(), GEO_ResetAction(), GEO_SetOverlay_f(), INS_BuildInstallation_f(), INS_SelectType_f(), RADAR_DeactivateRadarOverlay(), and UFO_DetectNewUFO().

static void GEO_SetOverlay_f ( void  )
static

Console command to call GEO_SetOverlay.

Definition at line 2273 of file cp_geoscape.cpp.

References cgi, cgame_import_s::Cmd_Argv(), GEO_IsRadarOverlayActivated(), GEO_SetOverlay(), Q_streq, and radarOverlayWasSet.

Referenced by GEO_InitStartup().

void GEO_Shutdown ( void  )

Definition at line 2186 of file cp_geoscape.cpp.

References cgi, culturePic, nationsPic, populationPic, and terrainPic.

Referenced by CP_Shutdown(), GEO_Reset(), and CampaignTest::SetUp().

Variable Documentation

int centerOnEventIdx
static

Current Event centered on 3D geoscape

Definition at line 52 of file cp_geoscape.cpp.

Referenced by GEO_CenterOnPoint_f(), and GEO_GetGeoscapeAngle().

int cultureHeight
static

the width and height for the culture pic.

Definition at line 67 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

byte* culturePic
static

this is the mask for separating the culture zone and water by different color values

Definition at line 65 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), GEO_Init(), and GEO_Shutdown().

int cultureWidth
static

Definition at line 67 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

const float defaultBaseAngle = -90.0f
static

Default angle value for 3D models like bases

Definition at line 59 of file cp_geoscape.cpp.

Referenced by GEO_DrawMapOneBase(), GEO_DrawMapOneInstallation(), and GEO_DrawMapOneMission().

uiNode_t* geoscapeNode
static
const vec4_t green = {0.0f, 1.0f, 0.0f, 0.8f}
static

Definition at line 55 of file cp_geoscape.cpp.

Referenced by GEO_DrawAircraftHealthBar(), and PR_RequirementsInfo().

const float MIN_DIST_BASE = 4.0f
static

Minimum distance between a new mission and an existing base.

Definition at line 2023 of file cp_geoscape.cpp.

Referenced by GEO_PositionCloseToBase().

int nationsHeight
static

the width and height for the nation pic.

Definition at line 75 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

byte* nationsPic
static

this is the nation mask - separated by colors given in nations.ufo.

Definition at line 73 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), GEO_Init(), and GEO_Shutdown().

int nationsWidth
static

Definition at line 75 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

int populationHeight
static

the width and height for the population pic.

Definition at line 71 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

byte* populationPic
static

this is the mask for separating the population rate zone and water by different color values

Definition at line 69 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), GEO_Init(), and GEO_Shutdown().

int populationWidth
static

Definition at line 71 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

const vec4_t red = {1.0f, 0.0f, 0.0f, 0.8f}
static
int terrainHeight
static

the width and height for the terrain pic.

Definition at line 63 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

byte* terrainPic
static

this is the terrain mask for separating the climate zone and water by different color values

Definition at line 61 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), GEO_Init(), and GEO_Shutdown().

int terrainWidth
static

Definition at line 63 of file cp_geoscape.cpp.

Referenced by GEO_GetColor(), and GEO_Init().

char textStandard[2048]
static

Buffer to display standard text on the geoscape

Definition at line 51 of file cp_geoscape.cpp.

Referenced by GEO_Draw().

const vec4_t yellow = {1.0f, 0.874f, 0.294f, 1.0f}
static