All that I have done to group_lookup() is added the if (name ==
NULL)  statement towards the beginning, hoping that would keep it from
returning funky values. I've marked lines I've added with '+', and lines
I've changed with '!'.


/* returns a group index number given the name */
int group_lookup( const char *name )
{
    int gn;

!    if (name == NULL)
!       return -1;

    for ( gn = 0; gn < MAX_GROUP; gn++ )
    {
        if ( group_table[gn].name == NULL )
            break;
        if ( LOWER(name[0]) == LOWER(group_table[gn].name[0])
        &&   !str_prefix( name, group_table[gn].name ) )
            return gn;
    }

    return -1;
}

        The same thing with skill_lookup():

int skill_lookup( const char *name )
{
    int sn;

!    if (name == NULL)
!       return -1;

    for ( sn = 0; sn < MAX_SKILL; sn++ )
    {
        if ( skill_table[sn].name == NULL )
            break;
        if ( LOWER(name[0]) == LOWER(skill_table[sn].name[0])
        &&   !str_prefix( name, skill_table[sn].name ) )
            return sn;
    }

    return -1;
}


        I also modified the section in save.c that gn_add is being called
from:

if ( !str_cmp( word, "Group" )  || !str_cmp(word,"Gr"))
            {
!                int gn = -1;
!                char *temp = NULL;

                temp = fread_word( fp ) ;
                gn = group_lookup(temp);
                logf("group: %s - gn: %d", temp, gn);
                //gn    = group_lookup( fread_word( fp ) );
!                if ( gn < 0 || gn >= (MAX_GROUP - 1) )
                {
                    fprintf(stderr,"%s",temp);
                    bug("Fread_char: unknown group.",0);
                }
                else
                    gn_add(ch,gn);
                fMatch = TRUE;

...


        I've also modified gn_add slightly:

/* recursively adds a group given its number -- uses group_add */
void gn_add( CHAR_DATA *ch, int gn)
{
    int i;

+    if (gn < 0 || gn >= (MAX_GROUP - 1))
+        return;

    ch->pcdata->group_known[gn] = TRUE;
    for ( i = 0; i < MAX_IN_GROUP; i++)
    {
        if (group_table[gn].spells[i] == NULL)
            break;
        group_add(ch,group_table[gn].spells[i],FALSE);
    }
}

        With these changes I am at least able to boot, though when I try
to list my spells or skills, I get:

No skills found. or No spells found.

        However, when I use practice, it shows my spells and skills
properly.


        MAX_GROUP seems to be defined properly:

(gdb) print MAX_GROUP
$1 = 34

        MAX_SKILL seems to be defined properly:

(gdb) print MAX_SKILL
$3 = 161

        However, when I try loading a character, group 33 tries to load
over and over:

Breakpoint 1, gn_add (ch=0x404065ec, gn=33) at skills.c:968
968         if (gn < 0 || gn >= (MAX_GROUP - 1))
(gdb) c
Continuing.

Breakpoint 1, gn_add (ch=0x404065ec, gn=33) at skills.c:968
968         if (gn < 0 || gn >= (MAX_GROUP - 1))
(gdb) c
Continuing.

Breakpoint 1, gn_add (ch=0x404065ec, gn=33) at skills.c:968
968         if (gn < 0 || gn >= (MAX_GROUP - 1))
(gdb) c
Continuing.

Breakpoint 1, gn_add (ch=0x404065ec, gn=33) at skills.c:968
968         if (gn < 0 || gn >= (MAX_GROUP - 1))
(gdb)

(gdb) print group_table[33].name
$2 = 0x8122b30 ""

        This group is the last entry, which is a NULL entry. Perhaps I
should tell gn_add() to return if gn is < 0 || >= (MAX_GROUP - 2)? instead
of just -1?

        My group_table and race_table seem to be ok:

(gdb) print group_table[0].name
$4 = 0x4007162e "rom basics"
(gdb) print group_table[1].name
$5 = 0x40071645 "mage basics"
(gdb) print group_table[2].name
$6 = 0x40071655 "cleric basics"
(gdb) print group_table[3].name
$7 = 0x40071667 "thief basics"
...
(gdb) print group_table[32].name
$8 = 0x4006ff34 "weather"

(gdb) print race_table[0].name
$9 = 0x4006f457 "unique"
(gdb) print race_table[1].name
$10 = 0x4006f47f "human"
(gdb) print race_table[2].name
$11 = 0x4006f49e "elf"
(gdb) print race_table[3].name
$12 = 0x4006f4b9 "dwarf"
(gdb) print race_table[4].name
$13 = 0x4006f4cd "giant"
(gdb) print race_table[5].name
$14 = 0x4006f4eb "dragon"
...
(gdb) print race_table[20].name
$15 = 0x4006f5e7 "fido"
...
(gdb) print race_table[30].name
$16 = 0x4006f64c "school monster"
...
(gdb) print race_table[35].name
$18 = 0x4006f68d "water fowl"
...
(gdb) print race_table[38].name
$19 = 0x4006f457 "unique"
(gdb) print race_table[39].name
$20 = 0x0

        It looks like ch->pcdata->group_known isn't getting set quite
right...

(gdb) print ch->pcdata->group_known[0]
$21 = 1 '\001'
(gdb) print ch->pcdata->group_known[1]
$22 = 0 '\0'
(gdb) print ch->pcdata->group_known[2]
$23 = 0 '\0'

        At this point, at least 3 or 4 groups should have been loaded...

Fri Oct 25 08:28:14 2002 :: group:  - gn: 33
Fri Oct 25 08:28:14 2002 :: [*****] BUG: Fread_char: unknown group.

        I added the following lines in new_pcdata():

    for ( sn = 0; sn < MAX_SKILL; sn++ )
        pcdata->learned[sn] = 0;

    for ( gn = 0; gn < MAX_GROUP; gn++ )
        pcdata->group_known[gn] = FALSE;

        Might this be causing a problem?

        Ryan

On Thu, 24 Oct 2002 [EMAIL PROTECTED] wrote:

> Well, without your group_lookup function, I can't say for any certainty,
> but I am willing to bet that you forgot the hook to load your group table
> information, or at least, the MAX_GROUP isn't being initialized properly...
> Since it is a global it /should/ default to 0. The gn isn't even a number I
> could say 'it is just rolling over' since it isn't MAX_INT or such.
>
> Why don't you give us a complete rundown? print things such as MAX_GROUP,
> ch->pcdata->group_known, group_table, race_table, and a thorough
> walkthrough?
>
> Ammaross Danan
>
> >
> >     It looks like group_lookup() is returning a bad gn.
> >
> > Breakpoint 1, gn_add (ch=0x404065ec, gn=0) at skills.c:968
> > 968         ch->pcdata->group_known[gn] = TRUE;
> > (gdb) c
> > Continuing.
> >
> > Breakpoint 1, gn_add (ch=0x404065ec, gn=135421864) at skills.c:968 968
> >        ch->pcdata->group_known[gn] = TRUE;
> > (gdb)
> >
> >     Any ideas why this might be happening?
> >
> >     Ryan
> >
> > --
> > [EMAIL PROTECTED]
> > HELO... my name is root... you have SIGKILLed my father... prepare to
> > vi!
> >
> >     Hi! Can you to speak to me the learn for to speak the Unix?
> >
> > On Thu, 24 Oct 2002 [EMAIL PROTECTED] wrote:
> >
> >>
> >> > #1  0x080be696 in gn_add (ch=0x4040647c, gn=135448576) at
> >> > skills.c:970 #2  0x080be813 in group_add (ch=0x4040647c,
> >> >    name=0x21 <Address 0x21 out of bounds>, deduct=0 '\0') at
> >> > skills.c:1024
> >>
> >> It would help if you actually passed good information to group_add().
> >> Use GDB for more than a backtrace and see if your race_table actually
> >> has something in it. Particularly race_table[ch->race].skills[]
> >>
> >> Ammaross Danan
> >>
> >>
> >>
> >>
> >
> >
> > --
> > ROM mailing list
> > [email protected]
> > http://www.rom.org/cgi-bin/mailman/listinfo/rom
>
>
>
>
>



Reply via email to