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.
This commit is contained in:
PatR
2017-03-14 05:27:45 -07:00
parent 4b87255105
commit dd8a95eec4
2 changed files with 14 additions and 6 deletions

View File

@@ -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

View File

@@ -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();