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

Technology research. More...

#include "../../DateTime.h"
#include "../../cl_shared.h"
#include "../../../shared/parse.h"
#include "cp_campaign.h"
#include "cp_capacity.h"
#include "cp_research.h"
#include "cp_popup.h"
#include "cp_time.h"
#include "save/save_research.h"
#include "aliencontainment.h"
Include dependency graph for cp_research.cpp:

Go to the source code of this file.

Macros

#define TECH_HASH_SIZE   64

Functions

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.
bool RS_RequirementsMet (const technology_t *tech, const base_t *base)
 Checks if all requirements of a tech have been met so that it becomes researchable.
const char * RS_GetDescription (technologyDescriptions_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 (const base_t *base, bool init)
 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)
 Returns technology entry for an item.
technology_tRS_GetTechForTeam (const teamDef_t *team)
 Returns technology entry for a team.
void RS_InitTree (const campaign_t *campaign, bool 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 *employee)
 Assigns scientist to the selected research-project.
void RS_RemoveScientist (technology_t *tech, Employee *employee)
 Remove a scientist from a technology.
void RS_RemoveFiredScientist (base_t *base, Employee *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.
bool RS_MarkStoryLineEventResearched (const char *techID)
void RS_CheckRequirements (void)
 Checks if running researches still meet their requirements.
int 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 bool RS_IsValidTechIndex (int techIdx)
bool RS_IsResearched_idx (int techIdx)
 Checks if the technology (tech-index) has been researched.
bool RS_IsResearched_ptr (const technology_t *tech)
 Checks whether an item is already researched.
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.
bool RS_SaveXML (xmlNode_t *parent)
 Save callback for research and technologies.
bool RS_LoadXML (xmlNode_t *parent)
 Load callback for research and technologies.
bool RS_ResearchAllowed (const base_t *base)
 Returns true if the current base is able to handle research.
bool 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.cpp.

Macro Definition Documentation

◆ TECH_HASH_SIZE

#define TECH_HASH_SIZE   64

Function Documentation

◆ RS_AssignScientist()

void RS_AssignScientist ( technology_t * tech,
base_t * base,
Employee * 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]techWhat technology you want to assign the scientist to.
[in]basePointer to base where the research is ongoing.
[in]employeePointer to the scientist to assign. It can be nullptr! That means "any".
Note
if employee is nullptr, te system selects an unassigned scientist on the selected (or tech-) base
See also
RS_AssignScientist_f
RS_RemoveScientist

Definition at line 654 of file cp_research.cpp.

References _, technology_t::base, CAP_AddCurrent(), CAP_GetFreeCapacity(), CAP_LABSPACE, cgi, CP_Popup(), DEBUG_CLIENT, E_GetUnassignedEmployee(), EMPL_SCIENTIST, technology_t::id, technology_t::idx, base_t::name, technology_t::name, RS_RUNNING, technology_t::scientists, Employee::setAssigned(), technology_t::statusResearch, and technology_t::statusResearchable.

Referenced by RS_Change_f(), RS_Max_f(), RS_RemoveFiredScientist(), and TEST_F().

◆ RS_AssignTechLinks()

void RS_AssignTechLinks ( requirements_t * reqs)
static

◆ RS_CheckRequirements()

◆ RS_CountScientistsInBase()

int RS_CountScientistsInBase ( const base_t * base)

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

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

Definition at line 1688 of file cp_research.cpp.

References technology_t::base, ccs, i, and technology_t::scientists.

Referenced by B_ResetAllStatusAndCapacities(), and RS_RemoveScientistsExceedingCapacity().

◆ RS_GetDescription()

const char * RS_GetDescription ( technologyDescriptions_t * desc)

returns the currently used description for a technology.

Parameters
[in,out]descA list of possible descriptions (with tech-links that decide which one is the correct one)

< Stored used description

Definition at line 271 of file cp_research.cpp.

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

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

◆ RS_GetTechByID()

◆ RS_GetTechByIDX()

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]techIdxIndex in the global ccs.technologies[] array.
Returns
technology_t pointer or nullptr if an error occurred.

Definition at line 1590 of file cp_research.cpp.

References ccs, and RS_IsValidTechIndex().

Referenced by AIM_AircraftEquipMenuClick_f(), CP_ParseResearchableCampaignStates(), CP_ParseResearchedCampaignItems(), RS_CheckRequirements(), RS_FillTechnologyList_f(), RS_GetTechWithMostScientists(), RS_MarkResearchable(), RS_RequiredLinksAssign(), RS_ResearchRun(), RS_SaveXML(), and RS_ShowActiveResearch_f().

◆ RS_GetTechByProvided()

technology_t * RS_GetTechByProvided ( const char * idProvided)

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

Parameters
[in]idProvidedUnique identifier of the object the tech is providing
Returns
The tech for the given object id or nullptr if not found

Definition at line 1622 of file cp_research.cpp.

References cgi, Com_HashKey(), DEBUG_CLIENT, hash, technology_t::hashProvidedNext, technology_t::provides, Q_strcasecmp, TECH_HASH_SIZE, and techHashProvided.

Referenced by AII_LoadOneSlotXML(), AIRFIGHT_LoadXML(), B_ParseBuildings(), BS_FillMarket_f(), BS_MarketInfoClick_f(), GAME_CP_GetItemModel(), INS_LinkTechnologies(), RS_InitTree(), UFO_GetTechnologyFromType(), and UP_UGVDescription().

◆ RS_GetTechForItem()

◆ RS_GetTechForTeam()

technology_t * RS_GetTechForTeam ( const teamDef_t * team)

Returns technology entry for a team.

Parameters
[in]teamPointer to the team definition

Definition at line 471 of file cp_research.cpp.

References ccs, cgi, ERR_DROP, teamDef_t::id, teamDef_t::idx, and lengthof.

Referenced by AC_Init_f(), AC_KillOne_f(), and AlienContainment::add().

◆ RS_GetTechIdxByName()

int RS_GetTechIdxByName ( const char * name)

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

Parameters
[in]namethe name of the tech

Definition at line 1670 of file cp_research.cpp.

References cgi, Com_HashKey(), hash, technology_t::hashNext, technology_t::id, technology_t::idx, name, Q_strcasecmp, TECH_HASH_SIZE, TECH_INVALID, and techHash.

◆ RS_GetTechWithMostScientists()

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]baseIn what base the tech should be researched.

Definition at line 1645 of file cp_research.cpp.

References technology_t::base, ccs, i, RS_GetTechByIDX(), RS_RUNNING, technology_t::scientists, and technology_t::statusResearch.

Referenced by RS_RemoveFiredScientist(), and RS_RemoveScientistsExceedingCapacity().

◆ RS_InitStartup()

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 1069 of file cp_research.cpp.

References cgi.

Referenced by CP_InitStartup().

◆ RS_InitTree()

void RS_InitTree ( const campaign_t * campaign,
bool 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]campaignThe campaign data structure
[in]loadtrue if we are loading a game, false otherwise
Todo
Add a function to reset ALL research-stati to RS_NONE; -> to be called after start of a new game.
See also
CP_CampaignInit
Todo
Implement me

Definition at line 491 of file cp_research.cpp.

References AIR_Foreach, markResearched_t::campaign, ccs, cgi, cp_campaignPool, csi, DEBUG_CLIENT, ERR_DROP, ERR_FATAL, i, aircraft_t::id, building_t::id, objDef_t::id, technology_t::id, objDef_t::idx, building_t::image, objDef_t::image, technology_t::image, INVSH_GetItemByIDX(), technology_t::mail, markResearched_t::markOnly, technology_t::markResearched, technology_t::mdl, aircraft_t::model, objDef_t::model, aircraft_t::name, building_t::name, objDef_t::name, technology_t::name, markResearched_t::numDefinitions, technology_t::provides, Q_streq, technology_t::requireAND, technology_t::requireOR, campaign_t::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_t::subject, aircraft_t::tech, TECHMAIL_MAX, techMail_t::to, and technology_t::type.

Referenced by CP_CampaignInit(), CreateBase(), TEST_F(), TEST_F(), and TEST_F().

◆ RS_IsResearched_idx()

bool RS_IsResearched_idx ( int techIdx)

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

Parameters
[in]techIdxindex of the technology.
Returns
true if the technology has been researched, otherwise (or on error) false;
See also
RS_IsResearched_ptr

Definition at line 1561 of file cp_research.cpp.

References ccs, RS_FINISH, and RS_IsValidTechIndex().

◆ RS_IsResearched_ptr()

◆ RS_IsValidTechIndex()

bool RS_IsValidTechIndex ( int techIdx)
inlinestatic

Definition at line 1543 of file cp_research.cpp.

References ccs, MAX_TECHNOLOGIES, and TECH_INVALID.

Referenced by RS_GetTechByIDX(), and RS_IsResearched_idx().

◆ RS_LoadXML()

◆ RS_MarkCollected()

◆ RS_MarkOneResearchable()

void RS_MarkOneResearchable ( technology_t * tech)

Marks one tech as researchable.

Parameters
techThe 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 107 of file cp_research.cpp.

References _, ccs, cgi, Com_sprintf(), cp_messageBuffer, DEBUG_CLIENT, DateTime::getDateAsDays(), technology_t::id, technology_t::mailSent, MAILSENT_FINISHED, MAILSENT_PROPOSAL, MSG_RESEARCH_PROPOSAL, MSO_CheckAddNewMessage(), technology_t::name, NT_RESEARCH_PROPOSED, technology_t::preDescription, technology_t::preResearchedDate, RS_GetDescription(), technology_t::statusResearchable, and technology_t::time.

Referenced by CP_AddTechAsResearchable_f(), CP_ParseResearchableCampaignStates(), RS_MarkResearchable(), and TEST_F().

◆ RS_MarkResearchable()

void RS_MarkResearchable ( const base_t * base,
bool init )

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 335 of file cp_research.cpp.

References technology_t::base, ccs, cgi, DEBUG_CLIENT, i, technology_t::id, technology_t::mailSent, MAILSENT_FINISHED, MAILSENT_PROPOSAL, RS_FINISH, RS_GetTechByIDX(), RS_MarkOneResearchable(), RS_RequirementsMet(), RS_ResearchFinish(), technology_t::statusResearch, technology_t::statusResearchable, and technology_t::time.

Referenced by B_SellOrAddItems(), CP_CampaignInit(), RS_FillTechnologyList_f(), RS_MarkResearched(), TEST_F(), and TEST_F().

◆ RS_MarkResearched()

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]techPointer to a technology_t struct.
[in]basePointer 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 762 of file cp_research.cpp.

References cgi, DEBUG_CLIENT, technology_t::id, RS_MarkResearchable(), and RS_ResearchFinish().

Referenced by RS_MarkStoryLineEventResearched(), and RS_ResearchRun().

◆ RS_MarkStoryLineEventResearched()

bool RS_MarkStoryLineEventResearched ( const char * techID)

Pick a random base to research a story line event tech

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

Definition at line 774 of file cp_research.cpp.

References B_GetNext(), RS_GetTechByID(), RS_IsResearched_ptr(), and RS_MarkResearched().

Referenced by CP_CheckCampaignEvents().

◆ RS_ParseTechnologies()

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]nameUnique id of a technology_t. This is parsed from "tech xxx" -> id=xxx
[in]textthe 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 cgi->Com_RegisterConstInt();

Definition at line 1134 of file cp_research.cpp.

References _, requirement_t::amount, ccs, cgi, Com_HashKey(), Com_Parse(), cp_campaignPool, linkedList_t::data, DEBUG_CLIENT, technology_t::description, ERR_DROP, hash, technology_t::hashNext, technology_t::hashProvidedNext, i, requirement_t::id, technology_t::id, technology_t::idx, requirements_t::links, technology_t::mail, MAX_DESCRIPTIONS, MAX_TECHLINKS, MAX_TECHNOLOGIES, techMail_t::model, name, linkedList_t::next, technologyDescriptions_t::numDescriptions, requirements_t::numLinks, technology_t::numTechMails, OBJZERO, technology_t::overallTime, technology_t::preDescription, technology_t::provides, Q_streq, redirectedTechs, technology_t::requireAND, technology_t::requireForProduction, technology_t::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, technology_t::statusResearch, technology_t::statusResearchable, Sys_Error(), technologyDescriptions_t::tech, TECH_HASH_SIZE, techHash, techHashProvided, TECHMAIL_MAX, TECHMAIL_PRE, TECHMAIL_RESEARCHED, technologyDescriptions_t::text, technology_t::time, requirement_t::type, technology_t::type, technology_t::upChapter, technology_t::upNext, technology_t::upPrev, technologyDescriptions_t::usedDescription, valid_tech_vars, and valid_techmail_vars.

Referenced by CP_ParseScriptFirst().

◆ RS_RemoveFiredScientist()

void RS_RemoveFiredScientist ( base_t * base,
Employee * employee )

Remove one scientist from research project if needed.

Parameters
[in]basePointer to base where a scientist should be removed.
[in]employeePointer to the employee that is fired.
Note
used when a scientist is fired.
This function is called before the employee is actually fired.

Definition at line 731 of file cp_research.cpp.

References cgi, Employee::chr, E_GetUnassignedEmployee(), EMPL_SCIENTIST, base_t::idx, RS_AssignScientist(), RS_GetTechWithMostScientists(), RS_RemoveScientist(), Employee::setAssigned(), and character_t::ucn.

Referenced by Employee::unassign().

◆ RS_RemoveScientist()

void RS_RemoveScientist ( technology_t * tech,
Employee * employee )

Remove a scientist from a technology.

Parameters
[in]techThe technology you want to remove the scientist from.
[in]employeeEmployee you want to remove (nullptr if you don't care which one should be removed).
See also
RS_RemoveScientist_f
RS_AssignScientist

Definition at line 695 of file cp_research.cpp.

References technology_t::base, CAP_AddCurrent(), CAP_LABSPACE, cgi, E_GetAssignedEmployee(), EMPL_SCIENTIST, RS_PAUSED, technology_t::scientists, Employee::setAssigned(), and technology_t::statusResearch.

Referenced by RS_Change_f(), RS_RemoveFiredScientist(), RS_RemoveScientistsExceedingCapacity(), and RS_StopResearch().

◆ RS_RemoveScientistsExceedingCapacity()

void RS_RemoveScientistsExceedingCapacity ( base_t * base)

Remove all exceeding scientist.

Parameters
[in,out]basePointer to base where a scientist should be removed.

Definition at line 1707 of file cp_research.cpp.

References CAP_GetFreeCapacity(), CAP_LABSPACE, CAP_SetCurrent(), RS_CountScientistsInBase(), RS_GetTechWithMostScientists(), and RS_RemoveScientist().

Referenced by CAP_CheckOverflow().

◆ RS_RequiredLinksAssign()

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 420 of file cp_research.cpp.

References ccs, cgi, linkedList_t::data, i, linkedList_t::next, requirements_t::numLinks, technology_t::redirect, redirectedTechs, technology_t::requireAND, technology_t::requireForProduction, technology_t::requireOR, RS_AssignTechLinks(), RS_GetTechByID(), and RS_GetTechByIDX().

Referenced by CP_ParseCampaignData().

◆ RS_RequirementsMet()

bool RS_RequirementsMet ( const technology_t * tech,
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]techThe technology we want to research
[in]baseIn what base to check the "collected" items etc..
Returns
true if all requirements are satisfied otherwise false.
Todo
Add support for the "delay" value.

Definition at line 151 of file cp_research.cpp.

References requirement_t::typelink_t::aircraft, AL_CountAll(), base_t::alienContainment, requirement_t::amount, B_AntimatterInBase(), B_ItemInBase(), cgi, DEBUG_CLIENT, AlienCargo::getAlive(), AlienCargo::getDead(), i, requirement_t::id, technology_t::id, requirement_t::link, requirements_t::links, requirements_t::numLinks, requirement_t::typelink_t::od, Q_streq, technology_t::requireAND, technology_t::requireOR, 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, technology_t::statusResearchable, requirement_t::typelink_t::td, requirement_t::typelink_t::tech, requirement_t::type, and US_UFOsInStorage().

Referenced by RS_CheckRequirements(), RS_FillTechnologyList_f(), RS_MarkResearchable(), and RS_ResearchRun().

◆ RS_ResearchAllowed()

bool 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 1840 of file cp_research.cpp.

References B_GetBuildingStatus(), B_IsUnderAttack, B_LAB, E_CountHired(), and EMPL_SCIENTIST.

Referenced by B_BaseInit_f(), B_BuildingOpenAfterClick_f(), RS_ResearchRun(), RS_ShowActiveResearch_f(), and TR_TransferStart().

◆ RS_ResearchFinish()

void RS_ResearchFinish ( technology_t * tech)

Sets a technology status to researched and updates the date.

Parameters
[in]techThe 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 52 of file cp_research.cpp.

References _, technology_t::announce, ccs, cgi, Com_sprintf(), cp_messageBuffer, technology_t::description, technology_t::finishedResearchEvent, technology_t::id, technology_t::mailSent, MAILSENT_FINISHED, MSG_RESEARCH_FINISHED, MSO_CheckAddNewMessage(), technology_t::name, NT_RESEARCH_COMPLETED, technology_t::preDescription, technology_t::preResearchedDate, technology_t::researchedDate, RS_FINISH, RS_GetDescription(), RS_LOGIC, RS_StopResearch(), technology_t::statusResearch, technology_t::statusResearchable, technology_t::type, UP_OpenWith(), and technologyDescriptions_t::usedDescription.

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

◆ RS_ResearchRun()

int 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
Returns
The amout of new researched technologies

Definition at line 814 of file cp_research.cpp.

References _, technology_t::base, ccs, Com_sprintf(), cp_messageBuffer, i, MSG_RESEARCH_HALTED, MSO_CheckAddNewMessage(), technology_t::name, NT_RESEARCH_HALTED, RS_GetTechByIDX(), RS_MarkResearched(), RS_RequirementsMet(), RS_ResearchAllowed(), RS_RUNNING, RS_StopResearch(), technology_t::scientists, technology_t::statusResearch, and technology_t::time.

Referenced by CP_CampaignRun(), and TEST_F().

◆ RS_ResetTechs()

void RS_ResetTechs ( void )

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

Definition at line 1083 of file cp_research.cpp.

References cgi, OBJZERO, redirectedTechs, techHash, and techHashProvided.

Referenced by CP_ResetCampaignData().

◆ RS_SaveXML()

◆ RS_ScriptSanityCheck()

bool 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 1850 of file cp_research.cpp.

References ccs, cgi, technology_t::description, i, technology_t::id, technology_t::name, technology_t::produceTime, technology_t::provides, RS_ALIEN, RS_BUILDING, RS_LOGIC, RS_NEWS, RS_TECH, technologyDescriptions_t::text, and technology_t::type.

◆ RS_StopResearch()

void RS_StopResearch ( technology_t * tech)

Stops a research (Removes scientists from it).

Parameters
[in]techThe technology that is being researched.

Definition at line 94 of file cp_research.cpp.

References RS_RemoveScientist(), and technology_t::scientists.

Referenced by B_AddToStorage(), RS_CheckRequirements(), RS_ResearchFinish(), RS_ResearchRun(), and RS_Stop_f().

Variable Documentation

◆ redirectedTechs

linkedList_t* redirectedTechs
static

Definition at line 46 of file cp_research.cpp.

Referenced by RS_ParseTechnologies(), RS_RequiredLinksAssign(), and RS_ResetTechs().

◆ techHash

◆ techHashProvided

technology_t* techHashProvided[TECH_HASH_SIZE]
static

Definition at line 44 of file cp_research.cpp.

Referenced by RS_GetTechByProvided(), RS_ParseTechnologies(), and RS_ResetTechs().

◆ valid_tech_vars

const value_t valid_tech_vars[]
static
Initial value:
= {
{"name", V_TRANSLATION_STRING, offsetof(technology_t, name), 0},
{"provides", V_HUNK_STRING, offsetof(technology_t, provides), 0},
{"event", V_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)},
{"announce", V_BOOL, offsetof(technology_t, announce), MEMBER_SIZEOF(technology_t, announce)},
{"image", V_HUNK_STRING, offsetof(technology_t, image), 0},
{"model", V_HUNK_STRING, offsetof(technology_t, mdl), 0},
{nullptr, V_NULL, 0, 0}
}
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
@ V_BOOL
Definition scripts.h:50
@ V_FLOAT
Definition scripts.h:54
@ V_TRANSLATION_STRING
Definition scripts.h:59
@ V_HUNK_STRING
Definition scripts.h:69
@ V_NULL
Definition scripts.h:49
@ V_INT
Definition scripts.h:52
#define MEMBER_SIZEOF(TYPE, MEMBER)
Definition scripts.h:34
This is the technology parsed from research.ufo.

The valid definition names in the research.ufo file.

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

Definition at line 1098 of file cp_research.cpp.

Referenced by RS_ParseTechnologies().

◆ valid_techmail_vars

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_HUNK_STRING, offsetof(techMail_t, icon), 0},
{"model", V_HUNK_STRING, offsetof(techMail_t, model), 0},
{nullptr, V_NULL, 0, 0}
}
available mails for a tech - mail and mail_pre in script files

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

Definition at line 1115 of file cp_research.cpp.

Referenced by RS_ParseTechnologies().