Freeciv21
Develop your civilization from humble roots to a global empire
specialist.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file
3  is part of Freeciv21. Freeciv21 is free software:
4 |\_/|,,_____,~~` you can redistribute it and/or modify it under the
5 (.".)~~ )`~}} terms of the GNU General Public License as published
6  \o/\ /---~\\ ~}} by the Free Software Foundation, either version 3 of
7  _// _// ~} the License, or (at your option) any later version.
8  You should have received a copy of the GNU General
9  Public License along with Freeciv21. If not, see
10  https://www.gnu.org/licenses/.
11 **************************************************************************/
12 
13 #pragma once
14 
15 // utility
16 #include "shared.h"
17 
18 // common
19 #include "fc_types.h"
20 #include "name_translation.h"
21 #include "requirements.h"
22 
23 struct specialist {
25  struct name_translation name;
28 
31 
32  struct requirement_vector reqs;
33 
35 };
36 
37 #define DEFAULT_SPECIALIST default_specialist
38 
39 extern struct specialist specialists[SP_MAX];
40 extern int default_specialist;
41 
42 // General specialist accessor functions.
46 
48 struct specialist *specialist_by_rule_name(const char *name);
49 struct specialist *specialist_by_translated_name(const char *name);
50 
51 const char *specialist_rule_name(const struct specialist *sp);
52 const char *specialist_plural_translation(const struct specialist *sp);
53 const char *specialist_abbreviation_translation(const struct specialist *sp);
54 
55 // Ancillary routines
57 const char *specialists_string(const citizens *specialist_list);
58 
59 int get_specialist_output(const struct city *pcity, Specialist_type_id sp,
60  Output_type_id otype);
61 
62 // Initialization and iteration
63 void specialists_init();
64 void specialists_free();
65 
66 // usually an index to arrays
67 #define specialist_type_iterate(sp) \
68  { \
69  Specialist_type_id sp; \
70  \
71  for (sp = 0; sp < specialist_count(); sp++) {
72 
73 #define specialist_type_iterate_end \
74  } \
75  }
76 
77 #define specialist_type_re_active_iterate(_p) \
78  specialist_type_iterate(_p##_) \
79  { \
80  struct specialist *_p = specialist_by_number(_p##_); \
81  if (!_p->ruledit_disabled) {
82 
83 #define specialist_type_re_active_iterate_end \
84  } \
85  } \
86  specialist_type_iterate_end;
unsigned char citizens
Definition: fc_types.h:305
#define SP_MAX
Definition: fc_types.h:324
int Specialist_type_id
Definition: fc_types.h:292
#define MAX_LEN_NAME
Definition: fc_types.h:61
enum output_type_id Output_type_id
Definition: fc_types.h:295
const char * name
Definition: inputfile.cpp:118
struct specialist specialists[SP_MAX]
Definition: specialist.cpp:24
struct specialist * specialist_by_rule_name(const char *name)
Return the specialist type with the given (untranslated!) rule name.
Definition: specialist.cpp:104
void specialists_free()
Free data for specialists.
Definition: specialist.cpp:47
const char * specialists_string(const citizens *specialist_list)
Return a string showing the number of specialists in the array.
Definition: specialist.cpp:198
const char * specialist_rule_name(const struct specialist *sp)
Return the (untranslated) rule name of the specialist type.
Definition: specialist.cpp:142
struct specialist * specialist_by_translated_name(const char *name)
Return the specialist type with the given (translated, plural) name.
Definition: specialist.cpp:124
void specialists_init()
Initialize data for specialists.
Definition: specialist.cpp:30
Specialist_type_id specialist_index(const struct specialist *sp)
Return the specialist index.
Definition: specialist.cpp:74
Specialist_type_id specialist_number(const struct specialist *sp)
Return the specialist item_number.
Definition: specialist.cpp:83
int default_specialist
Definition: specialist.cpp:25
const char * specialist_abbreviation_translation(const struct specialist *sp)
Return the (translated) abbreviation of the specialist type.
Definition: specialist.cpp:160
const char * specialists_abbreviation_string()
Return a string containing all the specialist abbreviations, for instance "E/S/T".
Definition: specialist.cpp:170
struct specialist * specialist_by_number(const Specialist_type_id id)
Return the specialist pointer for the given number.
Definition: specialist.cpp:92
Specialist_type_id specialist_count()
Return the number of specialist_types.
Definition: specialist.cpp:63
const char * specialist_plural_translation(const struct specialist *sp)
Return the (translated, plural) name of the specialist type.
Definition: specialist.cpp:151
int get_specialist_output(const struct city *pcity, Specialist_type_id sp, Output_type_id otype)
Return the output for the specialist type with this output type.
Definition: specialist.cpp:218
Definition: city.h:291
int item_number
Definition: specialist.h:24
struct requirement_vector reqs
Definition: specialist.h:32
char graphic_alt[MAX_LEN_NAME]
Definition: specialist.h:30
bool ruledit_disabled
Definition: specialist.h:27
char graphic_str[MAX_LEN_NAME]
Definition: specialist.h:29
struct name_translation name
Definition: specialist.h:25
QVector< QString > * helptext
Definition: specialist.h:34
struct name_translation abbreviation
Definition: specialist.h:26