[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  practice/learning/teaching
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: practice/learning/teaching
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 01 Jan 2005 03:33 AM (UTC)  quote  ]
Message
Most likely, since the possess skill no longer exists, gsn_possess contains -1 or whatever value the lookup function returns (let's call it bad_value.) Check in db.c - somewhere in there, it does all the gsn lookups. (The so-called "GSNs" are in fact cached skill lookups.)

At this point, if you're comparing stuff against a bad value, all bets are off. If you want to remove the possess skill, you should truly remove it by taking out all references to it. I would comment out the line that defines the gsn (in mud.h, I believe) and then go to each compile error, and comment out the relevant section.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Sat 01 Jan 2005 03:29 AM (UTC)  quote  ]
Message
Check ch->desc->original, that would seem to be null. If thats the case, you need to find out why that if check is evaluating to true. When you removed it, did you remove all references to possess? Looks like gsn_possess might be doubling up with something else, and this is mistaking the affect type as possess instead of what it really is.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] bio
Date Sat 01 Jan 2005 03:12 AM (UTC)  quote  ]
Message
line 387 of fight.c where it was breaking is a part of this:


                }
                if (paf->type == gsn_possess)
                {
                    ch->desc->character = ch->desc->original;
                    ch->desc->original  = NULL;
                    ch->desc->character->desc = ch->desc;
                    ch->desc->character->switched = NULL;
                    ch->desc            = NULL;
                }


[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sat 01 Jan 2005 02:11 AM (UTC)  quote  ]
Message
You say that the update function refers to the possess skill... could you show me how? It's possible that you're trying to edit a skill that doesn't exist, thereby editing memory that isn't what you think it is, and thereby corrupting something - for instance, a player descriptor.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] bio
Date Sat 01 Jan 2005 12:42 AM (UTC)  quote  ]
Message
Hmm.

I put possess back into the skills table (ie skills.dat) and the crash stopped happening. Now why is this so? I have absolutely zero idea.
[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] bio
Date Sat 01 Jan 2005 12:16 AM (UTC)  quote  ]
Message
Well the violence update refers to the section under gsn_possess. I had taken this skill off the skill table, would that cause this crash?
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Fri 31 Dec 2004 11:49 PM (UTC)  quote  ]
Message
Indeed. That's your problem, but how you got there baffles me. Surely something has changed besides this one function, because the function you showed us doesn't even touch the descriptor structures.

If you haven't already done so, be sure to make clean, then make again.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Fri 31 Dec 2004 11:38 PM (UTC)  quote  ]

Amended on Fri 31 Dec 2004 11:39 PM (UTC) by Nick Cash

Message
Quote:


Program received signal SIGSEGV, Segmentation fault.
0x080eb2a3 in violence_update () at fight.c:387
387 ch->desc->character->desc = ch->desc;


--------
gdb) print ch->desc->character
$3 = (CHAR_DATA *) 0x0

This would make perfect sense. You are trying to access something from a NULL pointer, which quite obviously wont work :P

I'm not quite sure what that has to do with the skills though...

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] bio
Date Fri 31 Dec 2004 11:00 PM (UTC)  quote  ]
Message
Like this?


(gdb) print ch
$1 = (CHAR_DATA *) 0x83fdb38
(gdb) print ch->desc
$2 = (DESCRIPTOR_DATA *) 0x83fbb00
(gdb) print ch->desc->character
$3 = (CHAR_DATA *) 0x0
(gdb) print ch->desc->character->desc
Cannot access memory at address 0x4c
(gdb)


[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Fri 31 Dec 2004 10:35 PM (UTC)  quote  ]
Message
Ksilyan was refering to this:
(gdb) frame 0
#0  0x080eb2a3 in violence_update () at fight.c:387
387     
Print those in your gdb to see what they are and why its crashing at that spot.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] bio
Date Fri 31 Dec 2004 07:35 PM (UTC)  quote  ]
Message
These values?



                }
                if (paf->type == gsn_possess)
                {
                    ch->desc->character = ch->desc->original;
                    ch->desc->original  = NULL;
                    ch->desc->character->desc = ch->desc;
                    ch->desc->character->switched = NULL;
                    ch->desc            = NULL;
                }

[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Fri 31 Dec 2004 04:42 AM (UTC)  quote  ]
Message
Only thing that I can spot offhand would be that that function will wreak havok if called on a non-player victim- after you find the victim character you should make a check with IS_NPC or something. Then again, this would be much more likely to simply segfault than to corrupt data, so it's probably not the problem.

Other than that, you might want to check the values of ch, ch->desc, ch->desc->character and ch->desc->character->desc in the gdb backtrace.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] bio
Date Fri 31 Dec 2004 03:16 AM (UTC)  quote  ]
Message
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;
}



[Go to top] top

Posted by Frobozz   (75 posts)  [Biography] bio
Date Fri 31 Dec 2004 03:04 AM (UTC)  quote  ]
Message
Thanks,

That pretty much showed me what I was doing wrong.
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Fri 31 Dec 2004 02:26 AM (UTC)  quote  ]
Message
I'm not sure about SMAUG, but SWR has a teach command, you could take a look at that.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] 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.


5,654 views.

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

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]