Project

General

Profile

Feature #1078 » 0066-Unhardcode-wld.map-from-city_exists_within_max_city_.patch

main, S3_2 - Marko Lindqvist, 11/09/2024 01:35 AM

View differences:

common/city.c
Return TRUE iff a city exists within a city radius of the given
location. may_be_on_center determines if a city at x,y counts.
**************************************************************************/
bool city_exists_within_max_city_map(const struct tile *ptile,
bool city_exists_within_max_city_map(const struct civ_map *nmap,
const struct tile *ptile,
bool may_be_on_center)
{
const struct civ_map *nmap = &(wld.map);
city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
if (may_be_on_center || !same_pos(ptile, ptile1)) {
if (tile_city(ptile1)) {
common/city.h
const struct player *owner,
const struct tile *ptile,
int distance);
bool city_exists_within_max_city_map(const struct tile *ptile,
bool city_exists_within_max_city_map(const struct civ_map *nmap,
const struct tile *ptile,
bool may_be_on_center);
/* Granary size as a function of city size */
common/scriptcore/api_game_methods.c
LUASCRIPT_CHECK_STATE(L, FALSE);
LUASCRIPT_CHECK_SELF(L, ptile, FALSE);
return city_exists_within_max_city_map(ptile, may_be_on_center);
return city_exists_within_max_city_map(&(wld.map), ptile, may_be_on_center);
}
/**********************************************************************//**
server/unittools.c
bool ok = TRUE;
int hut_chance = fc_rand(12);
struct player *pplayer = unit_owner(punit);
const struct civ_map *nmap = &(wld.map);
/* 1 in 12 to get barbarians */
if (hut_chance != 0) {
int cred = 25;
notify_player(pplayer, unit_tile(punit), E_HUT_GOLD, ftc_server,
PL_("You found %d gold.",
"You found %d gold.", cred), cred);
pplayer->economic.gold += cred;
} else if (city_exists_within_max_city_map(unit_tile(punit), TRUE)
} else if (city_exists_within_max_city_map(nmap, unit_tile(punit), TRUE)
|| unit_has_type_flag(punit, UTYF_GAMELOSS)) {
notify_player(pplayer, unit_tile(punit),
E_HUT_BARB_CITY_NEAR, ftc_server,
......
wipe_unit(punit, ULR_BARB_UNLEASH, NULL);
ok = FALSE;
}
return ok;
}
(1-1/2)