|
@@ -7,13 +7,14 @@
|
|
|
#include <sourcemod>
|
|
|
|
|
|
#tryinclude <steamtools>
|
|
|
+#include <sdktools>
|
|
|
|
|
|
#pragma newdecls required
|
|
|
#include <stocksoup/log_server>
|
|
|
#include <stocksoup/files>
|
|
|
#include <stocksoup/version>
|
|
|
|
|
|
-#define PLUGIN_VERSION "1.4.0"
|
|
|
+#define PLUGIN_VERSION "1.5.0"
|
|
|
public Plugin myinfo = {
|
|
|
name = "[CSRD] SRCDS Automatic Data Dumper",
|
|
|
author = "nosoop",
|
|
@@ -43,9 +44,11 @@ enum DumpAction {
|
|
|
DumpAction g_DumpAction;
|
|
|
StringMap g_ConCommandFlagCache;
|
|
|
|
|
|
+Handle g_SDKCallGetTFConditionName, g_SDKCallGetTFConditionNamePtr;
|
|
|
+
|
|
|
public APLRes AskPluginLoad2(Handle hPluginSelf, bool bLateLoaded, char[] error, int err_max) {
|
|
|
if (bLateLoaded) {
|
|
|
- // skip dump on late load because muh consistency
|
|
|
+ // skip dump on late load because it's too late to cache flags for consistency
|
|
|
g_DumpAction = DumpAction_None;
|
|
|
} else {
|
|
|
g_DumpAction = DumpAction_UpdateCheck;
|
|
@@ -74,6 +77,27 @@ public APLRes AskPluginLoad2(Handle hPluginSelf, bool bLateLoaded, char[] error,
|
|
|
}
|
|
|
|
|
|
public void OnPluginStart() {
|
|
|
+ Handle hGameConf = LoadGameConfigFile("csrd.data_dump");
|
|
|
+ if (!hGameConf) {
|
|
|
+ SetFailState("Failed to load gamedata (csrd.data_dump).");
|
|
|
+ }
|
|
|
+
|
|
|
+ // we call and fetch the pointer to work around alliedmodders/sourcemod#874
|
|
|
+ // we could read the pointer directly, but ain't got time for that
|
|
|
+ StartPrepSDKCall(SDKCall_Static);
|
|
|
+ PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "GetTFConditionName()");
|
|
|
+ PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
|
|
+ PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
|
|
+ g_SDKCallGetTFConditionNamePtr = EndPrepSDKCall();
|
|
|
+
|
|
|
+ StartPrepSDKCall(SDKCall_Static);
|
|
|
+ PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "GetTFConditionName()");
|
|
|
+ PrepSDKCall_SetReturnInfo(SDKType_String, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL);
|
|
|
+ PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
|
|
+ g_SDKCallGetTFConditionName = EndPrepSDKCall();
|
|
|
+
|
|
|
+ delete hGameConf;
|
|
|
+
|
|
|
RegAdminCmd("csrd_force_data_dump", ForceDataDump, ADMFLAG_ROOT);
|
|
|
}
|
|
|
|
|
@@ -150,6 +174,7 @@ void PerformDataDump(RequestFrameCallback postDumpCallback = INVALID_FUNCTION, a
|
|
|
DumpServerCommands("%s/%d.commands.txt", outputDirectory, version);
|
|
|
DumpServerConVars("%s/%d.convars.txt", outputDirectory, version);
|
|
|
DumpUserMessageNames("%s/%d.usermessages.txt", outputDirectory, version);
|
|
|
+ DumpTFCondNames("%s/%d.tf_conds.txt", outputDirectory, version);
|
|
|
|
|
|
/**
|
|
|
* Spawns all entities, server will crash on map change -- make sure there are 700-ish
|
|
@@ -320,6 +345,24 @@ void DumpUserMessageNames(const char[] format, any ...) {
|
|
|
delete outputFile;
|
|
|
}
|
|
|
|
|
|
+void DumpTFCondNames(const char[] format, any ...) {
|
|
|
+ char outputPath[PLATFORM_MAX_PATH];
|
|
|
+ VFormat(outputPath, sizeof(outputPath), format, 2);
|
|
|
+
|
|
|
+ File outputFile = OpenFile(outputPath, "w");
|
|
|
+ outputFile.WriteLine("\"%s\",\"%s\"", "Condition Index", "Name");
|
|
|
+
|
|
|
+ char condName[64];
|
|
|
+ int cond;
|
|
|
+ while (SDKCall(g_SDKCallGetTFConditionNamePtr, cond)
|
|
|
+ && SDKCall(g_SDKCallGetTFConditionName, condName, sizeof(condName), cond)) {
|
|
|
+ outputFile.WriteLine("\"%d\",\"%s\"", cond, condName);
|
|
|
+ cond++;
|
|
|
+ }
|
|
|
+
|
|
|
+ delete outputFile;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Converts bitflags from a ConCommandBase to a space-separated list of flag descriptions.
|
|
|
*/
|