From 769b1255f66e2a44d31a562dfecd520cede8f733 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 27 Jul 2017 09:13:37 +0000 Subject: [PATCH] I think this fixes readarrayfromfile and writearraytofile git-svn-id: https://svn.eduke32.com/eduke32@6385 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/gameexec.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index b81ff90c3..4f78523fc 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -4387,7 +4387,7 @@ finish_qsprintf: if (kFile < 0) continue; - int const numElements = Gv_GetArrayElementSize(arrayNum) ? kfilelength(kFile) / Gv_GetArrayElementSize(arrayNum) : 1; + int const numElements = Gv_GetArrayElementSize(arrayNum) ? kfilelength(kFile) / min(Gv_GetArrayElementSize(arrayNum), sizeof(uint32_t)) : 1; if (numElements > 0) { @@ -4457,7 +4457,7 @@ finish_qsprintf: continue; } - int const numBytes = Gv_GetArrayAllocSize(arrayNum); + int const numBytes = Gv_GetArrayAllocSize(arrayNum); switch (aGameArrays[arrayNum].flags & GAMEARRAY_TYPE_MASK) { @@ -4465,12 +4465,12 @@ finish_qsprintf: #ifdef BITNESS64 { int const numElements = aGameArrays[arrayNum].size; - int32_t *const pArray = (int32_t *)Xmalloc(numBytes); + int32_t *const pArray = (int32_t *)Xmalloc(numBytes >> 1); for (bssize_t k = 0; k < numElements; k++) pArray[k] = Gv_GetArrayValue(arrayNum, k); - Bfwrite(pArray, 1, numBytes, fil); + Bfwrite(pArray, 1, numBytes >> 1, fil); Bfree(pArray); break; }