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

Go to the source code of this file.

Data Structures

struct  radar_s
 

Macros

#define MAX_UFOONGEOSCAPE   8
 

Typedefs

typedef struct radar_s radar_t
 

Functions

void RADAR_UpdateStaticRadarCoverage (void)
 Update every static radar drawing (radar that don't move: base and installation radar). More...
 
void RADAR_UpdateWholeRadarOverlay (void)
 Update radar overlay of base, installation and aircraft range. More...
 
void RADAR_DeactivateRadarOverlay (void)
 Deactivate Radar overlay if there is no more UFO on geoscape. More...
 
void RADAR_NotifyUFORemoved (const struct aircraft_s *ufo, bool destroyed)
 
void RADAR_Initialise (radar_t *radar, float range, float trackingRange, float level, bool updateSourceRadarMap)
 Set radar range to new value. More...
 
void RADAR_InitialiseUFOs (radar_t *radar)
 Reset UFO sensored on radar. More...
 
void RADAR_UpdateBaseRadarCoverage_f (void)
 Update radar coverage when building/destroying new radar. More...
 
void RADAR_UpdateInstallationRadarCoverage (struct installation_s *installation, const float radarRange, const float trackingRadarRange)
 Update radar coverage when building/destroying new radar. More...
 
void RADAR_AddDetectedUFOToEveryRadar (const struct aircraft_s *ufo)
 
bool RADAR_CheckRadarSensored (const vec2_t pos)
 Check if the specified position is within base radar range. More...
 
bool RADAR_CheckUFOSensored (radar_t *radar, const vec2_t posRadar, const struct aircraft_s *ufo, bool detected)
 
void RADAR_SetRadarAfterLoading (void)
 Set radar to proper values after loading. More...
 

Variables

bool radarOverlayWasSet
 
const float RADAR_BASERANGE
 
const float RADAR_BASETRACKINGRANGE
 

Macro Definition Documentation

#define MAX_UFOONGEOSCAPE   8

Typedef Documentation

typedef struct radar_s radar_t

Function Documentation

void RADAR_AddDetectedUFOToEveryRadar ( const struct aircraft_s ufo)
bool RADAR_CheckRadarSensored ( const vec2_t  pos)

Check if the specified position is within base radar range.

Note
aircraft radars are not checked (and this is intended)
Returns
true if the position is inside one of the base radar range

Definition at line 377 of file cp_radar.cpp.

References B_GetNext(), GetDistanceOnGlobe(), INS_Foreach, base_s::pos, and radar.

Referenced by AIRFIGHT_ExecuteActions(), CP_CheckMissionVisibleOnGeoscape(), and CP_UFORemoveFromGeoscape().

bool RADAR_CheckUFOSensored ( radar_t radar,
const vec2_t  posRadar,
const struct aircraft_s ufo,
bool  detected 
)
void RADAR_DeactivateRadarOverlay ( void  )

Deactivate Radar overlay if there is no more UFO on geoscape.

Todo:
Is aircraft->radar cleared for crashed aircraft?

Definition at line 106 of file cp_radar.cpp.

References AIR_Foreach, B_GetNext(), GEO_IsRadarOverlayActivated(), GEO_SetOverlay(), INS_Foreach, radar_s::numUFOs, base_s::radar, and radarOverlayWasSet.

Referenced by RADAR_NotifyUFORemovedFromOneRadar(), RADAR_RemoveUFO(), and UFO_CampaignCheckEvents().

void RADAR_Initialise ( radar_t radar,
float  range,
float  trackingRange,
float  level,
bool  updateSourceRadarMap 
)

Set radar range to new value.

Parameters
[in,out]radarThe radar to update/initialize
[in]rangeNew range of the radar
[in]trackingRangeNew tracking range of the radar
[in]levelThe tech level of the radar
[in]updateSourceRadarMapif the radar overlay should be updated.

Definition at line 239 of file cp_radar.cpp.

References DETECTION_INTERVAL, EQUAL, radar_s::numUFOs, RADAR_UpdateStaticRadarCoverage(), RADAR_UpdateWholeRadarOverlay(), RADAR_UPGRADE_MULTIPLIER, radar_s::range, radar_s::trackingRange, and radar_s::ufoDetectionProbability.

Referenced by AIR_LoadAircraftXML(), AIR_NewAircraft(), B_Build(), B_LoadXML(), INS_Build(), INS_LoadXML(), RADAR_UpdateBaseRadarCoverage_f(), and RADAR_UpdateInstallationRadarCoverage().

void RADAR_InitialiseUFOs ( radar_t radar)

Reset UFO sensored on radar.

Parameters
[out]radarThe radar to initialize.

Definition at line 265 of file cp_radar.cpp.

References radar_s::numUFOs, OBJZERO, and radar_s::ufos.

Referenced by AIR_LoadAircraftXML(), AIR_ParseAircraft(), B_AircraftReturnedToHomeBase(), B_Build(), B_LoadXML(), and INS_LoadXML().

void RADAR_NotifyUFORemoved ( const struct aircraft_s ufo,
bool  destroyed 
)
void RADAR_SetRadarAfterLoading ( void  )

Set radar to proper values after loading.

Note
numUFOs is not saved, so we must calculate it.
should be called after loading.

Definition at line 453 of file cp_radar.cpp.

References aircraft_s::detected, GEO_UpdateGeoscapeDock(), RADAR_AddDetectedUFOToEveryRadar(), and UFO_GetNext().

Referenced by SAV_GameActionsAfterLoad().

void RADAR_UpdateBaseRadarCoverage_f ( void  )

Update radar coverage when building/destroying new radar.

Note
This must be called on each radar build/destruction because radar facilities may have different level.
This must also be called when radar installation become inactive or active (due to dependencies)
called with update_base_radar_coverage

Definition at line 277 of file cp_radar.cpp.

References B_GetFoundedBaseByIDX(), B_GetMaxBuildingLevel(), B_RADAR, cgi, cgame_import_s::Cmd_Argv(), CP_UpdateMissionVisibleOnGeoscape(), level, MAX_BASES, base_s::radar, RADAR_BASERANGE, RADAR_BASETRACKINGRANGE, and RADAR_Initialise().

void RADAR_UpdateInstallationRadarCoverage ( installation_t installation,
const float  radarRange,
const float  trackingRadarRange 
)

Update radar coverage when building/destroying new radar.

Parameters
[in,out]installationThe radartower to update
[in]radarRangeNew range of the radar
[in]trackingRadarRangeNew tracking range of the radar

Definition at line 311 of file cp_radar.cpp.

References cgi, CP_UpdateMissionVisibleOnGeoscape(), ERR_DROP, INSTALLATION_WORKING, installation_s::installationStatus, installation_s::installationTemplate, installation_s::radar, RADAR_Initialise(), RADAR_INSTALLATIONLEVEL, installationTemplate_s::radarRange, and installationTemplate_s::trackingRange.

Referenced by INS_DestroyInstallation(), INS_FinishInstallation(), and INS_LoadXML().

void RADAR_UpdateStaticRadarCoverage ( void  )

Update every static radar drawing (radar that don't move: base and installation radar).

Note
This is only called when radar range of bases change.

Definition at line 49 of file cp_radar.cpp.

References B_GetNext(), CP_AddRadarCoverage(), CP_InitializeRadarOverlay(), CP_UploadRadarCoverage(), INS_Foreach, INSTALLATION_WORKING, base_s::pos, base_s::radar, radar_s::range, and radar_s::trackingRange.

Referenced by RADAR_Initialise().

void RADAR_UpdateWholeRadarOverlay ( void  )

Update radar overlay of base, installation and aircraft range.

Definition at line 89 of file cp_radar.cpp.

References AIR_Foreach, AIR_IsAircraftOnGeoscape(), CP_InitializeRadarOverlay(), CP_UploadRadarCoverage(), and RADAR_DrawCoverage().

Referenced by AIR_CampaignRun(), AIR_DeleteAircraft(), GEO_SetOverlay(), and RADAR_Initialise().

Variable Documentation

const float RADAR_BASERANGE

Definition at line 39 of file cp_radar.cpp.

Referenced by B_Build(), and RADAR_UpdateBaseRadarCoverage_f().

const float RADAR_BASETRACKINGRANGE

Definition at line 40 of file cp_radar.cpp.

Referenced by B_Build(), and RADAR_UpdateBaseRadarCoverage_f().

bool radarOverlayWasSet

used to store the previous configuration of overlay before radar is automatically turned on (e.g when creating base or when UFO appears)

Definition at line 36 of file cp_radar.cpp.

Referenced by CP_LoadXML(), CP_SaveXML(), GEO_ResetAction(), GEO_SetOverlay_f(), and RADAR_DeactivateRadarOverlay().