The International Simutrans Forum

 

Author Topic: [Code v3.6] Ware Merging  (Read 1733 times)

0 Members and 1 Guest are viewing this topic.

knightly

  • Guest
[Code v3.6] Ware Merging
« 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?

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 20190
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Code v3.6] Ware Merging
« Reply #1 on: May 10, 2009, 03:11:57 PM »
Ahh, that seems to make sense...

knightly

  • Guest
Re: [Code v3.6] Ware Merging
« Reply #2 on: May 10, 2009, 05:52:08 PM »
gerw has confirmed here that is_freight() is correct with index>2. So, please ignore the 2nd point in my first post. Thank you for your attention.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 20190
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Code v3.6] Ware Merging
« Reply #3 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?

knightly

  • Guest
Re: [Code v3.6] Ware Merging
« Reply #4 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.