cp_transfer.c File Reference

Deals with the Transfer stuff. More...

#include "../cl_shared.h"
#include "cp_campaign.h"
#include "save/save_transfer.h"
#include "cp_transfer_callbacks.h"
#include "../ui/ui_main.h"
Include dependency graph for cp_transfer.c:

Go to the source code of this file.

Functions

transfer_tTR_GetNext (transfer_t *lastTransfer)
 Iterates through transfers.
static void TR_EmptyTransferCargo (base_t *destination, transfer_t *transfer, qboolean success)
 Unloads transfer cargo when finishing the transfer or destroys it when no buildings/base.
void TR_TransferAlienAfterMissionStart (const base_t *base, aircraft_t *transferAircraft)
 Starts alien bodies transfer between mission and base.
static void TR_TransferEnd (transfer_t *transfer)
 Ends the transfer.
void TR_TransferStart (base_t *srcBase, struct transferData_s *transData)
 Starts a transfer.
void TR_NotifyAircraftRemoved (const aircraft_t *aircraft)
 Notify that an aircraft has been removed.
void TR_TransferCheck (void)
 Checks whether given transfer should be processed.
qboolean TR_SaveXML (mxml_node_t *p)
 Save callback for xml savegames.
qboolean TR_LoadXML (mxml_node_t *p)
 Load callback for xml savegames.
void TR_InitStartup (void)
 Defines commands and cvars for the Transfer menu(s).

Detailed Description

Deals with the Transfer stuff.

Note:
Transfer menu functions prefix: TR_
Todo:
Remove direct access to nodes

Definition in file cp_transfer.c.


Function Documentation

static void TR_EmptyTransferCargo ( base_t destination,
transfer_t transfer,
qboolean  success 
) [static]

Unloads transfer cargo when finishing the transfer or destroys it when no buildings/base.

Parameters:
[in,out] destination The destination base - might be NULL in case the base is already destroyed
[in] transfer Pointer to transfer in ccs.transfers.
[in] success True if the transfer reaches dest base, false if the base got destroyed.
See also:
TR_TransferEnd

Todo:
If source base is destroyed during transfer, aircraft doesn't exist anymore. aircraftArray should contain pointers to aircraftTemplates to avoid this problem, and be removed from source base as soon as transfer starts

Definition at line 68 of file cp_transfer.c.

References _, AIR_AircraftGetFromIDX(), AIR_CalculateHangarStorage(), AIR_DeleteAircraft(), AIR_MoveAircraftIntoNewHomebase(), transfer_s::aircraftArray, AL_ChangeAliveAlienNumber(), transfer_s::alienAmount, base_s::alienscont, aliensCont_s::amountDead, ANTIMATTER_TECH_ID, B_ALIEN_CONTAINMENT, B_ANTIMATTER, B_GetBuildingStatus(), B_ItemIsStoredInBaseStorage(), B_ManageAntimatter(), B_QUARTERS, B_STORAGE, B_UpdateStorageAndCapacity(), employee_s::baseHired, ccs, Com_sprintf(), cp_messageBuffer, csi, E_HireEmployee(), E_UnhireEmployee(), transfer_s::employeeArray, transfer_s::hasAircraft, transfer_s::hasAliens, transfer_s::hasEmployees, transfer_s::hasItems, i, objDef_s::idx, INVSH_GetItemByID(), INVSH_GetItemByIDX(), transfer_s::itemAmount, MAX_EMPL, MSG_TRANSFERFINISHED, MSO_CheckAddNewMessage(), base_s::name, NT_TRANSFER_LOST, ccs_s::numAircraft, ccs_s::numAliensTD, ccs_s::numEmployees, csi_s::numODs, qfalse, qtrue, transfer_s::srcBase, aircraft_s::tpl, TRANS_ALIEN_ALIVE, TRANS_ALIEN_DEAD, TRANS_LIST_EMPTY_SLOT, and employee_s::transfer.

Referenced by TR_TransferEnd().

transfer_t* TR_GetNext ( transfer_t lastTransfer  ) 

Iterates through transfers.

Parameters:
[in] lastTransfer Pointer of the transfer to iterate from. call with NULL to get the first one.

Definition at line 38 of file cp_transfer.c.

References ccs, ccs_s::numTransfers, and ccs_s::transfers.

Referenced by TR_NotifyAircraftRemoved(), TR_SaveXML(), and TR_TransferCheck().

void TR_InitStartup ( void   ) 

Defines commands and cvars for the Transfer menu(s).

See also:
UI_InitStartup

Definition at line 756 of file cp_transfer.c.

References Cmd_AddCommand().

Referenced by CP_InitStartup().

qboolean TR_LoadXML ( mxml_node_t p  ) 
void TR_NotifyAircraftRemoved ( const aircraft_t aircraft  ) 

Notify that an aircraft has been removed.

Parameters:
[in] aircraft Aircraft that was removed from the game
See also:
AIR_DeleteAircraft

Definition at line 418 of file cp_transfer.c.

References transfer_s::active, transfer_s::aircraftArray, ccs, transfer_s::hasAircraft, aircraft_s::idx, MAX_AIRCRAFT, ccs_s::numAircraft, REMOVE_ELEM_MEMSET, TR_GetNext(), and TRANS_LIST_EMPTY_SLOT.

Referenced by AIR_DeleteAircraft().

qboolean TR_SaveXML ( mxml_node_t p  ) 
void TR_TransferAlienAfterMissionStart ( const base_t base,
aircraft_t transferAircraft 
)
void TR_TransferCheck ( void   ) 

Checks whether given transfer should be processed.

See also:
CL_CampaignRun

Todo:
make it TR_Remove()

Definition at line 438 of file cp_transfer.c.

References transfer_s::active, ccs, ccs_s::date, date_s::day, transfer_s::destBase, transfer_s::event, ccs_s::numTransfers, REMOVE_ELEM, date_s::sec, TR_GetNext(), TR_TransferEnd(), and ccs_s::transfers.

Referenced by CL_CampaignRun().

static void TR_TransferEnd ( transfer_t transfer  )  [static]

Ends the transfer.

Parameters:
[in] transfer Pointer to transfer in ccs.transfers

Todo:
what if source base is lost? we won't be able to unhire transfered employees.

Definition at line 290 of file cp_transfer.c.

References _, transfer_s::active, Com_sprintf(), transfer_s::destBase, base_s::founded, MSG_TRANSFERFINISHED, MSO_CheckAddNewMessage(), base_s::name, NT_TRANSFER_COMPLETED_SUCCESS, NT_TRANSFER_LOST, qfalse, qtrue, and TR_EmptyTransferCargo().

Referenced by TR_TransferCheck().

void TR_TransferStart ( base_t srcBase,
struct transferData_s transData 
)

Starts a transfer.

Parameters:
[in] srcBase start transfer from this base
[in] transData Container holds transfer details

Todo:
This doesn't work - it would require to store the aliens as the first entries in the teamDef array - and this is not guaranteed. The alienAmount array may not contain more than numAliensTD entries though

Definition at line 313 of file cp_transfer.c.

References transfer_s::active, AIR_AircraftGetFromIDX(), AIR_RemoveEmployees(), AIR_TRANSFER, transfer_s::aircraftArray, transfer_s::alienAmount, employee_s::baseHired, ccs, CHRSH_IsTeamDefAlien(), Com_DPrintf(), Com_Error(), Com_Printf(), csi, ccs_s::date, date_s::day, DEBUG_CLIENT, transfer_s::destBase, E_IsInBase(), E_ResetEmployee(), transfer_s::employeeArray, ERR_DROP, transfer_s::event, GetDistanceOnGlobe(), transfer_s::hasAircraft, transfer_s::hasAliens, transfer_s::hasEmployees, transfer_s::hasItems, i, transfer_s::itemAmount, MAX_EMPL, MAX_TRANSFERS, ccs_s::numAircraft, ccs_s::numAliensTD, ccs_s::numEmployees, csi_s::numODs, ccs_s::numTransfers, base_s::pos, PR_ProductionAllowed(), qtrue, RS_ResearchAllowed(), date_s::sec, SECONDS_PER_DAY, transfer_s::srcBase, aircraft_s::status, csi_s::teamDef, transferData_s::trAircraftsTmp, transferData_s::trAliensTmp, TRANS_ALIEN_ALIVE, TRANS_ALIEN_DEAD, TRANS_LIST_EMPTY_SLOT, employee_s::transfer, transferData_s::transferBase, ccs_s::transfers, transferData_s::trCargoCountTmp, transferData_s::trEmployeesTmp, and transferData_s::trItemsTmp.

Referenced by TR_TransferStart_f().


Generated by  doxygen 1.6.2