diff --git a/doc/fixes36.3 b/doc/fixes36.3 index f9781a9a8..71572a441 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -177,6 +177,7 @@ avoid 'object lost' panic when polymorph causes loss of levitation boots or over but buffered output didn't show it until hero stopped, so it wasn't possible to tell where they were, unlike all other forms of multiple movement; stop running if/when an engraving is reached +fix exploding land mine moving ball or chain and causing a sanity error Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository diff --git a/include/prop.h b/include/prop.h index ba0dc0863..570f3f2fa 100644 --- a/include/prop.h +++ b/include/prop.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 prop.h $NHDT-Date: 1547514641 2019/01/15 01:10:41 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.20 $ */ +/* NetHack 3.6 prop.h $NHDT-Date: 1570566360 2019/10/08 20:26:00 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.21 $ */ /* Copyright (c) 1989 Mike Threepoint */ /* NetHack may be freely redistributed. See license for details. */ @@ -106,7 +106,7 @@ struct prop { #define W_WEP 0x00000100L /* Wielded weapon */ #define W_QUIVER 0x00000200L /* Quiver for (f)iring ammo */ #define W_SWAPWEP 0x00000400L /* Secondary weapon */ -#define W_WEAPON (W_WEP | W_SWAPWEP | W_QUIVER) +#define W_WEAPONS (W_WEP | W_SWAPWEP | W_QUIVER) #define W_ART 0x00001000L /* Carrying artifact (not really worn) */ #define W_ARTI 0x00002000L /* Invoked artifact (not really worn) */ /* Amulets, rings, tools, and other items */ diff --git a/src/ball.c b/src/ball.c index e7ab564d4..4a6c6b8c6 100644 --- a/src/ball.c +++ b/src/ball.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 ball.c $NHDT-Date: 1559601027 2019/06/03 22:30:27 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.40 $ */ +/* NetHack 3.6 ball.c $NHDT-Date: 1570566373 2019/10/08 20:26:13 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.43 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) David Cohrs, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1074,7 +1074,7 @@ bc_sanity_check() && uball->where != OBJ_FREE) || (freeball ^ freechain) || (uball->owornmask & W_BALL) == 0L - || (uball->owornmask & ~(W_BALL | W_WEAPON)) != 0L)) { + || (uball->owornmask & ~(W_BALL | W_WEAPONS)) != 0L)) { otyp = uball->otyp; onam = safe_typename(otyp); impossible("uball: type %d (%s), where %d, wornmask=0x%08lx", diff --git a/src/do_wear.c b/src/do_wear.c index ec9751c2c..4a3c5fade 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do_wear.c $NHDT-Date: 1559670603 2019/06/04 17:50:03 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.109 $ */ +/* NetHack 3.6 do_wear.c $NHDT-Date: 1570566377 2019/10/08 20:26:17 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.111 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1097,7 +1097,7 @@ struct obj *otmp; boolean already_blind = Blind, changed = FALSE; /* blindfold might be wielded; release it for wearing */ - if (otmp->owornmask & W_WEAPON) + if (otmp->owornmask & W_WEAPONS) remove_worn_item(otmp, FALSE); setworn(otmp, W_TOOL); on_msg(otmp); @@ -1915,7 +1915,7 @@ struct obj *obj; /* if the armor is wielded, release it for wearing (won't be welded even if cursed; that only happens for weapons/weptools) */ - if (obj->owornmask & W_WEAPON) + if (obj->owornmask & W_WEAPONS) remove_worn_item(obj, FALSE); /* * Setting obj->known=1 is done because setworn() causes hero's AC @@ -2541,7 +2541,7 @@ doddoremarm() possibly combined with weapons */ (void) strncpy(g.context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ); /* specific activity when handling weapons only */ - if (!(g.context.takeoff.mask & ~W_WEAPON)) + if (!(g.context.takeoff.mask & ~W_WEAPONS)) (void) strncpy(g.context.takeoff.disrobing, "disarming", CONTEXTVERBSZ); (void) take_off(); diff --git a/src/explode.c b/src/explode.c index 20b7a04b4..ff5b71bc2 100644 --- a/src/explode.c +++ b/src/explode.c @@ -621,6 +621,13 @@ struct obj *obj; /* only scatter this obj */ obj->ox, obj->oy, sx, sy); while ((otmp = (individual_object ? obj : g.level.objects[sx][sy])) != 0) { + if (otmp == uball || otmp == uchain) { + boolean waschain = (otmp == uchain); + pline_The("chain shatters!"); + unpunish(); + if (waschain) + continue; + } if (otmp->quan > 1L) { qtmp = otmp->quan - 1L; if (qtmp > LARGEST_INT) diff --git a/src/invent.c b/src/invent.c index e66929a49..9236528d2 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 invent.c $NHDT-Date: 1570232224 2019/10/04 23:37:04 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.263 $ */ +/* NetHack 3.6 invent.c $NHDT-Date: 1570566378 2019/10/08 20:26:18 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.264 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1884,7 +1884,7 @@ boolean is_worn(otmp) struct obj *otmp; { - return (otmp->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE | W_WEAPON)) + return (otmp->owornmask & (W_ARMOR | W_ACCESSORY | W_SADDLE | W_WEAPONS)) ? TRUE : FALSE; } diff --git a/src/makemon.c b/src/makemon.c index f38864433..1cc291e35 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 makemon.c $NHDT-Date: 1561236435 2019/06/22 20:47:15 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.138 $ */ +/* NetHack 3.6 makemon.c $NHDT-Date: 1570569787 2019/10/08 21:23:07 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.140 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -166,7 +166,7 @@ register struct monst *mtmp; register struct permonst *ptr = mtmp->data; register int mm = monsndx(ptr); struct obj *otmp; - int bias, spe2, w1, w2; + int bias, w1, w2; if (Is_rogue_level(&u.uz)) return; @@ -259,12 +259,10 @@ register struct monst *mtmp; } else if (ptr->msound == MS_PRIEST || quest_mon_represents_role(ptr, PM_PRIEST)) { otmp = mksobj(MACE, FALSE, FALSE); - if (otmp) { - otmp->spe = rnd(3); - if (!rn2(2)) - curse(otmp); - (void) mpickobj(mtmp, otmp); - } + otmp->spe = rnd(3); + if (!rn2(2)) + curse(otmp); + (void) mpickobj(mtmp, otmp); } else if (mm == PM_NINJA) { /* extra quest villains */ (void) mongets(mtmp, rn2(4) ? SHURIKEN : DART); (void) mongets(mtmp, rn2(4) ? SHORT_SWORD : AXE); @@ -336,14 +334,13 @@ register struct monst *mtmp; artiname(rn2(2) ? ART_DEMONBANE : ART_SUNSWORD)); bless(otmp); otmp->oerodeproof = TRUE; - spe2 = rn2(4); - otmp->spe = max(otmp->spe, spe2); + otmp->spe = rn2(4); (void) mpickobj(mtmp, otmp); otmp = mksobj(!rn2(4) || is_lord(ptr) ? SHIELD_OF_REFLECTION : LARGE_SHIELD, FALSE, FALSE); - otmp->cursed = FALSE; + /* uncurse(otmp); -- mksobj(,FALSE,) item is always uncursed */ otmp->oerodeproof = TRUE; otmp->spe = 0; (void) mpickobj(mtmp, otmp); diff --git a/src/mkobj.c b/src/mkobj.c index f8ef49c75..97c03edc4 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkobj.c $NHDT-Date: 1561588627 2019/06/26 22:37:07 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.151 $ */ +/* NetHack 3.6 mkobj.c $NHDT-Date: 1570569798 2019/10/08 21:23:18 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.153 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1064,6 +1064,7 @@ boolean artif; default: impossible("impossible mkobj %d, sym '%c'.", otmp->otyp, objects[otmp->otyp].oc_class); + dealloc_obj(otmp); /* free() would suffice here */ return (struct obj *) 0; } } @@ -2572,7 +2573,7 @@ struct obj *obj; } if (n == 2 && carried(obj) && obj == uball && (owornmask & W_BALL) != 0L - && (owornmask & W_WEAPON) != 0L) { + && (owornmask & W_WEAPONS) != 0L) { /* chained ball can be wielded/alt-wielded/quivered; if so, pretend it's not chained in order to check the weapon pointer (we've already verified the ball pointer by successfully passing @@ -2681,7 +2682,7 @@ struct obj *obj; becoming embedded in poly'd hero's skin */ if (embedded && !Is_dragon_scales(obj)) what = "skin"; - } else if (owornmask & W_WEAPON) { + } else if (owornmask & W_WEAPONS) { /* monsters don't maintain alternate weapon or quiver */ if (mcarried(obj) && (owornmask & (W_SWAPWEP | W_QUIVER)) != 0L) what = (owornmask & W_SWAPWEP) != 0L ? "monst alt weapon?" diff --git a/src/pickup.c b/src/pickup.c index e9aead0f2..4c1a51300 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pickup.c $NHDT-Date: 1570142736 2019/10/03 22:45:36 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.234 $ */ +/* NetHack 3.6 pickup.c $NHDT-Date: 1570566381 2019/10/08 20:26:21 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.235 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1194,7 +1194,8 @@ int qflags; for (curr = olist; curr; curr = FOLLOW(curr, qflags)) { if (curr->oclass == *pack) { if ((qflags & WORN_TYPES) - && !(curr->owornmask & (W_ARMOR | W_ACCESSORY | W_WEAPON))) + && !(curr->owornmask & (W_ARMOR | W_ACCESSORY + | W_WEAPONS))) continue; if (!counted_category) { ccount++; diff --git a/src/steal.c b/src/steal.c index 7988b0316..e170cc50d 100644 --- a/src/steal.c +++ b/src/steal.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 steal.c $NHDT-Date: 1562806584 2019/07/11 00:56:24 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.74 $ */ +/* NetHack 3.6 steal.c $NHDT-Date: 1570566382 2019/10/08 20:26:22 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.75 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -218,7 +218,7 @@ boolean unchain_ball; /* whether to unpunish or just unwield */ Ring_gone(obj); } else if (obj->owornmask & W_TOOL) { Blindf_off(obj); - } else if (obj->owornmask & W_WEAPON) { + } else if (obj->owornmask & W_WEAPONS) { if (obj == uwep) uwepgone(); if (obj == uswapwep) diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index e5f53f3fe..e82039841 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -377,6 +377,7 @@ curses_str_remainder(const char *str, int width, int line_num) int strsize = strlen(str) + 1; #if __STDC_VERSION__ >= 199901L char substr[strsize]; + char curstr[strsize]; char tmpstr[strsize]; strcpy(substr, str); @@ -385,6 +386,7 @@ curses_str_remainder(const char *str, int width, int line_num) #define BUFSZ 256 #endif char substr[BUFSZ * 2]; + char curstr[BUFSZ * 2]; char tmpstr[BUFSZ * 2]; if (strsize > (BUFSZ * 2) - 1) { @@ -412,6 +414,10 @@ curses_str_remainder(const char *str, int width, int line_num) if (last_space == 0) { /* No spaces found */ last_space = count - 1; } + for (count = 0; count < last_space; count++) { + curstr[count] = substr[count]; + } + curstr[count] = '\0'; if (substr[count] == '\0') { break; }