diff options
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/io.c | 5 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 2 | ||||
-rw-r--r-- | mbbsd/talk.c | 14 | ||||
-rw-r--r-- | mbbsd/var.c | 2 |
4 files changed, 22 insertions, 1 deletions
@@ -445,6 +445,7 @@ igetch(void) case KEY_TAB: if (WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW)) if (currutmp != NULL && watermode > 0) { + check_water_init(); watermode = (watermode + water_which->count) % water_which->count + 1; t_display_new(); @@ -470,6 +471,7 @@ igetch(void) i_newfd = my_newfd; continue; } else if (!WATERMODE(WATER_OFO)) { + check_water_init(); if (watermode > 0) { watermode = (watermode + water_which->count) % water_which->count + 1; @@ -525,6 +527,7 @@ igetch(void) case Ctrl('T'): if (WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW)) { if (watermode > 0) { + check_water_init(); if (watermode > 1) watermode--; else @@ -538,6 +541,7 @@ igetch(void) case Ctrl('F'): if (WATERMODE(WATER_NEW)) { if (watermode > 0) { + check_water_init(); if (water_which_flag == (int)water_usies) water_which_flag = 0; else @@ -557,6 +561,7 @@ igetch(void) case Ctrl('G'): if (WATERMODE(WATER_NEW)) { if (watermode > 0) { + check_water_init(); water_which_flag = (water_which_flag + water_usies) % (water_usies + 1); if (water_which_flag == 0) water_which = &water[0]; diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 4ef29a8b..1adfe339 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -380,6 +380,7 @@ add_history(const msgque_t * msg) { int i = 0, j, waterinit = 0; water_t *tmp; + check_water_init(); if (WATERMODE(WATER_ORIG) || WATERMODE(WATER_NEW)) add_history_water(&water[0], msg); if (WATERMODE(WATER_NEW) || WATERMODE(WATER_OFO)) { @@ -441,6 +442,7 @@ write_request(int sig) #else now = time(0); #endif + check_water_init(); if (WATERMODE(WATER_OFO)) { /* 如果目前正在回水球模式的話, 就不能進行 add_history() , 因為會改寫 water[], 而使回水球目的爛掉, 所以分成幾種情況考慮. diff --git a/mbbsd/talk.c b/mbbsd/talk.c index 408c9ac8..28accbf0 100644 --- a/mbbsd/talk.c +++ b/mbbsd/talk.c @@ -531,6 +531,17 @@ my_query(const char *uident) static char t_last_write[80]; +void check_water_init(void) +{ + if(water==NULL) { + water = (water_t*)malloc(sizeof(water_t)*6); + memset(water, 0, sizeof(water_t)*6); + water_which = &water[0]; + + strlcpy(water[0].userid, " 全部 ", sizeof(water[0].userid)); + } +} + static void water_scr(const water_t * tw, int which, char type) { @@ -590,6 +601,7 @@ my_write2(void) water_t *tw; unsigned char mode0; + check_water_init(); if (swater[0] == NULL) return; wmofo = REPLYING; @@ -727,6 +739,7 @@ my_write(pid_t pid, const char *prompt, const char *id, int flag, userinfo_t * p userinfo_t *uin; uin = (puin != NULL) ? puin : (userinfo_t *) search_ulist_pid(pid); strlcpy(destid, id, sizeof(destid)); + check_water_init(); /* what if uin is NULL but other conditions are not true? * will this situation cause SEGV? @@ -976,6 +989,7 @@ t_display_new(void) else t_display_new_flag = 1; + check_water_init(); if (WATERMODE(WATER_ORIG)) water_which = &water[0]; else diff --git a/mbbsd/var.c b/mbbsd/var.c index 657a25d6..6da13ebe 100644 --- a/mbbsd/var.c +++ b/mbbsd/var.c @@ -386,7 +386,7 @@ char raw_connection = 0; char fromhost[STRLEN] = "\0"; char water_usies = 0; FILE *fp_writelog = NULL; -water_t water[6], *swater[6], *water_which = &water[0]; +water_t *water, *swater[6], *water_which; char over18 = 0; /* chc_play.c */ |