Radars / sensor stuff, to detect and track ufos. More...
#include "../cl_shared.h"
#include "../cl_renderer.h"
#include "../renderer/r_image.h"
#include "../renderer/r_draw.h"
#include "../ui/ui_nodes.h"
#include "cp_campaign.h"
#include "cp_overlay.h"
#include "cp_map.h"
#include "cp_ufo.h"
Go to the source code of this file.
Functions | |
void | RADAR_UpdateStaticRadarCoverage (void) |
Update every static radar drawing (radar that don't move: base and installation radar). | |
static void | RADAR_DrawCoverage (const radar_t *radar, const vec2_t pos) |
Update map radar coverage with moving radar. | |
void | RADAR_UpdateWholeRadarOverlay (void) |
Update radar overlay of base, installation and aircraft range. | |
static void | RADAR_DrawLineCoverage (const uiNode_t *node, const radar_t *radar, const vec2_t pos) |
Draw only the "wire" Radar coverage. | |
void | RADAR_DrawInMap (const uiNode_t *node, const radar_t *radar, const vec2_t pos) |
Draw only the "wire" part of the radar coverage in geoscape. | |
void | RADAR_DeactivateRadarOverlay (void) |
Deactivate Radar overlay if there is no more UFO on geoscape. | |
static qboolean | RADAR_IsUFOSensored (const radar_t *radar, const aircraft_t *ufo) |
Check if UFO is in the sensored list. | |
static qboolean | RADAR_AddUFO (radar_t *radar, const aircraft_t *ufo) |
Add a UFO in the list of sensored UFOs. | |
static void | RADAR_RemoveUFO (radar_t *radar, const aircraft_t *ufo) |
UFO will no more be referenced by radar. | |
static void | RADAR_NotifyUFORemovedFromOneRadar (radar_t *radar, const aircraft_t *ufo, qboolean destroyed) |
Notify that the specified ufo has been removed from geoscape to one radar. | |
void | RADAR_NotifyUFORemoved (const aircraft_t *ufo, qboolean destroyed) |
Notify to every radar that the specified ufo has been removed from geoscape. | |
void | RADAR_Initialise (radar_t *radar, float range, float trackingRange, float level, qboolean updateSourceRadarMap) |
Set radar range to new value. | |
void | RADAR_InitialiseUFOs (radar_t *radar) |
Reset UFO sensored on radar. | |
void | RADAR_UpdateBaseRadarCoverage_f (void) |
Update radar coverage when building/destroying new radar. | |
void | RADAR_UpdateInstallationRadarCoverage (installation_t *installation, const float radarRange, const float trackingRadarRange) |
Update radar coverage when building/destroying new radar. | |
void | RADAR_AddDetectedUFOToEveryRadar (const aircraft_t const *ufo) |
Adds detected UFO to any radar in range (if not already detected). | |
qboolean | RADAR_CheckRadarSensored (const vec2_t pos) |
Check if the specified position is within base radar range. | |
qboolean | RADAR_CheckUFOSensored (radar_t *radar, const vec2_t posRadar, const aircraft_t *ufo, qboolean detected) |
Check if the specified UFO is inside the sensor range of the given radar. | |
void | RADAR_SetRadarAfterLoading (void) |
Set radar to proper values after loading. | |
Variables | |
qboolean | radarOverlayWasSet |
const float | RADAR_BASERANGE = 24.0f |
const float | RADAR_BASETRACKINGRANGE = 34.0f |
const float | RADAR_AIRCRAFTRANGE = 10.0f |
const float | RADAR_AIRCRAFTTRACKINGRANGE = 14.0f |
const float | RADAR_INSTALLATIONLEVEL = 1.0f |
static const float | RADAR_UPGRADE_MULTIPLIER = 0.4f |
this is the multiplier applied to the radar range when the radar levels up |
Radars / sensor stuff, to detect and track ufos.
Definition in file cp_radar.c.
void RADAR_AddDetectedUFOToEveryRadar | ( | const aircraft_t const * | ufo | ) |
Adds detected UFO to any radar in range (if not already detected).
[in] | ufo | Pointer to the UFO to check. |
Definition at line 427 of file cp_radar.c.
References AIR_GetNextFromBase(), AIR_IsAircraftOnGeoscape(), B_GetFoundedBaseByIDX(), GetDistanceOnGlobe(), INS_GetFoundedInstallationByIDX(), MAX_BASES, MAX_INSTALLATIONS, installation_s::pos, base_s::pos, aircraft_s::pos, installation_s::radar, aircraft_s::radar, radar, base_s::radar, RADAR_AddUFO(), RADAR_IsUFOSensored(), and radar_s::trackingRange.
Referenced by AIRFIGHT_ExecuteActions(), RADAR_CheckUFOSensored(), and RADAR_SetRadarAfterLoading().
static qboolean RADAR_AddUFO | ( | radar_t * | radar, | |
const aircraft_t * | ufo | |||
) | [static] |
Add a UFO in the list of sensored UFOs.
Definition at line 233 of file cp_radar.c.
References Com_Printf(), MAX_UFOONGEOSCAPE, radar_s::numUFOs, qfalse, qtrue, RADAR_IsUFOSensored(), and radar_s::ufos.
Referenced by RADAR_AddDetectedUFOToEveryRadar(), and RADAR_CheckUFOSensored().
Check if the specified position is within base radar range.
Definition at line 480 of file cp_radar.c.
References B_GetFoundedBaseByIDX(), GetDistanceOnGlobe(), INS_GetFoundedInstallationByIDX(), MAX_BASES, MAX_INSTALLATIONS, installation_s::pos, base_s::pos, qfalse, qtrue, and radar.
Referenced by AIRFIGHT_ExecuteActions(), CP_CheckMissionVisibleOnGeoscape(), and CP_UFORemoveFromGeoscape().
qboolean RADAR_CheckUFOSensored | ( | radar_t * | radar, | |
const vec2_t | posRadar, | |||
const aircraft_t * | ufo, | |||
qboolean | detected | |||
) |
Check if the specified UFO is inside the sensor range of the given radar.
[in,out] | radar | radar that may detect the UFO. |
[in] | posRadar | Position of radar |
[in,out] | ufo | aircraft that should be checked. |
[in] | detected | Is the UFO already detected by another radar? (Beware: this is not the same as ufo->detected) |
Probability to detect UFO each DETECTION_INTERVAL
DETECTION_INTERVAL
without changing the way radar works) Definition at line 519 of file cp_radar.c.
References DETECTION_INTERVAL, frand(), GetDistanceOnGlobe(), aircraft_s::pos, qfalse, qtrue, RADAR_AddDetectedUFOToEveryRadar(), RADAR_AddUFO(), RADAR_IsUFOSensored(), RADAR_RemoveUFO(), radar_s::range, and radar_s::trackingRange.
Referenced by UFO_CampaignCheckEvents().
void RADAR_DeactivateRadarOverlay | ( | void | ) |
Deactivate Radar overlay if there is no more UFO on geoscape.
Definition at line 180 of file cp_radar.c.
References AIR_GetNextFromBase(), B_GetFoundedBaseByIDX(), INS_GetFoundedInstallationByIDX(), MAP_IsRadarOverlayActivated(), MAP_SetOverlay(), MAX_BASES, MAX_INSTALLATIONS, radar_s::numUFOs, installation_s::radar, aircraft_s::radar, base_s::radar, and radarOverlayWasSet.
Referenced by RADAR_NotifyUFORemovedFromOneRadar(), RADAR_RemoveUFO(), and UFO_CampaignCheckEvents().
Update map radar coverage with moving radar.
Definition at line 89 of file cp_radar.c.
References CP_AddRadarCoverage(), qfalse, radar_s::range, and radar_s::trackingRange.
Referenced by RADAR_UpdateWholeRadarOverlay().
Draw only the "wire" part of the radar coverage in geoscape.
[in] | node | The menu node where radar coverage will be drawn. |
[in] | radar | Pointer to the radar that will be drawn. |
[in] | pos | Position of the radar. |
Definition at line 139 of file cp_radar.c.
References i, MAP_AllMapToScreen(), radar_s::numUFOs, aircraft_s::pos, R_Color(), R_DrawLineStrip(), RADAR_DrawLineCoverage(), UFO_IsUFOSeenOnGeoscape(), radar_s::ufos, screenPoint_t::x, and screenPoint_t::y.
Referenced by MAP_DrawMapOneBase(), MAP_DrawMapOneInstallation(), and MAP_DrawMapOnePhalanxAircraft().
static void RADAR_DrawLineCoverage | ( | const uiNode_t * | node, | |
const radar_t * | radar, | |||
const vec2_t | pos | |||
) | [static] |
Draw only the "wire" Radar coverage.
[in] | node | The menu node where radar coverage will be drawn. |
[in] | radar | Pointer to the radar that will be drawn. |
[in] | pos | Position of the radar. |
Definition at line 126 of file cp_radar.c.
References MAP_MapDrawEquidistantPoints(), radar_s::range, and radar_s::trackingRange.
Referenced by RADAR_DrawInMap().
void RADAR_Initialise | ( | radar_t * | radar, | |
float | range, | |||
float | trackingRange, | |||
float | level, | |||
qboolean | updateSourceRadarMap | |||
) |
Set radar range to new value.
[in,out] | radar | The radar to update/initialize |
[in] | range | New range of the radar |
[in] | trackingRange | New tracking range of the radar |
[in] | level | The tech level of the radar |
[in] | updateSourceRadarMap | if the radar overlay should be updated. |
Definition at line 332 of file cp_radar.c.
References radar_s::numUFOs, RADAR_UpdateStaticRadarCoverage(), RADAR_UpdateWholeRadarOverlay(), RADAR_UPGRADE_MULTIPLIER, radar_s::range, and radar_s::trackingRange.
Referenced by AIR_NewAircraft(), B_LoadXML(), B_SetUpBase(), INS_LoadXML(), INS_SetUpInstallation(), RADAR_UpdateBaseRadarCoverage_f(), and RADAR_UpdateInstallationRadarCoverage().
void RADAR_InitialiseUFOs | ( | radar_t * | radar | ) |
Reset UFO sensored on radar.
[out] | radar | The radar to initialize. |
Definition at line 356 of file cp_radar.c.
References radar_s::numUFOs, and radar_s::ufos.
Referenced by AIR_LoadAircraftXML(), AIR_ParseAircraft(), B_AircraftReturnedToHomeBase(), B_LoadXML(), B_SetUpBase(), and INS_LoadXML().
static qboolean RADAR_IsUFOSensored | ( | const radar_t * | radar, | |
const aircraft_t * | ufo | |||
) | [static] |
Check if UFO is in the sensored list.
Definition at line 219 of file cp_radar.c.
References i, radar_s::numUFOs, qfalse, qtrue, and radar_s::ufos.
Referenced by RADAR_AddDetectedUFOToEveryRadar(), RADAR_AddUFO(), and RADAR_CheckUFOSensored().
void RADAR_NotifyUFORemoved | ( | const aircraft_t * | ufo, | |
qboolean | destroyed | |||
) |
Notify to every radar that the specified ufo has been removed from geoscape.
[in] | ufo | Pointer to UFO to remove. |
[in] | destroyed | True if the UFO has been destroyed, false if it's only landed. |
Definition at line 298 of file cp_radar.c.
References AIR_GetNextFromBase(), B_GetFoundedBaseByIDX(), installation_s::founded, INS_GetFoundedInstallationByIDX(), INSTALLATION_WORKING, installation_s::installationStatus, MAX_BASES, MAX_INSTALLATIONS, installation_s::radar, aircraft_s::radar, base_s::radar, and RADAR_NotifyUFORemovedFromOneRadar().
Referenced by CP_UFORemoveFromGeoscape().
static void RADAR_NotifyUFORemovedFromOneRadar | ( | radar_t * | radar, | |
const aircraft_t * | ufo, | |||
qboolean | destroyed | |||
) | [static] |
Notify that the specified ufo has been removed from geoscape to one radar.
[in] | radar | Pointer to the radar where ufo should be removed. |
[in] | ufo | Pointer to UFO to remove. |
[in] | destroyed | True if the UFO has been destroyed, false if it's been only set invisible (landed) |
Definition at line 278 of file cp_radar.c.
References i, radar_s::numUFOs, RADAR_DeactivateRadarOverlay(), and radar_s::ufos.
Referenced by RADAR_NotifyUFORemoved().
static void RADAR_RemoveUFO | ( | radar_t * | radar, | |
const aircraft_t * | ufo | |||
) | [static] |
UFO will no more be referenced by radar.
Definition at line 254 of file cp_radar.c.
References i, MAX_UFOONGEOSCAPE, radar_s::numUFOs, RADAR_DeactivateRadarOverlay(), REMOVE_ELEM, and radar_s::ufos.
Referenced by RADAR_CheckUFOSensored().
void RADAR_SetRadarAfterLoading | ( | void | ) |
Set radar to proper values after loading.
Definition at line 572 of file cp_radar.c.
References ccs, aircraft_s::detected, MAP_UpdateGeoscapeDock(), ccs_s::numUFOs, RADAR_AddDetectedUFOToEveryRadar(), and UFO_GetByIDX().
Referenced by SAV_GameActionsAfterLoad().
void RADAR_UpdateBaseRadarCoverage_f | ( | void | ) |
Update radar coverage when building/destroying new radar.
Definition at line 368 of file cp_radar.c.
References B_GetFoundedBaseByIDX(), B_GetMaxBuildingLevel(), B_RADAR, Cmd_Argc(), Cmd_Argv(), Com_Printf(), CP_UpdateMissionVisibleOnGeoscape(), level, MAX_BASES, qtrue, 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.
[in,out] | installation | The radartower to update |
[in] | radarRange | New range of the radar |
[in] | trackingRadarRange | New tracking range of the radar |
Definition at line 402 of file cp_radar.c.
References Com_Error(), CP_UpdateMissionVisibleOnGeoscape(), ERR_DROP, installation_s::founded, INSTALLATION_WORKING, installation_s::installationStatus, installation_s::installationTemplate, qtrue, 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).
Definition at line 55 of file cp_radar.c.
References B_GetFoundedBaseByIDX(), CP_AddRadarCoverage(), CP_InitializeRadarOverlay(), CP_UploadRadarCoverage(), installation_s::founded, INS_GetFoundedInstallationByIDX(), INSTALLATION_WORKING, installation_s::installationStatus, MAX_BASES, MAX_INSTALLATIONS, installation_s::pos, base_s::pos, qfalse, qtrue, installation_s::radar, 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 97 of file cp_radar.c.
References AIR_GetNextFromBase(), AIR_IsAircraftOnGeoscape(), B_GetFoundedBaseByIDX(), CP_InitializeRadarOverlay(), CP_UploadRadarCoverage(), MAX_BASES, aircraft_s::pos, qfalse, aircraft_s::radar, and RADAR_DrawCoverage().
Referenced by AIR_DeleteAircraft(), CL_CampaignRunAircraft(), MAP_SetOverlay(), and RADAR_Initialise().
const float RADAR_AIRCRAFTRANGE = 10.0f |
Definition at line 45 of file cp_radar.c.
Referenced by AIR_NewAircraft().
const float RADAR_AIRCRAFTTRACKINGRANGE = 14.0f |
Definition at line 46 of file cp_radar.c.
Referenced by AIR_NewAircraft().
const float RADAR_BASERANGE = 24.0f |
Definition at line 43 of file cp_radar.c.
Referenced by RADAR_UpdateBaseRadarCoverage_f().
const float RADAR_BASETRACKINGRANGE = 34.0f |
Definition at line 44 of file cp_radar.c.
Referenced by RADAR_UpdateBaseRadarCoverage_f().
const float RADAR_INSTALLATIONLEVEL = 1.0f |
Definition at line 47 of file cp_radar.c.
Referenced by RADAR_UpdateInstallationRadarCoverage().
const float RADAR_UPGRADE_MULTIPLIER = 0.4f [static] |
this is the multiplier applied to the radar range when the radar levels up
Definition at line 49 of file cp_radar.c.
Referenced by RADAR_Initialise().
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 40 of file cp_radar.c.
Referenced by CP_LoadXML(), CP_SaveXML(), MAP_ResetAction(), MAP_SetOverlay_f(), and RADAR_DeactivateRadarOverlay().