diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-07 21:12:22 -0600 |
| commit | 087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch) | |
| tree | 69454763e73ca764af4e682d3573080b13138a0e /Minecraft.World/CompressedTileStorage.cpp | |
| parent | a9be52c41a02d207233199e98898fe7483d7e817 (diff) | |
Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore
functionality of the nightly. All in-game menus do not work and generating
a world crashes.
This reverts commit a9be52c41a02d207233199e98898fe7483d7e817.
Diffstat (limited to 'Minecraft.World/CompressedTileStorage.cpp')
| -rw-r--r-- | Minecraft.World/CompressedTileStorage.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/Minecraft.World/CompressedTileStorage.cpp b/Minecraft.World/CompressedTileStorage.cpp index 8e4fd090..eb1b784a 100644 --- a/Minecraft.World/CompressedTileStorage.cpp +++ b/Minecraft.World/CompressedTileStorage.cpp @@ -23,11 +23,11 @@ CRITICAL_SECTION CompressedTileStorage::cs_write; #ifdef PSVITA_PRECOMPUTED_TABLE // AP - this will create a precomputed table to speed up getData -static int *CompressedTile_StorageIndexTable = nullptr; +static int *CompressedTile_StorageIndexTable = NULL; void CompressedTileStorage_InitTable() { - if( CompressedTile_StorageIndexTable == nullptr ) + if( CompressedTile_StorageIndexTable == NULL ) { CompressedTile_StorageIndexTable = (int*) malloc(sizeof(int) * 64); for(int j = 0;j < 64;j += 1 ) @@ -41,7 +41,7 @@ void CompressedTileStorage_InitTable() CompressedTileStorage::CompressedTileStorage() { - indicesAndData = nullptr; + indicesAndData = NULL; allocatedSize = 0; #ifdef PSVITA_PRECOMPUTED_TABLE @@ -55,12 +55,12 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage *copyFrom) allocatedSize = copyFrom->allocatedSize; if(allocatedSize > 0) { - indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc(allocatedSize); + indicesAndData = (unsigned char *)XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc(allocatedSize); XMemCpy(indicesAndData, copyFrom->indicesAndData, allocatedSize); } else { - indicesAndData = nullptr; + indicesAndData = NULL; } LeaveCriticalSection(&cs_write); @@ -71,11 +71,11 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage *copyFrom) CompressedTileStorage::CompressedTileStorage(byteArray initFrom, unsigned int initOffset) { - indicesAndData = nullptr; + indicesAndData = NULL; allocatedSize = 0; // We need 32768 bytes for a fully uncompressed chunk, plus 1024 for the index. Rounding up to nearest 4096 bytes for allocation - indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(32768 + 4096, MAXULONG_PTR, 4096, PAGE_READWRITE)); + indicesAndData = (unsigned char *)XPhysicalAlloc(32768+4096, MAXULONG_PTR, 4096, PAGE_READWRITE); unsigned short *indices = (unsigned short *)indicesAndData; unsigned char *data = indicesAndData + 1024; @@ -117,7 +117,7 @@ bool CompressedTileStorage::isCompressed() CompressedTileStorage::CompressedTileStorage(bool isEmpty) { - indicesAndData = nullptr; + indicesAndData = NULL; allocatedSize = 0; // Empty and already compressed, so we only need 1K. Rounding up to nearest 4096 bytes for allocation @@ -125,7 +125,7 @@ CompressedTileStorage::CompressedTileStorage(bool isEmpty) // XPhysicalAlloc just maps to malloc on PS3, so allocate the smallest amount indicesAndData = (unsigned char *)XPhysicalAlloc(1024, MAXULONG_PTR, 4096, PAGE_READWRITE); #else - indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(4096, MAXULONG_PTR, 4096, PAGE_READWRITE)); + indicesAndData = (unsigned char *)XPhysicalAlloc(4096, MAXULONG_PTR, 4096, PAGE_READWRITE); #endif //__PS3__ unsigned short *indices = (unsigned short *)indicesAndData; //unsigned char *data = indicesAndData + 1024; @@ -386,7 +386,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset) // printf("%d: %d (0) %d (1) %d (2) %d (4) %d (8)\n", chunkTotal, type0 / chunkTotal, type1 / chunkTotal, type2 / chunkTotal, type4 / chunkTotal, type8 / chunkTotal); memToAlloc += 1024; // For the indices - unsigned char *newIndicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc( memToAlloc ); + unsigned char *newIndicesAndData = (unsigned char *)XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc( memToAlloc ); unsigned char *pucData = newIndicesAndData + 1024; unsigned short usDataOffset = 0; unsigned short *newIndices = (unsigned short *) newIndicesAndData; @@ -401,7 +401,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset) { if( _blockIndices[i] & INDEX_TYPE_0_BIT_FLAG ) { - newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (static_cast<unsigned short>(data[getIndex(i, 0)]) << INDEX_TILE_SHIFT); + newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (((unsigned short)data[getIndex(i,0)]) << INDEX_TILE_SHIFT); } else { @@ -423,7 +423,7 @@ void CompressedTileStorage::setData(byteArray dataIn, unsigned int inOffset) ucMappings[j] = 255; } - unsigned char *repacked = nullptr; + unsigned char *repacked = NULL; int bitspertile = 1 << indexTypeNew; // will be 1, 2 or 4 (from index values of 0, 1, 2) int tiletypecount = 1 << bitspertile; // will be 2, 4 or 16 (from index values of 0, 1, 2) @@ -738,7 +738,7 @@ int CompressedTileStorage::setDataRegion(byteArray dataIn, int x0, int y0, int } ptrdiff_t count = pucIn - &dataIn.data[offset]; - return static_cast<int>(count); + return (int)count; } // Tests whether setting data would actually change anything @@ -777,7 +777,7 @@ int CompressedTileStorage::getDataRegion(byteArray dataInOut, int x0, int y0, i } ptrdiff_t count = pucOut - &dataInOut.data[offset]; - return static_cast<int>(count); + return (int)count; } void CompressedTileStorage::staticCtor() @@ -806,7 +806,7 @@ void CompressedTileStorage::tick() int freeIndex = ( deleteQueueIndex + 1 ) % 3; // printf("Free queue: %d, %d\n",deleteQueue[freeIndex].GetEntryCount(),deleteQueue[freeIndex].GetAllocated()); - unsigned char *toFree = nullptr; + unsigned char *toFree = NULL; do { toFree = deleteQueue[freeIndex].Pop(); @@ -887,7 +887,7 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) { unsigned short indexType = blockIndices[i] & INDEX_TYPE_MASK; - unsigned char *unpacked_data = nullptr; + unsigned char *unpacked_data = NULL; unsigned char *packed_data; // First task is to find out what type of storage each block needs. Need to unpack each where required. @@ -1049,8 +1049,8 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) if( needsCompressed ) { memToAlloc += 1024; // For the indices - unsigned char *newIndicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE));//(unsigned char *)malloc( memToAlloc ); - if( newIndicesAndData == nullptr ) + unsigned char *newIndicesAndData = (unsigned char *)XPhysicalAlloc(memToAlloc, MAXULONG_PTR, 4096, PAGE_READWRITE);//(unsigned char *)malloc( memToAlloc ); + if( newIndicesAndData == NULL ) { DWORD lastError = GetLastError(); #ifndef _DURANGO @@ -1111,9 +1111,9 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) // If we're not done, then we actually need to recompress this block. First of all decompress from its current format. if( !done ) { - unsigned char *unpacked_data = nullptr; - unsigned char *tile_types = nullptr; - unsigned char *packed_data = nullptr; + unsigned char *unpacked_data = NULL; + unsigned char *tile_types = NULL; + unsigned char *packed_data = NULL; if( indexTypeOld == INDEX_TYPE_0_OR_8_BIT ) { if( blockIndices[i] & INDEX_TYPE_0_BIT_FLAG ) @@ -1159,13 +1159,13 @@ void CompressedTileStorage::compress(int upgradeBlock/*=-1*/) } #endif - unsigned char *repacked = nullptr; + unsigned char *repacked = NULL; if( indexTypeNew == INDEX_TYPE_0_OR_8_BIT ) { if( _blockIndices[i] & INDEX_TYPE_0_BIT_FLAG ) { - newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (static_cast<unsigned short>(unpacked_data[0]) << INDEX_TILE_SHIFT); + newIndices[i] = INDEX_TYPE_0_OR_8_BIT | INDEX_TYPE_0_BIT_FLAG | (((unsigned short)unpacked_data[0]) << INDEX_TILE_SHIFT); } else { @@ -1339,7 +1339,7 @@ void CompressedTileStorage::read(DataInputStream *dis) { XPhysicalFree(indicesAndData); } - indicesAndData = static_cast<unsigned char *>(XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE)); + indicesAndData = (unsigned char *)XPhysicalAlloc(allocatedSize, MAXULONG_PTR, 4096, PAGE_READWRITE); byteArray wrapper(indicesAndData, allocatedSize); dis->readFully(wrapper); |
