Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
savecompat.h File Reference
#include "rand.h"
#include "srv_main.h"

Go to the source code of this file.

Data Structures

struct  loaddata
 

Macros

#define log_sg   log_error
 
#define log_sgfix   log_normal
 
#define sg_check_ret(...)
 
#define sg_check_ret_val(_val)
 
#define sg_warn(condition, message, ...)
 
#define sg_warn_ret(condition, message, ...)
 
#define sg_warn_ret_val(condition, _val, message, ...)
 
#define sg_failure_ret(condition, message, ...)
 
#define sg_failure_ret_val(condition, _val, message, ...)
 
#define sg_regr(fixversion, message, ...)
 
#define hex_chars   "0123456789abcdef"
 
#define MAX_TRADE_ROUTES_OLD   5
 

Enumerations

enum  sgf_version { SAVEGAME_2 , SAVEGAME_3 }
 
enum  tile_special_type {
  S_IRRIGATION , S_MINE , S_POLLUTION , S_HUT ,
  S_FARMLAND , S_FALLOUT , S_LAST , S_OLD_FORTRESS ,
  S_OLD_AIRBASE , S_OLD_ROAD , S_OLD_RAILROAD , S_OLD_RIVER
}
 

Functions

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)
 
enum ai_level ai_level_convert (int old_level)
 
enum barbarian_type barb_type_convert (int old_type)
 

Macro Definition Documentation

◆ hex_chars

#define hex_chars   "0123456789abcdef"

Definition at line 205 of file savecompat.h.

◆ log_sg

#define log_sg   log_error

Definition at line 146 of file savecompat.h.

◆ log_sgfix

#define log_sgfix   log_normal

Definition at line 148 of file savecompat.h.

◆ MAX_TRADE_ROUTES_OLD

#define MAX_TRADE_ROUTES_OLD   5

Definition at line 222 of file savecompat.h.

◆ sg_check_ret

#define sg_check_ret (   ...)
Value:
if (!sg_success) { \
return; \
}
bool sg_success
Definition savecompat.c:34

Definition at line 150 of file savecompat.h.

◆ sg_check_ret_val

#define sg_check_ret_val (   _val)
Value:
if (!sg_success) { \
return _val; \
}
char * incite_cost
Definition comments.c:75

Definition at line 155 of file savecompat.h.

◆ sg_failure_ret

#define sg_failure_ret (   condition,
  message,
  ... 
)
Value:
if (!(condition)) { \
}
#define FALSE
Definition support.h:47

Definition at line 177 of file savecompat.h.

◆ sg_failure_ret_val

#define sg_failure_ret_val (   condition,
  _val,
  message,
  ... 
)
Value:
if (!(condition)) { \
}

Definition at line 184 of file savecompat.h.

◆ sg_regr

#define sg_regr (   fixversion,
  message,
  ... 
)
Value:
if (loading->full_version >= fixversion) { \
} else { \
}

Definition at line 193 of file savecompat.h.

◆ sg_warn

#define sg_warn (   condition,
  message,
  ... 
)
Value:
if (!(condition)) { \
}

Definition at line 160 of file savecompat.h.

◆ sg_warn_ret

#define sg_warn_ret (   condition,
  message,
  ... 
)
Value:
if (!(condition)) { \
return; \
}

Definition at line 165 of file savecompat.h.

◆ sg_warn_ret_val

#define sg_warn_ret_val (   condition,
  _val,
  message,
  ... 
)
Value:
if (!(condition)) { \
return _val; \
}

Definition at line 171 of file savecompat.h.

Enumeration Type Documentation

◆ sgf_version

Enumerator
SAVEGAME_2 
SAVEGAME_3 

Definition at line 27 of file savecompat.h.

◆ tile_special_type

Enumerator
S_IRRIGATION 
S_MINE 
S_POLLUTION 
S_HUT 
S_FARMLAND 
S_FALLOUT 
S_LAST 
S_OLD_FORTRESS 
S_OLD_AIRBASE 
S_OLD_ROAD 
S_OLD_RAILROAD 
S_OLD_RIVER 

Definition at line 29 of file savecompat.h.

Function Documentation

◆ ai_level_convert()

enum ai_level ai_level_convert ( int  old_level)

Convert old ai level value to ai_level

Definition at line 2406 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 227 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 2435 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 215 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 251 of file savecompat.c.

Referenced by compat_load_030100(), and sg_load_player_unit().

◆ current_compat_ver()

int current_compat_ver ( void  )

Return current compatibility version

Definition at line 205 of file savecompat.c.

Referenced by sg_save_savefile().

◆ 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 306 of file savecompat.c.

Referenced by char2resource().

◆ 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 138 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 183 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 266 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 292 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 282 of file savecompat.c.

Referenced by sg_special_set_bv(), and sg_special_set_dbv().