[Freeciv-Dev] Re: (PR#12841) city_luxury_need function
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12841 >
Uh... "attached" all right...
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.329
diff -b -u -p -r1.329 city.c
--- common/city.c 21 Apr 2005 00:28:27 -0000 1.329
+++ common/city.c 21 Apr 2005 14:08:25 -0000
@@ -2249,6 +2249,10 @@ void generic_city_refresh(struct city *p
unhappy_city_check(pcity);
set_surpluses(pcity);
+ assert(pcity->surplus[O_LUXURY]
+ >= city_luxury_need(pcity, city_specialists(pcity),
+ !city_unhappy(pcity), city_happy(pcity)));
+
if (full_refresh
&& pcity->citizen_base[O_TRADE] != prev_tile_trade) {
int i;
@@ -2616,3 +2620,40 @@ void remove_city_virtual(struct city *pc
unit_list_free(pcity->units_supported);
free(pcity);
}
+
+/**************************************************************************
+ Calculate necessary luxury to achieve goals for this city.
+
+ The number of specialists matters since specialists don't use up
+ luxuries -- they're just always content.
+
+ FIXME This is buggy for celebrate: we need to make all unhappy citizens
+ at least content. Maybe we should use citzen_happy_luxury somehow?
+**************************************************************************/
+int city_luxury_need(struct city *pcity, int specialists,
+ bool order, bool celebrate)
+{
+ struct player *pplayer = city_owner(pcity);
+ int result = 0;
+ int happy, content, unhappy, angry;
+
+ if (order || celebrate) {
+ /* We need to figure out how much luxuries we need. */
+ citizen_base_mood(pplayer, specialists, &happy, &content,
+ &unhappy, &angry, pcity->size);
+ citizen_content_buildings(pcity, &content, &unhappy, &angry);
+ citizen_happy_units(pcity, &happy, &content, &unhappy, &angry);
+ citizen_happy_wonders(pcity, &happy, &content, &unhappy, &angry);
+ }
+ if (order || celebrate) {
+ /* Find out how much luxuries we need to make everyone content. */
+ result = MAX((angry * 2 + unhappy - happy) * HAPPY_COST, 0);
+ }
+ if (celebrate) {
+ /* Find out how much extra luxuries we will need to make enough
+ * citizens happy that we can celebrate. */
+ result += MAX(((pcity->size - happy + 1) / 2) * HAPPY_COST, 0);
+ }
+
+ return result;
+}
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.205
diff -b -u -p -r1.205 city.h
--- common/city.h 18 Apr 2005 06:52:50 -0000 1.205
+++ common/city.h 21 Apr 2005 14:08:26 -0000
@@ -517,6 +517,8 @@ void remove_city_virtual(struct city *pc
bool is_city_option_set(const struct city *pcity, enum city_options option);
void city_styles_alloc(int num);
void city_styles_free(void);
+int city_luxury_need(struct city *pcity, int specialists,
+ bool order, bool celebrate);
void get_citizen_output(const struct city *pcity, int *output);
void add_tax_income(const struct player *pplayer, int trade, int *output);
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Per I. Mathisen, 2005/04/19
- [Freeciv-Dev] (PR#12841) city_luxury_need function, Jason Short, 2005/04/20
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Per I. Mathisen, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Benoit Hudson, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Benoit Hudson, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function,
Benoit Hudson <=
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Per I. Mathisen, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Benoit Hudson, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Jason Short, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Jason Short, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Per I. Mathisen, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Brian Dunstan, 2005/04/21
- [Freeciv-Dev] Re: (PR#12841) city_luxury_need function, Benoit Hudson, 2005/04/21
|
|