fix(property): cancelling a property launch takes the rocket off again

Using a property launch pad equips the player's rocket and opens the property
browser. When the browser is closed without a launch, or the player dies with
it open, the client fires "CancelLaunch" at the launch pad, locally and to the
server (LWOPropertyEntranceComponent::onPropertyEntranceSelected,
). Nothing handled the event, so the rocket stayed equipped until the
next world load.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 20:55:35 -06:00
parent 0926fce824
commit 05072948c5
4 changed files with 38 additions and 0 deletions

View File

@@ -58,6 +58,11 @@ bool PropertyEntranceComponent::OnRequestUse(GameMessages::RequestUseEvent& even
return true;
}
void PropertyEntranceComponent::CancelLaunch(Entity& player) {
auto* const characterComponent = player.GetComponent<CharacterComponent>();
if (characterComponent) characterComponent->RocketUnEquip(&player);
}
bool PropertyEntranceComponent::IsFriendsSort(const int32_t sortMethod) {
return sortMethod == SORT_TYPE_FEATURED || sortMethod == SORT_TYPE_FRIENDS;
}

View File

@@ -34,6 +34,10 @@ public:
*/
void OnEnterProperty(Entity* entity, uint32_t index, bool returnToZone, const SystemAddress& sysAddr);
// The player left the property browser without launching (FireEventServerSide "CancelLaunch"): the rocket that
// OnRequestUse put in their hands is taken off again
static void CancelLaunch(Entity& player);
// True when the property browser asked for the friends list (the reply's wasFriends says so)
static bool IsFriendsSort(int32_t sortMethod);

View File

@@ -13,6 +13,7 @@
#include "MissionComponent.h"
#include "MissionOfferComponent.h"
#include "PlayerManager.h"
#include "PropertyEntranceComponent.h"
#include "RocketLaunchpadControlComponent.h"
#include "ZoneMessages.h"
#include "ZoneInstanceManager.h"
@@ -127,6 +128,12 @@ namespace GameMessages {
});
}
// The property browser was closed without a launch, or the player died with it open
// (LWOPropertyEntranceComponent::onPropertyEntranceSelected)
if (args == u"CancelLaunch" && entity.HasComponent(eReplicaComponentType::PROPERTY_ENTRANCE)) {
PropertyEntranceComponent::CancelLaunch(*player);
}
entity.OnFireEventServerSide(sender, GeneralUtils::UTF16ToWTF8(args), param1, param2, param3);
}

View File

@@ -17,6 +17,7 @@
#include "InventoryComponent.h"
#include "InventoryMessages.h"
#include "Item.h"
#include "PropertyEntranceComponent.h"
#include "SkillMessages.h"
#include "ZoneMessages.h"
#include "eReplicaComponentType.h"
@@ -217,6 +218,27 @@ TEST_F(EquipMessagesTests, UnequippingAndSlotsWithoutAnEffect) {
// A worn jetpack is found again after a world load, so jetpack mode can be sent again: live sent SetJetPackMode (use,
// bypass checks, effect 167) about 100 packets after the player's own construction in 12 of 28 world loads of a player
// with a jetpack, and constructed the player in jetpack mode in the other 16.
// Opening a property launch pad puts the rocket in the player's hands; leaving the browser without launching (the
// client's "CancelLaunch" event) takes it off again
TEST_F(EquipMessagesTests, CancellingAPropertyLaunchTakesTheRocketOff) {
auto* const rocket = Give(ROCKET);
auto* const sword = Give(SWORD);
sword->Equip(true);
auto* const characterComponent = entity->GetComponent<CharacterComponent>();
characterComponent->SetLastRocketItemID(rocket->GetId());
ASSERT_EQ(characterComponent->RocketEquip(entity.get()), rocket);
ASSERT_TRUE(rocket->IsEquipped());
PropertyEntranceComponent::CancelLaunch(*entity);
EXPECT_FALSE(rocket->IsEquipped());
EXPECT_TRUE(sword->IsEquipped());
// Cancelling with nothing in hand changes nothing
PropertyEntranceComponent::CancelLaunch(*entity);
EXPECT_FALSE(rocket->IsEquipped());
EXPECT_TRUE(sword->IsEquipped());
}
TEST_F(EquipMessagesTests, AWornJetPackIsFoundAfterAWorldLoad) {
constexpr LOT JETPACK = 1727; // skill 306, behavior 3569 on equip
RegisterLot(JETPACK, "back");