Feature #181 » 0042-Unhardcode-wld.map-from-citymindist_prevents_city_on.patch
| common/actres.c | ||
|---|---|---|
|       return TRI_NO; | ||
|     } | ||
|     if (citymindist_prevents_city_on_tile(target->tile)) { | ||
|     if (citymindist_prevents_city_on_tile(nmap, target->tile)) { | ||
|       if (omniscient) { | ||
|         /* No need to check again. */ | ||
|         return TRI_NO; | ||
| common/city.c | ||
|---|---|---|
|   Returns TRUE iff it is illegal to found a city on the specified tile | ||
|   because of citymindist. | ||
| **************************************************************************/ | ||
| bool citymindist_prevents_city_on_tile(const struct tile *ptile) | ||
| bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, | ||
|                                        const struct tile *ptile) | ||
| { | ||
|   /* citymindist minimum is 1, meaning adjacent is okay */ | ||
|   int citymindist = game.info.citymindist; | ||
|   square_iterate(&(wld.map), ptile, citymindist - 1, ptile1) { | ||
|   square_iterate(nmap, ptile, citymindist - 1, ptile1) { | ||
|     if (tile_city(ptile1)) { | ||
|       return TRUE; | ||
|     } | ||
| ... | ... | |
| { | ||
|   struct civ_map *nmap = &(wld.map); | ||
|   if (!city_can_be_built_tile_only(ptile)) { | ||
|   if (!city_can_be_built_tile_only(nmap, ptile)) { | ||
|     return FALSE; | ||
|   } | ||
| ... | ... | |
|   It may still be illegal for any unit to build a city at the specified | ||
|   tile. | ||
| **************************************************************************/ | ||
| bool city_can_be_built_tile_only(const struct tile *ptile) | ||
| bool city_can_be_built_tile_only(const struct civ_map *nmap, | ||
|                                  const struct tile *ptile) | ||
| { | ||
|   if (terrain_has_flag(tile_terrain(ptile), TER_NO_CITIES)) { | ||
|     /* No cities on this terrain. */ | ||
|     return FALSE; | ||
|   } | ||
|   if (citymindist_prevents_city_on_tile(ptile)) { | ||
|   if (citymindist_prevents_city_on_tile(nmap, ptile)) { | ||
|     return FALSE; | ||
|   } | ||
| common/city.h | ||
|---|---|---|
|                              const struct tile *ptile); | ||
| bool city_can_work_tile(const struct city *pcity, const struct tile *ptile); | ||
| bool citymindist_prevents_city_on_tile(const struct tile *ptile); | ||
| bool citymindist_prevents_city_on_tile(const struct civ_map *nmap, | ||
|                                        const struct tile *ptile); | ||
| bool city_can_be_built_here(const struct tile *ptile, | ||
|                             const struct unit *punit, | ||
|                             bool hut_test); | ||
| bool city_can_be_built_tile_only(const struct tile *ptile); | ||
| bool city_can_be_built_tile_only(const struct civ_map *nmap, | ||
|                                  const struct tile *ptile); | ||
| /* List functions */ | ||
| struct city *city_list_find_number(struct city_list *This, int id); | ||
| server/unithand.c | ||
|---|---|---|
|     explnat->kind = ANEK_CITY_NO_CAPACITY; | ||
|     explnat->capacity_city = game_city_by_number(target_city->id); | ||
|   } else if (action_has_result_safe(paction, ACTRES_FOUND_CITY) | ||
|              && citymindist_prevents_city_on_tile(target_tile)) { | ||
|              && citymindist_prevents_city_on_tile(nmap, target_tile)) { | ||
|     explnat->kind = ANEK_CITY_TOO_CLOSE_TGT; | ||
|   } else if ((action_has_result_safe(paction, ACTRES_PARADROP_CONQUER) | ||
|               || action_has_result_safe(paction, ACTRES_PARADROP)) | ||
| ... | ... | |
|   struct ane_expl *explnat = expl_act_not_enabl(punit, ACTION_ANY, | ||
|                                                 target_tile, | ||
|                                                 target_city, target_unit); | ||
|   const struct civ_map *nmap = &(wld.map); | ||
|   switch (explnat->kind) { | ||
|   case ANEK_ACTOR_UNIT: | ||
| ... | ... | |
|       if (!utype_can_do_act_when_ustate(unit_type_get(punit), | ||
|                                         ACTION_ANY, USP_LIVABLE_TILE, | ||
|                                         FALSE) | ||
|           && !can_unit_exist_at_tile(&(wld.map), punit, unit_tile(punit))) { | ||
|           && !can_unit_exist_at_tile(nmap, punit, unit_tile(punit))) { | ||
|         unit_type_iterate(utype) { | ||
|           if (utype_can_do_act_when_ustate(utype, ACTION_ANY, | ||
|                                            USP_LIVABLE_TILE, FALSE)) { | ||