Skip to main content
Topic: [Bug v3.8] Comparison Missing in haltestelle_t::find_route() (Read 2227 times) previous topic - next topic

[Bug v3.8] Comparison Missing in haltestelle_t::find_route()

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.

 

Re: [Bug v3.8] Comparison Missing in haltestelle_t::find_route()

Reply #1
Aha, well-spotted, thank you! Will be in 3.9.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.