UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_transfer_callbacks.cpp File Reference
#include "cp_transfer_callbacks.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"

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

Variables

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

Enumeration Type Documentation

transfer types

Enumerator
TRANS_TYPE_INVALID 
TRANS_TYPE_ITEM 
TRANS_TYPE_EMPLOYEE 
TRANS_TYPE_ALIEN 
TRANS_TYPE_AIRCRAFT 
TRANS_TYPE_MAX 

Definition at line 38 of file cp_transfer_callbacks.cpp.

Function Documentation

static 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 202 of file cp_transfer_callbacks.cpp.

References AIR_IsAircraftInBase(), transfer_s::aircraft, cgi, and cgame_import_s::LIST_GetPointer().

Referenced by TR_Add_f().

static 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().

static 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().

static 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 367 of file cp_transfer_callbacks.cpp.

References cgi, 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().

static void TR_Fill_f ( void  )
static

Callback for filling list with stuff available for transfer.

Definition at line 398 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), cgi, cgame_import_s::Cmd_Argv(), transfer_s::destBase, TR_Fill(), TR_GetTransferType(), TRANS_TYPE_INVALID, and type.

static 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 344 of file cp_transfer_callbacks.cpp.

References AIR_ForeachFromBase, AIR_IsAircraftInBase(), transfer_s::aircraft, cgi, and cgame_import_s::LIST_GetPointer().

Referenced by TR_Fill().

static 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 309 of file cp_transfer_callbacks.cpp.

References _, transfer_s::alienCargo, base_s::alienContainment, cgi, Com_sprintf(), AlienCargo::getAlive(), AlienCargo::getDead(), AlienCargo::list(), and LIST_Foreach.

Referenced by TR_Fill().

static 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 252 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, transfer_s::employees, ERR_DROP, i, cgame_import_s::LIST_GetPointer(), MAX_EMPL, and rank_s::shortname.

Referenced by TR_Fill().

static 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 217 of file cp_transfer_callbacks.cpp.

References _, transfer_s::antimatter, ANTIMATTER_ITEM_ID, B_AntimatterInBase(), B_ItemInBase(), B_ItemIsStoredInBaseStorage(), cgi, cgame_import_s::csi, ItemCargo::getAmount(), i, objDef_s::id, INVSH_GetItemByID(), INVSH_GetItemByIDX(), transfer_s::itemCargo, objDef_s::name, and csi_s::numODs.

Referenced by TR_Fill().

static transferType_t TR_GetTransferType ( const char *  id)
static

Returns the transfer type.

Parameters
[in]idTransfer type Id
See also
transferType_t

Definition at line 112 of file cp_transfer_callbacks.cpp.

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

Referenced by TR_Fill_f().

static 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 722 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), B_GetNext(), cgi, cgame_import_s::Cvar_Set(), transfer_s::destBase, ERR_DROP, base_s::idx, base_s::name, TR_ClearTempCargo(), TR_InitBaseList(), TR_TransferBaseSelect(), and transferTypeIDs.

static void TR_InitBaseList ( void  )
static

Fills the optionlist with available bases to transfer to.

Definition at line 681 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), B_GetNext(), cgi, base_s::idx, base_s::name, OPTION_BASELIST, cgame_import_s::UI_AddOption(), and va().

Referenced by TR_Init_f().

void TR_InitCallbacks ( void  )

Definition at line 935 of file cp_transfer_callbacks.cpp.

References cgi.

Referenced by TR_InitStartup().

static void TR_List_f ( void  )
static
static void TR_SelectBase_f ( void  )
static

Callback to select destination base.

Definition at line 700 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), B_GetFoundedBaseByIDX(), cgi, cgame_import_s::Cmd_Argv(), and TR_TransferBaseSelect().

void TR_ShutdownCallbacks ( void  )

Definition at line 940 of file cp_transfer_callbacks.cpp.

References cgi, and TR_ClearTempCargo().

Referenced by TR_Shutdown().

static 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 660 of file cp_transfer_callbacks.cpp.

References cgi, cgame_import_s::Cvar_Set(), transfer_s::destBase, base_s::idx, base_s::name, and TR_Fill().

Referenced by TR_Init_f(), and TR_SelectBase_f().

static void TR_TransferClose_f ( void  )
static

Closes Transfer Menu and resets temp arrays.

Definition at line 755 of file cp_transfer_callbacks.cpp.

References TR_ClearTempCargo(), and TR_TransferListClear_f().

static 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 636 of file cp_transfer_callbacks.cpp.

References B_GetCurrentSelectedBase(), cgi, transfer_s::destBase, base_s::idx, TR_CargoList(), TR_ClearTempCargo(), and TR_Fill().

Referenced by TR_TransferClose_f().

Variable Documentation

transferType_t currentTransferType
static
Todo:
move this into Lua UI

Definition at line 62 of file cp_transfer_callbacks.cpp.

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_Init_f(void)
Transfer menu init function.
static void TR_Add_f(void)
Callback handles adding/removing items to transfercargo.
static void TR_List_f(void)
Assembles the list of transfers for the popup.
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_TransferListClear_f(void)
Unload everything from transfer cargo back to base.
static void TR_DestinationCapacityList_f(void)
Callback for assemble destination base capacity list.
static void TR_TransferClose_f(void)
Closes Transfer Menu and resets temp arrays.
static void TR_SelectBase_f(void)
Callback to select destination base.

Definition at line 923 of file cp_transfer_callbacks.cpp.

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

transfer typeID strings

Definition at line 51 of file cp_transfer_callbacks.cpp.

Referenced by TR_GetTransferType(), and TR_Init_f().