From 1fe26901afa81e3498fd433297daa35198aaabd5 Mon Sep 17 00:00:00 2001 From: ehofman Date: Thu, 7 Aug 2003 14:11:35 +0000 Subject: [PATCH] Go back to a function that actually does check wheter endian swapping needs to be done --- simgear/scene/sky/clouds3d/SkyArchive.cpp | 4 +-- simgear/scene/sky/clouds3d/SkyCloud.cpp | 25 +++++++++---------- simgear/scene/sky/clouds3d/SkySceneLoader.cpp | 2 +- .../scene/sky/clouds3d/SkySceneManager.cpp | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/simgear/scene/sky/clouds3d/SkyArchive.cpp b/simgear/scene/sky/clouds3d/SkyArchive.cpp index f5c8c648..f451dd0f 100644 --- a/simgear/scene/sky/clouds3d/SkyArchive.cpp +++ b/simgear/scene/sky/clouds3d/SkyArchive.cpp @@ -1165,7 +1165,7 @@ SKYRESULT SkyArchive::_Load( FILE* pSrcFile) if (!iNumItemsRead) FAIL_RETURN_MSG(SKYRESULT_FAIL, "Error: SkyArchive::_Load(): failed to read Archive header."); - _ulEndianSwap(&thisItem.iDataSize); + thisItem.iDataSize = ulEndianLittle32(thisItem.iDataSize); _pName = new char[::strlen(thisItem.pName)+1]; ::strcpy( _pName, thisItem.pName); @@ -1178,7 +1178,7 @@ SKYRESULT SkyArchive::_Load( FILE* pSrcFile) if (1 > iNumItemsRead) FAIL_RETURN_MSG(SKYRESULT_FAIL, "Error: SkyArchive::_Load(): failed to read embedded archive item."); - _ulEndianSwap(&embeddedItem.iDataSize); + embeddedItem.iDataSize = ulEndianLittle32(embeddedItem.iDataSize); switch( embeddedItem.type) diff --git a/simgear/scene/sky/clouds3d/SkyCloud.cpp b/simgear/scene/sky/clouds3d/SkyCloud.cpp index 24078499..889ebfb9 100644 --- a/simgear/scene/sky/clouds3d/SkyCloud.cpp +++ b/simgear/scene/sky/clouds3d/SkyCloud.cpp @@ -735,13 +735,13 @@ SKYRESULT SkyCloud::Load(const SkyArchive &archive, //_boundingBox.SetMax(vecCenter + Vec3f(rRadius, rRadius, rRadius)); archive.FindUInt32("CldNumParticles", &iNumParticles); - _ulEndianSwap(&iNumParticles); + iNumParticles = ulEndianLittle32(iNumParticles); //if (!bLocal) archive.FindVec3f("CldCenter", &vecCenter); - _ulEndianSwap((unsigned int*)&vecCenter.x); - _ulEndianSwap((unsigned int*)&vecCenter.y); - _ulEndianSwap((unsigned int*)&vecCenter.z); + vecCenter.x = ulEndianLittleFloat(vecCenter.x); + vecCenter.y = ulEndianLittleFloat(vecCenter.y); + vecCenter.z = ulEndianLittleFloat(vecCenter.z); Vec3f *pParticlePositions = new Vec3f[iNumParticles]; float *pParticleRadii = new float[iNumParticles]; @@ -755,17 +755,16 @@ SKYRESULT SkyCloud::Load(const SkyArchive &archive, for (unsigned int i = 0; i < iNumParticles; ++i) { - _ulEndianSwap((unsigned int*)&pParticlePositions[i].x); - _ulEndianSwap((unsigned int*)&pParticlePositions[i].y); - _ulEndianSwap((unsigned int*)&pParticlePositions[i].z); + pParticlePositions[i].x = ulEndianLittleFloat(pParticlePositions[i].x); + pParticlePositions[i].y = ulEndianLittleFloat(pParticlePositions[i].y); + pParticlePositions[i].z = ulEndianLittleFloat(pParticlePositions[i].z); - _ulEndianSwap((unsigned int*)&pParticleRadii[i]); - - _ulEndianSwap((unsigned int*)&pParticleColors[i].x); - _ulEndianSwap((unsigned int*)&pParticleColors[i].y); - _ulEndianSwap((unsigned int*)&pParticleColors[i].z); - _ulEndianSwap((unsigned int*)&pParticleColors[i].w); + pParticleRadii[i] = ulEndianLittleFloat(pParticleRadii[i]); + pParticleColors[i].x = ulEndianLittleFloat(pParticleColors[i].x); + pParticleColors[i].y = ulEndianLittleFloat(pParticleColors[i].y); + pParticleColors[i].z = ulEndianLittleFloat(pParticleColors[i].z); + pParticleColors[i].w = ulEndianLittleFloat(pParticleColors[i].w); SkyCloudParticle *pParticle = new SkyCloudParticle((pParticlePositions[i] + vecCenter) * rScale, pParticleRadii[i] * rScale, diff --git a/simgear/scene/sky/clouds3d/SkySceneLoader.cpp b/simgear/scene/sky/clouds3d/SkySceneLoader.cpp index 1f712ecb..7ab82735 100644 --- a/simgear/scene/sky/clouds3d/SkySceneLoader.cpp +++ b/simgear/scene/sky/clouds3d/SkySceneLoader.cpp @@ -174,7 +174,7 @@ bool SkySceneLoader::Load( SGPath filename, double latitude, double longitude ) unsigned int iNumFiles; if (!SKYFAILED(archive.GetInfo("CloudFile", STRING_TYPE, &iNumFiles))) { - _ulEndianSwap(&iNumFiles); + iNumFiles = ulEndianLittle32(iNumFiles); for (unsigned int i = 0; i < iNumFiles; ++i) { FAIL_RETURN(archive.FindString("CloudFile", &pFilename, i)); diff --git a/simgear/scene/sky/clouds3d/SkySceneManager.cpp b/simgear/scene/sky/clouds3d/SkySceneManager.cpp index 83d16002..02275046 100644 --- a/simgear/scene/sky/clouds3d/SkySceneManager.cpp +++ b/simgear/scene/sky/clouds3d/SkySceneManager.cpp @@ -536,7 +536,7 @@ SKYRESULT SkySceneManager::LoadClouds(SkyArchive& cloudArchive, float rScale, do { unsigned int iNumClouds = 0; cloudArchive.FindUInt32("CldNumClouds", &iNumClouds); - _ulEndianSwap(&iNumClouds); + iNumClouds = ulEndianLittle32(iNumClouds); SkyArchive subArchive; //iNumClouds = 5; //set this value to reduce cloud field for debugging -- 2.39.5