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
@@ -159,9 +159,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.
|
||||
|
||||
@@ -66,8 +66,8 @@ struct AnimationSet {
|
||||
|
||||
struct Animation {
|
||||
long animType;
|
||||
long source;
|
||||
long target;
|
||||
GameObject* source;
|
||||
GameObject* target;
|
||||
long data1;
|
||||
long elevation;
|
||||
long animCode;
|
||||
@@ -84,24 +84,27 @@ static_assert(sizeof(AnimationSet) == 2656, "Incorrect AnimationSet definition."
|
||||
|
||||
struct AnimationSad {
|
||||
long flags;
|
||||
long source;
|
||||
GameObject* 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;
|
||||
long sX;
|
||||
long sY;
|
||||
} pathData[200];
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(AnimationSad) == 3240, "Incorrect AnimationSad definition.");
|
||||
|
||||
@@ -52,6 +52,7 @@ static double mousePartX;
|
||||
static double mousePartY;
|
||||
|
||||
#define MAX_KEYS (264)
|
||||
|
||||
static DWORD keysDown[MAX_KEYS] = {0};
|
||||
|
||||
static int mouseX;
|
||||
@@ -60,6 +61,7 @@ static int mouseY;
|
||||
static DWORD forcingGraphicsRefresh = 0;
|
||||
|
||||
void __stdcall ForceGraphicsRefresh(DWORD d) {
|
||||
if (!d3d9Device) return;
|
||||
forcingGraphicsRefresh = (d == 0) ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -301,11 +303,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;
|
||||
|
||||
HookCommon::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;
|
||||
@@ -448,7 +453,7 @@ inline void InitInputFeatures() {
|
||||
mousePartY = 0;
|
||||
} else adjustMouseSpeed = false;
|
||||
|
||||
middleMouseKey = IniReader::GetConfigInt("Input", "MiddleMouse", 0x30);
|
||||
middleMouseKey = IniReader::GetConfigInt("Input", "MiddleMouse", DIK_B);
|
||||
middleMouseDown = false;
|
||||
|
||||
backgroundKeyboard = IniReader::GetConfigInt("Input", "BackgroundKeyboard", 0) != 0;
|
||||
|
||||
@@ -30,7 +30,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,
|
||||
@@ -66,7 +66,7 @@ static struct AnimSetHack {
|
||||
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*/
|
||||
};
|
||||
|
||||
const DWORD anim_set_4[9] = { // counter
|
||||
@@ -181,10 +181,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;
|
||||
@@ -206,6 +206,7 @@ end:
|
||||
}
|
||||
|
||||
static void __declspec(naked) action_climb_ladder_hook() {
|
||||
using namespace fo;
|
||||
__asm {
|
||||
cmp word ptr [edi + 0x40], 0xFFFF; // DestTile
|
||||
je skip;
|
||||
@@ -217,7 +218,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 fo::funcoffs::register_begin_;
|
||||
}
|
||||
@@ -288,9 +289,9 @@ void ApplyAnimationsAtOncePatches(signed char aniMax) {
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->animCode, sadAddrs.sad_C);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->ticks, sadAddrs.sad_10);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->tpf, sadAddrs.sad_14);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->currAnimSet, sadAddrs.sad_18);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->animSetSlot, sadAddrs.sad_18);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->pathCount, sadAddrs.sad_1C);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->currentAnim, sadAddrs.sad_20);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->animStep, sadAddrs.sad_20);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->dstTile, sadAddrs.sad_24);
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->rotation1, { 0x416903 });
|
||||
SafeWriteBatch<DWORD>((DWORD)&animSad->rotation2, sadAddrs.sad_27);
|
||||
|
||||
@@ -174,7 +174,10 @@ void HookCommon::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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user