]> granicus.if.org Git - nethack/commitdiff
merging conflict fixup
authornhmall <nhmall@nethack.org>
Mon, 5 Oct 2020 00:07:57 +0000 (20:07 -0400)
committernhmall <nhmall@nethack.org>
Mon, 5 Oct 2020 00:07:57 +0000 (20:07 -0400)
include/global.h
src/rip.c

index 4581137ef4c98ed6ff414f9c136befc94f7739e3..caa32847b59f7bcb90acebcfe57f895a97bd92be 100644 (file)
@@ -331,15 +331,8 @@ struct version_info {
     unsigned long incarnation;   /* actual version number */
     unsigned long feature_set;   /* bitmask of config settings */
     unsigned long entity_count;  /* # of monsters and objects */
-#ifndef __EMSCRIPTEN__
     unsigned long struct_sizes1; /* size of key structs */
     unsigned long struct_sizes2; /* size of more key structs */
-#else /* __EMSCRIPTEN__ */
-    /* 'long' in WASM is 4 bytes, which is too small to hold version numbers
-     * such as: VERSION_SANITY2 */
-    unsigned long long struct_sizes1; /* size of key structs */
-    unsigned long long struct_sizes2; /* size of more key structs */
-#endif /* !__EMSCRIPTEN__ */
 };
 
 struct savefile_info {
@@ -403,7 +396,7 @@ struct savefile_info {
 
 /* PANICTRACE: Always defined for NH_DEVEL_STATUS != NH_STATUS_RELEASED
    but only for supported platforms. */
-#if defined(UNIX) && !defined(__EMSCRIPTEN__)
+#ifdef UNIX
 #if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
 /* see end.c */
 #if !defined(CROSS_TO_WASM)
@@ -421,7 +414,7 @@ struct savefile_info {
 #if defined(MACOSX)
 #define PANICTRACE_LIBC
 #endif
-#if defined(UNIX) && !defined(__EMSCRIPTEN__) /* no popen in WASM */
+#ifdef UNIX
 #if !defined(CROSS_TO_WASM) /* no popen in WASM */
 #define PANICTRACE_GDB
 #endif
index c9d518aea06e55c4fdcd82e81b87f74a905feb40..634d816d2feb13d2abae79588c23f87811f55732 100644 (file)
--- a/src/rip.c
+++ b/src/rip.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 rip.c   $NHDT-Date: 1596498204 2020/08/03 23:43:24 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.32 $ */
+/* NetHack 3.7 rip.c   $NHDT-Date: 1597967808 2020/08/20 23:56:48 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.33 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2017. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -61,12 +61,10 @@ static const char *rip_txt[] = {
 };
 #define STONE_LINE_CENT 19 /* char[] element of center of stone face */
 #endif                     /* NH320_DEDICATION */
-#define STONE_LINE_LEN                               \
-    16               /* # chars that fit on one line \
-                      * (note 1 ' ' border)          \
-                      */
-#define NAME_LINE 6  /* *char[] line # for player name */
-#define GOLD_LINE 7  /* *char[] line # for amount of gold */
+#define STONE_LINE_LEN  16 /* # chars that fit on one line
+                            * (note 1 ' ' border)           */
+#define NAME_LINE  6 /* *char[] line # for player name */
+#define GOLD_LINE  7 /* *char[] line # for amount of gold */
 #define DEATH_LINE 8 /* *char[] line # for death description */
 #define YEAR_LINE 12 /* *char[] line # for year */
 
@@ -91,9 +89,9 @@ time_t when;
     register char **dp;
     register char *dpx;
     char buf[BUFSZ];
-    long year;
     register int x;
-    int line;
+    int line, year;
+    long cash;
 
     g.rip = dp = (char **) alloc(sizeof(rip_txt));
     for (x = 0; rip_txt[x]; ++x)
@@ -101,13 +99,15 @@ time_t when;
     dp[x] = (char *) 0;
 
     /* Put name on stone */
-    Sprintf(buf, "%s", g.plname);
-    buf[STONE_LINE_LEN] = 0;
+    Sprintf(buf, "%.*s", (int) STONE_LINE_LEN, g.plname);
     center(NAME_LINE, buf);
 
     /* Put $ on stone */
-    Sprintf(buf, "%ld Au", g.done_money);
-    buf[STONE_LINE_LEN] = 0; /* It could be a *lot* of gold :-) */
+    cash = max(g.done_money, 0L);
+    /* arbitrary upper limit; practical upper limit is quite a bit less */
+    if (cash > 999999999L)
+        cash = 999999999L;
+    Sprintf(buf, "%ld Au", cash);
     center(GOLD_LINE, buf);
 
     /* Put together death description */
@@ -115,11 +115,11 @@ time_t when;
 
     /* Put death type on stone */
     for (line = DEATH_LINE, dpx = buf; line < YEAR_LINE; line++) {
-        register int i, i0;
         char tmpchar;
+        int i, i0 = (int) strlen(dpx);
 
-        if ((i0 = strlen(dpx)) > STONE_LINE_LEN) {
-            for (i = STONE_LINE_LEN; ((i0 > STONE_LINE_LEN) && i); i--)
+        if (i0 > STONE_LINE_LEN) {
+            for (i = STONE_LINE_LEN; (i > 0) && (i0 > STONE_LINE_LEN); --i)
                 if (dpx[i] == ' ')
                     i0 = i;
             if (!i)
@@ -136,8 +136,8 @@ time_t when;
     }
 
     /* Put year on stone */
-    year = yyyymmdd(when) / 10000L;
-    Sprintf(buf, "%4ld", year);
+    year = (int) ((yyyymmdd(when) / 10000L) % 10000L);
+    Sprintf(buf, "%4d", year);
     center(YEAR_LINE, buf);
 
 #ifdef DUMPLOG