Skip to content

Commit

Permalink
releasing inventory window(s)
Browse files Browse the repository at this point in the history
This should address the issue that the problem patch to display_pickinv()
was trying to deal with:  releasing the inventory window before exiting
the program so Pasi's memory checker doesn't think it's a memory leak.

Not related, but in the same file:
The older qsort comparison routines are tagged with CFDECLSPEC to deal
with some C vs C++ interaction issue.  I added that to the relatively
recently added 'sortloot' qsort compare callback.

I also changed worn_wield_only(), although it isn't actually called.
(display_minventory() has provisions to call it, but both of the latter's
callers pass in MINV_ALL so allow_all() gets used instead.)
  • Loading branch information
PatR committed Nov 3, 2015
1 parent 91369e7 commit 69b13d5
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 159 deletions.
7 changes: 4 additions & 3 deletions include/extern.h
@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1446336781 2015/11/01 00:13:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.511 $ */
/* NetHack 3.6 extern.h $NHDT-Date: 1446516834 2015/11/03 02:13:54 $ $NHDT-Branch: master $:$NHDT-Revision: 1.513 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */

Expand Down Expand Up @@ -910,8 +910,8 @@ E boolean NDECL(wearing_armor);
E boolean FDECL(is_worn, (struct obj *));
E struct obj *FDECL(g_at, (int, int));
E struct obj *FDECL(getobj, (const char *, const char *));
E int FDECL(ggetobj,
(const char *, int (*)(OBJ_P), int, BOOLEAN_P, unsigned *));
E int FDECL(ggetobj, (const char *, int (*)(OBJ_P), int,
BOOLEAN_P, unsigned *));
E int FDECL(askchain, (struct obj **, const char *, int, int (*)(OBJ_P),
int (*)(OBJ_P), int, const char *));
E void FDECL(fully_identify_obj, (struct obj *));
Expand Down Expand Up @@ -945,6 +945,7 @@ E char *FDECL(let_to_name, (CHAR_P, BOOLEAN_P, BOOLEAN_P));
E void NDECL(free_invbuf);
E void NDECL(reassign);
E int NDECL(doorganize);
E void NDECL(free_pickinv_cache);
E int FDECL(count_unpaid, (struct obj *));
E int FDECL(count_buc, (struct obj *, int));
E long FDECL(count_contents, (struct obj *, BOOLEAN_P, BOOLEAN_P, BOOLEAN_P));
Expand Down
68 changes: 36 additions & 32 deletions src/end.c
@@ -1,4 +1,4 @@
/* NetHack 3.6 end.c $NHDT-Date: 1434408399 2015/06/15 22:46:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.100 $ */
/* NetHack 3.6 end.c $NHDT-Date: 1446510332 2015/11/03 00:25:32 $ $NHDT-Branch: master $:$NHDT-Revision: 1.102 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */

Expand Down Expand Up @@ -214,7 +214,7 @@ NH_panictrace_libc()
for (x = 0; x < count; x++) {
raw_printf("[%lu] %s", (unsigned long) x, info[x]);
}
/* free(info); Don't risk it. */
/* free(info); -- Don't risk it. */
return TRUE;
#else
return FALSE;
Expand Down Expand Up @@ -273,22 +273,23 @@ NH_panictrace_gdb()
/*
* The order of these needs to match the macros in hack.h.
*/
static NEARDATA const char *deaths[] =
{ /* the array of death */
"died", "choked", "poisoned", "starvation", "drowning", "burning",
"dissolving under the heat and pressure", "crushed", "turned to stone",
"turned into slime", "genocided", "panic", "trickery", "quit",
"escaped", "ascended"
};

static NEARDATA const char *ends[] = { /* "when you..." */
"died", "choked", "were poisoned",
"starved", "drowned", "burned",
"dissolved in the lava",
"were crushed", "turned to stone",
"turned into slime", "were genocided",
"panicked", "were tricked", "quit",
"escaped", "ascended"
static NEARDATA const char *deaths[] = {
/* the array of death */
"died", "choked", "poisoned", "starvation", "drowning", "burning",
"dissolving under the heat and pressure", "crushed", "turned to stone",
"turned into slime", "genocided", "panic", "trickery", "quit",
"escaped", "ascended"
};

static NEARDATA const char *ends[] = {
/* "when you %s" */
"died", "choked", "were poisoned",
"starved", "drowned", "burned",
"dissolved in the lava",
"were crushed", "turned to stone",
"turned into slime", "were genocided",
"panicked", "were tricked", "quit",
"escaped", "ascended"
};

static boolean Schroedingers_cat = FALSE;
Expand Down Expand Up @@ -366,8 +367,8 @@ done2()

#ifndef NO_SIGNAL
/*ARGSUSED*/
STATIC_PTR void done_intr(
sig_unused) /* called as signal() handler, so sent at least one arg */
STATIC_PTR void
done_intr(sig_unused) /* called as signal() handler, so sent at least 1 arg */
int sig_unused UNUSED;
{
done_stopprint++;
Expand Down Expand Up @@ -396,10 +397,11 @@ struct monst *mtmp;
int how;
{
char buf[BUFSZ];
struct permonst *mptr = mtmp->data, *champtr = (mtmp->cham >= LOW_PM)
? &mons[mtmp->cham]
: mptr;
boolean distorted = (boolean)(Hallucination && canspotmon(mtmp)),
struct permonst *mptr = mtmp->data,
*champtr = ((mtmp->cham >= LOW_PM)
? &mons[mtmp->cham]
: mptr);
boolean distorted = (boolean) (Hallucination && canspotmon(mtmp)),
mimicker = (mtmp->m_ap_type == M_AP_MONSTER),
imitator = (mptr != champtr || mimicker);

Expand Down Expand Up @@ -452,8 +454,9 @@ int how;
Strcpy(shape, an(fakenm));
/* omit "called" to avoid excessive verbosity */
Sprintf(eos(buf),
alt ? "%s in %s form" : mimicker ? "%s disguised as %s"
: "%s imitating %s",
alt ? "%s in %s form"
: mimicker ? "%s disguised as %s"
: "%s imitating %s",
realnm, shape);
mptr = mtmp->data; /* reset for mimicker case */
} else if (mptr == &mons[PM_GHOST]) {
Expand All @@ -462,9 +465,8 @@ int how;
Sprintf(eos(buf), " of %s", MNAME(mtmp));
} else if (mtmp->isshk) {
const char *shknm = shkname(mtmp),
*honorific = shkname_is_pname(mtmp) ? "" : mtmp->female
? "Ms. "
: "Mr. ";
*honorific = shkname_is_pname(mtmp) ? ""
: mtmp->female ? "Ms. " : "Mr. ";

Sprintf(eos(buf), "%s%s, the shopkeeper", honorific, shknm);
killer.format = KILLED_BY;
Expand Down Expand Up @@ -925,7 +927,7 @@ int how;
}

/*
* The game is now over...
* The game is now over...
*/

die:
Expand Down Expand Up @@ -1092,6 +1094,8 @@ int how;
/* clean up unneeded windows */
if (have_windows) {
wait_synch();
if (WIN_INVEN != WIN_ERR)
destroy_nhwindow(WIN_INVEN), WIN_INVEN = WIN_ERR;
display_nhwindow(WIN_MESSAGE, TRUE);
destroy_nhwindow(WIN_MAP), WIN_MAP = WIN_ERR;
#ifndef STATUS_VIA_WINDOWPORT
Expand Down Expand Up @@ -1130,8 +1134,8 @@ int how;
}

if (how == ESCAPED || how == ASCENDED) {
register struct monst *mtmp;
register struct obj *otmp;
struct monst *mtmp;
struct obj *otmp;
register struct val_list *val;
register int i;

Expand Down

0 comments on commit 69b13d5

Please sign in to comment.