cp_parse.c 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 dependency graph for cp_parse.c:

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_tCL_GetComponentsByItem (const objDef_t *item)
 Returns components definition for an item.
components_tCL_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.

Detailed Description

Campaign parsing code.

Definition in file cp_parse.c.


Function Documentation

static int CL_GetAlienMissionTypeByID ( const char *  type  )  [static]
components_t* CL_GetComponentsByID ( const char *  id  ) 

Returns components definition by ID.

Parameters:
[in] id assemblyId of the component definition.
Returns:
comp Pointer to components_t 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.

Parameters:
[in] item Item to search the components for.
Returns:
comp Pointer to components_t definition.

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]
void CL_ParseCampaign ( const char *  name,
const char **  text 
)
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).

Parameters:
[in] name The unique id of a components_t array entry.
[in] text the whole following text after the "components" definition.
See also:
CL_ParseScriptFirst

Todo:
Set item links to NONE if needed

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.

Parameters:
[in] name Name of the techlist
[in,out] text Script to parse
[in] researchable Mark them researchable or not researchable
See also:
CL_ParseScriptFirst
Todo:
Mark unresearchable

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]
static void CL_ParseSalary ( const char *  name,
const char **  text,
int  campaignID 
) [static]

Parse the salaries from campaign definition.

Parameters:
[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)
Note:
Example: 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

See also:
CL_ReadSinglePlayerData
Com_ParseScripts
CL_ParseScriptSecond

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

See also:
CL_ReadSinglePlayerData
Com_ParseScripts
CL_ParseScriptFirst

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   ) 
void CL_ScriptSanityCheck ( void   ) 

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

See also:
CL_ReadSinglePlayerData

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]

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},
    {NULL, 0, 0, 0}
}

Definition at line 64 of file cp_parse.c.

const value_t campaign_vals[] [static]
Initial value:
 {
    {"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]
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)},
    {"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.

Initial value:
 {
    {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.


Generated by  doxygen 1.6.2