diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 90a119bed3..2817aba48b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Setting up Haxe @@ -23,7 +23,7 @@ jobs: with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that # key: cache-build-linux @@ -65,7 +65,7 @@ jobs: name: Codename Engine path: export/release/linux/bin/ # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -84,7 +84,7 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit # key: cache-build-linux @@ -100,13 +100,13 @@ jobs: needs: build # since its low priority, it'll run after, so actions will concentrate first on normal builds steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setting up Haxe uses: krdlab/setup-haxe@v2 with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that # key: cache-build-linux-debug @@ -143,7 +143,7 @@ jobs: name: Codename Engine Debug path: export/debug/linux/bin/ # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -162,7 +162,7 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit # key: cache-build-linux-debug diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index ba2bfcb48b..79f1cfcc36 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -15,7 +15,7 @@ jobs: runs-on: macos-26 steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Setting up Haxe @@ -23,17 +23,17 @@ jobs: with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that - # key: cache-build-mac + # key: cache-build-mac-intel # path: | # .haxelib/ # export/release/macos/obj/ - name: Installing/Updating libraries run: | - brew trust aws/tap arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + arch -x86_64 /usr/local/bin/brew trust aws/tap arch -x86_64 /usr/local/bin/brew install zlib haxe -cp commandline -D analyzer-optimize --run Main setup -si - name: Building the game @@ -41,7 +41,7 @@ jobs: haxelib run lime setup -alias -y -nocffi haxelib run lime rebuild hxcpp haxelib run lime rebuild tools - haxelib run lime rebuild mac -64 -nocolor -release + arch -x86_64 haxelib run lime rebuild mac -nocolor -release arch -x86_64 haxelib run lime build mac -DCOMPILE_EXPERIMENTAL - name: Tar files run: tar -zcvf CodenameEngine.tar.gz -C export/release/macos/bin . @@ -51,7 +51,7 @@ jobs: name: Codename Engine-x64 path: CodenameEngine.tar.gz # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -59,7 +59,7 @@ jobs: # repo: context.repo.repo, # }) # for (const cache of caches.data.actions_caches) { - # if (cache.key == "cache-build-mac") { + # if (cache.key == "cache-build-mac-intel") { # console.log('Clearing ' + cache.key + '...') # await github.rest.actions.deleteActionsCacheById({ # owner: context.repo.owner, @@ -70,10 +70,10 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit - # key: cache-build-mac + # key: cache-build-mac-intel # path: | # .haxelib/ # export/release/macos/obj/ @@ -84,7 +84,7 @@ jobs: runs-on: macos-26 steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Setting up Haxe @@ -92,10 +92,10 @@ jobs: with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that - # key: cache-build-mac + # key: cache-build-mac-arm # path: | # .haxelib/ # export/release/macos/obj/ @@ -119,7 +119,7 @@ jobs: name: Codename Engine-ARM64 path: CodenameEngine.tar.gz # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -127,7 +127,7 @@ jobs: # repo: context.repo.repo, # }) # for (const cache of caches.data.actions_caches) { - # if (cache.key == "cache-build-mac") { + # if (cache.key == "cache-build-mac-arm") { # console.log('Clearing ' + cache.key + '...') # await github.rest.actions.deleteActionsCacheById({ # owner: context.repo.owner, @@ -138,10 +138,10 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit - # key: cache-build-mac + # key: cache-build-mac-arm # path: | # .haxelib/ # export/release/macos/obj/ @@ -200,23 +200,23 @@ jobs: needs: universal_build # since its low priority, it'll run after, so actions will concentrate first on normal builds steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setting up Haxe uses: krdlab/setup-haxe@v2 with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that - # key: cache-build-mac-debug + # key: cache-build-mac-intel-debug # path: | # .haxelib/ # export/debug/macos/obj/ - name: Installing/Updating libraries run: | - brew trust aws/tap arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + arch -x86_64 /usr/local/bin/brew trust aws/tap arch -x86_64 /usr/local/bin/brew install zlib haxe -cp commandline -D analyzer-optimize --run Main setup -si - name: Building the game @@ -224,7 +224,7 @@ jobs: haxelib run lime setup -alias -y -nocffi haxelib run lime rebuild hxcpp haxelib run lime rebuild tools - haxelib run lime rebuild mac -64 -nocolor -release + arch -x86_64 haxelib run lime rebuild mac -nocolor -release arch -x86_64 haxelib run lime build mac -debug -DCOMPILE_EXPERIMENTAL - name: Tar files run: tar -zcvf CodenameEngine.tar.gz -C export/debug/macos/bin . @@ -234,7 +234,7 @@ jobs: name: Codename Engine-x64 Debug path: CodenameEngine.tar.gz # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -242,7 +242,7 @@ jobs: # repo: context.repo.repo, # }) # for (const cache of caches.data.actions_caches) { - # if (cache.key == "cache-build-mac-debug") { + # if (cache.key == "cache-build-mac-intel-debug") { # console.log('Clearing ' + cache.key + '...') # await github.rest.actions.deleteActionsCacheById({ # owner: context.repo.owner, @@ -253,10 +253,10 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit - # key: cache-build-mac-debug + # key: cache-build-mac-intel-debug # path: | # .haxelib/ # export/debug/macos/obj/ @@ -268,16 +268,16 @@ jobs: needs: universal_build # since its low priority, it'll run after, so actions will concentrate first on normal builds steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setting up Haxe uses: krdlab/setup-haxe@v2 with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that - # key: cache-build-mac-debug + # key: cache-build-mac-arm-debug # path: | # .haxelib/ # export/debug/macos/obj/ @@ -301,7 +301,7 @@ jobs: name: Codename Engine-ARM64 Debug path: CodenameEngine.tar.gz # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -309,7 +309,7 @@ jobs: # repo: context.repo.repo, # }) # for (const cache of caches.data.actions_caches) { - # if (cache.key == "cache-build-mac-debug") { + # if (cache.key == "cache-build-mac-arm-debug") { # console.log('Clearing ' + cache.key + '...') # await github.rest.actions.deleteActionsCacheById({ # owner: context.repo.owner, @@ -320,10 +320,10 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit - # key: cache-build-mac-debug + # key: cache-build-mac-arm-debug # path: | # .haxelib/ # export/debug/macos/obj/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e78c83f20..4fd7a32e68 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,12 +21,12 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Download Windows Full Build - uses: dawidd6/action-download-artifact@v8 + uses: dawidd6/action-download-artifact@v24 with: workflow: windows.yml name: Codename Engine @@ -34,7 +34,7 @@ jobs: allow_forks: false - name: Download Windows Executable - uses: dawidd6/action-download-artifact@v8 + uses: dawidd6/action-download-artifact@v24 with: workflow: windows.yml name: Codename Engine (Executable Only) @@ -42,7 +42,7 @@ jobs: allow_forks: false - name: Download Mac OS Full Build - uses: dawidd6/action-download-artifact@v8 + uses: dawidd6/action-download-artifact@v24 with: workflow: macos.yml name: Codename Engine @@ -50,7 +50,7 @@ jobs: allow_forks: false - name: Download Mac OS Executable - uses: dawidd6/action-download-artifact@v8 + uses: dawidd6/action-download-artifact@v24 with: workflow: macos.yml name: Codename Engine (Executable Only) @@ -58,7 +58,7 @@ jobs: allow_forks: false - name: Download Linux Full Build - uses: dawidd6/action-download-artifact@v8 + uses: dawidd6/action-download-artifact@v24 with: workflow: linux.yml name: Codename Engine @@ -66,7 +66,7 @@ jobs: allow_forks: false - name: Download Linux Executable - uses: dawidd6/action-download-artifact@v8 + uses: dawidd6/action-download-artifact@v24 with: workflow: linux.yml name: Codename Engine (Executable Only) @@ -178,7 +178,7 @@ jobs: echo -e "Final pre-changelog message:\n\n$BODY" - name: Create GitHub Release with Assets - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v3 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ffaf51af8c..b77d3e706b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -15,7 +15,7 @@ jobs: runs-on: windows-latest steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Setting up Haxe @@ -23,7 +23,7 @@ jobs: with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that # key: cache-build-windows @@ -53,7 +53,7 @@ jobs: name: Codename Engine path: export/release/windows/bin # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -72,7 +72,7 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit # key: cache-build-windows @@ -88,13 +88,13 @@ jobs: needs: build # since its low priority, it'll run after, so actions will concentrate first on normal builds steps: - name: Pulling the new commit - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Setting up Haxe uses: krdlab/setup-haxe@v2 with: haxe-version: ${{ env.HAXE_VERSION }} # - name: Restore existing build cache for faster compilation - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # not caching the bin folder to prevent asset duplication and stuff like that # key: cache-build-windows-debug @@ -118,7 +118,7 @@ jobs: name: Codename Engine Debug path: export/debug/windows/bin # - name: Clearing already existing cache - # uses: actions/github-script@v6 + # uses: actions/github-script@v9 # with: # script: | # const caches = await github.rest.actions.getActionsCacheList({ @@ -137,7 +137,7 @@ jobs: # } # } # - name: Uploading new cache - # uses: actions/cache@v4.2.3 + # uses: actions/cache@v6 # with: # # caching again since for some reason it doesnt work with the first post cache shit # key: cache-build-windows-debug diff --git a/source/funkin/backend/assets/AssetsLibraryList.hx b/source/funkin/backend/assets/AssetsLibraryList.hx index 10c1d33208..1e94335d8d 100644 --- a/source/funkin/backend/assets/AssetsLibraryList.hx +++ b/source/funkin/backend/assets/AssetsLibraryList.hx @@ -57,10 +57,12 @@ class AssetsLibraryList extends AssetLibrary { var existsSpecificCacheLibrary:Map, Map>> = []; var existsSpecificCacheTime:Map, Map>> = []; - public function existsSpecific(id:String, type:String, source:AssetSource = BOTH) { - if (!id.startsWith("assets/") && existsSpecific('assets/$id', type, source)) - return true; + private function shouldSkipLib(lib:AssetLibrary, source:AssetSource) { + if (source == BOTH || lib.tag == BOTH) return false; + return source != lib.tag; + } + public function getAssetPathLibrary(id:String, type:Null, source:AssetSource = BOTH):Null { // Prevent massive lags on repetitive usage, primarily with getting note sprite sheets in mania charts (usually 2k+ notes) final time = haxe.Timer.stamp(); @@ -77,47 +79,55 @@ class AssetsLibraryList extends AssetLibrary { } if (cacheTimePaths.exists(id)) { - final cacheSafeTime = cacheTimePaths.get(id) + 6, library = cacheLibraryPaths.get(id); + final library = cacheLibraryPaths.get(id); + final cacheSafeTime = (Flags.PATHS_CACHE_LIFETIME == null ? null : cacheTimePaths.get(id) + Flags.PATHS_CACHE_LIFETIME); + if (library != null) { - if (time < cacheSafeTime) return true; - else if (!shouldSkipLib(library, source) && library.exists(id, type)) { + if (cacheSafeTime == null || time < cacheSafeTime) return library; + else if (!shouldSkipLib(library, source) + && (type == null ? library.exists(id, @:privateAccess library.types.get(id)) : library.exists(id, type)) + ) { cacheTimePaths.set(id, time); - return true; + return library; } cacheLibraryPaths.remove(id); } - else if (time < cacheSafeTime) { - return false; - } + /*else if (time < cacheSafeTime) { + return null; + }*/ } cacheTimePaths.set(id, time); for (library in libraries) { if (shouldSkipLib(library, source)) continue; - if (library.exists(id, type)) { + if (type == null ? library.exists(id, @:privateAccess library.types.get(id)) : library.exists(id, type)) { cacheLibraryPaths.set(id, library); - return true; + return library; } } - return false; + return null; + } + + public function existsSpecific(id:String, type:String, source:AssetSource = BOTH) { + if (!id.startsWith("assets/") && existsSpecific('assets/$id', type, source)) return true; + return getAssetPathLibrary(id, type, source) != null; } + public override inline function exists(id:String, type:String):Bool return existsSpecific(id, type, BOTH); - public function getSpecificPath(id:String, source:AssetSource = BOTH) { - for(k=>e in libraries) { - if (shouldSkipLib(e, source)) continue; - - @:privateAccess - if (e.exists(id, e.types.get(id))) { - var path = e.getPath(id); - if (path != null) - return path; - } + public function getSpecificPath(id:String, source:AssetSource = BOTH):Null { + // idk if this should be null ? cus theres no mentions of type here + // but also adding one makes actions not work + final library = getAssetPathLibrary(id, null, source); + if (library != null) { + final path = library.getPath(id); + if (path != null) return path; } + return null; } @@ -163,36 +173,20 @@ class AssetsLibraryList extends AssetLibrary { } public function getSpecificAsset(id:String, type:String, source:AssetSource = BOTH):Dynamic { - try { - if (!id.startsWith("assets/")) { - var ass = getSpecificAsset('assets/$id', type, source); - if (ass != null) { - return ass; - } - } - for(k=>l in libraries) { - if (shouldSkipLib(l, source)) continue; + if (!id.startsWith("assets/")) { + final asset = getSpecificAsset('assets/$id', type, source); + if (asset != null) return asset; + } - @:privateAccess - if (l.exists(id, l.types.get(id))) { - var asset = l.getAsset(id, type); - if (asset != null) { - return asset; - } - } - } - return null; - } catch(e) { - // TODO: trace the error - throw e; + final library = getAssetPathLibrary(id, type, source); + if (library != null) { + final asset = library.getAsset(id, type); + if (asset != null) return asset; } + return null; } - private function shouldSkipLib(lib:AssetLibrary, source:AssetSource) { - if (source == BOTH || lib.tag == BOTH) return false; - return source != lib.tag; - } public override inline function getAsset(id:String, type:String):Dynamic return getSpecificAsset(id, type, BOTH); @@ -254,18 +248,21 @@ class AssetsLibraryList extends AssetLibrary { public function reset() { unloadLibraries(); + resetAssetPathCache(); + + libraries.resize(0); + + // adds default libraries in again + for (d in __defaultLibraries) addLibrary(d); + } - for(source in [AssetSource.SOURCE, AssetSource.MODS, AssetSource.BOTH]) { + public function resetAssetPathCache() { + for (source in [AssetSource.SOURCE, AssetSource.MODS, AssetSource.BOTH]) { existsSpecificCacheLibrary[source]?.clear(); existsSpecificCacheTime[source]?.clear(); } existsSpecificCacheLibrary.clear(); existsSpecificCacheTime.clear(); - - libraries.resize(0); - - // adds default libraries in again - for (d in __defaultLibraries) addLibrary(d); } public function addLibrary(lib:AssetLibrary, ?tag:AssetSource, ?addTransLib:Bool = true) { diff --git a/source/funkin/backend/scripting/GlobalScript.hx b/source/funkin/backend/scripting/GlobalScript.hx index 5c2365c737..ee58344a99 100644 --- a/source/funkin/backend/scripting/GlobalScript.hx +++ b/source/funkin/backend/scripting/GlobalScript.hx @@ -71,6 +71,8 @@ class GlobalScript { FlxG.signals.preStateSwitch.add(function() { call("preStateSwitch"); + if (Flags.PATHS_CACHE_RESET_ON_SWITCH_STATE) Paths.assetsTree.resetAssetPathCache(); + var stateName = Type.getClassName(Type.getClass(@:privateAccess FlxG.game._requestedState)); stateName = stateName.substring(stateName.lastIndexOf(".") + 1); if (Flags.MOD_REDIRECT_STATES.exists(stateName)) { diff --git a/source/funkin/backend/system/Flags.hx b/source/funkin/backend/system/Flags.hx index b6df32d766..863bdac634 100644 --- a/source/funkin/backend/system/Flags.hx +++ b/source/funkin/backend/system/Flags.hx @@ -61,6 +61,10 @@ class Flags { public static var REPO_OWNER:String = "CodenameCrew"; public static var REPO_URL:String = 'https://github.com/$REPO_OWNER/$REPO_NAME'; + @:lazy public static var PATHS_CACHE_LIFETIME:Null = null; + public static var PATHS_CACHE_RESET_ON_SWITCH_STATE:Bool = true; + //public static var PATHS_CHECK_ASSETS_PREFIX:Bool = true; // Doesn't work fully + /** * Preferred file extensions for the game's audio files. */