25 #include "../../cl_shared.h"
26 #include "../../ui/ui_main.h"
66 #define NATIONBELOWLIMITPERCENTAGE 0.5f
90 cgi->Cmd_ExecuteString(
"game_save slotend \"End of game\"");
91 cgi->Cbuf_AddText(
va(
"ui_set_endgame %s;", won ?
"won" :
"lose"));
92 cgi->Cbuf_AddText(
"ui_initstack endgame;");
102 bool endCampaign =
false;
116 cgi->UI_RegisterText(
TEXT_STANDARD,
_(
"You've lost your bases and don't have enough money to build new ones."));
122 cgi->UI_RegisterText(
TEXT_STANDARD,
_(
"You have failed in your charter to protect Earth."
123 " Our home and our people have fallen to the alien infection. Only a handful"
124 " of people on Earth remain human, and the remaining few no longer have a"
125 " chance to stem the tide. Your command is no more; PHALANX is no longer"
126 " able to operate as a functioning unit. Nothing stands between the aliens"
127 " and total victory."));
131 int nationBelowLimit = 0;
140 cgi->UI_RegisterText(
TEXT_STANDARD,
_(
"Under your command, PHALANX operations have"
141 " consistently failed to protect nations."
142 " The UN, highly unsatisfied with your performance, has decided to remove"
143 " you from command and subsequently disbands the PHALANX project as an"
144 " effective task force. No further attempts at global cooperation are made."
145 " Earth's nations each try to stand alone against the aliens, and eventually"
146 " fall one by one."));
246 int currentsecond = ccs.
date.
sec;
263 for (
int i = 0;
i < checks;
i++) {
286 while (currentmin < newmin) {
295 while (currenthour < newhour) {
306 for (
int i = currentday;
i < ccs.
date.
day;
i++) {
344 }
else if (date.
day > 1)
390 cgi->Com_Printf(
"Warning: MapDef with no id in xml!\n");
395 cgi->Com_Printf(
"Warning: No MapDef with id '%s'!\n", s);
418 cgi->Com_Printf(
"Did not find campaign entry in xml!\n");
422 cgi->Com_Printf(
"couldn't locate campaign name in savegame\n");
428 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();
594 static void CP_DebugShowItems_f (
void)
596 if (
cgi->Cmd_Argc() < 2) {
620 static 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));
632 cgi->Com_Printf(
"Invalid base index given\n");
641 cgi->Com_Printf(
"%s %s %d\n", base->
name, obj->
id, amount);
654 static void CP_DebugAddAntimatter_f (
void)
656 if (
cgi->Cmd_Argc() < 3) {
657 cgi->Com_Printf(
"Usage: %s <baseID> <amount>\n",
cgi->
Cmd_Argv(0));
665 cgi->Com_Printf(
"Invalid base index given\n");
675 static 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}
727 cgi->Cmd_TableAddList(game_commands);
755 cgi->Cmd_TableRemoveList(game_commands);
788 cgi->UI_InitStack(
"geoscape",
"campaign_main");
845 cgi->Cvar_SetValue(
"geo_overlay_radar", 0);
846 cgi->Cvar_SetValue(
"geo_overlay_nations", 0);
847 cgi->Cvar_SetValue(
"geo_overlay_xvi", 0);
870 cgi->Com_Printf(
"CL_GetCampaign: Campaign \"%s\" doesn't exist.\n", name);
885 cgi->UI_MessageResetStack();
895 while((base =
B_GetNext(base)) !=
nullptr) {
899 cgi->FreePool(cp_campaignPool);
930 cp_campaignPool =
cgi->
CreatePool(
"Client: Local (per game)");
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");
Header file for menu related console command callbacks.
bool CP_IsTimeStopped(void)
Check if time is stopped.
void SAV_Init(void)
Register all save-subsystems and init some cvars and commands.
int CP_GetAverageXVIRate(void)
Return the average XVI rate.
bool AIR_Delete(base_t *base, aircraft_t *aircraft)
Will remove the given aircraft from the base.
#define SAVE_CAMPAIGN_CIVILIANSKILLED
alienTeamCategory_t alienCategories[ALIENCATEGORY_MAX]
void CHAR_InitStartup(void)
Campaign initialization actions for the character module.
const nationInfo_t * NAT_GetCurrentMonthInfo(const nation_t *const nation)
Get the current month nation stats.
Header file for single player automatic (quick, simulated) missions, without going to the battlescape...
void CHAR_Shutdown(void)
Campaign closing actions for the character module.
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.
bool CP_CheckNewMissionDetectedOnGeoscape(void)
Check if mission has been detected by radar.
bool CP_IsRunning(void)
Checks whether a campaign mode game is running.
static void CP_AddCampaignCommands(void)
void PR_InitCallbacks(void)
A building with all it's data.
void AIM_ShutdownCallbacks(void)
void INS_InitStartup(void)
Resets console commands.
void B_ShutdownCallbacks(void)
void B_InitCallbacks(void)
void BDEF_AutoSelectTarget(void)
Chooses target for all base defences and sam sites.
bool CP_OnGeoscape(void)
Returns if we are currently on the Geoscape.
alien team category definition
void MIS_Shutdown(void)
Closing actions for missions-subsystem.
void B_UpdateBuildingConstructions(void)
Updates base data.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
Header file for character (soldier, alien) related campaign functions.
bool CP_CheckMissionLimitedInTime(const mission_t *mission)
Check if mission should end because of limited time.
void CP_MissionStageEnd(const campaign_t *campaign, mission_t *mission)
Determine what action should be performed when a mission stage ends.
void CP_UpdateNationXVIInfection(void)
Update xviInfection value for each nation, using the XVI overlay.
Header file for menu related console command callbacks.
missionSpawnFunction_t missionSpawnCallback
void CP_SetGameTime_f(void)
Set a new time game from id.
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
void INT_ResetAlienInterest(void)
Initialize alien interest values and mission cycle.
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
void RS_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
#define MIS_Foreach(var)
iterates through missions
void CL_EventAddMail(const char *eventMailId)
Adds the event mail to the message stack. This message is going to be added to the savegame...
Header for menu related research stuff.
void INS_UpdateInstallationData(void)
Check if some installation are build.
void INT_Shutdown(void)
Closing actions for alien interests-subsystem.
void UFO_CampaignRunUFOs(const campaign_t *campaign, int deltaTime)
Make the UFOs run.
void CP_EndCampaign(bool won)
Function to handle the campaign end.
static bool CP_LoadMapDefStatXML(xmlNode_t *parent)
Load mapDef statistics.
void AB_Shutdown(void)
Closing actions for alienbase-subsystem.
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
struct technology_s * tech
void AB_BaseSearchedByNations(void)
Nations help in searching alien base.
void CP_Shutdown(void)
Campaign closing actions.
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 ...
static void CP_RemoveCampaignCommands(void)
void GEO_InitStartup(void)
Initialise MAP/Geoscape.
#define B_AtLeastOneExists()
void AIRFIGHT_InitStartup(void)
#define SAVE_CAMPAIGN_MAP
#define SAVE_CAMPAIGN_CREDITS
void CP_ResetCampaignData(void)
Will clear most of the parsed singleplayer data.
Header file for Transfer stuff.
void AB_InitStartup(void)
Init actions for alienbase-subsystem.
void CP_SpawnNewMissions(void)
Spawn new missions.
void BS_InitMarket(const campaign_t *campaign)
sets market prices at start of the game
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void AII_RepairAircraft(void)
Repair aircraft.
#define SAVE_CAMPAIGN_ALIENSKILLED
void BDEF_ShutdownCallbacks(void)
void UFO_Shutdown(void)
Closing actions for ufo-subsystem.
void E_Shutdown(void)
Closing actions for employee-subsystem.
void CP_GameTimeSlow(void)
Decrease game time speed.
#define SAVE_CAMPAIGN_MAPDEFSTAT
Defines all attributes of objects used in the inventory.
#define SAVE_CAMPAIGN_MAPDEF
void BS_ShutdownCallbacks(void)
Function unregisters the callbacks of the maket UI.
bool Date_LaterThan(const date_t *now, const date_t *compare)
Check whether the given date and time is later than current date.
struct mission_s * mission
memPool_t * cp_campaignPool
void CP_GameTimeStop(void)
Stop game time speed.
void BATTLE_Start(mission_t *mission, const battleParam_t *battleParameters)
Select the mission type and start the map from mission definition.
void CP_InitializeSpawningDelay(void)
Initialize spawning delay.
A base with all it's data.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
void UR_InitStartup(void)
Init actions for ufostoring-subsystem.
bool CP_LoadXML(xmlNode_t *parent)
Load callback for savegames in XML Format.
Header file for menu related console command callbacks.
void BATTLE_SetVars(const battleParam_t *battleParameters)
Set some needed cvars from a battle definition.
void CP_ReadCampaignData(const campaign_t *campaign)
Functions to generate and render overlay for geoscape.
int B_GetCount(void)
Returns the count of founded bases.
void CP_StartSelectedMission(void)
Starts a selected mission.
void AIR_InitStartup(void)
Init actions for aircraft-subsystem.
xmlNode_t *IMPORT * XML_GetDate(xmlNode_t *parent, const char *name, int *day, int *sec)
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
#define SAVE_CAMPAIGN_MAPDEF_COUNT
void CP_CampaignInit(campaign_t *campaign, bool load)
Called at new game and load game.
void INS_Shutdown(void)
Closing operations for installations subsystem.
Campaign mission headers.
void TR_Shutdown(void)
Closing actions for transfer-subsystem.
void CP_AttackUFOCarrier_f(void)
Decide whether you hit and destroyed the carrier and spawns a new carrier crash site mission...
Campaign mission triggers.
Header file for menu callback functions used for base and aircraft equip menu.
Header file for menu callback functions used for basedefence menu.
#define NAT_Foreach(var)
iterates trough nations
void B_Delete(base_t *base)
Resets a base structure.
#define SAVE_CAMPAIGN_CL_GEOSCAPE_OVERLAY
void INS_InitCallbacks(void)
void CP_CheckBaseAttacks(void)
Check and start baseattack missions.
void CP_UpdateTime(void)
Updates date/time and timescale (=timelapse) on the geoscape menu.
#define SAVE_CAMPAIGN_GEO_OVERLAY_RADAR
void CP_TEAM_ShutdownCallbacks(void)
Function that unregisters team (UI) callbacks.
Header file for hospital related stuff.
battleParam_t battleParameters
void CP_CampaignRun(campaign_t *campaign, float secondsSinceLastFrame)
Called every frame when we are in geoscape view.
mapDef_t *IMPORT * Com_GetMapDefinitionByID(const char *mapDefID)
void UR_ProcessActive(void)
Function to process active recoveries.
void NAT_BackupMonthlyData(void)
Backs up each nation's relationship values.
Campaign missions headers.
void CP_ScriptSanityCheck(void)
Check the parsed script values for errors after parsing every script file.
memPool_t *IMPORT * CreatePool(const char *name)
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
void CL_EventAddMail_f(void)
void RS_MarkCollected(technology_t *tech)
Marks a give technology as collected.
void AIRFIGHT_CampaignRunBaseDefence(int dt)
Run base defences.
#define SAVE_CAMPAIGN_GEO_OVERLAY_XVI
const cgame_import_t * cgi
void CP_ReduceXVIEverywhere(void)
Reduce XVI everywhere.
void HOS_ShutdownCallbacks(void)
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
Menu related callback functions for the team menu.
void INT_InitStartup(void)
Init actions for alien interests-subsystem.
UFO recovery and storing.
This is the technology parsed from research.ufo.
campaign_t * CP_GetCampaign(const char *name)
Returns the campaign pointer from global campaign array.
void BS_InitCallbacks(void)
Function registers the callbacks of the maket UI and do initializations.
void AB_UpdateStealthForAllBase(void)
Update stealth value of every base for every aircraft.
static void CP_AddCampaignCallbackCommands(void)
registers callback commands that are used by campaign
#define SAVE_CAMPAIGN_MAPDEF_ID
int maxAllowedXVIRateUntilLost
void BDEF_InitCallbacks(void)
Header file for menu related console command callbacks for production menu.
void NAT_UpdateHappinessForAllNations(const float minhappiness)
Lower happiness of nations depending on alien activity.
void UP_InitStartup(void)
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
void AIM_InitCallbacks(void)
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 ...
bool UFO_CampaignCheckEvents(void)
Check events for UFOs: Appears or disappears on radars.
void MIS_InitStartup(void)
Init actions for missions-subsystem.
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...
Campaign geoscape time header.
#define MapDef_ForeachSingleplayerCampaign(var)
client campaign structure
Campaign statistic headers.
void NAT_Shutdown(void)
Closing actions for nation-subsystem.
void CAP_CheckOverflow(void)
Checks capacity overflows on bases.
Header for Geoscape management.
void HOS_InitStartup(void)
Initial stuff for hospitals Bind some of the functions in this file to console-commands that you can ...
cvar_t *IMPORT * Cvar_Get(const char *varName, const char *value, int flags, const char *desc)
void AC_InitStartup(void)
Defines commands and cvars for the alien containment menu(s).
#define SECONDS_PER_MINUTE
void AIR_CampaignRun(const campaign_t *campaign, int dt, bool updateRadarOverlay)
Handles aircraft movement and actions in geoscape mode.
int UP_GetUnreadMails(void)
Sets the amount of unread/new mails.
#define GEO_GetMissionAircraft()
#define GEO_SetSelectedMission(mission)
void TR_InitStartup(void)
Defines commands and cvars for the Transfer menu(s).
void CP_FreeDynamicEventMail(void)
Make sure, that the linked list is freed with every new game.
void RADAR_UpdateBaseRadarCoverage_f(void)
Update radar coverage when building/destroying new radar.
void INT_IncreaseAlienInterest(const campaign_t *campaign)
Increase alien overall interest.
static void CP_RemoveCampaignCallbackCommands(void)
registers callback commands that are used by campaign
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 CP_TEAM_InitCallbacks(void)
Function that registers team (UI) callbacks.
void UR_Shutdown(void)
Closing actions for ufostoring-subsystem.
#define SAVE_CAMPAIGN_DATE
static bool CP_SaveMapDefStatXML(xmlNode_t *parent)
Save mapDef statistics.
static const cmdList_t game_commands[]
void UFO_UpdateAlienInterestForAllBasesAndInstallations(void)
Update alien interest for all PHALANX bases.
void PR_ShutdownCallbacks(void)
static bool CP_IsBudgetDue(const dateLong_t *oldDate, const dateLong_t *date)
Human readable time information in the game.
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...
static void CP_AdvanceTimeBySeconds(int seconds)
Ensure that the day always matches the seconds. If the seconds per day limit is reached, the seconds are reset and the day is increased.
#define SAVE_CAMPAIGN_NEXTUNIQUECHARACTERNUMBER
void CP_StartXVISpreading_f(void)
Start XVI spreading in campaign.
void RS_InitCallbacks(void)
void CP_CheckCampaignEvents(campaign_t *campaign)
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
int AIR_GetTeamSize(const aircraft_t *aircraft)
Counts the number of soldiers in given aircraft.
Header for slot management related stuff.
const char *IMPORT * UI_GetActiveWindowName(void)
void GEO_CenterOnPoint_f(void)
Switch to next model on 2D and 3D geoscape.
#define SAVE_CAMPAIGN_XVISTARTED
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void CP_CheckLostCondition(const campaign_t *campaign)
Checks whether the player has lost the campaign.
void CP_SpreadXVI(void)
Spread XVI for each mission that needs to be daily spread.
void CP_GameTimeFast(void)
Increase game time speed.
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
void CP_DateConvertLong(const date_t *date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
static void CP_CheckMissionEnd(const campaign_t *campaign)
Check for missions that have a timeout defined.
#define SAVE_CAMPAIGN_CAMPAIGN
void CP_InitStartup(void)
void AM_Shutdown(void)
Closing actions for automission-subsystem.
void HOS_InitCallbacks(void)
void NAT_InitStartup(void)
Init actions for nation-subsystem.
#define GEO_GetSelectedMission()
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
missionResults_t missionResults
void E_InitialEmployees(const campaign_t *campaign)
Create initial hireable employees.
void CP_InitializeXVIOverlay(void)
Initialize XVI overlay on geoscape.
XML tag constants for savegame.
Header file for single player campaign control.
int CP_GetSalaryUpKeepBase(const salary_t *salary, const base_t *base)
void B_InitStartup(void)
Resets console commands.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
void MS_MessageInit(void)
void RS_ResetTechs(void)
This is called everytime RS_ParseTechnologies is called - to prevent cyclic hash tables.
void AII_UpdateInstallationDelay(void)
Update the installation delay of all slots of a given aircraft.
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
Campaign mission headers.
#define NATIONBELOWLIMITPERCENTAGE
void CP_SpawnUFOCarrier_f(void)
Spawns a UFO-Carrier mission.
bool CP_SaveXML(xmlNode_t *parent)
Save callback for savegames in XML Format.
void HOS_HospitalRun(void)
Checks health status of all employees in all bases.
void STATS_InitStartup(void)
#define SAVE_CAMPAIGN_PAID
void CP_CleanTempInventory(base_t *base)
Clears all containers that are temp containers (see script definition).
bool CP_CheckCredits(int costs)
Checks whether you have enough credits for something.
#define AIR_Foreach(var)
iterates trough all aircraft
void INS_ShutdownCallbacks(void)
int RS_ResearchRun(void)
Checks the research status.
An aircraft with all it's data.
void UFO_InitStartup(void)
Init actions for ufo-subsystem.
Team management for the campaign gametype headers.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
buildingStatus_t buildingStatus
void TR_TransferRun(void)
Checks whether given transfer should be processed.
int negativeCreditsUntilLost
#define SAVE_CAMPAIGN_GEO_OVERLAY_NATION
void CP_UpdateXVIMapButton(void)
This will hide or show the geoscape button for handling the xvi overlay map.
void CP_CampaignRunMarket(campaign_t *campaign)
make number of items change every day.
void B_SelectBase(const base_t *base)
Select and opens a base.
#define CP_IsXVIStarted()
Header file for menu related console command callbacks.
const char *IMPORT * Cmd_Argv(int n)
campaign_t campaigns[MAX_CAMPAIGNS]
#define SAVE_CAMPAIGN_RADAROVERLAYWASSET
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...
void AIRFIGHT_CampaignRunProjectiles(const campaign_t *campaign, int dt)
Update values of projectiles.
void PR_ProductionRun(void)
Checks whether an item is finished.
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
void NAT_HandleBudget(const campaign_t *campaign)
Update the nation data from all parsed nation each month.
void STATS_ShutDown(void)
void AIR_Shutdown(void)
Closing actions for aircraft-subsystem.
void RS_ShutdownCallbacks(void)
void AM_InitStartup(void)
Init actions for automission-subsystem.
building_t * B_GetNextBuilding(const base_t *base, building_t *lastBuilding)
Iterates through buildings in a base.
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...
void GEO_Reset(const char *map)
void CP_CleanupAircraftTeam(aircraft_t *aircraft, equipDef_t *ed)
Reloads weapons, removes not assigned and resets defaults.