Hmm well,
Next question!! I've more or less adapted what SWR had, just to get a feel for what it was doing but now I have a more important question!
Now that I have a character obtaining a skill for the first time after being taught, how do I make that save over a hotboot/reboot/etc?
Right now the mud goes down in the next pulse after I use the teach command. Looks something like this:
Program received signal SIGSEGV, Segmentation fault.
0x080eb2a3 in violence_update () at fight.c:387
387 ch->desc->character->desc = ch->desc;
(gdb) bt
#0 0x080eb2a3 in violence_update () at fight.c:387
#1 0x0818f042 in update_handler () at update.c:2025
#2 0x080c77f9 in game_loop () at comm.c:675
#3 0x080c6d16 in main (argc=2, argv=0xbffffc94) at comm.c:308
#4 0x4003f177 in __libc_start_main (main=0x80c6904 <main>, argc=2, ubp_av=0xbffffc94, init=0x80490dc <_init>, fini=0x8197030 <_fini>,
rtld_fini=0x4000e184 <_dl_fini>, stack_end=0xbffffc8c) at ../sysdeps/generic/libc-start.c:129
(gdb) frame 0
#0 0x080eb2a3 in violence_update () at fight.c:387
387 ch->desc->character->desc = ch->desc;
(gdb) frame 2
#2 0x080c77f9 in game_loop () at comm.c:675
675 update_handler( );
(gdb) frame 3
#3 0x080c6d16 in main (argc=2, argv=0xbffffc94) at comm.c:308
308 game_loop( );
(gdb) frame 4
#4 0x4003f177 in __libc_start_main (main=0x80c6904 <main>, argc=2, ubp_av=0xbffffc94, init=0x80490dc <_init>, fini=0x8197030 <_fini>,
rtld_fini=0x4000e184 <_dl_fini>, stack_end=0xbffffc8c) at ../sysdeps/generic/libc-start.c:129
129 ../sysdeps/generic/libc-start.c: No such file or directory.
in ../sysdeps/generic/libc-start.c
The code I used looks like this:
void do_teach (CHAR_DATA *ch, char *argument)
{
char arg[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
int sn;
if ( IS_NPC(ch) )
return;
argument = one_argument(argument, arg);
if ( argument[0] == '\0' )
{
send_to_char("\n\r", ch);
send_to_char("&wSyntax: teach &w<&Cpupil&w> &w<&Cskill&w>\n\r", ch);
return;
}
else
{
CHAR_DATA *victim;
int adept;
if ( !IS_AWAKE(ch) )
{
send_to_char( "You plan on teaching that while sleeping?\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "Your imaginary friend thanks you for the lessons", ch );
return;
}
sn = skill_lookup( argument );
if ( sn == -1 )
{
act( AT_TELL, "You fail in teaching what you do not know.", victim, NULL, ch, TO_VICT );
return;
}
if ( is_name( skill_tname[skill_table[sn]->type], CANT_PRAC ) )
{
act( AT_TELL, "You are unable to teach that skill.", victim, NULL, ch, TO_VICT );
return;
}
adept = 5;
if ( victim->pcdata->learned[sn] >= adept )
{
act( AT_TELL, "$n must learn on their own.", victim, NULL, ch, TO_VICT );
return;
}
if ( ch->pcdata->learned[sn] < 5 )
{
act( AT_TELL, "You must learn more before teaching others.", victim, NULL, ch, TO_VICT );
return;
}
else
{
victim->pcdata->learned[sn] += int_app[get_curr_int(ch)].learn;
sprintf( buf, "You teach %s &Y$T.&D", victim->name );
act( AT_ACTION, buf,
ch, NULL, skill_table[sn]->name, TO_CHAR );
sprintf( buf, "%s teaches you &Y$T&D.", ch->name );
act( AT_ACTION, buf, victim, NULL, skill_table[sn]->name, TO_CHAR );
}
}
return;
}
|