The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Topic started by: knightly on May 14, 2009, 04:54:49 pm

Title: [Bug v3.8] Comparison Missing in haltestelle_t::find_route()
Post by: knightly on May 14, 2009, 04:54:49 pm
James,

In the following part of code from haltestelle_t::find_route(ziel_list, ware, journey_time) :

Quote
   // Now, find the best route from here.
   ITERATE_PTR(ziel_list,i)
   {
      path test_path = get_path_to(ziel_list->get_element(i), ware.get_besch()->get_catg_index());
      if(test_path.journey_time != 65535 && test_path.next_transfer.is_bound())
      {
         journey_time = test_path.journey_time;
         best_destination = i;
      }
   }

While you have checked the validity of test_path, you have forgotten to compare test_path.journey_time < journey_time. Without this check, journey_time and best_destination will always store the values for the last valid test_path, which may not necessary be the best path.
Title: Re: [Bug v3.8] Comparison Missing in haltestelle_t::find_route()
Post by: jamespetts on May 15, 2009, 11:13:44 pm
Aha, well-spotted, thank you! Will be in 3.9.