openlvc / disco

Java library for Distributed Interactive Simulation
11 stars 3 forks source link

Add check for EmitterBeam length > 255 to be compliant with DIS 7 spec. #59

Closed timpokorny closed 1 year ago

timpokorny commented 1 year ago

DIS 7 Spec (7.6.2 paragraph f.5.i) says that for an emitter beam, if the length of the beam is greater than 255, write it as 0.

I checked that the length for this record isn't being used anywhere in deserialization (we go by the number of records, which is also written to the record in the PDU), so this shouldn't have an advserse impact.

michaelrfraser commented 1 year ago

Hey Tim, I’m still not sure that fix is 100% standard compliant (it looks like it never was). The standard talks about the Beam Data Length field being

However from what I can see our code is treating it as

So line 143 needs to be changed from:

int beamLength = getByteLength();

to

int beamDataLength = beamData.getByteLength() / 4; // Size of the beam data in 32-bit words

timpokorny commented 1 year ago

@michaelrfraser - I concur. I have updated the encoding for both this instance, in EmitterBeam, and for the same problem in EmitterSystem. Updated in commit https://github.com/openlvc/disco/commit/9de56e9b72b7eddcf580f619249cc6d2e4985f0f