Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] Re: (PR#9148) Researchpenalty for stealing techs calculate
Home

[Freeciv-Dev] Re: (PR#9148) Researchpenalty for stealing techs calculate

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: mstefek@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#9148) Researchpenalty for stealing techs calculated wrong way
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Thu, 30 Jun 2005 10:37:30 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Marko Lindqvist wrote:
> 
>   Untested patch

  Updated against CVS.


  - ML

diff -Nurd -X.diff_ignore freeciv/server/diplhand.c freeciv/server/diplhand.c
--- freeciv/server/diplhand.c   2005-06-30 19:05:30.078125000 +0300
+++ freeciv/server/diplhand.c   2005-06-30 20:26:46.406250000 +0300
@@ -367,7 +367,7 @@
                           API_TYPE_STRING, "traded");
         gamelog(GAMELOG_TECH, pdest, pgiver, pclause->value, "acquire");
         gamelog(GAMELOG_TREATY, GL_TECH, pgiver, pdest);
-       do_dipl_cost(pdest);
+       do_dipl_cost(pdest, pclause->value);
 
        found_new_tech(pdest, pclause->value, FALSE, TRUE, A_NONE);
        break;
diff -Nurd -X.diff_ignore freeciv/server/diplomats.c freeciv/server/diplomats.c
--- freeciv/server/diplomats.c  2005-06-30 19:05:30.265625000 +0300
+++ freeciv/server/diplomats.c  2005-06-30 20:26:46.406250000 +0300
@@ -685,7 +685,7 @@
     /* Steal a technology. */
 
     /* Do it. */
-    do_conquer_cost (pplayer);
+    do_conquer_cost (pplayer, target);
     found_new_tech (pplayer, target, FALSE, TRUE, A_NONE);
     /* Report it. */
     notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_THEFT,
diff -Nurd -X.diff_ignore freeciv/server/scripting/api_actions.c 
freeciv/server/scripting/api_actions.c
--- freeciv/server/scripting/api_actions.c      2005-06-30 19:05:32.859375000 
+0300
+++ freeciv/server/scripting/api_actions.c      2005-06-30 20:26:46.406250000 
+0300
@@ -70,11 +70,10 @@
   }
 
   if (get_invention(pplayer, id) != TECH_KNOWN) {
-    do_free_cost(pplayer);
+    do_free_cost(pplayer, id);
     found_new_tech(pplayer, id, FALSE, TRUE, A_NONE);
     return TRUE;
   } else {
     return FALSE;
   }
 }
-
diff -Nurd -X.diff_ignore freeciv/server/techtools.c freeciv/server/techtools.c
--- freeciv/server/techtools.c  2005-06-30 19:05:34.734375000 +0300
+++ freeciv/server/techtools.c  2005-06-30 20:33:53.593750000 +0300
@@ -46,36 +46,36 @@
 /**************************************************************************
 ...
 **************************************************************************/
-void do_dipl_cost(struct player *pplayer)
+void do_dipl_cost(struct player *pplayer, Tech_type_id tech)
 {
   struct player_research * research = get_player_research(pplayer);
 
   research->bulbs_researched
-    -= (total_bulbs_required(pplayer) * game.info.diplcost) / 100;
+    -= (base_total_bulbs_required(pplayer, tech) * game.info.diplcost) / 100;
   research->changed_from = -1;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void do_free_cost(struct player *pplayer)
+void do_free_cost(struct player *pplayer, Tech_type_id tech)
 {
   struct player_research * research = get_player_research(pplayer);
 
   research->bulbs_researched
-    -= (total_bulbs_required(pplayer) * game.info.freecost) / 100;
+    -= (base_total_bulbs_required(pplayer, tech) * game.info.freecost) / 100;
   research->changed_from = -1;
 }
 
 /**************************************************************************
 ...
 **************************************************************************/
-void do_conquer_cost(struct player *pplayer)
+void do_conquer_cost(struct player *pplayer, Tech_type_id tech)
 {
   struct player_research * research = get_player_research(pplayer);  
 
   research->bulbs_researched
-    -= (total_bulbs_required(pplayer) * game.info.conquercost) / 100;
+    -= (base_total_bulbs_required(pplayer, tech) * game.info.conquercost) / 
100;
   research->changed_from = -1;
 }
 
@@ -180,7 +180,7 @@
                           get_nation_name_plural(pplayer->nation),
                           get_tech_name(pplayer, i), buf);
 
-         do_free_cost(pplayer);
+         do_free_cost(pplayer, i);
          found_new_tech(pplayer, i, FALSE, TRUE, A_NONE);
          break;
        }
@@ -693,7 +693,7 @@
                   get_tech_name(pplayer, stolen_tech),
                   get_nation_name_plural(target->nation));
 
-  do_conquer_cost(pplayer);
+  do_conquer_cost(pplayer, stolen_tech);
   found_new_tech(pplayer, stolen_tech, FALSE, TRUE, A_NONE);
 }
 
@@ -774,7 +774,7 @@
   Tech_type_id tech;
   
   tech = pick_random_tech(pplayer);
-  do_free_cost(pplayer);
+  do_free_cost(pplayer, tech);
   found_new_tech(pplayer, tech, FALSE, TRUE, A_NONE);
   return tech;
 }
@@ -789,7 +789,7 @@
     return give_random_free_tech(pplayer);
   }
   tech = get_player_research(pplayer)->researching;
-  do_free_cost(pplayer);
+  do_free_cost(pplayer, tech);
   found_new_tech(pplayer, tech, FALSE, TRUE, A_NONE);
   return tech;
 }
diff -Nurd -X.diff_ignore freeciv/server/techtools.h freeciv/server/techtools.h
--- freeciv/server/techtools.h  2005-06-30 19:05:34.750000000 +0300
+++ freeciv/server/techtools.h  2005-06-30 20:26:46.437500000 +0300
@@ -16,9 +16,9 @@
 #include "player.h"
 #include "tech.h"
 
-void do_dipl_cost(struct player *pplayer);
-void do_free_cost(struct player *pplayer);
-void do_conquer_cost(struct player *pplayer);
+void do_dipl_cost(struct player *pplayer, Tech_type_id tech);
+void do_free_cost(struct player *pplayer, Tech_type_id tech);
+void do_conquer_cost(struct player *pplayer, Tech_type_id tech);
 
 void do_tech_parasite_effect(struct player *pplayer);
 void found_new_tech(struct player *plr, Tech_type_id tech_found,
@@ -34,4 +34,3 @@
 Tech_type_id give_random_free_tech(struct player *pplayer);
 Tech_type_id give_immediate_free_tech(struct player *pplayer);
 #endif
-

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