Fix fonts on Big Endian systems, fixes #148

The code used #ifdef __ppc__, probably a leftover from old Mac support,
which apparently doesn't work on all PPC systems (maybe not 64bit PPC).

Now using the LittleFloat() function instead which exists for
exactly this purpose and already handles endianess properly.
This commit is contained in:
Daniel Gibson 2021-01-14 12:25:22 +01:00
parent bbe30e300c
commit 7297ebcaf6

View file

@ -246,31 +246,16 @@ int readInt( void ) {
return i;
}
typedef union {
byte fred[4];
float ffred;
} poor;
/*
============
readFloat
============
*/
float readFloat( void ) {
poor me;
#ifdef __ppc__
me.fred[0] = fdFile[fdOffset+3];
me.fred[1] = fdFile[fdOffset+2];
me.fred[2] = fdFile[fdOffset+1];
me.fred[3] = fdFile[fdOffset+0];
#else
me.fred[0] = fdFile[fdOffset+0];
me.fred[1] = fdFile[fdOffset+1];
me.fred[2] = fdFile[fdOffset+2];
me.fred[3] = fdFile[fdOffset+3];
#endif
fdOffset += 4;
return me.ffred;
float f;
memcpy(&f, &fdFile[fdOffset], sizeof(float));
fdOffset += sizeof(float);
return LittleFloat(f);
}
/*
@ -312,6 +297,7 @@ bool idRenderSystemLocal::RegisterFont( const char *fontName, fontInfoEx_t &font
}
}
*/
assert(sizeof(float) == 4 && "if this is false, readFloat() won't work");
memset( &font, 0, sizeof( font ) );