UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_xvi.cpp File Reference

Campaign XVI code. More...

#include "../../cl_shared.h"
#include "cp_campaign.h"
#include "cp_overlay.h"
#include "cp_geoscape.h"
#include "cp_xvi.h"
#include "cp_missions.h"
#include "save/save_xvi.h"
Include dependency graph for cp_xvi.cpp:

Go to the source code of this file.

Macros

#define XVI_EVENT_NAME   "rs_alien_xvi_event"
 Name of the technology for the XVI event.

Functions

void CP_SpreadXVIAtPos (const vec2_t pos)
 Spread XVI at a given position.
void CP_ReduceXVIEverywhere (void)
 Reduce XVI everywhere.
void CP_UpdateNationXVIInfection (void)
 Update xviInfection value for each nation, using the XVI overlay.
int CP_GetAverageXVIRate (void)
 Return the average XVI rate.
void CP_SpreadXVI (void)
 Spread XVI for each mission that needs to be daily spread.
bool CP_IsXVIVisible (void)
 Returns true if the XVI effect should be visible to the player.
void CP_XVIInit (void)
bool XVI_SaveXML (xmlNode_t *p)
 XVI map saving callback.
bool XVI_LoadXML (xmlNode_t *p)
 Load the XVI map from the savegame.
void CP_StartXVISpreading_f (void)
 Start XVI spreading in campaign.
void CP_UpdateXVIMapButton (void)
 This will hide or show the geoscape button for handling the xvi overlay map.

Variables

static technology_trsAlienXVI
 technology for XVI event
static bool xviNationInfectionNeedsUpdate = false
 boolean used to know if each nation XVI level should be updated this day.
static const float XVI_FACTOR = 15.0f
 The factor that is used to determine XVI radius spreading. The higher this factor, the faster XVI will spread.
static const int XVI_DECREASE_DAYS = 7
 Number of days between 2 XVI decrease (everywhere around the world).

Detailed Description

Campaign XVI code.

Definition in file cp_xvi.cpp.

Macro Definition Documentation

◆ XVI_EVENT_NAME

#define XVI_EVENT_NAME   "rs_alien_xvi_event"

Name of the technology for the XVI event.

Definition at line 50 of file cp_xvi.cpp.

Referenced by CP_XVIInit().

Function Documentation

◆ CP_GetAverageXVIRate()

int CP_GetAverageXVIRate ( void )

Return the average XVI rate.

Note
XVI = eXtraterrestial Viral Infection

Definition at line 163 of file cp_xvi.cpp.

References ccs, NAT_Foreach, NAT_GetCurrentMonthInfo(), and nationInfo_t::xviInfection.

Referenced by CP_CheckLostCondition(), CP_CheckTriggerEvent(), MIS_IsSpawnedFromGround(), and STATS_Update_f().

◆ CP_IsXVIVisible()

bool CP_IsXVIVisible ( void )

Returns true if the XVI effect should be visible to the player.

Definition at line 196 of file cp_xvi.cpp.

References RS_IsResearched_ptr(), and rsAlienXVI.

Referenced by CP_UpdateXVIMapButton(), GEO_DrawMarkers(), and STATS_Update_f().

◆ CP_ReduceXVIEverywhere()

void CP_ReduceXVIEverywhere ( void )

Reduce XVI everywhere.

Note
This is called daily.

Definition at line 70 of file cp_xvi.cpp.

References ccs, CP_DecreaseXVILevelEverywhere(), CP_IsXVIStarted, XVI_DECREASE_DAYS, and xviNationInfectionNeedsUpdate.

Referenced by CP_CampaignRun().

◆ CP_SpreadXVI()

void CP_SpreadXVI ( void )

Spread XVI for each mission that needs to be daily spread.

Note
Daily called

Definition at line 181 of file cp_xvi.cpp.

References CP_IsXVIStarted, CP_SpreadXVIAtPos(), MIS_Foreach, and STAGE_SPREAD_XVI.

Referenced by CP_CampaignRun().

◆ CP_SpreadXVIAtPos()

void CP_SpreadXVIAtPos ( const vec2_t pos)

Spread XVI at a given position.

Parameters
[in]posPosition where XVI should be spread.

Definition at line 56 of file cp_xvi.cpp.

References CP_ChangeXVILevel(), CP_IsXVIStarted, XVI_FACTOR, and xviNationInfectionNeedsUpdate.

Referenced by CP_BuildBaseMissionIsSuccess(), CP_SpreadXVI(), and CP_SupplyMissionIsSuccess().

◆ CP_StartXVISpreading_f()

void CP_StartXVISpreading_f ( void )

Start XVI spreading in campaign.

Note
This is called when 'a new twist' technology is discovered.

Definition at line 276 of file cp_xvi.cpp.

References ccs, CP_CreateNewMission(), campaign_t::difficulty, i, and INTERESTCATEGORY_BUILDING.

◆ CP_UpdateNationXVIInfection()

void CP_UpdateNationXVIInfection ( void )

Update xviInfection value for each nation, using the XVI overlay.

Note
should be executed after all daily event that could change XVI overlay

Definition at line 88 of file cp_xvi.cpp.

References ccs, cgi, cp_campaignPool, CP_GetXVILevel(), CP_GetXVIMapDimensions(), GEO_GetColor(), GEO_GetNation(), nation_t::idx, MAPTYPE_NATIONS, Mem_PoolAllocTypeN, NAT_Foreach, OBJZERO, torad, Vector2Set, VectorCompare, and xviNationInfectionNeedsUpdate.

Referenced by CP_CampaignRun().

◆ CP_UpdateXVIMapButton()

void CP_UpdateXVIMapButton ( void )

This will hide or show the geoscape button for handling the xvi overlay map.

Definition at line 298 of file cp_xvi.cpp.

References cgi, and CP_IsXVIVisible().

Referenced by CP_CampaignInit(), CP_CampaignRun(), and SAV_GameActionsAfterLoad().

◆ CP_XVIInit()

void CP_XVIInit ( void )

Definition at line 201 of file cp_xvi.cpp.

References cgi, ERR_DROP, RS_GetTechByID(), rsAlienXVI, and XVI_EVENT_NAME.

Referenced by CP_CampaignInit().

◆ XVI_LoadXML()

bool XVI_LoadXML ( xmlNode_t * p)

Load the XVI map from the savegame.

See also
Savegame callback
SAV_InitXML
XVI_SaveXML

Definition at line 247 of file cp_xvi.cpp.

References cgi, CP_InitializeXVIOverlay(), CP_SetXVILevel(), level, SAVE_XVI_ENTRY, SAVE_XVI_HEIGHT, SAVE_XVI_LEVEL, SAVE_XVI_WIDTH, SAVE_XVI_X, SAVE_XVI_XVI, SAVE_XVI_Y, and xmlNode_t.

Referenced by SAV_Init().

◆ XVI_SaveXML()

bool XVI_SaveXML ( xmlNode_t * p)

XVI map saving callback.

Note
Only save transparency
See also
Savegame callback
SAV_InitXML
XVI_LoadXML

Definition at line 215 of file cp_xvi.cpp.

References cgi, CP_GetXVILevel(), CP_GetXVIMapDimensions(), SAVE_XVI_ENTRY, SAVE_XVI_HEIGHT, SAVE_XVI_LEVEL, SAVE_XVI_WIDTH, SAVE_XVI_X, SAVE_XVI_XVI, SAVE_XVI_Y, and xmlNode_t.

Referenced by SAV_Init().

Variable Documentation

◆ rsAlienXVI

technology_t* rsAlienXVI
static

technology for XVI event

Definition at line 35 of file cp_xvi.cpp.

Referenced by CP_IsXVIVisible(), and CP_XVIInit().

◆ XVI_DECREASE_DAYS

const int XVI_DECREASE_DAYS = 7
static

Number of days between 2 XVI decrease (everywhere around the world).

Definition at line 47 of file cp_xvi.cpp.

Referenced by CP_ReduceXVIEverywhere().

◆ XVI_FACTOR

const float XVI_FACTOR = 15.0f
static

The factor that is used to determine XVI radius spreading. The higher this factor, the faster XVI will spread.

Definition at line 44 of file cp_xvi.cpp.

Referenced by CP_SpreadXVIAtPos().

◆ xviNationInfectionNeedsUpdate

bool xviNationInfectionNeedsUpdate = false
static

boolean used to know if each nation XVI level should be updated this day.

Definition at line 38 of file cp_xvi.cpp.

Referenced by CP_ReduceXVIEverywhere(), CP_SpreadXVIAtPos(), and CP_UpdateNationXVIInfection().