Freeciv-3.2
Loading...
Searching...
No Matches
research.h
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12****************************************************************************/
13#ifndef FC__RESEARCH_H
14#define FC__RESEARCH_H
15
16#ifdef __cplusplus
17extern "C" {
18#endif /* __cplusplus */
19
20/* utility */
21#include "iterator.h"
22#include "support.h"
23
24/* common */
25#include "fc_types.h"
26#include "tech.h"
27
28/* TECH_KNOWN is self-explanatory, TECH_PREREQS_KNOWN are those for which all
29 * requirements are fulfilled; all others (including those which can never
30 * be reached) are TECH_UNKNOWN. */
31#define SPECENUM_NAME tech_state
32/* TECH_UNKNOWN must be 0 as the code does no special initialisation after
33 * memset(0), See researches_init(). */
34#define SPECENUM_VALUE0 TECH_UNKNOWN
35#define SPECENUM_VALUE1 TECH_PREREQS_KNOWN
36#define SPECENUM_VALUE2 TECH_KNOWN
37#include "specenum_gen.h"
38
39struct research {
40 /* The number of techs and future techs the player has
41 * researched/acquired. */
43
44 /* Invention being researched in. Valid values for researching are:
45 * - any existing tech (not A_NONE)
46 * - A_FUTURE
47 * - A_UNSET (indicates need for choosing new research)
48 * For enemies, A_UNKNOWN is sent to the client, but not on server.
49 *
50 * bulbs_researched tracks how many bulbs have been accumulated toward
51 * this research target. */
54
55 /* If the player changes their research target in a turn, they lose some
56 * or all of the bulbs they've accumulated toward that target. We save
57 * the original info from the start of the turn so that if they change
58 * back they will get the bulbs back.
59 *
60 * Has the same values as researching, plus A_UNKNOWN used between turns
61 * (not -1 anymore) for savegames. */
64
65 /* For this amount of bulbs, changing targets this turn
66 * may be done without penalty. */
68
70 /* One of TECH_UNKNOWN, TECH_KNOWN or TECH_PREREQS_KNOWN. */
72
73 /* Following fields are cached values. They are updated by
74 * research_update()). */
80
81 /* Tech goal (similar to worklists; when one tech is researched the next
82 * tech toward the goal will be chosen). May be A_NONE. */
84
85 /*
86 * Cached values. Updated by research_update().
87 */
89
90 union {
91 /* Add server side when needed */
92
93 struct {
94 /* Only used at the client (the server is omniscient; ./client/). */
95
99 };
100};
101
102/* Common functions. */
103void researches_init(void);
104void researches_free(void);
105
106int research_number(const struct research *presearch);
107const char *research_rule_name(const struct research *presearch);
108const char *research_name_translation(const struct research *presearch);
109int research_pretty_name(const struct research *presearch, char *buf,
110 size_t buf_len);
111
112struct research *research_by_number(int number);
113struct research *research_get(const struct player *pplayer);
114
115const char *research_advance_rule_name(const struct research *presearch,
116 Tech_type_id tech);
117const char *
119 Tech_type_id tech);
120
121/* Ancillary routines */
123
125 Tech_type_id tech);
127 Tech_type_id tech,
128 enum tech_state value);
130 const Tech_type_id tech);
132 const Tech_type_id tech,
133 bool allow_holes);
134
136 Tech_type_id goal);
138 Tech_type_id goal);
140 Tech_type_id goal);
141bool research_goal_tech_req(const struct research *presearch,
142 Tech_type_id goal, Tech_type_id tech);
143
145 Tech_type_id tech, bool loss_value);
146
147int player_tech_upkeep(const struct player *pplayer);
148
149/* Iterating utilities. */
150struct research_iter;
151
152size_t research_iter_sizeof(void);
153struct iterator *research_iter_init(struct research_iter *it);
154
155#define researches_iterate(_presearch) \
156 generic_iterate(struct research_iter, struct research *, \
157 _presearch, research_iter_sizeof, research_iter_init)
158#define researches_iterate_end generic_iterate_end
159
161
162size_t research_player_iter_sizeof(void);
164 const struct research *presearch);
165
166#define research_players_iterate(_presearch, _pplayer) \
167 generic_iterate(struct research_player_iter, struct player *, _pplayer, \
168 research_player_iter_sizeof, research_player_iter_init, \
169 _presearch)
170#define research_players_iterate_end generic_iterate_end
171
172int research_count(void);
173
175
176bool research_future_next(const struct research *presearch);
177
178#ifdef __cplusplus
179}
180#endif /* __cplusplus */
181
182#endif /* FC__RESEARCH_H */
char * incite_cost
Definition comments.c:75
int Tech_type_id
Definition fc_types.h:377
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Definition research.c:750
bool research_invention_reachable(const struct research *presearch, const Tech_type_id tech)
Definition research.c:668
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
Definition research.c:807
const char * research_name_translation(const struct research *presearch)
Definition research.c:156
enum tech_state research_invention_set(struct research *presearch, Tech_type_id tech, enum tech_state value)
Definition research.c:637
struct research * research_by_number(int number)
Definition research.c:118
const char * research_advance_rule_name(const struct research *presearch, Tech_type_id tech)
Definition research.c:240
int player_tech_upkeep(const struct player *pplayer)
Definition research.c:1050
bool research_future_next(const struct research *presearch)
Definition research.c:1362
size_t research_iter_sizeof(void)
Definition research.c:1137
void researches_init(void)
Definition research.c:64
int research_count(void)
Definition research.c:1328
int research_number(const struct research *presearch)
Definition research.c:109
int research_goal_bulbs_required(const struct research *presearch, Tech_type_id goal)
Definition research.c:772
const char * research_advance_name_translation(const struct research *presearch, Tech_type_id tech)
Definition research.c:273
int research_total_bulbs_required(const struct research *presearch, Tech_type_id tech, bool loss_value)
Definition research.c:868
struct iterator * research_iter_init(struct research_iter *it)
Definition research.c:1205
int recalculate_techs_researched(const struct research *presearch)
Definition research.c:1345
const char * research_rule_name(const struct research *presearch)
Definition research.c:143
struct research * research_get(const struct player *pplayer)
Definition research.c:128
void researches_free(void)
Definition research.c:100
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Definition research.c:619
Tech_type_id research_goal_step(const struct research *presearch, Tech_type_id goal)
Definition research.c:720
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Definition research.c:693
size_t research_player_iter_sizeof(void)
Definition research.c:1227
struct iterator * research_player_iter_init(struct research_player_iter *it, const struct research *presearch)
Definition research.c:1297
void research_update(struct research *presearch)
Definition research.c:501
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
Definition research.c:169
enum tech_state state
Definition research.h:71
Tech_type_id researching
Definition research.h:52
int future_tech
Definition research.h:42
Tech_type_id tech_goal
Definition research.h:83
struct research::@76::@78 client
int bulbs_researching_saved
Definition research.h:63
struct research::research_invention inventions[A_ARRAY_SIZE]
Tech_type_id researching_saved
Definition research.h:62
int techs_researched
Definition research.h:42
int total_bulbs_prod
Definition research.h:97
int researching_cost
Definition research.h:96
int bulbs_researched
Definition research.h:53
int free_bulbs
Definition research.h:67
int num_known_tech_with_flag[TF_COUNT]
Definition research.h:88
#define A_ARRAY_SIZE
Definition tech.h:47