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

@@ -123,7 +123,7 @@ void LevelChunk::init(Level *level, int x, int z)
#ifdef _LARGE_WORLDS
m_bUnloaded = false; // 4J Added
m_unloadedEntitiesTag = nullptr;
m_unloadedEntitiesTag = NULL;
#endif
}
@@ -132,10 +132,10 @@ LevelChunk::LevelChunk(Level *level, int x, int z)
{
init(level, x, z);
lowerBlocks = new CompressedTileStorage();
lowerData = nullptr;
lowerSkyLight = nullptr;
lowerBlockLight = nullptr;
serverTerrainPopulated = nullptr;
lowerData = NULL;
lowerSkyLight = NULL;
lowerBlockLight = NULL;
serverTerrainPopulated = NULL;
if(Level::maxBuildHeight > Level::COMPRESSED_CHUNK_SECTION_HEIGHT)
{
@@ -147,10 +147,10 @@ LevelChunk::LevelChunk(Level *level, int x, int z)
}
else
{
upperBlocks = nullptr;
upperData = nullptr;
upperSkyLight = nullptr;
upperBlockLight = nullptr;
upperBlocks = NULL;
upperData = NULL;
upperSkyLight = NULL;
upperBlockLight = NULL;
}
#ifdef SHARING_ENABLED
@@ -167,7 +167,7 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z)
// We'll be creating this as "empty" when this ctor is called on the client, as a result of a chunk becoming visible (but we don't have the data yet for it).
// In this case, we want to keep memory usage down and so create all data as empty/compressed as possible. On the client we get the full data for the chunk as a single
// update in a block region update packet, and so there is a single point where it is good to compress the data.
bool createEmpty = ( blocks.data == nullptr );
bool createEmpty = ( blocks.data == NULL );
if( createEmpty )
{
@@ -199,13 +199,13 @@ LevelChunk::LevelChunk(Level *level, byteArray blocks, int x, int z)
}
else
{
upperBlocks = nullptr;
upperData = nullptr;
upperSkyLight = nullptr;
upperBlockLight = nullptr;
upperBlocks = NULL;
upperData = NULL;
upperSkyLight = NULL;
upperBlockLight = NULL;
}
serverTerrainPopulated = nullptr;
serverTerrainPopulated = NULL;
#ifdef SHARING_ENABLED
sharingTilesAndData = false;
#endif
@@ -237,7 +237,7 @@ LevelChunk::LevelChunk(Level *level, int x, int z, LevelChunk *lc)
this->data = new SparseDataStorage(lc->data);
this->skyLight = new SparseLightStorage(lc->skyLight);
this->blockLight = new SparseLightStorage(lc->blockLight);
serverTerrainPopulated = nullptr;
serverTerrainPopulated = NULL;
#endif
}
@@ -296,8 +296,8 @@ void LevelChunk::stopSharingTilesAndData()
}
else
{
upperBlocks = nullptr;
upperData = nullptr;
upperBlocks = NULL;
upperData = NULL;
}
/*
@@ -531,7 +531,7 @@ void LevelChunk::recalcHeightmapOnly()
blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks;
}
#endif
heightmap[z << 4 | x] = static_cast<byte>(y);
heightmap[z << 4 | x] = (byte) y;
if (y < min) min = y;
}
@@ -588,7 +588,7 @@ void LevelChunk::recalcHeightmap()
blocks = (y-1) >= Level::COMPRESSED_CHUNK_SECTION_HEIGHT?upperBlocks : lowerBlocks;
}
#endif
heightmap[z << 4 | x] = static_cast<byte>(y);
heightmap[z << 4 | x] = (byte) y;
if (y < min) min = y;
if (y < lowestHeightmap) lowestHeightmap = y;
@@ -811,7 +811,7 @@ void LevelChunk::recalcHeight(int x, int yStart, int z)
if (y == yOld) return;
// level->lightColumnChanged(x, z, y, yOld); // 4J - this call moved below & corrected - see comment further down
heightmap[z << 4 | x] = static_cast<byte>(y);
heightmap[z << 4 | x] = (byte) y;
if (y < minHeight)
{
@@ -919,12 +919,12 @@ int LevelChunk::getTile(int x, int y, int z)
bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
{
byte tile = static_cast<byte>(_tile);
byte tile = (byte) _tile;
// Optimisation brought forward from 1.8.2, change from int to unsigned char & this special value changed from -999 to 255
int slot = z << 4 | x;
if (y >= static_cast<int>(rainHeights[slot]) - 1)
if (y >= ((int)rainHeights[slot]) - 1)
{
rainHeights[slot] = 255;
}
@@ -939,7 +939,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
{
// 4J Stu - Need to do this here otherwise double chests don't always work correctly
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
if (te != nullptr)
if (te != NULL)
{
te->clearCache();
}
@@ -1032,17 +1032,17 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
}
}
// AP - changed the method of EntityTile detection cos it's well slow on Vita mate
// if (_tile > 0 && dynamic_cast<EntityTile *>(Tile::tiles[_tile]) != nullptr)
if (_tile > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile())
// if (_tile > 0 && dynamic_cast<EntityTile *>(Tile::tiles[_tile]) != NULL)
if (_tile > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile())
{
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
if (te == nullptr)
if (te == NULL)
{
te = dynamic_cast<EntityTile *>(Tile::tiles[_tile])->newTileEntity(level);
//app.DebugPrintf("%s: Setting tile id %d, created tileEntity type %d\n", level->isClientSide?"Client":"Server", _tile, te->GetType());
level->setTileEntity(xOffs, y, zOffs, te);
}
if (te != nullptr)
if (te != NULL)
{
//app.DebugPrintf("%s: Setting tile id %d, found tileEntity type %d\n", level->isClientSide?"Client":"Server", _tile, te->GetType());
te->clearCache();
@@ -1050,11 +1050,11 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data)
}
}
// AP - changed the method of EntityTile detection cos it's well slow on Vita mate
// else if (old > 0 && dynamic_cast<EntityTile *>(Tile::tiles[old]) != nullptr)
else if (old > 0 && Tile::tiles[_tile] != nullptr && Tile::tiles[_tile]->isEntityTile())
// else if (old > 0 && dynamic_cast<EntityTile *>(Tile::tiles[old]) != NULL)
else if (old > 0 && Tile::tiles[_tile] != NULL && Tile::tiles[_tile]->isEntityTile())
{
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
if (te != nullptr)
if (te != NULL)
{
te->clearCache();
}
@@ -1091,10 +1091,10 @@ bool LevelChunk::setData(int x, int y, int z, int val, int mask, bool *maskedBit
data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, val);
int _tile = getTile(x, y, z);
if (_tile > 0 && dynamic_cast<EntityTile *>( Tile::tiles[_tile] ) != nullptr)
if (_tile > 0 && dynamic_cast<EntityTile *>( Tile::tiles[_tile] ) != NULL)
{
shared_ptr<TileEntity> te = getTileEntity(x, y, z);
if (te != nullptr)
if (te != NULL)
{
te->clearCache();
te->data = val;
@@ -1310,7 +1310,7 @@ shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
//EntityTile *et = (EntityTile *) Tile::tiles[t];
//et->onPlace(level, this->x * 16 + x, y, this->z * 16 + z);
//if (tileEntity == nullptr)
//if (tileEntity == NULL)
//{
tileEntity = dynamic_cast<EntityTile *>(Tile::tiles[t])->newTileEntity(level);
level->setTileEntity(this->x * 16 + x, y, this->z * 16 + z, tileEntity);
@@ -1332,7 +1332,7 @@ shared_ptr<TileEntity> LevelChunk::getTileEntity(int x, int y, int z)
tileEntity = it->second;
LeaveCriticalSection(&m_csTileEntities);
}
if (tileEntity != nullptr && tileEntity->isRemoved())
if (tileEntity != NULL && tileEntity->isRemoved())
{
EnterCriticalSection(&m_csTileEntities);
tileEntities.erase(pos);
@@ -1398,7 +1398,7 @@ void LevelChunk::removeTileEntity(int x, int y, int z)
{
shared_ptr<TileEntity> te = tileEntities[pos];
tileEntities.erase(pos);
if( te != nullptr )
if( te != NULL )
{
if(level->isClientSide)
{
@@ -1421,13 +1421,13 @@ void LevelChunk::load()
if(m_bUnloaded && m_unloadedEntitiesTag)
{
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) m_unloadedEntitiesTag->getList(L"Entities");
if (entityTags != nullptr)
if (entityTags != NULL)
{
for (int i = 0; i < entityTags->size(); i++)
{
CompoundTag *teTag = entityTags->get(i);
shared_ptr<Entity> ent = EntityIO::loadStatic(teTag, level);
if (ent != nullptr)
if (ent != NULL)
{
ent->onLoadedFromSave();
addEntity(ent);
@@ -1436,20 +1436,20 @@ void LevelChunk::load()
}
ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) m_unloadedEntitiesTag->getList(L"TileEntities");
if (tileEntityTags != nullptr)
if (tileEntityTags != NULL)
{
for (int i = 0; i < tileEntityTags->size(); i++)
{
CompoundTag *teTag = tileEntityTags->get(i);
shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
if (te != nullptr)
if (te != NULL)
{
addTileEntity(te);
}
}
}
delete m_unloadedEntitiesTag;
m_unloadedEntitiesTag = nullptr;
m_unloadedEntitiesTag = NULL;
m_bUnloaded = false;
}
#endif
@@ -1628,16 +1628,16 @@ void LevelChunk::getEntities(shared_ptr<Entity> except, AABB *bb, vector<shared_
for (auto& e : *entities)
{
if ( e && e != except && e->bb->intersects(bb) && (selector == nullptr || selector->matches(e)))
if ( e && e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
{
es.push_back(e);
vector<shared_ptr<Entity> > *subs = e->getSubEntities();
if (subs != nullptr)
if (subs != NULL)
{
for (const auto& sub : *subs)
{
e = sub;
if ( e && e != except && e->bb->intersects(bb) && (selector == nullptr || selector->matches(e)))
if ( e && e != except && e->bb->intersects(bb) && (selector == NULL || selector->matches(e)))
{
es.push_back(e);
}
@@ -1693,10 +1693,10 @@ void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, vector<shared
else if ( ec==typeid(Minecart) ) isAssignableFrom = e->instanceof(eTYPE_MINECART);
else if ( ec==typeid(Monster) ) isAssignableFrom = e->instanceof(eTYPE_MONSTER);
else if ( ec==typeid(Zombie) ) isAssignableFrom = e->instanceof(eTYPE_ZOMBIE);
else if(e != nullptr && ec == typeid(*(e.get())) ) isAssignableFrom = true;
else if(e != NULL && ec == typeid(*(e.get())) ) isAssignableFrom = true;
if (isAssignableFrom && e->bb->intersects(bb))
{
if (selector == nullptr || selector->matches(e))
if (selector == NULL || selector->matches(e))
{
es.push_back(e);
}
@@ -1719,7 +1719,7 @@ int LevelChunk::countEntities()
#endif
for (int yc = 0; yc < ENTITY_BLOCKS_LENGTH; yc++)
{
entityCount += static_cast<int>(entityBlocks[yc]->size());
entityCount += (int)entityBlocks[yc]->size();
}
#ifdef _ENTITIES_RW_SECTION
LeaveCriticalRWSection(&m_csEntities, false);
@@ -1813,7 +1813,7 @@ bool LevelChunk::testSetBlocksAndData(byteArray data, int x0, int y0, int z0, in
void LevelChunk::tileUpdatedCallback(int x, int y, int z, void *param, int yparam)
{
LevelChunk *lc = static_cast<LevelChunk *>(param);
LevelChunk *lc = (LevelChunk *)param;
int xx = lc->x * 16 + x;
int yy = y + yparam;
int zz = lc->z * 16 + z;
@@ -1849,8 +1849,8 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1,
int compressedHeight = Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
// 4J - replaced block storage as now uses CompressedTileStorage
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, 0 );
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerBlocks->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperBlocks->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
/*
for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++)
@@ -1864,8 +1864,8 @@ int LevelChunk::setBlocksAndData(byteArray data, int x0, int y0, int z0, int x1,
recalcHeightmapOnly();
// 4J - replaced data storage as now uses SparseDataStorage
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, 0 );
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? nullptr : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
if(y0 < Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += lowerData->setDataRegion( data, x0, y0, z0, x1, min(compressedHeight, y1), z1, p, includeLighting ? NULL : tileUpdatedCallback, this, 0 );
if(y1 > Level::COMPRESSED_CHUNK_SECTION_HEIGHT) p += upperData->setDataRegion( data, x0, max(y0-compressedHeight,0), z0, x1, y1-Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z1, p, includeLighting ? NULL : tileUpdatedCallback, this, Level::COMPRESSED_CHUNK_SECTION_HEIGHT );
if( includeLighting )
{
@@ -2000,7 +2000,7 @@ void LevelChunk::checkChests(ChunkSource *source, int x, int z )
{
int xOffs = x * 16 + xx;
int zOffs = z * 16 + zz;
ChestTile *tile = static_cast<ChestTile *>(Tile::tiles[Tile::chest_Id]);
ChestTile *tile = (ChestTile *)Tile::tiles[Tile::chest_Id];
tile->recalcLockDir( level, xOffs, yy, zOffs );
level->checkLight(xOffs, yy, zOffs, true);
}
@@ -2047,7 +2047,7 @@ void LevelChunk::reloadBiomes()
for(unsigned int z = 0; z < 16; ++z)
{
Biome *biome = biomeSource->getBiome((this->x << 4) + x, (this->z << 4) + z);
biomes[(z << 4) | x] = static_cast<byte>((biome->id) & 0xff);
biomes[(z << 4) | x] = (byte) ( (biome->id) & 0xff);
}
}
}
@@ -2059,9 +2059,9 @@ Biome *LevelChunk::getBiome(int x, int z, BiomeSource *biomeSource)
{
Biome *biome = biomeSource->getBiome((this->x << 4) + x, (this->z << 4) + z);
value = biome->id;
biomes[(z << 4) | x] = static_cast<byte>(value & 0xff);
biomes[(z << 4) | x] = (byte) (value & 0xff);
}
if (Biome::biomes[value] == nullptr)
if (Biome::biomes[value] == NULL)
{
return Biome::plains;
}
@@ -2075,7 +2075,7 @@ byteArray LevelChunk::getBiomes()
void LevelChunk::setBiomes(byteArray biomes)
{
if(this->biomes.data != nullptr) delete[] this->biomes.data;
if(this->biomes.data != NULL) delete[] this->biomes.data;
this->biomes = biomes;
}
@@ -2156,8 +2156,8 @@ void LevelChunk::getDataData(byteArray data)
// Set data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set.
void LevelChunk::setDataData(byteArray data)
{
if( lowerData == nullptr ) lowerData = new SparseDataStorage();
if( upperData == nullptr ) upperData = new SparseDataStorage(true);
if( lowerData == NULL ) lowerData = new SparseDataStorage();
if( upperData == NULL ) upperData = new SparseDataStorage(true);
lowerData->setData(data,0);
if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperData->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2);
}
@@ -2179,8 +2179,8 @@ void LevelChunk::getBlockLightData(byteArray data)
// Set sky light data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set.
void LevelChunk::setSkyLightData(byteArray data)
{
if( lowerSkyLight == nullptr ) lowerSkyLight = new SparseLightStorage(true);
if( upperSkyLight == nullptr ) upperSkyLight = new SparseLightStorage(true,true);
if( lowerSkyLight == NULL ) lowerSkyLight = new SparseLightStorage(true);
if( upperSkyLight == NULL ) upperSkyLight = new SparseLightStorage(true,true);
lowerSkyLight->setData(data,0);
if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperSkyLight->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2);
}
@@ -2188,8 +2188,8 @@ void LevelChunk::setSkyLightData(byteArray data)
// Set block light data to data passed in input byte array of length 16384. This data must be in original (java version) order if originalOrder set.
void LevelChunk::setBlockLightData(byteArray data)
{
if( lowerBlockLight == nullptr ) lowerBlockLight = new SparseLightStorage(false);
if( upperBlockLight == nullptr ) upperBlockLight = new SparseLightStorage(false, true);
if( lowerBlockLight == NULL ) lowerBlockLight = new SparseLightStorage(false);
if( upperBlockLight == NULL ) upperBlockLight = new SparseLightStorage(false, true);
lowerBlockLight->setData(data,0);
if(data.length > Level::COMPRESSED_CHUNK_SECTION_TILES/2) upperBlockLight->setData(data,Level::COMPRESSED_CHUNK_SECTION_TILES/2);
}
@@ -2215,8 +2215,8 @@ void LevelChunk::compressLighting()
void LevelChunk::compressBlocks()
{
#ifdef SHARING_ENABLED
CompressedTileStorage *blocksToCompressLower = nullptr;
CompressedTileStorage *blocksToCompressUpper = nullptr;
CompressedTileStorage *blocksToCompressLower = NULL;
CompressedTileStorage *blocksToCompressUpper = NULL;
// If we're the host machine, and this is the client level, then we only want to do this if we are sharing data. This means that we will be compressing the data that is shared from the server.
// No point trying to compress the local client copy of the data if the data is unshared, since we'll be throwing this data away again anyway once we share with the server again.
@@ -2293,24 +2293,24 @@ void LevelChunk::readCompressedBlockData(DataInputStream *dis)
void LevelChunk::readCompressedDataData(DataInputStream *dis)
{
if( lowerData == nullptr ) lowerData = new SparseDataStorage();
if( upperData == nullptr ) upperData = new SparseDataStorage(true);
if( lowerData == NULL ) lowerData = new SparseDataStorage();
if( upperData == NULL ) upperData = new SparseDataStorage(true);
lowerData->read(dis);
upperData->read(dis);
}
void LevelChunk::readCompressedSkyLightData(DataInputStream *dis)
{
if( lowerSkyLight == nullptr ) lowerSkyLight = new SparseLightStorage(true);
if( upperSkyLight == nullptr ) upperSkyLight = new SparseLightStorage(true,true);
if( lowerSkyLight == NULL ) lowerSkyLight = new SparseLightStorage(true);
if( upperSkyLight == NULL ) upperSkyLight = new SparseLightStorage(true,true);
lowerSkyLight->read(dis);
upperSkyLight->read(dis);
}
void LevelChunk::readCompressedBlockLightData(DataInputStream *dis)
{
if( lowerBlockLight == nullptr ) lowerBlockLight = new SparseLightStorage(false);
if( upperBlockLight == nullptr ) upperBlockLight = new SparseLightStorage(false, true);
if( lowerBlockLight == NULL ) lowerBlockLight = new SparseLightStorage(false);
if( upperBlockLight == NULL ) upperBlockLight = new SparseLightStorage(false, true);
lowerBlockLight->read(dis);
upperBlockLight->read(dis);
}
@@ -2319,8 +2319,8 @@ void LevelChunk::readCompressedBlockLightData(DataInputStream *dis)
void LevelChunk::compressData()
{
#ifdef SHARING_ENABLED
SparseDataStorage *dataToCompressLower = nullptr;
SparseDataStorage *dataToCompressUpper = nullptr;
SparseDataStorage *dataToCompressLower = NULL;
SparseDataStorage *dataToCompressUpper = NULL;
// If we're the host machine, and this is the client level, then we only want to do this if we are sharing data. This means that we will be compressing the data that is shared from the server.
// No point trying to compress the local client copy of the data if the data is unshared, since we'll be throwing this data away again anyway once we share with the server again.