From 5141df01c1a12cd325fc0100b5ad1547d5ee0c8b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 4 Oct 2010 14:50:16 +0000 Subject: home button while docked, give cargo cheat --- src/game/base/game.cc | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'src/game') 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; } } -- cgit v1.2.3