From 7615843946d87b720b939caf7e5c9a8a49eeaa20 Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Sun, 5 Mar 2023 17:35:22 -0500 Subject: [PATCH 01/11] feat: commit actions --- .github/workflows/compile.yaml | 49 +++++++++++++++++++++++++++++ .gitignore | 1 + README.md | 2 +- _DO_NOT_INCLUDE/extract-metadata.py | 48 ++++++++++++++++++++++++++++ conf.lua | 2 +- makelove.toml | 23 ++++++++++++++ physics.lua | 2 +- 7 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/compile.yaml create mode 100644 _DO_NOT_INCLUDE/extract-metadata.py create mode 100644 makelove.toml diff --git a/.github/workflows/compile.yaml b/.github/workflows/compile.yaml new file mode 100644 index 0000000..6427424 --- /dev/null +++ b/.github/workflows/compile.yaml @@ -0,0 +1,49 @@ +name: Compile +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + path: main + submodules: true + name: Checkout Repository + - name: Extract Metadata + id: metadata + run: python3 main/_DO_NOT_INCLUDE/extract-metadata.py + - name: Add Universe Repository + run: sudo add-apt-repository universe + - name: Update Packages + run: sudo apt-get update + - name: Install Dependencies + run: sudo apt-get install --assume-yes wine-stable wine64 python3-pip libfuse2 + - name: Install makelove + run: pip3 install git+https://github.com/pfirsich/makelove/ + - name: Build + run: cd main && python3 -m makelove && cd .. + - name: Artifact (LÖVE) + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.metadata.outputs.id }}-source + path: main/makelove-build/love/${{ env.ARTIFACT_NAME_LOVE }} + - name: Artifact (AppImage) + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.metadata.outputs.id }}-linux + path: main/makelove-build/appimage/${{ env.ARTIFACT_NAME_APPIMAGE }} + - name: Artifact (Win64) + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.metadata.outputs.id }}-win64 + path: main/makelove-build/win64/${{ env.ARTIFACT_NAME_WIN64 }} + - name: Artifact (Win32) + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.metadata.outputs.id }}-win32 + path: main/makelove-build/win32/${{ env.ARTIFACT_NAME_WIN32 }} + - name: Artifact (MacOS) + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.metadata.outputs.id }}-macos + path: main/makelove-build/macos/${{ env.ARTIFACT_NAME_MACOS }} diff --git a/.gitignore b/.gitignore index dfe7cc8..b25beba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store ._.* Thumbs.db +makelove-build/ diff --git a/README.md b/README.md index 68779a8..a96f062 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ # mari0 -Runs on LÖVE 11.2 +Runs on LÖVE 11.4 MIT License \ No newline at end of file diff --git a/_DO_NOT_INCLUDE/extract-metadata.py b/_DO_NOT_INCLUDE/extract-metadata.py new file mode 100644 index 0000000..e4f550b --- /dev/null +++ b/_DO_NOT_INCLUDE/extract-metadata.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +''' +Extracts game metadata from main.lua and makelove.toml +and writes it out for use by GitHub Actions. + +Authored by @qixils +''' + +import os +from pathlib import Path +import re + +game_path: Path = Path(__file__).parent.parent.resolve() +main_path: Path = game_path / 'main.lua' +conf_path: Path = game_path / 'conf.lua' +toml_path: Path = game_path / 'makelove.toml' +metadata: dict[str, str] = {} + +with open(main_path, 'r') as main_file: + main = main_file.read() + metadata['title'] = re.search(r'love\.window\.setTitle\(\s*"(.+)"\s*\)', main).group(1) + metadata['version'] = re.search(r'^\s*versionstring\s*=\s*"version (.+)"$', main, re.MULTILINE).group(1) + +with open(conf_path, 'r') as conf_file: + conf = conf_file.read() + metadata['love-version'] = re.search(r'^\s*t\.version\s*=\s*"(.+)"$', conf, re.MULTILINE).group(1) + +with open(toml_path, 'r') as toml_file: + toml = toml_file.read() + metadata['id'] = re.search(r'^name\s*=\s*"(.+)"', toml).group(1) + # ensure title is the same as the one in main.lua + if (_win_title := re.search(r'^ProductName\s*=\s*"(.+)"$', toml, re.MULTILINE)) is None: + print('::error file=makelove.toml::Windows product name could not be found') + if metadata['title'] != _win_title.group(1): + print('::error file=makelove.toml::Windows product name does not match game title in main.lua') + if (_linux_title := re.search(r'\[linux.desktop_file_metadata\]\n+Name\s*=\s*"(.+)"', toml, re.MULTILINE)) is None: + print('::error file=makelove.toml::Linux desktop file name could not be found') + if metadata['title'] != _linux_title.group(1): + print('::error file=makelove.toml::Linux desktop file name does not match game title in main.lua') + if (_mac_title := re.search(r'^CFBundle(?:Display)?Name\s*=\s*"(.+)"$', toml, re.MULTILINE)) is None: + print('::error file=makelove.toml::macOS bundle display name could not be found') + if metadata['title'] != _mac_title.group(1): + print('::error file=makelove.toml::macOS bundle display name does not match game title in main.lua') + +with open(os.environ['GITHUB_OUTPUT'], 'a') as env_file: + for key, value in metadata.items(): + env_file.write(f'{key}={value}\n') diff --git a/conf.lua b/conf.lua index adf3a4a..49d24fe 100644 --- a/conf.lua +++ b/conf.lua @@ -4,5 +4,5 @@ function love.conf(t) t.console = false --t.screen = false t.modules.physics = false - t.version = "11.1" + t.version = "11.4" end \ No newline at end of file diff --git a/makelove.toml b/makelove.toml new file mode 100644 index 0000000..38a0e30 --- /dev/null +++ b/makelove.toml @@ -0,0 +1,23 @@ +name = "mari0" +default_targets = ["win32", "win64", "appimage", "macos"] +build_directory = "makelove-build" +icon_file = "_DO_NOT_INCLUDE/icon.png" + +love_files = [ + "::git-ls-tree::", + "-*/.*", + "-./_DO_NOT_INCLUDE/*", +] + +[windows.exe_metadata] +ProductName = "Mari0" +CompanyName = "Stabyourself.net" +LegalCopyright = "Copyright © 2006-2023 Maurice Guégan" + +[linux.desktop_file_metadata] +Name = "Mari0" + +[macos.app_metadata] +CFBundleName = "Mari0" +CFBundleIdentifier = "net.stabyourself" +NSHumanReadableCopyright = "Copyright © 2006-2023 Maurice Guégan" diff --git a/physics.lua b/physics.lua index d78d072..452b0cd 100644 --- a/physics.lua +++ b/physics.lua @@ -1,6 +1,6 @@ --[[ PHYSICS LIBRARY THING - WRITTEN BY MAURICE GUÉGAN FOR MARI0 + WRITTEN BY MAURICE GUÉGAN FOR MARI0 DON'T STEAL MY SHIT Licensed under the same license as the game itself. ]]-- From 3789e6b1d0cc2561358e5d917ba537fbb061902f Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Sun, 5 Mar 2023 19:38:26 -0500 Subject: [PATCH 02/11] feat: auto upload release assets --- .github/workflows/compile.yaml | 30 ++++++++++++++++++++--------- _DO_NOT_INCLUDE/extract-metadata.py | 5 +++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/compile.yaml b/.github/workflows/compile.yaml index 6427424..438553f 100644 --- a/.github/workflows/compile.yaml +++ b/.github/workflows/compile.yaml @@ -1,7 +1,13 @@ -name: Compile -on: [push, pull_request] +name: Create Artifacts +on: + release: + types: + - created + push: {} + pull_request: {} jobs: build: + name: Build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -11,7 +17,7 @@ jobs: name: Checkout Repository - name: Extract Metadata id: metadata - run: python3 main/_DO_NOT_INCLUDE/extract-metadata.py + run: python3 main/_DO_NOT_INCLUDE/extract-metadata.py ${{ github.ref }} - name: Add Universe Repository run: sudo add-apt-repository universe - name: Update Packages @@ -21,29 +27,35 @@ jobs: - name: Install makelove run: pip3 install git+https://github.com/pfirsich/makelove/ - name: Build - run: cd main && python3 -m makelove && cd .. + run: cd main && python3 -m makelove --version-name ${{ steps.metadata.outputs.version }} && cd .. - name: Artifact (LÖVE) uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-source - path: main/makelove-build/love/${{ env.ARTIFACT_NAME_LOVE }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/love/${{ env.ARTIFACT_NAME_LOVE }} - name: Artifact (AppImage) uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-linux - path: main/makelove-build/appimage/${{ env.ARTIFACT_NAME_APPIMAGE }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/appimage/${{ env.ARTIFACT_NAME_APPIMAGE }} - name: Artifact (Win64) uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-win64 - path: main/makelove-build/win64/${{ env.ARTIFACT_NAME_WIN64 }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/win64/${{ env.ARTIFACT_NAME_WIN64 }} - name: Artifact (Win32) uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-win32 - path: main/makelove-build/win32/${{ env.ARTIFACT_NAME_WIN32 }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/win32/${{ env.ARTIFACT_NAME_WIN32 }} - name: Artifact (MacOS) uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-macos - path: main/makelove-build/macos/${{ env.ARTIFACT_NAME_MACOS }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/macos/${{ env.ARTIFACT_NAME_MACOS }} + - name: Upload Release Assets + if: github.event_name == 'release' + uses: svenstaro/upload-release-action@v2 + with: + file: main/makelove-build/${{ steps.metadata.outputs.version }}/**/* + file_glob: true diff --git a/_DO_NOT_INCLUDE/extract-metadata.py b/_DO_NOT_INCLUDE/extract-metadata.py index e4f550b..59dd4c3 100644 --- a/_DO_NOT_INCLUDE/extract-metadata.py +++ b/_DO_NOT_INCLUDE/extract-metadata.py @@ -10,6 +10,7 @@ import os from pathlib import Path import re +import sys game_path: Path = Path(__file__).parent.parent.resolve() main_path: Path = game_path / 'main.lua' @@ -43,6 +44,10 @@ if metadata['title'] != _mac_title.group(1): print('::error file=makelove.toml::macOS bundle display name does not match game title in main.lua') +if len(sys.argv > 1): + if (version := re.sub(r'^refs/tags/v?', '', sys.argv[1], count=1)) != sys.argv[1]: + metadata['version'] = version + with open(os.environ['GITHUB_OUTPUT'], 'a') as env_file: for key, value in metadata.items(): env_file.write(f'{key}={value}\n') From cb2ef985a24c327daeb117a2dfeebdde708e7210 Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Sun, 5 Mar 2023 19:40:18 -0500 Subject: [PATCH 03/11] fix: metadata script --- _DO_NOT_INCLUDE/extract-metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_DO_NOT_INCLUDE/extract-metadata.py b/_DO_NOT_INCLUDE/extract-metadata.py index 59dd4c3..39fc17a 100644 --- a/_DO_NOT_INCLUDE/extract-metadata.py +++ b/_DO_NOT_INCLUDE/extract-metadata.py @@ -44,7 +44,7 @@ if metadata['title'] != _mac_title.group(1): print('::error file=makelove.toml::macOS bundle display name does not match game title in main.lua') -if len(sys.argv > 1): +if len(sys.argv) > 1: if (version := re.sub(r'^refs/tags/v?', '', sys.argv[1], count=1)) != sys.argv[1]: metadata['version'] = version From 14d2650cc4c0e62767b92722720a59921e574f6a Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Sun, 5 Mar 2023 20:01:58 -0500 Subject: [PATCH 04/11] fix: artifact publishing & linux file name --- .github/workflows/compile.yaml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compile.yaml b/.github/workflows/compile.yaml index 438553f..ba87f31 100644 --- a/.github/workflows/compile.yaml +++ b/.github/workflows/compile.yaml @@ -27,32 +27,42 @@ jobs: - name: Install makelove run: pip3 install git+https://github.com/pfirsich/makelove/ - name: Build - run: cd main && python3 -m makelove --version-name ${{ steps.metadata.outputs.version }} && cd .. + run: | + cd main + python3 -m makelove --version-name ${{ steps.metadata.outputs.version }} + cd .. + - name: Rename AppImage # for consistency with every other built artifact + run: mv main/makelove-build/${{ steps.metadata.outputs.version }}/appimage/${{ steps.metadata.outputs.id }}.AppImage main/makelove-build/${{ steps.metadata.outputs.version }}/appimage/${{ steps.metadata.outputs.id }}-linux.AppImage - name: Artifact (LÖVE) + if: github.event_name != 'release' uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-source - path: main/makelove-build/${{ steps.metadata.outputs.version }}/love/${{ env.ARTIFACT_NAME_LOVE }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/love/${{ steps.metadata.outputs.id }}.love - name: Artifact (AppImage) + if: github.event_name != 'release' uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-linux - path: main/makelove-build/${{ steps.metadata.outputs.version }}/appimage/${{ env.ARTIFACT_NAME_APPIMAGE }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/appimage/${{ steps.metadata.outputs.id }}-linux.AppImage - name: Artifact (Win64) + if: github.event_name != 'release' uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-win64 - path: main/makelove-build/${{ steps.metadata.outputs.version }}/win64/${{ env.ARTIFACT_NAME_WIN64 }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/win64/${{ steps.metadata.outputs.id }}-win64.zip - name: Artifact (Win32) + if: github.event_name != 'release' uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-win32 - path: main/makelove-build/${{ steps.metadata.outputs.version }}/win32/${{ env.ARTIFACT_NAME_WIN32 }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/win32/${{ steps.metadata.outputs.id }}-win32.zip - name: Artifact (MacOS) + if: github.event_name != 'release' uses: actions/upload-artifact@v3 with: name: ${{ steps.metadata.outputs.id }}-macos - path: main/makelove-build/${{ steps.metadata.outputs.version }}/macos/${{ env.ARTIFACT_NAME_MACOS }} + path: main/makelove-build/${{ steps.metadata.outputs.version }}/macos/${{ steps.metadata.outputs.id }}-macos.zip - name: Upload Release Assets if: github.event_name == 'release' uses: svenstaro/upload-release-action@v2 From 1640fd68f3da268ff8943c742c30d59b3983efef Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Sun, 5 Mar 2023 22:45:07 -0500 Subject: [PATCH 05/11] fix: warning, not error --- _DO_NOT_INCLUDE/extract-metadata.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_DO_NOT_INCLUDE/extract-metadata.py b/_DO_NOT_INCLUDE/extract-metadata.py index 39fc17a..e2d6d22 100644 --- a/_DO_NOT_INCLUDE/extract-metadata.py +++ b/_DO_NOT_INCLUDE/extract-metadata.py @@ -32,17 +32,17 @@ metadata['id'] = re.search(r'^name\s*=\s*"(.+)"', toml).group(1) # ensure title is the same as the one in main.lua if (_win_title := re.search(r'^ProductName\s*=\s*"(.+)"$', toml, re.MULTILINE)) is None: - print('::error file=makelove.toml::Windows product name could not be found') + print('::warning file=makelove.toml::Windows product name could not be found') if metadata['title'] != _win_title.group(1): - print('::error file=makelove.toml::Windows product name does not match game title in main.lua') + print('::warning file=makelove.toml::Windows product name does not match game title in main.lua') if (_linux_title := re.search(r'\[linux.desktop_file_metadata\]\n+Name\s*=\s*"(.+)"', toml, re.MULTILINE)) is None: - print('::error file=makelove.toml::Linux desktop file name could not be found') + print('::warning file=makelove.toml::Linux desktop file name could not be found') if metadata['title'] != _linux_title.group(1): - print('::error file=makelove.toml::Linux desktop file name does not match game title in main.lua') + print('::warning file=makelove.toml::Linux desktop file name does not match game title in main.lua') if (_mac_title := re.search(r'^CFBundle(?:Display)?Name\s*=\s*"(.+)"$', toml, re.MULTILINE)) is None: - print('::error file=makelove.toml::macOS bundle display name could not be found') + print('::warning file=makelove.toml::macOS bundle display name could not be found') if metadata['title'] != _mac_title.group(1): - print('::error file=makelove.toml::macOS bundle display name does not match game title in main.lua') + print('::warning file=makelove.toml::macOS bundle display name does not match game title in main.lua') if len(sys.argv) > 1: if (version := re.sub(r'^refs/tags/v?', '', sys.argv[1], count=1)) != sys.argv[1]: From 8c20fc8ca80dff3e997c902a072b918153feb17b Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Mon, 24 Apr 2023 23:07:49 -0400 Subject: [PATCH 06/11] lovejs --- main.lua | 2 +- menu.lua | 4 ++-- musicloader.lua | 2 +- shaders/init.lua | 6 ++++++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/main.lua b/main.lua index 8e7c239..0445da7 100644 --- a/main.lua +++ b/main.lua @@ -1610,7 +1610,7 @@ function openSaveFolder(subfolder) --By Slime end function getupdate() - local onlinedata, code = http.request("http://server.stabyourself.net/mari0/?mode=mappacks") + local onlinedata, code = {}, 404--http.request("http://server.stabyourself.net/mari0/?mode=mappacks") if code ~= 200 then return false diff --git a/menu.lua b/menu.lua index c0ae965..1806da2 100644 --- a/menu.lua +++ b/menu.lua @@ -1417,7 +1417,7 @@ end function downloadmappacks() downloaderror = false - local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks") + local onlinedata, code = {}, 404--http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks") if code ~= 200 then downloaderror = true @@ -1473,7 +1473,7 @@ function downloadmappacks() end love.filesystem.createDirectory("mappacks/" .. maplist[i]) - local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i]) + local onlinedata, code = {}, 404--http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i]) if code == 200 then filecount = 0 diff --git a/musicloader.lua b/musicloader.lua index 4bf0a20..ce1a103 100644 --- a/musicloader.lua +++ b/musicloader.lua @@ -35,7 +35,7 @@ end function music:play(name) if name and soundenabled then if self.loaded[name] == false then - local source = self.thread:demand(name) + local source = love.thread.getChannel("musiclist"):demand(name) self:onLoad(name, source) end if self.loaded[name] then diff --git a/shaders/init.lua b/shaders/init.lua index a431b8f..67e4685 100644 --- a/shaders/init.lua +++ b/shaders/init.lua @@ -93,6 +93,7 @@ shaders.passes = {} -- call at the end of love.load -- numpasses is the max number of concurrent shaders (default 2) function shaders:init(numpasses) + if true then return end numpasses = numpasses or 2 local files = love.filesystem.getDirectoryItems("shaders") @@ -131,6 +132,7 @@ end -- pass nil as the second argument to disable that shader pass -- don't call before shaders:init() function shaders:set(i, shadername) + if true then return end i = i or 1 local pass = self.passes[i] if not pass then return end @@ -150,6 +152,7 @@ end -- for tweaking some of the 'extern' parameters in the shaders -- returns true if it worked, false with an error message otherwise function shaders:setParameter(shadername, paramname, ...) + if true then return end if self.effects[shadername] then local effect = self.effects[shadername][1] return pcall(effect.send, effect, paramname, ...) @@ -160,6 +163,7 @@ end -- automatically called on init -- should also be called when resolution changes or fullscreen is toggled function shaders:refresh() + if true then return end if not self.scale or self.scale ~= scale or not self.xres or not self.yres or self.xres ~= love.graphics.getWidth() or self.yres ~= love.graphics.getHeight() then @@ -180,6 +184,7 @@ end -- call in love.draw before drawing whatever you want post-processed -- note: don't change shaders in between predraw and postdraw! function shaders:predraw() + if true then return end -- only predraw the first available pass here (we'll do the rest in postdraw) self.curcanvas = nil for i,v in ipairs(self.passes) do @@ -194,6 +199,7 @@ end -- call in love.draw after drawing whatever you want post-processed function shaders:postdraw() + if true then return end if not self.curcanvas then return end local blendmode, alphamode = love.graphics.getBlendMode() From 4d87f8b2754d5e807653792f41d39675b094d55e Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Thu, 14 Sep 2023 19:57:07 -0400 Subject: [PATCH 07/11] fix: better handle http failure --- main.lua | 6 ++---- menu.lua | 23 ++++++++--------------- musicloader.lua | 2 +- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/main.lua b/main.lua index 0445da7..c00269e 100644 --- a/main.lua +++ b/main.lua @@ -1610,11 +1610,9 @@ function openSaveFolder(subfolder) --By Slime end function getupdate() - local onlinedata, code = {}, 404--http.request("http://server.stabyourself.net/mari0/?mode=mappacks") + local psuccess, onlinedata, code = pcall(http.request("http://server.stabyourself.net/mari0/?mode=mappacks")) - if code ~= 200 then - return false - elseif not onlinedata then + if not psuccess or not onlinedata or code ~= 200 then return false end diff --git a/menu.lua b/menu.lua index 1806da2..67826d9 100644 --- a/menu.lua +++ b/menu.lua @@ -1417,12 +1417,9 @@ end function downloadmappacks() downloaderror = false - local onlinedata, code = {}, 404--http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks") + local psuccess, onlinedata, code = pcall(http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks")) - if code ~= 200 then - downloaderror = true - return false - elseif not onlinedata then + if not psuccess or not onlinedata or code ~= 200 then downloaderror = true return false end @@ -1473,9 +1470,9 @@ function downloadmappacks() end love.filesystem.createDirectory("mappacks/" .. maplist[i]) - local onlinedata, code = {}, 404--http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i]) + local psuccess, onlinedata, code = pcall(http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i])) - if code == 200 then + if psuccess and code == 200 then filecount = 0 local checksums = {} @@ -2128,9 +2125,9 @@ function keypromptstart() end function downloadfile(url, target, checksum) - local data, code = http.request(url) + local psuccess, data, code = pcall(http.request(url)) - if code ~= 200 then + if not psuccess or not data or code ~= 200 then return false end @@ -2139,12 +2136,8 @@ function downloadfile(url, target, checksum) return false end - if data then - love.filesystem.write(target, data) - return true - else - return false - end + love.filesystem.write(target, data) + return true end function reset_mappacks() diff --git a/musicloader.lua b/musicloader.lua index ce1a103..816eeda 100644 --- a/musicloader.lua +++ b/musicloader.lua @@ -35,7 +35,7 @@ end function music:play(name) if name and soundenabled then if self.loaded[name] == false then - local source = love.thread.getChannel("musiclist"):demand(name) + local source = love.thread.getChannel(name):demand() self:onLoad(name, source) end if self.loaded[name] then From 206ebbeeefd74fa89d7aa7305ef19c2ecc86d610 Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Thu, 14 Sep 2023 22:00:23 -0400 Subject: [PATCH 08/11] fix: revert pcalls on http.request --- main.lua | 4 ++-- menu.lua | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/main.lua b/main.lua index c00269e..7b2666b 100644 --- a/main.lua +++ b/main.lua @@ -1610,9 +1610,9 @@ function openSaveFolder(subfolder) --By Slime end function getupdate() - local psuccess, onlinedata, code = pcall(http.request("http://server.stabyourself.net/mari0/?mode=mappacks")) + local onlinedata, code = http.request("http://server.stabyourself.net/mari0/?mode=mappacks") - if not psuccess or not onlinedata or code ~= 200 then + if not onlinedata or code ~= 200 then return false end diff --git a/menu.lua b/menu.lua index 67826d9..09a4680 100644 --- a/menu.lua +++ b/menu.lua @@ -1417,9 +1417,9 @@ end function downloadmappacks() downloaderror = false - local psuccess, onlinedata, code = pcall(http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks")) + local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks") - if not psuccess or not onlinedata or code ~= 200 then + if not onlinedata or code ~= 200 then downloaderror = true return false end @@ -1470,9 +1470,9 @@ function downloadmappacks() end love.filesystem.createDirectory("mappacks/" .. maplist[i]) - local psuccess, onlinedata, code = pcall(http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i])) + local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=getmap&get=" .. maplist[i]) - if psuccess and code == 200 then + if code == 200 then filecount = 0 local checksums = {} @@ -2125,9 +2125,9 @@ function keypromptstart() end function downloadfile(url, target, checksum) - local psuccess, data, code = pcall(http.request(url)) + local data, code = http.request(url) - if not psuccess or not data or code ~= 200 then + if not data or code ~= 200 then return false end From de5177413af048f6988023895fd0eed7c51c44ba Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Thu, 14 Sep 2023 22:14:55 -0400 Subject: [PATCH 09/11] fix: intro explosion --- intro.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/intro.lua b/intro.lua index e0bf943..1e866b4 100644 --- a/intro.lua +++ b/intro.lua @@ -20,7 +20,9 @@ function intro_update(dt) end if introprogress > 0.5 and playedwilhelm == nil then - playsound(stabsound) + if love.system.getOS() ~= "Web" then + playsound(stabsound) + end playedwilhelm = true end From 502c12399ba582f3e690e4f54086a68b2fe72102 Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Thu, 14 Sep 2023 22:15:02 -0400 Subject: [PATCH 10/11] fix: music loading --- musicloader.lua | 36 ++++++++++++++++++++++++++++++++++-- musicloader_thread.lua | 20 +++----------------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/musicloader.lua b/musicloader.lua index 816eeda..0c06dcf 100644 --- a/musicloader.lua +++ b/musicloader.lua @@ -9,6 +9,31 @@ music = { music.stringlist = table.concat(music.toload, ";") +-- music loading constants + +local musicpath = "sounds/%s.ogg" + +local function getfilename(name) + local filename = name:match("%.[mo][pg][3g]$") and name or musicpath:format(name) -- mp3 or ogg + if love.filesystem.getInfo(filename).type == "file" then + return filename + else + print(string.format("thread can't load \"%s\": not a file!", filename)) + end +end + +function loadsong(name) + local filename = getfilename(name) + if filename then + local source = love.audio.newSource(love.sound.newDecoder(filename, 512 * 1024), "static") + --print("thread loaded music", name) + return source + end + return false +end + +-- music object + function music:init() self.thread:start() end @@ -35,8 +60,13 @@ end function music:play(name) if name and soundenabled then if self.loaded[name] == false then - local source = love.thread.getChannel(name):demand() - self:onLoad(name, source) + local source = love.thread.getChannel(name):pop() + if source == nil then + source = loadsong(name) + end + if source ~= nil then + self:onLoad(name, source) + end end if self.loaded[name] then self.loaded[name]:play() @@ -78,8 +108,10 @@ end function music:onLoad(name, source) self.loaded[name] = source + print("loaded yo") source:setLooping(true) source:setPitch(self.pitch) + print("configured yo") end diff --git a/musicloader_thread.lua b/musicloader_thread.lua index fc1f3c7..2da5fab 100644 --- a/musicloader_thread.lua +++ b/musicloader_thread.lua @@ -2,11 +2,10 @@ require("love.filesystem") require("love.sound") require("love.audio") require("love.timer") +require("musicloader") love.filesystem.setIdentity("mari0") -local musicpath = "sounds/%s.ogg" - local musiclist = {} local musictoload = {} -- waiting to be loaded into memory @@ -24,24 +23,11 @@ local function getmusiclist() end end -local function getfilename(name) - local filename = name:match("%.[mo][pg][3g]$") and name or musicpath:format(name) -- mp3 or ogg - if love.filesystem.getInfo(filename).type == "file" then - return filename - else - print(string.format("thread can't load \"%s\": not a file!", filename)) - end -end - local function loadmusic() if #musictoload > 0 then local name = table.remove(musictoload, 1) - local filename = getfilename(name) - if filename then - local source = love.audio.newSource(love.sound.newDecoder(filename, 512 * 1024), "static") - --print("thread loaded music", name) - love.thread.getChannel(name):push(source) - end + local source = loadsong(name) + love.thread.getChannel(name):push(source) end end From e52e2f330b239ae1289fc2585b0c4bb5d61cda16 Mon Sep 17 00:00:00 2001 From: Lexi Larkin Date: Thu, 14 Sep 2023 22:33:41 -0400 Subject: [PATCH 11/11] fix: revert more unrelated changes --- main.lua | 4 +++- menu.lua | 15 +++++++++++---- musicloader.lua | 2 -- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/main.lua b/main.lua index 3b618b6..a168935 100644 --- a/main.lua +++ b/main.lua @@ -1615,7 +1615,9 @@ end function getupdate() local onlinedata, code = http.request("http://server.stabyourself.net/mari0/?mode=mappacks") - if not onlinedata or code ~= 200 then + if code ~= 200 then + return false + elseif not onlinedata then return false end diff --git a/menu.lua b/menu.lua index 09a4680..c0ae965 100644 --- a/menu.lua +++ b/menu.lua @@ -1419,7 +1419,10 @@ function downloadmappacks() downloaderror = false local onlinedata, code = http.request("http://server.stabyourself.net/mari0/index2.php?mode=mappacks") - if not onlinedata or code ~= 200 then + if code ~= 200 then + downloaderror = true + return false + elseif not onlinedata then downloaderror = true return false end @@ -2127,7 +2130,7 @@ end function downloadfile(url, target, checksum) local data, code = http.request(url) - if not data or code ~= 200 then + if code ~= 200 then return false end @@ -2136,8 +2139,12 @@ function downloadfile(url, target, checksum) return false end - love.filesystem.write(target, data) - return true + if data then + love.filesystem.write(target, data) + return true + else + return false + end end function reset_mappacks() diff --git a/musicloader.lua b/musicloader.lua index 0c06dcf..96e9d00 100644 --- a/musicloader.lua +++ b/musicloader.lua @@ -108,10 +108,8 @@ end function music:onLoad(name, source) self.loaded[name] = source - print("loaded yo") source:setLooping(true) source:setPitch(self.pitch) - print("configured yo") end