use gi.invalid_obj instead of cg.zeroobj
cg.zeroobj was originally added (under its previous unprefixed name)
for providing a one-line way to zero out the fields of a struct obj.
struct obj tempobj;
tempobj = cg.zeroobj;
initfn(struct obj *otmp)
{
if (otmp)
*otmp = cg.zeroobj;
}
More recently, the address of cg.zeroobj began to be used as a return
flag to indicate some things, but the 'const struct obj zeroobj' wasn't
an ideal fit for the purpose and required a number of casts, including
casting away const.
Provide a better fitting variable (gi.invalid_obj) and eliminate a
number of casts.
This commit is contained in:
@@ -532,7 +532,7 @@ doengrave(void)
|
||||
if (!otmp) /* otmp == cg.zeroobj if fingers */
|
||||
return ECMD_CANCEL;
|
||||
|
||||
if (otmp == &cg.zeroobj) {
|
||||
if (otmp == &gi.invalid_obj) {
|
||||
Strcat(strcpy(fbuf, "your "), body_part(FINGERTIP));
|
||||
writer = fbuf;
|
||||
} else {
|
||||
@@ -563,7 +563,7 @@ doengrave(void)
|
||||
return ECMD_OK;
|
||||
}
|
||||
if (IS_GRAVE(levl[u.ux][u.uy].typ)) {
|
||||
if (otmp == &cg.zeroobj) { /* using only finger */
|
||||
if (otmp == &gi.invalid_obj) { /* using only finger */
|
||||
You("would only make a small smudge on the %s.",
|
||||
surface(u.ux, u.uy));
|
||||
return ECMD_OK;
|
||||
@@ -1024,7 +1024,7 @@ doengrave(void)
|
||||
}
|
||||
|
||||
/* Tell adventurer what is going on */
|
||||
if (otmp != &cg.zeroobj)
|
||||
if (otmp != &gi.invalid_obj)
|
||||
You("%s the %s with %s.", everb, eloc, doname(otmp));
|
||||
else
|
||||
You("%s the %s with your %s.", everb, eloc, body_part(FINGERTIP));
|
||||
@@ -1131,7 +1131,7 @@ engrave(void)
|
||||
}
|
||||
/* Stylus might have been taken out of inventory and destroyed somehow.
|
||||
* Not safe to dereference stylus until after this. */
|
||||
if (gc.context.engraving.stylus == &cg.zeroobj) { /* bare finger */
|
||||
if (gc.context.engraving.stylus == &gi.invalid_obj) { /* bare finger */
|
||||
stylus = (struct obj *) 0;
|
||||
} else {
|
||||
for (stylus = gi.invent; stylus; stylus = stylus->nobj) {
|
||||
|
||||
Reference in New Issue
Block a user