/* send special use elements into the network, to make sure nothing bad happens with explosions we send the ex_nr number too */ void net_game_send_special (int pl_nr, int ex_nr, int type) { int pl; d_printf ("Send Special Data pl_nr:%d ex_nr:%d type:%d\n", pl_nr, ex_nr, type); if (pl_nr < 0 || pl_nr >= MAX_PLAYERS) return; for (pl = 0; pl < MAX_PLAYERS; pl++) if (NET_CANSEND (pl)) send_special (&players[pl].net.addr, pl_nr, type, ex_nr); };
int main() { char *str; int i = 0, fd = -1, msqid = -1; int sp_retv, sv_retv; srandom(time(NULL)); chdir(MY_BBS_HOME); mkdir(SP_DIR, 0770); umask(027); msqid = initAILogMSQ(); if (msqid < 0) return -1; #if !defined(DEBUG_MODE) if (fork()) return 0; setsid(); if (fork()) return 0; close(0); close(1); close(2); #endif signal(SIGHUP, sig_hup); signal(SIGTERM, sig_term); signal(SIGCHLD, sig_chld); fd = open(MY_BBS_HOME "/reclog/AId.lock", O_CREAT | O_RDONLY, 0660); if (flock(fd, LOCK_EX | LOCK_NB) < 0) return -1; #ifdef DEBUG_MODE printf("msq started...\n"); #endif while (1) { if(i % 128 == 0) { sv_retv = load_server(); sp_retv = load_special(); if(fork() == 0) { close(fd); update_special_html(); if(sp_retv == 1) return send_special(); else return MAX_SERVER_NUM; } } while ((str = rcvlog(msqid, 1))) { strsncpy(queue[qlen++], str, 512); #ifdef DEBUG_MODE printf("recved@%ld |%s|\n", time(NULL), str); if(qlen < 1) #else if(qlen < 16) #endif continue; if(num_server == 0) { if(qlen > MAX_QLEN - 1) qlen--;//drop msg break; } if(fork() == 0) { close(fd); return require_ai(i%num_server); } qlen=0; break; } i++; sleep(5); } }