diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-22 22:26:19 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-22 22:26:19 +0800 |
commit | f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7 (patch) | |
tree | b0e430ca957ad9ca19a535440ec922e56c4609f5 | |
parent | 88ca4f26404ab5eab6f103f66c611d60fbea6534 (diff) | |
download | pttbbs-f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7.tar pttbbs-f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7.tar.gz pttbbs-f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7.tar.bz2 pttbbs-f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7.tar.lz pttbbs-f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7.tar.xz pttbbs-f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7.tar.zst pttbbs-f575e3fb30bbb08a3dadc230b3ca03cd08a1f7c7.zip |
Fix SIGABRT when watching chc.
Thanks to blackmajisha.bbs@ptt.cc and AMONAMON.bbs@ptt.cc for
helping locating problem.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3072 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/chc.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 45c2bb47..0dbe3514 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -530,7 +530,7 @@ chc_canmove(board_t board, rc_t from, rc_t to) } /* §ä turn's king ªº®y¼Ð */ -static void +static int findking(board_t board, int turn, rc_t * buf) { int i, r, c; @@ -541,9 +541,10 @@ findking(board_t board, int turn, rc_t * buf) if (CHE_P(board[r][c]) == KIND_K && CHE_O(board[r][c]) == turn) { buf->r = r, buf->c = c; - return; + return 1; } - assert_not_reached(); + /* one's king may be eaten */ + return 0; } static int @@ -551,8 +552,8 @@ chc_iskfk(board_t board) { rc_t from, to; - findking(board, BLK, &to); - findking(board, RED, &from); + if (!findking(board, BLK, &to)) return 0; + if (!findking(board, RED, &from)) return 0; if (from.c == to.c && between(board, from, to, 0) == 0) return 1; return 0; @@ -563,7 +564,7 @@ chc_ischeck(board_t board, int turn) { rc_t from, to; - findking(board, turn, &to); + if (!findking(board, turn, &to)) return 0; for (from.r = 0; from.r < BRD_ROW; from.r++) for (from.c = 0; from.c < BRD_COL; from.c++) if (board[from.r][from.c] && |