Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14170) Replace "Trade_revenue_reduce" tech flag with p
Home

[Freeciv-Dev] (PR#14170) Replace "Trade_revenue_reduce" tech flag with p

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#14170) Replace "Trade_revenue_reduce" tech flag with proper effect
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Mon, 3 Oct 2005 11:06:46 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Mon Oct 03 17:00:27 2005]:

> This should definitely be an effect.  But where do you get 1.189?  The
> fourth root of 2?  But why isn't this just 2/3 (or 1.5 if you want to
> invert it)?  If you want to change the logic around, change it to be
> simpler: a power of 2, in centimes (so a value of -100 means cutting
> the
> trade in half).
> 
>    tb = (double)tb * pow(2, (double)bonus / 100.0);
> 
> then for the current case where each cuts it by 33% you'd want -58 I
> think (log2(2/3) = log(2/3) / log(2) ~= -0.5849).
> 
OK.
--
mateusz
? civscore.log
? client/diff.diff
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.241
diff -u -r1.241 aicity.c
--- ai/aicity.c 3 Oct 2005 06:38:04 -0000       1.241
+++ ai/aicity.c 3 Oct 2005 18:03:05 -0000
@@ -654,6 +654,7 @@
         case EFT_INSPIRE_PARTISANS:
         case EFT_HAPPINESS_TO_GOLD:
         case EFT_FANATICS:
+       case EFT_TRADE_REVENUE_BONUS:
           break;
        case EFT_LAST:
          freelog(LOG_ERROR, "Bad effect type.");
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.365
diff -u -r1.365 city.c
--- common/city.c       30 Sep 2005 17:03:36 -0000      1.365
+++ common/city.c       3 Oct 2005 18:03:24 -0000
@@ -893,7 +893,7 @@
 int get_caravan_enter_city_trade_bonus(const struct city *pc1, 
                                        const struct city *pc2)
 {
-  int i, tb;
+  int tb, bonus;
 
   /* Should this be real_map_distance? */
   tb = map_distance(pc1->tile, pc2->tile) + 10;
@@ -902,12 +902,11 @@
   /*  fudge factor to more closely approximate Civ2 behavior (Civ2 is
    * really very different -- this just fakes it a little better) */
   tb *= 3;
-
-  /* Check for technologies that reduce trade revenues. */
-  for (i = 0; i < num_known_tech_with_flag(city_owner(pc1),
-                                          TF_TRADE_REVENUE_REDUCE); i++) {
-    tb = (tb * 2) / 3;
-  }
+  
+  /* Trade_revenue_bonus increases revenue by power of 2 in centimes */
+  bonus = get_city_bonus(pc1, EFT_TRADE_REVENUE_BONUS);
+  
+  tb = (float)tb * pow(2.0, (double)bonus / 100.0);
 
   return tb;
 }
Index: common/effects.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.c,v
retrieving revision 1.47
diff -u -r1.47 effects.c
--- common/effects.c    22 Aug 2005 21:15:48 -0000      1.47
+++ common/effects.c    3 Oct 2005 18:03:24 -0000
@@ -116,6 +116,7 @@
   "Inspire_Partisans",
   "Happiness_To_Gold",
   "Fanatics",
+  "Trade_Revenue_Bonus",
   "No_Diplomacy"
 };
 
Index: common/effects.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.h,v
retrieving revision 1.28
diff -u -r1.28 effects.h
--- common/effects.h    22 Aug 2005 21:15:48 -0000      1.28
+++ common/effects.h    3 Oct 2005 18:03:25 -0000
@@ -105,6 +105,7 @@
   EFT_HAPPINESS_TO_GOLD,
   EFT_FANATICS, /* stupid special case, we hatess it */
   EFT_NO_DIPLOMACY,
+  EFT_TRADE_REVENUE_BONUS,
   EFT_LAST     /* keep this last */
 };
 
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.101
diff -u -r1.101 tech.c
--- common/tech.c       3 Oct 2005 02:50:45 -0000       1.101
+++ common/tech.c       3 Oct 2005 18:03:27 -0000
@@ -41,7 +41,7 @@
 
 static const char *flag_names[] = {
   "Bonus_Tech", "Bridge", "Railroad", "Fortress",
-  "Watchtower", "Population_Pollution_Inc", "Trade_Revenue_Reduce",
+  "Watchtower", "Population_Pollution_Inc", 
   "Airbase", "Farmland", "Reduce_Trireme_Loss1", "Reduce_Trireme_Loss2", 
   "Build_Airborne"
 };
Index: common/tech.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.h,v
retrieving revision 1.59
diff -u -r1.59 tech.h
--- common/tech.h       20 Jul 2005 07:19:20 -0000      1.59
+++ common/tech.h       3 Oct 2005 18:03:27 -0000
@@ -58,8 +58,6 @@
   TF_FORTRESS,  /* "Settler" unit types can build fortress */
   TF_WATCHTOWER, /* Units get enhanced visionrange in a fortress (=fortress 
acts also as a watchtower) */
   TF_POPULATION_POLLUTION_INC,  /* Increase the pollution factor created by 
popultaion by one */
-  TF_TRADE_REVENUE_REDUCE, /* When known by the player establishing a trade 
route 
-                              reduces the initial revenue by cumulative 
factors of 2/3 */
   TF_AIRBASE,   /* "Airbase" unit types can build Airbases */
   TF_FARMLAND,  /* "Settler" unit types can build farmland */
   TF_REDUCE_TRIREME_LOSS1, /* Reduces chance of Trireme being lost at sea */
Index: data/civ1/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/effects.ruleset,v
retrieving revision 1.8
diff -u -r1.8 effects.ruleset
--- data/civ1/effects.ruleset   3 Oct 2005 06:38:05 -0000       1.8
+++ data/civ1/effects.ruleset   3 Oct 2005 18:03:31 -0000
@@ -984,3 +984,19 @@
     { "type", "name", "range"
       "Building", "Women's Suffrage", "Player"
     }
+
+[effect_flight_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Flight", "Player"
+    }
+    
+[effect_railroad_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Railroad", "Player"
+    }    
Index: data/civ1/techs.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/techs.ruleset,v
retrieving revision 1.17
diff -u -r1.17 techs.ruleset
--- data/civ1/techs.ruleset     17 Dec 2004 00:14:15 -0000      1.17
+++ data/civ1/techs.ruleset     3 Oct 2005 18:03:31 -0000
@@ -216,7 +216,7 @@
 name     = _("Flight")
 req1     = "Combustion"
 req2     = "Physics"
-flags    = "Trade_Revenue_Reduce"
+flags    = ""
 
 [advance_fundamentalism]
 name     = _("Fundamentalism")
@@ -433,7 +433,7 @@
 name     = _("Railroad")
 req1     = "Steam Engine"
 req2     = "Bridge Building"
-flags    = "Railroad","Trade_Revenue_Reduce"
+flags    = "Railroad"
 
 [advance_recycling]
 name     = _("Recycling")
Index: data/civ2/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/effects.ruleset,v
retrieving revision 1.11
diff -u -r1.11 effects.ruleset
--- data/civ2/effects.ruleset   3 Oct 2005 06:38:05 -0000       1.11
+++ data/civ2/effects.ruleset   3 Oct 2005 18:03:34 -0000
@@ -1394,3 +1394,18 @@
       "Building", "Capitalization", "City"
     }
 
+[effect_flight_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Flight", "Player"
+    }
+    
+[effect_railroad_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Railroad", "Player"
+    }    
Index: data/default/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/effects.ruleset,v
retrieving revision 1.13
diff -u -r1.13 effects.ruleset
--- data/default/effects.ruleset        3 Oct 2005 06:38:05 -0000       1.13
+++ data/default/effects.ruleset        3 Oct 2005 18:03:36 -0000
@@ -1471,3 +1471,18 @@
       "Building", "Coinage", "City"
     }
 
+[effect_flight_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Flight", "Player"
+    }
+    
+[effect_railroad_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Railroad", "Player"
+    }    
Index: data/default/techs.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/techs.ruleset,v
retrieving revision 1.26
diff -u -r1.26 techs.ruleset
--- data/default/techs.ruleset  21 Apr 2005 22:53:13 -0000      1.26
+++ data/default/techs.ruleset  3 Oct 2005 18:03:36 -0000
@@ -48,9 +48,6 @@
 ; "Watchtower" = Units get enhanced visionrange in a fortress
 ; "Population_Pollution_Inc" = Increase the pollution factor created by
 ;                              popultaion by one
-; "Trade_Revenue_Reduce" = When known by the player establishing a trade
-;                          route reduces the initial revenue by cumulative
-;                          factors of 2/3
 ; "Airbase" = "Airbase" unit types can build Airbases
 ; "Build_Airborne" = from now on can build air units (for use by AI)
 
@@ -292,7 +289,7 @@
 name     = _("Flight")
 req1     = "Combustion"
 req2     = "Theory of Gravity"
-flags    = "Trade_Revenue_Reduce","Build_Airborne"
+flags    = "Build_Airborne"
 graphic     = "a.flight"
 graphic_alt = "-"
 
@@ -584,7 +581,7 @@
 name     = _("Railroad")
 req1     = "Steam Engine"
 req2     = "Bridge Building"
-flags    = "Railroad","Trade_Revenue_Reduce"
+flags    = "Railroad"
 graphic     = "a.railroad"
 graphic_alt = "-"
 
Index: data/history/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/effects.ruleset,v
retrieving revision 1.9
diff -u -r1.9 effects.ruleset
--- data/history/effects.ruleset        3 Oct 2005 06:38:05 -0000       1.9
+++ data/history/effects.ruleset        3 Oct 2005 18:03:39 -0000
@@ -1053,3 +1053,18 @@
       "Building", "Coinage", "City"
     }
 
+[effect_flight_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Flight", "Player"
+    }
+    
+[effect_railroad_trade_revenue_reduce]
+name    = "Trade_Revenue_Bonus"
+value   = -58
+reqs    =
+    { "type", "name", "range"
+      "Tech", "Railroad", "Player"
+    }    
Index: data/history/techs.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/techs.ruleset,v
retrieving revision 1.6
diff -u -r1.6 techs.ruleset
--- data/history/techs.ruleset  21 Apr 2005 22:53:13 -0000      1.6
+++ data/history/techs.ruleset  3 Oct 2005 18:03:39 -0000
@@ -218,7 +218,7 @@
 name     = _("Flight")
 req1     = "Combustion"
 req2     = "Theory of Gravity"
-flags    = "Trade_Revenue_Reduce"
+flags    = ""
 
 [advance_fundamentalism]
 name     = _("Fundamentalism")
@@ -438,7 +438,7 @@
 name     = _("Railroad")
 req1     = "Metallurgy"
 req2     = "Bridge Building"
-flags    = "Railroad","Trade_Revenue_Reduce"
+flags    = "Railroad"
 
 [advance_recycling]
 name     = _("Recycling")
Index: doc/README.effects
===================================================================
RCS file: /home/freeciv/CVS/freeciv/doc/README.effects,v
retrieving revision 1.15
diff -u -r1.15 README.effects
--- doc/README.effects  3 Oct 2005 06:38:05 -0000       1.15
+++ doc/README.effects  3 Oct 2005 18:03:40 -0000
@@ -168,6 +168,9 @@
                        AMOUNT <= 0 the timeline is unaffected.
                        The effect will be ignored if game.spacerace isn't
                        set.
+"Trade_Revenue_Bonus" - Trade revenue is multiplied by pow(2, amount/100).
+                        The amount value is taken from the caravan's home 
+                       city.
 
 
 .range may be one of: 

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