Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] (PR#14129) choose_random_tech called on "set" tech
Home

[Freeciv-Dev] (PR#14129) choose_random_tech called on "set" tech

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#14129) choose_random_tech called on "set" tech
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Sun, 2 Oct 2005 06:57:13 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Wed Sep 28 04:03:43 2005]:
> 
> Use S2_0 (2.0.6) with this RC file.  The message
> 
> 1: Error: choose_random_tech should only be called when research target 
> is A_UNSET. Please report this bug at <bugs@xxxxxxxxxxxx>.
> 
> is repeated over and over again.  In fact I think this will occur with 
> *any* autogame.
> 
> -jason
> 
Oops.
Here's a patch. The bug was in new techs found in huts.
--
mateusz 

Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.330.2.39
diff -u -r1.330.2.39 plrhand.c
--- server/plrhand.c    20 Sep 2005 10:35:02 -0000      1.330.2.39
+++ server/plrhand.c    2 Oct 2005 13:55:15 -0000
@@ -638,6 +638,21 @@
   return A_NONE;
 }
 
+/****************************************************************************
+  Gives a player random tech, which he hasn't researched yet. Applies freecost
+  Returns the tech.
+****************************************************************************/
+Tech_Type_id give_random_free_tech(struct player* pplayer)
+{
+  Tech_Type_id tech;
+  
+  tech = pick_random_tech(pplayer);
+  do_free_cost(pplayer);
+  found_new_tech(pplayer, tech, FALSE, TRUE, A_NONE);
+  return tech;
+}
+
+
 /**************************************************************************
 ...
 **************************************************************************/
Index: server/plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.69.2.2
diff -u -r1.69.2.2 plrhand.h
--- server/plrhand.h    20 Sep 2005 10:35:03 -0000      1.69.2.2
+++ server/plrhand.h    2 Oct 2005 13:55:15 -0000
@@ -73,6 +73,7 @@
 void get_a_tech(struct player *pplayer, struct player *target);
 void give_initial_techs(struct player* plr);
 Tech_Type_id give_random_initial_tech(struct player* pplayer);
+Tech_Type_id give_random_free_tech(struct player* pplayer);
 
 void send_player_turn_notifications(struct conn_list *dest);
 
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.306.2.18
diff -u -r1.306.2.18 unittools.c
--- server/unittools.c  8 Sep 2005 19:20:38 -0000       1.306.2.18
+++ server/unittools.c  2 Oct 2005 13:55:16 -0000
@@ -2285,19 +2285,10 @@
 static void hut_get_tech(struct unit *punit)
 {
   struct player *pplayer = unit_owner(punit);
-  int res_ed, res_ing;
   Tech_Type_id new_tech;
   const char *tech_name;
   
-  /* Save old values, choose tech, then restore old values: */
-  res_ed = pplayer->research.bulbs_researched;
-  res_ing = pplayer->research.researching;
-  
-  choose_random_tech(pplayer);
-  new_tech = pplayer->research.researching;
-  
-  pplayer->research.bulbs_researched = res_ed;
-  pplayer->research.researching = res_ing;
+  new_tech = give_random_free_tech(pplayer);
 
   tech_name = get_tech_name(pplayer, new_tech);
   notify_player_ex(pplayer, punit->tile, E_HUT_TECH,
@@ -2307,13 +2298,6 @@
   notify_embassies(pplayer, NULL, _("Game: The %s have acquired %s"
                                    " from ancient scrolls of wisdom."),
                   get_nation_name_plural(pplayer->nation), tech_name);
-
-  do_free_cost(pplayer);
-  if (!is_future_tech(new_tech)) {
-    found_new_tech(pplayer, new_tech, FALSE, TRUE, A_NONE);
-  } else {
-    found_new_future_tech(pplayer);
-  }
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#14129) choose_random_tech called on "set" tech, Mateusz Stefek <=