OSDN Git Service

[Fix] 属性への免疫を唱えた時のメッセージ
[hengbandforosx/hengbandosx.git] / src / maid-x11.cpp
index 99dce2e..5ffbdce 100644 (file)
@@ -1,4 +1,4 @@
-/* File: maid-x11.c */
+/* File: maid-x11.c */
 
 /*
  * Copyright (c) 1997 Ben Harrison, and others
@@ -10,7 +10,7 @@
 
 #ifdef USE_X11
 
-#include "main/x11-gamma-builder.h"
+#include "main-unix/x11-gamma-builder.h"
 #include <math.h>
 
 /*
@@ -73,14 +73,16 @@ static unsigned long create_pixel(Display *dpy, byte red, byte green, byte blue)
     XColor xcolour;
     if (!gamma_table_ready) {
         concptr str = getenv("ANGBAND_X11_GAMMA");
-        if (str != nullptr)
+        if (str != nullptr) {
             gamma_val = atoi(str);
+        }
 
         gamma_table_ready = true;
 
         /* Only need to build the table if gamma exists */
-        if (gamma_val)
+        if (gamma_val) {
             build_gamma_table(gamma_val);
+        }
     }
 
     /* Hack -- Gamma Correction */
@@ -272,12 +274,13 @@ static XImage *ReadBMP(Display *dpy, char *Name)
     /* Determine total bytes needed for image */
     i = 1;
     j = (depth - 1) >> 2;
-    while (j >>= 1)
+    while (j >>= 1) {
         i <<= 1;
+    }
     total = infoheader.biWidth * infoheader.biHeight * i;
 
     /* Allocate image memory */
-    Data = (char*)malloc(total);
+    Data = (char *)malloc(total);
 
     Res = XCreateImage(dpy, visual, depth, ZPixmap, 0 /*offset*/, Data, infoheader.biWidth, infoheader.biHeight, 8 /*bitmap_pad*/, 0 /*bytes_per_line*/);
 
@@ -295,16 +298,18 @@ static XImage *ReadBMP(Display *dpy, char *Name)
             int ch = getc(f);
 
             /* Verify not at end of file XXX XXX */
-            if (feof(f))
+            if (feof(f)) {
                 quit_fmt("Unexpected end of file in %s", Name);
+            }
 
             if (infoheader.biBitCount == 24) {
                 int c2 = getc(f);
                 int c3 = getc(f);
 
                 /* Verify not at end of file XXX XXX */
-                if (feof(f))
+                if (feof(f)) {
                     quit_fmt("Unexpected end of file in %s", Name);
+                }
 
                 XPutPixel(Res, x, y2, create_pixel(dpy, ch, c2, c3));
             } else if (infoheader.biBitCount == 8) {
@@ -480,8 +485,7 @@ static void PutRGBScan(XImage *Im, int x, int y, int w, int div, unsigned long *
     unsigned long pix;
     unsigned long adj = div / 2;
     for (xi = 0; xi < w; xi++) {
-        pix = (((((redScan[xi] + adj) / div) & redMask) << redShift) + ((((greenScan[xi] + adj) / div) & greenMask) << greenShift)
-            + ((((blueScan[xi] + adj) / div) & blueMask) << blueShift));
+        pix = (((((redScan[xi] + adj) / div) & redMask) << redShift) + ((((greenScan[xi] + adj) / div) & greenMask) << greenShift) + ((((blueScan[xi] + adj) / div) & blueMask) << blueShift));
         XPutPixel(Im, x + xi, y, pix);
     }
 }
@@ -514,12 +518,13 @@ static void ScaleIcon(XImage *ImIn, XImage *ImOut, int x1, int y1, int x2, int y
     bool getNextRow;
 
     /* get divider value for the horizontal scaling: */
-    if (ix == ox)
+    if (ix == ox) {
         div = 1;
-    else if (ix < ox)
+    } else if (ix < ox) {
         div = ox - 1;
-    else
+    } else {
         div = ix;
+    }
 
     if (iy == oy) {
         /* no scaling needed vertically: */
@@ -685,9 +690,8 @@ static XImage *ResizeImage(Display *dpy, XImage *Im, int ix, int iy, int ox, int
     Visual *visual = DefaultVisual(dpy, DefaultScreen(dpy));
 
     int width1, height1, width2, height2;
-    volatile int x1, x2, y1, y2, Tx, Ty;
-    volatile int *px1, *px2, *dx1, *dx2;
-    volatile int *py1, *py2, *dy1, *dy2;
+    int x1, x2, y1, y2, Tx, Ty;
+    int dx1, dx2, dy1, dy2;
 
     XImage *Tmp;
 
@@ -708,52 +712,60 @@ static XImage *ResizeImage(Display *dpy, XImage *Im, int ix, int iy, int ox, int
     Tmp = XCreateImage(dpy, visual, Im->depth, ZPixmap, 0, Data, width2, height2, 32, 0);
 
     if (ix > ox) {
-        px1 = &x1;
-        px2 = &x2;
-        dx1 = &ix;
-        dx2 = &ox;
+        dx1 = ix;
+        dx2 = ox;
     } else {
-        px1 = &x2;
-        px2 = &x1;
-        dx1 = &ox;
-        dx2 = &ix;
+        dx1 = ox;
+        dx2 = ix;
     }
 
     if (iy > oy) {
-        py1 = &y1;
-        py2 = &y2;
-        dy1 = &iy;
-        dy2 = &oy;
+        dy1 = iy;
+        dy2 = oy;
     } else {
-        py1 = &y2;
-        py2 = &y1;
-        dy1 = &oy;
-        dy2 = &iy;
+        dy1 = oy;
+        dy2 = iy;
     }
 
-    Ty = *dy1 / 2;
+    Ty = dy1 / 2;
 
     for (y1 = 0, y2 = 0; (y1 < height1) && (y2 < height2);) {
-        Tx = *dx1 / 2;
+        Tx = dx1 / 2;
 
         for (x1 = 0, x2 = 0; (x1 < width1) && (x2 < width2);) {
             XPutPixel(Tmp, x2, y2, XGetPixel(Im, x1, y1));
 
-            (*px1)++;
+            if (ix > ox) {
+                ++x1;
+            } else {
+                ++x2;
+            }
 
-            Tx -= *dx2;
+            Tx -= dx2;
             if (Tx < 0) {
-                Tx += *dx1;
-                (*px2)++;
+                Tx += dx1;
+                if (ix > ox) {
+                    ++x2;
+                } else {
+                    ++x1;
+                }
             }
         }
 
-        (*py1)++;
+        if (iy > oy) {
+            ++y1;
+        } else {
+            ++y2;
+        }
 
-        Ty -= *dy2;
+        Ty -= dy2;
         if (Ty < 0) {
-            Ty += *dy1;
-            (*py2)++;
+            Ty += dy1;
+            if (iy > oy) {
+                ++y2;
+            } else {
+                ++y1;
+            }
         }
     }