diff --git a/code/nel/tools/3d/ligo/plugin_max/DllEntry.cpp b/code/nel/tools/3d/ligo/plugin_max/DllEntry.cpp index dee174c9c..c3e90719e 100644 --- a/code/nel/tools/3d/ligo/plugin_max/DllEntry.cpp +++ b/code/nel/tools/3d/ligo/plugin_max/DllEntry.cpp @@ -12,6 +12,8 @@ **********************************************************************/ #include "ligoscape_utility.h" #include "nel/misc/app_context.h" +#include +#include "../../plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.h" extern ClassDesc2* GetLigoscapeDesc(); @@ -26,6 +28,13 @@ int controlsInit = FALSE; BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { + // initialize nel context + if (!NLMISC::INelContext::isContextInitialised()) + { + new NLMISC::CLibraryContext(GetSharedNelContext()); + nldebug("NeL Ligoscape Utility: DllMain"); + } + hInstance = hinstDLL; // Hang on to this DLL's instance handle. if (!controlsInit) diff --git a/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.cpp b/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.cpp index 9053eecc9..2c5cedd65 100644 --- a/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.cpp +++ b/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.cpp @@ -27,7 +27,10 @@ BOOL APIENTRY DllMain( HANDLE hModule, { // initialize nel context if (!NLMISC::INelContext::isContextInitialised()) - new NLMISC::CApplicationContext(); + { + GetSharedNelContext(); + nldebug("NeL 3ds Max Shared: DllMain"); + } switch (ul_reason_for_call) { @@ -51,10 +54,20 @@ void init () // The static allocator static CPatchAllocator Allocator; -NEL_3DSMAX_SHARED_API CPatchAllocator& GetAllocator () +NEL_3DSMAX_SHARED_API CPatchAllocator &GetAllocator () { // Init fonction init (); return Allocator; } + +NEL_3DSMAX_SHARED_API NLMISC::INelContext &GetSharedNelContext() +{ + if (!NLMISC::INelContext::isContextInitialised()) + { + new NLMISC::CApplicationContext(); + NLMISC::createDebug(); + } + return NLMISC::INelContext::getInstance(); +} diff --git a/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.h b/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.h index 4a6b72335..d7a248fef 100644 --- a/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.h +++ b/code/nel/tools/3d/plugin_max/nel_3dsmax_shared/nel_3dsmax_shared.h @@ -14,11 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +class CPatchAllocator; + #ifdef NEL_3DSMAX_SHARED_EXPORTS #define NEL_3DSMAX_SHARED_API __declspec(dllexport) #else #define NEL_3DSMAX_SHARED_API __declspec(dllimport) #endif -extern NEL_3DSMAX_SHARED_API CPatchAllocator& GetAllocator (); +extern NEL_3DSMAX_SHARED_API CPatchAllocator& GetAllocator(); +extern NEL_3DSMAX_SHARED_API NLMISC::INelContext &GetSharedNelContext(); diff --git a/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp b/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp index ac9868e97..61337b328 100644 --- a/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/nel_export/DllEntry.cpp @@ -18,6 +18,7 @@ #include "nel_export.h" #include "nel/3d/register_3d.h" #include "nel/misc/app_context.h" +#include "../nel_3dsmax_shared/nel_3dsmax_shared.h" extern ClassDesc2* GetCNelExportDesc(); @@ -30,7 +31,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { // initialize nel context if (!NLMISC::INelContext::isContextInitialised()) - new NLMISC::CApplicationContext(); + { + new NLMISC::CLibraryContext(GetSharedNelContext()); + nldebug("NeL Export: DllMain"); + } hInstance = hinstDLL; // Hang on to this DLL's instance handle. diff --git a/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp b/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp index 3216466cb..22ae76790 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_converter/DllEntry.cpp @@ -19,6 +19,7 @@ #include "PO2RPO.h" #include "nel/misc/debug.h" #include "nel/misc/app_context.h" +#include "../nel_3dsmax_shared/nel_3dsmax_shared.h" extern ClassDesc2* GetPO2RPODesc(); extern ClassDesc* GetRPODesc(); @@ -38,6 +39,12 @@ int controlsInit = FALSE; BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { + if (!NLMISC::INelContext::isContextInitialised()) + { + new NLMISC::CLibraryContext(GetSharedNelContext()); + nldebug("NeL Export: DllMain"); + } + if(fdwReason == DLL_PROCESS_ATTACH) { // Hang on to this DLL's instance handle. diff --git a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp index 6fc721caa..8470f3653 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_edit/np_mods.cpp @@ -15,6 +15,7 @@ #include "editpat.h" #include +#include "../nel_3dsmax_shared/nel_3dsmax_shared.h" HINSTANCE hInstance; int controlsInit = FALSE; @@ -24,6 +25,13 @@ using namespace NLMISC; /** public functions **/ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { + // initialize nel context + if (!NLMISC::INelContext::isContextInitialised()) + { + new NLMISC::CLibraryContext(GetSharedNelContext()); + nldebug("NeL Patch Edit: DllMain"); + } + if (fdwReason == DLL_PROCESS_ATTACH) { hInstance = hinstDLL; diff --git a/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp b/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp index 72d51e81d..d7fd70aec 100644 --- a/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/nel_patch_paint/DllEntry.cpp @@ -2,6 +2,7 @@ #include "nel_patch_paint.h" #include "nel/misc/debug.h" #include "nel/misc/app_context.h" +#include "../nel_3dsmax_shared/nel_3dsmax_shared.h" HINSTANCE hInstance; int controlsInit = FALSE; @@ -13,7 +14,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { // initialize nel context if (!NLMISC::INelContext::isContextInitialised()) - new NLMISC::CApplicationContext(); + { + new NLMISC::CLibraryContext(GetSharedNelContext()); + nldebug("NeL Patch Paint: DllMain"); + } hInstance = hinstDLL; diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp index b20b421c6..4dc068eea 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/dllmain.cpp @@ -1,11 +1,19 @@ #include "vertex_tree_paint.h" +#include "../nel_3dsmax_shared/nel_3dsmax_shared.h" HINSTANCE hInstance; BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) +{ + // initialize nel context + if (!NLMISC::INelContext::isContextInitialised()) { + new NLMISC::CLibraryContext(GetSharedNelContext()); + nldebug("NeL Vertex Tree Paint: DllMain"); + } + hInstance = hinstDLL; // Hang on to this DLL's instance handle. switch (fdwReason) { @@ -16,31 +24,31 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) } return (TRUE); - } +} __declspec( dllexport ) const TCHAR* LibDescription() - { +{ return GetString(IDS_LIBDESCRIPTION); - } +} __declspec( dllexport ) int LibNumberClasses() - { +{ return 1; - } +} __declspec( dllexport ) ClassDesc* LibClassDesc(int i) - { +{ switch(i) { case 0: return GetVertexPaintDesc(); default: return 0; } - } +} __declspec( dllexport ) ULONG LibVersion() - { +{ return VERSION_3DSMAX; - } +} // Let the plug-in register itself for deferred loading __declspec( dllexport ) ULONG CanAutoDefer() @@ -49,11 +57,11 @@ __declspec( dllexport ) ULONG CanAutoDefer() } TCHAR *GetString(int id) - { +{ static TCHAR buf[256]; if (hInstance) return LoadString(hInstance, id, buf, sizeof(buf)) ? buf : NULL; return NULL; - } +} diff --git a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h index 104a8afa1..b55caa8d1 100644 --- a/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h +++ b/code/nel/tools/3d/plugin_max/nel_vertex_tree_paint/vertex_tree_paint.h @@ -19,6 +19,15 @@ #include "istdplug.h" #include "modstack.h" +#ifdef min +#undef min +#endif +#ifdef max +#undef max +#endif +#define NL_MAP_ASSERT +#include + #define VERTEX_TREE_PAINT_CLASS_ID Class_ID(0x40c7005e, 0x2a95082c) #define CID_PAINT (CID_USER+0x439c) diff --git a/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp b/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp index 71a8372dd..d1c6c7d6b 100644 --- a/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp +++ b/code/nel/tools/3d/plugin_max/tile_utility/DllEntry.cpp @@ -16,7 +16,9 @@ #include "tile_utility.h" #include +#include #include "nel/misc/app_context.h" +#include "../nel_3dsmax_shared/nel_3dsmax_shared.h" #include extern ClassDesc2* GetTile_utilityDesc(); @@ -35,7 +37,10 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved) { // initialize nel context if (!NLMISC::INelContext::isContextInitialised()) - new NLMISC::CApplicationContext(); + { + new NLMISC::CLibraryContext(GetSharedNelContext()); + nldebug("NeL Tile Utility: DllMain"); + } hInstance = hinstDLL; // Hang on to this DLL's instance handle.