[CODE] struct char_file_u mismatch

From: Michael Gesner (dabion@wpi.edu)
Date: 07/22/01


In an attempt to write an website which uses player passwords and usernames
which match with the MUD, I am parsing the playerfile (instead of making a
passwd file).  In doing so, I've determined the char_file_u size to be 1292
(in our case).  However, the following utility code, used to derive the
width of each field ends up resulting with 1285.

Utility Code:

int main(){

   int size = 0;

   printf("Structure Data\n\n");

   printf("Name: %d\n", MAX_NAME_LENGTH+1);

   size+= (MAX_NAME_LENGTH+1);

   printf("Desc: %d\n", EXDSCR_LENGTH);

   size += EXDSCR_LENGTH;

   printf("Title: %d\n", MAX_TITLE_LENGTH+1);

   size += (MAX_TITLE_LENGTH+1);

   printf("Sex: %d\n", sizeof(byte));

   size += sizeof(byte);

   printf("Level: %d\n", sizeof(byte));

   size += sizeof(byte);

   printf("Hometown: %d\n", sizeof(sh_int));

   size += sizeof(sh_int);

   printf("Birth: %d\n", sizeof(time_t));

   size += sizeof(time_t);

   printf("Played: %d\n", sizeof(int));

   size += sizeof(int);

   printf("Weight: %d\n", sizeof(ubyte));

   size += sizeof(ubyte);

   printf("Height: %d\n", sizeof(ubyte));

   size += sizeof(ubyte);

   printf("Passwd: %d\n", MAX_PWD_LENGTH+1);

   size += (MAX_PWD_LENGTH+1);

   printf("Struct: %d\n", sizeof(struct char_special_data_saved));

   size += sizeof(struct char_special_data_saved);

   printf("Struct: %d\n", sizeof(struct player_special_data_saved));

   size += sizeof(struct player_special_data_saved);

   printf("Struct: %d\n", sizeof(struct char_ability_data));

   size += sizeof(struct char_ability_data);

   printf("Struct: %d\n", sizeof(struct char_point_data));

   size += sizeof(struct char_point_data);

   printf("Struct: %d\n", (sizeof(struct affected_type)*MAX_AFFECT));

   size += (sizeof(struct affected_type)*MAX_AFFECT);

   printf("LastLog: %d\n", sizeof(time_t));

   size += sizeof(time_t);

   printf("Host: %d\n", HOST_LENGTH+1);

   size += (HOST_LENGTH+1);

   printf("Size: %d\n", size);
   printf("Actual: %d\n", sizeof(struct char_file_u));

   return 1;
}

End Utility code:

The utility code also includes sysdep.h, conf.h, and structs.h


This is the reflected structure in structs.h:

struct char_file_u {
   /* char_player_data */
   char name[MAX_NAME_LENGTH+1];
   char description[EXDSCR_LENGTH];
   char title[MAX_TITLE_LENGTH+1];
   byte sex;
   byte level;
   sh_int hometown;
   time_t birth;   /* Time of birth of character     */
   int  played;    /* Number of secs played in total */
   ubyte weight;
   ubyte height;

   char pwd[MAX_PWD_LENGTH+1];    /* character's password */

   struct char_special_data_saved char_specials_saved;
   struct player_special_data_saved player_specials_saved;
   struct char_ability_data abilities;
   struct char_point_data points;
   struct affected_type affected[MAX_AFFECT];

   time_t last_logon;           /* Time (in secs) of last logon */
   char host[HOST_LENGTH+1];    /* host of last logon */
};

End structure code


I have not had the time to truly hammer out the utility code, so it is
very... dirty code.  This is a 5 minute bit of coding... however, due to
the fact that I'd like to get this site up and running... I'd appreciate
any comments on where you believe the 7 bit offset may be.  Yes.. I know
this seems noobish of me... but... frankly, given the 2 hours of sleep I've
gotten... I figure I deserve it ;)

Thanks,

Lodaren of Rhu-Dina'ar
rhudin.newvisiongames.net 7777

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/06/01 PST