Side Mask
Hans Ronne
hronne@pp.sbbs.se
Tue Jul 23 11:32:00 GMT 2002
>Currently, the side mask set operation is defined as:
>
>#define add_side_to_set(side,mask) ((mask) | (1 << ((side) ? (side)->id
>: 0)))
>
>It would seem to be better to define it as:
>
>#define add_side_to_set(side,mask) ((mask) | ((side)?(1 << (side)->id) :
>0)))
>
>since that would not modify the mask if the side pointer is null, where
>the current definition would set the 0'th (or 31st depending on how you
>number the bits) bit if the side mask is null. If the side id can be 0
>(which I haven't dug through the code to find out), side 0 or a null
>poiter would set the same bit. The remove side from mask would need a
>similar correction.
The indepside (which always exists even if it has no units) has side id 0.
All these checks for null side pointers are remnants from the time when
independent units did not have a side at all. So you had to check if a unit
had a side before dereferencing it. This is no longer so, every unit has a
side. So I don't think the problem with a null side being passed to this
macro would ever occur. But I will check to make sure.
Hans
Hans Ronne
hronne@pp.sbbs.se
More information about the Xconq7
mailing list