Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions | Variables
ruleset.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bitvector.h"
#include "deprecations.h"
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "registry.h"
#include "shared.h"
#include "string_vector.h"
#include "support.h"
#include "achievements.h"
#include "actions.h"
#include "ai.h"
#include "base.h"
#include "capability.h"
#include "city.h"
#include "counters.h"
#include "effects.h"
#include "extras.h"
#include "fc_types.h"
#include "featured_text.h"
#include "game.h"
#include "government.h"
#include "map.h"
#include "movement.h"
#include "multipliers.h"
#include "name_translation.h"
#include "nation.h"
#include "packets.h"
#include "player.h"
#include "requirements.h"
#include "rgbcolor.h"
#include "road.h"
#include "sex.h"
#include "specialist.h"
#include "style.h"
#include "tech.h"
#include "traderoutes.h"
#include "unit.h"
#include "unittype.h"
#include "citytools.h"
#include "notify.h"
#include "plrhand.h"
#include "rscompat.h"
#include "rssanity.h"
#include "settings.h"
#include "srv_main.h"
#include "advruleset.h"
#include "script_server.h"
#include "ruleset.h"

Go to the source code of this file.

Macros

#define RULES_SUFFIX   "ruleset"
 
#define SCRIPT_SUFFIX   "lua"
 
#define ADVANCE_SECTION_PREFIX   "advance_"
 
#define TECH_CLASS_SECTION_PREFIX   "techclass_"
 
#define BUILDING_SECTION_PREFIX   "building_"
 
#define CITYSTYLE_SECTION_PREFIX   "citystyle_"
 
#define MUSICSTYLE_SECTION_PREFIX   "musicstyle_"
 
#define UEFF_SECTION_PREFIX   "ueff_"
 
#define EFFECT_SECTION_PREFIX   "effect_"
 
#define GOVERNMENT_SECTION_PREFIX   "government_"
 
#define NATION_SET_SECTION_PREFIX   "nset" /* without underscore? */
 
#define NATION_GROUP_SECTION_PREFIX   "ngroup" /* without underscore? */
 
#define NATION_SECTION_PREFIX   "nation" /* without underscore? */
 
#define STYLE_SECTION_PREFIX   "style_"
 
#define CLAUSE_SECTION_PREFIX   "clause_"
 
#define EXTRA_SECTION_PREFIX   "extra_"
 
#define BASE_SECTION_PREFIX   "base_"
 
#define ROAD_SECTION_PREFIX   "road_"
 
#define RESOURCE_SECTION_PREFIX   "resource_"
 
#define GOODS_SECTION_PREFIX   "goods_"
 
#define SPECIALIST_SECTION_PREFIX   "specialist_"
 
#define TERRAIN_SECTION_PREFIX   "terrain_"
 
#define UNIT_CLASS_SECTION_PREFIX   "unitclass_"
 
#define UNIT_SECTION_PREFIX   "unit_"
 
#define DISASTER_SECTION_PREFIX   "disaster_"
 
#define ACHIEVEMENT_SECTION_PREFIX   "achievement_"
 
#define ACTION_ENABLER_SECTION_PREFIX   "actionenabler_"
 
#define MULTIPLIER_SECTION_PREFIX   "multiplier_"
 
#define COUNTER_SECTION_PREFIX   "counter_"
 
#define check_name(name)   (check_strlen(name, MAX_LEN_NAME, NULL))
 
#define check_cityname(name)   (check_strlen(name, MAX_LEN_CITYNAME, NULL))
 
#define MAX_SECTION_LABEL   64
 
#define section_strlcpy(dst, src)    (void) loud_strlcpy(dst, src, MAX_SECTION_LABEL, name_too_long)
 
#define rs_sanity_veteran(_path, _entry, _i, _condition, _action)
 

Functions

static bool load_rulesetdir (const char *rsdir, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
 
static struct section_fileopenload_ruleset_file (const char *whichset, const char *rsdir)
 
static bool load_game_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_action_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_tech_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_unit_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_building_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_government_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_terrain_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_style_names (struct section_file *file, struct rscompat_info *compat)
 
static bool load_nation_names (struct section_file *file, struct rscompat_info *compat)
 
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)
 
static bool load_ruleset_techs (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_units (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_buildings (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_governments (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_terrain (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_styles (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_cities (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_effects (struct section_file *file, struct rscompat_info *compat)
 
static bool load_ruleset_game (struct section_file *file, bool act, struct rscompat_info *compat)
 
static bool load_ruleset_actions (struct section_file *file, struct section_file *gamefile, struct rscompat_info *compat)
 
static void send_ruleset_tech_classes (struct conn_list *dest)
 
static void send_ruleset_techs (struct conn_list *dest)
 
static void send_ruleset_unit_classes (struct conn_list *dest)
 
static void send_ruleset_units (struct conn_list *dest)
 
static void send_ruleset_buildings (struct conn_list *dest)
 
static void send_ruleset_terrain (struct conn_list *dest)
 
static void send_ruleset_resources (struct conn_list *dest)
 
static void send_ruleset_extras (struct conn_list *dest)
 
static void send_ruleset_bases (struct conn_list *dest)
 
static void send_ruleset_roads (struct conn_list *dest)
 
static void send_ruleset_goods (struct conn_list *dest)
 
static void send_ruleset_governments (struct conn_list *dest)
 
static void send_ruleset_styles (struct conn_list *dest)
 
static void send_ruleset_clauses (struct conn_list *dest)
 
static void send_ruleset_musics (struct conn_list *dest)
 
static void send_ruleset_cities (struct conn_list *dest)
 
static void send_ruleset_game (struct conn_list *dest)
 
static void send_ruleset_team_names (struct conn_list *dest)
 
static bool load_ruleset_veteran (struct section_file *file, const char *path, struct veteran_system **vsystem, char *err, size_t err_len)
 
void ruleset_error_real (rs_conversion_logger logger, const char *file, const char *function, int line, enum log_level level, const char *format,...)
 
static int ruleset_purge_unused_enablers (void)
 
static int ruleset_purge_unused_effects (void)
 
int ruleset_purge_unused_entities (void)
 
static bool purge_unused_req_vec (const struct requirement_vector *reqs, const char *msg)
 
static bool purge_duplicate_req_vec (const struct requirement_vector *reqs, const char *msg)
 
static bool purge_redundant_req_vec (const struct requirement_vector *reqs, const char *msg)
 
static int ruleset_purge_redundant_reqs_enablers (void)
 
static int ruleset_purge_redundant_reqs_effects (void)
 
int ruleset_purge_redundant_reqs (void)
 
static const charvalid_ruleset_filename (const char *subdir, const char *name, const char *extension, bool optional)
 
charget_script_buffer (void)
 
charget_parser_buffer (void)
 
static enum fc_tristate openload_script_file (const char *whichset, const char *rsdir, char **buffer, bool optional)
 
static struct section_fileopenload_luadata_file (const char *rsdir)
 
struct requirement_vectorlookup_req_list (struct section_file *file, struct rscompat_info *compat, const char *sec, const char *sub, const char *rfor)
 
static bool lookup_cbonus_list (struct combat_bonus_list *list, struct section_file *file, const char *sec, const char *sub)
 
static bool lookup_tech (struct section_file *file, struct advance **result, const char *prefix, const char *entry, const char *filename, const char *description)
 
static bool lookup_building (struct section_file *file, const char *prefix, const char *entry, struct impr_type **result, const char *filename, const char *description)
 
static bool lookup_unit_list (struct section_file *file, const char *prefix, const char *entry, struct unit_type **output, const char *filename)
 
static bool lookup_tech_list (struct section_file *file, const char *prefix, const char *entry, int *output, const char *filename)
 
static bool lookup_building_list (struct section_file *file, const char *prefix, const char *entry, int *output, const char *filename)
 
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)
 
static struct governmentlookup_government (struct section_file *file, const char *entry, const char *filename, struct government *fallback)
 
static charlookup_string (struct section_file *file, const char *prefix, const char *suffix)
 
static struct strveclookup_strvec (struct section_file *file, const char *prefix, const char *suffix)
 
static struct extra_typelookup_resource (const char *filename, const char *name, const char *jsection)
 
static bool lookup_terrain (struct section_file *file, const char *entry, const char *filename, struct terrain *pthis, struct terrain **result, bool null_acceptable)
 
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)
 
static bool ruleset_load_names (struct name_translation *pname, const char *domain, struct section_file *file, const char *sec_name)
 
static void ruleset_load_traits (struct trait_limits *out, struct section_file *file, const char *secname, const char *field_prefix)
 
static void send_ruleset_control (struct conn_list *dest)
 
static const charcheck_leader_names (struct nation_type *pnation)
 
static bool is_on_allowed_list (const char *name, const char **list, size_t len)
 
static bool load_ruleset_nations (struct section_file *file, struct rscompat_info *compat)
 
static bool load_action_auto_uflag_block (struct section_file *file, struct action_auto_perf *auto_perf, const char *uflags_path, const char *filename)
 
static bool load_action_auto_actions (struct section_file *file, struct action_auto_perf *auto_perf, const char *actions_path, const char *filename)
 
static bool load_muuk_as_action_auto (struct section_file *file, struct action_auto_perf *auto_perf, const char *item, const char *filename)
 
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__
 
static bool load_action_ui_name (struct section_file *file, int act, const char *entry_name, const char *compat_name)
 
static bool load_action_range_max (struct section_file *file, action_id act)
 
static bool load_action_range (struct section_file *file, action_id act)
 
static bool load_action_kind (struct section_file *file, action_id act)
 
static bool load_action_actor_consuming_always (struct section_file *file, action_id act)
 
static bool load_action_blocked_by_list (struct section_file *file, const char *filename, struct action *paction)
 
static bool load_action_post_success_force (struct section_file *file, const char *filename, int performer_slot, struct action *paction)
 
static bool lookup_bv_actions (struct section_file *file, const char *filename, bv_actions *target, const char *path)
 
static void send_ruleset_specialists (struct conn_list *dest)
 
static void send_ruleset_counters (struct conn_list *dest)
 
static void send_ruleset_disasters (struct conn_list *dest)
 
static void send_ruleset_achievements (struct conn_list *dest)
 
static void send_ruleset_actions (struct conn_list *dest)
 
static void send_ruleset_action_enablers (struct conn_list *dest)
 
static void send_ruleset_action_auto_performers (struct conn_list *dest)
 
static void send_ruleset_trade_routes (struct conn_list *dest)
 
static void send_ruleset_nations (struct conn_list *dest)
 
static void send_ruleset_multipliers (struct conn_list *dest)
 
static void notify_ruleset_fallback (const char *msg)
 
bool load_rulesets (const char *restore, const char *alt, bool compat_mode, rs_conversion_logger logger, bool act, bool buffer_script, bool load_luadata)
 
static void nullcheck_secfile_destroy (struct section_file *file)
 
void rulesets_deinit (void)
 
bool reload_rulesets_settings (void)
 
void send_rulesets (struct conn_list *dest)
 

Variables

static const char name_too_long [] = "Name \"%s\" too long; truncating."
 
static charresource_sections = NULL
 
static charterrain_sections = NULL
 
static charextra_sections = NULL
 
static charbase_sections = NULL
 
static charroad_sections = NULL
 
static struct requirement_vector reqs_list
 
charscript_buffer = NULL
 
charparser_buffer = NULL
 

Macro Definition Documentation

◆ ACHIEVEMENT_SECTION_PREFIX

#define ACHIEVEMENT_SECTION_PREFIX   "achievement_"

Definition at line 110 of file ruleset.c.

◆ ACTION_ENABLER_SECTION_PREFIX

#define ACTION_ENABLER_SECTION_PREFIX   "actionenabler_"

Definition at line 111 of file ruleset.c.

◆ ADVANCE_SECTION_PREFIX

#define ADVANCE_SECTION_PREFIX   "advance_"

Definition at line 87 of file ruleset.c.

◆ BASE_SECTION_PREFIX

#define BASE_SECTION_PREFIX   "base_"

Definition at line 101 of file ruleset.c.

◆ BUILDING_SECTION_PREFIX

#define BUILDING_SECTION_PREFIX   "building_"

Definition at line 89 of file ruleset.c.

◆ check_cityname

#define check_cityname (   name)    (check_strlen(name, MAX_LEN_CITYNAME, NULL))

Definition at line 116 of file ruleset.c.

◆ check_name

#define check_name (   name)    (check_strlen(name, MAX_LEN_NAME, NULL))

Definition at line 115 of file ruleset.c.

◆ CITYSTYLE_SECTION_PREFIX

#define CITYSTYLE_SECTION_PREFIX   "citystyle_"

Definition at line 90 of file ruleset.c.

◆ CLAUSE_SECTION_PREFIX

#define CLAUSE_SECTION_PREFIX   "clause_"

Definition at line 99 of file ruleset.c.

◆ COUNTER_SECTION_PREFIX

#define COUNTER_SECTION_PREFIX   "counter_"

Definition at line 113 of file ruleset.c.

◆ DISASTER_SECTION_PREFIX

#define DISASTER_SECTION_PREFIX   "disaster_"

Definition at line 109 of file ruleset.c.

◆ EFFECT_SECTION_PREFIX

#define EFFECT_SECTION_PREFIX   "effect_"

Definition at line 93 of file ruleset.c.

◆ EXTRA_SECTION_PREFIX

#define EXTRA_SECTION_PREFIX   "extra_"

Definition at line 100 of file ruleset.c.

◆ GOODS_SECTION_PREFIX

#define GOODS_SECTION_PREFIX   "goods_"

Definition at line 104 of file ruleset.c.

◆ GOVERNMENT_SECTION_PREFIX

#define GOVERNMENT_SECTION_PREFIX   "government_"

Definition at line 94 of file ruleset.c.

◆ MAX_SECTION_LABEL

#define MAX_SECTION_LABEL   64

Definition at line 120 of file ruleset.c.

◆ MULTIPLIER_SECTION_PREFIX

#define MULTIPLIER_SECTION_PREFIX   "multiplier_"

Definition at line 112 of file ruleset.c.

◆ MUSICSTYLE_SECTION_PREFIX

#define MUSICSTYLE_SECTION_PREFIX   "musicstyle_"

Definition at line 91 of file ruleset.c.

◆ NATION_GROUP_SECTION_PREFIX

#define NATION_GROUP_SECTION_PREFIX   "ngroup" /* without underscore? */

Definition at line 96 of file ruleset.c.

◆ NATION_SECTION_PREFIX

#define NATION_SECTION_PREFIX   "nation" /* without underscore? */

Definition at line 97 of file ruleset.c.

◆ NATION_SET_SECTION_PREFIX

#define NATION_SET_SECTION_PREFIX   "nset" /* without underscore? */

Definition at line 95 of file ruleset.c.

◆ RESOURCE_SECTION_PREFIX

#define RESOURCE_SECTION_PREFIX   "resource_"

Definition at line 103 of file ruleset.c.

◆ ROAD_SECTION_PREFIX

#define ROAD_SECTION_PREFIX   "road_"

Definition at line 102 of file ruleset.c.

◆ rs_sanity_veteran

#define rs_sanity_veteran (   _path,
  _entry,
  _i,
  _condition,
  _action 
)
Value:
if (_condition) { \
log_error("Invalid veteran definition '%s.%s[%d]'!", \
log_debug("Failed check: '%s'. Update value: '%s'.", \
}
char * incite_cost
Definition comments.c:75

◆ RULES_SUFFIX

#define RULES_SUFFIX   "ruleset"

Definition at line 84 of file ruleset.c.

◆ SCRIPT_SUFFIX

#define SCRIPT_SUFFIX   "lua"

Definition at line 85 of file ruleset.c.

◆ section_strlcpy

#define section_strlcpy (   dst,
  src 
)     (void) loud_strlcpy(dst, src, MAX_SECTION_LABEL, name_too_long)

Definition at line 121 of file ruleset.c.

◆ SPECIALIST_SECTION_PREFIX

#define SPECIALIST_SECTION_PREFIX   "specialist_"

Definition at line 105 of file ruleset.c.

◆ STYLE_SECTION_PREFIX

#define STYLE_SECTION_PREFIX   "style_"

Definition at line 98 of file ruleset.c.

◆ TECH_CLASS_SECTION_PREFIX

#define TECH_CLASS_SECTION_PREFIX   "techclass_"

Definition at line 88 of file ruleset.c.

◆ TERRAIN_SECTION_PREFIX

#define TERRAIN_SECTION_PREFIX   "terrain_"

Definition at line 106 of file ruleset.c.

◆ UEFF_SECTION_PREFIX

#define UEFF_SECTION_PREFIX   "ueff_"

Definition at line 92 of file ruleset.c.

◆ UNIT_CLASS_SECTION_PREFIX

#define UNIT_CLASS_SECTION_PREFIX   "unitclass_"

Definition at line 107 of file ruleset.c.

◆ UNIT_SECTION_PREFIX

#define UNIT_SECTION_PREFIX   "unit_"

Definition at line 108 of file ruleset.c.

Function Documentation

◆ check_leader_names()

static const char * check_leader_names ( struct nation_type pnation)
static

Check for duplicate leader names in nation. If no duplicates return NULL; if yes return pointer to name which is repeated.

Definition at line 4696 of file ruleset.c.

Referenced by load_ruleset_nations().

◆ get_parser_buffer()

char * get_parser_buffer ( void  )

Return current parser.lua buffer.

Definition at line 562 of file ruleset.c.

Referenced by save_ruleset().

◆ get_script_buffer()

char * get_script_buffer ( void  )

Return current script.lua buffer.

Definition at line 554 of file ruleset.c.

Referenced by save_ruleset().

◆ is_on_allowed_list()

static bool is_on_allowed_list ( const char name,
const char **  list,
size_t  len 
)
static

Check if a string is in a vector (case-insensitively).

Definition at line 4852 of file ruleset.c.

Referenced by load_city_name_list(), and load_ruleset_nations().

◆ load_action_actor_consuming_always()

static bool load_action_actor_consuming_always ( struct section_file file,
action_id  act 
)
static

Load if the action always consumes the actor

Definition at line 6532 of file ruleset.c.

Referenced by load_ruleset_actions().

◆ 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 
)
static

Load the list of actions an action auto performer should try. The actions will be tried in the given order.

Definition at line 5937 of file ruleset.c.

Referenced by load_action_post_success_force(), load_muuk_as_action_auto(), and load_ruleset_actions().

◆ 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 
)
static

Load a list of unit type flags that must be absent from the actor unit if an action auto performer should be triggered into an action auto performer.

Definition at line 5894 of file ruleset.c.

Referenced by load_muuk_as_action_auto().

◆ load_action_blocked_by_list()

static bool load_action_blocked_by_list ( struct section_file file,
const char filename,
struct action paction 
)
static

Load what actions can block the action

Definition at line 6549 of file ruleset.c.

Referenced by load_ruleset_actions().

◆ load_action_kind()

static bool load_action_kind ( struct section_file file,
action_id  act 
)
static

Load kind of an action

Definition at line 6510 of file ruleset.c.

Referenced by load_ruleset_actions().

◆ load_action_names()

static bool load_action_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names from actions.ruleset so other rulesets can refer to objects with their name.

Definition at line 1482 of file ruleset.c.

Referenced by load_rulesetdir().

◆ 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 
)
static

Load what actions an actor under certain circumstances will be forced to perform after successfully performing this action.

Definition at line 6593 of file ruleset.c.

Referenced by load_ruleset_actions().

◆ load_action_range()

static bool load_action_range ( struct section_file file,
action_id  act 
)
static

Load range of an action

Definition at line 6485 of file ruleset.c.

Referenced by load_ruleset_actions().

◆ load_action_range_max()

static bool load_action_range_max ( struct section_file file,
action_id  act 
)
static

Load max range of an action

Definition at line 6444 of file ruleset.c.

Referenced by load_action_range().

◆ load_action_ui_name()

static bool load_action_ui_name ( struct section_file file,
int  act,
const char entry_name,
const char compat_name 
)
static

Load ui_name of one action

Definition at line 6422 of file ruleset.c.

Referenced by load_ruleset_actions().

◆ load_building_names()

static bool load_building_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names of buildings so other rulesets can refer to buildings with their name.

Definition at line 2646 of file ruleset.c.

Referenced by load_rulesetdir().

◆ 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 
)
static

This function loads a city name list from a section file. The file and two section names (which will be concatenated) are passed in.

Definition at line 4868 of file ruleset.c.

Referenced by load_ruleset_nations().

◆ load_game_names()

static bool load_game_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names from game.ruleset so other rulesets can refer to objects with their name.

Definition at line 1352 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_government_names()

static bool load_government_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names of governments so other rulesets can refer to governments with their name. Also load multiplier names/count from governments.ruleset.

Definition at line 4378 of file ruleset.c.

Referenced by load_rulesetdir().

◆ 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 
)
static

Load missing unit upkeep ruleset settings as action auto performers.

Definition at line 5973 of file ruleset.c.

Referenced by load_ruleset_cities().

◆ load_nation_names()

static bool load_nation_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names of nations so other rulesets can refer to nations with their name.

Definition at line 4716 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_actions()

static bool load_ruleset_actions ( struct section_file file,
struct section_file gamefile,
struct rscompat_info compat 
)
static

Loads action information from a file

Definition at line 7732 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_buildings()

static bool load_ruleset_buildings ( struct section_file file,
struct rscompat_info compat 
)
static

Load buildings related ruleset data

Definition at line 2727 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_cities()

static bool load_ruleset_cities ( struct section_file file,
struct rscompat_info compat 
)
static

Load cities.ruleset file

Definition at line 5995 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_effects()

static bool load_ruleset_effects ( struct section_file file,
struct rscompat_info compat 
)
static

Load effects.ruleset file

Definition at line 6210 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_game()

static bool load_ruleset_game ( struct section_file file,
bool  act,
struct rscompat_info compat 
)
static

Load ruleset file.

Definition at line 6664 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_governments()

static bool load_ruleset_governments ( struct section_file file,
struct rscompat_info compat 
)
static

This loads information from given governments.ruleset

Definition at line 4460 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_nations()

static bool load_ruleset_nations ( struct section_file file,
struct rscompat_info compat 
)
static

Load nations.ruleset file

Definition at line 5038 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_styles()

static bool load_ruleset_styles ( struct section_file file,
struct rscompat_info compat 
)
static

Load styles.ruleset file

Definition at line 5816 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_techs()

static bool load_ruleset_techs ( struct section_file file,
struct rscompat_info compat 
)
static

Load technologies related ruleset data

Definition at line 1620 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_terrain()

static bool load_ruleset_terrain ( struct section_file file,
struct rscompat_info compat 
)
static

Load terrain types related ruleset data

Definition at line 3191 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_ruleset_units()

static bool load_ruleset_units ( struct section_file file,
struct rscompat_info compat 
)
static

Load units related ruleset data.

Definition at line 2110 of file ruleset.c.

Referenced by load_rulesetdir().

◆ 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 
)
static

Load veteran levels.

Definition at line 1989 of file ruleset.c.

Referenced by load_ruleset_units().

◆ load_rulesetdir()

static bool load_rulesetdir ( const char rsdir,
bool  compat_mode,
rs_conversion_logger  logger,
bool  act,
bool  buffer_script,
bool  load_luadata 
)
static

Loads the rulesets from directory. This may be called more than once and it will free any stale data.

Definition at line 9448 of file ruleset.c.

Referenced by load_rulesets().

◆ 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 
)

◆ load_style_names()

static bool load_style_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names of nation styles so other rulesets can refer to styles with their name.

Definition at line 5755 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_tech_names()

static bool load_tech_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names of technologies so other rulesets can refer to techs with their name.

Definition at line 1502 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_terrain_names()

static bool load_terrain_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names of terrain types so other rulesets can refer to terrains with their name.

Definition at line 2855 of file ruleset.c.

Referenced by load_rulesetdir().

◆ load_unit_names()

static bool load_unit_names ( struct section_file file,
struct rscompat_info compat 
)
static

Load names of units so other rulesets can refer to units with their name.

Definition at line 1831 of file ruleset.c.

Referenced by load_rulesetdir().

◆ 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 
)
static

Lookup a string prefix.entry in the file and return the corresponding improvement pointer. Return B_NEVER for match "None" or can't match. If description is not NULL, it is used in the warning message instead of prefix (eg pass unit->name instead of prefix="units2.u27")

Definition at line 888 of file ruleset.c.

Referenced by load_ruleset_units().

◆ lookup_building_list()

static bool lookup_building_list ( struct section_file file,
const char prefix,
const char entry,
int output,
const char filename 
)
static

Lookup a prefix.entry string vector in the file and fill in the array, which should hold MAX_NUM_BUILDING_LIST items. The output array is either B_LAST terminated or full (contains MAX_NUM_BUILDING_LIST items). [All valid entries of the output array are guaranteed to pass improvement_exist()?]

Definition at line 1045 of file ruleset.c.

Referenced by load_ruleset_game(), and load_ruleset_nations().

◆ lookup_bv_actions()

static bool lookup_bv_actions ( struct section_file file,
const char filename,
bv_actions target,
const char path 
)
static

Load a list of actions from the ruleset to a bv_actions bit vector.

Definition at line 6630 of file ruleset.c.

Referenced by load_ruleset_actions().

◆ lookup_cbonus_list()

static bool lookup_cbonus_list ( struct combat_bonus_list list,
struct section_file file,
const char sec,
const char sub 
)
static

Load combat bonus list

Definition at line 797 of file ruleset.c.

Referenced by load_ruleset_units().

◆ lookup_government()

static struct government * lookup_government ( struct section_file file,
const char entry,
const char filename,
struct government fallback 
)
static

Lookup entry in the file and return the corresponding government index. filename is for error message.

Definition at line 1128 of file ruleset.c.

Referenced by load_ruleset_governments(), load_ruleset_nations(), and load_ruleset_units().

◆ 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 
)

Load a requirement list. The list is returned as a static vector (callers need not worry about freeing anything).

Definition at line 654 of file ruleset.c.

Referenced by load_ruleset_actions(), load_ruleset_buildings(), load_ruleset_cities(), load_ruleset_effects(), load_ruleset_game(), load_ruleset_governments(), load_ruleset_styles(), load_ruleset_techs(), load_ruleset_terrain(), and load_ruleset_units().

◆ lookup_resource()

static struct extra_type * lookup_resource ( const char filename,
const char name,
const char jsection 
)
static

Look up the resource section name and return its pointer.

Definition at line 1193 of file ruleset.c.

Referenced by load_ruleset_terrain().

◆ lookup_string()

static char * lookup_string ( struct section_file file,
const char prefix,
const char suffix 
)
static

Lookup optional string, returning allocated memory or NULL.

Definition at line 1153 of file ruleset.c.

Referenced by load_ruleset_techs().

◆ lookup_strvec()

static struct strvec * lookup_strvec ( struct section_file file,
const char prefix,
const char suffix 
)
static

Lookup optional string vector, returning allocated memory or NULL.

Definition at line 1173 of file ruleset.c.

Referenced by load_ruleset_buildings(), load_ruleset_cities(), load_ruleset_game(), load_ruleset_governments(), load_ruleset_techs(), load_ruleset_terrain(), and load_ruleset_units().

◆ 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 
)
static

Lookup a string prefix.entry in the file and return the corresponding advances pointer. If (!required), return A_NEVER for match "Never" or can't match. If (required), die when can't match. Note the first tech should have name "None" so that will always match. If description is not NULL, it is used in the warning message instead of prefix (eg pass unit->name instead of prefix="units2.u27")

Definition at line 856 of file ruleset.c.

Referenced by load_ruleset_techs(), and load_ruleset_units().

◆ lookup_tech_list()

static bool lookup_tech_list ( struct section_file file,
const char prefix,
const char entry,
int output,
const char filename 
)
static

Lookup a prefix.entry string vector in the file and fill in the array, which should hold MAX_NUM_TECH_LIST items. The output array is either A_LAST terminated or full (contains MAX_NUM_TECH_LIST items). All valid entries of the output array are guaranteed to exist.

Definition at line 981 of file ruleset.c.

Referenced by load_ruleset_game(), and load_ruleset_nations().

◆ 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 
)
static

Look up the terrain by name and return its pointer. filename is for error message.

Definition at line 1214 of file ruleset.c.

Referenced by load_ruleset_terrain().

◆ lookup_time()

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 
)

Look up a value comparable to activity_count (road_time, etc). item_name describes the thing which has the time property, if non-NULL, for any error message. Returns FALSE if not found in secfile, but TRUE even if validation failed. Sets *ok to FALSE if validation failed, leaves it alone otherwise.

Definition at line 1264 of file ruleset.c.

Referenced by load_ruleset_terrain(), load_ruleset_units(), and rscompat_terrain_extra_rmtime_3_2().

◆ 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 
)
static

Lookup a prefix.entry string vector in the file and fill in the array, which should hold MAX_NUM_UNIT_LIST items. The output array is either NULL terminated or full (contains MAX_NUM_UNIT_LIST items). If the vector is not found and the required parameter is set, we report it as an error, otherwise we just punt.

Definition at line 921 of file ruleset.c.

Referenced by load_ruleset_nations().

◆ 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 
)
static

Lookup a string prefix.entry in the file and set result to the corresponding unit_type. If description is not NULL, it is used in the warning message instead of prefix (eg pass unit->name instead of prefix="units2.u27")

Definition at line 1097 of file ruleset.c.

Referenced by load_ruleset_terrain(), and load_ruleset_units().

◆ notify_ruleset_fallback()

static void notify_ruleset_fallback ( const char msg)
static

Make it clear to everyone that requested ruleset has not been loaded.

Definition at line 9350 of file ruleset.c.

Referenced by load_rulesets().

◆ nullcheck_secfile_destroy()

static void nullcheck_secfile_destroy ( struct section_file file)
static

Destroy secfile. Handle NULL parameter gracefully.

Definition at line 9427 of file ruleset.c.

Referenced by load_rulesetdir().

◆ openload_luadata_file()

static struct section_file * openload_luadata_file ( const char rsdir)
static

Load optional luadata.txt

Definition at line 626 of file ruleset.c.

Referenced by load_rulesetdir().

◆ openload_ruleset_file()

static struct section_file * openload_ruleset_file ( const char whichset,
const char rsdir 
)
static

Do initial section_file_load on a ruleset file. "whichset" = "techs", "units", "buildings", "terrain", ...

Definition at line 571 of file ruleset.c.

Referenced by load_rulesetdir(), and reload_rulesets_settings().

◆ openload_script_file()

static enum fc_tristate openload_script_file ( const char whichset,
const char rsdir,
char **  buffer,
bool  optional 
)
static

Parse script file.

Definition at line 599 of file ruleset.c.

Referenced by load_rulesetdir().

◆ purge_duplicate_req_vec()

static bool purge_duplicate_req_vec ( const struct requirement_vector reqs,
const char msg 
)
static

Purge the first duplicate requirement in a requirement vector.

Returns
TRUE if a requirement was purged.

Definition at line 367 of file ruleset.c.

Referenced by purge_redundant_req_vec().

◆ purge_redundant_req_vec()

static bool purge_redundant_req_vec ( const struct requirement_vector reqs,
const char msg 
)
static

Purge the first redundant requirement in a requirement vector.

Returns
TRUE if a requirement was purged.

Definition at line 412 of file ruleset.c.

Referenced by ruleset_purge_redundant_reqs_effects(), and ruleset_purge_redundant_reqs_enablers().

◆ purge_unused_req_vec()

static bool purge_unused_req_vec ( const struct requirement_vector reqs,
const char msg 
)
static

Purge the first unused requirement in a requirement vector.

Returns
TRUE if a requirement was purged.

Definition at line 327 of file ruleset.c.

Referenced by purge_redundant_req_vec().

◆ reload_rulesets_settings()

bool reload_rulesets_settings ( void  )

Reload the game settings saved in the ruleset file.

Definition at line 9705 of file ruleset.c.

Referenced by reset_command().

◆ 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,
  ... 
)

Notifications about ruleset errors to clients. Especially important in case of internal server crashing.

Definition at line 215 of file ruleset.c.

◆ ruleset_load_names()

static bool ruleset_load_names ( struct name_translation pname,
const char domain,
struct section_file file,
const char sec_name 
)
static

◆ ruleset_load_traits()

static void ruleset_load_traits ( struct trait_limits out,
struct section_file file,
const char secname,
const char field_prefix 
)
static

Load trait values to array.

Definition at line 1313 of file ruleset.c.

Referenced by load_ruleset_nations().

◆ ruleset_purge_redundant_reqs()

int ruleset_purge_redundant_reqs ( void  )

Purge redundant requirement in requirement vectors.

Returns
the number of purged requirements.

Definition at line 490 of file ruleset.c.

Referenced by main().

◆ ruleset_purge_redundant_reqs_effects()

static int ruleset_purge_redundant_reqs_effects ( void  )
static

Purge redundant requirements from effects.

Returns
the number of purged requirements.

Definition at line 461 of file ruleset.c.

Referenced by ruleset_purge_redundant_reqs().

◆ ruleset_purge_redundant_reqs_enablers()

static int ruleset_purge_redundant_reqs_enablers ( void  )
static

Purge redundant requirements from action enablers.

Returns
the number of purged requirements.

Definition at line 423 of file ruleset.c.

Referenced by ruleset_purge_redundant_reqs().

◆ ruleset_purge_unused_effects()

static int ruleset_purge_unused_effects ( void  )
static

Purge unused effects from the ruleset.

Definition at line 290 of file ruleset.c.

Referenced by ruleset_purge_unused_entities().

◆ ruleset_purge_unused_enablers()

static int ruleset_purge_unused_enablers ( void  )
static

Purge unused action enablers from the ruleset.

Definition at line 244 of file ruleset.c.

Referenced by ruleset_purge_unused_entities().

◆ ruleset_purge_unused_entities()

int ruleset_purge_unused_entities ( void  )

Purge unused entities from the ruleset.

Definition at line 313 of file ruleset.c.

Referenced by main().

◆ rulesets_deinit()

void rulesets_deinit ( void  )

Completely deinitialize ruleset system. Server is not in usable state after this.

Definition at line 9438 of file ruleset.c.

Referenced by server_quit().

◆ secfile_lookup_int_default_min_max()

static int static int secfile_lookup_int_default_min_max ( struct section_file file,
int  def,
int  min,
int  max,
const char path,
  ... 
)
static

Print an error message if the value is out of range.

Definition at line 6384 of file ruleset.c.

Referenced by load_ruleset_game().

◆ send_ruleset_achievements()

static void send_ruleset_achievements ( struct conn_list dest)
static

Send the achievement ruleset information (all individual achievement types) to the specified connections.

Definition at line 8839 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_action_auto_performers()

static void send_ruleset_action_auto_performers ( struct conn_list dest)
static

Send action auto performer ruleset information to the specified connections.

Definition at line 8918 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_action_enablers()

static void send_ruleset_action_enablers ( struct conn_list dest)
static

Send the action enabler ruleset information to the specified connections.

Definition at line 8890 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_actions()

static void send_ruleset_actions ( struct conn_list dest)
static

Send action ruleset information to the specified connections.

Definition at line 8860 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_bases()

static void send_ruleset_bases ( struct conn_list dest)
static

Send the base ruleset information (all individual base types) to the specified connections.

Definition at line 8715 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_buildings()

static void send_ruleset_buildings ( struct conn_list dest)
static

Send the buildings ruleset information (all individual improvements and wonders) to the specified connections.

Definition at line 8407 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_cities()

static void send_ruleset_cities ( struct conn_list dest)
static

Send the city-style ruleset information (each style) to the specified connections.

Definition at line 9213 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_clauses()

static void send_ruleset_clauses ( struct conn_list dest)
static

Send the clause type ruleset information to the specified connections.

Definition at line 9147 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_control()

static void send_ruleset_control ( struct conn_list dest)
static

Send information in packet_ruleset_control (numbers of units etc, and other miscellany) to specified connections.

The client assumes that exactly one ruleset control packet is sent as a part of each ruleset send. So after sending this packet we have to resend every other part of the rulesets (and none of them should be is-info in the network code!). The client frees ruleset data when receiving this packet and then re-initializes as it receives the individual ruleset packets. See packhand.c.

Definition at line 4658 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_counters()

static void send_ruleset_counters ( struct conn_list dest)
static

Send the counters ruleset information to the specified connections.

Definition at line 8386 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_disasters()

static void send_ruleset_disasters ( struct conn_list dest)
static

Send the disaster ruleset information (all individual disaster types) to the specified connections.

Definition at line 8809 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_extras()

static void send_ruleset_extras ( struct conn_list dest)
static

Send the extra ruleset information (all individual extra types) to the specified connections.

Definition at line 8599 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_game()

static void send_ruleset_game ( struct conn_list dest)
static

Send information in packet_ruleset_game (miscellaneous rules) to the specified connections.

Definition at line 9267 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_goods()

static void send_ruleset_goods ( struct conn_list dest)
static

Send the goods ruleset information (all individual goods types) to the specified connections.

Definition at line 8777 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_governments()

static void send_ruleset_governments ( struct conn_list dest)
static

Send the government ruleset information to the specified connections. One packet per government type, and for each type one per ruler title.

Definition at line 8975 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_multipliers()

static void send_ruleset_multipliers ( struct conn_list dest)
static

Send the multiplier ruleset information to the specified connections.

Definition at line 9179 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_musics()

static void send_ruleset_musics ( struct conn_list dest)
static

Send the music-style ruleset information (each style) to the specified connections.

Definition at line 9241 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_nations()

static void send_ruleset_nations ( struct conn_list dest)
static

Send the nations ruleset information (info on each nation) to the specified connections.

Definition at line 9021 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_resources()

static void send_ruleset_resources ( struct conn_list dest)
static

Send the resource ruleset information to the specified connections.

Definition at line 8580 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_roads()

static void send_ruleset_roads ( struct conn_list dest)
static

Send the road ruleset information (all individual road types) to the specified connections.

Definition at line 8737 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_specialists()

static void send_ruleset_specialists ( struct conn_list dest)
static

Send the specialists ruleset information (all individual specialist types) to the specified connections.

Definition at line 8249 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_styles()

static void send_ruleset_styles ( struct conn_list dest)
static

Send the nation style ruleset information (each style) to the specified connections.

Definition at line 9131 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_team_names()

static void send_ruleset_team_names ( struct conn_list dest)
static

Send all team names defined in the ruleset file(s) to the specified connections.

Definition at line 9328 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_tech_classes()

static void send_ruleset_tech_classes ( struct conn_list dest)
static

Send the techs class information to the specified connections.

Definition at line 8277 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_techs()

static void send_ruleset_techs ( struct conn_list dest)
static

Send the techs ruleset information (all individual advances) to the specified connections.

Definition at line 8295 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_terrain()

static void send_ruleset_terrain ( struct conn_list dest)
static

Send the terrain ruleset information (terrain_control, and the individual terrain types) to the specified connections.

Definition at line 8473 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_trade_routes()

static void send_ruleset_trade_routes ( struct conn_list dest)
static

Send the trade route types ruleset information (all individual trade route types) to the specified connections.

Definition at line 8954 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_unit_classes()

static void send_ruleset_unit_classes ( struct conn_list dest)
static

Send the units ruleset information (all individual unit classes) to the specified connections.

Definition at line 8062 of file ruleset.c.

Referenced by send_rulesets().

◆ send_ruleset_units()

static void send_ruleset_units ( struct conn_list dest)
static

Send the units ruleset information (all individual units) to the specified connections.

Definition at line 8110 of file ruleset.c.

Referenced by send_rulesets().

◆ send_rulesets()

void send_rulesets ( struct conn_list dest)

Send all ruleset information to the specified connections.

Definition at line 9728 of file ruleset.c.

Referenced by establish_new_connection(), load_command(), and set_rulesetdir().

◆ valid_ruleset_filename()

static const char * valid_ruleset_filename ( const char subdir,
const char name,
const char extension,
bool  optional 
)
static

datafilename() wrapper: tries to match in two ways. Returns NULL on failure, the (statically allocated) filename on success.

Definition at line 509 of file ruleset.c.

Referenced by openload_luadata_file(), openload_ruleset_file(), and openload_script_file().

Variable Documentation

◆ base_sections

char* base_sections = NULL
static

Definition at line 126 of file ruleset.c.

Referenced by load_ruleset_terrain(), load_rulesetdir(), and load_terrain_names().

◆ extra_sections

char* extra_sections = NULL
static

Definition at line 125 of file ruleset.c.

Referenced by load_ruleset_terrain(), load_rulesetdir(), and load_terrain_names().

◆ name_too_long

const char name_too_long[] = "Name \"%s\" too long; truncating."
static

Definition at line 119 of file ruleset.c.

Referenced by names_set().

◆ parser_buffer

char* parser_buffer = NULL

Definition at line 209 of file ruleset.c.

Referenced by get_parser_buffer(), and load_rulesetdir().

◆ reqs_list

struct requirement_vector reqs_list
static

Definition at line 129 of file ruleset.c.

Referenced by lookup_req_list(), and rulesets_deinit().

◆ resource_sections

char* resource_sections = NULL
static

Definition at line 123 of file ruleset.c.

Referenced by load_ruleset_terrain(), load_rulesetdir(), and load_terrain_names().

◆ road_sections

char* road_sections = NULL
static

Definition at line 127 of file ruleset.c.

Referenced by load_ruleset_terrain(), load_rulesetdir(), and load_terrain_names().

◆ script_buffer

char* script_buffer = NULL

Definition at line 208 of file ruleset.c.

Referenced by get_script_buffer(), and load_rulesetdir().

◆ terrain_sections

char* terrain_sections = NULL
static