From ab0aee4cfa563f0409ef275d6b99a2f6158c4a4b Mon Sep 17 00:00:00 2001 From: Dunedan Date: Sat, 28 Dec 2024 08:30:11 +0100 Subject: [PATCH] Use MD5 hash for splash screen version check Instead of using the file modification date, this uses the MD5 hash of the file holding the content of the splash screen for the version check. This ensures the splash screen isn't unintentionally shown again when just the modification date of the file changes. Fixes #4399 --- binaries/data/config/default.cfg | 2 +- binaries/data/mods/public/gui/pregame/SplashscreenHandler.js | 2 +- binaries/data/mods/public/gui/splashscreen/splashscreen.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index f7539414a6..551221bba0 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -482,7 +482,7 @@ phase = completed ; Show a chat notification if you or an ally h [gui.splashscreen] enable = true ; Enable/disable the splashscreen -version = 0 ; Splashscreen version (date of last modification). By default, 0 to force splashscreen to appear at first launch +version = 0 ; Splashscreen version (MD5 hash of file content). By default, 0 to force splashscreen to appear at first launch [gui.session.diplomacycolors] self = "21 55 149" ; Color of your units when diplomacy colors are enabled diff --git a/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js b/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js index 6dd27b43d7..746d5efadd 100644 --- a/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js +++ b/binaries/data/mods/public/gui/pregame/SplashscreenHandler.js @@ -31,7 +31,7 @@ class SplashScreenHandler this.showSplashScreen = false; if (Engine.ConfigDB_GetValue("user", "gui.splashscreen.enable") === "true" || - Engine.ConfigDB_GetValue("user", "gui.splashscreen.version") < Engine.GetFileMTime("gui/splashscreen/splashscreen.txt")) + Engine.ConfigDB_GetValue("user", "gui.splashscreen.version") !== Engine.CalculateMD5(Engine.ReadFile("gui/splashscreen/splashscreen.txt"))) Engine.PushGuiPage("page_splashscreen.xml", {}); } } diff --git a/binaries/data/mods/public/gui/splashscreen/splashscreen.js b/binaries/data/mods/public/gui/splashscreen/splashscreen.js index aea932a850..b653e36af7 100644 --- a/binaries/data/mods/public/gui/splashscreen/splashscreen.js +++ b/binaries/data/mods/public/gui/splashscreen/splashscreen.js @@ -9,7 +9,7 @@ function init(data) function closePage() { Engine.ConfigDB_CreateValue("user", "gui.splashscreen.enable", String(Engine.GetGUIObjectByName("displaySplashScreen").checked)); - Engine.ConfigDB_CreateValue("user", "gui.splashscreen.version", Engine.GetFileMTime(g_SplashScreenFile)); + Engine.ConfigDB_CreateValue("user", "gui.splashscreen.version", Engine.CalculateMD5(Engine.ReadFile(g_SplashScreenFile))); Engine.ConfigDB_SaveChanges("user"); Engine.PopGuiPage(); }