UFO: Alien Invasion
cp_transfer.cpp
Go to the documentation of this file.
1 
8 /*
9 Copyright (C) 2002-2022 UFO: Alien Invasion.
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 See the GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26 
27 #include "../../DateTime.h"
28 #include "../../cl_shared.h"
29 #include "cp_campaign.h"
30 #include "cp_capacity.h"
31 #include "cp_time.h"
32 #include "save/save_transfer.h"
33 #include "cp_transfer_callbacks.h"
34 #include "aliencargo.h"
35 #include "aliencontainment.h"
36 #include "itemcargo.h"
37 
46 static void TR_EmptyTransferCargo (base_t* destination, transfer_t* transfer, bool success)
47 {
48  assert(transfer);
49 
50  /* antimatter */
51  if (transfer->antimatter > 0 && success) {
52  if (B_GetBuildingStatus(destination, B_ANTIMATTER)) {
53  B_AddAntimatter(destination, transfer->antimatter);
54  } else {
55  Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("%s does not have Antimatter Storage, antimatter are removed!"), destination->name);
57  }
58  }
59 
60  /* items */
61  if (transfer->itemCargo != nullptr) {
62  if (success) {
63  linkedList_t* cargo = transfer->itemCargo->list();
64  LIST_Foreach(cargo, itemCargo_t, item) {
65  if (item->amount <= 0)
66  continue;
67  if (!B_ItemIsStoredInBaseStorage(item->objDef))
68  continue;
69  B_AddToStorage(destination, item->objDef, item->amount);
70  }
71  cgi->LIST_Delete(&cargo);
72  }
73  delete transfer->alienCargo;
74  transfer->alienCargo = nullptr;
75  }
76 
77  /* Employee */
78  if (transfer->hasEmployees && transfer->srcBase) { /* Employees. (cannot come from a mission) */
79  for (int i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
81  TR_ForeachEmployee(employee, transfer, type) {
82  employee->transfer = false;
83  if (!success) {
84  E_DeleteEmployee(employee);
85  continue;
86  }
87  switch (type) {
88  case EMPL_WORKER:
89  PR_UpdateProductionCap(destination, 0);
90  break;
91  case EMPL_PILOT:
92  AIR_AutoAddPilotToAircraft(destination, employee);
93  break;
94  default:
95  break;
96  }
97  }
98  }
99  }
100 
101  /* Aliens */
102  if (transfer->alienCargo != nullptr) {
103  if (success) {
104  if (!destination->alienContainment) {
105  Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("%s does not have Alien Containment, Aliens are removed!"), destination->name);
107  } else {
108  linkedList_t* cargo = transfer->alienCargo->list();
109  LIST_Foreach(cargo, alienCargo_t, item) {
110  destination->alienContainment->add(item->teamDef, item->alive, item->dead);
111  }
112  cgi->LIST_Delete(&cargo);
113  }
114  }
115  delete transfer->alienCargo;
116  transfer->alienCargo = nullptr;
117  }
118 
119  TR_ForeachAircraft(aircraft, transfer) {
120  if (success) {
121  VectorCopy(destination->pos, aircraft->pos);
122  aircraft->status = AIR_HOME;
123  if (!destination->aircraftCurrent)
124  destination->aircraftCurrent = aircraft;
125  } else {
126  AIR_DeleteAircraft(aircraft);
127  }
128  }
129  cgi->LIST_Delete(&transfer->aircraft);
130 }
131 
136 static void TR_TransferEnd (transfer_t* transfer)
137 {
138  base_t* destination = transfer->destBase;
139  assert(destination);
140 
141  if (!destination->founded) {
142  TR_EmptyTransferCargo(nullptr, transfer, false);
143  MSO_CheckAddNewMessage(NT_TRANSFER_LOST, _("Transport mission"), _("The destination base no longer exists! Transfer cargo was lost, personnel has been discharged."), MSG_TRANSFERFINISHED);
145  } else {
146  char message[256];
147  TR_EmptyTransferCargo(destination, transfer, true);
148  Com_sprintf(message, sizeof(message), _("Transport mission ended, unloading cargo in %s"), destination->name);
150  }
151  cgi->LIST_Remove(&ccs.transfers, transfer);
152 }
153 
160 {
161  transfer_t transfer;
162  float time;
163  int i;
164 
165  if (!transData.destBase || !srcBase) {
166  cgi->Com_Printf("TR_TransferStart: No base selected!\n");
167  return nullptr;
168  }
169 
170  /* Initialize transfer. */
171  OBJZERO(transfer);
172  if (srcBase != nullptr && transData.destBase != nullptr) {
173  /* calculate time to go from 1 base to another : 1 day for one quarter of the globe*/
174  time = GetDistanceOnGlobe(transData.destBase->pos, srcBase->pos) / 90.0f;
175  } else {
176  time = DEFAULT_TRANSFER_TIME;
177  }
178  transfer.event = DateTime(ccs.date.getDateAsDays() + floor(time), ccs.date.getTimeAsSeconds() + round(time - floor(time)) * DateTime::SECONDS_PER_DAY);
179  transfer.destBase = transData.destBase; /* Destination base. */
180  transfer.srcBase = srcBase; /* Source base. */
181 
182  int count = 0;
183  /* antimatter */
184  if (transData.antimatter > 0) {
185  transfer.antimatter = transData.antimatter;
186  B_AddAntimatter(srcBase, -transData.antimatter);
187  count += transData.antimatter;
188  }
189 
190  /* Items */
191  if (transData.itemCargo != nullptr) {
192  transfer.itemCargo = new ItemCargo(*transData.itemCargo);
193 
194  linkedList_t* list = transData.itemCargo->list();
195  LIST_Foreach(list, itemCargo_t, item) {
196  if (srcBase == nullptr)
197  continue;
198  if (!B_ItemIsStoredInBaseStorage(item->objDef))
199  continue;
200  B_AddToStorage(srcBase, item->objDef, -item->amount);
201  count += item->amount;
202  }
203  cgi->LIST_Delete(&list);
204  }
205 
206  for (i = 0; i < MAX_EMPL; i++) { /* Employees. */
207  LIST_Foreach(transData.employees[i], Employee, employee) {
208  if (employee->isAssigned())
209  employee->unassign();
210 
211  const aircraft_t *aircraft = AIR_IsEmployeeInAircraft(employee, nullptr);
212  if (aircraft && cgi->LIST_GetPointer(transData.aircraft, (const void*)aircraft) == nullptr) {
213  /* get a non-constant pointer */
214  aircraft_t* craft = AIR_AircraftGetFromIDX(aircraft->idx);
215  AIR_RemoveEmployee(employee, craft);
216  }
217 
218  E_MoveIntoNewBase(employee, transfer.destBase);
219  employee->transfer = true;
220  cgi->LIST_AddPointer(&transfer.employees[i], (void*) employee);
221  transfer.hasEmployees = true;
222  count++;
223  }
224  }
225 
226  /* Aliens. */
227  if (transData.alienCargo != nullptr) {
228  transfer.alienCargo = new AlienCargo(*transData.alienCargo);
229 
230  linkedList_t* list = transData.alienCargo->list();
231  LIST_Foreach(list, alienCargo_t, item) {
232  if (srcBase != nullptr && srcBase->alienContainment != nullptr)
233  srcBase->alienContainment->add(item->teamDef, -item->alive, -item->dead);
234  count += item->alive;
235  count += item->dead;
236  }
237  cgi->LIST_Delete(&list);
238  }
239 
240  /* Aircraft */
241  LIST_Foreach(transData.aircraft, aircraft_t, aircraft) {
242  const baseCapacities_t capacity = AIR_GetHangarCapacityType(aircraft);
243  aircraft->status = AIR_TRANSFER;
244  aircraft->homebase = transData.destBase;
245 
246  /* Remove crew if not transfered */
247  if (aircraft->pilot != nullptr && cgi->LIST_GetPointer(transfer.employees[aircraft->pilot->getType()], (void*)aircraft->pilot) == nullptr)
248  AIR_RemoveEmployee(aircraft->pilot, aircraft);
249 
250  LIST_Foreach(aircraft->acTeam, Employee, employee) {
251  if (cgi->LIST_GetPointer(transfer.employees[employee->getType()], (void*)employee) == nullptr)
252  AIR_RemoveEmployee(employee, aircraft);
253  }
254 
255  cgi->LIST_AddPointer(&transfer.aircraft, (void*)aircraft);
256 
257  if (srcBase->aircraftCurrent == aircraft)
258  srcBase->aircraftCurrent = AIR_GetFirstFromBase(srcBase);
259  CAP_AddCurrent(srcBase, capacity, -1);
260 
261  /* This should happen in TR_EmptyTransferCargo but on loading capacities are
262  calculated based on aircraft->homebase. aircraft->homebase cannot be null yet
263  there are hidden tests on that. */
264  CAP_AddCurrent(transData.destBase, capacity, 1);
265 
266  count++;
267  }
268 
269  /* don't start empty transfer */
270  if (count == 0)
271  return nullptr;
272 
273  /* Recheck if production/research can be done on srcbase (if there are workers/scientists) */
274  PR_ProductionAllowed(srcBase);
275  RS_ResearchAllowed(srcBase);
276 
277  return &LIST_Add(&ccs.transfers, transfer);
278 }
279 
285 void TR_NotifyAircraftRemoved (const aircraft_t* aircraft)
286 {
287  if (!aircraft)
288  return;
289 
290  TR_Foreach(transfer) {
291  if (cgi->LIST_Remove(&transfer->aircraft, aircraft))
292  return;
293  }
294 }
295 
300 void TR_TransferRun (void)
301 {
302  TR_Foreach(transfer) {
303  if (transfer->event <= ccs.date) {
304  assert(transfer->destBase);
305  TR_TransferEnd(transfer);
306  return;
307  }
308  }
309 }
310 
311 #ifdef DEBUG
312 
315 static void TR_ListTransfers_f (void)
316 {
317  int transIdx = -1;
318  int i = 0;
319 
320  if (cgi->Cmd_Argc() == 2) {
321  transIdx = atoi(cgi->Cmd_Argv(1));
322  if (transIdx < 0 || transIdx > cgi->LIST_Count(ccs.transfers)) {
323  cgi->Com_Printf("Usage: %s [transferIDX]\nWithout parameter it lists all.\n", cgi->Cmd_Argv(0));
324  return;
325  }
326  }
327 
328  TR_Foreach(transfer) {
329  dateLong_t date;
330  i++;
331 
332  if (transIdx >= 0 && i != transIdx)
333  continue;
334 
335  /* @todo: we need a strftime feature to make this easier */
336  CP_DateConvertLong(transfer->event, &date);
337 
338  cgi->Com_Printf("Transfer #%d\n", i);
339  cgi->Com_Printf("...From %d (%s) To %d (%s) Arrival: %04i-%02i-%02i %02i:%02i:%02i\n",
340  (transfer->srcBase) ? transfer->srcBase->idx : -1,
341  (transfer->srcBase) ? transfer->srcBase->name : "(null)",
342  (transfer->destBase) ? transfer->destBase->idx : -1,
343  (transfer->destBase) ? transfer->destBase->name : "(null)",
344  date.year, date.month, date.day, date.hour, date.min, date.sec);
345 
346  /* Antimatter */
347  if (transfer->antimatter > 0)
348  cgi->Com_Printf("......Antimatter amount: %i\n", transfer->antimatter);
349  /* ItemCargo */
350  if (transfer->alienCargo != nullptr) {
351  cgi->Com_Printf("...ItemCargo:\n");
352  linkedList_t* cargo = transfer->itemCargo->list();
353  LIST_Foreach(cargo, itemCargo_t, item) {
354  cgi->Com_Printf("......%s amount: %i\n", item->objDef->id, item->amount);
355  }
356  cgi->LIST_Delete(&cargo);
357  }
358  /* Carried Employees */
359  if (transfer->hasEmployees) {
360  int i;
361 
362  cgi->Com_Printf("...Carried Employee:\n");
363  for (i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
364  const employeeType_t emplType = (employeeType_t)i;
365  TR_ForeachEmployee(employee, transfer, emplType) {
366  if (employee->getUGV()) {
368  cgi->Com_Printf("......ugv: %s [ucn: %i]\n", employee->getUGV()->id, employee->chr.ucn);
369  } else {
370  cgi->Com_Printf("......%s (%s) / %s [ucn: %i]\n", employee->chr.name,
371  E_GetEmployeeString(employee->getType(), 1),
372  (employee->getNation()) ? employee->getNation()->id : "(nonation)",
373  employee->chr.ucn);
374  if (!employee->isHired())
375  cgi->Com_Printf("Warning: employee^ not hired!\n");
376  if (!employee->transfer)
377  cgi->Com_Printf("Warning: employee^ not marked as being transferred!\n");
378  }
379  }
380  }
381  }
382  /* AlienCargo */
383  if (transfer->alienCargo != nullptr) {
384  cgi->Com_Printf("...AlienCargo:\n");
385  linkedList_t* cargo = transfer->alienCargo->list();
386  LIST_Foreach(cargo, alienCargo_t, item) {
387  cgi->Com_Printf("......%s alive: %i dead: %i\n", item->teamDef->id, item->alive, item->dead);
388  }
389  cgi->LIST_Delete(&cargo);
390  }
391  /* Transfered Aircraft */
392  if (!cgi->LIST_IsEmpty(transfer->aircraft)) {
393  cgi->Com_Printf("...Transfered Aircraft:\n");
394  TR_ForeachAircraft(aircraft, transfer) {
395  cgi->Com_Printf("......%s [idx: %i]\n", aircraft->id, aircraft->idx);
396  }
397  }
398  }
399 }
400 #endif
401 
409 {
411 
412  TR_Foreach(transfer) {
413  int j;
414  xmlNode_t* s;
415 
417  cgi->XML_AddInt(s, SAVE_TRANSFER_DAY, transfer->event.getDateAsDays());
418  cgi->XML_AddInt(s, SAVE_TRANSFER_SEC, transfer->event.getTimeAsSeconds());
419  if (!transfer->destBase) {
420  cgi->Com_Printf("Could not save transfer, no destBase is set\n");
421  return false;
422  }
423  cgi->XML_AddInt(s, SAVE_TRANSFER_DESTBASE, transfer->destBase->idx);
424  /* scrBase can be nullptr if this is alien (mission->base) transport
425  * @sa TR_TransferAlienAfterMissionStart */
426  if (transfer->srcBase)
427  cgi->XML_AddInt(s, SAVE_TRANSFER_SRCBASE, transfer->srcBase->idx);
428  /* save antimatter */
429  if (transfer->antimatter > 0) {
430  xmlNode_t* antimatterNode = cgi->XML_AddNode(s, SAVE_TRANSFER_ANTIMATTER);
431  if (!antimatterNode)
432  return false;
433  cgi->XML_AddInt(antimatterNode, SAVE_TRANSFER_ANTIMATTER_AMOUNT, transfer->antimatter);
434  }
435  /* save items */
436  if (transfer->itemCargo != nullptr) {
438  if (!itemNode)
439  return false;
440  transfer->itemCargo->save(itemNode);
441  }
442  /* save aliens */
443  if (transfer->alienCargo != nullptr) {
445  if (!alienNode)
446  return false;
447  transfer->alienCargo->save(alienNode);
448  }
449  /* save employee */
450  if (transfer->hasEmployees) {
451  for (j = 0; j < MAX_EMPL; j++) {
452  TR_ForeachEmployee(employee, transfer, j) {
454  cgi->XML_AddInt(ss, SAVE_TRANSFER_UCN, employee->chr.ucn);
455  }
456  }
457  }
458  /* save aircraft */
459  TR_ForeachAircraft(aircraft, transfer) {
461  cgi->XML_AddInt(ss, SAVE_TRANSFER_ID, aircraft->idx);
462  }
463  }
464  return true;
465 }
466 
474 {
475  xmlNode_t* n, *s;
476 
478  if (!n)
479  return false;
480 
481  assert(B_AtLeastOneExists());
482 
484  xmlNode_t* ss;
485  transfer_t transfer;
486 
487  OBJZERO(transfer);
488 
489  transfer.destBase = B_GetBaseByIDX(cgi->XML_GetInt(s, SAVE_TRANSFER_DESTBASE, -1));
490  if (!transfer.destBase) {
491  cgi->Com_Printf("Error: Transfer has no destBase set\n");
492  return false;
493  }
494  transfer.srcBase = B_GetBaseByIDX(cgi->XML_GetInt(s, SAVE_TRANSFER_SRCBASE, -1));
495 
496  transfer.event = DateTime(cgi->XML_GetInt(s, SAVE_TRANSFER_DAY, 0), cgi->XML_GetInt(s, SAVE_TRANSFER_SEC, 0));
497 
498  /* Initializing some variables */
499  transfer.hasEmployees = false;
500 
501  /* load antimatter */
503  if (ss) {
504  const int amount = cgi->XML_GetInt(ss, SAVE_TRANSFER_ANTIMATTER_AMOUNT, 0);
505  transfer.antimatter = amount;
506  }
507  /* load items */
509  if (ss) {
510  transfer.itemCargo = new ItemCargo();
511  if (transfer.itemCargo == nullptr)
512  cgi->Com_Error(ERR_DROP, "TR_LoadXML: Cannot create ItemCargo object\n");
513  transfer.itemCargo->load(ss);
514  } else {
515  /* If there is at last one element, hasItems is true */
517  if (ss) {
518  transfer.itemCargo = new ItemCargo();
519  for (; ss; ss = cgi->XML_GetNextNode(ss, s, SAVE_TRANSFER_ITEM)) {
520  const char* itemId = cgi->XML_GetString(ss, SAVE_TRANSFER_ITEMID);
521  int amount = cgi->XML_GetInt(ss, SAVE_TRANSFER_AMOUNT, 1);
522  transfer.itemCargo->add(itemId, amount, 1);
523  }
524  }
525  }
526  /* load aliens */
528  if (ss) {
529  transfer.alienCargo = new AlienCargo();
530  if (transfer.alienCargo == nullptr)
531  cgi->Com_Error(ERR_DROP, "TR_LoadXML: Cannot create AlienCargo object\n");
532  transfer.alienCargo->load(ss);
533  }
534  /* load employee */
536  if (ss) {
537  transfer.hasEmployees = true;
538  for (; ss; ss = cgi->XML_GetNextNode(ss, s, SAVE_TRANSFER_EMPLOYEE)) {
539  const int ucn = cgi->XML_GetInt(ss, SAVE_TRANSFER_UCN, -1);
540  Employee* empl = E_GetEmployeeFromChrUCN(ucn);
541 
542  if (!empl) {
543  cgi->Com_Printf("Error: No employee found with UCN: %i\n", ucn);
544  return false;
545  }
546 
547  cgi->LIST_AddPointer(&transfer.employees[empl->getType()], (void*) empl);
548  empl->transfer = true;
549  }
550  }
551  /* load aircraft */
553  const int j = cgi->XML_GetInt(ss, SAVE_TRANSFER_ID, -1);
554  aircraft_t* aircraft = AIR_AircraftGetFromIDX(j);
555 
556  if (aircraft)
557  cgi->LIST_AddPointer(&transfer.aircraft, (void*)aircraft);
558  }
559  LIST_Add(&ccs.transfers, transfer);
560  }
561 
562  return true;
563 }
564 
569 void TR_InitStartup (void)
570 {
572 #ifdef DEBUG
573  cgi->Cmd_AddCommand("debug_listtransfers", TR_ListTransfers_f, "Lists an/all active transfer(s)");
574 #endif
575 }
576 
580 void TR_Shutdown (void)
581 {
582  TR_Foreach(transfer) {
583  if (transfer->itemCargo != nullptr) {
584  delete transfer->itemCargo;
585  transfer->itemCargo = nullptr;
586  }
587  if (transfer->alienCargo != nullptr) {
588  delete transfer->alienCargo;
589  transfer->alienCargo = nullptr;
590  }
591  cgi->LIST_Delete(&transfer->aircraft);
592  for (int i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
593  cgi->LIST_Delete(&transfer->employees[i]);
594  }
595  }
596  cgi->LIST_Delete(&ccs.transfers);
597 
599 #ifdef DEBUG
600  cgi->Cmd_RemoveCommand("debug_listtransfers");
601 #endif
602 }
Transfer information (they are being stored in ccs.transfers).
Definition: cp_transfer.h:33
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
#define VectorCopy(src, dest)
Definition: vector.h:51
linkedList_t * employees[MAX_EMPL]
Definition: cp_transfer.h:41
#define SAVE_TRANSFER_ITEMID
Definition: save_transfer.h:36
virtual bool add(const objDef_t *od, int amount, int looseAmount)
Add items to the cargo.
Definition: itemcargo.cpp:39
uiMessageListNodeMessage_t * MSO_CheckAddNewMessage(const notify_t messagecategory, const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup)
Adds a new message to message stack. It uses message settings to verify whether sound should be playe...
class ItemCargo * itemCargo
Definition: cp_transfer.h:39
class AlienCargo * alienCargo
Definition: cp_transfer.h:40
QGL_EXTERN GLint GLenum type
Definition: r_gl.h:94
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
Definition: cp_base.cpp:478
#define SAVE_TRANSFER_ANTIMATTER_AMOUNT
Definition: save_transfer.h:49
Header file for menu related console command callbacks.
#define SAVE_TRANSFER_TRANSFERS
Definition: save_transfer.h:27
byte month
Definition: cp_time.h:38
A base with all it&#39;s data.
Definition: cp_base.h:84
void CAP_AddCurrent(base_t *base, baseCapacities_t capacity, int value)
Changes the current (used) capacity on a base.
const aircraft_t * AIR_IsEmployeeInAircraft(const Employee *employee, const aircraft_t *aircraft)
Tells you if an employee is assigned to an aircraft.
short year
Definition: cp_time.h:37
linkedList_t * list(void) const
Returns a copy of the cargo list.
Definition: aliencargo.cpp:150
#define _(String)
Definition: cl_shared.h:44
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition: shared.cpp:494
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
Definition: cp_base.cpp:2576
#define SAVE_TRANSFER_DAY
Definition: save_transfer.h:31
base_t * destBase
Definition: cp_transfer.h:34
bool AIR_RemoveEmployee(Employee *employee, aircraft_t *aircraft)
Removes a soldier from an aircraft.
Class describing a point of time.
Definition: DateTime.h:30
#define B_AtLeastOneExists()
Definition: cp_base.h:55
char name[MAX_VAR]
Definition: cp_base.h:86
aircraft_t * AIR_AircraftGetFromIDX(int aircraftIdx)
Returns aircraft for a given global index.
byte day
Definition: cp_time.h:39
const char *IMPORT * Cmd_Argv(int n)
int getTimeAsSeconds() const
Return the time part of the DateTime as seconds.
Definition: DateTime.cpp:54
bool load(xmlNode_t *root)
Load item cargo from xml savegame.
Definition: itemcargo.cpp:197
Item cargo class header.
class DateTime event
Definition: cp_transfer.h:36
static const int SECONDS_PER_DAY
Definition: DateTime.h:43
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
bool TR_LoadXML(xmlNode_t *p)
Load callback for xml savegames.
base_t * srcBase
Definition: cp_transfer.h:35
#define SAVE_TRANSFER_SRCBASE
Definition: save_transfer.h:30
#define xmlNode_t
Definition: xml.h:24
bool E_DeleteEmployee(Employee *employee)
Removes the employee completely from the game (buildings + global list).
void AIR_AutoAddPilotToAircraft(const base_t *base, Employee *pilot)
Adds the pilot to the first available aircraft at the specified base.
void TR_Shutdown(void)
Closing actions for transfer-subsystem.
#define ERR_DROP
Definition: common.h:211
byte sec
Definition: cp_time.h:42
aircraft_t * aircraftCurrent
Definition: cp_base.h:100
#define TR_Foreach(var)
Definition: cp_transfer.h:48
#define OBJZERO(obj)
Definition: shared.h:178
employeeType_t getType() const
Definition: cp_employee.h:99
linkedList_t * aircraft
Definition: cp_transfer.h:42
aircraft_t * AIR_GetFirstFromBase(const base_t *b)
Iterates through the aircraft of a base.
Definition: cp_aircraft.cpp:51
Item cargo class.
Definition: itemcargo.h:41
#define SAVE_TRANSFER_ANTIMATTER
Definition: save_transfer.h:48
XML tag constants for savegame.
int getDateAsDays() const
Return the date part of the DateTime as days.
Definition: DateTime.cpp:46
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
Human readable time information in the game.
Definition: cp_time.h:36
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
const cgame_import_t * cgi
#define SAVE_TRANSFER_AIRCRAFT
Definition: save_transfer.h:45
#define DEFAULT_TRANSFER_TIME
Default transfer time for cases with no source/dest base.
Definition: cp_transfer.h:30
employeeType_t
The types of employees.
Definition: cp_employee.h:30
ccs_t ccs
Definition: cp_campaign.cpp:63
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:313
Campaign geoscape time header.
linkedList_t * transfers
Definition: cp_campaign.h:308
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
Alien cargo class.
Definition: aliencargo.h:41
bool RS_ResearchAllowed(const base_t *base)
Returns true if the current base is able to handle research.
void TR_InitStartup(void)
Defines commands and cvars for the Transfer menu(s).
char cp_messageBuffer[MAX_MESSAGE_TEXT]
Definition: cp_messages.cpp:33
Alien containment class header.
QGL_EXTERN GLuint count
Definition: r_gl.h:99
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
alien cargo entry
Definition: aliencargo.h:32
linkedList_t *IMPORT * LIST_GetPointer(linkedList_t *list, const void *data)
byte min
Definition: cp_time.h:41
bool PR_ProductionAllowed(const base_t *base)
Returns true if the current base is able to produce items.
Definition: cp_produce.cpp:596
baseCapacities_t
All possible capacities in base.
Definition: cp_capacity.h:27
An aircraft with all it&#39;s data.
Definition: cp_aircraft.h:115
transfer_t * TR_TransferStart(base_t *srcBase, transfer_t &transData)
Starts a transfer.
static void TR_TransferEnd(transfer_t *transfer)
Ends the transfer.
#define TR_ForeachEmployee(var, transfer, employeeType)
Definition: cp_transfer.h:49
QGL_EXTERN GLint i
Definition: r_gl.h:113
item cargo entry
Definition: itemcargo.h:32
void TR_InitCallbacks(void)
class DateTime date
Definition: cp_campaign.h:246
virtual bool add(const teamDef_t *team, int alive, int dead)
Add aliens to the containment by teamDef.
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
Definition: cp_base.cpp:2635
#define SAVE_TRANSFER_AMOUNT
Definition: save_transfer.h:37
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id)
int antimatter
Definition: cp_transfer.h:38
const char * E_GetEmployeeString(employeeType_t type, int n)
Convert employeeType_t to translated string.
#define SAVE_TRANSFER_ID
Definition: save_transfer.h:46
#define SAVE_TRANSFER_ALIENCARGO
Definition: save_transfer.h:39
Alien cargo class header.
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it&#39;s safe to delete the returned entry from the list while looping over ...
Definition: list.h:41
Header file for single player campaign control.
bool load(xmlNode_t *root)
Load alien cargo from xml savegame.
Definition: aliencargo.cpp:167
static void TR_EmptyTransferCargo(base_t *destination, transfer_t *transfer, bool success)
Unloads transfer cargo when finishing the transfer or destroys it when no buildings/base.
Definition: cp_transfer.cpp:46
#define SAVE_TRANSFER_SEC
Definition: save_transfer.h:32
bool hasEmployees
Definition: cp_transfer.h:45
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
bool founded
Definition: cp_base.h:90
#define SAVE_TRANSFER_ITEMCARGO
Definition: save_transfer.h:40
void CP_DateConvertLong(const DateTime &date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
Definition: cp_time.cpp:73
#define TR_ForeachAircraft(var, transfer)
Definition: cp_transfer.h:50
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
Definition: cp_produce.cpp:607
class AlienContainment * alienContainment
Definition: cp_base.h:108
vec3_t pos
Definition: cp_base.h:91
#define SAVE_TRANSFER_DESTBASE
Definition: save_transfer.h:29
void TR_TransferRun(void)
Checks whether given transfer should be processed.
void TR_NotifyAircraftRemoved(const aircraft_t *aircraft)
Notify that an aircraft has been removed.
linkedList_t * list(void) const
Returns a copy of the cargo list.
Definition: itemcargo.cpp:156
bool TR_SaveXML(xmlNode_t *p)
Save callback for xml savegames.
byte hour
Definition: cp_time.h:40
void TR_ShutdownCallbacks(void)
#define SAVE_TRANSFER_ITEM
Definition: save_transfer.h:35
bool transfer
Definition: cp_employee.h:118
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
Definition: mathlib.cpp:171
bool B_ItemIsStoredInBaseStorage(const objDef_t *obj)
Check if an item is stored in storage.
Definition: cp_base.cpp:2560
void AIR_DeleteAircraft(aircraft_t *aircraft)
Removes an aircraft from its base and the game.
#define SAVE_TRANSFER_EMPLOYEE
Definition: save_transfer.h:42
#define SAVE_TRANSFER_TRANSFER
Definition: save_transfer.h:28
#define SAVE_TRANSFER_UCN
Definition: save_transfer.h:43