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:
54
src/lock.c
54
src/lock.c
@@ -600,7 +600,7 @@ pick_lock(struct obj *pick,
|
||||
return PICKLOCK_DID_SOMETHING;
|
||||
}
|
||||
|
||||
/* try to force a chest with your weapon */
|
||||
/* the #force command - try to force a chest with your weapon */
|
||||
int
|
||||
doforce(void)
|
||||
{
|
||||
@@ -610,7 +610,7 @@ doforce(void)
|
||||
|
||||
if (u.uswallow) {
|
||||
You_cant("force anything from inside here.");
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
if (!uwep /* proper type test */
|
||||
|| ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
|
||||
@@ -623,18 +623,18 @@ doforce(void)
|
||||
: (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))
|
||||
? "without a proper"
|
||||
: "with that");
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
if (!can_reach_floor(TRUE)) {
|
||||
cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
picktyp = is_blade(uwep) && !is_pick(uwep);
|
||||
if (g.xlock.usedtime && g.xlock.box && picktyp == g.xlock.picktyp) {
|
||||
You("resume your attempt to force the lock.");
|
||||
set_occupation(forcelock, "forcing the lock", 0);
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
/* A lock is made only for the honest man, the thief will break it. */
|
||||
@@ -658,7 +658,7 @@ doforce(void)
|
||||
|
||||
c = ynq(qbuf);
|
||||
if (c == 'q')
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
if (c == 'n')
|
||||
continue;
|
||||
|
||||
@@ -678,7 +678,7 @@ doforce(void)
|
||||
set_occupation(forcelock, "forcing the lock", 0);
|
||||
else
|
||||
You("decide not to force the issue.");
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
boolean
|
||||
@@ -694,7 +694,7 @@ stumble_on_door_mimic(int x, int y)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* the 'O' command - try to open a door */
|
||||
/* the #open command - try to open a door */
|
||||
int
|
||||
doopen(void)
|
||||
{
|
||||
@@ -708,35 +708,35 @@ doopen_indir(int x, int y)
|
||||
coord cc;
|
||||
register struct rm *door;
|
||||
boolean portcullis;
|
||||
int res = 0;
|
||||
int res = ECMD_OK;
|
||||
|
||||
if (nohands(g.youmonst.data)) {
|
||||
You_cant("open anything -- you have no hands!");
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
if (u.utrap && u.utraptype == TT_PIT) {
|
||||
You_cant("reach over the edge of the pit.");
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
if (x > 0 && y > 0) {
|
||||
cc.x = x;
|
||||
cc.y = y;
|
||||
} else if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc))
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
|
||||
/* open at yourself/up/down */
|
||||
if ((cc.x == u.ux) && (cc.y == u.uy))
|
||||
return doloot();
|
||||
|
||||
if (stumble_on_door_mimic(cc.x, cc.y))
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
|
||||
/* when choosing a direction is impaired, use a turn
|
||||
regardless of whether a door is successfully targetted */
|
||||
if (Confusion || Stunned)
|
||||
res = 1;
|
||||
res = ECMD_TIME;
|
||||
|
||||
door = &levl[cc.x][cc.y];
|
||||
portcullis = (is_drawbridge_wall(cc.x, cc.y) >= 0);
|
||||
@@ -747,7 +747,7 @@ doopen_indir(int x, int y)
|
||||
feel_location(cc.x, cc.y);
|
||||
if (door->glyph != oldglyph
|
||||
|| g.lastseentyp[cc.x][cc.y] != oldlastseentyp)
|
||||
res = 1; /* learned something */
|
||||
res = ECMD_TIME; /* learned something */
|
||||
}
|
||||
|
||||
if (portcullis || !IS_DOOR(door->typ)) {
|
||||
@@ -786,7 +786,7 @@ doopen_indir(int x, int y)
|
||||
}
|
||||
pline("This door%s.", mesg);
|
||||
if (locked && flags.autounlock && (unlocktool = autokey(TRUE)) != 0) {
|
||||
res = pick_lock(unlocktool, cc.x, cc.y, (struct obj *) 0);
|
||||
res = pick_lock(unlocktool, cc.x, cc.y, (struct obj *) 0) ? ECMD_TIME : ECMD_OK;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -813,7 +813,7 @@ doopen_indir(int x, int y)
|
||||
pline_The("door resists!");
|
||||
}
|
||||
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
static boolean
|
||||
@@ -848,45 +848,45 @@ obstructed(register int x, register int y, boolean quietly)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* the 'C' command - try to close a door */
|
||||
/* the #close command - try to close a door */
|
||||
int
|
||||
doclose(void)
|
||||
{
|
||||
register int x, y;
|
||||
register struct rm *door;
|
||||
boolean portcullis;
|
||||
int res = 0;
|
||||
int res = ECMD_OK;
|
||||
|
||||
if (nohands(g.youmonst.data)) {
|
||||
You_cant("close anything -- you have no hands!");
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
if (u.utrap && u.utraptype == TT_PIT) {
|
||||
You_cant("reach over the edge of the pit.");
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
}
|
||||
|
||||
if (!getdir((char *) 0))
|
||||
return 0;
|
||||
return ECMD_OK;
|
||||
|
||||
x = u.ux + u.dx;
|
||||
y = u.uy + u.dy;
|
||||
if ((x == u.ux) && (y == u.uy)) {
|
||||
You("are in the way!");
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
if (!isok(x, y))
|
||||
goto nodoor;
|
||||
|
||||
if (stumble_on_door_mimic(x, y))
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
|
||||
/* when choosing a direction is impaired, use a turn
|
||||
regardless of whether a door is successfully targetted */
|
||||
if (Confusion || Stunned)
|
||||
res = 1;
|
||||
res = ECMD_TIME;
|
||||
|
||||
door = &levl[x][y];
|
||||
portcullis = (is_drawbridge_wall(x, y) >= 0);
|
||||
@@ -896,7 +896,7 @@ doclose(void)
|
||||
|
||||
feel_location(x, y);
|
||||
if (door->glyph != oldglyph || g.lastseentyp[x][y] != oldlastseentyp)
|
||||
res = 1; /* learned something */
|
||||
res = ECMD_TIME; /* learned something */
|
||||
}
|
||||
|
||||
if (portcullis || !IS_DOOR(door->typ)) {
|
||||
@@ -942,7 +942,7 @@ doclose(void)
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
/* box obj was hit with spell or wand effect otmp;
|
||||
|
||||
Reference in New Issue
Block a user