Skip to content

Commit 8d137cc

Browse files
committed
v1.3 Display if a plugin is incompatible becuase of data table versions.
Plugins can set a custom error message at any time now Slight UI Changes
1 parent 056ee6e commit 8d137cc

16 files changed

Lines changed: 110 additions & 55 deletions

.github/workflows/msbuild.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ jobs:
7070
echo "new_version=$NEW_VER" >> $GITHUB_OUTPUT
7171
7272
- name: Add MSBuild to PATH
73-
uses: microsoft/setup-msbuild@v1.0.2
73+
uses: microsoft/setup-msbuild@v2
74+
with:
75+
msbuild-architecture: x64
7476

7577
- name: Build
7678
working-directory: ${{env.GITHUB_WORKSPACE}}

.github/workflows/update-minimal-sdk-headers.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ jobs:
3535
git checkout minimal-sdk-headers || git checkout -b minimal-sdk-headers
3636
3737
- name: Copy latest headers from master
38-
run: git checkout origin/master -- BnsPlugin/Data.h BnsPlugin/DatafilePluginsdk.h BnsPlugin/DrEl.h BnsPlugin/imgui_plugin_api.h
38+
run: git checkout origin/master -- BnsPlugin/DataConstants.h BnsPlugin/Data.h BnsPlugin/DatafilePluginsdk.h BnsPlugin/DrEl.h BnsPlugin/imgui_plugin_api.h
3939

4040

4141
- name: Add header files
42-
run: git add BnsPlugin/Data.h BnsPlugin/DatafilePluginsdk.h BnsPlugin/DrEl.h BnsPlugin/imgui_plugin_api.h
42+
run: git add BnsPlugin/DataConstants.h BnsPlugin/Data.h BnsPlugin/DatafilePluginsdk.h BnsPlugin/DrEl.h BnsPlugin/imgui_plugin_api.h
4343

4444
- name: Commit changes
4545
run: |

ArtifactDatafilePlugin/ArtifactDatafilePlugin.vcxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,38 @@
3737
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
3838
<ConfigurationType>Application</ConfigurationType>
3939
<UseDebugLibraries>true</UseDebugLibraries>
40-
<PlatformToolset>v143</PlatformToolset>
40+
<PlatformToolset>v145</PlatformToolset>
4141
<CharacterSet>Unicode</CharacterSet>
4242
</PropertyGroup>
4343
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug File|Win32'" Label="Configuration">
4444
<ConfigurationType>Application</ConfigurationType>
4545
<UseDebugLibraries>true</UseDebugLibraries>
46-
<PlatformToolset>v143</PlatformToolset>
46+
<PlatformToolset>v145</PlatformToolset>
4747
<CharacterSet>Unicode</CharacterSet>
4848
</PropertyGroup>
4949
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
5050
<ConfigurationType>Application</ConfigurationType>
5151
<UseDebugLibraries>false</UseDebugLibraries>
52-
<PlatformToolset>v143</PlatformToolset>
52+
<PlatformToolset>v145</PlatformToolset>
5353
<WholeProgramOptimization>true</WholeProgramOptimization>
5454
<CharacterSet>Unicode</CharacterSet>
5555
</PropertyGroup>
5656
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
5757
<ConfigurationType>DynamicLibrary</ConfigurationType>
5858
<UseDebugLibraries>true</UseDebugLibraries>
59-
<PlatformToolset>v143</PlatformToolset>
59+
<PlatformToolset>v145</PlatformToolset>
6060
<CharacterSet>Unicode</CharacterSet>
6161
</PropertyGroup>
6262
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug File|x64'" Label="Configuration">
6363
<ConfigurationType>DynamicLibrary</ConfigurationType>
6464
<UseDebugLibraries>true</UseDebugLibraries>
65-
<PlatformToolset>v143</PlatformToolset>
65+
<PlatformToolset>v145</PlatformToolset>
6666
<CharacterSet>Unicode</CharacterSet>
6767
</PropertyGroup>
6868
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
6969
<ConfigurationType>DynamicLibrary</ConfigurationType>
7070
<UseDebugLibraries>false</UseDebugLibraries>
71-
<PlatformToolset>v143</PlatformToolset>
71+
<PlatformToolset>v145</PlatformToolset>
7272
<WholeProgramOptimization>true</WholeProgramOptimization>
7373
<CharacterSet>Unicode</CharacterSet>
7474
</PropertyGroup>

BnsPlugin/BnsPlugin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ static void InitDatafileService() {
258258
constexpr auto sleep_duration = std::chrono::milliseconds(1000);
259259
while (true) {
260260
if (g_DatafileService->CheckIfDatamanagerReady()) {
261+
std::this_thread::sleep_for(std::chrono::milliseconds(3000));
261262
// Notify main thread
262263
if (g_mainThreadInitCallback) {
263264
g_runMainThreadInit = true;

BnsPlugin/BnsPlugin.vcxproj

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,32 @@
3434
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugEU|x64'" Label="Configuration">
3535
<ConfigurationType>DynamicLibrary</ConfigurationType>
3636
<UseDebugLibraries>true</UseDebugLibraries>
37-
<PlatformToolset>v143</PlatformToolset>
37+
<PlatformToolset>v145</PlatformToolset>
3838
<CharacterSet>Unicode</CharacterSet>
3939
</PropertyGroup>
4040
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugFile|x64'" Label="Configuration">
4141
<ConfigurationType>DynamicLibrary</ConfigurationType>
4242
<UseDebugLibraries>true</UseDebugLibraries>
43-
<PlatformToolset>v143</PlatformToolset>
43+
<PlatformToolset>v145</PlatformToolset>
4444
<CharacterSet>Unicode</CharacterSet>
4545
</PropertyGroup>
4646
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugKR|x64'" Label="Configuration">
4747
<ConfigurationType>DynamicLibrary</ConfigurationType>
4848
<UseDebugLibraries>true</UseDebugLibraries>
49-
<PlatformToolset>v143</PlatformToolset>
49+
<PlatformToolset>v145</PlatformToolset>
5050
<CharacterSet>Unicode</CharacterSet>
5151
</PropertyGroup>
5252
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseEU|x64'" Label="Configuration">
5353
<ConfigurationType>DynamicLibrary</ConfigurationType>
5454
<UseDebugLibraries>false</UseDebugLibraries>
55-
<PlatformToolset>v143</PlatformToolset>
55+
<PlatformToolset>v145</PlatformToolset>
5656
<WholeProgramOptimization>true</WholeProgramOptimization>
5757
<CharacterSet>Unicode</CharacterSet>
5858
</PropertyGroup>
5959
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseKR|x64'" Label="Configuration">
6060
<ConfigurationType>DynamicLibrary</ConfigurationType>
6161
<UseDebugLibraries>false</UseDebugLibraries>
62-
<PlatformToolset>v143</PlatformToolset>
62+
<PlatformToolset>v145</PlatformToolset>
6363
<WholeProgramOptimization>true</WholeProgramOptimization>
6464
<CharacterSet>Unicode</CharacterSet>
6565
</PropertyGroup>
@@ -131,7 +131,7 @@
131131
<ClCompile>
132132
<WarningLevel>Level3</WarningLevel>
133133
<SDLCheck>true</SDLCheck>
134-
<PreprocessorDefinitions>TRIALDLL_EXPORT;_CRT_SECURE_NO_WARNINGS;UNICODE;_UNICODE;_DEBUG;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);_BNSEU;_ITERATOR_DEBUG_LEVEL=0</PreprocessorDefinitions>
134+
<PreprocessorDefinitions>TRIALDLL_EXPORT;_CRT_SECURE_NO_WARNINGS;UNICODE;_UNICODE;_DEBUG;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);BNSEU;_ITERATOR_DEBUG_LEVEL=0</PreprocessorDefinitions>
135135
<ConformanceMode>true</ConformanceMode>
136136
<AdditionalIncludeDirectories>$(ProjectDir)vcpkg_installed\x64-windows\include;$(ProjectDir)deps;$(ProjectDir)deps\Detours;$(ProjectDir)deps\BnsPluginTables\Generated\include</AdditionalIncludeDirectories>
137137
<LanguageStandard>stdcpp23</LanguageStandard>
@@ -145,6 +145,7 @@
145145
<ObjectFileName>$(IntDir)%(RelativeDir)%(Filename)%(Extension).obj</ObjectFileName>
146146
<UseFullPaths>true</UseFullPaths>
147147
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
148+
<UseStandardPreprocessor>true</UseStandardPreprocessor>
148149
</ClCompile>
149150
<Link>
150151
<SubSystem>Windows</SubSystem>
@@ -178,6 +179,7 @@
178179
<ObjectFileName>$(IntDir)%(RelativeDir)%(Filename)%(Extension).obj</ObjectFileName>
179180
<UseFullPaths>true</UseFullPaths>
180181
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
182+
<UseStandardPreprocessor>true</UseStandardPreprocessor>
181183
</ClCompile>
182184
<Link>
183185
<SubSystem>Windows</SubSystem>
@@ -197,7 +199,7 @@
197199
<ClCompile>
198200
<WarningLevel>Level3</WarningLevel>
199201
<SDLCheck>true</SDLCheck>
200-
<PreprocessorDefinitions>TRIALDLL_EXPORT;_CRT_SECURE_NO_WARNINGS;UNICODE;_UNICODE;_DEBUG;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);_BNSKR</PreprocessorDefinitions>
202+
<PreprocessorDefinitions>TRIALDLL_EXPORT;_CRT_SECURE_NO_WARNINGS;UNICODE;_UNICODE;_DEBUG;_WINDOWS;NDEBUG;%(PreprocessorDefinitions);BNSKR</PreprocessorDefinitions>
201203
<ConformanceMode>true</ConformanceMode>
202204
<AdditionalIncludeDirectories>$(ProjectDir)vcpkg_installed\x64-windows\include;$(ProjectDir)deps;$(ProjectDir)deps\Detours;$(ProjectDir)deps\BnsPluginTables\Generated\include</AdditionalIncludeDirectories>
203205
<LanguageStandard>stdcpp23</LanguageStandard>
@@ -211,6 +213,7 @@
211213
<ObjectFileName>$(IntDir)%(RelativeDir)%(Filename)%(Extension).obj</ObjectFileName>
212214
<UseFullPaths>true</UseFullPaths>
213215
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
216+
<UseStandardPreprocessor>true</UseStandardPreprocessor>
214217
</ClCompile>
215218
<Link>
216219
<SubSystem>Windows</SubSystem>
@@ -232,7 +235,7 @@
232235
<FunctionLevelLinking>true</FunctionLevelLinking>
233236
<IntrinsicFunctions>true</IntrinsicFunctions>
234237
<SDLCheck>false</SDLCheck>
235-
<PreprocessorDefinitions>NDEBUG;NOMINMAX;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_UNICODE;_WINDOWS;JM_XORSTR_DISABLE_AVX_INTRINSICS;PHNT_VERSION=PHNT_THRESHOLD;RESULT_DIAGNOSTICS_LEVEL=0;UNICODE;%(PreprocessorDefinitions);_BNSEU</PreprocessorDefinitions>
238+
<PreprocessorDefinitions>NDEBUG;NOMINMAX;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_UNICODE;_WINDOWS;JM_XORSTR_DISABLE_AVX_INTRINSICS;PHNT_VERSION=PHNT_THRESHOLD;RESULT_DIAGNOSTICS_LEVEL=0;UNICODE;%(PreprocessorDefinitions);BNSEU</PreprocessorDefinitions>
236239
<ConformanceMode>true</ConformanceMode>
237240
<AdditionalIncludeDirectories>$(ProjectDir)vcpkg_installed\x64-windows\include;$(ProjectDir)deps;$(ProjectDir)deps\Detours;$(ProjectDir)deps\BnsPluginTables\Generated\include</AdditionalIncludeDirectories>
238241
<LanguageStandard>stdcpp23</LanguageStandard>
@@ -269,7 +272,7 @@
269272
<FunctionLevelLinking>true</FunctionLevelLinking>
270273
<IntrinsicFunctions>true</IntrinsicFunctions>
271274
<SDLCheck>false</SDLCheck>
272-
<PreprocessorDefinitions>NDEBUG;NOMINMAX;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_UNICODE;_WINDOWS;JM_XORSTR_DISABLE_AVX_INTRINSICS;PHNT_VERSION=PHNT_THRESHOLD;RESULT_DIAGNOSTICS_LEVEL=0;UNICODE;%(PreprocessorDefinitions);_BNSKR</PreprocessorDefinitions>
275+
<PreprocessorDefinitions>NDEBUG;NOMINMAX;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_UNICODE;_WINDOWS;JM_XORSTR_DISABLE_AVX_INTRINSICS;PHNT_VERSION=PHNT_THRESHOLD;RESULT_DIAGNOSTICS_LEVEL=0;UNICODE;%(PreprocessorDefinitions);BNSKR</PreprocessorDefinitions>
273276
<ConformanceMode>true</ConformanceMode>
274277
<AdditionalIncludeDirectories>$(ProjectDir)vcpkg_installed\x64-windows\include;$(ProjectDir)deps;$(ProjectDir)deps\Detours;$(ProjectDir)deps\BnsPluginTables\Generated\include</AdditionalIncludeDirectories>
275278
<LanguageStandard>stdcpp23</LanguageStandard>
@@ -284,6 +287,7 @@
284287
<FloatingPointModel>Fast</FloatingPointModel>
285288
<ControlFlowGuard>false</ControlFlowGuard>
286289
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
290+
<UseStandardPreprocessor>true</UseStandardPreprocessor>
287291
</ClCompile>
288292
<Link>
289293
<SubSystem>Windows</SubSystem>
@@ -326,6 +330,7 @@
326330
<ItemGroup>
327331
<ClInclude Include="BSFunctions.h" />
328332
<ClInclude Include="Data.h" />
333+
<ClInclude Include="DataConstants.h" />
329334
<ClInclude Include="DatafilePluginManager.h" />
330335
<ClInclude Include="DatafilePluginsdk.h" />
331336
<ClInclude Include="DatafileService.h" />
@@ -346,6 +351,7 @@
346351
<ClInclude Include="patternbyte.h" />
347352
<ClInclude Include="pch.h" />
348353
<ClInclude Include="BnsPlugin.h" />
354+
<ClInclude Include="pluginversion.h" />
349355
<ClInclude Include="versioninfo.h" />
350356
</ItemGroup>
351357
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

BnsPlugin/BnsPlugin.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,11 @@
152152
<ClInclude Include="DataHelper.h">
153153
<Filter>Header Files</Filter>
154154
</ClInclude>
155+
<ClInclude Include="DataConstants.h">
156+
<Filter>Header Files</Filter>
157+
</ClInclude>
158+
<ClInclude Include="pluginversion.h">
159+
<Filter>Header Files</Filter>
160+
</ClInclude>
155161
</ItemGroup>
156162
</Project>

BnsPlugin/Data.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <iostream>
55
#include <set>
66
#include <vector>
7+
#include "DataConstants.h"
78

89
struct DataChunk
910
{
@@ -245,12 +246,10 @@ namespace Data {
245246
void* _aliasMap;
246247
void* _elreader;
247248
char padding2[0x54];
248-
#ifdef _BNSKR
249-
__declspec(align(4)) DrLoaderDef _loaderDefs[498];
250-
#elif _BNSEU
251-
__declspec(align(4)) DrLoaderDef _loaderDefs[498];
249+
#ifdef BNSKR
250+
__declspec(align(4)) DrLoaderDef _loaderDefs[DR_LOADERDEFS_SIZE];
252251
#else
253-
__declspec(align(4)) DrLoaderDef _loaderDefs[498];
252+
__declspec(align(4)) DrLoaderDef _loaderDefs[DR_LOADERDEFS_SIZE];
254253
#endif
255254
};
256255
}

BnsPlugin/DataConstants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
constexpr auto DR_LOADERDEFS_SIZE = 498;

BnsPlugin/DatafilePluginManager.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ std::vector<std::string> DatafilePluginManager::ReloadAll() {
174174
}
175175
return results;
176176
}
177+
constexpr size_t kMaxStatusMessageLength = 256;
177178

178179
std::vector<std::string> DatafilePluginManager::GetPluginStateText()
179180
{
@@ -194,27 +195,20 @@ std::vector<std::string> DatafilePluginManager::GetPluginStateText()
194195
}
195196
else if (handle->dll && handle->identifier && handle->version) {
196197
line = std::string("[Loaded] ") + handle->identifier() + " v" + handle->version();
197-
if (handle->tableHandlers.empty()) {
198-
line += " (no handlers registered)";
198+
if (handle->is_incompatible && handle->is_incompatible()) {
199+
line = std::string("[Incompatible with current game version] ") + handle->identifier() + " v" + handle->version();
199200
}
200-
else {
201-
line += " (handlers: ";
202-
for (size_t i = 0; i < handle->tableHandlers.size(); ++i) {
203-
const auto* th = handle->tableHandlers[i];
204-
if (th && th->tableName) {
205-
int requiredSize = WideCharToMultiByte(CP_UTF8, 0, th->tableName, -1, nullptr, 0, nullptr, nullptr);
206-
if (requiredSize > 0) {
207-
std::string utf8Name(requiredSize - 1, '\0'); // exclude null terminator
208-
WideCharToMultiByte(CP_UTF8, 0, th->tableName, -1, utf8Name.data(), requiredSize, nullptr, nullptr);
209-
line += utf8Name;
210-
}
211-
}
212-
else {
213-
line += "(unknown)";
201+
else if (handle->status) {
202+
auto pluginInternalStatus = handle->status();
203+
if (!pluginInternalStatus.success) {
204+
std::string msg = pluginInternalStatus.message;
205+
if (msg.length() > kMaxStatusMessageLength) {
206+
msg = msg.substr(0, kMaxStatusMessageLength - 3) + "...";
214207
}
215-
if (i + 1 < handle->tableHandlers.size()) line += ", ";
208+
line = std::string("[Plugin Error] ") + handle->identifier() + " v" + handle->version();
209+
if (!msg.empty())
210+
line += " - " + msg;
216211
}
217-
line += ")";
218212
}
219213
}
220214
else {
@@ -320,6 +314,8 @@ std::string DatafilePluginManager::ReloadPluginIfChanged(std::string_view plugin
320314
auto plugin_version = reinterpret_cast<PluginVersionFunc>(GetProcAddress(dll, "PluginVersion"));
321315
auto tableHandlersFunc = reinterpret_cast<PluginTableHandlersFunc>(GetProcAddress(dll, "PluginTableHandlers"));
322316
auto tableHandlerCountFunc = reinterpret_cast<PluginTableHandlerCountFunc>(GetProcAddress(dll, "PluginTableHandlerCount"));
317+
auto statusFunc = reinterpret_cast<PluginStatusFunc>(GetProcAddress(dll, "PluginStatusCheck"));
318+
auto isIncompatibleFunc = reinterpret_cast<PluginCompatibilityFunc>(GetProcAddress(dll, "IsIncompatible"));
323319

324320
if (!(identifier && api_version && plugin_version)) {
325321
std::cerr << "Error: Missing required exports in " << plugin_path << "\n";
@@ -363,6 +359,8 @@ std::string DatafilePluginManager::ReloadPluginIfChanged(std::string_view plugin
363359
handle->version = plugin_version;
364360
handle->last_write_time = current_write_time;
365361
handle->shadow_path = shadow_path;
362+
handle->status = statusFunc;
363+
handle->is_incompatible = isIncompatibleFunc;
366364
std::cout << "Loaded: " << identifier() << " (API v" << reported_api_version << ", Plugin v" << plugin_version() << ")\n";
367365
// Call init if available
368366
if (handle->init && handle->unregister) {

BnsPlugin/DatafilePluginManager.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct PluginHandle {
2020
std::string shadow_path; // copied DLL path (shadow copy)
2121
bool load_failed = false;
2222
std::string fail_reason;
23+
PluginStatusFunc status = nullptr;
24+
PluginCompatibilityFunc is_incompatible = nullptr;
2325
};
2426

2527
void RegisterDetours(const HookFunctionParams* hooks, size_t count);

0 commit comments

Comments
 (0)