diff --git a/buildnumber.txt b/buildnumber.txt index 50b46273..f21f44f5 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -1578 \ No newline at end of file +1582 \ No newline at end of file diff --git a/source/funkin/menus/TitleState.hx b/source/funkin/menus/TitleState.hx index 873e5798..64d586fc 100644 --- a/source/funkin/menus/TitleState.hx +++ b/source/funkin/menus/TitleState.hx @@ -35,6 +35,7 @@ using StringTools; class TitleState extends MusicBeatState { static var initialized:Bool = false; + static var hasCheckedUpdates:Bool = false; public var curWacky:Array = []; @@ -176,8 +177,10 @@ class TitleState extends MusicBeatState new FlxTimer().start(2, function(tmr:FlxTimer) { #if UPDATE_CHECKING - var report = funkin.updating.UpdateUtil.checkForUpdates(); - if (report.newUpdate) { + var report = hasCheckedUpdates ? null : funkin.updating.UpdateUtil.checkForUpdates(); + hasCheckedUpdates = true; + + if (report != null && report.newUpdate) { FlxG.switchState(new funkin.updating.UpdateAvailableScreen(report)); } else { FlxG.switchState(new MainMenuState()); diff --git a/source/funkin/updating/AsyncUpdater.hx b/source/funkin/updating/AsyncUpdater.hx index ba31e6c6..4cf1a5fa 100644 --- a/source/funkin/updating/AsyncUpdater.hx +++ b/source/funkin/updating/AsyncUpdater.hx @@ -28,12 +28,12 @@ class AsyncUpdater { #if windows - public var executableGitHubName:String = "update-windows.exe"; - public var executableName:String = "CodenameEngine.exe"; + public static var executableGitHubName:String = "update-windows.exe"; + public static var executableName:String = "CodenameEngine.exe"; #end #if linux - public var executableGitHubName:String = "update-linux"; - public var executableName:String = "CodenameEngine"; + public static var executableGitHubName:String = "update-linux"; + public static var executableName:String = "CodenameEngine"; #end public var releases:Array; @@ -58,6 +58,7 @@ class AsyncUpdater { progress.curZipProgress = new ZipProgress(); ZipUtils.uncompressZip(reader, './', null, progress.curZipProgress); + FileSystem.deleteFile(path); } if (executableReplaced = FileSystem.exists('$path$executableName')) { var progPath = Sys.programPath(); diff --git a/source/funkin/updating/UpdateScreen.hx b/source/funkin/updating/UpdateScreen.hx index 913e82b0..653da253 100644 --- a/source/funkin/updating/UpdateScreen.hx +++ b/source/funkin/updating/UpdateScreen.hx @@ -74,7 +74,7 @@ class UpdateScreen extends MusicBeatState { FlxG.camera.fade(0xFF000000, overSound.length / 1000, false, function() { if (updater.executableReplaced) { // the executable has been replaced, restart the game entirely - Sys.command('start /B ${updater.executableName}'); + Sys.command('start /B ${AsyncUpdater.executableName}'); openfl.system.System.exit(0); } else { // assets update, switch back to TitleState. diff --git a/source/funkin/updating/UpdateUtil.hx b/source/funkin/updating/UpdateUtil.hx index 307f2542..0515badb 100644 --- a/source/funkin/updating/UpdateUtil.hx +++ b/source/funkin/updating/UpdateUtil.hx @@ -64,10 +64,19 @@ class UpdateUtil { var i = releases.length - 1 - index; var release = releases[i]; - if (release.tag_name == currentVersionTag) { - __curVersionPos = index; + var containsBinary = false; + for(asset in release.assets) { + if (asset.name.toLowerCase() == AsyncUpdater.executableGitHubName.toLowerCase()) { + containsBinary = true; + break; + } + } + if (containsBinary) { + if (release.tag_name == currentVersionTag) { + __curVersionPos = index; + } + newArray.push(release); } - newArray.push(release); } return newArray.length <= 0 ? newArray : newArray.splice(__curVersionPos+1, newArray.length-(__curVersionPos+1));