Skip to main content
Topic: get_max_speed() in grund_t (Read 2629 times) previous topic - next topic

get_max_speed() in grund_t

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.

Re: get_max_speed() in grund_t

Reply #1
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?
Parsley, sage, rosemary, and maggikraut.

Re: get_max_speed() in grund_t

Reply #2
Sorry, forgot to mention that I discovered this with R2431.

I came across this when I read Simutrans code out of interest. :)

Re: get_max_speed() in grund_t

Reply #3
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.
Parsley, sage, rosemary, and maggikraut.