From 815f2aed821d9c6b7fb5355764d8d04f0bd5f28c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 28 Nov 2020 20:48:53 +0000 Subject: Lilypads: add missing boundary check --- src/Items/ItemLilypad.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Items') diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h index 5760ff830..b448b33c8 100644 --- a/src/Items/ItemLilypad.h +++ b/src/Items/ItemLilypad.h @@ -63,9 +63,15 @@ public: return false; } - // Lilypad should be placed only if there is a water block below + const auto Below = PlacePos.addedY(-1); + if (Below.y < 0) + { + return false; + } + + // Lilypad should be placed only if there is a water block below: if ( - const auto BlockBelow = a_World->GetBlock(PlacePos.addedY(-1)); + const auto BlockBelow = a_World->GetBlock(Below); (BlockBelow != E_BLOCK_WATER) && (BlockBelow != E_BLOCK_STATIONARY_WATER) ) @@ -78,6 +84,7 @@ public: { a_Player->GetInventory().RemoveOneEquippedItem(); } + return true; } -- cgit v1.2.3