Skip to content

Commit

Permalink
Deprecate CreateInterface (alliedmodders#2001)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Nov 11, 2023
1 parent 7747beb commit 11c8084
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
33 changes: 13 additions & 20 deletions public/smsdk_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions public/smsdk_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@ class SDKExtension :
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.
*
Expand Down

0 comments on commit 11c8084

Please sign in to comment.