Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-01-22 17:46:40 +0000
committerStijn Buys <ingar@osirion.org>2012-01-22 17:46:40 +0000
commit3c8f200dd83d18839c8205ed630a104d67e0807d (patch)
tree6a1e847ca9788566dda7cb356e2a90944f858023 /src/game
parente38beeb8e048402de8ee46cbbba66436810c2f87 (diff)
Implemented autosave for single player games.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/game.cc61
-rw-r--r--src/game/base/ship.cc6
2 files changed, 36 insertions, 31 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index fc87403..0610377 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -1742,32 +1742,31 @@ void Game::player_load(core::Player *player)
if (player->control())
return;
-
- if (!core::server()->mode() == core::GameServer::MultiPlayer) {
- return;
- }
-
- std::string guid(player->guid().str());
- std::string directory(guid.substr(0,4));
-
- std::string filename;
- filename.append("players");
- filename += '/';
- filename.append(directory);
- filename += '/';
- filename.append(guid);
- filesystem::IniFile inifile;
- inifile.open(filename);
- if (!inifile.is_open()) {
- return;
+ if (!core::server()->mode() == core::GameServer::MultiPlayer) {
+
+ std::string guid(player->guid().str());
+ std::string directory(guid.substr(0,4));
+
+ std::string filename;
+ filename.append("players");
+ filename += '/';
+ filename.append(directory);
+ filename += '/';
+ filename.append(guid);
+
+ filesystem::IniFile inifile;
+ inifile.open(filename);
+ if (!inifile.is_open()) {
+ return;
+ }
+
+ con_debug << "player " << player->id() << ": " << "loading data" << std::endl;
+
+ SaveGame::load_game(player, inifile);
+
+ inifile.close();
}
-
- con_debug << "player " << player->id() << ": " << "loading data" << std::endl;
-
- SaveGame::load_game(player, inifile);
-
- inifile.close();
}
void Game::game_save(core::Player *player, std::ostream & os)
@@ -1784,14 +1783,20 @@ void Game::game_save(core::Player *player, std::ostream & os)
void Game::player_save(core::Player *player)
{
- if (!player->guid().is_valid()) {
- return;}
-
if ((!player->control()) || (player->control()->moduletype() != ship_enttype)) {
return;
}
- if (core::server()->mode() == core::GameServer::MultiPlayer) {
+ if (core::server()->mode() == core::GameServer::SinglePlayer) {
+ std::string command("savegame autosave AUTOSAVE");
+ core::CommandBuffer::exec(command);
+
+ } else if (core::server()->mode() == core::GameServer::MultiPlayer) {
+
+ if (!player->guid().is_valid()) {
+ return;
+ }
+
con_debug << "player " << player->id() << ": " << "saving data" << std::endl;
std::string guid(player->guid().str());
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 1aca505..e5ae2fe 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -357,11 +357,11 @@ void Ship::set_dock(core::Entity *dock)
// if the dock is not owned by a player. set it as spawn
+ set_state(core::Entity::Docked);
const core::Player *owner = (dock->type() == core::Entity::Controlable ? static_cast<core::EntityControlable *>(dock)->owner() : 0 );
- if (!owner)
+ if (!owner) {
set_spawn(dock);
-
- set_state(core::Entity::Docked);
+ }
}
void Ship::launch()