diff --git a/include/extern.h b/include/extern.h index ccd54c605..e4c2f82fe 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1542798602 2018/11/21 11:10:02 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.650 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1543185068 2018/11/25 22:31:08 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.663 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -431,7 +431,8 @@ E struct obj *FDECL(realloc_obj, (struct obj *, int, genericptr_t, int, const char *)); E char *FDECL(coyotename, (struct monst *, char *)); E char *FDECL(rndorcname, (char *)); -E struct monst *FDECL(christen_orc, (struct monst *, char *, char *)); +E struct monst *FDECL(christen_orc, (struct monst *, const char *, + const char *)); E const char *FDECL(noveltitle, (int *)); E const char *FDECL(lookup_novel, (const char *, int *)); diff --git a/src/do_name.c b/src/do_name.c index e2e249b93..88735f6e1 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do_name.c $NHDT-Date: 1537477563 2018/09/20 21:06:03 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.132 $ */ +/* NetHack 3.6 do_name.c $NHDT-Date: 1543185069 2018/11/25 22:31:09 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.136 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2090,19 +2090,21 @@ char *s; struct monst * christen_orc(mtmp, gang, other) struct monst *mtmp; -char *gang, *other; +const char *gang, *other; { int sz = 0; char buf[BUFSZ], buf2[BUFSZ], *orcname; orcname = rndorcname(buf2); sz = (int) ((gang ? strlen(gang) : other ? strlen(other) : 0) - + strlen(orcname) + sizeof " of " - sizeof ""); + + strlen(orcname) + sizeof " of " - sizeof ""); if (sz < BUFSZ) { + char gbuf[BUFSZ]; boolean nameit = FALSE; if (gang && orcname) { - Sprintf(buf, "%s of %s", upstart(orcname), upstart(gang)); + Sprintf(buf, "%s of %s", upstart(orcname), + upstart(strcpy(gbuf, gang))); nameit = TRUE; } else if (other && orcname) { Sprintf(buf, "%s%s", upstart(orcname), other); diff --git a/src/dokick.c b/src/dokick.c index 3274b15e9..68eb49c24 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 dokick.c $NHDT-Date: 1541842623 2018/11/10 09:37:03 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.122 $ */ +/* NetHack 3.6 dokick.c $NHDT-Date: 1543185070 2018/11/25 22:31:10 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.128 $ */ /* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1704,10 +1704,12 @@ unsigned long deliverflags; /* special treatment for orcs and their kind */ if ((otmp->corpsenm & M2_ORC) != 0 && has_oname(otmp)) { if (!has_mname(mtmp)) { - if (at_crime_scene || (!at_crime_scene && !rn2(2))) + if (at_crime_scene || !rn2(2)) mtmp = christen_orc(mtmp, - at_crime_scene ? ONAME(otmp) : (char *) 0, - " the Fence"); /* bought the stolen goods */ + at_crime_scene ? ONAME(otmp) + : (char *) 0, + /* bought the stolen goods */ + " the Fence"); } free_oname(otmp); } diff --git a/src/mkmaze.c b/src/mkmaze.c index 1dd52cb98..863502baf 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkmaze.c $NHDT-Date: 1537477570 2018/09/20 21:06:10 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.61 $ */ +/* NetHack 3.6 mkmaze.c $NHDT-Date: 1543185071 2018/11/25 22:31:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.67 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -705,9 +705,10 @@ int otyp; const char *gang; { struct obj *otmp; + otmp = mksobj_migr_to_species(otyp, (unsigned long) M2_ORC, FALSE, FALSE); if (otmp && gang) { - new_oname(otmp, strlen(gang) + 1); /* removes old name if one is present */ + new_oname(otmp, strlen(gang) + 1); /* removes old name if present */ Strcpy(ONAME(otmp), gang); if (otyp >= TRIPE_RATION && otyp <= TIN) { if (otyp == SLIME_MOLD) diff --git a/src/pager.c b/src/pager.c index 894d3e7d5..27d274adc 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pager.c $NHDT-Date: 1537477571 2018/09/20 21:06:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.129 $ */ +/* NetHack 3.6 pager.c $NHDT-Date: 1543185072 2018/11/25 22:31:12 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.139 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1397,7 +1397,7 @@ boolean without_asking; } if (yes_to_moreinfo) { int i, subs = 0; - char *gang = (char *) 0; + const char *gang = (char *) 0; if (bp) { textp = suptext1; diff --git a/src/pickup.c b/src/pickup.c index d68def38d..65a541d12 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pickup.c $NHDT-Date: 1542798625 2018/11/21 11:10:25 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.202 $ */ +/* NetHack 3.6 pickup.c $NHDT-Date: 1543188989 2018/11/25 23:36:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.220 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -24,6 +24,7 @@ STATIC_DCL boolean FDECL(allow_cat_no_uchain, (struct obj *)); #endif STATIC_DCL int FDECL(autopick, (struct obj *, int, menu_item **)); STATIC_DCL int FDECL(count_categories, (struct obj *, int)); +STATIC_DCL int FDECL(delta_cwt, (struct obj *, struct obj *)); STATIC_DCL long FDECL(carry_count, (struct obj *, struct obj *, long, BOOLEAN_P, int *, int *)); STATIC_DCL int FDECL(lift_object, (struct obj *, struct obj *, long *, @@ -49,15 +50,6 @@ STATIC_DCL void FDECL(tipcontainer, (struct obj *)); #define FOLLOW(curr, flags) \ (((flags) & BY_NEXTHERE) ? (curr)->nexthere : (curr)->nobj) -/* - * How much the weight of the given container will change when the given - * object is removed from it. This calculation must match the one used - * by weight() in mkobj.c. - */ -#define DELTA_CWT(cont, obj) \ - ((cont)->cursed ? (obj)->owt * 2 : (cont)->blessed \ - ? ((obj)->owt + 3) / 4 \ - : ((obj)->owt + 1) / 2) #define GOLD_WT(n) (((n) + 50L) / 100L) /* if you can figure this out, give yourself a hearty pat on the back... */ #define GOLD_CAPACITY(w, n) (((w) * -100L) - ((n) + 50L) - 1L) @@ -1205,6 +1197,37 @@ int qflags; return ccount; } +/* + * How much the weight of the given container will change when the given + * object is removed from it. Use before and after weight amounts rather + * than trying to match the calculation used by weight() in mkobj.c. + */ +STATIC_OVL int +delta_cwt(container, obj) +struct obj *container, *obj; +{ + struct obj **prev; + int owt, nwt; + + if (container->otyp != BAG_OF_HOLDING) + return obj->owt; + + owt = nwt = container->owt; + /* find the object so that we can remove it */ + for (prev = &container->cobj; *prev; prev = &(*prev)->nobj) + if (*prev == obj) + break; + if (!*prev) { + panic("delta_cwt: obj not inside container?"); + } else { + /* temporarily remove the object and calculate resulting weight */ + *prev = obj->nobj; + nwt = weight(container); + *prev = obj; /* put the object back; obj->nobj is still valid */ + } + return owt - nwt; +} + /* could we carry `obj'? if not, could we carry some of it/them? */ STATIC_OVL long carry_count(obj, container, count, telekinesis, wt_before, wt_after) @@ -1232,9 +1255,7 @@ int *wt_before, *wt_after; } wt = iw + (int) obj->owt; if (adjust_wt) - wt -= (container->otyp == BAG_OF_HOLDING) - ? (int) DELTA_CWT(container, obj) - : (int) obj->owt; + wt -= delta_cwt(container, obj); /* This will go with silver+copper & new gold weight */ if (is_gold) /* merged gold might affect cumulative weight */ wt -= (GOLD_WT(umoney) + GOLD_WT(count) - GOLD_WT(umoney + count)); @@ -1262,9 +1283,7 @@ int *wt_before, *wt_after; obj->quan = qq; obj->owt = (unsigned) GOLD_WT(qq); ow = (int) GOLD_WT(umoney + qq); - ow -= (container->otyp == BAG_OF_HOLDING) - ? (int) DELTA_CWT(container, obj) - : (int) obj->owt; + ow -= delta_cwt(container, obj); if (iw + ow >= 0) break; oow = ow; @@ -1289,9 +1308,7 @@ int *wt_before, *wt_after; obj->quan = qq; obj->owt = (unsigned) (ow = weight(obj)); if (adjust_wt) - ow -= (container->otyp == BAG_OF_HOLDING) - ? (int) DELTA_CWT(container, obj) - : (int) obj->owt; + ow -= delta_cwt(container, obj); if (iw + ow >= 0) break; wt = iw + ow;