simplify #vanquished monsters processing...
...prior to making it more complicated. Most of the diff is just reducing the block nesting level of the kill-count formatting by a couple of tab stops.
This commit is contained in:
111
src/end.c
111
src/end.c
@@ -50,6 +50,8 @@ STATIC_DCL void FDECL(artifact_score, (struct obj *, BOOLEAN_P, winid));
|
|||||||
STATIC_DCL void FDECL(really_done, (int)) NORETURN;
|
STATIC_DCL void FDECL(really_done, (int)) NORETURN;
|
||||||
STATIC_DCL boolean FDECL(odds_and_ends, (struct obj *, int));
|
STATIC_DCL boolean FDECL(odds_and_ends, (struct obj *, int));
|
||||||
STATIC_DCL void FDECL(savelife, (int));
|
STATIC_DCL void FDECL(savelife, (int));
|
||||||
|
STATIC_PTR int FDECL(CFDECLSPEC vanqsort_cmp, (const genericptr,
|
||||||
|
const genericptr));
|
||||||
STATIC_DCL void FDECL(list_vanquished, (CHAR_P, BOOLEAN_P));
|
STATIC_DCL void FDECL(list_vanquished, (CHAR_P, BOOLEAN_P));
|
||||||
STATIC_DCL void FDECL(list_genocided, (CHAR_P, BOOLEAN_P));
|
STATIC_DCL void FDECL(list_genocided, (CHAR_P, BOOLEAN_P));
|
||||||
STATIC_DCL boolean FDECL(should_query_disclose_option, (int, char *));
|
STATIC_DCL boolean FDECL(should_query_disclose_option, (int, char *));
|
||||||
@@ -1424,6 +1426,23 @@ int status;
|
|||||||
nethack_exit(status);
|
nethack_exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC_PTR int CFDECLSPEC
|
||||||
|
vanqsort_cmp(vptr1, vptr2)
|
||||||
|
const genericptr vptr1;
|
||||||
|
const genericptr vptr2;
|
||||||
|
{
|
||||||
|
int indx1 = *(short *) vptr1, indx2 = *(short *) vptr2,
|
||||||
|
mlev1 = mons[indx1].mlevel, mlev2 = mons[indx2].mlevel,
|
||||||
|
res;
|
||||||
|
|
||||||
|
/* sort by monster level */
|
||||||
|
res = mlev2 - mlev1; /* mlevel high to low */
|
||||||
|
if (res == 0)
|
||||||
|
res = indx1 - indx2; /* tiebreaker, mons[] index low to high */
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/* #vanquished command */
|
/* #vanquished command */
|
||||||
int
|
int
|
||||||
dovanquished()
|
dovanquished()
|
||||||
@@ -1437,20 +1456,21 @@ list_vanquished(defquery, ask)
|
|||||||
char defquery;
|
char defquery;
|
||||||
boolean ask;
|
boolean ask;
|
||||||
{
|
{
|
||||||
register int i, lev;
|
register int i;
|
||||||
int ntypes = 0, max_lev = 0, pfx, nkilled;
|
int pfx, nkilled;
|
||||||
|
unsigned ntypes, ni;
|
||||||
long total_killed = 0L;
|
long total_killed = 0L;
|
||||||
char c;
|
|
||||||
winid klwin;
|
winid klwin;
|
||||||
char buf[BUFSZ], buftoo[BUFSZ];
|
short mindx[NUMMONS];
|
||||||
|
char c, buf[BUFSZ], buftoo[BUFSZ];
|
||||||
|
|
||||||
/* get totals first */
|
/* get totals first */
|
||||||
|
ntypes = 0;
|
||||||
for (i = LOW_PM; i < NUMMONS; i++) {
|
for (i = LOW_PM; i < NUMMONS; i++) {
|
||||||
if (mvitals[i].died)
|
if ((nkilled = (int) mvitals[i].died) == 0)
|
||||||
ntypes++;
|
continue;
|
||||||
total_killed += (long) mvitals[i].died;
|
mindx[ntypes++] = i;
|
||||||
if (mons[i].mlevel > max_lev)
|
total_killed += (long) nkilled;
|
||||||
max_lev = mons[i].mlevel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vanquished creatures list;
|
/* vanquished creatures list;
|
||||||
@@ -1468,45 +1488,44 @@ boolean ask;
|
|||||||
putstr(klwin, 0, "Vanquished creatures:");
|
putstr(klwin, 0, "Vanquished creatures:");
|
||||||
putstr(klwin, 0, "");
|
putstr(klwin, 0, "");
|
||||||
|
|
||||||
/* countdown by monster "toughness" */
|
qsort((genericptr_t) mindx, ntypes, sizeof *mindx, vanqsort_cmp);
|
||||||
for (lev = max_lev; lev >= 0; lev--)
|
for (ni = 0; ni < ntypes; ni++) {
|
||||||
for (i = LOW_PM; i < NUMMONS; i++)
|
i = mindx[ni];
|
||||||
if (mons[i].mlevel == lev
|
nkilled = mvitals[i].died;
|
||||||
&& (nkilled = mvitals[i].died) > 0) {
|
if ((mons[i].geno & G_UNIQ) && i != PM_HIGH_PRIEST) {
|
||||||
if ((mons[i].geno & G_UNIQ) && i != PM_HIGH_PRIEST) {
|
Sprintf(buf, "%s%s",
|
||||||
Sprintf(buf, "%s%s",
|
!type_is_pname(&mons[i]) ? "the " : "",
|
||||||
!type_is_pname(&mons[i]) ? "the " : "",
|
mons[i].mname);
|
||||||
mons[i].mname);
|
if (nkilled > 1) {
|
||||||
if (nkilled > 1) {
|
switch (nkilled) {
|
||||||
switch (nkilled) {
|
case 2:
|
||||||
case 2:
|
Sprintf(eos(buf), " (twice)");
|
||||||
Sprintf(eos(buf), " (twice)");
|
break;
|
||||||
break;
|
case 3:
|
||||||
case 3:
|
Sprintf(eos(buf), " (thrice)");
|
||||||
Sprintf(eos(buf), " (thrice)");
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
Sprintf(eos(buf), " (%d times)", nkilled);
|
||||||
Sprintf(eos(buf), " (%d times)", nkilled);
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* trolls or undead might have come back,
|
|
||||||
but we don't keep track of that */
|
|
||||||
if (nkilled == 1)
|
|
||||||
Strcpy(buf, an(mons[i].mname));
|
|
||||||
else
|
|
||||||
Sprintf(buf, "%3d %s", nkilled,
|
|
||||||
makeplural(mons[i].mname));
|
|
||||||
}
|
}
|
||||||
/* number of leading spaces to match 3 digit prefix */
|
|
||||||
pfx = !strncmpi(buf, "the ", 3) ? 0
|
|
||||||
: !strncmpi(buf, "an ", 3) ? 1
|
|
||||||
: !strncmpi(buf, "a ", 2) ? 2
|
|
||||||
: !isdigit(buf[2]) ? 4 : 0;
|
|
||||||
Sprintf(buftoo, "%*s%s", pfx, "", buf);
|
|
||||||
putstr(klwin, 0, buftoo);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* trolls or undead might have come back,
|
||||||
|
but we don't keep track of that */
|
||||||
|
if (nkilled == 1)
|
||||||
|
Strcpy(buf, an(mons[i].mname));
|
||||||
|
else
|
||||||
|
Sprintf(buf, "%3d %s", nkilled,
|
||||||
|
makeplural(mons[i].mname));
|
||||||
|
}
|
||||||
|
/* number of leading spaces to match 3 digit prefix */
|
||||||
|
pfx = !strncmpi(buf, "the ", 3) ? 0
|
||||||
|
: !strncmpi(buf, "an ", 3) ? 1
|
||||||
|
: !strncmpi(buf, "a ", 2) ? 2
|
||||||
|
: !isdigit(buf[2]) ? 4 : 0;
|
||||||
|
Sprintf(buftoo, "%*s%s", pfx, "", buf);
|
||||||
|
putstr(klwin, 0, buftoo);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* if (Hallucination)
|
* if (Hallucination)
|
||||||
* putstr(klwin, 0, "and a partridge in a pear tree");
|
* putstr(klwin, 0, "and a partridge in a pear tree");
|
||||||
|
|||||||
Reference in New Issue
Block a user