Use the "Forum Search"
It may help you to find anything in the forum ;).

r1943 - Water level of ppm preview on new map window is one level high

Started by z9999, August 09, 2008, 12:49:08 PM

Previous topic - Next topic

0 Members and 11 Guests are viewing this topic.


simutrans r1943 GDI

I repoted this before and made a patch.
But this problem is NOT solved yet.
I don't know why you don't like my patches in spite of working well.

Index: gui/
--- gui/ (r1943)
+++ gui/ (copy)
@@ -322,7 +322,7 @@
uint16 B = (uint8)fgetc(file);

while(karte_x<=rest_x  &&  karte_x<preview_size) {
- karte[(karte_y*preview_size)+karte_x] = reliefkarte_t::calc_hoehe_farbe( (((R*2+G*3+B)/4 - 224+16)/16)*Z_TILE_STEP, sets->gib_grundwasser() );
+ karte[(karte_y*preview_size)+karte_x] = reliefkarte_t::calc_hoehe_farbe( (((R*2+G*3+B)/4 - 224+16)>>4)*Z_TILE_STEP, sets->gib_grundwasser() );
karte_x ++;
rest_x += skip_x;


This is a compiler error then. It works fine on my compiler. Furthermore for an unsigned number >> 4 and /16 are identical. Hmm. Ok, can change it, although I do not like hidden divisions in not speed critical sections.

It works even for the main routine ... maybe should be same in both places.


AFAIK, both vc++ and gcc are same at this point.
-5/2 = -2
-5 >> 1 = -3

And my first report is for v100.0 which you made it.
My code is the old simutrans code before you changed it. I dig it.


I apologize. Since the numbers are unsigned, I was assuming that the compiler would make an unsigned shift. And even more, I was so used to /16 equal >>4 that I overlooked your point. (Strangley division by 16 is still used in the main code though).