@@ -1969,7 +1969,7 @@ void remove_city(struct city *pcity)
1969
1969
bool unit_conquer_city (struct unit *punit, struct city *pcity)
1970
1970
{
1971
1971
bool try_civil_war = false ;
1972
- bool city_remains ;
1972
+ int pcity_id = pcity-> id ;
1973
1973
struct player *pplayer = unit_owner (punit);
1974
1974
struct player *cplayer = city_owner (pcity);
1975
1975
@@ -2013,8 +2013,6 @@ bool unit_conquer_city(struct unit *punit, struct city *pcity)
2013
2013
* the city will be destroyed.
2014
2014
*/
2015
2015
if (city_size_get (pcity) <= 1 ) {
2016
- int saved_id = pcity->id ;
2017
-
2018
2016
notify_player (pplayer, city_tile (pcity), E_UNIT_WIN_ATT, ftc_server,
2019
2017
_ (" You destroy %s completely." ), city_tile_link (pcity));
2020
2018
notify_player (cplayer, city_tile (pcity), E_CITY_LOST, ftc_server,
@@ -2023,7 +2021,7 @@ bool unit_conquer_city(struct unit *punit, struct city *pcity)
2023
2021
script_server_signal_emit (" city_destroyed" , pcity, cplayer, pplayer);
2024
2022
2025
2023
// We cant't be sure of city existence after running some script
2026
- if (city_exist (saved_id )) {
2024
+ if (city_exist (pcity_id )) {
2027
2025
remove_city (pcity);
2028
2026
}
2029
2027
@@ -2033,62 +2031,25 @@ bool unit_conquer_city(struct unit *punit, struct city *pcity)
2033
2031
return true ;
2034
2032
}
2035
2033
2036
- auto coins = cplayer->economic .gold ;
2037
- coins = MIN (coins, int (fc_rand ((coins / 20 ) + 1 ))
2038
- + (coins * (city_size_get (pcity))) / 200 );
2039
- pplayer->economic .gold += coins;
2040
- cplayer->economic .gold -= coins;
2041
- send_player_info_c (pplayer, pplayer->connections );
2042
- send_player_info_c (cplayer, cplayer->connections );
2043
2034
if (pcity->original != pplayer) {
2044
- if (coins > 0 ) {
2045
- notify_player (pplayer, city_tile (pcity), E_UNIT_WIN_ATT, ftc_server,
2046
- PL_ (" You conquer %s; your lootings accumulate"
2047
- " to %d gold!" ,
2048
- " You conquer %s; your lootings accumulate"
2049
- " to %d gold!" ,
2050
- coins),
2051
- city_link (pcity), coins);
2052
- notify_player (cplayer, city_tile (pcity), E_CITY_LOST, ftc_server,
2053
- PL_ (" %s conquered %s and looted %d gold"
2054
- " from the city." ,
2055
- " %s conquered %s and looted %d gold"
2056
- " from the city." ,
2057
- coins),
2058
- player_name (pplayer), city_link (pcity), coins);
2059
- } else {
2060
- notify_player (pplayer, city_tile (pcity), E_UNIT_WIN_ATT, ftc_server,
2061
- _ (" You conquer %s." ), city_link (pcity));
2062
- notify_player (cplayer, city_tile (pcity), E_CITY_LOST, ftc_server,
2063
- _ (" %s conquered %s." ), player_name (pplayer),
2064
- city_link (pcity));
2065
- }
2035
+ notify_player (pplayer, city_tile (pcity), E_UNIT_WIN_ATT, ftc_server,
2036
+ _ (" You conquer %s." ), city_link (pcity));
2037
+ notify_player (cplayer, city_tile (pcity), E_CITY_LOST, ftc_server,
2038
+ _ (" %s conquered %s." ), player_name (pplayer),
2039
+ city_link (pcity));
2066
2040
} else {
2067
- if (coins > 0 ) {
2068
- notify_player (pplayer, city_tile (pcity), E_UNIT_WIN_ATT, ftc_server,
2069
- PL_ (" You have liberated %s!"
2070
- " Lootings accumulate to %d gold." ,
2071
- " You have liberated %s!"
2072
- " Lootings accumulate to %d gold." ,
2073
- coins),
2074
- city_link (pcity), coins);
2075
- notify_player (cplayer, city_tile (pcity), E_CITY_LOST, ftc_server,
2076
- PL_ (" %s liberated %s and looted %d gold"
2077
- " from the city." ,
2078
- " %s liberated %s and looted %d gold"
2079
- " from the city." ,
2080
- coins),
2081
- player_name (pplayer), city_link (pcity), coins);
2082
- } else {
2083
- notify_player (pplayer, city_tile (pcity), E_UNIT_WIN_ATT, ftc_server,
2084
- _ (" You have liberated %s!" ), city_link (pcity));
2085
- notify_player (cplayer, city_tile (pcity), E_CITY_LOST, ftc_server,
2086
- _ (" %s liberated %s." ), player_name (pplayer),
2087
- city_link (pcity));
2088
- }
2041
+ notify_player (pplayer, city_tile (pcity), E_UNIT_WIN_ATT, ftc_server,
2042
+ _ (" You have liberated %s!" ), city_link (pcity));
2043
+ notify_player (cplayer, city_tile (pcity), E_CITY_LOST, ftc_server,
2044
+ _ (" %s liberated %s." ), player_name (pplayer),
2045
+ city_link (pcity));
2089
2046
}
2090
2047
2091
- if (fc_rand (100 ) < get_unit_bonus (punit, EFT_CONQUEST_TECH_PCT)) {
2048
+ int conquestTechPct = get_unit_bonus (punit, EFT_CONQUEST_TECH_PCT);
2049
+ script_server_signal_emit (" city_loot" , pcity, punit);
2050
+ bool city_remains = city_exist (pcity_id);
2051
+
2052
+ if (fc_rand (100 ) < conquestTechPct) {
2092
2053
// Just try to steal. Ignore failures to get tech
2093
2054
steal_a_tech (pplayer, cplayer, A_UNSET);
2094
2055
}
@@ -2097,8 +2058,9 @@ bool unit_conquer_city(struct unit *punit, struct city *pcity)
2097
2058
* the size is reduced. */
2098
2059
/* FIXME: maybe it should be a ruleset option whether barbarians get
2099
2060
* free buildings such as palaces? */
2100
- city_remains = transfer_city (pplayer, pcity, 0 , true , true , true ,
2101
- !is_barbarian (pplayer));
2061
+ city_remains = city_remains
2062
+ && transfer_city (pplayer, pcity, 0 , true , true , true ,
2063
+ !is_barbarian (pplayer));
2102
2064
2103
2065
if (city_remains) {
2104
2066
// reduce size should not destroy this city
0 commit comments