Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/rscompat.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Macros | Functions
rscompat.c File Reference
`#include "capability.h"`
`#include "log.h"`
`#include "registry.h"`
`#include "actions.h"`
`#include "effects.h"`
`#include "game.h"`
`#include "movement.h"`
`#include "requirements.h"`
`#include "unittype.h"`
`#include "rssanity.h"`
`#include "ruleset.h"`
`#include "settings.h"`
`#include "rscompat.h"`

Go to the source code of this file.

## Macros

#define | enough_new_user_flags(_new_flags_, _name_, _LAST_USER_FLAG_, _LAST_USER_FLAG_PREV_)
#define | UTYF_LAST_USER_FLAG_3_0 UTYF_USER_FLAG_40
#define | UCF_LAST_USER_FLAG_3_0 UCF_USER_FLAG_8
#define | TER_LAST_USER_FLAG_3_0 TER_USER_8

## Functions

void | rscompat_init_info (struct rscompat_info *info)
int | rscompat_check_capabilities (struct section_file *file, const char *filename, const struct rscompat_info *info)
bool | rscompat_check_cap_and_version (struct section_file *file, const char *filename, const struct rscompat_info *info)
static bool | rscompat_enabler_add_obligatory_hard_reqs (struct action_enabler *ae)
void | rscompat_enablers_add_obligatory_hard_reqs (void)
static int | first_free_unit_type_user_flag (void)
static int | first_free_unit_class_user_flag (void)
static int | first_free_terrain_user_flag (void)
bool | rscompat_names (struct rscompat_info *info)
static void | split_action_name_update (struct action *original, struct action *copy, const char *name_modification)
static bool | effect_handle_split_universal (struct effect *peffect, struct universal original, struct universal separated)
static bool | effect_list_compat_cb (struct effect *peffect, void *data)
static void | paratroopers_mr_sub_to_effect (struct unit_type *putype, struct action *paction)
static bool | ete_is_target_req (struct requirement *preq)
static void | effect_to_enabler (action_id action, struct section_file *file, const char *sec_name, struct rscompat_info *compat, const char *type)
bool | rscompat_old_effect_3_1 (const char *type, struct section_file *file, const char *sec_name, struct rscompat_info *compat)
void | rscompat_adjust_pre_sanity (struct rscompat_info *info)
void | rscompat_postprocess (struct rscompat_info *info)
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)
static bool | slow_invasion_enablers (action_id action_orig, action_id action_copy)
static bool | slow_invasion_effects (const char *action_rule_name)
bool | rscompat_old_slow_invasions_3_1 (struct rscompat_info *compat, bool slow_invasions)
const char * | rscompat_req_type_name_3_1 (const char *old_type)
const char * | rscompat_req_name_3_1 (const char *type, const char *old_name)
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)
const char * | rscompat_utype_flag_name_3_1 (struct rscompat_info *compat, const char *old_type)
const char * | rscompat_combat_bonus_name_3_1 (struct rscompat_info *compat, const char *old_type)
void | rscompat_uclass_flags_3_1 (struct rscompat_info *compat, struct unit_class *pclass)
void | rscompat_extra_adjust_3_1 (struct rscompat_info *compat, struct extra_type *pextra)
enum road_gui_type | rscompat_road_gui_type_3_1 (struct road_type *proad)
const char * | rscompat_action_ui_name_S3_1 (struct rscompat_info *compat, int act_id)
const char * | rscompat_action_max_range_name_S3_1 (struct rscompat_info *compat, int act_id)

## Macro Definition Documentation

## ◆ enough_new_user_flags

#define enough_new_user_flags | ( |  | _new_flags_,
|  |  | _name_,
|  |  | _LAST_USER_FLAG_,
|  |  | _LAST_USER_FLAG_PREV_
| ) |  |

Value:
FC_STATIC_ASSERT((ARRAY_SIZE(_new_flags_) \
<= _LAST_USER_FLAG_ - _LAST_USER_FLAG_PREV_), \
not_enough_new_##_name_##_user_flags)
FC_STATIC_ASSERT
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
ARRAY_SIZE
#define ARRAY_SIZE(x)
Definition shared.h:85

Definition at line 43 of file rscompat.c.

## ◆ TER_LAST_USER_FLAG_3_0

#define TER_LAST_USER_FLAG_3_0 TER_USER_8

Definition at line 51 of file rscompat.c.

## ◆ UCF_LAST_USER_FLAG_3_0

#define UCF_LAST_USER_FLAG_3_0 UCF_USER_FLAG_8

Definition at line 50 of file rscompat.c.

## ◆ UTYF_LAST_USER_FLAG_3_0

#define UTYF_LAST_USER_FLAG_3_0 UTYF_USER_FLAG_40

Definition at line 49 of file rscompat.c.

## Function Documentation

## ◆ effect_handle_split_universal()

static bool effect_handle_split_universal | ( | struct effect * | peffect,
|  | struct universal | original,
|  | struct universal | separated
| ) |  |

static

Handle a universal being separated from an original universal.

A universal may be split into two new universals. An effect may mention the universal that now has been split in its requirement list. In that case two effect - one for the original and one for the universal being separated from it - are needed.

Check if the original universal is mentioned in the requirement list of peffect. Handle creating one effect for the original and one for the universal that has been separated out if it is.

Definition at line 551 of file rscompat.c.

Referenced by effect_list_compat_cb().

## ◆ effect_list_compat_cb()

static bool effect_list_compat_cb | ( | struct effect * | peffect,
|  | void * | data
| ) |  |

static

Adjust effects

Definition at line 570 of file rscompat.c.

Referenced by rscompat_postprocess().

## ◆ effect_to_enabler()

static void effect_to_enabler | ( | action_id | action,
|  | struct section_file * | file,
|  | const char * | sec_name,
|  | struct rscompat_info * | compat,
|  | const char * | type
| ) |  |

static

Turn old effect to an action enabler.

Definition at line 752 of file rscompat.c.

Referenced by rscompat_old_effect_3_1().

## ◆ ete_is_target_req()

static bool ete_is_target_req | ( | struct requirement * | preq | ) |

static

Helper for effect_to_enabler(). Is this requirement meant for target rather than actor?

Definition at line 670 of file rscompat.c.

Referenced by effect_to_enabler().

## ◆ first_free_terrain_user_flag()

static int first_free_terrain_user_flag | ( | void |  | ) |

static

Find and return the first unused terrain user flag. If all terrain user flags are taken MAX_NUM_USER_TER_FLAGS is returned.

Definition at line 361 of file rscompat.c.

Referenced by rscompat_names().

## ◆ first_free_unit_class_user_flag()

static int first_free_unit_class_user_flag | ( | void |  | ) |

static

Find and return the first unused unit class user flag. If all unit class user flags are taken MAX_NUM_USER_UCLASS_FLAGS is returned.

Definition at line 342 of file rscompat.c.

Referenced by rscompat_names().

## ◆ first_free_unit_type_user_flag()

static int first_free_unit_type_user_flag | ( | void |  | ) |

static

Find and return the first unused unit type user flag. If all unit type user flags are taken MAX_NUM_USER_UNIT_FLAGS is returned.

Definition at line 323 of file rscompat.c.

Referenced by rscompat_names().

## ◆ paratroopers_mr_sub_to_effect()

static void paratroopers_mr_sub_to_effect | ( | struct unit_type * | putype,
|  | struct action * | paction
| ) |  |

static

Turn paratroopers_mr_sub into the Action_Success_Actor_Move_Cost effect

Definition at line 645 of file rscompat.c.

Referenced by rscompat_postprocess().

## ◆ rscompat_action_max_range_name_S3_1()

const char * rscompat_action_max_range_name_S3_1 | ( | struct rscompat_info * | compat,
|  | int | act_id
| ) |  |

Adjust freeciv-3.0 ruleset action max_range to freeciv-3.1

Definition at line 2253 of file rscompat.c.

Referenced by load_action_range_max().

## ◆ rscompat_action_ui_name_S3_1()

const char * rscompat_action_ui_name_S3_1 | ( | struct rscompat_info * | compat,
|  | int | act_id
| ) |  |

Adjust freeciv-3.0 ruleset action ui_name to freeciv-3.1

Definition at line 2238 of file rscompat.c.

Referenced by load_ruleset_game().

## ◆ rscompat_adjust_pre_sanity()

void rscompat_adjust_pre_sanity | ( | struct rscompat_info * | info | ) |

Do compatibility things after regular ruleset loading, but before sanity checking.

Definition at line 839 of file rscompat.c.

Referenced by load_rulesetdir().

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

Replace deprecated auto_attack configuration.

Definition at line 1749 of file rscompat.c.

Referenced by load_ruleset_game().

## ◆ rscompat_check_cap_and_version()

bool rscompat_check_cap_and_version | ( | struct section_file * | file,
|  | const char * | filename,
|  | const struct rscompat_info * | info
| ) |  |

Different ruleset files within a ruleset directory should all have identical datafile.format_version This checks the file version against the expected version.

See also rscompat_check_capabilities

Definition at line 131 of file rscompat.c.

Referenced by load_building_names(), load_government_names(), load_nation_names(), load_ruleset_cities(), load_ruleset_effects(), load_style_names(), load_tech_names(), load_terrain_names(), and load_unit_names().

## ◆ rscompat_check_capabilities()

int rscompat_check_capabilities | ( | struct section_file * | file,
|  | const char * | filename,
|  | const struct rscompat_info * | info
| ) |  |

Ruleset files should have a capabilities string datafile.options This checks the string and that the required capabilities are satisfied.

Definition at line 65 of file rscompat.c.

Referenced by load_game_names(), and rscompat_check_cap_and_version().

## ◆ rscompat_combat_bonus_name_3_1()

const char * rscompat_combat_bonus_name_3_1 | ( | struct rscompat_info * | compat,
|  | const char * | old_type
| ) |  |

Replace deprecated combat bonus names with currently valid ones.

Definition at line 2177 of file rscompat.c.

Referenced by lookup_cbonus_list().

## ◆ rscompat_enabler_add_obligatory_hard_reqs()

static bool rscompat_enabler_add_obligatory_hard_reqs | ( | struct action_enabler * | ae | ) |

static

Add all hard obligatory requirements to an action enabler or disable it.

Parameters

  ae | the action enabler to add requirements to.

Returns
  TRUE iff adding obligatory hard reqs for the enabler's action needs to restart - say if an enabler was added or removed.

Definition at line 165 of file rscompat.c.

Referenced by rscompat_enablers_add_obligatory_hard_reqs().

## ◆ rscompat_enablers_add_obligatory_hard_reqs()

void rscompat_enablers_add_obligatory_hard_reqs | ( | void |  | ) |

Update existing action enablers for new hard obligatory requirements. Disable those that can't be upgraded.

Definition at line 285 of file rscompat.c.

Referenced by rscompat_postprocess(), and ruleset_purge_redundant_reqs().

## ◆ rscompat_extra_adjust_3_1()

void rscompat_extra_adjust_3_1 | ( | struct rscompat_info * | compat,
|  | struct extra_type * | pextra
| ) |  |

Adjust freeciv-3.0 ruleset extra definitions to freeciv-3.1

Definition at line 2204 of file rscompat.c.

Referenced by load_ruleset_terrain().

## ◆ rscompat_init_info()

void rscompat_init_info | ( | struct rscompat_info * | info | ) |

Initialize rscompat information structure

Definition at line 56 of file rscompat.c.

Referenced by load_rulesetdir(), and tab_misc::sanity_check().

## ◆ rscompat_names()

bool rscompat_names | ( | struct rscompat_info * | info | ) |

Do compatibility things with names before they are referred to. Runs after names are loaded from the ruleset but before the ruleset objects that may refer to them are loaded.

This is needed when previously hard coded items that are referred to in the ruleset them self becomes ruleset defined.

Returns FALSE if an error occurs.

Definition at line 386 of file rscompat.c.

Referenced by load_rulesetdir().

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

Check if effect name refers to one of the removed effects, and handle it if it does. Returns TRUE iff name was a valid old name.

Definition at line 806 of file rscompat.c.

Referenced by load_ruleset_effects().

## ◆ rscompat_old_slow_invasions_3_1()

bool rscompat_old_slow_invasions_3_1 | ( | struct rscompat_info * | compat,
|  | bool | slow_invasions
| ) |  |

Replace slow_invasions and friends.

Definition at line 1908 of file rscompat.c.

Referenced by load_ruleset_game().

## ◆ rscompat_postprocess()

void rscompat_postprocess | ( | struct rscompat_info * | info | ) |

Do compatibility things after regular ruleset loading.

Definition at line 859 of file rscompat.c.

Referenced by load_rulesetdir().

## ◆ rscompat_req_name_3_1()

const char * rscompat_req_name_3_1 | ( | const char * | type,
|  | const char * | old_name
| ) |  |

Replace deprecated requirement type names with currently valid ones.

The extra arguments are for situation where some, but not all, instances of a requirement type should become something else.

Definition at line 2059 of file rscompat.c.

Referenced by lookup_req_list().

## ◆ rscompat_req_type_name_3_1()

const char * rscompat_req_type_name_3_1 | ( | const char * | old_type | ) |

Replace deprecated requirement type names with currently valid ones.

Definition at line 2043 of file rscompat.c.

Referenced by lookup_req_list().

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

Modify requirement vectors in ways that require looking at the entire vector, rather than just individual requirements.

Definition at line 2079 of file rscompat.c.

Referenced by lookup_req_list().

## ◆ rscompat_road_gui_type_3_1()

enum road_gui_type rscompat_road_gui_type_3_1 | ( | struct road_type * | proad | ) |

Determine freeciv-3.1 road gui_type from freeciv-3.0 compat_special

Definition at line 2220 of file rscompat.c.

Referenced by load_ruleset_terrain().

## ◆ rscompat_uclass_flags_3_1()

void rscompat_uclass_flags_3_1 | ( | struct rscompat_info * | compat,
|  | struct unit_class * | pclass
| ) |  |

Set compatibility unit class flags.

Definition at line 2192 of file rscompat.c.

Referenced by load_ruleset_units().

## ◆ rscompat_utype_flag_name_3_1()

const char * rscompat_utype_flag_name_3_1 | ( | struct rscompat_info * | compat,
|  | const char * | old_type
| ) |  |

Replace deprecated unit type flag names with currently valid ones.

Definition at line 2165 of file rscompat.c.

Referenced by load_ruleset_units(), load_unit_names(), lookup_cbonus_list(), and lookup_req_list().

## ◆ slow_invasion_effects()

static bool slow_invasion_effects | ( | const char * | action_rule_name | ) |

static

Slow invasion movement punishment.

Definition at line 1881 of file rscompat.c.

Referenced by rscompat_old_slow_invasions_3_1().

## ◆ slow_invasion_enablers()

static bool slow_invasion_enablers | ( | action_id | action_orig,
|  | action_id | action_copy
| ) |  |

static

Slow invasion split existing action enablers for action_orig.

Definition at line 1790 of file rscompat.c.

Referenced by rscompat_old_slow_invasions_3_1().

## ◆ split_action_name_update()

static void split_action_name_update | ( | struct action * | original,
|  | struct action * | copy,
|  | const char * | name_modification
| ) |  |

static

Copy the ui_name of an existing action to the ui_name of its copy by inserting it at the first s in name_modification string.

Definition at line 531 of file rscompat.c.

Referenced by rscompat_postprocess().