open-dis / open-dis-cpp

C++ implementation of the IEEE-1278.1 Distributed Interactive Simulation (DIS) application protocol v6 and v7
BSD 2-Clause "Simplified" License
90 stars 65 forks source link

DIS7. StartResumePDU, StopFreezePDU: Error in marshal and unmarshal methods #96

Open eTrilles opened 6 months ago

eTrilles commented 6 months ago

Hi.

The following methods:

virtual void marshal(DataStream& dataStream) const;
virtual void unmarshal(DataStream& dataStream);

In both classes: StartResumePdu and StopFreezePdu for DIS7, are processing twice the fields OriginatingEntityID and ReceivingEntityID.

The correct implementation for these methods should be something like this:

void StopFreezePdu::marshal(DataStream& dataStream) const
{
    SimulationManagementFamilyPdu::marshal(dataStream); // Marshal information in superclass first
    _realWorldTime.marshal(dataStream);
    dataStream << _reason;
    dataStream << _frozenBehavior;
    dataStream << _padding1;
    dataStream << _requestID;
}

void StopFreezePdu::unmarshal(DataStream& dataStream)
{
    SimulationManagementFamilyPdu::unmarshal(dataStream); // unmarshal information in superclass first
    _realWorldTime.unmarshal(dataStream);
    dataStream >> _reason;
    dataStream >> _frozenBehavior;
    dataStream >> _padding1;
    dataStream >> _requestID;
}

Also, these attributes:

/** Identifier for originating entity(or simulation) */
EntityID _originatingID; 

/** Identifier for the receiving entity(or simulation) */
EntityID _receivingID; 

Are not needed as they are already found in the parent class SimulationManagementFamilyPdu. Removing these duplicated attributes affect several other methods of both classes.

leif81 commented 5 months ago

Thanks @eTrilles . Would you like to submit a pull request for the proposed change?