diff --git a/.github/workflows/Android.yml b/.github/workflows/Android.yml deleted file mode 100644 index 8352e14d581..00000000000 --- a/.github/workflows/Android.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: Android - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [ opened, synchronize ] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Install gettext - run: sudo apt-get update && sudo apt-get install -y gettext - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'adopt' - cache: gradle - - - name: Cache CMake build folder - uses: actions/cache@v4 - with: - path: android-project/app/.cxx - key: ${{ github.workflow }}-v4-${{ github.sha }} - restore-keys: ${{ github.workflow }}-v4- - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: cd android-project && ./gradlew assembleDebug - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-debug.apk - path: android-project/app/build/outputs/apk/debug/app-debug.apk - - - name: Clean up artifacts - run: rm -rf android-project/app/build/outputs diff --git a/.github/workflows/Linux_aarch64.yml b/.github/workflows/Linux_aarch64.yml deleted file mode 100644 index 7c6bcb52f74..00000000000 --- a/.github/workflows/Linux_aarch64.yml +++ /dev/null @@ -1,116 +0,0 @@ -name: Linux AArch64 (aarch64-linux-gnu) - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # Work around the somewhat broken packages in the GitHub Actions Ubuntu 20.04 image. - # https://github.com/actions/runner-images/issues/4620#issuecomment-981333260 - - name: Work around broken packages - run: sudo apt-get -y install --allow-downgrades libpcre2-8-0=10.34-7 - - - name: Add clang repo - run: | - wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc - sudo tee /etc/apt/sources.list.d/clang.list < - sudo apt-get update && - sudo apt-get install -y cmake file g++ git libfmt-dev libsdl1.2-dev libsodium-dev libpng-dev libbz2-dev rpm smpq - - - name: Cache CMake build folder - uses: actions/cache@v4 - with: - path: build - key: ${{ github.workflow }}-v2-${{ github.sha }} - restore-keys: ${{ github.workflow }}-v2- - - - name: Configure CMake - shell: bash - working-directory: ${{github.workspace}} - # Disable LTO to work around an ICE in gcc11 - run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=OFF -DCPACK=ON -DUSE_SDL1=ON -DDISCORD_INTEGRATION=ON -DDISABLE_LTO=ON - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: cmake --build build -j $(nproc) --target package - - - name: Package - run: Packaging/nix/LinuxReleasePackaging.sh - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx_linux_x86_64_SDL1.tar.xz - path: devilutionx.tar.xz - - - name: Clean up artifacts - run: rm -rf build/_CPack_Packages build/package build/*.deb build/*.rpm build/*.appimage build/*.tar.xz diff --git a/.github/workflows/Linux_x86_64_test.yml b/.github/workflows/Linux_x86_64_test.yml deleted file mode 100644 index 3165868806b..00000000000 --- a/.github/workflows/Linux_x86_64_test.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Linux x64 Tests - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [ opened, synchronize ] - paths-ignore: - - '*.md' - - 'docs/**' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y cmake curl g++ git lcov libgtest-dev libgmock-dev libbenchmark-dev libfmt-dev libsdl2-dev libsodium-dev libpng-dev libbz2-dev wget - - name: Cache CMake build folder - uses: actions/cache@v4 - with: - path: build - key: ${{ github.workflow }}-v1-${{ github.sha }} - restore-keys: ${{ github.workflow }}-v1- - - # We specify `-DDEVILUTIONX_SYSTEM_BENCHMARK=OFF` to work around the following error: - # lto1: fatal error: bytecode stream in file ‘/usr/lib/x86_64-linux-gnu/libbenchmark_main.a’ generated with LTO version 11.2 instead of the expected 11.3 - - name: Build tests - run: | - cmake -S. -Bbuild -DENABLE_CODECOVERAGE=ON -DDEVILUTIONX_SYSTEM_BENCHMARK=OFF - wget -nc https://github.com/diasurgical/devilutionx-assets/releases/download/v2/spawn.mpq -P build - cmake --build build -j $(nproc) - - - name: Run tests - run: cd build && ctest --output-on-failure - - - name: Upload results - uses: codecov/codecov-action@v4 - with: - gcov: true diff --git a/.github/workflows/PS4.yml b/.github/workflows/PS4.yml deleted file mode 100644 index a1ef66c44f2..00000000000 --- a/.github/workflows/PS4.yml +++ /dev/null @@ -1,61 +0,0 @@ -name: PS4 - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - ps4: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create Build Environment - run: > - sudo apt-get update && - sudo apt-get install -y wget cmake git gettext smpq && - wget https://github.com/PacBrew/pacbrew-pacman/releases/download/v1.1/pacbrew-pacman-1.1.deb && - sudo dpkg -i pacbrew-pacman-1.1.deb && sudo pacbrew-pacman -Sy && - sudo pacbrew-pacman --noconfirm -S ps4-openorbis ps4-openorbis-portlibs && - echo "#include " | sudo tee /opt/pacbrew/ps4/openorbis/include/sys/endian.h - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: Packaging/ps4/build.sh - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-ps4.pkg - path: build-ps4/devilutionx.pkg - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - asset_name: devilutionx-ps4.pkg - file: build-ps4/devilutionx.pkg - overwrite: true diff --git a/.github/workflows/PS5.yml b/.github/workflows/PS5.yml deleted file mode 100644 index b9b6e0eefb1..00000000000 --- a/.github/workflows/PS5.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: PS5 (ps5-payload-dev) - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - - -jobs: - ps5: - runs-on: ubuntu-24.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create Build Environment - run: | - sudo apt update - sudo apt install cmake pkg-config clang-15 lld-15 - sudo apt install build-essential autoconf libtool yasm nasm - sudo apt install smpq gperf pkgconf libarchive-tools autopoint po4a git curl doxygen wget - wget https://github.com/ps5-payload-dev/pacbrew-repo/releases/download/v0.8/ps5-payload-dev.tar.gz - sudo tar -xf ps5-payload-dev.tar.gz -C / - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: Packaging/ps5/build.sh - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-ps5.zip - path: build-ps5/devilutionx-ps5.zip - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - asset_name: devilutionx-ps5.zip - file: build-ps5/devilutionx-ps5.zip - overwrite: true diff --git a/.github/workflows/Windows9x_MinGW.yml b/.github/workflows/Windows9x_MinGW.yml deleted file mode 100644 index 8fafa473591..00000000000 --- a/.github/workflows/Windows9x_MinGW.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Windows 9x MinGW - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [ opened, synchronize ] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create Build Environment - run: > - sudo apt-get update && - sudo apt-get install -y cmake gcc-mingw-w64-i686 g++-mingw-w64-i686 mingw-w64-tools libz-mingw-w64-dev gettext dpkg-dev wget git sudo smpq && - sudo rm /usr/i686-w64-mingw32/lib/libz.dll.a && - sudo Packaging/windows/mingw9x-prep.sh - - - name: Configure CMake - shell: bash - working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild-windows9x -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DCPACK=ON -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/mingw9x.toolchain.cmake -DTARGET_PLATORM=windows9x - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: | - cmake --build build-windows9x -j $(nproc) --target package - mv build-windows9x/devilutionx.zip devilutionx-win9x.zip - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - path: devilutionx-win9x.zip - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - file: devilutionx-win9x.zip - overwrite: true - diff --git a/.github/workflows/Windows_MSVC_x64.yml b/.github/workflows/Windows_MSVC_x64.yml deleted file mode 100644 index 6c35e1179d8..00000000000 --- a/.github/workflows/Windows_MSVC_x64.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: Windows MSVC x64 - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [ opened, synchronize ] - paths-ignore: - - '*.md' - - 'docs/**' - -permissions: - contents: write - -env: - VCPKG_FEATURE_FLAGS: dependencygraph - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - - - name: Install latest CMake - uses: lukka/get-cmake@latest - - - name: Restore or setup vcpkg - uses: lukka/run-vcpkg@v11.5 - with: - vcpkgGitCommitId: '29b2ea2d4b6197e66ef346e62ccbba35b55b7de5' - - - name: Fetch test data - run: | - mkdir build-ninja-vcpkg-relwithdebinfo - Invoke-WebRequest -Uri "https://github.com/diasurgical/devilutionx-assets/releases/download/v2/spawn.mpq" -OutFile "build-ninja-vcpkg-relwithdebinfo/spawn.mpq" -Resume - - - name: Get CMakePresets.json - run: cp Packaging/windows/CMakePresets.json . - - - name: Run CMake consuming CMakePresets.json and vcpkg.json by mean of vcpkg. - uses: lukka/run-cmake@v10 - with: - configurePreset: 'ninja-vcpkg-relwithdebinfo' - buildPreset: 'ninja-vcpkg-relwithdebinfo' - testPreset: 'ninja-vcpkg-relwithdebinfo' - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx.exe - path: | - build-ninja-vcpkg-relwithdebinfo/devilutionx.exe - build-ninja-vcpkg-relwithdebinfo/bz2.dll - build-ninja-vcpkg-relwithdebinfo/fmt.dll - build-ninja-vcpkg-relwithdebinfo/libpng16.dll - build-ninja-vcpkg-relwithdebinfo/libsodium.dll - build-ninja-vcpkg-relwithdebinfo/SDL2.dll - build-ninja-vcpkg-relwithdebinfo/SDL2_image.dll - build-ninja-vcpkg-relwithdebinfo/zlib1.dll diff --git a/.github/workflows/Windows_MinGW_x64.yml b/.github/workflows/Windows_MinGW_x64.yml deleted file mode 100644 index f17d1db7caf..00000000000 --- a/.github/workflows/Windows_MinGW_x64.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Windows MinGW x64 - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [ opened, synchronize ] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create Build Environment - run: > - sudo apt-get update && - sudo apt-get install -y cmake gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 pkg-config-mingw-w64-x86-64 libz-mingw-w64-dev gettext dpkg-dev wget git sudo smpq && - sudo rm /usr/x86_64-w64-mingw32/lib/libz.dll.a && - sudo Packaging/windows/mingw-prep64.sh - - - name: Configure CMake - shell: bash - working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=OFF -DCPACK=ON -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/mingwcc64.toolchain.cmake -DDEVILUTIONX_SYSTEM_BZIP2=OFF -DDEVILUTIONX_STATIC_LIBSODIUM=ON -DDISCORD_INTEGRATION=ON -DSCREEN_READER_INTEGRATION=ON - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: cmake --build build -j $(nproc) --target package - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx_x64.zip - path: build/devilutionx.zip - - - name: Move artifacts to new folder and split exe and other data into two folders - if: ${{ !env.ACT && github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'diasurgical/devilutionX'}} - working-directory: ${{github.workspace}} - shell: bash - run: mkdir artifacts_dir && unzip build/devilutionx.zip -d artifacts_dir && mkdir artifacts_dir/exe_dir && mv artifacts_dir/devilutionx/devilutionx.exe artifacts_dir/exe_dir && zip -m artifacts_dir/exe_dir/build.zip artifacts_dir/exe_dir/devilutionx.exe && rm artifacts_dir/devilutionx/libTolk.dll - - - name: Pushes DLLs and devilutionx.mpq to another repository - if: ${{ !env.ACT && github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'diasurgical/devilutionX' }} - uses: cpina/github-action-push-to-another-repository@main - env: - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - with: - source-directory: artifacts_dir/devilutionx/ - destination-github-username: 'artifacts-storage' - destination-repository-name: 'devilutionx-artifacts' - target-directory: data - commit-message: "[DATA] ${{ github.event.head_commit.message }}" - target-branch: master - - - name: Pushes exe to another repository - if: ${{ !env.ACT && github.ref == 'refs/heads/master' && github.event_name != 'pull_request' && github.repository == 'diasurgical/devilutionX' }} - uses: cpina/github-action-push-to-another-repository@main - env: - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - with: - source-directory: artifacts_dir/exe_dir - destination-github-username: 'artifacts-storage' - destination-repository-name: 'devilutionx-artifacts' - target-directory: ${{ github.sha }} - commit-message: "[EXE] ${{ github.event.head_commit.message }}" - target-branch: master diff --git a/.github/workflows/Windows_MinGW_x86.yml b/.github/workflows/Windows_MinGW_x86.yml deleted file mode 100644 index d35f24eb957..00000000000 --- a/.github/workflows/Windows_MinGW_x86.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Windows MinGW x86 - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [ opened, synchronize ] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create Build Environment - run: > - sudo apt update && - sudo apt install -y cmake gcc-mingw-w64-i686 g++-mingw-w64-i686 pkg-config-mingw-w64-i686 libz-mingw-w64-dev gettext dpkg-dev wget git sudo smpq && - sudo rm /usr/i686-w64-mingw32/lib/libz.dll.a && - sudo Packaging/windows/mingw-prep.sh - - - name: Configure CMake - shell: bash - working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=OFF -DCPACK=ON -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/mingwcc.toolchain.cmake -DDEVILUTIONX_SYSTEM_BZIP2=OFF -DDEVILUTIONX_STATIC_LIBSODIUM=ON -DDISCORD_INTEGRATION=ON -DSCREEN_READER_INTEGRATION=ON - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: cmake --build build -j $(nproc) --target package - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx_x86.zip - path: build/devilutionx.zip diff --git a/.github/workflows/iOS.yml b/.github/workflows/iOS.yml deleted file mode 100644 index 0d0043e291a..00000000000 --- a/.github/workflows/iOS.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: iOS - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: macos-12 - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Cache CMake build folder - uses: actions/cache@v4 - with: - path: build - key: ${{ github.workflow }}-v4-${{ github.sha }} - restore-keys: ${{ github.workflow }}-v4- - - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{github.workspace}} - run: cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=../CMake/platforms/ios.toolchain.cmake -DENABLE_BITCODE=0 -DPLATFORM=OS64 - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: > - cmake --build build -j $(sysctl -n hw.physicalcpu) --config Release && - cd build && - mkdir Payload && - mv devilutionx.app Payload && - zip -r devilutionx-iOS.ipa Payload - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-iOS.ipa - path: build/devilutionx-iOS.ipa - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - file: build/devilutionx-iOS.ipa - overwrite: true - - - name: Clean up artifacts - run: rm -rf build/Payload build/*.ipa diff --git a/.github/workflows/macOS_x86_64.yml b/.github/workflows/macOS_x86_64.yml deleted file mode 100644 index 8fc713c8239..00000000000 --- a/.github/workflows/macOS_x86_64.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: macOS x86_64 - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: macos-12 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Create Build Environment - run: brew bundle install - - - name: Cache CMake build folder - uses: actions/cache@v4 - with: - path: build - key: ${{ github.workflow }}-v2-${{ github.sha }} - restore-keys: ${{ github.workflow }}-v2- - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - env: - CMAKE_BUILD_TYPE: ${{github.event_name == 'release' && 'Release' || 'RelWithDebInfo'}} - run: | - cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=${{env.CMAKE_BUILD_TYPE}} -DBUILD_TESTING=OFF \ - -DMACOSX_STANDALONE_APP_BUNDLE=ON -DDISCORD_INTEGRATION=ON && \ - cmake --build build -j $(sysctl -n hw.physicalcpu) --target package && \ - mv build/devilutionx.dmg build/devilutionx-x86_64-macOS.dmg - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-x86_64-macOS.dmg - path: build/devilutionx-x86_64-macOS.dmg - - - name: Clean up artifacts - run: rm -rf build/_CPack_Packages build/*.dmg diff --git a/.github/workflows/miyoo_mini_release.yml b/.github/workflows/miyoo_mini_release.yml deleted file mode 100644 index e97fd3e6178..00000000000 --- a/.github/workflows/miyoo_mini_release.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Miyoo Mini Release Build - -on: - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - miyoo-mini: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install toolchain - working-directory: ${{github.workspace}} - run: sudo Packaging/miyoo_mini/setup_toolchain.sh - - - name: Build - working-directory: ${{github.workspace}} - run: Packaging/miyoo_mini/build.sh - - - name: Upload-OnionOS-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-miyoo-mini-onion-os.zip - path: build-miyoo-mini/devilutionx-miyoo-mini-onion-os.zip - - - name: Upload-miniUI-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-miyoo-mini-miniui.zip - path: build-miyoo-mini/devilutionx-miyoo-mini-miniui.zip - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - file: "build-miyoo-mini/devilutionx-*.zip" - file_glob: true - overwrite: true diff --git a/.github/workflows/switch.yml b/.github/workflows/switch.yml deleted file mode 100644 index c2293300c7d..00000000000 --- a/.github/workflows/switch.yml +++ /dev/null @@ -1,65 +0,0 @@ ---- -name: Nintendo Switch - -on: # yamllint disable-line rule:truthy - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - container: devkitpro/devkita64:latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install dependencies - run: | - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests \ - gettext - - - name: Configure CMake - run: | - cmake \ - -S . \ - -B build \ - -D CMAKE_BUILD_TYPE=RelWithDebInfo \ - -D CMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake - - - name: Build DevilutionX - run: cmake --build build -j$(nproc) - - - name: Upload Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx.nro - path: ./build/devilutionx.nro - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - asset_name: devilutionx-switch.nro - file: ./build/devilutionx.nro - overwrite: true -... diff --git a/.github/workflows/vita.yml b/.github/workflows/vita.yml deleted file mode 100644 index 33d0e9a43c6..00000000000 --- a/.github/workflows/vita.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- -name: Sony PlayStation Vita - -on: # yamllint disable-line rule:truthy - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: ubuntu-latest - container: vitasdk/vitasdk:latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install dependencies - run: | - apk add \ - gettext \ - git \ - samurai - - - name: Configure CMake - run: | - cmake \ - -S . \ - -B build \ - -G Ninja \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake - - - name: Build DevilutionX - run: cmake --build build - - - name: Upload Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx.vpk - path: ./build/devilutionx.vpk - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - asset_name: devilutionx-vita.vpk - file: ./build/devilutionx.vpk - overwrite: true -... diff --git a/.github/workflows/xbox_nxdk.yml b/.github/workflows/xbox_nxdk.yml deleted file mode 100644 index abb286ba1b7..00000000000 --- a/.github/workflows/xbox_nxdk.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Xbox - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - xbox: - # `ubuntu-latest` is currently 20.04 but we require a newer clang. - runs-on: ubuntu-22.04 - env: - NXDK_DIR: /opt/nxdk - steps: - - name: Install APT packages - run: sudo apt-get update && sudo apt-get install -y clang llvm lld bison flex cmake git gettext - - - name: Clone nxdk Repo - shell: bash - run: git clone --recursive --depth 1 https://github.com/XboxDev/nxdk.git "$NXDK_DIR" - - - name: Build nxdk - shell: bash - run: PATH="${NXDK_DIR}/bin:$PATH" make -j $(nproc) -C "$NXDK_DIR" NXDK_ONLY=1 CFLAGS=-O2 CXXFLAGS=-O2 all cxbe - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Configure CMake - working-directory: ${{github.workspace}} - env: - CMAKE_BUILD_TYPE: ${{github.event_name == 'release' && 'Release' || 'RelWithDebInfo'}} - run: cmake -S. -Bbuild-xbox -DCMAKE_BUILD_TYPE=${{env.CMAKE_BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/opt/nxdk/share/toolchain-nxdk.cmake - - - name: Build - working-directory: ${{github.workspace}} - shell: bash - run: cmake --build build-xbox -j $(nproc) --target nxdk_xbe - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-xbox - path: build-xbox/pkg/ - - - name: Package Release - if: ${{ github.event_name == 'release' && !env.ACT }} - working-directory: ${{github.workspace}}/build-xbox/pkg - run: zip -r ../../devilutionx-xbox.zip . - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - file: devilutionx-xbox.zip - overwrite: true diff --git a/.github/workflows/xbox_one.yml b/.github/workflows/xbox_one.yml deleted file mode 100644 index b6b12f97ff4..00000000000 --- a/.github/workflows/xbox_one.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Xbox One / Series - -on: - push: - branches: - - master - paths-ignore: - - '*.md' - - 'docs/**' - pull_request: - types: [opened, synchronize] - paths-ignore: - - '*.md' - - 'docs/**' - release: - types: [published] - paths-ignore: - - '*.md' - - 'docs/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - runs-on: windows-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 - - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v2 - with: - msbuild-architecture: x64 - - - name: Configure git - shell: cmd - run: | - git config --global core.filemode false - git config --global core.autocrlf false - - - name: Install gettext - run: > - New-Item -Path . -Name tools-gettext -ItemType Directory -Force && - Invoke-WebRequest -Uri "https://github.com/vslavik/gettext-tools-windows/releases/download/v0.22.5/gettext-tools-windows-0.22.5.zip" -OutFile tools-gettext.zip -Resume && - Expand-Archive tools-gettext.zip && - Remove-Item tools-gettext.zip && - Add-Content $env:GITHUB_PATH "$((Get-Item tools-gettext).FullName)\bin" - - - name: Build - shell: cmd - run: | - cd ${{ github.workspace }}\Packaging\xbox-one - build.bat - - - name: Copy artifacts to package directory - run: > - New-Item -Path build\uwp-project -Name pkg -ItemType Directory -Force && - Get-Childitem -Path build\uwp-project\AppxPackages, build\uwp-project\Release - -Include Microsoft.VCLibs.x64.*.appx, devilutionX_*_x64.appx -File -Recurse | - Copy-Item -Destination build\uwp-project\pkg\ - - - name: Upload-Package - if: ${{ !env.ACT }} - uses: actions/upload-artifact@v4 - with: - name: devilutionx-xbox-one-series - if-no-files-found: error - path: | - build/uwp-project/pkg/ - - - name: Package Release - if: ${{ github.event_name == 'release' && !env.ACT }} - working-directory: ${{github.workspace}}/build/uwp-project/pkg/ - run: 7z a -r ../../../devilutionx-xbox-one-series.zip . - - - name: Update Release - if: ${{ github.event_name == 'release' && !env.ACT }} - uses: svenstaro/upload-release-action@v2 - with: - file: devilutionx-xbox-one-series.zip - overwrite: true diff --git a/Source/init.cpp b/Source/init.cpp index 360947149b9..fe3503bde88 100644 --- a/Source/init.cpp +++ b/Source/init.cpp @@ -101,8 +101,14 @@ std::optional LoadMPQ(const std::vector &paths, std::st std::optional archive; std::string mpqAbsPath; std::int32_t error = 0; +#ifdef __DREAMCAST__ + Log("Searching for {}", mpqName); +#endif for (const auto &path : paths) { mpqAbsPath = path + mpqName.data(); +#ifdef __DREAMCAST__ + Log("Checking path: {}", mpqAbsPath); +#endif if ((archive = MpqArchive::Open(mpqAbsPath.c_str(), error))) { LogVerbose(" Found: {} in {}", mpqName, path); return archive; @@ -195,7 +201,12 @@ bool CheckDevilutionXMpqVersion(AssetRef &&ref) bool CheckExtraFontsVersion(AssetRef &&ref) { +#ifdef __DREAMCAST__ + // Bypass version check for Dreamcast to troubleshoot + return false; +#else return !AssetContentsEq(std::move(ref), ExtraFontsVersion); +#endif } } // namespace diff --git a/Source/pfile.cpp b/Source/pfile.cpp index a9bf2ca6e73..430b6b2a7d3 100644 --- a/Source/pfile.cpp +++ b/Source/pfile.cpp @@ -1,3 +1,4 @@ +// ---------------------------------- SECTION 1: FILE HEADER ---------------------------------- /** * @file pfile.cpp * @@ -32,12 +33,38 @@ #include "utils/str_split.hpp" #include "utils/utf8.hpp" +// ---------------------------------- SECTION 2: DREAMCAST SPECIFIC INCLUDES ---------------------------------- #ifdef __DREAMCAST__ #include #include #include + +// Add array of possible VMU paths to try +const char* vmuPaths[] = { + "/vmu/A1", + "/vmu/a1", + "/vmu/A2", + "/vmu/a2", + "/vmu/B1", + "/vmu/b1", + // Additional paths for Flycast compatibility + "/flycast/vmu/vm01.bin", + "/flycast/vmu/vm02.bin", + "/flycast/vmu/vma1.bin", + "/flycast/vmu/vma2.bin", + "/tmp/vmu/A1", + "/tmp/vmu/a1", + "/fs/vmu/A1", + "/fs/vmu/a1", + "/fs/sd/vmu/A1", + "/fs/sd/vmu/a1" +}; +const int numVmuPaths = sizeof(vmuPaths) / sizeof(vmuPaths[0]); +// Current working VMU path index - will be set when one is found working +int workingVmuPath = -1; #endif +// ---------------------------------- SECTION 3: INCLUDE UNPACKED SAVES ---------------------------------- #ifdef UNPACKED_SAVES #include "utils/file_util.h" #else @@ -46,6 +73,12 @@ namespace devilution { +#ifdef __DREAMCAST__ +// Flag to suppress VMU error popups until we've tried all paths +bool suppressVmuErrors = true; +#endif + +// ---------------------------------- SECTION 4: CONSTANTS AND GLOBALS ---------------------------------- #define PASSWORD_SPAWN_SINGLE "adslhfb1" #define PASSWORD_SPAWN_MULTI "lshbkfg1" #define PASSWORD_SINGLE "xrgyrkj1" @@ -58,6 +91,7 @@ namespace { /** List of character names for the character selection screen. */ char hero_names[MAX_CHARACTERS][PlayerNameLength]; +// ---------------------------------- SECTION 5: PATH HANDLING FUNCTIONS ---------------------------------- std::string GetSavePath(uint32_t saveNum, std::string_view savePrefix = {}) { return StrCat(paths::PrefPath(), savePrefix, @@ -149,6 +183,7 @@ void RenameTempToPerm(SaveWriter &saveWriter) assert(!GetPermSaveNames(dwIndex, szPerm)); } +// ---------------------------------- SECTION 6: IO HANDLING FUNCTIONS ---------------------------------- bool ReadHero(SaveReader &archive, PlayerPack *pPack) { size_t read; @@ -191,6 +226,7 @@ SaveWriter GetStashWriter() return SaveWriter(GetStashSavePath()); } +// ---------------------------------- SECTION 7: DEMO MODE FUNCTIONS ---------------------------------- #ifndef DISABLE_DEMOMODE void CopySaveFile(uint32_t saveNum, std::string targetPath) { @@ -209,6 +245,7 @@ void CopySaveFile(uint32_t saveNum, std::string targetPath) } #endif +// ---------------------------------- SECTION 8: PLAYER AND UI FUNCTIONS ---------------------------------- void Game2UiPlayer(const Player &player, _uiheroinfo *heroinfo, bool bHasSaveFile) { CopyUtf8(heroinfo->name, player._pName, sizeof(heroinfo->name)); @@ -284,6 +321,7 @@ std::optional CreateSaveReader(std::string &&path) #endif } +// ---------------------------------- SECTION 9: DEMO MODE COMPARISON FUNCTIONS ---------------------------------- #ifndef DISABLE_DEMOMODE struct CompareInfo { std::unique_ptr &data; @@ -541,6 +579,7 @@ HeroCompareResult CompareSaves(const std::string &actualSavePath, const std::str } #endif // !DISABLE_DEMOMODE +// ---------------------------------- SECTION 10: HERO AND GAME FUNCTIONS ---------------------------------- void pfile_write_hero(SaveWriter &saveWriter, bool writeGameData) { Log("pfile_write_hero with writeGameData = {}", writeGameData); @@ -575,50 +614,109 @@ void RemoveAllInvalidItems(Player &player) } // namespace +// ---------------------------------- SECTION 11: DREAMCAST SPECIFIC VMU FUNCTIONS ---------------------------------- #ifdef UNPACKED_SAVES #ifdef __DREAMCAST__ std::unique_ptr SaveReader::ReadFile(const char *filename, std::size_t &fileSize, int32_t &error) { Log("SaveReader::ReadFile(\"{}\", fileSize, error)", filename); error = 0; - const std::string path = dir_ + filename; - Log("path = \"{}\"", path); - size_t size = 0; - uint8 *contents; - if (fs_load(path.c_str(), &contents) == -1) { - error = 1; - LogError("fs_load(\"{}\", &contents) = -1", path); - app_fatal("SaveReader::ReadFile " + path + " KO"); - return nullptr; + + // If we already know a working path, use it + if (workingVmuPath >= 0) { + // Use the path that worked before + std::string basePath = vmuPaths[workingVmuPath]; + std::string finalDir = basePath + dir_.substr(dir_.find_last_of('/')); + const std::string path = finalDir + filename; + Log("Using known working VMU path = \"{}\"", path); + + uint8 *contents; + // Cast to void** as required by fs_load + if (fs_load(path.c_str(), (void**)&contents) == -1) { + error = 1; + LogError("fs_load(\"{}\", &contents) = -1", path); + return nullptr; + } + + vmu_pkg_t package; + if (vmu_pkg_parse(contents, &package) < 0) { + error = 1; + free(contents); + LogError("vmu_pkg_parse = -1"); + return nullptr; + } + + Log("Parsed package {} ({})", package.desc_short, package.desc_long); + fileSize = package.data_len; + std::unique_ptr result; + result.reset(new std::byte[fileSize]); + memcpy(result.get(), package.data, fileSize); + free(contents); + return result; } - vmu_pkg_t package; - if (vmu_pkg_parse(contents, &package) < 0) { - error = 1; + + // Try all possible VMU paths until one works + for (int i = 0; i < numVmuPaths; i++) { + std::string basePath = vmuPaths[i]; + std::string finalDir = basePath; + // Extract the save directory from the original path (after the /vmu/XX/) + if (dir_.find('/') != std::string::npos) { + finalDir += dir_.substr(dir_.find_last_of('/')); + } + const std::string path = finalDir + filename; + Log("Trying VMU path = \"{}\"", path); + + uint8 *contents; + // Cast to void** as required by fs_load + if (fs_load(path.c_str(), (void**)&contents) == -1) { + LogError("fs_load(\"{}\", &contents) = -1", path); + continue; // Try next path + } + + vmu_pkg_t package; + if (vmu_pkg_parse(contents, &package) < 0) { + free(contents); + LogError("vmu_pkg_parse = -1"); + continue; // Try next path + } + + // Found a working path + workingVmuPath = i; + Log("Found working VMU path: {}", vmuPaths[i]); + Log("Parsed package {} ({})", package.desc_short, package.desc_long); + fileSize = package.data_len; + std::unique_ptr result; + result.reset(new std::byte[fileSize]); + memcpy(result.get(), package.data, fileSize); free(contents); - LogError("vmu_pkg_parse = -1"); - app_fatal("vmu_pkg_parse failed"); - return nullptr; + suppressVmuErrors = false; // Reset error suppression since we found a working path + return result; } - Log("Parsed package {} ({})", package.desc_short, package.desc_long); - fileSize = package.data_len; - std::unique_ptr result; - result.reset(new std::byte[fileSize]); - memcpy(result.get(), package.data, fileSize); - // free(package.data); - free(contents); - return result; + + // No working paths found + error = 1; + LogError("No working VMU paths found for reading"); + suppressVmuErrors = false; // Reset error suppression since we've tried all paths + return nullptr; } bool SaveWriter::WriteFile(const char *filename, const std::byte *data, size_t size) { Log("SaveWriter::WriteFile(\"{}\", data[], {})", filename, size); - const std::string path = dir_ + filename; - Log("dir_ = {}", dir_); - Log("path = {}", path); - const char *baseName = basename(path.c_str()); - - // vmu code - if (dir_.starts_with("/vmu")) { + + // If we already know a working path, use it + if (workingVmuPath >= 0) { + std::string basePath = vmuPaths[workingVmuPath]; + std::string finalDir = basePath; + // Extract the save directory from the original path + if (dir_.find('/') != std::string::npos) { + finalDir += dir_.substr(dir_.find_last_of('/')); + } + const std::string path = finalDir + filename; + Log("Using known working VMU path = \"{}\"", path); + + // We don't need basename here so we'll remove it + vmu_pkg_t package; strcpy(package.app_id, "DevilutionX"); strncpy(package.desc_short, filename, 20); @@ -628,44 +726,133 @@ bool SaveWriter::WriteFile(const char *filename, const std::byte *data, size_t s package.eyecatch_type = VMUPKG_EC_NONE; package.data_len = size; package.data = new uint8[size]; - memcpy(package.data, data, size); + // Use a proper cast for memcpy + memcpy((void*)package.data, (const void*)data, size); uint8 *contents; - size_t packageSize; - if (vmu_pkg_build(&package, &contents, &packageSize) < 0) { + int packageSizeInt; + // Fix the vmu_pkg_build call to use int* instead of size_t* + if (vmu_pkg_build(&package, &contents, &packageSizeInt) < 0) { delete[] package.data; LogError("vmu_pkg_build failed"); - app_fatal("vmu_pkg_build failed"); return false; } - FILE *file = OpenFile(path.c_str(), "wb"); + size_t packageSize = packageSizeInt; + + // Create directory structure if needed + // Extract directory from path + std::string dirPath = path.substr(0, path.find_last_of('/')); + Log("Ensuring directory exists: {}", dirPath); + fs_mkdir(dirPath.c_str()); + + FILE *file = devilution::OpenFile(path.c_str(), "wb"); if (file == nullptr) { delete[] package.data; free(contents); LogError("fopen(\"{}\", \"wb\") = nullptr", path); - app_fatal("SaveReader::WriteFile KO"); return false; } + size_t written = std::fwrite(contents, sizeof(uint8), packageSize, file); if (written != packageSize) { delete[] package.data; free(contents); std::fclose(file); LogError("fwrite(data, {}, {}, file) = {} != -1", sizeof(uint8), packageSize, written); - app_fatal("vmu fwrite call failed"); return false; } + if (std::fclose(file) != 0) { delete[] package.data; free(contents); LogError("fclose(file) = 0"); - app_fatal("fclose(file) = 0"); return false; } + delete[] package.data; free(contents); + suppressVmuErrors = false; // Reset error suppression since we found a working path return true; } + + // Try all possible VMU paths until one works + for (int i = 0; i < numVmuPaths; i++) { + std::string basePath = vmuPaths[i]; + std::string finalDir = basePath; + // Extract the save directory from the original path + if (dir_.find('/') != std::string::npos) { + finalDir += dir_.substr(dir_.find_last_of('/')); + } + const std::string path = finalDir + filename; + Log("Trying VMU path = \"{}\"", path); + + // We don't need basename here so we'll remove it + + vmu_pkg_t package; + strcpy(package.app_id, "DevilutionX"); + strncpy(package.desc_short, filename, 20); + strcpy(package.desc_long, "Diablo 1 save data"); + package.icon_cnt = 0; + package.icon_anim_speed = 0; + package.eyecatch_type = VMUPKG_EC_NONE; + package.data_len = size; + package.data = new uint8[size]; + // Use a proper cast for memcpy + memcpy((void*)package.data, (const void*)data, size); + + uint8 *contents; + int packageSizeInt; + // Fix the vmu_pkg_build call to use int* instead of size_t* + if (vmu_pkg_build(&package, &contents, &packageSizeInt) < 0) { + delete[] package.data; + LogError("vmu_pkg_build failed for path {}", path); + continue; // Try next path + } + size_t packageSize = packageSizeInt; + + // Create directory structure if needed + // Extract directory from path + std::string dirPath = path.substr(0, path.find_last_of('/')); + Log("Ensuring directory exists: {}", dirPath); + fs_mkdir(dirPath.c_str()); + + FILE *file = devilution::OpenFile(path.c_str(), "wb"); + if (file == nullptr) { + delete[] package.data; + free(contents); + LogError("fopen(\"{}\", \"wb\") = nullptr", path); + continue; // Try next path + } + + size_t written = std::fwrite(contents, sizeof(uint8), packageSize, file); + if (written != packageSize) { + delete[] package.data; + free(contents); + std::fclose(file); + LogError("fwrite error for path {}", path); + continue; // Try next path + } + + if (std::fclose(file) != 0) { + delete[] package.data; + free(contents); + LogError("fclose error for path {}", path); + continue; // Try next path + } + + // Found a working path + workingVmuPath = i; + Log("Found working VMU path: {}", vmuPaths[i]); + delete[] package.data; + free(contents); + suppressVmuErrors = false; // Reset error suppression since we found a working path + return true; + } + + // No working paths found + LogError("No working VMU paths found for writing"); + suppressVmuErrors = false; // Reset error suppression since we've tried all paths + return false; } #else std::unique_ptr SaveReader::ReadFile(const char *filename, std::size_t &fileSize, int32_t &error) @@ -679,7 +866,7 @@ std::unique_ptr SaveReader::ReadFile(const char *filename, std::siz return nullptr; } fileSize = size; - FILE *file = OpenFile(path.c_str(), "rb"); + FILE *file = devilution::OpenFile(path.c_str(), "rb"); if (file == nullptr) { error = 1; return nullptr; @@ -697,7 +884,7 @@ std::unique_ptr SaveReader::ReadFile(const char *filename, std::siz bool SaveWriter::WriteFile(const char *filename, const std::byte *data, size_t size) { const std::string path = dir_ + filename; - FILE *file = OpenFile(path.c_str(), "wb"); + FILE *file = devilution::OpenFile(path.c_str(), "wb"); if (file == nullptr) { return false; } @@ -719,7 +906,7 @@ void SaveWriter::RemoveHashEntries(bool (*fnGetName)(uint8_t, char *)) } } #endif // def UNPACKED_SAVES - +// ---------------------------------- SECTION 12: PUBLIC API FUNCTIONS ---------------------------------- std::optional OpenSaveArchive(uint32_t saveNum) { return CreateSaveReader(GetSavePath(saveNum)); @@ -973,4 +1160,4 @@ void pfile_update(bool forceSave) sfile_write_stash(); } -} // namespace devilution +} // namespace devilution \ No newline at end of file diff --git a/Source/restrict.cpp b/Source/restrict.cpp index 654bdb0ab35..6fd93f2936f 100644 --- a/Source/restrict.cpp +++ b/Source/restrict.cpp @@ -17,6 +17,14 @@ void ReadOnlyTest() const std::string path = paths::PrefPath() + "Diablo1ReadOnlyTest.foo"; SDL_RWops *file = SDL_RWFromFile(path.c_str(), "w"); if (file == nullptr) { +#ifdef __DREAMCAST__ + // Check if the error is related to VMU paths and we're in suppression mode + extern bool suppressVmuErrors; + if (suppressVmuErrors && paths::PrefPath().find("/vmu") != std::string::npos) { + // Skip showing the error dialog for VMU paths while we're trying them + return; + } +#endif DirErrorDlg(paths::PrefPath()); }