diff -r -u ../my_freeciv/common/city.c ./common/city.c --- ../my_freeciv/common/city.c Wed Feb 2 06:34:35 2000 +++ ./common/city.c Wed Feb 2 07:15:15 2000 @@ -928,10 +928,24 @@ return (pcity->ppl_happy[4]ppl_unhappy[4]); } +/************************************************************************** +cities celebrate only after consecutive happy turns +**************************************************************************/ int city_celebrating(struct city *pcity) { - struct government *g = get_gov_pcity(pcity); - return (pcity->size>=g->rapture_size && pcity->was_happy && city_happy(pcity)); + struct government *g = get_gov_pcity(pcity); + return (pcity->size>=g->rapture_size && pcity->was_happy && city_happy(pcity)); +} + +/************************************************************************** +.rapture is checked instead of city_celebrating() because this functun is +called after .was_happy was updated. +**************************************************************************/ +int city_rapture_grow(struct city *pcity) +{ + struct government *g = get_gov_pcity(pcity); + return (pcity->rapture>0 && pcity->food_surplus>0 && + government_has_flag(g, G_RAPTURE_CITY_GROWTH)); } /* The find_city_by_id() code has returned from its trip to server land and diff -r -u ../my_freeciv/common/city.h ./common/city.h --- ../my_freeciv/common/city.h Wed Jan 19 13:28:16 2000 +++ ./common/city.h Wed Feb 2 07:05:06 2000 @@ -236,6 +236,7 @@ int city_happy(struct city *pcity); /* generally use celebrating instead */ int city_unhappy(struct city *pcity); /* anarchy??? */ int city_celebrating(struct city *pcity); /* love the king ??? */ +int city_rapture_grow(struct city *pcity); /* improvement functions */ diff -r -u ../my_freeciv/server/cityturn.c ./server/cityturn.c --- ../my_freeciv/server/cityturn.c Wed Feb 2 06:37:31 2000 +++ ./server/cityturn.c Wed Feb 2 07:13:18 2000 @@ -773,6 +773,7 @@ { int have_square, x, y; int has_granary = city_got_effect(pcity, B_GRANARY); + int rapture_grow = city_rapture_grow(pcity); /* check before size increase! */ int new_food; if (!city_got_building(pcity, B_AQUEDUCT) @@ -814,10 +815,15 @@ } pcity->size++; - if (has_granary) - new_food = ((pcity->size+1) * game.foodbox) / 2; - else - new_food = 0; + /* Do not empty food stock if city is growing by celebrating */ + if (rapture_grow) { + new_food = (pcity->size+1) * game.foodbox; + } else { + if (has_granary) + new_food = ((pcity->size+1) * game.foodbox) / 2; + else + new_food = 0; + } pcity->food_stock = MIN(pcity->food_stock, new_food); /* If there is enough food, and the city is big enough, @@ -879,7 +885,7 @@ static void city_populate(struct city *pcity) { pcity->food_stock+=pcity->food_surplus; - if(pcity->food_stock >= (pcity->size+1)*game.foodbox) + if(pcity->food_stock >= (pcity->size+1)*game.foodbox || city_rapture_grow(pcity)) city_increase_size(pcity); else if(pcity->food_stock<0) { /* FIXME: should this depend on units with ability to build @@ -1426,12 +1432,6 @@ city_check_workers(pplayer, pcity); city_refresh(pcity); - /* increase city size if it is in rapture -- jjm */ - if (city_celebrating(pcity) && government_has_flag(g, G_RAPTURE_CITY_GROWTH) && - pcity->size >= g->rapture_size && pcity->food_surplus > 0) { - city_increase_size(pcity); - } - if (!city_got_effect(pcity,B_GRANARY) && !pcity->is_building_unit && (pcity->currently_building == B_GRANARY) && (pcity->food_surplus > 0) && (pcity->shield_surplus > 0)) { @@ -1480,12 +1480,14 @@ } pcity->was_happy=city_happy(pcity); - { - int id=pcity->id; - city_populate(pcity); - if(!city_list_find_id(&pplayer->cities, id)) - return 0; - } + + /* City population updated here -- after the rapture stuff above. --Jing */ + { + int id=pcity->id; + city_populate(pcity); + if(!city_list_find_id(&pplayer->cities, id)) + return 0; + } pcity->is_updated=1;