I can't seem to figure out this issue. When Dispel Magic is cast on myself (no chance of failure) it dispels 4 of 5 of the spells. It always dispels all but one spell. I put an log_string() to list every spell that it finds in the loop and it finds all but the last one every time. Then the second cast works and gets the last one. The problem is that the loop shouldn't be skipping the last spell.
Another strange issue is that if I don't test for IS_VALID, it will list something like 650+ spells even though the character has less than 5.
This is the main part of the code from spell_dispel_magic. It takes the affects one by one and (with no chance of failure because ch == victim) it dispels each spell that is found within affects. Affects are loaded from the player file or is on them just after cast (checked both times).
Another strange issue is that if I don't test for IS_VALID, it will list something like 650+ spells even though the character has less than 5.
This is the main part of the code from spell_dispel_magic. It takes the affects one by one and (with no chance of failure because ch == victim) it dispels each spell that is found within affects. Affects are loaded from the player file or is on them just after cast (checked both times).
for ( paf = victim->affected; paf != NULL; paf = paf_next )
{
paf_next = paf->next;
if ( paf->where != TO_AFFECTS )
continue;
if ( !IS_VALID(paf) )
continue;
found = true;
// Self casting is what's being tested so it will always go to ELSE
if ( perform_save(victim,STAT_INT,16) && victim != ch )
{
strcpy( buf, skill_table[paf->type].name );
strcat( buf, " was not {Rdispelled{x\n\r" );
send_to_char( buf, victim );
fail = TRUE;
}
else
{
strcpy( buf, skill_table[paf->type].name );
strcat( buf, " was {Gdispelled{x\n\r" );
send_to_char(buf, victim);
affect_strip(victim,paf->type);
success = TRUE;
}
}