revisit #H4083 - glob ID and merging

Globs on the floor used different criteria (anything goes) than globs
in inventory (mostly requiring same ownership when in shops and same
curse/bless state--other stuff generally isn't applicable) when
deciding whether two globs should merge.  That was okay as long as
the globs on the floor were from being left behind when a pudding or
ooze was killed, but not if the player had picked some up, dipped
them in holy or unholy water, and dropped them again.  This changes
things so that globs on the floor use the same criteria as globs in
inventory when deciding whether to coallesce.

Also, my earlier fix was modifying globs in the mergeable() test (to
make bknown and rknown match) rather than during actual merge, which
would be a problem if the merger didn't take place for some reason.
This commit is contained in:
PatR
2016-01-28 18:13:25 -08:00
parent a309e076e0
commit b632247a74
4 changed files with 46 additions and 49 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mkobj.c $NHDT-Date: 1447475943 2015/11/14 04:39:03 $ $NHDT-Branch: master $:$NHDT-Revision: 1.113 $ */
/* NetHack 3.6 mkobj.c $NHDT-Date: 1454033600 2016/01/29 02:13:20 $ $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. */
@@ -2578,15 +2578,10 @@ struct obj *
obj_nexto(otmp)
struct obj *otmp;
{
struct obj *otmp2 = (struct obj *) 0;
if (otmp) {
otmp2 = obj_nexto_xy(otmp->otyp, otmp->ox, otmp->oy, otmp->o_id);
} else {
if (!otmp)
impossible("obj_nexto: wasn't given an object to check");
}
return otmp2;
return obj_nexto_xy(otmp, otmp->ox, otmp->oy, TRUE);
}
/*
@@ -2598,24 +2593,27 @@ struct obj *otmp;
* reliably predict which one we want to 'find' first
*/
struct obj *
obj_nexto_xy(otyp, x, y, oid)
int otyp, x, y;
unsigned oid;
obj_nexto_xy(obj, x, y, recurs)
struct obj *obj;
int x, y;
boolean recurs;
{
struct obj *otmp;
int fx, fy, ex, ey;
int fx, fy, ex, ey, otyp = obj->otyp;
short dx, dy;
/* check under our "feet" first */
otmp = sobj_at(otyp, x, y);
while (otmp) {
/* don't be clever and find ourselves */
if (otmp->o_id != oid) {
if (otmp != obj && mergable(otmp, obj))
return otmp;
}
otmp = nxtobj(otmp, otyp, TRUE);
}
if (!recurs)
return (struct obj *) 0;
/* search in a random order */
dx = (rn2(2) ? -1 : 1);
dy = (rn2(2) ? -1 : 1);
@@ -2626,9 +2624,8 @@ unsigned oid;
for (fy = ey; abs(fy - ey) < 3; fy += dy) {
/* 0, 0 was checked above */
if (isok(fx, fy) && (fx != x || fy != y)) {
if ((otmp = sobj_at(otyp, fx, fy)) != 0) {
if ((otmp = obj_nexto_xy(obj, fx, fy, FALSE)) != 0)
return otmp;
}
}
}
}
@@ -2644,14 +2641,22 @@ struct obj *
obj_absorb(obj1, obj2)
struct obj **obj1, **obj2;
{
struct obj *otmp1 = (struct obj *) 0, *otmp2 = (struct obj *) 0;
int extrawt = 0;
struct obj *otmp1, *otmp2;
int extrawt;
/* don't let people dumb it up */
if (obj1 && obj2) {
otmp1 = *obj1;
otmp2 = *obj2;
if (otmp1 && otmp2) {
if (otmp1 && otmp2 && otmp1 != otmp2) {
if (otmp1->bknown != otmp2->bknown)
otmp1->bknown = otmp2->bknown = 0;
if (otmp1->rknown != otmp2->rknown)
otmp1->rknown = otmp2->rknown = 0;
if (otmp1->greased != otmp2->greased)
otmp1->greased = otmp2->greased = 0;
if (otmp1->orotten || otmp2->orotten)
otmp1->orotten = otmp2->orotten = 1;
extrawt = otmp2->oeaten ? otmp2->oeaten : otmp2->owt;
otmp1->owt += extrawt;
otmp1->oeaten += otmp1->oeaten ? extrawt : 0;
@@ -2677,13 +2682,14 @@ struct obj *
obj_meld(obj1, obj2)
struct obj **obj1, **obj2;
{
struct obj *otmp1 = (struct obj *) 0, *otmp2 = (struct obj *) 0;
struct obj *otmp1, *otmp2;
if (obj1 && obj2) {
otmp1 = *obj1;
otmp2 = *obj2;
if (otmp1 && otmp2) {
if (otmp1->owt > otmp2->owt || rn2(2)) {
if (otmp1 && otmp2 && otmp1 != otmp2) {
if (otmp1->owt > otmp2->owt
|| (otmp1->owt == otmp2->owt && rn2(2))) {
return obj_absorb(obj1, obj2);
}
return obj_absorb(obj2, obj1);