Skip to content

Commit f90ee99

Browse files
authored
Merge pull request #38 from GeneralsOnlineDevelopmentTeam/seer/dx8-createimagesurface-failure
DX8: Handle failure of CreateImageSurface
2 parents bc17fb5 + 20a4dea commit f90ee99

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,14 @@ IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(unsigned int width, unsigned
23712371
// Paletted surfaces not supported!
23722372
WWASSERT(format!=D3DFMT_P8);
23732373

2374-
DX8CALL(CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface));
2374+
HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface);
2375+
number_of_DX8_calls++;
2376+
2377+
if (FAILED(hr)) {
2378+
// Log the error and return NULL to indicate failure
2379+
Non_Fatal_Log_DX8_ErrorCode(hr, __FILE__, __LINE__);
2380+
return NULL;
2381+
}
23752382

23762383
return surface;
23772384
}

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2943,7 +2943,14 @@ IDirect3DSurface8 * DX8Wrapper::_Create_DX8_Surface(unsigned int width, unsigned
29432943
// Paletted surfaces not supported!
29442944
WWASSERT(format!=D3DFMT_P8);
29452945

2946-
DX8CALL(CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface));
2946+
HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->CreateImageSurface(width, height, WW3DFormat_To_D3DFormat(format), &surface);
2947+
number_of_DX8_calls++;
2948+
2949+
if (FAILED(hr)) {
2950+
// Log the error and return NULL to indicate failure
2951+
Non_Fatal_Log_DX8_ErrorCode(hr, __FILE__, __LINE__);
2952+
return NULL;
2953+
}
29472954

29482955
return surface;
29492956
}

0 commit comments

Comments
 (0)