Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] (PR#5100) player vectors should be BV vectors
Home

[Freeciv-Dev] (PR#5100) player vectors should be BV vectors

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#5100) player vectors should be BV vectors
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Aug 2003 20:41:54 -0700
Reply-to: rt@xxxxxxxxxxxxxx

pplayer->embassy, pplayer->gives_shared_vision and 
pplayer->really_gives_vision should all be of type Player_Vector.

   BV_DEFINE(Player_Vector, MAX_NUM_PLAYERS);

Unfortunately these values aren't just used internally: they're put over 
the network and into the savegame.  This makes things ugly.  Things 
could be made less ugly if we had secfile_[insert|lookup]_bv() and 
dio_[put|get]_bv functions for accessing this data.  Unfortunately to do 
right this would take more macro magic.

The current code assumes MAX_NUM_PLAYERS <= 32.  It may assume 
MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS <= 32.  But this assumption 
(although known to everyone) isn't made particularly clear.  In 
particular, if you redefine MAX_NUM_PLAYERS as a higher value, Freeciv 
will happily compile (but won't work properly, obviously).  Something 
like the attached patch may help with this (so that Freeciv won't 
compile if MAX_NUM_PLAYERS is too large).

jason

? rc
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.105
diff -u -r1.105 player.h
--- common/player.h     2003/08/14 19:07:01     1.105
+++ common/player.h     2003/08/15 03:36:17
@@ -184,7 +184,7 @@
   bool got_tech;
   int revolution;
   bool capital; /* used to give player capital in first city. */
-  int embassy;
+  unsigned int embassy : MAX_TOTAL_PLAYERS;
   int reputation;
   struct player_diplstate diplstates[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
   int city_style;
@@ -202,8 +202,12 @@
   struct conn_list connections;               /* will replace conn */
   struct worklist worklists[MAX_NUM_WORKLISTS];
   struct player_tile *private_map;
-  unsigned int gives_shared_vision; /* bitvector those that give you shared 
vision */
-  unsigned int really_gives_vision; /* takes into account that p3 may see what 
p1 has via p2 */
+
+  /* These bitvectors track whether the player is being given shared vision.
+   * really_gives_vision takes into account transitivity. */
+  unsigned int gives_shared_vision : MAX_TOTAL_PLAYERS;
+  unsigned int really_gives_vision : MAX_TOTAL_PLAYERS;
+
   Impr_Status improvements[B_LAST]; /* improvements with equiv_range==Player */
   Impr_Status *island_improv; /* improvements with equiv_range==Island, 
dimensioned to
                                 [map.num_continents][game.num_impr_types] */
Index: common/shared.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/shared.h,v
retrieving revision 1.116
diff -u -r1.116 shared.h
--- common/shared.h     2003/08/15 02:39:59     1.116
+++ common/shared.h     2003/08/15 03:36:17
@@ -57,6 +57,7 @@
 
 #define MAX_NUM_PLAYERS  30
 #define MAX_NUM_BARBARIANS   2
+#define MAX_TOTAL_PLAYERS (MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS)
 #define MAX_NUM_ITEMS   200    /* eg, unit_types */
 #define MAX_NUM_TECH_LIST 10
 #define MAX_LEN_NAME     32

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#5100) player vectors should be BV vectors, Jason Short <=