open-dis / opendis7-source-generator

Project to generate a type-safe Java implementation of the DIS Protocol version 7, IEEE 1278.1-2012 and SISO-REF-010 Enumerations specifications.
Other
5 stars 10 forks source link

Java doesn't have unsigned shorts, bitmasks occur instead #14

Open austinarrowsmith opened 3 years ago

austinarrowsmith commented 3 years ago

I think there might be an issue with some of the fields being read out / unmarshaled using .readShort(), as this results in high end shorts (>32k) being negative. This could cause a few issues with lookups of enumerations - if they were populated that high.

So far in various simulation tools, I've encountered issues with ElectronicEmitterPdu, EntityStatePdu and the classes used within (EntityID, etc) but I'm sure any part of the standard that references 2-bytes needs to be unsigned, so probably stored internally as an int that's masked (0xFFFF). Some are, but some aren't. Unsure on the lack of uniformity.

Raising this for further discussion on resolution or my use-case. :-)

terry-norbraten commented 11 months ago

@austinarrowsmith, looking through the EntityID and EE PDU classes, I'm seeing the proper masking during unmarshalling (& 0xFFFF) occurring for unsignedShorts in the src. Do you have another a specific reference in the src for where this is not occurring?