Hi! The following patch fixes an overflow that happened when the ac/wc bonus from holy possession, bless or curse exceeded the signed byte limit. It's done by using short tmp values to check for an overflow, and then limiting the bonus to 127/-128 . Bye Jochen -------------------------- patch ----------------------------- (patch taken in crossfire/server/) Index: spell_effect.c =================================================================== RCS file: /cvsroot/crossfire/crossfire/server/spell_effect.c,v retrieving revision 1.101 diff -u -r1.101 spell_effect.c --- spell_effect.c 3 Mar 2003 05:13:08 -0000 1.101 +++ spell_effect.c 4 Mar 2003 17:44:21 -0000 @@ -1637,8 +1637,25 @@ new_draw_info_format(NDI_UNIQUE, 0, tmp, "%s blessed you mightily!", op->name); } - force->stats.wc += SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); - force->stats.ac += SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); + + short tmp_wc = force->stats.wc + SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); + if(tmp_wc > 127) { + force->stats.wc = 127; + } + else { + // We don't have to check for an overflow at -128, because we increased + // the value. + force->stats.wc = tmp_wc; + } + + short tmp_ac = force->stats.ac + SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); + if(tmp_ac > 127) { + force->stats.ac = 127; + } + else { + force->stats.ac = tmp_ac; + } + break; } case SP_REGENERATION: force->stats.hp = 1 + SP_level_dam_adjust(op, caster,SP_REGENERATION); @@ -1655,8 +1672,22 @@ if(tmp!=op && caster->type==PLAYER) new_draw_info_format(NDI_UNIQUE, 0, caster, "You curse %s!",tmp->name); - force->stats.ac -= SP_level_dam_adjust(op, caster,SP_CURSE); - force->stats.wc -= SP_level_dam_adjust(op, caster,SP_CURSE); + short tmp_wc = force->stats.wc - SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); + if(tmp_wc < -128) { + force->stats.wc = -128; + } + else { + force->stats.wc = tmp_wc; + } + + short tmp_ac = force->stats.ac - SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); + if(tmp_ac < -128) { + force->stats.ac = -128; + } + else { + force->stats.ac = tmp_ac; + } + break; } case SP_BLESS: { object *god = find_god(determine_god(op)); @@ -1681,8 +1712,23 @@ new_draw_info_format(NDI_UNIQUE, 0, op, "You bless %s.", tmp->name); new_draw_info_format(NDI_UNIQUE, 0, tmp, "%s blessed you.", op->name); } - force->stats.wc += SP_level_dam_adjust(op, caster,SP_BLESS); - force->stats.ac += SP_level_dam_adjust(op, caster,SP_BLESS); + + short tmp_wc = force->stats.wc + SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); + if(tmp_wc > 127) { + force->stats.wc = 127; + } + else { + force->stats.wc = tmp_wc; + } + + short tmp_ac = force->stats.ac + SP_level_dam_adjust(op, caster,SP_HOLY_POSSESSION); + if(tmp_ac > 127) { + force->stats.ac = 127; + } + else { + force->stats.ac = tmp_ac; + } + break; } case SP_DARK_VISION: SET_FLAG(force,FLAG_SEE_IN_DARK); @@ -1798,8 +1844,7 @@ force = insert_ob_in_ob(force,tmp); } change_abil(tmp,force); /* Mostly to display any messages */ - fix_player(tmp); /* This takes care of some stuff that change_abil() */ - /* unfortunately is incapable off. */ + /* fix_player() is called from inside change_abil(). */ return 1; } -- Jochen Suckfuell --- http://www.suckfuell.net/jochen/ --- _______________________________________________ crossfire-devel mailing list crossfire-devel at lists.real-time.com https://mailman.real-time.com/mailman/listinfo/crossfire-devel