UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_base.h File Reference

Header for base management related stuff. More...

#include "cp_capacity.h"
#include "cp_aliencont.h"
#include "cp_produce.h"
#include "cp_building.h"
Include dependency graph for cp_base.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  baseBuildingTile_t
struct  baseWeapon_t
struct  base_t
 A base with all it's data. More...
struct  baseTemplate_t
 template for creating a base More...

Macros

#define MAX_BASES   8
#define MAX_BASETEMPLATES   5
#define MAX_BUILDINGS   32
#define MAX_BASE_SLOT   4
#define BASE_SIZE   5
#define MAX_BASEBUILDINGS   BASE_SIZE * BASE_SIZE
#define MAX_BLOCKEDFIELDS   4
#define MIN_BLOCKEDFIELDS   1
#define BASE_TILE_SIZE   512
#define BASE_TILE_UNITS   (BASE_TILE_SIZE / UNIT_SIZE)
#define BASE_INITIALINTEREST   1.0
#define B_IsUnderAttack(base)
#define B_AtLeastOneExists()
#define B_IsTileBlocked(base, x, y)
#define B_GetBuildingAt(base, x, y)

Enumerations

enum  baseStatus_t { BASE_NOT_USED , BASE_UNDER_ATTACK , BASE_WORKING , BASE_DESTROYED }
 Possible base states. More...

Functions

void B_UpdateBuildingConstructions (void)
 Updates base data.
float B_GetMaxBuildingLevel (const base_t *base, const buildingType_t type)
 Get the maximum level of a building type in a base.
void B_ParseBaseTemplate (const char *name, const char **text)
 Reads a base layout template.
void B_BaseResetStatus (base_t *const base)
 Sets the baseStatus to BASE_NOT_USED.
const building_tB_GetBuildingInBaseByType (const base_t *base, buildingType_t type, bool onlyWorking)
 Gets a building of a given type in the given base.
const baseTemplate_tB_GetBaseTemplate (const char *baseTemplateName)
 Returns the baseTemplate in the global baseTemplate list that has the unique name baseTemplateID.
void B_InitStartup (void)
 Resets console commands.
base_tB_Build (const struct campaign_s *campaign, const vec2_t pos, const char *name, bool fillBase=false)
void B_SetUpFirstBase (const struct campaign_s *campaign, base_t *base)
base_tB_GetNext (base_t *lastBase)
 Iterates through founded bases.
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.
int B_GetCount (void)
 Returns the count of founded bases.
void B_SelectBase (const base_t *base)
 Select and opens a base.
void B_Destroy (base_t *base)
 Destroy a base.
void B_Delete (base_t *base)
 Resets a base structure.
void B_SetName (base_t *base, const char *name)
 Set the base name.
base_tB_GetFirstUnfoundedBase (void)
 Get the first unfounded base.
base_tB_GetCurrentSelectedBase (void)
 returns the currently selected base
void B_SetCurrentSelectedBase (const base_t *base)
 Sets the selected base.
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.
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.
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.
bool B_GetBuildingStatus (const base_t *const base, const buildingType_t type)
 Get the status associated to a building.
void B_SetBuildingStatus (base_t *const base, const buildingType_t type, bool newStatus)
 Set status associated to a building.
bool B_MapIsCellFree (const base_t *base, int col, int row)
 Check a base cell.
building_tB_BuildBuilding (base_t *base, const building_t *buildingTemplate, int col, int row)
 Build a new building to the base.
bool B_IsBuildingDestroyable (const building_t *building)
 Returns if a base building is destroyable.
bool B_BuildingDestroy (building_t *building)
 Removes a building from the given base.
building_tB_GetFreeBuildingType (buildingType_t type)
int B_GetNumberOfBuildingsInBaseByTemplate (const base_t *base, const building_t *type)
 Counts the number of buildings of a particular type in a base.
int B_GetNumberOfBuildingsInBaseByBuildingType (const base_t *base, const buildingType_t type)
 Counts the number of buildings of a particular building type in a base.
bool B_ItemIsStoredInBaseStorage (const objDef_t *obj)
 Check if an item is stored in storage.
bool 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.
int B_AddToStorage (base_t *base, const objDef_t *obj, int amount)
 Add/remove items to/from the storage.
void B_AircraftReturnedToHomeBase (aircraft_t *aircraft)
 Do anything when dropship returns to base.
void B_DumpAircraftToHomeBase (aircraft_t *aircraft)
 Will unload all cargo to the homebase.
void B_UpdateBaseCapacities (baseCapacities_t cap, base_t *base)
 Updates base capacities.
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.
void B_ResetAllStatusAndCapacities (base_t *base, bool firstEnable)
 Recalculate status and capacities of one base.
int B_AntimatterInBase (const base_t *base)
 returns the amount of antimatter stored in a base
int B_AddAntimatter (base_t *base, int amount)
 Manages antimatter (adding, removing) through Antimatter Storage Facility.
void B_SaveBaseSlotsXML (const baseWeapon_t *weapons, const int numWeapons, xmlNode_t *p)
 Saves the missile and laser slots of a base or sam site.
int B_LoadBaseSlotsXML (baseWeapon_t *weapons, int numWeapons, xmlNode_t *p)
 Loads the missile and laser slots of a base or sam site.
bool B_SaveStorageXML (xmlNode_t *parent, const equipDef_t &equip)
 Saves base storage.
bool B_LoadStorageXML (xmlNode_t *parent, equipDef_t *equip)
 Loads base storage.
int B_GetInstallationLimit (void)
 Counts the actual installation count limit.
bool BS_BuySellAllowed (const base_t *base)
 Returns true if you can buy or sell equipment.
bool AIR_AircraftAllowed (const base_t *base)
 Returns true if the current base is able to handle aircraft.
bool RS_ResearchAllowed (const base_t *base)
 Returns true if the current base is able to handle research.
bool PR_ProductionAllowed (const base_t *base)
 Returns true if the current base is able to produce items.
bool E_HireAllowed (const base_t *base)
 Returns true if the current base is able to handle employees.
bool AC_ContainmentAllowed (const base_t *base)
 Returns true if the current base is able to handle captured aliens.
bool HOS_HospitalAllowed (const base_t *base)
 Returns true if you can enter in the hospital.

Detailed Description

Header for base management related stuff.

Definition in file cp_base.h.

Macro Definition Documentation

◆ B_AtLeastOneExists

#define B_AtLeastOneExists ( )
Value:
(B_GetNext(nullptr) != nullptr)
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
Definition cp_base.cpp:286

Definition at line 55 of file cp_base.h.

Referenced by CP_CampaignRun(), CP_CheckLostCondition(), E_LoadXML(), GEO_ResetAction(), GEO_SetOverlay(), SAV_GameSaveAllowed(), TEST_F(), TEST_F(), TEST_F(), and TR_LoadXML().

◆ B_GetBuildingAt

#define B_GetBuildingAt ( base,
x,
y )

◆ B_IsTileBlocked

#define B_IsTileBlocked ( base,
x,
y )
Value:
(base)->map[(int)(y)][(int)(x)].blocked

Definition at line 164 of file cp_base.h.

Referenced by B_AddBlockedTile(), B_AddBlockedTiles(), B_BuildBuilding(), B_FillMap_f(), B_MapIsCellFree(), B_SaveXML(), and GAME_CP_DrawBaseLayout().

◆ B_IsUnderAttack

◆ BASE_INITIALINTEREST

#define BASE_INITIALINTEREST   1.0

Definition at line 51 of file cp_base.h.

Referenced by B_Build().

◆ BASE_SIZE

◆ BASE_TILE_SIZE

#define BASE_TILE_SIZE   512

basetiles are 16 units in each direction 512 / UNIT_SIZE = 16 512 is the size in the mapeditor and the worldplane for a single base map tile

Definition at line 48 of file cp_base.h.

◆ BASE_TILE_UNITS

#define BASE_TILE_UNITS   (BASE_TILE_SIZE / UNIT_SIZE)

Definition at line 49 of file cp_base.h.

Referenced by B_AddMap().

◆ MAX_BASE_SLOT

#define MAX_BASE_SLOT   4

Definition at line 35 of file cp_base.h.

Referenced by B_LoadXML(), BDEF_AddBattery(), and BDEF_InitialiseBaseSlots().

◆ MAX_BASEBUILDINGS

#define MAX_BASEBUILDINGS   BASE_SIZE * BASE_SIZE

Definition at line 39 of file cp_base.h.

Referenced by B_ParseBaseTemplate().

◆ MAX_BASES

◆ MAX_BASETEMPLATES

#define MAX_BASETEMPLATES   5

Definition at line 33 of file cp_base.h.

Referenced by B_ParseBaseTemplate().

◆ MAX_BLOCKEDFIELDS

#define MAX_BLOCKEDFIELDS   4

Definition at line 41 of file cp_base.h.

Referenced by B_BuildFromTemplate().

◆ MAX_BUILDINGS

#define MAX_BUILDINGS   32

◆ MIN_BLOCKEDFIELDS

#define MIN_BLOCKEDFIELDS   1

Definition at line 42 of file cp_base.h.

Referenced by B_BuildFromTemplate().

Enumeration Type Documentation

◆ baseStatus_t

Possible base states.

Note
: Don't change the order or you have to change the basemenu scriptfiles, too
Enumerator
BASE_NOT_USED 
BASE_UNDER_ATTACK 

base is under attack

BASE_WORKING 

nothing special

BASE_DESTROYED 

the base is being destroyed (prevent double destroy attempt)

Definition at line 61 of file cp_base.h.

Function Documentation

◆ AC_ContainmentAllowed()

bool AC_ContainmentAllowed ( const base_t * base)

Returns true if the current base is able to handle captured aliens.

Parameters
[in]basePointer to the base to check alien containment at

Definition at line 227 of file cp_aliencont.cpp.

References base_t::alienContainment.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick_f().

◆ AIR_AircraftAllowed()

bool AIR_AircraftAllowed ( const base_t * base)

Returns true if the current base is able to handle aircraft.

See also
B_BaseInit_f
Note
Hangar must be accessible during base attack to make aircraft lift off and to equip soldiers.

Definition at line 2641 of file cp_aircraft.cpp.

References B_GetBuildingStatus(), B_HANGAR, and B_SMALL_HANGAR.

Referenced by AIR_ShowAircraft_f(), B_BaseInit_f(), B_BuildingOpenAfterClick_f(), and BS_Buy_f().

◆ B_AddAntimatter()

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

References ANTIMATTER_ITEM_ID, B_AntimatterInBase(), CAP_ANTIMATTER, CAP_Get, cgi, capacities_t::cur, ERR_DROP, objDef_t::idx, INVSH_GetItemByIDSilent(), equipDef_t::numItems, and base_t::storage.

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

◆ B_AddToStorage()

◆ B_AircraftReturnedToHomeBase()

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

References AII_ReloadAircraftWeapons(), AIRFIGHT_RemoveProjectileAimingAircraft(), B_DumpAircraftToHomeBase(), aircraft_t::radar, and RADAR_InitialiseUFOs().

Referenced by AIR_Move().

◆ B_AntimatterInBase()

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

◆ B_AssembleMap()

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

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

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

◆ B_BaseHasItem()

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

References B_ItemInBase(), and objDef_t::isVirtual.

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

◆ B_BaseResetStatus()

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_t::baseStatus.

◆ B_Build()

base_t * B_Build ( const struct campaign_s * campaign,
const vec2_t pos,
const char * name,
bool fillBase = false )

References name.

◆ B_BuildBuilding()

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_t::base, BASE_SIZE, BASE_WORKING, base_t::baseStatus, baseBuildingTile_t::building, building_t::buildingStatus, ccs, cgi, CP_CheckCredits(), CP_UpdateCredits(), ERR_DROP, building_t::fixCosts, base_t::idx, building_t::idx, LIST_Foreach, base_t::map, building_t::pos, building_t::size, and building_t::timeStart.

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

◆ B_BuildingDestroy()

◆ B_CheckBuildingTypeStatus()

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

References B_GetNextBuildingByType(), building_t::buildingStatus, and type.

Referenced by BDEF_UpdateActiveBattery_f().

◆ B_Delete()

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

References base_t::alienContainment.

Referenced by B_Destroy(), and CP_ResetCampaignData().

◆ B_Destroy()

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

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

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

◆ B_DumpAircraftToHomeBase()

void B_DumpAircraftToHomeBase ( aircraft_t * aircraft)

Will unload all cargo to the homebase.

Parameters
[in,out]aircraftThe aircraft to dump

Definition at line 2084 of file cp_base.cpp.

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

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

◆ B_GetBaseByIDX()

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

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

◆ B_GetBaseTemplate()

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, cgi, i, and Q_streq.

Referenced by B_BuildFromTemplate().

◆ B_GetBuildingInBaseByType()

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

◆ B_GetBuildingStatus()

◆ B_GetBuildingTypeByCapacity()

◆ B_GetCapacityFromBuildingType()

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 416 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, MAX_CAP, and type.

Referenced by AIR_GetHangarCapacityType(), B_BuildingDestroy(), B_BuildingDestroy_f(), B_ListBuildings_f(), B_UpdateAllBaseBuildingStatus(), and TR_DestinationCapacityList_f().

◆ B_GetCount()

◆ B_GetCurrentSelectedBase()

◆ B_GetFirstUnfoundedBase()

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_t::founded, and MAX_BASES.

Referenced by B_Build().

◆ B_GetFoundedBaseByIDX()

◆ B_GetFreeBuildingType()

building_t * B_GetFreeBuildingType ( buildingType_t type)

References type, and xmlNode_t.

◆ B_GetInstallationLimit()

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

◆ B_GetMaxBuildingLevel()

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

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

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

◆ B_GetNext()

◆ B_GetNextBuilding()

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

References B_GetBuildingByIDX, ccs, and base_t::idx.

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

◆ B_GetNextBuildingByType()

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

References B_GetNextBuilding(), and building_t::buildingType.

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

◆ B_GetNumberOfBuildingsInBaseByBuildingType()

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_t::buildingStatus, cgi, and MAX_BUILDING_TYPE.

Referenced by B_BuildingDestroy(), and CP_BaseAttackStartMission().

◆ B_GetNumberOfBuildingsInBaseByTemplate()

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_t::buildingStatus, cgi, and building_t::tpl.

Referenced by B_FillBuildingInfo_f(), and B_ListBuildings_f().

◆ B_InitStartup()

void B_InitStartup ( void )

Resets console commands.

Definition at line 1970 of file cp_base.cpp.

References cgi.

Referenced by CP_InitStartup().

◆ B_IsBuildingDestroyable()

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

References B_GetNeighbours(), B_GetNextBuilding(), building_t::base, BASE_DESTROYED, base_t::baseStatus, ccs, cgi, linkedList_t::data, i, base_t::idx, building_t::idx, LIST_Foreach, MAX_BUILDINGS, and OBJZERO.

Referenced by B_BuildingDestroy(), and B_BuildingDestroy_f().

◆ B_ItemInBase()

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

References objDef_t::idx, objDef_t::isVirtual, equipDef_t::numItems, and base_t::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().

◆ B_ItemIsStoredInBaseStorage()

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

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

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

◆ B_LoadBaseSlotsXML()

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

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

Referenced by B_LoadXML(), and INS_LoadXML().

◆ B_LoadStorageXML()

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

References cgi, objDef_t::idx, INVSH_GetItemByID(), equipDef_t::numItems, equipDef_t::numItemsLoose, SAVE_BASES_ITEM, SAVE_BASES_NUM, SAVE_BASES_NUMLOOSE, SAVE_BASES_ODS_ID, and xmlNode_t.

Referenced by B_LoadXML().

◆ B_MapIsCellFree()

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.

◆ B_ParseBaseTemplate()

void B_ParseBaseTemplate ( const char * name,
const char ** text )

◆ B_ResetAllStatusAndCapacities()

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 706 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_t::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_t::name, PR_UpdateProductionCap(), RS_CountScientistsInBase(), and type.

Referenced by B_Build(), and B_PostLoadInitCapacity().

◆ B_SaveBaseSlotsXML()

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

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

Referenced by B_SaveXML(), and INS_SaveXML().

◆ B_SaveStorageXML()

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

References cgi, objDef_t::id, INVSH_GetItemByIDX(), equipDef_t::numItems, equipDef_t::numItemsLoose, SAVE_BASES_ITEM, SAVE_BASES_NUM, SAVE_BASES_NUMLOOSE, SAVE_BASES_ODS_ID, and xmlNode_t.

Referenced by B_SaveXML().

◆ B_SelectBase()

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_t::idx, MA_NEWBASE, MA_NONE, and MAX_BASES.

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

◆ B_SetBuildingStatus()

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

References B_MISC, cgi, DEBUG_CLIENT, base_t::hasBuilding, and MAX_BUILDING_TYPE.

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

◆ B_SetCurrentSelectedBase()

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_t::aircraftCurrent, B_GetNext(), base_t::baseStatus, cgi, INS_SetCurrentSelectedInstallation(), base_t::name, and base_t::selected.

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

◆ B_SetName()

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_t::name, name, and Q_strncpyz().

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

◆ B_SetUpFirstBase()

void B_SetUpFirstBase ( const struct campaign_s * campaign,
base_t * base )

References name.

◆ B_UpdateBaseCapacities()

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

References base_t::alienContainment, B_GetBuildingTypeByCapacity(), B_GetNextBuildingByType(), B_STATUS_CONSTRUCTION_FINISHED, B_UpdateBaseCapacities(), building_t::buildingStatus, building_t::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_t::capacity, ccs, cgi, capacities_t::cur, DEBUG_CLIENT, ERR_DROP, i, building_t::id, capacities_t::max, and MAX_CAP.

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

◆ B_UpdateBuildingConstructions()

void B_UpdateBuildingConstructions ( void )

◆ BS_BuySellAllowed()

bool BS_BuySellAllowed ( const base_t * base)

Returns true if you can buy or sell equipment.

Parameters
[in]basePointer to base to check on
See also
B_BaseInit_f

Definition at line 656 of file cp_market.cpp.

References B_GetBuildingStatus(), B_IsUnderAttack, and B_STORAGE.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick_f().

◆ E_HireAllowed()

bool E_HireAllowed ( const base_t * base)

Returns true if the current base is able to handle employees.

See also
B_BaseInit_f

Definition at line 985 of file cp_employee.cpp.

References B_GetBuildingStatus(), B_IsUnderAttack, and B_QUARTERS.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick_f().

◆ HOS_HospitalAllowed()

bool HOS_HospitalAllowed ( const base_t * base)

Returns true if you can enter in the hospital.

See also
B_BaseInit_f

Definition at line 210 of file cp_hospital.cpp.

References B_GetBuildingStatus(), B_HOSPITAL, and B_IsUnderAttack.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick_f().

◆ PR_ProductionAllowed()

bool PR_ProductionAllowed ( const base_t * base)

Returns true if the current base is able to produce items.

Parameters
[in]basePointer to the base.
See also
B_BaseInit_f

Definition at line 596 of file cp_produce.cpp.

References B_GetBuildingStatus(), B_IsUnderAttack, B_WORKSHOP, E_CountHired(), and EMPL_WORKER.

Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick_f(), PR_ProductionRun(), PR_ShowActiveProduction_f(), PR_UpdateProductionCap(), TEST_F(), TEST_F(), TEST_F(), and TR_TransferStart().

◆ RS_ResearchAllowed()

bool RS_ResearchAllowed ( const base_t * base)

Returns true if the current base is able to handle research.

See also
B_BaseInit_f probably menu function, but not for research gui

Definition at line 1840 of file cp_research.cpp.

References B_GetBuildingStatus(), B_IsUnderAttack, B_LAB, E_CountHired(), and EMPL_SCIENTIST.

Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick_f(), RS_ResearchRun(), RS_ShowActiveResearch_f(), and TR_TransferStart().