The International Simutrans Forum

 

Author Topic: r1943 - weg_search still has problem  (Read 3383 times)

0 Members and 1 Guest are viewing this topic.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
r1943 - weg_search still has problem
« on: August 09, 2008, 12:50:21 PM »
I made apatch before.
But this problem is NOT solved yet.
I don't know why you don't like my patches in spite of working well.

Code: [Select]
Index: bauer/wegbauer.cc
===================================================================
--- bauer/wegbauer.cc (r1943)
+++ bauer/wegbauer.cc (copy)
@@ -126,6 +126,7 @@
  if(  (test->gib_wtyp()==wtyp  &&
       (test->gib_styp()==system_type  ||  system_type==weg_t::type_all)  ||  (test->gib_wtyp()==track_wt  &&  test->gib_styp()==weg_t::type_tram  &&  wtyp==tram_wt))
       &&  test->gib_cursor()->gib_bild_nr(1)!=IMG_LEER  ) {
+#if 0
  if(  best==NULL  ||  time==0  ||  (test->get_intro_year_month()<=time  &&  time<test->get_retire_year_month())) {
  if(  best==NULL  ||
  (test->gib_topspeed() <=  speed_limit  &&  best->gib_topspeed() < test->gib_topspeed()) ||
@@ -133,6 +134,15 @@
  best = test;
  }
  }
+#endif
+ if(  best==NULL ||
+ (test->gib_topspeed() <= speed_limit  &&  best->gib_topspeed() < test->gib_topspeed()) ||
+ (test->gib_topspeed() >= speed_limit  &&  test->gib_wartung()  < best->gib_wartung())) {
+ if(  time==0  ||  (test->get_intro_year_month()<=time  &&  time<test->get_retire_year_month())) {
+ best = test;
+ }
+ }
+
  }
  }
  return best;

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: r1943 - weg_search still has problem
« Reply #1 on: August 09, 2008, 08:07:01 PM »
Timeline check must be first. Otherwise city road may not be found, even if timeline is disabled.

Because it should never return a way faster than the requested speed. Therefore the faster is replaced if the the new one is cheaper (which means slower in most sets). However, doing it implicitely seems more reasonable.

And the timeline test must be first, otherwise a cheaper future way is overlaid the desired ones. I changed the section in question and added comments.

But again, if you disagree, I am open to discussion.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: r1943 - weg_search still has problem
« Reply #2 on: August 12, 2008, 07:42:21 PM »
Timeline check must be first.

I agree that. That *is* the problem.

In old code, if there are no suitable way, it returns NULL.
The return value is used in AI code and in other places.

But in your code, first found way is always selected without checking timeline, and never return NULL.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
Re: r1943 - weg_search still has problem
« Reply #3 on: August 12, 2008, 07:45:18 PM »
Actually this routine was made to never return zero, since there are places which always need a way. Otherwise towns could not exist.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: r1943 - weg_search still has problem
« Reply #4 on: August 13, 2008, 11:39:39 AM »
The problem that I reported first was solved in r1944. Thank you.

I have no idea how it should be, in the case of cityhall without way or in the case of engine without track. It rarely happens or never happens.
So, there is no reason to continue discussion.  :)