Author: sveinung
Date: Wed Jan 18 22:48:14 2017
New Revision: 34867

URL: http://svn.gna.org/viewcvs/freeciv?rev=34867&view=rev
Log:
Move tile seen checker to the tile module.

Rename the function is_tile_seen() to tile_is_seen() and move it from the
metaknowledge module to the tile module.

See patch #8080

Modified:
    trunk/common/metaknowledge.c
    trunk/common/tile.c
    trunk/common/tile.h

Modified: trunk/common/metaknowledge.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/metaknowledge.c?rev=34867&r1=34866&r2=34867&view=diff
==============================================================================
--- trunk/common/metaknowledge.c        (original)
+++ trunk/common/metaknowledge.c        Wed Jan 18 22:48:14 2017
@@ -41,15 +41,6 @@
 }
 
 /**************************************************************************
-  Returns TRUE iff the target_tile is seen by pow_player.
-**************************************************************************/
-static bool is_tile_seen(const struct player *pow_player,
-                         const struct tile *target_tile)
-{
-  return tile_get_known(target_tile, pow_player) == TILE_KNOWN_SEEN;
-}
-
-/**************************************************************************
   Returns TRUE iff the target_tile it self and all tiles cardinally
   adjacent to it are seen by pow_player.
 **************************************************************************/
@@ -57,13 +48,13 @@
                               const struct tile *target_tile)
 {
   /* The tile it self is unseen. */
-  if (!is_tile_seen(pow_player, target_tile)) {
+  if (!tile_is_seen(target_tile, pow_player)) {
     return FALSE;
   }
 
   /* A cardinally adjacent tile is unseen. */
   cardinal_adjc_iterate(target_tile, ptile) {
-    if (!is_tile_seen(pow_player, ptile)) {
+    if (!tile_is_seen(ptile, pow_player)) {
       return FALSE;
     }
   } cardinal_adjc_iterate_end;
@@ -80,13 +71,13 @@
                              const struct tile *target_tile)
 {
   /* The tile it self is unseen. */
-  if (!is_tile_seen(pow_player, target_tile)) {
+  if (!tile_is_seen(target_tile, pow_player)) {
     return FALSE;
   }
 
   /* An adjacent tile is unseen. */
   adjc_iterate(target_tile, ptile) {
-    if (!is_tile_seen(pow_player, ptile)) {
+    if (!tile_is_seen(ptile, pow_player)) {
       return FALSE;
     }
   } adjc_iterate_end;
@@ -109,7 +100,7 @@
   /* A tile of the city is unseen */
   city_tile_iterate(city_map_radius_sq_get(target_city),
                     city_tile(target_city), ptile) {
-    if (!is_tile_seen(pow_player, ptile)) {
+    if (!tile_is_seen(ptile, pow_player)) {
       return FALSE;
     }
   } city_tile_iterate_end;
@@ -361,7 +352,7 @@
     switch (req->range) {
     case REQ_RANGE_LOCAL:
       /* Known because the tile is seen */
-      if (is_tile_seen(pow_player, target_tile)) {
+      if (tile_is_seen(target_tile, pow_player)) {
         return TRUE;
       }
 
@@ -575,7 +566,7 @@
 
     switch (req->range) {
     case REQ_RANGE_LOCAL:
-      return is_tile_seen(pow_player, target_tile);
+      return tile_is_seen(target_tile, pow_player);
     case REQ_RANGE_CADJACENT:
       /* TODO: The answer is known when the universal is located on a seen
        * tile. Is returning TRUE in those cases worth the added complexity
@@ -724,7 +715,7 @@
     return TRUE;
   }
 
-  if (is_tile_seen(pow_player, city_tile(target_city))) {
+  if (tile_is_seen(city_tile(target_city), pow_player)) {
     /* The tile is being observed. */
     return TRUE;
   }

Modified: trunk/common/tile.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/tile.c?rev=34867&r1=34866&r2=34867&view=diff
==============================================================================
--- trunk/common/tile.c (original)
+++ trunk/common/tile.c Wed Jan 18 22:48:14 2017
@@ -428,6 +428,15 @@
   }
 }
 
+/**************************************************************************
+  Returns TRUE iff the target_tile is seen by pow_player.
+**************************************************************************/
+bool tile_is_seen(const struct tile *target_tile,
+                  const struct player *pow_player)
+{
+  return tile_get_known(target_tile, pow_player) == TILE_KNOWN_SEEN;
+}
+
 /****************************************************************************
   Time to complete the given activity on the given tile.
 ****************************************************************************/

Modified: trunk/common/tile.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/tile.h?rev=34867&r1=34866&r2=34867&view=diff
==============================================================================
--- trunk/common/tile.h (original)
+++ trunk/common/tile.h Wed Jan 18 22:48:14 2017
@@ -158,6 +158,9 @@
 enum known_type tile_get_known(const struct tile *ptile,
                              const struct player *pplayer);
 
+bool tile_is_seen(const struct tile *target_tile,
+                  const struct player *pow_player);
+
 /* A somewhat arbitrary integer value.  Activity times are multiplied by
  * this amount, and divided by them later before being used.  This may
  * help to avoid rounding errors; however it should probably be removed. */


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

Reply via email to