The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: gerw on June 12, 2009, 06:40:37 pm

Title: Cleanup in route, wegbauer
Post by: gerw on June 12, 2009, 06:40:37 pm
As mentioned in an other thread, I did some cleanup in route_t (removed double end entries, get_max_n -> get_count()) and wegbauer_t (removed max_n, replaced by get_count()).

http://www-user.tu-chemnitz.de/~gerw/patches/cleanup_route_wegbauer.patch (http://www-user.tu-chemnitz.de/~gerw/patches/cleanup_route_wegbauer.patch)
Title: Re: Cleanup in route, wegbauer
Post by: prissi on June 12, 2009, 08:31:49 pm
I am pretty sure the loading routines of route.cc must be touched too as trains are beaming sometimes after loading.

I get also several out of bounds. (For instance in line 2584 and 2655 in simconvoi.cc there is something wrong, needs to be >=.)

Probably needs a little more testing.
Title: Re: Cleanup in route, wegbauer
Post by: gerw on June 12, 2009, 10:19:05 pm
I am pretty sure the loading routines of route.cc must be touched too as trains are beaming sometimes after loading.
Do you mean route_t::rdwr? I don't know, what there should be changed.

Quote
I get also several out of bounds. (For instance in line 2584 and 2655 in simconvoi.cc there is something wrong, needs to be >=.)
I didn't get a "out of bounds". But indeed, these two lines was wrong in my patch. Thank you.
Changed into:
Code: [Select]
@@ -2581,7 +2581,7 @@
 
        while( distance > 0 ) {
 
-               if(  route_index >= route.get_max_n()  ) {
+               if(  route_index >= route.get_count()  ) {
                        return false;
                }
 
@@ -2652,7 +2652,7 @@
        time_overtaking = (time_overtaking << 16)/akt_speed;
        while ( time_overtaking > 0 ) {
 
-               if ( route_index >= route.get_max_n() ) {
+               if ( route_index >= route.get_count() ) {
                        return false;
                }
Title: Re: Cleanup in route, wegbauer
Post by: prissi on June 12, 2009, 10:22:32 pm
Would load old routes get routes one tile too long?
Title: Re: Cleanup in route, wegbauer
Post by: gerw on June 13, 2009, 07:26:36 am
In old routes the last tile is doubled, but this shouldn't matter, does it?

Edit: Patch at website updated (according last post from me).
Title: Re: Cleanup in route, wegbauer
Post by: prissi on June 17, 2009, 07:28:10 pm
Ther seems to be some inconsistencies, like route.is_empty will return true for 1 tile routes. Or did I missed something?

Also in many place there is bla<route->get_count()-1 added; but when get_count==0 the result will be must surely not the expected ones, i.e. it may do the wrong stuff with non found routes.
Title: Re: Cleanup in route, wegbauer
Post by: gerw on June 17, 2009, 08:56:42 pm
Ther seems to be some inconsistencies, like route.is_empty will return true for 1 tile routes. Or did I missed something?
This is just the old behaviour. It's rather a philosophical question, wether a route with 1 tile is empty or not :)


Quote
Also in many place there is bla<route->get_count()-1 added; but when get_count==0 the result will be must surely not the expected ones, i.e. it may do the wrong stuff with non found routes.
I will fix this with some higher algebra in the next days.
Title: Re: Cleanup in route, wegbauer
Post by: prissi on June 17, 2009, 09:04:59 pm
I am probably too critic; but when doing something for principe it should be as good as what was there before. Take you time.
Title: Re: Cleanup in route, wegbauer
Post by: gerw on June 18, 2009, 09:12:32 pm
Ther seems to be some inconsistencies, like route.is_empty will return true for 1 tile routes. Or did I missed something?
This is indeed needed in the code. Especially in vehikel_t::neue_fahrt (called by convoi_t::vorfahren).

Quote
Also in many place there is bla<route->get_count()-1 added; but when get_count==0 the result will be must surely not the expected ones, i.e. it may do the wrong stuff with non found routes.
This is now corrected. Thank you.
tu-chemnitz.de/~gerw/patches/cleanup_route_wegbauer_2.patch (http://tu-chemnitz.de/~gerw/patches/cleanup_route_wegbauer_2.patch)
Title: Re: Cleanup in route, wegbauer
Post by: gerw on October 11, 2009, 09:13:28 pm
In trunk.