From 1a1842473c826f4cf327d336b30a1f874e0e470b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 10 Nov 2013 01:45:26 +0000 Subject: Do not target far away ships with func_target_controlable. --- src/client/targets.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/client/targets.cc b/src/client/targets.cc index 1f8b8a1..3c3b2b8 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -268,7 +268,12 @@ void func_target_controlable_next(std::string const &args) if (it == zone->content().end()) { it = zone->content().begin(); } - while (!( ((*it)->type() == core::Entity::Controlable) && is_valid_hud_target((*it))) ) { + while ( + !( + is_valid_hud_target((*it)) && + ((*it)->type() == core::Entity::Controlable) && + ((static_cast((*it))->owner() || (math::distancesquared(core::localcontrol()->location(), (*it)->location()) < core::range::fxdistance * core::range::fxdistance))) + )) { it++; if (it == zone->content().end()) it = zone->content().begin(); @@ -280,7 +285,11 @@ void func_target_controlable_next(std::string const &args) } } - if ((it != zone->content().end()) && ((*it)->type() == core::Entity::Controlable) && is_valid_hud_target((*it))) { + if ((it != zone->content().end()) && + is_valid_hud_target((*it)) && + ((*it)->type() == core::Entity::Controlable) && + ((static_cast((*it))->owner() || (math::distancesquared(core::localcontrol()->location(), (*it)->location()) < core::range::fxdistance * core::range::fxdistance))) + ) { set_target((*it)); } else { current_target = 0; -- cgit v1.2.3