]> granicus.if.org Git - nethack/commitdiff
NO_TILE_C => no USE_TILES in tile.c
authorPatR <rankin@nethack.org>
Fri, 31 Dec 2021 21:49:43 +0000 (13:49 -0800)
committerPatR <rankin@nethack.org>
Fri, 31 Dec 2021 21:49:43 +0000 (13:49 -0800)
Compiling with NO_TILE_C defined results in preventing USE_TILES
from being defined and that causes display.c to use alternate code.
Construct src/tile.c such that nethack links successfully if the
configuration specifies NO_TILE_C but the Makefile goes ahead and
builds tile.c, compiles it, and links with it, otherwise it conflicts
with that alternate code.  Prior to this, linking gave two complaints
about duplicate symbols and failed.

win/share/tilemap.c

index 66a862545119388e583f0a07e1e893a0ca14af06..5b64602729cd36eb348a44761bdecb93628d56fd 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 tilemap.c       $NHDT-Date: 1639622363 2021/12/16 02:39:23 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.63 $ */
+/* NetHack 3.7 tilemap.c       $NHDT-Date: 1640987372 2021/12/31 21:49:32 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.64 $ */
 /*      Copyright (c) 2016 by Michael Allison                     */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -95,11 +95,15 @@ const char *expl_texts[] = {
     "dark", "noxious", "muddy", "wet", "magical", "fiery", "frosty",
 };
 
-const char *zap_texts[] = { "missile", "fire",      "frost",      "sleep",
-                            "death",   "lightning", "poison gas", "acid" };
+const char *zap_texts[] = {
+    "missile", "fire",      "frost",      "sleep",
+    "death",   "lightning", "poison gas", "acid",
+};
 
-enum tilesrc {monsters_file, objects_file, other_file, generated};
-const char *tilesrc_texts[] = { "monsters.txt", "objects.txt", "other.txt", "generated" };
+enum tilesrc { monsters_file, objects_file, other_file, generated };
+const char *tilesrc_texts[] = {
+    "monsters.txt", "objects.txt", "other.txt", "generated",
+};
 
 struct tilemap_t {
     short tilenum;
@@ -1265,7 +1269,7 @@ init_tilemap(void)
     }
     /* go beyond NUMMONS to cover off the invisible tile at the
        end of monsters.txt so that the tile mapping matches things
-       the .bmp file (for example) */
+       in the .bmp file (for example) */
     file_entry = 0;
 #if defined(OBTAIN_TILEMAP)
     add_tileref(tilenum, NO_GLYPH, monsters_file, file_entry,
@@ -1276,8 +1280,8 @@ init_tilemap(void)
 
 #if defined(OBTAIN_TILEMAP)
     for (i = 0; i < MAX_GLYPH; ++i) {
-        Fprintf(tilemap_file, "glyph[%04d] [%04d] %-80s\n", i, tilemap[i].tilenum,
-                tilemap[i].name);
+        Fprintf(tilemap_file, "glyph[%04d] [%04d] %-80s\n",
+                i, tilemap[i].tilenum, tilemap[i].name);
     }
     dump_tilerefs(tilemap_file);
     fclose(tilemap_file);
@@ -1317,17 +1321,20 @@ main(int argc UNUSED, char *argv[] UNUSED)
     Fprintf(ofp,
             "/* This file is automatically generated.  Do not edit. */\n");
     Fprintf(ofp, "\n#include \"hack.h\"\n");
+    Fprintf(ofp, "\n#ifdef USE_TILES\n");
     Fprintf(ofp, "\nint total_tiles_used = %d,\n", laststatuetile + 1);
     Fprintf(ofp, "%sTile_corr = %d,\n", indent, TILE_corr);       /* X11 references it */
     Fprintf(ofp, "%sTile_stone = %d,\n",  indent, TILE_stone);
     Fprintf(ofp, "%sTile_unexplored = %d;\n\n",  indent, TILE_unexplored);
-    Fprintf(ofp, "/* glyph, ttychar, { color, symidx, ovidx, glyphflags, tileidx} */\n");
+    Fprintf(ofp,
+      "/* glyph, ttychar, { color, symidx, ovidx, glyphflags, tileidx} */\n");
     Fprintf(ofp, "const glyph_info nul_glyphinfo = { \n");
     Fprintf(ofp, "%sNO_GLYPH, ' ',\n", indent);
     Fprintf(ofp, "%s%s{  /* glyph_map */\n", indent, indent);
     Fprintf(ofp, "%s%s%sNO_COLOR, SYM_UNEXPLORED + SYM_OFF_X,\n",
-                 indent, indent, indent);
-    Fprintf(ofp, "%s%s%sMG_UNEXPL, %d\n", indent, indent, indent, TILE_unexplored);
+            indent, indent, indent);
+    Fprintf(ofp, "%s%s%sMG_UNEXPL, %d\n", indent, indent, indent,
+            TILE_unexplored);
     Fprintf(ofp, "%s%s}\n", indent, indent);
     Fprintf(ofp, "};\n");
     Fprintf(ofp, "\nglyph_map glyphmap[MAX_GLYPH] = {\n");
@@ -1341,6 +1348,7 @@ main(int argc UNUSED, char *argv[] UNUSED)
                 tilemap[i].name);
     }
     Fprintf(ofp, "};\n");
+    Fprintf(ofp, "\n#endif /* USE_TILES */\n");
     Fprintf(ofp, "\n/*tile.c*/\n");
 
     (void) fclose(ofp);