From fd4376b1a4e670cc8d80af303f610e0bc2ff3ace Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 19 Jul 2014 11:23:49 +0200 Subject: [PATCH] Changed: Some Big endian swaps (for PowerPC especially) --- code/nel/tools/3d/tga_2_dds/tga2dds.cpp | 4 +++ code/nel/tools/memory/memlog/memlog.cpp | 9 +++++++ code/nel/tools/misc/bnp_make/main.cpp | 34 ++++++++++++++++++++++--- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp index 6becf5e7b..292280349 100644 --- a/code/nel/tools/3d/tga_2_dds/tga2dds.cpp +++ b/code/nel/tools/3d/tga_2_dds/tga2dds.cpp @@ -61,6 +61,10 @@ uint8 getType(const std::string &sFileNameDest) return NOT_DEFINED; } +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(dds); +#endif + if (fread(&h,sizeof(CS3TCCompressor::DDS_HEADER),1,f) != 1) { fclose(f); diff --git a/code/nel/tools/memory/memlog/memlog.cpp b/code/nel/tools/memory/memlog/memlog.cpp index 2f9892727..8112f6181 100644 --- a/code/nel/tools/memory/memlog/memlog.cpp +++ b/code/nel/tools/memory/memlog/memlog.cpp @@ -69,11 +69,20 @@ int main(int argc, char* argv[]) if (fread (&size, sizeof(uint32), 1, file) != 1) break; +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(size); +#endif + while (1) { uint32 start; if (fread (&start, sizeof(uint32), 1, file) != 1) break; + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(start); +#endif + string category; if (!readString (category, file)) break; diff --git a/code/nel/tools/misc/bnp_make/main.cpp b/code/nel/tools/misc/bnp_make/main.cpp index 06025d80c..a3f34a6a4 100644 --- a/code/nel/tools/misc/bnp_make/main.cpp +++ b/code/nel/tools/misc/bnp_make/main.cpp @@ -94,7 +94,15 @@ struct BNPHeader if (f == NULL) return false; uint32 nNbFile = (uint32)Files.size(); - if (fwrite (&nNbFile, sizeof(uint32), 1, f) != 1) + + // value to be serialized + uint32 nNbFile2 = nNbFile; + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nNbFile2); +#endif + + if (fwrite (&nNbFile2, sizeof(uint32), 1, f) != 1) { fclose(f); return false; @@ -115,20 +123,38 @@ struct BNPHeader return false; } - if (fwrite (&Files[i].Size, sizeof(uint32), 1, f) != 1) + uint32 nFileSize = Files[i].Size; + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nFileSize); +#endif + + if (fwrite (&nFileSize, sizeof(uint32), 1, f) != 1) { fclose(f); return false; } - if (fwrite (&Files[i].Pos, sizeof(uint32), 1, f) != 1) + uint32 nFilePos = Files[i].Pos; + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nFilePos); +#endif + + if (fwrite (&nFilePos, sizeof(uint32), 1, f) != 1) { fclose(f); return false; } } - if (fwrite (&OffsetFromBeginning, sizeof(uint32), 1, f) != 1) + uint32 nOffsetFromBeginning = OffsetFromBeginning; + +#ifdef NL_BIG_ENDIAN + NLMISC_BSWAP32(nOffsetFromBeginning); +#endif + + if (fwrite (&nOffsetFromBeginning, sizeof(uint32), 1, f) != 1) { fclose(f); return false;