News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

Cleanup in route, wegbauer

Started by gerw, June 12, 2009, 06:40:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gerw

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

prissi

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.

gerw

Quote from: 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.
Do you mean route_t::rdwr? I don't know, what there should be changed.

QuoteI 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:
@@ -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;
                }

prissi

Would load old routes get routes one tile too long?

gerw

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

prissi

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.

gerw

Quote from: 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?
This is just the old behaviour. It's rather a philosophical question, wether a route with 1 tile is empty or not :)


QuoteAlso 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.

prissi

I am probably too critic; but when doing something for principe it should be as good as what was there before. Take you time.

gerw

Quote from: 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?
This is indeed needed in the code. Especially in vehikel_t::neue_fahrt (called by convoi_t::vorfahren).

QuoteAlso 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