![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <fc_config.h>#include <QBitArray>#include <QSet>#include <cstdarg>#include <cstdio>#include <cstdlib>#include <cstring>#include <sstream>#include "bitvector.h"#include "capability.h"#include "fcintl.h"#include "idex.h"#include "log.h"#include "rand.h"#include "registry.h"#include "shared.h"#include "support.h"#include "timing.h"#include "fc_version.h"#include "achievements.h"#include "ai.h"#include "citizens.h"#include "city.h"#include "game.h"#include "government.h"#include "map.h"#include "mapimg.h"#include "movement.h"#include "multipliers.h"#include "packets.h"#include "research.h"#include "rgbcolor.h"#include "specialist.h"#include "style.h"#include "unit.h"#include "unitlist.h"#include "version.h"#include "citizenshand.h"#include "citytools.h"#include "cityturn.h"#include "diplhand.h"#include "maphand.h"#include "meta.h"#include "notify.h"#include "plrhand.h"#include "report.h"#include "ruleset.h"#include "sanitycheck.h"#include "savecompat.h"#include "settings.h"#include "spacerace.h"#include "srv_main.h"#include "techtools.h"#include "unittools.h"#include "advbuilding.h"#include "advdata.h"#include "infracache.h"#include "mapgen_utils.h"#include "script_server.h"#include "aitraits.h"#include "difficulty.h"#include "savegame3.h"Go to the source code of this file.
Classes | |
| struct | savedata |
Macros | |
| #define | SAVE_MAP_CHAR(ptile, GET_XY_CHAR, secfile, secpath, ...) |
| #define | LOAD_MAP_CHAR(ch, ptile, SET_XY_CHAR, secfile, secpath, ...) |
| #define | halfbyte_iterate_extras(e, num_extras_types) |
| #define | halfbyte_iterate_extras_end |
| #define | TOKEN_SIZE 10 |
| #define | PART_SIZE (3 * 256) |
| #define | PART_ADJUST (3) |
Functions | |
| static void | savegame3_save_real (struct section_file *file, const char *save_reason, bool scenario) |
| Really save the game to a file. More... | |
| static struct loaddata * | loaddata_new (struct section_file *file) |
| Create new loaddata item for given section file. More... | |
| static void | loaddata_destroy (struct loaddata *loading) |
| Free resources allocated for loaddata item. More... | |
| static struct savedata * | savedata_new (struct section_file *file, const char *save_reason, bool scenario) |
| Create new savedata item for given file. More... | |
| static void | savedata_destroy (struct savedata *saving) |
| Free resources allocated for savedata item. More... | |
| static enum unit_orders | char2order (char order) |
| Returns an order for a character identifier. More... | |
| static char | order2char (enum unit_orders order) |
| Returns a character identifier for an order. More... | |
| static enum direction8 | char2dir (char dir) |
| Returns a direction for a character identifier. More... | |
| static char | dir2char (enum direction8 dir) |
| Returns a character identifier for a direction. More... | |
| static char | activity2char (enum unit_activity activity) |
| Returns a character identifier for an activity. More... | |
| static enum unit_activity | char2activity (char activity) |
| Returns an activity for a character identifier. More... | |
| static char * | quote_block (const void *const data, int length) |
| Quote the memory block denoted by data and length so it consists only of " a-f0-9:". More... | |
| static int | unquote_block (const char *const quoted_, void *dest, int dest_length) |
| Unquote a string. More... | |
| static void | worklist_load (struct section_file *file, struct worklist *pwl, const char *path,...) |
| Load the worklist elements specified by path to the worklist pointed to by 'pwl'. More... | |
| static void | worklist_save (struct section_file *file, const struct worklist *pwl, int max_length, const char *path,...) |
| Save the worklist elements specified by path from the worklist pointed to by 'pwl'. More... | |
| static void | unit_ordering_calc () |
| Assign values to ord_city and ord_map for each unit, so the values can be saved. More... | |
| static void | unit_ordering_apply () |
| For each city and tile, sort unit lists according to ord_city and ord_map values. More... | |
| static void | sg_extras_set (bv_extras *extras, char ch, struct extra_type **idx) |
| Helper function for loading extras from a savegame. More... | |
| static char | sg_extras_get (bv_extras extras, struct extra_type *presource, const int *idx) |
| Helper function for saving extras into a savegame. More... | |
| static struct terrain * | char2terrain (char ch) |
| Dereferences the terrain character. More... | |
| static char | terrain2char (const struct terrain *pterrain) |
| References the terrain character. More... | |
| static Tech_type_id | technology_load (struct section_file *file, const char *path, int plrno) |
| Load technology from path_name and if doesn't exist (because savegame is too old) load from path. More... | |
| static void | technology_save (struct section_file *file, const char *path, int plrno, Tech_type_id tech) |
| Save technology in secfile entry called path_name. More... | |
| static void | sg_load_savefile (struct loaddata *loading) |
| Load '[savefile]'. More... | |
| static void | sg_save_savefile (struct savedata *saving) |
| Save '[savefile]'. More... | |
| static void | sg_save_savefile_options (struct savedata *saving, const char *option) |
| Save options for this savegame. More... | |
| static void | sg_load_game (struct loaddata *loading) |
| Load '[game]'. More... | |
| static void | sg_save_game (struct savedata *saving) |
| Save '[game]'. More... | |
| static void | sg_load_ruledata (struct loaddata *loading) |
| Load '[ruledata]'. More... | |
| static void | sg_save_ruledata (struct savedata *saving) |
| Save '[ruledata]'. More... | |
| static void | sg_load_random (struct loaddata *loading) |
| Load '[random]'. More... | |
| static void | sg_save_random (struct savedata *saving) |
| Save '[random]'. More... | |
| static void | sg_load_script (struct loaddata *loading) |
| Load '[script]'. More... | |
| static void | sg_save_script (struct savedata *saving) |
| Save '[script]'. More... | |
| static void | sg_load_scenario (struct loaddata *loading) |
| Load '[scenario]'. More... | |
| static void | sg_save_scenario (struct savedata *saving) |
| Save '[scenario]'. More... | |
| static void | sg_load_settings (struct loaddata *loading) |
| Load '[settings]'. More... | |
| static void | sg_save_settings (struct savedata *saving) |
| Save [settings]. More... | |
| static void | sg_load_map (struct loaddata *loading) |
| Load '[map']. More... | |
| static void | sg_save_map (struct savedata *saving) |
| Save 'map'. More... | |
| static void | sg_load_map_tiles (struct loaddata *loading) |
| Load tiles of the map. More... | |
| static void | sg_save_map_tiles (struct savedata *saving) |
| Save all map tiles. More... | |
| static void | sg_load_map_tiles_extras (struct loaddata *loading) |
| Load extras to map. More... | |
| static void | sg_save_map_tiles_extras (struct savedata *saving) |
| Save information about extras on map. More... | |
| static void | sg_load_map_startpos (struct loaddata *loading) |
| Load starting positions for the players from a savegame file. More... | |
| static void | sg_save_map_startpos (struct savedata *saving) |
| Save the map start positions. More... | |
| static void | sg_load_map_owner (struct loaddata *loading) |
| Load tile owner information. More... | |
| static void | sg_save_map_owner (struct savedata *saving) |
| Save tile owner information. More... | |
| static void | sg_load_map_worked (struct loaddata *loading) |
| Load worked tiles information. More... | |
| static void | sg_save_map_worked (struct savedata *saving) |
| Save worked tiles information. More... | |
| static void | sg_load_map_known (struct loaddata *loading) |
| Load tile known status. More... | |
| static void | sg_save_map_known (struct savedata *saving) |
| Save tile known status for whole map and all players. More... | |
| static void | sg_load_players_basic (struct loaddata *loading) |
| Load '[player]' (basic data). More... | |
| static void | sg_load_players (struct loaddata *loading) |
| Load '[player]'. More... | |
| static void | sg_load_player_main (struct loaddata *loading, struct player *plr) |
| Main player data loading function. More... | |
| static void | sg_load_player_cities (struct loaddata *loading, struct player *plr) |
| Load city data. More... | |
| static bool | sg_load_player_city (struct loaddata *loading, struct player *plr, struct city *pcity, const char *citystr) |
| Load data for one city. More... | |
| static void | sg_load_player_city_citizens (struct loaddata *loading, struct player *plr, struct city *pcity, const char *citystr) |
| Load nationality data for one city. More... | |
| static void | sg_load_player_units (struct loaddata *loading, struct player *plr) |
| Load unit data. More... | |
| static bool | sg_load_player_unit (struct loaddata *loading, struct player *plr, struct unit *punit, const char *unitstr) |
| Load one unit. More... | |
| static void | sg_load_player_units_transport (struct loaddata *loading, struct player *plr) |
| Load the transport status of all units. More... | |
| static void | sg_load_player_attributes (struct loaddata *loading, struct player *plr) |
| Load player (client) attributes data. More... | |
| static void | sg_load_player_vision (struct loaddata *loading, struct player *plr) |
| Load vision data. More... | |
| static bool | sg_load_player_vision_city (struct loaddata *loading, struct player *plr, struct vision_site *pdcity, const char *citystr) |
| Load data for one seen city. More... | |
| static void | sg_save_players (struct savedata *saving) |
| Save '[player]'. More... | |
| static void | sg_save_player_main (struct savedata *saving, struct player *plr) |
| Main player data saving function. More... | |
| static void | sg_save_player_cities (struct savedata *saving, struct player *plr) |
| Save cities data. More... | |
| static void | sg_save_player_units (struct savedata *saving, struct player *plr) |
| Save unit data. More... | |
| static void | sg_save_player_attributes (struct savedata *saving, struct player *plr) |
| Save player (client) attributes data. More... | |
| static void | sg_save_player_vision (struct savedata *saving, struct player *plr) |
| Save vision data. More... | |
| static void | sg_load_researches (struct loaddata *loading) |
| Load '[research]'. More... | |
| static void | sg_save_researches (struct savedata *saving) |
| Save '[research]'. More... | |
| static void | sg_load_event_cache (struct loaddata *loading) |
| Load '[event_cache]'. More... | |
| static void | sg_save_event_cache (struct savedata *saving) |
| Save '[event_cache]'. More... | |
| static void | sg_load_treaties (struct loaddata *loading) |
| Load '[treaty_xxx]'. More... | |
| static void | sg_save_treaties (struct savedata *saving) |
| Save '[treaty_xxx]'. More... | |
| static void | sg_load_history (struct loaddata *loading) |
| Load '[history]'. More... | |
| static void | sg_save_history (struct savedata *saving) |
| Save '[history]'. More... | |
| static void | sg_load_mapimg (struct loaddata *loading) |
| Load '[mapimg]'. More... | |
| static void | sg_save_mapimg (struct savedata *saving) |
| Save '[mapimg]'. More... | |
| static void | sg_load_sanitycheck (struct loaddata *loading) |
| Sanity check for loaded game. More... | |
| static void | sg_save_sanitycheck (struct savedata *saving) |
| Sanity check for saved game. More... | |
| void | savegame3_save (struct section_file *sfile, const char *save_reason, bool scenario) |
| Main entry point for saving a game in savegame3 format. More... | |
| void | savegame3_load (struct section_file *file) |
| Really loading the savegame. More... | |
Variables | |
| bool | sg_success |
| static const char | savefile_options_default [] = " +version3" |
| #define halfbyte_iterate_extras | ( | e, | |
| num_extras_types | |||
| ) |
Definition at line 251 of file savegame3.cpp.
| #define halfbyte_iterate_extras_end |
Definition at line 256 of file savegame3.cpp.
| #define LOAD_MAP_CHAR | ( | ch, | |
| ptile, | |||
| SET_XY_CHAR, | |||
| secfile, | |||
| secpath, | |||
| ... | |||
| ) |
Definition at line 214 of file savegame3.cpp.
| #define PART_ADJUST (3) |
| #define PART_SIZE (3 * 256) |
| #define SAVE_MAP_CHAR | ( | ptile, | |
| GET_XY_CHAR, | |||
| secfile, | |||
| secpath, | |||
| ... | |||
| ) |
Definition at line 165 of file savegame3.cpp.
| #define TOKEN_SIZE 10 |
Definition at line 272 of file savegame3.cpp.
|
static |
Returns a character identifier for an activity.
See also char2activity.
Definition at line 751 of file savegame3.cpp.
Referenced by sg_save_player_cities(), and sg_save_player_units().
|
static |
Returns an activity for a character identifier.
See also activity2char.
Definition at line 751 of file savegame3.cpp.
Referenced by sg_load_player_city(), and sg_load_player_unit().
|
static |
Returns a direction for a character identifier.
See also dir2char.
Definition at line 669 of file savegame3.cpp.
Referenced by sg_load_player_city(), and sg_load_player_unit().
|
static |
Returns an order for a character identifier.
See also order2char.
Definition at line 633 of file savegame3.cpp.
Referenced by sg_load_player_city(), and sg_load_player_unit().
|
static |
Dereferences the terrain character.
See terrains[].identifier example: char2terrain('a') => T_ARCTIC
Definition at line 1085 of file savegame3.cpp.
Referenced by sg_load_map_tiles(), and sg_load_player_vision().
|
static |
Returns a character identifier for a direction.
See also char2dir.
Definition at line 722 of file savegame3.cpp.
Referenced by sg_save_player_cities(), and sg_save_player_units().
|
static |
Free resources allocated for loaddata item.
Definition at line 594 of file savegame3.cpp.
Referenced by savegame3_load().
|
static |
Create new loaddata item for given section file.
Definition at line 557 of file savegame3.cpp.
Referenced by savegame3_load().
|
static |
Returns a character identifier for an order.
See also char2order.
Definition at line 669 of file savegame3.cpp.
Referenced by sg_save_player_cities(), and sg_save_player_units().
|
static |
Quote the memory block denoted by data and length so it consists only of " a-f0-9:".
The returned string has to be deleted by the caller.
Definition at line 830 of file savegame3.cpp.
Referenced by sg_save_player_attributes().
|
static |
Free resources allocated for savedata item.
Definition at line 633 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Create new savedata item for given file.
Definition at line 614 of file savegame3.cpp.
Referenced by savegame3_save_real().
| void savegame3_load | ( | struct section_file * | file | ) |
Really loading the savegame.
Definition at line 436 of file savegame3.cpp.
Referenced by savegame_load().
| void savegame3_save | ( | struct section_file * | sfile, |
| const char * | save_reason, | ||
| bool | scenario | ||
| ) |
Main entry point for saving a game in savegame3 format.
Definition at line 412 of file savegame3.cpp.
Referenced by savegame_save().
|
static |
Really save the game to a file.
Definition at line 503 of file savegame3.cpp.
Referenced by savegame3_save().
|
static |
Helper function for saving extras into a savegame.
Extras are packed in four to a character in hex notation. 'index' specifies which set of extras are included in this character.
Definition at line 1056 of file savegame3.cpp.
Referenced by sg_save_map_tiles_extras(), and sg_save_player_vision().
|
static |
Helper function for loading extras from a savegame.
'ch' gives the character loaded from the savegame. Extras are packed in four to a character in hex notation. 'index' is a mapping of savegame bit -> base bit.
Definition at line 1023 of file savegame3.cpp.
Referenced by sg_load_map_tiles_extras(), and sg_load_player_vision().
|
static |
Load '[event_cache]'.
Definition at line 7215 of file savegame3.cpp.
Referenced by savegame3_load().
|
static |
|
static |
|
static |
|
static |
|
static |
Load tile owner information.
Definition at line 2856 of file savegame3.cpp.
Referenced by sg_load_map().
|
static |
Load starting positions for the players from a savegame file.
There should be at least enough for every player.
Definition at line 2712 of file savegame3.cpp.
Referenced by sg_load_map().
|
static |
|
static |
|
static |
Load worked tiles information.
Definition at line 3104 of file savegame3.cpp.
Referenced by sg_load_map().
|
static |
Load player (client) attributes data.
Definition at line 6415 of file savegame3.cpp.
Referenced by sg_load_players().
|
static |
Load data for one city.
sg_save_player_city() is not defined.
Definition at line 4693 of file savegame3.cpp.
Referenced by sg_load_player_cities().
|
static |
Load nationality data for one city.
Definition at line 5095 of file savegame3.cpp.
Referenced by sg_load_player_cities().
Main player data loading function.
Definition at line 3832 of file savegame3.cpp.
Referenced by sg_load_players().
|
static |
Load one unit.
sg_save_player_unit() is not defined.
Definition at line 5605 of file savegame3.cpp.
Referenced by sg_load_player_units().
|
static |
Load the transport status of all units.
This is seperated from the other code as all units must be known.
Definition at line 6114 of file savegame3.cpp.
Referenced by sg_load_players().
|
static |
Load data for one seen city.
sg_save_player_vision_city() is not defined.
Definition at line 6759 of file savegame3.cpp.
Referenced by sg_load_player_vision().
|
static |
|
static |
Load '[player]' (basic data).
Definition at line 3318 of file savegame3.cpp.
Referenced by savegame3_load().
|
static |
|
static |
|
static |
|
static |
Sanity check for loaded game.
Definition at line 7480 of file savegame3.cpp.
Referenced by savegame3_load().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Save '[event_cache]'.
Definition at line 7226 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
|
static |
Save '[history]'.
Definition at line 7396 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
|
static |
Save tile known status for whole map and all players.
Definition at line 3249 of file savegame3.cpp.
Referenced by sg_save_map().
|
static |
Save tile owner information.
Definition at line 2979 of file savegame3.cpp.
Referenced by sg_save_map().
|
static |
Save the map start positions.
Definition at line 2799 of file savegame3.cpp.
Referenced by sg_save_map().
|
static |
|
static |
Save information about extras on map.
Definition at line 2684 of file savegame3.cpp.
Referenced by sg_save_map().
|
static |
Save worked tiles information.
Definition at line 3148 of file savegame3.cpp.
Referenced by sg_save_map().
|
static |
Save '[mapimg]'.
Definition at line 7455 of file savegame3.cpp.
Referenced by savegame3_save_real().
Save player (client) attributes data.
Definition at line 6483 of file savegame3.cpp.
Referenced by sg_save_players().
Main player data saving function.
Definition at line 4275 of file savegame3.cpp.
Referenced by sg_save_players().
|
static |
Save '[player]'.
Definition at line 3768 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save '[random]'.
Definition at line 2235 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save '[research]'.
Definition at line 7144 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save '[ruledata]'.
Definition at line 2045 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Sanity check for saved game.
Definition at line 7654 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save '[savefile]'.
Definition at line 1561 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save options for this savegame.
sg_load_savefile_options() is not defined.
Definition at line 1844 of file savegame3.cpp.
Referenced by sg_save_savefile().
|
static |
Save '[scenario]'.
Definition at line 2368 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save '[script]'.
Definition at line 2273 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save [settings].
Definition at line 2463 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Save '[treaty_xxx]'.
Definition at line 7327 of file savegame3.cpp.
Referenced by savegame3_save_real().
|
static |
Load technology from path_name and if doesn't exist (because savegame is too old) load from path.
Definition at line 1120 of file savegame3.cpp.
Referenced by sg_load_researches().
|
static |
Save technology in secfile entry called path_name.
Definition at line 1155 of file savegame3.cpp.
Referenced by sg_save_researches().
|
static |
References the terrain character.
See terrains[].identifier example: terrain2char(T_ARCTIC) => 'a'
Definition at line 1107 of file savegame3.cpp.
Referenced by sg_save_map_tiles(), and sg_save_player_vision().
|
static |
For each city and tile, sort unit lists according to ord_city and ord_map values.
Definition at line 997 of file savegame3.cpp.
Referenced by sg_load_players().
|
static |
Assign values to ord_city and ord_map for each unit, so the values can be saved.
Definition at line 962 of file savegame3.cpp.
Referenced by sg_save_players().
|
static |
Unquote a string.
The unquoted data is written into dest. If the unquoted data will be larger than dest_length the function aborts. It returns the actual length of the unquoted block.
Definition at line 852 of file savegame3.cpp.
Referenced by sg_load_player_attributes().
|
static |
Load the worklist elements specified by path to the worklist pointed to by 'pwl'.
'pwl' should be a pointer to an existing worklist.
Definition at line 884 of file savegame3.cpp.
Referenced by sg_load_player_city().
|
static |
Save the worklist elements specified by path from the worklist pointed to by 'pwl'.
'pwl' should be a pointer to an existing worklist.
Definition at line 924 of file savegame3.cpp.
Referenced by sg_save_player_cities().
|
static |
Definition at line 274 of file savegame3.cpp.
Referenced by sg_save_savefile().
|
extern |
Definition at line 30 of file savecompat.cpp.
Referenced by savegame3_load(), savegame3_save_real(), and sg_load_savefile().