[Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Sun, 10 Apr 2005 14:36:44 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12734 >
This is the common portions of city.c taken from the greedy patch and
committed to cvs.
- Per
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.323
diff -u -r1.323 city.c
--- common/city.c 3 Apr 2005 20:19:51 -0000 1.323
+++ common/city.c 6 Apr 2005 22:59:39 -0000
@@ -1780,33 +1780,30 @@
/**************************************************************************
Create content, unhappy and angry citizens.
**************************************************************************/
-static void citizen_base_mood(struct city *pcity,
+static void citizen_base_mood(struct player *pplayer, int specialists,
int *happy, int *content,
- int *unhappy, int *angry)
+ int *unhappy, int *angry, int size)
{
- /* Number of specialists in city */
- int specialists = city_specialists(pcity);
-
/* This is the number of citizens that may start out content, depending
* on empire size and game's city unhappysize. This may be bigger than
* the size of the city, since this is a potential. */
- int base_content = content_citizens(city_owner(pcity));
+ int base_content = content_citizens(pplayer);
/* Create content citizens. Take specialists from their ranks. */
- *content = MAX(0, MIN(pcity->size, base_content) - specialists);
+ *content = MAX(0, MIN(size, base_content) - specialists);
/* Create angry citizens only if we have a negative number of possible
* content citizens. This happens when empires grow really big. */
if (game.angrycitizen == FALSE) {
*angry = 0;
} else {
- *angry = MIN(MAX(0, -base_content), pcity->size - specialists);
+ *angry = MIN(MAX(0, -base_content), size - specialists);
}
/* Create unhappy citizens. In the beginning, all who are not content,
* specialists or angry are unhappy. This is changed by luxuries and
* buildings later. */
- *unhappy = (pcity->size - specialists - *content - *angry);
+ *unhappy = (size - specialists - *content - *angry);
/* No one is born happy. */
*happy = 0;
@@ -2132,7 +2129,7 @@
/* Add base amounts for building upkeep and citizen consumption. */
pcity->usage[O_GOLD] += city_building_upkeep(pcity, O_GOLD);
- pcity->usage[O_FOOD] += 2 * pcity->size;
+ pcity->usage[O_FOOD] += FOOD_COST * pcity->size;
/*
* If you modify anything here these places might also need updating:
@@ -2246,6 +2243,7 @@
void (*send_unit_info) (struct player * pplayer,
struct unit * punit))
{
+ struct player *pplayer = city_owner(pcity);
int prev_tile_trade = pcity->citizen_base[O_TRADE];
if (full_refresh) {
@@ -2255,8 +2253,9 @@
}
get_citizen_output(pcity, pcity->citizen_base); /* Calculate output from
citizens. */
set_city_production(pcity);
- citizen_base_mood(pcity, &pcity->ppl_happy[0], &pcity->ppl_content[0],
- &pcity->ppl_unhappy[0], &pcity->ppl_angry[0]);
+ citizen_base_mood(pplayer, city_specialists(pcity), &pcity->ppl_happy[0],
+ &pcity->ppl_content[0], &pcity->ppl_unhappy[0],
+ &pcity->ppl_angry[0], pcity->size);
pcity->pollution = city_pollution(pcity, pcity->prod[O_SHIELD]);
citizen_happy_luxury(pcity); /* with our new found luxuries */
happy_copy(pcity, 1);
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.203
diff -u -r1.203 city.h
--- common/city.h 26 Mar 2005 05:59:14 -0000 1.203
+++ common/city.h 6 Apr 2005 22:59:39 -0000
@@ -86,6 +89,9 @@
/* Cost in luxuries to make one citizen happier by one level. */
#define HAPPY_COST 2
+/* Cost in food to feed one citizen. */
+#define FOOD_COST 2
+
/* Iterate a city map, from the center (the city) outwards */
extern struct iter_index {
int dx, dy, dist;
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation, Jason Short, 2005/04/06
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation, Vasco Alexandre da Silva Costa, 2005/04/06
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation, Benoit Hudson, 2005/04/06
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation, Benoit Hudson, 2005/04/06
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation, Jason Short, 2005/04/06
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation, Per I. Mathisen, 2005/04/07
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation, Per I. Mathisen, 2005/04/07
- [Freeciv-Dev] Re: (PR#12734) A new, fast and greedy CM implementation,
Per I. Mathisen <=
- [Freeciv-Dev] (PR#12734) calculate city's lux need, Per I. Mathisen, 2005/04/11
- [Freeciv-Dev] (PR#12734) calculate city's lux need, Per I. Mathisen, 2005/04/11
- [Freeciv-Dev] (PR#12734) quick&dirty CM v5, Per I. Mathisen, 2005/04/11
- [Freeciv-Dev] Re: (PR#12734) calculate city's lux need, Benoit Hudson, 2005/04/12
- [Freeciv-Dev] Re: (PR#12734) calculate city's lux need, Jason Short, 2005/04/12
- [Freeciv-Dev] Re: (PR#12734) calculate city's lux need, Per I. Mathisen, 2005/04/13
|
|