Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/base/game.cc')
-rw-r--r--src/game/base/game.cc96
1 files changed, 81 insertions, 15 deletions
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index ebf09ce..418bfb5 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -51,7 +51,6 @@ void Default::clear()
// game variables
core::Cvar *Game::g_impulsespeed = 0;
-core::Cvar *Game::g_impulseacceleration = 0;
core::Cvar *Game::g_jumppointrange = 0;
core::Cvar *Game::g_devel = 0;
core::Cvar *Game::g_damping = 0;
@@ -148,7 +147,7 @@ void Game::func_jump(core::Player *player, std::string const &args)
{
if (!player->control())
return;
- if (!player->control()->moduletype() == ship_enttype)
+ if (player->control()->moduletype() != ship_enttype)
return;
Ship * ship = static_cast<Ship *>(player->control());
ship->func_jump(args);
@@ -159,7 +158,7 @@ void Game::func_impulse(core::Player *player, std::string const &args)
{
if (!player->control())
return;
- if (!player->control()->moduletype() == ship_enttype)
+ if (player->control()->moduletype() != ship_enttype)
return;
Ship * ship = static_cast<Ship *>(player->control());
ship->func_impulse();
@@ -236,12 +235,13 @@ void Game::func_give(core::Player *player, const std::string &args)
return;
}
+ ShipModel *shipmodel = 0;
if (!(is >> labelstr)) {
player->send("Usage: give ship [string]");
- return;
+ } else {
+ shipmodel = ShipModel::find(labelstr);
}
- ShipModel *shipmodel = ShipModel::find(labelstr);
if (!shipmodel) {
// enable rcon buffering
sys::ConsoleInterface::instance()->set_rcon(true);
@@ -282,8 +282,8 @@ void Game::func_give(core::Player *player, const std::string &args)
ship->get_location().assign(player->control()->location());
ship->set_state(player->control()->state());
ship->get_axis().assign(player->control()->axis());
- ship->set_speed(player->control()->speed());
ship->set_thrust(player->control()->thrust());
+ ship->reset();
//target_thrust is protected
//ship->target_thrust = player->control()->target_thrust());
@@ -316,12 +316,13 @@ void Game::func_give(core::Player *player, const std::string &args)
player->send("^WNeed a ship to load cargo!");
}
+ Cargo *cargo = 0;
if (!(is >> labelstr)) {
player->send("Usage: give cargo [string] [int]");
- return;
+ } else {
+ cargo = Cargo::find(labelstr);
}
- Cargo *cargo = Cargo::find(labelstr);
if (!cargo) {
// enable rcon buffering
sys::ConsoleInterface::instance()->set_rcon(true);
@@ -375,6 +376,74 @@ void Game::func_give(core::Player *player, const std::string &args)
}
}
+
+void Game::func_specs(core::Player *player, const std::string &args)
+{
+ if (!Game::g_devel->value()) {
+ player->send("Cheats disabled");
+ return;
+ }
+
+ if (!player->control()) {
+ player->send("^WYou need to join the game first!");
+ return;
+ }
+
+ if (player->control()->moduletype() != ship_enttype)
+ return;
+ Ship * ship = static_cast<Ship *>(player->control());
+
+ std::istringstream is(args);
+ std::string str;
+
+ if (!(is >> str)) {
+ // enable rcon buffering
+ sys::ConsoleInterface::instance()->set_rcon(true);
+
+ con_print << "Current ship specifications for " + ship->name() << std::endl;
+ con_print << " mass = " << ship->shipmodel()->mass() << std::endl;
+ con_print << " thrust = " << ship->thrust_force() << std::endl;
+ con_print << " impulse = " << ship->impulse_force() << std::endl;
+ con_print << " strafe = " << ship->strafe_force() << std::endl;
+ con_print << " torque = " << ship->torque_force() << std::endl;
+
+ // 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();
+ }
+
+ } else {
+ float value;
+ if (!(is >> value))
+ return;
+
+ aux::to_label(str);
+ std::stringstream msgstr;
+
+ if (str.compare("thrust") == 0) {
+ ship->set_thrust_force(value);
+ msgstr << "Ship thrust force set to " << value;
+ } else if (str.compare("impulse") == 0) {
+ ship->set_impulse_force(value);
+ msgstr << "Ship impulse force set to " << value;
+ } else if (str.compare("strafe") == 0) {
+ ship->set_strafe_force(value) ;
+ msgstr << "Ship strafe force set to " << value;
+ } else if (str.compare("torque") == 0) {
+ ship->set_torque_force(value);
+ msgstr << "Ship torque force set to " << value;
+ } else {
+ msgstr << "^WUnknown ship specification '" << str << "'";
+ }
+
+ player->send(msgstr.str());
+ }
+
+}
+
// sell request from a player
void Game::func_sell(core::Player *player, const std::string &args)
{
@@ -769,6 +838,9 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func = core::Func::add("give", Game::func_give);
func->set_info("cheat functions");
+
+ func = core::Func::add("specs", Game::func_specs);
+ func->set_info("change ship specifications");
func = core::Func::add("jump", Game::func_jump);
func->set_info("[string] activate or deactivate hyperspace jump drive");
@@ -789,12 +861,9 @@ Game::Game() : core::Module("Project::OSiRiON", true)
func->set_info("dock with target object");
// add engine variables
- g_impulsespeed = core::Cvar::get("g_impulsespeed", "15", core::Cvar::Game | core::Cvar::Archive);
+ g_impulsespeed = core::Cvar::get("g_impulsespeed", "1500", core::Cvar::Game | core::Cvar::Archive);
g_impulsespeed->set_info("[float] speed of the impulse drive");
- g_impulseacceleration = core::Cvar::get("g_impulseacceleration", "5", core::Cvar::Game | core::Cvar::Archive);
- g_impulseacceleration->set_info("[float] acceleration of the impulse drive");
-
g_jumppointrange = core::Cvar::get("g_jumppointrange", "512", core::Cvar::Game | core::Cvar::Archive);
g_jumppointrange->set_info("[float] jumppoint range");
@@ -920,9 +989,6 @@ bool Game::load_zone(core::Zone *zone)
std::string strval;
- // set th default sky
- zone->set_sky("sky");
-
while (zoneini.getline()) {
if (zoneini.got_section()) {