Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2010-09-18 18:50:55 +0000
committerStijn Buys <ingar@osirion.org>2010-09-18 18:50:55 +0000
commit9c91a9767b570fdc3c3e19e1f452f9a8257f9999 (patch)
tree9ac10114a3378134ea19dac3d7f7639532c3bf5a /src/game/base/shipdealer.cc
parentfc4809e41bc5694231046eb2fd4c324c4daba13f (diff)
trade updates
Diffstat (limited to 'src/game/base/shipdealer.cc')
-rw-r--r--src/game/base/shipdealer.cc75
1 files changed, 28 insertions, 47 deletions
diff --git a/src/game/base/shipdealer.cc b/src/game/base/shipdealer.cc
index adb97ea..e6df18f 100644
--- a/src/game/base/shipdealer.cc
+++ b/src/game/base/shipdealer.cc
@@ -68,33 +68,19 @@ ShipModel *ShipDealer::find(ShipModel *shipmodel) const
void ShipDealer::func_buy(core::Player *player, const std::string &args)
{
core::Entity *dock = player->view();
-
ShipDealer *shipdealer = 0;
-
- // find the ship model
- ShipModel *shipmodel = ShipModel::find(args);
- if (!shipmodel) {
- if (!Game::g_devel->value()) {
- player->send("Cheats disabled");
- return;
- } else {
- shipmodel = ShipModel::search(args);
- }
+
+ std::istringstream is(args);
+ std::string labelstr;
+
+ if (!(is >> labelstr)) {
+ player->send("Usage: buy ship [string]");
}
- if (!shipmodel) {
- // enable rcon buffering
- sys::ConsoleInterface::instance()->set_rcon(true);
- ShipModel::list();
- // disable rcon buffering
- sys::ConsoleInterface::instance()->set_rcon(false);
-
- while (sys::ConsoleInterface::instance()->rconbuf().size()) {
- player->send((*sys::ConsoleInterface::instance()->rconbuf().begin()));
- sys::ConsoleInterface::instance()->rconbuf().pop_front();
- }
-
- player->send("Usage: buy ship label");
+ // find the ship model
+ ShipModel *shipmodel = ShipModel::find(labelstr);
+ if (!shipmodel) {
+ player->send("Unkown ship type '" + labelstr + "'");
return;
}
@@ -107,29 +93,26 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
}
}
- if (!Game::g_devel->value()) {
-
- if (!shipdealer) {
- player->send("No ship dealer available");
- return;
- }
-
- if (!shipdealer->find(shipmodel)) {
- player->send("Ship dealer does not sell the " + shipmodel->name());
- return;
- }
+ if (!shipdealer) {
+ player->send("No ship dealer available");
+ return;
+ }
- // check price
- if (shipmodel->price() > player->credits()) {
- std::stringstream msgstr;
- msgstr << "You require " << (shipmodel->price() - player->credits()) << " additional credits to buy the " << shipmodel->name();
- player->send(msgstr.str());
- return;
- }
+ if (!shipdealer->find(shipmodel)) {
+ player->send("Ship dealer does not sell the " + shipmodel->name());
+ return;
+ }
- player->add_credits(-shipmodel->price());
+ // check price
+ if (shipmodel->price() > player->credits()) {
+ std::stringstream msgstr;
+ msgstr << "You require " << (shipmodel->price() - player->credits()) << " additional credits to buy the " << shipmodel->name();
+ player->send(msgstr.str());
+ return;
}
+ player->add_credits(-shipmodel->price());
+
// player has only ship for now
if (player->control()) {
player->remove_asset(player->control());
@@ -151,10 +134,8 @@ void ShipDealer::func_buy(core::Player *player, const std::string &args)
// send the ship purchased message
std::stringstream msgstr;
- msgstr << "^BPurchased " << aux::article(shipmodel->name());
- if (!Game::g_devel->value()) {
- msgstr << " for " << shipmodel->price() << " credits";
- }
+ msgstr << "^BPurchased " << aux::article(shipmodel->name()) << " for " << shipmodel->price() << " credits";
+
player->send(msgstr.str());
player->sound("game/buy-ship");
}