reman3/Rayman_X/cpa/tempgrp/TPG/Src/_DLLcom.cpp

128 lines
3.4 KiB
C++

//
// Common functions for Object DLL capabilities
// C. Beaudet
//
// Modified by David Reizer
//
#include "StdAfx.h"
#include "afxdllx.h"
#include "ACP_Base.h"
#include "ITF.h"
#include "MEC.h"
#define D_State_Define
#include "IncGAM.h"
#undef D_State_Define
#include "GLI.h"
#include "_Minterf.hpp"
#include "x:\cpa\main\inc\_EditID.h"
//------------------------------------------------------------------------
// Global vars
static CList<CPA_DLLBase*,CPA_DLLBase*> g_oListOfInstances; //private internal
static char *gs_p_szCPAVersion = C_szCPAVersion;
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
#ifdef DLL_ONLY_ONE_INSTANCE
static CPA_PartGen_Interface *gs_p_oPartGenInterface = NULL;
#endif
//------------------------------------------------------------------------
// 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_stPartGenDLLIdentity.eType = TOOL_DLL;
g_stPartGenDLLIdentity.csName = C_szDLLPartGenName;
g_stPartGenDLLIdentity.hModule = NULL;
g_stPartGenDLLIdentity.p_oListOfInstances = &g_oListOfInstances;
return &g_stPartGenDLLIdentity;
}
//========================================================================
// DLL init 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_oMYTOOLInterface == NULL)
{
gs_p_oPartGenInterface = new CPA_PartGen_Interface();
ERROR_ASSERT(gs_p_oPartGenInterface != NULL);
//*** DR ***//
g_pclInterface = gs_p_oPartGenInterface;
//*** End DR ***//
}
return gs_p_oPartGenInterface;
break;
default:
return NULL;
}
#else //DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
//*** DR ***//
g_pclInterface = new CPA_PartGen_Interface();
return g_pclInterface;
//*** End DR ***//
break;
default:
return NULL;
}
#endif //DLL_ONLY_ONE_INSTANCE
}
//------------------------------------------------------------------------
// functions that are present in this type of DLL only :
//------------------------------------------------------------------------
#undef DLL_ONLY_ONE_INSTANCE