mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Tightened the compatibility mode check
This commit is contained in:
@@ -111,7 +111,7 @@ DWORD __stdcall KeyDown(DWORD key) {
|
||||
// combined use of DINPUT states + confirmation from GetAsyncKeyState()
|
||||
if (key < MAX_KEYS) {
|
||||
if (keysDown[key]) { // confirm pressed state
|
||||
DWORD keyVK = MapVirtualKeyEx(key, MAPVK_VSC_TO_VK, keyboardLayout);
|
||||
DWORD keyVK = MapVirtualKeyExA(key, MAPVK_VSC_TO_VK, keyboardLayout);
|
||||
if (keyVK) keysDown[key] = (GetAsyncKeyState(keyVK) & 0x8000);
|
||||
}
|
||||
return (keysDown[key] > 0);
|
||||
@@ -293,7 +293,7 @@ public:
|
||||
DWORD oldState = keysDown[dxKey];
|
||||
keysDown[dxKey] = state;
|
||||
|
||||
HookCommon::KeyPressHook(&dxKey, (state > 0), MapVirtualKeyEx(dxKey, MAPVK_VSC_TO_VK, keyboardLayout));
|
||||
HookCommon::KeyPressHook(&dxKey, (state > 0), MapVirtualKeyExA(dxKey, MAPVK_VSC_TO_VK, keyboardLayout));
|
||||
|
||||
if ((signed)dxKey > 0 && dxKey != buf[i].dwOfs) {
|
||||
keysDown[buf[i].dwOfs] = oldState;
|
||||
|
||||
@@ -202,7 +202,7 @@ noFile:
|
||||
|
||||
void FallbackEnglishCredits() {
|
||||
const char* lang;
|
||||
if (fo::func::get_game_config_string(&lang, "system", "language") && stricmp(lang, "english") != 0) {
|
||||
if (fo::func::get_game_config_string(&lang, "system", "language") && _stricmp(lang, "english") != 0) {
|
||||
HookCall(0x42C900, CreditsFileHook);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ static void PerkAndTraitSetup() {
|
||||
char *stat, *mod;
|
||||
stat = strtok(buf, "|");
|
||||
mod = strtok(0, "|");
|
||||
while (stat&&mod) {
|
||||
while (stat && mod) {
|
||||
int _stat = atoi(stat), _mod = atoi(mod);
|
||||
if (_stat >= 0 && _stat <= fo::STAT_max_derived) traitStatBonuses[_stat * fo::Trait::TRAIT_count + i] = _mod;
|
||||
stat = strtok(0, "|");
|
||||
@@ -829,7 +829,7 @@ static void PerkAndTraitSetup() {
|
||||
char *stat, *mod;
|
||||
stat = strtok(buf, "|");
|
||||
mod = strtok(0, "|");
|
||||
while (stat&&mod) {
|
||||
while (stat && mod) {
|
||||
int _stat = atoi(stat), _mod = atoi(mod);
|
||||
if (_stat >= 0 && _stat < 18) traitSkillBonuses[_stat * fo::Trait::TRAIT_count + i] = _mod;
|
||||
stat = strtok(0, "|");
|
||||
|
||||
@@ -166,7 +166,7 @@ static void CreateSndWnd() {
|
||||
wcx.hInstance = GetModuleHandleA(0);
|
||||
wcx.lpszClassName = "sfallSndWnd";
|
||||
|
||||
RegisterClassEx(&wcx);
|
||||
RegisterClassExA(&wcx);
|
||||
soundwindow = CreateWindowA("sfallSndWnd", "SndWnd", 0, 0, 0, 0, 0, HWND_MESSAGE, 0, wcx.hInstance, 0);
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
|
||||
+14
-6
@@ -188,18 +188,26 @@ static void GetHRPModule() {
|
||||
|
||||
static void CompatModeCheck(HKEY root, const char* filepath, int extra) {
|
||||
HKEY key;
|
||||
char buf[MAX_PATH];
|
||||
char buf[MAX_PATH] = {0};
|
||||
DWORD size = MAX_PATH;
|
||||
DWORD type;
|
||||
if (!(type = RegOpenKeyEx(root, "Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", 0, extra | STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, &key))) {
|
||||
if (!RegQueryValueEx(key, filepath, 0, &type, (BYTE*)buf, &size)) {
|
||||
if (!RegOpenKeyExA(root, "Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", 0, extra | STANDARD_RIGHTS_READ | KEY_QUERY_VALUE, &key)) {
|
||||
if (!RegQueryValueExA(key, filepath, 0, &type, (BYTE*)buf, &size)) {
|
||||
if (size >= MAX_PATH) {
|
||||
size = MAX_PATH - 1; // prevent overflow
|
||||
}
|
||||
buf[size] = '\0'; // null-terminate the buffer
|
||||
|
||||
if (size && (type == REG_EXPAND_SZ || type == REG_MULTI_SZ || type == REG_SZ)) {
|
||||
if (strstr(buf, "256COLOR") || strstr(buf, "640X480") || strstr(buf, "WIN")) {
|
||||
char* pos = strstr(buf, "DISABLEDXMAXIMIZEDWINDOWEDMODE"); // "Disable fullscreen optimizations" in Win10
|
||||
if (pos) std::memmove(pos, pos + 30, strlen(pos + 30) + 1); // remove the substring
|
||||
|
||||
if (strstr(buf, "256COLOR") || strstr(buf, "640X480") || strstr(buf, "WIN") || strstr(buf, "NT4") || strstr(buf, "VISTA")) {
|
||||
RegCloseKey(key);
|
||||
|
||||
MessageBoxA(0, "Fallout appears to be running in compatibility mode.\n" //, and sfall was not able to disable it.\n"
|
||||
"Please check the compatibility tab of fallout2.exe, and ensure that the following settings are unchecked:\n"
|
||||
"Run this program in compatibility mode for..., run in 256 colours, and run in 640x480 resolution.\n"
|
||||
"Run this program in compatibility mode for..., run in 256 colors, and run in 640x480 resolution.\n"
|
||||
"If these options are disabled, click the 'change settings for all users' button and see if that enables them.", 0, MB_TASKMODAL | MB_ICONERROR);
|
||||
|
||||
ExitProcess(-1);
|
||||
@@ -252,7 +260,7 @@ static HMODULE SfallInit() {
|
||||
if (IniReader::GetIntDefaultConfig("Debugging", "SkipCompatModeCheck", 0) == 0) {
|
||||
int is64bit;
|
||||
typedef int (__stdcall *chk64bitproc)(HANDLE, int*);
|
||||
HMODULE h = LoadLibrary("Kernel32.dll");
|
||||
HMODULE h = LoadLibraryA("Kernel32.dll");
|
||||
chk64bitproc proc = (chk64bitproc)GetProcAddress(h, "IsWow64Process");
|
||||
if (proc)
|
||||
proc(GetCurrentProcess(), &is64bit);
|
||||
|
||||
Reference in New Issue
Block a user