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, 18 Mar 2003 17:55:54 -0800
Reply-to: rt@xxxxxxxxxxxxxx

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?
 
Thomas
-- 
Thomas Strub  ***  eMail ue80@xxxxxxxxxxxxxxxxxxxxx
Wenn Du nicht programmieren kannst und Dir für Arbeit zu schade bist:
Werde Berater, Analyst oder organisiere Kongresse.

? 1-city-space-race-1957.gz
? 1-city-space-race-1958.gz
? 3565.diff
? PR#3688.diff
? armour-landed.gz
? armour-on-ship.gz
? big-game
? bla
? civscore.log
? def_ships_moves2.diff
? fix_3476_a1.diff
? fix_3476_b1.diff
? fregatte-with-horse-2steps.gz
? fregatte-with-horse-4-steps.gz
? fregatte-with-horse.gz
? fun.leaders
? gleich.gz
? gleichgehtslos.gz
? heli.gz
? help.diff
? iuz
? key.diff
? para.gz
? rep-2250-normalplaying-civscore.log
? rep-2250-normalplaying.gz
? rep-2400-not-normal.civscore.log
? rep-2400-not-normal.gz
? rep-in-27.gz
? republic.gz
? rifle-on-rail.gz
? test-35000
? test-ai
? test-big
? test-para
? data/theme
? server/.gamehand.c.swp
? server/.unittools.c.swp
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/19 01:52:55
@@ -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;
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/19 01:52:55
@@ -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;
@@ -377,6 +378,7 @@
 #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.240
diff -u -r1.240 packets.c
--- common/packets.c    2003/02/17 22:49:27     1.240
+++ common/packets.c    2003/03/19 01:52:56
@@ -293,6 +293,7 @@
     return receive_packet_move_unit(pc);
 
   case PACKET_TURN_DONE:
+  case PACKET_REMOVE_TURN_DONE:
     return receive_packet_generic_message(pc);
 
   case PACKET_CONN_PING:
Index: common/packets.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v
retrieving revision 1.141
diff -u -r1.141 packets.h
--- common/packets.h    2003/02/17 22:49:28     1.141
+++ common/packets.h    2003/03/19 01:52:57
@@ -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/19 01:52:58
@@ -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/19 01:52:58
@@ -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/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.272
diff -u -r1.272 stdinhand.c
--- server/stdinhand.c  2003/03/10 16:34:50     1.272
+++ server/stdinhand.c  2003/03/19 01:52:59
@@ -1221,11 +1221,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",
@@ -2229,17 +2231,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) {
@@ -2252,14 +2255,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/19 01:52:59
@@ -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,15 @@
     }
     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;
     }
   }
   conn_list_iterate_end;
+  //if (timeout != 0 && option && yes) 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]