diff --git a/mta-mono/mta-mono.vcxproj b/mta-mono/mta-mono.vcxproj
index 324d3e7..42fc545 100644
--- a/mta-mono/mta-mono.vcxproj
+++ b/mta-mono/mta-mono.vcxproj
@@ -10,85 +10,6 @@
Win32
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{5E5C7A85-A869-4D86-88FF-05DCEFC07AC3}
mta-mono
@@ -131,7 +52,7 @@
D:\Server\MTA\server\mods\deathmatch\modules
bin\Release\
- false
+ true
@@ -146,10 +67,11 @@
EnableFastChecks
MultiThreadedDebugDLL
true
-
+ Use
Level3
false
EditAndContinue
+ StdInc.h
_DEBUG;%(PreprocessorDefinitions)
@@ -178,18 +100,21 @@
false
- .\include;.\src\include;.\vendor\lua51\src;.\vendor\mysql;.\vendor\eglib
+ .\src;.\include;.\src\include;.\vendor\lua51\src;.\vendor\mysql;.\vendor\eglib
WIN32;_WINDOWS;NDEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
- MultiThreadedDebug
+ MultiThreadedDebugDLL
true
-
+ Use
Level3
- ProgramDatabase
- false
- Full
- Default
- true
- true
+ EditAndContinue
+ Disabled
+ EnableFastChecks
+ false
+
+
+ StdInc.h
+ true
+ StdInc.h;%(ForcedIncludeFiles)
NDEBUG;%(PreprocessorDefinitions)
@@ -201,20 +126,117 @@
$(OutDir)$(TargetName)$(TargetExt)
true
- Windows
- true
- true
+ Console
+
+
+
+
false
-
-
+ $(IntDir)$(TargetFileName).lib
MachineX86
- UseLinkTimeCodeGeneration
+
+
lib;%(AdditionalLibraryDirectories)
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mta-mono/src/CFunctions.cpp b/mta-mono/src/CFunctions.cpp
index 4cd6591..4da7b85 100644
--- a/mta-mono/src/CFunctions.cpp
+++ b/mta-mono/src/CFunctions.cpp
@@ -10,6 +10,7 @@
*
*********************************************************/
+#include "StdInc.h"
#include "CFunctions.h"
#include "extra/CLuaArguments.h"
@@ -42,4 +43,32 @@ int CFunctions::monoInit( lua_State *pLuaVM )
}
return 0;
-}
\ No newline at end of file
+}
+
+int CFunctions::monoEventHandler( lua_State *pLuaVM )
+{
+ if( pLuaVM )
+ {
+ CResource *pResource = g_pResourceManager->GetFromList( pLuaVM );
+
+ if( pResource )
+ {
+ // eventName, this, source, client, ...
+
+ string strEventName = CLuaArgument( pLuaVM, -4 ).GetString();
+ void* pThis = CLuaArgument( pLuaVM, -3 ).GetLightUserData();
+ void* pSource = CLuaArgument( pLuaVM, -2 ).GetLightUserData();
+ void* pClient = CLuaArgument( pLuaVM, -1 ).GetLightUserData();
+
+ //void *args[] = { &vecVector.fX, &vecVector.fY };
+
+ g_pModuleManager->DebugPrintf( pLuaVM, "event: %s", strEventName.c_str() );
+
+ pResource->CallEvent( strEventName, pThis, pSource, pClient, nullptr );
+
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/mta-mono/src/CFunctions.h b/mta-mono/src/CFunctions.h
index d2d457b..53ac837 100644
--- a/mta-mono/src/CFunctions.h
+++ b/mta-mono/src/CFunctions.h
@@ -28,6 +28,7 @@ class CFunctions
{
public:
static int monoInit ( lua_State *pLuaVM );
+ static int monoEventHandler ( lua_State *pLuaVM );
};
#endif
diff --git a/mta-mono/src/CMonoClass.cpp b/mta-mono/src/CMonoClass.cpp
index f720bfc..e14d04f 100644
--- a/mta-mono/src/CMonoClass.cpp
+++ b/mta-mono/src/CMonoClass.cpp
@@ -1,18 +1,35 @@
+/*********************************************************
+*
+* 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 "CMonoClass.h"
-MonoObject* CMonoClass::New( MonoClass* pMonoClass, MonoDomain* pMonoDomain )
+CMonoClass::CMonoClass( MonoClass* pMonoClass, CMonoDomain* pDomain )
{
- MonoObject* pObject = mono_object_new( pMonoDomain, pMonoClass );
+ this->m_pClass = pMonoClass;
+ this->m_pDomain = pDomain;
+}
+
+CMonoClass::~CMonoClass( void )
+{
+ this->m_pDomain = nullptr;
+ this->m_pClass = nullptr;
+}
+
+MonoObject* CMonoClass::New( void )
+{
+ MonoObject* pObject = this->m_pDomain->CreateObject( this->m_pClass );
if( !pObject )
{
- g_pModuleManager->ErrorPrintf( "%s:%d: Failed to create mono object for %s::%s\n",
- CMonoClass::GetNameSpace( pMonoClass ),
- CMonoClass::GetName( pMonoClass ),
- __FILE__,
- __LINE__
- );
-
return nullptr;
}
@@ -21,45 +38,40 @@ MonoObject* CMonoClass::New( MonoClass* pMonoClass, MonoDomain* pMonoDomain )
return pObject;
}
-MonoObject* CMonoClass::New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, SColor& pColor )
+MonoObject* CMonoClass::New( SColor& pColor )
{
void *args[] = { &pColor.R, &pColor.G, &pColor.B, &pColor.A };
- return CMonoClass::New( pMonoClass, pMonoDomain, args, 4 );
+ return this->New( args, 4 );
}
-
-MonoObject* CMonoClass::New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, Vector2& vecVector )
+MonoObject* CMonoClass::New( Vector2& vecVector )
{
void *args[] = { &vecVector.fX, &vecVector.fY };
- return CMonoClass::New( pMonoClass, pMonoDomain, args, 2 );
+ return this->New( args, 2 );
}
-MonoObject* CMonoClass::New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, Vector3& vecVector )
+MonoObject* CMonoClass::New( Vector3& vecVector )
{
void *args[] = { &vecVector.fX, &vecVector.fY, &vecVector.fZ };
- return CMonoClass::New( pMonoClass, pMonoDomain, args, 3 );
+ return this->New( args, 3 );
}
-MonoObject* CMonoClass::New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, void** args, int argc )
+MonoObject* CMonoClass::New( void** args, int argc )
{
- MonoObject* pObject = mono_object_new( pMonoDomain, pMonoClass );
+ MonoObject* pObject = this->m_pDomain->CreateObject( this->m_pClass );
if( !pObject )
{
- g_pModuleManager->ErrorPrintf( "%s:%d: Failed to create mono object for %s::%s\n", GetNameSpace( pMonoClass ), GetName( pMonoClass ), __FILE__, __LINE__ );
-
return nullptr;
}
- MonoMethod* pMonoMethod = CMonoClass::GetMethod( pMonoClass, ".ctor", argc );
+ MonoMethod* pMonoMethod = this->GetMethod( ".ctor", argc );
if( !pMonoMethod )
{
- g_pModuleManager->ErrorPrintf( "%s:%d: Could not lookup constructor for class %s::%s\n", GetNameSpace( pMonoClass ), GetName( pMonoClass ), __FILE__, __LINE__ );
-
return nullptr;
}
@@ -68,28 +80,29 @@ MonoObject* CMonoClass::New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, voi
return pObject;
}
-const char* CMonoClass::GetName( MonoClass* pMonoClass )
+
+const char* CMonoClass::GetName( void )
{
- return mono_class_get_name( pMonoClass );
+ return mono_class_get_name( this->m_pClass );
}
-const char* CMonoClass::GetNameSpace( MonoClass* pMonoClass )
+const char* CMonoClass::GetNameSpace( void )
{
- return mono_class_get_namespace( pMonoClass );
+ return mono_class_get_namespace( this->m_pClass );
}
-MonoMethod* CMonoClass::GetMethod( MonoClass* pMonoClass, const char* szMethodName, int iParamCount )
+MonoMethod* CMonoClass::GetMethod( const char* szMethodName, int iParamCount )
{
- return mono_class_get_method_from_name( pMonoClass, szMethodName, iParamCount );
+ return mono_class_get_method_from_name( this->m_pClass, szMethodName, iParamCount );
}
-MonoMethod* CMonoClass::GetMethod( MonoClass* pMonoClass, const char* szMethodName )
+MonoMethod* CMonoClass::GetMethod( const char* szMethodName )
{
MonoMethodDesc* pMonoMethodDesc = mono_method_desc_new( szMethodName, false );
if( pMonoMethodDesc )
{
- MonoMethod* pMethod = mono_method_desc_search_in_class( pMonoMethodDesc, pMonoClass );
+ MonoMethod* pMethod = mono_method_desc_search_in_class( pMonoMethodDesc, this->m_pClass );
mono_method_desc_free( pMonoMethodDesc );
diff --git a/mta-mono/src/CMonoClass.h b/mta-mono/src/CMonoClass.h
index 92da49b..3fe7cc9 100644
--- a/mta-mono/src/CMonoClass.h
+++ b/mta-mono/src/CMonoClass.h
@@ -1,28 +1,47 @@
+/*********************************************************
+*
+* 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 CMonoClass;
-#ifndef _C_MONO_CLASS
-#define _C_MONO_CLASS
+#ifndef _C_MONOCLASS_H
+#define _C_MONOCLASS_H
-#include "Common.h"
-
-extern ILuaModuleManager10 *g_pModuleManager;
+#include "CMonoDomain.h"
class CMonoClass
{
+private:
+ MonoClass* m_pClass;
+
+ CMonoDomain* m_pDomain;
+
public:
- static MonoObject* New( MonoClass* pMonoClass, MonoDomain* pMonoDomain );
- static MonoObject* New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, SColor& pColor );
- static MonoObject* New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, Vector2& vecVector );
- static MonoObject* New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, Vector3& vecVector );
- static MonoObject* New( MonoClass* pMonoClass, MonoDomain* pMonoDomain, void** args, int argc );
+ CMonoClass ( MonoClass* pMonoClass, CMonoDomain* pDomain );
+ ~CMonoClass ( void );
- static const char* GetName( MonoClass* pMonoClass );
- static const char* GetNameSpace( MonoClass* pMonoClass );
+ MonoObject* New ( void );
+ MonoObject* New ( SColor& pColor );
+ MonoObject* New ( Vector2& vecVector );
+ MonoObject* New ( Vector3& vecVector );
+ MonoObject* New ( void** args, int argc );
- static MonoMethod* GetMethod( MonoClass* pMonoClass, const char* szMethodName, int iParamCount );
- static MonoMethod* GetMethod( MonoClass* pMonoClass, const char* szMethodName );
+ const char* GetName ( void );
+ const char* GetNameSpace ( void );
- static MonoClass* GetClass( MonoClass* pMonoClass );
+ MonoMethod* GetMethod ( const char* szMethodName, int iParamCount );
+ MonoMethod* GetMethod ( const char* szMethodName );
+
+ MonoClass* GetMonoPtr ( void ) { return this->m_pClass; }
+ CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
};
#endif
\ No newline at end of file
diff --git a/mta-mono/src/CMonoCorlib.cpp b/mta-mono/src/CMonoCorlib.cpp
new file mode 100644
index 0000000..63f7e1f
--- /dev/null
+++ b/mta-mono/src/CMonoCorlib.cpp
@@ -0,0 +1,58 @@
+/*********************************************************
+*
+* 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 "CMonoCorlib.h"
+
+CMonoCorlib::CMonoCorlib( CMonoDomain* pDomain )
+{
+ this->m_pDomain = pDomain;
+ this->m_pImage = mono_get_corlib();
+ this->m_pAssembly = mono_image_get_assembly( this->m_pImage );
+
+ this->Class[ "intptr" ] = this->GetDomain()->FindOrAdd( mono_get_intptr_class() );
+ this->Class[ "uintptr" ] = this->GetDomain()->FindOrAdd( mono_get_uintptr_class() );
+ this->Class[ "boolean" ] = this->GetDomain()->FindOrAdd( mono_get_boolean_class() );
+ this->Class[ "char" ] = this->GetDomain()->FindOrAdd( mono_get_char_class() );
+ this->Class[ "sbyte" ] = this->GetDomain()->FindOrAdd( mono_get_sbyte_class() );
+ this->Class[ "byte" ] = this->GetDomain()->FindOrAdd( mono_get_byte_class() );
+ this->Class[ "int16" ] = this->GetDomain()->FindOrAdd( mono_get_int16_class() );
+ this->Class[ "uint16" ] = this->GetDomain()->FindOrAdd( mono_get_uint16_class() );
+ this->Class[ "int32" ] = this->GetDomain()->FindOrAdd( mono_get_int32_class() );
+ this->Class[ "uint32" ] = this->GetDomain()->FindOrAdd( mono_get_uint32_class() );
+ this->Class[ "int64" ] = this->GetDomain()->FindOrAdd( mono_get_int64_class() );
+ this->Class[ "uint64" ] = this->GetDomain()->FindOrAdd( mono_get_uint64_class() );
+ this->Class[ "float" ] = this->GetDomain()->FindOrAdd( mono_get_single_class() );
+ this->Class[ "double" ] = this->GetDomain()->FindOrAdd( mono_get_double_class() );
+ this->Class[ "string" ] = this->GetDomain()->FindOrAdd( mono_get_string_class() );
+ this->Class[ "array" ] = this->GetDomain()->FindOrAdd( mono_get_array_class() );
+ this->Class[ "enum" ] = this->GetDomain()->FindOrAdd( mono_get_enum_class() );
+ this->Class[ "exception" ] = this->GetDomain()->FindOrAdd( mono_get_exception_class() );
+ this->Class[ "object" ] = this->GetDomain()->FindOrAdd( mono_get_object_class() );
+ this->Class[ "thread" ] = this->GetDomain()->FindOrAdd( mono_get_thread_class() );
+
+ this->Class[ "Type" ] = this->GetClass( "System", "Type" );
+ this->Class[ "ValueType" ] = this->GetClass( "System", "ValueType" );
+}
+
+CMonoCorlib::~CMonoCorlib( void )
+{
+ this->m_pDomain = nullptr;
+ this->m_pAssembly = nullptr;
+ this->m_pImage = nullptr;
+
+ this->Class.clear();
+}
+
+CMonoClass* CMonoCorlib::GetClass( const char *szNameSpace, const char *szClassName )
+{
+ return this->GetDomain()->FindOrAdd( mono_class_from_name( this->m_pImage, szNameSpace, szClassName ) );
+}
\ No newline at end of file
diff --git a/mta-mono/src/CMonoCorlib.h b/mta-mono/src/CMonoCorlib.h
new file mode 100644
index 0000000..f39d2aa
--- /dev/null
+++ b/mta-mono/src/CMonoCorlib.h
@@ -0,0 +1,40 @@
+/*********************************************************
+*
+* 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 CMonoCorlib;
+
+#ifndef __CMONOCORLIB_H
+#define __CMONOCORLIB_H
+
+#include "CMonoDomain.h"
+#include "CMonoClass.h"
+
+class CMonoCorlib
+{
+private:
+ MonoAssembly* m_pAssembly;
+ MonoImage* m_pImage;
+ CMonoDomain* m_pDomain;
+
+protected:
+ map< const char*, CMonoClass* > Class;
+
+public:
+ CMonoCorlib ( CMonoDomain* pDomain );
+ ~CMonoCorlib ( void );
+
+ CMonoClass* GetClass ( const char *szNameSpace, const char *szClassName );
+
+ CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
+};
+
+#endif
\ No newline at end of file
diff --git a/mta-mono/src/CMonoDomain.cpp b/mta-mono/src/CMonoDomain.cpp
new file mode 100644
index 0000000..d11fea0
--- /dev/null
+++ b/mta-mono/src/CMonoDomain.cpp
@@ -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 "CMonoDomain.h"
+
+CMonoDomain::CMonoDomain( CResource* pResource, MonoDomain* pDomain )
+{
+ this->m_pDomain = pDomain;
+ this->m_pResource = pResource;
+
+ this->m_pCorlib = nullptr;
+ this->m_pMTALib = nullptr;
+}
+
+CMonoDomain::~CMonoDomain( void )
+{
+ SAFE_DELETE( this->m_pMTALib );
+ SAFE_DELETE( this->m_pCorlib );
+
+ for( auto iter : this->m_ClassPool )
+ {
+ delete iter;
+ }
+
+ this->m_ClassPool.clear();
+
+ this->m_pDomain = nullptr;
+}
+
+CMonoClass* CMonoDomain::FindOrAdd( MonoClass* klass )
+{
+ if( !klass )
+ {
+ return nullptr;
+ }
+
+ if( this->m_pDomain )
+ {
+ for( auto iter : this->m_ClassPool )
+ {
+ if( iter->GetMonoPtr() == klass )
+ {
+ return iter;
+ }
+ }
+
+ CMonoClass* pClass = new CMonoClass( klass, this );
+
+ this->m_ClassPool.push_back( pClass );
+
+ return pClass;
+ }
+
+ return nullptr;
+}
+
+void CMonoDomain::Init( void )
+{
+ this->m_pCorlib = new CMonoCorlib( this );
+ this->m_pMTALib = new CMonoMTALib( this );
+}
+
+void CMonoDomain::Unload( void )
+{
+ mono_domain_unload( this->m_pDomain );
+}
+
+bool CMonoDomain::Set( bool bForce )
+{
+ return mono_domain_set( this->m_pDomain, bForce );
+}
+
+MonoAssembly* CMonoDomain::OpenAssembly( const char *szName )
+{
+ return mono_domain_assembly_open( this->m_pDomain, szName );
+}
+
+MonoObject* CMonoDomain::CreateObject( MonoClass* klass )
+{
+ return mono_object_new( this->m_pDomain, klass );
+}
+
+MonoString* CMonoDomain::NewString( const char* szText )
+{
+ return mono_string_new( this->m_pDomain, szText );
+}
+
+MonoString* CMonoDomain::NewString( string strText )
+{
+ return mono_string_new( this->m_pDomain, strText.c_str() );
+}
diff --git a/mta-mono/src/CMonoDomain.h b/mta-mono/src/CMonoDomain.h
new file mode 100644
index 0000000..e3c0776
--- /dev/null
+++ b/mta-mono/src/CMonoDomain.h
@@ -0,0 +1,97 @@
+/*********************************************************
+*
+* 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 CMonoDomain;
+
+#ifndef __CMONODOMAIN_H
+#define __CMONODOMAIN_H
+
+#include "CMonoCorlib.h"
+#include "CMonoMTALib.h"
+#include "CMonoClass.h"
+#include "CResource.h"
+
+#include "extra/CLuaArguments.h"
+
+class CMonoDomain
+{
+private:
+ MonoDomain* m_pDomain;
+ CResource* m_pResource;
+
+ CMonoCorlib* m_pCorlib;
+ CMonoMTALib* m_pMTALib;
+
+ vector< CMonoClass* > m_ClassPool;
+
+public:
+ CMonoDomain ( CResource* pResource, MonoDomain* pDomain );
+ ~CMonoDomain ( void );
+
+ CMonoClass* FindOrAdd ( MonoClass* klass );
+
+ void Init ( void );
+
+ void Unload ( void );
+ bool Set ( bool bForce );
+ MonoAssembly* OpenAssembly ( const char *szName );
+ MonoObject* CreateObject ( MonoClass* klass );
+
+ MonoString* NewString ( const char* szText );
+ MonoString* NewString ( string strText );
+
+ template
+ MonoArray* NewArray ( MonoClass* pMonoClass, CLuaArguments* pLuaArguments = NULL )
+ {
+ MonoArray* pArray = mono_array_new( this->m_pDomain, pMonoClass, pLuaArguments ? pLuaArguments->Count() : 0 );
+
+ if( pLuaArguments )
+ {
+ int i = 0;
+
+ for( auto iter : pLuaArguments->GetArguments() )
+ {
+ if( LuaType == LUA_TBOOLEAN )
+ {
+ mono_array_set( pArray, T, i++, (T)( iter->GetBoolean() ) );
+ }
+ else if( LuaType == LUA_TLIGHTUSERDATA )
+ {
+ mono_array_set( pArray, T, i++, (T)( iter->GetLightUserData() ) );
+ }
+ else if( LuaType == LUA_TNUMBER )
+ {
+ mono_array_set( pArray, T, i++, iter->GetNumber< T >() );
+ }
+ else if( LuaType == LUA_TSTRING )
+ {
+ mono_array_set( pArray, T, i++, (T)( iter->GetString() ) );
+ }
+ else if( LuaType == LUA_TUSERDATA )
+ {
+ mono_array_set( pArray, T, i++, (T)( iter->GetLightUserData() ) );
+ }
+ }
+ }
+
+ return pArray;
+ }
+
+ MonoDomain* GetMonoPtr ( void ) { return this->m_pDomain; }
+
+ CResource* GetResource ( void ) { return this->m_pResource; }
+
+ CMonoCorlib* GetCorlib ( void ) { return this->m_pCorlib; }
+ CMonoMTALib* GetMTALib ( void ) { return this->m_pMTALib; }
+};
+
+#endif
\ No newline at end of file
diff --git a/mta-mono/src/CMonoFunctions.cpp b/mta-mono/src/CMonoFunctions.cpp
index 21e7624..9ecd446 100644
--- a/mta-mono/src/CMonoFunctions.cpp
+++ b/mta-mono/src/CMonoFunctions.cpp
@@ -37,12 +37,16 @@ void CMonoFunctions::AddInternals( void )
MONO_DECLARE( Server, SetRuleValue );
MONO_DECLARE( Server, RemoveRuleValue );
+ MONO_DECLARE( Event, AddHandler );
+
// Element create/destroy
MONO_DECLARE( Element, Create );
MONO_DECLARE( Element, Destroy );
MONO_DECLARE( Element, Clone );
// Element get funcs
+ MONO_DECLARE( Element, GetRootElement );
+
MONO_DECLARE( Element, GetByType );
MONO_DECLARE( Element, IsElement );
MONO_DECLARE( Element, GetType );
@@ -746,7 +750,7 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
&szSortable
};
- return RESOURCE->NewObject( "MultiTheftAuto", "ServerVersion", args, 8 );
+ return RESOURCE->GetDomain()->GetMTALib()->GetClass( "ServerVersion" )->New( args, 8 );
}
}
@@ -757,7 +761,7 @@ MonoString* CMonoFunctions::Server::GetGameType( void )
{
if( RESOURCE )
{
- return RESOURCE->NewString( CLuaFunctionDefinitions::GetGameType( RESOURCE->GetLua() ) );
+ return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetGameType( RESOURCE->GetLua() ) );
}
return NULL;
@@ -767,7 +771,7 @@ MonoString* CMonoFunctions::Server::GetMapName( void )
{
if( RESOURCE )
{
- return RESOURCE->NewString( CLuaFunctionDefinitions::GetMapName( RESOURCE->GetLua() ) );
+ return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetMapName( RESOURCE->GetLua() ) );
}
return NULL;
@@ -803,7 +807,7 @@ MonoString* CMonoFunctions::Server::GetRuleValue( MonoString* msKey )
{
const char* szKey = mono_string_to_utf8( msKey );
- return RESOURCE->NewString( CLuaFunctionDefinitions::GetRuleValue( RESOURCE->GetLua(), szKey ) );
+ return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetRuleValue( RESOURCE->GetLua(), szKey ) );
}
return false;
diff --git a/mta-mono/src/CMonoFunctions.h b/mta-mono/src/CMonoFunctions.h
index 9e035f0..0c64a17 100644
--- a/mta-mono/src/CMonoFunctions.h
+++ b/mta-mono/src/CMonoFunctions.h
@@ -1,717 +1,727 @@
-/*********************************************************
-*
-* 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 "CResource.h"
-#include "CResourceManager.h"
-
-class CMonoFunctions;
-
-#ifndef __CMONOFUNCTIONS_H
-#define __CMONOFUNCTIONS_H
-
-#include "Common.h"
-#include "lua/CLuaFunctionDefinitions.h"
-
-#include "CMonoObject.h"
-
-extern ILuaModuleManager10 *g_pModuleManager;
-extern CResourceManager *g_pResourceManager;
-
-#define RESOURCE g_pResourceManager->GetFromList( mono_domain_get() )
-
-#define MONO_DECLARE(a,b) mono_add_internal_call("MultiTheftAuto.Native."#a"::"#b,CMonoFunctions::a::b)
-
-class CMonoFunctions
-{
-public:
- static void AddInternals( void );
-
- class Debug
- {
- public:
- static void Log ( MonoString *string );
- static void Info ( MonoString *string );
- static void Error ( MonoString *string );
- };
-
- class Config
- {
- public:
- static MonoString* Get ( MonoString *msKey );
- static bool Set ( MonoString *msKey, MonoString *msValue );
- };
-
- class Server
- {
- public:
- static unsigned int GetMaxPlayers ( void );
- static bool SetMaxPlayers ( unsigned int uiMax );
- static bool OutputChatBox ( MonoString* szText, DWORD pElement, MonoObject* pColor, bool bColorCoded );
- static bool OutputConsole ( MonoString* szText, DWORD pElement );
- static bool SetPassword ( MonoString* msPassword, bool bSave );
- static MonoObject* GetVersion ( void );
-
- static MonoString* GetGameType ( void );
- static MonoString* GetMapName ( void );
-
- static bool SetGameType ( MonoString* msGameType );
- static bool SetMapName ( MonoString* msMapName );
- static MonoString* GetRuleValue ( MonoString* msKey );
- static bool SetRuleValue ( MonoString* msKey, MonoString* msValue );
- static bool RemoveRuleValue ( MonoString* msKey );
- };
-
- class Element
- {
- public:
- // Element create/destroy
- static DWORD Create ( MonoString* msTypeName, MonoString* msID );
- static bool Destroy ( DWORD pUserData );
- static DWORD Clone ( DWORD pUserData, MonoObject* vecPosition, bool bCloneElement );
-
- // Element get funcs
- static MonoArray* GetByType ( MonoString* msType, DWORD pStartElement );
-
- static bool IsElement ( DWORD pUserData );
- static MonoString* GetType ( DWORD pUserData );
- static DWORD GetByID ( MonoString* msID, unsigned int uiIndex );
- static DWORD GetByIndex ( int iIndex );
- static DWORD GetChild ( DWORD pUserData, int iIndex );
- static int GetChildrenCount ( DWORD pUserData );
- static MonoString* GetID ( DWORD pUserData );
- static MonoObject* GetData ( DWORD pUserData, MonoString* sKey, bool bInherit = true );
- static MonoArray* GetAllData ( DWORD pUserData );
- static unsigned int GetParent ( DWORD pUserData );
- static MonoObject* GetPosition ( DWORD pUserData );
- static MonoObject* GetRotation ( DWORD pUserData );
- static MonoObject* GetVelocity ( DWORD pUserData );
- static unsigned char GetInterior ( DWORD pUserData );
- static bool IsWithinColShape ( DWORD pUserData );
- static bool IsWithinMarker ( DWORD pUserData );
- static unsigned short GetDimension ( DWORD pUserData );
- static MonoString* GetZoneName ( DWORD pUserData, bool bCitiesOnly = false );
- static bool IsAttached ( DWORD pUserData );
- static DWORD GetAttachedTo ( DWORD pUserData );
- static DWORD GetColShape ( DWORD pUserData );
- static unsigned char GetAlpha ( DWORD pUserData );
- static bool IsDoubleSided ( DWORD pUserData );
- static float GetHealth ( DWORD pUserData );
- static unsigned short GetModel ( DWORD pUserData );
- static bool IsInWater ( DWORD pUserData );
- static MonoObject* GetAttachedOffsetPosition ( DWORD pUserData );
- static MonoObject* GetAttachedOffsetRotation ( DWORD pUserData );
- static DWORD GetSyncer ( DWORD pUserData );
- static bool GetCollisionsEnabled ( DWORD pUserData );
- static bool IsFrozen ( DWORD pUserData );
- static DWORD GetLowLod ( DWORD pUserData );
- static bool IsLowLod ( DWORD pUserData );
-
- // Element set funcs
- static bool ClearVisibleTo ( DWORD pUserData );
- static bool SetID ( DWORD pUserData, MonoString* msID );
- static bool SetData ( DWORD pUserData, MonoString* msKey, CLuaArgument& Variable );
- static bool RemoveData ( DWORD pUserData, MonoString* msKey );
- static bool SetParent ( DWORD pUserData, DWORD pTarget );
- static bool SetPosition ( DWORD pUserData, MonoObject* pPosition, bool bWarp );
- static bool SetRotation ( DWORD pUserData, MonoObject* pRotation, MonoString* msRotationOrder, bool bNewWay );
- static bool SetVelocity ( DWORD pUserData, MonoObject* pVelocity );
- static bool SetVisibleTo ( DWORD pUserData, DWORD pTarget, bool bVisible );
- static bool SetInterior ( DWORD pUserData, int iInterior );
- static bool SetDimension ( DWORD pUserData, int iDimension );
- static bool Attach ( DWORD pUserData, DWORD pTarget, MonoObject* pPosition, MonoObject* pRotation );
- static bool Detach ( DWORD pUserData, DWORD pTarget );
- static bool SetAlpha ( DWORD pUserData, int iAlpha );
- static bool SetDoubleSided ( DWORD pUserData, bool bDoubleSided );
- static bool SetHealth ( DWORD pUserData, float fHealth );
- static bool SetModel ( DWORD pUserData, int iModel );
- static bool SetAttachedOffsets ( DWORD pUserData, MonoObject* pPosition, MonoObject* pRotation );
- static bool SetSyncer ( DWORD pUserData, DWORD pPlayer );
- static bool SetCollisionsEnabled ( DWORD pUserData, bool bEnabled );
- static bool SetFrozen ( DWORD pUserData, bool bFrozen );
- static bool SetLowLod ( DWORD pUserData, bool bEnabled );
- };
-
- class Player
- {
- public:
- // Player get functions
- static unsigned int GetCount ( void );
- static DWORD GetFromName ( MonoString* msNick );
- static unsigned int GetPing ( DWORD pUserData );
- static long GetMoney ( DWORD pUserData );
- static DWORD GetRandom ( void );
- static bool IsMuted ( DWORD pUserData );
- static DWORD GetTeam ( DWORD pUserData );
- static unsigned int GetWantedLevel ( DWORD pUserData );
- static MonoArray* GetAlivePlayers ( void );
- static MonoArray* GetDeadPlayers ( void );
- static unsigned int GetIdleTime ( DWORD pUserData );
- static bool IsMapForced ( DWORD pUserData );
- static MonoString* GetNametagText ( DWORD pUserData );
- static MonoObject* GetNametagColor ( DWORD pUserData );
- static bool IsNametagShowing ( DWORD pUserData );
- static MonoString* GetSerial ( DWORD pUserData );
- static MonoString* GetUserName ( DWORD pUserData );
- static unsigned char GetBlurLevel ( DWORD pUserData );
- static MonoString* GetName ( DWORD pUserData );
- static MonoString* GetIP ( DWORD pUserData );
- static DWORD GetAccount ( DWORD pUserData );
- static MonoString* GetVersion ( DWORD pUserData );
- static MonoObject* GetACInfo ( DWORD pUserData );
- static MonoString* GetPlayerAnnounceValue ( DWORD pElement, MonoString* msKey );
-
- // Player set functions
- static bool SetMoney ( DWORD pUserData, int iAmount, bool bInstant );
- static bool GiveMoney ( DWORD pUserData, int iAmount );
- static bool TakeMoney ( DWORD pUserData, int iAmount );
- static bool Spawn ( DWORD pUserData, MonoObject* vecPosition, int iRotation, int iSkinID, int iInterior, int iDimension, DWORD pTeam );
- static bool ShowHudComponent ( DWORD pUserData, MonoString* sComponent, bool bShow );
- static bool SetWantedLevel ( DWORD pUserData, int iLevel );
- static bool ForceMap ( DWORD pUserData, bool bForceOn );
- static bool SetNametagText ( DWORD pUserData, MonoString* sText );
- static bool SetNametagColor ( DWORD pUserData, int iRed, int iGreen, int iBlue );
- static bool SetNametagShowing ( DWORD pUserData, bool bShowing );
- static bool SetMuted ( DWORD pUserData, bool bMuted );
- static bool SetBlurLevel ( DWORD pUserData, int iLevel );
- static bool Redirect ( DWORD pUserData, MonoString* sServerIP, int iServerPort, MonoString* sServerPassword );
- static bool SetName ( DWORD pUserData, MonoString* sName );
- static bool DetonateSatchels ( DWORD pUserData );
- static bool TakeScreenShot ( DWORD pUserData, int iWidth, int iHeight, MonoString* sTag, int iQuality, int iMaxBandwith );
- static bool SetTeam ( DWORD pUserData, DWORD pTeam );
- static bool SetPlayerAnnounceValue ( DWORD pElement, MonoString* msKey, MonoString* msValue );
-
- // Input funcs
- static bool BindKey ( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName, MonoString* msArguments );
- static bool UnbindKey ( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName );
- static bool GetControlState ( DWORD pUserData, MonoString* msControl );
- static bool IsControlEnabled ( DWORD pUserData, MonoString* msControl );
-
- static bool SetControlState ( DWORD pUserData, MonoString* msControl, bool bState );
- static bool ToggleControl ( DWORD pUserData, MonoString* msControl, bool bEnabled );
- static bool ToggleAllControls ( DWORD pUserData, bool bGTAControls, bool bMTAControls, bool bEnabled );
-
- // Log in/out funcs
- static bool LogIn ( DWORD pPlayer, DWORD pAccount, MonoString* msPassword );
- static bool LogOut ( DWORD pPlayer );
-
- // Admin funcs
- static bool Kick ( DWORD pPlayer, MonoString* msResponsible, MonoString* msReason );
- static DWORD Ban ( DWORD pPlayer, bool bIP, bool bUsername, bool bSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban );
-
- // Cursor get funcs
- static bool IsCursorShowing ( DWORD pPlayer );
-
- // Cursor set funcs
- static bool ShowCursor ( DWORD pPlayer, bool bShow, bool bToggleControls );
-
- // Chat funcs
- static bool ShowChat ( DWORD pPlayer, bool bShow );
-
- // Camera get functions
- static MonoObject* GetCameraMatrix ( DWORD pPlayer );
- static DWORD GetCameraTarget ( DWORD pPlayer );
- static unsigned char GetCameraInterior ( DWORD pPlayer );
-
- // Camera set functions
- static bool SetCameraMatrix ( DWORD pPlayer, MonoObject* pCameraMatrix );
- static bool SetCameraTarget ( DWORD pPlayer, DWORD pTarget );
- static bool SetCameraInterior ( DWORD pPlayer, unsigned char ucInterior );
- static bool FadeCamera ( DWORD pPlayer, bool bFadeIn, float fFadeTime, MonoObject* pColor );
- };
-
- class Ped
- {
- public:
- // Ped get functions
- static DWORD Create ( int iModelid, MonoObject* pMonoPosition, float fRot, bool bSynced );
- static float GetArmor ( DWORD pUserData );
- static bool IsChoking ( DWORD pUserData );
- static bool IsDead ( DWORD pUserData );
- static bool IsDucked ( DWORD pUserData );
- static float GetStat ( DWORD pUserData, unsigned short usStat );
- static DWORD GetTarget ( DWORD pUserData );
- static int GetWeapon ( DWORD pUserData, int iWeaponSlot );
- static MonoString* GetClothesTexture ( DWORD pUserData, unsigned char ucType );
- static MonoString* GetClothesModel ( DWORD pUserData, unsigned char ucType );
- static bool DoesHaveJetPack ( DWORD pUserData );
- static bool IsOnGround ( DWORD pUserData );
- static unsigned char GetFightingStyle ( DWORD pUserData );
- static unsigned int GetMoveAnim ( DWORD pUserData );
- static float GetGravity ( DWORD pUserData );
- static DWORD GetContactElement ( DWORD pUserData );
- static unsigned char GetWeaponSlot ( DWORD pUserData );
- static bool IsDoingGangDriveby ( DWORD pUserData );
- static bool IsOnFire ( DWORD pUserData );
- static bool IsHeadless ( DWORD pUserData );
- static bool IsFrozen ( DWORD pUserData );
- static DWORD GetOccupiedVehicle ( DWORD pUserData );
- static unsigned int GetOccupiedVehicleSeat ( DWORD pUserData );
- static bool IsInVehicle ( DWORD pUserData );
- static short GetWeaponProperty ( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty );
- static short GetOriginalWeaponProperty ( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty );
-
- // Ped set functions
- static bool SetArmor ( DWORD pUserData, float fArmor );
- static bool Kill ( DWORD pUserData, DWORD pKiller, unsigned char ucKillerWeapon, unsigned char ucBodyPart, bool bStealth );
- static bool SetStat ( DWORD pUserData, unsigned short usStat, float fValue );
- static bool AddClothes ( DWORD pUserData, MonoString* msTexture, MonoString* msModel, unsigned char ucType );
- static bool RemoveClothes ( DWORD pUserData, unsigned char ucType, MonoString* msTexture, MonoString* msModel );
- static bool GiveJetPack ( DWORD pUserData );
- static bool RemoveJetPack ( DWORD pUserData );
- static bool SetFightingStyle ( DWORD pUserData, unsigned char ucStyle );
- static bool SetMoveAnim ( DWORD pUserData, unsigned int iMoveAnim );
- static bool SetGravity ( DWORD pUserData, float fGravity );
- static bool SetChoking ( DWORD pUserData, bool bChoking );
- static bool SetWeaponSlot ( DWORD pUserData, unsigned char ucWeaponSlot );
- static bool WarpIntoVehicle ( DWORD pUserData, DWORD pVehicle, unsigned int uiSeat );
- static bool RemoveFromVehicle ( DWORD pUserData );
- static bool SetDoingGangDriveby ( DWORD pUserData, bool bGangDriveby );
- static bool SetAnimation ( DWORD pUserData, MonoString* msBlockName, MonoString* msAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame );
- static bool SetAnimationProgress ( DWORD pUserData, MonoString* msAnimName, float fProgress );
- static bool SetOnFire ( DWORD pUserData, bool bIsOnFire );
- static bool SetHeadless ( DWORD pUserData, bool bIsHeadless );
- static bool SetFrozen ( DWORD pUserData, bool bIsFrozen );
- static bool ReloadWeapon ( DWORD pUserData );
- static bool SetWeaponProperty ( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty, short uData );
-
- // Ped body?
- static MonoString* GetBodyPartName ( unsigned char ucID );
- static MonoArray* GetClothesByTypeIndex ( unsigned char ucType, unsigned char ucIndex );
- static MonoArray* GetTypeIndexFromClothes ( MonoString* msTexture, MonoString* msModel );
- static MonoString* GetClothesTypeName ( unsigned char ucType );
-
- // Weapon give/take functions
- static bool GiveWeapon ( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, bool bSetAsCurrent = false );
- static bool TakeWeapon ( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo = 9999 );
- static bool TakeAllWeapons ( DWORD pPed );
- static bool SetWeaponAmmo ( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, unsigned short usAmmoInClip );
- };
-
- class Vehicle
- {
- public:
- // Vehicle create/destroy functions
- static DWORD Create ( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 );
-
- // Vehicle get functions
- static MonoString* GetType ( DWORD pUserData );
- static MonoArray* GetVariant ( DWORD pUserData );
- static MonoObject* GetColor ( DWORD pUserData );
- static unsigned short GetModelFromName ( MonoString* msName );
- static bool GetLandingGearDown ( DWORD pUserData );
- static unsigned char GetMaxPassengers ( DWORD pUserData );
- static MonoString* GetName ( DWORD pUserData );
- static MonoString* GetNameFromModel ( unsigned short usModel );
- static DWORD GetOccupant ( DWORD pUserData, unsigned int uiSeat );
- static MonoArray* GetOccupants ( DWORD pUserData );
- static DWORD GetController ( DWORD pUserData );
- static bool GetSirensOn ( DWORD pUserData );
- static MonoObject* GetTurnVelocity ( DWORD pUserData );
- static MonoObject* GetTurretPosition ( DWORD pUserData );
- static bool IsLocked ( DWORD pUserData );
- static MonoArray* GetOfType ( unsigned int uiModel );
- static unsigned short GetUpgradeOnSlot ( DWORD pUserData, unsigned char ucSlot );
- static MonoArray* GetUpgrades ( DWORD pUserData );
-// static MonoString* GetUpgradeSlotName ( unsigned char ucSlot );
- static MonoString* GetUpgradeSlotName ( unsigned short usUpgrade );
- static MonoArray* GetCompatibleUpgrades ( DWORD pUserData );
- static unsigned char GetDoorState ( DWORD pUserData, unsigned char ucDoor );
- static MonoObject* GetWheelStates ( DWORD pUserData );
- static unsigned char GetLightState ( DWORD pUserData, unsigned char ucLight );
- static unsigned char GetPanelState ( DWORD pUserData, unsigned char ucPanel );
- static unsigned char GetOverrideLights ( DWORD pUserData );
- static DWORD GetTowedByVehicle ( DWORD pUserData );
- static DWORD GetTowingVehicle ( DWORD pUserData );
- static unsigned char GetPaintjob ( DWORD pUserData );
- static MonoString* GetPlateText ( DWORD pUserData );
- static bool IsDamageProof ( DWORD pUserData );
- static bool IsFuelTankExplodable ( DWORD pUserData );
- static bool IsFrozen ( DWORD pUserData );
- static bool IsOnGround ( DWORD pUserData );
- static bool GetEngineState ( DWORD pUserData );
- static bool IsTrainDerailed ( DWORD pUserData );
- static bool IsTrainDerailable ( DWORD pUserData );
- static bool GetTrainDirection ( DWORD pUserData );
- static float GetTrainSpeed ( DWORD pUserData );
- static bool IsBlown ( DWORD pUserData );
- static MonoObject* GetHeadLightColor ( DWORD pUserData );
- static float GetDoorOpenRatio ( DWORD pUserData, unsigned char ucDoor );
- static bool IsTaxiLightOn ( DWORD pUserData );
-
- // Vehicle set functions
- static bool Fix ( DWORD pUserData );
- static bool Blow ( DWORD pUserData, bool bExplode );
- static bool SetTurnVelocity ( DWORD pUserData, MonoObject* pVelocity );
- static bool SetColor ( DWORD pUserData, MonoObject* pColor1, MonoObject* pColor2, MonoObject* pColor3, MonoObject* pColor4 );
- static bool SetLandingGearDown ( DWORD pUserData, bool bLandingGearDown );
- static bool SetLocked ( DWORD pUserData, bool bLocked );
- static bool SetDoorsUndamageable ( DWORD pUserData, bool bDoorsUndamageable );
- static bool SetSirensOn ( DWORD pUserData, bool bSirensOn );
- static bool SetTaxiLightOn ( DWORD pUserData, bool bTaxiLightState );
- static bool AddUpgrade ( DWORD pUserData, unsigned short usUpgrade );
- static bool RemoveUpgrade ( DWORD pUserData, unsigned short usUpgrade );
- static bool SetDoorState ( DWORD pUserData, unsigned char ucDoor, unsigned char ucState );
- static bool SetWheelStates ( DWORD pUserData, int iFrontLeft, int iRearLeft, int iFrontRight, int iRearRight );
- static bool SetLightState ( DWORD pUserData, unsigned char ucLight, unsigned char ucState );
- static bool SetPanelState ( DWORD pUserData, unsigned char ucPanel, unsigned char ucState );
- static bool SetIdleRespawnDelay ( DWORD pUserData, unsigned long ulTime );
- static bool SetRespawnDelay ( DWORD pUserData, unsigned long ulTime );
- static bool SetRespawnPosition ( DWORD pUserData, MonoObject* pPosition, MonoObject* pRotation );
- static bool ToggleRespawn ( DWORD pUserData, bool bRespawn );
- static bool ResetExplosionTime ( DWORD pUserData );
- static bool ResetIdleTime ( DWORD pUserData );
- static bool Spawn ( DWORD pUserData, MonoObject* pPosition, MonoObject* pRotation );
- static bool Respawn ( DWORD pUserData );
- static bool SetOverrideLights ( DWORD pUserData, unsigned char ucLights );
- static bool AttachTrailer ( DWORD pUserData, DWORD pTrailer );
- static bool DetachTrailer ( DWORD pUserData, DWORD pTrailer );
- static bool SetEngineState ( DWORD pUserData, bool bState );
- static bool SetDirtLevel ( DWORD pUserData, float fDirtLevel );
- static bool SetDamageProof ( DWORD pUserData, bool bDamageProof );
- static bool SetPaintjob ( DWORD pUserData, unsigned char ucPaintjob );
- static bool SetFuelTankExplodable ( DWORD pUserData, bool bExplodable );
- static bool SetTrainDerailed ( DWORD pUserData, bool bDerailed );
- static bool SetTrainDerailable ( DWORD pUserData, bool bDerailable );
- static bool SetTrainDirection ( DWORD pUserData, bool bDireciton );
- static bool SetTrainSpeed ( DWORD pUserData, float fSpeed );
- static bool SetHeadLightColor ( DWORD pUserData, MonoObject* pColor );
- static bool SetTurretPosition ( DWORD pUserData, MonoObject* pPosition );
- static bool SetDoorOpenRatio ( DWORD pUserData, unsigned char ucDoor, float fRatio, unsigned long ulTime );
- static bool SetVariant ( DWORD pUserData, unsigned char ucVariant, unsigned char ucVariant2 );
- static bool GiveSirens ( DWORD pUserData, unsigned char ucSirenType, unsigned char ucSirenCount, bool bFlag360 = false, bool bCheckLosFlag = true, bool bUseRandomiserFlag = true, bool bSilentFlag = false );
- static bool RemoveSirens ( DWORD pUserData );
- static bool SetSirens ( DWORD pUserData, unsigned char ucSirenID, MonoObject* pPosition, MonoObject* pColor, float fMinAlpha );
- static MonoArray* GetSirens ( DWORD pUserData );
- static MonoObject* GetSirenParams ( DWORD pUserData );
- static bool SetPlateText ( DWORD pUserData, MonoString* msName );
- };
-
- class Marker
- {
- public:
- // Marker create/destroy functions
- static DWORD Create ( MonoObject* pPosition, MonoString* szType, float fSize, MonoObject* color, DWORD pVisibleTo );
-
- // Marker get functions
- static unsigned int GetCount ();
- static MonoString* GetType ( DWORD pUserData );
- static float GetSize ( DWORD pUserData );
- static MonoObject* GetColor ( DWORD pUserData );
- static MonoObject* GetTarget ( DWORD pUserData );
- static MonoString* GetIcon ( DWORD pUserData );
-
- // Marker set functions
- static bool SetType ( DWORD pUserData, MonoString* szType );
- static bool SetSize ( DWORD pUserData, float fSize );
- static bool SetColor ( DWORD pUserData, MonoObject* color );
- static bool SetTarget ( DWORD pUserData, MonoObject* pTarget );
- static bool SetIcon ( DWORD pUserData, MonoString* szIcon );
- };
-
- class Blip
- {
- public:
- // Blip create/destroy functions
- static DWORD Create ( MonoObject* vecPosition, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo );
- static DWORD CreateAttachedTo ( DWORD pTarget, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo );
-
- // Blip get functions
- static unsigned char GetIcon ( DWORD pUserData );
- static unsigned char GetSize ( DWORD pUserData );
- static MonoObject* GetColor ( DWORD pUserData );
- static short GetOrdering ( DWORD pUserData );
- static unsigned short GetVisibleDistance ( DWORD pUserData );
-
- // Blip set functions
- static bool SetIcon ( DWORD pUserData, unsigned char ucIcon );
- static bool SetSize ( DWORD pUserData, unsigned char ucSize );
- static bool SetColor ( DWORD pUserData, MonoObject* color );
- static bool SetOrdering ( DWORD pUserData, short sOrdering );
- static bool SetVisibleDistance ( DWORD pUserData, unsigned short usVisibleDistance );
- };
-
- class Object
- {
- public:
- // Object create/destroy functions
- static DWORD Create ( unsigned short usModelID, MonoObject* pPosition, MonoObject* pRotation, bool bIsLowLod );
-
- // Object get functions
- static MonoObject* GetScale ( DWORD pUserData );
-
- // Object set functions
- static bool SetScale ( DWORD pUserData, MonoObject* pScale );
- static bool Move ( DWORD pUserData, unsigned long ulTime, MonoObject* pPosition, MonoObject* pRotation, MonoString* msEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot );
- static bool Stop ( DWORD pUserData );
- };
-
- class RadarArea
- {
- public:
- // Radar area create/destroy funcs
- static DWORD Create ( MonoObject* pPosition, MonoObject* pSize, MonoObject* pColor, DWORD pVisibleTo );
-
- // Radar area get funcs
- static MonoObject* GetSize ( DWORD pUserData );
- static MonoObject* GetColor ( DWORD pUserData );
- static bool IsFlashing ( DWORD pUserData );
- static bool IsInside ( DWORD pUserData, MonoObject* pPosition );
-
- // Radar area set funcs
- static bool SetSize ( DWORD pUserData, MonoObject* pSize );
- static bool SetColor ( DWORD pUserData, MonoObject* pColor );
- static bool SetFlashing ( DWORD pUserData, bool bFlashing );
- };
-
- class Pickup
- {
- public:
- // Pickup create/destroy funcs
- static DWORD Create ( MonoObject* pPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval, double dSix );
-
- // Pickup get funcs
- static unsigned char GetType ( DWORD pUserData );
- static unsigned char GetWeapon ( DWORD pUserData );
- static float GetAmount ( DWORD pUserData );
- static unsigned short GetAmmo ( DWORD pUserData );
- static unsigned long GetRespawnInterval ( DWORD pUserData );
- static bool IsSpawned ( DWORD pUserData );
-
- // Pickup set funcs
- static bool SetType ( DWORD pUserData, unsigned char ucType, double dThree, double dFour );
- static bool SetRespawnInterval ( DWORD pUserData, unsigned long ulInterval );
- static bool Use ( DWORD pUserData, DWORD pPlayer );
- };
-
- class Shape
- {
- public:
- // Shape create funcs
- static DWORD CreateCircle ( MonoObject* pPosition, float fRadius );
- static DWORD CreateCuboid ( MonoObject* pPosition, MonoObject* vecSize );
- static DWORD CreateSphere ( MonoObject* pPosition, float fRadius );
- static DWORD CreateRectangle ( MonoObject* pPosition, MonoObject* vecSize );
- static DWORD CreatePolygon ( MonoArray* vecPointList );
- static DWORD CreateTube ( MonoObject* pPosition, float fRadius, float fHeight );
- };
-
- class Explosion
- {
- public:
- // Explosion funcs
- static bool Create ( MonoObject* pPosition, unsigned char ucType, DWORD pCreator );
- };
-
- class Audio
- {
- public:
- // Audio funcs
- static bool PlayFrontEnd ( DWORD pUserData, unsigned char ucSound );
- static bool PlayMission ( DWORD pUserData, MonoObject* vecPosition, unsigned short usSlot );
- };
-
- class Team
- {
- public:
- // Team get funcs
- static DWORD Create ( MonoString* msTeamName, MonoObject* pColor );
- static DWORD GetFromName ( MonoString* msTeamName );
- static MonoString* GetName ( DWORD pUserData );
- static MonoObject* GetColor ( DWORD pUserData );
- static unsigned int CountPlayers ( DWORD pUserData );
- static bool GetFriendlyFire ( DWORD pUserData );
-
- // Team set funcs
- static bool SetName ( DWORD pUserData, MonoString* msTeamName );
- static bool SetColor ( DWORD pUserData, MonoObject* pColor );
- static bool SetFriendlyFire ( DWORD pUserData, bool bFriendlyFire );
- };
-
- class Water
- {
- public:
- // Water funcs
- static DWORD Create ( MonoObject* pV1, MonoObject* pV2, MonoObject* pV3, MonoObject* pV4, bool bShallow );
- static bool SetLevel ( DWORD pUserData, float fLevel );
- static bool SetLevelAll ( float fLevel );
- static bool SetLevelWorld ( float fLevel, bool bIncludeWorldNonSeaLevel );
- static bool ResetLevelWorld ( void );
- static MonoObject* GetVertexPosition ( DWORD pUserData, int iVertexIndex );
- static bool SetVertexPosition ( DWORD pUserData, int iVertexIndex, MonoObject* vecPosition );
- static MonoObject* GetColor ( void );
- static bool SetColor ( MonoObject* pColor );
- static bool ResetColor ( void );
- };
-
- class World
- {
- public:
- // General world get funcs
- static MonoArray* GetTime ( void );
- static MonoArray* GetWeather ( void );
- static MonoString* GetZoneName ( MonoObject* vecPosition, bool bCitiesOnly );
- static float GetGravity ( void );
- static float GetGameSpeed ( void );
- static float GetWaveHeight ( void );
- static unsigned short GetFPSLimit ( void );
- static unsigned long GetMinuteDuration ( void );
- static bool IsGarageOpen ( unsigned char ucGarageID );
- static unsigned char GetTrafficLightState ( void );
- static bool GetTrafficLightsLocked ( void );
- static float GetJetpackMaxHeight ( void );
- static float GetAircraftMaxVelocity ( void );
- static bool GetInteriorSoundsEnabled ( void );
- static float GetRainLevel ( void );
- static float GetSunSize ( void );
- static MonoArray* GetSunColor ( void );
- static MonoObject* GetWindVelocity ( void );
- static float GetFarClipDistance ( void );
- static float GetFogDistance ( void );
- static float GetAircraftMaxHeight ( void );
- static bool GetOcclusionsEnabled ( void );
- static int GetMoonSize ( void );
- static MonoArray* GetSkyGradient ( void );
- static MonoObject* GetHeatHaze ( void );
- static bool GetJetpackWeaponEnabled ( unsigned int uiWeaponType );
- static bool GetCloudsEnabled ( void );
-
- // General world set funcs
- static bool SetTime ( unsigned char ucHour, unsigned char ucMinute );
- static bool SetWeather ( unsigned char ucWeather );
- static bool SetWeatherBlended ( unsigned char ucWeather );
- static bool SetGravity ( float fGravity );
- static bool SetGameSpeed ( float fSpeed );
- static bool SetWaveHeight ( float fHeight );
- static bool SetSkyGradient ( MonoObject* pTopColor, MonoObject* pBottomColor );
- static bool ResetSkyGradient ( void );
- static bool SetHeatHaze ( MonoObject* heatHazeSettings );
- static bool ResetHeatHaze ( void );
- static bool SetFPSLimit ( unsigned short usLimit, bool bSave );
- static bool SetMinuteDuration ( unsigned long ulDuration );
- static bool SetGarageOpen ( unsigned char ucGarageID, bool bIsOpen );
- static bool SetGlitchEnabled ( MonoString* msGlitchName, bool bEnabled );
- static bool IsGlitchEnabled ( MonoString* msGlitchName );
- static bool SetJetpackWeaponEnabled ( unsigned int uiWeaponType, bool bEnabled );
- static bool SetCloudsEnabled ( bool bEnabled );
- static bool SetTrafficLightState ( unsigned char ucState, bool bForced = false );
- static bool SetTrafficLightsLocked ( bool bLocked );
- static bool SetJetpackMaxHeight ( float fMaxHeight );
- static bool SetInteriorSoundsEnabled ( bool bEnable );
- static bool SetRainLevel ( float fRainLevel );
- static bool SetSunSize ( float fSunSize );
- static bool SetSunColor ( MonoObject* pCoreColor, MonoObject* pCoronaColor );
- static bool SetWindVelocity ( MonoObject* pVelocity );
- static bool SetFarClipDistance ( float fFarClip );
- static bool SetFogDistance ( float fFogDist );
- static bool SetAircraftMaxHeight ( float fMaxHeight );
- static bool SetAircraftMaxVelocity ( float fVelocity );
- static bool SetOcclusionsEnabled ( bool bEnabled );
- static bool ResetRainLevel ( void );
- static bool ResetSunSize ( void );
- static bool ResetSunColor ( void );
- static bool ResetWindVelocity ( void );
- static bool ResetFarClipDistance ( void );
- static bool ResetFogDistance ( void );
- static bool RemoveWorldModel ( unsigned short usModel, float fRadius, MonoObject* vecPosition, char cInterior );
- static bool RestoreWorldModel ( unsigned short usModel, float fRadius, MonoObject* vecPosition, char cInterior );
- static bool RestoreAllWorldModels ( void );
- static bool SetMoonSize ( int iMoonSize );
- static bool ResetMoonSize ( void );
- };
-
- class Account
- {
- public:
- // Account get funcs
- static DWORD Get ( MonoString* msName, MonoString* msPassword );
- static MonoArray* GetAll ( void );
- static DWORD GetPlayer ( DWORD pAccount );
- static bool IsGuest ( DWORD pAccount );
- // static CLuaArgument* GetData ( DWORD pAccount, MonoString* szKey );
- // static MonoArray* GetAllData ( DWORD pAccount );
- static MonoString* GetSerial ( DWORD pAccount );
- // static MonoArray* GetBySerial ( MonoString* msSerial );
-
- // Account set funcs
- static DWORD Add ( MonoString* msName, MonoString* msPassword );
- static bool Remove ( DWORD pAccount );
- static bool SetPassword ( DWORD pAccount, MonoString* msPassword );
- // static bool SetData ( DWORD pAccount, MonoString* msKey, CLuaArgument* pArgument );
- static bool CopyData ( DWORD pAccount, DWORD pFromAccount );
- };
-
- class Ban
- {
- public:
- static DWORD Add ( MonoString* msIP, MonoString* msUsername, MonoString* msSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban );
- static bool Remove ( DWORD pBan, DWORD pResponsible );
-
- // static MonoArray* GetBans ( void );
- static bool Reload ( void );
-
- static MonoString* GetIP ( DWORD pBan );
- static MonoString* GetSerial ( DWORD pBan );
- static MonoString* GetUsername ( DWORD pBan );
- static MonoString* GetNick ( DWORD pBan );
- static MonoString* GetReason ( DWORD pBan );
- static MonoString* GetAdmin ( DWORD pBan );
-
- static int GetBanTime ( DWORD pBan );
- static int GetUnbanTime ( DWORD pBan );
-
- static bool SetUnbanTime ( DWORD pBan, int time );
- static bool SetReason ( DWORD pBan, MonoString* msReason );
- static bool SetAdmin ( DWORD pBan, MonoString* msAdminName );
- };
-
- class Resource
- {
- public:
- // Resource funcs
- static DWORD Create ( MonoString* msResourceName, MonoString* msOrganizationalDir );
- static DWORD Copy ( DWORD pResource, MonoString* msNewResourceName, MonoString* msOrganizationalDir );
- static DWORD GetRootElement ( DWORD pResource = NULL );
- static DWORD GetMapRootElement ( DWORD pResource, MonoString* msMap );
- static DWORD GetDynamicElementRoot ( DWORD pResource );
- // static CXMLNode* AddMap ( MonoString* msFilePath, MonoString* msMapName, int iDimension );
- // static CXMLNode* AddConfig ( MonoString* msFilePath, MonoString* msConfigName, int iType );
- static bool RemoveFile ( DWORD pResource, MonoString* msFilename );
- // static CXMLNode AddConfig ( MonoString* msFilePath, MonoString* msFileType );
- // static CXMLNode AddMap ( MonoString* msFilePath, unsigned int uiDimension = 0 );
- // static CXMLNode GetConfig ( MonoString* msFilePath );
- // static CLuaArguments* GetExportedFunctions ( DWORD pResource );
- static DWORD GetFromName ( MonoString* msResourceName );
- static MonoString* GetInfo ( DWORD pResource, MonoString* msAttribute );
- static unsigned int GetLastStartTime ( DWORD pResource );
- static MonoString* GetLoadFailureReason ( DWORD pResource );
- static unsigned int GetLoadTime ( DWORD pResource );
- static MonoString* GetName ( DWORD pResource );
- static MonoArray* GetResources ( void );
- static MonoString* GetState ( DWORD pResource );
- static DWORD GetCurrent ( void );
- static bool Refresh ( bool refreshAll = false );
- static bool RemoveDefaultSetting ( DWORD pResource, MonoString* msSettingName );
- static bool Start ( DWORD pResource, bool persistent = false, bool startIncludedResources = true, bool loadServerConfigs = true, bool loadMaps = true, bool loadServerScripts = true, bool loadHTML = true, bool loadClientConfigs = true, bool loadClientScripts = true, bool loadFiles = true );
- static bool Restart ( DWORD pResource );
- static bool Stop ( DWORD pResource );
- static bool SetDefaultSetting ( DWORD pResource, MonoString* msSettingName, MonoString* msSettingValue );
- // static bool SetDefaultSetting ( DWORD pResource, MonoString* msSettingName, int iSettingValue );
- // static bool SetDefaultSetting ( DWORD pResource, MonoString* msSettingName, float fSettingValue );
- static bool SetInfo ( DWORD pResource, MonoString* msAttribute, MonoString* msValue );
- static bool Rename ( MonoString* msResourceName, MonoString* msNewResourceName, MonoString* msOrganizationalPath );
- static bool Delete ( MonoString* msResourceName );
- // static CLuaArguments* GetACLRequests ( DWORD pResource );
- static bool UpdateACLRequest ( DWORD pResource, MonoString* msRightName, bool bAccess, MonoString* msByWho );
- };
-};
-
+/*********************************************************
+*
+* 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 "CResource.h"
+#include "CResourceManager.h"
+
+class CMonoFunctions;
+
+#ifndef __CMONOFUNCTIONS_H
+#define __CMONOFUNCTIONS_H
+
+#include "lua/CLuaFunctionDefinitions.h"
+
+#include "CMonoDomain.h"
+#include "CMonoClass.h"
+#include "CMonoObject.h"
+#include "CMonoCorlib.h"
+#include "CMonoMTALib.h"
+
+extern ILuaModuleManager10 *g_pModuleManager;
+extern CResourceManager *g_pResourceManager;
+
+#define RESOURCE g_pResourceManager->GetFromList( mono_domain_get() )
+
+#define MONO_DECLARE(a,b) mono_add_internal_call("MultiTheftAuto.Native."#a"::"#b,CMonoFunctions::a::b)
+
+class CMonoFunctions
+{
+public:
+ static void AddInternals( void );
+
+ class Debug
+ {
+ public:
+ static void Log ( MonoString *string );
+ static void Info ( MonoString *string );
+ static void Error ( MonoString *string );
+ };
+
+ class Config
+ {
+ public:
+ static MonoString* Get ( MonoString *msKey );
+ static bool Set ( MonoString *msKey, MonoString *msValue );
+ };
+
+ class Server
+ {
+ public:
+ static unsigned int GetMaxPlayers ( void );
+ static bool SetMaxPlayers ( unsigned int uiMax );
+ static bool OutputChatBox ( MonoString* szText, DWORD pElement, MonoObject* pColor, bool bColorCoded );
+ static bool OutputConsole ( MonoString* szText, DWORD pElement );
+ static bool SetPassword ( MonoString* msPassword, bool bSave );
+ static MonoObject* GetVersion ( void );
+
+ static MonoString* GetGameType ( void );
+ static MonoString* GetMapName ( void );
+
+ static bool SetGameType ( MonoString* msGameType );
+ static bool SetMapName ( MonoString* msMapName );
+ static MonoString* GetRuleValue ( MonoString* msKey );
+ static bool SetRuleValue ( MonoString* msKey, MonoString* msValue );
+ static bool RemoveRuleValue ( MonoString* msKey );
+ };
+
+ class Event
+ {
+ public:
+ static bool AddHandler ( MonoString* msName, DWORD pUserData, lua_CFunction iLuaFunction, bool bPropagated, MonoString* msEventPriority );
+ };
+
+ class Element
+ {
+ public:
+ // Element create/destroy
+ static DWORD Create ( MonoString* msTypeName, MonoString* msID );
+ static bool Destroy ( DWORD pUserData );
+ static DWORD Clone ( DWORD pUserData, MonoObject* vecPosition, bool bCloneElement );
+
+ // Element get funcs
+ static DWORD GetRootElement ( void );
+ static MonoArray* GetByType ( MonoString* msType, DWORD pStartElement );
+
+ static bool IsElement ( DWORD pUserData );
+ static MonoString* GetType ( DWORD pUserData );
+ static DWORD GetByID ( MonoString* msID, unsigned int uiIndex );
+ static DWORD GetByIndex ( int iIndex );
+ static DWORD GetChild ( DWORD pUserData, int iIndex );
+ static int GetChildrenCount ( DWORD pUserData );
+ static MonoString* GetID ( DWORD pUserData );
+ static MonoObject* GetData ( DWORD pUserData, MonoString* sKey, bool bInherit = true );
+ static MonoArray* GetAllData ( DWORD pUserData );
+ static unsigned int GetParent ( DWORD pUserData );
+ static MonoObject* GetPosition ( DWORD pUserData );
+ static MonoObject* GetRotation ( DWORD pUserData );
+ static MonoObject* GetVelocity ( DWORD pUserData );
+ static unsigned char GetInterior ( DWORD pUserData );
+ static bool IsWithinColShape ( DWORD pUserData );
+ static bool IsWithinMarker ( DWORD pUserData );
+ static unsigned short GetDimension ( DWORD pUserData );
+ static MonoString* GetZoneName ( DWORD pUserData, bool bCitiesOnly = false );
+ static bool IsAttached ( DWORD pUserData );
+ static DWORD GetAttachedTo ( DWORD pUserData );
+ static DWORD GetColShape ( DWORD pUserData );
+ static unsigned char GetAlpha ( DWORD pUserData );
+ static bool IsDoubleSided ( DWORD pUserData );
+ static float GetHealth ( DWORD pUserData );
+ static unsigned short GetModel ( DWORD pUserData );
+ static bool IsInWater ( DWORD pUserData );
+ static MonoObject* GetAttachedOffsetPosition ( DWORD pUserData );
+ static MonoObject* GetAttachedOffsetRotation ( DWORD pUserData );
+ static DWORD GetSyncer ( DWORD pUserData );
+ static bool GetCollisionsEnabled ( DWORD pUserData );
+ static bool IsFrozen ( DWORD pUserData );
+ static DWORD GetLowLod ( DWORD pUserData );
+ static bool IsLowLod ( DWORD pUserData );
+
+ // Element set funcs
+ static bool ClearVisibleTo ( DWORD pUserData );
+ static bool SetID ( DWORD pUserData, MonoString* msID );
+ static bool SetData ( DWORD pUserData, MonoString* msKey, CLuaArgument& Variable );
+ static bool RemoveData ( DWORD pUserData, MonoString* msKey );
+ static bool SetParent ( DWORD pUserData, DWORD pTarget );
+ static bool SetPosition ( DWORD pUserData, MonoObject* pPosition, bool bWarp );
+ static bool SetRotation ( DWORD pUserData, MonoObject* pRotation, MonoString* msRotationOrder, bool bNewWay );
+ static bool SetVelocity ( DWORD pUserData, MonoObject* pVelocity );
+ static bool SetVisibleTo ( DWORD pUserData, DWORD pTarget, bool bVisible );
+ static bool SetInterior ( DWORD pUserData, int iInterior );
+ static bool SetDimension ( DWORD pUserData, int iDimension );
+ static bool Attach ( DWORD pUserData, DWORD pTarget, MonoObject* pPosition, MonoObject* pRotation );
+ static bool Detach ( DWORD pUserData, DWORD pTarget );
+ static bool SetAlpha ( DWORD pUserData, int iAlpha );
+ static bool SetDoubleSided ( DWORD pUserData, bool bDoubleSided );
+ static bool SetHealth ( DWORD pUserData, float fHealth );
+ static bool SetModel ( DWORD pUserData, int iModel );
+ static bool SetAttachedOffsets ( DWORD pUserData, MonoObject* pPosition, MonoObject* pRotation );
+ static bool SetSyncer ( DWORD pUserData, DWORD pPlayer );
+ static bool SetCollisionsEnabled ( DWORD pUserData, bool bEnabled );
+ static bool SetFrozen ( DWORD pUserData, bool bFrozen );
+ static bool SetLowLod ( DWORD pUserData, bool bEnabled );
+ };
+
+ class Player
+ {
+ public:
+ // Player get functions
+ static unsigned int GetCount ( void );
+ static DWORD GetFromName ( MonoString* msNick );
+ static unsigned int GetPing ( DWORD pUserData );
+ static long GetMoney ( DWORD pUserData );
+ static DWORD GetRandom ( void );
+ static bool IsMuted ( DWORD pUserData );
+ static DWORD GetTeam ( DWORD pUserData );
+ static unsigned int GetWantedLevel ( DWORD pUserData );
+ static MonoArray* GetAlivePlayers ( void );
+ static MonoArray* GetDeadPlayers ( void );
+ static unsigned int GetIdleTime ( DWORD pUserData );
+ static bool IsMapForced ( DWORD pUserData );
+ static MonoString* GetNametagText ( DWORD pUserData );
+ static MonoObject* GetNametagColor ( DWORD pUserData );
+ static bool IsNametagShowing ( DWORD pUserData );
+ static MonoString* GetSerial ( DWORD pUserData );
+ static MonoString* GetUserName ( DWORD pUserData );
+ static unsigned char GetBlurLevel ( DWORD pUserData );
+ static MonoString* GetName ( DWORD pUserData );
+ static MonoString* GetIP ( DWORD pUserData );
+ static DWORD GetAccount ( DWORD pUserData );
+ static MonoString* GetVersion ( DWORD pUserData );
+ static MonoObject* GetACInfo ( DWORD pUserData );
+ static MonoString* GetPlayerAnnounceValue ( DWORD pElement, MonoString* msKey );
+
+ // Player set functions
+ static bool SetMoney ( DWORD pUserData, int iAmount, bool bInstant );
+ static bool GiveMoney ( DWORD pUserData, int iAmount );
+ static bool TakeMoney ( DWORD pUserData, int iAmount );
+ static bool Spawn ( DWORD pUserData, MonoObject* vecPosition, int iRotation, int iSkinID, int iInterior, int iDimension, DWORD pTeam );
+ static bool ShowHudComponent ( DWORD pUserData, MonoString* sComponent, bool bShow );
+ static bool SetWantedLevel ( DWORD pUserData, int iLevel );
+ static bool ForceMap ( DWORD pUserData, bool bForceOn );
+ static bool SetNametagText ( DWORD pUserData, MonoString* sText );
+ static bool SetNametagColor ( DWORD pUserData, int iRed, int iGreen, int iBlue );
+ static bool SetNametagShowing ( DWORD pUserData, bool bShowing );
+ static bool SetMuted ( DWORD pUserData, bool bMuted );
+ static bool SetBlurLevel ( DWORD pUserData, int iLevel );
+ static bool Redirect ( DWORD pUserData, MonoString* sServerIP, int iServerPort, MonoString* sServerPassword );
+ static bool SetName ( DWORD pUserData, MonoString* sName );
+ static bool DetonateSatchels ( DWORD pUserData );
+ static bool TakeScreenShot ( DWORD pUserData, int iWidth, int iHeight, MonoString* sTag, int iQuality, int iMaxBandwith );
+ static bool SetTeam ( DWORD pUserData, DWORD pTeam );
+ static bool SetPlayerAnnounceValue ( DWORD pElement, MonoString* msKey, MonoString* msValue );
+
+ // Input funcs
+ static bool BindKey ( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName, MonoString* msArguments );
+ static bool UnbindKey ( DWORD pUserData, MonoString* msKey, MonoString* msHitState, MonoString* msCommandName );
+ static bool GetControlState ( DWORD pUserData, MonoString* msControl );
+ static bool IsControlEnabled ( DWORD pUserData, MonoString* msControl );
+
+ static bool SetControlState ( DWORD pUserData, MonoString* msControl, bool bState );
+ static bool ToggleControl ( DWORD pUserData, MonoString* msControl, bool bEnabled );
+ static bool ToggleAllControls ( DWORD pUserData, bool bGTAControls, bool bMTAControls, bool bEnabled );
+
+ // Log in/out funcs
+ static bool LogIn ( DWORD pPlayer, DWORD pAccount, MonoString* msPassword );
+ static bool LogOut ( DWORD pPlayer );
+
+ // Admin funcs
+ static bool Kick ( DWORD pPlayer, MonoString* msResponsible, MonoString* msReason );
+ static DWORD Ban ( DWORD pPlayer, bool bIP, bool bUsername, bool bSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban );
+
+ // Cursor get funcs
+ static bool IsCursorShowing ( DWORD pPlayer );
+
+ // Cursor set funcs
+ static bool ShowCursor ( DWORD pPlayer, bool bShow, bool bToggleControls );
+
+ // Chat funcs
+ static bool ShowChat ( DWORD pPlayer, bool bShow );
+
+ // Camera get functions
+ static MonoObject* GetCameraMatrix ( DWORD pPlayer );
+ static DWORD GetCameraTarget ( DWORD pPlayer );
+ static unsigned char GetCameraInterior ( DWORD pPlayer );
+
+ // Camera set functions
+ static bool SetCameraMatrix ( DWORD pPlayer, MonoObject* pCameraMatrix );
+ static bool SetCameraTarget ( DWORD pPlayer, DWORD pTarget );
+ static bool SetCameraInterior ( DWORD pPlayer, unsigned char ucInterior );
+ static bool FadeCamera ( DWORD pPlayer, bool bFadeIn, float fFadeTime, MonoObject* pColor );
+ };
+
+ class Ped
+ {
+ public:
+ // Ped get functions
+ static DWORD Create ( int iModelid, MonoObject* pMonoPosition, float fRot, bool bSynced );
+ static float GetArmor ( DWORD pUserData );
+ static bool IsChoking ( DWORD pUserData );
+ static bool IsDead ( DWORD pUserData );
+ static bool IsDucked ( DWORD pUserData );
+ static float GetStat ( DWORD pUserData, unsigned short usStat );
+ static DWORD GetTarget ( DWORD pUserData );
+ static int GetWeapon ( DWORD pUserData, int iWeaponSlot );
+ static MonoString* GetClothesTexture ( DWORD pUserData, unsigned char ucType );
+ static MonoString* GetClothesModel ( DWORD pUserData, unsigned char ucType );
+ static bool DoesHaveJetPack ( DWORD pUserData );
+ static bool IsOnGround ( DWORD pUserData );
+ static unsigned char GetFightingStyle ( DWORD pUserData );
+ static unsigned int GetMoveAnim ( DWORD pUserData );
+ static float GetGravity ( DWORD pUserData );
+ static DWORD GetContactElement ( DWORD pUserData );
+ static unsigned char GetWeaponSlot ( DWORD pUserData );
+ static bool IsDoingGangDriveby ( DWORD pUserData );
+ static bool IsOnFire ( DWORD pUserData );
+ static bool IsHeadless ( DWORD pUserData );
+ static bool IsFrozen ( DWORD pUserData );
+ static DWORD GetOccupiedVehicle ( DWORD pUserData );
+ static unsigned int GetOccupiedVehicleSeat ( DWORD pUserData );
+ static bool IsInVehicle ( DWORD pUserData );
+ static short GetWeaponProperty ( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty );
+ static short GetOriginalWeaponProperty ( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty );
+
+ // Ped set functions
+ static bool SetArmor ( DWORD pUserData, float fArmor );
+ static bool Kill ( DWORD pUserData, DWORD pKiller, unsigned char ucKillerWeapon, unsigned char ucBodyPart, bool bStealth );
+ static bool SetStat ( DWORD pUserData, unsigned short usStat, float fValue );
+ static bool AddClothes ( DWORD pUserData, MonoString* msTexture, MonoString* msModel, unsigned char ucType );
+ static bool RemoveClothes ( DWORD pUserData, unsigned char ucType, MonoString* msTexture, MonoString* msModel );
+ static bool GiveJetPack ( DWORD pUserData );
+ static bool RemoveJetPack ( DWORD pUserData );
+ static bool SetFightingStyle ( DWORD pUserData, unsigned char ucStyle );
+ static bool SetMoveAnim ( DWORD pUserData, unsigned int iMoveAnim );
+ static bool SetGravity ( DWORD pUserData, float fGravity );
+ static bool SetChoking ( DWORD pUserData, bool bChoking );
+ static bool SetWeaponSlot ( DWORD pUserData, unsigned char ucWeaponSlot );
+ static bool WarpIntoVehicle ( DWORD pUserData, DWORD pVehicle, unsigned int uiSeat );
+ static bool RemoveFromVehicle ( DWORD pUserData );
+ static bool SetDoingGangDriveby ( DWORD pUserData, bool bGangDriveby );
+ static bool SetAnimation ( DWORD pUserData, MonoString* msBlockName, MonoString* msAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame );
+ static bool SetAnimationProgress ( DWORD pUserData, MonoString* msAnimName, float fProgress );
+ static bool SetOnFire ( DWORD pUserData, bool bIsOnFire );
+ static bool SetHeadless ( DWORD pUserData, bool bIsHeadless );
+ static bool SetFrozen ( DWORD pUserData, bool bIsFrozen );
+ static bool ReloadWeapon ( DWORD pUserData );
+ static bool SetWeaponProperty ( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty, short uData );
+
+ // Ped body?
+ static MonoString* GetBodyPartName ( unsigned char ucID );
+ static MonoArray* GetClothesByTypeIndex ( unsigned char ucType, unsigned char ucIndex );
+ static MonoArray* GetTypeIndexFromClothes ( MonoString* msTexture, MonoString* msModel );
+ static MonoString* GetClothesTypeName ( unsigned char ucType );
+
+ // Weapon give/take functions
+ static bool GiveWeapon ( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, bool bSetAsCurrent = false );
+ static bool TakeWeapon ( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo = 9999 );
+ static bool TakeAllWeapons ( DWORD pPed );
+ static bool SetWeaponAmmo ( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, unsigned short usAmmoInClip );
+ };
+
+ class Vehicle
+ {
+ public:
+ // Vehicle create/destroy functions
+ static DWORD Create ( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction = false, int variant1 = 255, int variant2 = 255 );
+
+ // Vehicle get functions
+ static MonoString* GetType ( DWORD pUserData );
+ static MonoArray* GetVariant ( DWORD pUserData );
+ static MonoObject* GetColor ( DWORD pUserData );
+ static unsigned short GetModelFromName ( MonoString* msName );
+ static bool GetLandingGearDown ( DWORD pUserData );
+ static unsigned char GetMaxPassengers ( DWORD pUserData );
+ static MonoString* GetName ( DWORD pUserData );
+ static MonoString* GetNameFromModel ( unsigned short usModel );
+ static DWORD GetOccupant ( DWORD pUserData, unsigned int uiSeat );
+ static MonoArray* GetOccupants ( DWORD pUserData );
+ static DWORD GetController ( DWORD pUserData );
+ static bool GetSirensOn ( DWORD pUserData );
+ static MonoObject* GetTurnVelocity ( DWORD pUserData );
+ static MonoObject* GetTurretPosition ( DWORD pUserData );
+ static bool IsLocked ( DWORD pUserData );
+ static MonoArray* GetOfType ( unsigned int uiModel );
+ static unsigned short GetUpgradeOnSlot ( DWORD pUserData, unsigned char ucSlot );
+ static MonoArray* GetUpgrades ( DWORD pUserData );
+// static MonoString* GetUpgradeSlotName ( unsigned char ucSlot );
+ static MonoString* GetUpgradeSlotName ( unsigned short usUpgrade );
+ static MonoArray* GetCompatibleUpgrades ( DWORD pUserData );
+ static unsigned char GetDoorState ( DWORD pUserData, unsigned char ucDoor );
+ static MonoObject* GetWheelStates ( DWORD pUserData );
+ static unsigned char GetLightState ( DWORD pUserData, unsigned char ucLight );
+ static unsigned char GetPanelState ( DWORD pUserData, unsigned char ucPanel );
+ static unsigned char GetOverrideLights ( DWORD pUserData );
+ static DWORD GetTowedByVehicle ( DWORD pUserData );
+ static DWORD GetTowingVehicle ( DWORD pUserData );
+ static unsigned char GetPaintjob ( DWORD pUserData );
+ static MonoString* GetPlateText ( DWORD pUserData );
+ static bool IsDamageProof ( DWORD pUserData );
+ static bool IsFuelTankExplodable ( DWORD pUserData );
+ static bool IsFrozen ( DWORD pUserData );
+ static bool IsOnGround ( DWORD pUserData );
+ static bool GetEngineState ( DWORD pUserData );
+ static bool IsTrainDerailed ( DWORD pUserData );
+ static bool IsTrainDerailable ( DWORD pUserData );
+ static bool GetTrainDirection ( DWORD pUserData );
+ static float GetTrainSpeed ( DWORD pUserData );
+ static bool IsBlown ( DWORD pUserData );
+ static MonoObject* GetHeadLightColor ( DWORD pUserData );
+ static float GetDoorOpenRatio ( DWORD pUserData, unsigned char ucDoor );
+ static bool IsTaxiLightOn ( DWORD pUserData );
+
+ // Vehicle set functions
+ static bool Fix ( DWORD pUserData );
+ static bool Blow ( DWORD pUserData, bool bExplode );
+ static bool SetTurnVelocity ( DWORD pUserData, MonoObject* pVelocity );
+ static bool SetColor ( DWORD pUserData, MonoObject* pColor1, MonoObject* pColor2, MonoObject* pColor3, MonoObject* pColor4 );
+ static bool SetLandingGearDown ( DWORD pUserData, bool bLandingGearDown );
+ static bool SetLocked ( DWORD pUserData, bool bLocked );
+ static bool SetDoorsUndamageable ( DWORD pUserData, bool bDoorsUndamageable );
+ static bool SetSirensOn ( DWORD pUserData, bool bSirensOn );
+ static bool SetTaxiLightOn ( DWORD pUserData, bool bTaxiLightState );
+ static bool AddUpgrade ( DWORD pUserData, unsigned short usUpgrade );
+ static bool RemoveUpgrade ( DWORD pUserData, unsigned short usUpgrade );
+ static bool SetDoorState ( DWORD pUserData, unsigned char ucDoor, unsigned char ucState );
+ static bool SetWheelStates ( DWORD pUserData, int iFrontLeft, int iRearLeft, int iFrontRight, int iRearRight );
+ static bool SetLightState ( DWORD pUserData, unsigned char ucLight, unsigned char ucState );
+ static bool SetPanelState ( DWORD pUserData, unsigned char ucPanel, unsigned char ucState );
+ static bool SetIdleRespawnDelay ( DWORD pUserData, unsigned long ulTime );
+ static bool SetRespawnDelay ( DWORD pUserData, unsigned long ulTime );
+ static bool SetRespawnPosition ( DWORD pUserData, MonoObject* pPosition, MonoObject* pRotation );
+ static bool ToggleRespawn ( DWORD pUserData, bool bRespawn );
+ static bool ResetExplosionTime ( DWORD pUserData );
+ static bool ResetIdleTime ( DWORD pUserData );
+ static bool Spawn ( DWORD pUserData, MonoObject* pPosition, MonoObject* pRotation );
+ static bool Respawn ( DWORD pUserData );
+ static bool SetOverrideLights ( DWORD pUserData, unsigned char ucLights );
+ static bool AttachTrailer ( DWORD pUserData, DWORD pTrailer );
+ static bool DetachTrailer ( DWORD pUserData, DWORD pTrailer );
+ static bool SetEngineState ( DWORD pUserData, bool bState );
+ static bool SetDirtLevel ( DWORD pUserData, float fDirtLevel );
+ static bool SetDamageProof ( DWORD pUserData, bool bDamageProof );
+ static bool SetPaintjob ( DWORD pUserData, unsigned char ucPaintjob );
+ static bool SetFuelTankExplodable ( DWORD pUserData, bool bExplodable );
+ static bool SetTrainDerailed ( DWORD pUserData, bool bDerailed );
+ static bool SetTrainDerailable ( DWORD pUserData, bool bDerailable );
+ static bool SetTrainDirection ( DWORD pUserData, bool bDireciton );
+ static bool SetTrainSpeed ( DWORD pUserData, float fSpeed );
+ static bool SetHeadLightColor ( DWORD pUserData, MonoObject* pColor );
+ static bool SetTurretPosition ( DWORD pUserData, MonoObject* pPosition );
+ static bool SetDoorOpenRatio ( DWORD pUserData, unsigned char ucDoor, float fRatio, unsigned long ulTime );
+ static bool SetVariant ( DWORD pUserData, unsigned char ucVariant, unsigned char ucVariant2 );
+ static bool GiveSirens ( DWORD pUserData, unsigned char ucSirenType, unsigned char ucSirenCount, bool bFlag360 = false, bool bCheckLosFlag = true, bool bUseRandomiserFlag = true, bool bSilentFlag = false );
+ static bool RemoveSirens ( DWORD pUserData );
+ static bool SetSirens ( DWORD pUserData, unsigned char ucSirenID, MonoObject* pPosition, MonoObject* pColor, float fMinAlpha );
+ static MonoArray* GetSirens ( DWORD pUserData );
+ static MonoObject* GetSirenParams ( DWORD pUserData );
+ static bool SetPlateText ( DWORD pUserData, MonoString* msName );
+ };
+
+ class Marker
+ {
+ public:
+ // Marker create/destroy functions
+ static DWORD Create ( MonoObject* pPosition, MonoString* szType, float fSize, MonoObject* color, DWORD pVisibleTo );
+
+ // Marker get functions
+ static unsigned int GetCount ();
+ static MonoString* GetType ( DWORD pUserData );
+ static float GetSize ( DWORD pUserData );
+ static MonoObject* GetColor ( DWORD pUserData );
+ static MonoObject* GetTarget ( DWORD pUserData );
+ static MonoString* GetIcon ( DWORD pUserData );
+
+ // Marker set functions
+ static bool SetType ( DWORD pUserData, MonoString* szType );
+ static bool SetSize ( DWORD pUserData, float fSize );
+ static bool SetColor ( DWORD pUserData, MonoObject* color );
+ static bool SetTarget ( DWORD pUserData, MonoObject* pTarget );
+ static bool SetIcon ( DWORD pUserData, MonoString* szIcon );
+ };
+
+ class Blip
+ {
+ public:
+ // Blip create/destroy functions
+ static DWORD Create ( MonoObject* vecPosition, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo );
+ static DWORD CreateAttachedTo ( DWORD pTarget, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo );
+
+ // Blip get functions
+ static unsigned char GetIcon ( DWORD pUserData );
+ static unsigned char GetSize ( DWORD pUserData );
+ static MonoObject* GetColor ( DWORD pUserData );
+ static short GetOrdering ( DWORD pUserData );
+ static unsigned short GetVisibleDistance ( DWORD pUserData );
+
+ // Blip set functions
+ static bool SetIcon ( DWORD pUserData, unsigned char ucIcon );
+ static bool SetSize ( DWORD pUserData, unsigned char ucSize );
+ static bool SetColor ( DWORD pUserData, MonoObject* color );
+ static bool SetOrdering ( DWORD pUserData, short sOrdering );
+ static bool SetVisibleDistance ( DWORD pUserData, unsigned short usVisibleDistance );
+ };
+
+ class Object
+ {
+ public:
+ // Object create/destroy functions
+ static DWORD Create ( unsigned short usModelID, MonoObject* pPosition, MonoObject* pRotation, bool bIsLowLod );
+
+ // Object get functions
+ static MonoObject* GetScale ( DWORD pUserData );
+
+ // Object set functions
+ static bool SetScale ( DWORD pUserData, MonoObject* pScale );
+ static bool Move ( DWORD pUserData, unsigned long ulTime, MonoObject* pPosition, MonoObject* pRotation, MonoString* msEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot );
+ static bool Stop ( DWORD pUserData );
+ };
+
+ class RadarArea
+ {
+ public:
+ // Radar area create/destroy funcs
+ static DWORD Create ( MonoObject* pPosition, MonoObject* pSize, MonoObject* pColor, DWORD pVisibleTo );
+
+ // Radar area get funcs
+ static MonoObject* GetSize ( DWORD pUserData );
+ static MonoObject* GetColor ( DWORD pUserData );
+ static bool IsFlashing ( DWORD pUserData );
+ static bool IsInside ( DWORD pUserData, MonoObject* pPosition );
+
+ // Radar area set funcs
+ static bool SetSize ( DWORD pUserData, MonoObject* pSize );
+ static bool SetColor ( DWORD pUserData, MonoObject* pColor );
+ static bool SetFlashing ( DWORD pUserData, bool bFlashing );
+ };
+
+ class Pickup
+ {
+ public:
+ // Pickup create/destroy funcs
+ static DWORD Create ( MonoObject* pPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval, double dSix );
+
+ // Pickup get funcs
+ static unsigned char GetType ( DWORD pUserData );
+ static unsigned char GetWeapon ( DWORD pUserData );
+ static float GetAmount ( DWORD pUserData );
+ static unsigned short GetAmmo ( DWORD pUserData );
+ static unsigned long GetRespawnInterval ( DWORD pUserData );
+ static bool IsSpawned ( DWORD pUserData );
+
+ // Pickup set funcs
+ static bool SetType ( DWORD pUserData, unsigned char ucType, double dThree, double dFour );
+ static bool SetRespawnInterval ( DWORD pUserData, unsigned long ulInterval );
+ static bool Use ( DWORD pUserData, DWORD pPlayer );
+ };
+
+ class Shape
+ {
+ public:
+ // Shape create funcs
+ static DWORD CreateCircle ( MonoObject* pPosition, float fRadius );
+ static DWORD CreateCuboid ( MonoObject* pPosition, MonoObject* vecSize );
+ static DWORD CreateSphere ( MonoObject* pPosition, float fRadius );
+ static DWORD CreateRectangle ( MonoObject* pPosition, MonoObject* vecSize );
+ static DWORD CreatePolygon ( MonoArray* vecPointList );
+ static DWORD CreateTube ( MonoObject* pPosition, float fRadius, float fHeight );
+ };
+
+ class Explosion
+ {
+ public:
+ // Explosion funcs
+ static bool Create ( MonoObject* pPosition, unsigned char ucType, DWORD pCreator );
+ };
+
+ class Audio
+ {
+ public:
+ // Audio funcs
+ static bool PlayFrontEnd ( DWORD pUserData, unsigned char ucSound );
+ static bool PlayMission ( DWORD pUserData, MonoObject* vecPosition, unsigned short usSlot );
+ };
+
+ class Team
+ {
+ public:
+ // Team get funcs
+ static DWORD Create ( MonoString* msTeamName, MonoObject* pColor );
+ static DWORD GetFromName ( MonoString* msTeamName );
+ static MonoString* GetName ( DWORD pUserData );
+ static MonoObject* GetColor ( DWORD pUserData );
+ static unsigned int CountPlayers ( DWORD pUserData );
+ static bool GetFriendlyFire ( DWORD pUserData );
+
+ // Team set funcs
+ static bool SetName ( DWORD pUserData, MonoString* msTeamName );
+ static bool SetColor ( DWORD pUserData, MonoObject* pColor );
+ static bool SetFriendlyFire ( DWORD pUserData, bool bFriendlyFire );
+ };
+
+ class Water
+ {
+ public:
+ // Water funcs
+ static DWORD Create ( MonoObject* pV1, MonoObject* pV2, MonoObject* pV3, MonoObject* pV4, bool bShallow );
+ static bool SetLevel ( DWORD pUserData, float fLevel );
+ static bool SetLevelAll ( float fLevel );
+ static bool SetLevelWorld ( float fLevel, bool bIncludeWorldNonSeaLevel );
+ static bool ResetLevelWorld ( void );
+ static MonoObject* GetVertexPosition ( DWORD pUserData, int iVertexIndex );
+ static bool SetVertexPosition ( DWORD pUserData, int iVertexIndex, MonoObject* vecPosition );
+ static MonoObject* GetColor ( void );
+ static bool SetColor ( MonoObject* pColor );
+ static bool ResetColor ( void );
+ };
+
+ class World
+ {
+ public:
+ // General world get funcs
+ static MonoArray* GetTime ( void );
+ static MonoArray* GetWeather ( void );
+ static MonoString* GetZoneName ( MonoObject* vecPosition, bool bCitiesOnly );
+ static float GetGravity ( void );
+ static float GetGameSpeed ( void );
+ static float GetWaveHeight ( void );
+ static unsigned short GetFPSLimit ( void );
+ static unsigned long GetMinuteDuration ( void );
+ static bool IsGarageOpen ( unsigned char ucGarageID );
+ static unsigned char GetTrafficLightState ( void );
+ static bool GetTrafficLightsLocked ( void );
+ static float GetJetpackMaxHeight ( void );
+ static float GetAircraftMaxVelocity ( void );
+ static bool GetInteriorSoundsEnabled ( void );
+ static float GetRainLevel ( void );
+ static float GetSunSize ( void );
+ static MonoArray* GetSunColor ( void );
+ static MonoObject* GetWindVelocity ( void );
+ static float GetFarClipDistance ( void );
+ static float GetFogDistance ( void );
+ static float GetAircraftMaxHeight ( void );
+ static bool GetOcclusionsEnabled ( void );
+ static int GetMoonSize ( void );
+ static MonoArray* GetSkyGradient ( void );
+ static MonoObject* GetHeatHaze ( void );
+ static bool GetJetpackWeaponEnabled ( unsigned int uiWeaponType );
+ static bool GetCloudsEnabled ( void );
+
+ // General world set funcs
+ static bool SetTime ( unsigned char ucHour, unsigned char ucMinute );
+ static bool SetWeather ( unsigned char ucWeather );
+ static bool SetWeatherBlended ( unsigned char ucWeather );
+ static bool SetGravity ( float fGravity );
+ static bool SetGameSpeed ( float fSpeed );
+ static bool SetWaveHeight ( float fHeight );
+ static bool SetSkyGradient ( MonoObject* pTopColor, MonoObject* pBottomColor );
+ static bool ResetSkyGradient ( void );
+ static bool SetHeatHaze ( MonoObject* heatHazeSettings );
+ static bool ResetHeatHaze ( void );
+ static bool SetFPSLimit ( unsigned short usLimit, bool bSave );
+ static bool SetMinuteDuration ( unsigned long ulDuration );
+ static bool SetGarageOpen ( unsigned char ucGarageID, bool bIsOpen );
+ static bool SetGlitchEnabled ( MonoString* msGlitchName, bool bEnabled );
+ static bool IsGlitchEnabled ( MonoString* msGlitchName );
+ static bool SetJetpackWeaponEnabled ( unsigned int uiWeaponType, bool bEnabled );
+ static bool SetCloudsEnabled ( bool bEnabled );
+ static bool SetTrafficLightState ( unsigned char ucState, bool bForced = false );
+ static bool SetTrafficLightsLocked ( bool bLocked );
+ static bool SetJetpackMaxHeight ( float fMaxHeight );
+ static bool SetInteriorSoundsEnabled ( bool bEnable );
+ static bool SetRainLevel ( float fRainLevel );
+ static bool SetSunSize ( float fSunSize );
+ static bool SetSunColor ( MonoObject* pCoreColor, MonoObject* pCoronaColor );
+ static bool SetWindVelocity ( MonoObject* pVelocity );
+ static bool SetFarClipDistance ( float fFarClip );
+ static bool SetFogDistance ( float fFogDist );
+ static bool SetAircraftMaxHeight ( float fMaxHeight );
+ static bool SetAircraftMaxVelocity ( float fVelocity );
+ static bool SetOcclusionsEnabled ( bool bEnabled );
+ static bool ResetRainLevel ( void );
+ static bool ResetSunSize ( void );
+ static bool ResetSunColor ( void );
+ static bool ResetWindVelocity ( void );
+ static bool ResetFarClipDistance ( void );
+ static bool ResetFogDistance ( void );
+ static bool RemoveWorldModel ( unsigned short usModel, float fRadius, MonoObject* vecPosition, char cInterior );
+ static bool RestoreWorldModel ( unsigned short usModel, float fRadius, MonoObject* vecPosition, char cInterior );
+ static bool RestoreAllWorldModels ( void );
+ static bool SetMoonSize ( int iMoonSize );
+ static bool ResetMoonSize ( void );
+ };
+
+ class Account
+ {
+ public:
+ // Account get funcs
+ static DWORD Get ( MonoString* msName, MonoString* msPassword );
+ static MonoArray* GetAll ( void );
+ static DWORD GetPlayer ( DWORD pAccount );
+ static bool IsGuest ( DWORD pAccount );
+ // static CLuaArgument* GetData ( DWORD pAccount, MonoString* szKey );
+ // static MonoArray* GetAllData ( DWORD pAccount );
+ static MonoString* GetSerial ( DWORD pAccount );
+ // static MonoArray* GetBySerial ( MonoString* msSerial );
+
+ // Account set funcs
+ static DWORD Add ( MonoString* msName, MonoString* msPassword );
+ static bool Remove ( DWORD pAccount );
+ static bool SetPassword ( DWORD pAccount, MonoString* msPassword );
+ // static bool SetData ( DWORD pAccount, MonoString* msKey, CLuaArgument* pArgument );
+ static bool CopyData ( DWORD pAccount, DWORD pFromAccount );
+ };
+
+ class Ban
+ {
+ public:
+ static DWORD Add ( MonoString* msIP, MonoString* msUsername, MonoString* msSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban );
+ static bool Remove ( DWORD pBan, DWORD pResponsible );
+
+ // static MonoArray* GetBans ( void );
+ static bool Reload ( void );
+
+ static MonoString* GetIP ( DWORD pBan );
+ static MonoString* GetSerial ( DWORD pBan );
+ static MonoString* GetUsername ( DWORD pBan );
+ static MonoString* GetNick ( DWORD pBan );
+ static MonoString* GetReason ( DWORD pBan );
+ static MonoString* GetAdmin ( DWORD pBan );
+
+ static int GetBanTime ( DWORD pBan );
+ static int GetUnbanTime ( DWORD pBan );
+
+ static bool SetUnbanTime ( DWORD pBan, int time );
+ static bool SetReason ( DWORD pBan, MonoString* msReason );
+ static bool SetAdmin ( DWORD pBan, MonoString* msAdminName );
+ };
+
+ class Resource
+ {
+ public:
+ // Resource funcs
+ static DWORD Create ( MonoString* msResourceName, MonoString* msOrganizationalDir );
+ static DWORD Copy ( DWORD pResource, MonoString* msNewResourceName, MonoString* msOrganizationalDir );
+ static DWORD GetRootElement ( DWORD pResource = NULL );
+ static DWORD GetMapRootElement ( DWORD pResource, MonoString* msMap );
+ static DWORD GetDynamicElementRoot ( DWORD pResource );
+ // static CXMLNode* AddMap ( MonoString* msFilePath, MonoString* msMapName, int iDimension );
+ // static CXMLNode* AddConfig ( MonoString* msFilePath, MonoString* msConfigName, int iType );
+ static bool RemoveFile ( DWORD pResource, MonoString* msFilename );
+ // static CXMLNode AddConfig ( MonoString* msFilePath, MonoString* msFileType );
+ // static CXMLNode AddMap ( MonoString* msFilePath, unsigned int uiDimension = 0 );
+ // static CXMLNode GetConfig ( MonoString* msFilePath );
+ // static CLuaArguments* GetExportedFunctions ( DWORD pResource );
+ static DWORD GetFromName ( MonoString* msResourceName );
+ static MonoString* GetInfo ( DWORD pResource, MonoString* msAttribute );
+ static unsigned int GetLastStartTime ( DWORD pResource );
+ static MonoString* GetLoadFailureReason ( DWORD pResource );
+ static unsigned int GetLoadTime ( DWORD pResource );
+ static MonoString* GetName ( DWORD pResource );
+ static MonoArray* GetResources ( void );
+ static MonoString* GetState ( DWORD pResource );
+ static DWORD GetCurrent ( void );
+ static bool Refresh ( bool refreshAll = false );
+ static bool RemoveDefaultSetting ( DWORD pResource, MonoString* msSettingName );
+ static bool Start ( DWORD pResource, bool persistent = false, bool startIncludedResources = true, bool loadServerConfigs = true, bool loadMaps = true, bool loadServerScripts = true, bool loadHTML = true, bool loadClientConfigs = true, bool loadClientScripts = true, bool loadFiles = true );
+ static bool Restart ( DWORD pResource );
+ static bool Stop ( DWORD pResource );
+ static bool SetDefaultSetting ( DWORD pResource, MonoString* msSettingName, MonoString* msSettingValue );
+ // static bool SetDefaultSetting ( DWORD pResource, MonoString* msSettingName, int iSettingValue );
+ // static bool SetDefaultSetting ( DWORD pResource, MonoString* msSettingName, float fSettingValue );
+ static bool SetInfo ( DWORD pResource, MonoString* msAttribute, MonoString* msValue );
+ static bool Rename ( MonoString* msResourceName, MonoString* msNewResourceName, MonoString* msOrganizationalPath );
+ static bool Delete ( MonoString* msResourceName );
+ // static CLuaArguments* GetACLRequests ( DWORD pResource );
+ static bool UpdateACLRequest ( DWORD pResource, MonoString* msRightName, bool bAccess, MonoString* msByWho );
+ };
+};
+
#endif
\ No newline at end of file
diff --git a/mta-mono/src/CMonoFunctions_Account.cpp b/mta-mono/src/CMonoFunctions_Account.cpp
index 5857dd0..0edb01f 100644
--- a/mta-mono/src/CMonoFunctions_Account.cpp
+++ b/mta-mono/src/CMonoFunctions_Account.cpp
@@ -1,125 +1,125 @@
-/*********************************************************
-*
-* 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 "CMonoFunctions.h"
-
-// Account get funcs
+/*********************************************************
+*
+* 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 "CMonoFunctions.h"
+
+// Account get funcs
DWORD CMonoFunctions::Account::Get( MonoString* msName, MonoString* msPassword )
{
- if( RESOURCE )
- {
- const char* szName = mono_string_to_utf8( msName );
- const char* szPassword = mono_string_to_utf8( msPassword );
-
- return (DWORD)CLuaFunctionDefinitions::GetAccount( RESOURCE->GetLua(), szName, szPassword );
- }
-
+ if( RESOURCE )
+ {
+ const char* szName = mono_string_to_utf8( msName );
+ const char* szPassword = mono_string_to_utf8( msPassword );
+
+ return (DWORD)CLuaFunctionDefinitions::GetAccount( RESOURCE->GetLua(), szName, szPassword );
+ }
+
return NULL;
}
-
+
MonoArray* CMonoFunctions::Account::GetAll( void )
{
- if( RESOURCE )
- {
- CLuaArguments* pLuaTable = CLuaFunctionDefinitions::GetAccounts( RESOURCE->GetLua() );
-
- return RESOURCE->NewArray( mono_get_uint32_class(), pLuaTable );
- }
-
+ if( RESOURCE )
+ {
+ CLuaArguments* pLuaTable = CLuaFunctionDefinitions::GetAccounts( RESOURCE->GetLua() );
+
+ return RESOURCE->GetDomain()->NewArray( mono_get_uint32_class(), pLuaTable );
+ }
+
return NULL;
}
-
+
DWORD CMonoFunctions::Account::GetPlayer( DWORD pAccount )
{
- if( RESOURCE )
- {
- return (DWORD)CLuaFunctionDefinitions::GetAccountPlayer( RESOURCE->GetLua(), (void*)pAccount );
- }
-
+ if( RESOURCE )
+ {
+ return (DWORD)CLuaFunctionDefinitions::GetAccountPlayer( RESOURCE->GetLua(), (void*)pAccount );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Account::IsGuest( DWORD pAccount )
{
- if( RESOURCE )
- {
- bool bIsGuest;
-
- if( CLuaFunctionDefinitions::IsGuestAccount( RESOURCE->GetLua(), (void*)pAccount, bIsGuest ) )
- {
- return bIsGuest;
- }
- }
-
+ if( RESOURCE )
+ {
+ bool bIsGuest;
+
+ if( CLuaFunctionDefinitions::IsGuestAccount( RESOURCE->GetLua(), (void*)pAccount, bIsGuest ) )
+ {
+ return bIsGuest;
+ }
+ }
+
return NULL;
}
-
+
MonoString* CMonoFunctions::Account::GetSerial( DWORD pAccount )
{
- if( RESOURCE )
- {
- string strSerial;
-
- if( CLuaFunctionDefinitions::GetAccountSerial( RESOURCE->GetLua(), (void*)pAccount, strSerial ) )
- {
- return RESOURCE->NewString( strSerial );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strSerial;
+
+ if( CLuaFunctionDefinitions::GetAccountSerial( RESOURCE->GetLua(), (void*)pAccount, strSerial ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strSerial );
+ }
+ }
+
return NULL;
-}
-
-// Account set funcs
+}
+
+// Account set funcs
DWORD CMonoFunctions::Account::Add( MonoString* msName, MonoString* msPassword )
{
- if( RESOURCE )
- {
- const char* szName = mono_string_to_utf8( msName );
- const char* szPassword = mono_string_to_utf8( msPassword );
-
- return (DWORD)CLuaFunctionDefinitions::AddAccount( RESOURCE->GetLua(), szName, szPassword );
- }
-
+ if( RESOURCE )
+ {
+ const char* szName = mono_string_to_utf8( msName );
+ const char* szPassword = mono_string_to_utf8( msPassword );
+
+ return (DWORD)CLuaFunctionDefinitions::AddAccount( RESOURCE->GetLua(), szName, szPassword );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Account::Remove( DWORD pAccount )
{
- if( RESOURCE )
- {
- return CLuaFunctionDefinitions::RemoveAccount( RESOURCE->GetLua(), (void*)pAccount );
- }
-
+ if( RESOURCE )
+ {
+ return CLuaFunctionDefinitions::RemoveAccount( RESOURCE->GetLua(), (void*)pAccount );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Account::SetPassword( DWORD pAccount, MonoString* msPassword )
{
- if( RESOURCE )
- {
- const char* szPassword = mono_string_to_utf8( msPassword );
-
- return CLuaFunctionDefinitions::SetAccountPassword( RESOURCE->GetLua(), (void*)pAccount, szPassword );
- }
-
+ if( RESOURCE )
+ {
+ const char* szPassword = mono_string_to_utf8( msPassword );
+
+ return CLuaFunctionDefinitions::SetAccountPassword( RESOURCE->GetLua(), (void*)pAccount, szPassword );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Account::CopyData( DWORD pAccount, DWORD pFromAccount )
{
- if( RESOURCE )
- {
- return CLuaFunctionDefinitions::CopyAccountData( RESOURCE->GetLua(), (void*)pAccount, (void*)pFromAccount );
- }
-
+ if( RESOURCE )
+ {
+ return CLuaFunctionDefinitions::CopyAccountData( RESOURCE->GetLua(), (void*)pAccount, (void*)pFromAccount );
+ }
+
return NULL;
}
diff --git a/mta-mono/src/CMonoFunctions_Ban.cpp b/mta-mono/src/CMonoFunctions_Ban.cpp
index a9b4638..c4ab66f 100644
--- a/mta-mono/src/CMonoFunctions_Ban.cpp
+++ b/mta-mono/src/CMonoFunctions_Ban.cpp
@@ -1,208 +1,208 @@
-/*********************************************************
-*
-* 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 "CMonoFunctions.h"
-
+/*********************************************************
+*
+* 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 "CMonoFunctions.h"
+
DWORD CMonoFunctions::Ban::Add( MonoString* msIP, MonoString* msUsername, MonoString* msSerial, DWORD pResponsible, MonoString* msResponsible, MonoString* msReason, int iUnban )
{
- if( RESOURCE )
- {
- string
- strIP( mono_string_to_utf8( msIP ) ),
- strUsername( mono_string_to_utf8( msUsername ) ),
- strSerial( mono_string_to_utf8( msSerial ) ),
- 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 );
- }
-
+ if( RESOURCE )
+ {
+ string
+ strIP( mono_string_to_utf8( msIP ) ),
+ strUsername( mono_string_to_utf8( msUsername ) ),
+ strSerial( mono_string_to_utf8( msSerial ) ),
+ 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 );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Ban::Remove( DWORD pBan, DWORD pResponsible )
{
- if( RESOURCE )
- {
- return (DWORD)CLuaFunctionDefinitions::RemoveBan( RESOURCE->GetLua(), (void*)pBan, (void*)pResponsible );
- }
-
+ if( RESOURCE )
+ {
+ return (DWORD)CLuaFunctionDefinitions::RemoveBan( RESOURCE->GetLua(), (void*)pBan, (void*)pResponsible );
+ }
+
return false;
}
-
-
+
+
bool CMonoFunctions::Ban::Reload( void )
{
- if( RESOURCE )
- {
- return (DWORD)CLuaFunctionDefinitions::ReloadBanList( RESOURCE->GetLua() );
- }
-
+ if( RESOURCE )
+ {
+ return (DWORD)CLuaFunctionDefinitions::ReloadBanList( RESOURCE->GetLua() );
+ }
+
return false;
}
-
-
+
+
MonoString* CMonoFunctions::Ban::GetIP( DWORD pBan )
{
- if( RESOURCE )
- {
- string strIP;
-
- if( CLuaFunctionDefinitions::GetBanIP( RESOURCE->GetLua(), (void*)pBan, strIP ) )
- {
- return RESOURCE->NewString( strIP );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strIP;
+
+ if( CLuaFunctionDefinitions::GetBanIP( RESOURCE->GetLua(), (void*)pBan, strIP ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strIP );
+ }
+ }
+
return NULL;
}
-
+
MonoString* CMonoFunctions::Ban::GetSerial( DWORD pBan )
{
- if( RESOURCE )
- {
- string strSerial;
-
- if( CLuaFunctionDefinitions::GetBanSerial( RESOURCE->GetLua(), (void*)pBan, strSerial ) )
- {
- return RESOURCE->NewString( strSerial );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strSerial;
+
+ if( CLuaFunctionDefinitions::GetBanSerial( RESOURCE->GetLua(), (void*)pBan, strSerial ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strSerial );
+ }
+ }
+
return NULL;
}
-
+
MonoString* CMonoFunctions::Ban::GetUsername( DWORD pBan )
{
- if( RESOURCE )
- {
- string strUsername;
-
- if( CLuaFunctionDefinitions::GetBanUsername( RESOURCE->GetLua(), (void*)pBan, strUsername ) )
- {
- return RESOURCE->NewString( strUsername );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strUsername;
+
+ if( CLuaFunctionDefinitions::GetBanUsername( RESOURCE->GetLua(), (void*)pBan, strUsername ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strUsername );
+ }
+ }
+
return NULL;
}
-
+
MonoString* CMonoFunctions::Ban::GetNick( DWORD pBan )
{
- if( RESOURCE )
- {
- string strNick;
-
- if( CLuaFunctionDefinitions::GetBanNick( RESOURCE->GetLua(), (void*)pBan, strNick ) )
- {
- return RESOURCE->NewString( strNick );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strNick;
+
+ if( CLuaFunctionDefinitions::GetBanNick( RESOURCE->GetLua(), (void*)pBan, strNick ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strNick );
+ }
+ }
+
return NULL;
}
-
+
MonoString* CMonoFunctions::Ban::GetReason( DWORD pBan )
{
- if( RESOURCE )
- {
- string strReason;
-
- if( CLuaFunctionDefinitions::GetBanReason( RESOURCE->GetLua(), (void*)pBan, strReason ) )
- {
- return RESOURCE->NewString( strReason );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strReason;
+
+ if( CLuaFunctionDefinitions::GetBanReason( RESOURCE->GetLua(), (void*)pBan, strReason ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strReason );
+ }
+ }
+
return NULL;
}
-
+
MonoString* CMonoFunctions::Ban::GetAdmin( DWORD pBan )
{
- if( RESOURCE )
- {
- string strAdmin;
-
- if( CLuaFunctionDefinitions::GetBanAdmin( RESOURCE->GetLua(), (void*)pBan, strAdmin ) )
- {
- return RESOURCE->NewString( strAdmin );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strAdmin;
+
+ if( CLuaFunctionDefinitions::GetBanAdmin( RESOURCE->GetLua(), (void*)pBan, strAdmin ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strAdmin );
+ }
+ }
+
return NULL;
}
-
-
+
+
int CMonoFunctions::Ban::GetBanTime( DWORD pBan )
{
- if( RESOURCE )
- {
- time_t tTime;
-
- if( CLuaFunctionDefinitions::GetBanTime( RESOURCE->GetLua(), (void*)pBan, tTime ) )
- {
- return (int)tTime;
- }
- }
-
+ if( RESOURCE )
+ {
+ time_t tTime;
+
+ if( CLuaFunctionDefinitions::GetBanTime( RESOURCE->GetLua(), (void*)pBan, tTime ) )
+ {
+ return (int)tTime;
+ }
+ }
+
return 0;
}
-
+
int CMonoFunctions::Ban::GetUnbanTime( DWORD pBan )
{
- if( RESOURCE )
- {
- time_t tTime;
-
- if( CLuaFunctionDefinitions::GetUnbanTime( RESOURCE->GetLua(), (void*)pBan, tTime ) )
- {
- return (int)tTime;
- }
- }
-
+ if( RESOURCE )
+ {
+ time_t tTime;
+
+ if( CLuaFunctionDefinitions::GetUnbanTime( RESOURCE->GetLua(), (void*)pBan, tTime ) )
+ {
+ return (int)tTime;
+ }
+ }
+
return 0;
}
-
-
+
+
bool CMonoFunctions::Ban::SetUnbanTime( DWORD pBan, int time )
{
- if( RESOURCE )
- {
- return CLuaFunctionDefinitions::SetUnbanTime( RESOURCE->GetLua(), (void*)pBan, time );
- }
-
+ if( RESOURCE )
+ {
+ return CLuaFunctionDefinitions::SetUnbanTime( RESOURCE->GetLua(), (void*)pBan, time );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Ban::SetReason( DWORD pBan, MonoString* msReason )
{
- if( RESOURCE )
- {
- string strReason( mono_string_to_utf8( msReason ) );
-
- return CLuaFunctionDefinitions::SetBanReason( RESOURCE->GetLua(), (void*)pBan, strReason );
- }
-
+ if( RESOURCE )
+ {
+ string strReason( mono_string_to_utf8( msReason ) );
+
+ return CLuaFunctionDefinitions::SetBanReason( RESOURCE->GetLua(), (void*)pBan, strReason );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Ban::SetAdmin( DWORD pBan, MonoString* msAdminName )
{
- if( RESOURCE )
- {
- string strAdmin( mono_string_to_utf8( msAdminName ) );
-
- return CLuaFunctionDefinitions::SetBanAdmin( RESOURCE->GetLua(), (void*)pBan, strAdmin );
- }
-
+ if( RESOURCE )
+ {
+ string strAdmin( mono_string_to_utf8( msAdminName ) );
+
+ return CLuaFunctionDefinitions::SetBanAdmin( RESOURCE->GetLua(), (void*)pBan, strAdmin );
+ }
+
return false;
}
diff --git a/mta-mono/src/CMonoFunctions_Blip.cpp b/mta-mono/src/CMonoFunctions_Blip.cpp
index 0bd18f9..d16e52e 100644
--- a/mta-mono/src/CMonoFunctions_Blip.cpp
+++ b/mta-mono/src/CMonoFunctions_Blip.cpp
@@ -79,7 +79,7 @@ MonoObject* CMonoFunctions::Blip::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{
- return RESOURCE->NewObject( outColor );
+ return RESOURCE->GetDomain()->GetMTALib()->Color->New( outColor );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Element.cpp b/mta-mono/src/CMonoFunctions_Element.cpp
index 5435b10..0e60900 100644
--- a/mta-mono/src/CMonoFunctions_Element.cpp
+++ b/mta-mono/src/CMonoFunctions_Element.cpp
@@ -49,6 +49,16 @@ DWORD CMonoFunctions::Element::Clone( DWORD pUserData, MonoObject* vecPosition,
// Element get funcs
+DWORD CMonoFunctions::Element::GetRootElement( void )
+{
+ if( RESOURCE )
+ {
+ return (DWORD)CLuaFunctionDefinitions::GetRootElement( RESOURCE->GetLua() );
+ }
+
+ return NULL;
+}
+
MonoArray* CMonoFunctions::Element::GetByType( MonoString* msType, DWORD pStartElement )
{
if( RESOURCE )
@@ -57,7 +67,7 @@ MonoArray* CMonoFunctions::Element::GetByType( MonoString* msType, DWORD pStartE
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetElementsByType( RESOURCE->GetLua(), szType, (void*)pStartElement );
- return RESOURCE->NewArray( mono_get_uint32_class(), pLuaArguments );
+ return RESOURCE->GetDomain()->NewArray( mono_get_uint32_class(), pLuaArguments );
}
return NULL;
@@ -157,7 +167,7 @@ MonoObject* CMonoFunctions::Element::GetPosition( DWORD pUserData )
if( CLuaFunctionDefinitions::GetElementPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{
- return RESOURCE->NewObject( vecPosition );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
}
}
@@ -172,7 +182,7 @@ MonoObject* CMonoFunctions::Element::GetRotation( DWORD pUserData )
if( CLuaFunctionDefinitions::GetElementRotation( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{
- return RESOURCE->NewObject( vecPosition );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
}
}
@@ -187,7 +197,7 @@ MonoObject* CMonoFunctions::Element::GetVelocity( DWORD pUserData )
if( CLuaFunctionDefinitions::GetElementVelocity( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{
- return RESOURCE->NewObject( vecPosition );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
}
}
@@ -262,7 +272,7 @@ MonoString* CMonoFunctions::Element::GetZoneName( DWORD pUserData, bool bCitiesO
if( CLuaFunctionDefinitions::GetElementZoneName( RESOURCE->GetLua(), (void*)pUserData, strOutName, bCitiesOnly ) )
{
- return RESOURCE->NewString( strOutName );
+ return RESOURCE->GetDomain()->NewString( strOutName );
}
}
@@ -382,7 +392,7 @@ MonoObject* CMonoFunctions::Element::GetAttachedOffsetPosition( DWORD pUserData
if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) )
{
- return RESOURCE->NewObject( vecPosition );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
}
}
@@ -397,7 +407,7 @@ MonoObject* CMonoFunctions::Element::GetAttachedOffsetRotation( DWORD pUserData
if( CLuaFunctionDefinitions::GetElementAttachedOffsets( RESOURCE->GetLua(), (void*)pUserData, vecPosition, vecRotation ) )
{
- return RESOURCE->NewObject( vecRotation );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecRotation );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Event.cpp b/mta-mono/src/CMonoFunctions_Event.cpp
new file mode 100644
index 0000000..bafe312
--- /dev/null
+++ b/mta-mono/src/CMonoFunctions_Event.cpp
@@ -0,0 +1,20 @@
+/*********************************************************
+*
+* 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 "CMonoFunctions.h"
+
+bool CMonoFunctions::Event::AddHandler( MonoString* msName, DWORD pUserData, lua_CFunction iLuaFunction, bool bPropagated, MonoString* msEventPriority )
+{
+
+
+ return false;
+}
diff --git a/mta-mono/src/CMonoFunctions_Marker.cpp b/mta-mono/src/CMonoFunctions_Marker.cpp
index a2e40a7..7aecabe 100644
--- a/mta-mono/src/CMonoFunctions_Marker.cpp
+++ b/mta-mono/src/CMonoFunctions_Marker.cpp
@@ -50,7 +50,7 @@ MonoString* CMonoFunctions::Marker::GetType( DWORD pUserData )
if( CLuaFunctionDefinitions::GetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ) )
{
- return RESOURCE->NewString( szType );
+ return RESOURCE->GetDomain()->NewString( szType );
}
}
@@ -80,7 +80,7 @@ MonoObject* CMonoFunctions::Marker::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{
- return RESOURCE->NewObject( outColor );
+ return RESOURCE->GetDomain()->GetMTALib()->Color->New( outColor );
}
}
@@ -95,7 +95,7 @@ MonoObject* CMonoFunctions::Marker::GetTarget( DWORD pUserData )
if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{
- return RESOURCE->NewObject( vecPosition );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
}
}
@@ -110,7 +110,7 @@ MonoString* CMonoFunctions::Marker::GetIcon( DWORD pUserData )
if( CLuaFunctionDefinitions::GetMarkerIcon( RESOURCE->GetLua(), (void*)pUserData, szIcon ) )
{
- return RESOURCE->NewString( szIcon );
+ return RESOURCE->GetDomain()->NewString( szIcon );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Object.cpp b/mta-mono/src/CMonoFunctions_Object.cpp
index 56ce24e..bcfbf8f 100644
--- a/mta-mono/src/CMonoFunctions_Object.cpp
+++ b/mta-mono/src/CMonoFunctions_Object.cpp
@@ -36,7 +36,7 @@ MonoObject* CMonoFunctions::Object::GetScale( DWORD pUserData )
if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) )
{
- return RESOURCE->NewObject( vecScale );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecScale );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Ped.cpp b/mta-mono/src/CMonoFunctions_Ped.cpp
index 4950ca4..8e91d42 100644
--- a/mta-mono/src/CMonoFunctions_Ped.cpp
+++ b/mta-mono/src/CMonoFunctions_Ped.cpp
@@ -131,7 +131,7 @@ MonoString* CMonoFunctions::Ped::GetClothesTexture( DWORD pUserData, unsigned ch
if( CLuaFunctionDefinitions::GetPedClothes( RESOURCE->GetLua(), (void*)pUserData, ucType, strOutTexture, strOutModel ) )
{
- return RESOURCE->NewString( strOutTexture );
+ return RESOURCE->GetDomain()->NewString( strOutTexture );
}
}
@@ -146,7 +146,7 @@ MonoString* CMonoFunctions::Ped::GetClothesModel( DWORD pUserData, unsigned char
if( CLuaFunctionDefinitions::GetPedClothes( RESOURCE->GetLua(), (void*)pUserData, ucType, strOutTexture, strOutModel ) )
{
- return RESOURCE->NewString( strOutModel );
+ return RESOURCE->GetDomain()->NewString( strOutModel );
}
}
@@ -635,7 +635,7 @@ MonoString* CMonoFunctions::Ped::GetBodyPartName( unsigned char ucID )
if( CLuaFunctionDefinitions::GetBodyPartName( RESOURCE->GetLua(), ucID, szName ) )
{
- return RESOURCE->NewString( szName );
+ return RESOURCE->GetDomain()->NewString( szName );
}
}
@@ -651,12 +651,12 @@ MonoArray* CMonoFunctions::Ped::GetClothesByTypeIndex( unsigned char ucType, uns
if( CLuaFunctionDefinitions::GetClothesByTypeIndex( RESOURCE->GetLua(), ucType, ucIndex, szTexture, szModel ) )
{
- MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_string_class(), 2 );
+ MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_string_class(), 2 );
if( pArray )
{
- mono_array_set( pArray, MonoString*, 0, RESOURCE->NewString( szTexture ) );
- mono_array_set( pArray, MonoString*, 1, RESOURCE->NewString( szModel ) );
+ mono_array_set( pArray, MonoString*, 0, RESOURCE->GetDomain()->NewString( szTexture ) );
+ mono_array_set( pArray, MonoString*, 1, RESOURCE->GetDomain()->NewString( szModel ) );
return pArray;
}
@@ -677,7 +677,7 @@ MonoArray* CMonoFunctions::Ped::GetTypeIndexFromClothes( MonoString* msTexture,
if( CLuaFunctionDefinitions::GetTypeIndexFromClothes( RESOURCE->GetLua(), szTexture, szModel, ucType, ucIndex ) )
{
- MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 );
+ MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_char_class(), 2 );
if( pArray )
{
@@ -700,7 +700,7 @@ MonoString* CMonoFunctions::Ped::GetClothesTypeName( unsigned char ucType )
if( CLuaFunctionDefinitions::GetClothesTypeName( RESOURCE->GetLua(), ucType, szName ) )
{
- return RESOURCE->NewString( szName );
+ return RESOURCE->GetDomain()->NewString( szName );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Player.cpp b/mta-mono/src/CMonoFunctions_Player.cpp
index 04dfbf3..f9cb58a 100644
--- a/mta-mono/src/CMonoFunctions_Player.cpp
+++ b/mta-mono/src/CMonoFunctions_Player.cpp
@@ -126,7 +126,7 @@ MonoArray* CMonoFunctions::Player::GetAlivePlayers( void )
if( pLuaArguments )
{
- MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_uint32_class(), pLuaArguments->Count() );
+ MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_uint32_class(), pLuaArguments->Count() );
vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin();
@@ -150,7 +150,7 @@ MonoArray* CMonoFunctions::Player::GetDeadPlayers( void )
if( pLuaArguments )
{
- MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_uint32_class(), pLuaArguments->Count() );
+ MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_uint32_class(), pLuaArguments->Count() );
vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin();
@@ -204,7 +204,7 @@ MonoString* CMonoFunctions::Player::GetNametagText( DWORD pUserData )
if( CLuaFunctionDefinitions::GetPlayerNametagText( RESOURCE->GetLua(), (void*)pUserData, strOutText ) )
{
- return RESOURCE->NewString( strOutText );
+ return RESOURCE->GetDomain()->NewString( strOutText );
}
}
@@ -224,7 +224,7 @@ MonoObject* CMonoFunctions::Player::GetNametagColor( DWORD pUserData )
&ucR, &ucG, &ucB
};
- return RESOURCE->NewObject( "MultiTheftAuto", "Color", args, 3 );
+ return RESOURCE->GetDomain()->GetMTALib()->Color->New( args, 3 );
}
}
@@ -250,7 +250,7 @@ MonoString* CMonoFunctions::Player::GetSerial( DWORD pUserData )
{
if( RESOURCE )
{
- return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerSerial( RESOURCE->GetLua(), (void*)pUserData ) );
+ return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetPlayerSerial( RESOURCE->GetLua(), (void*)pUserData ) );
}
return NULL;
@@ -260,7 +260,7 @@ MonoString* CMonoFunctions::Player::GetUserName( DWORD pUserData )
{
if( RESOURCE )
{
- return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerUserName( RESOURCE->GetLua(), (void*)pUserData ) );
+ return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetPlayerUserName( RESOURCE->GetLua(), (void*)pUserData ) );
}
return NULL;
@@ -289,7 +289,7 @@ MonoString* CMonoFunctions::Player::GetName( DWORD pUserData )
if( CLuaFunctionDefinitions::GetPlayerName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) )
{
- return RESOURCE->NewString( strOutName );
+ return RESOURCE->GetDomain()->NewString( strOutName );
}
}
@@ -304,7 +304,7 @@ MonoString* CMonoFunctions::Player::GetIP( DWORD pUserData )
if( CLuaFunctionDefinitions::GetPlayerIP( RESOURCE->GetLua(), (void*)pUserData, strIP ) )
{
- return RESOURCE->NewString( strIP );
+ return RESOURCE->GetDomain()->NewString( strIP );
}
}
@@ -325,7 +325,7 @@ MonoString* CMonoFunctions::Player::GetVersion( DWORD pUserData )
{
if( RESOURCE )
{
- return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerVersion( RESOURCE->GetLua(), (void*)pUserData ) );
+ return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetPlayerVersion( RESOURCE->GetLua(), (void*)pUserData ) );
}
return NULL;
@@ -339,9 +339,9 @@ MonoObject* CMonoFunctions::Player::GetACInfo( DWORD pUserData )
if( !pLuaTable.empty() )
{
- MonoString* msDetectedAC = RESOURCE->NewString( pLuaTable[ "DetectedAC" ]->GetString() );
- MonoString* msD3D9MD5 = RESOURCE->NewString( pLuaTable[ "d3d9MD5" ]->GetString() );
- MonoString* msD3D9SHA256 = RESOURCE->NewString( pLuaTable[ "d3d9SHA256" ]->GetString() );
+ MonoString* msDetectedAC = RESOURCE->GetDomain()->NewString( pLuaTable[ "DetectedAC" ]->GetString() );
+ MonoString* msD3D9MD5 = RESOURCE->GetDomain()->NewString( pLuaTable[ "d3d9MD5" ]->GetString() );
+ MonoString* msD3D9SHA256 = RESOURCE->GetDomain()->NewString( pLuaTable[ "d3d9SHA256" ]->GetString() );
unsigned int iD3D9Size = pLuaTable[ "d3d9Size" ]->GetNumber< unsigned int >();
@@ -353,7 +353,7 @@ MonoObject* CMonoFunctions::Player::GetACInfo( DWORD pUserData )
&msD3D9SHA256
};
- return RESOURCE->NewObject( "MultiTheftAuto", "PlayerACInfo", args, 4 );
+ return RESOURCE->GetDomain()->GetMTALib()->GetClass( "PlayerACInfo" )->New( args, 4 );
}
}
return NULL;
@@ -365,7 +365,7 @@ MonoString* CMonoFunctions::Player::GetPlayerAnnounceValue( DWORD pElement, Mono
{
const char* szKey = mono_string_to_utf8( msKey );
- return RESOURCE->NewString( CLuaFunctionDefinitions::GetPlayerAnnounceValue( RESOURCE->GetLua(), (void*)pElement, szKey ) );
+ return RESOURCE->GetDomain()->NewString( CLuaFunctionDefinitions::GetPlayerAnnounceValue( RESOURCE->GetLua(), (void*)pElement, szKey ) );
}
return NULL;
@@ -785,7 +785,7 @@ MonoObject* CMonoFunctions::Player::GetCameraMatrix( DWORD pPlayer )
&fFOV
};
- return RESOURCE->NewObject( "MultiTheftAuto", "CameraMatrix", args, 8 );
+ return RESOURCE->GetDomain()->GetMTALib()->GetClass( "CameraMatrix" )->New( args, 8 );
}
}
diff --git a/mta-mono/src/CMonoFunctions_RadarArea.cpp b/mta-mono/src/CMonoFunctions_RadarArea.cpp
index 03ee380..38f5d7d 100644
--- a/mta-mono/src/CMonoFunctions_RadarArea.cpp
+++ b/mta-mono/src/CMonoFunctions_RadarArea.cpp
@@ -37,7 +37,7 @@ MonoObject* CMonoFunctions::RadarArea::GetSize( DWORD pUserData )
if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) )
{
- return RESOURCE->NewObject( vecSize );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector2->New( vecSize );
}
}
@@ -52,7 +52,7 @@ MonoObject* CMonoFunctions::RadarArea::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{
- return RESOURCE->NewObject( outColor );
+ return RESOURCE->GetDomain()->GetMTALib()->Color->New( outColor );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Resource.cpp b/mta-mono/src/CMonoFunctions_Resource.cpp
index ae391aa..526c44d 100644
--- a/mta-mono/src/CMonoFunctions_Resource.cpp
+++ b/mta-mono/src/CMonoFunctions_Resource.cpp
@@ -1,327 +1,327 @@
-/*********************************************************
-*
-* 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 "CMonoFunctions.h"
-
-// Resource funcs
+/*********************************************************
+*
+* 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 "CMonoFunctions.h"
+
+// Resource funcs
DWORD CMonoFunctions::Resource::Create( MonoString* msResourceName, MonoString* msOrganizationalDir )
{
- if( RESOURCE )
- {
- const char* szResourceName = mono_string_to_utf8( msResourceName );
- const char* szOrganizationalDir = mono_string_to_utf8( msOrganizationalDir );
-
- return (DWORD)CLuaFunctionDefinitions::CreateResource( RESOURCE->GetLua(), szResourceName, szOrganizationalDir );
- }
-
+ if( RESOURCE )
+ {
+ const char* szResourceName = mono_string_to_utf8( msResourceName );
+ const char* szOrganizationalDir = mono_string_to_utf8( msOrganizationalDir );
+
+ return (DWORD)CLuaFunctionDefinitions::CreateResource( RESOURCE->GetLua(), szResourceName, szOrganizationalDir );
+ }
+
return NULL;
}
-
+
DWORD CMonoFunctions::Resource::Copy( DWORD pResource, MonoString* msNewResourceName, MonoString* msOrganizationalDir )
{
- if( RESOURCE )
- {
- 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 );
- }
-
+ if( RESOURCE )
+ {
+ 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 );
+ }
+
return NULL;
}
-
+
DWORD CMonoFunctions::Resource::GetRootElement( DWORD pResource )
{
- if( RESOURCE )
- {
- return (DWORD)CLuaFunctionDefinitions::GetResourceRootElement( RESOURCE->GetLua(), (void*)pResource );
- }
-
+ if( RESOURCE )
+ {
+ return (DWORD)CLuaFunctionDefinitions::GetResourceRootElement( RESOURCE->GetLua(), (void*)pResource );
+ }
+
return NULL;
}
-
+
DWORD CMonoFunctions::Resource::GetMapRootElement( DWORD pResource, MonoString* msMap )
{
- if( RESOURCE )
- {
- const char* szMap = mono_string_to_utf8( msMap );
-
- return (DWORD)CLuaFunctionDefinitions::GetResourceMapRootElement( RESOURCE->GetLua(), (void*)pResource, szMap );
- }
-
+ if( RESOURCE )
+ {
+ const char* szMap = mono_string_to_utf8( msMap );
+
+ return (DWORD)CLuaFunctionDefinitions::GetResourceMapRootElement( RESOURCE->GetLua(), (void*)pResource, szMap );
+ }
+
return NULL;
}
-
+
DWORD CMonoFunctions::Resource::GetDynamicElementRoot( DWORD pResource )
{
- if( RESOURCE )
- {
- return (DWORD)CLuaFunctionDefinitions::GetResourceDynamicElementRoot( RESOURCE->GetLua(), (void*)pResource );
- }
-
+ if( RESOURCE )
+ {
+ return (DWORD)CLuaFunctionDefinitions::GetResourceDynamicElementRoot( RESOURCE->GetLua(), (void*)pResource );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Resource::RemoveFile( DWORD pResource, MonoString* msFilename )
{
- if( RESOURCE )
- {
- const char* szFileName = mono_string_to_utf8( msFilename );
-
- return CLuaFunctionDefinitions::RemoveResourceFile( RESOURCE->GetLua(), (void*)pResource, szFileName );
- }
-
+ if( RESOURCE )
+ {
+ const char* szFileName = mono_string_to_utf8( msFilename );
+
+ return CLuaFunctionDefinitions::RemoveResourceFile( RESOURCE->GetLua(), (void*)pResource, szFileName );
+ }
+
return false;
}
-
+
DWORD CMonoFunctions::Resource::GetFromName( MonoString* msResourceName )
{
- if( RESOURCE )
- {
- const char* szResourceName = mono_string_to_utf8( msResourceName );
-
- return (DWORD)CLuaFunctionDefinitions::GetResourceFromName( RESOURCE->GetLua(), szResourceName );
- }
-
+ if( RESOURCE )
+ {
+ const char* szResourceName = mono_string_to_utf8( msResourceName );
+
+ return (DWORD)CLuaFunctionDefinitions::GetResourceFromName( RESOURCE->GetLua(), szResourceName );
+ }
+
return false;
}
-
+
MonoString* CMonoFunctions::Resource::GetInfo( DWORD pResource, MonoString* msAttribute )
{
- if( RESOURCE )
- {
- const char* szAttribute = mono_string_to_utf8( msAttribute );
-
- string strOutInfo;
-
- if( CLuaFunctionDefinitions::GetResourceInfo( RESOURCE->GetLua(), (void*)pResource, szAttribute, strOutInfo ) )
- {
- return RESOURCE->NewString( strOutInfo );
- }
- }
-
+ if( RESOURCE )
+ {
+ const char* szAttribute = mono_string_to_utf8( msAttribute );
+
+ string strOutInfo;
+
+ if( CLuaFunctionDefinitions::GetResourceInfo( RESOURCE->GetLua(), (void*)pResource, szAttribute, strOutInfo ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strOutInfo );
+ }
+ }
+
return NULL;
}
-
+
unsigned int CMonoFunctions::Resource::GetLastStartTime( DWORD pResource )
{
- if( RESOURCE )
- {
- unsigned int uiTime;
-
- if( CLuaFunctionDefinitions::GetResourceLastStartTime( RESOURCE->GetLua(), (void*)pResource, uiTime ) )
- {
- return uiTime;
- }
- }
-
+ if( RESOURCE )
+ {
+ unsigned int uiTime;
+
+ if( CLuaFunctionDefinitions::GetResourceLastStartTime( RESOURCE->GetLua(), (void*)pResource, uiTime ) )
+ {
+ return uiTime;
+ }
+ }
+
return 0;
}
-
+
MonoString* CMonoFunctions::Resource::GetLoadFailureReason( DWORD pResource )
{
- if( RESOURCE )
- {
- string strOutReason;
-
- if( CLuaFunctionDefinitions::GetResourceLoadFailureReason( RESOURCE->GetLua(), (void*)pResource, strOutReason ) )
- {
- return RESOURCE->NewString( strOutReason );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strOutReason;
+
+ if( CLuaFunctionDefinitions::GetResourceLoadFailureReason( RESOURCE->GetLua(), (void*)pResource, strOutReason ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strOutReason );
+ }
+ }
+
return NULL;
}
-
+
unsigned int CMonoFunctions::Resource::GetLoadTime( DWORD pResource )
{
- if( RESOURCE )
- {
- unsigned int uiTime;
-
- if( CLuaFunctionDefinitions::GetResourceLoadTime( RESOURCE->GetLua(), (void*)pResource, uiTime ) )
- {
- return uiTime;
- }
- }
-
+ if( RESOURCE )
+ {
+ unsigned int uiTime;
+
+ if( CLuaFunctionDefinitions::GetResourceLoadTime( RESOURCE->GetLua(), (void*)pResource, uiTime ) )
+ {
+ return uiTime;
+ }
+ }
+
return 0;
}
-
+
MonoString* CMonoFunctions::Resource::GetName( DWORD pResource )
{
- if( RESOURCE )
- {
- string strOut;
-
- if( CLuaFunctionDefinitions::GetResourceName( RESOURCE->GetLua(), (void*)pResource, strOut ) )
- {
- return RESOURCE->NewString( strOut );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strOut;
+
+ if( CLuaFunctionDefinitions::GetResourceName( RESOURCE->GetLua(), (void*)pResource, strOut ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strOut );
+ }
+ }
+
return NULL;
}
-
+
MonoArray* CMonoFunctions::Resource::GetResources( void )
{
- if( RESOURCE )
- {
- CLuaArguments* pLuaTable = CLuaFunctionDefinitions::GetResources( RESOURCE->GetLua() );
-
- return RESOURCE->NewArray( mono_get_uint32_class(), pLuaTable );
- }
-
+ if( RESOURCE )
+ {
+ CLuaArguments* pLuaTable = CLuaFunctionDefinitions::GetResources( RESOURCE->GetLua() );
+
+ return RESOURCE->GetDomain()->NewArray( mono_get_uint32_class(), pLuaTable );
+ }
+
return NULL;
}
-
+
MonoString* CMonoFunctions::Resource::GetState( DWORD pResource )
{
- if( RESOURCE )
- {
- string strOut;
-
- if( CLuaFunctionDefinitions::GetResourceState( RESOURCE->GetLua(), (void*)pResource, strOut ) )
- {
- return RESOURCE->NewString( strOut );
- }
- }
-
+ if( RESOURCE )
+ {
+ string strOut;
+
+ if( CLuaFunctionDefinitions::GetResourceState( RESOURCE->GetLua(), (void*)pResource, strOut ) )
+ {
+ return RESOURCE->GetDomain()->NewString( strOut );
+ }
+ }
+
return NULL;
}
-
+
DWORD CMonoFunctions::Resource::GetCurrent( void )
{
- if( RESOURCE )
- {
- return (DWORD)CLuaFunctionDefinitions::GetThisResource( RESOURCE->GetLua() );
- }
-
+ if( RESOURCE )
+ {
+ return (DWORD)CLuaFunctionDefinitions::GetThisResource( RESOURCE->GetLua() );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Resource::Refresh( bool refreshAll )
{
- if( RESOURCE )
- {
- return CLuaFunctionDefinitions::RefreshResources( RESOURCE->GetLua(), refreshAll );
- }
-
+ if( RESOURCE )
+ {
+ return CLuaFunctionDefinitions::RefreshResources( RESOURCE->GetLua(), refreshAll );
+ }
+
return NULL;
}
-
+
bool CMonoFunctions::Resource::RemoveDefaultSetting( DWORD pResource, MonoString* msSettingName )
{
- if( RESOURCE )
- {
- const char* szSettingName = mono_string_to_utf8( msSettingName );
-
- return CLuaFunctionDefinitions::RemoveResourceDefaultSetting( RESOURCE->GetLua(), (void*)pResource, szSettingName );
- }
-
+ if( RESOURCE )
+ {
+ const char* szSettingName = mono_string_to_utf8( msSettingName );
+
+ return CLuaFunctionDefinitions::RemoveResourceDefaultSetting( RESOURCE->GetLua(), (void*)pResource, 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 )
{
- if( RESOURCE )
- {
- return CLuaFunctionDefinitions::StartResource( RESOURCE->GetLua(), (void*)pResource, persistent, startIncludedResources, loadServerConfigs, loadMaps, loadServerScripts, loadHTML, loadClientConfigs, loadClientScripts, loadFiles );
- }
-
+ if( RESOURCE )
+ {
+ return CLuaFunctionDefinitions::StartResource( RESOURCE->GetLua(), (void*)pResource, persistent, startIncludedResources, loadServerConfigs, loadMaps, loadServerScripts, loadHTML, loadClientConfigs, loadClientScripts, loadFiles );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Resource::Restart( DWORD pResource )
{
- if( RESOURCE )
- {
- return CLuaFunctionDefinitions::RestartResource( RESOURCE->GetLua(), (void*)pResource );
- }
-
+ if( RESOURCE )
+ {
+ return CLuaFunctionDefinitions::RestartResource( RESOURCE->GetLua(), (void*)pResource );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Resource::Stop( DWORD pResource )
{
- if( RESOURCE )
- {
- return CLuaFunctionDefinitions::StopResource( RESOURCE->GetLua(), (void*)pResource );
- }
-
+ if( RESOURCE )
+ {
+ return CLuaFunctionDefinitions::StopResource( RESOURCE->GetLua(), (void*)pResource );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Resource::SetDefaultSetting( DWORD pResource, MonoString* msSettingName, MonoString* msSettingValue )
{
- if( RESOURCE )
- {
- 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 );
- }
-
+ if( RESOURCE )
+ {
+ 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 );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Resource::SetInfo( DWORD pResource, MonoString* msAttribute, MonoString* msValue )
{
- if( RESOURCE )
- {
- 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 );
- }
-
+ if( RESOURCE )
+ {
+ 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 );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Resource::Rename( MonoString* msResourceName, MonoString* msNewResourceName, MonoString* msOrganizationalPath )
{
- if( RESOURCE )
- {
- 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 );
- }
-
+ if( RESOURCE )
+ {
+ 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 false;
}
-
+
bool CMonoFunctions::Resource::Delete( MonoString* msResourceName )
{
- if( RESOURCE )
- {
- const char* szResourceName = mono_string_to_utf8( msResourceName );
-
- return CLuaFunctionDefinitions::DeleteResource( RESOURCE->GetLua(), szResourceName );
- }
-
+ if( RESOURCE )
+ {
+ const char* szResourceName = mono_string_to_utf8( msResourceName );
+
+ return CLuaFunctionDefinitions::DeleteResource( RESOURCE->GetLua(), szResourceName );
+ }
+
return false;
}
-
+
bool CMonoFunctions::Resource::UpdateACLRequest( DWORD pResource, MonoString* msRightName, bool bAccess, MonoString* msByWho )
{
- if( RESOURCE )
- {
- 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 );
- }
-
+ if( RESOURCE )
+ {
+ 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 );
+ }
+
return false;
}
diff --git a/mta-mono/src/CMonoFunctions_Team.cpp b/mta-mono/src/CMonoFunctions_Team.cpp
index d955e7a..6f2c5d0 100644
--- a/mta-mono/src/CMonoFunctions_Team.cpp
+++ b/mta-mono/src/CMonoFunctions_Team.cpp
@@ -46,7 +46,7 @@ MonoString* CMonoFunctions::Team::GetName( DWORD pUserData )
if( CLuaFunctionDefinitions::GetTeamName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) )
{
- return RESOURCE->NewString( strOutName );
+ return RESOURCE->GetDomain()->NewString( strOutName );
}
}
@@ -61,7 +61,7 @@ MonoObject* CMonoFunctions::Team::GetColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) )
{
- return RESOURCE->NewObject( pColor );
+ return RESOURCE->GetDomain()->GetMTALib()->Color->New( pColor );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Vehicle.cpp b/mta-mono/src/CMonoFunctions_Vehicle.cpp
index 62b8370..58ae239 100644
--- a/mta-mono/src/CMonoFunctions_Vehicle.cpp
+++ b/mta-mono/src/CMonoFunctions_Vehicle.cpp
@@ -47,7 +47,7 @@ MonoString* CMonoFunctions::Vehicle::GetType( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleType( RESOURCE->GetLua(), (void*)pUserData, strType ) )
{
- return RESOURCE->NewString( strType );
+ return RESOURCE->GetDomain()->NewString( strType );
}
}
@@ -63,7 +63,7 @@ MonoArray* CMonoFunctions::Vehicle::GetVariant( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleVariant( RESOURCE->GetLua(), (void*)pUserData, ucVariant, ucVariant2 ) )
{
- MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 );
+ MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_char_class(), 2 );
if( pArray )
{
@@ -99,7 +99,7 @@ MonoObject* CMonoFunctions::Vehicle::GetColor( DWORD pUserData )
&pColor4
};
- return RESOURCE->NewObject( "MultiTheftAuto", "VehicleColor", args, 4 );
+ return RESOURCE->GetDomain()->GetMTALib()->GetClass( "VehicleColor" )->New( args, 4 );
}
}
@@ -161,7 +161,7 @@ MonoString* CMonoFunctions::Vehicle::GetName( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) )
{
- return RESOURCE->NewString( strOutName );
+ return RESOURCE->GetDomain()->NewString( strOutName );
}
}
@@ -176,7 +176,7 @@ MonoString* CMonoFunctions::Vehicle::GetNameFromModel( unsigned short usModel )
if( CLuaFunctionDefinitions::GetVehicleNameFromModel( RESOURCE->GetLua(), usModel, strOutName ) )
{
- return RESOURCE->NewString( strOutName );
+ return RESOURCE->GetDomain()->NewString( strOutName );
}
}
@@ -199,7 +199,7 @@ MonoArray* CMonoFunctions::Vehicle::GetOccupants( DWORD pUserData )
{
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehicleOccupants( RESOURCE->GetLua(), (void*)pUserData );
- return RESOURCE->NewArray( mono_get_uint32_class(), pLuaArguments );
+ return RESOURCE->GetDomain()->NewArray( mono_get_uint32_class(), pLuaArguments );
}
return NULL;
@@ -238,7 +238,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurnVelocity( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, vecVelocity ) )
{
- return RESOURCE->NewObject( vecVelocity );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecVelocity );
}
}
@@ -253,7 +253,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurretPosition( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{
- return RESOURCE->NewObject( vecPosition );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
}
}
@@ -281,7 +281,7 @@ MonoArray* CMonoFunctions::Vehicle::GetOfType( unsigned int uiModel )
{
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehiclesOfType( RESOURCE->GetLua(), uiModel );
- return RESOURCE->NewArray( mono_get_uint32_class(), pLuaArguments );
+ return RESOURCE->GetDomain()->NewArray( mono_get_uint32_class(), pLuaArguments );
}
return NULL;
@@ -308,7 +308,7 @@ MonoArray* CMonoFunctions::Vehicle::GetUpgrades( DWORD pUserData )
{
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehicleUpgrades( RESOURCE->GetLua(), (void*)pUserData );
- return RESOURCE->NewArray( mono_get_uint32_class(), pLuaArguments );
+ return RESOURCE->GetDomain()->NewArray( mono_get_uint32_class(), pLuaArguments );
}
return NULL;
@@ -322,7 +322,7 @@ MonoString* CMonoFunctions::Vehicle::GetUpgradeSlotName( unsigned short usUpgrad
if( CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( RESOURCE->GetLua(), usUpgrade, strOutName ) )
{
- return RESOURCE->NewString( strOutName );
+ return RESOURCE->GetDomain()->NewString( strOutName );
}
}
@@ -335,7 +335,7 @@ MonoArray* CMonoFunctions::Vehicle::GetCompatibleUpgrades( DWORD pUserData )
{
CLuaArguments* pLuaArguments = CLuaFunctionDefinitions::GetVehicleCompatibleUpgrades( RESOURCE->GetLua(), (void*)pUserData );
- return RESOURCE->NewArray( mono_get_uint32_class(), pLuaArguments );
+ return RESOURCE->GetDomain()->NewArray( mono_get_uint32_class(), pLuaArguments );
}
return NULL;
@@ -369,7 +369,7 @@ MonoObject* CMonoFunctions::Vehicle::GetWheelStates( DWORD pUserData )
&ucFrontLeft, &ucRearLeft, &ucFrontRight, &ucRearRight
};
- return RESOURCE->NewObject( "MultiTheftAuto.Vehicle", "VehicleWheelsState", args, 4 );
+ return RESOURCE->GetDomain()->GetMTALib()->GetClass( "Vehicle", "VehicleWheelsState" )->New( args, 4 );
}
}
@@ -464,7 +464,7 @@ MonoString* CMonoFunctions::Vehicle::GetPlateText( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehiclePlateText( RESOURCE->GetLua(), (void*)pUserData, szPlateText ) )
{
- return RESOURCE->NewString( szPlateText );
+ return RESOURCE->GetDomain()->NewString( szPlateText );
}
}
@@ -624,7 +624,7 @@ MonoObject* CMonoFunctions::Vehicle::GetHeadLightColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{
- return RESOURCE->NewObject( outColor );
+ return RESOURCE->GetDomain()->GetMTALib()->Color->New( outColor );
}
}
diff --git a/mta-mono/src/CMonoFunctions_Water.cpp b/mta-mono/src/CMonoFunctions_Water.cpp
index 7cf1545..5acf059 100644
--- a/mta-mono/src/CMonoFunctions_Water.cpp
+++ b/mta-mono/src/CMonoFunctions_Water.cpp
@@ -76,7 +76,7 @@ MonoObject* CMonoFunctions::Water::GetVertexPosition( DWORD pUserData, int iVert
if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) )
{
- return RESOURCE->NewObject( vecPosition );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecPosition );
}
}
@@ -103,7 +103,7 @@ MonoObject* CMonoFunctions::Water::GetColor( void )
if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) )
{
- return RESOURCE->NewObject( pColor );
+ return RESOURCE->GetDomain()->GetMTALib()->Color->New( pColor );
}
}
diff --git a/mta-mono/src/CMonoFunctions_World.cpp b/mta-mono/src/CMonoFunctions_World.cpp
index e4be1fc..09bdc8f 100644
--- a/mta-mono/src/CMonoFunctions_World.cpp
+++ b/mta-mono/src/CMonoFunctions_World.cpp
@@ -21,7 +21,7 @@ MonoArray* CMonoFunctions::World::GetTime( void )
if( CLuaFunctionDefinitions::GetTime( RESOURCE->GetLua(), ucHour, ucMinute ) )
{
- MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 );
+ MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_char_class(), 2 );
mono_array_set( pArray, unsigned char, 0, ucHour );
mono_array_set( pArray, unsigned char, 1, ucMinute );
@@ -41,7 +41,7 @@ MonoArray* CMonoFunctions::World::GetWeather( void )
if( CLuaFunctionDefinitions::GetWeather( RESOURCE->GetLua(), ucWeather, ucWeatherBlending ) )
{
- MonoArray* pArray = mono_array_new( RESOURCE->m_pMonoDomain, mono_get_char_class(), 2 );
+ MonoArray* pArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), mono_get_char_class(), 2 );
mono_array_set( pArray, unsigned char, 0, ucWeather );
mono_array_set( pArray, unsigned char, 1, ucWeatherBlending );
@@ -63,7 +63,7 @@ MonoString* CMonoFunctions::World::GetZoneName( MonoObject* mPosition, bool bCit
if( CLuaFunctionDefinitions::GetZoneName( RESOURCE->GetLua(), vecPosition, strOutName, bCitiesOnly ) )
{
- return RESOURCE->NewString( strOutName );
+ return RESOURCE->GetDomain()->NewString( strOutName );
}
}
@@ -275,12 +275,12 @@ MonoArray* CMonoFunctions::World::GetSunColor( void )
{
pCore.A = pCorona.A = 255;
- MonoObject* pCoreObject = RESOURCE->NewObject( pCore );
- MonoObject* pCoronaObject = RESOURCE->NewObject( pCorona );
+ MonoObject* pCoreObject = RESOURCE->GetDomain()->GetMTALib()->Color->New( pCore );
+ MonoObject* pCoronaObject = RESOURCE->GetDomain()->GetMTALib()->Color->New( pCorona );
if( pCoreObject && pCoronaObject )
{
- MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, CMonoObject::GetClass( pCoreObject ), 2 );
+ MonoArray* pMonoArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), CMonoObject::GetClass( pCoreObject ), 2 );
mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject );
mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject );
@@ -301,7 +301,7 @@ MonoObject* CMonoFunctions::World::GetWindVelocity( void )
if( CLuaFunctionDefinitions::GetWindVelocity( RESOURCE->GetLua(), vecVelocity.fX, vecVelocity.fY, vecVelocity.fZ ) )
{
- return RESOURCE->NewObject( vecVelocity );
+ return RESOURCE->GetDomain()->GetMTALib()->Vector3->New( vecVelocity );
}
}
@@ -393,12 +393,12 @@ MonoArray* CMonoFunctions::World::GetSkyGradient( void )
{
pCore.A = pCorona.A = 255;
- MonoObject* pCoreObject = RESOURCE->NewObject( pCore );
- MonoObject* pCoronaObject = RESOURCE->NewObject( pCorona );
+ MonoObject* pCoreObject = RESOURCE->GetDomain()->GetMTALib()->Color->New( pCore );
+ MonoObject* pCoronaObject = RESOURCE->GetDomain()->GetMTALib()->Color->New( pCorona );
if( pCoreObject && pCoronaObject )
{
- MonoArray* pMonoArray = mono_array_new( RESOURCE->m_pMonoDomain, CMonoObject::GetClass( pCoreObject ), 2 );
+ MonoArray* pMonoArray = mono_array_new( RESOURCE->GetDomain()->GetMonoPtr(), CMonoObject::GetClass( pCoreObject ), 2 );
mono_array_set( pMonoArray, MonoObject*, 0, pCoreObject );
mono_array_set( pMonoArray, MonoObject*, 1, pCoronaObject );
@@ -424,7 +424,7 @@ MonoObject* CMonoFunctions::World::GetHeatHaze( void )
&heatHazeSettings
};
- return RESOURCE->NewObject( "MultiTheftAuto", "HeatHazeSettings", args, 1 );
+ return RESOURCE->GetDomain()->GetMTALib()->GetClass( "HeatHazeSettings" )->New( args, 1 );
}
}
diff --git a/mta-mono/src/CMonoGC.cpp b/mta-mono/src/CMonoGC.cpp
new file mode 100644
index 0000000..07620fc
--- /dev/null
+++ b/mta-mono/src/CMonoGC.cpp
@@ -0,0 +1,92 @@
+/*********************************************************
+*
+* 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 "CMonoGC.h"
+
+CMonoGC::CMonoGC( void )
+{
+}
+
+void CMonoGC::Collect( int generation )
+{
+ mono_gc_collect( generation );
+}
+
+unsigned int CMonoGC::Hold( MonoObject* obj )
+{
+ if( obj )
+ {
+ mono_gchandle_new_weakref( reinterpret_cast< MonoObject* >( obj ), false );
+ }
+
+ return -1;
+}
+
+unsigned int CMonoGC::HoldWithHope( MonoObject* obj )
+{
+ if( obj )
+ {
+ return mono_gchandle_new_weakref( reinterpret_cast< MonoObject* >( obj ), true );
+ }
+
+ return -1;
+}
+
+unsigned int CMonoGC::Keep( MonoObject* obj )
+{
+ if( obj )
+ {
+ return mono_gchandle_new( reinterpret_cast< MonoObject* >( obj ), false );
+ }
+
+ return -1;
+}
+
+unsigned int CMonoGC::Pin( MonoObject* obj )
+{
+ if( obj )
+ {
+ return mono_gchandle_new( reinterpret_cast< MonoObject* >( obj ), true );
+ }
+
+ return -1;
+}
+
+int CMonoGC::GetMaxGeneration()
+{
+ return mono_gc_max_generation();
+}
+
+int64 CMonoGC::GetHeapSize()
+{
+ return mono_gc_get_heap_size();
+}
+
+void CMonoGC::ReleaseGCHandle( unsigned int handle )
+{
+ if( handle == -1 )
+ {
+ return;
+ }
+
+ mono_gchandle_free( handle );
+}
+
+MonoObject* CMonoGC::GetGCHandleTarget( unsigned int handle )
+{
+ if( handle == -1 )
+ {
+ return nullptr;
+ }
+
+ return mono_gchandle_get_target( handle );
+}
\ No newline at end of file
diff --git a/mta-mono/src/CMonoGC.h b/mta-mono/src/CMonoGC.h
new file mode 100644
index 0000000..9b7e29f
--- /dev/null
+++ b/mta-mono/src/CMonoGC.h
@@ -0,0 +1,36 @@
+/*********************************************************
+*
+* 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 CMonoGC;
+
+#ifndef __CMONOGC_H
+#define __CMONOGC_H
+
+class CMonoGC
+{
+public:
+ CMonoGC ( void );
+
+ void Collect ( int generation = -1 );
+
+ unsigned int Hold ( MonoObject* obj );
+ unsigned int HoldWithHope ( MonoObject* obj );
+ unsigned int Keep ( MonoObject* obj );
+ unsigned int Pin ( MonoObject* obj );
+
+ int GetMaxGeneration ( void );
+ int64 GetHeapSize ( void );
+ void ReleaseGCHandle ( unsigned int handle );
+ MonoObject* GetGCHandleTarget ( unsigned int handle );
+};
+
+#endif
\ No newline at end of file
diff --git a/mta-mono/src/CMonoInterface.cpp b/mta-mono/src/CMonoInterface.cpp
new file mode 100644
index 0000000..d8a53b1
--- /dev/null
+++ b/mta-mono/src/CMonoInterface.cpp
@@ -0,0 +1,50 @@
+/*********************************************************
+*
+* 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 "CMonoInterface.h"
+#include "CMonoFunctions.h"
+
+CMonoInterface::CMonoInterface( void )
+{
+ mono_set_dirs( "mods/deathmatch/mono/lib", "mods/deathmatch/mono/etc" );
+
+ mono_set_signal_chaining( false );
+
+ mono_debug_init( MONO_DEBUG_FORMAT_MONO );
+
+ this->m_pMonoDomain = mono_jit_init_version( "Mono Root", "v4.0.30319" );
+
+ mono_domain_set_config( this->m_pMonoDomain, "mods/deathmatch/", "mods/deathmatch/mono/etc/mono/4.5/machine.config" );
+
+ CMonoFunctions::AddInternals();
+
+ this->m_pGC = new CMonoGC;
+}
+
+CMonoInterface::~CMonoInterface( void )
+{
+ mono_jit_cleanup( this->m_pMonoDomain );
+
+ SAFE_DELETE( this->m_pGC );
+}
+
+CMonoDomain* CMonoInterface::CreateAppdomain( CResource* pResource, char* szName, char* szConfig )
+{
+ MonoDomain* pMonoDomain = mono_domain_create_appdomain( szName, szConfig );
+
+ if( pMonoDomain )
+ {
+ return new CMonoDomain( pResource, pMonoDomain );
+ }
+
+ return nullptr;
+}
diff --git a/mta-mono/src/CMonoInterface.h b/mta-mono/src/CMonoInterface.h
new file mode 100644
index 0000000..b78e7d8
--- /dev/null
+++ b/mta-mono/src/CMonoInterface.h
@@ -0,0 +1,47 @@
+/*********************************************************
+*
+* 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 CMonoInterface;
+
+#ifndef __CMONOINTERFACE_H
+#define __CMONOINTERFACE_H
+
+#include "CMonoGC.h"
+#include "CMonoDomain.h"
+#include "CResource.h"
+
+class CMonoInterface
+{
+private:
+ MonoDomain* m_pMonoDomain;
+
+ CMonoGC* m_pGC;
+
+public:
+ CMonoInterface ( void );
+ ~CMonoInterface ( void );
+
+ CMonoDomain* CreateAppdomain ( CResource* pResource, char* szName, char* szConfig );
+
+ CMonoGC* GetGC ( void ) { return this->m_pGC; }
+
+#pragma region Static methods
+
+ static string GetBinariesDirectory( void )
+ {
+ return "mods/deathmatch/resources/[ire]";
+ }
+
+#pragma endregion
+};
+
+#endif
\ No newline at end of file
diff --git a/mta-mono/src/CMonoMTALib.cpp b/mta-mono/src/CMonoMTALib.cpp
new file mode 100644
index 0000000..8bae72e
--- /dev/null
+++ b/mta-mono/src/CMonoMTALib.cpp
@@ -0,0 +1,68 @@
+/*********************************************************
+*
+* 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 "CMonoMTALib.h"
+
+CMonoMTALib::CMonoMTALib( CMonoDomain* pDomain )
+{
+ this->m_pAssembly = nullptr;
+ this->m_pImage = nullptr;
+ this->m_pDomain = pDomain;
+
+ string strPath( CMonoInterface::GetBinariesDirectory() + "/" + pDomain->GetResource()->GetName() + "/MultiTheftAuto.dll" );
+
+ this->m_pAssembly = pDomain->OpenAssembly( strPath.c_str() );
+
+ if( this->m_pAssembly )
+ {
+ this->m_pImage = mono_assembly_get_image( this->m_pAssembly );
+
+ if( this->m_pImage )
+ {
+ this->Color = this->GetClass( "Color" );
+ this->Vector2 = this->GetClass( "Vector2" );
+ this->Vector3 = this->GetClass( "Vector3" );
+
+ MonoClass* pMonoClass = mono_class_from_name( this->m_pImage, "MultiTheftAuto", "MultiTheftAuto" );
+
+ if( pMonoClass )
+ {
+ MonoObject* pMonoObject = this->m_pDomain->CreateObject( pMonoClass );
+
+ mono_gchandle_new( pMonoObject, false );
+
+ mono_runtime_object_init( pMonoObject );
+ }
+ }
+ }
+}
+
+CMonoMTALib::~CMonoMTALib( void )
+{
+ this->m_pDomain = nullptr;
+ this->m_pAssembly = nullptr;
+ this->m_pImage = nullptr;
+}
+
+CMonoClass* CMonoMTALib::GetClass( const char* szName )
+{
+ return this->GetDomain()->FindOrAdd( mono_class_from_name( this->m_pImage, "MultiTheftAuto", szName ) );
+}
+
+CMonoClass* CMonoMTALib::GetClass( const char* szNameSpace, const char* szName )
+{
+ char szBuffer[ 128 ];
+
+ sprintf( szBuffer, "MultiTheftAuto.%s", szNameSpace );
+
+ return this->GetDomain()->FindOrAdd( mono_class_from_name( this->m_pImage, szBuffer, szName ) );
+}
\ No newline at end of file
diff --git a/mta-mono/src/CMonoMTALib.h b/mta-mono/src/CMonoMTALib.h
new file mode 100644
index 0000000..a602590
--- /dev/null
+++ b/mta-mono/src/CMonoMTALib.h
@@ -0,0 +1,43 @@
+/*********************************************************
+*
+* 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 CMonoMTALib;
+
+#ifndef __CMONOMTALIB_H
+#define __CMONOMTALIB_H
+
+#include "CMonoDomain.h"
+#include "CMonoClass.h"
+
+class CMonoMTALib
+{
+private:
+ MonoAssembly* m_pAssembly;
+ MonoImage* m_pImage;
+ CMonoDomain* m_pDomain;
+
+public:
+ CMonoClass* Color;
+ CMonoClass* Vector2;
+ CMonoClass* Vector3;
+
+public:
+ CMonoMTALib ( CMonoDomain* pDomain );
+ ~CMonoMTALib ( void );
+
+ CMonoClass* GetClass ( const char* szName );
+ CMonoClass* GetClass ( const char* szNameSpace, const char* szName );
+
+ CMonoDomain* GetDomain ( void ) { return this->m_pDomain; }
+};
+
+#endif
\ No newline at end of file
diff --git a/mta-mono/src/CMonoObject.cpp b/mta-mono/src/CMonoObject.cpp
index 85254af..60733b5 100644
--- a/mta-mono/src/CMonoObject.cpp
+++ b/mta-mono/src/CMonoObject.cpp
@@ -10,6 +10,7 @@
*
*********************************************************/
+#include "StdInc.h"
#include "CMonoObject.h"
MonoClass* CMonoObject::GetClass( MonoObject* pObject )
diff --git a/mta-mono/src/CResource.cpp b/mta-mono/src/CResource.cpp
index dad9f50..975d20b 100644
--- a/mta-mono/src/CResource.cpp
+++ b/mta-mono/src/CResource.cpp
@@ -10,62 +10,121 @@
*
*********************************************************/
+#include "StdInc.h"
#include "CResource.h"
#include "CResourceManager.h"
+#include "CFunctions.h"
#include "include/ILuaModuleManager.h"
#include "lua/CLuaFunctionDefinitions.h"
extern ILuaModuleManager10 *g_pModuleManager;
extern CResourceManager *g_pResourceManager;
-CResource::CResource( lua_State *pLuaVM, string sName )
+CResource::CResource( CMonoInterface* pMono, lua_State *pLuaVM, string sName )
{
+ this->m_pMono = pMono;
this->m_pLuaVM = pLuaVM;
this->m_sName = sName;
- this->m_pMonoAssembly = NULL;
- this->m_pMonoAssemblyLib = NULL;
- this->m_pMonoGCHandle = NULL;
- this->m_pMonoDomain = NULL;
- this->m_pMonoImage = NULL;
- this->m_pMonoImageLib = NULL;
- this->m_pMonoClass = NULL;
+ this->m_pMonoAssembly = nullptr;
+ this->m_pMonoGCHandle = 0;
+ this->m_pMonoDomain = nullptr;
+ this->m_pMonoImage = nullptr;
+ this->m_pMonoClass = nullptr;
}
CResource::~CResource( void )
{
+ this->GetMono()->GetGC()->Collect( this->GetMono()->GetGC()->GetMaxGeneration() );
+
mono_domain_set( mono_get_root_domain(), false );
if( this->m_pMonoDomain )
{
- mono_domain_unload( this->m_pMonoDomain );
+ this->m_pMonoDomain->Unload();
+ this->m_pMonoDomain = nullptr;
}
- mono_gc_collect( mono_gc_max_generation() );
-
g_pResourceManager->RemoveFromList( this );
- this->m_pMonoAssembly = NULL;
- this->m_pMonoAssemblyLib = NULL;
- this->m_pMonoGCHandle = NULL;
- this->m_pMonoDomain = NULL;
- this->m_pMonoImage = NULL;
- this->m_pMonoImageLib = NULL;
- this->m_pMonoClass = NULL;
+ this->m_pMonoAssembly = nullptr;
+ this->m_pMonoGCHandle = 0;
+ this->m_pMonoDomain = nullptr;
+ this->m_pMonoImage = nullptr;
+ this->m_pMonoClass = nullptr;
- this->m_pLuaVM = NULL;
+ this->m_pMono = nullptr;
+ this->m_pLuaVM = nullptr;
+ this->m_sName = nullptr;
+}
+
+bool CResource::CallEvent( string strEventName, void* pThis, void* pSource, void* pClient, void **args )
+{
+ MonoEvent* pEvent = nullptr;
+ MonoMethod* method = nullptr;
+ MonoClass* klass = this->GetDomain()->GetMTALib()->GetClass( "Element" )->GetMonoPtr();
+
+ g_pModuleManager->DebugPrintf( this->GetLua(), "CResource::CallEvent::%s", strEventName.substr( 2 ).c_str() );
+
+ gpointer iter;
+
+ while( klass )
+ {
+ iter = nullptr;
+
+ while( pEvent = mono_class_get_events( klass, &iter ) )
+ {
+ if( !strcmp( strEventName.substr( 2 ).c_str(), mono_event_get_name( pEvent ) ) )
+ {
+ method = mono_event_get_raise_method( pEvent );
+
+ break;
+ }
+ }
+
+ klass = mono_class_get_parent( klass );
+ }
+
+ if( method )
+ {
+ mono_runtime_invoke( method, pThis, args, nullptr );
+
+ return true;
+ }
+ else
+ {
+ g_pModuleManager->ErrorPrintf( "mono: method not found\n" );
+ }
+
+ return false;
+}
+
+void CResource::RegisterEvents( void )
+{
+ if( this->m_pLuaVM )
+ {
+ if( g_pModuleManager->RegisterFunction( this->m_pLuaVM, "mono_event_handler", CFunctions::monoEventHandler ) )
+ {
+ luaL_dostring( this->m_pLuaVM, "addEventHandler( 'onElementDestroy', root, \
+function( ... ) \
+ mono_event_handler( eventName, this, source, client, ... );\
+end \
+)"
+ );
+ }
+ }
}
bool CResource::Init( void )
{
if( this->m_pLuaVM )
{
- string sDirectory ( "mods/deathmatch/resources/[ire]/" + this->m_sName + "/" );
+ string sDirectory ( CMonoInterface::GetBinariesDirectory() + "/" + this->m_sName + "/" );
string sPath ( sDirectory + this->m_sName + ".dll" );
string sNamespace ( this->m_sName );
string sClass ( "Program" );
- this->m_pMonoDomain = mono_domain_create_appdomain( const_cast< char* >( this->m_sName.c_str( ) ), NULL );
+ this->m_pMonoDomain = this->GetMono()->CreateAppdomain( this, const_cast< char* >( this->m_sName.c_str() ), nullptr );
if( !this->m_pMonoDomain )
{
@@ -74,16 +133,11 @@ bool CResource::Init( void )
return false;
}
- mono_domain_set( this->m_pMonoDomain, false );
+ this->m_pMonoDomain->Set( false );
- this->m_pMonoAssemblyLib = mono_domain_assembly_open( this->m_pMonoDomain, ( sDirectory + "MultiTheftAuto.dll" ).c_str() );
+ this->m_pMonoDomain->Init();
- if( this->m_pMonoAssemblyLib )
- {
- this->m_pMonoImageLib = mono_assembly_get_image( this->m_pMonoAssemblyLib );
- }
-
- this->m_pMonoAssembly = mono_domain_assembly_open( this->m_pMonoDomain, sPath.c_str() );
+ this->m_pMonoAssembly = this->m_pMonoDomain->OpenAssembly( sPath.c_str() );
if( !this->m_pMonoAssembly )
{
@@ -92,10 +146,12 @@ bool CResource::Init( void )
return false;
}
+ this->RegisterEvents();
+
this->m_pMonoImage = mono_assembly_get_image( this->m_pMonoAssembly );
this->m_pMonoClass = mono_class_from_name( this->m_pMonoImage, sNamespace.c_str(), sClass.c_str() );
- MonoObject *pMonoObject = mono_object_new( this->m_pMonoDomain, this->m_pMonoClass );
+ MonoObject *pMonoObject = this->m_pMonoDomain->CreateObject( this->m_pMonoClass );
mono_gchandle_new( pMonoObject, false );
@@ -127,139 +183,47 @@ bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func
return true;
}
-MonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName )
+void CResource::Printf( const char* szFormat, ... )
{
- MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName );
+ va_list args;
- if( !pMonoClass )
- {
- pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName );
- }
+ va_start( args, szFormat );
- return pMonoClass;
+ char szBuffer[ 255 ];
+
+ vsprintf( szBuffer, szFormat, args );
+
+ va_end( args );
+
+ g_pModuleManager->Printf( szBuffer );
}
-MonoObject* CResource::NewObject( const char* szNamespace, const char* szName )
+void CResource::DebugPrintf( const char* szFormat, ... )
{
- MonoClass* pClass = this->GetClassFromName( szNamespace, szName );
-
- if( pClass )
- {
- MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get() );
-
- if( pObject )
- {
- return pObject;
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName );
- }
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
- }
+ va_list args;
- return nullptr;
+ va_start( args, szFormat );
+
+ char szBuffer[ 255 ];
+
+ vsprintf( szBuffer, szFormat, args );
+
+ va_end( args );
+
+ g_pModuleManager->DebugPrintf( this->m_pLuaVM, szBuffer );
}
-MonoObject* CResource::NewObject( SColor& pColor )
+void CResource::ErrorPrintf( const char* szFormat, ... )
{
- MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Color" );
-
- if( pClass )
- {
- MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), pColor );
-
- if( pObject )
- {
- return pObject;
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Color'\n", __FILE__, __LINE__ );
- }
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Color' not found\n", __FILE__, __LINE__ );
- }
+ va_list args;
- return nullptr;
-}
-
-MonoObject* CResource::NewObject( Vector2& vecVector )
-{
- MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector2" );
-
- if( pClass )
- {
- MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector );
-
- if( pObject )
- {
- return pObject;
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ );
- }
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ );
- }
-
- return nullptr;
-}
-
-MonoObject* CResource::NewObject( Vector3& vecVector )
-{
- MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector3" );
-
- if( pClass )
- {
- MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector );
-
- if( pObject )
- {
- return pObject;
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector3'\n", __FILE__, __LINE__ );
- }
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ );
- }
-
- return nullptr;
-}
-
-MonoObject* CResource::NewObject( const char* szNamespace, const char* szName, void** args, int argc )
-{
- MonoClass* pClass = this->GetClassFromName( szNamespace, szName );
-
- if( pClass )
- {
- MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), args, argc );
-
- if( pObject )
- {
- return pObject;
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName );
- }
- }
- else
- {
- g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
- }
-
- return nullptr;
+ va_start( args, szFormat );
+
+ char szBuffer[ 255 ];
+
+ vsprintf( szBuffer, szFormat, args );
+
+ va_end( args );
+
+ g_pModuleManager->ErrorPrintf( szBuffer );
}
diff --git a/mta-mono/src/CResource.h b/mta-mono/src/CResource.h
index c2b14ef..0c48fb5 100644
--- a/mta-mono/src/CResource.h
+++ b/mta-mono/src/CResource.h
@@ -17,88 +17,44 @@ class CResource;
#include "Common.h"
#include "CMonoClass.h"
+#include "CMonoInterface.h"
#include "extra/CLuaArguments.h"
class CResource
{
private:
- string m_sName;
+ string m_sName;
- MonoAssembly *m_pMonoAssembly;
- MonoAssembly *m_pMonoAssemblyLib;
- MonoImage *m_pMonoImage;
- MonoImage *m_pMonoImageLib;
- MonoClass *m_pMonoClass;
- uint32_t m_pMonoGCHandle;
+ MonoAssembly* m_pMonoAssembly;
+ MonoImage* m_pMonoImage;
+ MonoClass* m_pMonoClass;
+ uint32_t m_pMonoGCHandle;
+
+ lua_State* m_pLuaVM;
+
+ CMonoInterface* m_pMono;
+ CMonoDomain* m_pMonoDomain;
public:
- lua_State *m_pLuaVM;
- MonoDomain *m_pMonoDomain;
+ CResource ( CMonoInterface* m_pMono, lua_State *pLuaVM, string sName );
+ ~CResource ( void );
- CResource ( lua_State *pLuaVM, string sName );
- ~CResource ( void );
+ bool CallEvent ( string strEventName, void* pThis, void* pSource, void* pClient, void **args );
- bool Init ( void );
- void OnStopping ( void );
- void DoPulse ( void );
- bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func );
+ void RegisterEvents ( void );
+ bool Init ( void );
+ void OnStopping ( void );
+ void DoPulse ( void );
+ bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func );
- MonoClass* GetClassFromName( const char* szNamespace, const char* szName );
+ void Printf ( const char* szFormat, ... );
+ void DebugPrintf ( const char* szFormat, ... );
+ void ErrorPrintf ( const char* szFormat, ... );
- MonoObject* NewObject( const char* szNamespace, const char* szName );
- MonoObject* NewObject( SColor& pColor );
- MonoObject* NewObject( Vector2& vecVector );
- MonoObject* NewObject( Vector3& vecVector );
- MonoObject* NewObject( const char* szNamespace, const char* szName, void** args, int argc );
-
- MonoString* NewString( const char* szText )
- {
- return mono_string_new( this->m_pMonoDomain, szText );
- }
-
- MonoString* NewString( string strText )
- {
- return mono_string_new( this->m_pMonoDomain, strText.c_str() );
- }
-
- template MonoArray* NewArray( MonoClass* pMonoClass, CLuaArguments* pLuaArguments = NULL )
- {
- MonoArray* pArray = mono_array_new( this->m_pMonoDomain, pMonoClass, pLuaArguments ? pLuaArguments->Count() : 0 );
-
- if( pLuaArguments )
- {
- vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin();
-
- for( unsigned int i = 0; iter != pLuaArguments->IterEnd(); iter++, i++ )
- {
- if( LuaType == LUA_TBOOLEAN )
- {
- mono_array_set( pArray, T, i, (T)( ( *iter )->GetBoolean() ) );
- }
- else if( LuaType == LUA_TLIGHTUSERDATA )
- {
- mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) );
- }
- else if( LuaType == LUA_TNUMBER )
- {
- mono_array_set( pArray, T, i, ( *iter )->GetNumber< T >() );
- }
- else if( LuaType == LUA_TSTRING )
- {
- mono_array_set( pArray, T, i, (T)( ( *iter )->GetString() ) );
- }
- else if( LuaType == LUA_TUSERDATA )
- {
- mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) );
- }
- }
- }
-
- return pArray;
- }
-
- string GetName ( void ) { return this->m_sName; }
- lua_State *GetLua ( void ) { return this->m_pLuaVM; }
+ 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; }
};
#endif
\ No newline at end of file
diff --git a/mta-mono/src/CResourceManager.cpp b/mta-mono/src/CResourceManager.cpp
index 2727c22..198c81f 100644
--- a/mta-mono/src/CResourceManager.cpp
+++ b/mta-mono/src/CResourceManager.cpp
@@ -10,15 +10,12 @@
*
*********************************************************/
+#include "StdInc.h"
#include "CResourceManager.h"
-CResourceManager::CResourceManager( void )
+CResourceManager::CResourceManager( CMonoInterface* pMono )
{
- mono_set_dirs( "mods/deathmatch/mono/lib", "mods/deathmatch/mono/etc" );
-
- this->m_pMonoDomain = mono_jit_init_version( "Mono Root", "v4.0.30319" );
-
- CMonoFunctions::AddInternals();
+ this->m_pMono = pMono;
}
CResourceManager::~CResourceManager( void )
@@ -27,8 +24,6 @@ CResourceManager::~CResourceManager( void )
{
delete iter;
}
-
- mono_jit_cleanup( this->m_pMonoDomain );
}
CResource* CResourceManager::Create( lua_State* luaVM, string strName )
@@ -44,7 +39,7 @@ CResource* CResourceManager::Create( lua_State* luaVM, string strName )
return nullptr;
}
- CResource *pResource = new CResource( luaVM, strName );
+ CResource *pResource = new CResource( this->m_pMono, luaVM, strName );
this->AddToList( pResource );
@@ -63,7 +58,7 @@ CResource* CResourceManager::GetFromList( lua_State* pLuaVM )
{
for( auto iter : this->m_List )
{
- if( iter->m_pLuaVM == pLuaVM )
+ if( iter->GetLua() == pLuaVM )
{
return iter;
}
@@ -76,7 +71,7 @@ CResource* CResourceManager::GetFromList( MonoDomain* pDomain )
{
for( auto iter : this->m_List )
{
- if( iter->m_pMonoDomain == pDomain )
+ if( iter->GetDomain()->GetMonoPtr() == pDomain )
{
return iter;
}
diff --git a/mta-mono/src/CResourceManager.h b/mta-mono/src/CResourceManager.h
index d5d7b73..e850928 100644
--- a/mta-mono/src/CResourceManager.h
+++ b/mta-mono/src/CResourceManager.h
@@ -15,19 +15,20 @@ class CResourceManager;
#ifndef __CRESOURCEMANAGER_H
#define __CRESOURCEMANAGER_H
-#include "CMonoFunctions.h"
+#include "CResource.h"
+#include "CMonoInterface.h"
extern ILuaModuleManager10 *g_pModuleManager;
class CResourceManager
{
private:
- list< CResource* > m_List;
+ CMonoInterface* m_pMono;
- MonoDomain *m_pMonoDomain;
+ list< CResource* > m_List;
public:
- CResourceManager ( void );
+ CResourceManager ( CMonoInterface* pMono );
~CResourceManager ( void );
CResource* Create ( lua_State* luaVM, string strName );
diff --git a/mta-mono/src/Common.cpp b/mta-mono/src/Common.cpp
index 8debbff..aeb6f4c 100644
--- a/mta-mono/src/Common.cpp
+++ b/mta-mono/src/Common.cpp
@@ -1,3 +1,4 @@
+#include "StdInc.h"
#include "Common.h"
CVehicleColor::CVehicleColor( void )
diff --git a/mta-mono/src/Common.h b/mta-mono/src/Common.h
index b7ca7ff..e4cec47 100644
--- a/mta-mono/src/Common.h
+++ b/mta-mono/src/Common.h
@@ -16,44 +16,6 @@
*
*********************************************************/
-extern "C"
-{
- #include
- #include
- #include
-}
-
-#ifdef WIN32
- #define MTAEXPORT extern "C" __declspec(dllexport)
-#else
- #define MTAEXPORT extern "C"
-#endif
-
-#include
-#include
-#include