From 602c9f558d33e2d5dbcc9d86ac5a8bb7d3a021c5 Mon Sep 17 00:00:00 2001 From: disinvite Date: Mon, 14 Apr 2025 21:59:05 -0400 Subject: [PATCH] Add Destroy methods to TglImpl --- LEGO1/tgl/d3drm/impl.h | 200 +++++++++++++++++++++++++++++------------ 1 file changed, 144 insertions(+), 56 deletions(-) diff --git a/LEGO1/tgl/d3drm/impl.h b/LEGO1/tgl/d3drm/impl.h index c5c74f82..16794273 100644 --- a/LEGO1/tgl/d3drm/impl.h +++ b/LEGO1/tgl/d3drm/impl.h @@ -133,13 +133,7 @@ class DeviceImpl : public Device { DeviceImpl() : m_data(0) {} // FUNCTION: BETA10 0x1016dd80 - ~DeviceImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + ~DeviceImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -161,12 +155,29 @@ class DeviceImpl : public Device { IDirect3DRMDevice2* ImplementationData() const { return m_data; } void SetImplementationData(IDirect3DRMDevice2* device) { m_data = device; } + inline void Destroy(); + friend class RendererImpl; private: IDirect3DRMDevice2* m_data; }; +// FUNCTION: BETA10 0x101708c0 +inline void DeviceDestroy(IDirect3DRMDevice2* pDevice) +{ + pDevice->Release(); +} + +// FUNCTION: BETA10 0x10170880 +void DeviceImpl::Destroy() +{ + if (m_data) { + DeviceDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100db9e8 // VTABLE: BETA10 0x101c3220 class ViewImpl : public View { @@ -175,13 +186,7 @@ class ViewImpl : public View { ViewImpl() : m_data(0) {} // FUNCTION: BETA10 0x1016e5d0 - ~ViewImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + ~ViewImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -218,12 +223,29 @@ class ViewImpl : public View { static Result ViewportCreateAppData(IDirect3DRM2*, IDirect3DRMViewport*, IDirect3DRMFrame2*); + inline void Destroy(); + friend class RendererImpl; private: IDirect3DRMViewport* m_data; }; +// FUNCTION: BETA10 0x101711a0 +inline void ViewDestroy(IDirect3DRMViewport* pView) +{ + pView->Release(); +} + +// FUNCTION: BETA10 0x10171160 +void ViewImpl::Destroy() +{ + if (m_data) { + ViewDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbad8 // VTABLE: BETA10 0x101c3260 class CameraImpl : public Camera { @@ -232,13 +254,7 @@ class CameraImpl : public Camera { CameraImpl() : m_data(0) {} // FUNCTION: BETA10 0x1016f200 - ~CameraImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + ~CameraImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -247,12 +263,29 @@ class CameraImpl : public Camera { IDirect3DRMFrame2* ImplementationData() const { return m_data; } + inline void Destroy(); + friend class RendererImpl; private: IDirect3DRMFrame2* m_data; }; +// FUNCTION: BETA10 0x10170940 +inline void CameraDestroy(IDirect3DRMFrame2* pFrame) +{ + pFrame->Release(); +} + +// FUNCTION: BETA10 0x10170900 +void CameraImpl::Destroy() +{ + if (m_data) { + CameraDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbaf8 // VTABLE: BETA10 0x101c31e0 class LightImpl : public Light { @@ -261,13 +294,7 @@ class LightImpl : public Light { LightImpl() : m_data(0) {} // FUNCTION: BETA10 0x1016c7e0 - ~LightImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + ~LightImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -277,12 +304,29 @@ class LightImpl : public Light { IDirect3DRMFrame2* ImplementationData() const { return m_data; } + inline void Destroy(); + friend class RendererImpl; private: IDirect3DRMFrame2* m_data; }; +// FUNCTION: BETA10 0x10170390 +inline void LightDestroy(IDirect3DRMFrame2* pLight) +{ + pLight->Release(); +} + +// FUNCTION: BETA10 0x10170350 +void LightImpl::Destroy() +{ + if (m_data) { + LightDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbb88 // VTABLE: BETA10 0x101c3340 class MeshImpl : public Mesh { @@ -291,13 +335,7 @@ class MeshImpl : public Mesh { MeshImpl() : m_data(0) {} // FUNCTION: BETA10 0x10170460 - ~MeshImpl() override - { - if (m_data) { - delete m_data; - m_data = NULL; - } - } + ~MeshImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -324,12 +362,29 @@ class MeshImpl : public Mesh { const MeshDataType& ImplementationData() const { return m_data; } MeshDataType& ImplementationData() { return m_data; } + inline void Destroy(); + friend class RendererImpl; private: MeshDataType m_data; }; +// FUNCTION: BETA10 0x10171b40 +inline void MeshDestroy(MeshImpl::MeshDataType pMesh) +{ + delete pMesh; +} + +// FUNCTION: BETA10 0x10171b00 +void MeshImpl::Destroy() +{ + if (m_data) { + MeshDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dba68 // VTABLE: BETA10 0x101c3150 class GroupImpl : public Group { @@ -338,13 +393,7 @@ class GroupImpl : public Group { GroupImpl() : m_data(0) {} // FUNCTION: BETA10 0x1016a410 - ~GroupImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + ~GroupImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -369,12 +418,29 @@ class GroupImpl : public Group { IDirect3DRMFrame2* ImplementationData() const { return m_data; } + inline void Destroy(); + friend class RendererImpl; private: IDirect3DRMFrame2* m_data; }; +// FUNCTION: BETA10 0x1016c2b0 +inline void GroupDestroy(IDirect3DRMFrame2* pGroup) +{ + pGroup->Release(); +} + +// FUNCTION: BETA10 0x1016c270 +void GroupImpl::Destroy() +{ + if (m_data) { + GroupDestroy(m_data); + m_data = NULL; + } +} + // VTABLE: LEGO1 0x100dbb18 // VTABLE: BETA10 0x101c3270 class MeshBuilderImpl : public MeshBuilder { @@ -383,13 +449,7 @@ class MeshBuilderImpl : public MeshBuilder { MeshBuilderImpl() : m_data(0) {} // FUNCTION: BETA10 0x1016f5c0 - ~MeshBuilderImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + ~MeshBuilderImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -411,6 +471,8 @@ class MeshBuilderImpl : public MeshBuilder { IDirect3DRMMesh* ImplementationData() const { return m_data; } + inline void Destroy(); + friend class RendererImpl; private: @@ -429,6 +491,21 @@ class MeshBuilderImpl : public MeshBuilder { IDirect3DRMMesh* m_data; }; +// FUNCTION: BETA10 0x10171220 +inline void MeshBuilderDestroy(IDirect3DRMMesh* pMeshBuilder) +{ + pMeshBuilder->Release(); +} + +// FUNCTION: BETA10 0x101711e0 +void MeshBuilderImpl::Destroy() +{ + if (m_data) { + MeshBuilderDestroy(m_data); + m_data = NULL; + } +} + // No vtable, this is just a simple wrapper around D3DRMIMAGE class TglD3DRMIMAGE { public: @@ -460,13 +537,7 @@ class TextureImpl : public Texture { TextureImpl() : m_data(0) {} // FUNCTION: BETA10 0x1016c2d0 - ~TextureImpl() override - { - if (m_data) { - m_data->Release(); - m_data = NULL; - } - } + ~TextureImpl() override { Destroy(); } void* ImplementationDataPtr() override; @@ -489,6 +560,8 @@ class TextureImpl : public Texture { IDirect3DRMTexture* ImplementationData() const { return m_data; } void SetImplementation(IDirect3DRMTexture* pData) { m_data = pData; } + inline void Destroy(); + friend class RendererImpl; static Result SetImage(IDirect3DRMTexture* pSelf, TglD3DRMIMAGE* pImage); @@ -497,6 +570,21 @@ class TextureImpl : public Texture { IDirect3DRMTexture* m_data; }; +// FUNCTION: BETA10 0x1016fd40 +inline void TextureDestroy(IDirect3DRMTexture* pTexture) +{ + pTexture->Release(); +} + +// FUNCTION: BETA10 0x1016fd00 +void TextureImpl::Destroy() +{ + if (m_data) { + TextureDestroy(m_data); + m_data = NULL; + } +} + // Translation helpers inline D3DRMRENDERQUALITY Translate(ShadingModel tglShadingModel) {