Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12490) Watchtower patch
Home

[Freeciv-Dev] (PR#12490) Watchtower patch

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12490) Watchtower patch
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 12 Mar 2005 05:31:37 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch simplies and enables the watchtower rules.

CHANGES:
 - Moved watchtower options from server options to terrain ruleset
 - Removed the 'wtowervision' option.
 - Set default 'wtowerevision' to 2. This increases the vision range of
any ground unit in a fortress by 2.
 - Simplified the code, and increased max 'wtowerevision' from 2 to 4.

This change might make fortresses somewhat useful.

  - Per

Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.199
diff -u -r1.199 game.c
--- common/game.c       9 Mar 2005 18:49:06 -0000       1.199
+++ common/game.c       12 Mar 2005 13:24:40 -0000
@@ -251,8 +251,7 @@
   game.save_compress_level = GAME_NO_COMPRESS_LEVEL;
 #endif
   game.seed = GAME_DEFAULT_SEED;
-  game.watchtower_vision=GAME_DEFAULT_WATCHTOWER_VISION;
-  game.watchtower_extra_vision=GAME_DEFAULT_WATCHTOWER_EXTRA_VISION,
+  game.watchtower_extra_vision = GAME_DEFAULT_WATCHTOWER_EXTRA_VISION;
   game.allowed_city_names = GAME_DEFAULT_ALLOWED_CITY_NAMES;
 
   sz_strlcpy(game.rulesetdir, GAME_DEFAULT_RULESETDIR);
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.177
diff -u -r1.177 game.h
--- common/game.h       9 Mar 2005 18:49:06 -0000       1.177
+++ common/game.h       12 Mar 2005 13:24:40 -0000
@@ -165,7 +165,6 @@
   int terrain_count;
 
   int watchtower_extra_vision;
-  int watchtower_vision;
   int allowed_city_names;
 
   int borders;         /* distance of border from city; 0=disabled. */
@@ -504,13 +503,9 @@
 #define GAME_MAX_REPUTATION 1000
 #define GAME_REPUTATION_INCR 2
 
-#define GAME_DEFAULT_WATCHTOWER_VISION 2
-#define GAME_MIN_WATCHTOWER_VISION 1
-#define GAME_MAX_WATCHTOWER_VISION 3
-
-#define GAME_DEFAULT_WATCHTOWER_EXTRA_VISION 0
+#define GAME_DEFAULT_WATCHTOWER_EXTRA_VISION 2
 #define GAME_MIN_WATCHTOWER_EXTRA_VISION 0
-#define GAME_MAX_WATCHTOWER_EXTRA_VISION 2
+#define GAME_MAX_WATCHTOWER_EXTRA_VISION 4
 
 #define GAME_DEFAULT_ALLOWED_CITY_NAMES 1
 #define GAME_MIN_ALLOWED_CITY_NAMES 0
Index: data/default/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/terrain.ruleset,v
retrieving revision 1.36
diff -u -r1.36 terrain.ruleset
--- data/default/terrain.ruleset        30 Nov 2004 05:46:34 -0000      1.36
+++ data/default/terrain.ruleset        12 Mar 2005 13:24:41 -0000
@@ -60,6 +60,9 @@
 ; percent added to defense if square has fortress
 fortress_defense_bonus=100
 
+; extra vision range given to units in a fortress
+fortress_extra_vision=2
+
 ; percent added to trade production if road and city has superhighways
 road_superhighway_trade_bonus=50
 
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.230
diff -u -r1.230 ruleset.c
--- server/ruleset.c    2 Feb 2005 02:44:32 -0000       1.230
+++ server/ruleset.c    12 Mar 2005 13:24:42 -0000
@@ -1362,6 +1362,16 @@
   }
   terrain_control.fortress_defense_bonus =
     secfile_lookup_int_default(file, 100, "parameters.fortress_defense_bonus");
+
+  game.watchtower_extra_vision = 
+    secfile_lookup_int_default(file, GAME_DEFAULT_WATCHTOWER_EXTRA_VISION,
+                               "parameters.fortress_extra_vision");
+  if (game.watchtower_extra_vision < GAME_MIN_WATCHTOWER_EXTRA_VISION
+      || game.watchtower_extra_vision > GAME_MAX_WATCHTOWER_EXTRA_VISION) {
+    freelog(LOG_FATAL, _("Fortress vision range set to illegal value."));
+    exit(EXIT_FAILURE);
+  }
+
   terrain_control.road_superhighway_trade_bonus =
     secfile_lookup_int_default(file, 50, 
"parameters.road_superhighway_trade_bonus");
   output_type_iterate(o) {
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.224
diff -u -r1.224 savegame.c
--- server/savegame.c   4 Mar 2005 18:48:08 -0000       1.224
+++ server/savegame.c   12 Mar 2005 13:24:42 -0000
@@ -3188,11 +3188,8 @@
     if (has_capability("watchtower", savefile_options)) {
       game.watchtower_extra_vision =
          secfile_lookup_int(file, "game.watchtower_extra_vision");
-      game.watchtower_vision =
-         secfile_lookup_int(file, "game.watchtower_vision");
     } else {
       game.watchtower_extra_vision = 0;
-      game.watchtower_vision = 1;
     }
 
     sz_strlcpy(game.save_name,
@@ -3724,7 +3721,6 @@
   secfile_insert_int(file, game.borders, "game.borders");
   secfile_insert_bool(file, game.happyborders, "game.happyborders");
   secfile_insert_int(file, game.diplomacy, "game.diplomacy");
-  secfile_insert_int(file, game.watchtower_vision, "game.watchtower_vision");
   secfile_insert_int(file, game.watchtower_extra_vision, 
"game.watchtower_extra_vision");
   secfile_insert_int(file, game.allowed_city_names, "game.allowed_city_names");
 
Index: server/settings.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settings.c,v
retrieving revision 1.19
diff -u -r1.19 settings.c
--- server/settings.c   4 Mar 2005 18:48:08 -0000       1.19
+++ server/settings.c   12 Mar 2005 13:24:42 -0000
@@ -626,31 +626,6 @@
          GAME_MIN_KILLCITIZEN, GAME_MAX_KILLCITIZEN,
          GAME_DEFAULT_KILLCITIZEN)
 
-  GEN_INT("wtowervision", game.watchtower_vision,
-         SSET_RULES, SSET_MILITARY, SSET_RARE, SSET_TO_CLIENT,
-         N_("Range of vision for units in a fortress"),
-         N_("If set to 1, it has no effect. "
-            "If 2 or larger, the vision range of a unit inside a "
-            "fortress is set to this value, if the necessary invention "
-            "has been made. This invention is determined by the flag "
-            "'Watchtower' in the techs ruleset. See also wtowerevision."), 
-         NULL, 
-         GAME_MIN_WATCHTOWER_VISION, GAME_MAX_WATCHTOWER_VISION, 
-         GAME_DEFAULT_WATCHTOWER_VISION)
-
-  GEN_INT("wtowerevision", game.watchtower_extra_vision,
-         SSET_RULES, SSET_MILITARY, SSET_RARE, SSET_TO_CLIENT,
-         N_("Extra vision range for units in a fortress"),
-         N_("If set to 0, it has no "
-            "effect. If larger than 0, the vision range of a unit is "
-            "raised by this value, if the unit is inside a fortress "
-            "and the invention determined by the flag 'Watchtower' "
-            "in the techs ruleset has been made. Always the larger "
-            "value of wtowervision and wtowerevision will be used. "
-            "Also see wtowervision."), NULL, 
-         GAME_MIN_WATCHTOWER_EXTRA_VISION, GAME_MAX_WATCHTOWER_EXTRA_VISION, 
-         GAME_DEFAULT_WATCHTOWER_EXTRA_VISION)
-
   GEN_INT("borders", game.borders,
          SSET_RULES, SSET_MILITARY, SSET_SITUATIONAL, SSET_TO_CLIENT,
          N_("National borders radius"),
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.325
diff -u -r1.325 unittools.c
--- server/unittools.c  6 Mar 2005 18:37:28 -0000       1.325
+++ server/unittools.c  12 Mar 2005 13:24:43 -0000
@@ -3244,23 +3244,16 @@
 }
 
 /**************************************************************************
-...
+  Get the vision range of a unit standing inside a 'watchtower'.
 **************************************************************************/
 int get_watchtower_vision(struct unit *punit)
 {
-  int base_vision = unit_type(punit)->vision_range;
-
-  assert(base_vision > 0);
-  assert(game.watchtower_vision > 0);
-  assert(game.watchtower_extra_vision >= 0);
-
-  return MAX(base_vision,
-            MAX(game.watchtower_vision,
-                base_vision + game.watchtower_extra_vision));
+  return (unit_type(punit)->vision_range + game.watchtower_extra_vision);
 }
 
 /**************************************************************************
-...
+  Would a unit gain extra vision range due to a 'watchtower', if there
+  was one present?
 **************************************************************************/
 bool unit_profits_of_watchtower(struct unit *punit)
 {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12490) Watchtower patch, Per I. Mathisen <=