Merge branch 'NetHack-3.6.2'

This commit is contained in:
nhmall
2018-12-04 21:38:30 -05:00
35 changed files with 697 additions and 587 deletions

102
src/cmd.c
View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 cmd.c $NHDT-Date: 1543711385 2018/12/02 00:43:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.309 $ */
/* NetHack 3.6 cmd.c $NHDT-Date: 1543972186 2018/12/05 01:09:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.313 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -126,10 +126,10 @@ extern int NDECL(dozap); /**/
extern int NDECL(doorganize); /**/
#endif /* DUMB */
static int NDECL(dosuspend_core); /**/
static int NDECL((*timed_occ_fn));
STATIC_PTR int NDECL(dosuspend_core);
STATIC_PTR int NDECL(dosh_core);
STATIC_PTR int NDECL(doherecmdmenu);
STATIC_PTR int NDECL(dotherecmdmenu);
STATIC_PTR int NDECL(doprev_message);
@@ -194,9 +194,6 @@ STATIC_DCL void FDECL(one_characteristic, (int, int, int));
STATIC_DCL void FDECL(status_enlightenment, (int, int));
STATIC_DCL void FDECL(attributes_enlightenment, (int, int));
static const char *readchar_queue = "";
static coord clicklook_cc;
STATIC_DCL void FDECL(add_herecmd_menuitem, (winid, int NDECL((*)),
const char *));
STATIC_DCL char FDECL(here_cmd_menu, (BOOLEAN_P));
@@ -205,6 +202,13 @@ STATIC_DCL char *NDECL(parse);
STATIC_DCL void FDECL(show_direction_keys, (winid, CHAR_P, BOOLEAN_P));
STATIC_DCL boolean FDECL(help_dir, (CHAR_P, int, const char *));
static const char *readchar_queue = "";
static coord clicklook_cc;
/* for rejecting attempts to use wizard mode commands */
static const char unavailcmd[] = "Unavailable command '%s'.";
/* for rejecting #if !SHELL, !SUSPEND */
static const char cmdnotavail[] = "'%s' command not available.";
STATIC_PTR int
doprev_message(VOID_ARGS)
{
@@ -438,6 +442,8 @@ doextlist(VOID_ARGS)
for (efp = extcmdlist; efp->ef_txt; efp++) {
int wizc;
if ((efp->flags & CMD_NOT_AVAILABLE) != 0)
continue;
/* if hiding non-autocomplete commands, skip such */
if (menumode == 1 && (efp->flags & AUTOCOMPLETE) == 0)
continue;
@@ -567,7 +573,8 @@ extcmd_via_menu()
any = zeroany;
/* populate choices */
for (efp = extcmdlist; efp->ef_txt; efp++) {
if (!(efp->flags & AUTOCOMPLETE)
if ((efp->flags & CMD_NOT_AVAILABLE)
|| !(efp->flags & AUTOCOMPLETE)
|| (!wizard && (efp->flags & WIZMODECMD)))
continue;
if (!matchlevel || !strncmp(efp->ef_txt, cbuf, matchlevel)) {
@@ -763,8 +770,7 @@ wiz_wish(VOID_ARGS) /* Unlimited wishes for debug mode by Paul Polderman */
flags.verbose = save_verbose;
(void) encumber_msg();
} else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_wish)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_wish)));
return 0;
}
@@ -784,8 +790,7 @@ wiz_identify(VOID_ARGS)
(void) display_inventory((char *) 0, FALSE);
iflags.override_ID = 0;
} else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_identify)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_identify)));
return 0;
}
@@ -840,8 +845,7 @@ wiz_map(VOID_ARGS)
HConfusion = save_Hconf;
HHallucination = save_Hhallu;
} else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_map)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_map)));
return 0;
}
@@ -852,8 +856,7 @@ wiz_genesis(VOID_ARGS)
if (wizard)
(void) create_particular();
else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_genesis)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_genesis)));
return 0;
}
@@ -864,8 +867,7 @@ wiz_where(VOID_ARGS)
if (wizard)
(void) print_dungeon(FALSE, (schar *) 0, (xchar *) 0);
else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_where)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_where)));
return 0;
}
@@ -876,8 +878,7 @@ wiz_detect(VOID_ARGS)
if (wizard)
(void) findit();
else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_detect)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_detect)));
return 0;
}
@@ -888,8 +889,7 @@ wiz_level_tele(VOID_ARGS)
if (wizard)
level_tele();
else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_level_tele)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_level_tele)));
return 0;
}
@@ -1444,8 +1444,7 @@ wiz_intrinsic(VOID_ARGS)
free((genericptr_t) pick_list);
doredraw();
} else
pline("Unavailable command '%s'.",
visctrl((int) cmd_from_func(wiz_intrinsic)));
pline(unavailcmd, visctrl((int) cmd_from_func(wiz_intrinsic)));
return 0;
}
@@ -3304,16 +3303,21 @@ struct ext_func_tab extcmdlist[] = {
{ '^', "seetrap", "show the type of adjacent trap", doidtrap, IFBURIED },
{ WEAPON_SYM, "seeweapon", "show the weapon currently wielded",
doprwep, IFBURIED },
#ifdef SHELL
{ '!', "shell", "do a shell escape", dosh, IFBURIED | GENERALCMD },
{ '!', "shell", "do a shell escape",
dosh_core, IFBURIED | GENERALCMD
#ifndef SHELL
| CMD_NOT_AVAILABLE
#endif /* SHELL */
},
{ M('s'), "sit", "sit down", dosit, AUTOCOMPLETE },
{ '\0', "stats", "show memory statistics",
wiz_show_stats, IFBURIED | AUTOCOMPLETE | WIZMODECMD },
#ifdef SUSPEND
{ C('z'), "suspend", "suspend the game",
dosuspend_core, IFBURIED | GENERALCMD },
dosuspend_core, IFBURIED | GENERALCMD
#ifndef SUSPEND
| CMD_NOT_AVAILABLE
#endif /* SUSPEND */
},
{ 'x', "swap", "swap wielded and secondary weapons", doswapweapon },
{ 'T', "takeoff", "take off one piece of armor", dotakeoff },
{ 'A', "takeoffall", "remove all armor", doddoremarm },
@@ -3407,6 +3411,14 @@ const char *command;
if (strcmp(command, extcmd->ef_txt))
continue;
Cmd.commands[key] = extcmd;
#if 0 /* silently accept key binding for unavailable command (!SHELL,&c) */
if ((extcmd->flags & CMD_NOT_AVAILABLE) != 0) {
char buf[BUFSZ];
Sprintf(buf, cmdnotavail, extcmd->ef_txt);
config_error_add("%s", buf);
}
#endif
return TRUE;
}
@@ -5504,10 +5516,7 @@ parse()
if (iflags.debug_fuzzer /* if fuzzing, override '!' and ^Z */
&& (Cmd.commands[foo & 0x0ff]
&& (Cmd.commands[foo & 0x0ff]->ef_funct == dosuspend_core
#ifdef SHELL
|| Cmd.commands[foo & 0x0ff]->ef_funct == dosh
#endif
)))
|| Cmd.commands[foo & 0x0ff]->ef_funct == dosh_core)))
foo = Cmd.spkeys[NHKF_ESC];
if (foo == Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */
@@ -5666,19 +5675,26 @@ readchar()
return (char) sym;
}
/* '_' command, #travel, via keyboard rather than mouse click */
STATIC_PTR int
dotravel(VOID_ARGS)
{
/* Keyboard travel command */
static char cmd[2];
coord cc;
/* [FIXME? Supporting the ability to disable traveling via mouse
click makes some sense, depending upon overall mouse usage.
Disabling '_' on a user by user basis makes no sense at all since
even if it is typed by accident, aborting when picking a target
destination is trivial. Travel via mouse predates travel via '_',
and this use of OPTION=!travel is probably just a mistake....] */
if (!flags.travelcmd)
return 0;
cmd[1] = 0;
cc.x = iflags.travelcc.x;
cc.y = iflags.travelcc.y;
if (cc.x == -1 && cc.y == -1) {
if (cc.x == 0 && cc.y == 0) {
/* No cached destination, start attempt from current position */
cc.x = u.ux;
cc.y = u.uy;
@@ -5789,8 +5805,9 @@ const char *prompt;
return confirmed_ok;
}
int
dosuspend_core()
/* ^Z command, #suspend */
STATIC_PTR int
dosuspend_core(VOID_ARGS)
{
#ifdef SUSPEND
/* Does current window system support suspend? */
@@ -5799,7 +5816,20 @@ dosuspend_core()
dosuspend();
} else
#endif
Norep("Suspend command not available.");
Norep(cmdnotavail, "#suspend");
return 0;
}
/* '!' command, #shell */
STATIC_PTR int
dosh_core(VOID_ARGS)
{
#ifdef SHELL
/* access restrictions, if any, are handled in port code */
dosh();
#else
Norep(cmdnotavail, "#shell");
#endif
return 0;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do.c $NHDT-Date: 1543052696 2018/11/24 09:44:56 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.175 $ */
/* NetHack 3.6 do.c $NHDT-Date: 1543972190 2018/12/05 01:09:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.176 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1244,6 +1244,17 @@ boolean at_stairs, falling, portal;
if(dropleveltempsfn) (*dropleveltempsfn)();
#endif
/* discard context which applies to the level we're leaving;
for lock-picking, container may be carried, in which case we
keep context; if on the floor, it's about to be saved+freed and
maybe_reset_pick() needs to do its carried() check before that */
maybe_reset_pick();
reset_trapset(); /* even if to-be-armed trap obj is accompanying hero */
iflags.travelcc.x = iflags.travelcc.y = 0; /* travel destination cache */
context.polearm.hitmon = (struct monst *) 0; /* polearm target */
/* digging context is level-aware and can actually be resumed if
hero returns to the previous level without any intervening dig */
if (falling) /* assuming this is only trap door or hole */
impact_drop((struct obj *) 0, u.ux, u.uy, newlevel->dlevel);
@@ -1600,14 +1611,6 @@ boolean at_stairs, falling, portal;
/* assume this will always return TRUE when changing level */
(void) in_out_region(u.ux, u.uy);
(void) pickup(1);
/* discard context which applied to previous level */
maybe_reset_pick(); /* for door or for box not accompanying hero */
reset_trapset(); /* even if to-be-armed trap obj is accompanying hero */
iflags.travelcc.x = iflags.travelcc.y = -1; /* travel destination cache */
context.polearm.hitmon = (struct monst *) 0; /* polearm target */
/* digging context is level-aware and can actually be resumed if
hero returns to the previous level without any intervening dig */
}
STATIC_OVL void

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 dothrow.c $NHDT-Date: 1525012611 2018/04/29 14:36:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.137 $ */
/* NetHack 3.6 dothrow.c $NHDT-Date: 1543892215 2018/12/04 02:56:55 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.152 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2013. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1652,13 +1652,16 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
}
if (tmp >= dieroll) {
boolean wasthrown = (thrownobj != 0);
boolean wasthrown = (thrownobj != 0),
/* remember weapon attribute; hmon() might destroy obj */
chopper = is_axe(obj);
/* attack hits mon */
if (hmode == HMON_APPLIED)
u.uconduct.weaphit++;
if (hmon(mon, obj, hmode, dieroll)) { /* mon still alive */
cutworm(mon, bhitpos.x, bhitpos.y, obj);
if (mon->wormno)
cutworm(mon, bhitpos.x, bhitpos.y, chopper);
}
exercise(A_DEX, TRUE);
/* if hero was swallowed and projectile killed the engulfer,
@@ -1668,8 +1671,9 @@ register struct obj *obj; /* thrownobj or kickedobj or uwep */
if (wasthrown && !thrownobj)
return 1;
/* projectiles other than magic stones
sometimes disappear when thrown */
/* projectiles other than magic stones sometimes disappear
when thrown; projectiles aren't among the types of weapon
that hmon() might have destroyed so obj is intact */
if (objects[otyp].oc_skill < P_NONE
&& objects[otyp].oc_skill > -P_BOOMERANG
&& !objects[otyp].oc_magic) {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 hack.c $NHDT-Date: 1540591769 2018/10/26 22:09:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.194 $ */
/* NetHack 3.6 hack.c $NHDT-Date: 1543972190 2018/12/05 01:09:50 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.200 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -923,7 +923,7 @@ int mode;
u.dx = u.tx - u.ux;
u.dy = u.ty - u.uy;
nomul(0);
iflags.travelcc.x = iflags.travelcc.y = -1;
iflags.travelcc.x = iflags.travelcc.y = 0;
}
return TRUE;
}
@@ -1045,7 +1045,7 @@ int mode;
nomul(0);
/* reset run so domove run checks work */
context.run = 8;
iflags.travelcc.x = iflags.travelcc.y = -1;
iflags.travelcc.x = iflags.travelcc.y = 0;
}
return TRUE;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1543395749 2018/11/28 09:02:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.334 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1543972192 2018/12/05 01:09:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.335 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -747,8 +747,6 @@ initoptions_init()
warnsyms[i] = def_warnsyms[i].sym;
iflags.bouldersym = 0;
iflags.travelcc.x = iflags.travelcc.y = -1;
/* for "special achievement" tracking (see obj.h,
create_object(sp_lev.c), addinv_core1(invent.c) */
iflags.mines_prize_type = LUCKSTONE;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 restore.c $NHDT-Date: 1542798626 2018/11/21 11:10:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.109 $ */
/* NetHack 3.6 restore.c $NHDT-Date: 1543972193 2018/12/05 01:09:53 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.128 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -539,6 +539,7 @@ unsigned int *stuckid, *steedid;
#ifdef SYSFLAGS
struct sysflag newgamesysflags;
#endif
struct context_info newgamecontext; /* all 0, but has some pointers */
struct obj *otmp, *tmp_bc;
char timebuf[15];
unsigned long uid;
@@ -553,9 +554,15 @@ unsigned int *stuckid, *steedid;
if (!wizard)
return FALSE;
}
newgamecontext = context; /* copy statically init'd context */
mread(fd, (genericptr_t) &context, sizeof (struct context_info));
if (context.warntype.speciesidx >= LOW_PM)
context.warntype.species = &mons[context.warntype.speciesidx];
context.warntype.species = (context.warntype.speciesidx >= LOW_PM)
? &mons[context.warntype.speciesidx]
: (struct permonst *) 0;
/* context.victual.piece, .tin.tin, .spellbook.book, and .polearm.hitmon
are pointers which get set to Null during save and will be recovered
via corresponding o_id or m_id while objs or mons are being restored */
/* we want to be able to revert to command line/environment/config
file option values instead of keeping old save file option values
@@ -625,6 +632,7 @@ unsigned int *stuckid, *steedid;
#ifdef SYSFLAGS
sysflags = newgamesysflags;
#endif
context = newgamecontext;
return FALSE;
}
/* in case hangup save occurred in midst of level change */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 save.c $NHDT-Date: 1489192905 2017/03/11 00:41:45 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.101 $ */
/* NetHack 3.6 save.c $NHDT-Date: 1543972194 2018/12/05 01:09:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.115 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1035,37 +1035,22 @@ register struct obj *otmp;
if (Has_contents(otmp))
saveobjchn(fd, otmp->cobj, mode);
if (release_data(mode)) {
/* if (otmp->oclass == FOOD_CLASS)
* food_disappears(otmp);
*/
/*
* If these are on the floor, the discarding could
* be because of a game save, or we could just be changing levels.
* If these are on the floor, the discarding could be
* due to game save, or we could just be changing levels.
* Always invalidate the pointer, but ensure that we have
* the o_id in order to restore the pointer on reload.
*/
if (otmp == context.victual.piece) {
/* Store the o_id of the victual if mismatched */
if (context.victual.o_id != otmp->o_id)
context.victual.o_id = otmp->o_id;
/* invalidate the pointer; on reload it will get restored */
context.victual.o_id = otmp->o_id;
context.victual.piece = (struct obj *) 0;
}
if (otmp == context.tin.tin) {
/* Store the o_id of your tin */
if (context.tin.o_id != otmp->o_id)
context.tin.o_id = otmp->o_id;
/* invalidate the pointer; on reload it will get restored */
context.tin.o_id = otmp->o_id;
context.tin.tin = (struct obj *) 0;
}
/* if (otmp->oclass == SPBOOK_CLASS)
* book_disappears(otmp);
*/
if (otmp == context.spbook.book) {
/* Store the o_id of your spellbook */
if (context.spbook.o_id != otmp->o_id)
context.spbook.o_id = otmp->o_id;
/* invalidate the pointer; on reload it will get restored */
context.spbook.o_id = otmp->o_id;
context.spbook.book = (struct obj *) 0;
}
otmp->where = OBJ_FREE; /* set to free so dealloc will work */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 uhitm.c $NHDT-Date: 1542765366 2018/11/21 01:56:06 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.185 $ */
/* NetHack 3.6 uhitm.c $NHDT-Date: 1543892215 2018/12/04 02:56:55 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.195 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2012. */
/* NetHack may be freely redistributed. See license for details. */
@@ -449,7 +449,9 @@ int rollneeded, armorpenalty; /* for monks */
struct attack *uattk;
int dieroll;
{
register boolean malive = TRUE;
boolean malive = TRUE,
/* hmon() might destroy weapon; remember aspect for cutworm */
slice_or_chop = (weapon && (is_blade(weapon) || is_axe(weapon)));
if (override_confirmation) {
/* this may need to be generalized if weapons other than
@@ -490,7 +492,7 @@ int dieroll;
u.uconduct.weaphit = oldweaphit;
}
if (mon->wormno && *mhit)
cutworm(mon, x, y, weapon);
cutworm(mon, x, y, slice_or_chop);
}
}
return malive;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 worm.c $NHDT-Date: 1456528599 2016/02/26 23:16:39 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */
/* NetHack 3.6 worm.c $NHDT-Date: 1543892216 2018/12/04 02:56:56 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.28 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2009. */
/* NetHack may be freely redistributed. See license for details. */
@@ -314,10 +314,10 @@ register struct monst *worm;
* that both halves will survive.
*/
void
cutworm(worm, x, y, weap)
cutworm(worm, x, y, cuttier)
struct monst *worm;
xchar x, y;
struct obj *weap;
boolean cuttier; /* hit is by wielded blade or axe or by thrown axe */
{
register struct wseg *curr, *new_tail;
register struct monst *new_worm;
@@ -330,12 +330,10 @@ struct obj *weap;
if (x == worm->mx && y == worm->my)
return; /* hit on head */
/* cutting goes best with a bladed weapon */
cut_chance = rnd(20); /* Normally 1-16 does not cut */
/* Normally 17-20 does */
if (weap && is_blade(weap)) /* With a blade 1- 6 does not cut */
cut_chance += 10; /* 7-20 does */
/* cutting goes best with a cuttier weapon */
cut_chance = rnd(20); /* Normally 1-16 does not cut, 17-20 does, */
if (cuttier)
cut_chance += 10; /* with a blade 1- 6 does not cut, 7-20 does. */
if (cut_chance < 17)
return; /* not good enough */