Deprecate CreateInterface (#2001)

* Deprecate CreateInterface

Co-authored-by: KitRifty <[email protected]>

* Expose the 'newer' data

* Update smsdk_ext.cpp

---------

Co-authored-by: Kenzzer <[email protected]>
Co-authored-by: KitRifty <[email protected]>
This commit is contained in:
Benoist
2023-11-11 16:59:22 +00:00
committed by GitHub
co-authored by KitRifty Kenzzer
parent 7747beb4cf
commit 11c8084ccd
2 changed files with 22 additions and 20 deletions
+13 -20
View File
@@ -297,6 +297,12 @@ void SDKExtension::SDK_OnDependenciesDropped()
#if defined SMEXT_CONF_METAMOD
#if defined _MSC_VER
#define SMEXT_DLL_EXPORT extern "C" __declspec(dllexport)
#else
#define SMEXT_DLL_EXPORT extern "C" __attribute__((visibility("default")))
#endif
PluginId g_PLID = 0; /**< Metamod plugin ID */
ISmmPlugin *g_PLAPI = NULL; /**< Metamod plugin API */
SourceHook::ISourceHook *g_SHPtr = NULL; /**< SourceHook pointer */
@@ -308,27 +314,9 @@ IServerGameDLL *gamedll = NULL; /**< IServerGameDLL pointer */
#endif
/** Exposes the extension to Metamod */
SMM_API void *PL_EXPOSURE(const char *name, int *code)
SMEXT_DLL_EXPORT METAMOD_PLUGIN *CreateInterface_MMS(const MetamodVersionInfo *mvi, const MetamodLoaderInfo *mli)
{
#if defined METAMOD_PLAPI_VERSION
if (name && !strcmp(name, METAMOD_PLAPI_NAME))
#else
if (name && !strcmp(name, PLAPI_NAME))
#endif
{
if (code)
{
*code = META_IFACE_OK;
}
return static_cast<void *>(g_pExtensionIface);
}
if (code)
{
*code = META_IFACE_FAILED;
}
return NULL;
return g_pExtensionIface->SDK_OnMetamodCreateInterface(mvi, mli);
}
bool SDKExtension::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
@@ -457,6 +445,11 @@ const char *SDKExtension::GetVersion()
return GetExtensionVerString();
}
METAMOD_PLUGIN *SDKExtension::SDK_OnMetamodCreateInterface(const MetamodVersionInfo *mvi, const MetamodLoaderInfo *mli)
{
return this;
}
bool SDKExtension::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late)
{
return true;
+9
View File
@@ -152,6 +152,15 @@ public:
virtual void SDK_OnDependenciesDropped();
#if defined SMEXT_CONF_METAMOD
/**
* @brief Called when Metamod is requesting the extension (ISmmPlugin) interface.
*
* @param mvi Struct that contains Metamod version, SourceHook version, Plugin version and Source Engine version.
* @param mli Struct that contains the library file name and path being loaded.
* @return The ISmmPlugin interface.
*/
virtual METAMOD_PLUGIN *SDK_OnMetamodCreateInterface(const MetamodVersionInfo *mvi, const MetamodLoaderInfo *mli);
/**
* @brief Called when Metamod is attached, before the extension version is called.
*