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 a9be52c41a.
This commit is contained in:
Loki Rautio
2026-03-07 21:12:22 -06:00
parent a9be52c41a
commit 087b7e7abf
1373 changed files with 19449 additions and 19903 deletions

View File

@@ -28,7 +28,7 @@ SparseLightStorage::SparseLightStorage(bool sky)
#ifdef _XBOX
unsigned char *planeIndices = (unsigned char *)XPhysicalAlloc(128 * 128, MAXULONG_PTR, 4096, PAGE_READWRITE);
#else
unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128 * 128));
unsigned char *planeIndices = (unsigned char *)malloc(128 * 128);
#endif
unsigned char *data = planeIndices + 128;
planeIndices[127] = sky ? ALL_15_INDEX : ALL_0_INDEX;
@@ -51,7 +51,7 @@ SparseLightStorage::SparseLightStorage(bool sky, bool isUpper)
{
// Allocate using physical alloc. As this will (by default) return memory from the pool of 4KB pages, the address will in the range of MM_PHYSICAL_4KB_BASE upwards. We can use
// this fact to identify the allocation later, and so free it with the corresponding call to XPhysicalFree.
unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128));
unsigned char *planeIndices = (unsigned char *)malloc(128);
for( int i = 0; i < 128; i++ )
{
planeIndices[i] = sky ? ALL_15_INDEX : ALL_0_INDEX;
@@ -92,7 +92,7 @@ SparseLightStorage::SparseLightStorage(SparseLightStorage *copyFrom)
int sourceCount = (sourceDataAndCount >> 48 ) & 0xffff;
// Allocate & copy indices ( 128 bytes ) and any allocated planes (128 * count)
unsigned char *destIndicesAndData = static_cast<unsigned char *>(malloc(sourceCount * 128 + 128));
unsigned char *destIndicesAndData = (unsigned char *)malloc( sourceCount * 128 + 128 );
// AP - I've moved this to be before the memcpy because of a very strange bug on vita. Sometimes dataAndCount wasn't valid in time when ::get was called.
// This should never happen and this isn't a proper solution but fixes it for now.
@@ -150,7 +150,7 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset)
}
// Allocate required storage
unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128 * allocatedPlaneCount + 128));
unsigned char *planeIndices = (unsigned char *)malloc(128 * allocatedPlaneCount + 128);
unsigned char *data = planeIndices + 128;
XMemCpy(planeIndices, _planeIndices, 128);
@@ -180,9 +180,9 @@ void SparseLightStorage::setData(byteArray dataIn, unsigned int inOffset)
// Get new data and count packed info
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = reinterpret_cast<int64_t>(planeIndices) & 0x0000ffffffffffffL;
int64_t newDataAndCount = ((int64_t) planeIndices) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= static_cast<int64_t>(allocatedPlaneCount) << 48;
newDataAndCount |= ((int64_t)allocatedPlaneCount) << 48;
updateDataAndCount( newDataAndCount );
}
@@ -305,7 +305,7 @@ void SparseLightStorage::set(int x, int y, int z, int val)
void SparseLightStorage::setAllBright()
{
unsigned char *planeIndices = static_cast<unsigned char *>(malloc(128));
unsigned char *planeIndices = (unsigned char *)malloc(128);
for( int i = 0; i < 128; i++ )
{
planeIndices[i] = ALL_15_INDEX;
@@ -346,7 +346,7 @@ int SparseLightStorage::setDataRegion(byteArray dataIn, int x0, int y0, int z0,
}
ptrdiff_t count = pucIn - &dataIn.data[offset];
return static_cast<int>(count);
return (int)count;
}
// Updates the data at offset position dataInOut with a region of lighting information - external ordering compatible with java DataLayer
@@ -376,7 +376,7 @@ int SparseLightStorage::getDataRegion(byteArray dataInOut, int x0, int y0, int z
}
ptrdiff_t count = pucOut - &dataInOut.data[offset];
return static_cast<int>(count);
return (int)count;
}
void SparseLightStorage::addNewPlane(int y)
@@ -388,7 +388,7 @@ void SparseLightStorage::addNewPlane(int y)
int64_t lastDataAndCount = dataAndCount;
// Unpack count & data pointer
int lastLinesUsed = static_cast<int>((lastDataAndCount >> 48) & 0xffff);
int lastLinesUsed = (int)(( lastDataAndCount >> 48 ) & 0xffff);
unsigned char *lastDataPointer = (unsigned char *)(lastDataAndCount & 0x0000ffffffffffff);
// Find out what to prefill the newly allocated line with
@@ -400,7 +400,7 @@ void SparseLightStorage::addNewPlane(int y)
int linesUsed = lastLinesUsed + 1;
// Allocate new memory storage, copy over anything from old storage, and initialise remainder
unsigned char *dataPointer = static_cast<unsigned char *>(malloc(linesUsed * 128 + 128));
unsigned char *dataPointer = (unsigned char *)malloc(linesUsed * 128 + 128);
XMemCpy( dataPointer, lastDataPointer, 128 * lastLinesUsed + 128);
XMemSet( dataPointer + ( 128 * lastLinesUsed ) + 128, prefill, 128 );
dataPointer[y] = lastLinesUsed;
@@ -409,7 +409,7 @@ void SparseLightStorage::addNewPlane(int y)
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= static_cast<int64_t>(linesUsed) << 48;
newDataAndCount |= ((int64_t)linesUsed) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
@@ -457,7 +457,7 @@ void SparseLightStorage::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();
@@ -560,7 +560,7 @@ int SparseLightStorage::compress()
if( needsCompressed )
{
unsigned char *newIndicesAndData = static_cast<unsigned char *>(malloc(128 + 128 * planesToAlloc));
unsigned char *newIndicesAndData = (unsigned char *)malloc( 128 + 128 * planesToAlloc );
unsigned char *pucData = newIndicesAndData + 128;
XMemCpy( newIndicesAndData, _planeIndices, 128 );
@@ -577,7 +577,7 @@ int SparseLightStorage::compress()
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = ((int64_t) newIndicesAndData) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= static_cast<int64_t>(planesToAlloc) << 48;
newDataAndCount |= ((int64_t)planesToAlloc) << 48;
// Attempt to update the data & count atomically. This command will Only succeed if the data stored at
// dataAndCount is equal to lastDataAndCount, and will return the value present just before the write took place
@@ -603,7 +603,7 @@ int SparseLightStorage::compress()
}
else
{
return static_cast<int>((lastDataAndCount >> 48) & 0xffff);
return (int)((lastDataAndCount >> 48 ) & 0xffff);
}
}
@@ -629,14 +629,14 @@ void SparseLightStorage::write(DataOutputStream *dos)
void SparseLightStorage::read(DataInputStream *dis)
{
int count = dis->readInt();
unsigned char *dataPointer = static_cast<unsigned char *>(malloc(count * 128 + 128));
unsigned char *dataPointer = (unsigned char *)malloc(count * 128 + 128);
byteArray wrapper(dataPointer, count * 128 + 128);
dis->readFully(wrapper);
#pragma warning ( disable : 4826 )
int64_t newDataAndCount = ((int64_t) dataPointer) & 0x0000ffffffffffffL;
#pragma warning ( default : 4826 )
newDataAndCount |= static_cast<int64_t>(count) << 48;
newDataAndCount |= ((int64_t)count) << 48;
updateDataAndCount( newDataAndCount );
}