From 3055d50d14229c4ad6bceb2f8c0abec68d6ebc3c Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 2 Sep 2023 14:02:43 +0300 Subject: [PATCH 6/6] Unify occurrences of "neighbour" to "neighbor" Drop obsolete rand_neighbour() completely. See osdn #48549 Signed-off-by: Marko Lindqvist --- ai/default/daisettler.c | 2 +- client/gui-gtk-3.0/sprite.c | 4 +-- client/gui-gtk-3.22/sprite.c | 4 +-- client/gui-gtk-4.0/sprite.c | 2 +- common/aicore/caravan.h | 2 +- common/map.c | 47 ++++------------------------------- common/map.h | 2 -- data/alien/units.ruleset | 2 +- data/nation/hittite.ruleset | 2 +- doc/HACKING | 4 +-- server/advisors/advbuilding.c | 6 ++++- server/advisors/infracache.h | 8 +++--- server/barbarian.c | 4 +-- 13 files changed, 27 insertions(+), 62 deletions(-) diff --git a/ai/default/daisettler.c b/ai/default/daisettler.c index 334e0b02cd..754079f279 100644 --- a/ai/default/daisettler.c +++ b/ai/default/daisettler.c @@ -800,7 +800,7 @@ static struct cityresult *settler_map_iterate(struct ai_type *ait, if (NULL != powner && powner != pplayer && pplayers_in_peace(powner, pplayer)) { - /* Land theft does not make for good neighbours. */ + /* Land theft does not make for good neighbors. */ continue; } } diff --git a/client/gui-gtk-3.0/sprite.c b/client/gui-gtk-3.0/sprite.c index 7dd1912608..944d4f289e 100644 --- a/client/gui-gtk-3.0/sprite.c +++ b/client/gui-gtk-3.0/sprite.c @@ -316,10 +316,10 @@ struct sprite *sprite_scale(struct sprite *src, int new_w, int new_h) /************************************************************************//** Method returns the bounding box of a sprite. It assumes a rectangular object/mask. The bounding box contains the border (pixel which have - unset pixel as neighbours) pixel. + unset pixel as neighbors) pixel. ****************************************************************************/ void sprite_get_bounding_box(struct sprite * sprite, int *start_x, - int *start_y, int *end_x, int *end_y) + int *start_y, int *end_x, int *end_y) { unsigned char *data = cairo_image_surface_get_data(sprite->surface); int width = cairo_image_surface_get_width(sprite->surface); diff --git a/client/gui-gtk-3.22/sprite.c b/client/gui-gtk-3.22/sprite.c index 2cf4883661..bb3f76d516 100644 --- a/client/gui-gtk-3.22/sprite.c +++ b/client/gui-gtk-3.22/sprite.c @@ -316,10 +316,10 @@ struct sprite *sprite_scale(struct sprite *src, int new_w, int new_h) /************************************************************************//** Method returns the bounding box of a sprite. It assumes a rectangular object/mask. The bounding box contains the border (pixel which have - unset pixel as neighbours) pixel. + unset pixel as neighbors) pixel. ****************************************************************************/ void sprite_get_bounding_box(struct sprite * sprite, int *start_x, - int *start_y, int *end_x, int *end_y) + int *start_y, int *end_x, int *end_y) { unsigned char *data = cairo_image_surface_get_data(sprite->surface); int width = cairo_image_surface_get_width(sprite->surface); diff --git a/client/gui-gtk-4.0/sprite.c b/client/gui-gtk-4.0/sprite.c index f825ae373b..2c2fb2cb4a 100644 --- a/client/gui-gtk-4.0/sprite.c +++ b/client/gui-gtk-4.0/sprite.c @@ -316,7 +316,7 @@ struct sprite *sprite_scale(struct sprite *src, int new_w, int new_h) /************************************************************************//** Method returns the bounding box of a sprite. It assumes a rectangular object/mask. The bounding box contains the border (pixel which have - unset pixel as neighbours) pixel. + unset pixel as neighbors) pixel. ****************************************************************************/ void sprite_get_bounding_box(struct sprite * sprite, int *start_x, int *start_y, int *end_x, int *end_y) diff --git a/common/aicore/caravan.h b/common/aicore/caravan.h index 6b9be1f210..7557869cc8 100644 --- a/common/aicore/caravan.h +++ b/common/aicore/caravan.h @@ -93,7 +93,7 @@ struct caravan_parameter { bool account_for_broken_routes; /* - * Allow trading with allies and peaceful neighbours. + * Allow trading with allies and peaceful neighbors. * BUG: currently we only consider allies. */ enum foreign_trade_limit allow_foreign_trade; diff --git a/common/map.c b/common/map.c index 5274231bdf..923acd94ce 100644 --- a/common/map.c +++ b/common/map.c @@ -1045,7 +1045,7 @@ void base_map_distance_vector(int *dx, int *dy, /*******************************************************************//** Topology function to find the vector which has the minimum "real" - distance between the map positions (x0, y0) and (x1, y1). If there is + distance between the map positions (x0, y0) and (x1, y1). If there is more than one vector with equal distance, no guarantee is made about which is found. @@ -1056,8 +1056,8 @@ void base_map_distance_vector(int *dx, int *dy, (See also: real_map_distance, map_distance, and sq_map_distance.) With the standard topology the ranges of the return value are: - -map.xsize/2 <= dx <= map.xsize/2 - -map.ysize < dy < map.ysize + -map.xsize / 2 <= dx <= map.xsize / 2 + -map.ysize < dy < map.ysize ***********************************************************************/ void map_distance_vector(int *dx, int *dy, const struct tile *tile0, @@ -1071,44 +1071,7 @@ void map_distance_vector(int *dx, int *dy, } /*******************************************************************//** - Random neighbouring square. -***********************************************************************/ -struct tile *rand_neighbour(const struct civ_map *nmap, - const struct tile *ptile) -{ - int n; - struct tile *tile1; - - /* - * list of all 8 directions - */ - enum direction8 dirs[8] = { - DIR8_NORTHWEST, DIR8_NORTH, DIR8_NORTHEAST, DIR8_WEST, DIR8_EAST, - DIR8_SOUTHWEST, DIR8_SOUTH, DIR8_SOUTHEAST - }; - - /* This clever loop by Trent Piepho will take no more than - * 8 tries to find a valid direction. */ - for (n = 8; n > 0; n--) { - enum direction8 choice = (enum direction8) fc_rand(n); - - /* this neighbour's OK */ - tile1 = mapstep(nmap, ptile, dirs[choice]); - if (tile1) { - return tile1; - } - - /* Choice was bad, so replace it with the last direction in the list. - * On the next iteration, one fewer choices will remain. */ - dirs[choice] = dirs[n - 1]; - } - - fc_assert(FALSE); /* Are we on a 1x1 map with no wrapping??? */ - return NULL; -} - -/*******************************************************************//** - Random square anywhere on the map. Only normal positions (for which + Random square anywhere on the map. Only normal positions (for which is_normal_map_pos returns true) will be found. ***********************************************************************/ struct tile *rand_map_pos(const struct civ_map *nmap) @@ -1120,7 +1083,7 @@ struct tile *rand_map_pos(const struct civ_map *nmap) /*******************************************************************//** Give a random tile anywhere on the map for which the 'filter' function - returns TRUE. Return FALSE if none can be found. The filter may be + returns TRUE. Return FALSE if none can be found. The filter may be NULL if any position is okay; if non-NULL it shouldn't have any side effects. ***********************************************************************/ diff --git a/common/map.h b/common/map.h index eefd719405..82149a70fe 100644 --- a/common/map.h +++ b/common/map.h @@ -264,8 +264,6 @@ void map_distance_vector(int *dx, int *dy, const struct tile *ptile0, int map_num_tiles(void); #define map_size_checked() MAX(map_num_tiles() / 1000, 1) -struct tile *rand_neighbour(const struct civ_map *nmap, - const struct tile *ptile); struct tile *rand_map_pos(const struct civ_map *nmap); struct tile *rand_map_pos_filtered(const struct civ_map *nmap, void *data, bool (*filter)(const struct tile *ptile, diff --git a/data/alien/units.ruleset b/data/alien/units.ruleset index 1792ea8c83..367aba9842 100644 --- a/data/alien/units.ruleset +++ b/data/alien/units.ruleset @@ -1482,7 +1482,7 @@ uk_shield = 1 uk_food = 0 uk_gold = 0 helptext = _("\ -Teleporting Missile can teleport and attack to neighbour tile.") +Teleporting Missile can teleport and attack to neighbor tile.") [unit_antiburrow_missile] name = _("Antiburrow Missile") diff --git a/data/nation/hittite.ruleset b/data/nation/hittite.ruleset index df6a4c2153..20ac122022 100644 --- a/data/nation/hittite.ruleset +++ b/data/nation/hittite.ruleset @@ -55,7 +55,7 @@ cities = "Zallara", "Lusna", -; Kizzuwatna cities (they were Hittite neighbours and alllies): +; Kizzuwatna cities (they were Hittite neighbors and allies): "Mersin", "Adana", "Ursa", diff --git a/doc/HACKING b/doc/HACKING index ef36a4fe48..5981f0b048 100644 --- a/doc/HACKING +++ b/doc/HACKING @@ -825,7 +825,7 @@ National borders For the display of national borders (similar to those used in Sid Meier's Alpha Centauri) each map tile also has an "owner" field, to identify which nation lays claim to it. If game.borders is non-zero, each city -claims a circle of tiles game.borders in radius (in the case of neighbouring +claims a circle of tiles game.borders in radius (in the case of neighboring enemy cities, tiles are divided equally, with the older city winning any ties). Cities claim all immediately adjacent tiles, plus any other tiles within the border radius on the same continent. Land cities also claim ocean @@ -836,7 +836,7 @@ Tile ownership is decided only by the server, and sent to the clients, which draw border lines between tiles of differing ownership. Owner information is sent for all tiles that are known by a client, whether or not they are fogged. A patch to convert this to "semi-fogged" behaviour, whereby clients receive -limited information about non-neighbouring and unseen enemies, is available +limited information about non-neighboring and unseen enemies, is available at http://freecivac.sf.net/. =========================================================================== diff --git a/server/advisors/advbuilding.c b/server/advisors/advbuilding.c index 05ecf65da1..98c3cc342c 100644 --- a/server/advisors/advbuilding.c +++ b/server/advisors/advbuilding.c @@ -229,6 +229,7 @@ void building_advisor(struct player *pplayer) if (is_terrain_class_near_tile(pcity->tile, TC_OCEAN)) { value /= 2; } + /* Downtown is the number of cities within a certain pf range. * These may be able to help with caravans. Also look at the whole * continent. */ @@ -240,10 +241,12 @@ void building_advisor(struct player *pplayer) value += adv->stats.cities[place] / 8; } } + if (place >= 0 && adv->threats.continent[place] > 0) { - /* We have threatening neighbours: -25% */ + /* We have threatening neighbors: -25% */ value -= value / 4; } + /* Require that there is at least some neighbors for wonder helpers, * if ruleset supports it. */ if (value > best_candidate_value @@ -253,6 +256,7 @@ void building_advisor(struct player *pplayer) best_candidate_value = value; } } city_list_iterate_end; + if (best_candidate) { CITY_LOG(LOG_DEBUG, best_candidate, "chosen as wonder-city!"); adv->wonder_city = best_candidate->id; diff --git a/server/advisors/infracache.h b/server/advisors/infracache.h index 4b4bc19b00..104ae153a5 100644 --- a/server/advisors/infracache.h +++ b/server/advisors/infracache.h @@ -1,4 +1,4 @@ -/********************************************************************** +/*********************************************************************** Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,8 +31,8 @@ struct adv_city { */ adv_want building_want[B_LAST]; - int downtown; /* distance from neighbours, for locating - wonders wisely */ + int downtown; /* Distance from neighbors, for locating + * wonders wisely */ }; void adv_city_alloc(struct city *pcity); @@ -58,4 +58,4 @@ void adv_city_worker_rmextra_set(struct city *pcity, int city_tile_index, int adv_city_worker_rmextra_get(const struct city *pcity, int city_tile_index, const struct extra_type *pextra); -#endif /* FC__INFRACACHE_H */ +#endif /* FC__INFRACACHE_H */ diff --git a/server/barbarian.c b/server/barbarian.c index f5a995193b..822a83451a 100644 --- a/server/barbarian.c +++ b/server/barbarian.c @@ -492,7 +492,7 @@ static bool is_near_land(struct tile *tile0) } /**********************************************************************//** - Return this or a neighbouring tile that is free of any units + Return this or a neighboring tile that is free of any units **************************************************************************/ static struct tile *find_empty_tile_nearby(struct tile *ptile) { @@ -510,7 +510,7 @@ static struct tile *find_empty_tile_nearby(struct tile *ptile) 1. It's not closer than MIN_UNREST_DIST and not further than MAX_UNREST_DIST from the nearest city. City owner is called 'victim' here. - 2. The place or a neighbouring tile must be empty to deploy the units. + 2. The place or a neighboring tile must be empty to deploy the units. 3. If it's the sea it shouldn't be far from the land. (questionable) 4. Place must be known to the victim 5. The uprising chance depends also on the victim empire size, its -- 2.40.1