From a40f0788bc94f9891f3a5723878c20d2a65d085c Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 21 Jan 2018 16:30:58 -0800 Subject: [PATCH 1/6] fix object pickup Mentioned in the newsgroup: picked up items have stopped merging with compatible stacks in inventory. The commit 0c5155584975731f2c37ace88acd046a54ae5aa6 by me on January 5 | | fix #H6713 - unpaid_cost: object not on any bill | | Stealing a shop object from outside the shop with a grappling hook | would result in that item being left marked 'unpaid' after the shop's | bill was treated as being bought and not yet paid for. This led to | "unpaid_cost: object wasn't on any bill" every time inventory was | examined. The problem was caused by handling the shop robbery after | removing the object from the floor but before adding it to inventory, | so it couldn't be found to have its unpaid bit cleared. | inadvertently caused that. The effect was actually deliberate but it wasn't intended to be so widespread. Handle extract/bill/addinv/rob sequencing differently instead of overriding inventory merging. --- doc/fixes36.1 | 3 +++ src/pickup.c | 29 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index d33e86598..3dfa88bbb 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -568,6 +568,9 @@ try again to fix achievement recording bug with mines and sokoban prizes the fix for secret doors on special levels always having vertical orientation resulted in some--but not all--secret doors within vertical walls being displayed as horizontal walls while still hidden +the fix intended for "a shop object stolen from outside the shop (via + grappling hook) would be left marked as 'unpaid'" broke normal pickup, + preventing any picked up item from merging with compatible stack Platform- and/or Interface-Specific Fixes diff --git a/src/pickup.c b/src/pickup.c index d09bbbfdb..0f53d8cbb 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pickup.c $NHDT-Date: 1515144225 2018/01/05 09:23:45 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.193 $ */ +/* NetHack 3.6 pickup.c $NHDT-Date: 1516581051 2018/01/22 00:30:51 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.194 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1500,17 +1500,16 @@ struct obj *otmp; boolean robshop = (!u.uswallow && otmp != uball && costly_spot(ox, oy)); obj_extract_self(otmp); - otmp->nomerge = 1; - result = addinv(otmp); - otmp->nomerge = 0; newsym(ox, oy); - /* this used to be done before addinv(), but remote_burglary() - calls rob_shop() which calls setpaid() after moving costs of - unpaid items to shop debt; setpaid() calls clear_unpaid() for - lots of object chains, but 'otmp' wasn't on any of those so - remained flagged as an unpaid item in inventory, triggering - impossible() every time inventory was examined... */ + /* for shop items, addinv() needs to be after addtobill() (so that + object merger can take otmp->unpaid into account) but before + remote_robbery() (which calls rob_shop() which calls setpaid() + after moving costs of unpaid items to shop debt; setpaid() + calls clear_unpaid() for lots of object chains, but 'otmp' isn't + on any of those between obj_extract_self() and addinv(); for + 3.6.0, 'otmp' remained flagged as an unpaid item in inventory + and triggered impossible() every time inventory was examined) */ if (robshop) { char saveushops[5], fakeshop[2]; @@ -1524,10 +1523,14 @@ struct obj *otmp; /* sets obj->unpaid if necessary */ addtobill(otmp, TRUE, FALSE, FALSE); Strcpy(u.ushops, saveushops); - /* if you're outside the shop, make shk notice */ - if (!index(u.ushops, *fakeshop)) - remote_burglary(ox, oy); + robshop = otmp->unpaid && !index(u.ushops, *fakeshop); } + + result = addinv(otmp); + /* if you're taking a shop item from outside the shop, make shk notice */ + if (robshop) + remote_burglary(ox, oy); + return result; } From 32890d1bc1cc8d48cdd31ffb17373b917edfb267 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 23 Jan 2018 00:52:57 -0800 Subject: [PATCH 2/6] fix 'makedefs -z' for config using FILE_PREFIX Apply user-contributed patch to make do_vision() handle FILE_PREFIX correctly. It was putting that value into the filename buffer, then overwriting it with the ordinary filename instead of appending. Deletion of just-made vis_tab.h when creation of vis_tab.c fails would have failed too if FILE_PREFIX had been working. The patch was against 3.4.3 and didn't apply cleanly to current code, but it is a staightforward fix, although the file deletion case was buggy (failed to clear "vis_tab.c" from buffer before reconstructing "vis_tab.h" via appending stuff). FILE_PREFIX seems to be Amiga-only so I've only tested the usual case where it isn't defined. --- doc/fixes36.1 | 2 ++ util/makedefs.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 3dfa88bbb..28313a87c 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -637,6 +637,8 @@ PANICTRACE: PANICTRACE_GDB used wrong value for ARGV0 when launching gdb if win32gui: gather raw_print error messages into a single dialog window win32tty: fix display errors when using a font with double wide or ambiguous width characters +Amiga (untested): 'makedefs -z' didn't handle FILE_PREFIX correctly when + building vis_tab.h and vis_tab.c General New Features diff --git a/util/makedefs.c b/util/makedefs.c index 4d32cc4ad..f9bab0ef1 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 makedefs.c $NHDT-Date: 1506993895 2017/10/03 01:24:55 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.117 $ */ +/* NetHack 3.6 makedefs.c $NHDT-Date: 1516697571 2018/01/23 08:52:51 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.118 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) M. Stephenson, 1990, 1991. */ /* Copyright (c) Dean Luick, 1990. */ @@ -2816,7 +2816,7 @@ do_vision() #ifdef FILE_PREFIX Strcat(filename, file_prefix); #endif - Sprintf(filename, INCLUDE_TEMPLATE, VIS_TAB_H); + Sprintf(eos(filename), INCLUDE_TEMPLATE, VIS_TAB_H); if (!(ofp = fopen(filename, WRTMODE))) { perror(filename); exit(EXIT_FAILURE); @@ -2839,10 +2839,15 @@ do_vision() #ifdef FILE_PREFIX Strcat(filename, file_prefix); #endif - Sprintf(filename, SOURCE_TEMPLATE, VIS_TAB_C); + Sprintf(eos(filename), SOURCE_TEMPLATE, VIS_TAB_C); if (!(ofp = fopen(filename, WRTMODE))) { perror(filename); - Sprintf(filename, INCLUDE_TEMPLATE, VIS_TAB_H); + /* creating vis_tab.c failed; remove the vis_tab.h we just made */ + filename[0] = '\0'; +#ifdef FILE_PREFIX + Strcat(filename, file_prefix); +#endif + Sprintf(eos(filename), INCLUDE_TEMPLATE, VIS_TAB_H); Unlink(filename); exit(EXIT_FAILURE); } From 0ffde7e45fdb4be7df980494b4e6741748cd5fdd Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 25 Jan 2018 23:23:16 -0500 Subject: [PATCH 3/6] copyright notice to 2018 --- dat/.gitignore | 2 ++ include/patchlevel.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dat/.gitignore b/dat/.gitignore index 6cdbe532d..748a8ffe1 100644 --- a/dat/.gitignore +++ b/dat/.gitignore @@ -23,3 +23,5 @@ dlb.lst guioptions porthelp NetHack.ad +gitinfo.txt + diff --git a/include/patchlevel.h b/include/patchlevel.h index 0d2828ffc..daa0234e0 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -15,7 +15,7 @@ */ #define EDITLEVEL 0 -#define COPYRIGHT_BANNER_A "NetHack, Copyright 1985-2016" +#define COPYRIGHT_BANNER_A "NetHack, Copyright 1985-2018" #define COPYRIGHT_BANNER_B \ " By Stichting Mathematisch Centrum and M. Stephenson." /* COPYRIGHT_BANNER_C is generated by makedefs into date.h */ From fec245dba23bc4a6ffaef2700e1abc4cf0305ff0 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 26 Jan 2018 08:01:03 -0500 Subject: [PATCH 4/6] Only update dat/gitinfo.txt if the hash is new --- DEVEL/hooksdir/NHgithook.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/DEVEL/hooksdir/NHgithook.pm b/DEVEL/hooksdir/NHgithook.pm index 6024c1c03..1bb92cf7e 100644 --- a/DEVEL/hooksdir/NHgithook.pm +++ b/DEVEL/hooksdir/NHgithook.pm @@ -60,6 +60,36 @@ sub POST { &do_hook("POST"); } +### +### store githash and gitbranch in dat/gitinfo.txt +### + +sub nhversioning { + use strict; + use warnings; + + my $git_sha = `git rev-parse HEAD`; + $git_sha =~ s/\s+//g; + my $git_branch = `git rev-parse --abbrev-ref HEAD`; + $git_branch =~ s/\s+//g; + + if (open my $fh, '<', 'dat/gitinfo.txt') { + while(my $line = <$fh>) { + if ((index $line, $git_sha) >= 0) { + close $fh; + print "No update made to dat/gitinfo.txt, existing githash=".$git_sha."\n"; + return; + } + } + close $fh; + } + if (open my $fh, '>', 'dat/gitinfo.txt') { + print $fh 'githash='.$git_sha."\n"; + print $fh 'gitbranch='.$git_branch."\n"; + print "An updated dat/gitinfo.txt was written, githash=".$git_sha."\n"; + } +} + # PRIVATE sub do_hook { my($p) = @_; From 9728616a2169d07574c032511a314273deb09bfc Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 26 Jan 2018 08:06:23 -0500 Subject: [PATCH 5/6] fix branch placement of change --- DEVEL/hooksdir/NHgithook.pm | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/DEVEL/hooksdir/NHgithook.pm b/DEVEL/hooksdir/NHgithook.pm index 1bb92cf7e..6024c1c03 100644 --- a/DEVEL/hooksdir/NHgithook.pm +++ b/DEVEL/hooksdir/NHgithook.pm @@ -60,36 +60,6 @@ sub POST { &do_hook("POST"); } -### -### store githash and gitbranch in dat/gitinfo.txt -### - -sub nhversioning { - use strict; - use warnings; - - my $git_sha = `git rev-parse HEAD`; - $git_sha =~ s/\s+//g; - my $git_branch = `git rev-parse --abbrev-ref HEAD`; - $git_branch =~ s/\s+//g; - - if (open my $fh, '<', 'dat/gitinfo.txt') { - while(my $line = <$fh>) { - if ((index $line, $git_sha) >= 0) { - close $fh; - print "No update made to dat/gitinfo.txt, existing githash=".$git_sha."\n"; - return; - } - } - close $fh; - } - if (open my $fh, '>', 'dat/gitinfo.txt') { - print $fh 'githash='.$git_sha."\n"; - print $fh 'gitbranch='.$git_branch."\n"; - print "An updated dat/gitinfo.txt was written, githash=".$git_sha."\n"; - } -} - # PRIVATE sub do_hook { my($p) = @_; From d2245aab2959972da53f0466c6d3b14284b42861 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 26 Jan 2018 17:25:21 -0500 Subject: [PATCH 6/6] version output appearance bits --- include/extern.h | 2 +- src/version.c | 23 +++++++++++++++++------ sys/winnt/winnt.c | 14 +++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/include/extern.h b/include/extern.h index 6f355fa07..ce0b42008 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2567,7 +2567,7 @@ E unsigned long NDECL(get_current_feature_ver); E const char *FDECL(copyright_banner_line, (int)); #ifdef RUNTIME_PORT_ID -E void FDECL(append_port_id, (char *)); +E char *FDECL(get_port_id, (char *)); #endif /* ### video.c ### */ diff --git a/src/version.c b/src/version.c index 4567e30d7..19f74c265 100644 --- a/src/version.c +++ b/src/version.c @@ -15,8 +15,6 @@ #include "patchlevel.h" #endif -#define BETA_INFO "" - STATIC_DCL void FDECL(insert_rtoption, (char *)); /* fill buffer with short version (so caller can avoid including date.h) */ @@ -32,13 +30,26 @@ char * getversionstring(buf) char *buf; { + int details = 0; + Strcpy(buf, VERSION_ID); -#if defined(BETA) && defined(BETA_INFO) - Sprintf(eos(buf), " %s", BETA_INFO); -#endif #if defined(RUNTIME_PORT_ID) - append_port_id(buf); + details++; #endif + + if (details) { + int c = 0; + char tmpbuf[BUFSZ]; + char *tmp = (char *)0; + + Sprintf(eos(buf), " ("); +#if defined(RUNTIME_PORT_ID) + tmp = get_port_id(tmpbuf); + if (tmp) + Sprintf(eos(buf), "%s%s", c++ ? "," : "", tmp); +#endif + Sprintf(eos(buf), ")"); + } return buf; } diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index 892744432..842bfd036 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -326,23 +326,23 @@ int interjection_type; */ #ifndef _M_IX86 #ifdef _M_X64 -#define TARGET_PORT "(x64) " +#define TARGET_PORT "x64" #endif #ifdef _M_IA64 -#define TARGET_PORT "(IA64) " +#define TARGET_PORT "IA64" #endif #endif #ifndef TARGET_PORT -#define TARGET_PORT "(x86) " +#define TARGET_PORT "x86" #endif -void -append_port_id(buf) +char * +get_port_id(buf) char *buf; { - char *portstr = TARGET_PORT; - Sprintf(eos(buf), " %s", portstr); + Strcpy(buf, TARGET_PORT); + return buf; } #endif /* RUNTIME_PORT_ID */