Reverted speed patch/keys behavior to pre-4.1.5

* Enable in [Speed] is the master switch for all Speed* settings.
* SpeedMultiInitial requires Enable=1, not a standalone setting.
* SpeedModKey=0 allows players to use only numpad keys to change speed.
This commit is contained in:
NovaRain
2024-05-24 21:36:50 +08:00
parent 6d432163ca
commit bc962aca9c
2 changed files with 9 additions and 17 deletions
+2 -2
View File
@@ -34,7 +34,7 @@ UseCommandLine=0
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Speed] [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 Enable=1
;The speeds corresponding to each slot in percent. (i.e. 100 is normal speed) ;The speeds corresponding to each slot in percent. (i.e. 100 is normal speed)
@@ -236,7 +236,7 @@ WindowScrollKey=0
ReloadWeaponKey=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 ;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 ItemFastMoveKey=29
;Set to 1 to skip the 'Move Items' window when taking items from containers or corpses and not holding down ItemFastMoveKey ;Set to 1 to skip the 'Move Items' window when taking items from containers or corpses and not holding down ItemFastMoveKey
+7 -15
View File
@@ -77,7 +77,7 @@ static struct SpeedCfg {
float multiplier; float multiplier;
} *speed = nullptr; } *speed = nullptr;
static int modKey[2]; static int modKey[2] = {0};
static int toggleKey; static int toggleKey;
static bool defaultDelay = true; static bool defaultDelay = true;
@@ -97,7 +97,7 @@ static void SetKeyboardDelay() {
static DWORD __stdcall FakeGetTickCount() { static DWORD __stdcall FakeGetTickCount() {
// Keyboard control // 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 (toggleKey && KeyDown(toggleKey)) {
if (!toggled) { if (!toggled) {
toggled = true; toggled = true;
@@ -176,8 +176,6 @@ void TimerInit() {
GetLocalTime(&time); GetLocalTime(&time);
SystemTimeToFileTime(&time, (FILETIME*)&startTime); SystemTimeToFileTime(&time, (FILETIME*)&startTime);
if (!modKey[0]) return;
speed = new SpeedCfg[10]; speed = new SpeedCfg[10];
char buf[2], spKey[10] = "SpeedKey#"; char buf[2], spKey[10] = "SpeedKey#";
@@ -191,16 +189,12 @@ void TimerInit() {
} }
void SpeedPatch::init() { void SpeedPatch::init() {
int init = IniReader::GetConfigInt("Speed", "SpeedMultiInitial", 100); if (IniReader::GetConfigInt("Speed", "Enable", 0) == 0) return;
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;
dlogr("Applying speed patch.", DL_INIT); dlogr("Applying speed patch.", DL_INIT);
modKey[0] = IniReader::GetConfigInt("Input", "SpeedModKey", -1);
toggleKey = IniReader::GetConfigInt("Input", "SpeedToggleKey", 0);
switch (modKey[0]) { switch (modKey[0]) {
case -1: case -1:
modKey[0] = DIK_LCONTROL; modKey[0] = DIK_LCONTROL;
@@ -214,11 +208,9 @@ void SpeedPatch::init() {
modKey[0] = DIK_LSHIFT; modKey[0] = DIK_LSHIFT;
modKey[1] = DIK_RSHIFT; modKey[1] = DIK_RSHIFT;
break; break;
default:
modKey[1] = 0;
} }
multi = init / 100.0f; multi = IniReader::GetConfigInt("Speed", "SpeedMultiInitial", 100) / 100.0f;
getTickCountOffs = (DWORD)&FakeGetTickCount; getTickCountOffs = (DWORD)&FakeGetTickCount;
getLocalTimeOffs = (DWORD)&FakeGetLocalTime; getLocalTimeOffs = (DWORD)&FakeGetLocalTime;