The International Simutrans Forum

 

Author Topic: [Code v3.5] Suggestion Regarding stadt_t::step_passagiere()  (Read 1723 times)

0 Members and 1 Guest are viewing this topic.

knightly

  • Guest
Hi James,

Regarding the following part of code in stadt_t::step_passagiere() :

Code: [Select]

ITERATE(start_halts,i)
{
if(start_halts.get_count() < 1)
{
break;
}
halthandle_t current_halt = start_halts[i];
#ifdef NEW_PATHING
uint16 current_journey_time = current_halt->find_route(pax, best_journey_time);


I see that, for each ware packet, find_route() is called once per start halt. The same ziel halt list for the same ziel pos will get created each time find_route() is invoked, causing redundant efforts. While find_route() is certainly useful in cases where you only need to find the best route from a single start halt, it is not very efficient when you want to check multiple start halts against multiple ziel halts.

IMHO, find_route() can be incorporated into the iteration above, by nesting an iteration of ziel halts within. In this way, you can build the ziel list once, and you can even save the overhead of calling find_route().

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18722
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Code v3.5] Suggestion Regarding stadt_t::step_passagiere()
« Reply #1 on: May 09, 2009, 03:19:25 PM »
Knightly,

thank you for the suggestion - I have implemented this in 3.6.