Skip to content

Commit

Permalink
[CKPE]
Browse files Browse the repository at this point in the history
SSE:
- Fixed assert unsupport format texture for v1378.1;
  • Loading branch information
Perchik71 committed Feb 4, 2025
1 parent 9442050 commit 77cb004
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
39 changes: 27 additions & 12 deletions Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ namespace CreationKitPlatformExtended
//
// Replace direct crash with an assertion when an incompatible texture format is used in the renderer
//
lpRelocator->DetourCall(lpRelocationDatabaseItem->At(0), (uintptr_t)&sub);
if (lpRelocator->GetEngine()->GetEditorVersion() >= EDITOR_EXECUTABLE_TYPE::EDITOR_SKYRIM_SE_1_6_1378_1)
lpRelocator->DetourCall(lpRelocationDatabaseItem->At(0), (uintptr_t)&sub_1378);
else
lpRelocator->DetourCall(lpRelocationDatabaseItem->At(0), (uintptr_t)&sub);

pointer_LoadDDSFile_sub = lpRelocator->Rav2Off(lpRelocationDatabaseItem->At(1));

return true;
Expand All @@ -82,17 +86,28 @@ namespace CreationKitPlatformExtended
// Modified DirectX::LoadFromDDSFile from DDSTextureLoader (DirectXTex)
HRESULT hr = ((HRESULT(__fastcall*)(__int64, __int64, __int64, __int64, unsigned int, int))pointer_LoadDDSFile_sub)(a1, a2, a3, a4, a5, a6);

if (FAILED(hr))
{
// NiBinaryStream->BSResourceStream->File name
const char* fileName = *(const char**)(*(__int64*)(a2 + 0x20) + 0x20);

AssertMsgVa(SUCCEEDED(hr),
"Fatal error while trying to load texture \"%s\" due to an incompatible file format. This "
"indicates a problem with your mod or game files. Note that B5G6R5 and B5G5R5A1 texture "
"formats are not supported on Windows 7. HR = 0x%08X.",
fileName, hr);
}
const char* fileName = *(const char**)(*(__int64*)(a2 + 0x20) + 0x20);
AssertMsgVa(SUCCEEDED(hr),
"Fatal error while trying to load texture \"%s\" due to an incompatible file format. This "
"indicates a problem with your mod or game files. Note that B5G6R5 and B5G5R5A1 texture "
"formats are not supported on Windows 7. HR = 0x%08X.",
fileName, hr);

// This return value is ignored. If it fails it returns a null pointer (a3) and crashes later on.
return hr;
}

HRESULT LoadDDSFilePatch::sub_1378(__int64 a1, __int64 a2, __int64 a3, __int64 a4, unsigned int a5, int a6)
{
// Modified DirectX::LoadFromDDSFile from DDSTextureLoader (DirectXTex)
HRESULT hr = ((HRESULT(__fastcall*)(__int64, __int64, __int64, __int64, unsigned int, int))pointer_LoadDDSFile_sub)(a1, a2, a3, a4, a5, a6);

const char* fileName = *(const char**)(*(__int64*)(a2 + 0x20) + 0x28);
AssertMsgVa(SUCCEEDED(hr),
"Fatal error while trying to load texture \"%s\" due to an incompatible file format. This "
"indicates a problem with your mod or game files. Note that B5G6R5 and B5G5R5A1 texture "
"formats are not supported on Windows 7. HR = 0x%08X.",
fileName, hr);

// This return value is ignored. If it fails it returns a null pointer (a3) and crashes later on.
return hr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace CreationKitPlatformExtended
virtual Array<String> GetDependencies() const;

static HRESULT sub(__int64 a1, __int64 a2, __int64 a3, __int64 a4, unsigned int a5, int a6);
static HRESULT sub_1378(__int64 a1, __int64 a2, __int64 a3, __int64 a4, unsigned int a5, int a6);
protected:
virtual bool QueryFromPlatform(EDITOR_EXECUTABLE_TYPE eEditorCurrentVersion,
const char* lpcstrPlatformRuntimeVersion) const;
Expand Down
Binary file modified Creation Kit Platform Extended Core/Version/build_version.txt
Binary file not shown.
Binary file modified Creation Kit Platform Extended Core/Version/resource_version2.h
Binary file not shown.

0 comments on commit 77cb004

Please sign in to comment.