Skip to content

Commit e2d2928

Browse files
committed
updated for CS release
added ENB detection from CS bump version 1.0.0
1 parent 41e1279 commit e2d2928

File tree

7 files changed

+61
-2
lines changed

7 files changed

+61
-2
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
New-Item -ItemType Directory -Path "artifacts/SKSE/Plugins" -Force
3737
Copy-Item -Recurse -Force build/release-msvc/TerrainHelper.dll artifacts/SKSE/Plugins/
3838
Copy-Item -Recurse -Force build/release-msvc/TerrainHelper.pdb artifacts/SKSE/Plugins/
39-
Copy-Item -Force plugins/TerrainHelper.esp artifacts/
39+
Copy-Item -Recurse -Force "package/*" artifacts/
4040
4141
- name: Upload Build Artifacts
4242
uses: actions/upload-artifact@v4

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21)
22

33
# Set project name and version
44
set(PLUGIN_NAME TerrainHelper)
5-
set(PLUGIN_VERSION 0.4.0)
5+
set(PLUGIN_VERSION 1.0.0)
66
project(${PLUGIN_NAME} VERSION ${PLUGIN_VERSION} LANGUAGES CXX)
77

88
# Set compile defitions
@@ -27,6 +27,7 @@ include_directories("extern/detours")
2727
set(headers
2828
"include/TerrainHelper.h"
2929
"include/PCH.h"
30+
"include/THUtil.h"
3031
)
3132

3233
set(sources

include/THUtil.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#pragma once
2+
3+
#include <windows.h>
4+
#include <psapi.h>
5+
6+
namespace THUtil
7+
{
8+
/**
9+
* @brief Checks if ENB is loaded or not (Comes from CS implementation)
10+
*
11+
* @return bool true if loaded, false otherwise
12+
*/
13+
[[nodiscard]] static bool IsENBLoaded()
14+
{
15+
DWORD cb = 1000 * sizeof(HMODULE);
16+
DWORD cbNeeded = 0;
17+
HMODULE enbmodule = NULL;
18+
HMODULE hmodules[1000];
19+
HANDLE hproc = GetCurrentProcess();
20+
for (long i = 0; i < 1000; i++)
21+
{
22+
hmodules[i] = NULL;
23+
}
24+
25+
// Find the proper library using the existance of an exported function, because several with the same name may exist
26+
if (EnumProcessModules(hproc, hmodules, cb, &cbNeeded))
27+
{
28+
long count = cbNeeded / sizeof(HMODULE);
29+
for (long i = 0; i < count; i++)
30+
{
31+
if (hmodules[i] == NULL)
32+
{
33+
break;
34+
}
35+
36+
void *func = (void *)GetProcAddress(hmodules[i], "ENBGetSDKVersion");
37+
if (func)
38+
{
39+
enbmodule = hmodules[i];
40+
break;
41+
}
42+
}
43+
}
44+
45+
return enbmodule != nullptr;
46+
}
47+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Info]
2+
Version = 1-0-0

src/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "TerrainHelper.h"
2121

22+
#include "THUtil.h"
23+
2224
#define DLLEXPORT __declspec(dllexport)
2325

2426
using namespace std;
@@ -88,6 +90,13 @@ void MessageHandler(SKSE::MessagingInterface::Message* a_msg) {
8890
extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* skse) {
8991
SKSE::Init(skse);
9092
SetupLog();
93+
94+
if (!THUtil::IsENBLoaded()) {
95+
// Do not load the plugin if ENB is not loaded
96+
spdlog::critical("ENB is not loaded, TerrainHelper for ENB is disabled. If you use Community Shaders this message is okay.");
97+
return true;
98+
}
99+
91100
spdlog::info("{} version {} loaded", PLUGIN_NAME, PLUGIN_VERSION);
92101

93102
// Register messaging interface

0 commit comments

Comments
 (0)