From 834a977330fbb22cc0389502b31da05bdf640b16 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Sun, 2 Nov 2025 17:45:35 -0500 Subject: [PATCH 1/3] refactor(w3dview): replace custom MEMBER_ADD/MEMBER_RELEASE macros with core library REF_PTR_SET/REF_PTR_RELEASE --- Core/Tools/W3DView/AdvancedAnimSheet.cpp | 7 ++-- Core/Tools/W3DView/AssetInfo.cpp | 5 ++- Core/Tools/W3DView/AssetInfo.h | 8 ++-- Core/Tools/W3DView/BoneMgrDialog.cpp | 13 ++++--- Core/Tools/W3DView/DataTreeView.cpp | 13 ++++--- Core/Tools/W3DView/EditLODDialog.cpp | 5 ++- Core/Tools/W3DView/EmitterInstanceList.cpp | 5 ++- Core/Tools/W3DView/EmitterPropertySheet.cpp | 5 ++- Core/Tools/W3DView/GraphicView.cpp | 7 ++-- Core/Tools/W3DView/PlaySoundDialog.cpp | 3 +- Core/Tools/W3DView/RingPropertySheet.cpp | 9 +++-- Core/Tools/W3DView/ScreenCursor.cpp | 3 +- Core/Tools/W3DView/SpherePropertySheet.cpp | 9 +++-- Core/Tools/W3DView/TextureMgrDialog.cpp | 7 ++-- Core/Tools/W3DView/TextureMgrDialog.h | 6 +-- Core/Tools/W3DView/TextureSettingsDialog.cpp | 7 ++-- Core/Tools/W3DView/Utils.cpp | 7 ++-- Core/Tools/W3DView/Utils.h | 21 ---------- Core/Tools/W3DView/W3DViewDoc.cpp | 41 ++++++++++---------- 19 files changed, 88 insertions(+), 93 deletions(-) diff --git a/Core/Tools/W3DView/AdvancedAnimSheet.cpp b/Core/Tools/W3DView/AdvancedAnimSheet.cpp index 5da4fb8e96..13ddc37d92 100644 --- a/Core/Tools/W3DView/AdvancedAnimSheet.cpp +++ b/Core/Tools/W3DView/AdvancedAnimSheet.cpp @@ -23,6 +23,7 @@ #include "W3DView.h" #include "W3DViewDoc.h" #include "AdvancedAnimSheet.h" +#include "refcount.h" #include "assetmgr.h" #include "hanim.h" @@ -77,7 +78,7 @@ CAdvancedAnimSheet::~CAdvancedAnimSheet() { for (int i = 0; i < AnimCount; i++) { - MEMBER_RELEASE(Anims[i]); + REF_PTR_RELEASE(Anims[i]); } AnimsValid = false; AnimCount = 0; @@ -162,7 +163,7 @@ void CAdvancedAnimSheet::LoadAnims (void) // Add this Anims pointer to the array. if (AnimCount < MAX_REPORT_ANIMS) { - MEMBER_ADD(Anims[AnimCount], pHierarchyAnim); + REF_PTR_SET(Anims[AnimCount], pHierarchyAnim); AnimCount++; } else @@ -176,7 +177,7 @@ void CAdvancedAnimSheet::LoadAnims (void) } // Release our hold on this animation. - MEMBER_RELEASE(pHierarchyAnim); + REF_PTR_RELEASE(pHierarchyAnim); } } diff --git a/Core/Tools/W3DView/AssetInfo.cpp b/Core/Tools/W3DView/AssetInfo.cpp index 60c7f210c2..1b991ea2e9 100644 --- a/Core/Tools/W3DView/AssetInfo.cpp +++ b/Core/Tools/W3DView/AssetInfo.cpp @@ -37,6 +37,7 @@ #include "StdAfx.h" #include "AssetInfo.h" +#include "refcount.h" //#include "HModel.h" #include "assetmgr.h" #include "htree.h" @@ -53,7 +54,7 @@ AssetInfoClass::Initialize (void) // Assume we are wrapping an instance as apposed to an asset 'name'. RenderObjClass *prender_obj = m_pRenderObj; - SAFE_ADD_REF (prender_obj); + if (prender_obj) prender_obj->Add_Ref(); // If we are wrapping an asset name, then create an instance of it. if (prender_obj == NULL) { @@ -72,7 +73,7 @@ AssetInfoClass::Initialize (void) } // Release our hold on the temporary object - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } return ; diff --git a/Core/Tools/W3DView/AssetInfo.h b/Core/Tools/W3DView/AssetInfo.h index b93944c093..1ba0adf5e0 100644 --- a/Core/Tools/W3DView/AssetInfo.h +++ b/Core/Tools/W3DView/AssetInfo.h @@ -65,9 +65,9 @@ class AssetInfoClass : m_Name (passet_name), m_AssetType (type), m_dwUserData (user_data), - m_pRenderObj (NULL) { MEMBER_ADD (m_pRenderObj, prender_obj); Initialize (); } + m_pRenderObj (NULL) { REF_PTR_SET (m_pRenderObj, prender_obj); Initialize (); } - virtual ~AssetInfoClass (void) { MEMBER_RELEASE (m_pRenderObj); } + virtual ~AssetInfoClass (void) { REF_PTR_RELEASE (m_pRenderObj); } ////////////////////////////////////////////////////////////// // @@ -83,14 +83,14 @@ class AssetInfoClass ASSET_TYPE Get_Type (void) const { return m_AssetType; } DWORD Get_User_Number (void) const { return m_dwUserData; } const CString & Get_User_String (void) const { return m_UserString; } - RenderObjClass * Get_Render_Obj (void) const { SAFE_ADD_REF (m_pRenderObj); return m_pRenderObj; } + RenderObjClass * Get_Render_Obj (void) const { if (m_pRenderObj) m_pRenderObj->Add_Ref(); return m_pRenderObj; } RenderObjClass * Peek_Render_Obj (void) const { return m_pRenderObj; } void Set_Name (LPCTSTR pname) { m_Name = pname; } void Set_Hierarchy_Name (LPCTSTR pname) { m_HierarchyName = pname; } void Set_Type (ASSET_TYPE type) { m_AssetType = type; } void Set_User_Number (DWORD user_data) { m_dwUserData = user_data; } void Set_User_String (LPCTSTR string) { m_UserString = string; } - void Set_Render_Obj (RenderObjClass *pobj) { MEMBER_ADD (m_pRenderObj, pobj); } + void Set_Render_Obj (RenderObjClass *pobj) { REF_PTR_SET (m_pRenderObj, pobj); } // // Information methods diff --git a/Core/Tools/W3DView/BoneMgrDialog.cpp b/Core/Tools/W3DView/BoneMgrDialog.cpp index ab8cd54864..e86014f6e7 100644 --- a/Core/Tools/W3DView/BoneMgrDialog.cpp +++ b/Core/Tools/W3DView/BoneMgrDialog.cpp @@ -22,6 +22,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "BoneMgrDialog.h" +#include "refcount.h" #include "htree.h" #include "assetmgr.h" #include "Utils.h" @@ -222,15 +223,15 @@ BoneMgrDialogClass::Fill_Bone_Item // Free our hold on the render objs in the original node list for (index = 0; index < orig_node_list.Count (); index ++) { - MEMBER_RELEASE (orig_node_list[index]); + REF_PTR_RELEASE (orig_node_list[index]); } // Free our hold on the render objs in the node list for (index = 0; index < node_list.Count (); index ++) { - MEMBER_RELEASE (node_list[index]); + REF_PTR_RELEASE (node_list[index]); } - MEMBER_RELEASE (porig_model); + REF_PTR_RELEASE (porig_model); return ; } @@ -405,7 +406,7 @@ void BoneMgrDialogClass::OnOK (void) { // Simply forget about the backup we made - MEMBER_RELEASE (m_pBackupModel); + REF_PTR_RELEASE (m_pBackupModel); // Update the hierarchy's cached information to reflect the new settings CW3DViewDoc *pdoc = (CW3DViewDoc *)((CMainFrame *)::AfxGetMainWnd())->GetActiveDocument (); @@ -459,7 +460,7 @@ BoneMgrDialogClass::OnAttachButton (void) if (prender_obj != NULL) { m_pBaseModel->Add_Sub_Object_To_Bone (prender_obj, m_BoneName); m_BoneTree.InsertItem (name, 1, 1, hbone_item); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } } else { @@ -481,7 +482,7 @@ BoneMgrDialogClass::OnAttachButton (void) } // Release our hold on this pointer - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // Remove the object from our UI diff --git a/Core/Tools/W3DView/DataTreeView.cpp b/Core/Tools/W3DView/DataTreeView.cpp index 88fea23b65..bff83dfb25 100644 --- a/Core/Tools/W3DView/DataTreeView.cpp +++ b/Core/Tools/W3DView/DataTreeView.cpp @@ -38,6 +38,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "DataTreeView.h" +#include "refcount.h" #include "rendobj.h" #include "ViewerAssetMgr.h" #include "Globals.h" @@ -521,7 +522,7 @@ CDataTreeView::LoadAnimationsIntoTree (void) } // Release our hold on this animation... - MEMBER_RELEASE (pHierarchyAnim); + REF_PTR_RELEASE (pHierarchyAnim); } } @@ -583,7 +584,7 @@ CDataTreeView::LoadAnimationsIntoTree (HTREEITEM hItem) } // Release our hold on the animation object - MEMBER_RELEASE (pHierarchyAnim); + REF_PTR_RELEASE (pHierarchyAnim); } } @@ -1009,7 +1010,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) RenderObjClass *prender_obj = Create_Render_Obj_To_Display (hParentItem); pdoc->PlayAnimation (prender_obj, asset_info->Get_Name ()); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } } break; @@ -1019,7 +1020,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) // Ask the document to display this object ParticleEmitterClass *emitter = (ParticleEmitterClass *)Create_Render_Obj_To_Display (htree_item); pdoc->Display_Emitter (emitter); - MEMBER_RELEASE (emitter); + REF_PTR_RELEASE (emitter); } break; @@ -1035,7 +1036,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) // Ask the document to display this object RenderObjClass *prender_obj = Create_Render_Obj_To_Display (htree_item); pdoc->DisplayObject (prender_obj); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } break; } @@ -1478,7 +1479,7 @@ Set_Highest_LOD (RenderObjClass *render_obj) if (sub_obj != NULL) { Set_Highest_LOD (sub_obj); } - MEMBER_RELEASE (sub_obj); + REF_PTR_RELEASE (sub_obj); } // diff --git a/Core/Tools/W3DView/EditLODDialog.cpp b/Core/Tools/W3DView/EditLODDialog.cpp index bdd7bf2aac..32c71cadb5 100644 --- a/Core/Tools/W3DView/EditLODDialog.cpp +++ b/Core/Tools/W3DView/EditLODDialog.cpp @@ -22,6 +22,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "EditLODDialog.h" +#include "refcount.h" #include "distlod.h" #include "Utils.h" #include "rendobj.h" @@ -119,7 +120,7 @@ CEditLODDialog::OnInitDialog (void) RenderObjClass *pfirst_subobj = pLOD->Get_Sub_Object (0); if (pfirst_subobj != NULL) { m_spinIncrement = pfirst_subobj->Get_Bounding_Sphere ().Radius / 5.0F; - MEMBER_RELEASE (pfirst_subobj); + REF_PTR_RELEASE (pfirst_subobj); } // Loop through all the subobjects @@ -142,7 +143,7 @@ CEditLODDialog::OnInitDialog (void) m_hierarchyListCtrl.SetItemText (iIndex, COL_SWITCH_DN, stringTemp); // Free this object - MEMBER_RELEASE (pCSubObject); + REF_PTR_RELEASE (pCSubObject); } } diff --git a/Core/Tools/W3DView/EmitterInstanceList.cpp b/Core/Tools/W3DView/EmitterInstanceList.cpp index d8d20d5f67..1f3009993b 100644 --- a/Core/Tools/W3DView/EmitterInstanceList.cpp +++ b/Core/Tools/W3DView/EmitterInstanceList.cpp @@ -33,6 +33,7 @@ #include "StdAfx.h" #include "EmitterInstanceList.h" +#include "refcount.h" #include "Utils.h" ///////////////////////////////////////////////////////////////////// @@ -59,7 +60,7 @@ EmitterInstanceListClass::Free_List (void) // Release our hold on each of the emitter pointers // for (int index = 0; index < m_List.Count (); index ++) { - MEMBER_RELEASE (m_List[index]); + REF_PTR_RELEASE (m_List[index]); } m_List.Delete_All (); @@ -93,7 +94,7 @@ EmitterInstanceListClass::Add_Emitter (ParticleEmitterClass *emitter) // // Add this emitter to the list and put a hold on its reference // - SAFE_ADD_REF (emitter); + if (emitter) emitter->Add_Ref(); m_List.Add (emitter); } diff --git a/Core/Tools/W3DView/EmitterPropertySheet.cpp b/Core/Tools/W3DView/EmitterPropertySheet.cpp index 7dc9c5f0fd..2e6873df6e 100644 --- a/Core/Tools/W3DView/EmitterPropertySheet.cpp +++ b/Core/Tools/W3DView/EmitterPropertySheet.cpp @@ -33,6 +33,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "EmitterPropertySheet.h" +#include "refcount.h" #include "part_emt.h" #include "part_ldr.h" #include "assetmgr.h" @@ -265,7 +266,7 @@ EmitterPropertySheetClass::Update_Emitter (void) // // Use this emitter as the edited emitter from here on out // - MEMBER_RELEASE (m_pEmitter); + REF_PTR_RELEASE (m_pEmitter); m_pEmitter = pemitter;*/ // Pass the emitter along to the pages @@ -501,7 +502,7 @@ EmitterPropertySheetClass::Create_New_Emitter (void) // Display the new emitter // ::GetCurrentDocument ()->Display_Emitter (emitter); - MEMBER_RELEASE (emitter); + REF_PTR_RELEASE (emitter); /*SAFE_DELETE_ARRAY (color.Values); SAFE_DELETE_ARRAY (color.KeyTimes); diff --git a/Core/Tools/W3DView/GraphicView.cpp b/Core/Tools/W3DView/GraphicView.cpp index f072b2fba7..1cc81f6b2f 100644 --- a/Core/Tools/W3DView/GraphicView.cpp +++ b/Core/Tools/W3DView/GraphicView.cpp @@ -22,6 +22,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "GraphicView.h" +#include "refcount.h" #include "ww3d.h" #include "Globals.h" #include "W3DViewDoc.h" @@ -329,8 +330,8 @@ CGraphicView::OnDestroy (void) // // Free the camera object // - MEMBER_RELEASE (m_pCamera); - MEMBER_RELEASE (m_pLightMesh); + REF_PTR_RELEASE (m_pCamera); + REF_PTR_RELEASE (m_pLightMesh); // Is there an update thread running? if (m_TimerID == 0) { @@ -388,7 +389,7 @@ Set_Lowest_LOD (RenderObjClass *render_obj) if (psub_obj != NULL) { Set_Lowest_LOD (psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // diff --git a/Core/Tools/W3DView/PlaySoundDialog.cpp b/Core/Tools/W3DView/PlaySoundDialog.cpp index 78ec632014..6988aae536 100644 --- a/Core/Tools/W3DView/PlaySoundDialog.cpp +++ b/Core/Tools/W3DView/PlaySoundDialog.cpp @@ -21,6 +21,7 @@ #include "StdAfx.h" #include "PlaySoundDialog.h" +#include "refcount.h" #include "Utils.h" #include "AudibleSound.h" @@ -100,7 +101,7 @@ void PlaySoundDialogClass::OnCancel (void) { SoundObj->Stop (); - MEMBER_RELEASE (SoundObj); + REF_PTR_RELEASE (SoundObj); CDialog::OnCancel (); return ; diff --git a/Core/Tools/W3DView/RingPropertySheet.cpp b/Core/Tools/W3DView/RingPropertySheet.cpp index d4e89914c9..aeca496b73 100644 --- a/Core/Tools/W3DView/RingPropertySheet.cpp +++ b/Core/Tools/W3DView/RingPropertySheet.cpp @@ -22,6 +22,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "RingPropertySheet.h" +#include "refcount.h" #include "Utils.h" #include "W3DViewDoc.h" #include "assetmgr.h" @@ -51,7 +52,7 @@ RingPropertySheetClass::RingPropertySheetClass : m_RenderObj (NULL), CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, ring); + REF_PTR_SET (m_RenderObj, ring); Initialize (); return ; } @@ -72,7 +73,7 @@ RingPropertySheetClass::RingPropertySheetClass : m_RenderObj (NULL), CPropertySheet(pszCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, ring); + REF_PTR_SET (m_RenderObj, ring); Initialize (); return ; } @@ -85,7 +86,7 @@ RingPropertySheetClass::RingPropertySheetClass ///////////////////////////////////////////////////////////////////////////// RingPropertySheetClass::~RingPropertySheetClass (void) { - MEMBER_RELEASE (m_RenderObj); + REF_PTR_RELEASE (m_RenderObj); return ; } @@ -204,7 +205,7 @@ RingPropertySheetClass::Add_Object_To_Viewer (void) // doc->Reload_Displayed_Object (); m_LastSavedName = m_RenderObj->Get_Name (); - MEMBER_ADD (m_RenderObj, (RingRenderObjClass *)doc->GetDisplayedObject ()); + REF_PTR_SET (m_RenderObj, (RingRenderObjClass *)doc->GetDisplayedObject ()); // // Pass the object along to the pages diff --git a/Core/Tools/W3DView/ScreenCursor.cpp b/Core/Tools/W3DView/ScreenCursor.cpp index 8b8d67f0a0..37e78b4aae 100644 --- a/Core/Tools/W3DView/ScreenCursor.cpp +++ b/Core/Tools/W3DView/ScreenCursor.cpp @@ -33,6 +33,7 @@ #include "StdAfx.h" #include "ScreenCursor.h" +#include "refcount.h" #include "Utils.h" #include "ww3d.h" #include "vertmaterial.h" @@ -153,7 +154,7 @@ ScreenCursorClass::Initialize (void) void ScreenCursorClass::Set_Texture (TextureClass *texture) { - MEMBER_ADD (m_pTexture, texture); + REF_PTR_SET (m_pTexture, texture); // Find the dimensions of the texture: if (m_pTexture != NULL) { diff --git a/Core/Tools/W3DView/SpherePropertySheet.cpp b/Core/Tools/W3DView/SpherePropertySheet.cpp index cdeaa7de6f..7a447640bb 100644 --- a/Core/Tools/W3DView/SpherePropertySheet.cpp +++ b/Core/Tools/W3DView/SpherePropertySheet.cpp @@ -22,6 +22,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "SpherePropertySheet.h" +#include "refcount.h" #include "Utils.h" #include "W3DViewDoc.h" #include "assetmgr.h" @@ -51,7 +52,7 @@ SpherePropertySheetClass::SpherePropertySheetClass : m_RenderObj (NULL), CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, sphere); + REF_PTR_SET (m_RenderObj, sphere); Initialize (); return ; } @@ -72,7 +73,7 @@ SpherePropertySheetClass::SpherePropertySheetClass : m_RenderObj (NULL), CPropertySheet(pszCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, sphere); + REF_PTR_SET (m_RenderObj, sphere); Initialize (); return ; } @@ -85,7 +86,7 @@ SpherePropertySheetClass::SpherePropertySheetClass ///////////////////////////////////////////////////////////////////////////// SpherePropertySheetClass::~SpherePropertySheetClass (void) { - MEMBER_RELEASE (m_RenderObj); + REF_PTR_RELEASE (m_RenderObj); return ; } @@ -204,7 +205,7 @@ SpherePropertySheetClass::Add_Object_To_Viewer (void) // doc->Reload_Displayed_Object (); m_LastSavedName = m_RenderObj->Get_Name (); - MEMBER_ADD (m_RenderObj, (SphereRenderObjClass *)doc->GetDisplayedObject ()); + REF_PTR_SET (m_RenderObj, (SphereRenderObjClass *)doc->GetDisplayedObject ()); // // Pass the object along to the pages diff --git a/Core/Tools/W3DView/TextureMgrDialog.cpp b/Core/Tools/W3DView/TextureMgrDialog.cpp index e05712f75a..150eaef29f 100644 --- a/Core/Tools/W3DView/TextureMgrDialog.cpp +++ b/Core/Tools/W3DView/TextureMgrDialog.cpp @@ -38,6 +38,7 @@ #include "StdAfx.h" #include "W3DView.h" #include "TextureMgrDialog.h" +#include "refcount.h" #include "Mesh.h" #include "MatInfo.h" #include "TextureSettingsDialog.h" @@ -283,7 +284,7 @@ TextureMgrDialogClass::Add_Subobjs_To_List (RenderObjClass *prender_obj) // Recursively add subobjs to the list Add_Subobjs_To_List (psubobj); - MEMBER_RELEASE (psubobj); + REF_PTR_RELEASE (psubobj); } } @@ -336,7 +337,7 @@ TextureMgrDialogClass::Add_Textures_To_Node } // Release our hold on this pointer - MEMBER_RELEASE (pmat_info); + REF_PTR_RELEASE (pmat_info); } return ; @@ -438,7 +439,7 @@ TextureMgrDialogClass::OnDblclkMeshTextureListCtrl SR_RELEASE (poriginal_texture); } - MEMBER_RELEASE (pmat_info); + REF_PTR_RELEASE (pmat_info); } } diff --git a/Core/Tools/W3DView/TextureMgrDialog.h b/Core/Tools/W3DView/TextureMgrDialog.h index ede44585ef..1e109aa479 100644 --- a/Core/Tools/W3DView/TextureMgrDialog.h +++ b/Core/Tools/W3DView/TextureMgrDialog.h @@ -91,9 +91,9 @@ class TextureListNodeClass m_pParent (NULL), m_Name (name), m_TextureIndex (0), - m_IconIndex (ICON_DEF_TEXTURE) { MEMBER_ADD (m_pTexture, ptexture); } + m_IconIndex (ICON_DEF_TEXTURE) { REF_PTR_SET (m_pTexture, ptexture); } - ~TextureListNodeClass (void) { MEMBER_RELEASE (m_pTexture); Free_Subobj_List (); } + ~TextureListNodeClass (void) { REF_PTR_RELEASE (m_pTexture); Free_Subobj_List (); } //////////////////////////////////////////////////////////// @@ -107,7 +107,7 @@ class TextureListNodeClass void Set_Type (NODE_TYPE type) { m_Type = type; } TextureClass * Peek_Texture (void) const { return m_pTexture; } - void Set_Texture (TextureClass *ptex) { MEMBER_ADD (m_pTexture, ptex); } + void Set_Texture (TextureClass *ptex) { REF_PTR_SET (m_pTexture, ptex); } TEXTURE_NODE_LIST & Get_Subobj_List (void) { return m_SubObjectList; } diff --git a/Core/Tools/W3DView/TextureSettingsDialog.cpp b/Core/Tools/W3DView/TextureSettingsDialog.cpp index f84e79e94a..1c7fd13aba 100644 --- a/Core/Tools/W3DView/TextureSettingsDialog.cpp +++ b/Core/Tools/W3DView/TextureSettingsDialog.cpp @@ -35,6 +35,7 @@ #include "Texture.h" #include "W3DView.h" #include "TextureSettingsDialog.h" +#include "refcount.h" #include "Utils.h" #include "AssetMgr.h" @@ -79,8 +80,8 @@ TextureSettingsDialogClass::TextureSettingsDialogClass { //{{AFX_DATA_INIT(TextureSettingsDialogClass) //}}AFX_DATA_INIT - MEMBER_ADD (m_pTexture, ptexture); - MEMBER_ADD (m_pOriginalTexture, poriginal_texture); + REF_PTR_SET (m_pTexture, ptexture); + REF_PTR_SET (m_pOriginalTexture, poriginal_texture); return ; } @@ -528,7 +529,7 @@ TextureSettingsDialogClass::OnRestore (void) // Get the original texture TextureClass *pnew_texture = m_pOriginalTexture->Get_Texture (); m_pTexture->Set_Texture (pnew_texture); - MEMBER_RELEASE (pnew_texture); + REF_PTR_RELEASE (pnew_texture); // Reload the dialog control settings Load_Texture_Settings (); diff --git a/Core/Tools/W3DView/Utils.cpp b/Core/Tools/W3DView/Utils.cpp index ea565a19c4..f255cf43d5 100644 --- a/Core/Tools/W3DView/Utils.cpp +++ b/Core/Tools/W3DView/Utils.cpp @@ -27,6 +27,7 @@ #include "StdAfx.h" #include "W3DViewDoc.h" #include "MainFrm.h" +#include "refcount.h" #include "DataTreeView.h" #include "Utils.h" #include "texture.h" @@ -559,7 +560,7 @@ Build_Emitter_List // Recursivly add emitters to the list Build_Emitter_List (*psub_obj, list); - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } } @@ -586,7 +587,7 @@ Is_Aggregate (const char *asset_name) } // Free our hold on the temporary render object - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); // Return the true/false result code return retval; @@ -649,7 +650,7 @@ Is_Real_LOD (const char *asset_name) } // Free our hold on the temporary render object - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); // Return the true/false result code return retval; diff --git a/Core/Tools/W3DView/Utils.h b/Core/Tools/W3DView/Utils.h index 8316f899e9..afd07056a7 100644 --- a/Core/Tools/W3DView/Utils.h +++ b/Core/Tools/W3DView/Utils.h @@ -38,27 +38,6 @@ class RenderObjClass; #define SAFE_DELETE(pobject) { delete pobject; pobject = NULL; } #define SAFE_DELETE_ARRAY(pobject) { delete [] pobject; pobject = NULL; } -#define SAFE_ADD_REF(pobject) \ - if (pobject) { \ - pobject->Add_Ref (); \ - } \ - -#define SAFE_RELEASE_REF(pobject) \ - if (pobject) { \ - pobject->Release_Ref (); \ - } \ - -#define MEMBER_RELEASE(pmember) \ - SAFE_RELEASE_REF(pmember); \ - pmember = NULL; \ - - -#define MEMBER_ADD(pmember, pnew) \ - MEMBER_RELEASE (pmember); \ - pmember = pnew; \ - SAFE_ADD_REF (pmember); \ - - #define COM_RELEASE(pobject) \ if (pobject) { \ pobject->Release (); \ diff --git a/Core/Tools/W3DView/W3DViewDoc.cpp b/Core/Tools/W3DView/W3DViewDoc.cpp index f67232afcd..5216ed461a 100644 --- a/Core/Tools/W3DView/W3DViewDoc.cpp +++ b/Core/Tools/W3DView/W3DViewDoc.cpp @@ -42,6 +42,7 @@ #include "Utils.h" #include "w3derr.h" #include "chunkio.h" +#include "refcount.h" #include "AssetInfo.h" #include "meshmdl.h" #include "agg_def.h" @@ -130,7 +131,7 @@ CW3DViewDoc::CW3DViewDoc (void) CW3DViewDoc::~CW3DViewDoc (void) { CleanupResources (); - MEMBER_RELEASE (m_pCursor); + REF_PTR_RELEASE (m_pCursor); return ; } @@ -172,7 +173,7 @@ CW3DViewDoc::CleanupResources (void) if (m_pCursor != NULL) { m_pCursor->Remove (); } - MEMBER_RELEASE (m_pCursorScene); + REF_PTR_RELEASE (m_pCursorScene); if (m_pCScene) { @@ -243,8 +244,8 @@ CW3DViewDoc::CleanupResources (void) { // Free the currently displayed object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); - MEMBER_RELEASE (m_pCRenderObj); + REF_PTR_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCRenderObj); } return ; @@ -284,8 +285,8 @@ CW3DViewDoc::OnNewDocument (void) { // Free the currently displayed object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); - MEMBER_RELEASE (m_pCRenderObj); + REF_PTR_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCRenderObj); } CDataTreeView *pCDataTreeView = GetDataTreeView (); @@ -610,7 +611,7 @@ CW3DViewDoc::Display_Emitter // Lose the animation SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); if (m_pCRenderObj != NULL) { @@ -626,7 +627,7 @@ CW3DViewDoc::Display_Emitter // Add the emitter to the scene pemitter->Set_Transform (Matrix3D (1)); - MEMBER_ADD (m_pCRenderObj, pemitter); + REF_PTR_SET (m_pCRenderObj, pemitter); m_pCScene->Add_Render_Object (m_pCRenderObj); pemitter->Start (); @@ -669,7 +670,7 @@ CW3DViewDoc::DisplayObject { // Lose the animation SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); // Do we have an old object to remove from the scene? if (add_ghost == false) { @@ -874,7 +875,7 @@ CW3DViewDoc::PlayAnimation // Get an instance of the animation object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); m_pCAnimation = WW3DAssetManager::Get_Instance()->Get_HAnim (pszAnimationName); ASSERT (m_pCAnimation); @@ -966,7 +967,7 @@ CW3DViewDoc::PlayAnimation // Get an instance of the animation object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); m_pCAnimCombo = pCAnimCombo; m_pCAnimation = m_pCAnimCombo->Get_Motion(0); // ref added by get_motion ASSERT (m_pCAnimation); @@ -1026,7 +1027,7 @@ Get_Camera_Transform (RenderObjClass *render_obj, Matrix3D &tm) if (psub_obj != NULL) { retval = Get_Camera_Transform (psub_obj, tm); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } if (!retval) { @@ -1248,11 +1249,11 @@ CW3DViewDoc::GenerateLOD HLodDefClass *pdefinition = new HLodDefClass (*pnew_lod); plod_prototype = new HLodPrototypeClass (pdefinition); - MEMBER_RELEASE (pnew_lod); + REF_PTR_RELEASE (pnew_lod); // Loop through all the LOD definitions and free their names for (lod_index = 0; lod_index < lod_count; lod_index ++) { - MEMBER_RELEASE (plod_array[lod_index]); + REF_PTR_RELEASE (plod_array[lod_index]); } // Free the LOD definition array @@ -1889,7 +1890,7 @@ CW3DViewDoc::Remove_Object_From_Scene (RenderObjClass *prender_obj) if (psub_obj != NULL) { Remove_Object_From_Scene (psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // If this is an emitter, then remove its buffer @@ -2254,7 +2255,7 @@ CW3DViewDoc::Auto_Assign_Bones (void) // Add this render object to the bone RenderObjClass *prender_obj = WW3DAssetManager::Get_Instance ()->Create_Render_Obj (pbone_name); m_pCRenderObj->Add_Sub_Object_To_Bone (prender_obj, index); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); bupdate_prototype = true; } } @@ -2536,7 +2537,7 @@ CW3DViewDoc::Build_Emitter_List if (psub_obj != NULL) { Build_Emitter_List (emitter_list, emitter_name, psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // @@ -2639,7 +2640,7 @@ CW3DViewDoc::Count_Particles (RenderObjClass *render_obj) if (psub_obj != NULL) { count += Count_Particles (psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } @@ -2699,7 +2700,7 @@ CW3DViewDoc::Switch_LOD (int increment, RenderObjClass *render_obj) if (psub_obj != NULL) { Switch_LOD (increment, psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // @@ -2970,7 +2971,7 @@ CW3DViewDoc::Import_Facial_Animation (const CString &heirarchy_name, const CStri // Cleanup // anim_desc_file->Close (); - MEMBER_RELEASE (new_anim); + REF_PTR_RELEASE (new_anim); SAFE_DELETE (anim_desc_file); } From f060ce507fd42223001da70697d532161a48c9b4 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Mon, 3 Nov 2025 14:29:40 -0500 Subject: [PATCH 2/3] refactor(w3dview): fix code formatting for if statements with Add_Ref calls --- Core/Tools/W3DView/AssetInfo.cpp | 3 ++- Core/Tools/W3DView/EmitterInstanceList.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/Tools/W3DView/AssetInfo.cpp b/Core/Tools/W3DView/AssetInfo.cpp index 1b991ea2e9..f7e257c7f1 100644 --- a/Core/Tools/W3DView/AssetInfo.cpp +++ b/Core/Tools/W3DView/AssetInfo.cpp @@ -54,7 +54,8 @@ AssetInfoClass::Initialize (void) // Assume we are wrapping an instance as apposed to an asset 'name'. RenderObjClass *prender_obj = m_pRenderObj; - if (prender_obj) prender_obj->Add_Ref(); + if (prender_obj) + prender_obj->Add_Ref(); // If we are wrapping an asset name, then create an instance of it. if (prender_obj == NULL) { diff --git a/Core/Tools/W3DView/EmitterInstanceList.cpp b/Core/Tools/W3DView/EmitterInstanceList.cpp index 1f3009993b..aa4f8889ec 100644 --- a/Core/Tools/W3DView/EmitterInstanceList.cpp +++ b/Core/Tools/W3DView/EmitterInstanceList.cpp @@ -94,7 +94,8 @@ EmitterInstanceListClass::Add_Emitter (ParticleEmitterClass *emitter) // // Add this emitter to the list and put a hold on its reference // - if (emitter) emitter->Add_Ref(); + if (emitter) + emitter->Add_Ref(); m_List.Add (emitter); } From 18ce073a8aa6fb07bf6dc2cf0de5e2279acd0ca8 Mon Sep 17 00:00:00 2001 From: Bobby Battista Date: Thu, 6 Nov 2025 03:17:17 -0500 Subject: [PATCH 3/3] refactor(w3dview): remove redundant refcount.h includes now that it's in WWCommon.h --- Core/Tools/W3DView/AdvancedAnimSheet.cpp | 1 - Core/Tools/W3DView/AssetInfo.cpp | 1 - Core/Tools/W3DView/BoneMgrDialog.cpp | 1 - Core/Tools/W3DView/DataTreeView.cpp | 1 - Core/Tools/W3DView/EditLODDialog.cpp | 1 - Core/Tools/W3DView/EmitterInstanceList.cpp | 1 - Core/Tools/W3DView/EmitterPropertySheet.cpp | 1 - Core/Tools/W3DView/GraphicView.cpp | 1 - Core/Tools/W3DView/PlaySoundDialog.cpp | 1 - Core/Tools/W3DView/RingPropertySheet.cpp | 1 - Core/Tools/W3DView/ScreenCursor.cpp | 1 - Core/Tools/W3DView/SpherePropertySheet.cpp | 1 - Core/Tools/W3DView/TextureMgrDialog.cpp | 1 - Core/Tools/W3DView/TextureSettingsDialog.cpp | 1 - Core/Tools/W3DView/Utils.cpp | 1 - Core/Tools/W3DView/W3DViewDoc.cpp | 1 - 16 files changed, 16 deletions(-) diff --git a/Core/Tools/W3DView/AdvancedAnimSheet.cpp b/Core/Tools/W3DView/AdvancedAnimSheet.cpp index 13ddc37d92..4c57a38b2d 100644 --- a/Core/Tools/W3DView/AdvancedAnimSheet.cpp +++ b/Core/Tools/W3DView/AdvancedAnimSheet.cpp @@ -23,7 +23,6 @@ #include "W3DView.h" #include "W3DViewDoc.h" #include "AdvancedAnimSheet.h" -#include "refcount.h" #include "assetmgr.h" #include "hanim.h" diff --git a/Core/Tools/W3DView/AssetInfo.cpp b/Core/Tools/W3DView/AssetInfo.cpp index f7e257c7f1..3b7092dcc6 100644 --- a/Core/Tools/W3DView/AssetInfo.cpp +++ b/Core/Tools/W3DView/AssetInfo.cpp @@ -37,7 +37,6 @@ #include "StdAfx.h" #include "AssetInfo.h" -#include "refcount.h" //#include "HModel.h" #include "assetmgr.h" #include "htree.h" diff --git a/Core/Tools/W3DView/BoneMgrDialog.cpp b/Core/Tools/W3DView/BoneMgrDialog.cpp index e86014f6e7..57ed30814e 100644 --- a/Core/Tools/W3DView/BoneMgrDialog.cpp +++ b/Core/Tools/W3DView/BoneMgrDialog.cpp @@ -22,7 +22,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "BoneMgrDialog.h" -#include "refcount.h" #include "htree.h" #include "assetmgr.h" #include "Utils.h" diff --git a/Core/Tools/W3DView/DataTreeView.cpp b/Core/Tools/W3DView/DataTreeView.cpp index bff83dfb25..1b5a31d163 100644 --- a/Core/Tools/W3DView/DataTreeView.cpp +++ b/Core/Tools/W3DView/DataTreeView.cpp @@ -38,7 +38,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "DataTreeView.h" -#include "refcount.h" #include "rendobj.h" #include "ViewerAssetMgr.h" #include "Globals.h" diff --git a/Core/Tools/W3DView/EditLODDialog.cpp b/Core/Tools/W3DView/EditLODDialog.cpp index 32c71cadb5..f00c487d6f 100644 --- a/Core/Tools/W3DView/EditLODDialog.cpp +++ b/Core/Tools/W3DView/EditLODDialog.cpp @@ -22,7 +22,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "EditLODDialog.h" -#include "refcount.h" #include "distlod.h" #include "Utils.h" #include "rendobj.h" diff --git a/Core/Tools/W3DView/EmitterInstanceList.cpp b/Core/Tools/W3DView/EmitterInstanceList.cpp index aa4f8889ec..a4f66a0e97 100644 --- a/Core/Tools/W3DView/EmitterInstanceList.cpp +++ b/Core/Tools/W3DView/EmitterInstanceList.cpp @@ -33,7 +33,6 @@ #include "StdAfx.h" #include "EmitterInstanceList.h" -#include "refcount.h" #include "Utils.h" ///////////////////////////////////////////////////////////////////// diff --git a/Core/Tools/W3DView/EmitterPropertySheet.cpp b/Core/Tools/W3DView/EmitterPropertySheet.cpp index 2e6873df6e..0b3eed55b2 100644 --- a/Core/Tools/W3DView/EmitterPropertySheet.cpp +++ b/Core/Tools/W3DView/EmitterPropertySheet.cpp @@ -33,7 +33,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "EmitterPropertySheet.h" -#include "refcount.h" #include "part_emt.h" #include "part_ldr.h" #include "assetmgr.h" diff --git a/Core/Tools/W3DView/GraphicView.cpp b/Core/Tools/W3DView/GraphicView.cpp index 1cc81f6b2f..e32acee128 100644 --- a/Core/Tools/W3DView/GraphicView.cpp +++ b/Core/Tools/W3DView/GraphicView.cpp @@ -22,7 +22,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "GraphicView.h" -#include "refcount.h" #include "ww3d.h" #include "Globals.h" #include "W3DViewDoc.h" diff --git a/Core/Tools/W3DView/PlaySoundDialog.cpp b/Core/Tools/W3DView/PlaySoundDialog.cpp index 6988aae536..a15b28e23a 100644 --- a/Core/Tools/W3DView/PlaySoundDialog.cpp +++ b/Core/Tools/W3DView/PlaySoundDialog.cpp @@ -21,7 +21,6 @@ #include "StdAfx.h" #include "PlaySoundDialog.h" -#include "refcount.h" #include "Utils.h" #include "AudibleSound.h" diff --git a/Core/Tools/W3DView/RingPropertySheet.cpp b/Core/Tools/W3DView/RingPropertySheet.cpp index aeca496b73..51ca2e8a78 100644 --- a/Core/Tools/W3DView/RingPropertySheet.cpp +++ b/Core/Tools/W3DView/RingPropertySheet.cpp @@ -22,7 +22,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "RingPropertySheet.h" -#include "refcount.h" #include "Utils.h" #include "W3DViewDoc.h" #include "assetmgr.h" diff --git a/Core/Tools/W3DView/ScreenCursor.cpp b/Core/Tools/W3DView/ScreenCursor.cpp index 37e78b4aae..28917a34f4 100644 --- a/Core/Tools/W3DView/ScreenCursor.cpp +++ b/Core/Tools/W3DView/ScreenCursor.cpp @@ -33,7 +33,6 @@ #include "StdAfx.h" #include "ScreenCursor.h" -#include "refcount.h" #include "Utils.h" #include "ww3d.h" #include "vertmaterial.h" diff --git a/Core/Tools/W3DView/SpherePropertySheet.cpp b/Core/Tools/W3DView/SpherePropertySheet.cpp index 7a447640bb..400f73d631 100644 --- a/Core/Tools/W3DView/SpherePropertySheet.cpp +++ b/Core/Tools/W3DView/SpherePropertySheet.cpp @@ -22,7 +22,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "SpherePropertySheet.h" -#include "refcount.h" #include "Utils.h" #include "W3DViewDoc.h" #include "assetmgr.h" diff --git a/Core/Tools/W3DView/TextureMgrDialog.cpp b/Core/Tools/W3DView/TextureMgrDialog.cpp index 150eaef29f..a639372773 100644 --- a/Core/Tools/W3DView/TextureMgrDialog.cpp +++ b/Core/Tools/W3DView/TextureMgrDialog.cpp @@ -38,7 +38,6 @@ #include "StdAfx.h" #include "W3DView.h" #include "TextureMgrDialog.h" -#include "refcount.h" #include "Mesh.h" #include "MatInfo.h" #include "TextureSettingsDialog.h" diff --git a/Core/Tools/W3DView/TextureSettingsDialog.cpp b/Core/Tools/W3DView/TextureSettingsDialog.cpp index 1c7fd13aba..6413def588 100644 --- a/Core/Tools/W3DView/TextureSettingsDialog.cpp +++ b/Core/Tools/W3DView/TextureSettingsDialog.cpp @@ -35,7 +35,6 @@ #include "Texture.h" #include "W3DView.h" #include "TextureSettingsDialog.h" -#include "refcount.h" #include "Utils.h" #include "AssetMgr.h" diff --git a/Core/Tools/W3DView/Utils.cpp b/Core/Tools/W3DView/Utils.cpp index f255cf43d5..95ed99ff0b 100644 --- a/Core/Tools/W3DView/Utils.cpp +++ b/Core/Tools/W3DView/Utils.cpp @@ -27,7 +27,6 @@ #include "StdAfx.h" #include "W3DViewDoc.h" #include "MainFrm.h" -#include "refcount.h" #include "DataTreeView.h" #include "Utils.h" #include "texture.h" diff --git a/Core/Tools/W3DView/W3DViewDoc.cpp b/Core/Tools/W3DView/W3DViewDoc.cpp index 5216ed461a..1594b53859 100644 --- a/Core/Tools/W3DView/W3DViewDoc.cpp +++ b/Core/Tools/W3DView/W3DViewDoc.cpp @@ -42,7 +42,6 @@ #include "Utils.h" #include "w3derr.h" #include "chunkio.h" -#include "refcount.h" #include "AssetInfo.h" #include "meshmdl.h" #include "agg_def.h"