The International Simutrans Forum

 

Author Topic: r1943 - Water level of ppm preview on new map window is one level high  (Read 3514 times)

0 Members and 1 Guest are viewing this topic.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
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.

Code: [Select]
Index: gui/welt.cc
===================================================================
--- gui/welt.cc (r1943)
+++ gui/welt.cc (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;

« Last Edit: August 21, 2008, 10:13:43 AM by z9999 »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10638
  • Languages: De,EN,JP
Re: r1943 - Water level of ppm preview on new map window is one level high
« Reply #1 on: August 09, 2008, 08:13:28 PM »
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.

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: r1943 - Water level of ppm preview on new map window is one level high
« Reply #2 on: August 12, 2008, 04:43:29 PM »
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.
« Last Edit: August 12, 2008, 04:46:28 PM by z9999 »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10638
  • Languages: De,EN,JP
Re: r1943 - Water level of ppm preview on new map window is one level high
« Reply #3 on: August 12, 2008, 06:49:48 PM »
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).