From 9328afe65c72b29f5cedbf1897ea8559f6b2c42f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 5 Jan 2021 02:13:02 +0000 Subject: Convert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses * Hopefully fixes #5094 --- src/Simulator/FireSimulator.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/Simulator/FireSimulator.cpp') diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp index 30fe88acd..67a00f241 100644 --- a/src/Simulator/FireSimulator.cpp +++ b/src/Simulator/FireSimulator.cpp @@ -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))) -- cgit v1.2.3