| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Freeciv
Revision: 15195
Author: cazfi
Date: 04 Sep 2008 18:22:39
Changes:There cannot be two territory claiming bases on same tile. If one
exist already when new one is built, old one is removed.
See #40474
Files:| ... | ...@@ -290,3 +290,20 @@ | |
| 290 | 290 | |
| 291 | 291 | return NULL; |
| 292 | 292 | } |
| 293 | ||
| 294 | /************************************************************************** | |
| 295 | Can two bases coexist in same tile? | |
| 296 | **************************************************************************/ | |
| 297 | bool can_bases_coexist(const struct base_type *base1, const struct base_type *base2) | |
| 298 | { | |
| 299 | if (base1 == base2) { | |
| 300 | return TRUE; | |
| 301 | } | |
| 302 | ||
| 303 | if (base_has_flag(base1, BF_CLAIM_TERRITORY) | |
| 304 | && base_has_flag(base2, BF_CLAIM_TERRITORY)) { | |
| 305 | return FALSE; | |
| 306 | } | |
| 307 | ||
| 308 | return TRUE; | |
| 309 | } |
| ... | ...@@ -791,14 +791,25 @@ | |
| 791 | 791 | case ACTIVITY_BASE: |
| 792 | 792 | if (total_activity_base(ptile, punit->activity_base) |
| 793 | 793 | >= tile_activity_base_time(ptile, punit->activity_base)) { |
| 794 | tile_add_base(ptile, base_by_number(punit->activity_base)); | |
| 794 | struct base_type *new_base = base_by_number(punit->activity_base); | |
| 795 | ||
| 796 | base_type_iterate(old_base) { | |
| 797 | if (!can_bases_coexist(old_base, new_base)) { | |
| 798 | if (base_has_flag(old_base, BF_CLAIM_TERRITORY)) { | |
| 799 | map_clear_border(ptile, ptile->owner); | |
| 800 | } | |
| 801 | tile_remove_base(ptile, old_base); | |
| 802 | } | |
| 803 | } base_type_iterate_end; | |
| 804 | ||
| 805 | tile_add_base(ptile, new_base); | |
| 795 | 806 | |
| 796 | 807 | /* Watchtower might become effective |
| 797 | 808 | * FIXME: Reqs on other specials will not be updated immediately. */ |
| 798 | 809 | unit_list_refresh_vision(ptile->units); |
| 799 | 810 | |
| 800 | 811 | /* Claim base if it has "ClaimTerritory" flag */ |
| 801 | if (tile_has_base_flag(ptile, BF_CLAIM_TERRITORY)) { | |
| 812 | if (base_has_flag(new_base, BF_CLAIM_TERRITORY)) { | |
| 802 | 813 | map_claim_ownership(ptile, unit_owner(punit), ptile); |
| 803 | 814 | map_claim_border(ptile, unit_owner(punit)); |
| 804 | 815 | city_thaw_workers_queue(); |
| ... | ...@@ -88,6 +88,8 @@ | |
| 88 | 88 | const struct unit *punit, |
| 89 | 89 | const struct tile *ptile); |
| 90 | 90 | |
| 91 | bool can_bases_coexist(const struct base_type *base1, const struct base_type *base2); | |
| 92 | ||
| 91 | 93 | /* Initialization and iteration */ |
| 92 | 94 | void base_types_init(void); |
| 93 | 95 | void base_types_free(void); |