/* ************************************************************************ * file: plrconv.c Part of CircleMUD * * Usage: Convert the player file By Gekke Eekhoorn, 4/95 * * All Rights Reserved * * Copyright (C) 1992, 1993 The Trustees of The Johns Hopkins University * ************************************************************************* */ #include #include #include #include "../structs.h" /* Insert your new structs here */ struct player_special_data_saved2 { byte skills[MAX_SKILLS+1]; /* array of skills plus skill 0 */ byte spells_to_learn; /* How many can you learn yet this level*/ bool talks[MAX_TONGUE]; /* PC s Tongues 0 for NPC */ int wimp_level; /* Below this # of hit points, flee! */ byte freeze_level; /* Level of god who froze char, if any */ sh_int invis_level; /* level of invisibility */ room_num load_room; /* Which room to place char in */ long pref; /* preference flags for PC's. */ ubyte bad_pws; /* number of bad password attemps */ sbyte conditions[3]; /* Drunk, full, thirsty */ }; struct t1 { char name[MAX_NAME_LENGTH+1]; char description[EXDSCR_LENGTH]; char title[MAX_TITLE_LENGTH+1]; byte sex; byte class; }; struct t2 { byte level; sh_int hometown; time_t birth; /* Time of birth of character */ int played; /* Number of secs played in total */ }; struct t3 { /* password */ char pwd[MAX_PWD_LENGTH+1]; struct char_special_data_saved char_specials_saved; }; struct t4 { 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 */ }; struct char_file_u2 { /* char_player_data */ struct t1 tmp1; byte race; struct t2 tmp2; sh_int weight; sh_int height; struct t3 tmp3; struct player_special_data_saved2 player_specials_saved; struct t4 tmp4; }; void convert(char *filename) { FILE * fl; FILE * outfile; struct char_file_u oldpl; struct char_file_u2 newpl; if (!(fl = fopen(filename, "r+"))) { printf("Can't open %s.", filename); exit(); } outfile = fopen("players.new", "w"); printf("Converting.\n"); for (; ; ) { fread(&oldpl, sizeof(struct char_file_u), 1, fl); if (feof(fl)) { fclose(fl); fclose(outfile); puts("Done."); exit(); } /* Here, the conversion takes place. */ /* The memcpys are for not having to type the lot :] */ memcpy(&newpl.tmp1, oldpl.name, sizeof(struct t1)); memcpy(&newpl.tmp2, &oldpl.level, sizeof(struct t2)); memcpy(&newpl.tmp3, oldpl.pwd, sizeof(struct t3)); memcpy(&newpl.tmp4, &oldpl.abilities, sizeof(struct t4)); /* Move race to char_data */ newpl.race=oldpl.player_specials_saved.race; /* Convert them to sh_int */ newpl.weight=oldpl.weight; newpl.height=oldpl.height; /* Here, I cut all the unnecessary junk away */ memcpy(&newpl.player_specials_saved, &oldpl.player_specials_saved, sizeof(struct player_special_data_saved)); /* And here we write it */ fwrite(&newpl, sizeof(struct char_file_u2 ), 1, outfile); } } void main(int argc, char *argv[]) { if (argc != 2) printf("Usage: %s playerfile-name\n", argv[0]); else convert(argv[1]); }