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-01-11 12:15:22 +0000
committerStijn Buys <ingar@osirion.org>2009-01-11 12:15:22 +0000
commit20e8e4c0fb1262a25c2491679da4587d264208a2 (patch)
treec836dc74bfb82088c70bdd636dfb1f236043f58d /src/core/player.cc
parent7082a5a1b7258580c698a09cf9fb8bec0bc97472 (diff)
core::Player interface updates
Diffstat (limited to 'src/core/player.cc')
-rw-r--r--src/core/player.cc40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/core/player.cc b/src/core/player.cc
index c09cb6d..ad6641e 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -44,6 +44,20 @@ void Player::clear()
}
+void Player::print() const
+{
+ con_print << "id: ^B" << id() << "^N name: ^B" << name() << "^N" << std::endl;
+ con_print << " color ^B" << color() << std::endl;
+ con_print << " ping ^B" << ping() << std::endl;
+ con_print << " credits ^B" << credits() << std::endl;
+ con_print << " level ^B" << level() << std::endl;
+
+ if (zone()) {
+ con_print << " zone ^B" << zone()->name() << std::endl;
+ }
+
+}
+
void Player::send(const std::string text)
{
message(core::Message::Info, text);
@@ -95,21 +109,25 @@ void Player::set_mission_target(Entity *new_mission_target)
}
}
-void Player::set_credits(long amount)
+void Player::set_credits(const long amount)
{
player_credits = amount;
}
-void Player::add_credits(long amount)
+void Player::add_credits(const long amount)
{
player_credits += amount;
}
-void Player::set_ping(long ping)
+void Player::set_ping(const long ping)
{
player_ping = ping;
}
+void Player::set_level(const int level) {
+ player_level = level;
+}
+
void Player::update_info()
{
Cvar *cl_name = Cvar::find("cl_name");
@@ -184,12 +202,24 @@ void Player::serialize_server_update(std::ostream & os) const
unsigned int control_id = (player_control ? player_control->id() : 0);
unsigned int mission_id = (player_mission_target ? player_mission_target->id() : 0);
- os << player_id << " " << zone_id << " " << view_id << " " << control_id << " " << mission_id << " " << player_color << " ";
+ os << player_id << " "
+ << zone_id << " "
+ << view_id << " "
+ << control_id << " "
+ << mission_id << " "
+ << player_color << " ";
}
void Player::receive_server_update(std::istream &is)
{
- is >> player_id;
+ int id = 0;
+ is >> id;
+ if (!player_id) {
+ player_id = id;
+ } else if (player_id != id) {
+ con_warn << "received inconsistent player update for player " << id << "\n";
+ return;
+ }
unsigned int zone_id = 0;
is >> zone_id;