27 #include "../../cl_shared.h"
28 #include "../../cl_inventory.h"
29 #include "../../ui/ui_dataids.h"
30 #include "../../../shared/parse.h"
45 #define B_GetBuildingByIDX(baseIdx, buildingIdx) (&ccs.buildings[(baseIdx)][(buildingIdx)])
46 #define B_GetBuildingIDX(base, building) ((ptrdiff_t)((building) - ccs.buildings[base->idx]))
47 #define B_GetBaseIDX(base) ((ptrdiff_t)((base) - ccs.bases))
62 const int x = building->
pos[0];
63 const int y = building->
pos[1];
68 for (
int i = x;
i < x + building->
size[0];
i++) {
76 for (
int i = y;
i < y + building->
size[1];
i++) {
92 static bool B_IsCoherent (
const base_t* base)
100 cgi->LIST_AddPointer(&queue, (
void*)bldg);
106 while (!
cgi->LIST_IsEmpty(queue)) {
108 found[bldg->
idx] = 1;
109 cgi->LIST_RemoveEntry(&queue, queue);
113 if (found[bldg->
idx] == 0) {
114 found[bldg->
idx] = 1;
115 cgi->LIST_AddPointer(&queue, (
void*)bldg);
118 cgi->LIST_Delete(&neighbours);
120 cgi->LIST_Delete(&queue);
146 found[row][column] = -1;
150 for (
int y = 0; y <
BASE_SIZE &&
cgi->LIST_IsEmpty(queue); y++) {
151 for (
int x = 0; x <
BASE_SIZE &&
cgi->LIST_IsEmpty(queue); x++) {
152 if (x == column && y == row)
155 cgi->LIST_AddPointer(&queue, &base->
map[y][x]);
159 if (
cgi->LIST_IsEmpty(queue))
163 while (!
cgi->LIST_IsEmpty(queue)) {
165 cgi->LIST_RemoveEntry(&queue, queue);
166 const int x = tile->
posX;
167 const int y = tile->
posY;
172 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y][x - 1]);
175 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y][x + 1]);
178 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y - 1][x]);
181 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y + 1][x]);
183 cgi->LIST_Delete(&queue);
205 for (
int placed = 0; placed <
count; placed++) {
236 if (bldg != building) {
237 cgi->LIST_AddPointer(&queue, (
void*)bldg);
247 found[building->
idx] = 1;
249 while (!
cgi->LIST_IsEmpty(queue)) {
251 found[bldg->
idx] = 1;
252 cgi->LIST_RemoveEntry(&queue, queue);
256 if (found[bldg->
idx] == 0) {
257 found[bldg->
idx] = 1;
258 cgi->LIST_AddPointer(&queue, (
void*)bldg);
261 cgi->LIST_Delete(&neighbours);
263 cgi->LIST_Delete(&queue);
296 assert(lastBase < endOfBases);
301 if (base >= endOfBases)
349 assert(lastBuilding < endOfBuildings);
351 building = lastBuilding;
354 if (building >= endOfBuildings)
407 return cntlocal ?
true :
false;
481 if (buildingType ==
B_MISC)
487 cgi->Com_Printf(
"B_GetBuildingStatus: Building-type %i does not exist.\n", buildingType);
500 if (buildingType ==
B_MISC) {
501 cgi->Com_Printf(
"B_SetBuildingStatus: No status is associated to B_MISC type of building.\n");
505 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_SetBuildingStatus: set status for %i to %i\n", buildingType, newStatus);
507 cgi->Com_Printf(
"B_SetBuildingStatus: Type of building %i does not exist\n", buildingType);
526 max = std::max(building->
level, max);
544 static inline void B_AddMap (
char* maps,
size_t mapsLength,
char* coords,
size_t coordsLength,
const char* map,
int col,
int row)
547 Q_strcat(maps, mapsLength,
"%s", map);
565 cgi->Com_Printf(
"B_AssembleMap: No base to assemble\n");
572 for (
int row = 0; row <
BASE_SIZE; row++) {
573 for (
int col = 0; col <
BASE_SIZE; col++) {
576 B_AddMap(maps, mapsLength, coords, coordsLength,
"b/empty ", col, row);
579 if (building->
pos[0] != col || building->
pos[1] != row)
582 B_AddMap(maps, mapsLength, coords, coordsLength,
"b/construction ", col, row);
586 cgi->Com_Error(
ERR_DROP,
"MapPart for building '%s' is missing'", building->
id);
587 B_AddMap(maps, mapsLength, coords, coordsLength,
va(
"b/%s ", building->
mapPart), col, row);
617 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Status of building %s is changed to %i.\n",
637 bool returnValue =
false;
644 if (dependsBuilding && buildingType == dependsBuilding->
buildingType) {
760 cgi->Com_Printf(
"B_ResetAllStatusAndCapacities: Warning, capacity of %i is bigger than maximum capacity\n",
i);
778 if (base->
map[(
int)building->
pos[1]][(
int)building->
pos[0]].
building != building) {
779 cgi->Com_Error(
ERR_DROP,
"B_BuildingDestroy: building mismatch at base %i pos %i,%i.",
780 base->
idx, (
int)building->
pos[0], (
int)building->
pos[1]);
796 int const baseIDX = base->
idx;
798 int const idx = building->
idx;
800 for (
int y = building->
pos[1]; y < building->
pos[1] + building->
size[1]; y++)
801 for (
int x = building->
pos[0]; x < building->
pos[0] + building->
size[0]; x++)
808 for (
int i = 0;
i < cntBldgs;
i++) {
814 for (
int y = bldg->
pos[1]; y < bldg->
pos[1] + bldg->
size[1]; y++)
815 for (
int x = (
int)bldg->
pos[0]; x < bldg->
pos[0] + bldg->
size[0]; x++)
840 if (runDisableCommand) {
849 cgi->Cmd_ExecuteString(
"base_init %d", base->
idx);
865 base_t* newbase =
nullptr;
867 while ((newbase =
B_GetNext(newbase)) !=
nullptr) {
922 for (
int buildingIdx =
ccs.
numBuildings[base->
idx] - 1; buildingIdx >= 0; buildingIdx--) {
948 static void B_Destroy_f (
void)
950 if (
cgi->Cmd_Argc() < 2) {
956 if (baseIdx < 0 || baseIdx >=
MAX_BASES) {
957 cgi->Com_Printf(
"B_Destroy_f: baseIdx %i is outside bounds\n", baseIdx);
963 cgi->Com_Printf(
"B_Destroy_f: Base %i not founded\n", baseIdx);
1015 buildingNew =
B_BuildBuilding(base, buildingTemplate, (
int)pos[0], (
int)pos[1]);
1021 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Base %i new building: %s at (%.0f:%.0f)\n",
1022 base->
idx, buildingNew->
id, buildingNew->
pos[0], buildingNew->
pos[1]);
1082 cgi->Com_Error(
ERR_DROP,
"B_BuildFromTemplate: Cannot build base. No space for it's buildings!");
1122 cgi->Com_Printf(
"B_SetUpFirstBase: Cannot add %s aircraft to the base, no free space", tempAircraft->
id);
1131 cgi->Com_Error(
ERR_DROP,
"B_SetUpFirstBase: Hiring pilot failed.");
1159 while ((base =
B_GetNext(base)) !=
nullptr) {
1188 cgi->Com_Error(
ERR_DROP,
"You can only build a base in an active campaign");
1192 cgi->Com_Error(
ERR_DROP,
"Cannot build more bases");
1213 cgi->Com_Error(
ERR_DROP,
"No base template for setting up the first base given");
1248 if (!baseTemplateID)
1255 cgi->Com_Printf(
"Base Template %s not found\n", baseTemplateID);
1283 if (!buildingTemplate)
1284 cgi->Com_Error(
ERR_DROP,
"no current building\n");
1295 for (
int y = row; y < row + buildingTemplate->
size[1]; y++)
1296 for (
int x = col; x < col + buildingTemplate->
size[0]; x++)
1303 *buildingNew = *buildingTemplate;
1306 buildingNew->
base = base;
1307 buildingNew->
pos[0] = col;
1308 buildingNew->
pos[1] = row;
1313 bool coherent =
false;
1322 cgi->LIST_Delete(&neighbours);
1329 for (
int y = row; y < row + buildingNew->
size[1]; y++)
1330 for (
int x = col; x < col + buildingNew->
size[0]; x++)
1341 cgi->Cmd_ExecuteString(
"base_init %d", base->
idx);
1356 cgi->Com_Printf(
"B_GetNumberOfBuildingsInBaseByTemplate: No base given!\n");
1361 cgi->Com_Printf(
"B_GetNumberOfBuildingsInBaseByTemplate: no building-type given!\n");
1366 if (tpl != tpl->
tpl) {
1367 cgi->Com_Printf(
"B_GetNumberOfBuildingsInBaseByTemplate: No building-type given as parameter. It's probably a normal building!\n");
1371 int numberOfBuildings = 0;
1375 numberOfBuildings++;
1377 return numberOfBuildings;
1389 cgi->Com_Printf(
"B_GetNumberOfBuildingsInBaseByBuildingType: No base given!\n");
1394 cgi->Com_Printf(
"B_GetNumberOfBuildingsInBaseByBuildingType: no sane building-type given!\n");
1398 int numberOfBuildings = 0;
1402 numberOfBuildings++;
1404 return numberOfBuildings;
1437 const char* errhead =
"B_ParseBaseTemplate: unexpected end of file (names ";
1447 if (!*text || *token !=
'{') {
1448 cgi->Com_Printf(
"B_ParseBaseTemplate: Template \"%s\" without body ignored\n", name);
1453 cgi->Com_Error(
ERR_DROP,
"B_ParseBaseTemplate: too many base templates");
1473 if (!
Q_streq(token,
"building")) {
1474 cgi->Com_Error(
ERR_DROP,
"B_ParseBaseTemplate: \"building\" token expected but \"%s\" found", token);
1478 if (!
cgi->Com_ParseList(text, &list)) {
1479 cgi->Com_Error(
ERR_DROP,
"B_ParseBaseTemplate: error while reading building tuple");
1482 if (
cgi->LIST_Count(list) != 2) {
1483 cgi->Com_Error(
ERR_DROP,
"B_ParseBaseTemplate: building tuple must contains 2 elements (id pos)");
1486 const char* buildingToken = (
char*)list->
data;
1487 const char* positionToken = (
char*)list->
next->
data;
1490 cgi->Com_Error(
ERR_DROP,
"B_ParseBaseTemplate: too many buildings");
1500 cgi->Com_Error(
ERR_DROP,
"B_ParseBaseTemplate: Found more %s than allowed in template %s (%d))", buildingToken, baseTemplate->
id, tile->
building->
maxCount);
1506 cgi->Com_Error(
ERR_DROP,
"B_ParseBaseTemplate: Could not find building with id %s\n", baseTemplate->
id);
1509 cgi->Com_EParseValue(pos, positionToken,
V_POS, 0,
sizeof(
vec2_t));
1510 tile->
posX = pos[0];
1511 tile->
posY = pos[1];
1513 cgi->Com_Error(
ERR_DROP,
"Invalid template coordinates for building %s in template %s given",
1518 cgi->Com_Error(
ERR_DROP,
"Base template '%s' has ambiguous positions for buildings set.", baseTemplate->
id);
1519 map[tile->
posY][tile->
posX] =
true;
1521 cgi->LIST_Delete(&list);
1527 if (building && building->
mandatory && !buildingNums[
i]) {
1528 cgi->Com_Error(
ERR_DROP,
"Every base template needs one '%s'! '%s' has none.", building->
id, baseTemplate->
id);
1539 for (
int baseIdx = 0; baseIdx <
MAX_BASES; baseIdx++) {
1581 while ((base =
B_GetNext(base)) !=
nullptr)
1612 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_SelectBase_f: select base with id %i\n", base->
idx);
1614 cgi->Cmd_ExecuteString(
va(
"ui_push bases %d", base->
idx));
1669 cgi->Com_Error(
ERR_DROP,
"CL_SwapSkills: illegal skill %i.\n", skill);
1689 if (rightHand && rightHand->
ammoDef() && rightHand->
def())
1691 if (holster && holster->
ammoDef() && holster->
def())
1695 if (fdHolster ==
nullptr)
1697 if (fdRight ==
nullptr)
1700 const byte fmode1 = 0;
1701 const byte fmode2 = 1;
1703 if (rightHand !=
nullptr) {
1721 const int teamSize =
cgi->LIST_Count(team);
1723 for (
int i = 0;
i < teamSize;
i++) {
1730 if (cp1__iter ==
nullptr)
1743 || (no1 && no1 == no2)) {
1745 }
else if (no1 < no2) {
1773 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_InitialEquipment: Packing initial equipment for %s.\n", chr->
name);
1774 cgi->INV_EquipActor(chr, ed,
nullptr,
cgi->GAME_GetChrMaxLoad(chr));
1775 cgi->LIST_AddPointer(&chrListTemp, (
void*)chr);
1780 cgi->LIST_Delete(&chrListTemp);
1801 static void B_BuildingList_f (
void)
1804 while ((base =
B_GetNext(base)) !=
nullptr) {
1805 cgi->Com_Printf(
"\nBase id %i: %s\n", base->
idx, base->
name);
1810 cgi->Com_Printf(
"...Building: %s #%i - id: %i\n", building->
id,
1812 cgi->Com_Printf(
"...image: %s\n", building->
image);
1813 cgi->Com_Printf(
".....Status:\n");
1816 if (k > 1 && k % BASE_SIZE == 0)
1817 cgi->Com_Printf(
"\n");
1822 cgi->Com_Printf(
"\n");
1832 static void B_BaseList_f (
void)
1835 while ((base =
B_GetNext(base)) !=
nullptr) {
1837 cgi->Com_Printf(
"Base idx %i not founded\n\n", base->
idx);
1841 cgi->Com_Printf(
"Base idx %i\n", base->
idx);
1842 cgi->Com_Printf(
"Base name %s\n", base->
name);
1843 cgi->Com_Printf(
"Base founded %i\n", base->
founded);
1845 cgi->Com_Printf(
"Base numLaserBattery %i\n", base->
numLasers);
1848 cgi->Com_Printf(
"Base numSensoredAircraft %i\n", base->
radar.
numUFOs);
1850 cgi->Com_Printf(
"Base hasBuilding[]:\n");
1851 cgi->Com_Printf(
"Misc Lab Quar Stor Work Hosp Hang Cont SHgr UHgr SUHg Powr cgi->Cmd AMtr Entr Miss Lasr Rdr Team\n");
1856 cgi->Com_Printf(
"\n");
1857 cgi->Com_Printf(
"Base pos %.02f:%.02f\n", base->
pos[0], base->
pos[1]);
1858 cgi->Com_Printf(
"Base map:\n");
1859 for (
int row = 0; row <
BASE_SIZE; row++) {
1861 cgi->Com_Printf(
"\n");
1862 for (
int col = 0; col <
BASE_SIZE; col++)
1866 cgi->Com_Printf(
"\n\n");
1874 static void B_PrintCapacities_f (
void)
1876 if (
cgi->Cmd_Argc() < 2) {
1890 if (buildingType >= MAX_BUILDING_TYPE) {
1891 cgi->Com_Printf(
"B_PrintCapacities_f: Could not find building associated with capacity %i\n",
i);
1898 cgi->Com_Printf(
"Building: %s, capacity max: %i, capacity cur: %i\n",
1908 static void B_BuildingConstructionFinished_f (
void)
1910 if (
cgi->Cmd_Argc() < 2) {
1938 static void B_ResetAllStatusAndCapacities_f (
void)
1943 while ((base =
B_GetNext(base)) !=
nullptr) {
1952 static void B_CheckCoherency_f (
void)
1954 if (
cgi->Cmd_Argc() < 2) {
1964 cgi->Com_Printf(
"Base '%s' (idx:%i) is %scoherent.\n", base->
name, base->
idx, (B_IsCoherent(base)) ?
"" :
"not ");
1974 cgi->Cmd_AddCommand(
"debug_listbase", B_BaseList_f,
"Print base information to the game console");
1975 cgi->Cmd_AddCommand(
"debug_listbuilding", B_BuildingList_f,
"Print building information to the game console");
1976 cgi->Cmd_AddCommand(
"debug_listcapacities", B_PrintCapacities_f,
"Debug function to show all capacities in given base");
1977 cgi->Cmd_AddCommand(
"debug_basereset", B_ResetAllStatusAndCapacities_f,
"Reset building status and capacities of all bases");
1978 cgi->Cmd_AddCommand(
"debug_destroybase", B_Destroy_f,
"Destroy a base");
1979 cgi->Cmd_AddCommand(
"debug_buildingfinished", B_BuildingConstructionFinished_f,
"Finish construction for every building in the current base");
1980 cgi->Cmd_AddCommand(
"debug_baseiscoherent", B_CheckCoherency_f,
"Checks if all buildings are connected on a base");
2013 while ((base =
B_GetNext(base)) !=
nullptr) {
2020 _(
"Construction of %s building finished in %s."),
_(building->
name), base->
name);
2050 if (item->amount > 0)
2058 numitems += item->amount;
2065 cgi->LIST_Delete(&items);
2069 va(
ngettext(
"%i collected item",
"%i collected items", numitems), numitems), gained);
2173 int buildingTemplateIDX = -1;
2185 buildingTemplateIDX =
i;
2195 if (buildingTemplateIDX != -1)
2196 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_UpdateBaseCapacities: updated capacity of %s: %i\n",
2211 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_UpdateBaseCapacities: going to update ALL capacities.\n");
2213 for (
int i = 0;
i < cap;
i++) {
2219 cgi->Com_Error(
ERR_DROP,
"Unknown capacity limit for this base: %i \n", cap);
2231 for (
int i = 0;
i < numWeapons;
i++) {
2235 if (weapons[
i].target)
2274 cgi->Com_Printf(
"B_SaveXML: Base (idx: %i) not founded!\n", b->
idx);
2289 for (
int row = 0; row <
BASE_SIZE; row++) {
2290 for (
int column = 0; column <
BASE_SIZE; column++) {
2368 while ((base =
B_GetNext(base)) !=
nullptr)
2394 cgi->Com_Printf(
"B_Load: Could not find item '%s'\n", s);
2414 cgi->Com_Printf(
"Error: Node 'bases' wasn't found in savegame\n");
2431 cgi->Com_Printf(
"Invalid base index %i\n", b->
idx);
2438 cgi->Com_Printf(
"Invalid base status '%s'\n", str);
2459 if (buildingIdx != -1)
2466 cgi->Com_Printf(
"inconstent base layout found\n");
2482 cgi->Com_Printf(
"building ID is greater than MAX buildings\n");
2488 if (buildingType[0] ==
'\0') {
2489 cgi->Com_Printf(
"No buildingtype set\n");
2495 if (!buildingTemplate)
2501 if (building->
idx != buildId) {
2502 cgi->Com_Printf(
"building ID doesn't match\n");
2510 cgi->Com_Printf(
"Invalid building status '%s'\n", str);
2587 cap->
cur += (amount * obj->
size);
2589 }
else if (amount < 0) {
2592 amount = std::max(amount, -itemInBase);
2594 cap->
cur += (amount * obj->
size);
2648 }
else if (amount < 0) {
2651 amount = std::max(amount, -inBase);
2652 cap->
cur += (amount);
#define MAX_BASEBUILDINGS
static void B_UpdateAllBaseBuildingStatus(building_t *building, buildingStatus_t status)
Updates base status for particular buildings as well as capacities.
#define SAVE_BASES_BUILDING_PLACE
bool B_SaveXML(xmlNode_t *parent)
Save callback for saving in xml format.
const objDef_t * INVSH_GetItemByIDSilent(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
#define FOREACH_XMLNODE(var, node, name)
static const constListEntry_t saveBaseConstants[]
static void B_AddMap(char *maps, size_t mapsLength, char *coords, size_t coordsLength, const char *map, int col, int row)
Adds a map to the given position to the map string.
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.
const float RADAR_BASERANGE
void RADAR_Initialise(radar_t *radar, float range, float trackingRange, float level, bool updateSourceRadarMap)
Set radar range to new value.
A building with all it's data.
uiMessageListNodeMessage_t * MSO_CheckAddNewMessage(const notify_t messagecategory, const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup)
Adds a new message to message stack. It uses message settings to verify whether sound should be playe...
void B_UpdateBuildingConstructions(void)
Updates base data.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
QGL_EXTERN GLint GLenum type
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
static void B_AddBlockedTiles(base_t *base, int count)
Fuction to put blocked tiles on basemap.
aircraft_t * AIR_NewAircraft(base_t *base, const aircraft_t *aircraftTemplate)
Places a new aircraft in the given base.
this is a fire definition for our weapons/ammo
bool E_HireEmployeeByType(base_t *base, employeeType_t type)
Hires the first free employee of that type.
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
float B_GetMaxBuildingLevel(const base_t *base, const buildingType_t type)
Get the maximum level of a building type in a base.
int B_GetNumberOfBuildingsInBaseByTemplate(const base_t *base, const building_t *tpl)
Counts the number of buildings of a particular type in a base.
int experience[SKILL_NUM_TYPES+1]
#define SAVE_BASES_BUILDINGS
int E_CountAllHired(const base_t *const base, const bool peopleOnly)
Counts all hired employees of a given base.
researchStatus_t statusResearch
weaponFireDefIndex_t weapFdsIdx
void AIM_AutoEquipAircraft(aircraft_t *aircraft)
Auto Add weapon and ammo to an aircraft.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
int B_AddToStorage(base_t *base, const objDef_t *obj, int amount)
Add/remove items to/from the storage.
bool B_IsBuildingDestroyable(const building_t *building)
Returns if a base building is destroyable.
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
void empty(void)
Empties the cargo.
char firstBaseTemplate[MAX_VAR]
#define CAP_Get(base, capacity)
Capacity macros.
void B_ResetAllStatusAndCapacities(base_t *base, bool firstEnable)
Recalculate status and capacities of one base.
void RS_MarkResearchable(const base_t *base, bool init)
Marks all the techs that can be researched. Automatically researches 'free' techs such as ammo for a ...
void B_UpdateBaseCapacities(baseCapacities_t cap, base_t *base)
Updates base capacities.
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.
const float RADAR_BASETRACKINGRANGE
base_t * B_GetCurrentSelectedBase(void)
returns the currently selected base
static bool B_CheckBuildingConstruction(building_t *building)
Checks whether the construction of a building is finished. Calls the onEnable functions and assign wo...
xmlNode_t *IMPORT * XML_GetPos3(xmlNode_t *parent, const char *name, vec3_t pos)
bool B_LoadXML(xmlNode_t *parent)
Loads base data.
const objDef_t * def(void) const
void INS_SetCurrentSelectedInstallation(const installation_t *installation)
Sets the currently selected installation.
class AlienContainment * alienContainment
void AIR_MoveAircraftIntoNewHomebase(aircraft_t *aircraft, base_t *base)
Moves a given aircraft to a new base (also the employees and inventory)
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
const byte * GEO_GetColor(const vec2_t pos, mapType_t type, bool *coast)
Returns the color value from geoscape of a certain mask (terrain, culture or population) at a given p...
void AL_AddAliens(aircraft_t *aircraft)
Puts alien cargo into Alien Containment.
#define ABILITY_NUM_TYPES
bool GEO_IsRadarOverlayActivated(void)
void E_HireForBuilding(base_t *base, building_t *building, int num)
Hires some employees of appropriate type for a building.
void CP_MissionNotifyBaseDestroyed(const base_t *base)
Notify that a base has been removed.
#define SAVE_BASES_BASESTATUS
buildingType_t
All different building types.
template for creating a base
#define SAVE_BASES_BUILDINGSPACE
static void B_MoveAircraftOnGeoscapeToOtherBases(const base_t *base)
Will ensure that aircraft on geoscape are not stored in a base that no longer has any hangar left...
static void B_AddBuildingToBasePos(base_t *base, const building_t *buildingTemplate, bool hire, const vec2_t pos)
Build starting building in the first base, and hire employees.
Defines all attributes of objects used in the inventory.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
#define SAVE_BASES_LASERS
building_t * B_GetBuildingTemplate(const char *buildingName)
Returns the building in the global building-types list that has the unique name buildingID.
linkedList_t * initialCraft
void B_BaseResetStatus(base_t *const base)
Sets the baseStatus to BASE_NOT_USED.
#define SAVE_BASES_BATTERIES
uiMessageListNodeMessage_t * MS_AddNewMessage(const char *title, const char *text, messageType_t type, technology_t *pedia, bool popup, bool playSound)
Adds a new message to message stack.
static void B_InitialEquipment(aircraft_t *aircraft, const equipDef_t *ed)
Prepares initial equipment for initial team the beginning of the campaign.
memPool_t * cp_campaignPool
#define CAP_GetCurrent(base, capacity)
building_t * B_BuildBuilding(base_t *base, const building_t *buildingTemplate, int col, int row)
Build a new building to the base.
A base with all it's data.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
class ItemCargo * itemCargo
void GEO_ResetAction(void)
No more special action on the geoscape.
Header file for menu related console command callbacks.
static void CL_SwapSkill(character_t *cp1, character_t *cp2, abilityskills_t skill)
Swaps one skill from character1 to character 2 and vice versa.
int CAP_GetFreeCapacity(const base_t *base, baseCapacities_t capacityType)
Returns the free capacity of a type.
int B_GetCount(void)
Returns the count of founded bases.
void RADAR_InitialiseUFOs(radar_t *radar)
Reset UFO sensored on radar.
#define SAVE_BASES_TARGET
const struct building_s * dependsBuilding
void CAP_AddMax(base_t *base, baseCapacities_t capacity, int value)
Changes the maximal capacity on a base.
#define SAVE_BASES_BUILDINGSTATUS
item instance data, with linked list capability
#define REMOVE_ELEM(array, index, n)
void B_ParseBaseTemplate(const char *name, const char **text)
Reads a base layout template.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
int RS_CountScientistsInBase(const base_t *base)
Returns the number of employees searching in labs in given base.
xmlNode_t *IMPORT * XML_GetDate(xmlNode_t *parent, const char *name, int *day, int *sec)
#define SAVE_BASES_TRACKINGRANGE
void AII_ReloadAircraftWeapons(aircraft_t *aircraft)
Reload the weapons of an aircraft.
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
Item * getHolsterContainer() const
bool B_MapIsCellFree(const base_t *base, int col, int row)
Check a base cell.
aircraft_t * aircraftCurrent
#define ngettext(x, y, cnt)
void B_DumpAircraftToHomeBase(aircraft_t *aircraft)
Will unload all cargo to the homebase.
static void B_UpdateAntimatterCap(base_t *base)
Update Antimatter Capacity.
void B_Delete(base_t *base)
Resets a base structure.
const equipDef_t *IMPORT * INV_GetEquipmentDefinitionByID(const char *name)
Item * getRightHandContainer() const
aircraft_t * AIR_GetFirstFromBase(const base_t *b)
Iterates through the aircraft of a base.
bool B_SaveStorageXML(xmlNode_t *parent, const equipDef_t &equip)
Saves base storage.
#define Vector2Set(v, x, y)
bool B_CheckBuildingDependencesStatus(const building_t *building)
Check that the dependences of a building is operationnal.
Campaign missions headers.
static linkedList_t * B_GetNeighbours(const building_t *building)
Returns the neighbourhood of a building.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
#define MAX_BLOCKEDFIELDS
void RS_MarkCollected(technology_t *tech)
Marks a give technology as collected.
#define SAVE_BASES_AUTOFIRE
#define SAVE_BASES_ALIENCONTAINMENT
const cgame_import_t * cgi
void UFO_NotifyPhalanxAircraftRemoved(const aircraft_t *const aircraft)
Notify to UFOs that a Phalanx aircraft has been destroyed.
bool B_LoadStorageXML(xmlNode_t *parent, equipDef_t *equip)
Loads base storage.
void B_AircraftReturnedToHomeBase(aircraft_t *aircraft)
Do anything when dropship returns to base.
#define SAVE_BASES_BUILDINGLEVEL
void B_SetUpFirstBase(const campaign_t *campaign, base_t *base)
Setup aircraft and equipment for first base. Uses the campaign scriptable equipmentlist.
int initialSkills[SKILL_NUM_TYPES+1]
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
const char *IMPORT * Com_GetConstVariable(const char *space, int value)
This is the technology parsed from research.ufo.
#define SAVE_BASES_ALIENINTEREST
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.
static void CL_SwapSkills(linkedList_t *team)
Swaps skills of the initial team of soldiers so that they match inventories.
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...
Campaign geoscape time header.
baseBuildingTile_t map[BASE_SIZE][BASE_SIZE]
void CAP_CheckOverflow(void)
Checks capacity overflows on bases.
Header for Geoscape management.
#define MAX_INSTALLATIONS_PER_BASE
bool BS_SellItem(const objDef_t *od, base_t *base, int count)
Sells items from the market.
void B_Destroy(base_t *base)
Destroy a base.
void B_SetCurrentSelectedBase(const base_t *base)
Sets the selected base.
static void B_SellOrAddItems(aircraft_t *aircraft)
Sell items to the market or add them to base storage.
#define SAVE_BUILDINGSTATUS_NAMESPACE
char cp_messageBuffer[MAX_MESSAGE_TEXT]
bool AIR_IsAircraftOnGeoscape(const aircraft_t *aircraft)
Checks whether given aircraft is on geoscape.
Alien containment class header.
int B_GetNumberOfBuildingsInBaseByBuildingType(const base_t *base, const buildingType_t buildingType)
Counts the number of buildings of a particular building 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.
int numBuildings[MAX_BASES]
#define AIR_ForeachFromBase(var, base)
iterates trough all aircraft from a specific homebase
#define CAP_GetMax(base, capacity)
baseCapacities_t
All possible capacities in base.
bool B_IsBuildingBuiltUp(const building_t *building)
Returns if a building is fully buildt up.
baseWeapon_t batteries[MAX_BASE_SLOT]
void AIR_DestroyAircraft(aircraft_t *aircraft, bool killPilot)
Removes an aircraft from its base and the game.
void CAP_UpdateStorageCap(base_t *base)
Update Storage Capacity.
void CP_SpawnRescueMission(aircraft_t *aircraft, aircraft_t *ufo)
Spawn a new rescue mission for a crashed (phalanx) aircraft.
#define MIN_BLOCKEDFIELDS
#define B_GetBuildingByIDX(baseIdx, buildingIdx)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
aircraft_t * UFO_GetByIDX(const int idx)
returns the UFO on the geoscape with a certain index
xmlNode_t *IMPORT * XML_GetPos2(xmlNode_t *parent, const char *name, vec2_t pos)
static bool B_UpdateStatusBuilding(base_t *base, buildingType_t buildingType, bool onBuilt)
Update status of every building when a building has been built/destroyed.
#define SAVE_BASES_RADARRANGE
bool isReloadable() const
static bool B_CheckUpdateBuilding(building_t *building)
Check base status for particular buildings as well as capacities.
Header file for aircraft stuff.
int B_AntimatterInBase(const base_t *base)
returns the amount of antimatter stored in a base
int B_LoadBaseSlotsXML(baseWeapon_t *weapons, int max, xmlNode_t *p)
Loads the missile and laser slots of a base or sam site.
int B_GetInstallationLimit(void)
Counts the actual installation count limit.
#define B_GetBuildingAt(base, x, y)
float frand(void)
Return random values between 0 and 1.
base_t * B_GetFirstUnfoundedBase(void)
Get the first unfounded base.
void AII_LoadOneSlotXML(xmlNode_t *node, aircraftSlot_t *slot, bool weapon)
Loads one slot (base, installation or aircraft)
void CAP_SetCurrent(base_t *base, baseCapacities_t capacity, int value)
Sets the current (used) capacity on a base.
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
static void B_BuildFromTemplate(base_t *base, const char *templateName, bool hire)
builds a base from template
int numItems[MAX_OBJDEFS]
Header for slot management related stuff.
void AIR_AssignInitial(aircraft_t *aircraft)
Assigns initial team of soldiers to aircraft.
int BS_GetItemSellingPrice(const objDef_t *od)
Get the price for an item that you want to sell on the market.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
bool B_BaseHasItem(const base_t *base, const objDef_t *item)
Check if an item is available on a base.
void RS_StopResearch(technology_t *tech)
Stops a research (Removes scientists from it)
#define BASE_INITIALINTEREST
bool B_PostLoadInit(void)
Set the capacity stuff for all the bases after loading a savegame.
#define SAVE_BASES_WEAPON
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
static bool B_PostLoadInitCapacity(void)
Set the capacity stuff for all the bases after loading a savegame.
#define SAVE_BASES_BUILDING
building_t * B_GetNextBuildingByType(const base_t *base, building_t *lastBuilding, buildingType_t buildingType)
Iterates throught buildings of a type in a base.
#define MapIsWater(color)
const objDef_t * ammoDef(void) const
#define LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
building_t buildingTemplates[MAX_BUILDINGS]
#define Vector2Copy(src, dest)
Header file for single player campaign control.
byte numItemsLoose[MAX_OBJDEFS]
void B_InitStartup(void)
Resets console commands.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
#define SAVE_BASES_BUILDINGTYPE
char soldierEquipment[MAX_VAR]
void E_DeleteAllEmployees(base_t *base)
Removes all employees completely from the game (buildings + global list) from a given base...
bool load(xmlNode_t *root)
Load alien cargo from xml savegame.
baseWeapon_t lasers[MAX_BASE_SLOT]
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
const char *IMPORT * Com_EParse(const char **text, const char *errhead, const char *errinfo)
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.
static bool B_AddBlockedTile(base_t *base, int row, int column)
Check and add blocked tile to the base.
#define B_GetBuildingIDX(base, building)
bool autosell[MAX_OBJDEFS]
void BDEF_InitialiseBaseSlots(base_t *base)
Initialise all values of base slot defence.
XML tag constants for savegame.
baseBuildingTile_t buildings[MAX_BASEBUILDINGS]
building_t buildings[MAX_BASES][MAX_BUILDINGS]
bool CP_CheckCredits(int costs)
Checks whether you have enough credits for something.
Store capacities in base.
buildingType_t buildingType
const char * AIR_CheckMoveIntoNewHomebase(const aircraft_t *aircraft, const base_t *base)
Checks if destination base can store an aircraft and its team.
#define SAVE_BASES_BUILDINGINDEX
char *IMPORT * PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
An aircraft with all it's data.
void CAP_SetMax(base_t *base, baseCapacities_t capacity, int value)
Sets the maximal capacity on a base.
static void CL_DoSwapSkills(character_t *cp1, character_t *cp2, const abilityskills_t skill)
bool B_BuildingDestroy(building_t *building)
Removes a building from the given base.
void AIR_MoveEmployeeInventoryIntoStorage(const aircraft_t &aircraft, equipDef_t &ed)
Move all the equipment carried by the team on the aircraft into the given equipment.
#define SAVE_BASES_STORAGE
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
void GEO_SetOverlay(const char *overlayID, int status)
Turn overlay on/off.
buildingStatus_t buildingStatus
linkedList_t * list(void) const
Returns a copy of the cargo list.
void B_SetBuildingStatus(base_t *const base, const buildingType_t buildingType, bool newStatus)
Set status associated to a building.
#define SAVE_BASES_ODS_ID
bool save(xmlNode_t *root) const
Save alien cargo to xml savegame.
#define ANTIMATTER_ITEM_ID
baseCapacities_t B_GetCapacityFromBuildingType(buildingType_t type)
Get the capacity associated to a building type.
#define B_IsTileBlocked(base, x, y)
bool hasBuilding[MAX_BUILDING_TYPE]
#define MAX_BASETEMPLATES
void B_SelectBase(const base_t *base)
Select and opens a base.
int skills[SKILL_NUM_TYPES]
#define SAVE_BASES_BUILDINGTIMESTART
static int CL_GetSkillIndicator(const character_t *chr, abilityskills_t skill)
Assembles a skill indicator for the given character and its wore weapons in correlation to the given ...
void AII_SaveOneSlotXML(xmlNode_t *p, const aircraftSlot_t *slot, bool weapon)
Save callback for savegames in XML Format.
#define SAVE_BASES_BUILDINGBUILDTIME
base_t * B_Build(const campaign_t *campaign, const vec2_t pos, const char *name, bool fillBase)
Build new base, uses template for the first base.
baseTemplate_t baseTemplates[MAX_BASETEMPLATES]
const char *IMPORT * Cmd_Argv(int n)
const baseTemplate_t * B_GetBaseTemplate(const char *baseTemplateID)
Returns the baseTemplate in the global baseTemplate list that has the unique name baseTemplateID...
#define SAVE_BASESTATUS_NAMESPACE
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
void AIRFIGHT_RemoveProjectileAimingAircraft(const aircraft_t *aircraft)
Set all projectile aiming a given aircraft to an idle destination.
bool B_FireEvent(const building_t *buildingTemplate, const base_t *base, buildingEvent_t eventType)
Run eventhandler script for a building.
#define SAVE_BASES_BLOCKED
void B_SetName(base_t *base, const char *name)
Set the base name.
buildingType_t B_GetBuildingTypeByCapacity(baseCapacities_t cap)
Get building type by base capacity.
#define SAVE_BASES_NUMLOOSE
building_t * B_GetNextBuilding(const base_t *base, building_t *lastBuilding)
Iterates through buildings in a base.
bool B_ItemIsStoredInBaseStorage(const objDef_t *obj)
Check if an item is stored in storage.
void AIR_DeleteAircraft(aircraft_t *aircraft)
Removes an aircraft from its base and the game.
Describes a character with all its attributes.
buildingStatus_t
All possible building status.