Make extended commands return defined flags

Instead of returning 0 or 1, we'll now use ECMD_OK or ECMD_TURN.
These have the same meaning as the hardcoded numbers; ECMD_TURN
means the command uses a turn.

In future, could add eg. a flag denoting "user cancelled command"
or "command failed", and should clear eg. the cmdq.

Mostly this was simply replacing return values with the defines
in the extended commands, so hopefully I didn't break anything.
This commit is contained in:
Pasi Kallinen
2021-12-30 18:46:30 +02:00
parent 511ce70309
commit d53cd28d46
46 changed files with 821 additions and 793 deletions

View File

@@ -114,18 +114,18 @@ dowrite(struct obj *pen)
if (nohands(g.youmonst.data)) {
You("need hands to be able to write!");
return 0;
return ECMD_OK;
} else if (Glib) {
pline("%s from your %s.", Tobjnam(pen, "slip"),
fingers_or_gloves(FALSE));
dropx(pen);
return 1;
return ECMD_TIME;
}
/* get paper to write on */
paper = getobj("write on", write_ok, GETOBJ_NOFLAGS);
if (!paper)
return 0;
return ECMD_OK;
/* can't write on a novel (unless/until it's been converted into a blank
spellbook), but we want messages saying so to avoid "spellbook" */
typeword = (paper->otyp == SPE_NOVEL)
@@ -136,19 +136,19 @@ dowrite(struct obj *pen)
if (Blind) {
if (!paper->dknown) {
You("don't know if that %s is blank or not.", typeword);
return 0;
return ECMD_OK;
} else if (paper->oclass == SPBOOK_CLASS) {
/* can't write a magic book while blind */
pline("%s can't create braille text.",
upstart(ysimple_name(pen)));
return 0;
return ECMD_OK;
}
}
paper->dknown = 1;
if (paper->otyp != SCR_BLANK_PAPER && paper->otyp != SPE_BLANK_PAPER) {
pline("That %s is not blank!", typeword);
exercise(A_WIS, FALSE);
return 1;
return ECMD_TIME;
}
/* what to write */
@@ -156,7 +156,7 @@ dowrite(struct obj *pen)
getlin(qbuf, namebuf);
(void) mungspaces(namebuf); /* remove any excess whitespace */
if (namebuf[0] == '\033' || !namebuf[0])
return 1;
return ECMD_TIME;
nm = namebuf;
if (!strncmpi(nm, "scroll ", 7))
nm += 7;
@@ -213,21 +213,21 @@ dowrite(struct obj *pen)
}
There("is no such %s!", typeword);
return 1;
return ECMD_TIME;
found:
if (i == SCR_BLANK_PAPER || i == SPE_BLANK_PAPER) {
You_cant("write that!");
pline("It's obscene!");
return 1;
return ECMD_TIME;
} else if (i == SPE_BOOK_OF_THE_DEAD) {
pline("No mere dungeon adventurer could write that.");
return 1;
return ECMD_TIME;
} else if (by_descr && paper->oclass == SPBOOK_CLASS
&& !objects[i].oc_name_known) {
/* can't write unknown spellbooks by description */
pline("Unfortunately you don't have enough information to go on.");
return 1;
return ECMD_TIME;
}
/* KMH, conduct */
@@ -244,7 +244,7 @@ dowrite(struct obj *pen)
if (pen->spe < basecost / 2) {
Your("marker is too dry to write that!");
obfree(new_obj, (struct obj *) 0);
return 1;
return ECMD_TIME;
}
/* we're really going to write now, so calculate cost
@@ -265,7 +265,7 @@ dowrite(struct obj *pen)
useup(paper);
}
obfree(new_obj, (struct obj *) 0);
return 1;
return ECMD_TIME;
}
pen->spe -= actualcost;
@@ -314,7 +314,7 @@ dowrite(struct obj *pen)
useup(paper);
}
obfree(new_obj, (struct obj *) 0);
return 1;
return ECMD_TIME;
}
/* can write scrolls when blind, but requires luck too;
attempts to write books when blind are caught above */
@@ -327,7 +327,7 @@ dowrite(struct obj *pen)
You("fail to write the scroll correctly and it disappears.");
useup(paper);
obfree(new_obj, (struct obj *) 0);
return 1;
return ECMD_TIME;
}
/* useup old scroll / spellbook */
@@ -357,7 +357,7 @@ dowrite(struct obj *pen)
The(aobjnam(new_obj, "slip")),
(const char *) 0);
nhUse(new_obj); /* try to avoid complaint about dead assignment */
return 1;
return ECMD_TIME;
}
/* most book descriptions refer to cover appearance, so we can issue a