Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/client.cc22
-rw-r--r--src/client/savegamemenu.cc23
-rw-r--r--src/client/savegamemenu.h2
-rw-r--r--src/game/base/game.cc61
-rw-r--r--src/game/base/ship.cc6
5 files changed, 69 insertions, 45 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index 1ee53d3..eee940d 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -171,10 +171,10 @@ void Client::init(int count, char **arguments)
func->set_info("[command] view menu functions");
func = core::Func::add("loadgame", func_loadgame);
- func->set_info("load game");
+ func->set_info("[savename] load game");
func = core::Func::add("savegame", func_savegame);
- func->set_info("save game");
+ func->set_info("[savename] [description] save game");
previous_timestamp = 0;
}
@@ -648,13 +648,25 @@ void Client::func_savegame(std::string const &args)
{
std::stringstream argstr(args);
std::string savename;
+ std::string descr;
+
argstr >> savename;
aux::to_label(savename);
if (!savename.size()) {
- savename.assign("quick");
+ savename.assign("quicksave");
+ descr.assign("QUICKSAVE");
+ } else {
+ std::string word;
+ while(argstr >> word)
+ {
+ if (descr.size()) {
+ descr += ' ';
+ }
+ descr.append(word);
+ }
}
- SaveGameMenu::savegame(savename);
+ SaveGameMenu::savegame(savename, descr);
}
// quik save
@@ -666,7 +678,7 @@ void Client::func_loadgame(std::string const &args)
aux::to_label(savename);
if (!savename.size()) {
- savename.assign("quick");
+ savename.assign("quicksave");
}
SaveGameMenu::loadgame(savename);
}
diff --git a/src/client/savegamemenu.cc b/src/client/savegamemenu.cc
index 5e8f369..ea766a2 100644
--- a/src/client/savegamemenu.cc
+++ b/src/client/savegamemenu.cc
@@ -378,7 +378,8 @@ bool SaveGameMenu::on_emit(ui::Widget *sender, const ui::Widget::Event event, vo
if (event == ui::Widget::EventButtonClicked) {
if (savegamemenu_mode == Save) {
if (savegamemenu_filelistview->selected()) {
- savegame(savegamemenu_filelistview->selected()->value());
+ std::string descr;
+ savegame(savegamemenu_filelistview->selected()->value(), descr);
parent()->hide();
}
} else {
@@ -470,7 +471,7 @@ void SaveGameMenu::deletegame(std::string savename)
::remove(filename.c_str());
}
-void SaveGameMenu::savegame(std::string savename)
+void SaveGameMenu::savegame(std::string savename, const std::string & description)
{
if (!core::server() || !core::server()->module())
return;
@@ -505,6 +506,7 @@ void SaveGameMenu::savegame(std::string savename)
filesystem::OFileStream ofs("savegames/" + savename + ".ini");
con_debug << "Saving " << ofs.filename() << std::endl;
+ core::application()->notify_message(core::Message::Info, "Saving '" + savename + "'");
ofs << "; Project::OSiRiON" << std::endl;
ofs << "; savegame data" << std::endl;
@@ -512,13 +514,16 @@ void SaveGameMenu::savegame(std::string savename)
ofs << "[savegame]" << std::endl;
ofs << "description=";
- if (core::localcontrol()->state() == core::Entity::Docked) {
- // FIXME implement entity->dock()
- ofs << core::localplayer()->view()->name() << std::endl;
+ if (description.size()) {
+ ofs << description << std::endl;
} else {
- ofs << core::localplayer()->zone()->name() << std::endl;
+ if (core::localcontrol()->state() == core::Entity::Docked) {
+ // FIXME implement entity->dock()
+ ofs << core::localplayer()->view()->name() << std::endl;
+ } else {
+ ofs << core::localplayer()->zone()->name() << std::endl;
+ }
}
-
ofs << "info=";
if (core::localcontrol()->state() == core::Entity::Docked) {
// FIXME implement entity->dock()
@@ -555,13 +560,15 @@ void SaveGameMenu::loadgame(std::string savename) {
return;
}
- con_debug << "Loading " << inifile.filename() << std::endl;
if (core::application()->connected())
core::application()->disconnect();
core::application()->connect("");
+ con_debug << "Loading " << inifile.filename() << std::endl;
+ core::application()->notify_message(core::Message::Info, "Loading '" + savename + "'");
+
if (core::application()->connected() && core::server() && core::server()->module()) {
core::server()->module()->game_load(core::localplayer(), inifile);
}
diff --git a/src/client/savegamemenu.h b/src/client/savegamemenu.h
index d615102..d8dde05 100644
--- a/src/client/savegamemenu.h
+++ b/src/client/savegamemenu.h
@@ -27,7 +27,7 @@ public:
static void loadgame(std::string savename);
- static void savegame(std::string savename);
+ static void savegame(std::string savename, const std::string & description);
static void deletegame(std::string savename);
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()