03 Oct, 2010, tphegley wrote in the 1st comment:
Votes: 0
I am wanting to add a line to all my pfiles for version control without having to go through and hand editing all files. Just kind of wondering where I'd start and/or a general idea of how to go about it. I think my troubles come from having to open/close the files really.

This wouldn't need to be done in the game persay, but a bash command or something that I could configure and run through the player/letter folders.

Looking for ideas.
03 Oct, 2010, Mudder wrote in the 2nd comment:
Votes: 0
The ROMs solve this problem when the pfiles are loaded.

It identifies the pfile version and updates it there, setting default values for the updated pfile.
03 Oct, 2010, tphegley wrote in the 3rd comment:
Votes: 0
Right. I'm wanting to add that version line to all my pfiles. I'm running Envy and it doesn't use versions.
03 Oct, 2010, Runter wrote in the 4th comment:
Votes: 0
You could always write a perl script to just append a line to each file.
03 Oct, 2010, Mudder wrote in the 5th comment:
Votes: 0
Oh, sorry. I misunderstood the post.

I'm not bash savvy, so I can't say anything there. But I did a quick google and maybe this would help.

Thanks for this though, I should add version numbers myself. :unclesam:
03 Oct, 2010, Mudder wrote in the 6th comment:
Votes: 0
This is how ram did it.

void load_area_file( FILE * fp )
{
char *word = NULL;
int version = 0;

if ( fp == stdin )
{
/*
* We can't fseek here, so assume it's OLD format!
*/
load_rom_area_file( fp );
return;
}

if ( fread_letter( fpArea ) != '#' )
{
proper_exit( MUD_HALT, "Boot_db: # not found." );
}

word = fread_word( fpArea );

if ( str_cmp( word, "VERSION" ) )
{
/*
* If the first line isn't #VERSION, this is an old format file.
*/
rewind( fp );
load_rom_area_file( fp );
return;
}

version = fread_number( fp );
load_ram_area_file( fp, version );
}
03 Oct, 2010, tphegley wrote in the 7th comment:
Votes: 0
Yea, it seems I've made it harder then it should have been. I just added this to save.c in fwrite_char

if ( !ch->version )
fprintf( fp, "Version %d~\n", SAVEVERSION );


and this in fread_char

if ( !ch->version )
KEY ("Version", ch->version, fread_number (fp));


This seems to work.


****EDIT****
then again, this does not work for reading the file. It hangs the mud. Hmm
03 Oct, 2010, Runter wrote in the 8th comment:
Votes: 0
Assume version is zero for any pfile without versioning data. Make sure you initialize version to zero, then after the load process if its still zero no version data was found or it was zero.

Always write version or change the if to

If (ch->version)
03 Oct, 2010, Scandum wrote in the 9th comment:
Votes: 0
Adding a routine to load and unload all player files would fix your problem.
03 Oct, 2010, tphegley wrote in the 10th comment:
Votes: 0
Runter said:
Assume version is zero for any pfile without versioning data. Make sure you initialize version to zero, then after the load process if its still zero no version data was found or it was zero.

Always write version or change the if to

If (ch->version)


I changed this and I'm still getting an error when logging in. I'm hanging the mud. My fread_eol is bugging.

Sun Oct  3 19:15:13 2010 :: [*****] BUG: Version
Program received signal SIGINT, Interrupt.
0xf57fe416 in __kernel_vsyscall ()
(gdb) bt
#0 0xf57fe416 in __kernel_vsyscall ()
#1 0xb7f1b093 in __read_nocancel () from /lib/tls/i686/cmov/libc.so.6
#2 0xb7ec4fbb in _IO_new_file_underflow (fp=0x81bf1b0) at fileops.c:605
#3 0xb7ec684b in _IO_default_uflow (fp=0x81bf1b0) at genops.c:440
#4 0xb7ec7c78 in *__GI___uflow (fp=0x81bf1b0) at genops.c:394
#5 0xb7ebd56c in _IO_getc (fp=0x81bf1b0) at getc.c:41
#6 0x0807ab16 in fread_to_eol (fp=0x81bf1b0) at db.c:3090
#7 0x080a8376 in fread_char (ch=0xb7025d18, fp=0x81bf1b0) at save.c:1111
#8 0x080a9bfc in load_char_obj (d=0xb6c604fc, name=0xb6c60799 "Rao") at save.c:677
#9 0x08075df0 in nanny (d=0xb6c604fc, argument=0xb6c60799 "Rao") at comm.c:2659
#10 0x0807877b in game_loop_unix (control=6) at comm.c:930
#11 0x08078deb in main (argc=1, argv=0x0) at comm.c:527
#6 0x0807ab16 in fread_to_eol (fp=0x81bf1b0) at db.c:3090
3090 c = getc (fp);
(gdb) list
3085 {
3086 char c;
3087
3088 do
3089 {
3090 c = getc (fp);
3091 }
3092 while (c != '\n' && c != '\r');
3093
3094 do
(gdb) frame 7
#7 0x080a8376 in fread_char (ch=0xb7025d18, fp=0x81bf1b0) at save.c:1111
1111 fread_to_eol( fp );
(gdb) list
1106 ch->exp = xp_for_level(ch,ch->level +1)-1;
1107 if ( !fMatch )
1108 {
1109 sprintf(buf,"Fread_char(): no match '%s'",word);
1110 bug( word, 0 );
1111 fread_to_eol( fp );
1112 } // end if
1113 } // end for
1114 } // end proc
1115
(gdb)


Scandum said:
Adding a routine to load and unload all player files would fix your problem.

I think this was my initial question. I need some steps or a push in writing a for loop to open close every file in my player/* folders.
03 Oct, 2010, tphegley wrote in the 11th comment:
Votes: 0
Runter, I tried this:

if ( str_cmp( word, "Version" ) )
{
ch->version = fread_number (fp);
fMatch = TRUE;
break;
}
break;

But that didn't work either. Am I in the right direction of what you were wanting?
04 Oct, 2010, jurdendurden wrote in the 12th comment:
Votes: 0
In save.c, in fread_char, there's a list of things that the mud 'initializes'. You need to initialize the version here. The reason the mud is hanging is because you are putting the "~" after a number. Fread_number doesn't need this, but fread_string does. Once you change this around, you should be good to go.

This:
fprintf( fp, "Version     %d~\n",   SAVEVERSION             );


Should be this:
fprintf( fp, "Version     %d\n",   SAVEVERSION             );
04 Oct, 2010, Runter wrote in the 13th comment:
Votes: 0
Good catch. Seems like freadnumber should have been designed to work with tilde for such cases.
05 Oct, 2010, tphegley wrote in the 14th comment:
Votes: 0
Thanks JurdenDurden, that was it. I got everything else working great.
0.0/14