Campaign parsing code. More...
#include "../cl_shared.h"
#include "../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_rank.h"
#include "cp_parse.h"
Go to the source code of this file.
Data Structures | |
struct | sanity_functions_t |
struct that holds the sanity check data More... | |
Functions | |
static int | CL_GetAlienMissionTypeByID (const char *type) |
static void | CL_ParseAlienTeam (const char *name, const char **text) |
static void | CL_ParseResearchedCampaignItems (const char *name, const char **text) |
This function parses a list of items that should be set to researched = true after campaign start. | |
static void | CL_ParseResearchableCampaignStates (const char *name, const char **text, qboolean researchable) |
This function parses a list of items that should be set to researchable = true after campaign start. | |
static void | CL_ParseSalary (const char *name, const char **text, int campaignID) |
Parse the salaries from campaign definition. | |
void | CL_ParseCampaign (const char *name, const char **text) |
static void | CL_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 (components_t). | |
components_t * | CL_GetComponentsByItem (const objDef_t *item) |
Returns components definition for an item. | |
components_t * | CL_GetComponentsByID (const char *id) |
Returns components definition by ID. | |
static void | CL_ParseScriptFirst (const char *type, const char *name, const char **text) |
Parsing only for singleplayer. | |
static void | CL_ParseScriptSecond (const char *type, const char *name, const char **text) |
Parsing only for singleplayer. | |
static qboolean | CP_ItemsSanityCheck (void) |
Make sure values of items after parsing are proper. | |
void | CL_ScriptSanityCheck (void) |
Check the parsed script values for errors after parsing every script file. | |
void | CL_ReadSinglePlayerData (void) |
Read the data for singleplayer campaigns. | |
Variables | |
static const value_t | alien_group_vals [] |
static const value_t | salary_vals [] |
static const value_t | campaign_vals [] |
static const sanity_functions_t | sanity_functions [] |
Data for sanity check of parsed script data. |
Campaign parsing code.
Definition in file cp_parse.c.
static int CL_GetAlienMissionTypeByID | ( | const char * | type | ) | [static] |
Definition at line 36 of file cp_parse.c.
References Com_Printf(), INTERESTCATEGORY_ALIENBASE, INTERESTCATEGORY_BASE_ATTACK, INTERESTCATEGORY_BUILDING, INTERESTCATEGORY_HARVEST, INTERESTCATEGORY_INTERCEPT, INTERESTCATEGORY_NONE, INTERESTCATEGORY_RECON, INTERESTCATEGORY_RESCUE, INTERESTCATEGORY_SUPPLY, INTERESTCATEGORY_TERROR_ATTACK, and INTERESTCATEGORY_XVI.
Referenced by CL_ParseAlienTeam().
components_t* CL_GetComponentsByID | ( | const char * | id | ) |
Returns components definition by ID.
[in] | id | assemblyId of the component definition. |
Definition at line 623 of file cp_parse.c.
References components_s::assemblyId, ccs, Com_Error(), ccs_s::components, ERR_DROP, i, and ccs_s::numComponents.
Referenced by US_LoadXML(), and US_StoreUFO().
components_t* CL_GetComponentsByItem | ( | const objDef_t * | item | ) |
Returns components definition for an item.
[in] | item | Item to search the components for. |
Definition at line 604 of file cp_parse.c.
References components_s::assemblyId, components_s::assemblyItem, ccs, Com_DPrintf(), Com_Error(), ccs_s::components, DEBUG_CLIENT, ERR_DROP, i, objDef_s::id, and ccs_s::numComponents.
static void CL_ParseAlienTeam | ( | const char * | name, | |
const char ** | text | |||
) | [static] |
Definition at line 73 of file cp_parse.c.
References ccs_s::alienCategories, ALIENCATEGORY_MAX, alienTeamCategory_s::alienTeamGroups, alienTeamGroup_s::alienTeams, alienTeamGroup_s::categoryIdx, ccs, CL_GetAlienMissionTypeByID(), Com_EParse(), Com_EParseValue(), Com_Error(), Com_GetTeamDefinitionByID(), Com_Parse(), Com_Printf(), alienTeamCategory_s::equipment, ERR_DROP, i, alienTeamCategory_s::id, alienTeamGroup_s::idx, INTERESTCATEGORY_NONE, LIST_AddString(), MAX_ALIEN_GROUP_PER_CATEGORY, MAX_TEAMS_PER_MISSION, alienTeamCategory_s::missionCategories, ccs_s::numAlienCategories, alienTeamCategory_s::numAlienTeamGroups, alienTeamGroup_s::numAlienTeams, alienTeamCategory_s::numMissionCategories, value_s::ofs, Q_strncpyz(), value_s::size, value_s::string, and value_s::type.
Referenced by CL_ParseScriptFirst().
void CL_ParseCampaign | ( | const char * | name, | |
const char ** | text | |||
) |
Definition at line 416 of file cp_parse.c.
References salary_s::admin, salary_s::adminInitial, salary_s::aircraftDivisor, salary_s::aircraftFactor, salary_s::base, salary_s::baseUpkeep, ccs_s::campaigns, ccs, CL_ParseSalary(), Com_EParse(), Com_EParseValue(), Com_Parse(), Com_Printf(), CP_GetEventsByID(), salary_s::debtInterest, campaign_s::difficulty, EMPL_PILOT, EMPL_ROBOT, EMPL_SCIENTIST, EMPL_SOLDIER, EMPL_WORKER, campaign_s::events, i, campaign_s::id, campaign_s::idx, MAX_CAMPAIGNS, ccs_s::numCampaigns, value_s::ofs, Q_strncpyz(), salary_s::rankBonus, campaign_s::researched, ccs_s::salaries, value_s::size, value_s::string, campaign_s::team, TEAM_PHALANX, and value_s::type.
Referenced by CL_ParseScriptSecond().
static void CL_ParseComponents | ( | const char * | name, | |
const char ** | text | |||
) | [static] |
Parses one "components" entry in a .ufo file and writes it into the next free entry in xxxxxxxx (components_t).
[in] | name | The unique id of a components_t array entry. |
[in] | text | the whole following text after the "components" definition. |
Definition at line 526 of file cp_parse.c.
References components_s::assemblyId, components_s::assemblyItem, ccs, Com_DPrintf(), Com_EParse(), Com_Parse(), Com_Printf(), COMP_ITEMCOUNT_SCALED, ccs_s::components, DEBUG_CLIENT, INVSH_GetItemByID(), INVSH_GetItemByIDSilent(), components_s::itemAmount, components_s::itemAmount2, components_s::items, MAX_ASSEMBLIES, MAX_COMP, ccs_s::numComponents, components_s::numItemtypes, Q_strncpyz(), and components_s::time.
Referenced by CL_ParseScriptFirst().
static void CL_ParseResearchableCampaignStates | ( | const char * | name, | |
const char ** | text, | |||
qboolean | researchable | |||
) | [static] |
This function parses a list of items that should be set to researchable = true after campaign start.
[in] | name | Name of the techlist |
[in,out] | text | Script to parse |
[in] | researchable | Mark them researchable or not researchable |
Definition at line 256 of file cp_parse.c.
References ccs, CL_GetCampaign(), Com_DPrintf(), Com_EParse(), Com_Parse(), Com_Printf(), cp_campaign, DEBUG_CLIENT, i, technology_s::id, technology_s::mailSent, MAILSENT_PROPOSAL, ccs_s::numTechnologies, campaign_s::researched, RS_GetTechByIDX(), RS_MarkOneResearchable(), and cvar_s::string.
Referenced by CL_ParseScriptSecond().
static void CL_ParseResearchedCampaignItems | ( | const char * | name, | |
const char ** | text | |||
) | [static] |
This function parses a list of items that should be set to researched = true after campaign start.
Definition at line 198 of file cp_parse.c.
References markResearched_s::campaign, ccs, CL_GetCampaign(), Com_DPrintf(), Com_EParse(), Com_Parse(), Com_Printf(), cp_campaign, cp_campaignPool, DEBUG_CLIENT, i, technology_s::id, technology_s::mailSent, MAILSENT_FINISHED, markResearched_s::markOnly, technology_s::markResearched, Mem_PoolStrDup, markResearched_s::numDefinitions, ccs_s::numTechnologies, qtrue, campaign_s::researched, RS_GetTechByIDX(), and cvar_s::string.
Referenced by CL_ParseScriptSecond().
static void CL_ParseSalary | ( | const char * | name, | |
const char ** | text, | |||
int | campaignID | |||
) | [static] |
Parse the salaries from campaign definition.
[in] | name | Name or ID of the found character skill and ability definition |
[in] | text | The text of the nation node |
[in] | campaignID | Current campaign id (idx) |
salary { soldier_base 3000 }
Definition at line 343 of file cp_parse.c.
References ccs, Com_EParse(), Com_EParseValue(), Com_Parse(), Com_Printf(), value_s::ofs, ccs_s::salaries, value_s::size, value_s::string, and value_s::type.
Referenced by CL_ParseCampaign().
static void CL_ParseScriptFirst | ( | const char * | type, | |
const char * | name, | |||
const char ** | text | |||
) | [static] |
Parsing only for singleplayer.
parsed if we are no dedicated server first stage parses all the main data into their struct see CL_ParseScriptSecond for more details about parsing stages
Definition at line 646 of file cp_parse.c.
References AIR_ParseAircraft(), B_ParseBuildings(), CL_ParseAlienTeam(), CL_ParseCampaignEvents(), CL_ParseCities(), CL_ParseComponents(), CL_ParseEventMails(), CL_ParseNations(), CL_ParseRanks(), INS_ParseInstallations(), MSO_ParseCategories(), MSO_ParseSettings(), qfalse, RS_ParseTechnologies(), and UP_ParseChapters().
Referenced by CL_ReadSinglePlayerData().
static void CL_ParseScriptSecond | ( | const char * | type, | |
const char * | name, | |||
const char ** | text | |||
) | [static] |
Parsing only for singleplayer.
parsed if we are no dedicated server second stage links all the parsed data from first stage example: we need a techpointer in a building - in the second stage the buildings and the techs are already parsed - so now we can link them
Definition at line 690 of file cp_parse.c.
References AIR_ParseAircraft(), B_ParseBaseTemplate(), B_ParseBuildings(), CL_ParseCampaign(), CL_ParseResearchableCampaignStates(), CL_ParseResearchedCampaignItems(), qfalse, and qtrue.
Referenced by CL_ReadSinglePlayerData().
void CL_ReadSinglePlayerData | ( | void | ) |
Read the data for singleplayer campaigns.
Definition at line 788 of file cp_parse.c.
References ccs, CHRSH_IsTeamDefAlien(), CL_ParseScriptFirst(), CL_ParseScriptSecond(), Com_DPrintf(), Com_Error(), Com_Printf(), csi, DEBUG_CLIENT, ERR_DROP, FS_BuildFileList(), FS_NextScriptHeader(), i, teamDef_s::id, teamDef_s::idx, name, ccs_s::numBuildingTemplates, ccs_s::numCities, ccs_s::numNations, ccs_s::numRanks, csi_s::numTeamDefs, ccs_s::numTechnologies, RS_GetTechByID(), RS_RequiredLinksAssign(), csi_s::teamDef, ccs_s::teamDefTechs, teamDef_s::tech, type, and UFO_SIZE_T.
Referenced by GAME_CP_InitStartup().
void CL_ScriptSanityCheck | ( | void | ) |
Check the parsed script values for errors after parsing every script file.
Definition at line 768 of file cp_parse.c.
References sanity_functions_t::check, Com_Printf(), and sanity_functions_t::name.
Referenced by CP_CampaignInit().
static qboolean CP_ItemsSanityCheck | ( | void | ) | [static] |
Make sure values of items after parsing are proper.
Definition at line 712 of file cp_parse.c.
References B_ItemIsStoredInBaseStorage(), BS_IsOnMarket(), Com_Printf(), csi, objDef_s::extension, objDef_s::headgear, i, objDef_s::id, INVSH_GetItemByIDX(), csi_s::numODs, PR_ItemIsProduceable(), objDef_s::price, qfalse, qtrue, and objDef_s::size.
const value_t alien_group_vals[] [static] |
{ {"mininterest", V_INT, offsetof(alienTeamGroup_t, minInterest), 0}, {"maxinterest", V_INT, offsetof(alienTeamGroup_t, maxInterest), 0}, {NULL, 0, 0, 0} }
Definition at line 64 of file cp_parse.c.
const value_t campaign_vals[] [static] |
{ {"team", V_TEAM, offsetof(campaign_t, team), MEMBER_SIZEOF(campaign_t, team)}, {"soldiers", V_INT, offsetof(campaign_t, soldiers), MEMBER_SIZEOF(campaign_t, soldiers)}, {"workers", V_INT, offsetof(campaign_t, workers), MEMBER_SIZEOF(campaign_t, workers)}, {"xvirate", V_INT, offsetof(campaign_t, maxAllowedXVIRateUntilLost), MEMBER_SIZEOF(campaign_t, maxAllowedXVIRateUntilLost)}, {"maxdebts", V_INT, offsetof(campaign_t, negativeCreditsUntilLost), MEMBER_SIZEOF(campaign_t, negativeCreditsUntilLost)}, {"minhappiness", V_FLOAT, offsetof(campaign_t, minhappiness), MEMBER_SIZEOF(campaign_t, minhappiness)}, {"scientists", V_INT, offsetof(campaign_t, scientists), MEMBER_SIZEOF(campaign_t, scientists)}, {"ugvs", V_INT, offsetof(campaign_t, ugvs), MEMBER_SIZEOF(campaign_t, ugvs)}, {"equipment", V_STRING, offsetof(campaign_t, equipment), 0}, {"market", V_STRING, offsetof(campaign_t, market), 0}, {"asymptotic_market", V_STRING, offsetof(campaign_t, asymptoticMarket), 0}, {"researched", V_STRING, offsetof(campaign_t, researched), 0}, {"difficulty", V_INT, offsetof(campaign_t, difficulty), MEMBER_SIZEOF(campaign_t, difficulty)}, {"map", V_STRING, offsetof(campaign_t, map), 0}, {"credits", V_INT, offsetof(campaign_t, credits), MEMBER_SIZEOF(campaign_t, credits)}, {"visible", V_BOOL, offsetof(campaign_t, visible), MEMBER_SIZEOF(campaign_t, visible)}, {"text", V_TRANSLATION_STRING, offsetof(campaign_t, text), 0}, {"name", V_TRANSLATION_STRING, offsetof(campaign_t, name), 0}, {"date", V_DATE, offsetof(campaign_t, date), 0}, {"basecost", V_INT, offsetof(campaign_t, basecost), MEMBER_SIZEOF(campaign_t, basecost)}, {"firstbase", V_STRING, offsetof(campaign_t, firstBaseTemplate), 0}, {NULL, 0, 0, 0} }
Definition at line 388 of file cp_parse.c.
const value_t salary_vals[] [static] |
{ {"soldier_base", V_INT, offsetof(salary_t, base[EMPL_SOLDIER]), MEMBER_SIZEOF(salary_t, base[EMPL_SOLDIER])}, {"soldier_rankbonus", V_INT, offsetof(salary_t, rankBonus[EMPL_SOLDIER]), MEMBER_SIZEOF(salary_t, rankBonus[EMPL_SOLDIER])}, {"worker_base", V_INT, offsetof(salary_t, base[EMPL_WORKER]), MEMBER_SIZEOF(salary_t, base[EMPL_WORKER])}, {"worker_rankbonus", V_INT, offsetof(salary_t, rankBonus[EMPL_WORKER]), MEMBER_SIZEOF(salary_t, rankBonus[EMPL_WORKER])}, {"scientist_base", V_INT, offsetof(salary_t, base[EMPL_SCIENTIST]), MEMBER_SIZEOF(salary_t, base[EMPL_SCIENTIST])}, {"scientist_rankbonus", V_INT, offsetof(salary_t, rankBonus[EMPL_SCIENTIST]), MEMBER_SIZEOF(salary_t, rankBonus[EMPL_SCIENTIST])}, {"pilot_base", V_INT, offsetof(salary_t, base[EMPL_PILOT]), MEMBER_SIZEOF(salary_t, base[EMPL_PILOT])}, {"pilot_rankbonus", V_INT, offsetof(salary_t, rankBonus[EMPL_PILOT]), MEMBER_SIZEOF(salary_t, rankBonus[EMPL_PILOT])}, {"robot_base", V_INT, offsetof(salary_t, base[EMPL_ROBOT]), MEMBER_SIZEOF(salary_t, base[EMPL_ROBOT])}, {"robot_rankbonus", V_INT, offsetof(salary_t, rankBonus[EMPL_ROBOT]), MEMBER_SIZEOF(salary_t, rankBonus[EMPL_ROBOT])}, {"aircraft_factor", V_INT, offsetof(salary_t, aircraftFactor), MEMBER_SIZEOF(salary_t, aircraftFactor)}, {"aircraft_divisor", V_INT, offsetof(salary_t, aircraftDivisor), MEMBER_SIZEOF(salary_t, aircraftDivisor)}, {"base_upkeep", V_INT, offsetof(salary_t, baseUpkeep), MEMBER_SIZEOF(salary_t, baseUpkeep)}, {"admin_initial", V_INT, offsetof(salary_t, adminInitial), MEMBER_SIZEOF(salary_t, adminInitial)}, {"admin_soldier", V_INT, offsetof(salary_t, admin[EMPL_SOLDIER]), MEMBER_SIZEOF(salary_t, admin[EMPL_SOLDIER])}, {"admin_worker", V_INT, offsetof(salary_t, admin[EMPL_WORKER]), MEMBER_SIZEOF(salary_t, admin[EMPL_WORKER])}, {"admin_scientist", V_INT, offsetof(salary_t, admin[EMPL_SCIENTIST]), MEMBER_SIZEOF(salary_t, admin[EMPL_SCIENTIST])}, {"admin_pilot", V_INT, offsetof(salary_t, admin[EMPL_PILOT]), MEMBER_SIZEOF(salary_t, admin[EMPL_PILOT])}, {"admin_robot", V_INT, offsetof(salary_t, admin[EMPL_ROBOT]), MEMBER_SIZEOF(salary_t, admin[EMPL_ROBOT])}, {"debt_interest", V_FLOAT, offsetof(salary_t, debtInterest), MEMBER_SIZEOF(salary_t, debtInterest)}, {NULL, 0, 0, 0} }
Definition at line 309 of file cp_parse.c.
const sanity_functions_t sanity_functions[] [static] |
{ {B_ScriptSanityCheck, "buildings"}, {RS_ScriptSanityCheck, "tech"}, {AIR_ScriptSanityCheck, "aircraft"}, {CP_ItemsSanityCheck, "items"}, {NAT_ScriptSanityCheck, "nations"}, {NULL, NULL} }
Data for sanity check of parsed script data.
Definition at line 754 of file cp_parse.c.