The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: knightly on April 19, 2009, 01:14:21 am

Title: get_max_speed() in grund_t
Post by: knightly on April 19, 2009, 01:14:21 am
I am not sure if it is a bug -- please pardon me if I am wrong.

In the following code, min() in the body of the 2nd if seems to be comparing the same value, as obj_bei() is called with argument 0 in both bodies of if  :

Code: [Select]
int grund_t::get_max_speed() const
{
int max = 0;
if(flags&has_way1) {
max = ((weg_t *)obj_bei(0))->get_max_speed();
}
if(flags&has_way2) {
max = min( max, ((weg_t *)obj_bei(0))->get_max_speed() );
}
return max;
}

Thank you for your attention.
Title: Re: get_max_speed() in grund_t
Post by: Dwachs on April 19, 2009, 02:33:46 pm
imho there should be obj_bei(1), as the ways on one tile are hard-coded at indices 0 and 1.

How did you come across this?
Title: Re: get_max_speed() in grund_t
Post by: knightly on April 19, 2009, 03:09:06 pm
Sorry, forgot to mention that I discovered this with R2431.

I came across this when I read Simutrans code out of interest. :)
Title: Re: get_max_speed() in grund_t
Post by: Dwachs on April 19, 2009, 03:32:54 pm
I came across this when I read Simutrans code out of interest. :)


Please read more ;)

This bug was not critical, the routine is only used in the gui (map).

Thanks for reporting, should be fixed now.