From 7d4e85b1dc52ccd74cfaccf22e3ee2d171406d69 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 20 Mar 2015 21:10:13 +0100 Subject: [PATCH] Optional lunar.png loading from file --- SAFix/SilentPatchSA.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/SAFix/SilentPatchSA.cpp b/SAFix/SilentPatchSA.cpp index 6e19b99..363d54b 100644 --- a/SAFix/SilentPatchSA.cpp +++ b/SAFix/SilentPatchSA.cpp @@ -567,15 +567,26 @@ void DrawMoonWithPhases(int moonColor, float* screenPos, float sizeX, float size { if ( !gpMoonMask ) { - HMODULE thisModule; - GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)DrawMoonWithPhases, &thisModule); + + if ( GetFileAttributes("lunar.png") != INVALID_FILE_ATTRIBUTES ) + { + // load from file + gpMoonMask = CPNGFile::ReadFromFile("lunar.png"); + } + else + { + // Load from memory - HRSRC resource = FindResource(thisModule, MAKEINTRESOURCE(IDR_LUNAR64), RT_RCDATA); - void* pMoonMask = static_cast(LoadResource(thisModule, resource)); + HMODULE thisModule; + GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)DrawMoonWithPhases, &thisModule); - gpMoonMask = CPNGFile::ReadFromMemory(pMoonMask, SizeofResource(thisModule, resource)); + HRSRC resource = FindResource(thisModule, MAKEINTRESOURCE(IDR_LUNAR64), RT_RCDATA); + void* pMoonMask = static_cast(LoadResource(thisModule, resource)); - FreeResource(pMoonMask); + gpMoonMask = CPNGFile::ReadFromMemory(pMoonMask, SizeofResource(thisModule, resource)); + + FreeResource(pMoonMask); + } } //D3DPERF_BeginEvent(D3DCOLOR_ARGB(0,0,0,0), L"render moon");