Freeciv-3.3: /fast/freeciv/nightly/main/common/tech.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
tech.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
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
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18#include <stdlib.h> /* exit */
19#include <string.h>
20#include <math.h>
21
22/* utility */
23#include "fcintl.h"
24#include "iterator.h"
25#include "log.h"
26#include "mem.h" /* free */
27#include "shared.h" /* ARRAY_SIZE */
28#include "string_vector.h"
29#include "support.h"
30
31/* common */
32#include "game.h"
33#include "research.h"
34
35#include "tech.h"
36
37
38 struct advance_req_iter {
39 struct iterator base;
40 bv_techs done;
41 const struct advance *array[A_LAST];
42 const struct advance **current, **end;
43};
44#define ADVANCE_REQ_ITER(it) ((struct advance_req_iter *) it)
45
46 struct advance_root_req_iter {
47 struct iterator base;
48 bv_techs done, rootdone;
49 const struct advance *array[A_LAST];
50 const struct advance **current, **end;
51};
52#define ADVANCE_ROOT_REQ_ITER(it) ((struct advance_root_req_iter *) it)
53
54/* the advances array is now setup in:
55 * server/ruleset.c (for the server)
56 * client/packhand.c (for the client)
57 */
58 struct advance advances[A_ARRAY_SIZE];
59
60 struct tech_class tech_classes[MAX_NUM_TECH_CLASSES];
61
62 static struct user_flag user_tech_flags[MAX_NUM_USER_TECH_FLAGS];
63
64/**********************************************************************/
67 const struct advance *advance_array_last(void)
68{
69 if (game.control.num_tech_types > 0) {
70 return &advances[game.control.num_tech_types - 1];
71 }
72 return NULL;
73}
74
75/**********************************************************************/
78 Tech_type_id advance_count_real(void)
79{
80 return game.control.num_tech_types;
81}
82
83/**********************************************************************/
89 Tech_type_id advance_index(const struct advance *padvance)
90{
91 fc_assert_ret_val(NULL != padvance, -1);
92 return padvance - advances;
93}
94
95/**********************************************************************/
98 Tech_type_id advance_number(const struct advance *padvance)
99{
100 fc_assert_ret_val(NULL != padvance, -1);
101 return padvance->item_number;
102}
103
104/**********************************************************************/
107 struct advance *advance_by_number(const Tech_type_id atype)
108{
109 if (atype != A_FUTURE
110 && (atype < 0 || atype >= game.control.num_tech_types)) {
111 /* This isn't an error; some callers depend on it. */
112 return NULL;
113 }
114
115 return &advances[atype];
116}
117
118/**********************************************************************/
121 Tech_type_id advance_required(const Tech_type_id tech,
122 enum tech_req require)
123{
124 fc_assert_ret_val(require >= 0 && require < AR_SIZE, -1);
125 fc_assert_ret_val(tech >= A_NONE && tech < A_LAST, -1);
126 if (A_NEVER == advances[tech].require[require]) {
127 /* out of range */
128 return A_LAST;
129 }
130 return advance_number(advances[tech].require[require]);
131}
132
133/**********************************************************************/
136 struct advance *advance_requires(const struct advance *padvance,
137 enum tech_req require)
138{
139 fc_assert_ret_val(require >= 0 && require < AR_SIZE, NULL);
140 fc_assert_ret_val(NULL != padvance, NULL);
141 return padvance->require[require];
142}
143
144/**********************************************************************/
152 struct advance *valid_advance(struct advance *padvance)
153{
154 if (padvance == NULL) {
155 return NULL;
156 }
157
158 if (padvance->item_number == A_FUTURE) {
159 return padvance;
160 }
161
162 if (A_NEVER == padvance->require[AR_ONE]
163 || A_NEVER == padvance->require[AR_TWO]) {
164 return NULL;
165 }
166
167 return padvance;
168}
169
170/**********************************************************************/
176 struct advance *valid_advance_by_number(const Tech_type_id id)
177{
178 return valid_advance(advance_by_number(id));
179}
180
181/**********************************************************************/
185 struct advance *advance_by_translated_name(const char *name)
186{
187 advance_iterate_all(padvance) {
188 if (0 == strcmp(advance_name_translation(padvance), name)) {
189 return padvance;
190 }
191 } advance_iterate_all_end;
192
193 return NULL;
194}
195
196/**********************************************************************/
200 struct advance *advance_by_rule_name(const char *name)
201{
202 const char *qname = Qn_(name);
203
204 advance_iterate_all(padvance) {
205 if (0 == fc_strcasecmp(advance_rule_name(padvance), qname)) {
206 return padvance;
207 }
208 } advance_iterate_all_end;
209
210 return NULL;
211}
212
213/**********************************************************************/
216 bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
217{
218 fc_assert_ret_val(tech_flag_id_is_valid(flag), FALSE);
219 return BV_ISSET(advance_by_number(tech)->flags, flag);
220}
221
222/**********************************************************************/
225 void techs_precalc_data(void)
226{
227 fc_assert_msg(tech_cost_style_is_valid(game.info.tech_cost_style),
228 "Invalid tech_cost_style %d", game.info.tech_cost_style);
229
230 advance_iterate(padvance) {
231 int num_reqs = 0;
232 bool min_req = TRUE;
233
234 advance_req_iterate(padvance, preq) {
235 (void) preq; /* Compiler wants us to do something with 'preq'. */
236 num_reqs++;
237 } advance_req_iterate_end;
238 padvance->num_reqs = num_reqs;
239
240 switch (game.info.tech_cost_style) {
241 case TECH_COST_CIV1CIV2:
242 case TECH_COST_LINEAR:
243 padvance->cost = game.info.base_tech_cost * num_reqs;
244 break;
245 case TECH_COST_CLASSIC_PRESET:
246 if (-1 != padvance->cost) {
247 min_req = FALSE;
248 break;
249 }
250 fc__fallthrough; /* No break. */
251 case TECH_COST_CLASSIC:
252 padvance->cost = game.info.base_tech_cost * (1.0 + num_reqs)
253 * sqrt(1.0 + num_reqs) / 2;
254 break;
255 case TECH_COST_EXPERIMENTAL_PRESET:
256 if (-1 != padvance->cost) {
257 min_req = FALSE;
258 break;
259 }
260 fc__fallthrough; /* No break. */
261 case TECH_COST_EXPERIMENTAL:
262 padvance->cost = game.info.base_tech_cost * ((num_reqs) * (num_reqs)
263 / (1 + sqrt(sqrt(num_reqs + 1))) - 0.5);
264 break;
265 }
266
267 if (min_req && padvance->cost < game.info.min_tech_cost) {
268 padvance->cost = game.info.min_tech_cost;
269 }
270
271 /* Class cost */
272 if (padvance->tclass != NULL) {
273 padvance->cost = padvance->cost * padvance->tclass->cost_pct / 100;
274 }
275 } advance_iterate_end;
276}
277
278/**********************************************************************/
281 bool is_future_tech(Tech_type_id tech)
282{
283 return tech == A_FUTURE;
284}
285
286/**********************************************************************/
290 bool is_regular_advance(struct advance *padvance)
291{
292 return valid_advance(padvance) != nullptr
293 && padvance->item_number != A_FUTURE;
294}
295
296/**********************************************************************/
300 const char *advance_name_translation(const struct advance *padvance)
301{
302 return name_translation_get(&padvance->name);
303}
304
305/**********************************************************************/
309 const char *advance_rule_name(const struct advance *padvance)
310{
311 return rule_name_get(&padvance->name);
312}
313
314/**********************************************************************/
317 void tech_classes_init(void)
318{
319 int i;
320
321 for (i = 0; i < MAX_NUM_TECH_CLASSES; i++) {
322 tech_classes[i].idx = i;
323 tech_classes[i].ruledit_disabled = FALSE;
324 }
325}
326
327/**********************************************************************/
330 struct tech_class *tech_class_by_number(const int idx)
331{
332 if (idx < 0 || idx >= game.control.num_tech_classes) {
333 return NULL;
334 }
335
336 return &tech_classes[idx];
337}
338
339/**********************************************************************/
343 const char *tech_class_name_translation(const struct tech_class *ptclass)
344{
345 return name_translation_get(&ptclass->name);
346}
347
348/**********************************************************************/
352 const char *tech_class_rule_name(const struct tech_class *ptclass)
353{
354 return rule_name_get(&ptclass->name);
355}
356
357/**********************************************************************/
361 struct tech_class *tech_class_by_rule_name(const char *name)
362{
363 const char *qname = Qn_(name);
364 int i;
365
366 for (i = 0; i < game.control.num_tech_classes; i++) {
367 struct tech_class *ptclass = tech_class_by_number(i);
368
369 if (!fc_strcasecmp(tech_class_rule_name(ptclass), qname)) {
370 return ptclass;
371 }
372 }
373
374 return NULL;
375}
376
377/**********************************************************************/
380 void user_tech_flags_init(void)
381{
382 int i;
383
384 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
385 user_flag_init(&user_tech_flags[i]);
386 }
387}
388
389/**********************************************************************/
392 void user_tech_flags_free(void)
393{
394 int i;
395
396 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
397 user_flag_free(&user_tech_flags[i]);
398 }
399}
400
401/**********************************************************************/
404 void set_user_tech_flag_name(enum tech_flag_id id, const char *name,
405 const char *helptxt)
406{
407 int tfid = id - TECH_USER_1;
408
409 fc_assert_ret(id >= TECH_USER_1 && id <= TECH_USER_LAST);
410
411 if (user_tech_flags[tfid].name != NULL) {
412 FC_FREE(user_tech_flags[tfid].name);
413 user_tech_flags[tfid].name = NULL;
414 }
415
416 if (name && name[0] != '\0') {
417 user_tech_flags[tfid].name = fc_strdup(name);
418 }
419
420 if (user_tech_flags[tfid].helptxt != NULL) {
421 FC_FREE(user_tech_flags[tfid].helptxt);
422 user_tech_flags[tfid].helptxt = NULL;
423 }
424
425 if (helptxt && helptxt[0] != '\0') {
426 user_tech_flags[tfid].helptxt = fc_strdup(helptxt);
427 }
428}
429
430/**********************************************************************/
433 const char *tech_flag_id_name_cb(enum tech_flag_id flag)
434{
435 if (flag < TECH_USER_1 || flag > TECH_USER_LAST) {
436 return NULL;
437 }
438
439 return user_tech_flags[flag-TECH_USER_1].name;
440}
441
442/**********************************************************************/
445 const char *tech_flag_helptxt(enum tech_flag_id id)
446{
447 fc_assert(id >= TECH_USER_1 && id <= TECH_USER_LAST);
448
449 return user_tech_flags[id - TECH_USER_1].helptxt;
450}
451
452/**********************************************************************/
460 bool techs_have_fixed_costs(void)
461{
462 return (game.info.tech_leakage == TECH_LEAKAGE_NONE
463 && game.info.tech_cost_style != TECH_COST_CIV1CIV2);
464}
465
466/**********************************************************************/
469 void techs_init(void)
470{
471 struct advance *a_none = &advances[A_NONE];
472 struct advance *a_future = &advances[A_FUTURE];
473 int i;
474
475 memset(advances, 0, sizeof(advances));
476 for (i = 0; i < ARRAY_SIZE(advances); i++) {
477 advances[i].item_number = i;
478 advances[i].ruledit_dlg = NULL;
479 advances[i].cost = -1;
480 advances[i].inherited_root_req = FALSE;
481 advances[i].tclass = 0;
482
483 requirement_vector_init(&(advances[i].research_reqs));
484 }
485
486 /* Initialize dummy tech A_NONE */
487 /* TRANS: "None" tech */
488 name_set(&a_none->name, NULL, N_("?tech:None"));
489 a_none->require[AR_ONE] = a_none;
490 a_none->require[AR_TWO] = a_none;
491 a_none->require[AR_ROOT] = A_NEVER;
492
493 name_set(&a_future->name, NULL, "Future");
494 a_future->require[AR_ONE] = A_NEVER;
495 a_future->require[AR_TWO] = A_NEVER;
496 a_future->require[AR_ROOT] = A_NEVER;
497}
498
499/**********************************************************************/
502 static void tech_free(Tech_type_id tech)
503{
504 struct advance *p = &advances[tech];
505
506 if (NULL != p->helptext) {
507 strvec_destroy(p->helptext);
508 p->helptext = NULL;
509 }
510
511 if (p->bonus_message) {
512 free(p->bonus_message);
513 p->bonus_message = NULL;
514 }
515}
516
517/**********************************************************************/
520 void techs_free(void)
521{
522 int i;
523
524 advance_index_iterate(A_FIRST, adv_idx) {
525 tech_free(adv_idx);
526 } advance_index_iterate_end;
527
528 for (i = 0; i < ARRAY_SIZE(advances); i++) {
529 requirement_vector_free(&(advances[i].research_reqs));
530 }
531}
532
533/**********************************************************************/
536 size_t advance_req_iter_sizeof(void)
537{
538 return sizeof(struct advance_req_iter);
539}
540
541/**********************************************************************/
544 static void *advance_req_iter_get(const struct iterator *it)
545{
546 return (void *) *ADVANCE_REQ_ITER(it)->current;
547}
548
549/**********************************************************************/
552 static void advance_req_iter_next(struct iterator *it)
553{
554 struct advance_req_iter *iter = ADVANCE_REQ_ITER(it);
555 const struct advance *padvance = *iter->current, *preq;
556 enum tech_req req;
557 bool new = FALSE;
558
559 for (req = AR_ONE; req < AR_SIZE; req++) {
560 preq = valid_advance(advance_requires(padvance, req));
561 if (NULL != preq
562 && A_NONE != advance_number(preq)
563 && !BV_ISSET(iter->done, advance_number(preq))) {
564 BV_SET(iter->done, advance_number(preq));
565 if (new) {
566 *iter->end++ = preq;
567 } else {
568 *iter->current = preq;
569 new = TRUE;
570 }
571 }
572 }
573
574 if (!new) {
575 iter->current++;
576 }
577}
578
579/**********************************************************************/
582 static bool advance_req_iter_valid(const struct iterator *it)
583{
584 const struct advance_req_iter *iter = ADVANCE_REQ_ITER(it);
585
586 return iter->current < iter->end;
587}
588
589/**********************************************************************/
592 struct iterator *advance_req_iter_init(struct advance_req_iter *it,
593 const struct advance *goal)
594{
595 struct iterator *base = ITERATOR(it);
596
597 base->get = advance_req_iter_get;
598 base->next = advance_req_iter_next;
599 base->valid = advance_req_iter_valid;
600
601 BV_CLR_ALL(it->done);
602 it->current = it->array;
603 *it->current = goal;
604 it->end = it->current + 1;
605
606 return base;
607}
608
609/************************************************************************/
612 size_t advance_root_req_iter_sizeof(void)
613{
614 return sizeof(struct advance_root_req_iter);
615}
616
617/************************************************************************/
620 static void *advance_root_req_iter_get(const struct iterator *it)
621{
622 return
623 (void *) advance_requires(*ADVANCE_ROOT_REQ_ITER(it)->current, AR_ROOT);
624}
625
626/************************************************************************/
629 static bool advance_root_req_iter_valid(const struct iterator *it)
630{
631 const struct advance_root_req_iter *iter = ADVANCE_ROOT_REQ_ITER(it);
632
633 return iter->current < iter->end;
634}
635
636/************************************************************************/
639 static void advance_root_req_iter_next(struct iterator *it)
640{
641 struct advance_root_req_iter *iter = ADVANCE_ROOT_REQ_ITER(it);
642
643 /* Precondition: either iteration has already finished, or iter->current
644 * points at a tech with an interesting root_req (which means its
645 * requirements may have more). */
646 while (advance_root_req_iter_valid(it)) {
647 const struct advance *padvance = *iter->current;
648 enum tech_req req;
649 bool new = FALSE;
650
651 for (req = AR_ONE; req < AR_SIZE; req++) {
652 const struct advance *preq
653 = valid_advance(advance_requires(padvance, req));
654
655 if (NULL != preq
656 && A_NONE != advance_number(preq)
657 && !BV_ISSET(iter->done, advance_number(preq))) {
658
659 BV_SET(iter->done, advance_number(preq));
660 /* Do we need to look at this subtree at all? If it has A_NONE as
661 * root_req, further root_reqs can't propagate through it, so no. */
662 if (advance_required(advance_number(preq), AR_ROOT) != A_NONE) {
663 /* Yes, this subtree needs iterating over at some point, starting
664 * with preq (whose own root_req we'll consider in a bit) */
665 if (!new) {
666 *iter->current = preq;
667 new = TRUE;
668 } else {
669 *iter->end++ = preq; /* make a note for later */
670 }
671 }
672 }
673 }
674 if (!new) {
675 /* Didn't find an interesting new subtree. */
676 iter->current++;
677 }
678 /* Precondition: *current has been moved on from where we started, and
679 * it has an interesting root_req or it wouldn't be on the list; but
680 * it may be one that we've already yielded. */
681 if (advance_root_req_iter_valid(it)) {
682 Tech_type_id root = advance_required(advance_number(*iter->current),
683 AR_ROOT);
684 if (!BV_ISSET(iter->rootdone, root)) {
685 /* A previously unseen root_req. Stop and yield it. */
686 break;
687 } /* else keep looking */
688 }
689 }
690}
691
692/************************************************************************/
695 struct iterator *advance_root_req_iter_init(struct advance_root_req_iter *it,
696 const struct advance *goal)
697{
698 struct iterator *base = ITERATOR(it);
699
700 base->get = advance_root_req_iter_get;
701 base->next = advance_root_req_iter_next;
702 base->valid = advance_root_req_iter_valid;
703
704 BV_CLR_ALL(it->done);
705 BV_CLR_ALL(it->rootdone);
706 it->current = it->array;
707 if (advance_required(advance_number(goal), AR_ROOT) != A_NONE) {
708 /* First root_req to return is goal's own, and there may be more
709 * for next() to find. */
710 *it->current = goal;
711 it->end = it->current + 1;
712 } else {
713 /* No root_reqs -- go straight to invalid state */
714 it->end = it->current;
715 }
716
717 return base;
718}
BV_CLR_ALL
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
BV_SET
#define BV_SET(bv, bit)
Definition bitvector.h:81
BV_ISSET
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
incite_cost
char * incite_cost
Definition comments.c:74
base
static void base(QVariant data1, QVariant data2)
Definition dialogs.cpp:2937
Tech_type_id
int Tech_type_id
Definition fc_types.h:381
MAX_NUM_TECH_CLASSES
#define MAX_NUM_TECH_CLASSES
Definition fc_types.h:63
fcintl.h
Qn_
#define Qn_(String)
Definition fcintl.h:89
N_
#define N_(String)
Definition fcintl.h:69
user_flag_init
void user_flag_init(struct user_flag *flag)
Definition game.c:830
user_flag_free
void user_flag_free(struct user_flag *flag)
Definition game.c:839
game
struct civ_game game
Definition game.c:62
game.h
name
const char * name
Definition inputfile.c:127
iterator.h
ITERATOR
#define ITERATOR(p)
Definition iterator.h:37
log.h
fc_assert_msg
#define fc_assert_msg(condition, message,...)
Definition log.h:181
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
mem.h
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_strdup
#define fc_strdup(str)
Definition mem.h:43
name_set
static void name_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name)
Definition name_translation.h:88
rule_name_get
static const char * rule_name_get(const struct name_translation *ptrans)
Definition name_translation.h:112
name_translation_get
static const char * name_translation_get(const struct name_translation *ptrans)
Definition name_translation.h:121
research.h
shared.h
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
strvec_destroy
void strvec_destroy(struct strvec *psv)
Definition string_vector.c:72
string_vector.h
advance_req_iter
Definition tech.c:38
advance_req_iter::done
bv_techs done
Definition tech.c:40
advance_req_iter::end
const struct advance ** end
Definition tech.c:42
advance_req_iter::current
const struct advance ** current
Definition tech.c:42
advance_req_iter::base
struct iterator base
Definition tech.c:39
advance_req_iter::array
const struct advance * array[A_LAST]
Definition tech.c:41
advance_root_req_iter
Definition tech.c:46
advance_root_req_iter::array
const struct advance * array[A_LAST]
Definition tech.c:49
advance_root_req_iter::current
const struct advance ** current
Definition tech.c:50
advance_root_req_iter::rootdone
bv_techs rootdone
Definition tech.c:48
advance_root_req_iter::done
bv_techs done
Definition tech.c:48
advance_root_req_iter::end
const struct advance ** end
Definition tech.c:50
advance_root_req_iter::base
struct iterator base
Definition tech.c:47
advance
Definition tech.h:124
advance::ruledit_dlg
void * ruledit_dlg
Definition tech.h:127
advance::research_reqs
struct requirement_vector research_reqs
Definition tech.h:137
advance::tclass
struct tech_class * tclass
Definition tech.h:130
advance::cost
double cost
Definition tech.h:150
advance::require
struct advance * require[AR_SIZE]
Definition tech.h:132
advance::bonus_message
char * bonus_message
Definition tech.h:145
advance::helptext
struct strvec * helptext
Definition tech.h:140
advance::inherited_root_req
bool inherited_root_req
Definition tech.h:133
advance::flags
bv_tech_flags flags
Definition tech.h:139
advance::num_reqs
int num_reqs
Definition tech.h:156
advance::item_number
Tech_type_id item_number
Definition tech.h:125
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
civ_game::info
struct packet_game_info info
Definition game.h:89
iterator
Definition iterator.h:31
packet_game_info::base_tech_cost
int base_tech_cost
Definition packets_gen.h:129
packet_game_info::tech_leakage
enum tech_leakage_style tech_leakage
Definition packets_gen.h:233
packet_game_info::min_tech_cost
int min_tech_cost
Definition packets_gen.h:130
packet_game_info::tech_cost_style
enum tech_cost_style tech_cost_style
Definition packets_gen.h:232
packet_ruleset_control::num_tech_types
int num_tech_types
Definition packets_gen.h:1462
packet_ruleset_control::num_tech_classes
int num_tech_classes
Definition packets_gen.h:1461
tech_class
Definition tech.h:117
tech_class::ruledit_disabled
bool ruledit_disabled
Definition tech.h:120
tech_class::idx
int idx
Definition tech.h:118
user_flag
Definition game.h:73
user_flag::name
char * name
Definition game.h:74
user_flag::helptxt
char * helptxt
Definition game.h:75
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
support.h
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
fc__fallthrough
#define fc__fallthrough
Definition support.h:119
advance_count_real
Tech_type_id advance_count_real(void)
Definition tech.c:78
advance_by_number
struct advance * advance_by_number(const Tech_type_id atype)
Definition tech.c:107
tech_flag_id_name_cb
const char * tech_flag_id_name_cb(enum tech_flag_id flag)
Definition tech.c:433
tech_classes_init
void tech_classes_init(void)
Definition tech.c:317
tech_class_rule_name
const char * tech_class_rule_name(const struct tech_class *ptclass)
Definition tech.c:352
set_user_tech_flag_name
void set_user_tech_flag_name(enum tech_flag_id id, const char *name, const char *helptxt)
Definition tech.c:404
is_future_tech
bool is_future_tech(Tech_type_id tech)
Definition tech.c:281
advance_req_iter_next
static void advance_req_iter_next(struct iterator *it)
Definition tech.c:552
valid_advance
struct advance * valid_advance(struct advance *padvance)
Definition tech.c:152
techs_precalc_data
void techs_precalc_data(void)
Definition tech.c:225
advance_by_translated_name
struct advance * advance_by_translated_name(const char *name)
Definition tech.c:185
advance_has_flag
bool advance_has_flag(Tech_type_id tech, enum tech_flag_id flag)
Definition tech.c:216
advance_root_req_iter_sizeof
size_t advance_root_req_iter_sizeof(void)
Definition tech.c:612
tech_class_name_translation
const char * tech_class_name_translation(const struct tech_class *ptclass)
Definition tech.c:343
ADVANCE_ROOT_REQ_ITER
#define ADVANCE_ROOT_REQ_ITER(it)
Definition tech.c:52
user_tech_flags
static struct user_flag user_tech_flags[MAX_NUM_USER_TECH_FLAGS]
Definition tech.c:62
advances
struct advance advances[A_ARRAY_SIZE]
Definition tech.c:58
advance_root_req_iter_init
struct iterator * advance_root_req_iter_init(struct advance_root_req_iter *it, const struct advance *goal)
Definition tech.c:695
advance_req_iter_init
struct iterator * advance_req_iter_init(struct advance_req_iter *it, const struct advance *goal)
Definition tech.c:592
advance_root_req_iter_get
static void * advance_root_req_iter_get(const struct iterator *it)
Definition tech.c:620
tech_free
static void tech_free(Tech_type_id tech)
Definition tech.c:502
advance_requires
struct advance * advance_requires(const struct advance *padvance, enum tech_req require)
Definition tech.c:136
advance_name_translation
const char * advance_name_translation(const struct advance *padvance)
Definition tech.c:300
valid_advance_by_number
struct advance * valid_advance_by_number(const Tech_type_id id)
Definition tech.c:176
advance_root_req_iter_valid
static bool advance_root_req_iter_valid(const struct iterator *it)
Definition tech.c:629
techs_have_fixed_costs
bool techs_have_fixed_costs(void)
Definition tech.c:460
advance_required
Tech_type_id advance_required(const Tech_type_id tech, enum tech_req require)
Definition tech.c:121
tech_class_by_number
struct tech_class * tech_class_by_number(const int idx)
Definition tech.c:330
techs_init
void techs_init(void)
Definition tech.c:469
advance_rule_name
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:309
tech_classes
struct tech_class tech_classes[MAX_NUM_TECH_CLASSES]
Definition tech.c:60
advance_array_last
const struct advance * advance_array_last(void)
Definition tech.c:67
advance_req_iter_get
static void * advance_req_iter_get(const struct iterator *it)
Definition tech.c:544
advance_index
Tech_type_id advance_index(const struct advance *padvance)
Definition tech.c:89
tech_flag_helptxt
const char * tech_flag_helptxt(enum tech_flag_id id)
Definition tech.c:445
advance_req_iter_valid
static bool advance_req_iter_valid(const struct iterator *it)
Definition tech.c:582
techs_free
void techs_free(void)
Definition tech.c:520
advance_by_rule_name
struct advance * advance_by_rule_name(const char *name)
Definition tech.c:200
advance_root_req_iter_next
static void advance_root_req_iter_next(struct iterator *it)
Definition tech.c:639
user_tech_flags_init
void user_tech_flags_init(void)
Definition tech.c:380
advance_req_iter_sizeof
size_t advance_req_iter_sizeof(void)
Definition tech.c:536
ADVANCE_REQ_ITER
#define ADVANCE_REQ_ITER(it)
Definition tech.c:44
tech_class_by_rule_name
struct tech_class * tech_class_by_rule_name(const char *name)
Definition tech.c:361
is_regular_advance
bool is_regular_advance(struct advance *padvance)
Definition tech.c:290
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
user_tech_flags_free
void user_tech_flags_free(void)
Definition tech.c:392
tech.h
A_ARRAY_SIZE
#define A_ARRAY_SIZE
Definition tech.h:47
A_FUTURE
#define A_FUTURE
Definition tech.h:46
A_NEVER
#define A_NEVER
Definition tech.h:51
advance_index_iterate_end
#define advance_index_iterate_end
Definition tech.h:249
advance_req_iterate
#define advance_req_iterate(_goal, _padvance)
Definition tech.h:300
MAX_NUM_USER_TECH_FLAGS
#define MAX_NUM_USER_TECH_FLAGS
Definition tech.h:108
advance_iterate_all_end
#define advance_iterate_all_end
Definition tech.h:280
tech_req
tech_req
Definition tech.h:110
AR_TWO
@ AR_TWO
Definition tech.h:112
AR_ROOT
@ AR_ROOT
Definition tech.h:113
AR_ONE
@ AR_ONE
Definition tech.h:111
AR_SIZE
@ AR_SIZE
Definition tech.h:114
advance_iterate_all
#define advance_iterate_all(_p)
Definition tech.h:279
advance_req_iterate_end
#define advance_req_iterate_end
Definition tech.h:304
A_FIRST
#define A_FIRST
Definition tech.h:44
A_NONE
#define A_NONE
Definition tech.h:43
advance_iterate
#define advance_iterate(_p)
Definition tech.h:276
advance_iterate_end
#define advance_iterate_end
Definition tech.h:277
A_LAST
#define A_LAST
Definition tech.h:45
advance_index_iterate
#define advance_index_iterate(_start, _index)
Definition tech.h:245