14 #include <fc_config.h>
48 const char *savefile_options;
57 if (!savefile_options) {
58 qCritical(
"Missing savefile options. Can not load the savegame.");
64 qDebug(
"loading savefile in 3.0+ format ...");
68 qDebug(
"loading savefile in 2.3 - 2.6 format ...");
71 qCritical(
"Too old savegame format not supported any more.");
94 qCDebug(timers_category,
"Loading secfile in %.3f seconds.",
126 _(
"Failed saving game."));
139 void save_game(
const char *orig_filename,
const char *save_reason,
142 char *dot, *filename;
148 if (!orig_filename) {
153 filename = strrchr(stdata->
filepath,
'/');
161 for (dot = filename;
'.' == *dot; dot++) {
169 const char *strip_extensions[] = {
".sav",
".gz",
".bz2",
170 ".xz",
".zst",
nullptr};
171 bool stripped =
true;
173 while ((end_dot = strrchr(dot,
'.')) && stripped) {
178 for (i = 0; strip_extensions[i] !=
nullptr && !stripped; i++) {
179 if (!strcmp(end_dot, strip_extensions[i])) {
189 if (filename[0] ==
'\0') {
218 #ifdef FREECIV_HAVE_BZ2
224 #ifdef FREECIV_HAVE_LZMA
230 #ifdef FREECIV_HAVE_ZSTD
239 qCritical(
_(
"Unsupported compression type %d."),
242 _(
"Unsupported compression type %d."),
248 if (!QFileInfo(stdata->
filepath).isAbsolute()) {
265 if (!tmpname.isEmpty()) {
266 tmpname += QLatin1String(
"/");
268 tmpname += QString::fromUtf8(stdata->
filepath);
273 if (!save_thread->isRunning()) {
275 save_thread->start(QThread::LowestPriority);
278 log_time(QStringLiteral(
"Save time: %1 seconds")
#define CALL_FUNC_EACH_AI(_func,...)
#define CALL_PLR_AI_FUNC(_func, _player,...)
bool has_capabilities(const char *us, const char *them)
This routine returns true if all the mandatory capabilities in us appear in them.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void con_write(enum rfc_status rfc_status, const char *message,...)
Write to console and add line-break, and show prompt if required.
const struct ft_color ftc_warning
int generate_save_name(const char *format, char *buf, int buflen, const char *reason)
Generate a default save file name and place it in the provided buffer.
void log_time(const QString &msg, bool log)
#define fc_assert_ret(condition)
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
See notify_conn_packet - this is just the "non-v" version, with varargs.
#define players_iterate_end
#define players_iterate(_pplayer)
const char * secfile_error()
Returns the last error which occurred in a string.
struct section_file * secfile_new(bool allow_duplicates)
Create a new empty section file.
void secfile_destroy(struct section_file *secfile)
Free a section file.
bool secfile_save(const struct section_file *secfile, QString filename)
Save the previously filled in section_file to disk.
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
Lookup a string value in the secfile.
void savegame2_load(struct section_file *file)
Really loading the savegame.
void savegame3_save(struct section_file *sfile, const char *save_reason, bool scenario)
Main entry point for saving a game in savegame3 format.
void savegame3_load(struct section_file *file)
Really loading the savegame.
void savegame_load(struct section_file *sfile)
Main entry point for loading a game.
void save_system_close()
Close saving system.
void savegame_save(struct section_file *sfile, const char *save_reason, bool scenario)
Main entry point for saving a game.
Q_GLOBAL_STATIC(fcThread, save_thread)
static void save_thread_run(void *arg)
Run game saving thread.
void save_game(const char *orig_filename, const char *save_reason, bool scenario)
Unconditionally save the game, with specified filename.
struct server_arguments srvarg
struct civ_game::@28::@32 server
struct section_file * sfile
compress_type save_compress_type
QString scenarios_pathname
#define sz_strlcpy(dest, src)
#define sz_strlcat(dest, src)
void timer_destroy(civtimer *t)
Deletes timer.
double timer_read_seconds(civtimer *t)
Read value from timer.
civtimer * timer_new(enum timer_timetype type, enum timer_use use)
Allocate a new timer with specified "type" and "use".
void timer_start(civtimer *t)
Start timing, adding to previous accumulated time if timer has not been cleared.
void timer_stop(civtimer *t)
Stop timing, and accumulate time so far.
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end