mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 09:45:28 +00:00
fix: a rail that is off or whose preconditions fail is not ridden
LWORailActivatorComponent::msgCheckUseRequirements (0x00c2c5b0) refuses a use, after the quick build check, when the row's preconditions fail or rail_activator_active is off, so a client does not ask. The server started the rail on any use request. The rows ask for an equipped item (44) or a completed mission (283 to 286). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "CDRailActivatorComponent.h"
|
||||
#include "Entity.h"
|
||||
#include "MovementMessages.h"
|
||||
#include "ObjectMessages.h"
|
||||
#include "dGameMessagesTests/GameMessageTestUtils.h"
|
||||
#include "RailActivatorComponent.h"
|
||||
|
||||
@@ -82,3 +83,24 @@ TEST_F(RailActivatorComponentTests, InactiveRailIsReportedInactive) {
|
||||
notify.bActive = false;
|
||||
EXPECT_FALSE(RoundTrip(notify).bActive);
|
||||
}
|
||||
|
||||
// A rail that is off is not ridden: LWORailActivatorComponent::msgCheckUseRequirements (0x00c2c5b0) refuses the use, so a
|
||||
// client never asks for it
|
||||
TEST_F(RailActivatorComponentTests, ARailThatIsOffIsNotUsed) {
|
||||
entity->SetVar<bool>(u"rail_activator_active", false);
|
||||
auto* const rail = entity->AddComponent<RailActivatorComponent>(COMPONENT_ID);
|
||||
Entity user(77, info);
|
||||
GameMessages::RequestUse use;
|
||||
GameMessages::RequestUseEvent event(use, user);
|
||||
EXPECT_TRUE(rail->OnRequestUse(event));
|
||||
EXPECT_TRUE(rail->GetEntitiesOnRail().empty());
|
||||
}
|
||||
|
||||
TEST_F(RailActivatorComponentTests, ARailThatIsOnIsUsed) {
|
||||
auto* const rail = entity->AddComponent<RailActivatorComponent>(COMPONENT_ID);
|
||||
Entity user(78, info);
|
||||
GameMessages::RequestUse use;
|
||||
GameMessages::RequestUseEvent event(use, user);
|
||||
EXPECT_TRUE(rail->OnRequestUse(event));
|
||||
EXPECT_EQ(rail->GetEntitiesOnRail(), std::vector<LWOOBJID>{ 78 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user