mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed temporary arrays being cleared when flushing the keyboard buffer (#337)
Added a message about failed initialization of the game and exit if an error occurs.
This commit is contained in:
@@ -104,7 +104,6 @@ Delegate<>& OnInputLoop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FlushInputBuffer() {
|
void FlushInputBuffer() {
|
||||||
while (!bufferedPresses.empty()) bufferedPresses.pop();
|
|
||||||
__asm call fo::funcoffs::kb_clear_;
|
__asm call fo::funcoffs::kb_clear_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,17 +266,25 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only called for the keyboard (dxinput_read_keyboard_buffer_ called at 0x4E06AB)
|
/* Only called for the keyboard
|
||||||
|
0x4E06AB dxinput_read_keyboard_buffer_
|
||||||
|
0x4E0631 dxinput_flush_keyboard_buffer_
|
||||||
|
*/
|
||||||
HRESULT __stdcall GetDeviceData(DWORD a, DIDEVICEOBJECTDATA* buf, DWORD* count, DWORD d) { // buf - DirectInputKeyboardBuffer (0x6B2560)
|
HRESULT __stdcall GetDeviceData(DWORD a, DIDEVICEOBJECTDATA* buf, DWORD* count, DWORD d) { // buf - DirectInputKeyboardBuffer (0x6B2560)
|
||||||
if (DeviceType != kDeviceType_KEYBOARD) {
|
if (DeviceType != kDeviceType_KEYBOARD) {
|
||||||
return RealDevice->GetDeviceData(a, buf, count, d);
|
return RealDevice->GetDeviceData(a, buf, count, d);
|
||||||
}
|
}
|
||||||
|
if (!buf && !d && *count == INFINITE) { // flush
|
||||||
|
while (!bufferedPresses.empty()) bufferedPresses.pop();
|
||||||
|
return RealDevice->GetDeviceData(a, buf, count, d);
|
||||||
|
}
|
||||||
|
|
||||||
onInputLoop.invoke();
|
onInputLoop.invoke();
|
||||||
|
|
||||||
if (!buf || bufferedPresses.empty() || (d & DIGDD_PEEK)) {
|
if (!buf || bufferedPresses.empty() || (d & DIGDD_PEEK)) {
|
||||||
HRESULT hr = RealDevice->GetDeviceData(a, buf, count, d);
|
HRESULT hr = RealDevice->GetDeviceData(a, buf, count, d);
|
||||||
if (FAILED(hr) || !buf || !(*count)) return hr;
|
if (FAILED(hr) || !buf || !(*count)) return hr;
|
||||||
|
|
||||||
for (DWORD i = 0; i < *count; i++) {
|
for (DWORD i = 0; i < *count; i++) {
|
||||||
DWORD dxKey = buf[i].dwOfs;
|
DWORD dxKey = buf[i].dwOfs;
|
||||||
DWORD state = buf[i].dwData & 0x80;
|
DWORD state = buf[i].dwData & 0x80;
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ const float* Graphics::rcpresGet() {
|
|||||||
static void GetDisplayMode(D3DDISPLAYMODE &ddm) {
|
static void GetDisplayMode(D3DDISPLAYMODE &ddm) {
|
||||||
ZeroMemory(&ddm, sizeof(ddm));
|
ZeroMemory(&ddm, sizeof(ddm));
|
||||||
d3d9->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &ddm);
|
d3d9->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &ddm);
|
||||||
dlog_f("\nDisplay mode format id: %d", DL_INIT, ddm.Format);
|
dlog_f("Display mode format id: %d\n", DL_INIT, ddm.Format);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ResetDevice(bool createNew) {
|
static void ResetDevice(bool createNew) {
|
||||||
|
|||||||
@@ -339,7 +339,13 @@ static void __stdcall game_init_hook() {
|
|||||||
onGameInit.invoke();
|
onGameInit.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __stdcall GameInitialized() {
|
static void __stdcall GameInitialized(int initResult) {
|
||||||
|
#ifdef NDEBUG
|
||||||
|
if (!initResult) {
|
||||||
|
MessageBoxA(0, "Game initialization failed!", "Error", MB_TASKMODAL | MB_ICONERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
onAfterGameInit.invoke();
|
onAfterGameInit.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,6 +364,7 @@ static void __declspec(naked) main_init_system_hook() {
|
|||||||
popadc;
|
popadc;
|
||||||
call fo::funcoffs::main_init_system_;
|
call fo::funcoffs::main_init_system_;
|
||||||
pushadc;
|
pushadc;
|
||||||
|
push eax;
|
||||||
call GameInitialized;
|
call GameInitialized;
|
||||||
popadc;
|
popadc;
|
||||||
retn;
|
retn;
|
||||||
|
|||||||
Reference in New Issue
Block a user