cp_base.c File Reference

Handles everything that is located in or accessed trough a base. More...

#include "../client.h"
#include "../cl_inventory.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_mapfightequip.h"
#include "cp_aircraft.h"
#include "cp_missions.h"
#include "cp_map.h"
#include "cp_popup.h"
#include "cp_time.h"
#include "cp_base_callbacks.h"
#include "cp_ufo.h"
#include "save/save_base.h"
Include dependency graph for cp_base.c:

Go to the source code of this file.

Defines

#define MAX_BUILDING_INFO_TEXT_LENGTH   512

Functions

static void B_PackInitialEquipment (aircraft_t *aircraft, const equipDef_t *ed)
 Assigns initial soldier equipment for the first base.
base_tB_GetBaseByIDX (int baseIdx)
 Array bound check for the base index. Will also return unfounded bases as long as the index is in the valid ranges,.
base_tB_GetFoundedBaseByIDX (int baseIdx)
 Array bound check for the base index.
building_tB_GetNextBuilding (const base_t *base, building_t *lastBuilding)
 Iterates through buildings in a base.
building_tB_GetNextBuildingByType (const base_t *base, building_t *lastBuilding, buildingType_t buildingType)
 Iterates throught buildings of a type in a base.
qboolean B_CheckBuildingTypeStatus (const base_t *const base, buildingType_t type, buildingStatus_t status, int *cnt)
 Searches the base for a given building type with the given status.
baseCapacities_t B_GetCapacityFromBuildingType (buildingType_t type)
 Get the capacity associated to a building type.
buildingType_t B_GetBuildingTypeByCapacity (baseCapacities_t cap)
 Get building type by base capacity.
qboolean B_GetBuildingStatus (const base_t *const base, const buildingType_t buildingType)
 Get the status associated to a building.
void B_SetBuildingStatus (base_t *const base, const buildingType_t buildingType, qboolean newStatus)
 Set status associated to a building.
qboolean B_CheckBuildingDependencesStatus (const base_t *const base, const building_t *building)
 Check that the dependences of a building is operationnal.
void B_ResetBuildingCurrent (base_t *base)
 Resets the buildingCurrent variable and baseAction.
float B_GetMaxBuildingLevel (const base_t *base, const buildingType_t type)
 Get the maximum level of a building type in a base.
qboolean B_AssembleMap (const base_t *base)
 Perform the base assembling in case of an alien attack.
static qboolean B_CheckUpdateBuilding (building_t *building, base_t *base)
 Check base status for particular buildings as well as capacities.
static void B_UpdateOneBaseBuildingStatusOnEnable (buildingType_t type, base_t *base)
 Actions to perform when a type of buildings goes from qfalse to qtrue.
static void B_UpdateOneBaseBuildingStatusOnDisable (buildingType_t type, base_t *base)
 Actions to perform when a type of buildings goes from functional to non-functional.
static qboolean B_UpdateStatusBuilding (base_t *base, buildingType_t buildingType, qboolean onBuilt)
 Update status of every building when a building has been built/destroyed.
static void B_UpdateAntimatterCap (base_t *base)
 Update Antimatter Capacity.
int B_FreeCapacity (const base_t *base, baseCapacities_t cap)
 Returns the free capacity of a type.
void B_ResetAllStatusAndCapacities (base_t *base, qboolean firstEnable)
 Recalculate status and capacities of one base.
void B_RemoveAircraftExceedingCapacity (base_t *base, buildingType_t buildingType)
 Actions to perform when destroying one hangar.
qboolean B_BuildingDestroy (base_t *base, building_t *building)
 Removes a building from the given base.
static void B_MoveAircraftOnGeoscapeToOtherBases (const base_t *base)
 Will ensure that aircraft on geoscape are not stored in a base that no longer has any hangar left.
void B_Destroy (base_t *base)
 Destroy a base.
void B_MarkBuildingDestroy (base_t *base, building_t *building)
 Mark a building for destruction - you only have to confirm it now.
void B_BuildingStatus (const base_t *base, const building_t *building)
 Displays the status of a building for baseview.
static void B_UpdateAllBaseBuildingStatus (building_t *building, base_t *base, buildingStatus_t status)
 Updates base status for particular buildings as well as capacities.
static void B_AddBuildingToBasePos (base_t *base, const building_t const *buildingTemplate, qboolean hire, const vec2_t pos)
 Build starting building in the first base, and hire employees.
static void B_InitialEquipment (base_t *base, aircraft_t *assignInitialAircraft, const char *eqname, equipDef_t *edTarget)
 Prepares initial equipment for first base at the beginning of the campaign.
static void B_BuildFromTemplate (base_t *base, const char *templateName, qboolean hire)
 builds a base from template
static void B_SetUpFirstBase (base_t *base)
 Setup buildings and equipment for first base. Uses the campaign scriptable first base template to place the buildings in the base.
int B_GetInstallationLimit (void)
 Counts the actual installation count limit.
void B_UpdateBaseCount (void)
 Update menu script related cvars when the amount of bases changed.
void B_SetUpBase (base_t *base, vec2_t pos)
 Setup new base, uses template for the first base.
building_tB_GetBuildingTemplate (const char *buildingName)
 Returns the building in the global building-types list that has the unique name buildingID.
const baseTemplate_tB_GetBaseTemplate (const char *baseTemplateID)
 Returns the baseTemplate in the global baseTemplate list that has the unique name baseTemplateID.
static qboolean B_CheckCredits (int costs)
 Checks whether you have enough credits to build this building.
static qboolean B_ConstructBuilding (base_t *base, building_t *building)
 Builds new building. And checks whether the player has enough credits to construct the current selected building before starting construction.
static void B_NewBuilding (base_t *base, building_t *building)
 Build new building.
building_tB_SetBuildingByClick (base_t *base, const building_t const *buildingTemplate, int row, int col)
 Set the currently selected building.
void B_DrawBuilding (base_t *base, building_t *building)
 Draws a building.
int B_GetNumberOfBuildingsInBaseByTemplate (const base_t *base, const building_t *tpl)
 Counts the number of buildings of a particular type in a base.
int B_GetNumberOfBuildingsInBaseByBuildingType (const base_t *base, const buildingType_t buildingType)
 Counts the number of buildings of a particular buuilding type in a base.
buildingType_t B_GetBuildingTypeByBuildingID (const char *buildingID)
 Returns the building type for a given building identified by its building id from the ufo script files.
void B_ParseBuildings (const char *name, const char **text, qboolean link)
 Copies an entry from the building description file into the list of building types.
building_tB_GetBuildingInBaseByType (const base_t *base, buildingType_t buildingType, qboolean onlyWorking)
 Gets a building of a given type in the given base.
void B_ParseBaseTemplate (const char *name, const char **text)
 Reads a base layout template.
base_tB_GetFirstUnfoundedBase (void)
 Get the lower IDX of unfounded base.
void B_SetCurrentSelectedBase (const base_t *base)
base_tB_GetCurrentSelectedBase (void)
void B_SelectBase (const base_t *base)
static void CL_SwapSkill (character_t *cp1, character_t *cp2, abilityskills_t skill)
 Swaps one skill from character1 to character 2 and vice versa.
static void CL_DoSwapSkills (character_t *cp1, character_t *cp2, const int skill)
static void CL_SwapSkills (chrList_t *team)
 Swaps skills of the initial team of soldiers so that they match inventories.
void B_BaseResetStatus (base_t *const base)
 Sets the baseStatus to BASE_NOT_USED.
void B_BuildingOpenAfterClick (const base_t *base, const building_t *building)
 Checks whether the building menu or the pedia entry should be called when you click a building in the baseview.
void B_InitStartup (void)
 Resets console commands.
int B_GetFoundedBaseCount (void)
 Counts the number of bases.
void B_UpdateBaseData (void)
 Updates base data.
int B_CheckBuildingConstruction (building_t *building, base_t *base)
 Checks whether the construction of a building is finished. Calls the onConstruct functions and assign workers, too.
static void B_SellOrAddItems (aircraft_t *aircraft)
 Sell items to the market or add them to base storage.
void B_DumpAircraftToHomeBase (aircraft_t *aircraft)
 Will unload all cargo to the homebase.
void B_AircraftReturnedToHomeBase (aircraft_t *aircraft)
 Do anything when dropship returns to base.
qboolean B_BaseHasItem (const base_t *base, const objDef_t *item)
 Check if an item is available on a base.
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.
void B_UpdateBaseCapacities (baseCapacities_t cap, base_t *base)
 Updates base capacities.
void B_SaveBaseSlotsXML (const baseWeapon_t *weapons, const int numWeapons, mxml_node_t *node)
 Saves the missile and laser slots of a base or sam site.
qboolean B_SaveStorageXML (mxml_node_t *parent, const equipDef_t equip)
 Saves base storage.
qboolean B_SaveXML (mxml_node_t *parent)
 Save callback for saving in xml format.
int B_LoadBaseSlotsXML (baseWeapon_t *weapons, int max, mxml_node_t *p)
 Loads the missile and laser slots of a base or sam site.
static void B_PostLoadInitCapacity (void)
 Set the capacity stuff for all the bases after loading a savegame.
void B_PostLoadInit (void)
 Set the capacity stuff for all the bases after loading a savegame.
qboolean B_LoadStorageXML (mxml_node_t *parent, equipDef_t *equip)
 Loads base storage.
qboolean B_LoadXML (mxml_node_t *parent)
 Loads base data.
qboolean B_ItemIsStoredInBaseStorage (const objDef_t *obj)
 Check if an item is stored in storage.
int B_AddToStorage (base_t *base, const objDef_t *obj, int amount)
 Add/remove items to/from the storage.
qboolean B_UpdateStorageAndCapacity (base_t *base, const objDef_t *obj, int amount, qboolean reset, qboolean ignorecap)
 Update the storage amount and the capacities for the storages in the base.
qboolean B_ScriptSanityCheck (void)
 Checks the parsed buildings for errors.
void B_RemoveItemsExceedingCapacity (base_t *base)
 Remove items until everything fits in storage.
void B_UpdateStorageCap (base_t *base)
 Update Storage Capacity.
int B_AntimatterInBase (const base_t *base)
 returns the amount of antimatter stored in a base
void B_ManageAntimatter (base_t *base, int amount, qboolean add)
 Manages antimatter (adding, removing) through Antimatter Storage Facility.
void B_RemoveAntimatterExceedingCapacity (base_t *base)
 Remove exceeding antimatter if an antimatter tank has been destroyed.

Variables

vec2_t newBasePos
static cvar_tcp_initial_equipment
static const value_t valid_building_vars []
 Holds the names of valid entries in the basemanagement.ufo file.

Detailed Description

Handles everything that is located in or accessed trough a base.

Note:
Basemanagement functions prefix: B_
See "base/ufos/basemanagement.ufo", "base/ufos/menu_bases.ufo" and "base/ufos/menu_buildings.ufo" for the underlying content.

Definition in file cp_base.c.


Define Documentation

#define MAX_BUILDING_INFO_TEXT_LENGTH   512

Definition at line 1500 of file cp_base.c.

Referenced by B_DrawBuilding().


Function Documentation

static void B_AddBuildingToBasePos ( base_t base,
const building_t const *  buildingTemplate,
qboolean  hire,
const vec2_t  pos 
) [static]

Build starting building in the first base, and hire employees.

Parameters:
[in,out] base The base to put the new building into
[in] buildingTemplate The building template to create a new building with
[in] hire Hire employees for the building we create from the template
[in] pos The position on the base grid

Definition at line 1053 of file cp_base.c.

References B_SetBuildingByClick(), B_STATUS_WORKING, B_UpdateAllBaseBuildingStatus(), Cmd_ExecuteString(), Com_DPrintf(), DEBUG_CLIENT, E_HireForBuilding(), building_s::id, base_s::idx, building_s::onConstruct, building_s::pos, and va().

Referenced by B_BuildFromTemplate().

int B_AddToStorage ( base_t base,
const objDef_t obj,
int  amount 
)

Add/remove items to/from the storage.

Parameters:
[in] base The base which storage and capacity should be updated
[in] obj The item.
[in] amount Amount to be added to removed
Returns:
the added/removed amount
Note:
The main difference between B_AddToStorage and B_UpdateStorageAndCapacity is that B_AddToStorage adds/removes as many items as possible if adding/removing all not possible also B_AddToStorage don't have a reset method

Definition at line 3054 of file cp_base.c.

References B_ItemIsStoredInBaseStorage(), CAP_ITEMS, base_s::capacities, cap_maxcur_s::cur, objDef_s::idx, objDef_s::isVirtual, cap_maxcur_s::max, equipDef_s::numItems, objDef_s::size, and base_s::storage.

Referenced by PR_UpdateRequiredItemsInBasestorage().

void B_AircraftReturnedToHomeBase ( aircraft_t aircraft  ) 

Do anything when dropship returns to base.

Parameters:
[in] aircraft Returning aircraft.
Note:
Place here any stuff, which should be called when Drophip returns to base.
See also:
CL_CampaignRunAircraft

Definition at line 2601 of file cp_base.c.

References AII_ReloadAircraftWeapons(), B_DumpAircraftToHomeBase(), aircraft_s::radar, and RADAR_InitialiseUFOs().

Referenced by AIR_Move().

int B_AntimatterInBase ( const base_t base  ) 

returns the amount of antimatter stored in a base

Parameters:
[in] base Pointer to the base to check

Definition at line 3260 of file cp_base.c.

References ANTIMATTER_TECH_ID, CAP_ANTIMATTER, base_s::capacities, Com_Error(), cap_maxcur_s::cur, ERR_DROP, objDef_s::idx, INVSH_GetItemByID(), equipDef_s::numItems, and base_s::storage.

Referenced by PR_RequirementsMet(), RS_RequirementsMet(), TR_TransferList_Scroll_f(), TR_TransferListSelect_f(), and TR_TransferSelect().

qboolean B_AssembleMap ( const base_t base  ) 

Perform the base assembling in case of an alien attack.

Parameters:
[in,out] base The base to assemble
Returns:
true if the assembly was successful, false if it failed
Todo:

Search a empty field and add a alien craft there

If a building is still under construction, it will be assembled as a finished part. Otherwise we need mapparts for all the maps under construction.

Definition at line 349 of file cp_base.c.

References B_BuildingGetUsed, B_BuildingSetUsed, BASE_MAX_WORLDLEVEL, BASE_SIZE, BASE_TILE_UNITS, baseBuildingTile_s::building, Cbuf_AddText(), cl, Com_Error(), Com_Printf(), ERR_DROP, building_s::id, building_s::idx, base_s::map, MAP_IsNight(), building_s::mapPart, MAX_BUILDINGS, building_s::needs, base_s::pos, Q_strcat(), qfalse, qtrue, SAV_QuickSave(), and va().

Referenced by B_AssembleMap_f(), and CP_StartMissionMap().

qboolean B_BaseHasItem ( const base_t base,
const objDef_t item 
)

Check if an item is available on a base.

Parameters:
[in] base Pointer to the base to check at
[in] item Pointer to the item to check

Definition at line 2616 of file cp_base.c.

References objDef_s::idx, objDef_s::isVirtual, equipDef_s::numItems, and base_s::storage.

Referenced by AII_AddAmmoToSlot(), AII_AddItemToSlot(), AII_ReloadWeapon(), AIM_AutoEquipAircraft(), AIM_CheckTechnologyIntoSlot(), AIM_CrafttypeFilter(), and AIM_SelectableCraftItem().

void B_BaseResetStatus ( base_t *const   base  ) 

Sets the baseStatus to BASE_NOT_USED.

Parameters:
[in] base Which base should be reseted?
See also:
CL_CampaignRemoveMission

Definition at line 2153 of file cp_base.c.

References BASE_NOT_USED, base_s::baseStatus, ccs, MA_BASEATTACK, MA_NONE, and ccs_s::mapAction.

static void B_BuildFromTemplate ( base_t base,
const char *  templateName,
qboolean  hire 
) [static]

builds a base from template

Parameters:
[out] base The base to build
[in] templateName Templated used for building. If NULL no template will be used.
[in] hire If hiring employee needed
Note:
It builds an empty base on NULL (or empty) templatename

Todo:
if there is no more space for mandatory building, remove a non mandatory one or build mandatory ones first

Definition at line 1120 of file cp_base.c.

References B_AddBuildingToBasePos(), B_GetBaseTemplate(), B_GetBuildingStatus(), BASE_SIZE, stats_s::basesBuilt, baseBuildingTile_s::blocked, baseBuildingTile_s::building, baseTemplate_s::buildings, ccs_s::buildingTemplates, building_s::buildingType, ccs_s::campaignStats, base_s::capacities, ccs, Com_Error(), cap_maxcur_s::cur, ERR_DROP, frand(), i, building_s::mandatory, base_s::map, MAX_BLOCKEDFIELDS, MAX_CAP, MIN_BLOCKEDFIELDS, baseTemplate_s::numBuildings, ccs_s::numBuildingTemplates, pos, baseBuildingTile_s::posX, baseBuildingTile_s::posY, qtrue, and Vector2Set.

Referenced by B_SetUpBase(), and B_SetUpFirstBase().

qboolean B_BuildingDestroy ( base_t base,
building_t building 
)

Removes a building from the given base.

Parameters:
[in] base Base to remove the building in
[in] building The building to remove
Note:
Also updates capacities and sets the hasBuilding[] values in base_t
See also:
B_BuildingDestroy_f

< Template of the removed building

Note:
Don't use the building pointer after this point - it's zeroed.

Definition at line 715 of file cp_base.c.

References B_ENTRANCE, B_GetCapacityFromBuildingType(), B_GetNumberOfBuildingsInBaseByBuildingType(), B_MISC, B_SetBuildingStatus(), B_STATUS_NOT_SET, B_STATUS_WORKING, B_UpdateBaseCapacities(), B_UpdateStatusBuilding(), baseBuildingTile_s::building, base_s::buildingCurrent, ccs_s::buildings, building_s::buildingStatus, building_s::buildingType, ccs, Cmd_ExecuteString(), Com_DPrintf(), Com_Error(), DEBUG_CLIENT, ERR_DROP, i, building_s::idx, base_s::idx, int(), base_s::map, MAX_BUILDING_TYPE, MAX_CAP, building_s::needs, ccs_s::numBuildings, building_s::onDestroy, pos, building_s::pos, qfalse, qtrue, REMOVE_ELEM, building_s::tpl, and va().

Referenced by B_BuildingDestroy_f(), and B_Destroy().

void B_BuildingOpenAfterClick ( const base_t base,
const building_t building 
)

Checks whether the building menu or the pedia entry should be called when you click a building in the baseview.

Parameters:
[in] base The current active base we are viewing right now
[in] building The building we have clicked

Definition at line 2250 of file cp_base.c.

References _, AC_ContainmentAllowed(), AIR_AircraftAllowed(), AIR_BaseHasAircraft(), B_ALIEN_CONTAINMENT, B_ANTIMATTER, B_DEFENCE_LASER, B_DEFENCE_MISSILE, B_GetBuildingStatus(), B_HANGAR, B_HOSPITAL, B_LAB, B_QUARTERS, B_SMALL_HANGAR, B_STORAGE, B_WORKSHOP, BS_BuySellAllowed(), building_s::buildingType, CAP_ANTIMATTER, base_s::capacities, ccs, Com_sprintf(), cap_maxcur_s::cur, E_HireAllowed(), HOS_HospitalAllowed(), cap_maxcur_s::max, ccs_s::numBases, building_s::pedia, popupText, PR_ProductionAllowed(), RS_ResearchAllowed(), UI_Popup(), UI_PushWindow(), and UP_OpenWith().

Referenced by UI_BaseMapNodeClick().

void B_BuildingStatus ( const base_t base,
const building_t building 
)

Displays the status of a building for baseview.

Note:
updates the cvar mn_building_status which is used in the building construction menu to display the status of the given building
also script command function binding for 'building_status'

Todo:
shorten text or provide more space in overview popup

Definition at line 961 of file cp_base.c.

References _, B_CheckBuildingDependencesStatus(), B_GetNumberOfBuildingsInBaseByTemplate(), B_STATUS_CONSTRUCTION_FINISHED, B_STATUS_DOWN, B_STATUS_NOT_SET, B_STATUS_UNDER_CONSTRUCTION, B_STATUS_WORKING, building_s::buildingStatus, Cvar_Set(), building_s::dependsBuilding, building_s::name, building_s::tpl, and va().

Referenced by B_BuildingStatus_f(), B_DrawBuilding(), and B_NewBuilding().

int B_CheckBuildingConstruction ( building_t building,
base_t base 
)

Checks whether the construction of a building is finished. Calls the onConstruct functions and assign workers, too.

Definition at line 2471 of file cp_base.c.

References B_STATUS_UNDER_CONSTRUCTION, B_STATUS_WORKING, B_UpdateAllBaseBuildingStatus(), base_s::buildingCurrent, building_s::buildingStatus, building_s::buildTime, Cbuf_AddText(), ccs, Cmd_ExecuteString(), Com_DPrintf(), ccs_s::date, date_s::day, DEBUG_CLIENT, base_s::idx, building_s::onConstruct, building_s::timeStart, and va().

Referenced by B_UpdateBaseData().

qboolean B_CheckBuildingDependencesStatus ( const base_t *const   base,
const building_t building 
)

Check that the dependences of a building is operationnal.

Parameters:
[in] base Base to check
[in] building Pointer to the building to check
Returns:
true if base contains needed dependence for entering building

Definition at line 263 of file cp_base.c.

References B_GetBuildingStatus(), building_s::buildingType, building_s::dependsBuilding, qtrue, and building_s::tpl.

Referenced by B_BuildingStatus(), B_CheckBuildingStatusForMenu_f(), B_CheckUpdateBuilding(), B_UpdateAllBaseBuildingStatus(), and UI_BaseMapNodeDrawTooltip().

qboolean B_CheckBuildingTypeStatus ( const base_t *const   base,
buildingType_t  type,
buildingStatus_t  status,
int *  cnt 
)

Searches the base for a given building type with the given status.

Parameters:
[in] base Base to search
[in] type Building type to search
[in] status The status the building should have
[out] cnt This is a pointer to an int value which will hold the building count of that type with the status you are searching - might also be NULL if you are not interested in this value
Note:
If you are searching for a quarter (e.g.) you should perform a if (hasBuilding[B_QUARTERS]) check - this should speed things up a lot
Returns:
true if building with status was found

Definition at line 134 of file cp_base.c.

References B_GetNextBuildingByType(), building_s::buildingStatus, qfalse, and qtrue.

Referenced by B_CheckBuildingStatusForMenu_f().

static qboolean B_CheckCredits ( int  costs  )  [inline, static]

Checks whether you have enough credits to build this building.

Parameters:
costs buildcosts of the building
Returns:
qboolean true - enough credits
qboolean false - not enough credits
See also:
B_ConstructBuilding
B_NewBuilding Checks whether the given costs are bigger than the current available credits

Definition at line 1359 of file cp_base.c.

References ccs, ccs_s::credits, qfalse, and qtrue.

Referenced by B_ConstructBuilding(), and B_SetBuildingByClick().

static qboolean B_CheckUpdateBuilding ( building_t building,
base_t base 
) [static]

Check base status for particular buildings as well as capacities.

Parameters:
[in] building Pointer to building.
[in] base Pointer to base with given building.
Note:
This function checks base status for particular buildings and base capacities.
Returns:
qtrue if a base status has been modified (but do not check capacities)

Definition at line 409 of file cp_base.c.

References B_CheckBuildingDependencesStatus(), B_GetBuildingStatus(), B_MISC, B_SetBuildingStatus(), B_STATUS_WORKING, building_s::buildingStatus, building_s::buildingType, Com_DPrintf(), DEBUG_CLIENT, building_s::name, qfalse, and qtrue.

Referenced by B_ResetAllStatusAndCapacities(), B_UpdateAllBaseBuildingStatus(), and B_UpdateStatusBuilding().

static qboolean B_ConstructBuilding ( base_t base,
building_t building 
) [static]

Builds new building. And checks whether the player has enough credits to construct the current selected building before starting construction.

See also:
B_MarkBuildingDestroy
B_CheckCredits
CL_UpdateCredits
Returns:
qboolean
See also:
B_NewBuilding
Parameters:
[in,out] base The base to construct the building in
[in,out] building The building to construct

Definition at line 1377 of file cp_base.c.

References B_CheckCredits(), B_ResetBuildingCurrent(), B_STATUS_UNDER_CONSTRUCTION, building_s::buildingStatus, ccs, CL_UpdateCredits(), Cmd_ExecuteString(), Com_DPrintf(), ccs_s::credits, ccs_s::date, date_s::day, DEBUG_CLIENT, building_s::fixCosts, building_s::id, qfalse, qtrue, and building_s::timeStart.

Referenced by B_NewBuilding().

void B_Destroy ( base_t base  ) 

Destroy a base.

Parameters:
[in] base Pointer to base to be destroyed.
Note:
If you want to sell items or unhire employees, you should do it before calling this function - they are going to be killed / destroyed.

Todo:
Destroy the base if we solved aircraft transfer issue it should be done via moving other bases (and adjusting pointers where needed. We don't allow holes in baselist

Definition at line 831 of file cp_base.c.

References B_BuildingDestroy(), B_MoveAircraftOnGeoscapeToOtherBases(), BASE_DESTROYED, base_s::baseStatus, ccs_s::buildings, ccs, CP_MissionNotifyBaseDestroyed(), base_s::idx, and ccs_s::numBuildings.

Referenced by B_Destroy_AntimaterStorage_f(), and CP_BaseAttackMissionDestroyBase().

void B_DrawBuilding ( base_t base,
building_t building 
)
void B_DumpAircraftToHomeBase ( aircraft_t aircraft  ) 

Will unload all cargo to the homebase.

Parameters:
[in,out] aircraft The aircraft to dump

Definition at line 2575 of file cp_base.c.

References AIRCRAFT_TRANSPORTER, AL_AddAliens(), AL_GetAircraftAlienCargo, AL_SetAircraftAlienCargoTypes, B_SellOrAddItems(), aircraft_s::itemcargo, and aircraft_s::type.

Referenced by B_AircraftReturnedToHomeBase(), and CP_MissionEndActions().

int B_FreeCapacity ( const base_t base,
baseCapacities_t  cap 
)

Returns the free capacity of a type.

Parameters:
[in] base Pointer to the base to check
[in] cap Capacity type
See also:
baseCapacities_t

Definition at line 567 of file cp_base.c.

References base_s::capacities, cap_maxcur_s::cur, and cap_maxcur_s::max.

Referenced by TR_CheckItem(), and TR_TransferAliensFromMission_f().

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 valid ranges,.

Parameters:
[in] baseIdx Index to check
Returns:
Pointer to the base corresponding to baseIdx.

Definition at line 54 of file cp_base.c.

References ccs_s::bases, ccs, and MAX_BASES.

Referenced by AC_LoadXML(), AIR_AircraftsUFODisappear(), AIR_LoadAircraftXML(), B_AssembleMap_f(), B_GetCurrentSelectedBase(), B_GetFirstUnfoundedBase(), B_GetFoundedBaseByIDX(), B_LoadXML(), B_MoveAircraftOnGeoscapeToOtherBases(), B_SaveXML(), B_SetCurrentSelectedBase(), BDEF_AddBattery_f(), CL_CampaignRunAircraft(), CL_ResetSinglePlayerData(), CP_AddItemAsCollected_f(), CP_LoadMissionsXML(), E_LoadXML(), PR_ProductionBase(), RS_LoadXML(), TR_LoadXML(), and UI_BaseLayoutNodeDraw().

const baseTemplate_t* B_GetBaseTemplate ( const char *  baseTemplateID  ) 

Returns the baseTemplate in the global baseTemplate list that has the unique name baseTemplateID.

Parameters:
[in] baseTemplateID The unique id of the building (baseTemplate_t->name).
Returns:
baseTemplate_t If a Template was found it is returned, otherwise->NULL.

Definition at line 1334 of file cp_base.c.

References ccs_s::baseTemplates, ccs, Com_Printf(), i, baseTemplate_s::id, and ccs_s::numBaseTemplates.

Referenced by B_BuildFromTemplate().

building_t* B_GetBuildingInBaseByType ( const base_t base,
buildingType_t  buildingType,
qboolean  onlyWorking 
)

Gets a building of a given type in the given base.

Parameters:
[in] base The base to search the building in
[in] buildingType What building-type to get.
[in] onlyWorking If we're looking only for working buildings
Returns:
The building or NULL if base has no building of that type

Definition at line 1798 of file cp_base.c.

References B_GetBuildingStatus(), and B_GetNextBuildingByType().

Referenced by RS_AssignScientist(), and RS_InitGUIData().

qboolean B_GetBuildingStatus ( const base_t *const   base,
const buildingType_t  buildingType 
)

Get the status associated to a building.

Parameters:
[in] base The base to search for the given building type
[in] buildingType value of building->buildingType
Returns:
true if the building is functional
See also:
B_SetBuildingStatus

Definition at line 222 of file cp_base.c.

References B_MISC, Com_Printf(), base_s::hasBuilding, MAX_BUILDING_TYPE, qfalse, and qtrue.

Referenced by AC_AlienClick(), AC_ContainmentAllowed(), AC_KillOne_f(), AC_UpdateMenu(), AII_BaseCanShoot(), AIM_AircraftStart_f(), AIR_AircraftAllowed(), AIR_CanIntercept(), AIR_CheckMoveIntoNewHomebase(), AIR_UpdateHangarCapForOne(), AIRFIGHT_CampaignRunBaseDefence(), AL_AddAliens(), AL_ChangeAliveAlienNumber(), AL_CheckAliveFreeSpace(), AL_CountAll(), AL_CountForMenu(), B_BuildFromTemplate(), B_BuildingOpenAfterClick(), B_CheckBuildingDependencesStatus(), B_CheckUpdateBuilding(), B_GetBuildingInBaseByType(), B_GetInstallationLimit(), B_GetMaxBuildingLevel(), B_ManageAntimatter(), B_ResetAllStatusAndCapacities(), B_SetUpFirstBase(), B_UpdateStatusBuilding(), BaseSummary_Init(), BS_BuyAircraft_f(), BS_BuySellAllowed(), CL_PopupInterceptClick_f(), CL_ResearchType_f(), CP_BaseAttackChooseBase(), E_HireAllowed(), HOS_HospitalAllowed(), HOS_HospitalRun(), HOS_Init_f(), PR_ProductionAllowed(), PR_QueueNew(), RS_ResearchAllowed(), RS_ResearchStart_f(), RS_ResearchStop_f(), TR_CheckAircraft(), TR_CheckItem(), TR_EmptyTransferCargo(), TR_TransferBaseSelect(), TR_TransferList_Scroll_f(), TR_TransferListSelect_f(), TR_TransferSelect(), and UFO_CampaignCheckEvents().

building_t* B_GetBuildingTemplate ( const char *  buildingName  ) 

Returns the building in the global building-types list that has the unique name buildingID.

Parameters:
[in] buildingName The unique id of the building (building_t->id).
Returns:
building_t If a building was found it is returned, if no id was give the current building is returned, otherwise->NULL.

Definition at line 1316 of file cp_base.c.

References ccs_s::buildingTemplates, ccs, Com_Printf(), i, building_s::id, and ccs_s::numBuildingTemplates.

Referenced by B_CheckBuildingStatusForMenu_f(), B_LoadXML(), B_ParseBuildings(), UI_BaseMapNodeDraw(), and UP_BuildingDescription().

buildingType_t B_GetBuildingTypeByBuildingID ( const char *  buildingID  ) 

Returns the building type for a given building identified by its building id from the ufo script files.

See also:
B_ParseBuildings
B_GetBuildingType
Note:
Do not use B_GetBuildingType here, this is also used for parsing the types!

Definition at line 1616 of file cp_base.c.

References B_ALIEN_CONTAINMENT, B_ANTIMATTER, B_COMMAND, B_DEFENCE_LASER, B_DEFENCE_MISSILE, B_ENTRANCE, B_HANGAR, B_HOSPITAL, B_LAB, B_POWER, B_QUARTERS, B_RADAR, B_SMALL_HANGAR, B_STORAGE, B_WORKSHOP, and MAX_BUILDING_TYPE.

Referenced by B_ParseBuildings().

buildingType_t B_GetBuildingTypeByCapacity ( baseCapacities_t  cap  ) 

Get building type by base capacity.

Parameters:
[in] cap Enum type of baseCapacities_t.
Returns:
Enum type of buildingType_t.
See also:
B_UpdateBaseCapacities
B_PrintCapacities_f

Definition at line 191 of file cp_base.c.

References B_ALIEN_CONTAINMENT, B_ANTIMATTER, B_HANGAR, B_LAB, B_QUARTERS, B_SMALL_HANGAR, B_STORAGE, B_WORKSHOP, CAP_AIRCRAFT_BIG, CAP_AIRCRAFT_SMALL, CAP_ALIENS, CAP_ANTIMATTER, CAP_EMPLOYEES, CAP_ITEMS, CAP_LABSPACE, CAP_WORKSPACE, and MAX_BUILDING_TYPE.

Referenced by AIR_CheckMoveIntoNewHomebase(), B_ResetAllStatusAndCapacities(), and B_UpdateBaseCapacities().

baseCapacities_t B_GetCapacityFromBuildingType ( buildingType_t  type  ) 

Get the capacity associated to a building type.

Parameters:
[in] type The type of the building
Returns:
capacity (baseCapacities_t), or MAX_CAP if building has no capacity

Definition at line 160 of file cp_base.c.

References B_ALIEN_CONTAINMENT, B_ANTIMATTER, B_HANGAR, B_LAB, B_QUARTERS, B_SMALL_HANGAR, B_STORAGE, B_WORKSHOP, CAP_AIRCRAFT_BIG, CAP_AIRCRAFT_SMALL, CAP_ALIENS, CAP_ANTIMATTER, CAP_EMPLOYEES, CAP_ITEMS, CAP_LABSPACE, CAP_WORKSPACE, and MAX_CAP.

Referenced by B_BuildingDestroy(), B_MarkBuildingDestroy(), B_RemoveAircraftExceedingCapacity(), B_UpdateAllBaseBuildingStatus(), and BaseSummary_Init().

base_t* B_GetCurrentSelectedBase ( void   ) 

Definition at line 1953 of file cp_base.c.

References B_GetBaseByIDX(), i, MAX_BASES, and base_s::selected.

Referenced by AC_AlienClick_f(), AC_Init_f(), AC_KillAll_f(), AC_KillOne_f(), AIM_AircraftEquipAddItem_f(), AIM_AircraftEquipMenuUpdate(), AIM_AircraftEquipRemoveItem_f(), AIM_AircraftEquipSlotSelect_f(), AIM_AircraftEquipZoneSelect_f(), AIM_AircraftReturnToBase_f(), AIM_AircraftStart_f(), AIM_SelectAircraft_f(), AIM_UpdateItemDescription(), AIR_AircraftUpdateList_f(), AIR_ChangeAircraftName_f(), B_AssembleMap_f(), B_BaseInit_f(), B_BuildingClick_f(), B_BuildingDestroy_f(), B_BuildingInfoClick_f(), B_BuildingInit_f(), B_BuildingStatus_f(), B_ChangeBaseName_f(), B_CheckBuildingStatusForMenu_f(), B_NextBase_f(), B_PrevBase_f(), B_ResetBuildingCurrent_f(), BaseSummary_SelectBase_f(), BDEF_AddItem_f(), BDEF_BaseDefenceMenuUpdate_f(), BDEF_ChangeAutoFire(), BDEF_RemoveItem_f(), BDEF_SelectItem_f(), BS_Autosell_f(), BS_BuyAircraft_f(), BS_BuyItem_f(), BS_BuyType_f(), BS_MarketScroll_f(), BS_SellAircraft_f(), BS_SellItem_f(), CL_ActorPilotSelect_f(), CL_ActorTeamSelect_f(), CL_AssignPilot_f(), CL_AssignSoldier_f(), CL_ResearchSelect_f(), CL_ResearchType_f(), CL_UpdateEmployeeList(), CL_UpdateEquipmentMenuParameters_f(), E_EmployeeHire_f(), E_EmployeeList_f(), E_EmployeeListScroll_f(), E_EmployeeSelect(), E_UpdateGUICount_f(), HOS_Init_f(), HOS_ListClick_f(), HOS_UpdateMenu(), PR_ProductionDecrease_f(), PR_ProductionDown_f(), PR_ProductionIncrease_f(), PR_ProductionList_f(), PR_ProductionListClick_f(), PR_ProductionListRightClick_f(), PR_ProductionRollBottom_f(), PR_ProductionStop_f(), PR_ProductionType_f(), PR_ProductionUp_f(), RS_AssignScientist_f(), RS_ChangeScientist_f(), RS_RemoveScientist_f(), RS_ResearchStart_f(), RS_ResearchStop_f(), RS_UpdateData_f(), TR_CargoListSelect_f(), TR_Init_f(), TR_InitBaseList(), TR_SelectBase_f(), TR_TransferClose_f(), TR_TransferList_Scroll_f(), TR_TransferListClear_f(), TR_TransferListSelect_f(), TR_TransferSelect_f(), TR_TransferStart_f(), UI_BaseMapNodeClick(), UI_BaseMapNodeDraw(), UI_BaseMapNodeDrawTooltip(), UI_BaseMapNodeMiddleClick(), UI_BaseMapNodeRightClick(), and UI_ResearchInit_f().

base_t* B_GetFirstUnfoundedBase ( void   ) 

Get the lower IDX of unfounded base.

Returns:
baseIdx of first Base Unfounded, or MAX_BASES is maximum base number is reached.

Definition at line 1910 of file cp_base.c.

References B_GetBaseByIDX(), base_s::founded, and MAX_BASES.

Referenced by B_BuildBase_f().

base_t* B_GetFoundedBaseByIDX ( int  baseIdx  ) 

Array bound check for the base index.

Parameters:
[in] baseIdx Index to check
Returns:
Pointer to the base corresponding to baseIdx if base is founded, NULL else.

Definition at line 67 of file cp_base.c.

References B_GetBaseByIDX(), and base_s::founded.

Referenced by AB_UpdateStealthForAllBase(), AC_LoadXML(), AC_SaveXML(), AII_RepairAircraft(), AII_UpdateInstallationDelay(), AIR_AircraftGetFromIDX(), AIR_AircraftsNotifyMissionRemoved(), AIR_AircraftsNotifyUFORemoved(), AIR_IsEmployeeInAircraft(), AIR_PostLoadInitMissions(), AIR_RemoveEmployee(), AIR_SaveXML(), AIRFIGHT_CampaignRunBaseDefence(), AL_CountAll(), AL_CountForMenu(), B_BuildingOnDestroy_f(), B_Destroy_AntimaterStorage_f(), B_GetInstallationLimit(), B_NextBase_f(), B_PostLoadInitCapacity(), B_PrevBase_f(), B_SelectBase_f(), B_UpdateBaseData(), BaseSummary_SelectBase_f(), BDEF_AutoSelectTarget(), BDEF_RemoveBattery_f(), CL_DisplayHomebasePopup(), CL_DisplayPopupInterceptMission(), CL_DisplayPopupInterceptUFO(), CL_PopupChangeHomebase_f(), CL_PopupInterceptBaseClick_f(), CL_StatsUpdate_f(), CP_BaseAttackChooseBase(), CP_CheckBaseAttacks_f(), CP_NationHandleBudget(), E_DeleteEmployee(), MAP_DrawMapMarkers(), MAP_GetGeoscapeAngle(), MAP_MapClick(), MAP_MultiSelectExecuteAction_f(), MAP_PositionCloseToBase(), PR_ProductionQueueBase(), PR_ProductionRun(), RADAR_AddDetectedUFOToEveryRadar(), RADAR_CheckRadarSensored(), RADAR_DeactivateRadarOverlay(), RADAR_NotifyUFORemoved(), RADAR_UpdateBaseRadarCoverage_f(), RADAR_UpdateStaticRadarCoverage(), RADAR_UpdateWholeRadarOverlay(), RS_InitGUI(), RS_InitGUIData(), RS_InitTree(), RS_MarkStoryLineEventResearched(), TR_Init_f(), TR_InitBaseList(), TR_SelectBase_f(), TR_TransferAlienAfterMissionStart(), TR_TransferAliensFromMission_f(), TR_TransferBaseListClick_f(), UFO_CampaignCheckEvents(), UFO_SearchAircraftTarget(), and UFO_UpdateAlienInterestForAllBasesAndInstallations().

int B_GetFoundedBaseCount ( void   ) 

Counts the number of bases.

Returns:
The number of founded bases.

Definition at line 2428 of file cp_base.c.

References ccs_s::bases, ccs, and base_s::founded.

Referenced by B_LoadXML().

int B_GetInstallationLimit ( void   ) 

Counts the actual installation count limit.

Returns:
int number of installations can be built

Definition at line 1252 of file cp_base.c.

References B_COMMAND, B_GetBuildingStatus(), B_GetFoundedBaseByIDX(), ccs, i, MAX_INSTALLATIONS, MAX_INSTALLTAIONS_PER_BASE, and ccs_s::numBases.

Referenced by INS_BuildInstallation_f(), INS_GetFirstUnfoundedInstallation(), INS_SelectInstallation(), and INS_UpdateInsatallationLimit_f().

float B_GetMaxBuildingLevel ( const base_t base,
const buildingType_t  type 
)

Get the maximum level of a building type in a base.

Parameters:
[in] base Pointer to base.
[in] type Building type to get the maximum level for.
Note:
This function checks base status for particular buildings.
Returns:
0.0f if there is no (operational) building of the requested type in the base, otherwise the maximum level.

Definition at line 327 of file cp_base.c.

References B_GetBuildingStatus(), B_GetNextBuildingByType(), B_STATUS_WORKING, building_s::buildingStatus, and building_s::level.

Referenced by B_LoadXML(), and RADAR_UpdateBaseRadarCoverage_f().

building_t* B_GetNextBuilding ( const base_t base,
building_t lastBuilding 
)

Iterates through buildings in a base.

Parameters:
[in] base Pointer to the base which buildings asked
[in] lastBuilding Pointer to the building iterate from. Call with NULL to get the first one.

Definition at line 82 of file cp_base.c.

References ccs_s::buildings, ccs, base_s::idx, and ccs_s::numBuildings.

Referenced by B_GetNextBuildingByType(), B_GetNumberOfBuildingsInBaseByTemplate(), B_ResetAllStatusAndCapacities(), B_SaveXML(), B_UpdateBaseData(), B_UpdateStatusBuilding(), and CP_GetSalaryUpKeepBase().

building_t* B_GetNextBuildingByType ( const base_t base,
building_t lastBuilding,
buildingType_t  buildingType 
)

Iterates throught buildings of a type in a base.

Parameters:
[in] base Pointer to the base which buildings asked
[in] lastBuilding Pointer to the building iterate from. Call with NULL to get the first one.
[in] buildingType Type of the buildings to search
See also:
buildingType_t

Definition at line 111 of file cp_base.c.

References B_GetNextBuilding(), and building_s::buildingType.

Referenced by B_CheckBuildingStatusForMenu_f(), B_CheckBuildingTypeStatus(), B_GetBuildingInBaseByType(), B_GetMaxBuildingLevel(), B_GetNumberOfBuildingsInBaseByBuildingType(), B_UpdateBaseCapacities(), and BDEF_RemoveBattery_f().

int B_GetNumberOfBuildingsInBaseByBuildingType ( const base_t base,
const buildingType_t  buildingType 
)

Counts the number of buildings of a particular buuilding type in a base.

Parameters:
[in] base Which base to count in.
[in] buildingType Building type value.
Returns:
The number of buildings.
-1 on error (e.g. base index out of range)

Definition at line 1587 of file cp_base.c.

References B_GetNextBuildingByType(), B_STATUS_NOT_SET, building_s::buildingStatus, Com_Printf(), and MAX_BUILDING_TYPE.

Referenced by B_BuildingDestroy(), B_CheckBuildingStatusForMenu_f(), BaseSummary_Init(), CP_BaseAttackStartMission(), PR_ProductionList_f(), and PR_QueueFreeSpace().

int B_GetNumberOfBuildingsInBaseByTemplate ( const base_t base,
const building_t tpl 
)

Counts the number of buildings of a particular type in a base.

Parameters:
[in] base Which base to count in.
[in] tpl The template type in the ccs.buildingTemplates list.
Returns:
The number of buildings.
-1 on error (e.g. base index out of range)

Definition at line 1551 of file cp_base.c.

References B_GetNextBuilding(), B_STATUS_NOT_SET, building_s::buildingStatus, Com_Printf(), and building_s::tpl.

Referenced by B_BuildingInit(), and B_BuildingStatus().

static void B_InitialEquipment ( base_t base,
aircraft_t assignInitialAircraft,
const char *  eqname,
equipDef_t edTarget 
) [static]

Prepares initial equipment for first base at the beginning of the campaign.

Parameters:
[in] base Pointer to first base.
[in] assignInitialAircraft aircraft on which the soldiers (to equip) are
[in] eqname Initial equipment definition id
[in] edTarget storage to put items to
See also:
B_BuildBase_f
Todo:
Make sure all equipment including soldiers equipment is added to capacity.cur.

Definition at line 1084 of file cp_base.c.

References B_PackInitialEquipment(), CAP_ITEMS, base_s::capacities, ccs, CL_UpdateCredits(), ccs_s::credits, csi, cap_maxcur_s::cur, i, INV_GetEquipmentDefinitionByID(), INVSH_GetItemByIDX(), equipDef_s::numItems, csi_s::numODs, objDef_s::price, and objDef_s::size.

Referenced by B_SetUpFirstBase().

void B_InitStartup ( void   ) 

Resets console commands.

See also:
UI_InitStartup

Definition at line 2410 of file cp_base.c.

References Cmd_AddCommand(), and Cvar_Get().

Referenced by CP_InitStartup().

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.

Parameters:
[in] item The item to check
[in] base The base to search in.
Returns:
amount Number of available items in base

Definition at line 2629 of file cp_base.c.

References objDef_s::idx, objDef_s::isVirtual, equipDef_s::numItems, and base_s::storage.

Referenced by AIR_Refuel(), PR_RequirementsMet(), RS_RequirementsMet(), TR_TransferListSelect_f(), and TR_TransferSelect().

qboolean B_ItemIsStoredInBaseStorage ( const objDef_t obj  ) 

Check if an item is stored in storage.

Parameters:
[in] obj Pointer to the item to check.
Returns:
True if item is stored in storage.

Definition at line 3035 of file cp_base.c.

References ANTIMATTER_TECH_ID, objDef_s::id, objDef_s::isVirtual, qfalse, and qtrue.

Referenced by B_AddToStorage(), B_RemoveItemsExceedingCapacity(), B_UpdateStorageAndCapacity(), B_UpdateStorageCap(), CP_ItemsSanityCheck(), TR_EmptyTransferCargo(), TR_TransferList_Scroll_f(), TR_TransferListSelect_f(), and TR_TransferSelect().

int B_LoadBaseSlotsXML ( baseWeapon_t weapons,
int  max,
mxml_node_t p 
)

Loads the missile and laser slots of a base or sam site.

Parameters:
[out] weapons Defence weapons array
[out] max Number of entries in weapons array
[in] p XML Node structure, where we load the information from
See also:
B_Load
B_SaveBaseSlots

Definition at line 2833 of file cp_base.c.

References AII_LoadOneSlotXML(), baseWeapon_s::autofire, mxml_GetBool(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), qtrue, SAVE_BASES_AUTOFIRE, SAVE_BASES_TARGET, SAVE_BASES_WEAPON, baseWeapon_s::target, and UFO_GetByIDX().

Referenced by B_LoadXML(), and INS_LoadXML().

qboolean B_LoadStorageXML ( mxml_node_t parent,
equipDef_t equip 
)

Loads base storage.

Parameters:
[in] parent XML Node structure, where we get the information from
[out] equip Storage to load

Definition at line 2877 of file cp_base.c.

References Com_Printf(), objDef_s::idx, INVSH_GetItemByID(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetString(), equipDef_s::numItems, equipDef_s::numItemsLoose, qtrue, SAVE_BASES_ITEM, SAVE_BASES_NUM, SAVE_BASES_NUMLOOSE, and SAVE_BASES_ODS_ID.

Referenced by B_LoadXML().

qboolean B_LoadXML ( mxml_node_t parent  ) 

Loads base data.

Parameters:
[in] parent XML Node structure, where we get the information from

Todo:
this must be set after the aircraft are loaded
Todo:
can't we use something like I_DestroyInventory here?

Definition at line 2898 of file cp_base.c.

References AIRCRAFT_INBASE_INVALID, base_s::aircraftCurrent, base_s::alienInterest, B_GetBaseByIDX(), B_GetBaseIDX, B_GetBuildingIDX, B_GetBuildingTemplate(), B_GetFoundedBaseCount(), B_GetMaxBuildingLevel(), B_LoadBaseSlotsXML(), B_LoadStorageXML(), B_RADAR, B_UpdateBaseCount(), building_s::base, base_s::baseStatus, base_s::batteries, BDEF_InitialiseBaseSlots(), base_s::bEquipment, baseBuildingTile_s::blocked, baseBuildingTile_s::building, ccs_s::buildings, building_s::buildingStatus, building_s::buildTime, ccs, Com_GetConstIntFromNamespace(), Com_Printf(), Com_RegisterConstList(), Com_UnregisterConstList(), base_s::founded, building_s::idx, base_s::idx, base_s::lasers, building_s::level, base_s::map, MAX_BASE_SLOT, MAX_BUILDINGS, MAX_VAR, mxml_GetBool(), mxml_GetFloat(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetPos2(), mxml_GetPos3(), mxml_GetString(), base_s::name, ccs_s::numBases, base_s::numBatteries, ccs_s::numBuildings, base_s::numLasers, building_s::pos, base_s::pos, Q_strncpyz(), qfalse, qtrue, base_s::radar, RADAR_Initialise(), RADAR_InitialiseUFOs(), SAVE_BASES_ALIENINTEREST, SAVE_BASES_BASE, SAVE_BASES_BASESTATUS, SAVE_BASES_BATTERIES, SAVE_BASES_BLOCKED, SAVE_BASES_BUILDING, SAVE_BASES_BUILDING_PLACE, SAVE_BASES_BUILDINGBUILDTIME, SAVE_BASES_BUILDINGINDEX, SAVE_BASES_BUILDINGLEVEL, SAVE_BASES_BUILDINGS, SAVE_BASES_BUILDINGSPACE, SAVE_BASES_BUILDINGSTATUS, SAVE_BASES_BUILDINGTIMESTART, SAVE_BASES_BUILDINGTYPE, SAVE_BASES_CURRENTAIRCRAFTIDX, SAVE_BASES_LASERS, SAVE_BASES_NAME, SAVE_BASES_POS, SAVE_BASES_RADARRANGE, SAVE_BASES_STORAGE, SAVE_BASES_TRACKINGRANGE, SAVE_BASES_X, SAVE_BASES_Y, SAVE_BASESTATUS_NAMESPACE, SAVE_BUILDINGSTATUS_NAMESPACE, saveBaseConstants, base_s::storage, and building_s::timeStart.

Referenced by SAV_Init().

void B_ManageAntimatter ( base_t base,
int  amount,
qboolean  add 
)

Manages antimatter (adding, removing) through Antimatter Storage Facility.

Parameters:
[in] base Pointer to the base.
[in] amount quantity of antimatter to add/remove (> 0 even if antimatter is removed)
[in] add True if we are adding antimatter, false when removing.
Note:
This function should be called whenever we add or remove antimatter from Antimatter Storage Facility.
Call with amount = 0 if you want to remove ALL antimatter from given base.

Definition at line 3284 of file cp_base.c.

References _, ANTIMATTER_TECH_ID, B_ANTIMATTER, B_GetBuildingStatus(), CAP_ANTIMATTER, base_s::capacities, Com_Error(), Com_sprintf(), cp_messageBuffer, cap_maxcur_s::cur, ERR_DROP, objDef_s::idx, INVSH_GetItemByIDSilent(), lengthof, cap_maxcur_s::max, MS_AddNewMessage(), MSG_STANDARD, base_s::name, equipDef_s::numItems, qfalse, and base_s::storage.

Referenced by AIR_Refuel(), B_RemoveAntimatterExceedingCapacity(), PR_DisassembleItem(), PR_UpdateRequiredItemsInBasestorage(), TR_CargoListSelect_f(), TR_EmptyTransferCargo(), TR_TransferListClear_f(), and TR_TransferListSelect_f().

void B_MarkBuildingDestroy ( base_t base,
building_t building 
)

Mark a building for destruction - you only have to confirm it now.

Note:
Also calls the ondestroy trigger

Todo:
: make base destroyable by destroying entrance

Definition at line 889 of file cp_base.c.

References _, B_ENTRANCE, B_GetCapacityFromBuildingType(), B_HANGAR, B_QUARTERS, B_SMALL_HANGAR, B_STATUS_WORKING, B_STORAGE, BASE_UNDER_ATTACK, base_s::baseStatus, base_s::buildingCurrent, building_s::buildingStatus, building_s::buildingType, base_s::capacities, building_s::capacity, ccs, cap_maxcur_s::cur, cap_maxcur_s::max, ccs_s::numBases, UI_Popup(), and UI_PopupButton().

Referenced by UI_BaseMapNodeRightClick().

static void B_MoveAircraftOnGeoscapeToOtherBases ( const base_t base  )  [static]

Will ensure that aircraft on geoscape are not stored in a base that no longer has any hangar left.

Parameters:
base The base that is going to be destroyed

Todo:
What should happen with it if no other base has enough free storage for it? Spawn a dropship crash mission if no more fuel?

Definition at line 802 of file cp_base.c.

References AIR_DestroyAircraft(), AIR_GetNextFromBase(), AIR_IsAircraftOnGeoscape(), AIR_MoveAircraftIntoNewHomebase(), B_GetBaseByIDX(), ccs, and ccs_s::numBases.

Referenced by B_Destroy().

static void B_NewBuilding ( base_t base,
building_t building 
) [static]

Build new building.

Parameters:
[in,out] base The base to construct the building in
[in,out] building The building to construct
See also:
B_MarkBuildingDestroy
B_ConstructBuilding

Definition at line 1407 of file cp_base.c.

References B_BuildingStatus(), B_ConstructBuilding(), B_STATUS_UNDER_CONSTRUCTION, building_s::buildingStatus, Com_DPrintf(), and DEBUG_CLIENT.

Referenced by B_SetBuildingByClick().

static void B_PackInitialEquipment ( aircraft_t aircraft,
const equipDef_t ed 
) [static]

Assigns initial soldier equipment for the first base.

Todo:
Move this function to a better place - has nothing to do with bases anymore

Definition at line 2121 of file cp_base.c.

References aircraft_s::acTeam, AIR_MoveEmployeeInventoryIntoStorage(), B_UpdateStorageCap(), chr_list_s::chr, employee_s::chr, CL_SwapSkills(), cls, Com_DPrintf(), linkedList_s::data, DEBUG_CLIENT, inventoryInterface_s::EquipActor, aircraft_s::homebase, client_static_s::i, linkedList_s::next, chr_list_s::num, and base_s::storage.

Referenced by B_InitialEquipment().

void B_ParseBaseTemplate ( const char *  name,
const char **  text 
)
void B_ParseBuildings ( const char *  name,
const char **  text,
qboolean  link 
)

Copies an entry from the building description file into the list of building types.

Note:
Parses one "building" entry in the basemanagement.ufo file and writes it into the next free entry in bmBuildings[0], which is the list of buildings in the first base (building_t).
Parameters:
[in] name Unique test-id of a building_t. This is parsed from "building xxx" -> id=xxx.
[in] text the whole following text that is part of the "building" item definition in .ufo.
[in] link Bool value that decides whether to link the tech pointer in or not
See also:
CL_ParseScriptFirst (link is false here)
CL_ParseScriptSecond (link it true here)

Definition at line 1665 of file cp_base.c.

References B_GetBuildingTemplate(), B_GetBuildingTypeByBuildingID(), building_s::base, ccs_s::buildingTemplates, building_s::buildingType, ccs, Com_DPrintf(), Com_EParse(), Com_EParseValue(), Com_Error(), Com_Parse(), Com_Printf(), cp_campaignPool, DEBUG_CLIENT, building_s::dependsBuilding, ERR_DROP, i, building_s::id, building_s::idx, MAX_BUILDING_TYPE, MAX_BUILDINGS, building_s::maxCount, Mem_PoolStrDup, Mem_PoolStrDupTo, ccs_s::numBuildingTemplates, value_s::ofs, qtrue, RS_GetTechByProvided(), value_s::size, value_s::string, building_s::tech, building_s::tpl, value_s::type, V_CLIENT_HUNK_STRING, V_NULL, V_TRANSLATION_STRING, and building_s::visible.

Referenced by CL_ParseScriptFirst(), and CL_ParseScriptSecond().

void B_PostLoadInit ( void   ) 

Set the capacity stuff for all the bases after loading a savegame.

See also:
SAV_GameActionsAfterLoad

Definition at line 2867 of file cp_base.c.

References B_PostLoadInitCapacity().

Referenced by SAV_GameActionsAfterLoad().

static void B_PostLoadInitCapacity ( void   )  [static]

Set the capacity stuff for all the bases after loading a savegame.

See also:
B_PostLoadInit

Definition at line 2850 of file cp_base.c.

References B_GetFoundedBaseByIDX(), B_ResetAllStatusAndCapacities(), and qtrue.

Referenced by B_PostLoadInit().

void B_RemoveAircraftExceedingCapacity ( base_t base,
buildingType_t  buildingType 
)

Actions to perform when destroying one hangar.

Parameters:
[in] base Pointer to the base where hangar is destroyed.
[in] buildingType Type of hangar: B_SMALL_HANGAR for small hangar, B_HANGAR for large hangar
Note:
called when player destroy its building or hangar is destroyed during base attack.
These actions will be performed after we actually remove the building.
Precondition:
we checked before calling this function that all parameters are valid.
building is not under construction.
See also:
B_BuildingDestroy_f
Todo:
If player choose to destroy the building, a popup should ask him if he wants to sell aircraft in it.

Todo:
move aircraft being transfered to the destBase
Todo:
Better solution? let it crash due to technical difficulties and spawn a rescue mission?

Definition at line 650 of file cp_base.c.

References AIR_DeleteAircraft(), AIR_GetNextFromBase(), AIR_IsAircraftInBase(), AIR_IsAircraftOnGeoscape(), AIRCRAFT_LARGE, AIRCRAFT_SMALL, B_GetCapacityFromBuildingType(), B_HANGAR, B_SMALL_HANGAR, base_s::capacities, CL_DisplayHomebasePopup(), Com_Error(), cap_maxcur_s::cur, ERR_DROP, cap_maxcur_s::max, MAX_AIRCRAFT, qfalse, and aircraft_s::size.

Referenced by B_BuildingOnDestroy_f().

void B_RemoveAntimatterExceedingCapacity ( base_t base  ) 

Remove exceeding antimatter if an antimatter tank has been destroyed.

Parameters:
[in] base Pointer to the base.

Definition at line 3322 of file cp_base.c.

References B_ManageAntimatter(), CAP_ANTIMATTER, base_s::capacities, cap_maxcur_s::cur, cap_maxcur_s::max, and qfalse.

Referenced by B_Destroy_AntimaterStorage_f().

void B_RemoveItemsExceedingCapacity ( base_t base  ) 

Remove items until everything fits in storage.

Note:
items will be randomly selected for removal.
Parameters:
[in] base Pointer to the base

< Will contain idx of items that can be removed

Definition at line 3178 of file cp_base.c.

References B_ItemIsStoredInBaseStorage(), B_UpdateStorageAndCapacity(), CAP_ITEMS, base_s::capacities, Com_DPrintf(), csi, cap_maxcur_s::cur, DEBUG_CLIENT, E_CountHired(), E_DeleteEmployee(), E_GetHiredRobot(), EMPL_ROBOT, INVSH_GetItemByIDX(), cap_maxcur_s::max, MAX_OBJDEFS, equipDef_s::numItems, csi_s::numODs, qfalse, REMOVE_ELEM, and base_s::storage.

Referenced by B_BuildingOnDestroy_f().

void B_ResetAllStatusAndCapacities ( base_t base,
qboolean  firstEnable 
)
void B_ResetBuildingCurrent ( base_t base  ) 

Resets the buildingCurrent variable and baseAction.

Parameters:
[in,out] base Pointer to the base needs buildingCurrent to be reseted
Note:
Make sure you are not doing anything with the buildingCurrent pointer in this function, the pointer might already be invalid

Definition at line 283 of file cp_base.c.

References BA_NONE, ccs_s::baseAction, base_s::buildingCurrent, and ccs.

Referenced by B_BuildingDestroy_f(), B_ConstructBuilding(), B_ResetBuildingCurrent_f(), and B_SetBuildingByClick().

void B_SaveBaseSlotsXML ( const baseWeapon_t weapons,
const int  numWeapons,
mxml_node_t node 
)

Saves the missile and laser slots of a base or sam site.

Parameters:
[in] weapons Defence weapons array
[in] numWeapons Number of entries in weapons array
[out] node XML Node structure, where we write the information to

Definition at line 2713 of file cp_base.c.

References AII_SaveOneSlotXML(), mxml_AddBoolValue(), mxml_AddInt(), mxml_AddNode(), qtrue, SAVE_BASES_AUTOFIRE, SAVE_BASES_TARGET, and SAVE_BASES_WEAPON.

Referenced by B_SaveXML(), and INS_SaveXML().

qboolean B_SaveStorageXML ( mxml_node_t parent,
const equipDef_t  equip 
)

Saves base storage.

Parameters:
[out] parent XML Node structure, where we write the information to
[in] equip Storage to save

Definition at line 2731 of file cp_base.c.

References csi, objDef_s::id, INVSH_GetItemByIDX(), mxml_AddByteValue(), mxml_AddIntValue(), mxml_AddNode(), mxml_AddString(), equipDef_s::numItems, equipDef_s::numItemsLoose, csi_s::numODs, qtrue, SAVE_BASES_ITEM, SAVE_BASES_NUM, SAVE_BASES_NUMLOOSE, and SAVE_BASES_ODS_ID.

Referenced by B_SaveXML().

qboolean B_SaveXML ( mxml_node_t parent  ) 

Save callback for saving in xml format.

Parameters:
[out] parent XML Node structure, where we write the information to

Definition at line 2750 of file cp_base.c.

References AIR_GetAircraftIDXInBase(), base_s::aircraftCurrent, base_s::alienInterest, B_GetBaseByIDX(), B_GetNextBuilding(), B_SaveBaseSlotsXML(), B_SaveStorageXML(), base_s::baseStatus, base_s::batteries, baseBuildingTile_s::blocked, baseBuildingTile_s::building, building_s::buildingStatus, building_s::buildTime, ccs, Com_GetConstVariable(), Com_Printf(), Com_RegisterConstList(), Com_UnregisterConstList(), base_s::founded, building_s::id, building_s::idx, base_s::idx, base_s::lasers, building_s::level, base_s::map, mxml_AddBoolValue(), mxml_AddFloat(), mxml_AddInt(), mxml_AddIntValue(), mxml_AddNode(), mxml_AddPos2(), mxml_AddPos3(), mxml_AddString(), base_s::name, ccs_s::numBases, base_s::numBatteries, base_s::numLasers, building_s::pos, base_s::pos, qfalse, qtrue, base_s::radar, radar_s::range, SAVE_BASES_ALIENINTEREST, SAVE_BASES_BASE, SAVE_BASES_BASES, SAVE_BASES_BASESTATUS, SAVE_BASES_BATTERIES, SAVE_BASES_BLOCKED, SAVE_BASES_BUILDING, SAVE_BASES_BUILDING_PLACE, SAVE_BASES_BUILDINGBUILDTIME, SAVE_BASES_BUILDINGINDEX, SAVE_BASES_BUILDINGLEVEL, SAVE_BASES_BUILDINGS, SAVE_BASES_BUILDINGSPACE, SAVE_BASES_BUILDINGSTATUS, SAVE_BASES_BUILDINGTIMESTART, SAVE_BASES_BUILDINGTYPE, SAVE_BASES_CURRENTAIRCRAFTIDX, SAVE_BASES_LASERS, SAVE_BASES_NAME, SAVE_BASES_POS, SAVE_BASES_RADARRANGE, SAVE_BASES_STORAGE, SAVE_BASES_TRACKINGRANGE, SAVE_BASES_X, SAVE_BASES_Y, SAVE_BASESTATUS_NAMESPACE, SAVE_BUILDINGSTATUS_NAMESPACE, saveBaseConstants, base_s::storage, building_s::timeStart, building_s::tpl, and radar_s::trackingRange.

Referenced by SAV_Init().

qboolean B_ScriptSanityCheck ( void   ) 

Checks the parsed buildings for errors.

Returns:
false if there are errors - true otherwise

Definition at line 3141 of file cp_base.c.

References ccs_s::buildingTemplates, ccs, Com_Printf(), error(), building_s::id, building_s::image, building_s::mapPart, building_s::name, ccs_s::numBuildingTemplates, building_s::pedia, qfalse, qtrue, RS_GetTechByID(), and building_s::visible.

void B_SelectBase ( const base_t base  ) 
static void B_SellOrAddItems ( aircraft_t aircraft  )  [static]
building_t* B_SetBuildingByClick ( base_t base,
const building_t const *  buildingTemplate,
int  row,
int  col 
)

Set the currently selected building.

Parameters:
[in,out] base The base to place the building in
[in] buildingTemplate The template of the building to place at the given location
[in] row Set building to row
[in] col Set building to col
Returns:
building created in base (this is not a building template)

Definition at line 1429 of file cp_base.c.

References _, B_CheckCredits(), B_GetBuildingIDX, B_NewBuilding(), B_ResetBuildingCurrent(), building_s::base, BASE_SIZE, baseBuildingTile_s::blocked, baseBuildingTile_s::building, ccs_s::buildings, ccs, Cmd_ExecuteString(), Com_DPrintf(), Com_Error(), DEBUG_CLIENT, ERR_DROP, building_s::fixCosts, building_s::idx, base_s::idx, base_s::map, building_s::needs, ccs_s::numBuildings, building_s::pos, and UI_Popup().

Referenced by B_AddBuildingToBasePos(), and UI_BaseMapNodeClick().

void B_SetBuildingStatus ( base_t *const   base,
const buildingType_t  buildingType,
qboolean  newStatus 
)

Set status associated to a building.

Parameters:
[in] base Base to check
[in] buildingType value of building->buildingType
[in] newStatus New value of the status
See also:
B_GetBuildingStatus

Definition at line 244 of file cp_base.c.

References B_MISC, Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, base_s::hasBuilding, and MAX_BUILDING_TYPE.

Referenced by B_BuildingDestroy(), B_CheckUpdateBuilding(), and B_ResetAllStatusAndCapacities().

void B_SetCurrentSelectedBase ( const base_t base  ) 
void B_SetUpBase ( base_t base,
vec2_t  pos 
)

Setup new base, uses template for the first base.

Parameters:
[in,out] base The base to set up
[in] pos Position (on Geoscape) the base built at
See also:
B_NewBase
B_SetUpFirstBase

Definition at line 1284 of file cp_base.c.

References base_s::aircraft, base_s::alienInterest, B_BuildFromTemplate(), B_GetBaseIDX, B_SetUpFirstBase(), BASE_WORKING, stats_s::basesBuilt, base_s::baseStatus, BDEF_InitialiseBaseSlots(), ccs_s::campaignStats, ccs, base_s::founded, base_s::idx, LIST_Delete(), base_s::pos, qtrue, base_s::radar, RADAR_Initialise(), RADAR_InitialiseUFOs(), and Vector2Copy.

Referenced by B_BuildBase_f().

static void B_SetUpFirstBase ( base_t base  )  [static]
static void B_UpdateAllBaseBuildingStatus ( building_t building,
base_t base,
buildingStatus_t  status 
) [static]

Updates base status for particular buildings as well as capacities.

Parameters:
[in] building Pointer to building.
[in] base Pointer to base with given building.
[in] status Enum of buildingStatus_t which is status of given building.
Note:
This function checks whether a building has B_STATUS_WORKING status, and then updates base status for particular buildings and base capacities.

Todo:
this should be an user option defined in Game Options.

Definition at line 1007 of file cp_base.c.

References B_CheckBuildingDependencesStatus(), B_CheckUpdateBuilding(), B_GetCapacityFromBuildingType(), B_STATUS_CONSTRUCTION_FINISHED, B_STATUS_UNDER_CONSTRUCTION, B_STATUS_WORKING, B_UpdateBaseCapacities(), B_UpdateOneBaseBuildingStatusOnEnable(), B_UpdateStatusBuilding(), building_s::buildingStatus, building_s::buildingType, CL_GameTimeStop(), MAX_CAP, and qtrue.

Referenced by B_AddBuildingToBasePos(), and B_CheckBuildingConstruction().

static void B_UpdateAntimatterCap ( base_t base  )  [static]

Update Antimatter Capacity.

Parameters:
[in] base Pointer to the base
See also:
B_ResetAllStatusAndCapacities_f

Definition at line 554 of file cp_base.c.

References ANTIMATTER_TECH_ID, CAP_ANTIMATTER, base_s::capacities, cap_maxcur_s::cur, objDef_s::idx, INVSH_GetItemByID(), equipDef_s::numItems, and base_s::storage.

Referenced by B_ResetAllStatusAndCapacities().

void B_UpdateBaseCapacities ( baseCapacities_t  cap,
base_t base 
)

Updates base capacities.

Parameters:
[in] cap Enum type of baseCapacities_t.
[in] base Pointer to the base.
See also:
B_UpdateAllBaseBuildingStatus
B_BuildingDestroy_f
Note:
If hasBuilding is qfalse, the capacity is still increase: if power plant is destroyed and rebuilt, you shouldn't have to hire employees again

< Update Aliens capacity in base.

< Update employees capacity in base.

< Update laboratory space capacity in base.

< Update workshop space capacity in base.

< Update items capacity in base.

< Update aircraft capacity in base.

< Update aircraft capacity in base.

< Update antimatter capacity in base.

< Update all capacities in base.

Definition at line 2656 of file cp_base.c.

References B_GetBuildingTypeByCapacity(), B_GetNextBuildingByType(), B_STATUS_CONSTRUCTION_FINISHED, B_UpdateBaseCapacities(), building_s::buildingStatus, ccs_s::buildingTemplates, building_s::buildingType, CAP_AIRCRAFT_BIG, CAP_AIRCRAFT_SMALL, CAP_ALIENS, CAP_ANTIMATTER, CAP_EMPLOYEES, CAP_ITEMS, CAP_LABSPACE, CAP_WORKSPACE, base_s::capacities, building_s::capacity, ccs, Com_DPrintf(), Com_Error(), DEBUG_CLIENT, ERR_DROP, building_s::id, cap_maxcur_s::max, and ccs_s::numBuildingTemplates.

Referenced by B_BuildingDestroy(), B_ResetAllStatusAndCapacities(), B_UpdateAllBaseBuildingStatus(), and B_UpdateBaseCapacities().

void B_UpdateBaseCount ( void   ) 

Update menu script related cvars when the amount of bases changed.

Definition at line 1270 of file cp_base.c.

References ccs, Cvar_SetValue(), and ccs_s::numBases.

Referenced by B_BuildBase_f(), and B_LoadXML().

void B_UpdateBaseData ( void   ) 

Updates base data.

See also:
CL_CampaignRun
Note:
called every "day"
See also:
AIRFIGHT_ProjectileHitsBase

Definition at line 2447 of file cp_base.c.

References _, B_CheckBuildingConstruction(), B_GetFoundedBaseByIDX(), B_GetNextBuilding(), ccs_s::bases, ccs, Com_sprintf(), cp_messageBuffer, lengthof, MS_AddNewMessage(), MSG_CONSTRUCTION, base_s::name, building_s::name, and qfalse.

Referenced by CL_CampaignRun().

static void B_UpdateOneBaseBuildingStatusOnDisable ( buildingType_t  type,
base_t base 
) [static]

Actions to perform when a type of buildings goes from functional to non-functional.

Parameters:
[in] type Type of building which hasBuilding value has been modified from qtrue to qfalse
[in] base Pointer to base with given building.
Note:
That does not mean that a building of this type has been destroyed: maybe one of its dependencies has been destroyed: don't use onDestroy trigger.
See also:
B_UpdateOneBaseBuildingStatusOnEnable
onDestroy trigger

Definition at line 468 of file cp_base.c.

References AC_KillAll(), B_ALIEN_CONTAINMENT, B_COMMAND, B_RADAR, Cmd_ExecuteString(), base_s::idx, and va().

Referenced by B_UpdateStatusBuilding().

static void B_UpdateOneBaseBuildingStatusOnEnable ( buildingType_t  type,
base_t base 
) [static]

Actions to perform when a type of buildings goes from qfalse to qtrue.

Note:
This function is not only called when a building is enabled for the first time in base
but also when one of its dependencies is destroyed and then rebuilt
Parameters:
[in] type Type of building that has been modified from qfalse to qtrue
[in] base Pointer to base with given building.
See also:
B_UpdateOneBaseBuildingStatusOnDisable
onConstruct trigger

Definition at line 445 of file cp_base.c.

References B_COMMAND, B_RADAR, Cmd_ExecuteString(), base_s::idx, and va().

Referenced by B_ResetAllStatusAndCapacities(), B_UpdateAllBaseBuildingStatus(), and B_UpdateStatusBuilding().

static qboolean B_UpdateStatusBuilding ( base_t base,
buildingType_t  buildingType,
qboolean  onBuilt 
) [static]

Update status of every building when a building has been built/destroyed.

Parameters:
[in] base 
[in] buildingType The building-type that has been built / removed.
[in] onBuilt qtrue if building has been built, qfalse else
See also:
B_BuildingDestroy
B_UpdateAllBaseBuildingStatus
Returns:
qtrue if at least one building status has been modified

Definition at line 495 of file cp_base.c.

References B_CheckUpdateBuilding(), B_GetBuildingStatus(), B_GetNextBuilding(), B_UpdateOneBaseBuildingStatusOnDisable(), B_UpdateOneBaseBuildingStatusOnEnable(), building_s::buildingType, building_s::dependsBuilding, qfalse, and qtrue.

Referenced by B_BuildingDestroy(), and B_UpdateAllBaseBuildingStatus().

qboolean B_UpdateStorageAndCapacity ( base_t base,
const objDef_t obj,
int  amount,
qboolean  reset,
qboolean  ignorecap 
)

Update the storage amount and the capacities for the storages in the base.

Parameters:
[in] base The base which storage and capacity should be updated
[in] obj The item.
[in] amount Amount to be added to removed
[in] reset Set this to true (amount is not needed) if you want to reset the storage amount and capacities (e.g. in case of a base ransack)
[in] ignorecap qtrue if we won't check freespace but will just add items.
See also:
CL_BaseRansacked

Definition at line 3093 of file cp_base.c.

References B_ItemIsStoredInBaseStorage(), CAP_ITEMS, base_s::capacities, Com_DPrintf(), Com_Printf(), cap_maxcur_s::cur, DEBUG_CLIENT, objDef_s::id, objDef_s::idx, objDef_s::isVirtual, cap_maxcur_s::max, equipDef_s::numItems, equipDef_s::numItemsLoose, qfalse, qtrue, objDef_s::size, and base_s::storage.

Referenced by AII_AddAmmoToSlot(), AII_AddItemToSlot(), AII_ReloadWeapon(), AII_RemoveItemFromSlot(), AII_RemoveNextItemFromSlot(), AIR_TransferItemsCarriedByCharacterToBase(), B_RemoveItemsExceedingCapacity(), B_SellOrAddItems(), BS_BuyItem_f(), BS_CheckAndDoBuyItem(), BS_SellItem_f(), E_RemoveInventoryFromStorage(), PR_DisassembleItem(), PR_ProductionFrame(), TR_CargoListSelect_f(), TR_EmptyTransferCargo(), TR_TransferListClear_f(), and TR_TransferListSelect_f().

void B_UpdateStorageCap ( base_t base  ) 

Update Storage Capacity.

Parameters:
[in] base Pointer to the base
See also:
B_ResetAllStatusAndCapacities_f

Definition at line 3237 of file cp_base.c.

References B_ItemIsStoredInBaseStorage(), CAP_ITEMS, base_s::capacities, csi, cap_maxcur_s::cur, E_CountHired(), EMPL_ROBOT, INVSH_GetItemByIDX(), equipDef_s::numItems, csi_s::numODs, objDef_s::size, base_s::storage, and UGV_SIZE.

Referenced by B_PackInitialEquipment(), B_ResetAllStatusAndCapacities(), B_SellOrAddItems(), and CP_BaseAttackMissionDestroyBase().

static void CL_DoSwapSkills ( character_t cp1,
character_t cp2,
const int  skill 
) [static]
static void CL_SwapSkill ( character_t cp1,
character_t cp2,
abilityskills_t  skill 
) [static]

Swaps one skill from character1 to character 2 and vice versa.

Definition at line 1999 of file cp_base.c.

References chrScoreGlobal_s::experience, chrScoreGlobal_s::initialSkills, character_s::score, and chrScoreGlobal_s::skills.

Referenced by CL_DoSwapSkills().

static void CL_SwapSkills ( chrList_t team  )  [static]

Swaps skills of the initial team of soldiers so that they match inventories.

Todo:

This currently always uses exactly the first two firemodes (see fmode1+fmode2) for calculation. This needs to be adapted to support less (1) or more 3+ firemodes. I think the function will even break on only one firemode .. never tested it.

i think currently also the different ammo/firedef types for each weapon (different weaponr_fd_idx and weaponr_fd_idx values) are ignored.

Definition at line 2053 of file cp_base.c.

References ABILITY_NUM_TYPES, byte, chr_list_s::chr, CL_DoSwapSkills(), FIRESH_FiredefForWeapon(), HOLSTER, i, chr_list_s::num, RIGHT, SKILL_NUM_TYPES, and fireDef_s::weapFdsIdx.

Referenced by B_PackInitialEquipment().


Variable Documentation

Definition at line 44 of file cp_base.c.

Coordinates to place the new base at (long, lat)

Definition at line 43 of file cp_base.c.

Referenced by B_BuildBase_f(), INS_BuildInstallation_f(), and MAP_MapClick().

const value_t valid_building_vars[] [static]
Initial value:
 {
    {"map_name", V_CLIENT_HUNK_STRING, offsetof(building_t, mapPart), 0},   
    {"max_count", V_INT, offsetof(building_t, maxCount), MEMBER_SIZEOF(building_t, maxCount)},  
    {"level", V_FLOAT, offsetof(building_t, level), MEMBER_SIZEOF(building_t, level)},  
    {"name", V_TRANSLATION_STRING, offsetof(building_t, name), 0},  
    {"pedia", V_CLIENT_HUNK_STRING, offsetof(building_t, pedia), 0},    
    {"status", V_INT, offsetof(building_t, buildingStatus), MEMBER_SIZEOF(building_t, buildingStatus)}, 
    {"image", V_CLIENT_HUNK_STRING, offsetof(building_t, image), 0},    
    {"visible", V_BOOL, offsetof(building_t, visible), MEMBER_SIZEOF(building_t, visible)}, 
    {"needs", V_CLIENT_HUNK_STRING, offsetof(building_t, needs), 0},    
    {"fixcosts", V_INT, offsetof(building_t, fixCosts), MEMBER_SIZEOF(building_t, fixCosts)},   
    {"varcosts", V_INT, offsetof(building_t, varCosts), MEMBER_SIZEOF(building_t, varCosts)},   
    {"build_time", V_INT, offsetof(building_t, buildTime), MEMBER_SIZEOF(building_t, buildTime)},   
    {"starting_employees", V_INT, offsetof(building_t, maxEmployees), MEMBER_SIZEOF(building_t, maxEmployees)}, 
    {"capacity", V_INT, offsetof(building_t, capacity), MEMBER_SIZEOF(building_t, capacity)},   

    
    {"onconstruct", V_STRING, offsetof(building_t, onConstruct), 0}, 
    {"onattack", V_STRING, offsetof(building_t, onAttack), 0}, 
    {"ondestroy", V_STRING, offsetof(building_t, onDestroy), 0}, 
    {"mandatory", V_BOOL, offsetof(building_t, mandatory), MEMBER_SIZEOF(building_t, mandatory)}, 
    {NULL, 0, 0, 0}
}

Holds the names of valid entries in the basemanagement.ufo file.

The valid definition names for BUILDINGS (building_t) in the basemanagement.ufo file. to the appropriate values in the corresponding struct

Definition at line 296 of file cp_base.c.


Generated by  doxygen 1.6.2