Freeciv-3.2
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 (NULL != p->helptext) {
63 p->helptext = NULL;
64 }
65 }
66}
67
68/**********************************************************************/
75
76/**********************************************************************/
83{
85 return sp - specialists;
86}
87
88/**********************************************************************/
92{
94 return sp->item_number;
95}
96
97/**********************************************************************/
101{
103 return NULL;
104 }
105 return &specialists[id];
106}
107
108/**********************************************************************/
113{
114 const char *qname = Qn_(name);
115
119 return sp;
120 }
122
123 return NULL;
124}
125
126/**********************************************************************/
131{
135 return sp;
136 }
138
139 return NULL;
140}
141
142/**********************************************************************/
146const char *specialist_rule_name(const struct specialist *sp)
147{
148 return rule_name_get(&sp->name);
149}
150
151/**********************************************************************/
156{
157 return name_translation_get(&sp->name);
158}
159
160/**********************************************************************/
165{
166 return name_translation_get(&sp->abbreviation);
167}
168
169/**********************************************************************/
175{
176 static char buf[5 * SP_MAX];
177
178 buf[0] = '\0';
179
181 char *separator = (buf[0] == '\0') ? "" : "/";
182
183 cat_snprintf(buf, sizeof(buf), "%s%s", separator,
186
187 return buf;
188}
189
190/**********************************************************************/
200{
201 static char buf[5 * SP_MAX];
202
203 buf[0] = '\0';
204
206 char *separator = (buf[0] == '\0') ? "" : "/";
207
208 cat_snprintf(buf, sizeof(buf), "%s%d", separator, specialist_list[sp]);
210
211 return buf;
212}
213
214/**********************************************************************/
struct output_type * get_output_type(Output_type_id output)
Definition city.c:638
char * incite_cost
Definition comments.c:75
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:885
unsigned char citizens
Definition fc_types.h:388
#define SP_MAX
Definition fc_types.h:409
int Specialist_type_id
Definition fc_types.h:375
enum output_type_id Output_type_id
Definition fc_types.h:378
#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:194
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:174
struct specialist * specialist_by_rule_name(const char *name)
Definition specialist.c:112
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:100
Specialist_type_id specialist_index(const struct specialist *sp)
Definition specialist.c:82
Specialist_type_id specialist_number(const struct specialist *sp)
Definition specialist.c:91
const char * specialist_rule_name(const struct specialist *sp)
Definition specialist.c:146
int default_specialist
Definition specialist.c:31
const char * specialist_plural_translation(const struct specialist *sp)
Definition specialist.c:155
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:164
void specialists_init(void)
Definition specialist.c:36
const char * specialists_string(const citizens *specialist_list)
Definition specialist.c:199
struct specialist * specialist_by_translated_name(const char *name)
Definition specialist.c:130
int get_specialist_output(const struct city *pcity, Specialist_type_id sp, Output_type_id otype)
Definition specialist.c:217
#define specialist_type_iterate_end
Definition specialist.h:79
#define specialist_type_iterate(sp)
Definition specialist.h:73
void strvec_destroy(struct strvec *psv)
Definition city.h:320
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:189
int cat_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:1000
#define FALSE
Definition support.h:47