Problem with memin spells.

Posted by Ithildin on Thu 09 Dec 2004 05:31 AM — 2 posts, 13,139 views.

USA #0
Ok, I got everything working great, but I have one other problem. If I were to make a new spell, and save skill table and reboot, then the sn changes. When a player mem's a spell, he mem's the sn. so when the sn changes on the sort skill table, the player has a different spell memed. I tried not sorting in db.c, but then the spell stays at the end of the slo and you can't find the spell. Here's what I did:

sset create skill aeros
sset save skill table
slo aeros ( aros is slot 273)
<305hp 258m 568mv> 
<   > slo aeros
Sn:  273 Slot:    0 unknown: 'aeros               '
Saves: none  SaveEffect: none
Type: unknown  Target: ignore  Minpos: 0  Mana: 0  Beats: 0  Range: 0
Flags: 0  Guild: -1  Value: 0  Info: 0  Code: spell_smaug
Sectors Allowed: All
Dammsg: 
Wearoff: 
--------------------------[CLASS USE]--------------------------
Mag) lvl: 101 max: 95%  Cle) lvl: 101 max: 95%  Thi) lvl: 101 max: 95%
War) lvl: 101 max: 95%  Pal) lvl: 101 max: 95%  Dru) lvl: 101 max: 95%
Ran) lvl: 101 max: 95%  

<305hp 258m 568mv> 
<   > 
Comm: Sock.sinaddr:  4.225.5.196, port 3117.

<305hp 258m 568mv> 
<   > sset save skill table
Log: Camilla: sset save skill table
Saving skill table...


reboot mud now
slo aeros
<305hp 258m 568mv> 
<   > slo aeros
No such skill, spell, proficiency or tongue.


It's not showing up after it loads skill table. ANy thoughts on what to do?

here is db.c

    log_string("Loading skill table");
    load_skill_table();
//   sort_skill_table();
   remap_slot_numbers();	/* must be after the sort */

    gsn_first_spell  = 0;
    gsn_first_skill  = 0;
    gsn_first_weapon = 0;
    gsn_first_tongue = 0;
    gsn_top_sn	     = top_sn;

    for ( x = 0; x < top_sn; x++ )
	if ( !gsn_first_spell && skill_table[x]->type == SKILL_SPELL )
	    gsn_first_spell = x;
	else
	if ( !gsn_first_skill && skill_table[x]->type == SKILL_SKILL )
	    gsn_first_skill = x;
	else
	if ( !gsn_first_weapon && skill_table[x]->type == SKILL_WEAPON )
	    gsn_first_weapon = x;
	else
	if ( !gsn_first_tongue && skill_table[x]->type == SKILL_TONGUE )
	    gsn_first_tongue = x;




Amended on Thu 09 Dec 2004 05:58 AM by Ithildin
USA #1
Ok, i'm guessing this:


void remap_slot_numbers()
{
    SKILLTYPE *skill;
    SMAUG_AFF *aff;
    char tmp[32];
    int sn;

    log_string( "Remapping slots to sns" );

    for ( sn = 0; sn <= top_sn; sn++ )
    {
	if ( (skill=skill_table[sn]) != NULL )
	{
	    for ( aff = skill->affects; aff; aff = aff->next )
		if ( aff->location == APPLY_WEAPONSPELL
		||   aff->location == APPLY_WEARSPELL
		||   aff->location == APPLY_REMOVESPELL
		||   aff->location == APPLY_STRIPSN
		||   aff->location == APPLY_RECURRINGSPELL )
		{
		    sprintf( tmp, "%d", slot_lookup(atoi(aff->modifier)) );
		    DISPOSE(aff->modifier);
		    aff->modifier = str_dup(tmp);
		}
	}
    }
}


and this:


int skill_lookup2(const char *name, CHAR_DATA * ch)
{
int sn;

    if ( (sn=bsearch_skill_exact(name, gsn_first_spell, gsn_first_skill-1)) == -1 )
      if ( (sn=bsearch_skill_exact(name, gsn_first_skill, gsn_first_weapon-1)) == -1 )
	if ( (sn=bsearch_skill_exact(name, gsn_first_weapon, gsn_first_tongue-1)) == -1 )
	  if ( (sn=bsearch_skill_exact(name, gsn_first_tongue, gsn_top_sn-1)) == -1 )
	    if ( (sn=bsearch_skill_prefix(name, gsn_first_spell, gsn_first_skill-1)) == -1 )
	      if ( (sn=bsearch_skill_prefix(name, gsn_first_skill, gsn_first_weapon-1)) == -1 )
		if ( (sn=bsearch_skill_prefix(name, gsn_first_weapon, gsn_first_tongue-1)) == -1 )
		  if ( (sn=bsearch_skill_prefix(name, gsn_first_tongue, gsn_top_sn-1)) == -1
		  &&    gsn_top_sn < top_sn )
		  {
		      for ( sn = gsn_top_sn; sn < top_sn; sn++ )
		      {
			  if ( !skill_table[sn] || !skill_table[sn]->name )
			    return -1;
			  if ( LOWER(name[0]) == LOWER(skill_table[sn]->name[0])
			  &&  !str_prefix( name, skill_table[sn]->name ) )
			    return sn;
		      }
		      return -1;
		  }
    return sn;
}


I'm sure those are the two things I have to mess with in order to get the mem'd spells to move up a slot when new spells are added and sorted.

Any thoughts? Any thing I can do?