Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Issues with mob index/snippet

Issues with mob index/snippet

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #15 on Sun 03 Sep 2006 05:54 AM (UTC)
Message
Well it's worked fine every other time. This has been the only crash so far. Reproducing it might be hard.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #16 on Sun 03 Sep 2006 06:18 AM (UTC)
Message
If you have the core file, which I suspect you have to be able to answer those questions, you can still do 'info local'.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #17 on Sun 03 Sep 2006 06:51 PM (UTC)
Message
Oh right, I tried that already. Got something odd.

(gdb) f 0
#0  0x081ac1c9 in generate_quest (ch=0x96e2f20, questman=0x9456f38)
    at quest.c:596
596                 if ( level_diff < 15
(gdb) info locals
victim = Variable "victim" is not available.


I don't think victim has anything to do with that code.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #18 on Sun 03 Sep 2006 09:24 PM (UTC)
Message
Yes, that sort of confirms the stack is corrupted. As your function randomly picks a MOB I suspect that one of them is causing it.

One approach is to change the random choice to a sequence number passed down as an argument (from 99 to 6000 judging by your code), and then make a small function that repeatedly calls it, noting somewhere what one it is up to. Then when it crashes you will see which mob causes it.

Then step through it with that mob chosen.

As described on my page for gdb debugging, you could even script a simple loop like that in gdb itself.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #19 on Sun 03 Sep 2006 09:37 PM (UTC)

Amended on Sun 03 Sep 2006 09:46 PM (UTC) by Zeno

Message
Well I can find out what mob it is by printing vsearch->vnum, but how would that help? Do you think it would crash everytime with that mob?

[EDIT] Okay, I can reproduce it on the same mob. What does that mean? What's wrong with the mob?

Stepping through:
(gdb) next
588             if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
(gdb) p vsearch
$1 = (MOB_INDEX_DATA *) 0xa03b4c0
(gdb) p vsearch->vnum
$2 = 0
(gdb) p mob_vnum
No symbol "mob_vnum" in current context.
(gdb) list
583          for (mcounter = 0; mcounter < 99999; mcounter ++)
584            {
585             //mob_vnum = number_range(99, 6000);
586             mob_vnum = 2110;
587
588             if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
589             {
590                 level_diff = vsearch->level - ch->level;
591
592                     /* Level differences to search for. Moongate has 350


Er, mob_vnum has issues now?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #20 on Sun 03 Sep 2006 09:58 PM (UTC)
Message
Looks like vsearch is wrong, try stepping into the get_mob_index(mob_vnum) code with that vnum.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #21 on Sun 03 Sep 2006 10:11 PM (UTC)

Amended on Sun 03 Sep 2006 10:14 PM (UTC) by Zeno

Message
What am I looking for when I step into the function?

Breakpoint 1, generate_quest (ch=0x9852dd0, questman=0x97d44c0) at quest.c:567
567     {
(gdb) list
562         send_to_char("Job decline - Declines your current job.\n\r",ch);
563         return;
564     }
565
566     void generate_quest(CHAR_DATA *ch, CHAR_DATA *questman)
567     {
568         CHAR_DATA *victim;
569         MOB_INDEX_DATA *vsearch;
570         ROOM_INDEX_DATA *room;
571         OBJ_DATA *questitem;
(gdb) step
588             if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
(gdb) list
583          for (mcounter = 0; mcounter < 99999; mcounter ++)
584            {
585             //mob_vnum = number_range(99, 6000);
586             mob_vnum = 2110;
587
588             if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
589             {
590                 level_diff = vsearch->level - ch->level;
591
592                     /* Level differences to search for. Moongate has 350
(gdb) p mob_vnum
No symbol "mob_vnum" in current context.
(gdb) step
get_mob_index (vnum=2110) at db.c:3212
3212    {
(gdb) info locals
pMobIndex = Variable "pMobIndex" is not available.
(gdb) step
3218        for ( pMobIndex  = mob_index_hash[vnum % MAX_KEY_HASH];
(gdb) info locals
pMobIndex = Variable "pMobIndex" is not available.
(gdb) step
3219              pMobIndex;
(gdb) info locals
pMobIndex = (MOB_INDEX_DATA *) 0x985d9b0
(gdb) step
3221            if ( pMobIndex->vnum == vnum )
(gdb) info locals
pMobIndex = (MOB_INDEX_DATA *) 0x985d9b0
(gdb) p pMobIndex->vnum
$1 = 2110
(gdb) step
3228    }
(gdb) info locals
pMobIndex = Variable "pMobIndex" is not available.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #22 on Sun 03 Sep 2006 11:52 PM (UTC)
Message
In my code I have this:


 if( pMobIndex->vnum == vnum )
         return pMobIndex;


I didn't see the "return pMobIndex;" in your stepping. Since the vnum was correct we should be back at line 589.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #23 on Mon 04 Sep 2006 12:20 AM (UTC)
Message
This is what I have:
MOB_INDEX_DATA *get_mob_index( int vnum )
{
    MOB_INDEX_DATA *pMobIndex;

    if ( vnum < 0 )
      vnum = 0;

    for ( pMobIndex  = mob_index_hash[vnum % MAX_KEY_HASH];
          pMobIndex;
          pMobIndex  = pMobIndex->next )
        if ( pMobIndex->vnum == vnum )
            return pMobIndex;

    if ( fBootDb )
        bug( "Get_mob_index: bad vnum %d.", vnum );

    return NULL;
}


I'll try stepping through again.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #24 on Mon 04 Sep 2006 02:47 AM (UTC)

Amended on Mon 04 Sep 2006 02:54 AM (UTC) by Zeno

Message
Breakpoint 1, generate_quest (ch=0x9418570, questman=0x9398900) at quest.c:567
567     {
(gdb) list
562         send_to_char("Job decline - Declines your current job.\n\r",ch);
563         return;
564     }
565
566     void generate_quest(CHAR_DATA *ch, CHAR_DATA *questman)
567     {
568         CHAR_DATA *victim;
569         MOB_INDEX_DATA *vsearch;
570         ROOM_INDEX_DATA *room;
571         OBJ_DATA *questitem;
(gdb) info locals
victim = Variable "victim" is not available.
(gdb) step
588             if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
(gdb) info locals
victim = Variable "victim" is not available.
(gdb) step
get_mob_index (vnum=2110) at db.c:3212
3212    {
(gdb) info locals
pMobIndex = Variable "pMobIndex" is not available.
(gdb) step
3218        for ( pMobIndex  = mob_index_hash[vnum % MAX_KEY_HASH];
(gdb) list
3213        MOB_INDEX_DATA *pMobIndex;
3214
3215        if ( vnum < 0 )
3216          vnum = 0;
3217
3218        for ( pMobIndex  = mob_index_hash[vnum % MAX_KEY_HASH];
3219              pMobIndex;
3220              pMobIndex  = pMobIndex->next )
3221            if ( pMobIndex->vnum == vnum )
3222                return pMobIndex;
(gdb) info locals
pMobIndex = Variable "pMobIndex" is not available.
(gdb) step
3219              pMobIndex;
(gdb) list
3214
3215        if ( vnum < 0 )
3216          vnum = 0;
3217
3218        for ( pMobIndex  = mob_index_hash[vnum % MAX_KEY_HASH];
3219              pMobIndex;
3220              pMobIndex  = pMobIndex->next )
3221            if ( pMobIndex->vnum == vnum )
3222                return pMobIndex;
3223
(gdb) info locals
pMobIndex = (MOB_INDEX_DATA *) 0x94335c8
(gdb) step
3221            if ( pMobIndex->vnum == vnum )
(gdb) p vnum
$1 = 2110
(gdb) p pMobIndex->vnum
$2 = 2110
(gdb) step
3228    }
(gdb) list
3223
3224        if ( fBootDb )
3225            bug( "Get_mob_index: bad vnum %d.", vnum );
3226
3227        return NULL;
3228    }
3229
3230
3231
3232    /*
(gdb) p pMobIndex
Variable "pMobIndex" is not available.
(gdb) info locals
pMobIndex = Variable "pMobIndex" is not available.
(gdb) step
generate_quest (ch=0x9418570, questman=0x9398900) at quest.c:597
597                 if ( level_diff < 15
(gdb) info locals
victim = Variable "victim" is not available.
(gdb) list
592                     /* Level differences to search for. Moongate has 350
593                        levels, so you will want to tweak these greater or
594                        less than statements for yourself. - Vassago */
595
596
597                 if ( level_diff < 15
598                     && vsearch->pShop == NULL
599                     && vsearch->rShop == NULL
600                     && !str_cmp(get_area_by_m_vnum(vsearch->vnum)->era, ch->in_room->area->era)
601                     && !xIS_SET(vsearch->act,ACT_PACIFIST)
(gdb) p vsearch
$3 = (MOB_INDEX_DATA *) 0x94335c8
(gdb) p vsearch->level
$4 = 1
(gdb) p vsearch->vnum
$5 = 2110


vsearch looks fine to me.

It looks like it crashes on any prototype mob. Why? I have no idea. It doesn't even get to the proto ifcheck before it crashes.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #25 on Mon 04 Sep 2006 05:03 AM (UTC)
Message
All I can suggest is doing this:

p *vsearch


Then see if any values look odd.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #26 on Mon 04 Sep 2006 05:26 AM (UTC)

Amended on Mon 04 Sep 2006 05:27 AM (UTC) by Zeno

Message
(gdb) p *vsearch
$1 = {next = 0x0, next_sort = 0x0, spec_fun = 0, pShop = 0x0, rShop = 0x0, mudprogs = 0x92fb018, progtypes = {bits = {128,
      0, 0, 0}}, player_name = 0x929a348 "Boy", short_descr = 0x92fb008 "A Boy",
  long_descr = 0x929a230 "A young boy is here dancing around\n\r", description = 0x8ea9a80 "", vnum = 2110, count = 1,
  killed = 0, sex = 1, level = 1, act = {bits = {1140850689, 0, 0, 0}}, affected_by = {bits = {4194304, 0, 0, 0}},
  alignment = 0, mobthac0 = 0, ac = 0, hitnodice = 0, hitsizedice = 0, hitplus = 0, damnodice = 0, damsizedice = 0,
  damplus = 0, numattacks = 0, gold = 0, exp = 0, xflags = 0, immune = 0, resistant = 0, susceptible = 0, attacks = {
    bits = {0, 0, 0, 0}}, defenses = {bits = {0, 0, 0, 0}}, speaks = 0, speaking = 0, position = 12, defposition = 12,
  height = 0, weight = 0, race = 0, class = 3, hitroll = 0, damroll = 0, perm_vig = 13, perm_int = 13, perm_wis = 13,
  perm_dex = 13, perm_end = 13, perm_cha = 13, perm_lck = 13, saving_poison_death = 0, saving_wand = 0,
  saving_para_petri = 0, saving_breath = 0, saving_spell_staff = 0, hp_from_gain = 0}


Looks okay to me, I think.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #27 on Mon 04 Sep 2006 05:47 AM (UTC)
Message
I'd like to see the whole generate_quest function. I can't help thinking something is overflowing somewhere in it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #28 on Mon 04 Sep 2006 05:54 AM (UTC)
Message
void generate_quest(CHAR_DATA *ch, CHAR_DATA *questman)
{
    CHAR_DATA *victim;
    MOB_INDEX_DATA *vsearch;
    ROOM_INDEX_DATA *room;
    OBJ_DATA *questitem;
    char buf[MAX_STRING_LENGTH];
    long mcounter;
    int level_diff, mob_vnum;

    /*  Randomly selects a mob from the world mob list. If you don't
        want a mob to be selected, make sure it is immune to summon.
        Or, you could add a new mob flag called ACT_NOQUEST. The mob
        is selected for both mob and obj quests, even tho in the obj
        quest the mob is not used. This is done to assure the level
        of difficulty for the area isn't too great for the player. */

     for (mcounter = 0; mcounter < 99999; mcounter ++)
       {
        mob_vnum = number_range(99, 6000);

        if ( (vsearch = get_mob_index(mob_vnum) ) != NULL )
        {
            level_diff = vsearch->level - ch->level;

                /* Level differences to search for. Moongate has 350
                   levels, so you will want to tweak these greater or
                   less than statements for yourself. - Vassago */


            if ( level_diff < 15
                && vsearch->pShop == NULL
                && vsearch->rShop == NULL
                && !str_cmp(get_area_by_m_vnum(vsearch->vnum)->era, ch->in_room->area->era)
                && !xIS_SET(vsearch->act,ACT_PACIFIST)
                && !xIS_SET(vsearch->act,ACT_NOTARGET)
                && !xIS_SET(vsearch->act,ACT_PET)
                && !xIS_SET(vsearch->act,ACT_TRAIN)
                && !xIS_SET(vsearch->act,ACT_PRACTICE)
                && !xIS_SET(vsearch->act,ACT_PROTOTYPE)
                && !xIS_SET(vsearch->act,ACT_IMMORTAL)) break;
                else vsearch = NULL;
        }
    }

    if ( vsearch == NULL || ( victim = get_mob_by_vnum( vsearch->vnum )) == NULL || !IS_NPC(victim))
    {
        sprintf(buf, "%s Sorry, but I don't have any jobs for you right now.", ch->name);
        do_say_to_char(questman, buf);
        sprintf(buf, "%s Try again later.", ch->name);
        do_say_to_char(questman, buf);
        ch->nextquest = 5;
        ch->questmob = 0;
        ch->quest_mob = NULL;
        ch->quest_item = NULL;
        ch->questobj = 0;
        return;
    }

    if ( ( room = victim->in_room ) == NULL )
    {
        sprintf(buf, "%s Sorry, but I don't have any jobs for you right now.", ch->name);
        do_say_to_char(questman, buf);
        sprintf(buf, "%s Try again later.", ch->name);
        do_say_to_char(questman, buf);
        ch->nextquest = 5;
        ch->questmob = 0;
        ch->quest_mob = NULL;
        ch->quest_item = NULL;
        ch->questobj = 0;
        return;
    }

That's the loop and a little more. If you need the rest, let me know.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #29 on Mon 04 Sep 2006 09:16 PM (UTC)
Message
I can't see the problem, but as you can reproduce it, it must be a case of using gdb to narrow down the block of code that leads up to the corrupted variables.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


85,553 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.