UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_transfer.cpp
Go to the documentation of this file.
1 
8 /*
9 Copyright (C) 2002-2020 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 "../../cl_shared.h"
28 #include "cp_campaign.h"
29 #include "cp_capacity.h"
30 #include "cp_time.h"
31 #include "save/save_transfer.h"
32 #include "cp_transfer_callbacks.h"
33 #include "aliencargo.h"
34 #include "aliencontainment.h"
35 #include "itemcargo.h"
36 
45 static void TR_EmptyTransferCargo (base_t* destination, transfer_t* transfer, bool success)
46 {
47  assert(transfer);
48 
49  /* antimatter */
50  if (transfer->antimatter > 0 && success) {
51  if (B_GetBuildingStatus(destination, B_ANTIMATTER)) {
52  B_AddAntimatter(destination, transfer->antimatter);
53  } else {
54  Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("%s does not have Antimatter Storage, antimatter are removed!"), destination->name);
56  }
57  }
58 
59  /* items */
60  if (transfer->itemCargo != nullptr) {
61  if (success) {
62  linkedList_t* cargo = transfer->itemCargo->list();
63  LIST_Foreach(cargo, itemCargo_t, item) {
64  if (item->amount <= 0)
65  continue;
66  if (!B_ItemIsStoredInBaseStorage(item->objDef))
67  continue;
68  B_AddToStorage(destination, item->objDef, item->amount);
69  }
70  cgi->LIST_Delete(&cargo);
71  }
72  delete transfer->alienCargo;
73  transfer->alienCargo = nullptr;
74  }
75 
76  /* Employee */
77  if (transfer->hasEmployees && transfer->srcBase) { /* Employees. (cannot come from a mission) */
78  for (int i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
80  TR_ForeachEmployee(employee, transfer, type) {
81  employee->transfer = false;
82  if (!success) {
83  E_DeleteEmployee(employee);
84  continue;
85  }
86  switch (type) {
87  case EMPL_WORKER:
88  PR_UpdateProductionCap(destination, 0);
89  break;
90  case EMPL_PILOT:
91  AIR_AutoAddPilotToAircraft(destination, employee);
92  break;
93  default:
94  break;
95  }
96  }
97  }
98  }
99 
100  /* Aliens */
101  if (transfer->alienCargo != nullptr) {
102  if (success) {
103  if (!destination->alienContainment) {
104  Com_sprintf(cp_messageBuffer, sizeof(cp_messageBuffer), _("%s does not have Alien Containment, Aliens are removed!"), destination->name);
106  } else {
107  linkedList_t* cargo = transfer->alienCargo->list();
108  LIST_Foreach(cargo, alienCargo_t, item) {
109  destination->alienContainment->add(item->teamDef, item->alive, item->dead);
110  }
111  cgi->LIST_Delete(&cargo);
112  }
113  }
114  delete transfer->alienCargo;
115  transfer->alienCargo = nullptr;
116  }
117 
118  TR_ForeachAircraft(aircraft, transfer) {
119  if (success) {
120  VectorCopy(destination->pos, aircraft->pos);
121  aircraft->status = AIR_HOME;
122  if (!destination->aircraftCurrent)
123  destination->aircraftCurrent = aircraft;
124  } else {
125  AIR_DeleteAircraft(aircraft);
126  }
127  }
128  cgi->LIST_Delete(&transfer->aircraft);
129 }
130 
135 static void TR_TransferEnd (transfer_t* transfer)
136 {
137  base_t* destination = transfer->destBase;
138  assert(destination);
139 
140  if (!destination->founded) {
141  TR_EmptyTransferCargo(nullptr, transfer, false);
142  MSO_CheckAddNewMessage(NT_TRANSFER_LOST, _("Transport mission"), _("The destination base no longer exists! Transfer cargo was lost, personnel has been discharged."), MSG_TRANSFERFINISHED);
144  } else {
145  char message[256];
146  TR_EmptyTransferCargo(destination, transfer, true);
147  Com_sprintf(message, sizeof(message), _("Transport mission ended, unloading cargo in %s"), destination->name);
149  }
150  cgi->LIST_Remove(&ccs.transfers, transfer);
151 }
152 
159 {
160  transfer_t transfer;
161  float time;
162  int i;
163 
164  if (!transData.destBase || !srcBase) {
165  cgi->Com_Printf("TR_TransferStart: No base selected!\n");
166  return nullptr;
167  }
168 
169  /* Initialize transfer. */
170  OBJZERO(transfer);
171  if (srcBase != nullptr && transData.destBase != nullptr) {
172  /* calculate time to go from 1 base to another : 1 day for one quarter of the globe*/
173  time = GetDistanceOnGlobe(transData.destBase->pos, srcBase->pos) / 90.0f;
174  } else {
175  time = DEFAULT_TRANSFER_TIME;
176  }
177  transfer.event.day = ccs.date.day + floor(time); /* add day */
178  time = (time - floor(time)) * SECONDS_PER_DAY; /* convert remaining time in second */
179  transfer.event.sec = ccs.date.sec + round(time);
180  /* check if event is not the following day */
181  if (transfer.event.sec > SECONDS_PER_DAY) {
182  transfer.event.sec -= SECONDS_PER_DAY;
183  transfer.event.day++;
184  }
185  transfer.destBase = transData.destBase; /* Destination base. */
186  transfer.srcBase = srcBase; /* Source base. */
187 
188  int count = 0;
189  /* antimatter */
190  if (transData.antimatter > 0) {
191  transfer.antimatter = transData.antimatter;
192  B_AddAntimatter(srcBase, -transData.antimatter);
193  count += transData.antimatter;
194  }
195 
196  /* Items */
197  if (transData.itemCargo != nullptr) {
198  transfer.itemCargo = new ItemCargo(*transData.itemCargo);
199 
200  linkedList_t* list = transData.itemCargo->list();
201  LIST_Foreach(list, itemCargo_t, item) {
202  if (srcBase == nullptr)
203  continue;
204  if (!B_ItemIsStoredInBaseStorage(item->objDef))
205  continue;
206  B_AddToStorage(srcBase, item->objDef, -item->amount);
207  count += item->amount;
208  }
209  cgi->LIST_Delete(&list);
210  }
211 
212  for (i = 0; i < MAX_EMPL; i++) { /* Employees. */
213  LIST_Foreach(transData.employees[i], Employee, employee) {
214  if (employee->isAssigned())
215  employee->unassign();
216 
217  const aircraft_t *aircraft = AIR_IsEmployeeInAircraft(employee, nullptr);
218  if (aircraft && cgi->LIST_GetPointer(transData.aircraft, (const void*)aircraft) == nullptr) {
219  /* get a non-constant pointer */
220  aircraft_t* craft = AIR_AircraftGetFromIDX(aircraft->idx);
221  AIR_RemoveEmployee(employee, craft);
222  }
223 
224  E_MoveIntoNewBase(employee, transfer.destBase);
225  employee->transfer = true;
226  cgi->LIST_AddPointer(&transfer.employees[i], (void*) employee);
227  transfer.hasEmployees = true;
228  count++;
229  }
230  }
231 
232  /* Aliens. */
233  if (transData.alienCargo != nullptr) {
234  transfer.alienCargo = new AlienCargo(*transData.alienCargo);
235 
236  linkedList_t* list = transData.alienCargo->list();
237  LIST_Foreach(list, alienCargo_t, item) {
238  if (srcBase != nullptr && srcBase->alienContainment != nullptr)
239  srcBase->alienContainment->add(item->teamDef, -item->alive, -item->dead);
240  count += item->alive;
241  count += item->dead;
242  }
243  cgi->LIST_Delete(&list);
244  }
245 
246  /* Aircraft */
247  LIST_Foreach(transData.aircraft, aircraft_t, aircraft) {
248  const baseCapacities_t capacity = AIR_GetHangarCapacityType(aircraft);
249  aircraft->status = AIR_TRANSFER;
250  aircraft->homebase = transData.destBase;
251 
252  /* Remove crew if not transfered */
253  if (aircraft->pilot != nullptr && cgi->LIST_GetPointer(transfer.employees[aircraft->pilot->getType()], (void*)aircraft->pilot) == nullptr)
254  AIR_RemoveEmployee(aircraft->pilot, aircraft);
255 
256  LIST_Foreach(aircraft->acTeam, Employee, employee) {
257  if (cgi->LIST_GetPointer(transfer.employees[employee->getType()], (void*)employee) == nullptr)
258  AIR_RemoveEmployee(employee, aircraft);
259  }
260 
261  cgi->LIST_AddPointer(&transfer.aircraft, (void*)aircraft);
262 
263  if (srcBase->aircraftCurrent == aircraft)
264  srcBase->aircraftCurrent = AIR_GetFirstFromBase(srcBase);
265  CAP_AddCurrent(srcBase, capacity, -1);
266 
267  /* This should happen in TR_EmptyTransferCargo but on loading capacities are
268  calculated based on aircraft->homebase. aircraft->homebase cannot be null yet
269  there are hidden tests on that. */
270  CAP_AddCurrent(transData.destBase, capacity, 1);
271 
272  count++;
273  }
274 
275  /* don't start empty transfer */
276  if (count == 0)
277  return nullptr;
278 
279  /* Recheck if production/research can be done on srcbase (if there are workers/scientists) */
280  PR_ProductionAllowed(srcBase);
281  RS_ResearchAllowed(srcBase);
282 
283  return &LIST_Add(&ccs.transfers, transfer);
284 }
285 
291 void TR_NotifyAircraftRemoved (const aircraft_t* aircraft)
292 {
293  if (!aircraft)
294  return;
295 
296  TR_Foreach(transfer) {
297  if (cgi->LIST_Remove(&transfer->aircraft, aircraft))
298  return;
299  }
300 }
301 
306 void TR_TransferRun (void)
307 {
308  TR_Foreach(transfer) {
309  if (Date_IsDue(&transfer->event)) {
310  assert(transfer->destBase);
311  TR_TransferEnd(transfer);
312  return;
313  }
314  }
315 }
316 
317 #ifdef DEBUG
318 
321 static void TR_ListTransfers_f (void)
322 {
323  int transIdx = -1;
324  int i = 0;
325 
326  if (cgi->Cmd_Argc() == 2) {
327  transIdx = atoi(cgi->Cmd_Argv(1));
328  if (transIdx < 0 || transIdx > cgi->LIST_Count(ccs.transfers)) {
329  cgi->Com_Printf("Usage: %s [transferIDX]\nWithout parameter it lists all.\n", cgi->Cmd_Argv(0));
330  return;
331  }
332  }
333 
334  TR_Foreach(transfer) {
335  dateLong_t date;
336  i++;
337 
338  if (transIdx >= 0 && i != transIdx)
339  continue;
340 
341  /* @todo: we need a strftime feature to make this easier */
342  CP_DateConvertLong(&transfer->event, &date);
343 
344  cgi->Com_Printf("Transfer #%d\n", i);
345  cgi->Com_Printf("...From %d (%s) To %d (%s) Arrival: %04i-%02i-%02i %02i:%02i:%02i\n",
346  (transfer->srcBase) ? transfer->srcBase->idx : -1,
347  (transfer->srcBase) ? transfer->srcBase->name : "(null)",
348  (transfer->destBase) ? transfer->destBase->idx : -1,
349  (transfer->destBase) ? transfer->destBase->name : "(null)",
350  date.year, date.month, date.day, date.hour, date.min, date.sec);
351 
352  /* Antimatter */
353  if (transfer->antimatter > 0)
354  cgi->Com_Printf("......Antimatter amount: %i\n", transfer->antimatter);
355  /* ItemCargo */
356  if (transfer->alienCargo != nullptr) {
357  cgi->Com_Printf("...ItemCargo:\n");
358  linkedList_t* cargo = transfer->itemCargo->list();
359  LIST_Foreach(cargo, itemCargo_t, item) {
360  cgi->Com_Printf("......%s amount: %i\n", item->objDef->id, item->amount);
361  }
362  cgi->LIST_Delete(&cargo);
363  }
364  /* Carried Employees */
365  if (transfer->hasEmployees) {
366  int i;
367 
368  cgi->Com_Printf("...Carried Employee:\n");
369  for (i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
370  const employeeType_t emplType = (employeeType_t)i;
371  TR_ForeachEmployee(employee, transfer, emplType) {
372  if (employee->getUGV()) {
374  cgi->Com_Printf("......ugv: %s [ucn: %i]\n", employee->getUGV()->id, employee->chr.ucn);
375  } else {
376  cgi->Com_Printf("......%s (%s) / %s [ucn: %i]\n", employee->chr.name,
377  E_GetEmployeeString(employee->getType(), 1),
378  (employee->getNation()) ? employee->getNation()->id : "(nonation)",
379  employee->chr.ucn);
380  if (!employee->isHired())
381  cgi->Com_Printf("Warning: employee^ not hired!\n");
382  if (!employee->transfer)
383  cgi->Com_Printf("Warning: employee^ not marked as being transferred!\n");
384  }
385  }
386  }
387  }
388  /* AlienCargo */
389  if (transfer->alienCargo != nullptr) {
390  cgi->Com_Printf("...AlienCargo:\n");
391  linkedList_t* cargo = transfer->alienCargo->list();
392  LIST_Foreach(cargo, alienCargo_t, item) {
393  cgi->Com_Printf("......%s alive: %i dead: %i\n", item->teamDef->id, item->alive, item->dead);
394  }
395  cgi->LIST_Delete(&cargo);
396  }
397  /* Transfered Aircraft */
398  if (!cgi->LIST_IsEmpty(transfer->aircraft)) {
399  cgi->Com_Printf("...Transfered Aircraft:\n");
400  TR_ForeachAircraft(aircraft, transfer) {
401  cgi->Com_Printf("......%s [idx: %i]\n", aircraft->id, aircraft->idx);
402  }
403  }
404  }
405 }
406 #endif
407 
415 {
417 
418  TR_Foreach(transfer) {
419  int j;
420  xmlNode_t* s;
421 
423  cgi->XML_AddInt(s, SAVE_TRANSFER_DAY, transfer->event.day);
424  cgi->XML_AddInt(s, SAVE_TRANSFER_SEC, transfer->event.sec);
425  if (!transfer->destBase) {
426  cgi->Com_Printf("Could not save transfer, no destBase is set\n");
427  return false;
428  }
429  cgi->XML_AddInt(s, SAVE_TRANSFER_DESTBASE, transfer->destBase->idx);
430  /* scrBase can be nullptr if this is alien (mission->base) transport
431  * @sa TR_TransferAlienAfterMissionStart */
432  if (transfer->srcBase)
433  cgi->XML_AddInt(s, SAVE_TRANSFER_SRCBASE, transfer->srcBase->idx);
434  /* save antimatter */
435  if (transfer->antimatter > 0) {
436 
437  }
438  /* save items */
439  if (transfer->itemCargo != nullptr) {
441  if (!itemNode)
442  return false;
443  transfer->itemCargo->save(itemNode);
444  }
445  /* save aliens */
446  if (transfer->alienCargo != nullptr) {
448  if (!alienNode)
449  return false;
450  transfer->alienCargo->save(alienNode);
451  }
452  /* save employee */
453  if (transfer->hasEmployees) {
454  for (j = 0; j < MAX_EMPL; j++) {
455  TR_ForeachEmployee(employee, transfer, j) {
457  cgi->XML_AddInt(ss, SAVE_TRANSFER_UCN, employee->chr.ucn);
458  }
459  }
460  }
461  /* save aircraft */
462  TR_ForeachAircraft(aircraft, transfer) {
464  cgi->XML_AddInt(ss, SAVE_TRANSFER_ID, aircraft->idx);
465  }
466  }
467  return true;
468 }
469 
477 {
478  xmlNode_t* n, *s;
479 
481  if (!n)
482  return false;
483 
484  assert(B_AtLeastOneExists());
485 
487  xmlNode_t* ss;
488  transfer_t transfer;
489 
490  OBJZERO(transfer);
491 
492  transfer.destBase = B_GetBaseByIDX(cgi->XML_GetInt(s, SAVE_TRANSFER_DESTBASE, -1));
493  if (!transfer.destBase) {
494  cgi->Com_Printf("Error: Transfer has no destBase set\n");
495  return false;
496  }
497  transfer.srcBase = B_GetBaseByIDX(cgi->XML_GetInt(s, SAVE_TRANSFER_SRCBASE, -1));
498 
499  transfer.event.day = cgi->XML_GetInt(s, SAVE_TRANSFER_DAY, 0);
500  transfer.event.sec = cgi->XML_GetInt(s, SAVE_TRANSFER_SEC, 0);
501 
502  /* Initializing some variables */
503  transfer.hasEmployees = false;
504 
505  /* load items */
507  if (ss) {
508  transfer.itemCargo = new ItemCargo();
509  if (transfer.itemCargo == nullptr)
510  cgi->Com_Error(ERR_DROP, "TR_LoadXML: Cannot create ItemCargo object\n");
511  transfer.itemCargo->load(ss);
512  } else {
513  /* If there is at last one element, hasItems is true */
515  if (ss) {
516  transfer.itemCargo = new ItemCargo();
517  for (; ss; ss = cgi->XML_GetNextNode(ss, s, SAVE_TRANSFER_ITEM)) {
518  const char* itemId = cgi->XML_GetString(ss, SAVE_TRANSFER_ITEMID);
519  int amount = cgi->XML_GetInt(ss, SAVE_TRANSFER_AMOUNT, 1);
520  transfer.itemCargo->add(itemId, amount, 1);
521  }
522  }
523  }
524  /* load aliens */
526  if (ss) {
527  transfer.alienCargo = new AlienCargo();
528  if (transfer.alienCargo == nullptr)
529  cgi->Com_Error(ERR_DROP, "TR_LoadXML: Cannot create AlienCargo object\n");
530  transfer.alienCargo->load(ss);
531  }
532  /* load employee */
534  if (ss) {
535  transfer.hasEmployees = true;
536  for (; ss; ss = cgi->XML_GetNextNode(ss, s, SAVE_TRANSFER_EMPLOYEE)) {
537  const int ucn = cgi->XML_GetInt(ss, SAVE_TRANSFER_UCN, -1);
538  Employee* empl = E_GetEmployeeFromChrUCN(ucn);
539 
540  if (!empl) {
541  cgi->Com_Printf("Error: No employee found with UCN: %i\n", ucn);
542  return false;
543  }
544 
545  cgi->LIST_AddPointer(&transfer.employees[empl->getType()], (void*) empl);
546  empl->transfer = true;
547  }
548  }
549  /* load aircraft */
551  const int j = cgi->XML_GetInt(ss, SAVE_TRANSFER_ID, -1);
552  aircraft_t* aircraft = AIR_AircraftGetFromIDX(j);
553 
554  if (aircraft)
555  cgi->LIST_AddPointer(&transfer.aircraft, (void*)aircraft);
556  }
557  LIST_Add(&ccs.transfers, transfer);
558  }
559 
560  return true;
561 }
562 
567 void TR_InitStartup (void)
568 {
570 #ifdef DEBUG
571  cgi->Cmd_AddCommand("debug_listtransfers", TR_ListTransfers_f, "Lists an/all active transfer(s)");
572 #endif
573 }
574 
578 void TR_Shutdown (void)
579 {
580  TR_Foreach(transfer) {
581  if (transfer->itemCargo != nullptr) {
582  delete transfer->itemCargo;
583  transfer->itemCargo = nullptr;
584  }
585  if (transfer->alienCargo != nullptr) {
586  delete transfer->alienCargo;
587  transfer->alienCargo = nullptr;
588  }
589  cgi->LIST_Delete(&transfer->aircraft);
590  for (int i = EMPL_SOLDIER; i < MAX_EMPL; i++) {
591  cgi->LIST_Delete(&transfer->employees[i]);
592  }
593  }
594  cgi->LIST_Delete(&ccs.transfers);
595 
597 #ifdef DEBUG
598  cgi->Cmd_RemoveCommand("debug_listtransfers");
599 #endif
600 }
byte hour
Definition: cp_time.h:38
#define VectorCopy(src, dest)
Definition: vector.h:51
bool Date_IsDue(const date_t *date)
Checks whether a given date is equal or earlier than the current campaign date.
Definition: cp_time.cpp:255
#define SAVE_TRANSFER_ITEMID
Definition: save_transfer.h:36
bool hasEmployees
Definition: cp_transfer.h:43
virtual bool add(const objDef_t *od, int amount, int looseAmount)
Add items to the cargo.
Definition: itemcargo.cpp:39
byte min
Definition: cp_time.h: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...
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:477
Header file for menu related console command callbacks.
#define SAVE_TRANSFER_TRANSFERS
Definition: save_transfer.h:27
int antimatter
Definition: cp_transfer.h:36
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.
#define _(String)
Definition: cl_shared.h:43
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:2574
#define SAVE_TRANSFER_DAY
Definition: save_transfer.h:31
char name[MAX_VAR]
Definition: cp_base.h:86
bool founded
Definition: cp_base.h:90
linkedList_t * list(void) const
Returns a copy of the cargo list.
Definition: aliencargo.cpp:150
bool AIR_RemoveEmployee(Employee *employee, aircraft_t *aircraft)
Removes a soldier from an aircraft.
int day
Definition: common.h:291
date_t date
Definition: cp_campaign.h:245
linkedList_t * transfers
Definition: cp_campaign.h:307
#define B_AtLeastOneExists()
Definition: cp_base.h:55
aircraft_t * AIR_AircraftGetFromIDX(int aircraftIdx)
Returns aircraft for a given global index.
class AlienContainment * alienContainment
Definition: cp_base.h:108
employeeType_t getType() const
Definition: cp_employee.h:99
byte day
Definition: cp_time.h:37
bool load(xmlNode_t *root)
Load item cargo from xml savegame.
Definition: itemcargo.cpp:197
Item cargo class header.
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.
A base with all it's data.
Definition: cp_base.h:84
#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.
aircraft_t * aircraftCurrent
Definition: cp_base.h:100
void TR_Shutdown(void)
Closing actions for transfer-subsystem.
#define ERR_DROP
Definition: common.h:211
alien cargo entry
Definition: aliencargo.h:32
#define TR_Foreach(var)
Definition: cp_transfer.h:46
#define OBJZERO(obj)
Definition: shared.h:178
base_t * srcBase
Definition: cp_transfer.h:33
aircraft_t * AIR_GetFirstFromBase(const base_t *b)
Iterates through the aircraft of a base.
Definition: cp_aircraft.cpp:50
Item cargo class.
Definition: itemcargo.h:41
XML tag constants for savegame.
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
const cgame_import_t * cgi
short year
Definition: cp_time.h:35
#define SAVE_TRANSFER_AIRCRAFT
Definition: save_transfer.h:45
class ItemCargo * itemCargo
Definition: cp_transfer.h:37
#define DEFAULT_TRANSFER_TIME
Default transfer time for cases with no source/dest base.
Definition: cp_transfer.h:28
employeeType_t
The types of employees.
Definition: cp_employee.h:30
ccs_t ccs
Definition: cp_campaign.cpp:62
date_t event
Definition: cp_transfer.h:34
byte month
Definition: cp_time.h:36
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.
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.
int sec
Definition: common.h:292
void TR_InitStartup(void)
Defines commands and cvars for the Transfer menu(s).
char cp_messageBuffer[MAX_MESSAGE_TEXT]
Definition: cp_messages.cpp:31
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)
bool PR_ProductionAllowed(const base_t *base)
Returns true if the current base is able to produce items.
Definition: cp_produce.cpp:595
baseCapacities_t
All possible capacities in base.
Definition: cp_capacity.h:27
linkedList_t * employees[MAX_EMPL]
Definition: cp_transfer.h:39
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:47
Human readable time information in the game.
Definition: cp_time.h:34
byte sec
Definition: cp_time.h:40
QGL_EXTERN GLint i
Definition: r_gl.h:113
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
void TR_InitCallbacks(void)
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: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
#define SAVE_TRANSFER_AMOUNT
Definition: save_transfer.h:37
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id)
base_t * destBase
Definition: cp_transfer.h:32
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
#define SECONDS_PER_DAY
Definition: common.h:301
Alien cargo class header.
Transfer information (they are being stored in ccs.transfers).
Definition: cp_transfer.h:31
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it'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
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
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:45
#define SAVE_TRANSFER_SEC
Definition: save_transfer.h:32
#define SAVE_TRANSFER_ITEMCARGO
Definition: save_transfer.h:40
vec3_t pos
Definition: cp_base.h:91
An aircraft with all it's data.
Definition: cp_aircraft.h:114
#define TR_ForeachAircraft(var, transfer)
Definition: cp_transfer.h:48
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
Definition: cp_produce.cpp:606
#define SAVE_TRANSFER_DESTBASE
Definition: save_transfer.h:29
linkedList_t *IMPORT * LIST_GetPointer(linkedList_t *list, const void *data)
linkedList_t * list(void) const
Returns a copy of the cargo list.
Definition: itemcargo.cpp:156
void TR_TransferRun(void)
Checks whether given transfer should be processed.
class AlienCargo * alienCargo
Definition: cp_transfer.h:38
void TR_NotifyAircraftRemoved(const aircraft_t *aircraft)
Notify that an aircraft has been removed.
linkedList_t * aircraft
Definition: cp_transfer.h:40
bool TR_SaveXML(xmlNode_t *p)
Save callback for xml savegames.
const char *IMPORT * Cmd_Argv(int n)
item cargo entry
Definition: itemcargo.h:32
void TR_ShutdownCallbacks(void)
#define SAVE_TRANSFER_ITEM
Definition: save_transfer.h:35
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
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:2558
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