The International Simutrans Forum

 

Author Topic: [Bug v3.5] Empty ware_t Objects' arrival_time is not Reset during Merging  (Read 4255 times)

0 Members and 1 Guest are viewing this topic.

knightly

  • Guest
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.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18721
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
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
« Last Edit: May 09, 2009, 03:19:02 PM by jamespetts »