From 1e72315359bd0f2dbddd42b3b79e0b23587b10f3 Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 19 Apr 2026 10:13:53 -0400 Subject: [PATCH 1/5] Unify log prefixes Collapse [OSdb Debug], [OSdb], and [osdb] into a single [OSdb] tag. DebugPrint adds the prefix itself so callers no longer pass it in. --- .../scripting/include/offstyledb.inc | 16 ++-- .../scripting/include/offstyledb_bulk.inc | 86 +++++++++---------- .../scripting/include/offstyledb_http.inc | 2 +- .../scripting/include/offstyledb_records.inc | 26 +++--- .../scripting/include/offstyledb_shavit.inc | 8 +- .../scripting/include/offstyledb_styles.inc | 52 +++++------ .../scripting/include/offstyledb_updater.inc | 8 +- 7 files changed, 99 insertions(+), 99 deletions(-) diff --git a/addons/sourcemod/scripting/include/offstyledb.inc b/addons/sourcemod/scripting/include/offstyledb.inc index fc8adf7..a36ba5b 100644 --- a/addons/sourcemod/scripting/include/offstyledb.inc +++ b/addons/sourcemod/scripting/include/offstyledb.inc @@ -73,7 +73,7 @@ void DebugPrint(const char[] format, any ...) char buffer[512]; VFormat(buffer, sizeof(buffer), format, 2); - PrintToServer("[OSdb Debug] %s", buffer); + PrintToServer("[OSdb] %s", buffer); } #include @@ -121,7 +121,7 @@ public void OnPluginStart() gM_StyleMapping = new StringMap(); - DebugPrint("[OSdb] OSdb plugin started, commands registered, ConVars created"); + DebugPrint("OSdb plugin started, commands registered, ConVars created"); } public void OnAllPluginsLoaded() @@ -167,32 +167,32 @@ public void OnMapStart() { char sMapName[256]; GetCurrentMap(sMapName, sizeof(sMapName)); - DebugPrint("[OSdb] Map started: %s", sMapName); + DebugPrint("Map started: %s", sMapName); gI_Tickrate = RoundToZero(1.0 / GetTickInterval()); - DebugPrint("[OSdb] Tickrate calculated: %d", gI_Tickrate); + DebugPrint("Tickrate calculated: %d", gI_Tickrate); } public void OnMapEnd() { - DebugPrint("[OSdb] Map ending, requesting style mapping"); + DebugPrint("Map ending, requesting style mapping"); GetStyleMapping(); } public void OnPluginEnd() { - DebugPrint("[OSdb] Plugin shutting down, cleaning up resources"); + DebugPrint("Plugin shutting down, cleaning up resources"); if (gA_AllRecords != null) { - DebugPrint("[OSdb] Cleaning up AllRecords ArrayList"); + DebugPrint("Cleaning up AllRecords ArrayList"); delete gA_AllRecords; gA_AllRecords = null; } if (gM_StyleMapping != null) { - DebugPrint("[OSdb] Cleaning up StyleMapping StringMap"); + DebugPrint("Cleaning up StyleMapping StringMap"); delete gM_StyleMapping; gM_StyleMapping = null; } diff --git a/addons/sourcemod/scripting/include/offstyledb_bulk.inc b/addons/sourcemod/scripting/include/offstyledb_bulk.inc index 86071c6..93696fa 100644 --- a/addons/sourcemod/scripting/include/offstyledb_bulk.inc +++ b/addons/sourcemod/scripting/include/offstyledb_bulk.inc @@ -8,19 +8,19 @@ public Action Command_SendAllWRs(int client, int args) { - DebugPrint("[OSdb] Command_SendAllWRs called by client %d", client); + DebugPrint("Command_SendAllWRs called by client %d", client); int iSteamID = GetSteamAccountID(client); bool bAllowed = false; - DebugPrint("[OSdb] Checking authorization for SteamID %d", iSteamID); + DebugPrint("Checking authorization for SteamID %d", iSteamID); for (int i = 0; i < sizeof(gI_SteamIDWhitelist); i++) { if (iSteamID == gI_SteamIDWhitelist[i]) { bAllowed = true; - DebugPrint("[OSdb] SteamID %d found in whitelist at index %d", iSteamID, i); + DebugPrint("SteamID %d found in whitelist at index %d", iSteamID, i); break; } } @@ -28,19 +28,19 @@ public Action Command_SendAllWRs(int client, int args) if (!bAllowed) { ReplyToCommand(client, "[OSdb] You are not permitted to fetch the records list."); - DebugPrint("[OSdb] SteamID %d not authorized for bulk operations", iSteamID); + DebugPrint("SteamID %d not authorized for bulk operations", iSteamID); return Plugin_Handled; } if (gB_IsProcessingBatches) { ReplyToCommand(client, "[OSdb] Already processing batches. Please wait for current operation to complete."); - DebugPrint("[OSdb] Bulk operation request denied - already processing batches"); + DebugPrint("Bulk operation request denied - already processing batches"); return Plugin_Handled; } ReplyToCommand(client, "[OSdb] Requesting bulk verification..."); - DebugPrint("[OSdb] Starting bulk verification request"); + DebugPrint("Starting bulk verification request"); RequestBulkVerification(); return Plugin_Handled; @@ -68,14 +68,14 @@ public Action Command_BatchStatus(int client, int args) void RequestBulkVerification() { - DebugPrint("[OSdb] Starting bulk verification request"); + DebugPrint("Starting bulk verification request"); HTTPRequest hHTTPRequest = new HTTPRequest(API_BASE_URL... "/bulk_verification"); AddHeaders(hHTTPRequest); JSONObject hVerificationBody = new JSONObject(); - DebugPrint("[OSdb] Sending bulk verification request to server"); + DebugPrint("Sending bulk verification request to server"); hHTTPRequest.Post(hVerificationBody, Callback_OnBulkVerification); delete hVerificationBody; @@ -84,23 +84,23 @@ void RequestBulkVerification() public void Callback_OnBulkVerification(HTTPResponse resp, any value) { - DebugPrint("[OSdb] Bulk verification callback received - Status: %d", resp.Status); + DebugPrint("Bulk verification callback received - Status: %d", resp.Status); if (resp.Status != HTTPStatus_OK || resp.Data == null) { LogError("[OSdb] Bulk verification failed: status = %d, data = null", resp.Status); - DebugPrint("[OSdb] Bulk verification failed with status %d", resp.Status); + DebugPrint("Bulk verification failed with status %d", resp.Status); return; } - DebugPrint("[OSdb] Bulk verification response received successfully"); + DebugPrint("Bulk verification response received successfully"); JSONObject data = view_as(resp.Data); if (!data.HasKey("key_to_send_times")) { LogError("[OSdb] Bulk verification response missing 'key_to_send_times' field"); - DebugPrint("[OSdb] Bulk verification response missing required field"); + DebugPrint("Bulk verification response missing required field"); delete data; return; } @@ -108,7 +108,7 @@ public void Callback_OnBulkVerification(HTTPResponse resp, any value) data.GetString("key_to_send_times", gS_BulkCode, sizeof(gS_BulkCode)); delete data; - DebugPrint("[OSdb] Bulk code received: %s", gS_BulkCode); + DebugPrint("Bulk code received: %s", gS_BulkCode); PrintToServer("[OSdb] Bulk verification successful, starting record collection..."); SendRecordDatabase(); @@ -116,15 +116,15 @@ public void Callback_OnBulkVerification(HTTPResponse resp, any value) void SendRecordDatabase() { - DebugPrint("[OSdb] Starting record database query"); + DebugPrint("Starting record database query"); int bulkMode = gCV_BulkUploadMode.IntValue; - DebugPrint("[OSdb] Bulk upload mode: %d (-1=no times, 0=WRs only, 1=all times)", bulkMode); + DebugPrint("Bulk upload mode: %d (-1=no times, 0=WRs only, 1=all times)", bulkMode); if (bulkMode == -1) { PrintToServer("[OSdb] Bulk upload disabled (mode = -1), skipping record collection"); - DebugPrint("[OSdb] Bulk upload skipped due to mode = -1"); + DebugPrint("Bulk upload skipped due to mode = -1"); return; } @@ -160,13 +160,13 @@ public void SQL_GetRecords_Callback(Database db, DBResultSet results, const char { if (results == null) { - LogError("[osdb] SQL_GetRecords_Callback results are null, SQL error: %s", error); + LogError("[OSdb] SQL_GetRecords_Callback results are null, SQL error: %s", error); return; } if (results.RowCount == 0) { - LogError("[osdb] SQL_GetRecords_Callback rowcount is 0"); + LogError("[OSdb] SQL_GetRecords_Callback rowcount is 0"); return; } @@ -180,7 +180,7 @@ public void SQL_GetRecords_Callback(Database db, DBResultSet results, const char } gA_AllRecords = new ArrayList(); - PrintToServer("[osdb] Collecting %d records for batch processing...", results.RowCount); + PrintToServer("[OSdb] Collecting %d records for batch processing...", results.RowCount); while (results.FetchRow()) { @@ -194,7 +194,7 @@ public void SQL_GetRecords_Callback(Database db, DBResultSet results, const char } } - PrintToServer("[osdb] Collected %d records, starting batch processing...", gI_TotalRecords); + PrintToServer("[OSdb] Collected %d records, starting batch processing...", gI_TotalRecords); ProcessNextBatch(); } @@ -238,13 +238,13 @@ JSONObject GetTimeJsonFromResult(DBResultSet results) void ProcessNextBatch() { - DebugPrint("[OSdb] ProcessNextBatch called - gB_IsProcessingBatches: %s, gS_BulkCode length: %d", + DebugPrint("ProcessNextBatch called - gB_IsProcessingBatches: %s, gS_BulkCode length: %d", gB_IsProcessingBatches ? "true" : "false", strlen(gS_BulkCode)); - DebugPrint("[OSdb] Current bulk code value: %s", gS_BulkCode); + DebugPrint("Current bulk code value: %s", gS_BulkCode); if (gA_AllRecords == null || gA_AllRecords.Length == 0) { - PrintToServer("[osdb] No more records to process, finishing batch operation."); + PrintToServer("[OSdb] No more records to process, finishing batch operation."); FinishBatchProcessing(); return; } @@ -254,7 +254,7 @@ void ProcessNextBatch() if (startIndex >= gI_TotalRecords) { - PrintToServer("[osdb] All batches processed, finishing operation."); + PrintToServer("[OSdb] All batches processed, finishing operation."); FinishBatchProcessing(); return; } @@ -264,7 +264,7 @@ void ProcessNextBatch() endIndex = gI_TotalRecords; } - PrintToServer("[osdb] Processing batch %d (%d-%d of %d records)...", + PrintToServer("[OSdb] Processing batch %d (%d-%d of %d records)...", gI_CurrentBatch + 1, startIndex + 1, endIndex, gI_TotalRecords); JSONArray hArray = new JSONArray(); @@ -275,10 +275,10 @@ void ProcessNextBatch() hArray.Push(hJSON); } - DebugPrint("[OSdb] Created JSON array with %d records", hArray.Length); + DebugPrint("Created JSON array with %d records", hArray.Length); HTTPRequest hHTTPRequest = new HTTPRequest(API_BASE_URL... "/bulk_records"); - DebugPrint("[OSdb] Created HTTP request to %s/bulk_records", API_BASE_URL); + DebugPrint("Created HTTP request to %s/bulk_records", API_BASE_URL); AddHeaders(hHTTPRequest); JSONObject hRecordsList = new JSONObject(); @@ -288,7 +288,7 @@ void ProcessNextBatch() pack.WriteCell(gI_CurrentBatch); pack.WriteCell(hArray.Length); - DebugPrint("[OSdb] Sending batch %d with %d records", gI_CurrentBatch + 1, hArray.Length); + DebugPrint("Sending batch %d with %d records", gI_CurrentBatch + 1, hArray.Length); hHTTPRequest.Post(hRecordsList, Callback_OnBatchSent, pack); delete hRecordsList; @@ -302,12 +302,12 @@ public void Callback_OnBatchSent(HTTPResponse resp, any value) int batchSize = pack.ReadCell(); delete pack; - DebugPrint("[OSdb] Callback_OnBatchSent received - Status: %d", resp.Status); + DebugPrint("Callback_OnBatchSent received - Status: %d", resp.Status); if (resp.Status != HTTPStatus_OK) { - LogError("[osdb] Batch %d failed to send: status = %d", batchNumber + 1, resp.Status); - DebugPrint("[OSdb] Batch %d failed with HTTP status %d", batchNumber + 1, resp.Status); + LogError("[OSdb] Batch %d failed to send: status = %d", batchNumber + 1, resp.Status); + DebugPrint("Batch %d failed with HTTP status %d", batchNumber + 1, resp.Status); // Try to extract error message from response if (resp.Data != null) @@ -316,27 +316,27 @@ public void Callback_OnBatchSent(HTTPResponse resp, any value) char errorMsg[256]; if (errorData.GetString("error", errorMsg, sizeof(errorMsg))) { - DebugPrint("[OSdb] Server error message: %s", errorMsg); - LogError("[osdb] Server error: %s", errorMsg); + DebugPrint("Server error message: %s", errorMsg); + LogError("[OSdb] Server error: %s", errorMsg); } if (errorData.GetString("message", errorMsg, sizeof(errorMsg))) { - DebugPrint("[OSdb] Server message: %s", errorMsg); - LogError("[osdb] Server message: %s", errorMsg); + DebugPrint("Server message: %s", errorMsg); + LogError("[OSdb] Server message: %s", errorMsg); } } else { - DebugPrint("[OSdb] No response data available"); + DebugPrint("No response data available"); } - PrintToServer("[osdb] Batch %d failed, stopping batch processing.", batchNumber + 1); + PrintToServer("[OSdb] Batch %d failed, stopping batch processing.", batchNumber + 1); FinishBatchProcessing(); return; } - PrintToServer("[osdb] Batch %d (%d records) sent successfully.", batchNumber + 1, batchSize); - DebugPrint("[OSdb] Batch %d completed successfully", batchNumber + 1); + PrintToServer("[OSdb] Batch %d (%d records) sent successfully.", batchNumber + 1, batchSize); + DebugPrint("Batch %d completed successfully", batchNumber + 1); gI_CurrentBatch++; ProcessNextBatch(); @@ -344,7 +344,7 @@ public void Callback_OnBatchSent(HTTPResponse resp, any value) void FinishBatchProcessing() { - DebugPrint("[OSdb] FinishBatchProcessing called - clearing bulk code: %s", gS_BulkCode); + DebugPrint("FinishBatchProcessing called - clearing bulk code: %s", gS_BulkCode); gB_IsProcessingBatches = false; gI_CurrentBatch = 0; @@ -352,13 +352,13 @@ void FinishBatchProcessing() if (gA_AllRecords != null) { - DebugPrint("[OSdb] Cleaning up %d records from ArrayList", gA_AllRecords.Length); + DebugPrint("Cleaning up %d records from ArrayList", gA_AllRecords.Length); delete gA_AllRecords; gA_AllRecords = null; } gS_BulkCode[0] = '\0'; - DebugPrint("[OSdb] Batch processing state reset complete"); - PrintToServer("[osdb] Batch processing completed."); + DebugPrint("Batch processing state reset complete"); + PrintToServer("[OSdb] Batch processing completed."); } diff --git a/addons/sourcemod/scripting/include/offstyledb_http.inc b/addons/sourcemod/scripting/include/offstyledb_http.inc index a0bf3b6..569d7ac 100644 --- a/addons/sourcemod/scripting/include/offstyledb_http.inc +++ b/addons/sourcemod/scripting/include/offstyledb_http.inc @@ -23,7 +23,7 @@ void AddHeaders(HTTPRequest req) if (gB_IsProcessingBatches && strlen(gS_BulkCode) > 0) { - DebugPrint("[OSdb] Adding bulk_verify header: %s", gS_BulkCode); + DebugPrint("Adding bulk_verify header: %s", gS_BulkCode); req.SetHeader("bulk_verify", gS_BulkCode); } } diff --git a/addons/sourcemod/scripting/include/offstyledb_records.inc b/addons/sourcemod/scripting/include/offstyledb_records.inc index 4fa453c..3611c58 100644 --- a/addons/sourcemod/scripting/include/offstyledb_records.inc +++ b/addons/sourcemod/scripting/include/offstyledb_records.inc @@ -40,7 +40,7 @@ void Records_HandleFinish(int client, int style, float time, int jumps, int stra { gPending[client].pending = false; - DebugPrint("[OSdb] OnFinish: client=%d style=%d time=%f oldtime=%f track=%d", client, style, time, oldtime, track); + DebugPrint("OnFinish: client=%d style=%d time=%f oldtime=%f track=%d", client, style, time, oldtime, track); if (!IsSubmittableFinish(client, track)) { @@ -51,7 +51,7 @@ void Records_HandleFinish(int client, int style, float time, int jumps, int stra // means no prior PB (first-time finish on this style), which should submit. if (oldtime != 0.0 && time >= oldtime) { - DebugPrint("[OSdb] Dropping non-PB (time=%f >= oldtime=%f)", time, oldtime); + DebugPrint("Dropping non-PB (time=%f >= oldtime=%f)", time, oldtime); return; } @@ -60,7 +60,7 @@ void Records_HandleFinish(int client, int style, float time, int jumps, int stra if (!isWR && gCV_SubmitMode.IntValue == 0) { - DebugPrint("[OSdb] Skipping non-WR (submit_mode=0)"); + DebugPrint("Skipping non-WR (submit_mode=0)"); return; } @@ -92,7 +92,7 @@ void Records_HandleFinish(int client, int style, float time, int jumps, int stra } gPending[client] = intent; - DebugPrint("[OSdb] Stashed intent for client %d (isWR=%d)", client, isWR); + DebugPrint("Stashed intent for client %d (isWR=%d)", client, isWR); } // Fills an intent from the shavit-finish params and the client's current identity. @@ -126,7 +126,7 @@ bool Records_ShouldSaveReplay(int client, bool isbestreplay, bool istoolong) if (istoolong) { - DebugPrint("[OSdb] Replay too long (isWR=%d), submitting without replay", gPending[client].isWR); + DebugPrint("Replay too long (isWR=%d), submitting without replay", gPending[client].isWR); DispatchSubmission(gPending[client], ""); gPending[client].pending = false; return false; @@ -139,7 +139,7 @@ bool Records_ShouldSaveReplay(int client, bool isbestreplay, bool istoolong) return false; } - DebugPrint("[OSdb] Requesting non-WR replay copy for client %d", client); + DebugPrint("Requesting non-WR replay copy for client %d", client); return true; } @@ -182,7 +182,7 @@ void Records_HandleReplaySaved(int client, bool isbestreplay, const char[] repla return; } - DebugPrint("[OSdb] Dispatching pending submission for client %d (isWR=%d)", client, gPending[client].isWR); + DebugPrint("Dispatching pending submission for client %d (isWR=%d)", client, gPending[client].isWR); DispatchSubmission(gPending[client], replayPath); gPending[client].pending = false; } @@ -191,7 +191,7 @@ void Records_HandleReplaySaved(int client, bool isbestreplay, const char[] repla // may chain a replay upload. void DispatchSubmission(SubmissionIntent intent, const char[] replayPath) { - DebugPrint("[OSdb] Dispatch: map=%s steamid=%s name=%s time=%.3f style=%d isWR=%s replay=%s", + DebugPrint("Dispatch: map=%s steamid=%s name=%s time=%.3f style=%d isWR=%s replay=%s", intent.map, intent.steamId, intent.name, intent.time, intent.rawStyle, intent.isWR ? "true" : "false", replayPath); @@ -241,7 +241,7 @@ void UploadReplay(const char[] replayKey, const char[] replayPath) return; } - DebugPrint("[OSdb] Uploading replay: key=%s path=%s", replayKey, replayPath); + DebugPrint("Uploading replay: key=%s path=%s", replayKey, replayPath); HTTPRequest request = new HTTPRequest(API_BASE_URL... "/upload_replay"); AddHeaders(request); @@ -260,7 +260,7 @@ void CleanupTempReplay(const char[] replayPath) return; } DeleteFile(replayPath); - DebugPrint("[OSdb] Deleted temp replay: %s", replayPath); + DebugPrint("Deleted temp replay: %s", replayPath); } public void OnRecordSubmitted(HTTPResponse resp, any value, const char[] error) @@ -274,7 +274,7 @@ public void OnRecordSubmitted(HTTPResponse resp, any value, const char[] error) if (gCV_ReplayMode.IntValue == -1) { - DebugPrint("[OSdb] Replay mode -1, not uploading replay"); + DebugPrint("Replay mode -1, not uploading replay"); CleanupTempReplay(replayPath); return; } @@ -303,12 +303,12 @@ public void OnRecordSubmitted(HTTPResponse resp, any value, const char[] error) if (hasReplayKey && replayKey[0] != '\0' && replayPath[0] != '\0') { - DebugPrint("[OSdb] Got replay_key=%s, uploading %s", replayKey, replayPath); + DebugPrint("Got replay_key=%s, uploading %s", replayKey, replayPath); UploadReplay(replayKey, replayPath); } else { - DebugPrint("[OSdb] No replay upload (hasKey=%d, pathEmpty=%d)", hasReplayKey, replayPath[0] == '\0'); + DebugPrint("No replay upload (hasKey=%d, pathEmpty=%d)", hasReplayKey, replayPath[0] == '\0'); CleanupTempReplay(replayPath); } } diff --git a/addons/sourcemod/scripting/include/offstyledb_shavit.inc b/addons/sourcemod/scripting/include/offstyledb_shavit.inc index 46293bd..f43cc12 100644 --- a/addons/sourcemod/scripting/include/offstyledb_shavit.inc +++ b/addons/sourcemod/scripting/include/offstyledb_shavit.inc @@ -100,7 +100,7 @@ void EnsureTempReplayDir() if (!DirExists(sDir)) { CreateDirectory(sDir, 511); - DebugPrint("[OSdb] Created temp replay directory: %s", sDir); + DebugPrint("Created temp replay directory: %s", sDir); return; } @@ -131,7 +131,7 @@ void EnsureTempReplayDir() if (swept > 0) { - DebugPrint("[OSdb] Swept %d orphan temp replays", swept); + DebugPrint("Swept %d orphan temp replays", swept); } } #endif @@ -166,7 +166,7 @@ void ShavitCompat_OnPluginStart() else if (smv >= 5) { // probably needless but future proofing is nice ig - DebugPrint("[OSdb] bhoptimer version >4 detected, there may be compatibility issues, check for update here https://github.com/offstyles/offstyle-plugins/releases"); + DebugPrint("bhoptimer version >4 detected, there may be compatibility issues, check for update here https://github.com/offstyles/offstyle-plugins/releases"); } EnsureTempReplayDir(); @@ -210,7 +210,7 @@ public void Shavit_AddAdditionalReplayPathsHere(int client, int style, float tim char sTempPath[PLATFORM_MAX_PATH]; GetTempReplayPath(client, sTempPath, sizeof(sTempPath)); Shavit_AlsoSaveReplayTo(sTempPath); - DebugPrint("[OSdb] Requesting non-WR replay at %s", sTempPath); + DebugPrint("Requesting non-WR replay at %s", sTempPath); } public void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, ArrayList replaypaths, ArrayList frames, int preframes, int postframes, const char[] name) diff --git a/addons/sourcemod/scripting/include/offstyledb_styles.inc b/addons/sourcemod/scripting/include/offstyledb_styles.inc index 7c12259..7b56685 100644 --- a/addons/sourcemod/scripting/include/offstyledb_styles.inc +++ b/addons/sourcemod/scripting/include/offstyledb_styles.inc @@ -8,7 +8,7 @@ void GetStyleMapping(bool forceRefresh = false) { - DebugPrint("[OSdb] Starting style mapping request (forceRefresh: %s)", forceRefresh ? "true" : "false"); + DebugPrint("Starting style mapping request (forceRefresh: %s)", forceRefresh ? "true" : "false"); if (!forceRefresh) { @@ -18,16 +18,16 @@ void GetStyleMapping(bool forceRefresh = false) if (strcmp(temp, gS_StyleHash) == 0) { - DebugPrint("[OSdb] Style hash unchanged, skipping mapping request"); + DebugPrint("Style hash unchanged, skipping mapping request"); return; } } else { - DebugPrint("[OSdb] Force refresh requested, bypassing hash check"); + DebugPrint("Force refresh requested, bypassing hash check"); } - DebugPrint("[OSdb] Style hash changed or forced refresh, requesting new mapping from server"); + DebugPrint("Style hash changed or forced refresh, requesting new mapping from server"); HTTPRequest hHTTPRequest; JSONObject hJSONObject = new JSONObject(); @@ -78,23 +78,23 @@ int ConvertStyle(int style) if (gM_StyleMapping == null) { LogError("[OSdb] Style mapping is null in ConvertStyle"); - DebugPrint("[OSdb] ConvertStyle called but style mapping is null"); + DebugPrint("ConvertStyle called but style mapping is null"); return -1; } char s[16]; IntToString(style, s, sizeof(s)); - DebugPrint("[OSdb] Converting style %d (key: %s)", style, s); + DebugPrint("Converting style %d (key: %s)", style, s); int out; if (gM_StyleMapping.GetValue(s, out)) { - DebugPrint("[OSdb] Style %d converted to %d", style, out); + DebugPrint("Style %d converted to %d", style, out); return out; } - DebugPrint("[OSdb] Style %d not found in mapping, returning -1", style); + DebugPrint("Style %d not found in mapping, returning -1", style); return -1; } @@ -125,17 +125,17 @@ void HashStyleConfig() public void Callback_OnStyleMapping(HTTPResponse resp, any value) { - DebugPrint("[OSdb] Style mapping callback received - Status: %d", resp.Status); + DebugPrint("Style mapping callback received - Status: %d", resp.Status); if (resp.Status != HTTPStatus_OK || resp.Data == null) { LogError("[OSdb] Style Mapping failed: status = %d, data = null", resp.Status); - DebugPrint("[OSdb] Style mapping failed with status %d", resp.Status); + DebugPrint("Style mapping failed with status %d", resp.Status); SetFailState("[OSdb] Style Mapping returned non-ok response"); return; } - DebugPrint("[OSdb] Style mapping response received successfully"); + DebugPrint("Style mapping response received successfully"); JSONObject data = view_as(resp.Data); char s_Data[512]; @@ -143,19 +143,19 @@ public void Callback_OnStyleMapping(HTTPResponse resp, any value) // dont think we need to do it here, but doing it anyway delete data; - DebugPrint("[OSdb] Style mapping data extracted: %s", s_Data); + DebugPrint("Style mapping data extracted: %s", s_Data); // check if StringMap is still valid FUCKING INVALID HANDLE if (gM_StyleMapping == null) { LogError("[OSdb] Style mapping handle is null, recreating..."); - DebugPrint("[OSdb] Style mapping handle was null, recreating"); + DebugPrint("Style mapping handle was null, recreating"); gM_StyleMapping = new StringMap(); } if (gM_StyleMapping.Size > 0) { - DebugPrint("[OSdb] Clearing existing style mapping (%d entries)", gM_StyleMapping.Size); + DebugPrint("Clearing existing style mapping (%d entries)", gM_StyleMapping.Size); gM_StyleMapping.Clear(); } @@ -164,7 +164,7 @@ public void Callback_OnStyleMapping(HTTPResponse resp, any value) int count = ExplodeString(s_Data, ",", parts, sizeof(parts), sizeof(parts[])); - DebugPrint("[OSdb] Processing style mapping with %d parts", count); + DebugPrint("Processing style mapping with %d parts", count); for (int i = 0; i < count - 1; i += 2) { @@ -174,27 +174,27 @@ public void Callback_OnStyleMapping(HTTPResponse resp, any value) int ivalue = StringToInt(parts[i + 1]); gM_StyleMapping.SetValue(key, ivalue); - DebugPrint("[OSdb] Mapped style %s -> %d", key, ivalue); + DebugPrint("Mapped style %s -> %d", key, ivalue); } - DebugPrint("[OSdb] Style mapping completed with %d styles", gM_StyleMapping.Size); + DebugPrint("Style mapping completed with %d styles", gM_StyleMapping.Size); } public Action Command_ViewStyleMap(int client, int args) { - DebugPrint("[OSdb] Command_ViewStyleMap called by client %d", client); + DebugPrint("Command_ViewStyleMap called by client %d", client); if (gM_StyleMapping == null || gM_StyleMapping.Size == 0) { PrintToChat(client, "[OSdb] Style map is empty or null"); - DebugPrint("[OSdb] Style mapping is null or empty"); + DebugPrint("Style mapping is null or empty"); return Plugin_Handled; } StringMapSnapshot snapshot = gM_StyleMapping.Snapshot(); int count = snapshot.Length; - DebugPrint("[OSdb] Displaying style mapping with %d entries", count); + DebugPrint("Displaying style mapping with %d entries", count); PrintToChat(client, "[OSdb] Style Mapping (%d entries):", count); char key[16]; @@ -213,19 +213,19 @@ public Action Command_ViewStyleMap(int client, int args) public Action Command_RefreshMapping(int client, int args) { - DebugPrint("[OSdb] Command_RefreshMapping called by client %d", client); + DebugPrint("Command_RefreshMapping called by client %d", client); int iSteamID = GetSteamAccountID(client); bool bAllowed = false; - DebugPrint("[OSdb] Checking authorization for SteamID %d", iSteamID); + DebugPrint("Checking authorization for SteamID %d", iSteamID); for (int i = 0; i < sizeof(gI_SteamIDWhitelist); i++) { if (iSteamID == gI_SteamIDWhitelist[i]) { bAllowed = true; - DebugPrint("[OSdb] SteamID %d found in whitelist at index %d", iSteamID, i); + DebugPrint("SteamID %d found in whitelist at index %d", iSteamID, i); break; } } @@ -233,19 +233,19 @@ public Action Command_RefreshMapping(int client, int args) if (!bAllowed) { ReplyToCommand(client, "[OSdb] You are not permitted to refresh the style mapping."); - DebugPrint("[OSdb] SteamID %d not authorized for style mapping refresh", iSteamID); + DebugPrint("SteamID %d not authorized for style mapping refresh", iSteamID); return Plugin_Handled; } ReplyToCommand(client, "[OSdb] Refreshing style mapping..."); - DebugPrint("[OSdb] Starting style mapping refresh"); + DebugPrint("Starting style mapping refresh"); // recreate the StringMap if it's null if (gM_StyleMapping == null) { gM_StyleMapping = new StringMap(); PrintToServer("[OSdb] Recreated null StringMap handle"); - DebugPrint("[OSdb] Recreated null StringMap handle"); + DebugPrint("Recreated null StringMap handle"); } GetStyleMapping(true); // Force refresh diff --git a/addons/sourcemod/scripting/include/offstyledb_updater.inc b/addons/sourcemod/scripting/include/offstyledb_updater.inc index cf2078c..d3e9554 100644 --- a/addons/sourcemod/scripting/include/offstyledb_updater.inc +++ b/addons/sourcemod/scripting/include/offstyledb_updater.inc @@ -59,11 +59,11 @@ void Updater_CheckForUpdate(bool silent) { PrintToServer("[OSdb] An update check is already in progress."); } - DebugPrint("[OSdb] Skipping update check, one is already in flight"); + DebugPrint("Skipping update check, one is already in flight"); return; } - DebugPrint("[OSdb] Checking for updates (silent=%s, current=%s)", silent ? "true" : "false", PLUGIN_VERSION); + DebugPrint("Checking for updates (silent=%s, current=%s)", silent ? "true" : "false", PLUGIN_VERSION); gB_UpdateInFlight = true; @@ -101,7 +101,7 @@ public void Callback_OnLatestRelease(HTTPResponse resp, any value) int tagOffset = (tag[0] == 'v' || tag[0] == 'V') ? 1 : 0; bool newer = !StrEqual(tag[tagOffset], PLUGIN_VERSION); - DebugPrint("[OSdb] Latest release tag: %s (current: %s)", tag, PLUGIN_VERSION); + DebugPrint("Latest release tag: %s (current: %s)", tag, PLUGIN_VERSION); if (!newer) { @@ -157,7 +157,7 @@ public void Callback_OnLatestRelease(HTTPResponse resp, any value) return; } - DebugPrint("[OSdb] Downloading %s from %s", UPDATER_SMX_NAME, downloadUrl); + DebugPrint("Downloading %s from %s", UPDATER_SMX_NAME, downloadUrl); char stagePath[PLATFORM_MAX_PATH]; BuildPath(Path_SM, stagePath, sizeof(stagePath), "plugins/" ... UPDATER_SMX_NAME ... ".new"); From e648c38a1c8a77608931b0ab4dc0165f8490e09e Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 19 Apr 2026 10:15:10 -0400 Subject: [PATCH 2/5] Extract IsOSdbAdmin admin-whitelist helper --- .../scripting/include/offstyledb.inc | 20 ++++++++++++++ .../scripting/include/offstyledb_bulk.inc | 20 +------------- .../scripting/include/offstyledb_styles.inc | 26 ++----------------- .../scripting/include/offstyledb_updater.inc | 21 ++------------- 4 files changed, 25 insertions(+), 62 deletions(-) diff --git a/addons/sourcemod/scripting/include/offstyledb.inc b/addons/sourcemod/scripting/include/offstyledb.inc index a36ba5b..8d04988 100644 --- a/addons/sourcemod/scripting/include/offstyledb.inc +++ b/addons/sourcemod/scripting/include/offstyledb.inc @@ -76,6 +76,26 @@ void DebugPrint(const char[] format, any ...) PrintToServer("[OSdb] %s", buffer); } +// Gate for all osdb_* admin commands. Server console (client 0) is always +// allowed; everyone else must be in gI_SteamIDWhitelist. +bool IsOSdbAdmin(int client) +{ + if (client == 0) + { + return true; + } + + int iSteamID = GetSteamAccountID(client); + for (int i = 0; i < sizeof(gI_SteamIDWhitelist); i++) + { + if (iSteamID == gI_SteamIDWhitelist[i]) + { + return true; + } + } + return false; +} + #include #include #include diff --git a/addons/sourcemod/scripting/include/offstyledb_bulk.inc b/addons/sourcemod/scripting/include/offstyledb_bulk.inc index 93696fa..f9bc334 100644 --- a/addons/sourcemod/scripting/include/offstyledb_bulk.inc +++ b/addons/sourcemod/scripting/include/offstyledb_bulk.inc @@ -8,27 +8,9 @@ public Action Command_SendAllWRs(int client, int args) { - DebugPrint("Command_SendAllWRs called by client %d", client); - - int iSteamID = GetSteamAccountID(client); - bool bAllowed = false; - - DebugPrint("Checking authorization for SteamID %d", iSteamID); - - for (int i = 0; i < sizeof(gI_SteamIDWhitelist); i++) - { - if (iSteamID == gI_SteamIDWhitelist[i]) - { - bAllowed = true; - DebugPrint("SteamID %d found in whitelist at index %d", iSteamID, i); - break; - } - } - - if (!bAllowed) + if (!IsOSdbAdmin(client)) { ReplyToCommand(client, "[OSdb] You are not permitted to fetch the records list."); - DebugPrint("SteamID %d not authorized for bulk operations", iSteamID); return Plugin_Handled; } diff --git a/addons/sourcemod/scripting/include/offstyledb_styles.inc b/addons/sourcemod/scripting/include/offstyledb_styles.inc index 7b56685..881865f 100644 --- a/addons/sourcemod/scripting/include/offstyledb_styles.inc +++ b/addons/sourcemod/scripting/include/offstyledb_styles.inc @@ -213,41 +213,19 @@ public Action Command_ViewStyleMap(int client, int args) public Action Command_RefreshMapping(int client, int args) { - DebugPrint("Command_RefreshMapping called by client %d", client); - - int iSteamID = GetSteamAccountID(client); - bool bAllowed = false; - - DebugPrint("Checking authorization for SteamID %d", iSteamID); - - for (int i = 0; i < sizeof(gI_SteamIDWhitelist); i++) - { - if (iSteamID == gI_SteamIDWhitelist[i]) - { - bAllowed = true; - DebugPrint("SteamID %d found in whitelist at index %d", iSteamID, i); - break; - } - } - - if (!bAllowed) + if (!IsOSdbAdmin(client)) { ReplyToCommand(client, "[OSdb] You are not permitted to refresh the style mapping."); - DebugPrint("SteamID %d not authorized for style mapping refresh", iSteamID); return Plugin_Handled; } ReplyToCommand(client, "[OSdb] Refreshing style mapping..."); - DebugPrint("Starting style mapping refresh"); - // recreate the StringMap if it's null if (gM_StyleMapping == null) { gM_StyleMapping = new StringMap(); - PrintToServer("[OSdb] Recreated null StringMap handle"); - DebugPrint("Recreated null StringMap handle"); } - GetStyleMapping(true); // Force refresh + GetStyleMapping(true); return Plugin_Handled; } diff --git a/addons/sourcemod/scripting/include/offstyledb_updater.inc b/addons/sourcemod/scripting/include/offstyledb_updater.inc index d3e9554..f8dfcff 100644 --- a/addons/sourcemod/scripting/include/offstyledb_updater.inc +++ b/addons/sourcemod/scripting/include/offstyledb_updater.inc @@ -219,7 +219,7 @@ bool Updater_ApplyStaged() public Action Command_CheckUpdate(int client, int args) { - if (!IsUpdaterAuthorized(client)) + if (!IsOSdbAdmin(client)) { ReplyToCommand(client, "[OSdb] You are not permitted to run update commands."); return Plugin_Handled; @@ -232,7 +232,7 @@ public Action Command_CheckUpdate(int client, int args) public Action Command_ApplyUpdate(int client, int args) { - if (!IsUpdaterAuthorized(client)) + if (!IsOSdbAdmin(client)) { ReplyToCommand(client, "[OSdb] You are not permitted to run update commands."); return Plugin_Handled; @@ -249,20 +249,3 @@ public Action Command_ApplyUpdate(int client, int args) return Plugin_Handled; } -bool IsUpdaterAuthorized(int client) -{ - if (client == 0) - { - return true; // server console - } - - int iSteamID = GetSteamAccountID(client); - for (int i = 0; i < sizeof(gI_SteamIDWhitelist); i++) - { - if (iSteamID == gI_SteamIDWhitelist[i]) - { - return true; - } - } - return false; -} From 64231e34f4ae64fde8a0526ceeb4bf1c1ec28eb2 Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 19 Apr 2026 10:15:45 -0400 Subject: [PATCH 3/5] Don't SetFailState on recoverable style-mapping errors --- .../sourcemod/scripting/include/offstyledb_styles.inc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/sourcemod/scripting/include/offstyledb_styles.inc b/addons/sourcemod/scripting/include/offstyledb_styles.inc index 881865f..28ca1c2 100644 --- a/addons/sourcemod/scripting/include/offstyledb_styles.inc +++ b/addons/sourcemod/scripting/include/offstyledb_styles.inc @@ -64,7 +64,9 @@ void GetStyleMapping(bool forceRefresh = false) } } else { - SetFailState("Couldnt find configs/shavit-styles.cfg"); + LogError("[OSdb] configs/shavit-styles.cfg is missing - style mapping cannot be synced. Submissions will be dropped until shavit is installed correctly."); + delete hJSONObject; + delete hHTTPRequest; return; } @@ -129,9 +131,10 @@ public void Callback_OnStyleMapping(HTTPResponse resp, any value) if (resp.Status != HTTPStatus_OK || resp.Data == null) { - LogError("[OSdb] Style Mapping failed: status = %d, data = null", resp.Status); - DebugPrint("Style mapping failed with status %d", resp.Status); - SetFailState("[OSdb] Style Mapping returned non-ok response"); + LogError("[OSdb] Style mapping fetch failed (status=%d). Keeping any existing mapping; will retry on next map change.", resp.Status); + // Invalidate the cached hash so the next OnMapEnd tries again even if + // shavit-styles.cfg didn't change in between. + gS_StyleHash[0] = '\0'; return; } From 824f2a585170f0d23131a76df1230d685ba6b0f8 Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 19 Apr 2026 10:16:27 -0400 Subject: [PATCH 4/5] Bulk batches set their own bulk_verify header --- addons/sourcemod/scripting/include/offstyledb_bulk.inc | 2 +- addons/sourcemod/scripting/include/offstyledb_http.inc | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/addons/sourcemod/scripting/include/offstyledb_bulk.inc b/addons/sourcemod/scripting/include/offstyledb_bulk.inc index f9bc334..71a3dad 100644 --- a/addons/sourcemod/scripting/include/offstyledb_bulk.inc +++ b/addons/sourcemod/scripting/include/offstyledb_bulk.inc @@ -260,8 +260,8 @@ void ProcessNextBatch() DebugPrint("Created JSON array with %d records", hArray.Length); HTTPRequest hHTTPRequest = new HTTPRequest(API_BASE_URL... "/bulk_records"); - DebugPrint("Created HTTP request to %s/bulk_records", API_BASE_URL); AddHeaders(hHTTPRequest); + hHTTPRequest.SetHeader("bulk_verify", gS_BulkCode); JSONObject hRecordsList = new JSONObject(); hRecordsList.Set("records", hArray); diff --git a/addons/sourcemod/scripting/include/offstyledb_http.inc b/addons/sourcemod/scripting/include/offstyledb_http.inc index 569d7ac..37405a9 100644 --- a/addons/sourcemod/scripting/include/offstyledb_http.inc +++ b/addons/sourcemod/scripting/include/offstyledb_http.inc @@ -20,12 +20,6 @@ void AddHeaders(HTTPRequest req) req.SetHeader("hostname", sHostname); req.SetHeader("auth", gS_AuthKey); req.SetHeader("timer_plugin", gS_TimerVersion[gI_TimerVersion]); - - if (gB_IsProcessingBatches && strlen(gS_BulkCode) > 0) - { - DebugPrint("Adding bulk_verify header: %s", gS_BulkCode); - req.SetHeader("bulk_verify", gS_BulkCode); - } } // from smlib From 536c0667f8d806ba4fcffa2155ab0caf9b1d3281 Mon Sep 17 00:00:00 2001 From: tommy Date: Sun, 19 Apr 2026 10:17:39 -0400 Subject: [PATCH 5/5] Remove dead code and comments --- .../sourcemod/scripting/include/offstyledb_bulk.inc | 13 ++++--------- .../scripting/include/offstyledb_shavit.inc | 2 -- .../scripting/include/offstyledb_styles.inc | 10 ++-------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/addons/sourcemod/scripting/include/offstyledb_bulk.inc b/addons/sourcemod/scripting/include/offstyledb_bulk.inc index 71a3dad..0397d5c 100644 --- a/addons/sourcemod/scripting/include/offstyledb_bulk.inc +++ b/addons/sourcemod/scripting/include/offstyledb_bulk.inc @@ -188,16 +188,11 @@ JSONObject GetTimeJsonFromResult(DBResultSet results) char sSteamID[32]; results.FetchString(1, sSteamID, sizeof(sSteamID)); - switch (gI_TimerVersion) + // Shavit stores the auth column in the compact Steam2 form; the API expects + // Steam3. Wrap bare account IDs in [u:1:...]. + if (StrContains(sSteamID, "[U:1:]", false) == -1) { - // we dont Really need to do this switch case shit anymore, but whatever - case TimerVersion_shavit: - { - if (StrContains(sSteamID, "[U:1:]", false) == -1) - { - Format(sSteamID, sizeof(sSteamID), "[u:1:%s]", sSteamID); - } - } + Format(sSteamID, sizeof(sSteamID), "[u:1:%s]", sSteamID); } char sName[MAX_NAME_LENGTH]; diff --git a/addons/sourcemod/scripting/include/offstyledb_shavit.inc b/addons/sourcemod/scripting/include/offstyledb_shavit.inc index f43cc12..831e87e 100644 --- a/addons/sourcemod/scripting/include/offstyledb_shavit.inc +++ b/addons/sourcemod/scripting/include/offstyledb_shavit.inc @@ -14,7 +14,6 @@ native bool Shavit_IsPaused(int client); forward void Shavit_OnReplaySaved(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong, bool iscopy, const char[] replaypath); forward void Shavit_OnFinish(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp); forward Action Shavit_ShouldSaveReplayCopy(int client, int style, float time, int jumps, int strafes, float sync, int track, float oldtime, float perfs, float avgvel, float maxvel, int timestamp, bool isbestreplay, bool istoolong); -forward void OnTimerFinished_Post(int client, float Time, int Type, int Style, bool tas, bool NewTime, int OldPosition, int NewPosition); // stocks from shavit.inc (v3 doesn't ship the helpers we use) stock Database GetTimerDatabaseHandle() @@ -142,7 +141,6 @@ void ShavitCompat_MarkOptionalNatives() { MarkNativeAsOptional("Shavit_GetWorldRecord"); MarkNativeAsOptional("Shavit_OnReplaySaved"); - MarkNativeAsOptional("OnTimerFinished_Post"); MarkNativeAsOptional("Shavit_OnFinish"); MarkNativeAsOptional("Shavit_IsPracticeMode"); MarkNativeAsOptional("Shavit_IsPaused"); diff --git a/addons/sourcemod/scripting/include/offstyledb_styles.inc b/addons/sourcemod/scripting/include/offstyledb_styles.inc index 28ca1c2..834622f 100644 --- a/addons/sourcemod/scripting/include/offstyledb_styles.inc +++ b/addons/sourcemod/scripting/include/offstyledb_styles.inc @@ -143,26 +143,20 @@ public void Callback_OnStyleMapping(HTTPResponse resp, any value) JSONObject data = view_as(resp.Data); char s_Data[512]; data.GetString("data", s_Data, sizeof(s_Data)); - // dont think we need to do it here, but doing it anyway delete data; DebugPrint("Style mapping data extracted: %s", s_Data); - // check if StringMap is still valid FUCKING INVALID HANDLE if (gM_StyleMapping == null) { - LogError("[OSdb] Style mapping handle is null, recreating..."); - DebugPrint("Style mapping handle was null, recreating"); gM_StyleMapping = new StringMap(); } - - if (gM_StyleMapping.Size > 0) + else if (gM_StyleMapping.Size > 0) { - DebugPrint("Clearing existing style mapping (%d entries)", gM_StyleMapping.Size); gM_StyleMapping.Clear(); } - const int MAX_STYLES = 512; // fucking Hope people arent adding this many.... + const int MAX_STYLES = 512; char parts[MAX_STYLES][8]; int count = ExplodeString(s_Data, ",", parts, sizeof(parts), sizeof(parts[]));