artifacts in final score

Fix the problem From a bug report.  An earlier fix (3.3.1)
made them be listed during final disclosure, but the points shown for
them actually got left out of the total due to misplaced brackets.
Rather than just fixing the brackets, merge the two inventory scanning
loops so that both passes will always be synchronized with each other.
This commit is contained in:
nethack.rankin
2003-01-08 22:07:06 +00:00
parent 601b3b56d3
commit 9988440b2e
2 changed files with 28 additions and 37 deletions
+2
View File
@@ -348,6 +348,8 @@ allow "grey spellbook" as alternative spelling of "gray spellbook"
handle attacks by cancelled monsters more consistently handle attacks by cancelled monsters more consistently
armor worn by monsters might negate some magic attacks like it does for hero armor worn by monsters might negate some magic attacks like it does for hero
give feedback and discovery when visible monster puts on cloak of invisibility give feedback and discovery when visible monster puts on cloak of invisibility
really add artifacts inside carried containers to final score (3.3.1 fix
displayed them them but didn't include any points for them)
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
+26 -37
View File
@@ -1,4 +1,4 @@
/* SCCS Id: @(#)end.c 3.4 2002/11/20 */ /* SCCS Id: @(#)end.c 3.4 2003/01/08 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -37,8 +37,7 @@ static void FDECL(done_hangup, (int));
STATIC_DCL void FDECL(disclose,(int,BOOLEAN_P)); STATIC_DCL void FDECL(disclose,(int,BOOLEAN_P));
STATIC_DCL void FDECL(get_valuables, (struct obj *)); STATIC_DCL void FDECL(get_valuables, (struct obj *));
STATIC_DCL void FDECL(sort_valuables, (struct valuable_data *,int)); STATIC_DCL void FDECL(sort_valuables, (struct valuable_data *,int));
STATIC_DCL void FDECL(add_artifact_score, (struct obj *)); STATIC_DCL void FDECL(artifact_score, (struct obj *,BOOLEAN_P,winid));
STATIC_DCL void FDECL(display_artifact_score, (struct obj *,winid));
STATIC_DCL void FDECL(savelife, (int)); STATIC_DCL void FDECL(savelife, (int));
STATIC_DCL void FDECL(list_vanquished, (int, BOOLEAN_P)); STATIC_DCL void FDECL(list_vanquished, (int, BOOLEAN_P));
STATIC_DCL void FDECL(list_genocided, (int, BOOLEAN_P)); STATIC_DCL void FDECL(list_genocided, (int, BOOLEAN_P));
@@ -490,52 +489,41 @@ int size; /* max value is less than 20 */
return; return;
} }
/* called twice; first to calculate total, then to list relevant items */
STATIC_OVL void STATIC_OVL void
add_artifact_score(list) artifact_score(list, counting, endwin)
struct obj *list;
{
struct obj *otmp;
for (otmp = list; otmp; otmp = otmp->nobj)
if (otmp->oartifact ||
otmp->otyp == BELL_OF_OPENING ||
otmp->otyp == SPE_BOOK_OF_THE_DEAD ||
otmp->otyp == CANDELABRUM_OF_INVOCATION) {
u.urexp += (arti_cost(otmp) * 5 / 2);
if (Has_contents(otmp))
add_artifact_score(otmp->cobj);
}
}
STATIC_OVL void
display_artifact_score(list,endwin)
struct obj *list; struct obj *list;
boolean counting; /* true => add up points; false => display them */
winid endwin; winid endwin;
{ {
char pbuf[BUFSZ]; char pbuf[BUFSZ];
struct obj *otmp; struct obj *otmp;
long value, points;
short dummy; /* object type returned by artifact_name() */
for (otmp = list; otmp; otmp = otmp->nobj) { for (otmp = list; otmp; otmp = otmp->nobj) {
if (otmp->oartifact || if (otmp->oartifact ||
otmp->otyp == BELL_OF_OPENING || otmp->otyp == BELL_OF_OPENING ||
otmp->otyp == SPE_BOOK_OF_THE_DEAD || otmp->otyp == SPE_BOOK_OF_THE_DEAD ||
otmp->otyp == CANDELABRUM_OF_INVOCATION) { otmp->otyp == CANDELABRUM_OF_INVOCATION) {
short dummy; value = arti_cost(otmp); /* zorkmid value */
points = value * 5 / 2; /* score value */
makeknown(otmp->otyp); if (counting) {
otmp->known = otmp->bknown = otmp->dknown = u.rexp += points;
otmp->rknown = 1; } else {
/* assumes artifacts don't have quan>1 */ makeknown(otmp->otyp);
Sprintf(pbuf, "%s%s (worth %ld %s and %ld points)", otmp->known = otmp->dknown = otmp->bknown = otmp->rknown = 1;
the_unique_obj(otmp) ? "The " : "", /* assumes artifacts don't have quan > 1 */
otmp->oartifact ? artifact_name(xname(otmp), &dummy) : Sprintf(pbuf, "%s%s (worth %ld %s and %ld points)",
OBJ_NAME(objects[otmp->otyp]), the_unique_obj(otmp) ? "The " : "",
arti_cost(otmp), currency(2L), otmp->oartifact ? artifact_name(xname(otmp), &dummy) :
arti_cost(otmp) * 5 / 2); OBJ_NAME(objects[otmp->otyp]),
putstr(endwin, 0, pbuf); value, currency(value), points);
putstr(endwin, 0, pbuf);
}
} }
if (Has_contents(otmp)) if (Has_contents(otmp))
display_artifact_score(otmp->cobj,endwin); artifact_score(otmp->cobj, counting, endwin);
} }
} }
@@ -807,7 +795,8 @@ die:
u.urexp += val->list[i].count u.urexp += val->list[i].count
* (long)objects[val->list[i].typ].oc_cost; * (long)objects[val->list[i].typ].oc_cost;
add_artifact_score(invent); /* count the points for artifacts */
artifact_score(invent, TRUE, endwin);
keepdogs(TRUE); keepdogs(TRUE);
viz_array[0][0] |= IN_SIGHT; /* need visibility for naming */ viz_array[0][0] |= IN_SIGHT; /* need visibility for naming */
@@ -835,7 +824,7 @@ die:
} }
if (!done_stopprint) if (!done_stopprint)
display_artifact_score(invent,endwin); artifact_score(invent, FALSE, endwin); /* list artifacts */
/* list valuables here */ /* list valuables here */
for (val = valuables; val->list; val++) { for (val = valuables; val->list; val++) {