UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_transfer_callbacks.cpp File Reference
#include "cp_transfer_callbacks.h"
#include "../../DateTime.h"
#include "../../cl_shared.h"
#include "cp_campaign.h"
#include "cp_capacity.h"
#include "cp_transfer.h"
#include "cp_popup.h"
#include "cp_time.h"
#include "aliencargo.h"
#include "aliencontainment.h"
#include "itemcargo.h"
Include dependency graph for cp_transfer_callbacks.cpp:

Go to the source code of this file.

Enumerations

enum  transferType_t {
  TRANS_TYPE_INVALID = -1 , TRANS_TYPE_ITEM , TRANS_TYPE_EMPLOYEE , TRANS_TYPE_ALIEN ,
  TRANS_TYPE_AIRCRAFT , TRANS_TYPE_MAX
}
 transfer types More...

Functions

 CASSERT (lengthof(transferTypeIDs)==TRANS_TYPE_MAX)
static void TR_ClearTempCargo (void)
 Clear temporary cargo arrays.
static void TR_TransferStart_f (void)
 Starts the transfer.
static transferType_t TR_GetTransferType (const char *id)
 Returns the transfer type.
static void TR_CargoList (void)
 Display cargo list.
static bool TR_AircraftListSelect (const aircraft_t *aircraft)
 Check if an aircraft should be displayed for transfer.
static void TR_FillItems (const base_t *srcBase, const base_t *destBase)
 Add items to the transfer storages list.
static void TR_FillEmployees (const base_t *srcBase, const base_t *destBase)
 Add employees to the transfer storages list.
static void TR_FillAliens (const base_t *srcBase, const base_t *destBase)
 Add aliens to the transfer storages list.
static void TR_FillAircraft (const base_t *srcBase, const base_t *destBase)
 Add aircraft to the transfer storages list.
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.
static void TR_Fill_f (void)
 Callback for filling list with stuff available for transfer.
static void TR_Add_f (void)
 Callback handles adding/removing items to transfercargo.
static void TR_TransferListClear_f (void)
 Unload everything from transfer cargo back to base.
static void TR_TransferBaseSelect (base_t *srcbase, base_t *destbase)
 Callback for base list click.
static void TR_InitBaseList (void)
 Fills the optionlist with available bases to transfer to.
static void TR_SelectBase_f (void)
 Callback to select destination base.
static void TR_Init_f (void)
 Transfer menu init function.
static void TR_TransferClose_f (void)
 Closes Transfer Menu and resets temp arrays.
static void TR_List_f (void)
 Assembles the list of transfers for the popup.
static void TR_CountEmployeeInListArray (linkedList_t *employeeListArray[], int capacity[])
 Count capacity need of employee in array of lists.
static void TR_CountAircraftInList (linkedList_t *aircraftList, int capacity[])
 Count capacity need of aircraft in lists.
static void TR_DestinationCapacityList_f (void)
 Callback for assemble destination base capacity list.
void TR_InitCallbacks (void)
void TR_ShutdownCallbacks (void)

Variables

static char const *const transferTypeIDs []
 transfer typeID strings
static transfer_t tr
static transferType_t currentTransferType
static const cmdList_t transferCallbacks []

Enumeration Type Documentation

◆ transferType_t

transfer types

Enumerator
TRANS_TYPE_INVALID 
TRANS_TYPE_ITEM 
TRANS_TYPE_EMPLOYEE 
TRANS_TYPE_ALIEN 
TRANS_TYPE_AIRCRAFT 
TRANS_TYPE_MAX 

Definition at line 39 of file cp_transfer_callbacks.cpp.

Function Documentation

◆ CASSERT()

◆ TR_Add_f()

◆ TR_AircraftListSelect()

bool TR_AircraftListSelect ( const aircraft_t * aircraft)
static

Check if an aircraft should be displayed for transfer.

Parameters
[in]aircraftPointer to an aircraft
Returns
true if the aircraft should be displayed, false else.

Definition at line 203 of file cp_transfer_callbacks.cpp.

References AIR_IsAircraftInBase(), cgi, and tr.

Referenced by TR_Add_f().

◆ TR_CargoList()

◆ TR_ClearTempCargo()

void TR_ClearTempCargo ( void )
static

Clear temporary cargo arrays.

Definition at line 68 of file cp_transfer_callbacks.cpp.

References cgi, EMPL_SOLDIER, i, MAX_EMPL, and tr.

Referenced by TR_Init_f(), TR_ShutdownCallbacks(), TR_TransferClose_f(), TR_TransferListClear_f(), and TR_TransferStart_f().

◆ TR_CountAircraftInList()

void TR_CountAircraftInList ( linkedList_t * aircraftList,
int capacity[] )
static

Count capacity need of aircraft in lists.

Parameters
[in]aircraftListList to count aircraft in
[in,out]capacityCapacity need array to update

Definition at line 849 of file cp_transfer_callbacks.cpp.

References AIR_GetHangarCapacityType(), and LIST_Foreach.

Referenced by TR_DestinationCapacityList_f().

◆ TR_CountEmployeeInListArray()

void TR_CountEmployeeInListArray ( linkedList_t * employeeListArray[],
int capacity[] )
static

Count capacity need of employee in array of lists.

Parameters
[in]employeeListArrayArray to count employee in
[in,out]capacityCapacity need array to update

Definition at line 837 of file cp_transfer_callbacks.cpp.

References CAP_EMPLOYEES, cgi, EMPL_ROBOT, EMPL_SOLDIER, and i.

Referenced by TR_DestinationCapacityList_f().

◆ TR_DestinationCapacityList_f()

◆ TR_Fill()

void TR_Fill ( const base_t * srcBase,
const base_t * destBase,
transferType_t transferType )
static

Fills the items-in-base list with stuff available for transfer.

Note
Filling the transfer list with proper stuff (items/employees/aliens/aircraft) is being done here.
Parameters
[in]srcBasePointer to the base the transfer starts from
[in]destBasePointer to the base to transfer
[in]transferTypeTransfer category
See also
transferType_t

Definition at line 368 of file cp_transfer_callbacks.cpp.

References cgi, currentTransferType, ERR_DROP, TR_CargoList(), TR_FillAircraft(), TR_FillAliens(), TR_FillEmployees(), TR_FillItems(), TRANS_TYPE_AIRCRAFT, TRANS_TYPE_ALIEN, TRANS_TYPE_EMPLOYEE, and TRANS_TYPE_ITEM.

Referenced by TR_Add_f(), TR_Fill_f(), TR_TransferBaseSelect(), and TR_TransferListClear_f().

◆ TR_Fill_f()

void TR_Fill_f ( void )
static

Callback for filling list with stuff available for transfer.

Definition at line 399 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), cgi, currentTransferType, tr, TR_Fill(), TR_GetTransferType(), TRANS_TYPE_INVALID, and type.

◆ TR_FillAircraft()

void TR_FillAircraft ( const base_t * srcBase,
const base_t * destBase )
static

Add aircraft to the transfer storages list.

Parameters
[in]srcBaseSource base of the transfer
[in]destBaseDestination base of the transfer

Definition at line 345 of file cp_transfer_callbacks.cpp.

References AIR_ForeachFromBase, AIR_IsAircraftInBase(), cgi, and tr.

Referenced by TR_Fill().

◆ TR_FillAliens()

void TR_FillAliens ( const base_t * srcBase,
const base_t * destBase )
static

Add aliens to the transfer storages list.

Parameters
[in]srcBaseSource base of the transfer
[in]destBaseDestination base of the transfer

Definition at line 310 of file cp_transfer_callbacks.cpp.

References _, base_t::alienContainment, cgi, Com_sprintf(), AlienCargo::getAlive(), AlienCargo::getDead(), AlienCargo::list(), LIST_Foreach, and tr.

Referenced by TR_Fill().

◆ TR_FillEmployees()

void TR_FillEmployees ( const base_t * srcBase,
const base_t * destBase )
static

Add employees to the transfer storages list.

Parameters
[in]srcBaseSource base of the transfer
[in]destBaseDestination base of the transfer
Todo
implement UGV transfers

Definition at line 253 of file cp_transfer_callbacks.cpp.

References _, cgi, CL_GetRankByIdx(), Com_sprintf(), E_CountHired(), E_Foreach, E_GetEmployeeString(), EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, ERR_DROP, i, MAX_EMPL, rank_t::shortname, and tr.

Referenced by TR_Fill().

◆ TR_FillItems()

void TR_FillItems ( const base_t * srcBase,
const base_t * destBase )
static

Add items to the transfer storages list.

Parameters
[in]srcBaseSource base of the transfer
[in]destBaseDestination base of the transfer

Definition at line 218 of file cp_transfer_callbacks.cpp.

References _, ANTIMATTER_ITEM_ID, B_AntimatterInBase(), B_ItemInBase(), B_ItemIsStoredInBaseStorage(), cgi, i, objDef_t::id, INVSH_GetItemByID(), INVSH_GetItemByIDX(), objDef_t::name, and tr.

Referenced by TR_Fill().

◆ TR_GetTransferType()

transferType_t TR_GetTransferType ( const char * id)
static

Returns the transfer type.

Parameters
[in]idTransfer type Id
See also
transferType_t

Definition at line 113 of file cp_transfer_callbacks.cpp.

References i, Q_streq, TRANS_TYPE_INVALID, TRANS_TYPE_MAX, and transferTypeIDs.

Referenced by TR_Fill_f().

◆ TR_Init_f()

void TR_Init_f ( void )
static

Transfer menu init function.

Note
Command to call this: trans_init
Should be called whenever the Transfer menu gets active.

Definition at line 723 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), B_GetNext(), cgi, ERR_DROP, tr, TR_ClearTempCargo(), TR_InitBaseList(), TR_TransferBaseSelect(), and transferTypeIDs.

◆ TR_InitBaseList()

void TR_InitBaseList ( void )
static

Fills the optionlist with available bases to transfer to.

Definition at line 682 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), B_GetNext(), cgi, base_t::idx, base_t::name, OPTION_BASELIST, and va().

Referenced by TR_Init_f().

◆ TR_InitCallbacks()

void TR_InitCallbacks ( void )

Definition at line 935 of file cp_transfer_callbacks.cpp.

References cgi, and transferCallbacks.

Referenced by TR_InitStartup().

◆ TR_List_f()

void TR_List_f ( void )
static

Assembles the list of transfers for the popup.

Todo
: add ugv listing when they're implemented

Definition at line 767 of file cp_transfer_callbacks.cpp.

References _, ANTIMATTER_ITEM_ID, ccs, cgi, CP_SecondConvert(), Date_DateToSeconds(), E_GetEmployeeString(), EMPL_SOLDIER, i, objDef_t::id, INVSH_GetItemByID(), LIST_Count(), LIST_Foreach, MAX_EMPL, objDef_t::name, ngettext, TR_Foreach, TR_ForeachAircraft, TR_ForeachEmployee, and va().

◆ TR_SelectBase_f()

void TR_SelectBase_f ( void )
static

Callback to select destination base.

Definition at line 701 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), B_GetFoundedBaseByIDX(), cgi, and TR_TransferBaseSelect().

◆ TR_ShutdownCallbacks()

void TR_ShutdownCallbacks ( void )

Definition at line 940 of file cp_transfer_callbacks.cpp.

References cgi, TR_ClearTempCargo(), and transferCallbacks.

Referenced by TR_Shutdown().

◆ TR_TransferBaseSelect()

void TR_TransferBaseSelect ( base_t * srcbase,
base_t * destbase )
static

Callback for base list click.

Note
transferBase is being set here.
Parameters
[in]srcbase
[in]destbasePointer to base which will be transferBase.

Definition at line 661 of file cp_transfer_callbacks.cpp.

References cgi, currentTransferType, base_t::idx, base_t::name, tr, and TR_Fill().

Referenced by TR_Init_f(), and TR_SelectBase_f().

◆ TR_TransferClose_f()

void TR_TransferClose_f ( void )
static

Closes Transfer Menu and resets temp arrays.

Definition at line 756 of file cp_transfer_callbacks.cpp.

References TR_ClearTempCargo(), and TR_TransferListClear_f().

◆ TR_TransferListClear_f()

void TR_TransferListClear_f ( void )
static

Unload everything from transfer cargo back to base.

Note
This is being executed by pressing Unload button in menu.

Definition at line 637 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), cgi, currentTransferType, tr, TR_CargoList(), TR_ClearTempCargo(), and TR_Fill().

Referenced by TR_TransferClose_f().

◆ TR_TransferStart_f()

Variable Documentation

◆ currentTransferType

transferType_t currentTransferType
static

◆ tr

◆ transferCallbacks

const cmdList_t transferCallbacks[]
static
Initial value:
= {
{"trans_list", TR_List_f, "Assembles the transferlist"},
{"trans_init", TR_Init_f, "Init function for Transfer menu"},
{"trans_close", TR_TransferClose_f, "Callback for closing Transfer Menu"},
{"trans_start", TR_TransferStart_f, "Starts the transfer"},
{"trans_emptyairstorage", TR_TransferListClear_f, "Unload everything from transfer cargo back to base"},
{"trans_selectbase", TR_SelectBase_f, "Callback for selecting a base"},
{"ui_trans_caplist", TR_DestinationCapacityList_f, "Update destination base capacity list"},
{"ui_trans_fill", TR_Fill_f, "Fill itemlists for transfer"},
{"ui_trans_add", TR_Add_f, "Add/Remove items to transfercargo"},
{nullptr, nullptr, nullptr}
}
static void TR_Add_f(void)
Callback handles adding/removing items to transfercargo.
static void TR_TransferListClear_f(void)
Unload everything from transfer cargo back to base.
static void TR_TransferClose_f(void)
Closes Transfer Menu and resets temp arrays.
static void TR_SelectBase_f(void)
Callback to select destination base.
static void TR_Fill_f(void)
Callback for filling list with stuff available for transfer.
static void TR_TransferStart_f(void)
Starts the transfer.
static void TR_DestinationCapacityList_f(void)
Callback for assemble destination base capacity list.
static void TR_Init_f(void)
Transfer menu init function.
static void TR_List_f(void)
Assembles the list of transfers for the popup.

Definition at line 923 of file cp_transfer_callbacks.cpp.

Referenced by TR_InitCallbacks(), and TR_ShutdownCallbacks().

◆ transferTypeIDs

char const* const transferTypeIDs[]
static
Initial value:
= {
"item",
"employee",
"alien",
"aircraft"
}

transfer typeID strings

Definition at line 52 of file cp_transfer_callbacks.cpp.

Referenced by CASSERT(), TR_GetTransferType(), and TR_Init_f().