cp_campaign.c File Reference

Single player campaign control. More...

#include "../client.h"
#include "../ui/ui_main.h"
#include "cp_campaign.h"
#include "cp_overlay.h"
#include "cp_mapfightequip.h"
#include "cp_hospital.h"
#include "cp_hospital_callbacks.h"
#include "cp_base_callbacks.h"
#include "cp_basedefence_callbacks.h"
#include "cp_team.h"
#include "cp_team_callbacks.h"
#include "cp_popup.h"
#include "cp_map.h"
#include "cp_ufo.h"
#include "cp_installation_callbacks.h"
#include "cp_alien_interest.h"
#include "cp_missions.h"
#include "cp_mission_triggers.h"
#include "cp_nations.h"
#include "cp_statistics.h"
#include "cp_time.h"
#include "cp_xvi.h"
#include "cp_aircraft_callbacks.h"
#include "cp_fightequip_callbacks.h"
#include "cp_produce_callbacks.h"
#include "cp_transfer_callbacks.h"
#include "cp_employee_callbacks.h"
#include "cp_market_callbacks.h"
#include "cp_research_callbacks.h"
#include "cp_uforecovery_callbacks.h"
#include "save/save_campaign.h"
Include dependency graph for cp_campaign.c:

Go to the source code of this file.

Data Structures

struct  updateCharacter_t

Defines

#define XVI_LOST_START_PERCENTAGE   0.20f
#define XVI_WON_START_PERCENTAGE   0.05f
#define MAX_CREDITS   10000000

Functions

void CP_ParseCharacterData (struct dbuffer *msg)
 Parses the character data which was send by G_MatchSendResults using G_SendCharacterData.
qboolean CP_IsRunning (void)
 Checks whether a campaign mode game is running.
static qboolean CP_MapIsSelectable (mission_t *mission, int mapIdx, const vec2_t pos)
 Check if a map may be selected for mission.
qboolean CP_ChooseMap (mission_t *mission, const vec2_t pos)
 Choose a map for given mission.
void CP_EndCampaign (qboolean won)
 Function to handle the campaign end.
void CP_CheckLostCondition (void)
 Checks whether the player has lost the campaign.
void CL_HandleNationData (qboolean won, mission_t *mis)
 Updates each nation's happiness and mission win/loss stats. Should be called at the completion or expiration of every mission. The nation where the mission took place will be most affected, surrounding nations will be less affected.
static void CP_CheckMissionEnd (void)
 Check for missions that have a timeout defined.
const char * CL_SecondConvert (int second)
 Converts a number of second into a char to display.
void CL_DateConvert (const date_t *date, byte *day, byte *month, short *year)
 Converts a number of days into the number of the current month and the current day in this month.
int CL_DateCreateDay (const short years, const byte months, const byte days)
 Converts a number of years+months+days into an "day" integer as used in date_t.
int CL_DateCreateSeconds (byte hours, byte minutes, byte seconds)
 Converts a number of hours+minutes+seconds into an "sec" integer as used in date_t.
void CL_DateConvertLong (const date_t *date, dateLong_t *dateLong)
 Converts a date from the engine in a (longer) human-readable format.
static void CL_CampaignFunctionPeriodicCall (int dt, qboolean updateRadarOverlay)
 Functions that should be called with a minimum time lapse (will be called at least every DETECTION_INTERVAL).
qboolean CP_OnGeoscape (void)
void CL_CampaignRun (void)
 Called every frame when we are in geoscape view.
void CL_UpdateCredits (int credits)
 Sets credits and update mn_credits cvar.
static qboolean CP_LoadMapDefStatXML (mxml_node_t *parent)
 Load mapDef statistics.
qboolean CP_LoadXML (mxml_node_t *parent)
 Load callback for savegames in XML Format.
static qboolean CP_SaveMapDefStatXML (mxml_node_t *parent)
 Save mapDef statistics.
qboolean CP_SaveXML (mxml_node_t *parent)
 Save callback for savegames in XML Format.
void CP_StartSelectedMission (void)
 Starts a selected mission.
static float CP_GetWinProbabilty (const mission_t *mis, const base_t *base, const aircraft_t *aircraft)
 Calculates the win probability for an auto mission.
static void CL_AutoMissionAlienCollect (aircraft_t *aircraft)
 Collect alien bodies for auto missions.
void CL_GameAutoGo (mission_t *mission)
 Handles the auto mission for none storyrelated missions.
void CP_InitMissionResults (qboolean won)
static qboolean CL_ShouldUpdateSoldierRank (const rank_t *rank, const character_t *chr)
 Checks whether a soldier should be promoted.
void CL_UpdateCharacterStats (const base_t *base, const aircraft_t *aircraft)
 Update employees stats after mission.
static void CP_AddCampaignCallbackCommands (void)
 registers callback commands that are used by campaign
static void CP_AddCampaignCommands (void)
static void CP_RemoveCampaignCallbackCommands (void)
 registers callback commands that are used by campaign
static void CP_RemoveCampaignCommands (void)
void CP_CampaignInit (campaign_t *campaign, qboolean load)
 Called at new game and load game.
void CP_CampaignExit (void)
campaign_tCL_GetCampaign (const char *name)
 Returns the campaign pointer from global campaign array.
void CL_ResetSinglePlayerData (void)
 Will clear most of the parsed singleplayer data.
void CP_GetRandomPosOnGeoscape (vec2_t pos, qboolean noWater)
 Determines a random position on geoscape.
qboolean CP_GetRandomPosOnGeoscapeWithParameters (vec2_t pos, const linkedList_t *terrainTypes, const linkedList_t *cultureTypes, const linkedList_t *populationTypes, const linkedList_t *nations)
 Determines a random position on geoscape that fulfills certain criteria given via parameters.
int CP_GetSalaryAdministrative (void)
int CP_GetSalaryBaseEmployee (employeeType_t type)
int CP_GetSalaryAdminEmployee (employeeType_t type)
int CP_GetSalaryRankBonusEmployee (employeeType_t type)
int CP_GetSalaryUpKeepBase (const base_t *base)
void CP_InitStartup (void)

Variables

struct memPool_scp_campaignPool
ccs_t ccs
cvar_tcp_campaign
cvar_tcp_start_employees
cvar_tcp_missiontest
static const int monthLength [MONTHS_PER_YEAR] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
const int DETECTION_INTERVAL = (SECONDS_PER_HOUR / 2)
 delay between actions that must be executed independently of time scale
static const cmdList_t game_commands []

Detailed Description

Single player campaign control.

Definition in file cp_campaign.c.


Define Documentation

#define MAX_CREDITS   10000000

Definition at line 736 of file cp_campaign.c.

Referenced by CL_UpdateCredits().

#define XVI_LOST_START_PERCENTAGE   0.20f

Definition at line 385 of file cp_campaign.c.

#define XVI_WON_START_PERCENTAGE   0.05f

Definition at line 386 of file cp_campaign.c.


Function Documentation

static void CL_AutoMissionAlienCollect ( aircraft_t aircraft  )  [static]
static void CL_CampaignFunctionPeriodicCall ( int  dt,
qboolean  updateRadarOverlay 
) [static]

Functions that should be called with a minimum time lapse (will be called at least every DETECTION_INTERVAL).

Parameters:
[in] dt Ellapsed second since last call.
[in] updateRadarOverlay true if radar overlay should be updated (only for drawing purpose)
See also:
CL_CampaignRun

Definition at line 586 of file cp_campaign.c.

References AB_UpdateStealthForAllBase(), AIRFIGHT_CampaignRunBaseDefence(), AIRFIGHT_CampaignRunProjectiles(), CL_CampaignRunAircraft(), CP_CheckNewMissionDetectedOnGeoscape(), UFO_CampaignCheckEvents(), UFO_CampaignRunUFOs(), and UFO_UpdateAlienInterestForAllBasesAndInstallations().

Referenced by CL_CampaignRun().

void CL_CampaignRun ( void   ) 
void CL_DateConvert ( const date_t date,
byte day,
byte month,
short *  year 
)

Converts a number of days into the number of the current month and the current day in this month.

Note:
The seconds from "date" are ignored here.
The function always starts calculation from Jan. and also catches new years.
Parameters:
[in] date Contains the number of days to be converted.
[out] day The day in the month above.
[out] month The month. [1-12]
[out] year The year.

< Return month in range [1-12]

Definition at line 494 of file cp_campaign.c.

References byte, date_s::day, DAYS_PER_YEAR, i, monthLength, and MONTHS_PER_YEAR.

Referenced by CL_DateConvertLong().

void CL_DateConvertLong ( const date_t date,
dateLong_t dateLong 
)

Converts a date from the engine in a (longer) human-readable format.

Parameters:
[in] date Contains the date to be converted.
[out] dateLong The converted date.

Todo:
Make this conversion a function as well (DateConvertSeconds?) See also CL_SecondConvert

Definition at line 571 of file cp_campaign.c.

References CL_DateConvert(), dateLong_s::day, dateLong_s::hour, dateLong_s::min, dateLong_s::month, dateLong_s::sec, date_s::sec, SECONDS_PER_HOUR, and dateLong_s::year.

Referenced by CL_CampaignRun(), CL_EventAddMail_f(), CL_UpdateTime(), MS_TimestampedText(), SAV_GameSave(), UP_OpenMail_f(), and UP_SetMailHeader().

int CL_DateCreateDay ( const short  years,
const byte  months,
const byte  days 
)

Converts a number of years+months+days into an "day" integer as used in date_t.

Parameters:
[in] years The number of years to sum up.
[in] months The number of months to sum up [1-12]
[in] days The number of days to sum up.
Returns:
The total number of days.

Definition at line 526 of file cp_campaign.c.

References DAYS_PER_YEAR, i, and monthLength.

int CL_DateCreateSeconds ( byte  hours,
byte  minutes,
byte  seconds 
)

Converts a number of hours+minutes+seconds into an "sec" integer as used in date_t.

Parameters:
[in] hours The number of hours to sum up.
[in] minutes The number of minutes to sum up.
[in] seconds The number of seconds to sum up.
Returns:
The total number of seconds.

Definition at line 550 of file cp_campaign.c.

References SECONDS_PER_HOUR.

void CL_GameAutoGo ( mission_t mission  ) 
campaign_t* CL_GetCampaign ( const char *  name  ) 

Returns the campaign pointer from global campaign array.

Parameters:
name Name of the campaign
Returns:
campaign_t pointer to campaign with name or NULL if not found

Definition at line 1576 of file cp_campaign.c.

References ccs_s::campaigns, Com_Printf(), campaign_s::id, and ccs_s::numCampaigns.

Referenced by CL_ParseResearchableCampaignStates(), CL_ParseResearchedCampaignItems(), CP_LoadXML(), and GAME_CP_Start_f().

void CL_HandleNationData ( qboolean  won,
mission_t mis 
)

Updates each nation's happiness and mission win/loss stats. Should be called at the completion or expiration of every mission. The nation where the mission took place will be most affected, surrounding nations will be less affected.

Todo:
Scoring should eventually be expanded to include such elements as infected humans and mission objectives other than xenocide.

Todo:
HACK: This should be handled properly, i.e. civilians should only factor into the scoring if the mission objective is actually to save civilians.
Todo:
The score for aliens is always negative or zero currently, but this should be dependent on the mission objective. In a mission that has a special objective, the amount of killed aliens should only serve to increase the score, not reduce the penalty.

Definition at line 396 of file cp_campaign.c.

References missionResults_s::aliensKilled, missionResults_s::aliensStunned, missionResults_s::aliensSurvived, ccs_s::battleParameters, ccs_s::campaignStats, missionResults_s::civiliansKilled, missionResults_s::civiliansKilledFriendlyFire, missionResults_s::civiliansSurvived, Com_DPrintf(), DEBUG_CLIENT, nationInfo_s::happiness, HAPPINESS_MAX_MISSION_IMPACT, i, nation_s::id, mission_s::id, ccs_s::missionResults, stats_s::missionsLost, stats_s::missionsWon, NAT_SetHappiness(), battleParam_s::nation, ccs_s::nations, ccs_s::numNations, and nation_s::stats.

Referenced by CL_GameAutoGo(), and CP_MissionEnd().

void CL_ResetSinglePlayerData ( void   ) 

Will clear most of the parsed singleplayer data.

See also:
INV_InitInventory
CL_ReadSinglePlayerData

Todo:
subsystems should have Init/Shutdown functions like callbacks have and do these cleanups for themselves
Note:
Most of them has InitStartup but not working like the callback init/shutdown ones in pair
Todo:
this isn't working per per-base, as get next from base won't give every available craft (not every craft must be in a base). Maybe we should use the tags for the memory allocation for linked list (like we do for the game shared object already, too)

Definition at line 1597 of file cp_campaign.c.

References aircraft_s::acTeam, AIR_GetNextFromBase(), base_s::aircraft, ccs_s::alienBases, ccs_s::alienCategories, ccs_s::alienTeams, B_GetBaseByIDX(), CHRSH_IsTeamDefAlien(), ccs_s::cities, CL_FreeDynamicEventMail(), cls, Com_GetMapDefByIDX(), cp_messageStack, csi, E_ResetEmployees(), alienTeamCategory_s::equipment, LIST_Delete(), Mem_FreePool, ccs_s::missions, ccs_s::numAlienCategories, ccs_s::numAliensTD, ccs_s::numBases, client_static_s::numMDs, csi_s::numTeamDefs, RS_ResetTechs(), ccs_s::storedUFOs, td, csi_s::teamDef, and mapDef_s::timesAlreadyUsed.

Referenced by GAME_CP_InitStartup(), and GAME_CP_Shutdown().

const char* CL_SecondConvert ( int  second  ) 

Converts a number of second into a char to display.

Parameters:
[in] second Number of second.
Todo:
Abstract the code into an extra function (DateConvertSeconds?) see also CL_DateConvertLong

Definition at line 474 of file cp_campaign.c.

References Com_sprintf(), and SECONDS_PER_HOUR.

Referenced by CL_DisplayPopupInterceptMission(), and MAP_GetAircraftText().

static qboolean CL_ShouldUpdateSoldierRank ( const rank_t rank,
const character_t chr 
) [static]

Checks whether a soldier should be promoted.

Parameters:
[in] rank The rank to check for
[in] chr The character to check a potential promotion for
Todo:
(Zenerka 20080301) extend ranks and change calculations here.

Definition at line 1224 of file cp_campaign.c.

References ABILITY_MIND, EMPL_SOLDIER, KILLED_CIVILIANS, KILLED_ENEMIES, KILLED_TEAM, rank_s::killedEnemies, rank_s::killedOthers, chrScoreGlobal_s::kills, rank_s::mind, qfalse, qtrue, character_s::score, chrScoreGlobal_s::skills, and rank_s::type.

Referenced by CL_UpdateCharacterStats().

void CL_UpdateCharacterStats ( const base_t base,
const aircraft_t aircraft 
)

Update employees stats after mission.

Parameters:
[in] base The base where the team lives.
[in] aircraft The aircraft used for the mission.
Note:
Soldier promotion is being done here.

Todo:
use chrScore_t to determine negative influence on soldier here, like killing too many civilians and teammates can lead to unhire and disband such soldier, or maybe rank degradation.

Definition at line 1250 of file cp_campaign.c.

References _, AIR_IsEmployeeInAircraft(), chrScoreGlobal_s::assignedMissions, employee_s::chr, cl, CL_GetRankByIdx(), CL_ShouldUpdateSoldierRank(), Com_DPrintf(), Com_sprintf(), cp_messageBuffer, DEBUG_CLIENT, E_GetNextFromBase(), EMPL_SOLDIER, aircraft_s::homebase, character_s::HP, MS_AddNewMessage(), MSG_PROMOTION, rank_s::name, character_s::name, base_s::name, ccs_s::numRanks, qfalse, chrScoreGlobal_s::rank, and character_s::score.

Referenced by CP_MissionEnd().

void CL_UpdateCredits ( int  credits  ) 
static void CP_AddCampaignCallbackCommands ( void   )  [static]

registers callback commands that are used by campaign

Todo:
callbacks should be registered on menu push (what about sideeffects for commands that are called from different menus?)
See also:
CP_AddCampaignCommands
CP_RemoveCampaignCallbackCommands

Definition at line 1424 of file cp_campaign.c.

References AIM_InitCallbacks(), AIR_InitCallbacks(), B_InitCallbacks(), BDEF_InitCallbacks(), BS_InitCallbacks(), CP_TEAM_InitCallbacks(), E_InitCallbacks(), HOS_InitCallbacks(), INS_InitCallbacks(), PR_InitCallbacks(), RS_InitCallbacks(), TR_InitCallbacks(), and UR_InitCallbacks().

Referenced by CP_AddCampaignCommands().

static void CP_AddCampaignCommands ( void   )  [static]
void CP_CampaignExit ( void   ) 
void CP_CampaignInit ( campaign_t campaign,
qboolean  load 
)

Called at new game and load game.

Parameters:
[in] load true if we are loading game, false otherwise
[in] campaign Pointer to campaign - it will be set to ccs.curCampaign here.

< Initialise all data in the research tree.

Todo:
this should be called in this function for new campaigns too but as researched items not yet set, it can't. It's called in B_SetUpFirstBase for new campaigns

Definition at line 1492 of file cp_campaign.c.

References ccs_s::angles, B_SelectBase(), BS_InitMarket(), ccs_s::center, CL_GameTimeStop(), CL_PopupInit(), CL_ResetAlienInterest(), CL_ScriptSanityCheck(), CL_UpdateCredits(), CL_UpdateTime(), Cmd_ExecuteString(), CP_AddCampaignCommands(), CP_InitializeSpawningDelay(), CP_InitializeXVIOverlay(), CP_InitOverlay(), CP_XVIInit(), campaign_s::credits, ccs_s::curCampaign, Cvar_SetValue(), campaign_s::date, ccs_s::date, date_s::day, GLOBE_ROTATE, MAP_Init(), PR_ProductionInit(), qtrue, RS_InitTree(), date_s::sec, SECONDS_PER_DAY, UI_InitStack(), ccs_s::XVIShowMap, YAW, and ccs_s::zoom.

Referenced by CP_LoadXML(), and GAME_CP_Start_f().

void CP_CheckLostCondition ( void   ) 

Checks whether the player has lost the campaign.

Todo:
Should we make the campaign lost when a player loses all his bases? until he has set up a base again, the aliens might have invaded the whole world ;) - i mean, removing the credits check here.

Definition at line 324 of file cp_campaign.c.

References _, campaign_s::basecost, CP_EndCampaign(), CP_GetAverageXVIRate(), ccs_s::credits, ccs_s::curCampaign, Cvar_SetValue(), nationInfo_s::happiness, cvar_s::integer, campaign_s::maxAllowedXVIRateUntilLost, campaign_s::minhappiness, ccs_s::nations, campaign_s::negativeCreditsUntilLost, ccs_s::numBases, ccs_s::numNations, qfalse, qtrue, nation_s::stats, TEXT_STANDARD, and UI_RegisterText().

Referenced by CL_CampaignRun(), CL_GameAutoGo(), and CP_MissionEnd().

static void CP_CheckMissionEnd ( void   )  [static]

Check for missions that have a timeout defined.

Definition at line 451 of file cp_campaign.c.

References CP_CheckMissionLimitedInTime(), CP_MissionStageEnd(), linkedList_s::data, ccs_s::date, Date_LaterThan(), mission_s::finalDate, ccs_s::missions, linkedList_s::next, and next.

Referenced by CL_CampaignRun().

qboolean CP_ChooseMap ( mission_t mission,
const vec2_t  pos 
)

Choose a map for given mission.

Parameters:
[in,out] mission Pointer to the mission where a new map should be added
[in] pos position of the mission (NULL if the position will be chosen afterwards)
[in] ufoCrashed true if the ufo is crashed
Returns:
qfalse if could not set mission

< Total number of maps fulfilling mission conditions.

< Number of maps fulfilling mission conditions and that appeared less often during game.

Definition at line 201 of file cp_campaign.c.

References mission_s::category, cls, Com_DPrintf(), Com_Error(), Com_GetMapDefByIDX(), Com_GetMapDefinitionByID(), Com_Printf(), Com_UFOTypeToShortName(), CP_MapIsSelectable(), mission_s::crashed, DEBUG_CLIENT, ERR_DROP, i, mapDef_s::id, cvar_s::integer, INTERESTCATEGORY_RESCUE, MAP_GetColor(), mission_s::mapDef, MapIsWater, MAPTYPE_TERRAIN, client_static_s::numMDs, qfalse, qtrue, mapDef_s::timesAlreadyUsed, mission_s::ufo, and aircraft_s::ufotype.

Referenced by CP_HarvestMissionGo(), CP_ReconMissionGroundGo(), CP_SpawnCrashSiteMission(), CP_SpawnRescueMission(), and CP_TerrorMissionGo().

void CP_EndCampaign ( qboolean  won  ) 

Function to handle the campaign end.

Definition at line 309 of file cp_campaign.c.

References Cmd_ExecuteString(), Com_Drop(), qtrue, and UI_InitStack().

Referenced by CP_CheckLostCondition(), and CP_EndGame_f().

void CP_GetRandomPosOnGeoscape ( vec2_t  pos,
qboolean  noWater 
)

Determines a random position on geoscape.

Parameters:
[out] pos The position that will be overwritten. pos[0] is within -180, +180. pos[1] within -90, +90.
[in] noWater True if the position should not be on water
See also:
CP_GetRandomPosOnGeoscapeWithParameters
Note:
The random positions should be roughly uniform thanks to the non-uniform distribution used.
This function always returns a value.

Definition at line 1692 of file cp_campaign.c.

References Com_DPrintf(), DEBUG_CLIENT, f, frand(), MAP_GetColor(), MapIsWater, MAPTYPE_TERRAIN, and todeg.

Referenced by AB_SetAlienBasePosition(), UFO_SetRandomDest(), and UFO_SetRandomPos().

qboolean CP_GetRandomPosOnGeoscapeWithParameters ( vec2_t  pos,
const linkedList_t terrainTypes,
const linkedList_t cultureTypes,
const linkedList_t populationTypes,
const linkedList_t nations 
)

Determines a random position on geoscape that fulfills certain criteria given via parameters.

Parameters:
[out] pos The position that will be overwritten with the random point fulfilling the criteria. pos[0] is within -180, +180. pos[1] within -90, +90.
[in] terrainTypes A linkedList_t containing a list of strings determining the acceptable terrain types (e.g. "grass") May be NULL.
[in] cultureTypes A linkedList_t containing a list of strings determining the acceptable culture types (e.g. "western") May be NULL.
[in] populationTypes A linkedList_t containing a list of strings determining the acceptable population types (e.g. "suburban") May be NULL.
[in] nations A linkedList_t containing a list of strings determining the acceptable nations (e.g. "asia"). May be NULL
Returns:
true if a location was found, otherwise false
Note:
There may be no position fitting the parameters. The higher RASTER, the lower the probability to find a position.
See also:
LIST_AddString
LIST_Delete
Note:
When all parameters are NULL, the algorithm assumes that it does not need to include "water" terrains when determining a random position
You should rather use CP_GetRandomPosOnGeoscape if there are no parameters (except water) to choose a random position

Todo:
  • cache the counted hits
Todo:
add EQUAL_EPSILON here?

Definition at line 1716 of file cp_campaign.c.

References Com_DPrintf(), DEBUG_CLIENT, frand(), MAP_PositionFitsTCPNTypes(), qfalse, qtrue, RASTER, todeg, and Vector2Set.

Referenced by CP_HarvestMissionGo(), and CP_ReconMissionGroundGo().

int CP_GetSalaryAdminEmployee ( employeeType_t  type  ) 
int CP_GetSalaryAdministrative ( void   ) 
int CP_GetSalaryBaseEmployee ( employeeType_t  type  ) 
int CP_GetSalaryRankBonusEmployee ( employeeType_t  type  ) 
int CP_GetSalaryUpKeepBase ( const base_t base  ) 
static float CP_GetWinProbabilty ( const mission_t mis,
const base_t base,
const aircraft_t aircraft 
) [static]

Calculates the win probability for an auto mission.

Todo:
This needs work - also take mis->initialIndividualInterest into account?
Returns:
a float value that is between 0 and 1
Parameters:
[in] mis The mission we are calculating the probability for
[in] base The base we are trying to defend in case of a base attack mission
[in] aircraft Your aircraft that has reached the mission location in case this is no base attack mission

Todo:
change the formular here to reflect the above comment
Todo:
change the formular here to reflect the above comment
Todo:
change the formular here to reflect the above comments
See also:
G_CharacterGetMaxExperiencePerMission
Todo:
fix this value
See also:
G_CharacterGetMaxExperiencePerMission
Todo:
fix this value

Definition at line 976 of file cp_campaign.c.

References AIR_GetTeamSize(), battleParam_s::aliens, chrScoreGlobal_s::assignedMissions, ccs_s::battleParameters, mission_s::category, employee_s::chr, CL_GetRankByIdx(), Com_DPrintf(), ccs_s::curCampaign, linkedList_s::data, DEBUG_CLIENT, campaign_s::difficulty, E_GetHiredEmployees(), E_IsAwayFromBase(), EMPL_ROBOT, EMPL_SOLDIER, chrScoreGlobal_s::experience, rank_s::factor, INTERESTCATEGORY_TERROR_ATTACK, INTERESTCATEGORY_XVI, LIST_Delete(), linkedList_s::next, chrScoreGlobal_s::rank, character_s::score, SKILL_CLOSE, mission_s::stage, and STAGE_BASE_ATTACK.

Referenced by CL_GameAutoGo().

void CP_InitMissionResults ( qboolean  won  ) 
void CP_InitStartup ( void   ) 
qboolean CP_IsRunning ( void   ) 

Checks whether a campaign mode game is running.

Definition at line 146 of file cp_campaign.c.

References ccs_s::curCampaign.

Referenced by CL_CampaignRun(), CP_CampaignExit(), SAV_GameContinue_f(), SAV_GameQuickSave_f(), SAV_GameReadGameComments_f(), SAV_GameSave(), SAV_GameSave_f(), and UI_MapNodeDraw().

static qboolean CP_LoadMapDefStatXML ( mxml_node_t parent  )  [static]

Load mapDef statistics.

Parameters:
[in] parent XML Node structure, where we get the information from

Definition at line 755 of file cp_campaign.c.

References Com_GetMapDefinitionByID(), Com_Printf(), map, mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetString(), qtrue, SAVE_CAMPAIGN_MAPDEF, SAVE_CAMPAIGN_MAPDEF_COUNT, SAVE_CAMPAIGN_MAPDEF_ID, and mapDef_s::timesAlreadyUsed.

Referenced by CP_LoadXML().

qboolean CP_LoadXML ( mxml_node_t parent  ) 
static qboolean CP_MapIsSelectable ( mission_t mission,
int  mapIdx,
const vec2_t  pos 
) [static]

Check if a map may be selected for mission.

Parameters:
[in] mission Pointer to the mission where mapDef should be added
[in] pos position of the mission (NULL if the position will be chosen afterwards)
[in] mapIdx idx of the map in the mapdef array
[in] ufoCrashed Search the mission definition for crash ufo id if true
Returns:
qfalse if map is not selectable

Definition at line 159 of file cp_campaign.c.

References Com_GetMapDefByIDX(), Com_UFOCrashedTypeToShortName(), Com_UFOTypeToShortName(), mission_s::crashed, mapDef_s::cultures, LIST_ContainsString(), MAP_PositionFitsTCPNTypes(), mapDef_s::populations, qfalse, qtrue, mapDef_s::storyRelated, mapDef_s::terrains, type, mission_s::ufo, mapDef_s::ufos, and aircraft_s::ufotype.

Referenced by CP_ChooseMap().

qboolean CP_OnGeoscape ( void   ) 

Definition at line 604 of file cp_campaign.c.

References UI_GetActiveWindowName().

Referenced by CL_AllowTimeScale(), CL_CampaignRun(), and CL_GameTimeStop().

void CP_ParseCharacterData ( struct dbuffer msg  ) 

Parses the character data which was send by G_MatchSendResults using G_SendCharacterData.

Parameters:
[in] msg The network buffer message. If this is NULL the character is updated, if this is not NULL the data is stored in a temp buffer because the player can choose to retry the mission and we have to catch this situation to not update the character data in this case.
See also:
G_SendCharacterData
GAME_SendCurrentTeamSpawningInfo
E_Save

Scores

See also:
inv_shared.h:chrScoreGlobal_t

Definition at line 82 of file cp_campaign.c.

References chrScoreGlobal_s::assignedMissions, byte, updateCharacter_t::chrscore, Com_Error(), Com_Printf(), linkedList_s::data, E_GetEmployeeFromChrUCN(), ERR_DROP, chrScoreGlobal_s::experience, updateCharacter_t::HP, character_s::HP, i, KILLED_NUM_TYPES, chrScoreGlobal_s::kills, LIST_Add(), LIST_Delete(), character_s::maxHP, updateCharacter_t::morale, character_s::morale, NET_ReadByte(), NET_ReadLong(), NET_ReadShort(), linkedList_s::next, character_s::score, SKILL_NUM_TYPES, chrScoreGlobal_s::skills, updateCharacter_t::STUN, character_s::STUN, chrScoreGlobal_s::stuns, and updateCharacter_t::ucn.

Referenced by CP_MissionEnd(), and GAME_CP_Results().

static void CP_RemoveCampaignCallbackCommands ( void   )  [static]
static void CP_RemoveCampaignCommands ( void   )  [static]
static qboolean CP_SaveMapDefStatXML ( mxml_node_t parent  )  [static]

Save mapDef statistics.

Parameters:
[out] parent XML Node structure, where we write the information to

Definition at line 852 of file cp_campaign.c.

References cls, Com_GetMapDefByIDX(), i, mapDef_s::id, map, mxml_AddInt(), mxml_AddNode(), mxml_AddString(), client_static_s::numMDs, qtrue, SAVE_CAMPAIGN_MAPDEF, SAVE_CAMPAIGN_MAPDEF_COUNT, SAVE_CAMPAIGN_MAPDEF_ID, and mapDef_s::timesAlreadyUsed.

Referenced by CP_SaveXML().

qboolean CP_SaveXML ( mxml_node_t parent  ) 
void CP_StartSelectedMission ( void   ) 

Variable Documentation

Definition at line 59 of file cp_campaign.c.

Referenced by AB_BaseSearchedByNations(), AB_BuildBase(), AB_DestroyBase(), AB_GetAlienBaseNumber(), AB_GetNext(), AB_LoadXML(), AC_AlienClick(), AC_InitCallbacks(), AC_KillAll(), AC_KillOne_f(), AC_LoadXML(), AC_SaveXML(), AC_UpdateMenu(), AII_CarriedItems(), AII_CollectingItems(), AIM_AircraftEquipMenuClick_f(), AIR_Add(), AIR_AircraftGetFromIDX(), AIR_AircraftsNotifyMissionRemoved(), AIR_Delete(), AIR_GetAircraftSilent(), AIR_IsEmployeeInAircraft(), AIR_LoadAircraftXML(), AIR_LoadXML(), AIR_Move(), AIR_NewAircraft(), AIR_ParseAircraft(), AIR_PostLoadInitMissions(), AIR_RemoveEmployee(), AIR_SaveAircraftXML(), AIR_ScriptSanityCheck(), AIR_SendAircraftPursuingUFO(), AIR_SendAircraftToMission(), AIRFIGHT_AddProjectile(), AIRFIGHT_BaseShoot(), AIRFIGHT_CampaignRunProjectiles(), AIRFIGHT_ExecuteActions(), AIRFIGHT_InstallationShoot(), AIRFIGHT_LoadXML(), AIRFIGHT_RemoveProjectile(), AIRFIGHT_RemoveProjectileAimingAircraft(), AIRFIGHT_SaveXML(), AIRFIGHT_UpdateProjectileForDestroyedAircraft(), AL_AddAliens(), AL_CountAll(), AL_CountInBase(), AL_FillInContainment(), AL_RemoveAliens(), B_BaseInit_f(), B_BaseResetStatus(), B_BuildBase_f(), B_BuildFromTemplate(), B_BuildingClick_f(), B_BuildingDestroy(), B_BuildingInit(), B_BuildingOpenAfterClick(), B_CheckBuildingConstruction(), B_CheckBuildingStatusForMenu_f(), B_CheckCredits(), B_ConstructBuilding(), B_Destroy(), B_GetBaseByIDX(), B_GetBaseTemplate(), B_GetBuildingTemplate(), B_GetFoundedBaseCount(), B_GetInstallationLimit(), B_GetNextBuilding(), B_InitCallbacks(), B_InitialEquipment(), B_LoadXML(), B_MarkBuildingDestroy(), B_MoveAircraftOnGeoscapeToOtherBases(), B_NextBase_f(), B_ParseBaseTemplate(), B_ParseBuildings(), B_PrevBase_f(), B_ResetBuildingCurrent(), B_SaveXML(), B_ScriptSanityCheck(), B_SelectBase(), B_SellOrAddItems(), B_SetBaseTitle_f(), B_SetBuildingByClick(), B_SetUpBase(), B_SetUpFirstBase(), B_UpdateBaseCapacities(), B_UpdateBaseCount(), B_UpdateBaseData(), BaseSummary_Init(), BaseSummary_SelectBase_f(), BDEF_AddBattery_f(), BDEF_AutoSelectTarget(), BDEF_AutoTarget(), BDEF_RemoveBattery_f(), BS_AddAircraftToMarket(), BS_AddItemToMarket(), BS_Autosell_f(), BS_BuyAircraft_f(), BS_BuyItem_f(), BS_BuyType(), BS_CheckAndDoBuyItem(), BS_GetAircraftBuyingPrice(), BS_GetAircraftOnMarket(), BS_GetAircraftSellingPrice(), BS_GetItemBuyingPrice(), BS_GetItemSellingPrice(), BS_GetMinMaxValueByItemID(), BS_InitMarket(), BS_LoadXML(), BS_MarketScroll_f(), BS_ProcessCraftItemSale(), BS_RemoveAircraftFromMarket(), BS_RemoveItemFromMarket(), BS_SaveXML(), BS_SellAircraft_f(), BS_SellItem_f(), CL_AllowTimeScale(), CL_CampaignRunMarket(), CL_ChangeIndividualInterest(), CL_CleanTempInventory(), CL_DisplayPopupAircraft(), CL_DisplayPopupInterceptMission(), CL_DisplayPopupInterceptUFO(), CL_EventAddMail_f(), CL_GameTimeFast(), CL_GameTimeSlow(), CL_GameTimeStop(), CL_GetComponentsByID(), CL_GetComponentsByItem(), CL_GetEventMail(), CL_GetRankByIdx(), CL_GetRankIdx(), CL_IsTimeStopped(), CL_NationDrawStats(), CL_NationSelect_f(), CL_NationsMaxFunding(), CL_NationStatsUpdate_f(), CL_ParseAlienTeam(), CL_ParseCampaign(), CL_ParseCampaignEvents(), CL_ParseCities(), CL_ParseComponents(), CL_ParseEventMails(), CL_ParseNations(), CL_ParseRanks(), CL_ParseResearchableCampaignStates(), CL_ParseResearchedCampaignItems(), CL_ParseSalary(), CL_PopupChangeHomebase_f(), CL_PopupInterceptBaseClick_f(), CL_ReadSinglePlayerData(), CL_ResetAlienInterest(), CL_SetGameTime(), CL_StatsUpdate_f(), CL_UpdateTime(), CP_BaseAttackChooseBase(), CP_BaseAttackGoToBase(), CP_BaseAttackMissionDestroyBase(), CP_BaseAttackMissionIsFailure(), CP_BaseAttackMissionLeave(), CP_BaseAttackStartMission(), CP_BuildBaseSetUpBase(), CP_BuildBaseSubvertGovernment(), CP_ChangeNationHappiness_f(), CP_CheckBaseAttacks_f(), CP_CheckCampaignEvents(), CP_CheckNewMissionDetectedOnGeoscape(), CP_ChooseCity(), CP_ChooseNation(), CP_CountMission(), CP_CountMissionActive(), CP_CountMissionOnGeoscape(), CP_CreateAlienTeam(), CP_CreateBattleParameters(), CP_CreateCivilianTeam(), CP_CreateNewMission(), CP_GetAverageXVIRate(), CP_GetEventsByID(), CP_GetMissionByIDSilent(), CP_HarvestMissionGo(), CP_HarvestMissionStart(), CP_IncreaseAlienInterest(), CP_InitializeSpawningDelay(), CP_InterceptAircraftMissionSet(), CP_InterceptAttackInstallation(), CP_InterceptMissionSet(), CP_InterceptNextStage(), CP_IsAlienEquipmentSelectable(), CP_LoadInterestsXML(), CP_LoadMissionsXML(), CP_MissionBegin(), CP_MissionEnd(), CP_MissionNotifyBaseDestroyed(), CP_MissionNotifyInstallationDestroyed(), CP_MissionRemove(), CP_MissionStageEnd(), CP_NationBackupMonthlyData(), CP_NationHandleBudget(), CP_NationStatsClick_f(), CP_ReconMissionAerial(), CP_ReconMissionGround(), CP_ReconMissionGroundGo(), CP_ReconMissionLeave(), CP_ReduceXVIEverywhere(), CP_SaveInterestsXML(), CP_SaveMissionsXML(), CP_SelectNewMissionType(), CP_SetAlienEquipmentByInterest(), CP_SetAlienTeamByInterest(), CP_SetMissionName(), CP_SetMissionVars(), CP_SpawnCrashSiteMission(), CP_SpawnNewMissions(), CP_SpawnRescueMission(), CP_SpreadXVI(), CP_StartMissionMap(), CP_StartXVISpreading_f(), CP_SupplySetStayAtBase(), CP_TerrorInCity(), CP_TerrorMissionGo(), CP_TerrorMissionStart(), CP_UFORemoveFromGeoscape(), CP_UpdateMissionVisibleOnGeoscape(), CP_UpdateNationXVIInfection(), CP_UpdateXVIMapButton(), CP_XVIMissionStart(), E_CreateEmployeeAtIndex(), E_DeleteAllEmployees(), E_DeleteEmployee(), E_DeleteEmployeesExceedingCapacity(), E_GetNext(), E_GetUnhiredEmployee(), E_HireForBuilding(), E_InitialEmployees(), E_LoadXML(), E_RandomNation(), E_RefreshUnhiredEmployeeGlobalList(), E_ResetEmployees(), GAME_CP_CampaignListClick_f(), GAME_CP_GetCampaigns_f(), GAME_CP_GetEquipmentDefinition(), GAME_CP_GetTeam(), GAME_CP_MissionAutoCheck_f(), GAME_CP_MissionAutoGo_f(), GAME_CP_Results(), GAME_CP_Results_f(), GAME_CP_Spawn(), GAME_CP_TeamIsKnown(), INS_BuildInstallation_f(), INS_DestroyInstallation(), INS_GetFirstUFOYard(), INS_GetFirstUnfoundedInstallation(), INS_GetInstallationByIDX(), INS_GetInstallationTemplateFromInstallationID(), INS_InitCallbacks(), INS_InitStartup(), INS_LoadXML(), INS_ParseInstallations(), INS_SaveXML(), INS_SelectInstallation(), INS_SelectInstallation_f(), INS_SetInstallationTitle(), INS_SetUpInstallation(), INS_UpdateInstallationData(), MAP3D_ScreenToMap(), MAP3D_SmoothRotate(), MAP_3DMapToScreen(), MAP_Draw3DMarkerIfVisible(), MAP_DrawAircraftHealthBar(), MAP_DrawMap(), MAP_DrawMapMarkers(), MAP_DrawMapOneMission(), MAP_DrawMapOnePhalanxAircraft(), MAP_GetGeoscapeAngle(), MAP_GetMissionByIDX(), MAP_GetNation(), MAP_GetUFOAngle(), MAP_Init(), MAP_IsNight(), MAP_MapClick(), MAP_MapDrawLine(), MAP_MapToScreen(), MAP_MultiSelectExecuteAction_f(), MAP_NotifyAircraftRemoved(), MAP_NotifyMissionRemoved(), MAP_NotifyUFODisappear(), MAP_NotifyUFORemoved(), MAP_ResetAction(), MAP_ScreenToMap(), MAP_Scroll_f(), MAP_SelectAircraft(), MAP_SelectMission(), MAP_SelectUFO(), MAP_SetOverlay(), MAP_SmoothTranslate(), MAP_StartCenter(), MAP_UpdateGeoscapeDock(), MAP_Zoom_f(), MS_AddNewMessageSound(), MSO_InitList(), MSO_ParseCategories(), MSO_Toggle_f(), MSO_UpdateVisibleButtons(), NAT_GetNationByID(), NAT_GetNationByIDX(), NAT_SaveXML(), NAT_ScriptSanityCheck(), NAT_SetHappiness(), NAT_UpdateHappinessForAllNations(), PR_DecreaseProduction(), PR_EmptyQueue(), PR_LoadXML(), PR_ProductionBase(), PR_ProductionDown_f(), PR_ProductionFrame(), PR_ProductionIncrease_f(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionQueueBase(), PR_ProductionRollBottom_f(), PR_ProductionRun(), PR_ProductionStop_f(), PR_ProductionType_f(), PR_ProductionUp_f(), PR_QueueNext(), PR_SaveXML(), PR_UpdateProductionList(), RADAR_SetRadarAfterLoading(), RS_CountScientistsInBase(), RS_GetTechByIDX(), RS_GetTechForItem(), RS_GetTechWithMostScientists(), RS_InitGUIData(), RS_InitTree(), RS_IsResearched_idx(), RS_IsValidTechIndex(), RS_MarkCollected(), RS_MarkOneResearchable(), RS_MarkResearchable(), RS_MarkStoryLineEventResearched(), RS_ParseTechnologies(), RS_RequiredLinksAssign(), RS_ResearchFinish(), RS_ResearchRun(), RS_SaveXML(), RS_ScriptSanityCheck(), SAV_GameSave(), STATS_LoadXML(), STATS_SaveXML(), TR_CargoList(), TR_CargoListSelect_f(), TR_CheckAircraft(), TR_CheckAlien(), TR_CheckEmployee(), TR_EmptyTransferCargo(), TR_GetNext(), TR_Init_f(), TR_InitBaseList(), TR_LoadXML(), TR_NotifyAircraftRemoved(), TR_SaveXML(), TR_TransferAlienAfterMissionStart(), TR_TransferAliensFromMission_f(), TR_TransferCheck(), TR_TransferListClear_f(), TR_TransferListSelect_f(), TR_TransferSelect(), TR_TransferStart(), UFO_AddToGeoscape(), UFO_CampaignCheckEvents(), UFO_CampaignRunUFOs(), UFO_DetectNewUFO(), UFO_GetByIDX(), UFO_GetByType(), UFO_MissionResultToString(), UFO_NotifyPhalanxAircraftRemoved(), UFO_RemoveFromGeoscape(), UFO_ShouldAppearOnGeoscape(), UFO_UpdateAlienInterestForAllBasesAndInstallations(), UI_BaseMapNodeClick(), UI_BaseMapNodeDraw(), UI_MapNodeCapturedMouseMove(), UI_MapNodeZoom(), UP_Click_f(), UP_GenerateSummary(), UP_GetUnreadMails(), UP_ParseChapters(), UP_SetAllMailsRead_f(), UP_SetMailHeader(), UR_DialogFillNations(), UR_DialogGetCurrentNationIndex(), UR_DialogInit_f(), UR_DialogInitSell_f(), UR_DialogInitStore_f(), UR_DialogSelectSellNation_f(), UR_DialogStartSell_f(), UR_DialogStartStore_f(), UR_ProcessActive(), UR_SortNations(), US_GetNext(), US_LoadXML(), US_RemoveStoredUFO(), US_StoredUFOCount(), and US_StoreUFO().

Definition at line 62 of file cp_campaign.c.

Referenced by CL_GameTimeStop().

Definition at line 61 of file cp_campaign.c.

Referenced by GAME_CP_InitStartup().

const int DETECTION_INTERVAL = (SECONDS_PER_HOUR / 2)
const cmdList_t game_commands[] [static]
Initial value:
 {
    {"update_base_radar_coverage", RADAR_UpdateBaseRadarCoverage_f, "Update base radar coverage"},
    {"addeventmail", CL_EventAddMail_f, "Add a new mail (event trigger) - e.g. after a mission"},
    {"stats_update", CL_StatsUpdate_f, NULL},
    {"game_go", CP_StartSelectedMission, NULL},
    {"game_timestop", CL_GameTimeStop, NULL},
    {"game_timeslow", CL_GameTimeSlow, NULL},
    {"game_timefast", CL_GameTimeFast, NULL},
    {"game_settimeid", CL_SetGameTime_f, NULL},
    {"map_center", MAP_CenterOnPoint_f, "Centers the geoscape view on items on the geoscape - and cycle through them"},
    {"map_zoom", MAP_Zoom_f, NULL},
    {"map_scroll", MAP_Scroll_f, NULL},
    {"cp_start_xvi_spreading", CP_StartXVISpreading_f, "Start XVI spreading"},









    {NULL, NULL, NULL}
}

Definition at line 1392 of file cp_campaign.c.

const int monthLength[MONTHS_PER_YEAR] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } [static]

Definition at line 483 of file cp_campaign.c.

Referenced by CL_DateConvert(), and CL_DateCreateDay().


Generated by  doxygen 1.6.2