Complete.Org: Mailing Lists: Archives: freeciv-dev: October 1998:
[Freeciv-Dev] units found in huts
Home

[Freeciv-Dev] units found in huts

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] units found in huts
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Tue, 27 Oct 1998 23:13:00 +1100

This patch fixes what I believe to be a few problems with 
find_a_unit_type() (function to pick a unit_type found in hut).

The existing version has the following behaviour:
Always a chance of Horsemen, Legion; chance of Chariot when Chivalry
known by anyone; chance of Chariot and Knights when Gunpowder known.
Musketeers are never found despite being in the code.

The fixed version has: 
Always a chance of Horsemen, Legion, Chariot; chance of Knights when 
Chivalry known; chance of Musketeers when Gunpowder known.

-- David
diff -u -r --exclude-from exclude freeciv-cvs/server/unittools.c 
freeciv-mod/server/unittools.c
--- freeciv-cvs/server/unittools.c      Wed Sep  2 00:32:38 1998
+++ freeciv-mod/server/unittools.c      Mon Oct 26 18:35:12 1998
@@ -458,29 +458,32 @@
 
 /**************************************************************************
   returns a unit type for the goodie huts
+  Note: it's possible to get Gunpowder before Chivalry;
+  Also note: myrand(num) returns 0 to (num-1) inclusive
 **************************************************************************/
 int find_a_unit_type()
  {
   int num;
   
-  num = 2;
+  num = 3;
   if (game.global_advances[A_CHIVALRY])
-    num = 3;
+    num++;
   if (game.global_advances[A_GUNPOWDER]) 
-    num = 4;
+    num++;
 
   switch (myrand(num)) {
   case 0:
-    return U_HORSEMEN;
-  case 1:
     return U_LEGION;
+  case 1:
+    return U_HORSEMEN;
   case 2:
     return U_CHARIOT;
   case 3:
-    return U_KNIGHTS;
+    return (game.global_advances[A_CHIVALRY]) ? U_KNIGHTS : U_MUSKETEERS;
   case 4:
     return U_MUSKETEERS;
   default:
+    printf("problem in find_a_unit_type\n");
     return U_HORSEMEN;
   }
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] units found in huts, David Pfitzner <=