summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-08-20 23:51:45 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-08-20 23:51:45 +0800
commit46a79dde2118135b7e78c3df9315a4d8bd41a298 (patch)
tree19d9435697b5bcea6660d599c65b0f8624fd5c9a
parentc9a012bd5ba0cab8b69565ae814821273793491d (diff)
downloadpttbbs-46a79dde2118135b7e78c3df9315a4d8bd41a298.tar
pttbbs-46a79dde2118135b7e78c3df9315a4d8bd41a298.tar.gz
pttbbs-46a79dde2118135b7e78c3df9315a4d8bd41a298.tar.bz2
pttbbs-46a79dde2118135b7e78c3df9315a4d8bd41a298.tar.lz
pttbbs-46a79dde2118135b7e78c3df9315a4d8bd41a298.tar.xz
pttbbs-46a79dde2118135b7e78c3df9315a4d8bd41a298.tar.zst
pttbbs-46a79dde2118135b7e78c3df9315a4d8bd41a298.zip
prevent opening file error
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1112 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/gamble.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c
index eb42d085..4e2f348f 100644
--- a/mbbsd/gamble.c
+++ b/mbbsd/gamble.c
@@ -291,13 +291,15 @@ openticket(int bid)
while (fscanf(fp1, "%s %d %d\n", userid, &mybet, &i) != EOF) {
if (bet == 98 && mybet >= 0 && mybet < count) {
- fprintf(fp, "%s 買了 %d 張 %s, 退回 %d 枚P幣\n"
- ,userid, i, betname[mybet], money * i);
+ if (fp)
+ fprintf(fp, "%s 買了 %d 張 %s, 退回 %d 枚P幣\n"
+ ,userid, i, betname[mybet], money * i);
snprintf(buf, sizeof(buf),
"%s 賭場退錢! $ %d", bh->brdname, money * i);
} else if (mybet == bet) {
- fprintf(fp, "恭喜 %s 買了%d 張 %s, 獲得 %d 枚P幣\n"
- ,userid, i, betname[mybet], money * i);
+ if (fp)
+ fprintf(fp, "恭喜 %s 買了%d 張 %s, 獲得 %d 枚P幣\n"
+ ,userid, i, betname[mybet], money * i);
snprintf(buf, sizeof(buf), "%s 中獎咧! $ %d", bh->brdname, money * i);
} else
continue;
@@ -308,7 +310,8 @@ openticket(int bid)
}
fclose(fp1);
}
- fclose(fp);
+ if (fp)
+ fclose(fp);
if (bet != 98)
snprintf(buf, sizeof(buf), "[公告] %s 賭盤開獎", bh->brdname);