- Added IS_QUERYING_CLIENT_cVAR for new client cvar engine API. B-work
authorbailopan
Thu Aug 18 16:47:27 2005 +0000 (2005-08-18)
branchB-work
changeset 143c8bb186f5851
parent 142 90ed94768998
child 144 8f8565e045a0
- Added IS_QUERYING_CLIENT_cVAR for new client cvar engine API.
- Added support for new HLSDK-API functions.
- Fixed source plugin indices referring to an invalid plugin
- Changed cmd_doplug() to make sure a complete string was not mishandled as a number.
- Fixed DLCLOSE() to not accept NULL handles.
- Fixed reloading failed plugins again.
- Bumped API to ifvers 5:12
metamod/api_info.cpp
metamod/api_info.h
metamod/commands_meta.cpp
metamod/dllapi.cpp
metamod/dllapi.h
metamod/engine_api.cpp
metamod/engine_api.h
metamod/meta_api.h
metamod/metamod.cpp
metamod/metamod.h
metamod/mlist.cpp
metamod/mlist.h
metamod/mplugin.cpp
metamod/msvc/metamod.vcproj
metamod/mutil.cpp
metamod/mutil.h
metamod/osdep.cpp
metamod/osdep.h
metamod/plinfo.h
     1.1 --- a/metamod/api_info.cpp	Mon Aug 08 20:18:11 2005 +0000
     1.2 +++ b/metamod/api_info.cpp	Thu Aug 18 16:47:27 2005 +0000
     1.3 @@ -97,6 +97,8 @@
     1.4  	{ mFALSE,  16,	"OnFreeEntPrivateData" },	// pfnOnFreeEntPrivateData
     1.5  	{ mFALSE,  3,	"GameShutdown" },			// pfnGameShutdown
     1.6  	{ mFALSE,  14,	"ShouldCollide" },			// pfnShouldCollide
     1.7 +	// Added 2005/08/11 (no SDK update)
     1.8 +	{ mFALSE,  3,   "CvarValue" },				// pfnCvarValue
     1.9  	{ mFALSE,  0,	NULL },
    1.10  };
    1.11  
    1.12 @@ -259,6 +261,8 @@
    1.13  	{ mFALSE,  30,	"ProcessTutorMessageDecayBuffer" },	// pfnProcessTutorMessageDecayBuffer
    1.14  	{ mFALSE,  30,	"ConstructTutorMessageDecayBuffer" },	// pfnConstructTutorMessageDecayBuffer
    1.15  	{ mFALSE,  9,	"ResetTutorMessageDecayData" },	// pfnResetTutorMessageDecayData
    1.16 +	// Added 2005/08/11 (no SDK update)
    1.17 +	{ mFALSE,  3,   "QueryClientCvarValue" }, //pfnQueryClientCvarValue
    1.18  	// end
    1.19  	{ mFALSE,  0,	NULL },
    1.20  };
     2.1 --- a/metamod/api_info.h	Mon Aug 08 20:18:11 2005 +0000
     2.2 +++ b/metamod/api_info.h	Thu Aug 18 16:47:27 2005 +0000
     2.3 @@ -112,6 +112,8 @@
     2.4  	api_info_t pfnOnFreeEntPrivateData;
     2.5  	api_info_t pfnGameShutdown;
     2.6  	api_info_t pfnShouldCollide;
     2.7 +	// Added 2005/08/11 (no SDK update)
     2.8 +	api_info_t pfnCvarValue;
     2.9  	api_info_t END;
    2.10  } newapi_info_t;
    2.11  
    2.12 @@ -276,6 +278,8 @@
    2.13  	api_info_t pfnProcessTutorMessageDecayBuffer;
    2.14  	api_info_t pfnConstructTutorMessageDecayBuffer;
    2.15  	api_info_t pfnResetTutorMessageDecayData;
    2.16 +	// Added 2005/08/11 (no SDK update)
    2.17 +	api_info_t pfnQueryClientCvarValue;
    2.18  	// end
    2.19  	api_info_t END;
    2.20  } engine_info_t;
     3.1 --- a/metamod/commands_meta.cpp	Mon Aug 08 20:18:11 2005 +0000
     3.2 +++ b/metamod/commands_meta.cpp	Thu Aug 18 16:47:27 2005 +0000
     3.3 @@ -35,6 +35,7 @@
     3.4   */
     3.5  
     3.6  #include <ctype.h>		// isdigit()
     3.7 +#include <stdlib.h>		// strtol()
     3.8  
     3.9  #include <extdll.h>		// always
    3.10  
    3.11 @@ -344,11 +345,16 @@
    3.12  	}
    3.13  	// i=2 to skip first arg, as that's the "cmd"
    3.14  	for(i=2; i < argc; i++) {
    3.15 +		int pindex;
    3.16 +		char *endptr;
    3.17  		arg=CMD_ARGV(i);
    3.18  
    3.19  		// try to match plugin id first
    3.20  		if(isdigit(arg[0]))
    3.21  			findp=Plugins->find(atoi(arg));
    3.22 +		pindex = strtol(arg, &endptr, 10);
    3.23 +		if (*arg != '\0' && *endptr == '\0')
    3.24 +			findp=Plugins->find(pindex);
    3.25  		// else try to match some string (prefix)
    3.26  		else
    3.27  			findp=Plugins->find_match(arg);
     4.1 --- a/metamod/dllapi.cpp	Mon Aug 08 20:18:11 2005 +0000
     4.2 +++ b/metamod/dllapi.cpp	Thu Aug 18 16:47:27 2005 +0000
     4.3 @@ -143,10 +143,12 @@
     4.4  
     4.5  // From SDK dlls/client.cpp:
     4.6  BOOL mm_ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) {
     4.7 +	SetPlayerQuerying(pEntity, mFALSE);
     4.8  	META_DLLAPI_HANDLE(BOOL, TRUE, FN_CLIENTCONNECT, pfnClientConnect, (pEntity, pszName, pszAddress, szRejectReason));
     4.9  	RETURN_API();
    4.10  }
    4.11  void mm_ClientDisconnect(edict_t *pEntity) {
    4.12 +	SetPlayerQuerying(pEntity, mFALSE);
    4.13  	META_DLLAPI_HANDLE_void(FN_CLIENTDISCONNECT, pfnClientDisconnect, (pEntity));
    4.14  	RETURN_API_void();
    4.15  }
    4.16 @@ -191,6 +193,7 @@
    4.17  	Plugins->refresh(PT_CHANGELEVEL);
    4.18  	Plugins->unpause_all();
    4.19  	// Plugins->retry_all(PT_CHANGELEVEL);
    4.20 +	ClearAllPlayers();
    4.21  	RETURN_API_void();
    4.22  }
    4.23  void mm_PlayerPreThink(edict_t *pEntity) {
    4.24 @@ -321,7 +324,12 @@
    4.25  	META_NEWAPI_HANDLE(int, 1, FN_SHOULDCOLLIDE, pfnShouldCollide, (pentTouched, pentOther));
    4.26  	RETURN_API();
    4.27  }
    4.28 -
    4.29 +// Added 2005/08/11 (no SDK update)
    4.30 +void mm_CvarValue(const edict_t *pEdict, const char *value) {
    4.31 +	SetPlayerQuerying(const_cast<edict_t *>(pEdict), mFALSE, NULL);
    4.32 +	META_NEWAPI_HANDLE_void(FN_CVARVALUE, pfnCvarValue, (pEdict, value));
    4.33 +	RETURN_API_void();
    4.34 +}
    4.35  
    4.36  // From SDK dlls/cbase.cpp:
    4.37  // "(wd)" indicates my comments on the functions
    4.38 @@ -454,6 +462,8 @@
    4.39  	mm_OnFreeEntPrivateData,		//! pfnOnFreeEntPrivateData()	Called right before the object's memory is freed.  Calls its destructor.
    4.40  	mm_GameShutdown,				//! pfnGameShutdown()
    4.41  	mm_ShouldCollide,				//! pfnShouldCollide()
    4.42 +	// Added 2005/08/11 (no SDK update)
    4.43 +	mm_CvarValue,					//! pfnCvarValue()
    4.44  };
    4.45  
    4.46  C_DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS *pNewFunctionTable, int *interfaceVersion) 
    4.47 @@ -475,6 +485,11 @@
    4.48  		*interfaceVersion = NEW_DLL_FUNCTIONS_VERSION;
    4.49  		return(FALSE);
    4.50  	}
    4.51 -	memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS));
    4.52 +	
    4.53 +	// Detect old engine
    4.54 +	if (!IS_VALID_PTR((void *)g_engfuncs.pfnQueryClientCvarValue))
    4.55 +		memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS) - sizeof(void *));
    4.56 +	else
    4.57 +        memcpy(pNewFunctionTable, &gNewFunctionTable, sizeof(NEW_DLL_FUNCTIONS));
    4.58  	return(TRUE);
    4.59  }
     5.1 --- a/metamod/dllapi.h	Mon Aug 08 20:18:11 2005 +0000
     5.2 +++ b/metamod/dllapi.h	Thu Aug 18 16:47:27 2005 +0000
     5.3 @@ -119,6 +119,7 @@
     5.4  extern void mm_OnFreeEntPrivateData(edict_t pEnt);
     5.5  extern void mm_GameShutdown(void);
     5.6  extern int mm_ShouldCollide(edict_t *pentTouched, edict_t *pentOther);
     5.7 +extern void mm_CvarValue(const edict_t *pEnt, const char *value);
     5.8  
     5.9  
    5.10  // Typedefs for the above functions:
    5.11 @@ -180,5 +181,7 @@
    5.12  typedef void (*FN_ONFREEENTPRIVATEDATA) (edict_t *pEnt);
    5.13  typedef void (*FN_GAMESHUTDOWN) (void);
    5.14  typedef int (*FN_SHOULDCOLLIDE) (edict_t *pentTouched, edict_t *pentOther);
    5.15 +//Added 2005/08/11 (no SDK update)
    5.16 +typedef void (*FN_CVARVALUE)(const edict_t *pEnt, const char *value);
    5.17  
    5.18  #endif /* DLLAPI_H */
     6.1 --- a/metamod/engine_api.cpp	Mon Aug 08 20:18:11 2005 +0000
     6.2 +++ b/metamod/engine_api.cpp	Thu Aug 18 16:47:27 2005 +0000
     6.3 @@ -863,6 +863,19 @@
     6.4  	RETURN_API_void()
     6.5  }
     6.6  
     6.7 +//Added 2005/08/11 (no SDK update)
     6.8 +void mm_QueryClientCvarValue(const edict_t *pEdict, const char *cvarName)
     6.9 +{
    6.10 +	//Engine version didn't change when this API was added.  Check if pointer is valid.
    6.11 +	if (g_engfuncs.pfnQueryClientCvarValue && 
    6.12 +		!IS_VALID_PTR((void *)g_engfuncs.pfnQueryClientCvarValue))
    6.13 +		g_engfuncs.pfnQueryClientCvarValue = 0;
    6.14 +
    6.15 +	SetPlayerQuerying(const_cast<edict_t *>(pEdict), mTRUE);
    6.16 +
    6.17 +	META_ENGINE_HANDLE_void(FN_QUERYCLIENTCVARVALUE, pfnQueryClientCvarValue, (pEdict, cvarName));
    6.18 +	RETURN_API_void();
    6.19 +}
    6.20  
    6.21  enginefuncs_t meta_engfuncs = {
    6.22  	mm_PrecacheModel,			// pfnPrecacheModel()
    6.23 @@ -1067,4 +1080,7 @@
    6.24  	mm_ProcessTutorMessageDecayBuffer,	// pfnProcessTutorMessageDecayBuffer()
    6.25  	mm_ConstructTutorMessageDecayBuffer,	// pfnConstructTutorMessageDecayBuffer()
    6.26  	mm_ResetTutorMessageDecayData,		// pfnResetTutorMessageDecayData()
    6.27 +
    6.28 +	//Added 2005/08/11 (no SDK update)
    6.29 +	mm_QueryClientCvarValue,		// pfnQueryClientCvarValue()
    6.30  };
     7.1 --- a/metamod/engine_api.h	Mon Aug 08 20:18:11 2005 +0000
     7.2 +++ b/metamod/engine_api.h	Thu Aug 18 16:47:27 2005 +0000
     7.3 @@ -269,6 +269,8 @@
     7.4  extern void mm_ProcessTutorMessageDecayBuffer(int *buffer, int bufferLength);
     7.5  extern void mm_ConstructTutorMessageDecayBuffer(int *buffer, int bufferLength);
     7.6  extern void mm_ResetTutorMessageDecayData(void);
     7.7 +//Added 2005/08/11 (no SDK update)
     7.8 +extern void mm_QueryClientCvarValue(const edict_t *pEdict, const char *cvarName);
     7.9  
    7.10  
    7.11  // Typedefs for the above functions:
    7.12 @@ -445,5 +447,7 @@
    7.13  typedef void (*FN_PROCESSTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength);
    7.14  typedef void (*FN_CONSTRUCTTUTORMESSAGEDECAYBUFFER) (int *buffer, int bufferLength);
    7.15  typedef void (*FN_RESETTUTORMESSAGEDECAYDATA) (void);
    7.16 +//Added 2005/08/11 (no SDK update)
    7.17 +typedef void (*FN_QUERYCLIENTCVARVALUE)(const edict_t *pEdict, const char *cvarName);
    7.18  
    7.19  #endif /* ENGINE_API_H */
     8.1 --- a/metamod/meta_api.h	Mon Aug 08 20:18:11 2005 +0000
     8.2 +++ b/metamod/meta_api.h	Thu Aug 18 16:47:27 2005 +0000
     8.3 @@ -60,7 +60,8 @@
     8.4  // Version 5:9	added GetGameInfo [v1.14]
     8.5  // Version 5:10 added GINFO_REALDLL_FULLPATH for GetGameInfo [v1.17]
     8.6  // Version 5:11 added plugin loading and unloading API [v1.18]
     8.7 -#define META_INTERFACE_VERSION "5:11"
     8.8 +// Version 5:12 added util code for checking player query status [v1.18]
     8.9 +#define META_INTERFACE_VERSION "5:12"
    8.10  
    8.11  #ifdef UNFINISHED
    8.12  // Version 5:99	added event hook utility functions [v.???]
     9.1 --- a/metamod/metamod.cpp	Mon Aug 08 20:18:11 2005 +0000
     9.2 +++ b/metamod/metamod.cpp	Thu Aug 18 16:47:27 2005 +0000
     9.3 @@ -81,6 +81,8 @@
     9.4  MRegCvarList *RegCvars;
     9.5  MRegMsgList *RegMsgs;
     9.6  
     9.7 +mplayer g_Players[MAX_PLAYERS + 1] = {mFALSE, NULL};
     9.8 +
     9.9  unsigned int CALL_API_count = 0;
    9.10  
    9.11  #ifdef UNFINISHED
    10.1 --- a/metamod/metamod.h	Mon Aug 08 20:18:11 2005 +0000
    10.2 +++ b/metamod/metamod.h	Thu Aug 18 16:47:27 2005 +0000
    10.3 @@ -43,6 +43,7 @@
    10.4  #include "conf_meta.h"			// MConfig
    10.5  #include "osdep.h"				// NAME_MAX, etc
    10.6  #include "types_meta.h"			// mBOOL
    10.7 +#include "mplayer.h"			// mplayer
    10.8  
    10.9  // file that lists plugins to load at startup
   10.10  #define PLUGINS_INI			"addons/metamod/plugins.ini"
   10.11 @@ -58,6 +59,8 @@
   10.12  // generic config file
   10.13  #define CONFIG_INI			"addons/metamod/config.ini"
   10.14  
   10.15 +#define	MAX_PLAYERS			32
   10.16 +
   10.17  // cvar to contain version
   10.18  extern cvar_t meta_version;
   10.19  
   10.20 @@ -124,6 +127,11 @@
   10.21  //  it's already being used.
   10.22  extern unsigned int CALL_API_count;
   10.23  
   10.24 +// (patch by BAILOPAN)
   10.25 +// Holds cached player info, right now only things for querying cvars
   10.26 +// Max players is always 32, small enough that we can use a static array
   10.27 +extern mplayer g_Players[MAX_PLAYERS + 1];
   10.28 +
   10.29  void metamod_startup(void);
   10.30  
   10.31  mBOOL meta_init_gamedll(void);
    11.1 --- a/metamod/mlist.cpp	Mon Aug 08 20:18:11 2005 +0000
    11.2 +++ b/metamod/mlist.cpp	Thu Aug 18 16:47:27 2005 +0000
    11.3 @@ -827,4 +827,18 @@
    11.4  	return mFALSE;
    11.5  }
    11.6  
    11.7 +void MPluginList::clear_source_plugin_index(int source_index)
    11.8 +{
    11.9 +	int i;
   11.10  
   11.11 +	if (source_index <= 0)
   11.12 +		return;
   11.13 +
   11.14 +	for (i=0; i<endlist; i++)
   11.15 +	{
   11.16 +		if (plist[i].status < PL_VALID)
   11.17 +			continue;
   11.18 +		if (plist[i].source_plugin_index == source_index)
   11.19 +			plist[i].source_plugin_index = -1;
   11.20 +	}
   11.21 +}
    12.1 --- a/metamod/mlist.h	Mon Aug 08 20:18:11 2005 +0000
    12.2 +++ b/metamod/mlist.h	Thu Aug 18 16:47:27 2005 +0000
    12.3 @@ -84,6 +84,7 @@
    12.4  		void retry_all(PLUG_LOADTIME now);	// retry any pending plugin actions
    12.5  		void show(int source_index);		// list plugins to console
    12.6  		void show_client(edict_t *pEntity);	// list plugins to player client
    12.7 +		void clear_source_plugin_index(int source_index);
    12.8  };
    12.9  
   12.10  #endif /* MLIST_H */
    13.1 --- a/metamod/mplugin.cpp	Mon Aug 08 20:18:11 2005 +0000
    13.2 +++ b/metamod/mplugin.cpp	Thu Aug 18 16:47:27 2005 +0000
    13.3 @@ -941,17 +941,19 @@
    13.4  		RETURN_ERRNO(mFALSE, ME_ARGUMENT);
    13.5  	}
    13.6  	if(status < PL_RUNNING) {
    13.7 -		META_ERROR("dll: Not unloading plugin '%s'; already unloaded (status=%s)", desc, str_status());
    13.8 -		RETURN_ERRNO(mFALSE, ME_ALREADY);
    13.9 +		if (reason != PNL_CMD_FORCED && reason != PNL_RELOAD) {
   13.10 +			META_ERROR("dll: Not unloading plugin '%s'; already unloaded (status=%s)", desc, str_status());
   13.11 +			RETURN_ERRNO(mFALSE, ME_ALREADY);
   13.12 +		}
   13.13  	}
   13.14  	if(action != PA_UNLOAD && action != PA_RELOAD) {
   13.15 -		META_ERROR("dll: Not unloading plugin '%s'; not marked for unload (action=%s)", desc, str_action());
   13.16 +		META_WARNING("dll: Not unloading plugin '%s'; not marked for unload (action=%s)", desc, str_action());
   13.17  		RETURN_ERRNO(mFALSE, ME_BADREQ);
   13.18  	}
   13.19  
   13.20  	// Are we allowed to detach this plugin at this time?
   13.21  	// If forcing unload, we disregard when plugin wants to be unloaded.
   13.22 -	if(info->unloadable < now) {
   13.23 +	if(info && info->unloadable < now) {
   13.24  		if(reason == PNL_CMD_FORCED) {
   13.25  			META_DEBUG(2, ("dll: Forced unload plugin '%s' overriding allowed times: allowed=%s; now=%s", desc, str_unloadable(), str_loadtime(now, SL_SIMPLE)));
   13.26  		}
   13.27 @@ -978,16 +980,20 @@
   13.28  
   13.29  	// detach plugin
   13.30  	if(!detach(now, reason)) {
   13.31 -		if(reason == PNL_CMD_FORCED) {
   13.32 +		if (reason == PNL_CMD_FORCED){
   13.33 +			META_DEBUG(2, ("dll: Reload plugin '%s' overriding failed detach", desc));
   13.34 +		} else if(reason == PNL_CMD_FORCED) {
   13.35  			META_DEBUG(2, ("dll: Forced unload plugin '%s' overriding failed detach"));
   13.36  		}
   13.37  		else {
   13.38 -			META_ERROR("dll: Failed to detach plugin '%s'; ", desc);
   13.39 +			META_WARNING("dll: Failed to detach plugin '%s'; ", desc);
   13.40  			// meta_errno should be already set in detach()
   13.41  			return(mFALSE);
   13.42  		}
   13.43  	}
   13.44  
   13.45 +	Plugins->clear_source_plugin_index(index);
   13.46 +
   13.47  	// successful detach, or forced unload
   13.48  
   13.49  	// Unmark registered commands for this plugin (by index number).
   13.50 @@ -1003,9 +1009,9 @@
   13.51  	// Close the file.  Note: after this, attempts to reference any memory
   13.52  	// locations in the file will produce a segfault.
   13.53  	if(DLCLOSE(handle) != 0) {
   13.54 -		META_ERROR("dll: Couldn't close plugin file '%s': %s", file, DLERROR());
   13.55 -		status=PL_FAILED;
   13.56 -		RETURN_ERRNO(mFALSE, ME_DLERROR);
   13.57 +		// If DLL cannot be closed, OS is badly broken or we are giving invalid handle.
   13.58 +		// So we don't return here but instead remove plugin from our listings.
   13.59 +		META_WARNING("dll: Couldn't close plugin file '%s': %s", file, DLERROR());
   13.60  	}
   13.61  	handle=NULL;
   13.62  
   13.63 @@ -1074,13 +1080,18 @@
   13.64  		}
   13.65  	}
   13.66  
   13.67 -	if(status>=PL_RUNNING && !unload(now, reason, reason)) {
   13.68 -		META_ERROR("dll: Failed to unload plugin '%s' for reloading", desc);
   13.69 +	if (status < PL_RUNNING)
   13.70 +	{
   13.71 +		META_WARNING("dll: Plugin '%s' isn't running; Forcing unload plugin for reloading", desc);
   13.72 +		reason = PNL_RELOAD;
   13.73 +	}
   13.74 +	if (!unload(now, reason, reason)) {
   13.75 +		META_WARNING("dll: Failed to unload plugin '%s' for reloading", desc);
   13.76  		// meta_errno should be set already in unload()
   13.77  		return(mFALSE);
   13.78  	}
   13.79  	if(!load(now)) {
   13.80 -		META_ERROR("dll: Failed to reload plugin '%s' after unloading", desc);
   13.81 +		META_WARNING("dll: Failed to reload plugin '%s' after unloading", desc);
   13.82  		// meta_errno should be set already in load()
   13.83  		return(mFALSE);
   13.84  	}
   13.85 @@ -1431,6 +1442,8 @@
   13.86  		case PNL_PLG_FORCED:
   13.87  			STRNCPY(buf, str_reason(PNL_NULL, preason), sizeof(buf));
   13.88  			return(UTIL_VarArgs("%s (forced request from plugin[%d])", buf, unloader_index));
   13.89 +		case PNL_RELOAD:
   13.90 +			return("server command, reload");
   13.91  		default:
   13.92  			return(UTIL_VarArgs("unknown (%d)", preal_reason));
   13.93  	}
    14.1 --- a/metamod/msvc/metamod.vcproj	Mon Aug 08 20:18:11 2005 +0000
    14.2 +++ b/metamod/msvc/metamod.vcproj	Thu Aug 18 16:47:27 2005 +0000
    14.3 @@ -416,6 +416,9 @@
    14.4  				</FileConfiguration>
    14.5  			</File>
    14.6  			<File
    14.7 +				RelativePath="..\mplayer.cpp">
    14.8 +			</File>
    14.9 +			<File
   14.10  				RelativePath="..\mplugin.cpp">
   14.11  				<FileConfiguration
   14.12  					Name="Debug|Win32">
   14.13 @@ -671,6 +674,9 @@
   14.14  				RelativePath="..\mlist.h">
   14.15  			</File>
   14.16  			<File
   14.17 +				RelativePath="..\mplayer.h">
   14.18 +			</File>
   14.19 +			<File
   14.20  				RelativePath="..\mplugin.h">
   14.21  			</File>
   14.22  			<File
    15.1 --- a/metamod/mutil.cpp	Mon Aug 08 20:18:11 2005 +0000
    15.2 +++ b/metamod/mutil.cpp	Thu Aug 18 16:47:27 2005 +0000
    15.3 @@ -358,6 +358,19 @@
    15.4  	return (int)meta_errno;
    15.5  }
    15.6  
    15.7 +const char *mutil_IsQueryingClientCvar(plid_t plid, const edict_t *pEdict)
    15.8 +{
    15.9 +	int index = ENTINDEX(const_cast<edict_t *>(pEdict));
   15.10 +
   15.11 +	if (index < 1 || index > gpGlobals->maxClients)
   15.12 +	{
   15.13 +		return NULL;
   15.14 +		RETURN_ERRNO(NULL, ME_NOTFOUND);
   15.15 +	}
   15.16 +
   15.17 +	return g_Players[index].cvarName;
   15.18 +}
   15.19 +
   15.20  #ifdef UNFINISHED
   15.21  int mutil_HookGameEvent(plid_t plid, game_event_t event, 
   15.22  		event_func_t pfnHandle) 
   15.23 @@ -412,6 +425,7 @@
   15.24  	mutil_LoadMetaPlugin,	// pfnLoadPlugin
   15.25  	mutil_UnloadMetaPlugin, // pfnUnloadPlugin
   15.26  	mutil_UnloadMetaPluginByHandle, //pfnUnloadPluginByHandle
   15.27 +	mutil_IsQueryingClientCvar, //pfnIsQueryingClientCvar
   15.28  #ifdef UNFINISHED
   15.29  	mutil_HookGameEvent,	// pfnGameEvent
   15.30  	mutil_HookLogTrigger,	// pfnLogTrigger
    16.1 --- a/metamod/mutil.h	Mon Aug 08 20:18:11 2005 +0000
    16.2 +++ b/metamod/mutil.h	Thu Aug 18 16:47:27 2005 +0000
    16.3 @@ -74,6 +74,7 @@
    16.4  	int 		(*pfnLoadPlugin)		(plid_t plid, const char *cmdline, PLUG_LOADTIME now, void **plugin_handle);
    16.5  	int			(*pfnUnloadPlugin)		(plid_t plid, const char *cmdline, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
    16.6  	int			(*pfnUnloadPluginByHandle) (plid_t plid, void *plugin_handle, PLUG_LOADTIME now, PL_UNLOAD_REASON reason);
    16.7 +	const char *(*pfnIsQueryingClientCvar) (plid_t plid, const edict_t *pEdict);
    16.8  #ifdef UNFINISHED
    16.9  	int			(*pfnHookGameEvent)		(plid_t plid, game_event_t event, 
   16.10  											event_func_t pfnHandle);
   16.11 @@ -107,6 +108,7 @@
   16.12  const char *mutil_GetUserMsgName(plid_t plid, int msgid, int *size);
   16.13  const char *mutil_GetPluginPath(plid_t plid);
   16.14  const char *mutil_GetGameInfo(plid_t plid, ginfo_t tag);
   16.15 +const char *mutil_IsQueryingClientCvar(plid_t plid, const edict_t *pEdict);
   16.16  
   16.17  #ifdef UNFINISHED
   16.18  int mutil_HookGameEvent(plid_t plid, game_event_t event, 
   16.19 @@ -138,6 +140,7 @@
   16.20  #define LOAD_PLUGIN			(*gpMetaUtilFuncs->pfnLoadPlugin)
   16.21  #define UNLOAD_PLUGIN		(*gpMetaUtilFuncs->pfnUnloadPlugin)
   16.22  #define UNLOAD_PLUGIN_BY_HANDLE (*gpMetaUtilFuncs->pfnUnloadPluginByHandle)
   16.23 +#define IS_QUERYING_CLIENT_CVAR (*gpMetaUtilFuncs->pfnIsQueryingClientCvar)
   16.24  
   16.25  #ifdef UNFINISHED
   16.26  #define HOOK_GAME_EVENT		(*gpMetaUtilFuncs->pfnHookGameEvent)
    17.1 --- a/metamod/osdep.cpp	Mon Aug 08 20:18:11 2005 +0000
    17.2 +++ b/metamod/osdep.cpp	Thu Aug 18 16:47:27 2005 +0000
    17.3 @@ -61,6 +61,8 @@
    17.4  #include "types_meta.h"		// mBOOL
    17.5  #include "support_meta.h"	// MAX_STRBUF_LEN
    17.6  
    17.7 +mBOOL dlclose_handle_invalid;
    17.8 +
    17.9  // To keep the rest of the sources clean and keep not only OS but also
   17.10  // compiler dependant differences in this file, we define a local function
   17.11  // to set the new handler.
   17.12 @@ -73,9 +75,6 @@
   17.13  #endif
   17.14  }
   17.15  
   17.16 -
   17.17 -
   17.18 -
   17.19  #ifdef _WIN32
   17.20  // Since windows doesn't provide a verison of strtok_r(), we include one
   17.21  // here.  This may or may not operate exactly like strtok_r(), but does
    18.1 --- a/metamod/osdep.h	Mon Aug 08 20:18:11 2005 +0000
    18.2 +++ b/metamod/osdep.h	Thu Aug 18 16:47:27 2005 +0000
    18.3 @@ -47,6 +47,8 @@
    18.4  #include "mreg.h"			// REG_CMD_FN, etc
    18.5  #include "log_meta.h"		// LOG_ERROR, etc
    18.6  
    18.7 +extern mBOOL dlclose_handle_invalid;
    18.8 +
    18.9  // String describing platform/DLL-type, for matching lines in plugins.ini.
   18.10  #ifdef linux
   18.11  	#define PLATFORM		"linux"
   18.12 @@ -127,9 +129,16 @@
   18.13  		return(dlsym(handle, string));
   18.14  	}
   18.15  	inline int DLCLOSE(DLHANDLE handle) {
   18.16 +		if (!handle) {
   18.17 +			dlclose_handle_invalid = mTRUE;
   18.18 +			return(1);
   18.19 +		}
   18.20 +		dlclose_handle_invalid = mFALSE;
   18.21  		return(dlclose(handle));
   18.22  	}
   18.23  	inline char* DLERROR(void) {
   18.24 +		if (dlclose_handle_invalid)
   18.25 +			return("Invalid handle.");
   18.26  		return(dlerror());
   18.27  	}
   18.28  #elif defined(_WIN32)
   18.29 @@ -142,6 +151,11 @@
   18.30  		return(GetProcAddress(handle, string));
   18.31  	}
   18.32  	inline int DLCLOSE(DLHANDLE handle) {
   18.33 +		if (!handle) {
   18.34 +			dlclose_handle_invalid = mTRUE;
   18.35 +			return(1);
   18.36 +		}
   18.37 +		dlclose_handle_invalid = mFALSE;
   18.38  		// NOTE: Windows FreeLibrary returns success=nonzero, fail=zero,
   18.39  		// which is the opposite of the unix convention, thus the '!'.
   18.40  		return(!FreeLibrary(handle));
   18.41 @@ -150,6 +164,8 @@
   18.42  	// we make our own.
   18.43  	char *str_GetLastError(void);
   18.44  	inline char* DLERROR(void) {
   18.45 +		if (dlclose_handle_invalid)
   18.46 +			return("Invalid handle.");
   18.47  		return(str_GetLastError());
   18.48  	}
   18.49  #endif /* _WIN32 */
    19.1 --- a/metamod/plinfo.h	Mon Aug 08 20:18:11 2005 +0000
    19.2 +++ b/metamod/plinfo.h	Thu Aug 18 16:47:27 2005 +0000
    19.3 @@ -58,6 +58,7 @@
    19.4  //only used for 'real_reason' on MPlugin::unload()
    19.5  	PNL_PLUGIN,				// requested by plugin function call
    19.6  	PNL_PLG_FORCED,			// forced by plugin function call
    19.7 +	PNL_RELOAD,				// forced unload by reload()
    19.8  } PL_UNLOAD_REASON;
    19.9  
   19.10  // Information plugin provides about itself.