[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]  Segfault in learn_from_success and learn_from_failure
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Segfault in learn_from_success and learn_from_failure

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


Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Fri 27 Jun 2014 06:53 AM (UTC)

Amended on Fri 27 Jun 2014 06:58 AM (UTC) by Robert Powell

Message
I am not sure what is happening here: Namely why adept is in the millions when it should be 95 at most.


Program received signal SIGSEGV, Segmentation fault.
0x00000000005d8ace in learn_from_success (ch=0xc426a0, sn=-1) at skills.c:1835
1835	   adept = GET_ADEPT( ch, sn );
(gdb) list
1830	   
1831	  
1832	
1833	   if( IS_NPC( ch ) || ch->pcdata->learned[sn] <= 0 )
1834	      return;
1835	   adept = GET_ADEPT( ch, sn );
1836	   sklvl = skill_table[sn]->skill_level[ch->Class];
1837	   if( sklvl == 0 )
1838	      sklvl = ch->level;
1839	   if( ch->pcdata->learned[sn] < adept )
(gdb) print adept
$19 = 178727773
(gdb) print ch
$20 = (CHAR_DATA *) 0xc426a0
(gdb) print sn
$21 = -1
(gdb) print sklvl
$22 = 32
(gdb) print ch->level
$23 = 65
(gdb) print ch->pcdata->learned[sn]
$24 = 75
(gdb) 




void learn_from_success( CHAR_DATA * ch, int sn )
{
   int adept, gain, sklvl, learn, percent, schance;
   
  

   if( IS_NPC( ch ) || ch->pcdata->learned[sn] <= 0 )
      return;
   adept = GET_ADEPT( ch, sn );
   sklvl = skill_table[sn]->skill_level[ch->Class];
   if( sklvl == 0 )
      sklvl = ch->level;
   if( ch->pcdata->learned[sn] < adept )
   {
      schance = ch->pcdata->learned[sn] + ( 5 * skill_table[sn]->difficulty );
      percent = number_percent(  );
      if( percent >= schance )
         learn = 2;
      else if( schance - percent > 25 )
         return;
      else
         learn = 1;
      ch->pcdata->learned[sn] = UMIN( adept, ch->pcdata->learned[sn] + learn );
      if( ch->pcdata->learned[sn] == adept ) /* fully learned! */
      {
         gain = 1000 * sklvl;
         
         set_char_color( AT_WHITE, ch );
         ch_printf( ch, "You are now an adept of %s!  You gain %d bonus experience!\r\n", skill_table[sn]->name, gain );
      }
      else
      {
         gain = 100 * sklvl;
         
         if( !ch->fighting && sn != gsn_hide && sn != gsn_sneak )
         {
            set_char_color( AT_WHITE, ch );
            ch_printf( ch, "You gain %d experience points from your success!\r\n", gain );
         }
      }
      gain_exp( ch, gain );
   }
}

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #1 on Fri 27 Jun 2014 02:52 PM (UTC)
Message
I'm not seeing anything there that should be causing any issues. My best guess would be you're getting a bad reference from GET_ADEPT and we probably need to be looking at the code behind that call rather than this function.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #2 on Fri 27 Jun 2014 10:48 PM (UTC)
Message
Meerclar said:

I'm not seeing anything there that should be causing any issues. My best guess would be you're getting a bad reference from GET_ADEPT and we probably need to be looking at the code behind that call rather than this function.


Yeah I did a bit more digging and when i tried to print difficulty, found that its memory was unreachable. Started stepping backwards and found it all came down to a new auto defence skill I added 'Pirouette' much like dodge etc,

ASSIGN_GSN( gsn_pirouette, "pirouette" ); but spelled the skill pirouete in skills.dat :)

One typo cost me a few hours of wondering and stuffing about, now that this is sorted out, I can get back to what I was doing.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] bio
Date Reply #3 on Sat 28 Jun 2014 02:17 AM (UTC)
Message
Sounds like my login script issues earlier in the week - strcmp between lowercase in the first list and uppercase in the second location. I'm sure you know how well that worked out.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #4 on Sat 28 Jun 2014 04:40 AM (UTC)
Message
Meerclar said:

Sounds like my login script issues earlier in the week - strcmp between lowercase in the first list and uppercase in the second location. I'm sure you know how well that worked out.


I bet it worked out dismally and took you hours of debugging to work out why it was all wrong :)

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[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.


3,057 views.

It is now over 60 days since the last post. This thread is closed.     [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.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]