UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_campaign.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */
24 
25 #include "../../cl_shared.h"
26 #include "../../ui/ui_main.h"
27 #include "../cgame.h"
28 #include "cp_campaign.h"
29 #include "cp_capacity.h"
30 #include "cp_character.h"
31 #include "cp_overlay.h"
32 #include "cp_mapfightequip.h"
33 #include "cp_hospital.h"
34 #include "cp_hospital_callbacks.h"
35 #include "cp_base_callbacks.h"
37 #include "cp_team.h"
38 #include "cp_team_callbacks.h"
39 #include "cp_popup.h"
40 #include "cp_geoscape.h"
41 #include "cp_ufo.h"
43 #include "cp_alien_interest.h"
44 #include "cp_missions.h"
45 #include "cp_mission_triggers.h"
46 #include "cp_nation.h"
47 #include "cp_statistics.h"
48 #include "cp_time.h"
49 #include "cp_xvi.h"
51 #include "cp_produce_callbacks.h"
52 #include "cp_transfer.h"
53 #include "cp_market_callbacks.h"
54 #include "cp_research_callbacks.h"
55 #include "cp_uforecovery.h"
56 #include "save/save_campaign.h"
57 #include "cp_auto_mission.h"
60 
64 
65 /* fraction of nation that can be below min happiness before the game is lost */
66 #define NATIONBELOWLIMITPERCENTAGE 0.5f
67 
75 
79 bool CP_IsRunning (void)
80 {
81  return ccs.curCampaign != nullptr;
82 }
83 
88 void CP_EndCampaign (bool won)
89 {
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;");
93 
94  cgi->Com_Drop();
95 }
96 
100 void CP_CheckLostCondition (const campaign_t* campaign)
101 {
102  bool endCampaign = false;
103 
104  if (cp_missiontest->integer)
105  return;
106 
107  if (!endCampaign && ccs.credits < -campaign->negativeCreditsUntilLost) {
108  cgi->UI_RegisterText(TEXT_STANDARD, _("You've gone too far into debt."));
109  endCampaign = true;
110  }
111 
115  if (ccs.credits < campaign->basecost - campaign->negativeCreditsUntilLost && !B_AtLeastOneExists()) {
116  cgi->UI_RegisterText(TEXT_STANDARD, _("You've lost your bases and don't have enough money to build new ones."));
117  endCampaign = true;
118  }
119 
120  if (!endCampaign) {
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."));
128  endCampaign = true;
129  } else {
130  /* check for nation happiness */
131  int nationBelowLimit = 0;
132  NAT_Foreach(nation) {
133  const nationInfo_t* stats = NAT_GetCurrentMonthInfo(nation);
134  if (stats->happiness < campaign->minhappiness) {
135  nationBelowLimit++;
136  }
137  }
138  if (nationBelowLimit >= NATIONBELOWLIMITPERCENTAGE * ccs.numNations) {
139  /* lost the game */
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."));
147  endCampaign = true;
148  }
149  }
150  }
151 
152  if (endCampaign)
153  CP_EndCampaign(false);
154 }
155 
159 static void CP_CheckMissionEnd (const campaign_t* campaign)
160 {
161  MIS_Foreach(mission) {
162  if (CP_CheckMissionLimitedInTime(mission) && Date_LaterThan(&ccs.date, &mission->finalDate))
163  CP_MissionStageEnd(campaign, mission);
164  }
165 }
166 
167 /* =========================================================== */
168 
176 static void CP_CampaignFunctionPeriodicCall (campaign_t* campaign, int dt, bool updateRadarOverlay)
177 {
178  UFO_CampaignRunUFOs(campaign, dt);
179  AIR_CampaignRun(campaign, dt, updateRadarOverlay);
180 
182  AIRFIGHT_CampaignRunProjectiles(campaign, dt);
184 
185  /* Update alien interest for bases */
187 
188  /* Update how phalanx troop know alien bases */
190 
192 }
193 
198 bool CP_OnGeoscape (void)
199 {
200  return Q_streq("geoscape", cgi->UI_GetActiveWindowName());
201 }
202 
208 static inline void CP_AdvanceTimeBySeconds (int seconds)
209 {
210  ccs.date.sec += seconds;
211  while (ccs.date.sec >= SECONDS_PER_DAY) {
212  ccs.date.sec -= SECONDS_PER_DAY;
213  ccs.date.day++;
214  }
215 }
216 
220 static inline bool CP_IsBudgetDue (const dateLong_t* oldDate, const dateLong_t* date)
221 {
222  if (oldDate->year < date->year) {
223  return true;
224  }
225  return oldDate->month < date->month;
226 }
227 
234 void CP_CampaignRun (campaign_t* campaign, float secondsSinceLastFrame)
235 {
236  /* advance time */
237  ccs.frametime = secondsSinceLastFrame;
238  ccs.timer += secondsSinceLastFrame * ccs.gameTimeScale;
239 
241 
242  if (ccs.timer < 1.0)
243  return;
244 
245  /* calculate new date */
246  int currentsecond = ccs.date.sec;
247  int currentday = ccs.date.day;
248  const int currentinterval = currentsecond % DETECTION_INTERVAL;
249  int dt = DETECTION_INTERVAL - currentinterval;
250  dateLong_t date, oldDate;
251  const int timer = (int)floor(ccs.timer);
252  const int checks = (currentinterval + timer) / DETECTION_INTERVAL;
253 
254  CP_DateConvertLong(&ccs.date, &oldDate);
255 
256  int currenthour = currentsecond / SECONDS_PER_HOUR;
257  int currentmin = currentsecond / SECONDS_PER_MINUTE;
258 
259  /* Execute every actions that needs to be independent of time speed : every DETECTION_INTERVAL
260  * - Run UFOs and craft at least every DETECTION_INTERVAL. If detection occurred, break.
261  * - Check if any new mission is detected
262  * - Update stealth value of phalanx bases and installations ; alien bases */
263  for (int i = 0; i < checks; i++) {
264  ccs.timer -= dt;
265  currentsecond += dt;
267  CP_CampaignFunctionPeriodicCall(campaign, dt, false);
268 
269  /* if something stopped time, we must stop here the loop */
270  if (CP_IsTimeStopped()) {
271  ccs.timer = 0.0f;
272  break;
273  }
274  dt = DETECTION_INTERVAL;
275  }
276 
277  dt = timer;
278 
280  currentsecond += dt;
281  ccs.timer -= dt;
282 
283  /* compute minutely events */
284  /* (this may run multiple times if the time stepping is > 1 minute at a time) */
285  const int newmin = currentsecond / SECONDS_PER_MINUTE;
286  while (currentmin < newmin) {
287  currentmin++;
290  }
291 
292  /* compute hourly events */
293  /* (this may run multiple times if the time stepping is > 1 hour at a time) */
294  const int newhour = currentsecond / SECONDS_PER_HOUR;
295  while (currenthour < newhour) {
296  currenthour++;
297  RS_ResearchRun();
301  TR_TransferRun();
302  INT_IncreaseAlienInterest(campaign);
303  }
304 
305  /* daily events */
306  for (int i = currentday; i < ccs.date.day; i++) {
307  /* every day */
309  HOS_HospitalRun();
310  ccs.missionSpawnCallback();
311  CP_SpreadXVI();
314  CP_CampaignRunMarket(campaign);
315  CP_CheckCampaignEvents(campaign);
317  /* should be executed after all daily event that could
318  * change XVI overlay */
321  }
322 
323  if (dt > 0) {
324  /* check for campaign events
325  * aircraft and UFO already moved during radar detection (see above),
326  * just make them move the missing part -- if any */
327  CP_CampaignFunctionPeriodicCall(campaign, dt, true);
328  }
329 
330  CP_CheckMissionEnd(campaign);
331  CP_CheckLostCondition(campaign);
332  /* Check if there is a base attack mission */
334  /* check if any stores are full */
337 
338  CP_DateConvertLong(&ccs.date, &date);
339  /* every new month we have to handle the budget */
340  if (CP_IsBudgetDue(&oldDate, &date) && ccs.paid && B_AtLeastOneExists()) {
342  NAT_HandleBudget(campaign);
343  ccs.paid = false;
344  } else if (date.day > 1)
345  ccs.paid = true;
346 
348  /* set time cvars */
349  CP_UpdateTime();
350 }
351 
356 bool CP_CheckCredits (int costs)
357 {
358  if (costs > ccs.credits)
359  return false;
360  return true;
361 }
362 
368 void CP_UpdateCredits (int credits)
369 {
370  /* credits */
371  if (credits > MAX_CREDITS)
372  credits = MAX_CREDITS;
373  ccs.credits = credits;
374  cgi->Cvar_Set("mn_credits", _("%i c"), ccs.credits);
375 }
376 
381 static bool CP_LoadMapDefStatXML (xmlNode_t* parent)
382 {
383  xmlNode_t* node;
384 
385  for (node = cgi->XML_GetNode(parent, SAVE_CAMPAIGN_MAPDEF); node; node = cgi->XML_GetNextNode(node, parent, SAVE_CAMPAIGN_MAPDEF)) {
386  const char* s = cgi->XML_GetString(node, SAVE_CAMPAIGN_MAPDEF_ID);
387  mapDef_t* map;
388 
389  if (s[0] == '\0') {
390  cgi->Com_Printf("Warning: MapDef with no id in xml!\n");
391  continue;
392  }
393  map = cgi->Com_GetMapDefinitionByID(s);
394  if (!map) {
395  cgi->Com_Printf("Warning: No MapDef with id '%s'!\n", s);
396  continue;
397  }
398  map->timesAlreadyUsed = cgi->XML_GetInt(node, SAVE_CAMPAIGN_MAPDEF_COUNT, 0);
399  }
400 
401  return true;
402 }
403 
408 bool CP_LoadXML (xmlNode_t* parent)
409 {
410  xmlNode_t* campaignNode;
411  xmlNode_t* mapNode;
412  const char* name;
413  campaign_t* campaign;
414  xmlNode_t* mapDefStat;
415 
416  campaignNode = cgi->XML_GetNode(parent, SAVE_CAMPAIGN_CAMPAIGN);
417  if (!campaignNode) {
418  cgi->Com_Printf("Did not find campaign entry in xml!\n");
419  return false;
420  }
421  if (!(name = cgi->XML_GetString(campaignNode, SAVE_CAMPAIGN_ID))) {
422  cgi->Com_Printf("couldn't locate campaign name in savegame\n");
423  return false;
424  }
425 
426  campaign = CP_GetCampaign(name);
427  if (!campaign) {
428  cgi->Com_Printf("......campaign \"%s\" doesn't exist.\n", name);
429  return false;
430  }
431 
432  CP_CampaignInit(campaign, true);
433  /* init the map images and reset the map actions */
434  GEO_Reset(campaign->map);
435 
436  /* read credits */
437  CP_UpdateCredits(cgi->XML_GetLong(campaignNode, SAVE_CAMPAIGN_CREDITS, 0));
438  ccs.paid = cgi->XML_GetBool(campaignNode, SAVE_CAMPAIGN_PAID, false);
439 
440  cgi->SetNextUniqueCharacterNumber(cgi->XML_GetInt(campaignNode, SAVE_CAMPAIGN_NEXTUNIQUECHARACTERNUMBER, 0));
441 
442  cgi->XML_GetDate(campaignNode, SAVE_CAMPAIGN_DATE, &ccs.date.day, &ccs.date.sec);
443 
444  /* read other campaign data */
445  ccs.civiliansKilled = cgi->XML_GetInt(campaignNode, SAVE_CAMPAIGN_CIVILIANSKILLED, 0);
446  ccs.aliensKilled = cgi->XML_GetInt(campaignNode, SAVE_CAMPAIGN_ALIENSKILLED, 0);
447 
448  cgi->Com_DPrintf(DEBUG_CLIENT, "CP_LoadXML: Getting position\n");
449 
450  /* read map view */
451  mapNode = cgi->XML_GetNode(campaignNode, SAVE_CAMPAIGN_MAP);
452 
453  /* Compatibility code for savegames */
454  int oldOverlayStatus = cgi->XML_GetInt(mapNode, SAVE_CAMPAIGN_CL_GEOSCAPE_OVERLAY, -1);
455  if (oldOverlayStatus >= 0) {
456  const int overlayNation = 1 << 0;
457  const int overlayXvi = 1 << 1;
458  const int overlayRadar = 1 << 2;
459 
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);
463  } else {
464  cgi->Cvar_SetValue("geo_overlay_radar", cgi->XML_GetInt(mapNode, SAVE_CAMPAIGN_GEO_OVERLAY_RADAR, 0));
465  cgi->Cvar_SetValue("geo_overlay_nation", cgi->XML_GetInt(mapNode, SAVE_CAMPAIGN_GEO_OVERLAY_NATION, 0));
466  cgi->Cvar_SetValue("geo_overlay_xvi", cgi->XML_GetInt(mapNode, SAVE_CAMPAIGN_GEO_OVERLAY_XVI, 0));
467  }
468  radarOverlayWasSet = cgi->XML_GetBool(mapNode, SAVE_CAMPAIGN_RADAROVERLAYWASSET, false);
469  ccs.startXVI = cgi->XML_GetBool(mapNode, SAVE_CAMPAIGN_XVISTARTED, false);
470 
471  mapDefStat = cgi->XML_GetNode(campaignNode, SAVE_CAMPAIGN_MAPDEFSTAT);
472  if (mapDefStat && !CP_LoadMapDefStatXML(mapDefStat))
473  return false;
474 
475  mxmlDelete(campaignNode);
476  return true;
477 }
478 
483 static bool CP_SaveMapDefStatXML (xmlNode_t* parent)
484 {
485  const mapDef_t* md;
486 
488  if (md->timesAlreadyUsed > 0) {
489  xmlNode_t* node = cgi->XML_AddNode(parent, SAVE_CAMPAIGN_MAPDEF);
490  cgi->XML_AddString(node, SAVE_CAMPAIGN_MAPDEF_ID, md->id);
491  cgi->XML_AddInt(node, SAVE_CAMPAIGN_MAPDEF_COUNT, md->timesAlreadyUsed);
492  }
493  }
494 
495  return true;
496 }
497 
502 bool CP_SaveXML (xmlNode_t* parent)
503 {
504  xmlNode_t* campaign;
505  xmlNode_t* map;
506  xmlNode_t* mapDefStat;
507 
508  campaign = cgi->XML_AddNode(parent, SAVE_CAMPAIGN_CAMPAIGN);
509 
510  cgi->XML_AddString(campaign, SAVE_CAMPAIGN_ID, ccs.curCampaign->id);
511  cgi->XML_AddDate(campaign, SAVE_CAMPAIGN_DATE, ccs.date.day, ccs.date.sec);
512  cgi->XML_AddLong(campaign, SAVE_CAMPAIGN_CREDITS, ccs.credits);
513  cgi->XML_AddShort(campaign, SAVE_CAMPAIGN_PAID, ccs.paid);
514  cgi->XML_AddShortValue(campaign, SAVE_CAMPAIGN_NEXTUNIQUECHARACTERNUMBER, cgi->GetNextUniqueCharacterNumber());
515 
516  cgi->XML_AddIntValue(campaign, SAVE_CAMPAIGN_CIVILIANSKILLED, ccs.civiliansKilled);
517  cgi->XML_AddIntValue(campaign, SAVE_CAMPAIGN_ALIENSKILLED, ccs.aliensKilled);
518 
519  /* Map and user interface */
520  map = cgi->XML_AddNode(campaign, SAVE_CAMPAIGN_MAP);
521  cgi->XML_AddShort(map, SAVE_CAMPAIGN_GEO_OVERLAY_RADAR, cgi->Cvar_GetInteger("geo_overlay_radar"));
522  cgi->XML_AddShort(map, SAVE_CAMPAIGN_GEO_OVERLAY_NATION, cgi->Cvar_GetInteger("geo_overlay_nation"));
523  cgi->XML_AddShort(map, SAVE_CAMPAIGN_GEO_OVERLAY_XVI, cgi->Cvar_GetInteger("geo_overlay_xvi"));
525  cgi->XML_AddBool(map, SAVE_CAMPAIGN_XVISTARTED, CP_IsXVIStarted());
526 
527  mapDefStat = cgi->XML_AddNode(campaign, SAVE_CAMPAIGN_MAPDEFSTAT);
528  if (!CP_SaveMapDefStatXML(mapDefStat))
529  return false;
530 
531  return true;
532 }
533 
541 {
542  mission_t* mis;
543  aircraft_t* aircraft = GEO_GetMissionAircraft();
544  base_t* base;
545  battleParam_t* battleParam = &ccs.battleParameters;
546 
547  if (!aircraft) {
548  cgi->Com_Printf("CP_StartSelectedMission: No mission aircraft\n");
549  return;
550  }
551 
552  base = aircraft->homebase;
553 
554  if (GEO_GetSelectedMission() == nullptr)
555  GEO_SetSelectedMission(aircraft->mission);
556 
557  mis = GEO_GetSelectedMission();
558  if (!mis) {
559  cgi->Com_Printf("CP_StartSelectedMission: No mission selected\n");
560  return;
561  }
562 
563  /* Before we start, we should clear the missionResults array. */
564  OBJZERO(mis->missionResults);
565 
566  /* Various sanity checks. */
567  if (!mis->active) {
568  cgi->Com_Printf("CP_StartSelectedMission: Dropship not near landing zone: mis->active: %i\n", mis->active);
569  return;
570  }
571  if (AIR_GetTeamSize(aircraft) == 0) {
572  cgi->Com_Printf("CP_StartSelectedMission: No team in dropship.\n");
573  return;
574  }
575 
576  /* if we retry a mission we have to drop from the current game before */
577  cgi->SV_Shutdown("Server quit.", false);
578  cgi->CL_Disconnect();
579 
580  CP_CreateBattleParameters(mis, battleParam, aircraft);
581  BATTLE_SetVars(battleParam);
582 
583  /* manage inventory */
584  ccs.eMission = base->storage; /* copied, including arrays inside! */
585  CP_CleanTempInventory(base);
586  CP_CleanupAircraftTeam(aircraft, &ccs.eMission);
587  BATTLE_Start(mis, battleParam);
588 }
589 #ifdef DEBUG
590 
594 static void CP_DebugShowItems_f (void)
595 {
596  if (cgi->Cmd_Argc() < 2) {
597  cgi->Com_Printf("Usage: %s <baseID>\n", cgi->Cmd_Argv(0));
598  return;
599  }
600 
601  int i = atoi(cgi->Cmd_Argv(1));
602  if (i >= B_GetCount()) {
603  cgi->Com_Printf("invalid baseID (%s)\n", cgi->Cmd_Argv(1));
604  return;
605  }
606  base_t* base = B_GetBaseByIDX(i);
607 
608  for (i = 0; i < cgi->csi->numODs; i++) {
609  const objDef_t* obj = INVSH_GetItemByIDX(i);
610  cgi->Com_Printf("%i. %s: %i\n", i, obj->id, B_ItemInBase(obj, base));
611  }
612 }
613 
620 static void CP_DebugAddItem_f (void)
621 {
622  if (cgi->Cmd_Argc() < 4) {
623  cgi->Com_Printf("Usage: %s <baseID> <itemid> <count>\n", cgi->Cmd_Argv(0));
624  return;
625  }
626 
627  base_t* base = B_GetFoundedBaseByIDX(atoi(cgi->Cmd_Argv(1)));
628  const objDef_t* obj = INVSH_GetItemByID(cgi->Cmd_Argv(2));
629  const int count = atoi(cgi->Cmd_Argv(3));
630 
631  if (!base) {
632  cgi->Com_Printf("Invalid base index given\n");
633  return;
634  }
635  if (!obj) {
636  /* INVSH_GetItemByIDX prints warning already */
637  return;
638  }
639 
640  const int amount = B_AddToStorage(base, obj, count);
641  cgi->Com_Printf("%s %s %d\n", base->name, obj->id, amount);
642  if (B_ItemInBase(obj, base) > 0) {
644  RS_MarkCollected(tech);
645  }
646 }
647 
654 static void CP_DebugAddAntimatter_f (void)
655 {
656  if (cgi->Cmd_Argc() < 3) {
657  cgi->Com_Printf("Usage: %s <baseID> <amount>\n", cgi->Cmd_Argv(0));
658  return;
659  }
660 
661  base_t* base = B_GetFoundedBaseByIDX(atoi(cgi->Cmd_Argv(1)));
662  const int amount = atoi(cgi->Cmd_Argv(2));
663 
664  if (!base) {
665  cgi->Com_Printf("Invalid base index given\n");
666  return;
667  }
668 
669  B_AddAntimatter(base, amount);
670 }
671 
675 static void CP_DebugFullCredits_f (void)
676 {
678 }
679 #endif
680 
681 /* ===================================================================== */
682 
683 /* these commands are only available in singleplayer */
684 static const cmdList_t game_commands[] = {
685  {"update_base_radar_coverage", RADAR_UpdateBaseRadarCoverage_f, "Update base radar coverage"},
686  {"addeventmail", CL_EventAddMail_f, "Add a new mail (event trigger) - e.g. after a mission"},
687  {"game_go", CP_StartSelectedMission, nullptr},
688  {"game_timestop", CP_GameTimeStop, nullptr},
689  {"game_timeslow", CP_GameTimeSlow, nullptr},
690  {"game_timefast", CP_GameTimeFast, nullptr},
691  {"game_settimeid", CP_SetGameTime_f, nullptr},
692  {"map_center", GEO_CenterOnPoint_f, "Centers the geoscape view on items on the geoscape - and cycle through them"},
693  {"cp_start_xvi_spreading", CP_StartXVISpreading_f, "Start XVI spreading"},
694  {"cp_spawn_ufocarrier", CP_SpawnUFOCarrier_f, "Spawns a UFO-Carrier on the geoscape"},
695  {"cp_attack_ufocarrier", CP_AttackUFOCarrier_f, "Attack the UFO-Carrier"},
696 #ifdef DEBUG
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"},
701 #endif
702  {nullptr, nullptr, nullptr}
703 };
704 
713 {
715  B_InitCallbacks();
723 }
724 
725 static void CP_AddCampaignCommands (void)
726 {
727  cgi->Cmd_TableAddList(game_commands);
729 }
730 
739 {
749  MSO_Shutdown();
750  UP_Shutdown();
751 }
752 
753 static void CP_RemoveCampaignCommands (void)
754 {
755  cgi->Cmd_TableRemoveList(game_commands);
756 
758 }
759 
765 void CP_CampaignInit (campaign_t* campaign, bool load)
766 {
767  ccs.curCampaign = campaign;
768 
769  CP_ReadCampaignData(campaign);
770 
771  CP_UpdateTime();
772 
773  RS_InitTree(campaign, load);
776 
777  CP_GameTimeStop();
778 
779  /* Init popup and map/geoscape */
780  CL_PopupInit();
781 
782  CP_XVIInit();
783 
784  if (load) {
785  return;
786  }
787 
788  cgi->UI_InitStack("geoscape", "campaign_main");
789 
790  CL_EventAddMail("prolog");
791 
792  RS_MarkResearchable(nullptr, true);
793  BS_InitMarket(campaign);
794 
795  /* create initial employees */
796  E_InitialEmployees(campaign);
797 
798  GEO_Reset(campaign->map);
799 
800  CP_UpdateCredits(campaign->credits);
801 
802  /* Initialize alien interest */
804 
805  /* Initialize XVI overlay */
808 
809  /* create a base as first step */
810  B_SelectBase(nullptr);
811 
812  /* Spawn first missions of the game */
814 
815  /* now check the parsed values for errors that are not caught at parsing stage */
817 }
818 
822 void CP_Shutdown (void)
823 {
824  if (CP_IsRunning()) {
825  AB_Shutdown();
826  UFO_Shutdown();
827  AIR_Shutdown();
828  INS_Shutdown();
829  INT_Shutdown();
830  NAT_Shutdown();
831  MIS_Shutdown();
832  TR_Shutdown();
833  STATS_ShutDown();
834  UR_Shutdown();
835  AM_Shutdown();
836  E_Shutdown();
837  CHAR_Shutdown();
838 
840  for (int i = 0; i < ccs.numAlienCategories; i++) {
841  alienTeamCategory_t* alienCat = &ccs.alienCategories[i];
842  cgi->LIST_Delete(&alienCat->equipment);
843  }
844 
845  cgi->Cvar_SetValue("geo_overlay_radar", 0);
846  cgi->Cvar_SetValue("geo_overlay_nations", 0);
847  cgi->Cvar_SetValue("geo_overlay_xvi", 0);
848  /* singleplayer commands are no longer available */
850  }
851 
852  GEO_Shutdown();
853 }
854 
861 {
862  campaign_t* campaign;
863  int i;
864 
865  for (i = 0, campaign = ccs.campaigns; i < ccs.numCampaigns; i++, campaign++)
866  if (Q_streq(name, campaign->id))
867  break;
868 
869  if (i == ccs.numCampaigns) {
870  cgi->Com_Printf("CL_GetCampaign: Campaign \"%s\" doesn't exist.\n", name);
871  return nullptr;
872  }
873  return campaign;
874 }
875 
882 {
883  mapDef_t* md;
884 
885  cgi->UI_MessageResetStack();
886 
887  /* cleanup dynamic mails */
889 
890  AIR_Foreach(aircraft) {
891  AIR_Delete(nullptr, aircraft);
892  }
893 
894  base_t* base = nullptr;
895  while((base = B_GetNext(base)) != nullptr) {
896  B_Delete(base);
897  }
898 
899  cgi->FreePool(cp_campaignPool);
900 
901  /* called to flood the hash list - because the parse tech function
902  * was maybe already called */
903  RS_ResetTechs();
904 
905  OBJZERO(ccs);
906 
908 
909  /* Clear mapDef usage statistics */
911  md->timesAlreadyUsed = 0;
912  }
913 }
914 
915 int CP_GetSalaryUpKeepBase (const salary_t* salary, const base_t* base)
916 {
917  int cost = salary->baseUpkeep; /* base cost */
918  building_t* building = nullptr;
919  while ((building = B_GetNextBuilding(base, building))) {
920  if (building->buildingStatus == B_STATUS_WORKING
922  cost += building->varCosts;
923  }
924  return cost;
925 }
926 
928 void CP_InitStartup (void)
929 {
930  cp_campaignPool = cgi->CreatePool("Client: Local (per game)");
931 
932  SAV_Init();
933 
934 
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");
936 
937  /* init subsystems */
938  MS_MessageInit();
940 
941  MIS_InitStartup();
942  UP_InitStartup();
943  B_InitStartup();
944  INS_InitStartup();
945  RS_InitStartup();
946  E_InitStartup();
947  HOS_InitStartup();
948  INT_InitStartup();
949  AC_InitStartup();
950  GEO_InitStartup();
951  UFO_InitStartup();
952  TR_InitStartup();
953  AB_InitStartup();
954  AIR_InitStartup();
956  NAT_InitStartup();
957  TR_InitStartup();
959  UR_InitStartup();
960  AM_InitStartup();
962 }
Header file for menu related console command callbacks.
bool CP_IsTimeStopped(void)
Check if time is stopped.
Definition: cp_time.cpp:139
void SAV_Init(void)
Register all save-subsystems and init some cvars and commands.
Definition: cp_save.cpp:413
int CP_GetAverageXVIRate(void)
Return the average XVI rate.
Definition: cp_xvi.cpp:163
bool AIR_Delete(base_t *base, aircraft_t *aircraft)
Will remove the given aircraft from the base.
#define SAVE_CAMPAIGN_CIVILIANSKILLED
Definition: save_campaign.h:34
alienTeamCategory_t alienCategories[ALIENCATEGORY_MAX]
Definition: cp_campaign.h:317
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.
Definition: cp_nation.cpp:132
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.
Definition: cp_base.cpp:2134
bool CP_CheckNewMissionDetectedOnGeoscape(void)
Check if mission has been detected by radar.
bool CP_IsRunning(void)
Checks whether a campaign mode game is running.
Definition: cp_campaign.cpp:79
static void CP_AddCampaignCommands(void)
void PR_InitCallbacks(void)
A building with all it's data.
Definition: cp_building.h:73
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
Definition: cp_campaign.h:124
void MIS_Shutdown(void)
Closing actions for missions-subsystem.
void B_UpdateBuildingConstructions(void)
Updates base data.
Definition: cp_base.cpp:2010
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
Definition: inv_shared.cpp:282
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.
Definition: cp_xvi.cpp:88
int civiliansKilled
Definition: cp_campaign.h:243
int numAlienCategories
Definition: cp_campaign.h:318
Header file for menu related console command callbacks.
missionSpawnFunction_t missionSpawnCallback
Definition: cp_campaign.h:386
char * id
Definition: q_shared.h:463
void CP_SetGameTime_f(void)
Set a new time game from id.
Definition: cp_time.cpp:214
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...
Definition: shared.cpp:410
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.
Definition: cvar.h:71
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 aliensKilled
Definition: cp_campaign.h:244
#define MIS_Foreach(var)
iterates through missions
Definition: cp_missions.h:118
void CL_EventAddMail(const char *eventMailId)
Adds the event mail to the message stack. This message is going to be added to the savegame...
Definition: cp_event.cpp:508
#define _(String)
Definition: cl_shared.h:43
Header for menu related research stuff.
void INS_UpdateInstallationData(void)
Check if some installation are build.
int baseUpkeep
Definition: cp_campaign.h:158
void INT_Shutdown(void)
Closing actions for alien interests-subsystem.
void UFO_CampaignRunUFOs(const campaign_t *campaign, int deltaTime)
Make the UFOs run.
Definition: cp_ufo.cpp:601
void CP_EndCampaign(bool won)
Function to handle the campaign end.
Definition: cp_campaign.cpp:88
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.
Definition: cp_base.cpp:2574
struct technology_s * tech
Definition: cp_building.h:111
char id[MAX_VAR]
Definition: cp_campaign.h:165
char name[MAX_VAR]
Definition: cp_base.h:86
void AB_BaseSearchedByNations(void)
Nations help in searching alien base.
int credits
Definition: cp_campaign.h:242
int numNations
Definition: cp_campaign.h:296
void CP_Shutdown(void)
Campaign closing actions.
void GEO_Shutdown(void)
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 ...
csi_t * csi
Definition: cgame.h:100
static void CP_RemoveCampaignCommands(void)
void GEO_InitStartup(void)
Initialise MAP/Geoscape.
int day
Definition: common.h:291
date_t date
Definition: cp_campaign.h:245
#define B_AtLeastOneExists()
Definition: cp_base.h:55
void MSO_Shutdown(void)
void AIRFIGHT_InitStartup(void)
#define SAVE_CAMPAIGN_MAP
Definition: save_campaign.h:37
#define SAVE_CAMPAIGN_CREDITS
Definition: save_campaign.h:30
void CP_ResetCampaignData(void)
Will clear most of the parsed singleplayer data.
bool paid
Definition: cp_campaign.h:268
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
Definition: cp_market.cpp:525
int gameTimeScale
Definition: cp_campaign.h:264
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
int numODs
Definition: q_shared.h:518
byte day
Definition: cp_time.h:37
void AII_RepairAircraft(void)
Repair aircraft.
#define SAVE_CAMPAIGN_ALIENSKILLED
Definition: save_campaign.h:35
Nation code.
void BDEF_ShutdownCallbacks(void)
void UFO_Shutdown(void)
Closing actions for ufo-subsystem.
Definition: cp_ufo.cpp:1023
void E_Shutdown(void)
Closing actions for employee-subsystem.
void CP_GameTimeSlow(void)
Decrease game time speed.
Definition: cp_time.cpp:160
mission definition
Definition: cp_missions.h:85
linkedList_t * equipment
Definition: cp_campaign.h:130
#define SAVE_CAMPAIGN_MAPDEFSTAT
Definition: save_campaign.h:48
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
#define SECONDS_PER_HOUR
Definition: common.h:302
#define SAVE_CAMPAIGN_MAPDEF
Definition: save_campaign.h:49
int integer
Definition: cvar.h:81
void BS_ShutdownCallbacks(void)
Function unregisters the callbacks of the maket UI.
equipDef_t storage
Definition: cp_base.h:112
bool Date_LaterThan(const date_t *now, const date_t *compare)
Check whether the given date and time is later than current date.
Definition: cp_time.cpp:239
struct mission_s * mission
Definition: cp_aircraft.h:152
Definition: common.cpp:82
memPool_t * cp_campaignPool
Definition: cp_campaign.cpp:61
void CP_GameTimeStop(void)
Stop game time speed.
Definition: cp_time.cpp:126
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.
float happiness
Definition: cp_nation.h:37
A base with all it's data.
Definition: cp_base.h:84
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
Definition: cp_base.cpp:325
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.
Definition: cp_missions.cpp:78
bool radarOverlayWasSet
Definition: cp_radar.cpp:36
void CP_ReadCampaignData(const campaign_t *campaign)
Definition: cp_parse.cpp:681
Functions to generate and render overlay for geoscape.
float timer
Definition: cp_campaign.h:247
float frametime
Definition: cp_campaign.h:248
#define xmlNode_t
Definition: xml.h:24
int B_GetCount(void)
Returns the count of founded bases.
Definition: cp_base.cpp:276
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)
Campaign XVI header.
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
#define SAVE_CAMPAIGN_MAPDEF_COUNT
Definition: save_campaign.h:51
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.
#define MAX_CREDITS
Definition: cp_campaign.h:400
Header file for menu callback functions used for base and aircraft equip menu.
#define DEBUG_CLIENT
Definition: defines.h:59
Header file for menu callback functions used for basedefence menu.
#define NAT_Foreach(var)
iterates trough nations
Definition: cp_nation.h:80
void B_Delete(base_t *base)
Resets a base structure.
Definition: cp_base.cpp:897
#define SAVE_CAMPAIGN_CL_GEOSCAPE_OVERLAY
Definition: save_campaign.h:40
void INS_InitCallbacks(void)
void CP_CheckBaseAttacks(void)
Check and start baseattack missions.
struct base_s * base
Definition: cp_building.h:76
#define OBJZERO(obj)
Definition: shared.h:178
equipDef_t eMission
Definition: cp_campaign.h:229
void CP_UpdateTime(void)
Updates date/time and timescale (=timelapse) on the geoscape menu.
Definition: cp_time.cpp:104
#define SAVE_CAMPAIGN_GEO_OVERLAY_RADAR
Definition: save_campaign.h:42
void CP_TEAM_ShutdownCallbacks(void)
Function that unregisters team (UI) callbacks.
Header file for hospital related stuff.
battleParam_t battleParameters
Definition: cp_campaign.h:235
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.
Definition: cp_nation.cpp:826
Campaign missions headers.
void CP_ScriptSanityCheck(void)
Check the parsed script values for errors after parsing every script file.
Definition: cp_parse.cpp:612
memPool_t *IMPORT * CreatePool(const char *name)
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
Definition: cp_base.cpp:285
void CL_EventAddMail_f(void)
Definition: cp_event.cpp:554
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
Definition: save_campaign.h:44
const cgame_import_t * cgi
short year
Definition: cp_time.h:35
void CP_ReduceXVIEverywhere(void)
Reduce XVI everywhere.
Definition: cp_xvi.cpp:70
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.
Definition: cp_research.h:137
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
Definition: save_campaign.h:50
ccs_t ccs
Definition: cp_campaign.cpp:62
int maxAllowedXVIRateUntilLost
Definition: cp_campaign.h:188
Definition: cmd.h:86
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.
Definition: cp_nation.cpp:83
byte month
Definition: cp_time.h:36
void UP_InitStartup(void)
void CP_TriggerEvent(campaignTriggerEventType_t type, const void *userdata)
Triggers a campaign event with a special type.
Definition: cp_event.cpp:311
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.
Definition: cp_ufo.cpp:867
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...
Definition: cp_base.cpp:312
Campaign geoscape time header.
#define MapDef_ForeachSingleplayerCampaign(var)
Definition: cl_shared.h:83
client campaign structure
Definition: cp_campaign.h:228
Campaign statistic headers.
void NAT_Shutdown(void)
Closing actions for nation-subsystem.
Definition: cp_nation.cpp:860
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).
char map[MAX_VAR]
Definition: cp_campaign.h:177
#define SECONDS_PER_MINUTE
Definition: common.h:303
void AIR_CampaignRun(const campaign_t *campaign, int dt, bool updateRadarOverlay)
Handles aircraft movement and actions in geoscape mode.
bool active
Definition: cp_missions.h:89
int sec
Definition: common.h:292
bool startXVI
Definition: cp_campaign.h:246
int UP_GetUnreadMails(void)
Sets the amount of unread/new mails.
#define GEO_GetMissionAircraft()
Definition: cp_geoscape.h:60
#define GEO_SetSelectedMission(mission)
Definition: cp_geoscape.h:65
void TR_InitStartup(void)
Defines commands and cvars for the Transfer menu(s).
int numCampaigns
Definition: cp_campaign.h:381
void CP_XVIInit(void)
Definition: cp_xvi.cpp:201
void CP_FreeDynamicEventMail(void)
Make sure, that the linked list is freed with every new game.
Definition: cp_event.cpp:66
void RADAR_UpdateBaseRadarCoverage_f(void)
Update radar coverage when building/destroying new radar.
Definition: cp_radar.cpp:277
QGL_EXTERN GLuint count
Definition: r_gl.h:99
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...
struct base_s * homebase
Definition: cp_aircraft.h:149
int varCosts
Definition: cp_building.h:83
void CP_TEAM_InitCallbacks(void)
Function that registers team (UI) callbacks.
void UR_Shutdown(void)
Closing actions for ufostoring-subsystem.
#define SAVE_CAMPAIGN_DATE
Definition: save_campaign.h:33
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.
Definition: cp_ufo.cpp:437
void PR_ShutdownCallbacks(void)
static bool CP_IsBudgetDue(const dateLong_t *oldDate, const dateLong_t *date)
Human readable time information in the game.
Definition: cp_time.h:34
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
Definition: save_campaign.h:32
QGL_EXTERN GLint i
Definition: r_gl.h:113
void CP_StartXVISpreading_f(void)
Start XVI spreading in campaign.
Definition: cp_xvi.cpp:276
void RS_InitCallbacks(void)
void CP_CheckCampaignEvents(campaign_t *campaign)
Definition: cp_event.cpp:112
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
Definition: save_campaign.h:46
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
void UP_Shutdown(void)
#define CVAR_DEVELOPER
Definition: cvar.h:45
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.
Definition: cp_xvi.cpp:181
void CP_GameTimeFast(void)
Increase game time speed.
Definition: cp_time.cpp:174
#define SAVE_CAMPAIGN_ID
Definition: save_campaign.h:29
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
Definition: cp_base.cpp:2633
void CP_DateConvertLong(const date_t *date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
Definition: cp_time.cpp:72
static void CP_CheckMissionEnd(const campaign_t *campaign)
Check for missions that have a timeout defined.
#define SAVE_CAMPAIGN_CAMPAIGN
Definition: save_campaign.h:27
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.
Definition: cp_nation.cpp:852
#define SECONDS_PER_DAY
Definition: common.h:301
int timesAlreadyUsed
Definition: q_shared.h:490
#define GEO_GetSelectedMission()
Definition: cp_geoscape.h:59
const int DETECTION_INTERVAL
delay between actions that must be executed independently of time scale
Definition: cp_campaign.cpp:74
missionResults_t missionResults
Definition: cp_missions.h:112
void E_InitialEmployees(const campaign_t *campaign)
Create initial hireable employees.
void CP_InitializeXVIOverlay(void)
Initialize XVI overlay on geoscape.
Definition: cp_overlay.cpp:269
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.
Definition: cp_base.cpp:1971
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
Definition: inv_shared.cpp:266
void MS_MessageInit(void)
void RS_ResetTechs(void)
This is called everytime RS_ParseTechnologies is called - to prevent cyclic hash tables.
void CL_PopupInit(void)
Initialise popups.
Definition: cp_popup.cpp:457
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
Definition: cp_campaign.cpp:66
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.
Definition: cp_hospital.cpp:82
void STATS_InitStartup(void)
#define SAVE_CAMPAIGN_PAID
Definition: save_campaign.h:31
void CP_CleanTempInventory(base_t *base)
Clears all containers that are temp containers (see script definition).
Definition: cp_team.cpp:273
#define Q_streq(a, b)
Definition: shared.h:136
bool CP_CheckCredits(int costs)
Checks whether you have enough credits for something.
#define AIR_Foreach(var)
iterates trough all aircraft
Definition: cp_aircraft.h:192
void INS_ShutdownCallbacks(void)
int RS_ResearchRun(void)
Checks the research status.
An aircraft with all it's data.
Definition: cp_aircraft.h:114
void UFO_InitStartup(void)
Init actions for ufo-subsystem.
Definition: cp_ufo.cpp:1011
Team management for the campaign gametype headers.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
campaign_t * curCampaign
Definition: cp_campaign.h:377
buildingStatus_t buildingStatus
Definition: cp_building.h:94
void TR_TransferRun(void)
Checks whether given transfer should be processed.
int negativeCreditsUntilLost
Definition: cp_campaign.h:187
#define SAVE_CAMPAIGN_GEO_OVERLAY_NATION
Definition: save_campaign.h:43
void CP_UpdateXVIMapButton(void)
This will hide or show the geoscape button for handling the xvi overlay map.
Definition: cp_xvi.cpp:298
void CP_CampaignRunMarket(campaign_t *campaign)
make number of items change every day.
Definition: cp_market.cpp:578
void B_SelectBase(const base_t *base)
Select and opens a base.
Definition: cp_base.cpp:1592
Alien interest header.
float minhappiness
Definition: cp_campaign.h:186
#define CP_IsXVIStarted()
Definition: cp_xvi.h:37
cvar_t * cp_missiontest
Definition: cp_campaign.cpp:63
Header file for menu related console command callbacks.
const char *IMPORT * Cmd_Argv(int n)
campaign_t campaigns[MAX_CAMPAIGNS]
Definition: cp_campaign.h:380
#define SAVE_CAMPAIGN_RADAROVERLAYWASSET
Definition: save_campaign.h:45
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.
Definition: cp_produce.cpp:555
const char * id
Definition: inv_shared.h:268
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.
Definition: cp_nation.cpp:714
void STATS_ShutDown(void)
void AIR_Shutdown(void)
Closing actions for aircraft-subsystem.
static uiTimer_t * timer
Definition: cl_radar.cpp:37
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.
Definition: cp_base.cpp:338
Detailed information about the nation relationship (currently per month, but could be used elsewhere)...
Definition: cp_nation.h:33
void GEO_Reset(const char *map)
void CP_CleanupAircraftTeam(aircraft_t *aircraft, equipDef_t *ed)
Reloads weapons, removes not assigned and resets defaults.
Definition: cp_team.cpp:240