From f557d08ed33d9e7274c926e2002fb06866ad3dac Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 2 Sep 2023 13:53:18 +0300 Subject: [PATCH 11/11] 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.22/sprite.c | 4 ++-- client/gui-gtk-4.0/sprite.c | 2 +- common/aicore/caravan.h | 2 +- common/map.c | 38 ---------------------------------- 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 ++-- server/unittools.c | 39 +++++++++++++++++++---------------- 13 files changed, 41 insertions(+), 74 deletions(-) diff --git a/ai/default/daisettler.c b/ai/default/daisettler.c index 65497bd1f1..00663ff281 100644 --- a/ai/default/daisettler.c +++ b/ai/default/daisettler.c @@ -799,7 +799,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.22/sprite.c b/client/gui-gtk-3.22/sprite.c index 7262e01416..3dd007b1f7 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 4a540a5e59..f1cfb5517b 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 7d06a74552..080e871df3 100644 --- a/common/map.c +++ b/common/map.c @@ -1082,44 +1082,6 @@ void map_distance_vector(int *dx, int *dy, base_map_distance_vector(dx, dy, tx0, ty0, tx1, ty1); } -/*******************************************************************//** - 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 is 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 nullptr; -} - /*******************************************************************//** Random square anywhere on the map. Only normal positions (for which is_normal_map_pos() returns TRUE) will be found. diff --git a/common/map.h b/common/map.h index c68347028f..294476e211 100644 --- a/common/map.h +++ b/common/map.h @@ -256,8 +256,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 0066d7bd2e..61d8d846df 100644 --- a/data/alien/units.ruleset +++ b/data/alien/units.ruleset @@ -1577,7 +1577,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 a3a5c549cb..6641fad19b 100644 --- a/data/nation/hittite.ruleset +++ b/data/nation/hittite.ruleset @@ -56,7 +56,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 feae06db10..d58efc7658 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 c2c8e5ba08..7589d49d92 100644 --- a/server/advisors/advbuilding.c +++ b/server/advisors/advbuilding.c @@ -224,6 +224,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. */ @@ -235,10 +236,12 @@ void building_advisor(struct player *pplayer) value += adv->stats.cities[place] / 8; } } + if (place >= 0 && adv->continents[place].threat > 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 @@ -248,6 +251,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 2745ab4bff..6ffabfb323 100644 --- a/server/barbarian.c +++ b/server/barbarian.c @@ -498,7 +498,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) { @@ -516,7 +516,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 diff --git a/server/unittools.c b/server/unittools.c index ec6cd96006..0ac120a028 100644 --- a/server/unittools.c +++ b/server/unittools.c @@ -4889,11 +4889,8 @@ void random_movements(struct player *pplayer) int id = punit->id; while (moved && unit_is_alive(id) && punit->moves_left > 0) { - /* Search for random direction to move to mostly copied from - * rand_neighbour() */ - /* - * list of all 8 directions + * List of all 8 directions */ enum direction8 dirs[8] = { DIR8_NORTHWEST, DIR8_NORTH, DIR8_NORTHEAST, DIR8_WEST, DIR8_EAST, @@ -4908,7 +4905,8 @@ void random_movements(struct player *pplayer) struct tile *dest = mapstep(&(wld.map), curtile, dirs[choice]); if (dest != NULL) { - if (action_prob_possible(action_prob_vs_units(punit, ACTION_ATTACK, dest))) { + if (action_prob_possible(action_prob_vs_units(punit, ACTION_ATTACK, + dest))) { if (unit_perform_action(pplayer, id, tile_index(dest), NO_TARGET, "", ACTION_ATTACK, ACT_REQ_RULES)) { moved = TRUE; @@ -4917,21 +4915,25 @@ void random_movements(struct player *pplayer) } if (!moved) { - if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE, punit, dest, NULL)) { - if (unit_perform_action(pplayer, id, tile_index(dest), NO_TARGET, - "", ACTION_UNIT_MOVE, ACT_REQ_RULES)) { + if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE, punit, dest, + NULL)) { + if (unit_perform_action(pplayer, id, tile_index(dest), + NO_TARGET, "", ACTION_UNIT_MOVE, + ACT_REQ_RULES)) { moved = TRUE; } - } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE2, punit, dest, - NULL)) { - if (unit_perform_action(pplayer, id, tile_index(dest), NO_TARGET, - "", ACTION_UNIT_MOVE2, ACT_REQ_RULES)) { + } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE2, + punit, dest, NULL)) { + if (unit_perform_action(pplayer, id, tile_index(dest), + NO_TARGET, "", ACTION_UNIT_MOVE2, + ACT_REQ_RULES)) { moved = TRUE; } - } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE3, punit, dest, - NULL)) { - if (unit_perform_action(pplayer, id, tile_index(dest), NO_TARGET, - "", ACTION_UNIT_MOVE3, ACT_REQ_RULES)) { + } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE3, + punit, dest, NULL)) { + if (unit_perform_action(pplayer, id, tile_index(dest), + NO_TARGET, "", ACTION_UNIT_MOVE3, + ACT_REQ_RULES)) { moved = TRUE; } } @@ -4939,8 +4941,9 @@ void random_movements(struct player *pplayer) } if (!moved) { - /* Choice was bad, so replace it with the last direction in the list. - * On the next iteration, one fewer choices will remain. */ + /* Choice was bad, so replace it with the last direction + * in the list. On the next iteration, one fewer choice + * will remain. */ dirs[choice] = dirs[n - 1]; } } -- 2.40.1