Devilution: NetSendCmdLoc & NetSendCmdParam1

Created on 16 Dec 2018  路  2Comments  路  Source: diasurgical/devilution

The properties of TCmdLoc & TCmdParam1 appears shifted:
billede
Possibly something to do with the struct packing?

Minimal differences

Most helpful comment

Interesting, I've noticed this only seems to be a problem when the data in question is exactly 3 bytes and the compiler aligns it to 4. Where as instances of 5-7 don't seem to have this problem. I wonder if they had some kind of pragma or compiler setting that only aligns data >= 4 bytes.

All 2 comments

Since it's again alignment on stack, adding __declspec(align(1)) fixes both and in this case it could also be written before struct definition which probably makes more sense than writing it for locals. However confusing part is that it is done only for several structs and not for all of them, doing it for some of the others breaks binary exactness for some other functions.

Also packing is orthogonal to alignment, so packing e.g. for TCmdParam1 is still needed.

Interesting, I've noticed this only seems to be a problem when the data in question is exactly 3 bytes and the compiler aligns it to 4. Where as instances of 5-7 don't seem to have this problem. I wonder if they had some kind of pragma or compiler setting that only aligns data >= 4 bytes.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AJenbo picture AJenbo  路  8Comments

AJenbo picture AJenbo  路  7Comments

maristane picture maristane  路  3Comments

AJenbo picture AJenbo  路  8Comments

AJenbo picture AJenbo  路  4Comments