News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

r1943 - weg_search still has problem

Started by z9999, August 09, 2008, 12:50:21 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

z9999

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.


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;


prissi

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.

z9999

Quote from: prissi on August 09, 2008, 08:07:01 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.

prissi

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

z9999

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.  :)