The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: isidoro on October 16, 2013, 11:32:10 PM

Title: r6819:linux:minibug in display/viewport.cc
Post by: isidoro on October 16, 2013, 11:32:10 PM
The floor function in display/viewport.cc requires to
#include <cmath>
to compile.
Title: Re: r6819:linux:minibug in display/viewport.cc
Post by: Ters on October 17, 2013, 04:41:20 AM
Or rather math.h, which is more in the style of the other includes.
Title: Re: r6819:linux:minibug in display/viewport.cc
Post by: kierongreen on October 17, 2013, 09:15:25 AM
Fixed in 6820 (along with some accidental climate code which will be tidied up shortly...)
Title: Re: r6819:linux:minibug in display/viewport.cc
Post by: Dwachs on October 17, 2013, 09:20:11 AM
Is this piece of code

found_i = ((int)floor(base_i/(double)rw4)) + i_off;

not equivalent to

found_i = base_i / rw4 + i_off;

?? Integer division does the rounding it self.

Or maybe

found_i = (base_i + rw4*i_off) / rw4;


Title: Re: r6819:linux:minibug in display/viewport.cc
Post by: kierongreen on October 17, 2013, 11:05:02 AM
found_i = base_i / rw4 + i_off;
does not give identical values

however
found_i = (base_i + rw4*i_off) / rw4;
does give the same result so I've changed the code to this in 6822 and removed the math.h header include. Actually I've also moved the rw4*i_off to outside the height loop as that should be marginally more efficient...
Title: Re: r6819:linux:minibug in display/viewport.cc
Post by: Markohs on October 17, 2013, 11:47:03 AM
I come back to the forum and you already identified and repaired the bug! oh boy, good! ;) Thx.
Title: Re: r6819:linux:minibug in display/viewport.cc
Post by: isidoro on October 17, 2013, 10:59:32 PM
Thank you all.