Изменён метод работы с библиотеками. Исправлены ошибки

This commit is contained in:
Kernell 2015-11-28 04:41:37 +03:00
parent 9b0242c67b
commit 31a0c20137
18 changed files with 4118 additions and 4443 deletions

View File

@ -1,189 +1,189 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
void CMonoFunctions::AddInternals( void ) void CMonoFunctions::AddInternals( void )
{ {
mono_add_internal_call( "MultiTheftAuto.Debug::Log", CMonoFunctions::Debug::Log ); mono_add_internal_call( "MultiTheftAuto.Debug::Log", CMonoFunctions::Debug::Log );
mono_add_internal_call( "MultiTheftAuto.Debug::Info", CMonoFunctions::Debug::Info ); mono_add_internal_call( "MultiTheftAuto.Debug::Info", CMonoFunctions::Debug::Info );
mono_add_internal_call( "MultiTheftAuto.Debug::Error", CMonoFunctions::Debug::Error ); mono_add_internal_call( "MultiTheftAuto.Debug::Error", CMonoFunctions::Debug::Error );
MONO_DECLARE( Config, Get ); MONO_DECLARE( Config, Get );
MONO_DECLARE( Config, Set ); MONO_DECLARE( Config, Set );
MONO_DECLARE( Server, GetMaxPlayers ); MONO_DECLARE( Server, GetMaxPlayers );
MONO_DECLARE( Server, SetMaxPlayers ); MONO_DECLARE( Server, SetMaxPlayers );
MONO_DECLARE( Server, OutputChatBox ); MONO_DECLARE( Server, OutputChatBox );
MONO_DECLARE( Server, OutputConsole ); MONO_DECLARE( Server, OutputConsole );
MONO_DECLARE( Server, SetPassword ); MONO_DECLARE( Server, SetPassword );
MONO_DECLARE( Server, GetVersion ); MONO_DECLARE( Server, GetVersion );
MONO_DECLARE( Server, GetGameType ); MONO_DECLARE( Server, GetGameType );
MONO_DECLARE( Server, GetMapName ); MONO_DECLARE( Server, GetMapName );
MONO_DECLARE( Server, SetGameType ); MONO_DECLARE( Server, SetGameType );
MONO_DECLARE( Server, SetMapName ); MONO_DECLARE( Server, SetMapName );
MONO_DECLARE( Server, GetRuleValue ); MONO_DECLARE( Server, GetRuleValue );
MONO_DECLARE( Server, SetRuleValue ); MONO_DECLARE( Server, SetRuleValue );
MONO_DECLARE( Server, RemoveRuleValue ); MONO_DECLARE( Server, RemoveRuleValue );
// Element create/destroy // Element create/destroy
MONO_DECLARE( Element, Create ); MONO_DECLARE( Element, Create );
MONO_DECLARE( Element, Destroy ); MONO_DECLARE( Element, Destroy );
MONO_DECLARE( Element, Clone ); MONO_DECLARE( Element, Clone );
// Element get funcs // Element get funcs
MONO_DECLARE( Element, GetByType ); MONO_DECLARE( Element, GetByType );
MONO_DECLARE( Element, IsElement ); MONO_DECLARE( Element, IsElement );
MONO_DECLARE( Element, GetType ); MONO_DECLARE( Element, GetType );
MONO_DECLARE( Element, GetByID ); MONO_DECLARE( Element, GetByID );
MONO_DECLARE( Element, GetByIndex ); MONO_DECLARE( Element, GetByIndex );
MONO_DECLARE( Element, GetChild ); MONO_DECLARE( Element, GetChild );
MONO_DECLARE( Element, GetChildrenCount ); MONO_DECLARE( Element, GetChildrenCount );
MONO_DECLARE( Element, GetID ); MONO_DECLARE( Element, GetID );
MONO_DECLARE( Element, GetParent ); MONO_DECLARE( Element, GetParent );
MONO_DECLARE( Element, GetPosition ); MONO_DECLARE( Element, GetPosition );
MONO_DECLARE( Element, GetRotation ); MONO_DECLARE( Element, GetRotation );
MONO_DECLARE( Element, GetVelocity ); MONO_DECLARE( Element, GetVelocity );
MONO_DECLARE( Element, GetInterior ); MONO_DECLARE( Element, GetInterior );
MONO_DECLARE( Element, IsWithinColShape ); MONO_DECLARE( Element, IsWithinColShape );
MONO_DECLARE( Element, IsWithinMarker ); MONO_DECLARE( Element, IsWithinMarker );
MONO_DECLARE( Element, GetDimension ); MONO_DECLARE( Element, GetDimension );
MONO_DECLARE( Element, GetZoneName ); MONO_DECLARE( Element, GetZoneName );
MONO_DECLARE( Element, IsAttached ); MONO_DECLARE( Element, IsAttached );
MONO_DECLARE( Element, GetAttachedTo ); MONO_DECLARE( Element, GetAttachedTo );
MONO_DECLARE( Element, GetColShape ); MONO_DECLARE( Element, GetColShape );
MONO_DECLARE( Element, GetAlpha ); MONO_DECLARE( Element, GetAlpha );
MONO_DECLARE( Element, IsDoubleSided ); MONO_DECLARE( Element, IsDoubleSided );
MONO_DECLARE( Element, GetHealth ); MONO_DECLARE( Element, GetHealth );
MONO_DECLARE( Element, GetModel ); MONO_DECLARE( Element, GetModel );
MONO_DECLARE( Element, IsInWater ); MONO_DECLARE( Element, IsInWater );
MONO_DECLARE( Element, GetAttachedOffsetPosition ); MONO_DECLARE( Element, GetAttachedOffsetPosition );
MONO_DECLARE( Element, GetAttachedOffsetRotation ); MONO_DECLARE( Element, GetAttachedOffsetRotation );
MONO_DECLARE( Element, GetSyncer ); MONO_DECLARE( Element, GetSyncer );
MONO_DECLARE( Element, GetCollisionsEnabled ); MONO_DECLARE( Element, GetCollisionsEnabled );
MONO_DECLARE( Element, IsFrozen ); MONO_DECLARE( Element, IsFrozen );
MONO_DECLARE( Element, GetLowLod ); MONO_DECLARE( Element, GetLowLod );
MONO_DECLARE( Element, IsLowLod ); MONO_DECLARE( Element, IsLowLod );
// Element set funcs // Element set funcs
MONO_DECLARE( Element, ClearVisibleTo ); MONO_DECLARE( Element, ClearVisibleTo );
MONO_DECLARE( Element, SetID ); MONO_DECLARE( Element, SetID );
MONO_DECLARE( Element, SetData ); MONO_DECLARE( Element, SetData );
MONO_DECLARE( Element, RemoveData ); MONO_DECLARE( Element, RemoveData );
MONO_DECLARE( Element, SetParent ); MONO_DECLARE( Element, SetParent );
MONO_DECLARE( Element, SetPosition ); MONO_DECLARE( Element, SetPosition );
MONO_DECLARE( Element, SetRotation ); MONO_DECLARE( Element, SetRotation );
MONO_DECLARE( Element, SetVelocity ); MONO_DECLARE( Element, SetVelocity );
MONO_DECLARE( Element, SetVisibleTo ); MONO_DECLARE( Element, SetVisibleTo );
MONO_DECLARE( Element, SetInterior ); MONO_DECLARE( Element, SetInterior );
MONO_DECLARE( Element, SetDimension ); MONO_DECLARE( Element, SetDimension );
MONO_DECLARE( Element, Attach ); MONO_DECLARE( Element, Attach );
MONO_DECLARE( Element, Detach ); MONO_DECLARE( Element, Detach );
MONO_DECLARE( Element, SetAlpha ); MONO_DECLARE( Element, SetAlpha );
MONO_DECLARE( Element, SetDoubleSided ); MONO_DECLARE( Element, SetDoubleSided );
MONO_DECLARE( Element, SetHealth ); MONO_DECLARE( Element, SetHealth );
MONO_DECLARE( Element, SetModel ); MONO_DECLARE( Element, SetModel );
MONO_DECLARE( Element, SetAttachedOffsets ); MONO_DECLARE( Element, SetAttachedOffsets );
MONO_DECLARE( Element, SetSyncer ); MONO_DECLARE( Element, SetSyncer );
MONO_DECLARE( Element, SetCollisionsEnabled ); MONO_DECLARE( Element, SetCollisionsEnabled );
MONO_DECLARE( Element, SetFrozen ); MONO_DECLARE( Element, SetFrozen );
MONO_DECLARE( Element, SetLowLod ); MONO_DECLARE( Element, SetLowLod );
// Player get functions // Player get functions
MONO_DECLARE( Player, GetCount ); MONO_DECLARE( Player, GetCount );
MONO_DECLARE( Player, GetFromName ); MONO_DECLARE( Player, GetFromName );
MONO_DECLARE( Player, GetPing ); MONO_DECLARE( Player, GetPing );
MONO_DECLARE( Player, GetMoney ); MONO_DECLARE( Player, GetMoney );
MONO_DECLARE( Player, GetRandom ); MONO_DECLARE( Player, GetRandom );
MONO_DECLARE( Player, IsMuted ); MONO_DECLARE( Player, IsMuted );
MONO_DECLARE( Player, GetTeam ); MONO_DECLARE( Player, GetTeam );
MONO_DECLARE( Player, GetWantedLevel ); MONO_DECLARE( Player, GetWantedLevel );
MONO_DECLARE( Player, GetAlivePlayers ); MONO_DECLARE( Player, GetAlivePlayers );
MONO_DECLARE( Player, GetDeadPlayers ); MONO_DECLARE( Player, GetDeadPlayers );
MONO_DECLARE( Player, GetIdleTime ); MONO_DECLARE( Player, GetIdleTime );
MONO_DECLARE( Player, IsMapForced ); MONO_DECLARE( Player, IsMapForced );
MONO_DECLARE( Player, GetNametagText ); MONO_DECLARE( Player, GetNametagText );
MONO_DECLARE( Player, GetNametagColor ); MONO_DECLARE( Player, GetNametagColor );
MONO_DECLARE( Player, IsNametagShowing ); MONO_DECLARE( Player, IsNametagShowing );
MONO_DECLARE( Player, GetSerial ); MONO_DECLARE( Player, GetSerial );
MONO_DECLARE( Player, GetUserName ); MONO_DECLARE( Player, GetUserName );
MONO_DECLARE( Player, GetBlurLevel ); MONO_DECLARE( Player, GetBlurLevel );
MONO_DECLARE( Player, GetName ); MONO_DECLARE( Player, GetName );
MONO_DECLARE( Player, GetIP ); MONO_DECLARE( Player, GetIP );
MONO_DECLARE( Player, GetAccount ); MONO_DECLARE( Player, GetAccount );
MONO_DECLARE( Player, GetVersion ); MONO_DECLARE( Player, GetVersion );
MONO_DECLARE( Player, GetACInfo ); MONO_DECLARE( Player, GetACInfo );
MONO_DECLARE( Player, GetPlayerAnnounceValue ); MONO_DECLARE( Player, GetPlayerAnnounceValue );
// Player set functions // Player set functions
MONO_DECLARE( Player, SetMoney ); MONO_DECLARE( Player, SetMoney );
MONO_DECLARE( Player, GiveMoney ); MONO_DECLARE( Player, GiveMoney );
MONO_DECLARE( Player, TakeMoney ); MONO_DECLARE( Player, TakeMoney );
MONO_DECLARE( Player, Spawn ); MONO_DECLARE( Player, Spawn );
MONO_DECLARE( Player, ShowHudComponent ); MONO_DECLARE( Player, ShowHudComponent );
MONO_DECLARE( Player, SetWantedLevel ); MONO_DECLARE( Player, SetWantedLevel );
MONO_DECLARE( Player, ForceMap ); MONO_DECLARE( Player, ForceMap );
MONO_DECLARE( Player, SetNametagText ); MONO_DECLARE( Player, SetNametagText );
MONO_DECLARE( Player, SetNametagColor ); MONO_DECLARE( Player, SetNametagColor );
MONO_DECLARE( Player, SetNametagShowing ); MONO_DECLARE( Player, SetNametagShowing );
MONO_DECLARE( Player, SetMuted ); MONO_DECLARE( Player, SetMuted );
MONO_DECLARE( Player, SetBlurLevel ); MONO_DECLARE( Player, SetBlurLevel );
MONO_DECLARE( Player, Redirect ); MONO_DECLARE( Player, Redirect );
MONO_DECLARE( Player, SetName ); MONO_DECLARE( Player, SetName );
MONO_DECLARE( Player, DetonateSatchels ); MONO_DECLARE( Player, DetonateSatchels );
MONO_DECLARE( Player, TakeScreenShot ); MONO_DECLARE( Player, TakeScreenShot );
MONO_DECLARE( Player, SetTeam ); MONO_DECLARE( Player, SetTeam );
MONO_DECLARE( Player, SetPlayerAnnounceValue ); MONO_DECLARE( Player, SetPlayerAnnounceValue );
// Input funcs // Input funcs
MONO_DECLARE( Player, BindKey ); MONO_DECLARE( Player, BindKey );
MONO_DECLARE( Player, UnbindKey ); MONO_DECLARE( Player, UnbindKey );
MONO_DECLARE( Player, GetControlState ); MONO_DECLARE( Player, GetControlState );
MONO_DECLARE( Player, IsControlEnabled ); MONO_DECLARE( Player, IsControlEnabled );
MONO_DECLARE( Player, SetControlState ); MONO_DECLARE( Player, SetControlState );
MONO_DECLARE( Player, ToggleControl ); MONO_DECLARE( Player, ToggleControl );
MONO_DECLARE( Player, ToggleAllControls ); MONO_DECLARE( Player, ToggleAllControls );
// Log in/out funcs // Log in/out funcs
MONO_DECLARE( Player, LogIn ); MONO_DECLARE( Player, LogIn );
MONO_DECLARE( Player, LogOut ); MONO_DECLARE( Player, LogOut );
// Admin funcs // Admin funcs
MONO_DECLARE( Player, Kick ); MONO_DECLARE( Player, Kick );
MONO_DECLARE( Player, Ban ); MONO_DECLARE( Player, Ban );
// Cursor get funcs // Cursor get funcs
MONO_DECLARE( Player, IsCursorShowing ); MONO_DECLARE( Player, IsCursorShowing );
// Cursor set funcs // Cursor set funcs
MONO_DECLARE( Player, ShowCursor ); MONO_DECLARE( Player, ShowCursor );
// Chat funcs // Chat funcs
MONO_DECLARE( Player, ShowChat ); MONO_DECLARE( Player, ShowChat );
// Camera get functions // Camera get functions
MONO_DECLARE( Player, GetCameraMatrix ); MONO_DECLARE( Player, GetCameraMatrix );
MONO_DECLARE( Player, GetCameraTarget ); MONO_DECLARE( Player, GetCameraTarget );
MONO_DECLARE( Player, GetCameraInterior ); MONO_DECLARE( Player, GetCameraInterior );
// Camera set functions // Camera set functions
MONO_DECLARE( Player, SetCameraMatrix ); MONO_DECLARE( Player, SetCameraMatrix );
MONO_DECLARE( Player, SetCameraTarget ); MONO_DECLARE( Player, SetCameraTarget );
MONO_DECLARE( Player, SetCameraInterior ); MONO_DECLARE( Player, SetCameraInterior );
MONO_DECLARE( Player, FadeCamera ); MONO_DECLARE( Player, FadeCamera );
// Ped get functions // Ped get functions
MONO_DECLARE( Ped, Create ); MONO_DECLARE( Ped, Create );
MONO_DECLARE( Ped, GetArmor ); MONO_DECLARE( Ped, GetArmor );
@ -246,8 +246,8 @@ void CMonoFunctions::AddInternals( void )
MONO_DECLARE( Ped, GiveWeapon ); MONO_DECLARE( Ped, GiveWeapon );
MONO_DECLARE( Ped, TakeWeapon ); MONO_DECLARE( Ped, TakeWeapon );
MONO_DECLARE( Ped, TakeAllWeapons ); MONO_DECLARE( Ped, TakeAllWeapons );
MONO_DECLARE( Ped, SetWeaponAmmo ); MONO_DECLARE( Ped, SetWeaponAmmo );
// Vehicle create/destroy functions // Vehicle create/destroy functions
MONO_DECLARE( Vehicle, Create ); MONO_DECLARE( Vehicle, Create );
@ -341,8 +341,8 @@ void CMonoFunctions::AddInternals( void )
MONO_DECLARE( Vehicle, SetSirens ); MONO_DECLARE( Vehicle, SetSirens );
MONO_DECLARE( Vehicle, GetSirens ); MONO_DECLARE( Vehicle, GetSirens );
MONO_DECLARE( Vehicle, GetSirenParams ); MONO_DECLARE( Vehicle, GetSirenParams );
MONO_DECLARE( Vehicle, SetPlateText ); MONO_DECLARE( Vehicle, SetPlateText );
// Marker create/destroy functions // Marker create/destroy functions
MONO_DECLARE( Marker, Create ); MONO_DECLARE( Marker, Create );
@ -603,241 +603,234 @@ void CMonoFunctions::AddInternals( void )
MONO_DECLARE( Resource, Rename ); MONO_DECLARE( Resource, Rename );
MONO_DECLARE( Resource, Delete ); MONO_DECLARE( Resource, Delete );
// MONO_DECLARE( Resource, GetACLRequests ); // MONO_DECLARE( Resource, GetACLRequests );
MONO_DECLARE( Resource, UpdateACLRequest ); MONO_DECLARE( Resource, UpdateACLRequest );
} }
void CMonoFunctions::Debug::Log( MonoString *string ) void CMonoFunctions::Debug::Log( MonoString *string )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
g_pModuleManager->Printf( "%s\n", mono_string_to_utf8( string ) ); g_pModuleManager->Printf( "%s\n", mono_string_to_utf8( string ) );
} }
} }
void CMonoFunctions::Debug::Info( MonoString *string ) void CMonoFunctions::Debug::Info( MonoString *string )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
g_pModuleManager->DebugPrintf( RESOURCE->GetLua(), "%s", mono_string_to_utf8( string ) ); g_pModuleManager->DebugPrintf( RESOURCE->GetLua(), "%s", mono_string_to_utf8( string ) );
} }
} }
void CMonoFunctions::Debug::Error( MonoString *string ) void CMonoFunctions::Debug::Error( MonoString *string )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
g_pModuleManager->ErrorPrintf( "%s\n", mono_string_to_utf8( string ) ); g_pModuleManager->ErrorPrintf( "%s\n", mono_string_to_utf8( string ) );
} }
} }
MonoString *CMonoFunctions::Config::Get( MonoString *msKey ) MonoString *CMonoFunctions::Config::Get( MonoString *msKey )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
string sValue = CLuaFunctionDefinitions::Get( RESOURCE->GetLua(), mono_string_to_utf8( msKey ) ); string sValue = CLuaFunctionDefinitions::Get( RESOURCE->GetLua(), mono_string_to_utf8( msKey ) );
return mono_string_new( mono_domain_get(), sValue.c_str() ); return mono_string_new( mono_domain_get(), sValue.c_str() );
} }
return mono_string_new( mono_domain_get(), "" ); return mono_string_new( mono_domain_get(), "" );
} }
bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue ) bool CMonoFunctions::Config::Set( MonoString *msKey, MonoString *msValue )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
const char* szKey = mono_string_to_utf8( msKey ); const char* szKey = mono_string_to_utf8( msKey );
const char* szValue = mono_string_to_utf8( msValue ); const char* szValue = mono_string_to_utf8( msValue );
return CLuaFunctionDefinitions::Set( RESOURCE->GetLua(), szKey, szValue ); return CLuaFunctionDefinitions::Set( RESOURCE->GetLua(), szKey, szValue );
} }
return false; return false;
} }
unsigned int CMonoFunctions::Server::GetMaxPlayers( void ) unsigned int CMonoFunctions::Server::GetMaxPlayers( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::GetMaxPlayers( RESOURCE->GetLua() ); return CLuaFunctionDefinitions::GetMaxPlayers( RESOURCE->GetLua() );
} }
return 0; return 0;
} }
bool CMonoFunctions::Server::SetMaxPlayers( unsigned int uiMax ) bool CMonoFunctions::Server::SetMaxPlayers( unsigned int uiMax )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetMaxPlayers( RESOURCE->GetLua(), uiMax ); return CLuaFunctionDefinitions::SetMaxPlayers( RESOURCE->GetLua(), uiMax );
} }
return 0; return 0;
} }
bool CMonoFunctions::Server::OutputChatBox( MonoString* msText, DWORD pElement, MonoObject* mpColor, bool bColorCoded ) bool CMonoFunctions::Server::OutputChatBox( MonoString* msText, DWORD pElement, MonoObject* mpColor, bool bColorCoded )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
const char* szText = mono_string_to_utf8( msText ); const char* szText = mono_string_to_utf8( msText );
CMonoObject pColor( mpColor ); unsigned char ucRed = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "R" );
unsigned char ucGreen = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "G" );
unsigned char ucRed = pColor.GetPropertyValue< unsigned char >( "R" ); unsigned char ucBlue = CMonoObject::GetPropertyValue< unsigned char >( mpColor, "B" );
unsigned char ucGreen = pColor.GetPropertyValue< unsigned char >( "G" );
unsigned char ucBlue = pColor.GetPropertyValue< unsigned char >( "B" ); return CLuaFunctionDefinitions::OutputChatBox( RESOURCE->GetLua(), szText, (void*)pElement, ucRed, ucGreen, ucBlue, bColorCoded );
}
return CLuaFunctionDefinitions::OutputChatBox( RESOURCE->GetLua(), szText, (void*)pElement, ucRed, ucGreen, ucBlue, bColorCoded );
} return false;
}
return false;
} bool CMonoFunctions::Server::OutputConsole( MonoString* msText, DWORD pElement )
{
bool CMonoFunctions::Server::OutputConsole( MonoString* msText, DWORD pElement ) if( RESOURCE )
{ {
if( RESOURCE ) const char* szText = mono_string_to_utf8( msText );
{
const char* szText = mono_string_to_utf8( msText ); return CLuaFunctionDefinitions::OutputConsole( RESOURCE->GetLua(), szText, (void*)pElement );
}
return CLuaFunctionDefinitions::OutputConsole( RESOURCE->GetLua(), szText, (void*)pElement );
} return false;
}
return false;
} bool CMonoFunctions::Server::SetPassword( MonoString* msPassword, bool bSave )
{
bool CMonoFunctions::Server::SetPassword( MonoString* msPassword, bool bSave ) if( RESOURCE )
{ {
if( RESOURCE ) const char* szPassword = mono_string_to_utf8( msPassword );
{
const char* szPassword = mono_string_to_utf8( msPassword ); return CLuaFunctionDefinitions::SetServerPassword( RESOURCE->GetLua(), szPassword, bSave );
}
return CLuaFunctionDefinitions::SetServerPassword( RESOURCE->GetLua(), szPassword, bSave );
} return false;
}
return false;
} MonoObject* CMonoFunctions::Server::GetVersion( void )
{
MonoObject* CMonoFunctions::Server::GetVersion( void ) if( RESOURCE )
{ {
if( RESOURCE ) LuaTable pLuaTable = CLuaFunctionDefinitions::GetVersion( RESOURCE->GetLua() );
{
LuaTable pLuaTable = CLuaFunctionDefinitions::GetVersion( RESOURCE->GetLua() ); if( !pLuaTable.empty() )
{
if( !pLuaTable.empty() ) unsigned long ulNumber = pLuaTable[ "number" ]->GetNumber< unsigned long >();
{ const char* szString = pLuaTable[ "mta" ]->GetString();
unsigned long ulNumber = pLuaTable[ "number" ]->GetNumber< unsigned long >(); const char* szName = pLuaTable[ "name" ]->GetString();
const char* szString = pLuaTable[ "mta" ]->GetString(); const char* szBuildType = pLuaTable[ "type" ]->GetString();
const char* szName = pLuaTable[ "name" ]->GetString(); unsigned long ulNetcode = pLuaTable[ "netcode" ]->GetNumber< unsigned long >();
const char* szBuildType = pLuaTable[ "type" ]->GetString(); const char* szOS = pLuaTable[ "os" ]->GetString();
unsigned long ulNetcode = pLuaTable[ "netcode" ]->GetNumber< unsigned long >(); const char* szBuildTag = pLuaTable[ "tag" ]->GetString();
const char* szOS = pLuaTable[ "os" ]->GetString(); const char* szSortable = pLuaTable[ "sortable" ]->GetString();
const char* szBuildTag = pLuaTable[ "tag" ]->GetString();
const char* szSortable = pLuaTable[ "sortable" ]->GetString(); void *args[] =
{
void *args[] = &ulNumber,
{ &szString,
&ulNumber, &szName,
&szString, &szBuildType,
&szName, &ulNetcode,
&szBuildType, &szOS,
&ulNetcode, &szBuildTag,
&szOS, &szSortable
&szBuildTag, };
&szSortable
}; return RESOURCE->NewObject( "MultiTheftAuto", "ServerVersion", args, 8 );
}
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "ServerVersion", args, 8 ); }
if( pObject ) return NULL;
{ }
return pObject->GetObject();
} MonoString* CMonoFunctions::Server::GetGameType( void )
} {
} if( RESOURCE )
{
return NULL; return RESOURCE->NewString( CLuaFunctionDefinitions::GetGameType( RESOURCE->GetLua() ) );
} }
MonoString* CMonoFunctions::Server::GetGameType( void ) return NULL;
{ }
if( RESOURCE )
{ MonoString* CMonoFunctions::Server::GetMapName( void )
return RESOURCE->NewString( CLuaFunctionDefinitions::GetGameType( RESOURCE->GetLua() ) ); {
} if( RESOURCE )
{
return NULL; return RESOURCE->NewString( CLuaFunctionDefinitions::GetMapName( RESOURCE->GetLua() ) );
} }
MonoString* CMonoFunctions::Server::GetMapName( void ) return NULL;
{ }
if( RESOURCE )
{ bool CMonoFunctions::Server::SetGameType( MonoString* msGameType )
return RESOURCE->NewString( CLuaFunctionDefinitions::GetMapName( RESOURCE->GetLua() ) ); {
} if( RESOURCE )
{
return NULL; const char* szGameType = mono_string_to_utf8( msGameType );
}
return CLuaFunctionDefinitions::SetGameType( RESOURCE->GetLua(), szGameType );
bool CMonoFunctions::Server::SetGameType( MonoString* msGameType ) }
{
if( RESOURCE ) return false;
{ }
const char* szGameType = mono_string_to_utf8( msGameType );
bool CMonoFunctions::Server::SetMapName( MonoString* msMapName )
return CLuaFunctionDefinitions::SetGameType( RESOURCE->GetLua(), szGameType ); {
} if( RESOURCE )
{
return false; const char* szMapName = mono_string_to_utf8( msMapName );
}
return CLuaFunctionDefinitions::SetMapName( RESOURCE->GetLua(), szMapName );
bool CMonoFunctions::Server::SetMapName( MonoString* msMapName ) }
{
if( RESOURCE ) return false;
{ }
const char* szMapName = mono_string_to_utf8( msMapName );
MonoString* CMonoFunctions::Server::GetRuleValue( MonoString* msKey )
return CLuaFunctionDefinitions::SetMapName( RESOURCE->GetLua(), szMapName ); {
} if( RESOURCE )
{
return false; const char* szKey = mono_string_to_utf8( msKey );
}
return RESOURCE->NewString( CLuaFunctionDefinitions::GetRuleValue( RESOURCE->GetLua(), szKey ) );
MonoString* CMonoFunctions::Server::GetRuleValue( MonoString* msKey ) }
{
if( RESOURCE ) return false;
{ }
const char* szKey = mono_string_to_utf8( msKey );
bool CMonoFunctions::Server::SetRuleValue( MonoString* msKey, MonoString* msValue )
return RESOURCE->NewString( CLuaFunctionDefinitions::GetRuleValue( RESOURCE->GetLua(), szKey ) ); {
} if( RESOURCE )
{
return false; const char* szKey = mono_string_to_utf8( msKey );
} const char* szValue = mono_string_to_utf8( msValue );
bool CMonoFunctions::Server::SetRuleValue( MonoString* msKey, MonoString* msValue ) return CLuaFunctionDefinitions::SetRuleValue( RESOURCE->GetLua(), szKey, szValue );
{ }
if( RESOURCE )
{ return false;
const char* szKey = mono_string_to_utf8( msKey ); }
const char* szValue = mono_string_to_utf8( msValue );
bool CMonoFunctions::Server::RemoveRuleValue( MonoString* msKey )
return CLuaFunctionDefinitions::SetRuleValue( RESOURCE->GetLua(), szKey, szValue ); {
} if( RESOURCE )
{
return false; const char* szKey = mono_string_to_utf8( msKey );
}
return CLuaFunctionDefinitions::RemoveRuleValue( RESOURCE->GetLua(), szKey );
bool CMonoFunctions::Server::RemoveRuleValue( MonoString* msKey ) }
{
if( RESOURCE ) return false;
{ }
const char* szKey = mono_string_to_utf8( msKey );
return CLuaFunctionDefinitions::RemoveRuleValue( RESOURCE->GetLua(), szKey );
}
return false;
}

View File

@ -1,36 +1,34 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Audio funcs // Audio funcs
bool CMonoFunctions::Audio::PlayFrontEnd( DWORD pUserData, unsigned char ucSound ) bool CMonoFunctions::Audio::PlayFrontEnd( DWORD pUserData, unsigned char ucSound )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::PlaySoundFrontEnd( RESOURCE->GetLua(), (void*)pUserData, ucSound ); return CLuaFunctionDefinitions::PlaySoundFrontEnd( RESOURCE->GetLua(), (void*)pUserData, ucSound );
} }
return false; return false;
} }
bool CMonoFunctions::Audio::PlayMission( DWORD pUserData, MonoObject* pPosition, unsigned short usSlot ) bool CMonoFunctions::Audio::PlayMission( DWORD pUserData, MonoObject* pPosition, unsigned short usSlot )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); return CLuaFunctionDefinitions::PlayMissionAudio( RESOURCE->GetLua(), (void*)pUserData, Vector3( pPosition ), usSlot );
}
return CLuaFunctionDefinitions::PlayMissionAudio( RESOURCE->GetLua(), (void*)pUserData, vecPosition, usSlot );
} return false;
}
return false;
}

View File

@ -1,175 +1,168 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Blip create/destroy functions // Blip create/destroy functions
DWORD CMonoFunctions::Blip::Create( MonoObject* pPosition, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo ) DWORD CMonoFunctions::Blip::Create( MonoObject* pPosition, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
SColor pColor = CMonoObject( color ).GetColor(); SColor pColor = CMonoObject::GetColor( color );
return (DWORD)CLuaFunctionDefinitions::CreateBlip( RESOURCE->GetLua(), vecPosition, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); return (DWORD)CLuaFunctionDefinitions::CreateBlip( RESOURCE->GetLua(), vecPosition, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo );
} }
return NULL; return NULL;
} }
DWORD CMonoFunctions::Blip::CreateAttachedTo( DWORD pTarget, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo ) DWORD CMonoFunctions::Blip::CreateAttachedTo( DWORD pTarget, unsigned char ucIcon, unsigned char ucSize, MonoObject* color, short sOrdering, unsigned short usVisibleDistance, DWORD pVisibleTo )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor = CMonoObject( color ).GetColor(); SColor pColor = CMonoObject::GetColor( color );
return (DWORD)CLuaFunctionDefinitions::CreateBlipAttachedTo( RESOURCE->GetLua(), (void*)pTarget, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo ); return (DWORD)CLuaFunctionDefinitions::CreateBlipAttachedTo( RESOURCE->GetLua(), (void*)pTarget, ucIcon, ucSize, pColor, sOrdering, usVisibleDistance, (void*)pVisibleTo );
} }
return NULL; return NULL;
} }
// Blip get functions // Blip get functions
unsigned char CMonoFunctions::Blip::GetIcon( DWORD pUserData ) unsigned char CMonoFunctions::Blip::GetIcon( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned char ucIcon; unsigned char ucIcon;
if( CLuaFunctionDefinitions::GetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ) ) if( CLuaFunctionDefinitions::GetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ) )
{ {
return ucIcon; return ucIcon;
} }
} }
return 0; return 0;
} }
unsigned char CMonoFunctions::Blip::GetSize( DWORD pUserData ) unsigned char CMonoFunctions::Blip::GetSize( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned char ucSize; unsigned char ucSize;
if( CLuaFunctionDefinitions::GetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ) ) if( CLuaFunctionDefinitions::GetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ) )
{ {
return ucSize; return ucSize;
} }
} }
return 0; return 0;
} }
MonoObject* CMonoFunctions::Blip::GetColor( DWORD pUserData ) MonoObject* CMonoFunctions::Blip::GetColor( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor outColor; SColor outColor;
if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetBlipColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
}
if( pObject )
{
return pObject->GetObject();
}
}
} }
return NULL; return NULL;
} }
short CMonoFunctions::Blip::GetOrdering( DWORD pUserData ) short CMonoFunctions::Blip::GetOrdering( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
short sOrdering; short sOrdering;
if( CLuaFunctionDefinitions::GetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ) ) if( CLuaFunctionDefinitions::GetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ) )
{ {
return sOrdering; return sOrdering;
} }
} }
return 0; return 0;
} }
unsigned short CMonoFunctions::Blip::GetVisibleDistance( DWORD pUserData ) unsigned short CMonoFunctions::Blip::GetVisibleDistance( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned short usVisibleDistance; unsigned short usVisibleDistance;
if( CLuaFunctionDefinitions::GetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ) ) if( CLuaFunctionDefinitions::GetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ) )
{ {
return usVisibleDistance; return usVisibleDistance;
} }
} }
return 0; return 0;
} }
// Blip set functions // Blip set functions
bool CMonoFunctions::Blip::SetIcon( DWORD pUserData, unsigned char ucIcon ) bool CMonoFunctions::Blip::SetIcon( DWORD pUserData, unsigned char ucIcon )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon ); return CLuaFunctionDefinitions::SetBlipIcon( RESOURCE->GetLua(), (void*)pUserData, ucIcon );
} }
return false; return false;
} }
bool CMonoFunctions::Blip::SetSize( DWORD pUserData, unsigned char ucSize ) bool CMonoFunctions::Blip::SetSize( DWORD pUserData, unsigned char ucSize )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize ); return CLuaFunctionDefinitions::SetBlipSize( RESOURCE->GetLua(), (void*)pUserData, ucSize );
} }
return false; return false;
} }
bool CMonoFunctions::Blip::SetColor( DWORD pUserData, MonoObject* color ) bool CMonoFunctions::Blip::SetColor( DWORD pUserData, MonoObject* color )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor = CMonoObject( color ).GetColor(); return CLuaFunctionDefinitions::SetBlipColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( color ) );
return CLuaFunctionDefinitions::SetBlipColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
} }
return false; return false;
} }
bool CMonoFunctions::Blip::SetOrdering( DWORD pUserData, short sOrdering ) bool CMonoFunctions::Blip::SetOrdering( DWORD pUserData, short sOrdering )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering ); return CLuaFunctionDefinitions::SetBlipOrdering( RESOURCE->GetLua(), (void*)pUserData, sOrdering );
} }
return false; return false;
} }
bool CMonoFunctions::Blip::SetVisibleDistance( DWORD pUserData, unsigned short usVisibleDistance ) bool CMonoFunctions::Blip::SetVisibleDistance( DWORD pUserData, unsigned short usVisibleDistance )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance ); return CLuaFunctionDefinitions::SetBlipVisibleDistance( RESOURCE->GetLua(), (void*)pUserData, usVisibleDistance );
} }
return false; return false;

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,24 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Explosion funcs // Explosion funcs
bool CMonoFunctions::Explosion::Create( MonoObject* pPosition, unsigned char ucType, DWORD pCreator ) bool CMonoFunctions::Explosion::Create( MonoObject* pPosition, unsigned char ucType, DWORD pCreator )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); return (DWORD)CLuaFunctionDefinitions::CreateExplosion( RESOURCE->GetLua(), Vector3( pPosition ), ucType, (void*)pCreator );
}
return (DWORD)CLuaFunctionDefinitions::CreateExplosion( RESOURCE->GetLua(), vecPosition, ucType, (void*)pCreator );
} return NULL;
return NULL;
} }

View File

@ -1,217 +1,173 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Marker create/destroy functions // Marker create/destroy functions
DWORD CMonoFunctions::Marker::Create( MonoObject* pPosition, MonoString* msType, float fSize, MonoObject* pColor, DWORD pVisibleTo ) DWORD CMonoFunctions::Marker::Create( MonoObject* pPosition, MonoString* msType, float fSize, MonoObject* pColor, DWORD pVisibleTo )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); const char* szType = mono_string_to_utf8( msType );
float fX = pPosition.GetPropertyValue< float >( "X" ); return (DWORD)CLuaFunctionDefinitions::CreateMarker( RESOURCE->GetLua(), Vector3( pPosition ), szType, fSize, CMonoObject::GetColor( pColor ), (void*)pVisibleTo );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
const char* szType = mono_string_to_utf8( msType );
CMonoObject pMonoColor( pColor );
SColor pColor;
pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" );
pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" );
pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" );
pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" );
return (DWORD)CLuaFunctionDefinitions::CreateMarker( RESOURCE->GetLua(), vecPosition, szType, fSize, pColor, (void*)pVisibleTo );
}
return NULL;
}
// Marker get functions
unsigned int CMonoFunctions::Marker::GetCount()
{
if( RESOURCE )
{
unsigned int uiCount;
if( CLuaFunctionDefinitions::GetMarkerCount( RESOURCE->GetLua(), uiCount ) )
{
return uiCount;
}
} }
return 0; return NULL;
} }
// Marker get functions
unsigned int CMonoFunctions::Marker::GetCount()
{
if( RESOURCE )
{
unsigned int uiCount;
if( CLuaFunctionDefinitions::GetMarkerCount( RESOURCE->GetLua(), uiCount ) )
{
return uiCount;
}
}
return 0;
}
MonoString* CMonoFunctions::Marker::GetType( DWORD pUserData ) MonoString* CMonoFunctions::Marker::GetType( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
char* szType = NULL; char* szType = NULL;
if( CLuaFunctionDefinitions::GetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ) ) if( CLuaFunctionDefinitions::GetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ) )
{ {
return RESOURCE->NewString( szType ); return RESOURCE->NewString( szType );
} }
} }
return NULL; return NULL;
} }
float CMonoFunctions::Marker::GetSize( DWORD pUserData ) float CMonoFunctions::Marker::GetSize( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
float fSize; float fSize;
if( CLuaFunctionDefinitions::GetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ) ) if( CLuaFunctionDefinitions::GetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ) )
{ {
return fSize; return fSize;
} }
} }
return 0.0f; return 0.0f;
} }
MonoObject* CMonoFunctions::Marker::GetColor( DWORD pUserData ) MonoObject* CMonoFunctions::Marker::GetColor( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor outColor; SColor outColor;
if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
}
if( pObject )
{
return pObject->GetObject();
}
}
} }
return NULL; return NULL;
} }
MonoObject* CMonoFunctions::Marker::GetTarget( DWORD pUserData ) MonoObject* CMonoFunctions::Marker::GetTarget( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition; Vector3 vecPosition;
if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) if( CLuaFunctionDefinitions::GetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
}
if( pObject )
{
return pObject->GetObject();
}
}
} }
return NULL; return NULL;
} }
MonoString* CMonoFunctions::Marker::GetIcon( DWORD pUserData ) MonoString* CMonoFunctions::Marker::GetIcon( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
char* szIcon = NULL; char* szIcon = NULL;
if( CLuaFunctionDefinitions::GetMarkerIcon( RESOURCE->GetLua(), (void*)pUserData, szIcon ) ) if( CLuaFunctionDefinitions::GetMarkerIcon( RESOURCE->GetLua(), (void*)pUserData, szIcon ) )
{ {
return RESOURCE->NewString( szIcon ); return RESOURCE->NewString( szIcon );
} }
} }
return NULL; return NULL;
} }
// Marker set functions // Marker set functions
bool CMonoFunctions::Marker::SetType( DWORD pUserData, MonoString* msType ) bool CMonoFunctions::Marker::SetType( DWORD pUserData, MonoString* msType )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
const char* szType = mono_string_to_utf8( msType ); const char* szType = mono_string_to_utf8( msType );
return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType ); return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szType );
} }
return false; return false;
} }
bool CMonoFunctions::Marker::SetSize( DWORD pUserData, float fSize ) bool CMonoFunctions::Marker::SetSize( DWORD pUserData, float fSize )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize ); return CLuaFunctionDefinitions::SetMarkerSize( RESOURCE->GetLua(), (void*)pUserData, fSize );
} }
return false; return false;
} }
bool CMonoFunctions::Marker::SetColor( DWORD pUserData, MonoObject* color ) bool CMonoFunctions::Marker::SetColor( DWORD pUserData, MonoObject* pColor )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor; return CLuaFunctionDefinitions::SetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, CMonoObject::GetColor( pColor ) );
CMonoObject pMonoColor( color );
pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" );
pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" );
pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" );
pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" );
return CLuaFunctionDefinitions::SetMarkerColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
} }
return false; return false;
} }
bool CMonoFunctions::Marker::SetTarget( DWORD pUserData, MonoObject* pTarget ) bool CMonoFunctions::Marker::SetTarget( DWORD pUserData, MonoObject* pTarget )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3* vecPosition = new Vector3; return CLuaFunctionDefinitions::SetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, Vector3( pTarget ) );
CMonoObject pTarget( pTarget );
vecPosition->fX = pTarget.GetPropertyValue< float >( "X" );
vecPosition->fY = pTarget.GetPropertyValue< float >( "Y" );
vecPosition->fZ = pTarget.GetPropertyValue< float >( "Z" );
return CLuaFunctionDefinitions::SetMarkerTarget( RESOURCE->GetLua(), (void*)pUserData, vecPosition );
} }
return false; return false;
} }
bool CMonoFunctions::Marker::SetIcon( DWORD pUserData, MonoString* msIcon ) bool CMonoFunctions::Marker::SetIcon( DWORD pUserData, MonoString* msIcon )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
const char* szIcon = mono_string_to_utf8( msIcon ); const char* szIcon = mono_string_to_utf8( msIcon );
return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szIcon ); return CLuaFunctionDefinitions::SetMarkerType( RESOURCE->GetLua(), (void*)pUserData, szIcon );
} }
return false; return false;

View File

@ -1,117 +1,81 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Object create/destroy functions // Object create/destroy functions
DWORD CMonoFunctions::Object::Create( unsigned short usModelID, MonoObject* pPosition, MonoObject* pRotation, bool bIsLowLod ) DWORD CMonoFunctions::Object::Create( unsigned short usModelID, MonoObject* pPosition, MonoObject* pRotation, bool bIsLowLod )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); Vector3 vecPosition( pPosition );
Vector3 vecRotation( pRotation );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" ); return (DWORD)CLuaFunctionDefinitions::CreateObject( RESOURCE->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod );
float fZ = pPosition.GetPropertyValue< float >( "Z" ); }
Vector3 vecPosition( fX, fY, fZ );
CMonoObject pRotation( pRotation );
float fRX = pRotation.GetPropertyValue< float >( "X" );
float fRY = pRotation.GetPropertyValue< float >( "Y" );
float fRZ = pRotation.GetPropertyValue< float >( "Z" );
Vector3 vecRotation( fRX, fRY, fRZ );
return (DWORD)CLuaFunctionDefinitions::CreateObject( RESOURCE->GetLua(), usModelID, vecPosition, vecRotation, bIsLowLod );
}
return NULL; return NULL;
} }
// Object get functions // Object get functions
MonoObject* CMonoFunctions::Object::GetScale( DWORD pUserData ) MonoObject* CMonoFunctions::Object::GetScale( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecScale; Vector3 vecScale;
if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) ) if( CLuaFunctionDefinitions::GetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecScale ); return RESOURCE->NewObject( vecScale );
}
if( pObject )
{
return pObject->GetObject();
}
}
} }
return NULL; return NULL;
} }
// Object set functions // Object set functions
bool CMonoFunctions::Object::SetScale( DWORD pUserData, MonoObject* pScale ) bool CMonoFunctions::Object::SetScale( DWORD pUserData, MonoObject* pScale )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecScale; return CLuaFunctionDefinitions::SetObjectScale( RESOURCE->GetLua(), (void*)pUserData, Vector3( pScale ) );
CMonoObject pScale( pScale );
vecScale.fX = pScale.GetPropertyValue< float >( "X" );
vecScale.fY = pScale.GetPropertyValue< float >( "Y" );
vecScale.fZ = pScale.GetPropertyValue< float >( "Z" );
return CLuaFunctionDefinitions::SetObjectScale( RESOURCE->GetLua(), (void*)pUserData, vecScale );
} }
return false; return false;
} }
bool CMonoFunctions::Object::Move( DWORD pUserData, unsigned long ulTime, MonoObject* pPosition, MonoObject* pRotation, MonoString* msEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot ) bool CMonoFunctions::Object::Move( DWORD pUserData, unsigned long ulTime, MonoObject* pPosition, MonoObject* pRotation, MonoString* msEasingType, float fEasingPeriod, float fEasingAmplitude, float fEasingOvershoot )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition, vecRotation; Vector3
vecPosition( pPosition ),
CMonoObject pPosition( pPosition ); vecRotation( pRotation );
vecPosition.fX = pPosition.GetPropertyValue< float >( "X" ); const char* szEasingType = mono_string_to_utf8( msEasingType );
vecPosition.fY = pPosition.GetPropertyValue< float >( "Y" );
vecPosition.fZ = pPosition.GetPropertyValue< float >( "Z" ); return CLuaFunctionDefinitions::MoveObject( RESOURCE->GetLua(), (void*)pUserData, ulTime, vecPosition, vecRotation, szEasingType, fEasingPeriod, fEasingAmplitude, fEasingOvershoot );
CMonoObject pRotation( pRotation );
vecRotation.fX = pRotation.GetPropertyValue< float >( "X" );
vecRotation.fY = pRotation.GetPropertyValue< float >( "Y" );
vecRotation.fZ = pRotation.GetPropertyValue< float >( "Z" );
const char* szEasingType = mono_string_to_utf8( msEasingType );
return CLuaFunctionDefinitions::MoveObject( RESOURCE->GetLua(), (void*)pUserData, ulTime, vecPosition, vecRotation, szEasingType, fEasingPeriod, fEasingAmplitude, fEasingOvershoot );
} }
return false; return false;
} }
bool CMonoFunctions::Object::Stop( DWORD pUserData ) bool CMonoFunctions::Object::Stop( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::StopObject( RESOURCE->GetLua(), (void*)pUserData ); return CLuaFunctionDefinitions::StopObject( RESOURCE->GetLua(), (void*)pUserData );
} }
return false; return false;

View File

@ -1,134 +1,128 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#ifndef _CMONO_FUNCS_PED #ifndef _CMONO_FUNCS_PED
#define _CMONO_FUNCS_PED #define _CMONO_FUNCS_PED
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Ped get functions // Ped get functions
DWORD CMonoFunctions::Ped::Create( int iModelid, MonoObject* pMonoPosition, float fRot, bool bSynced ) DWORD CMonoFunctions::Ped::Create( int iModelid, MonoObject* pMonoPosition, float fRot, bool bSynced )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pMonoPosition ); Vector3 vecPosition( pMonoPosition );
float fX = pPosition.GetPropertyValue< float >( "X" ); return (DWORD)CLuaFunctionDefinitions::CreatePed( RESOURCE->GetLua(), iModelid, vecPosition, fRot, bSynced );
float fY = pPosition.GetPropertyValue< float >( "Y" ); }
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
return (DWORD)CLuaFunctionDefinitions::CreatePed( RESOURCE->GetLua(), iModelid, vecPosition, fRot, bSynced );
}
return NULL; return NULL;
} }
float CMonoFunctions::Ped::GetArmor( DWORD pUserData ) float CMonoFunctions::Ped::GetArmor( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
float fArmor; float fArmor;
if( CLuaFunctionDefinitions::GetPedArmor( RESOURCE->GetLua(), (void*)pUserData, fArmor ) ) if( CLuaFunctionDefinitions::GetPedArmor( RESOURCE->GetLua(), (void*)pUserData, fArmor ) )
{ {
return fArmor; return fArmor;
} }
} }
return 0.0f; return 0.0f;
} }
bool CMonoFunctions::Ped::IsChoking( DWORD pUserData ) bool CMonoFunctions::Ped::IsChoking( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
bool bChoking; bool bChoking;
if( CLuaFunctionDefinitions::IsPedChoking( RESOURCE->GetLua(), (void*)pUserData, bChoking ) ) if( CLuaFunctionDefinitions::IsPedChoking( RESOURCE->GetLua(), (void*)pUserData, bChoking ) )
{ {
return bChoking; return bChoking;
} }
} }
return false; return false;
} }
bool CMonoFunctions::Ped::IsDead( DWORD pUserData ) bool CMonoFunctions::Ped::IsDead( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
bool bDead; bool bDead;
if( CLuaFunctionDefinitions::IsPedDead( RESOURCE->GetLua(), (void*)pUserData, bDead ) ) if( CLuaFunctionDefinitions::IsPedDead( RESOURCE->GetLua(), (void*)pUserData, bDead ) )
{ {
return bDead; return bDead;
} }
} }
return false; return false;
} }
bool CMonoFunctions::Ped::IsDucked( DWORD pUserData ) bool CMonoFunctions::Ped::IsDucked( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
bool bDucked; bool bDucked;
if( CLuaFunctionDefinitions::IsPedDucked( RESOURCE->GetLua(), (void*)pUserData, bDucked ) ) if( CLuaFunctionDefinitions::IsPedDucked( RESOURCE->GetLua(), (void*)pUserData, bDucked ) )
{ {
return bDucked; return bDucked;
} }
} }
return false; return false;
} }
float CMonoFunctions::Ped::GetStat( DWORD pUserData, unsigned short usStat ) float CMonoFunctions::Ped::GetStat( DWORD pUserData, unsigned short usStat )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
float fStat; float fStat;
if( CLuaFunctionDefinitions::GetPedStat( RESOURCE->GetLua(), (void*)pUserData, usStat, fStat ) ) if( CLuaFunctionDefinitions::GetPedStat( RESOURCE->GetLua(), (void*)pUserData, usStat, fStat ) )
{ {
return fStat; return fStat;
} }
} }
return 0.0f; return 0.0f;
} }
DWORD CMonoFunctions::Ped::GetTarget( DWORD pUserData ) DWORD CMonoFunctions::Ped::GetTarget( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return (DWORD)CLuaFunctionDefinitions::GetPedTarget( RESOURCE->GetLua(), (void*)pUserData ); return (DWORD)CLuaFunctionDefinitions::GetPedTarget( RESOURCE->GetLua(), (void*)pUserData );
} }
return NULL; return NULL;
} }
int CMonoFunctions::Ped::GetWeapon( DWORD pUserData, int iWeaponSlot ) int CMonoFunctions::Ped::GetWeapon( DWORD pUserData, int iWeaponSlot )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::GetPedWeapon( RESOURCE->GetLua(), (void*)pUserData, iWeaponSlot ); return CLuaFunctionDefinitions::GetPedWeapon( RESOURCE->GetLua(), (void*)pUserData, iWeaponSlot );
} }
return NULL; return NULL;
} }
MonoString* CMonoFunctions::Ped::GetClothesTexture( DWORD pUserData, unsigned char ucType ) MonoString* CMonoFunctions::Ped::GetClothesTexture( DWORD pUserData, unsigned char ucType )
{ {
if( RESOURCE ) if( RESOURCE )
@ -143,7 +137,7 @@ MonoString* CMonoFunctions::Ped::GetClothesTexture( DWORD pUserData, unsigned ch
return NULL; return NULL;
} }
MonoString* CMonoFunctions::Ped::GetClothesModel( DWORD pUserData, unsigned char ucType ) MonoString* CMonoFunctions::Ped::GetClothesModel( DWORD pUserData, unsigned char ucType )
{ {
if( RESOURCE ) if( RESOURCE )
@ -158,7 +152,7 @@ MonoString* CMonoFunctions::Ped::GetClothesModel( DWORD pUserData, unsigned char
return NULL; return NULL;
} }
bool CMonoFunctions::Ped::DoesHaveJetPack( DWORD pUserData ) bool CMonoFunctions::Ped::DoesHaveJetPack( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -173,7 +167,7 @@ bool CMonoFunctions::Ped::DoesHaveJetPack( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::IsOnGround( DWORD pUserData ) bool CMonoFunctions::Ped::IsOnGround( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -188,7 +182,7 @@ bool CMonoFunctions::Ped::IsOnGround( DWORD pUserData )
return false; return false;
} }
unsigned char CMonoFunctions::Ped::GetFightingStyle( DWORD pUserData ) unsigned char CMonoFunctions::Ped::GetFightingStyle( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -203,7 +197,7 @@ unsigned char CMonoFunctions::Ped::GetFightingStyle( DWORD pUserData )
return 0; return 0;
} }
unsigned int CMonoFunctions::Ped::GetMoveAnim( DWORD pUserData ) unsigned int CMonoFunctions::Ped::GetMoveAnim( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -218,7 +212,7 @@ unsigned int CMonoFunctions::Ped::GetMoveAnim( DWORD pUserData )
return 0; return 0;
} }
float CMonoFunctions::Ped::GetGravity( DWORD pUserData ) float CMonoFunctions::Ped::GetGravity( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -233,7 +227,7 @@ float CMonoFunctions::Ped::GetGravity( DWORD pUserData )
return 0.0f; return 0.0f;
} }
DWORD CMonoFunctions::Ped::GetContactElement( DWORD pUserData ) DWORD CMonoFunctions::Ped::GetContactElement( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -243,7 +237,7 @@ DWORD CMonoFunctions::Ped::GetContactElement( DWORD pUserData )
return NULL; return NULL;
} }
unsigned char CMonoFunctions::Ped::GetWeaponSlot( DWORD pUserData ) unsigned char CMonoFunctions::Ped::GetWeaponSlot( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -258,7 +252,7 @@ unsigned char CMonoFunctions::Ped::GetWeaponSlot( DWORD pUserData )
return 0; return 0;
} }
bool CMonoFunctions::Ped::IsDoingGangDriveby( DWORD pUserData ) bool CMonoFunctions::Ped::IsDoingGangDriveby( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -273,7 +267,7 @@ bool CMonoFunctions::Ped::IsDoingGangDriveby( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::IsOnFire( DWORD pUserData ) bool CMonoFunctions::Ped::IsOnFire( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -288,7 +282,7 @@ bool CMonoFunctions::Ped::IsOnFire( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::IsHeadless( DWORD pUserData ) bool CMonoFunctions::Ped::IsHeadless( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -303,7 +297,7 @@ bool CMonoFunctions::Ped::IsHeadless( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::IsFrozen( DWORD pUserData ) bool CMonoFunctions::Ped::IsFrozen( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -318,7 +312,7 @@ bool CMonoFunctions::Ped::IsFrozen( DWORD pUserData )
return false; return false;
} }
DWORD CMonoFunctions::Ped::GetOccupiedVehicle( DWORD pUserData ) DWORD CMonoFunctions::Ped::GetOccupiedVehicle( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -328,7 +322,7 @@ DWORD CMonoFunctions::Ped::GetOccupiedVehicle( DWORD pUserData )
return NULL; return NULL;
} }
unsigned int CMonoFunctions::Ped::GetOccupiedVehicleSeat( DWORD pUserData ) unsigned int CMonoFunctions::Ped::GetOccupiedVehicleSeat( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -343,7 +337,7 @@ unsigned int CMonoFunctions::Ped::GetOccupiedVehicleSeat( DWORD pUserData )
return 0; return 0;
} }
bool CMonoFunctions::Ped::IsInVehicle( DWORD pUserData ) bool CMonoFunctions::Ped::IsInVehicle( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -358,7 +352,7 @@ bool CMonoFunctions::Ped::IsInVehicle( DWORD pUserData )
return false; return false;
} }
short CMonoFunctions::Ped::GetWeaponProperty( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty ) short CMonoFunctions::Ped::GetWeaponProperty( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty )
{ {
if( RESOURCE ) if( RESOURCE )
@ -376,7 +370,7 @@ short CMonoFunctions::Ped::GetWeaponProperty( unsigned char ucWeaponID, MonoStri
return 0; return 0;
} }
short CMonoFunctions::Ped::GetOriginalWeaponProperty( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty ) short CMonoFunctions::Ped::GetOriginalWeaponProperty( unsigned char ucWeaponID, MonoString *msWeaponSkill, MonoString* msProperty )
{ {
if( RESOURCE ) if( RESOURCE )
@ -394,9 +388,9 @@ short CMonoFunctions::Ped::GetOriginalWeaponProperty( unsigned char ucWeaponID,
return 0; return 0;
} }
// Ped set functions // Ped set functions
bool CMonoFunctions::Ped::SetArmor( DWORD pUserData, float fArmor ) bool CMonoFunctions::Ped::SetArmor( DWORD pUserData, float fArmor )
{ {
if( RESOURCE ) if( RESOURCE )
@ -406,7 +400,7 @@ bool CMonoFunctions::Ped::SetArmor( DWORD pUserData, float fArmor )
return false; return false;
} }
bool CMonoFunctions::Ped::Kill( DWORD pUserData, DWORD pKiller, unsigned char ucKillerWeapon, unsigned char ucBodyPart, bool bStealth ) bool CMonoFunctions::Ped::Kill( DWORD pUserData, DWORD pKiller, unsigned char ucKillerWeapon, unsigned char ucBodyPart, bool bStealth )
{ {
if( RESOURCE ) if( RESOURCE )
@ -416,7 +410,7 @@ bool CMonoFunctions::Ped::Kill( DWORD pUserData, DWORD pKiller, unsigned char uc
return false; return false;
} }
bool CMonoFunctions::Ped::SetStat( DWORD pUserData, unsigned short usStat, float fValue ) bool CMonoFunctions::Ped::SetStat( DWORD pUserData, unsigned short usStat, float fValue )
{ {
if( RESOURCE ) if( RESOURCE )
@ -426,7 +420,7 @@ bool CMonoFunctions::Ped::SetStat( DWORD pUserData, unsigned short usStat, float
return false; return false;
} }
bool CMonoFunctions::Ped::AddClothes( DWORD pUserData, MonoString* msTexture, MonoString* msModel, unsigned char ucType ) bool CMonoFunctions::Ped::AddClothes( DWORD pUserData, MonoString* msTexture, MonoString* msModel, unsigned char ucType )
{ {
if( RESOURCE ) if( RESOURCE )
@ -439,7 +433,7 @@ bool CMonoFunctions::Ped::AddClothes( DWORD pUserData, MonoString* msTexture, Mo
return false; return false;
} }
bool CMonoFunctions::Ped::RemoveClothes( DWORD pUserData, unsigned char ucType, MonoString* msTexture, MonoString* msModel ) bool CMonoFunctions::Ped::RemoveClothes( DWORD pUserData, unsigned char ucType, MonoString* msTexture, MonoString* msModel )
{ {
if( RESOURCE ) if( RESOURCE )
@ -452,7 +446,7 @@ bool CMonoFunctions::Ped::RemoveClothes( DWORD pUserData, unsigned char ucType,
return false; return false;
} }
bool CMonoFunctions::Ped::GiveJetPack( DWORD pUserData ) bool CMonoFunctions::Ped::GiveJetPack( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -462,7 +456,7 @@ bool CMonoFunctions::Ped::GiveJetPack( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::RemoveJetPack( DWORD pUserData ) bool CMonoFunctions::Ped::RemoveJetPack( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -472,7 +466,7 @@ bool CMonoFunctions::Ped::RemoveJetPack( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::SetFightingStyle( DWORD pUserData, unsigned char ucStyle ) bool CMonoFunctions::Ped::SetFightingStyle( DWORD pUserData, unsigned char ucStyle )
{ {
if( RESOURCE ) if( RESOURCE )
@ -482,7 +476,7 @@ bool CMonoFunctions::Ped::SetFightingStyle( DWORD pUserData, unsigned char ucSty
return false; return false;
} }
bool CMonoFunctions::Ped::SetMoveAnim( DWORD pUserData, unsigned int iMoveAnim ) bool CMonoFunctions::Ped::SetMoveAnim( DWORD pUserData, unsigned int iMoveAnim )
{ {
if( RESOURCE ) if( RESOURCE )
@ -492,7 +486,7 @@ bool CMonoFunctions::Ped::SetMoveAnim( DWORD pUserData, unsigned int iMoveAnim )
return false; return false;
} }
bool CMonoFunctions::Ped::SetGravity( DWORD pUserData, float fGravity ) bool CMonoFunctions::Ped::SetGravity( DWORD pUserData, float fGravity )
{ {
if( RESOURCE ) if( RESOURCE )
@ -502,7 +496,7 @@ bool CMonoFunctions::Ped::SetGravity( DWORD pUserData, float fGravity )
return false; return false;
} }
bool CMonoFunctions::Ped::SetChoking( DWORD pUserData, bool bChoking ) bool CMonoFunctions::Ped::SetChoking( DWORD pUserData, bool bChoking )
{ {
if( RESOURCE ) if( RESOURCE )
@ -512,7 +506,7 @@ bool CMonoFunctions::Ped::SetChoking( DWORD pUserData, bool bChoking )
return false; return false;
} }
bool CMonoFunctions::Ped::SetWeaponSlot( DWORD pUserData, unsigned char ucWeaponSlot ) bool CMonoFunctions::Ped::SetWeaponSlot( DWORD pUserData, unsigned char ucWeaponSlot )
{ {
if( RESOURCE ) if( RESOURCE )
@ -522,7 +516,7 @@ bool CMonoFunctions::Ped::SetWeaponSlot( DWORD pUserData, unsigned char ucWeapon
return false; return false;
} }
bool CMonoFunctions::Ped::WarpIntoVehicle( DWORD pUserData, DWORD pVehicle, unsigned int uiSeat ) bool CMonoFunctions::Ped::WarpIntoVehicle( DWORD pUserData, DWORD pVehicle, unsigned int uiSeat )
{ {
if( RESOURCE ) if( RESOURCE )
@ -532,7 +526,7 @@ bool CMonoFunctions::Ped::WarpIntoVehicle( DWORD pUserData, DWORD pVehicle, unsi
return false; return false;
} }
bool CMonoFunctions::Ped::RemoveFromVehicle( DWORD pUserData ) bool CMonoFunctions::Ped::RemoveFromVehicle( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -542,7 +536,7 @@ bool CMonoFunctions::Ped::RemoveFromVehicle( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::SetDoingGangDriveby( DWORD pUserData, bool bGangDriveby ) bool CMonoFunctions::Ped::SetDoingGangDriveby( DWORD pUserData, bool bGangDriveby )
{ {
if( RESOURCE ) if( RESOURCE )
@ -552,7 +546,7 @@ bool CMonoFunctions::Ped::SetDoingGangDriveby( DWORD pUserData, bool bGangDriveb
return false; return false;
} }
bool CMonoFunctions::Ped::SetAnimation( DWORD pUserData, MonoString* msBlockName, MonoString* msAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame ) bool CMonoFunctions::Ped::SetAnimation( DWORD pUserData, MonoString* msBlockName, MonoString* msAnimName, int iTime, bool bLoop, bool bUpdatePosition, bool bInterruptable, bool bFreezeLastFrame )
{ {
if( RESOURCE ) if( RESOURCE )
@ -565,7 +559,7 @@ bool CMonoFunctions::Ped::SetAnimation( DWORD pUserData, MonoString* msBlockName
return false; return false;
} }
bool CMonoFunctions::Ped::SetAnimationProgress( DWORD pUserData, MonoString* msAnimName, float fProgress ) bool CMonoFunctions::Ped::SetAnimationProgress( DWORD pUserData, MonoString* msAnimName, float fProgress )
{ {
if( RESOURCE ) if( RESOURCE )
@ -577,7 +571,7 @@ bool CMonoFunctions::Ped::SetAnimationProgress( DWORD pUserData, MonoString* msA
return false; return false;
} }
bool CMonoFunctions::Ped::SetOnFire( DWORD pUserData, bool bIsOnFire ) bool CMonoFunctions::Ped::SetOnFire( DWORD pUserData, bool bIsOnFire )
{ {
if( RESOURCE ) if( RESOURCE )
@ -587,7 +581,7 @@ bool CMonoFunctions::Ped::SetOnFire( DWORD pUserData, bool bIsOnFire )
return false; return false;
} }
bool CMonoFunctions::Ped::SetHeadless( DWORD pUserData, bool bIsHeadless ) bool CMonoFunctions::Ped::SetHeadless( DWORD pUserData, bool bIsHeadless )
{ {
if( RESOURCE ) if( RESOURCE )
@ -597,7 +591,7 @@ bool CMonoFunctions::Ped::SetHeadless( DWORD pUserData, bool bIsHeadless )
return false; return false;
} }
bool CMonoFunctions::Ped::SetFrozen( DWORD pUserData, bool bIsFrozen ) bool CMonoFunctions::Ped::SetFrozen( DWORD pUserData, bool bIsFrozen )
{ {
if( RESOURCE ) if( RESOURCE )
@ -607,7 +601,7 @@ bool CMonoFunctions::Ped::SetFrozen( DWORD pUserData, bool bIsFrozen )
return false; return false;
} }
bool CMonoFunctions::Ped::ReloadWeapon( DWORD pUserData ) bool CMonoFunctions::Ped::ReloadWeapon( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -617,7 +611,7 @@ bool CMonoFunctions::Ped::ReloadWeapon( DWORD pUserData )
return false; return false;
} }
bool CMonoFunctions::Ped::SetWeaponProperty( unsigned char ucWeaponID, MonoString* msWeaponSkill, MonoString* msProperty, short uData ) bool CMonoFunctions::Ped::SetWeaponProperty( unsigned char ucWeaponID, MonoString* msWeaponSkill, MonoString* msProperty, short uData )
{ {
if( RESOURCE ) if( RESOURCE )
@ -630,9 +624,9 @@ bool CMonoFunctions::Ped::SetWeaponProperty( unsigned char ucWeaponID, MonoStrin
return false; return false;
} }
// Ped body? // Ped body?
MonoString* CMonoFunctions::Ped::GetBodyPartName( unsigned char ucID ) MonoString* CMonoFunctions::Ped::GetBodyPartName( unsigned char ucID )
{ {
if( RESOURCE ) if( RESOURCE )
@ -647,7 +641,7 @@ MonoString* CMonoFunctions::Ped::GetBodyPartName( unsigned char ucID )
return NULL; return NULL;
} }
MonoArray* CMonoFunctions::Ped::GetClothesByTypeIndex( unsigned char ucType, unsigned char ucIndex ) MonoArray* CMonoFunctions::Ped::GetClothesByTypeIndex( unsigned char ucType, unsigned char ucIndex )
{ {
if( RESOURCE ) if( RESOURCE )
@ -671,7 +665,7 @@ MonoArray* CMonoFunctions::Ped::GetClothesByTypeIndex( unsigned char ucType, uns
return NULL; return NULL;
} }
MonoArray* CMonoFunctions::Ped::GetTypeIndexFromClothes( MonoString* msTexture, MonoString* msModel ) MonoArray* CMonoFunctions::Ped::GetTypeIndexFromClothes( MonoString* msTexture, MonoString* msModel )
{ {
if( RESOURCE ) if( RESOURCE )
@ -697,7 +691,7 @@ MonoArray* CMonoFunctions::Ped::GetTypeIndexFromClothes( MonoString* msTexture,
return NULL; return NULL;
} }
MonoString* CMonoFunctions::Ped::GetClothesTypeName( unsigned char ucType ) MonoString* CMonoFunctions::Ped::GetClothesTypeName( unsigned char ucType )
{ {
if( RESOURCE ) if( RESOURCE )
@ -712,9 +706,9 @@ MonoString* CMonoFunctions::Ped::GetClothesTypeName( unsigned char ucType )
return NULL; return NULL;
} }
// Weapon give/take functions // Weapon give/take functions
bool CMonoFunctions::Ped::GiveWeapon( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, bool bSetAsCurrent ) bool CMonoFunctions::Ped::GiveWeapon( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, bool bSetAsCurrent )
{ {
if( RESOURCE ) if( RESOURCE )
@ -724,7 +718,7 @@ bool CMonoFunctions::Ped::GiveWeapon( DWORD pPed, unsigned char ucWeaponID, unsi
return false; return false;
} }
bool CMonoFunctions::Ped::TakeWeapon( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo ) bool CMonoFunctions::Ped::TakeWeapon( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo )
{ {
if( RESOURCE ) if( RESOURCE )
@ -734,7 +728,7 @@ bool CMonoFunctions::Ped::TakeWeapon( DWORD pPed, unsigned char ucWeaponID, unsi
return false; return false;
} }
bool CMonoFunctions::Ped::TakeAllWeapons( DWORD pPed ) bool CMonoFunctions::Ped::TakeAllWeapons( DWORD pPed )
{ {
if( RESOURCE ) if( RESOURCE )
@ -744,7 +738,7 @@ bool CMonoFunctions::Ped::TakeAllWeapons( DWORD pPed )
return false; return false;
} }
bool CMonoFunctions::Ped::SetWeaponAmmo( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, unsigned short usAmmoInClip ) bool CMonoFunctions::Ped::SetWeaponAmmo( DWORD pPed, unsigned char ucWeaponID, unsigned short usAmmo, unsigned short usAmmoInClip )
{ {
if( RESOURCE ) if( RESOURCE )

View File

@ -1,155 +1,149 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Pickup create/destroy funcs // Pickup create/destroy funcs
DWORD CMonoFunctions::Pickup::Create( MonoObject* pPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval, double dSix ) DWORD CMonoFunctions::Pickup::Create( MonoObject* pPosition, unsigned char ucType, double dFive, unsigned long ulRespawnInterval, double dSix )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); Vector3 vecPosition( pPosition );
float fX = pPosition.GetPropertyValue< float >( "X" ); return (DWORD)CLuaFunctionDefinitions::CreatePickup( RESOURCE->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix );
float fY = pPosition.GetPropertyValue< float >( "Y" ); }
float fZ = pPosition.GetPropertyValue< float >( "Z" );
Vector3 vecPosition( fX, fY, fZ );
return (DWORD)CLuaFunctionDefinitions::CreatePickup( RESOURCE->GetLua(), vecPosition, ucType, dFive, ulRespawnInterval, dSix );
}
return NULL; return NULL;
} }
// Pickup get funcs // Pickup get funcs
unsigned char CMonoFunctions::Pickup::GetType( DWORD pUserData ) unsigned char CMonoFunctions::Pickup::GetType( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned char ucType; unsigned char ucType;
if( CLuaFunctionDefinitions::GetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType ) ) if( CLuaFunctionDefinitions::GetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType ) )
{ {
return ucType; return ucType;
} }
} }
return 0; return 0;
} }
unsigned char CMonoFunctions::Pickup::GetWeapon( DWORD pUserData ) unsigned char CMonoFunctions::Pickup::GetWeapon( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned char ucWeapon; unsigned char ucWeapon;
if( CLuaFunctionDefinitions::GetPickupWeapon( RESOURCE->GetLua(), (void*)pUserData, ucWeapon ) ) if( CLuaFunctionDefinitions::GetPickupWeapon( RESOURCE->GetLua(), (void*)pUserData, ucWeapon ) )
{ {
return ucWeapon; return ucWeapon;
} }
} }
return 0; return 0;
} }
float CMonoFunctions::Pickup::GetAmount( DWORD pUserData ) float CMonoFunctions::Pickup::GetAmount( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
float fAmount; float fAmount;
if( CLuaFunctionDefinitions::GetPickupAmount( RESOURCE->GetLua(), (void*)pUserData, fAmount ) ) if( CLuaFunctionDefinitions::GetPickupAmount( RESOURCE->GetLua(), (void*)pUserData, fAmount ) )
{ {
return fAmount; return fAmount;
} }
} }
return 0; return 0;
} }
unsigned short CMonoFunctions::Pickup::GetAmmo( DWORD pUserData ) unsigned short CMonoFunctions::Pickup::GetAmmo( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned short usAmmo; unsigned short usAmmo;
if( CLuaFunctionDefinitions::GetPickupAmmo( RESOURCE->GetLua(), (void*)pUserData, usAmmo ) ) if( CLuaFunctionDefinitions::GetPickupAmmo( RESOURCE->GetLua(), (void*)pUserData, usAmmo ) )
{ {
return usAmmo; return usAmmo;
} }
} }
return 0; return 0;
} }
unsigned long CMonoFunctions::Pickup::GetRespawnInterval( DWORD pUserData ) unsigned long CMonoFunctions::Pickup::GetRespawnInterval( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned long ulInterval; unsigned long ulInterval;
if( CLuaFunctionDefinitions::GetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ) ) if( CLuaFunctionDefinitions::GetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ) )
{ {
return ulInterval; return ulInterval;
} }
} }
return 0; return 0;
} }
bool CMonoFunctions::Pickup::IsSpawned( DWORD pUserData ) bool CMonoFunctions::Pickup::IsSpawned( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
bool bSpawned; bool bSpawned;
if( CLuaFunctionDefinitions::IsPickupSpawned( RESOURCE->GetLua(), (void*)pUserData, bSpawned ) ) if( CLuaFunctionDefinitions::IsPickupSpawned( RESOURCE->GetLua(), (void*)pUserData, bSpawned ) )
{ {
return bSpawned; return bSpawned;
} }
} }
return false; return false;
} }
// Pickup set funcs // Pickup set funcs
bool CMonoFunctions::Pickup::SetType( DWORD pUserData, unsigned char ucType, double dThree, double dFour ) bool CMonoFunctions::Pickup::SetType( DWORD pUserData, unsigned char ucType, double dThree, double dFour )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType, dThree, dFour ); return CLuaFunctionDefinitions::SetPickupType( RESOURCE->GetLua(), (void*)pUserData, ucType, dThree, dFour );
} }
return false; return false;
} }
bool CMonoFunctions::Pickup::SetRespawnInterval( DWORD pUserData, unsigned long ulInterval ) bool CMonoFunctions::Pickup::SetRespawnInterval( DWORD pUserData, unsigned long ulInterval )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval ); return CLuaFunctionDefinitions::SetPickupRespawnInterval( RESOURCE->GetLua(), (void*)pUserData, ulInterval );
} }
return false; return false;
} }
bool CMonoFunctions::Pickup::Use( DWORD pUserData, DWORD pPlayer ) bool CMonoFunctions::Pickup::Use( DWORD pUserData, DWORD pPlayer )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::UsePickup( RESOURCE->GetLua(), (void*)pUserData, (void*)pPlayer ); return CLuaFunctionDefinitions::UsePickup( RESOURCE->GetLua(), (void*)pUserData, (void*)pPlayer );
} }
return false; return false;

File diff suppressed because it is too large Load Diff

View File

@ -1,166 +1,128 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Radar area create/destroy funcs // Radar area create/destroy funcs
DWORD CMonoFunctions::RadarArea::Create( MonoObject* pPosition, MonoObject* pSize, MonoObject* color, DWORD pVisibleTo ) DWORD CMonoFunctions::RadarArea::Create( MonoObject* pPosition, MonoObject* pSize, MonoObject* color, DWORD pVisibleTo )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector2 vecPosition, vecSize; Vector2 vecPosition( pPosition );
Vector2 vecSize( pSize );
CMonoObject pPosition( pPosition ); SColor pColor = CMonoObject::GetColor( color );
vecPosition.fX = pPosition.GetPropertyValue< float >( "X" ); return (DWORD)CLuaFunctionDefinitions::CreateRadarArea( RESOURCE->GetLua(), vecPosition, vecSize, pColor, (void*)pVisibleTo );
vecPosition.fY = pPosition.GetPropertyValue< float >( "Y" ); }
CMonoObject pSize( pSize );
vecSize.fX = pSize.GetPropertyValue< float >( "X" );
vecSize.fY = pSize.GetPropertyValue< float >( "Y" );
CMonoObject pMonoColor( color );
SColor pColor;
pColor.R = pMonoColor.GetPropertyValue< unsigned char >( "R" );
pColor.G = pMonoColor.GetPropertyValue< unsigned char >( "G" );
pColor.B = pMonoColor.GetPropertyValue< unsigned char >( "B" );
pColor.A = pMonoColor.GetPropertyValue< unsigned char >( "A" );
return (DWORD)CLuaFunctionDefinitions::CreateRadarArea( RESOURCE->GetLua(), vecPosition, vecSize, pColor, (void*)pVisibleTo );
}
return NULL; return NULL;
} }
// Radar area get funcs // Radar area get funcs
MonoObject* CMonoFunctions::RadarArea::GetSize( DWORD pUserData ) MonoObject* CMonoFunctions::RadarArea::GetSize( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector2 vecSize; Vector2 vecSize;
if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) ) if( CLuaFunctionDefinitions::GetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecSize ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecSize ); return RESOURCE->NewObject( vecSize );
}
if( pObject )
{
return pObject->GetObject();
}
}
} }
return NULL; return NULL;
} }
MonoObject* CMonoFunctions::RadarArea::GetColor( DWORD pUserData ) MonoObject* CMonoFunctions::RadarArea::GetColor( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor outColor; SColor outColor;
if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
}
if( pObject )
{
return pObject->GetObject();
}
}
} }
return NULL; return NULL;
} }
bool CMonoFunctions::RadarArea::IsFlashing( DWORD pUserData ) bool CMonoFunctions::RadarArea::IsFlashing( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::IsRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData ); return CLuaFunctionDefinitions::IsRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData );
} }
return false; return false;
} }
bool CMonoFunctions::RadarArea::IsInside( DWORD pUserData, MonoObject* pPosition ) bool CMonoFunctions::RadarArea::IsInside( DWORD pUserData, MonoObject* pPosition )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
bool bInside; bool bInside;
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" ); Vector2 vecPosition( fX, fY );
Vector2 vecPosition( fX, fY ); if( CLuaFunctionDefinitions::IsInsideRadarArea( RESOURCE->GetLua(), (void*)pUserData, vecPosition, bInside ) )
{
if( CLuaFunctionDefinitions::IsInsideRadarArea( RESOURCE->GetLua(), (void*)pUserData, vecPosition, bInside ) ) return bInside;
{ }
return bInside;
}
} }
return false; return false;
} }
// Radar area set funcs // Radar area set funcs
bool CMonoFunctions::RadarArea::SetSize( DWORD pUserData, MonoObject* pSize ) bool CMonoFunctions::RadarArea::SetSize( DWORD pUserData, MonoObject* pSize )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pSize( pSize ); float fX = CMonoObject::GetPropertyValue< float >( pSize, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pSize, "Y" );
float fX = pSize.GetPropertyValue< float >( "X" );
float fY = pSize.GetPropertyValue< float >( "Y" ); Vector2 vecPosition( fX, fY );
Vector2 vecPosition( fX, fY ); return CLuaFunctionDefinitions::SetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecPosition );
return CLuaFunctionDefinitions::SetRadarAreaSize( RESOURCE->GetLua(), (void*)pUserData, vecPosition );
} }
return false; return false;
} }
bool CMonoFunctions::RadarArea::SetColor( DWORD pUserData, MonoObject* color ) bool CMonoFunctions::RadarArea::SetColor( DWORD pUserData, MonoObject* color )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor; SColor pColor = CMonoObject::GetColor( color );
CMonoObject pObject( color ); return CLuaFunctionDefinitions::SetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
pColor.R = pObject.GetPropertyValue< unsigned char >( "R" );
pColor.G = pObject.GetPropertyValue< unsigned char >( "G" );
pColor.B = pObject.GetPropertyValue< unsigned char >( "B" );
pColor.A = pObject.GetPropertyValue< unsigned char >( "A" );
return CLuaFunctionDefinitions::SetRadarAreaColor( RESOURCE->GetLua(), (void*)pUserData, pColor );
} }
return false; return false;
} }
bool CMonoFunctions::RadarArea::SetFlashing( DWORD pUserData, bool bFlashing ) bool CMonoFunctions::RadarArea::SetFlashing( DWORD pUserData, bool bFlashing )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData, bFlashing ); return CLuaFunctionDefinitions::SetRadarAreaFlashing( RESOURCE->GetLua(), (void*)pUserData, bFlashing );
} }
return false; return false;

View File

@ -1,100 +1,98 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Shape create funcs // Shape create funcs
DWORD CMonoFunctions::Shape::CreateCircle( MonoObject* pPosition, float fRadius ) DWORD CMonoFunctions::Shape::CreateCircle( MonoObject* pPosition, float fRadius )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector2 vecPosition = CMonoObject( pPosition ).GetVector2(); Vector2 vecPosition( pPosition );
return (DWORD)CLuaFunctionDefinitions::CreateColCircle( RESOURCE->GetLua(), vecPosition, fRadius ); return (DWORD)CLuaFunctionDefinitions::CreateColCircle( RESOURCE->GetLua(), vecPosition, fRadius );
} }
return NULL; return NULL;
} }
DWORD CMonoFunctions::Shape::CreateCuboid( MonoObject* pPosition, MonoObject* pSize ) DWORD CMonoFunctions::Shape::CreateCuboid( MonoObject* pPosition, MonoObject* pSize )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
Vector3 vecSize = CMonoObject( pSize ).GetVector3(); Vector3 vecSize( pSize );
return (DWORD)CLuaFunctionDefinitions::CreateColCuboid( RESOURCE->GetLua(), vecPosition, vecSize ); return (DWORD)CLuaFunctionDefinitions::CreateColCuboid( RESOURCE->GetLua(), vecPosition, vecSize );
} }
return NULL; return NULL;
} }
DWORD CMonoFunctions::Shape::CreateSphere( MonoObject* pPosition, float fRadius ) DWORD CMonoFunctions::Shape::CreateSphere( MonoObject* pPosition, float fRadius )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
return (DWORD)CLuaFunctionDefinitions::CreateColSphere( RESOURCE->GetLua(), vecPosition, fRadius ); return (DWORD)CLuaFunctionDefinitions::CreateColSphere( RESOURCE->GetLua(), vecPosition, fRadius );
} }
return NULL; return NULL;
} }
DWORD CMonoFunctions::Shape::CreateRectangle( MonoObject* pPosition, MonoObject* pSize ) DWORD CMonoFunctions::Shape::CreateRectangle( MonoObject* pPosition, MonoObject* pSize )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector2 vecPosition = CMonoObject( pPosition ).GetVector2(); Vector2 vecPosition( pPosition );
Vector2 vecSize = CMonoObject( pSize ).GetVector2(); Vector2 vecSize( pSize );
return (DWORD)CLuaFunctionDefinitions::CreateColRectangle( RESOURCE->GetLua(), vecPosition, vecSize ); return (DWORD)CLuaFunctionDefinitions::CreateColRectangle( RESOURCE->GetLua(), vecPosition, vecSize );
} }
return NULL; return NULL;
} }
DWORD CMonoFunctions::Shape::CreatePolygon( MonoArray* pPointList ) DWORD CMonoFunctions::Shape::CreatePolygon( MonoArray* pPointList )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
vector< Vector2 > vecPointList; vector< Vector2 > vecPointList;
for( unsigned int i = 0; i < mono_array_length( pPointList ); i++ ) for( unsigned int i = 0; i < mono_array_length( pPointList ); i++ )
{ {
MonoObject* pObject = mono_array_get( pPointList, MonoObject*, i ); MonoObject* pObject = mono_array_get( pPointList, MonoObject*, i );
if( pObject ) if( pObject )
{ {
Vector2 vecPosition = CMonoObject( pObject ).GetVector2(); vecPointList.push_back( Vector2( pObject ) );
}
vecPointList.push_back( vecPosition ); }
}
} return (DWORD)CLuaFunctionDefinitions::CreateColPolygon( RESOURCE->GetLua(), vecPointList );
}
return (DWORD)CLuaFunctionDefinitions::CreateColPolygon( RESOURCE->GetLua(), vecPointList );
}
return NULL; return NULL;
} }
DWORD CMonoFunctions::Shape::CreateTube( MonoObject* pPosition, float fRadius, float fHeight ) DWORD CMonoFunctions::Shape::CreateTube( MonoObject* pPosition, float fRadius, float fHeight )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( pPosition ).GetVector3(); Vector3 vecPosition( pPosition );
return (DWORD)CLuaFunctionDefinitions::CreateColTube( RESOURCE->GetLua(), vecPosition, fRadius, fHeight ); return (DWORD)CLuaFunctionDefinitions::CreateColTube( RESOURCE->GetLua(), vecPosition, fRadius, fHeight );
} }
return NULL; return NULL;
} }

View File

@ -1,140 +1,135 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Team get funcs // Team get funcs
DWORD CMonoFunctions::Team::Create( MonoString* msTeamName, MonoObject* mColor ) DWORD CMonoFunctions::Team::Create( MonoString* msTeamName, MonoObject* mColor )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
const char* szTeamName = mono_string_to_utf8( msTeamName ); const char* szTeamName = mono_string_to_utf8( msTeamName );
SColor pColor = CMonoObject( mColor ).GetColor(); SColor pColor = CMonoObject::GetColor( mColor );
return (DWORD)CLuaFunctionDefinitions::CreateTeam( RESOURCE->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B ); return (DWORD)CLuaFunctionDefinitions::CreateTeam( RESOURCE->GetLua(), szTeamName, pColor.R, pColor.G, pColor.B );
} }
return NULL; return NULL;
} }
DWORD CMonoFunctions::Team::GetFromName( MonoString* msTeamName ) DWORD CMonoFunctions::Team::GetFromName( MonoString* msTeamName )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
const char* szTeamName = mono_string_to_utf8( msTeamName ); const char* szTeamName = mono_string_to_utf8( msTeamName );
return (DWORD)CLuaFunctionDefinitions::GetTeamFromName( RESOURCE->GetLua(), szTeamName ); return (DWORD)CLuaFunctionDefinitions::GetTeamFromName( RESOURCE->GetLua(), szTeamName );
} }
return NULL; return NULL;
} }
MonoString* CMonoFunctions::Team::GetName( DWORD pUserData ) MonoString* CMonoFunctions::Team::GetName( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
string strOutName; string strOutName;
if( CLuaFunctionDefinitions::GetTeamName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) if( CLuaFunctionDefinitions::GetTeamName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) )
{ {
return RESOURCE->NewString( strOutName ); return RESOURCE->NewString( strOutName );
} }
} }
return NULL; return NULL;
} }
MonoObject* CMonoFunctions::Team::GetColor( DWORD pUserData ) MonoObject* CMonoFunctions::Team::GetColor( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor; SColor pColor;
if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) ) if( CLuaFunctionDefinitions::GetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( pColor ); return RESOURCE->NewObject( pColor );
}
if( pObject ) }
{
return pObject->GetObject(); return NULL;
} }
}
} unsigned int CMonoFunctions::Team::CountPlayers( DWORD pUserData )
{
return NULL; if( RESOURCE )
} {
unsigned int uiCount;
unsigned int CMonoFunctions::Team::CountPlayers( DWORD pUserData )
{ if( CLuaFunctionDefinitions::CountPlayersInTeam( RESOURCE->GetLua(), (void*)pUserData, uiCount ) )
if( RESOURCE ) {
{ return uiCount;
unsigned int uiCount; }
}
if( CLuaFunctionDefinitions::CountPlayersInTeam( RESOURCE->GetLua(), (void*)pUserData, uiCount ) )
{ return 0;
return uiCount; }
}
} bool CMonoFunctions::Team::GetFriendlyFire( DWORD pUserData )
{
return 0; if( RESOURCE )
} {
bool bFriendlyFire;
bool CMonoFunctions::Team::GetFriendlyFire( DWORD pUserData )
{ if( CLuaFunctionDefinitions::GetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire ) )
if( RESOURCE ) {
{ return bFriendlyFire;
bool bFriendlyFire; }
}
if( CLuaFunctionDefinitions::GetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire ) )
{ return false;
return bFriendlyFire; }
}
}
// Team set funcs
return false; bool CMonoFunctions::Team::SetName( DWORD pUserData, MonoString* msTeamName )
} {
if( RESOURCE )
{
// Team set funcs const char* szTeamName = mono_string_to_utf8( msTeamName );
bool CMonoFunctions::Team::SetName( DWORD pUserData, MonoString* msTeamName )
{ return CLuaFunctionDefinitions::SetTeamName( RESOURCE->GetLua(), (void*)pUserData, szTeamName );
if( RESOURCE ) }
{
const char* szTeamName = mono_string_to_utf8( msTeamName ); return false;
}
return CLuaFunctionDefinitions::SetTeamName( RESOURCE->GetLua(), (void*)pUserData, szTeamName );
} bool CMonoFunctions::Team::SetColor( DWORD pUserData, MonoObject* mColor )
{
return false; if( RESOURCE )
} {
SColor pColor = CMonoObject::GetColor( mColor );
bool CMonoFunctions::Team::SetColor( DWORD pUserData, MonoObject* mColor )
{ return CLuaFunctionDefinitions::SetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B );
if( RESOURCE ) }
{
SColor pColor = CMonoObject( mColor ).GetColor(); return false;
}
return CLuaFunctionDefinitions::SetTeamColor( RESOURCE->GetLua(), (void*)pUserData, pColor.R, pColor.G, pColor.B );
} bool CMonoFunctions::Team::SetFriendlyFire( DWORD pUserData, bool bFriendlyFire )
{
return false; if( RESOURCE )
} {
return CLuaFunctionDefinitions::SetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire );
bool CMonoFunctions::Team::SetFriendlyFire( DWORD pUserData, bool bFriendlyFire ) }
{
if( RESOURCE ) return false;
{ }
return CLuaFunctionDefinitions::SetTeamFriendlyFire( RESOURCE->GetLua(), (void*)pUserData, bFriendlyFire );
}
return false;
}

View File

@ -1,132 +1,123 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Vehicle create/destroy functions // Vehicle create/destroy functions
DWORD CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction, int variant1, int variant2 ) DWORD CMonoFunctions::Vehicle::Create( int model, MonoObject* position, MonoObject* rotation, MonoString* numberplate, bool direction, int variant1, int variant2 )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( position ); float fX = CMonoObject::GetPropertyValue< float >( position, "X" );
float fY = CMonoObject::GetPropertyValue< float >( position, "Y" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fZ = CMonoObject::GetPropertyValue< float >( position, "Z" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
float fZ = pPosition.GetPropertyValue< float >( "Z" ); float fRX = CMonoObject::GetPropertyValue< float >( rotation, "X" );
float fRY = CMonoObject::GetPropertyValue< float >( rotation, "Y" );
CMonoObject pRotation( rotation ); float fRZ = CMonoObject::GetPropertyValue< float >( rotation, "Z" );
float fRX = pRotation.GetPropertyValue< float >( "X" ); string sNumberplate = "";
float fRY = pRotation.GetPropertyValue< float >( "Y" );
float fRZ = pRotation.GetPropertyValue< float >( "Z" ); if( numberplate && mono_string_length( numberplate ) > 0 )
{
string sNumberplate = ""; sNumberplate = string( mono_string_to_utf8( numberplate ) );
}
if( numberplate && mono_string_length( numberplate ) > 0 )
{ return (DWORD)CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, sNumberplate, direction, variant1, variant2 );
sNumberplate = string( mono_string_to_utf8( numberplate ) ); }
}
return NULL;
return (DWORD)CLuaFunctionDefinitions::CreateVehicle( RESOURCE->GetLua(), model, fX, fY, fZ, fRX, fRY, fRZ, sNumberplate, direction, variant1, variant2 ); }
}
return NULL;
}
// Vehicle get functions // Vehicle get functions
MonoString* CMonoFunctions::Vehicle::GetType( DWORD pUserData ) MonoString* CMonoFunctions::Vehicle::GetType( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
string strType; string strType;
if( CLuaFunctionDefinitions::GetVehicleType( RESOURCE->GetLua(), (void*)pUserData, strType ) ) if( CLuaFunctionDefinitions::GetVehicleType( RESOURCE->GetLua(), (void*)pUserData, strType ) )
{ {
return RESOURCE->NewString( strType ); return RESOURCE->NewString( strType );
} }
} }
return NULL; return NULL;
} }
MonoArray* CMonoFunctions::Vehicle::GetVariant( DWORD pUserData ) MonoArray* CMonoFunctions::Vehicle::GetVariant( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned char ucVariant; unsigned char ucVariant;
unsigned char ucVariant2; unsigned char ucVariant2;
if( CLuaFunctionDefinitions::GetVehicleVariant( RESOURCE->GetLua(), (void*)pUserData, ucVariant, ucVariant2 ) ) 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->m_pMonoDomain, mono_get_char_class(), 2 );
if( pArray ) if( pArray )
{ {
mono_array_set( pArray, unsigned char, 0, ucVariant ); mono_array_set( pArray, unsigned char, 0, ucVariant );
mono_array_set( pArray, unsigned char, 1, ucVariant2 ); mono_array_set( pArray, unsigned char, 1, ucVariant2 );
return pArray; return pArray;
} }
} }
} }
return NULL; return NULL;
} }
MonoObject* CMonoFunctions::Vehicle::GetColor( DWORD pUserData ) MonoObject* CMonoFunctions::Vehicle::GetColor( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CVehicleColor pColor; CVehicleColor pColor;
if( CLuaFunctionDefinitions::GetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, pColor ) ) if( CLuaFunctionDefinitions::GetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, pColor ) )
{ {
SColor pColor1 = pColor.GetRGBColor( 0 ); SColor pColor1 = pColor.GetRGBColor( 0 );
SColor pColor2 = pColor.GetRGBColor( 1 ); SColor pColor2 = pColor.GetRGBColor( 1 );
SColor pColor3 = pColor.GetRGBColor( 2 ); SColor pColor3 = pColor.GetRGBColor( 2 );
SColor pColor4 = pColor.GetRGBColor( 3 ); SColor pColor4 = pColor.GetRGBColor( 3 );
void* args[] = void* args[] =
{ {
&pColor1, &pColor1,
&pColor2, &pColor2,
&pColor3, &pColor3,
&pColor4 &pColor4
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto", "VehicleColor", args, 4 ); return RESOURCE->NewObject( "MultiTheftAuto", "VehicleColor", args, 4 );
}
if( pObject ) }
{
return pObject->GetObject();
}
}
}
return NULL; return NULL;
} }
unsigned short CMonoFunctions::Vehicle::GetModelFromName( MonoString* msName ) unsigned short CMonoFunctions::Vehicle::GetModelFromName( MonoString* msName )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
const char* szName = mono_string_to_utf8( msName ); const char* szName = mono_string_to_utf8( msName );
unsigned short usModel; unsigned short usModel;
if( CLuaFunctionDefinitions::GetVehicleModelFromName( RESOURCE->GetLua(), szName, usModel ) ) if( CLuaFunctionDefinitions::GetVehicleModelFromName( RESOURCE->GetLua(), szName, usModel ) )
{ {
return usModel; return usModel;
} }
} }
return 0; return 0;
@ -134,14 +125,14 @@ unsigned short CMonoFunctions::Vehicle::GetModelFromName( MonoString* msName )
bool CMonoFunctions::Vehicle::GetLandingGearDown( DWORD pUserData ) bool CMonoFunctions::Vehicle::GetLandingGearDown( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
bool bGearDown; bool bGearDown;
if( CLuaFunctionDefinitions::GetVehicleLandingGearDown( RESOURCE->GetLua(), (void*)pUserData, bGearDown ) ) if( CLuaFunctionDefinitions::GetVehicleLandingGearDown( RESOURCE->GetLua(), (void*)pUserData, bGearDown ) )
{ {
return bGearDown; return bGearDown;
} }
} }
return false; return false;
@ -149,14 +140,14 @@ bool CMonoFunctions::Vehicle::GetLandingGearDown( DWORD pUserData )
unsigned char CMonoFunctions::Vehicle::GetMaxPassengers( DWORD pUserData ) unsigned char CMonoFunctions::Vehicle::GetMaxPassengers( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
unsigned char ucPassengers; unsigned char ucPassengers;
if( CLuaFunctionDefinitions::GetVehicleMaxPassengers( RESOURCE->GetLua(), (void*)pUserData, ucPassengers ) ) if( CLuaFunctionDefinitions::GetVehicleMaxPassengers( RESOURCE->GetLua(), (void*)pUserData, ucPassengers ) )
{ {
return ucPassengers; return ucPassengers;
} }
} }
return 0; return 0;
@ -164,14 +155,14 @@ unsigned char CMonoFunctions::Vehicle::GetMaxPassengers( DWORD pUserData )
MonoString* CMonoFunctions::Vehicle::GetName( DWORD pUserData ) MonoString* CMonoFunctions::Vehicle::GetName( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
string strOutName; string strOutName;
if( CLuaFunctionDefinitions::GetVehicleName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) ) if( CLuaFunctionDefinitions::GetVehicleName( RESOURCE->GetLua(), (void*)pUserData, strOutName ) )
{ {
return RESOURCE->NewString( strOutName ); return RESOURCE->NewString( strOutName );
} }
} }
return NULL; return NULL;
@ -179,14 +170,14 @@ MonoString* CMonoFunctions::Vehicle::GetName( DWORD pUserData )
MonoString* CMonoFunctions::Vehicle::GetNameFromModel( unsigned short usModel ) MonoString* CMonoFunctions::Vehicle::GetNameFromModel( unsigned short usModel )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
string strOutName; string strOutName;
if( CLuaFunctionDefinitions::GetVehicleNameFromModel( RESOURCE->GetLua(), usModel, strOutName ) ) if( CLuaFunctionDefinitions::GetVehicleNameFromModel( RESOURCE->GetLua(), usModel, strOutName ) )
{ {
return RESOURCE->NewString( strOutName ); return RESOURCE->NewString( strOutName );
} }
} }
return NULL; return NULL;
@ -247,12 +238,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurnVelocity( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, vecVelocity ) ) if( CLuaFunctionDefinitions::GetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, vecVelocity ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecVelocity ); return RESOURCE->NewObject( vecVelocity );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -267,12 +253,7 @@ MonoObject* CMonoFunctions::Vehicle::GetTurretPosition( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) ) if( CLuaFunctionDefinitions::GetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -335,14 +316,14 @@ MonoArray* CMonoFunctions::Vehicle::GetUpgrades( DWORD pUserData )
MonoString* CMonoFunctions::Vehicle::GetUpgradeSlotName( unsigned short usUpgrade ) MonoString* CMonoFunctions::Vehicle::GetUpgradeSlotName( unsigned short usUpgrade )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
string strOutName; string strOutName;
if( CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( RESOURCE->GetLua(), usUpgrade, strOutName ) ) if( CLuaFunctionDefinitions::GetVehicleUpgradeSlotName( RESOURCE->GetLua(), usUpgrade, strOutName ) )
{ {
return RESOURCE->NewString( strOutName ); return RESOURCE->NewString( strOutName );
} }
} }
return NULL; return NULL;
@ -388,12 +369,7 @@ MonoObject* CMonoFunctions::Vehicle::GetWheelStates( DWORD pUserData )
&ucFrontLeft, &ucRearLeft, &ucFrontRight, &ucRearRight &ucFrontLeft, &ucRearLeft, &ucFrontRight, &ucRearRight
}; };
CMonoObject* pObject = RESOURCE->NewObject( "MultiTheftAuto.Vehicle", "VehicleWheelsState", args, 4 ); return RESOURCE->NewObject( "MultiTheftAuto.Vehicle", "VehicleWheelsState", args, 4 );
if( pObject )
{
return pObject->GetObject();
}
} }
} }
@ -482,14 +458,14 @@ unsigned char CMonoFunctions::Vehicle::GetPaintjob( DWORD pUserData )
MonoString* CMonoFunctions::Vehicle::GetPlateText( DWORD pUserData ) MonoString* CMonoFunctions::Vehicle::GetPlateText( DWORD pUserData )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
char* szPlateText = NULL; char* szPlateText = NULL;
if( CLuaFunctionDefinitions::GetVehiclePlateText( RESOURCE->GetLua(), (void*)pUserData, szPlateText ) ) if( CLuaFunctionDefinitions::GetVehiclePlateText( RESOURCE->GetLua(), (void*)pUserData, szPlateText ) )
{ {
return RESOURCE->NewString( szPlateText ); return RESOURCE->NewString( szPlateText );
} }
} }
return NULL; return NULL;
@ -648,12 +624,7 @@ MonoObject* CMonoFunctions::Vehicle::GetHeadLightColor( DWORD pUserData )
if( CLuaFunctionDefinitions::GetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) ) if( CLuaFunctionDefinitions::GetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, outColor ) )
{ {
CMonoObject* pMonoObject = RESOURCE->NewObject( outColor ); return RESOURCE->NewObject( outColor );
if( pMonoObject )
{
return pMonoObject->GetObject();
}
} }
} }
@ -716,11 +687,9 @@ bool CMonoFunctions::Vehicle::SetTurnVelocity( DWORD pUserData, MonoObject* pVel
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pVelocity( pVelocity ); float fX = CMonoObject::GetPropertyValue< float >( pVelocity, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pVelocity, "Y" );
float fX = pVelocity.GetPropertyValue< float >( "X" ); float fZ = CMonoObject::GetPropertyValue< float >( pVelocity, "Z" );
float fY = pVelocity.GetPropertyValue< float >( "Y" );
float fZ = pVelocity.GetPropertyValue< float >( "Z" );
return CLuaFunctionDefinitions::SetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ ); return CLuaFunctionDefinitions::SetVehicleTurnVelocity( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ );
} }
@ -732,29 +701,21 @@ bool CMonoFunctions::Vehicle::SetColor( DWORD pUserData, MonoObject* pColor1, Mo
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pColor1( pColor1 ); unsigned char ucR1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "R" );
unsigned char ucG1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "G" );
unsigned char ucB1 = CMonoObject::GetPropertyValue< unsigned char >( pColor1, "B" );
unsigned char ucR1 = pColor1.GetPropertyValue< unsigned char >( "R" ); unsigned char ucR2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "R" );
unsigned char ucG1 = pColor1.GetPropertyValue< unsigned char >( "G" ); unsigned char ucG2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "G" );
unsigned char ucB1 = pColor1.GetPropertyValue< unsigned char >( "B" ); unsigned char ucB2 = CMonoObject::GetPropertyValue< unsigned char >( pColor2, "B" );
CMonoObject pColor2( pColor2 ); unsigned char ucR3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "R" );
unsigned char ucG3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "G" );
unsigned char ucB3 = CMonoObject::GetPropertyValue< unsigned char >( pColor3, "B" );
unsigned char ucR2 = pColor2.GetPropertyValue< unsigned char >( "R" ); unsigned char ucR4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "R" );
unsigned char ucG2 = pColor2.GetPropertyValue< unsigned char >( "G" ); unsigned char ucG4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "G" );
unsigned char ucB2 = pColor2.GetPropertyValue< unsigned char >( "B" ); unsigned char ucB4 = CMonoObject::GetPropertyValue< unsigned char >( pColor4, "B" );
CMonoObject pColor3( pColor3 );
unsigned char ucR3 = pColor3.GetPropertyValue< unsigned char >( "R" );
unsigned char ucG3 = pColor3.GetPropertyValue< unsigned char >( "G" );
unsigned char ucB3 = pColor3.GetPropertyValue< unsigned char >( "B" );
CMonoObject pColor4( pColor4 );
unsigned char ucR4 = pColor4.GetPropertyValue< unsigned char >( "R" );
unsigned char ucG4 = pColor4.GetPropertyValue< unsigned char >( "G" );
unsigned char ucB4 = pColor4.GetPropertyValue< unsigned char >( "B" );
return CLuaFunctionDefinitions::SetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1, ucR2, ucG2, ucB2, ucR3, ucG3, ucB3, ucR4, ucG4, ucB4 ); return CLuaFunctionDefinitions::SetVehicleColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1, ucR2, ucG2, ucB2, ucR3, ucG3, ucB3, ucR4, ucG4, ucB4 );
} }
@ -896,17 +857,13 @@ bool CMonoFunctions::Vehicle::SetRespawnPosition( DWORD pUserData, MonoObject* p
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fRX = CMonoObject::GetPropertyValue< float >( pRotation, "X" );
float fY = pPosition.GetPropertyValue< float >( "X" ); float fRY = CMonoObject::GetPropertyValue< float >( pRotation, "Y" );
float fZ = pPosition.GetPropertyValue< float >( "X" ); float fRZ = CMonoObject::GetPropertyValue< float >( pRotation, "Z" );
CMonoObject pRotation( pRotation );
float fRX = pRotation.GetPropertyValue< float >( "X" );
float fRY = pRotation.GetPropertyValue< float >( "X" );
float fRZ = pRotation.GetPropertyValue< float >( "X" );
return CLuaFunctionDefinitions::SetVehicleRespawnPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ ); return CLuaFunctionDefinitions::SetVehicleRespawnPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ );
} }
@ -948,17 +905,13 @@ bool CMonoFunctions::Vehicle::Spawn( DWORD pUserData, MonoObject* pPosition, Mon
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fRX = CMonoObject::GetPropertyValue< float >( pRotation, "X" );
float fY = pPosition.GetPropertyValue< float >( "X" ); float fRY = CMonoObject::GetPropertyValue< float >( pRotation, "Y" );
float fZ = pPosition.GetPropertyValue< float >( "X" ); float fRZ = CMonoObject::GetPropertyValue< float >( pRotation, "Z" );
CMonoObject pRotation( pRotation );
float fRX = pRotation.GetPropertyValue< float >( "X" );
float fRY = pRotation.GetPropertyValue< float >( "X" );
float fRZ = pRotation.GetPropertyValue< float >( "X" );
return CLuaFunctionDefinitions::SpawnVehicle( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ ); return CLuaFunctionDefinitions::SpawnVehicle( RESOURCE->GetLua(), (void*)pUserData, fX, fY, fZ, fRX, fRY, fRZ );
} }
@ -1100,11 +1053,9 @@ bool CMonoFunctions::Vehicle::SetHeadLightColor( DWORD pUserData, MonoObject* pC
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pColor1( pColor ); unsigned char ucR1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "R" );
unsigned char ucG1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "G" );
unsigned char ucR1 = pColor1.GetPropertyValue< unsigned char >( "R" ); unsigned char ucB1 = CMonoObject::GetPropertyValue< unsigned char >( pColor, "B" );
unsigned char ucG1 = pColor1.GetPropertyValue< unsigned char >( "G" );
unsigned char ucB1 = pColor1.GetPropertyValue< unsigned char >( "B" );
return CLuaFunctionDefinitions::SetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1 ); return CLuaFunctionDefinitions::SetVehicleHeadLightColor( RESOURCE->GetLua(), (void*)pUserData, ucR1, ucG1, ucB1 );
} }
@ -1116,10 +1067,8 @@ bool CMonoFunctions::Vehicle::SetTurretPosition( DWORD pUserData, MonoObject* pP
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fX = pPosition.GetPropertyValue< float >( "X" );
float fY = pPosition.GetPropertyValue< float >( "Y" );
return CLuaFunctionDefinitions::SetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY ); return CLuaFunctionDefinitions::SetVehicleTurretPosition( RESOURCE->GetLua(), (void*)pUserData, fX, fY );
} }
@ -1171,18 +1120,14 @@ bool CMonoFunctions::Vehicle::SetSirens( DWORD pUserData, unsigned char ucSirenI
{ {
if( RESOURCE ) if( RESOURCE )
{ {
CMonoObject pPosition( pPosition ); float fX = CMonoObject::GetPropertyValue< float >( pPosition, "X" );
float fY = CMonoObject::GetPropertyValue< float >( pPosition, "Y" );
float fZ = CMonoObject::GetPropertyValue< float >( pPosition, "Z" );
float fX = pPosition.GetPropertyValue< float >( "X" ); float fRed = CMonoObject::GetPropertyValue< float >( pColor, "R" );
float fY = pPosition.GetPropertyValue< float >( "Y" ); float fGreen = CMonoObject::GetPropertyValue< float >( pColor, "G" );
float fZ = pPosition.GetPropertyValue< float >( "Z" ); float fBlue = CMonoObject::GetPropertyValue< float >( pColor, "B" );
float fAlpha = CMonoObject::GetPropertyValue< float >( pColor, "A" );
CMonoObject pColor( pColor );
float fRed = pColor.GetPropertyValue< float >( "R" );
float fGreen = pColor.GetPropertyValue< float >( "G" );
float fBlue = pColor.GetPropertyValue< float >( "B" );
float fAlpha = pColor.GetPropertyValue< float >( "A" );
return CLuaFunctionDefinitions::SetVehicleSirens( RESOURCE->GetLua(), (void*)pUserData, ucSirenID, fX, fY, fZ, fRed, fGreen, fBlue, fAlpha, fMinAlpha ); return CLuaFunctionDefinitions::SetVehicleSirens( RESOURCE->GetLua(), (void*)pUserData, ucSirenID, fX, fY, fZ, fRed, fGreen, fBlue, fAlpha, fMinAlpha );
} }

View File

@ -1,137 +1,133 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CMonoFunctions.h" #include "CMonoFunctions.h"
// Water funcs // Water funcs
DWORD CMonoFunctions::Water::Create( MonoObject* pV1, MonoObject* pV2, MonoObject* pV3, MonoObject* pV4, bool bShallow ) DWORD CMonoFunctions::Water::Create( MonoObject* pV1, MonoObject* pV2, MonoObject* pV3, MonoObject* pV4, bool bShallow )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3* vec1 = &CMonoObject( pV1 ).GetVector3(); Vector3 vec1( pV1 );
Vector3* vec2 = &CMonoObject( pV2 ).GetVector3(); Vector3 vec2( pV2 );
Vector3* vec3 = &CMonoObject( pV3 ).GetVector3(); Vector3 vec3( pV3 );
Vector3* vec4 = pV4 ? &CMonoObject( pV4 ).GetVector3() : NULL; Vector3 vec4 = pV4 ? Vector3( pV4 ) : NULL;
return (DWORD)CLuaFunctionDefinitions::CreateWater( RESOURCE->GetLua(), vec1, vec2, vec3, vec4, bShallow ); return (DWORD)CLuaFunctionDefinitions::CreateWater( RESOURCE->GetLua(), &vec1, &vec2, &vec3, &vec4, bShallow );
} }
return NULL; return NULL;
} }
bool CMonoFunctions::Water::SetLevel( DWORD pUserData, float fLevel ) bool CMonoFunctions::Water::SetLevel( DWORD pUserData, float fLevel )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetElementWaterLevel( RESOURCE->GetLua(), (void*)pUserData, fLevel ); return CLuaFunctionDefinitions::SetElementWaterLevel( RESOURCE->GetLua(), (void*)pUserData, fLevel );
} }
return false; return false;
} }
bool CMonoFunctions::Water::SetLevelAll( float fLevel ) bool CMonoFunctions::Water::SetLevelAll( float fLevel )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetAllElementWaterLevel( RESOURCE->GetLua(), fLevel ); return CLuaFunctionDefinitions::SetAllElementWaterLevel( RESOURCE->GetLua(), fLevel );
} }
return false; return false;
} }
bool CMonoFunctions::Water::SetLevelWorld( float fLevel, bool bIncludeWorldNonSeaLevel ) bool CMonoFunctions::Water::SetLevelWorld( float fLevel, bool bIncludeWorldNonSeaLevel )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::SetWorldWaterLevel( RESOURCE->GetLua(), fLevel, bIncludeWorldNonSeaLevel ); return CLuaFunctionDefinitions::SetWorldWaterLevel( RESOURCE->GetLua(), fLevel, bIncludeWorldNonSeaLevel );
} }
return false; return false;
} }
bool CMonoFunctions::Water::ResetLevelWorld( void ) bool CMonoFunctions::Water::ResetLevelWorld( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::ResetWorldWaterLevel( RESOURCE->GetLua() ); return CLuaFunctionDefinitions::ResetWorldWaterLevel( RESOURCE->GetLua() );
} }
return false; return false;
} }
MonoObject* CMonoFunctions::Water::GetVertexPosition( DWORD pUserData, int iVertexIndex ) MonoObject* CMonoFunctions::Water::GetVertexPosition( DWORD pUserData, int iVertexIndex )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition; Vector3 vecPosition;
if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) ) if( CLuaFunctionDefinitions::GetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( vecPosition ); return RESOURCE->NewObject( vecPosition );
}
return pObject ? pObject->GetObject() : NULL; }
}
}
return NULL; return NULL;
} }
bool CMonoFunctions::Water::SetVertexPosition( DWORD pUserData, int iVertexIndex, MonoObject* mPosition ) bool CMonoFunctions::Water::SetVertexPosition( DWORD pUserData, int iVertexIndex, MonoObject* mPosition )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
Vector3 vecPosition = CMonoObject( mPosition ).GetVector3(); Vector3 vecPosition( mPosition );
return CLuaFunctionDefinitions::SetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition ); return CLuaFunctionDefinitions::SetWaterVertexPosition( RESOURCE->GetLua(), (void*)pUserData, iVertexIndex, vecPosition );
} }
return false; return false;
} }
MonoObject* CMonoFunctions::Water::GetColor( void ) MonoObject* CMonoFunctions::Water::GetColor( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor; SColor pColor;
if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) ) if( CLuaFunctionDefinitions::GetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ) )
{ {
CMonoObject* pObject = RESOURCE->NewObject( pColor ); return RESOURCE->NewObject( pColor );
}
return pObject ? pObject->GetObject() : NULL; }
}
}
return NULL; return NULL;
} }
bool CMonoFunctions::Water::SetColor( MonoObject* mColor ) bool CMonoFunctions::Water::SetColor( MonoObject* mColor )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
SColor pColor = CMonoObject( mColor ).GetColor(); SColor pColor = CMonoObject::GetColor( mColor );
return CLuaFunctionDefinitions::SetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A ); return CLuaFunctionDefinitions::SetWaterColor( RESOURCE->GetLua(), pColor.R, pColor.G, pColor.B, pColor.A );
} }
return false; return false;
} }
bool CMonoFunctions::Water::ResetColor( void ) bool CMonoFunctions::Water::ResetColor( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
return CLuaFunctionDefinitions::ResetWaterColor( RESOURCE->GetLua() ); return CLuaFunctionDefinitions::ResetWaterColor( RESOURCE->GetLua() );
} }
return false; return false;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,270 +1,265 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
#include "CResource.h" #include "CResource.h"
#include "CResourceManager.h" #include "CResourceManager.h"
#include "include/ILuaModuleManager.h" #include "include/ILuaModuleManager.h"
#include "lua/CLuaFunctionDefinitions.h" #include "lua/CLuaFunctionDefinitions.h"
extern ILuaModuleManager10 *g_pModuleManager; extern ILuaModuleManager10 *g_pModuleManager;
extern CResourceManager *g_pResourceManager; extern CResourceManager *g_pResourceManager;
CResource::CResource( lua_State *pLuaVM, string sName ) CResource::CResource( lua_State *pLuaVM, string sName )
{ {
this->m_pLuaVM = pLuaVM; this->m_pLuaVM = pLuaVM;
this->m_sName = sName; this->m_sName = sName;
this->m_pMonoAssembly = NULL; this->m_pMonoAssembly = NULL;
this->m_pMonoAssemblyLib = NULL; this->m_pMonoAssemblyLib = NULL;
this->m_pMonoGCHandle = NULL; this->m_pMonoGCHandle = NULL;
this->m_pMonoDomain = NULL; this->m_pMonoDomain = NULL;
this->m_pMonoImage = NULL; this->m_pMonoImage = NULL;
this->m_pMonoImageLib = NULL; this->m_pMonoImageLib = NULL;
this->m_pMonoClass = NULL; this->m_pMonoClass = NULL;
} }
CResource::~CResource( void ) CResource::~CResource( void )
{ {
mono_domain_set( mono_get_root_domain(), false ); mono_domain_set( mono_get_root_domain(), false );
if( this->m_pMonoDomain ) if( this->m_pMonoDomain )
{ {
mono_domain_unload( this->m_pMonoDomain ); mono_domain_unload( this->m_pMonoDomain );
} }
mono_gc_collect( mono_gc_max_generation() ); mono_gc_collect( mono_gc_max_generation() );
g_pResourceManager->RemoveFromList( this ); g_pResourceManager->RemoveFromList( this );
this->m_pMonoAssembly = NULL; this->m_pMonoAssembly = NULL;
this->m_pMonoAssemblyLib = NULL; this->m_pMonoAssemblyLib = NULL;
this->m_pMonoGCHandle = NULL; this->m_pMonoGCHandle = NULL;
this->m_pMonoDomain = NULL; this->m_pMonoDomain = NULL;
this->m_pMonoImage = NULL; this->m_pMonoImage = NULL;
this->m_pMonoImageLib = NULL; this->m_pMonoImageLib = NULL;
this->m_pMonoClass = NULL; this->m_pMonoClass = NULL;
this->m_pLuaVM = NULL; this->m_pLuaVM = NULL;
} }
bool CResource::Init( void ) bool CResource::Init( void )
{ {
if( this->m_pLuaVM ) if( this->m_pLuaVM )
{ {
string sDirectory ( "mods/deathmatch/resources/[ire]/" + this->m_sName + "/" ); string sDirectory ( "mods/deathmatch/resources/[ire]/" + this->m_sName + "/" );
string sPath ( sDirectory + this->m_sName + ".dll" ); string sPath ( sDirectory + this->m_sName + ".dll" );
string sNamespace ( this->m_sName ); string sNamespace ( this->m_sName );
string sClass ( "Program" ); string sClass ( "Program" );
this->m_pMonoDomain = mono_domain_create_appdomain( const_cast< char* >( this->m_sName.c_str( ) ), NULL ); this->m_pMonoDomain = mono_domain_create_appdomain( const_cast< char* >( this->m_sName.c_str( ) ), NULL );
if( !this->m_pMonoDomain ) if( !this->m_pMonoDomain )
{ {
g_pModuleManager->ErrorPrintf( "%s - failed to create appdomain\n", this->m_sName.c_str() ); g_pModuleManager->ErrorPrintf( "%s - failed to create appdomain\n", this->m_sName.c_str() );
return false; return false;
} }
mono_domain_set( this->m_pMonoDomain, false ); mono_domain_set( this->m_pMonoDomain, false );
this->m_pMonoAssemblyLib = mono_domain_assembly_open( this->m_pMonoDomain, ( sDirectory + "MultiTheftAuto.dll" ).c_str() ); this->m_pMonoAssemblyLib = mono_domain_assembly_open( this->m_pMonoDomain, ( sDirectory + "MultiTheftAuto.dll" ).c_str() );
if( this->m_pMonoAssemblyLib ) if( this->m_pMonoAssemblyLib )
{ {
this->m_pMonoImageLib = mono_assembly_get_image( 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 = mono_domain_assembly_open( this->m_pMonoDomain, sPath.c_str() );
if( !this->m_pMonoAssembly ) if( !this->m_pMonoAssembly )
{ {
g_pModuleManager->ErrorPrintf( "failed to open assembly '%s.dll'\n", this->m_sName.c_str() ); g_pModuleManager->ErrorPrintf( "failed to open assembly '%s.dll'\n", this->m_sName.c_str() );
return false; return false;
} }
this->m_pMonoImage = mono_assembly_get_image( this->m_pMonoAssembly ); 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() ); 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 = mono_object_new( this->m_pMonoDomain, this->m_pMonoClass );
mono_gchandle_new( pMonoObject, false ); mono_gchandle_new( pMonoObject, false );
mono_runtime_object_init( pMonoObject ); mono_runtime_object_init( pMonoObject );
return true; return true;
} }
return false; return false;
} }
void CResource::OnStopping( void ) void CResource::OnStopping( void )
{ {
} }
void CResource::DoPulse( void ) void CResource::DoPulse( void )
{ {
} }
bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func ) bool CResource::RegisterFunction( const char *szFunctionName, lua_CFunction Func )
{ {
if( !g_pModuleManager->RegisterFunction( this->m_pLuaVM, szFunctionName, Func ) ) if( !g_pModuleManager->RegisterFunction( this->m_pLuaVM, szFunctionName, Func ) )
{ {
g_pModuleManager->ErrorPrintf( "Failed to register function '%s' for %s", szFunctionName, this->m_sName.c_str() ); g_pModuleManager->ErrorPrintf( "Failed to register function '%s' for %s", szFunctionName, this->m_sName.c_str() );
return false; return false;
} }
return true; return true;
} }
CMonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName ) MonoClass* CResource::GetClassFromName( const char* szNamespace, const char* szName )
{ {
MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName ); MonoClass* pMonoClass = mono_class_from_name( this->m_pMonoImage, szNamespace, szName );
if( !pMonoClass ) if( !pMonoClass )
{ {
pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName ); pMonoClass = mono_class_from_name( this->m_pMonoImageLib, szNamespace, szName );
} }
if( pMonoClass ) return pMonoClass;
{ }
return new CMonoClass( pMonoClass );
} MonoObject* CResource::NewObject( const char* szNamespace, const char* szName )
{
return NULL; MonoClass* pClass = this->GetClassFromName( szNamespace, szName );
}
if( pClass )
CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName ) {
{ MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get() );
CMonoClass* pClass = this->GetClassFromName( szNamespace, szName );
if( pObject )
if( pClass ) {
{ return pObject;
CMonoObject* pObject = pClass->New( mono_domain_get() ); }
else
if( pObject ) {
{ g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName );
return pObject; }
} }
else else
{ {
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName ); g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
} }
}
else return nullptr;
{ }
g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
} MonoObject* CResource::NewObject( SColor& pColor )
{
return NULL; MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Color" );
}
if( pClass )
CMonoObject* CResource::NewObject( SColor& pColor ) {
{ MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), pColor );
CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Color" );
if( pObject )
if( pClass ) {
{ return pObject;
CMonoObject* pObject = pClass->New( mono_domain_get(), pColor ); }
else
if( pObject ) {
{ g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Color'\n", __FILE__, __LINE__ );
return pObject; }
} }
else else
{ {
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ ); g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Color' not found\n", __FILE__, __LINE__ );
} }
}
else return nullptr;
{ }
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ );
} MonoObject* CResource::NewObject( Vector2& vecVector )
{
return NULL; MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector2" );
}
if( pClass )
CMonoObject* CResource::NewObject( Vector2& vecVector ) {
{ MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector );
CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector2" );
if( pObject )
if( pClass ) {
{ return pObject;
CMonoObject* pObject = pClass->New( mono_domain_get(), vecVector ); }
else
if( pObject ) {
{ g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ );
return pObject; }
} }
else else
{ {
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector2'\n", __FILE__, __LINE__ ); g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ );
} }
}
else return nullptr;
{ }
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector2' not found\n", __FILE__, __LINE__ );
} MonoObject* CResource::NewObject( Vector3& vecVector )
{
return NULL; MonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector3" );
}
if( pClass )
CMonoObject* CResource::NewObject( Vector3& vecVector ) {
{ MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), vecVector );
CMonoClass* pClass = this->GetClassFromName( "MultiTheftAuto", "Vector3" );
if( pObject )
if( pClass ) {
{ return pObject;
CMonoObject* pObject = pClass->New( mono_domain_get(), vecVector ); }
else
if( pObject ) {
{ g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector3'\n", __FILE__, __LINE__ );
return pObject; }
} }
else else
{ {
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of 'MultiTheftAuto::Vector3'\n", __FILE__, __LINE__ ); g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ );
} }
}
else return nullptr;
{ }
g_pModuleManager->ErrorPrintf( "%s:%d: class 'MultiTheftAuto::Vector3' not found\n", __FILE__, __LINE__ );
} MonoObject* CResource::NewObject( const char* szNamespace, const char* szName, void** args, int argc )
{
return NULL; MonoClass* pClass = this->GetClassFromName( szNamespace, szName );
}
if( pClass )
CMonoObject* CResource::NewObject( const char* szNamespace, const char* szName, void** args, int argc ) {
{ MonoObject* pObject = CMonoClass::New( pClass, mono_domain_get(), args, argc );
CMonoClass* pClass = this->GetClassFromName( szNamespace, szName );
if( pObject )
if( pClass ) {
{ return pObject;
CMonoObject* pObject = pClass->New( mono_domain_get(), args, argc ); }
else
if( pObject ) {
{ g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName );
return pObject; }
} }
else else
{ {
g_pModuleManager->ErrorPrintf( "%s:%d: failed to create instance of '%s::%s'\n", __FILE__, __LINE__, szNamespace, szName ); g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
} }
}
else return nullptr;
{ }
g_pModuleManager->ErrorPrintf( "%s:%d: class '%s::%s' not found\n", __FILE__, __LINE__, szNamespace, szName );
}
return NULL;
}

View File

@ -1,104 +1,104 @@
/********************************************************* /*********************************************************
* *
* Copyright © 2013, Innovation Roleplay Engine. * Copyright © 2013, Innovation Roleplay Engine.
* *
* All Rights Reserved. * All Rights Reserved.
* *
* Redistribution and use in source and binary forms, * Redistribution and use in source and binary forms,
* with or without modification, * with or without modification,
* is permitted only for authors. * is permitted only for authors.
* *
*********************************************************/ *********************************************************/
class CResource; class CResource;
#ifndef __CRESOURCE_H #ifndef __CRESOURCE_H
#define __CRESOURCE_H #define __CRESOURCE_H
#include "Common.h" #include "Common.h"
#include "CMonoClass.h" #include "CMonoClass.h"
#include "extra/CLuaArguments.h" #include "extra/CLuaArguments.h"
class CResource class CResource
{ {
private: private:
string m_sName; string m_sName;
MonoAssembly *m_pMonoAssembly; MonoAssembly *m_pMonoAssembly;
MonoAssembly *m_pMonoAssemblyLib; MonoAssembly *m_pMonoAssemblyLib;
MonoImage *m_pMonoImage; MonoImage *m_pMonoImage;
MonoImage *m_pMonoImageLib; MonoImage *m_pMonoImageLib;
MonoClass *m_pMonoClass; MonoClass *m_pMonoClass;
uint32_t m_pMonoGCHandle; uint32_t m_pMonoGCHandle;
public: public:
lua_State *m_pLuaVM; lua_State *m_pLuaVM;
MonoDomain *m_pMonoDomain; MonoDomain *m_pMonoDomain;
CResource ( lua_State *pLuaVM, string sName ); CResource ( lua_State *pLuaVM, string sName );
~CResource ( void ); ~CResource ( void );
bool Init ( void ); bool Init ( void );
void OnStopping ( void ); void OnStopping ( void );
void DoPulse ( void ); void DoPulse ( void );
bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func ); bool RegisterFunction ( const char *szFunctionName, lua_CFunction Func );
CMonoClass* GetClassFromName( const char* szNamespace, const char* szName ); MonoClass* GetClassFromName( const char* szNamespace, const char* szName );
CMonoObject* NewObject( const char* szNamespace, const char* szName ); MonoObject* NewObject( const char* szNamespace, const char* szName );
CMonoObject* NewObject( SColor& pColor ); MonoObject* NewObject( SColor& pColor );
CMonoObject* NewObject( Vector2& vecVector ); MonoObject* NewObject( Vector2& vecVector );
CMonoObject* NewObject( Vector3& vecVector ); MonoObject* NewObject( Vector3& vecVector );
CMonoObject* NewObject( const char* szNamespace, const char* szName, void** args, int argc ); MonoObject* NewObject( const char* szNamespace, const char* szName, void** args, int argc );
MonoString* NewString( const char* szText ) MonoString* NewString( const char* szText )
{ {
return mono_string_new( this->m_pMonoDomain, szText ); return mono_string_new( this->m_pMonoDomain, szText );
} }
MonoString* NewString( string strText ) MonoString* NewString( string strText )
{ {
return mono_string_new( this->m_pMonoDomain, strText.c_str() ); return mono_string_new( this->m_pMonoDomain, strText.c_str() );
} }
template <class T, int LuaType> MonoArray* NewArray( MonoClass* pMonoClass, CLuaArguments* pLuaArguments = NULL ) template <class T, int LuaType> MonoArray* NewArray( MonoClass* pMonoClass, CLuaArguments* pLuaArguments = NULL )
{ {
MonoArray* pArray = mono_array_new( this->m_pMonoDomain, pMonoClass, pLuaArguments ? pLuaArguments->Count() : 0 ); MonoArray* pArray = mono_array_new( this->m_pMonoDomain, pMonoClass, pLuaArguments ? pLuaArguments->Count() : 0 );
if( pLuaArguments ) if( pLuaArguments )
{ {
vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin(); vector< CLuaArgument* >::const_iterator iter = pLuaArguments->IterBegin();
for( unsigned int i = 0; iter != pLuaArguments->IterEnd(); iter++, i++ ) for( unsigned int i = 0; iter != pLuaArguments->IterEnd(); iter++, i++ )
{ {
if( LuaType == LUA_TBOOLEAN ) if( LuaType == LUA_TBOOLEAN )
{ {
mono_array_set( pArray, T, i, (T)( ( *iter )->GetBoolean() ) ); mono_array_set( pArray, T, i, (T)( ( *iter )->GetBoolean() ) );
} }
else if( LuaType == LUA_TLIGHTUSERDATA ) else if( LuaType == LUA_TLIGHTUSERDATA )
{ {
mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) ); mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) );
} }
else if( LuaType == LUA_TNUMBER ) else if( LuaType == LUA_TNUMBER )
{ {
mono_array_set( pArray, T, i, ( *iter )->GetNumber< T >() ); mono_array_set( pArray, T, i, ( *iter )->GetNumber< T >() );
} }
else if( LuaType == LUA_TSTRING ) else if( LuaType == LUA_TSTRING )
{ {
mono_array_set( pArray, T, i, (T)( ( *iter )->GetString() ) ); mono_array_set( pArray, T, i, (T)( ( *iter )->GetString() ) );
} }
else if( LuaType == LUA_TUSERDATA ) else if( LuaType == LUA_TUSERDATA )
{ {
mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) ); mono_array_set( pArray, T, i, (T)( ( *iter )->GetLightUserData() ) );
} }
} }
} }
return pArray; return pArray;
} }
string GetName ( void ) { return this->m_sName; } string GetName ( void ) { return this->m_sName; }
lua_State *GetLua ( void ) { return this->m_pLuaVM; } lua_State *GetLua ( void ) { return this->m_pLuaVM; }
}; };
#endif #endif