mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed value bounds for the redefined key code value in HOOK_KEYPRESS
Minor code & document edits.
This commit is contained in:
+2
-2
@@ -132,9 +132,9 @@ ScrollMod=0
|
||||
MouseSensitivity=100
|
||||
|
||||
;DX scancode of a key to press when the middle mouse button is clicked
|
||||
;The default of 0x30 toggles between your two weapons
|
||||
;The default of 48 ('B' key) toggles between your active items
|
||||
;Set to 0 to disable
|
||||
MiddleMouse=0x30
|
||||
MiddleMouse=48
|
||||
|
||||
;Set to 1 to reverse the left and right mouse buttons
|
||||
ReverseMouseButtons=0
|
||||
|
||||
@@ -406,7 +406,7 @@ int ret0 - The new amount of ammo to be consumed, or ammo cost per round for
|
||||
#### `HOOK_KEYPRESS (hs_keypress.int)`
|
||||
|
||||
Runs once every time when any key was pressed or released.
|
||||
- DX codes: (see **dik.h** header)
|
||||
- DX codes: see **dik.h** header or https://kippykip.com/b3ddocs/commands/scancodes.htm
|
||||
- VK codes: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
|
||||
|
||||
__NOTE:__ if you want to override a key, the new key DX scancode should be the same for both pressed and released events.
|
||||
|
||||
@@ -25,7 +25,7 @@ enum AnimFlags {
|
||||
e_InCombat = 0x002,
|
||||
e_Reserved = 0x004,
|
||||
e_InUse = 0x008,
|
||||
e_Suspend = 0x010,
|
||||
e_Suspend = 0x010, // animation not start running in register_end
|
||||
e_Clear = 0x020,
|
||||
e_EndAnim = 0x040,
|
||||
e_DontStand = 0x080,
|
||||
@@ -60,7 +60,7 @@ static const DWORD anim_set_0[] = { // curr_anim
|
||||
0x414E48, 0x414EDA, 0x414F5E, 0x414FEE, 0x41505C, 0x4150D0, 0x415158,
|
||||
0x4151B8, 0x415286, 0x41535C, 0x4153D0, 0x41544A, 0x4154EC, 0x4155EA,
|
||||
0x4156C0, 0x4156D5, 0x4156F2, 0x41572F, 0x41573E, 0x415B1B, 0x415B56,
|
||||
0x415BB6, 0x415C7C, 0x415CA3, /*0x415DE4, - conflct with 0x415DE2*/
|
||||
0x415BB6, 0x415C7C, 0x415CA3, /*0x415DE4, - conflict with 0x415DE2*/
|
||||
};
|
||||
|
||||
static const DWORD anim_set_4[] = { // counter
|
||||
@@ -172,10 +172,10 @@ skip:
|
||||
}
|
||||
|
||||
static bool __fastcall CheckSetSad(BYTE openFlag, DWORD slot) {
|
||||
if (animSad[slot].currentAnim == -1000) {
|
||||
if (animSad[slot].animStep == -1000) {
|
||||
return true;
|
||||
} else if (!InCombat() && !(openFlag & 1)) {
|
||||
animSad[slot].currentAnim = -1000;
|
||||
animSad[slot].animStep = -1000;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -208,7 +208,7 @@ static void __declspec(naked) action_climb_ladder_hook() {
|
||||
pop edx;
|
||||
jne skip;
|
||||
reset:
|
||||
and al, ~0x4; // reset RB_DONTSTAND flag
|
||||
and al, ~RB_DONTSTAND; // unset flag
|
||||
skip:
|
||||
jmp register_begin_;
|
||||
}
|
||||
@@ -278,9 +278,9 @@ void ApplyAnimationsAtOncePatches(signed char aniMax) {
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->animCode, sad_C);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->ticks, sad_10);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->tpf, sad_14);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->currAnimSet, sad_18);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->animSetSlot, sad_18);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->pathCount, sad_1C);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->currentAnim, sad_20);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->animStep, sad_20);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->dstTile, sad_24);
|
||||
SafeWrite32(0x416903, (DWORD)&animSad->rotation1);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->rotation2, sad_27);
|
||||
|
||||
@@ -56,8 +56,8 @@ struct AnimationSet {
|
||||
|
||||
struct Animation {
|
||||
long animType;
|
||||
long source;
|
||||
long target;
|
||||
TGameObj* source;
|
||||
TGameObj* target;
|
||||
long data1;
|
||||
long elevation;
|
||||
long animCode;
|
||||
@@ -74,18 +74,20 @@ static_assert(sizeof(AnimationSet) == 2656, "Incorrect AnimationSet definition."
|
||||
|
||||
struct AnimationSad {
|
||||
long flags;
|
||||
long source;
|
||||
TGameObj* source;
|
||||
long fid;
|
||||
long animCode;
|
||||
long ticks;
|
||||
long tpf; // fps
|
||||
long currAnimSet;
|
||||
long animSetSlot;
|
||||
long pathCount; // len
|
||||
long currentAnim;
|
||||
long animStep; // current step in rotationData/pathData
|
||||
short dstTile;
|
||||
char rotation1;
|
||||
char rotation2;
|
||||
|
||||
union {
|
||||
long rotationData[800];
|
||||
struct BuildPathData {
|
||||
long tile;
|
||||
long elevation;
|
||||
@@ -93,6 +95,7 @@ struct AnimationSad {
|
||||
long sY;
|
||||
} pathData[200];
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(AnimationSad) == 3240, "Incorrect AnimationSad definition.");
|
||||
|
||||
|
||||
@@ -938,7 +938,10 @@ void __stdcall KeyPressHook(DWORD* dxKey, bool pressed, DWORD vKey) {
|
||||
args[1] = *dxKey;
|
||||
args[2] = vKey;
|
||||
RunHookScript(HOOK_KEYPRESS);
|
||||
if (cRet != 0) *dxKey = rets[0];
|
||||
if (cRet != 0) {
|
||||
long retKey = rets[0];
|
||||
if (retKey > 0 && retKey < 264) *dxKey = retKey;
|
||||
}
|
||||
EndHook();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ static double mousePartX;
|
||||
static double mousePartY;
|
||||
|
||||
#define MAX_KEYS (264)
|
||||
|
||||
static DWORD keysDown[MAX_KEYS] = {0};
|
||||
|
||||
static int mouseX;
|
||||
@@ -62,6 +63,7 @@ static int mouseY;
|
||||
static DWORD forcingGraphicsRefresh = 0;
|
||||
|
||||
void __stdcall ForceGraphicsRefresh(DWORD d) {
|
||||
if (!d3d9Device) return;
|
||||
forcingGraphicsRefresh = (d == 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -287,11 +289,14 @@ public:
|
||||
|
||||
for (DWORD i = 0; i < *count; i++) {
|
||||
DWORD dxKey = buf[i].dwOfs;
|
||||
assert(dxKey >= 0 && dxKey < MAX_KEYS);
|
||||
DWORD state = buf[i].dwData & 0x80;
|
||||
DWORD oldState = keysDown[dxKey];
|
||||
keysDown[dxKey] = state;
|
||||
|
||||
KeyPressHook(&dxKey, (state > 0), MapVirtualKeyEx(dxKey, MAPVK_VSC_TO_VK, keyboardLayout));
|
||||
if (dxKey > 0 && dxKey != buf[i].dwOfs) {
|
||||
|
||||
if ((signed)dxKey > 0 && dxKey != buf[i].dwOfs) {
|
||||
keysDown[buf[i].dwOfs] = oldState;
|
||||
buf[i].dwOfs = dxKey; // Override key
|
||||
keysDown[buf[i].dwOfs] = state;
|
||||
@@ -446,7 +451,7 @@ HRESULT __stdcall FakeDirectInputCreate(HINSTANCE a, DWORD b, IDirectInputA** c,
|
||||
mousePartY = 0;
|
||||
} else adjustMouseSpeed = false;
|
||||
|
||||
middleMouseKey = GetConfigInt("Input", "MiddleMouse", 0x30);
|
||||
middleMouseKey = GetConfigInt("Input", "MiddleMouse", DIK_B);
|
||||
middleMouseDown = false;
|
||||
|
||||
backgroundKeyboard = GetConfigInt("Input", "BackgroundKeyboard", 0) != 0;
|
||||
|
||||
Reference in New Issue
Block a user