From 862f1dc0ae63b476b620a817bb2ea73d9b35ef3f Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 15 Oct 2010 13:01:44 +0000 Subject: added 'eject cargo' game command --- src/game/base/game.cc | 67 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 4 deletions(-) (limited to 'src/game/base/game.cc') diff --git a/src/game/base/game.cc b/src/game/base/game.cc index 19b3968..b426989 100644 --- a/src/game/base/game.cc +++ b/src/game/base/game.cc @@ -200,7 +200,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 with!"); + player->send("^WYou need to join the game first!"); return; } @@ -346,6 +346,11 @@ void Game::func_give(core::Player *player, const std::string &args) // sell request from a player void Game::func_sell(core::Player *player, const std::string &args) { + if (!player->control()) { + player->send("^WYou need to join the game first!"); + return; + } + std::istringstream is(args); std::string typestr; std::string labelstr; @@ -384,6 +389,11 @@ void Game::func_sell(core::Player *player, const std::string &args) // buy request from a player void Game::func_buy(core::Player *player, const std::string &args) { + if (!player->control()) { + player->send("^WYou need to join the game first!"); + return; + } + std::istringstream is(args); std::string typestr; std::string labelstr; @@ -426,11 +436,55 @@ void Game::func_buy(core::Player *player, const std::string &args) return; } +// eject cargo request +void Game::func_eject(core::Player *player, const std::string &args) +{ + if (!player->control()) { + player->send("^WYou need to join the game first!"); + return; + } + + std::istringstream is(args); + std::string typestr; + std::string labelstr; + + if (!(is >> typestr)) { + player->send("Usage: eject [string] [string] [int] eject an item: specify type, label and amount"); + return; + } else { + aux::to_label(typestr); + } + + if (!(is >> labelstr)) { + player->send("Usage: eject [string] [string] [int] eject an item: specify type, label and amount"); + return; + } else { + aux::to_label(labelstr); + } + + int amount = 0; + if (!(is >> amount)) + amount = 0; + + if (typestr.compare("cargo") == 0) { + Cargo *cargo = Cargo::find(labelstr); + if (cargo) { + cargo->eject(player->control(), amount); + } else { + player->send("Unkown cargo type '" + labelstr + "'"); + } + } else { + player->send("Unkown item type '" + typestr + "'"); + } +} + // launch request void Game::func_launch(core::Player *player, std::string const &args) { - if (!player->control()) + if (!player->control()) { + player->send("^WYou need to join the game first!"); return; + } if (!player->view()) return; @@ -494,8 +548,10 @@ void Game::func_launch(core::Player *player, std::string const &args) // respawn void Game::func_respawn(core::Player *player, std::string const &args) { - if (!player->control()) + if (!player->control()) { + func_join(player, args); return; + } if (!(player->view() == player->control())) return; @@ -606,7 +662,10 @@ Game::Game() : core::Module("Project::OSiRiON", true) func = core::Func::add("sell", Game::func_sell); func->set_info("[string] [string] [int] sell an item: specify type, label and amount"); - + + func = core::Func::add("eject", Game::func_eject); + func->set_info("[string] [string] [int] eject an item from inventory: specify type, label and amount"); + func = core::Func::add("give", Game::func_give); func->set_info("cheat functions"); -- cgit v1.2.3