mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-25 16:46:17 +00:00
Changed: #1249 Endianness problems while access to disk or memory
This commit is contained in:
parent
0ccbf5501b
commit
290645322e
2 changed files with 27 additions and 4 deletions
|
@ -35,13 +35,19 @@ class IStream;
|
|||
//------------------ DDS STUFFS --------------------
|
||||
|
||||
#ifndef NL_MAKEFOURCC
|
||||
#define NL_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((uint32)(uint8)(ch0) | ((uint32)(uint8)(ch1) << 8) | \
|
||||
((uint32)(uint8)(ch2) << 16) | ((uint32)(uint8)(ch3) << 24 ))
|
||||
#ifdef NL_LITTLE_ENDIAN
|
||||
#define NL_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((uint32)(uint8)(ch0) | ((uint32)(uint8)(ch1) << 8) | \
|
||||
((uint32)(uint8)(ch2) << 16) | ((uint32)(uint8)(ch3) << 24 ))
|
||||
#else
|
||||
#define NL_MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((uint32)(uint8)(ch3) | ((uint32)(uint8)(ch2) << 8) | \
|
||||
((uint32)(uint8)(ch1) << 16) | ((uint32)(uint8)(ch0) << 24 ))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const uint32 DDS_HEADER = NL_MAKEFOURCC('D', 'D', 'S', ' ');
|
||||
const uint32 DXT_HEADER = NL_MAKEFOURCC('D','X', 'T', '\0');
|
||||
const uint32 DXT_HEADER = NL_MAKEFOURCC('D', 'X', 'T', '\0');
|
||||
const uint32 PNG_HEADER = NL_MAKEFOURCC(0x89, 'P', 'N', 'G');
|
||||
const uint32 JPG_HEADER = NL_MAKEFOURCC(0xff, 0xd8, 0xff, 0xe0);
|
||||
|
||||
|
|
|
@ -157,6 +157,10 @@ static void markBNPFile(std::string &path)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nOffsetFromBegining);
|
||||
#endif
|
||||
|
||||
if (nlfseek64 (f, nOffsetFromBegining, SEEK_SET) != 0)
|
||||
{
|
||||
fclose (f);
|
||||
|
@ -170,6 +174,11 @@ static void markBNPFile(std::string &path)
|
|||
fclose (f);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nNbFile);
|
||||
#endif
|
||||
|
||||
for (uint32 i = 0; i < nNbFile; ++i)
|
||||
{
|
||||
char FileName[MAX_PATH];
|
||||
|
@ -223,12 +232,20 @@ static void markBNPFile(std::string &path)
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nFileSize2);
|
||||
#endif
|
||||
|
||||
uint32 nFilePos;
|
||||
if (fread (&nFilePos, sizeof(uint32), 1, f) != 1)
|
||||
{
|
||||
fclose (f);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NL_BIG_ENDIAN
|
||||
NLMISC_BSWAP32(nFilePos);
|
||||
#endif
|
||||
}
|
||||
|
||||
fclose (f);
|
||||
|
|
Loading…
Reference in a new issue