(PR#10997) AI can sell his last cities
"Mateusz Stefek" <mstefek-IjDXvh/[email protected]> Sat, 13 Nov 2004 01:55:00 -0800
| Newsgroups | gmane.games.freeciv.ai |
|---|---|
| Message-ID | <[email protected]> |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10997 > http://forum.freeciv.org/viewtopic.php?t=486 Someone mentioned on the forum that the AI can sell all his cities except capital. This is of course wrong. This patch makes last 8 cities very expensive. -- mateusz
dont_sell_last_8_cities.diff
(text/x-patch, 1.5 KB)
Index: advdiplomacy.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdiplomacy.c,v
retrieving revision 1.48
diff -u -r1.48 advdiplomacy.c
--- advdiplomacy.c 31 Oct 2004 22:14:46 -0000 1.48
+++ advdiplomacy.c 13 Nov 2004 09:53:41 -0000
@@ -474,6 +474,7 @@
bool has_treaty = FALSE;
bool only_gifts = TRUE;
struct ai_data *ai = ai_data_get(pplayer);
+ int given_cities = 0;
assert(!is_barbarian(pplayer));
@@ -483,6 +484,9 @@
if (is_pact_clause(pclause->type)) {
has_treaty = TRUE;
}
+ if (pclause->type == CLAUSE_CITY && pclause->from == pplayer) {
+ given_cities++;
+ }
if (pclause->type != CLAUSE_GOLD && pclause->type != CLAUSE_MAP
&& pclause->type != CLAUSE_SEAMAP && pclause->type != CLAUSE_VISION
&& (pclause->type != CLAUSE_ADVANCE
@@ -503,6 +507,12 @@
return;
}
+ /* Last 8 cities should be sold only for much gold */
+ if (given_cities > 0) {
+ total_balance -=
+ MAX(0, 8 - (city_list_size(&pplayer->cities) - given_cities)) * 10000;
+ }
+
/* Accept if balance is good */
if (total_balance >= 0) {
handle_diplomacy_accept_treaty_req(pplayer, aplayer->player_no);
@@ -560,7 +570,6 @@
/* Evaluate clauses */
clause_list_iterate(ptreaty->clauses, pclause) {
int balance = ai_goldequiv_clause(pplayer, aplayer, pclause, ai, TRUE);
-
total_balance += balance;
gift = (gift && (balance >= 0));
ai_treaty_react(pplayer, aplayer, pclause);