26 #include "../../cl_shared.h"
27 #include "../../../shared/parse.h"
139 const char* errhead =
"B_ParseBuildings: unexpected end of file (names ";
144 if (!*text || *token !=
'{') {
145 cgi->Com_Printf(
"B_ParseBuildings: building \"%s\" without body ignored\n", name);
150 cgi->Com_Error(
ERR_DROP,
"B_ParseBuildings: too many buildings");
155 cgi->Com_Printf(
"B_ParseBuildings: Second building with same name found (%s) - second ignored\n", name);
168 building->
tpl = building;
170 building->
base =
nullptr;
174 building->
size[0] = 1;
175 building->
size[1] = 1;
194 cgi->Com_Printf(
"didn't find buildingType '%s'\n", token);
197 if (
Q_streq(token,
"depends")) {
202 if (!
cgi->Com_ParseBlockToken(name, text, building, valid_building_vars,
cp_campaignPool, token))
203 cgi->Com_Printf(
"B_ParseBuildings: unknown token \"%s\" ignored (building %s)\n", token, name);
208 cgi->Com_Printf(
"B_ParseBuildings: Invalid size for building %s (%i, %i)\n", building->
id, (
int)building->
size[0], (
int)building->
size[1]);
214 cgi->Com_Error(
ERR_DROP,
"B_ParseBuildings: Could not find building with id %s\n", name);
218 building->
tech = techLink;
228 if (
Q_streq(token,
"depends")) {
230 if (!dependsBuilding)
231 cgi->Com_Error(
ERR_DROP,
"Could not find building depend of %s\n", building->
id);
252 cgi->Com_Printf(
"...... no name for building '%s' given\n", b->
id);
256 cgi->Com_Printf(
"...... no image for building '%s' given\n", b->
id);
260 cgi->Com_Printf(
"...... no pedia link for building '%s' given\n", b->
id);
263 cgi->Com_Printf(
"...... could not get pedia entry tech (%s) for building '%s'\n", b->
pedia, b->
id);
282 if (
Q_streq(buildingTemplate->
id, buildingName))
283 return buildingTemplate;
296 if (!buildingName || buildingName[0] ==
'\0') {
297 cgi->Com_Printf(
"No, or empty building ID\n");
302 if (!buildingTemplate)
303 cgi->Com_Printf(
"Building %s not found\n", buildingName);
304 return buildingTemplate;
316 return buildingTemplate;
348 const char* command =
nullptr;
350 assert(buildingTemplate);
358 command = buildingTemplate->
onEnable;
367 cgi->Com_Error(
ERR_DROP,
"B_FireEvent: Invalid Event\n");
371 cgi->Cmd_ExecuteString(
"%s %i %i", command, base->
idx, buildingTemplate->
buildingType);
bool Date_IsDue(const date_t *date)
Checks whether a given date is equal or earlier than the current campaign date.
float B_GetConstructionTimeRemain(const building_t *building)
Returns the time remaining time of a building construction.
A building with all it's data.
QGL_EXTERN GLint GLenum type
bool B_GetBuildingStatus(const base_t *const base, const buildingType_t buildingType)
Get the status associated to a building.
const building_t * B_GetBuildingTemplateByType(buildingType_t type)
Returns the building template in the global building-types list for a buildingType.
struct technology_s * tech
void B_ParseBuildings(const char *name, const char **text, bool link)
Copies an entry from the building description file into the list of building types.
buildingType_t
All different building types.
building_t * B_GetBuildingTemplate(const char *buildingName)
Returns the building in the global building-types list that has the unique name buildingID.
memPool_t * cp_campaignPool
A base with all it's data.
#define Q_strvalid(string)
const struct building_s * dependsBuilding
static const value_t valid_building_vars[]
Holds the names of valid entries in the basemanagement.ufo file.
bool B_CheckBuildingDependencesStatus(const building_t *building)
Check that the dependences of a building is operationnal.
const cgame_import_t * cgi
This is the technology parsed from research.ufo.
Engine-side time information in the game.
date_t Date_Substract(date_t a, const date_t &b)
Substract the second date from the first and return the result.
Campaign geoscape time header.
Header for base building related stuff.
building_t * B_GetBuildingTemplateSilent(const char *buildingName)
Returns the building in the global building-types list that has the unique name buildingID.
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
bool B_IsBuildingBuiltUp(const building_t *building)
Returns if a building is fully buildt up.
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
bool B_BuildingScriptSanityCheck(void)
Checks the parsed buildings for errors.
static const struct buildingTypeMapping_s buildingTypeMapping[]
buildingEvent_t
Building events.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
#define MEMBER_SIZEOF(TYPE, MEMBER)
building_t buildingTemplates[MAX_BUILDINGS]
Header file for single player campaign control.
const char *IMPORT * Com_EParse(const char **text, const char *errhead, const char *errinfo)
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
buildingType_t buildingType
char *IMPORT * PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
buildingType_t B_GetBuildingTypeByBuildingID(const char *buildingID)
Returns the building type for a given building identified by its building id from the ufo script file...
QGL_EXTERN int GLboolean GLfloat * v
bool B_FireEvent(const building_t *buildingTemplate, const base_t *base, buildingEvent_t eventType)
Run eventhandler script for a building.