UFO: Alien Invasion
Doxygen documentation generating
cp_research.h
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2023 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 #include "../../DateTime.h"
29 
30 #define MAX_RESEARCHLIST 32
31 #define MAX_TECHNOLOGIES 256
32 #define MAX_TECHLINKS 16
33 #define MAX_DESCRIPTIONS 8
35 #define TECH_INVALID -1
37 #define ANTIMATTER_ITEM_ID "antimatter"
38 
40 typedef enum researchStatus_s {
46 
48 typedef enum researchType_s {
60 
61 typedef enum requirementType_s {
72 
73 typedef struct requirement_s {
75  char* id;
76  union typelink_t {
77  const struct technology_s* tech;
78  const struct objDef_s* od;
79  const struct teamDef_s* td;
80  const struct aircraft_s* aircraft;
81  } link;
82  int amount;
83  int collected;
85 
86 typedef struct requirements_s {
87  int numLinks;
90 
92 typedef struct markResearched_s {
93  bool markOnly[MAX_CAMPAIGNS];
94  char* campaign[MAX_CAMPAIGNS];
97 
99 typedef enum {
105 
110 typedef struct techMail_s {
111  char* from;
112  const char* to;
113  const char* subject;
116  const char* date;
117  const char* icon;
118  const char* model;
119  bool read;
120 } techMail_t;
121 
122 typedef enum {
129 
130 typedef struct technologyDescriptions_s {
134  char* text[MAX_DESCRIPTIONS];
135  char* tech[MAX_DESCRIPTIONS];
137 
139 typedef struct technology_s {
140  char* id;
141  int idx;
142  char* name;
147  struct technology_s* redirect;
156  char* provides;
158  float overallTime, time;
161  int delay;
167  bool announce;
169  struct base_s* base;
172  char* image;
175  char* mdl;
186  class DateTime preResearchedDate;
187  class DateTime researchedDate;
191  /* Pedia info */
192  struct pediaChapter_s* upChapter;
193  struct technology_s* upPrev;
194  struct technology_s* upNext;
199  struct technology_s* hashNext;
200  struct technology_s* hashProvidedNext;
201 } technology_t;
202 
203 #define RS_Collected_(tech) ((tech)->statusCollected)
204 
205 void RS_InitStartup(void);
206 void RS_ResetTechs(void);
207 int RS_ResearchRun(void);
208 void RS_ParseTechnologies(const char* name, const char** text);
209 bool RS_IsResearched_idx(int techIdx);
210 bool RS_IsResearched_ptr(const technology_t* tech);
211 
214 void RS_AddObjectTechs(void);
215 void RS_RequiredLinksAssign(void);
216 void RS_InitTree(const struct campaign_s* campaign, bool load);
218 void RS_MarkCollected(technology_t* tech) __attribute__((nonnull));
219 void RS_MarkResearchable(const struct base_s* base, bool init = false);
220 bool RS_MarkStoryLineEventResearched(const char* techID);
221 void RS_ResearchFinish(technology_t* tech);
222 void RS_StopResearch(technology_t* tech);
224 
225 void RS_AssignScientist(technology_t* tech, struct base_s* base, Employee* employee = nullptr);
226 void RS_RemoveScientist(technology_t* tech, Employee* employee);
227 void RS_RemoveFiredScientist(struct base_s* base, Employee* employee);
228 void RS_RemoveScientistsExceedingCapacity(struct base_s* base);
229 
230 technology_t* RS_GetTechByID(const char* id);
231 technology_t* RS_GetTechByProvided(const char* idProvided);
232 technology_t* RS_GetTechByIDX(int tech_idx);
233 technology_t* RS_GetTechWithMostScientists(const struct base_s* base);
234 int RS_GetTechIdxByName(const char* name);
235 int RS_CountScientistsInBase(const struct base_s* base);
236 bool RS_ScriptSanityCheck(void);
237 
238 /* UFOpaedia function - but needs technology_t */
239 void UP_AircraftDescription(const technology_t* t);
240 void UP_UGVDescription(const struct ugv_s* ugvType);
241 
242 void RS_CheckRequirements(void);
243 bool RS_RequirementsMet(const technology_t* tech, const struct base_s* base);
technology_t * RS_GetTechByID(const char *id)
return a pointer to the technology identified by given id string
Class describing a point of time.
Definition: DateTime.h:30
void RS_AddObjectTechs(void)
struct technology_s * redirect
Definition: cp_research.h:147
struct technology_s * hashProvidedNext
Definition: cp_research.h:200
#define MAX_CAMPAIGNS
Definition: cp_campaign.h:31
struct technology_s * upNext
Definition: cp_research.h:194
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
The status of a research (per tech)
Definition: cp_research.h:40
requirements_t requireAND
Definition: cp_research.h:150
struct base_s * base
Definition: cp_research.h:169
void RS_MarkCollected(technology_t *tech) __attribute__((nonnull))
Marks a give technology as collected.
techMailType_t
Types for tech mail definitions - see tech->mail[].
Definition: cp_research.h:99
void RS_RequiredLinksAssign(void)
Assign Link pointers to all required techs/items/etc...
requirements_t requireForProduction
Definition: cp_research.h:181
#define MAX_DESCRIPTIONS
Definition: cp_research.h:33
#define __attribute__(x)
Definition: cxx.h:37
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)
char * from
Definition: cp_research.h:111
mailSentType_t mailSent
Definition: cp_research.h:180
#define MAX_TECHLINKS
Definition: cp_research.h:32
markResearched_t markResearched
Definition: cp_research.h:189
struct technology_s * upPrev
Definition: cp_research.h:193
char * finishedResearchEvent
Definition: cp_research.h:166
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.
technologyDescriptions_t description
Definition: cp_research.h:143
const char * subject
Definition: cp_research.h:113
struct pediaChapter_s * upChapter
Definition: cp_research.h:192
bool RS_MarkStoryLineEventResearched(const char *techID)
mailSentType_t
Definition: cp_research.h:122
researchType_t type
Definition: cp_research.h:145
char * image
Definition: cp_research.h:172
bool RS_RequirementsMet(const technology_t *tech, const struct base_s *base)
void RS_InitTree(const struct campaign_s *campaign, bool load)
technologyDescriptions_t preDescription
Definition: cp_research.h:144
const char * date
Definition: cp_research.h:116
bool RS_IsResearched_idx(int techIdx)
Checks if the technology (tech-index) has been researched.
const char * RS_GetDescription(technologyDescriptions_t *desc)
returns the currently used description for a technology.
void RS_AssignScientist(technology_t *tech, struct base_s *base, Employee *employee=nullptr)
void RS_StopResearch(technology_t *tech)
Stops a research (Removes scientists from it)
Definition: cp_research.cpp:94
int RS_CountScientistsInBase(const struct base_s *base)
char * provides
Definition: cp_research.h:156
void RS_CheckRequirements(void)
Checks if running researches still meet their requirements.
requirementType_t type
Definition: cp_research.h:74
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.
This is the technology parsed from research.ufo.
Definition: cp_research.h:139
const char * icon
Definition: cp_research.h:117
void RS_InitStartup(void)
This is more or less the initial Bind some of the functions in this file to console-commands that you...
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
void UP_UGVDescription(const struct ugv_s *ugvType)
technology_t * RS_GetTechForItem(const objDef_t *item)
Returns technology entry for an item.
available mails for a tech - mail and mail_pre in script files
Definition: cp_research.h:110
Defines all attributes of objects used in the inventory.
Definition: inv_shared.h:264
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...
const char * to
Definition: cp_research.h:112
void RS_RemoveFiredScientist(struct base_s *base, Employee *employee)
researchType_t
Types of research topics.
Definition: cp_research.h:48
bool statusResearchable
Definition: cp_research.h:177
technology_t * RS_GetTechByProvided(const char *idProvided)
returns a pointer to the item tech (as listed in "provides")
int RS_ResearchRun(void)
Checks the research status.
void RS_MarkOneResearchable(technology_t *tech)
Marks one tech as researchable.
requirements_t requireOR
Definition: cp_research.h:151
researchStatus_t statusResearch
Definition: cp_research.h:165
technology_t * RS_GetTechWithMostScientists(const struct base_s *base)
Searches for the technology that has the most scientists assigned in a given base.
requirementType_t
Definition: cp_research.h:61
void RS_RemoveScientistsExceedingCapacity(struct base_s *base)
const char * model
Definition: cp_research.h:118
struct technology_s * hashNext
Definition: cp_research.h:199
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:52
bool statusCollected
Definition: cp_research.h:152