summaryrefslogtreecommitdiffstats
path: root/mbbsd/gomo.c
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-23 21:16:43 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-01-23 21:16:43 +0800
commit253ffe32777fe96cf317ad3c9c94b0accd78e72f (patch)
tree1bcfbd60a8d8d19f50822fad54039cae0270593e /mbbsd/gomo.c
parent76e1eaf7912082c13829bab92b0a4974c2c824cf (diff)
downloadpttbbs-253ffe32777fe96cf317ad3c9c94b0accd78e72f.tar
pttbbs-253ffe32777fe96cf317ad3c9c94b0accd78e72f.tar.gz
pttbbs-253ffe32777fe96cf317ad3c9c94b0accd78e72f.tar.bz2
pttbbs-253ffe32777fe96cf317ad3c9c94b0accd78e72f.tar.lz
pttbbs-253ffe32777fe96cf317ad3c9c94b0accd78e72f.tar.xz
pttbbs-253ffe32777fe96cf317ad3c9c94b0accd78e72f.tar.zst
pttbbs-253ffe32777fe96cf317ad3c9c94b0accd78e72f.zip
Showing blank photo when either side has not joined chess country,
but showing original style when neither side has joined. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2422 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/gomo.c')
-rw-r--r--mbbsd/gomo.c57
1 files changed, 30 insertions, 27 deletions
diff --git a/mbbsd/gomo.c b/mbbsd/gomo.c
index 9980d9fc..c36a6b0e 100644
--- a/mbbsd/gomo.c
+++ b/mbbsd/gomo.c
@@ -339,28 +339,39 @@ gomoku(int fd)
draw_photo = 0;
setuserfile(genbuf, "photo_fivechess");
- if (dashf(genbuf)) {
+ if (dashf(genbuf))
+ draw_photo = 1;
+ else {
sethomefile(genbuf, my->mateid, "photo_fivechess");
if (dashf(genbuf))
draw_photo = 1;
}
getuser(my->mateid);
- if (draw_photo) { // XXX
+ if (draw_photo) {
int line;
FILE* fp;
+ const static char * const blank_photo[6] = {
+ "┌──────┐",
+ "│ 空 │",
+ "│ 白 │",
+ "│ 照 │",
+ "│ 片│",
+ "└──────┘"
+ };
setuserfile(genbuf, "photo_fivechess");
fp = fopen(genbuf, "r");
- if (fp == NULL)
- goto drawing_reference;
for (line = 2; line < 8; ++line) {
move(line, 37);
- if (fgets(genbuf, 200, fp)) {
- genbuf[strlen(genbuf) - 1] = 0;
- prints("%s ", genbuf);
+ if (fp != NULL) {
+ if (fgets(genbuf, 200, fp)) {
+ genbuf[strlen(genbuf) - 1] = 0;
+ prints("%s ", genbuf);
+ } else
+ outs(" ");
} else
- outs(" ");
+ outs(blank_photo[line - 2]);
switch (line - 2) {
case 0: prints("<代號> %s", cuser.userid); break;
@@ -371,7 +382,8 @@ gomoku(int fd)
case 5: prints("<來源> %.16s", cuser.lasthost); break;
}
}
- fclose(fp);
+ if (fp != NULL)
+ fclose(fp);
move(8, 43);
prints("\033[7m%s\033[m", me == BBLACK ? "黑棋" : "白棋");
@@ -382,8 +394,6 @@ gomoku(int fd)
sethomefile(genbuf, my->mateid, "photo_fivechess");
fp = fopen(genbuf, "r");
- if (fp == NULL)
- goto drawing_reference;
for (line = 11; line < 17; ++line) {
move(line, 37);
switch (line - 11) {
@@ -395,28 +405,21 @@ gomoku(int fd)
case 5: prints("<來源> %-16.16s ", xuser.lasthost); break;
}
- if (fgets(genbuf, 200, fp)) {
- genbuf[strlen(genbuf) - 1] = 0;
- outs(genbuf);
+ if (fp != NULL) {
+ if (fgets(genbuf, 200, fp)) {
+ genbuf[strlen(genbuf) - 1] = 0;
+ outs(genbuf);
+ } else
+ outs(" ");
} else
- outs(" ");
+ outs(blank_photo[line - 11]);
}
- fclose(fp);
+ if (fp != NULL)
+ fclose(fp);
move(18, 4);
prints("我是 %s", me == BBLACK ? "先手 ●,有禁手" : "後手 ○");
} else {
-drawing_reference:
-
- if (draw_photo) { // jump from `if' block
- int i;
- for (i = 2; i < 11; ++i) {
- move(i, 37);
- clrtoeol();
- }
- draw_photo = 0;
- }
-
move(3, 40); outs("[q] 認輸離開");
move(4, 40); outs("[u] 悔棋");
move(5, 40); outs("[p] 要求和棋");