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>2009-06-29 18:22:07 +0000
committerStijn Buys <ingar@osirion.org>2009-06-29 18:22:07 +0000
commit024532b748b15a92303fd20c3b6a7062a37ca2ed (patch)
treea313dee0aed03c27582a68432e40b96ab90dfbed /src/core/player.cc
parentbf96f47d2c993112327f278eb2dd270b769e59aa (diff)
client player list updates, short pif network messages, bump to network proto version 17
Diffstat (limited to 'src/core/player.cc')
-rw-r--r--src/core/player.cc52
1 files changed, 49 insertions, 3 deletions
diff --git a/src/core/player.cc b/src/core/player.cc
index 9a3ec9b..4276f20 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -214,7 +214,6 @@ void Player::serialize_server_update(std::ostream & os) const
<< view_id << " "
<< control_id << " "
<< mission_id << " "
- << player_color << " "
<< player_credits << " "
<< player_level << " "
<< player_ping;
@@ -263,10 +262,9 @@ void Player::receive_server_update(std::istream &is)
} else {
player_mission_target = 0;
}
- is >> player_color;
+
is >> player_credits;
is >> player_level;
-
is >> player_ping;
/*
@@ -281,6 +279,54 @@ void Player::receive_server_update(std::istream &is)
*/
}
+void Player::serialize_short_server_update(std::ostream & os) const
+{
+ unsigned int zone_id = (zone() ? zone()->id() : 0);
+
+ os << player_id << " "
+ << "\"" << player_name << "\" "
+ << zone_id << " "
+ << player_color << " "
+ << player_color_second << " "
+ << player_level << " "
+ << player_ping;
+
+}
+
+void Player::receive_short_server_update(std::istream &is)
+{
+ // read player id
+ int id = 0;
+ is >> id;
+ if (!player_id) {
+ player_id = id;
+ } else if (player_id != id) {
+ con_warn << "received inconsistent short update for player " << id << "\n";
+ return;
+ }
+
+ // read player name
+ std::string n;
+ char c;
+ while ( (is.get(c)) && (c != '"'));
+ while ( (is.get(c)) && (c != '"'))
+ n += c;
+
+ if (n.size())
+ player_name = n;
+
+ // read zone id
+ unsigned int zone_id = 0;
+ is >> zone_id;
+ set_zone(Zone::find(zone_id));
+
+ // read attributes
+ is >> player_color;
+ is >> player_color_second;
+ is >> player_level;
+ is >> player_ping;
+}
+
void Player::add_asset(EntityControlable *entity)
{
entity->entity_owner = this;