From 0c521e2623b0364ba5be8e4dcce2193631357d06 Mon Sep 17 00:00:00 2001 From: silversurfer Date: Fri, 14 Apr 2017 19:03:55 +0000 Subject: [PATCH] Fixes (by The_Bob): - Fixed never ending interrupt bug (cats/bugs got interrupt when out of breath) - Added condition to interrupt code for minimal breath left to get interrupts - Tweaked timer control code git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8401 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.cpp | 16 ++++++++-------- Tactical/Soldier Control.cpp | 4 +++- Tactical/TeamTurns.cpp | 2 +- Utils/Timer Control.cpp | 6 +++--- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/GameVersion.cpp b/GameVersion.cpp index a2abb30cc..e9c7a6f7d 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -15,9 +15,9 @@ #ifdef JA2EDITOR #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8401 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8401 (Development Build)" }; #endif // ------------------------------ @@ -27,11 +27,11 @@ //DEBUG BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8401 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8401 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8401 (Development Build)" }; #endif #elif defined CRIPPLED_VERSION @@ -46,11 +46,11 @@ //RELEASE BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8401 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8401 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Release v1.13.8400 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.8401 (Development Build)" }; #endif #endif diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 9922b2360..9b8eb90a9 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -22006,8 +22006,10 @@ BOOLEAN ResolvePendingInterrupt( SOLDIERTYPE * pSoldier, UINT8 ubInterruptType ) pInterrupter = MercPtrs[uCnt]; if ( pInterrupter == NULL ) continue; // not valid - if ( pInterrupter->stats.bLife < OKLIFE || pInterrupter->bCollapsed || !pInterrupter->bActive || !pInterrupter->bInSector || pInterrupter->bActionPoints < 4 ) + if (pInterrupter->stats.bLife < OKLIFE || pInterrupter->bCollapsed || !pInterrupter->bActive || !pInterrupter->bInSector || pInterrupter->bActionPoints < 4) continue; // not active + if (pInterrupter->bBreath < OKBREATH && pInterrupter->bTeam != OUR_TEAM) + continue; // BOB: prevent NPCs from getting interrupts when out of breath if ( pSoldier->bTeam == pInterrupter->bTeam ) continue; // same team if ( pSoldier->bSide == pInterrupter->bSide ) diff --git a/Tactical/TeamTurns.cpp b/Tactical/TeamTurns.cpp index 26042ccdc..db9c1868c 100644 --- a/Tactical/TeamTurns.cpp +++ b/Tactical/TeamTurns.cpp @@ -2378,7 +2378,7 @@ void ResolveInterruptsVs( SOLDIERTYPE * pSoldier, UINT8 ubInterruptType) { pOpponent = MercPtrs[ubOpp]; AssertNotNIL(pOpponent); - if ( pOpponent->bActive && pOpponent->bInSector && (pOpponent->stats.bLife >= OKLIFE) && !(pOpponent->bCollapsed) ) + if ( pOpponent->bActive && pOpponent->bInSector && (pOpponent->stats.bLife >= OKLIFE) && (pOpponent->bBreath >= OKBREATH) && !(pOpponent->bCollapsed) ) { if ( ubInterruptType == NOISEINTERRUPT ) { diff --git a/Utils/Timer Control.cpp b/Utils/Timer Control.cpp index 56228a4c6..b25063266 100644 --- a/Utils/Timer Control.cpp +++ b/Utils/Timer Control.cpp @@ -289,12 +289,12 @@ UINT32 GetNextCounterDoneTime(void) gliTimestampDiff = gliPerfCountNext.QuadPart - gliPerfCount.QuadPart; gliWaitTime = (gliTimestampDiff * FREQUENCY_CONST) / gliPerfFreq.QuadPart; - // if the wait time is too long/short, re-evaluate the timer and try waiting 125ms - if (gliWaitTime > 15 * FREQUENCY_CONST) { + // if the wait time is too long, or the "missed" step gets too long, re-evaluate the timer and try waiting 125ms + if (gliWaitTime > 15000 || gliWaitTime < -15000) { gliWaitTime = 125; // in mili-seconds QueryPerformanceFrequency(&gliPerfFreq); - gliPerfCountNext.QuadPart = gliPerfCount.QuadPart + ((125 * gliPerfFreq.QuadPart) / 1000000); + gliPerfCountNext.QuadPart = gliPerfCount.QuadPart + ((125 * gliPerfFreq.QuadPart) / FREQUENCY_CONST); } return (UINT32)((gliWaitTime > 0) ? gliWaitTime : 0);