Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
savecompat.c File Reference
#include "capability.h"
#include "log.h"
#include "map.h"
#include "specialist.h"
#include "aiiface.h"
#include "setcompat.h"
#include "settings.h"
#include "unittools.h"
#include "savecompat.h"

Go to the source code of this file.

Data Structures

struct  compatibility
 

Macros

#define compat_current   (compat_num - 1)
 

Typedefs

typedef void(* load_version_func_t) (struct loaddata *loading, enum sgf_version format_class)
 

Functions

static void compat_load_020400 (struct loaddata *loading, enum sgf_version format_class)
 
static void compat_load_020500 (struct loaddata *loading, enum sgf_version format_class)
 
static void compat_load_020600 (struct loaddata *loading, enum sgf_version format_class)
 
static void compat_load_030000 (struct loaddata *loading, enum sgf_version format_class)
 
static void compat_load_030100 (struct loaddata *loading, enum sgf_version format_class)
 
static void compat_load_030200 (struct loaddata *loading, enum sgf_version format_class)
 
static void compat_load_030300 (struct loaddata *loading, enum sgf_version format_class)
 
static void compat_post_load_030100 (struct loaddata *loading, enum sgf_version format_class)
 
void sg_load_compat (struct loaddata *loading, enum sgf_version format_class)
 
void sg_load_post_load_compat (struct loaddata *loading, enum sgf_version format_class)
 
int current_compat_ver (void)
 
char bin2ascii_hex (int value, int halfbyte_wanted)
 
int ascii_hex2bin (char ch, int halfbyte)
 
int char2num (char ch)
 
enum tile_special_type special_by_rule_name (const char *name)
 
const charspecial_rule_name (enum tile_special_type type)
 
struct extra_typespecial_extra_get (int spe)
 
struct extra_typeresource_by_identifier (const char identifier)
 
static const charkillcitizen_enum_str (secfile_data_t data, int bit)
 
static charrevolentype_str (enum revolen_type type)
 
static int increase_secfile_turn_int (struct loaddata *loading, const char *key, int old_def, bool keep_default)
 
static void insert_server_side_agent (struct loaddata *loading, enum sgf_version format_class)
 
static void unit_order_activity_to_action (struct unit *act_unit)
 
static enum direction8 dir_opposite (enum direction8 dir)
 
static void upgrade_unit_order_targets (struct unit *act_unit)
 
static void upgrade_server_side_agent (struct loaddata *loading)
 
enum ai_level ai_level_convert (int old_level)
 
enum barbarian_type barb_type_convert (int old_type)
 

Variables

bool sg_success
 
static charspecial_names []
 
static struct compatibility compat []
 
static const int compat_num = ARRAY_SIZE(compat)
 
static const char num_chars []
 

Macro Definition Documentation

◆ compat_current

#define compat_current   (compat_num - 1)

Definition at line 138 of file savecompat.c.

Typedef Documentation

◆ load_version_func_t

Definition at line 92 of file savecompat.c.

Function Documentation

◆ ai_level_convert()

enum ai_level ai_level_convert ( int  old_level)

Translate savegame secfile data from earlier development version format to current one. Convert old ai level value to ai_level

Definition at line 3129 of file savecompat.c.

Referenced by sg_load_player_main().

◆ ascii_hex2bin()

int ascii_hex2bin ( char  ch,
int  halfbyte 
)

This returns a binary integer value of the ascii hex char, offset by the given number of half-bytes. See bin2ascii_hex(). example: ascii_hex2bin('a', 2) == 0xa00 This is only used in loading games, and it requires some error checking so it's done as a function.

Definition at line 248 of file savecompat.c.

Referenced by compat_load_020400(), sg_load_map_known(), sg_load_map_known(), sg_load_player_vision(), and sg_load_player_vision().

◆ barb_type_convert()

enum barbarian_type barb_type_convert ( int  old_type)

Convert old barbarian type value to barbarian_type

Definition at line 3158 of file savecompat.c.

Referenced by compat_load_020600().

◆ bin2ascii_hex()

char bin2ascii_hex ( int  value,
int  halfbyte_wanted 
)

This returns an ascii hex value of the given half-byte of the binary integer. See ascii_hex2bin(). example: bin2ascii_hex(0xa00, 2) == 'a'

Definition at line 236 of file savecompat.c.

Referenced by compat_load_020400(), sg_save_map_known(), and sg_save_player_vision().

◆ char2num()

int char2num ( char  ch)

Converts single character into numerical value. This is not hex conversion.

Definition at line 272 of file savecompat.c.

Referenced by compat_load_030100(), and sg_load_player_unit().

◆ compat_load_020400()

static void compat_load_020400 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Translate savegame secfile data from 2.3.x to 2.4.0 format.

Definition at line 345 of file savecompat.c.

◆ compat_load_020500()

static void compat_load_020500 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Translate savegame secfile data from 2.4.x to 2.5.0 format.

Definition at line 581 of file savecompat.c.

◆ compat_load_020600()

static void compat_load_020600 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Translate savegame secfile data from 2.5.x to 2.6.0 format.

Definition at line 707 of file savecompat.c.

◆ compat_load_030000()

static void compat_load_030000 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Translate savegame secfile data from 2.6.x to 3.0.0 format. Note that even after 2.6 savegame has gone through this compatibility function, it's still 2.6 savegame in the sense that savegame2.c, and not savegame3.c, handles it.

Definition at line 1313 of file savecompat.c.

◆ compat_load_030100()

static void compat_load_030100 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Translate savegame secfile data from 3.0.x to 3.1.0 format. Note that even after 2.6 savegame has gone through all the compatibility functions, it's still 2.6 savegame in the sense that savegame2.c, and not savegame3.c, handles it.

Definition at line 1519 of file savecompat.c.

◆ compat_load_030200()

static void compat_load_030200 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Translate savegame secfile data from 3.1.x to 3.2.0 format. Note that even after 2.6 savegame has gone through all the compatibility functions, it's still 2.6 savegame in the sense that savegame2.c, and not savegame3.c, handles it.

Definition at line 1915 of file savecompat.c.

◆ compat_load_030300()

static void compat_load_030300 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Translate savegame secfile data from 3.2.x to 3.3.0 format. Note that even after 2.6 savegame has gone through all the compatibility functions, it's still 2.6 savegame in the sense that savegame2.c, and not savegame3.c, handles it.

Definition at line 2430 of file savecompat.c.

◆ compat_post_load_030100()

static void compat_post_load_030100 ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Update loaded game data from 3.0.x to something usable by 3.1.0.

Definition at line 1824 of file savecompat.c.

◆ current_compat_ver()

int current_compat_ver ( void  )

Return current compatibility version

Definition at line 226 of file savecompat.c.

Referenced by sg_save_savefile().

◆ dir_opposite()

static enum direction8 dir_opposite ( enum direction8  dir)
static

Returns the opposite direction.

Definition at line 1702 of file savecompat.c.

Referenced by upgrade_unit_order_targets().

◆ increase_secfile_turn_int()

static int increase_secfile_turn_int ( struct loaddata loading,
const char key,
int  old_def,
bool  keep_default 
)
static

Increase turn value in secfile by one.

Definition at line 1292 of file savecompat.c.

Referenced by compat_load_030000().

◆ insert_server_side_agent()

static void insert_server_side_agent ( struct loaddata loading,
enum sgf_version  format_class 
)
static

Insert server side agent information.

Definition at line 1428 of file savecompat.c.

Referenced by compat_load_030100().

◆ killcitizen_enum_str()

static const char * killcitizen_enum_str ( secfile_data_t  data,
int  bit 
)
static

Callback to get name of old killcitizen setting bit.

Definition at line 564 of file savecompat.c.

Referenced by compat_load_020500().

◆ resource_by_identifier()

struct extra_type * resource_by_identifier ( const char  identifier)

Return the resource type matching the identifier, or NULL when none matches.

Definition at line 327 of file savecompat.c.

Referenced by char2resource().

◆ revolentype_str()

static char * revolentype_str ( enum revolen_type  type)
static

Return string representation of revolentype

Definition at line 688 of file savecompat.c.

Referenced by compat_load_020600().

◆ sg_load_compat()

void sg_load_compat ( struct loaddata loading,
enum sgf_version  format_class 
)

Compatibility functions for loaded game.

This function is called at the beginning of loading a savegame. The data in loading->file should be change such, that the current loading functions can be executed without errors.

Definition at line 147 of file savecompat.c.

Referenced by savegame2_load(), and savegame3_load().

◆ sg_load_post_load_compat()

void sg_load_post_load_compat ( struct loaddata loading,
enum sgf_version  format_class 
)

Compatibility functions for loaded game that needs game state.

Some compatibility needs access to game state not available in sg_load_compat(). Do those here.

This function is called after a savegame has loaded the game state. The data should be changed in the game state since the game already is done loading. Prefer using sg_load_compat() when possible.

Definition at line 198 of file savecompat.c.

Referenced by savegame2_load(), and savegame3_load().

◆ special_by_rule_name()

enum tile_special_type special_by_rule_name ( const char name)

Return the special with the given name, or S_LAST.

Definition at line 287 of file savecompat.c.

Referenced by sg_load_savefile().

◆ special_extra_get()

struct extra_type * special_extra_get ( int  spe)

Get extra of the given special

Definition at line 313 of file savecompat.c.

Referenced by sg_load_player_unit().

◆ special_rule_name()

const char * special_rule_name ( enum tile_special_type  type)

Return the untranslated name of the given special.

Definition at line 303 of file savecompat.c.

Referenced by sg_special_set_bv(), and sg_special_set_dbv().

◆ unit_order_activity_to_action()

static void unit_order_activity_to_action ( struct unit act_unit)
static

Upgrade unit activity orders to unit action orders.

Definition at line 1650 of file savecompat.c.

Referenced by compat_post_load_030100().

◆ upgrade_server_side_agent()

static void upgrade_server_side_agent ( struct loaddata loading)
static

Correct the server side agent information.

Definition at line 1810 of file savecompat.c.

Referenced by compat_post_load_030100().

◆ upgrade_unit_order_targets()

static void upgrade_unit_order_targets ( struct unit act_unit)
static

Upgrade unit action order target encoding.

Definition at line 1729 of file savecompat.c.

Referenced by compat_post_load_030100().

Variable Documentation

◆ compat

struct compatibility compat[]
static
Initial value:
= {
{ 0, NULL, NULL },
{ 3, NULL, NULL },
}
char * incite_cost
Definition comments.c:76
static void compat_post_load_030100(struct loaddata *loading, enum sgf_version format_class)
static void compat_load_030000(struct loaddata *loading, enum sgf_version format_class)
static void compat_load_020400(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:345
static void compat_load_030300(struct loaddata *loading, enum sgf_version format_class)
static void compat_load_020600(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:707
static void compat_load_020500(struct loaddata *loading, enum sgf_version format_class)
Definition savecompat.c:581
static void compat_load_030200(struct loaddata *loading, enum sgf_version format_class)
static void compat_load_030100(struct loaddata *loading, enum sgf_version format_class)

Definition at line 112 of file savecompat.c.

Referenced by current_compat_ver(), load_action_blocked_by_list(), load_action_names(), load_action_ui_name_3_3(), load_building_names(), load_game_names(), load_government_names(), load_nation_names(), 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(), load_ruleset_units(), load_style_names(), load_tech_names(), load_terrain_names(), load_unit_names(), lookup_req_list(), real_menus_update(), receive_packet_ruleset_road_100(), road_by_compat_special(), sanity_check_ruleset_data(), setting_ruleset_one(), settings_ruleset(), sg_load_compat(), sg_load_post_load_compat(), and sg_load_savefile().

◆ compat_num

const int compat_num = ARRAY_SIZE(compat)
static

Definition at line 137 of file savecompat.c.

Referenced by sg_load_compat(), and sg_load_post_load_compat().

◆ num_chars

const char num_chars[]
static
Initial value:
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-+"

Definition at line 266 of file savecompat.c.

Referenced by char2num().

◆ sg_success

bool sg_success

Definition at line 34 of file savecompat.c.

Referenced by savegame2_load(), savegame3_load(), savegame3_save_real(), and sg_load_savefile().

◆ special_names

char* special_names[]
static
Initial value:
=
{
"Irrigation", "Mine", "Pollution", "Hut", "Farmland",
"Fallout", NULL
}

Definition at line 36 of file savecompat.c.

Referenced by special_by_rule_name(), and special_rule_name().