Skip to content

Commit a10305d

Browse files
ZReCJustus H
authored andcommitted
Add "soundEnable" parameter to createEffect function (#147)
For the reason of this comment: Https://bugs.mtasa.com/view.php?id=8590#c25890 I was able to turn off the sound of the particles, as before solving the bug. With the tests I did it seems to work fine :)
1 parent 68b09f6 commit a10305d

File tree

8 files changed

+20
-13
lines changed

8 files changed

+20
-13
lines changed

Client/game_sa/CFxManagerSA.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
#include "StdInc.h"
1313

1414

15-
CFxSystem* CFxManagerSA::CreateFxSystem( const char * szBlueprint, const CVector & vecPosition, RwMatrix * pRwMatrixTag, unsigned char bSkipCameraFrustumCheck )
15+
CFxSystem* CFxManagerSA::CreateFxSystem( const char * szBlueprint, const CVector & vecPosition, RwMatrix * pRwMatrixTag, unsigned char bSkipCameraFrustumCheck, bool bSoundEnable )
1616
{
1717
const CVector * pvecPosition = &vecPosition;
1818
DWORD dwThis = ( DWORD ) m_pInterface;
1919
DWORD dwFunc = FUNC_FxManager_c__CreateFxSystem;
2020
DWORD dwReturn = 0;
21+
2122
_asm
2223
{
2324
mov ecx, dwThis
@@ -28,8 +29,12 @@ CFxSystem* CFxManagerSA::CreateFxSystem( const char * szBlueprint, const CVector
2829
call dwFunc
2930
mov dwReturn, eax
3031
}
32+
3133
if ( dwReturn != 0 )
3234
{
35+
if ( !bSoundEnable )
36+
* ( DWORD * )( ( DWORD )dwReturn + 0x100 ) = NULL;
37+
3338
CFxSystemSA* pFxSystemSA = new CFxSystemSA((CFxSystemSAInterface*)dwReturn);
3439
return pFxSystemSA;
3540
}

Client/game_sa/CFxManagerSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class CFxManagerSA : public CFxManager
6262
public:
6363
CFxManagerSA( CFxManagerSAInterface * pInterface ) { m_pInterface = pInterface; }
6464
// CFxManager interface
65-
CFxSystem* CreateFxSystem( const char * szBlueprint, const CVector & vecPosition, RwMatrix * pRwMatrixTag, unsigned char bSkipCameraFrustumCheck );
65+
CFxSystem* CreateFxSystem( const char * szBlueprint, const CVector & vecPosition, RwMatrix * pRwMatrixTag, unsigned char bSkipCameraFrustumCheck, bool bSoundEnable );
6666
void DestroyFxSystem( CFxSystem* pFxSystem );
6767
void OnFxSystemSAInterfaceDestroyed ( CFxSystemSAInterface* pFxSystemSAInterface );
6868

Client/mods/deathmatch/logic/CClientEffectManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ void CClientEffectManager::DeleteAll( )
3333
m_bCanRemoveFromList = true;
3434
}
3535

36-
CClientEffect * CClientEffectManager::Create(const SString& strEffectName, const CVector &vecPosition, ElementID ID)
36+
CClientEffect * CClientEffectManager::Create(const SString& strEffectName, const CVector &vecPosition, ElementID ID, bool bSoundEnable )
3737
{
3838
if ( strEffectName.length () >= 0x60 )
3939
return NULL;
4040

41-
CFxSystem * pFxSA = g_pGame->GetFxManager()->CreateFxSystem ( strEffectName, vecPosition, NULL, true );
41+
CFxSystem * pFxSA = g_pGame->GetFxManager()->CreateFxSystem ( strEffectName, vecPosition, NULL, true, bSoundEnable );
4242
if ( pFxSA == NULL )
4343
return NULL; // GTA was unable to create the effect (e.g. wrong effect name)
4444

@@ -95,4 +95,4 @@ void CClientEffectManager::SAEffectDestroyed ( void *pFxSAInterface )
9595

9696
pFx->SetFxSystem ( NULL );
9797
g_pClientGame->GetElementDeleter()->Delete(pFx);
98-
}
98+
}

Client/mods/deathmatch/logic/CClientEffectManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CClientEffectManager
2121
friend class CClientManager;
2222

2323
public:
24-
CClientEffect* Create ( const SString& strEffectName, const CVector& vecPosition, ElementID ID );
24+
CClientEffect* Create ( const SString& strEffectName, const CVector& vecPosition, ElementID ID, bool bSoundEnable );
2525
void SAEffectDestroyed ( void * pFxSAInterface );
2626
void DeleteAll ( void );
2727

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7454,9 +7454,9 @@ bool CStaticFunctionDefinitions::FxAddFootSplash ( CVector & vecPosition )
74547454
return true;
74557455
}
74567456

7457-
CClientEffect* CStaticFunctionDefinitions::CreateEffect(CResource& Resource, const SString &strFxName, const CVector &vecPosition)
7457+
CClientEffect* CStaticFunctionDefinitions::CreateEffect( CResource& Resource, const SString &strFxName, const CVector &vecPosition, bool bSoundEnable )
74587458
{
7459-
CClientEffect * pFx = m_pManager->GetEffectManager()->Create(strFxName, vecPosition, INVALID_ELEMENT_ID);
7459+
CClientEffect * pFx = m_pManager->GetEffectManager()->Create( strFxName, vecPosition, INVALID_ELEMENT_ID, bSoundEnable );
74607460
if ( pFx )
74617461
pFx->SetParent ( Resource.GetResourceDynamicEntity () );
74627462
return pFx;

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ class CStaticFunctionDefinitions
636636
static bool FxAddWaterSplash ( CVector & vecPosition );
637637
static bool FxAddBulletSplash ( CVector & vecPosition );
638638
static bool FxAddFootSplash ( CVector & vecPosition );
639-
static CClientEffect* CreateEffect ( CResource& Resource, const SString& strFxName, const CVector& vecPosition );
639+
static CClientEffect* CreateEffect ( CResource& Resource, const SString& strFxName, const CVector& vecPosition, bool bSoundEnable );
640640

641641
// Sound funcs
642642
static CClientSound* PlaySound ( CResource* pResource, const SString& strSound, bool bIsURL, bool bLoop, bool bThrottle );

Client/mods/deathmatch/logic/luadefs/CLuaEffectDefs.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,18 +490,20 @@ int CLuaEffectDefs::fxAddFootSplash ( lua_State* luaVM )
490490

491491
int CLuaEffectDefs::CreateEffect ( lua_State* luaVM )
492492
{
493-
// bool createEffect ( string fxName, float posX, float posY, float posZ[, float rotX, float rotY, float rotZ, float drawDistance] )
493+
// bool createEffect ( string fxName, float posX, float posY, float posZ[, float rotX, float rotY, float rotZ, float drawDistance, bool soundEnable = false] )
494494

495495
CVector vecPosition;
496496
CVector vecRotation;
497497
SString strFxName;
498-
float fDrawDistance;
498+
float fDrawDistance;
499+
bool bSoundEnable;
499500

500501
CScriptArgReader argStream ( luaVM );
501502
argStream.ReadString ( strFxName );
502503
argStream.ReadVector3D ( vecPosition );
503504
argStream.ReadVector3D ( vecRotation, CVector ( 0, 0, 0 ) );
504505
argStream.ReadNumber ( fDrawDistance, 0 );
506+
argStream.ReadBool ( bSoundEnable, false );
505507

506508
if ( !argStream.HasErrors () )
507509
{
@@ -512,7 +514,7 @@ int CLuaEffectDefs::CreateEffect ( lua_State* luaVM )
512514
if ( pResource )
513515
{
514516
// Create it and return it
515-
CClientEffect * pFx = CStaticFunctionDefinitions::CreateEffect ( *pResource, strFxName, vecPosition );
517+
CClientEffect * pFx = CStaticFunctionDefinitions::CreateEffect ( *pResource, strFxName, vecPosition, bSoundEnable );
516518
if ( pFx != NULL )
517519
{
518520
pFx->SetRotationDegrees ( vecRotation );

Client/sdk/game/CFxManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CFxSystemSAInterface;
2020
class CFxManager
2121
{
2222
public:
23-
virtual CFxSystem* CreateFxSystem ( const char * szBlueprint, const CVector & vecPosition, RwMatrix * pRwMatrixTag, unsigned char bSkipCameraFrustumCheck ) = 0;
23+
virtual CFxSystem* CreateFxSystem ( const char * szBlueprint, const CVector & vecPosition, RwMatrix * pRwMatrixTag, unsigned char bSkipCameraFrustumCheck, bool bSoundEnable ) = 0;
2424
virtual void DestroyFxSystem ( CFxSystem* pFxSystem ) = 0;
2525
virtual void OnFxSystemSAInterfaceDestroyed ( CFxSystemSAInterface* pFxSystemSAInterface ) = 0;
2626
};

0 commit comments

Comments
 (0)