28 Oct, 2011, arholly wrote in the 1st comment:
Votes: 0
Today I noticed something odd in the player files. It kept adding more and more information in the player files (I noticed this because the Pfiles were bloating).
So, it started like this in the player file.
Email xxxxxxxx@xxxxx.xxx

Econfnum 0

Prof None 0 2 0

Cncpt None
Econfnum 0
Prof None 0 0 0
Cncpt None~

So, then if you logout and log back in, it gives you this.
Email xxxxxxxx@xxxxx.xxx

Econfnum 0

Prof None 0 2 0

Cncpt None

Econfnum 0

Prof None 0 0 0

Cncpt None
Econfnum 0
Prof None 0 0 0
Cncpt None~

So, I looked at the save code for it and it looks like this:
fprintf (fp, "Email %s\n", ch->email_addr );
fprintf (fp, "Econfnum %ld\n", ch->email_lock );

fprintf (fp, "Prof %s %ld %d %d\n",
ch->profession != NULL ? ch->profession : "None",
ch->employer,
ch->pospts,
ch->markup );

fprintf( fp, "Cncpt %s~\nNature %s~\nDemnor %s~\n",
ch->concept,
ch->nature,
ch->demeanor );


But I have no idea why it is doing that. Needless to say, as players login and logout, it creates rather large pfiles.

Any thoughts?

Arholly
28 Oct, 2011, Rarva.Riendf wrote in the 2nd comment:
Votes: 0
Either you do not run the code you showed, or check the values you have in ch->concept, I think it may not be defined, thus repeating a bufffer.
29 Oct, 2011, Tyche wrote in the 3rd comment:
Votes: 0
arholly said:
Any thoughts?


Clearly that code didn't create the file.
It's likely that it hasn't been compiled and linked into the current executing code.
29 Oct, 2011, Runter wrote in the 4th comment:
Votes: 0
It may be possible that because you're missing ~ to delimit strings and that's causing too much to be read and loaded to variables unintended. Then saved back again, and it only seems phantom fields are happening here. That's my best guess, anyways.
29 Oct, 2011, Vatiken wrote in the 5th comment:
Votes: 0
From a quick look, I'd guess that Runter is correct. You are missing the delimiter on the email string which would then cause fread_string() to end that string right after "Cncpt None", which seems to be the loop.
29 Oct, 2011, arholly wrote in the 6th comment:
Votes: 0
OK, that seemed to fix it. Thanks everyone for the help. That's a big help.

Now, let me ask the ancillary question. Is there an easy way to clear the bloat from the pfiles or is it best to do it manually?

Big thank you to everyone for all your help.

OH, but let me ask a programming question that is related. Do you only add the ~ when the string is the only thing on the line? So, obviously email is the only thing on that line, so it get's the tilde at the end. But what about things like this:
fprintf (fp, "Prof %s %ld %d %d\n",

Where a string is part of a line?
29 Oct, 2011, Vatiken wrote in the 7th comment:
Votes: 0
If the affected pfiles are few, then it would probably be a time saver to just do it by hand. If it's more then a feasible amount then you might want to look at writing a function to rip out the bloat.

The '~' signifies the end of the string. This is used by file reading functions like fread_string() which capture all data in a file including non-printable characters like '\n'. For this reason, we need to provide some sort of indicator to tell fread_string() to stop reading, which in this case we use '~'. Without the '~' fread_string() will keep reading until it hits the end of the file, or as in your case, till it finds the next applicable '~'.

Fread_number() for example though, will stop once it detects a character that isn't a number, thus we don't need to use a delimiter, we can just use a space or a '\n' new line.

In your:
fprintf (fp, "Prof %s %ld %d %d\n",

example, I suspect you are using something like fread_line() which will grab every character in the file until it hits '\n', which again, removes the need for '~'. In that example I assume you are probably using sscanf() after fread_line() to parse the string into the appropriate variables. Which would look something like:
sscanf(line, "Prof %s %ld %d %d\n", &string_variable, &long_variable, &int_variable_one, &int_variable_two);
0.0/7