1.1 --- a/sourcemm/ISmmPlugin.h Mon Aug 14 20:14:02 2006 +0000
1.2 +++ b/sourcemm/ISmmPlugin.h Tue Aug 15 20:10:12 2006 +0000
1.3 @@ -248,4 +248,43 @@
1.4 #endif
1.5 #endif //!defined SMM_API
1.6
1.7 +/**
1.8 + * @brief Macro for automatically getting a current or newer Valve interface.
1.9 + *
1.10 + * @param v_factory Factory method to use from ISmmAPI (such as engineFactory).
1.11 + * @param v_var Variable name to store into.
1.12 + * @param v_type Interface type (do not include the pointer/asterisk).
1.13 + * @param v_name Inteface name.
1.14 + */
1.15 +#define GET_V_IFACE_CURRENT(v_factory, v_var, v_type, v_name) \
1.16 + v_var = (v_type *)ismm->VInterfaceMatch(ismm->v_factory(), v_name); \
1.17 + if (!v_var) \
1.18 + { \
1.19 + if (error && maxlen) \
1.20 + { \
1.21 + snprintf(error, maxlen, "Could not find interface: %s", v_name); \
1.22 + } \
1.23 + return false; \
1.24 + }
1.25 +
1.26 + /**
1.27 + * @brief Same as GET_V_IFACE, except searches for any.
1.28 + *
1.29 + * @param v_factory Factory method to use from ISmmAPI (such as engineFactory).
1.30 + * @param v_var Variable name to store into.
1.31 + * @param v_type Interface type (do not include the pointer/asterisk).
1.32 + * @param v_name Inteface name.
1.33 + */
1.34 +#define GET_V_IFACE_ANY(v_factory, v_var, v_type, v_name) \
1.35 + v_var = (v_type *)ismm->VInterfaceMatch(ismm->v_factory(), v_name, 0); \
1.36 + if (!v_var) \
1.37 + { \
1.38 + if (error && maxlen) \
1.39 + { \
1.40 + snprintf(error, maxlen, "Could not find interface: %s", v_name); \
1.41 + } \
1.42 + return false; \
1.43 + }
1.44 +
1.45 +
1.46 #endif //_INCLUDE_ISMM_PLUGIN_H