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]
Subject: [Freeciv-Dev] Re: (PR#9148) Researchpenalty for stealing techs calculated wrong way
From: "Marko Lindqvist" <marko.lindqvist@xxxxxxxxxxx>
Date: Fri, 24 Jun 2005 08:59:08 -0700
Reply-to: bugs@xxxxxxxxxxx

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


  Untested patch


  - ML

diff -Nurd -X.diff_ignore freeciv/server/cityturn.c freeciv/server/cityturn.c
--- freeciv/server/cityturn.c   2005-06-24 18:18:21.281250000 +0300
+++ freeciv/server/cityturn.c   2005-06-24 18:41:49.265625000 +0300
@@ -1131,10 +1131,10 @@
          choose_random_tech(pplayer);
          tech = get_player_research(pplayer)->researching;
        }
-       do_free_cost(pplayer);
-       found_new_tech(pplayer,
-                      get_player_research(pplayer)->researching, TRUE, TRUE, 
-                      A_NONE);
+        do_free_cost(pplayer, tech);
+        found_new_tech(pplayer,
+                       tech, TRUE, TRUE,
+                       A_NONE);
 
        notify_embassies(pplayer, NULL,
            _("The %s have acquired %s from %s."),
diff -Nurd -X.diff_ignore freeciv/server/diplhand.c freeciv/server/diplhand.c
--- freeciv/server/diplhand.c   2005-06-24 18:18:21.515625000 +0300
+++ freeciv/server/diplhand.c   2005-06-24 18:39:20.984375000 +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-24 18:18:21.546875000 +0300
+++ freeciv/server/diplomats.c  2005-06-24 18:39:57.625000000 +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-24 18:18:23.156250000 
+0300
+++ freeciv/server/scripting/api_actions.c      2005-06-24 18:55:36.218750000 
+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-24 18:18:24.296875000 +0300
+++ freeciv/server/techtools.c  2005-06-24 18:50:30.234375000 +0300
@@ -44,36 +44,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;
 }
 
@@ -178,7 +178,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;
        }
@@ -654,7 +654,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);
 }
 
diff -Nurd -X.diff_ignore freeciv/server/techtools.h freeciv/server/techtools.h
--- freeciv/server/techtools.h  2005-06-24 18:18:24.312500000 +0300
+++ freeciv/server/techtools.h  2005-06-24 18:55:39.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,
@@ -33,4 +33,3 @@
 void get_a_tech(struct player *pplayer, struct player *target);
 
 #endif
-
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c  2005-06-24 18:18:24.406250000 +0300
+++ freeciv/server/unittools.c  2005-06-24 18:52:07.546875000 +0300
@@ -2310,7 +2310,7 @@
                                    " from ancient scrolls of wisdom."),
                   get_nation_name_plural(pplayer->nation), tech_name);
 
-  do_free_cost(pplayer);
+  do_free_cost(pplayer, new_tech);
   if (!is_future_tech(new_tech)) {
     found_new_tech(pplayer, new_tech, FALSE, TRUE, A_NONE);
   } else {

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