diff options
Diffstat (limited to 'src/core/player.cc')
-rw-r--r-- | src/core/player.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/core/player.cc b/src/core/player.cc index 1a610ca..26ea070 100644 --- a/src/core/player.cc +++ b/src/core/player.cc @@ -6,6 +6,7 @@ #include <sstream> +#include "auxiliary/functions.h" #include "sys/sys.h" #include "core/player.h" #include "core/cvar.h" @@ -33,6 +34,7 @@ void Player::clear() player_zonechange = false; player_rcon = false; player_mute = false; + player_mission_target = 0; clear_assets(); player_control = 0; @@ -56,12 +58,23 @@ void Player::set_zone(Zone *zone) } } +void Player::set_mission_target(Entity *new_mission_target) +{ + if (new_mission_target != player_mission_target) { + player_mission_target = new_mission_target; + player_dirty = true; + } +} + void Player::update_info() { Cvar *cl_name = Cvar::find("cl_name"); if (cl_name) { - if (cl_name->str().size()) + if (cl_name->str().size()) { player_name = cl_name->str(); + aux::strip_quotes(player_name); + (*cl_name) = player_name; + } } Cvar *cl_color = Cvar::find("cl_color"); @@ -105,8 +118,9 @@ void Player::serialize_server_update(std::ostream & os) const { unsigned int zo = (zone() ? zone()->id() : 0); unsigned int co = (player_control ? player_control->id() : 0); + unsigned int mission = (player_mission_target ? player_mission_target->id() : 0); - os << player_id << " " << zo << " " << co << " " << player_color << " \"" << player_name << "\""; + os << player_id << " " << zo << " " << co << " " << mission << " " << player_color << " \"" << player_name << "\""; } void Player::receive_server_update(std::istream &is) @@ -131,6 +145,16 @@ void Player::receive_server_update(std::istream &is) player_control = 0; } + unsigned int mission = 0; + is >> mission; + if (mission) { + player_mission_target = Entity::find(mission); + if (!player_mission_target) { + con_warn << "mission target set to unknown entity " << co << "\n"; + } + } else { + player_mission_target = 0; + } is >> player_color; std::string n; |