Author: sveinung
Date: Tue Jan 24 16:15:40 2017
New Revision: 34885

URL: http://svn.gna.org/viewcvs/freeciv?rev=34885&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:
    trunk/common/actions.c
    trunk/common/metaknowledge.c
    trunk/common/metaknowledge.h
    trunk/common/player.c
    trunk/common/player.h

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=34885&r1=34884&r2=34885&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Tue Jan 24 16:15:40 2017
@@ -1952,7 +1952,7 @@
       int new_pop;
 
       if (!omniscient
-          && !mke_can_see_city_externals(actor_player, target_city)) {
+          && !player_can_see_city_externals(actor_player, target_city)) {
         return TRI_MAYBE;
       }
 

Modified: trunk/common/metaknowledge.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/metaknowledge.c?rev=34885&r1=34884&r2=34885&view=diff
==============================================================================
--- trunk/common/metaknowledge.c        (original)
+++ trunk/common/metaknowledge.c        Tue Jan 24 16:15:40 2017
@@ -335,7 +335,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;
     }
   }
@@ -450,7 +450,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;
@@ -696,38 +696,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;
-  }
-
-  fc_assert_ret_val(target_city->routes, FALSE);
-
-  trade_partners_iterate(target_city, trade_city) {
-    if (city_owner(trade_city) == pow_player) {
-      /* Revealed because of the trade route. */
-      return TRUE;
-    }
-  } trade_partners_iterate_end;
-
-  return FALSE;
-}

Modified: trunk/common/metaknowledge.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/metaknowledge.h?rev=34885&r1=34884&r2=34885&view=diff
==============================================================================
--- trunk/common/metaknowledge.h        (original)
+++ trunk/common/metaknowledge.h        Tue Jan 24 16:15:40 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: trunk/common/player.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/player.c?rev=34885&r1=34884&r2=34885&view=diff
==============================================================================
--- trunk/common/player.c       (original)
+++ trunk/common/player.c       Tue Jan 24 16:15:40 2017
@@ -1055,6 +1055,41 @@
                                   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;
+  }
+
+  fc_assert_ret_val(target_city->routes, FALSE);
+
+  trade_partners_iterate(target_city, trade_city) {
+    if (city_owner(trade_city) == pow_player) {
+      /* Revealed because of the trade route. */
+      return TRUE;
+    }
+  } trade_partners_iterate_end;
+
+  return FALSE;
 }
 
 /***************************************************************

Modified: trunk/common/player.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/player.h?rev=34885&r1=34884&r2=34885&view=diff
==============================================================================
--- trunk/common/player.h       (original)
+++ trunk/common/player.h       Tue Jan 24 16:15:40 2017
@@ -413,6 +413,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