|
16 | 16 | #include "CFxSA.h" |
17 | 17 | #include "CEntitySA.h" |
18 | 18 | ; |
19 | | -using StoreShadowToBeRendered_t = int(__cdecl*)(eShadowType, struct RwTexture*, const CVector*, float, float, float, float, short, unsigned char, unsigned char, |
| 19 | +using StoreShadowToBeRendered_t = int(__cdecl*)(eShadowType, RwTexture*, const CVector*, float, float, float, float, short, unsigned char, unsigned char, |
20 | 20 | unsigned char, float, bool, float, class CRealTimeShadow*, bool); |
21 | | -auto StoreShadowToBeRendered = reinterpret_cast<StoreShadowToBeRendered_t>(0x707390); |
22 | | -unsigned short& CShadows_ShadowsStoredToBeRendered = *(unsigned short*)0xC403DC; |
| 21 | +inline auto StoreShadowToBeRendered = reinterpret_cast<StoreShadowToBeRendered_t>(FUNC_FXSystem_StoreShadows); |
| 22 | +inline unsigned short& CShadows_ShadowsStoredToBeRendered = *(unsigned short*)VAR_FXSystem_StoreShadows; |
23 | 23 |
|
24 | 24 | void CFxSA::AddBlood(CVector& vecPosition, CVector& vecDirection, int iCount, float fBrightness) |
25 | 25 | { |
@@ -340,19 +340,22 @@ void CFxSA::AddParticle(FxParticleSystems eFxParticle, const CVector& vecPositio |
340 | 340 |
|
341 | 341 | bool CFxSA::IsShadowsLimitReached() |
342 | 342 | { |
343 | | - constexpr int shadowsLimit = 48; |
344 | | - return CShadows_ShadowsStoredToBeRendered >= shadowsLimit; |
| 343 | + // GTA:SA can handle max 48 shadows per frame |
| 344 | + return CShadows_ShadowsStoredToBeRendered >= 48; |
345 | 345 | } |
346 | 346 |
|
347 | 347 | bool CFxSA::AddShadow(eShadowTextureType shadowTextureType, const CVector& vecPosition, const CVector2D& vecOffset1, const CVector2D& vecOffset2, SColor color, |
348 | 348 | eShadowType shadowType, float fZDistance, bool bDrawOnWater, bool bDrawOnBuildings) |
349 | 349 | { |
350 | | - if (IsShadowsLimitReached()) |
| 350 | + // Check if we can add more shadows this frame |
| 351 | + if (IsShadowsLimitReached() || shadowTextureType >= eShadowTextureType::COUNT) |
351 | 352 | return false; |
352 | 353 |
|
353 | | - void* textureAddress = *(void**)(FUNC_FXSystem_BaseShadow + (int)shadowTextureType * 4); |
| 354 | + // Get the RwTexture for the shadow |
| 355 | + void* textureAddress = *(void**)(TEXTURE_FXSystem_Shadow + (int)shadowTextureType * 4); |
354 | 356 | RwTexture* pRwTexture = reinterpret_cast<RwTexture*>(textureAddress); |
355 | 357 |
|
| 358 | + // Store the shadow to be rendered |
356 | 359 | return StoreShadowToBeRendered(shadowType, pRwTexture, &vecPosition, vecOffset1.fX, vecOffset1.fY, vecOffset2.fX, vecOffset2.fY, color.A, color.R, color.G, |
357 | 360 | color.B, fZDistance, bDrawOnWater, 1, 0, bDrawOnBuildings); |
358 | 361 | } |
0 commit comments