sourcemm/util.h
author Scott Ehlert <ds@alliedmods.net>
Sun May 22 04:33:58 2005 +0000 (2005-05-22)
changeset 66 ddefc8bfb9fa
parent 33 3c7faa7abf09
child 84 3f77bc9e64d8
permissions -rw-r--r--
Added macro so that ConCommands created with the SDK's CON_COMMAND and CON_COMMAND_F macros can be properly registered and unregisterd
     1 /* ======== SourceMM ========
     2 * Copyright (C) 2004-2005 Metamod:Source Development Team
     3 * No warranties of any kind
     4 *
     5 * License: zlib/libpng
     6 *
     7 * Author(s): David "BAILOPAN" Anderson
     8 * ============================
     9 */
    10 
    11 #ifndef _INCLUDE_UTIL_H
    12 #define _INCLUDE_UTIL_H
    13 
    14 /**
    15  * @brief Utility functons
    16  * @file util.h
    17  */
    18 
    19 const char *UTIL_GetExtension(const char *file);
    20 
    21 #define META_INTERFACE_MACRO(type, final) \
    22 	PluginIter i; \
    23 	void *mret=NULL, *d; \
    24 	META_RES mres, high=MRES_IGNORED; \
    25 	g_SmmAPI.SetLastMetaReturn(MRES_IGNORED); \
    26 	for (i=g_PluginMngr._begin(); i!=g_PluginMngr._end(); i++) \
    27 	{ \
    28 		if ( (*i) && (*i)->fac_list. type ) \
    29 		{ \
    30 			d = ((*i)->fac_list. type)(name, ret); \
    31 			mres = g_SmmAPI.GetLastMetaReturn(); \
    32 			if (mres > high) \
    33 				high = mres; \
    34 			if (mres >= MRES_OVERRIDE) \
    35 				mret = d; \
    36 		} \
    37 	} \
    38 	if (high == MRES_OVERRIDE) \
    39 	{ \
    40 		(final)(name, ret); \
    41 		return mret; \
    42 	} else if (high == MRES_SUPERCEDE) { \
    43 		return mret; \
    44 	} else { \
    45 		return (final)(name, ret); \
    46 	} 
    47 
    48 #endif //_INCLUDE_UTIL_H