Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Re: (PR#4669) more restrict borders politic
Home

[Freeciv-Dev] Re: (PR#4669) more restrict borders politic

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#4669) more restrict borders politic
From: "Rafa³ Bursig" <bursig@xxxxxxxxx>
Date: Mon, 28 Jul 2003 06:39:58 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Dnia 2003.07.25 19:46, Guest napisa³(a):
> 
> [bursig - Thu Jul 24 17:27:19 2003]:
> 
> > 1) all (land and sea) city terrains belong to your territory.
> 
> This is bad because of compatibility with other games and that narrow
> waters will be impassable.
We shouldn't blid clone wrong design of other games,
and this clean some strange situations.

> > 2) city workers can work only on your territory.
> 
> This is bad because they should be able to work on neutral territory.
City have no conntact with neutral territory only with own or enemy 
territory.

> > 3) new cities can only be build on neutral, your and allied
> territory.
> 
> This is bad because it must be possible to build cities on enemie's
> territory.
> That is an act of war.
The act of war is when you decleare war other player but here you have 
right we should be able build new city when we are at war with tile 
owner. New patch fix it.

Rafal
diff -u -r ../cvs/freeciv/common/city.c freeciv/common/city.c
--- ../cvs/freeciv/common/city.c        Mon Jul 21 17:05:10 2003
+++ freeciv/common/city.c       Mon Jul 28 14:28:32 2003
@@ -189,11 +189,8 @@
 **************************************************************************/
 bool is_worker_here(struct city *pcity, int city_x, int city_y) 
 {
-  if (!is_valid_city_coords(city_x, city_y)) {
-    return FALSE;
-  }
-
-  return get_worker_city(pcity, city_x, city_y) == C_TILE_WORKER;
+  /* is_valid_city_coords check is make inside get_worker_city */
+  return (get_worker_city(pcity, city_x, city_y) == C_TILE_WORKER);
 }
 
 /**************************************************************************
@@ -823,11 +820,18 @@
 bool city_can_be_built_here(int x, int y, struct unit *punit)
 {
   enum unit_move_type move_type = unit_type(punit)->move_type;
-
+  struct tile *ptile = map_get_tile(x, y);
+  
+  /* you can build city on neutral, your, and allied/"at war" player territory 
*/
+  if (ptile->owner && (!pplayers_allied(ptile->owner, unit_owner(punit))
+                      || !pplayers_at_war(ptile->owner, unit_owner(punit))) {
+    return FALSE;
+  }
+  
   /* We allow land units to build land cities and sea units to build
    * ocean cities. */
-  if ((move_type == LAND_MOVING && is_ocean(map_get_terrain(x, y)))
-      || (move_type == SEA_MOVING && !is_ocean(map_get_terrain(x, y)))) {
+  if ((move_type == LAND_MOVING && is_ocean(ptile->terrain))
+      || (move_type == SEA_MOVING && !is_ocean(ptile->terrain))) {
     return FALSE;
   }
 
diff -u -r ../cvs/freeciv/server/citytools.c freeciv/server/citytools.c
--- ../cvs/freeciv/server/citytools.c   Thu Jul 24 22:13:37 2003
+++ freeciv/server/citytools.c  Mon Jul 28 14:24:44 2003
@@ -1869,13 +1869,18 @@
 **************************************************************************/
 bool can_place_worker_here(struct city *pcity, int city_x, int city_y)
 {
-  return get_worker_city(pcity, city_x, city_y) == C_TILE_EMPTY;
+  return ((get_worker_city(pcity, city_x, city_y) == C_TILE_EMPTY)
+         && city_can_work_tile(pcity, city_x, city_y));
 }
 
 /**************************************************************************
-Returns if a tile is available to be worked.
-Return true if the city itself is currently working the tile (and can
-continue.)
+Returns TRUE if a tile is available to be worked.
+Return true if ...
+ (a) you know that tile AND
+ (b) the tile belong to you AND
+ (c) if worked then only your city can
+       currently working the tile (and can continue.) AND
+ (d) there is no enemy units.
 city_x, city_y is in city map coords.
 **************************************************************************/
 bool city_can_work_tile(struct city *pcity, int city_x, int city_y)
@@ -1883,25 +1888,13 @@
   int map_x, map_y;
   struct tile *ptile;
 
-  if (!city_map_to_map(&map_x, &map_y, pcity, city_x, city_y))
-    return FALSE;
-  ptile = map_get_tile(map_x, map_y);
-
-  if (is_enemy_unit_tile(ptile, city_owner(pcity))
-      && !is_city_center(city_x, city_y))
-    return FALSE;
-
-  if (!map_get_known(map_x, map_y, city_owner(pcity)))
-    return FALSE;
-
-  if (ptile->worked && ptile->worked != pcity)
-    return FALSE;
-
-  if (ptile->owner && ptile->owner->player_no != pcity->owner) {
-    return FALSE;
-  }
-
-  return TRUE;
+  return (city_map_to_map(&map_x, &map_y, pcity, city_x, city_y)
+       && (ptile = map_get_tile(map_x, map_y))
+        && TEST_BIT(ptile->known, pcity->owner) /* map_get_known(map_x, map_y, 
city_owner(pcity)) */
+       && (ptile->owner && ptile->owner->player_no == pcity->owner)
+       && !(ptile->worked && ptile->worked != pcity)
+        && !(is_enemy_unit_tile(ptile, city_owner(pcity))
+                 && !is_city_center(city_x, city_y)));
 }
 
 /**************************************************************************
diff -u -r ../cvs/freeciv/server/maphand.c freeciv/server/maphand.c
--- ../cvs/freeciv/server/maphand.c     Thu Jul 24 12:24:19 2003
+++ freeciv/server/maphand.c    Mon Jul 28 14:24:44 2003
@@ -1463,20 +1463,22 @@
 {
   struct city *closest = NULL;   /* Closest city */
   struct tile *ptile;
-
+  int dist_city = game.borders, dist;  /* Squared distance to city */
+  
   ptile = map_get_tile(x, y);
   if (ptile->city) {
     return ptile->city;
   }
 
-  adjc_iterate(x, y, xp, yp) {
+  map_city_radius_iterate(x, y, xp, yp) {
     ptile = map_get_tile(xp, yp);
-    if (ptile->city && 
+    if (ptile->city && ((dist = sq_map_distance(x, y, xp, yp)) <= dist_city) &&
          (!closest || ptile->city->turn_founded < closest->turn_founded)) {
+      dist_city = dist;   
       closest = ptile->city;
     }
-  } adjc_iterate_end;
-
+  } map_city_radius_iterate_end;
+  
   return closest;
 }
 
diff -u -r ../cvs/freeciv/server/sanitycheck.c freeciv/server/sanitycheck.c
--- ../cvs/freeciv/server/sanitycheck.c Thu Jul 24 12:24:19 2003
+++ freeciv/server/sanitycheck.c        Mon Jul 28 14:24:44 2003
@@ -161,7 +161,7 @@
                      pcity->name, x, y);
            }
            if (game.borders > 0
-               && owner && owner->player_no != pcity->owner) {
+               && (!owner || owner->player_no != pcity->owner)) {
              freelog(LOG_ERROR, "Tile at %s->%d,%d marked as "
                      "empty but in enemy territory!",
                      pcity->name, x, y);
@@ -179,7 +179,7 @@
                      pcity->name, x, y);
            }
            if (game.borders > 0
-                && owner && owner->player_no != pcity->owner) {
+                && (!owner || owner->player_no != pcity->owner)) {
              freelog(LOG_ERROR, "Tile at %s->%d,%d marked as "
                      "worked but in enemy territory!",
                      pcity->name, x, y);
@@ -189,7 +189,7 @@
            if (!map_get_tile(map_x, map_y)->worked
                && !is_enemy_unit_tile(ptile, pplayer)
                && map_get_known(map_x, map_y, pplayer)
-               && (!owner || owner->player_no == pcity->owner)) {
+               && (owner && owner->player_no == pcity->owner)) {
              freelog(LOG_ERROR, "Tile at %s->%d,%d marked as "
                      "unavailable but seems to be available!",
                      pcity->name, x, y);

[Prev in Thread] Current Thread [Next in Thread]