changeset 2074:4a08463c4d5f

Rename LocMarker::{x,y} to {xc,yc}.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 21 Aug 2019 13:51:37 +0300
parents 108499a64178
children c065c2c2b86e
files liblocfile.c liblocfile.h mapsearch.c mkcitymap.c mkloc.c
diffstat 5 files changed, 67 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/liblocfile.c	Wed Aug 21 13:45:03 2019 +0300
+++ b/liblocfile.c	Wed Aug 21 13:51:37 2019 +0300
@@ -76,7 +76,7 @@
 }
 
 
-BOOL locAddNew(MapLocations *l, int x, int y, int dir, int flags,
+BOOL locAddNew(MapLocations *l, int xc, int yc, int dir, int flags,
     LocName *names, LocName *coders, LocDateStruct *added, BOOL valid,
     const char *uri, const char *freeform, LocFileInfo *file)
 {
@@ -87,8 +87,8 @@
     if ((tmp = th_malloc0(sizeof(LocMarker))) == NULL)
         return FALSE;
 
-    tmp->x = tmp->ox = x;
-    tmp->y = tmp->oy = y;
+    tmp->xc = tmp->ox = xc;
+    tmp->yc = tmp->oy = yc;
     tmp->align = dir;
     tmp->flags = flags;
     tmp->file = file;
@@ -130,19 +130,19 @@
 }
 
 
-int locFindByCoords(const MapLocations *l, const int x, const int y, const BOOL locTrue)
+int locFindByCoords(const MapLocations *l, const int xc, const int yc, const BOOL locTrue)
 {
     for (int i = 0; i < l->nlocations; i++)
     {
         LocMarker *tmp = l->locations[i];
         if (locTrue)
         {
-            if (tmp->ox == x && tmp->oy == y)
+            if (tmp->ox == xc && tmp->oy == yc)
                 return i;
         }
         else
         {
-            if (tmp->x == x && tmp->y == y)
+            if (tmp->xc == xc && tmp->yc == yc)
                 return i;
         }
     }
@@ -453,7 +453,7 @@
     switch (ctx->field)
     {
     case 1:            // X-coordinate
-        res = parseFieldInt(ctx, &marker->x);
+        res = parseFieldInt(ctx, &marker->xc);
         ctx->fieldSep = ";";
         if (res)
         {
@@ -465,7 +465,7 @@
         break;
 
     case 2:            // Y-coordinate
-        res = parseFieldInt(ctx, &marker->y);
+        res = parseFieldInt(ctx, &marker->yc);
         if (res)
         {
             ctx->field++;
@@ -526,28 +526,28 @@
         tmpStr = parseFieldString(ctx, "\r\n");
 
         // Check coordinates
-        if (marker->x < 1 || marker->y < 1)
+        if (marker->xc < 1 || marker->yc < 1)
         {
             locPMErr(ctx, "Invalid X or Y coordinate (%d, %d), for location '%s'. Must be > 0.\n",
-                marker->x, marker->y, marker->names[0].name);
+                marker->xc, marker->yc, marker->names[0].name);
         }
 
         // Check if location already exists
-        marker->x = marker->x + marker->ox - 1;
-        marker->y = marker->y + marker->oy - 1;
+        marker->xc = marker->xc + marker->ox - 1;
+        marker->yc = marker->yc + marker->oy - 1;
 
-        i = locFindByCoords(l, marker->x, marker->y, TRUE);
+        i = locFindByCoords(l, marker->xc, marker->yc, TRUE);
         if (i >= 0)
         {
             LocMarker *tloc = l->locations[i];
             locPMErr(ctx, "Warning, location already in list! (%d,%d) '%s' <-> (%d,%d) '%s'\n",
-                tloc->x + 1, tloc->y + 1, tloc->names[0].name,
-                marker->x + 1, marker->y + 1, marker->names[0].name);
+                tloc->xc + 1, tloc->yc + 1, tloc->names[0].name,
+                marker->xc + 1, marker->yc + 1, marker->names[0].name);
         }
         else
         {
             // Add new location to our list
-            locAddNew(l, marker->x, marker->y, marker->align, marker->flags,
+            locAddNew(l, marker->xc, marker->yc, marker->align, marker->flags,
                       marker->names, marker->coders, &marker->added,
                       marker->valid, marker->uri, tmpStr, ctx->file);
             locPMSet(ctx, PM_IDLE, -1);
--- a/liblocfile.h	Wed Aug 21 13:45:03 2019 +0300
+++ b/liblocfile.h	Wed Aug 21 13:51:37 2019 +0300
@@ -111,7 +111,7 @@
 {
     LocFileInfo *file;   // Reference to file/continent data
 
-    int x, y, ox, oy;    // Location coordinates
+    int xc, yc, ox, oy;  // Location coordinates
     int align;           // Label alignment value
     int flags;           // Flags (see LOCF_*)
 
@@ -136,7 +136,7 @@
 
 /* Location file parsing and data handling
  */
-BOOL   locAddNew(MapLocations *l, int x, int y, int dir, int flags,
+BOOL   locAddNew(MapLocations *l, int xc, int yc, int dir, int flags,
          LocName *names, LocName *coders, LocDateStruct *added, BOOL valid,
          const char *uri, const char *freeform, LocFileInfo *file);
 
--- a/mapsearch.c	Wed Aug 21 13:45:03 2019 +0300
+++ b/mapsearch.c	Wed Aug 21 13:51:37 2019 +0300
@@ -1219,10 +1219,10 @@
                 match->marker = marker;
                 match->nname = nname;
                 match->map = info->locFile.continent;
-                match->mx = marker->x + 1;
-                match->my = marker->y + 1;
-                match->wx = optWorldXC + info->locFile.xoffs + marker->x;
-                match->wy = optWorldYC + info->locFile.yoffs + marker->y;
+                match->mx = marker->xc + 1;
+                match->my = marker->yc + 1;
+                match->wx = optWorldXC + info->locFile.xoffs + marker->xc;
+                match->wy = optWorldYC + info->locFile.yoffs + marker->yc;
 
                 // Check for max matches
                 if (nmatches >= SET_MAX_MATCHES)
--- a/mkcitymap.c	Wed Aug 21 13:45:03 2019 +0300
+++ b/mkcitymap.c	Wed Aug 21 13:51:37 2019 +0300
@@ -119,17 +119,19 @@
 
         fprintf(outFile,
         "<a class=\"loc\" id=\"listloc%d_%d\" href=\"?%d_%d\" onmouseover=\"qh('%d_%d')",
-        tmp->x, tmp->y,
-        tmp->x, tmp->y,
-        tmp->x, tmp->y);
+        tmp->xc, tmp->yc,
+        tmp->xc, tmp->yc,
+        tmp->xc, tmp->yc);
 
         if (tmp->freeform)
         {
-            fprintf(outFile, ";stt('%d_%d');", tmp->x, tmp->y);
+            fprintf(outFile, ";stt('%d_%d');",
+                tmp->xc, tmp->yc);
         }
 
         fprintf(outFile, "\" "
-        "onmouseout=\"qn('%d_%d');\">", tmp->x, tmp->y);
+            "onmouseout=\"qn('%d_%d');\">",
+            tmp->xc, tmp->yc);
 
         if (tmp->names[0].name != NULL)
         {
@@ -309,7 +311,7 @@
         fprintf(outFile,
         "<div class=\"tooltip\" name=\"tooltip\" id=\"tt%d_%d\">"
         "<div class=\"holder\">",
-        tmp->x, tmp->y);
+        tmp->xc, tmp->yc);
 
         if (tmp->names[0].name != NULL)
         {
@@ -364,9 +366,9 @@
                     "class=\"loc\" id=\"maploc%d_%d\" "
                     "href=\"?%d_%d\">%c</span></a></span>",
                     'a' + col_light_red,
-                    tmp->x, tmp->y,
-                    tmp->x, tmp->y,
-                    tmp->x, tmp->y, *d);
+                    tmp->xc, tmp->yc,
+                    tmp->xc, tmp->yc,
+                    tmp->xc, tmp->yc, *d);
                 }
                 span = FALSE;
                 p = -1;
--- a/mkloc.c	Wed Aug 21 13:45:03 2019 +0300
+++ b/mkloc.c	Wed Aug 21 13:51:37 2019 +0300
@@ -275,7 +275,7 @@
 {
     for (int i = 0; i < l->nlocations; i++)
     {
-        int y, x0, x1, len;
+        int yc, x0, x1, len;
         LocMarker *tmp = l->locations[i];
 
         len = strlen(tmp->names[0].name);
@@ -286,24 +286,24 @@
         switch (tmp->align)
         {
         case LOCD_LEFTDOWN:
-            y = tmp->y + 1;
-            x0 = tmp->x - len;
+            yc = tmp->yc + 1;
+            x0 = tmp->xc - len;
             break;
 
         case LOCD_LEFT:
-            y = tmp->y - 1;
-            x0 = tmp->x - len;
+            yc = tmp->yc - 1;
+            x0 = tmp->xc - len;
             break;
 
         case LOCD_DOWN:
-            y = tmp->y + 1;
-            x0 = tmp->x + 1;
+            yc = tmp->yc + 1;
+            x0 = tmp->xc + 1;
             break;
 
         case LOCD_NONE:
         default:
-            y = tmp->y - 1;
-            x0 = tmp->x + 1;
+            yc = tmp->yc - 1;
+            x0 = tmp->xc + 1;
             break;
         }
 
@@ -311,14 +311,17 @@
 
         if (x1 > map->width)
             x0 -= (x1 - map->width - 1);
-        if (x0 < 0) x0 = 0;
+        if (x0 < 0)
+            x0 = 0;
 
-        if (y < 0) y += 2;
-        if (y > map->height) y -= (y - map->height - 1);
+        if (yc < 0)
+            yc += 2;
+        if (yc > map->height)
+            yc -= (yc - map->height - 1);
 
         // Update location info
-        tmp->x = x0;
-        tmp->y = y;
+        tmp->xc = x0;
+        tmp->yc = yc;
     }
 }
 
@@ -747,7 +750,7 @@
     for (int i = 0; i < l->nlocations; i++)
     {
         LocMarker *tmp = l->locations[i];
-        int x, y, leftMove;
+        int xc, yc, leftMove;
         char *cs;
 
         // Is location visible?
@@ -759,24 +762,24 @@
         switch (tmp->align)
         {
         case LOCD_LEFTDOWN:
-            y = tmp->y + optUnitSize*3.0f;
-            x = tmp->x - leftMove;
+            yc = tmp->yc + optUnitSize*3.0f;
+            xc = tmp->xc - leftMove;
             break;
 
         case LOCD_LEFT:
-            y = tmp->y - optUnitSize;
-            x = tmp->x - leftMove;
+            yc = tmp->yc - optUnitSize;
+            xc = tmp->xc - leftMove;
             break;
 
         case LOCD_DOWN:
-            y = tmp->y + optUnitSize*3.0f;
-            x = tmp->x + optUnitSize;
+            yc = tmp->yc + optUnitSize*3.0f;
+            xc = tmp->xc + optUnitSize;
             break;
 
         case LOCD_NONE:
         default:
-            y = tmp->y - optUnitSize;
-            x = tmp->x + optUnitSize;
+            yc = tmp->yc - optUnitSize;
+            xc = tmp->xc + optUnitSize;
             break;
         }
 
@@ -813,14 +816,14 @@
         // Location marker
         fprintf(outFile,
             "\t-fill black -draw \"circle %d,%d %d,%d\" ",
-            tmp->x, tmp->y,
-            (int) (tmp->x + optUnitSize), (int) (tmp->y + optUnitSize));
+            tmp->xc, tmp->yc,
+            (int) (tmp->xc + optUnitSize), (int) (tmp->yc + optUnitSize));
 
         fprintf(outFile,
             "-fill %s -draw \"circle %d,%d %d,%d\" ",
-            cs, tmp->x, tmp->y,
-            (int) (tmp->x + optUnitSize * 0.90f),
-            (int) (tmp->y + optUnitSize * 0.90f));
+            cs, tmp->xc, tmp->yc,
+            (int) (tmp->xc + optUnitSize * 0.90f),
+            (int) (tmp->yc + optUnitSize * 0.90f));
 
 
         // Location description text
@@ -828,7 +831,7 @@
         {
             fprintf(outFile,
                 "-fill %s -box '#00000080' -draw \"text %d,%d '",
-                cs, x, y);
+                cs, xc, yc);
 
             fputsesc3(tmp->names[0].name, outFile);
             fprintf(outFile, "'\" ");
@@ -1171,8 +1174,8 @@
         {
             LocMarker *tmp = worldLoc.locations[i];
 
-            tmp->x = ((float) tmp->x) * optScale;
-            tmp->y = ((float) tmp->y) * optScale;
+            tmp->xc = ((float) tmp->xc) * optScale;
+            tmp->yc = ((float) tmp->yc) * optScale;
         }
     }