From 01fee0d2fcef1fc428531fdc7895c06e2996ed89 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Wed, 11 Nov 2026 07:10:16 -0600 Subject: [PATCH] fix(preconditions): a precondition of an unknown type fails LWOPreconditionComponent::CheckPrecondition fails a type it does not know and logs it; the server passed it. No row of the table has one, so nothing changes for the shipped data. Co-Authored-By: Claude Opus 5.5 --- dGame/dUtilities/Preconditions.cpp | 5 ++++- tests/dGameTests/PreconditionCheckTests.cpp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dGame/dUtilities/Preconditions.cpp b/dGame/dUtilities/Preconditions.cpp index a11cd3734..dbfabdf71 100644 --- a/dGame/dUtilities/Preconditions.cpp +++ b/dGame/dUtilities/Preconditions.cpp @@ -213,7 +213,10 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value) const { case PreconditionType::DoesNotHaveFlag: return !character->GetPlayerFlag(value); default: - return true; // There are a couple more unknown preconditions. Always return true in this case. + // LWOPreconditionComponent::CheckPrecondition fails a type it does not know, and logs it. No row of + // the table has one. + LOG("Precondition with unknown type %i", static_cast(type)); + return false; } } diff --git a/tests/dGameTests/PreconditionCheckTests.cpp b/tests/dGameTests/PreconditionCheckTests.cpp index 76a68e235..ebe5b85c6 100644 --- a/tests/dGameTests/PreconditionCheckTests.cpp +++ b/tests/dGameTests/PreconditionCheckTests.cpp @@ -153,3 +153,8 @@ TEST_F(PreconditionCheckTests, VendorBuyChecksTheItemsRequirementsInItsContext) EXPECT_TRUE(BaseVendorComponent::MeetsBuyRequirements(*player, std::to_string(level))); EXPECT_TRUE(BaseVendorComponent::MeetsBuyRequirements(*player, std::to_string(notAtVendors) + ";" + std::to_string(everywhere))); } + +// A type the client does not know fails +TEST_F(PreconditionCheckTests, AnUnknownTypeFails) { + EXPECT_FALSE(Preconditions::Check(player.get(), Row(static_cast(99), "1", 1, 255))); +}