From 04a594543b3968de81c8724e0eeac07548575ee7 Mon Sep 17 00:00:00 2001 From: DudeMcDude Date: Tue, 12 Jan 2021 12:18:47 +0200 Subject: [PATCH 1/2] Fixed crash issue from lodged readied action with null handle --- TemplePlus/action_sequence.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/TemplePlus/action_sequence.cpp b/TemplePlus/action_sequence.cpp index c8684678d..43c2a9d6f 100644 --- a/TemplePlus/action_sequence.cpp +++ b/TemplePlus/action_sequence.cpp @@ -2209,7 +2209,18 @@ int32_t ActionSequenceSystem::InterruptNonCounterspell(D20Actn* d20a) int32_t ActionSequenceSystem::InterruptCounterspell(D20Actn* d20a) { - uint32_t result = 0; + auto result = FALSE; + + for (auto rdyAction = ReadiedActionGetNext(nullptr, d20a); + rdyAction!= nullptr; rdyAction = ReadiedActionGetNext(rdyAction, d20a)) { + if (rdyAction->readyType == ReadyVsTypeEnum::RV_Counterspell) { + InterruptSwitchActionSequence(rdyAction); + result = TRUE; + } + } + + return result; + /*uint32_t result = 0; __asm{ push esi; push ecx; @@ -2223,7 +2234,7 @@ int32_t ActionSequenceSystem::InterruptCounterspell(D20Actn* d20a) pop ecx; pop esi; } - return result; + return result;*/ } @@ -2314,6 +2325,11 @@ ReadiedActionPacket* ActionSequenceSystem::ReadiedActionGetNext(ReadiedActionPac void ActionSequenceSystem::InterruptSwitchActionSequence(ReadiedActionPacket* readiedAction) { + if (!readiedAction->interrupter) { + logger->error("InterruptSwitchActionSequence: Null objHnd! Aborting."); + return; + } + if (readiedAction->readyType == RV_Counterspell) return addresses.Counterspell_sthg(readiedAction); From 1c80bbf715dd6b98fdc97dc2f358652c7392c434 Mon Sep 17 00:00:00 2001 From: DudeMcDude Date: Fri, 15 Jan 2021 21:22:03 +0200 Subject: [PATCH 2/2] Fixed issue with SlowPosChange --- TemplePlus/tig/tig_mouse.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/TemplePlus/tig/tig_mouse.cpp b/TemplePlus/tig/tig_mouse.cpp index 3c730b550..8e6500386 100644 --- a/TemplePlus/tig/tig_mouse.cpp +++ b/TemplePlus/tig/tig_mouse.cpp @@ -93,10 +93,13 @@ void MouseFuncs::SetPos(int x, int y, int wheelDelta) auto& mouseLastChange = temple::GetRef(0x10D251C4); auto systemTime = temple::GetRef(0x11E74578); + + static int slowMoveRefX = mouseState->x, slowMoveRefY = mouseState->y; auto slowMoveDelta = abs(x - slowMoveRefX) + abs(y - slowMoveRefY); - auto timeDeltaMs = systemTime - mouseLastChange; + // systemTime += 2793682137; + auto timeDeltaMs = abs(systemTime - mouseLastChange); // abs delta in case the time stamp is above the integer limit if (x != mouseState->x || y != mouseState->y ) { mouseIsStatic = 0; //if (slowMoveDelta > 0) { // this was the effective vanilla condition