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:
+5
-4
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 decl.h $NHDT-Date: 1496531104 2017/06/03 23:05:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.82 $ */
|
/* NetHack 3.6 decl.h $NHDT-Date: 1547025154 2019/01/09 09:12:34 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.147 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Michael Allison, 2007. */
|
/*-Copyright (c) Michael Allison, 2007. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -247,9 +247,10 @@ E NEARDATA struct obj *migrating_objs;
|
|||||||
E NEARDATA struct obj *billobjs;
|
E NEARDATA struct obj *billobjs;
|
||||||
E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj;
|
E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj;
|
||||||
|
|
||||||
E NEARDATA struct obj zeroobj; /* for init; &zeroobj used as special value */
|
E NEARDATA const struct obj zeroobj; /* for init; also, &zeroobj is used
|
||||||
|
* as special value */
|
||||||
|
|
||||||
E NEARDATA anything zeroany; /* init'd and defined in decl.c */
|
E NEARDATA const anything zeroany; /* init'd and defined in decl.c */
|
||||||
|
|
||||||
#include "you.h"
|
#include "you.h"
|
||||||
E NEARDATA struct you u;
|
E NEARDATA struct you u;
|
||||||
@@ -261,7 +262,7 @@ E NEARDATA struct u_realtime urealtime;
|
|||||||
#include "pm.h"
|
#include "pm.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
E NEARDATA struct monst zeromonst; /* for init of new or temp monsters */
|
E NEARDATA const struct monst zeromonst; /* for init of new or temp monsters */
|
||||||
E NEARDATA struct monst youmonst; /* monster details when hero is poly'd */
|
E NEARDATA struct monst youmonst; /* monster details when hero is poly'd */
|
||||||
E NEARDATA struct monst *mydogs, *migrating_mons;
|
E NEARDATA struct monst *mydogs, *migrating_mons;
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 decl.c $NHDT-Date: 1446975463 2015/11/08 09:37:43 $ $NHDT-Branch: master $:$NHDT-Revision: 1.62 $ */
|
/* NetHack 3.6 decl.c $NHDT-Date: 1547025164 2019/01/09 09:12:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.141 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Michael Allison, 2009. */
|
/*-Copyright (c) Michael Allison, 2009. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -198,10 +198,10 @@ NEARDATA struct obj *migrating_objs = (struct obj *) 0;
|
|||||||
NEARDATA struct obj *billobjs = (struct obj *) 0;
|
NEARDATA struct obj *billobjs = (struct obj *) 0;
|
||||||
|
|
||||||
/* used to zero all elements of a struct obj and a struct monst */
|
/* used to zero all elements of a struct obj and a struct monst */
|
||||||
NEARDATA struct obj zeroobj = DUMMY;
|
NEARDATA const struct obj zeroobj = DUMMY;
|
||||||
NEARDATA struct monst zeromonst = DUMMY;
|
NEARDATA const struct monst zeromonst = DUMMY;
|
||||||
/* used to zero out union any; initializer deliberately omitted */
|
/* used to zero out union any; initializer deliberately omitted */
|
||||||
NEARDATA anything zeroany;
|
NEARDATA const anything zeroany;
|
||||||
|
|
||||||
/* originally from dog.c */
|
/* originally from dog.c */
|
||||||
NEARDATA char dogname[PL_PSIZ] = DUMMY;
|
NEARDATA char dogname[PL_PSIZ] = DUMMY;
|
||||||
|
|||||||
+3
-3
@@ -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) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Derek S. Ray, 2015. */
|
/*-Copyright (c) Derek S. Ray, 2015. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -1702,7 +1702,7 @@ register const char *let, *word;
|
|||||||
You("mime %s something%s%s.", ing_suffix(bp), suf ? " " : "",
|
You("mime %s something%s%s.", ing_suffix(bp), suf ? " " : "",
|
||||||
suf ? 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
|
/* since gold is now kept in inventory, we need to do processing for
|
||||||
@@ -1735,7 +1735,7 @@ redo_menu:
|
|||||||
if (!ilet)
|
if (!ilet)
|
||||||
continue;
|
continue;
|
||||||
if (ilet == HANDS_SYM)
|
if (ilet == HANDS_SYM)
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj; /* cast away 'const' */
|
||||||
if (ilet == '\033') {
|
if (ilet == '\033') {
|
||||||
if (flags.verbose)
|
if (flags.verbose)
|
||||||
pline1(Never_mind);
|
pline1(Never_mind);
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 muse.c $NHDT-Date: 1539804880 2018/10/17 19:34:40 $ $NHDT-Branch: keni-makedefsm $:$NHDT-Revision: 1.85 $ */
|
/* NetHack 3.6 muse.c $NHDT-Date: 1547025167 2019/01/09 09:12:47 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.92 $ */
|
||||||
/* Copyright (C) 1990 by Ken Arromdee */
|
/* Copyright (C) 1990 by Ken Arromdee */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -2412,7 +2412,7 @@ boolean by_you;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (t && t->ttyp == FIRE_TRAP)
|
if (t && t->ttyp == FIRE_TRAP)
|
||||||
return muse_unslime(mon, &zeroobj, t, by_you);
|
return muse_unslime(mon, (struct obj *) &zeroobj, t, by_you);
|
||||||
|
|
||||||
} /* MUSE */
|
} /* MUSE */
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 objnam.c $NHDT-Date: 1546687293 2019/01/05 11:21:33 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.232 $ */
|
/* NetHack 3.6 objnam.c $NHDT-Date: 1547025168 2019/01/09 09:12:48 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.233 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -3583,7 +3583,7 @@ wiztrap:
|
|||||||
(trap != MAGIC_PORTAL) ? "" : " to nowhere");
|
(trap != MAGIC_PORTAL) ? "" : " to nowhere");
|
||||||
} else
|
} else
|
||||||
pline("Creation of %s failed.", an(tname));
|
pline("Creation of %s failed.", an(tname));
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* furniture and terrain */
|
/* furniture and terrain */
|
||||||
@@ -3596,20 +3596,20 @@ wiztrap:
|
|||||||
lev->blessedftn = 1;
|
lev->blessedftn = 1;
|
||||||
pline("A %sfountain.", lev->blessedftn ? "magic " : "");
|
pline("A %sfountain.", lev->blessedftn ? "magic " : "");
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
if (!BSTRCMPI(bp, p - 6, "throne")) {
|
if (!BSTRCMPI(bp, p - 6, "throne")) {
|
||||||
lev->typ = THRONE;
|
lev->typ = THRONE;
|
||||||
pline("A throne.");
|
pline("A throne.");
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
if (!BSTRCMPI(bp, p - 4, "sink")) {
|
if (!BSTRCMPI(bp, p - 4, "sink")) {
|
||||||
lev->typ = SINK;
|
lev->typ = SINK;
|
||||||
level.flags.nsinks++;
|
level.flags.nsinks++;
|
||||||
pline("A sink.");
|
pline("A sink.");
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
/* ("water" matches "potion of water" rather than terrain) */
|
/* ("water" matches "potion of water" rather than terrain) */
|
||||||
if (!BSTRCMPI(bp, p - 4, "pool") || !BSTRCMPI(bp, p - 4, "moat")) {
|
if (!BSTRCMPI(bp, p - 4, "pool") || !BSTRCMPI(bp, p - 4, "moat")) {
|
||||||
@@ -3619,7 +3619,7 @@ wiztrap:
|
|||||||
/* Must manually make kelp! */
|
/* Must manually make kelp! */
|
||||||
water_damage_chain(level.objects[x][y], TRUE);
|
water_damage_chain(level.objects[x][y], TRUE);
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
if (!BSTRCMPI(bp, p - 4, "lava")) { /* also matches "molten lava" */
|
if (!BSTRCMPI(bp, p - 4, "lava")) { /* also matches "molten lava" */
|
||||||
lev->typ = LAVAPOOL;
|
lev->typ = LAVAPOOL;
|
||||||
@@ -3628,7 +3628,7 @@ wiztrap:
|
|||||||
if (!(Levitation || Flying))
|
if (!(Levitation || Flying))
|
||||||
(void) lava_effects();
|
(void) lava_effects();
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BSTRCMPI(bp, p - 5, "altar")) {
|
if (!BSTRCMPI(bp, p - 5, "altar")) {
|
||||||
@@ -3648,7 +3648,7 @@ wiztrap:
|
|||||||
lev->altarmask = Align2amask(al);
|
lev->altarmask = Align2amask(al);
|
||||||
pline("%s altar.", An(align_str(al)));
|
pline("%s altar.", An(align_str(al)));
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BSTRCMPI(bp, p - 5, "grave")
|
if (!BSTRCMPI(bp, p - 5, "grave")
|
||||||
@@ -3657,7 +3657,7 @@ wiztrap:
|
|||||||
pline("%s.", IS_GRAVE(lev->typ) ? "A grave"
|
pline("%s.", IS_GRAVE(lev->typ) ? "A grave"
|
||||||
: "Can't place a grave here");
|
: "Can't place a grave here");
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BSTRCMPI(bp, p - 4, "tree")) {
|
if (!BSTRCMPI(bp, p - 4, "tree")) {
|
||||||
@@ -3665,14 +3665,14 @@ wiztrap:
|
|||||||
pline("A tree.");
|
pline("A tree.");
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
block_point(x, y);
|
block_point(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!BSTRCMPI(bp, p - 4, "bars")) {
|
if (!BSTRCMPI(bp, p - 4, "bars")) {
|
||||||
lev->typ = IRONBARS;
|
lev->typ = IRONBARS;
|
||||||
pline("Iron bars.");
|
pline("Iron bars.");
|
||||||
newsym(x, y);
|
newsym(x, y);
|
||||||
return &zeroobj;
|
return (struct obj *) &zeroobj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3690,7 +3690,7 @@ wiztrap:
|
|||||||
return ((struct obj *) 0);
|
return ((struct obj *) 0);
|
||||||
any:
|
any:
|
||||||
if (!oclass)
|
if (!oclass)
|
||||||
oclass = wrpsym[rn2((int) sizeof(wrpsym))];
|
oclass = wrpsym[rn2((int) sizeof wrpsym)];
|
||||||
typfnd:
|
typfnd:
|
||||||
if (typ)
|
if (typ)
|
||||||
oclass = objects[typ].oc_class;
|
oclass = objects[typ].oc_class;
|
||||||
@@ -3981,7 +3981,7 @@ typfnd:
|
|||||||
|| (otmp->oartifact && rn2(nartifact_exist()) > 1)) && !wizard) {
|
|| (otmp->oartifact && rn2(nartifact_exist()) > 1)) && !wizard) {
|
||||||
artifact_exists(otmp, safe_oname(otmp), FALSE);
|
artifact_exists(otmp, safe_oname(otmp), FALSE);
|
||||||
obfree(otmp, (struct obj *) 0);
|
obfree(otmp, (struct obj *) 0);
|
||||||
otmp = &zeroobj;
|
otmp = (struct obj *) &zeroobj;
|
||||||
pline("For a moment, you feel %s in your %s, but it disappears!",
|
pline("For a moment, you feel %s in your %s, but it disappears!",
|
||||||
something, makeplural(body_part(HAND)));
|
something, makeplural(body_part(HAND)));
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-10
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 weapon.c $NHDT-Date: 1545964580 2018/12/28 02:36:20 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.67 $ */
|
/* NetHack 3.6 weapon.c $NHDT-Date: 1547025169 2019/01/09 09:12:49 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.68 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
/*-Copyright (c) Robert Patrick Rankin, 2011. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
@@ -402,7 +402,7 @@ register struct monst *mtmp;
|
|||||||
|
|
||||||
char mlet = mtmp->data->mlet;
|
char mlet = mtmp->data->mlet;
|
||||||
|
|
||||||
propellor = &zeroobj;
|
propellor = (struct obj *) &zeroobj;
|
||||||
Oselect(EGG); /* cockatrice egg */
|
Oselect(EGG); /* cockatrice egg */
|
||||||
if (mlet == S_KOP) /* pies are first choice for Kops */
|
if (mlet == S_KOP) /* pies are first choice for Kops */
|
||||||
Oselect(CREAM_PIE);
|
Oselect(CREAM_PIE);
|
||||||
@@ -461,25 +461,25 @@ register struct monst *mtmp;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* KMH -- This belongs here so darts will work */
|
/* KMH -- This belongs here so darts will work */
|
||||||
propellor = &zeroobj;
|
propellor = (struct obj *) &zeroobj;
|
||||||
|
|
||||||
prop = (objects[rwep[i]]).oc_skill;
|
prop = objects[rwep[i]].oc_skill;
|
||||||
if (prop < 0) {
|
if (prop < 0) {
|
||||||
switch (-prop) {
|
switch (-prop) {
|
||||||
case P_BOW:
|
case P_BOW:
|
||||||
propellor = (oselect(mtmp, YUMI));
|
propellor = oselect(mtmp, YUMI);
|
||||||
if (!propellor)
|
if (!propellor)
|
||||||
propellor = (oselect(mtmp, ELVEN_BOW));
|
propellor = oselect(mtmp, ELVEN_BOW);
|
||||||
if (!propellor)
|
if (!propellor)
|
||||||
propellor = (oselect(mtmp, BOW));
|
propellor = oselect(mtmp, BOW);
|
||||||
if (!propellor)
|
if (!propellor)
|
||||||
propellor = (oselect(mtmp, ORCISH_BOW));
|
propellor = oselect(mtmp, ORCISH_BOW);
|
||||||
break;
|
break;
|
||||||
case P_SLING:
|
case P_SLING:
|
||||||
propellor = (oselect(mtmp, SLING));
|
propellor = oselect(mtmp, SLING);
|
||||||
break;
|
break;
|
||||||
case P_CROSSBOW:
|
case P_CROSSBOW:
|
||||||
propellor = (oselect(mtmp, CROSSBOW));
|
propellor = oselect(mtmp, CROSSBOW);
|
||||||
}
|
}
|
||||||
if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != propellor
|
if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != propellor
|
||||||
&& mtmp->weapon_check == NO_WEAPON_WANTED)
|
&& mtmp->weapon_check == NO_WEAPON_WANTED)
|
||||||
@@ -681,6 +681,7 @@ register struct monst *mon;
|
|||||||
}
|
}
|
||||||
if (obj && obj != &zeroobj) {
|
if (obj && obj != &zeroobj) {
|
||||||
struct obj *mw_tmp = MON_WEP(mon);
|
struct obj *mw_tmp = MON_WEP(mon);
|
||||||
|
|
||||||
if (mw_tmp && mw_tmp->otyp == obj->otyp) {
|
if (mw_tmp && mw_tmp->otyp == obj->otyp) {
|
||||||
/* already wielding it */
|
/* already wielding it */
|
||||||
mon->weapon_check = NEED_WEAPON;
|
mon->weapon_check = NEED_WEAPON;
|
||||||
|
|||||||
Reference in New Issue
Block a user