Feature #699 » 0067-Unhardcode-wld.map-from-can_city_build_unit_later.patch
ai/default/daimilitary.c | ||
---|---|---|
best_unit_type = punittype;
|
||
best_unit_cost = build_cost;
|
||
}
|
||
} else if (can_city_build_unit_later(pcity, punittype)) {
|
||
} else if (can_city_build_unit_later(nmap, pcity, punittype)) {
|
||
/* We first need to develop the tech required by the unit... */
|
||
/* Cost (shield equivalent) of gaining these techs. */
|
ai/default/daitech.c | ||
---|---|---|
unit_type_iterate(deftype) {
|
||
if (def_values[utype_index(deftype)] > best_avl_def
|
||
&& !can_city_build_unit_now(nmap, pcity, deftype)
|
||
&& can_city_build_unit_later(pcity, deftype)) {
|
||
&& can_city_build_unit_later(nmap, pcity, deftype)) {
|
||
/* It would be better than current best. Consider researching tech */
|
||
const struct impr_type *building;
|
||
int cost = 0;
|
||
... | ... | |
if (can_city_build_unit_now(nmap, pcity, iunit)) {
|
||
build_unit = iunit;
|
||
break;
|
||
} else if (can_city_build_unit_later(pcity, iunit)) {
|
||
} else if (can_city_build_unit_later(nmap, pcity, iunit)) {
|
||
const struct impr_type *building;
|
||
struct advance *itech = A_NEVER;
|
||
int cost = 0;
|
client/climisc.c | ||
---|---|---|
{
|
||
struct city *pcity;
|
||
struct unit *punit;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (!can_client_change_view()) {
|
||
return;
|
||
... | ... | |
fc_assert_ret(punit != NULL);
|
||
center_tile_mapcanvas(unit_tile(punit));
|
||
} else {
|
||
struct tile *ctile = native_pos_to_tile(&(wld.map), MAP_NATIVE_WIDTH / 2,
|
||
struct tile *ctile = native_pos_to_tile(nmap, MAP_NATIVE_WIDTH / 2,
|
||
MAP_NATIVE_HEIGHT / 2);
|
||
/* Just any known tile will do; search near the middle first. */
|
||
... | ... | |
* is guaranteed to be larger than the map will be. Although this is
|
||
* a misuse of map.xsize and map.ysize (which are native dimensions),
|
||
* it should give a sufficiently large radius. */
|
||
iterate_outward(&(wld.map), ctile, MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT, ptile) {
|
||
iterate_outward(nmap, ctile, MAP_NATIVE_WIDTH + MAP_NATIVE_HEIGHT, ptile) {
|
||
if (client_tile_get_known(ptile) != TILE_UNKNOWN) {
|
||
ctile = ptile;
|
||
break;
|
||
... | ... | |
{
|
||
struct player *pplayer = client_player();
|
||
int cids_used = 0;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
improvement_iterate(pimprove) {
|
||
bool can_build;
|
||
... | ... | |
if (NULL != pcity) {
|
||
/* Can the city build? */
|
||
can_build = can_city_build_unit_now(&(wld.map), pcity, punittype);
|
||
can_eventually_build = can_city_build_unit_later(pcity, punittype);
|
||
can_build = can_city_build_unit_now(nmap, pcity, punittype);
|
||
can_eventually_build = can_city_build_unit_later(nmap, pcity, punittype);
|
||
} else if (NULL != pplayer) {
|
||
/* Can our player build? */
|
||
can_build = can_player_build_unit_now(pplayer, punittype);
|
client/gui-sdl2/wldlg.c | ||
---|---|---|
bool can_build, can_eventually_build;
|
||
SDL_Rect area;
|
||
int len;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (editor) {
|
||
return;
|
||
... | ... | |
/* If there's a city, can the city build the unit? */
|
||
if (pcity) {
|
||
can_build = can_build && can_city_build_unit_now(&(wld.map), pcity, un);
|
||
can_build = can_build && can_city_build_unit_now(nmap, pcity, un);
|
||
can_eventually_build = can_eventually_build
|
||
&& can_city_build_unit_later(pcity, un);
|
||
&& can_city_build_unit_later(nmap, pcity, un);
|
||
}
|
||
if ((advanced_tech && can_eventually_build)
|
client/gui-sdl3/wldlg.c | ||
---|---|---|
bool can_build, can_eventually_build;
|
||
SDL_Rect area;
|
||
int len;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (editor) {
|
||
return;
|
||
... | ... | |
/* If there's a city, can the city build the unit? */
|
||
if (pcity) {
|
||
can_build = can_build && can_city_build_unit_now(&(wld.map), pcity, un);
|
||
can_build = can_build && can_city_build_unit_now(nmap, pcity, un);
|
||
can_eventually_build = can_eventually_build
|
||
&& can_city_build_unit_later(pcity, un);
|
||
&& can_city_build_unit_later(nmap, pcity, un);
|
||
}
|
||
if ((advanced_tech && can_eventually_build)
|
common/city.c | ||
---|---|---|
Returns whether player can eventually build given unit in the city;
|
||
returns FALSE if unit can never possibly be built in this city.
|
||
**************************************************************************/
|
||
bool can_city_build_unit_later(const struct city *pcity,
|
||
bool can_city_build_unit_later(const struct civ_map *nmap,
|
||
const struct city *pcity,
|
||
const struct unit_type *punittype)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
/* Can the _player_ ever build this unit? */
|
||
if (!can_player_build_unit_later(city_owner(pcity), punittype)) {
|
||
return FALSE;
|
||
... | ... | |
bool can_city_build_later(const struct city *pcity,
|
||
const struct universal *target)
|
||
{
|
||
const struct civ_map *nmap = &(wld.map);
|
||
switch (target->kind) {
|
||
case VUT_UTYPE:
|
||
return can_city_build_unit_later(pcity, target->value.utype);
|
||
return can_city_build_unit_later(nmap, pcity, target->value.utype);
|
||
case VUT_IMPROVEMENT:
|
||
return can_city_build_improvement_later(pcity, target->value.building);
|
||
default:
|
common/city.h | ||
---|---|---|
bool can_city_build_unit_direct(const struct civ_map *nmap,
|
||
const struct city *pcity,
|
||
const struct unit_type *punittype);
|
||
bool can_city_build_unit_later(const struct city *pcity,
|
||
bool can_city_build_unit_later(const struct civ_map *nmap,
|
||
const struct city *pcity,
|
||
const struct unit_type *punittype);
|
||
bool can_city_build_unit_now(const struct civ_map *nmap,
|
||
const struct city *pcity,
|
server/cityturn.c | ||
---|---|---|
int saved_id = pcity->id;
|
||
bool city_checked = TRUE; /* This is used to avoid spurious city_exist() calls */
|
||
struct worklist *pwl = &pcity->worklist;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
if (worklist_is_empty(pwl)) {
|
||
/* Nothing in the worklist; bail now. */
|
||
... | ... | |
city_checked = FALSE;
|
||
break;
|
||
} else {
|
||
purge = !can_city_build_unit_later(pcity, pupdate);
|
||
purge = !can_city_build_unit_later(nmap, pcity, pupdate);
|
||
}
|
||
if (purge) {
|
||
/* If the city can never build this unit or its descendants,
|