diff options
author | Stijn Buys <ingar@osirion.org> | 2013-11-10 13:13:45 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-11-10 13:13:45 +0000 |
commit | 4db4ba29453ef17022ab71d99e1029c32687c6da (patch) | |
tree | 63c0cfe8f37c09f639bf482bd281445d740ad53e /src | |
parent | 7ddcc5fe68c58205ced08c596b74b74b85de2d4e (diff) |
Added 'give reputation' cheat.
Diffstat (limited to 'src')
-rw-r--r-- | src/game/base/game.cc | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc index e34f9a3..a628440 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -104,9 +104,9 @@ void Game::func_join(core::Player *player, std::string const &args) player->reputation().clear(); Faction::apply_default(player->reputation()); - // reset player timestamps - player->set_time_wasted(0); - player->set_time_joined(); + // reset player timestamps + player->set_time_wasted(0); + player->set_time_joined(); } player->set_dirty(); @@ -536,7 +536,7 @@ void Game::func_give(core::Player *player, const std::string &args) sys::ConsoleInterface::instance()->rconbuf().pop_front(); } - player->send("Unknown weapon type '" + labelstr + "'"); + player->send("^WUnknown weapon type '" + labelstr + "'"); return; } else { int amount = 0; @@ -607,9 +607,61 @@ void Game::func_give(core::Player *player, const std::string &args) player->sound("game/buy"); } + } else if (str.compare("reputation") == 0) { + std::string labelstr; + + Faction *faction= 0; + if (!(is >> labelstr)) { + player->send("Usage: give reputation [string] [int]"); + return; + } else { + aux::to_label(labelstr); + faction = Faction::find(labelstr); + } + + if (labelstr.compare("default") == 0) { + + player->reputation().clear(); + Faction::apply_default(player->reputation()); + player->reputation().set_dirty(); + + player->send("Reputation reset to default"); + return; + + } else if (!faction) { + // enable rcon buffering + sys::ConsoleInterface::instance()->set_rcon(true); + Faction::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("^WUnknown faction '" + labelstr + "'"); + return; + } + + float reputation; + if (!(is >> reputation)) { + player->send("Usage: give reputation [string] [int]"); + return; + } + + math::clamp(reputation, -100.0f, 100.0f); + player->reputation().set_reputation(faction, reputation); + player->reputation().set_dirty(); + + std::ostringstream msgstr; + msgstr << "Reputation for faction '" << faction->label() << "' set to " << reputation; + player->send(msgstr.str().c_str()); + } else { player->send("Usage: give cargo [string] [int]"); player->send(" give credits [int]"); + player->send(" give reputation [string] [int]"); player->send(" give ship [string]"); player->send(" give weapon [string] [int]"); return; |