Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2005:
[Freeciv-Dev] (PR#13366) get_invention and A_FUTURE
Home

[Freeciv-Dev] (PR#13366) get_invention and A_FUTURE

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13366) get_invention and A_FUTURE
From: "Mateusz Stefek" <mstefek@xxxxxxxxx>
Date: Tue, 28 Jun 2005 14:16:14 -0700
Reply-to: bugs@xxxxxxxxxxx

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

> [mstefek - Tue Jun 28 21:15:14 2005]:
> S2_0 version.
> Assertion is of course not as strict as for HEAD
> --
> mateusz 
> 
> 

Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.76.2.6
diff -u -r1.76.2.6 tech.c
--- common/tech.c       31 Mar 2005 17:37:58 -0000      1.76.2.6
+++ common/tech.c       28 Jun 2005 21:11:46 -0000
@@ -52,7 +52,7 @@
 enum tech_state get_invention(const struct player *pplayer,
                              Tech_Type_id tech)
 {
-  assert(tech >= 0 || tech < game.num_tech_types);
+  assert(tech >= 0);
 
   return pplayer->research.inventions[tech].state;
 }
@@ -186,12 +186,18 @@
 }
 
 /**************************************************************************
-  Marks reachable techs. Calls build_required_techs to update the
-  cache of requirements.
+  Mark as TECH_REACHABLE each tech which is available, not known and
+  which has all requirements fullfiled.
+  If there is no such a tech mark A_FUTURE as researchable.
+  
+  Recalculate research->num_known_tech_with_flag
+  Should be called always after set_invention()
+
 **************************************************************************/
 void update_research(struct player *pplayer)
 {
   enum tech_flag_id flag;
+  int researchable = 0;
 
   tech_type_iterate(i) {
     if (i == A_NONE) {
@@ -209,11 +215,18 @@
          && get_invention(pplayer, advances[i].req[0]) == TECH_KNOWN
          && get_invention(pplayer, advances[i].req[1]) == TECH_KNOWN) {
        set_invention(pplayer, i, TECH_REACHABLE);
+       researchable++;
       }
     }
     build_required_techs(pplayer, i);
   } tech_type_iterate_end;
 
+  /* No techs we can research? Mark A_FUTURE as researchable */
+  if (researchable == 0) {
+    set_invention(pplayer, A_FUTURE, TECH_REACHABLE);
+  }
+
+
   for (flag = 0; flag < TF_LAST; flag++) {
     pplayer->research.num_known_tech_with_flag[flag] = 0;
 

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