naev 0.12.6
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 "difficulty.h"
#include "economy.h"
#include "event.h"
#include "gui.h"
#include "hook.h"
#include "land.h"
#include "log.h"
#include "menu.h"
#include "mission.h"
#include "ndata.h"
#include "nstring.h"
#include "nxml.h"
#include "player.h"
#include "plugin.h"
#include "render.h"
#include "save.h"
#include "shiplog.h"
#include "space.h"
#include "start.h"
#include "threadpool.h"
#include "toolkit.h"
#include "unidiff.h"
Include dependency graph for load.c:

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 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)
 Loads an individual save.
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 int has_plugin (const char *plugin)
 Checks to see if has a plugin.
static SaveCompatibility load_compatibility (const nsave_t *ns)
 Checks to see if a save is compatible with current Naev.
static int load_sortComparePlayersName (const void *p1, const void *p2)
 qsort compare function for files.
static int load_sortComparePlayers (const void *p1, const void *p2)
 qsort compare function for files.
static int load_sortCompareName (const void *p1, const void *p2)
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).
static void load_freeSave (nsave_t *ns)
static int load_loadThread (void *ptr)
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_game (const nsave_t *ns)
 Actually loads a new game based on save structure.

Variables

static player_saves_tload_saves = NULL
static player_saves_tload_player
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 1979 of file unidiff.c.

◆ display_save_info()

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 875 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 1019 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 877 of file event.c.

◆ has_plugin()

int has_plugin ( const char * plugin)
static

Checks to see if has a plugin.

Definition at line 477 of file load.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 1310 of file hook.c.

◆ load_compatibility()

SaveCompatibility load_compatibility ( const nsave_t * ns)
static

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

Definition at line 489 of file load.c.

◆ load_compatibilityString()

const char * load_compatibilityString ( const nsave_t * ns)
static

Definition at line 459 of file load.c.

◆ load_compatibilityTest()

int load_compatibilityTest ( const nsave_t * ns)
static

Definition at line 410 of file load.c.

◆ load_compatSlots()

void load_compatSlots ( void )
static

Definition at line 1185 of file load.c.

◆ load_enumerateCallback()

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

The PHYSFS_EnumerateCallback for load_refresh.

Definition at line 365 of file load.c.

◆ load_enumerateCallbackPlayer()

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

Definition at line 326 of file load.c.

◆ load_free()

void load_free ( void )

Frees loaded save stuff.

Definition at line 595 of file load.c.

◆ load_freeSave()

void load_freeSave ( nsave_t * ns)
static

Definition at line 575 of file load.c.

◆ load_game()

int load_game ( const nsave_t * ns)

Actually loads a new game based on save structure.

Parameters
nsSave game to load.
Returns
0 on success.

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

◆ load_gameInternalHook()

int load_gameInternalHook ( void * data)
static

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

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

◆ load_load()

int load_load ( nsave_t * save)
static

Loads an individual save.

Parameters
[out]saveStructure to populate.
Returns
0 on success.

Definition at line 123 of file load.c.

◆ load_loadGameMenu()

void load_loadGameMenu ( void )

Opens the load game menu.

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

◆ load_loadThread()

int load_loadThread ( void * ptr)
static

Definition at line 223 of file load.c.

◆ load_menu_close()

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

Closes the load game menu.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 853 of file load.c.

◆ load_menu_delete()

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

Definition at line 1098 of file load.c.

◆ load_menu_load()

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

Loads a new game.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 1024 of file load.c.

◆ load_menu_snapshots()

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

Opens the load snapshot menu.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 803 of file load.c.

◆ load_menu_update()

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

Updates the load menu.

Parameters
widWidget triggering function.
strUnused.

Definition at line 977 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()

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

◆ load_snapshot_menu_delete()

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

Deletes an old game.

Parameters
wdwWindow to delete.
strUnused.

Definition at line 1140 of file load.c.

◆ load_snapshot_menu_load()

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

Loads a new game.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 1062 of file load.c.

◆ load_snapshot_menu_onClose()

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

Definition at line 698 of file load.c.

◆ load_snapshot_menu_save()

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

Creates new custom snapshot.

Parameters
wdwWindow triggering function.
strUnused.

Definition at line 817 of file load.c.

◆ load_snapshot_menu_update()

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

◆ load_sortCompare()

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

qsort compare function for files.

Definition at line 553 of file load.c.

◆ load_sortCompareName()

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

Definition at line 526 of file load.c.

◆ load_sortComparePlayers()

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

qsort compare function for files.

Definition at line 518 of file load.c.

◆ load_sortComparePlayersName()

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

qsort compare function for files.

Definition at line 507 of file load.c.

◆ load_xml_parsePhysFS()

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

◆ move_old_save()

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 934 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 487 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 2242 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 3736 of file player.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 79 of file nlua_var.c.

Variable Documentation

◆ load_player

player_saves_t* load_player
static
Initial value:
=
NULL

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

◆ player_warned

int player_warned = 0
static

Definition at line 60 of file load.c.

◆ save_loaded

int save_loaded
extern

From save.c

Just loaded the saved game.

Definition at line 30 of file save.c.

◆ selected_player

char* selected_player = NULL
static

Definition at line 61 of file load.c.