replace XPhysicalAlloc

This commit is contained in:
Tropical 2026-04-01 01:23:05 -05:00
parent 7df158d266
commit 5e7cdabea3
9 changed files with 12 additions and 33 deletions

View file

@ -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) {

View file

@ -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; }

View file

@ -47,9 +47,7 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage* copyFrom) {
std::lock_guard<std::recursive_mutex> 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<uint8_t>& 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<uint8_t>& 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<uint8_t> wrapper(allocatedSize);
dis->readFully(wrapper);

View file

@ -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<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);

View file

@ -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<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + chunksSize);
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);

View file

@ -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<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);

View file

@ -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<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);

View file

@ -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<uint8_t> blocks = std::vector<uint8_t>(tileData, tileData + blocksSize);
// std::vector<uint8_t> blocks = std::vector<uint8_t>(16 * level->depth * 16);

View file

@ -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;