Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] Re: (PR#12841) city_luxury_need function
Home

[Freeciv-Dev] Re: (PR#12841) city_luxury_need function

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12841) city_luxury_need function
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Thu, 21 Apr 2005 07:36:11 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12841 >

On Thu, 21 Apr 2005, Benoit Hudson wrote:
> There's a comment that the celebrate code is buggy, but now I'm not sure
> I believe the order code either: it doesn't take account of happy
> citizens -- if the city has more happy than unhappy, it still says we
> need luxuries.

Huh? Only the comment is wrong.

+    /* Find out how much luxuries we need to make everyone content. */
+    result = MAX((angry * 2 + unhappy - happy) * HAPPY_COST, 0);

This code will make the city orderly, not all content. Happy citizens will
keep unhappy citizens in line. The comment was not updated when the code
was...

+    /* 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);

So this will then be wrong, since IIRC you cannot celebrate if there are
_any_ unhappy people in the city. It should be

+    result += MAX(((pcity->size - MAX(happy - (unhappy + angry * 2), 0)
+                  + 1) / 2) * HAPPY_COST, 0);

Since you must additionally make content those we did not make content in
the first calculation.

Tricky...

  - Per






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