[Freeciv-Dev] (PR#3565) addtimeenemymoves repost of patch
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=3565 >
Hi,
i updated the patch because
time_t turn_start got time_t phase_start
Updating the time in the client is not working ...
Thomas
--
Thomas Strub *** eMail ue80@xxxxxxxxxxxxxxxxxxxxx
jb: people are stupid, they don't want to learn.
? 3565-only-timeout-2.diff
? 3565-only-timeout-3.diff
? 3565-only-timeout-4.diff
? dddd2.diff
? dddd3
? ddddd.diff
? server/.gamehand.c.swp
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.187.2.2
diff -u -u -r1.187.2.2 game.c
--- common/game.c 25 Nov 2004 23:22:34 -0000 1.187.2.2
+++ common/game.c 2 May 2005 18:32:54 -0000
@@ -189,6 +189,7 @@
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;
game.last_ping = 0;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.152.2.4
diff -u -u -r1.152.2.4 game.h
--- common/game.h 25 Nov 2004 23:22:34 -0000 1.152.2.4
+++ common/game.h 2 May 2005 18:32:54 -0000
@@ -71,6 +71,7 @@
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; /* increase to, when enemy move seen */
int tcptimeout;
int netwait;
time_t last_ping;
@@ -424,6 +425,7 @@
#define GAME_DEFAULT_TIMEOUTINTINC 0
#define GAME_DEFAULT_TIMEOUTINC 0
#define GAME_DEFAULT_TIMEOUTINCMULT 1
+#define GAME_DEFAULT_TIMEOUTADDEMOVE 0
#ifndef NDEBUG
#define GAME_MIN_TIMEOUT -1
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.143.2.2
diff -u -u -r1.143.2.2 gamehand.c
--- server/gamehand.c 16 Nov 2004 18:14:00 -0000 1.143.2.2
+++ server/gamehand.c 2 May 2005 18:32:56 -0000
@@ -407,6 +407,23 @@
return game.timeout;
}
+/**************************************************************************
+ adjusts game.turn_start when enemy moves an unit, we see it and the
+ remaining timeout is smaller than the option
+ It's possible to use a simular function to do that per player.
+**************************************************************************/
+void increase_timeout_because_unit_moved(void)
+{
+ int seconds_to_turndone;
+ if (game.timeout != 0){
+ seconds_to_turndone = game.turn_start + game.timeout - time(NULL);
+ if (seconds_to_turndone < game.timeoutaddenemymove){
+ game.turn_start = time(NULL) - game.timeout + game.timeoutaddenemymove;
+ send_game_info(NULL);
+ }
+ }
+}
+
/**************************************************************************
generate challenge filename for this connection, cannot fail.
**************************************************************************/
Index: server/gamehand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.h,v
retrieving revision 1.11.2.1
diff -u -u -r1.11.2.1 gamehand.h
--- server/gamehand.h 16 Nov 2004 18:14:00 -0000 1.11.2.1
+++ server/gamehand.h 2 May 2005 18:32:56 -0000
@@ -24,6 +24,7 @@
void send_start_turn_to_clients(void);
int update_timeout(void);
+void increase_timeout_because_unit_moved(void);
const char *new_challenge_filename(struct connection *pc);
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.197.2.13
diff -u -u -r1.197.2.13 savegame.c
--- server/savegame.c 26 Feb 2005 00:33:23 -0000 1.197.2.13
+++ server/savegame.c 2 May 2005 18:32:57 -0000
@@ -3084,6 +3084,11 @@
game.timeoutcounter =
secfile_lookup_int_default(file, 1, "game.timeoutcounter");
+ game.timeoutaddenemymove =
+ secfile_lookup_int_default(file, game.timeoutaddenemymove,
+ "game.timeoutaddenemymove");
+
+
game.end_year = secfile_lookup_int(file, "game.end_year");
game.researchcost = secfile_lookup_int_default(file, 0,
"game.researchcost");
if (game.researchcost == 0)
@@ -3634,7 +3639,9 @@
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.timeoutcounter, "game.timeoutcounter");
+ secfile_insert_int(file, game.timeoutaddenemymove,
+ "game.timeoutaddenemymove");
secfile_insert_int(file, game.end_year, "game.end_year");
secfile_insert_int(file, game.year, "game.year");
secfile_insert_int(file, game.turn, "game.turn");
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.5.2.8
diff -u -u -r1.5.2.8 settings.c
--- server/settings.c 29 Apr 2005 17:49:27 -0000 1.5.2.8
+++ server/settings.c 2 May 2005 18:32:58 -0000
@@ -865,7 +865,7 @@
N_("Year the game ends"),
N_("The game will end at the end of the given year."), NULL,
GAME_MIN_END_YEAR, GAME_MAX_END_YEAR, GAME_DEFAULT_END_YEAR)
-
+
GEN_INT("timeout", game.timeout,
SSET_META, SSET_INTERNAL, SSET_VITAL, SSET_TO_CLIENT,
N_("Maximum seconds per turn"),
@@ -877,6 +877,15 @@
"\"timeoutincrease\" to have a dynamic timer."), NULL,
GAME_MIN_TIMEOUT, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUT)
+ GEN_INT("timeaddenemymove", game.timeoutaddenemymove,
+ SSET_META, SSET_INTERNAL, SSET_VITAL, SSET_TO_CLIENT,
+ N_("Timeout at least n seconds when enemy moved"),
+ N_("Timeout will be set to n seconds when "
+ " it was lower"
+ "and players at war are moving units in sight of other player")
+ , NULL,
+ 0, GAME_MAX_TIMEOUT, GAME_DEFAULT_TIMEOUTADDEMOVE)
+
GEN_INT("nettimeout", game.tcptimeout,
SSET_META, SSET_NETWORK, SSET_RARE, SSET_TO_CLIENT,
N_("Seconds to let a client's network connection block"),
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.306.2.11
diff -u -u -r1.306.2.11 unittools.c
--- server/unittools.c 1 Apr 2005 00:42:29 -0000 1.306.2.11
+++ server/unittools.c 2 May 2005 18:33:00 -0000
@@ -48,6 +48,7 @@
#include "settlers.h"
#include "srv_main.h"
#include "unithand.h"
+#include "gamehand.h"
#include "aiexplorer.h"
#include "aitools.h"
@@ -1940,11 +1941,15 @@
{
struct packet_unit_info info;
struct packet_unit_short_info sinfo;
-
+
+ bool new_information_for_enemy=false;
if (!dest) {
dest = &game.game_connections;
}
+/* maybe the wrong position for that, but this is the lowlevel function
+ * where we check if we have to increase timeout, or remove_turn_done */
+
package_unit(punit, &info);
package_short_unit(punit, &sinfo, UNIT_INFO_IDENTITY, FALSE, FALSE);
@@ -1958,6 +1963,9 @@
if (can_player_see_unit_at(pplayer, punit, punit->tile)
|| can_player_see_unit_at(pplayer, punit, ptile)) {
send_packet_unit_short_info(pconn, &sinfo);
+ if (pplayers_at_war(pplayer,unit_owner(punit)) && !pplayer->ai.control)
+ /* increase_timeout_because_unit_moved(pplayer) possible here */
+ new_information_for_enemy=true;
} else {
if (remove_unseen) {
dsend_packet_unit_remove(pconn, punit->id);
@@ -1965,6 +1973,11 @@
}
}
} conn_list_iterate_end;
+
+ if ((game.timeout != 0) && new_information_for_enemy){
+ increase_timeout_because_unit_moved();
+ }
+
}
/**************************************************************************
- [Freeciv-Dev] (PR#3565) addtimeenemymoves repost of patch,
ue80@xxxxxxxxxxxxxxxxxxxxx <=
|
|