cp_base.h File Reference

Header for base management related stuff. More...

#include "cp_aliencont.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  cap_maxcur_s
 Store capacities in base. More...
struct  building_s
 A building with all it's data. More...
struct  baseBuildingTile_s
struct  baseWeapon_s
struct  base_s
 A base with all it's data. More...
struct  baseTemplate_s
 template for creating a base More...

Defines

#define MAX_BASES   8
#define MAX_BUILDINGS   32
#define MAX_BASETEMPLATES   5
#define MAX_BATTERY_DAMAGE   50
#define MAX_BASE_DAMAGE   100
#define MAX_BASE_SLOT   4
#define BASEMAP_SIZE_X   778.0
#define BASEMAP_SIZE_Y   672.0
#define BASE_SIZE   5
#define MAX_BASEBUILDINGS   BASE_SIZE * BASE_SIZE
#define MAX_EMPLOYEES_IN_BUILDING   64
#define MAX_BLOCKEDFIELDS   4
#define MIN_BLOCKEDFIELDS   1
#define BASE_TILE_SIZE   512
#define BASE_TILE_UNITS   (BASE_TILE_SIZE / UNIT_SIZE)
#define BASE_MAX_WORLDLEVEL   6
#define B_GetBaseIDX(base)   ((ptrdiff_t)((base) - ccs.bases))
#define B_GetBuildingIDX(base, building)   ((ptrdiff_t)((building) - ccs.buildings[base->idx]))
#define B_BuildingSetUsed(usedArray, buildingIDX)   { (usedArray)[buildingIDX] = qtrue; }
 Macro sets a building used.
#define B_BuildingGetUsed(usedArray, buildingIDX)   ((usedArray)[buildingIDX])
 Macro returns if a building is used.

Typedefs

typedef struct cap_maxcur_s capacities_t
 Store capacities in base.
typedef struct building_s building_t
 A building with all it's data.
typedef struct baseBuildingTile_s baseBuildingTile_t
typedef struct baseWeapon_s baseWeapon_t
typedef struct base_s base_t
 A base with all it's data.
typedef struct baseTemplate_s baseTemplate_t
 template for creating a base

Enumerations

enum  baseStatus_t { BASE_NOT_USED, BASE_UNDER_ATTACK, BASE_WORKING, BASE_DESTROYED }
 

Possible base states.

More...
enum  baseAction_t { BA_NONE, BA_NEWBUILDING, BA_MAX }
 

All possible base actions.

More...
enum  buildingStatus_t {
  B_STATUS_NOT_SET, B_STATUS_UNDER_CONSTRUCTION, B_STATUS_CONSTRUCTION_FINISHED, B_STATUS_WORKING,
  B_STATUS_DOWN
}
 

All possible building status.

More...
enum  buildingType_t {
  B_MISC, B_LAB, B_QUARTERS, B_STORAGE,
  B_WORKSHOP, B_HOSPITAL, B_HANGAR, B_ALIEN_CONTAINMENT,
  B_SMALL_HANGAR, B_POWER, B_COMMAND, B_ANTIMATTER,
  B_ENTRANCE, B_DEFENCE_MISSILE, B_DEFENCE_LASER, B_RADAR,
  MAX_BUILDING_TYPE
}
 

All different building types.

More...
enum  baseCapacities_t {
  CAP_ALIENS, CAP_AIRCRAFT_SMALL, CAP_AIRCRAFT_BIG, CAP_EMPLOYEES,
  CAP_ITEMS, CAP_LABSPACE, CAP_WORKSPACE, CAP_ANTIMATTER,
  MAX_CAP
}
 

All possible capacities in base.

More...

Functions

void B_UpdateBaseData (void)
 Updates base data.
int B_CheckBuildingConstruction (building_t *b, base_t *base)
 Checks whether the construction of a building is finished. Calls the onConstruct functions and assign workers, too.
float B_GetMaxBuildingLevel (const base_t *base, const buildingType_t type)
 Get the maximum level of a building type in a base.
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.
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.
building_tB_GetBuildingInBaseByType (const base_t *base, buildingType_t type, qboolean onlyWorking)
 Gets a building of a given type in the given 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 *baseTemplateName)
 Returns the baseTemplate in the global baseTemplate list that has the unique name baseTemplateID.
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_InitStartup (void)
 Resets console commands.
void B_NewBases (void)
void B_SetUpBase (base_t *base, vec2_t pos)
 Setup new base, uses template 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.
void B_SelectBase (const base_t *base)
void B_UpdateBaseCount (void)
 Update menu script related cvars when the amount of bases changed.
int B_GetFoundedBaseCount (void)
 Counts the number of bases.
void B_Destroy (base_t *base)
 Destroy a base.
base_tB_GetFirstUnfoundedBase (void)
 Get the lower IDX of unfounded base.
base_tB_GetCurrentSelectedBase (void)
void B_SetCurrentSelectedBase (const base_t *base)
qboolean B_AssembleMap (const base_t *base)
 Perform the base assembling in case of an alien attack.
buildingType_t B_GetBuildingTypeByCapacity (baseCapacities_t cap)
 Get building type by base capacity.
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.
void B_BuildingStatus (const base_t *base, const building_t *building)
 Displays the status of a building for baseview.
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.
qboolean 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, 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.
building_tB_SetBuildingByClick (base_t *base, const building_t const *buildingTemplate, int row, int col)
 Set the currently selected building.
void B_MarkBuildingDestroy (base_t *base, building_t *building)
 Mark a building for destruction - you only have to confirm it now.
qboolean B_BuildingDestroy (base_t *base, 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 buuilding type in a base.
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_ResetBuildingCurrent (base_t *base)
 Resets the buildingCurrent variable and baseAction.
qboolean B_ItemIsStoredInBaseStorage (const objDef_t *obj)
 Check if an item is stored in storage.
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.
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.
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.
baseCapacities_t B_GetCapacityFromBuildingType (buildingType_t type)
 Get the capacity associated to a building type.
void B_ResetAllStatusAndCapacities (base_t *base, qboolean firstEnable)
 Recalculate status and capacities of one base.
void B_UpdateStorageCap (base_t *base)
 Update Storage Capacity.
void B_RemoveAircraftExceedingCapacity (base_t *base, buildingType_t buildingType)
 Actions to perform when destroying one hangar.
void B_RemoveItemsExceedingCapacity (base_t *base)
 Remove items until everything fits in storage.
void B_RemoveAntimatterExceedingCapacity (base_t *base)
 Remove exceeding antimatter if an antimatter tank has been destroyed.
int B_FreeCapacity (const base_t *base, baseCapacities_t cap)
 Returns the free capacity of a type.
void B_BaseMenuInit (const base_t *base)
void B_DrawBuilding (base_t *base, building_t *building)
 Draws a building.
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_SaveBaseSlotsXML (const baseWeapon_t *weapons, const int numWeapons, mxml_node_t *p)
 Saves the missile and laser slots of a base or sam site.
int B_LoadBaseSlotsXML (baseWeapon_t *weapons, int numWeapons, mxml_node_t *p)
 Loads 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_LoadStorageXML (mxml_node_t *parent, equipDef_t *equip)
 Loads base storage.
qboolean B_ScriptSanityCheck (void)
 Checks the parsed buildings for errors.
int B_GetInstallationLimit (void)
 Counts the actual installation count limit.
qboolean BS_BuySellAllowed (const base_t *base)
 Returns true if you can buy or sell equipment.
qboolean AIR_AircraftAllowed (const base_t *base)
 Returns true if the current base is able to handle aircraft.
qboolean RS_ResearchAllowed (const base_t *base)
 Returns true if the current base is able to handle research.
qboolean PR_ProductionAllowed (const base_t *base)
 Returns true if the current base is able to produce items.
qboolean E_HireAllowed (const base_t *base)
 Returns true if the current base is able to handle employees.
qboolean AC_ContainmentAllowed (const base_t *base)
 Returns true if the current base is able to handle captured aliens.
qboolean HOS_HospitalAllowed (const base_t *base)
 Returns true if you can enter in the hospital.

Variables

vec2_t newBasePos

Detailed Description

Header for base management related stuff.

Definition in file cp_base.h.


Define Documentation

#define B_BuildingGetUsed ( usedArray,
buildingIDX   )     ((usedArray)[buildingIDX])

Macro returns if a building is used.

Parameters:
[in] usedArray must be a qboolean array of the size MAX_BUILDINGS
[in] buildingIDX Index of building to check

Definition at line 75 of file cp_base.h.

Referenced by B_AssembleMap(), and UI_BaseMapNodeDraw().

#define B_BuildingSetUsed ( usedArray,
buildingIDX   )     { (usedArray)[buildingIDX] = qtrue; }

Macro sets a building used.

Parameters:
[in] usedArray must be a qboolean array of the size MAX_BUILDINGS
[in] buildingIDX Index of building to set used

Definition at line 69 of file cp_base.h.

Referenced by B_AssembleMap(), and UI_BaseMapNodeDraw().

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

Definition at line 61 of file cp_base.h.

Referenced by B_LoadXML(), and B_SetUpBase().

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

Definition at line 62 of file cp_base.h.

Referenced by B_LoadXML(), and B_SetBuildingByClick().

#define BASE_MAX_WORLDLEVEL   6

Definition at line 59 of file cp_base.h.

Referenced by B_AssembleMap().

#define BASE_SIZE   5
#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 57 of file cp_base.h.

#define BASE_TILE_UNITS   (BASE_TILE_SIZE / UNIT_SIZE)

Definition at line 58 of file cp_base.h.

Referenced by B_AssembleMap().

#define BASEMAP_SIZE_X   778.0
Todo:
take the values from scriptfile

Definition at line 41 of file cp_base.h.

#define BASEMAP_SIZE_Y   672.0

Definition at line 42 of file cp_base.h.

#define MAX_BASE_DAMAGE   100

Definition at line 37 of file cp_base.h.

#define MAX_BASE_SLOT   4

Definition at line 38 of file cp_base.h.

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

#define MAX_BASEBUILDINGS   BASE_SIZE * BASE_SIZE

Definition at line 46 of file cp_base.h.

Referenced by B_ParseBaseTemplate().

#define MAX_BASES   8
#define MAX_BASETEMPLATES   5

Definition at line 34 of file cp_base.h.

Referenced by B_ParseBaseTemplate().

#define MAX_BATTERY_DAMAGE   50

Definition at line 36 of file cp_base.h.

#define MAX_BLOCKEDFIELDS   4

Definition at line 50 of file cp_base.h.

Referenced by B_BuildFromTemplate().

#define MAX_BUILDINGS   32
#define MAX_EMPLOYEES_IN_BUILDING   64

Definition at line 48 of file cp_base.h.

#define MIN_BLOCKEDFIELDS   1

Definition at line 51 of file cp_base.h.

Referenced by B_BuildFromTemplate().


Typedef Documentation

typedef struct base_s base_t

A base with all it's data.

template for creating a base

typedef struct baseWeapon_s baseWeapon_t
typedef struct building_s building_t

A building with all it's data.

typedef struct cap_maxcur_s capacities_t

Store capacities in base.


Enumeration Type Documentation

All possible base actions.

Enumerator:
BA_NONE 
BA_NEWBUILDING 

hovering the needed base tiles for this building

BA_MAX 

Definition at line 89 of file cp_base.h.

All possible capacities in base.

Enumerator:
CAP_ALIENS 

Live aliens stored in base.

CAP_AIRCRAFT_SMALL 

Small aircraft in base.

CAP_AIRCRAFT_BIG 

Big aircraft in base.

CAP_EMPLOYEES 

Personel in base.

CAP_ITEMS 

Items in base.

CAP_LABSPACE 

Space for scientists in laboratory.

CAP_WORKSPACE 

Space for workers in workshop.

CAP_ANTIMATTER 

Space for Antimatter Storage.

MAX_CAP 

Definition at line 130 of file cp_base.h.

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 81 of file cp_base.h.

All possible building status.

Enumerator:
B_STATUS_NOT_SET 

not build yet

B_STATUS_UNDER_CONSTRUCTION 

right now under construction

B_STATUS_CONSTRUCTION_FINISHED 

construction finished - no workers assigned

B_STATUS_WORKING 

working normal (or workers assigned when needed)

B_STATUS_DOWN 

totally damaged

Definition at line 97 of file cp_base.h.

All different building types.

Note:
if you change the order, you'll load values of hasBuilding in wrong indice
Enumerator:
B_MISC 

this building is nothing with a special function (used when a building appears twice in .ufo file)

B_LAB 

this building is a lab

B_QUARTERS 

this building is a quarter

B_STORAGE 

this building is a storage

B_WORKSHOP 

this building is a workshop

B_HOSPITAL 

this building is a hospital

B_HANGAR 

this building is a hangar

B_ALIEN_CONTAINMENT 

this building is an alien containment

B_SMALL_HANGAR 

this building is a small hangar

B_POWER 

this building is power plant

B_COMMAND 

this building is command centre

B_ANTIMATTER 

this building is antimatter storage

B_ENTRANCE 

this building is an entrance

B_DEFENCE_MISSILE 

this building is a missile rack

B_DEFENCE_LASER 

this building is a laser battery

B_RADAR 

this building is a radar

MAX_BUILDING_TYPE 

Definition at line 108 of file cp_base.h.


Function Documentation

qboolean AC_ContainmentAllowed ( const base_t base  ) 

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

See also:
B_BaseInit_f
Note:
Alien cont. must be accessible during base attack to kill aliens.

Definition at line 791 of file cp_aliencont.c.

References B_ALIEN_CONTAINMENT, B_GetBuildingStatus(), qfalse, and qtrue.

Referenced by AC_SaveXML(), B_BaseInit_f(), B_BuildingOpenAfterClick(), CP_TransferOfAliensToOtherBaseNeeded(), and TR_TransferAliensFromMission_f().

qboolean 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 2905 of file cp_aircraft.c.

References B_GetBuildingStatus(), B_HANGAR, and B_SMALL_HANGAR.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick().

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_BaseMenuInit ( const base_t base  ) 
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.

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

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

building_t* B_GetFreeBuildingType ( buildingType_t  type  ) 
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().

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

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

void B_NewBases ( void   ) 
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_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_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  ) 
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().

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

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

qboolean BS_BuySellAllowed ( const base_t base  ) 

Returns true if you can buy or sell equipment.

Parameters:
[in] base Pointer to base to check on
See also:
B_BaseInit_f

Definition at line 408 of file cp_market.c.

References B_GetBuildingStatus(), B_STORAGE, BASE_UNDER_ATTACK, base_s::baseStatus, qfalse, and qtrue.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick().

qboolean 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 1350 of file cp_employee.c.

References B_GetBuildingStatus(), B_QUARTERS, BASE_UNDER_ATTACK, base_s::baseStatus, qfalse, and qtrue.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick().

qboolean HOS_HospitalAllowed ( const base_t base  ) 

Returns true if you can enter in the hospital.

See also:
B_BaseInit_f

Definition at line 205 of file cp_hospital.c.

References B_GetBuildingStatus(), B_HOSPITAL, BASE_UNDER_ATTACK, base_s::baseStatus, qfalse, and qtrue.

Referenced by B_BaseInit_f(), and B_BuildingOpenAfterClick().

qboolean PR_ProductionAllowed ( const base_t base  ) 

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

Parameters:
[in] base Pointer to the base.
See also:
B_BaseInit_f

Definition at line 726 of file cp_produce.c.

References B_GetBuildingStatus(), B_WORKSHOP, BASE_UNDER_ATTACK, base_s::baseStatus, E_CountHired(), EMPL_WORKER, qfalse, and qtrue.

Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick(), PR_ProductionRun(), and TR_TransferStart().

qboolean 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 1916 of file cp_research.c.

References B_GetBuildingStatus(), B_LAB, BASE_UNDER_ATTACK, base_s::baseStatus, E_CountHired(), EMPL_SCIENTIST, qfalse, and qtrue.

Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick(), RS_ResearchRun(), and TR_TransferStart().


Variable Documentation

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


Generated by  doxygen 1.6.2