reman3/Rayman_X/cpa/tempgrp/TIA/Src/dllcom.cpp

127 lines
3.8 KiB
C++

/*
*=======================================================================================
* Name : dllcom.cpp
* Author : C. Beaudet Date :20/05/97
* Description : Common functions for Object DLL capabilities
*=======================================================================================
* Modification -> Author : VL Date : 20/05/97
* Description : Common functions for Object Table Tool DLL
*=======================================================================================
*/
#include "stdafx.h"
#include "acp_base.h"
#include "afxdllx.h"
#include "ITF.h"
#include "ai_intf.hpp"
#include "x:\cpa\main\inc\_EditID.h"
/*
*------------------------------------------------------------------------
* Global vars
*------------------------------------------------------------------------
*/
static char *gs_p_szCPAVersion = C_szCPAVersion;
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
#ifdef DLL_ONLY_ONE_INSTANCE
static CPA_EdIR_Interface *gs_p_oAIInterface = 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_stAIIdentity.eType = TOOL_DLL; //DLL type
g_stAIIdentity.csName = C_szDLLAIEditorName; //DLL name (unique name)
g_stAIIdentity.hModule = NULL; //********************** private internal
g_stAIIdentity.p_oListOfInstances = &g_oListOfInstances; //********************** private internal
return &g_stAIIdentity;
}
//========================================================================
// 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_oAIInterface == NULL)
{
gs_p_oAIInterface = new CPA_EdIR_Interface();
ASSERT(gs_p_oAIInterface != NULL);
}
g_pclAIInterface = gs_p_oAIInterface;
return gs_p_oAIInterface;
break;
default:
return NULL;
}
#else //DLL_ONLY_ONE_INSTANCE
switch(lKey)
{
case 0: // the game world
g_pclAIInterface=new CPA_EdIR_Interface();
return g_pclAIInterface;
break;
default:
return NULL;
}
#endif //DLL_ONLY_ONE_INSTANCE
}
//------------------------------------------------------------------------
// functions that are present in this type of DLL only :
//------------------------------------------------------------------------
#undef DLL_ONLY_ONE_INSTANCE