cp_map.c File Reference

Geoscape/Map management. More...

#include "../client.h"
#include "../renderer/r_image.h"
#include "../renderer/r_framebuffer.h"
#include "../renderer/r_draw.h"
#include "../renderer/r_geoscape.h"
#include "../ui/ui_main.h"
#include "../ui/ui_font.h"
#include "../ui/ui_render.h"
#include "../ui/node/ui_node_abstractnode.h"
#include "../ui/node/ui_node_map.h"
#include "cp_overlay.h"
#include "cp_campaign.h"
#include "cp_popup.h"
#include "cp_mapfightequip.h"
#include "cp_map.h"
#include "cp_missions.h"
#include "cp_ufo.h"
#include "cp_time.h"
#include "cp_xvi.h"
Include dependency graph for cp_map.c:

Go to the source code of this file.

Data Structures

struct  multiSelect_s
 Structure to manage the multi selection. More...

Defines

#define ZOOM_LIMIT   2.5f
#define MULTISELECT_MAXSELECT   6
#define UI_MAP_DIST_SELECTION   15
 maximum distance (in pixel) to get a valid mouse click
#define GLOBE_RADIUS   EARTH_RADIUS * (ccs.zoom / STANDARD_3D_ZOOM)
 radius of the globe in screen coordinates
#define CIRCLE_DRAW_POINTS   60
#define SMOOTHING_STEP_2D   0.02f
#define BULLET_SIZE   1
#define SELECT_CIRCLE_RADIUS   1.5f + 3.0f / ccs.zoom

Typedefs

typedef struct multiSelect_s multiSelect_t
 Structure to manage the multi selection.

Enumerations

enum  {
  GEOSCAPE_IMAGE_MISSION, GEOSCAPE_IMAGE_MISSION_SELECTED, GEOSCAPE_IMAGE_MISSION_ACTIVE, GEOSCAPE_IMAGE_BASE,
  GEOSCAPE_IMAGE_BASE_ATTACK, GEOSCAPE_IMAGE_MAX
}
enum  multiSelectType_t {
  MULTISELECT_TYPE_BASE, MULTISELECT_TYPE_INSTALLATION, MULTISELECT_TYPE_MISSION, MULTISELECT_TYPE_AIRCRAFT,
  MULTISELECT_TYPE_UFO, MULTISELECT_TYPE_NONE
}
 

Types of elements that can be selected in map.

More...

Functions

 CASSERT (lengthof(geoscapeImageNames)==GEOSCAPE_IMAGE_MAX)
static qboolean MAP_IsMapPositionSelected (const uiNode_t *node, const vec2_t pos, int x, int y)
 Tell if the specified position is considered clicked.
static void MAP3D_ScreenToMap (const uiNode_t *node, int x, int y, vec2_t pos)
 Return longitude and latitude of a point of the screen for 3D geoscape (globe).
static void MAP_ScreenToMap (const uiNode_t *node, int x, int y, vec2_t pos)
 Return longitude and latitude of a point of the screen for 2D geoscape.
static void MAP_MultiSelectListAddItem (multiSelectType_t itemType, int itemID, const char *itemDescription, const char *itemName)
 Add an element in the multiselection list.
static void MAP_MultiSelectExecuteAction_f (void)
 Execute action for 1 element of the multi selection Param Cmd_Argv(1) is the element selected in the popup_multi_selection menu.
void MAP_MapClick (uiNode_t *node, int x, int y)
 Click on the map/geoscape.
static qboolean MAP_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.
qboolean MAP_MapToScreen (const uiNode_t *node, const vec2_t pos, int *x, int *y)
 Transform a 2D position on the map to screen coordinates.
qboolean MAP_AllMapToScreen (const uiNode_t *node, const vec2_t pos, int *x, int *y, int *z)
 Call either MAP_MapToScreen or MAP_3DMapToScreen depending on the geoscape you're using.
void MAP_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.
void MAP_MapCalcLine (const vec2_t start, const vec2_t end, mapline_t *line)
 Calculate the shortest way to go from start to end on a sphere.
static void MAP_MapDrawLine (const uiNode_t *node, const mapline_t *line)
 Draw a path on a menu node (usually the 2D geoscape map).
static void MAP_3DMapDrawLine (const uiNode_t *node, const mapline_t *line)
 Draw a path on a menu node (usually the 3Dgeoscape map).
void MAP_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.
static float MAP_AngleOfPath3D (const vec3_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.
static float MAP_AngleOfPath2D (const vec3_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.
float MAP_AngleOfPath (const vec3_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.
static void MAP_ConvertObjectPositionToGeoscapePosition (float *vector, const vec2_t objectPos)
 Will set the vector for the geoscape position.
static void MAP_GetMissionAngle (float *vector, int id)
 center to a mission
static void MAP_GetUFOAngle (float *vector, int idx)
 center to an ufo
static void MAP_StartCenter (void)
 Start center to the selected point.
static void MAP_SelectObject_f (void)
 Center the view and select an object from the geoscape.
static void MAP_GetGeoscapeAngle (float *vector)
 Returns position of the model corresponding to centerOnEventIdx.
void MAP_CenterOnPoint_f (void)
 Switch to next model on 2D and 3D geoscape.
static void MAP3D_SmoothRotate (void)
 smooth rotation of the 3D geoscape
void MAP_StopSmoothMovement (void)
 stop smooth translation on geoscape
static void MAP_SmoothTranslate (void)
 smooth translation of the 2D geoscape
static void MAP_DrawBullets (const uiNode_t *node, const vec3_t pos)
 Draws on bunch of bullets on the geoscape map.
static void MAP_DrawBeam (const uiNode_t *node, const vec3_t start, const vec3_t end, const vec4_t color)
 Draws an energy beam on the geoscape map (laser/particle).
static void MAP_DrawMapOneMission (const uiNode_t *node, const mission_t *ms)
 Draws one mission on the geoscape map (2D and 3D).
static void MAP_DrawMapOneInstallation (const uiNode_t *node, const installation_t *installation, qboolean oneUFOVisible, const char *font)
 Draws one installation on the geoscape map (2D and 3D).
static void MAP_DrawMapOneBase (const uiNode_t *node, const base_t *base, qboolean oneUFOVisible, const char *font)
 Draws one base on the geoscape map (2D and 3D).
static void MAP_DrawAircraftHealthBar (const uiNode_t *node, const aircraft_t *aircraft)
 Draws health bar for an aircraft (either phalanx or ufo).
static void MAP_DrawMapOnePhalanxAircraft (const uiNode_t *node, aircraft_t *aircraft, qboolean oneUFOVisible)
 Draws one Phalanx aircraft on the geoscape map (2D and 3D).
static const char * MAP_GetMissionText (char *buffer, size_t size, const mission_t *mission)
 Assembles a string for a mission that is on the geoscape.
static const char * MAP_GetShortMissionText (char *buffer, size_t size, const mission_t *mission)
 Assembles a short string for a mission that is on the geoscape.
static const char * MAP_GetAircraftText (char *buffer, size_t size, const aircraft_t *aircraft)
 Assembles a string for an aircraft that is on the geoscape.
static const char * MAP_GetUFOText (char *buffer, size_t size, const aircraft_t *ufo)
 Assembles a string for an UFO that is on the geoscape.
void MAP_UpdateGeoscapeDock (void)
 Will add missions and UFOs to the geoscape dock panel.
static void MAP_DrawMapMarkers (const uiNode_t *node)
 Draws all ufos, aircraft, bases and so on to the geoscape map (2D and 3D).
void MAP_DrawMap (const uiNode_t *node)
 Draw the geoscape.
void MAP_ResetAction (void)
 No more special action in geoscape.
void MAP_SelectUFO (aircraft_t *ufo)
 Select the specified ufo in geoscape.
void MAP_SelectAircraft (aircraft_t *aircraft)
 Select the specified aircraft in geoscape.
void MAP_SelectMission (mission_t *mission)
 Selected the specified mission.
void MAP_NotifyMissionRemoved (const mission_t *mission)
 Notify that a mission has been removed.
void MAP_NotifyUFORemoved (const aircraft_t *ufo, qboolean destroyed)
 Notify that a UFO has been removed.
void MAP_NotifyAircraftRemoved (const aircraft_t *aircraft)
 Notify that an aircraft has been removed from game.
nation_tMAP_GetNation (const vec2_t pos)
 Translate nation map color to nation.
const char * MAP_GetTerrainType (const byte *const color)
 Translate color value to terrain type.
static const char * MAP_GetCultureType (const byte *color)
 Translate color value to culture type.
static const char * MAP_GetPopulationType (const byte *color)
 Translate color value to population type.
static const char * MAP_GetTerrainTypeByPos (const vec2_t pos)
 Determine the terrain type under a given position.
static const char * MAP_GetCultureTypeByPos (const vec2_t pos)
 Determine the culture type under a given position.
static const char * MAP_GetPopulationTypeByPos (const vec2_t pos)
 Determine the population type under a given position.
int MAP_GetCivilianNumberByPosition (const vec2_t pos)
 Get number of civilian on a map at given position.
void MAP_PrintParameterStringByPos (const vec2_t pos)
 Prints positions parameter in console.
void MAP_CheckPositionBoundaries (float *pos)
 Check that a position (in latitude / longitude) is within boundaries.
qboolean MAP_IsNight (const vec2_t pos)
 Check whether given position is Day or Night.
byteMAP_GetColor (const vec2_t pos, mapType_t type)
 Returns the color value from geoscape of a certain mask (terrain, culture or population) at a given position.
base_tMAP_PositionCloseToBase (const vec2_t pos)
 Check if given pos is close to an existing base.
qboolean MAP_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).
void MAP_Init (void)
void MAP_NotifyUFODisappear (const aircraft_t *ufo)
 Notify that a UFO disappears on radars.
void MAP_Zoom_f (void)
 Command binding for map zooming.
void MAP_Scroll_f (void)
 Command binding for map scrolling.
void MAP_SetOverlay (const char *overlayID)
 Switch overlay (turn on / off).
static void MAP_SetOverlay_f (void)
 Console command to call MAP_SetOverlay.
void MAP_DeactivateOverlay (const char *overlayID)
 Remove overlay.
static void MAP_DeactivateOverlay_f (void)
 Console command to call MAP_DeactivateOverlay.
qboolean MAP_IsRadarOverlayActivated (void)
qboolean MAP_IsNationOverlayActivated (void)
qboolean MAP_IsXVIOverlayActivated (void)
void MAP_InitStartup (void)
 Initialise MAP/Geoscape.

Variables

cvar_tcl_3dmap
static cvar_tcl_3dmapAmbient
cvar_tcl_mapzoommax
cvar_tcl_mapzoommin
cvar_tcl_geoscape_overlay
image_tr_dayandnightTexture
image_tr_radarTexture
image_tr_xviTexture
static const char * geoscapeImageNames []
static image_tgeoscapeImages [GEOSCAPE_IMAGE_MAX]
static multiSelect_t multiSelect
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 qboolean smoothRotation = qfalse
static vec3_t smoothFinalGlobeAngle = {0, GLOBE_ROTATE, 0}
static vec2_t smoothFinal2DGeoscapeCenter = {0.5, 0.5}
static float smoothDeltaLength = 0.0f
static float smoothFinalZoom = 0.0f
static float smoothDeltaZoom = 0.0f
static const float smoothAcceleration = 0.06f
static float curZoomSpeed = 0.0f
static float curRotationSpeed = 0.0f
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
const float STANDARD_3D_ZOOM = 40.0f
 Typical zoom to use in 3D geoscape to use same zoom values for both 2D and 3D geoscape.
static const float MIN_DIST_BASE = 4.0f
 Minimum distance between a new mission and an existing base.

Detailed Description

Geoscape/Map management.

Definition in file cp_map.c.


Define Documentation

#define BULLET_SIZE   1

Definition at line 1359 of file cp_map.c.

Referenced by MAP_DrawBullets().

#define CIRCLE_DRAW_POINTS   60

Definition at line 803 of file cp_map.c.

Referenced by MAP_MapDrawEquidistantPoints().

#define GLOBE_RADIUS   EARTH_RADIUS * (ccs.zoom / STANDARD_3D_ZOOM)

radius of the globe in screen coordinates

Definition at line 436 of file cp_map.c.

Referenced by MAP3D_ScreenToMap(), MAP_3DMapToScreen(), and MAP_Draw3DMarkerIfVisible().

#define MULTISELECT_MAXSELECT   6

Maximal count of elements that can be selected at once

Definition at line 89 of file cp_map.c.

Referenced by MAP_MapClick().

#define SELECT_CIRCLE_RADIUS   1.5f + 3.0f / ccs.zoom
#define SMOOTHING_STEP_2D   0.02f

Definition at line 1332 of file cp_map.c.

Referenced by MAP_SmoothTranslate().

#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 413 of file cp_map.c.

Referenced by MAP_IsMapPositionSelected().

#define ZOOM_LIMIT   2.5f

Definition at line 60 of file cp_map.c.

Referenced by MAP_StartCenter().


Typedef Documentation

typedef struct multiSelect_s multiSelect_t

Structure to manage the multi selection.


Enumeration Type Documentation

anonymous enum
Enumerator:
GEOSCAPE_IMAGE_MISSION 
GEOSCAPE_IMAGE_MISSION_SELECTED 
GEOSCAPE_IMAGE_MISSION_ACTIVE 
GEOSCAPE_IMAGE_BASE 
GEOSCAPE_IMAGE_BASE_ATTACK 
GEOSCAPE_IMAGE_MAX 

Definition at line 62 of file cp_map.c.

Types of elements that can be selected in map.

Enumerator:
MULTISELECT_TYPE_BASE 
MULTISELECT_TYPE_INSTALLATION 
MULTISELECT_TYPE_MISSION 
MULTISELECT_TYPE_AIRCRAFT 
MULTISELECT_TYPE_UFO 
MULTISELECT_TYPE_NONE 

Definition at line 94 of file cp_map.c.


Function Documentation

CASSERT ( lengthof(geoscapeImageNames = =GEOSCAPE_IMAGE_MAX  ) 
static void MAP3D_ScreenToMap ( const uiNode_t node,
int  x,
int  y,
vec2_t  pos 
) [static]

Return longitude and latitude of a point of the screen for 3D geoscape (globe).

Parameters:
[in] node The current menuNode we was clicking into (3dmap or map)
[in] x X coordinate on the screen that was clicked to
[in] y Y coordinate on the screen that was clicked to
[out] pos vec2_t was filled with longitude and latitude
See also:
MAP_3DMapToScreen

Definition at line 593 of file cp_map.c.

References ccs_s::angles, ccs, GLOBE_RADIUS, ccs_s::mapPos, ccs_s::mapSize, PITCH, RotatePointAroundVector(), VecToPolar(), Vector2Set, VectorNormalize(), VectorSet, and YAW.

Referenced by MAP_MapClick().

static void MAP3D_SmoothRotate ( void   )  [static]

smooth rotation of the 3D geoscape

Note:
updates slowly values of ccs.angles and ccs.zoom so that its value goes to smoothFinalGlobeAngle
See also:
MAP_DrawMap
MAP_CenterOnPoint

Definition at line 1273 of file cp_map.c.

References ccs_s::angles, ccs, curRotationSpeed, curZoomSpeed, f, qfalse, smoothAcceleration, smoothDeltaLength, smoothDeltaZoom, smoothFinalGlobeAngle, smoothFinalZoom, smoothRotation, VectorAdd, VectorCopy, VectorLength(), VectorScale, VectorSubtract, and ccs_s::zoom.

Referenced by MAP_DrawMap().

static void MAP_3DMapDrawLine ( const uiNode_t node,
const mapline_t line 
) [static]

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

Parameters:
[in] node The menu node which will be used for drawing dimensions. This is usually the 3Dgeoscape menu node.
[in] line The path which is to be drawn
See also:
MAP_MapCalcLine

Definition at line 781 of file cp_map.c.

References i, LINE_MAXPTS, MAP_3DMapToScreen(), mapline_s::numPoints, mapline_s::point, R_Color(), R_DrawLineStrip(), screenPoint_t::x, and screenPoint_t::y.

Referenced by MAP_DrawMapMarkers(), and MAP_DrawMapOnePhalanxAircraft().

static qboolean MAP_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] node Menu node
[in] pos vector that holds longitude and latitude
[out] x normalized (rotated and scaled) x value of mouseclick
[out] y normalized (rotated and scaled) y value of mouseclick
[out] z z value of the given latitude and longitude - might also be NULL if not needed
See also:
MAP_MapToScreen
MAP3D_ScreenToMap
Returns:
qtrue if the point is visible, qfalse else (if it's outside the node or on the wrong side of earth).
Note:
In the function, we do the opposite of MAP3D_ScreenToMap

Definition at line 450 of file cp_map.c.

References ccs_s::angles, ccs, GLOBE_RADIUS, int(), ccs_s::mapPos, ccs_s::mapSize, PITCH, PolarToVec(), qfalse, qtrue, RotatePointAroundVector(), Vector2Set, VectorSet, and YAW.

Referenced by MAP_3DMapDrawLine(), and MAP_AllMapToScreen().

qboolean MAP_AllMapToScreen ( const uiNode_t node,
const vec2_t  pos,
int *  x,
int *  y,
int *  z 
)

Call either MAP_MapToScreen or MAP_3DMapToScreen depending on the geoscape you're using.

Parameters:
[in] node Menu node
[in] pos Position on the map described by longitude and latitude
[out] x Pointer to the X coordinate on the screen
[out] y Pointer to the Y coordinate on the screen
[out] z Pointer to the Z coordinate on the screen (may be NULL if not needed)
Returns:
qtrue if pos corresponds to a point which is visible on the screen. Otherwise returns qfalse.
See also:
MAP_MapToScreen
MAP_3DMapToScreen

Definition at line 532 of file cp_map.c.

References cvar_s::integer, MAP_3DMapToScreen(), and MAP_MapToScreen().

Referenced by MAP_Draw3DMarkerIfVisible(), MAP_DrawAircraftHealthBar(), MAP_DrawBeam(), MAP_DrawBullets(), MAP_DrawMapMarkers(), MAP_DrawMapOneBase(), MAP_DrawMapOneInstallation(), MAP_DrawMapOneMission(), MAP_DrawMapOnePhalanxAircraft(), MAP_IsMapPositionSelected(), MAP_MapDrawEquidistantPoints(), and RADAR_DrawInMap().

float MAP_AngleOfPath ( const vec3_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] start Latitude and longitude of the position of the model.
[in] end Latitude and longitude of aimed point.
[in] direction vec3_t giving current direction of the model (NULL if the model is idle).
[out] ortVector If not NULL, 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 992 of file cp_map.c.

References cvar_s::integer, MAP_AngleOfPath2D(), and MAP_AngleOfPath3D().

Referenced by AIRFIGHT_GetNextPointInPath(), MAP_DrawMapMarkers(), and MAP_DrawMapOnePhalanxAircraft().

static float MAP_AngleOfPath2D ( const vec3_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] start Latitude and longitude of the position of the model.
[in] end Latitude and longitude of aimed point.
[in] direction vec3_t giving current direction of the model (NULL if the model is idle).
[out] ortVector If not NULL, 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 934 of file cp_map.c.

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

Referenced by MAP_AngleOfPath().

static float MAP_AngleOfPath3D ( const vec3_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] start Latitude and longitude of the position of the model.
[in] end Latitude and longitude of aimed point.
[in] direction vec3_t giving current direction of the model (NULL if the model is idle).
[out] ortVector If not NULL, 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 is the 'up' side

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 872 of file cp_map.c.

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

Referenced by MAP_AngleOfPath().

void MAP_CenterOnPoint_f ( void   ) 

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

Note:
Set smoothRotation to qtrue to allow a smooth rotation in MAP_DrawMap.
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.
See also:
MAP_GetGeoscapeAngle
MAP_DrawMap
MAP3D_SmoothRotate
MAP_SmoothTranslate

Definition at line 1253 of file cp_map.c.

References centerOnEventIdx, cvar_s::integer, MAP_GetGeoscapeAngle(), MAP_StartCenter(), smoothFinal2DGeoscapeCenter, smoothFinalGlobeAngle, and UI_GetActiveWindowName().

void MAP_CheckPositionBoundaries ( float *  pos  ) 

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

Parameters:
[in,out] pos Pointer to the 2 elements vector giving the position.

Definition at line 2329 of file cp_map.c.

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

static void MAP_ConvertObjectPositionToGeoscapePosition ( float *  vector,
const vec2_t  objectPos 
) [static]

Will set the vector for the geoscape position.

Parameters:
[out] vector The output vector. A two-dim vector for the flat geoscape, and a three-dim vector for the 3d geoscape
[in] objectPos The position vector of the object to transform.

Definition at line 1009 of file cp_map.c.

References cvar_s::integer, Vector2Set, and VectorSet.

Referenced by MAP_GetGeoscapeAngle(), MAP_GetMissionAngle(), and MAP_GetUFOAngle().

void MAP_DeactivateOverlay ( const char *  overlayID  ) 

Remove overlay.

Parameters:
[in] overlayID Name of the overlay you want to turn off.

Definition at line 2725 of file cp_map.c.

References MAP_IsNationOverlayActivated(), MAP_IsRadarOverlayActivated(), MAP_IsXVIOverlayActivated(), and MAP_SetOverlay().

Referenced by MAP_DeactivateOverlay_f(), and MAP_ResetAction().

static void MAP_DeactivateOverlay_f ( void   )  [static]

Console command to call MAP_DeactivateOverlay.

Definition at line 2750 of file cp_map.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), and MAP_DeactivateOverlay().

Referenced by MAP_InitStartup().

void MAP_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.

Parameters:
[in] node Menu node.
[in] pos Longitude and latitude of the marker to draw.
[in] theta Angle (degree) of the model to the horizontal.
[in] model The name of the model of the marker.
[in] skin Number of modelskin to draw on marker

Definition at line 551 of file cp_map.c.

References ccs_s::angles, ccs, GLOBE_RADIUS, cvar_s::integer, MAP_AllMapToScreen(), ccs_s::mapPos, ccs_s::mapSize, R_Draw2DMapMarkers(), R_Draw3DMapMarkers(), and VectorSet.

Referenced by MAP_DrawMapMarkers(), MAP_DrawMapOneBase(), MAP_DrawMapOneInstallation(), MAP_DrawMapOneMission(), and MAP_DrawMapOnePhalanxAircraft().

static void MAP_DrawAircraftHealthBar ( const uiNode_t node,
const aircraft_t aircraft 
) [static]

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

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

Definition at line 1547 of file cp_map.c.

References AIR_STATS_DAMAGE, ccs, aircraft_s::damage, green, MAP_AllMapToScreen(), aircraft_s::pos, R_DrawFill(), R_DrawRect(), red, aircraft_s::stats, Vector4Copy, yellow, and ccs_s::zoom.

Referenced by MAP_DrawMapMarkers(), and MAP_DrawMapOnePhalanxAircraft().

static void MAP_DrawBeam ( const uiNode_t node,
const vec3_t  start,
const vec3_t  end,
const vec4_t  color 
) [static]

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

Parameters:
[in] node Pointer to the node in which you want to draw.
[in] start Start position of the shot (on geoscape)
[in] end End position of the shot (on geoscape)
[in] color color of the beam
See also:
MAP_DrawMap

Definition at line 1382 of file cp_map.c.

References MAP_AllMapToScreen(), R_Color(), and R_DrawLine().

Referenced by MAP_DrawMapMarkers().

static void MAP_DrawBullets ( const uiNode_t node,
const vec3_t  pos 
) [static]

Draws on bunch of bullets on the geoscape map.

Parameters:
[in] node Pointer to the node in which you want to draw the bullets.
[in] pos 
See also:
MAP_DrawMap

Definition at line 1366 of file cp_map.c.

References BULLET_SIZE, MAP_AllMapToScreen(), R_DrawFill(), and yellow.

Referenced by MAP_DrawMapMarkers().

void MAP_DrawMap ( const uiNode_t node  ) 
static void MAP_DrawMapMarkers ( const uiNode_t node  )  [static]

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

Parameters:
[in] node The 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. distance between 2 items on geoscape (you should instead calculate it just after one of the item moved -- distance is not going to change when you rotate earth around itself and time is stopped eg.).
See also:
MAP_DrawMap

Todo:
we should only show healthbar if aircraft is fighting but it's a slow algo

Definition at line 1772 of file cp_map.c.

References _, aircraftProjectile_s::aimedAircraft, AIR_GetNextFromBase(), AIR_IsAircraftOnGeoscape(), aircraftProjectile_s::aircraftItem, ALIGN_UC, aircraftProjectile_s::angle, aircraftProjectile_s::attackerPos, aircraftProjectile_s::attackingAircraft, B_GetFoundedBaseByIDX(), aircraftProjectile_s::beam, craftitem_s::beamColor, aircraftProjectile_s::bullets, ccs, cls, uiNode_s::color, CP_IsXVIResearched(), objDef_s::craftitem, Cvar_GetInteger(), Cvar_Set(), linkedList_s::data, aircraft_s::direction, f, client_static_s::frametime, ccs_s::gameTimeScale, GEOSCAPE_IMAGE_MISSION_SELECTED, geoscapeImages, aircraftProjectile_s::hasMoved, image_s::height, i, aircraftProjectile_s::idleTarget, INS_GetFoundedInstallationByIDX(), cvar_s::integer, LinearInterpolation, MAP_3DMapDrawLine(), MAP_AllMapToScreen(), MAP_AngleOfPath(), MAP_Draw3DMarkerIfVisible(), MAP_DrawAircraftHealthBar(), MAP_DrawBeam(), MAP_DrawBullets(), MAP_DrawMapOneBase(), MAP_DrawMapOneInstallation(), MAP_DrawMapOneMission(), MAP_DrawMapOnePhalanxAircraft(), MAP_MapDrawEquidistantPoints(), MAP_MapDrawLine(), MAX_BASES, MAX_INSTALLATIONS, ccs_s::missions, objDef_s::model, aircraft_s::model, nation_s::name, ccs_s::nations, linkedList_s::next, aircraftProjectile_s::numInterpolationPoints, ccs_s::numNations, mapline_s::numPoints, ccs_s::numProjectiles, ccs_s::numUFOs, aircraft_s::oldDrawPos, mission_s::onGeoscape, mapline_s::point, nation_s::pos, aircraftProjectile_s::pos, aircraft_s::pos, aircraftProjectile_s::projectedPos, ccs_s::projectiles, Q_strcat(), qfalse, qtrue, R_Color(), R_DrawImage(), aircraft_s::route, RS_IsResearched_ptr(), SELECT_CIRCLE_RADIUS, ccs_s::selectedUFO, nation_s::stats, aircraft_s::tech, TEXT_XVI, UFO_IsUFOSeenOnGeoscape(), ccs_s::ufos, UI_DrawString(), UI_GetFontFromNode(), UI_RegisterText(), UI_ResetData(), va(), VectorCopy, white, image_s::width, nationInfo_s::xviInfection, and yellow.

Referenced by MAP_DrawMap().

static void MAP_DrawMapOneBase ( const uiNode_t node,
const base_t base,
qboolean  oneUFOVisible,
const char *  font 
) [static]
static void MAP_DrawMapOneInstallation ( const uiNode_t node,
const installation_t installation,
qboolean  oneUFOVisible,
const char *  font 
) [static]
static void MAP_DrawMapOneMission ( const uiNode_t node,
const mission_t ms 
) [static]
static void MAP_DrawMapOnePhalanxAircraft ( const uiNode_t node,
aircraft_t aircraft,
qboolean  oneUFOVisible 
) [static]

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

Parameters:
[in] node The menu node which will be used for drawing markers.
[in] aircraft Pointer to the aircraft to draw.
[in] oneUFOVisible Is 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 aircraft is fighting but it's a slow algo

Definition at line 1581 of file cp_map.c.

References AIR_STATS_WRANGE, AIR_TRANSIT, AIR_UFO, aircraft_s::aircraftTarget, ccs, Cvar_GetInteger(), aircraft_s::direction, GEOSCAPE_IMAGE_MISSION, geoscapeImages, image_s::height, cvar_s::integer, MAP_3DMapDrawLine(), MAP_AllMapToScreen(), MAP_AngleOfPath(), MAP_Draw3DMarkerIfVisible(), MAP_DrawAircraftHealthBar(), MAP_IsRadarOverlayActivated(), MAP_MapDrawEquidistantPoints(), MAP_MapDrawLine(), aircraft_s::model, mapline_s::numPoints, aircraft_s::oldDrawPos, mapline_s::point, aircraft_s::point, aircraft_s::pos, R_DrawImage(), aircraft_s::radar, RADAR_DrawInMap(), red, aircraft_s::route, SELECT_CIRCLE_RADIUS, ccs_s::selectedAircraft, aircraft_s::stats, aircraft_s::status, VectorCopy, image_s::width, and yellow.

Referenced by MAP_DrawMapMarkers().

static const char* MAP_GetAircraftText ( char *  buffer,
size_t  size,
const aircraft_t aircraft 
) [static]

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

Parameters:
[in] aircraft The aircraft to get the description for
[out] buffer The target buffer to store the text in
[in] size The size of the target buffer
Returns:
A pointer to the buffer that was given to this function
See also:
MAP_GetUFOText
MAP_GetMissionText

Definition at line 1690 of file cp_map.c.

References _, AIR_AircraftStatusToName(), AIR_GetTeamSize(), AIR_IDLE, AIR_STATS_FUELSIZE, AIR_STATS_SPEED, AIR_UFO, aircraft_s::aircraftTarget, CL_AircraftMenuStatsValues(), CL_SecondConvert(), Com_sprintf(), 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, aircraft_s::status, and va().

Referenced by MAP_DrawMap().

int MAP_GetCivilianNumberByPosition ( const vec2_t  pos  ) 

Get number of civilian on a map at given position.

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

Definition at line 2290 of file cp_map.c.

References byte, Com_Error(), ERR_DROP, MAP_GetColor(), MapIsNopopulation, MapIsRural, MapIsSuburban, MapIsUrban, MapIsVillage, MapIsWater, and MAPTYPE_POPULATION.

Referenced by CP_CreateCivilianTeam().

byte* MAP_GetColor ( const vec2_t  pos,
mapType_t  type 
)

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

Parameters:
[in] pos vec2_t Value of position on map to get the color value from. pos is longitude and latitude
[in] type determine the map to get the color from (there are different masks) one for the climazone (bases made use of this - there are grass, ice and desert base tiles available) and one for the nations
Returns:
Returns the color value at given position.
Note:
terrainPic, culturePic and populationPic are pointers to an rgba image in memory
See also:
MAP_GetTerrainType
MAP_GetCultureType
MAP_GetPopulationType

Todo:
add EQUAL_EPSILON here?

Definition at line 2374 of file cp_map.c.

References byte, Com_Error(), cultureHeight, culturePic, cultureWidth, ERR_DROP, MAPTYPE_CULTURE, MAPTYPE_NATIONS, MAPTYPE_POPULATION, MAPTYPE_TERRAIN, nationsHeight, nationsPic, nationsWidth, populationHeight, populationPic, populationWidth, terrainHeight, terrainPic, and terrainWidth.

Referenced by AIRFIGHT_ActionsAfterAirfight(), CP_ChooseMap(), CP_CreateBattleParameters(), CP_GetRandomPosOnGeoscape(), CP_UpdateNationXVIInfection(), MAP_GetCivilianNumberByPosition(), MAP_GetCultureTypeByPos(), MAP_GetNation(), MAP_GetPopulationTypeByPos(), MAP_GetTerrainTypeByPos(), MAP_MapClick(), and MAP_PositionFitsTCPNTypes().

static const char* MAP_GetCultureType ( const byte color  )  [static]

Translate color value to culture type.

See also:
MAP_GetColor
Parameters:
[in] color the 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 2207 of file cp_map.c.

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

Referenced by MAP_GetCultureTypeByPos().

static const char* MAP_GetCultureTypeByPos ( const vec2_t  pos  )  [inline, static]

Determine the culture type under a given position.

See also:
MAP_GetColor
Parameters:
[in] pos Map Coordinates to get the culture type from
Returns:
returns the zone name

Definition at line 2266 of file cp_map.c.

References byte, MAP_GetColor(), MAP_GetCultureType(), and MAPTYPE_CULTURE.

Referenced by MAP_PositionFitsTCPNTypes(), and MAP_PrintParameterStringByPos().

static void MAP_GetGeoscapeAngle ( float *  vector  )  [static]
static void MAP_GetMissionAngle ( float *  vector,
int  id 
) [static]

center to a mission

Definition at line 1020 of file cp_map.c.

References MAP_ConvertObjectPositionToGeoscapePosition(), MAP_GetMissionByIDX(), MAP_SelectMission(), and mission_s::pos.

Referenced by MAP_SelectObject_f().

static const char* MAP_GetMissionText ( char *  buffer,
size_t  size,
const mission_t mission 
) [static]

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

Parameters:
[in] mission The mission to get the description for
[out] buffer The target buffer to store the text in
[in] size The size of the target buffer
Returns:
A pointer to the buffer that was given to this function
See also:
MAP_GetAircraftText
MAP_GetUFOText

Definition at line 1654 of file cp_map.c.

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

Referenced by MAP_DrawMap().

nation_t* MAP_GetNation ( const vec2_t  pos  ) 

Translate nation map color to nation.

See also:
MAP_GetColor
Parameters:
[in] pos Map Coordinates to get the nation from
Returns:
returns the nation pointer with the given color on nationPic at given pos
NULL if no nation with the given color value was found
Note:
The coodinates already have to be transfored to map coordinates via MAP_ScreenToMap

Definition at line 2154 of file cp_map.c.

References byte, ccs, nation_s::color, Com_DPrintf(), DEBUG_CLIENT, i, MAP_GetColor(), MAPTYPE_NATIONS, ccs_s::nations, ccs_s::numNations, and VectorCompare.

Referenced by AB_BaseSearchedByNations(), B_BuildBase_f(), CP_BuildBaseGovernmentLeave(), CP_ChangeNationHappiness_f(), CP_CreateCivilianTeam(), CP_HarvestMissionGo(), CP_ReconMissionGroundGo(), CP_SpawnCrashSiteMission(), CP_SpawnRescueMission(), CP_UpdateNationXVIInfection(), INS_BuildInstallation_f(), MAP_PositionFitsTCPNTypes(), and NAT_UpdateHappinessForAllNations().

static const char* MAP_GetPopulationType ( const byte color  )  [static]

Translate color value to population type.

See also:
MAP_GetColor
Parameters:
[in] color the 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 2230 of file cp_map.c.

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

Referenced by MAP_GetPopulationTypeByPos().

static const char* MAP_GetPopulationTypeByPos ( const vec2_t  pos  )  [inline, static]

Determine the population type under a given position.

See also:
MAP_GetColor
Parameters:
[in] pos Map Coordinates to get the population type from
Returns:
returns the zone name

Definition at line 2278 of file cp_map.c.

References byte, MAP_GetColor(), MAP_GetPopulationType(), and MAPTYPE_POPULATION.

Referenced by MAP_PositionFitsTCPNTypes(), and MAP_PrintParameterStringByPos().

static const char* MAP_GetShortMissionText ( char *  buffer,
size_t  size,
const mission_t mission 
) [static]

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

Parameters:
[in] mission The mission to get the description for
[out] buffer The target buffer to store the text in
[in] size The size of the target buffer
Returns:
A pointer to the buffer that was given to this function
See also:
MAP_GetAircraftText
MAP_GetUFOText

Definition at line 1671 of file cp_map.c.

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

Referenced by MAP_UpdateGeoscapeDock().

const char* MAP_GetTerrainType ( const byte *const   color  ) 

Translate color value to terrain type.

See also:
MAP_GetColor
Parameters:
[in] color the 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 2180 of file cp_map.c.

References MapIsArctic, MapIsCold, MapIsDesert, MapIsMountain, MapIsTropical, MapIsWasted, and MapIsWater.

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

static const char* MAP_GetTerrainTypeByPos ( const vec2_t  pos  )  [inline, static]

Determine the terrain type under a given position.

See also:
MAP_GetColor
Parameters:
[in] pos Map Coordinates to get the terrain type from
Returns:
returns the zone name

Definition at line 2254 of file cp_map.c.

References byte, MAP_GetColor(), MAP_GetTerrainType(), and MAPTYPE_TERRAIN.

Referenced by MAP_PositionFitsTCPNTypes(), and MAP_PrintParameterStringByPos().

static void MAP_GetUFOAngle ( float *  vector,
int  idx 
) [static]
static const char* MAP_GetUFOText ( char *  buffer,
size_t  size,
const aircraft_t ufo 
) [static]

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

Parameters:
[in] ufo The UFO to get the description for
[out] buffer The target buffer to store the text in
[in] size The size of the target buffer
Returns:
A pointer to the buffer that was given to this function
See also:
MAP_GetAircraftText
MAP_GetMissionText

Definition at line 1725 of file cp_map.c.

References _, AIR_STATS_SPEED, CL_AircraftMenuStatsValues(), Com_sprintf(), Q_strcat(), aircraft_s::stats, UFO_AircraftToIDOnGeoscape(), and va().

Referenced by MAP_DrawMap(), and MAP_UpdateGeoscapeDock().

void MAP_Init ( void   ) 
void MAP_InitStartup ( void   ) 
static qboolean MAP_IsMapPositionSelected ( const uiNode_t node,
const vec2_t  pos,
int  x,
int  y 
) [static]

Tell if the specified position is considered clicked.

Definition at line 417 of file cp_map.c.

References MAP_AllMapToScreen(), qfalse, qtrue, and UI_MAP_DIST_SELECTION.

Referenced by MAP_MapClick().

qboolean MAP_IsNationOverlayActivated ( void   ) 

Definition at line 2768 of file cp_map.c.

References cvar_s::integer, and OVERLAY_NATION.

Referenced by MAP_DeactivateOverlay(), MAP_DrawMap(), and MAP_SetOverlay().

qboolean MAP_IsNight ( const vec2_t  pos  ) 

Check whether given position is Day or Night.

Parameters:
[in] pos Given position.
Returns:
True if given position is Night.

Definition at line 2346 of file cp_map.c.

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

Referenced by B_AssembleMap(), CP_StartMissionMap(), and MAP_DrawMapOneMission().

qboolean MAP_IsRadarOverlayActivated ( void   ) 
qboolean MAP_IsXVIOverlayActivated ( void   ) 

Definition at line 2773 of file cp_map.c.

References cvar_s::integer, and OVERLAY_XVI.

Referenced by MAP_DeactivateOverlay(), and MAP_DrawMap().

void MAP_MapCalcLine ( 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] start The point you start from
[in] end The point you go to
[out] line Contains the shortest path to go from start to end
See also:
MAP_MapDrawLine

Definition at line 646 of file cp_map.c.

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

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

void MAP_MapClick ( uiNode_t node,
int  x,
int  y 
)

Click on the map/geoscape.

Todo:
make this a function in cp_base.c - B_BuildBaseAtPos and make newBasePos static

Definition at line 282 of file cp_map.c.

References _, AIR_AircraftHasEnoughFuel(), AIR_GetNextFromBase(), AIR_IsAircraftOnGeoscape(), AIR_TRANSIT, B_GetFoundedBaseByIDX(), ccs, CL_GameTimeStop(), Cmd_ExecuteString(), CP_MissionToTypeString(), Cvar_GetInteger(), linkedList_s::data, aircraft_s::fuel, i, aircraft_s::idx, INS_GetFoundedInstallationByIDX(), cvar_s::integer, mission_s::location, MA_NEWBASE, MA_NEWINSTALLATION, MA_UFORADAR, MAP3D_ScreenToMap(), MAP_GetColor(), MAP_GetIDXByMission(), MAP_IsMapPositionSelected(), MAP_MapCalcLine(), MAP_MultiSelectListAddItem(), MAP_ResetAction(), MAP_ScreenToMap(), ccs_s::mapAction, MapIsWater, MAPTYPE_TERRAIN, MAX_BASES, MAX_INSTALLATIONS, ccs_s::missions, MULTISELECT_MAXSELECT, MULTISELECT_TYPE_AIRCRAFT, MULTISELECT_TYPE_BASE, MULTISELECT_TYPE_INSTALLATION, MULTISELECT_TYPE_MISSION, MULTISELECT_TYPE_UFO, installation_s::name, aircraft_s::name, base_s::name, multiSelect_s::nbSelect, newBasePos, linkedList_s::next, ccs_s::numBases, ccs_s::numInstallations, ccs_s::numUFOs, mission_s::onGeoscape, aircraft_s::point, multiSelect_s::popupText, installation_s::pos, aircraft_s::pos, base_s::pos, mission_s::pos, pos, aircraft_s::route, ccs_s::selectedAircraft, mission_s::stage, STAGE_NOT_ACTIVE, aircraft_s::status, TEXT_MULTISELECTION, aircraft_s::time, UFO_AircraftToIDOnGeoscape(), UFO_IsUFOSeenOnGeoscape(), ccs_s::ufos, UI_PushWindow(), UI_RegisterText(), and Vector2Copy.

Referenced by UI_RegisterMapNode().

void MAP_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.

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

Definition at line 813 of file cp_map.c.

References CIRCLE_DRAW_POINTS, i, cvar_s::integer, MAP_AllMapToScreen(), PerpendicularVector(), PolarToVec(), qfalse, qtrue, R_Color(), R_DrawLineStrip(), RotatePointAroundVector(), VecToPolar(), screenPoint_t::x, and screenPoint_t::y.

Referenced by MAP_DrawMapMarkers(), MAP_DrawMapOneBase(), MAP_DrawMapOneInstallation(), MAP_DrawMapOneMission(), MAP_DrawMapOnePhalanxAircraft(), and RADAR_DrawLineCoverage().

static void MAP_MapDrawLine ( const uiNode_t node,
const mapline_t line 
) [static]

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

Parameters:
[in] node The menu node which will be used for drawing dimensions. This is usually the geoscape menu node.
[in] line The path which is to be drawn
See also:
MAP_MapCalcLine

Definition at line 732 of file cp_map.c.

References ccs, i, LINE_MAXPTS, MAP_MapToScreen(), ccs_s::mapSize, mapline_s::numPoints, mapline_s::point, R_Color(), R_DrawLineStrip(), screenPoint_t::x, screenPoint_t::y, and ccs_s::zoom.

Referenced by MAP_DrawMapMarkers(), and MAP_DrawMapOnePhalanxAircraft().

qboolean MAP_MapToScreen ( const uiNode_t node,
const vec2_t  pos,
int *  x,
int *  y 
)

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

Parameters:
[in] node Menu node
[in] pos Position on the map described by longitude and latitude
[out] x X coordinate on the screen
[out] y Y coordinate on the screen
Returns:
qtrue if the screen position is within the boundaries of the menu node. Otherwise returns qfalse.
See also:
MAP_3DMapToScreen

Definition at line 498 of file cp_map.c.

References ccs, ccs_s::center, ccs_s::mapPos, ccs_s::mapSize, qfalse, qtrue, and ccs_s::zoom.

Referenced by MAP_AllMapToScreen(), MAP_DrawMapOneBase(), MAP_DrawMapOneInstallation(), and MAP_MapDrawLine().

static void MAP_MultiSelectExecuteAction_f ( void   )  [static]
static void MAP_MultiSelectListAddItem ( multiSelectType_t  itemType,
int  itemID,
const char *  itemDescription,
const char *  itemName 
) [static]

Add an element in the multiselection list.

Definition at line 177 of file cp_map.c.

References multiSelect_s::nbSelect, multiSelect_s::popupText, Q_strcat(), multiSelect_s::selectId, multiSelect_s::selectType, and va().

Referenced by MAP_MapClick().

void MAP_NotifyAircraftRemoved ( const aircraft_t aircraft  ) 

Notify that an aircraft has been removed from game.

Parameters:
[in] aircraft Pointer to the aircraft has been removed
[in] destroyed True if the UFO has been destroyed, false if it's been only set invisible (landed)

Definition at line 2139 of file cp_map.c.

References ccs, ccs_s::interceptAircraft, MAP_ResetAction(), and ccs_s::selectedAircraft.

Referenced by AIR_DeleteAircraft().

void MAP_NotifyMissionRemoved ( const mission_t mission  ) 

Notify that a mission has been removed.

Definition at line 2106 of file cp_map.c.

References ccs, MAP_ResetAction(), MAP_UpdateGeoscapeDock(), and ccs_s::selectedMission.

Referenced by CP_BaseAttackMissionIsFailure(), and CP_MissionRemoveFromGeoscape().

void MAP_NotifyUFODisappear ( const aircraft_t ufo  ) 

Notify that a UFO disappears on radars.

Definition at line 2534 of file cp_map.c.

References ccs, MAP_ResetAction(), MAP_UpdateGeoscapeDock(), and ccs_s::selectedUFO.

Referenced by UFO_CampaignCheckEvents().

void MAP_NotifyUFORemoved ( const aircraft_t ufo,
qboolean  destroyed 
)

Notify that a UFO has been removed.

Parameters:
[in] ufo Pointer to the ufo has been removed
[in] destroyed True if the UFO has been destroyed, false if it's been only set invisible (landed)

Definition at line 2120 of file cp_map.c.

References ccs, MAP_ResetAction(), MAP_UpdateGeoscapeDock(), and ccs_s::selectedUFO.

Referenced by CP_UFORemoveFromGeoscape().

base_t* MAP_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, NULL else

Definition at line 2437 of file cp_map.c.

References B_GetFoundedBaseByIDX(), GetDistanceOnGlobe(), MAX_BASES, MIN_DIST_BASE, and base_s::pos.

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

qboolean MAP_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] pos Location to be tested
[in] terrainTypes A linkedList_t containing a list of strings determining the terrain types to be tested for (e.g. "grass") may be NULL
[in] cultureTypes A linkedList_t containing a list of strings determining the culture types to be tested for (e.g. "western") may be NULL
[in] populationTypes A linkedList_t containing a list of strings determining the population types to be tested for (e.g. "suburban") may be NULL
[in] nations A linkedList_t containing a list of strings determining the nations to be tested for (e.g. "asia") may be NULL
Returns:
true if a location was found, otherwise false. If map is water, return false
Note:
The name TCPNTypes comes from terrain, culture, population, nation types

Definition at line 2464 of file cp_map.c.

References nation_s::id, LIST_ContainsString(), MAP_GetColor(), MAP_GetCultureTypeByPos(), MAP_GetNation(), MAP_GetPopulationTypeByPos(), MAP_GetTerrainTypeByPos(), MapIsWater, MAPTYPE_TERRAIN, qfalse, and qtrue.

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

void MAP_PrintParameterStringByPos ( const vec2_t  pos  ) 

Prints positions parameter in console.

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

Definition at line 2316 of file cp_map.c.

References Com_Printf(), MAP_GetCultureTypeByPos(), MAP_GetPopulationTypeByPos(), and MAP_GetTerrainTypeByPos().

Referenced by NAT_ScriptSanityCheck().

void MAP_ResetAction ( void   ) 
static void MAP_ScreenToMap ( const uiNode_t node,
int  x,
int  y,
vec2_t  pos 
) [static]

Return longitude and latitude of a point of the screen for 2D geoscape.

Parameters:
[in] node The current menuNode we was clicking into (3dmap or map)
[in] x X coordinate on the screen that was clicked to
[in] y Y coordinate on the screen that was clicked to
[out] pos vec2_t was filled with longitude and latitude

Definition at line 574 of file cp_map.c.

References ccs, ccs_s::center, ccs_s::mapPos, ccs_s::mapSize, and ccs_s::zoom.

Referenced by MAP_MapClick().

void MAP_Scroll_f ( void   ) 
void MAP_SelectAircraft ( aircraft_t aircraft  ) 
void MAP_SelectMission ( mission_t mission  ) 
static void MAP_SelectObject_f ( void   )  [static]

Center the view and select an object from the geoscape.

Definition at line 1085 of file cp_map.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), cvar_s::integer, MAP_GetMissionAngle(), MAP_GetUFOAngle(), MAP_StartCenter(), smoothFinal2DGeoscapeCenter, smoothFinalGlobeAngle, and type.

Referenced by MAP_InitStartup().

void MAP_SelectUFO ( aircraft_t ufo  ) 

Select the specified ufo in geoscape.

Definition at line 2076 of file cp_map.c.

References ccs, MAP_ResetAction(), and ccs_s::selectedUFO.

Referenced by MAP_GetGeoscapeAngle(), MAP_GetUFOAngle(), and MAP_MultiSelectExecuteAction_f().

void MAP_SetOverlay ( const char *  overlayID  ) 
static void MAP_SetOverlay_f ( void   )  [static]

Console command to call MAP_SetOverlay.

Definition at line 2704 of file cp_map.c.

References Cmd_Argc(), Cmd_Argv(), Com_Printf(), MAP_IsRadarOverlayActivated(), MAP_SetOverlay(), and radarOverlayWasSet.

Referenced by MAP_InitStartup().

static void MAP_SmoothTranslate ( void   )  [static]

smooth translation of the 2D geoscape

Note:
updates slowly values of ccs.center so that its value goes to smoothFinal2DGeoscapeCenter
updates slowly values of ccs.zoom so that its value goes to ZOOM_LIMIT
See also:
MAP_DrawMap
MAP_CenterOnPoint

Definition at line 1340 of file cp_map.c.

References ccs, ccs_s::center, qfalse, smoothFinal2DGeoscapeCenter, smoothFinalZoom, SMOOTHING_STEP_2D, smoothRotation, and ccs_s::zoom.

Referenced by MAP_DrawMap().

static void MAP_StartCenter ( void   )  [static]
void MAP_StopSmoothMovement ( void   ) 

stop smooth translation on geoscape

See also:
UI_RightClick
UI_MouseWheel

Definition at line 1327 of file cp_map.c.

References qfalse, and smoothRotation.

Referenced by UI_MapNodeMouseDown(), and UI_MapNodeZoom().

void MAP_UpdateGeoscapeDock ( void   ) 
void MAP_Zoom_f ( void   ) 

Variable Documentation

int centerOnEventIdx [static]

Current Event centered on 3D geoscape

Definition at line 130 of file cp_map.c.

Referenced by MAP_CenterOnPoint_f(), and MAP_GetGeoscapeAngle().

3D geoscape or flat geoscape

Definition at line 46 of file cp_map.c.

Referenced by UI_MapNodeMouseDown(), and UI_MapNodeZoom().

Definition at line 47 of file cp_map.c.

Definition at line 50 of file cp_map.c.

Referenced by CP_CampaignExit(), CP_LoadXML(), and CP_SaveXML().

Definition at line 48 of file cp_map.c.

Referenced by UI_MapNodeCapturedMouseMove(), and UI_MapNodeZoom().

Definition at line 49 of file cp_map.c.

Referenced by UI_MapNodeCapturedMouseMove(), and UI_MapNodeZoom().

int cultureHeight [static]

the width and height for the culture pic.

Definition at line 157 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

byte* culturePic [static]

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

Definition at line 155 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

int cultureWidth [static]

Definition at line 157 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

float curRotationSpeed = 0.0f [static]

The current rotation speed. Used for smooth rotating.

Definition at line 146 of file cp_map.c.

Referenced by MAP3D_SmoothRotate().

float curZoomSpeed = 0.0f [static]

The current zooming speed. Used for smooth zooming.

Definition at line 145 of file cp_map.c.

Referenced by MAP3D_SmoothRotate().

const float defaultBaseAngle = 90.0f [static]

Default angle value for 3D models like bases

Definition at line 149 of file cp_map.c.

Referenced by MAP_DrawMapOneBase(), MAP_DrawMapOneInstallation(), and MAP_DrawMapOneMission().

const char* geoscapeImageNames[] [static]
Initial value:
 {
    "pics/geoscape/mission",
    "pics/geoscape/circle",
    "pics/geoscape/circleactive",
    "pics/geoscape/base",
    "pics/geoscape/baseattack"
}

Definition at line 72 of file cp_map.c.

Referenced by MAP_InitStartup().

image_t* geoscapeImages[GEOSCAPE_IMAGE_MAX] [static]
const vec4_t green = {0.0f, 1.0f, 0.0f, 0.8f} [static]

Definition at line 133 of file cp_map.c.

Referenced by LoadTGA(), MAP_DrawAircraftHealthBar(), and TR_TransferAliensFromMission_f().

const float MIN_DIST_BASE = 4.0f [static]

Minimum distance between a new mission and an existing base.

Definition at line 2431 of file cp_map.c.

Referenced by MAP_PositionCloseToBase().

Data to manage the multi selection

Definition at line 114 of file cp_map.c.

int nationsHeight [static]

the width and height for the nation pic.

Definition at line 165 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

byte* nationsPic [static]

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

Definition at line 163 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

int nationsWidth [static]

Definition at line 165 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

int populationHeight [static]

the width and height for the population pic.

Definition at line 161 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

byte* populationPic [static]

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

Definition at line 159 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

int populationWidth [static]

Definition at line 161 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

this is the mask that is used to display day/night on (2d-)geoscape

Definition at line 46 of file cp_overlay.c.

radar texture

Definition at line 47 of file cp_overlay.c.

XVI alpha mask texture

Definition at line 48 of file cp_overlay.c.

const vec4_t red = {1.0f, 0.0f, 0.0f, 0.8f} [static]
const float smoothAcceleration = 0.06f [static]

the acceleration to use during a smooth motion (This affects the speed of the smooth motion)

Definition at line 144 of file cp_map.c.

Referenced by MAP3D_SmoothRotate().

float smoothDeltaLength = 0.0f [static]

angle/position difference that we need to change when smoothing

Definition at line 141 of file cp_map.c.

Referenced by MAP3D_SmoothRotate(), MAP_Scroll_f(), MAP_StartCenter(), and MAP_Zoom_f().

float smoothDeltaZoom = 0.0f [static]

zoom difference that we need to change when smoothing

Definition at line 143 of file cp_map.c.

Referenced by MAP3D_SmoothRotate(), MAP_Scroll_f(), MAP_StartCenter(), and MAP_Zoom_f().

vec2_t smoothFinal2DGeoscapeCenter = {0.5, 0.5} [static]

value of ccs.center for a smooth change of position (see MAP_CenterOnPoint)

Definition at line 140 of file cp_map.c.

Referenced by MAP_CenterOnPoint_f(), MAP_SelectObject_f(), MAP_SmoothTranslate(), and MAP_StartCenter().

vec3_t smoothFinalGlobeAngle = {0, GLOBE_ROTATE, 0} [static]

value of finale ccs.angles for a smooth change of angle (see MAP_CenterOnPoint)

Definition at line 139 of file cp_map.c.

Referenced by MAP3D_SmoothRotate(), MAP_CenterOnPoint_f(), MAP_Scroll_f(), MAP_SelectObject_f(), MAP_StartCenter(), and MAP_Zoom_f().

float smoothFinalZoom = 0.0f [static]

value of finale ccs.zoom for a smooth change of angle (see MAP_CenterOnPoint)

Definition at line 142 of file cp_map.c.

Referenced by MAP3D_SmoothRotate(), MAP_Scroll_f(), MAP_SmoothTranslate(), MAP_StartCenter(), and MAP_Zoom_f().

qboolean smoothRotation = qfalse [static]

qtrue if the rotation of 3D geoscape must me smooth

Definition at line 138 of file cp_map.c.

Referenced by MAP3D_SmoothRotate(), MAP_DrawMap(), MAP_Scroll_f(), MAP_SmoothTranslate(), MAP_StartCenter(), MAP_StopSmoothMovement(), and MAP_Zoom_f().

const float STANDARD_3D_ZOOM = 40.0f

Typical zoom to use in 3D geoscape to use same zoom values for both 2D and 3D geoscape.

Note:
Used to convert openGL coordinates of the sphere into screen coordinates
See also:
GLOBE_RADIUS

Definition at line 433 of file cp_map.c.

Referenced by R_Draw3DGlobe().

int terrainHeight [static]

the width and height for the terrain pic.

Definition at line 153 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

byte* terrainPic [static]

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

Definition at line 151 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

int terrainWidth [static]

Definition at line 153 of file cp_map.c.

Referenced by MAP_GetColor(), and MAP_Init().

char textStandard[2048] [static]

Buffer to display standard text in geoscape

Definition at line 129 of file cp_map.c.

Referenced by MAP_DrawMap().

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

Generated by  doxygen 1.6.2