reman3/Rayman_X/cpa/tempgrp/OIT/src/dllcom.cpp

119 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 Instanciated Physical Object DLL Test
*=======================================================================================
*/
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
#include "stdafx.h"
#include "acp_base.h"
#include "afxdllx.h"
#include "ITF.h"
#include "IPO_intf.hpp"
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/*
=======================================================================================
Globals
=======================================================================================
*/
static char *gs_p_szCPAVersion = C_szCPAVersion;
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
static IPOInterface *gs_p_oIPOInterface = NULL;
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;
}
/*
----------------------------------------------------------------------------------------
Description : Get type of this DLL
Returns (tdstDLLIdentity )
----------------------------------------------------------------------------------------
*/
extern "C" tdstDLLIdentity __declspec(dllexport) *fn_p_stGetDLLIdentity(void)
{
g_stIPOIdentity.eType = OBJECT_DLL; //object DLL type
g_stIPOIdentity.csName = C_szDLLInstanciatedPhysicalObjectName; //object DLL name (unique name)
g_stIPOIdentity.hModule = NULL; //********************** private internal
g_stIPOIdentity.p_oListOfInstances = &g_oListOfInstances; //********************** private internal
return &g_stIPOIdentity;
}
/*
----------------------------------------------------------------------------------------
Description : Init DLL function
----------------------------------------------------------------------------------------
*/
extern "C" void WINAPI fn_vInitDll(void)
{
new CDynLinkLibrary(extensionDLL);
}
/*
----------------------------------------------------------------------------------------
Description : DLL main function
hInstance -> DLL instance
dwReason -> reason of DLL loading
lpReserved ->
Returns ( int )
----------------------------------------------------------------------------------------
*/
extern "C" int __stdcall DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
if (!AfxInitExtensionModule(extensionDLL, hInstance))
return 0;
}
return 1;
}
/*
----------------------------------------------------------------------------------------
Description : Get the DLL
lKey -> number of DLL
Returns (CPA_DLLBase )
----------------------------------------------------------------------------------------
*/
extern "C" CPA_DLLBase __declspec(dllexport) *fn_p_oGetDLL(long lKey)
{
switch(lKey)
{
case 0: // the game world
if (gs_p_oIPOInterface == NULL)
{
gs_p_oIPOInterface = new IPOInterface();
ASSERT(gs_p_oIPOInterface != NULL);
}
return gs_p_oIPOInterface;
break;
default:
return NULL;
}
}