25 #include "../../cl_shared.h"
94 cgi->Com_Printf(
"TR_TransferStart_f: currentTransferType is wrong!\n");
102 Com_sprintf(message,
sizeof(message),
_(
"Transport mission started, cargo is being transported to %s"), tr.
destBase->
name);
104 cgi->UI_PopWindow(
false);
127 cgi->UI_ExecuteConfunc(
"ui_cargolist_clear");
132 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"%s\" \"%s\" %d", od->
id,
_(od->
name), tr.
antimatter);
139 if (item->amount > 0)
140 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"%s\" \"%s\" %d", item->objDef->id,
_(item->objDef->name), item->amount);
142 cgi->LIST_Delete(&cargo);
154 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"ucn_%d\" \"%s %s %s\" %d", employee->chr.ucn,
157 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"ucn_%d\" \"%s %s\" %d", employee->chr.ucn,
167 int emplCount =
cgi->LIST_Count(tr.
employees[emplType]);
170 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"%s\" \"%s\" %d", (emplType ==
EMPL_SCIENTIST) ?
"scientist" :
"worker",
175 cgi->Com_Error(
ERR_DROP,
"TR_CargoList: Invalid employeetype in cargo");
184 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"dead_%s\" \"%s\" %d", item->teamDef->id,
va(
_(
"Corpse of %s"),
_(item->teamDef->name)), item->dead);
186 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"alive_%s\" \"%s\" %d", item->teamDef->id,
va(
_(
"Alive %s"),
_(item->teamDef->name)), item->alive);
188 cgi->LIST_Delete(&cargo);
193 cgi->UI_ExecuteConfunc(
"ui_cargolist_add \"aircraft_%d\" \"%s\" %d", aircraft->idx,
va(
_(
"Aircraft %s"), aircraft->name), 1);
227 if (antiMatterInCargo || antiMatterInSrcBase) {
228 cgi->UI_ExecuteConfunc(
"ui_translist_add \"%s\" \"%s\" %d %d %d %d %d", od->
id,
_(od->
name),
229 antiMatterInSrcBase - antiMatterInCargo, antiMatterInDstBase, 0, antiMatterInCargo, antiMatterInSrcBase);
240 if (itemCargoAmount || itemInSrcBase > 0) {
241 cgi->UI_ExecuteConfunc(
"ui_translist_add \"%s\" \"%s\" %d %d %d %d %d", od->
id,
_(od->
name),
242 itemInSrcBase - itemCargoAmount, itemInDstBase, 0, itemCargoAmount, itemInSrcBase);
262 if (!employee->isHiredInBase(srcBase))
276 cgi->UI_ExecuteConfunc(
"ui_translist_add \"ucn_%d\" \"%s\" %d %d %d %d %d", employee->chr.ucn,
277 str, -1, -1, -1, -1, -1);
288 const int trCount =
cgi->LIST_Count(tr.
employees[emplType]);
293 cgi->UI_ExecuteConfunc(
"ui_translist_add \"%s\" \"%s\" %d %d %d %d %d",
295 hiredSrc - trCount, hiredDst, 0, trCount, hiredSrc);
299 cgi->Com_Error(
ERR_DROP,
"TR_CargoList: Invalid employeetype in cargo");
316 const int srcDead = item->dead;
317 const int srcAlive = item->alive;
323 if (srcDead > 0 || transferDead > 0) {
325 Com_sprintf(str,
sizeof(str),
_(
"Corpse of %s"),
_(item->teamDef->name));
326 cgi->UI_ExecuteConfunc(
"ui_translist_add \"dead_%s\" \"%s\" %d %d %d %d %d",
327 item->teamDef->id, str, srcDead - transferDead, dstDead, 0, transferDead, srcDead);
329 if (srcAlive > 0 || transferAlive > 0) {
331 Com_sprintf(str,
sizeof(str),
_(
"Alive %s"),
_(item->teamDef->name));
332 cgi->UI_ExecuteConfunc(
"ui_translist_add \"alive_%s\" \"%s\" %d %d %d %d %d",
333 item->teamDef->id, str, srcAlive - transferAlive, dstAlive, 0, transferAlive, srcAlive);
336 cgi->LIST_Delete(&list);
354 cgi->UI_ExecuteConfunc(
"ui_translist_add \"aircraft_%d\" \"%s\" %d %d %d %d %d",
355 aircraft->idx, aircraft->name, -1, -1, -1, -1, -1);
369 if (srcBase ==
nullptr || destBase ==
nullptr)
372 currentTransferType = transferType;
374 cgi->UI_ExecuteConfunc(
"ui_translist_clear");
375 switch (transferType) {
389 cgi->Com_Error(
ERR_DROP,
"invalid transfertype given: %i", transferType);
405 if (
cgi->Cmd_Argc() < 2)
406 type = currentTransferType;
421 if (
cgi->Cmd_Argc() < 3) {
439 cgi->LIST_AddPointer(&tr.
aircraft, (
void*)aircraft);
443 cgi->Cmd_ExecuteString(
"ui_trans_add ucn_%d 1", aircraft->
pilot->
chr.
ucn);
447 cgi->Cmd_ExecuteString(
"ui_trans_add ucn_%d 1", employee->chr.ucn);
449 }
else if (amount < 0) {
455 cgi->Cmd_ExecuteString(
"ui_trans_add ucn_%d -1", aircraft->
pilot->
chr.
ucn);
459 cgi->Cmd_ExecuteString(
"ui_trans_add ucn_%d -1", employee->chr.ucn);
481 const Item item = *ic;
486 cgi->Cmd_ExecuteString(
"ui_trans_add %s 1", od->
id);
490 cgi->Cmd_ExecuteString(
"ui_trans_add %s 1", ammo->
id);
495 }
else if (amount < 0) {
501 while ((cont = employee->chr.inv.getNextCont(cont,
true))) {
504 const Item item = *ic;
509 cgi->Cmd_ExecuteString(
"ui_trans_add %s -1", od->
id);
513 cgi->Cmd_ExecuteString(
"ui_trans_add %s -1", ammo->
id);
519 }
else if (
Q_streq(itemId,
"scientist")) {
524 if (!employee->isHiredInBase(base))
532 }
else if (amount < 0) {
538 }
else if (
Q_streq(itemId,
"worker")) {
543 if (!employee->isHiredInBase(base))
551 }
else if (amount < 0) {
561 cgi->Com_Error(
ERR_DROP,
"TR_Add_f: Cannot create AlienCargo object\n");
569 amount = std::min(amount, store - cargo);
571 amount = std::max(amount, -cargo);
580 cgi->Com_Error(
ERR_DROP,
"TR_Add_f: Cannot create AlienCargo object\n");
588 amount = std::min(amount, store - cargo);
590 amount = std::max(amount, -cargo);
601 amount = std::min(amount, store - cargo);
603 amount = std::max(amount, -cargo);
619 amount = std::min(amount, store - cargo);
621 amount = std::max(amount, -cargo);
662 if (!destbase || !srcbase)
668 cgi->Cvar_SetValue(
"mn_trans_base_id", destbase->
idx);
671 TR_Fill(srcbase, destbase, currentTransferType);
687 while ((base =
B_GetNext(base)) !=
nullptr) {
688 if (base == currentBase)
706 if (
cgi->Cmd_Argc() < 2) {
736 cgi->Com_Error(
ERR_DROP,
"No bases! Transfer needs at least two...");
770 cgi->UI_ExecuteConfunc(
"tr_listclear");
772 const char* source = transfer->srcBase ? transfer->srcBase->name :
"mission";
778 if (transfer->antimatter) {
779 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo",
"antimatter",
_(
"Antimatter"));
781 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo.antimatter", od->
id,
va(
"%i %s", transfer->antimatter,
_(od->
name)));
784 if (transfer->itemCargo !=
nullptr) {
785 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo",
"items",
_(
"Items"));
788 if (item->amount <= 0)
790 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo.items", item->objDef->id,
va(
"%i %s", item->amount,
_(item->objDef->name)));
792 cgi->LIST_Delete(&cargo);
795 if (transfer->hasEmployees) {
797 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo",
"employee",
_(
"Employee"));
801 if (employee->getUGV()) {
804 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo.employee",
va(
"ucn_%i", employee->chr.ucn),
va(
"%s %s",
E_GetEmployeeString(employee->getType(), 1), employee->chr.name));
810 if (transfer->alienCargo !=
nullptr) {
811 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo",
"aliens",
_(
"Aliens"));
815 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo.aliens",
va(
"%s_alive", item->teamDef->id),
va(
"%i %s %s", item->alive,
_(
"alive"),
_(item->teamDef->name)));
817 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo.aliens",
va(
"%s_dead", item->teamDef->id),
va(
"%i %s %s", item->dead,
_(
"dead"),
_(item->teamDef->name)));
819 cgi->LIST_Delete(&cargo);
822 if (!
cgi->LIST_IsEmpty(transfer->aircraft)) {
823 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo",
"aircraft",
_(
"Aircraft"));
826 cgi->UI_ExecuteConfunc(
"tr_listaddcargo %d \"%s\" \"%s\" \"%s\"", i,
"tr_cargo.aircraft",
va(
"craft%i", aircraft->idx), aircraft->name);
862 if (
cgi->Cmd_Argc() < 2) {
863 cgi->Com_Printf(
"Usage: %s <destinationBaseIdx>\n",
cgi->
Cmd_Argv(0));
869 cgi->Com_Printf(
"Invalid destinationBaseIdx: %s\n",
cgi->
Cmd_Argv(1));
878 if (transfer->destBase != base)
883 currentCap[
CAP_ITEMS] += transfer->itemCargo ? transfer->itemCargo->size() : 0;
886 currentCap[
CAP_ALIENS] += (transfer->alienCargo) ? transfer->alienCargo->getAlive() : 0;
902 cgi->UI_ExecuteConfunc(
"ui_t_capacities_clear");
915 currentCap[capType] += cap.
cur;
916 if (cap.
max <= 0 && currentCap[capType] <= 0)
919 cgi->UI_ExecuteConfunc(
"ui_t_capacities_add \"%s\" \"%s\" %d %d", building->
id,
_(building->
name), currentCap[capType], cap.
max);
924 {
"trans_list",
TR_List_f,
"Assembles the transferlist"},
925 {
"trans_init",
TR_Init_f,
"Init function for Transfer menu"},
929 {
"trans_selectbase",
TR_SelectBase_f,
"Callback for selecting a base"},
931 {
"ui_trans_fill",
TR_Fill_f,
"Fill itemlists for transfer"},
932 {
"ui_trans_add",
TR_Add_f,
"Add/Remove items to transfercargo"},
933 {
nullptr,
nullptr,
nullptr}
937 cgi->Cmd_TableAddList(transferCallbacks);
944 cgi->Cmd_TableRemoveList(transferCallbacks);
static void TR_Init_f(void)
Transfer menu init function.
static void TR_CargoList(void)
Display cargo list.
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.
bool AIR_IsAircraftInBase(const aircraft_t *aircraft)
Checks whether given aircraft is in its homebase.
virtual bool add(const objDef_t *od, int amount, int looseAmount)
Add items to the cargo.
A building with all it's data.
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...
virtual bool add(const teamDef_t *team, int alive, int dead)
Add aliens to the cargo by teamDef.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
QGL_EXTERN GLint GLenum type
Describes a rank that a recruit can gain.
Header file for menu related console command callbacks.
static void TR_Add_f(void)
Callback handles adding/removing items to transfercargo.
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...
#define E_Foreach(employeeType, var)
static void TR_List_f(void)
Assembles the list of transfers for the popup.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
struct technology_s * tech
static void TR_FillItems(const base_t *srcBase, const base_t *destBase)
Add items to the transfer storages list.
#define CAP_Get(base, capacity)
Capacity macros.
linkedList_t * list(void) const
Returns a copy of the cargo list.
base_t * B_GetCurrentSelectedBase(void)
returns the currently selected base
int Date_DateToSeconds(const date_t *date)
Convert a date_t date to seconds.
const objDef_t * def(void) const
aircraft_t * AIR_AircraftGetFromIDX(int aircraftIdx)
Returns aircraft for a given global index.
class AlienContainment * alienContainment
static bool TR_AircraftListSelect(const aircraft_t *aircraft)
Check if an aircraft should be displayed for transfer.
Header file for Transfer stuff.
static const cmdList_t transferCallbacks[]
employeeType_t getType() const
bool isReloadable() const
rank_t * CL_GetRankByIdx(const int index)
Returns a rank at an index.
static transferType_t TR_GetTransferType(const char *id)
Returns the transfer type.
Defines all attributes of objects used in the inventory.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
int E_CountHired(const base_t *const base, employeeType_t type)
Counts hired employees of a given type in a given base.
static void TR_Fill(const base_t *srcBase, const base_t *destBase, transferType_t transferType)
Fills the items-in-base list with stuff available for transfer.
A base with all it's data.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
static void TR_InitBaseList(void)
Fills the optionlist with available bases to transfer to.
item instance data, with linked list capability
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
static void TR_FillAliens(const base_t *srcBase, const base_t *destBase)
Add aliens to the transfer storages list.
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
int size(void) const
Calculate size of all items in the cargo.
transferType_t
transfer types
static void TR_CountAircraftInList(linkedList_t *aircraftList, int capacity[])
Count capacity need of aircraft in lists.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
const cgame_import_t * cgi
static void TR_CountEmployeeInListArray(linkedList_t *employeeListArray[], int capacity[])
Count capacity need of employee in array of lists.
class ItemCargo * itemCargo
employeeType_t
The types of employees.
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
static void TR_Fill_f(void)
Callback for filling list with stuff available for transfer.
Engine-side time information in the game.
date_t Date_Substract(date_t a, const date_t &b)
Substract the second date from the first and return the result.
Campaign geoscape time header.
static void TR_FillEmployees(const base_t *srcBase, const base_t *destBase)
Add employees to the transfer storages list.
Item * getNextItem(const Item *prev) const
Atomic structure used to define most of the UI.
Alien containment class header.
static void TR_TransferStart_f(void)
Starts the transfer.
static transferType_t currentTransferType
#define AIR_ForeachFromBase(var, base)
iterates trough all aircraft from a specific homebase
int getDead(const teamDef_t *team) const
Return number of dead alien bodies of a type in the cargo.
baseCapacities_t
All possible capacities in base.
AlienCargo(void)
Creates and initializes AlienCargo object.
linkedList_t * employees[MAX_EMPL]
transfer_t * TR_TransferStart(base_t *srcBase, transfer_t &transData)
Starts a transfer.
int B_AntimatterInBase(const base_t *base)
returns the amount of antimatter stored in a base
#define TR_ForeachEmployee(var, transfer, employeeType)
const Container * getNextCont(const Container *prev, bool inclTemp=false) const
void TR_InitCallbacks(void)
CASSERT(lengthof(transferTypeIDs)==TRANS_TYPE_MAX)
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.
static void TR_TransferListClear_f(void)
Unload everything from transfer cargo back to base.
static char const *const transferTypeIDs[]
transfer typeID strings
Alien cargo class header.
Transfer information (they are being stored in ccs.transfers).
const objDef_t * ammoDef(void) const
#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 ...
building_t buildingTemplates[MAX_BUILDINGS]
Header file for single player campaign control.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const teamDef_t *IMPORT * Com_GetTeamDefinitionByID(const char *team)
int getAlive(const teamDef_t *team) const
Return number of alive aliens of a type in the cargo.
static void TR_DestinationCapacityList_f(void)
Callback for assemble destination base capacity list.
static void TR_ClearTempCargo(void)
Clear temporary cargo arrays.
static void TR_TransferClose_f(void)
Closes Transfer Menu and resets temp arrays.
Store capacities in base.
buildingType_t buildingType
An aircraft with all it's data.
#define TR_ForeachAircraft(var, transfer)
const char uiNode_t *IMPORT * UI_AddOption(uiNode_t **tree, const char *name, const char *label, const char *value)
linkedList_t *IMPORT * LIST_GetPointer(linkedList_t *list, const void *data)
linkedList_t * list(void) const
Returns a copy of the cargo list.
static void TR_SelectBase_f(void)
Callback to select destination base.
#define ANTIMATTER_ITEM_ID
class AlienCargo * alienCargo
baseCapacities_t B_GetCapacityFromBuildingType(buildingType_t type)
Get the capacity associated to a building type.
const char *IMPORT * Cmd_Argv(int n)
const char * CP_SecondConvert(int second)
Converts a number of second into a char to display.
void TR_ShutdownCallbacks(void)
static void TR_TransferBaseSelect(base_t *srcbase, base_t *destbase)
Callback for base list click.
static void TR_FillAircraft(const base_t *srcBase, const base_t *destBase)
Add aircraft to the transfer storages list.
bool isHiredInBase(const base_t *const base) const
Checks whether the given employee is in the given base.
int getAmount(const objDef_t *od) const
Returns amount of an item in the cargo.
bool B_ItemIsStoredInBaseStorage(const objDef_t *obj)
Check if an item is stored in storage.