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')
-rw-r--r--src/game/base/base.cc33
-rw-r--r--src/game/base/base.h33
-rw-r--r--src/game/base/ship.cc22
3 files changed, 55 insertions, 33 deletions
diff --git a/src/game/base/base.cc b/src/game/base/base.cc
index 530e520..738db04 100644
--- a/src/game/base/base.cc
+++ b/src/game/base/base.cc
@@ -25,10 +25,7 @@
namespace base
{
-ShipModel *default_shipmodel = 0;
-core::Zone *default_zone = 0;
-
-/*----- engine game functions ------------------------------------- */
+/* -- engine game functions ---------------------------------------- */
/// list the ship model registry
void func_list_ship(std::string const &args)
@@ -42,9 +39,9 @@ void func_join(core::Player *player, std::string const &args)
if (player->control())
return;
- player->set_zone(default_zone);
- Ship *ship = new Ship(player, default_shipmodel);
- ship->set_zone(default_zone);
+ player->set_zone(Base::default_zone);
+ Ship *ship = new Ship(player, Base::default_shipmodel);
+ ship->set_zone(Base::default_zone);
player->set_control(ship);
core::server()->send_sound(player, "game/buy-ship");
@@ -105,7 +102,7 @@ void func_buy(core::Player *player, std::string const &args)
if (player->zone()) {
ship->set_zone(player->zone());
} else {
- ship->set_zone(default_zone);
+ ship->set_zone(Base::default_zone);
}
player->set_control(ship);
@@ -162,19 +159,29 @@ void func_impulse(core::Player *player, std::string const &args)
ship->impulse();
}
-/* ---- class Base ------------------------------------------------ */
+/* -- class Base static members ----------------------------------- */
+
+// game variables
+core::Cvar *Base::g_impulsespeed = 0;
+core::Cvar *Base::g_impulseacceleration = 0;
+core::Cvar *Base::g_strafespeed = 0;
+core::Cvar *Base::g_jumppointrange = 0;
+core::Cvar *Base::g_devel = 0;
-Base *Base::game_instance = 0;
+// game defaults
+core::Zone *Base::default_zone = 0;
+ShipModel *Base::default_shipmodel = 0;
+
+/* -- class Base -------------------------------------------------- */
Base::Base() : core::Module("base", "Project::OSiRiON", true)
{
- game_instance = this;
- g_impulsespeed = 0;
+ default_shipmodel = 0;
+ default_zone = 0;
}
Base::~Base()
{
- game_instance = 0;
}
void Base::init()
diff --git a/src/game/base/base.h b/src/game/base/base.h
index 2393a2e..34b3bd7 100644
--- a/src/game/base/base.h
+++ b/src/game/base/base.h
@@ -11,13 +11,14 @@
#include <string>
#include "base/ship.h"
+#include "base/shipmodel.h"
#include "base/star.h"
#include "core/core.h"
#include "filesystem/inifile.h"
#include "sys/sys.h"
/// the base game module
-/** the base game module containis the game-specific code for Project::Osirion
+/** the base game module contains the game-specific code for Project::OSiRiON
*/
namespace base
{
@@ -29,6 +30,7 @@ const unsigned int planet_enttype = 258;
const unsigned int navpoint_enttype = 259;
const unsigned int jumppoint_enttype = 260;
+/// the base Project::OSiRiON game model
class Base : public core::Module {
public:
Base();
@@ -43,13 +45,28 @@ public:
/// is called when a player disconnects
void player_disconnect(core::Player *player);
- static inline Base *instance() { return game_instance; }
+ /* --- game variables -------------------------------------- */
- core::Cvar *g_impulsespeed;
- core::Cvar *g_impulseacceleration;
- core::Cvar *g_strafespeed;
- core::Cvar *g_jumppointrange;
- core::Cvar *g_devel;
+ /// game variable: speed of the impulse drive
+ static core::Cvar *g_impulsespeed;
+
+ /// game variable: acceleration of the impulse drive
+ static core::Cvar *g_impulseacceleration;
+
+ /// game variable strafe speed
+ static core::Cvar *g_strafespeed;
+
+ /// game variable: jumppoint range
+ static core::Cvar *g_jumppointrange;
+
+ /// game variable: enable or disable development mode
+ static core::Cvar *g_devel;
+
+ /// default zone
+ static core::Zone *default_zone;
+
+ /// default ship model
+ static ShipModel *default_shipmodel;
protected:
/// initialize the game
@@ -59,7 +76,6 @@ protected:
void shutdown();
private:
- bool got_entity_key(filesystem::IniFile &inifile, core::Entity *entity);
bool load_world();
@@ -69,7 +85,6 @@ private:
bool load_ships();
- static Base *game_instance;
};
}
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 0fdfd3f..574d66c 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -73,7 +73,7 @@ void Ship::impulse()
}
entity_eventstate = core::Entity::ImpulseInitiate;
- if (Base::instance()->g_devel->value()) {
+ if (Base::g_devel->value()) {
entity_timer = 0;
} else {
entity_timer = 3;
@@ -88,7 +88,7 @@ void Ship::impulse()
void Ship::jump(std::string const &args)
{
// devel mode provides instant jump access to arbitrary systems
- if (Base::instance()->g_devel->value() && (args.size())) {
+ if (Base::g_devel->value() && (args.size())) {
core::Zone *jumptargetzone = 0;
std::string target;
@@ -130,7 +130,7 @@ void Ship::jump(std::string const &args)
return;
} else {
- if (!jumpdrive() && !Base::instance()->g_devel->value()) {
+ if (!jumpdrive() && !Base::g_devel->value()) {
core::server()->send(owner(), "This ship is not equiped with a hyperspace drive!");
return;
@@ -150,7 +150,7 @@ void Ship::jump(std::string const &args)
}
entity_eventstate = core::Entity::JumpInitiate;
- if (Base::instance()->g_devel->value()) {
+ if (Base::g_devel->value()) {
entity_timer = 0;
} else {
entity_timer = 8;
@@ -179,7 +179,7 @@ JumpPoint * Ship::find_closest_jumppoint()
}
if (jumppoint && jumppoint->target()) {
- if (Base::instance()->g_jumppointrange->value() < d) {
+ if (Base::g_jumppointrange->value() < d) {
core::server()->send(owner(), "Jumppoint out of range!");
return 0;
} else {
@@ -274,8 +274,8 @@ void Ship::frame(float seconds)
entity_timer -= 1.0f;
if (entity_timer <= 0) {
- actual_maxspeed = Base::instance()->g_impulsespeed->value();
- actual_acceleration = Base::instance()->g_impulseacceleration->value();
+ actual_maxspeed = Base::g_impulsespeed->value();
+ actual_acceleration = Base::g_impulseacceleration->value();
entity_eventstate = core::Entity::Impulse;
entity_timer = 0;
entity_dirty = true;
@@ -301,8 +301,8 @@ void Ship::frame(float seconds)
math::clamp(target_roll, -1.0f, 1.0f);
math::clamp(target_direction, -1.0f, 1.0f);
target_afterburner = 0.0f;
- actual_maxspeed = Base::instance()->g_impulsespeed->value();
- actual_acceleration = Base::instance()->g_impulseacceleration->value();
+ actual_maxspeed = Base::g_impulsespeed->value();
+ actual_acceleration = Base::g_impulseacceleration->value();
actual_turnspeed *= 0.5;
} else if (entity_eventstate == core::Entity::Normal) {
@@ -315,7 +315,7 @@ void Ship::frame(float seconds)
math::clamp(target_afterburner, -1.0f, 1.0f);
if (speed() > actual_maxspeed * 1.15f) {
- actual_acceleration = Base::instance()->g_impulseacceleration->value();
+ actual_acceleration = Base::g_impulseacceleration->value();
actual_turnspeed *= 0.5;
}
@@ -443,7 +443,7 @@ void Ship::frame(float seconds)
}
if (fabs(current_target_strafe) > MIN_DELTA) {
- entity_location += entity_axis.left() * (current_target_strafe * Base::instance()->g_strafespeed->value());
+ entity_location += entity_axis.left() * (current_target_strafe * Base::g_strafespeed->value());
}
entity_movement = target_thrust;