diff --git a/NetworkSync.cpp b/NetworkSync.cpp index 76f6943..3fa7dcb 100644 --- a/NetworkSync.cpp +++ b/NetworkSync.cpp @@ -9,8 +9,8 @@ void NetworkSync::SendVector3(unsigned char *data, unsigned int &startIndex, const Vector3 v) { SendSingle100(data, startIndex, v.x); - SendSingle100(data, startIndex += 4, v.y); - SendSingle100(data, startIndex += 8, v.z); + SendSingle100(data, startIndex, v.y); + SendSingle100(data, startIndex, v.z); } void NetworkSync::SendQuaternion(unsigned char *data, const int startIndex, @@ -19,7 +19,7 @@ void NetworkSync::SendQuaternion(unsigned char *data, const int startIndex, int ix = startIndex; SendAngle(data, ix++, angles.x); SendAngle(data, ix++, angles.y); - SendAngle(data, ix, angles.z); + SendAngle(data, ix++, angles.z); } void NetworkSync::SendQuat32(unsigned char *data, int startIndex, @@ -46,7 +46,7 @@ void NetworkSync::SendAngle(unsigned char *data, const int startIndex, data[startIndex] = packedAngle.GetValue(); } -void NetworkSync::SendSingle100(unsigned char *data, const int startIndex, +void NetworkSync::SendSingle100(unsigned char *data, unsigned int &startIndex, float value) { // Sends a float with truncated 2 decimal precision Int32 intValue = value * 100; @@ -56,10 +56,10 @@ void NetworkSync::SendSingle100(unsigned char *data, const int startIndex, // } } -void NetworkSync::SendInt32(unsigned char *data, const int startIndex, +void NetworkSync::SendInt32(unsigned char *data, unsigned int &startIndex, Int32 value) { for (unsigned char ix = 0; ix < 4; ix++) { - data[startIndex + ix] = ((unsigned char *)&value)[ix]; + data[startIndex++] = ((unsigned char *)&value)[ix]; } } diff --git a/NetworkSync.h b/NetworkSync.h index e7a8fbd..dac812b 100644 --- a/NetworkSync.h +++ b/NetworkSync.h @@ -50,8 +50,9 @@ protected: NetworkPerception *networkPerception; void PublishTrackedObject(SendBuffer sendBuffer, InterestingThing *object); - void SendSingle100(unsigned char *data, const int startIndex, float value); - void SendInt32(unsigned char *data, const int startIndex, Int32 value); + void SendSingle100(unsigned char *data, unsigned int &startIndex, + float value); + void SendInt32(unsigned char *data, unsigned int &startIndex, Int32 value); void SendAngle(unsigned char *data, const int startIndex, float value); void SendVector3(unsigned char *data, unsigned int &startIndex, const Vector3 v);