The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Topic started by: knightly on May 08, 2009, 03:58:08 pm

Title: [Code v3.5] 1/3 of Max Wait Time??
Post by: knightly 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
Title: Re: [Code v3.5] 1/3 of Max Wait Time??
Post by: jamespetts 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