Skip to content

Commit

Permalink
Fix linking errors with some compilers when MM:S plugins call functio…
Browse files Browse the repository at this point in the history
…n in tier1 interface.h. (#34)
  • Loading branch information
psychonic committed Sep 7, 2017
1 parent 6f2938b commit e770220
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions core/ISmmPlugin.h
Expand Up @@ -39,6 +39,10 @@
#include <ISmmAPI.h>
#include <ISmmPluginExt.h>

#ifndef META_NO_HL2SDK
#include <tier1/interface.h>
#endif

class IServerPluginCallbacks;

// Interface return status, binary-compatible with HL2SDK's IFACE_OK and IFACE_FAILED.
Expand Down Expand Up @@ -439,18 +443,30 @@ using namespace SourceMM;
* you should not pass a pointer to your plugin's
* singleton.
*/
#define PLUGIN_EXPOSE(name, var) \
ISmmAPI *g_SMAPI = NULL; \
ISmmPlugin *g_PLAPI = NULL; \
PluginId g_PLID = (PluginId)0; \
SourceHook::ISourceHook *g_SHPtr = NULL; \
#ifdef META_NO_HL2SDK
#define PL_EXPOSURE_FUNC(name, var) \
SMM_API void *PL_EXPOSURE(const char *name, int *code) { \
if (name && !strcmp(name, METAMOD_PLAPI_NAME)) { \
return static_cast<void *>(&var); \
} \
return NULL; \
}

#else
// First param should be actual classname, not iface name, but we don't have that and it doesn't matter here.
#define PL_EXPOSURE_FUNC(name, var) EXPOSE_SINGLE_INTERFACE_GLOBALVAR(ISmmPlugin, ISmmPlugin, METAMOD_PLAPI_NAME, var);
#endif

#define PLUGIN_EXPOSE(name, var) \
ISmmAPI *g_SMAPI = NULL; \
ISmmPlugin *g_PLAPI = NULL; \
PluginId g_PLID = (PluginId)0; \
SourceHook::ISourceHook *g_SHPtr = NULL; \
PL_EXPOSURE_FUNC(name, var)





/**
* @brief This should be in one of your header files, if you wish
Expand Down

0 comments on commit e770220

Please sign in to comment.