Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] Re: (PR#4786) bitvector for tech tree
Home

[Freeciv-Dev] Re: (PR#4786) bitvector for tech tree

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#4786) bitvector for tech tree
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 7 Aug 2003 20:26:22 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Jason Short wrote:
> pplayer->research.inventions[tech].required_techs should be a BV 
> bitvector rather than a manual one.

And the patch.

jason

Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.102
diff -u -r1.102 player.h
--- common/player.h     2003/08/04 15:42:47     1.102
+++ common/player.h     2003/08/08 03:25:18
@@ -63,6 +63,8 @@
   int luxury;
 };
 
+BV_DEFINE(tech_vector, A_LAST);
+
 struct player_research {
   int bulbs_researched;   /* # bulbs reseached for the current tech */    
   int techs_researched;   /* # techs the player has researched/acquired */
@@ -87,7 +89,7 @@
      * cached values. Updated from build_required_techs (which is
      * called by update_research).
      */
-    unsigned char required_techs[(A_LAST + 7) / 8];
+    tech_vector required_techs;
     int num_required_techs, bulbs_required;
   } inventions[A_LAST];
 
Index: common/tech.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/tech.c,v
retrieving revision 1.67
diff -u -r1.67 tech.c
--- common/tech.c       2003/07/21 01:43:52     1.67
+++ common/tech.c       2003/08/08 03:25:18
@@ -81,8 +81,7 @@
   if (tech == goal) {
     return FALSE;
   } else {
-    return TEST_BIT(pplayer->research.inventions[goal].
-                   required_techs[tech / 8], tech % 8);
+    return BV_ISSET(pplayer->research.inventions[goal].required_techs, tech);
   }
 }
 
@@ -103,8 +102,7 @@
   }
 
   /* Mark the tech as required for the goal */
-  pplayer->research.inventions[goal].required_techs[tech / 8] |=
-      (1 << (tech % 8));
+  BV_SET(pplayer->research.inventions[goal].required_techs, tech);
 
   if (advances[tech].req[0] == goal || advances[tech].req[1] == goal) {
     freelog(LOG_FATAL, _("tech \"%s\": requires itself"),
@@ -124,8 +122,7 @@
 {
   int counter;
 
-  memset(pplayer->research.inventions[goal].required_techs, 0,
-        sizeof(pplayer->research.inventions[goal].required_techs));
+  BV_CLR_ALL(pplayer->research.inventions[goal].required_techs);
 
   if (get_invention(pplayer, goal) == TECH_KNOWN) {
     pplayer->research.inventions[goal].num_required_techs = 0;

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