25 #include "../../cl_shared.h"
26 #include "../../../shared/parse.h"
30 #include "../../cl_inventory.h"
41 else if (
Q_streq(type,
"terror"))
43 else if (
Q_streq(type,
"baseattack"))
45 else if (
Q_streq(type,
"building"))
47 else if (
Q_streq(type,
"supply"))
51 else if (
Q_streq(type,
"intercept"))
53 else if (
Q_streq(type,
"harvest"))
55 else if (
Q_streq(type,
"alienbase"))
57 else if (
Q_streq(type,
"ufocarrier"))
59 else if (
Q_streq(type,
"rescue"))
62 cgi->Com_Printf(
"CP_GetAlienMissionTypeByID: unknown alien mission category '%s'\n", type);
80 const char* errhead =
"CP_ParseAlienTeam: unexpected end of file (alienteam ";
88 if (!*text || *token !=
'{') {
89 cgi->Com_Printf(
"CP_ParseAlienTeam: alien team category \"%s\" without body ignored\n", name);
94 cgi->Com_Printf(
"CP_ParseAlienTeam: maximum number of alien team category reached (%i)\n",
ALIENCATEGORY_MAX);
103 cgi->Com_Printf(
"CP_ParseAlienTeam: alien category def \"%s\" with same name found, second ignored\n", name);
117 if (
Q_streq(token,
"equipment")) {
119 if (!
cgi->Com_ParseList(text, list)) {
120 cgi->Com_Error(
ERR_DROP,
"CL_ParseAlienTeam: \"%s\" Error while parsing equipment list", name);
122 }
else if (
Q_streq(token,
"category")) {
124 if (!
cgi->Com_ParseList(text, &list)) {
125 cgi->Com_Error(
ERR_DROP,
"CL_ParseAlienTeam: \"%s\" Error while parsing category list", name);
127 for (
linkedList_t* element = list; element !=
nullptr; element = element->
next) {
130 cgi->Com_Printf(
"CP_ParseAlienTeam: alien team category \"%s\" is used with no mission category. It won't be used in game.\n", name);
133 cgi->LIST_Delete(&list);
134 }
else if (
Q_streq(token,
"teaminterest")) {
138 if (!*text || *token !=
'{') {
139 cgi->Com_Printf(
"CP_ParseAlienTeam: alien team \"%s\" has team with no opening brace\n", name);
156 if (!
cgi->Com_ParseBlockToken(name, text, group, alien_group_vals,
cp_campaignPool, token)) {
157 if (!*text || *token ==
'}')
162 if (!
cgi->Com_ParseList(text, &list)) {
163 cgi->Com_Error(
ERR_DROP,
"CL_ParseAlienTeam: \"%s\" Error while parsing team list", name);
165 for (
linkedList_t* element = list; element !=
nullptr; element = element->
next) {
167 cgi->Com_Error(
ERR_DROP,
"CL_ParseAlienTeam: MAX_TEAMS_PER_MISSION hit");
176 cgi->LIST_Delete(&list);
178 cgi->Com_Error(
ERR_DROP,
"CL_ParseAlienTeam: Unknown token \"%s\"\n", token);
184 cgi->Com_Printf(
"CP_ParseAlienTeam: Minimum number of aliens is greater than maximum value! Swapped.\n");
190 cgi->Com_Printf(
"CP_ParseAlienTeam: unknown token \"%s\" ignored (category %s)\n", token, name);
196 Sys_Error(
"alien category equipment list is empty");
204 const char* errhead =
"CP_ParseResearchedCampaignItems: unexpected end of file (equipment ";
215 if (!*text || *token !=
'{') {
216 cgi->Com_Printf(
"CP_ParseResearchedCampaignItems: equipment def \"%s\" without body ignored (%s)\n",
221 cgi->Com_DPrintf(
DEBUG_CLIENT,
"..campaign research list '%s'\n", name);
224 if (!*text || *token ==
'}')
241 cgi->Com_Printf(
"CP_ParseResearchedCampaignItems: unknown token \"%s\" ignored (tech %s)\n", token, name);
256 const char* errhead =
"CP_ParseResearchableCampaignStates: unexpected end of file (equipment ";
263 if (!*text || *token !=
'{') {
264 cgi->Com_Printf(
"CP_ParseResearchableCampaignStates: equipment def \"%s\" without body ignored\n", name);
269 cgi->Com_DPrintf(
DEBUG_CLIENT,
"..don't use '%s' as researchable list\n", name);
273 cgi->Com_DPrintf(
DEBUG_CLIENT,
"..campaign researchable list '%s'\n", name);
276 if (!*text || *token ==
'}')
294 cgi->Com_Printf(
"CP_ParseResearchableCampaignStates: unknown token \"%s\" ignored (tech %s)\n", token, name);
380 const char* errhead =
"CP_ParseCampaign: unexpected end of file (campaign ";
389 cgi->Com_Printf(
"CP_ParseCampaign: campaign def \"%s\" with same name found, second ignored\n", name);
394 cgi->Com_Printf(
"CP_ParseCampaign: Max campaigns reached (%i)\n",
MAX_CAMPAIGNS);
420 if (!*text || *token !=
'{') {
421 cgi->Com_Printf(
"CP_ParseCampaign: campaign def \"%s\" without body ignored\n", name);
445 if (
cgi->Com_ParseBlockToken(name, text, cp, campaign_vals,
nullptr, token)) {
447 }
else if (
Q_streq(token,
"salary")) {
449 }
else if (
Q_streq(token,
"events")) {
454 }
else if (
Q_streq(token,
"aircraft")) {
457 cgi->Com_Printf(
"CP_ParseCampaign: unknown token \"%s\" ignored (campaign %s)\n", token, name);
476 cgi->Com_Printf(
"CP_ParseCampaign: check salary definition. Campaign def \"%s\" ignored\n", name);
493 if (
Q_streq(type,
"up_chapter"))
495 else if (
Q_streq(type,
"building"))
497 else if (
Q_streq(type,
"installation"))
499 else if (
Q_streq(type,
"tech"))
501 else if (
Q_streq(type,
"nation"))
503 else if (
Q_streq(type,
"city"))
505 else if (
Q_streq(type,
"rank"))
507 else if (
Q_streq(type,
"aircraft"))
509 else if (
Q_streq(type,
"mail"))
511 else if (
Q_streq(type,
"events"))
513 else if (
Q_streq(type,
"event"))
515 else if (
Q_streq(type,
"components"))
517 else if (
Q_streq(type,
"alienteam"))
519 else if (
Q_streq(type,
"msgoptions"))
539 else if (
Q_streq(type,
"aircraft"))
541 else if (
Q_streq(type,
"basetemplate"))
543 else if (
Q_streq(type,
"campaign"))
552 if (
Q_streq(type,
"researched"))
554 else if (
Q_streq(type,
"researchable"))
556 else if (
Q_streq(type,
"notresearchable"))
573 cgi->Com_Printf(
"CP_ItemsSanityCheck: Item %s has zero size set.\n", item->
id);
579 cgi->Com_Printf(
"CP_ItemsSanityCheck: Item %s has zero price set.\n", item->
id);
584 cgi->Com_Printf(
"CP_ItemsSanityCheck: Item %s has a price set though it is neither available on the market and production.\n", item->
id);
616 cgi->Com_Printf(
"Sanity check for script data\n");
619 bool status = s->
check();
620 cgi->Com_Printf(
"...%s %s\n", s->
name, (status ?
"ok" :
"failed"));
637 cgi->FS_BuildFileList(
"ufos/*.ufo");
663 cgi->Com_Error(
ERR_DROP,
"Could not find a tech for teamdef %s", teamDef->
id);
672 cgi->Com_Printf(
"Campaign data loaded - size " UFO_SIZE_T " bytes\n",
sizeof(
ccs));
678 cgi->Com_Printf(
"\n");
static void CP_ParseResearchedCampaignItems(const campaign_t *campaign, const char *name, const char **text)
This function parses a list of items that should be set to researched = true after campaign start...
alienTeamCategory_t alienCategories[ALIENCATEGORY_MAX]
void INS_LinkTechnologies(void)
const equipDef_t * marketDef
const equipDef_t * asymptoticMarketDef
static void CP_ParseScriptCampaignRelated(const campaign_t *campaign, const char *type, const char *name, const char **text)
Parses the campaign specific data - this data can only be parsed once the campaign started...
void Sys_Error(const char *error,...)
void UP_ParseChapter(const char *name, const char **text)
Parse the UFOpaedia chapters from scripts.
technology_t * RS_GetTechByIDX(int techIdx)
Returns the technology pointer for a tech index. You can use this instead of "&ccs.technologies[techIdx]" to avoid having to check valid indices.
Header file for Aircraft and item components.
static void CP_ParseResearchableCampaignStates(const campaign_t *campaign, const char *name, const char **text, bool researchable)
This function parses a list of items that should be set to researchable = true after campaign start...
static const value_t alien_group_vals[]
alien team category definition
QGL_EXTERN GLint GLenum type
static void CP_ParseScriptSecond(const char *type, const char *name, const char **text)
Parsing only for singleplayer.
static void CP_ParseAlienTeam(const char *name, const char **text)
void RS_MarkOneResearchable(technology_t *tech)
Marks one tech as researchable.
static void CP_ParseCampaign(const char *name, const char **text)
char *IMPORT * FS_NextScriptHeader(const char *files, const char **name, const char **text)
const teamDef_t * alienTeams[MAX_TEAMS_PER_MISSION]
bool BS_IsOnMarket(const objDef_t *item)
Check if an item is on market.
static const value_t campaign_vals[]
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.
bool CHRSH_IsTeamDefAlien(const teamDef_t *const td)
Check if a team definition is alien.
bool markOnly[MAX_CAMPAIGNS]
Defines all attributes of objects used in the inventory.
alienTeamGroup_t alienTeamGroups[MAX_ALIEN_GROUP_PER_CATEGORY]
linkedList_t * initialCraft
memPool_t * cp_campaignPool
technology_t * teamDefTechs[MAX_TEAMDEFS]
void CL_ParseCampaignEvents(const char *name, const char **text)
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.
void RS_ParseTechnologies(const char *name, const char **text)
Parses one "tech" entry in the research.ufo file and writes it into the next free entry in technologi...
const chrTemplate_t * alienChrTemplates[MAX_TEAMS_PER_MISSION]
bool AIR_ScriptSanityCheck(void)
Checks the parsed aircraft for errors.
char * campaign[MAX_CAMPAIGNS]
const equipDef_t *IMPORT * INV_GetEquipmentDefinitionByID(const char *name)
void CP_ParseEventTrigger(const char *name, const char **text)
void INS_ParseInstallations(const char *name, const char **text)
Copies an entry from the installation description file into the list of installation templates...
void CP_ScriptSanityCheck(void)
Check the parsed script values for errors after parsing every script file.
bool RS_ScriptSanityCheck(void)
Checks the parsed tech data for errors.
markResearched_t markResearched
void AIR_ParseAircraft(const char *name, const char **text, bool assignAircraftItems)
Parses all aircraft that are defined in our UFO-scripts.
const cgame_import_t * cgi
char asymptoticMarket[MAX_VAR]
static bool CP_ItemsSanityCheck(void)
Make sure values of items after parsing are proper.
struct that holds the sanity check data
const chrTemplate_t * CHRSH_GetTemplateByID(const teamDef_t *teamDef, const char *templateId)
static const sanity_functions_t sanity_functions[]
Data for sanity check of parsed script data.
This is the technology parsed from research.ufo.
campaign_t * CP_GetCampaign(const char *name)
Returns the campaign pointer from global campaign array.
const campaignEvents_t * CP_GetEventsByID(const char *name)
teamDef_t teamDef[MAX_TEAMDEFS]
alien team group definition.
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
const GLuint *typedef void(APIENTRY *GenRenderbuffersEXT_t)(GLsizei
static void CP_ParseSalary(const char *name, const char **text, salary_t *s)
Parse the salaries from campaign definition.
static interestCategory_t CP_GetAlienMissionTypeByID(const char *type)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
enum interestCategory_s interestCategory_t
bool B_BuildingScriptSanityCheck(void)
Checks the parsed buildings for errors.
void MSO_ParseMessageSettings(const char *name, const char **text)
parses message options settings from file.
void RS_RequiredLinksAssign(void)
Assign Link pointers to all required techs/items/etc...
#define INITIAL_OVERALL_INTEREST
Determines the interest interval for a single campaign.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
#define MAX_TEAMS_PER_MISSION
#define MEMBER_SIZEOF(TYPE, MEMBER)
Header file for single player campaign control.
void CP_ParseCampaignData(void)
Read the data for campaigns.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
const teamDef_t *IMPORT * Com_GetTeamDefinitionByID(const char *team)
const char *IMPORT * Com_EParse(const char **text, const char *errhead, const char *errinfo)
static void CP_ParseScriptFirst(const char *type, const char *name, const char **text)
Parsing campaign data.
bool PR_ItemIsProduceable(const objDef_t *item)
check if an item is producable.
void CL_ParseRanks(const char *name, const char **text)
Parse medals and ranks defined in the medals.ufo file.
void COMP_ParseComponents(const char *name, const char **text)
Parses one "components" entry in a .ufo file and writes it into the next free entry in xxxxxxxx (comp...
char *IMPORT * PoolStrDup(const char *in, memPool_t *pool, const int tagNum)
const campaignEvents_t * events
#define ALIENCATEGORY_MAX
void CL_ParseNations(const char *name, const char **text)
Parse the nation data from script file.
void CL_ParseEventMails(const char *name, const char **text)
#define NON_OCCURRENCE_PROBABILITY
The probability that any new alien mission will be a non-occurrence mission.
campaign_t campaigns[MAX_CAMPAIGNS]
interestCategory_t missionCategories[INTERESTCATEGORY_MAX]
bool NAT_ScriptSanityCheck(void)
Checks the parsed nations and cities for errors.
static const value_t salary_vals[]
void CITY_Parse(const char *name, const char **text)
Parse the city data from script file.
void CP_ReadCampaignData(const campaign_t *campaign)
bool B_ItemIsStoredInBaseStorage(const objDef_t *obj)
Check if an item is stored in storage.
#define MAX_ALIEN_GROUP_PER_CATEGORY