mcgredonps / open-dis

Javascript implementation of IEEE-1278.1, Distributed Interactive Simulation protocol, widely used in military simulations
BSD 2-Clause "Simplified" License
6 stars 1 forks source link

Variable Datums Handled Incorrectly #2

Open Mendanbar opened 9 years ago

Mendanbar commented 9 years ago

This has been an issue in at least the JAVA incarnation of open-dis, and maybe others. The variable datum is handled as if it is a fixed datum with length 8, which ends up ignoring any data beyond the first 8 characters.

in dis.VariableDatum, the code reads as follows:

this.variableData = new Array(0, 0, 0, 0, 0, 0, 0, 0);

  dis.VariableDatum.prototype.initFromBinaryDIS = function(inputStream)
  {

       this.variableDatumID = inputStream.readInt();
       this.variableDatumLength = inputStream.readInt();
       for(var idx = 0; idx < 8; idx++)
       {
          this.variableData[ idx ] = inputStream.readByte();
       }
  };

I believe it should be like this (at least this works for my project anyway, which makes heavy use of variable datums):

this.variableData = new Array();

  dis.VariableDatum.prototype.initFromBinaryDIS = function(inputStream)
  {

       this.variableDatumID = inputStream.readInt();
       this.variableDatumLength = inputStream.readInt();
       for (var idx = 0; idx < (this.variableDatumLength / 8); idx++) {
           this.variableData.push(inputStream.readByte());
       }
  };
mcgredonps commented 8 years ago

Thanks, I should be getting to this soon. I think the Java version has patches applied to it post-generation to fix the issue.