Skip to main content
Topic: r1943 - weg_search still has problem (Read 5824 times) previous topic - next topic

r1943 - weg_search still has problem

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;

Re: r1943 - weg_search still has problem

Reply #1
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.

Re: r1943 - weg_search still has problem

Reply #2

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.

Re: r1943 - weg_search still has problem

Reply #3
Actually this routine was made to never return zero, since there are places which always need a way. Otherwise towns could not exist.

 

Re: r1943 - weg_search still has problem

Reply #4
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.  :)