From 50855e48ed664e1ea4c6327e78e40bf1efa6d93a Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Mon, 13 Jul 2020 16:48:14 -0600 Subject: [PATCH] Allow PXPhysicals to change scene nodes (cherry picked from H'uru 1b6f3151860bfade36179853e096a4e7d9c46c83) If this isn't done, the client will crash on exit when markers have been loaded at some point in the game --- .../Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp index ff706964..dfc0f643 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp @@ -999,7 +999,18 @@ plKey plPXPhysical::GetSceneNode() const void plPXPhysical::SetSceneNode(plKey newNode) { - // Not Supported + plKey oldNode = GetSceneNode(); + if (oldNode == newNode) + return; + + // If we don't do this, we get leaked keys and a crash on exit with certain clones + // Note this has nothing do to with the world that the physical is in + if (newNode) { + plNodeRefMsg* refMsg = new plNodeRefMsg(newNode, plNodeRefMsg::kOnRequest, -1, plNodeRefMsg::kPhysical); + hsgResMgr::ResMgr()->SendRef(GetKey(), refMsg, plRefFlags::kActiveRef); + } + if (oldNode) + oldNode->Release(GetKey()); } /////////////////////////////////////////////////////////////////////