1.1 --- a/sourcemm/stub_mm/stub_mm.cpp Mon Aug 14 05:45:07 2006 +0000
1.2 +++ b/sourcemm/stub_mm/stub_mm.cpp Mon Aug 14 05:49:53 2006 +0000
1.3 @@ -1,53 +1,42 @@
1.4 /* ======== stub_mm ========
1.5 -* Copyright (C) 2004-2006 Metamod:Source Development Team
1.6 -* No warranties of any kind
1.7 -*
1.8 -* License: zlib/libpng
1.9 -*
1.10 -* Author(s): David "BAILOPAN" Anderson
1.11 -* ============================
1.12 -*/
1.13 + * Copyright (C) 2004-2006 Metamod:Source Development Team
1.14 + * No warranties of any kind
1.15 + *
1.16 + * License: zlib/libpng
1.17 + *
1.18 + * Author(s): David "BAILOPAN" Anderson
1.19 + * ============================
1.20 + */
1.21
1.22 #include <oslink.h>
1.23 #include "stub_mm.h"
1.24
1.25 +SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
1.26 +
1.27 StubPlugin g_StubPlugin;
1.28
1.29 PLUGIN_EXPOSE(SamplePlugin, g_StubPlugin);
1.30
1.31 -//This has all of the necessary hook declarations. Read it!
1.32 -#include "meta_hooks.h"
1.33 -
1.34 -#define FIND_IFACE(func, assn_var, num_var, name, type) \
1.35 - do { \
1.36 - if ( (assn_var=(type)((ismm->func())(name, NULL))) != NULL ) { \
1.37 - num_var = 0; \
1.38 - break; \
1.39 - } \
1.40 - if (num_var >= 999) \
1.41 - break; \
1.42 - } while (( num_var=ismm->FormatIface(name, sizeof(name)-1) )); \
1.43 - if (!assn_var) { \
1.44 - if (error) \
1.45 - snprintf(error, maxlen, "Could not find interface %s", name); \
1.46 - return false; \
1.47 - }
1.48 -
1.49 void ServerActivate_handler(edict_t *pEdictList, int edictCount, int clientMax)
1.50 {
1.51 META_LOG(g_PLAPI, "ServerActivate() called: edictCount=%d, clientMax=%d", edictCount, clientMax);
1.52 RETURN_META(MRES_IGNORED);
1.53 }
1.54
1.55 +#define GET_V_IFACE(v_factory, v_var, v_type, v_name) \
1.56 + v_var = (v_type *)ismm->VInterfaceMatch(ismm->v_factory(), v_name); \
1.57 + if (!v_var) { \
1.58 + if (error && maxlen) { \
1.59 + snprintf(error, maxlen, "Could not find interface: %s", v_name); \
1.60 + } \
1.61 + return false; \
1.62 + }
1.63 +
1.64 bool StubPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
1.65 {
1.66 PLUGIN_SAVEVARS();
1.67
1.68 - char iface_buffer[255];
1.69 - int num = 0;
1.70 -
1.71 - strcpy(iface_buffer, "ServerGameDLL003");
1.72 - FIND_IFACE(serverFactory, m_ServerDll, num, iface_buffer, IServerGameDLL *);
1.73 + GET_V_IFACE(serverFactory, m_ServerDll, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL);
1.74
1.75 SH_ADD_HOOK_STATICFUNC(IServerGameDLL, ServerActivate, m_ServerDll, ServerActivate_handler, true);
1.76