File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -879,7 +879,7 @@ void GeoscapeState::time5Seconds()
879879 continue ;
880880 }
881881 // Can we actually fight it
882- if (!(*j)->isInDogfight () && !(*j)-> getDistance (u) )
882+ if (!(*j)->isInDogfight ())
883883 {
884884 _dogfightsToBeStarted.push_back (new DogfightState (this , (*j), u));
885885 if ((*j)->getRules ()->isWaterOnly () && u->getAltitudeInt () > (*j)->getRules ()->getMaxAltitude ())
Original file line number Diff line number Diff line change @@ -685,6 +685,7 @@ void Craft::think()
685685 else
686686 {
687687 _takeoff--;
688+ resetMeetPoint ();
688689 }
689690 if (reachedDestination () && _dest == (Target*)_base)
690691 {
Original file line number Diff line number Diff line change @@ -207,7 +207,7 @@ void MovingTarget::move()
207207 calculateSpeed ();
208208 if (_dest != 0 )
209209 {
210- if (getDistance (_dest ) > _speedRadian)
210+ if (getDistance (_meetPointLon, _meetPointLat ) > _speedRadian)
211211 {
212212 setLongitude (_lon + _speedLon);
213213 setLatitude (_lat + _speedLat);
@@ -216,6 +216,7 @@ void MovingTarget::move()
216216 {
217217 setLongitude (_dest->getLongitude ());
218218 setLatitude (_dest->getLatitude ());
219+ resetMeetPoint ();
219220 }
220221 }
221222}
@@ -240,7 +241,7 @@ void MovingTarget::calculateMeetPoint()
240241 _meetPointLon = _lon;
241242 }
242243
243- if (!_dest || !Options::meetingPoint) return ;
244+ if (!_dest || !Options::meetingPoint || reachedDestination () ) return ;
244245
245246 MovingTarget *t = dynamic_cast <MovingTarget*>(_dest);
246247 if (!t || !t->getDestination ()) return ;
Original file line number Diff line number Diff line change @@ -238,7 +238,12 @@ std::vector<Craft*> Target::getCraftFollowers() const
238238 */
239239double Target::getDistance (const Target *target) const
240240{
241- return acos (cos (_lat) * cos (target->getLatitude ()) * cos (target->getLongitude () - _lon) + sin (_lat) * sin (target->getLatitude ()));
241+ return getDistance (target->getLongitude (), target->getLatitude ());
242+ }
243+
244+ double Target::getDistance (double lon, double lat) const
245+ {
246+ return acos (cos (_lat) * cos (lat) * cos (lon - _lon) + sin (_lat) * sin (lat));
242247}
243248
244249}
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ class Target
8080 std::vector<Craft*> getCraftFollowers () const ;
8181 // / Gets the distance to another target.
8282 double getDistance (const Target *target) const ;
83+ double getDistance (double lon, double lat) const ;
8384};
8485
8586}
Original file line number Diff line number Diff line change 3232
3333inline bool AreSame (float l, float r)
3434{
35- return std::fabs (l-r) <= FLT_EPSILON ;
35+ return std::fabs (l-r) <= FLT_EPSILON * std::max ( 1 . 0f , std::max ( std::fabs (l), std::fabs (r))) ;
3636}
3737
3838inline bool AreSame (double l, double r)
3939{
40- return std::fabs (l-r) <= DBL_EPSILON ;
40+ return std::fabs (l-r) <= DBL_EPSILON * std::max ( 1.0 , std::max ( std::fabs (l), std::fabs (r))); ;
4141}
4242
4343inline float Round (float x)
You can’t perform that action at this time.
0 commit comments