UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_base.cpp File Reference

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

#include "../../cl_shared.h"
#include "../../cl_inventory.h"
#include "../../ui/ui_dataids.h"
#include "../../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_mapfightequip.h"
#include "cp_aircraft.h"
#include "cp_missions.h"
#include "cp_geoscape.h"
#include "cp_popup.h"
#include "cp_radar.h"
#include "cp_time.h"
#include "cp_base_callbacks.h"
#include "cp_ufo.h"
#include "save/save_base.h"
#include "aliencontainment.h"
#include "itemcargo.h"

Go to the source code of this file.

Macros

#define B_GetBuildingByIDX(baseIdx, buildingIdx)   (&ccs.buildings[(baseIdx)][(buildingIdx)])
 
#define B_GetBuildingIDX(base, building)   ((ptrdiff_t)((building) - ccs.buildings[base->idx]))
 
#define B_GetBaseIDX(base)   ((ptrdiff_t)((base) - ccs.bases))
 

Functions

static void B_InitialEquipment (aircraft_t *aircraft, const equipDef_t *ed)
 Prepares initial equipment for initial team the beginning of the campaign. More...
 
static linkedList_tB_GetNeighbours (const building_t *building)
 Returns the neighbourhood of a building. More...
 
static bool B_AddBlockedTile (base_t *base, int row, int column)
 Check and add blocked tile to the base. More...
 
static void B_AddBlockedTiles (base_t *base, int count)
 Fuction to put blocked tiles on basemap. More...
 
bool B_IsBuildingDestroyable (const building_t *building)
 Returns if a base building is destroyable. More...
 
int B_GetCount (void)
 Returns the count of founded bases. More...
 
base_tB_GetNext (base_t *lastBase)
 Iterates through founded bases. More...
 
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,. More...
 
base_tB_GetFoundedBaseByIDX (int baseIdx)
 Array bound check for the base index. More...
 
building_tB_GetNextBuilding (const base_t *base, building_t *lastBuilding)
 Iterates through buildings in a base. More...
 
building_tB_GetNextBuildingByType (const base_t *base, building_t *lastBuilding, buildingType_t buildingType)
 Iterates throught buildings of a type in a base. More...
 
bool 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. More...
 
baseCapacities_t B_GetCapacityFromBuildingType (buildingType_t type)
 Get the capacity associated to a building type. More...
 
buildingType_t B_GetBuildingTypeByCapacity (baseCapacities_t cap)
 Get building type by base capacity. More...
 
bool B_GetBuildingStatus (const base_t *const base, const buildingType_t buildingType)
 Get the status associated to a building. More...
 
void B_SetBuildingStatus (base_t *const base, const buildingType_t buildingType, bool newStatus)
 Set status associated to a building. More...
 
float B_GetMaxBuildingLevel (const base_t *base, const buildingType_t type)
 Get the maximum level of a building type in a base. More...
 
static void B_AddMap (char *maps, size_t mapsLength, char *coords, size_t coordsLength, const char *map, int col, int row)
 Adds a map to the given position to the map string. More...
 
bool B_AssembleMap (char *maps, size_t mapsLength, char *coords, size_t coordsLength, const base_t *base)
 Perform the base assembling in case of an alien attack. More...
 
static bool B_CheckUpdateBuilding (building_t *building)
 Check base status for particular buildings as well as capacities. More...
 
static bool B_UpdateStatusBuilding (base_t *base, buildingType_t buildingType, bool onBuilt)
 Update status of every building when a building has been built/destroyed. More...
 
static void B_UpdateAntimatterCap (base_t *base)
 Update Antimatter Capacity. More...
 
void B_ResetAllStatusAndCapacities (base_t *base, bool firstEnable)
 Recalculate status and capacities of one base. More...
 
bool B_BuildingDestroy (building_t *building)
 Removes a building from the given base. More...
 
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. More...
 
void B_Delete (base_t *base)
 Resets a base structure. More...
 
void B_Destroy (base_t *base)
 Destroy a base. More...
 
static void B_UpdateAllBaseBuildingStatus (building_t *building, buildingStatus_t status)
 Updates base status for particular buildings as well as capacities. More...
 
static void B_AddBuildingToBasePos (base_t *base, const building_t *buildingTemplate, bool hire, const vec2_t pos)
 Build starting building in the first base, and hire employees. More...
 
static void B_BuildFromTemplate (base_t *base, const char *templateName, bool hire)
 builds a base from template More...
 
void B_SetUpFirstBase (const campaign_t *campaign, base_t *base)
 Setup aircraft and equipment for first base. Uses the campaign scriptable equipmentlist. More...
 
int B_GetInstallationLimit (void)
 Counts the actual installation count limit. More...
 
void B_SetName (base_t *base, const char *name)
 Set the base name. More...
 
base_tB_Build (const campaign_t *campaign, const vec2_t pos, const char *name, bool fillBase)
 Build new base, uses template for the first base. More...
 
const baseTemplate_tB_GetBaseTemplate (const char *baseTemplateID)
 Returns the baseTemplate in the global baseTemplate list that has the unique name baseTemplateID. More...
 
bool B_MapIsCellFree (const base_t *base, int col, int row)
 Check a base cell. More...
 
building_tB_BuildBuilding (base_t *base, const building_t *buildingTemplate, int col, int row)
 Build a new building to the base. More...
 
int B_GetNumberOfBuildingsInBaseByTemplate (const base_t *base, const building_t *tpl)
 Counts the number of buildings of a particular type in a base. More...
 
int B_GetNumberOfBuildingsInBaseByBuildingType (const base_t *base, const buildingType_t buildingType)
 Counts the number of buildings of a particular building type in a base. More...
 
const building_tB_GetBuildingInBaseByType (const base_t *base, buildingType_t buildingType, bool onlyWorking)
 Gets a building of a given type in the given base. More...
 
void B_ParseBaseTemplate (const char *name, const char **text)
 Reads a base layout template. More...
 
base_tB_GetFirstUnfoundedBase (void)
 Get the first unfounded base. More...
 
void B_SetCurrentSelectedBase (const base_t *base)
 Sets the selected base. More...
 
base_tB_GetCurrentSelectedBase (void)
 returns the currently selected base More...
 
void B_SelectBase (const base_t *base)
 Select and opens a base. More...
 
static void CL_SwapSkill (character_t *cp1, character_t *cp2, abilityskills_t skill)
 Swaps one skill from character1 to character 2 and vice versa. More...
 
static void CL_DoSwapSkills (character_t *cp1, character_t *cp2, const abilityskills_t skill)
 
static int CL_GetSkillIndicator (const character_t *chr, abilityskills_t skill)
 Assembles a skill indicator for the given character and its wore weapons in correlation to the given skill. More...
 
static void CL_SwapSkills (linkedList_t *team)
 Swaps skills of the initial team of soldiers so that they match inventories. More...
 
void B_BaseResetStatus (base_t *const base)
 Sets the baseStatus to BASE_NOT_USED. More...
 
void B_InitStartup (void)
 Resets console commands. More...
 
static bool B_CheckBuildingConstruction (building_t *building)
 Checks whether the construction of a building is finished. Calls the onEnable functions and assign workers, too. More...
 
void B_UpdateBuildingConstructions (void)
 Updates base data. More...
 
static void B_SellOrAddItems (aircraft_t *aircraft)
 Sell items to the market or add them to base storage. More...
 
void B_DumpAircraftToHomeBase (aircraft_t *aircraft)
 Will unload all cargo to the homebase. More...
 
void B_AircraftReturnedToHomeBase (aircraft_t *aircraft)
 Do anything when dropship returns to base. More...
 
bool B_BaseHasItem (const base_t *base, const objDef_t *item)
 Check if an item is available on a base. More...
 
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. More...
 
void B_UpdateBaseCapacities (baseCapacities_t cap, base_t *base)
 Updates base capacities. More...
 
void B_SaveBaseSlotsXML (const baseWeapon_t *weapons, const int numWeapons, xmlNode_t *node)
 Saves the missile and laser slots of a base or sam site. More...
 
bool B_SaveStorageXML (xmlNode_t *parent, const equipDef_t &equip)
 Saves base storage. More...
 
bool B_SaveXML (xmlNode_t *parent)
 Save callback for saving in xml format. More...
 
int B_LoadBaseSlotsXML (baseWeapon_t *weapons, int max, xmlNode_t *p)
 Loads the missile and laser slots of a base or sam site. More...
 
static bool B_PostLoadInitCapacity (void)
 Set the capacity stuff for all the bases after loading a savegame. More...
 
bool B_PostLoadInit (void)
 Set the capacity stuff for all the bases after loading a savegame. More...
 
bool B_LoadStorageXML (xmlNode_t *parent, equipDef_t *equip)
 Loads base storage. More...
 
bool B_LoadXML (xmlNode_t *parent)
 Loads base data. More...
 
bool B_ItemIsStoredInBaseStorage (const objDef_t *obj)
 Check if an item is stored in storage. More...
 
int B_AddToStorage (base_t *base, const objDef_t *obj, int amount)
 Add/remove items to/from the storage. More...
 
int B_AntimatterInBase (const base_t *base)
 returns the amount of antimatter stored in a base More...
 
int B_AddAntimatter (base_t *base, int amount)
 Manages antimatter (adding, removing) through Antimatter Storage Facility. More...
 

Detailed Description

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

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

Definition in file cp_base.cpp.

Macro Definition Documentation

#define B_GetBaseIDX (   base)    ((ptrdiff_t)((base) - ccs.bases))

Definition at line 47 of file cp_base.cpp.

#define B_GetBuildingByIDX (   baseIdx,
  buildingIdx 
)    (&ccs.buildings[(baseIdx)][(buildingIdx)])

Definition at line 45 of file cp_base.cpp.

Referenced by B_BuildBuilding(), B_Destroy(), B_GetNextBuilding(), and B_LoadXML().

#define B_GetBuildingIDX (   base,
  building 
)    ((ptrdiff_t)((building) - ccs.buildings[base->idx]))

Definition at line 46 of file cp_base.cpp.

Referenced by B_BuildBuilding(), and B_LoadXML().

Function Documentation

int B_AddAntimatter ( base_t base,
int  amount 
)

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

Parameters
[in,out]basePointer to the base.
[in]amountquantity of antimatter to add/remove
Returns
amount of antimater in the storage after the action

Definition at line 2633 of file cp_base.cpp.

References ANTIMATTER_ITEM_ID, B_AntimatterInBase(), CAP_ANTIMATTER, CAP_Get, cgi, capacities_s::cur, ERR_DROP, objDef_s::idx, INVSH_GetItemByIDSilent(), equipDef_s::numItems, and base_s::storage.

Referenced by AIR_Refuel(), CAP_RemoveAntimatterExceedingCapacity(), PR_FinishDisassembly(), PR_UpdateRequiredItemsInBasestorage(), TR_EmptyTransferCargo(), and TR_TransferStart().

static bool B_AddBlockedTile ( base_t base,
int  row,
int  column 
)
static

Check and add blocked tile to the base.

Parameters
[in,out]baseThe base to add blocked tile to
[in]rowRow position of the tile
[in]columnColumn position of the tile
Returns
bool value of success

Definition at line 137 of file cp_base.cpp.

References B_GetBuildingAt, B_IsTileBlocked, BASE_SIZE, baseBuildingTile_s::blocked, cgi, linkedList_t::data, base_s::map, OBJZERO, baseBuildingTile_s::posX, and baseBuildingTile_s::posY.

Referenced by B_AddBlockedTiles().

static void B_AddBlockedTiles ( base_t base,
int  count 
)
static

Fuction to put blocked tiles on basemap.

Parameters
[out]baseThe base to fill
[in]countNumber of blocked tiles to add

Definition at line 201 of file cp_base.cpp.

References B_AddBlockedTile(), B_GetBuildingAt, B_IsTileBlocked, BASE_SIZE, and count.

Referenced by B_BuildFromTemplate().

static void B_AddBuildingToBasePos ( base_t base,
const building_t buildingTemplate,
bool  hire,
const vec2_t  pos 
)
static

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

Parameters
[in,out]baseThe base to put the new building into
[in]buildingTemplateThe building template to create a new building with
[in]hireHire employees for the building we create from the template
[in]posThe position on the base grid

Definition at line 1010 of file cp_base.cpp.

References B_BuildBuilding(), B_FireEvent(), B_ONENABLE, B_STATUS_WORKING, B_UpdateAllBaseBuildingStatus(), cgi, date_s::day, DEBUG_CLIENT, E_HireForBuilding(), building_s::id, base_s::idx, building_s::onEnable, building_s::pos, date_s::sec, and building_s::timeStart.

Referenced by B_BuildFromTemplate().

static void B_AddMap ( char *  maps,
size_t  mapsLength,
char *  coords,
size_t  coordsLength,
const char *  map,
int  col,
int  row 
)
inlinestatic

Adds a map to the given position to the map string.

Parameters
[out]mapsThe map output string
[in]mapsLengthThe length of the maps string
[out]coordsThe coords output string
[in]coordsLengthThe length of the coords string
[in]mapThe map tile to add
[in]colThe col to spawn the map at
[in]rowThe row to spawn the map at
See also
SV_Map_f
SV_Map

Definition at line 544 of file cp_base.cpp.

References BASE_SIZE, BASE_TILE_UNITS, and Q_strcat().

Referenced by B_AssembleMap().

void B_AircraftReturnedToHomeBase ( aircraft_t aircraft)

Do anything when dropship returns to base.

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

Definition at line 2103 of file cp_base.cpp.

References AII_ReloadAircraftWeapons(), AIRFIGHT_RemoveProjectileAimingAircraft(), 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]basePointer to the base to check

Definition at line 2611 of file cp_base.cpp.

References ANTIMATTER_ITEM_ID, B_ItemInBase(), CAP_ANTIMATTER, CAP_GetCurrent, cgi, ERR_DROP, and INVSH_GetItemByID().

Referenced by B_AddAntimatter(), PR_RequirementsInfo(), PR_RequirementsMet(), RS_RequirementsMet(), TR_Add_f(), and TR_FillItems().

bool B_AssembleMap ( char *  maps,
size_t  mapsLength,
char *  coords,
size_t  coordsLength,
const base_t base 
)

Perform the base assembling in case of an alien attack.

Parameters
[out]mapsThe string containing the list of tilenames
[in]mapsLengthThe maximum length of maps string
[out]coordsThe string containing the positions of the tiles
[in]coordsLengthThe maximum length of coords string
[in,out]baseThe 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 562 of file cp_base.cpp.

References B_AddMap(), B_GetBuildingAt, B_IsBuildingBuiltUp(), BASE_SIZE, cgi, ERR_DROP, building_s::id, building_s::mapPart, building_s::pos, and va().

Referenced by B_AssembleMap_f(), BATTLE_Start(), and TEST_F().

bool B_BaseHasItem ( const base_t base,
const objDef_t item 
)

Check if an item is available on a base.

Parameters
[in]basePointer to the base to check at
[in]itemPointer to the item to check

Definition at line 2120 of file cp_base.cpp.

References B_ItemInBase(), and objDef_s::isVirtual.

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]baseWhich base should be reseted?
See also
CL_CampaignRemoveMission

Definition at line 1789 of file cp_base.cpp.

References BASE_NOT_USED, and base_s::baseStatus.

base_t* B_Build ( const campaign_t campaign,
const vec2_t  pos,
const char *  name,
bool  fillBase 
)

Build new base, uses template for the first base.

Parameters
[in]campaignThe campaign data structure
[in]posPosition (on Geoscape) the base built at
[in]nameThe name of the new base, this string might already be in utf-8
[in]fillBaseWhether we should build default buildings at the base

Definition at line 1185 of file cp_base.cpp.

References base_s::alienInterest, B_BuildFromTemplate(), B_GetFirstUnfoundedBase(), B_GetMaxBuildingLevel(), B_RADAR, B_ResetAllStatusAndCapacities(), B_SetCurrentSelectedBase(), B_SetName(), BASE_INITIALINTEREST, BASE_WORKING, stats_s::basesBuilt, base_s::baseStatus, BDEF_InitialiseBaseSlots(), ccs_s::campaignStats, CAP_SetCurrent(), ccs, cgi, ERR_DROP, campaign_s::firstBaseTemplate, base_s::founded, i, base_s::idx, level, MAX_CAP, ccs_s::numBases, base_s::pos, PR_UpdateProductionCap(), base_s::radar, RADAR_BASERANGE, RADAR_BASETRACKINGRANGE, RADAR_Initialise(), RADAR_InitialiseUFOs(), and Vector2Copy.

Referenced by B_BuildBase_f(), and CreateBase().

building_t* B_BuildBuilding ( base_t base,
const building_t buildingTemplate,
int  col,
int  row 
)

Build a new building to the base.

Parameters
[in,out]baseThe base to place the building in
[in]buildingTemplateThe template of the building to place at the given location
[in]rowSet building to row
[in]colSet building to col
Returns
building created in base (this is not a building template)

Definition at line 1279 of file cp_base.cpp.

References B_FireEvent(), B_GetBuildingAt, B_GetBuildingByIDX, B_GetBuildingIDX, B_GetNeighbours(), B_IsBuildingBuiltUp(), B_IsTileBlocked, B_ONCONSTRUCT, B_STATUS_UNDER_CONSTRUCTION, building_s::base, BASE_SIZE, BASE_WORKING, base_s::baseStatus, baseBuildingTile_s::building, building_s::buildingStatus, ccs, cgi, CP_CheckCredits(), CP_UpdateCredits(), ccs_s::credits, ccs_s::date, ERR_DROP, building_s::fixCosts, building_s::idx, base_s::idx, LIST_Foreach, base_s::map, ccs_s::numBuildings, building_s::pos, building_s::size, and building_s::timeStart.

Referenced by B_AddBuildingToBasePos(), B_BuildBuilding_f(), and TEST_F().

static void B_BuildFromTemplate ( base_t base,
const char *  templateName,
bool  hire 
)
static

builds a base from template

Parameters
[out]baseThe base to build
[in]templateNameTemplate used for building. If nullptr no template will be used.
[in]hireIf hiring employee needed
Note
It builds an empty base on nullptr (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 1040 of file cp_base.cpp.

References B_AddBlockedTiles(), B_AddBuildingToBasePos(), B_GetBaseTemplate(), B_GetBuildingStatus(), BASE_SIZE, stats_s::basesBuilt, baseBuildingTile_s::building, baseTemplate_s::buildings, ccs_s::buildingTemplates, building_s::buildingType, ccs_s::campaignStats, ccs, cgi, ERR_DROP, frand(), i, building_s::mandatory, base_s::map, MAX_BLOCKEDFIELDS, MIN_BLOCKEDFIELDS, baseTemplate_s::numBuildings, ccs_s::numBuildingTemplates, mission_s::pos, baseBuildingTile_s::posX, baseBuildingTile_s::posY, and Vector2Set.

Referenced by B_Build().

static bool B_CheckBuildingConstruction ( building_t building)
static

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

Definition at line 1988 of file cp_base.cpp.

References B_FireEvent(), B_IsBuildingBuiltUp(), B_ONENABLE, B_STATUS_UNDER_CONSTRUCTION, B_STATUS_WORKING, B_UpdateAllBaseBuildingStatus(), building_s::base, building_s::buildingStatus, cgi, DEBUG_CLIENT, base_s::idx, and building_s::onEnable.

Referenced by B_UpdateBuildingConstructions().

bool 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]baseBase to search
[in]typeBuilding type to search
[in]statusThe status the building should have
[out]cntThis 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 nullptr 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 389 of file cp_base.cpp.

References B_GetNextBuildingByType(), and building_s::buildingStatus.

Referenced by BDEF_UpdateActiveBattery_f().

static bool B_CheckUpdateBuilding ( building_t building)
static

Check base status for particular buildings as well as capacities.

Parameters
[in]buildingPointer to building.
Returns
true if a base status has been modified (but do not check capacities)

Definition at line 599 of file cp_base.cpp.

References B_CheckBuildingDependencesStatus(), B_GetBuildingStatus(), B_MISC, B_SetBuildingStatus(), B_STATUS_WORKING, building_s::base, building_s::buildingStatus, building_s::buildingType, cgi, DEBUG_CLIENT, and building_s::name.

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

void B_Delete ( base_t base)

Resets a base structure.

Parameters
[in,out]basePointer to base to be deleted.
Todo:
A lot more could be extracted here from B_Destroy

Definition at line 897 of file cp_base.cpp.

References base_s::alienContainment.

Referenced by B_Destroy(), and CP_ResetCampaignData().

void B_Destroy ( base_t base)

Destroy a base.

Parameters
[in,out]basePointer 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. For this we need to check all the dependencies and references. Should be only done after putting bases into a linkedList

Definition at line 913 of file cp_base.cpp.

References AIR_DeleteAircraft(), AIR_ForeachFromBase, base_s::alienInterest, B_BuildingDestroy(), B_Delete(), B_GetBuildingByIDX, B_MoveAircraftOnGeoscapeToOtherBases(), BASE_DESTROYED, base_s::baseStatus, CAP_ITEMS, CAP_SetCurrent(), ccs, CP_MissionNotifyBaseDestroyed(), E_DeleteAllEmployees(), base_s::idx, ccs_s::numBuildings, OBJZERO, and base_s::storage.

Referenced by B_Destroy_AntimaterStorage_f(), CP_BaseAttackMissionDestroyBase(), and TEST_F().

void B_DumpAircraftToHomeBase ( aircraft_t aircraft)

Will unload all cargo to the homebase.

Parameters
[in,out]aircraftThe aircraft to dump

Definition at line 2085 of file cp_base.cpp.

References AL_AddAliens(), B_SellOrAddItems(), and aircraft_s::maxTeamSize.

Referenced by B_AircraftReturnedToHomeBase(), CP_EndRescueMission(), and CP_MissionEndActions().

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]baseIdxIndex to check
Returns
Pointer to the base corresponding to baseIdx.

Definition at line 312 of file cp_base.cpp.

References ccs_s::bases, ccs, and MAX_BASES.

Referenced by AIR_LoadAircraftXML(), B_BuildBuilding_f(), B_FillBuildingInfo_f(), B_GetFirstUnfoundedBase(), B_GetFoundedBaseByIDX(), B_ListBuildings_f(), B_LoadXML(), BDEF_AddBattery_f(), BDEF_UpdateActiveBattery_f(), CP_AddItemAsCollected_f(), E_LoadXML(), GAME_CP_DrawBaseLayout(), MIS_LoadXML(), PR_LoadXML(), RS_LoadXML(), and TR_LoadXML().

const baseTemplate_t* B_GetBaseTemplate ( const char *  baseTemplateID)

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

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

Definition at line 1246 of file cp_base.cpp.

References ccs_s::baseTemplates, ccs, cgi, i, baseTemplate_s::id, ccs_s::numBaseTemplates, and Q_streq.

Referenced by B_BuildFromTemplate().

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

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

Parameters
[in]baseThe base to search the building in
[in]buildingTypeWhat building-type to get.
[in]onlyWorkingIf we're looking only for working buildings
Returns
The building or nullptr if base has no building of that type

Definition at line 1414 of file cp_base.cpp.

References B_GetBuildingStatus(), and B_GetNextBuildingByType().

buildingType_t B_GetBuildingTypeByCapacity ( baseCapacities_t  cap)

Get building type by base capacity.

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

Definition at line 446 of file cp_base.cpp.

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(), B_UpdateBaseCapacities(), CAP_CheckOverflow(), and UP_AircraftDescription().

baseCapacities_t B_GetCapacityFromBuildingType ( buildingType_t  type)

Get the capacity associated to a building type.

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

Definition at line 415 of file cp_base.cpp.

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 AIR_GetHangarCapacityType(), B_BuildingDestroy(), B_BuildingDestroy_f(), B_ListBuildings_f(), B_UpdateAllBaseBuildingStatus(), and TR_DestinationCapacityList_f().

base_t* B_GetFirstUnfoundedBase ( void  )

Get the first unfounded base.

Returns
first unfounded base or nullptr if every available base slot is already filled

Definition at line 1537 of file cp_base.cpp.

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

Referenced by B_Build().

int B_GetInstallationLimit ( void  )

Counts the actual installation count limit.

Returns
int number of installations can be built

Definition at line 1153 of file cp_base.cpp.

References B_COMMAND, B_GetBuildingStatus(), B_GetNext(), and MAX_INSTALLATIONS_PER_BASE.

Referenced by INS_BuildInstallation_f(), INS_FillTypes_f(), INS_SelectType_f(), INS_UpdateInstallationLimit_f(), and TEST_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]basePointer to base.
[in]typeBuilding 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 518 of file cp_base.cpp.

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

Referenced by B_Build(), B_LoadXML(), and RADAR_UpdateBaseRadarCoverage_f().

static linkedList_t* B_GetNeighbours ( const building_t building)
static

Returns the neighbourhood of a building.

Parameters
[in]buildingThe building we ask neighbours
Returns
a linkedList with neighbouring buildings
Note
for unfinished building it returns an empty list

Definition at line 57 of file cp_base.cpp.

References B_GetBuildingAt, B_IsBuildingBuiltUp(), building_s::base, cgi, i, building_s::pos, and building_s::size.

Referenced by B_BuildBuilding(), and B_IsBuildingDestroyable().

building_t* B_GetNextBuilding ( const base_t base,
building_t lastBuilding 
)

Iterates through buildings in a base.

Parameters
[in]basePointer to the base which buildings asked
[in]lastBuildingPointer to the building iterate from. Call with nullptr to get the first one.

Definition at line 338 of file cp_base.cpp.

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

Referenced by B_GetNextBuildingByType(), B_GetNumberOfBuildingsInBaseByTemplate(), B_IsBuildingDestroyable(), B_ResetAllStatusAndCapacities(), B_SaveXML(), B_UpdateBuildingConstructions(), 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]basePointer to the base which buildings asked
[in]lastBuildingPointer to the building iterate from. Call with nullptr to get the first one.
[in]buildingTypeType of the buildings to search
See also
buildingType_t

Definition at line 366 of file cp_base.cpp.

References B_GetNextBuilding(), and building_s::buildingType.

Referenced by 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 building type in a base.

Parameters
[in]baseWhich base to count in.
[in]buildingTypeBuilding type value.
Returns
The number of buildings or -1 on error (e.g. base index out of range)

Definition at line 1386 of file cp_base.cpp.

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

Referenced by B_BuildingDestroy(), and CP_BaseAttackStartMission().

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]baseWhich base to count in.
[in]tplThe template type in the ccs.buildingTemplates list.
Returns
The number of buildings or -1 on error (e.g. base index out of range)

Definition at line 1353 of file cp_base.cpp.

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

Referenced by B_FillBuildingInfo_f(), and B_ListBuildings_f().

static void B_InitialEquipment ( aircraft_t aircraft,
const equipDef_t ed 
)
static

Prepares initial equipment for initial team the beginning of the campaign.

Parameters
[in,out]aircraftaircraft on which the soldiers (to equip) are
[in]edInitial equipment definition

Definition at line 1759 of file cp_base.cpp.

References aircraft_s::acTeam, AIR_MoveEmployeeInventoryIntoStorage(), CAP_UpdateStorageCap(), cgi, CL_SwapSkills(), DEBUG_CLIENT, aircraft_s::homebase, LIST_Foreach, character_s::name, and base_s::storage.

Referenced by B_SetUpFirstBase().

void B_InitStartup ( void  )

Resets console commands.

Definition at line 1971 of file cp_base.cpp.

References cgi.

Referenced by CP_InitStartup().

bool B_IsBuildingDestroyable ( const building_t building)

Returns if a base building is destroyable.

Parameters
[in]buildingPointer to the building to check

Definition at line 223 of file cp_base.cpp.

References B_GetNeighbours(), B_GetNextBuilding(), building_s::base, BASE_DESTROYED, base_s::baseStatus, ccs, cgi, linkedList_t::data, i, building_s::idx, base_s::idx, LIST_Foreach, MAX_BUILDINGS, ccs_s::numBuildings, and OBJZERO.

Referenced by B_BuildingDestroy(), and B_BuildingDestroy_f().

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]itemThe item to check
[in]baseThe base to search in.
Returns
amount Number of available items in base

Definition at line 2134 of file cp_base.cpp.

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

Referenced by AIM_UpdateAircraftItemList(), AIR_Refuel(), B_AddToStorage(), B_AntimatterInBase(), B_BaseHasItem(), B_UpdateAntimatterCap(), BS_Buy_f(), BS_FillMarket_f(), BS_SellItem(), CAP_UpdateStorageCap(), PR_RequirementsInfo(), PR_RequirementsMet(), PR_UpdateProductionList(), RS_RequirementsMet(), TR_Add_f(), and TR_FillItems().

bool B_ItemIsStoredInBaseStorage ( const objDef_t obj)

Check if an item is stored in storage.

Parameters
[in]objPointer to the item to check.
Returns
True if item is stored in storage.

Definition at line 2558 of file cp_base.cpp.

References ANTIMATTER_ITEM_ID, objDef_s::id, objDef_s::isVirtual, and Q_streq.

Referenced by B_AddToStorage(), CAP_UpdateStorageCap(), CP_ItemsSanityCheck(), TR_Add_f(), TR_EmptyTransferCargo(), TR_FillItems(), and TR_TransferStart().

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

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

Parameters
[out]weaponsDefence weapons array
[out]maxNumber of entries in weapons array
[in]pXML Node structure, where we load the information from
See also
B_Load
B_SaveBaseSlots

Definition at line 2348 of file cp_base.cpp.

References AII_LoadOneSlotXML(), baseWeapon_s::autofire, cgi, i, SAVE_BASES_AUTOFIRE, SAVE_BASES_TARGET, SAVE_BASES_WEAPON, baseWeapon_s::target, UFO_GetByIDX(), cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), and xmlNode_t.

Referenced by B_LoadXML(), and INS_LoadXML().

bool B_LoadStorageXML ( xmlNode_t parent,
equipDef_t equip 
)

Loads base storage.

Parameters
[in]parentXML Node structure, where we get the information from
[out]equipStorage to load

Definition at line 2388 of file cp_base.cpp.

References cgi, objDef_s::idx, INVSH_GetItemByID(), equipDef_s::numItems, equipDef_s::numItemsLoose, SAVE_BASES_ITEM, SAVE_BASES_NUM, SAVE_BASES_NUMLOOSE, SAVE_BASES_ODS_ID, cgame_import_s::XML_GetNextNode(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetString(), and xmlNode_t.

Referenced by B_LoadXML().

bool B_LoadXML ( xmlNode_t parent)

Loads base data.

Parameters
[in]parentXML Node structure, where we get the information from
Todo:
save it as vec2t if needed, also it's opposite

Definition at line 2407 of file cp_base.cpp.

References base_s::aircraftCurrent, base_s::alienContainment, base_s::alienInterest, B_GetBaseByIDX(), B_GetBuildingByIDX, B_GetBuildingIDX, B_GetBuildingTemplate(), B_GetCount(), B_GetMaxBuildingLevel(), B_LoadBaseSlotsXML(), B_LoadStorageXML(), B_RADAR, 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, CAP_ALIENS, CAP_Get, ccs, cgi, date_s::day, FOREACH_XMLNODE, base_s::founded, i, building_s::idx, base_s::idx, Inventory::init(), base_s::lasers, building_s::level, AlienCargo::load(), base_s::map, MAX_BASE_SLOT, MAX_BUILDINGS, MAX_VAR, base_s::name, ccs_s::numBases, base_s::numBatteries, ccs_s::numBuildings, base_s::numLasers, base_s::pos, building_s::pos, baseBuildingTile_s::posX, baseBuildingTile_s::posY, Q_strncpyz(), base_s::radar, RADAR_Initialise(), RADAR_InitialiseUFOs(), SAVE_BASES_ALIENCONTAINMENT, 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_IDX, 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, date_s::sec, base_s::storage, building_s::timeStart, cgame_import_s::XML_GetDate(), cgame_import_s::XML_GetNode(), cgame_import_s::XML_GetPos2(), cgame_import_s::XML_GetPos3(), cgame_import_s::XML_GetString(), and xmlNode_t.

Referenced by SAV_Init().

bool B_MapIsCellFree ( const base_t base,
int  col,
int  row 
)

Check a base cell.

Returns
True if the cell is free to build

Definition at line 1263 of file cp_base.cpp.

References B_GetBuildingAt, B_IsTileBlocked, and BASE_SIZE.

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
[in]baseThe base that is going to be destroyed
Todo:
this should be merged into CAP_RemoveAircraftExceedingCapacity
Todo:
Pilot skills; really kill pilot in this case?

Definition at line 860 of file cp_base.cpp.

References AIR_CheckMoveIntoNewHomebase(), AIR_DestroyAircraft(), AIR_ForeachFromBase, AIR_IsAircraftOnGeoscape(), AIR_MoveAircraftIntoNewHomebase(), B_GetNext(), CP_SpawnRescueMission(), GEO_GetColor(), MapIsWater, MAPTYPE_TERRAIN, and UFO_NotifyPhalanxAircraftRemoved().

Referenced by B_Destroy().

bool B_PostLoadInit ( void  )

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

See also
SAV_GameActionsAfterLoad

Definition at line 2378 of file cp_base.cpp.

References B_PostLoadInitCapacity().

Referenced by SAV_GameActionsAfterLoad().

static bool B_PostLoadInitCapacity ( void  )
static

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

See also
B_PostLoadInit

Definition at line 2365 of file cp_base.cpp.

References B_GetNext(), and B_ResetAllStatusAndCapacities().

Referenced by B_PostLoadInit().

void B_ResetAllStatusAndCapacities ( base_t base,
bool  firstEnable 
)

Recalculate status and capacities of one base.

Parameters
[in]basePointer to the base where status and capacities must be recalculated
[in]firstEnabletrue if this is the first time the function is called for this base

Definition at line 705 of file cp_base.cpp.

References B_CheckUpdateBuilding(), B_FireEvent(), B_GetBuildingStatus(), B_GetBuildingTypeByCapacity(), B_GetNextBuilding(), B_MISC, B_ONENABLE, B_SetBuildingStatus(), B_UpdateAntimatterCap(), B_UpdateBaseCapacities(), building_s::buildingType, CAP_ANTIMATTER, CAP_EMPLOYEES, CAP_GetFreeCapacity(), CAP_ITEMS, CAP_LABSPACE, CAP_SetCurrent(), CAP_UpdateStorageCap(), CAP_WORKSPACE, cgi, DEBUG_CLIENT, E_CountAllHired(), i, MAX_BUILDING_TYPE, MAX_CAP, base_s::name, PR_UpdateProductionCap(), RS_CountScientistsInBase(), and type.

Referenced by B_Build(), and B_PostLoadInitCapacity().

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

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

Parameters
[in]weaponsDefence weapons array
[in]numWeaponsNumber of entries in weapons array
[out]nodeXML Node structure, where we write the information to

Definition at line 2229 of file cp_base.cpp.

References AII_SaveOneSlotXML(), cgi, i, SAVE_BASES_AUTOFIRE, SAVE_BASES_TARGET, SAVE_BASES_WEAPON, cgame_import_s::XML_AddNode(), and xmlNode_t.

Referenced by B_SaveXML(), and INS_SaveXML().

bool B_SaveStorageXML ( xmlNode_t parent,
const equipDef_t equip 
)

Saves base storage.

Parameters
[out]parentXML Node structure, where we write the information to
[in]equipStorage to save

Definition at line 2245 of file cp_base.cpp.

References cgi, cgame_import_s::csi, objDef_s::id, INVSH_GetItemByIDX(), equipDef_s::numItems, equipDef_s::numItemsLoose, csi_s::numODs, SAVE_BASES_ITEM, SAVE_BASES_NUM, SAVE_BASES_NUMLOOSE, SAVE_BASES_ODS_ID, cgame_import_s::XML_AddNode(), and xmlNode_t.

Referenced by B_SaveXML().

bool B_SaveXML ( xmlNode_t parent)

Save callback for saving in xml format.

Parameters
[out]parentXML Node structure, where we write the information to
Todo:
save it as vec2t if needed, also it's opposite

Definition at line 2264 of file cp_base.cpp.

References base_s::alienContainment, base_s::alienInterest, B_GetBuildingAt, B_GetNext(), B_GetNextBuilding(), B_IsTileBlocked, B_SaveBaseSlotsXML(), B_SaveStorageXML(), BASE_SIZE, base_s::baseStatus, base_s::batteries, building_s::buildingStatus, building_s::buildTime, cgi, cgame_import_s::Com_GetConstVariable(), date_s::day, base_s::founded, building_s::id, building_s::idx, base_s::idx, mission_s::idx, base_s::lasers, building_s::level, base_s::name, base_s::numBatteries, base_s::numLasers, base_s::pos, building_s::pos, base_s::radar, radar_s::range, AlienCargo::save(), SAVE_BASES_ALIENCONTAINMENT, 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_IDX, 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, date_s::sec, base_s::storage, building_s::timeStart, building_s::tpl, radar_s::trackingRange, cgame_import_s::XML_AddNode(), and xmlNode_t.

Referenced by SAV_Init().

void B_SelectBase ( const base_t base)

Select and opens a base.

Parameters
[in]baseIf this is nullptr we want to build a new base

Definition at line 1592 of file cp_base.cpp.

References B_GetCount(), B_SetCurrentSelectedBase(), ccs, cgi, DEBUG_CLIENT, GEO_IsRadarOverlayActivated(), GEO_ResetAction(), GEO_SetOverlay(), base_s::idx, MA_NEWBASE, MA_NONE, ccs_s::mapAction, MAX_BASES, and va().

Referenced by B_BuildBase_f(), B_SelectBase_f(), CL_PopupInterceptRClick_f(), and CP_CampaignInit().

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

Set status associated to a building.

Parameters
[in]baseBase to check
[in]buildingTypevalue of building->buildingType
[in]newStatusNew value of the status
See also
B_GetBuildingStatus

Definition at line 498 of file cp_base.cpp.

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

Sets the selected base.

Parameters
[in]baseThe base that is going to be selected
See also
B_SelectBase

Definition at line 1553 of file cp_base.cpp.

References AIR_GetFirstFromBase(), base_s::aircraftCurrent, B_GetNext(), base_s::baseStatus, cgi, cgame_import_s::Cvar_Set(), INS_SetCurrentSelectedInstallation(), base_s::name, and base_s::selected.

Referenced by B_Build(), B_SelectBase(), CP_BaseAttackPrepareBattle(), and INS_SelectInstallation().

void B_SetName ( base_t base,
const char *  name 
)

Set the base name.

Parameters
[out]baseThe base to set the name for
[in]nameThe name for the base. This might already be in utf-8 as it's the user input from the UI

Definition at line 1173 of file cp_base.cpp.

References base_s::name, and Q_strncpyz().

Referenced by B_Build(), B_ChangeBaseName_f(), and TEST_F().

static void B_UpdateAllBaseBuildingStatus ( building_t building,
buildingStatus_t  status 
)
static

Updates base status for particular buildings as well as capacities.

Parameters
[in,out]buildingPointer to building.
[in]statusEnum 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.

Definition at line 978 of file cp_base.cpp.

References B_CheckUpdateBuilding(), B_FireEvent(), B_GetCapacityFromBuildingType(), B_ONENABLE, B_UpdateBaseCapacities(), B_UpdateStatusBuilding(), building_s::base, building_s::buildingStatus, building_s::buildingType, and MAX_CAP.

Referenced by B_AddBuildingToBasePos(), and B_CheckBuildingConstruction().

static void B_UpdateAntimatterCap ( base_t base)
static

Update Antimatter Capacity.

Parameters
[in]basePointer to the base
See also
B_ResetAllStatusAndCapacities_f

Definition at line 693 of file cp_base.cpp.

References ANTIMATTER_ITEM_ID, B_ItemInBase(), CAP_ANTIMATTER, CAP_SetCurrent(), and INVSH_GetItemByID().

Referenced by B_ResetAllStatusAndCapacities().

void B_UpdateBaseCapacities ( baseCapacities_t  cap,
base_t base 
)

Updates base capacities.

Parameters
[in]capEnum type of baseCapacities_t.
[in]basePointer to the base.
See also
B_UpdateAllBaseBuildingStatus
B_BuildingDestroy_f
Note
If hasBuilding is false, 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 2161 of file cp_base.cpp.

References base_s::alienContainment, B_GetBuildingTypeByCapacity(), B_GetNextBuildingByType(), B_STATUS_CONSTRUCTION_FINISHED, B_UpdateBaseCapacities(), building_s::buildingStatus, ccs_s::buildingTemplates, building_s::buildingType, CAP_AddMax(), CAP_AIRCRAFT_BIG, CAP_AIRCRAFT_SMALL, CAP_ALIENS, CAP_ANTIMATTER, CAP_EMPLOYEES, CAP_Get, CAP_GetMax, CAP_ITEMS, CAP_LABSPACE, CAP_SetMax(), CAP_WORKSPACE, building_s::capacity, ccs, cgi, capacities_s::cur, DEBUG_CLIENT, ERR_DROP, i, building_s::id, capacities_s::max, and ccs_s::numBuildingTemplates.

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

void B_UpdateBuildingConstructions ( void  )
static bool B_UpdateStatusBuilding ( base_t base,
buildingType_t  buildingType,
bool  onBuilt 
)
static

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

Parameters
[in]base
[in]buildingTypeThe building-type that has been built / removed.
[in]onBuilttrue if building has been built, false else
See also
B_BuildingDestroy
B_UpdateAllBaseBuildingStatus
Returns
true if at least one building status has been modified

Definition at line 634 of file cp_base.cpp.

References B_CheckUpdateBuilding(), B_FireEvent(), B_GetBuildingStatus(), B_GetNextBuilding(), B_ONDISABLE, B_ONENABLE, building_s::buildingType, and building_s::dependsBuilding.

Referenced by B_BuildingDestroy(), and B_UpdateAllBaseBuildingStatus().

static int CL_GetSkillIndicator ( const character_t chr,
abilityskills_t  skill 
)
static

Assembles a skill indicator for the given character and its wore weapons in correlation to the given skill.

Parameters
[in]chrThe character to get the skill indicator for
[in]skillThe skill to get the indicator for
Returns
-1 if the given character does not wear the needed weapons, otherwise a weighted indicator that tell us how good the weapons fit for the given skill.
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 1682 of file cp_base.cpp.

References Item::ammoDef(), Item::def(), objDef_s::fd, Item::getFiredefs(), Inventory::getHolsterContainer(), Inventory::getRightHandContainer(), character_s::inv, Item::isReloadable(), fireDef_s::weapFdsIdx, and fireDef_s::weaponSkill.

Referenced by CL_SwapSkills().

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 1622 of file cp_base.cpp.

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

Referenced by CL_DoSwapSkills().

static void CL_SwapSkills ( linkedList_t team)
static

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

Definition at line 1719 of file cp_base.cpp.

References ABILITY_NUM_TYPES, cgi, CL_DoSwapSkills(), CL_GetSkillIndicator(), i, LIST_Foreach, and SKILL_NUM_TYPES.

Referenced by B_InitialEquipment().