Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[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]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] Re: (PR#3565) End of turn moves
From: "ue80@xxxxxxxxxxxxxxxxxxxxx" <ue80@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Mar 2003 05:29:02 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Tue, Mar 18, 2003 at 05:55:54PM -0800, ue80@xxxxxxxxxxxxxxxxxxxxx wrote:
> On Fri, Feb 28, 2003 at 11:03:32AM -0800, ue80@xxxxxxxxxxxxxxxxxxxxx wrote:
> > 
> > Hi,
> > 
> > i really dislike end of turn moves.
> > People use that trick to get nearer to enemy cities and the defending
> > person has no chance to react. 
> > In a round based game people should have full information what happened
> > last round before the next round starts.
> > 
> > When another person has moved his units into my FOC my "turn done"
> > button should change to unpressed and the timeout should increase this
> > turn by a configurable amount of time.
> 
> Ok, i only changed the timeout thing ... any comments?

New packet introduced to remove the turn done for the client, so its not
comaptible to old clients ...

Thomas

Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.165
diff -u -r1.165 civclient.c
--- client/civclient.c  2003/03/24 22:29:31     1.165
+++ client/civclient.c  2003/03/25 13:23:23
@@ -100,6 +100,7 @@
  */
 bool turn_done_sent = FALSE;
 
+static void server_reenable_turn_done(void);
 static void client_remove_all_cli_conn(void);
 
 /**************************************************************************
@@ -468,6 +469,10 @@
     handle_ping_info((struct packet_ping_info *) packet);
     break;
 
+  case PACKET_REMOVE_TURN_DONE:
+    server_reenable_turn_done();
+    break;
+    
   default:
     freelog(LOG_ERROR, "Received unknown packet (type %d) from server!", type);
     /* Old clients (<= some 1.11.5-devel, capstr +1.11) used to exit()
@@ -485,6 +490,16 @@
 void user_ended_turn(void)
 {
   send_turn_done();
+}
+
+/**************************************************************************
+When hostile units in FOV are moved after player pressed turn the turn done
+bottom state goes back to not pressed (when option is enabled) 
+**************************************************************************/
+static void server_reenable_turn_done(void)
+{
+  game.player_ptr->turn_done=false;
+  turn_done_sent=false;
 }
 
 /**************************************************************************
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.158
diff -u -r1.158 game.c
--- common/game.c       2003/02/20 09:45:21     1.158
+++ common/game.c       2003/03/25 13:23:23
@@ -651,6 +651,7 @@
   game.timeoutinc    = GAME_DEFAULT_TIMEOUTINC;
   game.timeoutincmult= GAME_DEFAULT_TIMEOUTINCMULT;
   game.timeoutcounter= 1;
+  game.timeoutenemyunitmoved=GAME_DEFAULT_TIMEOUTENEMYUNITMOVED;
   game.tcptimeout    = GAME_DEFAULT_TCPTIMEOUT;
   game.netwait       = GAME_DEFAULT_NETWAIT;
   game.last_ping     = 0;
@@ -690,6 +691,7 @@
   game.fogofwar    = GAME_DEFAULT_FOGOFWAR;
   game.fogofwar_old= game.fogofwar;
   game.auto_ai_toggle = GAME_DEFAULT_AUTO_AI_TOGGLE;
+  game.rem_turn_done_moved = GAME_DEFAULT_REM_TNDNE_MOV;
   game.notradesize    = GAME_DEFAULT_NOTRADESIZE;
   game.fulltradesize  = GAME_DEFAULT_FULLTRADESIZE;
   game.barbarianrate  = GAME_DEFAULT_BARBARIANRATE;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.119
diff -u -r1.119 game.h
--- common/game.h       2003/02/12 22:22:33     1.119
+++ common/game.h       2003/03/25 13:23:23
@@ -68,6 +68,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 timeoutenemyunitmoved; /* reset timeout to that amount of seconds when 
enemy units moved  */
   int tcptimeout;
   int netwait;
   time_t last_ping;
@@ -136,6 +137,7 @@
   bool turnblock;
   bool fixedlength;
   bool auto_ai_toggle;
+  bool rem_turn_done_moved;
   bool fogofwar;
   bool fogofwar_old;   /* as the fog_of_war bit get changed by setting
                           the server we need to remember the old setting */
@@ -371,12 +373,14 @@
 #define GAME_DEFAULT_SPACERACE       TRUE
 
 #define GAME_DEFAULT_AUTO_AI_TOGGLE  FALSE
+#define GAME_DEFAULT_REM_TNDNE_MOV   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_TIMEOUTENEMYUNITMOVED 0
 
 #ifndef NDEBUG
 #define GAME_MIN_TIMEOUT             -1
Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.242
diff -u -r1.242 packets.c
--- common/packets.c    2003/03/24 22:29:31     1.242
+++ common/packets.c    2003/03/25 13:23:24
@@ -295,6 +295,7 @@
   case PACKET_TURN_DONE:
     return receive_packet_generic_message(pc);
 
+  case PACKET_REMOVE_TURN_DONE:
   case PACKET_CONN_PING:
   case PACKET_CONN_PONG:
   case PACKET_BEFORE_NEW_YEAR:
Index: common/packets.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v
retrieving revision 1.142
diff -u -r1.142 packets.h
--- common/packets.h    2003/03/24 22:29:31     1.142
+++ common/packets.h    2003/03/25 13:23:24
@@ -128,6 +128,7 @@
   PACKET_FREEZE_HINT,
   PACKET_THAW_HINT,
   PACKET_PING_INFO,
+  PACKET_REMOVE_TURN_DONE,
   PACKET_LAST  /* leave this last */
 };
 
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.124
diff -u -r1.124 gamehand.c
--- server/gamehand.c   2003/03/05 08:56:08     1.124
+++ server/gamehand.c   2003/03/25 13:23:25
@@ -311,3 +311,19 @@
 
   return game.timeout;
 }
+
+/**************************************************************************
+  adjusts game.turn_start when enemy moves an unit, we see it and its the 
+  timeout is nearly over
+**************************************************************************/
+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.timeoutenemyunitmoved){
+      game.turn_start = time(NULL) - game.timeout + game.timeoutenemyunitmoved;
+      send_game_info(NULL);
+    }  
+  }
+}
Index: server/gamehand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.h,v
retrieving revision 1.10
diff -u -r1.10 gamehand.h
--- server/gamehand.h   2002/04/25 14:09:38     1.10
+++ server/gamehand.h   2003/03/25 13:23:25
@@ -23,5 +23,6 @@
 void send_start_turn_to_clients(void);
 
 int update_timeout(void);
+void increase_timeout_because_unit_moved(void);
 
 #endif  /* FC__GAMEHAND_H */
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.114
diff -u -r1.114 savegame.c
--- server/savegame.c   2003/02/17 22:49:28     1.114
+++ server/savegame.c   2003/03/25 13:23:25
@@ -1798,6 +1798,10 @@
     game.timeoutcounter =
        secfile_lookup_int_default(file, 1, "game.timeoutcounter");
 
+game.timeoutenemyunitmoved =
+        secfile_lookup_int_default(file, game.timeoutenemyunitmoved, 
+                                  "game.timeoutenemyunitmoved");
+    
     game.end_year      = secfile_lookup_int(file, "game.end_year");
     game.researchcost  = secfile_lookup_int_default(file, 0, 
"game.researchcost");
     if (game.researchcost == 0)
@@ -1968,6 +1972,8 @@
     game.auto_ai_toggle = secfile_lookup_bool_default(file, 
game.auto_ai_toggle,
                                                     "game.auto_ai_toggle");
 
+    game.rem_turn_done_moved = secfile_lookup_bool_default(file, 
+                       game.rem_turn_done_moved , "game.rem_turn_done_moved");
     game.heating=0;
     game.cooling=0;
 
@@ -2190,7 +2196,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.timeoutenemyunitmoved, 
+                         "game.timeoutenemyunitmoved");
   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");
@@ -2225,6 +2233,8 @@
   secfile_insert_bool(file, game.fogofwar, "game.fogofwar");
   secfile_insert_bool(file, game.spacerace, "game.spacerace");
   secfile_insert_bool(file, game.auto_ai_toggle, "game.auto_ai_toggle");
+  secfile_insert_bool(file, game.rem_turn_done_moved, 
+                     "game.rem_turn_done_moved");
   secfile_insert_int(file, game.diplchance, "game.diplchance");
   secfile_insert_int(file, game.aqueductloss, "game.aqueductloss");
   secfile_insert_int(file, game.killcitizen, "game.killcitizen");
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.273
diff -u -r1.273 stdinhand.c
--- server/stdinhand.c  2003/03/24 22:20:58     1.273
+++ server/stdinhand.c  2003/03/25 13:23:27
@@ -690,6 +690,13 @@
              "connects, and on when a player disconnects."), autotoggle, 
           GAME_DEFAULT_AUTO_AI_TOGGLE)
 
+  GEN_BOOL("turndonerem", game.rem_turn_done_moved, SSET_META, SSET_TO_CLIENT,
+          N_("TURN DONE removed when enemy moves in FOV"),
+          N_("If this is set to 1, the state of the turn done button changes "
+              "back to unpressed when an enemy moves his units in FOV after "
+             "the player has pressed turn done."), NULL, 
+          GAME_DEFAULT_REM_TNDNE_MOV)
+  
   GEN_INT("endyear", game.end_year, SSET_META, SSET_TO_CLIENT,
          N_("Year the game ends"), "", NULL, 
          GAME_MIN_END_YEAR, GAME_MAX_END_YEAR, GAME_DEFAULT_END_YEAR)
@@ -1222,11 +1229,13 @@
   },
   {"timeoutincrease", ALLOW_CTRL, 
    /* TRANS: translate text between <> only */
-   N_("timeoutincrease <turn> <turninc> <value> <valuemult>"), 
+   N_("timeoutincrease <turn> <turninc> <value> <valuemult> <unitmoved>"), 
    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")
+      "to <turn> and multiply <value> by <valuemult>. <unitmoved> resets the "
+      "timeout for this round to at least <unitmoved> when a player at war "
+      "moves a unit into your vision field.  Use this command in "
+      "concert with the option \"timeout\". Defaults are 0 0 0 1 0")
   },
   {"endgame",  ALLOW_HACK,
    "endgame",
@@ -2230,17 +2239,18 @@
 static void timeout_command(struct connection *caller, char *str) 
 {
   char buf[MAX_LEN_CONSOLE_LINE];
-  char *arg[4];
+  char *arg[5];
   int i = 0, ntokens;
-  int *timeouts[4];
+  int *timeouts[5];
 
   timeouts[0] = &game.timeoutint;
   timeouts[1] = &game.timeoutintinc;
   timeouts[2] = &game.timeoutinc;
   timeouts[3] = &game.timeoutincmult;
+  timeouts[4] = &game.timeoutenemyunitmoved;
 
   sz_strlcpy(buf, str);
-  ntokens = get_tokens(buf, arg, 4, TOKEN_DELIMITERS);
+  ntokens = get_tokens(buf, arg, 5, TOKEN_DELIMITERS);
 
   for (i = 0; i < ntokens; i++) {
     if (sscanf(arg[i], "%d", timeouts[i]) != 1) {
@@ -2253,14 +2263,16 @@
   if (ntokens == 0) {
     cmd_reply(CMD_TIMEOUT, caller, C_SYNTAX, _("Usage: timeoutincrease "
                                               "<turn> <turnadd> "
-                                              "<value> <valuemult>."));
+                                              "<value> <valuemult>"
+                                              "<unitmoved> ."));
     return;
   }
 
   cmd_reply(CMD_TIMEOUT, caller, C_OK, _("Dynamic timeout set to "
-                                        "%d %d %d %d"),
+                                        "%d %d %d %d %d"),
            game.timeoutint, game.timeoutintinc,
-           game.timeoutinc, game.timeoutincmult);
+           game.timeoutinc, game.timeoutincmult,
+           game.timeoutenemyunitmoved);
 
   /* if we set anything here, reset the counter */
   game.timeoutcounter = 1;
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.216
diff -u -r1.216 unittools.c
--- server/unittools.c  2003/03/05 12:53:27     1.216
+++ server/unittools.c  2003/03/25 13:23:28
@@ -48,6 +48,7 @@
 #include "settlers.h"
 #include "srv_main.h"
 #include "unithand.h"
+#include "gamehand.h"
 
 #include "aiunit.h"
 #include "aitools.h"
@@ -1974,12 +1975,14 @@
                                 int x, int y, bool carried)
 {
   struct packet_unit_info info;
-
+  bool new_information_for_enemy=false;
   if (!dest) dest = &game.game_connections;
   
   package_unit(punit, &info, carried,
               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;
     bool see_pos =
@@ -1991,9 +1994,22 @@
     }
     if ((!pplayer && pconn->observer) || see_pos || see_xy) {
       send_packet_unit_info(pconn, &info);
+      if (pplayers_at_war(pplayer,unit_owner(punit)) && !pplayer->ai.control) {
+        new_information_for_enemy=true;
+        if (pplayer->turn_done && game.rem_turn_done_moved) { 
+               /*&&client_able_for_that*/
+         send_packet_generic_empty(pconn, PACKET_REMOVE_TURN_DONE);
+          pplayer->turn_done=false; 
+         send_player_info(pplayer, NULL);
+        }
+      }
     }
   }
   conn_list_iterate_end;
+  /* increase timeout by n secs */
+  if ((game.timeout != 0) && new_information_for_enemy){
+    increase_timeout_because_unit_moved();
+  }
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]