UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_parse.cpp File Reference

Campaign parsing code. More...

#include "../../cl_shared.h"
#include "../../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_rank.h"
#include "cp_parse.h"
#include "../../cl_inventory.h"
#include "cp_component.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 interestCategory_t CP_GetAlienMissionTypeByID (const char *type)
 
static void CP_ParseAlienTeam (const char *name, const char **text)
 
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. More...
 
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. More...
 
static void CP_ParseSalary (const char *name, const char **text, salary_t *s)
 Parse the salaries from campaign definition. More...
 
static void CP_ParseCampaign (const char *name, const char **text)
 
static void CP_ParseScriptFirst (const char *type, const char *name, const char **text)
 Parsing campaign data. More...
 
static void CP_ParseScriptSecond (const char *type, const char *name, const char **text)
 Parsing only for singleplayer. More...
 
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. More...
 
static bool CP_ItemsSanityCheck (void)
 Make sure values of items after parsing are proper. More...
 
void CP_ScriptSanityCheck (void)
 Check the parsed script values for errors after parsing every script file. More...
 
void CP_ParseCampaignData (void)
 Read the data for campaigns. More...
 
void CP_ReadCampaignData (const campaign_t *campaign)
 

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. More...
 

Detailed Description

Campaign parsing code.

Definition in file cp_parse.cpp.

Function Documentation

static bool CP_ItemsSanityCheck ( void  )
static

Make sure values of items after parsing are proper.

Definition at line 563 of file cp_parse.cpp.

References B_ItemIsStoredInBaseStorage(), BS_IsOnMarket(), cgi, cgame_import_s::csi, i, objDef_s::id, INVSH_GetItemByIDX(), csi_s::numODs, PR_ItemIsProduceable(), objDef_s::price, and objDef_s::size.

static void CP_ParseResearchableCampaignStates ( const campaign_t campaign,
const char *  name,
const char **  text,
bool  researchable 
)
static

This function parses a list of items that should be set to researchable = true after campaign start.

Parameters
[in]campaignThe campaign data structure
[in]nameName of the techlist
[in,out]textScript to parse
[in]researchableMark them researchable or not researchable
See also
CP_ParseScriptFirst
Todo:
Mark unresearchable

Definition at line 254 of file cp_parse.cpp.

References ccs, cgi, cgame_import_s::Com_EParse(), Com_Parse(), DEBUG_CLIENT, i, technology_s::id, technology_s::mailSent, MAILSENT_PROPOSAL, ccs_s::numTechnologies, Q_streq, campaign_s::researched, RS_GetTechByIDX(), and RS_MarkOneResearchable().

Referenced by CP_ParseScriptCampaignRelated().

static void CP_ParseResearchedCampaignItems ( const campaign_t campaign,
const char *  name,
const char **  text 
)
static
static void CP_ParseSalary ( const char *  name,
const char **  text,
salary_t s 
)
static

Parse the salaries from campaign definition.

Parameters
[in]nameName or ID of the found character skill and ability definition
[in]textThe text of the nation node
[out]sPointer to the campaign salaries data structure to parse into
Note
Example: salary { soldier_base 3000 }

Definition at line 329 of file cp_parse.cpp.

References cgi, and cp_campaignPool.

Referenced by CP_ParseCampaign().

static void CP_ParseScriptCampaignRelated ( const campaign_t campaign,
const char *  type,
const char *  name,
const char **  text 
)
static

Parses the campaign specific data - this data can only be parsed once the campaign started.

Definition at line 550 of file cp_parse.cpp.

References CP_ParseResearchableCampaignStates(), CP_ParseResearchedCampaignItems(), and Q_streq.

Referenced by CP_ReadCampaignData().

static void CP_ParseScriptFirst ( const char *  type,
const char *  name,
const char **  text 
)
static

Parsing campaign data.

first stage parses all the main data into their struct see CP_ParseScriptSecond for more details about parsing stages

See also
CP_ParseCampaignData
CP_ParseScriptSecond

Definition at line 490 of file cp_parse.cpp.

References AIR_ParseAircraft(), B_ParseBuildings(), CITY_Parse(), CL_ParseCampaignEvents(), CL_ParseEventMails(), CL_ParseNations(), CL_ParseRanks(), COMP_ParseComponents(), CP_ParseAlienTeam(), CP_ParseEventTrigger(), INS_ParseInstallations(), MSO_ParseMessageSettings(), Q_streq, RS_ParseTechnologies(), and UP_ParseChapter().

Referenced by CP_ParseCampaignData().

static void CP_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

See also
CP_ParseCampaignData
Com_ParseScripts
CL_ParseScriptFirst

Definition at line 534 of file cp_parse.cpp.

References AIR_ParseAircraft(), B_ParseBaseTemplate(), B_ParseBuildings(), CP_ParseCampaign(), and Q_streq.

Referenced by CP_ParseCampaignData().

void CP_ScriptSanityCheck ( void  )

Check the parsed script values for errors after parsing every script file.

See also
CP_ParseCampaignData

Definition at line 612 of file cp_parse.cpp.

References cgi, sanity_functions_t::check, sanity_functions_t::name, and sanity_functions.

Referenced by CP_CampaignInit().

Variable Documentation

const value_t alien_group_vals[]
static
Initial value:
= {
{"mininterest", V_INT, offsetof(alienTeamGroup_t, minInterest), 0},
{"maxinterest", V_INT, offsetof(alienTeamGroup_t, maxInterest), 0},
{"minaliencount", V_INT, offsetof(alienTeamGroup_t, minAlienCount), 0},
{"maxaliencount", V_INT, offsetof(alienTeamGroup_t, maxAlienCount), 0},
{nullptr, V_NULL, 0, 0}
}
alien team group definition.
Definition: cp_campaign.h:105
Definition: scripts.h:49
Definition: scripts.h:52

Definition at line 67 of file cp_parse.cpp.

const value_t campaign_vals[]
static

Definition at line 336 of file cp_parse.cpp.

const value_t salary_vals[]
static
Initial value:
= {
{"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)},
{"debt_interest", V_FLOAT, offsetof(salary_t, debtInterest), MEMBER_SIZEOF(salary_t, debtInterest)},
{nullptr, V_NULL, 0, 0}
}
Definition: scripts.h:49
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition: scripts.h:34
Definition: scripts.h:52

Definition at line 301 of file cp_parse.cpp.

const sanity_functions_t sanity_functions[]
static
Initial value:
= {
{AIR_ScriptSanityCheck, "aircraft"},
{CP_ItemsSanityCheck, "items"},
{NAT_ScriptSanityCheck, "nations"},
{nullptr, nullptr}
}
bool AIR_ScriptSanityCheck(void)
Checks the parsed aircraft for errors.
bool RS_ScriptSanityCheck(void)
Checks the parsed tech data for errors.
static bool CP_ItemsSanityCheck(void)
Make sure values of items after parsing are proper.
Definition: cp_parse.cpp:563
bool B_BuildingScriptSanityCheck(void)
Checks the parsed buildings for errors.
bool NAT_ScriptSanityCheck(void)
Checks the parsed nations and cities for errors.
Definition: cp_nation.cpp:470

Data for sanity check of parsed script data.

Definition at line 598 of file cp_parse.cpp.

Referenced by CP_ScriptSanityCheck().