mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-24 11:12:20 +00:00
Global refactoring.
Removed global varriables g_pModuleManager and g_pResourceManager. Added CModule class with ILuaModuleManager methods. Added CElement class for synchronizing Lua-userdata with MonoObjects. Added CElementManager for caching elements. Added CMonoArguments helper class. Fixed passing references of removed object.
This commit is contained in:
parent
3b7b5190a2
commit
df922e1236
@ -139,8 +139,12 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\CElement.cpp" />
|
||||
<ClCompile Include="src\CElementManager.cpp" />
|
||||
<ClCompile Include="src\CEvent.cpp" />
|
||||
<ClCompile Include="src\CEventManager.cpp" />
|
||||
<ClCompile Include="src\CModule.cpp" />
|
||||
<ClCompile Include="src\CMonoArguments.cpp" />
|
||||
<ClCompile Include="src\CMonoClass.cpp" />
|
||||
<ClCompile Include="src\CMonoCorlib.cpp" />
|
||||
<ClCompile Include="src\CMonoDomain.cpp" />
|
||||
@ -187,8 +191,12 @@
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\CElement.h" />
|
||||
<ClInclude Include="src\CElementManager.h" />
|
||||
<ClInclude Include="src\CEvent.h" />
|
||||
<ClInclude Include="src\CEventManager.h" />
|
||||
<ClInclude Include="src\CModule.h" />
|
||||
<ClInclude Include="src\CMonoArguments.h" />
|
||||
<ClInclude Include="src\CMonoClass.h" />
|
||||
<ClInclude Include="src\CMonoCorlib.h" />
|
||||
<ClInclude Include="src\CMonoDomain.h" />
|
||||
|
@ -124,6 +124,16 @@
|
||||
<ClCompile Include="src\CRegisteredCommands.cpp">
|
||||
<Filter>ResourceInterface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CElement.cpp">
|
||||
<Filter>ResourceInterface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CElementManager.cpp">
|
||||
<Filter>ResourceInterface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\CModule.cpp" />
|
||||
<ClCompile Include="src\CMonoArguments.cpp">
|
||||
<Filter>MonoInterface</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\include\ILuaModuleManager.h">
|
||||
@ -284,6 +294,16 @@
|
||||
<ClInclude Include="src\CRegisteredCommands.h">
|
||||
<Filter>ResourceInterface</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CElement.h">
|
||||
<Filter>ResourceInterface</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CElementManager.h">
|
||||
<Filter>ResourceInterface</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\CModule.h" />
|
||||
<ClInclude Include="src\CMonoArguments.h">
|
||||
<Filter>MonoInterface</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="MonoInterface">
|
||||
|
69
mta-mono/src/CElement.cpp
Normal file
69
mta-mono/src/CElement.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "CElement.h"
|
||||
|
||||
const map<eElementType, pair<string, string>> CElement::_eElementType =
|
||||
{
|
||||
{ eElementType::Dummy, { "dummy", "Element" } },
|
||||
{ eElementType::Player, { "player", "Player" } },
|
||||
{ eElementType::Vehicle, { "vehicle", "Vehile" } },
|
||||
{ eElementType::Object, { "object", "Object" } },
|
||||
{ eElementType::Marker, { "marker", "Marker" } },
|
||||
{ eElementType::Blip, { "blip", "Blip" } },
|
||||
{ eElementType::Pickup, { "pickup", "Pickup" } },
|
||||
{ eElementType::RadarArea, { "radararea", "RadarArea" } },
|
||||
{ eElementType::Console, { "console", "Console" } },
|
||||
{ eElementType::Team, { "team", "Team" } },
|
||||
{ eElementType::Ped, { "ped", "Ped" } },
|
||||
{ eElementType::ColShape, { "colshape", "ColShape" } },
|
||||
{ eElementType::ScriptFile, { "scriptfile", "ScriptFile" } },
|
||||
{ eElementType::Water, { "water", "Water" } },
|
||||
{ eElementType::Weapon, { "weapon", "Weapon" } },
|
||||
{ eElementType::DatabaseConnection, { "db-connection", "DbConnection" } },
|
||||
{ eElementType::Resource, { "resource", "Resource" } },
|
||||
{ eElementType::Root, { "root", "Element" } },
|
||||
{ eElementType::Unknown, { "unknown", "Element" } },
|
||||
};
|
||||
|
||||
CElement::CElement( CElementManager* pManager, MonoObject* pObject, PVOID pUserdata, const CResource* pParent )
|
||||
{
|
||||
this->m_pElementManager = pManager;
|
||||
this->m_pMonoObject = pObject;
|
||||
this->m_pLuaUserdata = pUserdata;
|
||||
this->m_pParent = pParent;
|
||||
|
||||
this->m_iType = eElementType::Unknown;
|
||||
|
||||
this->m_pElementManager->AddToList( this );
|
||||
}
|
||||
|
||||
CElement::~CElement( void )
|
||||
{
|
||||
this->m_pElementManager->RemoveFromList( this );
|
||||
|
||||
this->m_pMonoObject = nullptr;
|
||||
this->m_pLuaUserdata = nullptr;
|
||||
this->m_pParent = nullptr;
|
||||
this->m_pElementManager = nullptr;
|
||||
}
|
||||
|
||||
void CElement::SetTypeName( const string& strTypeName )
|
||||
{
|
||||
this->m_iType = CElement::GetTypeByName( strTypeName );
|
||||
}
|
||||
|
||||
const string CElement::GetTypeName( void )
|
||||
{
|
||||
return CElement::GetTypeName( this->m_iType );
|
||||
}
|
126
mta-mono/src/CElement.h
Normal file
126
mta-mono/src/CElement.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
class CElement;
|
||||
|
||||
#ifndef __CELEMENT_H
|
||||
#define __CELEMENT_H
|
||||
|
||||
#include "CResource.h"
|
||||
#include "CElementManager.h"
|
||||
|
||||
enum class eElementType
|
||||
{
|
||||
Dummy,
|
||||
Player,
|
||||
Vehicle,
|
||||
Object,
|
||||
Marker,
|
||||
Blip,
|
||||
Pickup,
|
||||
RadarArea,
|
||||
SpawnpointDeprecated,
|
||||
RemoteclientDeprecated,
|
||||
Console,
|
||||
PathNodeUnused,
|
||||
WorldMeshUnused,
|
||||
Team,
|
||||
Ped,
|
||||
ColShape,
|
||||
ScriptFile,
|
||||
Water,
|
||||
Weapon,
|
||||
DatabaseConnection,
|
||||
Resource,
|
||||
Root,
|
||||
Unknown,
|
||||
};
|
||||
|
||||
class CElement
|
||||
{
|
||||
public:
|
||||
static const map<eElementType, pair<string, string>> _eElementType;
|
||||
|
||||
inline static const string GetTypeName( eElementType iType )
|
||||
{
|
||||
for( const auto& iter : _eElementType )
|
||||
{
|
||||
if( iter.first == iType )
|
||||
{
|
||||
return iter.second.first;
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
inline static const eElementType GetTypeByName( const string& strName )
|
||||
{
|
||||
for( const auto& iter : _eElementType )
|
||||
{
|
||||
if( iter.second.first == strName )
|
||||
{
|
||||
return iter.first;
|
||||
}
|
||||
}
|
||||
|
||||
return eElementType::Unknown;
|
||||
}
|
||||
|
||||
inline static const char* GetTypeClassName( eElementType iType )
|
||||
{
|
||||
for( const auto& iter : _eElementType )
|
||||
{
|
||||
if( iter.first == iType )
|
||||
{
|
||||
return iter.second.second.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline static const char* GetTypeClassName( const string& strType )
|
||||
{
|
||||
for( const auto& iter : _eElementType )
|
||||
{
|
||||
if( iter.second.first == strType )
|
||||
{
|
||||
return iter.second.second.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
PVOID m_pLuaUserdata;
|
||||
MonoObject* m_pMonoObject;
|
||||
const CResource* m_pParent;
|
||||
CElementManager* m_pElementManager;
|
||||
|
||||
eElementType m_iType;
|
||||
|
||||
public:
|
||||
CElement ( CElementManager* pManager, MonoObject* pObject, PVOID pUserdata, const CResource* pParent = nullptr );
|
||||
virtual ~CElement ( void );
|
||||
inline eElementType GetType ( void ) const { return this->m_iType; }
|
||||
inline void SetType ( eElementType iType ) { this->m_iType = iType; }
|
||||
|
||||
void SetTypeName ( const string& strTypeName );
|
||||
const string GetTypeName ( void );
|
||||
|
||||
inline MonoObject* ToMonoObject ( void ) const { return this->m_pMonoObject; }
|
||||
inline PVOID ToLuaUserData ( void ) const { return this->m_pLuaUserdata; }
|
||||
};
|
||||
|
||||
#endif
|
126
mta-mono/src/CElementManager.cpp
Normal file
126
mta-mono/src/CElementManager.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "CElementManager.h"
|
||||
|
||||
CElementManager::CElementManager( CResource* pResource )
|
||||
{
|
||||
this->m_pResource = pResource;
|
||||
}
|
||||
|
||||
CElementManager::~CElementManager( void )
|
||||
{
|
||||
this->DeleteAll();
|
||||
|
||||
this->m_pResource = nullptr;
|
||||
}
|
||||
|
||||
void CElementManager::DeleteAll( void )
|
||||
{
|
||||
auto clonedList = this->m_List;
|
||||
|
||||
this->m_List.clear();
|
||||
|
||||
for( const auto iter: clonedList )
|
||||
{
|
||||
delete iter;
|
||||
}
|
||||
}
|
||||
|
||||
CElement* CElementManager::Create( MonoObject* pObject, PVOID pUserData )
|
||||
{
|
||||
if( pObject == nullptr )
|
||||
{
|
||||
string _tmp;
|
||||
string strTypeName;
|
||||
|
||||
if( CLuaFunctionDefinitions::IsElement( this->m_pResource->GetLua(), pUserData ) )
|
||||
{
|
||||
strTypeName = CLuaFunctionDefinitions::GetElementType( this->m_pResource->GetLua(), pUserData );
|
||||
}
|
||||
else if( CLuaFunctionDefinitions::GetResourceName( this->m_pResource->GetLua(), pUserData, _tmp ) )
|
||||
{
|
||||
strTypeName = "resource";
|
||||
}
|
||||
|
||||
const char* szClassName = CElement::GetTypeClassName( CElement::GetTypeByName( strTypeName ) );
|
||||
|
||||
CMonoClass* pClass = this->m_pResource->GetDomain()->GetMTALib()->GetClass( szClassName );
|
||||
|
||||
if( pClass )
|
||||
{
|
||||
pObject = pClass->New();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->m_pResource->ErrorPrintf( "[mono] Could not find the 'MultiTheftAuto.%s' class\n", szClassName );
|
||||
}
|
||||
}
|
||||
|
||||
if( pObject )
|
||||
{
|
||||
return new CElement( this, pObject, pUserData, this->m_pResource );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CElement* CElementManager::FindOrCreate( PVOID pUserData )
|
||||
{
|
||||
CElement* pElement;
|
||||
|
||||
pElement = this->GetFromList( pUserData );
|
||||
|
||||
if( !pElement )
|
||||
{
|
||||
pElement = this->Create( nullptr, pUserData );
|
||||
}
|
||||
|
||||
return pElement;
|
||||
}
|
||||
|
||||
void CElementManager::AddToList( CElement* pElement )
|
||||
{
|
||||
this->m_List.push_back( pElement );
|
||||
}
|
||||
|
||||
void CElementManager::RemoveFromList( CElement* pElement )
|
||||
{
|
||||
this->m_List.remove( pElement );
|
||||
}
|
||||
|
||||
CElement* CElementManager::GetFromList( PVOID pUserdata )
|
||||
{
|
||||
for( const auto& pElement : this->m_List )
|
||||
{
|
||||
if( pElement->ToLuaUserData() == pUserdata )
|
||||
{
|
||||
return pElement;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CElement* CElementManager::GetFromList( MonoObject* pMonoObject )
|
||||
{
|
||||
for( const auto& pElement : this->m_List )
|
||||
{
|
||||
if( pElement->ToMonoObject() == pMonoObject )
|
||||
{
|
||||
return pElement;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
46
mta-mono/src/CElementManager.h
Normal file
46
mta-mono/src/CElementManager.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
class CElementManager;
|
||||
|
||||
#ifndef __CELEMENT_MANAGER_H
|
||||
#define __CELEMENT_MANAGER_H
|
||||
|
||||
#include "CElement.h"
|
||||
#include "CResource.h"
|
||||
|
||||
class CElementManager
|
||||
{
|
||||
friend CElement;
|
||||
|
||||
private:
|
||||
CResource* m_pResource;
|
||||
list< CElement* > m_List;
|
||||
|
||||
public:
|
||||
CElementManager ( CResource* pResource );
|
||||
~CElementManager ( void );
|
||||
|
||||
void DeleteAll ( void );
|
||||
|
||||
CElement* Create ( MonoObject* pObject, PVOID pUserdata );
|
||||
CElement* FindOrCreate ( PVOID pUserdata );
|
||||
|
||||
CElement* GetFromList ( PVOID pUserdata );
|
||||
CElement* GetFromList ( MonoObject* pMonoObject );
|
||||
|
||||
private:
|
||||
void AddToList ( CElement* pElement );
|
||||
void RemoveFromList ( CElement* pElement );
|
||||
};
|
||||
|
||||
#endif
|
@ -13,7 +13,7 @@
|
||||
#include "StdInc.h"
|
||||
#include "CEvent.h"
|
||||
|
||||
CEvent::CEvent( CEventManager* pEventManager, string strName, DWORD pElement, MonoObject* pMonoDelegate, bool bPropagated, string strPriority )
|
||||
CEvent::CEvent( CEventManager* pEventManager, string strName, CElement* pElement, MonoObject* pMonoDelegate, bool bPropagated, string strPriority )
|
||||
{
|
||||
this->m_pEventManager = pEventManager;
|
||||
|
||||
@ -27,19 +27,20 @@ CEvent::CEvent( CEventManager* pEventManager, string strName, DWORD pElement, Mo
|
||||
CEvent::~CEvent( void )
|
||||
{
|
||||
this->m_pMonoDelegate = nullptr;
|
||||
this->m_pElement = nullptr;
|
||||
|
||||
this->m_pEventManager = nullptr;
|
||||
}
|
||||
|
||||
bool CEvent::Call( DWORD pThis, void** params )
|
||||
bool CEvent::Call( CElement* pThis, void** params )
|
||||
{
|
||||
CResource* pResource = this->m_pEventManager->GetResource();
|
||||
|
||||
assert( pResource );
|
||||
ASSERT( pResource );
|
||||
|
||||
CMonoMTALib* pMTALib = pResource->GetDomain()->GetMTALib();
|
||||
|
||||
assert( pMTALib );
|
||||
ASSERT( pMTALib );
|
||||
|
||||
MonoObject* pException = nullptr;
|
||||
|
||||
|
@ -18,6 +18,7 @@ class CEvent;
|
||||
#include "extra/CLuaArgument.h"
|
||||
#include "extra/CLuaArguments.h"
|
||||
|
||||
#include "CElement.h"
|
||||
#include "CResource.h"
|
||||
#include "CEventManager.h"
|
||||
|
||||
@ -25,7 +26,7 @@ class CEvent
|
||||
{
|
||||
private:
|
||||
string m_strName;
|
||||
DWORD m_pElement;
|
||||
CElement* m_pElement;
|
||||
MonoObject* m_pMonoDelegate;
|
||||
bool m_bPropagated;
|
||||
string m_strPriority;
|
||||
@ -34,13 +35,13 @@ private:
|
||||
CEventManager* m_pEventManager;
|
||||
|
||||
public:
|
||||
CEvent ( CEventManager* pEventManager, string strName, DWORD pElement, MonoObject* pMonoDelegate, bool bPropagated, string strPriority );
|
||||
CEvent ( CEventManager* pEventManager, string strName, CElement* pElement, MonoObject* pMonoDelegate, bool bPropagated, string strPriority );
|
||||
~CEvent ( void );
|
||||
|
||||
bool Call ( DWORD pThis, void** params );
|
||||
bool Call ( CElement* pThis, void** params );
|
||||
|
||||
string GetName ( void ) { return this->m_strName; }
|
||||
DWORD GetElement ( void ) { return this->m_pElement; }
|
||||
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; }
|
||||
|
@ -25,21 +25,21 @@ CEventManager::~CEventManager( void )
|
||||
this->m_pResource = nullptr;
|
||||
}
|
||||
|
||||
bool CEventManager::Add( string strName, DWORD pUserData, MonoObject* pMonoDelegate, bool bPropagated, string strPriority )
|
||||
bool CEventManager::Add( string strName, CElement* pElement, MonoObject* pMonoDelegate, bool bPropagated, string strPriority )
|
||||
{
|
||||
if( !pUserData )
|
||||
if( !pElement )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CEvent* pEvent = new CEvent( this, strName, pUserData, pMonoDelegate, bPropagated, strPriority );
|
||||
CEvent* pEvent = new CEvent( this, strName, pElement, pMonoDelegate, bPropagated, strPriority );
|
||||
|
||||
this->m_Events.insert( pair< string, CEvent* >( pEvent->GetName(), pEvent ) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEventManager::Delete( string strName, DWORD pUserData, MonoObject* pMonoDelegate )
|
||||
bool CEventManager::Delete( string strName, CElement* pElement, MonoObject* pMonoDelegate )
|
||||
{
|
||||
bool bFind = false;
|
||||
|
||||
@ -74,70 +74,65 @@ void CEventManager::DeleteAll( void )
|
||||
}
|
||||
}
|
||||
|
||||
bool CEventManager::Call( string strName, void* pThis, list< CLuaArgument* > Arguments )
|
||||
bool CEventManager::Call( const string& strName, CElement* pThis, list< CLuaArgument* > Arguments )
|
||||
{
|
||||
CMonoMTALib* pMTALib = this->GetResource()->GetDomain()->GetMTALib();
|
||||
CElementManager* pElementManager = this->m_pResource->GetElementManager();
|
||||
|
||||
MonoObject* pThisObj = pMTALib->RegisterElement( pThis );
|
||||
CMonoMTALib* pMTALib = this->m_pResource->GetDomain()->GetMTALib();
|
||||
|
||||
if( !pThisObj )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD pSource = 0;
|
||||
CElement* pSource = nullptr;
|
||||
|
||||
auto *iter = *Arguments.begin();
|
||||
|
||||
if( iter->GetType() == LUA_TLIGHTUSERDATA )
|
||||
{
|
||||
pSource = (DWORD)iter->GetLightUserData();
|
||||
pSource = pElementManager->FindOrCreate( iter->GetLightUserData() );
|
||||
}
|
||||
|
||||
void** params = new void*[ Arguments.size() ];
|
||||
CMonoArguments pArguments;
|
||||
|
||||
this->ReadArgumens( Arguments, params );
|
||||
this->ReadArgumens( Arguments, pArguments );
|
||||
|
||||
for( auto iter : this->m_Events )
|
||||
for( const auto& iter : this->m_Events )
|
||||
{
|
||||
CEvent* pEvent = iter.second;
|
||||
|
||||
DWORD pElement = pEvent->GetElement();
|
||||
CElement* pElement = pEvent->GetElement();
|
||||
|
||||
if( pEvent->GetName() == strName && ( pElement == (DWORD)pThis || ( pEvent->IsPropagated() && pElement == pSource ) ) )
|
||||
if( pEvent->GetName() == strName && ( pElement == pThis || ( pEvent->IsPropagated() && pElement == pSource ) ) )
|
||||
{
|
||||
pEvent->Call( (DWORD)pThis, params );
|
||||
pEvent->Call( pThis, *pArguments );
|
||||
}
|
||||
}
|
||||
|
||||
delete[] params;
|
||||
|
||||
CMonoClass* pClass = pMTALib->GetClass( "Element" );
|
||||
|
||||
assert( pClass );
|
||||
ASSERT( pClass );
|
||||
|
||||
strName[ 0 ] = toupper( strName[ 0 ] );
|
||||
string strEventName = strName;
|
||||
|
||||
CMonoEvent* pEvent = pClass->GetEvent( strName );
|
||||
strEventName[ 0 ] = toupper( strEventName[ 0 ] );
|
||||
|
||||
CMonoEvent* pEvent = pClass->GetEvent( strEventName );
|
||||
|
||||
if( pEvent )
|
||||
{
|
||||
return pEvent->Call( pThisObj, Arguments );
|
||||
return pEvent->Call( pThis->ToMonoObject(), Arguments );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEventManager::ReadArgumens( list< CLuaArgument* > Arguments, void** params )
|
||||
void CEventManager::ReadArgumens( list< CLuaArgument* > Arguments, CMonoArguments& pArguments )
|
||||
{
|
||||
CMonoDomain* pDomain = this->GetResource()->GetDomain();
|
||||
CElementManager* pElementManager = this->m_pResource->GetElementManager();
|
||||
|
||||
CMonoDomain* pDomain = this->m_pResource->GetDomain();
|
||||
|
||||
CMonoMTALib* pMTALib = pDomain->GetMTALib();
|
||||
CMonoCorlib* pCorlib = pDomain->GetCorlib();
|
||||
|
||||
uint argc = 0;
|
||||
|
||||
for( auto iter : Arguments )
|
||||
for( const auto& iter : Arguments )
|
||||
{
|
||||
int iLuaType = iter->GetType();
|
||||
|
||||
@ -147,17 +142,15 @@ void CEventManager::ReadArgumens( list< CLuaArgument* > Arguments, void** params
|
||||
{
|
||||
bool bValue = iter->GetBoolean();
|
||||
|
||||
params[ argc++ ] = &bValue;
|
||||
pArguments.Push( bValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case LUA_TNUMBER:
|
||||
{
|
||||
double value = iter->GetNumber< double >();
|
||||
double dValue = iter->GetNumber< double >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "double" ]->Box( &value );
|
||||
|
||||
params[ argc++ ] = pObj;
|
||||
pArguments.Push( dValue );
|
||||
|
||||
break;
|
||||
}
|
||||
@ -167,24 +160,17 @@ void CEventManager::ReadArgumens( list< CLuaArgument* > Arguments, void** params
|
||||
|
||||
MonoString* pString = pDomain->NewString( szValue );
|
||||
|
||||
params[ argc++ ] = pString;
|
||||
pArguments.Push( pString );
|
||||
|
||||
break;
|
||||
}
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
{
|
||||
void* pUserData = iter->GetLightUserData();
|
||||
CElement* pElement = pElementManager->FindOrCreate( iter->GetLightUserData() );
|
||||
|
||||
MonoObject* pValue = pMTALib->RegisterElement( pUserData );
|
||||
MonoObject* pValue = pElement->ToMonoObject();
|
||||
|
||||
if( pValue )
|
||||
{
|
||||
params[ argc++ ] = pValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
params[ argc++ ] = pUserData;
|
||||
}
|
||||
pArguments.Push( pValue );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -15,9 +15,11 @@ class CEventManager;
|
||||
#ifndef __CEVENTMANAGER_H
|
||||
#define __CEVENTMANAGER_H
|
||||
|
||||
#include "CElement.h"
|
||||
#include "CResource.h"
|
||||
#include "CMonoDomain.h"
|
||||
#include "CEvent.h"
|
||||
#include "CMonoArguments.h"
|
||||
|
||||
#include "extra/CLuaArgument.h"
|
||||
#include "extra/CLuaArguments.h"
|
||||
@ -32,13 +34,13 @@ public:
|
||||
CEventManager ( CResource* pResource );
|
||||
~CEventManager ( void );
|
||||
|
||||
bool Add ( string strName, DWORD pUserData, MonoObject* pMonoDelegate, bool bPropagated, string strPriority );
|
||||
bool Delete ( string strName, DWORD pUserData, MonoObject* pMonoDelegate = nullptr );
|
||||
bool Add ( string strName, CElement* pElement, MonoObject* pMonoDelegate, bool bPropagated, string strPriority );
|
||||
bool Delete ( string strName, CElement* pElement, MonoObject* pMonoDelegate = nullptr );
|
||||
void DeleteAll ( void );
|
||||
|
||||
bool Call ( string strName, void* pThis, list< CLuaArgument* > Arguments );
|
||||
bool Call ( const string& strName, CElement* pThis, list< CLuaArgument* > Arguments );
|
||||
|
||||
void ReadArgumens ( list< CLuaArgument* > Arguments, void** params );
|
||||
void ReadArgumens ( list< CLuaArgument* > Arguments, CMonoArguments& pArguments );
|
||||
|
||||
CResource* GetResource( void ) { return this->m_pResource; }
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ int CFunctions::monoInit( lua_State *pLuaVM )
|
||||
{
|
||||
if( pLuaVM )
|
||||
{
|
||||
CResource *pResource = g_pResourceManager->GetFromList( pLuaVM );
|
||||
CResource *pResource = g_pModule->GetResourceManager()->GetFromList( pLuaVM );
|
||||
|
||||
if( pResource == nullptr )
|
||||
{
|
||||
@ -28,7 +28,7 @@ int CFunctions::monoInit( lua_State *pLuaVM )
|
||||
|
||||
if( !strName.empty() )
|
||||
{
|
||||
pResource = g_pResourceManager->Create( pLuaVM, strName );
|
||||
pResource = g_pModule->GetResourceManager()->Create( pLuaVM, strName );
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ int CFunctions::monoEventHandler( lua_State *pLuaVM )
|
||||
{
|
||||
if( pLuaVM )
|
||||
{
|
||||
CResource *pResource = g_pResourceManager->GetFromList( pLuaVM );
|
||||
CResource *pResource = g_pModule->GetResourceManager()->GetFromList( pLuaVM );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
@ -119,7 +119,7 @@ int CFunctions::monoCommandHandler( lua_State* pLuaVM )
|
||||
{
|
||||
if( pLuaVM )
|
||||
{
|
||||
CResource *pResource = g_pResourceManager->GetFromList( pLuaVM );
|
||||
CResource *pResource = g_pModule->GetResourceManager()->GetFromList( pLuaVM );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
|
@ -18,11 +18,11 @@ class CFunctions;
|
||||
#ifndef __CFUNCTIONS_H
|
||||
#define __CFUNCTIONS_H
|
||||
|
||||
#include "CModule.h"
|
||||
#include "CResource.h"
|
||||
#include "CResourceManager.h"
|
||||
|
||||
extern CResourceManager *g_pResourceManager;
|
||||
extern ILuaModuleManager10 *g_pModuleManager;
|
||||
extern CModule* g_pModule;
|
||||
|
||||
class CFunctions
|
||||
{
|
||||
|
100
mta-mono/src/CModule.cpp
Normal file
100
mta-mono/src/CModule.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "StdInc.h"
|
||||
#include "CModule.h"
|
||||
|
||||
CModule::CModule( ILuaModuleManager10* pModule )
|
||||
{
|
||||
this->m_pModuleManager = pModule;
|
||||
|
||||
this->m_pMonoInterface = new CMonoInterface( this );
|
||||
this->m_pResourceManager = new CResourceManager( this, this->m_pMonoInterface );
|
||||
}
|
||||
|
||||
CModule::~CModule( void )
|
||||
{
|
||||
SAFE_DELETE( this->m_pResourceManager );
|
||||
SAFE_DELETE( this->m_pMonoInterface );
|
||||
|
||||
this->m_pModuleManager = nullptr;
|
||||
}
|
||||
|
||||
void CModule::DoPulse( void )
|
||||
{
|
||||
this->m_pResourceManager->DoPulse();
|
||||
}
|
||||
|
||||
void CModule::Shutdown( void )
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void CModule::ResourceStopped( lua_State* pLuaVM )
|
||||
{
|
||||
this->m_pResourceManager->ResourceStopped( pLuaVM );
|
||||
}
|
||||
|
||||
void CModule::ResourceStopping( lua_State* pLuaVM )
|
||||
{
|
||||
this->m_pResourceManager->ResourceStopping( pLuaVM );
|
||||
}
|
||||
|
||||
bool CModule::RegisterFunction( lua_State* luaVM, const char *szFunctionName, lua_CFunction Func )
|
||||
{
|
||||
return this->m_pModuleManager->RegisterFunction( luaVM, szFunctionName, Func );
|
||||
}
|
||||
|
||||
bool CModule::GetResourceName( lua_State* luaVM, string &strName )
|
||||
{
|
||||
return this->m_pModuleManager->GetResourceName( luaVM, strName );
|
||||
}
|
||||
|
||||
CChecksum CModule::GetResourceMetaChecksum( lua_State* luaVM )
|
||||
{
|
||||
return this->m_pModuleManager->GetResourceMetaChecksum( luaVM );
|
||||
}
|
||||
|
||||
CChecksum CModule::GetResourceFileChecksum( lua_State* luaVM, const char* szFile )
|
||||
{
|
||||
return this->m_pModuleManager->GetResourceFileChecksum( luaVM, szFile );
|
||||
}
|
||||
|
||||
unsigned long CModule::GetVersion( void )
|
||||
{
|
||||
return this->m_pModuleManager->GetVersion();
|
||||
}
|
||||
|
||||
const char* CModule::GetVersionString( void )
|
||||
{
|
||||
return this->m_pModuleManager->GetVersionString();
|
||||
}
|
||||
|
||||
const char* CModule::GetVersionName( void )
|
||||
{
|
||||
return this->m_pModuleManager->GetVersionName();
|
||||
}
|
||||
|
||||
unsigned long CModule::GetNetcodeVersion( void )
|
||||
{
|
||||
return this->m_pModuleManager->GetNetcodeVersion();
|
||||
}
|
||||
|
||||
const char* CModule::GetOperatingSystemName( void )
|
||||
{
|
||||
return this->m_pModuleManager->GetOperatingSystemName();
|
||||
}
|
||||
|
||||
lua_State* CModule::GetResourceFromName( const char* szResourceName )
|
||||
{
|
||||
return this->m_pModuleManager->GetResourceFromName( szResourceName );
|
||||
}
|
76
mta-mono/src/CModule.h
Normal file
76
mta-mono/src/CModule.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
class CModule;
|
||||
|
||||
#ifndef __CMODULE_H
|
||||
#define __CMODULE_H
|
||||
|
||||
#include "CResourceManager.h"
|
||||
#include "CMonoInterface.h"
|
||||
|
||||
#include "include/ILuaModuleManager.h"
|
||||
|
||||
class CModule
|
||||
{
|
||||
private:
|
||||
ILuaModuleManager10* m_pModuleManager;
|
||||
CResourceManager* m_pResourceManager;
|
||||
CMonoInterface* m_pMonoInterface;
|
||||
|
||||
public:
|
||||
CModule ( ILuaModuleManager10* pModuleManager );
|
||||
~CModule ( void );
|
||||
|
||||
void DoPulse ( void );
|
||||
void Shutdown ( void );
|
||||
|
||||
void ResourceStopping ( lua_State* pLuaVM );
|
||||
void ResourceStopped ( lua_State* pLuaVM );
|
||||
|
||||
inline CMonoInterface* GetMono ( void ) const { return this->m_pMonoInterface; }
|
||||
inline CResourceManager* GetResourceManager ( void ) const { return this->m_pResourceManager; }
|
||||
inline ILuaModuleManager10* GetModuleManager ( void ) const { return this->m_pModuleManager; }
|
||||
|
||||
template< typename ... Type >
|
||||
void Printf ( const char* szFormat, Type ... args ) const
|
||||
{
|
||||
this->m_pModuleManager->Printf( szFormat, args ... );
|
||||
}
|
||||
|
||||
template< typename ... Type >
|
||||
void DebugPrintf ( lua_State* luaVM, const char* szFormat, Type ... args ) const
|
||||
{
|
||||
this->m_pModuleManager->DebugPrintf( luaVM, szFormat, args ... );
|
||||
}
|
||||
|
||||
template< typename ... Type >
|
||||
void ErrorPrintf ( const char* szFormat, Type ... args ) const
|
||||
{
|
||||
this->m_pModuleManager->ErrorPrintf( szFormat, args ... );
|
||||
}
|
||||
|
||||
bool RegisterFunction ( lua_State* luaVM, const char *szFunctionName, lua_CFunction Func );
|
||||
bool GetResourceName ( lua_State* luaVM, string &strName );
|
||||
CChecksum GetResourceMetaChecksum ( lua_State* luaVM );
|
||||
CChecksum GetResourceFileChecksum ( lua_State* luaVM, const char* szFile );
|
||||
|
||||
unsigned long GetVersion ( void );
|
||||
const char* GetVersionString ( void );
|
||||
const char* GetVersionName ( void );
|
||||
unsigned long GetNetcodeVersion ( void );
|
||||
const char* GetOperatingSystemName ( void );
|
||||
|
||||
lua_State* GetResourceFromName ( const char* szResourceName );
|
||||
};
|
||||
|
||||
#endif
|
@ -18,6 +18,7 @@ CMonoDomain::CMonoDomain( CMonoInterface* pMono, MonoDomain* pDomain, CResource*
|
||||
this->m_pMono = pMono;
|
||||
this->m_pDomain = pDomain;
|
||||
this->m_pResource = pResource;
|
||||
this->m_pModule = pResource->GetModule();
|
||||
|
||||
this->m_strName = szName;
|
||||
|
||||
@ -57,13 +58,14 @@ CMonoDomain::~CMonoDomain( void )
|
||||
this->m_pMonoAssembly = nullptr;
|
||||
this->m_pMonoImage = nullptr;
|
||||
this->m_pMonoClass = nullptr;
|
||||
this->m_pModule = nullptr;
|
||||
}
|
||||
|
||||
void CMonoDomain::HandleException( MonoObject* pException )
|
||||
{
|
||||
if( pException )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "%s\n", mono_string_to_utf8( mono_object_to_string( pException, nullptr ) ) );
|
||||
this->m_pResource->ErrorPrintf( "%s\n", mono_string_to_utf8( mono_object_to_string( pException, nullptr ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +78,7 @@ CMonoClass* CMonoDomain::FindOrAdd( MonoClass* klass )
|
||||
|
||||
if( this->m_pDomain )
|
||||
{
|
||||
for( auto iter : this->m_ClassPool )
|
||||
for( const auto& iter : this->m_ClassPool )
|
||||
{
|
||||
if( iter->GetMonoPtr() == klass )
|
||||
{
|
||||
@ -105,7 +107,7 @@ bool CMonoDomain::Init( void )
|
||||
|
||||
if( !this->m_pMonoAssembly )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "failed to open assembly '%s.dll'\n", this->m_strName.c_str() );
|
||||
this->GetResource()->ErrorPrintf( "failed to open assembly '%s.dll'\n", this->m_strName.c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -114,7 +116,7 @@ bool CMonoDomain::Init( void )
|
||||
|
||||
if( !this->m_pMonoImage )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "failed to get image '%s.dll'\n", this->m_strName.c_str() );
|
||||
this->GetResource()->ErrorPrintf( "failed to get image '%s.dll'\n", this->m_strName.c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -123,7 +125,7 @@ bool CMonoDomain::Init( void )
|
||||
|
||||
if( !this->m_pMonoClass )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "class '%s' not found in '%s.dll'\n", sClass.c_str(), this->m_strName.c_str() );
|
||||
this->GetResource()->ErrorPrintf( "class '%s' not found in '%s.dll'\n", sClass.c_str(), this->m_strName.c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -140,7 +142,7 @@ bool CMonoDomain::Start( void )
|
||||
|
||||
if( !pMethod )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Assembly '%s.dll' doesn't have an entry point.\n", this->m_strName.c_str() );
|
||||
this->GetResource()->ErrorPrintf( "Assembly '%s.dll' doesn't have an entry point.\n", this->m_strName.c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -157,7 +159,7 @@ bool CMonoDomain::Start( void )
|
||||
|
||||
MonoObject* pException = nullptr;
|
||||
|
||||
pMethod->Invoke( nullptr, params, pException );
|
||||
pMethod->Invoke( nullptr, params, &pException );
|
||||
|
||||
if( pException )
|
||||
{
|
||||
@ -192,12 +194,36 @@ void CMonoDomain::SetConfig( const char *szBaseDir, const char *szConfigFileName
|
||||
mono_domain_set_config( this->m_pDomain, szBaseDir, szConfigFileName );
|
||||
}
|
||||
|
||||
MonoString* CMonoDomain::NewString( const char* szText )
|
||||
MonoString* CMonoDomain::NewString( const char* szText ) const
|
||||
{
|
||||
return mono_string_new( this->m_pDomain, szText );
|
||||
}
|
||||
|
||||
MonoString* CMonoDomain::NewString( string strText )
|
||||
MonoString* CMonoDomain::NewString( const string& strText ) const
|
||||
{
|
||||
return mono_string_new( this->m_pDomain, strText.c_str() );
|
||||
}
|
||||
|
||||
MonoArray* CMonoDomain::NewElementArray( MonoClass* pMonoClass, CLuaArgumentsVector pLuaArguments )
|
||||
{
|
||||
MonoArray* pArray = mono_array_new( this->m_pDomain, pMonoClass, pLuaArguments.size() );
|
||||
|
||||
if( pLuaArguments.size() > 0 )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for( const auto& pArgument : pLuaArguments )
|
||||
{
|
||||
PVOID pUserData = pArgument.GetLightUserData();
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
CElement* pElement = this->m_pResource->GetElementManager()->FindOrCreate( pUserData );
|
||||
|
||||
mono_array_set( pArray, MonoObject*, i++, pElement->ToMonoObject() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pArray;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ private:
|
||||
MonoDomain* m_pDomain;
|
||||
CResource* m_pResource;
|
||||
CMonoInterface* m_pMono;
|
||||
CModule* m_pModule;
|
||||
|
||||
MonoAssembly* m_pMonoAssembly;
|
||||
MonoImage* m_pMonoImage;
|
||||
@ -57,31 +58,33 @@ public:
|
||||
MonoObject* CreateObject ( MonoClass* klass );
|
||||
void SetConfig ( const char* szBaseDir, const char* szConfigFileName );
|
||||
|
||||
MonoString* NewString ( const char* szText );
|
||||
MonoString* NewString ( string strText );
|
||||
MonoString* NewString ( const char* szText ) const;
|
||||
MonoString* NewString ( const string& strText ) const;
|
||||
|
||||
MonoArray* NewElementArray ( MonoClass* pMonoClass, CLuaArgumentsVector pLuaArguments );
|
||||
|
||||
template< class T, int iLuaType >
|
||||
MonoArray* NewArray ( MonoClass* pMonoClass, CLuaArgumentsVector* pLuaArguments = nullptr )
|
||||
MonoArray* NewArray ( MonoClass* pMonoClass, CLuaArgumentsVector pLuaArguments )
|
||||
{
|
||||
MonoArray* pArray = mono_array_new( this->m_pDomain, pMonoClass, pLuaArguments ? pLuaArguments->size() : 0 );
|
||||
MonoArray* pArray = mono_array_new( this->m_pDomain, pMonoClass, pLuaArguments.size() );
|
||||
|
||||
if( pLuaArguments )
|
||||
if( pLuaArguments.size() > 0 )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for( const auto& pArgument : *pLuaArguments )
|
||||
for( const auto& pArgument : pLuaArguments )
|
||||
{
|
||||
switch( iLuaType )
|
||||
{
|
||||
case LUA_TBOOLEAN:
|
||||
{
|
||||
mono_array_set( pArray, T, i++, (T)( pArgument.GetBoolean() ) );
|
||||
mono_array_set( pArray, T, i++, ( T )pArgument.GetBoolean() );
|
||||
|
||||
break;
|
||||
}
|
||||
case LUA_TNUMBER:
|
||||
{
|
||||
mono_array_set( pArray, T, i++, pArgument.GetNumber< T >() );
|
||||
mono_array_set( pArray, T, i++, ( T )pArgument.GetNumber() );
|
||||
|
||||
break;
|
||||
}
|
||||
@ -96,7 +99,7 @@ public:
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
case LUA_TUSERDATA:
|
||||
{
|
||||
mono_array_set( pArray, T, i++, reinterpret_cast< T >( pArgument.GetLightUserData() ) );
|
||||
mono_array_set( pArray, T, i++, ( T )pArgument.GetLightUserData() );
|
||||
|
||||
break;
|
||||
}
|
||||
@ -107,15 +110,15 @@ public:
|
||||
return pArray;
|
||||
}
|
||||
|
||||
MonoDomain* GetMonoPtr ( void ) { return this->m_pDomain; }
|
||||
inline MonoDomain* GetMonoPtr ( void ) const { return this->m_pDomain; }
|
||||
|
||||
CMonoInterface* GetMono ( void ) { return this->m_pMono; }
|
||||
CResource* GetResource ( void ) { return this->m_pResource; }
|
||||
inline CMonoInterface* GetMono ( void ) const { return this->m_pMono; }
|
||||
inline CResource* GetResource ( void ) const { return this->m_pResource; }
|
||||
|
||||
CMonoCorlib* GetCorlib ( void ) { return this->m_pCorlib; }
|
||||
CMonoMTALib* GetMTALib ( void ) { return this->m_pMTALib; }
|
||||
inline CMonoCorlib* GetCorlib ( void ) const { return this->m_pCorlib; }
|
||||
inline CMonoMTALib* GetMTALib ( void ) const { return this->m_pMTALib; }
|
||||
|
||||
string GetName ( void ) { return this->m_strName; }
|
||||
inline string GetName ( void ) const { return this->m_strName; }
|
||||
};
|
||||
|
||||
#endif
|
@ -17,6 +17,7 @@ CMonoEvent::CMonoEvent( CMonoClass* pClass, MonoEvent* pEvent )
|
||||
{
|
||||
this->m_pClass = pClass;
|
||||
this->m_pEvent = pEvent;
|
||||
this->m_pResource = pClass->GetDomain()->GetResource();
|
||||
this->m_pAddMethod = nullptr;
|
||||
this->m_pRemoveMethod = nullptr;
|
||||
this->m_pRaiseMethod = nullptr;
|
||||
@ -26,6 +27,7 @@ CMonoEvent::CMonoEvent( CMonoClass* pClass, MonoEvent* pEvent )
|
||||
|
||||
CMonoEvent::~CMonoEvent( void )
|
||||
{
|
||||
this->m_pResource = nullptr;
|
||||
this->m_pClass = nullptr;
|
||||
this->m_pEvent = nullptr;
|
||||
this->m_pAddMethod = nullptr;
|
||||
@ -42,53 +44,35 @@ bool CMonoEvent::Call( MonoObject* pThis, list< CLuaArgument* > argv )
|
||||
return false;
|
||||
}
|
||||
|
||||
void** pArguments = this->ParseArguments( argv );
|
||||
CMonoArguments pArguments;
|
||||
|
||||
if( !pArguments )
|
||||
if( !this->ParseArguments( pArguments, argv ) )
|
||||
{
|
||||
this->GetClass()->GetDomain()->GetResource()->ErrorPrintf( "Raise method for event '%s' not found\n", this->GetName().c_str() );
|
||||
this->m_pResource->ErrorPrintf( "Raise method for event '%s' not found\n", this->GetName().c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MonoObject* pException = nullptr;
|
||||
pMethod->Invoke( pThis, *pArguments, nullptr );
|
||||
|
||||
pMethod->Invoke( pThis, pArguments, pException );
|
||||
const auto& iter = *argv.begin();
|
||||
|
||||
if( !pException )
|
||||
if( iter->GetType() == LUA_TLIGHTUSERDATA )
|
||||
{
|
||||
auto iter = argv.begin();
|
||||
|
||||
if( (*iter)->GetType() == LUA_TLIGHTUSERDATA )
|
||||
{
|
||||
pMethod->Invoke( pArguments[ 0 ], pArguments, pException );
|
||||
}
|
||||
pMethod->Invoke( pArguments[ 0 ], *pArguments, nullptr );
|
||||
}
|
||||
|
||||
delete [] pArguments;
|
||||
|
||||
if( pException )
|
||||
{
|
||||
this->GetClass()->GetDomain()->GetResource()->ErrorPrintf( "%s\n", mono_string_to_utf8( mono_object_to_string( pException, nullptr ) ) );
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void** CMonoEvent::ParseArguments( list< CLuaArgument* > argv )
|
||||
bool CMonoEvent::ParseArguments( CMonoArguments& pArguments, list< CLuaArgument* > argv )
|
||||
{
|
||||
CMonoMTALib* pMTALib = this->GetClass()->GetDomain()->GetMTALib();
|
||||
CMonoCorlib* pCorlib = this->GetClass()->GetDomain()->GetCorlib();
|
||||
CMonoMTALib* pMTALib = this->m_pClass->GetDomain()->GetMTALib();
|
||||
CMonoCorlib* pCorlib = this->m_pClass->GetDomain()->GetCorlib();
|
||||
|
||||
PVOID* pArguments = new PVOID[ argv.size() ];
|
||||
const auto& pMethods = this->m_pClass->GetMethods( "raise_" + this->GetName() );
|
||||
|
||||
uint argc = 0;
|
||||
|
||||
auto pMethods = this->m_pClass->GetMethods( "raise_" + this->GetName() );
|
||||
|
||||
for( auto pMethod : pMethods )
|
||||
for( const auto& pMethod : pMethods )
|
||||
{
|
||||
vector< SMonoType > pArgList = pMethod->GetArguments();
|
||||
|
||||
@ -100,11 +84,11 @@ void** CMonoEvent::ParseArguments( list< CLuaArgument* > argv )
|
||||
auto iter = argv.begin();
|
||||
auto pType = pArgList.begin();
|
||||
|
||||
for( ; ; iter++ )
|
||||
for( ; ; iter++, pType++ )
|
||||
{
|
||||
if( iter == argv.end() || pType == pArgList.end() )
|
||||
{
|
||||
return pArguments;
|
||||
return true;
|
||||
}
|
||||
|
||||
int iLuaType = (*iter)->GetType();
|
||||
@ -113,189 +97,188 @@ void** CMonoEvent::ParseArguments( list< CLuaArgument* > argv )
|
||||
{
|
||||
case MONO_TYPE_BOOLEAN: // System.Boolean
|
||||
{
|
||||
bool bValue = false;
|
||||
|
||||
if( iLuaType == LUA_TBOOLEAN )
|
||||
{
|
||||
bool bValue = (*iter)->GetBoolean();
|
||||
|
||||
pArguments[ argc++ ] = &bValue;
|
||||
bValue = (*iter)->GetBoolean();
|
||||
}
|
||||
|
||||
pArguments.Push( bValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_CHAR: // System.Char
|
||||
{
|
||||
wchar_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
wchar_t iValue = (*iter)->GetNumber< wchar_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "char" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< wchar_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_I1: // System.SByte
|
||||
{
|
||||
int8_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
int8_t iValue = (*iter)->GetNumber< int8_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "sbyte" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< int8_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_U1: // System.Byte
|
||||
{
|
||||
uint8_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
uint8_t iValue = (*iter)->GetNumber< uint8_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "byte" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< uint8_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_I2: // System.Int16
|
||||
{
|
||||
int16_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
int16_t iValue = (*iter)->GetNumber< int16_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "int16" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< int16_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_U2: // System.UInt16
|
||||
{
|
||||
uint16_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
uint16_t iValue = (*iter)->GetNumber< uint16_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "uint16" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< uint16_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_I4: // System.Int32
|
||||
{
|
||||
int32_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
int32_t iValue = (*iter)->GetNumber< int32_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "int32" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< int32_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_U4: // System.UInt32
|
||||
{
|
||||
uint32_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
uint32_t iValue = (*iter)->GetNumber< uint32_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "uint32" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< uint32_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_I8: // System.Int64
|
||||
{
|
||||
int64_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
int64_t iValue = (*iter)->GetNumber< int64_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "int64" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< int64_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_U8: // System.UInt64
|
||||
{
|
||||
uint64_t iValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
uint64_t iValue = (*iter)->GetNumber< uint64_t >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "uint64" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
iValue = (*iter)->GetNumber< uint64_t >();
|
||||
}
|
||||
|
||||
pArguments.Push( iValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_R4: // System.Single
|
||||
{
|
||||
float fValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
float iValue = (*iter)->GetNumber< float >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "float" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
fValue = (*iter)->GetNumber< float >();
|
||||
}
|
||||
|
||||
pArguments.Push( fValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_R8: // System.Double
|
||||
{
|
||||
double dValue = 0;
|
||||
|
||||
if( iLuaType == LUA_TNUMBER )
|
||||
{
|
||||
double iValue = (*iter)->GetNumber< double >();
|
||||
|
||||
MonoObject* pObj = pCorlib->Class[ "double" ]->Box( &iValue );
|
||||
|
||||
pArguments[ argc++ ] = pObj;
|
||||
dValue = (*iter)->GetNumber< double >();
|
||||
}
|
||||
|
||||
pArguments.Push( dValue );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_STRING: // System.String
|
||||
{
|
||||
string strValue = "";
|
||||
|
||||
if( iLuaType == LUA_TSTRING )
|
||||
{
|
||||
const char* szValue = (*iter)->GetString();
|
||||
|
||||
MonoString* pString = this->GetClass()->GetDomain()->NewString( szValue );
|
||||
|
||||
pArguments[ argc++ ] = pString;
|
||||
strValue = (*iter)->GetString();
|
||||
}
|
||||
|
||||
MonoString* pString = this->m_pResource->GetDomain()->NewString( strValue );
|
||||
|
||||
pArguments.Push( pString );
|
||||
|
||||
break;
|
||||
}
|
||||
case MONO_TYPE_OBJECT: // System.Object
|
||||
case MONO_TYPE_CLASS:
|
||||
{
|
||||
MonoObject* pValue = nullptr;
|
||||
|
||||
if( iLuaType == LUA_TLIGHTUSERDATA )
|
||||
{
|
||||
void* pUserData = (*iter)->GetLightUserData();
|
||||
CElement* pElement = this->m_pResource->GetElementManager()->FindOrCreate( (*iter)->GetLightUserData() );
|
||||
|
||||
MonoObject* pValue = pMTALib->RegisterElement( pUserData );
|
||||
pValue = pElement->ToMonoObject();
|
||||
}
|
||||
|
||||
if( pValue )
|
||||
{
|
||||
pArguments[ argc++ ] = pValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
pArguments[ argc++ ] = pUserData;
|
||||
}
|
||||
}
|
||||
pArguments.Push( pValue );
|
||||
|
||||
break;
|
||||
}
|
||||
@ -303,7 +286,7 @@ void** CMonoEvent::ParseArguments( list< CLuaArgument* > argv )
|
||||
case MONO_TYPE_U:
|
||||
default:
|
||||
{
|
||||
this->GetClass()->GetDomain()->GetResource()->ErrorPrintf( "Unsupported type '%s (0x%i)' for '%s'\n", pType->strName.c_str(), pType->iType, this->GetName().c_str() );
|
||||
this->m_pResource->ErrorPrintf( "Unsupported type '%s (0x%i)' for '%s'\n", pType->strName.c_str(), pType->iType, this->GetName().c_str() );
|
||||
|
||||
break;
|
||||
}
|
||||
@ -311,9 +294,7 @@ void** CMonoEvent::ParseArguments( list< CLuaArgument* > argv )
|
||||
}
|
||||
}
|
||||
|
||||
delete [] pArguments;
|
||||
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
CMonoMethod* CMonoEvent::GetAddMethod( void )
|
||||
|
@ -15,14 +15,17 @@ class CMonoEvent;
|
||||
#ifndef __CMONOEVENT_H
|
||||
#define __CMONOEVENT_H
|
||||
|
||||
#include "CResource.h"
|
||||
#include "CMonoClass.h"
|
||||
#include "CMonoMethod.h"
|
||||
#include "CMonoArguments.h"
|
||||
|
||||
#include "extra/CLuaArgument.h"
|
||||
|
||||
class CMonoEvent
|
||||
{
|
||||
private:
|
||||
CResource* m_pResource;
|
||||
CMonoClass* m_pClass;
|
||||
|
||||
MonoEvent* m_pEvent;
|
||||
@ -37,7 +40,7 @@ public:
|
||||
~CMonoEvent ( void );
|
||||
|
||||
bool Call ( MonoObject* pThis, list< CLuaArgument* > argv );
|
||||
void** ParseArguments ( list< CLuaArgument* > argv );
|
||||
bool ParseArguments ( CMonoArguments& pArguments, list< CLuaArgument* > argv );
|
||||
|
||||
CMonoMethod* GetAddMethod ( void );
|
||||
CMonoMethod* GetRemoveMethod ( void );
|
||||
|
@ -15,9 +15,12 @@
|
||||
|
||||
void CMonoFunctions::AddInternals( void )
|
||||
{
|
||||
mono_add_internal_call( "MultiTheftAuto.Debug::Log", (const void*)CMonoFunctions::Debug::Log );
|
||||
mono_add_internal_call( "MultiTheftAuto.Debug::Info", (const void*)CMonoFunctions::Debug::Info );
|
||||
mono_add_internal_call( "MultiTheftAuto.Debug::Error", (const void*)CMonoFunctions::Debug::Error );
|
||||
MONO_DECLARE( Debug, Log );
|
||||
MONO_DECLARE( Debug, Info );
|
||||
MONO_DECLARE( Debug, Error );
|
||||
|
||||
MONO_DECLARE( Console, Write );
|
||||
MONO_DECLARE( Console, WriteLine );
|
||||
|
||||
MONO_DECLARE( Config, Get );
|
||||
MONO_DECLARE( Config, Set );
|
||||
@ -52,7 +55,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Event, TriggerClient );
|
||||
|
||||
// Element create/destroy
|
||||
MONO_DECLARE( Element, Create );
|
||||
MONO_DECLARE_CTOR( Element );
|
||||
MONO_DECLARE( Element, Destroy );
|
||||
MONO_DECLARE( Element, Clone );
|
||||
|
||||
@ -61,7 +64,8 @@ void CMonoFunctions::AddInternals( void )
|
||||
|
||||
MONO_DECLARE( Element, GetByType );
|
||||
MONO_DECLARE( Element, IsElement );
|
||||
MONO_DECLARE( Element, GetType );
|
||||
MONO_DECLARE( Element, GetUserData );
|
||||
MONO_DECLARE( Element, GetElementType );
|
||||
MONO_DECLARE( Element, GetByID );
|
||||
MONO_DECLARE( Element, GetByIndex );
|
||||
MONO_DECLARE( Element, GetChild );
|
||||
@ -201,7 +205,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Player, FadeCamera );
|
||||
|
||||
// Ped get functions
|
||||
MONO_DECLARE( Ped, Create );
|
||||
MONO_DECLARE_CTOR( Ped );
|
||||
MONO_DECLARE( Ped, GetArmor );
|
||||
MONO_DECLARE( Ped, IsChoking );
|
||||
MONO_DECLARE( Ped, IsDead );
|
||||
@ -265,10 +269,10 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Ped, SetWeaponAmmo );
|
||||
|
||||
// Vehicle create/destroy functions
|
||||
MONO_DECLARE( Vehicle, Create );
|
||||
MONO_DECLARE_CTOR( Vehicle );
|
||||
|
||||
// Vehicle get functions
|
||||
MONO_DECLARE( Vehicle, GetType );
|
||||
MONO_DECLARE( Vehicle, GetVehicleType );
|
||||
MONO_DECLARE( Vehicle, GetVariant );
|
||||
MONO_DECLARE( Vehicle, GetColor );
|
||||
MONO_DECLARE( Vehicle, GetModelFromName );
|
||||
@ -360,11 +364,11 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Vehicle, SetPlateText );
|
||||
|
||||
// Marker create/destroy functions
|
||||
MONO_DECLARE( Marker, Create );
|
||||
MONO_DECLARE_CTOR( Marker );
|
||||
|
||||
// Marker get functions
|
||||
MONO_DECLARE( Marker, GetCount );
|
||||
MONO_DECLARE( Marker, GetType );
|
||||
MONO_DECLARE( Marker, GetMarkerType );
|
||||
MONO_DECLARE( Marker, GetSize );
|
||||
MONO_DECLARE( Marker, GetColor );
|
||||
MONO_DECLARE( Marker, GetTarget );
|
||||
@ -378,8 +382,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Marker, SetIcon );
|
||||
|
||||
// Blip create/destroy functions
|
||||
MONO_DECLARE( Blip, Create );
|
||||
MONO_DECLARE( Blip, CreateAttachedTo );
|
||||
MONO_DECLARE_CTOR( Blip );
|
||||
|
||||
// Blip get functions
|
||||
MONO_DECLARE( Blip, GetIcon );
|
||||
@ -396,7 +399,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Blip, SetVisibleDistance );
|
||||
|
||||
// Object create/destroy functions
|
||||
MONO_DECLARE( Object, Create );
|
||||
MONO_DECLARE_CTOR( Object );
|
||||
|
||||
// Object get functions
|
||||
MONO_DECLARE( Object, GetScale );
|
||||
@ -407,7 +410,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Object, Stop );
|
||||
|
||||
// Radar area create/destroy funcs
|
||||
MONO_DECLARE( RadarArea, Create );
|
||||
MONO_DECLARE_CTOR( RadarArea );
|
||||
|
||||
// Radar area get funcs
|
||||
MONO_DECLARE( RadarArea, GetSize );
|
||||
@ -421,10 +424,10 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( RadarArea, SetFlashing );
|
||||
|
||||
// Pickup create/destroy funcs
|
||||
MONO_DECLARE( Pickup, Create );
|
||||
MONO_DECLARE_CTOR( Pickup );
|
||||
|
||||
// Pickup get funcs
|
||||
MONO_DECLARE( Pickup, GetType );
|
||||
MONO_DECLARE( Pickup, GetPickupType );
|
||||
MONO_DECLARE( Pickup, GetWeapon );
|
||||
MONO_DECLARE( Pickup, GetAmount );
|
||||
MONO_DECLARE( Pickup, GetAmmo );
|
||||
@ -437,12 +440,12 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Pickup, Use );
|
||||
|
||||
// Shape create funcs
|
||||
MONO_DECLARE( Shape, CreateCircle );
|
||||
MONO_DECLARE( Shape, CreateCuboid );
|
||||
MONO_DECLARE( Shape, CreateSphere );
|
||||
MONO_DECLARE( Shape, CreateRectangle );
|
||||
MONO_DECLARE( Shape, CreatePolygon );
|
||||
MONO_DECLARE( Shape, CreateTube );
|
||||
MONO_DECLARE_CTOR( ColCircle );
|
||||
MONO_DECLARE_CTOR( ColCuboid );
|
||||
MONO_DECLARE_CTOR( ColSphere );
|
||||
MONO_DECLARE_CTOR( ColRectangle );
|
||||
MONO_DECLARE_CTOR( ColPolygon );
|
||||
MONO_DECLARE_CTOR( ColTube );
|
||||
|
||||
// Explosion funcs
|
||||
MONO_DECLARE( Explosion, Create );
|
||||
@ -452,7 +455,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Audio, PlayMission );
|
||||
|
||||
// Team get funcs
|
||||
MONO_DECLARE( Team, Create );
|
||||
MONO_DECLARE_CTOR( Team );
|
||||
MONO_DECLARE( Team, GetFromName );
|
||||
MONO_DECLARE( Team, GetName );
|
||||
MONO_DECLARE( Team, GetColor );
|
||||
@ -465,7 +468,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Team, SetFriendlyFire );
|
||||
|
||||
// Water funcs
|
||||
MONO_DECLARE( Water, Create );
|
||||
MONO_DECLARE_CTOR( Water );
|
||||
MONO_DECLARE( Water, SetLevel );
|
||||
MONO_DECLARE( Water, SetLevelAll );
|
||||
MONO_DECLARE( Water, SetLevelWorld );
|
||||
@ -586,7 +589,7 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Ban, SetAdmin );
|
||||
|
||||
// Resource funcs
|
||||
MONO_DECLARE( Resource, Create );
|
||||
MONO_DECLARE_CTOR( Resource );
|
||||
MONO_DECLARE( Resource, Copy );
|
||||
MONO_DECLARE( Resource, GetRootElement );
|
||||
MONO_DECLARE( Resource, GetMapRootElement );
|
||||
@ -622,52 +625,91 @@ void CMonoFunctions::AddInternals( void )
|
||||
MONO_DECLARE( Resource, UpdateACLRequest );
|
||||
}
|
||||
|
||||
void CMonoFunctions::Debug::Log( MonoString *string )
|
||||
void CMonoFunctions::Debug::Log( MonoString* pString )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
g_pModuleManager->Printf( "%s\n", mono_string_to_utf8( string ) );
|
||||
string str = mono_string_to_utf8( pString );
|
||||
|
||||
str += "\n";
|
||||
|
||||
pResource->Printf( str.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void CMonoFunctions::Debug::Info( MonoString *string )
|
||||
void CMonoFunctions::Debug::Info( MonoString* pString )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
g_pModuleManager->DebugPrintf( RESOURCE->GetLua(), "%s", mono_string_to_utf8( string ) );
|
||||
string str = mono_string_to_utf8( pString );
|
||||
|
||||
pResource->DebugPrintf( str.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void CMonoFunctions::Debug::Error( MonoString *string )
|
||||
void CMonoFunctions::Debug::Error( MonoString* pString )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string str = mono_string_to_utf8( pString );
|
||||
|
||||
str += "\n";
|
||||
|
||||
g_pModuleManager->ErrorPrintf( "%s\n", mono_string_to_utf8( string ) );
|
||||
pResource->ErrorPrintf( str.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
void CMonoFunctions::Console::Write( MonoString* pString )
|
||||
{
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
printf( mono_string_to_utf8( pString ) );
|
||||
}
|
||||
}
|
||||
|
||||
void CMonoFunctions::Console::WriteLine( MonoString* pString )
|
||||
{
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
printf( mono_string_to_utf8( pString ) );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Config::Get( MonoString *msKey )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string sValue = CLuaFunctionDefinitions::Get( RESOURCE->GetLua(), mono_string_to_utf8( msKey ) );
|
||||
string sValue = CLuaFunctionDefinitions::Get( pResource->GetLua(), mono_string_to_utf8( msKey ) );
|
||||
|
||||
return mono_string_new( mono_domain_get(), sValue.c_str() );
|
||||
}
|
||||
|
||||
return mono_string_new( mono_domain_get(), "" );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szKey = mono_string_to_utf8( msKey );
|
||||
const char* szValue = mono_string_to_utf8( msValue );
|
||||
|
||||
return CLuaFunctionDefinitions::Set( RESOURCE->GetLua(), szKey, szValue );
|
||||
return CLuaFunctionDefinitions::Set( pResource->GetLua(), szKey, szValue );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -675,9 +717,11 @@ bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue )
|
||||
|
||||
unsigned int CMonoFunctions::Server::GetMaxPlayers( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::GetMaxPlayers( RESOURCE->GetLua() );
|
||||
return CLuaFunctionDefinitions::GetMaxPlayers( pResource->GetLua() );
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -685,37 +729,61 @@ unsigned int CMonoFunctions::Server::GetMaxPlayers( void )
|
||||
|
||||
bool CMonoFunctions::Server::SetMaxPlayers( unsigned int uiMax )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetMaxPlayers( RESOURCE->GetLua(), uiMax );
|
||||
return CLuaFunctionDefinitions::SetMaxPlayers( pResource->GetLua(), uiMax );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Server::OutputChatBox( MonoString* msText, DWORD pElement, MonoObject* mpColor, bool bColorCoded )
|
||||
bool CMonoFunctions::Server::OutputChatBox( MonoString* msText, MonoObject* pElementObj, MonoObject* mpColor, bool bColorCoded )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szText = mono_string_to_utf8( msText );
|
||||
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pElementObj );
|
||||
|
||||
if( !pElement )
|
||||
{
|
||||
pResource->ErrorPrintf( "Invalid argument #2 in method 'Server::OutputChatBox'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned char ucRed = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "R" );
|
||||
unsigned char ucGreen = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "G" );
|
||||
unsigned char ucBlue = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "B" );
|
||||
|
||||
return CLuaFunctionDefinitions::OutputChatBox( RESOURCE->GetLua(), szText, (void*)pElement, ucRed, ucGreen, ucBlue, bColorCoded );
|
||||
return CLuaFunctionDefinitions::OutputChatBox( pResource->GetLua(), szText, pElement->ToLuaUserData(), ucRed, ucGreen, ucBlue, bColorCoded );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Server::OutputConsole( MonoString* msText, DWORD pElement )
|
||||
bool CMonoFunctions::Server::OutputConsole( MonoString* msText, MonoObject* pElementObj )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szText = mono_string_to_utf8( msText );
|
||||
|
||||
return CLuaFunctionDefinitions::OutputConsole( RESOURCE->GetLua(), szText, (void*)pElement );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pElementObj );
|
||||
|
||||
if( !pElement )
|
||||
{
|
||||
pResource->ErrorPrintf( "Invalid argument #2 in method 'Server::OutputChatBox'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return CLuaFunctionDefinitions::OutputConsole( pResource->GetLua(), szText, pElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -723,11 +791,13 @@ bool CMonoFunctions::Server::OutputConsole( MonoString* msText, DWORD pElement )
|
||||
|
||||
bool CMonoFunctions::Server::SetPassword( MonoString* msPassword, bool bSave )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szPassword = mono_string_to_utf8( msPassword );
|
||||
|
||||
return CLuaFunctionDefinitions::SetServerPassword( RESOURCE->GetLua(), szPassword, bSave );
|
||||
return CLuaFunctionDefinitions::SetServerPassword( pResource->GetLua(), szPassword, bSave );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -735,11 +805,13 @@ bool CMonoFunctions::Server::SetPassword( MonoString* msPassword, bool bSave )
|
||||
|
||||
bool CMonoFunctions::Server::AddCommandHandler( MonoString* msCommand, MonoObject* pDelegate, bool bRestricted, bool bCaseSensitive )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
if( !pDelegate )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #1 in method 'Server::AddCommandHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #1 in method 'Server::AddCommandHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -748,14 +820,14 @@ bool CMonoFunctions::Server::AddCommandHandler( MonoString* msCommand, MonoObjec
|
||||
|
||||
if( strCommandName.length() == 0 )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #2 in method 'Server::AddCommandHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #2 in method 'Server::AddCommandHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( RESOURCE->GetCommandManager()->Add( strCommandName, pDelegate, bRestricted, bCaseSensitive ) )
|
||||
if( pResource->GetCommandManager()->Add( strCommandName, pDelegate, bRestricted, bCaseSensitive ) )
|
||||
{
|
||||
CLuaFunctionDefinitions::AddCommandHandler( RESOURCE->GetLua(), strCommandName.c_str(), CFunctions::monoCommandHandler, bRestricted, bCaseSensitive );
|
||||
CLuaFunctionDefinitions::AddCommandHandler( pResource->GetLua(), strCommandName.c_str(), CFunctions::monoCommandHandler, bRestricted, bCaseSensitive );
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -764,29 +836,40 @@ bool CMonoFunctions::Server::AddCommandHandler( MonoString* msCommand, MonoObjec
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Server::ExecuteCommandHandler( MonoString* msCommand, DWORD pUserData, MonoString* msArgs )
|
||||
bool CMonoFunctions::Server::ExecuteCommandHandler( MonoString* msCommand, MonoObject* pPlayerObj, MonoString* msArgs )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strCommandName = mono_string_to_utf8( msCommand );
|
||||
|
||||
if( strCommandName.length() == 0 )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #1 in method 'Server::ExecuteCommandHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #1 in method 'Server::ExecuteCommandHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !pUserData )
|
||||
if( !pPlayerObj )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #2 in method 'Server::ExecuteCommandHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #2 in method 'Server::ExecuteCommandHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CElement* pPlayer = pResource->GetElementManager()->GetFromList( pPlayerObj );
|
||||
|
||||
if( !pPlayer )
|
||||
{
|
||||
pResource->ErrorPrintf( "Invalid argument #2 in method 'Server::ExecuteCommandHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
string strArguments = mono_string_to_utf8( msArgs );
|
||||
|
||||
return CLuaFunctionDefinitions::ExecuteCommandHandler( RESOURCE->GetLua(), strCommandName.c_str(), (void*)pUserData, strArguments.c_str() );
|
||||
return CLuaFunctionDefinitions::ExecuteCommandHandler( pResource->GetLua(), strCommandName.c_str(), pPlayer->ToLuaUserData(), strArguments.c_str() );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -794,18 +877,20 @@ bool CMonoFunctions::Server::ExecuteCommandHandler( MonoString* msCommand, DWORD
|
||||
|
||||
bool CMonoFunctions::Server::RemoveCommandHandler( MonoString* msCommand, MonoObject* pDelegate )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strCommandName = mono_string_to_utf8( msCommand );
|
||||
|
||||
if( strCommandName.length() == 0 )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #1 in method 'Server::RemoveCommandHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #1 in method 'Server::RemoveCommandHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return RESOURCE->GetCommandManager()->Remove( strCommandName.c_str(), pDelegate );
|
||||
return pResource->GetCommandManager()->Remove( strCommandName.c_str(), pDelegate );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -813,9 +898,11 @@ bool CMonoFunctions::Server::RemoveCommandHandler( MonoString* msCommand, MonoOb
|
||||
|
||||
MonoObject* CMonoFunctions::Server::GetVersion( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
CLuaArgumentsMap pLuaTable = CLuaFunctionDefinitions::GetVersion( RESOURCE->GetLua() );
|
||||
CLuaArgumentsMap pLuaTable = CLuaFunctionDefinitions::GetVersion( pResource->GetLua() );
|
||||
|
||||
if( pLuaTable.size() >= 8 )
|
||||
{
|
||||
@ -828,18 +915,18 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
|
||||
const char* szBuildTag = pLuaTable[ "tag" ].GetString();
|
||||
const char* szSortable = pLuaTable[ "sortable" ].GetString();
|
||||
|
||||
CMonoCorlib* pLib = RESOURCE->GetDomain()->GetCorlib();
|
||||
CMonoCorlib* pLib = pResource->GetDomain()->GetCorlib();
|
||||
|
||||
PVOID* args = new PVOID[ pLuaTable.size() ];
|
||||
|
||||
MonoObject* pNumber = pLib->Class[ "uint64" ]->Box( &ulNumber );
|
||||
MonoString* pString = RESOURCE->GetDomain()->NewString( szString );
|
||||
MonoString* pName = RESOURCE->GetDomain()->NewString( szName );
|
||||
MonoString* pBuildType = RESOURCE->GetDomain()->NewString( szBuildType );
|
||||
MonoString* pString = pResource->GetDomain()->NewString( szString );
|
||||
MonoString* pName = pResource->GetDomain()->NewString( szName );
|
||||
MonoString* pBuildType = pResource->GetDomain()->NewString( szBuildType );
|
||||
MonoObject* pNetcode = pLib->Class[ "uint64" ]->Box( &ulNetcode );
|
||||
MonoString* pOS = RESOURCE->GetDomain()->NewString( szOS );
|
||||
MonoString* pBuildTag = RESOURCE->GetDomain()->NewString( szBuildTag );
|
||||
MonoString* pSortable = RESOURCE->GetDomain()->NewString( szSortable );
|
||||
MonoString* pOS = pResource->GetDomain()->NewString( szOS );
|
||||
MonoString* pBuildTag = pResource->GetDomain()->NewString( szBuildTag );
|
||||
MonoString* pSortable = pResource->GetDomain()->NewString( szSortable );
|
||||
|
||||
args[ 0 ] = pNumber;
|
||||
args[ 1 ] = pString;
|
||||
@ -850,7 +937,7 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
|
||||
args[ 6 ] = pBuildTag;
|
||||
args[ 7 ] = pSortable;
|
||||
|
||||
MonoObject* pObject = RESOURCE->GetDomain()->GetMTALib()->GetClass( "ServerVersion" )->New( args, pLuaTable.size() );
|
||||
MonoObject* pObject = pResource->GetDomain()->GetMTALib()->GetClass( "ServerVersion" )->New( args, pLuaTable.size() );
|
||||
|
||||
delete [] args;
|
||||
|
||||
@ -863,31 +950,37 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
|
||||
|
||||
MonoString* CMonoFunctions::Game::GetType( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetGameType( RESOURCE->GetLua() ) );
|
||||
return pResource->GetDomain()->NewString( CLuaFunctionDefinitions::GetGameType( pResource->GetLua() ) );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Game::GetMapName( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetMapName( RESOURCE->GetLua() ) );
|
||||
return pResource->GetDomain()->NewString( CLuaFunctionDefinitions::GetMapName( pResource->GetLua() ) );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Game::SetType( MonoString* msGameType )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szGameType = mono_string_to_utf8( msGameType );
|
||||
|
||||
return CLuaFunctionDefinitions::SetGameType( RESOURCE->GetLua(), szGameType );
|
||||
return CLuaFunctionDefinitions::SetGameType( pResource->GetLua(), szGameType );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -895,11 +988,13 @@ bool CMonoFunctions::Game::SetType( MonoString* msGameType )
|
||||
|
||||
bool CMonoFunctions::Game::SetMapName( MonoString* msMapName )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szMapName = mono_string_to_utf8( msMapName );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMapName( RESOURCE->GetLua(), szMapName );
|
||||
return CLuaFunctionDefinitions::SetMapName( pResource->GetLua(), szMapName );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -907,11 +1002,13 @@ bool CMonoFunctions::Game::SetMapName( MonoString* msMapName )
|
||||
|
||||
MonoString* CMonoFunctions::Game::GetRuleValue( MonoString* msKey )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szKey = mono_string_to_utf8( msKey );
|
||||
|
||||
return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetRuleValue( RESOURCE->GetLua(), szKey ) );
|
||||
return pResource->GetDomain()->NewString( CLuaFunctionDefinitions::GetRuleValue( pResource->GetLua(), szKey ) );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -919,12 +1016,14 @@ MonoString* CMonoFunctions::Game::GetRuleValue( MonoString* msKey )
|
||||
|
||||
bool CMonoFunctions::Game::SetRuleValue( MonoString* msKey, MonoString* msValue )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szKey = mono_string_to_utf8( msKey );
|
||||
const char* szValue = mono_string_to_utf8( msValue );
|
||||
|
||||
return CLuaFunctionDefinitions::SetRuleValue( RESOURCE->GetLua(), szKey, szValue );
|
||||
return CLuaFunctionDefinitions::SetRuleValue( pResource->GetLua(), szKey, szValue );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -932,11 +1031,13 @@ bool CMonoFunctions::Game::SetRuleValue( MonoString* msKey, MonoString* msValue
|
||||
|
||||
bool CMonoFunctions::Game::RemoveRuleValue( MonoString* msKey )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szKey = mono_string_to_utf8( msKey );
|
||||
|
||||
return CLuaFunctionDefinitions::RemoveRuleValue( RESOURCE->GetLua(), szKey );
|
||||
return CLuaFunctionDefinitions::RemoveRuleValue( pResource->GetLua(), szKey );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,51 +14,73 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Account get funcs
|
||||
DWORD CMonoFunctions::Account::Get( MonoString* msName, MonoString* msPassword )
|
||||
TElement CMonoFunctions::Account::Get( MonoString* msName, MonoString* msPassword )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szName = mono_string_to_utf8( msName );
|
||||
const char* szPassword = mono_string_to_utf8( msPassword );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::GetAccount( RESOURCE->GetLua(), szName, szPassword );
|
||||
}
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetAccount( pResource->GetLua(), szName, szPassword );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MonoArray* CMonoFunctions::Account::GetAll( void )
|
||||
if( pUserData )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
CLuaArgumentsVector pLuaTable = CLuaFunctionDefinitions::GetAccounts( RESOURCE->GetLua() );
|
||||
|
||||
if( pLuaTable.size() > 0 )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaTable );
|
||||
return pResource->GetElementManager()->Create( nullptr, pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Account::GetPlayer( DWORD pAccount )
|
||||
MonoArray* CMonoFunctions::Account::GetAll( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return (DWORD)CLuaFunctionDefinitions::GetAccountPlayer( RESOURCE->GetLua(), (void*)pAccount );
|
||||
CLuaArgumentsVector pLuaTable = CLuaFunctionDefinitions::GetAccounts( pResource->GetLua() );
|
||||
|
||||
if( pLuaTable.size() > 0 )
|
||||
{
|
||||
return pResource->GetDomain()->NewElementArray( pResource->GetDomain()->GetMTALib()->GetClass( "Account" )->GetMonoPtr(), pLuaTable );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Account::IsGuest( DWORD pAccount )
|
||||
TElement CMonoFunctions::Account::GetPlayer( TElement pAccount )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAccount );
|
||||
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetAccountPlayer( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
return pResource->GetElementManager()->Create( nullptr, pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Account::IsGuest( TElement pAccount )
|
||||
{
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
bool bIsGuest;
|
||||
|
||||
if( CLuaFunctionDefinitions::IsGuestAccount( RESOURCE->GetLua(), (void*)pAccount, bIsGuest ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAccount );
|
||||
|
||||
if( CLuaFunctionDefinitions::IsGuestAccount( pResource->GetLua(), pElement->ToLuaUserData(), bIsGuest ) )
|
||||
{
|
||||
return bIsGuest;
|
||||
}
|
||||
@ -67,15 +89,19 @@ bool CMonoFunctions::Account::IsGuest( DWORD pAccount )
|
||||
return false;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Account::GetSerial( DWORD pAccount )
|
||||
MonoString* CMonoFunctions::Account::GetSerial( TElement pAccount )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strSerial;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetAccountSerial( RESOURCE->GetLua(), (void*)pAccount, strSerial ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAccount );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetAccountSerial( pResource->GetLua(), pElement->ToLuaUserData(), strSerial ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strSerial );
|
||||
return pResource->GetDomain()->NewString( strSerial );
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,46 +109,66 @@ MonoString* CMonoFunctions::Account::GetSerial( DWORD pAccount )
|
||||
}
|
||||
|
||||
// Account set funcs
|
||||
DWORD CMonoFunctions::Account::Add( MonoString* msName, MonoString* msPassword )
|
||||
TElement CMonoFunctions::Account::Add( MonoString* msName, MonoString* msPassword )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szName = mono_string_to_utf8( msName );
|
||||
const char* szPassword = mono_string_to_utf8( msPassword );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::AddAccount( RESOURCE->GetLua(), szName, szPassword );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::AddAccount( pResource->GetLua(), szName, szPassword );
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
return pResource->GetElementManager()->Create( nullptr, pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Account::Remove( DWORD pAccount )
|
||||
bool CMonoFunctions::Account::Remove( TElement pAccount )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::RemoveAccount( RESOURCE->GetLua(), (void*)pAccount );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAccount );
|
||||
|
||||
return CLuaFunctionDefinitions::RemoveAccount( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Account::SetPassword( DWORD pAccount, MonoString* msPassword )
|
||||
bool CMonoFunctions::Account::SetPassword( TElement pAccount, MonoString* msPassword )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szPassword = mono_string_to_utf8( msPassword );
|
||||
|
||||
return CLuaFunctionDefinitions::SetAccountPassword( RESOURCE->GetLua(), (void*)pAccount, szPassword );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAccount );
|
||||
|
||||
return CLuaFunctionDefinitions::SetAccountPassword( pResource->GetLua(), pElement->ToLuaUserData(), szPassword );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Account::CopyData( DWORD pAccount, DWORD pFromAccount )
|
||||
bool CMonoFunctions::Account::CopyData( TElement pAccount, TElement pFromAccount )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::CopyAccountData( RESOURCE->GetLua(), (void*)pAccount, (void*)pFromAccount );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAccount );
|
||||
CElement* pFromElement = pResource->GetElementManager()->GetFromList( pFromAccount );
|
||||
|
||||
return CLuaFunctionDefinitions::CopyAccountData( pResource->GetLua(), pElement->ToLuaUserData(), pFromElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -14,23 +14,31 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Audio funcs
|
||||
bool CMonoFunctions::Audio::PlayFrontEnd( DWORD pUserData, unsigned char ucSound )
|
||||
bool CMonoFunctions::Audio::PlayFrontEnd( TElement pThis, unsigned char ucSound )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::PlaySoundFrontEnd( RESOURCE->GetLua(), (void*)pUserData, ucSound );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::PlaySoundFrontEnd( pResource->GetLua(), pElement->ToLuaUserData(), ucSound );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Audio::PlayMission( DWORD pUserData, MonoObject* pPosition, unsigned short usSlot )
|
||||
bool CMonoFunctions::Audio::PlayMission( TElement pThis, MonoObject* pPosition, unsigned short usSlot )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( pPosition );
|
||||
|
||||
return CLuaFunctionDefinitions::PlayMissionAudio( RESOURCE->GetLua(), (void*)pUserData, vecPosition, usSlot );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::PlayMissionAudio( pResource->GetLua(), pElement->ToLuaUserData(), vecPosition, usSlot );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -13,9 +13,11 @@
|
||||
#include "StdInc.h"
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
DWORD CMonoFunctions::Ban::Add( MonoString* msIP, MonoString* msUsername, MonoString* msSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban )
|
||||
TElement CMonoFunctions::Ban::Add( MonoString* msIP, MonoString* msUsername, MonoString* msSerial, TElement pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string
|
||||
strIP ( mono_string_to_utf8( msIP ) ),
|
||||
@ -24,17 +26,29 @@ DWORD CMonoFunctions::Ban::Add( MonoString* msIP, MonoString* msUsername, MonoSt
|
||||
strResponsible ( mono_string_to_utf8( msResponsible ) ),
|
||||
strReason ( mono_string_to_utf8( msReason ) );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::AddBan( RESOURCE->GetLua(), strIP, strUsername, strSerial, (void*)pResponsible, strResponsible, strReason, iUnban );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pResponsible );
|
||||
|
||||
PVOID pUserData = CLuaFunctionDefinitions::AddBan( pResource->GetLua(), strIP, strUsername, strSerial, pElement->ToLuaUserData(), strResponsible, strReason, iUnban );
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
return pResource->GetElementManager()->Create( nullptr, pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Ban::Remove( DWORD pBan, DWORD pResponsible )
|
||||
bool CMonoFunctions::Ban::Remove( TElement pBan, TElement pResponsible )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return (DWORD)CLuaFunctionDefinitions::RemoveBan( RESOURCE->GetLua(), (void*)pBan, (void*)pResponsible );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
CElement* pResponsibleElement = pResource->GetElementManager()->GetFromList( pResponsible );
|
||||
|
||||
return CLuaFunctionDefinitions::RemoveBan( pResource->GetLua(), pElement->ToLuaUserData(), pResponsibleElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -43,99 +57,125 @@ bool CMonoFunctions::Ban::Remove( DWORD pBan, DWORD pResponsible )
|
||||
|
||||
bool CMonoFunctions::Ban::Reload( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return (DWORD)CLuaFunctionDefinitions::ReloadBanList( RESOURCE->GetLua() );
|
||||
return CLuaFunctionDefinitions::ReloadBanList( pResource->GetLua() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
MonoString* CMonoFunctions::Ban::GetIP( DWORD pBan )
|
||||
MonoString* CMonoFunctions::Ban::GetIP( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strIP;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanIP( RESOURCE->GetLua(), (void*)pBan, strIP ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanIP( pResource->GetLua(), pElement->ToLuaUserData(), strIP ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strIP );
|
||||
return pResource->GetDomain()->NewString( strIP );
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Ban::GetSerial( DWORD pBan )
|
||||
MonoString* CMonoFunctions::Ban::GetSerial( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strSerial;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanSerial( RESOURCE->GetLua(), (void*)pBan, strSerial ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanSerial( pResource->GetLua(), pElement->ToLuaUserData(), strSerial ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strSerial );
|
||||
return pResource->GetDomain()->NewString( strSerial );
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Ban::GetUsername( DWORD pBan )
|
||||
MonoString* CMonoFunctions::Ban::GetUsername( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strUsername;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanUsername( RESOURCE->GetLua(), (void*)pBan, strUsername ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanUsername( pResource->GetLua(), pElement->ToLuaUserData(), strUsername ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strUsername );
|
||||
return pResource->GetDomain()->NewString( strUsername );
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Ban::GetNick( DWORD pBan )
|
||||
MonoString* CMonoFunctions::Ban::GetNick( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strNick;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanNick( RESOURCE->GetLua(), (void*)pBan, strNick ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanNick( pResource->GetLua(), pElement->ToLuaUserData(), strNick ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strNick );
|
||||
return pResource->GetDomain()->NewString( strNick );
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Ban::GetReason( DWORD pBan )
|
||||
MonoString* CMonoFunctions::Ban::GetReason( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strReason;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanReason( RESOURCE->GetLua(), (void*)pBan, strReason ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanReason( pResource->GetLua(), pElement->ToLuaUserData(), strReason ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strReason );
|
||||
return pResource->GetDomain()->NewString( strReason );
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Ban::GetAdmin( DWORD pBan )
|
||||
MonoString* CMonoFunctions::Ban::GetAdmin( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strAdmin;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanAdmin( RESOURCE->GetLua(), (void*)pBan, strAdmin ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanAdmin( pResource->GetLua(), pElement->ToLuaUserData(), strAdmin ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strAdmin );
|
||||
return pResource->GetDomain()->NewString( strAdmin );
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,13 +183,17 @@ MonoString* CMonoFunctions::Ban::GetAdmin( DWORD pBan )
|
||||
}
|
||||
|
||||
|
||||
int CMonoFunctions::Ban::GetBanTime( DWORD pBan )
|
||||
int CMonoFunctions::Ban::GetBanTime( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
time_t tTime;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanTime( RESOURCE->GetLua(), (void*)pBan, tTime ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBanTime( pResource->GetLua(), pElement->ToLuaUserData(), tTime ) )
|
||||
{
|
||||
return (int)tTime;
|
||||
}
|
||||
@ -158,13 +202,17 @@ int CMonoFunctions::Ban::GetBanTime( DWORD pBan )
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMonoFunctions::Ban::GetUnbanTime( DWORD pBan )
|
||||
int CMonoFunctions::Ban::GetUnbanTime( TElement pBan )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
time_t tTime;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetUnbanTime( RESOURCE->GetLua(), (void*)pBan, tTime ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetUnbanTime( pResource->GetLua(), pElement->ToLuaUserData(), tTime ) )
|
||||
{
|
||||
return (int)tTime;
|
||||
}
|
||||
@ -174,35 +222,47 @@ int CMonoFunctions::Ban::GetUnbanTime( DWORD pBan )
|
||||
}
|
||||
|
||||
|
||||
bool CMonoFunctions::Ban::SetUnbanTime( DWORD pBan, int time )
|
||||
bool CMonoFunctions::Ban::SetUnbanTime( TElement pBan, int time )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetUnbanTime( RESOURCE->GetLua(), (void*)pBan, time );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
return CLuaFunctionDefinitions::SetUnbanTime( pResource->GetLua(), pElement->ToLuaUserData(), time );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Ban::SetReason( DWORD pBan, MonoString* msReason )
|
||||
bool CMonoFunctions::Ban::SetReason( TElement pBan, MonoString* msReason )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strReason( mono_string_to_utf8( msReason ) );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBanReason( RESOURCE->GetLua(), (void*)pBan, strReason );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBanReason( pResource->GetLua(), pElement->ToLuaUserData(), strReason );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Ban::SetAdmin( DWORD pBan, MonoString* msAdminName )
|
||||
bool CMonoFunctions::Ban::SetAdmin( TElement pBan, MonoString* msAdminName )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strAdmin( mono_string_to_utf8( msAdminName ) );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBanAdmin( RESOURCE->GetLua(), (void*)pBan, strAdmin );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pBan );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBanAdmin( pResource->GetLua(), pElement->ToLuaUserData(), strAdmin );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -14,41 +14,64 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Blip create/destroy functions
|
||||
DWORD CMonoFunctions::Blip::Create( MonoObject* pPosition, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo )
|
||||
void CMonoFunctions::Blip::Ctor( TElement pThis, MonoObject* pTarget, unsigned char ucIcon, unsigned char ucSize, MonoObject* pArgColor, short sOrdering, unsigned short usVisibleDistance, TElement pArgVisibleTo )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( pPosition );
|
||||
SColor pColor;
|
||||
PVOID pVisibleTo = nullptr;
|
||||
|
||||
SColor pColor = CMonoObject::GetColor( color );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateBlip( RESOURCE->GetLua(), vecPosition, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo );
|
||||
if( pArgColor )
|
||||
{
|
||||
pColor = CMonoObject::GetColor( pArgColor );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Blip::CreateAttachedTo( DWORD pTarget, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo )
|
||||
if( pArgVisibleTo )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CElement* pVisibleToElement = pResource->GetElementManager()->GetFromList( pArgVisibleTo );
|
||||
|
||||
if( pVisibleToElement )
|
||||
{
|
||||
SColor pColor = CMonoObject::GetColor( color );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateBlipAttachedTo( RESOURCE->GetLua(), (void*)pTarget, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo );
|
||||
pVisibleTo = pVisibleToElement->ToLuaUserData();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
PVOID pUserData = nullptr;
|
||||
|
||||
string strClassName = mono_class_get_name( mono_object_get_class( pTarget ) );
|
||||
|
||||
if( strClassName == "Vector3" )
|
||||
{
|
||||
pUserData = CLuaFunctionDefinitions::CreateBlip( pResource->GetLua(), Vector3( pTarget ), ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, pVisibleTo );
|
||||
}
|
||||
else
|
||||
{
|
||||
CElement* pTargetElement = pResource->GetElementManager()->GetFromList( pTarget );
|
||||
|
||||
pUserData = CLuaFunctionDefinitions::CreateBlipAttachedTo( pResource->GetLua(), pTargetElement->ToLuaUserData(), ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, pVisibleTo );
|
||||
}
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Blip get functions
|
||||
unsigned char CMonoFunctions::Blip::GetIcon( DWORD pUserData )
|
||||
unsigned char CMonoFunctions::Blip::GetIcon( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned char ucIcon;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipIcon( pResource->GetLua(), pElement->ToLuaUserData(), ucIcon ) )
|
||||
{
|
||||
return ucIcon;
|
||||
}
|
||||
@ -57,13 +80,17 @@ unsigned char CMonoFunctions::Blip::GetIcon( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char CMonoFunctions::Blip::GetSize( DWORD pUserData )
|
||||
unsigned char CMonoFunctions::Blip::GetSize( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned char ucSize;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipSize( pResource->GetLua(), pElement->ToLuaUserData(), ucSize ) )
|
||||
{
|
||||
return ucSize;
|
||||
}
|
||||
@ -72,28 +99,36 @@ unsigned char CMonoFunctions::Blip::GetSize( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
MonoObject* CMonoFunctions::Blip::GetColor( DWORD pUserData )
|
||||
MonoObject* CMonoFunctions::Blip::GetColor( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor outColor;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipColor( pResource->GetLua(), pElement->ToLuaUserData(), outColor ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Color->New( outColor );
|
||||
return pResource->GetDomain()->GetMTALib()->Color->New( outColor );
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
short CMonoFunctions::Blip::GetOrdering( DWORD pUserData )
|
||||
short CMonoFunctions::Blip::GetOrdering( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
short sOrdering;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipOrdering( pResource->GetLua(), pElement->ToLuaUserData(), sOrdering ) )
|
||||
{
|
||||
return sOrdering;
|
||||
}
|
||||
@ -102,13 +137,17 @@ short CMonoFunctions::Blip::GetOrdering( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned short CMonoFunctions::Blip::GetVisibleDistance( DWORD pUserData )
|
||||
unsigned short CMonoFunctions::Blip::GetVisibleDistance( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned short usVisibleDistance;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetBlipVisibleDistance( pResource->GetLua(), pElement->ToLuaUserData(), usVisibleDistance ) )
|
||||
{
|
||||
return usVisibleDistance;
|
||||
}
|
||||
@ -119,51 +158,71 @@ unsigned short CMonoFunctions::Blip::GetVisibleDistance( DWORD pUserData )
|
||||
|
||||
|
||||
// Blip set functions
|
||||
bool CMonoFunctions::Blip::SetIcon( DWORD pUserData, unsigned char ucIcon )
|
||||
bool CMonoFunctions::Blip::SetIcon( TElement pThis, unsigned char ucIcon )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBlipIcon( pResource->GetLua(), pElement->ToLuaUserData(), ucIcon );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Blip::SetSize( DWORD pUserData, unsigned char ucSize )
|
||||
bool CMonoFunctions::Blip::SetSize( TElement pThis, unsigned char ucSize )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBlipSize( pResource->GetLua(), pElement->ToLuaUserData(), ucSize );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Blip::SetColor( DWORD pUserData, MonoObject* color )
|
||||
bool CMonoFunctions::Blip::SetColor( TElement pThis, MonoObject* color )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetBlipColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( color ) );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBlipColor( pResource->GetLua(), pElement->ToLuaUserData(), CMonoObject::GetColor( color ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Blip::SetOrdering( DWORD pUserData, short sOrdering )
|
||||
bool CMonoFunctions::Blip::SetOrdering( TElement pThis, short sOrdering )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBlipOrdering( pResource->GetLua(), pElement->ToLuaUserData(), sOrdering );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Blip::SetVisibleDistance( DWORD pUserData, unsigned short usVisibleDistance )
|
||||
bool CMonoFunctions::Blip::SetVisibleDistance( TElement pThis, unsigned short usVisibleDistance )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetBlipVisibleDistance( pResource->GetLua(), pElement->ToLuaUserData(), usVisibleDistance );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,33 +15,37 @@
|
||||
|
||||
bool CMonoFunctions::Event::Add( MonoString* msName, bool bAllowRemoteTrigger )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szName = mono_string_to_utf8( msName );
|
||||
|
||||
if( CLuaFunctionDefinitions::AddEvent( RESOURCE->GetLua(), szName, bAllowRemoteTrigger ) )
|
||||
if( CLuaFunctionDefinitions::AddEvent( pResource->GetLua(), szName, bAllowRemoteTrigger ) )
|
||||
{
|
||||
return RESOURCE->AddEvent( szName, "root" );
|
||||
return pResource->AddEvent( szName, "root" );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Event::AddHandler( MonoString* msName, DWORD pUserData, MonoObject* pDelegate, bool bPropagated, MonoString* msEventPriority )
|
||||
bool CMonoFunctions::Event::AddHandler( MonoString* msName, TElement pAttachedTo, MonoObject* pDelegate, bool bPropagated, MonoString* msEventPriority )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
if( !pUserData )
|
||||
if( !pAttachedTo )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #2 in method 'Event::AddHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #2 in method 'Event::AddHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !pDelegate )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #3 in method 'Event::AddHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #3 in method 'Event::AddHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -50,33 +54,37 @@ bool CMonoFunctions::Event::AddHandler( MonoString* msName, DWORD pUserData, Mon
|
||||
|
||||
if( strEventName.length() == 0 )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #1 in method 'Event::AddHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #1 in method 'Event::AddHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
string strEventPriority = mono_string_to_utf8( msEventPriority );
|
||||
|
||||
return RESOURCE->GetEventManager()->Add( strEventName, pUserData, pDelegate, bPropagated, strEventPriority );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAttachedTo );
|
||||
|
||||
return pResource->GetEventManager()->Add( strEventName, pElement, pDelegate, bPropagated, strEventPriority );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Event::RemoveHandler( MonoString* msName, DWORD pUserData, MonoObject* pDelegate )
|
||||
bool CMonoFunctions::Event::RemoveHandler( MonoString* msName, TElement pAttachedTo, MonoObject* pDelegate )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
if( !pUserData )
|
||||
if( !pAttachedTo )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #2 in method 'Event::AddHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #2 in method 'Event::AddHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !pDelegate )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #3 in method 'Event::AddHandler'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #3 in method 'Event::AddHandler'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -85,26 +93,32 @@ bool CMonoFunctions::Event::RemoveHandler( MonoString* msName, DWORD pUserData,
|
||||
|
||||
if( strEventName.length() == 0 )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Invalid argument #1 in method 'Event::RemoveEvent'\n" );
|
||||
pResource->ErrorPrintf( "Invalid argument #1 in method 'Event::RemoveEvent'\n" );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return RESOURCE->GetEventManager()->Delete( strEventName, pUserData, pDelegate );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pAttachedTo );
|
||||
|
||||
return pResource->GetEventManager()->Delete( strEventName, pElement, pDelegate );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Event::Trigger( MonoString* msName, DWORD pUserData, MonoArray* mpArguments )
|
||||
bool CMonoFunctions::Event::Trigger( MonoString* msName, TElement pArgElement, MonoArray* mpArguments )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szEventName = mono_string_to_utf8( msName );
|
||||
|
||||
CLuaArguments Arguments = CMonoInterface::MonoArrayToLuaArguments( mpArguments );
|
||||
CLuaArguments Arguments = CMonoInterface::MonoArrayToLuaArguments( mpArguments, pResource );
|
||||
|
||||
return CLuaFunctionDefinitions::TriggerEvent( RESOURCE->GetLua(), szEventName, (void*)pUserData, Arguments );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pArgElement );
|
||||
|
||||
return CLuaFunctionDefinitions::TriggerEvent( pResource->GetLua(), szEventName, pElement->ToLuaUserData(), Arguments );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -112,11 +126,13 @@ bool CMonoFunctions::Event::Trigger( MonoString* msName, DWORD pUserData, MonoAr
|
||||
|
||||
bool CMonoFunctions::Event::Cancel( bool bCancel, MonoString* msReason )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szReason = mono_string_to_utf8( msReason );
|
||||
|
||||
return CLuaFunctionDefinitions::CancelEvent( RESOURCE->GetLua(), bCancel, szReason );
|
||||
return CLuaFunctionDefinitions::CancelEvent( pResource->GetLua(), bCancel, szReason );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -124,9 +140,11 @@ bool CMonoFunctions::Event::Cancel( bool bCancel, MonoString* msReason )
|
||||
|
||||
bool CMonoFunctions::Event::WasCancelled( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::WasEventCancelled( RESOURCE->GetLua() );
|
||||
return CLuaFunctionDefinitions::WasEventCancelled( pResource->GetLua() );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -134,23 +152,30 @@ bool CMonoFunctions::Event::WasCancelled( void )
|
||||
|
||||
string CMonoFunctions::Event::GetCancelReason( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::GetCancelReason( RESOURCE->GetLua() );
|
||||
return CLuaFunctionDefinitions::GetCancelReason( pResource->GetLua() );
|
||||
}
|
||||
|
||||
return string();
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Event::TriggerClient( DWORD pSendTo, MonoString* msName, DWORD pSource, MonoArray* mpArguments )
|
||||
bool CMonoFunctions::Event::TriggerClient( TElement pSendTo, MonoString* msName, TElement pSource, MonoArray* mpArguments )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szEventName = mono_string_to_utf8( msName );
|
||||
|
||||
CLuaArguments Arguments = CMonoInterface::MonoArrayToLuaArguments( mpArguments );
|
||||
CElement* pSendToElement = pResource->GetElementManager()->GetFromList( pSendTo );
|
||||
CElement* pSourceElement = pResource->GetElementManager()->GetFromList( pSource );
|
||||
|
||||
return CLuaFunctionDefinitions::TriggerClientEvent( RESOURCE->GetLua(), (void*)pSendTo, szEventName, (void*)pSource, Arguments );
|
||||
CLuaArguments Arguments = CMonoInterface::MonoArrayToLuaArguments( mpArguments, pResource );
|
||||
|
||||
return CLuaFunctionDefinitions::TriggerClientEvent( pResource->GetLua(), pSendToElement->ToLuaUserData(), szEventName, pSourceElement->ToLuaUserData(), Arguments );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -14,12 +14,16 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Explosion funcs
|
||||
bool CMonoFunctions::Explosion::Create( MonoObject* pPosition, unsigned char ucType, DWORD pCreator )
|
||||
bool CMonoFunctions::Explosion::Create( MonoObject* pPosition, unsigned char ucType, TElement pCreator )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateExplosion( RESOURCE->GetLua(), Vector3( pPosition ), ucType, (void*)pCreator );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pCreator );
|
||||
|
||||
return CLuaFunctionDefinitions::CreateExplosion( pResource->GetLua(), Vector3( pPosition ), ucType, pElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
@ -14,27 +14,40 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Marker create/destroy functions
|
||||
DWORD CMonoFunctions::Marker::Create( MonoObject* pPosition, MonoString* msType, float fSize, MonoObject* pColor, DWORD pVisibleTo )
|
||||
void CMonoFunctions::Marker::Ctor( TElement pThis, MonoObject* pPosition, MonoString* msType, float fSize, MonoObject* pColor, TElement pArgVisibleTo )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szType = mono_string_to_utf8( msType );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateMarker( RESOURCE->GetLua(), Vector3( pPosition ), szType, fSize, CMonoObject::GetColor( pColor ), (void*)pVisibleTo );
|
||||
PVOID pVisibleTo = nullptr;
|
||||
|
||||
if( pArgVisibleTo )
|
||||
{
|
||||
pVisibleTo = pResource->GetElementManager()->GetFromList( pArgVisibleTo )->ToLuaUserData();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateMarker( pResource->GetLua(), Vector3( pPosition ), szType, fSize, CMonoObject::GetColor( pColor ), pVisibleTo );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Marker get functions
|
||||
unsigned int CMonoFunctions::Marker::GetCount()
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned int uiCount;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerCount( RESOURCE->GetLua(), uiCount ) )
|
||||
if( CLuaFunctionDefinitions::GetMarkerCount( pResource->GetLua(), uiCount ) )
|
||||
{
|
||||
return uiCount;
|
||||
}
|
||||
@ -43,28 +56,36 @@ unsigned int CMonoFunctions::Marker::GetCount()
|
||||
return 0;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Marker::GetType( DWORD pUserData )
|
||||
MonoString* CMonoFunctions::Marker::GetMarkerType( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
char* szType = NULL;
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ) )
|
||||
if( pResource )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( szType );
|
||||
char* szType = nullptr;
|
||||
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerType( pResource->GetLua(), pElement->ToLuaUserData(), szType ) )
|
||||
{
|
||||
return pResource->GetDomain()->NewString( szType );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
float CMonoFunctions::Marker::GetSize( DWORD pUserData )
|
||||
float CMonoFunctions::Marker::GetSize( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
float fSize;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerSize( pResource->GetLua(), pElement->ToLuaUserData(), fSize ) )
|
||||
{
|
||||
return fSize;
|
||||
}
|
||||
@ -73,102 +94,134 @@ float CMonoFunctions::Marker::GetSize( DWORD pUserData )
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
MonoObject* CMonoFunctions::Marker::GetColor( DWORD pUserData )
|
||||
MonoObject* CMonoFunctions::Marker::GetColor( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor outColor;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerColor( pResource->GetLua(), pElement->ToLuaUserData(), outColor ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Color->New( outColor );
|
||||
return pResource->GetDomain()->GetMTALib()->Color->New( outColor );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoObject* CMonoFunctions::Marker::GetTarget( DWORD pUserData )
|
||||
MonoObject* CMonoFunctions::Marker::GetTarget( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerTarget( pResource->GetLua(), pElement->ToLuaUserData(), vecPosition ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
|
||||
return pResource->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Marker::GetIcon( DWORD pUserData )
|
||||
MonoString* CMonoFunctions::Marker::GetIcon( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
char* szIcon = NULL;
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerIcon( RESOURCE->GetLua(), (void*)pUserData, szIcon ) )
|
||||
if( pResource )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( szIcon );
|
||||
char* szIcon = nullptr;
|
||||
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetMarkerIcon( pResource->GetLua(), pElement->ToLuaUserData(), szIcon ) )
|
||||
{
|
||||
return pResource->GetDomain()->NewString( szIcon );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// Marker set functions
|
||||
bool CMonoFunctions::Marker::SetType( DWORD pUserData, MonoString* msType )
|
||||
bool CMonoFunctions::Marker::SetType( TElement pThis, MonoString* msType )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szType = mono_string_to_utf8( msType );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMarkerType( pResource->GetLua(), pElement->ToLuaUserData(), szType );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Marker::SetSize( DWORD pUserData, float fSize )
|
||||
bool CMonoFunctions::Marker::SetSize( TElement pThis, float fSize )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMarkerSize( pResource->GetLua(), pElement->ToLuaUserData(), fSize );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Marker::SetColor( DWORD pUserData, MonoObject* pColor )
|
||||
bool CMonoFunctions::Marker::SetColor( TElement pThis, MonoObject* pColor )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( pColor ) );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMarkerColor( pResource->GetLua(), pElement->ToLuaUserData(), CMonoObject::GetColor( pColor ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Marker::SetTarget( DWORD pUserData, MonoObject* pTarget )
|
||||
bool CMonoFunctions::Marker::SetTarget( TElement pThis, MonoObject* pTarget )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, Vector3( pTarget ) );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMarkerTarget( pResource->GetLua(), pElement->ToLuaUserData(), Vector3( pTarget ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Marker::SetIcon( DWORD pUserData, MonoString* msIcon )
|
||||
bool CMonoFunctions::Marker::SetIcon( TElement pThis, MonoString* msIcon )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szIcon = mono_string_to_utf8( msIcon );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szIcon );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetMarkerType( pResource->GetLua(), pElement->ToLuaUserData(), szIcon );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -14,51 +14,65 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Object create/destroy functions
|
||||
DWORD CMonoFunctions::Object::Create( unsigned short usModelID, MonoObject* pPosition, MonoObject* pRotation, bool bIsLowLod )
|
||||
void CMonoFunctions::Object::Ctor( TElement pThis, unsigned short usModelID, MonoObject* pPosition, MonoObject* pRotation, bool bIsLowLod )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( pPosition );
|
||||
Vector3 vecRotation( pRotation );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateObject( RESOURCE->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod );
|
||||
}
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateObject( pResource->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod );
|
||||
|
||||
return NULL;
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Object get functions
|
||||
MonoObject* CMonoFunctions::Object::GetScale( DWORD pUserData )
|
||||
MonoObject* CMonoFunctions::Object::GetScale( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecScale;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetObjectScale( pResource->GetLua(), pElement->ToLuaUserData(), vecScale ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecScale );
|
||||
return pResource->GetDomain()->GetMTALib()->Vector3->New( vecScale );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
// Object set functions
|
||||
bool CMonoFunctions::Object::SetScale( DWORD pUserData, MonoObject* pScale )
|
||||
bool CMonoFunctions::Object::SetScale( TElement pThis, MonoObject* pScale )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetObjectScale( RESOURCE->GetLua(), (void*)pUserData, Vector3( pScale ) );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetObjectScale( pResource->GetLua(), pElement->ToLuaUserData(), Vector3( pScale ) );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Object::Move( DWORD pUserData, unsigned long ulTime, MonoObject* pPosition, MonoObject* pRotation, MonoString* msEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot )
|
||||
bool CMonoFunctions::Object::Move( TElement pThis, unsigned long ulTime, MonoObject* pPosition, MonoObject* pRotation, MonoString* msEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3
|
||||
vecPosition( pPosition ),
|
||||
@ -66,17 +80,23 @@ bool CMonoFunctions::Object::Move( DWORD pUserData, unsigned long ulTime, MonoOb
|
||||
|
||||
const char* szEasingType = mono_string_to_utf8( msEasingType );
|
||||
|
||||
return CLuaFunctionDefinitions::MoveObject( RESOURCE->GetLua(), (void*)pUserData, ulTime, vecPosition, vecRotation, szEasingType, fEasingPeriod, fEasingAmplitude, fEasingOvershoot );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::MoveObject( pResource->GetLua(), pElement->ToLuaUserData(), ulTime, vecPosition, vecRotation, szEasingType, fEasingPeriod, fEasingAmplitude, fEasingOvershoot );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Object::Stop( DWORD pUserData )
|
||||
bool CMonoFunctions::Object::Stop( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::StopObject( RESOURCE->GetLua(), (void*)pUserData );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::StopObject( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,27 +14,35 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Pickup create/destroy funcs
|
||||
DWORD CMonoFunctions::Pickup::Create( MonoObject* pPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval, double dSix )
|
||||
void CMonoFunctions::Pickup::Ctor( TElement pThis, MonoObject* pPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval, double dSix )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( pPosition );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreatePickup( RESOURCE->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix );
|
||||
}
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreatePickup( pResource->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix );
|
||||
|
||||
return NULL;
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Pickup get funcs
|
||||
unsigned char CMonoFunctions::Pickup::GetType( DWORD pUserData )
|
||||
unsigned char CMonoFunctions::Pickup::GetPickupType( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned char ucType;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupType( pResource->GetLua(), pElement->ToLuaUserData(), ucType ) )
|
||||
{
|
||||
return ucType;
|
||||
}
|
||||
@ -43,13 +51,17 @@ unsigned char CMonoFunctions::Pickup::GetType( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned char CMonoFunctions::Pickup::GetWeapon( DWORD pUserData )
|
||||
unsigned char CMonoFunctions::Pickup::GetWeapon( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned char ucWeapon;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupWeapon( RESOURCE->GetLua(), (void*)pUserData, ucWeapon ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupWeapon( pResource->GetLua(), pElement->ToLuaUserData(), ucWeapon ) )
|
||||
{
|
||||
return ucWeapon;
|
||||
}
|
||||
@ -58,13 +70,17 @@ unsigned char CMonoFunctions::Pickup::GetWeapon( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
float CMonoFunctions::Pickup::GetAmount( DWORD pUserData )
|
||||
float CMonoFunctions::Pickup::GetAmount( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
float fAmount;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupAmount( RESOURCE->GetLua(), (void*)pUserData, fAmount ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupAmount( pResource->GetLua(), pElement->ToLuaUserData(), fAmount ) )
|
||||
{
|
||||
return fAmount;
|
||||
}
|
||||
@ -73,13 +89,17 @@ float CMonoFunctions::Pickup::GetAmount( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned short CMonoFunctions::Pickup::GetAmmo( DWORD pUserData )
|
||||
unsigned short CMonoFunctions::Pickup::GetAmmo( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned short usAmmo;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupAmmo( RESOURCE->GetLua(), (void*)pUserData, usAmmo ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupAmmo( pResource->GetLua(), pElement->ToLuaUserData(), usAmmo ) )
|
||||
{
|
||||
return usAmmo;
|
||||
}
|
||||
@ -88,13 +108,17 @@ unsigned short CMonoFunctions::Pickup::GetAmmo( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long CMonoFunctions::Pickup::GetRespawnInterval( DWORD pUserData )
|
||||
unsigned long CMonoFunctions::Pickup::GetRespawnInterval( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned long ulInterval;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetPickupRespawnInterval( pResource->GetLua(), pElement->ToLuaUserData(), ulInterval ) )
|
||||
{
|
||||
return ulInterval;
|
||||
}
|
||||
@ -103,13 +127,17 @@ unsigned long CMonoFunctions::Pickup::GetRespawnInterval( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Pickup::IsSpawned( DWORD pUserData )
|
||||
bool CMonoFunctions::Pickup::IsSpawned( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
bool bSpawned;
|
||||
|
||||
if( CLuaFunctionDefinitions::IsPickupSpawned( RESOURCE->GetLua(), (void*)pUserData, bSpawned ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::IsPickupSpawned( pResource->GetLua(), pElement->ToLuaUserData(), bSpawned ) )
|
||||
{
|
||||
return bSpawned;
|
||||
}
|
||||
@ -120,31 +148,44 @@ bool CMonoFunctions::Pickup::IsSpawned( DWORD pUserData )
|
||||
|
||||
|
||||
// Pickup set funcs
|
||||
bool CMonoFunctions::Pickup::SetType( DWORD pUserData, unsigned char ucType, double dThree, double dFour )
|
||||
bool CMonoFunctions::Pickup::SetType( TElement pThis, unsigned char ucType, double dThree, double dFour )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType, dThree, dFour );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetPickupType( pResource->GetLua(), pElement->ToLuaUserData(), ucType, dThree, dFour );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Pickup::SetRespawnInterval( DWORD pUserData, unsigned long ulInterval )
|
||||
bool CMonoFunctions::Pickup::SetRespawnInterval( TElement pThis, unsigned long ulInterval )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetPickupRespawnInterval( pResource->GetLua(), pElement->ToLuaUserData(), ulInterval );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Pickup::Use( DWORD pUserData, DWORD pPlayer )
|
||||
bool CMonoFunctions::Pickup::Use( TElement pThis, TElement pPlayer )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::UsePickup( RESOURCE->GetLua(), (void*)pUserData, (void*)pPlayer );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
CElement* pPlayerElement = pResource->GetElementManager()->GetFromList( pPlayer );
|
||||
|
||||
return CLuaFunctionDefinitions::UsePickup( pResource->GetLua(), pElement->ToLuaUserData(), pPlayerElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,65 +14,90 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Radar area create/destroy funcs
|
||||
DWORD CMonoFunctions::RadarArea::Create( MonoObject* pPosition, MonoObject* pSize, MonoObject* color, DWORD pVisibleTo )
|
||||
void CMonoFunctions::RadarArea::Ctor( TElement pThis, MonoObject* pPosition, MonoObject* pSize, MonoObject* color, TElement pVisibleTo )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector2 vecPosition ( pPosition );
|
||||
Vector2 vecSize ( pSize );
|
||||
SColor pColor = CMonoObject::GetColor( color );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateRadarArea( RESOURCE->GetLua(), vecPosition, vecSize, pColor, (void*)pVisibleTo );
|
||||
PVOID pElementVisibleTo = nullptr;
|
||||
|
||||
if( pVisibleTo )
|
||||
{
|
||||
pElementVisibleTo = pResource->GetElementManager()->GetFromList( pVisibleTo )->ToLuaUserData();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateRadarArea( pResource->GetLua(), vecPosition, vecSize, pColor, pElementVisibleTo );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Radar area get funcs
|
||||
MonoObject* CMonoFunctions::RadarArea::GetSize( DWORD pUserData )
|
||||
MonoObject* CMonoFunctions::RadarArea::GetSize( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector2 vecSize;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetRadarAreaSize( pResource->GetLua(), pElement->ToLuaUserData(), vecSize ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Vector2->New( vecSize );
|
||||
return pResource->GetDomain()->GetMTALib()->Vector2->New( vecSize );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoObject* CMonoFunctions::RadarArea::GetColor( DWORD pUserData )
|
||||
MonoObject* CMonoFunctions::RadarArea::GetColor( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor outColor;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetRadarAreaColor( pResource->GetLua(), pElement->ToLuaUserData(), outColor ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Color->New( outColor );
|
||||
return pResource->GetDomain()->GetMTALib()->Color->New( outColor );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::RadarArea::IsFlashing( DWORD pUserData )
|
||||
bool CMonoFunctions::RadarArea::IsFlashing( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::IsRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::IsRadarAreaFlashing( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::RadarArea::IsInside( DWORD pUserData, MonoObject* pPosition )
|
||||
bool CMonoFunctions::RadarArea::IsInside( TElement pThis, MonoObject* pPosition )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
bool bInside;
|
||||
|
||||
@ -81,7 +106,9 @@ bool CMonoFunctions::RadarArea::IsInside( DWORD pUserData, MonoObject* pPosition
|
||||
|
||||
Vector2 vecPosition( fX, fY );
|
||||
|
||||
if( CLuaFunctionDefinitions::IsInsideRadarArea( RESOURCE->GetLua(), (void*)pUserData, vecPosition, bInside ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::IsInsideRadarArea( pResource->GetLua(), pElement->ToLuaUserData(), vecPosition, bInside ) )
|
||||
{
|
||||
return bInside;
|
||||
}
|
||||
@ -92,38 +119,50 @@ bool CMonoFunctions::RadarArea::IsInside( DWORD pUserData, MonoObject* pPosition
|
||||
|
||||
|
||||
// Radar area set funcs
|
||||
bool CMonoFunctions::RadarArea::SetSize( DWORD pUserData, MonoObject* pSize )
|
||||
bool CMonoFunctions::RadarArea::SetSize( TElement pThis, MonoObject* pSize )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
float fX = CMonoObject::GetPropertyValue< float >( pSize, "X" );
|
||||
float fY = CMonoObject::GetPropertyValue< float >( pSize, "Y" );
|
||||
|
||||
Vector2 vecPosition( fX, fY );
|
||||
|
||||
return CLuaFunctionDefinitions::SetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecPosition );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetRadarAreaSize( pResource->GetLua(), pElement->ToLuaUserData(), vecPosition );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::RadarArea::SetColor( DWORD pUserData, MonoObject* color )
|
||||
bool CMonoFunctions::RadarArea::SetColor( TElement pThis, MonoObject* color )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor pColor = CMonoObject::GetColor( color );
|
||||
|
||||
return CLuaFunctionDefinitions::SetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetRadarAreaColor( pResource->GetLua(), pElement->ToLuaUserData(), pColor );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::RadarArea::SetFlashing( DWORD pUserData, bool bFlashing )
|
||||
bool CMonoFunctions::RadarArea::SetFlashing( TElement pThis, bool bFlashing )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData, bFlashing );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetRadarAreaFlashing( pResource->GetLua(), pElement->ToLuaUserData(), bFlashing );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -14,112 +14,171 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Resource funcs
|
||||
DWORD CMonoFunctions::Resource::Create( MonoString* msResourceName, MonoString* msOrganizationalDir )
|
||||
void CMonoFunctions::Resource::Ctor( TElement pThis, MonoString* msResourceName, MonoString* msOrganizationalDir )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szResourceName = mono_string_to_utf8( msResourceName );
|
||||
const char* szOrganizationalDir = mono_string_to_utf8( msOrganizationalDir );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateResource( RESOURCE->GetLua(), szResourceName, szOrganizationalDir );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateResource( pResource->GetLua(), szResourceName, szOrganizationalDir );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Resource::Copy( DWORD pResource, MonoString* msNewResourceName, MonoString* msOrganizationalDir )
|
||||
TElement CMonoFunctions::Resource::Copy( TElement pThis, MonoString* msNewResourceName, MonoString* msOrganizationalDir )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szResourceName = mono_string_to_utf8( msNewResourceName );
|
||||
const char* szOrganizationalDir = mono_string_to_utf8( msOrganizationalDir );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CopyResource( RESOURCE->GetLua(), (void*)pResource, szResourceName, szOrganizationalDir );
|
||||
}
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CopyResource( pResource->GetLua(), pElement->ToLuaUserData(), szResourceName, szOrganizationalDir );
|
||||
|
||||
DWORD CMonoFunctions::Resource::GetRootElement( DWORD pResource )
|
||||
if( pUserData )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
return (DWORD)CLuaFunctionDefinitions::GetResourceRootElement( RESOURCE->GetLua(), (void*)pResource );
|
||||
return pResource->GetElementManager()->Create( nullptr, pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Resource::GetMapRootElement( DWORD pResource, MonoString* msMap )
|
||||
TElement CMonoFunctions::Resource::GetRootElement( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetResourceRootElement( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
return pResource->GetElementManager()->Create( nullptr, pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TElement CMonoFunctions::Resource::GetMapRootElement( TElement pThis, MonoString* msMap )
|
||||
{
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szMap = mono_string_to_utf8( msMap );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::GetResourceMapRootElement( RESOURCE->GetLua(), (void*)pResource, szMap );
|
||||
}
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetResourceMapRootElement( pResource->GetLua(), pElement->ToLuaUserData(), szMap );
|
||||
|
||||
DWORD CMonoFunctions::Resource::GetDynamicElementRoot( DWORD pResource )
|
||||
if( pUserData )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
return (DWORD)CLuaFunctionDefinitions::GetResourceDynamicElementRoot( RESOURCE->GetLua(), (void*)pResource );
|
||||
return pResource->GetElementManager()->FindOrCreate( pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::RemoveFile( DWORD pResource, MonoString* msFilename )
|
||||
TElement CMonoFunctions::Resource::GetDynamicElementRoot( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetResourceDynamicElementRoot( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
return pResource->GetElementManager()->FindOrCreate( pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::RemoveFile( TElement pThis, MonoString* msFilename )
|
||||
{
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szFileName = mono_string_to_utf8( msFilename );
|
||||
|
||||
return CLuaFunctionDefinitions::RemoveResourceFile( RESOURCE->GetLua(), (void*)pResource, szFileName );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::RemoveResourceFile( pResource->GetLua(), pElement->ToLuaUserData(), szFileName );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Resource::GetFromName( MonoString* msResourceName )
|
||||
TElement CMonoFunctions::Resource::GetFromName( MonoString* msResourceName )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szResourceName = mono_string_to_utf8( msResourceName );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::GetResourceFromName( RESOURCE->GetLua(), szResourceName );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetResourceFromName( pResource->GetLua(), szResourceName );
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
return pResource->GetElementManager()->FindOrCreate( pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Resource::GetInfo( DWORD pResource, MonoString* msAttribute )
|
||||
MonoString* CMonoFunctions::Resource::GetInfo( TElement pThis, MonoString* msAttribute )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szAttribute = mono_string_to_utf8( msAttribute );
|
||||
|
||||
string strOutInfo;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceInfo( RESOURCE->GetLua(), (void*)pResource, szAttribute, strOutInfo ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceInfo( pResource->GetLua(), pElement->ToLuaUserData(), szAttribute, strOutInfo ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strOutInfo );
|
||||
return pResource->GetDomain()->NewString( strOutInfo );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned int CMonoFunctions::Resource::GetLastStartTime( DWORD pResource )
|
||||
unsigned int CMonoFunctions::Resource::GetLastStartTime( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned int uiTime;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceLastStartTime( RESOURCE->GetLua(), (void*)pResource, uiTime ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceLastStartTime( pResource->GetLua(), pElement->ToLuaUserData(), uiTime ) )
|
||||
{
|
||||
return uiTime;
|
||||
}
|
||||
@ -128,28 +187,36 @@ unsigned int CMonoFunctions::Resource::GetLastStartTime( DWORD pResource )
|
||||
return 0;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Resource::GetLoadFailureReason( DWORD pResource )
|
||||
MonoString* CMonoFunctions::Resource::GetLoadFailureReason( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strOutReason;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceLoadFailureReason( RESOURCE->GetLua(), (void*)pResource, strOutReason ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceLoadFailureReason( pResource->GetLua(), pElement->ToLuaUserData(), strOutReason ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strOutReason );
|
||||
return pResource->GetDomain()->NewString( strOutReason );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned int CMonoFunctions::Resource::GetLoadTime( DWORD pResource )
|
||||
unsigned int CMonoFunctions::Resource::GetLoadTime( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned int uiTime;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceLoadTime( RESOURCE->GetLua(), (void*)pResource, uiTime ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceLoadTime( pResource->GetLua(), pElement->ToLuaUserData(), uiTime ) )
|
||||
{
|
||||
return uiTime;
|
||||
}
|
||||
@ -158,134 +225,177 @@ unsigned int CMonoFunctions::Resource::GetLoadTime( DWORD pResource )
|
||||
return 0;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Resource::GetName( DWORD pResource )
|
||||
MonoString* CMonoFunctions::Resource::GetName( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strOut;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceName( RESOURCE->GetLua(), (void*)pResource, strOut ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceName( pResource->GetLua(), pElement->ToLuaUserData(), strOut ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strOut );
|
||||
return pResource->GetDomain()->NewString( strOut );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoArray* CMonoFunctions::Resource::GetResources( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
CLuaArgumentsVector pLuaTable = CLuaFunctionDefinitions::GetResources( RESOURCE->GetLua() );
|
||||
CLuaArgumentsVector pLuaTable = CLuaFunctionDefinitions::GetResources( pResource->GetLua() );
|
||||
|
||||
if( pLuaTable.size() > 0 )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewArray<DWORD, LUA_TLIGHTUSERDATA>( mono_get_uint32_class(), &pLuaTable );
|
||||
return pResource->GetDomain()->NewElementArray( pResource->GetDomain()->GetMTALib()->GetClass( "Resource" )->GetMonoPtr(), pLuaTable );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Resource::GetState( DWORD pResource )
|
||||
MonoString* CMonoFunctions::Resource::GetState( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strOut;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceState( RESOURCE->GetLua(), (void*)pResource, strOut ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetResourceState( pResource->GetLua(), pElement->ToLuaUserData(), strOut ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strOut );
|
||||
return pResource->GetDomain()->NewString( strOut );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Resource::GetCurrent( void )
|
||||
TElement CMonoFunctions::Resource::GetCurrent( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return (DWORD)CLuaFunctionDefinitions::GetThisResource( RESOURCE->GetLua() );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetThisResource( pResource->GetLua() );
|
||||
|
||||
if( pUserData )
|
||||
{
|
||||
return pResource->GetElementManager()->FindOrCreate( pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::Refresh( bool refreshAll )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::RefreshResources( RESOURCE->GetLua(), refreshAll );
|
||||
return CLuaFunctionDefinitions::RefreshResources( pResource->GetLua(), refreshAll );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::RemoveDefaultSetting( DWORD pResource, MonoString* msSettingName )
|
||||
bool CMonoFunctions::Resource::RemoveDefaultSetting( TElement pThis, MonoString* msSettingName )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szSettingName = mono_string_to_utf8( msSettingName );
|
||||
|
||||
return CLuaFunctionDefinitions::RemoveResourceDefaultSetting( RESOURCE->GetLua(), (void*)pResource, szSettingName );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::RemoveResourceDefaultSetting( pResource->GetLua(), pElement->ToLuaUserData(), szSettingName );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::Start( DWORD pResource, bool persistent, bool startIncludedResources, bool loadServerConfigs, bool loadMaps, bool loadServerScripts, bool loadHTML, bool loadClientConfigs, bool loadClientScripts, bool loadFiles )
|
||||
bool CMonoFunctions::Resource::Start( TElement pThis, bool persistent, bool startIncludedResources, bool loadServerConfigs, bool loadMaps, bool loadServerScripts, bool loadHTML, bool loadClientConfigs, bool loadClientScripts, bool loadFiles )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::StartResource( RESOURCE->GetLua(), (void*)pResource, persistent, startIncludedResources, loadServerConfigs, loadMaps, loadServerScripts, loadHTML, loadClientConfigs, loadClientScripts, loadFiles );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::StartResource( pResource->GetLua(), pElement->ToLuaUserData(), persistent, startIncludedResources, loadServerConfigs, loadMaps, loadServerScripts, loadHTML, loadClientConfigs, loadClientScripts, loadFiles );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::Restart( DWORD pResource )
|
||||
bool CMonoFunctions::Resource::Restart( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::RestartResource( RESOURCE->GetLua(), (void*)pResource );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::RestartResource( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::Stop( DWORD pResource )
|
||||
bool CMonoFunctions::Resource::Stop( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::StopResource( RESOURCE->GetLua(), (void*)pResource );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::StopResource( pResource->GetLua(), pElement->ToLuaUserData() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::SetDefaultSetting( DWORD pResource, MonoString* msSettingName, MonoString* msSettingValue )
|
||||
bool CMonoFunctions::Resource::SetDefaultSetting( TElement pThis, MonoString* msSettingName, MonoString* msSettingValue )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szSettingName = mono_string_to_utf8( msSettingName );
|
||||
const char* szSettingValue = mono_string_to_utf8( msSettingValue );
|
||||
|
||||
return CLuaFunctionDefinitions::SetResourceDefaultSetting( RESOURCE->GetLua(), (void*)pResource, szSettingName, szSettingValue );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetResourceDefaultSetting( pResource->GetLua(), pElement->ToLuaUserData(), szSettingName, szSettingValue );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::SetInfo( DWORD pResource, MonoString* msAttribute, MonoString* msValue )
|
||||
bool CMonoFunctions::Resource::SetInfo( TElement pThis, MonoString* msAttribute, MonoString* msValue )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szAttribute = mono_string_to_utf8( msAttribute );
|
||||
const char* szValue = mono_string_to_utf8( msValue );
|
||||
|
||||
return CLuaFunctionDefinitions::SetResourceInfo( RESOURCE->GetLua(), (void*)pResource, szAttribute, szValue );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetResourceInfo( pResource->GetLua(), pElement->ToLuaUserData(), szAttribute, szValue );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -293,13 +403,15 @@ bool CMonoFunctions::Resource::SetInfo( DWORD pResource, MonoString* msAttribute
|
||||
|
||||
bool CMonoFunctions::Resource::Rename( MonoString* msResourceName, MonoString* msNewResourceName, MonoString* msOrganizationalPath )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szResourceName = mono_string_to_utf8( msResourceName );
|
||||
const char* szNewResourceName = mono_string_to_utf8( msNewResourceName );
|
||||
const char* szOrganizationalPath = mono_string_to_utf8( msOrganizationalPath );
|
||||
|
||||
return CLuaFunctionDefinitions::RenameResource( RESOURCE->GetLua(), szResourceName, szNewResourceName, szOrganizationalPath );
|
||||
return CLuaFunctionDefinitions::RenameResource( pResource->GetLua(), szResourceName, szNewResourceName, szOrganizationalPath );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -307,24 +419,30 @@ bool CMonoFunctions::Resource::Rename( MonoString* msResourceName, MonoString* m
|
||||
|
||||
bool CMonoFunctions::Resource::Delete( MonoString* msResourceName )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szResourceName = mono_string_to_utf8( msResourceName );
|
||||
|
||||
return CLuaFunctionDefinitions::DeleteResource( RESOURCE->GetLua(), szResourceName );
|
||||
return CLuaFunctionDefinitions::DeleteResource( pResource->GetLua(), szResourceName );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Resource::UpdateACLRequest( DWORD pResource, MonoString* msRightName, bool bAccess, MonoString* msByWho )
|
||||
bool CMonoFunctions::Resource::UpdateACLRequest( TElement pThis, MonoString* msRightName, bool bAccess, MonoString* msByWho )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szRightName = mono_string_to_utf8( msRightName );
|
||||
const char* szByWho = mono_string_to_utf8( msByWho );
|
||||
|
||||
return CLuaFunctionDefinitions::UpdateResourceACLRequest( RESOURCE->GetLua(), (void*)pResource, szRightName, bAccess, szByWho );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::UpdateResourceACLRequest( pResource->GetLua(), pElement->ToLuaUserData(), szRightName, bAccess, szByWho );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -13,67 +13,84 @@
|
||||
#include "StdInc.h"
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Shape create funcs
|
||||
DWORD CMonoFunctions::Shape::CreateCircle( MonoObject* pPosition, float fRadius )
|
||||
void CMonoFunctions::ColCircle::Ctor( TElement pThis, MonoObject* pPosition, float fRadius )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector2 vecPosition( pPosition );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateColCircle( RESOURCE->GetLua(), vecPosition, fRadius );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateColCircle( pResource->GetLua(), vecPosition, fRadius );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Shape::CreateCuboid( MonoObject* pPosition, MonoObject* pSize )
|
||||
void CMonoFunctions::ColCuboid::Ctor( TElement pThis, MonoObject* pPosition, MonoObject* pSize )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( pPosition );
|
||||
Vector3 vecSize( pSize );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateColCuboid( RESOURCE->GetLua(), vecPosition, vecSize );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateColCuboid( pResource->GetLua(), vecPosition, vecSize );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Shape::CreateSphere( MonoObject* pPosition, float fRadius )
|
||||
void CMonoFunctions::ColSphere::Ctor( TElement pThis, MonoObject* pPosition, float fRadius )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( pPosition );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateColSphere( RESOURCE->GetLua(), vecPosition, fRadius );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateColSphere( pResource->GetLua(), vecPosition, fRadius );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Shape::CreateRectangle( MonoObject* pPosition, MonoObject* pSize )
|
||||
void CMonoFunctions::ColRectangle::Ctor( TElement pThis, MonoObject* pPosition, MonoObject* pSize )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector2 vecPosition( pPosition );
|
||||
Vector2 vecSize( pSize );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateColRectangle( RESOURCE->GetLua(), vecPosition, vecSize );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateColRectangle( pResource->GetLua(), vecPosition, vecSize );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Shape::CreatePolygon( float fX, float fY, float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, MonoArray* pPointList )
|
||||
void CMonoFunctions::ColPolygon::Ctor( TElement pThis, MonoObject* vec1, MonoObject* vec2, MonoObject* vec3, MonoObject* vec4, MonoArray* pPointList )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
vector< Vector2 > vecPointList;
|
||||
|
||||
vecPointList.push_back( Vector2( fX, fY ) );
|
||||
vecPointList.push_back( Vector2( fX1, fY1 ) );
|
||||
vecPointList.push_back( Vector2( fX2, fY2 ) );
|
||||
vecPointList.push_back( Vector2( fX3, fY3 ) );
|
||||
vecPointList.push_back( Vector2( vec1 ) );
|
||||
vecPointList.push_back( Vector2( vec2 ) );
|
||||
vecPointList.push_back( Vector2( vec3 ) );
|
||||
vecPointList.push_back( Vector2( vec4 ) );
|
||||
|
||||
for( unsigned int i = 0; i < mono_array_length( pPointList ); i++ )
|
||||
{
|
||||
@ -85,20 +102,26 @@ DWORD CMonoFunctions::Shape::CreatePolygon( float fX, float fY, float fX1, float
|
||||
}
|
||||
}
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateColPolygon( RESOURCE->GetLua(), vecPointList );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateColPolygon( pResource->GetLua(), vecPointList );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Shape::CreateTube( MonoObject* pPosition, float fRadius, float fHeight )
|
||||
void CMonoFunctions::ColTube::Ctor( TElement pThis, MonoObject* pPosition, float fRadius, float fHeight )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( pPosition );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateColTube( RESOURCE->GetLua(), vecPosition, fRadius, fHeight );
|
||||
}
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateColTube( pResource->GetLua(), vecPosition, fRadius, fHeight );
|
||||
|
||||
return NULL;
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
@ -14,68 +14,91 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Team get funcs
|
||||
DWORD CMonoFunctions::Team::Create( MonoString* msTeamName, MonoObject* mColor )
|
||||
void CMonoFunctions::Team::Ctor( TElement pThis, MonoString* msTeamName, MonoObject* mColor )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szTeamName = mono_string_to_utf8( msTeamName );
|
||||
SColor pColor = CMonoObject::GetColor( mColor );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateTeam( RESOURCE->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateTeam( pResource->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DWORD CMonoFunctions::Team::GetFromName( MonoString* msTeamName )
|
||||
TElement CMonoFunctions::Team::GetFromName( MonoString* msTeamName )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szTeamName = mono_string_to_utf8( msTeamName );
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::GetTeamFromName( RESOURCE->GetLua(), szTeamName );
|
||||
}
|
||||
PVOID pUserData = CLuaFunctionDefinitions::GetTeamFromName( pResource->GetLua(), szTeamName );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Team::GetName( DWORD pUserData )
|
||||
if( pUserData )
|
||||
{
|
||||
if( RESOURCE )
|
||||
return pResource->GetElementManager()->FindOrCreate( pUserData )->ToMonoObject();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoString* CMonoFunctions::Team::GetName( TElement pThis )
|
||||
{
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
string strOutName;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetTeamName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetTeamName( pResource->GetLua(), pElement->ToLuaUserData(), strOutName ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->NewString( strOutName );
|
||||
return pResource->GetDomain()->NewString( strOutName );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MonoObject* CMonoFunctions::Team::GetColor( DWORD pUserData )
|
||||
MonoObject* CMonoFunctions::Team::GetColor( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor pColor;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetTeamColor( pResource->GetLua(), pElement->ToLuaUserData(), pColor.R, pColor.G, pColor.B ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Color->New( pColor );
|
||||
return pResource->GetDomain()->GetMTALib()->Color->New( pColor );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
unsigned int CMonoFunctions::Team::CountPlayers( DWORD pUserData )
|
||||
unsigned int CMonoFunctions::Team::CountPlayers( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
unsigned int uiCount;
|
||||
|
||||
if( CLuaFunctionDefinitions::CountPlayersInTeam( RESOURCE->GetLua(), (void*)pUserData, uiCount ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::CountPlayersInTeam( pResource->GetLua(), pElement->ToLuaUserData(), uiCount ) )
|
||||
{
|
||||
return uiCount;
|
||||
}
|
||||
@ -84,13 +107,17 @@ unsigned int CMonoFunctions::Team::CountPlayers( DWORD pUserData )
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Team::GetFriendlyFire( DWORD pUserData )
|
||||
bool CMonoFunctions::Team::GetFriendlyFire( TElement pThis )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
bool bFriendlyFire;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetTeamFriendlyFire( pResource->GetLua(), pElement->ToLuaUserData(), bFriendlyFire ) )
|
||||
{
|
||||
return bFriendlyFire;
|
||||
}
|
||||
@ -101,35 +128,47 @@ bool CMonoFunctions::Team::GetFriendlyFire( DWORD pUserData )
|
||||
|
||||
|
||||
// Team set funcs
|
||||
bool CMonoFunctions::Team::SetName( DWORD pUserData, MonoString* msTeamName )
|
||||
bool CMonoFunctions::Team::SetName( TElement pThis, MonoString* msTeamName )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
const char* szTeamName = mono_string_to_utf8( msTeamName );
|
||||
|
||||
return CLuaFunctionDefinitions::SetTeamName( RESOURCE->GetLua(), (void*)pUserData, szTeamName );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetTeamName( pResource->GetLua(), pElement->ToLuaUserData(), szTeamName );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Team::SetColor( DWORD pUserData, MonoObject* mColor )
|
||||
bool CMonoFunctions::Team::SetColor( TElement pThis, MonoObject* mColor )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor pColor = CMonoObject::GetColor( mColor );
|
||||
|
||||
return CLuaFunctionDefinitions::SetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetTeamColor( pResource->GetLua(), pElement->ToLuaUserData(), pColor.R, pColor.G, pColor.B );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Team::SetFriendlyFire( DWORD pUserData, bool bFriendlyFire )
|
||||
bool CMonoFunctions::Team::SetFriendlyFire( TElement pThis, bool bFriendlyFire )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetTeamFriendlyFire( pResource->GetLua(), pElement->ToLuaUserData(), bFriendlyFire );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,26 +14,34 @@
|
||||
#include "CMonoFunctions.h"
|
||||
|
||||
// Water funcs
|
||||
DWORD CMonoFunctions::Water::Create( MonoObject* pV1, MonoObject* pV2, MonoObject* pV3, MonoObject* pV4, bool bShallow )
|
||||
void CMonoFunctions::Water::Ctor( TElement pThis, MonoObject* pV1, MonoObject* pV2, MonoObject* pV3, MonoObject* pV4, bool bShallow )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vec1( pV1 );
|
||||
Vector3 vec2( pV2 );
|
||||
Vector3 vec3( pV3 );
|
||||
Vector3 vec4 = pV4 ? Vector3( pV4 ) : NULL;
|
||||
Vector3 vec4 = pV4 ? Vector3( pV4 ) : nullptr;
|
||||
|
||||
return (DWORD)CLuaFunctionDefinitions::CreateWater( RESOURCE->GetLua(), &vec1, &vec2, &vec3, &vec4, bShallow );
|
||||
PVOID pUserData = CLuaFunctionDefinitions::CreateWater( pResource->GetLua(), &vec1, &vec2, &vec3, &vec4, bShallow );
|
||||
|
||||
ASSERT( pUserData );
|
||||
|
||||
pResource->GetElementManager()->Create( pThis, pUserData );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
bool CMonoFunctions::Water::SetLevel( TElement pThis, float fLevel )
|
||||
{
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
bool CMonoFunctions::Water::SetLevel( DWORD pUserData, float fLevel )
|
||||
if( pResource )
|
||||
{
|
||||
if( RESOURCE )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetElementWaterLevel( RESOURCE->GetLua(), (void*)pUserData, fLevel );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetElementWaterLevel( pResource->GetLua(), pElement->ToLuaUserData(), fLevel );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -41,9 +49,11 @@ bool CMonoFunctions::Water::SetLevel( DWORD pUserData, float fLevel )
|
||||
|
||||
bool CMonoFunctions::Water::SetLevelAll( float fLevel )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetAllElementWaterLevel( RESOURCE->GetLua(), fLevel );
|
||||
return CLuaFunctionDefinitions::SetAllElementWaterLevel( pResource->GetLua(), fLevel );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -51,9 +61,11 @@ bool CMonoFunctions::Water::SetLevelAll( float fLevel )
|
||||
|
||||
bool CMonoFunctions::Water::SetLevelWorld( float fLevel, bool bIncludeWorldNonSeaLevel )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::SetWorldWaterLevel( RESOURCE->GetLua(), fLevel, bIncludeWorldNonSeaLevel );
|
||||
return CLuaFunctionDefinitions::SetWorldWaterLevel( pResource->GetLua(), fLevel, bIncludeWorldNonSeaLevel );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -61,36 +73,46 @@ bool CMonoFunctions::Water::SetLevelWorld( float fLevel, bool bIncludeWorldNonSe
|
||||
|
||||
bool CMonoFunctions::Water::ResetLevelWorld( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::ResetWorldWaterLevel( RESOURCE->GetLua() );
|
||||
return CLuaFunctionDefinitions::ResetWorldWaterLevel( pResource->GetLua() );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
MonoObject* CMonoFunctions::Water::GetVertexPosition( DWORD pUserData, int iVertexIndex )
|
||||
MonoObject* CMonoFunctions::Water::GetVertexPosition( TElement pThis, int iVertexIndex )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) )
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
if( CLuaFunctionDefinitions::GetWaterVertexPosition( pResource->GetLua(), pElement->ToLuaUserData(), iVertexIndex, vecPosition ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
|
||||
return pResource->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Water::SetVertexPosition( DWORD pUserData, int iVertexIndex, MonoObject* mPosition )
|
||||
bool CMonoFunctions::Water::SetVertexPosition( TElement pThis, int iVertexIndex, MonoObject* mPosition )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
Vector3 vecPosition( mPosition );
|
||||
|
||||
return CLuaFunctionDefinitions::SetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pThis );
|
||||
|
||||
return CLuaFunctionDefinitions::SetWaterVertexPosition( pResource->GetLua(), pElement->ToLuaUserData(), iVertexIndex, vecPosition );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -98,26 +120,30 @@ bool CMonoFunctions::Water::SetVertexPosition( DWORD pUserData, int iVertexIndex
|
||||
|
||||
MonoObject* CMonoFunctions::Water::GetColor( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor pColor;
|
||||
|
||||
if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) )
|
||||
if( CLuaFunctionDefinitions::GetWaterColor( pResource->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) )
|
||||
{
|
||||
return RESOURCE->GetDomain()->GetMTALib()->Color->New( pColor );
|
||||
return pResource->GetDomain()->GetMTALib()->Color->New( pColor );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool CMonoFunctions::Water::SetColor( MonoObject* mColor )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
SColor pColor = CMonoObject::GetColor( mColor );
|
||||
|
||||
return CLuaFunctionDefinitions::SetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A );
|
||||
return CLuaFunctionDefinitions::SetWaterColor( pResource->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A );
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -125,9 +151,11 @@ bool CMonoFunctions::Water::SetColor( MonoObject* mColor )
|
||||
|
||||
bool CMonoFunctions::Water::ResetColor( void )
|
||||
{
|
||||
if( RESOURCE )
|
||||
CResource* pResource = g_pModule->GetResourceManager()->GetFromList( mono_domain_get() );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
return CLuaFunctionDefinitions::ResetWaterColor( RESOURCE->GetLua() );
|
||||
return CLuaFunctionDefinitions::ResetWaterColor( pResource->GetLua() );
|
||||
}
|
||||
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,8 +16,10 @@
|
||||
|
||||
MonoAssembly* CMonoInterface::m_pMTALib = nullptr;
|
||||
|
||||
CMonoInterface::CMonoInterface( void )
|
||||
CMonoInterface::CMonoInterface( CModule* pModule )
|
||||
{
|
||||
this->m_pModule = pModule;
|
||||
|
||||
mono_set_dirs( "mods/deathmatch/mono/lib", "mods/deathmatch/mono/etc" );
|
||||
|
||||
mono_set_signal_chaining( false );
|
||||
@ -25,7 +27,7 @@ CMonoInterface::CMonoInterface( void )
|
||||
mono_debug_init( MONO_DEBUG_FORMAT_MONO );
|
||||
|
||||
#if _DEBUG
|
||||
mono_trace_set_level_string( "debug" );
|
||||
//mono_trace_set_level_string( "debug" );
|
||||
#else
|
||||
mono_trace_set_level_string( "critical" );
|
||||
#endif
|
||||
@ -47,6 +49,8 @@ CMonoInterface::~CMonoInterface( void )
|
||||
mono_jit_cleanup( this->m_pMonoDomain );
|
||||
|
||||
SAFE_DELETE( this->m_pGC );
|
||||
|
||||
this->m_pModule = nullptr;
|
||||
}
|
||||
|
||||
CMonoDomain* CMonoInterface::CreateAppdomain( CResource* pResource, const char* szName, char* szConfig )
|
||||
@ -66,7 +70,7 @@ void CMonoInterface::SetDomain( MonoDomain* pDomain, bool bForce )
|
||||
mono_domain_set( pDomain != nullptr ? pDomain : this->m_pMonoDomain, bForce );
|
||||
}
|
||||
|
||||
CLuaArguments CMonoInterface::MonoArrayToLuaArguments( MonoArray* pArray )
|
||||
CLuaArguments CMonoInterface::MonoArrayToLuaArguments( MonoArray* pArray, CResource* pResource )
|
||||
{
|
||||
CLuaArguments pLuaArguments;
|
||||
|
||||
@ -209,7 +213,9 @@ CLuaArguments CMonoInterface::MonoArrayToLuaArguments( MonoArray* pArray )
|
||||
case MONO_TYPE_OBJECT: // System.Object
|
||||
case MONO_TYPE_CLASS:
|
||||
{
|
||||
void* pValue = CMonoObject::GetPropertyValue<void*>( pObj, "userdata" );
|
||||
CElement* pElement = pResource->GetElementManager()->GetFromList( pObj );
|
||||
|
||||
PVOID pValue = pElement->ToLuaUserData();
|
||||
|
||||
if( pValue )
|
||||
{
|
||||
@ -224,7 +230,9 @@ CLuaArguments CMonoInterface::MonoArrayToLuaArguments( MonoArray* pArray )
|
||||
case MONO_TYPE_U:
|
||||
default:
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Unsupported type: %s (0x%i)\n", pType ? mono_type_get_name( pType ) : "(unknown type)", iType );
|
||||
ASSERT( g_pModule );
|
||||
|
||||
g_pModule->ErrorPrintf( "Unsupported type: %s (0x%i)\n", pType ? mono_type_get_name( pType ) : "(unknown type)", iType );
|
||||
|
||||
break;
|
||||
}
|
||||
@ -244,10 +252,14 @@ MonoAssembly* CMonoInterface::GetMTALib( void )
|
||||
|
||||
void CMonoInterface::MonoPrintCallbackHandler( const char *string, mono_bool is_stdout )
|
||||
{
|
||||
g_pModuleManager->Printf( string );
|
||||
ASSERT( g_pModule );
|
||||
|
||||
g_pModule->Printf( string );
|
||||
}
|
||||
|
||||
void CMonoInterface::MonoPrintErrorCallbackHandler( const char *string, mono_bool is_stdout )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( string );
|
||||
ASSERT( g_pModule );
|
||||
|
||||
g_pModule->ErrorPrintf( string );
|
||||
}
|
||||
|
@ -15,39 +15,39 @@ class CMonoInterface;
|
||||
#ifndef __CMONOINTERFACE_H
|
||||
#define __CMONOINTERFACE_H
|
||||
|
||||
#include "CModule.h"
|
||||
#include "CMonoGC.h"
|
||||
#include "CMonoDomain.h"
|
||||
#include "CResource.h"
|
||||
|
||||
#include "extra/CLuaArguments.h"
|
||||
|
||||
extern CModule* g_pModule;
|
||||
|
||||
class CMonoInterface
|
||||
{
|
||||
private:
|
||||
CModule* m_pModule;
|
||||
MonoDomain* m_pMonoDomain;
|
||||
|
||||
CMonoGC* m_pGC;
|
||||
|
||||
static MonoAssembly* m_pMTALib;
|
||||
|
||||
public:
|
||||
CMonoInterface ( void );
|
||||
CMonoInterface ( CModule* pModule );
|
||||
~CMonoInterface ( void );
|
||||
|
||||
CMonoDomain* CreateAppdomain ( CResource* pResource, const char* szName, char* szConfig );
|
||||
|
||||
void SetDomain ( MonoDomain* pDomain = nullptr, bool bForce = false );
|
||||
|
||||
CMonoGC* GetGC ( void ) { return this->m_pGC; }
|
||||
inline CMonoGC* GetGC ( void ) { return this->m_pGC; }
|
||||
|
||||
static string GetBinariesDirectory( void )
|
||||
{
|
||||
return "mods/deathmatch/resources/[ire]";
|
||||
}
|
||||
inline static string GetBinariesDirectory ( void ) { return "mods/deathmatch/resources/[ire]"; }
|
||||
|
||||
static MonoAssembly* GetMTALib ( void );
|
||||
|
||||
static CLuaArguments MonoArrayToLuaArguments( MonoArray* pArray );
|
||||
static CLuaArguments MonoArrayToLuaArguments ( MonoArray* pArray, CResource* pResource );
|
||||
|
||||
static void MonoPrintCallbackHandler ( const char *string, mono_bool is_stdout );
|
||||
static void MonoPrintErrorCallbackHandler ( const char *string, mono_bool is_stdout );
|
||||
|
@ -15,32 +15,16 @@
|
||||
|
||||
CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
|
||||
{
|
||||
this->m_pClass = nullptr;
|
||||
this->m_pObject = nullptr;
|
||||
|
||||
this->m_pAssembly = nullptr;
|
||||
this->m_pImage = nullptr;
|
||||
this->m_pDomain = pDomain;
|
||||
|
||||
this->m_pAssembly = CMonoInterface::GetMTALib();
|
||||
|
||||
if( this->m_pAssembly )
|
||||
{
|
||||
this->m_pImage = mono_assembly_get_image( this->m_pAssembly );
|
||||
this->m_pImage = mono_assembly_get_image( CMonoInterface::GetMTALib() );
|
||||
|
||||
if( this->m_pImage )
|
||||
{
|
||||
this->Color = this->GetClass( "Color" );
|
||||
this->Vector2 = this->GetClass( "Vector2" );
|
||||
this->Vector3 = this->GetClass( "Vector3" );
|
||||
|
||||
this->m_pClass = this->GetClass( "MultiTheftAuto" );
|
||||
|
||||
if( this->m_pClass )
|
||||
{
|
||||
this->m_pObject = this->m_pClass->New();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,12 +33,9 @@ CMonoMTALib::~CMonoMTALib( void )
|
||||
this->Color = nullptr;
|
||||
this->Vector2 = nullptr;
|
||||
this->Vector3 = nullptr;
|
||||
this->m_pClass = nullptr;
|
||||
|
||||
this->m_pDomain = nullptr;
|
||||
this->m_pAssembly = nullptr;
|
||||
this->m_pImage = nullptr;
|
||||
this->m_pObject = nullptr;
|
||||
}
|
||||
|
||||
CMonoClass* CMonoMTALib::GetClass( const char* szName )
|
||||
@ -70,72 +51,3 @@ CMonoClass* CMonoMTALib::GetClass( const char* szNameSpace, const char* szName )
|
||||
|
||||
return this->GetDomain()->FindOrAdd( mono_class_from_name( this->m_pImage, szBuffer, szName ) );
|
||||
}
|
||||
|
||||
string CMonoMTALib::GetElementType( void* pUseData )
|
||||
{
|
||||
CResource* pResource = this->GetDomain()->GetResource();
|
||||
|
||||
assert( pResource );
|
||||
|
||||
string strTypeName;
|
||||
|
||||
if( CLuaFunctionDefinitions::IsElement( pResource->GetLua(), pUseData ) )
|
||||
{
|
||||
strTypeName = CLuaFunctionDefinitions::GetElementType( pResource->GetLua(), pUseData );
|
||||
|
||||
strTypeName[ 0 ] = toupper( strTypeName[ 0 ] );
|
||||
|
||||
if( strTypeName == "Root" )
|
||||
{
|
||||
strTypeName = "Element";
|
||||
}
|
||||
}
|
||||
|
||||
return strTypeName;
|
||||
}
|
||||
|
||||
MonoObject* CMonoMTALib::RegisterElement( void* pUseData )
|
||||
{
|
||||
string strType = this->GetElementType( pUseData );
|
||||
|
||||
if( strType.length() == 0 )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CMonoClass* pClass = this->GetClass( strType.c_str() );
|
||||
|
||||
if( !pClass )
|
||||
{
|
||||
this->GetDomain()->GetResource()->ErrorPrintf( "[mono] Could not find the 'MultiTheftAuto.%s' class\n", strType.c_str() );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CMonoMethod* pMethod = pClass->GetMethod( "Find", 0 );
|
||||
|
||||
if( !pMethod )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *Args[] = { &pUseData };
|
||||
|
||||
MonoObject* pException = nullptr;
|
||||
|
||||
MonoObject* pObject = pMethod->Invoke( nullptr, Args, pException );
|
||||
|
||||
if( pException )
|
||||
{
|
||||
this->GetDomain()->GetResource()->ErrorPrintf( "%s\n", mono_string_to_utf8( mono_object_to_string( pException, nullptr ) ) );
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if( !pObject )
|
||||
{
|
||||
pObject = pClass->New( Args, 1 );
|
||||
}
|
||||
|
||||
return pObject;
|
||||
}
|
@ -21,10 +21,7 @@ class CMonoMTALib;
|
||||
class CMonoMTALib
|
||||
{
|
||||
private:
|
||||
MonoAssembly* m_pAssembly;
|
||||
MonoImage* m_pImage;
|
||||
MonoObject* m_pObject;
|
||||
CMonoClass* m_pClass;
|
||||
CMonoDomain* m_pDomain;
|
||||
|
||||
public:
|
||||
@ -39,10 +36,6 @@ public:
|
||||
CMonoClass* GetClass ( const char* szName );
|
||||
CMonoClass* GetClass ( const char* szNameSpace, const char* szName );
|
||||
|
||||
string GetElementType ( void* pUserData );
|
||||
|
||||
MonoObject* RegisterElement ( void* pUserData );
|
||||
|
||||
CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ void CMonoMethod::ParseSignature( void )
|
||||
}
|
||||
}
|
||||
|
||||
MonoObject* CMonoMethod::Invoke( void* pObject, void** params, MonoObject* pException )
|
||||
MonoObject* CMonoMethod::Invoke( PVOID pObject, PVOID* params, MonoObject** pException )
|
||||
{
|
||||
return mono_runtime_invoke( this->m_pMethod, pObject, params, &pException );
|
||||
return mono_runtime_invoke( this->m_pMethod, pObject, params, pException );
|
||||
}
|
@ -44,7 +44,7 @@ public:
|
||||
CMonoMethod ( CMonoClass* pClass, MonoMethod* pMethod );
|
||||
~CMonoMethod ( void );
|
||||
|
||||
MonoObject* Invoke ( void* pObject, void** params, MonoObject* pException );
|
||||
MonoObject* Invoke ( PVOID pObject, PVOID* params, MonoObject** pException );
|
||||
|
||||
string GetSignature ( void ) { return this->m_strSignature; }
|
||||
vector< SMonoType > GetArguments ( void ) { return this->m_ArgList; }
|
||||
|
@ -41,20 +41,37 @@ public:
|
||||
return pColor;
|
||||
}
|
||||
|
||||
template <class T> static T GetPropertyValue( MonoObject* pMonoObject, const char* szPropertyName )
|
||||
template< class T >
|
||||
static T GetPropertyValue( MonoObject* pMonoObject, const char* szPropertyName )
|
||||
{
|
||||
return *( reinterpret_cast<T*>( mono_object_unbox( GetPropertyValue( pMonoObject, szPropertyName ) ) ) );
|
||||
}
|
||||
|
||||
static void* GetValue( MonoObject* pMonoObject )
|
||||
static PVOID GetValue( MonoObject* pMonoObject )
|
||||
{
|
||||
return mono_object_unbox( pMonoObject );
|
||||
}
|
||||
|
||||
template <class T> static T GetValue( MonoObject* pMonoObject )
|
||||
template< class T >
|
||||
static T GetValue( MonoObject* pMonoObject )
|
||||
{
|
||||
return *( reinterpret_cast< T* >( mono_object_unbox( pMonoObject ) ) );
|
||||
}
|
||||
|
||||
inline static char* ToString( MonoObject* pMonoObject )
|
||||
{
|
||||
MonoClass* pClass = mono_object_get_class( pMonoObject );
|
||||
|
||||
ASSERT( pClass );
|
||||
|
||||
MonoMethod* pMethod = mono_class_get_method_from_name( pClass, "ToString", 0 );
|
||||
|
||||
ASSERT( pMethod );
|
||||
|
||||
MonoString* pString = (MonoString*)mono_runtime_invoke( pMethod, pMonoObject, nullptr, nullptr );
|
||||
|
||||
return mono_string_to_utf8( pString );
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
@ -46,13 +46,13 @@ bool CRegisteredCommands::Add( string strCommandName, MonoObject* pDelegate, boo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CRegisteredCommands::Execute( void* pPlayer, string strCommandName, list< string > argv )
|
||||
bool CRegisteredCommands::Execute( CElement* pPlayer, string strCommandName, list< string > argv )
|
||||
{
|
||||
bool bHandled = false;
|
||||
|
||||
int iCompareResult;
|
||||
|
||||
for( CRegisteredCommands::SCommand* pCommand : this->m_Commands )
|
||||
for( const auto& pCommand : this->m_Commands )
|
||||
{
|
||||
if( pCommand->bCaseSensitive )
|
||||
{
|
||||
@ -151,7 +151,7 @@ CRegisteredCommands::SCommand* CRegisteredCommands::GetCommand( string strName )
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CRegisteredCommands::Invoke( void* pUserData, MonoObject* pDelegate, string strCommandName, list< string > argv )
|
||||
void CRegisteredCommands::Invoke( CElement* pPlayer, MonoObject* pDelegate, const string& strCommandName, list< string > argv )
|
||||
{
|
||||
CMonoMTALib* pMTALib = this->m_pResource->GetDomain()->GetMTALib();
|
||||
CMonoCorlib* pCorlib = this->m_pResource->GetDomain()->GetCorlib();
|
||||
@ -159,26 +159,19 @@ void CRegisteredCommands::Invoke( void* pUserData, MonoObject* pDelegate, string
|
||||
assert( pMTALib );
|
||||
assert( pCorlib );
|
||||
|
||||
MonoObject* pPlayer = pMTALib->RegisterElement( pUserData );
|
||||
|
||||
if( !pPlayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MonoString* pCommandName = this->m_pResource->GetDomain()->NewString( strCommandName );
|
||||
MonoArray* pArguments = mono_array_new( this->m_pResource->GetDomain()->GetMonoPtr(), pCorlib->Class[ "string" ]->GetMonoPtr(), argv.size() );
|
||||
|
||||
uint index = 0;
|
||||
|
||||
for( string arg : argv )
|
||||
for( const string& arg : argv )
|
||||
{
|
||||
mono_array_set( pArguments, MonoString*, index++, this->m_pResource->GetDomain()->NewString( arg ) );
|
||||
}
|
||||
|
||||
PVOID* params = new PVOID[ 3 ];
|
||||
|
||||
params[ 0 ] = pPlayer;
|
||||
params[ 0 ] = pPlayer->ToMonoObject();
|
||||
params[ 1 ] = pCommandName;
|
||||
params[ 2 ] = pArguments;
|
||||
|
||||
|
@ -15,6 +15,7 @@ class CRegisteredCommands;
|
||||
#ifndef __CREGISTEREDCOMMANDS_H
|
||||
#define __CREGISTEREDCOMMANDS_H
|
||||
|
||||
#include "CElement.h"
|
||||
#include "CResource.h"
|
||||
|
||||
class CRegisteredCommands
|
||||
@ -40,13 +41,13 @@ public:
|
||||
~CRegisteredCommands ( void );
|
||||
|
||||
bool Add ( string strCommandName, MonoObject* pDelegate, bool bRestricted = false, bool bCaseSensitive = true );
|
||||
bool Execute ( void* pPlayer, string strCommandName, list< string > argv );
|
||||
bool Execute ( CElement* pPlayer, string strCommandName, list< string > argv );
|
||||
bool Remove ( string strCommandName, MonoObject* pDelegate = nullptr );
|
||||
|
||||
void ClearCommands ( void );
|
||||
|
||||
private:
|
||||
void Invoke ( void* pPlayer, MonoObject* pDelegate, string strCommandName, list< string > argv );
|
||||
void Invoke ( CElement* pPlayer, MonoObject* pDelegate, const string& strCommandName, list< string > argv );
|
||||
SCommand* GetCommand ( string strName );
|
||||
};
|
||||
|
||||
|
@ -13,14 +13,17 @@
|
||||
#include "StdInc.h"
|
||||
#include "CResource.h"
|
||||
|
||||
CResource::CResource( CMonoInterface* pMono, lua_State *pLuaVM, string sName )
|
||||
CResource::CResource( CResourceManager* pResourceManager, lua_State* pLuaVM, const string& sName )
|
||||
{
|
||||
this->m_pMono = pMono;
|
||||
this->m_pResourceManager = pResourceManager;
|
||||
this->m_pModule = pResourceManager->GetModule();
|
||||
this->m_pMono = pResourceManager->GetMono();
|
||||
this->m_pLuaVM = pLuaVM;
|
||||
this->m_sName = sName;
|
||||
|
||||
this->m_pMonoDomain = nullptr;
|
||||
|
||||
this->m_pElementManager = new CElementManager( this );
|
||||
this->m_pEventManager = new CEventManager( this );
|
||||
this->m_pRegisteredCommands = new CRegisteredCommands( this );
|
||||
}
|
||||
@ -31,10 +34,9 @@ CResource::~CResource( void )
|
||||
|
||||
this->GetMono()->GetGC()->Collect( this->GetMono()->GetGC()->GetMaxGeneration() );
|
||||
|
||||
g_pResourceManager->RemoveFromList( this );
|
||||
|
||||
SAFE_DELETE( this->m_pRegisteredCommands );
|
||||
SAFE_DELETE( this->m_pEventManager );
|
||||
SAFE_DELETE( this->m_pElementManager );
|
||||
|
||||
this->GetMono()->SetDomain( nullptr, true );
|
||||
|
||||
@ -42,17 +44,39 @@ CResource::~CResource( void )
|
||||
|
||||
this->m_pMono = nullptr;
|
||||
this->m_pLuaVM = nullptr;
|
||||
|
||||
this->m_pResourceManager = nullptr;
|
||||
this->m_pModule = nullptr;
|
||||
}
|
||||
|
||||
bool CResource::CallEvent( string strEventName, void* pThis, list< CLuaArgument* > argv )
|
||||
bool CResource::CallEvent( const string& strEventName, PVOID pThis, list< CLuaArgument* > argv ) const
|
||||
{
|
||||
if( !pThis )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this->m_pEventManager->Call( strEventName, pThis, argv );
|
||||
CElement* pThisElement = this->m_pElementManager->FindOrCreate( pThis );
|
||||
|
||||
bool bResult = this->m_pEventManager->Call( strEventName, pThisElement, argv );
|
||||
|
||||
if( strEventName == "onElementDestroy" )
|
||||
{
|
||||
CElement* pSource = nullptr;
|
||||
|
||||
auto *iter = *argv.begin();
|
||||
|
||||
if( iter->GetType() == LUA_TLIGHTUSERDATA )
|
||||
{
|
||||
pSource = this->m_pElementManager->GetFromList( iter->GetLightUserData() );
|
||||
}
|
||||
|
||||
if( pSource )
|
||||
{
|
||||
delete pSource;
|
||||
}
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool CResource::AddEvent( const char* szName, const char* szHandleElement )
|
||||
@ -87,21 +111,23 @@ bool CResource::RemoveEvent( const char* szName, const char* szHandleElement )
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CResource::ExecuteCommand( void* pPlayer, string strCommandName, list< string > argv )
|
||||
bool CResource::ExecuteCommand( PVOID pPlayer, const string& strCommandName, list< string > argv )
|
||||
{
|
||||
if( !pPlayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return this->m_pRegisteredCommands->Execute( pPlayer, strCommandName, argv );
|
||||
CElement* pPlayerElement = this->m_pElementManager->FindOrCreate( pPlayer );
|
||||
|
||||
return this->m_pRegisteredCommands->Execute( pPlayerElement, strCommandName, argv );
|
||||
}
|
||||
|
||||
void CResource::RegisterEvents( void )
|
||||
{
|
||||
if( this->m_pLuaVM )
|
||||
{
|
||||
if( g_pModuleManager->RegisterFunction( this->m_pLuaVM, "mono_event_handler", CFunctions::monoEventHandler ) )
|
||||
if( this->RegisterFunction( "mono_event_handler", CFunctions::monoEventHandler ) )
|
||||
{
|
||||
luaL_dostring( this->m_pLuaVM, "function _mono_event_handler( ... ) mono_event_handler( eventName, source, this, client, ... ); end" );
|
||||
|
||||
@ -109,7 +135,7 @@ void CResource::RegisterEvents( void )
|
||||
|
||||
if( pClass )
|
||||
{
|
||||
for( auto iter : pClass->GetAllEvents() )
|
||||
for( const auto& iter : pClass->GetAllEvents() )
|
||||
{
|
||||
string strEventName = iter.second->GetName();
|
||||
|
||||
@ -150,7 +176,7 @@ bool CResource::Init( void )
|
||||
|
||||
if( !this->m_pMonoDomain )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "%s - failed to create appdomain\n", this->m_sName.c_str() );
|
||||
this->ErrorPrintf( "%s - failed to create appdomain\n", this->m_sName.c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -188,57 +214,12 @@ void CResource::DoPulse( void )
|
||||
|
||||
bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func )
|
||||
{
|
||||
if( !g_pModuleManager->RegisterFunction( this->m_pLuaVM, szFunctionName, Func ) )
|
||||
if( !this->m_pModule->RegisterFunction( this->m_pLuaVM, szFunctionName, Func ) )
|
||||
{
|
||||
g_pModuleManager->ErrorPrintf( "Failed to register function '%s' for %s", szFunctionName, this->m_sName.c_str() );
|
||||
this->ErrorPrintf( "Failed to register function '%s' for %s", szFunctionName, this->m_sName.c_str() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CResource::Printf( const char* szFormat, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, szFormat );
|
||||
|
||||
char szBuffer[ 255 ];
|
||||
|
||||
vsprintf( szBuffer, szFormat, args );
|
||||
|
||||
va_end( args );
|
||||
|
||||
g_pModuleManager->Printf( szBuffer );
|
||||
}
|
||||
|
||||
void CResource::DebugPrintf( const char* szFormat, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, szFormat );
|
||||
|
||||
char szBuffer[ 255 ];
|
||||
|
||||
vsprintf( szBuffer, szFormat, args );
|
||||
|
||||
va_end( args );
|
||||
|
||||
g_pModuleManager->DebugPrintf( this->m_pLuaVM, szBuffer );
|
||||
}
|
||||
|
||||
void CResource::ErrorPrintf( const char* szFormat, ... )
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start( args, szFormat );
|
||||
|
||||
char szBuffer[ 255 ];
|
||||
|
||||
vsprintf( szBuffer, szFormat, args );
|
||||
|
||||
va_end( args );
|
||||
|
||||
g_pModuleManager->ErrorPrintf( szBuffer );
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class CResource;
|
||||
#ifndef __CRESOURCE_H
|
||||
#define __CRESOURCE_H
|
||||
|
||||
#include "CModule.h"
|
||||
#include "CMonoClass.h"
|
||||
#include "CMonoEvent.h"
|
||||
#include "CMonoInterface.h"
|
||||
@ -24,14 +25,14 @@ class CResource;
|
||||
#include "CRegisteredCommands.h"
|
||||
#include "CFunctions.h"
|
||||
|
||||
#include "CElement.h"
|
||||
#include "CElementManager.h"
|
||||
|
||||
#include "extra/CLuaArgument.h"
|
||||
#include "extra/CLuaArguments.h"
|
||||
|
||||
#include "include/ILuaModuleManager.h"
|
||||
#include "lua/CLuaFunctionDefinitions.h"
|
||||
|
||||
extern ILuaModuleManager10 *g_pModuleManager;
|
||||
|
||||
class CResource
|
||||
{
|
||||
private:
|
||||
@ -39,21 +40,24 @@ private:
|
||||
|
||||
lua_State* m_pLuaVM;
|
||||
|
||||
CResourceManager* m_pResourceManager;
|
||||
CElementManager* m_pElementManager;
|
||||
CMonoInterface* m_pMono;
|
||||
CMonoDomain* m_pMonoDomain;
|
||||
CModule* m_pModule;
|
||||
|
||||
CEventManager* m_pEventManager;
|
||||
CRegisteredCommands* m_pRegisteredCommands;
|
||||
|
||||
public:
|
||||
CResource ( CMonoInterface* m_pMono, lua_State *pLuaVM, string sName );
|
||||
CResource ( CResourceManager* pResourceManager, lua_State* pLuaVM, const string& strName );
|
||||
~CResource ( void );
|
||||
|
||||
bool CallEvent ( string strEventName, void* pThis, list< CLuaArgument* > argv );
|
||||
bool CallEvent ( const string& strEventName, PVOID pThis, list< CLuaArgument* > argv ) const;
|
||||
bool AddEvent ( const char* szName, const char* szHandleElement );
|
||||
bool RemoveEvent ( const char* szName, const char* szHandleElement );
|
||||
|
||||
bool ExecuteCommand ( void* pPlayer, string strCommandName, list< string > argv );
|
||||
bool ExecuteCommand ( PVOID pPlayer, const string& strCommandName, list< string > argv );
|
||||
|
||||
void RegisterEvents ( void );
|
||||
void RemoveEvents ( void );
|
||||
@ -62,16 +66,32 @@ public:
|
||||
void DoPulse ( void );
|
||||
bool RegisterFunction ( const char* szFunctionName, lua_CFunction Func );
|
||||
|
||||
void Printf ( const char* szFormat, ... );
|
||||
void DebugPrintf ( const char* szFormat, ... );
|
||||
void ErrorPrintf ( const char* szFormat, ... );
|
||||
template< typename ... Type >
|
||||
void Printf ( const char* szFormat, Type ... args ) const
|
||||
{
|
||||
this->m_pModule->Printf( szFormat, args ... );
|
||||
}
|
||||
|
||||
string GetName ( void ) { return this->m_sName; }
|
||||
lua_State* GetLua ( void ) { return this->m_pLuaVM; }
|
||||
CMonoInterface* GetMono ( void ) { return this->m_pMono; }
|
||||
CMonoDomain* GetDomain ( void ) { return this->m_pMonoDomain; }
|
||||
CEventManager* GetEventManager ( void ) { return this->m_pEventManager; }
|
||||
CRegisteredCommands* GetCommandManager ( void ) { return this->m_pRegisteredCommands; }
|
||||
template< typename ... Type >
|
||||
void DebugPrintf ( const char* szFormat, Type ... args ) const
|
||||
{
|
||||
this->m_pModule->DebugPrintf( this->m_pLuaVM, szFormat, args ... );
|
||||
}
|
||||
|
||||
template< typename ... Type >
|
||||
void ErrorPrintf ( const char* szFormat, Type ... args ) const
|
||||
{
|
||||
this->m_pModule->ErrorPrintf( szFormat, args ... );
|
||||
}
|
||||
|
||||
inline string GetName ( void ) const { return this->m_sName; }
|
||||
inline CModule* GetModule ( void ) const { return this->m_pModule; }
|
||||
inline lua_State* GetLua ( void ) const { return this->m_pLuaVM; }
|
||||
inline CMonoInterface* GetMono ( void ) const { return this->m_pMono; }
|
||||
inline CMonoDomain* GetDomain ( void ) const { return this->m_pMonoDomain; }
|
||||
inline CEventManager* GetEventManager ( void ) const { return this->m_pEventManager; }
|
||||
inline CElementManager* GetElementManager ( void ) const { return this->m_pElementManager; }
|
||||
inline CRegisteredCommands* GetCommandManager ( void ) const { return this->m_pRegisteredCommands; }
|
||||
|
||||
private:
|
||||
|
||||
|
@ -13,8 +13,9 @@
|
||||
#include "StdInc.h"
|
||||
#include "CResourceManager.h"
|
||||
|
||||
CResourceManager::CResourceManager( CMonoInterface* pMono )
|
||||
CResourceManager::CResourceManager( CModule* pModule, CMonoInterface* pMono )
|
||||
{
|
||||
this->m_pModule = pModule;
|
||||
this->m_pMono = pMono;
|
||||
}
|
||||
|
||||
@ -24,6 +25,30 @@ CResourceManager::~CResourceManager( void )
|
||||
{
|
||||
delete iter;
|
||||
}
|
||||
|
||||
this->m_pModule = nullptr;
|
||||
}
|
||||
|
||||
void CResourceManager::ResourceStopping( lua_State* pLuaVM )
|
||||
{
|
||||
CResource* pResource = this->GetFromList( pLuaVM );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
pResource->OnStopping();
|
||||
}
|
||||
}
|
||||
|
||||
void CResourceManager::ResourceStopped( lua_State* pLuaVM )
|
||||
{
|
||||
CResource* pResource = this->GetFromList( pLuaVM );
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
this->RemoveFromList( pResource );
|
||||
|
||||
delete pResource;
|
||||
}
|
||||
}
|
||||
|
||||
CResource* CResourceManager::Create( lua_State* luaVM, string strName )
|
||||
@ -39,7 +64,7 @@ CResource* CResourceManager::Create( lua_State* luaVM, string strName )
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CResource *pResource = new CResource( this->m_pMono, luaVM, strName );
|
||||
CResource *pResource = new CResource( this, luaVM, strName );
|
||||
|
||||
this->AddToList( pResource );
|
||||
|
||||
@ -56,7 +81,7 @@ void CResourceManager::AddToList( CResource* pResource )
|
||||
|
||||
CResource* CResourceManager::GetFromList( lua_State* pLuaVM )
|
||||
{
|
||||
for( auto iter : this->m_List )
|
||||
for( const auto& iter : this->m_List )
|
||||
{
|
||||
if( iter->GetLua() == pLuaVM )
|
||||
{
|
||||
@ -69,7 +94,7 @@ CResource* CResourceManager::GetFromList( lua_State* pLuaVM )
|
||||
|
||||
CResource* CResourceManager::GetFromList( MonoDomain* pDomain )
|
||||
{
|
||||
for( auto iter : this->m_List )
|
||||
for( const auto& iter : this->m_List )
|
||||
{
|
||||
if( iter->GetDomain()->GetMonoPtr() == pDomain )
|
||||
{
|
||||
@ -90,7 +115,7 @@ void CResourceManager::RemoveFromList( CResource* pResource )
|
||||
|
||||
void CResourceManager::DoPulse( void )
|
||||
{
|
||||
for( auto iter : this->m_List )
|
||||
for( const auto& iter : this->m_List )
|
||||
{
|
||||
iter->DoPulse();
|
||||
}
|
||||
|
@ -15,27 +15,33 @@ class CResourceManager;
|
||||
#ifndef __CRESOURCEMANAGER_H
|
||||
#define __CRESOURCEMANAGER_H
|
||||
|
||||
#include "CModule.h"
|
||||
#include "CResource.h"
|
||||
#include "CMonoInterface.h"
|
||||
|
||||
extern ILuaModuleManager10 *g_pModuleManager;
|
||||
|
||||
class CResourceManager
|
||||
{
|
||||
private:
|
||||
CModule* m_pModule;
|
||||
CMonoInterface* m_pMono;
|
||||
|
||||
list< CResource* > m_List;
|
||||
|
||||
public:
|
||||
CResourceManager ( CMonoInterface* pMono );
|
||||
CResourceManager ( CModule* pModule, CMonoInterface* pMono );
|
||||
~CResourceManager ( void );
|
||||
|
||||
void ResourceStopping ( lua_State* pLuaVM );
|
||||
void ResourceStopped ( lua_State* pLuaVM );
|
||||
|
||||
CResource* Create ( lua_State* luaVM, string strName );
|
||||
void AddToList ( CResource* pResource );
|
||||
CResource* GetFromList ( lua_State* pLuaVM );
|
||||
CResource* GetFromList ( MonoDomain* pDomain );
|
||||
void RemoveFromList ( CResource* pResource );
|
||||
void DoPulse ( void );
|
||||
|
||||
inline CModule* GetModule ( void ) { return this->m_pModule; }
|
||||
inline CMonoInterface* GetMono ( void ) { return this->m_pMono; }
|
||||
};
|
||||
#endif
|
||||
|
@ -62,5 +62,3 @@ extern "C"
|
||||
|
||||
#include "extra/Vector2.h"
|
||||
#include "extra/Vector3.h"
|
||||
|
||||
#include "include/ILuaModuleManager.h"
|
@ -61,9 +61,10 @@ public:
|
||||
CLuaArgumentsVector GetArray ( void ) const;
|
||||
CLuaArgumentsMap GetTable ( void ) const;
|
||||
|
||||
template <class T> T GetNumber() const
|
||||
template< class Type >
|
||||
inline Type GetNumber ( void )
|
||||
{
|
||||
return static_cast< T >( m_Number );
|
||||
return static_cast< Type >( m_Number );
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -534,6 +534,8 @@ bool CLuaFunctionDefinitions::IsElement( lua_State* pLuaVM, PVOID pUserData )
|
||||
|
||||
string CLuaFunctionDefinitions::GetElementType( lua_State* pLuaVM, PVOID pUserData )
|
||||
{
|
||||
string strResult;
|
||||
|
||||
CLuaArguments pLuaArguments;
|
||||
|
||||
pLuaArguments.PushUserData( pUserData );
|
||||
@ -542,13 +544,13 @@ string CLuaFunctionDefinitions::GetElementType( lua_State* pLuaVM, PVOID pUserDa
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
if( pLuaArgument.GetString() )
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
return string( pLuaArgument.GetString() );
|
||||
strResult = pLuaArgument.GetString();
|
||||
}
|
||||
}
|
||||
|
||||
return string();
|
||||
return strResult;
|
||||
}
|
||||
|
||||
PVOID CLuaFunctionDefinitions::GetElementByID( lua_State* pLuaVM, const char* szID, unsigned int uiIndex )
|
||||
@ -640,7 +642,10 @@ string CLuaFunctionDefinitions::GetElementID( lua_State* pLuaVM, PVOID pUserData
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
return string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
return pLuaArgument.GetString();
|
||||
}
|
||||
}
|
||||
|
||||
return string();
|
||||
@ -839,10 +844,13 @@ bool CLuaFunctionDefinitions::GetElementZoneName( lua_State* pLuaVM, PVOID pUser
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strOutName = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutName = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1700,10 +1708,15 @@ bool CLuaFunctionDefinitions::GetPlayerNametagText( lua_State* pLuaVM, PVOID pUs
|
||||
|
||||
if( pLuaArguments.Call( pLuaVM, "getPlayerNametagText", 1 ) )
|
||||
{
|
||||
strOutText = string( CLuaArgument( pLuaVM, -1 ).GetString() );
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutText = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1752,7 +1765,10 @@ string CLuaFunctionDefinitions::GetPlayerSerial( lua_State* pLuaVM, PVOID pUserD
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
return string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
return pLuaArgument.GetString();
|
||||
}
|
||||
}
|
||||
|
||||
return string();
|
||||
@ -1768,7 +1784,10 @@ string CLuaFunctionDefinitions::GetPlayerUserName( lua_State* pLuaVM, PVOID pUse
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
return string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
return pLuaArgument.GetString();
|
||||
}
|
||||
}
|
||||
|
||||
return string();
|
||||
@ -1796,10 +1815,15 @@ bool CLuaFunctionDefinitions::GetPlayerName( lua_State* pLuaVM, PVOID pUserData,
|
||||
|
||||
if( pLuaArguments.Call( pLuaVM, "getPlayerName", 1 ) )
|
||||
{
|
||||
strOutName = string( CLuaArgument( pLuaVM, -1 ).GetString() );
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutName = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1812,10 +1836,15 @@ bool CLuaFunctionDefinitions::GetPlayerIP( lua_State* pLuaVM, PVOID pUserData, s
|
||||
|
||||
if( pLuaArguments.Call( pLuaVM, "getPlayerIP", 1 ) )
|
||||
{
|
||||
strOutIP = string( CLuaArgument( pLuaVM, -1 ).GetString() );
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutIP = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1849,7 +1878,10 @@ string CLuaFunctionDefinitions::GetPlayerVersion( lua_State* pLuaVM, PVOID pUser
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
return string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
return pLuaArgument.GetString();
|
||||
}
|
||||
}
|
||||
|
||||
return string();
|
||||
@ -3026,7 +3058,12 @@ bool CLuaFunctionDefinitions::GetVehicleType( lua_State* pLuaVM, PVOID pUserData
|
||||
|
||||
if( pLuaArguments.Call( pLuaVM, "getVehicleType", 1 ) )
|
||||
{
|
||||
strType = string( CLuaArgument( pLuaVM, -1 ).GetString() );
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strType = pLuaArgument.GetString();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -7765,10 +7802,13 @@ bool CLuaFunctionDefinitions::GetAccountSerial( lua_State* pLuaVM, PVOID pAccoun
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strSerial = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strSerial = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -8033,10 +8073,13 @@ bool CLuaFunctionDefinitions::GetBanIP( lua_State* pLuaVM, PVOID pBan, string& s
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strOutIP = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutIP = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -8051,10 +8094,13 @@ bool CLuaFunctionDefinitions::GetBanSerial( lua_State* pLuaVM, PVOID pBan, strin
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strOutSerial = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutSerial = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -8069,10 +8115,13 @@ bool CLuaFunctionDefinitions::GetBanUsername( lua_State* pLuaVM, PVOID pBan, str
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strOutUsername = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutUsername = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -8087,10 +8136,13 @@ bool CLuaFunctionDefinitions::GetBanNick( lua_State* pLuaVM, PVOID pBan, string&
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strOutNick = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutNick = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -8105,10 +8157,13 @@ bool CLuaFunctionDefinitions::GetBanReason( lua_State* pLuaVM, PVOID pBan, strin
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strOutReason = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutReason = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -8123,10 +8178,13 @@ bool CLuaFunctionDefinitions::GetBanAdmin( lua_State* pLuaVM, PVOID pBan, string
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strOutAdmin = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strOutAdmin = pLuaArgument.GetString();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -8459,7 +8517,10 @@ bool CLuaFunctionDefinitions::GetResourceInfo( lua_State* pLuaVM, PVOID pResourc
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strInfo = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strInfo = pLuaArgument.GetString();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -8495,7 +8556,10 @@ bool CLuaFunctionDefinitions::GetResourceLoadFailureReason( lua_State* pLuaVM, P
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strReason = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strReason = pLuaArgument.GetString();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -8531,7 +8595,10 @@ bool CLuaFunctionDefinitions::GetResourceName( lua_State* pLuaVM, PVOID pResourc
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strName = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strName = pLuaArgument.GetString();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -8562,9 +8629,12 @@ bool CLuaFunctionDefinitions::GetResourceState( lua_State* pLuaVM, PVOID pResour
|
||||
{
|
||||
CLuaArgument pLuaArgument( pLuaVM, -1 );
|
||||
|
||||
strState = string( pLuaArgument.GetString() );
|
||||
if( pLuaArgument.GetType() == LUA_TSTRING )
|
||||
{
|
||||
strState = pLuaArgument.GetString();
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -18,8 +18,6 @@ class CLuaFunctionDefinitions;
|
||||
#include "../Common.h"
|
||||
#include "../extra/CLuaArguments.h"
|
||||
|
||||
extern ILuaModuleManager10 *g_pModuleManager;
|
||||
|
||||
class CLuaFunctionDefinitions
|
||||
{
|
||||
public:
|
||||
|
@ -14,22 +14,16 @@
|
||||
|
||||
#define MODULE_NAME "Mono 4.2.1"
|
||||
#define MODULE_AUTHOR "Dmitry Korolev <kernell@mtaroleplay.ru>"
|
||||
#define MODULE_VERSION 0.26f
|
||||
#define MODULE_VERSION 0.27f
|
||||
|
||||
#include "CModule.h"
|
||||
#include "CFunctions.h"
|
||||
#include "CResource.h"
|
||||
#include "CResourceManager.h"
|
||||
#include "CMonoInterface.h"
|
||||
|
||||
ILuaModuleManager10* g_pModuleManager = nullptr;
|
||||
CResourceManager* g_pResourceManager = nullptr;
|
||||
CMonoInterface* g_pMonoInterface = nullptr;
|
||||
CModule* g_pModule = nullptr;
|
||||
|
||||
MTAEXPORT bool InitModule( ILuaModuleManager10* pManager, char* szModuleName, char* szAuthor, float* fVersion )
|
||||
{
|
||||
g_pModuleManager = pManager;
|
||||
g_pMonoInterface = new CMonoInterface();
|
||||
g_pResourceManager = new CResourceManager( g_pMonoInterface );
|
||||
g_pModule = new CModule( pManager );
|
||||
|
||||
strncpy( szModuleName, MODULE_NAME, MAX_INFO_LENGTH );
|
||||
strncpy( szAuthor, MODULE_AUTHOR, MAX_INFO_LENGTH );
|
||||
@ -41,11 +35,10 @@ MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, ch
|
||||
|
||||
MTAEXPORT void RegisterFunctions( lua_State *pLuaVM )
|
||||
{
|
||||
if( g_pModuleManager && pLuaVM && g_pResourceManager )
|
||||
if( g_pModule && pLuaVM )
|
||||
{
|
||||
if( g_pModuleManager->RegisterFunction( pLuaVM, "mono_init", CFunctions::monoInit ) )
|
||||
if( g_pModule->RegisterFunction( pLuaVM, "mono_init", CFunctions::monoInit ) )
|
||||
{
|
||||
//luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, monoInit )" );
|
||||
luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, function( res ) mono_init( getResourceName( res ) ) end )" );
|
||||
}
|
||||
}
|
||||
@ -53,9 +46,9 @@ MTAEXPORT void RegisterFunctions( lua_State *pLuaVM )
|
||||
|
||||
MTAEXPORT bool DoPulse( void )
|
||||
{
|
||||
if( g_pResourceManager )
|
||||
if( g_pModule )
|
||||
{
|
||||
g_pResourceManager->DoPulse();
|
||||
g_pModule->DoPulse();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -63,14 +56,9 @@ MTAEXPORT bool DoPulse( void )
|
||||
|
||||
MTAEXPORT bool ShutdownModule( void )
|
||||
{
|
||||
if( g_pResourceManager )
|
||||
if( g_pModule )
|
||||
{
|
||||
delete g_pResourceManager;
|
||||
}
|
||||
|
||||
if( g_pMonoInterface )
|
||||
{
|
||||
delete g_pMonoInterface;
|
||||
g_pModule->Shutdown();
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -78,9 +66,9 @@ MTAEXPORT bool ShutdownModule( void )
|
||||
|
||||
MTAEXPORT bool ResourceStopping( lua_State* luaVM )
|
||||
{
|
||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||
if( g_pModule )
|
||||
{
|
||||
pResource->OnStopping();
|
||||
g_pModule->ResourceStopping( luaVM );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -88,9 +76,9 @@ MTAEXPORT bool ResourceStopping( lua_State* luaVM )
|
||||
|
||||
MTAEXPORT bool ResourceStopped( lua_State* luaVM )
|
||||
{
|
||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||
if( g_pModule )
|
||||
{
|
||||
delete pResource;
|
||||
g_pModule->ResourceStopped( luaVM );
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user