Freeciv-3.4
Loading...
Searching...
No Matches
specialist.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
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/* utility */
19#include "fcintl.h"
20#include "log.h"
21#include "string_vector.h"
22
23/* common */
24#include "city.h"
25#include "effects.h"
26#include "game.h"
27
28#include "specialist.h"
29
32
33/**********************************************************************/
37{
38 int i;
39
40 for (i = 0; i < ARRAY_SIZE(specialists); i++) {
41 struct specialist *p = &specialists[i];
42
43 p->item_number = i;
45
47 }
48}
49
50/**********************************************************************/
54{
55 int i;
56
57 for (i = 0; i < ARRAY_SIZE(specialists); i++) {
58 struct specialist *p = &specialists[i];
59
61 if (p->helptext != nullptr) {
63 p->helptext = nullptr;
64 }
65 }
66}
67
68/**********************************************************************/
75
76/**********************************************************************/
83
84/**********************************************************************/
91{
92 fc_assert_ret_val(sp != nullptr, -1);
93
94 return sp - specialists;
95}
96
97/**********************************************************************/
101{
102 fc_assert_ret_val(sp != nullptr, -1);
103
104 return sp->item_number;
105}
106
107/**********************************************************************/
111{
113 return nullptr;
114 }
115
116 return &specialists[id];
117}
118
119/**********************************************************************/
124{
125 const char *qname = Qn_(name);
126
130 return sp;
131 }
133
134 return nullptr;
135}
136
137/**********************************************************************/
142{
146 return sp;
147 }
149
150 return nullptr;
151}
152
153/**********************************************************************/
157const char *specialist_rule_name(const struct specialist *sp)
158{
159 return rule_name_get(&sp->name);
160}
161
162/**********************************************************************/
167{
168 return name_translation_get(&sp->name);
169}
170
171/**********************************************************************/
176{
177 return name_translation_get(&sp->abbreviation);
178}
179
180/**********************************************************************/
191
192/**********************************************************************/
197{
198 if (sp < 0) {
199 return FALSE;
200 }
202}
203
204/**********************************************************************/
209{
211}
212
213/**********************************************************************/
221
222/**********************************************************************/
228{
229 static char buf[5 * SP_MAX];
230
231 buf[0] = '\0';
232
234 char *separator = (buf[0] == '\0') ? "" : "/";
235
236 cat_snprintf(buf, sizeof(buf), "%s%s", separator,
239
240 return buf;
241}
242
243/**********************************************************************/
253{
254 static char buf[5 * SP_MAX];
255
256 buf[0] = '\0';
257
259 char *separator = (buf[0] == '\0') ? "" : "/";
260
261 cat_snprintf(buf, sizeof(buf), "%s%d", separator, specialist_list[sp]);
263
264 return buf;
265}
266
267/**********************************************************************/
struct output_type * get_output_type(Output_type_id output)
Definition city.c:638
char * incite_cost
Definition comments.c:76
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
Definition dialogs_g.h:78
int int id
Definition editgui_g.h:28
int get_city_specialist_output_bonus(const struct city *pcity, const struct specialist *pspecialist, const struct output_type *poutput, enum effect_type effect_type)
Definition effects.c:881
unsigned char citizens
Definition fc_types.h:248
#define SP_MAX
Definition fc_types.h:268
int Specialist_type_id
Definition fc_types.h:235
enum output_type_id Output_type_id
Definition fc_types.h:238
#define Qn_(String)
Definition fcintl.h:89
struct civ_game game
Definition game.c:62
const char * name
Definition inputfile.c:127
#define fc_assert_ret_val(condition, val)
Definition log.h:195
static const char * rule_name_get(const struct name_translation *ptrans)
static const char * name_translation_get(const struct name_translation *ptrans)
#define ARRAY_SIZE(x)
Definition shared.h:85
struct specialist specialists[SP_MAX]
Definition specialist.c:30
const char * specialists_abbreviation_string(void)
Definition specialist.c:227
struct specialist * specialist_by_rule_name(const char *name)
Definition specialist.c:123
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:110
bool is_super_specialist_id(Specialist_type_id sp)
Definition specialist.c:184
bool is_normal_specialist(const struct specialist *sp)
Definition specialist.c:217
Specialist_type_id specialist_index(const struct specialist *sp)
Definition specialist.c:90
Specialist_type_id specialist_number(const struct specialist *sp)
Definition specialist.c:100
Specialist_type_id normal_specialist_count(void)
Definition specialist.c:79
const char * specialist_rule_name(const struct specialist *sp)
Definition specialist.c:157
int default_specialist
Definition specialist.c:31
const char * specialist_plural_translation(const struct specialist *sp)
Definition specialist.c:166
void specialists_free(void)
Definition specialist.c:53
Specialist_type_id specialist_count(void)
Definition specialist.c:71
const char * specialist_abbreviation_translation(const struct specialist *sp)
Definition specialist.c:175
void specialists_init(void)
Definition specialist.c:36
const char * specialists_string(const citizens *specialist_list)
Definition specialist.c:252
bool is_normal_specialist_id(Specialist_type_id sp)
Definition specialist.c:196
struct specialist * specialist_by_translated_name(const char *name)
Definition specialist.c:141
bool is_super_specialist(const struct specialist *sp)
Definition specialist.c:208
int get_specialist_output(const struct city *pcity, Specialist_type_id sp, Output_type_id otype)
Definition specialist.c:270
#define specialist_type_iterate_end
Definition specialist.h:85
#define specialist_type_iterate(sp)
Definition specialist.h:79
void strvec_destroy(struct strvec *psv)
Definition city.h:318
struct packet_ruleset_control control
Definition game.h:83
int item_number
Definition specialist.h:30
struct requirement_vector reqs
Definition specialist.h:38
bool ruledit_disabled
Definition specialist.h:33
struct strvec * helptext
Definition specialist.h:40
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:986
#define FALSE
Definition support.h:47