From 15313fa65e19cd06b43ee5b3dec6680d3ebb4e71 Mon Sep 17 00:00:00 2001 From: TCA Date: Fri, 21 Jul 2023 16:02:10 +0200 Subject: [PATCH] Attempted to fix radiusGenerator As it turns out there goes something wrong along the line while parsing chunks, culminating in different values of chunks packed array ONLY ON WINDOWS. I am not sure where it happens, but somewhere before getBlockStates(). It's not CRLF related and hashes match. It might be cNBT, probably not. Couldn't create tests for that because the Windows C development enviroment is hellish compared to linux. --- chunkParser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/chunkParser.c b/chunkParser.c index e5440bb..19bfa11 100644 --- a/chunkParser.c +++ b/chunkParser.c @@ -10,7 +10,7 @@ #include "errorDefs.h" #include "chunkParser.h" -#define createMask(startBit, X) (((long)1 << X) - 1) << startBit +#define createMask(startBit, X) ((((long)1) << X) - 1) << startBit #define statesFormula(x, y, z) (y*16*16) + (z*16) + x @@ -191,6 +191,7 @@ unsigned int* getBlockStates(struct section s, int* outLen){ l = 4; } short numPerLong = (short)(64/l); + //fprintf(stderr, "%d %d\n", l, numPerLong); states = malloc(numPerLong * s.blockDataLen * sizeof(unsigned int)); //foreach long for(int a=0; a < s.blockDataLen; a++){ @@ -202,6 +203,7 @@ unsigned int* getBlockStates(struct section s, int* outLen){ short bits = b * l; unsigned long mask = createMask(bits, l); states[m] = (unsigned int)((mask & comp) >> bits); + //fprintf(stderr, "%ld&%ld=%ld, >>%d=%d\n", mask, comp, (mask & comp), bits, states[m]); m++; } }