Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/camera.cc14
-rw-r--r--src/client/input.cc10
-rw-r--r--src/core/commandbuffer.cc2
-rw-r--r--src/core/gameinterface.cc6
-rw-r--r--src/core/gameinterface.h5
-rw-r--r--src/core/gameserver.h2
-rw-r--r--src/core/netconnection.cc3
-rw-r--r--src/core/player.cc16
-rw-r--r--src/core/player.h7
9 files changed, 36 insertions, 29 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc
index 03a4e1b..dcf4acf 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -5,7 +5,7 @@
*/
#include "math/mathlib.h"
-#include "core/player.h"
+#include "core/core.h"
#include "client/client.h"
#include "client/camera.h"
#include "render/render.h"
@@ -82,7 +82,7 @@ void set_mode(Mode newmode) {
case Track:
// switch camera to Track mode
mode = Track;
- yaw_target = core::Player::local.control->direction();
+ yaw_target = core::game()->localplayer()->control->direction();
yaw_current = yaw_target;
pitch_target = pitch_track;
pitch_current = pitch_target;
@@ -91,7 +91,7 @@ void set_mode(Mode newmode) {
case Free:
// switch camera to Free mode
mode = Free;
- yaw_target = core::Player::local.control->direction();
+ yaw_target = core::game()->localplayer()->control->direction();
yaw_current = yaw_target;
pitch_target = pitch_track;
pitch_current = pitch_target;
@@ -112,7 +112,7 @@ void set_mode(Mode newmode) {
void next_mode()
{
- if (!core::Player::local.control) {
+ if (!core::game()->localplayer()->control) {
set_mode(Overview);
return;
}
@@ -133,7 +133,7 @@ void next_mode()
void draw(float elapsed)
{
- if (!core::Player::local.control) {
+ if (!core::game()->localplayer()->control) {
// switch the camera to Overview of the player is not controling anything
if (mode != Overview) {
set_mode(Overview);
@@ -142,11 +142,11 @@ void draw(float elapsed)
if (mode == Overview)
set_mode(Track);
- camera::target = core::Player::local.control->location();
+ camera::target = core::game()->localplayer()->control->location();
}
if (mode == Track) {
- yaw_target = core::Player::local.control->direction();
+ yaw_target = core::game()->localplayer()->control->direction();
}
if ((mode == Free) || (mode == Track)) {
diff --git a/src/client/input.cc b/src/client/input.cc
index 9053725..e8dacd6 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -101,7 +101,7 @@ void frame(float seconds)
switch (event.type) {
case SDL_KEYUP:
- if (!console::visible() && core::application()->connected() && core::Player::local.control)
+ if (!console::visible() && core::application()->connected() && core::game()->localplayer()->control)
// send key events to the game world
keyreleased(event.key.keysym);
break;
@@ -111,7 +111,7 @@ void frame(float seconds)
} else if (console::visible()) {
// send key events to the console
console::keypressed(event.key.keysym);
- } else if (core::application()->connected() && core::Player::local.control) {
+ } else if (core::application()->connected() && core::game()->localplayer()->control) {
// send key events to the game world
keypressed(event.key.keysym);
}
@@ -123,9 +123,9 @@ void frame(float seconds)
}
- if (!console::visible() && core::application()->connected() && core::Player::local.control) {
- core::Player::local.control->set_thrust(local_thrust);
- core::Player::local.control->set_direction(math::degrees360f(core::Player::local.control->direction() + local_turn_offset));
+ if (!console::visible() && core::application()->connected() && core::game()->localplayer()->control) {
+ core::game()->localplayer()->control->set_thrust(local_thrust);
+ core::game()->localplayer()->control->set_direction(math::degrees360f(core::game()->localplayer()->control->direction() + local_turn_offset));
}
}
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index 5ab40e5..729c1db 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -76,7 +76,7 @@ void CommandBuffer::exec(std::string const &cmdline)
}
if ((f->flags() & Func::Game)) {
if (application()->connected()) {
- f->exec(&Player::local, args);
+ f->exec(game()->localplayer(), args);
}
} else {
f->exec(args);
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 908ffca..33166ee 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -17,12 +17,14 @@
namespace core
{
+Player GameInterface::game_localplayer;
+
GameInterface::GameInterface()
{
if (Cvar::sv_dedicated->value())
- local_player.player_name.assign("Console");
+ game_localplayer.player_name.assign("Console");
else
- local_player.player_name.assign("Player0");
+ game_localplayer.player_name.assign("Player0");
clear();
}
diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h
index 5e1f9be..0a7bdbe 100644
--- a/src/core/gameinterface.h
+++ b/src/core/gameinterface.h
@@ -25,7 +25,7 @@ public:
/*----- inspectors ---------------------------------------------- */
/// return the local player
- inline Player *localplayer() { return &local_player; }
+ inline Player *localplayer() { return &game_localplayer; }
/*----- virtual inspectors --------------------------------------- */
@@ -44,7 +44,8 @@ public:
virtual void frame(float seconds) = 0;
protected:
- Player local_player;
+ /// the local player
+ static Player game_localplayer;
};
}
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index ba64f2e..32a37c3 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -54,7 +54,7 @@ public:
/*----- static ---------------------------------------------------- */
- /// retuen the current game server
+ /// return the current game server
static inline GameServer *instance() { return server_instance; }
protected:
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index 60b4ff8..63c906a 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -8,6 +8,7 @@
#include "sys/sys.h"
#include "net/net.h"
+#include "core/application.h"
#include "core/netconnection.h"
#include "core/player.h"
@@ -31,7 +32,7 @@ void NetConnection::connect(std::string const &to_host, int to_port)
}
std::ostringstream osstream;
- osstream << "name " << Player::local.name() << std::endl;
+ osstream << "name " << game()->localplayer()->name() << std::endl;
send(osstream.str());
}
diff --git a/src/core/player.cc b/src/core/player.cc
index b54bf9e..8fc4ebf 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -9,18 +9,22 @@
namespace core
{
-Player Player::local;
-
Player::Player()
{
- player_id = 0;
- player_name.clear();
- dirty = false;
- control = 0;
+ clear();
}
Player::~Player()
{
+ clear();
+}
+
+void Player::clear()
+{
+ player_id = 0;
+ player_name.clear();
+ dirty = false;
+ control = 0;
}
}
diff --git a/src/core/player.h b/src/core/player.h
index 490515d..11711b5 100644
--- a/src/core/player.h
+++ b/src/core/player.h
@@ -25,6 +25,9 @@ class Player
public:
Player();
~Player();
+
+ /// clear all the data
+ void clear();
/// name of the player
inline std::string const &name() const { return player_name; }
@@ -38,15 +41,11 @@ public:
/// name of the player
std::string player_name;
-
/// dirty state
bool dirty;
/// the entity the Player is currently controling
EntityControlable *control;
-
- /// the local player
- static Player local;
};
}