Skip to content

Commit dcdbc2c

Browse files
committed
move isGfxVsyncDisabled from Options
1 parent 0aeb5f2 commit dcdbc2c

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

src/client/hook/impl/DXHooks.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,40 @@ namespace {
1313
IDXGIOutput*,
1414
IDXGISwapChain1**);
1515

16-
SDK::Options* options = new SDK::Options();
1716
bool tearingSupported = false;
1817
bool isForceDisableVSync = false;
1918
std::shared_ptr<Hook> PresentHook;
2019
std::shared_ptr<Hook> ResizeBuffersHook;
2120
std::shared_ptr<Hook> ExecuteCommandListsHook;
21+
22+
// TODO: temporary, remove this
23+
bool isGfxVsyncDisabled() {
24+
wchar_t userProfile[MAX_PATH];
25+
DWORD pathLen = GetEnvironmentVariableW(L"USERPROFILE", userProfile, MAX_PATH);
26+
if (pathLen == 0 || pathLen >= MAX_PATH) {
27+
return true;
28+
}
29+
30+
std::wstring optionsPath(userProfile);
31+
optionsPath +=
32+
L"\\AppData\\Local\\Packages\\Microsoft.MinecraftUWP_8wekyb3d8bbwe\\LocalState\\games\\com.mojang\\minecraftpe\\options.txt";
33+
34+
std::ifstream file(optionsPath.c_str());
35+
if (!file.is_open()) {
36+
return true;
37+
}
38+
39+
std::string line;
40+
while (std::getline(file, line)) {
41+
std::erase(line, '\r');
42+
if (line.find("gfx_vsync:") == 0) {
43+
return line != "gfx_vsync:0";
44+
}
45+
}
46+
47+
// default to enabled
48+
return true;
49+
}
2250
}
2351

2452
void DXHooks::CheckForceDisableVSync() {
@@ -37,7 +65,7 @@ void DXHooks::CheckTearingSupport() {
3765
DXGI_FEATURE_PRESENT_ALLOW_TEARING,
3866
&allowTearing,
3967
sizeof(allowTearing)))) {
40-
if (allowTearing && !options->IsGfxVSyncEnabled()) {
68+
if (allowTearing && !isGfxVsyncDisabled()) {
4169
tearingSupported = true;
4270
}
4371
}
Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,2 @@
11
#include "pch.h"
22
#include "Options.h"
3-
4-
bool SDK::Options::IsGfxVSyncEnabled() {
5-
wchar_t userProfile[MAX_PATH];
6-
DWORD pathLen = GetEnvironmentVariableW(L"USERPROFILE", userProfile, MAX_PATH);
7-
if (pathLen == 0 || pathLen >= MAX_PATH) {
8-
return true;
9-
}
10-
11-
std::wstring optionsPath(userProfile);
12-
optionsPath +=
13-
L"\\AppData\\Local\\Packages\\Microsoft.MinecraftUWP_8wekyb3d8bbwe\\LocalState\\games\\com.mojang\\minecraftpe\\options.txt";
14-
15-
std::ifstream file(optionsPath.c_str());
16-
if (!file.is_open()) {
17-
return true;
18-
}
19-
20-
std::string line;
21-
while (std::getline(file, line)) {
22-
std::erase(line, '\r');
23-
if (line.find("gfx_vsync:") == 0) {
24-
return line != "gfx_vsync:0";
25-
}
26-
}
27-
28-
// default to enabled
29-
return true;
30-
}

src/sdk/common/client/game/Options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ namespace SDK {
1111
return 0;
1212
}
1313

14-
bool IsGfxVSyncEnabled();
14+
1515
};
1616
}

0 commit comments

Comments
 (0)