Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/ruleset.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
ruleset.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 <stdarg.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22
23/* utility */
24#include "bitvector.h"
25#include "deprecations.h"
26#include "fcintl.h"
27#include "log.h"
28#include "mem.h"
29#include "registry.h"
30#include "shared.h"
31#include "string_vector.h"
32#include "support.h"
33
34/* common */
35#include "achievements.h"
36#include "actions.h"
37#include "ai.h"
38#include "base.h"
39#include "capability.h"
40#include "city.h"
41#include "effects.h"
42#include "extras.h"
43#include "fc_types.h"
44#include "featured_text.h"
45#include "game.h"
46#include "government.h"
47#include "map.h"
48#include "movement.h"
49#include "multipliers.h"
50#include "name_translation.h"
51#include "nation.h"
52#include "packets.h"
53#include "player.h"
54#include "requirements.h"
55#include "rgbcolor.h"
56#include "road.h"
57#include "specialist.h"
58#include "style.h"
59#include "tech.h"
60#include "traderoutes.h"
61#include "unit.h"
62#include "unittype.h"
63
64/* server */
65#include "citytools.h"
66#include "notify.h"
67#include "plrhand.h"
68#include "rscompat.h"
69#include "rssanity.h"
70#include "settings.h"
71#include "srv_main.h"
72
73/* server/advisors */
74#include "advruleset.h"
75
76/* server/scripting */
77#include "script_server.h"
78
79#include "ruleset.h"
80
81/* RULESET_SUFFIX already used, no leading dot here */
82#define RULES_SUFFIX "ruleset"
83#define SCRIPT_SUFFIX "lua"
84
85#define ADVANCE_SECTION_PREFIX "advance_"
86#define TECH_CLASS_SECTION_PREFIX "techclass_"
87#define BUILDING_SECTION_PREFIX "building_"
88#define CITYSTYLE_SECTION_PREFIX "citystyle_"
89#define MUSICSTYLE_SECTION_PREFIX "musicstyle_"
90#define EFFECT_SECTION_PREFIX "effect_"
91#define GOVERNMENT_SECTION_PREFIX "government_"
92#define NATION_SET_SECTION_PREFIX "nset" /* without underscore? */
93#define NATION_GROUP_SECTION_PREFIX "ngroup" /* without underscore? */
94#define NATION_SECTION_PREFIX "nation" /* without underscore? */
95#define STYLE_SECTION_PREFIX "style_"
96#define CLAUSE_SECTION_PREFIX "clause_"
97#define EXTRA_SECTION_PREFIX "extra_"
98#define BASE_SECTION_PREFIX "base_"
99#define ROAD_SECTION_PREFIX "road_"
100#define RESOURCE_SECTION_PREFIX "resource_"
101#define GOODS_SECTION_PREFIX "goods_"
102#define SPECIALIST_SECTION_PREFIX "specialist_"
103#define TERRAIN_SECTION_PREFIX "terrain_"
104#define UNIT_CLASS_SECTION_PREFIX "unitclass_"
105#define UNIT_SECTION_PREFIX "unit_"
106#define DISASTER_SECTION_PREFIX "disaster_"
107#define ACHIEVEMENT_SECTION_PREFIX "achievement_"
108#define ACTION_ENABLER_SECTION_PREFIX "actionenabler_"
109#define MULTIPLIER_SECTION_PREFIX "multiplier_"
110
111#define check_name(name) (check_strlen(name, MAX_LEN_NAME, NULL))
112#define check_cityname(name) (check_strlen(name, MAX_LEN_CITYNAME, NULL))
113
114/* avoid re-reading files */
115 static const char name_too_long[] = "Name \"%s\" too long; truncating.";
116#define MAX_SECTION_LABEL 64
117#define section_strlcpy(dst, src) \
118 (void) loud_strlcpy(dst, src, MAX_SECTION_LABEL, name_too_long)
119 static char *resource_sections = NULL;
120 static char *terrain_sections = NULL;
121 static char *extra_sections = NULL;
122 static char *base_sections = NULL;
123 static char *road_sections = NULL;
124
125 static struct requirement_vector reqs_list;
126
127static bool load_rulesetdir(const char *rsdir, bool compat_mode,
128 rs_conversion_logger logger,
129 bool act, bool buffer_script, bool load_luadata);
130static struct section_file *openload_ruleset_file(const char *whichset,
131 const char *rsdir);
132
133static bool load_game_names(struct section_file *file,
134 struct rscompat_info *compat);
135static bool load_tech_names(struct section_file *file,
136 struct rscompat_info *compat);
137static bool load_unit_names(struct section_file *file,
138 struct rscompat_info *compat);
139static bool load_building_names(struct section_file *file,
140 struct rscompat_info *compat);
141static bool load_government_names(struct section_file *file,
142 struct rscompat_info *compat);
143static bool load_terrain_names(struct section_file *file,
144 struct rscompat_info *compat);
145static bool load_style_names(struct section_file *file,
146 struct rscompat_info *compat);
147static bool load_nation_names(struct section_file *file,
148 struct rscompat_info *compat);
149static bool load_city_name_list(struct section_file *file,
150 struct nation_type *pnation,
151 const char *secfile_str1,
152 const char *secfile_str2,
153 const char **allowed_terrains,
154 size_t atcount);
155
156static bool load_ruleset_techs(struct section_file *file,
157 struct rscompat_info *compat);
158static bool load_ruleset_units(struct section_file *file,
159 struct rscompat_info *compat);
160static bool load_ruleset_buildings(struct section_file *file,
161 struct rscompat_info *compat);
162static bool load_ruleset_governments(struct section_file *file,
163 struct rscompat_info *compat);
164static bool load_ruleset_terrain(struct section_file *file,
165 struct rscompat_info *compat);
166static bool load_ruleset_styles(struct section_file *file,
167 struct rscompat_info *compat);
168static bool load_ruleset_cities(struct section_file *file,
169 struct rscompat_info *compat);
170static bool load_ruleset_effects(struct section_file *file,
171 struct rscompat_info *compat);
172static bool load_ruleset_game(struct section_file *file, bool act,
173 struct rscompat_info *compat);
174
175static void send_ruleset_tech_classes(struct conn_list *dest);
176static void send_ruleset_techs(struct conn_list *dest);
177static void send_ruleset_unit_classes(struct conn_list *dest);
178static void send_ruleset_units(struct conn_list *dest);
179static void send_ruleset_buildings(struct conn_list *dest);
180static void send_ruleset_terrain(struct conn_list *dest);
181static void send_ruleset_resources(struct conn_list *dest);
182static void send_ruleset_extras(struct conn_list *dest);
183static void send_ruleset_bases(struct conn_list *dest);
184static void send_ruleset_roads(struct conn_list *dest);
185static void send_ruleset_goods(struct conn_list *dest);
186static void send_ruleset_governments(struct conn_list *dest);
187static void send_ruleset_styles(struct conn_list *dest);
188static void send_ruleset_clauses(struct conn_list *dest);
189static void send_ruleset_musics(struct conn_list *dest);
190static void send_ruleset_cities(struct conn_list *dest);
191static void send_ruleset_game(struct conn_list *dest);
192static void send_ruleset_team_names(struct conn_list *dest);
193
194static bool load_ruleset_veteran(struct section_file *file,
195 const char *path,
196 struct veteran_system **vsystem, char *err,
197 size_t err_len, struct rscompat_info *compat);
198
199 char *script_buffer = NULL;
200 char *parser_buffer = NULL;
201
202/**********************************************************************/
206 void ruleset_error_real(rs_conversion_logger logger,
207 const char *file, const char *function,
208 int line, enum log_level level,
209 const char *format, ...)
210{
211 va_list args;
212 char buf[MAX_LEN_LOG_LINE];
213
214 if (logger == NULL && !log_do_output_for_level(level)) {
215 return;
216 }
217
218 va_start(args, format);
219 if (logger != NULL) {
220 fc_vsnprintf(buf, sizeof(buf), format, args);
221 logger(buf);
222 } else {
223 vdo_log(file, function, line, FALSE, level, buf, sizeof(buf), format, args);
224 }
225 va_end(args);
226
227 if (LOG_FATAL >= level) {
228 exit(EXIT_FAILURE);
229 }
230}
231
232/**********************************************************************/
235 static int ruleset_purge_unused_enablers(void)
236{
237 int purged = 0;
238
239 action_iterate(act_id) {
240 struct action *paction = action_by_number(act_id);
241
242 if (action_enabler_list_size(action_enablers_for_action(paction->id))
243 == 0) {
244 /* Not relevant. */
245 continue;
246 }
247
248 /* Impossible hard requirement. */
249 if (!action_is_in_use(paction)) {
250 /* Make sure that all action enablers are disabled. */
251 action_enabler_list_iterate(action_enablers_for_action(paction->id),
252 ae) {
253 ae->ruledit_disabled = TRUE;
254 purged++;
255 } action_enabler_list_iterate_end;
256
257 log_normal("Purged all action enablers for %s",
258 action_rule_name(paction));
259 }
260
261 /* Impossible requirement vector requirement. */
262 action_enabler_list_iterate(action_enablers_for_action(paction->id),
263 ae) {
264 if (!ae->ruledit_disabled
265 && (!action_enabler_possible_actor(ae)
266 || req_vec_is_impossible_to_fulfill(&ae->target_reqs))) {
267 ae->ruledit_disabled = TRUE;
268 purged++;
269 log_normal("Purged unused action enabler for %s",
270 action_rule_name(paction));
271 }
272 } action_enabler_list_iterate_end;
273 } action_iterate_end;
274
275 return purged;
276}
277
278/**********************************************************************/
281 static int ruleset_purge_unused_effects(void)
282{
283 int purged = 0;
284 enum effect_type type;
285
286 for (type = effect_type_begin(); type != effect_type_end();
287 type = effect_type_next(type)) {
288 effect_list_iterate(get_effects(type), eft) {
289 if (req_vec_is_impossible_to_fulfill(&eft->reqs)) {
290 eft->ruledit_do_not_save = TRUE;
291 purged++;
292 log_normal("Purged unused effect for %s",
293 effect_type_name(eft->type));
294 }
295 } effect_list_iterate_end;
296 }
297
298 return purged;
299}
300
301/**********************************************************************/
304 int ruleset_purge_unused_entities(void)
305{
306 int purged = 0;
307
308 purged += ruleset_purge_unused_enablers();
309 purged += ruleset_purge_unused_effects();
310
311 return purged;
312}
313
314/**********************************************************************/
318 static bool purge_unused_req_vec(const struct requirement_vector *reqs,
319 const char *msg)
320{
321 struct req_vec_problem *problem;
322 bool result;
323
324 problem = req_vec_get_first_missing_univ(reqs, req_vec_vector_number,
325 reqs);
326
327 if (problem == NULL) {
328 /* No problem. */
329 return FALSE;
330 }
331
332 if (problem->num_suggested_solutions == 0) {
333 /* No solution. */
334 req_vec_problem_free(problem);
335 return FALSE;
336 }
337
338 if (problem->num_suggested_solutions == 1
339 && problem->suggested_solutions[0].operation == RVCO_REMOVE) {
340 /* Remove !present req that never is there. */
341 log_normal("%s", msg);
342 result = req_vec_change_apply(&problem->suggested_solutions[0],
343 req_vec_by_number, reqs);
344 req_vec_problem_free(problem);
345 return result;
346 }
347
348 /* Not handled. Don't know what this is. */
349 fc_assert(problem->num_suggested_solutions == 1);
350 req_vec_problem_free(problem);
351 return FALSE;
352}
353
354/**********************************************************************/
358 static bool purge_duplicate_req_vec(const struct requirement_vector *reqs,
359 const char *msg)
360{
361 struct req_vec_problem *problem;
362 bool result;
363
364 problem = req_vec_get_first_redundant_req(reqs, req_vec_vector_number,
365 reqs);
366
367 if (problem == NULL) {
368 /* No problem. */
369 return FALSE;
370 }
371
372 if (problem->num_suggested_solutions == 0) {
373 /* No solution. */
374 req_vec_problem_free(problem);
375 return FALSE;
376 }
377
378 if (problem->num_suggested_solutions == 2
379 && problem->suggested_solutions[0].operation == RVCO_REMOVE
380 && problem->suggested_solutions[1].operation == RVCO_REMOVE
381 && are_requirements_equal(&problem->suggested_solutions[0].req,
382 &problem->suggested_solutions[1].req)) {
383 /* Simple duplication is handled. */
384 log_normal("%s", msg);
385 result = req_vec_change_apply(&problem->suggested_solutions[1],
386 req_vec_by_number, reqs);
387 req_vec_problem_free(problem);
388 return result;
389 }
390
391 /* Requirements of different kinds making each other redundant isn't
392 * supported yet. It could be done by always removing the most general
393 * requirement. So unit type is kept when redundant with unit flag, unit
394 * class and unit class flag etc. */
395 req_vec_problem_free(problem);
396 return FALSE;
397}
398
399/**********************************************************************/
403 static bool purge_redundant_req_vec(const struct requirement_vector *reqs,
404 const char *msg)
405{
406 return (purge_unused_req_vec(reqs, msg)
407 || purge_duplicate_req_vec(reqs, msg));
408}
409
410/**********************************************************************/
414 static int ruleset_purge_redundant_reqs_enablers(void)
415{
416 int purged = 0;
417
418 action_iterate(act_id) {
419 struct action *paction = action_by_number(act_id);
420 char actor_reqs[MAX_LEN_NAME * 2];
421 char target_reqs[MAX_LEN_NAME * 2];
422
423 /* Error log text */
424 fc_snprintf(actor_reqs, sizeof(actor_reqs),
425 "Purged redundant requirement in"
426 " %s in action enabler for %s",
427 "actor_reqs", action_rule_name(paction));
428 fc_snprintf(target_reqs, sizeof(target_reqs),
429 "Purged redundant requirement in"
430 " %s in action enabler for %s",
431 "target_reqs", action_rule_name(paction));
432
433 /* Do the purging. */
434 action_enabler_list_iterate(action_enablers_for_action(paction->id),
435 ae) {
436 while (!ae->ruledit_disabled
437 && (purge_redundant_req_vec(&ae->actor_reqs, actor_reqs)
438 || purge_redundant_req_vec(&ae->target_reqs,
439 target_reqs))) {
440 purged++;
441 }
442 } action_enabler_list_iterate_end;
443 } action_iterate_end;
444
445 return purged;
446}
447
448/**********************************************************************/
452 static int ruleset_purge_redundant_reqs_effects(void)
453{
454 int purged = 0;
455 enum effect_type type;
456
457 for (type = effect_type_begin(); type != effect_type_end();
458 type = effect_type_next(type)) {
459 char msg[MAX_LEN_NAME * 2];
460
461 /* Error log text */
462 fc_snprintf(msg, sizeof(msg),
463 "Purged redundant requirement in effect of type %s",
464 effect_type_name(type));
465
466 /* Do the purging. */
467 effect_list_iterate(get_effects(type), eft) {
468 while (purge_redundant_req_vec(&eft->reqs, msg)) {
469 purged++;
470 }
471 } effect_list_iterate_end;
472 }
473
474 return purged;
475}
476
477/**********************************************************************/
481 int ruleset_purge_redundant_reqs(void)
482{
483 int purged = 0;
484
485 purged += ruleset_purge_redundant_reqs_enablers();
486 purged += ruleset_purge_redundant_reqs_effects();
487
488 if (purged > 0) {
489 /* An unused requirement may be an obligatory hard requirement. */
490 rscompat_enablers_add_obligatory_hard_reqs();
491 }
492
493 return purged;
494}
495
496/**********************************************************************/
500 static const char *valid_ruleset_filename(const char *subdir,
501 const char *name,
502 const char *extension,
503 bool optional)
504{
505 char filename[512];
506 const char *dfilename;
507
508 fc_assert_ret_val(subdir && name && extension, NULL);
509
510 fc_snprintf(filename, sizeof(filename), "%s" DIR_SEPARATOR "%s.%s",
511 subdir, name, extension);
512 log_verbose("Trying \"%s\".", filename);
513 dfilename = fileinfoname(get_data_dirs(), filename);
514 if (dfilename) {
515 return dfilename;
516 }
517
518 fc_snprintf(filename, sizeof(filename), "default" DIR_SEPARATOR "%s.%s", name, extension);
519 log_verbose("Trying \"%s\": default ruleset directory.", filename);
520 dfilename = fileinfoname(get_data_dirs(), filename);
521 if (dfilename) {
522 return dfilename;
523 }
524
525 fc_snprintf(filename, sizeof(filename), "%s_%s.%s",
526 subdir, name, extension);
527 log_verbose("Trying \"%s\": alternative ruleset filename syntax.",
528 filename);
529 dfilename = fileinfoname(get_data_dirs(), filename);
530 if (dfilename) {
531 return dfilename;
532 } else if (!optional) {
533 ruleset_error(NULL, LOG_ERROR,
534 /* TRANS: message about an installation error. */
535 _("Could not find a readable \"%s.%s\" ruleset file."),
536 name, extension);
537 }
538
539 return NULL;
540}
541
542/**********************************************************************/
545 char *get_script_buffer(void)
546{
547 return script_buffer;
548}
549
550/**********************************************************************/
553 char *get_parser_buffer(void)
554{
555 return parser_buffer;
556}
557
558/**********************************************************************/
562 static struct section_file *openload_ruleset_file(const char *whichset,
563 const char *rsdir)
564{
565 char sfilename[512];
566 const char *dfilename = valid_ruleset_filename(rsdir, whichset,
567 RULES_SUFFIX, FALSE);
568 struct section_file *secfile;
569
570 if (dfilename == NULL) {
571 return NULL;
572 }
573
574 /* Need to save a copy of the filename for following message, since
575 section_file_load() may call datafilename() for includes. */
576 sz_strlcpy(sfilename, dfilename);
577 secfile = secfile_load(sfilename, FALSE);
578
579 if (secfile == NULL) {
580 ruleset_error(NULL, LOG_ERROR, "Could not load ruleset '%s':\n%s",
581 sfilename, secfile_error());
582 }
583
584 return secfile;
585}
586
587/**********************************************************************/
590 static enum fc_tristate openload_script_file(const char *whichset, const char *rsdir,
591 char **buffer, bool optional)
592{
593 const char *dfilename = valid_ruleset_filename(rsdir, whichset,
594 SCRIPT_SUFFIX, optional);
595
596 if (dfilename == NULL) {
597 return optional ? TRI_MAYBE : TRI_NO;
598 }
599
600 if (buffer == NULL) {
601 if (!script_server_do_file(NULL, dfilename)) {
602 ruleset_error(NULL, LOG_ERROR, "\"%s\": could not load ruleset script.",
603 dfilename);
604
605 return TRI_NO;
606 }
607 } else {
608 script_server_load_file(dfilename, buffer);
609 }
610
611 return TRI_YES;
612}
613
614/**********************************************************************/
617 static struct section_file *openload_luadata_file(const char *rsdir)
618{
619 struct section_file *secfile;
620 char sfilename[512];
621 const char *dfilename = valid_ruleset_filename(rsdir, "luadata",
622 "txt", TRUE);
623
624 if (dfilename == NULL) {
625 return NULL;
626 }
627
628 /* Need to save a copy of the filename for following message, since
629 section_file_load() may call datafilename() for includes. */
630 sz_strlcpy(sfilename, dfilename);
631 secfile = secfile_load(sfilename, FALSE);
632
633 if (secfile == NULL) {
634 ruleset_error(NULL, LOG_ERROR, "Could not load luadata '%s':\n%s",
635 sfilename, secfile_error());
636 }
637
638 return secfile;
639}
640
641/**********************************************************************/
645 struct requirement_vector *lookup_req_list(struct section_file *file,
646 struct rscompat_info *compat,
647 const char *sec,
648 const char *sub,
649 const char *rfor)
650{
651 const char *type, *name;
652 int j;
653 const char *filename;
654
655 filename = secfile_name(file);
656
657 requirement_vector_reserve(&reqs_list, 0);
658
659 for (j = 0; (type = secfile_lookup_str_default(file, NULL, "%s.%s%d.type",
660 sec, sub, j)); j++) {
661 char buf[MAX_LEN_NAME];
662 const char *range;
663 bool survives, present, quiet;
664 struct entry *pentry;
665 struct requirement req;
666
667 if (compat->compat_mode) {
668 type = rscompat_req_type_name_3_1(type);
669 }
670
671 if (!(pentry = secfile_entry_lookup(file, "%s.%s%d.name",
672 sec, sub, j))) {
673 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
674
675 return NULL;
676 }
677 name = NULL;
678 switch (entry_type_get(pentry)) {
679 case ENTRY_BOOL:
680 {
681 bool val;
682
683 if (entry_bool_get(pentry, &val)) {
684 fc_snprintf(buf, sizeof(buf), "%d", val);
685 name = buf;
686 }
687 }
688 break;
689 case ENTRY_INT:
690 {
691 int val;
692
693 if (entry_int_get(pentry, &val)) {
694 fc_snprintf(buf, sizeof(buf), "%d", val);
695 name = buf;
696 }
697 }
698 break;
699 case ENTRY_STR:
700 (void) entry_str_get(pentry, &name);
701 break;
702 case ENTRY_FLOAT:
703 fc_assert(entry_type_get(pentry) != ENTRY_FLOAT);
704 ruleset_error(NULL, LOG_ERROR,
705 "\"%s\": trying to have an floating point entry as a requirement name in '%s.%s%d'.",
706 filename, sec, sub, j);
707 break;
708 case ENTRY_FILEREFERENCE:
709 fc_assert(entry_type_get(pentry) != ENTRY_FILEREFERENCE);
710 break;
711 case ENTRY_ILLEGAL:
712 fc_assert(entry_type_get(pentry) != ENTRY_ILLEGAL);
713 break;
714 }
715 if (NULL == name) {
716 ruleset_error(NULL, LOG_ERROR,
717 "\"%s\": error in handling requirement name for '%s.%s%d'.",
718 filename, sec, sub, j);
719 return NULL;
720 }
721
722 if (!(range = secfile_lookup_str(file, "%s.%s%d.range", sec, sub, j))) {
723 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
724
725 return NULL;
726 }
727
728 survives = FALSE;
729 if ((pentry = secfile_entry_lookup(file, "%s.%s%d.survives",
730 sec, sub, j))
731 && !entry_bool_get(pentry, &survives)) {
732 ruleset_error(NULL, LOG_ERROR,
733 "\"%s\": invalid boolean value for survives for "
734 "'%s.%s%d'.", filename, sec, sub, j);
735 }
736
737 present = TRUE;
738 if ((pentry = secfile_entry_lookup(file, "%s.%s%d.present",
739 sec, sub, j))
740 && !entry_bool_get(pentry, &present)) {
741 ruleset_error(NULL, LOG_ERROR,
742 "\"%s\": invalid boolean value for present for "
743 "'%s.%s%d'.", filename, sec, sub, j);
744 }
745 quiet = FALSE;
746 if ((pentry = secfile_entry_lookup(file, "%s.%s%d.quiet",
747 sec, sub, j))
748 && !entry_bool_get(pentry, &quiet)) {
749 ruleset_error(NULL, LOG_ERROR,
750 "\"%s\": invalid boolean value for quiet for "
751 "'%s.%s%d'.", filename, sec, sub, j);
752 }
753
754 if (compat->compat_mode) {
755 if (!fc_strcasecmp(type, universals_n_name(VUT_UTFLAG))) {
756 name = rscompat_utype_flag_name_3_1(compat, name);
757 }
758 }
759
760 if (compat->compat_mode) {
761 name = rscompat_req_name_3_1(type, name);
762 }
763
764 if (compat->compat_mode) {
765 if (!fc_strcasecmp(type, "UnitState")
766 && !fc_strcasecmp(name, "OnDomesticTile")) {
767 type = "DiplRelTile";
768 name = "Foreign";
769 present = !present;
770 }
771 }
772
773 req = req_from_str(type, range, survives, present, quiet, name);
774 if (req.source.kind == universals_n_invalid()) {
775 ruleset_error(NULL, LOG_ERROR,
776 "\"%s\" [%s] has invalid or unknown req: "
777 "\"%s\" \"%s\".",
778 filename, sec, type, name);
779
780 return NULL;
781 }
782
783 requirement_vector_append(&reqs_list, req);
784 }
785
786 if (compat->compat_mode) {
787 rscompat_req_vec_adjust_3_1(compat, &reqs_list, &j,
788 filename, sec, sub, rfor);
789 }
790
791 if (j > MAX_NUM_REQS) {
792 ruleset_error(NULL, LOG_ERROR,
793 "Too many (%d) requirements for %s. Max is %d",
794 j, rfor, MAX_NUM_REQS);
795
796 return NULL;
797 }
798
799 return &reqs_list;
800}
801
802/**********************************************************************/
805 static bool lookup_cbonus_list(struct rscompat_info *compat,
806 struct combat_bonus_list *list,
807 struct section_file *file,
808 const char *sec,
809 const char *sub)
810{
811 const char *flag;
812 int j;
813 const char *filename;
814 bool success = TRUE;
815
816 filename = secfile_name(file);
817
818 for (j = 0; (flag = secfile_lookup_str_default(file, NULL, "%s.%s%d.flag",
819 sec, sub, j)); j++) {
820 struct combat_bonus *bonus = fc_malloc(sizeof(*bonus));
821 const char *type;
822
823 bonus->flag = unit_type_flag_id_by_name(rscompat_utype_flag_name_3_1(compat, flag),
824 fc_strcasecmp);
825 if (!unit_type_flag_id_is_valid(bonus->flag)) {
826 log_error("\"%s\": unknown flag name \"%s\" in '%s.%s'.",
827 filename, flag, sec, sub);
828 FC_FREE(bonus);
829 success = FALSE;
830 continue;
831 }
832 type = secfile_lookup_str(file, "%s.%s%d.type", sec, sub, j);
833 type = rscompat_combat_bonus_name_3_1(compat, type);
834 bonus->type = combat_bonus_type_by_name(type, fc_strcasecmp);
835 if (!combat_bonus_type_is_valid(bonus->type)) {
836 log_error("\"%s\": unknown bonus type \"%s\" in '%s.%s'.",
837 filename, type, sec, sub);
838 FC_FREE(bonus);
839 success = FALSE;
840 continue;
841 }
842 if (!secfile_lookup_int(file, &bonus->value, "%s.%s%d.value",
843 sec, sub, j)) {
844 log_error("\"%s\": failed to get value from '%s.%s%d'.",
845 filename, sec, sub, j);
846 FC_FREE(bonus);
847 success = FALSE;
848 continue;
849 }
850 bonus->quiet = secfile_lookup_bool_default(file, FALSE,
851 "%s.%s%d.quiet",
852 sec, sub, j);
853 combat_bonus_list_append(list, bonus);
854 }
855
856 return success;
857}
858
859/**********************************************************************/
867 static bool lookup_tech(struct section_file *file,
868 struct advance **result,
869 const char *prefix, const char *entry,
870 const char *filename,
871 const char *description)
872{
873 const char *sval;
874
875 sval = secfile_lookup_str_default(file, NULL, "%s.%s", prefix, entry);
876 if (!sval || !strcmp(sval, "Never")) {
877 *result = A_NEVER;
878 } else {
879 *result = advance_by_rule_name(sval);
880
881 if (A_NEVER == *result) {
882 ruleset_error(NULL, LOG_ERROR,
883 "\"%s\" %s %s: couldn't match \"%s\".",
884 filename, (description ? description : prefix), entry, sval);
885 return FALSE;
886 }
887 }
888
889 return TRUE;
890}
891
892/**********************************************************************/
899 static bool lookup_building(struct section_file *file,
900 const char *prefix, const char *entry,
901 struct impr_type **result,
902 const char *filename,
903 const char *description)
904{
905 const char *sval;
906 bool ok = TRUE;
907
908 sval = secfile_lookup_str_default(file, NULL, "%s.%s", prefix, entry);
909 if (!sval || strcmp(sval, "None") == 0) {
910 *result = B_NEVER;
911 } else {
912 *result = improvement_by_rule_name(sval);
913
914 if (B_NEVER == *result) {
915 ruleset_error(NULL, LOG_ERROR,
916 "\"%s\" %s %s: couldn't match \"%s\".",
917 filename, (description ? description : prefix), entry, sval);
918 ok = FALSE;
919 }
920 }
921
922 return ok;
923}
924
925/**********************************************************************/
932 static bool lookup_unit_list(struct section_file *file, const char *prefix,
933 const char *entry,
934 struct unit_type **output,
935 const char *filename)
936{
937 const char **slist;
938 size_t nval;
939 int i;
940 bool ok = TRUE;
941
942 /* pre-fill with NULL: */
943 for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
944 output[i] = NULL;
945 }
946 slist = secfile_lookup_str_vec(file, &nval, "%s.%s", prefix, entry);
947 if (nval == 0) {
948 /* 'No vector' is considered same as empty vector */
949 if (slist != NULL) {
950 free(slist);
951 }
952 return TRUE;
953 }
954 if (nval > MAX_NUM_UNIT_LIST) {
955 ruleset_error(NULL, LOG_ERROR,
956 "\"%s\": string vector %s.%s too long (%d, max %d)",
957 filename, prefix, entry, (int) nval, MAX_NUM_UNIT_LIST);
958 ok = FALSE;
959 } else if (nval == 1 && strcmp(slist[0], "") == 0) {
960 free(slist);
961 return TRUE;
962 }
963 if (ok) {
964 for (i = 0; i < nval; i++) {
965 const char *sval = slist[i];
966 struct unit_type *punittype = unit_type_by_rule_name(sval);
967
968 if (!punittype) {
969 ruleset_error(NULL, LOG_ERROR,
970 "\"%s\" %s.%s (%d): couldn't match \"%s\".",
971 filename, prefix, entry, i, sval);
972 ok = FALSE;
973 break;
974 }
975 output[i] = punittype;
976 log_debug("\"%s\" %s.%s (%d): %s (%d)", filename, prefix, entry, i, sval,
977 utype_number(punittype));
978 }
979 }
980 free(slist);
981
982 return ok;
983}
984
985/**********************************************************************/
992 static bool lookup_tech_list(struct section_file *file, const char *prefix,
993 const char *entry, int *output,
994 const char *filename)
995{
996 const char **slist;
997 size_t nval;
998 int i;
999 bool ok = TRUE;
1000
1001 /* pre-fill with A_LAST: */
1002 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
1003 output[i] = A_LAST;
1004 }
1005 slist = secfile_lookup_str_vec(file, &nval, "%s.%s", prefix, entry);
1006 if (slist == NULL || nval == 0) {
1007 return TRUE;
1008 } else if (nval > MAX_NUM_TECH_LIST) {
1009 ruleset_error(NULL, LOG_ERROR,
1010 "\"%s\": string vector %s.%s too long (%d, max %d)",
1011 filename, prefix, entry, (int) nval, MAX_NUM_TECH_LIST);
1012 ok = FALSE;
1013 }
1014
1015 if (ok) {
1016 if (nval == 1 && strcmp(slist[0], "") == 0) {
1017 FC_FREE(slist);
1018 return TRUE;
1019 }
1020 for (i = 0; i < nval && ok; i++) {
1021 const char *sval = slist[i];
1022 struct advance *padvance = advance_by_rule_name(sval);
1023
1024 if (NULL == padvance) {
1025 ruleset_error(NULL, LOG_ERROR,
1026 "\"%s\" %s.%s (%d): couldn't match \"%s\".",
1027 filename, prefix, entry, i, sval);
1028 ok = FALSE;
1029 }
1030 if (!valid_advance(padvance)) {
1031 ruleset_error(NULL, LOG_ERROR,
1032 "\"%s\" %s.%s (%d): \"%s\" is removed.",
1033 filename, prefix, entry, i, sval);
1034 ok = FALSE;
1035 }
1036
1037 if (ok) {
1038 output[i] = advance_number(padvance);
1039 log_debug("\"%s\" %s.%s (%d): %s (%d)", filename, prefix, entry, i, sval,
1040 advance_number(padvance));
1041 }
1042 }
1043 }
1044 FC_FREE(slist);
1045
1046 return ok;
1047}
1048
1049/**********************************************************************/
1056 static bool lookup_building_list(struct section_file *file,
1057 const char *prefix, const char *entry,
1058 int *output, const char *filename)
1059{
1060 const char **slist;
1061 size_t nval;
1062 int i;
1063 bool ok = TRUE;
1064
1065 /* pre-fill with B_LAST: */
1066 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
1067 output[i] = B_LAST;
1068 }
1069 slist = secfile_lookup_str_vec(file, &nval, "%s.%s", prefix, entry);
1070 if (nval > MAX_NUM_BUILDING_LIST) {
1071 ruleset_error(NULL, LOG_ERROR,
1072 "\"%s\": string vector %s.%s too long (%d, max %d)",
1073 filename, prefix, entry, (int) nval, MAX_NUM_BUILDING_LIST);
1074 ok = FALSE;
1075 } else if (nval == 0 || (nval == 1 && strcmp(slist[0], "") == 0)) {
1076 if (slist != NULL) {
1077 FC_FREE(slist);
1078 }
1079 return TRUE;
1080 }
1081 if (ok) {
1082 for (i = 0; i < nval; i++) {
1083 const char *sval = slist[i];
1084 struct impr_type *pimprove = improvement_by_rule_name(sval);
1085
1086 if (NULL == pimprove) {
1087 ruleset_error(NULL, LOG_ERROR,
1088 "\"%s\" %s.%s (%d): couldn't match \"%s\".",
1089 filename, prefix, entry, i, sval);
1090 ok = FALSE;
1091 break;
1092 }
1093 output[i] = improvement_number(pimprove);
1094 log_debug("%s.%s,%d %s %d", prefix, entry, i, sval, output[i]);
1095 }
1096 }
1097 free(slist);
1098
1099 return ok;
1100}
1101
1102/**********************************************************************/
1108 static bool lookup_unit_type(struct section_file *file,
1109 const char *prefix,
1110 const char *entry,
1111 const struct unit_type **result,
1112 const char *filename,
1113 const char *description)
1114{
1115 const char *sval;
1116
1117 sval = secfile_lookup_str_default(file, "None", "%s.%s", prefix, entry);
1118
1119 if (strcmp(sval, "None") == 0) {
1120 *result = NULL;
1121 } else {
1122 *result = unit_type_by_rule_name(sval);
1123 if (*result == NULL) {
1124 ruleset_error(NULL, LOG_ERROR,
1125 "\"%s\" %s %s: couldn't match \"%s\".",
1126 filename, (description ? description : prefix), entry, sval);
1127
1128 return FALSE;
1129 }
1130 }
1131
1132 return TRUE;
1133}
1134
1135/**********************************************************************/
1139 static struct government *lookup_government(struct section_file *file,
1140 const char *entry,
1141 const char *filename,
1142 struct government *fallback)
1143{
1144 const char *sval;
1145 struct government *gov;
1146
1147 sval = secfile_lookup_str_default(file, NULL, "%s", entry);
1148 if (!sval) {
1149 gov = fallback;
1150 } else {
1151 gov = government_by_rule_name(sval);
1152 }
1153 if (!gov) {
1154 ruleset_error(NULL, LOG_ERROR,
1155 "\"%s\" %s: couldn't match \"%s\".",
1156 filename, entry, sval);
1157 }
1158 return gov;
1159}
1160
1161/**********************************************************************/
1164 static char *lookup_string(struct section_file *file, const char *prefix,
1165 const char *suffix)
1166{
1167 const char *sval = secfile_lookup_str(file, "%s.%s", prefix, suffix);
1168
1169 if (NULL != sval) {
1170 char copy[strlen(sval) + 1];
1171
1172 strcpy(copy, sval);
1173 remove_leading_trailing_spaces(copy);
1174 if (strlen(copy) > 0) {
1175 return fc_strdup(copy);
1176 }
1177 }
1178 return NULL;
1179}
1180
1181/**********************************************************************/
1184 static struct strvec *lookup_strvec(struct section_file *file,
1185 const char *prefix, const char *suffix)
1186{
1187 size_t dim;
1188 const char **vec = secfile_lookup_str_vec(file, &dim,
1189 "%s.%s", prefix, suffix);
1190
1191 if (NULL != vec) {
1192 struct strvec *dest = strvec_new();
1193
1194 strvec_store(dest, vec, dim);
1195 free(vec);
1196 return dest;
1197 }
1198 return NULL;
1199}
1200
1201/**********************************************************************/
1204 static struct extra_type *lookup_resource(const char *filename,
1205 const char *name,
1206 const char *jsection)
1207{
1208 struct extra_type *pres;
1209
1210 pres = extra_type_by_rule_name(name);
1211
1212 if (pres == NULL) {
1213 ruleset_error(NULL, LOG_ERROR,
1214 "\"%s\" [%s] has unknown \"%s\".",
1215 filename, jsection, name);
1216 }
1217
1218 return pres;
1219}
1220
1221/**********************************************************************/
1225 static bool lookup_terrain(struct section_file *file,
1226 const char *entry,
1227 const char *filename,
1228 struct terrain *pthis,
1229 struct terrain **result,
1230 bool null_acceptable)
1231{
1232 const int j = terrain_index(pthis);
1233 const char *jsection = &terrain_sections[j * MAX_SECTION_LABEL];
1234 const char *name = secfile_lookup_str(file, "%s.%s", jsection, entry);
1235 struct terrain *pterr;
1236
1237 if (NULL == name && !null_acceptable) {
1238 return FALSE;
1239 }
1240
1241 if (NULL == name
1242 || *name == '\0'
1243 || (0 == strcmp(name, "none"))
1244 || (0 == strcmp(name, "no"))) {
1245 *result = T_NONE;
1246
1247 return TRUE;
1248 }
1249 if (0 == strcmp(name, "yes")) {
1250 *result = pthis;
1251
1252 return TRUE;
1253 }
1254
1255 pterr = terrain_by_rule_name(name);
1256 *result = pterr;
1257
1258 if (pterr == NULL) {
1259 ruleset_error(NULL, LOG_ERROR,
1260 "\"%s\" [%s] has unknown \"%s\".",
1261 secfile_name(file), jsection, name);
1262 return FALSE;
1263 }
1264
1265 return TRUE;
1266}
1267
1268/**********************************************************************/
1275 static bool lookup_time(const struct section_file *secfile, int *turns,
1276 const char *sec_name, const char *property_name,
1277 const char *filename, const char *item_name,
1278 bool *ok)
1279{
1280 /* Assumes that PACKET_UNIT_INFO.activity_count in packets.def is UINT16 */
1281 const int max_turns = 65535 / ACTIVITY_FACTOR;
1282
1283 if (!secfile_lookup_int(secfile, turns, "%s.%s", sec_name, property_name)) {
1284 return FALSE;
1285 }
1286
1287 if (*turns > max_turns) {
1288 ruleset_error(NULL, LOG_ERROR,
1289 "\"%s\": \"%s\": \"%s\" value %d too large (max %d)",
1290 filename, item_name ? item_name : sec_name,
1291 property_name, *turns, max_turns);
1292 *ok = FALSE;
1293 }
1294
1295 return TRUE; /* we found _something */
1296}
1297
1298/**********************************************************************/
1301 static bool ruleset_load_names(struct name_translation *pname,
1302 const char *domain,
1303 struct section_file *file,
1304 const char *sec_name)
1305{
1306 const char *name = secfile_lookup_str(file, "%s.name", sec_name);
1307 const char *rule_name = secfile_lookup_str(file, "%s.rule_name", sec_name);
1308
1309 if (!name) {
1310 ruleset_error(NULL, LOG_ERROR,
1311 "\"%s\" [%s]: no \"name\" specified.",
1312 secfile_name(file), sec_name);
1313 return FALSE;
1314 }
1315
1316 names_set(pname, domain, name, rule_name);
1317
1318 return TRUE;
1319}
1320
1321/**********************************************************************/
1324 static void ruleset_load_traits(struct trait_limits *out,
1325 struct section_file *file,
1326 const char *secname, const char *field_prefix)
1327{
1328 enum trait tr;
1329
1330 /* FIXME: Use specenum trait names without duplicating them here.
1331 * Just needs to take care of case.
1332 * This list is also duplicated in rulesave.c:save_traits() */
1333 const char *trait_names[] = {
1334 "expansionist",
1335 "trader",
1336 "aggressive",
1337 "builder",
1338 NULL
1339 };
1340
1341 for (tr = trait_begin(); tr != trait_end() && trait_names[tr] != NULL; tr = trait_next(tr)) {
1342 out[tr].min = secfile_lookup_int_default(file, -1, "%s.%s%s_min",
1343 secname,
1344 field_prefix,
1345 trait_names[tr]);
1346 out[tr].max = secfile_lookup_int_default(file, -1, "%s.%s%s_max",
1347 secname,
1348 field_prefix,
1349 trait_names[tr]);
1350 out[tr].fixed = secfile_lookup_int_default(file, -1, "%s.%s%s_default",
1351 secname,
1352 field_prefix,
1353 trait_names[tr]);
1354 }
1355
1356 fc_assert(tr == trait_end()); /* number of trait_names correct */
1357}
1358
1359/**********************************************************************/
1363 static bool load_game_names(struct section_file *file,
1364 struct rscompat_info *compat)
1365{
1366 struct section_list *sec;
1367 int nval;
1368 const char *filename = secfile_name(file);
1369 bool ok = TRUE;
1370
1371 /* section: datafile */
1372 compat->version = rscompat_check_capabilities(file, filename, compat);
1373 if (compat->version <= 0) {
1374 return FALSE;
1375 }
1376
1377 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
1378 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
1379
1380 sec = secfile_sections_by_name_prefix(file, ACHIEVEMENT_SECTION_PREFIX);
1381 nval = (NULL != sec ? section_list_size(sec) : 0);
1382 if (nval > MAX_ACHIEVEMENT_TYPES) {
1383 int num = nval; /* No "size_t" to printf */
1384
1385 ruleset_error(NULL, LOG_ERROR,
1386 "\"%s\": Too many achievement types (%d, max %d)",
1387 filename, num, MAX_ACHIEVEMENT_TYPES);
1388 ok = FALSE;
1389 } else {
1390 game.control.num_achievement_types = nval;
1391 }
1392
1393 if (ok) {
1394 achievements_iterate(pach) {
1395 const char *sec_name = section_name(section_list_get(sec, achievement_index(pach)));
1396
1397 if (!ruleset_load_names(&pach->name, NULL, file, sec_name)) {
1398 ruleset_error(NULL, LOG_ERROR,
1399 "\"%s\": Cannot load achievement names",
1400 filename);
1401 ok = FALSE;
1402 break;
1403 }
1404 } achievements_iterate_end;
1405 }
1406
1407 section_list_destroy(sec);
1408
1409 if (ok) {
1410 sec = secfile_sections_by_name_prefix(file, GOODS_SECTION_PREFIX);
1411
1412 nval = (NULL != sec ? section_list_size(sec) : 0);
1413 if (nval > MAX_GOODS_TYPES) {
1414 int num = nval; /* No "size_t" to printf */
1415
1416 ruleset_error(NULL, LOG_ERROR,
1417 "\"%s\": Too many goods types (%d, max %d)",
1418 filename, num, MAX_GOODS_TYPES);
1419 section_list_destroy(sec);
1420 ok = FALSE;
1421 } else if (nval < 1) {
1422 ruleset_error(NULL, LOG_ERROR,
1423 "\"%s\": At least one goods type needed",
1424 filename);
1425 section_list_destroy(sec);
1426 ok = FALSE;
1427 } else {
1428 game.control.num_goods_types = nval;
1429 }
1430
1431 if (ok) {
1432 goods_type_iterate(pgood) {
1433 const char *sec_name
1434 = section_name(section_list_get(sec, goods_index(pgood)));
1435
1436 if (!ruleset_load_names(&pgood->name, NULL, file, sec_name)) {
1437 ruleset_error(NULL, LOG_ERROR,
1438 "\"%s\": Cannot load goods names",
1439 filename);
1440 ok = FALSE;
1441 break;
1442 }
1443 } goods_type_iterate_end;
1444 }
1445 section_list_destroy(sec);
1446 }
1447
1448 return ok;
1449}
1450
1451
1452/**********************************************************************/
1456 static bool load_tech_names(struct section_file *file,
1457 struct rscompat_info *compat)
1458{
1459 struct section_list *sec = NULL;
1460 /* Number of techs in the ruleset (means without A_NONE). */
1461 int num_techs = 0;
1462 int i;
1463 const char *filename = secfile_name(file);
1464 bool ok = TRUE;
1465 const char *flag;
1466
1467 if (!rscompat_check_cap_and_version(file, filename, compat)) {
1468 return FALSE;
1469 }
1470
1471 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
1472 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
1473
1474 /* User tech flag names */
1475 for (i = 0; (flag = secfile_lookup_str_default(file, NULL, "control.flags%d.name", i)) ;
1476 i++) {
1477 const char *helptxt = secfile_lookup_str_default(file, NULL, "control.flags%d.helptxt",
1478 i);
1479 if (tech_flag_id_by_name(flag, fc_strcasecmp) != tech_flag_id_invalid()) {
1480 ruleset_error(NULL, LOG_ERROR,
1481 "\"%s\": Duplicate tech flag name '%s'",
1482 filename, flag);
1483 ok = FALSE;
1484 break;
1485 }
1486 if (i > MAX_NUM_USER_TECH_FLAGS) {
1487 ruleset_error(NULL, LOG_ERROR,
1488 "\"%s\": Too many user tech flags!",
1489 filename);
1490 ok = FALSE;
1491 break;
1492 }
1493
1494 set_user_tech_flag_name(TECH_USER_1 + i, flag, helptxt);
1495 }
1496
1497 if (ok) {
1498 size_t nval;
1499
1500 for (; i < MAX_NUM_USER_TECH_FLAGS; i++) {
1501 set_user_tech_flag_name(TECH_USER_1 + i, NULL, NULL);
1502 }
1503
1504 /* Tech classes */
1505 sec = secfile_sections_by_name_prefix(file, TECH_CLASS_SECTION_PREFIX);
1506
1507 nval = (NULL != sec ? section_list_size(sec) : 0);
1508 if (nval > MAX_NUM_TECH_CLASSES) {
1509 int num = nval; /* No "size_t" to printf */
1510
1511 ruleset_error(NULL, LOG_ERROR,
1512 "\"%s\": Too many tech classes (%d, max %d)",
1513 filename, num, MAX_NUM_TECH_CLASSES);
1514 section_list_destroy(sec);
1515 ok = FALSE;
1516 } else {
1517 game.control.num_tech_classes = nval;
1518 }
1519
1520 if (ok) {
1521 tech_class_iterate(ptclass) {
1522 const char *sec_name
1523 = section_name(section_list_get(sec, tech_class_index(ptclass)));
1524
1525 if (!ruleset_load_names(&ptclass->name, NULL, file, sec_name)) {
1526 ruleset_error(NULL, LOG_ERROR, "\"%s\": Cannot load tech class names",
1527 filename);
1528 ok = FALSE;
1529 break;
1530 }
1531 } tech_class_iterate_end;
1532 }
1533 }
1534
1535 if (ok) {
1536 /* The techs: */
1537 sec = secfile_sections_by_name_prefix(file, ADVANCE_SECTION_PREFIX);
1538 if (NULL == sec || 0 == (num_techs = section_list_size(sec))) {
1539 ruleset_error(NULL, LOG_ERROR,
1540 "\"%s\": No Advances?!?", filename);
1541 ok = FALSE;
1542 } else {
1543 log_verbose("%d advances (including possibly unused)", num_techs);
1544 if (num_techs + A_FIRST > A_LAST) {
1545 ruleset_error(NULL, LOG_ERROR,
1546 "\"%s\": Too many advances (%d, max %d)",
1547 filename, num_techs, A_LAST - A_FIRST);
1548 ok = FALSE;
1549 }
1550 }
1551 }
1552
1553 if (ok) {
1554 game.control.num_tech_types = num_techs + A_FIRST; /* includes A_NONE */
1555
1556 i = 0;
1557 advance_iterate(A_FIRST, a) {
1558 if (!ruleset_load_names(&a->name, NULL, file, section_name(section_list_get(sec, i)))) {
1559 ok = FALSE;
1560 break;
1561 }
1562 i++;
1563 } advance_iterate_end;
1564 }
1565 section_list_destroy(sec);
1566
1567 return ok;
1568}
1569
1570/**********************************************************************/
1573 static bool load_ruleset_techs(struct section_file *file,
1574 struct rscompat_info *compat)
1575{
1576 struct section_list *sec;
1577 const char **slist;
1578 int i;
1579 size_t nval;
1580 struct advance *a_none = advance_by_number(A_NONE);
1581 const char *filename = secfile_name(file);
1582 bool ok = TRUE;
1583
1584 sec = secfile_sections_by_name_prefix(file, TECH_CLASS_SECTION_PREFIX);
1585
1586 i = 0;
1587 tech_class_iterate(ptclass) {
1588 const char *sec_name = section_name(section_list_get(sec, i));
1589
1590 ptclass->cost_pct = secfile_lookup_int_default(file, 100, "%s.%s",
1591 sec_name, "cost_pct");
1592
1593 i++;
1594 } tech_class_iterate_end;
1595
1596 sec = secfile_sections_by_name_prefix(file, ADVANCE_SECTION_PREFIX);
1597
1598 i = 0;
1599 advance_iterate(A_FIRST, a) {
1600 const char *sec_name = section_name(section_list_get(sec, i));
1601 const char *sval;
1602 int j, ival;
1603 struct requirement_vector *research_reqs;
1604
1605 if (!lookup_tech(file, &a->require[AR_ONE], sec_name, "req1",
1606 filename, rule_name_get(&a->name))
1607 || !lookup_tech(file, &a->require[AR_TWO], sec_name, "req2",
1608 filename, rule_name_get(&a->name))
1609 || !lookup_tech(file, &a->require[AR_ROOT], sec_name, "root_req",
1610 filename, rule_name_get(&a->name))) {
1611 ok = FALSE;
1612 break;
1613 }
1614
1615 if ((A_NEVER == a->require[AR_ONE] && A_NEVER != a->require[AR_TWO])
1616 || (A_NEVER != a->require[AR_ONE] && A_NEVER == a->require[AR_TWO])) {
1617 ruleset_error(NULL, LOG_ERROR,
1618 "\"%s\" [%s] \"%s\": \"Never\" with non-\"Never\".",
1619 filename, sec_name, rule_name_get(&a->name));
1620 ok = FALSE;
1621 break;
1622 }
1623 if (a_none == a->require[AR_ONE] && a_none != a->require[AR_TWO]) {
1624 ruleset_error(NULL, LOG_ERROR,
1625 "\"%s\" [%s] \"%s\": should have \"None\" second.",
1626 filename, sec_name, rule_name_get(&a->name));
1627 ok = FALSE;
1628 break;
1629 }
1630
1631 if (game.control.num_tech_classes == 0) {
1632 a->tclass = NULL;
1633 } else {
1634 const char *classname;
1635
1636 classname = lookup_string(file, sec_name, "class");
1637 if (classname != NULL) {
1638 classname = Q_(classname);
1639 a->tclass = tech_class_by_rule_name(classname);
1640 if (a->tclass == NULL) {
1641 ruleset_error(NULL, LOG_ERROR,
1642 "\"%s\" [%s] \"%s\": Unknown tech class \"%s\".",
1643 filename, sec_name, rule_name_get(&a->name), classname);
1644 ok = FALSE;
1645 break;
1646 }
1647 } else {
1648 a->tclass = NULL; /* Default */
1649 }
1650 }
1651
1652 research_reqs = lookup_req_list(file, compat, sec_name, "research_reqs",
1653 rule_name_get(&a->name));
1654 if (research_reqs == NULL) {
1655 ok = FALSE;
1656 break;
1657 }
1658
1659 requirement_vector_copy(&a->research_reqs, research_reqs);
1660
1661 BV_CLR_ALL(a->flags);
1662
1663 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", sec_name);
1664 for (j = 0; j < nval; j++) {
1665 sval = slist[j];
1666 if (strcmp(sval, "") == 0) {
1667 continue;
1668 }
1669 ival = tech_flag_id_by_name(sval, fc_strcasecmp);
1670 if (!tech_flag_id_is_valid(ival)) {
1671 ruleset_error(NULL, LOG_ERROR,
1672 "\"%s\" [%s] \"%s\": bad flag name \"%s\".",
1673 filename, sec_name, rule_name_get(&a->name), sval);
1674 ok = FALSE;
1675 break;
1676 } else {
1677 BV_SET(a->flags, ival);
1678 }
1679 }
1680 free(slist);
1681
1682 if (!ok) {
1683 break;
1684 }
1685
1686 sz_strlcpy(a->graphic_str,
1687 secfile_lookup_str_default(file, "-", "%s.graphic", sec_name));
1688 sz_strlcpy(a->graphic_alt,
1689 secfile_lookup_str_default(file, "-",
1690 "%s.graphic_alt", sec_name));
1691
1692 a->helptext = lookup_strvec(file, sec_name, "helptext");
1693 a->bonus_message = lookup_string(file, sec_name, "bonus_message");
1694 a->cost = secfile_lookup_int_default(file, -1, "%s.%s",
1695 sec_name, "cost");
1696 a->num_reqs = 0;
1697
1698 i++;
1699 } advance_iterate_end;
1700
1701 /* Propagate a root tech up into the tech tree. If a technology
1702 * X has Y has a root tech, then any technology requiring X (in the
1703 * normal way or as a root tech) also has Y as a root tech.
1704 * Later techs may gain a whole set of root techs in this way. The one
1705 * we store in AR_ROOT is a more or less arbitrary one of these,
1706 * also signalling that the set is non-empty; after this, you'll still
1707 * have to walk the tech tree to find them all. */
1708restart:
1709
1710 if (ok) {
1711 advance_iterate(A_FIRST, a) {
1712 if (valid_advance(a)
1713 && A_NEVER != a->require[AR_ROOT]) {
1714 bool out_of_order = FALSE;
1715
1716 /* Now find any tech depending on this technology and update its
1717 * root_req. */
1718 advance_iterate(A_FIRST, b) {
1719 if (valid_advance(b)
1720 && A_NEVER == b->require[AR_ROOT]
1721 && (a == b->require[AR_ONE] || a == b->require[AR_TWO])) {
1722 b->require[AR_ROOT] = a->require[AR_ROOT];
1723 b->inherited_root_req = TRUE;
1724 if (b < a) {
1725 out_of_order = TRUE;
1726 }
1727 }
1728 } advance_iterate_end;
1729
1730 if (out_of_order) {
1731 /* HACK: If we just changed the root_tech of a lower-numbered
1732 * technology, we need to go back so that we can propagate the
1733 * root_tech up to that technology's parents... */
1734 goto restart;
1735 }
1736 }
1737 } advance_iterate_end;
1738
1739 /* Now rename A_NEVER to A_NONE for consistency */
1740 advance_iterate(A_NONE, a) {
1741 if (A_NEVER == a->require[AR_ROOT]) {
1742 a->require[AR_ROOT] = a_none;
1743 }
1744 } advance_iterate_end;
1745
1746 /* Some more consistency checking:
1747 Non-removed techs depending on removed techs is too
1748 broken to fix by default, so die.
1749 */
1750 advance_iterate(A_FIRST, a) {
1751 if (valid_advance(a)) {
1752 /* We check for recursive tech loops later,
1753 * in build_required_techs_helper. */
1754 if (!valid_advance(a->require[AR_ONE])) {
1755 ruleset_error(NULL, LOG_ERROR,
1756 "\"%s\" tech \"%s\": req1 leads to removed tech.",
1757 filename, advance_rule_name(a));
1758 ok = FALSE;
1759 break;
1760 }
1761 if (!valid_advance(a->require[AR_TWO])) {
1762 ruleset_error(NULL, LOG_ERROR,
1763 "\"%s\" tech \"%s\": req2 leads to removed tech.",
1764 filename, advance_rule_name(a));
1765 ok = FALSE;
1766 break;
1767 }
1768 }
1769 } advance_iterate_end;
1770 }
1771
1772 section_list_destroy(sec);
1773 if (ok) {
1774 secfile_check_unused(file);
1775 }
1776
1777 return ok;
1778}
1779
1780/**********************************************************************/
1784 static bool load_unit_names(struct section_file *file,
1785 struct rscompat_info *compat)
1786{
1787 struct section_list *sec = NULL;
1788 int nval = 0;
1789 int i;
1790 const char *filename = secfile_name(file);
1791 const char *flag;
1792 bool ok = TRUE;
1793
1794 if (!rscompat_check_cap_and_version(file, filename, compat)) {
1795 return FALSE;
1796 }
1797
1798 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
1799 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
1800
1801 /* User unit flag names */
1802 for (i = 0; (flag = secfile_lookup_str_default(file, NULL, "control.flags%d.name", i)) ;
1803 i++) {
1804 const char *helptxt = secfile_lookup_str_default(file, NULL, "control.flags%d.helptxt",
1805 i);
1806
1807 if (unit_type_flag_id_by_name(rscompat_utype_flag_name_3_1(compat, flag),
1808 fc_strcasecmp)
1809 != unit_type_flag_id_invalid()) {
1810 ruleset_error(NULL, LOG_ERROR,
1811 "\"%s\": Duplicate unit flag name '%s'",
1812 filename, flag);
1813 ok = FALSE;
1814 break;
1815 }
1816 if (i > MAX_NUM_USER_UNIT_FLAGS) {
1817 ruleset_error(NULL, LOG_ERROR,
1818 "\"%s\": Too many user unit type flags!",
1819 filename);
1820 ok = FALSE;
1821 break;
1822 }
1823
1824 set_user_unit_type_flag_name(UTYF_USER_FLAG_1 + i, flag, helptxt);
1825 }
1826
1827 if (ok) {
1828 /* Blank the remaining unit type user flags. */
1829 for (; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
1830 set_user_unit_type_flag_name(UTYF_USER_FLAG_1 + i, NULL, NULL);
1831 }
1832 }
1833
1834 if (ok) {
1835 /* User unit class flag names */
1836 for (i = 0;
1837 (flag = secfile_lookup_str_default(file, NULL,
1838 "control.class_flags%d.name",
1839 i));
1840 i++) {
1841 const char *helptxt = secfile_lookup_str_default(file, NULL,
1842 "control.class_flags%d.helptxt", i);
1843
1844 if (unit_class_flag_id_by_name(flag, fc_strcasecmp)
1845 != unit_class_flag_id_invalid()) {
1846 ruleset_error(NULL, LOG_ERROR,
1847 "\"%s\": Duplicate unit class flag name '%s'",
1848 filename, flag);
1849 ok = FALSE;
1850 break;
1851 }
1852 if (i > MAX_NUM_USER_UCLASS_FLAGS) {
1853 ruleset_error(NULL, LOG_ERROR,
1854 "\"%s\": Too many user unit class flags!",
1855 filename);
1856 ok = FALSE;
1857 break;
1858 }
1859
1860 set_user_unit_class_flag_name(UCF_USER_FLAG_1 + i, flag, helptxt);
1861 }
1862 }
1863
1864 if (ok) {
1865 /* Blank the remaining unit class user flags. */
1866 for (; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
1867 set_user_unit_class_flag_name(UCF_USER_FLAG_1 + i, NULL, NULL);
1868 }
1869 }
1870
1871 if (ok) {
1872 /* Unit classes */
1873 sec = secfile_sections_by_name_prefix(file, UNIT_CLASS_SECTION_PREFIX);
1874 if (NULL == sec || 0 == (nval = section_list_size(sec))) {
1875 ruleset_error(NULL, LOG_ERROR,
1876 "\"%s\": No unit classes?!?", filename);
1877 ok = FALSE;
1878 } else {
1879 log_verbose("%d unit classes", nval);
1880 if (nval > UCL_LAST) {
1881 ruleset_error(NULL, LOG_ERROR,
1882 "\"%s\": Too many unit classes (%d, max %d)",
1883 filename, nval, UCL_LAST);
1884 ok = FALSE;
1885 }
1886 }
1887 }
1888
1889 if (ok) {
1890 game.control.num_unit_classes = nval;
1891
1892 unit_class_iterate(punitclass) {
1893 const int pci = uclass_index(punitclass);
1894
1895 if (!ruleset_load_names(&punitclass->name, NULL, file,
1896 section_name(section_list_get(sec, pci)))) {
1897 ok = FALSE;
1898 break;
1899 }
1900 } unit_class_iterate_end;
1901 }
1902 section_list_destroy(sec);
1903 sec = NULL;
1904
1905 /* The names: */
1906 if (ok) {
1907 sec = secfile_sections_by_name_prefix(file, UNIT_SECTION_PREFIX);
1908 if (NULL == sec || 0 == (nval = section_list_size(sec))) {
1909 ruleset_error(NULL, LOG_ERROR,
1910 "\"%s\": No unit types?!?", filename);
1911 ok = FALSE;
1912 } else {
1913 log_verbose("%d unit types (including possibly unused)", nval);
1914 if (nval > U_LAST) {
1915 ruleset_error(NULL, LOG_ERROR,
1916 "\"%s\": Too many unit types (%d, max %d)",
1917 filename, nval, U_LAST);
1918 ok = FALSE;
1919 }
1920 }
1921 }
1922
1923 if (ok) {
1924 game.control.num_unit_types = nval;
1925
1926 unit_type_iterate(punittype) {
1927 const int utypei = utype_index(punittype);
1928 if (!ruleset_load_names(&punittype->name, NULL, file,
1929 section_name(section_list_get(sec, utypei)))) {
1930 ok = FALSE;
1931 break;
1932 }
1933 } unit_type_iterate_end;
1934 }
1935 section_list_destroy(sec);
1936
1937 return ok;
1938}
1939
1940/**********************************************************************/
1943 static bool load_ruleset_veteran(struct section_file *file,
1944 const char *path,
1945 struct veteran_system **vsystem, char *err,
1946 size_t err_len, struct rscompat_info *compat)
1947{
1948 const char **vlist_name;
1949 int *vlist_power, *vlist_raise, *vlist_wraise, *vlist_move;
1950 size_t count_name, count_power, count_raise, count_wraise, count_move;
1951 int i;
1952 bool ret = TRUE;
1953
1954 /* The pointer should be uninitialised. */
1955 if (*vsystem != NULL) {
1956 fc_snprintf(err, err_len, "Veteran system is defined?!");
1957 return FALSE;
1958 }
1959
1960 /* Load data. */
1961 vlist_name = secfile_lookup_str_vec(file, &count_name,
1962 "%s.veteran_names", path);
1963 vlist_power = secfile_lookup_int_vec(file, &count_power,
1964 "%s.veteran_power_fact", path);
1965 vlist_raise = secfile_lookup_int_vec(file, &count_raise,
1966 "%s.veteran_base_raise_chance", path);
1967 if (vlist_raise == NULL) {
1968 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
1969 vlist_raise = secfile_lookup_int_vec(file, &count_raise,
1970 "%s.veteran_raise_chance", path);
1971 } else {
1972 fc_assert(count_raise == 0); /* Should be so from an attempt to
1973 * read veteran_base_raise_chance */
1974 count_raise = 0; /* ...but clang analyzer doesn't see it, or
1975 * sees something I don't. */
1976 }
1977 }
1978 vlist_wraise = secfile_lookup_int_vec(file, &count_wraise,
1979 "%s.veteran_work_raise_chance",
1980 path);
1981 vlist_move = secfile_lookup_int_vec(file, &count_move,
1982 "%s.veteran_move_bonus", path);
1983
1984 if (count_name > MAX_VET_LEVELS) {
1985 ret = FALSE;
1986 fc_snprintf(err, err_len, "\"%s\": Too many veteran levels (section "
1987 "'%s': %lu, max %d)", secfile_name(file), path,
1988 (long unsigned)count_name, MAX_VET_LEVELS);
1989 } else if (count_name != count_power
1990 || count_name != count_raise
1991 || count_name != count_wraise
1992 || count_name != count_move) {
1993 ret = FALSE;
1994 fc_snprintf(err, err_len, "\"%s\": Different lengths for the veteran "
1995 "settings in section '%s'", secfile_name(file),
1996 path);
1997 } else if (count_name == 0) {
1998 /* Nothing defined. */
1999 *vsystem = NULL;
2000 } else {
2001 /* Generate the veteran system. */
2002 *vsystem = veteran_system_new((int)count_name);
2003
2004#define rs_sanity_veteran(_path, _entry, _i, _condition, _action) \
2005 if (_condition) { \
2006 log_error("Invalid veteran definition '%s.%s[%d]'!", \
2007 _path, _entry, _i); \
2008 log_debug("Failed check: '%s'. Update value: '%s'.", \
2009 #_condition, #_action); \
2010 _action; \
2011 }
2012 for (i = 0; i < count_name; i++) {
2013 /* Some sanity checks. */
2014 rs_sanity_veteran(path, "veteran_power_fact", i,
2015 (vlist_power[i] < 0), vlist_power[i] = 0);
2016 rs_sanity_veteran(path, "veteran_base_raise_chance", i,
2017 (vlist_raise[i] < 0), vlist_raise[i] = 0);
2018 rs_sanity_veteran(path, "veteran_work_raise_chance", i,
2019 (vlist_wraise[i] < 0), vlist_wraise[i] = 0);
2020 rs_sanity_veteran(path, "veteran_move_bonus", i,
2021 (vlist_move[i] < 0), vlist_move[i] = 0);
2022 if (i == 0) {
2023 /* First element.*/
2024 rs_sanity_veteran(path, "veteran_power_fact", i,
2025 (vlist_power[i] != 100), vlist_power[i] = 100);
2026 } else if (i == count_name - 1) {
2027 /* Last element. */
2028 rs_sanity_veteran(path, "veteran_power_fact", i,
2029 (vlist_power[i] < vlist_power[i - 1]),
2030 vlist_power[i] = vlist_power[i - 1]);
2031 rs_sanity_veteran(path, "veteran_base_raise_chance", i,
2032 (vlist_raise[i] != 0), vlist_raise[i] = 0);
2033 rs_sanity_veteran(path, "veteran_work_raise_chance", i,
2034 (vlist_wraise[i] != 0), vlist_wraise[i] = 0);
2035 } else {
2036 /* All elements inbetween. */
2037 rs_sanity_veteran(path, "veteran_power_fact", i,
2038 (vlist_power[i] < vlist_power[i - 1]),
2039 vlist_power[i] = vlist_power[i - 1]);
2040 rs_sanity_veteran(path, "veteran_base_raise_chance", i,
2041 (vlist_raise[i] > 100), vlist_raise[i] = 100);
2042 rs_sanity_veteran(path, "veteran_work_raise_chance", i,
2043 (vlist_wraise[i] > 100), vlist_wraise[i] = 100);
2044 }
2045
2046 veteran_system_definition(*vsystem, i, vlist_name[i], vlist_power[i],
2047 vlist_move[i], vlist_raise[i],
2048 vlist_wraise[i]);
2049 }
2050#undef rs_sanity_veteran
2051 }
2052
2053 if (vlist_name) {
2054 free(vlist_name);
2055 }
2056 if (vlist_power) {
2057 free(vlist_power);
2058 }
2059 if (vlist_raise) {
2060 free(vlist_raise);
2061 }
2062 if (vlist_wraise) {
2063 free(vlist_wraise);
2064 }
2065 if (vlist_move) {
2066 free(vlist_move);
2067 }
2068
2069 return ret;
2070}
2071
2072/**********************************************************************/
2075 static bool load_ruleset_units(struct section_file *file,
2076 struct rscompat_info *compat)
2077{
2078 int j, ival;
2079 size_t nval;
2080 struct section_list *sec, *csec;
2081 const char *sval, **slist;
2082 const char *filename = secfile_name(file);
2083 char msg[MAX_LEN_MSG];
2084 bool ok = TRUE;
2085
2086 if (!load_ruleset_veteran(file, "veteran_system", &game.veteran, msg,
2087 sizeof(msg), compat)
2088 || game.veteran == NULL) {
2089 ruleset_error(NULL, LOG_ERROR,
2090 "Error loading the default veteran system: %s",
2091 msg);
2092 ok = FALSE;
2093 }
2094
2095 sec = secfile_sections_by_name_prefix(file, UNIT_SECTION_PREFIX);
2096 nval = (NULL != sec ? section_list_size(sec) : 0);
2097
2098 csec = secfile_sections_by_name_prefix(file, UNIT_CLASS_SECTION_PREFIX);
2099 nval = (NULL != csec ? section_list_size(csec) : 0);
2100
2101 if (ok) {
2102 unit_class_iterate(uc) {
2103 int i = uclass_index(uc);
2104 const char *sec_name = section_name(section_list_get(csec, i));
2105
2106 if (secfile_lookup_int(file, &uc->min_speed, "%s.min_speed", sec_name)) {
2107 uc->min_speed *= SINGLE_MOVE;
2108 } else {
2109 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
2110 ok = FALSE;
2111 break;
2112 }
2113 if (!secfile_lookup_int(file, &uc->hp_loss_pct,
2114 "%s.hp_loss_pct", sec_name)) {
2115 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
2116 ok = FALSE;
2117 break;
2118 }
2119
2120 uc->non_native_def_pct = secfile_lookup_int_default(file, 100,
2121 "%s.non_native_def_pct",
2122 sec_name);
2123
2124 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
2125 const char *hut_str;
2126
2127 hut_str = secfile_lookup_str_default(file, "Normal",
2128 "%s.hut_behavior", sec_name);
2129 if (fc_strcasecmp(hut_str, "Normal") == 0) {
2130 uc->rscompat_cache_from_3_0.hut_behavior = HUT_NORMAL;
2131 } else if (fc_strcasecmp(hut_str, "Nothing") == 0) {
2132 uc->rscompat_cache_from_3_0.hut_behavior = HUT_NOTHING;
2133 } else if (fc_strcasecmp(hut_str, "Frighten") == 0) {
2134 uc->rscompat_cache_from_3_0.hut_behavior = HUT_FRIGHTEN;
2135 } else {
2136 ruleset_error(NULL, LOG_ERROR,
2137 "\"%s\" unit_class \"%s\":"
2138 " Illegal hut behavior \"%s\".",
2139 filename, uclass_rule_name(uc), hut_str);
2140 ok = FALSE;
2141 break;
2142 }
2143 }
2144
2145 BV_CLR_ALL(uc->flags);
2146 rscompat_uclass_flags_3_1(compat, uc);
2147 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", sec_name);
2148 for (j = 0; j < nval; j++) {
2149 sval = slist[j];
2150 if (strcmp(sval, "") == 0) {
2151 continue;
2152 }
2153 ival = unit_class_flag_id_by_name(sval, fc_strcasecmp);
2154 if (!unit_class_flag_id_is_valid(ival)) {
2155 ok = FALSE;
2156 ival = unit_type_flag_id_by_name(rscompat_utype_flag_name_3_1(compat, sval),
2157 fc_strcasecmp);
2158 if (unit_type_flag_id_is_valid(ival)) {
2159 ruleset_error(NULL, LOG_ERROR,
2160 "\"%s\" unit_class \"%s\": unit_type flag \"%s\"!",
2161 filename, uclass_rule_name(uc), sval);
2162 } else {
2163 ruleset_error(NULL, LOG_ERROR,
2164 "\"%s\" unit_class \"%s\": bad flag name \"%s\".",
2165 filename, uclass_rule_name(uc), sval);
2166 }
2167 break;
2168 } else {
2169 BV_SET(uc->flags, ival);
2170 }
2171 }
2172 free(slist);
2173
2174 uc->helptext = lookup_strvec(file, sec_name, "helptext");
2175
2176 if (!ok) {
2177 break;
2178 }
2179 } unit_class_iterate_end;
2180 }
2181
2182 if (ok) {
2183 /* Tech and Gov requirements; per unit veteran system */
2184 unit_type_iterate(u) {
2185 const int i = utype_index(u);
2186 const struct section *psection = section_list_get(sec, i);
2187 const char *sec_name = section_name(psection);
2188
2189 if (!lookup_tech(file, &u->require_advance, sec_name,
2190 "tech_req", filename,
2191 rule_name_get(&u->name))) {
2192 ok = FALSE;
2193 break;
2194 }
2195 if (u->require_advance == A_NEVER) {
2196 ruleset_error(NULL, LOG_ERROR,
2197 "%s lacks valid tech_req.",
2198 rule_name_get(&u->name));
2199 ok = FALSE;
2200 break;
2201 }
2202
2203 /* Read the government build requirement from the old ruleset format
2204 * and put it in unit_type's build_reqs requirement vector.
2205 * The build_reqs requirement vector isn't ready to be exposed in the
2206 * ruleset yet.
2207 * Barbarians can build certain units as long as anyone in the world
2208 * has the required tech. Regular players must have the required tech
2209 * them self to build the same unit. One way to solve this is to make
2210 * unit building an action enabler controlled action with a city (not
2211 * unit) actor.
2212 * Putting a requirement vector on unit types in the ruleset will
2213 * force ruleset authors to change all their unit type build
2214 * requirements to a requirement vector. Forcing them to convert their
2215 * unit type requirements again in the next version (should building be
2216 * switched to an action enabler with a city actor) is not good. */
2217 if (NULL != section_entry_by_name(psection, "gov_req")) {
2218 char tmp[200] = "\0";
2219 struct government *need_government;
2220
2221 fc_strlcat(tmp, section_name(psection), sizeof(tmp));
2222 fc_strlcat(tmp, ".gov_req", sizeof(tmp));
2223 need_government = lookup_government(file, tmp, filename, NULL);
2224 if (need_government == NULL) {
2225 ok = FALSE;
2226 break;
2227 }
2228 requirement_vector_append(&u->build_reqs, req_from_values(
2229 VUT_GOVERNMENT, REQ_RANGE_PLAYER,
2230 FALSE, TRUE, FALSE,
2231 government_number(need_government)));
2232 }
2233
2234 if (!load_ruleset_veteran(file, sec_name, &u->veteran,
2235 msg, sizeof(msg), compat)) {
2236 ruleset_error(NULL, LOG_ERROR,
2237 "Error loading the veteran system: %s",
2238 msg);
2239 ok = FALSE;
2240 break;
2241 }
2242
2243 if (!lookup_unit_type(file, sec_name, "obsolete_by",
2244 &u->obsoleted_by, filename,
2245 rule_name_get(&u->name))
2246 || !lookup_unit_type(file, sec_name, "convert_to",
2247 &u->converted_to, filename,
2248 rule_name_get(&u->name))) {
2249 ok = FALSE;
2250 break;
2251 }
2252 u->convert_time = 1; /* default */
2253 lookup_time(file, &u->convert_time, sec_name, "convert_time",
2254 filename, rule_name_get(&u->name), &ok);
2255 } unit_type_iterate_end;
2256 }
2257
2258 if (ok) {
2259 /* main stats: */
2260 unit_type_iterate(u) {
2261 const int i = utype_index(u);
2262 struct unit_class *pclass;
2263 const char *sec_name = section_name(section_list_get(sec, i));
2264 const char *str;
2265 struct impr_type *impr_req = NULL;
2266
2267 /* Read the building build requirement from the old ruleset format
2268 * and put it in unit_type's build_reqs requirement vector.
2269 * The build_reqs requirement vector isn't ready to be exposed in the
2270 * ruleset yet.
2271 * See the comment for gov_req above for why. */
2272 if (!lookup_building(file, sec_name, "impr_req",
2273 &impr_req, filename,
2274 rule_name_get(&u->name))) {
2275 ok = FALSE;
2276 break;
2277 }
2278 if (impr_req) {
2279 requirement_vector_append(&u->build_reqs, req_from_values(
2280 VUT_IMPROVEMENT, REQ_RANGE_CITY,
2281 FALSE, TRUE, FALSE,
2282 improvement_number(impr_req)));
2283 }
2284
2285 sval = secfile_lookup_str(file, "%s.class", sec_name);
2286 pclass = unit_class_by_rule_name(sval);
2287 if (!pclass) {
2288 ruleset_error(NULL, LOG_ERROR,
2289 "\"%s\" unit_type \"%s\": bad class \"%s\".",
2290 filename, utype_rule_name(u), sval);
2291 ok = FALSE;
2292 break;
2293 }
2294 u->uclass = pclass;
2295
2296 sz_strlcpy(u->sound_move,
2297 secfile_lookup_str_default(file, "-", "%s.sound_move",
2298 sec_name));
2299 sz_strlcpy(u->sound_move_alt,
2300 secfile_lookup_str_default(file, "-", "%s.sound_move_alt",
2301 sec_name));
2302 sz_strlcpy(u->sound_fight,
2303 secfile_lookup_str_default(file, "-", "%s.sound_fight",
2304 sec_name));
2305 sz_strlcpy(u->sound_fight_alt,
2306 secfile_lookup_str_default(file, "-", "%s.sound_fight_alt",
2307 sec_name));
2308
2309 if ((str = secfile_lookup_str(file, "%s.graphic", sec_name))) {
2310 sz_strlcpy(u->graphic_str, str);
2311 } else {
2312 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
2313 ok = FALSE;
2314 break;
2315 }
2316 sz_strlcpy(u->graphic_alt,
2317 secfile_lookup_str_default(file, "-", "%s.graphic_alt",
2318 sec_name));
2319
2320 if (!secfile_lookup_int(file, &u->build_cost,
2321 "%s.build_cost", sec_name)
2322 || !secfile_lookup_int(file, &u->pop_cost,
2323 "%s.pop_cost", sec_name)
2324 || !secfile_lookup_int(file, &u->attack_strength,
2325 "%s.attack", sec_name)
2326 || !secfile_lookup_int(file, &u->defense_strength,
2327 "%s.defense", sec_name)
2328 || !secfile_lookup_int(file, &u->move_rate,
2329 "%s.move_rate", sec_name)
2330 || !secfile_lookup_int(file, &u->vision_radius_sq,
2331 "%s.vision_radius_sq", sec_name)
2332 || !secfile_lookup_int(file, &u->transport_capacity,
2333 "%s.transport_cap", sec_name)
2334 || !secfile_lookup_int(file, &u->hp,
2335 "%s.hitpoints", sec_name)
2336 || !secfile_lookup_int(file, &u->firepower,
2337 "%s.firepower", sec_name)
2338 || !secfile_lookup_int(file, &u->fuel,
2339 "%s.fuel", sec_name)
2340 || !secfile_lookup_int(file, &u->happy_cost,
2341 "%s.uk_happy", sec_name)) {
2342 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
2343 ok = FALSE;
2344 break;
2345 }
2346 u->move_rate *= SINGLE_MOVE;
2347
2348 if (u->firepower <= 0) {
2349 ruleset_error(NULL, LOG_ERROR,
2350 "\"%s\" unit_type \"%s\":"
2351 " firepower is %d,"
2352 " but must be at least 1. "
2353 " If you want no attack ability,"
2354 " set the unit's attack strength to 0.",
2355 filename, utype_rule_name(u), u->firepower);
2356 ok = FALSE;
2357 break;
2358 }
2359
2360 lookup_cbonus_list(compat, u->bonuses, file, sec_name, "bonuses");
2361
2362 output_type_iterate(o) {
2363 u->upkeep[o] = secfile_lookup_int_default(file, 0, "%s.uk_%s",
2364 sec_name,
2365 get_output_identifier(o));
2366 } output_type_iterate_end;
2367
2368 slist = secfile_lookup_str_vec(file, &nval, "%s.cargo", sec_name);
2369 if (u->transport_capacity > 0) {
2370 if (nval == 0) {
2371 ruleset_error(NULL, LOG_ERROR,
2372 "\"%s\" unit type \"%s\" "
2373 "has transport_cap %d, but no cargo unit classes.",
2374 filename, utype_rule_name(u), u->transport_capacity);
2375 ok = FALSE;
2376 break;
2377 }
2378 } else {
2379 if (nval > 0) {
2380 ruleset_error(NULL, LOG_ERROR,
2381 "\"%s\" unit type \"%s\" "
2382 "has cargo defined, but transport_cap is 0.",
2383 filename, utype_rule_name(u));
2384 ok = FALSE;
2385 break;
2386 }
2387 }
2388
2389 BV_CLR_ALL(u->cargo);
2390 for (j = 0; j < nval; j++) {
2391 struct unit_class *uclass = unit_class_by_rule_name(slist[j]);
2392
2393 if (!uclass) {
2394 ruleset_error(NULL, LOG_ERROR,
2395 "\"%s\" unit_type \"%s\":"
2396 "has unknown unit class %s as cargo.",
2397 filename, utype_rule_name(u), slist[j]);
2398 ok = FALSE;
2399 break;
2400 }
2401
2402 BV_SET(u->cargo, uclass_index(uclass));
2403 }
2404 free(slist);
2405
2406 if (!ok) {
2407 break;
2408 }
2409
2410 slist = secfile_lookup_str_vec(file, &nval, "%s.targets", sec_name);
2411 BV_CLR_ALL(u->targets);
2412 for (j = 0; j < nval; j++) {
2413 struct unit_class *uclass = unit_class_by_rule_name(slist[j]);
2414
2415 if (!uclass) {
2416 ruleset_error(NULL, LOG_ERROR,
2417 "\"%s\" unit_type \"%s\":"
2418 "has unknown unit class %s as target.",
2419 filename, utype_rule_name(u), slist[j]);
2420 ok = FALSE;
2421 break;
2422 }
2423
2424 BV_SET(u->targets, uclass_index(uclass));
2425 }
2426 free(slist);
2427
2428 if (!ok) {
2429 break;
2430 }
2431
2432 slist = secfile_lookup_str_vec(file, &nval, "%s.embarks", sec_name);
2433 BV_CLR_ALL(u->embarks);
2434 for (j = 0; j < nval; j++) {
2435 struct unit_class *uclass = unit_class_by_rule_name(slist[j]);
2436
2437 if (!uclass) {
2438 ruleset_error(NULL, LOG_ERROR,
2439 "\"%s\" unit_type \"%s\":"
2440 "has unknown unit class %s as embarkable.",
2441 filename, utype_rule_name(u), slist[j]);
2442 ok = FALSE;
2443 break;
2444 }
2445
2446 BV_SET(u->embarks, uclass_index(uclass));
2447 }
2448 free(slist);
2449
2450 if (!ok) {
2451 break;
2452 }
2453
2454 slist = secfile_lookup_str_vec(file, &nval, "%s.disembarks", sec_name);
2455 BV_CLR_ALL(u->disembarks);
2456 for (j = 0; j < nval; j++) {
2457 struct unit_class *uclass = unit_class_by_rule_name(slist[j]);
2458
2459 if (!uclass) {
2460 ruleset_error(NULL, LOG_ERROR,
2461 "\"%s\" unit_type \"%s\":"
2462 "has unknown unit class %s as disembarkable.",
2463 filename, utype_rule_name(u), slist[j]);
2464 ok = FALSE;
2465 break;
2466 }
2467
2468 BV_SET(u->disembarks, uclass_index(uclass));
2469 }
2470 free(slist);
2471
2472 if (!ok) {
2473 break;
2474 }
2475
2476 /* Set also all classes that are never unreachable as targets,
2477 * embarks, and disembarks. */
2478 unit_class_iterate(preachable) {
2479 if (!uclass_has_flag(preachable, UCF_UNREACHABLE)) {
2480 BV_SET(u->targets, uclass_index(preachable));
2481 BV_SET(u->embarks, uclass_index(preachable));
2482 BV_SET(u->disembarks, uclass_index(preachable));
2483 }
2484 } unit_class_iterate_end;
2485
2486 str = secfile_lookup_str_default(file, "Main", "%s.vision_layer",
2487 sec_name);
2488 u->vlayer = vision_layer_by_name(str, fc_strcasecmp);
2489 if (!vision_layer_is_valid(u->vlayer)) {
2490 ruleset_error(NULL, LOG_ERROR,
2491 "\"%s\" unit_type \"%s\":"
2492 "has unknown vision layer %s.",
2493 filename, utype_rule_name(u), str);
2494 ok = FALSE;
2495 break;
2496 }
2497
2498 u->helptext = lookup_strvec(file, sec_name, "helptext");
2499
2500 u->paratroopers_range = secfile_lookup_int_default(file,
2501 0, "%s.paratroopers_range", sec_name);
2502 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
2503 u->rscompat_cache.paratroopers_mr_req
2504 = SINGLE_MOVE * secfile_lookup_int_default(
2505 file, 0, "%s.paratroopers_mr_req", sec_name);
2506 u->rscompat_cache.paratroopers_mr_sub
2507 = SINGLE_MOVE * secfile_lookup_int_default(
2508 file, 0, "%s.paratroopers_mr_sub", sec_name);
2509 } else {
2510 u->rscompat_cache.paratroopers_mr_req = 0;
2511 u->rscompat_cache.paratroopers_mr_sub = 0;
2512 }
2513 u->bombard_rate = secfile_lookup_int_default(file, 0,
2514 "%s.bombard_rate", sec_name);
2515 u->city_slots = secfile_lookup_int_default(file, 0,
2516 "%s.city_slots", sec_name);
2517 u->city_size = secfile_lookup_int_default(file, 1,
2518 "%s.city_size", sec_name);
2519
2520 sval = secfile_lookup_str_default(file, transp_def_type_name(TDT_ALIGHT),
2521 "%s.tp_defense", sec_name);
2522 u->tp_defense = transp_def_type_by_name(sval, fc_strcasecmp);
2523 if (!transp_def_type_is_valid(u->tp_defense)) {
2524 ruleset_error(NULL, LOG_ERROR,
2525 "\"%s\" unit_type \"%s\":"
2526 " bad tp_defense \"%s\".",
2527 filename, utype_rule_name(u), sval);
2528 ok = FALSE;
2529 break;
2530 }
2531 } unit_type_iterate_end;
2532 }
2533
2534 if (ok) {
2535 /* flags */
2536 unit_type_iterate(u) {
2537 const int i = utype_index(u);
2538
2539 BV_CLR_ALL(u->flags);
2540 fc_assert(!utype_has_flag(u, UTYF_LAST_USER_FLAG - 1));
2541
2542 slist = secfile_lookup_str_vec(file, &nval, "%s.flags",
2543 section_name(section_list_get(sec, i)));
2544 for (j = 0; j < nval; j++) {
2545 sval = slist[j];
2546 if (0 == strcmp(sval, "")) {
2547 continue;
2548 }
2549 if (compat->compat_mode && !fc_strcasecmp("Partial_Invis", sval)) {
2550 u->vlayer = V_INVIS;
2551 } else {
2552 ival = unit_type_flag_id_by_name(rscompat_utype_flag_name_3_1(compat, sval),
2553 fc_strcasecmp);
2554 if (!unit_type_flag_id_is_valid(ival)) {
2555 ok = FALSE;
2556 ival = unit_class_flag_id_by_name(sval, fc_strcasecmp);
2557 if (unit_class_flag_id_is_valid(ival)) {
2558 ruleset_error(NULL, LOG_ERROR,
2559 "\"%s\" unit_type \"%s\": unit_class flag!",
2560 filename, utype_rule_name(u));
2561 } else {
2562 ruleset_error(NULL, LOG_ERROR,
2563 "\"%s\" unit_type \"%s\": bad flag name \"%s\".",
2564 filename, utype_rule_name(u), sval);
2565 }
2566 break;
2567 } else {
2568 BV_SET(u->flags, ival);
2569 }
2570 fc_assert(utype_has_flag(u, ival));
2571 }
2572 }
2573 free(slist);
2574
2575 if (!ok) {
2576 break;
2577 }
2578 } unit_type_iterate_end;
2579 }
2580
2581 /* roles */
2582 if (ok) {
2583 unit_type_iterate(u) {
2584 const int i = utype_index(u);
2585
2586 BV_CLR_ALL(u->roles);
2587
2588 slist = secfile_lookup_str_vec(file, &nval, "%s.roles",
2589 section_name(section_list_get(sec, i)));
2590 for (j = 0; j < nval; j++) {
2591 sval = slist[j];
2592 if (strcmp(sval, "") == 0) {
2593 continue;
2594 }
2595 ival = unit_role_id_by_name(sval, fc_strcasecmp);
2596 if (!unit_role_id_is_valid(ival)) {
2597 ruleset_error(NULL, LOG_ERROR,
2598 "\"%s\" unit_type \"%s\": bad role name \"%s\".",
2599 filename, utype_rule_name(u), sval);
2600 ok = FALSE;
2601 break;
2602 } else {
2603 BV_SET(u->roles, ival - L_FIRST);
2604 }
2605 fc_assert(utype_has_role(u, ival));
2606 }
2607 free(slist);
2608 } unit_type_iterate_end;
2609 }
2610
2611 if (ok) {
2612 /* Some more consistency checking: */
2613 unit_type_iterate(u) {
2614 if (!valid_advance(u->require_advance)) {
2615 ruleset_error(NULL, LOG_ERROR,
2616 "\"%s\" unit_type \"%s\": depends on removed tech \"%s\".",
2617 filename, utype_rule_name(u),
2618 advance_rule_name(u->require_advance));
2619 u->require_advance = A_NEVER;
2620 ok = FALSE;
2621 break;
2622 }
2623 } unit_type_iterate_end;
2624 }
2625
2626 section_list_destroy(csec);
2627 section_list_destroy(sec);
2628
2629 if (ok) {
2630 secfile_check_unused(file);
2631 }
2632
2633 return ok;
2634}
2635
2636/**********************************************************************/
2640 static bool load_building_names(struct section_file *file,
2641 struct rscompat_info *compat)
2642{
2643 struct section_list *sec;
2644 int i, nval = 0;
2645 const char *filename = secfile_name(file);
2646 bool ok = TRUE;
2647
2648 if (!rscompat_check_cap_and_version(file, filename, compat)) {
2649 return FALSE;
2650 }
2651
2652 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
2653 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
2654
2655 /* The names: */
2656 sec = secfile_sections_by_name_prefix(file, BUILDING_SECTION_PREFIX);
2657 if (NULL == sec || 0 == (nval = section_list_size(sec))) {
2658 ruleset_error(NULL, LOG_ERROR,
2659 "\"%s\": No improvements?!?", filename);
2660 ok = FALSE;
2661 } else {
2662 log_verbose("%d improvement types (including possibly unused)", nval);
2663 if (nval > B_LAST) {
2664 ruleset_error(NULL, LOG_ERROR,
2665 "\"%s\": Too many improvements (%d, max %d)",
2666 filename, nval, B_LAST);
2667 ok = FALSE;
2668 }
2669 }
2670
2671 if (ok) {
2672 game.control.num_impr_types = nval;
2673
2674 for (i = 0; i < nval; i++) {
2675 struct impr_type *b = improvement_by_number(i);
2676
2677 if (!ruleset_load_names(&b->name, NULL, file, section_name(section_list_get(sec, i)))) {
2678 ok = FALSE;
2679 break;
2680 }
2681 }
2682 }
2683
2684 section_list_destroy(sec);
2685
2686 return ok;
2687}
2688
2689/**********************************************************************/
2692 static bool load_ruleset_buildings(struct section_file *file,
2693 struct rscompat_info *compat)
2694{
2695 struct section_list *sec;
2696 const char *item;
2697 int i, nval;
2698 const char *filename = secfile_name(file);
2699 bool ok = TRUE;
2700
2701 sec = secfile_sections_by_name_prefix(file, BUILDING_SECTION_PREFIX);
2702 nval = (NULL != sec ? section_list_size(sec) : 0);
2703
2704 for (i = 0; i < nval && ok; i++) {
2705 struct impr_type *b = improvement_by_number(i);
2706 const char *sec_name = section_name(section_list_get(sec, i));
2707 struct requirement_vector *reqs =
2708 lookup_req_list(file, compat, sec_name, "reqs",
2709 improvement_rule_name(b));
2710
2711 if (reqs == NULL) {
2712 ok = FALSE;
2713 break;
2714 } else {
2715 const char *sval, **slist;
2716 int j, ival;
2717 size_t nflags;
2718
2719 item = secfile_lookup_str(file, "%s.genus", sec_name);
2720 b->genus = impr_genus_id_by_name(item, fc_strcasecmp);
2721 if (!impr_genus_id_is_valid(b->genus)) {
2722 ruleset_error(NULL, LOG_ERROR,
2723 "\"%s\" improvement \"%s\": couldn't match "
2724 "genus \"%s\".", filename,
2725 improvement_rule_name(b), item);
2726 ok = FALSE;
2727 break;
2728 }
2729
2730 slist = secfile_lookup_str_vec(file, &nflags, "%s.flags", sec_name);
2731 BV_CLR_ALL(b->flags);
2732
2733 for (j = 0; j < nflags; j++) {
2734 sval = slist[j];
2735 if (strcmp(sval, "") == 0) {
2736 continue;
2737 }
2738 ival = impr_flag_id_by_name(sval, fc_strcasecmp);
2739 if (!impr_flag_id_is_valid(ival)) {
2740 ruleset_error(NULL, LOG_ERROR,
2741 "\"%s\" improvement \"%s\": bad flag name \"%s\".",
2742 filename, improvement_rule_name(b), sval);
2743 ok = FALSE;
2744 break;
2745 } else {
2746 BV_SET(b->flags, ival);
2747 }
2748 }
2749 free(slist);
2750
2751 if (!ok) {
2752 break;
2753 }
2754
2755 requirement_vector_copy(&b->reqs, reqs);
2756
2757 {
2758 struct requirement_vector *obs_reqs =
2759 lookup_req_list(file, compat, sec_name, "obsolete_by",
2760 improvement_rule_name(b));
2761
2762 if (obs_reqs == NULL) {
2763 ok = FALSE;
2764 break;
2765 } else {
2766 requirement_vector_copy(&b->obsolete_by, obs_reqs);
2767 }
2768 }
2769
2770 if (!secfile_lookup_int(file, &b->build_cost,
2771 "%s.build_cost", sec_name)
2772 || !secfile_lookup_int(file, &b->upkeep,
2773 "%s.upkeep", sec_name)
2774 || !secfile_lookup_int(file, &b->sabotage,
2775 "%s.sabotage", sec_name)) {
2776 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
2777 ok = FALSE;
2778 break;
2779 }
2780
2781 sz_strlcpy(b->graphic_str,
2782 secfile_lookup_str_default(file, "-",
2783 "%s.graphic", sec_name));
2784 sz_strlcpy(b->graphic_alt,
2785 secfile_lookup_str_default(file, "-",
2786 "%s.graphic_alt", sec_name));
2787
2788 sz_strlcpy(b->soundtag,
2789 secfile_lookup_str_default(file, "-",
2790 "%s.sound", sec_name));
2791 sz_strlcpy(b->soundtag_alt,
2792 secfile_lookup_str_default(file, "-",
2793 "%s.sound_alt", sec_name));
2794 b->helptext = lookup_strvec(file, sec_name, "helptext");
2795 }
2796 }
2797
2798 section_list_destroy(sec);
2799 if (ok) {
2800 secfile_check_unused(file);
2801 }
2802
2803 return ok;
2804}
2805
2806/**********************************************************************/
2810 static bool load_terrain_names(struct section_file *file,
2811 struct rscompat_info *compat)
2812{
2813 int nval = 0;
2814 struct section_list *sec = NULL;
2815 const char *flag;
2816 int i;
2817 const char *filename = secfile_name(file);
2818 bool ok = TRUE;
2819
2820 if (!rscompat_check_cap_and_version(file, filename, compat)) {
2821 return FALSE;
2822 }
2823
2824 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
2825 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
2826
2827 /* User terrain flag names */
2828 for (i = 0; (flag = secfile_lookup_str_default(file, NULL, "control.flags%d.name", i)) ;
2829 i++) {
2830 const char *helptxt = secfile_lookup_str_default(file, NULL, "control.flags%d.helptxt",
2831 i);
2832
2833 if (terrain_flag_id_by_name(flag, fc_strcasecmp)
2834 != terrain_flag_id_invalid()) {
2835 ruleset_error(NULL, LOG_ERROR,
2836 "\"%s\": Duplicate terrain flag name '%s'",
2837 filename, flag);
2838 ok = FALSE;
2839 break;
2840 }
2841 if (i > MAX_NUM_USER_TER_FLAGS) {
2842 ruleset_error(NULL, LOG_ERROR,
2843 "\"%s\": Too many user terrain flags!",
2844 filename);
2845 ok = FALSE;
2846 break;
2847 }
2848
2849 set_user_terrain_flag_name(TER_USER_1 + i, flag, helptxt);
2850 }
2851
2852 if (ok) {
2853 /* Blank the remaining terrain user flag slots. */
2854 for (; i < MAX_NUM_USER_TER_FLAGS; i++) {
2855 set_user_terrain_flag_name(TER_USER_1 + i, NULL, NULL);
2856 }
2857 }
2858
2859 /* User extra flag names */
2860 for (i = 0;
2861 (flag = secfile_lookup_str_default(file, NULL,
2862 "control.extra_flags%d.name",
2863 i));
2864 i++) {
2865 const char *helptxt = secfile_lookup_str_default(file, NULL,
2866 "control.extra_flags%d.helptxt", i);
2867
2868 if (extra_flag_id_by_name(flag, fc_strcasecmp)
2869 != extra_flag_id_invalid()) {
2870 ruleset_error(NULL, LOG_ERROR,
2871 "\"%s\": Duplicate extra flag name '%s'",
2872 filename, flag);
2873 ok = FALSE;
2874 break;
2875 }
2876 if (i > MAX_NUM_USER_EXTRA_FLAGS) {
2877 ruleset_error(NULL, LOG_ERROR,
2878 "\"%s\": Too many user extra flags!",
2879 filename);
2880 ok = FALSE;
2881 break;
2882 }
2883
2884 set_user_extra_flag_name(EF_USER_FLAG_1 + i, flag, helptxt);
2885 }
2886
2887 if (ok) {
2888 /* Blank the remaining extra user flag slots. */
2889 for (; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
2890 set_user_extra_flag_name(EF_USER_FLAG_1 + i, NULL, NULL);
2891 }
2892
2893 /* terrain names */
2894
2895 sec = secfile_sections_by_name_prefix(file, TERRAIN_SECTION_PREFIX);
2896 if (NULL == sec || 0 == (nval = section_list_size(sec))) {
2897 ruleset_error(NULL, LOG_ERROR,
2898 "\"%s\": ruleset doesn't have any terrains.",
2899 filename);
2900 ok = FALSE;
2901 } else {
2902 if (nval > MAX_NUM_TERRAINS) {
2903 ruleset_error(NULL, LOG_ERROR,
2904 "\"%s\": Too many terrains (%d, max %d)",
2905 filename, nval, MAX_NUM_TERRAINS);
2906 ok = FALSE;
2907 }
2908 }
2909 }
2910
2911 if (ok) {
2912 game.control.terrain_count = nval;
2913
2914 /* avoid re-reading files */
2915 if (terrain_sections) {
2916 free(terrain_sections);
2917 }
2918 terrain_sections = fc_calloc(nval, MAX_SECTION_LABEL);
2919
2920 terrain_type_iterate(pterrain) {
2921 const int terri = terrain_index(pterrain);
2922 const char *sec_name = section_name(section_list_get(sec, terri));
2923
2924 if (!ruleset_load_names(&pterrain->name, NULL, file, sec_name)) {
2925 ok = FALSE;
2926 break;
2927 }
2928
2929 section_strlcpy(&terrain_sections[terri * MAX_SECTION_LABEL], sec_name);
2930 } terrain_type_iterate_end;
2931 }
2932
2933 section_list_destroy(sec);
2934 sec = NULL;
2935
2936 /* extra names */
2937
2938 if (ok) {
2939 sec = secfile_sections_by_name_prefix(file, EXTRA_SECTION_PREFIX);
2940 nval = (NULL != sec ? section_list_size(sec) : 0);
2941 if (nval > MAX_EXTRA_TYPES) {
2942 ruleset_error(NULL, LOG_ERROR,
2943 "\"%s\": Too many extra types (%d, max %d)",
2944 filename, nval, MAX_EXTRA_TYPES);
2945 ok = FALSE;
2946 }
2947 }
2948
2949 if (ok) {
2950 int idx;
2951
2952 game.control.num_extra_types = nval;
2953
2954 if (extra_sections) {
2955 free(extra_sections);
2956 }
2957 extra_sections = fc_calloc(nval, MAX_SECTION_LABEL);
2958
2959 if (ok) {
2960 for (idx = 0; idx < nval; idx++) {
2961 const char *sec_name = section_name(section_list_get(sec, idx));
2962 struct extra_type *pextra = extra_by_number(idx);
2963
2964 if (!ruleset_load_names(&pextra->name, NULL, file, sec_name)) {
2965 ok = FALSE;
2966 break;
2967 }
2968 section_strlcpy(&extra_sections[idx * MAX_SECTION_LABEL], sec_name);
2969 }
2970 }
2971 }
2972
2973 section_list_destroy(sec);
2974 sec = NULL;
2975
2976 /* Base names */
2977
2978 if (ok) {
2979 sec = secfile_sections_by_name_prefix(file, BASE_SECTION_PREFIX);
2980 nval = (NULL != sec ? section_list_size(sec) : 0);
2981 if (nval > MAX_EXTRA_TYPES) {
2982 ruleset_error(NULL, LOG_ERROR,
2983 "\"%s\": Too many base types (%d, max %d)",
2984 filename, nval, MAX_EXTRA_TYPES);
2985 ok = FALSE;
2986 }
2987
2988 game.control.num_base_types = nval;
2989 }
2990
2991 if (ok) {
2992 int idx;
2993
2994 if (base_sections) {
2995 free(base_sections);
2996 }
2997 base_sections = fc_calloc(nval, MAX_SECTION_LABEL);
2998
2999 /* Cannot use base_type_iterate() before bases are added to
3000 * EC_BASE caused_by list. Have to get them by extra_type_by_rule_name() */
3001 for (idx = 0; idx < nval; idx++) {
3002 const char *sec_name = section_name(section_list_get(sec, idx));
3003 const char *base_name = secfile_lookup_str(file, "%s.extra", sec_name);
3004
3005 if (base_name != NULL) {
3006 struct extra_type *pextra = extra_type_by_rule_name(base_name);
3007
3008 if (pextra != NULL) {
3009 base_type_init(pextra, idx);
3010 section_strlcpy(&base_sections[idx * MAX_SECTION_LABEL], sec_name);
3011 } else {
3012 ruleset_error(NULL, LOG_ERROR,
3013 "No extra definition matching base definition \"%s\"",
3014 base_name);
3015 ok = FALSE;
3016 }
3017 } else {
3018 ruleset_error(NULL, LOG_ERROR,
3019 "Base section \"%s\" does not associate base with any extra",
3020 sec_name);
3021 ok = FALSE;
3022 }
3023 }
3024 }
3025
3026 section_list_destroy(sec);
3027 sec = NULL;
3028
3029 /* Road names */
3030
3031 if (ok) {
3032 sec = secfile_sections_by_name_prefix(file, ROAD_SECTION_PREFIX);
3033 nval = (NULL != sec ? section_list_size(sec) : 0);
3034 if (nval > MAX_EXTRA_TYPES) {
3035 ruleset_error(NULL, LOG_ERROR,
3036 "\"%s\": Too many road types (%d, max %d)",
3037 filename, nval, MAX_EXTRA_TYPES);
3038 ok = FALSE;
3039 }
3040
3041 game.control.num_road_types = nval;
3042 }
3043
3044 if (ok) {
3045 int idx;
3046
3047 if (road_sections) {
3048 free(road_sections);
3049 }
3050 road_sections = fc_calloc(nval, MAX_SECTION_LABEL);
3051
3052 /* Cannot use extra_type_by_cause_iterate(EC_ROAD) before roads are added to
3053 * EC_ROAD caused_by list. Have to get them by extra_type_by_rule_name() */
3054 for (idx = 0; idx < nval; idx++) {
3055 const char *sec_name = section_name(section_list_get(sec, idx));
3056 const char *road_name = secfile_lookup_str(file, "%s.extra", sec_name);
3057
3058 if (road_name != NULL) {
3059 struct extra_type *pextra = extra_type_by_rule_name(road_name);
3060
3061 if (pextra != NULL) {
3062 road_type_init(pextra, idx);
3063 section_strlcpy(&road_sections[idx * MAX_SECTION_LABEL], sec_name);
3064 } else {
3065 ruleset_error(NULL, LOG_ERROR,
3066 "No extra definition matching road definition \"%s\"",
3067 road_name);
3068 ok = FALSE;
3069 }
3070 } else {
3071 ruleset_error(NULL, LOG_ERROR,
3072 "Road section \"%s\" does not associate road with any extra",
3073 sec_name);
3074 ok = FALSE;
3075 }
3076 }
3077 }
3078
3079 section_list_destroy(sec);
3080 sec = NULL;
3081
3082 /* resource names */
3083
3084 if (ok) {
3085 sec = secfile_sections_by_name_prefix(file, RESOURCE_SECTION_PREFIX);
3086 nval = (NULL != sec ? section_list_size(sec) : 0);
3087 if (nval > MAX_RESOURCE_TYPES) {
3088 ruleset_error(NULL, LOG_ERROR,
3089 "\"%s\": Too many resource types (%d, max %d)",
3090 filename, nval, MAX_RESOURCE_TYPES);
3091 ok = FALSE;
3092 }
3093
3094 game.control.num_resource_types = nval;
3095 }
3096
3097 if (ok) {
3098 int idx;
3099
3100 if (resource_sections) {
3101 free(resource_sections);
3102 }
3103 resource_sections = fc_calloc(nval, MAX_SECTION_LABEL);
3104
3105 /* Cannot use resource_type_iterate() before resource are added to
3106 * EC_RESOURCE caused_by list. Have to get them by extra_type_by_rule_name() */
3107 for (idx = 0; idx < nval; idx++) {
3108 const char *sec_name = section_name(section_list_get(sec, idx));
3109 const char *resource_name;
3110 struct extra_type *pextra = NULL;
3111
3112 resource_name = secfile_lookup_str_default(file, NULL, "%s.extra", sec_name);
3113
3114 if (resource_name != NULL) {
3115 pextra = extra_type_by_rule_name(resource_name);
3116
3117 if (pextra != NULL) {
3118 resource_type_init(pextra);
3119 section_strlcpy(&resource_sections[idx * MAX_SECTION_LABEL], sec_name);
3120 } else {
3121 ruleset_error(NULL, LOG_ERROR,
3122 "No extra definition matching resource definition \"%s\"",
3123 resource_name);
3124 ok = FALSE;
3125 }
3126 } else {
3127 ruleset_error(NULL, LOG_ERROR,
3128 "Resource section %s does not list extra this resource belongs to.",
3129 sec_name);
3130 ok = FALSE;
3131 }
3132 }
3133 }
3134
3135 section_list_destroy(sec);
3136
3137 return ok;
3138}
3139
3140/**********************************************************************/
3143 static bool load_ruleset_terrain(struct section_file *file,
3144 struct rscompat_info *compat)
3145{
3146 size_t nval;
3147 int j;
3148 bool compat_road = FALSE;
3149 bool compat_rail = FALSE;
3150 bool compat_river = FALSE;
3151 const char **res;
3152 const char *filename = secfile_name(file);
3153 const char *text;
3154 bool ok = TRUE;
3155
3156 /* parameters */
3157
3158 terrain_control.ocean_reclaim_requirement_pct
3159 = secfile_lookup_int_default(file, 101,
3160 "parameters.ocean_reclaim_requirement");
3161 terrain_control.land_channel_requirement_pct
3162 = secfile_lookup_int_default(file, 101,
3163 "parameters.land_channel_requirement");
3164 terrain_control.terrain_thaw_requirement_pct
3165 = secfile_lookup_int_default(file, 101,
3166 "parameters.thaw_requirement");
3167 terrain_control.terrain_freeze_requirement_pct
3168 = secfile_lookup_int_default(file, 101,
3169 "parameters.freeze_requirement");
3170 terrain_control.lake_max_size
3171 = secfile_lookup_int_default(file, 0,
3172 "parameters.lake_max_size");
3173 terrain_control.min_start_native_area
3174 = secfile_lookup_int_default(file, 0,
3175 "parameters.min_start_native_area");
3176 terrain_control.move_fragments
3177 = secfile_lookup_int_default(file, 3,
3178 "parameters.move_fragments");
3179 if (terrain_control.move_fragments < 1) {
3180 ruleset_error(NULL, LOG_ERROR,
3181 "\"%s\": move_fragments must be at least 1",
3182 filename);
3183 ok = FALSE;
3184 }
3185 init_move_fragments();
3186 terrain_control.igter_cost
3187 = secfile_lookup_int_default(file, 1,
3188 "parameters.igter_cost");
3189 if (terrain_control.igter_cost < 1) {
3190 ruleset_error(NULL, LOG_ERROR,
3191 "\"%s\": igter_cost must be at least 1",
3192 filename);
3193 ok = FALSE;
3194 }
3195 terrain_control.infrapoints = FALSE; /* This will be updated if we find
3196 * an placeable extra. */
3197
3198 terrain_control.pythagorean_diagonal
3199 = secfile_lookup_bool_default(file, RS_DEFAULT_PYTHAGOREAN_DIAGONAL,
3200 "parameters.pythagorean_diagonal");
3201
3202 wld.map.server.ocean_resources
3203 = secfile_lookup_bool_default(file, FALSE,
3204 "parameters.ocean_resources");
3205
3206 text = secfile_lookup_str_default(file,
3207 N_("?gui_type:Build Type A Base"),
3208 "extraui.ui_name_base_fortress");
3209 sz_strlcpy(terrain_control.gui_type_base0, text);
3210
3211 text = secfile_lookup_str_default(file,
3212 N_("?gui_type:Build Type B Base"),
3213 "extraui.ui_name_base_airbase");
3214 sz_strlcpy(terrain_control.gui_type_base1, text);
3215
3216 if (ok) {
3217 /* terrain details */
3218
3219 terrain_type_iterate(pterrain) {
3220 const char **slist;
3221 const int i = terrain_index(pterrain);
3222 const char *tsection = &terrain_sections[i * MAX_SECTION_LABEL];
3223 const char *cstr;
3224
3225 sz_strlcpy(pterrain->graphic_str,
3226 secfile_lookup_str(file, "%s.graphic", tsection));
3227 sz_strlcpy(pterrain->graphic_alt,
3228 secfile_lookup_str(file, "%s.graphic_alt", tsection));
3229
3230 pterrain->identifier
3231 = secfile_lookup_str(file, "%s.identifier", tsection)[0];
3232 if ('\0' == pterrain->identifier) {
3233 ruleset_error(NULL, LOG_ERROR,
3234 "\"%s\" [%s] identifier missing value.",
3235 filename, tsection);
3236 ok = FALSE;
3237 break;
3238 }
3239 if (TERRAIN_UNKNOWN_IDENTIFIER == pterrain->identifier) {
3240 ruleset_error(NULL, LOG_ERROR,
3241 "\"%s\" [%s] cannot use '%c' as an identifier;"
3242 " it is reserved for unknown terrain.",
3243 filename, tsection, pterrain->identifier);
3244 ok = FALSE;
3245 break;
3246 }
3247 for (j = T_FIRST; j < i; j++) {
3248 if (pterrain->identifier == terrain_by_number(j)->identifier) {
3249 ruleset_error(NULL, LOG_ERROR,
3250 "\"%s\" [%s] has the same identifier as [%s].",
3251 filename, tsection,
3252 &terrain_sections[j * MAX_SECTION_LABEL]);
3253 ok = FALSE;
3254 break;
3255 }
3256 }
3257
3258 if (!ok) {
3259 break;
3260 }
3261
3262 cstr = secfile_lookup_str(file, "%s.class", tsection);
3263 pterrain->tclass = terrain_class_by_name(cstr, fc_strcasecmp);
3264 if (!terrain_class_is_valid(pterrain->tclass)) {
3265 ruleset_error(NULL, LOG_ERROR,
3266 "\"%s\": [%s] unknown class \"%s\"",
3267 filename, tsection, cstr);
3268 ok = FALSE;
3269 break;
3270 }
3271
3272 if (!secfile_lookup_int(file, &pterrain->movement_cost,
3273 "%s.movement_cost", tsection)
3274 || !secfile_lookup_int(file, &pterrain->defense_bonus,
3275 "%s.defense_bonus", tsection)) {
3276 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
3277 ok = FALSE;
3278 break;
3279 }
3280
3281 output_type_iterate(o) {
3282 pterrain->output[o]
3283 = secfile_lookup_int_default(file, 0, "%s.%s", tsection,
3284 get_output_identifier(o));
3285 } output_type_iterate_end;
3286
3287 res = secfile_lookup_str_vec(file, &nval, "%s.resources", tsection);
3288 pterrain->resources = fc_calloc(nval + 1, sizeof(*pterrain->resources));
3289 for (j = 0; j < nval; j++) {
3290 pterrain->resources[j] = lookup_resource(filename, res[j], tsection);
3291 if (pterrain->resources[j] == NULL) {
3292 ok = FALSE;
3293 break;
3294 }
3295 }
3296 pterrain->resources[nval] = NULL;
3297 free(res);
3298 res = NULL;
3299
3300 if (!ok) {
3301 break;
3302 }
3303
3304 output_type_iterate(o) {
3305 pterrain->road_output_incr_pct[o]
3306 = secfile_lookup_int_default(file, 0, "%s.road_%s_incr_pct",
3307 tsection, get_output_identifier(o));
3308 } output_type_iterate_end;
3309
3310 if (!lookup_time(file, &pterrain->base_time, tsection, "base_time",
3311 filename, NULL, &ok)
3312 || !lookup_time(file, &pterrain->road_time, tsection, "road_time",
3313 filename, NULL, &ok)) {
3314 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
3315 ok = FALSE;
3316 break;
3317 }
3318
3319 if (!lookup_terrain(file, "cultivate_result", filename, pterrain,
3320 &pterrain->cultivate_result, FALSE)) {
3321 if (compat->compat_mode) {
3322 if (!lookup_terrain(file, "irrigation_result", filename, pterrain,
3323 &pterrain->cultivate_result, TRUE)) {
3324 ok = FALSE;
3325 break;
3326 }
3327 } else {
3328 ruleset_error(NULL, LOG_ERROR, "%s: No cultivate_result", tsection);
3329 ok = FALSE;
3330 break;
3331 }
3332 }
3333 if (!compat->compat_mode && pterrain->cultivate_result == pterrain) {
3334 ruleset_error(NULL, LOG_ERROR,
3335 "%s: Cultivating result in terrain itself.",
3336 tsection);
3337 ok = FALSE;
3338 break;
3339 }
3340 if (!secfile_lookup_int(file, &pterrain->irrigation_food_incr,
3341 "%s.irrigation_food_incr", tsection)
3342 || !lookup_time(file, &pterrain->irrigation_time,
3343 tsection, "irrigation_time", filename, NULL, &ok)) {
3344 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
3345 ok = FALSE;
3346 break;
3347 }
3348
3349 if (!lookup_terrain(file, "plant_result", filename, pterrain,
3350 &pterrain->plant_result, FALSE)) {
3351 if (compat->compat_mode) {
3352 if (!lookup_terrain(file, "mining_result", filename, pterrain,
3353 &pterrain->plant_result, TRUE)) {
3354 ok = FALSE;
3355 break;
3356 }
3357 } else {
3358 ruleset_error(NULL, LOG_ERROR, "%s: No plant_result", tsection);
3359 ok = FALSE;
3360 break;
3361 }
3362 }
3363 if (!compat->compat_mode && pterrain->plant_result == pterrain) {
3364 ruleset_error(NULL, LOG_ERROR,
3365 "%s: Planting result in terrain itself.",
3366 tsection);
3367 ok = FALSE;
3368 break;
3369 }
3370 if (!secfile_lookup_int(file, &pterrain->mining_shield_incr,
3371 "%s.mining_shield_incr", tsection)
3372 || !lookup_time(file, &pterrain->mining_time,
3373 tsection, "mining_time", filename, NULL, &ok)) {
3374 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
3375 ok = FALSE;
3376 break;
3377 }
3378
3379 if (!lookup_time(file, &pterrain->cultivate_time,
3380 tsection, "cultivate_time", filename, NULL, &ok)) {
3381 if (compat->compat_mode) {
3382 if (pterrain->cultivate_result != pterrain) {
3383 if (pterrain->cultivate_result == NULL && pterrain->irrigation_time != 0) {
3384 /* Make sure cultivate_time is zero when cultivate_result is "no".
3385 * In S3_0 it was legal to have any kind of _time value when _result was "no",
3386 * it was just ignored. We no longer accept that. */
3387 if (compat->log_cb != NULL) {
3388 char buf[512];
3389
3390 fc_snprintf(buf, sizeof(buf),
3391 "Changed %s cultivate_time to zero, as it inconsistently had "
3392 "irrigation_result \"no\" and nonzero irrigation_time.",
3393 tsection);
3394 compat->log_cb(buf);
3395 }
3396 pterrain->cultivate_time = 0;
3397 } else {
3398 pterrain->cultivate_time = pterrain->irrigation_time;
3399 }
3400 pterrain->irrigation_time = 0;
3401 } else {
3402 pterrain->cultivate_time = 0;
3403 pterrain->cultivate_result = NULL;
3404 }
3405 } else {
3406 ruleset_error(NULL, LOG_ERROR,
3407 "%s: Missing cultivate_time", tsection);
3408 ok = FALSE;
3409 break;
3410 }
3411 }
3412 if ((pterrain->cultivate_result != NULL
3413 && pterrain->cultivate_time <= 0)
3414 || (pterrain->cultivate_result == NULL
3415 && pterrain->cultivate_time > 0)) {
3416 ruleset_error(NULL, LOG_ERROR,
3417 "%s: cultivate_result and cultivate_time disagree "
3418 "whether cultivating is enabled", tsection);
3419 ok = FALSE;
3420 break;
3421 }
3422
3423 if (!lookup_time(file, &pterrain->plant_time,
3424 tsection, "plant_time", filename, NULL, &ok)) {
3425 if (compat->compat_mode) {
3426 if (pterrain->plant_result != pterrain) {
3427 if (pterrain->plant_result == NULL && pterrain->mining_time != 0) {
3428 /* Make sure plant_time is zero when plant_result is "no".
3429 * In S3_0 it was legal to have any kind of _time value when _result was "no",
3430 * it was just ignored. We no longer accept that. */
3431 if (compat->log_cb != NULL) {
3432 char buf[512];
3433
3434 fc_snprintf(buf, sizeof(buf),
3435 "Changed %s plant_time to zero, as it inconsistently had "
3436 "mining_result \"no\" and nonzero mining_time.",
3437 tsection);
3438 compat->log_cb(buf);
3439 }
3440 pterrain->plant_time = 0;
3441 } else {
3442 pterrain->plant_time = pterrain->mining_time;
3443 }
3444 pterrain->mining_time = 0;
3445 } else {
3446 pterrain->plant_time = 0;
3447 pterrain->plant_result = NULL;
3448 }
3449 } else {
3450 ruleset_error(NULL, LOG_ERROR, "%s: Missing plant_time", tsection);
3451 ok = FALSE;
3452 break;
3453 }
3454
3455 }
3456 if ((pterrain->plant_result != NULL
3457 && pterrain->plant_time <= 0)
3458 || (pterrain->plant_result == NULL
3459 && pterrain->plant_time > 0)) {
3460 ruleset_error(NULL, LOG_ERROR,
3461 "%s: plant_result and plant_time disagree "
3462 "whether planting is enabled", tsection);
3463 ok = FALSE;
3464 break;
3465 }
3466
3467 if (!lookup_unit_type(file, tsection, "animal",
3468 &pterrain->animal, filename,
3469 rule_name_get(&pterrain->name))) {
3470 ok = FALSE;
3471 break;
3472 }
3473
3474 if (!lookup_terrain(file, "transform_result", filename, pterrain,
3475 &pterrain->transform_result, TRUE)) {
3476 ok = FALSE;
3477 break;
3478 }
3479 if (!lookup_time(file, &pterrain->transform_time,
3480 tsection, "transform_time", filename, NULL, &ok)) {
3481 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
3482 ok = FALSE;
3483 break;
3484 }
3485 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
3486 if (pterrain->transform_time <= 0) {
3487 /* Transform time of zero was documented to disable the transform
3488 * regardless of given transform result in earlier versions, i.e.,
3489 * having them inconsistent was not an error. */
3490 pterrain->transform_result = NULL;
3491 } else if (pterrain->transform_result == NULL) {
3492 pterrain->transform_time = 0;
3493 }
3494 }
3495 if ((pterrain->transform_result != NULL
3496 && pterrain->transform_time <= 0)
3497 || (pterrain->transform_result == NULL
3498 && pterrain->transform_time > 0)) {
3499 ruleset_error(NULL, LOG_ERROR,
3500 "%s: transform_result and transform_time disagree "
3501 "whether transforming is enabled", tsection);
3502 ok = FALSE;
3503 break;
3504 }
3505
3506 pterrain->placing_time = 1; /* default */
3507 lookup_time(file, &pterrain->placing_time,
3508 tsection, "placing_time", filename, NULL, &ok);
3509
3510 pterrain->pillage_time = 1; /* default */
3511 lookup_time(file, &pterrain->pillage_time,
3512 tsection, "pillage_time", filename, NULL, &ok);
3513 pterrain->clean_pollution_time = 3; /* default */
3514 lookup_time(file, &pterrain->clean_pollution_time,
3515 tsection, "clean_pollution_time", filename, NULL, &ok);
3516 pterrain->clean_fallout_time = 3; /* default */
3517 lookup_time(file, &pterrain->clean_fallout_time,
3518 tsection, "clean_fallout_time", filename, NULL, &ok);
3519
3520 if (!lookup_terrain(file, "warmer_wetter_result", filename, pterrain,
3521 &pterrain->warmer_wetter_result, TRUE)
3522 || !lookup_terrain(file, "warmer_drier_result", filename, pterrain,
3523 &pterrain->warmer_drier_result, TRUE)
3524 || !lookup_terrain(file, "cooler_wetter_result", filename, pterrain,
3525 &pterrain->cooler_wetter_result, TRUE)
3526 || !lookup_terrain(file, "cooler_drier_result", filename, pterrain,
3527 &pterrain->cooler_drier_result, TRUE)) {
3528 ok = FALSE;
3529 break;
3530 }
3531
3532 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", tsection);
3533 BV_CLR_ALL(pterrain->flags);
3534 for (j = 0; j < nval; j++) {
3535 const char *sval = slist[j];
3536 enum terrain_flag_id flag
3537 = terrain_flag_id_by_name(sval, fc_strcasecmp);
3538
3539 if (!terrain_flag_id_is_valid(flag)) {
3540 ruleset_error(NULL, LOG_ERROR,
3541 "\"%s\" [%s] has unknown flag \"%s\".",
3542 filename, tsection, sval);
3543 ok = FALSE;
3544 break;
3545 } else {
3546 BV_SET(pterrain->flags, flag);
3547 }
3548 }
3549 free(slist);
3550
3551 if (!ok) {
3552 break;
3553 }
3554
3555 {
3556 enum mapgen_terrain_property mtp;
3557 for (mtp = mapgen_terrain_property_begin();
3558 mtp != mapgen_terrain_property_end();
3559 mtp = mapgen_terrain_property_next(mtp)) {
3560 pterrain->property[mtp]
3561 = secfile_lookup_int_default(file, 0, "%s.property_%s", tsection,
3562 mapgen_terrain_property_name(mtp));
3563 }
3564 }
3565
3566 slist = secfile_lookup_str_vec(file, &nval, "%s.native_to", tsection);
3567 BV_CLR_ALL(pterrain->native_to);
3568 for (j = 0; j < nval; j++) {
3569 struct unit_class *class = unit_class_by_rule_name(slist[j]);
3570
3571 if (!class) {
3572 ruleset_error(NULL, LOG_ERROR,
3573 "\"%s\" [%s] is native to unknown unit class \"%s\".",
3574 filename, tsection, slist[j]);
3575 ok = FALSE;
3576 break;
3577 } else {
3578 BV_SET(pterrain->native_to, uclass_index(class));
3579 }
3580 }
3581 free(slist);
3582
3583 if (!ok) {
3584 break;
3585 }
3586
3587 /* get terrain color */
3588 {
3589 fc_assert_ret_val(pterrain->rgb == NULL, FALSE);
3590 if (!rgbcolor_load(file, &pterrain->rgb, "%s.color", tsection)) {
3591 ruleset_error(NULL, LOG_ERROR,
3592 "Missing terrain color definition: %s",
3593 secfile_error());
3594 ok = FALSE;
3595 break;
3596 }
3597 }
3598
3599 pterrain->helptext = lookup_strvec(file, tsection, "helptext");
3600 } terrain_type_iterate_end;
3601 }
3602
3603 if (ok) {
3604 /* extra details */
3605 extra_type_iterate(pextra) {
3606 BV_CLR_ALL(pextra->conflicts);
3607 } extra_type_iterate_end;
3608
3609 extra_type_iterate(pextra) {
3610 const char *section = &extra_sections[extra_index(pextra) * MAX_SECTION_LABEL];
3611 const char **slist;
3612 struct requirement_vector *reqs;
3613 const char *catname;
3614 int cj;
3615 enum extra_cause cause;
3616 enum extra_rmcause rmcause;
3617 const char *eus_name;
3618 const char *vis_req_name;
3619 const struct advance *vis_req;
3620
3621 catname = secfile_lookup_str(file, "%s.category", section);
3622 if (catname == NULL) {
3623 ruleset_error(NULL, LOG_ERROR,
3624 "\"%s\" extra \"%s\" has no category.",
3625 filename, extra_rule_name(pextra));
3626 ok = FALSE;
3627 break;
3628 }
3629 pextra->category = extra_category_by_name(catname, fc_strcasecmp);
3630 if (!extra_category_is_valid(pextra->category)) {
3631 ruleset_error(NULL, LOG_ERROR,
3632 "\"%s\" extra \"%s\" has invalid category \"%s\".",
3633 filename, extra_rule_name(pextra), catname);
3634 ok = FALSE;
3635 break;
3636 }
3637
3638 slist = secfile_lookup_str_vec(file, &nval, "%s.causes", section);
3639 pextra->causes = 0;
3640 for (cj = 0; cj < nval; cj++) {
3641 const char *sval = slist[cj];
3642
3643 cause = extra_cause_by_name(sval, fc_strcasecmp);
3644
3645 if (!extra_cause_is_valid(cause)) {
3646 ruleset_error(NULL, LOG_ERROR,
3647 "\"%s\" extra \"%s\": unknown cause \"%s\".",
3648 filename, extra_rule_name(pextra), sval);
3649 ok = FALSE;
3650 break;
3651 } else {
3652 pextra->causes |= (1 << cause);
3653 extra_to_caused_by_list(pextra, cause);
3654 }
3655 }
3656
3657 if (pextra->causes == 0) {
3658 /* Extras that do not have any causes added to EC_NONE list */
3659 extra_to_caused_by_list(pextra, EC_NONE);
3660 }
3661
3662 if (!is_extra_caused_by(pextra, EC_BASE)
3663 && !is_extra_caused_by(pextra, EC_ROAD)
3664 && !is_extra_caused_by(pextra, EC_RESOURCE)) {
3665 /* Not a base, road, nor resource, so special */
3666 pextra->data.special_idx = extra_type_list_size(extra_type_list_by_cause(EC_SPECIAL));
3667 extra_to_caused_by_list(pextra, EC_SPECIAL);
3668 }
3669
3670 free(slist);
3671
3672 slist = secfile_lookup_str_vec(file, &nval, "%s.rmcauses", section);
3673 pextra->rmcauses = 0;
3674 for (j = 0; j < nval; j++) {
3675 const char *sval = slist[j];
3676
3677 rmcause = extra_rmcause_by_name(sval, fc_strcasecmp);
3678
3679 if (!extra_rmcause_is_valid(rmcause)) {
3680 ruleset_error(NULL, LOG_ERROR,
3681 "\"%s\" extra \"%s\": unknown rmcause \"%s\".",
3682 filename, extra_rule_name(pextra), sval);
3683 ok = FALSE;
3684 break;
3685 } else {
3686 pextra->rmcauses |= (1 << rmcause);
3687 extra_to_removed_by_list(pextra, rmcause);
3688 }
3689 }
3690
3691 free(slist);
3692
3693 sz_strlcpy(pextra->activity_gfx,
3694 secfile_lookup_str_default(file, "-",
3695 "%s.activity_gfx", section));
3696 sz_strlcpy(pextra->act_gfx_alt,
3697 secfile_lookup_str_default(file, "-",
3698 "%s.act_gfx_alt", section));
3699 sz_strlcpy(pextra->act_gfx_alt2,
3700 secfile_lookup_str_default(file, "-",
3701 "%s.act_gfx_alt2", section));
3702 sz_strlcpy(pextra->rmact_gfx,
3703 secfile_lookup_str_default(file, "-",
3704 "%s.rmact_gfx", section));
3705 sz_strlcpy(pextra->rmact_gfx_alt,
3706 secfile_lookup_str_default(file, "-",
3707 "%s.rmact_gfx_alt", section));
3708 sz_strlcpy(pextra->graphic_str,
3709 secfile_lookup_str_default(file, "-", "%s.graphic", section));
3710 sz_strlcpy(pextra->graphic_alt,
3711 secfile_lookup_str_default(file, "-",
3712 "%s.graphic_alt", section));
3713
3714 reqs = lookup_req_list(file, compat, section, "reqs", extra_rule_name(pextra));
3715 if (reqs == NULL) {
3716 ok = FALSE;
3717 break;
3718 }
3719 requirement_vector_copy(&pextra->reqs, reqs);
3720
3721 reqs = lookup_req_list(file, compat, section, "rmreqs", extra_rule_name(pextra));
3722 if (reqs == NULL) {
3723 ok = FALSE;
3724 break;
3725 }
3726 requirement_vector_copy(&pextra->rmreqs, reqs);
3727
3728 reqs = lookup_req_list(file, compat, section, "appearance_reqs", extra_rule_name(pextra));
3729 if (reqs == NULL) {
3730 ok = FALSE;
3731 break;
3732 }
3733 requirement_vector_copy(&pextra->appearance_reqs, reqs);
3734
3735 reqs = lookup_req_list(file, compat, section, "disappearance_reqs", extra_rule_name(pextra));
3736 if (reqs == NULL) {
3737 ok = FALSE;
3738 break;
3739 }
3740 requirement_vector_copy(&pextra->disappearance_reqs, reqs);
3741
3742 pextra->buildable = secfile_lookup_bool_default(file,
3743 is_extra_caused_by_worker_action(pextra),
3744 "%s.buildable", section);
3745 pextra->generated = secfile_lookup_bool_default(file, TRUE,
3746 "%s.generated", section);
3747
3748 pextra->build_time = 0; /* default */
3749 lookup_time(file, &pextra->build_time, section, "build_time",
3750 filename, extra_rule_name(pextra), &ok);
3751 pextra->build_time_factor = secfile_lookup_int_default(file, 1,
3752 "%s.build_time_factor", section);
3753 pextra->removal_time = 0; /* default */
3754 lookup_time(file, &pextra->removal_time, section, "removal_time",
3755 filename, extra_rule_name(pextra), &ok);
3756 pextra->removal_time_factor = secfile_lookup_int_default(file, 1,
3757 "%s.removal_time_factor", section);
3758 pextra->infracost = secfile_lookup_int_default(file, 0,
3759 "%s.infracost", section);
3760 if (pextra->infracost > 0) {
3761 terrain_control.infrapoints = TRUE;
3762 }
3763
3764 pextra->defense_bonus = secfile_lookup_int_default(file, 0,
3765 "%s.defense_bonus",
3766 section);
3767 if (pextra->defense_bonus != 0) {
3768 if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
3769 extra_to_caused_by_list(pextra, EC_NATURAL_DEFENSIVE);
3770 } else {
3771 extra_to_caused_by_list(pextra, EC_DEFENSIVE);
3772 }
3773 }
3774
3775 eus_name = secfile_lookup_str_default(file, "Normal", "%s.unit_seen", section);
3776 pextra->eus = extra_unit_seen_type_by_name(eus_name, fc_strcasecmp);
3777 if (!extra_unit_seen_type_is_valid(pextra->eus)) {
3778 ruleset_error(NULL, LOG_ERROR,
3779 "\"%s\" extra \"%s\" has illegal unit_seen value \"%s\".",
3780 filename, extra_rule_name(pextra), eus_name);
3781 ok = FALSE;
3782 break;
3783 }
3784 if (pextra->eus == EUS_HIDDEN) {
3785 extra_type_list_append(extra_type_list_of_unit_hiders(), pextra);
3786 }
3787
3788 pextra->appearance_chance = secfile_lookup_int_default(file, RS_DEFAULT_EXTRA_APPEARANCE,
3789 "%s.appearance_chance",
3790 section);
3791 pextra->disappearance_chance = secfile_lookup_int_default(file,
3792 RS_DEFAULT_EXTRA_DISAPPEARANCE,
3793 "%s.disappearance_chance",
3794 section);
3795
3796 slist = secfile_lookup_str_vec(file, &nval, "%s.native_to", section);
3797 BV_CLR_ALL(pextra->native_to);
3798 for (j = 0; j < nval; j++) {
3799 struct unit_class *uclass = unit_class_by_rule_name(slist[j]);
3800
3801 if (uclass == NULL) {
3802 ruleset_error(NULL, LOG_ERROR,
3803 "\"%s\" extra \"%s\" is native to unknown unit class \"%s\".",
3804 filename, extra_rule_name(pextra), slist[j]);
3805 ok = FALSE;
3806 break;
3807 } else {
3808 BV_SET(pextra->native_to, uclass_index(uclass));
3809 }
3810 }
3811 free(slist);
3812
3813 if (!ok) {
3814 break;
3815 }
3816
3817 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", section);
3818 BV_CLR_ALL(pextra->flags);
3819 for (j = 0; j < nval; j++) {
3820 const char *sval = slist[j];
3821 enum extra_flag_id flag = extra_flag_id_by_name(sval, fc_strcasecmp);
3822
3823 if (!extra_flag_id_is_valid(flag)) {
3824 ruleset_error(NULL, LOG_ERROR,
3825 "\"%s\" extra \"%s\": unknown flag \"%s\".",
3826 filename, extra_rule_name(pextra), sval);
3827 ok = FALSE;
3828 break;
3829 } else {
3830 BV_SET(pextra->flags, flag);
3831 }
3832 }
3833 free(slist);
3834
3835 if (extra_has_flag(pextra, EF_NOT_AGGRESSIVE)) {
3836 extra_to_caused_by_list(pextra, EC_NOT_AGGRESSIVE);
3837 }
3838
3839 if (!ok) {
3840 break;
3841 }
3842
3843 slist = secfile_lookup_str_vec(file, &nval, "%s.conflicts", section);
3844 for (j = 0; j < nval; j++) {
3845 const char *sval = slist[j];
3846 struct extra_type *pextra2 = extra_type_by_rule_name(sval);
3847
3848 if (pextra2 == NULL) {
3849 ruleset_error(NULL, LOG_ERROR,
3850 "\"%s\" extra \"%s\": unknown conflict extra \"%s\".",
3851 filename, extra_rule_name(pextra), sval);
3852 ok = FALSE;
3853 break;
3854 } else {
3855 BV_SET(pextra->conflicts, extra_index(pextra2));
3856 BV_SET(pextra2->conflicts, extra_index(pextra));
3857 }
3858 }
3859
3860 free(slist);
3861
3862 if (!ok) {
3863 break;
3864 }
3865
3866 slist = secfile_lookup_str_vec(file, &nval, "%s.hidden_by", section);
3867 BV_CLR_ALL(pextra->hidden_by);
3868 for (j = 0; j < nval; j++) {
3869 const char *sval = slist[j];
3870 const struct extra_type *top = extra_type_by_rule_name(sval);
3871
3872 if (top == NULL) {
3873 ruleset_error(NULL, LOG_ERROR,
3874 "\"%s\" extra \"%s\" hidden by unknown extra \"%s\".",
3875 filename, extra_rule_name(pextra), sval);
3876 ok = FALSE;
3877 break;
3878 } else {
3879 BV_SET(pextra->hidden_by, extra_index(top));
3880 }
3881 }
3882 free(slist);
3883
3884 if (!ok) {
3885 break;
3886 }
3887
3888 slist = secfile_lookup_str_vec(file, &nval, "%s.bridged_over", section);
3889 BV_CLR_ALL(pextra->bridged_over);
3890 for (j = 0; j < nval; j++) {
3891 const char *sval = slist[j];
3892 const struct extra_type *top = extra_type_by_rule_name(sval);
3893
3894 if (top == NULL) {
3895 ruleset_error(NULL, LOG_ERROR,
3896 "\"%s\" extra \"%s\" bridged over unknown extra \"%s\".",
3897 filename, extra_rule_name(pextra), sval);
3898 ok = FALSE;
3899 break;
3900 } else {
3901 BV_SET(pextra->bridged_over, extra_index(top));
3902 }
3903 }
3904 free(slist);
3905
3906 if (!ok) {
3907 break;
3908 }
3909
3910 vis_req_name = secfile_lookup_str_default(file, "None",
3911 "%s.visibility_req", section);
3912 vis_req = advance_by_rule_name(vis_req_name);
3913
3914 if (vis_req == NULL) {
3915 ruleset_error(NULL, LOG_ERROR,
3916 "\"%s\" %s: unknown visibility_req %s.",
3917 filename, section, vis_req_name);
3918 ok = FALSE;
3919 break;
3920 }
3921
3922 pextra->visibility_req = advance_number(vis_req);
3923
3924 pextra->helptext = lookup_strvec(file, section, "helptext");
3925
3926 rscompat_extra_adjust_3_1(compat, pextra);
3927 } extra_type_iterate_end;
3928 }
3929
3930 if (ok) {
3931 int i = 0;
3932 /* resource details */
3933
3934 extra_type_by_cause_iterate(EC_RESOURCE, presource) {
3935 char identifier[MAX_LEN_NAME];
3936 const char *rsection = &resource_sections[i * MAX_SECTION_LABEL];
3937
3938 if (!presource->data.resource) {
3939 ruleset_error(NULL, LOG_ERROR,
3940 "\"%s\" extra \"%s\" has \"Resource\" cause but no "
3941 "corresponding [resource_*] section",
3942 filename, extra_rule_name(presource));
3943 ok = FALSE;
3944 break;
3945 }
3946
3947 output_type_iterate (o) {
3948 presource->data.resource->output[o] =
3949 secfile_lookup_int_default(file, 0, "%s.%s", rsection,
3950 get_output_identifier(o));
3951 } output_type_iterate_end;
3952
3953 sz_strlcpy(identifier,
3954 secfile_lookup_str(file, "%s.identifier", rsection));
3955 presource->data.resource->id_old_save = identifier[0];
3956 if (RESOURCE_NULL_IDENTIFIER == presource->data.resource->id_old_save) {
3957 ruleset_error(NULL, LOG_ERROR,
3958 "\"%s\" [%s] identifier missing value.",
3959 filename, rsection);
3960 ok = FALSE;
3961 break;
3962 }
3963 if (RESOURCE_NONE_IDENTIFIER == presource->data.resource->id_old_save) {
3964 ruleset_error(NULL, LOG_ERROR,
3965 "\"%s\" [%s] cannot use '%c' as an identifier;"
3966 " it is reserved.",
3967 filename, rsection, presource->data.resource->id_old_save);
3968 ok = FALSE;
3969 break;
3970 }
3971
3972 if (!ok) {
3973 break;
3974 }
3975
3976 i++;
3977 } extra_type_by_cause_iterate_end;
3978
3979 for (j = 0; ok && j < game.control.num_resource_types; j++) {
3980 const char *section = &resource_sections[j * MAX_SECTION_LABEL];
3981 const char *extra_name = secfile_lookup_str(file, "%s.extra", section);
3982 struct extra_type *pextra = extra_type_by_rule_name(extra_name);
3983
3984 if (!is_extra_caused_by(pextra, EC_RESOURCE)) {
3985 ruleset_error(NULL, LOG_ERROR,
3986 "\"%s\" resource section [%s]: extra \"%s\" does not "
3987 "have \"Resource\" in its causes",
3988 filename, section, extra_name);
3989 ok = FALSE;
3990 }
3991 }
3992 }
3993
3994 if (ok) {
3995 /* This can't be part of previous loop as we don't want random data from previous
3996 * ruleset to play havoc on us when we have only some resource identifiers loaded
3997 * from the new ruleset. */
3998 extra_type_by_cause_iterate(EC_RESOURCE, pres) {
3999 extra_type_by_cause_iterate(EC_RESOURCE, pres2) {
4000 if (pres->data.resource->id_old_save == pres2->data.resource->id_old_save
4001 && pres != pres2) {
4002 ruleset_error(NULL, LOG_ERROR,
4003 "\"%s\" [%s] has the same identifier as [%s].",
4004 filename,
4005 extra_rule_name(pres),
4006 extra_rule_name(pres2));
4007 ok = FALSE;
4008 break;
4009 }
4010 } extra_type_by_cause_iterate_end;
4011
4012 if (!ok) {
4013 break;
4014 }
4015 } extra_type_by_cause_iterate_end;
4016 }
4017
4018 if (ok) {
4019 /* base details */
4020 extra_type_by_cause_iterate(EC_BASE, pextra) {
4021 struct base_type *pbase = extra_base_get(pextra);
4022 const char *section;
4023 const char *gui_str;
4024
4025 if (!pbase) {
4026 ruleset_error(NULL, LOG_ERROR,
4027 "\"%s\" extra \"%s\" has \"Base\" cause but no "
4028 "corresponding [base_*] section",
4029 filename, extra_rule_name(pextra));
4030 ok = FALSE;
4031 break;
4032 }
4033 section = &base_sections[base_number(pbase) * MAX_SECTION_LABEL];
4034
4035 gui_str = secfile_lookup_str(file, "%s.gui_type", section);
4036 pbase->gui_type = base_gui_type_by_name(gui_str, fc_strcasecmp);
4037 if (!base_gui_type_is_valid(pbase->gui_type)) {
4038 ruleset_error(NULL, LOG_ERROR,
4039 "\"%s\" base \"%s\": unknown gui_type \"%s\".",
4040 filename, extra_rule_name(pextra), gui_str);
4041 ok = FALSE;
4042 break;
4043 }
4044
4045 pbase->border_sq = secfile_lookup_int_default(file, -1, "%s.border_sq",
4046 section);
4047 pbase->vision_main_sq = secfile_lookup_int_default(file, -1,
4048 "%s.vision_main_sq",
4049 section);
4050 pbase->vision_invis_sq = secfile_lookup_int_default(file, -1,
4051 "%s.vision_invis_sq",
4052 section);
4053 pbase->vision_subs_sq = secfile_lookup_int_default(file, -1,
4054 "%s.vision_subs_sq",
4055 section);
4056
4057 if (compat->compat_mode) {
4058 int bj;
4059 const char **slist;
4060
4061 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", section);
4062 for (bj = 0; bj < nval; bj++) {
4063 const char *sval = slist[bj];
4064
4065 if (fc_strcasecmp("NoAggressive", sval)) {
4066 ruleset_error(NULL, LOG_ERROR,
4067 "\"%s\" base \"%s\": unknown flag \"%s\".",
4068 filename, extra_rule_name(pextra), sval);
4069 ok = FALSE;
4070 break;
4071 } else {
4072 if (!BV_ISSET(pextra->flags, EF_NOT_AGGRESSIVE)) {
4073 /* We would not be adding extra to caused_by_list second time. */
4074 BV_SET(pextra->flags, EF_NOT_AGGRESSIVE);
4075 extra_to_caused_by_list(pextra, EC_NOT_AGGRESSIVE);
4076 }
4077 }
4078 }
4079
4080 free(slist);
4081 }
4082
4083 if (!ok) {
4084 break;
4085 }
4086
4087 if (territory_claiming_base(pbase)) {
4088 extra_type_list_append(extra_type_list_of_terr_claimers(), pextra);
4089
4090 extra_type_by_cause_iterate(EC_BASE, pextra2) {
4091 struct base_type *pbase2;
4092
4093 if (pextra == pextra2) {
4094 /* End of the fully initialized bases iteration. */
4095 break;
4096 }
4097
4098 pbase2 = extra_base_get(pextra2);
4099 if (territory_claiming_base(pbase2)) {
4100 BV_SET(pextra->conflicts, extra_index(pextra2));
4101 BV_SET(pextra2->conflicts, extra_index(pextra));
4102 }
4103 } extra_type_by_cause_iterate_end;
4104 }
4105 } extra_type_by_cause_iterate_end;
4106
4107 for (j = 0; ok && j < game.control.num_base_types; j++) {
4108 const char *section = &base_sections[j * MAX_SECTION_LABEL];
4109 const char *extra_name = secfile_lookup_str(file, "%s.extra", section);
4110 struct extra_type *pextra = extra_type_by_rule_name(extra_name);
4111
4112 if (!is_extra_caused_by(pextra, EC_BASE)) {
4113 ruleset_error(NULL, LOG_ERROR,
4114 "\"%s\" base section [%s]: extra \"%s\" does not have "
4115 "\"Base\" in its causes",
4116 filename, section, extra_name);
4117 ok = FALSE;
4118 }
4119 }
4120 }
4121
4122 if (ok) {
4123 bv_extras compat_bridged;
4124
4125 if (compat->compat_mode) {
4126 BV_CLR_ALL(compat_bridged);
4127 extra_type_by_cause_iterate(EC_ROAD, pextra) {
4128 struct road_type *proad = extra_road_get(pextra);
4129 const char *section = &road_sections[road_number(proad) * MAX_SECTION_LABEL];
4130 const char **slist;
4131
4132 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", section);
4133
4134 for (j = 0; j < nval; j++) {
4135 if (!fc_strcasecmp("PreventsOtherRoads", slist[j])) {
4136 BV_SET(compat_bridged, pextra->id);
4137 }
4138 }
4139 } extra_type_by_cause_iterate_end;
4140 }
4141 extra_type_by_cause_iterate(EC_ROAD, pextra) {
4142 struct road_type *proad = extra_road_get(pextra);
4143 const char *section;
4144 const char **slist;
4145 const char *special;
4146 const char *modestr;
4147 struct requirement_vector *reqs;
4148 const char *gui_str;
4149
4150 if (!proad) {
4151 ruleset_error(NULL, LOG_ERROR,
4152 "\"%s\" extra \"%s\" has \"Road\" cause but no "
4153 "corresponding [road_*] section",
4154 filename, extra_rule_name(pextra));
4155 ok = FALSE;
4156 break;
4157 }
4158 section = &road_sections[road_number(proad) * MAX_SECTION_LABEL];
4159
4160 reqs = lookup_req_list(file, compat, section, "first_reqs", extra_rule_name(pextra));
4161 if (reqs == NULL) {
4162 ok = FALSE;
4163 break;
4164 }
4165 requirement_vector_copy(&proad->first_reqs, reqs);
4166
4167 if (!secfile_lookup_int(file, &proad->move_cost,
4168 "%s.move_cost", section)) {
4169 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
4170 ok = FALSE;
4171 break;
4172 }
4173
4174 modestr = secfile_lookup_str_default(file, "FastAlways", "%s.move_mode",
4175 section);
4176 proad->move_mode = road_move_mode_by_name(modestr, fc_strcasecmp);
4177 if (!road_move_mode_is_valid(proad->move_mode)) {
4178 ruleset_error(NULL, LOG_ERROR,
4179 "Illegal move_mode \"%s\" for road \"%s\"",
4180 modestr, extra_rule_name(pextra));
4181 ok = FALSE;
4182 break;
4183 }
4184
4185 output_type_iterate(o) {
4186 proad->tile_incr_const[o] =
4187 secfile_lookup_int_default(file, 0, "%s.%s_incr_const",
4188 section, get_output_identifier(o));
4189 proad->tile_incr[o] =
4190 secfile_lookup_int_default(file, 0, "%s.%s_incr",
4191 section, get_output_identifier(o));
4192 proad->tile_bonus[o] =
4193 secfile_lookup_int_default(file, 0, "%s.%s_bonus",
4194 section, get_output_identifier(o));
4195 } output_type_iterate_end;
4196
4197 special = secfile_lookup_str_default(file, "None", "%s.compat_special", section);
4198 if (!fc_strcasecmp(special, "Road")) {
4199 if (compat_road) {
4200 ruleset_error(NULL, LOG_ERROR,
4201 "Multiple roads marked as compatibility \"Road\"");
4202 ok = FALSE;
4203 }
4204 compat_road = TRUE;
4205 proad->compat = ROCO_ROAD;
4206 } else if (!fc_strcasecmp(special, "Railroad")) {
4207 if (compat_rail) {
4208 ruleset_error(NULL, LOG_ERROR,
4209 "Multiple roads marked as compatibility \"Railroad\"");
4210 ok = FALSE;
4211 }
4212 compat_rail = TRUE;
4213 proad->compat = ROCO_RAILROAD;
4214 } else if (!fc_strcasecmp(special, "River")) {
4215 if (compat_river) {
4216 ruleset_error(NULL, LOG_ERROR,
4217 "Multiple roads marked as compatibility \"River\"");
4218 ok = FALSE;
4219 }
4220 compat_river = TRUE;
4221 proad->compat = ROCO_RIVER;
4222 } else if (!fc_strcasecmp(special, "None")) {
4223 proad->compat = ROCO_NONE;
4224 } else {
4225 ruleset_error(NULL, LOG_ERROR,
4226 "Illegal compatibility special \"%s\" for road %s",
4227 special, extra_rule_name(pextra));
4228 ok = FALSE;
4229 }
4230
4231 if (!ok) {
4232 break;
4233 }
4234
4235 gui_str = secfile_lookup_str_default(file, NULL, "%s.gui_type", section);
4236 if (gui_str == NULL) {
4237 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
4238 proad->gui_type = rscompat_road_gui_type_3_1(proad);
4239 } else {
4240 ruleset_error(NULL, LOG_ERROR,
4241 "\"%s\" road \"%s\": no gui_type.",
4242 filename, extra_rule_name(pextra));
4243 ok = FALSE;
4244 break;
4245 }
4246 } else {
4247 proad->gui_type = road_gui_type_by_name(gui_str, fc_strcasecmp);
4248 if (!road_gui_type_is_valid(proad->gui_type)) {
4249 ruleset_error(NULL, LOG_ERROR,
4250 "\"%s\" road \"%s\": unknown gui_type \"%s\".",
4251 filename, extra_rule_name(pextra), gui_str);
4252 ok = FALSE;
4253 break;
4254 }
4255 }
4256
4257 slist = secfile_lookup_str_vec(file, &nval, "%s.integrates", section);
4258 BV_CLR_ALL(proad->integrates);
4259 for (j = 0; j < nval; j++) {
4260 const char *sval = slist[j];
4261 struct extra_type *textra = extra_type_by_rule_name(sval);
4262 struct road_type *top = NULL;
4263
4264 if (textra != NULL) {
4265 top = extra_road_get(textra);
4266 }
4267
4268 if (top == NULL) {
4269 ruleset_error(NULL, LOG_ERROR,
4270 "\"%s\" road \"%s\" integrates with unknown road \"%s\".",
4271 filename, extra_rule_name(pextra), sval);
4272 ok = FALSE;
4273 break;
4274 } else {
4275 BV_SET(proad->integrates, road_number(top));
4276 }
4277 }
4278 free(slist);
4279
4280 if (!ok) {
4281 break;
4282 }
4283
4284 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", section);
4285 BV_CLR_ALL(proad->flags);
4286 for (j = 0; j < nval; j++) {
4287 const char *sval = slist[j];
4288
4289 if (compat->compat_mode && !fc_strcasecmp("PreventsOtherRoads", sval)) {
4290 /* Nothing to do here */
4291 } else if (compat->compat_mode && !fc_strcasecmp("RequiresBridge", sval)) {
4292 extra_type_iterate(pbridged) {
4293 if (BV_ISSET(compat_bridged, pbridged->id)) {
4294 BV_SET(pextra->bridged_over, pbridged->id);
4295 }
4296 } extra_type_iterate_end;
4297 } else {
4298 enum road_flag_id flag = road_flag_id_by_name(sval, fc_strcasecmp);
4299
4300 if (!road_flag_id_is_valid(flag)) {
4301 ruleset_error(NULL, LOG_ERROR,
4302 "\"%s\" road \"%s\": unknown flag \"%s\".",
4303 filename, extra_rule_name(pextra), sval);
4304 ok = FALSE;
4305 break;
4306 } else {
4307 BV_SET(proad->flags, flag);
4308 }
4309 }
4310 }
4311 free(slist);
4312
4313 if (!ok) {
4314 break;
4315 }
4316 } extra_type_by_cause_iterate_end;
4317
4318 for (j = 0; ok && j < game.control.num_road_types; j++) {
4319 const char *section = &road_sections[j * MAX_SECTION_LABEL];
4320 const char *extra_name = secfile_lookup_str(file, "%s.extra", section);
4321 struct extra_type *pextra = extra_type_by_rule_name(extra_name);
4322
4323 if (!is_extra_caused_by(pextra, EC_ROAD)) {
4324 ruleset_error(NULL, LOG_ERROR,
4325 "\"%s\" road section [%s]: extra \"%s\" does not have "
4326 "\"Road\" in its causes",
4327 filename, section, extra_name);
4328 ok = FALSE;
4329 }
4330 }
4331 }
4332
4333 if (ok) {
4334 extra_type_iterate(pextra) {
4335 pextra->bridged = extra_type_list_new();
4336 extra_type_iterate(pbridged) {
4337 if (BV_ISSET(pextra->bridged_over, pbridged->id)) {
4338 extra_type_list_append(pextra->bridged, pbridged);
4339 }
4340 } extra_type_iterate_end;
4341 } extra_type_iterate_end;
4342 }
4343
4344 if (ok) {
4345 secfile_check_unused(file);
4346 }
4347
4348 return ok;
4349}
4350
4351/**********************************************************************/
4355 static bool load_government_names(struct section_file *file,
4356 struct rscompat_info *compat)
4357{
4358 int nval = 0;
4359 struct section_list *sec;
4360 const char *filename = secfile_name(file);
4361 bool ok = TRUE;
4362
4363 if (!rscompat_check_cap_and_version(file, filename, compat)) {
4364 return FALSE;
4365 }
4366
4367 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
4368 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
4369
4370 sec = secfile_sections_by_name_prefix(file, GOVERNMENT_SECTION_PREFIX);
4371 if (NULL == sec || 0 == (nval = section_list_size(sec))) {
4372 ruleset_error(NULL, LOG_ERROR, "\"%s\": No governments?!?", filename);
4373 ok = FALSE;
4374 } else if (nval > G_LAST) {
4375 ruleset_error(NULL, LOG_ERROR,
4376 "\"%s\": Too many governments (%d, max %d)",
4377 filename, nval, G_LAST);
4378 ok = FALSE;
4379 }
4380
4381 if (ok) {
4382 governments_alloc(nval);
4383
4384 /* Government names are needed early so that get_government_by_name will
4385 * work. */
4386 governments_iterate(gov) {
4387 const char *sec_name =
4388 section_name(section_list_get(sec, government_index(gov)));
4389
4390 if (!ruleset_load_names(&gov->name, NULL, file, sec_name)) {
4391 ok = FALSE;
4392 break;
4393 }
4394 } governments_iterate_end;
4395 }
4396
4397 section_list_destroy(sec);
4398
4399 if (ok) {
4400 sec = secfile_sections_by_name_prefix(file, MULTIPLIER_SECTION_PREFIX);
4401 nval = (NULL != sec ? section_list_size(sec) : 0);
4402
4403 if (nval > MAX_NUM_MULTIPLIERS) {
4404 ruleset_error(NULL, LOG_ERROR,
4405 "\"%s\": Too many multipliers (%d, max %d)",
4406 filename, nval, MAX_NUM_MULTIPLIERS);
4407
4408 ok = FALSE;
4409 } else {
4410 game.control.num_multipliers = nval;
4411 }
4412
4413 if (ok) {
4414 multipliers_iterate(pmul) {
4415 const char *sec_name =
4416 section_name(section_list_get(sec, multiplier_index(pmul)));
4417
4418 if (!ruleset_load_names(&pmul->name, NULL, file, sec_name)) {
4419 ruleset_error(NULL, LOG_ERROR,
4420 "\"%s\": Cannot load multiplier names",
4421 filename);
4422 ok = FALSE;
4423 break;
4424 }
4425 } multipliers_iterate_end;
4426 }
4427 }
4428
4429 section_list_destroy(sec);
4430
4431 return ok;
4432}
4433
4434/**********************************************************************/
4437 static bool load_ruleset_governments(struct section_file *file,
4438 struct rscompat_info *compat)
4439{
4440 struct section_list *sec;
4441 const char *filename = secfile_name(file);
4442 bool ok = TRUE;
4443
4444 sec = secfile_sections_by_name_prefix(file, GOVERNMENT_SECTION_PREFIX);
4445
4446 game.government_during_revolution
4447 = lookup_government(file, "governments.during_revolution", filename, NULL);
4448 if (game.government_during_revolution == NULL) {
4449 ok = FALSE;
4450 }
4451
4452 if (ok) {
4453 game.info.government_during_revolution_id =
4454 government_number(game.government_during_revolution);
4455
4456 /* easy ones: */
4457 governments_iterate(g) {
4458 const int i = government_index(g);
4459 const char *sec_name = section_name(section_list_get(sec, i));
4460 struct requirement_vector *reqs =
4461 lookup_req_list(file, compat, sec_name, "reqs", government_rule_name(g));
4462
4463 if (reqs == NULL) {
4464 ok = FALSE;
4465 break;
4466 }
4467
4468 if (NULL != secfile_entry_lookup(file, "%s.ai_better", sec_name)) {
4469 char entry[100];
4470
4471 fc_snprintf(entry, sizeof(entry), "%s.ai_better", sec_name);
4472 g->ai.better = lookup_government(file, entry, filename, NULL);
4473 if (g->ai.better == NULL) {
4474 ok = FALSE;
4475 break;
4476 }
4477 } else {
4478 g->ai.better = NULL;
4479 }
4480 requirement_vector_copy(&g->reqs, reqs);
4481
4482 sz_strlcpy(g->graphic_str,
4483 secfile_lookup_str(file, "%s.graphic", sec_name));
4484 sz_strlcpy(g->graphic_alt,
4485 secfile_lookup_str(file, "%s.graphic_alt", sec_name));
4486
4487 g->helptext = lookup_strvec(file, sec_name, "helptext");
4488 } governments_iterate_end;
4489 }
4490
4491
4492 if (ok) {
4493 /* titles */
4494 governments_iterate(g) {
4495 const char *sec_name =
4496 section_name(section_list_get(sec, government_index(g)));
4497 const char *male, *female;
4498
4499 if (!(male = secfile_lookup_str(file, "%s.ruler_male_title", sec_name))
4500 || !(female = secfile_lookup_str(file, "%s.ruler_female_title",
4501 sec_name))) {
4502 ruleset_error(NULL, LOG_ERROR,
4503 "Lack of default ruler titles for "
4504 "government \"%s\" (nb %d): %s",
4505 government_rule_name(g), government_number(g),
4506 secfile_error());
4507 ok = FALSE;
4508 break;
4509 } else if (NULL == government_ruler_title_new(g, NULL, male, female)) {
4510 ruleset_error(NULL, LOG_ERROR,
4511 "Lack of default ruler titles for "
4512 "government \"%s\" (nb %d).",
4513 government_rule_name(g), government_number(g));
4514 ok = FALSE;
4515 break;
4516 }
4517 } governments_iterate_end;
4518 }
4519
4520 section_list_destroy(sec);
4521
4522 if (ok) {
4523 sec = secfile_sections_by_name_prefix(file, MULTIPLIER_SECTION_PREFIX);
4524 multipliers_iterate(pmul) {
4525 int id = multiplier_index(pmul);
4526 const char *sec_name = section_name(section_list_get(sec, id));
4527 struct requirement_vector *reqs;
4528
4529 if (!secfile_lookup_int(file, &pmul->start, "%s.start", sec_name)) {
4530 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
4531 ok = FALSE;
4532 break;
4533 }
4534 if (!secfile_lookup_int(file, &pmul->stop, "%s.stop", sec_name)) {
4535 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
4536 ok = FALSE;
4537 break;
4538 }
4539 if (pmul->stop <= pmul->start) {
4540 ruleset_error(NULL, LOG_ERROR,
4541 "Multiplier \"%s\" stop (%d) must be greater "
4542 "than start (%d)", multiplier_rule_name(pmul),
4543 pmul->stop, pmul->start);
4544 ok = FALSE;
4545 break;
4546 }
4547 if (!secfile_lookup_int(file, &pmul->step, "%s.step", sec_name)) {
4548 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
4549 ok = FALSE;
4550 break;
4551 }
4552 if (((pmul->stop - pmul->start) % pmul->step) != 0) {
4553 ruleset_error(NULL, LOG_ERROR,
4554 "Multiplier \"%s\" step (%d) does not fit "
4555 "exactly into interval start-stop (%d to %d)",
4556 multiplier_rule_name(pmul), pmul->step,
4557 pmul->start, pmul->stop);
4558 ok = FALSE;
4559 break;
4560 }
4561 if (!secfile_lookup_int(file, &pmul->def, "%s.default", sec_name)) {
4562 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
4563 ok = FALSE;
4564 break;
4565 }
4566 if (pmul->def < pmul->start || pmul->def > pmul->stop) {
4567 ruleset_error(NULL, LOG_ERROR,
4568 "Multiplier \"%s\" default (%d) not within "
4569 "legal range (%d to %d)", multiplier_rule_name(pmul),
4570 pmul->def, pmul->start, pmul->stop);
4571 ok = FALSE;
4572 break;
4573 }
4574 if (((pmul->def - pmul->start) % pmul->step) != 0) {
4575 ruleset_error(NULL, LOG_ERROR,
4576 "Multiplier \"%s\" default (%d) not legal "
4577 "with respect to step size %d",
4578 multiplier_rule_name(pmul), pmul->def, pmul->step);
4579 ok = FALSE;
4580 break;
4581 }
4582 pmul->offset = secfile_lookup_int_default(file, 0,
4583 "%s.offset", sec_name);
4584 pmul->factor = secfile_lookup_int_default(file, 100,
4585 "%s.factor", sec_name);
4586 if (pmul->factor == 0) {
4587 ruleset_error(NULL, LOG_ERROR,
4588 "Multiplier \"%s\" scaling factor must "
4589 "not be zero", multiplier_rule_name(pmul));
4590 ok = FALSE;
4591 break;
4592 }
4593
4594 pmul->minimum_turns = secfile_lookup_int_default(file, 0,
4595 "%s.minimum_turns",
4596 sec_name);
4597
4598 reqs = lookup_req_list(file, compat, sec_name, "reqs",
4599 multiplier_rule_name(pmul));
4600 if (reqs == NULL) {
4601 ok = FALSE;
4602 break;
4603 }
4604 requirement_vector_copy(&pmul->reqs, reqs);
4605
4606 pmul->helptext = lookup_strvec(file, sec_name, "helptext");
4607 } multipliers_iterate_end;
4608 section_list_destroy(sec);
4609 }
4610
4611 if (ok) {
4612 secfile_check_unused(file);
4613 }
4614
4615 return ok;
4616}
4617
4618/**********************************************************************/
4629 static void send_ruleset_control(struct conn_list *dest)
4630{
4631 int desc_left = game.control.desc_length32;
4632 int idx = 0;
4633
4634 game.control.desc_length16 = game.control.desc_length32;
4635 lsend_packet_ruleset_control(dest, &(game.control));
4636
4637 if (game.ruleset_summary != NULL) {
4638 struct packet_ruleset_summary summary;
4639
4640 sz_strlcpy(summary.text, game.ruleset_summary);
4641
4642 lsend_packet_ruleset_summary(dest, &summary);
4643 }
4644
4645 while (desc_left > 0) {
4646 struct packet_ruleset_description_part part;
4647 int this_len = desc_left;
4648
4649 if (this_len > MAX_LEN_CONTENT - 21) {
4650 this_len = MAX_LEN_CONTENT - 1;
4651 }
4652
4653 part.text[this_len] = '\0';
4654
4655 strncpy(part.text, &game.ruleset_description[idx], this_len);
4656 idx += this_len;
4657 desc_left -= this_len;
4658
4659 lsend_packet_ruleset_description_part(dest, &part);
4660 }
4661}
4662
4663/**********************************************************************/
4668 static const char *check_leader_names(struct nation_type *pnation)
4669{
4670 nation_leader_list_iterate(nation_leaders(pnation), pleader) {
4671 const char *name = nation_leader_name(pleader);
4672
4673 nation_leader_list_iterate(nation_leaders(pnation), prev_leader) {
4674 if (prev_leader == pleader) {
4675 break;
4676 } else if (0 == fc_strcasecmp(name, nation_leader_name(prev_leader))) {
4677 return name;
4678 }
4679 } nation_leader_list_iterate_end;
4680 } nation_leader_list_iterate_end;
4681 return NULL;
4682}
4683
4684/**********************************************************************/
4688 static bool load_nation_names(struct section_file *file,
4689 struct rscompat_info *compat)
4690{
4691 struct section_list *sec;
4692 int j;
4693 bool ok = TRUE;
4694 const char *filename = secfile_name(file);
4695
4696 if (!rscompat_check_cap_and_version(file, filename, compat)) {
4697 return FALSE;
4698 }
4699
4700 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
4701 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
4702
4703 sec = secfile_sections_by_name_prefix(file, NATION_SECTION_PREFIX);
4704 if (NULL == sec) {
4705 ruleset_error(NULL, LOG_ERROR,
4706 "No available nations in this ruleset!");
4707 ok = FALSE;
4708 } else if (section_list_size(sec) > MAX_NUM_NATIONS) {
4709 ruleset_error(NULL, LOG_ERROR,
4710 "Too many nations (max %d, we have %d)!",
4711 MAX_NUM_NATIONS, section_list_size(sec));
4712 ok = FALSE;
4713 } else {
4714 game.control.nation_count = section_list_size(sec);
4715 nations_alloc(game.control.nation_count);
4716
4717 nations_iterate(pl) {
4718 const int i = nation_index(pl);
4719 const char *sec_name = section_name(section_list_get(sec, i));
4720 const char *domain = secfile_lookup_str_default(file, NULL,
4721 "%s.translation_domain", sec_name);
4722 const char *noun_plural = secfile_lookup_str(file,
4723 "%s.plural", sec_name);
4724
4725
4726 if (domain == NULL) {
4727 domain = "freeciv-nations";
4728 }
4729
4730 if (!strcmp("freeciv-core", domain)) {
4731 pl->translation_domain = NULL;
4732 } else if (compat->compat_mode && compat->version < RSFORMAT_3_1
4733 && !strcmp("freeciv", domain)) {
4734 pl->translation_domain = NULL;
4735 } else if (!strcmp("freeciv-nations", domain)) {
4736 pl->translation_domain = fc_strdup(domain);
4737 } else {
4738 ruleset_error(NULL, LOG_ERROR,
4739 "Unsupported translation domain \"%s\" for %s",
4740 domain, sec_name);
4741 ok = FALSE;
4742 break;
4743 }
4744
4745 if (!ruleset_load_names(&pl->adjective, pl->translation_domain, file, sec_name)) {
4746 ok = FALSE;
4747 break;
4748 }
4749 name_set(&pl->noun_plural, pl->translation_domain, noun_plural);
4750
4751 /* Check if nation name is already defined. */
4752 for (j = 0; j < i && ok; j++) {
4753 struct nation_type *n2 = nation_by_number(j);
4754
4755 /* Compare strings after stripping off qualifiers -- we don't want
4756 * two nations to end up with identical adjectives displayed to users.
4757 * (This check only catches English, not localisations, of course.) */
4758 if (0 == strcmp(Qn_(untranslated_name(&n2->adjective)),
4759 Qn_(untranslated_name(&pl->adjective)))) {
4760 ruleset_error(NULL, LOG_ERROR,
4761 "Two nations defined with the same adjective \"%s\": "
4762 "in section \'%s\' and section \'%s\'",
4763 Qn_(untranslated_name(&pl->adjective)),
4764 section_name(section_list_get(sec, j)), sec_name);
4765 ok = FALSE;
4766 } else if (!strcmp(rule_name_get(&n2->adjective),
4767 rule_name_get(&pl->adjective))) {
4768 /* We cannot have the same rule name, as the game needs them to be
4769 * distinct. */
4770 ruleset_error(NULL, LOG_ERROR,
4771 "Two nations defined with the same rule_name \"%s\": "
4772 "in section \'%s\' and section \'%s\'",
4773 rule_name_get(&pl->adjective),
4774 section_name(section_list_get(sec, j)), sec_name);
4775 ok = FALSE;
4776 } else if (0 == strcmp(Qn_(untranslated_name(&n2->noun_plural)),
4777 Qn_(untranslated_name(&pl->noun_plural)))) {
4778 /* We don't want identical English plural names either. */
4779 ruleset_error(NULL, LOG_ERROR,
4780 "Two nations defined with the same plural name \"%s\": "
4781 "in section \'%s\' and section \'%s\'",
4782 Qn_(untranslated_name(&pl->noun_plural)),
4783 section_name(section_list_get(sec, j)), sec_name);
4784 ok = FALSE;
4785 }
4786 }
4787 if (!ok) {
4788 break;
4789 }
4790 } nations_iterate_end;
4791 }
4792
4793 section_list_destroy(sec);
4794
4795 if (ok) {
4796 sec = secfile_sections_by_name_prefix(file, NATION_GROUP_SECTION_PREFIX);
4797 if (sec != NULL) {
4798 game.control.num_nation_groups = section_list_size(sec);
4799
4800 section_list_iterate(sec, psection) {
4801 struct nation_group *pgroup;
4802 const char *name;
4803
4804 name = secfile_lookup_str(file, "%s.name", section_name(psection));
4805 if (NULL == name) {
4806 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
4807 ok = FALSE;
4808 break;
4809 }
4810 pgroup = nation_group_new(name);
4811 if (pgroup == NULL) {
4812 ok = FALSE;
4813 break;
4814 }
4815 } section_list_iterate_end;
4816 section_list_destroy(sec);
4817 sec = NULL;
4818 }
4819 }
4820
4821 return ok;
4822}
4823
4824/**********************************************************************/
4827 static bool is_on_allowed_list(const char *name, const char **list, size_t len)
4828{
4829 int i;
4830
4831 for (i = 0; i < len; i++) {
4832 if (!fc_strcasecmp(name, list[i])) {
4833 return TRUE;
4834 }
4835 }
4836 return FALSE;
4837}
4838
4839/**********************************************************************/
4843 static bool load_city_name_list(struct section_file *file,
4844 struct nation_type *pnation,
4845 const char *secfile_str1,
4846 const char *secfile_str2,
4847 const char **allowed_terrains,
4848 size_t atcount)
4849{
4850 size_t dim, j;
4851 bool ok = TRUE;
4852 const char **cities = secfile_lookup_str_vec(file, &dim, "%s.%s",
4853 secfile_str1, secfile_str2);
4854
4855 /* Each string will be of the form "<cityname> (<label>, <label>, ...)".
4856 * The cityname is just the name for this city, while each "label" matches
4857 * a terrain type for the city (or "river"), with a preceeding ! to negate
4858 * it. The parentheses are optional (but necessary to have the settings,
4859 * of course). Our job is now to parse it. */
4860 for (j = 0; j < dim; j++) {
4861 size_t len = strlen(cities[j]);
4862 char city_name[len + 1], *p, *next, *end;
4863 struct nation_city *pncity;
4864
4865 sz_strlcpy(city_name, cities[j]);
4866
4867 /* Now we wish to determine values for all of the city labels. A value
4868 * of NCP_NONE means no preference (which is necessary so that the use
4869 * of this is optional); NCP_DISLIKE means the label is negated and
4870 * NCP_LIKE means it's labelled. Mostly the parsing just involves
4871 * a lot of ugly string handling... */
4872 if ((p = strchr(city_name, '('))) {
4873 *p++ = '\0';
4874
4875 if (!(end = strchr(p, ')'))) {
4876 ruleset_error(NULL, LOG_ERROR,
4877 "\"%s\" [%s] %s: city name \"%s\" "
4878 "unmatched parenthesis.", secfile_name(file),
4879 secfile_str1, secfile_str2, cities[j]);
4880 ok = FALSE;
4881 } else {
4882 for (*end++ = '\0'; '\0' != *end; end++) {
4883 if (!fc_isspace(*end)) {
4884 ruleset_error(NULL, LOG_ERROR,
4885 "\"%s\" [%s] %s: city name \"%s\" "
4886 "contains characters after last parenthesis.",
4887 secfile_name(file), secfile_str1, secfile_str2,
4888 cities[j]);
4889 ok = FALSE;
4890 break;
4891 }
4892 }
4893 }
4894 }
4895
4896 /* Build the nation_city. */
4897 remove_leading_trailing_spaces(city_name);
4898 if (check_cityname(city_name)) {
4899 /* The ruleset contains a name that is too long. This shouldn't
4900 * happen - if it does, the author should get immediate feedback. */
4901 ruleset_error(NULL, LOG_ERROR,
4902 "\"%s\" [%s] %s: city name \"%s\" is too long.",
4903 secfile_name(file),
4904 secfile_str1, secfile_str2, city_name);
4905 ok = FALSE;
4906 city_name[MAX_LEN_CITYNAME - 1] = '\0';
4907 }
4908 pncity = nation_city_new(pnation, city_name);
4909
4910 if (NULL != p) {
4911 /* Handle the labels one at a time. */
4912 do {
4913 enum nation_city_preference prefer;
4914
4915 if ((next = strchr(p, ','))) {
4916 *next = '\0';
4917 }
4918 remove_leading_trailing_spaces(p);
4919
4920 /* The ! is used to mark a negative, which is recorded with
4921 * NCP_DISLIKE. Otherwise we use a NCP_LIKE.
4922 */
4923 if (*p == '!') {
4924 p++;
4925 prefer = NCP_DISLIKE;
4926 } else {
4927 prefer = NCP_LIKE;
4928 }
4929
4930 if (0 == fc_strcasecmp(p, "river")) {
4931 if (game.server.ruledit.allowed_terrains != NULL
4932 && !is_on_allowed_list(p,
4933 game.server.ruledit.allowed_terrains, atcount)) {
4934 ruleset_error(NULL, LOG_ERROR,
4935 "\"%s\" [%s] %s: city \"%s\" "
4936 "has terrain hint \"%s\" not in allowed_terrains.",
4937 secfile_name(file), secfile_str1, secfile_str2,
4938 city_name, p);
4939 ok = FALSE;
4940 } else {
4941 nation_city_set_river_preference(pncity, prefer);
4942 }
4943 } else {
4944 const struct terrain *pterrain = terrain_by_rule_name(p);
4945
4946 if (NULL == pterrain) {
4947 /* Try with removing frequent trailing 's'. */
4948 size_t l = strlen(p);
4949
4950 if (0 < l && 's' == fc_tolower(p[l - 1])) {
4951 char saved = p[l - 1];
4952
4953 p[l - 1] = '\0';
4954 pterrain = terrain_by_rule_name(p);
4955 if (pterrain == NULL) {
4956 /* Didn't help, restore for later allowed_terrains check */
4957 p[l - 1] = saved;
4958 }
4959 }
4960 }
4961
4962 /* Nationset may have been devised with a specific set of terrains
4963 * in mind which don't quite match this ruleset, in which case we
4964 * (a) quietly ignore any hints mentioned that don't happen to be in
4965 * the current ruleset, (b) enforce that terrains mentioned by nations
4966 * must be on the list */
4967 if (pterrain != NULL && game.server.ruledit.allowed_terrains != NULL) {
4968 if (!is_on_allowed_list(p,
4969 game.server.ruledit.allowed_terrains, atcount)) {
4970 /* Terrain exists, but not intended for these nations */
4971 ruleset_error(NULL, LOG_ERROR,
4972 "\"%s\" [%s] %s: city \"%s\" "
4973 "has terrain hint \"%s\" not in allowed_terrains.",
4974 secfile_name(file), secfile_str1, secfile_str2,
4975 city_name, p);
4976 ok = FALSE;
4977 break;
4978 }
4979 } else if (!pterrain) {
4980 /* Terrain doesn't exist; only complain if it's not on any list */
4981 if (game.server.ruledit.allowed_terrains == NULL
4982 || !is_on_allowed_list(p,
4983 game.server.ruledit.allowed_terrains, atcount)) {
4984 ruleset_error(NULL, LOG_ERROR,
4985 "\"%s\" [%s] %s: city \"%s\" "
4986 "has unknown terrain hint \"%s\".",
4987 secfile_name(file), secfile_str1, secfile_str2,
4988 city_name, p);
4989 ok = FALSE;
4990 break;
4991 }
4992 }
4993 if (NULL != pterrain) {
4994 nation_city_set_terrain_preference(pncity, pterrain, prefer);
4995 }
4996 }
4997
4998 p = next ? next + 1 : NULL;
4999 } while (NULL != p && '\0' != *p);
5000 }
5001 }
5002
5003 if (NULL != cities) {
5004 free(cities);
5005 }
5006
5007 return ok;
5008}
5009
5010/**********************************************************************/
5013 static bool load_ruleset_nations(struct section_file *file,
5014 struct rscompat_info *compat)
5015{
5016 struct government *gov;
5017 int j;
5018 size_t dim;
5019 char temp_name[MAX_LEN_NAME];
5020 const char **vec;
5021 const char *name, *bad_leader;
5022 const char *sval;
5023 int default_set;
5024 const char *filename = secfile_name(file);
5025 struct section_list *sec = NULL;
5026 enum trait tr;
5027 bool ok = TRUE;
5028
5029 name = secfile_lookup_str_default(file, NULL, "ruledit.nationlist");
5030 if (name != NULL) {
5031 game.server.ruledit.nationlist = fc_strdup(name);
5032 }
5033 vec = secfile_lookup_str_vec(file, &game.server.ruledit.embedded_nations_count,
5034 "ruledit.embedded_nations");
5035
5036 if (vec != NULL) {
5037 /* Copy to persistent vector */
5038 game.server.ruledit.embedded_nations
5039 = fc_malloc(game.server.ruledit.embedded_nations_count * sizeof(char *));
5040
5041 for (j = 0; j < game.server.ruledit.embedded_nations_count; j++) {
5042 game.server.ruledit.embedded_nations[j] = fc_strdup(vec[j]);
5043 }
5044
5045 free(vec);
5046 }
5047
5048 game.default_government = NULL;
5049
5050 ruleset_load_traits(game.server.default_traits, file, "default_traits", "");
5051 for (tr = trait_begin(); tr != trait_end(); tr = trait_next(tr)) {
5052 if (game.server.default_traits[tr].min < 0) {
5053 game.server.default_traits[tr].min = TRAIT_DEFAULT_VALUE;
5054 }
5055 if (game.server.default_traits[tr].max < 0) {
5056 game.server.default_traits[tr].max = TRAIT_DEFAULT_VALUE;
5057 }
5058 if (game.server.default_traits[tr].fixed < 0) {
5059 int diff = game.server.default_traits[tr].max - game.server.default_traits[tr].min;
5060
5061 /* TODO: Should sometimes round the a / 2 = x.5 results up */
5062 game.server.default_traits[tr].fixed = diff / 2 + game.server.default_traits[tr].min;
5063 }
5064 if (game.server.default_traits[tr].max < game.server.default_traits[tr].min) {
5065 ruleset_error(NULL, LOG_ERROR,
5066 "Default values for trait %s not sane.",
5067 trait_name(tr));
5068 ok = FALSE;
5069 break;
5070 }
5071 }
5072
5073 if (ok) {
5074 vec = secfile_lookup_str_vec(file, &game.server.ruledit.ag_count,
5075 "compatibility.allowed_govs");
5076 if (vec != NULL) {
5077 /* Copy to persistent vector */
5078 game.server.ruledit.nc_agovs
5079 = fc_malloc(game.server.ruledit.ag_count * sizeof(char *));
5080 game.server.ruledit.allowed_govs =
5081 (const char **)game.server.ruledit.nc_agovs;
5082
5083 for (j = 0; j < game.server.ruledit.ag_count; j++) {
5084 game.server.ruledit.allowed_govs[j] = fc_strdup(vec[j]);
5085 }
5086
5087 free(vec);
5088 }
5089
5090 vec = secfile_lookup_str_vec(file, &game.server.ruledit.at_count,
5091 "compatibility.allowed_terrains");
5092 if (vec != NULL) {
5093 /* Copy to persistent vector */
5094 game.server.ruledit.nc_aterrs
5095 = fc_malloc(game.server.ruledit.at_count * sizeof(char *));
5096 game.server.ruledit.allowed_terrains =
5097 (const char **)game.server.ruledit.nc_aterrs;
5098
5099 for (j = 0; j < game.server.ruledit.at_count; j++) {
5100 game.server.ruledit.allowed_terrains[j] = fc_strdup(vec[j]);
5101 }
5102
5103 free(vec);
5104 }
5105
5106 vec = secfile_lookup_str_vec(file, &game.server.ruledit.as_count,
5107 "compatibility.allowed_styles");
5108 if (vec != NULL) {
5109 /* Copy to persistent vector */
5110 game.server.ruledit.nc_astyles
5111 = fc_malloc(game.server.ruledit.as_count * sizeof(char *));
5112 game.server.ruledit.allowed_styles =
5113 (const char **)game.server.ruledit.nc_astyles;
5114
5115 for (j = 0; j < game.server.ruledit.as_count; j++) {
5116 game.server.ruledit.allowed_styles[j] = fc_strdup(vec[j]);
5117 }
5118
5119 free(vec);
5120 }
5121
5122 sval = secfile_lookup_str_default(file, NULL,
5123 "compatibility.default_government");
5124 /* We deliberately don't check this against allowed_govs. It's only
5125 * specified once so not vulnerable to typos, and may usefully be set in
5126 * a specific ruleset to a gov not explicitly known by the nation set. */
5127 if (sval != NULL) {
5128 game.default_government = government_by_rule_name(sval);
5129 if (game.default_government == NULL) {
5130 ruleset_error(NULL, LOG_ERROR,
5131 "Tried to set unknown government type \"%s\" as default_government!",
5132 sval);
5133 ok = FALSE;
5134 } else {
5135 game.info.default_government_id
5136 = government_number(game.default_government);
5137 }
5138 }
5139 }
5140
5141 if (ok) {
5142 sec = secfile_sections_by_name_prefix(file, NATION_SET_SECTION_PREFIX);
5143 if (sec != NULL) {
5144 game.control.num_nation_sets = section_list_size(sec);
5145
5146 section_list_iterate(sec, psection) {
5147 const char *set_name, *set_rule_name, *set_description;
5148
5149 set_name = secfile_lookup_str(file, "%s.name", section_name(psection));
5150 set_rule_name =
5151 secfile_lookup_str(file, "%s.rule_name", section_name(psection));
5152 set_description = secfile_lookup_str_default(file, "", "%s.description",
5153 section_name(psection));
5154 if (NULL == set_name || NULL == set_rule_name) {
5155 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
5156 ok = FALSE;
5157 break;
5158 }
5159 if (nation_set_new(set_name, set_rule_name, set_description) == NULL) {
5160 ok = FALSE;
5161 break;
5162 }
5163 } section_list_iterate_end;
5164 section_list_destroy(sec);
5165 sec = NULL;
5166 } else {
5167 ruleset_error(NULL, LOG_ERROR,
5168 "At least one nation set [" NATION_SET_SECTION_PREFIX "_*] "
5169 "must be defined.");
5170 ok = FALSE;
5171 }
5172 }
5173
5174 if (ok) {
5175 /* Default set that every nation is a member of. */
5176 sval = secfile_lookup_str_default(file, NULL,
5177 "compatibility.default_nationset");
5178 if (sval != NULL) {
5179 const struct nation_set *pset = nation_set_by_rule_name(sval);
5180 if (pset != NULL) {
5181 default_set = nation_set_number(pset);
5182 } else {
5183 ruleset_error(NULL, LOG_ERROR,
5184 "Unknown default_nationset \"%s\".", sval);
5185 ok = FALSE;
5186 }
5187 } else if (nation_set_count() == 1) {
5188 /* If there's only one set defined, every nation is implicitly a
5189 * member of that set. */
5190 default_set = 0;
5191 } else {
5192 /* No default nation set; every nation must explicitly specify at
5193 * least one set to be a member of. */
5194 default_set = -1;
5195 }
5196 }
5197
5198 if (ok) {
5199 sec = secfile_sections_by_name_prefix(file, NATION_GROUP_SECTION_PREFIX);
5200 if (sec) {
5201 section_list_iterate(sec, psection) {
5202 struct nation_group *pgroup;
5203 bool hidden;
5204
5205 name = secfile_lookup_str(file, "%s.name", section_name(psection));
5206 pgroup = nation_group_by_rule_name(name);
5207 if (pgroup == NULL) {
5208 ok = FALSE;
5209 break;
5210 }
5211
5212 hidden = secfile_lookup_bool_default(file, FALSE, "%s.hidden",
5213 section_name(psection));
5214 nation_group_set_hidden(pgroup, hidden);
5215
5216 if (!secfile_lookup_int(file, &j, "%s.match", section_name(psection))) {
5217 ruleset_error(NULL, LOG_ERROR, "Error: %s", secfile_error());
5218 ok = FALSE;
5219 break;
5220 }
5221 nation_group_set_match(pgroup, j);
5222 } section_list_iterate_end;
5223 section_list_destroy(sec);
5224 sec = NULL;
5225 }
5226 }
5227
5228 if (ok) {
5229 sec = secfile_sections_by_name_prefix(file, NATION_SECTION_PREFIX);
5230 nations_iterate(pnation) {
5231 struct nation_type *pconflict;
5232 const int i = nation_index(pnation);
5233 char tmp[200] = "\0";
5234 const char *barb_type;
5235 const char *sec_name = section_name(section_list_get(sec, i));
5236 const char *legend;
5237
5238 /* Nation sets and groups. */
5239 if (default_set >= 0) {
5240 nation_set_list_append(pnation->sets,
5241 nation_set_by_number(default_set));
5242 }
5243 vec = secfile_lookup_str_vec(file, &dim, "%s.groups", sec_name);
5244 for (j = 0; j < dim; j++) {
5245 struct nation_set *pset = nation_set_by_rule_name(vec[j]);
5246 struct nation_group *pgroup = nation_group_by_rule_name(vec[j]);
5247
5248 fc_assert(pset == NULL || pgroup == NULL);
5249
5250 if (NULL != pset) {
5251 nation_set_list_append(pnation->sets, pset);
5252 } else if (NULL != pgroup) {
5253 nation_group_list_append(pnation->groups, pgroup);
5254 } else {
5255 /* For nation authors, this would probably be considered an error.
5256 * But it can happen normally. The civ1 compatibility ruleset only
5257 * uses the nations that were in civ1, so not all of the links will
5258 * exist. */
5259 log_verbose("Nation %s: Unknown set/group \"%s\".",
5260 nation_rule_name(pnation), vec[j]);
5261 }
5262 }
5263 if (NULL != vec) {
5264 free(vec);
5265 }
5266 if (nation_set_list_size(pnation->sets) < 1) {
5267 ruleset_error(NULL, LOG_ERROR,
5268 "Nation %s is not a member of any nation set",
5269 nation_rule_name(pnation));
5270 ok = FALSE;
5271 break;
5272 }
5273
5274 /* Nation conflicts. */
5275 vec = secfile_lookup_str_vec(file, &dim, "%s.conflicts_with", sec_name);
5276 for (j = 0; j < dim; j++) {
5277 pconflict = nation_by_rule_name(vec[j]);
5278
5279 if (pnation == pconflict) {
5280 ruleset_error(NULL, LOG_ERROR,
5281 "Nation %s conflicts with itself",
5282 nation_rule_name(pnation));
5283 ok = FALSE;
5284 break;
5285 } else if (NULL != pconflict) {
5286 nation_list_append(pnation->server.conflicts_with, pconflict);
5287 } else {
5288 /* For nation authors, this would probably be considered an error.
5289 * But it can happen normally. The civ1 compatibility ruleset only
5290 * uses the nations that were in civ1, so not all of the links will
5291 * exist. */
5292 log_verbose("Nation %s: conflicts_with nation \"%s\" is unknown.",
5293 nation_rule_name(pnation), vec[j]);
5294 }
5295 }
5296 if (NULL != vec) {
5297 free(vec);
5298 }
5299 if (!ok) {
5300 break;
5301 }
5302
5303 /* Nation leaders. */
5304 for (j = 0; j < MAX_NUM_LEADERS; j++) {
5305 const char *sex;
5306 bool is_male = FALSE;
5307
5308 name = secfile_lookup_str(file, "%s.leaders%d.name", sec_name, j);
5309 if (NULL == name) {
5310 /* No more to read. */
5311 break;
5312 }
5313
5314 if (check_name(name)) {
5315 /* The ruleset contains a name that is too long. This shouldn't
5316 * happen - if it does, the author should get immediate feedback */
5317 sz_strlcpy(temp_name, name);
5318 ruleset_error(NULL, LOG_ERROR,
5319 "Nation %s: leader name \"%s\" is too long.",
5320 nation_rule_name(pnation), name);
5321 ok = FALSE;
5322 break;
5323 }
5324
5325 sex = secfile_lookup_str(file, "%s.leaders%d.sex", sec_name, j);
5326 if (NULL == sex) {
5327 ruleset_error(NULL, LOG_ERROR, "Nation %s: leader \"%s\": %s.",
5328 nation_rule_name(pnation), name, secfile_error());
5329 ok = FALSE;
5330 break;
5331 } else if (0 == fc_strcasecmp("Male", sex)) {
5332 is_male = TRUE;
5333 } else if (0 != fc_strcasecmp("Female", sex)) {
5334 ruleset_error(NULL, LOG_ERROR,
5335 "Nation %s: leader \"%s\" has unsupported "
5336 "sex variant \"%s\".",
5337 nation_rule_name(pnation), name, sex);
5338 ok = FALSE;
5339 break;
5340 }
5341 (void) nation_leader_new(pnation, name, is_male);
5342 }
5343 if (!ok) {
5344 break;
5345 }
5346
5347 /* Check the number of leaders. */
5348 if (MAX_NUM_LEADERS == j) {
5349 /* Too much leaders, get the real number defined in the ruleset. */
5350 while (NULL != secfile_entry_lookup(file, "%s.leaders%d.name",
5351 sec_name, j)) {
5352 j++;
5353 }
5354 ruleset_error(NULL, LOG_ERROR,
5355 "Nation %s: Too many leaders; max is %d",
5356 nation_rule_name(pnation), MAX_NUM_LEADERS);
5357 ok = FALSE;
5358 break;
5359 } else if (0 == j) {
5360 ruleset_error(NULL, LOG_ERROR,
5361 "Nation %s: no leaders; at least one is required.",
5362 nation_rule_name(pnation));
5363 ok = FALSE;
5364 break;
5365 }
5366
5367 /* Check if leader name is not already defined in this nation. */
5368 if ((bad_leader = check_leader_names(pnation))) {
5369 ruleset_error(NULL, LOG_ERROR,
5370 "Nation %s: leader \"%s\" defined more than once.",
5371 nation_rule_name(pnation), bad_leader);
5372 ok = FALSE;
5373 break;
5374 }
5375
5376 /* Nation player color preference, if any */
5377 fc_assert_ret_val(pnation->server.rgb == NULL, FALSE);
5378 (void) rgbcolor_load(file, &pnation->server.rgb, "%s.color", sec_name);
5379
5380 /* Load nation traits */
5381 ruleset_load_traits(pnation->server.traits, file, sec_name, "trait_");
5382 for (tr = trait_begin(); tr != trait_end(); tr = trait_next(tr)) {
5383 bool server_traits_used = TRUE;
5384
5385 if (pnation->server.traits[tr].min < 0) {
5386 pnation->server.traits[tr].min = game.server.default_traits[tr].min;
5387 } else {
5388 server_traits_used = FALSE;
5389 }
5390 if (pnation->server.traits[tr].max < 0) {
5391 pnation->server.traits[tr].max = game.server.default_traits[tr].max;
5392 } else {
5393 server_traits_used = FALSE;
5394 }
5395 if (pnation->server.traits[tr].fixed < 0) {
5396 if (server_traits_used) {
5397 pnation->server.traits[tr].fixed = game.server.default_traits[tr].fixed;
5398 } else {
5399 int diff = pnation->server.traits[tr].max - pnation->server.traits[tr].min;
5400
5401 /* TODO: Should sometimes round the a / 2 = x.5 results up */
5402 pnation->server.traits[tr].fixed = diff / 2 + pnation->server.traits[tr].min;
5403 }
5404 }
5405 if (pnation->server.traits[tr].max < pnation->server.traits[tr].min) {
5406 ruleset_error(NULL, LOG_ERROR,
5407 "%s values for trait %s not sane.",
5408 nation_rule_name(pnation), trait_name(tr));
5409 ok = FALSE;
5410 break;
5411 }
5412 }
5413
5414 if (!ok) {
5415 break;
5416 }
5417
5418 pnation->is_playable =
5419 secfile_lookup_bool_default(file, TRUE, "%s.is_playable", sec_name);
5420
5421 /* Check barbarian type. Default is "None" meaning not a barbarian */
5422 barb_type = secfile_lookup_str_default(file, "None",
5423 "%s.barbarian_type", sec_name);
5424 pnation->barb_type = barbarian_type_by_name(barb_type, fc_strcasecmp);
5425 if (!barbarian_type_is_valid(pnation->barb_type)) {
5426 ruleset_error(NULL, LOG_ERROR,
5427 "Nation %s, barbarian_type is invalid (\"%s\")",
5428 nation_rule_name(pnation), barb_type);
5429 ok = FALSE;
5430 break;
5431 }
5432
5433 if (pnation->barb_type != NOT_A_BARBARIAN
5434 && pnation->is_playable) {
5435 /* We can't allow players to use barbarian nations, barbarians
5436 * may run out of nations */
5437 ruleset_error(NULL, LOG_ERROR,
5438 "Nation %s marked both barbarian and playable.",
5439 nation_rule_name(pnation));
5440 ok = FALSE;
5441 break;
5442 }
5443
5444 /* Flags */
5445 sz_strlcpy(pnation->flag_graphic_str,
5446 secfile_lookup_str_default(file, "-", "%s.flag", sec_name));
5447 sz_strlcpy(pnation->flag_graphic_alt,
5448 secfile_lookup_str_default(file, "-",
5449 "%s.flag_alt", sec_name));
5450
5451 /* Ruler titles */
5452 for (j = 0;; j++) {
5453 const char *male, *female;
5454
5455 name = secfile_lookup_str_default(file, NULL,
5456 "%s.ruler_titles%d.government",
5457 sec_name, j);
5458 if (NULL == name) {
5459 /* End of the list of ruler titles. */
5460 break;
5461 }
5462
5463 /* NB: even if the government doesn't exist, we load the entries for
5464 * the ruler titles to avoid warnings about unused entries. */
5465 male = secfile_lookup_str(file, "%s.ruler_titles%d.male_title",
5466 sec_name, j);
5467 female = secfile_lookup_str(file, "%s.ruler_titles%d.female_title",
5468 sec_name, j);
5469 gov = government_by_rule_name(name);
5470
5471 /* Nationset may have been devised with a specific set of govs in
5472 * mind which don't quite match this ruleset, in which case we
5473 * (a) quietly ignore any govs mentioned that don't happen to be in
5474 * the current ruleset, (b) enforce that govs mentioned by nations
5475 * must be on the list */
5476 if (gov != NULL && game.server.ruledit.allowed_govs != NULL) {
5477 if (!is_on_allowed_list(name,
5478 game.server.ruledit.allowed_govs,
5479 game.server.ruledit.ag_count)) {
5480 /* Gov exists, but not intended for these nations */
5481 gov = NULL;
5482 ruleset_error(NULL, LOG_ERROR,
5483 "Nation %s: government \"%s\" not in allowed_govs.",
5484 nation_rule_name(pnation), name);
5485 ok = FALSE;
5486 break;
5487 }
5488 } else if (!gov) {
5489 /* Gov doesn't exist; only complain if it's not on any list */
5490 if (game.server.ruledit.allowed_govs == NULL
5491 || !is_on_allowed_list(name,
5492 game.server.ruledit.allowed_govs,
5493 game.server.ruledit.ag_count)) {
5494 ruleset_error(NULL, LOG_ERROR,
5495 "Nation %s: government \"%s\" not found.",
5496 nation_rule_name(pnation), name);
5497 ok = FALSE;
5498 break;
5499 }
5500 }
5501 if (NULL != male && NULL != female) {
5502 if (gov) {
5503 (void) government_ruler_title_new(gov, pnation, male, female);
5504 }
5505 } else {
5506 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
5507 ok = FALSE;
5508 break;
5509 }
5510 }
5511 if (!ok) {
5512 break;
5513 }
5514
5515 /* City styles */
5516 name = secfile_lookup_str(file, "%s.style", sec_name);
5517 if (!name) {
5518 ruleset_error(NULL, LOG_ERROR, "%s", secfile_error());
5519 ok = FALSE;
5520 break;
5521 }
5522 pnation->style = style_by_rule_name(name);
5523 if (pnation->style == NULL) {
5524 if (game.server.ruledit.allowed_styles == NULL
5525 || !is_on_allowed_list(name,
5526 game.server.ruledit.allowed_styles,
5527 game.server.ruledit.as_count)) {
5528 ruleset_error(NULL, LOG_ERROR,
5529 "Nation %s: Illegal style \"%s\"",
5530 nation_rule_name(pnation), name);
5531 ok = FALSE;
5532 break;
5533 } else {
5534 log_verbose("Nation %s: style \"%s\" not supported in this "
5535 "ruleset; using default.",
5536 nation_rule_name(pnation), name);
5537 pnation->style = style_by_number(0);
5538 }
5539 }
5540
5541 /* Civilwar nations */
5542 vec = secfile_lookup_str_vec(file, &dim,
5543 "%s.civilwar_nations", sec_name);
5544 for (j = 0; j < dim; j++) {
5545 pconflict = nation_by_rule_name(vec[j]);
5546
5547 /* No test for duplicate nations is performed. If there is a duplicate
5548 * entry it will just cause that nation to have an increased
5549 * probability of being chosen. */
5550 if (pconflict == pnation) {
5551 ruleset_error(NULL, LOG_ERROR,
5552 "Nation %s is its own civil war nation",
5553 nation_rule_name(pnation));
5554 ok = FALSE;
5555 break;
5556 } else if (NULL != pconflict) {
5557 nation_list_append(pnation->server.civilwar_nations, pconflict);
5558 nation_list_append(pconflict->server.parent_nations, pnation);
5559 } else {
5560 /* For nation authors, this would probably be considered an error.
5561 * But it can happen normally. The civ1 compatibility ruleset only
5562 * uses the nations that were in civ1, so not all of the links will
5563 * exist. */
5564 log_verbose("Nation %s: civil war nation \"%s\" is unknown.",
5565 nation_rule_name(pnation), vec[j]);
5566 }
5567 }
5568 if (NULL != vec) {
5569 free(vec);
5570 }
5571 if (!ok) {
5572 break;
5573 }
5574
5575 /* Load nation specific initial items */
5576 if (!lookup_tech_list(file, sec_name, "init_techs",
5577 pnation->init_techs, filename)) {
5578 ok = FALSE;
5579 break;
5580 }
5581 if (!lookup_building_list(file, sec_name, "init_buildings",
5582 pnation->init_buildings, filename)) {
5583 ok = FALSE;
5584 break;
5585 }
5586 if (!lookup_unit_list(file, sec_name, "init_units",
5587 pnation->init_units, filename)) {
5588 ok = FALSE;
5589 break;
5590 }
5591 fc_strlcat(tmp, sec_name, 200);
5592 fc_strlcat(tmp, ".init_government", 200);
5593 if (secfile_entry_by_path(file, tmp)) {
5594 pnation->init_government = lookup_government(file, tmp, filename,
5595 NULL);
5596 /* If specified, init_government has to be in this specific ruleset,
5597 * not just allowed_govs */
5598 if (pnation->init_government == NULL) {
5599 ok = FALSE;
5600 break;
5601 }
5602 /* ...but if a list of govs has been specified, enforce that this
5603 * nation's init_government is on the list. */
5604 if (game.server.ruledit.allowed_govs != NULL
5605 && !is_on_allowed_list(government_rule_name(pnation->init_government),
5606 game.server.ruledit.allowed_govs,
5607 game.server.ruledit.ag_count)) {
5608 ruleset_error(NULL, LOG_ERROR,
5609 "Nation %s: init_government \"%s\" not allowed.",
5610 nation_rule_name(pnation),
5611 government_rule_name(pnation->init_government));
5612 ok = FALSE;
5613 break;
5614 }
5615 }
5616
5617 /* Read default city names. */
5618 if (!load_city_name_list(file, pnation, sec_name, "cities",
5619 game.server.ruledit.allowed_terrains,
5620 game.server.ruledit.at_count)) {
5621 ok = FALSE;
5622 break;
5623 }
5624
5625 legend = secfile_lookup_str_default(file, "", "%s.legend", sec_name);
5626 pnation->legend = fc_strdup(legend);
5627 if (check_strlen(pnation->legend, MAX_LEN_MSG, NULL)) {
5628 ruleset_error(NULL, LOG_ERROR,
5629 "Nation %s: legend \"%s\" is too long.",
5630 nation_rule_name(pnation),
5631 pnation->legend);
5632 ok = FALSE;
5633 break;
5634 }
5635
5636 pnation->player = NULL;
5637 } nations_iterate_end;
5638 section_list_destroy(sec);
5639 sec = NULL;
5640 }
5641
5642 /* Clean up on aborted load */
5643 if (sec != NULL) {
5644 fc_assert(!ok);
5645 section_list_destroy(sec);
5646 }
5647
5648 if (ok) {
5649 secfile_check_unused(file);
5650 }
5651
5652 if (ok) {
5653 /* Update cached number of playable nations in the current set */
5654 count_playable_nations();
5655
5656 /* Sanity checks on all sets */
5657 nation_sets_iterate(pset) {
5658 int num_playable = 0, barb_land_count = 0, barb_sea_count = 0, barb_both_count = 0;
5659
5660 nations_iterate(pnation) {
5661 if (nation_is_in_set(pnation, pset)) {
5662 switch (nation_barbarian_type(pnation)) {
5663 case NOT_A_BARBARIAN:
5664 if (is_nation_playable(pnation)) {
5665 num_playable++;
5666 }
5667 break;
5668 case LAND_BARBARIAN:
5669 barb_land_count++;
5670 break;
5671 case SEA_BARBARIAN:
5672 barb_sea_count++;
5673 break;
5674 case ANIMAL_BARBARIAN:
5675 /* Animals are optional */
5676 break;
5677 case LAND_AND_SEA_BARBARIAN:
5678 barb_both_count++;
5679 break;
5680 default:
5681 fc_assert_ret_val(FALSE, FALSE);
5682 }
5683 }
5684 } nations_iterate_end;
5685 if (num_playable < 1) {
5686 ruleset_error(NULL, LOG_ERROR,
5687 "Nation set \"%s\" has no playable nations. "
5688 "At least one required!", nation_set_rule_name(pset));
5689 ok = FALSE;
5690 break;
5691 }
5692 if (barb_land_count == 0 && barb_both_count == 0) {
5693 ruleset_error(NULL, LOG_ERROR,
5694 "No land barbarian nation defined in set \"%s\". "
5695 "At least one required!", nation_set_rule_name(pset));
5696 ok = FALSE;
5697 break;
5698 }
5699 if (barb_sea_count == 0 && barb_both_count == 0) {
5700 ruleset_error(NULL, LOG_ERROR,
5701 "No sea barbarian nation defined in set \"%s\". "
5702 "At least one required!", nation_set_rule_name(pset));
5703 ok = FALSE;
5704 break;
5705 }
5706 } nation_sets_iterate_end;
5707 }
5708
5709 return ok;
5710}
5711
5712/**********************************************************************/
5716 static bool load_style_names(struct section_file *file,
5717 struct rscompat_info *compat)
5718{
5719 bool ok = TRUE;
5720 struct section_list *sec;
5721 const char *filename = secfile_name(file);
5722
5723 if (!rscompat_check_cap_and_version(file, filename, compat)) {
5724 return FALSE;
5725 }
5726
5727 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
5728 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
5729
5730 sec = secfile_sections_by_name_prefix(file, STYLE_SECTION_PREFIX);
5731 if (NULL == sec) {
5732 ruleset_error(NULL, LOG_ERROR,
5733 "No available nation styles in this ruleset!");
5734 ok = FALSE;
5735 } else {
5736 game.control.num_styles = section_list_size(sec);
5737
5738 styles_alloc(game.control.num_styles);
5739
5740 styles_iterate(ps) {
5741 const int i = style_index(ps);
5742 const char *sec_name = section_name(section_list_get(sec, i));
5743
5744 ruleset_load_names(&ps->name, NULL, file, sec_name);
5745 } styles_iterate_end;
5746 }
5747
5748 section_list_destroy(sec);
5749
5750 if (ok) {
5751 /* The citystyle sections: */
5752 int i = 0;
5753
5754 sec = secfile_sections_by_name_prefix(file, CITYSTYLE_SECTION_PREFIX);
5755 if (NULL != sec) {
5756 city_styles_alloc(section_list_size(sec));
5757 section_list_iterate(sec, style) {
5758 if (!ruleset_load_names(&city_styles[i].name, NULL, file, section_name(style))) {
5759 ok = FALSE;
5760 break;
5761 }
5762 i++;
5763 } section_list_iterate_end;
5764
5765 section_list_destroy(sec);
5766 } else {
5767 city_styles_alloc(0);
5768 }
5769 }
5770
5771 return ok;
5772}
5773
5774/**********************************************************************/
5777 static bool load_ruleset_styles(struct section_file *file,
5778 struct rscompat_info *compat)
5779{
5780 struct section_list *sec;
5781 int i;
5782 bool ok = TRUE;
5783
5784 /* City Styles ... */
5785
5786 sec = secfile_sections_by_name_prefix(file, CITYSTYLE_SECTION_PREFIX);
5787
5788 /* Get rest: */
5789 for (i = 0; i < game.control.styles_count; i++) {
5790 struct requirement_vector *reqs;
5791 const char *sec_name = section_name(section_list_get(sec, i));
5792
5793 sz_strlcpy(city_styles[i].graphic,
5794 secfile_lookup_str(file, "%s.graphic", sec_name));
5795 sz_strlcpy(city_styles[i].graphic_alt,
5796 secfile_lookup_str(file, "%s.graphic_alt", sec_name));
5797 sz_strlcpy(city_styles[i].citizens_graphic,
5798 secfile_lookup_str_default(file, "-",
5799 "%s.citizens_graphic", sec_name));
5800
5801 reqs = lookup_req_list(file, compat, sec_name, "reqs", city_style_rule_name(i));
5802 if (reqs == NULL) {
5803 ok = FALSE;
5804 break;
5805 }
5806 requirement_vector_copy(&city_styles[i].reqs, reqs);
5807 }
5808
5809 section_list_destroy(sec);
5810
5811 if (ok) {
5812 sec = secfile_sections_by_name_prefix(file, MUSICSTYLE_SECTION_PREFIX);
5813
5814 if (sec != NULL) {
5815 int musi;
5816
5817 game.control.num_music_styles = section_list_size(sec);
5818 music_styles_alloc(game.control.num_music_styles);
5819 musi = 0;
5820
5821 section_list_iterate(sec, psection) {
5822 struct requirement_vector *reqs;
5823 struct music_style *pmus = music_style_by_number(musi);
5824 const char *sec_name = section_name(psection);
5825
5826 sz_strlcpy(pmus->music_peaceful,
5827 secfile_lookup_str_default(file, "-",
5828 "%s.music_peaceful", sec_name));
5829 sz_strlcpy(pmus->music_combat,
5830 secfile_lookup_str_default(file, "-",
5831 "%s.music_combat", sec_name));
5832
5833 reqs = lookup_req_list(file, compat, sec_name, "reqs", "Music Style");
5834 if (reqs == NULL) {
5835 ok = FALSE;
5836 break;
5837 }
5838 requirement_vector_copy(&pmus->reqs, reqs);
5839
5840 musi++;
5841 } section_list_iterate_end;
5842 }
5843
5844 section_list_destroy(sec);
5845 }
5846
5847 return ok;
5848}
5849
5850/**********************************************************************/
5855 static bool load_action_auto_uflag_block(struct section_file *file,
5856 struct action_auto_perf *auto_perf,
5857 const char *uflags_path,
5858 const char *filename)
5859{
5860 /* Add each listed protected unit type flag as a !present
5861 * requirement. */
5862 if (secfile_entry_lookup(file, "%s", uflags_path)) {
5863 enum unit_type_flag_id *protecor_flag;
5864 size_t psize;
5865 int i;
5866
5867 protecor_flag =
5868 secfile_lookup_enum_vec(file, &psize, unit_type_flag_id,
5869 "%s", uflags_path);
5870
5871 if (!protecor_flag) {
5872 /* Entity exists but couldn't read it. */
5873 ruleset_error(NULL, LOG_ERROR,
5874 "\"%s\": %s: bad unit type flag list.",
5875 filename, uflags_path);
5876
5877 return FALSE;
5878 }
5879
5880 for (i = 0; i < psize; i++) {
5881 requirement_vector_append(&auto_perf->reqs,
5882 req_from_values(VUT_UTFLAG,
5883 REQ_RANGE_LOCAL,
5884 FALSE, FALSE, TRUE,
5885 protecor_flag[i]));
5886 }
5887
5888 free(protecor_flag);
5889 }
5890
5891 return TRUE;
5892}
5893
5894/**********************************************************************/
5898 static bool load_action_auto_actions(struct section_file *file,
5899 struct action_auto_perf *auto_perf,
5900 const char *actions_path,
5901 const char *filename)
5902{
5903 /* Read the alternative actions. */
5904 if (secfile_entry_lookup(file, "%s", actions_path)) {
5905 enum gen_action *unit_acts;
5906 size_t asize;
5907 int i;
5908
5909 unit_acts = secfile_lookup_enum_vec(file, &asize, gen_action,
5910 "%s", actions_path);
5911
5912 if (!unit_acts) {
5913 /* Entity exists but couldn't read it. */
5914 ruleset_error(NULL, LOG_ERROR,
5915 "\"%s\": %s: bad action list",
5916 filename, actions_path);
5917
5918 return FALSE;
5919 }
5920
5921 for (i = 0; i < asize; i++) {
5922 auto_perf->alternatives[i] = unit_acts[i];
5923 }
5924
5925 free(unit_acts);
5926 }
5927
5928 return TRUE;
5929}
5930
5931/**********************************************************************/
5934 static bool load_muuk_as_action_auto(struct section_file *file,
5935 struct action_auto_perf *auto_perf,
5936 const char *item,
5937 const char *filename)
5938{
5939 char uflags_path[100];
5940 char action_path[100];
5941
5942 fc_snprintf(uflags_path, sizeof(uflags_path),
5943 "missing_unit_upkeep.%s_protected", item);
5944 fc_snprintf(action_path, sizeof(action_path),
5945 "missing_unit_upkeep.%s_unit_act", item);
5946
5947 return (load_action_auto_uflag_block(file, auto_perf, uflags_path,
5948 filename)
5949 && load_action_auto_actions(file, auto_perf, action_path,
5950 filename));
5951}
5952
5953/**********************************************************************/
5956 static bool load_ruleset_cities(struct section_file *file,
5957 struct rscompat_info *compat)
5958{
5959 const char *filename = secfile_name(file);
5960 const char *item;
5961 struct section_list *sec;
5962 bool ok = TRUE;
5963
5964 if (!rscompat_check_cap_and_version(file, filename, compat)) {
5965 return FALSE;
5966 }
5967
5968 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
5969 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
5970
5971 /* Specialist options */
5972 sec = secfile_sections_by_name_prefix(file, SPECIALIST_SECTION_PREFIX);
5973 if (section_list_size(sec) >= SP_MAX) {
5974 ruleset_error(NULL, LOG_ERROR,
5975 "\"%s\": Too many specialists (%d, max %d).",
5976 filename, section_list_size(sec), SP_MAX);
5977 ok = FALSE;
5978 }
5979
5980 if (ok) {
5981 int i = 0;
5982 const char *tag;
5983
5984 game.control.num_specialist_types = section_list_size(sec);
5985
5986 section_list_iterate(sec, psection) {
5987 struct specialist *s = specialist_by_number(i);
5988 struct requirement_vector *reqs;
5989 const char *sec_name = section_name(psection);
5990
5991 if (!ruleset_load_names(&s->name, NULL, file, sec_name)) {
5992 ok = FALSE;
5993 break;
5994 }
5995
5996 item = secfile_lookup_str_default(file, untranslated_name(&s->name),
5997 "%s.short_name", sec_name);
5998 name_set(&s->abbreviation, NULL, item);
5999
6000 tag = secfile_lookup_str(file, "%s.graphic", sec_name);
6001 if (tag == NULL) {
6002 ruleset_error(NULL, LOG_ERROR,
6003 "\"%s\": No graphic tag for specialist at %s.",
6004 filename, sec_name);
6005 ok = FALSE;
6006 break;
6007 }
6008 sz_strlcpy(s->graphic_str, tag);
6009 sz_strlcpy(s->graphic_alt,
6010 secfile_lookup_str_default(file, "-",
6011 "%s.graphic_alt", sec_name));
6012
6013 reqs = lookup_req_list(file, compat, sec_name, "reqs", specialist_rule_name(s));
6014 if (reqs == NULL) {
6015 ok = FALSE;
6016 break;
6017 }
6018 requirement_vector_copy(&s->reqs, reqs);
6019
6020 s->helptext = lookup_strvec(file, sec_name, "helptext");
6021
6022 if (requirement_vector_size(&s->reqs) == 0 && DEFAULT_SPECIALIST == -1) {
6023 DEFAULT_SPECIALIST = i;
6024 }
6025 i++;
6026 } section_list_iterate_end;
6027 }
6028
6029 if (ok && DEFAULT_SPECIALIST == -1) {
6030 ruleset_error(NULL, LOG_ERROR,
6031 "\"%s\": must give a min_size of 0 for at least one "
6032 "specialist type.", filename);
6033 ok = FALSE;
6034 }
6035 section_list_destroy(sec);
6036 sec = NULL;
6037
6038 if (ok) {
6039 /* City Parameters */
6040
6041 game.info.celebratesize =
6042 secfile_lookup_int_default(file, GAME_DEFAULT_CELEBRATESIZE,
6043 "parameters.celebrate_size_limit");
6044 game.info.add_to_size_limit =
6045 secfile_lookup_int_default(file, GAME_DEFAULT_ADDTOSIZE, "parameters.add_to_size_limit");
6046 game.info.angrycitizen =
6047 secfile_lookup_bool_default(file, GAME_DEFAULT_ANGRYCITIZEN,
6048 "parameters.angry_citizens");
6049
6050 game.info.changable_tax =
6051 secfile_lookup_bool_default(file, GAME_DEFAULT_CHANGABLE_TAX, "parameters.changable_tax");
6052 game.info.forced_science =
6053 secfile_lookup_int_default(file, 0, "parameters.forced_science");
6054 game.info.forced_luxury =
6055 secfile_lookup_int_default(file, 100, "parameters.forced_luxury");
6056 game.info.forced_gold =
6057 secfile_lookup_int_default(file, 0, "parameters.forced_gold");
6058 if (game.info.forced_science + game.info.forced_luxury
6059 + game.info.forced_gold != 100) {
6060 ruleset_error(NULL, LOG_ERROR,
6061 "\"%s\": Forced taxes do not add up in ruleset!",
6062 filename);
6063 ok = FALSE;
6064 }
6065 }
6066
6067 if (ok) {
6068 /* civ1 & 2 didn't reveal tiles */
6069 game.server.vision_reveal_tiles =
6070 secfile_lookup_bool_default(file, GAME_DEFAULT_VISION_REVEAL_TILES,
6071 "parameters.vision_reveal_tiles");
6072
6073 game.info.pop_report_zeroes =
6074 secfile_lookup_int_default(file, 1, "parameters.pop_report_zeroes");
6075
6076 /* Citizens configuration. */
6077 game.info.citizen_nationality =
6078 secfile_lookup_bool_default(file, GAME_DEFAULT_NATIONALITY,
6079 "citizen.nationality");
6080 game.info.citizen_convert_speed =
6081 secfile_lookup_int_default(file, GAME_DEFAULT_CONVERT_SPEED,
6082 "citizen.convert_speed");
6083 game.info.citizen_partisans_pct =
6084 secfile_lookup_int_default(file, 0, "citizen.partisans_pct");
6085 game.info.conquest_convert_pct =
6086 secfile_lookup_int_default(file, 0, "citizen.conquest_convert_pct");
6087 }
6088
6089 if (ok) {
6090 /* Missing unit upkeep. */
6091 struct action_auto_perf *auto_perf;
6092
6093 /* Can't pay food upkeep! */
6094 auto_perf = action_auto_perf_slot_number(ACTION_AUTO_UPKEEP_FOOD);
6095 auto_perf->cause = AAPC_UNIT_UPKEEP;
6096
6097 /* This is about food upkeep. */
6098 requirement_vector_append(&auto_perf->reqs,
6099 req_from_str("OutputType", "Local",
6100 FALSE, TRUE, TRUE,
6101 "Food"));
6102
6103 /* Internally represented as an action auto performer rule. */
6104 if (!load_muuk_as_action_auto(file, auto_perf, "food", filename)) {
6105 ok = FALSE;
6106 }
6107
6108 game.info.muuk_food_wipe =
6109 secfile_lookup_bool_default(file, RS_DEFAULT_MUUK_FOOD_WIPE,
6110 "missing_unit_upkeep.food_wipe");
6111
6112 /* Can't pay gold upkeep! */
6113 auto_perf = action_auto_perf_slot_number(ACTION_AUTO_UPKEEP_GOLD);
6114 auto_perf->cause = AAPC_UNIT_UPKEEP;
6115
6116 /* This is about gold upkeep. */
6117 requirement_vector_append(&auto_perf->reqs,
6118 req_from_str("OutputType", "Local",
6119 FALSE, TRUE, TRUE,
6120 "Gold"));
6121
6122 /* Internally represented as an action auto performer rule. */
6123 if (!load_muuk_as_action_auto(file, auto_perf, "gold", filename)) {
6124 ok = FALSE;
6125 }
6126
6127 game.info.muuk_gold_wipe =
6128 secfile_lookup_bool_default(file, RS_DEFAULT_MUUK_GOLD_WIPE,
6129 "missing_unit_upkeep.gold_wipe");
6130
6131 /* Can't pay shield upkeep! */
6132 auto_perf = action_auto_perf_slot_number(ACTION_AUTO_UPKEEP_SHIELD);
6133 auto_perf->cause = AAPC_UNIT_UPKEEP;
6134
6135 /* This is about shield upkeep. */
6136 requirement_vector_append(&auto_perf->reqs,
6137 req_from_str("OutputType", "Local",
6138 FALSE, TRUE, TRUE,
6139 "Shield"));
6140
6141 /* Internally represented as an action auto performer rule. */
6142 if (!load_muuk_as_action_auto(file, auto_perf, "shield", filename)) {
6143 ok = FALSE;
6144 }
6145
6146 game.info.muuk_shield_wipe =
6147 secfile_lookup_bool_default(file, RS_DEFAULT_MUUK_SHIELD_WIPE,
6148 "missing_unit_upkeep.shield_wipe");
6149 }
6150
6151 if (ok) {
6152 secfile_check_unused(file);
6153 }
6154
6155 return ok;
6156}
6157
6158/**********************************************************************/
6161 static bool load_ruleset_effects(struct section_file *file,
6162 struct rscompat_info *compat)
6163{
6164 struct section_list *sec;
6165 const char *type;
6166 const char *filename;
6167 bool ok = TRUE;
6168
6169 filename = secfile_name(file);
6170
6171 if (!rscompat_check_cap_and_version(file, filename, compat)) {
6172 return FALSE;
6173 }
6174
6175 (void) secfile_entry_by_path(file, "datafile.description"); /* unused */
6176 (void) secfile_entry_by_path(file, "datafile.ruledit"); /* unused */
6177
6178 /* Parse effects and add them to the effects ruleset cache. */
6179 sec = secfile_sections_by_name_prefix(file, EFFECT_SECTION_PREFIX);
6180 section_list_iterate(sec, psection) {
6181 enum effect_type eff;
6182 int value;
6183 struct multiplier *pmul;
6184 struct effect *peffect;
6185 const char *sec_name = section_name(psection);
6186 struct requirement_vector *reqs;
6187
6188 type = secfile_lookup_str(file, "%s.type", sec_name);
6189
6190 if (type == NULL) {
6191 ruleset_error(NULL, LOG_ERROR,
6192 "\"%s\" [%s] missing effect type.", filename, sec_name);
6193 ok = FALSE;
6194 break;
6195 }
6196
6197 if (compat->compat_mode && rscompat_old_effect_3_1(type, file, sec_name, compat)) {
6198 continue;
6199 }
6200
6201 eff = effect_type_by_name(type, fc_strcasecmp);
6202 if (!effect_type_is_valid(eff)) {
6203 ruleset_error(NULL, LOG_ERROR,
6204 "\"%s\" [%s] lists unknown effect type \"%s\".",
6205 filename, sec_name, type);
6206 ok = FALSE;
6207 break;
6208 }
6209
6210 value = secfile_lookup_int_default(file, 1, "%s.value", sec_name);
6211
6212 {
6213 const char *multiplier_name
6214 = secfile_lookup_str(file, "%s.multiplier", sec_name);
6215
6216 if (multiplier_name) {
6217 pmul = multiplier_by_rule_name(multiplier_name);
6218 if (!pmul) {
6219 ruleset_error(NULL, LOG_ERROR,
6220 "\"%s\" [%s] has unknown multiplier \"%s\".",
6221 filename, sec_name, multiplier_name);
6222 ok = FALSE;
6223 break;
6224 }
6225 } else {
6226 pmul = NULL;
6227 }
6228 }
6229
6230 peffect = effect_new(eff, value, pmul);
6231
6232 reqs = lookup_req_list(file, compat, sec_name, "reqs", type);
6233 if (reqs == NULL) {
6234 ok = FALSE;
6235 break;
6236 }
6237
6238 requirement_vector_iterate(reqs, preq) {
6239 effect_req_append(peffect, *preq);
6240 } requirement_vector_iterate_end;
6241
6242 } section_list_iterate_end;
6243 section_list_destroy(sec);
6244
6245 if (ok) {
6246 secfile_check_unused(file);
6247 }
6248
6249 return ok;
6250}
6251
6252/**********************************************************************/
6255static int secfile_lookup_int_default_min_max(struct section_file *file,
6256 int def, int min, int max,
6257 const char *path, ...)
6258 fc__attribute((__format__ (__printf__, 5, 6)));
6259static int secfile_lookup_int_default_min_max(struct section_file *file,
6260 int def, int min, int max,
6261 const char *path, ...)
6262{
6263 char fullpath[256];
6264 int ival;
6265 va_list args;
6266
6267 va_start(args, path);
6268 fc_vsnprintf(fullpath, sizeof(fullpath), path, args);
6269 va_end(args);
6270
6271 if (!secfile_lookup_int(file, &ival, "%s", fullpath)) {
6272 ival = def;
6273 }
6274
6275 if (ival < min) {
6276 ruleset_error(NULL, LOG_ERROR,
6277 "\"%s\" should be in the interval [%d, %d] "
6278 "but is %d; using the minimal value.",
6279 fullpath, min, max, ival);
6280 ival = min;
6281 }
6282
6283 if (ival > max) {
6284 ruleset_error(NULL, LOG_ERROR,
6285 "\"%s\" should be in the interval [%d, %d] "
6286 "but is %d; using the maximal value.",
6287 fullpath, min, max, ival);
6288 ival = max;
6289 }
6290
6291 return ival;
6292}
6293
6294/**********************************************************************/
6297 static bool load_action_ui_name(struct section_file *file, int act,
6298 const char *entry_name,
6299 const char *compat_name)
6300{
6301 const char *text;
6302 const char *def = action_ui_name_default(act);
6303
6304 if (compat_name != NULL) {
6305 def = secfile_lookup_str_default(file, def,
6306 "actions.%s", compat_name);
6307 }
6308
6309 text = secfile_lookup_str_default(file, def,
6310 "actions.%s", entry_name);
6311 sz_strlcpy(action_by_number(act)->ui_name, text);
6312
6313 return TRUE;
6314}
6315
6316/**********************************************************************/
6319 static bool load_action_range_max(struct rscompat_info *compat,
6320 struct section_file *file, action_id act)
6321{
6322 struct action *paction = action_by_number(act);
6323 const char *vname = action_max_range_ruleset_var_name(act);
6324
6325 if (vname != NULL) {
6326 struct entry *pentry;
6327 int max_range;
6328
6329 pentry = secfile_entry_lookup(file, "actions.%s", vname);
6330
6331 if (pentry == NULL) {
6332 const char *compat_name = rscompat_action_max_range_name_S3_1(compat, act);
6333
6334 if (compat_name != NULL) {
6335 pentry = secfile_entry_lookup(file, "actions.%s",
6336 compat_name);
6337 }
6338 }
6339
6340 if (pentry == NULL) {
6341 max_range = action_max_range_default(paction->result);
6342 } else {
6343 const char *custom;
6344
6345 if (entry_type_get(pentry) == ENTRY_INT
6346 && entry_int_get(pentry, &max_range)) {
6347 /* max_range already assigned */
6348 } else if (entry_type_get(pentry) == ENTRY_STR
6349 && entry_str_get(pentry, &custom)
6350 && !fc_strcasecmp(custom, RS_ACTION_NO_MAX_DISTANCE)) {
6351 max_range = ACTION_DISTANCE_UNLIMITED;
6352 } else {
6353 ruleset_error(NULL, LOG_ERROR, "Bad actions.%s",
6354 action_max_range_ruleset_var_name(act));
6355 action_by_number(act)->max_distance = action_max_range_default(paction->result);
6356
6357 return FALSE;
6358 }
6359 }
6360
6361 action_by_number(act)->max_distance = max_range;
6362 }
6363
6364 return TRUE;
6365}
6366
6367/**********************************************************************/
6370 static bool load_action_range(struct rscompat_info *compat,
6371 struct section_file *file, action_id act)
6372{
6373 struct action *paction = action_by_number(act);
6374 const char *vname;
6375
6376 if (!load_action_range_max(compat, file, act)) {
6377 return FALSE;
6378 }
6379
6380 vname = action_min_range_ruleset_var_name(act);
6381 if (vname != NULL) {
6382 /* Min range can be loaded from the ruleset. */
6383 action_by_number(act)->min_distance
6384 = secfile_lookup_int_default(file,
6385 action_min_range_default(paction->result),
6386 "actions.%s",
6387 vname);
6388 }
6389
6390 return TRUE;
6391}
6392
6393/**********************************************************************/
6396 static bool load_action_kind(struct section_file *file, action_id act)
6397{
6398 struct action *paction = action_by_number(act);
6399
6400 if (action_target_kind_ruleset_var_name(act) == NULL) {
6401 /* Target kind can't be loaded from the ruleset. */
6402 }
6403
6404 action_by_number(act)->target_kind
6405 = secfile_lookup_enum_default(file,
6406 action_target_kind_default(
6407 paction->result),
6408 action_target_kind,
6409 "actions.%s",
6410 action_target_kind_ruleset_var_name(act));
6411
6412 return TRUE;
6413}
6414
6415/**********************************************************************/
6418 static bool load_action_actor_consuming_always(struct section_file *file,
6419 action_id act)
6420{
6421 if (action_actor_consuming_always_ruleset_var_name(act) != NULL) {
6422 /* Actor consumption can be loaded from the ruleset. */
6423 action_by_number(act)->actor_consuming_always
6424 = secfile_lookup_bool_default(
6425 file, RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS, "actions.%s",
6426 action_actor_consuming_always_ruleset_var_name(act));
6427 }
6428
6429 return TRUE;
6430}
6431
6432/**********************************************************************/
6435 static bool load_action_blocked_by_list(struct section_file *file,
6436 const char *filename,
6437 struct action *paction)
6438{
6439 if (action_blocked_by_ruleset_var_name(paction) != NULL) {
6440 /* Action blocking can be loaded from the ruleset. */
6441
6442 char fullpath[1024];
6443
6444 fc_snprintf(fullpath, sizeof(fullpath), "actions.%s",
6445 action_blocked_by_ruleset_var_name(paction));
6446
6447 if (secfile_entry_by_path(file, fullpath)) {
6448 enum gen_action *blocking_actions;
6449 size_t asize;
6450 int j;
6451
6452 blocking_actions =
6453 secfile_lookup_enum_vec(file, &asize, gen_action, "%s", fullpath);
6454
6455 if (!blocking_actions) {
6456 /* Entity exists but couldn't read it. */
6457 ruleset_error(NULL, LOG_ERROR,
6458 "\"%s\": %s: bad action list",
6459 filename, fullpath);
6460
6461 return FALSE;
6462 }
6463
6464 for (j = 0; j < asize; j++) {
6465 BV_SET(paction->blocked_by, blocking_actions[j]);
6466 }
6467
6468 free(blocking_actions);
6469 }
6470 }
6471
6472 return TRUE;
6473}
6474
6475/**********************************************************************/
6479 static bool load_action_post_success_force(struct section_file *file,
6480 const char *filename,
6481 int performer_slot,
6482 struct action *paction)
6483{
6484 struct action_auto_perf *auto_perf;
6485 char action_list_path[100];
6486
6487 if (action_post_success_forced_ruleset_var_name(paction) == NULL) {
6488 /* Not relevant. */
6489 return TRUE;
6490 }
6491
6492 auto_perf = action_auto_perf_slot_number(performer_slot);
6493 auto_perf->cause = AAPC_POST_ACTION;
6494
6495 /* Limit auto performer to this action. */
6496 requirement_vector_append(&auto_perf->reqs,
6497 req_from_values(VUT_ACTION, REQ_RANGE_LOCAL,
6498 FALSE, TRUE, TRUE,
6499 paction->id));
6500
6501 /* Load the list of actions. */
6502 fc_snprintf(action_list_path, sizeof(action_list_path),
6503 "actions.%s",
6504 action_post_success_forced_ruleset_var_name(paction));
6505 if (!load_action_auto_actions(file, auto_perf,
6506 action_list_path, filename)) {
6507 return FALSE;
6508 }
6509
6510 return TRUE;
6511}
6512
6513/**********************************************************************/
6516 static bool lookup_bv_actions(struct section_file *file,
6517 const char *filename,
6518 bv_actions *target,
6519 const char *path)
6520{
6521 if (secfile_entry_by_path(file, path)) {
6522 enum gen_action *listed_actions;
6523 size_t asize;
6524 int j;
6525
6526 listed_actions = secfile_lookup_enum_vec(file, &asize, gen_action,
6527 "%s", path);
6528
6529 if (!listed_actions) {
6530 /* Entity exists but couldn't read it. */
6531 ruleset_error(NULL, LOG_ERROR, "\"%s\": %s: bad action list",
6532 filename, path);
6533
6534 return FALSE;
6535 }
6536
6537 for (j = 0; j < asize; j++) {
6538 BV_SET(*target, listed_actions[j]);
6539 }
6540
6541 free(listed_actions);
6542 }
6543
6544 return TRUE;
6545}
6546
6547/**********************************************************************/
6550 static bool load_ruleset_game(struct section_file *file, bool act,
6551 struct rscompat_info *compat)
6552{
6553 const char *sval, **svec;
6554 const char *filename;
6555 int *food_ini;
6556 int i;
6557 size_t teams;
6558 const char *pref_text;
6559 size_t gni_tmp;
6560 struct section_list *sec;
6561 size_t nval;
6562 const char *name;
6563 bool ok = TRUE;
6564
6565 if (file == NULL) {
6566 return FALSE;
6567 }
6568 filename = secfile_name(file);
6569
6570 name = secfile_lookup_str_default(file, NULL, "ruledit.description_file");
6571 if (name != NULL) {
6572 game.server.ruledit.description_file = fc_strdup(name);
6573 }
6574
6575 /* section: tileset */
6576 pref_text = secfile_lookup_str_default(file, "", "tileset.prefered");
6577 if (pref_text[0] != '\0') {
6578 log_deprecation("Entry tileset.prefered in game.ruleset."
6579 " Use correct spelling tileset.preferred instead");
6580 }
6581 pref_text = secfile_lookup_str_default(file, pref_text, "tileset.preferred");
6582 if (pref_text[0] != '\0') {
6583 /* There was tileset suggestion */
6584 sz_strlcpy(game.control.preferred_tileset, pref_text);
6585 } else {
6586 /* No tileset suggestions */
6587 game.control.preferred_tileset[0] = '\0';
6588 }
6589
6590 /* section: soundset */
6591 pref_text = secfile_lookup_str_default(file, "", "soundset.prefered");
6592 if (pref_text[0] != '\0') {
6593 log_deprecation("Entry soundset.prefered in game.ruleset."
6594 " Use correct spelling soundset.preferred instead");
6595 }
6596 pref_text = secfile_lookup_str_default(file, pref_text, "soundset.preferred");
6597 if (pref_text[0] != '\0') {
6598 /* There was soundset suggestion */
6599 sz_strlcpy(game.control.preferred_soundset, pref_text);
6600 } else {
6601 /* No soundset suggestions */
6602 game.control.preferred_soundset[0] = '\0';
6603 }
6604
6605 /* section: musicset */
6606 pref_text = secfile_lookup_str_default(file, "", "musicset.prefered");
6607 if (pref_text[0] != '\0') {
6608 log_deprecation("Entry musicset.prefered in game.ruleset."
6609 " Use correct spelling musicset.preferred instead");
6610 }
6611 pref_text = secfile_lookup_str_default(file, pref_text, "musicset.preferred");
6612 if (pref_text[0] != '\0') {
6613 /* There was musicset suggestion */
6614 sz_strlcpy(game.control.preferred_musicset, pref_text);
6615 } else {
6616 /* No musicset suggestions */
6617 game.control.preferred_musicset[0] = '\0';
6618 }
6619
6620 /* section: about */
6621 pref_text = secfile_lookup_str(file, "about.name");
6622 /* Ruleset/modpack name found */
6623 sz_strlcpy(game.control.name, pref_text);
6624
6625 pref_text = secfile_lookup_str_default(file, "", "about.version");
6626 if (pref_text[0] != '\0') {
6627 /* Ruleset/modpack version found */
6628 sz_strlcpy(game.control.version, pref_text);
6629 } else {
6630 /* No version information */
6631 game.control.version[0] = '\0';
6632 }
6633
6634 pref_text = secfile_lookup_str_default(file, "", "about.alt_dir");
6635 if (pref_text[0] != '\0') {
6636 /* Alt directory definition found. */
6637 sz_strlcpy(game.control.alt_dir, pref_text);
6638 } else {
6639 /* No alt directory information */
6640 game.control.alt_dir[0] = '\0';
6641 }
6642
6643 pref_text = secfile_lookup_str_default(file, "", "about.summary");
6644 if (pref_text[0] != '\0') {
6645 int len;
6646
6647 /* Ruleset/modpack summary found */
6648 len = strlen(pref_text);
6649 game.ruleset_summary = fc_malloc(len + 1);
6650 fc_strlcpy(game.ruleset_summary, pref_text, len + 1);
6651 } else {
6652 /* No summary */
6653 if (game.ruleset_summary != NULL) {
6654 free(game.ruleset_summary);
6655 game.ruleset_summary = NULL;
6656 }
6657 }
6658
6659 pref_text = secfile_lookup_str_default(file, "", "about.description");
6660 if (pref_text[0] != '\0') {
6661 int len;
6662
6663 /* Ruleset/modpack description found */
6664 len = strlen(pref_text);
6665 game.ruleset_description = fc_malloc(len + 1);
6666 fc_strlcpy(game.ruleset_description, pref_text, len + 1);
6667 game.control.desc_length32 = len;
6668 } else {
6669 /* No description */
6670 if (game.ruleset_description != NULL) {
6671 free(game.ruleset_description);
6672 game.ruleset_description = NULL;
6673 }
6674 game.control.desc_length32 = 0;
6675 }
6676
6677 pref_text = secfile_lookup_str_default(file, "", "about.capabilities");
6678 if (pref_text[0] != '\0') {
6679 int len = strlen(pref_text);
6680
6681 game.ruleset_capabilities = fc_malloc(len + 1);
6682 fc_strlcpy(game.ruleset_capabilities, pref_text, len +1);
6683 } else {
6684 game.ruleset_capabilities = fc_malloc(1);
6685 game.ruleset_capabilities[0] = '\0';
6686 }
6687
6688 /* section: options */
6689 if (!lookup_tech_list(file, "options", "global_init_techs",
6690 game.rgame.global_init_techs, filename)) {
6691 ok = FALSE;
6692 }
6693
6694 if (ok) {
6695 if (!lookup_building_list(file, "options", "global_init_buildings",
6696 game.rgame.global_init_buildings, filename)) {
6697 ok = FALSE;
6698 }
6699 }
6700
6701 if (ok) {
6702 const char **slist;
6703 int j;
6704
6705 game.control.popup_tech_help = secfile_lookup_bool_default(file, FALSE,
6706 "options.popup_tech_help");
6707
6708 /* section: civstyle */
6709 game.info.base_pollution
6710 = secfile_lookup_int_default(file, RS_DEFAULT_BASE_POLLUTION,
6711 "civstyle.base_pollution");
6712
6713 game.info.gameloss_style = GAMELOSS_STYLE_CLASSICAL;
6714
6715 slist = secfile_lookup_str_vec(file, &nval, "civstyle.gameloss_style");
6716 for (j = 0; j < nval; j++) {
6717 enum gameloss_style style;
6718
6719 sval = slist[j];
6720 if (strcmp(sval, "") == 0) {
6721 continue;
6722 }
6723 style = gameloss_style_by_name(sval, fc_strcasecmp);
6724 if (!gameloss_style_is_valid(style)) {
6725 ruleset_error(NULL, LOG_ERROR,
6726 "\"%s\": bad value \"%s\" for gameloss_style.",
6727 filename, sval);
6728 ok = FALSE;
6729 break;
6730 } else {
6731 game.info.gameloss_style |= style;
6732 }
6733 }
6734 free(slist);
6735 }
6736
6737 if (ok) {
6738 game.info.happy_cost
6739 = secfile_lookup_int_def_min_max(file,
6740 RS_DEFAULT_HAPPY_COST,
6741 RS_MIN_HAPPY_COST,
6742 RS_MAX_HAPPY_COST,
6743 "civstyle.happy_cost");
6744 game.info.food_cost
6745 = secfile_lookup_int_default_min_max(file,
6746 RS_DEFAULT_FOOD_COST,
6747 RS_MIN_FOOD_COST,
6748 RS_MAX_FOOD_COST,
6749 "civstyle.food_cost");
6750 game.info.civil_war_enabled
6751 = secfile_lookup_bool_default(file, TRUE, "civstyle.civil_war_enabled");
6752
6753 game.info.civil_war_bonus_celebrating
6754 = secfile_lookup_int_default(file, RS_DEFAULT_CIVIL_WAR_CELEB,
6755 "civstyle.civil_war_bonus_celebrating");
6756
6757 game.info.civil_war_bonus_unhappy
6758 = secfile_lookup_int_default(file, RS_DEFAULT_CIVIL_WAR_UNHAPPY,
6759 "civstyle.civil_war_bonus_unhappy");
6760
6761 game.info.base_bribe_cost
6762 = secfile_lookup_int_default_min_max(file,
6763 RS_DEFAULT_BASE_BRIBE_COST,
6764 RS_MIN_BASE_BRIBE_COST,
6765 RS_MAX_BASE_BRIBE_COST,
6766 "civstyle.base_bribe_cost");
6767 game.server.ransom_gold
6768 = secfile_lookup_int_default_min_max(file,
6769 RS_DEFAULT_RANSOM_GOLD,
6770 RS_MIN_RANSOM_GOLD,
6771 RS_MAX_RANSOM_GOLD,
6772 "civstyle.ransom_gold");
6773 game.info.pillage_select
6774 = secfile_lookup_bool_default(file, RS_DEFAULT_PILLAGE_SELECT,
6775 "civstyle.pillage_select");
6776
6777 game.info.tech_steal_allow_holes
6778 = secfile_lookup_bool_default(file, RS_DEFAULT_TECH_STEAL_HOLES,
6779 "civstyle.tech_steal_allow_holes");
6780 game.info.tech_trade_allow_holes
6781 = secfile_lookup_bool_default(file, RS_DEFAULT_TECH_TRADE_HOLES,
6782 "civstyle.tech_trade_allow_holes");
6783 game.info.tech_trade_loss_allow_holes
6784 = secfile_lookup_bool_default(file, RS_DEFAULT_TECH_TRADE_LOSS_HOLES,
6785 "civstyle.tech_trade_loss_allow_holes");
6786 game.info.tech_parasite_allow_holes
6787 = secfile_lookup_bool_default(file, RS_DEFAULT_TECH_PARASITE_HOLES,
6788 "civstyle.tech_parasite_allow_holes");
6789 game.info.tech_loss_allow_holes
6790 = secfile_lookup_bool_default(file, RS_DEFAULT_TECH_LOSS_HOLES,
6791 "civstyle.tech_loss_allow_holes");
6792
6793 game.server.upgrade_veteran_loss
6794 = secfile_lookup_int_default_min_max(file,
6795 RS_DEFAULT_UPGRADE_VETERAN_LOSS,
6796 RS_MIN_UPGRADE_VETERAN_LOSS,
6797 RS_MAX_UPGRADE_VETERAN_LOSS,
6798 "civstyle.upgrade_veteran_loss");
6799 game.server.autoupgrade_veteran_loss
6800 = secfile_lookup_int_default_min_max(file,
6801 RS_DEFAULT_UPGRADE_VETERAN_LOSS,
6802 RS_MIN_UPGRADE_VETERAN_LOSS,
6803 RS_MAX_UPGRADE_VETERAN_LOSS,
6804 "civstyle.autoupgrade_veteran_loss");
6805
6806 game.info.base_tech_cost
6807 = secfile_lookup_int_default_min_max(file,
6808 RS_DEFAULT_BASE_TECH_COST,
6809 RS_MIN_BASE_TECH_COST,
6810 RS_MAX_BASE_TECH_COST,
6811 "research.base_tech_cost");
6812
6813 food_ini = secfile_lookup_int_vec(file, &gni_tmp,
6814 "civstyle.granary_food_ini");
6815 game.info.granary_num_inis = (int) gni_tmp;
6816
6817 if (game.info.granary_num_inis > MAX_GRANARY_INIS) {
6818 ruleset_error(NULL, LOG_ERROR,
6819 "Too many granary_food_ini entries (%d, max %d)",
6820 game.info.granary_num_inis, MAX_GRANARY_INIS);
6821 ok = FALSE;
6822 } else if (game.info.granary_num_inis == 0) {
6823 log_error("No values for granary_food_ini. Using default "
6824 "value %d.", RS_DEFAULT_GRANARY_FOOD_INI);
6825 game.info.granary_num_inis = 1;
6826 game.info.granary_food_ini[0] = RS_DEFAULT_GRANARY_FOOD_INI;
6827 } else {
6828 int gi;
6829
6830 /* check for <= 0 entries */
6831 for (gi = 0; gi < game.info.granary_num_inis; gi++) {
6832 if (food_ini[gi] <= 0) {
6833 if (gi == 0) {
6834 food_ini[gi] = RS_DEFAULT_GRANARY_FOOD_INI;
6835 } else {
6836 food_ini[gi] = food_ini[gi - 1];
6837 }
6838 log_error("Bad value for granary_food_ini[%i]. Using %i.",
6839 gi, food_ini[gi]);
6840 }
6841 game.info.granary_food_ini[gi] = food_ini[gi];
6842 }
6843 }
6844 free(food_ini);
6845 }
6846
6847 if (ok) {
6848 game.info.granary_food_inc
6849 = secfile_lookup_int_default_min_max(file,
6850 RS_DEFAULT_GRANARY_FOOD_INC,
6851 RS_MIN_GRANARY_FOOD_INC,
6852 RS_MAX_GRANARY_FOOD_INC,
6853 "civstyle.granary_food_inc");
6854
6855 output_type_iterate(o) {
6856 game.info.min_city_center_output[o]
6857 = secfile_lookup_int_default_min_max(file,
6858 RS_DEFAULT_CITY_CENTER_OUTPUT,
6859 RS_MIN_CITY_CENTER_OUTPUT,
6860 RS_MAX_CITY_CENTER_OUTPUT,
6861 "civstyle.min_city_center_%s",
6862 get_output_identifier(o));
6863 } output_type_iterate_end;
6864 }
6865
6866 if (ok) {
6867 const char *tus_text;
6868
6869 game.server.init_vis_radius_sq
6870 = secfile_lookup_int_default_min_max(file,
6871 RS_DEFAULT_VIS_RADIUS_SQ,
6872 RS_MIN_VIS_RADIUS_SQ,
6873 RS_MAX_VIS_RADIUS_SQ,
6874 "civstyle.init_vis_radius_sq");
6875
6876 game.info.init_city_radius_sq
6877 = secfile_lookup_int_default_min_max(file,
6878 RS_DEFAULT_CITY_RADIUS_SQ,
6879 RS_MIN_CITY_RADIUS_SQ,
6880 RS_MAX_CITY_RADIUS_SQ,
6881 "civstyle.init_city_radius_sq");
6882
6883 tus_text = secfile_lookup_str_default(file, RS_DEFAULT_GOLD_UPKEEP_STYLE,
6884 "civstyle.gold_upkeep_style");
6885 game.info.gold_upkeep_style = gold_upkeep_style_by_name(tus_text,
6886 fc_strcasecmp);
6887 if (!gold_upkeep_style_is_valid(game.info.gold_upkeep_style)) {
6888 ruleset_error(NULL, LOG_ERROR,
6889 "Unknown gold upkeep style \"%s\"",
6890 tus_text);
6891 ok = FALSE;
6892 }
6893
6894 game.info.granularity = secfile_lookup_int_default(file, 1,
6895 "civstyle.output_granularity");
6896
6897 game.info.airlift_from_always_enabled
6898 = secfile_lookup_bool_default(file, FALSE, "civstyle.airlift_from_always_enabled");
6899
6900 game.info.airlift_to_always_enabled
6901 = secfile_lookup_bool_default(file, TRUE, "civstyle.airlift_to_always_enabled");
6902
6903 /* section: wonder_visibility */
6904 if (ok) {
6905 const char *text;
6906
6907 text = secfile_lookup_str_default(file,
6908 RS_DEFAULT_SMALL_WONDER_VISIBILITY,
6909 "wonder_visibility.small_wonders");
6910
6911 game.info.small_wonder_visibility = wonder_visib_type_by_name(text,
6912 fc_strcasecmp);
6913 if (!wonder_visib_type_is_valid(game.info.small_wonder_visibility)) {
6914 ruleset_error(NULL, LOG_ERROR,
6915 "Unknown wonder visibility typpe \"%s\"",
6916 text);
6917 ok = FALSE;
6918 }
6919 }
6920
6921 /* section: illness */
6922 game.info.illness_on
6923 = secfile_lookup_bool_default(file, RS_DEFAULT_ILLNESS_ON,
6924 "illness.illness_on");
6925 game.info.illness_base_factor
6926 = secfile_lookup_int_default_min_max(file,
6927 RS_DEFAULT_ILLNESS_BASE_FACTOR,
6928 RS_MIN_ILLNESS_BASE_FACTOR,
6929 RS_MAX_ILLNESS_BASE_FACTOR,
6930 "illness.illness_base_factor");
6931 game.info.illness_min_size
6932 = secfile_lookup_int_default_min_max(file,
6933 RS_DEFAULT_ILLNESS_MIN_SIZE,
6934 RS_MIN_ILLNESS_MIN_SIZE,
6935 RS_MAX_ILLNESS_MIN_SIZE,
6936 "illness.illness_min_size");
6937 game.info.illness_trade_infection
6938 = secfile_lookup_int_default_min_max(file,
6939 RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT,
6940 RS_MIN_ILLNESS_TRADE_INFECTION_PCT,
6941 RS_MAX_ILLNESS_TRADE_INFECTION_PCT,
6942 "illness.illness_trade_infection");
6943 game.info.illness_pollution_factor
6944 = secfile_lookup_int_default_min_max(file,
6945 RS_DEFAULT_ILLNESS_POLLUTION_PCT,
6946 RS_MIN_ILLNESS_POLLUTION_PCT,
6947 RS_MAX_ILLNESS_POLLUTION_PCT,
6948 "illness.illness_pollution_factor");
6949
6950 /* section: incite_cost */
6951 game.server.base_incite_cost
6952 = secfile_lookup_int_default_min_max(file,
6953 RS_DEFAULT_INCITE_BASE_COST,
6954 RS_MIN_INCITE_BASE_COST,
6955 RS_MAX_INCITE_BASE_COST,
6956 "incite_cost.base_incite_cost");
6957 game.server.incite_improvement_factor
6958 = secfile_lookup_int_default_min_max(file,
6959 RS_DEFAULT_INCITE_IMPROVEMENT_FCT,
6960 RS_MIN_INCITE_IMPROVEMENT_FCT,
6961 RS_MAX_INCITE_IMPROVEMENT_FCT,
6962 "incite_cost.improvement_factor");
6963 game.server.incite_unit_factor
6964 = secfile_lookup_int_default_min_max(file,
6965 RS_DEFAULT_INCITE_UNIT_FCT,
6966 RS_MIN_INCITE_UNIT_FCT,
6967 RS_MAX_INCITE_UNIT_FCT,
6968 "incite_cost.unit_factor");
6969 game.server.incite_total_factor
6970 = secfile_lookup_int_default_min_max(file,
6971 RS_DEFAULT_INCITE_TOTAL_FCT,
6972 RS_MIN_INCITE_TOTAL_FCT,
6973 RS_MAX_INCITE_TOTAL_FCT,
6974 "incite_cost.total_factor");
6975
6976 if (ok) {
6977 /* Auto attack. */
6978 struct action_auto_perf *auto_perf;
6979
6980 /* Action auto performers aren't ready to be exposed in the ruleset
6981 * yet. The behavior when two action auto performers for the same
6982 * cause can fire isn't set in stone yet. How is one of them chosen?
6983 * What if all the actions of the chosen action auto performer turned
6984 * out to be illegal but one of the other action auto performers that
6985 * fired has legal actions? These issues can decide what other action
6986 * rules action auto performers can represent in the future. Deciding
6987 * should therefore wait until a rule needs action auto performers to
6988 * work a certain way. */
6989 /* Only one action auto performer, ACTION_AUTO_MOVED_ADJ, is caused
6990 * by AAPC_UNIT_MOVED_ADJ. It is therefore safe to expose the full
6991 * requirement vector to the ruleset. */
6992 struct requirement_vector *reqs;
6993
6994 /* A unit moved next to this unit and the autoattack server setting
6995 * is enabled. */
6996 auto_perf = action_auto_perf_slot_number(ACTION_AUTO_MOVED_ADJ);
6997 auto_perf->cause = AAPC_UNIT_MOVED_ADJ;
6998
6999 reqs = lookup_req_list(file, compat,
7000 "auto_attack", "if_attacker",
7001 "auto_attack");
7002 if (reqs == NULL) {
7003 ok = FALSE;
7004 } else {
7005 requirement_vector_copy(&auto_perf->reqs, reqs);
7006
7007 if (!load_action_auto_actions(file, auto_perf,
7008 "auto_attack.attack_actions",
7009 filename)) {
7010 /* Failed to load auto attack actions */
7011 ruleset_error(NULL, LOG_ERROR,
7012 "\"%s\": %s: failed load %s.",
7013 filename, "auto_attack", "attack_actions");
7014 ok = FALSE;
7015 }
7016
7017 if (ok && compat->compat_mode) {
7018 enum unit_type_flag_id *protecor_flag;
7019 size_t psize;
7020
7021 if (secfile_entry_lookup(file, "%s", "auto_attack.will_never")) {
7022 protecor_flag =
7023 secfile_lookup_enum_vec(file, &psize, unit_type_flag_id,
7024 "%s", "auto_attack.will_never");
7025
7026 if (!protecor_flag) {
7027 /* Entity exists but couldn't read it. */
7028 ruleset_error(NULL, LOG_ERROR,
7029 "\"%s\": %s: bad unit type flag list.",
7030 filename, "auto_attack.will_never");
7031
7032 ok = FALSE;
7033 }
7034 } else {
7035 psize = 0;
7036 protecor_flag = NULL;
7037 }
7038
7039 if (ok && !rscompat_auto_attack_3_1(compat, auto_perf,
7040 psize, protecor_flag)) {
7041 /* Upgrade failed */
7042 ruleset_error(NULL, LOG_ERROR,
7043 "\"%s\": %s: failed to upgrade.",
7044 filename, "auto_attack");
7045 ok = FALSE;
7046 }
7047
7048 if (psize) {
7049 FC_FREE(protecor_flag);
7050 }
7051 }
7052 }
7053 }
7054
7055 /* Section: actions */
7056 if (ok) {
7057 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
7058 int force_capture_units, force_bombard, force_explode_nuclear;
7059
7060 if (secfile_lookup_bool_default(file, FALSE,
7061 "actions.force_trade_route")) {
7062 /* Forbid entering the marketplace when a trade route can be
7063 * established. */
7064 BV_SET(action_by_number(ACTION_MARKETPLACE)->blocked_by,
7065 ACTION_TRADE_ROUTE);
7066 }
7067
7068 /* Forbid bombarding, exploading nuclear or attacking when it is
7069 * legal to capture units. */
7070 force_capture_units
7071 = secfile_lookup_bool_default(file, FALSE,
7072 "actions.force_capture_units");
7073
7074 if (force_capture_units) {
7075 BV_SET(action_by_number(ACTION_BOMBARD)->blocked_by,
7076 ACTION_CAPTURE_UNITS);
7077 BV_SET(action_by_number(ACTION_BOMBARD2)->blocked_by,
7078 ACTION_CAPTURE_UNITS);
7079 BV_SET(action_by_number(ACTION_BOMBARD3)->blocked_by,
7080 ACTION_CAPTURE_UNITS);
7081 BV_SET(action_by_number(ACTION_NUKE)->blocked_by,
7082 ACTION_CAPTURE_UNITS);
7083 BV_SET(action_by_number(ACTION_NUKE_CITY)->blocked_by,
7084 ACTION_CAPTURE_UNITS);
7085 BV_SET(action_by_number(ACTION_NUKE_UNITS)->blocked_by,
7086 ACTION_CAPTURE_UNITS);
7087 BV_SET(action_by_number(ACTION_SUICIDE_ATTACK)->blocked_by,
7088 ACTION_CAPTURE_UNITS);
7089 BV_SET(action_by_number(ACTION_ATTACK)->blocked_by,
7090 ACTION_CAPTURE_UNITS);
7091 BV_SET(action_by_number(ACTION_CONQUER_CITY)->blocked_by,
7092 ACTION_CAPTURE_UNITS);
7093 BV_SET(action_by_number(ACTION_CONQUER_CITY2)->blocked_by,
7094 ACTION_CAPTURE_UNITS);
7095 BV_SET(action_by_number(ACTION_CONQUER_CITY3)->blocked_by,
7096 ACTION_CAPTURE_UNITS);
7097 BV_SET(action_by_number(ACTION_CONQUER_CITY4)->blocked_by,
7098 ACTION_CAPTURE_UNITS);
7099 }
7100
7101 /* Forbid exploding nuclear or attacking when it is legal to
7102 * bombard. */
7103 force_bombard
7104 = secfile_lookup_bool_default(file, FALSE,
7105 "actions.force_bombard");
7106
7107 if (force_bombard) {
7108 BV_SET(action_by_number(ACTION_NUKE)->blocked_by,
7109 ACTION_BOMBARD);
7110 BV_SET(action_by_number(ACTION_NUKE_CITY)->blocked_by,
7111 ACTION_BOMBARD);
7112 BV_SET(action_by_number(ACTION_NUKE_UNITS)->blocked_by,
7113 ACTION_BOMBARD);
7114 BV_SET(action_by_number(ACTION_SUICIDE_ATTACK)->blocked_by,
7115 ACTION_BOMBARD);
7116 BV_SET(action_by_number(ACTION_ATTACK)->blocked_by,
7117 ACTION_BOMBARD);
7118 BV_SET(action_by_number(ACTION_CONQUER_CITY)->blocked_by,
7119 ACTION_BOMBARD);
7120 BV_SET(action_by_number(ACTION_CONQUER_CITY2)->blocked_by,
7121 ACTION_BOMBARD);
7122 BV_SET(action_by_number(ACTION_CONQUER_CITY3)->blocked_by,
7123 ACTION_BOMBARD);
7124 BV_SET(action_by_number(ACTION_CONQUER_CITY4)->blocked_by,
7125 ACTION_BOMBARD);
7126 BV_SET(action_by_number(ACTION_NUKE)->blocked_by,
7127 ACTION_BOMBARD2);
7128 BV_SET(action_by_number(ACTION_NUKE_CITY)->blocked_by,
7129 ACTION_BOMBARD2);
7130 BV_SET(action_by_number(ACTION_NUKE_UNITS)->blocked_by,
7131 ACTION_BOMBARD2);
7132 BV_SET(action_by_number(ACTION_SUICIDE_ATTACK)->blocked_by,
7133 ACTION_BOMBARD2);
7134 BV_SET(action_by_number(ACTION_ATTACK)->blocked_by,
7135 ACTION_BOMBARD2);
7136 BV_SET(action_by_number(ACTION_CONQUER_CITY)->blocked_by,
7137 ACTION_BOMBARD2);
7138 BV_SET(action_by_number(ACTION_CONQUER_CITY2)->blocked_by,
7139 ACTION_BOMBARD2);
7140 BV_SET(action_by_number(ACTION_CONQUER_CITY3)->blocked_by,
7141 ACTION_BOMBARD2);
7142 BV_SET(action_by_number(ACTION_CONQUER_CITY4)->blocked_by,
7143 ACTION_BOMBARD2);
7144 BV_SET(action_by_number(ACTION_NUKE)->blocked_by,
7145 ACTION_BOMBARD3);
7146 BV_SET(action_by_number(ACTION_NUKE_CITY)->blocked_by,
7147 ACTION_BOMBARD3);
7148 BV_SET(action_by_number(ACTION_NUKE_UNITS)->blocked_by,
7149 ACTION_BOMBARD3);
7150 BV_SET(action_by_number(ACTION_SUICIDE_ATTACK)->blocked_by,
7151 ACTION_BOMBARD3);
7152 BV_SET(action_by_number(ACTION_ATTACK)->blocked_by,
7153 ACTION_BOMBARD3);
7154 BV_SET(action_by_number(ACTION_CONQUER_CITY)->blocked_by,
7155 ACTION_BOMBARD3);
7156 BV_SET(action_by_number(ACTION_CONQUER_CITY2)->blocked_by,
7157 ACTION_BOMBARD3);
7158 BV_SET(action_by_number(ACTION_CONQUER_CITY3)->blocked_by,
7159 ACTION_BOMBARD3);
7160 BV_SET(action_by_number(ACTION_CONQUER_CITY4)->blocked_by,
7161 ACTION_BOMBARD3);
7162 }
7163
7164 /* Forbid attacking when it is legal to do explode nuclear. */
7165 force_explode_nuclear
7166 = secfile_lookup_bool_default(file, FALSE,
7167 "actions.force_explode_nuclear");
7168
7169 if (force_explode_nuclear) {
7170 BV_SET(action_by_number(ACTION_SUICIDE_ATTACK)->blocked_by,
7171 ACTION_NUKE);
7172 BV_SET(action_by_number(ACTION_ATTACK)->blocked_by,
7173 ACTION_NUKE);
7174 BV_SET(action_by_number(ACTION_CONQUER_CITY)->blocked_by,
7175 ACTION_NUKE);
7176 BV_SET(action_by_number(ACTION_CONQUER_CITY2)->blocked_by,
7177 ACTION_NUKE);
7178 BV_SET(action_by_number(ACTION_CONQUER_CITY3)->blocked_by,
7179 ACTION_NUKE);
7180 BV_SET(action_by_number(ACTION_CONQUER_CITY4)->blocked_by,
7181 ACTION_NUKE);
7182 BV_SET(action_by_number(ACTION_SUICIDE_ATTACK)->blocked_by,
7183 ACTION_NUKE_CITY);
7184 BV_SET(action_by_number(ACTION_ATTACK)->blocked_by,
7185 ACTION_NUKE_CITY);
7186 BV_SET(action_by_number(ACTION_CONQUER_CITY)->blocked_by,
7187 ACTION_NUKE_CITY);
7188 BV_SET(action_by_number(ACTION_CONQUER_CITY2)->blocked_by,
7189 ACTION_NUKE_CITY);
7190 BV_SET(action_by_number(ACTION_CONQUER_CITY3)->blocked_by,
7191 ACTION_NUKE_CITY);
7192 BV_SET(action_by_number(ACTION_CONQUER_CITY4)->blocked_by,
7193 ACTION_NUKE_CITY);
7194 BV_SET(action_by_number(ACTION_SUICIDE_ATTACK)->blocked_by,
7195 ACTION_NUKE_UNITS);
7196 BV_SET(action_by_number(ACTION_ATTACK)->blocked_by,
7197 ACTION_NUKE_UNITS);
7198 BV_SET(action_by_number(ACTION_CONQUER_CITY)->blocked_by,
7199 ACTION_NUKE_UNITS);
7200 BV_SET(action_by_number(ACTION_CONQUER_CITY2)->blocked_by,
7201 ACTION_NUKE_UNITS);
7202 BV_SET(action_by_number(ACTION_CONQUER_CITY3)->blocked_by,
7203 ACTION_NUKE_UNITS);
7204 BV_SET(action_by_number(ACTION_CONQUER_CITY4)->blocked_by,
7205 ACTION_NUKE_UNITS);
7206 }
7207 }
7208
7209 action_iterate(act_id) {
7210 struct action *paction = action_by_number(act_id);
7211
7212 if (!load_action_blocked_by_list(file, filename, paction)) {
7213 ok = FALSE;
7214 break;
7215 }
7216 } action_iterate_end;
7217
7218 if (ok && !lookup_bv_actions(file, filename,
7219 &game.info.diplchance_initial_odds,
7220 "actions.diplchance_initial_odds")) {
7221 ok = FALSE;
7222 }
7223
7224 if (ok) {
7225 /* If the "Poison City" action or the "Poison City Escape" action
7226 * should empty the granary. */
7227 /* TODO: empty granary and reduce population should become separate
7228 * action effect flags when actions are generalized. */
7229 game.info.poison_empties_food_stock
7230 = secfile_lookup_bool_default(file,
7231 RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK,
7232 "actions.poison_empties_food_stock");
7233
7234 /* If the "Steal Maps" action or the "Steal Maps Escape" action always
7235 * will reveal all cities when successful. */
7236 game.info.steal_maps_reveals_all_cities
7237 = secfile_lookup_bool_default(file,
7238 RS_DEFAULT_STEAL_MAP_REVEALS_CITIES,
7239 "actions.steal_maps_reveals_all_cities");
7240
7241 /* Allow setting certain properties for some actions before
7242 * generalized actions. */
7243 action_iterate(act_id) {
7244 if (!load_action_range(compat, file, act_id)) {
7245 ok = FALSE;
7246 } else if (!load_action_kind(file, act_id)) {
7247 ok = FALSE;
7248 } else if (!load_action_actor_consuming_always(file, act_id)) {
7249 ok = FALSE;
7250 } else {
7251 load_action_ui_name(file, act_id,
7252 action_ui_name_ruleset_var_name(act_id),
7253 rscompat_action_ui_name_S3_1(compat, act_id));
7254 }
7255
7256 if (!ok) {
7257 break;
7258 }
7259 } action_iterate_end;
7260
7261 /* The quiet (don't auto generate help for) property of all actions
7262 * live in a single enum vector. This avoids generic action
7263 * expectations. */
7264 if (ok && secfile_entry_by_path(file, "actions.quiet_actions")) {
7265 enum gen_action *quiet_actions;
7266 size_t asize;
7267 int j;
7268
7269 quiet_actions =
7270 secfile_lookup_enum_vec(file, &asize, gen_action,
7271 "actions.quiet_actions");
7272
7273 if (!quiet_actions) {
7274 /* Entity exists but couldn't read it. */
7275 ruleset_error(NULL, LOG_ERROR,
7276 "\"%s\": actions.quiet_actions: bad action list",
7277 filename);
7278
7279 ok = FALSE;
7280 } else {
7281 for (j = 0; j < asize; j++) {
7282 /* Don't auto generate help text for this action. */
7283 action_by_number(quiet_actions[j])->quiet = TRUE;
7284 }
7285
7286 free(quiet_actions);
7287 }
7288 }
7289
7290 if (ok) {
7291 /* Hard code action sub results for now. */
7292
7293 /* Unit Enter Hut */
7294 action_by_result_iterate(paction, ACTRES_HUT_ENTER) {
7295 BV_SET(paction->sub_results, ACT_SUB_RES_HUT_ENTER);
7296 } action_by_result_iterate_end;
7297 BV_SET(action_by_number(ACTION_PARADROP_ENTER)->sub_results,
7298 ACT_SUB_RES_HUT_ENTER);
7299 BV_SET(action_by_number(ACTION_PARADROP_ENTER_CONQUER)->sub_results,
7300 ACT_SUB_RES_HUT_ENTER);
7301
7302 /* Unit Frighten Hut */
7303 action_by_result_iterate(paction, ACTRES_HUT_FRIGHTEN) {
7304 BV_SET(paction->sub_results, ACT_SUB_RES_HUT_FRIGHTEN);
7305 } action_by_result_iterate_end;
7306 BV_SET(action_by_number(ACTION_PARADROP_FRIGHTEN)->sub_results,
7307 ACT_SUB_RES_HUT_FRIGHTEN);
7308 BV_SET(action_by_number(ACTION_PARADROP_FRIGHTEN_CONQUER)->sub_results,
7309 ACT_SUB_RES_HUT_FRIGHTEN);
7310
7311 /* Unit May Embark */
7312 action_iterate(act_id) {
7313 struct action *paction = action_by_number(act_id);
7314
7315 if (secfile_lookup_bool_default(file, FALSE,
7316 "civstyle.paradrop_to_transport")
7317 && (action_has_result(paction, ACTRES_PARADROP)
7318 || action_has_result(paction, ACTRES_PARADROP_CONQUER))) {
7319 BV_SET(paction->sub_results, ACT_SUB_RES_MAY_EMBARK);
7320 }
7321
7322 /* Embark actions will always embark, not maybe embark. */
7323 } action_iterate_end;
7324 }
7325 }
7326 }
7327
7328 if (ok) {
7329 /* Forced actions after another action was successfully performed. */
7330
7331 /* "Bribe Unit" */
7332 if (!load_action_post_success_force(file, filename,
7333 ACTION_AUTO_POST_BRIBE,
7334 action_by_number(
7335 ACTION_SPY_BRIBE_UNIT))) {
7336 ok = FALSE;
7337 } else if (!load_action_post_success_force(file, filename,
7338 ACTION_AUTO_POST_ATTACK,
7339 action_by_number(
7340 ACTION_ATTACK))) {
7341 ok = FALSE;
7342 }
7343 }
7344
7345 if (ok) {
7346 struct action_auto_perf *auto_perf;
7347
7348 /* The city that made the unit's current tile native is gone.
7349 * Evaluated against an adjacent tile. */
7350 auto_perf = action_auto_perf_slot_number(ACTION_AUTO_ESCAPE_CITY);
7351 auto_perf->cause = AAPC_CITY_GONE;
7352
7353 /* I have no objections to moving this out of game's actions to
7354 * cities.ruleset, units.ruleset or an other location in game.ruleset
7355 * you find more suitable. -- Sveinung */
7356 if (!load_action_auto_actions(file, auto_perf,
7357 "actions.escape_city", filename)) {
7358 ok = FALSE;
7359 }
7360 }
7361
7362 if (ok) {
7363 struct action_auto_perf *auto_perf;
7364
7365 /* The unit's stack has been defeated and is scheduled for execution
7366 * but the unit has the CanEscape unit type flag.
7367 * Evaluated against an adjacent tile. */
7368 auto_perf = action_auto_perf_slot_number(ACTION_AUTO_ESCAPE_STACK);
7369 auto_perf->cause = AAPC_UNIT_STACK_DEATH;
7370
7371 /* I have no objections to moving this out of game's actions to
7372 * cities.ruleset, units.ruleset or an other location in game.ruleset
7373 * you find more suitable. -- Sveinung */
7374 if (!load_action_auto_actions(file, auto_perf,
7375 "actions.unit_stack_death", filename)) {
7376 ok = FALSE;
7377 }
7378 }
7379
7380 if (ok) {
7381 sec = secfile_sections_by_name_prefix(file,
7382 ACTION_ENABLER_SECTION_PREFIX);
7383
7384 if (sec) {
7385 section_list_iterate(sec, psection) {
7386 struct action_enabler *enabler;
7387 const char *sec_name = section_name(psection);
7388 struct action *paction;
7389 struct requirement_vector *actor_reqs;
7390 struct requirement_vector *target_reqs;
7391 const char *action_text;
7392
7393 enabler = action_enabler_new();
7394
7395 action_text = secfile_lookup_str(file, "%s.action", sec_name);
7396
7397 if (action_text == NULL) {
7398 ruleset_error(NULL, LOG_ERROR,
7399 "\"%s\" [%s] missing action to enable.",
7400 filename, sec_name);
7401 ok = FALSE;
7402 break;
7403 }
7404
7405 paction = action_by_rule_name(action_text);
7406 if (!paction) {
7407 ruleset_error(NULL, LOG_ERROR,
7408 "\"%s\" [%s] lists unknown action type \"%s\".",
7409 filename, sec_name, action_text);
7410 ok = FALSE;
7411 break;
7412 }
7413
7414 enabler->action = paction->id;
7415
7416 actor_reqs = lookup_req_list(file, compat, sec_name, "actor_reqs", action_text);
7417 if (actor_reqs == NULL) {
7418 ok = FALSE;
7419 break;
7420 }
7421
7422 requirement_vector_copy(&enabler->actor_reqs, actor_reqs);
7423
7424 target_reqs = lookup_req_list(file, compat, sec_name, "target_reqs", action_text);
7425 if (target_reqs == NULL) {
7426 ok = FALSE;
7427 break;
7428 }
7429
7430 requirement_vector_copy(&enabler->target_reqs, target_reqs);
7431
7432 action_enabler_add(enabler);
7433 } section_list_iterate_end;
7434
7435 section_list_destroy(sec);
7436 }
7437 }
7438 }
7439
7440 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
7441 bool slow_invasions
7442 = secfile_lookup_bool_default(file, TRUE,
7443 "global_unit_options.slow_invasions");
7444
7445 if (!rscompat_old_slow_invasions_3_1(compat, slow_invasions)) {
7446 ok = FALSE;
7447 }
7448 }
7449
7450 if (ok) {
7451 const char *tus_text;
7452 bool default_drbr = RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE;
7453
7454 /* section: combat_rules */
7455 game.info.tired_attack
7456 = secfile_lookup_bool_default(file, RS_DEFAULT_TIRED_ATTACK,
7457 "combat_rules.tired_attack");
7458
7459 game.info.only_killing_makes_veteran
7460 = secfile_lookup_bool_default(file, RS_DEFAULT_ONLY_KILLING_VETERAN,
7461 "combat_rules.only_killing_makes_veteran");
7462
7463 game.info.only_real_fight_makes_veteran
7464 = secfile_lookup_bool_default(file, RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN,
7465 "combat_rules.only_real_fight_makes_veteran");
7466
7467 game.info.combat_odds_scaled_veterancy
7468 = secfile_lookup_bool_default(file, RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY,
7469 "combat_rules.combat_odds_scaled_veterancy");
7470
7471 if (compat->compat_mode && compat->version < RSFORMAT_3_1) {
7472 /* Old hardcoded behavior was not to have bombard rate reduced for damage. */
7473 default_drbr = FALSE;
7474 }
7475 game.info.damage_reduces_bombard_rate
7476 = secfile_lookup_bool_default(file, default_drbr,
7477 "combat_rules.damage_reduces_bombard_rate");
7478
7479 game.info.low_firepower_badwallattacker
7480 = secfile_lookup_int_default(file, 1,
7481 "combat_rules.low_firepower_badwallattacker");
7482 game.info.low_firepower_pearl_harbour
7483 = secfile_lookup_int_default(file, 1,
7484 "combat_rules.low_firepower_pearl_harbour");
7485 game.info.low_firepower_combat_bonus
7486 = secfile_lookup_int_default(file, 1,
7487 "combat_rules.low_firepower_combat_bonus");
7488 game.info.low_firepower_nonnat_bombard
7489 = secfile_lookup_int_default(file, 1,
7490 "combat_rules.low_firepower_nonnat_bombard");
7491
7492 game.info.nuke_pop_loss_pct = secfile_lookup_int_default_min_max(file,
7493 RS_DEFAULT_NUKE_POP_LOSS_PCT,
7494 RS_MIN_NUKE_POP_LOSS_PCT,
7495 RS_MAX_NUKE_POP_LOSS_PCT,
7496 "combat_rules.nuke_pop_loss_pct");
7497
7498 game.info.nuke_defender_survival_chance_pct = secfile_lookup_int_default_min_max(file,
7499 RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT,
7500 RS_MIN_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT,
7501 RS_MAX_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT,
7502 "combat_rules.nuke_defender_survival_chance_pct");
7503
7504 /* section: borders */
7505 game.info.border_city_radius_sq
7506 = secfile_lookup_int_default_min_max(file,
7507 RS_DEFAULT_BORDER_RADIUS_SQ_CITY,
7508 RS_MIN_BORDER_RADIUS_SQ_CITY,
7509 RS_MAX_BORDER_RADIUS_SQ_CITY,
7510 "borders.radius_sq_city");
7511 game.info.border_size_effect
7512 = secfile_lookup_int_default_min_max(file,
7513 RS_DEFAULT_BORDER_SIZE_EFFECT,
7514 RS_MIN_BORDER_SIZE_EFFECT,
7515 RS_MAX_BORDER_SIZE_EFFECT,
7516 "borders.size_effect");
7517
7518 game.info.border_city_permanent_radius_sq
7519 = secfile_lookup_int_default_min_max(file,
7520 RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT,
7521 RS_MIN_BORDER_RADIUS_SQ_CITY_PERMANENT,
7522 RS_MAX_BORDER_RADIUS_SQ_CITY_PERMANENT,
7523 "borders.radius_sq_city_permanent");
7524
7525 /* section: research */
7526 tus_text = secfile_lookup_str_default(file, RS_DEFAULT_TECH_COST_STYLE,
7527 "research.tech_cost_style");
7528 game.info.tech_cost_style = tech_cost_style_by_name(tus_text,
7529 fc_strcasecmp);
7530 if (!tech_cost_style_is_valid(game.info.tech_cost_style)) {
7531 ruleset_error(NULL, LOG_ERROR,
7532 "Unknown tech cost style \"%s\"",
7533 tus_text);
7534 ok = FALSE;
7535 }
7536
7537 tus_text = secfile_lookup_str_default(file, RS_DEFAULT_TECH_LEAKAGE,
7538 "research.tech_leakage");
7539 game.info.tech_leakage = tech_leakage_style_by_name(tus_text,
7540 fc_strcasecmp);
7541 if (!tech_leakage_style_is_valid(game.info.tech_leakage)) {
7542 ruleset_error(NULL, LOG_ERROR,
7543 "Unknown tech leakage \"%s\"",
7544 tus_text);
7545 ok = FALSE;
7546 }
7547 if (game.info.tech_cost_style == TECH_COST_CIV1CIV2
7548 && game.info.tech_leakage != TECH_LEAKAGE_NONE) {
7549 log_error("Only tech_leakage \"%s\" supported with "
7550 "tech_cost_style \"%s\". ",
7551 tech_leakage_style_name(TECH_LEAKAGE_NONE),
7552 tech_cost_style_name(TECH_COST_CIV1CIV2));
7553 log_error("Switching to tech_leakage \"%s\".",
7554 tech_leakage_style_name(TECH_LEAKAGE_NONE));
7555 game.info.tech_leakage = TECH_LEAKAGE_NONE;
7556 }
7557 game.info.base_tech_cost
7558 = secfile_lookup_int_default_min_max(file,
7559 RS_DEFAULT_BASE_TECH_COST,
7560 RS_MIN_BASE_TECH_COST,
7561 RS_MAX_BASE_TECH_COST,
7562 "research.base_tech_cost");
7563
7564 tus_text = secfile_lookup_str_default(file, RS_DEFAULT_TECH_UPKEEP_STYLE,
7565 "research.tech_upkeep_style");
7566
7567 game.info.tech_upkeep_style = tech_upkeep_style_by_name(tus_text, fc_strcasecmp);
7568
7569 if (!tech_upkeep_style_is_valid(game.info.tech_upkeep_style)) {
7570 ruleset_error(NULL, LOG_ERROR,
7571 "Unknown tech upkeep style \"%s\"",
7572 tus_text);
7573 ok = FALSE;
7574 }
7575 }
7576
7577 if (ok) {
7578 game.info.tech_upkeep_divider
7579 = secfile_lookup_int_default_min_max(file,
7580 RS_DEFAULT_TECH_UPKEEP_DIVIDER,
7581 RS_MIN_TECH_UPKEEP_DIVIDER,
7582 RS_MAX_TECH_UPKEEP_DIVIDER,
7583 "research.tech_upkeep_divider");
7584
7585 sval = secfile_lookup_str_default(file, NULL, "research.free_tech_method");
7586 if (sval == NULL) {
7587 ruleset_error(NULL, LOG_ERROR,
7588 "No free_tech_method given");
7589 ok = FALSE;
7590 } else {
7591 game.info.free_tech_method = free_tech_method_by_name(sval, fc_strcasecmp);
7592 if (!free_tech_method_is_valid(game.info.free_tech_method)) {
7593 ruleset_error(NULL, LOG_ERROR,
7594 "Bad value %s for free_tech_method.", sval);
7595 ok = FALSE;
7596 }
7597 }
7598 }
7599
7600 if (ok) {
7601 int cf;
7602
7603 /* section: culture */
7604 game.info.culture_vic_points
7605 = secfile_lookup_int_default(file, RS_DEFAULT_CULTURE_VIC_POINTS,
7606 "culture.victory_min_points");
7607 game.info.culture_vic_lead
7608 = secfile_lookup_int_default(file, RS_DEFAULT_CULTURE_VIC_LEAD,
7609 "culture.victory_lead_pct");
7610 game.info.culture_migration_pml
7611 = secfile_lookup_int_default(file, RS_DEFAULT_CULTURE_MIGRATION_PML,
7612 "culture.migration_pml");
7613 game.info.history_interest_pml
7614 = secfile_lookup_int_default(file, RS_DEFAULT_HISTORY_INTEREST_PML,
7615 "culture.history_interest_pml");
7616
7617 /* section: calendar */
7618 game.calendar.calendar_skip_0
7619 = secfile_lookup_bool_default(file, RS_DEFAULT_CALENDAR_SKIP_0,
7620 "calendar.skip_year_0");
7621 game.server.start_year
7622 = secfile_lookup_int_default(file, GAME_DEFAULT_START_YEAR,
7623 "calendar.start_year");
7624 game.calendar.calendar_fragments
7625 = secfile_lookup_int_default(file, 0, "calendar.fragments");
7626
7627 if (game.calendar.calendar_fragments > MAX_CALENDAR_FRAGMENTS) {
7628 ruleset_error(NULL, LOG_ERROR,
7629 "Too many calendar fragments. Max is %d",
7630 MAX_CALENDAR_FRAGMENTS);
7631 ok = FALSE;
7632 game.calendar.calendar_fragments = 0;
7633 }
7634 sz_strlcpy(game.calendar.positive_year_label,
7635 secfile_lookup_str_default(file,
7636 RS_DEFAULT_POS_YEAR_LABEL,
7637 "calendar.positive_label"));
7638 sz_strlcpy(game.calendar.negative_year_label,
7639 secfile_lookup_str_default(file,
7640 RS_DEFAULT_NEG_YEAR_LABEL,
7641 "calendar.negative_label"));
7642
7643 for (cf = 0; cf < game.calendar.calendar_fragments; cf++) {
7644 const char *fname;
7645
7646 fname = secfile_lookup_str_default(file, NULL, "calendar.fragment_name%d", cf);
7647 if (fname != NULL) {
7648 strncpy(game.calendar.calendar_fragment_name[cf], fname,
7649 sizeof(game.calendar.calendar_fragment_name[cf]));
7650 }
7651 }
7652 }
7653
7654 if (ok) {
7655 /* section playercolors */
7656 struct rgbcolor *prgbcolor = NULL;
7657 bool color_read = TRUE;
7658
7659 /* Check if the player list is defined and empty. */
7660 if (playercolor_count() != 0) {
7661 ok = FALSE;
7662 } else {
7663 i = 0;
7664
7665 while (color_read) {
7666 prgbcolor = NULL;
7667
7668 color_read = rgbcolor_load(file, &prgbcolor, "playercolors.colorlist%d", i);
7669 if (color_read) {
7670 playercolor_add(prgbcolor);
7671 }
7672
7673 i++;
7674 }
7675
7676 if (playercolor_count() == 0) {
7677 ruleset_error(NULL, LOG_ERROR, "No player colors defined!");
7678 ok = FALSE;
7679 }
7680
7681 if (ok) {
7682 fc_assert(game.plr_bg_color == NULL);
7683 if (!rgbcolor_load(file, &game.plr_bg_color, "playercolors.background")) {
7684 ruleset_error(NULL, LOG_ERROR,
7685 "No background player color defined! (%s)",
7686 secfile_error());
7687 ok = FALSE;
7688 }
7689 }
7690 }
7691 }
7692
7693 if (ok) {
7694 /* section: teams */
7695 svec = secfile_lookup_str_vec(file, &teams, "teams.names");
7696 if (team_slot_count() < teams) {
7697 teams = team_slot_count();
7698 }
7699 game.server.ruledit.named_teams = teams;
7700 for (i = 0; i < teams; i++) {
7701 team_slot_set_defined_name(team_slot_by_number(i), svec[i]);
7702 }
7703 free(svec);
7704
7705 sec = secfile_sections_by_name_prefix(file, DISASTER_SECTION_PREFIX);
7706 nval = (NULL != sec ? section_list_size(sec) : 0);
7707 if (nval > MAX_DISASTER_TYPES) {
7708 int num = nval; /* No "size_t" to printf */
7709
7710 ruleset_error(NULL, LOG_ERROR,
7711 "\"%s\": Too many disaster types (%d, max %d)",
7712 filename, num, MAX_DISASTER_TYPES);
7713 section_list_destroy(sec);
7714 ok = FALSE;
7715 } else {
7716 game.control.num_disaster_types = nval;
7717 }
7718 }
7719
7720 if (ok) {
7721 disaster_type_iterate(pdis) {
7722 int id = disaster_index(pdis);
7723 int j;
7724 size_t eff_count;
7725 struct requirement_vector *reqs;
7726 const char *sec_name = section_name(section_list_get(sec, id));
7727
7728 if (!ruleset_load_names(&pdis->name, NULL, file, sec_name)) {
7729 ruleset_error(NULL, LOG_ERROR,
7730 "\"%s\": Cannot load disaster names",
7731 filename);
7732 ok = FALSE;
7733 break;
7734 }
7735
7736 reqs = lookup_req_list(file, compat, sec_name, "reqs", disaster_rule_name(pdis));
7737 if (reqs == NULL) {
7738 ok = FALSE;
7739 break;
7740 }
7741 requirement_vector_copy(&pdis->reqs, reqs);
7742
7743 pdis->frequency = secfile_lookup_int_default(file, GAME_DEFAULT_DISASTER_FREQ,
7744 "%s.frequency", sec_name);
7745
7746 svec = secfile_lookup_str_vec(file, &eff_count, "%s.effects", sec_name);
7747
7748 BV_CLR_ALL(pdis->effects);
7749 for (j = 0; j < eff_count; j++) {
7750 const char *dsval = svec[j];
7751 enum disaster_effect_id effect;
7752
7753 effect = disaster_effect_id_by_name(dsval, fc_strcasecmp);
7754
7755 if (!disaster_effect_id_is_valid(effect)) {
7756 ruleset_error(NULL, LOG_ERROR,
7757 "\"%s\" disaster \"%s\": unknown effect \"%s\".",
7758 filename, disaster_rule_name(pdis), dsval);
7759 ok = FALSE;
7760 break;
7761 } else {
7762 BV_SET(pdis->effects, effect);
7763 }
7764 }
7765
7766 free(svec);
7767
7768 if (!ok) {
7769 break;
7770 }
7771 } disaster_type_iterate_end;
7772 section_list_destroy(sec);
7773 }
7774
7775 if (ok) {
7776 sec = secfile_sections_by_name_prefix(file, ACHIEVEMENT_SECTION_PREFIX);
7777
7778 achievements_iterate(pach) {
7779 int id = achievement_index(pach);
7780 const char *sec_name = section_name(section_list_get(sec, id));
7781 const char *typename;
7782 const char *msg;
7783
7784 typename = secfile_lookup_str_default(file, NULL, "%s.type", sec_name);
7785
7786 pach->type = achievement_type_by_name(typename, fc_strcasecmp);
7787 if (!achievement_type_is_valid(pach->type)) {
7788 ruleset_error(NULL, LOG_ERROR,
7789 "Achievement has unknown type \"%s\".",
7790 typename != NULL ? typename : "(NULL)");
7791 ok = FALSE;
7792 }
7793
7794 if (ok) {
7795 pach->unique = secfile_lookup_bool_default(file, GAME_DEFAULT_ACH_UNIQUE,
7796 "%s.unique", sec_name);
7797
7798 pach->value = secfile_lookup_int_default(file, GAME_DEFAULT_ACH_VALUE,
7799 "%s.value", sec_name);
7800 pach->culture = secfile_lookup_int_default(file, 0,
7801 "%s.culture", sec_name);
7802
7803 msg = secfile_lookup_str_default(file, NULL, "%s.first_msg", sec_name);
7804 if (msg == NULL) {
7805 ruleset_error(NULL, LOG_ERROR,
7806 "Achievement %s has no first msg!", sec_name);
7807 ok = FALSE;
7808 } else {
7809 pach->first_msg = fc_strdup(msg);
7810 }
7811 }
7812
7813 if (ok) {
7814 msg = secfile_lookup_str_default(file, NULL, "%s.cons_msg", sec_name);
7815 if (msg == NULL) {
7816 if (!pach->unique) {
7817 ruleset_error(NULL, LOG_ERROR,
7818 "Achievement %s has no msg for consecutive gainers!",
7819 sec_name);
7820 ok = FALSE;
7821 }
7822 } else {
7823 pach->cons_msg = fc_strdup(msg);
7824 }
7825 }
7826
7827 if (!ok) {
7828 break;
7829 }
7830 } achievements_iterate_end;
7831 section_list_destroy(sec);
7832 }
7833
7834 if (ok) {
7835 for (i = 0; (name = secfile_lookup_str_default(file, NULL,
7836 "trade.settings%d.type",
7837 i)); i++) {
7838 enum trade_route_type type = trade_route_type_by_name(name);
7839
7840 if (type == TRT_LAST) {
7841 ruleset_error(NULL, LOG_ERROR,
7842 "\"%s\" unknown trade route type \"%s\".",
7843 filename, name);
7844 ok = FALSE;
7845 } else {
7846 struct trade_route_settings *set = trade_route_settings_by_type(type);
7847 const char *cancelling;
7848 const char *bonus;
7849
7850 set->trade_pct = secfile_lookup_int_default(file, 100,
7851 "trade.settings%d.pct", i);
7852 cancelling = secfile_lookup_str_default(file, "Active",
7853 "trade.settings%d.cancelling", i);
7854 set->cancelling = trade_route_cancelling_type_by_name(cancelling);
7855 if (set->cancelling == TRI_LAST) {
7856 ruleset_error(NULL, LOG_ERROR,
7857 "\"%s\" unknown trade route cancelling type \"%s\".",
7858 filename, cancelling);
7859 ok = FALSE;
7860 }
7861
7862 bonus = secfile_lookup_str_default(file, "None", "trade.settings%d.bonus", i);
7863
7864 set->bonus_type = trade_route_bonus_type_by_name(bonus, fc_strcasecmp);
7865
7866 if (!trade_route_bonus_type_is_valid(set->bonus_type)) {
7867 ruleset_error(NULL, LOG_ERROR,
7868 "\"%s\" unknown trade route bonus type \"%s\".",
7869 filename, bonus);
7870 ok = FALSE;
7871 }
7872 }
7873 }
7874 }
7875
7876 if (ok) {
7877 const char *str;
7878
7879 game.info.min_trade_route_val
7880 = secfile_lookup_int_default(file, 0, "trade.min_trade_route_val");
7881
7882 str = secfile_lookup_str_default(file,
7883 goods_selection_method_name(RS_DEFAULT_GOODS_SELECTION),
7884 "trade.goods_selection");
7885
7886 game.info.goods_selection = goods_selection_method_by_name(str, fc_strcasecmp);
7887
7888 if (!goods_selection_method_is_valid(game.info.goods_selection)) {
7889 ruleset_error(NULL, LOG_ERROR,
7890 "\"%s\" goods selection method \"%s\" unknown.",
7891 filename, str);
7892 ok = FALSE;
7893 }
7894 }
7895
7896 if (ok) {
7897 sec = secfile_sections_by_name_prefix(file, GOODS_SECTION_PREFIX);
7898
7899 goods_type_iterate(pgood) {
7900 int id = goods_index(pgood);
7901 const char *sec_name = section_name(section_list_get(sec, id));
7902 struct requirement_vector *reqs;
7903 const char **slist;
7904 int j;
7905
7906 reqs = lookup_req_list(file, compat, sec_name, "reqs", goods_rule_name(pgood));
7907 if (reqs == NULL) {
7908 ok = FALSE;
7909 break;
7910 }
7911 requirement_vector_copy(&pgood->reqs, reqs);
7912
7913 pgood->from_pct = secfile_lookup_int_default(file, 100,
7914 "%s.from_pct", sec_name);
7915 pgood->to_pct = secfile_lookup_int_default(file, 100,
7916 "%s.to_pct", sec_name);
7917 pgood->onetime_pct = secfile_lookup_int_default(file, 100,
7918 "%s.onetime_pct", sec_name);
7919
7920 slist = secfile_lookup_str_vec(file, &nval, "%s.flags", sec_name);
7921 BV_CLR_ALL(pgood->flags);
7922 for (j = 0; j < nval; j++) {
7923 enum goods_flag_id flag;
7924
7925 sval = slist[j];
7926 flag = goods_flag_id_by_name(sval, fc_strcasecmp);
7927 if (!goods_flag_id_is_valid(flag)) {
7928 ruleset_error(NULL, LOG_ERROR, "\"%s\" good \"%s\": unknown flag \"%s\".",
7929 filename, goods_rule_name(pgood), sval);
7930 ok = FALSE;
7931 break;
7932 } else {
7933 BV_SET(pgood->flags, flag);
7934 }
7935 }
7936 free(slist);
7937
7938 pgood->helptext = lookup_strvec(file, sec_name, "helptext");
7939 } goods_type_iterate_end;
7940 section_list_destroy(sec);
7941 }
7942
7943 if (ok) {
7944 sec = secfile_sections_by_name_prefix(file, CLAUSE_SECTION_PREFIX);
7945
7946 if (sec != NULL) {
7947 int num = section_list_size(sec);
7948
7949 for (i = 0; i < num; i++) {
7950 const char *sec_name = section_name(section_list_get(sec, i));
7951 const char *clause_name = secfile_lookup_str_default(file, NULL,
7952 "%s.type", sec_name);
7953 enum clause_type type = clause_type_by_name(clause_name, fc_strcasecmp);
7954 struct clause_info *info;
7955 struct requirement_vector *reqs;
7956
7957 if (!clause_type_is_valid(type)) {
7958 ruleset_error(NULL, LOG_ERROR,
7959 "\"%s\" unknown clause type \"%s\".",
7960 filename, clause_name);
7961 ok = FALSE;
7962 break;
7963 }
7964
7965 info = clause_info_get(type);
7966
7967 if (info->enabled) {
7968 ruleset_error(NULL, LOG_ERROR,
7969 "\"%s\" dublicate clause type \"%s\" definition.",
7970 filename, clause_name);
7971 ok = FALSE;
7972 break;
7973 }
7974
7975 reqs = lookup_req_list(file, compat, sec_name, "giver_reqs", clause_name);
7976 if (reqs == NULL) {
7977 ok = FALSE;
7978 break;
7979 }
7980 requirement_vector_copy(&info->giver_reqs, reqs);
7981
7982 reqs = lookup_req_list(file, compat, sec_name, "receiver_reqs", clause_name);
7983 if (reqs == NULL) {
7984 ok = FALSE;
7985 break;
7986 }
7987 requirement_vector_copy(&info->receiver_reqs, reqs);
7988
7989 info->enabled = TRUE;
7990 }
7991 }
7992 section_list_destroy(sec);
7993 }
7994
7995 /* secfile_check_unused() is not here, but only after also settings section
7996 * has been loaded. */
7997
7998 return ok;
7999}
8000
8001/**********************************************************************/
8005 static void send_ruleset_unit_classes(struct conn_list *dest)
8006{
8007 struct packet_ruleset_unit_class packet;
8008 struct packet_ruleset_unit_class_flag fpacket;
8009 int i;
8010
8011 for (i = 0; i < MAX_NUM_USER_UCLASS_FLAGS; i++) {
8012 const char *flagname;
8013 const char *helptxt;
8014
8015 fpacket.id = i + UCF_USER_FLAG_1;
8016
8017 flagname = unit_class_flag_id_name(i + UCF_USER_FLAG_1);
8018 if (flagname == NULL) {
8019 fpacket.name[0] = '\0';
8020 } else {
8021 sz_strlcpy(fpacket.name, flagname);
8022 }
8023
8024 helptxt = unit_class_flag_helptxt(i + UCF_USER_FLAG_1);
8025 if (helptxt == NULL) {
8026 fpacket.helptxt[0] = '\0';
8027 } else {
8028 sz_strlcpy(fpacket.helptxt, helptxt);
8029 }
8030
8031 lsend_packet_ruleset_unit_class_flag(dest, &fpacket);
8032 }
8033
8034 unit_class_iterate(c) {
8035 packet.id = uclass_number(c);
8036 sz_strlcpy(packet.name, untranslated_name(&c->name));
8037 sz_strlcpy(packet.rule_name, rule_name_get(&c->name));
8038 packet.min_speed = c->min_speed;
8039 packet.hp_loss_pct = c->hp_loss_pct;
8040 packet.non_native_def_pct = c->non_native_def_pct;
8041 packet.flags = c->flags;
8042
8043 PACKET_STRVEC_COMPUTE(packet.helptext, c->helptext);
8044
8045 lsend_packet_ruleset_unit_class(dest, &packet);
8046 } unit_class_iterate_end;
8047}
8048
8049/**********************************************************************/
8053 static void send_ruleset_units(struct conn_list *dest)
8054{
8055 struct packet_ruleset_unit packet;
8056#ifdef FREECIV_WEB
8057 struct packet_web_ruleset_unit_addition web_packet;
8058#endif /* FREECIV_WEB */
8059 struct packet_ruleset_unit_flag fpacket;
8060 int i;
8061
8062 for (i = 0; i < MAX_NUM_USER_UNIT_FLAGS; i++) {
8063 const char *flagname;
8064 const char *helptxt;
8065
8066 fpacket.id = i + UTYF_USER_FLAG_1;
8067
8068 flagname = unit_type_flag_id_name(i + UTYF_USER_FLAG_1);
8069 if (flagname == NULL) {
8070 fpacket.name[0] = '\0';
8071 } else {
8072 sz_strlcpy(fpacket.name, flagname);
8073 }
8074
8075 helptxt = unit_type_flag_helptxt(i + UTYF_USER_FLAG_1);
8076 if (helptxt == NULL) {
8077 fpacket.helptxt[0] = '\0';
8078 } else {
8079 sz_strlcpy(fpacket.helptxt, helptxt);
8080 }
8081
8082 lsend_packet_ruleset_unit_flag(dest, &fpacket);
8083 }
8084
8085 unit_type_iterate(u) {
8086 packet.id = utype_number(u);
8087 sz_strlcpy(packet.name, untranslated_name(&u->name));
8088 sz_strlcpy(packet.rule_name, rule_name_get(&u->name));
8089 sz_strlcpy(packet.sound_move, u->sound_move);
8090 sz_strlcpy(packet.sound_move_alt, u->sound_move_alt);
8091 sz_strlcpy(packet.sound_fight, u->sound_fight);
8092 sz_strlcpy(packet.sound_fight_alt, u->sound_fight_alt);
8093 sz_strlcpy(packet.graphic_str, u->graphic_str);
8094 sz_strlcpy(packet.graphic_alt, u->graphic_alt);
8095 packet.unit_class_id = uclass_number(utype_class(u));
8096 packet.build_cost = u->build_cost;
8097 packet.pop_cost = u->pop_cost;
8098 packet.attack_strength = u->attack_strength;
8099 packet.defense_strength = u->defense_strength;
8100 packet.move_rate = u->move_rate;
8101 packet.tech_requirement = u->require_advance
8102 ? advance_number(u->require_advance)
8103 : advance_count();
8104
8105 i = 0;
8106 requirement_vector_iterate(&u->build_reqs, req) {
8107 packet.build_reqs[i++] = *req;
8108 } requirement_vector_iterate_end;
8109 packet.build_reqs_count = i;
8110
8111 packet.vision_radius_sq = u->vision_radius_sq;
8112 packet.transport_capacity = u->transport_capacity;
8113 packet.hp = u->hp;
8114 packet.firepower = u->firepower;
8115 packet.obsoleted_by = u->obsoleted_by
8116 ? utype_number(u->obsoleted_by)
8117 : utype_count();
8118 packet.converted_to = u->converted_to
8119 ? utype_number(u->converted_to)
8120 : utype_count();
8121 packet.convert_time = u->convert_time;
8122 packet.fuel = u->fuel;
8123 packet.flags = u->flags;
8124 packet.roles = u->roles;
8125 packet.happy_cost = u->happy_cost;
8126 output_type_iterate(o) {
8127 packet.upkeep[o] = u->upkeep[o];
8128 } output_type_iterate_end;
8129 packet.paratroopers_range = u->paratroopers_range;
8130 packet.bombard_rate = u->bombard_rate;
8131 packet.city_size = u->city_size;
8132 packet.city_slots = u->city_slots;
8133 packet.tp_defense = u->tp_defense;
8134 packet.cargo = u->cargo;
8135 packet.targets = u->targets;
8136 packet.embarks = u->embarks;
8137 packet.disembarks = u->disembarks;
8138 packet.vlayer = u->vlayer;
8139
8140 if (u->veteran == NULL) {
8141 /* Use the default veteran system. */
8142 packet.veteran_levels = 0;
8143 } else {
8144 /* Per unit veteran system definition. */
8145 packet.veteran_levels = utype_veteran_levels(u);
8146
8147 for (i = 0; i < packet.veteran_levels; i++) {
8148 const struct veteran_level *vlevel = utype_veteran_level(u, i);
8149
8150 sz_strlcpy(packet.veteran_name[i], untranslated_name(&vlevel->name));
8151 packet.power_fact[i] = vlevel->power_fact;
8152 packet.move_bonus[i] = vlevel->move_bonus;
8153 packet.base_raise_chance[i] = vlevel->base_raise_chance;
8154 packet.work_raise_chance[i] = vlevel->work_raise_chance;
8155 }
8156 }
8157 PACKET_STRVEC_COMPUTE(packet.helptext, u->helptext);
8158
8159 packet.worker = u->adv.worker;
8160
8161#ifdef FREECIV_WEB
8162 web_packet.id = utype_number(u);
8163
8164 BV_CLR_ALL(web_packet.utype_actions);
8165
8166 action_iterate(act) {
8167 if (utype_can_do_action(u, act)) {
8168 BV_SET(web_packet.utype_actions, act);
8169 }
8170 } action_iterate_end;
8171#endif /* FREECIV_WEB */
8172
8173 lsend_packet_ruleset_unit(dest, &packet);
8174 web_lsend_packet(ruleset_unit_addition, dest, &web_packet);
8175
8176 combat_bonus_list_iterate(u->bonuses, pbonus) {
8177 struct packet_ruleset_unit_bonus bonuspacket;
8178
8179 bonuspacket.unit = packet.id;
8180 bonuspacket.flag = pbonus->flag;
8181 bonuspacket.type = pbonus->type;
8182 bonuspacket.value = pbonus->value;
8183 bonuspacket.quiet = pbonus->quiet;
8184
8185 lsend_packet_ruleset_unit_bonus(dest, &bonuspacket);
8186 } combat_bonus_list_iterate_end;
8187 } unit_type_iterate_end;
8188}
8189
8190/**********************************************************************/
8194 static void send_ruleset_specialists(struct conn_list *dest)
8195{
8196 struct packet_ruleset_specialist packet;
8197
8198 specialist_type_iterate(spec_id) {
8199 struct specialist *s = specialist_by_number(spec_id);
8200 int j;
8201
8202 packet.id = spec_id;
8203 sz_strlcpy(packet.plural_name, untranslated_name(&s->name));
8204 sz_strlcpy(packet.rule_name, rule_name_get(&s->name));
8205 sz_strlcpy(packet.short_name, untranslated_name(&s->abbreviation));
8206 sz_strlcpy(packet.graphic_str, s->graphic_str);
8207 sz_strlcpy(packet.graphic_alt, s->graphic_alt);
8208 j = 0;
8209 requirement_vector_iterate(&s->reqs, preq) {
8210 packet.reqs[j++] = *preq;
8211 } requirement_vector_iterate_end;
8212 packet.reqs_count = j;
8213
8214 PACKET_STRVEC_COMPUTE(packet.helptext, s->helptext);
8215
8216 lsend_packet_ruleset_specialist(dest, &packet);
8217 } specialist_type_iterate_end;
8218}
8219/**********************************************************************/
8222 static void send_ruleset_tech_classes(struct conn_list *dest)
8223{
8224 struct packet_ruleset_tech_class packet;
8225
8226 tech_class_iterate(ptclass) {
8227 packet.id = ptclass->idx;
8228 sz_strlcpy(packet.name, untranslated_name(&ptclass->name));
8229 sz_strlcpy(packet.rule_name, rule_name_get(&ptclass->name));
8230 packet.cost_pct = ptclass->cost_pct;
8231
8232 lsend_packet_ruleset_tech_class(dest, &packet);
8233 } tech_class_iterate_end;
8234}
8235
8236/**********************************************************************/
8240 static void send_ruleset_techs(struct conn_list *dest)
8241{
8242 struct packet_ruleset_tech packet;
8243 struct packet_ruleset_tech_flag fpacket;
8244 int i;
8245
8246 for (i = 0; i < MAX_NUM_USER_TECH_FLAGS; i++) {
8247 const char *flagname;
8248 const char *helptxt;
8249
8250 fpacket.id = i + TECH_USER_1;
8251
8252 flagname = tech_flag_id_name_cb(i + TECH_USER_1);
8253 if (flagname == NULL) {
8254 fpacket.name[0] = '\0';
8255 } else {
8256 sz_strlcpy(fpacket.name, flagname);
8257 }
8258
8259 helptxt = tech_flag_helptxt(i + TECH_USER_1);
8260 if (helptxt == NULL) {
8261 fpacket.helptxt[0] = '\0';
8262 } else {
8263 sz_strlcpy(fpacket.helptxt, helptxt);
8264 }
8265
8266 lsend_packet_ruleset_tech_flag(dest, &fpacket);
8267 }
8268
8269 advance_iterate(A_FIRST, a) {
8270 packet.id = advance_number(a);
8271 packet.removed = !valid_advance(a);
8272 if (a->tclass == NULL) {
8273 packet.tclass = 0;
8274 } else {
8275 packet.tclass = a->tclass->idx;
8276 }
8277 sz_strlcpy(packet.name, untranslated_name(&a->name));
8278 sz_strlcpy(packet.rule_name, rule_name_get(&a->name));
8279 sz_strlcpy(packet.graphic_str, a->graphic_str);
8280 sz_strlcpy(packet.graphic_alt, a->graphic_alt);
8281
8282 /* Current size of the packet's research_reqs requirement vector. */
8283 i = 0;
8284
8285 /* The requirements req1 and req2 are needed to research a tech. Send
8286 * them in the research_reqs requirement vector. Range is set to player
8287 * since pooled research is configurable. */
8288
8289 if ((a->require[AR_ONE] != A_NEVER)
8290 && advance_number(a->require[AR_ONE]) > A_NONE) {
8291 packet.research_reqs[i++]
8292 = req_from_values(VUT_ADVANCE, REQ_RANGE_PLAYER,
8293 FALSE, TRUE, FALSE,
8294 advance_number(a->require[AR_ONE]));
8295 }
8296
8297 if ((a->require[AR_TWO] != A_NEVER)
8298 && advance_number(a->require[AR_TWO]) > A_NONE) {
8299 packet.research_reqs[i++]
8300 = req_from_values(VUT_ADVANCE, REQ_RANGE_PLAYER,
8301 FALSE, TRUE, FALSE,
8302 advance_number(a->require[AR_TWO]));;
8303 }
8304
8305 /* The requirements of the tech's research_reqs also goes in the
8306 * packet's research_reqs requirement vector. */
8307 requirement_vector_iterate(&a->research_reqs, req) {
8308 packet.research_reqs[i++] = *req;
8309 } requirement_vector_iterate_end;
8310
8311 /* The packet's research_reqs should contain req1, req2 and the
8312 * requirements of the tech's research_reqs. */
8313 packet.research_reqs_count = i;
8314
8315 packet.root_req = a->require[AR_ROOT]
8316 ? advance_number(a->require[AR_ROOT])
8317 : advance_count();
8318
8319 packet.flags = a->flags;
8320 packet.cost = a->cost;
8321 packet.num_reqs = a->num_reqs;
8322 PACKET_STRVEC_COMPUTE(packet.helptext, a->helptext);
8323
8324 lsend_packet_ruleset_tech(dest, &packet);
8325 } advance_iterate_end;
8326}
8327
8328/**********************************************************************/
8332 static void send_ruleset_buildings(struct conn_list *dest)
8333{
8334 improvement_iterate(b) {
8335 struct packet_ruleset_building packet;
8336 int j;
8337
8338 packet.id = improvement_number(b);
8339 packet.genus = b->genus;
8340 sz_strlcpy(packet.name, untranslated_name(&b->name));
8341 sz_strlcpy(packet.rule_name, rule_name_get(&b->name));
8342 sz_strlcpy(packet.graphic_str, b->graphic_str);
8343 sz_strlcpy(packet.graphic_alt, b->graphic_alt);
8344 j = 0;
8345 requirement_vector_iterate(&b->reqs, preq) {
8346 packet.reqs[j++] = *preq;
8347 } requirement_vector_iterate_end;
8348 packet.reqs_count = j;
8349 j = 0;
8350 requirement_vector_iterate(&b->obsolete_by, pobs) {
8351 packet.obs_reqs[j++] = *pobs;
8352 } requirement_vector_iterate_end;
8353 packet.obs_count = j;
8354 packet.build_cost = b->build_cost;
8355 packet.upkeep = b->upkeep;
8356 packet.sabotage = b->sabotage;
8357 packet.flags = b->flags;
8358 sz_strlcpy(packet.soundtag, b->soundtag);
8359 sz_strlcpy(packet.soundtag_alt, b->soundtag_alt);
8360 PACKET_STRVEC_COMPUTE(packet.helptext, b->helptext);
8361
8362 lsend_packet_ruleset_building(dest, &packet);
8363 } improvement_iterate_end;
8364}
8365
8366/**********************************************************************/
8370 static void send_ruleset_terrain(struct conn_list *dest)
8371{
8372 struct packet_ruleset_terrain packet;
8373 struct packet_ruleset_terrain_flag fpacket;
8374 int i;
8375
8376 lsend_packet_ruleset_terrain_control(dest, &terrain_control);
8377
8378 for (i = 0; i < MAX_NUM_USER_TER_FLAGS; i++) {
8379 const char *flagname;
8380 const char *helptxt;
8381
8382 fpacket.id = i + TER_USER_1;
8383
8384 flagname = terrain_flag_id_name_cb(i + TER_USER_1);
8385 if (flagname == NULL) {
8386 fpacket.name[0] = '\0';
8387 } else {
8388 sz_strlcpy(fpacket.name, flagname);
8389 }
8390
8391 helptxt = terrain_flag_helptxt(i + TER_USER_1);
8392 if (helptxt == NULL) {
8393 fpacket.helptxt[0] = '\0';
8394 } else {
8395 sz_strlcpy(fpacket.helptxt, helptxt);
8396 }
8397
8398 lsend_packet_ruleset_terrain_flag(dest, &fpacket);
8399 }
8400
8401 terrain_type_iterate(pterrain) {
8402 struct extra_type **r;
8403
8404 packet.id = terrain_number(pterrain);
8405 packet.tclass = pterrain->tclass;
8406 packet.native_to = pterrain->native_to;
8407
8408 sz_strlcpy(packet.name, untranslated_name(&pterrain->name));
8409 sz_strlcpy(packet.rule_name, rule_name_get(&pterrain->name));
8410 sz_strlcpy(packet.graphic_str, pterrain->graphic_str);
8411 sz_strlcpy(packet.graphic_alt, pterrain->graphic_alt);
8412
8413 packet.movement_cost = pterrain->movement_cost;
8414 packet.defense_bonus = pterrain->defense_bonus;
8415
8416 output_type_iterate(o) {
8417 packet.output[o] = pterrain->output[o];
8418 } output_type_iterate_end;
8419
8420 packet.num_resources = 0;
8421 for (r = pterrain->resources; *r; r++) {
8422 packet.resources[packet.num_resources++] = extra_number(*r);
8423 }
8424
8425 output_type_iterate(o) {
8426 packet.road_output_incr_pct[o] = pterrain->road_output_incr_pct[o];
8427 } output_type_iterate_end;
8428
8429 packet.base_time = pterrain->base_time;
8430 packet.road_time = pterrain->road_time;
8431
8432 packet.cultivate_result = (pterrain->cultivate_result
8433 ? terrain_number(pterrain->cultivate_result)
8434 : terrain_count());
8435 packet.cultivate_time = pterrain->cultivate_time;
8436
8437 packet.plant_result = (pterrain->plant_result
8438 ? terrain_number(pterrain->plant_result)
8439 : terrain_count());
8440 packet.plant_time = pterrain->plant_time;
8441
8442 packet.irrigation_food_incr = pterrain->irrigation_food_incr;
8443 packet.irrigation_time = pterrain->irrigation_time;
8444
8445 packet.mining_shield_incr = pterrain->mining_shield_incr;
8446 packet.mining_time = pterrain->mining_time;
8447
8448 packet.animal = (pterrain->animal == NULL ? -1 : utype_number(pterrain->animal));
8449 packet.transform_result = (pterrain->transform_result
8450 ? terrain_number(pterrain->transform_result)
8451 : terrain_count());
8452 packet.placing_time = pterrain->placing_time;
8453 packet.pillage_time = pterrain->pillage_time;
8454 packet.transform_time = pterrain->transform_time;
8455 packet.clean_pollution_time = pterrain->clean_pollution_time;
8456 packet.clean_fallout_time = pterrain->clean_fallout_time;
8457
8458 packet.flags = pterrain->flags;
8459
8460 packet.color_red = pterrain->rgb->r;
8461 packet.color_green = pterrain->rgb->g;
8462 packet.color_blue = pterrain->rgb->b;
8463
8464 PACKET_STRVEC_COMPUTE(packet.helptext, pterrain->helptext);
8465
8466 lsend_packet_ruleset_terrain(dest, &packet);
8467 } terrain_type_iterate_end;
8468}
8469
8470/**********************************************************************/
8473 static void send_ruleset_resources(struct conn_list *dest)
8474{
8475 struct packet_ruleset_resource packet;
8476
8477 extra_type_by_cause_iterate(EC_RESOURCE, presource) {
8478 packet.id = extra_index(presource);
8479
8480 output_type_iterate(o) {
8481 packet.output[o] = presource->data.resource->output[o];
8482 } output_type_iterate_end;
8483
8484 lsend_packet_ruleset_resource(dest, &packet);
8485 } extra_type_by_cause_iterate_end;
8486}
8487
8488/**********************************************************************/
8492 static void send_ruleset_extras(struct conn_list *dest)
8493{
8494 struct packet_ruleset_extra packet;
8495 struct packet_ruleset_extra_flag fpacket;
8496 int i;
8497
8498 for (i = 0; i < MAX_NUM_USER_EXTRA_FLAGS; i++) {
8499 const char *flagname;
8500 const char *helptxt;
8501
8502 fpacket.id = i + EF_USER_FLAG_1;
8503
8504 flagname = extra_flag_id_name(i + EF_USER_FLAG_1);
8505 if (flagname == NULL) {
8506 fpacket.name[0] = '\0';
8507 } else {
8508 sz_strlcpy(fpacket.name, flagname);
8509 }
8510
8511 helptxt = extra_flag_helptxt(i + EF_USER_FLAG_1);
8512 if (helptxt == NULL) {
8513 fpacket.helptxt[0] = '\0';
8514 } else {
8515 sz_strlcpy(fpacket.helptxt, helptxt);
8516 }
8517
8518 lsend_packet_ruleset_extra_flag(dest, &fpacket);
8519 }
8520
8521 extra_type_iterate(e) {
8522 int j;
8523
8524 packet.id = extra_number(e);
8525 sz_strlcpy(packet.name, untranslated_name(&e->name));
8526 sz_strlcpy(packet.rule_name, rule_name_get(&e->name));
8527
8528 packet.category = e->category;
8529
8530 BV_CLR_ALL(packet.causes);
8531 for (j = 0; j < EC_COUNT; j++) {
8532 if (is_extra_caused_by(e, j)) {
8533 BV_SET(packet.causes, j);
8534 }
8535 }
8536
8537 BV_CLR_ALL(packet.rmcauses);
8538 for (j = 0; j < ERM_COUNT; j++) {
8539 if (is_extra_removed_by(e, j)) {
8540 BV_SET(packet.rmcauses, j);
8541 }
8542 }
8543
8544 sz_strlcpy(packet.activity_gfx, e->activity_gfx);
8545 sz_strlcpy(packet.act_gfx_alt, e->act_gfx_alt);
8546 sz_strlcpy(packet.act_gfx_alt2, e->act_gfx_alt2);
8547 sz_strlcpy(packet.rmact_gfx, e->rmact_gfx);
8548 sz_strlcpy(packet.rmact_gfx_alt, e->rmact_gfx_alt);
8549 sz_strlcpy(packet.graphic_str, e->graphic_str);
8550 sz_strlcpy(packet.graphic_alt, e->graphic_alt);
8551
8552 j = 0;
8553 requirement_vector_iterate(&e->reqs, preq) {
8554 packet.reqs[j++] = *preq;
8555 } requirement_vector_iterate_end;
8556 packet.reqs_count = j;
8557
8558 j = 0;
8559 requirement_vector_iterate(&e->rmreqs, preq) {
8560 packet.rmreqs[j++] = *preq;
8561 } requirement_vector_iterate_end;
8562 packet.rmreqs_count = j;
8563
8564 packet.appearance_chance = e->appearance_chance;
8565 j = 0;
8566 requirement_vector_iterate(&e->appearance_reqs, preq) {
8567 packet.appearance_reqs[j++] = *preq;
8568 } requirement_vector_iterate_end;
8569 packet.appearance_reqs_count = j;
8570
8571 packet.disappearance_chance = e->disappearance_chance;
8572 j = 0;
8573 requirement_vector_iterate(&e->disappearance_reqs, preq) {
8574 packet.disappearance_reqs[j++] = *preq;
8575 } requirement_vector_iterate_end;
8576 packet.disappearance_reqs_count = j;
8577
8578 packet.visibility_req = e->visibility_req;
8579 packet.buildable = e->buildable;
8580 packet.generated = e->generated;
8581 packet.build_time = e->build_time;
8582 packet.build_time_factor = e->build_time_factor;
8583 packet.removal_time = e->removal_time;
8584 packet.removal_time_factor = e->removal_time_factor;
8585 packet.infracost = e->infracost;
8586 packet.defense_bonus = e->defense_bonus;
8587 packet.eus = e->eus;
8588
8589 packet.native_to = e->native_to;
8590
8591 packet.flags = e->flags;
8592 packet.hidden_by = e->hidden_by;
8593 packet.bridged_over = e->bridged_over;
8594 packet.conflicts = e->conflicts;
8595
8596 PACKET_STRVEC_COMPUTE(packet.helptext, e->helptext);
8597
8598 lsend_packet_ruleset_extra(dest, &packet);
8599 } extra_type_iterate_end;
8600}
8601
8602/**********************************************************************/
8606 static void send_ruleset_bases(struct conn_list *dest)
8607{
8608 extra_type_by_cause_iterate(EC_BASE, pextra) {
8609 struct base_type *b = extra_base_get(pextra);
8610 struct packet_ruleset_base packet;
8611
8612 packet.id = base_number(b);
8613
8614 packet.gui_type = b->gui_type;
8615 packet.border_sq = b->border_sq;
8616 packet.vision_main_sq = b->vision_main_sq;
8617 packet.vision_invis_sq = b->vision_invis_sq;
8618 packet.vision_subs_sq = b->vision_subs_sq;
8619
8620 lsend_packet_ruleset_base(dest, &packet);
8621 } extra_type_by_cause_iterate_end;
8622}
8623
8624/**********************************************************************/
8628 static void send_ruleset_roads(struct conn_list *dest)
8629{
8630 struct packet_ruleset_road packet;
8631
8632 extra_type_by_cause_iterate(EC_ROAD, pextra) {
8633 struct road_type *r = extra_road_get(pextra);
8634 int j;
8635
8636 packet.id = road_number(r);
8637
8638 packet.gui_type = r->gui_type;
8639
8640 j = 0;
8641 requirement_vector_iterate(&r->first_reqs, preq) {
8642 packet.first_reqs[j++] = *preq;
8643 } requirement_vector_iterate_end;
8644 packet.first_reqs_count = j;
8645
8646 packet.move_cost = r->move_cost;
8647 packet.move_mode = r->move_mode;
8648
8649 output_type_iterate(o) {
8650 packet.tile_incr_const[o] = r->tile_incr_const[o];
8651 packet.tile_incr[o] = r->tile_incr[o];
8652 packet.tile_bonus[o] = r->tile_bonus[o];
8653 } output_type_iterate_end;
8654
8655 packet.compat = r->compat;
8656
8657 packet.integrates = r->integrates;
8658 packet.flags = r->flags;
8659
8660 lsend_packet_ruleset_road(dest, &packet);
8661 } extra_type_by_cause_iterate_end;
8662}
8663
8664/**********************************************************************/
8668 static void send_ruleset_goods(struct conn_list *dest)
8669{
8670 struct packet_ruleset_goods packet;
8671
8672 goods_type_iterate(g) {
8673 int j;
8674
8675 packet.id = goods_number(g);
8676 sz_strlcpy(packet.name, untranslated_name(&g->name));
8677 sz_strlcpy(packet.rule_name, rule_name_get(&g->name));
8678
8679 j = 0;
8680 requirement_vector_iterate(&g->reqs, preq) {
8681 packet.reqs[j++] = *preq;
8682 } requirement_vector_iterate_end;
8683 packet.reqs_count = j;
8684
8685 packet.from_pct = g->from_pct;
8686 packet.to_pct = g->to_pct;
8687 packet.onetime_pct = g->onetime_pct;
8688 packet.flags = g->flags;
8689
8690 PACKET_STRVEC_COMPUTE(packet.helptext, g->helptext);
8691
8692 lsend_packet_ruleset_goods(dest, &packet);
8693 } goods_type_iterate_end;
8694}
8695
8696/**********************************************************************/
8700 static void send_ruleset_disasters(struct conn_list *dest)
8701{
8702 struct packet_ruleset_disaster packet;
8703
8704 disaster_type_iterate(d) {
8705 int j;
8706
8707 packet.id = disaster_number(d);
8708
8709 sz_strlcpy(packet.name, untranslated_name(&d->name));
8710 sz_strlcpy(packet.rule_name, rule_name_get(&d->name));
8711
8712 j = 0;
8713 requirement_vector_iterate(&d->reqs, preq) {
8714 packet.reqs[j++] = *preq;
8715 } requirement_vector_iterate_end;
8716 packet.reqs_count = j;
8717
8718 packet.frequency = d->frequency;
8719
8720 packet.effects = d->effects;
8721
8722 lsend_packet_ruleset_disaster(dest, &packet);
8723 } disaster_type_iterate_end;
8724}
8725
8726/**********************************************************************/
8730 static void send_ruleset_achievements(struct conn_list *dest)
8731{
8732 struct packet_ruleset_achievement packet;
8733
8734 achievements_iterate(a) {
8735 packet.id = achievement_number(a);
8736
8737 sz_strlcpy(packet.name, untranslated_name(&a->name));
8738 sz_strlcpy(packet.rule_name, rule_name_get(&a->name));
8739
8740 packet.type = a->type;
8741 packet.unique = a->unique;
8742 packet.value = a->value;
8743
8744 lsend_packet_ruleset_achievement(dest, &packet);
8745 } achievements_iterate_end;
8746}
8747
8748/**********************************************************************/
8751 static void send_ruleset_actions(struct conn_list *dest)
8752{
8753 struct packet_ruleset_action packet;
8754
8755 action_iterate(act) {
8756 struct action *paction = action_by_number(act);
8757
8758 packet.id = act;
8759 sz_strlcpy(packet.ui_name, action_by_number(act)->ui_name);
8760 packet.quiet = action_by_number(act)->quiet;
8761
8762 packet.result = paction->result;
8763 packet.sub_results = paction->sub_results;
8764 packet.actor_consuming_always = paction->actor_consuming_always;
8765
8766 packet.act_kind = action_by_number(act)->actor_kind;
8767 packet.tgt_kind = action_by_number(act)->target_kind;
8768 packet.sub_tgt_kind = action_id_get_sub_target_kind(act);
8769
8770 packet.min_distance = action_by_number(act)->min_distance;
8771 packet.max_distance = action_by_number(act)->max_distance;
8772 packet.blocked_by = action_by_number(act)->blocked_by;
8773
8774 lsend_packet_ruleset_action(dest, &packet);
8775 } action_iterate_end;
8776}
8777
8778/**********************************************************************/
8781 static void send_ruleset_action_enablers(struct conn_list *dest)
8782{
8783 int counter;
8784 struct packet_ruleset_action_enabler packet;
8785
8786 action_enablers_iterate(enabler) {
8787 packet.enabled_action = enabler->action;
8788
8789 counter = 0;
8790 requirement_vector_iterate(&enabler->actor_reqs, req) {
8791 packet.actor_reqs[counter++] = *req;
8792 } requirement_vector_iterate_end;
8793 packet.actor_reqs_count = counter;
8794
8795 counter = 0;
8796 requirement_vector_iterate(&enabler->target_reqs, req) {
8797 packet.target_reqs[counter++] = *req;
8798 } requirement_vector_iterate_end;
8799 packet.target_reqs_count = counter;
8800
8801 lsend_packet_ruleset_action_enabler(dest, &packet);
8802 } action_enablers_iterate_end;
8803}
8804
8805/**********************************************************************/
8809 static void send_ruleset_action_auto_performers(struct conn_list *dest)
8810{
8811 int counter;
8812 int id;
8813 struct packet_ruleset_action_auto packet;
8814
8815 id = 0;
8816 action_auto_perf_iterate(aperf) {
8817 packet.id = id++;
8818
8819 packet.cause = aperf->cause;
8820
8821 counter = 0;
8822 requirement_vector_iterate(&aperf->reqs, req) {
8823 packet.reqs[counter++] = *req;
8824 } requirement_vector_iterate_end;
8825 packet.reqs_count = counter;
8826
8827 for (counter = 0;
8828 /* Can't list more actions than all actions. */
8829 counter < NUM_ACTIONS
8830 /* ACTION_NONE terminates the list. */
8831 && aperf->alternatives[counter] != ACTION_NONE;
8832 counter++) {
8833 packet.alternatives[counter] = aperf->alternatives[counter];
8834 }
8835 packet.alternatives_count = counter;
8836
8837 lsend_packet_ruleset_action_auto(dest, &packet);
8838 } action_auto_perf_iterate_end;
8839}
8840
8841/**********************************************************************/
8845 static void send_ruleset_trade_routes(struct conn_list *dest)
8846{
8847 struct packet_ruleset_trade packet;
8848 enum trade_route_type type;
8849
8850 for (type = TRT_NATIONAL; type < TRT_LAST; type++) {
8851 struct trade_route_settings *set = trade_route_settings_by_type(type);
8852
8853 packet.id = type;
8854 packet.trade_pct = set->trade_pct;
8855 packet.cancelling = set->cancelling;
8856 packet.bonus_type = set->bonus_type;
8857
8858 lsend_packet_ruleset_trade(dest, &packet);
8859 }
8860}
8861
8862/**********************************************************************/
8866 static void send_ruleset_governments(struct conn_list *dest)
8867{
8868 struct packet_ruleset_government gov;
8869 struct packet_ruleset_government_ruler_title title;
8870 int j;
8871
8872 governments_iterate(g) {
8873 /* send one packet_government */
8874 gov.id = government_number(g);
8875
8876 j = 0;
8877 requirement_vector_iterate(&g->reqs, preq) {
8878 gov.reqs[j++] = *preq;
8879 } requirement_vector_iterate_end;
8880 gov.reqs_count = j;
8881
8882 sz_strlcpy(gov.name, untranslated_name(&g->name));
8883 sz_strlcpy(gov.rule_name, rule_name_get(&g->name));
8884 sz_strlcpy(gov.graphic_str, g->graphic_str);
8885 sz_strlcpy(gov.graphic_alt, g->graphic_alt);
8886 PACKET_STRVEC_COMPUTE(gov.helptext, g->helptext);
8887
8888 lsend_packet_ruleset_government(dest, &gov);
8889
8890 /* Send one packet_government_ruler_title per ruler title. */
8891 ruler_titles_iterate(government_ruler_titles(g), pruler_title) {
8892 const struct nation_type *pnation = ruler_title_nation(pruler_title);
8893
8894 title.gov = government_number(g);
8895 title.nation = pnation ? nation_number(pnation) : nation_count();
8896 sz_strlcpy(title.male_title,
8897 ruler_title_male_untranslated_name(pruler_title));
8898 sz_strlcpy(title.female_title,
8899 ruler_title_female_untranslated_name(pruler_title));
8900 lsend_packet_ruleset_government_ruler_title(dest, &title);
8901 } ruler_titles_iterate_end;
8902 } governments_iterate_end;
8903}
8904
8905/**********************************************************************/
8909 static void send_ruleset_nations(struct conn_list *dest)
8910{
8911 struct packet_ruleset_nation_sets sets_packet;
8912 struct packet_ruleset_nation_groups groups_packet;
8913 struct packet_ruleset_nation packet;
8914 int i;
8915
8916 sets_packet.nsets = nation_set_count();
8917 i = 0;
8918 nation_sets_iterate(pset) {
8919 sz_strlcpy(sets_packet.names[i], nation_set_untranslated_name(pset));
8920 sz_strlcpy(sets_packet.rule_names[i], nation_set_rule_name(pset));
8921 sz_strlcpy(sets_packet.descriptions[i], nation_set_description(pset));
8922 i++;
8923 } nation_sets_iterate_end;
8924 lsend_packet_ruleset_nation_sets(dest, &sets_packet);
8925
8926 groups_packet.ngroups = nation_group_count();
8927 i = 0;
8928 nation_groups_iterate(pgroup) {
8929 sz_strlcpy(groups_packet.groups[i],
8930 nation_group_untranslated_name(pgroup));
8931 groups_packet.hidden[i] = pgroup->hidden;
8932 i++;
8933 } nation_groups_iterate_end;
8934 lsend_packet_ruleset_nation_groups(dest, &groups_packet);
8935
8936 nations_iterate(n) {
8937 packet.id = nation_number(n);
8938 if (n->translation_domain == NULL) {
8939 packet.translation_domain[0] = '\0';
8940 } else {
8941 sz_strlcpy(packet.translation_domain, n->translation_domain);
8942 }
8943 sz_strlcpy(packet.adjective, untranslated_name(&n->adjective));
8944 sz_strlcpy(packet.rule_name, rule_name_get(&n->adjective));
8945 sz_strlcpy(packet.noun_plural, untranslated_name(&n->noun_plural));
8946 sz_strlcpy(packet.graphic_str, n->flag_graphic_str);
8947 sz_strlcpy(packet.graphic_alt, n->flag_graphic_alt);
8948
8949 i = 0;
8950 nation_leader_list_iterate(nation_leaders(n), pleader) {
8951 sz_strlcpy(packet.leader_name[i], nation_leader_name(pleader));
8952 packet.leader_is_male[i] = nation_leader_is_male(pleader);
8953 i++;
8954 } nation_leader_list_iterate_end;
8955 packet.leader_count = i;
8956
8957 packet.style = style_number(n->style);
8958 packet.is_playable = n->is_playable;
8959 packet.barbarian_type = n->barb_type;
8960
8961 sz_strlcpy(packet.legend, n->legend);
8962
8963 i = 0;
8964 nation_set_list_iterate(n->sets, pset) {
8965 packet.sets[i++] = nation_set_number(pset);
8966 } nation_set_list_iterate_end;
8967 packet.nsets = i;
8968
8969 i = 0;
8970 nation_group_list_iterate(n->groups, pgroup) {
8971 packet.groups[i++] = nation_group_number(pgroup);
8972 } nation_group_list_iterate_end;
8973 packet.ngroups = i;
8974
8975 packet.init_government_id = n->init_government
8976 ? government_number(n->init_government) : government_count();
8977 fc_assert(ARRAY_SIZE(packet.init_techs) == ARRAY_SIZE(n->init_techs));
8978 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
8979 if (n->init_techs[i] != A_LAST) {
8980 packet.init_techs[i] = n->init_techs[i];
8981 } else {
8982 break;
8983 }
8984 }
8985 packet.init_techs_count = i;
8986 fc_assert(ARRAY_SIZE(packet.init_units) == ARRAY_SIZE(n->init_units));
8987 for (i = 0; i < MAX_NUM_UNIT_LIST; i++) {
8988 const struct unit_type *t = n->init_units[i];
8989 if (t) {
8990 packet.init_units[i] = utype_number(t);
8991 } else {
8992 break;
8993 }
8994 }
8995 packet.init_units_count = i;
8996 fc_assert(ARRAY_SIZE(packet.init_buildings)
8997 == ARRAY_SIZE(n->init_buildings));
8998 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
8999 if (n->init_buildings[i] != B_LAST) {
9000 /* Impr_type_id to int */
9001 packet.init_buildings[i] = n->init_buildings[i];
9002 } else {
9003 break;
9004 }
9005 }
9006 packet.init_buildings_count = i;
9007
9008 lsend_packet_ruleset_nation(dest, &packet);
9009 } nations_iterate_end;
9010
9011 /* Send initial values of is_pickable */
9012 send_nation_availability(dest, FALSE);
9013}
9014
9015/**********************************************************************/
9019 static void send_ruleset_styles(struct conn_list *dest)
9020{
9021 struct packet_ruleset_style packet;
9022
9023 styles_iterate(s) {
9024 packet.id = style_index(s);
9025 sz_strlcpy(packet.name, untranslated_name(&s->name));
9026 sz_strlcpy(packet.rule_name, rule_name_get(&s->name));
9027
9028 lsend_packet_ruleset_style(dest, &packet);
9029 } styles_iterate_end;
9030}
9031
9032/**********************************************************************/
9035 static void send_ruleset_clauses(struct conn_list *dest)
9036{
9037 struct packet_ruleset_clause packet;
9038 int i;
9039
9040 for (i = 0; i < CLAUSE_COUNT; i++) {
9041 struct clause_info *info = clause_info_get(i);
9042 int j;
9043
9044 packet.type = i;
9045 packet.enabled = info->enabled;
9046
9047 j = 0;
9048 requirement_vector_iterate(&info->giver_reqs, preq) {
9049 packet.giver_reqs[j++] = *preq;
9050 } requirement_vector_iterate_end;
9051 packet.giver_reqs_count = j;
9052
9053 j = 0;
9054 requirement_vector_iterate(&info->receiver_reqs, preq) {
9055 packet.receiver_reqs[j++] = *preq;
9056 } requirement_vector_iterate_end;
9057 packet.receiver_reqs_count = j;
9058
9059 lsend_packet_ruleset_clause(dest, &packet);
9060 }
9061}
9062
9063/**********************************************************************/
9067 static void send_ruleset_multipliers(struct conn_list *dest)
9068{
9069 multipliers_iterate(pmul) {
9070 int j;
9071 struct packet_ruleset_multiplier packet;
9072
9073 packet.id = multiplier_number(pmul);
9074 packet.start = pmul->start;
9075 packet.stop = pmul->stop;
9076 packet.step = pmul->step;
9077 packet.def = pmul->def;
9078 packet.offset = pmul->offset;
9079 packet.factor = pmul->factor;
9080 packet.minimum_turns = pmul->minimum_turns;
9081
9082 sz_strlcpy(packet.name, untranslated_name(&pmul->name));
9083 sz_strlcpy(packet.rule_name, rule_name_get(&pmul->name));
9084
9085 j = 0;
9086 requirement_vector_iterate(&pmul->reqs, preq) {
9087 packet.reqs[j++] = *preq;
9088 } requirement_vector_iterate_end;
9089 packet.reqs_count = j;
9090
9091 PACKET_STRVEC_COMPUTE(packet.helptext, pmul->helptext);
9092
9093 lsend_packet_ruleset_multiplier(dest, &packet);
9094 } multipliers_iterate_end;
9095}
9096
9097/**********************************************************************/
9101 static void send_ruleset_cities(struct conn_list *dest)
9102{
9103 struct packet_ruleset_city city_p;
9104 int k, j;
9105
9106 for (k = 0; k < game.control.styles_count; k++) {
9107 city_p.style_id = k;
9108
9109 j = 0;
9110 requirement_vector_iterate(&city_styles[k].reqs, preq) {
9111 city_p.reqs[j++] = *preq;
9112 } requirement_vector_iterate_end;
9113 city_p.reqs_count = j;
9114
9115 sz_strlcpy(city_p.name, untranslated_name(&city_styles[k].name));
9116 sz_strlcpy(city_p.rule_name, rule_name_get(&city_styles[k].name));
9117 sz_strlcpy(city_p.graphic, city_styles[k].graphic);
9118 sz_strlcpy(city_p.graphic_alt, city_styles[k].graphic_alt);
9119 sz_strlcpy(city_p.citizens_graphic, city_styles[k].citizens_graphic);
9120
9121 lsend_packet_ruleset_city(dest, &city_p);
9122 }
9123}
9124
9125/**********************************************************************/
9129 static void send_ruleset_musics(struct conn_list *dest)
9130{
9131 struct packet_ruleset_music packet;
9132
9133 music_styles_iterate(pmus) {
9134 int j;
9135
9136 packet.id = pmus->id;
9137
9138 sz_strlcpy(packet.music_peaceful, pmus->music_peaceful);
9139 sz_strlcpy(packet.music_combat, pmus->music_combat);
9140
9141 j = 0;
9142 requirement_vector_iterate(&(pmus->reqs), preq) {
9143 packet.reqs[j++] = *preq;
9144 } requirement_vector_iterate_end;
9145 packet.reqs_count = j;
9146
9147 lsend_packet_ruleset_music(dest, &packet);
9148 } music_styles_iterate_end;
9149}
9150
9151/**********************************************************************/
9155 static void send_ruleset_game(struct conn_list *dest)
9156{
9157 struct packet_ruleset_game misc_p;
9158 int i;
9159
9160 fc_assert_ret(game.veteran != NULL);
9161
9162 /* Per unit veteran system definition. */
9163 misc_p.veteran_levels = game.veteran->levels;
9164
9165 for (i = 0; i < misc_p.veteran_levels; i++) {
9166 const struct veteran_level *vlevel = game.veteran->definitions + i;
9167
9168 sz_strlcpy(misc_p.veteran_name[i], untranslated_name(&vlevel->name));
9169 misc_p.power_fact[i] = vlevel->power_fact;
9170 misc_p.move_bonus[i] = vlevel->move_bonus;
9171 misc_p.base_raise_chance[i] = vlevel->base_raise_chance;
9172 misc_p.work_raise_chance[i] = vlevel->work_raise_chance;
9173 }
9174
9175 fc_assert(sizeof(misc_p.global_init_techs)
9176 == sizeof(game.rgame.global_init_techs));
9177 fc_assert(ARRAY_SIZE(misc_p.global_init_techs)
9178 == ARRAY_SIZE(game.rgame.global_init_techs));
9179 for (i = 0; i < MAX_NUM_TECH_LIST; i++) {
9180 if (game.rgame.global_init_techs[i] != A_LAST) {
9181 misc_p.global_init_techs[i] = game.rgame.global_init_techs[i];
9182 } else {
9183 break;
9184 }
9185 }
9186 misc_p.global_init_techs_count = i;
9187
9188 fc_assert(ARRAY_SIZE(misc_p.global_init_buildings)
9189 == ARRAY_SIZE(game.rgame.global_init_buildings));
9190 for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) {
9191 if (game.rgame.global_init_buildings[i] != B_LAST) {
9192 /* Impr_type_id to int */
9193 misc_p.global_init_buildings[i] =
9194 game.rgame.global_init_buildings[i];
9195 } else {
9196 break;
9197 }
9198 }
9199 misc_p.global_init_buildings_count = i;
9200
9201 misc_p.default_specialist = DEFAULT_SPECIALIST;
9202
9203 fc_assert_ret(game.plr_bg_color != NULL);
9204
9205 misc_p.background_red = game.plr_bg_color->r;
9206 misc_p.background_green = game.plr_bg_color->g;
9207 misc_p.background_blue = game.plr_bg_color->b;
9208
9209 lsend_packet_ruleset_game(dest, &misc_p);
9210}
9211
9212/**********************************************************************/
9216 static void send_ruleset_team_names(struct conn_list *dest)
9217{
9218 struct packet_team_name_info team_name_info_p;
9219
9220 team_slots_iterate(tslot) {
9221 const char *name = team_slot_defined_name(tslot);
9222
9223 if (NULL == name) {
9224 /* End of defined names. */
9225 break;
9226 }
9227
9228 team_name_info_p.team_id = team_slot_index(tslot);
9229 sz_strlcpy(team_name_info_p.team_name, name);
9230
9231 lsend_packet_team_name_info(dest, &team_name_info_p);
9232 } team_slots_iterate_end;
9233}
9234
9235/**********************************************************************/
9238 static void notify_ruleset_fallback(const char *msg)
9239{
9240 notify_conn(NULL, NULL, E_LOG_FATAL, ftc_warning, "%s", msg);
9241}
9242
9243/**********************************************************************/
9246 bool load_rulesets(const char *restore, const char *alt, bool compat_mode,
9247 rs_conversion_logger logger,
9248 bool act, bool buffer_script, bool load_luadata)
9249{
9250 set_ruleset_compat_mode(compat_mode);
9251
9252 if (load_rulesetdir(game.server.rulesetdir, compat_mode, logger,
9253 act, buffer_script, load_luadata)) {
9254 set_ruleset_compat_mode(FALSE);
9255 return TRUE;
9256 }
9257
9258 if (alt != NULL) {
9259 if (load_rulesetdir(alt, compat_mode, logger, act, buffer_script,
9260 load_luadata)) {
9261 sz_strlcpy(game.server.rulesetdir, alt);
9262
9263 set_ruleset_compat_mode(FALSE);
9264 return TRUE;
9265 }
9266 }
9267
9268 /* Fallback to previous one. */
9269 if (restore != NULL) {
9270 if (load_rulesetdir(restore, compat_mode, logger, act, buffer_script, TRUE)) {
9271 sz_strlcpy(game.server.rulesetdir, restore);
9272
9273 notify_ruleset_fallback(_("Ruleset couldn't be loaded. Keeping previous one."));
9274
9275 set_ruleset_compat_mode(FALSE);
9276
9277 set_ruleset_compat_mode(FALSE);
9278
9279 /* We're in sane state as restoring previous ruleset succeeded,
9280 * but return failure to indicate that this is not what caller
9281 * wanted. */
9282 return FALSE;
9283 }
9284 }
9285
9286 set_ruleset_compat_mode(FALSE);
9287
9288 set_ruleset_compat_mode(FALSE);
9289
9290 /* Fallback to default one, but not if that's what we tried already */
9291 if (strcmp(GAME_DEFAULT_RULESETDIR, game.server.rulesetdir)
9292 && (restore == NULL || strcmp(GAME_DEFAULT_RULESETDIR, restore))) {
9293 if (load_rulesetdir(GAME_DEFAULT_RULESETDIR, FALSE, NULL, act, buffer_script, TRUE)) {
9294 /* We're in sane state as fallback ruleset loading succeeded,
9295 * but return failure to indicate that this is not what caller
9296 * wanted. */
9297 sz_strlcpy(game.server.rulesetdir, GAME_DEFAULT_RULESETDIR);
9298
9299 notify_ruleset_fallback(_("Ruleset couldn't be loaded. Switching to default one."));
9300
9301 return FALSE;
9302 }
9303 }
9304
9305#ifdef FREECIV_WEB
9306 log_normal(_("Cannot load any ruleset. Freeciv-web ruleset is available from "
9307 "https://github.com/freeciv/freeciv-web"));
9308#endif /* FREECIV_WEB */
9309
9310 /* Cannot load even default ruleset, we're in completely unusable state */
9311 exit(EXIT_FAILURE);
9312
9313 RETURN_VALUE_AFTER_EXIT(FALSE);
9314}
9315
9316/**********************************************************************/
9319 static void nullcheck_secfile_destroy(struct section_file *file)
9320{
9321 if (file != NULL) {
9322 secfile_destroy(file);
9323 }
9324}
9325
9326/**********************************************************************/
9330 void rulesets_deinit(void)
9331{
9332 script_server_free();
9333 requirement_vector_free(&reqs_list);
9334}
9335
9336/**********************************************************************/
9340 static bool load_rulesetdir(const char *rsdir, bool compat_mode,
9341 rs_conversion_logger logger,
9342 bool act, bool buffer_script, bool load_luadata)
9343{
9344 struct section_file *techfile, *unitfile, *buildfile, *govfile, *terrfile;
9345 struct section_file *stylefile, *cityfile, *nationfile, *effectfile, *gamefile;
9346 bool ok = TRUE;
9347 struct rscompat_info compat_info;
9348
9349 log_normal(_("Loading rulesets."));
9350
9351 rscompat_init_info(&compat_info);
9352 compat_info.compat_mode = compat_mode;
9353 compat_info.log_cb = logger;
9354
9355 game_ruleset_free();
9356 /* Reset the list of available player colors. */
9357 playercolor_free();
9358 playercolor_init();
9359 game_ruleset_init();
9360
9361 if (script_buffer != NULL) {
9362 FC_FREE(script_buffer);
9363 script_buffer = NULL;
9364 }
9365 if (parser_buffer != NULL) {
9366 FC_FREE(parser_buffer);
9367 parser_buffer = NULL;
9368 }
9369
9370 server.playable_nations = 0;
9371
9372 techfile = openload_ruleset_file("techs", rsdir);
9373 buildfile = openload_ruleset_file("buildings", rsdir);
9374 govfile = openload_ruleset_file("governments", rsdir);
9375 unitfile = openload_ruleset_file("units", rsdir);
9376 terrfile = openload_ruleset_file("terrain", rsdir);
9377 stylefile = openload_ruleset_file("styles", rsdir);
9378 cityfile = openload_ruleset_file("cities", rsdir);
9379 nationfile = openload_ruleset_file("nations", rsdir);
9380 effectfile = openload_ruleset_file("effects", rsdir);
9381 gamefile = openload_ruleset_file("game", rsdir);
9382 if (load_luadata) {
9383 game.server.luadata = openload_luadata_file(rsdir);
9384 } else {
9385 game.server.luadata = NULL;
9386 }
9387
9388 if (techfile == NULL
9389 || buildfile == NULL
9390 || govfile == NULL
9391 || unitfile == NULL
9392 || terrfile == NULL
9393 || stylefile == NULL
9394 || cityfile == NULL
9395 || nationfile == NULL
9396 || effectfile == NULL
9397 || gamefile == NULL) {
9398 ok = FALSE;
9399 }
9400
9401 if (ok) {
9402 /* Note: Keep load_game_names first so that compat_info.version is
9403 * correctly initialized. */
9404 ok = load_game_names(gamefile, &compat_info)
9405 && load_tech_names(techfile, &compat_info)
9406 && load_building_names(buildfile, &compat_info)
9407 && load_government_names(govfile, &compat_info)
9408 && load_unit_names(unitfile, &compat_info)
9409 && load_terrain_names(terrfile, &compat_info)
9410 && load_style_names(stylefile, &compat_info)
9411 && load_nation_names(nationfile, &compat_info);
9412 }
9413
9414 if (ok) {
9415 ok = rscompat_names(&compat_info);
9416 }
9417
9418 if (ok) {
9419 ok = load_ruleset_techs(techfile, &compat_info);
9420 }
9421 if (ok) {
9422 ok = load_ruleset_styles(stylefile, &compat_info);
9423 }
9424 if (ok) {
9425 ok = load_ruleset_cities(cityfile, &compat_info);
9426 }
9427 if (ok) {
9428 ok = load_ruleset_governments(govfile, &compat_info);
9429 }
9430 if (ok) {
9431 /* terrain must precede nations and units */
9432 ok = load_ruleset_terrain(terrfile, &compat_info);
9433 }
9434 if (ok) {
9435 ok = load_ruleset_units(unitfile, &compat_info);
9436 }
9437 if (ok) {
9438 ok = load_ruleset_buildings(buildfile, &compat_info);
9439 }
9440 if (ok) {
9441 ok = load_ruleset_nations(nationfile, &compat_info);
9442 }
9443 if (ok) {
9444 ok = load_ruleset_effects(effectfile, &compat_info);
9445 }
9446 if (ok) {
9447 ok = load_ruleset_game(gamefile, act, &compat_info);
9448 }
9449
9450 if (ok) {
9451 rscompat_adjust_pre_sanity(&compat_info);
9452
9453 /* Init nations we just loaded. */
9454 update_nations_with_startpos();
9455
9456 /* Needed by role_unit_precalcs(). */
9457 unit_type_action_cache_init();
9458
9459 /* Prepare caches we want to sanity check. */
9460 role_unit_precalcs();
9461 road_integrators_cache_init();
9462 actions_rs_pre_san_gen();
9463
9464 ok = autoadjust_ruleset_data()
9465 && sanity_check_ruleset_data(&compat_info);
9466 }
9467
9468 if (ok) {
9469 /* Only load settings for a sane ruleset */
9470 ok = settings_ruleset(gamefile, "settings", act);
9471
9472 if (ok) {
9473 secfile_check_unused(gamefile);
9474 }
9475 }
9476
9477 nullcheck_secfile_destroy(techfile);
9478 nullcheck_secfile_destroy(stylefile);
9479 nullcheck_secfile_destroy(cityfile);
9480 nullcheck_secfile_destroy(govfile);
9481 nullcheck_secfile_destroy(terrfile);
9482 nullcheck_secfile_destroy(unitfile);
9483 nullcheck_secfile_destroy(buildfile);
9484 nullcheck_secfile_destroy(nationfile);
9485 nullcheck_secfile_destroy(effectfile);
9486 nullcheck_secfile_destroy(gamefile);
9487
9488 if (extra_sections) {
9489 free(extra_sections);
9490 extra_sections = NULL;
9491 }
9492 if (base_sections) {
9493 free(base_sections);
9494 base_sections = NULL;
9495 }
9496 if (road_sections) {
9497 free(road_sections);
9498 road_sections = NULL;
9499 }
9500 if (resource_sections) {
9501 free(resource_sections);
9502 resource_sections = NULL;
9503 }
9504 if (terrain_sections) {
9505 free(terrain_sections);
9506 terrain_sections = NULL;
9507 }
9508
9509 if (ok) {
9510 rscompat_postprocess(&compat_info);
9511 }
9512
9513 if (ok) {
9514 char **buffer = buffer_script ? &script_buffer : NULL;
9515
9516 script_server_free();
9517
9518 script_server_init();
9519
9520 ok = (openload_script_file("script", rsdir, buffer, FALSE) == TRI_YES);
9521 }
9522
9523 if (ok) {
9524 enum fc_tristate pret;
9525 char **buffer = buffer_script ? &parser_buffer : NULL;
9526
9527 pret = openload_script_file("parser", rsdir, buffer, compat_info.compat_mode);
9528
9529 if (pret == TRI_MAYBE && buffer_script) {
9530 parser_buffer = fc_strdup(
9531 "-- This file is for lua-functionality for parsing luadata.txt\n-- of this ruleset.");
9532 }
9533
9534 ok = (pret != TRI_NO);
9535 }
9536
9537 if (ok && !buffer_script) {
9538 ok = (openload_script_file("default", rsdir, NULL, FALSE) == TRI_YES);
9539 }
9540
9541 if (ok && act) {
9542 /* Populate remaining caches. */
9543 techs_precalc_data();
9544 improvement_feature_cache_init();
9545 unit_class_iterate(pclass) {
9546 set_unit_class_caches(pclass);
9547 } unit_class_iterate_end;
9548 unit_type_iterate(ptype) {
9549 ptype->unknown_move_cost = utype_unknown_move_cost(ptype);
9550 set_unit_type_caches(ptype);
9551 } unit_type_iterate_end;
9552 city_production_caravan_shields_init();
9553
9554 /* Build advisors unit class cache corresponding to loaded rulesets */
9555 adv_units_ruleset_init();
9556 CALL_FUNC_EACH_AI(units_ruleset_init);
9557
9558 /* We may need to adjust the number of AI players
9559 * if the number of available nations changed. */
9560 (void) aifill(game.info.aifill);
9561 }
9562
9563 return ok;
9564}
9565
9566/**********************************************************************/
9569 bool reload_rulesets_settings(void)
9570{
9571 struct section_file *file;
9572 bool ok = TRUE;
9573
9574 file = openload_ruleset_file("game", game.server.rulesetdir);
9575 if (file == NULL) {
9576 ruleset_error(NULL, LOG_ERROR,
9577 "Could not load game.ruleset:\n%s",
9578 secfile_error());
9579 ok = FALSE;
9580 }
9581 if (ok) {
9582 settings_ruleset(file, "settings", TRUE);
9583 secfile_destroy(file);
9584 }
9585
9586 return ok;
9587}
9588
9589/**********************************************************************/
9592 void send_rulesets(struct conn_list *dest)
9593{
9594 conn_list_compression_freeze(dest);
9595
9596 /* ruleset_control also indicates to client that ruleset sending starts. */
9597 send_ruleset_control(dest);
9598
9599 /* Currently containing control-kind of data of nation sets and groups,
9600 * this too must be sent before any requirement vector may depend on
9601 * that data. */
9602 send_ruleset_nations(dest);
9603
9604 send_ruleset_game(dest);
9605 send_ruleset_disasters(dest);
9606 send_ruleset_achievements(dest);
9607 send_ruleset_trade_routes(dest);
9608 send_ruleset_team_names(dest);
9609 send_ruleset_actions(dest);
9610 send_ruleset_action_enablers(dest);
9611 send_ruleset_action_auto_performers(dest);
9612 send_ruleset_tech_classes(dest);
9613 send_ruleset_techs(dest);
9614 send_ruleset_governments(dest);
9615 send_ruleset_unit_classes(dest);
9616 send_ruleset_units(dest);
9617 send_ruleset_specialists(dest);
9618 send_ruleset_extras(dest);
9619 send_ruleset_bases(dest);
9620 send_ruleset_roads(dest);
9621 send_ruleset_resources(dest);
9622 send_ruleset_terrain(dest);
9623 send_ruleset_goods(dest);
9624 send_ruleset_buildings(dest);
9625 send_ruleset_styles(dest);
9626 send_ruleset_clauses(dest);
9627 send_ruleset_cities(dest);
9628 send_ruleset_multipliers(dest);
9629 send_ruleset_musics(dest);
9630 send_ruleset_cache(dest);
9631
9632 /* Indicate client that all rulesets have now been sent. */
9633 lsend_packet_rulesets_ready(dest);
9634
9635 /* changed game settings will be send in
9636 * connecthand.c:establish_new_connection() */
9637
9638 conn_list_compression_thaw(dest);
9639}
achievement_index
int achievement_index(const struct achievement *pach)
Definition achievements.c:86
achievement_number
int achievement_number(const struct achievement *pach)
Definition achievements.c:76
achievements.h
achievements_iterate_end
#define achievements_iterate_end
Definition achievements.h:70
achievements_iterate
#define achievements_iterate(_ach_)
Definition achievements.h:64
action_auto_perf_slot_number
struct action_auto_perf * action_auto_perf_slot_number(const int num)
Definition actions.c:7353
actions_rs_pre_san_gen
void actions_rs_pre_san_gen(void)
Definition actions.c:1520
action_min_range_ruleset_var_name
const char * action_min_range_ruleset_var_name(int act)
Definition actions.c:7966
action_blocked_by_ruleset_var_name
const char * action_blocked_by_ruleset_var_name(const struct action *act)
Definition actions.c:9034
action_is_in_use
bool action_is_in_use(struct action *paction)
Definition actions.c:7330
action_post_success_forced_ruleset_var_name
const char * action_post_success_forced_ruleset_var_name(const struct action *act)
Definition actions.c:9176
action_by_rule_name
struct action * action_by_rule_name(const char *name)
Definition actions.c:1708
action_rule_name
const char * action_rule_name(const struct action *action)
Definition actions.c:1876
action_actor_consuming_always_ruleset_var_name
const char * action_actor_consuming_always_ruleset_var_name(action_id act)
Definition actions.c:8899
action_max_range_ruleset_var_name
const char * action_max_range_ruleset_var_name(int act)
Definition actions.c:8177
action_target_kind_default
enum action_target_kind action_target_kind_default(enum action_result result)
Definition actions.c:8528
action_min_range_default
int action_min_range_default(enum action_result result)
Definition actions.c:8095
action_target_kind_ruleset_var_name
const char * action_target_kind_ruleset_var_name(int act)
Definition actions.c:8398
action_enabler_add
void action_enabler_add(struct action_enabler *enabler)
Definition actions.c:2442
action_ui_name_default
const char * action_ui_name_default(int act)
Definition actions.c:7664
action_enabler_new
struct action_enabler * action_enabler_new(void)
Definition actions.c:2396
action_enabler_possible_actor
bool action_enabler_possible_actor(const struct action_enabler *ae)
Definition actions.c:7274
action_enablers_for_action
struct action_enabler_list * action_enablers_for_action(action_id action)
Definition actions.c:2475
action_ui_name_ruleset_var_name
const char * action_ui_name_ruleset_var_name(int act)
Definition actions.c:7438
action_max_range_default
int action_max_range_default(enum action_result result)
Definition actions.c:8312
actions.h
action_by_result_iterate
#define action_by_result_iterate(_paction_, _result_)
Definition actions.h:488
action_auto_perf_iterate_end
#define action_auto_perf_iterate_end
Definition actions.h:593
action_enablers_iterate_end
#define action_enablers_iterate_end
Definition actions.h:526
ACTION_AUTO_MOVED_ADJ
#define ACTION_AUTO_MOVED_ADJ
Definition actions.h:617
action_id_get_sub_target_kind
#define action_id_get_sub_target_kind(act_id)
Definition actions.h:659
ACTION_AUTO_UPKEEP_GOLD
#define ACTION_AUTO_UPKEEP_GOLD
Definition actions.h:615
action_by_number
static struct action * action_by_number(action_id act_id)
Definition actions.h:638
NUM_ACTIONS
#define NUM_ACTIONS
Definition actions.h:297
ACTION_AUTO_ESCAPE_STACK
#define ACTION_AUTO_ESCAPE_STACK
Definition actions.h:621
action_has_result
#define action_has_result(_act_, _res_)
Definition actions.h:448
ACTION_AUTO_ESCAPE_CITY
#define ACTION_AUTO_ESCAPE_CITY
Definition actions.h:620
action_enabler_list_iterate_end
#define action_enabler_list_iterate_end
Definition actions.h:457
ACTION_DISTANCE_UNLIMITED
#define ACTION_DISTANCE_UNLIMITED
Definition actions.h:352
action_by_result_iterate_end
#define action_by_result_iterate_end
Definition actions.h:492
ACTION_AUTO_UPKEEP_SHIELD
#define ACTION_AUTO_UPKEEP_SHIELD
Definition actions.h:616
ACTION_AUTO_POST_BRIBE
#define ACTION_AUTO_POST_BRIBE
Definition actions.h:618
action_iterate_end
#define action_iterate_end
Definition actions.h:472
action_enablers_iterate
#define action_enablers_iterate(_enabler_)
Definition actions.h:520
action_enabler_list_iterate
#define action_enabler_list_iterate(action_enabler_list, aenabler)
Definition actions.h:455
action_iterate
#define action_iterate(_act_)
Definition actions.h:467
action_auto_perf_iterate
#define action_auto_perf_iterate(_act_perf_)
Definition actions.h:581
ACTION_AUTO_UPKEEP_FOOD
#define ACTION_AUTO_UPKEEP_FOOD
Definition actions.h:614
ACTION_AUTO_POST_ATTACK
#define ACTION_AUTO_POST_ATTACK
Definition actions.h:619
ACTION_NONE
#define ACTION_NONE
Definition actions.h:293
adv_units_ruleset_init
void adv_units_ruleset_init(void)
Definition advruleset.c:33
advruleset.h
ai.h
CALL_FUNC_EACH_AI
#define CALL_FUNC_EACH_AI(_func,...)
Definition ai.h:384
str
#define str
Definition astring.c:76
n
#define n
Definition astring.c:77
base_number
Base_type_id base_number(const struct base_type *pbase)
Definition base.c:92
base_type_init
void base_type_init(struct extra_type *pextra, int idx)
Definition base.c:117
territory_claiming_base
bool territory_claiming_base(const struct base_type *pbase)
Definition base.c:158
base.h
bitvector.h
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
capability.h
city_styles
struct citystyle * city_styles
Definition city.c:79
city_styles_alloc
void city_styles_alloc(int num)
Definition city.c:3305
city_production_caravan_shields_init
void city_production_caravan_shields_init(void)
Definition city.c:1747
city_style_rule_name
const char * city_style_rule_name(const int style)
Definition city.c:1734
get_output_identifier
const char * get_output_identifier(Output_type_id output)
Definition city.c:614
city.h
output_type_iterate
#define output_type_iterate(output)
Definition city.h:812
output_type_iterate_end
#define output_type_iterate_end
Definition city.h:818
citytools.h
list
static struct fc_sockaddr_list * list
Definition clinet.c:102
conn_list_compression_thaw
void conn_list_compression_thaw(const struct conn_list *pconn_list)
Definition connection.c:729
conn_list_compression_freeze
void conn_list_compression_freeze(const struct conn_list *pconn_list)
Definition connection.c:717
MAX_LEN_CONTENT
#define MAX_LEN_CONTENT
Definition connection.h:59
deprecations.h
log_deprecation
#define log_deprecation(message,...)
Definition deprecations.h:35
clause_info_get
struct clause_info * clause_info_get(enum clause_type type)
Definition diptreaty.c:273
disaster_rule_name
const char * disaster_rule_name(struct disaster_type *pdis)
Definition disaster.c:105
disaster_number
Disaster_type_id disaster_number(const struct disaster_type *pdis)
Definition disaster.c:56
disaster_index
Disaster_type_id disaster_index(const struct disaster_type *pdis)
Definition disaster.c:69
disaster_type_iterate
#define disaster_type_iterate(_p)
Definition disaster.h:80
disaster_type_iterate_end
#define disaster_type_iterate_end
Definition disaster.h:86
id
int int id
Definition editgui_g.h:28
reqs
struct @21::@22 reqs
send_ruleset_cache
void send_ruleset_cache(struct conn_list *dest)
Definition effects.c:553
effect_new
struct effect * effect_new(enum effect_type type, int value, struct multiplier *pmul)
Definition effects.c:179
get_effects
struct effect_list * get_effects(enum effect_type effect_type)
Definition effects.c:136
effect_req_append
void effect_req_append(struct effect *peffect, struct requirement req)
Definition effects.c:229
effects.h
effect_list_iterate_end
#define effect_list_iterate_end
Definition effects.h:375
effect_list_iterate
#define effect_list_iterate(effect_list, peffect)
Definition effects.h:373
extra_type_by_rule_name
struct extra_type * extra_type_by_rule_name(const char *name)
Definition extras.c:204
extra_flag_helptxt
const char * extra_flag_helptxt(enum extra_flag_id id)
Definition extras.c:923
set_user_extra_flag_name
void set_user_extra_flag_name(enum extra_flag_id id, const char *name, const char *helptxt)
Definition extras.c:882
is_extra_caused_by_worker_action
bool is_extra_caused_by_worker_action(const struct extra_type *pextra)
Definition extras.c:981
extra_number
int extra_number(const struct extra_type *pextra)
Definition extras.c:153
extra_has_flag
bool extra_has_flag(const struct extra_type *pextra, enum extra_flag_id flag)
Definition extras.c:810
extra_type_list_by_cause
struct extra_type_list * extra_type_list_by_cause(enum extra_cause cause)
Definition extras.c:241
extra_to_caused_by_list
void extra_to_caused_by_list(struct extra_type *pextra, enum extra_cause cause)
Definition extras.c:296
extra_by_number
struct extra_type * extra_by_number(int id)
Definition extras.c:175
extra_to_removed_by_list
void extra_to_removed_by_list(struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:316
extra_type_list_of_terr_claimers
struct extra_type_list * extra_type_list_of_terr_claimers(void)
Definition extras.c:259
extra_rule_name
const char * extra_rule_name(const struct extra_type *pextra)
Definition extras.c:195
is_extra_removed_by
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:327
extra_type_list_of_unit_hiders
struct extra_type_list * extra_type_list_of_unit_hiders(void)
Definition extras.c:251
extras.h
extra_type_iterate
#define extra_type_iterate(_p)
Definition extras.h:291
extra_type_iterate_end
#define extra_type_iterate_end
Definition extras.h:297
is_extra_caused_by
#define is_extra_caused_by(e, c)
Definition extras.h:196
extra_index
#define extra_index(_e_)
Definition extras.h:177
extra_base_get
#define extra_base_get(_e_)
Definition extras.h:184
extra_road_get
#define extra_road_get(_e_)
Definition extras.h:185
extra_type_by_cause_iterate_end
#define extra_type_by_cause_iterate_end
Definition extras.h:315
MAX_NUM_USER_EXTRA_FLAGS
#define MAX_NUM_USER_EXTRA_FLAGS
Definition extras.h:80
extra_type_by_cause_iterate
#define extra_type_by_cause_iterate(_cause, _extra)
Definition extras.h:309
fc_types.h
MAX_DISASTER_TYPES
#define MAX_DISASTER_TYPES
Definition fc_types.h:52
MAX_VET_LEVELS
#define MAX_VET_LEVELS
Definition fc_types.h:49
ROCO_RAILROAD
@ ROCO_RAILROAD
Definition fc_types.h:1105
ROCO_NONE
@ ROCO_NONE
Definition fc_types.h:1105
ROCO_RIVER
@ ROCO_RIVER
Definition fc_types.h:1105
ROCO_ROAD
@ ROCO_ROAD
Definition fc_types.h:1105
MAX_GRANARY_INIS
#define MAX_GRANARY_INIS
Definition fc_types.h:72
MAX_NUM_NATIONS
#define MAX_NUM_NATIONS
Definition fc_types.h:60
MAX_NUM_BUILDING_LIST
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
MAX_NUM_REQS
#define MAX_NUM_REQS
Definition fc_types.h:380
MAX_GOODS_TYPES
#define MAX_GOODS_TYPES
Definition fc_types.h:51
EC_NATURAL_DEFENSIVE
#define EC_NATURAL_DEFENSIVE
Definition fc_types.h:970
EC_SPECIAL
#define EC_SPECIAL
Definition fc_types.h:968
action_id
int action_id
Definition fc_types.h:359
SP_MAX
#define SP_MAX
Definition fc_types.h:379
EC_NONE
#define EC_NONE
Definition fc_types.h:967
EC_NOT_AGGRESSIVE
#define EC_NOT_AGGRESSIVE
Definition fc_types.h:971
EC_DEFENSIVE
#define EC_DEFENSIVE
Definition fc_types.h:969
MAX_CALENDAR_FRAGMENTS
#define MAX_CALENDAR_FRAGMENTS
Definition fc_types.h:62
MAX_NUM_TECH_CLASSES
#define MAX_NUM_TECH_CLASSES
Definition fc_types.h:63
MAX_NUM_LEADERS
#define MAX_NUM_LEADERS
Definition fc_types.h:56
MAX_NUM_MULTIPLIERS
#define MAX_NUM_MULTIPLIERS
Definition fc_types.h:55
MAX_NUM_UNIT_LIST
#define MAX_NUM_UNIT_LIST
Definition fc_types.h:45
MAX_EXTRA_TYPES
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
MAX_ACHIEVEMENT_TYPES
#define MAX_ACHIEVEMENT_TYPES
Definition fc_types.h:53
MAX_LEN_NAME
#define MAX_LEN_NAME
Definition fc_types.h:66
MAX_NUM_TECH_LIST
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
MAX_LEN_CITYNAME
#define MAX_LEN_CITYNAME
Definition fc_types.h:67
UCL_LAST
#define UCL_LAST
Definition fc_types.h:387
fcintl.h
Q_
#define Q_(String)
Definition fcintl.h:70
_
#define _(String)
Definition fcintl.h:67
Qn_
#define Qn_(String)
Definition fcintl.h:89
N_
#define N_(String)
Definition fcintl.h:69
ftc_warning
const struct ft_color ftc_warning
Definition featured_text.c:75
featured_text.h
game
struct civ_game game
Definition game.c:57
game_ruleset_init
void game_ruleset_init(void)
Definition game.c:499
game_ruleset_free
void game_ruleset_free(void)
Definition game.c:544
wld
struct world wld
Definition game.c:58
game.h
RS_DEFAULT_RANSOM_GOLD
#define RS_DEFAULT_RANSOM_GOLD
Definition game.h:840
RS_DEFAULT_GRANARY_FOOD_INI
#define RS_DEFAULT_GRANARY_FOOD_INI
Definition game.h:789
RS_DEFAULT_CIVIL_WAR_UNHAPPY
#define RS_DEFAULT_CIVIL_WAR_UNHAPPY
Definition game.h:826
RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
#define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:832
RS_MIN_BORDER_RADIUS_SQ_CITY_PERMANENT
#define RS_MIN_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:770
RS_MAX_TECH_UPKEEP_DIVIDER
#define RS_MAX_TECH_UPKEEP_DIVIDER
Definition game.h:852
RS_MIN_ILLNESS_POLLUTION_PCT
#define RS_MIN_ILLNESS_POLLUTION_PCT
Definition game.h:756
RS_DEFAULT_NUKE_POP_LOSS_PCT
#define RS_DEFAULT_NUKE_POP_LOSS_PCT
Definition game.h:829
RS_MAX_BORDER_RADIUS_SQ_CITY
#define RS_MAX_BORDER_RADIUS_SQ_CITY
Definition game.h:763
RS_DEFAULT_BASE_POLLUTION
#define RS_DEFAULT_BASE_POLLUTION
Definition game.h:812
RS_MIN_ILLNESS_TRADE_INFECTION_PCT
#define RS_MIN_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:752
RS_MAX_ILLNESS_BASE_FACTOR
#define RS_MAX_ILLNESS_BASE_FACTOR
Definition game.h:745
RS_DEFAULT_INCITE_TOTAL_FCT
#define RS_DEFAULT_INCITE_TOTAL_FCT
Definition game.h:785
RS_DEFAULT_ILLNESS_BASE_FACTOR
#define RS_DEFAULT_ILLNESS_BASE_FACTOR
Definition game.h:743
RS_DEFAULT_NEG_YEAR_LABEL
#define RS_DEFAULT_NEG_YEAR_LABEL
Definition game.h:739
RS_MIN_NUKE_POP_LOSS_PCT
#define RS_MIN_NUKE_POP_LOSS_PCT
Definition game.h:830
RS_MIN_INCITE_IMPROVEMENT_FCT
#define RS_MIN_INCITE_IMPROVEMENT_FCT
Definition game.h:778
RS_MIN_FOOD_COST
#define RS_MIN_FOOD_COST
Definition game.h:822
RS_MIN_BASE_BRIBE_COST
#define RS_MIN_BASE_BRIBE_COST
Definition game.h:837
RS_MAX_NUKE_POP_LOSS_PCT
#define RS_MAX_NUKE_POP_LOSS_PCT
Definition game.h:831
RS_DEFAULT_INCITE_IMPROVEMENT_FCT
#define RS_DEFAULT_INCITE_IMPROVEMENT_FCT
Definition game.h:777
RS_MAX_INCITE_IMPROVEMENT_FCT
#define RS_MAX_INCITE_IMPROVEMENT_FCT
Definition game.h:779
RS_MIN_RANSOM_GOLD
#define RS_MIN_RANSOM_GOLD
Definition game.h:841
RS_ACTION_NO_MAX_DISTANCE
#define RS_ACTION_NO_MAX_DISTANCE
Definition game.h:866
RS_DEFAULT_BASE_BRIBE_COST
#define RS_DEFAULT_BASE_BRIBE_COST
Definition game.h:836
RS_MAX_INCITE_BASE_COST
#define RS_MAX_INCITE_BASE_COST
Definition game.h:775
RS_DEFAULT_TECH_UPKEEP_DIVIDER
#define RS_DEFAULT_TECH_UPKEEP_DIVIDER
Definition game.h:850
RS_DEFAULT_HAPPY_COST
#define RS_DEFAULT_HAPPY_COST
Definition game.h:817
RS_MIN_UPGRADE_VETERAN_LOSS
#define RS_MIN_UPGRADE_VETERAN_LOSS
Definition game.h:847
RS_MIN_ILLNESS_MIN_SIZE
#define RS_MIN_ILLNESS_MIN_SIZE
Definition game.h:748
RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK
Definition game.h:858
RS_DEFAULT_GRANARY_FOOD_INC
#define RS_DEFAULT_GRANARY_FOOD_INC
Definition game.h:791
RS_DEFAULT_ILLNESS_ON
#define RS_DEFAULT_ILLNESS_ON
Definition game.h:741
RS_MAX_FOOD_COST
#define RS_MAX_FOOD_COST
Definition game.h:823
RS_MAX_HAPPY_COST
#define RS_MAX_HAPPY_COST
Definition game.h:819
GAME_DEFAULT_CELEBRATESIZE
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:480
RS_MIN_ILLNESS_BASE_FACTOR
#define RS_MIN_ILLNESS_BASE_FACTOR
Definition game.h:744
RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
#define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES
Definition game.h:859
RS_MIN_TECH_UPKEEP_DIVIDER
#define RS_MIN_TECH_UPKEEP_DIVIDER
Definition game.h:851
RS_MAX_RANSOM_GOLD
#define RS_MAX_RANSOM_GOLD
Definition game.h:842
RS_MIN_HAPPY_COST
#define RS_MIN_HAPPY_COST
Definition game.h:818
RS_MIN_BORDER_RADIUS_SQ_CITY
#define RS_MIN_BORDER_RADIUS_SQ_CITY
Definition game.h:762
GAME_DEFAULT_RULESETDIR
#define GAME_DEFAULT_RULESETDIR
Definition game.h:654
RS_DEFAULT_CIVIL_WAR_CELEB
#define RS_DEFAULT_CIVIL_WAR_CELEB
Definition game.h:825
RS_MAX_BASE_TECH_COST
#define RS_MAX_BASE_TECH_COST
Definition game.h:856
RS_DEFAULT_BASE_TECH_COST
#define RS_DEFAULT_BASE_TECH_COST
Definition game.h:854
RS_MIN_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
#define RS_MIN_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:833
RS_MAX_BORDER_RADIUS_SQ_CITY_PERMANENT
#define RS_MAX_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:771
RS_DEFAULT_UPGRADE_VETERAN_LOSS
#define RS_DEFAULT_UPGRADE_VETERAN_LOSS
Definition game.h:846
RS_MAX_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
#define RS_MAX_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT
Definition game.h:834
RS_MAX_INCITE_UNIT_FCT
#define RS_MAX_INCITE_UNIT_FCT
Definition game.h:783
RS_MIN_VIS_RADIUS_SQ
#define RS_MIN_VIS_RADIUS_SQ
Definition game.h:809
RS_DEFAULT_CALENDAR_SKIP_0
#define RS_DEFAULT_CALENDAR_SKIP_0
Definition game.h:759
RS_MAX_ILLNESS_MIN_SIZE
#define RS_MAX_ILLNESS_MIN_SIZE
Definition game.h:749
RS_DEFAULT_CITY_RADIUS_SQ
#define RS_DEFAULT_CITY_RADIUS_SQ
Definition game.h:804
GAME_DEFAULT_START_YEAR
#define GAME_DEFAULT_START_YEAR
Definition game.h:715
RS_MAX_BORDER_SIZE_EFFECT
#define RS_MAX_BORDER_SIZE_EFFECT
Definition game.h:767
RS_DEFAULT_BORDER_SIZE_EFFECT
#define RS_DEFAULT_BORDER_SIZE_EFFECT
Definition game.h:765
RS_MAX_BASE_BRIBE_COST
#define RS_MAX_BASE_BRIBE_COST
Definition game.h:838
RS_MIN_INCITE_BASE_COST
#define RS_MIN_INCITE_BASE_COST
Definition game.h:774
RS_DEFAULT_PILLAGE_SELECT
#define RS_DEFAULT_PILLAGE_SELECT
Definition game.h:844
RS_MIN_CITY_RADIUS_SQ
#define RS_MIN_CITY_RADIUS_SQ
Definition game.h:805
RS_MIN_CITY_CENTER_OUTPUT
#define RS_MIN_CITY_CENTER_OUTPUT
Definition game.h:796
RS_MAX_GRANARY_FOOD_INC
#define RS_MAX_GRANARY_FOOD_INC
Definition game.h:793
RS_MAX_CITY_CENTER_OUTPUT
#define RS_MAX_CITY_CENTER_OUTPUT
Definition game.h:797
RS_MAX_CITY_RADIUS_SQ
#define RS_MAX_CITY_RADIUS_SQ
Definition game.h:806
RS_DEFAULT_POS_YEAR_LABEL
#define RS_DEFAULT_POS_YEAR_LABEL
Definition game.h:737
RS_MIN_INCITE_UNIT_FCT
#define RS_MIN_INCITE_UNIT_FCT
Definition game.h:782
RS_MIN_BORDER_SIZE_EFFECT
#define RS_MIN_BORDER_SIZE_EFFECT
Definition game.h:766
RS_DEFAULT_VIS_RADIUS_SQ
#define RS_DEFAULT_VIS_RADIUS_SQ
Definition game.h:808
RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT
Definition game.h:769
RS_DEFAULT_TIRED_ATTACK
#define RS_DEFAULT_TIRED_ATTACK
Definition game.h:828
RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
#define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS
Definition game.h:860
RS_MAX_ILLNESS_POLLUTION_PCT
#define RS_MAX_ILLNESS_POLLUTION_PCT
Definition game.h:757
RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
#define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:751
RS_DEFAULT_FOOD_COST
#define RS_DEFAULT_FOOD_COST
Definition game.h:821
RS_DEFAULT_INCITE_UNIT_FCT
#define RS_DEFAULT_INCITE_UNIT_FCT
Definition game.h:781
RS_MAX_INCITE_TOTAL_FCT
#define RS_MAX_INCITE_TOTAL_FCT
Definition game.h:787
RS_DEFAULT_INCITE_BASE_COST
#define RS_DEFAULT_INCITE_BASE_COST
Definition game.h:773
GAME_DEFAULT_ANGRYCITIZEN
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:371
RS_DEFAULT_CITY_CENTER_OUTPUT
#define RS_DEFAULT_CITY_CENTER_OUTPUT
Definition game.h:795
RS_MIN_INCITE_TOTAL_FCT
#define RS_MIN_INCITE_TOTAL_FCT
Definition game.h:786
RS_DEFAULT_ILLNESS_POLLUTION_PCT
#define RS_DEFAULT_ILLNESS_POLLUTION_PCT
Definition game.h:755
RS_MAX_UPGRADE_VETERAN_LOSS
#define RS_MAX_UPGRADE_VETERAN_LOSS
Definition game.h:848
set_ruleset_compat_mode
static void set_ruleset_compat_mode(bool active)
Definition game.h:332
RS_MAX_VIS_RADIUS_SQ
#define RS_MAX_VIS_RADIUS_SQ
Definition game.h:810
RS_MIN_GRANARY_FOOD_INC
#define RS_MIN_GRANARY_FOOD_INC
Definition game.h:792
RS_MAX_ILLNESS_TRADE_INFECTION_PCT
#define RS_MAX_ILLNESS_TRADE_INFECTION_PCT
Definition game.h:753
RS_DEFAULT_ILLNESS_MIN_SIZE
#define RS_DEFAULT_ILLNESS_MIN_SIZE
Definition game.h:747
RS_MIN_BASE_TECH_COST
#define RS_MIN_BASE_TECH_COST
Definition game.h:855
RS_DEFAULT_BORDER_RADIUS_SQ_CITY
#define RS_DEFAULT_BORDER_RADIUS_SQ_CITY
Definition game.h:761
ruler_title_nation
const struct nation_type * ruler_title_nation(const struct ruler_title *pruler_title)
Definition government.c:364
government_ruler_title_new
struct ruler_title * government_ruler_title_new(struct government *pgovern, const struct nation_type *pnation, const char *ruler_male_title, const char *ruler_female_title)
Definition government.c:324
ruler_title_female_untranslated_name
const char * ruler_title_female_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:382
government_count
Government_type_id government_count(void)
Definition government.c:70
ruler_title_male_untranslated_name
const char * ruler_title_male_untranslated_name(const struct ruler_title *pruler_title)
Definition government.c:373
governments_alloc
void governments_alloc(int num)
Definition government.c:527
government_number
Government_type_id government_number(const struct government *pgovern)
Definition government.c:90
government_ruler_titles
const struct ruler_title_hash * government_ruler_titles(const struct government *pgovern)
Definition government.c:313
government_index
Government_type_id government_index(const struct government *pgovern)
Definition government.c:81
government_rule_name
const char * government_rule_name(const struct government *pgovern)
Definition government.c:132
government_by_rule_name
struct government * government_by_rule_name(const char *name)
Definition government.c:54
government.h
governments_iterate
#define governments_iterate(NAME_pgov)
Definition government.h:120
G_LAST
#define G_LAST
Definition government.h:48
ruler_titles_iterate
#define ruler_titles_iterate(ARG_hash, NAME_rule_title)
Definition government.h:38
ruler_titles_iterate_end
#define ruler_titles_iterate_end
Definition government.h:41
governments_iterate_end
#define governments_iterate_end
Definition government.h:123
title
const char * title
Definition repodlgs.c:1313
type
GType type
Definition repodlgs.c:1312
improvement_by_number
struct impr_type * improvement_by_number(const Impr_type_id id)
Definition improvement.c:192
improvement_number
Impr_type_id improvement_number(const struct impr_type *pimprove)
Definition improvement.c:182
improvement_rule_name
const char * improvement_rule_name(const struct impr_type *pimprove)
Definition improvement.c:250
improvement_feature_cache_init
void improvement_feature_cache_init(void)
Definition improvement.c:90
improvement_by_rule_name
struct impr_type * improvement_by_rule_name(const char *name)
Definition improvement.c:365
improvement_iterate_end
#define improvement_iterate_end
Definition improvement.h:211
improvement_iterate
#define improvement_iterate(_p)
Definition improvement.h:205
B_NEVER
#define B_NEVER
Definition improvement.h:44
B_LAST
#define B_LAST
Definition improvement.h:42
name
const char * name
Definition inputfile.c:127
vdo_log
void vdo_log(const char *file, const char *function, int line, bool print_from_where, enum log_level level, char *buf, int buflen, const char *message, va_list args)
Definition log.c:403
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
log_verbose
#define log_verbose(message,...)
Definition log.h:109
fc_assert
#define fc_assert(condition)
Definition log.h:176
MAX_LEN_LOG_LINE
#define MAX_LEN_LOG_LINE
Definition log.h:26
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
log_do_output_for_level
#define log_do_output_for_level(level)
Definition log.h:89
log_debug
#define log_debug(message,...)
Definition log.h:115
log_normal
#define log_normal(message,...)
Definition log.h:107
log_level
log_level
Definition log.h:28
LOG_ERROR
@ LOG_ERROR
Definition log.h:30
LOG_FATAL
@ LOG_FATAL
Definition log.h:29
log_error
#define log_error(message,...)
Definition log.h:103
terrain_control
struct terrain_misc terrain_control
Definition map.c:69
map.h
mem.h
fc_calloc
#define fc_calloc(n, esz)
Definition mem.h:38
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_strdup
#define fc_strdup(str)
Definition mem.h:43
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
utype_unknown_move_cost
int utype_unknown_move_cost(const struct unit_type *utype)
Definition movement.c:105
init_move_fragments
void init_move_fragments(void)
Definition movement.c:885
movement.h
SINGLE_MOVE
#define SINGLE_MOVE
Definition movement.h:24
multiplier_rule_name
const char * multiplier_rule_name(const struct multiplier *pmul)
Definition multipliers.c:106
multiplier_number
Multiplier_type_id multiplier_number(const struct multiplier *pmul)
Definition multipliers.c:67
multiplier_by_rule_name
struct multiplier * multiplier_by_rule_name(const char *name)
Definition multipliers.c:115
multiplier_index
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Definition multipliers.c:80
multipliers.h
multipliers_iterate
#define multipliers_iterate(_mul_)
Definition multipliers.h:61
multipliers_iterate_end
#define multipliers_iterate_end
Definition multipliers.h:67
name_translation.h
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
untranslated_name
static const char * untranslated_name(const struct name_translation *ptrans)
Definition name_translation.h:104
names_set
static void names_set(struct name_translation *ptrans, const char *domain, const char *vernacular_name, const char *rule_name)
Definition name_translation.h:60
nation_group_set_match
void nation_group_set_match(struct nation_group *pgroup, int match)
Definition nation.c:1046
nation_group_untranslated_name
const char * nation_group_untranslated_name(const struct nation_group *pgroup)
Definition nation.c:1068
nation_group_by_rule_name
struct nation_group * nation_group_by_rule_name(const char *name)
Definition nation.c:1020
nation_rule_name
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
nation_count
Nation_type_id nation_count(void)
Definition nation.c:506
nation_number
Nation_type_id nation_number(const struct nation_type *pnation)
Definition nation.c:485
nation_group_new
struct nation_group * nation_group_new(const char *name)
Definition nation.c:959
nation_leader_is_male
bool nation_leader_is_male(const struct nation_leader *pleader)
Definition nation.c:289
nation_set_new
struct nation_set * nation_set_new(const char *set_name, const char *set_rule_name, const char *set_description)
Definition nation.c:715
nation_by_number
struct nation_type * nation_by_number(const Nation_type_id nation)
Definition nation.c:474
nation_city_new
struct nation_city * nation_city_new(struct nation_type *pnation, const char *name)
Definition nation.c:341
nation_leaders
const struct nation_leader_list * nation_leaders(const struct nation_type *pnation)
Definition nation.c:229
nation_set_untranslated_name
const char * nation_set_untranslated_name(const struct nation_set *pset)
Definition nation.c:796
is_nation_playable
bool is_nation_playable(const struct nation_type *nation)
Definition nation.c:199
nation_set_number
int nation_set_number(const struct nation_set *pset)
Definition nation.c:707
nation_city_set_terrain_preference
void nation_city_set_terrain_preference(struct nation_city *pncity, const struct terrain *pterrain, enum nation_city_preference prefer)
Definition nation.c:389
nation_city_set_river_preference
void nation_city_set_river_preference(struct nation_city *pncity, enum nation_city_preference prefer)
Definition nation.c:401
nation_is_in_set
bool nation_is_in_set(const struct nation_type *pnation, const struct nation_set *pset)
Definition nation.c:836
nation_set_description
const char * nation_set_description(const struct nation_set *pset)
Definition nation.c:827
nation_set_count
int nation_set_count(void)
Definition nation.c:690
nation_set_by_number
struct nation_set * nation_set_by_number(int id)
Definition nation.c:761
nation_by_rule_name
struct nation_type * nation_by_rule_name(const char *name)
Definition nation.c:120
nation_set_by_rule_name
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:778
nation_index
Nation_type_id nation_index(const struct nation_type *pnation)
Definition nation.c:497
nation_leader_name
const char * nation_leader_name(const struct nation_leader *pleader)
Definition nation.c:280
nation_group_count
int nation_group_count(void)
Definition nation.c:934
nation_set_rule_name
const char * nation_set_rule_name(const struct nation_set *pset)
Definition nation.c:806
nation_leader_new
struct nation_leader * nation_leader_new(struct nation_type *pnation, const char *name, bool is_male)
Definition nation.c:238
nation_group_set_hidden
void nation_group_set_hidden(struct nation_group *pgroup, bool hidden)
Definition nation.c:1036
nations_alloc
void nations_alloc(int num)
Definition nation.c:621
nation_barbarian_type
enum barbarian_type nation_barbarian_type(const struct nation_type *nation)
Definition nation.c:210
nation_group_number
int nation_group_number(const struct nation_group *pgroup)
Definition nation.c:951
nation.h
nation_leader_list_iterate
#define nation_leader_list_iterate(leaderlist, pleader)
Definition nation.h:56
nation_sets_iterate_end
#define nation_sets_iterate_end
Definition nation.h:304
nation_set_list_iterate_end
#define nation_set_list_iterate_end
Definition nation.h:67
nation_group_list_iterate
#define nation_group_list_iterate(grouplist, pgroup)
Definition nation.h:74
nation_sets_iterate
#define nation_sets_iterate(NAME_pset)
Definition nation.h:300
nations_iterate_end
#define nations_iterate_end
Definition nation.h:335
nation_city_preference
nation_city_preference
Definition nation.h:38
NCP_DISLIKE
@ NCP_DISLIKE
Definition nation.h:39
NCP_LIKE
@ NCP_LIKE
Definition nation.h:41
nations_iterate
#define nations_iterate(NAME_pnation)
Definition nation.h:332
nation_leader_list_iterate_end
#define nation_leader_list_iterate_end
Definition nation.h:58
nation_group_list_iterate_end
#define nation_group_list_iterate_end
Definition nation.h:76
nation_set_list_iterate
#define nation_set_list_iterate(setlist, pset)
Definition nation.h:65
nation_groups_iterate
#define nation_groups_iterate(NAME_pgroup)
Definition nation.h:310
nation_groups_iterate_end
#define nation_groups_iterate_end
Definition nation.h:314
notify_conn
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:239
notify.h
packets.h
MAX_LEN_MSG
#define MAX_LEN_MSG
Definition packets.h:43
web_lsend_packet
#define web_lsend_packet(packetname,...)
Definition packets.h:53
PACKET_STRVEC_COMPUTE
#define PACKET_STRVEC_COMPUTE(str, strvec)
Definition packets.h:205
lsend_packet_ruleset_summary
void lsend_packet_ruleset_summary(struct conn_list *dest, const struct packet_ruleset_summary *packet)
Definition packets_gen.c:78537
lsend_packet_ruleset_building
void lsend_packet_ruleset_building(struct conn_list *dest, const struct packet_ruleset_building *packet)
Definition packets_gen.c:66020
lsend_packet_ruleset_unit_class_flag
void lsend_packet_ruleset_unit_class_flag(struct conn_list *dest, const struct packet_ruleset_unit_class_flag *packet)
Definition packets_gen.c:57036
lsend_packet_ruleset_achievement
void lsend_packet_ruleset_achievement(struct conn_list *dest, const struct packet_ruleset_achievement *packet)
Definition packets_gen.c:72797
lsend_packet_ruleset_nation_sets
void lsend_packet_ruleset_nation_sets(struct conn_list *dest, const struct packet_ruleset_nation_sets *packet)
Definition packets_gen.c:61923
lsend_packet_ruleset_multiplier
void lsend_packet_ruleset_multiplier(struct conn_list *dest, const struct packet_ruleset_multiplier *packet)
Definition packets_gen.c:75718
lsend_packet_ruleset_city
void lsend_packet_ruleset_city(struct conn_list *dest, const struct packet_ruleset_city *packet)
Definition packets_gen.c:65121
lsend_packet_ruleset_unit
void lsend_packet_ruleset_unit(struct conn_list *dest, const struct packet_ruleset_unit *packet)
Definition packets_gen.c:56290
lsend_packet_ruleset_clause
void lsend_packet_ruleset_clause(struct conn_list *dest, const struct packet_ruleset_clause *packet)
Definition packets_gen.c:76305
lsend_packet_ruleset_unit_flag
void lsend_packet_ruleset_unit_flag(struct conn_list *dest, const struct packet_ruleset_unit_flag *packet)
Definition packets_gen.c:56813
lsend_packet_ruleset_action
void lsend_packet_ruleset_action(struct conn_list *dest, const struct packet_ruleset_action *packet)
Definition packets_gen.c:73593
lsend_packet_ruleset_extra
void lsend_packet_ruleset_extra(struct conn_list *dest, const struct packet_ruleset_extra *packet)
Definition packets_gen.c:69970
lsend_packet_ruleset_nation_groups
void lsend_packet_ruleset_nation_groups(struct conn_list *dest, const struct packet_ruleset_nation_groups *packet)
Definition packets_gen.c:62368
lsend_packet_ruleset_terrain_control
void lsend_packet_ruleset_terrain_control(struct conn_list *dest, const struct packet_ruleset_terrain_control *packet)
Definition packets_gen.c:61299
lsend_packet_ruleset_government_ruler_title
void lsend_packet_ruleset_government_ruler_title(struct conn_list *dest, const struct packet_ruleset_government_ruler_title *packet)
Definition packets_gen.c:59191
lsend_packet_ruleset_music
void lsend_packet_ruleset_music(struct conn_list *dest, const struct packet_ruleset_music *packet)
Definition packets_gen.c:75064
lsend_packet_ruleset_control
void lsend_packet_ruleset_control(struct conn_list *dest, const struct packet_ruleset_control *packet)
Definition packets_gen.c:78376
lsend_packet_team_name_info
void lsend_packet_team_name_info(struct conn_list *dest, const struct packet_team_name_info *packet)
Definition packets_gen.c:10268
lsend_packet_ruleset_terrain_flag
void lsend_packet_ruleset_terrain_flag(struct conn_list *dest, const struct packet_ruleset_terrain_flag *packet)
Definition packets_gen.c:67829
lsend_packet_ruleset_unit_class
void lsend_packet_ruleset_unit_class(struct conn_list *dest, const struct packet_ruleset_unit_class *packet)
Definition packets_gen.c:68207
lsend_packet_ruleset_disaster
void lsend_packet_ruleset_disaster(struct conn_list *dest, const struct packet_ruleset_disaster *packet)
Definition packets_gen.c:72486
lsend_packet_ruleset_description_part
void lsend_packet_ruleset_description_part(struct conn_list *dest, const struct packet_ruleset_description_part *packet)
Definition packets_gen.c:78698
lsend_packet_ruleset_government
void lsend_packet_ruleset_government(struct conn_list *dest, const struct packet_ruleset_government *packet)
Definition packets_gen.c:60827
lsend_packet_ruleset_unit_bonus
void lsend_packet_ruleset_unit_bonus(struct conn_list *dest, const struct packet_ruleset_unit_bonus *packet)
Definition packets_gen.c:56590
lsend_packet_ruleset_base
void lsend_packet_ruleset_base(struct conn_list *dest, const struct packet_ruleset_base *packet)
Definition packets_gen.c:70519
lsend_packet_ruleset_resource
void lsend_packet_ruleset_resource(struct conn_list *dest, const struct packet_ruleset_resource *packet)
Definition packets_gen.c:83342
lsend_packet_ruleset_specialist
void lsend_packet_ruleset_specialist(struct conn_list *dest, const struct packet_ruleset_specialist *packet)
Definition packets_gen.c:58917
lsend_packet_ruleset_tech
void lsend_packet_ruleset_tech(struct conn_list *dest, const struct packet_ruleset_tech *packet)
Definition packets_gen.c:59851
lsend_packet_ruleset_trade
void lsend_packet_ruleset_trade(struct conn_list *dest, const struct packet_ruleset_trade *packet)
Definition packets_gen.c:73071
lsend_packet_ruleset_action_enabler
void lsend_packet_ruleset_action_enabler(struct conn_list *dest, const struct packet_ruleset_action_enabler *packet)
Definition packets_gen.c:74110
lsend_packet_ruleset_style
void lsend_packet_ruleset_style(struct conn_list *dest, const struct packet_ruleset_style *packet)
Definition packets_gen.c:64632
lsend_packet_ruleset_tech_flag
void lsend_packet_ruleset_tech_flag(struct conn_list *dest, const struct packet_ruleset_tech_flag *packet)
Definition packets_gen.c:60328
lsend_packet_ruleset_tech_class
void lsend_packet_ruleset_tech_class(struct conn_list *dest, const struct packet_ruleset_tech_class *packet)
Definition packets_gen.c:60105
lsend_packet_ruleset_goods
void lsend_packet_ruleset_goods(struct conn_list *dest, const struct packet_ruleset_goods *packet)
Definition packets_gen.c:72028
lsend_packet_ruleset_game
void lsend_packet_ruleset_game(struct conn_list *dest, const struct packet_ruleset_game *packet)
Definition packets_gen.c:58387
lsend_packet_ruleset_nation
void lsend_packet_ruleset_nation(struct conn_list *dest, const struct packet_ruleset_nation *packet)
Definition packets_gen.c:64090
lsend_packet_rulesets_ready
void lsend_packet_rulesets_ready(struct conn_list *dest)
Definition packets_gen.c:61336
lsend_packet_ruleset_extra_flag
void lsend_packet_ruleset_extra_flag(struct conn_list *dest, const struct packet_ruleset_extra_flag *packet)
Definition packets_gen.c:70193
lsend_packet_ruleset_road
void lsend_packet_ruleset_road(struct conn_list *dest, const struct packet_ruleset_road *packet)
Definition packets_gen.c:71477
lsend_packet_ruleset_terrain
void lsend_packet_ruleset_terrain(struct conn_list *dest, const struct packet_ruleset_terrain *packet)
Definition packets_gen.c:67606
lsend_packet_ruleset_action_auto
void lsend_packet_ruleset_action_auto(struct conn_list *dest, const struct packet_ruleset_action_auto *packet)
Definition packets_gen.c:74668
cities
struct city_list * cities
Definition packhand.c:117
len
int len
Definition packhand.c:125
player.h
send_nation_availability
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Definition plrhand.c:2471
playercolor_free
void playercolor_free(void)
Definition plrhand.c:3171
playercolor_init
void playercolor_init(void)
Definition plrhand.c:3162
playercolor_count
int playercolor_count(void)
Definition plrhand.c:3210
playercolor_add
void playercolor_add(struct rgbcolor *prgbcolor)
Definition plrhand.c:3190
count_playable_nations
void count_playable_nations(void)
Definition plrhand.c:2428
plrhand.h
secfile_load
struct section_file * secfile_load(const char *filename, bool allow_duplicates)
Definition registry.c:50
registry.h
secfile_error
const char * secfile_error(void)
Definition section_file.c:36
section_name
const char * section_name(const struct section *psection)
Definition section_file.c:65
secfile_destroy
void secfile_destroy(struct section_file *secfile)
Definition section_file.c:95
entry_bool_get
bool entry_bool_get(const struct entry *pentry, bool *value)
Definition registry_ini.c:3343
secfile_check_unused
void secfile_check_unused(const struct section_file *secfile)
Definition registry_ini.c:880
secfile_lookup_int
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
Definition registry_ini.c:1912
secfile_sections_by_name_prefix
struct section_list * secfile_sections_by_name_prefix(const struct section_file *secfile, const char *prefix)
Definition registry_ini.c:2808
secfile_lookup_str_vec
const char ** secfile_lookup_str_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
Definition registry_ini.c:2176
entry_name
const char * entry_name(const struct entry *pentry)
Definition registry_ini.c:3246
secfile_entry_lookup
struct entry * secfile_entry_lookup(const struct section_file *secfile, const char *path,...)
Definition registry_ini.c:1794
entry_str_get
bool entry_str_get(const struct entry *pentry, const char **value)
Definition registry_ini.c:3442
secfile_lookup_str
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
Definition registry_ini.c:2112
secfile_lookup_int_vec
int * secfile_lookup_int_vec(const struct section_file *secfile, size_t *dim, const char *path,...)
Definition registry_ini.c:2014
secfile_lookup_bool_default
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
Definition registry_ini.c:1837
section_entry_by_name
struct entry * section_entry_by_name(const struct section *psection, const char *name)
Definition registry_ini.c:2993
secfile_lookup_int_default
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
Definition registry_ini.c:1937
entry_int_get
bool entry_int_get(const struct entry *pentry, int *value)
Definition registry_ini.c:3414
secfile_name
const char * secfile_name(const struct section_file *secfile)
Definition registry_ini.c:916
secfile_entry_by_path
struct entry * secfile_entry_by_path(const struct section_file *secfile, const char *path)
Definition registry_ini.c:1721
secfile_lookup_str_default
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
Definition registry_ini.c:2142
secfile_lookup_int_def_min_max
int secfile_lookup_int_def_min_max(const struct section_file *secfile, int defval, int minval, int maxval, const char *path,...)
Definition registry_ini.c:1967
entry_type_get
enum entry_type entry_type_get(const struct entry *pentry)
Definition registry_ini.c:3228
ENTRY_FILEREFERENCE
@ ENTRY_FILEREFERENCE
Definition registry_ini.h:629
ENTRY_INT
@ ENTRY_INT
Definition registry_ini.h:626
ENTRY_FLOAT
@ ENTRY_FLOAT
Definition registry_ini.h:627
ENTRY_STR
@ ENTRY_STR
Definition registry_ini.h:628
ENTRY_ILLEGAL
@ ENTRY_ILLEGAL
Definition registry_ini.h:630
ENTRY_BOOL
@ ENTRY_BOOL
Definition registry_ini.h:625
secfile_lookup_enum_vec
#define secfile_lookup_enum_vec(secfile, dim, specenum_type, path,...)
Definition registry_ini.h:544
secfile_lookup_enum_default
#define secfile_lookup_enum_default(secfile, defval, specenum_type, path,...)
Definition registry_ini.h:511
section_list_iterate
#define section_list_iterate(seclist, psection)
Definition registry_ini.h:45
section_list_iterate_end
#define section_list_iterate_end
Definition registry_ini.h:47
req_vec_vector_number
req_vec_num_in_item req_vec_vector_number(const void *parent_item, const struct requirement_vector *vec)
Definition requirements.c:4789
req_vec_by_number
struct requirement_vector * req_vec_by_number(const void *parent_item, req_vec_num_in_item number)
Definition requirements.c:4808
req_vec_change_apply
bool req_vec_change_apply(const struct req_vec_change *modification, requirement_vector_by_number getter, const void *parent_item)
Definition requirements.c:4897
are_requirements_equal
bool are_requirements_equal(const struct requirement *req1, const struct requirement *req2)
Definition requirements.c:1296
req_from_str
struct requirement req_from_str(const char *type, const char *range, bool survives, bool present, bool quiet, const char *value)
Definition requirements.c:938
req_from_values
struct requirement req_from_values(int type, int range, bool survives, bool present, bool quiet, int value)
Definition requirements.c:1249
req_vec_problem_free
void req_vec_problem_free(struct req_vec_problem *issue)
Definition requirements.c:4994
req_vec_get_first_missing_univ
struct req_vec_problem * req_vec_get_first_missing_univ(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
Definition requirements.c:5100
req_vec_get_first_redundant_req
struct req_vec_problem * req_vec_get_first_redundant_req(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
Definition requirements.c:5185
req_vec_is_impossible_to_fulfill
bool req_vec_is_impossible_to_fulfill(const struct requirement_vector *reqs)
Definition requirements.c:4769
requirements.h
requirement_vector_iterate_end
#define requirement_vector_iterate_end
Definition requirements.h:93
requirement_vector_iterate
#define requirement_vector_iterate(req_vec, preq)
Definition requirements.h:91
rgbcolor_load
bool rgbcolor_load(struct section_file *file, struct rgbcolor **prgbcolor, char *path,...)
Definition rgbcolor.c:90
rgbcolor.h
road_number
Road_type_id road_number(const struct road_type *proad)
Definition road.c:32
road_integrators_cache_init
void road_integrators_cache_init(void)
Definition road.c:111
road_type_init
void road_type_init(struct extra_type *pextra, int idx)
Definition road.c:93
road.h
rscompat_action_ui_name_S3_1
const char * rscompat_action_ui_name_S3_1(struct rscompat_info *compat, int act_id)
Definition rscompat.c:2238
rscompat_adjust_pre_sanity
void rscompat_adjust_pre_sanity(struct rscompat_info *info)
Definition rscompat.c:839
rscompat_road_gui_type_3_1
enum road_gui_type rscompat_road_gui_type_3_1(struct road_type *proad)
Definition rscompat.c:2220
rscompat_extra_adjust_3_1
void rscompat_extra_adjust_3_1(struct rscompat_info *compat, struct extra_type *pextra)
Definition rscompat.c:2204
rscompat_uclass_flags_3_1
void rscompat_uclass_flags_3_1(struct rscompat_info *compat, struct unit_class *pclass)
Definition rscompat.c:2192
rscompat_req_name_3_1
const char * rscompat_req_name_3_1(const char *type, const char *old_name)
Definition rscompat.c:2059
rscompat_auto_attack_3_1
bool rscompat_auto_attack_3_1(struct rscompat_info *compat, struct action_auto_perf *auto_perf, size_t psize, enum unit_type_flag_id *protecor_flag)
Definition rscompat.c:1749
rscompat_old_effect_3_1
bool rscompat_old_effect_3_1(const char *type, struct section_file *file, const char *sec_name, struct rscompat_info *compat)
Definition rscompat.c:806
rscompat_names
bool rscompat_names(struct rscompat_info *info)
Definition rscompat.c:386
rscompat_utype_flag_name_3_1
const char * rscompat_utype_flag_name_3_1(struct rscompat_info *compat, const char *old_type)
Definition rscompat.c:2165
rscompat_req_vec_adjust_3_1
void rscompat_req_vec_adjust_3_1(struct rscompat_info *compat, struct requirement_vector *preqs, int *reqs_count, const char *filename, const char *sec, const char *sub, const char *rfor)
Definition rscompat.c:2079
rscompat_old_slow_invasions_3_1
bool rscompat_old_slow_invasions_3_1(struct rscompat_info *compat, bool slow_invasions)
Definition rscompat.c:1908
rscompat_postprocess
void rscompat_postprocess(struct rscompat_info *info)
Definition rscompat.c:859
rscompat_check_capabilities
int rscompat_check_capabilities(struct section_file *file, const char *filename, const struct rscompat_info *info)
Definition rscompat.c:65
rscompat_enablers_add_obligatory_hard_reqs
void rscompat_enablers_add_obligatory_hard_reqs(void)
Definition rscompat.c:285
rscompat_action_max_range_name_S3_1
const char * rscompat_action_max_range_name_S3_1(struct rscompat_info *compat, int act_id)
Definition rscompat.c:2253
rscompat_init_info
void rscompat_init_info(struct rscompat_info *info)
Definition rscompat.c:56
rscompat_check_cap_and_version
bool rscompat_check_cap_and_version(struct section_file *file, const char *filename, const struct rscompat_info *info)
Definition rscompat.c:131
rscompat_combat_bonus_name_3_1
const char * rscompat_combat_bonus_name_3_1(struct rscompat_info *compat, const char *old_type)
Definition rscompat.c:2177
rscompat_req_type_name_3_1
const char * rscompat_req_type_name_3_1(const char *old_type)
Definition rscompat.c:2043
rscompat.h
sanity_check_ruleset_data
bool sanity_check_ruleset_data(struct rscompat_info *compat)
Definition rssanity.c:836
autoadjust_ruleset_data
bool autoadjust_ruleset_data(void)
Definition rssanity.c:1517
rssanity.h
check_cityname
#define check_cityname(name)
Definition ruleset.c:112
ruleset_purge_redundant_reqs_enablers
static int ruleset_purge_redundant_reqs_enablers(void)
Definition ruleset.c:414
ruleset_load_traits
static void ruleset_load_traits(struct trait_limits *out, struct section_file *file, const char *secname, const char *field_prefix)
Definition ruleset.c:1324
load_rulesetdir
static bool load_rulesetdir(const char *rsdir, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
Definition ruleset.c:9340
STYLE_SECTION_PREFIX
#define STYLE_SECTION_PREFIX
Definition ruleset.c:95
lookup_terrain
static bool lookup_terrain(struct section_file *file, const char *entry, const char *filename, struct terrain *pthis, struct terrain **result, bool null_acceptable)
Definition ruleset.c:1225
load_terrain_names
static bool load_terrain_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:2810
load_style_names
static bool load_style_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:5716
ruleset_purge_unused_entities
int ruleset_purge_unused_entities(void)
Definition ruleset.c:304
MUSICSTYLE_SECTION_PREFIX
#define MUSICSTYLE_SECTION_PREFIX
Definition ruleset.c:89
road_sections
static char * road_sections
Definition ruleset.c:123
load_ruleset_governments
static bool load_ruleset_governments(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:4437
MULTIPLIER_SECTION_PREFIX
#define MULTIPLIER_SECTION_PREFIX
Definition ruleset.c:109
reqs_list
static struct requirement_vector reqs_list
Definition ruleset.c:125
send_ruleset_techs
static void send_ruleset_techs(struct conn_list *dest)
Definition ruleset.c:8240
section_strlcpy
#define section_strlcpy(dst, src)
Definition ruleset.c:117
check_name
#define check_name(name)
Definition ruleset.c:111
send_ruleset_units
static void send_ruleset_units(struct conn_list *dest)
Definition ruleset.c:8053
send_ruleset_governments
static void send_ruleset_governments(struct conn_list *dest)
Definition ruleset.c:8866
lookup_resource
static struct extra_type * lookup_resource(const char *filename, const char *name, const char *jsection)
Definition ruleset.c:1204
openload_luadata_file
static struct section_file * openload_luadata_file(const char *rsdir)
Definition ruleset.c:617
load_ruleset_techs
static bool load_ruleset_techs(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:1573
purge_unused_req_vec
static bool purge_unused_req_vec(const struct requirement_vector *reqs, const char *msg)
Definition ruleset.c:318
rulesets_deinit
void rulesets_deinit(void)
Definition ruleset.c:9330
load_action_ui_name
static bool load_action_ui_name(struct section_file *file, int act, const char *entry_name, const char *compat_name)
Definition ruleset.c:6297
send_ruleset_resources
static void send_ruleset_resources(struct conn_list *dest)
Definition ruleset.c:8473
load_ruleset_buildings
static bool load_ruleset_buildings(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:2692
terrain_sections
static char * terrain_sections
Definition ruleset.c:120
lookup_building_list
static bool lookup_building_list(struct section_file *file, const char *prefix, const char *entry, int *output, const char *filename)
Definition ruleset.c:1056
nullcheck_secfile_destroy
static void nullcheck_secfile_destroy(struct section_file *file)
Definition ruleset.c:9319
send_ruleset_clauses
static void send_ruleset_clauses(struct conn_list *dest)
Definition ruleset.c:9035
send_ruleset_game
static void send_ruleset_game(struct conn_list *dest)
Definition ruleset.c:9155
parser_buffer
char * parser_buffer
Definition ruleset.c:200
NATION_SECTION_PREFIX
#define NATION_SECTION_PREFIX
Definition ruleset.c:94
load_ruleset_effects
static bool load_ruleset_effects(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:6161
send_ruleset_nations
static void send_ruleset_nations(struct conn_list *dest)
Definition ruleset.c:8909
send_ruleset_roads
static void send_ruleset_roads(struct conn_list *dest)
Definition ruleset.c:8628
ruleset_purge_unused_enablers
static int ruleset_purge_unused_enablers(void)
Definition ruleset.c:235
is_on_allowed_list
static bool is_on_allowed_list(const char *name, const char **list, size_t len)
Definition ruleset.c:4827
send_ruleset_tech_classes
static void send_ruleset_tech_classes(struct conn_list *dest)
Definition ruleset.c:8222
send_ruleset_action_enablers
static void send_ruleset_action_enablers(struct conn_list *dest)
Definition ruleset.c:8781
send_ruleset_control
static void send_ruleset_control(struct conn_list *dest)
Definition ruleset.c:4629
load_rulesets
bool load_rulesets(const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
Definition ruleset.c:9246
GOODS_SECTION_PREFIX
#define GOODS_SECTION_PREFIX
Definition ruleset.c:101
ruleset_error_real
void ruleset_error_real(rs_conversion_logger logger, const char *file, const char *function, int line, enum log_level level, const char *format,...)
Definition ruleset.c:206
TERRAIN_SECTION_PREFIX
#define TERRAIN_SECTION_PREFIX
Definition ruleset.c:103
openload_ruleset_file
static struct section_file * openload_ruleset_file(const char *whichset, const char *rsdir)
Definition ruleset.c:562
send_ruleset_musics
static void send_ruleset_musics(struct conn_list *dest)
Definition ruleset.c:9129
ruleset_purge_redundant_reqs
int ruleset_purge_redundant_reqs(void)
Definition ruleset.c:481
secfile_lookup_int_default_min_max
static int secfile_lookup_int_default_min_max(struct section_file *file, int def, int min, int max, const char *path,...) fc__attribute((__format__(__printf__
Definition ruleset.c:6259
base_sections
static char * base_sections
Definition ruleset.c:122
DISASTER_SECTION_PREFIX
#define DISASTER_SECTION_PREFIX
Definition ruleset.c:106
send_ruleset_goods
static void send_ruleset_goods(struct conn_list *dest)
Definition ruleset.c:8668
name_too_long
static const char name_too_long[]
Definition ruleset.c:115
reload_rulesets_settings
bool reload_rulesets_settings(void)
Definition ruleset.c:9569
lookup_strvec
static struct strvec * lookup_strvec(struct section_file *file, const char *prefix, const char *suffix)
Definition ruleset.c:1184
CITYSTYLE_SECTION_PREFIX
#define CITYSTYLE_SECTION_PREFIX
Definition ruleset.c:88
load_action_range
static bool load_action_range(struct rscompat_info *compat, struct section_file *file, action_id act)
Definition ruleset.c:6370
lookup_tech
static bool lookup_tech(struct section_file *file, struct advance **result, const char *prefix, const char *entry, const char *filename, const char *description)
Definition ruleset.c:867
load_game_names
static bool load_game_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:1363
send_ruleset_specialists
static void send_ruleset_specialists(struct conn_list *dest)
Definition ruleset.c:8194
load_ruleset_veteran
static bool load_ruleset_veteran(struct section_file *file, const char *path, struct veteran_system **vsystem, char *err, size_t err_len, struct rscompat_info *compat)
Definition ruleset.c:1943
ADVANCE_SECTION_PREFIX
#define ADVANCE_SECTION_PREFIX
Definition ruleset.c:85
EFFECT_SECTION_PREFIX
#define EFFECT_SECTION_PREFIX
Definition ruleset.c:90
send_ruleset_action_auto_performers
static void send_ruleset_action_auto_performers(struct conn_list *dest)
Definition ruleset.c:8809
load_government_names
static bool load_government_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:4355
send_ruleset_team_names
static void send_ruleset_team_names(struct conn_list *dest)
Definition ruleset.c:9216
send_ruleset_cities
static void send_ruleset_cities(struct conn_list *dest)
Definition ruleset.c:9101
lookup_building
static bool lookup_building(struct section_file *file, const char *prefix, const char *entry, struct impr_type **result, const char *filename, const char *description)
Definition ruleset.c:899
purge_redundant_req_vec
static bool purge_redundant_req_vec(const struct requirement_vector *reqs, const char *msg)
Definition ruleset.c:403
lookup_string
static char * lookup_string(struct section_file *file, const char *prefix, const char *suffix)
Definition ruleset.c:1164
check_leader_names
static const char * check_leader_names(struct nation_type *pnation)
Definition ruleset.c:4668
ACTION_ENABLER_SECTION_PREFIX
#define ACTION_ENABLER_SECTION_PREFIX
Definition ruleset.c:108
BASE_SECTION_PREFIX
#define BASE_SECTION_PREFIX
Definition ruleset.c:98
ruleset_purge_redundant_reqs_effects
static int ruleset_purge_redundant_reqs_effects(void)
Definition ruleset.c:452
openload_script_file
static enum fc_tristate openload_script_file(const char *whichset, const char *rsdir, char **buffer, bool optional)
Definition ruleset.c:590
get_parser_buffer
char * get_parser_buffer(void)
Definition ruleset.c:553
load_building_names
static bool load_building_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:2640
EXTRA_SECTION_PREFIX
#define EXTRA_SECTION_PREFIX
Definition ruleset.c:97
load_action_range_max
static bool load_action_range_max(struct rscompat_info *compat, struct section_file *file, action_id act)
Definition ruleset.c:6319
send_rulesets
void send_rulesets(struct conn_list *dest)
Definition ruleset.c:9592
CLAUSE_SECTION_PREFIX
#define CLAUSE_SECTION_PREFIX
Definition ruleset.c:96
lookup_unit_list
static bool lookup_unit_list(struct section_file *file, const char *prefix, const char *entry, struct unit_type **output, const char *filename)
Definition ruleset.c:932
resource_sections
static char * resource_sections
Definition ruleset.c:119
UNIT_SECTION_PREFIX
#define UNIT_SECTION_PREFIX
Definition ruleset.c:105
ACHIEVEMENT_SECTION_PREFIX
#define ACHIEVEMENT_SECTION_PREFIX
Definition ruleset.c:107
load_ruleset_cities
static bool load_ruleset_cities(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:5956
load_ruleset_styles
static bool load_ruleset_styles(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:5777
lookup_government
static struct government * lookup_government(struct section_file *file, const char *entry, const char *filename, struct government *fallback)
Definition ruleset.c:1139
load_ruleset_units
static bool load_ruleset_units(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:2075
script_buffer
char * script_buffer
Definition ruleset.c:199
lookup_time
static bool lookup_time(const struct section_file *secfile, int *turns, const char *sec_name, const char *property_name, const char *filename, const char *item_name, bool *ok)
Definition ruleset.c:1275
load_action_blocked_by_list
static bool load_action_blocked_by_list(struct section_file *file, const char *filename, struct action *paction)
Definition ruleset.c:6435
send_ruleset_styles
static void send_ruleset_styles(struct conn_list *dest)
Definition ruleset.c:9019
NATION_GROUP_SECTION_PREFIX
#define NATION_GROUP_SECTION_PREFIX
Definition ruleset.c:93
extra_sections
static char * extra_sections
Definition ruleset.c:121
RULES_SUFFIX
#define RULES_SUFFIX
Definition ruleset.c:82
lookup_req_list
struct requirement_vector * lookup_req_list(struct section_file *file, struct rscompat_info *compat, const char *sec, const char *sub, const char *rfor)
Definition ruleset.c:645
send_ruleset_disasters
static void send_ruleset_disasters(struct conn_list *dest)
Definition ruleset.c:8700
purge_duplicate_req_vec
static bool purge_duplicate_req_vec(const struct requirement_vector *reqs, const char *msg)
Definition ruleset.c:358
lookup_tech_list
static bool lookup_tech_list(struct section_file *file, const char *prefix, const char *entry, int *output, const char *filename)
Definition ruleset.c:992
MAX_SECTION_LABEL
#define MAX_SECTION_LABEL
Definition ruleset.c:116
BUILDING_SECTION_PREFIX
#define BUILDING_SECTION_PREFIX
Definition ruleset.c:87
load_ruleset_game
static bool load_ruleset_game(struct section_file *file, bool act, struct rscompat_info *compat)
Definition ruleset.c:6550
load_nation_names
static bool load_nation_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:4688
send_ruleset_achievements
static void send_ruleset_achievements(struct conn_list *dest)
Definition ruleset.c:8730
SCRIPT_SUFFIX
#define SCRIPT_SUFFIX
Definition ruleset.c:83
send_ruleset_bases
static void send_ruleset_bases(struct conn_list *dest)
Definition ruleset.c:8606
load_ruleset_terrain
static bool load_ruleset_terrain(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:3143
ruleset_purge_unused_effects
static int ruleset_purge_unused_effects(void)
Definition ruleset.c:281
load_action_actor_consuming_always
static bool load_action_actor_consuming_always(struct section_file *file, action_id act)
Definition ruleset.c:6418
load_action_post_success_force
static bool load_action_post_success_force(struct section_file *file, const char *filename, int performer_slot, struct action *paction)
Definition ruleset.c:6479
load_tech_names
static bool load_tech_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:1456
SPECIALIST_SECTION_PREFIX
#define SPECIALIST_SECTION_PREFIX
Definition ruleset.c:102
lookup_cbonus_list
static bool lookup_cbonus_list(struct rscompat_info *compat, struct combat_bonus_list *list, struct section_file *file, const char *sec, const char *sub)
Definition ruleset.c:805
load_action_kind
static bool load_action_kind(struct section_file *file, action_id act)
Definition ruleset.c:6396
send_ruleset_multipliers
static void send_ruleset_multipliers(struct conn_list *dest)
Definition ruleset.c:9067
get_script_buffer
char * get_script_buffer(void)
Definition ruleset.c:545
send_ruleset_actions
static void send_ruleset_actions(struct conn_list *dest)
Definition ruleset.c:8751
load_city_name_list
static bool load_city_name_list(struct section_file *file, struct nation_type *pnation, const char *secfile_str1, const char *secfile_str2, const char **allowed_terrains, size_t atcount)
Definition ruleset.c:4843
load_action_auto_uflag_block
static bool load_action_auto_uflag_block(struct section_file *file, struct action_auto_perf *auto_perf, const char *uflags_path, const char *filename)
Definition ruleset.c:5855
load_ruleset_nations
static bool load_ruleset_nations(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:5013
load_action_auto_actions
static bool load_action_auto_actions(struct section_file *file, struct action_auto_perf *auto_perf, const char *actions_path, const char *filename)
Definition ruleset.c:5898
send_ruleset_unit_classes
static void send_ruleset_unit_classes(struct conn_list *dest)
Definition ruleset.c:8005
TECH_CLASS_SECTION_PREFIX
#define TECH_CLASS_SECTION_PREFIX
Definition ruleset.c:86
RESOURCE_SECTION_PREFIX
#define RESOURCE_SECTION_PREFIX
Definition ruleset.c:100
lookup_unit_type
static bool lookup_unit_type(struct section_file *file, const char *prefix, const char *entry, const struct unit_type **result, const char *filename, const char *description)
Definition ruleset.c:1108
send_ruleset_extras
static void send_ruleset_extras(struct conn_list *dest)
Definition ruleset.c:8492
rs_sanity_veteran
#define rs_sanity_veteran(_path, _entry, _i, _condition, _action)
send_ruleset_terrain
static void send_ruleset_terrain(struct conn_list *dest)
Definition ruleset.c:8370
GOVERNMENT_SECTION_PREFIX
#define GOVERNMENT_SECTION_PREFIX
Definition ruleset.c:91
load_unit_names
static bool load_unit_names(struct section_file *file, struct rscompat_info *compat)
Definition ruleset.c:1784
send_ruleset_trade_routes
static void send_ruleset_trade_routes(struct conn_list *dest)
Definition ruleset.c:8845
notify_ruleset_fallback
static void notify_ruleset_fallback(const char *msg)
Definition ruleset.c:9238
lookup_bv_actions
static bool lookup_bv_actions(struct section_file *file, const char *filename, bv_actions *target, const char *path)
Definition ruleset.c:6516
send_ruleset_buildings
static void send_ruleset_buildings(struct conn_list *dest)
Definition ruleset.c:8332
UNIT_CLASS_SECTION_PREFIX
#define UNIT_CLASS_SECTION_PREFIX
Definition ruleset.c:104
ruleset_load_names
static bool ruleset_load_names(struct name_translation *pname, const char *domain, struct section_file *file, const char *sec_name)
Definition ruleset.c:1301
ROAD_SECTION_PREFIX
#define ROAD_SECTION_PREFIX
Definition ruleset.c:99
valid_ruleset_filename
static const char * valid_ruleset_filename(const char *subdir, const char *name, const char *extension, bool optional)
Definition ruleset.c:500
load_muuk_as_action_auto
static bool load_muuk_as_action_auto(struct section_file *file, struct action_auto_perf *auto_perf, const char *item, const char *filename)
Definition ruleset.c:5934
NATION_SET_SECTION_PREFIX
#define NATION_SET_SECTION_PREFIX
Definition ruleset.c:92
ruleset.h
RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
#define RS_DEFAULT_DAMAGE_REDUCES_BOMBARD_RATE
Definition ruleset.h:107
RS_DEFAULT_TECH_TRADE_LOSS_HOLES
#define RS_DEFAULT_TECH_TRADE_LOSS_HOLES
Definition ruleset.h:84
RS_DEFAULT_TECH_COST_STYLE
#define RS_DEFAULT_TECH_COST_STYLE
Definition ruleset.h:90
RS_DEFAULT_EXTRA_APPEARANCE
#define RS_DEFAULT_EXTRA_APPEARANCE
Definition ruleset.h:101
RS_DEFAULT_TECH_PARASITE_HOLES
#define RS_DEFAULT_TECH_PARASITE_HOLES
Definition ruleset.h:85
GAME_DEFAULT_ACH_VALUE
#define GAME_DEFAULT_ACH_VALUE
Definition ruleset.h:78
RS_DEFAULT_TECH_TRADE_HOLES
#define RS_DEFAULT_TECH_TRADE_HOLES
Definition ruleset.h:83
RS_DEFAULT_CULTURE_VIC_POINTS
#define RS_DEFAULT_CULTURE_VIC_POINTS
Definition ruleset.h:94
RS_DEFAULT_CULTURE_MIGRATION_PML
#define RS_DEFAULT_CULTURE_MIGRATION_PML
Definition ruleset.h:96
rs_conversion_logger
void(* rs_conversion_logger)(const char *msg)
Definition ruleset.h:40
RS_DEFAULT_SMALL_WONDER_VISIBILITY
#define RS_DEFAULT_SMALL_WONDER_VISIBILITY
Definition ruleset.h:109
ruleset_error
#define ruleset_error(logger, level, format,...)
Definition ruleset.h:57
RS_DEFAULT_ONLY_KILLING_VETERAN
#define RS_DEFAULT_ONLY_KILLING_VETERAN
Definition ruleset.h:104
RS_DEFAULT_TECH_LOSS_HOLES
#define RS_DEFAULT_TECH_LOSS_HOLES
Definition ruleset.h:86
RS_DEFAULT_HISTORY_INTEREST_PML
#define RS_DEFAULT_HISTORY_INTEREST_PML
Definition ruleset.h:97
RS_DEFAULT_TECH_UPKEEP_STYLE
#define RS_DEFAULT_TECH_UPKEEP_STYLE
Definition ruleset.h:92
RS_DEFAULT_GOODS_SELECTION
#define RS_DEFAULT_GOODS_SELECTION
Definition ruleset.h:99
RS_DEFAULT_PYTHAGOREAN_DIAGONAL
#define RS_DEFAULT_PYTHAGOREAN_DIAGONAL
Definition ruleset.h:87
RS_DEFAULT_TECH_STEAL_HOLES
#define RS_DEFAULT_TECH_STEAL_HOLES
Definition ruleset.h:82
GAME_DEFAULT_ACH_UNIQUE
#define GAME_DEFAULT_ACH_UNIQUE
Definition ruleset.h:77
RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
#define RS_DEFAULT_COMBAT_ODDS_SCALED_VETERANCY
Definition ruleset.h:106
RS_DEFAULT_MUUK_FOOD_WIPE
#define RS_DEFAULT_MUUK_FOOD_WIPE
Definition ruleset.h:79
RS_DEFAULT_MUUK_GOLD_WIPE
#define RS_DEFAULT_MUUK_GOLD_WIPE
Definition ruleset.h:80
GAME_DEFAULT_CHANGABLE_TAX
#define GAME_DEFAULT_CHANGABLE_TAX
Definition ruleset.h:72
RS_DEFAULT_MUUK_SHIELD_WIPE
#define RS_DEFAULT_MUUK_SHIELD_WIPE
Definition ruleset.h:81
RS_DEFAULT_GOLD_UPKEEP_STYLE
#define RS_DEFAULT_GOLD_UPKEEP_STYLE
Definition ruleset.h:89
GAME_DEFAULT_NATIONALITY
#define GAME_DEFAULT_NATIONALITY
Definition ruleset.h:74
GAME_DEFAULT_ADDTOSIZE
#define GAME_DEFAULT_ADDTOSIZE
Definition ruleset.h:71
RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
#define RS_DEFAULT_ONLY_REAL_FIGHT_VETERAN
Definition ruleset.h:105
RS_DEFAULT_EXTRA_DISAPPEARANCE
#define RS_DEFAULT_EXTRA_DISAPPEARANCE
Definition ruleset.h:102
GAME_DEFAULT_VISION_REVEAL_TILES
#define GAME_DEFAULT_VISION_REVEAL_TILES
Definition ruleset.h:73
RS_DEFAULT_CULTURE_VIC_LEAD
#define RS_DEFAULT_CULTURE_VIC_LEAD
Definition ruleset.h:95
RS_DEFAULT_TECH_LEAKAGE
#define RS_DEFAULT_TECH_LEAKAGE
Definition ruleset.h:91
RSFORMAT_3_1
#define RSFORMAT_3_1
Definition ruleset.h:36
GAME_DEFAULT_DISASTER_FREQ
#define GAME_DEFAULT_DISASTER_FREQ
Definition ruleset.h:76
GAME_DEFAULT_CONVERT_SPEED
#define GAME_DEFAULT_CONVERT_SPEED
Definition ruleset.h:75
compat
static struct compatibility compat[]
Definition savecompat.c:101
script_server_init
bool script_server_init(void)
Definition script_server.c:292
script_server_load_file
bool script_server_load_file(const char *filename, char **buf)
Definition script_server.c:129
script_server_free
void script_server_free(void)
Definition script_server.c:366
script_server_do_file
bool script_server_do_file(struct connection *caller, const char *filename)
Definition script_server.c:188
script_server.h
settings_ruleset
bool settings_ruleset(struct section_file *file, const char *section, bool act)
Definition settings.c:4178
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
settings.h
check_strlen
bool check_strlen(const char *str, size_t len, const char *errmsg)
Definition shared.c:492
fileinfoname
const char * fileinfoname(const struct strvec *dirs, const char *filename)
Definition shared.c:1094
remove_leading_trailing_spaces
void remove_leading_trailing_spaces(char *s)
Definition shared.c:443
get_data_dirs
const struct strvec * get_data_dirs(void)
Definition shared.c:886
shared.h
fc_tristate
fc_tristate
Definition shared.h:46
TRI_YES
@ TRI_YES
Definition shared.h:46
TRI_NO
@ TRI_NO
Definition shared.h:46
TRI_MAYBE
@ TRI_MAYBE
Definition shared.h:46
DIR_SEPARATOR
#define DIR_SEPARATOR
Definition shared.h:127
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85
specialist_by_number
struct specialist * specialist_by_number(const Specialist_type_id id)
Definition specialist.c:100
specialist_rule_name
const char * specialist_rule_name(const struct specialist *sp)
Definition specialist.c:146
specialist.h
specialist_type_iterate_end
#define specialist_type_iterate_end
Definition specialist.h:79
specialist_type_iterate
#define specialist_type_iterate(sp)
Definition specialist.h:73
DEFAULT_SPECIALIST
#define DEFAULT_SPECIALIST
Definition specialist.h:43
aifill
const char * aifill(int amount)
Definition srv_main.c:2395
update_nations_with_startpos
void update_nations_with_startpos(void)
Definition srv_main.c:2200
srv_main.h
strvec_store
void strvec_store(struct strvec *psv, const char *const *vec, size_t size)
Definition string_vector.c:110
strvec_new
struct strvec * strvec_new(void)
Definition string_vector.c:58
string_vector.h
action_auto_perf
Definition actions.h:568
action_auto_perf::reqs
struct requirement_vector reqs
Definition actions.h:574
action_auto_perf::cause
enum action_auto_perf_cause cause
Definition actions.h:570
action_auto_perf::alternatives
action_id alternatives[MAX_NUM_ACTIONS]
Definition actions.h:578
action_enabler
Definition actions.h:438
action_enabler::action
action_id action
Definition actions.h:439
action_enabler::actor_reqs
struct requirement_vector actor_reqs
Definition actions.h:440
action_enabler::target_reqs
struct requirement_vector target_reqs
Definition actions.h:441
action
Definition actions.h:379
action::id
action_id id
Definition actions.h:380
action::actor_consuming_always
bool actor_consuming_always
Definition actions.h:412
action::max_distance
int max_distance
Definition actions.h:395
action::quiet
bool quiet
Definition actions.h:402
action::result
enum action_result result
Definition actions.h:382
action::ui_name
char ui_name[MAX_LEN_NAME]
Definition actions.h:398
action::sub_results
bv_action_sub_results sub_results
Definition actions.h:383
action::actor_kind
enum action_actor_kind actor_kind
Definition actions.h:385
action::blocked_by
bv_actions blocked_by
Definition actions.h:406
action::target_kind
enum action_target_kind target_kind
Definition actions.h:386
action::min_distance
int min_distance
Definition actions.h:395
advance
Definition tech.h:124
advance::require
struct advance * require[AR_SIZE]
Definition tech.h:132
base_type
Definition base.h:41
base_type::border_sq
int border_sq
Definition base.h:44
base_type::vision_main_sq
int vision_main_sq
Definition base.h:45
base_type::gui_type
enum base_gui_type gui_type
Definition base.h:43
base_type::vision_invis_sq
int vision_invis_sq
Definition base.h:46
base_type::vision_subs_sq
int vision_subs_sq
Definition base.h:47
citystyle::citizens_graphic
char citizens_graphic[MAX_LEN_NAME]
Definition city.h:475
citystyle::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition city.h:474
citystyle::graphic
char graphic[MAX_LEN_NAME]
Definition city.h:473
civ_game::rgame
struct civ_game::@29 rgame
civ_game::nationlist
char * nationlist
Definition game.h:274
civ_game::named_teams
int named_teams
Definition game.h:286
civ_game::as_count
size_t as_count
Definition game.h:285
civ_game::allowed_govs
const char ** allowed_govs
Definition game.h:277
civ_game::upgrade_veteran_loss
int upgrade_veteran_loss
Definition game.h:198
civ_game::plr_bg_color
struct rgbcolor * plr_bg_color
Definition game.h:102
civ_game::incite_total_factor
int incite_total_factor
Definition game.h:149
civ_game::init_vis_radius_sq
int init_vis_radius_sq
Definition game.h:151
civ_game::server
struct civ_game::@30::@34 server
civ_game::vision_reveal_tiles
bool vision_reveal_tiles
Definition game.h:199
civ_game::description_file
char * description_file
Definition game.h:273
civ_game::control
struct packet_ruleset_control control
Definition game.h:83
civ_game::ruleset_summary
char * ruleset_summary
Definition game.h:84
civ_game::nc_agovs
char ** nc_agovs
Definition game.h:278
civ_game::base_incite_cost
int base_incite_cost
Definition game.h:133
civ_game::global_init_techs
int global_init_techs[MAX_NUM_TECH_LIST]
Definition game.h:107
civ_game::info
struct packet_game_info info
Definition game.h:89
civ_game::autoupgrade_veteran_loss
int autoupgrade_veteran_loss
Definition game.h:131
civ_game::rulesetdir
char rulesetdir[MAX_LEN_NAME]
Definition game.h:236
civ_game::start_year
int start_year
Definition game.h:190
civ_game::incite_improvement_factor
int incite_improvement_factor
Definition game.h:148
civ_game::luadata
struct section_file * luadata
Definition game.h:244
civ_game::embedded_nations
char ** embedded_nations
Definition game.h:275
civ_game::global_init_buildings
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition game.h:108
civ_game::ruledit
struct civ_game::@30::@34::@39 ruledit
civ_game::default_traits
struct trait_limits default_traits[TRAIT_COUNT]
Definition game.h:270
civ_game::nc_astyles
char ** nc_astyles
Definition game.h:284
civ_game::allowed_terrains
const char ** allowed_terrains
Definition game.h:280
civ_game::ruleset_description
char * ruleset_description
Definition game.h:85
civ_game::ag_count
size_t ag_count
Definition game.h:279
civ_game::allowed_styles
const char ** allowed_styles
Definition game.h:283
civ_game::nc_aterrs
char ** nc_aterrs
Definition game.h:281
civ_game::embedded_nations_count
size_t embedded_nations_count
Definition game.h:276
civ_game::incite_unit_factor
int incite_unit_factor
Definition game.h:150
civ_game::ruleset_capabilities
char * ruleset_capabilities
Definition game.h:86
civ_game::ransom_gold
int ransom_gold
Definition game.h:174
civ_game::at_count
size_t at_count
Definition game.h:282
civ_game::veteran
struct veteran_system * veteran
Definition game.h:100
civ_game::calendar
struct packet_calendar_info calendar
Definition game.h:90
civ_game::default_government
struct government * default_government
Definition game.h:93
civ_game::government_during_revolution
struct government * government_during_revolution
Definition game.h:94
civ_map::server
struct civ_map::@41::@43 server
civ_map::ocean_resources
bool ocean_resources
Definition map_types.h:105
clause_info
Definition diptreaty.h:53
clause_info::receiver_reqs
struct requirement_vector receiver_reqs
Definition diptreaty.h:57
clause_info::giver_reqs
struct requirement_vector giver_reqs
Definition diptreaty.h:56
clause_info::enabled
bool enabled
Definition diptreaty.h:55
combat_bonus
Definition unittype.h:447
combat_bonus::value
int value
Definition unittype.h:450
combat_bonus::flag
enum unit_type_flag_id flag
Definition unittype.h:448
combat_bonus::quiet
bool quiet
Definition unittype.h:453
combat_bonus::type
enum combat_bonus_type type
Definition unittype.h:449
compatibility::version
int version
Definition savecompat.c:84
effect
Definition effects.h:340
entry
Definition registry_ini.c:193
extra_type
Definition extras.h:85
extra_type::conflicts
bv_extras conflicts
Definition extras.h:129
extra_type::name
struct name_translation name
Definition extras.h:87
government
Definition government.h:52
impr_type
Definition improvement.h:68
impr_type::build_cost
int build_cost
Definition improvement.h:77
impr_type::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition improvement.h:73
impr_type::upkeep
int upkeep
Definition improvement.h:78
impr_type::genus
enum impr_genus_id genus
Definition improvement.h:80
impr_type::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition improvement.h:74
impr_type::obsolete_by
struct requirement_vector obsolete_by
Definition improvement.h:76
impr_type::sabotage
int sabotage
Definition improvement.h:79
impr_type::soundtag_alt
char soundtag_alt[MAX_LEN_NAME]
Definition improvement.h:84
impr_type::reqs
struct requirement_vector reqs
Definition improvement.h:75
impr_type::helptext
struct strvec * helptext
Definition improvement.h:82
impr_type::name
struct name_translation name
Definition improvement.h:70
impr_type::flags
bv_impr_flags flags
Definition improvement.h:81
impr_type::soundtag
char soundtag[MAX_LEN_NAME]
Definition improvement.h:83
item
Definition climisc.h:80
multiplier
Definition multipliers.h:31
music_style
Definition style.h:29
music_style::reqs
struct requirement_vector reqs
Definition style.h:33
music_style::music_peaceful
char music_peaceful[MAX_LEN_NAME]
Definition style.h:31
music_style::music_combat
char music_combat[MAX_LEN_NAME]
Definition style.h:32
name_translation
Definition name_translation.h:35
nation_city
Definition nation.c:320
nation_group
Definition nation.h:166
nation_group::hidden
bool hidden
Definition nation.h:168
nation_set
Definition nation.c:40
nation_type
Definition nation.h:97
nation_type::noun_plural
struct name_translation noun_plural
Definition nation.h:101
nation_type::parent_nations
struct nation_list * parent_nations
Definition nation.h:135
nation_type::adjective
struct name_translation adjective
Definition nation.h:100
nation_type::legend
char * legend
Definition nation.h:106
nation_type::barb_type
enum barbarian_type barb_type
Definition nation.h:109
nation_type::server
struct nation_type::@50::@52 server
packet_calendar_info::positive_year_label
char positive_year_label[MAX_LEN_NAME]
Definition packets_gen.h:254
packet_calendar_info::calendar_skip_0
bool calendar_skip_0
Definition packets_gen.h:258
packet_calendar_info::negative_year_label
char negative_year_label[MAX_LEN_NAME]
Definition packets_gen.h:255
packet_calendar_info::calendar_fragments
int calendar_fragments
Definition packets_gen.h:256
packet_calendar_info::calendar_fragment_name
char calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME]
Definition packets_gen.h:257
packet_game_info::tech_steal_allow_holes
bool tech_steal_allow_holes
Definition packets_gen.h:211
packet_game_info::min_trade_route_val
int min_trade_route_val
Definition packets_gen.h:160
packet_game_info::illness_trade_infection
int illness_trade_infection
Definition packets_gen.h:183
packet_game_info::gameloss_style
enum gameloss_style gameloss_style
Definition packets_gen.h:232
packet_game_info::history_interest_pml
int history_interest_pml
Definition packets_gen.h:139
packet_game_info::citizen_partisans_pct
int citizen_partisans_pct
Definition packets_gen.h:146
packet_game_info::celebratesize
int celebratesize
Definition packets_gen.h:140
packet_game_info::goods_selection
enum goods_selection_method goods_selection
Definition packets_gen.h:161
packet_game_info::illness_base_factor
int illness_base_factor
Definition packets_gen.h:179
packet_game_info::illness_min_size
int illness_min_size
Definition packets_gen.h:180
packet_game_info::aifill
int aifill
Definition packets_gen.h:121
packet_game_info::add_to_size_limit
int add_to_size_limit
Definition packets_gen.h:120
packet_game_info::forced_science
int forced_science
Definition packets_gen.h:157
packet_game_info::granary_num_inis
int granary_num_inis
Definition packets_gen.h:174
packet_game_info::government_during_revolution_id
Government_type_id government_during_revolution_id
Definition packets_gen.h:171
packet_game_info::gold_upkeep_style
enum gold_upkeep_style gold_upkeep_style
Definition packets_gen.h:167
packet_game_info::pop_report_zeroes
int pop_report_zeroes
Definition packets_gen.h:142
packet_game_info::damage_reduces_bombard_rate
bool damage_reduces_bombard_rate
Definition packets_gen.h:192
packet_game_info::citizen_nationality
bool citizen_nationality
Definition packets_gen.h:143
packet_game_info::nuke_pop_loss_pct
int nuke_pop_loss_pct
Definition packets_gen.h:197
packet_game_info::nuke_defender_survival_chance_pct
int nuke_defender_survival_chance_pct
Definition packets_gen.h:198
packet_game_info::angrycitizen
int angrycitizen
Definition packets_gen.h:126
packet_game_info::granary_food_inc
int granary_food_inc
Definition packets_gen.h:172
packet_game_info::tech_upkeep_style
enum tech_upkeep_style tech_upkeep_style
Definition packets_gen.h:229
packet_game_info::tech_trade_loss_allow_holes
bool tech_trade_loss_allow_holes
Definition packets_gen.h:213
packet_game_info::granary_food_ini
int granary_food_ini[MAX_GRANARY_INIS]
Definition packets_gen.h:173
packet_game_info::culture_vic_lead
int culture_vic_lead
Definition packets_gen.h:137
packet_game_info::free_tech_method
enum free_tech_method free_tech_method
Definition packets_gen.h:231
packet_game_info::changable_tax
bool changable_tax
Definition packets_gen.h:141
packet_game_info::steal_maps_reveals_all_cities
bool steal_maps_reveals_all_cities
Definition packets_gen.h:209
packet_game_info::init_city_radius_sq
int init_city_radius_sq
Definition packets_gen.h:184
packet_game_info::granularity
int granularity
Definition packets_gen.h:249
packet_game_info::conquest_convert_pct
int conquest_convert_pct
Definition packets_gen.h:145
packet_game_info::muuk_food_wipe
bool muuk_food_wipe
Definition packets_gen.h:200
packet_game_info::tired_attack
bool tired_attack
Definition packets_gen.h:235
packet_game_info::only_real_fight_makes_veteran
bool only_real_fight_makes_veteran
Definition packets_gen.h:190
packet_game_info::low_firepower_pearl_harbour
int low_firepower_pearl_harbour
Definition packets_gen.h:194
packet_game_info::base_pollution
int base_pollution
Definition packets_gen.h:127
packet_game_info::citizen_convert_speed
int citizen_convert_speed
Definition packets_gen.h:144
packet_game_info::forced_gold
int forced_gold
Definition packets_gen.h:155
packet_game_info::illness_pollution_factor
int illness_pollution_factor
Definition packets_gen.h:182
packet_game_info::base_tech_cost
int base_tech_cost
Definition packets_gen.h:128
packet_game_info::happy_cost
int happy_cost
Definition packets_gen.h:176
packet_game_info::civil_war_enabled
bool civil_war_enabled
Definition packets_gen.h:246
packet_game_info::muuk_gold_wipe
bool muuk_gold_wipe
Definition packets_gen.h:201
packet_game_info::food_cost
int food_cost
Definition packets_gen.h:153
packet_game_info::tech_leakage
enum tech_leakage_style tech_leakage
Definition packets_gen.h:227
packet_game_info::airlift_from_always_enabled
bool airlift_from_always_enabled
Definition packets_gen.h:124
packet_game_info::illness_on
bool illness_on
Definition packets_gen.h:181
packet_game_info::civil_war_bonus_unhappy
int civil_war_bonus_unhappy
Definition packets_gen.h:248
packet_game_info::only_killing_makes_veteran
bool only_killing_makes_veteran
Definition packets_gen.h:189
packet_game_info::poison_empties_food_stock
bool poison_empties_food_stock
Definition packets_gen.h:210
packet_game_info::tech_loss_allow_holes
bool tech_loss_allow_holes
Definition packets_gen.h:215
packet_game_info::diplchance_initial_odds
bv_actions diplchance_initial_odds
Definition packets_gen.h:150
packet_game_info::tech_trade_allow_holes
bool tech_trade_allow_holes
Definition packets_gen.h:212
packet_game_info::low_firepower_nonnat_bombard
int low_firepower_nonnat_bombard
Definition packets_gen.h:196
packet_game_info::border_size_effect
int border_size_effect
Definition packets_gen.h:131
packet_game_info::tech_upkeep_divider
int tech_upkeep_divider
Definition packets_gen.h:228
packet_game_info::pillage_select
bool pillage_select
Definition packets_gen.h:208
packet_game_info::tech_parasite_allow_holes
bool tech_parasite_allow_holes
Definition packets_gen.h:214
packet_game_info::muuk_shield_wipe
bool muuk_shield_wipe
Definition packets_gen.h:202
packet_game_info::base_bribe_cost
int base_bribe_cost
Definition packets_gen.h:134
packet_game_info::low_firepower_combat_bonus
int low_firepower_combat_bonus
Definition packets_gen.h:195
packet_game_info::culture_migration_pml
int culture_migration_pml
Definition packets_gen.h:138
packet_game_info::border_city_permanent_radius_sq
int border_city_permanent_radius_sq
Definition packets_gen.h:132
packet_game_info::culture_vic_points
int culture_vic_points
Definition packets_gen.h:136
packet_game_info::low_firepower_badwallattacker
int low_firepower_badwallattacker
Definition packets_gen.h:193
packet_game_info::airlift_to_always_enabled
bool airlift_to_always_enabled
Definition packets_gen.h:125
packet_game_info::small_wonder_visibility
enum wonder_visib_type small_wonder_visibility
Definition packets_gen.h:250
packet_game_info::tech_cost_style
enum tech_cost_style tech_cost_style
Definition packets_gen.h:226
packet_game_info::combat_odds_scaled_veterancy
bool combat_odds_scaled_veterancy
Definition packets_gen.h:191
packet_game_info::civil_war_bonus_celebrating
int civil_war_bonus_celebrating
Definition packets_gen.h:247
packet_game_info::border_city_radius_sq
int border_city_radius_sq
Definition packets_gen.h:130
packet_game_info::default_government_id
Government_type_id default_government_id
Definition packets_gen.h:170
packet_game_info::forced_luxury
int forced_luxury
Definition packets_gen.h:156
packet_game_info::min_city_center_output
int min_city_center_output[O_LAST]
Definition packets_gen.h:199
packet_ruleset_achievement
Definition packets_gen.h:1373
packet_ruleset_achievement::id
int id
Definition packets_gen.h:1374
packet_ruleset_achievement::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1376
packet_ruleset_achievement::unique
bool unique
Definition packets_gen.h:1378
packet_ruleset_achievement::value
int value
Definition packets_gen.h:1379
packet_ruleset_achievement::type
enum achievement_type type
Definition packets_gen.h:1377
packet_ruleset_achievement::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1375
packet_ruleset_action_auto
Definition packets_gen.h:1412
packet_ruleset_action_auto::id
int id
Definition packets_gen.h:1413
packet_ruleset_action_auto::alternatives
action_id alternatives[MAX_NUM_ACTIONS]
Definition packets_gen.h:1418
packet_ruleset_action_auto::reqs_count
int reqs_count
Definition packets_gen.h:1415
packet_ruleset_action_auto::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1416
packet_ruleset_action_auto::alternatives_count
int alternatives_count
Definition packets_gen.h:1417
packet_ruleset_action_auto::cause
enum action_auto_perf_cause cause
Definition packets_gen.h:1414
packet_ruleset_action_enabler
Definition packets_gen.h:1404
packet_ruleset_action_enabler::enabled_action
action_id enabled_action
Definition packets_gen.h:1405
packet_ruleset_action_enabler::actor_reqs_count
int actor_reqs_count
Definition packets_gen.h:1406
packet_ruleset_action_enabler::actor_reqs
struct requirement actor_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1407
packet_ruleset_action_enabler::target_reqs
struct requirement target_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1409
packet_ruleset_action_enabler::target_reqs_count
int target_reqs_count
Definition packets_gen.h:1408
packet_ruleset_action
Definition packets_gen.h:1389
packet_ruleset_action::quiet
bool quiet
Definition packets_gen.h:1392
packet_ruleset_action::sub_tgt_kind
enum action_sub_target_kind sub_tgt_kind
Definition packets_gen.h:1398
packet_ruleset_action::act_kind
enum action_actor_kind act_kind
Definition packets_gen.h:1396
packet_ruleset_action::actor_consuming_always
bool actor_consuming_always
Definition packets_gen.h:1395
packet_ruleset_action::blocked_by
bv_actions blocked_by
Definition packets_gen.h:1401
packet_ruleset_action::max_distance
int max_distance
Definition packets_gen.h:1400
packet_ruleset_action::id
action_id id
Definition packets_gen.h:1390
packet_ruleset_action::min_distance
int min_distance
Definition packets_gen.h:1399
packet_ruleset_action::sub_results
bv_action_sub_results sub_results
Definition packets_gen.h:1394
packet_ruleset_action::ui_name
char ui_name[MAX_LEN_NAME]
Definition packets_gen.h:1391
packet_ruleset_action::tgt_kind
enum action_target_kind tgt_kind
Definition packets_gen.h:1397
packet_ruleset_action::result
enum action_result result
Definition packets_gen.h:1393
packet_ruleset_base
Definition packets_gen.h:1326
packet_ruleset_base::vision_subs_sq
int vision_subs_sq
Definition packets_gen.h:1332
packet_ruleset_base::vision_invis_sq
int vision_invis_sq
Definition packets_gen.h:1331
packet_ruleset_base::border_sq
int border_sq
Definition packets_gen.h:1329
packet_ruleset_base::vision_main_sq
int vision_main_sq
Definition packets_gen.h:1330
packet_ruleset_base::gui_type
enum base_gui_type gui_type
Definition packets_gen.h:1328
packet_ruleset_base::id
int id
Definition packets_gen.h:1327
packet_ruleset_building
Definition packets_gen.h:1203
packet_ruleset_building::flags
bv_impr_flags flags
Definition packets_gen.h:1217
packet_ruleset_building::id
Impr_type_id id
Definition packets_gen.h:1204
packet_ruleset_building::build_cost
int build_cost
Definition packets_gen.h:1214
packet_ruleset_building::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1220
packet_ruleset_building::obs_reqs
struct requirement obs_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1213
packet_ruleset_building::upkeep
int upkeep
Definition packets_gen.h:1215
packet_ruleset_building::soundtag_alt
char soundtag_alt[MAX_LEN_NAME]
Definition packets_gen.h:1219
packet_ruleset_building::reqs_count
int reqs_count
Definition packets_gen.h:1210
packet_ruleset_building::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1211
packet_ruleset_building::genus
enum impr_genus_id genus
Definition packets_gen.h:1205
packet_ruleset_building::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1206
packet_ruleset_building::soundtag
char soundtag[MAX_LEN_NAME]
Definition packets_gen.h:1218
packet_ruleset_building::sabotage
int sabotage
Definition packets_gen.h:1216
packet_ruleset_building::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1207
packet_ruleset_building::obs_count
int obs_count
Definition packets_gen.h:1212
packet_ruleset_building::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition packets_gen.h:1208
packet_ruleset_building::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:1209
packet_ruleset_city
Definition packets_gen.h:1192
packet_ruleset_city::citizens_graphic
char citizens_graphic[MAX_LEN_NAME]
Definition packets_gen.h:1196
packet_ruleset_city::style_id
int style_id
Definition packets_gen.h:1193
packet_ruleset_city::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1194
packet_ruleset_city::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1195
packet_ruleset_city::reqs_count
int reqs_count
Definition packets_gen.h:1197
packet_ruleset_city::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:1200
packet_ruleset_city::graphic
char graphic[MAX_LEN_NAME]
Definition packets_gen.h:1199
packet_ruleset_city::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1198
packet_ruleset_clause
Definition packets_gen.h:1445
packet_ruleset_clause::type
enum clause_type type
Definition packets_gen.h:1446
packet_ruleset_clause::receiver_reqs
struct requirement receiver_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1451
packet_ruleset_clause::receiver_reqs_count
int receiver_reqs_count
Definition packets_gen.h:1450
packet_ruleset_clause::giver_reqs_count
int giver_reqs_count
Definition packets_gen.h:1448
packet_ruleset_clause::enabled
bool enabled
Definition packets_gen.h:1447
packet_ruleset_clause::giver_reqs
struct requirement giver_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1449
packet_ruleset_control::num_goods_types
int num_goods_types
Definition packets_gen.h:1464
packet_ruleset_control::preferred_soundset
char preferred_soundset[MAX_LEN_NAME]
Definition packets_gen.h:1478
packet_ruleset_control::desc_length32
int desc_length32
Definition packets_gen.h:1485
packet_ruleset_control::num_styles
int num_styles
Definition packets_gen.h:1468
packet_ruleset_control::num_extra_types
int num_extra_types
Definition packets_gen.h:1460
packet_ruleset_control::num_unit_types
int num_unit_types
Definition packets_gen.h:1456
packet_ruleset_control::version
char version[MAX_LEN_NAME]
Definition packets_gen.h:1482
packet_ruleset_control::num_impr_types
int num_impr_types
Definition packets_gen.h:1457
packet_ruleset_control::nation_count
int nation_count
Definition packets_gen.h:1471
packet_ruleset_control::num_road_types
int num_road_types
Definition packets_gen.h:1462
packet_ruleset_control::terrain_count
int terrain_count
Definition packets_gen.h:1473
packet_ruleset_control::preferred_tileset
char preferred_tileset[MAX_LEN_NAME]
Definition packets_gen.h:1477
packet_ruleset_control::popup_tech_help
bool popup_tech_help
Definition packets_gen.h:1480
packet_ruleset_control::num_music_styles
int num_music_styles
Definition packets_gen.h:1469
packet_ruleset_control::num_tech_types
int num_tech_types
Definition packets_gen.h:1459
packet_ruleset_control::styles_count
int styles_count
Definition packets_gen.h:1472
packet_ruleset_control::num_disaster_types
int num_disaster_types
Definition packets_gen.h:1465
packet_ruleset_control::alt_dir
char alt_dir[MAX_LEN_NAME]
Definition packets_gen.h:1483
packet_ruleset_control::num_achievement_types
int num_achievement_types
Definition packets_gen.h:1466
packet_ruleset_control::num_specialist_types
int num_specialist_types
Definition packets_gen.h:1474
packet_ruleset_control::preferred_musicset
char preferred_musicset[MAX_LEN_NAME]
Definition packets_gen.h:1479
packet_ruleset_control::num_tech_classes
int num_tech_classes
Definition packets_gen.h:1458
packet_ruleset_control::num_unit_classes
int num_unit_classes
Definition packets_gen.h:1455
packet_ruleset_control::num_resource_types
int num_resource_types
Definition packets_gen.h:1463
packet_ruleset_control::num_multipliers
int num_multipliers
Definition packets_gen.h:1467
packet_ruleset_control::desc_length16
int desc_length16
Definition packets_gen.h:1484
packet_ruleset_control::num_nation_sets
int num_nation_sets
Definition packets_gen.h:1476
packet_ruleset_control::num_nation_groups
int num_nation_groups
Definition packets_gen.h:1475
packet_ruleset_control::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1481
packet_ruleset_control::num_base_types
int num_base_types
Definition packets_gen.h:1461
packet_ruleset_description_part
Definition packets_gen.h:1492
packet_ruleset_disaster
Definition packets_gen.h:1363
packet_ruleset_disaster::frequency
int frequency
Definition packets_gen.h:1369
packet_ruleset_disaster::id
int id
Definition packets_gen.h:1364
packet_ruleset_disaster::reqs_count
int reqs_count
Definition packets_gen.h:1367
packet_ruleset_disaster::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1366
packet_ruleset_disaster::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1368
packet_ruleset_disaster::effects
bv_disaster_effects effects
Definition packets_gen.h:1370
packet_ruleset_disaster::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1365
packet_ruleset_extra_flag
Definition packets_gen.h:1320
packet_ruleset_extra_flag::helptxt
char helptxt[MAX_LEN_PACKET]
Definition packets_gen.h:1323
packet_ruleset_extra_flag::id
int id
Definition packets_gen.h:1321
packet_ruleset_extra_flag::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1322
packet_ruleset_extra
Definition packets_gen.h:1278
packet_ruleset_extra::id
int id
Definition packets_gen.h:1279
packet_ruleset_extra::removal_time
int removal_time
Definition packets_gen.h:1307
packet_ruleset_extra::defense_bonus
int defense_bonus
Definition packets_gen.h:1310
packet_ruleset_extra::infracost
int infracost
Definition packets_gen.h:1309
packet_ruleset_extra::native_to
bv_unit_classes native_to
Definition packets_gen.h:1312
packet_ruleset_extra::appearance_reqs_count
int appearance_reqs_count
Definition packets_gen.h:1297
packet_ruleset_extra::build_time_factor
int build_time_factor
Definition packets_gen.h:1306
packet_ruleset_extra::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1293
packet_ruleset_extra::generated
bool generated
Definition packets_gen.h:1304
packet_ruleset_extra::disappearance_reqs_count
int disappearance_reqs_count
Definition packets_gen.h:1300
packet_ruleset_extra::appearance_chance
int appearance_chance
Definition packets_gen.h:1296
packet_ruleset_extra::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:1291
packet_ruleset_extra::rmcauses
bv_rmcauses rmcauses
Definition packets_gen.h:1284
packet_ruleset_extra::act_gfx_alt2
char act_gfx_alt2[MAX_LEN_NAME]
Definition packets_gen.h:1287
packet_ruleset_extra::removal_time_factor
int removal_time_factor
Definition packets_gen.h:1308
packet_ruleset_extra::reqs_count
int reqs_count
Definition packets_gen.h:1292
packet_ruleset_extra::buildable
bool buildable
Definition packets_gen.h:1303
packet_ruleset_extra::disappearance_reqs
struct requirement disappearance_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1301
packet_ruleset_extra::flags
bv_extra_flags flags
Definition packets_gen.h:1313
packet_ruleset_extra::act_gfx_alt
char act_gfx_alt[MAX_LEN_NAME]
Definition packets_gen.h:1286
packet_ruleset_extra::hidden_by
bv_extras hidden_by
Definition packets_gen.h:1314
packet_ruleset_extra::activity_gfx
char activity_gfx[MAX_LEN_NAME]
Definition packets_gen.h:1285
packet_ruleset_extra::build_time
int build_time
Definition packets_gen.h:1305
packet_ruleset_extra::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1281
packet_ruleset_extra::eus
enum extra_unit_seen_type eus
Definition packets_gen.h:1311
packet_ruleset_extra::appearance_reqs
struct requirement appearance_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1298
packet_ruleset_extra::category
int category
Definition packets_gen.h:1282
packet_ruleset_extra::disappearance_chance
int disappearance_chance
Definition packets_gen.h:1299
packet_ruleset_extra::rmreqs_count
int rmreqs_count
Definition packets_gen.h:1294
packet_ruleset_extra::bridged_over
bv_extras bridged_over
Definition packets_gen.h:1315
packet_ruleset_extra::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1280
packet_ruleset_extra::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition packets_gen.h:1290
packet_ruleset_extra::rmact_gfx_alt
char rmact_gfx_alt[MAX_LEN_NAME]
Definition packets_gen.h:1289
packet_ruleset_extra::rmact_gfx
char rmact_gfx[MAX_LEN_NAME]
Definition packets_gen.h:1288
packet_ruleset_extra::conflicts
bv_extras conflicts
Definition packets_gen.h:1316
packet_ruleset_extra::rmreqs
struct requirement rmreqs[MAX_NUM_REQS]
Definition packets_gen.h:1295
packet_ruleset_extra::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1317
packet_ruleset_extra::visibility_req
int visibility_req
Definition packets_gen.h:1302
packet_ruleset_extra::causes
bv_causes causes
Definition packets_gen.h:1283
packet_ruleset_game
Definition packets_gen.h:1043
packet_ruleset_game::work_raise_chance
int work_raise_chance[MAX_VET_LEVELS]
Definition packets_gen.h:1054
packet_ruleset_game::base_raise_chance
int base_raise_chance[MAX_VET_LEVELS]
Definition packets_gen.h:1053
packet_ruleset_game::global_init_techs
int global_init_techs[MAX_NUM_TECH_LIST]
Definition packets_gen.h:1046
packet_ruleset_game::veteran_levels
int veteran_levels
Definition packets_gen.h:1049
packet_ruleset_game::move_bonus
int move_bonus[MAX_VET_LEVELS]
Definition packets_gen.h:1052
packet_ruleset_game::global_init_techs_count
int global_init_techs_count
Definition packets_gen.h:1045
packet_ruleset_game::background_red
int background_red
Definition packets_gen.h:1055
packet_ruleset_game::veteran_name
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
Definition packets_gen.h:1050
packet_ruleset_game::global_init_buildings
Impr_type_id global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition packets_gen.h:1048
packet_ruleset_game::global_init_buildings_count
int global_init_buildings_count
Definition packets_gen.h:1047
packet_ruleset_game::default_specialist
int default_specialist
Definition packets_gen.h:1044
packet_ruleset_game::background_green
int background_green
Definition packets_gen.h:1056
packet_ruleset_game::power_fact
int power_fact[MAX_VET_LEVELS]
Definition packets_gen.h:1051
packet_ruleset_game::background_blue
int background_blue
Definition packets_gen.h:1057
packet_ruleset_goods
Definition packets_gen.h:1350
packet_ruleset_goods::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1360
packet_ruleset_goods::flags
bv_goods_flags flags
Definition packets_gen.h:1359
packet_ruleset_goods::from_pct
int from_pct
Definition packets_gen.h:1356
packet_ruleset_goods::onetime_pct
int onetime_pct
Definition packets_gen.h:1358
packet_ruleset_goods::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1352
packet_ruleset_goods::reqs_count
int reqs_count
Definition packets_gen.h:1354
packet_ruleset_goods::to_pct
int to_pct
Definition packets_gen.h:1357
packet_ruleset_goods::id
int id
Definition packets_gen.h:1351
packet_ruleset_goods::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1353
packet_ruleset_goods::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1355
packet_ruleset_government_ruler_title
Definition packets_gen.h:1072
packet_ruleset_government_ruler_title::gov
Government_type_id gov
Definition packets_gen.h:1073
packet_ruleset_government
Definition packets_gen.h:1109
packet_ruleset_multiplier
Definition packets_gen.h:1429
packet_ruleset_multiplier::stop
int stop
Definition packets_gen.h:1432
packet_ruleset_multiplier::step
int step
Definition packets_gen.h:1433
packet_ruleset_multiplier::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1438
packet_ruleset_multiplier::id
Multiplier_type_id id
Definition packets_gen.h:1430
packet_ruleset_multiplier::offset
int offset
Definition packets_gen.h:1435
packet_ruleset_multiplier::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1441
packet_ruleset_multiplier::def
int def
Definition packets_gen.h:1434
packet_ruleset_multiplier::start
int start
Definition packets_gen.h:1431
packet_ruleset_multiplier::minimum_turns
int minimum_turns
Definition packets_gen.h:1437
packet_ruleset_multiplier::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1439
packet_ruleset_multiplier::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1442
packet_ruleset_multiplier::factor
int factor
Definition packets_gen.h:1436
packet_ruleset_multiplier::reqs_count
int reqs_count
Definition packets_gen.h:1440
packet_ruleset_music
Definition packets_gen.h:1421
packet_ruleset_music::music_combat
char music_combat[MAX_LEN_NAME]
Definition packets_gen.h:1424
packet_ruleset_music::id
int id
Definition packets_gen.h:1422
packet_ruleset_music::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1426
packet_ruleset_music::reqs_count
int reqs_count
Definition packets_gen.h:1425
packet_ruleset_music::music_peaceful
char music_peaceful[MAX_LEN_NAME]
Definition packets_gen.h:1423
packet_ruleset_nation_groups
Definition packets_gen.h:1146
packet_ruleset_nation_groups::ngroups
int ngroups
Definition packets_gen.h:1147
packet_ruleset_nation_groups::groups
char groups[MAX_NUM_NATION_GROUPS][MAX_LEN_NAME]
Definition packets_gen.h:1148
packet_ruleset_nation_groups::hidden
bool hidden[MAX_NUM_NATION_GROUPS]
Definition packets_gen.h:1149
packet_ruleset_nation_sets
Definition packets_gen.h:1139
packet_ruleset_nation_sets::rule_names
char rule_names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
Definition packets_gen.h:1142
packet_ruleset_nation_sets::names
char names[MAX_NUM_NATION_SETS][MAX_LEN_NAME]
Definition packets_gen.h:1141
packet_ruleset_nation_sets::nsets
int nsets
Definition packets_gen.h:1140
packet_ruleset_nation_sets::descriptions
char descriptions[MAX_NUM_NATION_SETS][MAX_LEN_MSG]
Definition packets_gen.h:1143
packet_ruleset_nation
Definition packets_gen.h:1152
packet_ruleset_nation::ngroups
int ngroups
Definition packets_gen.h:1169
packet_ruleset_nation::init_techs
int init_techs[MAX_NUM_TECH_LIST]
Definition packets_gen.h:1173
packet_ruleset_nation::leader_name
char leader_name[MAX_NUM_LEADERS][MAX_LEN_NAME]
Definition packets_gen.h:1163
packet_ruleset_nation::style
int style
Definition packets_gen.h:1161
packet_ruleset_nation::is_playable
bool is_playable
Definition packets_gen.h:1165
packet_ruleset_nation::id
Nation_type_id id
Definition packets_gen.h:1153
packet_ruleset_nation::noun_plural
char noun_plural[MAX_LEN_NAME]
Definition packets_gen.h:1157
packet_ruleset_nation::init_units_count
int init_units_count
Definition packets_gen.h:1174
packet_ruleset_nation::adjective
char adjective[MAX_LEN_NAME]
Definition packets_gen.h:1155
packet_ruleset_nation::init_buildings
Impr_type_id init_buildings[MAX_NUM_BUILDING_LIST]
Definition packets_gen.h:1177
packet_ruleset_nation::init_units
Unit_type_id init_units[MAX_NUM_UNIT_LIST]
Definition packets_gen.h:1175
packet_ruleset_nation::init_techs_count
int init_techs_count
Definition packets_gen.h:1172
packet_ruleset_nation::leader_is_male
bool leader_is_male[MAX_NUM_LEADERS]
Definition packets_gen.h:1164
packet_ruleset_nation::translation_domain
char translation_domain[MAX_LEN_NAME]
Definition packets_gen.h:1154
packet_ruleset_nation::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition packets_gen.h:1158
packet_ruleset_nation::init_government_id
Government_type_id init_government_id
Definition packets_gen.h:1171
packet_ruleset_nation::leader_count
int leader_count
Definition packets_gen.h:1162
packet_ruleset_nation::groups
int groups[MAX_NUM_NATION_GROUPS]
Definition packets_gen.h:1170
packet_ruleset_nation::barbarian_type
enum barbarian_type barbarian_type
Definition packets_gen.h:1166
packet_ruleset_nation::sets
int sets[MAX_NUM_NATION_SETS]
Definition packets_gen.h:1168
packet_ruleset_nation::init_buildings_count
int init_buildings_count
Definition packets_gen.h:1176
packet_ruleset_nation::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:1159
packet_ruleset_nation::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1156
packet_ruleset_nation::legend
char legend[MAX_LEN_MSG]
Definition packets_gen.h:1160
packet_ruleset_nation::nsets
int nsets
Definition packets_gen.h:1167
packet_ruleset_resource
Definition packets_gen.h:1599
packet_ruleset_resource::id
int id
Definition packets_gen.h:1600
packet_ruleset_resource::output
int output[O_LAST]
Definition packets_gen.h:1601
packet_ruleset_road
Definition packets_gen.h:1335
packet_ruleset_road::flags
bv_road_flags flags
Definition packets_gen.h:1347
packet_ruleset_road::tile_incr_const
int tile_incr_const[O_LAST]
Definition packets_gen.h:1342
packet_ruleset_road::gui_type
enum road_gui_type gui_type
Definition packets_gen.h:1337
packet_ruleset_road::integrates
bv_max_extras integrates
Definition packets_gen.h:1346
packet_ruleset_road::move_cost
int move_cost
Definition packets_gen.h:1340
packet_ruleset_road::compat
enum road_compat compat
Definition packets_gen.h:1345
packet_ruleset_road::move_mode
enum road_move_mode move_mode
Definition packets_gen.h:1341
packet_ruleset_road::first_reqs_count
int first_reqs_count
Definition packets_gen.h:1338
packet_ruleset_road::tile_bonus
int tile_bonus[O_LAST]
Definition packets_gen.h:1344
packet_ruleset_road::tile_incr
int tile_incr[O_LAST]
Definition packets_gen.h:1343
packet_ruleset_road::id
int id
Definition packets_gen.h:1336
packet_ruleset_road::first_reqs
struct requirement first_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1339
packet_ruleset_specialist
Definition packets_gen.h:1060
packet_ruleset_specialist::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1063
packet_ruleset_specialist::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:1066
packet_ruleset_specialist::reqs
struct requirement reqs[MAX_NUM_REQS]
Definition packets_gen.h:1068
packet_ruleset_specialist::id
Specialist_type_id id
Definition packets_gen.h:1061
packet_ruleset_specialist::reqs_count
int reqs_count
Definition packets_gen.h:1067
packet_ruleset_specialist::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1069
packet_ruleset_specialist::short_name
char short_name[MAX_LEN_NAME]
Definition packets_gen.h:1064
packet_ruleset_specialist::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition packets_gen.h:1065
packet_ruleset_specialist::plural_name
char plural_name[MAX_LEN_NAME]
Definition packets_gen.h:1062
packet_ruleset_style
Definition packets_gen.h:1186
packet_ruleset_style::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1188
packet_ruleset_style::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1189
packet_ruleset_style::id
int id
Definition packets_gen.h:1187
packet_ruleset_summary
Definition packets_gen.h:1488
packet_ruleset_summary::text
char text[MAX_LEN_CONTENT]
Definition packets_gen.h:1489
packet_ruleset_tech_class
Definition packets_gen.h:1096
packet_ruleset_tech_class::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1098
packet_ruleset_tech_class::id
int id
Definition packets_gen.h:1097
packet_ruleset_tech_class::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1099
packet_ruleset_tech_class::cost_pct
int cost_pct
Definition packets_gen.h:1100
packet_ruleset_tech_flag
Definition packets_gen.h:1103
packet_ruleset_tech_flag::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1105
packet_ruleset_tech_flag::id
int id
Definition packets_gen.h:1104
packet_ruleset_tech_flag::helptxt
char helptxt[MAX_LEN_PACKET]
Definition packets_gen.h:1106
packet_ruleset_tech
Definition packets_gen.h:1079
packet_ruleset_tech::research_reqs_count
int research_reqs_count
Definition packets_gen.h:1082
packet_ruleset_tech::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1089
packet_ruleset_tech::removed
bool removed
Definition packets_gen.h:1085
packet_ruleset_tech::research_reqs
struct requirement research_reqs[MAX_NUM_REQS]
Definition packets_gen.h:1083
packet_ruleset_tech::id
int id
Definition packets_gen.h:1080
packet_ruleset_tech::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition packets_gen.h:1092
packet_ruleset_tech::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1090
packet_ruleset_tech::num_reqs
int num_reqs
Definition packets_gen.h:1088
packet_ruleset_tech::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:1093
packet_ruleset_tech::flags
bv_tech_flags flags
Definition packets_gen.h:1086
packet_ruleset_tech::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1091
packet_ruleset_tech::tclass
int tclass
Definition packets_gen.h:1084
packet_ruleset_tech::root_req
int root_req
Definition packets_gen.h:1081
packet_ruleset_tech::cost
float cost
Definition packets_gen.h:1087
packet_ruleset_terrain_flag
Definition packets_gen.h:1261
packet_ruleset_terrain_flag::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1263
packet_ruleset_terrain_flag::id
int id
Definition packets_gen.h:1262
packet_ruleset_terrain_flag::helptxt
char helptxt[MAX_LEN_PACKET]
Definition packets_gen.h:1264
packet_ruleset_terrain
Definition packets_gen.h:1223
packet_ruleset_terrain::cultivate_time
int cultivate_time
Definition packets_gen.h:1241
packet_ruleset_terrain::irrigation_food_incr
int irrigation_food_incr
Definition packets_gen.h:1244
packet_ruleset_terrain::base_time
int base_time
Definition packets_gen.h:1238
packet_ruleset_terrain::transform_result
Terrain_type_id transform_result
Definition packets_gen.h:1249
packet_ruleset_terrain::tclass
int tclass
Definition packets_gen.h:1225
packet_ruleset_terrain::mining_shield_incr
int mining_shield_incr
Definition packets_gen.h:1246
packet_ruleset_terrain::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1258
packet_ruleset_terrain::clean_fallout_time
int clean_fallout_time
Definition packets_gen.h:1253
packet_ruleset_terrain::irrigation_time
int irrigation_time
Definition packets_gen.h:1245
packet_ruleset_terrain::placing_time
int placing_time
Definition packets_gen.h:1251
packet_ruleset_terrain::flags
bv_terrain_flags flags
Definition packets_gen.h:1226
packet_ruleset_terrain::transform_time
int transform_time
Definition packets_gen.h:1250
packet_ruleset_terrain::defense_bonus
int defense_bonus
Definition packets_gen.h:1233
packet_ruleset_terrain::resources
Resource_type_id resources[MAX_RESOURCE_TYPES]
Definition packets_gen.h:1236
packet_ruleset_terrain::plant_time
int plant_time
Definition packets_gen.h:1243
packet_ruleset_terrain::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition packets_gen.h:1230
packet_ruleset_terrain::num_resources
int num_resources
Definition packets_gen.h:1235
packet_ruleset_terrain::output
int output[O_LAST]
Definition packets_gen.h:1234
packet_ruleset_terrain::animal
int animal
Definition packets_gen.h:1248
packet_ruleset_terrain::color_red
int color_red
Definition packets_gen.h:1255
packet_ruleset_terrain::native_to
bv_unit_classes native_to
Definition packets_gen.h:1227
packet_ruleset_terrain::pillage_time
int pillage_time
Definition packets_gen.h:1254
packet_ruleset_terrain::cultivate_result
Terrain_type_id cultivate_result
Definition packets_gen.h:1240
packet_ruleset_terrain::color_green
int color_green
Definition packets_gen.h:1256
packet_ruleset_terrain::road_time
int road_time
Definition packets_gen.h:1239
packet_ruleset_terrain::plant_result
Terrain_type_id plant_result
Definition packets_gen.h:1242
packet_ruleset_terrain::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1228
packet_ruleset_terrain::clean_pollution_time
int clean_pollution_time
Definition packets_gen.h:1252
packet_ruleset_terrain::road_output_incr_pct
int road_output_incr_pct[O_LAST]
Definition packets_gen.h:1237
packet_ruleset_terrain::movement_cost
int movement_cost
Definition packets_gen.h:1232
packet_ruleset_terrain::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:1231
packet_ruleset_terrain::mining_time
int mining_time
Definition packets_gen.h:1247
packet_ruleset_terrain::id
Terrain_type_id id
Definition packets_gen.h:1224
packet_ruleset_terrain::color_blue
int color_blue
Definition packets_gen.h:1257
packet_ruleset_terrain::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1229
packet_ruleset_trade
Definition packets_gen.h:1382
packet_ruleset_trade::cancelling
enum trade_route_illegal_cancelling cancelling
Definition packets_gen.h:1385
packet_ruleset_trade::trade_pct
int trade_pct
Definition packets_gen.h:1384
packet_ruleset_trade::id
int id
Definition packets_gen.h:1383
packet_ruleset_trade::bonus_type
enum trade_route_bonus_type bonus_type
Definition packets_gen.h:1386
packet_ruleset_unit_bonus
Definition packets_gen.h:1023
packet_ruleset_unit_bonus::type
enum combat_bonus_type type
Definition packets_gen.h:1026
packet_ruleset_unit_bonus::unit
Unit_type_id unit
Definition packets_gen.h:1024
packet_ruleset_unit_bonus::quiet
bool quiet
Definition packets_gen.h:1028
packet_ruleset_unit_bonus::value
int value
Definition packets_gen.h:1027
packet_ruleset_unit_bonus::flag
enum unit_type_flag_id flag
Definition packets_gen.h:1025
packet_ruleset_unit_class_flag
Definition packets_gen.h:1037
packet_ruleset_unit_class_flag::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1039
packet_ruleset_unit_class_flag::helptxt
char helptxt[MAX_LEN_PACKET]
Definition packets_gen.h:1040
packet_ruleset_unit_class_flag::id
int id
Definition packets_gen.h:1038
packet_ruleset_unit_class
Definition packets_gen.h:1267
packet_ruleset_unit_class::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:1270
packet_ruleset_unit_class::flags
bv_unit_class_flags flags
Definition packets_gen.h:1274
packet_ruleset_unit_class::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1269
packet_ruleset_unit_class::non_native_def_pct
int non_native_def_pct
Definition packets_gen.h:1273
packet_ruleset_unit_class::hp_loss_pct
int hp_loss_pct
Definition packets_gen.h:1272
packet_ruleset_unit_class::id
int id
Definition packets_gen.h:1268
packet_ruleset_unit_class::min_speed
int min_speed
Definition packets_gen.h:1271
packet_ruleset_unit_class::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1275
packet_ruleset_unit_flag
Definition packets_gen.h:1031
packet_ruleset_unit_flag::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:1033
packet_ruleset_unit_flag::id
int id
Definition packets_gen.h:1032
packet_ruleset_unit_flag::helptxt
char helptxt[MAX_LEN_PACKET]
Definition packets_gen.h:1034
packet_ruleset_unit
Definition packets_gen.h:972
packet_ruleset_unit::paratroopers_range
int paratroopers_range
Definition packets_gen.h:1001
packet_ruleset_unit::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition packets_gen.h:977
packet_ruleset_unit::vlayer
enum vision_layer vlayer
Definition packets_gen.h:1016
packet_ruleset_unit::tp_defense
enum transp_def_type tp_defense
Definition packets_gen.h:1011
packet_ruleset_unit::unit_class_id
int unit_class_id
Definition packets_gen.h:982
packet_ruleset_unit::rule_name
char rule_name[MAX_LEN_NAME]
Definition packets_gen.h:975
packet_ruleset_unit::vision_radius_sq
int vision_radius_sq
Definition packets_gen.h:991
packet_ruleset_unit::obsoleted_by
int obsoleted_by
Definition packets_gen.h:995
packet_ruleset_unit::upkeep
int upkeep[O_LAST]
Definition packets_gen.h:1000
packet_ruleset_unit::power_fact
int power_fact[MAX_VET_LEVELS]
Definition packets_gen.h:1004
packet_ruleset_unit::name
char name[MAX_LEN_NAME]
Definition packets_gen.h:974
packet_ruleset_unit::hp
int hp
Definition packets_gen.h:993
packet_ruleset_unit::pop_cost
int pop_cost
Definition packets_gen.h:984
packet_ruleset_unit::city_slots
int city_slots
Definition packets_gen.h:1010
packet_ruleset_unit::firepower
int firepower
Definition packets_gen.h:994
packet_ruleset_unit::fuel
int fuel
Definition packets_gen.h:998
packet_ruleset_unit::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition packets_gen.h:976
packet_ruleset_unit::convert_time
int convert_time
Definition packets_gen.h:997
packet_ruleset_unit::sound_fight_alt
char sound_fight_alt[MAX_LEN_NAME]
Definition packets_gen.h:981
packet_ruleset_unit::disembarks
bv_unit_classes disembarks
Definition packets_gen.h:1015
packet_ruleset_unit::veteran_levels
int veteran_levels
Definition packets_gen.h:1002
packet_ruleset_unit::move_rate
int move_rate
Definition packets_gen.h:987
packet_ruleset_unit::attack_strength
int attack_strength
Definition packets_gen.h:985
packet_ruleset_unit::cargo
bv_unit_classes cargo
Definition packets_gen.h:1012
packet_ruleset_unit::build_cost
int build_cost
Definition packets_gen.h:983
packet_ruleset_unit::transport_capacity
int transport_capacity
Definition packets_gen.h:992
packet_ruleset_unit::flags
bv_unit_type_flags flags
Definition packets_gen.h:1018
packet_ruleset_unit::sound_move_alt
char sound_move_alt[MAX_LEN_NAME]
Definition packets_gen.h:979
packet_ruleset_unit::happy_cost
int happy_cost
Definition packets_gen.h:999
packet_ruleset_unit::worker
bool worker
Definition packets_gen.h:1020
packet_ruleset_unit::targets
bv_unit_classes targets
Definition packets_gen.h:1013
packet_ruleset_unit::tech_requirement
int tech_requirement
Definition packets_gen.h:988
packet_ruleset_unit::defense_strength
int defense_strength
Definition packets_gen.h:986
packet_ruleset_unit::build_reqs
struct requirement build_reqs[MAX_NUM_REQS]
Definition packets_gen.h:990
packet_ruleset_unit::base_raise_chance
int base_raise_chance[MAX_VET_LEVELS]
Definition packets_gen.h:1006
packet_ruleset_unit::work_raise_chance
int work_raise_chance[MAX_VET_LEVELS]
Definition packets_gen.h:1007
packet_ruleset_unit::sound_fight
char sound_fight[MAX_LEN_NAME]
Definition packets_gen.h:980
packet_ruleset_unit::embarks
bv_unit_classes embarks
Definition packets_gen.h:1014
packet_ruleset_unit::build_reqs_count
int build_reqs_count
Definition packets_gen.h:989
packet_ruleset_unit::city_size
int city_size
Definition packets_gen.h:1009
packet_ruleset_unit::bombard_rate
int bombard_rate
Definition packets_gen.h:1008
packet_ruleset_unit::veteran_name
char veteran_name[MAX_VET_LEVELS][MAX_LEN_NAME]
Definition packets_gen.h:1003
packet_ruleset_unit::converted_to
int converted_to
Definition packets_gen.h:996
packet_ruleset_unit::sound_move
char sound_move[MAX_LEN_NAME]
Definition packets_gen.h:978
packet_ruleset_unit::helptext
char helptext[MAX_LEN_PACKET]
Definition packets_gen.h:1017
packet_ruleset_unit::roles
bv_unit_type_roles roles
Definition packets_gen.h:1019
packet_ruleset_unit::id
Unit_type_id id
Definition packets_gen.h:973
packet_ruleset_unit::move_bonus
int move_bonus[MAX_VET_LEVELS]
Definition packets_gen.h:1005
packet_team_name_info
Definition packets_gen.h:276
packet_team_name_info::team_name
char team_name[MAX_LEN_NAME]
Definition packets_gen.h:278
packet_team_name_info::team_id
int team_id
Definition packets_gen.h:277
packet_web_ruleset_unit_addition
Definition packets_gen.h:1878
packet_web_ruleset_unit_addition::utype_actions
bv_actions utype_actions
Definition packets_gen.h:1880
packet_web_ruleset_unit_addition::id
Unit_type_id id
Definition packets_gen.h:1879
part
Definition goto.c:52
range
Definition unittype.c:931
req_vec_change::operation
enum req_vec_change_operation operation
Definition requirements.h:281
req_vec_change::req
struct requirement req
Definition requirements.h:282
req_vec_problem
Definition requirements.h:287
req_vec_problem::num_suggested_solutions
int num_suggested_solutions
Definition requirements.h:293
req_vec_problem::suggested_solutions
struct req_vec_change * suggested_solutions
Definition requirements.h:294
requirement
Definition requirements.h:80
requirement::quiet
bool quiet
Definition requirements.h:85
requirement::survives
bool survives
Definition requirements.h:83
requirement::present
bool present
Definition requirements.h:84
requirement::source
struct universal source
Definition requirements.h:81
rgbcolor
Definition rgbcolor.h:33
rgbcolor::g
int g
Definition rgbcolor.h:34
rgbcolor::b
int b
Definition rgbcolor.h:34
rgbcolor::r
int r
Definition rgbcolor.h:34
road_type
Definition road.h:75
road_type::gui_type
enum road_gui_type gui_type
Definition road.h:84
road_type::first_reqs
struct requirement_vector first_reqs
Definition road.h:86
road_type::move_mode
enum road_move_mode move_mode
Definition road.h:79
road_type::tile_bonus
int tile_bonus[O_LAST]
Definition road.h:82
road_type::tile_incr_const
int tile_incr_const[O_LAST]
Definition road.h:80
road_type::tile_incr
int tile_incr[O_LAST]
Definition road.h:81
road_type::flags
bv_road_flags flags
Definition road.h:89
road_type::move_cost
int move_cost
Definition road.h:78
road_type::compat
enum road_compat compat
Definition road.h:83
road_type::integrates
bv_max_extras integrates
Definition road.h:88
rscompat_info
Definition rscompat.h:29
rscompat_info::compat_mode
bool compat_mode
Definition rscompat.h:30
rscompat_info::log_cb
rs_conversion_logger log_cb
Definition rscompat.h:31
section_file
Definition section_file.h:36
section
Definition section_file.h:28
server
Definition servers.h:29
specialist
Definition specialist.h:29
specialist::reqs
struct requirement_vector reqs
Definition specialist.h:38
specialist::graphic_alt
char graphic_alt[MAX_LEN_NAME]
Definition specialist.h:36
specialist::helptext
struct strvec * helptext
Definition specialist.h:40
specialist::graphic_str
char graphic_str[MAX_LEN_NAME]
Definition specialist.h:35
specialist::name
struct name_translation name
Definition specialist.h:31
specialist::abbreviation
struct name_translation abbreviation
Definition specialist.h:32
strvec
Definition string_vector.c:29
strvec::vec
char ** vec
Definition string_vector.c:30
terrain
Definition terrain.h:176
trade_route_settings
Definition traderoutes.h:75
trade_route_settings::bonus_type
enum trade_route_bonus_type bonus_type
Definition traderoutes.h:78
trade_route_settings::trade_pct
int trade_pct
Definition traderoutes.h:76
trade_route_settings::cancelling
enum trade_route_illegal_cancelling cancelling
Definition traderoutes.h:77
trait_limits
Definition traits.h:43
trait_limits::fixed
int fixed
Definition traits.h:46
trait_limits::min
int min
Definition traits.h:44
trait_limits::max
int max
Definition traits.h:45
unit_class
Definition unittype.h:136
unit_type
Definition unittype.h:481
universal::kind
enum universals_n kind
Definition fc_types.h:758
veteran_level
Definition unittype.h:467
veteran_level::power_fact
int power_fact
Definition unittype.h:469
veteran_level::base_raise_chance
int base_raise_chance
Definition unittype.h:471
veteran_level::name
struct name_translation name
Definition unittype.h:468
veteran_level::move_bonus
int move_bonus
Definition unittype.h:470
veteran_level::work_raise_chance
int work_raise_chance
Definition unittype.h:472
veteran_system
Definition unittype.h:475
veteran_system::definitions
struct veteran_level * definitions
Definition unittype.h:478
veteran_system::levels
int levels
Definition unittype.h:476
world::map
struct civ_map map
Definition world_object.h:38
style_by_rule_name
struct nation_style * style_by_rule_name(const char *name)
Definition style.c:117
style_by_number
struct nation_style * style_by_number(int id)
Definition style.c:88
styles_alloc
void styles_alloc(int count)
Definition style.c:36
music_style_by_number
struct music_style * music_style_by_number(int id)
Definition style.c:171
style_number
int style_number(const struct nation_style *pstyle)
Definition style.c:68
music_styles_alloc
void music_styles_alloc(int count)
Definition style.c:133
style_index
int style_index(const struct nation_style *pstyle)
Definition style.c:78
style.h
music_styles_iterate
#define music_styles_iterate(_p)
Definition style.h:72
music_styles_iterate_end
#define music_styles_iterate_end
Definition style.h:79
styles_iterate
#define styles_iterate(_p)
Definition style.h:46
styles_iterate_end
#define styles_iterate_end
Definition style.h:52
fc_snprintf
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
fc_strlcpy
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:787
fc_strcasecmp
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:189
fc_isspace
bool fc_isspace(char c)
Definition support.c:1249
fc_strlcat
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:832
fc_vsnprintf
int fc_vsnprintf(char *str, size_t n, const char *format, va_list ap)
Definition support.c:896
fc_tolower
char fc_tolower(char c)
Definition support.c:1282
support.h
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:161
RETURN_VALUE_AFTER_EXIT
#define RETURN_VALUE_AFTER_EXIT(_val_)
Definition support.h:121
fc__attribute
#define fc__attribute(x)
Definition support.h:89
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
team_slot_by_number
struct team_slot * team_slot_by_number(int team_id)
Definition team.c:175
team_slot_defined_name
const char * team_slot_defined_name(const struct team_slot *tslot)
Definition team.c:277
team_slot_index
int team_slot_index(const struct team_slot *tslot)
Definition team.c:138
team_slot_count
int team_slot_count(void)
Definition team.c:112
team_slot_set_defined_name
void team_slot_set_defined_name(struct team_slot *tslot, const char *team_name)
Definition team.c:288
team_slots_iterate_end
#define team_slots_iterate_end
Definition team.h:75
team_slots_iterate
#define team_slots_iterate(_tslot)
Definition team.h:70
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:423
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:394
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_rule_name
const char * advance_rule_name(const struct advance *padvance)
Definition tech.c:299
tech_flag_helptxt
const char * tech_flag_helptxt(enum tech_flag_id id)
Definition tech.c:435
advance_by_rule_name
struct advance * advance_by_rule_name(const char *name)
Definition tech.c:200
tech_class_by_rule_name
struct tech_class * tech_class_by_rule_name(const char *name)
Definition tech.c:351
advance_number
Tech_type_id advance_number(const struct advance *padvance)
Definition tech.c:98
tech.h
tech_class_index
#define tech_class_index(_ptclass_)
Definition tech.h:193
A_NEVER
#define A_NEVER
Definition tech.h:51
tech_class_iterate_end
#define tech_class_iterate_end
Definition tech.h:204
MAX_NUM_USER_TECH_FLAGS
#define MAX_NUM_USER_TECH_FLAGS
Definition tech.h:108
AR_TWO
@ AR_TWO
Definition tech.h:112
AR_ROOT
@ AR_ROOT
Definition tech.h:113
AR_ONE
@ AR_ONE
Definition tech.h:111
advance_iterate
#define advance_iterate(_start, _p)
Definition tech.h:264
advance_count
static Tech_type_id advance_count(void)
Definition tech.h:170
A_FIRST
#define A_FIRST
Definition tech.h:44
A_NONE
#define A_NONE
Definition tech.h:43
tech_class_iterate
#define tech_class_iterate(_p)
Definition tech.h:198
advance_iterate_end
#define advance_iterate_end
Definition tech.h:270
A_LAST
#define A_LAST
Definition tech.h:45
terrain_by_rule_name
struct terrain * terrain_by_rule_name(const char *name)
Definition terrain.c:174
terrain_count
Terrain_type_id terrain_count(void)
Definition terrain.c:106
terrain_flag_id_name_cb
const char * terrain_flag_id_name_cb(enum terrain_flag_id flag)
Definition terrain.c:805
terrain_index
Terrain_type_id terrain_index(const struct terrain *pterrain)
Definition terrain.c:126
terrain_by_number
struct terrain * terrain_by_number(const Terrain_type_id type)
Definition terrain.c:144
terrain_flag_helptxt
const char * terrain_flag_helptxt(enum terrain_flag_id id)
Definition terrain.c:817
resource_type_init
struct resource_type * resource_type_init(struct extra_type *pextra)
Definition terrain.c:260
set_user_terrain_flag_name
void set_user_terrain_flag_name(enum terrain_flag_id id, const char *name, const char *helptxt)
Definition terrain.c:776
terrain_number
Terrain_type_id terrain_number(const struct terrain *pterrain)
Definition terrain.c:135
terrain_type_iterate
#define terrain_type_iterate(_p)
Definition terrain.h:358
MAX_RESOURCE_TYPES
#define MAX_RESOURCE_TYPES
Definition terrain.h:67
T_NONE
#define T_NONE
Definition terrain.h:56
TERRAIN_UNKNOWN_IDENTIFIER
#define TERRAIN_UNKNOWN_IDENTIFIER
Definition terrain.h:188
terrain_type_iterate_end
#define terrain_type_iterate_end
Definition terrain.h:364
RESOURCE_NONE_IDENTIFIER
#define RESOURCE_NONE_IDENTIFIER
Definition terrain.h:47
RESOURCE_NULL_IDENTIFIER
#define RESOURCE_NULL_IDENTIFIER
Definition terrain.h:46
MAX_NUM_TERRAINS
#define MAX_NUM_TERRAINS
Definition terrain.h:64
T_FIRST
#define T_FIRST
Definition terrain.h:60
MAX_NUM_USER_TER_FLAGS
#define MAX_NUM_USER_TER_FLAGS
Definition terrain.h:146
ACTIVITY_FACTOR
#define ACTIVITY_FACTOR
Definition tile.h:164
goods_number
Goods_type_id goods_number(const struct goods_type *pgood)
Definition traderoutes.c:579
trade_route_cancelling_type_by_name
enum trade_route_illegal_cancelling trade_route_cancelling_type_by_name(const char *name)
Definition traderoutes.c:184
trade_route_settings_by_type
struct trade_route_settings * trade_route_settings_by_type(enum trade_route_type type)
Definition traderoutes.c:201
goods_rule_name
const char * goods_rule_name(struct goods_type *pgood)
Definition traderoutes.c:620
goods_index
Goods_type_id goods_index(const struct goods_type *pgood)
Definition traderoutes.c:592
trade_route_type_by_name
enum trade_route_type trade_route_type_by_name(const char *name)
Definition traderoutes.c:158
traderoutes.h
goods_type_iterate_end
#define goods_type_iterate_end
Definition traderoutes.h:223
TRI_LAST
@ TRI_LAST
Definition traderoutes.h:33
goods_type_iterate
#define goods_type_iterate(_p)
Definition traderoutes.h:217
trade_route_type
trade_route_type
Definition traderoutes.h:37
TRT_NATIONAL
@ TRT_NATIONAL
Definition traderoutes.h:38
TRT_LAST
@ TRT_LAST
Definition traderoutes.h:48
TRAIT_DEFAULT_VALUE
#define TRAIT_DEFAULT_VALUE
Definition traits.h:32
unit.h
set_unit_class_caches
void set_unit_class_caches(struct unit_class *pclass)
Definition unittype.c:2758
unit_class_flag_helptxt
const char * unit_class_flag_helptxt(enum unit_class_flag_id id)
Definition unittype.c:1906
unit_type_by_rule_name
struct unit_type * unit_type_by_rule_name(const char *name)
Definition unittype.c:1819
utype_has_role
bool utype_has_role(const struct unit_type *punittype, int role)
Definition unittype.c:193
unit_type_action_cache_init
void unit_type_action_cache_init(void)
Definition unittype.c:983
set_unit_type_caches
void set_unit_type_caches(struct unit_type *ptype)
Definition unittype.c:2817
role_unit_precalcs
void role_unit_precalcs(void)
Definition unittype.c:2223
veteran_system_definition
void veteran_system_definition(struct veteran_system *vsystem, int level, const char *vlist_name, int vlist_power, int vlist_move, int vlist_raise, int vlist_wraise)
Definition unittype.c:2719
utype_count
Unit_type_id utype_count(void)
Definition unittype.c:80
utype_veteran_levels
int utype_veteran_levels(const struct unit_type *punittype)
Definition unittype.c:2661
utype_rule_name
const char * utype_rule_name(const struct unit_type *punittype)
Definition unittype.c:1630
utype_veteran_level
const struct veteran_level * utype_veteran_level(const struct unit_type *punittype, int level)
Definition unittype.c:2631
uclass_rule_name
const char * uclass_rule_name(const struct unit_class *pclass)
Definition unittype.c:1693
utype_number
Unit_type_id utype_number(const struct unit_type *punittype)
Definition unittype.c:100
unit_class_by_rule_name
struct unit_class * unit_class_by_rule_name(const char *s)
Definition unittype.c:1836
unit_type_flag_helptxt
const char * unit_type_flag_helptxt(enum unit_type_flag_id id)
Definition unittype.c:1969
utype_index
Unit_type_id utype_index(const struct unit_type *punittype)
Definition unittype.c:91
set_user_unit_class_flag_name
void set_user_unit_class_flag_name(enum unit_class_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1864
veteran_system_new
struct veteran_system * veteran_system_new(int count)
Definition unittype.c:2688
uclass_number
Unit_Class_id uclass_number(const struct unit_class *pclass)
Definition unittype.c:2515
utype_can_do_action
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Definition unittype.c:443
set_user_unit_type_flag_name
void set_user_unit_type_flag_name(enum unit_type_flag_id id, const char *name, const char *helptxt)
Definition unittype.c:1928
unittype.h
uclass_has_flag
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
Definition unittype.h:753
utype_class
#define utype_class(_t_)
Definition unittype.h:736
combat_bonus_list_iterate_end
#define combat_bonus_list_iterate_end
Definition unittype.h:463
L_FIRST
#define L_FIRST
Definition unittype.h:333
combat_bonus_list_iterate
#define combat_bonus_list_iterate(bonuslist, pbonus)
Definition unittype.h:461
HUT_FRIGHTEN
@ HUT_FRIGHTEN
Definition unittype.h:129
HUT_NOTHING
@ HUT_NOTHING
Definition unittype.h:129
HUT_NORMAL
@ HUT_NORMAL
Definition unittype.h:129
unit_class_iterate
#define unit_class_iterate(_p)
Definition unittype.h:876
MAX_NUM_USER_UNIT_FLAGS
#define MAX_NUM_USER_UNIT_FLAGS
Definition unittype.h:316
utype_has_flag
static bool utype_has_flag(const struct unit_type *punittype, int flag)
Definition unittype.h:604
UTYF_LAST_USER_FLAG
#define UTYF_LAST_USER_FLAG
Definition unittype.h:315
unit_type_iterate
#define unit_type_iterate(_p)
Definition unittype.h:838
U_LAST
#define U_LAST
Definition unittype.h:40
uclass_index
#define uclass_index(_c_)
Definition unittype.h:729
unit_class_iterate_end
#define unit_class_iterate_end
Definition unittype.h:883
unit_type_iterate_end
#define unit_type_iterate_end
Definition unittype.h:845
MAX_NUM_USER_UCLASS_FLAGS
#define MAX_NUM_USER_UCLASS_FLAGS
Definition unittype.h:113