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:
@@ -384,7 +384,7 @@ dowield(void)
|
||||
}
|
||||
|
||||
/* Handle no object, or object in other slot */
|
||||
if (wep == &cg.zeroobj) {
|
||||
if (wep == &gi.invalid_obj) {
|
||||
wep = (struct obj *) 0;
|
||||
} else if (wep == uswapwep) {
|
||||
return doswapweapon();
|
||||
@@ -516,7 +516,7 @@ doquiver_core(const char *verb) /* "ready" or "fire" */
|
||||
if (!newquiver) {
|
||||
/* Cancelled */
|
||||
return ECMD_CANCEL;
|
||||
} else if (newquiver == &cg.zeroobj) { /* no object */
|
||||
} else if (newquiver == &gi.invalid_obj) { /* no object */
|
||||
/* Explicitly nothing */
|
||||
if (uquiver) {
|
||||
You("now have no ammunition readied.");
|
||||
|
||||
Reference in New Issue
Block a user