46#define B_GetBuildingByIDX(baseIdx, buildingIdx) (&ccs.buildings[(baseIdx)][(buildingIdx)])
47#define B_GetBuildingIDX(base, building) ((ptrdiff_t)((building) - ccs.buildings[base->idx]))
48#define B_GetBaseIDX(base) ((ptrdiff_t)((base) - ccs.bases))
63 const int x = building->
pos[0];
64 const int y = building->
pos[1];
69 for (
int i = x;
i < x + building->
size[0];
i++) {
77 for (
int i = y;
i < y + building->
size[1];
i++) {
93static bool B_IsCoherent (
const base_t* base)
101 cgi->LIST_AddPointer(&queue, (
void*)bldg);
107 while (!
cgi->LIST_IsEmpty(queue)) {
109 found[bldg->
idx] = 1;
110 cgi->LIST_RemoveEntry(&queue, queue);
114 if (found[bldg->
idx] == 0) {
115 found[bldg->
idx] = 1;
116 cgi->LIST_AddPointer(&queue, (
void*)bldg);
119 cgi->LIST_Delete(&neighbours);
121 cgi->LIST_Delete(&queue);
147 found[row][column] = -1;
151 for (
int y = 0; y <
BASE_SIZE &&
cgi->LIST_IsEmpty(queue); y++) {
152 for (
int x = 0; x <
BASE_SIZE &&
cgi->LIST_IsEmpty(queue); x++) {
153 if (x == column && y == row)
156 cgi->LIST_AddPointer(&queue, &base->
map[y][x]);
160 if (
cgi->LIST_IsEmpty(queue))
164 while (!
cgi->LIST_IsEmpty(queue)) {
166 cgi->LIST_RemoveEntry(&queue, queue);
167 const int x = tile->
posX;
168 const int y = tile->
posY;
173 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y][x - 1]);
176 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y][x + 1]);
179 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y - 1][x]);
182 cgi->LIST_AddPointer(&queue, (
void*)&base->
map[y + 1][x]);
184 cgi->LIST_Delete(&queue);
206 for (
int placed = 0; placed <
count; placed++) {
237 if (bldg != building) {
238 cgi->LIST_AddPointer(&queue, (
void*)bldg);
248 found[building->
idx] = 1;
250 while (!
cgi->LIST_IsEmpty(queue)) {
252 found[bldg->
idx] = 1;
253 cgi->LIST_RemoveEntry(&queue, queue);
257 if (found[bldg->
idx] == 0) {
258 found[bldg->
idx] = 1;
259 cgi->LIST_AddPointer(&queue, (
void*)bldg);
262 cgi->LIST_Delete(&neighbours);
264 cgi->LIST_Delete(&queue);
297 assert(lastBase < endOfBases);
302 if (base >= endOfBases)
350 assert(lastBuilding < endOfBuildings);
352 building = lastBuilding;
355 if (building >= endOfBuildings)
408 return cntlocal ? true :
false;
482 if (buildingType ==
B_MISC)
488 cgi->Com_Printf(
"B_GetBuildingStatus: Building-type %i does not exist.\n", buildingType);
501 if (buildingType ==
B_MISC) {
502 cgi->Com_Printf(
"B_SetBuildingStatus: No status is associated to B_MISC type of building.\n");
506 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_SetBuildingStatus: set status for %i to %i\n", buildingType, newStatus);
508 cgi->Com_Printf(
"B_SetBuildingStatus: Type of building %i does not exist\n", buildingType);
527 max = std::max(building->
level, max);
545static inline void B_AddMap (
char* maps,
size_t mapsLength,
char* coords,
size_t coordsLength,
const char* map,
int col,
int row)
548 Q_strcat(maps, mapsLength,
"%s", map);
566 cgi->Com_Printf(
"B_AssembleMap: No base to assemble\n");
573 for (
int row = 0; row <
BASE_SIZE; row++) {
574 for (
int col = 0; col <
BASE_SIZE; col++) {
577 B_AddMap(maps, mapsLength, coords, coordsLength,
"b/empty ", col, row);
580 if (building->
pos[0] != col || building->
pos[1] != row)
583 B_AddMap(maps, mapsLength, coords, coordsLength,
"b/construction ", col, row);
587 cgi->Com_Error(
ERR_DROP,
"MapPart for building '%s' is missing'", building->
id);
588 B_AddMap(maps, mapsLength, coords, coordsLength,
va(
"b/%s ", building->
mapPart), col, row);
618 cgi->Com_DPrintf(
DEBUG_CLIENT,
"Status of building %s is changed to %i.\n",
638 bool returnValue =
false;
645 if (dependsBuilding && buildingType == dependsBuilding->
buildingType) {
761 cgi->Com_Printf(
"B_ResetAllStatusAndCapacities: Warning, capacity of %i is bigger than maximum capacity\n",
i);
779 if (base->
map[(
int)building->
pos[1]][(
int)building->
pos[0]].
building != building) {
780 cgi->Com_Error(
ERR_DROP,
"B_BuildingDestroy: building mismatch at base %i pos %i,%i.",
781 base->
idx, (
int)building->
pos[0], (
int)building->
pos[1]);
797 int const baseIDX = base->
idx;
799 int const idx = building->
idx;
801 for (
int y = building->
pos[1]; y < building->pos[1] + building->
size[1]; y++)
802 for (
int x = building->
pos[0]; x < building->pos[0] + building->
size[0]; x++)
809 for (
int i = 0;
i < cntBldgs;
i++) {
815 for (
int y = bldg->
pos[1]; y < bldg->pos[1] + bldg->
size[1]; y++)
816 for (
int x = (
int)bldg->
pos[0]; x < bldg->pos[0] + bldg->
size[0]; x++)
841 if (runDisableCommand) {
850 cgi->Cmd_ExecuteString(
"base_init %d", base->
idx);
866 base_t* newbase =
nullptr;
868 while ((newbase =
B_GetNext(newbase)) !=
nullptr) {
923 for (
int buildingIdx =
ccs.
numBuildings[base->
idx] - 1; buildingIdx >= 0; buildingIdx--) {
949static void B_Destroy_f (
void)
951 if (
cgi->Cmd_Argc() < 2) {
957 if (baseIdx < 0 || baseIdx >=
MAX_BASES) {
958 cgi->Com_Printf(
"B_Destroy_f: baseIdx %i is outside bounds\n", baseIdx);
964 cgi->Com_Printf(
"B_Destroy_f: Base %i not founded\n", baseIdx);
1016 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(
"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);
1801static 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");
1817 cgi->Com_Printf(
"\n");
1822 cgi->Com_Printf(
"\n");
1832static 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);
1846 cgi->Com_Printf(
"Base radarRange %i\n", base->
radar.range);
1847 cgi->Com_Printf(
"Base trackingRange %i\n", base->
radar.trackingRange);
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");
1874static void B_PrintCapacities_f (
void)
1876 if (
cgi->Cmd_Argc() < 2) {
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",
1908static void B_BuildingConstructionFinished_f (
void)
1910 if (
cgi->Cmd_Argc() < 2) {
1937static void B_ResetAllStatusAndCapacities_f (
void)
1942 while ((base =
B_GetNext(base)) !=
nullptr) {
1951static void B_CheckCoherency_f (
void)
1953 if (
cgi->Cmd_Argc() < 2) {
1963 cgi->Com_Printf(
"Base '%s' (idx:%i) is %scoherent.\n", base->
name, base->
idx, (B_IsCoherent(base)) ?
"" :
"not ");
1973 cgi->Cmd_AddCommand(
"debug_listbase", B_BaseList_f,
"Print base information to the game console");
1974 cgi->Cmd_AddCommand(
"debug_listbuilding", B_BuildingList_f,
"Print building information to the game console");
1975 cgi->Cmd_AddCommand(
"debug_listcapacities", B_PrintCapacities_f,
"Debug function to show all capacities in given base");
1976 cgi->Cmd_AddCommand(
"debug_basereset", B_ResetAllStatusAndCapacities_f,
"Reset building status and capacities of all bases");
1977 cgi->Cmd_AddCommand(
"debug_destroybase", B_Destroy_f,
"Destroy a base");
1978 cgi->Cmd_AddCommand(
"debug_buildingfinished", B_BuildingConstructionFinished_f,
"Finish construction for every building in the current base");
1979 cgi->Cmd_AddCommand(
"debug_baseiscoherent", B_CheckCoherency_f,
"Checks if all buildings are connected on a base");
2012 while ((base =
B_GetNext(base)) !=
nullptr) {
2019 _(
"Construction of %s building finished in %s."),
_(building->
name), base->
name);
2049 if (item->amount > 0)
2057 numitems += item->amount;
2064 cgi->LIST_Delete(&items);
2068 va(
ngettext(
"%i collected item",
"%i collected items", numitems), numitems), gained);
2172 int buildingTemplateIDX = -1;
2184 buildingTemplateIDX =
i;
2194 if (buildingTemplateIDX != -1)
2195 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_UpdateBaseCapacities: updated capacity of %s: %i\n",
2210 cgi->Com_DPrintf(
DEBUG_CLIENT,
"B_UpdateBaseCapacities: going to update ALL capacities.\n");
2212 for (
int i = 0;
i < cap;
i++) {
2218 cgi->Com_Error(
ERR_DROP,
"Unknown capacity limit for this base: %i \n", cap);
2230 for (
int i = 0;
i < numWeapons;
i++) {
2234 if (weapons[
i].target)
2273 cgi->Com_Printf(
"B_SaveXML: Base (idx: %i) not founded!\n", b->
idx);
2277 cgi->Com_RegisterConstList(saveBaseConstants);
2288 for (
int row = 0; row <
BASE_SIZE; row++) {
2289 for (
int column = 0; column <
BASE_SIZE; column++) {
2334 cgi->Com_UnregisterConstList(saveBaseConstants);
2367 while ((base =
B_GetNext(base)) !=
nullptr)
2393 cgi->Com_Printf(
"B_Load: Could not find item '%s'\n", s);
2413 cgi->Com_Printf(
"Error: Node 'bases' wasn't found in savegame\n");
2419 cgi->Com_RegisterConstList(saveBaseConstants);
2430 cgi->Com_Printf(
"Invalid base index %i\n", b->
idx);
2431 cgi->Com_UnregisterConstList(saveBaseConstants);
2437 cgi->Com_Printf(
"Invalid base status '%s'\n", str);
2438 cgi->Com_UnregisterConstList(saveBaseConstants);
2458 if (buildingIdx != -1)
2465 cgi->Com_Printf(
"inconstent base layout found\n");
2466 cgi->Com_UnregisterConstList(saveBaseConstants);
2481 cgi->Com_Printf(
"building ID is greater than MAX buildings\n");
2482 cgi->Com_UnregisterConstList(saveBaseConstants);
2487 if (buildingType[0] ==
'\0') {
2488 cgi->Com_Printf(
"No buildingtype set\n");
2489 cgi->Com_UnregisterConstList(saveBaseConstants);
2494 if (!buildingTemplate)
2500 if (building->
idx != buildId) {
2501 cgi->Com_Printf(
"building ID doesn't match\n");
2502 cgi->Com_UnregisterConstList(saveBaseConstants);
2509 cgi->Com_Printf(
"Invalid building status '%s'\n", str);
2510 cgi->Com_UnregisterConstList(saveBaseConstants);
2550 cgi->Com_UnregisterConstList(saveBaseConstants);
2589 cap->
cur += (amount * obj->
size);
2591 }
else if (amount < 0) {
2594 amount = std::max(amount, -itemInBase);
2596 cap->
cur += (amount * obj->
size);
2650 }
else if (amount < 0) {
2653 amount = std::max(amount, -inBase);
2654 cap->
cur += (amount);
DateTime class definition.
Alien containment class header.
#define ABILITY_NUM_TYPES
Header file for inventory handling and Equipment menu.
Share stuff between the different cgame implementations.
bool load(xmlNode_t *root)
Load alien cargo from xml savegame.
bool save(xmlNode_t *root) const
Save alien cargo to xml savegame.
AlienContainment(capacities_t *aliveCapacity, capacities_t *deadCapacity)
Creates and initializes AlienContainment object.
DateTime(int day=0, int second=0)
Construct for DateTime class from date as days and time as seconds.
int getTimeAsSeconds() const
Return the time part of the DateTime as seconds.
int getDateAsDays() const
Return the date part of the DateTime as days.
Item * getRightHandContainer() const
Item * getHolsterContainer() const
void empty(void)
Empties the cargo.
linkedList_t * list(void) const
Returns a copy of the cargo list.
item instance data, with linked list capability
const objDef_t * ammoDef(void) const
const objDef_t * def(void) const
const fireDef_t * getFiredefs() const
Returns the firedefinitions for a given weapon/ammo.
bool isReloadable() const
#define REMOVE_ELEM(array, index, n)
void AIR_AssignInitial(aircraft_t *aircraft)
Assigns initial team of soldiers to aircraft.
void AIR_DeleteAircraft(aircraft_t *aircraft)
Removes an aircraft from its base and the game.
aircraft_t * AIR_NewAircraft(base_t *base, const aircraft_t *aircraftTemplate)
Places a new aircraft in the given base.
void AIR_MoveAircraftIntoNewHomebase(aircraft_t *aircraft, base_t *base)
Moves a given aircraft to a new base (also the employees and inventory).
bool AIR_IsAircraftOnGeoscape(const aircraft_t *aircraft)
Checks whether given aircraft is on geoscape.
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.
const char * AIR_CheckMoveIntoNewHomebase(const aircraft_t *aircraft, const base_t *base)
Checks if destination base can store an aircraft and its team.
const aircraft_t * AIR_GetAircraft(const char *name)
Searches the global array of aircraft types for a given aircraft.
void AIR_DestroyAircraft(aircraft_t *aircraft, bool killPilot)
Removes an aircraft from its base and the game.
baseCapacities_t AIR_GetHangarCapacityType(const aircraft_t *aircraft)
Returns capacity type needed for an aircraft.
aircraft_t * AIR_GetFirstFromBase(const base_t *b)
Iterates through the aircraft of a base.
Header file for aircraft stuff.
#define AIR_ForeachFromBase(var, base)
iterates trough all aircraft from a specific homebase
void AIRFIGHT_RemoveProjectileAimingAircraft(const aircraft_t *aircraft)
Set all projectile aiming a given aircraft to an idle destination.
void AL_AddAliens(aircraft_t *aircraft)
Puts alien cargo into Alien Containment.
void B_ParseBaseTemplate(const char *name, const char **text)
Reads a base layout template.
bool B_LoadXML(xmlNode_t *parent)
Loads base data.
static void CL_SwapSkills(linkedList_t *team)
Swaps skills of the initial team of soldiers so that they match inventories.
void B_DumpAircraftToHomeBase(aircraft_t *aircraft)
Will unload all cargo to the homebase.
void B_BaseResetStatus(base_t *const base)
Sets the baseStatus to BASE_NOT_USED.
bool B_BuildingDestroy(building_t *building)
Removes a building from the given base.
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.
building_t * B_BuildBuilding(base_t *base, const building_t *buildingTemplate, int col, int row)
Build a new building to the base.
bool B_PostLoadInit(void)
Set the capacity stuff for all the bases after loading a savegame.
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.
static void CL_DoSwapSkills(character_t *cp1, character_t *cp2, const abilityskills_t skill)
baseCapacities_t B_GetCapacityFromBuildingType(buildingType_t type)
Get the capacity associated to a building type.
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.
base_t * B_GetFoundedBaseByIDX(int baseIdx)
Array bound check for the base index.
bool B_SaveXML(xmlNode_t *parent)
Save callback for saving in xml format.
const baseTemplate_t * B_GetBaseTemplate(const char *baseTemplateID)
Returns the baseTemplate in the global baseTemplate list that has the unique name baseTemplateID.
static bool B_CheckUpdateBuilding(building_t *building)
Check base status for particular buildings as well as capacities.
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.
bool B_LoadStorageXML(xmlNode_t *parent, equipDef_t *equip)
Loads base storage.
static void B_BuildFromTemplate(base_t *base, const char *templateName, bool hire)
builds a base from template
void B_SelectBase(const base_t *base)
Select and opens a base.
static bool B_PostLoadInitCapacity(void)
Set the capacity stuff for all the bases after loading a savegame.
building_t * B_GetNextBuildingByType(const base_t *base, building_t *lastBuilding, buildingType_t buildingType)
Iterates throught buildings of a type in a base.
base_t * B_GetNext(base_t *lastBase)
Iterates through founded bases.
void B_SetCurrentSelectedBase(const base_t *base)
Sets the selected base.
static void B_MoveAircraftOnGeoscapeToOtherBases(const base_t *base)
Will ensure that aircraft on geoscape are not stored in a base that no longer has any hangar left.
static bool B_CheckBuildingConstruction(building_t *building)
Checks whether the construction of a building is finished. Calls the onEnable functions and assign wo...
#define B_GetBuildingByIDX(baseIdx, buildingIdx)
void B_AircraftReturnedToHomeBase(aircraft_t *aircraft)
Do anything when dropship returns to base.
void B_ResetAllStatusAndCapacities(base_t *base, bool firstEnable)
Recalculate status and capacities of one base.
static void B_UpdateAllBaseBuildingStatus(building_t *building, buildingStatus_t status)
Updates base status for particular buildings as well as capacities.
static void CL_SwapSkill(character_t *cp1, character_t *cp2, abilityskills_t skill)
Swaps one skill from character1 to character 2 and vice versa.
bool B_BaseHasItem(const base_t *base, const objDef_t *item)
Check if an item is available on a base.
int B_GetCount(void)
Returns the count of founded bases.
static bool B_UpdateStatusBuilding(base_t *base, buildingType_t buildingType, bool onBuilt)
Update status of every building when a building has been built/destroyed.
bool B_ItemIsStoredInBaseStorage(const objDef_t *obj)
Check if an item is stored in storage.
int B_GetInstallationLimit(void)
Counts the actual installation count limit.
int B_AddAntimatter(base_t *base, int amount)
Manages antimatter (adding, removing) through Antimatter Storage Facility.
base_t * B_GetCurrentSelectedBase(void)
returns the currently selected base
static void B_InitialEquipment(aircraft_t *aircraft, const equipDef_t *ed)
Prepares initial equipment for initial team the beginning of the campaign.
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...
bool B_IsBuildingDestroyable(const building_t *building)
Returns if a base building is destroyable.
void B_SetName(base_t *base, const char *name)
Set the base name.
void B_Destroy(base_t *base)
Destroy a base.
void B_UpdateBaseCapacities(baseCapacities_t cap, base_t *base)
Updates base capacities.
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.
void B_Delete(base_t *base)
Resets a base structure.
int B_AntimatterInBase(const base_t *base)
returns the amount of antimatter stored in a base
buildingType_t B_GetBuildingTypeByCapacity(baseCapacities_t cap)
Get building type by base capacity.
int B_GetNumberOfBuildingsInBaseByTemplate(const base_t *base, const building_t *tpl)
Counts the number of buildings of a particular type in a base.
int B_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_UpdateBuildingConstructions(void)
Updates base data.
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 ...
bool B_SaveStorageXML(xmlNode_t *parent, const equipDef_t &equip)
Saves base storage.
static linkedList_t * B_GetNeighbours(const building_t *building)
Returns the neighbourhood of a building.
base_t * B_GetFirstUnfoundedBase(void)
Get the first unfounded base.
static bool B_AddBlockedTile(base_t *base, int row, int column)
Check and add blocked tile to the base.
float B_GetMaxBuildingLevel(const base_t *base, const buildingType_t type)
Get the maximum level of a building type in a base.
int B_GetNumberOfBuildingsInBaseByBuildingType(const base_t *base, const buildingType_t buildingType)
Counts the number of buildings of a particular building type in a base.
void B_InitStartup(void)
Resets console commands.
int B_LoadBaseSlotsXML(baseWeapon_t *weapons, int max, xmlNode_t *p)
Loads the missile and laser slots of a base or sam site.
building_t * B_GetNextBuilding(const base_t *base, building_t *lastBuilding)
Iterates through buildings in a base.
bool B_MapIsCellFree(const base_t *base, int col, int row)
Check a base cell.
void B_SetBuildingStatus(base_t *const base, const buildingType_t buildingType, bool newStatus)
Set status associated to a building.
static void B_UpdateAntimatterCap(base_t *base)
Update Antimatter Capacity.
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
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.
static void B_SellOrAddItems(aircraft_t *aircraft)
Sell items to the market or add them to base storage.
#define B_GetBuildingIDX(base, building)
static void B_AddBlockedTiles(base_t *base, int count)
Fuction to put blocked tiles on basemap.
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.
void B_SetUpFirstBase(const campaign_t *campaign, base_t *base)
Setup aircraft and equipment for first base. Uses the campaign scriptable equipmentlist.
#define B_IsTileBlocked(base, x, y)
#define B_GetBuildingAt(base, x, y)
#define MIN_BLOCKEDFIELDS
#define MAX_BASETEMPLATES
#define MAX_BASEBUILDINGS
#define BASE_INITIALINTEREST
#define MAX_BLOCKEDFIELDS
Header file for menu related console command callbacks.
bool B_FireEvent(const building_t *buildingTemplate, const base_t *base, buildingEvent_t eventType)
Run eventhandler script for a building.
bool B_CheckBuildingDependencesStatus(const building_t *building)
Check that the dependences of a building is operationnal.
bool B_IsBuildingBuiltUp(const building_t *building)
Returns if a building is fully buildt up.
building_t * B_GetBuildingTemplate(const char *buildingName)
Returns the building in the global building-types list that has the unique name buildingID.
buildingType_t
All different building types.
buildingStatus_t
All possible building status.
@ B_STATUS_CONSTRUCTION_FINISHED
@ B_STATUS_UNDER_CONSTRUCTION
memPool_t * cp_campaignPool
bool CP_CheckCredits(int costs)
Checks whether you have enough credits for something.
void CP_UpdateCredits(int credits)
Sets credits and update mn_credits cvar.
Header file for single player campaign control.
const cgame_import_t * cgi
void CAP_AddMax(base_t *base, baseCapacities_t capacity, int value)
Changes the maximal capacity on a base.
void CAP_UpdateStorageCap(base_t *base)
Update Storage Capacity.
void CAP_CheckOverflow(void)
Checks capacity overflows on bases.
int CAP_GetFreeCapacity(const base_t *base, baseCapacities_t capacityType)
Returns the free capacity of a type.
void CAP_SetMax(base_t *base, baseCapacities_t capacity, int value)
Sets the maximal capacity on a base.
void CAP_SetCurrent(base_t *base, baseCapacities_t capacity, int value)
Sets the current (used) capacity on a base.
#define CAP_GetCurrent(base, capacity)
baseCapacities_t
All possible capacities in base.
#define CAP_GetMax(base, capacity)
#define CAP_Get(base, capacity)
Capacity macros.
bool E_HireEmployeeByType(base_t *base, employeeType_t type)
Hires the first free employee of that type.
int E_CountAllHired(const base_t *const base, const bool peopleOnly)
Counts all hired employees of a given base.
void E_DeleteAllEmployees(base_t *base)
Removes all employees completely from the game (buildings + global list) from a given base.
void E_HireForBuilding(base_t *base, building_t *building, int num)
Hires some employees of appropriate type for a building.
void GEO_SetOverlay(const char *overlayID, int status)
Turn overlay on/off.
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...
bool GEO_IsRadarOverlayActivated(void)
void GEO_ResetAction(void)
No more special action on the geoscape.
Header for Geoscape management.
#define MapIsWater(color)
void INS_SetCurrentSelectedInstallation(const installation_t *installation)
Sets the currently selected installation.
#define MAX_INSTALLATIONS_PER_BASE
void AIM_AutoEquipAircraft(aircraft_t *aircraft)
Auto Add weapon and ammo to an aircraft.
void AII_LoadOneSlotXML(xmlNode_t *node, aircraftSlot_t *slot, bool weapon)
Loads one slot (base, installation or aircraft).
void AII_ReloadAircraftWeapons(aircraft_t *aircraft)
Reload the weapons of an aircraft.
void BDEF_InitialiseBaseSlots(base_t *base)
Initialise all values of base slot defence.
void AII_SaveOneSlotXML(xmlNode_t *p, const aircraftSlot_t *slot, bool weapon)
Save callback for savegames in XML Format.
Header for slot management related stuff.
int BS_GetItemSellingPrice(const objDef_t *od)
Get the price for an item that you want to sell on the market.
bool BS_SellItem(const objDef_t *od, base_t *base, int count)
Sells items from the market.
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...
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.
char cp_messageBuffer[MAX_MESSAGE_TEXT]
void CP_MissionNotifyBaseDestroyed(const base_t *base)
Notify that a base has been removed.
void CP_SpawnRescueMission(aircraft_t *aircraft, aircraft_t *ufo)
Spawn a new rescue mission for a crashed (phalanx) aircraft.
Campaign missions headers.
void PR_UpdateProductionCap(base_t *base, int workerChange)
Update the current capacity of Workshop.
void RADAR_Initialise(radar_t *radar, float range, float trackingRange, float level, bool updateSourceRadarMap)
Set radar range to new value.
const float RADAR_BASETRACKINGRANGE
const float RADAR_BASERANGE
void RADAR_InitialiseUFOs(radar_t *radar)
Reset UFO sensored on radar.
void RS_MarkCollected(technology_t *tech)
Marks a give technology as collected.
int RS_CountScientistsInBase(const base_t *base)
Returns the number of employees searching in labs in given base.
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
void RS_StopResearch(technology_t *tech)
Stops a research (Removes scientists from it).
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 ...
#define ANTIMATTER_ITEM_ID
#define FOREACH_XMLNODE(var, node, name)
Campaign geoscape time header.
void UFO_NotifyPhalanxAircraftRemoved(const aircraft_t *const aircraft)
Notify to UFOs that a Phalanx aircraft has been destroyed.
aircraft_t * UFO_GetByIDX(const int idx)
returns the UFO on the geoscape with a certain index
#define ngettext(x, y, cnt)
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const objDef_t * INVSH_GetItemByID(const char *id)
Returns the item that belongs to the given id or nullptr if it wasn't found.
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 LIST_Foreach(list, type, var)
Iterates over a linked list, it's safe to delete the returned entry from the list while looping over ...
float frand(void)
Return random values between 0 and 1.
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Shared parsing functions.
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
XML tag constants for savegame.
#define SAVE_BASES_AUTOFIRE
#define SAVE_BASES_BUILDINGTYPE
#define SAVE_BASES_TARGET
#define SAVE_BASES_RADARRANGE
#define SAVE_BASES_STORAGE
#define SAVE_BASES_ALIENCONTAINMENT
#define SAVE_BASES_ODS_ID
#define SAVE_BASES_BATTERIES
#define SAVE_BASES_BUILDING_PLACE
#define SAVE_BASES_TRACKINGRANGE
#define SAVE_BASES_BUILDINGLEVEL
#define SAVE_BASES_BUILDINGS
#define SAVE_BASES_BUILDINGBUILDTIME
#define SAVE_BASES_NUMLOOSE
#define SAVE_BASESTATUS_NAMESPACE
#define SAVE_BASES_BUILDINGSTATUS
#define SAVE_BASES_BUILDINGSPACE
#define SAVE_BASES_BUILDING
#define SAVE_BUILDINGSTATUS_NAMESPACE
#define SAVE_BASES_LASERS
#define SAVE_BASES_BUILDINGTIMESTART
#define SAVE_BASES_BASESTATUS
#define SAVE_BASES_BLOCKED
#define SAVE_BASES_ALIENINTEREST
#define SAVE_BASES_WEAPON
#define SAVE_BASES_BUILDINGINDEX
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
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...
An aircraft with all it's data.
class ItemCargo * itemCargo
A base with all it's data.
aircraft_t * aircraftCurrent
class AlienContainment * alienContainment
baseWeapon_t batteries[MAX_BASE_SLOT]
baseWeapon_t lasers[MAX_BASE_SLOT]
baseBuildingTile_t map[BASE_SIZE][BASE_SIZE]
bool hasBuilding[MAX_BUILDING_TYPE]
template for creating a base
baseBuildingTile_t buildings[MAX_BASEBUILDINGS]
A building with all it's data.
const struct building_s * dependsBuilding
buildingType_t buildingType
buildingStatus_t buildingStatus
char firstBaseTemplate[MAX_VAR]
char soldierEquipment[MAX_VAR]
linkedList_t * initialCraft
Store capacities in base.
baseTemplate_t baseTemplates[MAX_BASETEMPLATES]
building_t buildings[MAX_BASES][MAX_BUILDINGS]
int numBuildings[MAX_BASES]
building_t buildingTemplates[MAX_BUILDINGS]
xmlNode_t *IMPORT * XML_GetNode(xmlNode_t *parent, const char *name)
const char *IMPORT * Cmd_Argv(int n)
xmlNode_t *IMPORT * XML_GetPos3(xmlNode_t *parent, const char *name, vec3_t pos)
xmlNode_t *IMPORT * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
xmlNode_t *IMPORT * XML_AddNode(xmlNode_t *parent, const char *name)
cvar_t *IMPORT * Cvar_Set(const char *varName, const char *value,...) __attribute__((format(__printf__
const char *IMPORT * Com_EParse(const char **text, const char *errhead, const char *errinfo)
const equipDef_t *IMPORT * INV_GetEquipmentDefinitionByID(const char *name)
xmlNode_t *IMPORT * XML_GetDate(xmlNode_t *parent, const char *name, int *day, int *sec)
char *IMPORT * PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
const char *IMPORT * XML_GetString(xmlNode_t *parent, const char *name)
const char *IMPORT * Com_GetConstVariable(const char *space, int value)
xmlNode_t *IMPORT * XML_GetPos2(xmlNode_t *parent, const char *name, vec2_t pos)
Describes a character with all its attributes.
int initialSkills[SKILL_NUM_TYPES+1]
int skills[SKILL_NUM_TYPES]
int experience[SKILL_NUM_TYPES+1]
int numItems[MAX_OBJDEFS]
byte numItemsLoose[MAX_OBJDEFS]
this is a fire definition for our weapons/ammo
weaponFireDefIndex_t weapFdsIdx
bool autosell[MAX_OBJDEFS]
Defines all attributes of objects used in the inventory.
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
This is the technology parsed from research.ufo.
researchStatus_t statusResearch
#define Vector2Set(v, x, y)
#define Vector2Copy(src, dest)
xmlNode_t * XML_GetNextNode(xmlNode_t *current, xmlNode_t *parent, const char *name)
Get next Node of the XML tree by name.