Convert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses

* Hopefully fixes #5094
This commit is contained in:
Tiger Wang
2021-01-11 16:39:56 +00:00
parent eeb63b8901
commit 9328afe65c
14 changed files with 204 additions and 88 deletions
+8 -5
View File
@@ -87,7 +87,6 @@ void cFireSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
for (cCoordWithIntList::iterator itr = Data.begin(); itr != Data.end();)
{
Vector3i relPos(itr->x, itr->y, itr->z);
auto absPos = a_Chunk->RelativeToAbsolute(relPos);
auto blockType = a_Chunk->GetBlock(relPos);
if (!IsAllowedBlock(blockType))
@@ -101,12 +100,16 @@ void cFireSimulator::SimulateChunk(std::chrono::milliseconds a_Dt, int a_ChunkX,
auto BurnsForever = ((relPos.y > 0) && DoesBurnForever(a_Chunk->GetBlock(relPos.addedY(-1))));
auto BlockMeta = a_Chunk->GetMeta(relPos);
auto Raining = std::any_of(std::begin(gCrossCoords), std::end(gCrossCoords),
[this, absPos](Vector3i cc)
auto Raining = std::any_of(std::begin(gCrossCoords), std::end(gCrossCoords), [a_Chunk, relPos](Vector3i cc)
{
auto Adjusted = relPos + cc;
const auto Chunk = a_Chunk->GetRelNeighborChunkAdjustCoords(Adjusted);
if ((Chunk != nullptr) && Chunk->IsValid())
{
return (m_World.IsWeatherWetAtXYZ(absPos + cc));
return Chunk->IsWeatherWetAt(Adjusted);
}
);
return false;
});
// Randomly burn out the fire if it is raining:
if (!BurnsForever && Raining && GetRandomProvider().RandBool(CHANCE_BASE_RAIN_EXTINGUISH + (BlockMeta * CHANCE_AGE_M_RAIN_EXTINGUISH)))