|
@@ -13,7 +13,7 @@
|
|
|
#include <stocksoup/files>
|
|
|
#include <stocksoup/version>
|
|
|
|
|
|
-#define PLUGIN_VERSION "1.1.3"
|
|
|
+#define PLUGIN_VERSION "1.1.4"
|
|
|
public Plugin myinfo = {
|
|
|
name = "[CSRD] SRCDS Automatic Data Dumper",
|
|
|
author = "nosoop",
|
|
@@ -83,6 +83,7 @@ public void OnMapStart() {
|
|
|
switch (g_DumpAction) {
|
|
|
/**
|
|
|
* Stage 1: Check if the marker file exists; change map if necessary.
|
|
|
+ * This is performed on first map load.
|
|
|
*/
|
|
|
case DumpAction_UpdateCheck: {
|
|
|
if (FileExists(path, false)) {
|
|
@@ -105,14 +106,10 @@ public void OnMapStart() {
|
|
|
GetCurrentMap(currentMap, sizeof(currentMap));
|
|
|
|
|
|
if (StrEqual(LOW_ENTITY_MAP, currentMap) && FileExists(path, false)) {
|
|
|
- PerformDataDump();
|
|
|
+ DataPack pack = new DataPack();
|
|
|
+ pack.WriteString(path);
|
|
|
|
|
|
- DeleteFile(path);
|
|
|
-
|
|
|
- int version = GetNetworkPatchVersion();
|
|
|
- LogMessage("Dumped server data for network patchversion %d", version);
|
|
|
-
|
|
|
- RequestFrame(ReloadServer);
|
|
|
+ PerformDataDump(OnDataDumpFinished, pack);
|
|
|
} else {
|
|
|
LogError("Failed to change to map %s", LOW_ENTITY_MAP);
|
|
|
}
|
|
@@ -120,7 +117,7 @@ public void OnMapStart() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void PerformDataDump() {
|
|
|
+void PerformDataDump(RequestFrameCallback postDumpCallback = INVALID_FUNCTION, any data = 0) {
|
|
|
char outputDirectory[PLATFORM_MAX_PATH];
|
|
|
BuildPath(Path_SM, outputDirectory, sizeof(outputDirectory), REDUMP_OUTPUT_DIRECTORY);
|
|
|
|
|
@@ -144,14 +141,55 @@ void PerformDataDump() {
|
|
|
// match expr /^[A-Za-z0-9_]+ - [A-Za-z0-9_]+$/
|
|
|
ServerCommand("sm_dump_classes %s/%d.classes.txt", outputDirectory, version);
|
|
|
|
|
|
+ ServerCommand("sm_dump_teprops %s/%d.tempents.txt", outputDirectory, version);
|
|
|
+
|
|
|
+ // Defer the rest of the actions by a frame to ensure everything is finished processing.
|
|
|
+ DataPack pack = new DataPack();
|
|
|
+ pack.WriteFunction(postDumpCallback);
|
|
|
+ pack.WriteCell(data);
|
|
|
+
|
|
|
+ RequestFrame(PerformDataDump_NextFrame, pack);
|
|
|
+}
|
|
|
+
|
|
|
+public void PerformDataDump_NextFrame(DataPack pack) {
|
|
|
// Create and update a .server-version file to notify incron of updates
|
|
|
char updatePath[PLATFORM_MAX_PATH];
|
|
|
BuildPath(Path_SM, updatePath, sizeof(updatePath), "%s/%s", REDUMP_OUTPUT_DIRECTORY,
|
|
|
".server-version");
|
|
|
|
|
|
File versionFile = OpenFile(updatePath, "w");
|
|
|
- versionFile.WriteLine("%d", version);
|
|
|
+ versionFile.WriteLine("%d", GetNetworkPatchVersion());
|
|
|
delete versionFile;
|
|
|
+
|
|
|
+ pack.Reset();
|
|
|
+
|
|
|
+ Function postDumpCallback = pack.ReadFunction();
|
|
|
+ any data = pack.ReadCell();
|
|
|
+
|
|
|
+ delete pack;
|
|
|
+
|
|
|
+ if (postDumpCallback != INVALID_FUNCTION) {
|
|
|
+ Call_StartFunction(INVALID_HANDLE, postDumpCallback);
|
|
|
+ Call_PushCell(data);
|
|
|
+ Call_Finish();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * User-defined call when the dumping process is finished.
|
|
|
+ */
|
|
|
+public void OnDataDumpFinished(DataPack pack) {
|
|
|
+ pack.Reset();
|
|
|
+
|
|
|
+ char path[PLATFORM_MAX_PATH];
|
|
|
+ pack.ReadString(path, sizeof(path));
|
|
|
+ delete pack;
|
|
|
+
|
|
|
+ DeleteFile(path);
|
|
|
+
|
|
|
+ LogMessage("Dumped server data for network patchversion %d", GetNetworkPatchVersion());
|
|
|
+
|
|
|
+ ServerCommand("quit");
|
|
|
}
|
|
|
|
|
|
#if defined _steamtools_included
|
|
@@ -165,10 +203,6 @@ public Action Steam_RestartRequested() {
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
-public void ReloadServer(any trash_professor_abacus) {
|
|
|
- ServerCommand("quit");
|
|
|
-}
|
|
|
-
|
|
|
public Action ForceDataDump(int client, int argc) {
|
|
|
PrepareRedump();
|
|
|
|