feat(property): handle BuildExitConfirmation, PropertyModerationAction and RequestLeaveProperty

Three client messages had no handler:

- BuildExitConfirmation (1072): the client says it left a build mode, after
  the last message of that mode (LWOPropertyManagementComponent::DoSetBuildMode
  ). It is addressed to the thinking hat the player wears
  or to no object, neither of which is an entity here, so the player who sent
  it takes it. Live answered nothing in the 10 captured ones, and the messages
  before it already ended the mode, so it is checked and logged.
- PropertyModerationAction (915): the owner started editing a property whose
  moderation status is not 0 and asks for 0 (LWOPropertyManagementComponent
  ). Live answered nothing in the 3 captured ones. The approval of an
  edited property is already taken back when the edit ends, so it is checked
  (own character, may build here, status 0) and logged; nothing new is stored.
- RequestLeaveProperty (1489): a visitor left through the "the owner is
  starting to build" dialog
  (LWOPropertyManagementComponent::onBuildModeVisitorConfirm). The
  player is sent to the world the property's launch pad returns to, as the
  visitors who are sent away when building starts.

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

View File

@@ -336,6 +336,30 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
return true;
}
LWOMAPID PropertyManagementComponent::GetReturnZone() const {
LWOMAPID zoneId = 1100;
const auto entrance = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_ENTRANCE);
if (!entrance.empty()) {
auto* rocketPad = entrance[0]->GetComponent<RocketLaunchpadControlComponent>();
if (rocketPad != nullptr) {
zoneId = rocketPad->GetDefaultZone();
}
}
return zoneId;
}
void PropertyManagementComponent::OnRequestLeaveProperty(Entity& player) const {
auto* const characterComponent = player.GetComponent<CharacterComponent>();
if (!characterComponent) return;
const auto zoneId = GetReturnZone();
LOG("Player %llu asked to leave the property, sending them to zone %u", player.GetObjectID(), static_cast<uint32_t>(zoneId));
characterComponent->SendToZone(zoneId);
}
void PropertyManagementComponent::OnStartBuilding(Entity& builder) {
const bool first = builders.empty();
if (!builders.insert(builder.GetObjectID()).second) return;
@@ -353,21 +377,11 @@ void PropertyManagementComponent::OnStartBuilding(Entity& builder) {
const auto players = PlayerManager::GetAllPlayers();
LWOMAPID zoneId = 1100;
const auto entrance = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_ENTRANCE);
originalPrivacyOption = privacyOption;
SetPrivacyOption(PropertyPrivacyOption::Private); // Cant visit player which is building
if (!entrance.empty()) {
auto* rocketPad = entrance[0]->GetComponent<RocketLaunchpadControlComponent>();
if (rocketPad != nullptr) {
zoneId = rocketPad->GetDefaultZone();
}
}
const LWOMAPID zoneId = GetReturnZone();
// Everyone who can't build here leaves
for (auto* player : players) {

View File

@@ -82,6 +82,16 @@ public:
* Returns the paths that this property has
* @return the paths that this property has
*/
/**
* The world a player who leaves the property goes to: the one its launch pad launches to
*/
LWOMAPID GetReturnZone() const;
/**
* A player asked to leave the property (RequestLeaveProperty): they go to the return zone
*/
void OnRequestLeaveProperty(Entity& player) const;
std::vector<NiPoint3> GetPaths() const;
/**

View File

@@ -500,6 +500,28 @@ namespace GameMessages {
}
}
void BuildExitConfirmation::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(playerID);
}
bool BuildExitConfirmation::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(bitStream.Read(playerID));
return true;
}
void BuildExitConfirmation::Handle(Entity& entity, const SystemAddress& sysAddr) {
const auto* const player = PlayerManager::GetPlayer(sysAddr);
if (!player) return;
if (playerID != player->GetObjectID()) {
LOG("Ignored BuildExitConfirmation from %llu for %llu", player->GetObjectID(), playerID);
return;
}
// The mode itself was already ended by the messages before this one (BuildModeSet, PropertyEditorEnd,
// DoneArrangingWithItem); live answered nothing here, so there is nothing more to do.
LOG_DEBUG("Player %llu confirmed leaving build mode", playerID);
}
void UnUseBBBModel::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(bHasWorldTransform);
bitStream.Write(modelID);

View File

@@ -171,6 +171,19 @@ namespace GameMessages {
NiPoint3 startPos{ NiPoint3Constant::ZERO }; // optional
};
// Client -> server. The client left a build mode (a modular build or the property editor) and says so after its
// last message of that mode (LWOPropertyManagementComponent::DoSetBuildMode). It is addressed to the
// thinking hat the player wears (the item in the hair slot, when it starts builds) or to no object,
// and carries the player. Live sent no answer to it (10 in the captures).
struct BuildExitConfirmation : public NetGameMsg {
BuildExitConfirmation() : NetGameMsg(MessageType::Game::BUILD_EXIT_CONFIRMATION) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
void Handle(Entity& entity, const SystemAddress& sysAddr) override;
LWOOBJID playerID{ LWOOBJID_EMPTY };
};
// Client -> server. The player put a model back from brick by brick building.
struct UnUseBBBModel : public NetGameMsg {
UnUseBBBModel() : NetGameMsg(MessageType::Game::UN_USE_BBB_MODEL) {}

View File

@@ -30,6 +30,7 @@ json ToJson(const GameMessages::ModularBuildConvertModel& m);
json ToJson(const GameMessages::SetBuildMode& m);
json ToJson(const GameMessages::SetBuildModeConfirmed& m);
json ToJson(const GameMessages::BuildModeSet& m);
json ToJson(const GameMessages::BuildExitConfirmation& m);
json ToJson(const GameMessages::UnUseBBBModel& m);
json ToJson(const GameMessages::BBBLoadItemRequest& m);
json ToJson(const GameMessages::BBBSaveRequest& m);
@@ -222,6 +223,8 @@ json ToJson(const GameMessages::UpdatePropertyOrModelForFilterCheck& m);
json ToJson(const GameMessages::QueryPropertyData& m);
json ToJson(const GameMessages::PropertyEditorBegin& m);
json ToJson(const GameMessages::PropertyEditorEnd& m);
json ToJson(const GameMessages::PropertyModerationAction& m);
json ToJson(const GameMessages::RequestLeaveProperty& m);
json ToJson(const GameMessages::PropertyContentsFromClient& m);
json ToJson(const GameMessages::ZonePropertyModelEquipped& m);
json ToJson(const GameMessages::ZonePropertyModelRotated& m);
@@ -531,6 +534,11 @@ json ToJson(const GameMessages::BuildModeSet& m) {
j["startPos"] = ToJson(m.startPos);
return j;
}
json ToJson(const GameMessages::BuildExitConfirmation& m) {
json j = json::object();
j["playerID"] = ToJson(m.playerID);
return j;
}
json ToJson(const GameMessages::UnUseBBBModel& m) {
json j = json::object();
j["bHasWorldTransform"] = ToJson(m.bHasWorldTransform);
@@ -1959,6 +1967,17 @@ json ToJson(const GameMessages::PropertyEditorEnd& m) {
json j = json::object();
return j;
}
json ToJson(const GameMessages::PropertyModerationAction& m) {
json j = json::object();
j["characterID"] = ToJson(m.characterID);
j["info"] = ToJson(m.info);
j["newModerationStatus"] = ToJson(m.newModerationStatus);
return j;
}
json ToJson(const GameMessages::RequestLeaveProperty& m) {
json j = json::object();
return j;
}
json ToJson(const GameMessages::PropertyContentsFromClient& m) {
json j = json::object();
j["queryDB"] = ToJson(m.queryDB);
@@ -2559,6 +2578,7 @@ const std::vector<Entry>& Entries() {
{ MessageType::Game::SET_BUILD_MODE, eDirection::TO_SERVER, "SetBuildMode", &ReadWith<GameMessages::SetBuildMode> },
{ MessageType::Game::SET_BUILD_MODE_CONFIRMED, eDirection::TO_CLIENT, "SetBuildModeConfirmed", &ReadWith<GameMessages::SetBuildModeConfirmed> },
{ MessageType::Game::BUILD_MODE_SET, eDirection::TO_SERVER, "BuildModeSet", &ReadWith<GameMessages::BuildModeSet> },
{ MessageType::Game::BUILD_EXIT_CONFIRMATION, eDirection::TO_SERVER, "BuildExitConfirmation", &ReadWith<GameMessages::BuildExitConfirmation> },
{ MessageType::Game::UN_USE_BBB_MODEL, eDirection::TO_SERVER, "UnUseBBBModel", &ReadWith<GameMessages::UnUseBBBModel> },
{ MessageType::Game::BBB_LOAD_ITEM_REQUEST, eDirection::TO_SERVER, "BBBLoadItemRequest", &ReadWith<GameMessages::BBBLoadItemRequest> },
{ MessageType::Game::BBB_SAVE_REQUEST, eDirection::TO_SERVER, "BBBSaveRequest", &ReadWith<GameMessages::BBBSaveRequest> },
@@ -2748,6 +2768,8 @@ const std::vector<Entry>& Entries() {
{ MessageType::Game::QUERY_PROPERTY_DATA, eDirection::TO_SERVER, "QueryPropertyData", &ReadWith<GameMessages::QueryPropertyData> },
{ MessageType::Game::PROPERTY_EDITOR_BEGIN, eDirection::TO_SERVER, "PropertyEditorBegin", &ReadWith<GameMessages::PropertyEditorBegin> },
{ MessageType::Game::PROPERTY_EDITOR_END, eDirection::TO_SERVER, "PropertyEditorEnd", &ReadWith<GameMessages::PropertyEditorEnd> },
{ MessageType::Game::PROPERTY_MODERATION_ACTION, eDirection::TO_SERVER, "PropertyModerationAction", &ReadWith<GameMessages::PropertyModerationAction> },
{ MessageType::Game::REQUEST_LEAVE_PROPERTY, eDirection::TO_SERVER, "RequestLeaveProperty", &ReadWith<GameMessages::RequestLeaveProperty> },
{ MessageType::Game::PROPERTY_CONTENTS_FROM_CLIENT, eDirection::TO_SERVER, "PropertyContentsFromClient", &ReadWith<GameMessages::PropertyContentsFromClient> },
{ MessageType::Game::ZONE_PROPERTY_MODEL_EQUIPPED, eDirection::TO_SERVER, "ZonePropertyModelEquipped", &ReadWith<GameMessages::ZonePropertyModelEquipped> },
{ MessageType::Game::ZONE_PROPERTY_MODEL_ROTATED, eDirection::TO_SERVER, "ZonePropertyModelRotated", &ReadWith<GameMessages::ZonePropertyModelRotated> },

View File

@@ -122,6 +122,8 @@ namespace {
{ PROPERTY_EDITOR_BEGIN, []() { return std::make_unique<PropertyEditorBegin>(); } },
{ PROPERTY_EDITOR_END, []() { return std::make_unique<PropertyEditorEnd>(); } },
{ PROPERTY_CONTENTS_FROM_CLIENT, []() { return std::make_unique<PropertyContentsFromClient>(); } },
{ PROPERTY_MODERATION_ACTION, []() { return std::make_unique<PropertyModerationAction>(); } },
{ REQUEST_LEAVE_PROPERTY, []() { return std::make_unique<RequestLeaveProperty>(); } },
{ ZONE_PROPERTY_MODEL_EQUIPPED, []() { return std::make_unique<ZonePropertyModelEquipped>(); } },
{ ZONE_PROPERTY_MODEL_ROTATED, []() { return std::make_unique<ZonePropertyModelRotated>(); } },
{ PLACE_PROPERTY_MODEL, []() { return std::make_unique<PlacePropertyModel>(); } },
@@ -143,6 +145,7 @@ namespace {
{ MODULAR_BUILD_CONVERT_MODEL, []() { return std::make_unique<ModularBuildConvertModel>(); } },
{ SET_BUILD_MODE, []() { return std::make_unique<SetBuildMode>(); } },
{ BUILD_MODE_SET, []() { return std::make_unique<BuildModeSet>(); } },
{ BUILD_EXIT_CONFIRMATION, []() { return std::make_unique<BuildExitConfirmation>(); } },
{ UN_USE_BBB_MODEL, []() { return std::make_unique<UnUseBBBModel>(); } },
{ FETCH_MODEL_METADATA_REQUEST, []() { return std::make_unique<FetchModelMetadataRequest>(); } },
{ BBB_LOAD_ITEM_REQUEST, []() { return std::make_unique<BBBLoadItemRequest>(); } },
@@ -240,6 +243,10 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System
return;
}
// BuildExitConfirmation is addressed to the thinking hat the player wears, or to no object: an item is not an
// entity here, so the player who sent it takes it
if (!entity && messageID == MessageType::Game::BUILD_EXIT_CONFIRMATION) entity = Game::entityManager->GetEntity(usr->GetLoggedInChar());
if (!entity) {
LOG("Failed to find associated entity (%llu), aborting GM: %4i, %s!", objectID, messageID, StringifiedEnum::ToString(messageID).data());
return;

View File

@@ -434,6 +434,42 @@ namespace GameMessages {
Game::zoneManager->GetZoneControlObject()->OnZonePropertyEditEnd();
}
void PropertyModerationAction::Serialize(RakNet::BitStream& bitStream) const {
BitStreamUtils::WriteOptional(bitStream, characterID, LWOOBJID_EMPTY);
BitStreamUtils::WriteLengthPrefixed<uint32_t>(bitStream, info);
BitStreamUtils::WriteOptional(bitStream, newModerationStatus, -1);
}
bool PropertyModerationAction::Deserialize(RakNet::BitStream& bitStream) {
VALIDATE_READ(BitStreamUtils::ReadOptional(bitStream, characterID, LWOOBJID_EMPTY));
VALIDATE_READ(BitStreamUtils::ReadLengthPrefixed<uint32_t>(bitStream, info));
VALIDATE_READ(BitStreamUtils::ReadOptional(bitStream, newModerationStatus, -1));
return true;
}
void PropertyModerationAction::Handle(Entity& entity, const SystemAddress& sysAddr) {
auto* property = PropertyManagementComponent::Instance();
auto* player = PlayerManager::GetPlayer(sysAddr);
if (!property || !player) return;
// The client only sends it for its own character, on a property it may edit, to ask for status 0
if (characterID != player->GetObjectID() || !property->CanBuild(*player) || newModerationStatus != 0) {
LOG("Ignored PropertyModerationAction from %llu (character %llu, status %i)", player->GetObjectID(), characterID, newModerationStatus);
return;
}
// Nothing is stored here and nothing is answered: the approval of an edited property is taken back when the
// edit ends (PropertyManagementComponent::EndBuilding), and live sent no PropertyModerationActionResponse.
LOG_DEBUG("Player %llu started editing a moderated property", player->GetObjectID());
}
void RequestLeaveProperty::Handle(Entity& entity, const SystemAddress& sysAddr) {
auto* property = PropertyManagementComponent::Instance();
auto* player = PlayerManager::GetPlayer(sysAddr);
if (!property || !player) return;
property->OnRequestLeaveProperty(*player);
}
void PropertyContentsFromClient::Serialize(RakNet::BitStream& bitStream) const {
bitStream.Write(queryDB);
}

View File

@@ -227,6 +227,27 @@ namespace GameMessages {
void Handle(Entity& entity, const SystemAddress& sysAddr) override;
};
// Client -> server, to the property plaque. The owner started editing a property whose moderation status is not
// 0 and asks for it to be 0 again (LWOPropertyManagementComponent). Laid out as the client writes it
// (PropertyModerationAction::Serialize). Live sent no answer to it (3 in the captures).
struct PropertyModerationAction : public NetGameMsg {
PropertyModerationAction() : NetGameMsg(MessageType::Game::PROPERTY_MODERATION_ACTION) {}
void Serialize(RakNet::BitStream& bitStream) const override;
bool Deserialize(RakNet::BitStream& bitStream) override;
void Handle(Entity& entity, const SystemAddress& sysAddr) override;
LWOOBJID characterID{ LWOOBJID_EMPTY }; // optional
std::u16string info;
int32_t newModerationStatus{ -1 }; // optional
};
// Client -> server, to the property plaque, with no payload. A visitor answered the "the owner is starting to
// build" dialog by leaving (LWOPropertyManagementComponent::onBuildModeVisitorConfirm).
struct RequestLeaveProperty : public NetGameMsg {
RequestLeaveProperty() : NetGameMsg(MessageType::Game::REQUEST_LEAVE_PROPERTY) {}
void Handle(Entity& entity, const SystemAddress& sysAddr) override;
};
// Client -> server.
struct PropertyContentsFromClient : public NetGameMsg {
PropertyContentsFromClient() : NetGameMsg(MessageType::Game::PROPERTY_CONTENTS_FROM_CLIENT) {}

View File

@@ -506,3 +506,11 @@ TEST_F(BuildingMessagesTests, NotifyClientUGCModelReadyWire) {
ready.WritePacket(bitStream);
EXPECT_PACKET_EQ(FromHex("53 05 00 0c 00 00 00 00 88 77 66 55 44 33 22 11 8d 03 08 07 06 05 04 03 02 01"), FromBitStream(bitStream));
}
// A live client's BuildExitConfirmation after leaving the property editor: sent to the thinking hat the player wears,
// with the player's id
TEST_F(BuildingMessagesTests, BuildExitConfirmationReadsLiveCapture) {
const auto confirmation = FromLiveClientCapture<GameMessages::BuildExitConfirmation>("53 04 00 05 00 00 00 00 43 b4 a8 91 00 00 00 10 30 04 54 db b6 91 00 00 00 10");
EXPECT_EQ(confirmation.target, 1152921507050599491LL);
EXPECT_EQ(confirmation.playerID, 1152921507051526996LL);
}

View File

@@ -651,3 +651,25 @@ TEST_F(PropertyMessagesTests, RequeryPropertyModelsHasNoPayload) {
GameMessages::RequeryPropertyModels requery;
EXPECT_EQ(Payload(requery).bits, 0u);
}
// A live client's PropertyModerationAction, sent to the property plaque when its owner started editing: the character,
// no text and status 0
TEST_F(PropertyMessagesTests, PropertyModerationActionReadsLiveCapture) {
const auto action = FromLiveClientCapture<GameMessages::PropertyModerationAction>("53 04 00 05 00 00 00 00 8a 4e 00 00 00 40 00 04 93 03 aa 6d db 48 80 00 00 08 00 00 00 00 40 00 00 00 00");
EXPECT_EQ(action.target, 288300744895909514LL);
EXPECT_EQ(action.characterID, 1152921507051526996LL);
EXPECT_TRUE(action.info.empty());
EXPECT_EQ(action.newModerationStatus, 0);
// Left at their defaults, the character and the status are one bit each
GameMessages::PropertyModerationAction empty;
EXPECT_PACKET_EQ(FromHex("00 00 00 00 00", 34), Payload(empty));
}
// RequestLeaveProperty carries nothing (RequestLeaveProperty::Deserialize reads nothing)
TEST_F(PropertyMessagesTests, RequestLeavePropertyHasNoPayload) {
GameMessages::RequestLeaveProperty leave;
EXPECT_EQ(Payload(leave).bits, 0u);
RakNet::BitStream bitStream;
EXPECT_TRUE(leave.Deserialize(bitStream));
}