Christoph Mallon wrote:
> Holger Rapp wrote:
>
>> Heya,
>>
>> i have a strange bug here, everytime i start a game, my HQ burns
>> already (that's not good though ;)
>> i traced the bug down and i'm pretty sure it has to do with the
>> snippet from field.h containing union Owner_Info.
>>
>> short gdb session:
>>
>> (gdb) set owner_info.parts.owner_number = 0
>> (gdb) print owner_info
>> $7 = {
>> all = 0 '\0',
>> parts = {
>> owner_number = 0 '\0',
>> is_border = false
>> }
>> }
>> (gdb) set owner_info.parts.owner_number = 1
>> (gdb) print owner_info
>> $8 = {
>> all = 2 '\002',
>> parts = {
>> owner_number = 1 '\001',
>> is_border = false
>> }
>> }
>>
>> the code seem to depend that all is owner_number + is_border, but
>> sizeof(parts) == 4 on my system (ppc mac os x).
>>
> Somebody tried to be clever and "microptimised" *sigh*
>
> Try changing src/field.h:102
> - bool is_border : 1;
> + uchar is_border : 1;
> and tell us if it helps.
>
If this helps, there should be an assert(sizeof(Owner_Info) == 1)
somewhere, so that this kind of error is detected immediately if it
breaks on some platform. From the gdb session it looks more like a bit
order problem though. Binary 10 = Decimal 2, while Binary 10 = Decimal 1
on my system. If this is the case, just swapping the order of is_border
and owner_number could perhaps help you.
|