? city_incite_cost-2.1.diff ? city_incite_cost-2.2.0.diff ? city_incite_cost-2.2.1.diff ? city_incite_cost-2.2.diff ? city_incite_cost-2.diff ? city_incite_cost.diff ? city_incite_cost3.diff ? dipl1.diff ? test-prize-2.gz ? test-the-price.gz Index: ai/aiunit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v retrieving revision 1.221 diff -u -r1.221 aiunit.c --- ai/aiunit.c 2002/09/28 21:58:15 1.221 +++ ai/aiunit.c 2002/09/30 13:03:30 @@ -2593,10 +2593,8 @@ city_list_iterate(aplayer->cities, acity) if (handicap && !map_get_known(acity->x, acity->y, pplayer)) continue; if (continent != map_get_continent(acity->x, acity->y)) continue; - city_incite_cost(acity); /* figure our incite cost */ - oic = acity->incite_revolt_cost; - if (pplayer->player_no == acity->original) oic = oic / 2; + oic = city_incite_cost(pplayer, acity); rmd=real_map_distance(pdiplomat->x, pdiplomat->y, acity->x, acity->y); if (!ctarget || (dist > rmd)) { if (!has_emb || acity->steal == 0 || (oic < Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.190 diff -u -r1.190 citytools.c --- server/citytools.c 2002/09/23 15:00:56 1.190 +++ server/citytools.c 2002/09/30 13:03:31 @@ -1058,8 +1058,6 @@ city_refresh(pcity); - city_incite_cost(pcity); - /* Put vision back to normal, if fortress acted as a watchtower */ if (player_knows_techs_with_flag(pplayer, TF_WATCHTOWER) && map_has_special(x, y, S_FORTRESS)) { Index: server/cityturn.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v retrieving revision 1.196 diff -u -r1.196 cityturn.c --- server/cityturn.c 2002/09/27 12:32:45 1.196 +++ server/cityturn.c 2002/09/30 13:03:31 @@ -1181,16 +1181,45 @@ /************************************************************************** Sets the incite_revolt_cost field in the given city. **************************************************************************/ -void city_incite_cost(struct city *pcity) +int city_incite_cost(struct player *pplayer, struct city *pcity) { struct government *g = get_gov_pcity(pcity); struct city *capital; int dist; - + int goldfactor=0, city_value=0, adjusted_size, incite_revolt_cost; +/* for the cost of a revolt you need + * goldfactor + * distance to capital + * city_value + * old + * - size + * new + * - size (multiplied with goldfactor, divided by modified distance to cap) + * - buildings(+ wonders) (added) + * - units (added) (present 75%) (supported 25%) + * modifiers + * - unhappy + * - happy + * - courthouse (modifies distance) + * - city_is_empty + * - buy back ... + * - buy from citybuilder + * */ if (city_got_building(pcity, B_PALACE)) { - pcity->incite_revolt_cost = INCITE_IMPOSSIBLE_COST; + incite_revolt_cost = INCITE_IMPOSSIBLE_COST; } else { - pcity->incite_revolt_cost = city_owner(pcity)->economic.gold + 1000; + goldfactor = city_owner(pcity)->economic.gold + 1000; + /* adjusted_size + * 2 for happy + * 1 for normal + * 0 for unhappy, angry + * 1 for specialists + * */ + adjusted_size = pcity->size + pcity->ppl_happy[4] - pcity->ppl_unhappy[4] + - pcity->ppl_angry[4]; + + goldfactor *= adjusted_size; + capital = find_palace(city_owner(pcity)); if (capital) { int tmp = map_distance(capital->x, capital->y, pcity->x, pcity->y); @@ -1205,15 +1234,64 @@ if (g->fixed_corruption_distance != 0) { dist = MIN(g->fixed_corruption_distance, dist); } - pcity->incite_revolt_cost /= (dist + 3); - pcity->incite_revolt_cost *= pcity->size; + incite_revolt_cost = goldfactor / (dist + 3); + + /* no damage discount */ + /* linear .. not quadratical */ + /* should we use unit_value?? */ + /* a unit in a !happy city is cheaper than a unit 32 fields from capital */ + unit_list_iterate(pcity->units_supported, punit) { + city_value += unit_type(punit)->build_cost/4; + } unit_list_iterate_end; + + unit_list_iterate(map_get_tile(pcity->x,pcity->y)->units,punit){ + city_value += 3*unit_type(punit)->build_cost/4; + } unit_list_iterate_end; + + built_impr_iterate(pcity, i) { + if (!is_wonder(i)) { + city_value += improvement_value(i); + } else { + city_value += improvement_value(i)*2; + } + } built_impr_iterate_end; + + /* city_value not distance dependent */ + incite_revolt_cost += city_value; + + /* this is to get the same values for a normal enemy city + * like in the old version + * + * buy a city with an unit which cost 40 shields increases the cost + * by 80 for a city from original owner + * by 40 for normal cities + * by 20 for the buy-back case + * + * */ + incite_revolt_cost *=2; + + /* happy or unhappy */ if (city_unhappy(pcity)) { - pcity->incite_revolt_cost /= 2; + incite_revolt_cost /= 2; } + if (pcity->was_happy && city_happy(pcity) && + (get_gov_pcity(pcity)->index != game.government_when_anarchy)) + incite_revolt_cost *= 2; + + /* city is empty */ if (unit_list_size(&map_get_tile(pcity->x,pcity->y)->units)==0) { - pcity->incite_revolt_cost /= 2; + incite_revolt_cost /= 2; } + + /* buy back */ + if (pplayer->player_no == pcity->original) + incite_revolt_cost /= 2; + /* buy the city of original owner (this is new) */ + if (city_owner(pcity)->player_no != pcity->original) + incite_revolt_cost /= 2; + } + return incite_revolt_cost; } /************************************************************************** @@ -1329,7 +1407,6 @@ pcity->anarchy=0; } check_pollution(pcity); - city_incite_cost(pcity); send_city_info(NULL, pcity); if (pcity->anarchy>2 && government_has_flag(g, G_REVOLUTION_WHEN_UNHAPPY)) { Index: server/cityturn.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityturn.h,v retrieving revision 1.26 diff -u -r1.26 cityturn.h --- server/cityturn.h 2002/04/12 13:50:57 1.26 +++ server/cityturn.h 2002/09/30 13:03:31 @@ -33,7 +33,7 @@ void send_city_turn_notifications(struct conn_list *dest, struct city *pcity); void begin_cities_turn(struct player *pplayer); void update_city_activities(struct player *pplayer); -void city_incite_cost(struct city *pcity); +int city_incite_cost(struct player *pplayer, struct city *pcity); void remove_obsolete_buildings_city(struct city *pcity, bool refresh); void remove_obsolete_buildings(struct player *pplayer); Index: server/diplomats.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v retrieving revision 1.30 diff -u -r1.30 diplomats.c --- server/diplomats.c 2002/08/07 11:21:51 1.30 +++ server/diplomats.c 2002/09/30 13:03:31 @@ -737,16 +737,8 @@ return; } - /* Update incite cost. */ - if (pcity->incite_revolt_cost == -1) { - freelog (LOG_ERROR, "Incite cost -1 in diplomat_incite by %s for %s", - pplayer->name, pcity->name); - city_incite_cost (pcity); - } - revolt_cost = pcity->incite_revolt_cost; - - /* Special deal for former owners! */ - if (pplayer->player_no == pcity->original) revolt_cost /= 2; + /* Get incite cost. */ + revolt_cost = city_incite_cost (pplayer, pcity); /* If player doesn't have enough gold, can't incite a revolt. */ if (pplayer->economic.gold < revolt_cost) { @@ -1117,8 +1109,12 @@ _("Game: Your %s has been eliminated defending" " against a %s in %s."), unit_name(punit->type), unit_name(pdiplomat->type), pcity->name); + notify_player_ex(pplayer, pcity->x, pcity->y, E_ENEMY_DIPLOMAT_FAILED, + _("Game: An enemy %s has been eliminated defending" + " %s."), unit_name(punit->type), pcity->name); wipe_unit_safe(punit, &myiter); + return FALSE; } else { /* Attacking Spy/Diplomat dies. */ Index: server/unithand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v retrieving revision 1.234 diff -u -r1.234 unithand.c --- server/unithand.c 2002/09/27 12:32:48 1.234 +++ server/unithand.c 2002/09/30 13:03:32 @@ -245,10 +245,9 @@ return; } if(pcity) { - city_incite_cost(pcity); + req.value1=city_incite_cost(pplayer, pcity); req.id=packet->value; - req.value1=pcity->incite_revolt_cost; - if(pplayer->player_no == pcity->original) req.value1/=2; + //if(pplayer->player_no == pcity->original) req.value1/=2; send_packet_generic_values(pconn, PACKET_INCITE_COST, &req); return; }