Complete.Org: Mailing Lists: Archives: freeciv-dev: December 1999:
[Freeciv-Dev] Re: New Rapture_size in 1.9.0 (PR#194)
Home

[Freeciv-Dev] Re: New Rapture_size in 1.9.0 (PR#194)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: New Rapture_size in 1.9.0 (PR#194)
From: "Mike Jing" <miky40@xxxxxxxxxxx>
Date: Mon, 20 Dec 1999 02:05:34 EST
Reply-to: mike_jing@xxxxxxxxx

OK, here is what I have done (also see attached patch):

-- added new flag "G_RAPTURE_CITY_GROWTH" in common/government.h and the corresponding flag name "Rapture_City_Growth" in common/government.c

-- added the new flag for Republic and Democracy and set rapture_size to 3 for all forms of government in:
        data/civ1/governments.ruleset
        data/civ2/governments.ruleset
        data/default/governments.ruleset

-- fixed Help on Happiness in data/helpdata.txt to reflect the new rapture_size of 3

-- fixed the old use of rapture_size in ai/aihand.c to use the new flag instead

-- fixed city_celebrating() in common/city.c to use rapture_size instead of the number 5

-- use city_celebrating() and the new flag to determine when city should grow by celebrating in server/cityturn.c

-- added new variable "rapture" in the "city" construct (and use it much the same way as the "anarchy" variable) in common/city.h

-- initialize and handle the new "rapture" variable in server/cityhand.c and server/plrhand.c (same way as "anarchy")

-- use the "rapture" rounds count to fix the display of game messages about city celebrations in server/cityturn.c


A couple of finer points:

1. The original city_celebrating() routine only requires that the city was happy during the last turn and is now bigger than or equal to size 5. This seems wrong because it is used to display the happiness state of the city in the City Report dialog, and the city should be happy NOW to be displayed as in Rapture. Here is the diff:

----------------------------------8<---------------------------------------
diff -r -u ../freeciv-Dec-19-1999/common/city.c ./common/city.c
--- ../freeciv-Dec-19-1999/common/city.c        Mon Nov 15 06:46:37 1999
+++ ./common/city.c     Sun Dec 19 19:41:41 1999
@@ -892,7 +892,8 @@

int city_celebrating(struct city *pcity)
{
-  return (pcity->size>=5 && 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));
}

/* The find_city_by_id() code has returned from its trip to server land and
----------------------------------8<---------------------------------------

Note in the original code, the "city_happy(pcity)" part was commented out. I put it back in and thus require a city to be happy during the previous turn and also to be happy now in order to celebrate. From what I can gather from the update_city_activity() routine in server/cityturn.c, this is the criteria for celebration used to determine rapid city growth. I think the same rule should be used to determine the other effects of celebration, and indeed, city_celebrating() is already being used to calculate these effects. So everything is consistent if we use the same routine to determine if a city is celebrating, i.e. in a state of Rapture.

The only loophole in this test is when a city was happy during the last turn but was smaller than rapture_size, and after the turn update it grows to rapture_size and is still happy. In this case the city will now be considered to be in Rapture. I think this should be allowed and it is not too much of a problem.

The bottom line is, a city has to be happy on consecutive turns to be able to celebrate, or at least I think that's the desired behavior. Please let me know if I am wrong on this.

2. I added the "rapture" variable in the "city" construct in order to deal with the "We Love the ... Day celebrated in ..." messages in a similar way to how the Disorder messages are handled. However, there is a small difference due to how celebration/rapture is defined in the last section. A city falls into disorder/anarchy as soon as it becomes unhappy, e.g. if you reduce the luxury rate or rearrange the city workers so that not enough luxury is produced and too many citizens become unhappy, the city will be labeled as in disorder immediately, without the need to wait for the turn update. In contrast, if you raise luxury rate and make your citizens happy, the city cannot go into celebration/rapture at once but only after the turn update. Again, this is just my understanding and I could be totally wrong.

Another difference is that the Celebration messages are printed before city_populate() is called, while the Disorder messages are handled after the city population is updated. This means the Disorder messages comes at the beginning of the turn, while Celebrations are notified at the end of the turn (or the beginning of the next turn) after the city is already in rapture. I think this is OK, and it's actually nice to see the celebration and city growth messages come during the same turn update when you are trying to grow your cities by celebrating. I am even tempted to let it print out "We Love the ... Day continued in ..." as long as the city is in rapture. Let me know whether you think that would be a good idea.

One thing that bothers me is that the variable "anarchy" is not handled in client/packhand.c and common/packet.c along with the other city info. That's why I didn't modify these files to include the new "rapture" variable. But is this correct? Could this have been overlooked when the "anarchy" variable was added? Is this a problem at all?


There are a few other places I think I can clean up, e.g. remove the side effect of city_refresh() because that's the job of city_celebrating(). Please take a look at the attached patch and see if I have done something wrong. Thanks in advance.

Mike Jing

P.S. I tried to test it but the server hang before I could turn up the luxury. I submitted a bug report on that with the game save file. Please take a look at it and see what was wrong. I will start another game and try it again.



______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

Attachment: rapture.diff
Description: Binary data


[Prev in Thread] Current Thread [Next in Thread]