Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11462) use happy_cost in city.c
Home

[Freeciv-Dev] (PR#11462) use happy_cost in city.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11462) use happy_cost in city.c
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Dec 2004 13:26:30 -0800
Reply-to: bugs@xxxxxxxxxxx

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

HAPPY_COST is added as a global constant.  So we should use it.

-jason

Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.278
diff -u -r1.278 city.c
--- common/city.c       10 Dec 2004 03:53:45 -0000      1.278
+++ common/city.c       10 Dec 2004 21:25:49 -0000
@@ -1822,25 +1822,30 @@
                                         int *angry, int *unhappy, int *happy, 
                                         int *content)
 {
-  while (*luxuries >= 2 && *angry > 0) {
+  while (*luxuries >= HAPPY_COST && *angry > 0) {
+    /* Upgrade angry to unhappy: costs HAPPY_COST each. */
     (*angry)--;
     (*unhappy)++;
-    *luxuries -= 2;
+    *luxuries -= HAPPY_COST;
   }
-  while (*luxuries >= 2 && *content > 0) {
+  while (*luxuries >= HAPPY_COST && *content > 0) {
+    /* Upgrade content to happy: costs HAPPY_COST each. */
     (*content)--;
     (*happy)++;
     *luxuries -= 2;
   }
-  while (*luxuries >= 4 && *unhappy > 0) {
+  while (*luxuries >= 2 * HAPPY_COST && *unhappy > 0) {
+    /* Upgrade unhappy to happy.  Note this is a 2-level upgrade with
+     * double the cost. */
     (*unhappy)--;
     (*happy)++;
-    *luxuries -= 4;
+    *luxuries -= 2 * HAPPY_COST;
   }
-  if (*luxuries >= 2 && *unhappy > 0) {
+  if (*luxuries >= HAPPY_COST && *unhappy > 0) {
+    /* Upgrade unhappy to content: costs HAPPY_COST each. */
     (*unhappy)--;
     (*content)++;
-    *luxuries -= 2;
+    *luxuries -= HAPPY_COST;
   }
 }
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11462) use happy_cost in city.c, Jason Short <=