Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] Re: (PR#3565) End of turn moves
Home

[Freeciv-Dev] Re: (PR#3565) End of turn moves

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: jdwheeler42@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#3565) End of turn moves
From: "ue80@xxxxxxxxxxxxxxxxxxxxx" <ue80@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 1 Mar 2005 13:24:56 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=3565 >

Hi,

i've reduced the patch, that only the timeout is changed.
Can be applied to pubserver without changing the clients.

Better patch only possible with manipulating turn-done-button.
But that would need a new capability.

Thomas
-- 
Thomas Strub  ***  eMail ue80@xxxxxxxxxxxxxxxxxxxxx
jb: people are stupid, they don't want to learn.

Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.197
diff -u -u -r1.197 game.c
--- common/game.c       23 Feb 2005 03:34:05 -0000      1.197
+++ common/game.c       1 Mar 2005 21:06:57 -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.173
diff -u -u -r1.173 game.h
--- common/game.h       23 Feb 2005 03:34:05 -0000      1.173
+++ common/game.h       1 Mar 2005 21:06:57 -0000
@@ -70,6 +70,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;
@@ -436,6 +437,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.152
diff -u -u -r1.152 gamehand.c
--- server/gamehand.c   23 Feb 2005 03:34:06 -0000      1.152
+++ server/gamehand.c   1 Mar 2005 21:06:58 -0000
@@ -413,6 +413,23 @@
   return game.timeout;
 }
 
+/**************************************************************************
+  adjusts game.phase_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.phase_start + game.timeout - time(NULL);
+    if (seconds_to_turndone < game.timeoutaddenemymove){
+      game.phase_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.13
diff -u -u -r1.13 gamehand.h
--- server/gamehand.h   23 Feb 2005 03:34:06 -0000      1.13
+++ server/gamehand.h   1 Mar 2005 21:06:58 -0000
@@ -24,6 +24,7 @@
 void send_start_phase_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.223
diff -u -u -r1.223 savegame.c
--- server/savegame.c   26 Feb 2005 00:33:21 -0000      1.223
+++ server/savegame.c   1 Mar 2005 21:06:59 -0000
@@ -3112,6 +3112,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)
@@ -3658,7 +3663,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.18
diff -u -u -r1.18 settings.c
--- server/settings.c   26 Feb 2005 01:05:55 -0000      1.18
+++ server/settings.c   1 Mar 2005 21:07:00 -0000
@@ -873,6 +873,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)
+  
   /* This setting points to the "stored" value; changing it won't have
    * an effect until the next synchronization point (i.e., the start of
    * the next turn). */
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.322
diff -u -u -r1.322 unittools.c
--- server/unittools.c  23 Feb 2005 03:34:06 -0000      1.322
+++ server/unittools.c  1 Mar 2005 21:07:02 -0000
@@ -48,6 +48,7 @@
 #include "settlers.h"
 #include "srv_main.h"
 #include "unithand.h"
+#include "gamehand.h"
 
 #include "aiexplorer.h"
 #include "aitools.h"
@@ -1932,14 +1933,19 @@
 {
   struct packet_unit_info info;
   struct packet_unit_short_info sinfo;
-  
+ 
+  bool new_information_for_enemy=false;
   if (!dest) {
     dest = game.game_connections;
   }
 
   package_unit(punit, &info);
   package_short_unit(punit, &sinfo, UNIT_INFO_IDENTITY, FALSE, FALSE);
-            
+
+/* 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 */
+
+  
   conn_list_iterate(dest, pconn) {
     struct player *pplayer = pconn->player;
     
@@ -1950,6 +1956,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);
@@ -1957,6 +1966,11 @@
       }
     }
   } conn_list_iterate_end;
+  
+  if ((game.timeout != 0) && new_information_for_enemy){
+    increase_timeout_because_unit_moved();
+  }
+
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#3565) End of turn moves, ue80@xxxxxxxxxxxxxxxxxxxxx <=