diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-09 05:50:42 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-09 05:50:42 +0800 |
commit | e28a0fc596acffdfc640501707ba71d3ccd2e17d (patch) | |
tree | afc6c2f805753bb53f1f6634c4e574d199405e51 | |
parent | a8d6240a1db56b86073d284ee5abf433e8d283d5 (diff) | |
download | pttbbs-e28a0fc596acffdfc640501707ba71d3ccd2e17d.tar pttbbs-e28a0fc596acffdfc640501707ba71d3ccd2e17d.tar.gz pttbbs-e28a0fc596acffdfc640501707ba71d3ccd2e17d.tar.bz2 pttbbs-e28a0fc596acffdfc640501707ba71d3ccd2e17d.tar.lz pttbbs-e28a0fc596acffdfc640501707ba71d3ccd2e17d.tar.xz pttbbs-e28a0fc596acffdfc640501707ba71d3ccd2e17d.tar.zst pttbbs-e28a0fc596acffdfc640501707ba71d3ccd2e17d.zip |
Fix r3015.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3017 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/chc.c | 15 | ||||
-rw-r--r-- | mbbsd/chess.c | 17 |
2 files changed, 21 insertions, 11 deletions
diff --git a/mbbsd/chc.c b/mbbsd/chc.c index 101079c1..4daa1c7a 100644 --- a/mbbsd/chc.c +++ b/mbbsd/chc.c @@ -37,7 +37,7 @@ typedef struct { } chc_tag_data_t; /* chess framework action functions */ -static void chc_init_user(const userec_t *userec, ChessUser *user); +static void chc_init_user(const userinfo_t *userec, ChessUser *user); static void chc_init_board(const ChessInfo* info, board_t board); static void chc_drawline(const ChessInfo* info, int line); static void chc_movecur(int r, int c); @@ -362,7 +362,7 @@ chc_drawline(const ChessInfo* info, int line) ANSI_COLOR(34) "%2d" ANSI_COLOR(37) "±Ñ " ANSI_COLOR(36) "%2d" ANSI_COLOR(37) "©M" ANSI_RESET, info->user2.userid, - info->user2.win, info->user2.lose - 1, info->user2.tie); + info->user2.win, info->user2.lose, info->user2.tie); } } } @@ -698,7 +698,7 @@ chcusr_put(userec_t* userec, const ChessUser* user) } static void -chc_init_user(const userec_t *userec, ChessUser *user) +chc_init_user(const userinfo_t *uinfo, ChessUser *user) { strlcpy(user->userid, userec->userid, sizeof(user->userid)); user->win = userec->chc_win; @@ -863,6 +863,15 @@ chc(int s, ChessGameMode mode) info->board = board; info->tag = &tag; + if (info->mode == CHESS_MODE_VERSUS) { + /* Assume that info->user1 is me. */ + info->user1.lose++; + count_chess_elo_rating(&info->user1, &info->user2, 0.0); + passwd_query(usernum, &cuser); + chcusr_put(&cuser, &info->user1); + passwd_update(usernum, &cuser); + } + if (mode == CHESS_MODE_WATCH) setutmpmode(CHESSWATCHING); else diff --git a/mbbsd/chess.c b/mbbsd/chess.c index f866d4c4..04a05f03 100644 --- a/mbbsd/chess.c +++ b/mbbsd/chess.c @@ -885,8 +885,8 @@ ChessWatchGame(void (*play)(int, ChessGameMode), int game, const char* title) static void ChessInitUser(ChessInfo* info) { - char userid[2][IDLEN + 1]; - userec_t xuser; + char userid[2][IDLEN + 1]; + const userinfo_t* uinfo; if (info->mode == CHESS_MODE_PERSONAL) { strlcpy(userid[0], cuser.userid, sizeof(userid[0])); @@ -897,15 +897,16 @@ ChessInitUser(ChessInfo* info) strlcpy(userid[0], uinfo->userid, sizeof(userid[0])); strlcpy(userid[1], uinfo->mateid, sizeof(userid[1])); } - else { + else if (info->mode == CHESS_MODE_VERSUS) { strlcpy(userid[0], cuser.userid, sizeof(userid[0])); strlcpy(userid[1], currutmp->mateid, sizeof(userid[1])); - } + } else + assert_not_reached(); - getuser(userid[0], &xuser); - info->actions->init_user(&xuser, &info->user1); - getuser(userid[1], &xuser); - info->actions->init_user(&xuser, &info->user2); + uinfo = search_ulist_userid(userid[0]); + info->actions->init_user(uinfo, &info->user1); + uinfo = search_ulist_userid(userid[1]); + info->actions->init_user(uinfo, &info->user2); } static char* |