s integer overflow, unsafe cast

This commit is contained in:
Nikita Edel
2026-03-11 16:10:48 +01:00
parent a24f9f5a5e
commit ed13020cf3
7 changed files with 28 additions and 23 deletions

View File

@@ -654,8 +654,8 @@ void RandomLevelSource::postProcess(ChunkSource *parent, int xt, int zt)
pprandom->setSeed(level->getSeed());
__int64 xScale = pprandom->nextLong() / 2 * 2 + 1;
__int64 zScale = pprandom->nextLong() / 2 * 2 + 1;
// 4jcraft added casts to u, holy moly, the getSeed is 64 bit and the result is 32...
pprandom->setSeed((((uint64_t)(int64_t)xt * (uint64_t)(int64_t)xScale) + ((uint64_t)(int64_t)zt * (uint64_t)(int64_t)zScale)) ^ level->getSeed());
// 4jcraft added casts to a higher int and unsigned
pprandom->setSeed((((uint64_t)xt * (uint64_t)xScale) + ((uint64_t)zt * (uint64_t)zScale)) ^ level->getSeed());
bool hasVillage = false;