Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] (PR#12917) myrand() call inside for loop
Home

[Freeciv-Dev] (PR#12917) myrand() call inside for loop

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12917) myrand() call inside for loop
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 27 Apr 2005 20:22:14 -0700
Reply-to: bugs@xxxxxxxxxxx

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

The loop doesn't do what it's supposed to do.  This patch should fix it.
 I haven't checked if this applies to S2_0.

-jason

? barbs
Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.87
diff -u -r1.87 barbarian.c
--- server/barbarian.c  23 Apr 2005 17:40:28 -0000      1.87
+++ server/barbarian.c  28 Apr 2005 03:12:28 -0000
@@ -391,12 +391,14 @@
   }
 
   if (!is_ocean(tile_get_terrain(utile))) {
+    int rand_factor = myrand(3);
+
     /* land (disembark) barbarians */
     barbarians = create_barbarian_player(TRUE);
     if (city_list_size(victim->cities) > UPRISE_CIV_MOST) {
       uprise = 3;
     }
-    for (i = 0; i < myrand(3) + uprise * game.barbarianrate; i++) {
+    for (i = 0; i < rand_factor + uprise * game.barbarianrate; i++) {
       unit = find_a_unit_type(L_BARBARIAN, L_BARBARIAN_TECH);
       (void) create_unit(barbarians, utile, unit, 0, 0, -1);
       freelog(LOG_DEBUG, "Created barbarian unit %s", unit_types[unit].name);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12917) myrand() call inside for loop, Jason Short <=