[Freeciv-Dev] (PR#12973) Autotimeout
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12973 >
This patch removes the timeoutinc command, and replaces it by an automatic
timeout extension mechanism. This is regulated by "/set gamespeed" which
is a 0-10 value, where a value of 1 is normally reasonable.
This requires a bit of adjustment, of course, and some more additions, but
I want comments on the overall idea and design before I go further.
The idea is that we remove voting, and so we need a way to extend timeout
as the game turns take longer. To do this, we set two parameters - timeout
and gamespeed - in pregame. These then regulate timeout during the game.
Not implemented in this patch, but I think are necessary in addition:
- "/cmdlevel ctrl someperson" should work like /start in that a consensus
of such "votes" can make some person a referee with increased powers
- "/pause", each players should be able to pause the game at most three
times each game; use /pause again to unpause; anyone can unpause. This
allows for a way to be nice to those who need to follow nature's call,
for instance.
- Per
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.209
diff -u -r1.209 game.c
--- common/game.c 2 May 2005 08:56:26 -0000 1.209
+++ common/game.c 3 May 2005 20:19:41 -0000
@@ -183,12 +183,7 @@
game.tech = GAME_DEFAULT_TECHLEVEL;
game.skill_level = GAME_DEFAULT_SKILL_LEVEL;
game.timeout = GAME_DEFAULT_TIMEOUT;
- game.simultaneous_phases_stored = GAME_DEFAULT_SIMULTANEOUS_PHASES;
- game.timeoutint = GAME_DEFAULT_TIMEOUTINT;
- game.timeoutintinc = GAME_DEFAULT_TIMEOUTINTINC;
game.timeoutinc = GAME_DEFAULT_TIMEOUTINC;
- game.timeoutincmult= GAME_DEFAULT_TIMEOUTINCMULT;
- game.timeoutcounter= 1;
game.timeoutaddenemymove = GAME_DEFAULT_TIMEOUTADDEMOVE;
game.tcptimeout = GAME_DEFAULT_TCPTIMEOUT;
game.netwait = GAME_DEFAULT_NETWAIT;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.184
diff -u -r1.184 game.h
--- common/game.h 2 May 2005 19:05:15 -0000 1.184
+++ common/game.h 3 May 2005 20:19:41 -0000
@@ -66,11 +66,7 @@
int tech;
int skill_level;
int timeout;
- int timeoutint; /* increase timeout every N turns... */
int timeoutinc; /* ... by this amount ... */
- int timeoutincmult; /* ... and multiply timeoutinc by this amount ... */
- int timeoutintinc; /* ... and increase timeoutint by this amount */
- int timeoutcounter; /* timeoutcounter - timeoutint = turns to next inc. */
int timeoutaddenemymove; /* minimum timeout after an enemy move is seen */
int tcptimeout;
int netwait;
@@ -422,13 +418,13 @@
#define GAME_DEFAULT_AUTO_AI_TOGGLE FALSE
-#define GAME_DEFAULT_TIMEOUT 0
-#define GAME_DEFAULT_TIMEOUTINT 0
-#define GAME_DEFAULT_TIMEOUTINTINC 0
-#define GAME_DEFAULT_TIMEOUTINC 0
-#define GAME_DEFAULT_TIMEOUTINCMULT 1
#define GAME_DEFAULT_TIMEOUTADDEMOVE 0
+#define GAME_DEFAULT_TIMEOUTINC 0
+#define GAME_MAX_TIMEOUTINC 10
+#define GAME_MIN_TIMEOUTINC 0
+
+#define GAME_DEFAULT_TIMEOUT 0
#define GAME_MIN_TIMEOUT -1
#define GAME_MAX_TIMEOUT 8639999
Index: server/commands.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/commands.c,v
retrieving revision 1.10
diff -u -r1.10 commands.c
--- server/commands.c 2 May 2005 10:37:18 -0000 1.10
+++ server/commands.c 3 May 2005 20:19:41 -0000
@@ -302,14 +302,6 @@
N_("If 'cmdlevel first come' has been used to set a special 'first come'\n"
"command access level, this is the command to grab it with.")
},
- {"timeoutincrease", ALLOW_CTRL,
- /* TRANS: translate text between <> only */
- N_("timeoutincrease <turn> <turninc> <value> <valuemult>"),
- N_("See \"help timeoutincrease\"."),
- N_("Every <turn> turns, add <value> to timeout timer, then add <turninc> "
- "to <turn> and multiply <value> by <valuemult>. Use this command in "
- "concert with the option \"timeout\". Defaults are 0 0 0 1")
- },
{"endgame", ALLOW_HACK,
/* TRANS: translate text between <> only */
N_("endgame"),
Index: server/commands.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/commands.h,v
retrieving revision 1.6
diff -u -r1.6 commands.h
--- server/commands.h 2 May 2005 10:37:18 -0000 1.6
+++ server/commands.h 3 May 2005 20:19:41 -0000
@@ -71,7 +71,6 @@
CMD_EXPERIMENTAL,
CMD_CMDLEVEL,
CMD_FIRSTLEVEL,
- CMD_TIMEOUT,
/* potentially harmful: */
CMD_END_GAME,
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.162
diff -u -r1.162 gamehand.c
--- server/gamehand.c 30 Apr 2005 17:09:28 -0000 1.162
+++ server/gamehand.c 3 May 2005 20:19:41 -0000
@@ -388,55 +388,43 @@
}
/**************************************************************************
- adjusts game.timeout based on various server options
-
- timeoutint: adjust game.timeout every timeoutint turns
- timeoutinc: adjust game.timeout by adding timeoutinc to it.
- timeoutintinc: every time we adjust game.timeout, we add timeoutintinc
- to timeoutint.
- timeoutincmult: every time we adjust game.timeout, we multiply timeoutinc
- by timeoutincmult
+ Calculates new game.timeout based on various server options. Returns new
+ timeout value.
**************************************************************************/
int update_timeout(void)
{
- /* if there's no timer or we're doing autogame, do nothing */
- if (game.timeout < 1 || game.timeoutint == 0) {
+ int extra = 0;
+
+ /* if there's no autotimer or we're doing autogame, do nothing */
+ if (game.timeout < 1 || game.timeoutinc == 0) {
return game.timeout;
}
- if (game.timeoutcounter >= game.timeoutint) {
- game.timeout += game.timeoutinc;
- game.timeoutinc *= game.timeoutincmult;
-
- game.timeoutcounter = 1;
- game.timeoutint += game.timeoutintinc;
-
- if (game.timeout > GAME_MAX_TIMEOUT) {
- notify_conn_ex(game.game_connections, NULL, 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;
- game.timeoutint = 0;
- game.timeoutinc = 0;
- } else if (game.timeout < 0) {
- notify_conn_ex(game.game_connections, NULL, E_NOEVENT,
- _("The turn timeout is smaller than zero, "
- "fixing at zero."));
- freelog(LOG_DEBUG, "game.timeout less than zero");
- game.timeout = 0;
+ players_iterate(pplayer) {
+ int timeout = 0;
+
+ if (!pplayer->is_alive || pplayer->ai.control) {
+ continue; /* irrelevant */
}
- } else {
- game.timeoutcounter++;
- }
- freelog(LOG_DEBUG, "timeout=%d, inc=%d incmult=%d\n "
- "int=%d, intinc=%d, turns till next=%d",
- game.timeout, game.timeoutinc, game.timeoutincmult,
- game.timeoutint, game.timeoutintinc,
- game.timeoutint - game.timeoutcounter);
+ if (game.turn == 0) {
+ timeout += game.timeout / 2; /* first turn bonus to clear the head */
+ }
+ timeout += unit_list_size(pplayer->units) * game.timeoutinc;
+ unit_list_iterate(pplayer->units, punit) {
+ if (unit_flag(punit, F_CITIES)) {
+ timeout += game.timeoutinc;
+ }
+ } unit_list_iterate_end;
+ timeout += city_list_size(pplayer->cities) * game.timeoutinc * 2;
+ timeout += map.size * game.timeoutinc;
+
+ if (timeout > extra) {
+ extra = timeout;
+ }
+ } players_iterate_end;
- return game.timeout;
+ return MIN(game.timeout + extra, GAME_MAX_TIMEOUT);
}
/**************************************************************************
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.239
diff -u -r1.239 savegame.c
--- server/savegame.c 1 May 2005 16:18:14 -0000 1.239
+++ server/savegame.c 3 May 2005 20:19:42 -0000
@@ -3205,21 +3205,9 @@
game.skill_level = GAME_OLD_DEFAULT_SKILL_LEVEL;
game.timeout = secfile_lookup_int(file, "game.timeout");
- game.timeoutint = secfile_lookup_int_default(file,
- GAME_DEFAULT_TIMEOUTINT,
- "game.timeoutint");
- game.timeoutintinc =
- secfile_lookup_int_default(file, GAME_DEFAULT_TIMEOUTINTINC,
- "game.timeoutintinc");
game.timeoutinc =
secfile_lookup_int_default(file, GAME_DEFAULT_TIMEOUTINC,
"game.timeoutinc");
- game.timeoutincmult =
- secfile_lookup_int_default(file, GAME_DEFAULT_TIMEOUTINCMULT,
- "game.timeoutincmult");
- game.timeoutcounter =
- secfile_lookup_int_default(file, 1, "game.timeoutcounter");
-
game.timeoutaddenemymove
= secfile_lookup_int_default(file, game.timeoutaddenemymove,
"game.timeoutaddenemymove");
@@ -3765,11 +3753,7 @@
secfile_insert_int(file, game.tech, "game.tech");
secfile_insert_int(file, game.skill_level, "game.skill_level");
secfile_insert_int(file, game.timeout, "game.timeout");
- secfile_insert_int(file, game.timeoutint, "game.timeoutint");
- secfile_insert_int(file, game.timeoutintinc, "game.timeoutintinc");
secfile_insert_int(file, game.timeoutinc, "game.timeoutinc");
- secfile_insert_int(file, game.timeoutincmult, "game.timeoutincmult");
- secfile_insert_int(file, game.timeoutcounter, "game.timeoutcounter");
secfile_insert_int(file, game.timeoutaddenemymove,
"game.timeoutaddenemymove");
secfile_insert_int(file, game.end_year, "game.end_year");
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.22
diff -u -r1.22 settings.c
--- server/settings.c 2 May 2005 19:05:15 -0000 1.22
+++ server/settings.c 3 May 2005 20:19:42 -0000
@@ -841,6 +841,16 @@
"\"timeoutincrease\" to have a dynamic timer."), NULL,
GAME_MIN_TIMEOUT, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUT)
+ GEN_INT("gamespeed", game.timeoutinc,
+ SSET_META, SSET_INTERNAL, SSET_VITAL, SSET_TO_CLIENT,
+ N_("Increase maximum seconds per turn automatically"),
+ N_("The server automatically increases the timeout "
+ "based on the landmass, number of cities, number "
+ "of units and settlers in the game. This option "
+ "determines how much extra time you will get. "
+ "Higher value means more time."), NULL,
+ GAME_MIN_TIMEOUTINC, GAME_MAX_TIMEOUTINC, GAME_DEFAULT_TIMEOUTINC)
+
GEN_INT("timeaddenemymove", game.timeoutaddenemymove,
SSET_META, SSET_INTERNAL, SSET_VITAL, SSET_TO_CLIENT,
N_("Timeout at least n seconds when enemy moved"),
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.252
diff -u -r1.252 srv_main.c
--- server/srv_main.c 2 May 2005 10:37:18 -0000 1.252
+++ server/srv_main.c 3 May 2005 20:19:42 -0000
@@ -702,7 +702,7 @@
game_advance_year();
freelog(LOG_DEBUG, "Updatetimeout");
- update_timeout();
+ game.timeout = update_timeout();
check_spaceship_arrivals();
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.403
diff -u -r1.403 stdinhand.c
--- server/stdinhand.c 2 May 2005 10:37:18 -0000 1.403
+++ server/stdinhand.c 3 May 2005 20:19:43 -0000
@@ -1391,51 +1391,6 @@
#endif
/**************************************************************************
- Set timeout options.
-**************************************************************************/
-static bool timeout_command(struct connection *caller, char *str, bool check)
-{
- char buf[MAX_LEN_CONSOLE_LINE];
- char *arg[4];
- int i = 0, ntokens;
- int *timeouts[4];
-
- timeouts[0] = &game.timeoutint;
- timeouts[1] = &game.timeoutintinc;
- timeouts[2] = &game.timeoutinc;
- timeouts[3] = &game.timeoutincmult;
-
- sz_strlcpy(buf, str);
- ntokens = get_tokens(buf, arg, 4, TOKEN_DELIMITERS);
-
- for (i = 0; i < ntokens; i++) {
- if (sscanf(arg[i], "%d", timeouts[i]) != 1) {
- cmd_reply(CMD_TIMEOUT, caller, C_FAIL, _("Invalid argument %d."),
- i + 1);
- }
- free(arg[i]);
- }
-
- if (ntokens == 0) {
- cmd_reply(CMD_TIMEOUT, caller, C_SYNTAX, _("Usage: timeoutincrease "
- "<turn> <turnadd> "
- "<value> <valuemult>."));
- return FALSE;
- } else if (check) {
- return TRUE;
- }
-
- cmd_reply(CMD_TIMEOUT, caller, C_OK, _("Dynamic timeout set to "
- "%d %d %d %d"),
- game.timeoutint, game.timeoutintinc,
- game.timeoutinc, game.timeoutincmult);
-
- /* if we set anything here, reset the counter */
- game.timeoutcounter = 1;
- return TRUE;
-}
-
-/**************************************************************************
Find option level number by name.
**************************************************************************/
static enum sset_level lookup_option_level(const char *name)
@@ -3496,8 +3451,6 @@
return cmdlevel_command(caller, arg, check);
case CMD_FIRSTLEVEL:
return firstlevel_command(caller, check);
- case CMD_TIMEOUT:
- return timeout_command(caller, allargs, check);
case CMD_START_GAME:
return start_command(caller, arg, check);
case CMD_END_GAME:
- [Freeciv-Dev] (PR#12973) Autotimeout,
Per I. Mathisen <=
|
|