Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/gamewindow.cc5
-rw-r--r--src/client/hud.cc27
-rw-r--r--src/client/targets.cc2
-rw-r--r--src/core/net.h2
-rw-r--r--src/core/player.cc33
-rw-r--r--src/core/player.h26
-rw-r--r--src/game/base/game.cc18
-rw-r--r--src/game/base/ship.cc3
8 files changed, 99 insertions, 17 deletions
diff --git a/src/client/gamewindow.cc b/src/client/gamewindow.cc
index 71a2171..0b39cea 100644
--- a/src/client/gamewindow.cc
+++ b/src/client/gamewindow.cc
@@ -402,6 +402,11 @@ void GameWindow::draw()
gamewindow_launchbutton->hide();
gamewindow_freeflightbutton->show();
+ if (core::localplayer()->autopilot_target()) {
+ gamewindow_freeflightbutton->enable();
+ } else {
+ gamewindow_freeflightbutton->disable();
+ }
gamewindow_gotobutton->show();
gamewindow_dockbutton->show();
gamewindow_formationbutton->show();
diff --git a/src/client/hud.cc b/src/client/hud.cc
index 1fabe10..4c98bd8 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -171,6 +171,8 @@ void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target)
if (entity == core::localplayer()->mission_target()) {
bitmap_color.assign(palette()->mission());
+ } else if (entity == core::localplayer()->autopilot_target()) {
+ bitmap_color.assign(palette()->mission());
}
render::Textures::bind(bitmap_material.c_str());
@@ -252,6 +254,7 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
std:: string bitmap_material;
+ // default target color
if (controlable) {
if (controlable->owner()) {
bitmap_material.assign("bitmaps/hud/target_controlable");
@@ -262,25 +265,33 @@ void HUD::draw_target(core::Entity *entity, bool is_active_target)
} else if (entity->has_flag(core::Entity::Dockable)) {
bitmap_material.assign("bitmaps/hud/target_dockable");
-
bitmap_color.assign(1.0f, 1.0f, 1.0f); // white
+
} else {
bitmap_material.assign("bitmaps/hud/target_default");
bitmap_color.assign(palette()->text()); // default text color
+
}
- // reputation color
- if (reputation >= core::range::reputation_friendly) {
+ // mission, autopilot and reputation override target color
+ if (entity == core::localplayer()->mission_target()) {
+ // mission target
+ bitmap_color.assign(palette()->mission());
+
+ } else if (entity == core::localplayer()->autopilot_target()) {
+ // mission target
+ bitmap_color.assign(palette()->mission());
+
+ } else if (reputation >= core::range::reputation_friendly) {
// friendly
bitmap_color.assign(0.0f, 1.0f, 0.0f); // green
+
} else if (reputation <= core::range::reputation_hostile) {
// hostile
bitmap_color.assign(1.0f, 0.0f, 0.0f); // red
+
}
- if (entity == core::localplayer()->mission_target()) {
- bitmap_color.assign(palette()->mission());
- }
ui::Paint::draw_bitmap(bitmap_location, bitmap_size, bitmap_color, bitmap_material);
// ---------------------------------------------------------
@@ -443,6 +454,10 @@ void HUD::draw()
// draw current HUD target
draw_target(entity, true);
+ } else if (entity == core::localplayer()->autopilot_target()) {
+ // draw current mission target
+ draw_target(entity, false);
+
} else if (entity == core::localplayer()->mission_target()) {
// draw current mission target
draw_target(entity, false);
diff --git a/src/client/targets.cc b/src/client/targets.cc
index 088d334..466b4a9 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -68,6 +68,8 @@ bool is_valid_hud_target(const core::Entity *entity)
return true;
} else if (entity == core::localplayer()->mission_target()) {
return true;
+ } else if (entity == core::localplayer()->autopilot_target()) {
+ return true;
} else if (!ext_render(entity)) {
return false;
} else {
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;
diff --git a/src/game/base/game.cc b/src/game/base/game.cc
index 4a4441d..776f6c1 100644
--- a/src/game/base/game.cc
+++ b/src/game/base/game.cc
@@ -2723,8 +2723,24 @@ bool Game::load_settings()
void Game::frame(float seconds)
{
- if (!running())
+ if (!running()) {
return;
+ }
+
+ for (core::GameInterface::Players::iterator it = core::game()->players().begin(); it != core::game()->players().end(); ++it) {
+ core::Entity *target = 0;
+
+ // set player autopilot target
+ if ((*it)->control()) {
+ assert ((*it)->control()->moduletype() == ship_enttype);
+
+ Ship * ship = static_cast<Ship *>((*it)->control());
+ if (ship->state() != Ship::Docked) {
+ target = ship->autopilot_target();
+ }
+ }
+ (*it)->set_autopilot_target(target);
+ }
}
void Game::player_connect(core::Player *player)
diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc
index 7c9de1f..e9d9b54 100644
--- a/src/game/base/ship.cc
+++ b/src/game/base/ship.cc
@@ -496,9 +496,6 @@ void Ship::set_zone(core::Zone *zone)
void Ship::set_autopilot_target(core::Entity *target)
{
if (ship_autopilot_target != target) {
- if (owner()) {
- owner()->set_mission_target(target);
- }
ship_autopilot_target = target;
}
}