The Watermelon wrote:


On 2/10/07, *Gerard Krol* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Hi all,

    As some of you may know, power required and hit points of droid parts
    are stored in central arrays. Individual body types are an index into
    this array and are used like this:
    (asBodyStats + psTemplate->asParts[COMP_BODY])->buildPower

    The code in intSetTemplatePowerShadowStats and
    intSetTemplateBodyShadowStats did store a pointer in this index by
    using
    the difference with the asBodyStats address, so that after this
    addition
    the correct address would magically reappear. Guilty code looks
    like this:

    compTempl.asParts[COMP_BODY] = (BODY_STATS *)psStats - asBodyStats;

    Funny thing is: on 64bit: sizeof(SDWORD) < sizeof(void*)

    In the attached patch, the calls to calcTemplatePower and
    calcTemplateBody were removed, and the (simple) formula's used for
    calculation were directly included in the two modified functions.

    - Gerard

I think that kind of stuff is everywhere in the source,at least I saw multiple instances of 'weapId = psStats - asWeaponStats' or 'psStats = asWeaponStats + weaponId'.
In most of the case psStats points to an member of the array asWeaponStats. In that case weaponId is a small integer (0 to about a max of 40) and the code is correct.

The bug is by the way exposed if you design a new droid, put a system on it (sensor for example) and then hover your mouse over another system (like the construction unit). The game then segfaults.

- Gerard

_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev

Reply via email to