UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_transfer.cpp
Go to the documentation of this file.
1
7
8/*
9Copyright (C) 2002-2025 UFO: Alien Invasion.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, 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"
34#include "aliencargo.h"
35#include "aliencontainment.h"
36#include "itemcargo.h"
37
46static 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
136static 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 {
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
286{
287 if (!aircraft)
288 return;
289
290 TR_Foreach(transfer) {
291 if (cgi->LIST_Remove(&transfer->aircraft, aircraft))
292 return;
293 }
294}
295
300void 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
315static 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{
410 xmlNode_t* n = cgi->XML_AddNode(p, SAVE_TRANSFER_TRANSFERS);
411
412 TR_Foreach(transfer) {
413 int j;
414 xmlNode_t* s;
415
416 s = cgi->XML_AddNode(n, SAVE_TRANSFER_TRANSFER);
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) {
437 xmlNode_t* itemNode = cgi->XML_AddNode(s, SAVE_TRANSFER_ITEMCARGO);
438 if (!itemNode)
439 return false;
440 transfer->itemCargo->save(itemNode);
441 }
442 /* save aliens */
443 if (transfer->alienCargo != nullptr) {
444 xmlNode_t* alienNode = cgi->XML_AddNode(s, SAVE_TRANSFER_ALIENCARGO);
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) {
453 xmlNode_t* ss = cgi->XML_AddNode(s, SAVE_TRANSFER_EMPLOYEE);
454 cgi->XML_AddInt(ss, SAVE_TRANSFER_UCN, employee->chr.ucn);
455 }
456 }
457 }
458 /* save aircraft */
459 TR_ForeachAircraft(aircraft, transfer) {
460 xmlNode_t* ss = cgi->XML_AddNode(s, SAVE_TRANSFER_AIRCRAFT);
461 cgi->XML_AddInt(ss, SAVE_TRANSFER_ID, aircraft->idx);
462 }
463 }
464 return true;
465}
466
474{
475 xmlNode_t* n, *s;
476
477 n = cgi->XML_GetNode(p, SAVE_TRANSFER_TRANSFERS);
478 if (!n)
479 return false;
480
481 assert(B_AtLeastOneExists());
482
483 for (s = cgi->XML_GetNode(n, SAVE_TRANSFER_TRANSFER); s; s = cgi->XML_GetNextNode(s, n, SAVE_TRANSFER_TRANSFER)) {
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 */
502 ss = cgi->XML_GetNode(s, SAVE_TRANSFER_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 */
508 ss = cgi->XML_GetNode(s, SAVE_TRANSFER_ITEMCARGO);
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 */
516 ss = cgi->XML_GetNode(s, SAVE_TRANSFER_ITEM);
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 */
527 ss = cgi->XML_GetNode(s, SAVE_TRANSFER_ALIENCARGO);
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 */
535 ss = cgi->XML_GetNode(s, SAVE_TRANSFER_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);
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 */
552 for (ss = cgi->XML_GetNode(s, SAVE_TRANSFER_AIRCRAFT); ss; ss = cgi->XML_GetNextNode(ss, s, SAVE_TRANSFER_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
569void 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
580void 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}
DateTime class definition.
Alien cargo class header.
Alien containment class header.
CGAME_HARD_LINKED_FUNCTIONS linkedList_t * LIST_Add(linkedList_t **listDest, void const *data, size_t length)
Share stuff between the different cgame implementations.
#define _(String)
Definition cl_shared.h:44
Alien cargo class.
Definition aliencargo.h:41
linkedList_t * list(void) const
Returns a copy of the cargo list.
bool load(xmlNode_t *root)
Load alien cargo from xml savegame.
virtual bool add(const teamDef_t *team, int alive, int dead)
Add aliens to the containment by teamDef.
Class describing a point of time.
Definition DateTime.h:31
static const int SECONDS_PER_DAY
Definition DateTime.h:43
employeeType_t getType() const
Definition cp_employee.h:99
bool transfer
Item cargo class.
Definition itemcargo.h:41
bool load(xmlNode_t *root)
Load item cargo from xml savegame.
linkedList_t * list(void) const
Returns a copy of the cargo list.
virtual bool add(const objDef_t *od, int amount, int looseAmount)
Add items to the cargo.
Definition itemcargo.cpp:39
#define ERR_DROP
Definition common.h:211
void AIR_DeleteAircraft(aircraft_t *aircraft)
Removes an aircraft from its base and the game.
bool AIR_RemoveEmployee(Employee *employee, aircraft_t *aircraft)
Removes a soldier from an aircraft.
void AIR_AutoAddPilotToAircraft(const base_t *base, Employee *pilot)
Adds the pilot to the first available aircraft at the specified base.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
aircraft_t * AIR_GetFirstFromBase(const base_t *b)
Iterates through the aircraft of a base.
const aircraft_t * AIR_IsEmployeeInAircraft(const Employee *employee, const aircraft_t *aircraft)
Tells you if an employee is assigned to an aircraft.
aircraft_t * AIR_AircraftGetFromIDX(int aircraftIdx)
Returns aircraft for a given global index.
@ AIR_HOME
@ AIR_TRANSFER
bool B_ItemIsStoredInBaseStorage(const objDef_t *obj)
Check if an item is stored in storage.
Definition cp_base.cpp:2560
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
Definition cp_base.cpp:2635
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
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
Definition cp_base.cpp:2576
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
Definition cp_base.cpp:478
bool PR_ProductionAllowed(const base_t *base)
Returns true if the current base is able to produce items.
#define B_AtLeastOneExists()
Definition cp_base.h:55
bool RS_ResearchAllowed(const base_t *base)
Returns true if the current base is able to handle research.
@ B_ANTIMATTER
Definition cp_building.h:63
ccs_t ccs
Header file for single player campaign control.
const cgame_import_t * cgi
void CAP_AddCurrent(base_t *base, baseCapacities_t capacity, int value)
Changes the current (used) capacity on a base.
baseCapacities_t
All possible capacities in base.
Definition cp_capacity.h:27
bool E_DeleteEmployee(Employee *employee)
Removes the employee completely from the game (buildings + global list).
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id).
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
const char * E_GetEmployeeString(employeeType_t type, int n)
Convert employeeType_t to translated string.
employeeType_t
The types of employees.
Definition cp_employee.h:30
@ EMPL_SOLDIER
Definition cp_employee.h:31
@ MAX_EMPL
Definition cp_employee.h:36
@ EMPL_PILOT
Definition cp_employee.h:34
@ EMPL_WORKER
Definition cp_employee.h:33
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...
@ NT_TRANSFER_LOST
@ NT_TRANSFER_COMPLETED_SUCCESS
char cp_messageBuffer[MAX_MESSAGE_TEXT]
@ MSG_TRANSFERFINISHED
Definition cp_messages.h:44
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
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
Campaign geoscape time header.
static void TR_TransferEnd(transfer_t *transfer)
Ends the transfer.
bool TR_SaveXML(xmlNode_t *p)
Save callback for xml savegames.
void TR_InitStartup(void)
Defines commands and cvars for the Transfer menu(s).
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.
transfer_t * TR_TransferStart(base_t *srcBase, transfer_t &transData)
Starts a transfer.
bool TR_LoadXML(xmlNode_t *p)
Load callback for xml savegames.
void TR_TransferRun(void)
Checks whether given transfer should be processed.
void TR_Shutdown(void)
Closing actions for transfer-subsystem.
void TR_NotifyAircraftRemoved(const aircraft_t *aircraft)
Notify that an aircraft has been removed.
#define TR_ForeachEmployee(var, transfer, employeeType)
Definition cp_transfer.h:49
#define DEFAULT_TRANSFER_TIME
Default transfer time for cases with no source/dest base.
Definition cp_transfer.h:30
#define TR_Foreach(var)
Definition cp_transfer.h:48
#define TR_ForeachAircraft(var, transfer)
Definition cp_transfer.h:50
void TR_InitCallbacks(void)
void TR_ShutdownCallbacks(void)
Header file for menu related console command callbacks.
Item cargo class header.
#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
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
Definition mathlib.cpp:171
QGL_EXTERN GLuint count
Definition r_gl.h:99
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
XML tag constants for savegame.
#define SAVE_TRANSFER_ITEMCARGO
#define SAVE_TRANSFER_AIRCRAFT
#define SAVE_TRANSFER_TRANSFERS
#define SAVE_TRANSFER_DESTBASE
#define SAVE_TRANSFER_SEC
#define SAVE_TRANSFER_SRCBASE
#define SAVE_TRANSFER_ITEMID
#define SAVE_TRANSFER_ID
#define SAVE_TRANSFER_ANTIMATTER
#define SAVE_TRANSFER_TRANSFER
#define SAVE_TRANSFER_ITEM
#define SAVE_TRANSFER_EMPLOYEE
#define SAVE_TRANSFER_AMOUNT
#define SAVE_TRANSFER_ANTIMATTER_AMOUNT
#define SAVE_TRANSFER_UCN
#define SAVE_TRANSFER_ALIENCARGO
#define SAVE_TRANSFER_DAY
#define OBJZERO(obj)
Definition shared.h:178
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
Definition shared.cpp:494
An aircraft with all it's data.
alien cargo entry
Definition aliencargo.h:32
A base with all it's data.
Definition cp_base.h:84
aircraft_t * aircraftCurrent
Definition cp_base.h:100
class AlienContainment * alienContainment
Definition cp_base.h:108
bool founded
Definition cp_base.h:90
char name[MAX_VAR]
Definition cp_base.h:86
vec3_t pos
Definition cp_base.h:91
Human readable time information in the game.
Definition cp_time.h:36
byte hour
Definition cp_time.h:40
byte month
Definition cp_time.h:38
byte day
Definition cp_time.h:39
byte min
Definition cp_time.h:41
short year
Definition cp_time.h:37
byte sec
Definition cp_time.h:42
item cargo entry
Definition itemcargo.h:32
Transfer information (they are being stored in ccs.transfers).
Definition cp_transfer.h:33
base_t * destBase
Definition cp_transfer.h:34
linkedList_t * aircraft
Definition cp_transfer.h:42
class AlienCargo * alienCargo
Definition cp_transfer.h:40
class ItemCargo * itemCargo
Definition cp_transfer.h:39
linkedList_t * employees[MAX_EMPL]
Definition cp_transfer.h:41
bool hasEmployees
Definition cp_transfer.h:45
base_t * srcBase
Definition cp_transfer.h:35
class DateTime event
Definition cp_transfer.h:36
#define VectorCopy(src, dest)
Definition vector.h:51
#define xmlNode_t
Definition xml.h:24