replace XMemSet/XMemSet128

This commit is contained in:
Tropical 2026-04-01 01:18:36 -05:00
parent 7f71a9b980
commit 7df158d266
14 changed files with 20 additions and 23 deletions

View file

@ -1,5 +1,6 @@
#include <utility>
#include <vector>
#include <cstring>
#include "ColourTable.h"
#include "Minecraft.World/ConsoleHelpers/StringHelpers.h"

View file

@ -38,8 +38,6 @@ int32_t XPartyGetUserList(void* pUserList) { return 0; }
bool IsEqualXUID(PlayerUID a, PlayerUID b) { return false; }
void XMemSet(void* a, int t, size_t s) { memset(a, t, s); }
void XMemSet128(void* a, int t, size_t s) { memset(a, t, s); }
void* XPhysicalAlloc(size_t a, uintptr_t b, uintptr_t c, uint32_t d) {
return malloc(a);
}

View file

@ -210,7 +210,7 @@ TileRenderer::TileRenderer(LevelSource* level, int xMin, int yMin, int zMin,
this->zMin2 = zMin - 2;
this->tileIds = tileIds;
cache = new unsigned int[32 * 32 * 32];
XMemSet(cache, 0, 32 * 32 * 32 * sizeof(unsigned int));
memset(cache, 0, 32 * 32 * 32 * sizeof(unsigned int));
}
TileRenderer::~TileRenderer() {

View file

@ -145,7 +145,7 @@ void Level::initCacheComplete(lightCache_t* cache, int xc, int yc, int zc) {
old[4] = cache[GetIndex(xc, yc + 1, zc)];
}
XMemSet128(cache, 0, 16 * 16 * 16 * sizeof(lightCache_t));
memset(cache, 0, 16 * 16 * 16 * sizeof(lightCache_t));
if (!(yc & 0xffffff00)) {
cache[GetIndex(xc, yc, zc)] = old[0];

View file

@ -386,8 +386,8 @@ void CompressedTileStorage::setData(std::vector<uint8_t>& dataIn, unsigned int i
unsigned char* tile_types = pucData + usDataOffset;
repacked = tile_types + tiletypecount;
XMemSet(tile_types, 255, tiletypecount);
XMemSet(repacked, 0, tiledatasize);
memset(tile_types, 255, tiletypecount);
memset(repacked, 0, tiledatasize);
newIndices[i] |= (usDataOffset & INDEX_OFFSET_MASK)
<< INDEX_OFFSET_SHIFT;
usDataOffset += tiletypecount + tiledatasize;
@ -1017,7 +1017,7 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) {
unpacked_data = tempdata;
int value = (blockIndices[i] >> INDEX_TILE_SHIFT) &
INDEX_TILE_MASK;
XMemSet(tempdata, value, 64);
memset(tempdata, value, 64);
} else {
unpacked_data =
data + ((blockIndices[i] >> INDEX_OFFSET_SHIFT) &
@ -1102,8 +1102,8 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) {
tile_types = pucData + usDataOffset;
repacked = tile_types + tiletypecount;
XMemSet(tile_types, 255, tiletypecount);
XMemSet(repacked, 0, tiledatasize);
memset(tile_types, 255, tiletypecount);
memset(repacked, 0, tiledatasize);
newIndices[i] |= (usDataOffset & INDEX_OFFSET_MASK)
<< INDEX_OFFSET_SHIFT;
usDataOffset += tiletypecount + tiledatasize;

View file

@ -47,7 +47,7 @@ SparseDataStorage::SparseDataStorage() {
for (int i = 1; i < 128; i++) {
planeIndices[i] = i - 1;
}
XMemSet(data, 0, 128 * 127);
memset(data, 0, 128 * 127);
// Data and count packs together the pointer to our data and the count of
// planes allocated - 127 planes allocated in this case
@ -202,7 +202,7 @@ void SparseDataStorage::setData(std::vector<uint8_t>& dataIn, unsigned int inOff
// Gets all data values into an array of length 16384. Destination data will
// have same order as original java game.
void SparseDataStorage::getData(std::vector<uint8_t>& retArray, unsigned int retOffset) {
XMemSet(retArray.data() + +retOffset, 0, 16384);
memset(retArray.data() + +retOffset, 0, 16384);
unsigned char *planeIndices, *data;
getPlaneIndicesAndData(&planeIndices, &data);
@ -409,7 +409,7 @@ void SparseDataStorage::addNewPlane(int y) {
unsigned char* dataPointer =
(unsigned char*)malloc(linesUsed * 128 + 128);
memcpy(dataPointer, lastDataPointer, 128 * lastLinesUsed + 128);
XMemSet(dataPointer + (128 * lastLinesUsed) + 128, 0, 128);
memset(dataPointer + (128 * lastLinesUsed) + 128, 0, 128);
dataPointer[y] = lastLinesUsed;
// Get new data and count packed info

View file

@ -48,7 +48,7 @@ SparseLightStorage::SparseLightStorage(bool sky) {
for (int i = 0; i < 127; i++) {
planeIndices[i] = i;
}
XMemSet(data, 0, 128 * 127);
memset(data, 0, 128 * 127);
// Data and count packs together the pointer to our data and the count of
// planes allocated - 127 planes allocated in this case
@ -204,7 +204,7 @@ void SparseLightStorage::setData(std::vector<uint8_t>& dataIn, unsigned int inOf
// Gets all lighting values into an array of length 16384. Destination data will
// have same order as original java game.
void SparseLightStorage::getData(std::vector<uint8_t>& retArray, unsigned int retOffset) {
XMemSet(retArray.data() + retOffset, 0, 16384);
memset(retArray.data() + retOffset, 0, 16384);
unsigned char *planeIndices, *data;
getPlaneIndicesAndData(&planeIndices, &data);
@ -412,7 +412,7 @@ void SparseLightStorage::addNewPlane(int y) {
unsigned char* dataPointer =
(unsigned char*)malloc(linesUsed * 128 + 128);
memcpy(dataPointer, lastDataPointer, 128 * lastLinesUsed + 128);
XMemSet(dataPointer + (128 * lastLinesUsed) + 128, prefill, 128);
memset(dataPointer + (128 * lastLinesUsed) + 128, prefill, 128);
dataPointer[y] = lastLinesUsed;
// Get new data and count packed info

View file

@ -353,7 +353,7 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) {
int blocksSize = Level::maxBuildHeight * 16 * 16;
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
PAGE_READWRITE);
XMemSet128(tileData, 0, 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

@ -61,7 +61,7 @@ LevelChunk* FlatLevelSource::getChunk(int xOffs, int zOffs) {
int chunksSize = Level::genDepth * 16 * 16;
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096,
PAGE_READWRITE);
XMemSet128(tileData, 0, 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);
prepareHeights(blocks);

View file

@ -108,7 +108,7 @@ LevelChunk* HellFlatLevelSource::getChunk(int xOffs, int zOffs) {
int chunksSize = Level::genDepth * 16 * 16;
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(chunksSize, MAXULONG_PTR, 4096,
PAGE_READWRITE);
XMemSet128(tileData, 0, 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

@ -306,7 +306,7 @@ LevelChunk* HellRandomLevelSource::getChunk(int xOffs, int zOffs) {
int blocksSize = Level::genDepth * 16 * 16;
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
PAGE_READWRITE);
XMemSet128(tileData, 0, 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

@ -478,7 +478,7 @@ LevelChunk* RandomLevelSource::getChunk(int xOffs, int zOffs) {
int blocksSize = Level::genDepth * 16 * 16;
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
PAGE_READWRITE);
XMemSet128(tileData, 0, 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

@ -179,7 +179,7 @@ LevelChunk* TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs) {
unsigned int blocksSize = Level::genDepth * 16 * 16;
uint8_t* tileData = (uint8_t*)XPhysicalAlloc(blocksSize, MAXULONG_PTR, 4096,
PAGE_READWRITE);
XMemSet128(tileData, 0, 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 XMemSet(void* a, int t, size_t s);
void XMemSet128(void* a, int t, size_t s);
void* XPhysicalAlloc(size_t a, uintptr_t b, uintptr_t c, uint32_t d);
class DLCManager;