Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-04 18:24:36 +0000
committerStijn Buys <ingar@osirion.org>2008-08-04 18:24:36 +0000
commit50a1e2b2fe3c207c7227df4941f2f66990db0c2c (patch)
tree5c4293babed4434d81cf9284f522dd0e74482cf0 /src/core/player.cc
parentebd5cd9daabb2d2eb6f5e06f9433cc8e6a4e0f7a (diff)
network protocol version 5, netserver per-client updates, zone change protocol
Diffstat (limited to 'src/core/player.cc')
-rw-r--r--src/core/player.cc41
1 files changed, 14 insertions, 27 deletions
diff --git a/src/core/player.cc b/src/core/player.cc
index ba5ffbe..fafb052 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -29,6 +29,7 @@ void Player::clear()
player_zone = 0;
player_name.clear();
player_dirty = false;
+ player_zonechange = false;
player_rcon = false;
player_mute = false;
@@ -40,16 +41,17 @@ void Player::set_control(EntityControlable *entitycontrolable)
player_control = entitycontrolable;
if (entitycontrolable) {
- player_zone = entitycontrolable->zone();
+ set_zone(entitycontrolable->zone());
}
-
player_dirty = true;
}
void Player::set_zone(Zone *zone)
{
- player_zone = zone;
- player_dirty = true;
+ if (zone != player_zone) {
+ player_zone = zone;
+ player_zonechange = true;
+ }
}
void Player::update_info()
@@ -99,41 +101,26 @@ void Player::receive_client_update(std::istream &is)
void Player::serialize_server_update(std::ostream & os) const
{
- unsigned int zone;
- if (player_zone)
- zone = player_zone->id();
- else
- zone = 0;
-
- unsigned int co;
- if (player_control)
- co = player_control->id();
- else
- co = 0;
-
-
- os << player_id << " " << zone << " " << co << " " << player_color << " \"" << player_name << "\"";
+ unsigned int zo = (zone() ? zone()->id() : 0);
+ unsigned int co = (player_control ? player_control->id() : 0);
+
+ os << player_id << " " << zo << " " << co << " " << player_color << " \"" << player_name << "\"";
}
void Player::receive_server_update(std::istream &is)
{
is >> player_id;
- unsigned int zone = 0;
- is >> zone;
- if (zone) {
- player_zone = Zone::find(zone);
- } else {
- player_zone = 0;
- }
+ unsigned int zo = 0;
+ is >> zo;
+ set_zone(Zone::find(zo));
unsigned int co = 0;
is >> co;
if (co) {
Entity *e = Entity::find(co);
if (e && e->type() == Entity::Controlable) {
- player_control = (EntityControlable *) e;
- player_zone = player_control->zone();
+ player_control = static_cast<EntityControlable *>(e);
} else {
player_control = 0;
con_warn << "control set to unknown entity " << co << "\n";