Skip to content

Commit

Permalink
Move a few checks and add device creation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Dec 7, 2024
1 parent 4582c6a commit a97b945
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 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 7364
#define BUILD_NUMBER 7365
6 changes: 0 additions & 6 deletions ddraw/IDirect3DX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,12 +644,6 @@ HRESULT m_IDirect3DX::CreateDevice(REFCLSID rclsid, LPDIRECTDRAWSURFACE7 lpDDS,
return DDERR_INVALIDOBJECT;
}

// Check if a device is already created
if (*ddrawParent->GetCurrentD3DDevice())
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: Direct3D Device has already been created!");
}

// Get surfaceX
m_IDirectDrawSurfaceX *DdrawSurface3D = nullptr;
lpDDS->QueryInterface(IID_GetInterfaceX, (LPVOID*)&DdrawSurface3D);
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirectDrawSurfaceX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5758,7 +5758,7 @@ inline bool m_IDirectDrawSurfaceX::CheckCoordinates(RECT& OutRect, LPRECT lpInRe
void m_IDirectDrawSurfaceX::LockEmuLock(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc)
{
// Only works if entire surface is locked
if (!lpDDSurfaceDesc || !lpDDSurfaceDesc->lPitch || lpDestRect)
if (!lpDDSurfaceDesc || !lpDDSurfaceDesc->lPitch || (lpDestRect && lpDestRect->top != 0 && lpDestRect->left != 0))
{
return;
}
Expand Down
23 changes: 23 additions & 0 deletions ddraw/IDirectDrawX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2839,14 +2839,37 @@ HRESULT m_IDirectDrawX::CheckInterface(char *FunctionName, bool CheckD3DDevice)

void m_IDirectDrawX::SetD3D(m_IDirect3DX* D3D)
{
// Check if a device is already created
if (D3DInterface && D3DInterface != D3D)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: Direct3D interface has already been created!");
}

D3DInterface = D3D;
}

void m_IDirectDrawX::SetD3DDevice(m_IDirect3DDeviceX* D3DDevice)
{
// Check if a device is already created
if (D3DDeviceInterface && D3DDeviceInterface != D3DDevice)
{
LOG_LIMIT(100, __FUNCTION__ << " Warning: Direct3D Device has already been created!");
}

D3DDeviceInterface = D3DDevice;
}

void m_IDirectDrawX::ClearD3DDevice()
{
Using3D = false;

D3DDeviceInterface = nullptr;

SetRenderTargetSurface(nullptr);

Clear3DFlagForAllSurfaces();
}

bool m_IDirectDrawX::IsInScene()
{
return (D3DDeviceInterface && D3DDeviceInterface->IsDeviceInScene());
Expand Down
2 changes: 1 addition & 1 deletion ddraw/IDirectDrawX.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class m_IDirectDrawX : public IUnknown, public AddressLookupTableDdrawObject
inline void ClearD3D() { D3DInterface = nullptr; }
void SetD3DDevice(m_IDirect3DDeviceX* D3DDevice);
inline m_IDirect3DDeviceX** GetCurrentD3DDevice() { return &D3DDeviceInterface; }
inline void ClearD3DDevice() { Using3D = false; D3DDeviceInterface = nullptr; SetRenderTargetSurface(nullptr); Clear3DFlagForAllSurfaces(); }
void ClearD3DDevice();
inline void Enable3D() { Using3D = true; }
inline bool IsUsing3D() { return Using3D; }
inline bool IsPrimaryRenderTarget() { return PrimarySurface ? PrimarySurface->IsRenderTarget() : false; }
Expand Down

0 comments on commit a97b945

Please sign in to comment.