reman3/Rayman_X/cpa/tempgrp/OAC/Src/_DLLCom.cpp

122 lines
3.3 KiB
C++

//
// Common functions for Object DLL capabilities
// C. Beaudet
//
#include "StdAfx.h"
#include "ACP_Base.h"
#include "afxdllx.h"
#include "ITF.h"
#include "_Ainterf.hpp"
//YB
#include "EDACStrg.hpp"
#include "EdtList.hpp"
#include "x:\cpa\main\inc\_EditID.h"
//End YB
//------------------------------------------------------------------------
// Global vars
static char *gs_p_szCPAVersion = C_szCPAVersion;
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
#ifdef DLL_ONLY_ONE_INSTANCE
static CPA_Actor_Editor_Interface *gs_p_oActorsDLLInterface = NULL;
#endif
static CList<CPA_DLLBase*,CPA_DLLBase*> g_oListOfInstances; //private internal
//------------------------------------------------------------------------
// functions that are present in all DLL :
//------------------------------------------------------------------------
//========================================================================
// Get current CPA version
//========================================================================
extern "C"char __declspec(dllexport) *fn_p_szGetCPAVersion(void)
{
return gs_p_szCPAVersion;
}
//========================================================================
// Get type of this DLL
//========================================================================
extern "C"tdstDLLIdentity __declspec(dllexport) *fn_p_stGetDLLIdentity(void)
{
g_stActorEditorIdentity.eType = OBJECT_DLL; //object DLL type
g_stActorEditorIdentity.csName = g_c_csActorDLLName; //object DLL name (unique name)
g_stActorEditorIdentity.hModule = NULL;
g_stActorEditorIdentity.p_oListOfInstances = &g_oListOfInstances;
return &g_stActorEditorIdentity;
}
//========================================================================
// DLL int function
//========================================================================
extern "C" void __declspec(dllexport) fn_vInitDll(void)
{
new CDynLinkLibrary(extensionDLL);
}
//========================================================================
// DLL entry point
//========================================================================
extern "C" int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
if (!AfxInitExtensionModule(extensionDLL, hInstance))
return 0;
}
return 1;
}
//========================================================================
// Get the DLL
//========================================================================
extern "C"CPA_DLLBase __declspec(dllexport) *fn_p_oGetDLL(long lKey)
{
#ifdef DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
if (gs_p_oActorsDLLInterface == NULL)
{
gs_p_oActorsDLLInterface = new CPA_Actor_Editor_Interface();
ASSERT(gs_p_oActorsDLLInterface != NULL);
}
g_pclInterface = gs_p_oActorsDLLInterface;
return gs_p_oActorsDLLInterface;
break;
default:
return NULL;
}
#else //DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
g_pclInterface = new CPA_Actor_Editor_Interface();
return g_pclInterface;
break;
default:
return NULL;
}
#endif //DLL_ONLY_ONE_INSTANCE
}
//------------------------------------------------------------------------
// functions that are present in this type of DLL only :
//------------------------------------------------------------------------
#undef DLL_ONLY_ONE_INSTANCE