From d09a1be33a647aedc12ce5ddcb7ea4ee23a75c8c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 30 Jul 2008 16:00:49 +0000 Subject: various minor issues: ESC closing chat, g_autolevel --- src/game/game.cc | 15 ++++++++++----- src/game/game.h | 6 ++++++ src/game/ship.cc | 4 ++-- 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'src/game') diff --git a/src/game/game.cc b/src/game/game.cc index e481c9f..83daa93 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -20,7 +20,7 @@ namespace game { -Game *this_game = 0; + ShipModel *default_shipmodel = 0; core::Zone *default_zone = 0; @@ -183,15 +183,19 @@ void func_jump(core::Player *player, std::string const &args) player->set_zone(zone); } -/*----- Game ------------------------------------------------------ */ +/* ---- The Game class --------------------------------------------- */ + +Game *Game::game_instance = 0; Game::Game() : core::Module("Project::OSiRiON") { - this_game = this; + game_instance = this; + g_autolevel = 0; } Game::~Game() { + game_instance = 0; } void Game::init() @@ -227,8 +231,8 @@ void Game::init() func = core::Func::add("list_ship", (core::FuncPtr) func_list_ship); func->set_info("list ship statistics"); - // set game variables - core::Cvar::set("g_impulsespeed", "10.0f", core::Cvar::Game); + g_autolevel = core::Cvar::get("g_autolevel", "1", core::Cvar::Game | core::Cvar::Archive); + g_autolevel->set_info("[bool] enable or disale experimental autolevelling"); // indicate the module is ready to run frames module_running = true; @@ -236,6 +240,7 @@ void Game::init() void Game::shutdown() { + g_autolevel = 0; // game functions are automaticly removed // remove engine core functions diff --git a/src/game/game.h b/src/game/game.h index a715edd..3d8e3b9 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -48,12 +48,18 @@ public: /// is called when a player disconnects void player_disconnect(core::Player *player); + static inline Game *instance() { return game_instance; } + + core::Cvar *g_autolevel; + private: bool load_world(); bool load_zone(core::Zone *zone); bool load_ships(); + + static Game *game_instance; }; } diff --git a/src/game/ship.cc b/src/game/ship.cc index d8f7bb3..aa47044 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -64,7 +64,7 @@ void Ship::frame(float seconds) entity_thrust = target_thrust; - if (autolevel()) { + if (autolevel() && Game::instance()->g_autolevel->value()) { n.assign(math::crossproduct(entity_axis.up(), math::Vector3f(0, 0, 1.0f))); if (!(n.length() < MIN_DELTA)) { cosangle = math::dotproduct(entity_axis.up(), math::Vector3f(0, 0, 1.0f)); @@ -96,7 +96,7 @@ void Ship::frame(float seconds) } // auto-leveling - if (autolevel()) { + if (autolevel() && Game::instance()->g_autolevel->value()) { n.assign(math::crossproduct(entity_axis.up(), math::Vector3f(0.0f, 0.0f, 1.0f))); if (!(n.length() < MIN_DELTA)) { cosangle = math::dotproduct(entity_axis.up(), math::Vector3f(0.0f, 0.0f, 1.0f)); -- cgit v1.2.3