From 1e0ab8f92fea53707d134242869b0b3af9202c58 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 25 Apr 2016 17:07:07 -0700 Subject: [PATCH] another sortloot tweak - diluted potions Change sort ordering of diluted potion of bar diluted potion of foo potion of bar potion of foo potion of fruit juice to potion of bar diluted potion of bar potion of foo diluted potion of foo potion of fruit juice so that potions of the same type are grouped together. Bless/curse state (when known) takes precedence over dilution, so "blessed diluted potion of foo" will come out before "uncursed potion foo". --- doc/fixes36.1 | 2 ++ src/invent.c | 24 +++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 492c522c8..d11688f85 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -220,6 +220,8 @@ automatic annotation for Ft.Ludios level got applied when a drawbridge became mapped, but entry there is a secret door rather than a drawbridge sortloot changed to group holy water and unholy water with water instead of placing them among the h- and u-named items +sortloot changed to place diluted potion of foo after potion of foo instead + of listing all diluted potions followed by all non-diluted ones digging down on a grave converted the terrain to floor but did not create a pit and uncover the grave's contents; digging again--on floor--did diff --git a/src/invent.c b/src/invent.c index a6299a12f..9654c7f8c 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1461451444 2016/04/23 22:44:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.206 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1461629196 2016/04/26 00:06:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.207 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -63,7 +63,8 @@ const genericptr vptr2; struct sortloot_item *sli1 = (struct sortloot_item *) vptr1, *sli2 = (struct sortloot_item *) vptr2; struct obj *obj1 = sli1->obj, - *obj2 = sli2->obj; + *obj2 = sli2->obj, + sav1, sav2; char *cls1, *cls2, nam1[BUFSZ], nam2[BUFSZ]; int val1, val2, c, namcmp; @@ -139,9 +140,19 @@ const genericptr vptr2; if ((sortlootmode & SORTLOOT_LOOT) == 0) goto tiebreak; - /* Sort object names in lexicographical order, ignoring quantity. - [Force holy and unholy water to sort adjacent to water rather - than among 'h's and 'u's. BUCX order will keep them distinct.] */ + /* + * Sort object names in lexicographical order, ignoring quantity. + */ + /* Force diluted potions to come out after undiluted of same type; + obj->odiluted overloads obj->oeroded. */ + sav1.odiluted = obj1->odiluted; + sav2.odiluted = obj2->odiluted; + if (obj1->oclass == POTION_CLASS) + obj1->odiluted = 0; + if (obj1->oclass == POTION_CLASS) + obj2->odiluted = 0; + /* Force holy and unholy water to sort adjacent to water rather + than among 'h's and 'u's. BUCX order will keep them distinct. */ Strcpy(nam1, cxname_singular(obj1)); if (obj1->otyp == POT_WATER && obj1->bknown && (obj1->blessed || obj1->cursed)) @@ -150,6 +161,9 @@ const genericptr vptr2; if (obj2->otyp == POT_WATER && obj2->bknown && (obj2->blessed || obj2->cursed)) (void) strsubst(nam2, obj2->blessed ? "holy " : "unholy ", ""); + obj1->odiluted = sav1.odiluted; + obj2->odiluted = sav2.odiluted; + if ((namcmp = strcmpi(nam1, nam2)) != 0) return namcmp;