diff -Nur -Xfreeciv/diff_ignore freeciv/common/capstr.c test-timer/common/capstr.c --- freeciv/common/capstr.c Fri Mar 8 18:26:31 2002 +++ test-timer/common/capstr.c Mon Mar 11 23:52:51 2002 @@ -73,7 +73,7 @@ #define CAPABILITY "+1.11.6 conn_info pop_cost +turn +attributes"\ " new_bonus_tech fund_added +processing_packets angrycitizen +tile_trade"\ " init_techs short_worklists tech_cost_style +short_city_tile_trade"\ -" +trade_size" +" +trade_size u32timeout" /* "+1.11.6" is protocol for 1.11.6 beta release. @@ -117,6 +117,9 @@ "trade_size" transfer game.notradesize and game.fulltradesize to the client. + + "u32timeout" designates that game.timeout is packeted as a uint32 + instead of a uint16 */ void init_our_capability(void) diff -Nur -Xfreeciv/diff_ignore freeciv/common/packets.c test-timer/common/packets.c --- freeciv/common/packets.c Fri Mar 8 18:26:42 2002 +++ test-timer/common/packets.c Mon Mar 11 23:58:55 2002 @@ -2051,9 +2051,12 @@ cptr=put_uint16(cptr, pinfo->gold); cptr=put_uint32(cptr, pinfo->tech); cptr=put_uint8(cptr, pinfo->researchcost); - cptr=put_uint32(cptr, pinfo->skill_level); - cptr=put_uint16(cptr, pinfo->timeout); + if (has_capability("u32timeout", pc->capability)) { + cptr=put_uint32(cptr, pinfo->timeout); + } else { + cptr=put_uint16(cptr, pinfo->timeout); + } cptr=put_uint32(cptr, pinfo->end_year); cptr=put_uint32(cptr, pinfo->year); cptr=put_uint8(cptr, pinfo->min_players); @@ -2110,7 +2113,11 @@ iget_uint32(&iter, &pinfo->tech); iget_uint8(&iter, &pinfo->researchcost); iget_uint32(&iter, &pinfo->skill_level); - iget_uint16(&iter, &pinfo->timeout); + if (has_capability("u32timeout", pc->capability)) { + iget_uint32(&iter, &pinfo->timeout); + } else { + iget_uint16(&iter, &pinfo->timeout); + } iget_uint32(&iter, &pinfo->end_year); iget_uint32(&iter, &pinfo->year); iget_uint8(&iter, &pinfo->min_players); diff -Nur -Xfreeciv/diff_ignore freeciv/server/gamehand.c test-timer/server/gamehand.c --- freeciv/server/gamehand.c Wed Mar 6 23:29:55 2002 +++ test-timer/server/gamehand.c Tue Mar 12 00:04:59 2002 @@ -196,7 +196,6 @@ lsend_packet_generic_integer(dest, PACKET_GAME_STATE, &pack); } - /************************************************************************** Send game_info packet; some server options and various stuff... dest==NULL means game.est_connections @@ -247,4 +246,51 @@ send_packet_game_info(pconn, &ginfo); } conn_list_iterate_end; +} + +/************************************************************************** + adjusts game.timeout based on various server options + + timeoutint: adjust game.timeout every timeoutint turns + timeoutintinc: everytime we adjust game.timeout, we add timeoutintinc + to timeoutint. + timeoutinc: adjust game.timeout by adding timeoutinc to it. + timeoutincmult: everytime we adjust game.timeout, we multiply timeoutinc + by timeoutincmult +**************************************************************************/ +int update_timeout(void) +{ + static int timeoutint = 0; + static int timeoutintinc = 0; + static int timeoutinc = 5; + static int timeoutincmult = 1; + + static int counter = 1; + + /* if there's no timer or we're doing autogame, do nothing */ + if (game.timeout < 1 || timeoutint == 0) { + return game.timeout; + } + + if(counter >= timeoutint) { + game.timeout += timeoutinc; + timeoutinc *= timeoutincmult; + + counter = 1; + timeoutint += timeoutintinc; + + if(game.timeout > GAME_MAX_TIMEOUT) { + notify_conn_ex(&game.est_connections, -1, -1, E_NOEVENT, + _("The turn timeout has exceeded its maximum value, " + "fixing at its maximum")); + freelog(LOG_DEBUG, "game.timeout exceeded maximum value"); + game.timeout = GAME_MAX_TIMEOUT; + timeoutint = 0; + timeoutinc = 0; + } + } else { + counter++; + } + + return game.timeout; } diff -Nur -Xfreeciv/diff_ignore freeciv/server/gamehand.h test-timer/server/gamehand.h --- freeciv/server/gamehand.h Thu Oct 18 11:45:34 2001 +++ test-timer/server/gamehand.h Sun Mar 10 02:07:23 2002 @@ -22,4 +22,6 @@ void send_game_state(struct conn_list *dest, int state); void send_start_turn_to_clients(void); +int update_timeout(void); + #endif /* FC__GAMEHAND_H */ diff -Nur -Xfreeciv/diff_ignore freeciv/server/sernet.c test-timer/server/sernet.c --- freeciv/server/sernet.c Tue Mar 5 20:04:55 2002 +++ test-timer/server/sernet.c Sun Mar 10 01:02:50 2002 @@ -63,6 +63,7 @@ #endif #include "fcintl.h" +#include "gamehand.h" #include "log.h" #include "mem.h" #include "netintf.h" @@ -619,9 +620,9 @@ } con_prompt_off(); - if(game.timeout != 0 - && (time(NULL)>game.turn_start + game.timeout)) + if(game.timeout != 0 && (time(NULL) > game.turn_start + game.timeout)) { return 0; + } return 1; } diff -Nur -Xfreeciv/diff_ignore freeciv/server/srv_main.c test-timer/server/srv_main.c --- freeciv/server/srv_main.c Wed Mar 6 23:29:55 2002 +++ test-timer/server/srv_main.c Sun Mar 10 10:31:58 2002 @@ -1731,6 +1731,8 @@ end_turn(); freelog(LOG_DEBUG, "Gamenextyear"); game_advance_year(); + freelog(LOG_DEBUG, "Updatetimout"); + update_timeout(); check_spaceship_arrivals(); freelog(LOG_DEBUG, "Sendplayerinfo"); send_player_info(NULL, NULL);