[Races]Variable length records?

From: Wyatt Bode (bode@juncol.juniata.edu)
Date: 01/08/97


Hello all,
I have found a little-used (at least by me :->) C device known as a
"union" that may be able to help me out.  Unfortunatly, my C book
doesn't specify how unions are input/output to binary files.  Anyone
know what the procedure is?  Am I doing things the wrong way?  Here's a
snippet of code as an example:

(from structs.h)
struct garou_exp {
	sh_int  temp_glory;
	sh_int  glory;
	sh_int  temp_honor;
	sh_int  honor;
	sh_int  temp_wisdom;
	sh_int  wisdom;
	
	sh_int  exp;
};

struct vampire_exp {
	sh_int	temp_status;
	sh_int	status;
	
	sh_int	exp;
};

...other stuff cut out...

struct char_point_data {
   sh_int will;
   sh_int max_will;     /* Max willpower for PC/NPC                */
   sh_int hit;
   sh_int max_hit;      /* Max hit for PC/NPC                      */
   sh_int move;
   sh_int max_move;     /* Max move for PC/NPC                     */

   sh_int armor;        /* Internal -100..100, external -10..10 AC */

   int  gold;           /* Money carried                           */
   int  bank_gold;      /* Gold the char has in a bank account     */
   union exp_stuff {
   	 struct garou_exp garou;
   	 struct vampire_exp vampire;
   } exp;		/* The experience of the player            */

   sbyte hitroll;       /* Any bonus or penalty to the hit roll    */
   sbyte damroll;       /* Any bonus or penalty to the damage roll */
};

Am I on the right track?  This is my first attempt with unions, and I'm
kinda clueless...  Thanks in advance!
					-- Wyatt Bode
+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST