make zeroany, zeromonst, zeroobj 'const'

They're never modified.  Minor complication:  &zeroobj is used as
a special not-Null-but-not-an-object value in multiple places and
needs to have 'const' removed with a cast in that situation.
This commit is contained in:
PatR
2019-01-09 01:13:01 -08:00
parent d4e3f9d9d3
commit dd13b10cf2
6 changed files with 63 additions and 61 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 invent.c $NHDT-Date: 1546770988 2019/01/06 10:36:28 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.249 $ */
/* NetHack 3.6 invent.c $NHDT-Date: 1547025166 2019/01/09 09:12:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.250 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -426,7 +426,7 @@ const genericptr vptr2;
return val2 - val1; /* bigger is better */
}
tiebreak:
tiebreak:
/* They're identical, as far as we're concerned. We want
to force a deterministic order, and do so by producing a
stable sort: maintain the original order of equal items. */
@@ -938,7 +938,7 @@ struct obj *obj;
&& obj->oartifact != ART_MJOLLNIR
&& (throwing_weapon(obj) || is_ammo(obj)))
setuqwep(obj);
added:
added:
addinv_core2(obj);
carry_obj_effects(obj); /* carrying affects the obj */
update_inventory();
@@ -1702,9 +1702,9 @@ register const char *let, *word;
You("mime %s something%s%s.", ing_suffix(bp), suf ? " " : "",
suf ? suf : "");
}
return (allownone ? &zeroobj : (struct obj *) 0);
return (allownone ? (struct obj *) &zeroobj : (struct obj *) 0);
}
redo_menu:
redo_menu:
/* since gold is now kept in inventory, we need to do processing for
select-from-invent before checking whether gold has been picked */
if (ilet == '?' || ilet == '*') {
@@ -1735,7 +1735,7 @@ redo_menu:
if (!ilet)
continue;
if (ilet == HANDS_SYM)
return &zeroobj;
return (struct obj *) &zeroobj; /* cast away 'const' */
if (ilet == '\033') {
if (flags.verbose)
pline1(Never_mind);
@@ -2139,7 +2139,7 @@ int FDECL((*fn), (OBJ_P)), FDECL((*ckfn), (OBJ_P));
* For example, if a person specifies =/ then first all rings
* will be asked about followed by all wands. -dgk
*/
nextclass:
nextclass:
ilet = 'a' - 1;
if (*objchn && (*objchn)->oclass == COIN_CLASS)
ilet--; /* extra iteration */
@@ -2249,7 +2249,7 @@ nextclass:
pline("That was all.");
else if (!dud && !cnt)
pline("No applicable objects.");
ret:
ret:
unsortloot(&sortedchn);
bypass_objlist(*objchn, FALSE);
return cnt;
@@ -2670,7 +2670,7 @@ long *out_cnt;
add_menu(win, NO_GLYPH, &any, HANDS_SYM, 0, ATR_NONE,
xtra_choice, MENU_UNSELECTED);
}
nextclass:
nextclass:
classcount = 0;
for (srtinv = sortedinvent; (otmp = srtinv->obj) != 0; ++srtinv) {
if (lets && !index(lets, otmp->invlet))
@@ -4101,7 +4101,7 @@ doorganize() /* inventory organizer by Del Lamb */
compatible stacks get collected along the way,
but splitting to same slot is not */
|| (splitting && let == obj->invlet)) {
noadjust:
noadjust:
if (splitting)
(void) merged(&splitting, &obj);
if (!ever_mind)