Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r--src/game/base/game.cc44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index b2824f5..da060b9 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -191,6 +191,26 @@ void Game::func_dock(core::Player *player, core::Entity *entity)
}
}
+// buy request from a player
+void Game::func_buy(core::Player *player, const std::string &args)
+{
+ std::istringstream is(args);
+ std::string itemtype;
+ if (!(is >> itemtype)) {
+ player->send("usage: buy [string] [string] buy type of item, name of item");
+ return;
+ }
+
+ aux::to_label(itemtype);
+ if ((args.size() > 5 ) && (itemtype.compare("ship") == 0)) {
+ ShipDealer::func_buy(player, args.substr(5, args.size() - 5));
+ } else {
+ player->send("unkown item type '" + itemtype + "'");
+ }
+
+ return;
+}
+
// launch request
void Game::func_launch(core::Player *player, std::string const &args)
{
@@ -308,8 +328,8 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func = core::Func::add("spectate", Game::func_spectate);
func->set_info("leave the game and spectate");
- func = core::Func::add("buy", ShipDealer::func_buy);
- func->set_info("buy a ship");
+ func = core::Func::add("buy", Game::func_buy);
+ func->set_info("[string] [string] buy type of item, name of item");
func = core::Func::add("jump", Game::func_jump);
func->set_info("[string] activate or deactivate hyperspace jump drive");
@@ -697,7 +717,7 @@ bool Game::load_menus(core::Entity *entity, const std::string &menufilename)
if (model) {
button = new ButtonDescription();
button->set_text("buy " + model->name());
- button->set_command("buy " + model->label());
+ button->set_command("buy ship " + model->label(), ButtonDescription::CommandMenu);
button->set_modelname(model->modelname());
button->set_alignment(ButtonDescription::Left);
menu_dealer->add_button(button);
@@ -719,14 +739,14 @@ bool Game::load_menus(core::Entity *entity, const std::string &menufilename)
button = new ButtonDescription();
button->set_text("Launch");
- button->set_command("launch");
+ button->set_command("launch", ButtonDescription::CommandGame);
button->set_alignment(ButtonDescription::Center);
menu_main->add_button(button);
if (menu_dealer) {
button = new ButtonDescription();
button->set_text("Return");
- button->set_command("menu view main");
+ button->set_command("main", ButtonDescription::CommandMenu);
button->set_alignment(ButtonDescription::Center);
menu_dealer->add_button(button);
@@ -734,7 +754,7 @@ bool Game::load_menus(core::Entity *entity, const std::string &menufilename)
button = new ButtonDescription();
button->set_text("Ship dealer");
- button->set_command("menu view dealer");
+ button->set_command("dealer", ButtonDescription::CommandMenu);
button->set_alignment(ButtonDescription::Center);
menu_main->add_button(button);
}
@@ -763,6 +783,7 @@ bool Game::load_ships()
ShipModel *shipmodel = 0;
std::string label;
+ std::string infostr;
long l;
float f;
@@ -776,6 +797,9 @@ bool Game::load_ships()
continue;
} else if (shipsini.got_key_string("name",shipmodel->shipmodel_name)) {
continue;
+ } else if (shipsini.got_key_string("info", infostr)) {
+ shipmodel->shipmodel_infotext.push_back(infostr);
+ continue;
} else if (shipsini.got_key_string("model", shipmodel->shipmodel_modelname)) {
continue;
} else if (shipsini.got_key_long("price", l)) {
@@ -814,6 +838,14 @@ bool Game::load_ships()
if (shipmodel && !ShipModel::find(shipmodel)) delete shipmodel;
+ // add shipmodel infos
+ for (ShipModel::iterator it = ShipModel::registry.begin(); it != ShipModel::registry.end(); it++) {
+ ShipModel *shipmodel = (*it).second;
+ core::Info *info = new core::Info("ship/" + shipmodel->label());
+ shipmodel->generate_info(info);
+ core::Info::add(info);
+ }
+
con_debug << " " << shipsini.name() << " " << ShipModel::registry.size() << " ship models" << std::endl;
return true;