From b0cc1c5fd104a02bc03e93c56f6c4a5c46195d39 Mon Sep 17 00:00:00 2001 From: Kernell Date: Sat, 28 Nov 2015 04:45:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=20=D0=BA=D0=B0=D0=BA=D0=BE=D0=B9-?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BF=D1=80=D0=B8=D1=87=D0=B8=D0=BD=D0=B5=20ILu?= =?UTF-8?q?aModuleManager10::GetResourceName=20=D0=BA=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D1=91=D1=82=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80.=20=D0=98?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F=20=D0=B0=D0=BB=D1=8C=D1=82=D0=B5=D1=80=D0=BD=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D0=B2=D0=BD=D1=8B=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0?= =?UTF-8?q?=D0=BD=D1=82=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=20=D1=80=D0=B5=D1=81?= =?UTF-8?q?=D1=83=D1=80=D1=81=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mta-mono/src/CFunctions.cpp | 79 ++++++++++-------- mta-mono/src/mta-mono.cpp | 155 ++++++++++++++++++------------------ 2 files changed, 121 insertions(+), 113 deletions(-) diff --git a/mta-mono/src/CFunctions.cpp b/mta-mono/src/CFunctions.cpp index 6d045af..4cd6591 100644 --- a/mta-mono/src/CFunctions.cpp +++ b/mta-mono/src/CFunctions.cpp @@ -1,36 +1,45 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "CFunctions.h" -#include "extra/CLuaArguments.h" - -int CFunctions::monoInit( lua_State *pLuaVM ) -{ - if( pLuaVM ) - { - CResource *pResource; - - if( !( pResource = g_pResourceManager->GetFromList( pLuaVM ) ) ) - { - pResource = g_pResourceManager->Create( pLuaVM ); - } - - if( pResource ) - { - pResource->Init(); - - return 1; - } - } - - return 0; +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "CFunctions.h" +#include "extra/CLuaArguments.h" + +int CFunctions::monoInit( lua_State *pLuaVM ) +{ + if( pLuaVM ) + { + CResource *pResource = g_pResourceManager->GetFromList( pLuaVM ); + + if( pResource == nullptr ) + { + //if( g_pModuleManager->GetResourceName( luaVM, strName ) ) + + CLuaArgument pLuaArgument( pLuaVM, -1 ); + + string strName = pLuaArgument.GetString(); + + if( !strName.empty() ) + { + pResource = g_pResourceManager->Create( pLuaVM, strName ); + } + } + + if( pResource != nullptr ) + { + pResource->Init(); + + return 1; + } + } + + return 0; } \ No newline at end of file diff --git a/mta-mono/src/mta-mono.cpp b/mta-mono/src/mta-mono.cpp index 545dd5e..a77fcef 100644 --- a/mta-mono/src/mta-mono.cpp +++ b/mta-mono/src/mta-mono.cpp @@ -1,79 +1,78 @@ -/********************************************************* -* -* Copyright © 2013, Innovation Roleplay Engine. -* -* All Rights Reserved. -* -* Redistribution and use in source and binary forms, -* with or without modification, -* is permitted only for authors. -* -*********************************************************/ - -#include "mta-mono.h" - -MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, char *szAuthor, float *fVersion ) -{ - g_pModuleManager = pManager; - g_pResourceManager = new CResourceManager(); - - strncpy( szModuleName, MODULE_NAME, MAX_INFO_LENGTH ); - strncpy( szAuthor, MODULE_AUTHOR, MAX_INFO_LENGTH ); - - (*fVersion) = MODULE_VERSION; - - return true; -} - - -MTAEXPORT void RegisterFunctions( lua_State *pLuaVM ) -{ - if( g_pModuleManager && pLuaVM && g_pResourceManager ) - { - if( g_pModuleManager->RegisterFunction( pLuaVM, "monoInit", CFunctions::monoInit ) ) - { - luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, monoInit )" ); - } - } -} - - -MTAEXPORT bool DoPulse( void ) -{ - if( g_pResourceManager ) - { - g_pResourceManager->DoPulse(); - } - - return true; -} - -MTAEXPORT bool ShutdownModule( void ) -{ - if( g_pResourceManager ) - { - delete g_pResourceManager; - } - - return true; -} - -MTAEXPORT bool ResourceStopping( lua_State* luaVM ) -{ - if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) ) - { - pResource->OnStopping(); - } - - return true; -} - -MTAEXPORT bool ResourceStopped( lua_State* luaVM ) -{ - if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) ) - { - delete pResource; - } - - return true; +/********************************************************* +* +* Copyright © 2013, Innovation Roleplay Engine. +* +* All Rights Reserved. +* +* Redistribution and use in source and binary forms, +* with or without modification, +* is permitted only for authors. +* +*********************************************************/ + +#include "mta-mono.h" + +MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, char *szAuthor, float *fVersion ) +{ + g_pModuleManager = pManager; + g_pResourceManager = new CResourceManager(); + + strncpy( szModuleName, MODULE_NAME, MAX_INFO_LENGTH ); + strncpy( szAuthor, MODULE_AUTHOR, MAX_INFO_LENGTH ); + + (*fVersion) = MODULE_VERSION; + + return true; +} + +MTAEXPORT void RegisterFunctions( lua_State *pLuaVM ) +{ + if( g_pModuleManager && pLuaVM && g_pResourceManager ) + { + if( g_pModuleManager->RegisterFunction( pLuaVM, "monoInit", CFunctions::monoInit ) ) + { + //luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, monoInit )" ); + luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, function( res ) monoInit( getResourceName( res ) ) end )" ); + } + } +} + +MTAEXPORT bool DoPulse( void ) +{ + if( g_pResourceManager ) + { + g_pResourceManager->DoPulse(); + } + + return true; +} + +MTAEXPORT bool ShutdownModule( void ) +{ + if( g_pResourceManager ) + { + delete g_pResourceManager; + } + + return true; +} + +MTAEXPORT bool ResourceStopping( lua_State* luaVM ) +{ + if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) ) + { + pResource->OnStopping(); + } + + return true; +} + +MTAEXPORT bool ResourceStopped( lua_State* luaVM ) +{ + if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) ) + { + delete pResource; + } + + return true; } \ No newline at end of file