UFO: Alien Invasion
Loading...
Searching...
No Matches
cp_parse.cpp File Reference

Campaign parsing code. More...

#include "../../DateTime.h"
#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"
Include dependency graph for cp_parse.cpp:

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.
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 void CP_ParseSalary (const char *name, const char **text, salary_t *s)
 Parse the salaries from campaign definition.
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.
static void CP_ParseScriptSecond (const char *type, const char *name, const char **text)
 Parsing only for singleplayer.
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.
static bool CP_ItemsSanityCheck (void)
 Make sure values of items after parsing are proper.
void CP_ScriptSanityCheck (void)
 Check the parsed script values for errors after parsing every script file.
void CP_ParseCampaignData (void)
 Read the data for campaigns.
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.

Detailed Description

Campaign parsing code.

Definition in file cp_parse.cpp.

Function Documentation

◆ CP_GetAlienMissionTypeByID()

◆ CP_ItemsSanityCheck()

bool CP_ItemsSanityCheck ( void )
static

Make sure values of items after parsing are proper.

Definition at line 574 of file cp_parse.cpp.

References B_ItemIsStoredInBaseStorage(), BS_IsOnMarket(), cgi, i, objDef_t::id, INVSH_GetItemByIDX(), PR_ItemIsProduceable(), objDef_t::price, and objDef_t::size.

◆ CP_ParseAlienTeam()

◆ CP_ParseCampaign()

◆ CP_ParseCampaignData()

◆ CP_ParseResearchableCampaignStates()

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 255 of file cp_parse.cpp.

References ccs, cgi, Com_Parse(), DEBUG_CLIENT, i, technology_t::id, technology_t::mailSent, MAILSENT_PROPOSAL, name, Q_streq, campaign_t::researched, RS_GetTechByIDX(), and RS_MarkOneResearchable().

Referenced by CP_ParseScriptCampaignRelated().

◆ CP_ParseResearchedCampaignItems()

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

◆ CP_ParseSalary()

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 330 of file cp_parse.cpp.

References cgi, cp_campaignPool, name, and salary_vals.

Referenced by CP_ParseCampaign().

◆ CP_ParseScriptCampaignRelated()

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 561 of file cp_parse.cpp.

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

Referenced by CP_ReadCampaignData().

◆ CP_ParseScriptFirst()

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 501 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(), name, Q_streq, RS_ParseTechnologies(), type, and UP_ParseChapter().

Referenced by CP_ParseCampaignData().

◆ CP_ParseScriptSecond()

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 545 of file cp_parse.cpp.

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

Referenced by CP_ParseCampaignData().

◆ CP_ReadCampaignData()

void CP_ReadCampaignData ( const campaign_t * campaign)

◆ CP_ScriptSanityCheck()

void CP_ScriptSanityCheck ( void )

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

See also
CP_ParseCampaignData

Definition at line 623 of file cp_parse.cpp.

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

Referenced by CP_CampaignInit().

Variable Documentation

◆ alien_group_vals

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}
}
@ V_NULL
Definition scripts.h:49
@ V_INT
Definition scripts.h:52
alien team group definition.

Definition at line 68 of file cp_parse.cpp.

Referenced by CP_ParseAlienTeam().

◆ campaign_vals

const value_t campaign_vals[]
static

Definition at line 337 of file cp_parse.cpp.

Referenced by CP_ParseCampaign().

◆ salary_vals

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}
}
@ EMPL_SOLDIER
Definition cp_employee.h:31
@ EMPL_ROBOT
Definition cp_employee.h:35
@ EMPL_PILOT
Definition cp_employee.h:34
@ EMPL_WORKER
Definition cp_employee.h:33
@ EMPL_SCIENTIST
Definition cp_employee.h:32
@ V_FLOAT
Definition scripts.h:54
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition scripts.h:34

Definition at line 302 of file cp_parse.cpp.

Referenced by CP_ParseSalary().

◆ sanity_functions

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 B_BuildingScriptSanityCheck(void)
Checks the parsed buildings for errors.
bool NAT_ScriptSanityCheck(void)
Checks the parsed nations and cities for errors.
static bool CP_ItemsSanityCheck(void)
Make sure values of items after parsing are proper.
Definition cp_parse.cpp:574
bool RS_ScriptSanityCheck(void)
Checks the parsed tech data for errors.

Data for sanity check of parsed script data.

Definition at line 609 of file cp_parse.cpp.

Referenced by CP_ScriptSanityCheck().