Nation code. More...
#include "../client.h"
#include "../cl_shared.h"
#include "../ui/ui_main.h"
#include "../ui/node/ui_node_linechart.h"
#include "../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_map.h"
#include "cp_ufo.h"
#include "save/save_nation.h"
Go to the source code of this file.
Functions | |
nation_t * | NAT_GetNationByIDX (const int index) |
nation_t * | NAT_GetNationByID (const char *nationID) |
Return a nation-pointer by the nations id (nation_t->id) text. | |
void | NAT_UpdateHappinessForAllNations (void) |
Lower happiness of nations depending on alien activity. | |
int | NAT_GetFunding (const nation_t *const nation, int month) |
Get the actual funding of a nation. | |
const char * | NAT_GetHappinessString (const nation_t *nation) |
Translates the nation happiness float value to a string. | |
void | NAT_SetHappiness (nation_t *nation, const float happiness) |
Updates the nation happiness. | |
qboolean | NAT_SaveXML (mxml_node_t *p) |
Nation saving callback. | |
qboolean | NAT_LoadXML (mxml_node_t *p) |
Nation loading xml callback. | |
void | CL_ParseNations (const char *name, const char **text) |
Parse the nation data from script file. | |
void | CL_ParseCities (const char *name, const char **text) |
Parse the city data from script file. | |
qboolean | NAT_ScriptSanityCheck (void) |
Checks the parsed nations and cities for errors. | |
static void | CP_NationStatsClick_f (void) |
static int | CL_NationsMaxFunding (void) |
Search the maximum (current) funding from all the nations (in all logged months). | |
static void | CL_NationDrawStats (const nation_t *nation, uiNode_t *node, lineStrip_t *funding, int maxFunding, int color) |
Draws a graph for the funding values over time. | |
static void | CL_NationStatsUpdate_f (void) |
Shows the current nation list + statistics. | |
static void | CL_NationSelect_f (void) |
Select nation and display all relevant information for it. | |
void | NAT_InitStartup (void) |
Variables | |
static const value_t | nation_vals [] |
static const value_t | city_vals [] |
static screenPoint_t | fundingPts [MAX_NATIONS][MONTHS_PER_YEAR] |
static int | usedFundPtslist = 0 |
static screenPoint_t | colorLinePts [MAX_NATIONS][2] |
static int | usedColPtslists = 0 |
static const vec4_t | graphColors [MAX_NATIONS] |
static const vec4_t | graphColorSelected = {1, 1, 1, 1} |
static int | selectedNation = 0 |
static lineStrip_t | fundingLineStrip [MAX_NATIONS] |
static lineStrip_t | colorLineStrip [MAX_NATIONS] |
Nation code.
Definition in file cp_nation.c.
static void CL_NationDrawStats | ( | const nation_t * | nation, | |
uiNode_t * | node, | |||
lineStrip_t * | funding, | |||
int | maxFunding, | |||
int | color | |||
) | [static] |
Draws a graph for the funding values over time.
[in] | nation | The nation to draw the graph for. |
[in] | node | A pointer to a "linestrip" node that we want to draw in. |
[out] | funding | Funding graph data in a lineStrip_t |
[in] | maxFunding | The upper limit of the graph - all values will be scaled to this one. |
[in] | color | If this is -1 draw the line for the current selected nation |
Definition at line 611 of file cp_nation.c.
References ccs, lineStrip_s::color, Cvar_Set(), graphColors, graphColorSelected, nation_s::id, int(), nationInfo_s::inuse, m, MONTHS_PER_YEAR, NAT_GetFunding(), ccs_s::nations, lineStrip_s::numPoints, lineStrip_s::pointList, selectedNation, uiNode_s::size, nation_s::stats, usedFundPtslist, va(), Vector4Copy, screenPoint_t::x, and screenPoint_t::y.
Referenced by CL_NationStatsUpdate_f().
static void CL_NationSelect_f | ( | void | ) | [static] |
Select nation and display all relevant information for it.
Definition at line 761 of file cp_nation.c.
References ccs, CL_NationStatsUpdate_f(), Cmd_Argc(), Cmd_Argv(), Com_Printf(), ccs_s::numNations, and selectedNation.
Referenced by NAT_InitStartup().
static int CL_NationsMaxFunding | ( | void | ) | [static] |
Search the maximum (current) funding from all the nations (in all logged months).
Definition at line 577 of file cp_nation.c.
References ccs, nationInfo_s::inuse, m, MONTHS_PER_YEAR, NAT_GetFunding(), ccs_s::nations, ccs_s::numNations, and nation_s::stats.
Referenced by CL_NationStatsUpdate_f().
static void CL_NationStatsUpdate_f | ( | void | ) | [static] |
Shows the current nation list + statistics.
Definition at line 672 of file cp_nation.c.
References _, ccs, CL_NationDrawStats(), CL_NationsMaxFunding(), lineStrip_s::color, Cvar_Set(), graphColors, graphColorSelected, i, int(), LINESTRIP_COLOR, LINESTRIP_FUNDING, MAX_NATIONS, nation_s::name, NAT_GetFunding(), ccs_s::nations, lineStrip_s::next, ccs_s::numNations, lineStrip_s::numPoints, lineStrip_s::pointList, selectedNation, uiNode_s::size, UI_ExecuteConfunc(), UI_GetNodeByPath(), UI_RegisterLineStrip(), usedColPtslists, usedFundPtslist, va(), Vector4Copy, screenPoint_t::x, and screenPoint_t::y.
Referenced by CL_NationSelect_f(), and NAT_InitStartup().
void CL_ParseCities | ( | const char * | name, | |
const char ** | text | |||
) |
Parse the city data from script file.
[in] | name | ID of the found nation |
[in] | text | The text of the nation node |
Definition at line 379 of file cp_nation.c.
References byte, ccs, ccs_s::cities, Com_DPrintf(), Com_EParse(), Com_EParseValue(), Com_Parse(), Com_Printf(), cp_campaignPool, linkedList_s::data, DEBUG_CLIENT, city_s::id, city_s::idx, LIST_Add(), Mem_PoolStrDup, Mem_PoolStrDupTo, linkedList_s::next, ccs_s::numCities, value_s::ofs, value_s::size, value_s::string, value_s::type, V_CLIENT_HUNK_STRING, and V_TRANSLATION_STRING.
Referenced by CL_ParseScriptFirst().
void CL_ParseNations | ( | const char * | name, | |
const char ** | text | |||
) |
Parse the nation data from script file.
[in] | name | Name or ID of the found nation |
[in] | text | The text of the nation node |
Definition at line 286 of file cp_nation.c.
References ccs, Com_DPrintf(), Com_EParse(), Com_EParseValue(), Com_Parse(), Com_Printf(), cp_campaignPool, DEBUG_CLIENT, i, nation_s::id, nation_s::idx, nationInfo_s::inuse, MAX_NATIONS, Mem_PoolStrDup, Mem_PoolStrDupTo, ccs_s::nations, ccs_s::numNations, value_s::ofs, qtrue, value_s::size, nation_s::stats, value_s::string, value_s::type, V_CLIENT_HUNK_STRING, and V_TRANSLATION_STRING.
Referenced by CL_ParseScriptFirst().
static void CP_NationStatsClick_f | ( | void | ) | [static] |
Definition at line 533 of file cp_nation.c.
References Cbuf_AddText(), ccs, Cmd_Argc(), Cmd_Argv(), Com_Printf(), ccs_s::numNations, UI_PushWindow(), and va().
Referenced by NAT_InitStartup().
int NAT_GetFunding | ( | const nation_t *const | nation, | |
int | month | |||
) |
Get the actual funding of a nation.
[in] | nation | Pointer to the nation |
[in] | month | idx of the month -- 0 for current month (sa nation_t) |
Definition at line 115 of file cp_nation.c.
References nationInfo_s::happiness, nation_s::maxFunding, and nation_s::stats.
Referenced by CL_NationDrawStats(), CL_NationsMaxFunding(), CL_NationStatsUpdate_f(), CL_StatsUpdate_f(), and CP_NationHandleBudget().
const char* NAT_GetHappinessString | ( | const nation_t * | nation | ) |
Translates the nation happiness float value to a string.
[in] | nation |
Definition at line 126 of file cp_nation.c.
References _, nationInfo_s::happiness, and nation_s::stats.
Referenced by CL_StatsUpdate_f(), CP_NationHandleBudget(), NAT_SetHappiness(), and UR_DialogFillNations().
nation_t* NAT_GetNationByID | ( | const char * | nationID | ) |
Return a nation-pointer by the nations id (nation_t->id) text.
[in] | nationID | nation id as defined in (nation_t->id) |
Definition at line 50 of file cp_nation.c.
References ccs, Com_Printf(), i, nation_s::id, ccs_s::nations, and ccs_s::numNations.
Referenced by E_LoadXML(), and NAT_LoadXML().
nation_t* NAT_GetNationByIDX | ( | const int | index | ) |
Definition at line 37 of file cp_nation.c.
References ccs, ccs_s::nations, and ccs_s::numNations.
Referenced by NAT_SaveXML(), UR_DialogInitSell_f(), and UR_DialogStartSell_f().
void NAT_InitStartup | ( | void | ) |
Definition at line 818 of file cp_nation.c.
References CL_NationSelect_f(), CL_NationStatsUpdate_f(), Cmd_AddCommand(), and CP_NationStatsClick_f().
Referenced by CP_InitStartup().
qboolean NAT_LoadXML | ( | mxml_node_t * | p | ) |
Nation loading xml callback.
[in] | p | XML Node structure, where we get the information from |
Definition at line 230 of file cp_nation.c.
References nationInfo_s::happiness, nationInfo_s::inuse, MONTHS_PER_YEAR, mxml_GetFloat(), mxml_GetInt(), mxml_GetNextNode(), mxml_GetNode(), mxml_GetString(), NAT_GetNationByID(), qfalse, qtrue, SAVE_NATION_HAPPINESS, SAVE_NATION_ID, SAVE_NATION_MONTH, SAVE_NATION_MONTH_IDX, SAVE_NATION_NATION, SAVE_NATION_NATIONS, SAVE_NATION_XVI, nation_s::stats, and nationInfo_s::xviInfection.
Referenced by SAV_Init().
qboolean NAT_SaveXML | ( | mxml_node_t * | p | ) |
Nation saving callback.
[out] | p | XML Node structure, where we write the information to |
Definition at line 196 of file cp_nation.c.
References ccs, nationInfo_s::happiness, i, nation_s::id, nationInfo_s::inuse, MONTHS_PER_YEAR, mxml_AddFloat(), mxml_AddInt(), mxml_AddNode(), mxml_AddString(), NAT_GetNationByIDX(), ccs_s::nations, ccs_s::numNations, qtrue, SAVE_NATION_HAPPINESS, SAVE_NATION_ID, SAVE_NATION_MONTH, SAVE_NATION_MONTH_IDX, SAVE_NATION_NATION, SAVE_NATION_NATIONS, SAVE_NATION_XVI, nation_s::stats, and nationInfo_s::xviInfection.
Referenced by SAV_Init().
qboolean NAT_ScriptSanityCheck | ( | void | ) |
Checks the parsed nations and cities for errors.
Definition at line 460 of file cp_nation.c.
References ccs, ccs_s::cities, cls, Com_GetMapDefByIDX(), Com_Printf(), Com_UFOTypeToShortName(), CP_TerrorMissionAvailableUFOs(), mapDef_s::cultures, linkedList_s::data, error(), i, LIST_ContainsString(), MAP_PositionFitsTCPNTypes(), MAP_PrintParameterStringByPos(), linkedList_s::next, client_static_s::numMDs, mapDef_s::populations, city_s::pos, pos, qfalse, qtrue, REMOVE_ELEM, mapDef_s::storyRelated, mapDef_s::terrains, UFO_MAX, and mapDef_s::ufos.
void NAT_SetHappiness | ( | nation_t * | nation, | |
const float | happiness | |||
) |
Updates the nation happiness.
[in] | nation | The nation to update the happiness for |
[in] | happiness | The new happiness value to set for the given nation |
Definition at line 157 of file cp_nation.c.
References _, ccs, Com_sprintf(), cp_messageBuffer, ccs_s::curCampaign, nationInfo_s::happiness, campaign_s::minhappiness, MSG_STANDARD, MSO_CheckAddNewMessage(), nation_s::name, NAT_GetHappinessString(), NT_HAPPINESS_CHANGED, NT_HAPPINESS_MIN, NT_HAPPINESS_PLEASED, NT_NUM_NOTIFYTYPE, qfalse, and nation_s::stats.
Referenced by CL_HandleNationData(), CP_BuildBaseGovernmentLeave(), CP_ChangeNationHappiness_f(), NAT_UpdateHappinessForAllNations(), and UR_DialogStartSell_f().
void NAT_UpdateHappinessForAllNations | ( | void | ) |
Lower happiness of nations depending on alien activity.
Definition at line 76 of file cp_nation.c.
References ccs, Com_DPrintf(), linkedList_s::data, DEBUG_CLIENT, HAPPINESS_ALIEN_MISSION_LOSS, MAP_GetNation(), ccs_s::missions, NAT_SetHappiness(), linkedList_s::next, mission_s::pos, mission_s::stage, STAGE_HARVEST, STAGE_RECON_GROUND, STAGE_SPREAD_XVI, STAGE_SUBVERT_GOV, and STAGE_TERROR_MISSION.
Referenced by CL_CampaignRun().
{ {"name", V_TRANSLATION_STRING, offsetof(city_t, name), 0}, {"pos", V_POS, offsetof(city_t, pos), MEMBER_SIZEOF(city_t, pos)}, {NULL, 0, 0, 0} }
Definition at line 364 of file cp_nation.c.
screenPoint_t colorLinePts[MAX_NATIONS][2] [static] |
Space for 1 line (2 points) for each nation.
Definition at line 555 of file cp_nation.c.
lineStrip_t colorLineStrip[MAX_NATIONS] [static] |
Definition at line 666 of file cp_nation.c.
lineStrip_t fundingLineStrip[MAX_NATIONS] [static] |
Definition at line 600 of file cp_nation.c.
screenPoint_t fundingPts[MAX_NATIONS][MONTHS_PER_YEAR] [static] |
Space for month-lines with 12 points for each nation.
Definition at line 552 of file cp_nation.c.
const vec4_t graphColors[MAX_NATIONS] [static] |
{ {1.0, 0.5, 0.5, 1.0}, {0.5, 1.0, 0.5, 1.0}, {0.5, 0.5, 1.0, 1.0}, {1.0, 0.0, 0.0, 1.0}, {0.0, 1.0, 0.0, 1.0}, {0.0, 0.0, 1.0, 1.0}, {1.0, 1.0, 0.0, 1.0}, {0.0, 1.0, 1.0, 1.0} }
Definition at line 558 of file cp_nation.c.
Referenced by CL_NationDrawStats(), and CL_NationStatsUpdate_f().
const vec4_t graphColorSelected = {1, 1, 1, 1} [static] |
Definition at line 568 of file cp_nation.c.
Referenced by CL_NationDrawStats(), and CL_NationStatsUpdate_f().
const value_t nation_vals[] [static] |
{ {"name", V_TRANSLATION_STRING, offsetof(nation_t, name), 0}, {"pos", V_POS, offsetof(nation_t, pos), MEMBER_SIZEOF(nation_t, pos)}, {"color", V_COLOR, offsetof(nation_t, color), MEMBER_SIZEOF(nation_t, color)}, {"funding", V_INT, offsetof(nation_t, maxFunding), MEMBER_SIZEOF(nation_t, maxFunding)}, {"happiness", V_FLOAT, offsetof(nation_t, stats[0].happiness), MEMBER_SIZEOF(nation_t, stats[0].happiness)}, {"soldiers", V_INT, offsetof(nation_t, maxSoldiers), MEMBER_SIZEOF(nation_t, maxSoldiers)}, {"scientists", V_INT, offsetof(nation_t, maxScientists), MEMBER_SIZEOF(nation_t, maxScientists)}, {NULL, 0, 0, 0} }
Definition at line 266 of file cp_nation.c.
int selectedNation = 0 [static] |
Definition at line 598 of file cp_nation.c.
Referenced by CL_NationDrawStats(), CL_NationSelect_f(), and CL_NationStatsUpdate_f().
int usedColPtslists = 0 [static] |
Definition at line 556 of file cp_nation.c.
Referenced by CL_NationStatsUpdate_f().
int usedFundPtslist = 0 [static] |
Definition at line 553 of file cp_nation.c.
Referenced by CL_NationDrawStats(), and CL_NationStatsUpdate_f().