initial import of 1.2 api changes
authorDavid Anderson <dvander@alliedmods.net>
Fri Dec 23 23:38:38 2005 +0000 (2005-12-23)
changeset 166e85ebcf21a7e
parent 165 76da01197c4c
child 167 6141c63a3ce1
initial import of 1.2 api changes
sourcemm/CPlugin.h
sourcemm/CSmmAPI.cpp
sourcemm/CSmmAPI.h
sourcemm/ISmmAPI.h
sourcemm/ISmmPlugin.h
sourcemm/sourcemm.cpp
sourcemm/sourcemm.h
sourcemm/util.cpp
sourcemm/util.h
     1.1 --- a/sourcemm/CPlugin.h	Fri Dec 23 23:32:21 2005 +0000
     1.2 +++ b/sourcemm/CPlugin.h	Fri Dec 23 23:38:38 2005 +0000
     1.3 @@ -32,9 +32,11 @@
     1.4   *    4: Added AllPluginsLoaded() callback (2005-04-18)
     1.5   *    5: Bumped version for SourceHook V4 (2005-05-01)
     1.6   *    6: Added functions for console printing (2005-05-26)
     1.7 - * MC 7: Changed template libraries (2005-08-11)
     1.8 + * M  7: Changed template libraries (2005-08-11)
     1.9   *		 New loading structure mechanism
    1.10   *	     New SourceHook version
    1.11 + *  C 8: New SourceHook version (2005-12-23)
    1.12 + *       New ISmmAPI additions
    1.13   */
    1.14  
    1.15  #define PLAPI_MIN_VERSION	7
     2.1 --- a/sourcemm/CSmmAPI.cpp	Fri Dec 23 23:32:21 2005 +0000
     2.2 +++ b/sourcemm/CSmmAPI.cpp	Fri Dec 23 23:38:38 2005 +0000
     2.3 @@ -316,3 +316,45 @@
     2.4  	return num;
     2.5  }
     2.6  
     2.7 +void *CSmmAPI::InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret)
     2.8 +{
     2.9 +	size_t len = strlen(iface);
    2.10 +	int num = 0;
    2.11 +	void *pf = NULL;
    2.12 +	char *_if = new char[len + 2];
    2.13 +
    2.14 +	if (max > 999)
    2.15 +		max = 999;
    2.16 +
    2.17 +	strcpy(_if, iface);
    2.18 +
    2.19 +	do
    2.20 +	{
    2.21 +		if ( (pf = (fn)(_if, NULL)) != NULL )
    2.22 +			break;
    2.23 +		if (num > max)
    2.24 +			break;
    2.25 +	} while ( num = FormatIface(_if, len) );
    2.26 +
    2.27 +	return pf;
    2.28 +}
    2.29 +
    2.30 +const char *CSmmAPI::GetBaseDir()
    2.31 +{
    2.32 +	return g_ModPath.c_str();
    2.33 +}
    2.34 +
    2.35 +void CSmmAPI::PathFormat(char *buffer, size_t len, const char *fmt, ...)
    2.36 +{
    2.37 +	va_list ap;
    2.38 +	va_start(ap,fmt);
    2.39 +	size_t mylen = vsnprintf(buffer, len, fmt, ap);
    2.40 +	va_end(ap);
    2.41 +
    2.42 +	for (size_t i=0; i<mylen; i++)
    2.43 +	{
    2.44 +		if (buffer[i] == ALT_SEP_CHAR)
    2.45 +			buffer[i] = PATH_SEP_CHAR;
    2.46 +	}
    2.47 +}
    2.48 +
     3.1 --- a/sourcemm/CSmmAPI.h	Fri Dec 23 23:32:21 2005 +0000
     3.2 +++ b/sourcemm/CSmmAPI.h	Fri Dec 23 23:38:38 2005 +0000
     3.3 @@ -51,6 +51,9 @@
     3.4  		virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener);
     3.5  		virtual void *MetaFactory(const char *iface, int *ret, PluginId *id);
     3.6  		virtual int FormatIface(char buffer[], unsigned int maxlength);
     3.7 +		virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret);
     3.8 +		virtual const char *GetBaseDir();
     3.9 +		virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...);
    3.10  	public:
    3.11  		bool CacheCmds();
    3.12  	private:
     4.1 --- a/sourcemm/ISmmAPI.h	Fri Dec 23 23:32:21 2005 +0000
     4.2 +++ b/sourcemm/ISmmAPI.h	Fri Dec 23 23:38:38 2005 +0000
     4.3 @@ -83,6 +83,21 @@
     4.4  	 * reformats the string to increase the number, then returns the new number.
     4.5  	 */
     4.6  	virtual int FormatIface(char iface[], unsigned int maxlength) =0;
     4.7 +public:		//Added in 1.2 (1:2)
     4.8 +	/**
     4.9 +	 * @brief Searches for an interface for you.
    4.10 +	 */
    4.11 +	virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret) =0;
    4.12 +
    4.13 +	/**
    4.14 +	 * @brief Returns the base directory of the game/server, equivalent to IVEngineServer::GetGameDir
    4.15 +	 */
    4.16 +	virtual const char *GetBaseDir() =0;
    4.17 +
    4.18 +	/**
    4.19 +	 * @brief Formats a file path to the local OS.  Does not include any base directories.
    4.20 +	 */
    4.21 +	virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0;
    4.22  };
    4.23  
    4.24  
     5.1 --- a/sourcemm/ISmmPlugin.h	Fri Dec 23 23:32:21 2005 +0000
     5.2 +++ b/sourcemm/ISmmPlugin.h	Fri Dec 23 23:38:38 2005 +0000
     5.3 @@ -20,7 +20,7 @@
     5.4  #include <sourcehook/sourcehook.h>
     5.5  #include "ISmmAPI.h"
     5.6  
     5.7 -#define PLAPI_VERSION	7
     5.8 +#define PLAPI_VERSION	8
     5.9  #define PLAPI_NAME		"ISmmPlugin"
    5.10  
    5.11  class ISmmAPI;
    5.12 @@ -143,7 +143,7 @@
    5.13  };
    5.14  
    5.15  /**
    5.16 - * @brief Added in 1.2 so plugins could listen to specific events
    5.17 + * @brief Added in 1.1 so plugins could listen to specific events
    5.18   */
    5.19  class IMetamodListener
    5.20  {
     6.1 --- a/sourcemm/sourcemm.cpp	Fri Dec 23 23:32:21 2005 +0000
     6.2 +++ b/sourcemm/sourcemm.cpp	Fri Dec 23 23:38:38 2005 +0000
     6.3 @@ -92,7 +92,7 @@
     6.4  	GetFileOfAddress(g_GameDll.factory, full_path, sizeof(full_path)-1);
     6.5  	g_BinPath.assign(full_path);
     6.6  
     6.7 -	UTIL_PathFmt(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile());
     6.8 +	g_SmmAPI.PathFormat(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile());
     6.9  
    6.10  	//Like metamod, reload plugins at the end of the map.
    6.11  	//This is so plugins can hook everything on load, BUT, new plugins will be reloaded
    6.12 @@ -138,7 +138,7 @@
    6.13  	}
    6.14  
    6.15  	char full_path[260];
    6.16 -	UTIL_PathFmt(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile());
    6.17 +	g_SmmAPI.PathFormat(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile());
    6.18  
    6.19  	LoadPluginsFromFile(full_path);
    6.20  
    6.21 @@ -304,9 +304,9 @@
    6.22  				//no need to append "bin"
    6.23  				if (gamebin)
    6.24  				{
    6.25 -					UTIL_PathFmt(temp_path, sizeof(temp_path)-1, "%s/%s/%s", lptr, ptr, SERVER_DLL);
    6.26 +					g_SmmAPI.PathFormat(temp_path, sizeof(temp_path)-1, "%s/%s/%s", lptr, ptr, SERVER_DLL);
    6.27  				} else {
    6.28 -					UTIL_PathFmt(temp_path, sizeof(temp_path)-1, "%s/%s/%s/%s", lptr, ptr, "bin", SERVER_DLL);
    6.29 +					g_SmmAPI.PathFormat(temp_path, sizeof(temp_path)-1, "%s/%s/%s/%s", lptr, ptr, "bin", SERVER_DLL);
    6.30  				}
    6.31  				if (!UTIL_PathCmp(s_dllpath.c_str(), temp_path))
    6.32  				{
    6.33 @@ -504,7 +504,7 @@
    6.34  				ext = "";
    6.35  			}
    6.36  			//Format the new path
    6.37 -			UTIL_PathFmt(full_path, sizeof(full_path)-1, "%s/%s%s", g_ModPath.c_str(), buffer, ext);
    6.38 +			g_SmmAPI.PathFormat(full_path, sizeof(full_path)-1, "%s/%s%s", g_ModPath.c_str(), buffer, ext);
    6.39  			id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error)-1);
    6.40  			if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused)
    6.41  			{
    6.42 @@ -598,6 +598,10 @@
    6.43  		LogMessage("[META] Warning: Console messages will not be redirected to rcon console.");
    6.44  	}
    6.45  
    6.46 +#if (defined _DEBUG || defined DEBUG) && (defined WIN32 || defined _WIN32)
    6.47 +    SetUnhandledExceptionFilter(NULL);
    6.48 +#endif
    6.49 +
    6.50  	ITER_EVENT(OnLevelInit, (pMapName, pMapEntities, pOldLevel, pLandmarkName, loadGame, background));
    6.51  
    6.52  	RETURN_META_VALUE(MRES_IGNORED, false);
     7.1 --- a/sourcemm/sourcemm.h	Fri Dec 23 23:32:21 2005 +0000
     7.2 +++ b/sourcemm/sourcemm.h	Fri Dec 23 23:38:38 2005 +0000
     7.3 @@ -28,22 +28,17 @@
     7.4  
     7.5  /**
     7.6   * Versioning
     7.7 - *  First grouping is major release version (1)
     7.8 - *  Second grouping is minor release version.
     7.9 - *  Third grouping is release change version.
    7.10 - * For an entire code rehaul, we would change major.
    7.11 - * For a simple bug-fix release, we would change the third grouping.
    7.12 - * For an API change, we would increase the second grouping by one.
    7.13 - * For a breaking API change, we would increase the second group up to the next bracket.
    7.14 - *  (example: 1.45 -> 1.50.  1.12 -> 1.20.  1.19 -> 1.20)
    7.15 - *  minor changes can also roll over, but a big change should ALWAYS roll over.
    7.16 - * Increasing one grouping should make the lesser ones reset back to zero.
    7.17 + *   ?what the hell was I smoking when I wrote this
    7.18 + *   increase api_major when API breaks
    7.19 + *   increase api_minor when new functions are added (non-breaking)
    7.20 + *   increase vers_release when bug fix releases are made
    7.21 + *   never increase major
    7.22   */
    7.23 -#define		SOURCEMM_VERSION	"1.1.2"
    7.24 +#define		SOURCEMM_VERSION	"1.2"
    7.25  #define		SOURCEMM_DATE		__DATE__
    7.26  #define		SM_MAJOR_VERSION	1		//never need to increase this
    7.27  #define		SM_VERS_API_MAJOR	1		//increase this on a breaking change
    7.28 -#define		SM_VERS_API_MINOR	1		//increase this on a non-breaking API change
    7.29 +#define		SM_VERS_API_MINOR	2		//increase this on a non-breaking API change
    7.30  #define		SM_VERS_RELEASE		0		//increase this on a bug-fix release.
    7.31  
    7.32  //We need a good CServerGameDLL version to work properly.  We support these inclusively.
     8.1 --- a/sourcemm/util.cpp	Fri Dec 23 23:32:21 2005 +0000
     8.2 +++ b/sourcemm/util.cpp	Fri Dec 23 23:38:38 2005 +0000
     8.3 @@ -159,23 +159,6 @@
     8.4  	buf2[c] = '\0';
     8.5  }
     8.6  
     8.7 -/** 
     8.8 - * Formats a path name for an OS
     8.9 - */
    8.10 -void UTIL_PathFmt(char *buffer, size_t len, const char *fmt, ...)
    8.11 -{
    8.12 -	va_list ap;
    8.13 -	va_start(ap,fmt);
    8.14 -	size_t mylen = vsnprintf(buffer, len, fmt, ap);
    8.15 -	va_end(ap);
    8.16 -
    8.17 -	for (size_t i=0; i<mylen; i++)
    8.18 -	{
    8.19 -		if (buffer[i] == ALT_SEP_CHAR)
    8.20 -			buffer[i] = PATH_SEP_CHAR;
    8.21 -	}
    8.22 -}
    8.23 -
    8.24  bool UTIL_PathCmp(const char *path1, const char *path2)
    8.25  {
    8.26  	size_t len1=strlen(path1);
     9.1 --- a/sourcemm/util.h	Fri Dec 23 23:32:21 2005 +0000
     9.2 +++ b/sourcemm/util.h	Fri Dec 23 23:38:38 2005 +0000
     9.3 @@ -21,7 +21,6 @@
     9.4  void UTIL_TrimLeft(char *buffer);
     9.5  void UTIL_TrimRight(char *buffer);
     9.6  void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t len2);
     9.7 -void UTIL_PathFmt(char *buffer, size_t len, const char *fmt, ...);
     9.8  bool UTIL_PathCmp(const char *path1, const char *path2);
     9.9  
    9.10  #endif //_INCLUDE_UTIL_H