[Freeciv-Dev] (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] (PR#4669) more restrict borders politic |
From: |
"Rafa³ Bursig" <bursig@xxxxxxxxx> |
Date: |
Thu, 24 Jul 2003 10:27:19 -0700 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
Hi All
This code add :
1) all (land and sea) city terrains belong to your territory.
2) city workers can work only on your territory.
3) new cities can only be build on neutral, your and allied territory.
+ small fix in worker placements.
Rafal
diff -u -r freeciv/common/city.c fc/common/city.c
--- freeciv/common/city.c Mon Jul 21 17:05:10 2003
+++ fc/common/city.c Thu Jul 24 17:37:34 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,17 @@
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 player territory */
+ if (ptile->owner && !pplayers_allied(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 freeciv/server/citytools.c fc/server/citytools.c
--- freeciv/server/citytools.c Thu Jul 24 12:24:19 2003
+++ fc/server/citytools.c Thu Jul 24 18:09:26 2003
@@ -1868,13 +1868,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)
@@ -1882,25 +1887,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 freeciv/server/maphand.c fc/server/maphand.c
--- freeciv/server/maphand.c Thu Jul 24 12:24:19 2003
+++ fc/server/maphand.c Thu Jul 24 16:08:14 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 freeciv/server/sanitycheck.c fc/server/sanitycheck.c
--- freeciv/server/sanitycheck.c Thu Jul 24 12:24:19 2003
+++ fc/server/sanitycheck.c Thu Jul 24 16:27:58 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);
- [Freeciv-Dev] (PR#4669) more restrict borders politic,
Rafa³ Bursig <=
|
|