Adonthell
0.4
|
Contains all the attributes related to a saved game and the high level methods for loading/saving the game. More...
#include <gamedata.h>
Public Member Functions | |
gamedata () | |
Default constructor. More... | |
gamedata (string desc, string dir, string time) | |
Alternate constructor. More... | |
~gamedata () | |
Destructor. More... | |
void | put (ogzstream &) |
Save a record to an opened file. More... | |
bool | get (igzstream &) |
Load a record from an opened file. More... | |
const char * | directory () |
A bunch of methods to access the private attributes. More... | |
const char * | description () |
Returns the description of the saved game. More... | |
const char * | location () |
Returns the location of the saved game. More... | |
const char * | gametime () |
Returns the in-game time of the saved game. More... | |
u_int32 | timestamp () |
Returns the (real) time when this game has been saved. More... | |
void | set_description (string) |
Sets the description for this game. More... | |
void | set_directory (string) |
Sets the directory for this game. More... | |
void | set_gametime (string) |
Set the in-game time of the saved game. More... | |
Static Public Member Functions | |
static bool | init (string udir, string gdir, string gname, u_int8 qload) |
Initialise the saved games array. More... | |
static void | cleanup () |
Cleanup the saved game array. More... | |
static bool | load_characters (u_int32 pos) |
Load the characters state from a saved game. More... | |
static bool | load_quests (u_int32 pos) |
Load the quests state from a saved game. More... | |
static bool | load_mapengine (u_int32 pos) |
Load the mapengine state from a saved game. More... | |
static bool | load_audio (u_int32 pos) |
Load the audio system state from a saved game. More... | |
static bool | load_achievements (u_int32 pos) |
static bool | load (u_int32 pos) |
Loads a previously saved game. More... | |
static bool | load_newest () |
Loads the most recent saved game. More... | |
static bool | save (u_int32 pos, string desc, string time) |
Save a game. More... | |
static void | unload () |
Unloads the current game, resetting the engine to it's initial state. More... | |
static gamedata * | next_save () |
Returns a pointer to the next saved game. More... | |
static string | user_data_dir () |
Returns the user data directory ($HOME/.adonthell). More... | |
static string | game_data_dir () |
Returns the game data directory. More... | |
static gamedata * | get_saved_game (u_int32 pos) |
Returns a pointer to a saved game. More... | |
static dictionary< quest * > | quests () |
Returns the global quests dictionary. More... | |
static character * | player () |
Returns the player character. More... | |
static character * | get_character (string name) |
Returns a certain NPC when given the name. More... | |
static quest * | get_quest (string name) |
Returns a certain quest when given the name. More... | |
static dictionary< character * > | characters () |
Returns the characters dictionary. More... | |
static adonthell * | engine () |
Returns a pointer to the global game engine. More... | |
Contains all the attributes related to a saved game and the high level methods for loading/saving the game.
A word about saved games: all games are stored inside $HOME/.adonthell/ into a individual subdirectory, consisting of the game's name (e.g. wastesedge) with the appendix "-save-xxx" where "xxx" is a number between 001 and 999. All data that belongs to a saved game is contained in that directory, thus allowing to copy individual games to another machine and/or user.
The numbering of the game directories has no special meaning. Saved games are recognized by the first part of their name, and saving a new game will never overwrite an existing.
Definition at line 52 of file gamedata.h.
gamedata::gamedata | ( | ) |
Default constructor.
Definition at line 61 of file gamedata.cc.
gamedata::gamedata | ( | string | desc, |
string | dir, | ||
string | time | ||
) |
Alternate constructor.
desc | description of the saved game. |
dir | directory of the saved game. |
time | Textual representation of in-game time. |
Definition at line 65 of file gamedata.cc.
gamedata::~gamedata | ( | ) |
Destructor.
Definition at line 73 of file gamedata.cc.
void gamedata::put | ( | ogzstream & | file | ) |
Save a record to an opened file.
ogzstream& | opened file to save to. |
Definition at line 90 of file gamedata.cc.
bool gamedata::get | ( | igzstream & | file | ) |
Load a record from an opened file.
igzstream& | opened file to load from. |
Definition at line 77 of file gamedata.cc.
|
inline |
A bunch of methods to access the private attributes.
Returns the directory where the saved game lies.
Definition at line 107 of file gamedata.h.
|
inline |
Returns the description of the saved game.
Definition at line 114 of file gamedata.h.
|
inline |
Returns the location of the saved game.
Definition at line 121 of file gamedata.h.
|
inline |
Returns the in-game time of the saved game.
Definition at line 128 of file gamedata.h.
|
inline |
Returns the (real) time when this game has been saved.
Definition at line 135 of file gamedata.h.
void gamedata::set_description | ( | string | desc | ) |
Sets the description for this game.
string | New description for this game. |
Definition at line 103 of file gamedata.cc.
void gamedata::set_directory | ( | string | dir | ) |
Sets the directory for this game.
string | New directory for this game. |
Definition at line 108 of file gamedata.cc.
void gamedata::set_gametime | ( | string | time | ) |
Set the in-game time of the saved game.
string | In-game time of the saved game. |
Definition at line 113 of file gamedata.cc.
|
static |
Initialise the saved games array.
Searches the user directory for available save games and loads their description.
udir | The user directory, usually $HOME/.adonthell |
gdir | The game data directory, usually /usr/local/share/adonthell |
gname | The name of the game we are running, e.g. wastesedge |
qload | Whether quick-loading should be enabled or disabled |
Definition at line 544 of file gamedata.cc.
|
static |
Cleanup the saved game array.
Definition at line 612 of file gamedata.cc.
|
static |
Load the characters state from a saved game.
pos | Slot number to load. |
Definition at line 118 of file gamedata.cc.
|
static |
Load the quests state from a saved game.
pos | Slot number to load. |
Definition at line 164 of file gamedata.cc.
|
static |
Load the mapengine state from a saved game.
pos | Slot number to load. |
Definition at line 203 of file gamedata.cc.
|
static |
Load the audio system state from a saved game.
pos | Slot number to load. |
Definition at line 237 of file gamedata.cc.
|
static |
Loads a previously saved game.
Slot 0 points to the initial game data and needs to be loaded when starting a fresh game.
pos | Slot number to load. |
Definition at line 303 of file gamedata.cc.
|
static |
Loads the most recent saved game.
This method only takes games created by the player into account, not the initial saved game.
Definition at line 317 of file gamedata.cc.
|
static |
Save a game.
When given a slot number in the range of the available saved games, the according game will be overwritten, otherwise a new saved game is created. Saving to slot 0 is not possible, as it contains the initial game data.
pos | Slot number where to save to. |
desc | Description of the game to be saved. |
time | Textual representation of in-game time. |
Definition at line 340 of file gamedata.cc.
|
static |
Unloads the current game, resetting the engine to it's initial state.
Definition at line 620 of file gamedata.cc.
|
static |
Returns a pointer to the next saved game.
Definition at line 521 of file gamedata.cc.
|
inlinestatic |
Returns the user data directory ($HOME/.adonthell).
Definition at line 272 of file gamedata.h.
|
inlinestatic |
Returns the game data directory.
Definition at line 283 of file gamedata.h.
Returns a pointer to a saved game.
pos | Slot number to return. |
Definition at line 295 of file gamedata.h.
|
inlinestatic |
Returns the global quests dictionary.
Definition at line 306 of file gamedata.h.
|
inlinestatic |
|
inlinestatic |
Returns a certain NPC when given the name.
Use player () to get the player character, as his/her name will be set at runtime.
name | The name of the character to return |
Definition at line 330 of file gamedata.h.
|
inlinestatic |
Returns a certain quest when given the name.
name | The name of the quest to return |
Definition at line 342 of file gamedata.h.
|
inlinestatic |
Returns the characters dictionary.
Definition at line 353 of file gamedata.h.
|
inlinestatic |
Returns a pointer to the global game engine.
Definition at line 364 of file gamedata.h.