// Realms of Aurealis Utility File // Author: James Rhone 1/23/97 // 9/17/97 - set quest_pts = 0 // 1/18/98 - reorder PLR2 flags // 5/04/98 - unaffect everybody... // check player file for out of range affections and eliminate them // also update player passwords and re encrypt them #include "structures.h" #include "utils.h" #define NUM_SPELLS 256 // depending on the defines below... this is whatll be done // #define _QUESTFIX_ 1 // #define _GOLDFIX_ 1 // #define _PWORDCHANGE_ 1 // #define _PLR2FLAGFIX_ 1 #define _AFFFIX_ 1 char *crypt(char * a, char *b); int main(int argc, char **argv) { struct char_file_u od; FILE *infp, *outfp; int n, j; int i; infp = fopen("../lib/misc/players", "rb"); outfp = fopen("../lib/misc/players.new", "wb"); if (infp == NULL || outfp == NULL) { fprintf(stderr, "Could not open files.\n"); exit(1); } n = 0; while (!feof(infp)) { if (fread(&od, sizeof(od), 1, infp) != 1) break; #ifdef _AFFFIX_ // do affect checks and corrections if necessary for (i = 0; i < MAX_AFFECT; i++) { if (od.affected[i].type > NUM_SPELLS) { printf("%s illegal affect detected and removed.\n",od.name); for (j = 0; j < MAX_AFFECT; j++) { od.affected[j].type = 0; od.affected[j].duration = 0; od.affected[j].modifier = 0; od.affected[j].location = 0; od.affected[j].bitvector = 0; od.affected[j].bitvector2 = 0; od.affected[j].next = 0; } break; } } #endif #ifdef _QUESTFIX_ od.saved.quest_pts = 0; #endif #ifdef _GOLDFIX_ od.points.bank_gold -= (int)(od.points.bank_gold * 0.90); od.points.bank_gold -= (int)(od.points.bank_gold * 0.50); od.points.gold -= (int)(od.points.gold * 0.90); od.points.gold -= (int)(od.points.gold * 0.50); #endif #ifdef _PWORDCHANGE_ // ONE time only hopefully, re encrypt passwords, remove old flag if (od.saved.changed_password ) { printf("%s password changed from %s to ",od.name,od.pwd); strncpy(od.pwd, (char *) crypt(od.pwd, od.pwd), MAX_PWD_LENGTH); od.pwd[MAX_PWD_LENGTH] = '\0'; printf("%s\n",od.pwd); od.saved.changed_password = 0; } #endif #ifdef _PLR2FLAGFIX_ // reorder some PLR2 flags around... if (IS_SET(od.saved.plr2_flags, PLR2_MADEPT)) SET_BIT(od.saved.plr2_flags, PLR2_CLAN_ASS); if (IS_SET(od.saved.plr2_flags, PLR2_DRUID)) SET_BIT(od.saved.plr2_flags, PLR2_IPP); if (IS_SET(od.saved.plr2_flags, (1 << 11))) SET_BIT(od.saved.plr2_flags, PLR2_MENTOR); // now remove the 1st REMOVE_BIT(od.saved.plr2_flags, PLR2_MADEPT | PLR2_DRUID | (1 << 11)); #endif fwrite(&od, sizeof(od), 1, outfp); n++; } // cleanup fclose(infp); fclose(outfp); printf("../lib/misc/players.new created.\n"); printf("%d players checked and updated.\n", n); return 1; }