diff --git a/Tactical/Weapons.h b/Tactical/Weapons.h index 22cf34db..a36c3390 100644 --- a/Tactical/Weapons.h +++ b/Tactical/Weapons.h @@ -299,7 +299,7 @@ typedef struct UINT8 ubVolatility; // maximum chance of accidental explosion UINT8 ubAnimationID; // Animation enum to use UINT32 uiIndex; - int ubDuration; + UINT16 ubDuration; UINT8 ubStartRadius; } EXPLOSIVETYPE; diff --git a/Tactical/XML_Explosive.cpp b/Tactical/XML_Explosive.cpp index 25a95134..d3ecb70b 100644 --- a/Tactical/XML_Explosive.cpp +++ b/Tactical/XML_Explosive.cpp @@ -187,7 +187,7 @@ explosiveEndElementHandle(void *userData, const char *name) else if(strcmp(name, "ubDuration") == 0) { pData->curElement = ELEMENT; - pData->curExplosive.ubDuration = (int) atol(pData->szCharData); + pData->curExplosive.ubDuration = (UINT16) atol(pData->szCharData); } pData->maxReadDepth--; diff --git a/TileEngine/LightEffects.cpp b/TileEngine/LightEffects.cpp index d7c5de7d..e722baa2 100644 --- a/TileEngine/LightEffects.cpp +++ b/TileEngine/LightEffects.cpp @@ -96,8 +96,8 @@ void UpdateLightingSprite( LIGHTEFFECT *pLight ) } -INT32 NewLightEffect( INT16 sGridNo, int ubDuration, UINT8 ubStartRadius ) -{ +INT32 NewLightEffect( INT16 sGridNo, UINT16 ubDuration, UINT8 ubStartRadius ) +{ LIGHTEFFECT *pLight; INT32 iLightIndex; @@ -159,6 +159,27 @@ void RemoveLightEffectFromTile( INT16 sGridNo ) } +BOOLEAN IsLightEffectAtTile( INT16 sGridNo ) +{ + LIGHTEFFECT *pLight; + UINT32 cnt; + + // Set to unallocated.... + for ( cnt = 0; cnt < guiNumLightEffects; cnt++ ) + { + pLight = &gLightEffectData[ cnt ]; + + if ( pLight->fAllocated ) + { + if ( pLight->sGridNo == sGridNo ) + { + return TRUE; + } + } + } + + return FALSE; +} void DecayLightEffects( UINT32 uiTime ) { @@ -187,6 +208,8 @@ void DecayLightEffects( UINT32 uiTime ) { pLight->bAge++; + if ( pLight->ubDuration <= 0 ) + fDelete = TRUE; // if this cloud remains effective (duration not reached) if ( pLight->bAge < pLight->ubDuration) { diff --git a/TileEngine/LightEffects.h b/TileEngine/LightEffects.h index 62a68e30..dd95f85c 100644 --- a/TileEngine/LightEffects.h +++ b/TileEngine/LightEffects.h @@ -15,9 +15,9 @@ typedef struct { INT16 sGridNo; // gridno at which the tear gas cloud is centered - int ubDuration; // the number of turns will remain effective + UINT16 ubDuration; // the number of turns will remain effective UINT8 bRadius; // the current radius - int bAge; // the number of turns light has been around + UINT16 bAge; // the number of turns light has been around BOOLEAN fAllocated; INT32 iLight; UINT32 uiTimeOfLastUpdate; @@ -35,7 +35,7 @@ void AddLightEffectToTile( INT8 bType, INT16 sGridNo ); void RemoveLightEffectFromTile( INT16 sGridNo ); -INT32 NewLightEffect( INT16 sGridNo, int ubDuration, UINT8 ubStartRadius ); +INT32 NewLightEffect( INT16 sGridNo, UINT16 ubDuration, UINT8 ubStartRadius ); BOOLEAN SaveLightEffectsToSaveGameFile( HWFILE hFile ); @@ -45,4 +45,6 @@ BOOLEAN SaveLightEffectsToMapTempFile( INT16 sMapX, INT16 sMapY, INT8 bMapZ ); BOOLEAN LoadLightEffectsFromMapTempFile( INT16 sMapX, INT16 sMapY, INT8 bMapZ ); void ResetLightEffects(); +BOOLEAN IsLightEffectAtTile( INT16 sGridNo ); + #endif \ No newline at end of file diff --git a/TileEngine/SmokeEffects.h b/TileEngine/SmokeEffects.h index ce7944f4..8ad1e135 100644 --- a/TileEngine/SmokeEffects.h +++ b/TileEngine/SmokeEffects.h @@ -22,10 +22,10 @@ typedef struct TAG_SMOKE_EFFECT { INT16 sGridNo; // gridno at which the tear gas cloud is centered - int ubDuration; // the number of turns gas will remain effective + UINT16 ubDuration; // the number of turns gas will remain effective UINT8 ubRadius; // the current radius of the cloud in map tiles UINT8 bFlags; // 0 - outdoors (fast spread), 1 - indoors (slow) - int bAge; // the number of turns gas has been around + UINT16 bAge; // the number of turns gas has been around BOOLEAN fAllocated; INT8 bType; UINT16 usItem; diff --git a/TileEngine/Tile Animation.cpp b/TileEngine/Tile Animation.cpp index 11e583e3..96fff437 100644 --- a/TileEngine/Tile Animation.cpp +++ b/TileEngine/Tile Animation.cpp @@ -138,7 +138,19 @@ ANITILE *CreateAnimationTile( ANITILE_PARAMS *pAniParams ) if ( uiFlags & ANITILE_LIGHT ) { - pNewAniNode->lightSprite = NewLightEffect(sGridNo, 1, 0); + if( !IsLightEffectAtTile(sGridNo) && ( pNewAniNode->lightSprite=LightSpriteCreate("L-R03.LHT", 0 ) )!=(-1)) + { + LightSpritePower(pNewAniNode->lightSprite, TRUE); + { + INT16 sXPos, sYPos; + + ConvertGridNoToCenterCellXY( sGridNo, &sXPos, &sYPos ); + LightSpritePosition( pNewAniNode->lightSprite, (INT16)(sXPos/CELL_X_SIZE), (INT16)(sYPos/CELL_Y_SIZE)); + AllTeamsLookForAll( FALSE ); + } + } + else + pNewAniNode->lightSprite = -1; } if ( ( uiFlags & ANITILE_CACHEDTILE ) ) @@ -368,7 +380,7 @@ void DeleteAniTile( ANITILE *pAniTile ) break; } - if ( pAniNode->uiFlags & ANITILE_LIGHT && pAniNode->lightSprite != NULL ) + if ( pAniNode->uiFlags & ANITILE_LIGHT && pAniNode->lightSprite > 0 ) { LightSpriteDestroy(pAniNode->lightSprite); } @@ -601,9 +613,9 @@ void UpdateAniTiles( ) } else { - if ( pNode->uiFlags & ANITILE_LIGHT && pNode->lightSprite != NULL ) + if ( pNode->uiFlags & ANITILE_LIGHT && pNode->lightSprite > 0 ) { - LightSpriteDestroy(pNode->lightSprite); + LightSpriteDestroy(pAniNode->lightSprite); } // Delete from world!