Bug: Spell immunity checks are not working properly
Danger: Medium - Expected immunity may not work, or may report successful even when not set.
Discovered in: AFKMud 1.77
Found by: Matteo2303
Fixed by: Samson
Replace that function with this new one:
bool is_immune( CHAR_DATA *ch, short damtype )
switch( damtype )
case SD_FIRE: return( IS_IMMUNE( ch, RIS_FIRE ) );
case SD_COLD: return( IS_IMMUNE( ch, RIS_COLD ) );
case SD_ELECTRICITY: return( IS_IMMUNE( ch, RIS_ELECTRICITY ) );
case SD_ENERGY: return( IS_IMMUNE( ch, RIS_ENERGY ) );
case SD_ACID: return( IS_IMMUNE( ch, RIS_ACID ) );
case SD_POISON: return( IS_IMMUNE( ch, RIS_POISON ) );
case SD_DRAIN: return( IS_IMMUNE( ch, RIS_DRAIN ) );
The is_immune function checks for the immunity to types of spell damage. It is supposed to return TRUE upon a successul check, and FALSE if not. Apparently the way the original function worked the switch was able to fall through to something else and report a false positive if another immunity was present on the player. It is assumed that this could also have worked the other way. In either case, the above function fixes the issue by returning the direct result of the IS_IMMUNE macro, be it TRUE or FALSE. The above function was adapted from the C++ 2.0 code. In addition to fixing the issue it is also visually easier to follow, and takes up fewer lines.