diff --git a/accelerator.games.txt b/accelerator.games.txt index 2361da7..35edc39 100644 --- a/accelerator.games.txt +++ b/accelerator.games.txt @@ -2,6 +2,19 @@ { "#default" { + "Offsets" + { + /* + * This has never changed, let us hope it never does. + */ + "GetCmdLine" + { + "windows" "2" + "linux" "2" + "mac" "2" + } + } + "Signatures" { /* diff --git a/extension/extension.cpp b/extension/extension.cpp index ef09307..6deddd2 100644 --- a/extension/extension.cpp +++ b/extension/extension.cpp @@ -48,6 +48,13 @@ GetSpew_t GetSpew; char spewBuffer[65536]; // Hi. +char crashMap[256]; +char crashGamePath[512]; +char crashCommandLine[1024]; +char crashSourceModPath[512]; +char crashGameDirectory[256]; +char crashExtensionVersion[32]; + char dumpStoragePath[512]; char logPath[512]; @@ -104,6 +111,21 @@ static bool dumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, return succeeded; } + sys_write(extra, "-------- CONFIG BEGIN --------", 30); + sys_write(extra, "\nMap=", 5); + sys_write(extra, crashMap, my_strlen(crashMap)); + sys_write(extra, "\nGamePath=", 10); + sys_write(extra, crashGamePath, my_strlen(crashGamePath)); + sys_write(extra, "\nCommandLine=", 13); + sys_write(extra, crashCommandLine, my_strlen(crashCommandLine)); + sys_write(extra, "\nSourceModPath=", 15); + sys_write(extra, crashSourceModPath, my_strlen(crashSourceModPath)); + sys_write(extra, "\nGameDirectory=", 15); + sys_write(extra, crashGameDirectory, my_strlen(crashGameDirectory)); + sys_write(extra, "\nExtensionVersion=", 18); + sys_write(extra, crashExtensionVersion, my_strlen(crashExtensionVersion)); + sys_write(extra, "\n-------- CONFIG END --------\n", 30); + if (GetSpew) { GetSpew(spewBuffer, sizeof(spewBuffer)); sys_write(extra, "-------- CONSOLE HISTORY BEGIN --------\n", 40); @@ -440,6 +462,10 @@ bool Accelerator::SDK_OnLoad(char *error, size_t maxlength, bool late) delete i; #endif + if (late) { + this->OnCoreMapStart(NULL, 0, 0); + } + return true; } @@ -458,3 +484,50 @@ void Accelerator::SDK_OnUnload() delete handler; } +class VFuncEmptyClass {}; + +const char *GetCmdLine() +{ + static int getCmdLineOffset = 0; + if (getCmdLineOffset == 0) { + if (!gameconfig->GetOffset("GetCmdLine", &getCmdLineOffset)) { + return ""; + } + if (getCmdLineOffset == 0) { + return ""; + } + } + + void *cmdline = gamehelpers->GetValveCommandLine(); + void **vtable = *(void ***)cmdline; + void *vfunc = vtable[getCmdLineOffset]; + + union { + const char *(VFuncEmptyClass::*mfpnew)(); +#ifndef WIN32 + struct { + void *addr; + intptr_t adjustor; + } s; + } u; + u.s.addr = vfunc; + u.s.adjustor = 0; +#else + void *addr; + } u; + u.addr = vfunc; +#endif + + return (const char *)(reinterpret_cast(cmdline)->*u.mfpnew)(); +} + +void Accelerator::OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax) +{ + strncpy(crashMap, gamehelpers->GetCurrentMap(), sizeof(crashMap) - 1); + strncpy(crashGamePath, g_pSM->GetGamePath(), sizeof(crashGamePath) - 1); + strncpy(crashCommandLine, GetCmdLine(), sizeof(crashCommandLine) - 1); + strncpy(crashSourceModPath, g_pSM->GetSourceModPath(), sizeof(crashSourceModPath) - 1); + strncpy(crashGameDirectory, g_pSM->GetGameFolderName(), sizeof(crashGameDirectory) - 1); + strncpy(crashExtensionVersion, SMEXT_CONF_VERSION, sizeof(crashExtensionVersion) - 1); +} + diff --git a/extension/extension.h b/extension/extension.h index 97e989c..1ce9265 100644 --- a/extension/extension.h +++ b/extension/extension.h @@ -96,6 +96,14 @@ public: */ //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen); #endif + /** + * @brief Called on server activation before plugins receive the OnServerLoad forward. + * + * @param pEdictList Edicts list. + * @param edictCount Number of edicts in the list. + * @param clientMax Maximum number of clients allowed in the server. + */ + virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax); }; #endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_ diff --git a/extension/smsdk_config.h b/extension/smsdk_config.h index 09b1faf..bb1ea72 100644 --- a/extension/smsdk_config.h +++ b/extension/smsdk_config.h @@ -64,7 +64,7 @@ //#define SMEXT_ENABLE_DBMANAGER #define SMEXT_ENABLE_GAMECONF //#define SMEXT_ENABLE_MEMUTILS -//#define SMEXT_ENABLE_GAMEHELPERS +#define SMEXT_ENABLE_GAMEHELPERS //#define SMEXT_ENABLE_TIMERSYS #define SMEXT_ENABLE_THREADER #define SMEXT_ENABLE_LIBSYS diff --git a/extension/version.h b/extension/version.h index 0bf6656..4ed8abc 100644 --- a/extension/version.h +++ b/extension/version.h @@ -18,9 +18,9 @@ #define SM_BUILD_TAG "-manual" #define SM_BUILD_UNIQUEID "[MANUAL BUILD]" -#define SM_VERSION "2.2.0" +#define SM_VERSION "2.2.1" #define SM_FULL_VERSION SM_VERSION SM_BUILD_TAG -#define SM_FILE_VERSION 2,2,0,0 +#define SM_FILE_VERSION 2,2,1,0 #endif diff --git a/product.version b/product.version index ccbccc3..c043eea 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -2.2.0 +2.2.1