mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
fix(preconditions): the racing licence types follow the licence mission
LWOPreconditionComponent::CheckPrecondition answers type 16 with "the racing licence level is at least the value" and type 17 with the opposite. The level comes from the mission component: 1 once mission 637 has been completed, 0 before (LWORacingMissions::SendMessage). Both types always failed here, so the item that asks for a licence (precondition 67) could not be used by anybody. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,13 @@ bool Precondition::MetByAnyValue(const PreconditionType type) {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Precondition::RacingLicenceLevel(const eMissionState licenceMission) {
|
||||
// The state's COMPLETE bit (UNKNOWN, -1, is no state)
|
||||
const auto state = static_cast<int32_t>(licenceMission);
|
||||
const bool completed = state > 0 && (state & static_cast<int32_t>(eMissionState::COMPLETE)) != 0;
|
||||
return completed ? 1 : 0;
|
||||
}
|
||||
|
||||
bool Precondition::ItemCountPasses(const PreconditionType type, const uint32_t held, const uint32_t count) {
|
||||
// LWOPreconditionComponent::CheckPrecondition: type 3 is the opposite of type 2's count check
|
||||
return type == PreconditionType::DoesNotHaveItem ? held < count : held >= count;
|
||||
@@ -183,9 +190,9 @@ bool Precondition::CheckValue(Entity* player, const uint32_t value) const {
|
||||
|
||||
return true;
|
||||
case PreconditionType::HasRacingLicence:
|
||||
return false; // TODO: requires a racing licence level on the player; DLU does not track this
|
||||
return RacingLicenceLevel(missionComponent->GetMissionState(RACING_LICENCE_MISSION)) >= value;
|
||||
case PreconditionType::DoesNotHaveRacingLicence:
|
||||
return false; // TODO: requires a racing licence level on the player; DLU does not track this
|
||||
return RacingLicenceLevel(missionComponent->GetMissionState(RACING_LICENCE_MISSION)) < value;
|
||||
case PreconditionType::LegoClubMember:
|
||||
return true; // Live LU opened LEGO CLUB to All players at some point, so always return true
|
||||
case PreconditionType::NoInteraction:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "Entity.h"
|
||||
#include "eMissionState.h"
|
||||
|
||||
|
||||
enum class PreconditionType
|
||||
@@ -72,6 +73,13 @@ public:
|
||||
// Whether a precondition listing several values is met by any one of them (true) or needs every one (false)
|
||||
static bool MetByAnyValue(PreconditionType type);
|
||||
|
||||
// The racing licence level the HasRacingLicence types compare their value with: 1 once the mission that makes
|
||||
// the player a licensed racer has been completed, 0 before (LWORacingMissions::SendMessage)
|
||||
static uint32_t RacingLicenceLevel(eMissionState licenceMission);
|
||||
|
||||
// That mission
|
||||
static constexpr uint32_t RACING_LICENCE_MISSION = 637;
|
||||
|
||||
// Whether holding this many of a LOT meets a HasItem (enough) or a DoesNotHaveItem (fewer) precondition
|
||||
static bool ItemCountPasses(PreconditionType type, uint32_t held, uint32_t count);
|
||||
|
||||
|
||||
@@ -111,3 +111,16 @@ TEST(PreconditionItemCostTests, ValidContextsWithoutAContext) {
|
||||
for (const uint64_t all : { 255ULL, 253ULL, 252ULL, 249ULL, 5ULL, 8ULL, ~0ULL }) EXPECT_TRUE(Precondition::AppliesIn(all, None)) << all;
|
||||
for (const uint64_t few : { 1ULL, 2ULL, 3ULL, 4ULL }) EXPECT_FALSE(Precondition::AppliesIn(few, None)) << few;
|
||||
}
|
||||
|
||||
// Types 16 and 17 compare their value with the player's racing licence level, which the client's mission component
|
||||
// answers (LWORacingMissions::SendMessage): 1 once mission 637 has been completed, repeatable or not
|
||||
TEST(PreconditionItemCostTests, RacingLicenceLevelFollowsTheLicenceMission) {
|
||||
EXPECT_EQ(Precondition::RACING_LICENCE_MISSION, 637u);
|
||||
for (const auto state : { eMissionState::UNKNOWN, eMissionState::AVAILABLE, eMissionState::ACTIVE, eMissionState::READY_TO_COMPLETE }) {
|
||||
EXPECT_EQ(Precondition::RacingLicenceLevel(state), 0u) << static_cast<int>(state);
|
||||
}
|
||||
for (const auto state : { eMissionState::COMPLETE, eMissionState::COMPLETE_AVAILABLE, eMissionState::COMPLETE_ACTIVE,
|
||||
eMissionState::COMPLETE_READY_TO_COMPLETE }) {
|
||||
EXPECT_EQ(Precondition::RacingLicenceLevel(state), 1u) << static_cast<int>(state);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user