Author: sveinung
Date: Tue Jan 24 16:17:08 2017
New Revision: 34887

URL: http://svn.gna.org/viewcvs/freeciv?rev=34887&view=rev
Log:
Move city is seen check to player module.

Rename mke_can_see_city_externals() to player_can_see_city_externals() and
move it to the player module.

See patch #8081

Modified:
    branches/S2_6/common/metaknowledge.c
    branches/S2_6/common/metaknowledge.h
    branches/S2_6/common/player.c
    branches/S2_6/common/player.h

Modified: branches/S2_6/common/metaknowledge.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/metaknowledge.c?rev=34887&r1=34886&r2=34887&view=diff
==============================================================================
--- branches/S2_6/common/metaknowledge.c        (original)
+++ branches/S2_6/common/metaknowledge.c        Tue Jan 24 16:17:08 2017
@@ -330,7 +330,7 @@
       return prob_type == RPT_CERTAIN;
     }
 
-    if (mke_can_see_city_externals(pow_player, target_city)) {
+    if (player_can_see_city_externals(pow_player, target_city)) {
       return TRUE;
     }
   }
@@ -431,7 +431,7 @@
       }
 
       if (is_improvement_visible(req->source.value.building)
-          && mke_can_see_city_externals(pow_player, target_city)) {
+          && player_can_see_city_externals(pow_player, target_city)) {
         /* Can see visible improvements when the outside of the city is
          * seen. */
         return TRUE;
@@ -677,36 +677,3 @@
   return pow_player == target_player
       || player_has_embassy(pow_player, target_player);
 }
-
-/**************************************************************************
-  Returns TRUE iff pow_player can see externally visible features of
-  target_city.
-
-  A city's external features are visible to its owner, to players that
-  currently sees the tile it is located at and to players that has it as
-  a trade partner.
-**************************************************************************/
-bool mke_can_see_city_externals(const struct player *pow_player,
-                                const struct city *target_city) {
-  fc_assert_ret_val(target_city, FALSE);
-  fc_assert_ret_val(pow_player, FALSE);
-
-  if (can_player_see_city_internals(pow_player, target_city)) {
-    /* City internals includes city externals. */
-    return TRUE;
-  }
-
-  if (tile_is_seen(city_tile(target_city), pow_player)) {
-    /* The tile is being observed. */
-    return TRUE;
-  }
-
-  trade_routes_iterate(target_city, trade_city) {
-    if (city_owner(trade_city) == pow_player) {
-      /* Revealed because of the trade route. */
-      return TRUE;
-    }
-  } trade_routes_iterate_end;
-
-  return FALSE;
-}

Modified: branches/S2_6/common/metaknowledge.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/metaknowledge.h?rev=34887&r1=34886&r2=34887&view=diff
==============================================================================
--- branches/S2_6/common/metaknowledge.h        (original)
+++ branches/S2_6/common/metaknowledge.h        Tue Jan 24 16:17:08 2017
@@ -54,9 +54,6 @@
 bool can_see_techs_of_target(const struct player *pow_player,
                              const struct player *target_player);
 
-bool mke_can_see_city_externals(const struct player *pow_player,
-                                const struct city *target_city);
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: branches/S2_6/common/player.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/player.c?rev=34887&r1=34886&r2=34887&view=diff
==============================================================================
--- branches/S2_6/common/player.c       (original)
+++ branches/S2_6/common/player.c       Tue Jan 24 16:17:08 2017
@@ -35,6 +35,7 @@
 #include "research.h"
 #include "rgbcolor.h"
 #include "tech.h"
+#include "traderoutes.h"
 #include "unit.h"
 #include "unitlist.h"
 #include "vision.h"
@@ -1032,6 +1033,39 @@
                                   const struct city *pcity)
 {
   return (!pplayer || pplayer == city_owner(pcity));
+}
+
+/**************************************************************************
+  Returns TRUE iff pow_player can see externally visible features of
+  target_city.
+
+  A city's external features are visible to its owner, to players that
+  currently sees the tile it is located at and to players that has it as
+  a trade partner.
+**************************************************************************/
+bool player_can_see_city_externals(const struct player *pow_player,
+                                   const struct city *target_city) {
+  fc_assert_ret_val(target_city, FALSE);
+  fc_assert_ret_val(pow_player, FALSE);
+
+  if (can_player_see_city_internals(pow_player, target_city)) {
+    /* City internals includes city externals. */
+    return TRUE;
+  }
+
+  if (tile_is_seen(city_tile(target_city), pow_player)) {
+    /* The tile is being observed. */
+    return TRUE;
+  }
+
+  trade_routes_iterate(target_city, trade_city) {
+    if (city_owner(trade_city) == pow_player) {
+      /* Revealed because of the trade route. */
+      return TRUE;
+    }
+  } trade_routes_iterate_end;
+
+  return FALSE;
 }
 
 /***************************************************************

Modified: branches/S2_6/common/player.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/player.h?rev=34887&r1=34886&r2=34887&view=diff
==============================================================================
--- branches/S2_6/common/player.h       (original)
+++ branches/S2_6/common/player.h       Tue Jan 24 16:17:08 2017
@@ -393,6 +393,8 @@
                                  const struct city *pcity);
 bool can_player_see_city_internals(const struct player *pplayer,
                                   const struct city *pcity);
+bool player_can_see_city_externals(const struct player *pow_player,
+                                   const struct city *target_city);
 
 bool player_owns_city(const struct player *pplayer,
                      const struct city *pcity);


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

Reply via email to