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>2010-10-04 14:50:16 +0000
committerStijn Buys <ingar@osirion.org>2010-10-04 14:50:16 +0000
commit5141df01c1a12cd325fc0100b5ad1547d5ee0c8b (patch)
tree586870c3da64ba59029f620e6d6138324deafe37 /src/game
parent7a75ef50dcf1955739969b47ff88c6fce9c3843a (diff)
home button while docked, give cargo cheat
Diffstat (limited to 'src/game')
-rw-r--r--src/game/base/game.cc63
1 files changed, 61 insertions, 2 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 7cdc066..c6b45ad 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -201,7 +201,7 @@ void Game::func_give(core::Player *player, const std::string &args)
std::string labelstr;
if (!player->control()) {
- player->send("^WNeed a ship to swap!");
+ player->send("^WNeed a ship to swap with!");
}
if (!(is >> labelstr)) {
@@ -263,10 +263,69 @@ void Game::func_give(core::Player *player, const std::string &args)
}
player->set_dirty();
player->sound("game/buy");
+
+ } else if (str.compare("cargo") == 0) {
+ std::string labelstr;
+
+ if (!player->control()) {
+ player->send("^WNeed a ship to load cargo!");
+ }
+
+ if (!(is >> labelstr)) {
+ player->send("Usage: give cargo [string] [int]");
+ return;
+ }
+
+ Cargo *cargo = Cargo::find(labelstr);
+ if (!cargo) {
+ // enable rcon buffering
+ sys::ConsoleInterface::instance()->set_rcon(true);
+ Cargo::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("Unkown cargo type '" + labelstr + "'");
+ return;
+ } else {
+ int amount = 0;
+ if (!(is >> amount)) {
+ amount = -1;
+ } else {
+ if (!amount)
+ return;
+ }
+
+ const int max = player->control()->inventory()->capacity_available() / cargo->volume();
+ if (amount < 0 ) {
+ amount = max;
+ }
+
+ if ((amount == 0) || (amount > max)) {
+ player->send("^WNot enough cargo space available!");
+ return;
+ }
+
+ core::Item *item = player->control()->inventory()->find(cargo);
+ if (!item) {
+ item = new core::Item(cargo);
+ player->control()->inventory()->add(item);
+ } else {
+ assert(player->control()->info() == cargo);
+ }
+ item->inc_amount(amount);
+ player->control()->inventory()->set_dirty();
+ player->sound("game/buy");
+ }
} else {
- player->send("Usage: give ship [string]");
+ player->send("Usage: give cargo [string] [int]");
player->send(" give credits [int]");
+ player->send(" give ship [string]");
return;
}
}