Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-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
7 files changed, 24 insertions, 17 deletions
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;
};
}