naev 0.11.5
load.c File Reference

Contains stuff to load a pilot or look up information about it. More...

#include "load.h"
#include "array.h"
#include "dialogue.h"
#include "economy.h"
#include "event.h"
#include "faction.h"
#include "difficulty.h"
#include "gui.h"
#include "hook.h"
#include "land.h"
#include "log.h"
#include "menu.h"
#include "mission.h"
#include "news.h"
#include "ndata.h"
#include "nlua_var.h"
#include "nstring.h"
#include "nxml.h"
#include "outfit.h"
#include "player.h"
#include "plugin.h"
#include "render.h"
#include "save.h"
#include "shiplog.h"
#include "start.h"
#include "space.h"
#include "toolkit.h"
#include "unidiff.h"

Go to the source code of this file.

Data Structures

struct  player_saves_t
 

Macros

#define LOAD_WIDTH   600
 
#define LOAD_HEIGHT   530
 
#define BUTTON_WIDTH   120
 
#define BUTTON_HEIGHT   30
 

Functions

Spobplayer_load (xmlNodePtr parent)
 Loads the player stuff.
 
int events_loadActive (xmlNodePtr parent)
 Loads the player's active events from a save.
 
int news_loadArticles (xmlNodePtr parent)
 Loads the player's active articles from a save, initilizes news.
 
int var_load (xmlNodePtr parent)
 Loads the vars from XML file.
 
int pfaction_load (xmlNodePtr parent)
 Loads the player's faction standings.
 
int hook_load (xmlNodePtr parent)
 Loads hooks for a player.
 
int space_sysLoad (xmlNodePtr parent)
 Loads player's space properties from an XML node.
 
int economy_sysLoad (xmlNodePtr parent)
 Loads player's economy properties from an XML node.
 
int diff_load (xmlNodePtr parent)
 Loads the diffs.
 
static void load_menu_update (unsigned int wid, const char *str)
 Updates the load menu.
 
static void load_menu_close (unsigned int wdw, const char *str)
 Closes the load game menu.
 
static void load_menu_load (unsigned int wdw, const char *str)
 Loads a new game.
 
static void load_menu_delete (unsigned int wdw, const char *str)
 
static void load_menu_snapshots (unsigned int wdw, const char *str)
 Opens the load snapshot menu.
 
static void load_snapshot_menu_update (unsigned int wid, const char *str)
 Updates the load snapshot menu.
 
static void load_snapshot_menu_close (unsigned int wdw, const char *str)
 Closes the load snapshot menu.
 
static void load_snapshot_menu_onClose (unsigned int wid, const char *str)
 
static void load_snapshot_menu_load (unsigned int wdw, const char *str)
 Loads a new game.
 
static void load_snapshot_menu_delete (unsigned int wdw, const char *str)
 Deletes an old game.
 
static void load_snapshot_menu_save (unsigned int wdw, const char *str)
 Creates new custom snapshot.
 
static void display_save_info (unsigned int wid, const nsave_t *ns)
 Displays Naev save info.
 
static void move_old_save (const char *path, const char *fname, const char *ext, const char *new_name)
 Moves old Naev saves to subdirectories.
 
static int load_load (nsave_t *save, const char *path)
 Loads an individual save.
 
static int load_game (const nsave_t *ns)
 Actually loads a new game based on save structure.
 
static int load_gameInternal (const char *file, const char *version)
 Actually loads a new game.
 
static int load_gameInternalHook (void *data)
 Loads a game. Meant to be run in a function hook.
 
static int load_enumerateCallback (void *data, const char *origdir, const char *fname)
 The PHYSFS_EnumerateCallback for load_refresh.
 
static int load_enumerateCallbackPlayer (void *data, const char *origdir, const char *fname)
 
static int load_compatibilityTest (const nsave_t *ns)
 
static const char * load_compatibilityString (const nsave_t *ns)
 
static SaveCompatibility load_compatibility (const nsave_t *ns)
 Checks to see if a save is compatible with current Naev.
 
static int load_sortComparePlayers (const void *p1, const void *p2)
 qsort compare function for files.
 
static int load_sortCompare (const void *p1, const void *p2)
 qsort compare function for files.
 
static xmlDocPtr load_xml_parsePhysFS (const char *filename)
 Temporary (hopefully) wrapper around xml_parsePhysFS in support of gzipped XML (like .ns files).
 
int load_refresh (void)
 Loads or refreshes saved games for the player.
 
void load_free (void)
 Frees loaded save stuff.
 
const nsave_tload_getList (const char *name)
 Gets the array (array.h) of loaded saves.
 
void load_loadGameMenu (void)
 Opens the load game menu.
 
void load_loadSnapshotMenu (const char *name, int disablesave)
 Opens the load snapshot menu.
 
static void load_compatSlots (void)
 
int load_gameDiff (const char *file)
 Loads the diffs from game file.
 
int load_gameFile (const char *file)
 Loads the game from a file.
 

Variables

static player_saves_tload_saves = NULL
 
static player_saves_tload_player = NULL
 
static int old_saves_detected = 0
 
static int player_warned = 0
 
static char * selected_player = NULL
 
int save_loaded
 

Detailed Description

Contains stuff to load a pilot or look up information about it.

Definition in file load.c.

Macro Definition Documentation

◆ BUTTON_HEIGHT

#define BUTTON_HEIGHT   30

Button height.

Definition at line 50 of file load.c.

◆ BUTTON_WIDTH

#define BUTTON_WIDTH   120

Button width.

Definition at line 49 of file load.c.

◆ LOAD_HEIGHT

#define LOAD_HEIGHT   530

Load window height.

Definition at line 47 of file load.c.

◆ LOAD_WIDTH

#define LOAD_WIDTH   600

Load window width.

Definition at line 46 of file load.c.

Function Documentation

◆ diff_load()

int diff_load ( xmlNodePtr parent)
extern

Loads the diffs.

Loads the universe diffs.

Parameters
parentParent node containing diffs.
Returns
0 on success.

Definition at line 1797 of file unidiff.c.

◆ display_save_info()

static void display_save_info ( unsigned int wid,
const nsave_t * ns )
static

Displays Naev save info.

Parameters
widWidget for displaying save info.
nsNaev save.

Definition at line 728 of file load.c.

◆ economy_sysLoad()

int economy_sysLoad ( xmlNodePtr parent)
extern

Loads player's economy properties from an XML node.

Loads the economy stuff.

Parameters
parentParent node for economy.
Returns
0 on success.

Definition at line 1001 of file economy.c.

◆ events_loadActive()

int events_loadActive ( xmlNodePtr parent)
extern

Loads the player's active events from a save.

Parameters
parentNode containing the player's active events.
Returns
0 on success.

Definition at line 854 of file event.c.

◆ hook_load()

int hook_load ( xmlNodePtr parent)
extern

Loads hooks for a player.

Loads hooks.

Parameters
parentParent xml node containing the hooks.
Returns
0 on success.

Definition at line 1232 of file hook.c.

◆ load_compatibility()

static SaveCompatibility load_compatibility ( const nsave_t * ns)
static

Checks to see if a save is compatible with current Naev.

Definition at line 385 of file load.c.

◆ load_compatibilityString()

static const char * load_compatibilityString ( const nsave_t * ns)
static

Definition at line 367 of file load.c.

◆ load_compatibilityTest()

static int load_compatibilityTest ( const nsave_t * ns)
static

Definition at line 324 of file load.c.

◆ load_compatSlots()

static void load_compatSlots ( void )
static

Definition at line 1016 of file load.c.

◆ load_enumerateCallback()

static int load_enumerateCallback ( void * data,
const char * origdir,
const char * fname )
static

The PHYSFS_EnumerateCallback for load_refresh.

Definition at line 276 of file load.c.

◆ load_enumerateCallbackPlayer()

static int load_enumerateCallbackPlayer ( void * data,
const char * origdir,
const char * fname )
static

Definition at line 240 of file load.c.

◆ load_free()

void load_free ( void )

Frees loaded save stuff.

Definition at line 447 of file load.c.

◆ load_game()

static int load_game ( const nsave_t * ns)
static

Actually loads a new game based on save structure.

Parameters
nsSave game to load.
Returns
0 on success.

Definition at line 1114 of file load.c.

◆ load_gameDiff()

int load_gameDiff ( const char * file)

Loads the diffs from game file.

Parameters
filePhysicsFS path (i.e., relative path starting with "saves/").
Returns
0 on success.

Definition at line 1063 of file load.c.

◆ load_gameFile()

int load_gameFile ( const char * file)

Loads the game from a file.

Parameters
filePhysicsFS path (i.e., relative path starting with "saves/").
Returns
0 on success

Definition at line 1103 of file load.c.

◆ load_gameInternal()

static int load_gameInternal ( const char * file,
const char * version )
static

Actually loads a new game.

Parameters
filePhysicsFS path (i.e., relative path starting with "saves/").
versionVersion string of game to load.
Returns
0 on success.

Definition at line 1126 of file load.c.

◆ load_gameInternalHook()

static int load_gameInternalHook ( void * data)
static

Loads a game. Meant to be run in a function hook.

Definition at line 1162 of file load.c.

◆ load_getList()

const nsave_t * load_getList ( const char * name)

Gets the array (array.h) of loaded saves.

Definition at line 477 of file load.c.

◆ load_load()

static int load_load ( nsave_t * save,
const char * path )
static

Loads an individual save.

Parameters
[out]saveStructure to populate.
pathPhysicsFS path (i.e., relative path starting with "saves/").
Returns
0 on success.

Definition at line 118 of file load.c.

◆ load_loadGameMenu()

void load_loadGameMenu ( void )

Opens the load game menu.

Definition at line 492 of file load.c.

◆ load_loadSnapshotMenu()

void load_loadSnapshotMenu ( const char * name,
int disablesave )

Opens the load snapshot menu.

Parameters
namePlayer's name.
disablesaveForcibly disable saving.

Definition at line 567 of file load.c.

◆ load_menu_close()

static void load_menu_close ( unsigned int wdw,
const char * str )
static

Closes the load game menu.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 706 of file load.c.

◆ load_menu_delete()

static void load_menu_delete ( unsigned int wdw,
const char * str )
static

Definition at line 936 of file load.c.

◆ load_menu_load()

static void load_menu_load ( unsigned int wdw,
const char * str )
static

Loads a new game.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 862 of file load.c.

◆ load_menu_snapshots()

static void load_menu_snapshots ( unsigned int wdw,
const char * str )
static

Opens the load snapshot menu.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 658 of file load.c.

◆ load_menu_update()

static void load_menu_update ( unsigned int wid,
const char * str )
static

Updates the load menu.

Parameters
widWidget triggering function.
strUnused.

Definition at line 814 of file load.c.

◆ load_refresh()

int load_refresh ( void )

Loads or refreshes saved games for the player.

Definition at line 227 of file load.c.

◆ load_snapshot_menu_close()

static void load_snapshot_menu_close ( unsigned int wdw,
const char * str )
static

Closes the load snapshot menu.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 717 of file load.c.

◆ load_snapshot_menu_delete()

static void load_snapshot_menu_delete ( unsigned int wdw,
const char * str )
static

Deletes an old game.

Parameters
wdwWindow to delete.
strUnused.

Definition at line 973 of file load.c.

◆ load_snapshot_menu_load()

static void load_snapshot_menu_load ( unsigned int wdw,
const char * str )
static

Loads a new game.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 900 of file load.c.

◆ load_snapshot_menu_onClose()

static void load_snapshot_menu_onClose ( unsigned int wid,
const char * str )
static

Definition at line 556 of file load.c.

◆ load_snapshot_menu_save()

static void load_snapshot_menu_save ( unsigned int wdw,
const char * str )
static

Creates new custom snapshot.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 674 of file load.c.

◆ load_snapshot_menu_update()

static void load_snapshot_menu_update ( unsigned int wid,
const char * str )
static

Updates the load snapshot menu.

Parameters
widWidget triggering function.
strUnused.

Definition at line 840 of file load.c.

◆ load_sortCompare()

static int load_sortCompare ( const void * p1,
const void * p2 )
static

qsort compare function for files.

Definition at line 422 of file load.c.

◆ load_sortComparePlayers()

static int load_sortComparePlayers ( const void * p1,
const void * p2 )
static

qsort compare function for files.

Definition at line 411 of file load.c.

◆ load_xml_parsePhysFS()

static xmlDocPtr load_xml_parsePhysFS ( const char * filename)
static

Temporary (hopefully) wrapper around xml_parsePhysFS in support of gzipped XML (like .ns files).

Definition at line 1273 of file load.c.

◆ move_old_save()

static void move_old_save ( const char * path,
const char * fname,
const char * ext,
const char * new_name )
static

Moves old Naev saves to subdirectories.

Parameters
pathPath to old file.
fnameOld filename.
extExtension of file to move.
new_nameName for file in subdirectory.

Definition at line 773 of file load.c.

◆ news_loadArticles()

int news_loadArticles ( xmlNodePtr parent)
extern

Loads the player's active articles from a save, initilizes news.

Parameters
parentNode containing the player's active events.
Returns
0 on success.

Definition at line 488 of file news.c.

◆ pfaction_load()

int pfaction_load ( xmlNodePtr parent)
extern

Loads the player's faction standings.

Loads faction data.

Parameters
parentParent xml node to read from.
Returns
0 on success.

Definition at line 1791 of file faction.c.

◆ player_load()

Spob * player_load ( xmlNodePtr parent)
extern

Loads the player stuff.

Loads player related stuff.

Parameters
parentNode where the player stuff is to be found.
Returns
0 on success.

Definition at line 3563 of file player.c.

◆ space_sysLoad()

int space_sysLoad ( xmlNodePtr parent)
extern

Loads player's space properties from an XML node.

Loads the space stuff.

Parameters
parentParent node for space.
Returns
0 on success.

Definition at line 3938 of file space.c.

◆ var_load()

int var_load ( xmlNodePtr parent)
extern

Loads the vars from XML file.

Loads mission variables.

Parameters
parentParent node containing the variables.
Returns
0 on success.

Definition at line 85 of file nlua_var.c.

Variable Documentation

◆ load_player

player_saves_t* load_player = NULL
static

Points to current element in load_saves.

Definition at line 58 of file load.c.

◆ load_saves

player_saves_t* load_saves = NULL
static

Array of saves

Definition at line 57 of file load.c.

◆ old_saves_detected

int old_saves_detected = 0
static

Definition at line 59 of file load.c.

◆ player_warned

int player_warned = 0
static

Definition at line 59 of file load.c.

◆ save_loaded

int save_loaded
extern

From save.c

Just loaded the saved game.

Definition at line 39 of file save.c.

◆ selected_player

char* selected_player = NULL
static

Definition at line 60 of file load.c.