Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Bing, DotBot, Yandex

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » Bug in do_sset and a suggeste...
Forum Rules | Mark all | Recent Posts

Bug in do_sset and a suggested update in the GET_ADEPT macro
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Oct 6, 2013, 4:58 pm
Go to the top of the page
Go to the bottom of the page

Sadiq
Fledgling
GroupMembers
Posts24
JoinedJan 7, 2010

So I was poking around in do_sset, in skills.c and found something that didn't seem quite right. If you scroll down through the function past the part where it is all about setting up a new skill and get to the part that is about setting a PC's skill level, you'll find this little chunk of code:

   if( fAll )
   {
      for( sn = 0; sn < num_skills; ++sn )
      {
         /*
          * Fix by Narn to prevent ssetting skills the player shouldn't have. 
          */
         if( victim->level >= skill_table[sn]->skill_level[victim->Class]
             || victim->level >= skill_table[sn]->race_level[victim->race] )
         {
            if( value == 100 && !IS_IMMORTAL( victim ) )
               victim->pcdata->learned[sn] = GET_ADEPT( victim, sn );
            else
               victim->pcdata->learned[sn] = value;
         }
      }
   }


It's that "value==100" comparison that got me. I went ahead and compiled a stock version of smaugfuss 1.9 and made a new character and advanced him to level 50 to get a robust practice list, and then issed the following command, with the admin imm: "sset newbie all 99" (less than 100). Sure enough, 'Newbie' got ALL of his skills and spells set to 99 - even those that were supposed to be adept for his class (I arbitrarily chose thief) at far less than 99. In order to make the code do what I believe Narn originally intended, I made the following change:


   if( fAll )
   {
      for( sn = 0; sn < num_skills; ++sn )
      {
         /*
          * Fix by Narn to prevent ssetting skills the player shouldn't have. 
          */
         if( victim->level >= skill_table[sn]->skill_level[victim->Class]
             || victim->level >= skill_table[sn]->race_level[victim->race] )
         {
            /* Another fix here, to prevent player from getting a skill level raised
                to more than adept value (but less than 100) */
            if( value > GET_ADEPT( victim, sn ) && !IS_IMMORTAL( victim ) )
               victim->pcdata->learned[sn] = GET_ADEPT( victim, sn );
            else
               victim->pcdata->learned[sn] = value;
         }
      }
   }



Messing around with this led me to another little discovery - that being if you try to implement new code that tries to use the GET_ADEPT macro on an imm that has had the 'sset all' command used on him (any level...doesn't matter) you are going to crash your mud because the macro will try to get the adept level of skills that aren't assigned to the imm's class. What I did, is change this:


#define GET_ADEPT(ch,sn)    (  skill_table[(sn)]->skill_adept[(ch)->Class])



to this:


#define GET_ADEPT(ch,sn)   (  IS_IMMORTAL(ch) ? 100 : skill_table[(sn)]->skill_adept[(ch)->Class])



Others can check all that to keep me honest, but I think it is all correct - ymmv

Sadiq
       
Post is unread #2 Oct 6, 2013, 5:13 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

nice catch. It looks like I had changed both those things long ago in LoP haha. It shouldn't crash because an Immortal gets to learn all spells and skills at imm level anyways even ones not assigned to any class. Still is a good idea to fix it though.
       
Post is unread #3 Oct 6, 2013, 5:18 pm
Go to the top of the page
Go to the bottom of the page

Sadiq
Fledgling
GroupMembers
Posts24
JoinedJan 7, 2010

Oh, an immortal can get everything, using sset, but if you do so, and then use the GET_ADEPT macro to check the level of a skill that his class normally doesn't have, you'll get a segmentation fault, with the stock code. At least, I did :tongue:
       
Post is unread #4 Oct 6, 2013, 6:22 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

lol something crazy must have been going on with how you were using it etc... If you just used something to display the adept using it, it shouldn't crash. Anyway it goes though personally I suggest doing the change lol
       
Pages:<< prev 1 next >>