News:

Beta test the new forum at https://simutrans.forum/
Use the "Forum Search"
It may help you to find anything in the forum ;).

[Bug v3.5] Empty ware_t Objects' arrival_time is not Reset during Merging

Started by knightly, May 08, 2009, 04:54:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

knightly

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.

jamespetts

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
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.