UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cp_research.h
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #pragma once
27 
28 #define MAX_RESEARCHLIST 32
29 #define MAX_TECHNOLOGIES 256
30 #define MAX_TECHLINKS 16
31 #define MAX_DESCRIPTIONS 8
33 #define TECH_INVALID -1
35 #define ANTIMATTER_ITEM_ID "antimatter"
36 
38 typedef enum researchStatus_s {
44 
46 typedef enum researchType_s {
58 
59 typedef enum requirementType_s {
70 
71 typedef struct requirement_s {
73  char* id;
74  union typelink_t {
75  const struct technology_s* tech;
76  const struct objDef_s* od;
77  const struct teamDef_s* td;
78  const struct aircraft_s* aircraft;
79  } link;
80  int amount;
81  int collected;
83 
84 typedef struct requirements_s {
85  int numLinks;
88 
90 typedef struct markResearched_s {
95 
97 typedef enum {
103 
108 typedef struct techMail_s {
109  char* from;
110  const char* to;
111  const char* subject;
114  const char* date;
115  const char* icon;
116  const char* model;
117  bool read;
118 } techMail_t;
119 
120 typedef enum {
127 
128 typedef struct technologyDescriptions_s {
135 
137 typedef struct technology_s {
138  char* id;
139  int idx;
140  char* name;
154  char* provides;
156  float overallTime, time;
159  int delay;
165  bool announce;
167  struct base_s* base;
170  char* image;
173  char* mdl;
189  /* Pedia info */
199 } technology_t;
200 
201 #define RS_Collected_(tech) ((tech)->statusCollected)
202 
203 void RS_InitStartup(void);
204 void RS_ResetTechs(void);
205 int RS_ResearchRun(void);
206 void RS_ParseTechnologies(const char* name, const char** text);
207 bool RS_IsResearched_idx(int techIdx);
208 bool RS_IsResearched_ptr(const technology_t* tech);
209 
212 void RS_AddObjectTechs(void);
213 void RS_RequiredLinksAssign(void);
214 void RS_InitTree(const struct campaign_s* campaign, bool load);
216 void RS_MarkCollected(technology_t* tech) __attribute__((nonnull));
217 void RS_MarkResearchable(const struct base_s* base, bool init = false);
218 bool RS_MarkStoryLineEventResearched(const char* techID);
219 void RS_ResearchFinish(technology_t* tech);
220 void RS_StopResearch(technology_t* tech);
222 
223 void RS_AssignScientist(technology_t* tech, struct base_s* base, Employee* employee = nullptr);
224 void RS_RemoveScientist(technology_t* tech, Employee* employee);
225 void RS_RemoveFiredScientist(struct base_s* base, Employee* employee);
227 
228 technology_t* RS_GetTechByID(const char* id);
229 technology_t* RS_GetTechByProvided(const char* idProvided);
230 technology_t* RS_GetTechByIDX(int tech_idx);
232 int RS_GetTechIdxByName(const char* name);
233 int RS_CountScientistsInBase(const struct base_s* base);
234 bool RS_ScriptSanityCheck(void);
235 
236 /* UFOpaedia function - but needs technology_t */
237 void UP_AircraftDescription(const technology_t* t);
238 void UP_UGVDescription(const struct ugv_s* ugvType);
239 
240 void RS_CheckRequirements(void);
241 bool RS_RequirementsMet(const technology_t* tech, const struct base_s* base);
researchStatus_s
The status of a research (per tech)
Definition: cp_research.h:38
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
struct technology_s * redirect
Definition: cp_research.h:145
void RS_AddObjectTechs(void)
char * from
Definition: cp_research.h:109
requirement_t links[MAX_TECHLINKS]
Definition: cp_research.h:86
#define MAX_CAMPAIGNS
Definition: cp_campaign.h:31
date_t researchedDate
Definition: cp_research.h:185
available mails for a tech - mail and mail_pre in script files
Definition: cp_research.h:108
bool statusResearchable
Definition: cp_research.h:175
struct techMail_s techMail_t
available mails for a tech - mail and mail_pre in script files
void RS_RemoveScientist(technology_t *tech, Employee *employee)
Remove a scientist from a technology.
technology_t * RS_GetTechByIDX(int tech_idx)
Returns the technology pointer for a tech index. You can use this instead of "&ccs.technologies[techIdx]" to avoid having to check valid indices.
researchStatus_t statusResearch
Definition: cp_research.h:163
date_t preResearchedDate
Definition: cp_research.h:184
Defines a type of UGV/Robot.
Definition: chr_shared.h:234
researchType_t type
Definition: cp_research.h:143
void RS_MarkCollected(technology_t *tech) __attribute__((nonnull))
Marks a give technology as collected.
requirementType_t type
Definition: cp_research.h:72
const char * date
Definition: cp_research.h:114
techMailType_t
Types for tech mail definitions - see tech->mail[].
Definition: cp_research.h:97
struct base_s * base
Definition: cp_research.h:167
void RS_RequiredLinksAssign(void)
Assign Link pointers to all required techs/items/etc...
requirements_t requireAND
Definition: cp_research.h:148
bool markOnly[MAX_CAMPAIGNS]
Definition: cp_research.h:91
const char * icon
Definition: cp_research.h:115
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
#define MAX_DESCRIPTIONS
Definition: cp_research.h:31
#define __attribute__(x)
Definition: cxx.h:37
const char * model
Definition: cp_research.h:116
int RS_GetTechIdxByName(const char *name)
Returns the index (idx) of a "tech" entry given it's name.
void RS_MarkResearchable(const struct base_s *base, bool init=false)
struct pediaChapter_s * upChapter
Definition: cp_research.h:190
requirements_t requireForProduction
Definition: cp_research.h:179
A base with all it's data.
Definition: cp_base.h:84
char * provides
Definition: cp_research.h:154
#define MAX_TECHLINKS
Definition: cp_research.h:30
struct requirement_s requirement_t
researchType_s
Types of research topics.
Definition: cp_research.h:46
char * campaign[MAX_CAMPAIGNS]
Definition: cp_research.h:92
void UP_AircraftDescription(const technology_t *t)
Prints the UFOpaedia description for aircraft.
bool RS_IsResearched_ptr(const technology_t *tech)
Checks whether an item is already researched.
mailSentType_t mailSent
Definition: cp_research.h:178
markResearched_t markResearched
Definition: cp_research.h:187
struct technology_s technology_t
This is the technology parsed from research.ufo.
bool RS_MarkStoryLineEventResearched(const char *techID)
mailSentType_t
Definition: cp_research.h:120
bool RS_RequirementsMet(const technology_t *tech, const struct base_s *base)
This is the technology parsed from research.ufo.
Definition: cp_research.h:137
union requirement_s::typelink_t link
struct technology_s * upNext
Definition: cp_research.h:192
Engine-side time information in the game.
Definition: common.h:290
void RS_InitTree(const struct campaign_s *campaign, bool load)
char * finishedResearchEvent
Definition: cp_research.h:164
bool RS_IsResearched_idx(int techIdx)
Checks if the technology (tech-index) has been researched.
struct technology_s * hashProvidedNext
Definition: cp_research.h:198
const char * RS_GetDescription(technologyDescriptions_t *desc)
returns the currently used description for a technology.
enum researchType_s researchType_t
Types of research topics.
void RS_AssignScientist(technology_t *tech, struct base_s *base, Employee *employee=nullptr)
Assigns scientist to the selected research-project.
const char * subject
Definition: cp_research.h:111
void RS_StopResearch(technology_t *tech)
Stops a research (Removes scientists from it)
Definition: cp_research.cpp:93
int RS_CountScientistsInBase(const struct base_s *base)
void RS_CheckRequirements(void)
Checks if running researches still meet their requirements.
requirementType_s
Definition: cp_research.h:59
technology_t * RS_GetTechForTeam(const teamDef_t *team)
Returns technology entry for a team.
void RS_ResetTechs(void)
This is called everytime RS_ParseTechnologies is called - to prevent cyclic hash tables.
enum researchStatus_s researchStatus_t
The status of a research (per tech)
struct technologyDescriptions_s technologyDescriptions_t
void RS_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
char * image
Definition: cp_research.h:170
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
enum requirementType_s requirementType_t
char * tech[MAX_DESCRIPTIONS]
Definition: cp_research.h:133
void UP_UGVDescription(const struct ugv_s *ugvType)
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
bool statusCollected
Definition: cp_research.h:150
struct markResearched_s markResearched_t
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 technologi...
struct technology_s * upPrev
Definition: cp_research.h:191
void RS_RemoveFiredScientist(struct base_s *base, Employee *employee)
Remove one scientist from research project if needed.
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
float overallTime
Definition: cp_research.h:156
int RS_ResearchRun(void)
Checks the research status.
An aircraft with all it's data.
Definition: cp_aircraft.h:114
requirements_t requireOR
Definition: cp_research.h:149
void RS_MarkOneResearchable(technology_t *tech)
Marks one tech as researchable.
struct requirements_s requirements_t
const char * to
Definition: cp_research.h:110
technologyDescriptions_t description
Definition: cp_research.h:141
technology_t * RS_GetTechWithMostScientists(const struct base_s *base)
Searches for the technology that has the most scientists assigned in a given base.
char * text[MAX_DESCRIPTIONS]
Definition: cp_research.h:132
void RS_RemoveScientistsExceedingCapacity(struct base_s *base)
Remove all exceeding scientist.
struct technology_s * hashNext
Definition: cp_research.h:197
technologyDescriptions_t preDescription
Definition: cp_research.h:142
bool RS_ScriptSanityCheck(void)
Checks the parsed tech data for errors.
void RS_ResearchFinish(technology_t *tech)
Sets a technology status to researched and updates the date.
Definition: cp_research.cpp:51
techMail_t mail[TECHMAIL_MAX]
Definition: cp_research.h:194