From b4de288ca7c8373d07ea859a2aad29e25dbc429f Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 16 Dec 2019 18:57:32 +0000 Subject: [PATCH] Emscripten is too lame to support c89's offsetof macro. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5593 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/image.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/client/image.c b/engine/client/image.c index c415c6b4f..d58aacae4 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -4971,7 +4971,7 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch int mipnum; int face; int datasize; - unsigned int w, h, d, f, l, browbytes,padbytes,y,x,rows; + unsigned int *swap, w, h, d, f, l, browbytes,padbytes,y,x,rows; struct pendingtextureinfo *mips; int encoding = TF_INVALID; const qbyte *fileend = filedata + filesize; @@ -4984,8 +4984,8 @@ static struct pendingtextureinfo *Image_ReadKTXFile(unsigned int flags, const ch header = *(const ktxheader_t*)filedata; if (header.endianness == 0x01020304) { //swap the rest of the header. - for (w = offsetof(ktxheader_t, endianness); w < sizeof(ktxheader_t); w+=sizeof(int)) - ((int*)&header)[w/sizeof(int)] = LongSwap(((int*)&header)[w/sizeof(int)]); + for (swap = &header.endianness; swap < (unsigned int*)(&header+1); swap++) + *swap = LongSwap(*swap); } else if (header.endianness != 0x04030201) return NULL;