[CF-Devel] Suspicious code in server/skills.c

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Fri Apr 23 07:21:35 CDT 2004


In server/skills.c is a suspicious calculation:

    throw_ob->stats.wc = 25-dex_bonus[op->stats.Dex?dex_bonus[op->stats.Dex]:0]-thaco_bonus[eff_str]-skill->level;

Essentially it calculates:

    dex_bonus[dex_bonus[Dex]]

This can't be correct because

 1. dex_bonus[] contains some negative values so it may access
    dex_bonus[-1]

 2. dex_bonus[1] == -3 so "Dex ? dex_bonus[Dex] : 0" is not a
    sensible (monotonic increasing) function

 3. dex_bonus maps "Dex" into "Wc" so "dex_bonus[Wc]" is incorrect


A possible solution could be

    throw_ob->stats.wc = 25-dex_bonus[op->stats.Dex]-thaco_bonus[eff_str]-skill->level;

Is this the intended behavior?

_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list