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/gameconnection.cc1
-rw-r--r--src/core/gameinterface.cc6
-rw-r--r--src/core/gameinterface.h10
-rw-r--r--src/core/gameserver.cc2
-rw-r--r--src/core/netconnection.cc2
5 files changed, 21 insertions, 0 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index f64c8fb..ba18bd5 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -61,6 +61,7 @@ GameConnection::GameConnection(std::string const &connectionstr)
}
game_players.push_back(localplayer());
+ set_playerlist_timestamp(timestamp());
connection_running = true;
}
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 5caa270..23018d3 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -122,6 +122,7 @@ void GameInterface::clear()
}
}
game_players.clear();
+ game_playerlist_timestamp = 0;
// remove all game functions
for (Func::Registry::iterator it = Func::registry().begin(); it != Func::registry().end();) {
@@ -193,4 +194,9 @@ void GameInterface::list_players()
con_print << count << " connected " << aux::plural("player", count) << std::endl;
}
+void GameInterface::set_playerlist_timestamp(const unsigned long timestamp)
+{
+ game_playerlist_timestamp = ( timestamp > 0 ? timestamp : 1);
+}
+
}
diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h
index bdce1d3..98894e7 100644
--- a/src/core/gameinterface.h
+++ b/src/core/gameinterface.h
@@ -38,6 +38,10 @@ public:
inline Players & players() {
return game_players;
}
+
+ inline const unsigned long playerlist_timestamp() const {
+ return game_playerlist_timestamp;
+ }
inline model::VertexArray *vertexarray() {
return game_vertexarray;
@@ -68,6 +72,9 @@ public:
/// request inventory for entity with id
virtual Inventory *request_inventory(Entity *entity) = 0;
+
+ void set_playerlist_timestamp(const unsigned long timestamp);
+
/*----- mutators ------------------------------------------------- */
@@ -89,6 +96,9 @@ protected:
Players game_players;
model::VertexArray *game_vertexarray;
+
+ /// timestamp of the time the playerlist was last changed
+ unsigned long game_playerlist_timestamp;
};
/// global local player instance
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 963db6d..31c6d42 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -441,6 +441,7 @@ void GameServer::player_connect(Player *player)
// manage player list
game_players.push_back(player);
+ set_playerlist_timestamp(timestamp());
}
void GameServer::player_disconnect(Player *player)
@@ -464,6 +465,7 @@ void GameServer::player_disconnect(Player *player)
if (it != game_players.end()) {
game_players.erase(it);
}
+ set_playerlist_timestamp(timestamp());
}
void GameServer::frame(unsigned long timestamp)
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index 3318c1e..15e57e2 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -755,6 +755,7 @@ void NetConnection::parse_incoming_message(const std::string & message)
if (!player) {
player = new Player();
game()->players().push_back(player);
+ game()->set_playerlist_timestamp(game()->timestamp());
}
player->receive_short_server_update(msgstream);
@@ -781,6 +782,7 @@ void NetConnection::parse_incoming_message(const std::string & message)
for (GameInterface::Players::iterator it = game()->players().begin(); it != game()->players().end() && !player; it++) {
if ((*it)->id() == player_id) {
game()->players().erase(it);
+ game()->set_playerlist_timestamp(game()->timestamp());
return;
}
}