diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index da7a6d5..6dacd26 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -17,9 +17,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Setup SourcePawn Compiler - uses: rumblefrog/setup-sp@v1.2.4 + uses: rumblefrog/setup-sp@v1.3.1 with: version: "1.12.x" @@ -27,7 +27,7 @@ jobs: run: | pwsh prepare-publish.ps1 - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: # Artifact name name: ftp-files @@ -40,20 +40,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Download files - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: # Artifact name name: ftp-files # Destination path path: ftp/ - name: Set up node - uses: actions/setup-node@v2 + uses: actions/setup-node@v6 with: - node-version: 16 + node-version: 24 - name: Install npm packages run: npm install fs path - name: Create release - uses: actions/github-script@v6 + uses: actions/github-script@v9 with: script: | const fs = require('fs'); diff --git a/logstf/logstf.sp b/logstf/logstf.sp index 2c82fab..e4f88dc 100644 --- a/logstf/logstf.sp +++ b/logstf/logstf.sp @@ -133,6 +133,10 @@ Release notes: - Fixed unnecessary tournament restart when server is almost empty +---- 2.8.0 (23/05/2026) ---- +- Reduced lag during mid-round log upload - by Arie + + TODO: - Some people run multiple instances of the same server (located in the same directory). This is a problem, because they all write to the same logstf.log file. Make the logstf.log and -partial files have dynamic names, and don't forget to clean them up. - Sanitize names for < and >, since logs.tf doesn't like those @@ -154,7 +158,7 @@ TODO: #undef REQUIRE_PLUGIN #include -#define PLUGIN_VERSION "2.7.1" +#define PLUGIN_VERSION "2.8.0" #define UPDATE_URL "https://sourcemod.krus.dk/logstf/update.txt" #define LOG_PATH "logstf.log" @@ -701,47 +705,50 @@ void UploadLog(bool partial) { g_bIsUploading = true; g_bIsPartialUpload = partial; - // Note: If you are making changes related to title generation, also update supstats2. - char title[128]; - g_hCvarTitle.GetString(title, sizeof(title)); - ReplaceString(title, sizeof(title), "{server}", g_sCachedHostname, false); - ReplaceString(title, sizeof(title), "{blu}", g_sCachedBluTeamName, false); - ReplaceString(title, sizeof(title), "{blue}", g_sCachedBluTeamName, false); - ReplaceString(title, sizeof(title), "{red}", g_sCachedRedTeamName, false); - - char path[64], partialpath[64]; + char path[64]; GetLogPath(LOG_PATH, path, sizeof(path)); - GetLogPath(PLOG_PATH, partialpath, sizeof(partialpath)); if (partial) { + char partialpath[64]; + GetLogPath(PLOG_PATH, partialpath, sizeof(partialpath)); DeleteFile(partialpath); - if (!CopyFile(path, partialpath)) { - LogError("Failed to create partial log file"); - g_bIsUploading = false; - if (g_bReuploadASAP) { - g_bReuploadASAP = false; - UploadLog(false); - } - return; + AnyHttp_CopyFile(path, partialpath, UploadLog_CopyComplete); + } else { + MC_PrintToChatAll("%s", "{lightgreen}[LogsTF] {blue}Uploading logs..."); + UploadLog_Send(path); + } +} + +void UploadLog_CopyComplete(bool success, any metadata) { + if (!success) { + LogError("Failed to create partial log file"); + g_bIsUploading = false; + if (g_bReuploadASAP) { + g_bReuploadASAP = false; + UploadLog(false); } + return; + } - // We should NOT add a Round_Stalemate just after a round has ended (logs.tf will not understand it) - //char buffer[128]; - //char time[32]; - //FormatTime(time, sizeof(time), "%m/%d/%Y - %H:%M:%S"); - //FormatEx(buffer, sizeof(buffer), "\nL %s: %s\n", time, "World triggered \"Round_Stalemate\""); + char partialpath[64]; + GetLogPath(PLOG_PATH, partialpath, sizeof(partialpath)); + UploadLog_Send(partialpath); +} - //Handle file = OpenFile(partialpath, "a"); - //WriteFileString(file, buffer, false); - //delete file; - } +void UploadLog_Send(const char[] logpath) { + char title[128]; + g_hCvarTitle.GetString(title, sizeof(title)); + ReplaceString(title, sizeof(title), "{server}", g_sCachedHostname, false); + ReplaceString(title, sizeof(title), "{blu}", g_sCachedBluTeamName, false); + ReplaceString(title, sizeof(title), "{blue}", g_sCachedBluTeamName, false); + ReplaceString(title, sizeof(title), "{red}", g_sCachedRedTeamName, false); - if (!partial) - MC_PrintToChatAll("%s", "{lightgreen}[LogsTF] {blue}Uploading logs..."); + char apiKey[64]; + g_hCvarApikey.GetString(apiKey, sizeof(apiKey)); AnyHttpRequest req = AnyHttp.CreatePost("http://logs.tf/upload"); - req.PutFile("logfile", partial ? partialpath : path); + req.PutFile("logfile", logpath); req.PutString("title", title); req.PutString("map", g_sCachedMap); req.PutString("key", apiKey); diff --git a/logstf/update.txt b/logstf/update.txt index 3f7ca2f..2280745 100644 --- a/logstf/update.txt +++ b/logstf/update.txt @@ -4,11 +4,11 @@ { "Version" { - "Latest" "2.7.1" + "Latest" "2.8.0" } - "Notes" "Changes in 2.7.1:" - "Notes" "- Fixed unnecessary tournament restart when server is almost empty" + "Notes" "Changes in 2.8.0:" + "Notes" "- Reduced lag during mid-round log upload - by Arie" } "Files"