forked from mchaptel/TESReloaded10
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide normals and odd black transparency
Add ability to block certain render passes Make fixed function lighting code toggleable Clean up culling patch Move includes for hooks to Hooks.cpp
- Loading branch information
1 parent
da642fb
commit 56a607c
Showing
11 changed files
with
77 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,45 @@ | ||
#include "Hooks.h" | ||
#include "../lib/minhook/include/MinHook.h" | ||
#include "Hooks.h" | ||
#include "../GameCommon.h" | ||
#include "Culling.h" | ||
#include "Game.h" | ||
#include "Lights.h" | ||
#include "Render.h" | ||
|
||
bool MH_CreateHookSimple(LPVOID *ppOriginal, LPVOID pDetour) { | ||
if (ppOriginal == nullptr) { | ||
Logger::Log("Attempted to create null hook for %p", pDetour); | ||
} | ||
void* pTarget = *ppOriginal; | ||
if (MH_CreateHook(pTarget, pDetour, ppOriginal) != MH_OK) { | ||
Logger::Log("Failed to create hook for %p", pTarget); | ||
} | ||
else if (MH_EnableHook(pTarget)) { | ||
Logger::Log("Failed to enable hook for %p", pTarget); | ||
} | ||
else { | ||
Logger::Debug("Created hook for %p to %p", pTarget, pDetour); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
void AttachHooks() { | ||
if (MH_Initialize() == MH_OK) { | ||
MH_CreateHook((void*)InitializeRenderer, &InitializeRendererHook, reinterpret_cast<LPVOID*>(&InitializeRenderer)); | ||
MH_CreateHook((void*)NewTES, &NewTESHook, reinterpret_cast<LPVOID*>(&NewTES)); | ||
MH_CreateHook((void*)NewMenuInterfaceManager, &NewMenuInterfaceManagerHook, reinterpret_cast<LPVOID*>(&NewMenuInterfaceManager)); | ||
if (MH_EnableHook(MH_ALL_HOOKS) != MH_OK) { | ||
Logger::Log("Failed to apply hooks"); | ||
} | ||
} else { | ||
if (MH_Initialize() != MH_OK) { | ||
Logger::Log("Failed to initialize MinHook"); | ||
return; | ||
} | ||
MH_CreateHookSimple((LPVOID*)&InitializeRenderer, InitializeRendererHook); | ||
MH_CreateHookSimple((LPVOID*)&NewTES, NewTESHook); | ||
MH_CreateHookSimple((LPVOID*)&NewMenuInterfaceManager, NewMenuInterfaceManagerHook); | ||
|
||
AttachLightHooks(); | ||
AttachRenderHooks(); | ||
|
||
if (SettingManager::PassLights) { | ||
AttachLightHooks(); | ||
} | ||
|
||
if (SettingManager::DisableCulling) | ||
{ | ||
if (SettingManager::DisableCulling) { | ||
AttachCullingHooks(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#pragma once | ||
|
||
bool MH_CreateHookSimple(LPVOID*, LPVOID); | ||
void AttachHooks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "Hooks.h" | ||
|
||
typedef void(__fastcall* RenderListAdd)(void*, void*, void*, WORD, BYTE, BYTE, void*, void*, void*, void*); | ||
static RenderListAdd RenderListOrig = (RenderListAdd)0xBA9EE0; | ||
|
||
void __fastcall RenderListHook(void* ecx, void* edx, void* triStrips, WORD renderPassNum, BYTE enable, BYTE numLights, void* light0, void* light1, void* light2, void* light3) { | ||
// Block normals and weird transparent black | ||
if (renderPassNum == 306 || renderPassNum == 334) { | ||
return; | ||
} | ||
// Hide lights from game | ||
RenderListOrig(ecx, edx, triStrips, renderPassNum, enable, min(numLights, 1), light0, nullptr, nullptr, nullptr); | ||
} | ||
|
||
void AttachRenderHooks() | ||
{ | ||
MH_CreateHookSimple((LPVOID*)&RenderListOrig, RenderListHook); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#pragma once | ||
void AttachRenderHooks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters