The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Topic started by: knightly on May 08, 2009, 04:54:06 PM

Title: [Bug v3.5] Empty ware_t Objects' arrival_time is not Reset during Merging
Post by: knightly on May 08, 2009, 04:54:06 PM
Hi James,

In this part of code from haltestelle_t::hole_ab() :

Quote

   ware_t neu(tmp);
   if(  tmp.menge > maxi  )
   {
      // not all can be loaded
      neu.menge = maxi;
      tmp.menge -= maxi;
   }
   else
   {
      // leave an empty entry => joining will more often work
      tmp.menge = 0;
   }


empty ware_t entries (i.e. menge == 0) are kept to allow future merging. However, when they merge with newly arrived ware_t, the arrival time isn't reset to the time when merging happens in haltestelle_t::vereinige_waren() :

Quote

   if(ware.can_merge_with(tmp))
   {
      if(  ware.get_zwischenziel().is_bound()  &&  ware.get_zwischenziel()!=self  )
      {
         // update route if there is newer route
         tmp.set_zwischenziel( ware.get_zwischenziel() );
      }

      // Merge waiting times.
      if(tmp.menge > 0 && ware.menge > 0)
      {
         //The waiting time for ware will always be zero.
         tmp.arrival_time = welt->get_zeit_ms() - ((welt->get_zeit_ms() - tmp.arrival_time) * tmp.menge) / (tmp.menge + ware.menge);
      }

      tmp.menge += ware.menge;
      resort_freight_info = true;
      return true;
   }


The case where tmp.menge == 0 has not been handled, and the previous time stored in tmp.arrival_time will continue to be used, causing waiting time to be inaccurate for newly merged wares.
Title: Re: [Bug v3.5] Empty ware_t Objects' arrival_time is not Reset during Merging
Post by: jamespetts on May 08, 2009, 11:06:54 PM
Found and fixed for the next version - thank you. This actually makes a noticeable difference to waiting times in the game, which must have been substantially incorrect in previous versions.

Edit: Now fixed in 3.6