- more byte order logic

- added new network packet debug
This commit is contained in:
Mark Vejvoda
2012-11-01 22:00:55 +00:00
parent 0d88936680
commit 00e075df97
6 changed files with 503 additions and 290 deletions

View File

@@ -68,14 +68,20 @@ template<typename T> class Vec4;
template<class T>
void toEndianVecArray(T *vec, size_t size) {
for(size_t i = 0; i < size; ++i) {
vec[i].toEndian();
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
for(size_t i = 0; i < size; ++i) {
vec[i].toEndian();
}
}
}
template<class T>
void fromEndianVecArray(T *vec, size_t size) {
for(size_t i = 0; i < size; ++i) {
vec[i].fromEndian();
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
for(size_t i = 0; i < size; ++i) {
vec[i].fromEndian();
}
}
}
@@ -276,12 +282,18 @@ public:
}
void toEndian() {
this->x = Shared::PlatformByteOrder::toCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::toCommonEndian(this->y);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
this->x = Shared::PlatformByteOrder::toCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::toCommonEndian(this->y);
}
}
void fromEndian() {
this->x = Shared::PlatformByteOrder::fromCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::fromCommonEndian(this->y);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
this->x = Shared::PlatformByteOrder::fromCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::fromCommonEndian(this->y);
}
}
};
@@ -524,14 +536,20 @@ public:
}
void toEndian() {
this->x = Shared::PlatformByteOrder::toCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::toCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::toCommonEndian(this->z);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
this->x = Shared::PlatformByteOrder::toCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::toCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::toCommonEndian(this->z);
}
}
void fromEndian() {
this->x = Shared::PlatformByteOrder::fromCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::fromCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::fromCommonEndian(this->z);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
this->x = Shared::PlatformByteOrder::fromCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::fromCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::fromCommonEndian(this->z);
}
}
};
@@ -750,16 +768,22 @@ public:
}
void toEndian() {
this->x = Shared::PlatformByteOrder::toCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::toCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::toCommonEndian(this->z);
this->w = Shared::PlatformByteOrder::toCommonEndian(this->w);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
this->x = Shared::PlatformByteOrder::toCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::toCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::toCommonEndian(this->z);
this->w = Shared::PlatformByteOrder::toCommonEndian(this->w);
}
}
void fromEndian() {
this->x = Shared::PlatformByteOrder::fromCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::fromCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::fromCommonEndian(this->z);
this->w = Shared::PlatformByteOrder::fromCommonEndian(this->w);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
this->x = Shared::PlatformByteOrder::fromCommonEndian(this->x);
this->y = Shared::PlatformByteOrder::fromCommonEndian(this->y);
this->z = Shared::PlatformByteOrder::fromCommonEndian(this->z);
this->w = Shared::PlatformByteOrder::fromCommonEndian(this->w);
}
}
};

View File

@@ -87,6 +87,7 @@ const char *GAME_ARGS[] = {
"--disable-opengl-checks",
"--disable-streflop-checks",
"--debug-network-packets",
"--verbose"
@@ -160,6 +161,8 @@ enum GAME_ARG_TYPE {
GAME_ARG_DISABLE_OPENGL_CAPS_CHECK,
GAME_ARG_DISABLE_STREFLOP_CAPS_CHECK,
GAME_ARG_DEBUG_NETWORK_PACKETS,
GAME_ARG_VERBOSE_MODE,
GAME_ARG_END

View File

@@ -37,123 +37,159 @@ using namespace Util;
// Utils methods for endianness conversion
void toEndianFileHeader(FileHeader &header) {
for(unsigned int i = 0; i < 3; ++i) {
header.id[i] = Shared::PlatformByteOrder::toCommonEndian(header.id[i]);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
for(unsigned int i = 0; i < 3; ++i) {
header.id[i] = Shared::PlatformByteOrder::toCommonEndian(header.id[i]);
}
header.version = Shared::PlatformByteOrder::toCommonEndian(header.version);
}
header.version = Shared::PlatformByteOrder::toCommonEndian(header.version);
}
void fromEndianFileHeader(FileHeader &header) {
for(unsigned int i = 0; i < 3; ++i) {
header.id[i] = Shared::PlatformByteOrder::fromCommonEndian(header.id[i]);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
for(unsigned int i = 0; i < 3; ++i) {
header.id[i] = Shared::PlatformByteOrder::fromCommonEndian(header.id[i]);
}
header.version = Shared::PlatformByteOrder::fromCommonEndian(header.version);
}
header.version = Shared::PlatformByteOrder::fromCommonEndian(header.version);
}
void toEndianModelHeader(ModelHeader &header) {
header.type = Shared::PlatformByteOrder::toCommonEndian(header.type);
header.meshCount = Shared::PlatformByteOrder::toCommonEndian(header.meshCount);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.type = Shared::PlatformByteOrder::toCommonEndian(header.type);
header.meshCount = Shared::PlatformByteOrder::toCommonEndian(header.meshCount);
}
}
void fromEndianModelHeader(ModelHeader &header) {
header.type = Shared::PlatformByteOrder::toCommonEndian(header.type);
header.meshCount = Shared::PlatformByteOrder::toCommonEndian(header.meshCount);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.type = Shared::PlatformByteOrder::toCommonEndian(header.type);
header.meshCount = Shared::PlatformByteOrder::toCommonEndian(header.meshCount);
}
}
void toEndianMeshHeader(MeshHeader &header) {
for(unsigned int i = 0; i < meshNameSize; ++i) {
header.name[i] = Shared::PlatformByteOrder::toCommonEndian(header.name[i]);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
for(unsigned int i = 0; i < meshNameSize; ++i) {
header.name[i] = Shared::PlatformByteOrder::toCommonEndian(header.name[i]);
}
header.frameCount = Shared::PlatformByteOrder::toCommonEndian(header.frameCount);
header.vertexCount = Shared::PlatformByteOrder::toCommonEndian(header.vertexCount);
header.indexCount = Shared::PlatformByteOrder::toCommonEndian(header.indexCount);
for(unsigned int i = 0; i < 3; ++i) {
header.diffuseColor[i] = Shared::PlatformByteOrder::toCommonEndian(header.diffuseColor[i]);
header.specularColor[i] = Shared::PlatformByteOrder::toCommonEndian(header.specularColor[i]);
}
header.specularPower = Shared::PlatformByteOrder::toCommonEndian(header.specularPower);
header.opacity = Shared::PlatformByteOrder::toCommonEndian(header.opacity);
header.properties = Shared::PlatformByteOrder::toCommonEndian(header.properties);
header.textures = Shared::PlatformByteOrder::toCommonEndian(header.textures);
}
header.frameCount = Shared::PlatformByteOrder::toCommonEndian(header.frameCount);
header.vertexCount = Shared::PlatformByteOrder::toCommonEndian(header.vertexCount);
header.indexCount = Shared::PlatformByteOrder::toCommonEndian(header.indexCount);
for(unsigned int i = 0; i < 3; ++i) {
header.diffuseColor[i] = Shared::PlatformByteOrder::toCommonEndian(header.diffuseColor[i]);
header.specularColor[i] = Shared::PlatformByteOrder::toCommonEndian(header.specularColor[i]);
}
header.specularPower = Shared::PlatformByteOrder::toCommonEndian(header.specularPower);
header.opacity = Shared::PlatformByteOrder::toCommonEndian(header.opacity);
header.properties = Shared::PlatformByteOrder::toCommonEndian(header.properties);
header.textures = Shared::PlatformByteOrder::toCommonEndian(header.textures);
}
void fromEndianMeshHeader(MeshHeader &header) {
for(unsigned int i = 0; i < meshNameSize; ++i) {
header.name[i] = Shared::PlatformByteOrder::fromCommonEndian(header.name[i]);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
for(unsigned int i = 0; i < meshNameSize; ++i) {
header.name[i] = Shared::PlatformByteOrder::fromCommonEndian(header.name[i]);
}
header.frameCount = Shared::PlatformByteOrder::fromCommonEndian(header.frameCount);
header.vertexCount = Shared::PlatformByteOrder::fromCommonEndian(header.vertexCount);
header.indexCount = Shared::PlatformByteOrder::fromCommonEndian(header.indexCount);
for(unsigned int i = 0; i < 3; ++i) {
header.diffuseColor[i] = Shared::PlatformByteOrder::fromCommonEndian(header.diffuseColor[i]);
header.specularColor[i] = Shared::PlatformByteOrder::fromCommonEndian(header.specularColor[i]);
}
header.specularPower = Shared::PlatformByteOrder::fromCommonEndian(header.specularPower);
header.opacity = Shared::PlatformByteOrder::fromCommonEndian(header.opacity);
header.properties = Shared::PlatformByteOrder::fromCommonEndian(header.properties);
header.textures = Shared::PlatformByteOrder::fromCommonEndian(header.textures);
}
header.frameCount = Shared::PlatformByteOrder::fromCommonEndian(header.frameCount);
header.vertexCount = Shared::PlatformByteOrder::fromCommonEndian(header.vertexCount);
header.indexCount = Shared::PlatformByteOrder::fromCommonEndian(header.indexCount);
for(unsigned int i = 0; i < 3; ++i) {
header.diffuseColor[i] = Shared::PlatformByteOrder::fromCommonEndian(header.diffuseColor[i]);
header.specularColor[i] = Shared::PlatformByteOrder::fromCommonEndian(header.specularColor[i]);
}
header.specularPower = Shared::PlatformByteOrder::fromCommonEndian(header.specularPower);
header.opacity = Shared::PlatformByteOrder::fromCommonEndian(header.opacity);
header.properties = Shared::PlatformByteOrder::fromCommonEndian(header.properties);
header.textures = Shared::PlatformByteOrder::fromCommonEndian(header.textures);
}
void toEndianModelHeaderV3(ModelHeaderV3 &header) {
header.meshCount = Shared::PlatformByteOrder::toCommonEndian(header.meshCount);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.meshCount = Shared::PlatformByteOrder::toCommonEndian(header.meshCount);
}
}
void fromEndianModelHeaderV3(ModelHeaderV3 &header) {
header.meshCount = Shared::PlatformByteOrder::fromCommonEndian(header.meshCount);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.meshCount = Shared::PlatformByteOrder::fromCommonEndian(header.meshCount);
}
}
void toEndianMeshHeaderV3(MeshHeaderV3 &header) {
header.vertexFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::toCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::toCommonEndian(header.indexCount);
header.properties = Shared::PlatformByteOrder::toCommonEndian(header.properties);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::toCommonEndian(header.texName[i]);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.vertexFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::toCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::toCommonEndian(header.indexCount);
header.properties = Shared::PlatformByteOrder::toCommonEndian(header.properties);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::toCommonEndian(header.texName[i]);
}
}
}
void fromEndianMeshHeaderV3(MeshHeaderV3 &header) {
header.vertexFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::fromCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::fromCommonEndian(header.indexCount);
header.properties = Shared::PlatformByteOrder::fromCommonEndian(header.properties);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::fromCommonEndian(header.texName[i]);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.vertexFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::fromCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::fromCommonEndian(header.indexCount);
header.properties = Shared::PlatformByteOrder::fromCommonEndian(header.properties);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::fromCommonEndian(header.texName[i]);
}
}
}
void toEndianMeshHeaderV2(MeshHeaderV2 &header) {
header.vertexFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::toCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::toCommonEndian(header.indexCount);
header.hasTexture = Shared::PlatformByteOrder::toCommonEndian(header.hasTexture);
header.primitive = Shared::PlatformByteOrder::toCommonEndian(header.primitive);
header.cullFace = Shared::PlatformByteOrder::toCommonEndian(header.cullFace);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.vertexFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::toCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::toCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::toCommonEndian(header.indexCount);
header.hasTexture = Shared::PlatformByteOrder::toCommonEndian(header.hasTexture);
header.primitive = Shared::PlatformByteOrder::toCommonEndian(header.primitive);
header.cullFace = Shared::PlatformByteOrder::toCommonEndian(header.cullFace);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::toCommonEndian(header.texName[i]);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::toCommonEndian(header.texName[i]);
}
}
}
void fromEndianMeshHeaderV2(MeshHeaderV2 &header) {
header.vertexFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::fromCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::fromCommonEndian(header.indexCount);
header.hasTexture = Shared::PlatformByteOrder::fromCommonEndian(header.hasTexture);
header.primitive = Shared::PlatformByteOrder::fromCommonEndian(header.primitive);
header.cullFace = Shared::PlatformByteOrder::fromCommonEndian(header.cullFace);
static bool bigEndianSystem = Shared::PlatformByteOrder::isBigEndian();
if(bigEndianSystem == true) {
header.vertexFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.vertexFrameCount);
header.normalFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.normalFrameCount);
header.texCoordFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.texCoordFrameCount);
header.colorFrameCount = Shared::PlatformByteOrder::fromCommonEndian(header.colorFrameCount);
header.pointCount = Shared::PlatformByteOrder::fromCommonEndian(header.pointCount);
header.indexCount = Shared::PlatformByteOrder::fromCommonEndian(header.indexCount);
header.hasTexture = Shared::PlatformByteOrder::fromCommonEndian(header.hasTexture);
header.primitive = Shared::PlatformByteOrder::fromCommonEndian(header.primitive);
header.cullFace = Shared::PlatformByteOrder::fromCommonEndian(header.cullFace);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::fromCommonEndian(header.texName[i]);
for(unsigned int i = 0; i < 64; ++i) {
header.texName[i] = Shared::PlatformByteOrder::fromCommonEndian(header.texName[i]);
}
}
}