Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2006:
[Freeciv-Dev] (PR#19559) gui-xaw: load_gfxfile fix etal
Home

[Freeciv-Dev] (PR#19559) gui-xaw: load_gfxfile fix etal

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#19559) gui-xaw: load_gfxfile fix etal
From: "Egor Vyscrebentsov" <evyscr@xxxxxxxxx>
Date: Mon, 14 Aug 2006 01:27:23 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=19559 >

Good daytime!

Thanks for new intro! It shows me a bug in gui-xaw load_gfxfile() code.
Fix attached. (S2_1 and trunk are affected.)

Patch also contains small select_random_race() semifix. I can't
understand how it was possible, but 
  int index = myrand(game.control.nation_count);
once returned -1478313908...

-- 
Thanks, evyscr
Index: client/gui-xaw/dialogs.c
===================================================================
--- client/gui-xaw/dialogs.c    (revision 12252)
+++ client/gui-xaw/dialogs.c    (working copy)
@@ -174,7 +174,7 @@
   /* try to find a free nation */
   /* FIXME: this code should be done another way. -ev */
   while (1) {
-    int race_toggle_index = myrand(game.control.nation_count);
+    unsigned int race_toggle_index = myrand(game.control.nation_count);
 
     if (!is_nation_playable(get_nation_by_idx(race_toggle_index))
        || !get_nation_by_idx(race_toggle_index)->is_available
Index: client/gui-xaw/graphics.c
===================================================================
--- client/gui-xaw/graphics.c   (revision 12252)
+++ client/gui-xaw/graphics.c   (working copy)
@@ -101,22 +101,22 @@
 
   /* Main graphic */
 
-  intro_gfx_sprite=load_gfxfile(tileset_main_intro_filename(tileset));
-  tot=intro_gfx_sprite->width;
+  intro_gfx_sprite = load_gfxfile(tileset_main_intro_filename(tileset));
+  tot = intro_gfx_sprite->width;
 
-  y=intro_gfx_sprite->height-(2*lin);
+  y = intro_gfx_sprite->height - (2 * lin);
 
   w = XmbTextEscapement(main_font_set, motto, strlen(motto));
   XSetForeground(display, font_gc, face.pixel);
   XmbDrawString(display, intro_gfx_sprite->pixmap,
-             main_font_set, font_gc, 
-             tot/2-w/2, y, 
-             motto, strlen(motto));
+               main_font_set, font_gc,
+               tot / 2 - w / 2, y,
+               motto, strlen(motto));
 
   /* Minimap graphic */
 
-  radar_gfx_sprite=load_gfxfile(tileset_mini_intro_filename(tileset));
-  tot=radar_gfx_sprite->width;
+  radar_gfx_sprite = load_gfxfile(tileset_mini_intro_filename(tileset));
+  tot = radar_gfx_sprite->width;
 
   y = radar_gfx_sprite->height - (lin +
       1.5 * (exts->max_logical_extent.height + exts->max_logical_extent.y));
@@ -125,17 +125,17 @@
   XSetForeground(display, font_gc,
                 get_color(tileset, COLOR_OVERVIEW_UNKNOWN)->color.pixel);
   XmbDrawString(display, radar_gfx_sprite->pixmap,
-             main_font_set, font_gc, 
-             (tot/2-w/2)+1, y+1, 
-             word_version(), strlen(word_version()));
+               main_font_set, font_gc,
+               (tot / 2 - w / 2) + 1, y + 1,
+               word_version(), strlen(word_version()));
   XSetForeground(display, font_gc,
                 get_color(tileset, COLOR_OVERVIEW_VIEWRECT)->color.pixel);
   XmbDrawString(display, radar_gfx_sprite->pixmap,
-             main_font_set, font_gc, 
-             tot/2-w/2, y, 
-             word_version(), strlen(word_version()));
+               main_font_set, font_gc,
+               tot / 2 - w / 2, y,
+               word_version(), strlen(word_version()));
 
-  y+=lin;
+  y += lin;
 
   my_snprintf(s, sizeof(s), "%d.%d.%d%s",
              MAJOR_VERSION, MINOR_VERSION,
@@ -144,18 +144,19 @@
   XSetForeground(display, font_gc,
                 get_color(tileset, COLOR_OVERVIEW_UNKNOWN)->color.pixel);
   XmbDrawString(display, radar_gfx_sprite->pixmap,
-             main_font_set, font_gc, 
-             (tot/2-w/2)+1, y+1, s, strlen(s));
+               main_font_set, font_gc,
+               (tot / 2 - w / 2) + 1, y + 1, s, strlen(s));
   XSetForeground(display, font_gc,
                 get_color(tileset, COLOR_OVERVIEW_VIEWRECT)->color.pixel);
   XmbDrawString(display, radar_gfx_sprite->pixmap,
-             main_font_set, font_gc, 
-             tot/2-w/2, y, s, strlen(s));
+               main_font_set, font_gc,
+               tot / 2 - w / 2, y, s, strlen(s));
 
   /* free colors */
 
-  if (have_face)
+  if (have_face) {
     XFreeColors(display, cmap, &(face.pixel), 1, 0);
+  }
 
   /* done */
 
@@ -473,8 +474,15 @@
       if (pcolorarray) {
        XPutPixel(xi, x, y, pcolorarray[pb[x]]);
       } else {
-       XPutPixel(xi, x, y,
-                 (pb[4 * x] << 16) + (pb[4 * x + 1] << 8) + pb[4 * x + 2]);
+       if (has_mask) {
+         XPutPixel(xi, x, y,
+                   (pb[4 * x] << 16) + (pb[4 * x + 1] << 8)
+                   + pb[4 * x + 2]);
+       } else {
+         XPutPixel(xi, x, y,
+                   (pb[3 * x] << 16) + (pb[3 * x + 1] << 8)
+                   + pb[3 * x + 2]);
+       }
       }
     }
     pb += stride;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#19559) gui-xaw: load_gfxfile fix etal, Egor Vyscrebentsov <=