Author: cazfi
Date: Tue Mar 24 04:13:59 2015
New Revision: 28605

URL: http://svn.gna.org/viewcvs/freeciv?rev=28605&view=rev
Log:
Rewritten the code to determine barbarian gang size.

See patch #5909

Modified:
    trunk/server/barbarian.c
    trunk/server/barbarian.h

Modified: trunk/server/barbarian.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/barbarian.c?rev=28605&r1=28604&r2=28605&view=diff
==============================================================================
--- trunk/server/barbarian.c    (original)
+++ trunk/server/barbarian.c    Tue Mar 24 04:13:59 2015
@@ -488,12 +488,14 @@
 {
   struct tile *ptile, *utile;
   int i, dist;
-  int uprise = 1;
+  int uprise;
   struct city *pc;
   struct player *barbarians, *victim;
   struct unit_type *leader_type;
   int barb_count, really_created = 0;
   bool hut_present = FALSE;
+  int city_count;
+  int city_max;
 
   /* We attempt the summons on a particular, random position.  If this is
    * an invalid position then the summons simply fails this time.  This means
@@ -532,9 +534,8 @@
   fc_assert(1 < game.server.barbarianrate);
 
   /* do not harass small civs - in practice: do not uprise at the beginning */
-  if ((int)fc_rand(UPRISE_CIV_MORE) >
-           (int)city_list_size(victim->cities) -
-                UPRISE_CIV_SIZE/(game.server.barbarianrate-1)
+  if ((int)fc_rand(30) + 1 >
+      (int)city_list_size(victim->cities) * (game.server.barbarianrate - 1)
       || fc_rand(100) > get_player_bonus(victim, EFT_CIVIL_WAR_CHANCE)) {
     return;
   }
@@ -552,6 +553,15 @@
     update_tile_knowledge(utile);
   }
 
+  city_count = city_list_size(victim->cities);
+  city_max = UPRISE_CIV_SIZE;
+  uprise = 1;
+
+  while (city_max <= city_count) {
+    uprise++;
+    city_max *= 1.2 + UPRISE_CIV_SIZE;
+  }
+
   barb_count = fc_rand(3) + uprise * game.server.barbarianrate;
   leader_type = get_role_unit(L_BARBARIAN_LEADER, 0);
 
@@ -560,9 +570,6 @@
     barbarians = create_barbarian_player(LAND_BARBARIAN);
     if (!barbarians) {
       return;
-    }
-    if (city_list_size(victim->cities) > UPRISE_CIV_MOST) {
-      uprise = 3;
     }
     for (i = 0; i < barb_count; i++) {
       struct unit_type *punittype

Modified: trunk/server/barbarian.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/barbarian.h?rev=28605&r1=28604&r2=28605&view=diff
==============================================================================
--- trunk/server/barbarian.h    (original)
+++ trunk/server/barbarian.h    Tue Mar 24 04:13:59 2015
@@ -22,8 +22,6 @@
 #define MAX_UNREST_DIST   8
 
 #define UPRISE_CIV_SIZE  10
-#define UPRISE_CIV_MORE  30
-#define UPRISE_CIV_MOST  50
 
 #define MAP_FACTOR     2000  /* adjust this to get a good uprising frequency */
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to