Skip to content

Commit

Permalink
Fix some interface reference issues
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Feb 10, 2025
1 parent 6f37dd1 commit 175c2b0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dllmain/BuildNo.rc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILD_NUMBER 7506
#define BUILD_NUMBER 7507
6 changes: 4 additions & 2 deletions ddraw/IDirect3DX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,8 @@ void m_IDirect3DX::ReleaseInterface()
// Release Viewport
for (auto& entry : ViewportList)
{
if (entry->Release())
m_IDirect3DViewport* Viewport = (m_IDirect3DViewport*)entry->GetWrapperInterfaceX(0);
if (!Viewport || Viewport->Release())
{
entry->ClearD3D();
}
Expand All @@ -1002,7 +1003,8 @@ void m_IDirect3DX::ReleaseInterface()
// Release Material
for (auto& entry : MaterialList)
{
if (entry->Release())
m_IDirect3DMaterial* Material = (m_IDirect3DMaterial*)entry->GetWrapperInterfaceX(0);
if (!Material || Material->Release())
{
entry->ClearD3D();
}
Expand Down
8 changes: 8 additions & 0 deletions ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ HRESULT m_IDirectDrawSurfaceX::QueryInterface(REFIID riid, LPVOID FAR* ppvObj, D
{
InterfaceX = new m_IDirect3DTextureX(ddrawParent->GetCurrentD3DDevice(), DxVersion, this);
attached3DTexture = InterfaceX;
attached3dTextureRefversion = DirectXVersion;
AddRef(attached3dTextureRefversion);
}

*ppvObj = InterfaceX->GetWrapperInterfaceX(DxVersion);
Expand Down Expand Up @@ -4165,6 +4167,12 @@ void m_IDirectDrawSurfaceX::InitInterface(DWORD DirectXVersion)
InitSurfaceDesc(DirectXVersion);
}

void m_IDirectDrawSurfaceX::ClearAttachedTexture()
{
attached3DTexture = nullptr;
Release(attached3dTextureRefversion);
}

void m_IDirectDrawSurfaceX::SetDdrawParent(m_IDirectDrawX* ddraw)
{
ddrawParent = ddraw;
Expand Down
5 changes: 3 additions & 2 deletions ddraw/IDirectDrawSurfaceX.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
CRITICAL_SECTION ddscs = {};
CRITICAL_SECTION ddlcs = {};
m_IDirectDrawX *ddrawParent = nullptr; // DirectDraw parent device
SURFACEOVERLAY SurfaceOverlay; // The overlays for this surface
SURFACEOVERLAY SurfaceOverlay; // The overlays for this surface
std::vector<MIPMAP> MipMaps; // MipMaps structure with addresses
DWORD MaxMipMapLevel = 0; // Total number of manually created MipMap levels
bool IsMipMapReadyToUse = false; // Used for MipMap filtering
Expand All @@ -174,6 +174,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
m_IDirectDrawPalette *attachedPalette = nullptr; // Associated palette
m_IDirectDrawClipper *attachedClipper = nullptr; // Associated clipper
m_IDirect3DTextureX *attached3DTexture = nullptr; // Associated texture
DWORD attached3dTextureRefversion = 0; // Reference wrapper version for associated texture
DDSURFACEDESC2 surfaceDesc2 = {}; // Surface description for this surface
DWORD ResetDisplayFlags = 0; // Flags that need to be reset when display mode changes
DWORD UniquenessValue = 0;
Expand Down Expand Up @@ -521,7 +522,7 @@ class m_IDirectDrawSurfaceX : public IUnknown, public AddressLookupTableDdrawObj
inline D3DFORMAT GetD3d9Format() const { return surface.Format; }
inline LPDIRECT3DTEXTURE9 GetD3d9PaletteTexture() const { return primary.PaletteTexture; }
inline m_IDirect3DTextureX* GetAttachedTexture() { return attached3DTexture; }
inline void ClearAttachedTexture() { attached3DTexture = nullptr; }
void ClearAttachedTexture();
void ClearUsing3DFlag();
HRESULT GetPresentWindowRect(LPRECT pRect, RECT& DestRect);

Expand Down

0 comments on commit 175c2b0

Please sign in to comment.