object name assignment vs persistent inventory

This is an alternate way to deal with pull request #876, where
splitting a stack that has a name assigned updated perm_invent when
cloning the name and ran into trouble with shop billing when trying
to format for persistent inventory display.

The PR#876 fix has been left in place but wouldn't have been needed
if this had gone in first.
This commit is contained in:
PatR
2022-09-26 14:25:06 -07:00
parent caf1eeebf9
commit 0735b790f9
4 changed files with 9 additions and 6 deletions

View File

@@ -408,6 +408,8 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */
* or m_initweap() (lawful Angel) */
/* flag congrolling potential livelog event of finding an artifact */
#define ONAME_KNOW_ARTI 0x0100U /* hero is already aware of this artifact */
/* flag for suppressing perm_invent update when name gets assigned */
#define ONAME_SKIP_INVUPD 0x0200U /* don't call update_inventory() */
/* Flags to control find_mid() */
#define FM_FMON 0x01 /* search the fmon chain */

View File

@@ -1358,11 +1358,12 @@ struct obj *
oname(
struct obj *obj, /* item to assign name to */
const char *name, /* name to assign */
unsigned oflgs) /* flags for artifact creation; otherwise ignored */
unsigned oflgs) /* flags, mostly for artifact creation */
{
int lth;
char buf[PL_PSIZ];
boolean via_naming = (oflgs & ONAME_VIA_NAMING) != 0;
boolean via_naming = (oflgs & ONAME_VIA_NAMING) != 0,
skip_inv_update = (oflgs & ONAME_SKIP_INVUPD) != 0;
lth = *name ? (int) (strlen(name) + 1) : 0;
if (lth > PL_PSIZ) {
@@ -1405,7 +1406,7 @@ oname(
ansimpleoname(obj), bare_artifactname(obj));
}
}
if (carried(obj))
if (carried(obj) && !skip_inv_update)
update_inventory();
return obj;
}

View File

@@ -726,7 +726,7 @@ merged(struct obj **potmp, struct obj **pobj)
else if (!Is_pudding(otmp))
otmp->owt += obj->owt;
if (!has_oname(otmp) && has_oname(obj))
otmp = *potmp = oname(otmp, ONAME(obj), ONAME_NO_FLAGS);
otmp = *potmp = oname(otmp, ONAME(obj), ONAME_SKIP_INVUPD);
obj_extract_self(obj);
if (obj->pickup_prev && otmp->where == OBJ_INVENT)

View File

@@ -359,7 +359,7 @@ copy_oextra(struct obj *obj2, struct obj *obj1)
if (!obj2->oextra)
obj2->oextra = newoextra();
if (has_oname(obj1))
oname(obj2, ONAME(obj1), ONAME_NO_FLAGS);
oname(obj2, ONAME(obj1), ONAME_SKIP_INVUPD);
if (has_omonst(obj1)) {
if (!OMONST(obj2))
newomonst(obj2);
@@ -427,7 +427,7 @@ splitobj(struct obj *obj, long num)
splitbill(obj, otmp);
copy_oextra(otmp, obj);
if (has_omid(otmp))
free_omid(otmp); /* only one association with m_id*/
free_omid(otmp); /* only one association with m_id */
if (obj->timed)
obj_split_timers(obj, otmp);
if (obj_sheds_light(obj))