67#define NATIONBELOWLIMITPERCENTAGE 0.5f
82 return ccs.curCampaign !=
nullptr;
91 cgi->Cmd_ExecuteString(
"game_save slotend \"End of game\"");
92 cgi->Cbuf_AddText(
"ui_set_endgame %s;", won ?
"won" :
"lose");
93 cgi->Cbuf_AddText(
"ui_initstack endgame;");
103 bool endCampaign =
false;
117 cgi->UI_RegisterText(
TEXT_STANDARD,
_(
"You've lost your bases and don't have enough money to build new ones."));
123 cgi->UI_RegisterText(
TEXT_STANDARD,
_(
"You have failed in your charter to protect Earth."
124 " Our home and our people have fallen to the alien infection. Only a handful"
125 " of people on Earth remain human, and the remaining few no longer have a"
126 " chance to stem the tide. Your command is no more; PHALANX is no longer"
127 " able to operate as a functioning unit. Nothing stands between the aliens"
128 " and total victory."));
132 int nationBelowLimit = 0;
141 cgi->UI_RegisterText(
TEXT_STANDARD,
_(
"Under your command, PHALANX operations have"
142 " consistently failed to protect nations."
143 " The UN, highly unsatisfied with your performance, has decided to remove"
144 " you from command and subsequently disbands the PHALANX project as an"
145 " effective task force. No further attempts at global cooperation are made."
146 " Earth's nations each try to stand alone against the aliens, and eventually"
147 " fall one by one."));
201 return Q_streq(
"geoscape",
cgi->UI_GetActiveWindowName());
234 ccs.frametime = secondsSinceLastFrame;
235 ccs.timer += secondsSinceLastFrame *
ccs.gameTimeScale;
243 int currentsecond =
ccs.date.getTimeAsSeconds();
244 int currentday =
ccs.date.getDateAsDays();
260 for (
int i = 0;
i < checks;
i++) {
283 while (currentmin < newmin) {
292 while (currenthour < newhour) {
303 for (
int i = currentday;
i <
ccs.date.getDateAsDays();
i++) {
307 ccs.missionSpawnCallback();
341 }
else if (date.
day > 1)
355 if (costs >
ccs.credits)
370 ccs.credits = credits;
371 cgi->Cvar_Set(
"mn_credits",
_(
"%i c"),
ccs.credits);
387 cgi->Com_Printf(
"Warning: MapDef with no id in xml!\n");
390 map =
cgi->Com_GetMapDefinitionByID(s);
392 cgi->Com_Printf(
"Warning: No MapDef with id '%s'!\n", s);
415 cgi->Com_Printf(
"Did not find campaign entry in xml!\n");
419 cgi->Com_Printf(
"couldn't locate campaign name in savegame\n");
425 cgi->Com_Printf(
"......campaign \"%s\" doesn't exist.\n",
name);
455 if (oldOverlayStatus >= 0) {
456 const int overlayNation = 1 << 0;
457 const int overlayXvi = 1 << 1;
458 const int overlayRadar = 1 << 2;
460 cgi->Cvar_SetValue(
"geo_overlay_radar", oldOverlayStatus & overlayRadar);
461 cgi->Cvar_SetValue(
"geo_overlay_nation", oldOverlayStatus & overlayNation);
462 cgi->Cvar_SetValue(
"geo_overlay_xvi", oldOverlayStatus & overlayXvi);
475 mxmlDelete(campaignNode);
548 cgi->Com_Printf(
"CP_StartSelectedMission: No mission aircraft\n");
559 cgi->Com_Printf(
"CP_StartSelectedMission: No mission selected\n");
568 cgi->Com_Printf(
"CP_StartSelectedMission: Dropship not near landing zone: mis->active: %i\n", mis->
active);
572 cgi->Com_Printf(
"CP_StartSelectedMission: No team in dropship.\n");
577 cgi->SV_Shutdown(
"Server quit.",
false);
578 cgi->CL_Disconnect();
594static void CP_DebugShowItems_f (
void)
596 if (
cgi->Cmd_Argc() < 2) {
597 cgi->Com_Printf(
"Usage: %s <baseID>\n",
cgi->Cmd_Argv(0));
601 int i = atoi(
cgi->Cmd_Argv(1));
603 cgi->Com_Printf(
"invalid baseID (%s)\n",
cgi->Cmd_Argv(1));
608 for (
i = 0;
i <
cgi->csi->numODs;
i++) {
620static void CP_DebugAddItem_f (
void)
622 if (
cgi->Cmd_Argc() < 4) {
623 cgi->Com_Printf(
"Usage: %s <baseID> <itemid> <count>\n",
cgi->Cmd_Argv(0));
629 const int count = atoi(
cgi->Cmd_Argv(3));
632 cgi->Com_Printf(
"Invalid base index given\n");
641 cgi->Com_Printf(
"%s %s %d\n", base->
name, obj->
id, amount);
654static void CP_DebugAddAntimatter_f (
void)
656 if (
cgi->Cmd_Argc() < 3) {
657 cgi->Com_Printf(
"Usage: %s <baseID> <amount>\n",
cgi->Cmd_Argv(0));
662 const int amount = atoi(
cgi->Cmd_Argv(2));
665 cgi->Com_Printf(
"Invalid base index given\n");
675static void CP_DebugFullCredits_f (
void)
686 {
"addeventmail",
CL_EventAddMail_f,
"Add a new mail (event trigger) - e.g. after a mission"},
692 {
"map_center",
GEO_CenterOnPoint_f,
"Centers the geoscape view on items on the geoscape - and cycle through them"},
697 {
"debug_fullcredits", CP_DebugFullCredits_f,
"Debug function to give the player full credits"},
698 {
"debug_itemadd", CP_DebugAddItem_f,
"Debug function to add certain items to base storage"},
699 {
"debug_antimatteradd", CP_DebugAddAntimatter_f,
"Debug function to add some antimatter to base container"},
700 {
"debug_listitem", CP_DebugShowItems_f,
"Debug function to show all items in base storage"},
702 {
nullptr,
nullptr,
nullptr}
767 ccs.curCampaign = campaign;
788 cgi->UI_InitStack(
"geoscape",
"campaign_main");
840 for (
int i = 0;
i <
ccs.numAlienCategories;
i++) {
845 cgi->Cvar_SetValue(
"geo_overlay_radar", 0);
846 cgi->Cvar_SetValue(
"geo_overlay_nations", 0);
847 cgi->Cvar_SetValue(
"geo_overlay_xvi", 0);
865 for (
i = 0, campaign =
ccs.campaigns;
i <
ccs.numCampaigns;
i++, campaign++)
869 if (
i ==
ccs.numCampaigns) {
870 cgi->Com_Printf(
"CL_GetCampaign: Campaign \"%s\" doesn't exist.\n",
name);
885 cgi->UI_MessageResetStack();
895 while((base =
B_GetNext(base)) !=
nullptr) {
935 cp_missiontest =
cgi->Cvar_Get(
"cp_missiontest",
"0",
CVAR_DEVELOPER,
"This will never stop the time on geoscape and print information about spawned missions");
DateTime class definition.
Client game mode interface.
Share stuff between the different cgame implementations.
#define MapDef_ForeachSingleplayerCampaign(var)
Class describing a point of time.
static const short SECONDS_PER_MINUTE
static const short SECONDS_PER_HOUR
void AIR_CampaignRun(const campaign_t *campaign, int dt, bool updateRadarOverlay)
Handles aircraft movement and actions in geoscape mode.
int AIR_GetTeamSize(const aircraft_t *aircraft)
Counts the number of soldiers in given aircraft.
void AIR_InitStartup(void)
Init actions for aircraft-subsystem.
bool AIR_Delete(base_t *base, aircraft_t *aircraft)
Will remove the given aircraft from the base.
void AIR_Shutdown(void)
Closing actions for aircraft-subsystem.
#define AIR_Foreach(var)
iterates trough all aircraft
void AIRFIGHT_CampaignRunBaseDefence(int dt)
Run base defences.
void AIRFIGHT_CampaignRunProjectiles(const campaign_t *campaign, int dt)
Update values of projectiles.
void AIRFIGHT_InitStartup(void)
void INT_InitStartup(void)
Init actions for alien interests-subsystem.
void INT_Shutdown(void)
Closing actions for alien interests-subsystem.
void INT_IncreaseAlienInterest(const campaign_t *campaign)
Increase alien overall interest.
void INT_ResetAlienInterest(void)
Initialize alien interest values and mission cycle.
void AB_InitStartup(void)
Init actions for alienbase-subsystem.
void AB_Shutdown(void)
Closing actions for alienbase-subsystem.
void AB_UpdateStealthForAllBase(void)
Update stealth value of every base for every aircraft.
void AB_BaseSearchedByNations(void)
Nations help in searching alien base.
void AC_InitStartup(void)
Defines commands and cvars for the alien containment menu(s).
void AM_InitStartup(void)
Init actions for automission-subsystem.
void AM_Shutdown(void)
Closing actions for automission-subsystem.
Header file for single player automatic (quick, simulated) missions, without going to the battlescape...
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
void B_SelectBase(const base_t *base)
Select and opens a base.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
int B_GetCount(void)
Returns the count of founded bases.
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
base_t * B_GetBaseByIDX(int baseIdx)
Array bound check for the base index. Will also return unfounded bases as long as the index is in the...
void B_Delete(base_t *base)
Resets a base structure.
int B_ItemInBase(const objDef_t *item, const base_t *base)
Check if the item has been collected (i.e it is in the storage) in the given base.
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
void B_UpdateBuildingConstructions(void)
Updates base data.
void B_InitStartup(void)
Resets console commands.
building_t * B_GetNextBuilding(const base_t *base, building_t *lastBuilding)
Iterates through buildings in a base.
#define B_AtLeastOneExists()
void B_InitCallbacks(void)
void B_ShutdownCallbacks(void)
Header file for menu related console command callbacks.
void BDEF_ShutdownCallbacks(void)
void BDEF_InitCallbacks(void)
Header file for menu callback functions used for basedefence menu.
@ B_STATUS_CONSTRUCTION_FINISHED
static void CP_CampaignFunctionPeriodicCall(campaign_t *campaign, int dt, bool updateRadarOverlay)
Functions that should be called with a minimum time lapse (will be called at least every DETECTION_IN...
memPool_t * cp_campaignPool
void CP_ResetCampaignData(void)
Will clear most of the parsed singleplayer data.
void CP_Shutdown(void)
Campaign closing actions.
bool CP_OnGeoscape(void)
Returns if we are currently on the Geoscape.
bool CP_IsRunning(void)
Checks whether a campaign mode game is running.
void CP_CampaignRun(campaign_t *campaign, float secondsSinceLastFrame)
Called every frame when we are in geoscape view.
int CP_GetSalaryUpKeepBase(const salary_t *salary, const base_t *base)
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
void CP_InitStartup(void)
static bool CP_SaveMapDefStatXML(xmlNode_t *parent)
Save mapDef statistics.
void CP_CheckLostCondition(const campaign_t *campaign)
Checks whether the player has lost the campaign.
void CP_StartSelectedMission(void)
Starts a selected mission.
static void CP_RemoveCampaignCallbackCommands(void)
registers callback commands that are used by campaign
bool CP_SaveXML(xmlNode_t *parent)
Save callback for savegames in XML Format.
static void CP_AdvanceTimeBySeconds(int seconds)
Ensure that the day always matches the seconds. If the seconds per day limit is reached,...
void CP_CampaignInit(campaign_t *campaign, bool load)
Called at new game and load game.
static void CP_CheckMissionEnd(const campaign_t *campaign)
Check for missions that have a timeout defined.
static void CP_AddCampaignCommands(void)
void CP_EndCampaign(bool won)
Function to handle the campaign end.
bool CP_LoadXML(xmlNode_t *parent)
Load callback for savegames in XML Format.
campaign_t * CP_GetCampaign(const char *name)
Returns the campaign pointer from global campaign array.
static const cmdList_t game_commands[]
bool CP_CheckCredits(int costs)
Checks whether you have enough credits for something.
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
static void CP_RemoveCampaignCommands(void)
static bool CP_LoadMapDefStatXML(xmlNode_t *parent)
Load mapDef statistics.
#define NATIONBELOWLIMITPERCENTAGE
static bool CP_IsBudgetDue(const dateLong_t *oldDate, const dateLong_t *date)
static void CP_AddCampaignCallbackCommands(void)
registers callback commands that are used by campaign
Header file for single player campaign control.
const cgame_import_t * cgi
void CP_ReadCampaignData(const campaign_t *campaign)
void CAP_CheckOverflow(void)
Checks capacity overflows on bases.
void CHAR_InitStartup(void)
Campaign initialization actions for the character module.
void CHAR_Shutdown(void)
Campaign closing actions for the character module.
Header file for character (soldier, alien) related campaign functions.
void E_InitialEmployees(const campaign_t *campaign)
Create initial hireable employees.
void E_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
void E_Shutdown(void)
Closing actions for employee-subsystem.
void CL_EventAddMail(const char *eventMailId)
Adds the event mail to the message stack. This message is going to be added to the savegame.
void CP_CheckCampaignEvents(campaign_t *campaign)
void CL_EventAddMail_f(void)
void CP_FreeDynamicEventMail(void)
Make sure, that the linked list is freed with every new game.
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
void AIM_ShutdownCallbacks(void)
void AIM_InitCallbacks(void)
Header file for menu callback functions used for base and aircraft equip menu.
void GEO_Reset(const char *map)
void GEO_InitStartup(void)
Initialise MAP/Geoscape.
void GEO_CenterOnPoint_f(void)
Switch to next model on 2D and 3D geoscape.
Header for Geoscape management.
#define GEO_GetMissionAircraft()
#define GEO_GetSelectedMission()
#define GEO_SetSelectedMission(mission)
void HOS_HospitalRun(void)
Checks health status of all employees in all bases.
void HOS_InitStartup(void)
Initial stuff for hospitals Bind some of the functions in this file to console-commands that you can ...
Header file for hospital related stuff.
void HOS_InitCallbacks(void)
void HOS_ShutdownCallbacks(void)
Header file for menu related console command callbacks.
void INS_UpdateInstallationData(void)
Check if some installation are build.
void INS_InitStartup(void)
Resets console commands.
void INS_Shutdown(void)
Closing operations for installations subsystem.
void INS_InitCallbacks(void)
void INS_ShutdownCallbacks(void)
Header file for menu related console command callbacks.
void AII_RepairAircraft(void)
Repair aircraft.
void AII_UpdateInstallationDelay(void)
Update the installation delay of all slots of a given aircraft.
void BDEF_AutoSelectTarget(void)
Chooses target for all base defences and sam sites.
Header for slot management related stuff.
void BS_InitMarket(const campaign_t *campaign)
sets market prices at start of the game
void CP_CampaignRunMarket(campaign_t *campaign)
make number of items change every day.
void BS_ShutdownCallbacks(void)
Function unregisters the callbacks of the maket UI.
void BS_InitCallbacks(void)
Function registers the callbacks of the maket UI and do initializations.
Header file for menu related console command callbacks.
void MS_MessageInit(void)
void CP_CheckBaseAttacks(void)
Check and start baseattack missions.
Campaign mission headers.
Campaign mission triggers.
void CP_SpawnUFOCarrier_f(void)
Spawns a UFO-Carrier mission.
void CP_AttackUFOCarrier_f(void)
Decide whether you hit and destroyed the carrier and spawns a new carrier crash site mission.
Campaign mission headers.
void MIS_InitStartup(void)
Init actions for missions-subsystem.
void CP_InitializeSpawningDelay(void)
Initialize spawning delay.
void BATTLE_Start(mission_t *mission, const battleParam_t *battleParameters)
Select the mission type and start the map from mission definition.
void CP_CreateBattleParameters(mission_t *mission, battleParam_t *param, const aircraft_t *aircraft)
Create parameters needed for battle. This is the data that is used for starting the tactical part of ...
void MIS_Shutdown(void)
Closing actions for missions-subsystem.
bool CP_CheckMissionLimitedInTime(const mission_t *mission)
Check if mission should end because of limited time.
void BATTLE_SetVars(const battleParam_t *battleParameters)
Set some needed cvars from a battle definition.
bool CP_CheckNewMissionDetectedOnGeoscape(void)
Check if mission has been detected by radar.
void CP_MissionStageEnd(const campaign_t *campaign, mission_t *mission)
Determine what action should be performed when a mission stage ends.
void CP_SpawnNewMissions(void)
Spawn new missions.
Campaign missions headers.
#define MIS_Foreach(var)
iterates through missions
void NAT_HandleBudget(const campaign_t *campaign)
Update the nation data from all parsed nation each month.
void NAT_BackupMonthlyData(void)
Backs up each nation's relationship values.
void NAT_UpdateHappinessForAllNations(const float minhappiness)
Lower happiness of nations depending on alien activity.
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
void NAT_InitStartup(void)
Init actions for nation-subsystem.
void NAT_Shutdown(void)
Closing actions for nation-subsystem.
#define NAT_Foreach(var)
iterates trough nations
void CP_InitializeXVIOverlay(void)
Initialize XVI overlay on geoscape.
Functions to generate and render overlay for geoscape.
void CP_ScriptSanityCheck(void)
Check the parsed script values for errors after parsing every script file.
void PR_ProductionRun(void)
Checks whether an item is finished.
void PR_ShutdownCallbacks(void)
void PR_InitCallbacks(void)
Header file for menu related console command callbacks for production menu.
void RADAR_UpdateBaseRadarCoverage_f(void)
Update radar coverage when building/destroying new radar.
void RS_MarkCollected(technology_t *tech)
Marks a give technology as collected.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
void RS_ResetTechs(void)
This is called everytime RS_ParseTechnologies is called - to prevent cyclic hash tables.
void RS_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
int RS_ResearchRun(void)
Checks the research status.
void RS_MarkResearchable(const base_t *base, bool init)
Marks all the techs that can be researched. Automatically researches 'free' techs such as ammo for a ...
void RS_InitTree(const campaign_t *campaign, bool load)
Gets all needed names/file-paths/etc... for each technology entry. Should be executed after the parsi...
void RS_ShutdownCallbacks(void)
void RS_InitCallbacks(void)
Header for menu related research stuff.
void SAV_Init(void)
Register all save-subsystems and init some cvars and commands.
void STATS_ShutDown(void)
void STATS_InitStartup(void)
Campaign statistic headers.
void CP_CleanupAircraftTeam(aircraft_t *aircraft, equipDef_t *ed)
Reloads weapons, removes not assigned and resets defaults.
void CP_CleanTempInventory(base_t *base)
Clears all containers that are temp containers (see script definition).
Team management for the campaign gametype headers.
void CP_TEAM_ShutdownCallbacks(void)
Function that unregisters team (UI) callbacks.
void CP_TEAM_InitCallbacks(void)
Function that registers team (UI) callbacks.
Menu related callback functions for the team menu.
void CP_GameTimeFast(void)
Increase game time speed.
void CP_GameTimeStop(void)
Stop game time speed.
void CP_UpdateTime(void)
Updates date/time and timescale (=timelapse) on the geoscape menu.
void CP_DateConvertLong(const DateTime &date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
bool CP_IsTimeStopped(void)
Check if time is stopped.
void CP_GameTimeSlow(void)
Decrease game time speed.
void CP_SetGameTime_f(void)
Set a new time game from id.
Campaign geoscape time header.
void TR_InitStartup(void)
Defines commands and cvars for the Transfer menu(s).
void TR_TransferRun(void)
Checks whether given transfer should be processed.
void TR_Shutdown(void)
Closing actions for transfer-subsystem.
Header file for Transfer stuff.
void UFO_CampaignRunUFOs(const campaign_t *campaign, int deltaTime)
Make the UFOs run.
bool UFO_CampaignCheckEvents(void)
Check events for UFOs: Appears or disappears on radars.
void UFO_InitStartup(void)
Init actions for ufo-subsystem.
void UFO_UpdateAlienInterestForAllBasesAndInstallations(void)
Update alien interest for all PHALANX bases.
void UFO_Shutdown(void)
Closing actions for ufo-subsystem.
int UP_GetUnreadMails(void)
Sets the amount of unread/new mails.
void UP_InitStartup(void)
void UR_Shutdown(void)
Closing actions for ufostoring-subsystem.
void UR_InitStartup(void)
Init actions for ufostoring-subsystem.
void UR_ProcessActive(void)
Function to process active recoveries.
UFO recovery and storing.
void CP_UpdateXVIMapButton(void)
This will hide or show the geoscape button for handling the xvi overlay map.
void CP_ReduceXVIEverywhere(void)
Reduce XVI everywhere.
int CP_GetAverageXVIRate(void)
Return the average XVI rate.
void CP_SpreadXVI(void)
Spread XVI for each mission that needs to be daily spread.
void CP_StartXVISpreading_f(void)
Start XVI spreading in campaign.
void CP_UpdateNationXVIInfection(void)
Update xviInfection value for each nation, using the XVI overlay.
#define CP_IsXVIStarted()
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
XML tag constants for savegame.
#define SAVE_CAMPAIGN_PAID
#define SAVE_CAMPAIGN_GEO_OVERLAY_XVI
#define SAVE_CAMPAIGN_MAP
#define SAVE_CAMPAIGN_MAPDEF
#define SAVE_CAMPAIGN_GEO_OVERLAY_NATION
#define SAVE_CAMPAIGN_DATE
#define SAVE_CAMPAIGN_MAPDEF_COUNT
#define SAVE_CAMPAIGN_CAMPAIGN
#define SAVE_CAMPAIGN_XVISTARTED
#define SAVE_CAMPAIGN_RADAROVERLAYWASSET
#define SAVE_CAMPAIGN_CIVILIANSKILLED
#define SAVE_CAMPAIGN_MAPDEFSTAT
#define SAVE_CAMPAIGN_GEO_OVERLAY_RADAR
#define SAVE_CAMPAIGN_ALIENSKILLED
#define SAVE_CAMPAIGN_NEXTUNIQUECHARACTERNUMBER
#define SAVE_CAMPAIGN_CREDITS
#define SAVE_CAMPAIGN_MAPDEF_ID
#define SAVE_CAMPAIGN_CL_GEOSCAPE_OVERLAY
An aircraft with all it's data.
struct mission_s * mission
alien team category definition
A base with all it's data.
A building with all it's data.
buildingStatus_t buildingStatus
int maxAllowedXVIRateUntilLost
int negativeCreditsUntilLost
client campaign structure
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Human readable time information in the game.
missionResults_t missionResults
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...
Defines all attributes of objects used in the inventory.
This is the technology parsed from research.ufo.