--- ../tetrinet-0.11-orig/server.c 2003-09-08 01:29:29 +0900 +++ server.c 2005-01-27 16:45:15 +0900 @@ -31,6 +31,10 @@ static int quit = 0; +static time_t add_line_when = 0; /*mp*/ +static time_t time_before_adding_lines = 60; /*mp*/ +static time_t time_between_adding_lines = 10; /*mp*/ + static int listen_sock = -1; #ifdef HAVE_IPV6 static int listen_sock6 = -1; @@ -171,6 +175,9 @@ winlist[i].games = atoi(t+1); i++; } + } else if (strcmp(s, "addlineswhen") == 0) { /*mp*/ + time_before_adding_lines = 60*atoi(strtok(NULL, " ")); + time_between_adding_lines = atoi(strtok(NULL, " ")); } } fclose(f); @@ -223,6 +230,7 @@ fprintf(f, "linuxmode %d\n", linuxmode); fprintf(f, "ipv6_only %d\n", ipv6_only); + fprintf(f, "addlineswhen %d %d\n", time_before_adding_lines / 60, time_between_adding_lines); /*mp*/ fclose(f); } @@ -602,6 +610,7 @@ } playing_game = 1; game_paused = 0; + add_line_when = time(NULL) + time_before_adding_lines; /*mp*/ for (i = 1; i <= 6; i++) { if (player_socks[i-1] < 0) continue; @@ -811,6 +820,7 @@ { fd_set fds; int i, fd, maxfd; + struct timeval timeout; /*mp*/ FD_ZERO(&fds); if (listen_sock >= 0) @@ -834,7 +844,8 @@ } } - if (select(maxfd+1, &fds, NULL, NULL, NULL) <= 0) + timeout.tv_sec = 0L; timeout.tv_usec = 500L; /*mp*/ + if (select(maxfd+1, &fds, NULL, NULL, &timeout) <= 0) /*mp*/ return; if (listen_sock >= 0 && FD_ISSET(listen_sock, &fds)) { @@ -949,8 +960,15 @@ if ((i = init()) != 0) return i; - while (!quit) + static time_t now; /*mp*/ + while (!quit) { /*mp*/ check_sockets(); + time(&now); /*mp*/ + if(playing_game && add_line_when <= now) { /*mp*/ + send_to_all("sb 0 cs1 0"); + add_line_when += time_between_adding_lines; + }; + }; /*mp*/ write_config(); if (listen_sock >= 0) close(listen_sock);