42extern int news_saveArticles( xmlTextWriterPtr writer );
44extern int var_save( xmlTextWriterPtr writer );
48extern int hook_save( xmlTextWriterPtr writer );
56static int save_data( xmlTextWriterPtr writer );
75 if ( news_saveArticles( writer ) < 0 )
87 if ( shiplog_save( writer ) < 0 )
113 xmlTextWriterPtr writer;
117 if ( player_isFlag( PLAYER_NOSAVE ) )
121 writer = xmlNewTextWriterDoc( &doc, 0 );
122 if ( writer == NULL )
129 xmlw_start( writer );
130 xmlw_startElem( writer,
"naev_save" );
133 xmlw_startElem( writer,
"version" );
135 xmlw_elem( writer,
"data",
"%s",
start_name() );
136 xmlw_endElem( writer );
139 xmlw_saveTime( writer,
"last_played", time( NULL ) );
142 xmlw_startElem( writer,
"plugins" );
145 xmlw_endElem( writer );
149 WARN( _(
"Trying to save game data" ) );
154 xmlw_endElem( writer );
158 if ( PHYSFS_mkdir(
"saves" ) == 0 ) {
159 snprintf( file,
sizeof( file ),
"%s/saves", PHYSFS_getWriteDir() );
160 WARN( _(
"Dir '%s' does not exist and unable to create: %s" ), file,
161 _( PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) ) );
164 snprintf( file,
sizeof( file ),
"saves/%s",
player.name );
165 if ( PHYSFS_mkdir( file ) == 0 ) {
166 snprintf( file,
sizeof( file ),
"%s/saves/%s", PHYSFS_getWriteDir(),
168 WARN( _(
"Dir '%s' does not exist and unable to create: %s" ), file,
169 _( PHYSFS_getErrorByCode( PHYSFS_getLastErrorCode() ) ) );
174 if ( !strcmp( name,
"autosave" ) ) {
177 snprintf( file,
sizeof( file ),
"saves/%s/autosave.ns",
player.name );
178 snprintf( backup,
sizeof( backup ),
"saves/%s/backup.ns",
181 WARN( _(
"Aborting saveā¦" ) );
190 xmlFreeTextWriter( writer );
191 snprintf( file,
sizeof( file ),
"%s/saves/%s/%s.ns", PHYSFS_getWriteDir(),
193 if ( xmlSaveFileEnc( file, doc,
"UTF-8" ) < 0 ) {
201 xmlFreeTextWriter( writer );
206 _(
"Failed to write saved game! You'll most likely have to restore it "
207 "by copying your backup saved game over your current saved game." );
221 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.
void dialogue_alert(const char *fmt,...)
Displays an alert popup with only an ok button and a message.
int load_game(const nsave_t *ns)
Actually loads a new game based on save structure.
const nsave_t * load_getList(const char *name)
Gets the array (array.h) of loaded saves.
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.
static plugin_t * plugins
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 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.
int space_playerSave(xmlTextWriterPtr writer)
Saves what is needed to be saved for space.
const char * start_name(void)
Gets the module name.