Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-07-30 16:00:49 +0000
committerStijn Buys <ingar@osirion.org>2008-07-30 16:00:49 +0000
commitd09a1be33a647aedc12ce5ddcb7ea4ee23a75c8c (patch)
tree8fe9d8778223e22e8c957b59c51bccabb98d2b94 /src/game
parentad436de3a520fb2469dafe23afe03dd0afe8d189 (diff)
various minor issues: ESC closing chat, g_autolevel
Diffstat (limited to 'src/game')
-rw-r--r--src/game/game.cc15
-rw-r--r--src/game/game.h6
-rw-r--r--src/game/ship.cc4
3 files changed, 18 insertions, 7 deletions
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));