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/net.h2
-rw-r--r--src/core/player.cc33
-rw-r--r--src/core/player.h26
3 files changed, 54 insertions, 7 deletions
diff --git a/src/core/net.h b/src/core/net.h
index 2102c7c..b919374 100644
--- a/src/core/net.h
+++ b/src/core/net.h
@@ -11,7 +11,7 @@ namespace core
{
/// network protocol version
-const unsigned int PROTOCOLVERSION = 27;
+const unsigned int PROTOCOLVERSION = 28;
/// maximum lenght of a (compressed) network message block
const unsigned int FRAMESIZE = 1152;
diff --git a/src/core/player.cc b/src/core/player.cc
index bf71b77..14767bd 100644
--- a/src/core/player.cc
+++ b/src/core/player.cc
@@ -38,6 +38,7 @@ void Player::clear()
player_zonechange = false;
player_mute = false;
player_mission_target = 0;
+ player_autopilot_target = 0;
player_view = 0;
clear_assets();
@@ -146,6 +147,14 @@ void Player::set_mission_target(Entity *new_mission_target)
}
}
+void Player::set_autopilot_target(Entity *new_autopilot_target)
+{
+ if (new_autopilot_target != player_autopilot_target) {
+ player_autopilot_target = new_autopilot_target;
+ player_dirty = true;
+ }
+}
+
void Player::set_credits(const long amount)
{
player_credits = amount;
@@ -260,16 +269,18 @@ void Player::receive_client_update(std::istream &is)
void Player::serialize_server_update(std::ostream & os) const
{
- unsigned int zone_id = (zone() ? zone()->id() : 0);
- unsigned int view_id = (player_view ? player_view->id() : 0);
- unsigned int control_id = (player_control ? player_control->id() : 0);
- unsigned int mission_id = (player_mission_target ? player_mission_target->id() : 0);
+ const unsigned int zone_id = (zone() ? zone()->id() : 0);
+ const unsigned int view_id = (player_view ? player_view->id() : 0);
+ const unsigned int control_id = (player_control ? player_control->id() : 0);
+ const unsigned int mission_id = (player_mission_target ? player_mission_target->id() : 0);
+ const unsigned int autopilot_id = (player_autopilot_target ? player_autopilot_target->id() : 0);
os << player_id << " "
<< zone_id << " "
<< view_id << " "
<< control_id << " "
<< mission_id << " "
+ << autopilot_id << " "
<< player_credits << " "
<< player_level << " "
<< player_npckills << " "
@@ -307,6 +318,7 @@ void Player::receive_server_update(std::istream &is)
} else {
player_control = 0;
con_warn << "control set to unknown entity " << control_id << "\n";
+ // FIMXE request entity
}
} else {
player_control = 0;
@@ -318,10 +330,23 @@ void Player::receive_server_update(std::istream &is)
player_mission_target = Entity::find(mission_id);
if (!player_mission_target) {
con_warn << "mission target set to unknown entity " << mission_id << "\n";
+ // FIMXE request entity
}
} else {
player_mission_target = 0;
}
+
+ unsigned int autopilot_id = 0;
+ is >> autopilot_id;
+ if (autopilot_id) {
+ player_autopilot_target = Entity::find(autopilot_id);
+ if (!player_autopilot_target) {
+ con_warn << "autopilot target set to unknown entity " << autopilot_id << "\n";
+ // FIMXE request entity
+ }
+ } else {
+ player_autopilot_target = 0;
+ }
is >> player_credits;
is >> player_level;
diff --git a/src/core/player.h b/src/core/player.h
index 8d614ee..a9eb4b0 100644
--- a/src/core/player.h
+++ b/src/core/player.h
@@ -89,10 +89,20 @@ public:
return player_rconpassword;
}
- /// mission target
+ /**
+ * @brief current mission target
+ * */
inline Entity *mission_target() {
return player_mission_target;
}
+
+ /**
+ * @brief current autopilot target
+ * */
+ /// mission target
+ inline Entity *autopilot_target() {
+ return player_autopilot_target;
+ }
/// view
inline Entity *view() {
@@ -245,8 +255,17 @@ public:
*/
void set_control(EntityControlable *entitycontrolable);
- /// set mission target
+ /**
+ * @brief set current mission target
+ * This will set dirty() if new_mission_target differs from mission_target()
+ * */
void set_mission_target(Entity *new_mission_target);
+
+ /**
+ * @brief set current autopilot target
+ * This will set dirty() if new_autopilot_target differs from autopilot_target()
+ * */
+ void set_autopilot_target(Entity *new_autopilot_target);
/// set the current view
void set_view(Entity *view);
@@ -331,6 +350,9 @@ private:
// current mission target
Entity *player_mission_target;
+
+ // current autopilot target
+ Entity *player_autopilot_target;
// the zone the player is currently in
Zone *player_zone;