diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 7c2eb5d5..efc593ec 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -34,7 +34,7 @@ UseCommandLine=0 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [Speed] -;Set to 1 to enable options related to the game speed adjustment (SpeedMulti#, SpeedKey#, SpeedModKey, and SpeedToggleKey) +;Set to 0 to disable everything in this section Enable=1 ;The speeds corresponding to each slot in percent. (i.e. 100 is normal speed) @@ -236,7 +236,7 @@ WindowScrollKey=0 ReloadWeaponKey=0 ;A key to hold down to let you move/drop a whole stack of items at once without the 'Move Items' window -;Set to 0 if you don't want to use a modifier key, or a DX scancode otherwise +;Set to 0 if you don't want a fast move key, or a DX scancode otherwise ItemFastMoveKey=29 ;Set to 1 to skip the 'Move Items' window when taking items from containers or corpses and not holding down ItemFastMoveKey diff --git a/sfall/Modules/SpeedPatch.cpp b/sfall/Modules/SpeedPatch.cpp index cc63d316..d32f4f08 100644 --- a/sfall/Modules/SpeedPatch.cpp +++ b/sfall/Modules/SpeedPatch.cpp @@ -77,7 +77,7 @@ static struct SpeedCfg { float multiplier; } *speed = nullptr; -static int modKey[2]; +static int modKey[2] = {0}; static int toggleKey; static bool defaultDelay = true; @@ -97,7 +97,7 @@ static void SetKeyboardDelay() { static DWORD __stdcall FakeGetTickCount() { // Keyboard control - if (modKey[0] && (KeyDown(modKey[0]) || (modKey[1] && KeyDown(modKey[1])))) { + if (!modKey[0] || (modKey[0] && KeyDown(modKey[0])) || (modKey[1] && KeyDown(modKey[1]))) { if (toggleKey && KeyDown(toggleKey)) { if (!toggled) { toggled = true; @@ -176,8 +176,6 @@ void TimerInit() { GetLocalTime(&time); SystemTimeToFileTime(&time, (FILETIME*)&startTime); - if (!modKey[0]) return; - speed = new SpeedCfg[10]; char buf[2], spKey[10] = "SpeedKey#"; @@ -191,16 +189,12 @@ void TimerInit() { } void SpeedPatch::init() { - int init = IniReader::GetConfigInt("Speed", "SpeedMultiInitial", 100); - - if (IniReader::GetConfigInt("Speed", "Enable", 0)) { - modKey[0] = IniReader::GetConfigInt("Input", "SpeedModKey", 0); - toggleKey = IniReader::GetConfigInt("Input", "SpeedToggleKey", 0); - } - if (init == 100 && !modKey[0]) return; - + if (IniReader::GetConfigInt("Speed", "Enable", 0) == 0) return; dlogr("Applying speed patch.", DL_INIT); + modKey[0] = IniReader::GetConfigInt("Input", "SpeedModKey", -1); + toggleKey = IniReader::GetConfigInt("Input", "SpeedToggleKey", 0); + switch (modKey[0]) { case -1: modKey[0] = DIK_LCONTROL; @@ -214,11 +208,9 @@ void SpeedPatch::init() { modKey[0] = DIK_LSHIFT; modKey[1] = DIK_RSHIFT; break; - default: - modKey[1] = 0; } - multi = init / 100.0f; + multi = IniReader::GetConfigInt("Speed", "SpeedMultiInitial", 100) / 100.0f; getTickCountOffs = (DWORD)&FakeGetTickCount; getLocalTimeOffs = (DWORD)&FakeGetLocalTime;