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:
59
src/dokick.c
59
src/dokick.c
@@ -759,6 +759,7 @@ kickstr(char *buf, const char *kickobjnam)
|
||||
return strcat(strcpy(buf, "kicking "), what);
|
||||
}
|
||||
|
||||
/* the #kick command */
|
||||
int
|
||||
dokick(void)
|
||||
{
|
||||
@@ -780,9 +781,9 @@ dokick(void)
|
||||
if (yn_function("Kick your steed?", ynchars, 'y') == 'y') {
|
||||
You("kick %s.", mon_nam(u.usteed));
|
||||
kick_steed();
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else {
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
} else if (Wounded_legs) {
|
||||
legs_in_no_shape("kicking", FALSE);
|
||||
@@ -817,13 +818,13 @@ dokick(void)
|
||||
if (no_kick) {
|
||||
/* ignore direction typed before player notices kick failed */
|
||||
display_nhwindow(WIN_MESSAGE, TRUE); /* --More-- */
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
if (!getdir((char *) 0))
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
if (!u.dx && !u.dy)
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
|
||||
x = u.ux + u.dx;
|
||||
y = u.uy + u.dy;
|
||||
@@ -849,11 +850,11 @@ dokick(void)
|
||||
Your("feeble kick has no effect.");
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else if (u.utrap && u.utraptype == TT_PIT) {
|
||||
/* must be Passes_walls */
|
||||
You("kick at the side of the pit.");
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (Levitation) {
|
||||
int xx, yy;
|
||||
@@ -868,7 +869,7 @@ dokick(void)
|
||||
&& !IS_DOOR(levl[xx][yy].typ)
|
||||
&& (!Is_airlevel(&u.uz) || !OBJ_AT(xx, yy))) {
|
||||
You("have nothing to brace yourself against.");
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,7 +881,7 @@ dokick(void)
|
||||
if (mtmp) {
|
||||
oldglyph = glyph_at(x, y);
|
||||
if (!maybe_kick_monster(mtmp, x, y))
|
||||
return g.context.move;
|
||||
return (g.context.move ? ECMD_TIME : ECMD_OK);
|
||||
}
|
||||
|
||||
wake_nearby();
|
||||
@@ -940,13 +941,13 @@ dokick(void)
|
||||
range = 1;
|
||||
hurtle(-u.dx, -u.dy, range, TRUE);
|
||||
}
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
(void) unmap_invisible(x, y);
|
||||
if (is_pool(x, y) ^ !!u.uinwater) {
|
||||
/* objects normally can't be removed from water by kicking */
|
||||
You("splash some %s around.", hliquid("water"));
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
if (OBJ_AT(x, y) && (!Levitation || Is_airlevel(&u.uz)
|
||||
@@ -954,7 +955,7 @@ dokick(void)
|
||||
if (kick_object(x, y, kickobjnam)) {
|
||||
if (Is_airlevel(&u.uz))
|
||||
hurtle(-u.dx, -u.dy, 1, TRUE); /* assume it's light */
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
goto ouch;
|
||||
}
|
||||
@@ -980,7 +981,7 @@ dokick(void)
|
||||
if (g.maploc->doormask == D_ISOPEN
|
||||
|| g.maploc->doormask == D_NODOOR)
|
||||
unblock_point(x, y); /* vision */
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else
|
||||
goto ouch;
|
||||
}
|
||||
@@ -991,7 +992,7 @@ dokick(void)
|
||||
g.maploc->typ = CORR;
|
||||
feel_newsym(x, y); /* we know it's gone */
|
||||
unblock_point(x, y); /* vision */
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else
|
||||
goto ouch;
|
||||
}
|
||||
@@ -1010,7 +1011,7 @@ dokick(void)
|
||||
newsym(x, y);
|
||||
}
|
||||
exercise(A_DEX, TRUE);
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else if (Luck > 0 && !rn2(3) && !g.maploc->looted) {
|
||||
(void) mkgold((long) rn1(201, 300), x, y);
|
||||
i = Luck + 1;
|
||||
@@ -1028,11 +1029,11 @@ dokick(void)
|
||||
}
|
||||
/* prevent endless milking */
|
||||
g.maploc->looted = T_LOOTED;
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else if (!rn2(4)) {
|
||||
if (dunlev(&u.uz) < dunlevs_in_dungeon(&u.uz)) {
|
||||
fall_through(FALSE, 0);
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else
|
||||
goto ouch;
|
||||
}
|
||||
@@ -1046,7 +1047,7 @@ dokick(void)
|
||||
if (!rn2(3))
|
||||
goto ouch;
|
||||
exercise(A_DEX, TRUE);
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (IS_FOUNTAIN(g.maploc->typ)) {
|
||||
if (Levitation)
|
||||
@@ -1061,7 +1062,7 @@ dokick(void)
|
||||
/* could cause short-lived fumbling here */
|
||||
}
|
||||
exercise(A_DEX, TRUE);
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (IS_GRAVE(g.maploc->typ)) {
|
||||
if (Levitation)
|
||||
@@ -1083,7 +1084,7 @@ dokick(void)
|
||||
pline_The("headstone topples over and breaks!");
|
||||
newsym(x, y);
|
||||
}
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
if (g.maploc->typ == IRONBARS)
|
||||
goto ouch;
|
||||
@@ -1121,7 +1122,7 @@ dokick(void)
|
||||
exercise(A_WIS, TRUE); /* discovered a new food source! */
|
||||
newsym(x, y);
|
||||
g.maploc->looted |= TREE_LOOTED;
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else if (!(g.maploc->looted & TREE_SWARM)) {
|
||||
int cnt = rnl(4) + 2;
|
||||
int made = 0;
|
||||
@@ -1140,7 +1141,7 @@ dokick(void)
|
||||
else
|
||||
You("smell stale honey.");
|
||||
g.maploc->looted |= TREE_SWARM;
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
goto ouch;
|
||||
}
|
||||
@@ -1155,7 +1156,7 @@ dokick(void)
|
||||
else
|
||||
pline("Klunk!");
|
||||
exercise(A_DEX, TRUE);
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else if (!(g.maploc->looted & S_LPUDDING) && !rn2(3)
|
||||
&& !(g.mvitals[PM_BLACK_PUDDING].mvflags & G_GONE)) {
|
||||
if (Blind)
|
||||
@@ -1167,7 +1168,7 @@ dokick(void)
|
||||
exercise(A_DEX, TRUE);
|
||||
newsym(x, y);
|
||||
g.maploc->looted |= S_LPUDDING;
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else if (!(g.maploc->looted & S_LDWASHER) && !rn2(3)
|
||||
&& !(g.mvitals[PM_AMOROUS_DEMON].mvflags & G_GONE)) {
|
||||
/* can't resist... */
|
||||
@@ -1178,7 +1179,7 @@ dokick(void)
|
||||
newsym(x, y);
|
||||
g.maploc->looted |= S_LDWASHER;
|
||||
exercise(A_DEX, TRUE);
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
} else if (!rn2(3)) {
|
||||
if (Blind && Deaf)
|
||||
Sprintf(buf, " %s", body_part(FACE));
|
||||
@@ -1199,7 +1200,7 @@ dokick(void)
|
||||
exercise(A_WIS, TRUE); /* a discovery! */
|
||||
g.maploc->looted |= S_LRING;
|
||||
}
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
goto ouch;
|
||||
}
|
||||
@@ -1227,7 +1228,7 @@ dokick(void)
|
||||
losehp(Maybe_Half_Phys(dmg), kickstr(buf, kickobjnam), KILLED_BY);
|
||||
if (Is_airlevel(&u.uz) || Levitation)
|
||||
hurtle(-u.dx, -u.dy, rn1(2, 4), TRUE); /* assume it's heavy */
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
goto dumb;
|
||||
}
|
||||
@@ -1247,7 +1248,7 @@ dokick(void)
|
||||
}
|
||||
if ((Is_airlevel(&u.uz) || Levitation) && rn2(2))
|
||||
hurtle(-u.dx, -u.dy, 1, TRUE);
|
||||
return 1; /* uses a turn */
|
||||
return ECMD_TIME; /* uses a turn */
|
||||
}
|
||||
|
||||
/* not enough leverage to kick open doors while levitating */
|
||||
@@ -1314,7 +1315,7 @@ dokick(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user