From 2930d23128ba69536feb8ac9898c9597eea946ab Mon Sep 17 00:00:00 2001 From: Kernell Date: Thu, 7 Jan 2016 21:12:49 +0300 Subject: [PATCH] Check parents in the method CEvent::IsPropagated --- mta-mono/src/CEvent.cpp | 24 +++++++++++++++++++++++- mta-mono/src/CEvent.h | 12 ++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/mta-mono/src/CEvent.cpp b/mta-mono/src/CEvent.cpp index 506eaa1..fe58457 100644 --- a/mta-mono/src/CEvent.cpp +++ b/mta-mono/src/CEvent.cpp @@ -32,7 +32,29 @@ CEvent::~CEvent( void ) this->m_pEventManager = nullptr; } -bool CEvent::Call( CElement* pThis, void** params ) +bool CEvent::IsPropagated( CElement* pSource ) const +{ + if( this->m_bPropagated ) + { + CElement* pParent = pSource; + + while( pParent != this->m_pElement ) + { + pParent = pParent->GetParent(); + + if( !pParent ) + { + return false; + } + } + + return true; + } + + return false; +} + +bool CEvent::Call( CElement* pThis, PVOID* params ) const { CResource* pResource = this->m_pEventManager->GetResource(); diff --git a/mta-mono/src/CEvent.h b/mta-mono/src/CEvent.h index 6e04133..5969f58 100644 --- a/mta-mono/src/CEvent.h +++ b/mta-mono/src/CEvent.h @@ -38,13 +38,13 @@ public: CEvent ( CEventManager* pEventManager, string strName, CElement* pElement, MonoObject* pMonoDelegate, bool bPropagated, string strPriority ); ~CEvent ( void ); - bool Call ( CElement* pThis, void** params ); + bool Call ( CElement* pThis, PVOID* params ) const; + bool IsPropagated ( CElement* pSource ) const; - string GetName ( void ) { return this->m_strName; } - CElement* GetElement ( void ) { return this->m_pElement; } - MonoObject* GetDelegate ( void ) { return this->m_pMonoDelegate; } - bool IsPropagated ( void ) { return this->m_bPropagated; } - string GetPriority ( void ) { return this->m_strPriority; } + inline string GetName ( void ) const { return this->m_strName; } + inline CElement* GetElement ( void ) const { return this->m_pElement; } + inline MonoObject* GetDelegate ( void ) const { return this->m_pMonoDelegate; } + inline string GetPriority ( void ) const { return this->m_strPriority; } }; #endif \ No newline at end of file