mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Unequal: Don't insist that solve moves must actually solve
A corrupt save file can include an "S" move that doesn't give a valid solution. An assertion failure ("execute_move: Assertion `rc > 0' failed.") at that point is rude, so now we just don't set the "completed" flag in that case. We still set the "cheated" flag, to reward (lack of) effort. Here's a trivial test case: SAVEFILE:41:Simon Tatham's Portable Puzzle Collection GAME :7:Unequal CPARAMS :1:3 PARAMS :1:3 DESC :17:0,0,0,0,0,0,0,0,0 NSTATES :1:2 STATEPOS:1:2 MOVE :10:S222222222
This commit is contained in:
@ -1652,7 +1652,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
|
|||||||
static game_state *execute_move(const game_state *state, const char *move)
|
static game_state *execute_move(const game_state *state, const char *move)
|
||||||
{
|
{
|
||||||
game_state *ret = NULL;
|
game_state *ret = NULL;
|
||||||
int x, y, n, i, rc;
|
int x, y, n, i;
|
||||||
|
|
||||||
debug(("execute_move: %s", move));
|
debug(("execute_move: %s", move));
|
||||||
|
|
||||||
@ -1677,7 +1677,7 @@ static game_state *execute_move(const game_state *state, const char *move)
|
|||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
ret = dup_game(state);
|
ret = dup_game(state);
|
||||||
ret->completed = ret->cheated = true;
|
ret->cheated = true;
|
||||||
|
|
||||||
p = move+1;
|
p = move+1;
|
||||||
for (i = 0; i < state->order*state->order; i++) {
|
for (i = 0; i < state->order*state->order; i++) {
|
||||||
@ -1688,8 +1688,8 @@ static game_state *execute_move(const game_state *state, const char *move)
|
|||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
if (*p) goto badmove;
|
if (*p) goto badmove;
|
||||||
rc = check_complete(ret->nums, ret, true);
|
if (!ret->completed && check_complete(ret->nums, ret, true) > 0)
|
||||||
assert(rc > 0);
|
ret->completed = true;
|
||||||
return ret;
|
return ret;
|
||||||
} else if (move[0] == 'M') {
|
} else if (move[0] == 'M') {
|
||||||
ret = dup_game(state);
|
ret = dup_game(state);
|
||||||
|
Reference in New Issue
Block a user