diff --git a/sourcemm/CPlugin.h b/sourcemm/CPlugin.h index 00a4fbd..947050a 100644 --- a/sourcemm/CPlugin.h +++ b/sourcemm/CPlugin.h @@ -32,9 +32,11 @@ * 4: Added AllPluginsLoaded() callback (2005-04-18) * 5: Bumped version for SourceHook V4 (2005-05-01) * 6: Added functions for console printing (2005-05-26) - * MC 7: Changed template libraries (2005-08-11) + * M 7: Changed template libraries (2005-08-11) * New loading structure mechanism * New SourceHook version + * C 8: New SourceHook version (2005-12-23) + * New ISmmAPI additions */ #define PLAPI_MIN_VERSION 7 diff --git a/sourcemm/CSmmAPI.cpp b/sourcemm/CSmmAPI.cpp index 913d923..8852dfe 100644 --- a/sourcemm/CSmmAPI.cpp +++ b/sourcemm/CSmmAPI.cpp @@ -316,3 +316,45 @@ int CSmmAPI::FormatIface(char iface[], unsigned int maxlength) return num; } +void *CSmmAPI::InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret) +{ + size_t len = strlen(iface); + int num = 0; + void *pf = NULL; + char *_if = new char[len + 2]; + + if (max > 999) + max = 999; + + strcpy(_if, iface); + + do + { + if ( (pf = (fn)(_if, NULL)) != NULL ) + break; + if (num > max) + break; + } while ( num = FormatIface(_if, len) ); + + return pf; +} + +const char *CSmmAPI::GetBaseDir() +{ + return g_ModPath.c_str(); +} + +void CSmmAPI::PathFormat(char *buffer, size_t len, const char *fmt, ...) +{ + va_list ap; + va_start(ap,fmt); + size_t mylen = vsnprintf(buffer, len, fmt, ap); + va_end(ap); + + for (size_t i=0; i #include "ISmmAPI.h" -#define PLAPI_VERSION 7 +#define PLAPI_VERSION 8 #define PLAPI_NAME "ISmmPlugin" class ISmmAPI; @@ -143,7 +143,7 @@ public: }; /** - * @brief Added in 1.2 so plugins could listen to specific events + * @brief Added in 1.1 so plugins could listen to specific events */ class IMetamodListener { diff --git a/sourcemm/sourcemm.cpp b/sourcemm/sourcemm.cpp index c4ecdf9..93c2408 100644 --- a/sourcemm/sourcemm.cpp +++ b/sourcemm/sourcemm.cpp @@ -92,7 +92,7 @@ void InitMainStates() GetFileOfAddress(g_GameDll.factory, full_path, sizeof(full_path)-1); g_BinPath.assign(full_path); - UTIL_PathFmt(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile()); + g_SmmAPI.PathFormat(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile()); //Like metamod, reload plugins at the end of the map. //This is so plugins can hook everything on load, BUT, new plugins will be reloaded @@ -138,7 +138,7 @@ bool DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, } char full_path[260]; - UTIL_PathFmt(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile()); + g_SmmAPI.PathFormat(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), GetPluginsFile()); LoadPluginsFromFile(full_path); @@ -304,9 +304,9 @@ SMM_API void *CreateInterface(const char *iface, int *ret) //no need to append "bin" if (gamebin) { - UTIL_PathFmt(temp_path, sizeof(temp_path)-1, "%s/%s/%s", lptr, ptr, SERVER_DLL); + g_SmmAPI.PathFormat(temp_path, sizeof(temp_path)-1, "%s/%s/%s", lptr, ptr, SERVER_DLL); } else { - UTIL_PathFmt(temp_path, sizeof(temp_path)-1, "%s/%s/%s/%s", lptr, ptr, "bin", SERVER_DLL); + g_SmmAPI.PathFormat(temp_path, sizeof(temp_path)-1, "%s/%s/%s/%s", lptr, ptr, "bin", SERVER_DLL); } if (!UTIL_PathCmp(s_dllpath.c_str(), temp_path)) { @@ -504,7 +504,7 @@ int LoadPluginsFromFile(const char *file) ext = ""; } //Format the new path - UTIL_PathFmt(full_path, sizeof(full_path)-1, "%s/%s%s", g_ModPath.c_str(), buffer, ext); + g_SmmAPI.PathFormat(full_path, sizeof(full_path)-1, "%s/%s%s", g_ModPath.c_str(), buffer, ext); id = g_PluginMngr.Load(full_path, Pl_File, already, error, sizeof(error)-1); if (id < Pl_MinId || g_PluginMngr.FindById(id)->m_Status < Pl_Paused) { @@ -598,6 +598,10 @@ bool LevelInit_handler(char const *pMapName, char const *pMapEntities, char cons LogMessage("[META] Warning: Console messages will not be redirected to rcon console."); } +#if (defined _DEBUG || defined DEBUG) && (defined WIN32 || defined _WIN32) + SetUnhandledExceptionFilter(NULL); +#endif + ITER_EVENT(OnLevelInit, (pMapName, pMapEntities, pOldLevel, pLandmarkName, loadGame, background)); RETURN_META_VALUE(MRES_IGNORED, false); diff --git a/sourcemm/sourcemm.h b/sourcemm/sourcemm.h index 60f4e74..aa6863c 100644 --- a/sourcemm/sourcemm.h +++ b/sourcemm/sourcemm.h @@ -28,22 +28,17 @@ /** * Versioning - * First grouping is major release version (1) - * Second grouping is minor release version. - * Third grouping is release change version. - * For an entire code rehaul, we would change major. - * For a simple bug-fix release, we would change the third grouping. - * For an API change, we would increase the second grouping by one. - * For a breaking API change, we would increase the second group up to the next bracket. - * (example: 1.45 -> 1.50. 1.12 -> 1.20. 1.19 -> 1.20) - * minor changes can also roll over, but a big change should ALWAYS roll over. - * Increasing one grouping should make the lesser ones reset back to zero. + * ?what the hell was I smoking when I wrote this + * increase api_major when API breaks + * increase api_minor when new functions are added (non-breaking) + * increase vers_release when bug fix releases are made + * never increase major */ -#define SOURCEMM_VERSION "1.1.2" +#define SOURCEMM_VERSION "1.2" #define SOURCEMM_DATE __DATE__ #define SM_MAJOR_VERSION 1 //never need to increase this #define SM_VERS_API_MAJOR 1 //increase this on a breaking change -#define SM_VERS_API_MINOR 1 //increase this on a non-breaking API change +#define SM_VERS_API_MINOR 2 //increase this on a non-breaking API change #define SM_VERS_RELEASE 0 //increase this on a bug-fix release. //We need a good CServerGameDLL version to work properly. We support these inclusively. diff --git a/sourcemm/util.cpp b/sourcemm/util.cpp index e7f32d7..7983b18 100644 --- a/sourcemm/util.cpp +++ b/sourcemm/util.cpp @@ -159,23 +159,6 @@ void UTIL_KeySplit(const char *str, char *buf1, size_t len1, char *buf2, size_t buf2[c] = '\0'; } -/** - * Formats a path name for an OS - */ -void UTIL_PathFmt(char *buffer, size_t len, const char *fmt, ...) -{ - va_list ap; - va_start(ap,fmt); - size_t mylen = vsnprintf(buffer, len, fmt, ap); - va_end(ap); - - for (size_t i=0; i