From 210075b73fa2a7c98946dfcdf7713264b595f0f9 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 15 Sep 2023 21:58:35 -0400 Subject: [PATCH 1/3] Fix unbounded growth in plSubWorldMsg Responders. The messages in Responder commands are reused, so it's important to clear out the receivers each iteration of the Responder command. Otherwise, we are basically leaking memory in a way that asan won't detect. --- Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp index ac5db34410..5e4a9d7da5 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp @@ -351,6 +351,7 @@ bool plResponderModifier::IContinueSending() plArmatureMod *avatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); if(avatar) { + swMsg->ClearReceivers(); swMsg->AddReceiver(avatar->GetKey()); } } From 9cbc926a0cbd0374cb5ebcd3cb5aa41ef8c51c64 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 15 Sep 2023 21:59:57 -0400 Subject: [PATCH 2/3] Properly synchronize subworld changes. From TPotS to MOUL, the avatar's physics related SDLs were removed from the avatar state descriptor and stashed into the avatarPhysical descriptor. So, when a subworld change happens, we need to syncrhonize avatarPhysical, not avatar. --- Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index e491b5573d..1737abfc05 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -1379,7 +1379,7 @@ bool plArmatureMod::MsgReceive(plMessage* msg) if (fController) { fController->SetSubworld(subMsg->fWorldKey); - DirtySynchState(kSDLAvatar, plSynchedObject::kBCastToClients); + DirtyPhysicalSynchState(plSynchedObject::kBCastToClients); } return true; } From 5931bd0168242f4da9dc1a8195434009f03df11d Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 15 Sep 2023 22:01:21 -0400 Subject: [PATCH 3/3] Don't send plSubWorldMsg in Responders due to non-local notifies. This is the most controversial change. The onus for this is a report that, when using Korman's Change Subworld Message node, when a player uses an activator that sends this message in a responder, all players change to that subworld. This is objectively incorrect. The code is currently written to send `plSubWorldMsg` to the local player. Unfortunately, there is currently no way to prevent a responder running on remote clients when its clickable is used without redirecting through some kind of hack Python script. The rationale here is that changing subworlds modifies a player's avatarPhysical SDL. So, really, we probably only want to be sending `plSubWorldMsg` to the local player from a Responder. Responders are primarily a zero-code artist logic tool, so they shouldn't have to care about that level of SDL detail. Further, there is precedent for major avatar/player related actions to be rejected from non-local sources. Namely, all camera messages are restricted in the same way in Responders. The alternate to this change would be to send the `plSubWorldMsg` to the player who triggered the responder i.e. `fPlayerKey`. We will need to validate all existing (read: Cyan) Responders to see which approach they expect. --- Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp index 5e4a9d7da5..c13619dfdc 100644 --- a/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp +++ b/Sources/Plasma/PubUtilLib/plModifier/plResponderModifier.cpp @@ -208,6 +208,8 @@ bool plResponderModifier::IIsLocalOnlyCmd(plMessage* cmd) return true; if (plCameraMsg::ConvertNoRef(cmd)) // don't want to change our camera return true; + if (plSubWorldMsg::ConvertNoRef(cmd)) // don't want to enter a subworld (changes the avatar SDL) + return true; plSoundMsg *snd = plSoundMsg::ConvertNoRef( cmd ); if (snd != nullptr && snd->Cmd(plSoundMsg::kIsLocalOnly))