27 #include "../../cl_shared.h"
64 if (item->amount <= 0)
70 cgi->LIST_Delete(&cargo);
81 employee->transfer =
false;
111 cgi->LIST_Delete(&cargo);
147 Com_sprintf(message,
sizeof(message),
_(
"Transport mission ended, unloading cargo in %s"), destination->
name);
164 if (!transData.
destBase || !srcBase) {
165 cgi->Com_Printf(
"TR_TransferStart: No base selected!\n");
171 if (srcBase !=
nullptr && transData.
destBase !=
nullptr) {
202 if (srcBase ==
nullptr)
207 count += item->amount;
209 cgi->LIST_Delete(&list);
214 if (employee->isAssigned())
215 employee->unassign();
225 employee->transfer =
true;
226 cgi->LIST_AddPointer(&transfer.
employees[i], (
void*) employee);
240 count += item->alive;
243 cgi->LIST_Delete(&list);
250 aircraft->homebase = transData.
destBase;
253 if (aircraft->pilot !=
nullptr &&
cgi->
LIST_GetPointer(transfer.
employees[aircraft->pilot->getType()], (
void*)aircraft->pilot) ==
nullptr)
261 cgi->LIST_AddPointer(&transfer.
aircraft, (
void*)aircraft);
297 if (
cgi->LIST_Remove(&transfer->aircraft, aircraft))
310 assert(transfer->destBase);
321 static void TR_ListTransfers_f (
void)
326 if (
cgi->Cmd_Argc() == 2) {
329 cgi->Com_Printf(
"Usage: %s [transferIDX]\nWithout parameter it lists all.\n",
cgi->
Cmd_Argv(0));
338 if (transIdx >= 0 && i != transIdx)
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)",
353 if (transfer->antimatter > 0)
354 cgi->Com_Printf(
"......Antimatter amount: %i\n", transfer->antimatter);
356 if (transfer->alienCargo !=
nullptr) {
357 cgi->Com_Printf(
"...ItemCargo:\n");
360 cgi->Com_Printf(
"......%s amount: %i\n", item->objDef->id, item->amount);
362 cgi->LIST_Delete(&cargo);
365 if (transfer->hasEmployees) {
368 cgi->Com_Printf(
"...Carried Employee:\n");
372 if (employee->getUGV()) {
374 cgi->Com_Printf(
"......ugv: %s [ucn: %i]\n", employee->getUGV()->id, employee->chr.ucn);
376 cgi->Com_Printf(
"......%s (%s) / %s [ucn: %i]\n", employee->chr.name,
378 (employee->getNation()) ? employee->getNation()->id :
"(nonation)",
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");
389 if (transfer->alienCargo !=
nullptr) {
390 cgi->Com_Printf(
"...AlienCargo:\n");
393 cgi->Com_Printf(
"......%s alive: %i dead: %i\n", item->teamDef->id, item->alive, item->dead);
395 cgi->LIST_Delete(&cargo);
398 if (!
cgi->LIST_IsEmpty(transfer->aircraft)) {
399 cgi->Com_Printf(
"...Transfered Aircraft:\n");
401 cgi->Com_Printf(
"......%s [idx: %i]\n", aircraft->id, aircraft->idx);
425 if (!transfer->destBase) {
426 cgi->Com_Printf(
"Could not save transfer, no destBase is set\n");
432 if (transfer->srcBase)
435 if (transfer->antimatter > 0) {
439 if (transfer->itemCargo !=
nullptr) {
443 transfer->itemCargo->save(itemNode);
446 if (transfer->alienCargo !=
nullptr) {
450 transfer->alienCargo->save(alienNode);
453 if (transfer->hasEmployees) {
494 cgi->Com_Printf(
"Error: Transfer has no destBase set\n");
510 cgi->Com_Error(
ERR_DROP,
"TR_LoadXML: Cannot create ItemCargo object\n");
529 cgi->Com_Error(
ERR_DROP,
"TR_LoadXML: Cannot create AlienCargo object\n");
541 cgi->Com_Printf(
"Error: No employee found with UCN: %i\n", ucn);
555 cgi->LIST_AddPointer(&transfer.
aircraft, (
void*)aircraft);
571 cgi->Cmd_AddCommand(
"debug_listtransfers", TR_ListTransfers_f,
"Lists an/all active transfer(s)");
581 if (transfer->itemCargo !=
nullptr) {
582 delete transfer->itemCargo;
583 transfer->itemCargo =
nullptr;
585 if (transfer->alienCargo !=
nullptr) {
586 delete transfer->alienCargo;
587 transfer->alienCargo =
nullptr;
589 cgi->LIST_Delete(&transfer->aircraft);
591 cgi->LIST_Delete(&transfer->employees[i]);
598 cgi->Cmd_RemoveCommand(
"debug_listtransfers");
#define VectorCopy(src, dest)
bool Date_IsDue(const date_t *date)
Checks whether a given date is equal or earlier than the current campaign date.
#define SAVE_TRANSFER_ITEMID
virtual bool add(const objDef_t *od, int amount, int looseAmount)
Add items to the cargo.
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
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
Header file for menu related console command callbacks.
#define SAVE_TRANSFER_TRANSFERS
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.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
#define SAVE_TRANSFER_DAY
linkedList_t * list(void) const
Returns a copy of the cargo list.
bool AIR_RemoveEmployee(Employee *employee, aircraft_t *aircraft)
Removes a soldier from an aircraft.
#define B_AtLeastOneExists()
aircraft_t * AIR_AircraftGetFromIDX(int aircraftIdx)
Returns aircraft for a given global index.
class AlienContainment * alienContainment
employeeType_t getType() const
bool load(xmlNode_t *root)
Load item cargo from xml savegame.
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.
#define SAVE_TRANSFER_SRCBASE
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
void TR_Shutdown(void)
Closing actions for transfer-subsystem.
aircraft_t * AIR_GetFirstFromBase(const base_t *b)
Iterates through the aircraft of a base.
XML tag constants for savegame.
bool E_MoveIntoNewBase(Employee *employee, base_t *newBase)
const cgame_import_t * cgi
#define SAVE_TRANSFER_AIRCRAFT
class ItemCargo * itemCargo
#define DEFAULT_TRANSFER_TIME
Default transfer time for cases with no source/dest base.
employeeType_t
The types of employees.
base_t * B_GetBaseByIDX(int baseIdx)
Array bound check for the base index. Will also return unfounded bases as long as the index is in the...
Campaign geoscape time header.
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]
Alien containment class header.
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.
baseCapacities_t
All possible capacities in base.
linkedList_t * employees[MAX_EMPL]
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)
Human readable time information in the game.
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.
void CP_DateConvertLong(const date_t *date, dateLong_t *dateLong)
Converts a date from the engine in a (longer) human-readable format.
#define SAVE_TRANSFER_AMOUNT
Employee * E_GetEmployeeFromChrUCN(int uniqueCharacterNumber)
Searches all employee for the ucn (character id)
const char * E_GetEmployeeString(employeeType_t type, int n)
Convert employeeType_t to translated string.
#define SAVE_TRANSFER_ALIENCARGO
Alien cargo class header.
Transfer information (they are being stored in ccs.transfers).
#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 ...
Header file for single player campaign control.
bool load(xmlNode_t *root)
Load alien cargo from xml savegame.
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.
#define SAVE_TRANSFER_SEC
#define SAVE_TRANSFER_ITEMCARGO
An aircraft with all it's data.
#define TR_ForeachAircraft(var, transfer)
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
#define SAVE_TRANSFER_DESTBASE
linkedList_t *IMPORT * LIST_GetPointer(linkedList_t *list, const void *data)
linkedList_t * list(void) const
Returns a copy of the cargo list.
void TR_TransferRun(void)
Checks whether given transfer should be processed.
class AlienCargo * alienCargo
void TR_NotifyAircraftRemoved(const aircraft_t *aircraft)
Notify that an aircraft has been removed.
bool TR_SaveXML(xmlNode_t *p)
Save callback for xml savegames.
const char *IMPORT * Cmd_Argv(int n)
void TR_ShutdownCallbacks(void)
#define SAVE_TRANSFER_ITEM
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
double GetDistanceOnGlobe(const vec2_t pos1, const vec2_t pos2)
Calculate distance on the geoscape.
bool B_ItemIsStoredInBaseStorage(const objDef_t *obj)
Check if an item is stored in storage.
void AIR_DeleteAircraft(aircraft_t *aircraft)
Removes an aircraft from its base and the game.
#define SAVE_TRANSFER_EMPLOYEE
#define SAVE_TRANSFER_TRANSFER
#define SAVE_TRANSFER_UCN