cp_map.h File Reference

Header for Geoscape/Map management. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define GLOBE_ROTATE   -90
#define ROTATE_SPEED   0.5
#define KILOMETER_PER_DEGREE   111.2

Functions

nation_tMAP_GetNation (const vec2_t pos)
 Translate nation map color to nation.
qboolean MAP_AllMapToScreen (const struct uiNode_s *node, const vec2_t pos, int *x, int *y, int *z)
qboolean MAP_MapToScreen (const struct uiNode_s *node, const vec2_t pos, int *x, int *y)
void MAP_Draw3DMarkerIfVisible (const struct uiNode_s *node, const vec2_t pos, float angle, const char *model, int skin)
void MAP_MapDrawEquidistantPoints (const struct uiNode_s *node, const vec2_t center, const float angle, const vec4_t color)
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.
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.
void MAP_DrawMap (const struct uiNode_s *node)
void MAP_CenterOnPoint_f (void)
 Switch to next model on 2D and 3D geoscape.
void MAP_StopSmoothMovement (void)
 stop smooth translation on geoscape
base_tMAP_PositionCloseToBase (const vec2_t pos)
 Check if given pos is close to an existing base.
void MAP_Scroll_f (void)
 Command binding for map scrolling.
void MAP_Zoom_f (void)
 Command binding for map zooming.
void MAP_MapClick (struct uiNode_s *node, int x, int y)
 Click on the map/geoscape.
void MAP_ResetAction (void)
 No more special action in geoscape.
void MAP_SelectAircraft (aircraft_t *aircraft)
 Select the specified aircraft in geoscape.
void MAP_SelectUFO (aircraft_t *ufo)
 Select the specified ufo 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.
void MAP_NotifyUFODisappear (const aircraft_t *ufo)
 Notify that a UFO disappears on radars.
void MAP_InitStartup (void)
 Initialise MAP/Geoscape.
const char * MAP_GetTerrainType (const byte *color)
 Translate color value to terrain type.
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.
void MAP_Init (void)
qboolean MAP_PositionFitsTCPNTypes (const vec2_t posT, 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_SetOverlay (const char *overlayID)
 Switch overlay (turn on / off).
void MAP_DeactivateOverlay (const char *overlayID)
 Remove overlay.
void MAP_UpdateGeoscapeDock (void)
 Will add missions and UFOs to the geoscape dock panel.
qboolean MAP_IsRadarOverlayActivated (void)
qboolean MAP_IsXVIOverlayActivated (void)
qboolean MAP_IsNationOverlayActivated (void)

Variables

cvar_tcl_geoscape_overlay
cvar_tcl_mapzoommax
cvar_tcl_mapzoommin
cvar_tcl_3dmap

Detailed Description

Header for Geoscape/Map management.

Definition in file cp_map.h.


Define Documentation

#define GLOBE_ROTATE   -90

Definition at line 29 of file cp_map.h.

Referenced by CP_CampaignInit(), and MAP_StartCenter().

#define KILOMETER_PER_DEGREE   111.2

Definition at line 31 of file cp_map.h.

Referenced by AIR_GetOperationRange().

#define ROTATE_SPEED   0.5

Function Documentation

qboolean MAP_AllMapToScreen ( const struct uiNode_s node,
const vec2_t  pos,
int *  x,
int *  y,
int *  z 
)
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().

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

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

void MAP_Draw3DMarkerIfVisible ( const struct uiNode_s node,
const vec2_t  pos,
float  angle,
const char *  model,
int  skin 
)
void MAP_DrawMap ( const struct uiNode_s node  ) 
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().

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

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

void MAP_Init ( void   ) 
void MAP_InitStartup ( void   ) 
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 ( struct uiNode_s 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 struct uiNode_s node,
const vec2_t  center,
const float  angle,
const vec4_t  color 
)
qboolean MAP_MapToScreen ( const struct uiNode_s node,
const vec2_t  pos,
int *  x,
int *  y 
)
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   ) 
void MAP_Scroll_f ( void   ) 
void MAP_SelectAircraft ( aircraft_t aircraft  ) 
void MAP_SelectMission ( mission_t mission  ) 
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  ) 
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

3D geoscape or flat geoscape

Definition at line 46 of file cp_map.c.

Referenced by UI_MapNodeMouseDown(), and UI_MapNodeZoom().

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


Generated by  doxygen 1.6.2