|
@@ -13,7 +13,7 @@
|
|
#include <stocksoup/files>
|
|
#include <stocksoup/files>
|
|
#include <stocksoup/version>
|
|
#include <stocksoup/version>
|
|
|
|
|
|
-#define PLUGIN_VERSION "1.3.0"
|
|
|
|
|
|
+#define PLUGIN_VERSION "1.4.0"
|
|
public Plugin myinfo = {
|
|
public Plugin myinfo = {
|
|
name = "[CSRD] SRCDS Automatic Data Dumper",
|
|
name = "[CSRD] SRCDS Automatic Data Dumper",
|
|
author = "nosoop",
|
|
author = "nosoop",
|
|
@@ -87,7 +87,7 @@ public void OnMapStart() {
|
|
* This is performed on first map load.
|
|
* This is performed on first map load.
|
|
*/
|
|
*/
|
|
case DumpAction_UpdateCheck: {
|
|
case DumpAction_UpdateCheck: {
|
|
- if (FileExists(path, false)) {
|
|
|
|
|
|
+ if (FileExists(path) || IsNewServerVersion()) {
|
|
g_DumpAction = DumpAction_PendingDump;
|
|
g_DumpAction = DumpAction_PendingDump;
|
|
ForceChangeLevel(LOW_ENTITY_MAP, "Starting server data dump");
|
|
ForceChangeLevel(LOW_ENTITY_MAP, "Starting server data dump");
|
|
} else {
|
|
} else {
|
|
@@ -106,7 +106,8 @@ public void OnMapStart() {
|
|
char currentMap[PLATFORM_MAX_PATH];
|
|
char currentMap[PLATFORM_MAX_PATH];
|
|
GetCurrentMap(currentMap, sizeof(currentMap));
|
|
GetCurrentMap(currentMap, sizeof(currentMap));
|
|
|
|
|
|
- if (StrEqual(LOW_ENTITY_MAP, currentMap) && FileExists(path, false)) {
|
|
|
|
|
|
+ if (StrEqual(LOW_ENTITY_MAP, currentMap)
|
|
|
|
+ && (FileExists(path) || IsNewServerVersion())) {
|
|
DataPack pack = new DataPack();
|
|
DataPack pack = new DataPack();
|
|
pack.WriteString(path);
|
|
pack.WriteString(path);
|
|
|
|
|
|
@@ -118,6 +119,23 @@ public void OnMapStart() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool IsNewServerVersion() {
|
|
|
|
+ char updatePath[PLATFORM_MAX_PATH];
|
|
|
|
+ BuildPath(Path_SM, updatePath, sizeof(updatePath), "%s/%s", REDUMP_OUTPUT_DIRECTORY,
|
|
|
|
+ ".server-version");
|
|
|
|
+
|
|
|
|
+ if (FileExists(updatePath)) {
|
|
|
|
+ char versionString[64];
|
|
|
|
+
|
|
|
|
+ File versionFile = OpenFile(updatePath, "r");
|
|
|
|
+ versionFile.ReadLine(versionString, sizeof(versionString));
|
|
|
|
+ delete versionFile;
|
|
|
|
+
|
|
|
|
+ return GetNetworkPatchVersion() > StringToInt(versionString);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
void PerformDataDump(RequestFrameCallback postDumpCallback = INVALID_FUNCTION, any data = 0) {
|
|
void PerformDataDump(RequestFrameCallback postDumpCallback = INVALID_FUNCTION, any data = 0) {
|
|
char outputDirectory[PLATFORM_MAX_PATH];
|
|
char outputDirectory[PLATFORM_MAX_PATH];
|
|
BuildPath(Path_SM, outputDirectory, sizeof(outputDirectory), REDUMP_OUTPUT_DIRECTORY);
|
|
BuildPath(Path_SM, outputDirectory, sizeof(outputDirectory), REDUMP_OUTPUT_DIRECTORY);
|
|
@@ -184,7 +202,9 @@ public void OnDataDumpFinished(DataPack pack) {
|
|
pack.ReadString(path, sizeof(path));
|
|
pack.ReadString(path, sizeof(path));
|
|
delete pack;
|
|
delete pack;
|
|
|
|
|
|
- DeleteFile(path);
|
|
|
|
|
|
+ if (FileExists(path)) {
|
|
|
|
+ DeleteFile(path);
|
|
|
|
+ }
|
|
|
|
|
|
LogMessage("Dumped server data for network patchversion %d", GetNetworkPatchVersion());
|
|
LogMessage("Dumped server data for network patchversion %d", GetNetworkPatchVersion());
|
|
|
|
|
|
@@ -204,9 +224,7 @@ public Action Steam_RestartRequested() {
|
|
|
|
|
|
public Action ForceDataDump(int client, int argc) {
|
|
public Action ForceDataDump(int client, int argc) {
|
|
PrepareRedump();
|
|
PrepareRedump();
|
|
-
|
|
|
|
ReplyToCommand(client, "[SM] Prepared dump process. Restart server.");
|
|
ReplyToCommand(client, "[SM] Prepared dump process. Restart server.");
|
|
-
|
|
|
|
return Plugin_Continue;
|
|
return Plugin_Continue;
|
|
}
|
|
}
|
|
|
|
|