Author: sveinung
Date: Wed Sep  9 11:26:33 2015
New Revision: 29829

URL: http://svn.gna.org/viewcvs/freeciv?rev=29829&view=rev
Log:
Add the new effect Border_Vision

When a player has a Border_Vision above 0 he can see all tiles within his
borders. Only useful when the borders setting is set to "Enabled".

Can be used for stuff like a "Leo the Mathematician's Beacon System" wonder
or a "Telegraph" tech.

See patch #6331

Modified:
    trunk/ai/default/daieffects.c
    trunk/client/helpdata.c
    trunk/common/effects.h
    trunk/common/player.h
    trunk/doc/README.effects
    trunk/fc_version
    trunk/server/maphand.c
    trunk/server/maphand.h
    trunk/server/plrhand.c
    trunk/server/savegame.c
    trunk/server/savegame2.c
    trunk/server/savegame3.c
    trunk/server/srv_main.c

Modified: trunk/ai/default/daieffects.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/daieffects.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/ai/default/daieffects.c       (original)
+++ trunk/ai/default/daieffects.c       Wed Sep  9 11:26:33 2015
@@ -533,6 +533,7 @@
   case EFT_CASUS_BELLI_CAUGHT:
   case EFT_CASUS_BELLI_SUCCESS:
   case EFT_ACTION_ODDS_PCT:
+  case EFT_BORDER_VISION:
     break;
     /* This has no effect for AI */
   case EFT_VISIBLE_WALLS:

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Wed Sep  9 11:26:33 2015
@@ -5472,6 +5472,13 @@
           }
         }
         break;
+      case EFT_BORDER_VISION:
+        if (game.info.borders == BORDERS_ENABLED
+            && playerwide && net_value > 0) {
+          CATLSTR(buf, bufsz, _("* All tiles inside your borders are"
+                                " monitored.\n"));
+        }
+        break;
       default:
         break;
       };

Modified: trunk/common/effects.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/effects.h?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/common/effects.h      (original)
+++ trunk/common/effects.h      Wed Sep  9 11:26:33 2015
@@ -281,6 +281,8 @@
 #define SPECENUM_VALUE109NAME "Casus_Belli_Success"
 #define SPECENUM_VALUE110 EFT_ACTION_ODDS_PCT
 #define SPECENUM_VALUE110NAME "Action_Odds_Pct"
+#define SPECENUM_VALUE111 EFT_BORDER_VISION
+#define SPECENUM_VALUE111NAME "Border_Vision"
 /* keep this last */
 #define SPECENUM_COUNT EFT_COUNT
 #include "specenum_gen.h"

Modified: trunk/common/player.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/player.h?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/common/player.h       (original)
+++ trunk/common/player.h       Wed Sep  9 11:26:33 2015
@@ -284,6 +284,9 @@
 
       struct player_tile *private_map;
 
+      /* Player can see inside his borders. */
+      bool border_vision;
+
       bv_player really_gives_vision; /* takes into account that p3 may see
                                       * what p1 has via p2 */
 

Modified: trunk/doc/README.effects
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.effects?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/doc/README.effects    (original)
+++ trunk/doc/README.effects    Wed Sep  9 11:26:33 2015
@@ -217,6 +217,12 @@
 Reveal_Map
     Immediately make entire map known.
 
+Border_Vision
+    Give vision on all tiles within the player's borders. Happens during
+    turn change.
+    Does nothing unless the borders setting is set to "Enabled". You can
+    lock it if border vision rules are important to your ruleset.
+
 Incite_Cost_Pct
     Increases revolt cost by amount percent.
 

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Wed Sep  9 11:26:33 2015
@@ -54,7 +54,7 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Sep.06"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Sep.09"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/maphand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/maphand.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/server/maphand.c      (original)
+++ trunk/server/maphand.c      Wed Sep  9 11:26:33 2015
@@ -667,6 +667,33 @@
     shared_vision_change_seen(pplayer, tile1, change, can_reveal_tiles);
   } circle_dxyr_iterate_end;
   unbuffer_shared_vision(pplayer);
+}
+
+/**************************************************************************
+  Turn a players ability to see inside his borders on or off.
+
+  It is safe to set the current value.
+**************************************************************************/
+void map_set_border_vision(struct player *pplayer,
+                           const bool is_enabled)
+{
+  const v_radius_t radius_sq = V_RADIUS(is_enabled ? 1 : -1, 0);
+
+  if (pplayer->server.border_vision == is_enabled) {
+    /* No change. Changing the seen count beyond what already exists would
+     * be a bug. */
+    return;
+  }
+
+  /* Set the new border seer value. */
+  pplayer->server.border_vision = is_enabled;
+
+  whole_map_iterate(ptile) {
+    if (pplayer == ptile->owner) {
+      /* The tile is within the player's borders. */
+      shared_vision_change_seen(pplayer, ptile, radius_sq, TRUE);
+    }
+  } whole_map_iterate_end;
 }
 
 /****************************************************************************
@@ -1884,7 +1911,8 @@
   struct player *ploser = tile_owner(ptile);
 
   if (BORDERS_SEE_INSIDE == game.info.borders
-      || BORDERS_EXPAND == game.info.borders) {
+      || BORDERS_EXPAND == game.info.borders
+      || (powner && powner->server.border_vision)) {
     if (ploser != powner) {
       if (ploser) {
         const v_radius_t radius_sq = V_RADIUS(-1, 0);

Modified: trunk/server/maphand.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/maphand.h?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/server/maphand.h      (original)
+++ trunk/server/maphand.h      Wed Sep  9 11:26:33 2015
@@ -69,6 +69,8 @@
                        const v_radius_t old_radius_sq,
                        const v_radius_t new_radius_sq,
                        bool can_reveal_tiles);
+void map_set_border_vision(struct player *pplayer,
+                           const bool is_enabled);
 void map_show_all(struct player *pplayer);
 
 bool map_is_known_and_seen(const struct tile *ptile,

Modified: trunk/server/plrhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/plrhand.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/server/plrhand.c      (original)
+++ trunk/server/plrhand.c      Wed Sep  9 11:26:33 2015
@@ -1296,6 +1296,8 @@
   BV_CLR_ALL(pplayer->server.really_gives_vision);
   BV_CLR_ALL(pplayer->server.debug);
 
+  pplayer->server.border_vision = FALSE;
+
   player_map_free(pplayer);
   pplayer->server.private_map = NULL;
 
@@ -2493,6 +2495,8 @@
   /* copy the maps */
 
   give_map_from_player_to_player(pplayer, cplayer);
+
+  pplayer->server.border_vision = cplayer->server.border_vision;
 
   /* Not sure if this is necessary, but might be a good idea
    * to avoid doing some ai calculations with bogus data. */

Modified: trunk/server/savegame.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/server/savegame.c     (original)
+++ trunk/server/savegame.c     Wed Sep  9 11:26:33 2015
@@ -3941,6 +3941,12 @@
     /* Load map player data. */
     players_iterate(pplayer) {
       player_map_init(pplayer);
+
+      /* Just in case savecompat starts adding it in the future. */
+      pplayer->server.border_vision =
+          secfile_lookup_bool_default(file, FALSE,
+                                      "player%d.border_vision",
+                                      player_number(pplayer));
     } players_iterate_end;
     map_load_known(file, savefile_options);
     map_load_owner(file, savefile_options);

Modified: trunk/server/savegame2.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame2.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/server/savegame2.c    (original)
+++ trunk/server/savegame2.c    Wed Sep  9 11:26:33 2015
@@ -2290,6 +2290,12 @@
         pplayer->multipliers_target[index] = rval;
       } /* else silently discard multiplier not in current ruleset */
     }
+
+    /* Just in case savecompat starts adding it in the future. */
+    pplayer->server.border_vision =
+        secfile_lookup_bool_default(loading->file, FALSE,
+                                    "player%d.border_vision",
+                                    player_slot_index(pslot));
   } player_slots_iterate_end;
 
   /* check number of players */

Modified: trunk/server/savegame3.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/savegame3.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/server/savegame3.c    (original)
+++ trunk/server/savegame3.c    Wed Sep  9 11:26:33 2015
@@ -3158,6 +3158,12 @@
         pplayer->multipliers_target[index] = rval;
       } /* else silently discard multiplier not in current ruleset */
     }
+
+    /* Must be loaded before tile owner is set. */
+    pplayer->server.border_vision =
+        secfile_lookup_bool_default(loading->file, FALSE,
+                                    "player%d.border_vision",
+                                    player_slot_index(pslot));
   } player_slots_iterate_end;
 
   /* check number of players */
@@ -4075,6 +4081,9 @@
                      "player%d.culture", plrno);
   secfile_insert_int(saving->file, plr->server.huts,
                      "player%d.hut_count", plrno);
+
+  secfile_insert_bool(saving->file, plr->server.border_vision,
+                      "player%d.border_vision", plrno);
 }
 
 /****************************************************************************

Modified: trunk/server/srv_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_main.c?rev=29829&r1=29828&r2=29829&view=diff
==============================================================================
--- trunk/server/srv_main.c     (original)
+++ trunk/server/srv_main.c     Wed Sep  9 11:26:33 2015
@@ -665,6 +665,33 @@
 }
 
 /**************************************************************************
+  Handle the vision granting effect EFT_BORDER_VISION
+**************************************************************************/
+static void do_border_vision_effect(void)
+{
+  if (game.info.borders != BORDERS_ENABLED) {
+    /* Border_Vision is useless. If borders are disabled there are no
+     * borders to see inside. If borders are seen they are seen already.
+     * The borders setting can't change after the game has started. */
+    return;
+  }
+
+  phase_players_iterate(plr) {
+    bool new_border_vision;
+
+    /* Check the Border_Vision effect for this player. */
+    new_border_vision = (0 < get_player_bonus(plr, EFT_BORDER_VISION));
+
+    if (new_border_vision != plr->server.border_vision) {
+      /* Border vision changed. */
+
+      /* Update the map */
+      map_set_border_vision(plr, new_border_vision);
+    }
+  } phase_players_iterate_end;
+}
+
+/**************************************************************************
   Handle environmental upsets, meaning currently pollution or fallout.
 **************************************************************************/
 static void update_environmental_upset(enum environment_upset_type type,
@@ -1170,6 +1197,7 @@
 
   do_reveal_effects();
   do_have_contacts_effect();
+  do_border_vision_effect();
 
   phase_players_iterate(pplayer) {
     CALL_PLR_AI_FUNC(phase_finished, pplayer, pplayer);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to