naev 0.10.4
Data Structures | Macros | Functions | Variables
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 "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  filedata_t
 Struct containing a file's name and stat structure. More...
 
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. More...
 
int events_loadActive (xmlNodePtr parent)
 Loads the player's active events from a save. More...
 
int news_loadArticles (xmlNodePtr parent)
 Loads the player's active articles from a save, initilizes news. More...
 
int var_load (xmlNodePtr parent)
 Loads the vars from XML file. More...
 
int pfaction_load (xmlNodePtr parent)
 Loads the player's faction standings. More...
 
int hook_load (xmlNodePtr parent)
 Loads hooks for a player. More...
 
int space_sysLoad (xmlNodePtr parent)
 Loads player's space properties from an XML node. More...
 
int economy_sysLoad (xmlNodePtr parent)
 Loads player's economy properties from an XML node. More...
 
int diff_load (xmlNodePtr parent)
 Loads the diffs. More...
 
static void load_menu_update (unsigned int wid, const char *str)
 Updates the load menu. More...
 
static void load_menu_close (unsigned int wdw, const char *str)
 Closes the load game menu. More...
 
static void load_menu_load (unsigned int wdw, const char *str)
 Loads a new game. More...
 
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. More...
 
static void load_snapshot_menu_update (unsigned int wid, const char *str)
 Updates the load snapshot menu. More...
 
static void load_snapshot_menu_close (unsigned int wdw, const char *str)
 Closes the load snapshot menu. More...
 
static void load_snapshot_menu_load (unsigned int wdw, const char *str)
 Loads a new game. More...
 
static void load_snapshot_menu_delete (unsigned int wdw, const char *str)
 Deletes an old game. More...
 
static void load_snapshot_menu_save (unsigned int wdw, const char *str)
 Creates new custom snapshot. More...
 
static void display_save_info (unsigned int wid, const nsave_t *ns)
 Displays Naev save info. More...
 
static void move_old_save (const char *path, const char *fname, const char *ext, const char *new_name)
 Moves old Naev saves to subdirectories. More...
 
static int load_load (nsave_t *save, const char *path)
 Loads an individual save. More...
 
static int load_game (nsave_t *ns)
 Actually loads a new game based on save structure. More...
 
static int load_gameInternal (const char *file, const char *version)
 Actually loads a new game. More...
 
static int load_gameInternalHook (void *data)
 Loads a game .Meant to be run in a function hook. More...
 
static int load_enumerateCallback (void *data, const char *origdir, const char *fname)
 The PHYSFS_EnumerateCallback for load_refresh. More...
 
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. More...
 
static int load_sortComparePlayers (const void *p1, const void *p2)
 qsort compare function for files. More...
 
static int load_sortCompare (const void *p1, const void *p2)
 qsort compare function for files. More...
 
static xmlDocPtr load_xml_parsePhysFS (const char *filename)
 Temporary (hopefully) wrapper around xml_parsePhysFS in support of gzipped XML (like .ns files). More...
 
int load_refresh (void)
 Loads or refreshes saved games for the player. More...
 
void load_free (void)
 Frees loaded save stuff. More...
 
const nsave_tload_getList (const char *name)
 Gets the array (array.h) of loaded saves. More...
 
void load_loadGameMenu (void)
 Opens the load game menu. More...
 
void load_loadSnapshotMenu (const char *name, int disablesave)
 Opens the load snapshot menu. More...
 
static void load_compatSlots (void)
 
int load_gameDiff (const char *file)
 Loads the diffs from game file. More...
 
int load_gameFile (const char *file)
 Loads the game from a file. More...
 

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 49 of file load.c.

◆ BUTTON_WIDTH

#define BUTTON_WIDTH   120

Button width.

Definition at line 48 of file load.c.

◆ LOAD_HEIGHT

#define LOAD_HEIGHT   530

Load window height.

Definition at line 46 of file load.c.

◆ LOAD_WIDTH

#define LOAD_WIDTH   600

Load window width.

Definition at line 45 of file load.c.

Function Documentation

◆ diff_load()

int diff_load ( xmlNodePtr  parent)

Loads the diffs.

Loads the universe diffs.

Parameters
parentParent node containing diffs.
Returns
0 on success.

Definition at line 1740 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 717 of file load.c.

◆ economy_sysLoad()

int economy_sysLoad ( xmlNodePtr  parent)

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)

Loads the player's active events from a save.

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

Definition at line 804 of file event.c.

◆ hook_load()

int hook_load ( xmlNodePtr  parent)

Loads hooks for a player.

Loads hooks.

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

Definition at line 1208 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 391 of file load.c.

◆ load_compatibilityString()

static const char * load_compatibilityString ( const nsave_t ns)
static

Definition at line 373 of file load.c.

◆ load_compatibilityTest()

static int load_compatibilityTest ( const nsave_t ns)
static

Definition at line 330 of file load.c.

◆ load_compatSlots()

static void load_compatSlots ( void  )
static

Definition at line 1007 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 282 of file load.c.

◆ load_enumerateCallbackPlayer()

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

Definition at line 246 of file load.c.

◆ load_free()

void load_free ( void  )

Frees loaded save stuff.

Definition at line 453 of file load.c.

◆ load_game()

static int load_game ( 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 1105 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 1054 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 1094 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 1117 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 1153 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 483 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 124 of file load.c.

◆ load_loadGameMenu()

void load_loadGameMenu ( void  )

Opens the load game menu.

Definition at line 498 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 695 of file load.c.

◆ load_menu_delete()

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

Definition at line 928 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 851 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 648 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 803 of file load.c.

◆ load_refresh()

int load_refresh ( void  )

Loads or refreshes saved games for the player.

Definition at line 233 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 706 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 965 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 889 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 664 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 829 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 428 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 417 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 1250 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 762 of file load.c.

◆ news_loadArticles()

int news_loadArticles ( xmlNodePtr  parent)

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 483 of file news.c.

◆ pfaction_load()

int pfaction_load ( xmlNodePtr  parent)

Loads the player's faction standings.

Loads faction data.

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

Definition at line 1756 of file faction.c.

◆ player_load()

Spob * player_load ( xmlNodePtr  parent)

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 3519 of file player.c.

◆ space_sysLoad()

int space_sysLoad ( xmlNodePtr  parent)

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 3894 of file space.c.

◆ var_load()

int var_load ( xmlNodePtr  parent)

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 65 of file load.c.

◆ load_saves

player_saves_t* load_saves = NULL
static

Array of saves

Definition at line 64 of file load.c.

◆ old_saves_detected

int old_saves_detected = 0
static

Definition at line 66 of file load.c.

◆ player_warned

int player_warned = 0
static

Definition at line 66 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 67 of file load.c.