From ecfb9a8f1efd7a826c9060acd2a68bcf2726092a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 30 Sep 2020 00:08:43 +0100 Subject: Explodinator: fix division by zero --- src/Physics/Explodinator.cpp | 4 ++-- src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Physics/Explodinator.cpp b/src/Physics/Explodinator.cpp index ca8b82b9b..b3e8f58f1 100644 --- a/src/Physics/Explodinator.cpp +++ b/src/Physics/Explodinator.cpp @@ -67,7 +67,7 @@ namespace Explodinator } } - return static_cast(Unobstructed) / Total; + return (Total == 0) ? 0 : (static_cast(Unobstructed) / Total); } /** Applies distance-based damage and knockback to all entities within the explosion's effect range. */ @@ -179,7 +179,7 @@ namespace Explodinator // The total displacement the ray must travel. const auto TraceDisplacement = (a_Destination - a_Origin); - // The displacement that they ray in one iteration step should travel. + // The displacement that the ray in one iteration step should travel. const auto Step = TraceDisplacement.NormalizeCopy() * StepUnit; // Loop until we've reached the prescribed destination: diff --git a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h index 2ac3ec869..8bf09c9eb 100644 --- a/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h +++ b/src/Simulator/IncrementalRedstoneSimulator/TNTHandler.h @@ -24,7 +24,7 @@ namespace TNTHandler if (Power != 0) { a_Chunk.SetBlock(a_Position, E_BLOCK_AIR, 0); - a_Chunk.GetWorld()->SpawnPrimedTNT(Vector3d(0.5, 0.5, 0.5) + cChunkDef::RelativeToAbsolute(a_Position, a_Chunk.GetPos())); // 80 ticks to boom + a_Chunk.GetWorld()->SpawnPrimedTNT(Vector3d(0.5, 0, 0.5) + cChunkDef::RelativeToAbsolute(a_Position, a_Chunk.GetPos())); // 80 ticks to boom } } -- cgit v1.2.3