The International Simutrans Forum

Simutrans Extended => Simutrans-Extended development => Topic started by: knightly on May 10, 2009, 02:42:39 PM

Title: [Code v3.6] Ware Merging
Post by: knightly on May 10, 2009, 02:42:39 PM
Hi James,

In the following code from ware_t::can_merge_with() :

Quote

   return index  == w.index  &&
      ziel  == w.ziel  &&
      // Only merge the destination *position* if the load is not freight
      (index < 3 || zielpos == w.zielpos) &&
      origin == w.origin;


I suppose the expression in blue should be index < 2 instead? Since pax and mail are hard-coded as 0 and 1 respectively.

If it is correct, then also in ware_t :

Quote
   bool is_passenger() const {  return index==0; }
   bool is_mail() const {  return index==1; }
   bool is_freight() const {  return index>2; }

this should also be changed to index>=2, right?
Title: Re: [Code v3.6] Ware Merging
Post by: jamespetts on May 10, 2009, 03:11:57 PM
Ahh, that seems to make sense...
Title: Re: [Code v3.6] Ware Merging
Post by: knightly on May 10, 2009, 05:52:08 PM
gerw has confirmed here (http://forum.simutrans.com/index.php?topic=2124.msg21636#msg21636) that is_freight() is correct with index>2. So, please ignore the 2nd point in my first post. Thank you for your attention.
Title: Re: [Code v3.6] Ware Merging
Post by: jamespetts on May 10, 2009, 06:00:21 PM
Knightly,

wouldn't that also mean that the first one was correct, too? If index > 2 is freight, then index < 3 is non-freight, isn't it?
Title: Re: [Code v3.6] Ware Merging
Post by: knightly on May 10, 2009, 07:47:30 PM
Sorry, I am not sure. I don't know if there will be any unexpected side-effects. But ST STD uses index<2, so probably it's safer to follow.