From 650deb67a5baa60fc615ecb11803cabdf036b1f0 Mon Sep 17 00:00:00 2001 From: Flugente Date: Tue, 2 Sep 2014 20:11:16 +0000 Subject: [PATCH] Fix: light sources did not decay in turnbased mode git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7482 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/LightEffects.cpp | 42 +++++++++++++++++++++++++++---------- TileEngine/SmokeEffects.cpp | 26 +++++++++++------------ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/TileEngine/LightEffects.cpp b/TileEngine/LightEffects.cpp index b569db62..599acb25 100644 --- a/TileEngine/LightEffects.cpp +++ b/TileEngine/LightEffects.cpp @@ -207,11 +207,13 @@ void DecayLightEffects( UINT32 uiTime ) { LIGHTEFFECT *pLight; UINT32 cnt, cnt2; + BOOLEAN fUpdate = FALSE; BOOLEAN fDelete = FALSE; + BOOLEAN fAnyUpdate = FALSE; UINT16 usNumUpdates = 1; // age all active tear gas clouds, deactivate those that are just dispersing - for ( cnt = 0; cnt < guiNumLightEffects; cnt++ ) + for ( cnt = 0; cnt < guiNumLightEffects; ++cnt ) { pLight = &gLightEffectData[ cnt ]; @@ -219,19 +221,32 @@ void DecayLightEffects( UINT32 uiTime ) if ( pLight->fAllocated ) { - // ATE: Do this every so ofte, to acheive the effect we want... - if ( ( uiTime - pLight->uiTimeOfLastUpdate ) > 10 ) - { - usNumUpdates = ( UINT16 ) ( ( uiTime - pLight->uiTimeOfLastUpdate ) / 10 ); + usNumUpdates = 1; + // Do things differently for combat /vs realtime + // always try to update during combat + if ( gTacticalStatus.uiFlags & INCOMBAT ) + { + fUpdate = TRUE; + } + // ATE: Do this every so ofte, to acheive the effect we want... + else if ( (uiTime - pLight->uiTimeOfLastUpdate) > 10 ) + { + fUpdate = TRUE; + usNumUpdates = (UINT16)((uiTime - pLight->uiTimeOfLastUpdate) / 10); + } + + if ( fUpdate ) + { pLight->uiTimeOfLastUpdate = uiTime; - for ( cnt2 = 0; cnt2 < usNumUpdates; cnt2++ ) + for ( cnt2 = 0; cnt2 < usNumUpdates; ++cnt2 ) { - pLight->bAge++; + ++pLight->bAge; if ( pLight->ubDuration <= 0 ) fDelete = TRUE; + // if this cloud remains effective (duration not reached) if ( pLight->bAge < pLight->ubDuration) { @@ -239,7 +254,7 @@ void DecayLightEffects( UINT32 uiTime ) // cloud expands by 1 every turn outdoors, and every other turn indoors if ( ( pLight->bAge % 2 ) ) { - pLight->bRadius--; + --pLight->bRadius; } if ( pLight->bRadius == 0 ) @@ -270,12 +285,17 @@ void DecayLightEffects( UINT32 uiTime ) } } - - // Handle sight here.... - AllTeamsLookForAll( FALSE ); + // we have to update sight later on if any light was updated + fAnyUpdate = TRUE; } } } + + if ( fAnyUpdate ) + { + // Handle sight here.... + AllTeamsLookForAll( FALSE ); + } } diff --git a/TileEngine/SmokeEffects.cpp b/TileEngine/SmokeEffects.cpp index 2e059ef1..ed8b0310 100644 --- a/TileEngine/SmokeEffects.cpp +++ b/TileEngine/SmokeEffects.cpp @@ -558,7 +558,7 @@ void DecaySmokeEffects( UINT32 uiTime ) INT8 bLevel; UINT16 usNumUpdates = 1; - for ( cnt = 0; cnt < guiNumMercSlots; cnt++ ) + for ( cnt = 0; cnt < guiNumMercSlots; ++cnt ) { if ( MercSlots[ cnt ] ) { @@ -571,7 +571,7 @@ void DecaySmokeEffects( UINT32 uiTime ) // all the deleting has to be done first/// // age all active tear gas clouds, deactivate those that are just dispersing - for ( cnt = 0; cnt < guiNumSmokeEffects; cnt++ ) + for ( cnt = 0; cnt < guiNumSmokeEffects; ++cnt ) { fSpreadEffect = TRUE; @@ -608,7 +608,7 @@ void DecaySmokeEffects( UINT32 uiTime ) { pSmoke->uiTimeOfLastUpdate = uiTime; - for ( cnt2 = 0; cnt2 < usNumUpdates; cnt2++ ) + for ( cnt2 = 0; cnt2 < usNumUpdates; ++cnt2 ) { pSmoke->bAge++; @@ -660,24 +660,24 @@ void DecaySmokeEffects( UINT32 uiTime ) } } - for ( cnt = 0; cnt < guiNumSmokeEffects; cnt++ ) + for ( cnt = 0; cnt < guiNumSmokeEffects; ++cnt ) { pSmoke = &gSmokeEffectData[ cnt ]; if ( pSmoke->fAllocated ) { - if ( pSmoke->bFlags & SMOKE_EFFECT_ON_ROOF ) - { - bLevel = 1; - } - else - { - bLevel = 0; - } - // if this cloud remains effective (duration not reached) if ( pSmoke->bFlags & SMOKE_EFFECT_MARK_FOR_UPDATE ) { + if ( pSmoke->bFlags & SMOKE_EFFECT_ON_ROOF ) + { + bLevel = 1; + } + else + { + bLevel = 0; + } + SpreadEffect( pSmoke->sGridNo, pSmoke->ubRadius, pSmoke->usItem, pSmoke->ubOwner, TRUE, bLevel, cnt ); pSmoke->bFlags &= (~SMOKE_EFFECT_MARK_FOR_UPDATE); }