The International Simutrans Forum

 

Author Topic: [Code v3.5] 1/3 of Max Wait Time??  (Read 1708 times)

0 Members and 1 Guest are viewing this topic.

knightly

  • Guest
[Code v3.5] 1/3 of Max Wait Time??
« on: May 08, 2009, 03:58:08 PM »
Hi James,

May I know why in the following code from haltestelle_t::hole_ab() :

Quote

   // Skip if the goods have recently arrived, and this is not their preferred line/convoy
   // After waiting some time (1/3rd of their maximum wait), they will board anything.
   const uint16 third_minutes = base_max_minutes / 3;
   const uint16 twice_journey = connexions[tmp.get_besch()->get_catg_index()].get(tmp.get_zwischenziel()) != NULL ?
      connexions[tmp.get_besch()->get_catg_index()].get(tmp.get_zwischenziel())->journey_time * 2 : base_max_minutes;
   const uint16 max_best_minutes = third_minutes > twice_journey ? twice_journey : third_minutes;
   if(cnv != NULL && waiting_minutes <= max_best_minutes / 3)
   {
      ...


third_minutes is already 1/3 of base_max_minutes, but max_best_minutes is divided by 3 again? I ask this because in your comment, it says 1/3 of max wait time. Many thanks for your clarification.

Edited
« Last Edit: May 08, 2009, 04:24:19 PM by Knightly »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18425
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Code v3.5] 1/3 of Max Wait Time??
« Reply #1 on: May 08, 2009, 04:33:18 PM »
Ahh, thank you for spotting that - that is indeed inefficient. I can use third_minutes there instead.

Edit: Changed in 3.6
« Last Edit: May 09, 2009, 03:20:13 PM by jamespetts »