Keeping skills during remort

Posted by Rash on Tue 04 Nov 2003 10:40 AM — 6 posts, 22,339 views.

United Kingdom #0
I have just installed remort to my mud, and im wondering how to get the players to keep the skills and spells they have accuried so far... i.e. keep word of recall from been a mage then remorting to warrior... and still have it.
Normally you lose them... i dont want this to happen... any ideas? iv tried myself and i cant figure it out.
Thankx

Rash
United Kingdom #1
Okay ill show the code before the problem...

Inside remort.c in do_remort()
i have:
ch->pcdata->mclass[0] = oldch->class;
if( ch->pcdata->tier == 2 )
ch->pcdata->mclass[1] = ch->class;
else
ch->pcdata->mclass[1] = oldch->class;
if( ch->pcdata->tier == 3 )
ch->pcdata->mclass[2] = ch->class;
else
ch->pcdata->mclass[2] = oldch->class;

Inside comm.c in function nanny()
after:
    case CON_READ_MOTD:
	{
	  char motdbuf[MAX_STRING_LENGTH];

	  sprintf( motdbuf, "\n\rWelcome to %s...\n\r", sysdata.mud_name);
	  write_to_buffer( d, motdbuf, 0 );
	}
	add_char( ch );
	d->connected	= CON_PLAYING;


I have:
if( ch->pcdata->mclass[0] == NULL )
{
ch->pcdata->mclass[0] = ch->class;
ch->pcdata->mclass[1] = -1;
ch->pcdata->mclass[2] = -1;
}

in name_stamp_stats( ch );
after

set_title( ch, buf );


i have:

            ch->pcdata->mclass[0] = ch->class;
  	    ch->pcdata->mclass[1] = -1;
	    ch->pcdata->mclass[2] = -1;


Inside save.c in fwrite_char()under:


    fprintf( fp, "Class        %d\n",	ch->class		);

I have this...

fprintf( fp, "mclass       %d %d %d\n", ch->pcdata->mclass[0]?ch->pcdata->mclass[0]: -1, ch->pcdata->mclass[1]?ch->pcdata->mclass[1]:-1, ch->pcdata->mclass[2]?ch->pcdata->mclass[2]:-1 );


and in fread_char() under case 'M'
i have:

            if ( !strcmp( word, "mclass" ) )
	    {
                ch->pcdata->mclass[0] = fread_number( fp );
	        ch->pcdata->mclass[1] = fread_number( fp );
	        ch->pcdata->mclass[2] = fread_number( fp );
	    }


What im trying to do is get remort to write to a pc_data struc (which iv made in mud.h allready) when your first make a character with 'mclass <current class> -1 -1'

then when your remort the first time change it to
'mclass <first class> <current class> -1'

then the final remort change it to:
'mclass <first class> <second class> <current class>'

that way i can get do_practice to read mclass instead of class and that should then display all the practices that can be used by those THREE classes (if you can help with any of this let me know please!)

btw the following comes back with when u remort


[*****] BUG: Fread_char: no match: Mclass
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: Mclass
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1


and again when you login:


[*****] BUG: Fread_char: no match: Mclass
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: Mclass
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1
[*****] BUG: Fread_char: no match: -1


Any help would be really really great!!!!

Rash
USA #2
Don't know about your remort stuff, but you certainly need to add in fMatch = true in your fread_char routines. That tells it that it found a match - just look at the other routines.

Also note that it seems to expect the first letter to be capitalized. You may want to save it as Mclass %d %d %d instead of mclass %d %d %d.
United Kingdom #3
it saves the pfile with no bugs now... but it still wont read it right... keep em coming thankx btw... half way there... im still getting the reading the pfile bug...
anyway keep the ideas coming thankx!!!!
USA #4
Try this for reading it (modeled after my Addiction section):


            if ( !str_cmp( word, "Mclass" ) )
            {
                line = fread_line( fp );
                x0=x1=x2=0;
                sscanf( line, "%d %d %d", &x0, &x1, &x2 );
                ch->pcdata->mclass[0] = x0;
	        ch->pcdata->mclass[1] = x1;
	        ch->pcdata->mclass[2] = x2;
                fMatch = TRUE;
                break;
            }


Hope that helps. Also, this assumes you change the m to a capital like Ksilyan suggested.

Good luck.
Amended on Wed 05 Nov 2003 11:38 PM by Nick Cash
USA #5
Actually, here's a completely random fact, but useful to know:

strcmp is the library version of string comparison. It is case sensitive.
str_cmp is the SMAUG version of the string comparison. It is case insensitive.

This, for example, is a very good example of why it's important to name your functions correctly. The SMAUG team should have called their function str_icmp or something to that effect, to make it obvious that it is doing a case insensitive comparison.

So, str_cmp(word, "HAHAHA") is equivalent to str_cmp(word, "hAhaHa"), but strcmp of the same arguments is not equivalent.

Anyways, that's just a random fact, and most people can probably ignore that... but it might be useful to some, or at least explain some behavior that you weren't expecting.