From 5e7cdabea39845e99641f6a0db016b5a279e11ec Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Wed, 1 Apr 2026 01:23:05 -0500 Subject: [PATCH] replace XPhysicalAlloc --- .../Source Files/Extrax64Stubs.cpp | 4 ---- .../net/minecraft/world/level/Level.cpp | 3 +-- .../level/chunk/CompressedTileStorage.cpp | 21 ++++++------------- .../level/levelgen/CustomLevelSource.cpp | 3 +-- .../world/level/levelgen/FlatLevelSource.cpp | 3 +-- .../level/levelgen/HellRandomLevelSource.cpp | 3 +-- .../level/levelgen/RandomLevelSource.cpp | 3 +-- .../levelgen/TheEndLevelRandomLevelSource.cpp | 3 +-- .../Minecraft.World/x64headers/extraX64.h | 2 -- 9 files changed, 12 insertions(+), 33 deletions(-) diff --git a/minecraft/Minecraft.Client/Source Files/Extrax64Stubs.cpp b/minecraft/Minecraft.Client/Source Files/Extrax64Stubs.cpp index d9c8e313a..c0475e8ac 100644 --- a/minecraft/Minecraft.Client/Source Files/Extrax64Stubs.cpp +++ b/minecraft/Minecraft.Client/Source Files/Extrax64Stubs.cpp @@ -38,10 +38,6 @@ int32_t XPartyGetUserList(void* pUserList) { return 0; } bool IsEqualXUID(PlayerUID a, PlayerUID b) { return false; } -void* XPhysicalAlloc(size_t a, uintptr_t b, uintptr_t c, uint32_t d) { - return malloc(a); -} - D3DXVECTOR3::D3DXVECTOR3() {} D3DXVECTOR3::D3DXVECTOR3(float x, float y, float z) : x(x), y(y), z(z) {} D3DXVECTOR3& D3DXVECTOR3::operator+=(const D3DXVECTOR3& add) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp index 7781106bb..355866149 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp @@ -92,8 +92,7 @@ void Level::enableLightingCache() { // results, plus 128K required for toCheck array. Rounding up to 256 to keep // as multiple of alignement - aligning to 128K boundary for possible cache // locking. - m_tlsLightCache = (lightCache_t*)XPhysicalAlloc( - 256 * 1024, MAXULONG_PTR, 128 * 1024, PAGE_READWRITE | MEM_LARGE_PAGES); + m_tlsLightCache = (lightCache_t*)malloc(256 * 1024); } void Level::destroyLightingCache() { delete m_tlsLightCache; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/CompressedTileStorage.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/CompressedTileStorage.cpp index 089681d55..a2143bd01 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/CompressedTileStorage.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/CompressedTileStorage.cpp @@ -47,9 +47,7 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage* copyFrom) { std::lock_guard lock(cs_write); allocatedSize = copyFrom->allocatedSize; if (allocatedSize > 0) { - indicesAndData = (unsigned char*)XPhysicalAlloc( - allocatedSize, MAXULONG_PTR, 4096, - PAGE_READWRITE); //(unsigned char *)malloc(allocatedSize); + indicesAndData = (unsigned char*)malloc(allocatedSize); //(unsigned char *)malloc(allocatedSize); memcpy(indicesAndData, copyFrom->indicesAndData, allocatedSize); } else { indicesAndData = nullptr; @@ -68,8 +66,7 @@ CompressedTileStorage::CompressedTileStorage(std::vector& initFrom, // We need 32768 bytes for a fully uncompressed chunk, plus 1024 for the // index. Rounding up to nearest 4096 bytes for allocation - indicesAndData = (unsigned char*)XPhysicalAlloc(32768 + 4096, MAXULONG_PTR, - 4096, PAGE_READWRITE); + indicesAndData = (unsigned char*)malloc(32768 + 4096); unsigned short* indices = (unsigned short*)indicesAndData; unsigned char* data = indicesAndData + 1024; @@ -112,8 +109,7 @@ CompressedTileStorage::CompressedTileStorage(bool isEmpty) { // Empty and already compressed, so we only need 1K. Rounding up to nearest // 4096 bytes for allocation - indicesAndData = (unsigned char*)XPhysicalAlloc(4096, MAXULONG_PTR, 4096, - PAGE_READWRITE); + indicesAndData = (unsigned char*)malloc(4096); unsigned short* indices = (unsigned short*)indicesAndData; // unsigned char *data = indicesAndData + 1024; @@ -330,9 +326,7 @@ void CompressedTileStorage::setData(std::vector& dataIn, unsigned int i // type8 / chunkTotal); memToAlloc += 1024; // For the indices - unsigned char* newIndicesAndData = (unsigned char*)XPhysicalAlloc( - memToAlloc, MAXULONG_PTR, 4096, - PAGE_READWRITE); //(unsigned char *)malloc( memToAlloc ); + unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc ); unsigned char* pucData = newIndicesAndData + 1024; unsigned short usDataOffset = 0; unsigned short* newIndices = (unsigned short*)newIndicesAndData; @@ -948,9 +942,7 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) { // If we need to do something here, then lets allocate some memory if (needsCompressed) { memToAlloc += 1024; // For the indices - unsigned char* newIndicesAndData = (unsigned char*)XPhysicalAlloc( - memToAlloc, MAXULONG_PTR, 4096, - PAGE_READWRITE); //(unsigned char *)malloc( memToAlloc ); + unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc ); if (newIndicesAndData == nullptr) { uint32_t lastError = GetLastError(); MEMORYSTATUS memStatus; @@ -1231,8 +1223,7 @@ void CompressedTileStorage::read(DataInputStream* dis) { if (indicesAndData) { free(indicesAndData); } - indicesAndData = (unsigned char*)XPhysicalAlloc( - allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE); + indicesAndData = (unsigned char*)malloc(allocatedSize); std::vector wrapper(allocatedSize); dis->readFully(wrapper); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CustomLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CustomLevelSource.cpp index efb2d91c8..a1c8b44cf 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CustomLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CustomLevelSource.cpp @@ -351,8 +351,7 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) { // 4J - now allocating this with a physical alloc & bypassing general memory // management so that it will get cleanly freed int blocksSize = Level::maxBuildHeight * 16 * 16; - uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, - PAGE_READWRITE); + uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); std::vector blocks = std::vector(tileData, tileData + blocksSize); // std::vector blocks = std::vector(16 * level->depth * 16); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/FlatLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/FlatLevelSource.cpp index 12b2b96cc..576f1a48c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/FlatLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/FlatLevelSource.cpp @@ -59,8 +59,7 @@ LevelChunk* FlatLevelSource::getChunk(int xOffs, int zOffs) { // 4J - now allocating this with a physical alloc & bypassing general memory // management so that it will get cleanly freed int chunksSize = Level::genDepth * 16 * 16; - uint8_t* tileData = (uint8_t*)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096, - PAGE_READWRITE); + uint8_t* tileData = (uint8_t*)malloc(chunksSize); memset(tileData, 0, chunksSize); std::vector blocks = std::vector(tileData, tileData + chunksSize); // std::vector blocks = std::vector(16 * level->depth * 16); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp index 87860736f..89a2b44c5 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp @@ -304,8 +304,7 @@ LevelChunk* HellRandomLevelSource::getChunk(int xOffs, int zOffs) { // 4J - now allocating this with a physical alloc & bypassing general memory // management so that it will get cleanly freed int blocksSize = Level::genDepth * 16 * 16; - uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, - PAGE_READWRITE); + uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); std::vector blocks = std::vector(tileData, tileData + blocksSize); // std::vector blocks = std::vector(16 * level->depth * 16); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp index cbeb9e88e..32bf5a775 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp @@ -476,8 +476,7 @@ LevelChunk* RandomLevelSource::getChunk(int xOffs, int zOffs) { // 4J - now allocating this with a physical alloc & bypassing general memory // management so that it will get cleanly freed int blocksSize = Level::genDepth * 16 * 16; - uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, - PAGE_READWRITE); + uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); std::vector blocks = std::vector(tileData, tileData + blocksSize); // std::vector blocks = std::vector(16 * level->depth * 16); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp index d839a840a..a56104e00 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp @@ -177,8 +177,7 @@ LevelChunk* TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs) { // 4J - now allocating this with a physical alloc & bypassing general memory // management so that it will get cleanly freed unsigned int blocksSize = Level::genDepth * 16 * 16; - uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096, - PAGE_READWRITE); + uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); std::vector blocks = std::vector(tileData, tileData + blocksSize); // std::vector blocks = std::vector(16 * level->depth * 16); diff --git a/minecraft/Minecraft.World/x64headers/extraX64.h b/minecraft/Minecraft.World/x64headers/extraX64.h index 2d577eb61..5356c1810 100644 --- a/minecraft/Minecraft.World/x64headers/extraX64.h +++ b/minecraft/Minecraft.World/x64headers/extraX64.h @@ -56,8 +56,6 @@ public: } }; -void* XPhysicalAlloc(size_t a, uintptr_t b, uintptr_t c, uint32_t d); - class DLCManager; class LevelRuleset; class ModelPart;