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. | |
| gamedata (string desc, string dir, string time) | |
| Alternate constructor. | |
| ~gamedata () | |
| Destructor. | |
| void | put (ogzstream &) |
| Save a record to an opened file. | |
| bool | get (igzstream &) |
| Load a record from an opened file. | |
| const char * | directory () |
| A bunch of methods to access the private attributes. | |
| const char * | description () |
| Returns the description of the saved game. | |
| const char * | location () |
| Returns the location of the saved game. | |
| const char * | gametime () |
| Returns the in-game time of the saved game. | |
| u_int32 | timestamp () |
| Returns the (real) time when this game has been saved. | |
| void | set_description (string) |
| Sets the description for this game. | |
| void | set_directory (string) |
| Sets the directory for this game. | |
| void | set_gametime (string) |
| Set the in-game time of the saved game. | |
Static Public Member Functions | |
| static bool | init (string udir, string gdir, string gname, u_int8 qload) |
| Initialise the saved games array. | |
| static void | cleanup () |
| Cleanup the saved game array. | |
| static bool | load_characters (u_int32 pos) |
| Load the characters state from a saved game. | |
| static bool | load_quests (u_int32 pos) |
| Load the quests state from a saved game. | |
| static bool | load_mapengine (u_int32 pos) |
| Load the mapengine state from a saved game. | |
| static bool | load_audio (u_int32 pos) |
| Load the audio system state from a saved game. | |
| static bool | load (u_int32 pos) |
| Loads a previously saved game. | |
| static bool | load_newest () |
| Loads the most recent saved game. | |
| static bool | save (u_int32 pos, string desc, string time) |
| Save a game. | |
| static void | unload () |
| Unloads the current game, resetting the engine to it's initial state. | |
| static gamedata * | next_save () |
| Returns a pointer to the next saved game. | |
| static string | user_data_dir () |
| Returns the user data directory ($HOME/.adonthell). | |
| static string | game_data_dir () |
| Returns the game data directory. | |
| static gamedata * | get_saved_game (u_int32 pos) |
| Returns a pointer to a saved game. | |
| static dictionary< quest * > | quests () |
| Returns the global quests dictionary. | |
| static character * | player () |
| Returns the player character. | |
| static character * | get_character (string name) |
| Returns a certain NPC when given the name. | |
| static quest * | get_quest (string name) |
| Returns a certain quest when given the name. | |
| static dictionary< character * > | characters () |
| Returns the characters dictionary. | |
| static adonthell * | engine () |
| Returns a pointer to the global game engine. | |
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 48 of file gamedata.h.
| gamedata::gamedata | ( | ) |
Default constructor.
Definition at line 55 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 59 of file gamedata.cc.
| gamedata::~gamedata | ( | ) |
Destructor.
Definition at line 67 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 84 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 71 of file gamedata.cc.
| const char* gamedata::directory | ( | ) | [inline] |
A bunch of methods to access the private attributes.
Returns the directory where the saved game lies.
Definition at line 103 of file gamedata.h.
| const char* gamedata::description | ( | ) | [inline] |
Returns the description of the saved game.
Definition at line 110 of file gamedata.h.
| const char* gamedata::location | ( | ) | [inline] |
Returns the location of the saved game.
Definition at line 117 of file gamedata.h.
| const char* gamedata::gametime | ( | ) | [inline] |
Returns the in-game time of the saved game.
Definition at line 124 of file gamedata.h.
| u_int32 gamedata::timestamp | ( | ) | [inline] |
Returns the (real) time when this game has been saved.
Definition at line 131 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 97 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 102 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 107 of file gamedata.cc.
| bool gamedata::init | ( | string | udir, | |
| string | gdir, | |||
| string | gname, | |||
| u_int8 | qload | |||
| ) | [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 477 of file gamedata.cc.
| void gamedata::cleanup | ( | void | ) | [static] |
Cleanup the saved game array.
Definition at line 545 of file gamedata.cc.
| bool gamedata::load_characters | ( | u_int32 | pos | ) | [static] |
Load the characters state from a saved game.
| pos | Slot number to load. |
Definition at line 112 of file gamedata.cc.
| bool gamedata::load_quests | ( | u_int32 | pos | ) | [static] |
Load the quests state from a saved game.
| pos | Slot number to load. |
Definition at line 155 of file gamedata.cc.
| bool gamedata::load_mapengine | ( | u_int32 | pos | ) | [static] |
Load the mapengine state from a saved game.
| pos | Slot number to load. |
Definition at line 192 of file gamedata.cc.
| bool gamedata::load_audio | ( | u_int32 | pos | ) | [static] |
Load the audio system state from a saved game.
| pos | Slot number to load. |
Definition at line 223 of file gamedata.cc.
| bool gamedata::load | ( | u_int32 | pos | ) | [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 253 of file gamedata.cc.
| bool gamedata::load_newest | ( | ) | [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 266 of file gamedata.cc.
| bool gamedata::save | ( | u_int32 | pos, | |
| string | desc, | |||
| string | time | |||
| ) | [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 289 of file gamedata.cc.
| void gamedata::unload | ( | ) | [static] |
Unloads the current game, resetting the engine to it's initial state.
Definition at line 553 of file gamedata.cc.
| gamedata * gamedata::next_save | ( | ) | [static] |
Returns a pointer to the next saved game.
Definition at line 454 of file gamedata.cc.
| static string gamedata::user_data_dir | ( | ) | [inline, static] |
Returns the user data directory ($HOME/.adonthell).
Definition at line 266 of file gamedata.h.
| static string gamedata::game_data_dir | ( | ) | [inline, static] |
Returns the game data directory.
Definition at line 277 of file gamedata.h.
| static gamedata* gamedata::get_saved_game | ( | u_int32 | pos | ) | [inline, static] |
Returns a pointer to a saved game.
| pos | Slot number to return. |
Definition at line 289 of file gamedata.h.
| static dictionary<quest *> gamedata::quests | ( | ) | [inline, static] |
Returns the global quests dictionary.
Definition at line 300 of file gamedata.h.
| static character* gamedata::player | ( | ) | [inline, static] |
| static character* gamedata::get_character | ( | string | name | ) | [inline, static] |
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 324 of file gamedata.h.
| static quest* gamedata::get_quest | ( | string | name | ) | [inline, static] |
Returns a certain quest when given the name.
| name | The name of the quest to return |
Definition at line 336 of file gamedata.h.
| static dictionary<character*> gamedata::characters | ( | ) | [inline, static] |
Returns the characters dictionary.
Definition at line 347 of file gamedata.h.
| static adonthell* gamedata::engine | ( | ) | [inline, static] |
Returns a pointer to the global game engine.
Definition at line 358 of file gamedata.h.
1.7.1