summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-29 00:08:13 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-08-29 00:08:13 +0800
commit426b7f33fa6dd881841bdc8209a4295520305a4c (patch)
tree41e7cfe02bf21bab25d90e74ad167f4334d3e4b0
parent4012bf960377f4281d2a47d22378e1b30f520190 (diff)
downloadpttbbs-426b7f33fa6dd881841bdc8209a4295520305a4c.tar
pttbbs-426b7f33fa6dd881841bdc8209a4295520305a4c.tar.gz
pttbbs-426b7f33fa6dd881841bdc8209a4295520305a4c.tar.bz2
pttbbs-426b7f33fa6dd881841bdc8209a4295520305a4c.tar.lz
pttbbs-426b7f33fa6dd881841bdc8209a4295520305a4c.tar.xz
pttbbs-426b7f33fa6dd881841bdc8209a4295520305a4c.tar.zst
pttbbs-426b7f33fa6dd881841bdc8209a4295520305a4c.zip
chc machine readable log update
* fix playing date * show result only when the game was completed git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3109 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/chc.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/mbbsd/chc.c b/mbbsd/chc.c
index ec42a460..3d9b2b82 100644
--- a/mbbsd/chc.c
+++ b/mbbsd/chc.c
@@ -359,7 +359,7 @@ chc_genlog(ChessInfo* info, FILE* fp, ChessGameResult result)
* http://www.elephantbase.net/protocol/cchess_pgn.htm */
{
/* machine readable header */
- time_t temp = (time_t)*clock;
+ time_t temp = (time_t) now;
struct tm *mytm = localtime(&temp);
fprintf(fp,
@@ -367,18 +367,23 @@ chc_genlog(ChessInfo* info, FILE* fp, ChessGameResult result)
"[Game \"Chinese Chess\"]\n"
"[Date \"%d.%d.%d\"]\n"
"[Red \"%s\"]\n"
- "[Black \"%s\"]\n"
- "[Result \"%s\"]\n"
- "[Notation \"Coord\"]\n"
- "[FEN \"rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/9/1C5C1/9/RN2K2NR"
- " r - - 0 1\"]\n",
+ "[Black \"%s\"]\n",
mytm->tm_year + 1900, mytm->tm_mon + 1, mytm->tm_mday,
info->myturn == RED ? info->user1.userid : info->user2.userid,
- info->myturn == RED ? info->user2.userid : info->user1.userid,
- result == CHESS_RESULT_TIE ? "0.5-0.5" :
- (info->myturn == RED) == (result== CHESS_RESULT_WIN) ?
- "1-0" : "0-1"
+ info->myturn == RED ? info->user2.userid : info->user1.userid
);
+
+ if (result == CHESS_RESULT_TIE || result == CHESS_RESULT_WIN ||
+ result == CHESS_RESULT_LOST)
+ fprintf(fp, "[Result \"%s\"]\n",
+ result == CHESS_RESULT_TIE ? "0.5-0.5" :
+ (info->myturn == RED) == (result== CHESS_RESULT_WIN) ?
+ "1-0" : "0-1");
+
+ fprintf(fp,
+ "[Notation \"Coord\"]\n"
+ "[FEN \"rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/9/1C5C1/9/RN2K2NR"
+ " r - - 0 1\"]\n");
}
chc_init_board(board);
for (i = 0; i < nStep - 1; i += 2) {