summaryrefslogtreecommitdiffstats
path: root/mbbsd/vice.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
commit1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch)
treee6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/vice.c
parent10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff)
downloadpttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/vice.c')
-rw-r--r--mbbsd/vice.c155
1 files changed, 83 insertions, 72 deletions
diff --git a/mbbsd/vice.c b/mbbsd/vice.c
index 8b8abe0f..d52f12ad 100644
--- a/mbbsd/vice.c
+++ b/mbbsd/vice.c
@@ -1,4 +1,4 @@
-/* $Id: vice.c,v 1.3 2002/06/04 13:08:34 in2 Exp $ */
+/* $Id: vice.c,v 1.4 2002/07/05 17:10:28 in2 Exp $ */
#include "bbs.h"
#define VICE_PLAY BBSHOME "/etc/vice/vice.play"
@@ -14,122 +14,133 @@
#define MAX_LOST_PICTURE 3
#define MAX_END_PICTURE 5
-static int vice_load(char tbingo[6][15]) {
- FILE *fb = fopen(VICE_BINGO, "r");
- char buf[16], *ptr;
- int i = 0;
- if(!fb) return -1; bzero((char*)tbingo, sizeof(tbingo));
- while(i < 6 && fgets(buf, 15, fb)) {
- if((ptr = strchr(buf, '\n')))
- *ptr = 0;
- strcpy(tbingo[i++], buf);
+static int
+vice_load(char tbingo[6][15])
+{
+ FILE *fb = fopen(VICE_BINGO, "r");
+ char buf[16], *ptr;
+ int i = 0;
+ if (!fb)
+ return -1;
+ bzero((char *)tbingo, sizeof(tbingo));
+ while (i < 6 && fgets(buf, 15, fb)) {
+ if ((ptr = strchr(buf, '\n')))
+ *ptr = 0;
+ strcpy(tbingo[i++], buf);
}
fclose(fb);
return 0;
}
-static int check(char tbingo[6][15], char *data) {
- int i = 0, j;
+static int
+check(char tbingo[6][15], char *data)
+{
+ int i = 0, j;
- if(!strcmp(data, tbingo[0]))
- return 8;
+ if (!strcmp(data, tbingo[0]))
+ return 8;
- for(j = 8; j > 0; j--)
- for(i = 1; i < 6; i++)
- if(!strncmp(data+8-j, tbingo[i]+8-j,j))
- return j - 1;
+ for (j = 8; j > 0; j--)
+ for (i = 1; i < 6; i++)
+ if (!strncmp(data + 8 - j, tbingo[i] + 8 - j, j))
+ return j - 1;
return 0;
}
-// Ptt: showfile ran_showfile more ¤TªÌ­n¾ã¦X
-static int ran_showfile(int y, int x, char *filename, int maxnum) {
- FILE *fs;
- char buf[512];
+//Ptt:showfile ran_showfile more ¤ T ª Ì­n ¾ ã¦X
+static int
+ran_showfile(int y, int x, char *filename, int maxnum)
+{
+ FILE *fs;
+ char buf[512];
bzero(buf, sizeof(char) * 512);
sprintf(buf, "%s%d", filename, rand() % maxnum + 1);
- if(!(fs = fopen(buf, "r"))) {
- move(10,10);
- prints("can't open file: %s", buf);
- return 0;
+ if (!(fs = fopen(buf, "r"))) {
+ move(10, 10);
+ prints("can't open file: %s", buf);
+ return 0;
}
-
move(y, x);
- while(fgets(buf, 511, fs))
- prints("%s", buf);
+ while (fgets(buf, 511, fs))
+ prints("%s", buf);
fclose(fs);
return 1;
}
-static int ran_showmfile(char *filename, int maxnum) {
- char buf[256];
+static int
+ran_showmfile(char *filename, int maxnum)
+{
+ char buf[256];
sprintf(buf, "%s%d", filename, rand() % maxnum + 1);
return more(buf, YEA);
}
-int vice_main() {
- FILE *fd;
- char tbingo[6][15];
- char buf_data[256]
- , serial[16], ch[2], *ptr;
- int TABLE[] = {0,10,200,1000,4000,10000,40000,100000,200000};
- int total = 0, money, i = 4, j = 0;
+int
+vice_main()
+{
+ FILE *fd;
+ char tbingo[6][15];
+ char buf_data[256]
+ ,serial[16], ch[2], *ptr;
+ int TABLE[] = {0, 10, 200, 1000, 4000, 10000, 40000, 100000, 200000};
+ int total = 0, money, i = 4, j = 0;
setuserfile(buf_data, VICE_DATA);
- if(!dashf(buf_data)) {
- ran_showmfile(VICE_NO, MAX_NO_PICTURE);
- return 0;
+ if (!dashf(buf_data)) {
+ ran_showmfile(VICE_NO, MAX_NO_PICTURE);
+ return 0;
}
- if(vice_load(tbingo)<0) return -1;
+ if (vice_load(tbingo) < 0)
+ return -1;
clear();
ran_showfile(0, 0, VICE_PLAY, 1);
ran_showfile(10, 0, VICE_SHOW, 1);
- if(!(fd = fopen(buf_data, "r")))
- return 0;
+ if (!(fd = fopen(buf_data, "r")))
+ return 0;
j = 0;
i = 0;
- move(10,24);
+ move(10, 24);
clrtoeol();
prints("³o¤@´Áªºµo²¼¸¹½X");
- while(fgets(serial, 15, fd)) {
- if((ptr = strchr(serial,'\r')))
- *ptr = 0;
- if(j == 0)
- i++;
- move(10 + i, 24 + j);
- prints("%s", serial);
- j += 9;
- j %= 45;
+ while (fgets(serial, 15, fd)) {
+ if ((ptr = strchr(serial, '\r')))
+ *ptr = 0;
+ if (j == 0)
+ i++;
+ move(10 + i, 24 + j);
+ prints("%s", serial);
+ j += 9;
+ j %= 45;
}
getdata(8, 0, "«ö'c'¶}©l¹ï¼ú¤F(©Î¬O¥ô·NÁäÂ÷¶})): ",
ch, sizeof(ch), LCECHO);
- if(ch[0] != 'c' || lockutmpmode(VICE, LOCK_MULTI)){
- fclose(fd);
- return 0;
- }
-
+ if (ch[0] != 'c' || lockutmpmode(VICE, LOCK_MULTI)) {
+ fclose(fd);
+ return 0;
+ }
showtitle("µo²¼¹ï¼ú", BBSNAME);
rewind(fd);
- while(fgets(serial, 15, fd)) {
- if((ptr = strchr(serial,'\n')))
- *ptr = 0;
- money = TABLE[check(tbingo,serial)];
- total += money;
- prints("%s ¤¤¤F %d\n", serial, money);
+ while (fgets(serial, 15, fd)) {
+ if ((ptr = strchr(serial, '\n')))
+ *ptr = 0;
+ money = TABLE[check(tbingo, serial)];
+ total += money;
+ prints("%s ¤¤¤F %d\n", serial, money);
}
pressanykey();
- if(total > 0) {
- ran_showmfile(VICE_WIN, MAX_WIN_PICTURE);
- move(22,0);
- clrtoeol();
- prints("¥þ³¡ªºµo²¼¤¤¤F %d ¶ô¿ú\n", total);
- demoney(total);
+ if (total > 0) {
+ ran_showmfile(VICE_WIN, MAX_WIN_PICTURE);
+ move(22, 0);
+ clrtoeol();
+ prints("¥þ³¡ªºµo²¼¤¤¤F %d ¶ô¿ú\n", total);
+ demoney(total);
} else
- ran_showmfile(VICE_LOST, MAX_LOST_PICTURE);
+ ran_showmfile(VICE_LOST, MAX_LOST_PICTURE);
fclose(fd);
unlink(buf_data);