cp_research.c File Reference

Technology research. More...

#include "../cl_shared.h"
#include "../ui/ui_main.h"
#include "../ui/ui_popup.h"
#include "../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_research.h"
#include "save/save_research.h"
Include dependency graph for cp_research.c:

Go to the source code of this file.

Defines

#define TECH_HASH_SIZE   64

Functions

static void RS_PushNewsWhenResearchedFinished (const technology_t *tech)
 Push a news about this tech when researched.
void RS_ResearchFinish (technology_t *tech)
 Sets a technology status to researched and updates the date.
void RS_StopResearch (technology_t *tech)
 Stops a research (Removes scientists from it).
void RS_MarkOneResearchable (technology_t *tech)
 Marks one tech as researchable.
qboolean RS_RequirementsMet (const requirements_t *requiredAND, const requirements_t *requiredOR, const base_t *base)
 Checks if all requirements of a tech have been met so that it becomes researchable.
const char * RS_GetDescription (descriptions_t *desc)
 returns the currently used description for a technology.
void RS_MarkCollected (technology_t *tech)
 Marks a give technology as collected.
void RS_MarkResearchable (qboolean init, const base_t *base)
 Marks all the techs that can be researched. Automatically researches 'free' techs such as ammo for a weapon. Not "researchable"-related. Should be called when a new item is researched (RS_MarkResearched) and after the tree-initialisation (RS_InitTree).
static void RS_AssignTechLinks (requirements_t *reqs)
 Assign required tech/item/etc... pointers for a single requirements list.
void RS_RequiredLinksAssign (void)
 Assign Link pointers to all required techs/items/etc...
technology_tRS_GetTechForItem (const objDef_t *item)
void RS_InitTree (qboolean load)
 Gets all needed names/file-paths/etc... for each technology entry. Should be executed after the parsing of _all_ the ufo files and e.g. the research tree/inventory/etc... are initialised.
void RS_AssignScientist (technology_t *tech, base_t *base, employee_t *employee)
 Assigns scientist to the selected research-project.
void RS_RemoveScientist (technology_t *tech, employee_t *employee)
 Remove a scientist from a technology.
void RS_RemoveFiredScientist (base_t *base, employee_t *employee)
 Remove one scientist from research project if needed.
static void RS_MarkResearched (technology_t *tech, const base_t *base)
 Mark technologies as researched. This includes techs that depends on "tech" and have time=0.
qboolean RS_MarkStoryLineEventResearched (const char *techID)
void RS_ResearchRun (void)
 Checks the research status.
void RS_InitStartup (void)
 This is more or less the initial Bind some of the functions in this file to console-commands that you can call ingame. Called from UI_InitStartup resp. CL_InitLocal.
void RS_ResetTechs (void)
 This is called everytime RS_ParseTechnologies is called - to prevent cyclic hash tables.
void RS_ParseTechnologies (const char *name, const char **text)
 Parses one "tech" entry in the research.ufo file and writes it into the next free entry in technologies (technology_t).
static qboolean RS_IsValidTechIndex (int techIdx)
qboolean RS_IsResearched_idx (int techIdx)
 Checks if the technology (tech-index) has been researched.
qboolean RS_IsResearched_ptr (const technology_t *tech)
 Checks whether an item is already researched.
int RS_Collected_ (const technology_t *tech)
technology_tRS_GetTechByIDX (int techIdx)
 Returns the technology pointer for a tech index. You can use this instead of "&ccs.technologies[techIdx]" to avoid having to check valid indices.
technology_tRS_GetTechByID (const char *id)
 return a pointer to the technology identified by given id string
technology_tRS_GetTechByProvided (const char *idProvided)
 returns a pointer to the item tech (as listed in "provides")
technology_tRS_GetTechWithMostScientists (const struct base_s *base)
 Searches for the technology that has the most scientists assigned in a given base.
int RS_GetTechIdxByName (const char *name)
 Returns the index (idx) of a "tech" entry given it's name.
int RS_CountScientistsInBase (const base_t *base)
 Returns the number of employees searching in labs in given base.
void RS_RemoveScientistsExceedingCapacity (base_t *base)
 Remove all exceeding scientist.
qboolean RS_SaveXML (mxml_node_t *parent)
 Save callback for research and technologies.
qboolean RS_LoadXML (mxml_node_t *parent)
 Load callback for research and technologies.
qboolean RS_ResearchAllowed (const base_t *base)
 Returns true if the current base is able to handle research.
qboolean RS_ScriptSanityCheck (void)
 Checks the parsed tech data for errors.

Variables

static technology_ttechHash [TECH_HASH_SIZE]
static technology_ttechHashProvided [TECH_HASH_SIZE]
static linkedList_tredirectedTechs
static const value_t valid_tech_vars []
 The valid definition names in the research.ufo file.
static const value_t valid_techmail_vars []
 The valid definition names in the research.ufo file for tech mails.

Detailed Description

Technology research.

Handles everything related to the research-tree. Provides information if items/buildings/etc.. can be researched/used/displayed etc... Implements the research-system (research new items/etc...) See base/ufos/research.ufo and base/ufos/ui/research.ufo for the underlying content.

Todo:
comment on used global variables.

Definition in file cp_research.c.


Define Documentation

#define TECH_HASH_SIZE   64

Function Documentation

void RS_AssignScientist ( technology_t tech,
base_t base,
employee_t employee 
)

Assigns scientist to the selected research-project.

Note:
The lab will be automatically selected (the first one that has still free space).
Parameters:
[in] tech What technology you want to assign the scientist to.
[in] base Pointer to base where the research is ongoing.
[in] employee Pointer to the scientist to assign. It can be NULL! That means "any".
Note:
if employee is NULL, te system selects an unassigned scientist on the selected (or tech-) base
See also:
RS_AssignScientist_f
RS_RemoveScientist

Todo:
make reassign possible with this.

Definition at line 680 of file cp_research.c.

References _, B_GetBuildingInBaseByType(), B_LAB, technology_s::base, employee_s::building, CAP_LABSPACE, base_s::capacities, Com_DPrintf(), Com_Error(), Com_Printf(), cap_maxcur_s::cur, DEBUG_CLIENT, E_GetUnassignedEmployee(), EMPL_SCIENTIST, ERR_DROP, technology_s::id, employee_s::idx, technology_s::idx, cap_maxcur_s::max, base_s::name, technology_s::name, qtrue, RS_RUNNING, technology_s::scientists, technology_s::statusResearch, technology_s::statusResearchable, employee_s::type, and UI_Popup().

Referenced by RS_AssignScientist_f(), RS_ChangeScientist_f(), RS_MaxOutResearch(), and RS_RemoveFiredScientist().

static void RS_AssignTechLinks ( requirements_t reqs  )  [static]

Assign required tech/item/etc... pointers for a single requirements list.

Note:
A function with the same behaviour was formerly also known as RS_InitRequirementList

Definition at line 413 of file cp_research.c.

References AIR_GetAircraft(), Com_Error(), Com_GetTeamDefinitionByID(), ERR_DROP, i, requirement_s::id, INVSH_GetItemByID(), requirement_s::link, requirements_s::links, requirements_s::numLinks, RS_GetTechByID(), RS_LINK_ALIEN, RS_LINK_ALIEN_DEAD, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, RS_LINK_UFO, and requirement_s::type.

Referenced by RS_InitTree(), and RS_RequiredLinksAssign().

int RS_Collected_ ( const technology_t tech  ) 
See also:
RS_ItemCollected Call this function if you already hold a tech pointer.

Definition at line 1638 of file cp_research.c.

References Com_DPrintf(), DEBUG_CLIENT, and technology_s::statusCollected.

Referenced by UP_AircraftDescription(), UP_Article(), UP_TechGetsDisplayed(), and UP_UGVDescription().

int RS_CountScientistsInBase ( const base_t base  ) 

Returns the number of employees searching in labs in given base.

Parameters:
[in] base Pointer to the base
See also:
B_ResetAllStatusAndCapacities_f
Note:
must not return 0 if hasBuilding[B_LAB] is qfalse: used to update capacity

Definition at line 1763 of file cp_research.c.

References technology_s::base, ccs, ccs_s::numTechnologies, technology_s::scientists, and ccs_s::technologies.

Referenced by B_ResetAllStatusAndCapacities(), and RS_RemoveScientistsExceedingCapacity().

const char* RS_GetDescription ( descriptions_t desc  ) 

returns the currently used description for a technology.

Parameters:
[in] desc A list of possible descriptions (with tech-links that decide which one is the correct one)

< Stored used description

Definition at line 292 of file cp_research.c.

References i, descriptions_s::numDescriptions, RS_GetTechByID(), RS_IsResearched_ptr(), descriptions_s::tech, descriptions_s::text, and descriptions_s::usedDescription.

Referenced by RS_MarkOneResearchable(), RS_ResearchFinish(), and UP_Article().

technology_t* RS_GetTechByID ( const char *  id  ) 

return a pointer to the technology identified by given id string

Parameters:
[in] id Unique identifier of the tech as defined in the research.ufo file (e.g. "tech xxxx").
Returns:
technology_t pointer or NULL if an error occured.

Definition at line 1667 of file cp_research.c.

References Com_HashKey(), Com_Printf(), hash(), technology_s::hashNext, technology_s::id, Q_strcasecmp, and TECH_HASH_SIZE.

Referenced by AIM_AutoEquipAircraft(), AIR_ParseAircraft(), AL_AddAliens(), B_ScriptSanityCheck(), BDEF_BaseDefenceMenuUpdate_f(), CL_ReadSinglePlayerData(), CP_AddTechAsResearchable_f(), CP_GetEventsByID(), CP_XVIInit(), MS_LoadXML(), RS_AssignTechLinks(), RS_GetDescription(), RS_LoadXML(), RS_MarkStoryLineEventResearched(), RS_RequiredLinksAssign(), TR_TransferAlienAfterMissionStart(), and UP_FindEntry_f().

technology_t* RS_GetTechByIDX ( int  techIdx  ) 

Returns the technology pointer for a tech index. You can use this instead of "&ccs.technologies[techIdx]" to avoid having to check valid indices.

Parameters:
[in] techIdx Index in the global ccs.technologies[] array.
Returns:
technology_t pointer or NULL if an error occurred.

Definition at line 1653 of file cp_research.c.

References ccs, RS_IsValidTechIndex(), and ccs_s::technologies.

Referenced by BaseSummary_Init(), CL_ParseResearchableCampaignStates(), CL_ParseResearchedCampaignItems(), RS_GetTechWithMostScientists(), RS_InitGUIData(), RS_MarkResearchable(), RS_RequiredLinksAssign(), RS_ResearchRun(), and RS_SaveXML().

technology_t* RS_GetTechByProvided ( const char *  idProvided  ) 

returns a pointer to the item tech (as listed in "provides")

Parameters:
[in] idProvided Unique identifier of the object the tech is providing
Returns:
The tech for the given object id or NULL if not found

Definition at line 1689 of file cp_research.c.

References Com_DPrintf(), Com_HashKey(), DEBUG_CLIENT, hash(), technology_s::hashProvidedNext, technology_s::provides, Q_strcasecmp, and TECH_HASH_SIZE.

Referenced by AII_LoadOneSlotXML(), AIRFIGHT_LoadXML(), B_ParseBuildings(), BS_BuyType(), BS_MarketInfoClick_f(), GAME_CP_DisplayItemInfo(), RS_InitTree(), UFO_GetTechnologyFromType(), and UP_UGVDescription().

technology_t* RS_GetTechForItem ( const objDef_t item  ) 
int RS_GetTechIdxByName ( const char *  name  ) 

Returns the index (idx) of a "tech" entry given it's name.

Parameters:
[in] name the name of the tech

Definition at line 1744 of file cp_research.c.

References Com_HashKey(), Com_Printf(), hash(), technology_s::hashNext, technology_s::id, technology_s::idx, Q_strcasecmp, TECH_HASH_SIZE, and TECH_INVALID.

technology_t* RS_GetTechWithMostScientists ( const struct base_s base  ) 

Searches for the technology that has the most scientists assigned in a given base.

Parameters:
[in] base In what base the tech should be researched.
See also:
E_RemoveEmployeeFromBuildingOrAircraft

Definition at line 1716 of file cp_research.c.

References technology_s::base, ccs, ccs_s::numTechnologies, RS_GetTechByIDX(), RS_RUNNING, technology_s::scientists, and technology_s::statusResearch.

Referenced by RS_RemoveFiredScientist(), and RS_RemoveScientistsExceedingCapacity().

void RS_InitStartup ( void   ) 

This is more or less the initial Bind some of the functions in this file to console-commands that you can call ingame. Called from UI_InitStartup resp. CL_InitLocal.

Definition at line 1123 of file cp_research.c.

References Cmd_AddCommand().

Referenced by CP_InitStartup().

void RS_InitTree ( qboolean  load  ) 

Gets all needed names/file-paths/etc... for each technology entry. Should be executed after the parsing of _all_ the ufo files and e.g. the research tree/inventory/etc... are initialised.

Parameters:
[in] load qtrue if we are loading a game, qfalse otherwise
Todo:

Add a function to reset ALL research-stati to RS_NONE; -> to be called after start of a new game.

Enhance ammo model display (see comment in code).

See also:
CP_CampaignInit

Todo:
Implement me

Definition at line 509 of file cp_research.c.

References AIR_GetNextFromBase(), ccs_s::aircraftTemplates, B_GetFoundedBaseByIDX(), ccs_s::buildingTemplates, byte, markResearched_s::campaign, ccs, Com_DPrintf(), Com_Error(), Com_Printf(), cp_campaignPool, csi, ccs_s::curCampaign, DEBUG_CLIENT, ERR_DROP, ERR_FATAL, i, aircraft_s::id, building_s::id, technology_s::id, objDef_s::id, objDef_s::idx, building_s::image, objDef_s::image, technology_s::image, INVSH_GetItemByIDX(), technology_s::mail, markResearched_s::markOnly, technology_s::markResearched, technology_s::mdl, Mem_PoolStrDup, aircraft_s::model, objDef_s::model, aircraft_s::name, building_s::name, objDef_s::name, technology_s::name, ccs_s::numAircraftTemplates, ccs_s::numBases, ccs_s::numBuildingTemplates, markResearched_s::numDefinitions, csi_s::numODs, ccs_s::numTechnologies, ccs_s::objDefTechs, csi_s::ods, technology_s::provides, qfalse, qtrue, technology_s::requireAND, technology_s::requireOR, campaign_s::researched, RS_ALIEN, RS_ARMOUR, RS_AssignTechLinks(), RS_BUILDING, RS_CRAFT, RS_CRAFTITEM, RS_GetTechByProvided(), RS_LOGIC, RS_NEWS, RS_ResearchFinish(), RS_TECH, RS_UGV, RS_WEAPON, techMail_s::subject, aircraft_s::tech, TECHMAIL_MAX, ccs_s::technologies, techMail_s::to, and technology_s::type.

Referenced by CP_CampaignInit().

qboolean RS_IsResearched_idx ( int  techIdx  ) 

Checks if the technology (tech-index) has been researched.

Parameters:
[in] techIdx index of the technology.
Returns:
qboolean Returns qtrue if the technology has been researched, otherwise (or on error) qfalse;
See also:
RS_IsResearched_ptr

Definition at line 1611 of file cp_research.c.

References ccs, qfalse, qtrue, RS_FINISH, RS_IsValidTechIndex(), technology_s::statusResearch, and ccs_s::technologies.

qboolean RS_IsResearched_ptr ( const technology_t tech  ) 
static qboolean RS_IsValidTechIndex ( int  techIdx  )  [inline, static]

Definition at line 1593 of file cp_research.c.

References ccs, MAX_TECHNOLOGIES, ccs_s::numTechnologies, qfalse, qtrue, and TECH_INVALID.

Referenced by RS_GetTechByIDX(), and RS_IsResearched_idx().

qboolean RS_LoadXML ( mxml_node_t parent  ) 
void RS_MarkCollected ( technology_t tech  ) 
void RS_MarkOneResearchable ( technology_t tech  ) 

Marks one tech as researchable.

Parameters:
tech The technology to be marked.
See also:
RS_MarkCollected
RS_MarkResearchable

At this point we define what research proposal description is used when displayed. (i.e. "usedDescription" is set here). That's because this is the first the player will see anything from the tech and any later changes may make the content (proposal) of the tech inconsistent for the player.

See also:
RS_ResearchFinish

Definition at line 113 of file cp_research.c.

References _, ccs, Com_DPrintf(), Com_sprintf(), cp_messageBuffer, ccs_s::date, date_s::day, DEBUG_CLIENT, technology_s::id, technology_s::mailSent, MAILSENT_FINISHED, MAILSENT_PROPOSAL, MSG_RESEARCH_PROPOSAL, MSO_CheckAddNewMessage(), technology_s::name, NT_RESEARCH_PROPOSED, technology_s::preDescription, technology_s::preResearchedDate, qfalse, qtrue, RS_GetDescription(), technology_s::statusResearchable, and technology_s::time.

Referenced by CL_ParseResearchableCampaignStates(), CP_AddTechAsResearchable_f(), RS_MarkResearchable(), and RS_ResearchStart_f().

void RS_MarkResearchable ( qboolean  init,
const base_t base 
)

Marks all the techs that can be researched. Automatically researches 'free' techs such as ammo for a weapon. Not "researchable"-related. Should be called when a new item is researched (RS_MarkResearched) and after the tree-initialisation (RS_InitTree).

See also:
RS_MarkResearched

Definition at line 358 of file cp_research.c.

References technology_s::base, ccs, Com_DPrintf(), DEBUG_CLIENT, i, technology_s::id, technology_s::mailSent, MAILSENT_FINISHED, MAILSENT_PROPOSAL, ccs_s::numTechnologies, qfalse, technology_s::requireAND, technology_s::requireOR, RS_FINISH, RS_GetTechByIDX(), RS_MarkOneResearchable(), RS_RequirementsMet(), RS_ResearchFinish(), technology_s::statusResearch, technology_s::statusResearchable, and technology_s::time.

Referenced by B_SellOrAddItems(), B_SetUpFirstBase(), RS_InitGUIData(), RS_MarkResearched(), RS_ResearchRun(), and RS_ResearchStart_f().

static void RS_MarkResearched ( technology_t tech,
const base_t base 
) [static]

Mark technologies as researched. This includes techs that depends on "tech" and have time=0.

Parameters:
[in] tech Pointer to a technology_t struct.
[in] base Pointer to base where we did research.
Todo:
Base shouldn't be needed here - check RS_MarkResearchable() for that.
See also:
RS_ResearchRun

Definition at line 809 of file cp_research.c.

References Com_DPrintf(), DEBUG_CLIENT, technology_s::id, qfalse, RS_MarkResearchable(), and RS_ResearchFinish().

Referenced by RS_MarkStoryLineEventResearched(), and RS_ResearchRun().

qboolean RS_MarkStoryLineEventResearched ( const char *  techID  ) 

Pick a random base to research a story line event tech

Parameters:
techID The event technology script id to research
Note:
If there is no base available the tech is not marked as researched, too

Definition at line 821 of file cp_research.c.

References B_GetFoundedBaseByIDX(), ccs, ccs_s::numBases, qfalse, qtrue, RS_GetTechByID(), RS_IsResearched_ptr(), and RS_MarkResearched().

Referenced by CP_CheckCampaignEvents(), and CP_SpawnAlienBaseMission().

void RS_ParseTechnologies ( const char *  name,
const char **  text 
)

Parses one "tech" entry in the research.ufo file and writes it into the next free entry in technologies (technology_t).

Parameters:
[in] name Unique id of a technology_t. This is parsed from "tech xxx" -> id=xxx
[in] text the whole following text that is part of the "tech" item definition in research.ufo.
See also:
CL_ParseScriptFirst
GAME_SetMode
Note:
write into cp_campaignPool - free on every game restart and reparse

Todo:
use Com_RegisterConstInt();

< Remove first char (i.e. we assume it's the "_")

Todo:
escape "type weapon/tech/etc.." here

Definition at line 1187 of file cp_research.c.

References _, requirement_s::amount, ccs, Com_DPrintf(), Com_EParse(), Com_EParseValue(), Com_Error(), Com_HashKey(), Com_Parse(), Com_Printf(), cp_campaignPool, DEBUG_CLIENT, technology_s::description, ERR_DROP, pediaChapter_s::first, hash(), technology_s::hashNext, technology_s::hashProvidedNext, pediaChapter_s::id, requirement_s::id, technology_s::id, technology_s::idx, pediaChapter_s::last, requirements_s::links, LIST_AddPointer(), LIST_AddString(), technology_s::mail, MAX_DESCRIPTIONS, MAX_TECHLINKS, MAX_TECHNOLOGIES, Mem_PoolStrDup, Mem_PoolStrDupTo, techMail_s::model, ccs_s::numChapters, descriptions_s::numDescriptions, requirements_s::numLinks, technology_s::numTechMails, ccs_s::numTechnologies, value_s::ofs, technology_s::overallTime, technology_s::preDescription, technology_s::provides, qfalse, technology_s::requireAND, technology_s::requireForProduction, technology_s::requireOR, RS_ALIEN, RS_ARMOUR, RS_BUILDING, RS_CRAFT, RS_CRAFTITEM, RS_LINK_ALIEN, RS_LINK_ALIEN_DEAD, RS_LINK_ALIEN_GLOBAL, RS_LINK_ANTIMATTER, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, RS_LINK_UFO, RS_LOGIC, RS_NEWS, RS_NONE, RS_TECH, RS_UGV, RS_WEAPON, value_s::size, technology_s::statusResearch, technology_s::statusResearchable, value_s::string, descriptions_s::tech, TECH_HASH_SIZE, TECHMAIL_MAX, TECHMAIL_PRE, TECHMAIL_RESEARCHED, ccs_s::technologies, descriptions_s::text, technology_s::time, value_s::type, requirement_s::type, technology_s::type, technology_s::upChapter, ccs_s::upChapters, technology_s::upNext, technology_s::upPrev, descriptions_s::usedDescription, V_CLIENT_HUNK_STRING, V_NULL, and V_TRANSLATION_STRING.

Referenced by CL_ParseScriptFirst().

static void RS_PushNewsWhenResearchedFinished ( const technology_t tech  )  [inline, static]

Push a news about this tech when researched.

Parameters:
[in] tech Technology pointer.
See also:
RS_ResearchFinish

Definition at line 49 of file cp_research.c.

Referenced by RS_ResearchFinish().

void RS_RemoveFiredScientist ( base_t base,
employee_t employee 
)

Remove one scientist from research project if needed.

Parameters:
[in] base Pointer to base where a scientist should be removed.
[in] employee Pointer to the employee that is fired.
Note:
used when a scientist is fired.
See also:
E_RemoveEmployeeFromBuildingOrAircraft
Note:
This function is called before the employee is actually fired.

Definition at line 782 of file cp_research.c.

References E_GetUnassignedEmployee(), EMPL_SCIENTIST, RS_AssignScientist(), RS_GetTechWithMostScientists(), and RS_RemoveScientist().

Referenced by E_RemoveEmployeeFromBuildingOrAircraft().

void RS_RemoveScientist ( technology_t tech,
employee_t employee 
)

Remove a scientist from a technology.

Parameters:
[in] tech The technology you want to remove the scientist from.
[in] employee Employee you want to remove (NULL if you don't care which one should be removed).
See also:
RS_RemoveScientist_f
RS_AssignScientist
E_RemoveEmployeeFromBuildingOrAircraft

Definition at line 741 of file cp_research.c.

References technology_s::base, employee_s::building, CAP_LABSPACE, base_s::capacities, Com_Error(), cap_maxcur_s::cur, E_GetAssignedEmployee(), EMPL_SCIENTIST, ERR_DROP, RS_PAUSED, technology_s::scientists, and technology_s::statusResearch.

Referenced by RS_ChangeScientist_f(), RS_RemoveFiredScientist(), RS_RemoveScientist_f(), RS_RemoveScientistsExceedingCapacity(), RS_ResearchFinish(), RS_ResearchRun(), and RS_StopResearch().

void RS_RemoveScientistsExceedingCapacity ( base_t base  ) 

Remove all exceeding scientist.

Parameters:
[in] base Pointer to base where a scientist should be removed.

Definition at line 1782 of file cp_research.c.

References CAP_LABSPACE, base_s::capacities, cap_maxcur_s::cur, cap_maxcur_s::max, RS_CountScientistsInBase(), RS_GetTechWithMostScientists(), and RS_RemoveScientist().

Referenced by B_BuildingOnDestroy_f().

void RS_RequiredLinksAssign ( void   ) 

Assign Link pointers to all required techs/items/etc...

Note:
This replaces the RS_InitRequirementList function (since the switch to the _OR and _AND list)

< Use this so we do not change the original redirectedTechs pointer.

Definition at line 455 of file cp_research.c.

References ccs, linkedList_s::data, i, LIST_Delete(), linkedList_s::next, requirements_s::numLinks, ccs_s::numTechnologies, technology_s::redirect, technology_s::requireAND, technology_s::requireForProduction, technology_s::requireOR, RS_AssignTechLinks(), RS_GetTechByID(), and RS_GetTechByIDX().

Referenced by CL_ReadSinglePlayerData().

qboolean RS_RequirementsMet ( const requirements_t requiredAND,
const requirements_t requiredOR,
const base_t base 
)

Checks if all requirements of a tech have been met so that it becomes researchable.

Note:
If there are NO requirements defined at all it will always return true.
Parameters:
[in] requiredAND Pointer to a list of AND-related requirements.
[in] requiredOR Pointer to a list of OR-related requirements.
[in] base In what base to check the "collected" items etc..
Returns:
true if all requirements are satisfied otherwise .
Todo:
Add support for the "delay" value.

Definition at line 158 of file cp_research.c.

References AL_CountAll(), AL_GetAlienAmount(), requirement_s::amount, B_AntimatterInBase(), B_ItemInBase(), Com_DPrintf(), Com_Printf(), DEBUG_CLIENT, i, requirement_s::id, requirement_s::link, requirements_s::links, requirements_s::numLinks, qfalse, qtrue, RS_IsResearched_ptr(), RS_LINK_ALIEN, RS_LINK_ALIEN_DEAD, RS_LINK_ALIEN_GLOBAL, RS_LINK_ANTIMATTER, RS_LINK_ITEM, RS_LINK_TECH, RS_LINK_TECH_NOT, RS_LINK_UFO, requirement_s::type, and US_UFOsInStorage().

Referenced by RS_MarkResearchable(), RS_ResearchRun(), and RS_ResearchStart_f().

qboolean RS_ResearchAllowed ( const base_t base  ) 

Returns true if the current base is able to handle research.

See also:
B_BaseInit_f probably menu function, but not for research gui

Definition at line 1916 of file cp_research.c.

References B_GetBuildingStatus(), B_LAB, BASE_UNDER_ATTACK, base_s::baseStatus, E_CountHired(), EMPL_SCIENTIST, qfalse, and qtrue.

Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick(), RS_ResearchRun(), and TR_TransferStart().

void RS_ResearchFinish ( technology_t tech  ) 

Sets a technology status to researched and updates the date.

Parameters:
[in] tech The technology that was researched.

At this point we define what research-report description is used when displayed. (i.e. "usedDescription" is set here). That's because this is the first the player will see the research result and any later changes may make the content inconsistent for the player.

See also:
RS_MarkOneResearchable

Definition at line 59 of file cp_research.c.

References _, ccs, Cmd_ExecuteString(), Com_sprintf(), cp_messageBuffer, ccs_s::date, technology_s::description, technology_s::finishedResearchEvent, technology_s::mailSent, MAILSENT_FINISHED, MSG_RESEARCH_FINISHED, MSO_CheckAddNewMessage(), technology_s::name, NT_RESEARCH_COMPLETED, technology_s::preDescription, technology_s::preResearchedDate, qfalse, qtrue, technology_s::researchedDate, RS_FINISH, RS_GetDescription(), RS_LOGIC, RS_PushNewsWhenResearchedFinished(), RS_RemoveScientist(), technology_s::scientists, technology_s::statusResearch, technology_s::statusResearchable, technology_s::type, and descriptions_s::usedDescription.

Referenced by RS_InitTree(), RS_MarkResearchable(), and RS_MarkResearched().

void RS_ResearchRun ( void   ) 

Checks the research status.

Todo:
Needs to check on the exact time that elapsed since the last check of the status.
See also:
RS_MarkResearched

< If there are scientitsts there _has_ to be a base.

Todo:
Just for testing, better formular may be needed. Include employee-skill in calculation.
Todo:
CHECK THAT: very very strange

rudolfo: please verify; I changed from RS_InitGuiData to RS_MarkResearchable

Definition at line 843 of file cp_research.c.

References _, technology_s::base, ccs, Com_sprintf(), cp_messageBuffer, i, base_s::idx, MAX_BASES, MSG_RESEARCH_HALTED, MSO_CheckAddNewMessage(), base_s::name, technology_s::name, NT_RESEARCH_HALTED, ccs_s::numTechnologies, qfalse, technology_s::requireAND, technology_s::requireOR, RS_GetTechByIDX(), RS_MarkResearchable(), RS_MarkResearched(), RS_PAUSED, RS_RemoveScientist(), RS_RequirementsMet(), RS_ResearchAllowed(), RS_RUNNING, technology_s::scientists, technology_s::statusResearch, and technology_s::time.

Referenced by CL_CampaignRun().

void RS_ResetTechs ( void   ) 

This is called everytime RS_ParseTechnologies is called - to prevent cyclic hash tables.

Definition at line 1137 of file cp_research.c.

References LIST_Delete().

Referenced by CL_ResetSinglePlayerData().

qboolean RS_SaveXML ( mxml_node_t parent  ) 
qboolean RS_ScriptSanityCheck ( void   ) 

Checks the parsed tech data for errors.

Returns:
false if there are errors - true otherwise

Todo:
error++; Crafts still give errors - are there any definitions missing?

Definition at line 1931 of file cp_research.c.

References ccs, Com_Printf(), technology_s::description, error(), technology_s::id, technology_s::name, ccs_s::numTechnologies, technology_s::produceTime, technology_s::provides, qfalse, qtrue, RS_ALIEN, RS_BUILDING, RS_LOGIC, RS_NEWS, RS_TECH, ccs_s::technologies, descriptions_s::text, and technology_s::type.

void RS_StopResearch ( technology_t tech  ) 

Stops a research (Removes scientists from it).

Parameters:
[in] tech The technology that is being researched.

Definition at line 99 of file cp_research.c.

References RS_PAUSED, RS_RemoveScientist(), technology_s::scientists, and technology_s::statusResearch.

Referenced by RS_ResearchStop_f(), and US_RemoveStoredUFO().


Variable Documentation

Definition at line 449 of file cp_research.c.

technology_t* techHash[TECH_HASH_SIZE] [static]

Definition at line 41 of file cp_research.c.

technology_t* techHashProvided[TECH_HASH_SIZE] [static]

Definition at line 42 of file cp_research.c.

const value_t valid_tech_vars[] [static]
Initial value:
 {
    {"name", V_TRANSLATION_STRING, offsetof(technology_t, name), 0},
    {"provides", V_CLIENT_HUNK_STRING, offsetof(technology_t, provides), 0},
    {"event", V_CLIENT_HUNK_STRING, offsetof(technology_t, finishedResearchEvent), 0},
    {"delay", V_INT, offsetof(technology_t, delay), MEMBER_SIZEOF(technology_t, delay)},
    {"producetime", V_INT, offsetof(technology_t, produceTime), MEMBER_SIZEOF(technology_t, produceTime)},
    {"time", V_FLOAT, offsetof(technology_t, time), MEMBER_SIZEOF(technology_t, time)},
    {"image", V_CLIENT_HUNK_STRING, offsetof(technology_t, image), 0},
    {"mdl", V_CLIENT_HUNK_STRING, offsetof(technology_t, mdl), 0},

    {NULL, 0, 0, 0}
}

The valid definition names in the research.ufo file.

Note:
Handled in parser below. description, preDescription, requireAND, requireOR, up_chapter

Definition at line 1152 of file cp_research.c.

const value_t valid_techmail_vars[] [static]
Initial value:
 {
    {"from", V_TRANSLATION_STRING, offsetof(techMail_t, from), 0},
    {"to", V_TRANSLATION_STRING, offsetof(techMail_t, to), 0},
    {"subject", V_TRANSLATION_STRING, offsetof(techMail_t, subject), 0},
    {"date", V_TRANSLATION_STRING, offsetof(techMail_t, date), 0},
    {"icon", V_CLIENT_HUNK_STRING, offsetof(techMail_t, icon), 0},
    {"model", V_CLIENT_HUNK_STRING, offsetof(techMail_t, model), 0},

    {NULL, 0, 0, 0}
}

The valid definition names in the research.ufo file for tech mails.

Definition at line 1168 of file cp_research.c.


Generated by  doxygen 1.6.2