]> granicus.if.org Git - nethack/commitdiff
Line numbering in lev_comp files
authorkmhugo <kmhugo>
Sat, 19 Jan 2002 06:06:16 +0000 (06:06 +0000)
committerkmhugo <kmhugo>
Sat, 19 Jan 2002 06:06:16 +0000 (06:06 +0000)
This patch allows the digits 0-9 to be used to indicate line numbers
in the MAP...ENDMAP arrays of level files.  This makes it a wee
bit easier to place features.  The digits get stripped out before
the map is interpreted.

util/lev_comp.l
util/lev_main.c

index 9cbf927fff0eb7df03b81abbe136ec9452b3173c..ea56256ba62ae733fcc09117a0576453050f29ec 100644 (file)
@@ -88,7 +88,7 @@ static int map_cnt = 0;
                  map_cnt = 0;
                  return MAP_ID;
                }
-<MAPC>[-|}{+ABCISHKPLWTF\\#. ]*\n      {
+<MAPC>[-|}{+ABCISHKPLWTF\\#. 0123456789]*\n    {
                  line_number++;
                  (void) strncpy(map + map_cnt, yytext, yyleng);
                  map_cnt += yyleng;
index bf9aae25da6f64fbb9a0eb7af9f7692ae762a5bc..440d93c0a0e1020722c5b5504eaebb4c2af71c5b 100644 (file)
@@ -516,8 +516,13 @@ char *map;
        int max_hig = 0;
        char msg[256];
 
-       /* First : find the max width of the map */
+       /* First, strip out digits 0-9 (line numbering) */
+       for (s1 = s2 = map; *s1; s1++)
+           if (*s1 < '0' || *s1 > '9')
+               *s2++ = *s1;
+       *s2 = '\0';
 
+       /* Second, find the max width of the map */
        s1 = map;
        while (s1 && *s1) {
                s2 = index(s1, NEWLINE);
@@ -532,7 +537,6 @@ char *map;
        }
 
        /* Then parse it now */
-
        while (map && *map) {
                tmpmap[max_hig] = (char *) alloc(max_len);
                s1 = index(map, NEWLINE);