From dd8a95eec43a89757f0ca7ed9ef8fe9c03099419 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 14 Mar 2017 05:27:45 -0700 Subject: [PATCH] fix #H5188 - getting an artifact break illiterate To-be-3.6.1 bug, caused by a patch (of mine...) incorporated about a week after 3.6.0 was released that was intended to be for naming Sting or Orcist. Any artifact creation ended up breaking illiterate conduct whether user-assigned naming was involved or not (because oname() is always used to apply the name, not just when do_name() is executing). This should be handled differently but I don't want to go through the dozen and half or so calls to oname() to add an extra argument. --- doc/fixes36.1 | 2 ++ src/do_name.c | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 761d1e02..f0986f9a 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -398,6 +398,8 @@ DUMPLOG: genocided and extinct species was always a blank line; vanquished creatures was just a blank line if nothing had been killed DUMPLOG: RIP tombstone was printed for characters who survived (ascended, escaped dungeon, quit, trickery or panic) +artifact creation violated illiterate conduct when artifact name was assigned, + behavior intended only for creating Sting or Orcrist via naming Platform- and/or Interface-Specific Fixes diff --git a/src/do_name.c b/src/do_name.c index d494942c..98293152 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do_name.c $NHDT-Date: 1452669022 2016/01/13 07:10:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.90 $ */ +/* NetHack 3.6 do_name.c $NHDT-Date: 1489494376 2017/03/14 12:26:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.116 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1011,10 +1011,12 @@ do_mname() (void) christen_monst(mtmp, buf); } +STATIC_VAR int via_naming = 0; + /* - * This routine changes the address of obj. Be careful not to call it - * when there might be pointers around in unknown places. For now: only - * when obj is in the inventory. + * This routine used to change the address of 'obj' so be unsafe if not + * used with extreme care. Applying a name to an object no longer + * allocates a replacement object, so that old risk is gone. */ STATIC_OVL void @@ -1079,7 +1081,9 @@ register struct obj *obj; display_nhwindow(WIN_MESSAGE, FALSE); You("engrave: \"%s\".", buf); } + ++via_naming; /* This ought to be an argument rather than a static... */ obj = oname(obj, buf); + --via_naming; /* ...but oname() is used in a lot of places, so defer. */ } struct obj * @@ -1119,8 +1123,10 @@ const char *name; /* if obj is owned by a shop, increase your bill */ if (obj->unpaid) alter_cost(obj, 0L); - /* violate illiteracy conduct since successfully wrote arti-name */ - u.uconduct.literate++; + if (via_naming) { + /* violate illiteracy conduct since successfully wrote arti-name */ + u.uconduct.literate++; + } } if (carried(obj)) update_inventory(); -- 2.11.4.GIT