I've written a bank account code for my mud.  The bank account system
works fine, but the problem is in writing and reading the bank info from
the pfile.  The bank account info is written to the pfile fine, but when a
character tries to log in after quitting out (or after creating
initially), it says the password is invalid.  I know the password is not
invalid, so I figure the problem is with reading the pfile, probably due
to something buggy in fread_char or fwrite_char.  Here's what I have done.

(The things I've added have a '+' before them...)
in  void fwrite_char (CHAR_DATA * ch, FILE * fp), I added

    if (ch->gold > 0)
        fprintf (fp, "Gold %ld\n", ch->gold);
    else
        fprintf (fp, "Gold %d\n", 0);
    if (ch->silver > 0)
        fprintf (fp, "Silv %ld\n", ch->silver);
    else
        fprintf (fp, "Silv %d\n", 0);
+    if (ch->bank > 0)
+      fprintf (fp, "Bank %ld\n", ch->bank);
+    else
+      fprintf (fp, "Bank %d\n", 0);

'bank' is one long int.  I set it up so that only gold can be deposited
(no silver).

Then, in   void fread_char (CHAR_DATA * ch, FILE * fp),

        case 'B':
          KEY ("Bamfin", ch->pcdata->bamfin, fread_string (fp));
          KEY ("Bamfout", ch->pcdata->bamfout, fread_string (fp));
          KEY ("Bin", ch->pcdata->bamfin, fread_string (fp));
          KEY ("Bout", ch->pcdata->bamfout, fread_string (fp));
+         KEY ("Bank", ch->bank, fread_number(fp));


I've tried deleting the line in the pfile that contains the bank
information, and the pfile will load fine after that. (No password error)

I don't have a lot of experience with how ROM reads the pfiles in, so I am
kind of lost here.  Any help would be appreciated.

Thanks.


Reply via email to