News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

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

Started by knightly, May 14, 2009, 04:54:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

knightly

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.

jamespetts

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.