50extern int news_saveArticles( xmlTextWriterPtr writer );
52extern int var_save( xmlTextWriterPtr writer );
56extern int hook_save( xmlTextWriterPtr writer );
62extern int diff_save( xmlTextWriterPtr writer );
64static int save_data( xmlTextWriterPtr writer );
79 if (news_saveArticles( writer ) < 0)
return -1;
85 if (shiplog_save(writer) < 0)
return -1;
110 xmlTextWriterPtr writer;
113 if (player_isFlag(PLAYER_NOSAVE))
118 if (writer == NULL) {
119 ERR(_(
"testXmlwriterDoc: Error creating the xml writer"));
128 xmlw_startElem(writer,
"naev_save");
131 xmlw_startElem(writer,
"version");
133 xmlw_elem( writer,
"data",
"%s",
start_name() );
134 xmlw_endElem(writer);
137 xmlw_saveTime( writer,
"last_played", time(NULL) );
140 xmlw_startElem(writer,
"plugins");
142 xmlw_elem( writer,
"plugin",
"%s",
plugin_name( &plugins[i] ) );
143 xmlw_endElem(writer);
147 ERR(_(
"Trying to save game data"));
152 xmlw_endElem(writer);
156 if (PHYSFS_mkdir(
"saves") == 0) {
157 snprintf(file,
sizeof(file),
"%s/saves", PHYSFS_getWriteDir());
158 WARN(_(
"Dir '%s' does not exist and unable to create: %s" ), file,
159 _(PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) ) );
162 snprintf(file,
sizeof(file),
"saves/%s",
player.
name);
163 if (PHYSFS_mkdir(file) == 0) {
164 snprintf(file,
sizeof(file),
"%s/saves/%s", PHYSFS_getWriteDir(),
player.
name);
165 WARN(_(
"Dir '%s' does not exist and unable to create: %s" ), file,
166 _(PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) ) );
171 if (!strcmp(name,
"autosave")) {
174 snprintf(file,
sizeof(file),
"saves/%s/autosave.ns",
player.
name);
175 snprintf(backup,
sizeof(backup),
"saves/%s/backup.ns",
player.
name);
177 WARN(_(
"Aborting saveā¦"));
186 xmlFreeTextWriter(writer);
187 snprintf(file,
sizeof(file),
"%s/saves/%s/%s.ns", PHYSFS_getWriteDir(),
player.
name, name);
188 if (xmlSaveFileEnc(file, doc,
"UTF-8") < 0) {
189 WARN(_(
"Failed to write saved game! You'll most likely have to restore it by copying your backup saved game over your current saved game."));
197 xmlFreeTextWriter(writer);
211 WARN(_(
"Unable to reload save for '%s'!"),
player.
name);
Provides macros to work with dynamic arrays.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
const nsave_t * load_getList(const char *name)
Gets the array (array.h) of loaded saves.
int load_gameFile(const char *file)
Loads the game from a file.
int missions_saveActive(xmlTextWriterPtr writer)
Saves the player's active missions.
Header file with generic functions and naev-specifics.
const char * naev_version(int long_version)
Returns the version in a human readable string.
int ndata_copyIfExists(const char *file1, const char *file2)
Copy a file, if it exists.
void xmlw_setParams(xmlTextWriterPtr writer)
Sets up the standard xml write parameters.
const char * plugin_name(const plugin_t *plg)
Tries to tget the name of a plugin.
const plugin_t * plugin_list(void)
Returns the list of all the plugins.
int player_save(xmlTextWriterPtr writer)
Save the freaking player in a freaking xmlfile.
int var_save(xmlTextWriterPtr writer)
Saves the mission variables.
void save_reload(void)
Reload the current saved game.
int save_all_with_name(const char *name)
Saves the current game.
int save_all(void)
Saves the current game.
int space_sysSave(xmlTextWriterPtr writer)
Saves what is needed to be saved for space.
int pfaction_save(xmlTextWriterPtr writer)
Saves player's standings with the factions.
static int save_data(xmlTextWriterPtr writer)
Saves all the player's game data.
int events_saveActive(xmlTextWriterPtr writer)
Saves the player's active events.
int economy_sysSave(xmlTextWriterPtr writer)
Saves what is needed to be saved for economy.
int diff_save(xmlTextWriterPtr writer)
Saves the active diffs.
int hook_save(xmlTextWriterPtr writer)
Saves all the hooks.
const char * start_name(void)
Gets the module name.