diff --git a/.clang-tidy b/.clang-tidy index 11e1f9b315..587796e895 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,9 +2,13 @@ Checks: > -*, cppcoreguidelines-macro-usage, + modernize-concat-nested-namespaces, + modernize-deprecated-headers, modernize-use-bool-literals, modernize-use-nullptr, modernize-use-override, + readability-container-size-empty, + readability-redundant-typename, readability-uppercase-literal-suffix CheckOptions: - key: cppcoreguidelines-macro-usage.AllowedRegexp diff --git a/.github/labeler.yml b/.github/labeler.yml index ceab8d4665..cd4be7e588 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -55,7 +55,7 @@ - changed-files: - any-glob-to-any-file: - 'src/openrct2/platform/*' -'android': +'Android (OS)': - changed-files: - any-glob-to-any-file: - 'src/openrct2-android/*' diff --git a/.github/workflows/backtrace-commit-fix.yml b/.github/workflows/backtrace-commit-fix.yml index 5297d55455..613daeb005 100644 --- a/.github/workflows/backtrace-commit-fix.yml +++ b/.github/workflows/backtrace-commit-fix.yml @@ -5,7 +5,7 @@ on: - opened jobs: backtrace_commit_correction: - runs-on: ubuntu-latest + runs-on: ubuntu-slim env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE: ${{ github.event.issue.html_url }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7a68e3d2c..59750c1f3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ concurrency: jobs: build_variables: name: Get version info - runs-on: ubuntu-latest + runs-on: ubuntu-latest # This job is too heavy for ubuntu-slim. It takes almost a minute to checkout the code on slim vs 23s on ubuntu-latest. # We want to sign tagged releases with release certificates, but it is only allowed to be ran manually. # Disable automatic runs for tags and force release signing for tags. if: | @@ -62,7 +62,7 @@ jobs: steps: # We need to fetch entire repo to get the tags and correctly run `describe` - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 # We cannot use proudust/gh-describe, as it reports incorrect (too short) short-sha @@ -119,7 +119,7 @@ jobs: # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # steps: # - name: Checkout - # uses: actions/checkout@v4 + # uses: actions/checkout@v6 # with: # fetch-depth: 0 # - name: Lint Commit Messages @@ -129,7 +129,7 @@ jobs: check-code-formatting: name: Check code formatting runs-on: ubuntu-latest - container: openrct2/openrct2-build:24-format + container: ghcr.io/openrct2/openrct2-build:26-format permissions: pull-requests: write contents: read @@ -138,28 +138,28 @@ jobs: shell: sh steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - run: git config --global --add safe.directory $PWD - name: Run clang-format run: scripts/check-code-formatting check-changelog-formatting: name: Check changelog formatting - runs-on: ubuntu-latest + runs-on: ubuntu-slim defaults: run: shell: bash steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Run check-changelog-formatting run: scripts/check-changelog-formatting g2dat: name: Graphics .dat files - runs-on: ubuntu-latest + runs-on: ubuntu-slim needs: build_variables steps: - name: Checkout OpenRCT2 - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: path: OpenRCT2 - name: Download gxc @@ -175,7 +175,7 @@ jobs: gxc build fonts.dat OpenRCT2/resources/fonts/sprites.json gxc build tracks.dat OpenRCT2/resources/tracks/sprites.json - name: Upload graphics .dat files - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: graphics-${{ needs.build_variables.outputs.name }} path: | @@ -204,14 +204,14 @@ jobs: echo "CONFIGURATION=Release" >> "$GITHUB_ENV" fi - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Install MSVC problem matcher uses: ammaraskar/msvc-problem-matcher@master - name: Build OpenRCT2 run: . scripts/setenv && build - name: Upload unsigned binaries id: upload-windows-binaries-unsigned - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-windows-unsigned-${{ matrix.platform }} path: | @@ -223,7 +223,7 @@ jobs: env: SIGNPATH_API_TOKEN: ${{ secrets.SIGNPATH_API_TOKEN }} if: ${{ needs.build_variables.outputs.sign == 'true' }} - uses: signpath/github-action-submit-signing-request@v1 + uses: signpath/github-action-submit-signing-request@v2 with: api-token: '${{ secrets.SIGNPATH_API_TOKEN }}' organization-id: 645b821f-6283-45e1-8198-264997072801 @@ -242,7 +242,7 @@ jobs: mv files-signed/openrct2.exe bin/openrct2.exe - name: Download graphics .dat files on ARM64 if: matrix.platform == 'arm64' - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: graphics-${{ needs.build_variables.outputs.name }} path: bin/data @@ -259,14 +259,14 @@ jobs: mv artifacts/openrct2-installer-*.exe artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-windows-installer-$PLATFORM.exe mv artifacts/openrct2-symbols-*.zip artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-windows-symbols-$PLATFORM.zip - name: Upload portable artifact (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-portable-${{ matrix.platform }} path: artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-windows-portable-${{ matrix.platform }}.zip if-no-files-found: error - name: Upload unsigned installer artifact (CI) id: upload-windows-installer-unsigned - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-installer-${{ matrix.platform }}-unsigned path: artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-windows-installer-${{ matrix.platform }}.exe @@ -274,7 +274,7 @@ jobs: - name: Sign installer id: sign-installer if: ${{ needs.build_variables.outputs.sign == 'true' }} - uses: signpath/github-action-submit-signing-request@v1 + uses: signpath/github-action-submit-signing-request@v2 with: api-token: '${{ secrets.SIGNPATH_API_TOKEN }}' organization-id: 645b821f-6283-45e1-8198-264997072801 @@ -290,13 +290,13 @@ jobs: - name: Upload signed installer artifact (CI) id: upload-windows-installer-signed if: ${{ needs.build_variables.outputs.sign == 'true' }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-installer-${{ matrix.platform }} path: files-signed/OpenRCT2-${{ needs.build_variables.outputs.name }}-windows-installer-${{ matrix.platform }}.exe if-no-files-found: error - name: Upload symbols artifact (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-symbols-${{ matrix.platform }} path: artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-windows-symbols-${{ matrix.platform }}.zip @@ -321,7 +321,7 @@ jobs: name: Windows (${{ matrix.platform_name }}) using mingw runs-on: ubuntu-latest needs: [check-code-formatting, build_variables] - container: openrct2/openrct2-build:24-mingw + container: ghcr.io/openrct2/openrct2-build:26-mingw strategy: fail-fast: false matrix: @@ -333,9 +333,9 @@ jobs: build_flags: -DBUILD_SHARED_LIBS=ON -DENABLE_SCRIPTING=ON steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: ${{ matrix.cache_key }} - name: Install GCC problem matcher @@ -348,7 +348,7 @@ jobs: ninja -k0 - name: Upload artifacts (CI) if: matrix.platform == 'NT5.1' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-Windows-mingw-${{ matrix.platform }} path: bin/openrct2.exe @@ -375,9 +375,9 @@ jobs: run_tests: true steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: ${{ matrix.cache_key }} - name: Install GCC problem matcher @@ -395,7 +395,7 @@ jobs: cd artifacts zip -rqy openrct2-macos.zip OpenRCT2.app - name: Upload artifacts (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ runner.os }}-${{ matrix.arch }}-cmake path: artifacts/openrct2-macos.zip @@ -414,14 +414,14 @@ jobs: needs: [macos-cmake, build_variables] steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: download x64 app bundle - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: OpenRCT2-${{ runner.os }}-x64-cmake path: macos_universal/x64 - name: download arm64 app bundle - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: OpenRCT2-${{ runner.os }}-arm64-cmake path: macos_universal/arm64 @@ -441,7 +441,7 @@ jobs: cd artifacts zip -rqy OpenRCT2-${{ needs.build_variables.outputs.name }}-macos-universal.zip OpenRCT2.app - name: Upload artifacts (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-universal path: artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-macos-universal.zip @@ -459,23 +459,28 @@ jobs: - platform: x86_64 distro: Ubuntu release: noble - image: openrct2/openrct2-build:24-noble + image: ghcr.io/openrct2/openrct2-build:26-noble build_flags: -DCMAKE_POSITION_INDEPENDENT_CODE=on -DCMAKE_CXX_FLAGS="-g1 -gz -fno-var-tracking-assignments" + - platform: x86_64 + distro: Ubuntu + release: resolute + image: ghcr.io/openrct2/openrct2-build:26-resolute + build_flags: -DCMAKE_POSITION_INDEPENDENT_CODE=on -DCMAKE_CXX_FLAGS="-g1 -gz" - platform: x86_64 distro: Debian release: bookworm - image: openrct2/openrct2-build:24-bookworm + image: ghcr.io/openrct2/openrct2-build:26-bookworm build_flags: -DCMAKE_POSITION_INDEPENDENT_CODE=on -DCMAKE_CXX_FLAGS="-g1 -gz -fno-var-tracking-assignments" -DWITH_TESTS=off - platform: x86_64 distro: Debian release: trixie - image: openrct2/openrct2-build:24-trixie + image: ghcr.io/openrct2/openrct2-build:26-trixie build_flags: -DCMAKE_POSITION_INDEPENDENT_CODE=on -DCMAKE_CXX_FLAGS="-g1 -gz -fno-var-tracking-assignments" -DWITH_TESTS=off steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: linux-${{ matrix.platform }}-${{ matrix.distro }}-${{ matrix.release }} - name: Get pre-reqs @@ -488,7 +493,7 @@ jobs: - name: Build artifacts run: . scripts/setenv -q && build-portable artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-${{ matrix.release }}-${{ matrix.platform }}.tar.gz bin/install/usr - name: Upload artifacts (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-${{ matrix.release }}-${{ matrix.platform }} path: artifacts @@ -502,9 +507,9 @@ jobs: container: openrct2/openrct2-build:24-jammy steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: linux-appimage - name: Get pre-reqs @@ -518,7 +523,7 @@ jobs: NO_STRIP: true # https://github.com/linuxdeploy/linuxdeploy/blob/d2557d616749c325a61058049e41a2d35ffce924/src/core/appdir.cpp#L248 run: . scripts/setenv -q && build-appimage - name: Upload artifacts (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-AppImage path: artifacts @@ -530,7 +535,7 @@ jobs: steps: - name: Checkout image if: github.repository == 'OpenRCT2/OpenRCT2' && github.ref == 'refs/heads/develop' - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: OpenRCT2/openrct2-docker - name: Build image @@ -554,12 +559,12 @@ jobs: name: Ubuntu Linux (noble, debug, [http, network, flac, vorbis OpenGL] disabled) using clang runs-on: ubuntu-latest needs: [check-code-formatting, build_variables] - container: openrct2/openrct2-build:24-noble + container: ghcr.io/openrct2/openrct2-build:26-noble steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: linux-clang - name: Install GCC problem matcher @@ -570,12 +575,12 @@ jobs: name: Ubuntu Linux (debug) using clang, coverage enabled runs-on: ubuntu-latest needs: [check-code-formatting, build_variables] - container: openrct2/openrct2-build:24-noble + container: ghcr.io/openrct2/openrct2-build:26-noble steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: linux-clang-tests - name: Install GCC problem matcher @@ -599,7 +604,7 @@ jobs: xz -1v coverage.json xz -1v OpenRCT2Tests - name: Upload artifacts (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-${{ runner.os }}-coverage path: | @@ -607,49 +612,110 @@ jobs: bin/coverage.json* bin/OpenRCT2Tests.xz if-no-files-found: error + android-libs: + name: Android (${{ matrix.arch }}) + runs-on: ubuntu-latest + needs: [check-code-formatting, build_variables] + container: ghcr.io/openrct2/openrct2-build:26-android + strategy: + fail-fast: false + matrix: + arch: [armeabi-v7a, arm64-v8a, x86_64] + steps: + - name: Checkout + uses: actions/checkout@v6 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2.20 + with: + key: android-${{ matrix.arch }} + - name: Cache Gradle + uses: actions/cache@v5 + with: + # The gradle cache is by default ~/.gradle/caches, but ~ gets resolved by GitHub Actions to the runner's + # home directory (/home/github), not the user inside the container (/root). Name the path explicitly. + path: /root/.gradle/caches + key: gradle-${{ hashFiles('src/openrct2-android/gradle.properties') }} + - name: Install GCC problem matcher + uses: ammaraskar/gcc-problem-matcher@master + - name: Build Native Libs + run: | + . scripts/setenv + pushd src/openrct2-android + ./gradlew app:externalNativeBuildRelease -PabiFilter=${{ matrix.arch }} + popd + - name: Upload Native Libs + uses: actions/upload-artifact@v6 + with: + name: android-libs-${{ matrix.arch }} + path: src/openrct2-android/app/build/intermediates/cmake/release/obj/${{ matrix.arch }} + if-no-files-found: error + android: name: Android runs-on: ubuntu-latest - needs: [check-code-formatting, build_variables] - container: openrct2/openrct2-build:24-android + needs: [android-libs, build_variables] + container: openrct2/openrct2-build:25-android steps: - name: Checkout - uses: actions/checkout@v4 - - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: actions/checkout@v6 + - name: Cache Gradle + uses: actions/cache@v5 with: - key: android + # The gradle cache is by default ~/.gradle/caches, but ~ gets resolved by GitHub Actions to the runner's + # home directory (/home/github), not the user inside the container (/root). Name the path explicitly. + path: /root/.gradle/caches + key: gradle-${{ hashFiles('src/openrct2-android/gradle.properties') }} - name: Setup keystore run: | echo "${{ secrets.OPENRCT2_KEYSTORE_CONTENTS }}" | base64 -d > keystore.jks echo "OPENRCT2_KEYSTORE_FILE=${{ github.workspace }}/keystore.jks" >> $GITHUB_ENV echo "OPENRCT2_KEYSTORE_PASSWORD=${{ secrets.OPENRCT2_KEYSTORE_PASSWORD }}" >> $GITHUB_ENV - - name: Install GCC problem matcher - uses: ammaraskar/gcc-problem-matcher@master + - name: Download all libs + uses: actions/download-artifact@v7 + with: + pattern: android-libs-* + path: artifacts/android-libs + - name: Move libs to project + run: | + mkdir -p src/openrct2-android/app/libs + for arch in armeabi-v7a arm64-v8a x86_64; do + if [ -d "artifacts/android-libs/android-libs-$arch" ]; then + mkdir -p src/openrct2-android/app/libs/$arch + mv artifacts/android-libs/android-libs-$arch/* src/openrct2-android/app/libs/$arch/ + else + echo "::warning title=Missing libraries::Warning: No libs found for $arch" + fi + done - name: Build OpenRCT2 run: | . scripts/setenv pushd src/openrct2-android - ./gradlew app:assembleRelease + ./gradlew app:assembleRelease -PskipNativeBuild popd mkdir -p artifacts - mv src/openrct2-android/app/build/outputs/apk/release/app-release.apk artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-android-arm.apk + mv src/openrct2-android/app/build/outputs/apk/release/app-release.apk artifacts/OpenRCT2-${{ needs.build_variables.outputs.name }}-android.apk - name: Upload artifacts (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: OpenRCT2-${{ needs.build_variables.outputs.name }}-Android path: artifacts if-no-files-found: error + - name: Upload gradle issues + uses: actions/upload-artifact@v6 + with: + name: OpenRCT2-${{ needs.build_variables.outputs.name }}-gradle-issues + path: src/openrct2-android/build/reports/problems/problems-report.html + if-no-files-found: ignore emscripten: name: Emscripten runs-on: ubuntu-latest needs: [check-code-formatting, build_variables] - container: openrct2/openrct2-build:24-emscripten + container: ghcr.io/openrct2/openrct2-build:26-emscripten steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: ccache - uses: hendrikmuhs/ccache-action@v1.2.18 + uses: hendrikmuhs/ccache-action@v1.2.20 with: key: emscripten - name: Install GCC problem matcher @@ -659,33 +725,45 @@ jobs: . scripts/setenv build-emscripten - name: Upload artifacts (CI) - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: path: build/www name: OpenRCT2-${{ needs.build_variables.outputs.name }}-emscripten release: name: Release - runs-on: ubuntu-latest + runs-on: ubuntu-slim needs: [build_variables, linux-portable, android, linux-appimage, macos-universal, windows] steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: sparse-checkout: | distribution/changelog.txt - name: Download artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: - merge-multiple: true - # Having multiple artifacts named the same might be confusing to the users. Drop the unsigned versions. - - name: Remove unsigned artifacts + merge-multiple: false + # Only remove unsigned artifacts if signing is enabled, otherwise we might end up with no artifacts at all + - name: Remove unsigned artifacts and flatten run: | - rm -rf *unsigned* + ls -lR + if [[ "${{ needs.build_variables.outputs.sign }}" == "true" ]]; then + echo "Signing enabled, removing unsigned artifacts" + find . -maxdepth 1 -name '*unsigned*' -type d -exec rm -rf {} + 2>/dev/null || true + echo "Unsigned artifacts removed" + else + echo "Signing not enabled, keeping unsigned artifacts" + fi + # Flatten remaining artifact directories + find . -maxdepth 2 -type f \( -path './OpenRCT2-*/*' -o -path './graphics-*/*' \) -exec mv {} . \; + # Clean up empty directories + find . -maxdepth 1 -type d \( -name 'OpenRCT2-*' -o -name 'graphics-*' \) -empty -delete 2>/dev/null || true + ls -lR - name: Concatenate sha256 files run: | ls -lR pushd ${{ github.workspace }} - sha256sum OpenRCT2-* > OpenRCT2-${{ needs.build_variables.outputs.name }}-sha256sums.txt + find . -maxdepth 1 -type f -name 'OpenRCT2-*' -print0 | xargs -0 sha256sum > OpenRCT2-${{ needs.build_variables.outputs.name }}-sha256sums.txt popd - name: Create release notes run: | @@ -715,7 +793,7 @@ jobs: tag_name: ${{ needs.build_variables.outputs.tag }} # The upload to binaries repository is done from develop only - name: Create tag for binaries repository - uses: actions/github-script@v5 + uses: actions/github-script@v8 if: ${{ needs.build_variables.outputs.push }} with: github-token: ${{ secrets.OPENRCT2_BINARIES_CI_UPLOAD }} diff --git a/.github/workflows/dependent-issues.yml b/.github/workflows/dependent-issues.yml index 92b57e72c4..a0fe970bff 100644 --- a/.github/workflows/dependent-issues.yml +++ b/.github/workflows/dependent-issues.yml @@ -18,7 +18,7 @@ on: - cron: '23 */2 * * *' jobs: check: - runs-on: ubuntu-latest + runs-on: ubuntu-slim steps: - uses: z0al/dependent-issues@v1 env: diff --git a/.github/workflows/label-prs.yml b/.github/workflows/label-prs.yml index 405ec01808..a3c6f4e2d1 100644 --- a/.github/workflows/label-prs.yml +++ b/.github/workflows/label-prs.yml @@ -10,7 +10,7 @@ jobs: contents: read issues: write # automatically creates labels pull-requests: write # assigning labels to PRs - runs-on: ubuntu-latest + runs-on: ubuntu-slim if: github.repository == 'OpenRCT2/OpenRCT2' steps: - uses: actions/labeler@v6 diff --git a/.github/workflows/localisation.yml b/.github/workflows/localisation.yml index 238c01b699..c6f5923b7e 100644 --- a/.github/workflows/localisation.yml +++ b/.github/workflows/localisation.yml @@ -6,7 +6,7 @@ jobs: merge-localisation: name: Merge Localisation if: github.repository == 'OpenRCT2/OpenRCT2' - runs-on: ubuntu-latest + runs-on: ubuntu-slim steps: - name: Store private SSH run: | diff --git a/.github/workflows/stale-backtrace-issues.yml b/.github/workflows/stale-backtrace-issues.yml index d5233e80b0..15a38a7c4b 100644 --- a/.github/workflows/stale-backtrace-issues.yml +++ b/.github/workflows/stale-backtrace-issues.yml @@ -5,7 +5,7 @@ on: jobs: stale: - runs-on: ubuntu-latest + runs-on: ubuntu-slim if: github.repository == 'OpenRCT2/OpenRCT2' steps: - uses: actions/stale@v8 diff --git a/.github/workflows/stale-prs.yml b/.github/workflows/stale-prs.yml index eb0128a7ce..425b623177 100644 --- a/.github/workflows/stale-prs.yml +++ b/.github/workflows/stale-prs.yml @@ -5,7 +5,7 @@ on: jobs: stale: - runs-on: ubuntu-latest + runs-on: ubuntu-slim if: github.repository == 'OpenRCT2/OpenRCT2' steps: - uses: actions/stale@v8 diff --git a/CMakeLists.txt b/CMakeLists.txt index 252009a7cd..a79fe8893d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,25 +66,22 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}") -set(TITLE_SEQUENCE_VERSION "0.4.26") -set(TITLE_SEQUENCE_URL "https://github.com/OpenRCT2/title-sequences/releases/download/v${TITLE_SEQUENCE_VERSION}/title-sequences.zip") -set(TITLE_SEQUENCE_SHA256 "dabb9787b1576342fca4dd9f64b3f8cfa04a7e6ce9c2bb9610f47b762905c858") +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/assets.json" ASSETS_JSON) -set(OBJECTS_VERSION "1.7.6") -set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v${OBJECTS_VERSION}/objects.zip") -set(OBJECTS_SHA256 "6aca2eb441fbe8c022ff84d59fb51ed7ea577756640970dc989eab685ff45696") +string(JSON TITLE_SEQUENCE_URL GET "${ASSETS_JSON}" "title-sequences" url) +string(JSON TITLE_SEQUENCE_SHA256 GET "${ASSETS_JSON}" "title-sequences" sha256) -set(OPENSFX_VERSION "1.0.6") -set(OPENSFX_URL "https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v${OPENSFX_VERSION}/opensound.zip") -set(OPENSFX_SHA256 "06b90f3e19c216752df441d551b26a9e3e1ba7755bdd2102504b73bf993608be") +string(JSON OBJECTS_URL GET "${ASSETS_JSON}" objects url) +string(JSON OBJECTS_SHA256 GET "${ASSETS_JSON}" objects sha256) -set(OPENMSX_VERSION "1.6.1") -set(OPENMSX_URL "https://github.com/OpenRCT2/OpenMusic/releases/download/v${OPENMSX_VERSION}/openmusic.zip") -set(OPENMSX_SHA256 "994b350d3b180ee1cb9619fe27f7ebae3a1a5232840c4bd47a89f33fa89de1a1") +string(JSON OPENSFX_URL GET "${ASSETS_JSON}" opensfx url) +string(JSON OPENSFX_SHA256 GET "${ASSETS_JSON}" opensfx sha256) -set(REPLAYS_VERSION "0.0.92") -set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v${REPLAYS_VERSION}/replays.zip") -set(REPLAYS_SHA256 "455a19172a8df81b935a942bbbda20167b4740b34653fdb74127740686bf4cbe") +string(JSON OPENMUSIC_URL GET "${ASSETS_JSON}" openmusic url) +string(JSON OPENMUSIC_SHA256 GET "${ASSETS_JSON}" openmusic sha256) + +string(JSON REPLAYS_URL GET "${ASSETS_JSON}" replays url) +string(JSON REPLAYS_SHA256 GET "${ASSETS_JSON}" replays sha256) option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(WITH_TESTS "Build tests") @@ -93,7 +90,7 @@ option(APPIMAGE "Create an appimage build (-rpath=$ORIGIN/../lib)" OFF) option(DOWNLOAD_TITLE_SEQUENCES "Download title sequences during installation." ON) option(DOWNLOAD_OBJECTS "Download objects during installation." ON) option(DOWNLOAD_OPENSFX "Download OpenSoundEffects during installation." ON) -option(DOWNLOAD_OPENMSX "Download OpenMusic during installation." ON) +option(DOWNLOAD_OPENMUSIC "Download OpenMusic during installation." ON) CMAKE_DEPENDENT_OPTION(DOWNLOAD_REPLAYS "Download replays during installation." ON "WITH_TESTS" OFF) CMAKE_DEPENDENT_OPTION(MACOS_USE_DEPENDENCIES "Use OpenRCT2 dependencies instead of system libraries" ON @@ -149,7 +146,6 @@ if (MACOS_USE_DEPENDENCIES) set(MACOS_DYLIBS_URL "https://github.com/OpenRCT2/Dependencies/releases/download/v${MACOS_DYLIBS_VERSION}/${MACOS_DYLIBS_ZIPFILE}") download_openrct2_zip( - ZIP_VERSION ${MACOS_DYLIBS_VERSION} DOWNLOAD_DIR ${MACOS_DYLIBS_DIR} ZIP_URL ${MACOS_DYLIBS_URL} SHA256 ${MACOS_DYLIBS_SHA256} @@ -406,7 +402,7 @@ if (NOT CMAKE_CROSSCOMPILING) file(GLOB_RECURSE dependent_files CONFIGURE_DEPENDS "${ROOT_DIR}/resources/${graphics_file}/*") add_custom_command( OUTPUT ${output_file} - COMMAND ./openrct2-cli sprite build "${CMAKE_BINARY_DIR}/${output_file}" "${json_file}" + COMMAND ./openrct2-cli sprite build "${CMAKE_BINARY_DIR}/${output_file}" "${json_file}" silent WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" DEPENDS ${dependent_files} ) @@ -449,7 +445,6 @@ if (NOT MACOS_BUNDLE OR (MACOS_BUNDLE AND WITH_TESTS)) install(CODE " include(${ROOT_DIR}/cmake/download.cmake) download_openrct2_zip( - ZIP_VERSION ${TITLE_SEQUENCE_VERSION} DOWNLOAD_DIR \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/openrct2/sequence/ SKIP_IF_EXISTS ${CMAKE_SOURCE_DIR}/data/sequence/ ZIP_URL ${TITLE_SEQUENCE_URL} @@ -463,7 +458,6 @@ if (NOT MACOS_BUNDLE OR (MACOS_BUNDLE AND WITH_TESTS)) install(CODE " include(${ROOT_DIR}/cmake/download.cmake) download_openrct2_zip( - ZIP_VERSION ${OBJECTS_VERSION} DOWNLOAD_DIR \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/openrct2/object/ SKIP_IF_EXISTS ${CMAKE_SOURCE_DIR}/data/object/ ZIP_URL ${OBJECTS_URL} @@ -474,22 +468,20 @@ if (NOT MACOS_BUNDLE OR (MACOS_BUNDLE AND WITH_TESTS)) install(CODE " include(${ROOT_DIR}/cmake/download.cmake) download_openrct2_zip( - ZIP_VERSION ${OPENSFX_VERSION} SKIP_IF_EXISTS ${CMAKE_SOURCE_DIR}/data/assetpack/openrct2.sound.parkap DOWNLOAD_DIR \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/openrct2/ ZIP_URL ${OPENSFX_URL} SHA256 ${OPENSFX_SHA256} )") endif () - if (DOWNLOAD_OPENMSX) + if (DOWNLOAD_OPENMUSIC) install(CODE " include(${ROOT_DIR}/cmake/download.cmake) download_openrct2_zip( - ZIP_VERSION ${OPENMSX_VERSION} SKIP_IF_EXISTS ${CMAKE_SOURCE_DIR}/data/assetpack/openrct2.music.alternative.parkap DOWNLOAD_DIR \$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/openrct2/ - ZIP_URL ${OPENMSX_URL} - SHA256 ${OPENMSX_SHA256} + ZIP_URL ${OPENMUSIC_URL} + SHA256 ${OPENMUSIC_SHA256} )") endif () if (DOWNLOAD_REPLAYS) @@ -497,7 +489,6 @@ if (NOT MACOS_BUNDLE OR (MACOS_BUNDLE AND WITH_TESTS)) install(CODE " include(${ROOT_DIR}/cmake/download.cmake) download_openrct2_zip( - ZIP_VERSION ${REPLAYS_VERSION} DOWNLOAD_DIR \${CMAKE_CURRENT_BINARY_DIR}/testdata/replays/ ZIP_URL ${REPLAYS_URL} SHA256 ${REPLAYS_SHA256} diff --git a/assets.json b/assets.json new file mode 100644 index 0000000000..9b05f0f4e7 --- /dev/null +++ b/assets.json @@ -0,0 +1,22 @@ +{ + "objects": { + "url": "https://github.com/OpenRCT2/objects/releases/download/v1.7.6/objects.zip", + "sha256": "6aca2eb441fbe8c022ff84d59fb51ed7ea577756640970dc989eab685ff45696" + }, + "openmusic": { + "url": "https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6.1/openmusic.zip", + "sha256": "994b350d3b180ee1cb9619fe27f7ebae3a1a5232840c4bd47a89f33fa89de1a1" + }, + "opensfx": { + "url": "https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v1.0.6/opensound.zip", + "sha256": "06b90f3e19c216752df441d551b26a9e3e1ba7755bdd2102504b73bf993608be" + }, + "title-sequences": { + "url": "https://github.com/OpenRCT2/title-sequences/releases/download/v0.4.26/title-sequences.zip", + "sha256": "dabb9787b1576342fca4dd9f64b3f8cfa04a7e6ce9c2bb9610f47b762905c858" + }, + "replays": { + "url": "https://github.com/OpenRCT2/replays/releases/download/v0.0.92/replays.zip", + "sha256": "455a19172a8df81b935a942bbbda20167b4740b34653fdb74127740686bf4cbe" + } +} diff --git a/cmake/FindSpeexDSP.cmake b/cmake/FindSpeexDSP.cmake deleted file mode 100644 index d1267499fd..0000000000 --- a/cmake/FindSpeexDSP.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# -# - Find speexdsp libraries -# -# SPEEXDSP_INCLUDE_DIRS - where to find speexdsp headers. -# SPEEXDSP_LIBRARIES - List of libraries when using speexdsp. -# SPEEXDSP_FOUND - True if speexdsp is found. - -find_package(PkgConfig QUIET) -pkg_search_module(PC_SPEEXDSP QUIET speexdsp) - -find_path(SPEEXDSP_INCLUDE_DIR - NAMES - speex/speex_resampler.h - HINTS - ${PC_SPEEXDSP_INCLUDE_DIRS} -) - -find_library(SPEEXDSP_LIBRARY - NAMES - speexdsp - HINTS - ${PC_SPEEXDSP_LIBRARY_DIRS} -) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SpeexDSP - REQUIRED_VARS SPEEXDSP_LIBRARY SPEEXDSP_INCLUDE_DIR - VERSION_VAR PC_SPEEXDSP_VERSION) - -if(SPEEXDSP_FOUND) - set(SPEEXDSP_LIBRARIES ${SPEEXDSP_LIBRARY}) - set(SPEEXDSP_INCLUDE_DIRS ${SPEEXDSP_INCLUDE_DIR}) - set(SPEEX_INCLUDE_DIRS ${SPEEXDSP_INCLUDE_DIR}) -else() - set(SPEEXDSP_LIBRARIES) - set(SPEEXDSP_INCLUDE_DIRS) - set(SPEEX_INCLUDE_DIRS) -endif() - -mark_as_advanced(SPEEXDSP_LIBRARIES SPEEXDSP_INCLUDE_DIRS SPEEX_INCLUDE_DIRS) diff --git a/cmake/download.cmake b/cmake/download.cmake index 0fa9ccfa50..e83aa1e956 100644 --- a/cmake/download.cmake +++ b/cmake/download.cmake @@ -1,5 +1,5 @@ function(download_openrct2_zip) - set(oneValueArgs ZIP_VERSION DOWNLOAD_DIR ZIP_URL SHA256) + set(oneValueArgs DOWNLOAD_DIR ZIP_URL SHA256) set(multiValueArgs SKIP_IF_EXISTS) cmake_parse_arguments(DOWNLOAD_OPENRCT2 "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) @@ -8,10 +8,11 @@ function(download_openrct2_zip) if (NOT EXISTS ${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}) set(DOWNLOAD_ZIP 1) + file(MAKE_DIRECTORY "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}") else () if (EXISTS "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}.zipversion") file(READ "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}.zipversion" DOWNLOAD_OPENRCT2_CACHED_VERSION) - if (NOT ${DOWNLOAD_OPENRCT2_CACHED_VERSION} STREQUAL ${DOWNLOAD_OPENRCT2_ZIP_VERSION}) + if (NOT ${DOWNLOAD_OPENRCT2_CACHED_VERSION} STREQUAL ${DOWNLOAD_OPENRCT2_ZIP_URL}) message("Cache ${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR} not up to date") set(DOWNLOAD_ZIP 1) endif () @@ -43,7 +44,7 @@ function(download_openrct2_zip) endif() file(WRITE "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}.zipversion" - "${DOWNLOAD_OPENRCT2_ZIP_VERSION}" + "${DOWNLOAD_OPENRCT2_ZIP_URL}" ) file(REMOVE "${DOWNLOAD_OPENRCT2_DOWNLOAD_DIR}/${ZIP_FILE_NAME}") endif () diff --git a/contributors.md b/contributors.md index e4149d51e3..9dc00978c8 100644 --- a/contributors.md +++ b/contributors.md @@ -256,6 +256,7 @@ Appreciation for contributors who have provided substantial work, but are no lon * Ruohao (Jater) Xu (jaterx) * Marcel Vos (MarcelVos96) * Jonas Doggart +* (pg805) ## Toolchain * (Balletie) - macOS diff --git a/data/language/ar-EG.txt b/data/language/ar-EG.txt index 3949c3e45a..f8ef1ad8b7 100644 --- a/data/language/ar-EG.txt +++ b/data/language/ar-EG.txt @@ -551,7 +551,6 @@ STR_1168 :الإعدادات STR_1169 :(لا شئ) STR_1170 :{STRING} STR_1171 :{RED} مغلق -STR_1172 :{YELLOW}{STRINGID} STR_1173 : ابني ممشي وخطوط إنتظار STR_1174 :Banner sign in the way STR_1175 :Can’t build this on sloped footpath @@ -1108,7 +1107,6 @@ STR_1727 :حقوق الإنشاء ليست للبيع! STR_1728 :لا يمكنك شراء حقوق البناء هُنا STR_1729 :الأرض ليست مملوكة للحديقة! STR_1730 :{RED}مغلقة -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :بناء STR_1733 :الوضع STR_1734 :{WINDOW_COLOUR_2}عدد اللفات: @@ -1149,7 +1147,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Only one on-ride photo section allowed per ride STR_1774 :Only one cable lift hill allowed per ride STR_1777 :موسيقي الرحلة -STR_1778 :{STRINGID} - - STR_1790 :Select uniform colour for this type of staff STR_1791 :{WINDOW_COLOUR_2}Uniform colour: STR_1792 :Responding to {STRINGID} breakdown call diff --git a/data/language/ca-ES.txt b/data/language/ca-ES.txt index ad23410ca7..b7d8200469 100644 --- a/data/language/ca-ES.txt +++ b/data/language/ca-ES.txt @@ -557,7 +557,6 @@ STR_1168 :Opcions STR_1169 :(Cap) STR_1170 :{STRING} STR_1171 :{RED}Tancada -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Construeix camins i cues STR_1174 :Hi ha un cartell pel mig. STR_1175 :Això no es pot construir a sobre d’un pendent. @@ -1114,7 +1113,6 @@ STR_1727 :Els drets de construcció no estan a la venda! STR_1728 :No se’n poden comprar els drets de construcció… STR_1729 :El terreny no és propietat del parc! STR_1730 :{RED}Tancat -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Construeix STR_1733 :Mode STR_1734 :{WINDOW_COLOUR_2}Nombre de voltes: @@ -1155,7 +1153,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Només es permet una secció de fotos de record per atracció. STR_1774 :Només es permet un cable d’elevació per atracció. STR_1777 :Música de l’atracció -STR_1778 :{STRINGID} - - STR_1790 :Seleccioneu el color de l’uniforme d’aquest tipus d’empleats. STR_1791 :{WINDOW_COLOUR_2}Color de l’uniforme: STR_1792 :Responent la trucada d’avaria de {STRINGID}. @@ -3844,3 +3841,8 @@ STR_7009 :Es reben scripts nous… STR_7010 :No s’ha pogut iniciar la repetició. El fitxer «{STRING}» no existeix o no és vàlid. STR_7011 :No s’ha pogut iniciar la repetició. STR_7012 :Złoty polonès (PLN) +STR_7013 :Construeix àrees de camins +STR_7014 :Tinc el joc a l’Steam, però no el tinc instal·lat. +STR_7015 :Tanqueu l'Steam si està en execució i després premeu «D’acord». +STR_7016 :L’OpenRCT2 ha intentat executar una descàrrega a l’Steam. Executeu l’Steam i deixeu que descarregui el joc. Quan hagi acabat, premeu «D’acord». +STR_7017 :Surt diff --git a/data/language/cs-CZ.txt b/data/language/cs-CZ.txt index 9459f71a55..4281ae230b 100644 --- a/data/language/cs-CZ.txt +++ b/data/language/cs-CZ.txt @@ -557,7 +557,6 @@ STR_1168 :Nastavení STR_1169 :(None) STR_1170 :{STRING} STR_1171 :{RED}Zavřeno -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Nástroj pro cesty a fronty STR_1174 :Banner v cestě STR_1175 :Toto nelze postavit na strmé cestě @@ -1116,7 +1115,6 @@ STR_1727 :Stavební práva nejsou na prodej! STR_1728 :Tyto stavební práva nelze zakoupit… STR_1729 :Pozemek není ve vlastnictví parku! STR_1730 :{RED}Zavřeno -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Stavět STR_1733 :Mód STR_1734 :{WINDOW_COLOUR_2}Počet kol: @@ -1157,7 +1155,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Je povolena jen jedna fotobuňka na atrakci STR_1774 :Je povolen pouze jeden výtah na atrakci STR_1777 :Hudba atrakcí -STR_1778 :{STRINGID} - - STR_1790 :Vybrat barvu uniformy těchto zaměstnanců STR_1791 :{WINDOW_COLOUR_2}Barva uniformy: STR_1792 :Reaguje na poruchu {STRINGID} @@ -3838,4 +3835,4 @@ STR_7004 :Vynutit překresl. (force redraw) STR_7005 :Stavět cesty v oblasti označené tažením STR_7006 :Vykreslit okraje tlačítek s obrázky STR_7007 :Typ atrakce -STR_7008 :Neznámá atrakce ({INT32}) \ No newline at end of file +STR_7008 :Neznámá atrakce ({INT32}) diff --git a/data/language/da-DK.txt b/data/language/da-DK.txt index 920523f90b..07f8975a58 100644 --- a/data/language/da-DK.txt +++ b/data/language/da-DK.txt @@ -91,6 +91,7 @@ STR_0095 :Alpin rutchebane STR_0096 :Klassisk træ rutsjebane STR_0097 :Klassisk Stå-op Rutschebane STR_0098 :LSM Accelereret Rutschebane +STR_0099 :Klassisk Wooden Twister-rutsjebane STR_0512 :En kompakt rutschebane med en spiral stigning og bløde, snoede fald. STR_0513 :En loopende rutschebane hvor passagerne er i en stående position STR_0514 :Vogne suspenderet under rutschebane sporet, svinger ud til siden i svingene @@ -176,6 +177,7 @@ STR_0605 :Ryttere kælker ned ad en bugtende stålbane og bremser for at kont STR_0606 :En ældre stils trærutsjebane med en hurtig og ujævn tur med masser af luft tid, laterale G'er, og designet til at føles som ‘ude-af-kontrol’ STR_0607 :En intens, Klassisk stål-stil, loopende rutschebane hvor passagerne er i en stående position STR_0608 :Rutsjebanetog accelereres ud af stationen af lineære synkronmotorer, for at suse gennem snoede inversioner og sving +STR_0609 :En træ-rutsjebane i klassisk stil med en hurtig og hård tur, artikulerede tog, masser af airtime og snoede spor STR_0767 :Gæst {INT32} STR_0768 :Handymand {INT32} STR_0769 :Mekaniker {INT32} @@ -462,14 +464,14 @@ STR_1076 :Butiks bod tilstand STR_1077 :Rotations tilstand STR_1078 :Fremad rotation STR_1079 :Baglæns rotation -STR_1080 :Film: ”Avenging aviators” -STR_1081 :3D film: ”Mouse tails” +STR_1080 :Film: ”Avenging Aviators” +STR_1081 :3D-film: ”Mouse Tails” STR_1082 :Space rings tilstand STR_1083 :Begynder tilstand STR_1084 :LIM-drevet afsendelse -STR_1085 :Film: ”Thrill riders” -STR_1086 :3D film: ”Storm chasers” -STR_1087 :3D film: ”Space raiders” +STR_1085 :Film: ”Thrill Riders” +STR_1086 :3D-film: ”Storm Chasers” +STR_1087 :3D-film: ”Space Raiders” STR_1088 :Intens tilstand STR_1089 :Bersærk tilstand STR_1090 :Spøgelseshus tilstand @@ -554,7 +556,6 @@ STR_1168 :Indstillinger STR_1169 :(ingen) STR_1170 :{STRING} STR_1171 :{RED}Lukket -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Byg stier og kø linjer STR_1174 :Banner skilt i vejen STR_1175 :Kan ikke bygge dette på en skrå sti @@ -1111,7 +1112,6 @@ STR_1727 :Byggetilladelse er ikke til salg! STR_1728 :Kan ikke købe byggetilladelse her… STR_1729 :Land ikke ejet af parken! STR_1730 :{RED}Lukket -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Byg STR_1733 :Tilstand STR_1734 :{WINDOW_COLOUR_2}Antal omgange: @@ -1152,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Kun en on-ride foto sektion, tilladt per forlystelse STR_1774 :Kun et trækspil er tilladt per forlystelse. STR_1777 :Forlystelses musik -STR_1778 :{STRINGID} - - STR_1790 :vælg uniforms farve for denne type personale STR_1791 :{WINDOW_COLOUR_2}Uniforms farve: STR_1792 :Reagerer på et kald til {STRINGID} på grund af nedbrud @@ -1255,8 +1254,8 @@ STR_1891 :Ingen {STRINGID} i parken endnu! STR_1894 :{WINDOW_COLOUR_2}{STRINGID} solgt: {BLACK}{COMMA32} STR_1895 :Byg en ny forlystelse STR_1896 :{WINDOW_COLOUR_2}Udgifter/indtægter -STR_1897 :{WINDOW_COLOUR_2}Forlystelse konstruktion -STR_1898 :{WINDOW_COLOUR_2}Forlystelse driftsomkostninger +STR_1897 :{WINDOW_COLOUR_2}Konstruktion +STR_1898 :{WINDOW_COLOUR_2}Drift (Forlystelser) STR_1899 :{WINDOW_COLOUR_2}Landopkøb STR_1900 :{WINDOW_COLOUR_2}Ændring af landskab STR_1901 :{WINDOW_COLOUR_2}Entrébilletter @@ -2224,8 +2223,8 @@ STR_3228 :Sæt start punkt for personer STR_3229 :Blokbremser kan ikke bruges lige efter stationen STR_3230 :Blokbremser kan ikke bruges lige efter hinanden STR_3231 :Blokbremser kan ikke bruges lige efter toppen af en løftekæde -STR_3232 :Indstillinger - Finansiel -STR_3233 :Indstillinger - Gæster +STR_3232 :Scenarieindstillinger - Økonomi +STR_3233 :Scenarieindstillinger – Gæster STR_3235 :Vis finansindstillinger STR_3236 :Vis gæsteindstillinger STR_3238 :Ingen penge @@ -2269,7 +2268,7 @@ STR_3279 :Gratis park entré / Betal for forlystelser STR_3280 :Betal Park entré / Gratis forlystelser STR_3281 :Entré pris: STR_3283 :vælg forlystelser der skal bevares -STR_3285 :Bevarede forlystelser +STR_3285 :Scenarieindstillinger - Bevarede forlystelser STR_3286 :Vælg mål for dette scenarie STR_3287 :{WINDOW_COLOUR_2}Mål: STR_3294 :Skift… @@ -2941,7 +2940,7 @@ STR_5858 :Brug GPU til visning i stedet for CPU. Forbedrer kompatibiliteten m STR_5859 :Aktiver ‘frame tweening’ for et visuelt{NEWLINE}mere flydende spil. Ved deaktivering,{NEWLINE}vil spillet køre med 40 billeder pr. sekund, fast. STR_5860 :Skift original/decompileret spor tegning STR_5861 :Kunne ikke verificere nøglen. -STR_5862 :Blokér ukendte spillere. +STR_5862 :Blokér ukendte spillere STR_5863 :Tillad at kun spillere med kendte nøgler kan deltage. STR_5864 :Denne server tillader kun hvidlistede spillere at oprette forbindelse. STR_5865 :Gem chat historik @@ -3182,7 +3181,7 @@ STR_6102 :Værdien af forlystelser vil ikke falde over tid over tid, Så gæs STR_6103 :Denne funktion er deaktiveret ved netværksspil. STR_6105 :Hypercoaster STR_6107 :Monster Trucks -STR_6109 :Hyper-Twister +STR_6109 :Hyper-Twister rutchebane STR_6111 :Klassisk mini rutchebane STR_6113 :En høj ikke-inverterende rutschebane med store fald, høj hastighed og komfortable vogne med simpel fastspænding STR_6115 :Kæmpe Eldrevne firhjulstrækkere , der kan klatre op ad stejle skråninger @@ -3686,8 +3685,8 @@ STR_6657 :Land Ikke Ejet STR_6658 :Sæt land til at ikke være ejet af parken, heller ikke muligt at købe land STR_6659 :Gæster ignorerer priser STR_6660 :Gæsterne vil ignorere priserne for forlystelser og stande. -STR_6661 :Alt tilfældigt -STR_6662 :Gør farverne tilfældige for hver Randomise colours for every train or vehicle. +STR_6661 :Randomisér alle +STR_6662 :Randomisér farver for hvert tog eller køretøj. STR_6663 :Dato snyd STR_6664 :Vis dato snyd STR_6665 :Natur/vejr Snyd @@ -3698,7 +3697,7 @@ STR_6669 :Vis snyd med ansatte STR_6670 :Gæste opførsel STR_6671 :Vis ‘rigtige’ navne på ansatte STR_6672 :Skift imellem at vise ‘rigtige’ navne på ansatte og ansatte numre -STR_6673 :Gennemsigtig +STR_6673 :Transparent # Used as part of a sentence (see https://github.com/OpenRCT2/OpenRCT2/issues/22072). STR_6674 :{MONTH}, År {COMMA16} STR_6675 :Peep Navne @@ -3736,85 +3735,112 @@ STR_6706 :{WINDOW_COLOUR_2}Nuværende billedfil: {BLACK}{STRING} STR_6707 :(Ingen valgt) STR_6708 :Udglatnings Styrke STR_6709 :Angiv udglatnings styrke imellem {COMMA16} og {COMMA16} -STR_6710 :Stable sort -STR_6711 :Filename: -STR_6712 :Save +STR_6710 :Stabil sortering +STR_6711 :Filnavn: +STR_6712 :Gem STR_6713 :{COMMA32} {STRINGID} -STR_6714 :Filename -STR_6715 :Date modified -STR_6716 :File size -STR_6717 :File size {STRINGID} -STR_6718 :Peep Animations -STR_6719 :At least one guest peep animations object must be selected -STR_6720 :At least one handyman peep animations object must be selected -STR_6721 :At least one mechanic peep animations object must be selected -STR_6722 :At least one security peep animations object must be selected -STR_6723 :At least one entertainer peep animations object must be selected +STR_6714 :Filnavn +STR_6715 :Dato ændret +STR_6716 :Filstørrelse +STR_6717 :Filstørrelse {STRINGID} +STR_6718 :Peep-animationer +STR_6719 :Mindst ét gæste-peep-animationsobjekt skal være valgt +STR_6720 :Mindst ét vicevært-peep-animationsobjekt skal være valgt +STR_6721 :Mindst ét mekaniker-peep-animationsobjekt skal være valgt +STR_6722 :Mindst ét sikkerheds-peep-animationsobjekt skal være valgt +STR_6723 :Mindst ét entertainer-peep-animationsobjekt skal være valgt STR_6724 :Scenarie Tekster STR_6725 :X: STR_6726 :Y: -STR_6727 :Dive Loop (left) -STR_6728 :Dive Loop (right) -STR_6729 :Cable lift hill must start immediately after station or block brake -STR_6730 :Export emscripten data -STR_6731 :Import emscripten data -STR_6732 :Show a button in the toolbar to rotate the view anti-clockwise -STR_6733 :See-Through -STR_6734 :Map elements that are at or above the cutting height are rendered translucent. -STR_6735 :Go up to parent folder -STR_6736 :Preview -STR_6737 :No preview available -STR_6738 :{WINDOW_COLOUR_2}Park rating: {BLACK}{UINT16} -STR_6739 :{WINDOW_COLOUR_2}Date: {BLACK}{STRINGID} -STR_6740 :{WINDOW_COLOUR_2}Cash: {BLACK}{CURRENCY2DP} -STR_6741 :{WINDOW_COLOUR_2}Num. rides: {BLACK}{UINT16} -STR_6742 :{WINDOW_COLOUR_2}Num. guests: {BLACK}{UINT16} -STR_6743 :Climate +STR_6727 :Dyk Loop (venstre) +STR_6728 :Dyk Loop (højre) +STR_6729 :Kabel-lifthill skal starte umiddelbart efter station eller blokbremse +STR_6730 :Eksportér emscripten-data +STR_6731 :Importér emscripten-data +STR_6732 :Vis en knap i værktøjslinjen til at rotere visningen mod uret +STR_6733 :Gennemsigtig +STR_6734 :Elementer på eller over skærehøjden vises som gennemsigtige. +STR_6735 :Gå op til overmappen +STR_6736 :Forhåndsvisning +STR_6737 :Ingen forhåndsvisning tilgængelig +STR_6738 :{WINDOW_COLOUR_2}Parkvurdering: {BLACK}{UINT16} +STR_6739 :{WINDOW_COLOUR_2}Dato: {BLACK}{STRINGID} +STR_6740 :{WINDOW_COLOUR_2}Kontanter: {BLACK}{CURRENCY2DP} +STR_6741 :{WINDOW_COLOUR_2}Antal forlystelser: {BLACK}{UINT16} +STR_6742 :{WINDOW_COLOUR_2}Antal gæster: {BLACK}{UINT16} +STR_6743 :Klima STR_6744 :{WINDOW_COLOUR_2}{UINT16}% -STR_6745 :{WINDOW_COLOUR_2}Guests’ intensity preferences: -STR_6746 :No preferences -STR_6747 :Preferences vary (default) -STR_6748 :Only less intense rides -STR_6749 :Only more intense rides -STR_6750 :Select what kind of ride intensity newly spawned guests prefer. -STR_6751 :Queue paths cannot be used for level crossings! -STR_6752 :Scenario options - Objective -STR_6753 :Scenario options - Scenario Details -STR_6754 :Scenario options - Land Restrictions -STR_6755 :Show objective options -STR_6756 :Show scenario details options -STR_6757 :Show land restriction options -STR_6758 :Loan options -STR_6759 :Business model -STR_6760 :Earnings: -STR_6761 :Scenario Details -STR_6762 :Udseende +STR_6745 :{WINDOW_COLOUR_2}Gæsters intensitetspræferencer: +STR_6746 :Ingen præferencer +STR_6747 :Varierende præferencer (standard) +STR_6748 :Kun mindre intense forlystelser +STR_6749 :Kun mere intense forlystelser +STR_6750 :Vælg hvilken intensitet nye gæster foretrækker. +STR_6751 :Køstier kan ikke bruges til planoverkørsler! +STR_6752 :Scenarieindstillinger – Mål +STR_6753 :Scenarieindstillinger – Scenariedetaljer +STR_6754 :Scenarieindstillinger – Jordbegrænsninger +STR_6755 :Vis målindstillinger +STR_6756 :Vis scenariedetaljeindstillinger +STR_6757 :Vis jordbegrænsningsindstillinger +STR_6758 :Låneindstillinger +STR_6759 :Forretningsmodel +STR_6760 :Indtjening: +STR_6761 :Scenariedetaljer +STR_6762 :Brugerflade STR_6763 :RollerCoaster Tycoon 1 -STR_6764 :Saving and autosaves -STR_6765 :Advanced -STR_6766 :Clear +STR_6764 :Gem og autogem +STR_6765 :Avanceret +STR_6766 :Ryd STR_6767 :Window STR_6768 :Rendering -STR_6769 :Behaviour -STR_6770 :Frame rate limit: -STR_6771 :Internal speed (default) -STR_6772 :Vertical sync -STR_6773 :Unrestricted -STR_6774 :Time since last inspection -STR_6775 :{COMMA16} minute -STR_6776 :{COMMA16} minutes -STR_6777 :more than 4 hours -STR_6778 :Preview scenarios using: -STR_6779 :Select the kind of preview image to use in the scenario selection screen. -STR_6780 :Mini maps -STR_6781 :Screenshots -STR_6782 :Park notifications -STR_6783 :Ride notifications -STR_6784 :Guest notifications +STR_6769 :Adfærd +STR_6770 :Begræns billedfrekvens: +STR_6771 :Skærmens hastighed (standard) +STR_6772 :Vertikal synkronisering +STR_6773 :Ubegrænset +STR_6774 :Tid siden sidste inspektion +STR_6775 :{COMMA16} minut +STR_6776 :{COMMA16} minutter +STR_6777 :mere end 4 timer +STR_6778 :Forhåndsvis scenarier med: +STR_6779 :Vælg hvilken type forhåndsvisningsbillede der bruges i scenarieoversigten. +STR_6780 :Minikort +STR_6781 :Skærmbilleder +STR_6782 :Park-meddelelser +STR_6783 :Forlystelses-meddelelser +STR_6784 :Gæste-meddelelser STR_6785 :Gamepad -STR_6786 :Deadzone: -STR_6787 :Analogue stick deadzone (minimum movement required) -STR_6788 :Sensitivity: -STR_6789 :Analogue stick sensitivity multiplier -STR_6790 :Deadzone: {COMMA32}% -STR_6791 :Sensitivity: {COMMA32}% +STR_6786 :Dødzone: +STR_6787 :Dødzone for analog‑stick (mindste nødvendige bevægelse) +STR_6788 :Følsomhed: +STR_6789 :Følsomhedsmultiplikator for analog‑stick +STR_6790 :Dødzone: {COMMA32}% +STR_6791 :Følsomhed: {COMMA32}% +STR_6792 :Indgangsbygninger +STR_6793 :Gæster og personale +STR_6794 :Scenarie og Temaer +STR_6795 :{MOVE_X}{10}{STRINGID} +STR_6796 :•{MOVE_X}{10}{STRINGID} +STR_6797 :Ingen forhåndsvisning +STR_6798 :Skærmbillede +STR_6799 :Minikort +STR_7000 :eller +STR_7001 :Forlystelsesnavn +STR_7002 :{STRINGID} {STRINGID} +STR_7003 :Lydfilen ‘{STRING}’ er afkortet. Forventede sample {INT32}, men kun {INT32} er tilgængelige. Overvej at geninstallere RCT2. +STR_7004 :Tving genoptegning +STR_7005 :Træk et område af fodgængersti +STR_7006 :Tegn kant rundt om billedknapper +STR_7007 :Forlystelsestype +STR_7008 :Ukendt forlystelsestype ({INT32}) +STR_7009 :Modtager scripts… +STR_7010 :Kunne ikke starte replay, filen ‘{STRING}’ findes ikke eller er ugyldig +STR_7011 :Kunne ikke starte replay +STR_7012 :Polsk złoty (PLN) +STR_7013 :Træk områder af sti +STR_7014 :Jeg ejer spillet på Steam, men har ikke installeret det endnu. +STR_7015 :Luk venligst Steam, hvis det kører, og klik derefter på ‘OK’. +STR_7016 :OpenRCT2 har forsøgt at starte en download i Steam. Åbn Steam og lad det hente spillet. Når Steam er færdig, klik på ‘OK’. +STR_7017 :Afslut + diff --git a/data/language/de-DE.txt b/data/language/de-DE.txt index aae868b05b..689c0142cd 100644 --- a/data/language/de-DE.txt +++ b/data/language/de-DE.txt @@ -556,7 +556,6 @@ STR_1168 :Optionen STR_1169 :(Keine) STR_1170 :{STRING} STR_1171 :{RED}Geschlossen -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Fußwege und Warteschlangenreihen anlegen STR_1174 :Banner im Weg STR_1175 :Kann nicht auf Fußweg mit Neigung angelegt werden @@ -1114,7 +1113,6 @@ STR_1727 :Baurechte nicht zum Verkauf! STR_1728 :Erwerb von Baurechten hier nicht möglich … STR_1729 :Land gehört nicht dem Park! STR_1730 :{RED}Geschlossen -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Bauen STR_1733 :Modus STR_1734 :{WINDOW_COLOUR_2}Anzahl der Runden: @@ -1155,7 +1153,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Nur ein Fahrtfoto-Bereich pro Bahn erlaubt STR_1774 :Nur ein Kabellifthügel pro Bahn erlaubt STR_1777 :Attraktionsmusik -STR_1778 :{STRINGID} - - STR_1790 :Uniformfarbe für diesen{NEWLINE}Mitarbeiter auswählen STR_1791 :{WINDOW_COLOUR_2}Uniformfarbe: STR_1792 :Unterwegs zur Reparatur von {STRINGID} @@ -3832,3 +3829,12 @@ STR_7005 :Baue eine Fläche aus Fußwegen STR_7006 :Zeichne Ränder um Bildknöpfe STR_7007 :Achterbahntyp STR_7008 :Unbekannter Fahrgeschäftstyp ({INT32}) +STR_7009 :Emfange Skripte … +STR_7010 :Wiederholung konnte nicht gestartet werden, Datei „{STRING}“ existiert nicht oder ist ungültig +STR_7011 :Wiederholung konnte nicht gestartet werden +STR_7012 :Polnische Złoty (PLN) +STR_7013 :Weggebiete ziehen +STR_7014 :Mir gehört das Spiel auf Steam, habe es aber noch nicht installiert. +STR_7015 :Bitte schließen Sie Steam, falls es läuft, dann klicken Sie auf „OK“. +STR_7016 :OpenRCT2 hat versucht, einen Download in Steam auszulösen. Bitte öffen Sie Steam und lassen Sie es das Spiel herunterladen. Wenn Steam fertig ist, klicken Sie auf „OK“. +STR_7017 :Verlassen diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index abbf2ef186..18a4bd0f55 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -556,7 +556,6 @@ STR_1168 :Options STR_1169 :(None) STR_1170 :{STRING} STR_1171 :{RED}Closed -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Build footpaths and queue lines STR_1174 :Banner sign in the way STR_1175 :Can’t build this on sloped footpath @@ -1113,7 +1112,6 @@ STR_1727 :Construction rights not for sale! STR_1728 :Can’t buy construction rights here… STR_1729 :Land not owned by park! STR_1730 :{RED}Closed -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Build STR_1733 :Mode STR_1734 :{WINDOW_COLOUR_2}Number of laps: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Only one on-ride photo section allowed per ride STR_1774 :Only one cable lift hill allowed per ride STR_1777 :Ride music -STR_1778 :{STRINGID} - - STR_1790 :Select uniform colour for this type of staff STR_1791 :{WINDOW_COLOUR_2}Uniform colour: STR_1792 :Responding to {STRINGID} breakdown call @@ -3851,3 +3848,8 @@ STR_7018 :{SPRITE}{MOVE_X}{17}{STRINGID} STR_7019 :{SPRITE}{MOVE_X}{27}{STRINGID} STR_7020 :{MOVE_X}{10}{SPRITE}{NEWLINE_SMALLER}{MOVE_X}{36}{STRINGID} STR_7021 :{MOVE_X}{10}{SPRITE}{NEWLINE_SMALLER}»{MOVE_X}{36}{STRINGID} +STR_7022 :{STRING} - - +STR_7023 :Make invisible +STR_7024 :Makes the whole ride invisible +STR_7025 :Make visible +STR_7026 :Makes the whole ride visible diff --git a/data/language/eo-ZZ.txt b/data/language/eo-ZZ.txt index d3471982ae..99130f7c3f 100644 --- a/data/language/eo-ZZ.txt +++ b/data/language/eo-ZZ.txt @@ -556,7 +556,6 @@ STR_1168 :Agordoj STR_1169 :(Neniu) STR_1170 :{STRING} STR_1171 :{RED}Fermita -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Konstrui trotuarojn kaj atendovicojn STR_1174 :Rubando obstrukcas STR_1175 :Ne eblas konstrui ĉi tion sur dekliva trotuaro @@ -1113,7 +1112,6 @@ STR_1727 :Konstruado-rajtoj ne estas aĉeteblaj! STR_1728 :Ne eblas aĉeti konstruado-rajtojn ĉi tie… STR_1729 :Bieno ne estas posedata de parko! STR_1730 :{RED}Fermita -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Konstrui STR_1733 :Reĝimo STR_1734 :{WINDOW_COLOUR_2}Nombro de etapoj: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Nur unu sur-atrakcia fotoparto estas permesita po atrakcio STR_1774 :Nur unu kablolifta monteto estas permesita po atrakcio STR_1777 :Muziko de atrakcio -STR_1778 :{STRINGID} - - STR_1790 :Elekti uniformkoloron de tiaj dungitoj STR_1791 :{WINDOW_COLOUR_2}Uniformkoloro: STR_1792 :Reagas al paneovoko de {STRINGID} @@ -1608,7 +1605,7 @@ STR_2261 :Minimuma financado STR_2262 :Normala financado STR_2263 :Maksimuma financado STR_2264 :Financado de esplorado -STR_2265 :{WINDOW_COLOUR_2}Kosto: {BLACK}po {CURRENCY} por mono +STR_2265 :{WINDOW_COLOUR_2}Kosto: {BLACK}po {CURRENCY} por monato STR_2266 :Prioritatoj de esplorado STR_2267 :Nune disvolvata STR_2268 :Pasinta disvolvado diff --git a/data/language/es-ES.txt b/data/language/es-ES.txt index 4818e88f7b..7d566e057b 100644 --- a/data/language/es-ES.txt +++ b/data/language/es-ES.txt @@ -557,7 +557,6 @@ STR_1168 :Opciones STR_1169 :(Ninguno) STR_1170 :{STRING} STR_1171 :{RED}Cerrada -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Construir senderos STR_1174 :Cartel de señal interfiere STR_1175 :No se puede construir esto sobre una pendiente @@ -1114,7 +1113,6 @@ STR_1727 :¡Derechos de construcción no a la venta! STR_1728 :No puedes comprar derechos de construcción aquí… STR_1729 :¡El terreno no es propiedad del parque! STR_1730 :{RED}Cerrado -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Construir STR_1733 :Modo STR_1734 :{WINDOW_COLOUR_2}Numero de vueltas: @@ -1155,7 +1153,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Sólo se permite una sección de fotos por atracción. STR_1774 :Sólo un cable de elevación por atracción. STR_1777 :Música de atracción -STR_1778 :{STRINGID} - - STR_1790 :Selecciona el color del uniforme para este tipo de empleados STR_1791 :{WINDOW_COLOUR_2}Color del uniforme: STR_1792 :Dirigiéndose a {STRINGID} @@ -3834,3 +3831,6 @@ STR_7000 :o STR_7001 :Nombre de Atracción STR_7002 :{STRINGID} {STRINGID} STR_7003 :El archivo de audio ‘{STRING}’ está truncado. Se esperaban {INT32} muestras, pero solo están disponibles {INT32}. Considere reinstalar RCT2. +STR_7004 :Forzar redibujado +STR_7005 :Arrastrar un área de sendero +STR_7006 :Dibujar borde alrededor de los botones con imágenes diff --git a/data/language/fi-FI.txt b/data/language/fi-FI.txt index b8e1c9491e..4f9618faef 100644 --- a/data/language/fi-FI.txt +++ b/data/language/fi-FI.txt @@ -553,7 +553,6 @@ STR_1168 :Asetukset STR_1169 :(Ei mitään) STR_1170 :{STRING} STR_1171 :{RED}Suljettu - - -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Rakenna polkuja ja jonotusalueita STR_1174 :Banneri on tiellä STR_1175 :Tätä ei voi rakentaa kaltevalle polulle @@ -1113,7 +1112,6 @@ STR_1727 :Rakennusluvat eivät ole myytävänä! STR_1728 :Rakennuslupia ei voi ostaa tähän… STR_1729 :Maa ei ole puiston omistuksessa! STR_1730 :{RED}Suljettu - - -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Rakenna STR_1733 :Tila STR_1734 :{WINDOW_COLOUR_2}Kierrosten määrä: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Vain yksi valokuvaosio sallittu per laite STR_1774 :Vain yksi nostomäki sallittu per laite STR_1777 :{WINDOW_COLOUR_2}Musiikki -STR_1778 :{STRINGID} - - STR_1790 :Valitse virka-asun väri tälle henkilöstötyypille STR_1791 :{WINDOW_COLOUR_2}Virka-asun väri: STR_1792 :Matkalla korjaamaan laitetta {STRINGID} diff --git a/data/language/fr-FR.txt b/data/language/fr-FR.txt index 51c56351f9..1e3c2ce6c7 100644 --- a/data/language/fr-FR.txt +++ b/data/language/fr-FR.txt @@ -556,7 +556,6 @@ STR_1168 :Options STR_1169 :(Aucun) STR_1170 :{STRING} STR_1171 :{RED}Fermé -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Construire des allées et des files d’attentes STR_1174 :Panneau d’affichage sur le passage STR_1175 :Impossible de construire ceci sur une allée en pente @@ -1114,7 +1113,6 @@ STR_1727 :Les droits de construction ne sont pas à vendre ! STR_1728 :Impossible d’acheter les droits de construction ici… STR_1729 :Ce terrain n’appartient pas au parc ! STR_1730 :{RED}Fermé -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Construction STR_1733 :Mode STR_1734 :{WINDOW_COLOUR_2}Nombre de tours : @@ -1155,7 +1153,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Une seule section photo sur le vif autorisée par attraction STR_1774 :Une seule remontée à chaîne autorisée par attraction STR_1777 :Musique de l’attraction -STR_1778 :{STRINGID} - - STR_1790 :Sélectionnez la couleur de l’uniforme pour ce type d’employé STR_1791 :{WINDOW_COLOUR_2}Couleur d’uniforme : STR_1792 :Va réparer {STRINGID} diff --git a/data/language/gl-ES.txt b/data/language/gl-ES.txt index e9554b0548..651a9e4fcb 100644 --- a/data/language/gl-ES.txt +++ b/data/language/gl-ES.txt @@ -556,7 +556,6 @@ STR_1168 :Opcións STR_1169 :(Ningún) STR_1170 :{STRING} STR_1171 :{RED}Pechado -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Construír sendeiros e filas de espera STR_1174 :Letreiro no medio STR_1175 :Non se pode construír isto nun sendeiro inclinado @@ -1113,7 +1112,6 @@ STR_1727 :Os dereitos de construción non están á venda! STR_1728 :Non se poden mercar dereitos de construción aquí… STR_1729 :O terreo non é propiedade do parque! STR_1730 :{RED}Pechado -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Construír STR_1733 :Modo STR_1734 :{WINDOW_COLOUR_2}Número de voltas: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Só se permite unha sección de fotos por atracción. STR_1774 :Só se permite unha subida con cable por atracción STR_1777 :Música de atracción -STR_1778 :{STRINGID} - - STR_1790 :Seleccione a cor do uniforme para este tipo de persoal STR_1791 :{WINDOW_COLOUR_2}Cor do uniforme: STR_1792 :Respondendo á avaría de {STRINGID} diff --git a/data/language/hu-HU.txt b/data/language/hu-HU.txt index a19a630a78..49749275d7 100644 --- a/data/language/hu-HU.txt +++ b/data/language/hu-HU.txt @@ -556,7 +556,6 @@ STR_1168 :Beállítások STR_1169 :(semmi) STR_1170 :{STRING} STR_1171 :{RED}Zárva -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Utak és várósorok építése STR_1174 :Egy hirdetőtábla útban van STR_1175 :Nem építhető lejtős úton @@ -1113,7 +1112,6 @@ STR_1727 :Az építési jogok nem eladóak! STR_1728 :Itt nem lehet építési jogokat vásárolni… STR_1729 :A terület nem a park tulajdona! STR_1730 :{RED}Zárva -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Építés STR_1733 :Mód STR_1734 :{WINDOW_COLOUR_2}Körök száma: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Csak egy élményfotó-szakasz engedélyezett játékonként STR_1774 :Csak egy kábeles felvonószakasz engedélyezett játékonként STR_1777 :Játékok zenéje -STR_1778 :{STRINGID} - - STR_1790 :A választott típusú alkalmazottak által viselt egyenruha színének kiválasztása STR_1791 :{WINDOW_COLOUR_2}Egyenruha színe: STR_1792 :{STRINGID} segélykérésére válaszol diff --git a/data/language/it-IT.txt b/data/language/it-IT.txt index d8a9985cea..a0f254be1c 100644 --- a/data/language/it-IT.txt +++ b/data/language/it-IT.txt @@ -555,7 +555,6 @@ STR_1168 :Opzioni STR_1169 :(Nessuno) STR_1170 :{STRING} STR_1171 :{RED}Chiuso -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Costruisci sentieri e corsie d’attesa STR_1174 :Un’insegna è d’intralcio STR_1175 :Impossibile costruirlo su un sentiero in pendenza @@ -1112,7 +1111,6 @@ STR_1727 :I diritti di costruzione non sono in vendita! STR_1728 :Impossibile comprare i diritti di costruzione qui… STR_1729 :Questo terreno non è di proprietà del parco! STR_1730 :{RED}Chiuso -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Costruisci STR_1733 :Modalità STR_1734 :{WINDOW_COLOUR_2}Numero di giri: @@ -1153,7 +1151,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Può esserci soltanto una sezione di foto-in-corsa per attrazione STR_1774 :Può esserci soltanto una salita per il traino con cavo per attrazione STR_1777 :Musica attrazioni -STR_1778 :{STRINGID} - - STR_1790 :Scegli il colore dell’uniforme per questo tipo di dipendente STR_1791 :{WINDOW_COLOUR_2}Colore dell’uniforme: STR_1792 :Sta accorrendo al guasto di {STRINGID} diff --git a/data/language/ja-JP.txt b/data/language/ja-JP.txt index 7b8282665e..48fcbbfb9a 100644 --- a/data/language/ja-JP.txt +++ b/data/language/ja-JP.txt @@ -552,7 +552,6 @@ STR_1168 :設定 STR_1169 :(なし) STR_1170 :{STRING} STR_1171 :{RED}閉鎖中 -STR_1172 :{YELLOW}{STRINGID} STR_1173 :歩道と行列歩道を敷設 STR_1174 :バナーがあります STR_1175 :これは傾斜のある歩道には設置できません @@ -1109,7 +1108,6 @@ STR_1727 :建設権は売りに出ていません! STR_1728 :ここの建設権を購入できません… STR_1729 :この土地は遊園地のものではありません! STR_1730 :{RED}閉鎖中 -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :建設 STR_1733 :モード STR_1734 :{WINDOW_COLOUR_2}ラップ数: @@ -1150,7 +1148,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :乗物からの写真の場所は、各乗物につき一箇所だけです STR_1774 :ケーブルリフトヒルは、各乗物につき一箇所だけです STR_1777 :音楽 -STR_1778 :{STRINGID} - - STR_1790 :このスタッフのタイプの制服の色を選択: STR_1791 :{WINDOW_COLOUR_2}制服の色: STR_1792 :{STRINGID}の故障の電話を返事中 diff --git a/data/language/ko-KR.txt b/data/language/ko-KR.txt index d6cdd87872..acb47e3432 100644 --- a/data/language/ko-KR.txt +++ b/data/language/ko-KR.txt @@ -557,7 +557,6 @@ STR_1168 :설정 STR_1169 :(없음) STR_1170 :{STRING} STR_1171 :{RED}닫힘 -STR_1172 :{YELLOW}{STRINGID} STR_1173 :보도와 대기 줄을 만듭니다 STR_1174 :팻말이 있습니다 STR_1175 :경사진 보도 위에 건설할 수 없습니다 @@ -1115,7 +1114,6 @@ STR_1727 :판매 중인 건설권이 아닙니다! STR_1728 :이곳의 건설권을 살 수 없습니다… STR_1729 :공원 소유의 땅이 아닙니다! STR_1730 :{RED}닫힘 -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :건설 STR_1733 :모드 STR_1734 :{WINDOW_COLOUR_2}바퀴 수: @@ -1156,7 +1154,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :한 놀이기구에는 하나의 탑승 사진 섹션만 만들 수 있습니다 STR_1774 :한 놀이기구에는 하나의 케이블 리프트만 만들 수 있습니다 STR_1777 :놀이기구 음악 -STR_1778 :{STRINGID} - - STR_1790 :이 직종의 유니폼 색상을 선택하세요 STR_1791 :{WINDOW_COLOUR_2}유니폼 색상: STR_1792 :{STRINGID} 고장 연락을 받음 diff --git a/data/language/nb-NO.txt b/data/language/nb-NO.txt index 18af191963..570d0b891e 100644 --- a/data/language/nb-NO.txt +++ b/data/language/nb-NO.txt @@ -550,7 +550,6 @@ STR_1168 :Valg STR_1169 :(Ingenting) STR_1170 :{STRING} STR_1171 :{RED}Stengt -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Bygg gangstier og køer STR_1174 :Banner i veien STR_1175 :Kan ikke bygges på hellende gangsti @@ -1107,7 +1106,6 @@ STR_1727 :Byggerettigheter ikke til salgs! STR_1728 :Kan ikke kjøpe byggerettigheter her… STR_1729 :Land ikke eid av parken! STR_1730 :{RED}Lukket -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Bygg STR_1733 :Modus STR_1734 :{WINDOW_COLOUR_2}Antall runder: @@ -1148,7 +1146,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Kun én fotoseksjon tillatt per bane STR_1774 :Kun ett kabeltrekk tillatt per bane STR_1777 :Attraksjonsmusikk -STR_1778 :{STRINGID} - - STR_1790 :Velg uniform-farge for denne typen personale STR_1791 :{WINDOW_COLOUR_2}Uniform-farge: STR_1792 :Svarer på {STRINGID} beskjed om sammenbrudd diff --git a/data/language/nl-NL.txt b/data/language/nl-NL.txt index a1fb3b4d55..66546356fd 100644 --- a/data/language/nl-NL.txt +++ b/data/language/nl-NL.txt @@ -554,7 +554,6 @@ STR_1168 :Opties STR_1169 :(Geen) STR_1170 :{STRING} STR_1171 :{RED}Gesloten -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Voetpaden en wachtrijen aanleggen STR_1174 :Lichtkrant in de weg STR_1175 :Kan dit niet op hellend voetpad neerzetten @@ -1112,7 +1111,6 @@ STR_1727 :Voor dit land zijn geen bouwrechten te koop! STR_1728 :Kan hier geen bouwrechten kopen… STR_1729 :Land is geen eigendom van het park! STR_1730 :{RED}Gesloten -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Bouwen STR_1733 :Modus STR_1734 :{WINDOW_COLOUR_2}Aantal rondes: @@ -1153,7 +1151,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Een attractie mag maar één actiefotogedeelte hebben STR_1774 :Een attractie mag maar één kabellift hebben STR_1777 :Attractiemuziek -STR_1778 :{STRINGID} - - STR_1790 :Selecteer de uniformkleur voor dit type werknemer STR_1791 :{WINDOW_COLOUR_2}Uniformkleur: STR_1792 :Gaat {STRINGID} repareren diff --git a/data/language/pl-PL.txt b/data/language/pl-PL.txt index 6477d7b413..de485e3350 100644 --- a/data/language/pl-PL.txt +++ b/data/language/pl-PL.txt @@ -556,7 +556,6 @@ STR_1168 :Opcje STR_1169 :(Brak) STR_1170 :{STRING} STR_1171 :{RED}Zamknięte -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Buduj dróżki i kolejki STR_1174 :Baner blokuje STR_1175 :Nie można tego postawić na nierównej ścieżce @@ -1113,7 +1112,6 @@ STR_1727 :Prawa do budowy nie są na sprzedaż! STR_1728 :Nie można tu kupić praw do budowy… STR_1729 :Teren nie należy do parku! STR_1730 :{RED}Zamknięte -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Buduj STR_1733 :Tryb STR_1734 :{WINDOW_COLOUR_2}Liczba okrążeń: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Tylko jedna sekcja fotograficzna dostępna na atrakcję STR_1774 :Tylko jedna wyciągarka dostępna na atrakcję STR_1777 :{WINDOW_COLOUR_2}Muzyka atrakcji -STR_1778 :{STRINGID} - - STR_1790 :Wybierz kolor uniformu dla tego typu pracownika STR_1791 :{WINDOW_COLOUR_2}Kolor uniformu: STR_1792 :Zmierza naprawić {STRINGID} @@ -3839,3 +3836,8 @@ STR_7009 :Otrzymywanie skryptów… STR_7010 :Nie udało się uruchomić powtórki, plik ‘{STRING}’ nie istnieje lub jest nieprawidłowy STR_7011 :Nie udało się uruchomić powtórki STR_7012 :Polski Złoty (zł) +STR_7013 :Przeciągnij po obszarze, aby utworzyć ścieżkę +STR_7014 :Posiadam grę na platformie Steam, ale jej jeszcze nie zainstalowałem/-am. +STR_7015 :Zamknij aplikację Steam, jeśli jest uruchomiona i kliknij ‘OK’. +STR_7016 :OpenRCT2 próbował zainicjować pobieranie w aplikacji Steam. Otwórz aplikację Steam i manualnie rozpocznij pobieranie gry. Kiedy Steam zakończy pobieranie, kliknij ‘OK’. +STR_7017 :Wyjdź diff --git a/data/language/pt-BR.txt b/data/language/pt-BR.txt index 3d9c98697c..5a4499f1f9 100644 --- a/data/language/pt-BR.txt +++ b/data/language/pt-BR.txt @@ -556,7 +556,6 @@ STR_1168 :Opções STR_1169 :(Nenhum) STR_1170 :{STRING} STR_1171 :{RED}Fechado -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Construir calçadas e filas de espera STR_1174 :Banner está no caminho STR_1175 :Impossível construir isto na calçada inclinada @@ -1113,7 +1112,6 @@ STR_1727 :Direitos de construção não está à venda! STR_1728 :Não pode comprar os direitos de construção aqui… STR_1729 :Os terrenos não são propriedade do parque! STR_1730 :{RED}Fechado -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Construir STR_1733 :Modo STR_1734 :{WINDOW_COLOUR_2}Número de voltas: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Somente uma seção de fotos é permitida por atração STR_1774 :Somente uma subida com cabo de elevação é permitida por atração STR_1777 :Música da atração -STR_1778 :{STRINGID} - - STR_1790 :Selecione a cor do uniforme para este tipo de funcionário STR_1791 :{WINDOW_COLOUR_2}Cor do uniforme: STR_1792 :Respondendo a chamada de quebra da {STRINGID} diff --git a/data/language/ru-RU.txt b/data/language/ru-RU.txt index d97b3cc00b..9eaf6224cd 100644 --- a/data/language/ru-RU.txt +++ b/data/language/ru-RU.txt @@ -550,7 +550,6 @@ STR_1168 :Опции STR_1169 :(Нет) STR_1170 :{STRING} STR_1171 :{RED}Закрыто - - -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Построить дорожки и заграждения STR_1174 :На пути баннер STR_1175 :Нельзя это строить на наклонной дорожке @@ -1107,7 +1106,6 @@ STR_1727 :Права на строительство не продаются! STR_1728 :Здесь нельзя купить права на строительство… STR_1729 :Земля не принадлежит парку! STR_1730 :{RED}Закрыто - - -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Строить STR_1733 :Режим STR_1734 :{WINDOW_COLOUR_2}Число кругов: @@ -1148,7 +1146,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Допускается только одна фото секция STR_1774 :Допускается только один кабельный лифт STR_1777 :{WINDOW_COLOUR_2}Музыка -STR_1778 :{STRINGID} - - STR_1790 :Выберите цвет униформы для этого типа работников STR_1791 :{WINDOW_COLOUR_2}Цвет формы: STR_1792 :Отвечает на вызов по {STRINGID} diff --git a/data/language/sv-SE.txt b/data/language/sv-SE.txt index 379f54c25f..51805e1bd0 100644 --- a/data/language/sv-SE.txt +++ b/data/language/sv-SE.txt @@ -557,7 +557,6 @@ STR_1168 :Inställningar STR_1169 :(Inga) STR_1170 :{STRING} STR_1171 :{RED}Stängd -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Bygg gångvägar och köer STR_1174 :En skylt är i vägen STR_1175 :Kan inte bygga på en sluttande gångväg @@ -1114,7 +1113,6 @@ STR_1727 :Bygglov är inte till salu! STR_1728 :Kan inte få bygglov här… STR_1729 :Marken ägs inte av parken! STR_1730 :{RED}Stängd -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Bygg STR_1733 :Läge STR_1734 :{WINDOW_COLOUR_2}Antal varv: @@ -1155,7 +1153,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Bara en fotosektion tillåten per åktur STR_1774 :Bara en uppskjutskulle tillåten per åktur STR_1777 :Musik för åkturer -STR_1778 :{STRINGID} - - STR_1790 :Välj uniformfärg för den här sortens personal STR_1791 :{WINDOW_COLOUR_2}Uniformfärg: STR_1792 :Svarar på radioanrop om {STRINGID} diff --git a/data/language/tr-TR.txt b/data/language/tr-TR.txt index 416b866988..df1001f874 100644 --- a/data/language/tr-TR.txt +++ b/data/language/tr-TR.txt @@ -1100,7 +1100,6 @@ STR_1727 :İnşa hakkı satılmıyor! STR_1728 :Burada inşa hakkı alınamıyor… STR_1729 :Bu alan parka ait değil STR_1730 :{RED}Kapalı - - -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :İnşa et STR_1733 :Mod STR_1734 :{WINDOW_COLOUR_2}Tur sayısı: @@ -1141,7 +1140,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Alet başı bir tane fotoğraf alanı inşa edilebilir STR_1774 :Alet başı bir tane asansörlü tırmanma zinciri inşa edilebilir STR_1777 :{WINDOW_COLOUR_2}Alet müziği -STR_1778 :{STRINGID} - - STR_1790 :Bu işçinin üniforma{NEWLINE}rengini seçiniz STR_1791 :{WINDOW_COLOUR_2}Üniforma rengi: STR_1792 :{STRINGID} aletinin tamirine gidiyor diff --git a/data/language/uk-UA.txt b/data/language/uk-UA.txt index 945a0b3674..f5ae9fcde9 100644 --- a/data/language/uk-UA.txt +++ b/data/language/uk-UA.txt @@ -550,7 +550,6 @@ STR_1168 :Параметри STR_1169 :(Немає) STR_1170 :{STRING} STR_1171 :{RED}Зачинено -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Побудова пішохідних доріжок та ліній черги STR_1174 :Знак банеру на шляху STR_1175 :Неможливо побудувати це на похилій доріжці @@ -1107,7 +1106,6 @@ STR_1727 :Права на будівництво не продаються! STR_1728 :Не вдалося купити права на будівництво… STR_1729 :Ділянка не належить парку! STR_1730 :{RED}Зачинено -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Build STR_1733 :Режим STR_1734 :{WINDOW_COLOUR_2}Кількість кіл: @@ -1148,7 +1146,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Only one on-ride photo section allowed per ride STR_1774 :Only one cable lift hill allowed per ride STR_1777 :Музика в атракціонах -STR_1778 :{STRINGID} - - STR_1790 :Вибрати колір уніформи для цього типу працівників STR_1791 :{WINDOW_COLOUR_2}Колір уніформи: STR_1792 :Відповідає на {STRINGING} виклик про поломку diff --git a/data/language/vi-VN.txt b/data/language/vi-VN.txt index 8a81a347de..488b35cbcb 100644 --- a/data/language/vi-VN.txt +++ b/data/language/vi-VN.txt @@ -556,7 +556,6 @@ STR_1168 :Tùy chọn STR_1169 :(Không có) STR_1170 :{STRING} STR_1171 :{RED}Đã đóng -STR_1172 :{YELLOW}{STRINGID} STR_1173 :Xây dựng đường đi bộ và hàng chờ STR_1174 :Biển hiệu biểu ngữ bị cản trở STR_1175 :Không thể xây dựng cái này trên đường đi bộ dốc @@ -1063,7 +1062,6 @@ STR_1727 :Quyền xây dựng không rao bán! STR_1728 :Không thể mua quyền xây dựng ở đây… STR_1729 :Đất không thuộc sở hữu của công viên! STR_1730 :{RED}Đã đóng -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :Xây dựng STR_1733 :Chế độ STR_1734 :{WINDOW_COLOUR_2}Số vòng: @@ -1104,7 +1102,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :Chỉ cho phép một phần chụp ảnh trên trò chơi mỗi trò chơi STR_1774 :Chỉ cho phép một đồi nâng dây cáp mỗi trò chơi STR_1777 :Nhạc trò chơi -STR_1778 :{STRINGID} - - STR_1790 :Chọn màu đồng phục cho loại nhân viên này STR_1791 :{WINDOW_COLOUR_2}Màu đồng phục: STR_1792 :Đang phản hồi cuộc gọi hỏng hóc {STRINGID} diff --git a/data/language/zh-CN.txt b/data/language/zh-CN.txt index 702b1241bb..a7cabe9f76 100644 --- a/data/language/zh-CN.txt +++ b/data/language/zh-CN.txt @@ -556,7 +556,6 @@ STR_1168 :选项 STR_1169 :(无) STR_1170 :{STRING} STR_1171 :{RED}已关闭 -STR_1172 :{YELLOW}{STRINGID} STR_1173 :建造道路和队列线 STR_1174 :被横幅挡住了 STR_1175 :不能在倾斜的小径上建造这个 @@ -1113,7 +1112,6 @@ STR_1727 :建筑权不供购买! STR_1728 :不能在此购买建权…… STR_1729 :非游乐园所属地块! STR_1730 :{RED}已关闭 -STR_1731 :{WHITE}{STRINGID}——- STR_1732 :建造 STR_1733 :模式 STR_1734 :{WINDOW_COLOUR_2}圈数: @@ -1154,7 +1152,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :每个游乐设施只能建造一个照相区域 STR_1774 :每个游乐设施只能建造一个牵引轨道 STR_1777 :设施音乐 -STR_1778 :{STRINGID} - - STR_1790 :选择这种员工的制服颜色 STR_1791 :{WINDOW_COLOUR_2}制服的颜色: STR_1792 :正在回应{STRINGID}的故障呼叫 diff --git a/data/language/zh-TW.txt b/data/language/zh-TW.txt index 176b3e52d1..8786189cae 100644 --- a/data/language/zh-TW.txt +++ b/data/language/zh-TW.txt @@ -557,7 +557,6 @@ STR_1168 :選項 STR_1169 :(無) STR_1170 :{STRING} STR_1171 :{RED}已關閉 -STR_1172 :{YELLOW}{STRINGID} STR_1173 :建造道路及‘輪候區’道路 STR_1174 :橫額擋在路上 STR_1175 :不能在斜路上建造此物件 @@ -1115,7 +1114,6 @@ STR_1727 :建造權不供購買! STR_1728 :不能在此購買建造權… STR_1729 :土地並非由樂園所擁有! STR_1730 :{RED}已關閉 -STR_1731 :{WHITE}{STRINGID} - - STR_1732 :建造 STR_1733 :模式 STR_1734 :{WINDOW_COLOUR_2}圈數: @@ -1156,7 +1154,6 @@ STR_1771 :{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{POP16}{COM STR_1773 :每個遊樂設施只可建造一個即時照相區域 STR_1774 :每個遊樂設施只可建造一個纜索坡道 STR_1777 :音樂 -STR_1778 :{STRINGID} - - STR_1790 :選擇這種員工的制服色彩 STR_1791 :{WINDOW_COLOUR_2}制服的色彩: STR_1792 :回應{STRINGID}的故障呼叫中 diff --git a/debian/control b/debian/control index a284b2bef6..0789d4b3a9 100644 --- a/debian/control +++ b/debian/control @@ -4,7 +4,7 @@ Section: misc Priority: optional Standards-Version: 3.9.2 Multi-Arch: same -Build-Depends: debhelper (>= 9), cmake (>= 3.8), libsdl2-dev, g++ (>= 4:10), pkg-config, nlohmann-json3-dev (>= 3.9.0), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev, libzip-dev (>= 1.0.0), libicu-dev (>= 59.0), libflac-dev, libvorbis-dev, libzstd-dev +Build-Depends: debhelper (>= 9), cmake (>= 3.8), libsdl2-dev, g++ (>= 4:10), pkg-config, nlohmann-json3-dev (>= 3.9.0), libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev, libzip-dev (>= 1.0.0), libicu-dev (>= 59.0), libflac-dev, libvorbis-dev, libzstd-dev Package: openrct2 Architecture: any diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 7f31b5814f..a1662c33f2 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,3 +1,31 @@ +0.4.32 (in development) +------------------------------------------------------------------------ +- Feature: [#22704] Rides can be made invisible more easily. +- Improved: [#21753] Tracked rides with cheated powered launch mode can change powered launch speed without extra cheats. +- Improved: [#25526] When a shop item cannot be recoloured, show a preview of the building instead. +- Improved: [#25941] The command line sprite build command is now faster. +- Improved: [#26002] Rides with newer track elements (like the zero G roll or diagonal brakes) can now be saved as track designs. +- Improved: [#26026] Profiler is now thread safe and supports JSON export with call graph data. +- Improved: [#26050] Add Danish translation to Windows installer. +- Improved: [#26091] When all rides are closed, the marketing window will no longer show the ride advertisement campaign. +- Change: [#26011] Audio resampling no longer depends on the third-party library libspeexdsp. +- Change: [#26049] Guest generation now starts slowing down above 52000 guests instead of 7000. +- Fix: [#14686, #23996, #25981] Preview images from different windows overwrite each other when using OpenGL. +- Fix: [#15128, #15626, #16331, #17443, #18626, #21597, #24175, #24971, #25963] Crash when loading corrupted RCT2/RCT1 save files with duplicate entity indices. +- Fix: [#23519] Title sequence cannot open .sea scenarios from RCTC. +- Fix: [#25237] Wrong colours on the Knight costume (original bug). +- Fix: [#25712, #25727] Crash during startup from window list race condition. +- Fix: [#25763] Crash when opening the Footpath window in Multiplayer. +- Fix: [#25910] Folders starting with numbers are sorted incorrectly (e.g. 1, 10, 2 instead of 1, 2, 10). +- Fix: [#25954] Guests display hats, balloons, and umbrellas while puking. +- Fix: [#25961] Fix crash when rendering malformed vehicles in the ride window. +- Fix: [#25978] Frozen peeps start clapping when the scenario is won. +- Fix: [#25999] Scenery picker tool does not pick the tertiary colour of large scenery correctly. +- Fix: [#26037] Selecting elements in the tile inspector list and changing all tiles of a track piece does not redraw correctly. +- Fix: [#26057] In the scrolling intro, the Infogrames logo is taken off the screen before it reaches the bottom (original bug). +- Fix: [#26058] RCT Classic scenarios with packed objects missing from scenario index. +- Fix: [#26083] You can advertise for closed food & drink stalls. + 0.4.31 (2026-02-01) ------------------------------------------------------------------------ - Feature: [#25844] The sprite builder now also supports adding JSON-based palettes. diff --git a/distribution/linux/io.openrct2.openrct2.appdata.xml b/distribution/linux/io.openrct2.openrct2.appdata.xml index a4b29e607b..750f2c6bd8 100644 --- a/distribution/linux/io.openrct2.openrct2.appdata.xml +++ b/distribution/linux/io.openrct2.openrct2.appdata.xml @@ -7,6 +7,7 @@ Amusement park simulation Simulador de parcs d’atraccions Simulátor zábavního parku + Forlystelsespark‑simulation Freizeitparksimulation Amuzparko-simulado Simulador de parque de atracciones @@ -21,6 +22,7 @@ The OpenRCT2 Team Equip de l’OpenRCT2 Tým OpenRCT2 + OpenRCT2 holdet Das OpenRCT2-Team La OpenRCT2-Teamo El equipo de OpenRCT2 @@ -62,6 +64,14 @@ i pískoviště. Ve scénářích má hráč za úkol splnit dané cíle v časovém limitu, zatímco na pískovišti může stavět s větší volností, volitelně bez finančních nebo jiných omezení.

+

+ OpenRCT2 er en open source‑genimplementering af RollerCoaster Tycoon 2. + Spillet går ud på at bygge og drive en forlystelsespark med attraktioner, butikker + og faciliteter. Spilleren skal skabe overskud, holde gæsterne glade og opretholde + et godt ry. OpenRCT2 kan spilles både som scenarier og i sandkassetilstand. + Scenarier kræver, at spilleren opfylder et mål inden for en tidsgrænse, mens + sandkasse giver friere rammer med mulighed for at slå begrænsninger og økonomi fra. +

OpenRCT2 ist eine Open-Source-Reimplementierung von RollerCoaster Tycoon 2 (RCT2). Im Spiel geht es um den Bau und die Verwaltung eines Freizeitparks mit Attraktionen, @@ -179,6 +189,9 @@

OpenRCT2 obsahuje mnoho změn oproti originálnímu RollerCoaster Tycoon 2, například:

+

+ OpenRCT2 indeholder mange forbedringer i forhold til det originale RollerCoaster Tycoon 2. Her er nogle af dem: +

OpenRCT2 hat viele Änderungen im Verleich mit dem Originalspiel RollerCoaster Tycoon 2. Hier sind einige von ihnen aufgelistet.

@@ -220,6 +233,7 @@
  • User Interface theming.
  • Temes per a la interfície gràfica
  • Barevné motivy uživatelského rozhraní
  • +
  • Brugerflade temaer
  • Thematische User-Interface-Anpassung.
  • Etosoj de uzantinterfaco.
  • Temas para la interfaz de usuario.
  • @@ -236,6 +250,7 @@
  • Fast-forwarding gameplay.
  • Diferents velocitats de joc
  • Možnost zrychlení hry
  • +
  • Hurtigspoling af spilhastighed.
  • Spielsimulation beschleunigen.
  • Rapidpluigo de ludado.
  • Aceleración de la velocidad del juego.
  • @@ -252,6 +267,7 @@
  • Multiplayer support.
  • Suport multijugador
  • Multiplayer - hra více hráčů
  • +
  • Multiplayer understøttelse.
  • Mehrspielerunterstützung.
  • Plurludanta subteno.
  • Soporte multijugador.
  • @@ -268,6 +284,7 @@
  • Multilingual. Improved translations.
  • Traduccions a diversos idiomes i correccions de les traduccions originals
  • Vylepšený překlad do mnoha jazyků
  • +
  • Flersproget med forbedrede oversættelser.
  • Mehrsprachig. Verbesserte Übersetzungen.
  • Plurlingva. Plibonigitaj tradukoj.
  • Traducido a varios idiomas y traducciones originales mejoradas.
  • @@ -284,6 +301,7 @@
  • OpenGL hardware rendering.
  • Renderització OpenGL per maquinari
  • OpenGL hardwarové vykreslování
  • +
  • OpenGL‑hardware‑rendering.
  • OpenGL-Hardwarerendering.
  • Aparatara bildigo de OpenGL.
  • Renderizado acelerado por hardware con OpenGL.
  • @@ -300,6 +318,7 @@
  • Various fixes and improvements for bugs in the original game.
  • Correccions i millores dels errors del joc original
  • Opravy chyb původní hry a různá vylepšení
  • +
  • Diverse fejlrettelser og forbedringer i forhold til originalspillet.
  • Diverse Fehlerkorrekturen und Verbesserungen für Fehler im Originalspiel.
  • Diversaj riparoj kaj plibonigoj por cimoj en la originala ludo.
  • Correcciones y mejoras de errores presentes en el juego original.
  • @@ -316,6 +335,7 @@
  • Native support for Linux and macOS.
  • Suport natiu per a Linux i macOS
  • Verze pro Linux a macOS
  • +
  • Indbygget support til Linux og macOS.
  • Native Unterstützung für Linux und macOS.
  • Operaciuma subteno por Linux kaj macOS.
  • Compatibilidad nativa para Linux y macOS.
  • @@ -332,6 +352,7 @@
  • Added hacks and cheats.
  • Es poden fer trucs i trampes
  • Přidané hacky a cheaty
  • +
  • Tilføjede hacks og snydekoder.
  • Eingebaute Hacks und Cheats.
  • Aldonis kodumojn kaj trompojn.
  • Incorporación de hacks y trucos.
  • @@ -348,6 +369,7 @@
  • Auto-saving and giant screenshots.
  • Desades automàtiques i captures de pantalla gegants
  • Automatické ukládaní a obrovské snímky obrazovky
  • +
  • Autosave og gigantiske Screenshots.
  • Automatisches Speichern und gigantische Screenshots.
  • Aŭtokonservado kaj gigantaj ekrankopioj.
  • Guardado automático y capturas de pantalla gigantes.
  • @@ -371,6 +393,9 @@

    OpenRCT2 vyžaduje k fungování soubory původního RollerCoaster Tycoon 2 nebo RollerCoaster Tycoon Classic.

    +

    + Originale spilfiler fra RollerCoaster Tycoon 2 eller RollerCoaster Tycoon Classic kræves for at spille OpenRCT2. +

    Die Originaldateien von RollerCoaster Tycoon 2 oder RollerCoaster Tycoon Classic werden benötigt, um OpenRCT2 zu spielen.

    @@ -410,10 +435,11 @@ - https://camo.githubusercontent.com/f513bc551e2c9e04e292724113ea4789726d23921d286f21dad39a6e955b5a56/68747470733a2f2f692e696d6775722e636f6d2f6537434b3553632e706e67 + https://openrct2.io/uploads/images/showcase/screenshot1.png Amusement park featuring an inverted roller coaster, a river rapids ride and custom scenery Parc d’atraccions amb una muntanya russa invertida, ràpids amb bots inflables i decoracions temàtiques. Zábavní park s obrácenou horskou dráhou, projížďkou po divoké vodě a uživatelskými kulisami + Forlystelsespark med en inverted rutsjebane, river rapids og specialbygget sceneri Freizeitpark mit einer umgekehrten Achterbahn, einer Stromschnellenattraktion und einer eigens errichteten Szenerie Amuzparko havante inversan ondan fervojon, rapidfluo-rajdon kaj propran pejzaĝon Parque de atracciones con una montaña rusa invertida, un recorrido de rápidos y decoraciones personalizadas. @@ -433,6 +459,7 @@ https://github.com/OpenRCT2/OpenRCT2/wiki/FAQ-&-Common-Issues https://docs.openrct2.io https://github.com/OpenRCT2/Localisation + https://github.com/OpenRCT2/OpenRCT2 mild none diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index 69dc880176..30fb4de9f9 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -844,11 +844,10 @@ declare global { /** Surface object */ object: number; railingsObject: number; - /** - * - `0`: Flat - * - `4`, `5`, `6`, `7`: Slope direction + 4 - */ - slope: number; + /** 0 if flat, 1 if sloped */ + slopeType: number; // + /** direction if sloped, otherwise ignored */ + slopeDirection: Direction; constructFlags: number; } @@ -2309,6 +2308,12 @@ declare global { /** * Various flags related to the operation of the ride. */ + flags: number; + + /** + * Old name of ‘flags’ property + * @deprecated + */ lifecycleFlags: number; /** diff --git a/distribution/readme.txt b/distribution/readme.txt index ce496cdc5d..ce0bfa9a58 100644 --- a/distribution/readme.txt +++ b/distribution/readme.txt @@ -1,4 +1,4 @@ -Last updated: 2025-08-04 +Last updated: 2026-02-15 ------------------------------------------------------------------------ @@ -146,7 +146,6 @@ duktape | MIT licence. libcURL | MIT (or Modified BSD-style) licence. libicu | Unicode licence. libpng | libpng licence. -libspeex | BSD-style licence. libzip | BSD 3 clause licence. nlohmann-json | MIT licence. OpenSSL | OpenSSL licence. diff --git a/distribution/windows/install.nsi b/distribution/windows/install.nsi index b89e4fcbb9..bd4af31fd4 100644 --- a/distribution/windows/install.nsi +++ b/distribution/windows/install.nsi @@ -108,7 +108,7 @@ ManifestDPIAware true !insertmacro MUI_LANGUAGE "Arabic" !insertmacro MUI_LANGUAGE "Catalan" !insertmacro MUI_LANGUAGE "Czech" -;!insertmacro MUI_LANGUAGE "Danish" +!insertmacro MUI_LANGUAGE "Danish" !insertmacro MUI_LANGUAGE "German" ;!insertmacro MUI_LANGUAGE "Esperanto" !insertmacro MUI_LANGUAGE "Spanish" @@ -136,6 +136,7 @@ ManifestDPIAware true !include "language\install_ar.nsi" !include "language\install_ca.nsi" !include "language\install_cs.nsi" +!include "language\install_da.nsi" !include "language\install_de.nsi" !include "language\install_es.nsi" !include "language\install_fi.nsi" diff --git a/distribution/windows/language/install_da.nsi b/distribution/windows/language/install_da.nsi new file mode 100644 index 0000000000..fa9bb7a08a --- /dev/null +++ b/distribution/windows/language/install_da.nsi @@ -0,0 +1,23 @@ +LangString ls32bitVersionOn64bitOS ${LANG_DANISH} "Du forsøger at installere 32-bit OpenRCT2 på et 64-bit operativsystem. Dette anbefales ikke, men vil fungere med begrænsede muligheder. Vi foreslår, at du downloader den korrekte version. Vil du virkelig fortsætte?" +LangString ls64bitVersionOn32bitOS ${LANG_DANISH} "Du forsøger at installere 64-bit OpenRCT2 på et 32-bit operativsystem. Dette kommer ikke til at virke. Download venligst den korrekte version. Vil du virkelig fortsætte?" +LangString lsBrandingText ${LANG_DANISH} "OpenRCT2-installationsprogram" +LangString lsCannotInstallToRCT2Dir ${LANG_DANISH} "Du kan ikke installere OpenRCT2 i samme mappe som RollerCoaster Tycoon 2." +LangString lsCannotInstallToRCTClassicDir ${LANG_DANISH} "Du kan ikke installere OpenRCT2 i samme mappe som RollerCoaster Tycoon Classic." +LangString lsComponentDescription ${LANG_DANISH} "Minimal OpenRCT2-installation. Du skal have RollerCoaster Tycoon 2 eller Classic installeret." +LangString lsFinishPageLink ${LANG_DANISH} "Besøg OpenRCT2-siden for mere information" +LangString lsInstallerName ${LANG_DANISH} "${APPNAMEANDVERSION} ${PLATFORM} til $(lsSupportedOS)" +LangString lsNewWindowsVersionOnOldWindows ${LANG_DANISH} "Du forsøger at installere versionen til Windows XP SP3, Vista og nyere på Windows 95, 98, ME, 2000 eller XP uden SP3. Dette vil ikke virke. Download venligst den korrekte version. Vil du virkelig fortsætte?" +LangString lsOldWindowsVersionOnNewWindows ${LANG_DANISH} "Du forsøger at installere versionen til Windows 95, 98, 2000 og XP uden SP3 på Windows XP SP3, Vista eller nyere. Dette anbefales ikke, men vil fungere med begrænsede muligheder. Vi foreslår, at du downloader den korrekte version. Vil du virkelig fortsætte?" +LangString lsOpenRCT2IsRunning ${LANG_DANISH} "OpenRCT2 kører. Luk det venligst og prøv igen." +LangString lsRunNow ${LANG_DANISH} "Kør ${APPNAMEANDVERSION} nu!" +LangString lsSupportedOS ${LANG_DANISH} "Windows 7 og nyere" +LangString lsUACErrorDefault ${LANG_DANISH} "Kan ikke forhøje rettigheder, fejl $0" +LangString lsUACError1062 ${LANG_DANISH} "Logon-tjenesten kører ikke, afbryder!" +LangString lsUACError1223 ${LANG_DANISH} "Denne ${thing} kræver administratorrettigheder, afbryder!" +LangString lsUACRequiresElevation ${LANG_DANISH} "Denne ${thing} kræver administratorrettigheder, prøv igen" +LangString lsUninstall ${LANG_DANISH} "Afinstaller ${APPNAMEANDVERSION}" +LangString lsUpgradeNotice ${LANG_DANISH} "Velkommen til ${APPNAMEANDVERSION}-opsætningen.$\nDette giver dig mulighed for at opgradere fra version $OLDVERSION." +VIAddVersionKey /LANG=${LANG_DANISH} "Comments" "Installerer ${APPNAMEANDVERSION}" +VIAddVersionKey /LANG=${LANG_DANISH} "CompanyName" "OpenRCT2-udviklerne" +VIAddVersionKey /LANG=${LANG_DANISH} "FileDescription" "Installerer ${APPNAMEANDVERSION}" +VIAddVersionKey /LANG=${LANG_DANISH} "ProductName" "OpenRCT2 ${PLATFORM}-installationsprogram til Windows 7 og nyere" diff --git a/openrct2.common.props b/openrct2.common.props index 9028146f6d..2025a0f66e 100644 --- a/openrct2.common.props +++ b/openrct2.common.props @@ -21,6 +21,10 @@ x64-windows-static arm64-windows-static + + + true + true @@ -88,7 +92,7 @@ DebugFull brotlicommon.lib;brotlidec.lib;brotlienc.lib;%(AdditionalDependencies) libbreakpadd.lib;libbreakpad_clientd.lib;%(AdditionalDependencies) - bz2d.lib;discord-rpc.lib;flac.lib;freetyped.lib;libpng16d.lib;ogg.lib;speexdsp.lib;SDL2-staticd.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlibd.lib;zstd.lib;%(AdditionalDependencies) + bz2d.lib;discord-rpc.lib;flac.lib;freetyped.lib;libpng16d.lib;ogg.lib;SDL2-staticd.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlibd.lib;zstd.lib;%(AdditionalDependencies) @@ -109,7 +113,7 @@ true brotlicommon.lib;brotlidec.lib;brotlienc.lib;%(AdditionalDependencies) libbreakpad.lib;libbreakpad_client.lib;%(AdditionalDependencies) - bz2.lib;discord-rpc.lib;flac.lib;freetype.lib;libpng16.lib;ogg.lib;speexdsp.lib;SDL2-static.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlib.lib;zstd.lib;%(AdditionalDependencies) + bz2.lib;discord-rpc.lib;flac.lib;freetype.lib;libpng16.lib;ogg.lib;SDL2-static.lib;vorbis.lib;vorbisfile.lib;zip.lib;zlib.lib;zstd.lib;%(AdditionalDependencies) @@ -131,3 +135,4 @@ false + diff --git a/openrct2.deps.targets b/openrct2.deps.targets index 551f7375f4..7567486b93 100644 --- a/openrct2.deps.targets +++ b/openrct2.deps.targets @@ -1,10 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TaskFactory="RoslynCodeTaskFactory" + AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> @@ -13,8 +99,6 @@ - - @@ -206,32 +290,41 @@ - + $(MsBuildThisFileDirectory) $(RootDir).dependencies + $(RootDir)assets.json https://github.com/OpenRCT2/Dependencies/releases/download/v41/openrct2-libs-v41-arm64-windows-static.zip 5d171f23eee584bdc29b1186dc7a86d935a6ea58efa42b5674c196c5b581923b https://github.com/OpenRCT2/Dependencies/releases/download/v41/openrct2-libs-v41-x64-windows-static.zip 8e78f1c3c09c50cb0f509eab6845a93dd69771ff95cdf82d747568093d138f73 https://github.com/OpenRCT2/Dependencies/releases/download/v41/openrct2-libs-v41-x86-windows-static.zip 490263b873dd02c13a043a04d26bb9837d2d378dacd8b2c8d29660fef44db3db - https://github.com/OpenRCT2/title-sequences/releases/download/v0.4.26/title-sequences.zip - dabb9787b1576342fca4dd9f64b3f8cfa04a7e6ce9c2bb9610f47b762905c858 - https://github.com/OpenRCT2/objects/releases/download/v1.7.6/objects.zip - 6aca2eb441fbe8c022ff84d59fb51ed7ea577756640970dc989eab685ff45696 - https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v1.0.6/opensound.zip - 06b90f3e19c216752df441d551b26a9e3e1ba7755bdd2102504b73bf993608be - https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6.1/openmusic.zip - 994b350d3b180ee1cb9619fe27f7ebae3a1a5232840c4bd47a89f33fa89de1a1 - https://github.com/OpenRCT2/replays/releases/download/v0.0.92/replays.zip - 455a19172a8df81b935a942bbbda20167b4740b34653fdb74127740686bf4cbe + + + + + + + + + + + + + + + + + DependsOnTargets="LoadAssetsJson;DownloadLibs;DownloadTitleSequences;DownloadObjects;DownloadOpenSFX;DownloadOpenMusic;DownloadReplays"> @@ -275,11 +368,11 @@ OutputDirectory="$(TargetDir)data" /> - - - + + diff --git a/openrct2.targets b/openrct2.targets index 2da26f6f8e..ec018e3ae8 100644 --- a/openrct2.targets +++ b/openrct2.targets @@ -113,7 +113,7 @@ - @@ -133,7 +133,7 @@ - @@ -153,7 +153,7 @@ - @@ -173,7 +173,7 @@ - diff --git a/scripts/build b/scripts/build index 5e6164d204..ab0fb72dc3 100755 --- a/scripts/build +++ b/scripts/build @@ -24,7 +24,7 @@ if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then # Build everything echo -e "\033[0;36mBuilding OpenRCT2 for Windows $CONFIGURATION|$PLATFORM...\033[0m" - vstool msbuild openrct2.proj -t:build -p:Breakpad=true -p:UsePCH=true + vstool msbuild openrct2.proj -t:build -p:Breakpad=true -p:UsePCH=true -maxcpucount # Create openrct2.exe and openrct2.com with correct subsystem cp bin/openrct2.exe bin/openrct2.com diff --git a/scripts/build-emscripten b/scripts/build-emscripten index d6604f1ed2..2780a9af0f 100755 --- a/scripts/build-emscripten +++ b/scripts/build-emscripten @@ -6,7 +6,6 @@ mkdir -p build cd build START_DIR=$(pwd) -SPEEXDSP_ROOT=/ext/speexdsp ICU_ROOT=/ext/icu/icu4c/source LIBZIP_ROOT=/ext/libzip ZSTD_ROOT=/ext/zstd @@ -22,8 +21,6 @@ emcmake cmake ../ \ -DDISABLE_DISCORD_RPC=ON \ -DCMAKE_SYSTEM_NAME=Emscripten \ -DCMAKE_BUILD_TYPE=Release \ - -DSPEEXDSP_INCLUDE_DIR="$SPEEXDSP_ROOT/include/" \ - -DSPEEXDSP_LIBRARY="$SPEEXDSP_ROOT/libspeexdsp/.libs/libspeexdsp.a" \ -DICU_INCLUDE_DIR="$ICU_ROOT/common" \ -DICU_DATA_LIBRARIES=$ICU_ROOT/lib/libicuuc.so \ -DICU_DT_LIBRARY_RELEASE="$ICU_ROOT/stubdata/libicudata.so" \ diff --git a/src/openrct2-android/app/build.gradle b/src/openrct2-android/app/build.gradle index 45160cf476..f14699cb41 100644 --- a/src/openrct2-android/app/build.gradle +++ b/src/openrct2-android/app/build.gradle @@ -1,63 +1,72 @@ apply plugin: 'com.android.application' android { - compileSdk 36 - ndkVersion "27.3.13750724" // Latest r27d (LTS), to be synced with CI container image - namespace "io.openrct2" + compileSdk = 36 + buildToolsVersion = "36.0.0" // to be synced with CI container image + ndkVersion = "27.3.13750724" // Latest r27d (LTS), to be synced with CI container image + namespace = "io.openrct2" signingConfigs { release { if (System.getenv('OPENRCT2_KEYSTORE_FILE') && System.getenv('OPENRCT2_KEYSTORE_PASSWORD')) { - storeFile file(System.getenv('OPENRCT2_KEYSTORE_FILE')) - storePassword System.getenv('OPENRCT2_KEYSTORE_PASSWORD') - keyAlias "openrct2" - keyPassword System.getenv('OPENRCT2_KEYSTORE_PASSWORD') // Same as keystore password in PKCS12 + storeFile = file(System.getenv('OPENRCT2_KEYSTORE_FILE')) + storePassword = System.getenv('OPENRCT2_KEYSTORE_PASSWORD') + keyAlias = "openrct2" + keyPassword = System.getenv('OPENRCT2_KEYSTORE_PASSWORD') // Same as keystore password in PKCS12 } } } defaultConfig { - applicationId 'io.openrct2' - minSdkVersion 24 - targetSdkVersion 36 + applicationId = 'io.openrct2' + minSdkVersion = 24 + targetSdkVersion = 36 - versionCode 18 - versionName '0.4.31' - externalNativeBuild { - cmake { - arguments '-DANDROID_STL=c++_shared', '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON' - targets 'openrct2', 'openrct2-ui', 'openrct2-cli' - // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' - abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' + versionCode = 18 + versionName = '0.4.31' + if (!project.hasProperty('skipNativeBuild')) { + externalNativeBuild { + cmake { + arguments '-DANDROID_STL=c++_shared', '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON' + targets 'openrct2', 'openrct2-ui', 'openrct2-cli' + if (project.hasProperty('abiFilter')) { + abiFilters project.property('abiFilter').split(',') + } else { + // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' + abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' + } + } } } } buildTypes { release { if (System.getenv('OPENRCT2_KEYSTORE_FILE') && System.getenv('OPENRCT2_KEYSTORE_PASSWORD')) { - signingConfig signingConfigs.release + signingConfig = signingConfigs.release } else { // Fallback to ephemeral debug signing when keystore is not available - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } } sourceSets.main { - jniLibs.srcDir 'libs' + jniLibs.srcDirs = ['libs'] java { - srcDir 'src/main/java' + srcDir('src/main/java') } } - externalNativeBuild { - cmake { - version "4.0.3" - path 'src/main/CMakeLists.txt' + if (!project.hasProperty('skipNativeBuild')) { + externalNativeBuild { + cmake { + version = "4.0.3" + path = 'src/main/CMakeLists.txt' + } } } lintOptions { - abortOnError false + abortOnError = false } } diff --git a/src/openrct2-android/app/src/main/AndroidManifest.xml b/src/openrct2-android/app/src/main/AndroidManifest.xml index 2f96334c16..ef45811647 100644 --- a/src/openrct2-android/app/src/main/AndroidManifest.xml +++ b/src/openrct2-android/app/src/main/AndroidManifest.xml @@ -18,6 +18,7 @@ android:label="@string/app_name" android:largeHeap="true" android:theme="@style/AppTheme.Splash" + android:requestLegacyExternalStorage="true" tools:targetApi="36"> #include #include -#include namespace OpenRCT2::Audio { @@ -25,7 +24,6 @@ namespace OpenRCT2::Audio private: AudioSource_* _source = nullptr; - SpeexResamplerState* _resampler = nullptr; MixerGroup _group = MixerGroup::Sound; double _rate = 0; @@ -52,30 +50,11 @@ namespace OpenRCT2::Audio AudioChannelImpl::SetPan(0.5f); } - ~AudioChannelImpl() override - { - if (_resampler != nullptr) - { - speex_resampler_destroy(_resampler); - _resampler = nullptr; - } - } - [[nodiscard]] IAudioSource* GetSource() const override { return _source; } - [[nodiscard]] SpeexResamplerState* GetResampler() const override - { - return _resampler; - } - - void SetResampler(SpeexResamplerState* value) override - { - _resampler = value; - } - [[nodiscard]] MixerGroup GetGroup() const override { return _group; diff --git a/src/openrct2-ui/audio/AudioContext.h b/src/openrct2-ui/audio/AudioContext.h index 8451b3bae8..fe45af0ed2 100644 --- a/src/openrct2-ui/audio/AudioContext.h +++ b/src/openrct2-ui/audio/AudioContext.h @@ -15,7 +15,6 @@ #include struct SDL_RWops; -using SpeexResamplerState = struct SpeexResamplerState_; namespace OpenRCT2::Audio { @@ -25,8 +24,6 @@ namespace OpenRCT2::Audio struct ISDLAudioChannel : public IAudioChannel { [[nodiscard]] virtual AudioFormat GetFormat() const = 0; - [[nodiscard]] virtual SpeexResamplerState* GetResampler() const = 0; - virtual void SetResampler(SpeexResamplerState* value) = 0; }; namespace AudioChannel diff --git a/src/openrct2-ui/audio/AudioMixer.cpp b/src/openrct2-ui/audio/AudioMixer.cpp index ad7ea788ba..6d80ca64b9 100644 --- a/src/openrct2-ui/audio/AudioMixer.cpp +++ b/src/openrct2-ui/audio/AudioMixer.cpp @@ -13,7 +13,6 @@ #include #include #include -#include using namespace OpenRCT2::Audio; @@ -124,6 +123,7 @@ const AudioFormat& AudioMixer::GetFormat() const return _outputFormat; } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::GetNextAudioChunk(uint8_t* dst, size_t length) { UpdateAdjustedSound(); @@ -156,6 +156,7 @@ void AudioMixer::GetNextAudioChunk(uint8_t* dst, size_t length) } } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::UpdateAdjustedSound() { // Did the volume level get changed? Recalculate level in this case. @@ -171,6 +172,7 @@ void AudioMixer::UpdateAdjustedSound() } } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::MixChannel(ISDLAudioChannel* channel, uint8_t* data, size_t length) { int32_t outputByteRate = _outputFormat.GetByteRate(); @@ -236,8 +238,7 @@ void AudioMixer::MixChannel(ISDLAudioChannel* channel, uint8_t* data, size_t len outRate = _outputFormat.freq * (1 / rate); } _effectBuffer.resize(length); - bufferLen = ApplyResample( - channel, buffer, static_cast(bufferLen / outputByteRate), numSamples, inRate, outRate); + bufferLen = ApplyResample(buffer, static_cast(bufferLen / outputByteRate), numSamples, inRate, outRate); buffer = _effectBuffer.data(); } @@ -256,30 +257,60 @@ void AudioMixer::MixChannel(ISDLAudioChannel* channel, uint8_t* data, size_t len /** * Resample the given buffer into _effectBuffer. * Assumes that srcBuffer is the same format as _outputFormat. + * + * TODO: investigate replacing this with OpenAL (#26035) */ -size_t AudioMixer::ApplyResample( - ISDLAudioChannel* channel, const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, int32_t outRate) +size_t AudioMixer::ApplyResample(const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, int32_t outRate) { - int32_t outputByteRate = _outputFormat.GetByteRate(); + // Prevent buffer underread in inner loop + if (srcSamples < 2) + return 0; - // Create resampler - SpeexResamplerState* resampler = channel->GetResampler(); - if (resampler == nullptr) + const int channels = _outputFormat.channels; + const int bytesPerFrame = channels * sizeof(int16_t); + + const int16_t* src = static_cast(srcBuffer); + int16_t* dst = reinterpret_cast(_effectBuffer.data()); + + double ratio = static_cast(inRate) / static_cast(outRate); + + for (int32_t i = 0; i < dstSamples; ++i) { - resampler = speex_resampler_init(_outputFormat.channels, _outputFormat.freq, _outputFormat.freq, 0, nullptr); - channel->SetResampler(resampler); + double srcPos = i * ratio; + int32_t index = static_cast(srcPos); + double frac = srcPos - index; + + // Clamp to avoid reading past end + if (index >= srcSamples - 1) + { + index = srcSamples - 2; + frac = 1.0; + } + + for (int ch = 0; ch < channels; ++ch) + { + int32_t baseIndex = index * channels + ch; + + int16_t s1 = src[baseIndex]; + int16_t s2 = src[baseIndex + channels]; + + // Linear interpolation + double sample = (1.0 - frac) * s1 + frac * s2; + + // Clamp to int16 range + if (sample > 32767.0) + sample = 32767.0; + if (sample < -32768.0) + sample = -32768.0; + + dst[i * channels + ch] = static_cast(sample); + } } - speex_resampler_set_rate(resampler, inRate, outRate); - uint32_t inLen = srcSamples; - uint32_t outLen = dstSamples; - speex_resampler_process_interleaved_int( - resampler, static_cast(srcBuffer), &inLen, reinterpret_cast(_effectBuffer.data()), - &outLen); - - return outLen * outputByteRate; + return dstSamples * bytesPerFrame; } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::ApplyPan(const IAudioChannel* channel, void* buffer, size_t len, size_t sampleSize) { if (channel->GetPan() != 0.5f && _outputFormat.channels == 2) @@ -296,6 +327,7 @@ void AudioMixer::ApplyPan(const IAudioChannel* channel, void* buffer, size_t len } } +// TODO: investigate replacing this with OpenAL (#26035) int32_t AudioMixer::ApplyVolume(const IAudioChannel* channel, void* buffer, size_t len) { float volumeAdjust = _volume; @@ -347,6 +379,7 @@ int32_t AudioMixer::ApplyVolume(const IAudioChannel* channel, void* buffer, size return mixVolume; } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::EffectPanS16(const IAudioChannel* channel, int16_t* data, int32_t length) { const float dt = 1.0f / static_cast(length * 2.0f); @@ -364,6 +397,7 @@ void AudioMixer::EffectPanS16(const IAudioChannel* channel, int16_t* data, int32 } } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::EffectPanU8(const IAudioChannel* channel, uint8_t* data, int32_t length) { float volumeL = channel->GetVolumeL(); @@ -379,6 +413,7 @@ void AudioMixer::EffectPanU8(const IAudioChannel* channel, uint8_t* data, int32_ } } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::EffectFadeS16(int16_t* data, int32_t length, int32_t startvolume, int32_t endvolume) { static_assert(SDL_MIX_MAXVOLUME == kMixerVolumeMax, "Max volume differs between OpenRCT2 and SDL2"); @@ -392,6 +427,7 @@ void AudioMixer::EffectFadeS16(int16_t* data, int32_t length, int32_t startvolum } } +// TODO: investigate replacing this with OpenAL (#26035) void AudioMixer::EffectFadeU8(uint8_t* data, int32_t length, int32_t startvolume, int32_t endvolume) { static_assert(SDL_MIX_MAXVOLUME == kMixerVolumeMax, "Max volume differs between OpenRCT2 and SDL2"); diff --git a/src/openrct2-ui/audio/AudioMixer.h b/src/openrct2-ui/audio/AudioMixer.h index b43d655e21..df68e18b86 100644 --- a/src/openrct2-ui/audio/AudioMixer.h +++ b/src/openrct2-ui/audio/AudioMixer.h @@ -69,9 +69,7 @@ namespace OpenRCT2::Audio * Resample the given buffer into _effectBuffer. * Assumes that srcBuffer is the same format as _outputFormat. */ - size_t ApplyResample( - ISDLAudioChannel* channel, const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, - int32_t outRate); + size_t ApplyResample(const void* srcBuffer, int32_t srcSamples, int32_t dstSamples, int32_t inRate, int32_t outRate); void ApplyPan(const IAudioChannel* channel, void* buffer, size_t len, size_t sampleSize); int32_t ApplyVolume(const IAudioChannel* channel, void* buffer, size_t len); static void EffectPanS16(const IAudioChannel* channel, int16_t* data, int32_t length); diff --git a/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp index 6c812b170b..80f085aa15 100644 --- a/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/HardwareDisplayDrawingEngine.cpp @@ -272,7 +272,7 @@ private: SDL_RenderPresent(_sdlRenderer); } - void CopyBitsToTexture(SDL_Texture* texture, uint8_t* src, int32_t width, int32_t height, const uint32_t* palette) + void CopyBitsToTexture(SDL_Texture* texture, PaletteIndex* src, int32_t width, int32_t height, const uint32_t* palette) { void* pixels; int32_t pitch; @@ -284,7 +284,7 @@ private: uint32_t* dst = static_cast(pixels); for (int32_t i = width * height; i > 0; i--) { - *dst++ = palette[*src++]; + *dst++ = palette[EnumValue(*src++)]; } } else @@ -296,8 +296,8 @@ private: { for (int32_t x = width; x > 0; x--) { - const uint8_t lower = *reinterpret_cast(&palette[*src++]); - const uint8_t upper = *reinterpret_cast(&palette[*src++]); + const uint8_t lower = *reinterpret_cast(&palette[EnumValue(*src++)]); + const uint8_t upper = *reinterpret_cast(&palette[EnumValue(*src++)]); *dst++ = (lower << 8) | upper; } dst = reinterpret_cast(reinterpret_cast(dst) + padding); @@ -310,7 +310,7 @@ private: { for (int32_t x = width; x > 0; x--) { - *dst++ = *reinterpret_cast(&palette[*src++]); + *dst++ = *reinterpret_cast(&palette[EnumValue(*src++)]); } dst += padding; } diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp index 39ba3d5435..93d25ac655 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLDrawingEngine.cpp @@ -117,7 +117,7 @@ public: void Clear(RenderTarget& rt, PaletteIndex paletteIndex) override; void FillRect( - RenderTarget& rt, PaletteIndex paletteIndex, int32_t x, int32_t y, int32_t w, int32_t h, + RenderTarget& rt, PaletteIndex paletteIndex, int32_t left, int32_t top, int32_t right, int32_t bottom, bool crossHatch = false) override; void FilterRect( RenderTarget& rt, FilterPaletteID palette, int32_t left, int32_t top, int32_t right, int32_t bottom) override; @@ -204,7 +204,7 @@ private: uint32_t _height = 0; uint32_t _pitch = 0; size_t _bitsSize = 0; - std::unique_ptr _bits; + std::unique_ptr _bits; RenderTarget _mainRT = {}; @@ -485,8 +485,8 @@ public: framebuffer.GetPixels(_mainRT); int32_t stride = _mainRT.LineStride(); - uint8_t* to = _mainRT.bits + y * stride + x; - uint8_t* from = _mainRT.bits + (y - dy) * stride + x - dx; + PaletteIndex* to = _mainRT.bits + y * stride + x; + PaletteIndex* from = _mainRT.bits + (y - dy) * stride + x - dx; if (dy > 0) { @@ -552,10 +552,10 @@ private: { size_t newBitsSize = pitch * height; - auto newBits = std::make_unique(newBitsSize); + auto newBits = std::make_unique(newBitsSize); if (_bits == nullptr) { - std::fill_n(newBits.get(), newBitsSize, 0); + std::fill_n(newBits.get(), newBitsSize, PaletteIndex::transparent); } else { @@ -565,8 +565,8 @@ private: } else { - uint8_t* src = _bits.get(); - uint8_t* dst = newBits.get(); + PaletteIndex* src = _bits.get(); + PaletteIndex* dst = newBits.get(); uint32_t minWidth = std::min(_width, width); uint32_t minHeight = std::min(_height, height); @@ -575,7 +575,7 @@ private: std::copy_n(src, minWidth, dst); if (pitch - minWidth > 0) { - std::fill_n(dst + minWidth, pitch - minWidth, 0); + std::fill_n(dst + minWidth, pitch - minWidth, PaletteIndex::transparent); } src += _pitch; dst += pitch; diff --git a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp index 0dfc5bbb4b..e052768fdb 100644 --- a/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/OpenGLFramebuffer.cpp @@ -184,14 +184,14 @@ void OpenGLFramebuffer::GetPixels(Drawing::RenderTarget& rt) const { assert(rt.width == _width && rt.height == _height); - auto pixels = std::make_unique(_width * _height); + auto pixels = std::make_unique(_width * _height); glCall(glBindTexture, GL_TEXTURE_2D, _texture); glCall(glPixelStorei, GL_PACK_ALIGNMENT, 1); glCall(glGetTexImage, GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, pixels.get()); // Flip pixels vertically on copy - uint8_t* src = pixels.get() + ((_height - 1) * _width); - uint8_t* dst = rt.bits; + Drawing::PaletteIndex* src = pixels.get() + ((_height - 1) * _width); + Drawing::PaletteIndex* dst = rt.bits; for (int32_t y = 0; y < _height; y++) { std::copy_n(src, _width, dst); @@ -204,10 +204,10 @@ void OpenGLFramebuffer::SetPixels(const Drawing::RenderTarget& rt) { assert(rt.width == _width && rt.height == _height); - auto pixels = std::make_unique(_width * _height); + auto pixels = std::make_unique(_width * _height); // Flip pixels vertically on copy - uint8_t* dst = pixels.get() + ((_height - 1) * _width); - uint8_t* src = rt.bits; + Drawing::PaletteIndex* dst = pixels.get() + ((_height - 1) * _width); + Drawing::PaletteIndex* src = rt.bits; for (int32_t y = 0; y < _height; y++) { std::copy_n(src, _width, dst); diff --git a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp index 34b6165d6a..da75ed1461 100644 --- a/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp +++ b/src/openrct2-ui/drawing/engines/opengl/TextureCache.cpp @@ -213,7 +213,7 @@ void TextureCache::GeneratePaletteTexture() // Init no-op palette for (int i = 0; i < width; ++i) { - rt.bits[i] = i; + rt.bits[i] = static_cast(i); } for (int i = 0; i < kPaletteTotalOffsets; ++i) @@ -390,8 +390,8 @@ void TextureCache::FreeTextures() RenderTarget TextureCache::CreateRT(int32_t width, int32_t height) { size_t numPixels = width * height; - auto pixels8 = new uint8_t[numPixels]; - std::fill_n(pixels8, numPixels, 0); + auto pixels8 = new PaletteIndex[numPixels]; + std::fill_n(pixels8, numPixels, PaletteIndex::transparent); RenderTarget rt; rt.bits = pixels8; diff --git a/src/openrct2-ui/drawing/engines/opengl/TextureCache.h b/src/openrct2-ui/drawing/engines/opengl/TextureCache.h index b80917bcfe..2c29bf77dd 100644 --- a/src/openrct2-ui/drawing/engines/opengl/TextureCache.h +++ b/src/openrct2-ui/drawing/engines/opengl/TextureCache.h @@ -19,11 +19,10 @@ #include #include -struct PaletteMap; - namespace OpenRCT2::Drawing { enum class FilterPaletteID : int32_t; + struct PaletteMap; struct RenderTarget; } // namespace OpenRCT2::Drawing @@ -208,7 +207,7 @@ namespace OpenRCT2::Ui ~TextureCache(); void InvalidateImage(ImageIndex image); BasicTextureInfo GetOrLoadImageTexture(ImageId imageId); - BasicTextureInfo GetOrLoadGlyphTexture(ImageId imageId, const PaletteMap& paletteMap); + BasicTextureInfo GetOrLoadGlyphTexture(ImageId imageId, const Drawing::PaletteMap& paletteMap); BasicTextureInfo GetOrLoadBitmapTexture(ImageIndex image, const void* pixels, size_t width, size_t height); GLuint GetAtlasesTexture(); @@ -221,11 +220,11 @@ namespace OpenRCT2::Ui void GeneratePaletteTexture(); void EnlargeAtlasesTexture(GLuint newEntries); AtlasTextureInfo LoadImageTexture(ImageId image); - AtlasTextureInfo LoadGlyphTexture(ImageId image, const PaletteMap& paletteMap); + AtlasTextureInfo LoadGlyphTexture(ImageId image, const Drawing::PaletteMap& paletteMap); AtlasTextureInfo AllocateImage(int32_t imageWidth, int32_t imageHeight); AtlasTextureInfo LoadBitmapTexture(ImageIndex image, const void* pixels, size_t width, size_t height); static Drawing::RenderTarget GetImageAsRT(ImageId imageId); - static Drawing::RenderTarget GetGlyphAsRT(ImageId imageId, const PaletteMap& paletteMap); + static Drawing::RenderTarget GetGlyphAsRT(ImageId imageId, const Drawing::PaletteMap& paletteMap); void FreeTextures(); static Drawing::RenderTarget CreateRT(int32_t width, int32_t height); diff --git a/src/openrct2-ui/input/Shortcuts.cpp b/src/openrct2-ui/input/Shortcuts.cpp index b3a0c0c069..6be76bd5be 100644 --- a/src/openrct2-ui/input/Shortcuts.cpp +++ b/src/openrct2-ui/input/Shortcuts.cpp @@ -23,10 +23,11 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/interface/Dropdown.h b/src/openrct2-ui/interface/Dropdown.h index 6f619e3ae8..bf9d1217ca 100644 --- a/src/openrct2-ui/interface/Dropdown.h +++ b/src/openrct2-ui/interface/Dropdown.h @@ -52,8 +52,8 @@ namespace OpenRCT2::Ui::Windows std::span items, int32_t width, size_t prefRowsPerColumn = 0); void WindowDropdownShowImage( - int32_t x, int32_t y, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, int32_t itemWidth, - int32_t itemHeight, int32_t numColumns); + const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, + int32_t itemWidth, int32_t itemHeight, int32_t numColumns); void WindowDropdownClose(); @@ -86,7 +86,7 @@ namespace OpenRCT2::Dropdown enum class ItemType { /** - * Regular label with padding at the left. Will get marked with » if selected. + * Regular label with padding on the left. Will get marked with » if selected. */ regular, /** diff --git a/src/openrct2-ui/interface/FileBrowser.cpp b/src/openrct2-ui/interface/FileBrowser.cpp index 92f4b3b15c..6f476a7357 100644 --- a/src/openrct2-ui/interface/FileBrowser.cpp +++ b/src/openrct2-ui/interface/FileBrowser.cpp @@ -69,7 +69,7 @@ namespace OpenRCT2::Ui::FileBrowser const bool isSave = (action == LoadSaveAction::save); const auto defaultDirectory = GetDir(type); - const u8string path = OpenSystemFileBrowser(isSave, type, defaultDirectory, defaultPath); + const u8string path = OpenSystemFileBrowser(isSave, type, defaultDirectory, defaultPath, trackDesign); if (!path.empty()) { Select(path.c_str(), action, type, trackDesign); @@ -174,7 +174,7 @@ namespace OpenRCT2::Ui::FileBrowser return env.GetDirectoryPath(DirBase::user); } - const char* GetFilterPatternByType(const LoadSaveType type, const bool isSave) + u8string GetFilterPatternByType(const LoadSaveType type, const bool isSave, const TrackDesign* trackDesign) { switch (type) { @@ -188,7 +188,15 @@ namespace OpenRCT2::Ui::FileBrowser return isSave ? "*.park" : "*.park;*.sc6;*.sc4"; case LoadSaveType::track: - return isSave ? "*.td6" : "*.td6;*.td4"; + { + if (!isSave) + return "*.td6;*.td4;*.td7"; + + if (trackDesign == nullptr) + return "*.td6"; + + return "*" + trackDesignGetExtension(trackDesign->version); + } case LoadSaveType::heightmap: return "*.bmp;*.png"; @@ -197,12 +205,12 @@ namespace OpenRCT2::Ui::FileBrowser Guard::Fail("Unsupported load/save directory type."); } - return nullptr; + return {}; } u8string RemovePatternWildcard(u8string_view pattern) { - while (pattern.length() >= 1 && pattern.front() == '*') + while (!pattern.empty() && pattern.front() == '*') { pattern.remove_prefix(1); } @@ -412,9 +420,10 @@ namespace OpenRCT2::Ui::FileBrowser } case LoadSaveType::track: { + auto extension = trackDesignGetExtension(trackDesignPtr->version); SetAndSaveConfigPath(Config::Get().general.lastSaveTrackDirectory, pathBuffer); - const auto withExtension = Path::WithExtension(pathBuffer, ".td6"); + const auto withExtension = Path::WithExtension(pathBuffer, extension); String::set(pathBuffer, sizeof(pathBuffer), withExtension.c_str()); RCT2::T6Exporter t6Export{ *trackDesignPtr }; @@ -468,28 +477,7 @@ namespace OpenRCT2::Ui::FileBrowser } } - static u8string GetDefaultExtensionByType(LoadSaveType type) - { - switch (type) - { - case LoadSaveType::park: - return u8".park"; - - case LoadSaveType::landscape: - return u8".park"; - - case LoadSaveType::scenario: - return u8".park"; - - case LoadSaveType::track: - return u8".td6"; - - default: - return {}; - } - } - - static FileDialogDesc::Filter GetFilterForType(LoadSaveType type, bool isSave) + static FileDialogDesc::Filter GetFilterForType(LoadSaveType type, bool isSave, const TrackDesign* trackDesign) { switch (type) { @@ -503,7 +491,7 @@ namespace OpenRCT2::Ui::FileBrowser return { LanguageGetString(STR_OPENRCT2_SCENARIO_FILE), GetFilterPatternByType(type, isSave) }; case LoadSaveType::track: - return { LanguageGetString(STR_OPENRCT2_TRACK_DESIGN_FILE), GetFilterPatternByType(type, isSave) }; + return { LanguageGetString(STR_OPENRCT2_TRACK_DESIGN_FILE), GetFilterPatternByType(type, isSave, trackDesign) }; case LoadSaveType::heightmap: return { LanguageGetString(STR_OPENRCT2_HEIGHTMAP_FILE), GetFilterPatternByType(type, isSave) }; @@ -514,7 +502,8 @@ namespace OpenRCT2::Ui::FileBrowser } } - u8string OpenSystemFileBrowser(bool isSave, LoadSaveType type, u8string defaultDirectory, u8string defaultPath) + u8string OpenSystemFileBrowser( + bool isSave, LoadSaveType type, u8string defaultDirectory, u8string defaultPath, const TrackDesign* trackDesign) { u8string path = defaultDirectory; if (isSave) @@ -535,7 +524,6 @@ namespace OpenRCT2::Ui::FileBrowser } } - u8string extension = GetDefaultExtensionByType(type); StringId title = GetTitleStringId(type, isSave); FileDialogDesc desc = { @@ -543,7 +531,7 @@ namespace OpenRCT2::Ui::FileBrowser .Title = LanguageGetString(title), .InitialDirectory = defaultDirectory, .DefaultFilename = isSave ? path : u8string(), - .Filters = { GetFilterForType(type, isSave), { LanguageGetString(STR_ALL_FILES), "*" } }, + .Filters = { GetFilterForType(type, isSave, trackDesign), { LanguageGetString(STR_ALL_FILES), "*" } }, }; return ContextOpenCommonFileDialog(desc); diff --git a/src/openrct2-ui/interface/FileBrowser.h b/src/openrct2-ui/interface/FileBrowser.h index 4f98468ce3..45feb0c80a 100644 --- a/src/openrct2-ui/interface/FileBrowser.h +++ b/src/openrct2-ui/interface/FileBrowser.h @@ -55,14 +55,15 @@ namespace OpenRCT2::Ui::FileBrowser bool IsValidPath(const char* path); u8string GetLastDirectoryByType(LoadSaveType type); u8string GetInitialDirectoryByType(LoadSaveType type); - const char* GetFilterPatternByType(LoadSaveType type, bool isSave); + u8string GetFilterPatternByType(LoadSaveType type, bool isSave, const TrackDesign* trackDesign = nullptr); u8string RemovePatternWildcard(u8string_view pattern); u8string GetDir(LoadSaveType type); void RegisterCallback(LoadSaveCallback callback); void InvokeCallback(ModalResult result, const utf8* path); void Select(const char* path, LoadSaveAction action, LoadSaveType type, TrackDesign* trackDesignPtr); StringId GetTitleStringId(LoadSaveType type, bool isSave); - u8string OpenSystemFileBrowser(bool isSave, LoadSaveType type, u8string defaultDirectory, u8string defaultPath); + u8string OpenSystemFileBrowser( + bool isSave, LoadSaveType type, u8string defaultDirectory, u8string defaultPath, const TrackDesign* trackDesign); WindowBase* OpenPreferred( LoadSaveAction action, LoadSaveType type, u8string defaultPath, LoadSaveCallback callback, TrackDesign* trackDesign); } // namespace OpenRCT2::Ui::FileBrowser diff --git a/src/openrct2-ui/interface/InGameConsole.h b/src/openrct2-ui/interface/InGameConsole.h index 4608dffb0b..b244c5af4d 100644 --- a/src/openrct2-ui/interface/InGameConsole.h +++ b/src/openrct2-ui/interface/InGameConsole.h @@ -62,7 +62,7 @@ namespace OpenRCT2::Ui void Close() override; void Hide() override; void Toggle(); - void WriteLine(const std::string& s, FormatToken colourFormat) override; + void WriteLine(const std::string& input, FormatToken colourFormat) override; void Input(ConsoleInput input); void RefreshCaret(size_t position = 0); diff --git a/src/openrct2-ui/interface/LandTool.cpp b/src/openrct2-ui/interface/LandTool.cpp index d50d50358b..b562c6ec54 100644 --- a/src/openrct2-ui/interface/LandTool.cpp +++ b/src/openrct2-ui/interface/LandTool.cpp @@ -78,7 +78,7 @@ void LandTool::ShowSurfaceStyleDropdown(WindowBase* w, Widget* widget, ObjectEnt uint32_t surfaceCount = itemIndex; WindowDropdownShowImage( - w->windowPos.x + widget->left, w->windowPos.y + widget->top, widget->height() - 1, w->colours[2], 0, surfaceCount, 47, + w->windowPos + ScreenCoordsXY{ widget->left, widget->top }, widget->height() - 1, w->colours[2], 0, surfaceCount, 47, 36, DropdownGetAppropriateImageDropdownItemsPerRow(surfaceCount)); gDropdown.hasTooltips = true; @@ -129,7 +129,7 @@ void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryI auto itemsPerRow = DropdownGetAppropriateImageDropdownItemsPerRow(edgeCount); WindowDropdownShowImage( - w->windowPos.x + widget->left, w->windowPos.y + widget->top, widget->height() - 1, w->colours[2], 0, edgeCount, 47, 36, + w->windowPos + ScreenCoordsXY{ widget->left, widget->top }, widget->height() - 1, w->colours[2], 0, edgeCount, 47, 36, itemsPerRow); gDropdown.hasTooltips = true; diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp index 5f764a7057..d46c770cf8 100644 --- a/src/openrct2-ui/interface/ViewportInteraction.cpp +++ b/src/openrct2-ui/interface/ViewportInteraction.cpp @@ -21,13 +21,14 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/interface/Window.h b/src/openrct2-ui/interface/Window.h index 2eff99d49a..8c65b73263 100644 --- a/src/openrct2-ui/interface/Window.h +++ b/src/openrct2-ui/interface/Window.h @@ -77,7 +77,7 @@ namespace OpenRCT2::Ui::Windows void WindowInitScrollWidgets(WindowBase& w); void WindowUpdateScrollWidgets(WindowBase& w); - void WindowMovePosition(WindowBase& w, const ScreenCoordsXY& screenCoords); + void WindowMovePosition(WindowBase& w, const ScreenCoordsXY& deltaCoords); void WindowSetPosition(WindowBase& w, const ScreenCoordsXY& screenCoords); void WindowMoveAndSnap(WindowBase& w, ScreenCoordsXY newWindowCoords, int32_t snapProximity); void WindowRelocateWindows(int32_t width, int32_t height); diff --git a/src/openrct2-ui/libopenrct2ui.vcxproj b/src/openrct2-ui/libopenrct2ui.vcxproj index e450099bc4..c845a3b418 100644 --- a/src/openrct2-ui/libopenrct2ui.vcxproj +++ b/src/openrct2-ui/libopenrct2ui.vcxproj @@ -1,4 +1,4 @@ - + ..\..\ @@ -80,6 +80,7 @@ + @@ -145,6 +146,9 @@ + + Create + @@ -255,6 +259,9 @@ USE_BREAKPAD;%(PreprocessorDefinitions) + Use + openrct2ui_pch.h + openrct2ui_pch.h @@ -268,4 +275,4 @@ - \ No newline at end of file + diff --git a/src/openrct2-ui/openrct2ui_pch.cpp b/src/openrct2-ui/openrct2ui_pch.cpp new file mode 100644 index 0000000000..f59bda8635 --- /dev/null +++ b/src/openrct2-ui/openrct2ui_pch.cpp @@ -0,0 +1,2 @@ +// Empty file for MSVC's PCH +// Do not include the header file - it is set up with MSVC solution diff --git a/src/openrct2-ui/openrct2ui_pch.h b/src/openrct2-ui/openrct2ui_pch.h new file mode 100644 index 0000000000..e94d052f4c --- /dev/null +++ b/src/openrct2-ui/openrct2ui_pch.h @@ -0,0 +1,24 @@ +#pragma once + +// Precompiled header for libopenrct2ui project + +// Standard library headers that are expensive to compile +#include +#include +#include +#include +#include +#include + +// Project core headers (from libopenrct2) that are used in UI +#include "../openrct2/Context.h" +#include "../openrct2/GameState.h" +#include "../openrct2/core/StringTypes.h" + +// Interface headers that are widely used in UI +// Note: These must be in dependency order +#include "../openrct2/interface/Viewport.h" +#include "../openrct2/interface/Window.h" +#include "interface/Viewport.h" +#include "interface/Widget.h" +#include "interface/Window.h" diff --git a/src/openrct2-ui/ride/Construction.cpp b/src/openrct2-ui/ride/Construction.cpp index e9d3575ce2..39dabf87ea 100644 --- a/src/openrct2-ui/ride/Construction.cpp +++ b/src/openrct2-ui/ride/Construction.cpp @@ -12,7 +12,8 @@ #include "../interface/Viewport.h" #include -#include +#include +#include #include #include #include @@ -108,7 +109,7 @@ namespace OpenRCT2 kSeparator, // (Wooden) water splash - TrackElemType::watersplash, + TrackElemType::waterSplash, kSeparator, // River Rapids @@ -281,7 +282,7 @@ namespace OpenRCT2 // Additional tower bases can only be built if the ride allows for it (elevator) if (trackType == TrackElemType::towerBase - && !currentRide.getRideTypeDescriptor().HasFlag(RtdFlag::allowExtraTowerBases)) + && !currentRide.getRideTypeDescriptor().flags.has(RtdFlag::allowExtraTowerBases)) entryIsDisabled = true; // Check if a previous element exists, to collate entries if possible diff --git a/src/openrct2-ui/scripting/CustomImages.cpp b/src/openrct2-ui/scripting/CustomImages.cpp index 6e5662d29d..626ae251e4 100644 --- a/src/openrct2-ui/scripting/CustomImages.cpp +++ b/src/openrct2-ui/scripting/CustomImages.cpp @@ -322,7 +322,7 @@ namespace OpenRCT2::Scripting auto importMode = getImportModeFromPalette(pixelData.Palette); auto pngData = DukGetDataFromBufferLikeObject(pixelData.Data); auto image = Imaging::ReadFromBuffer(pngData, imageFormat); - constexpr uint8_t flags = EnumToFlag(ImportFlags::RLE); + constexpr ImportFlags flags = { ImportFlag::rle }; ImageImportMeta meta = { { 0, 0 }, palette, flags, importMode }; ImageImporter importer; @@ -449,7 +449,7 @@ namespace OpenRCT2::Scripting if (createNewImage) { auto bufferSize = size.width * size.height; - rt.bits = new uint8_t[bufferSize]; + rt.bits = new PaletteIndex[bufferSize]; std::memset(rt.bits, 0, bufferSize); drawingEngine->BeginDraw(); @@ -461,7 +461,7 @@ namespace OpenRCT2::Scripting } else { - rt.bits = g1->offset; + rt.bits = reinterpret_cast(g1->offset); } auto dukG = GetObjectAsDukValue(ctx, std::make_shared(ctx, rt)); @@ -477,7 +477,7 @@ namespace OpenRCT2::Scripting delete[] g1->offset; newg1 = *g1; } - newg1.offset = rt.bits; + newg1.offset = reinterpret_cast(rt.bits); newg1.width = size.width; newg1.height = size.height; newg1.flags = {}; diff --git a/src/openrct2-ui/scripting/CustomListView.cpp b/src/openrct2-ui/scripting/CustomListView.cpp index a44313635e..99a245d5cd 100644 --- a/src/openrct2-ui/scripting/CustomListView.cpp +++ b/src/openrct2-ui/scripting/CustomListView.cpp @@ -615,9 +615,9 @@ void CustomListView::Paint(WindowBase* w, RenderTarget& rt, const ScrollArea* sc } // Columns - if (Columns.size() == 0) + if (Columns.empty()) { - if (item.Cells.size() != 0) + if (!item.Cells.empty()) { const auto& text = item.Cells[0]; if (!text.empty()) @@ -804,7 +804,7 @@ std::optional CustomListView::GetItemIndexAt(const ScreenCoordsXY& po } // Check what column we pressed if there are any - if (result && Columns.size() > 0) + if (result && !Columns.empty()) { bool found = false; int32_t x = 0; diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index 48de73d370..3e6e79932d 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -897,7 +897,7 @@ namespace OpenRCT2::Ui::Windows } // Add window tabs - if (_info.Desc.Tabs.size() != 0) + if (!_info.Desc.Tabs.empty()) { widgetList[WIDX_CONTENT_PANEL].top = kTabBarHeight; } @@ -919,7 +919,7 @@ namespace OpenRCT2::Ui::Windows // Add custom widgets auto totalWidgets = _info.Desc.Widgets.size(); auto tabWidgetsOffset = totalWidgets; - if (_info.Desc.Tabs.size() != 0) + if (!_info.Desc.Tabs.empty()) { totalWidgets += _info.Desc.Tabs[page].Widgets.size(); } @@ -1271,7 +1271,7 @@ namespace OpenRCT2::Ui::Windows auto& widget = w->widgets[widgetIndex]; auto lastSelectedIndex = customWidgetInfo->SelectedIndex; - if (customWidgetInfo->Items.size() == 0) + if (customWidgetInfo->Items.empty()) { selectedIndex = -1; } diff --git a/src/openrct2-ui/scripting/CustomWindow.h b/src/openrct2-ui/scripting/CustomWindow.h index 75bb8f5e38..f4ed9cead0 100644 --- a/src/openrct2-ui/scripting/CustomWindow.h +++ b/src/openrct2-ui/scripting/CustomWindow.h @@ -24,7 +24,7 @@ namespace OpenRCT2::Ui::Windows std::string GetWindowTitle(WindowBase* w); void UpdateWindowTitle(WindowBase* w, std::string_view value); void UpdateWindowTab(WindowBase* w, int32_t tabIndex); - void UpdateWidgetText(WindowBase* w, WidgetIndex widget, std::string_view string_view); + void UpdateWidgetText(WindowBase* w, WidgetIndex widget, std::string_view value); void UpdateWidgetItems(WindowBase* w, WidgetIndex widgetIndex, const std::vector& items); void UpdateWidgetColour(WindowBase* w, WidgetIndex widgetIndex, Drawing::Colour colour); void UpdateWidgetSelectedIndex(WindowBase* w, WidgetIndex widgetIndex, int32_t selectedIndex); diff --git a/src/openrct2-ui/title/TitleSequencePlayer.cpp b/src/openrct2-ui/title/TitleSequencePlayer.cpp index aace31522a..20adda625d 100644 --- a/src/openrct2-ui/title/TitleSequencePlayer.cpp +++ b/src/openrct2-ui/title/TitleSequencePlayer.cpp @@ -339,9 +339,9 @@ namespace OpenRCT2::Title _initialLoadCommand = false; success = true; } - catch (const std::exception&) + catch (const std::exception& e) { - Console::Error::WriteLine("Unable to load park: %s", path.c_str()); + Console::Error::WriteLine("Unable to load park ‘%s’: %s", path.c_str(), e.what()); GetContext()->CloseProgress(); } diff --git a/src/openrct2-ui/windows/Banner.cpp b/src/openrct2-ui/windows/Banner.cpp index be106901b8..c1963f81e8 100644 --- a/src/openrct2-ui/windows/Banner.cpp +++ b/src/openrct2-ui/windows/Banner.cpp @@ -16,9 +16,10 @@ #include #include #include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Cheats.cpp b/src/openrct2-ui/windows/Cheats.cpp index efa08827c8..1ce42ae064 100644 --- a/src/openrct2-ui/windows/Cheats.cpp +++ b/src/openrct2-ui/windows/Cheats.cpp @@ -18,8 +18,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/ClearScenery.cpp b/src/openrct2-ui/windows/ClearScenery.cpp index 726b571697..2399df2b4c 100644 --- a/src/openrct2-ui/windows/ClearScenery.cpp +++ b/src/openrct2-ui/windows/ClearScenery.cpp @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/DemolishRidePrompt.cpp b/src/openrct2-ui/windows/DemolishRidePrompt.cpp index 4309c92582..d63c464918 100644 --- a/src/openrct2-ui/windows/DemolishRidePrompt.cpp +++ b/src/openrct2-ui/windows/DemolishRidePrompt.cpp @@ -11,7 +11,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Dropdown.cpp b/src/openrct2-ui/windows/Dropdown.cpp index db813b49a8..e0172033b7 100644 --- a/src/openrct2-ui/windows/Dropdown.cpp +++ b/src/openrct2-ui/windows/Dropdown.cpp @@ -7,8 +7,6 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "openrct2/core/String.hpp" - #include #include #include @@ -20,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -89,6 +88,82 @@ namespace OpenRCT2::Ui::Windows return Config::Get().interface.enlargedUi ? 6 : 0; } + void drawItem(RenderTarget& rt, ScreenCoordsXY screenCoords, int32_t i) + { + int32_t highlightedIndex = gDropdown.highlightedIndex; + bool highlighted = (i == highlightedIndex); + + if (highlighted) + { + // Darken the cell's background slightly when highlighted + const ScreenCoordsXY rightBottom = screenCoords + ScreenCoordsXY{ ItemWidth - 1, ItemHeight - 1 }; + Rectangle::filter(rt, { screenCoords, rightBottom }, FilterPaletteID::paletteDarken3); + } + + const auto& item = gDropdown.items[i]; + switch (item.type) + { + case Dropdown::ItemType::regular: + { + auto formatString = STR_OPTIONS_DROPDOWN_ITEM; + if (i < Dropdown::kItemsMaxSize && gDropdown.items[i].isChecked()) + formatString = STR_OPTIONS_DROPDOWN_ITEM_SELECTED; + + drawTextItem(rt, screenCoords, width, item, highlighted, formatString, colours[0].colour); + break; + } + case Dropdown::ItemType::toggle: + { + auto formatString = STR_TOGGLE_OPTION; + if (i < Dropdown::kItemsMaxSize && gDropdown.items[i].isChecked()) + formatString = STR_TOGGLE_OPTION_CHECKED; + + drawTextItem(rt, screenCoords, width, item, highlighted, formatString, colours[0].colour); + break; + } + case Dropdown::ItemType::plain: + { + drawTextItem(rt, screenCoords, width, item, highlighted, STR_STRING, colours[0].colour); + break; + } + case Dropdown::ItemType::image: + { + GfxDrawSprite(rt, item.image, screenCoords); + break; + } + case Dropdown::ItemType::colour: + { + auto image = item.image; + if (highlightedIndex == i) + image = image.WithIndexOffset(1); + GfxDrawSprite(rt, image, screenCoords); + break; + } + case Dropdown::ItemType::separator: + break; + } + } + + void drawSeparator(RenderTarget& rt, ScreenCoordsXY screenCoords) + { + const auto leftTop = screenCoords + ScreenCoordsXY{ 2, (ItemHeight / 2) - 1 }; + const auto rightBottom = leftTop + ScreenCoordsXY{ ItemWidth - 4, 0 }; + const auto shadowOffset = ScreenCoordsXY{ 0, 1 }; + + if (colours[0].flags.has(ColourFlag::translucent)) + { + auto palette = kTranslucentWindowPalettes[EnumValue(colours[0].colour)]; + Rectangle::filter(rt, { leftTop, rightBottom }, palette.highlight); + Rectangle::filter(rt, { leftTop + shadowOffset, rightBottom + shadowOffset }, palette.shadow); + } + else + { + Rectangle::fill(rt, { leftTop, rightBottom }, getColourMap(colours[0].colour).midDark); + Rectangle::fill( + rt, { leftTop + shadowOffset, rightBottom + shadowOffset }, getColourMap(colours[0].colour).lightest); + } + } + void drawTextItem( RenderTarget& rt, ScreenCoordsXY screenCoords, int32_t ddWidth, const Dropdown::Item& item, bool highlighted, StringId format, Colour background) @@ -110,7 +185,6 @@ namespace OpenRCT2::Ui::Windows { drawWidgets(rt); - int32_t highlightedIndex = gDropdown.highlightedIndex; for (int32_t i = 0; i < gDropdown.numItems; i++) { ScreenCoordsXY cellCoords; @@ -124,76 +198,11 @@ namespace OpenRCT2::Ui::Windows if (gDropdown.items[i].isSeparator()) { - const auto leftTop = screenCoords + ScreenCoordsXY{ 2, (ItemHeight / 2) - 1 }; - const auto rightBottom = leftTop + ScreenCoordsXY{ ItemWidth - 4, 0 }; - const auto shadowOffset = ScreenCoordsXY{ 0, 1 }; - - if (colours[0].flags.has(ColourFlag::translucent)) - { - TranslucentWindowPalette palette = kTranslucentWindowPalettes[EnumValue(colours[0].colour)]; - Rectangle::filter(rt, { leftTop, rightBottom }, palette.highlight); - Rectangle::filter(rt, { leftTop + shadowOffset, rightBottom + shadowOffset }, palette.shadow); - } - else - { - Rectangle::fill(rt, { leftTop, rightBottom }, getColourMap(colours[0].colour).midDark); - Rectangle::fill( - rt, { leftTop + shadowOffset, rightBottom + shadowOffset }, - getColourMap(colours[0].colour).lightest); - } + drawSeparator(rt, screenCoords); } else { - auto highlighted = (i == highlightedIndex); - if (highlighted) - { - // Darken the cell's background slightly when highlighted - const ScreenCoordsXY rightBottom = screenCoords + ScreenCoordsXY{ ItemWidth - 1, ItemHeight - 1 }; - Rectangle::filter(rt, { screenCoords, rightBottom }, FilterPaletteID::paletteDarken3); - } - - const auto& item = gDropdown.items[i]; - switch (item.type) - { - case Dropdown::ItemType::regular: - { - auto formatString = STR_OPTIONS_DROPDOWN_ITEM; - if (i < Dropdown::kItemsMaxSize && gDropdown.items[i].isChecked()) - formatString = STR_OPTIONS_DROPDOWN_ITEM_SELECTED; - - drawTextItem(rt, screenCoords, width, item, highlighted, formatString, colours[0].colour); - break; - } - case Dropdown::ItemType::toggle: - { - auto formatString = STR_TOGGLE_OPTION; - if (i < Dropdown::kItemsMaxSize && gDropdown.items[i].isChecked()) - formatString = STR_TOGGLE_OPTION_CHECKED; - - drawTextItem(rt, screenCoords, width, item, highlighted, formatString, colours[0].colour); - break; - } - case Dropdown::ItemType::plain: - { - drawTextItem(rt, screenCoords, width, item, highlighted, STR_STRING, colours[0].colour); - break; - } - case Dropdown::ItemType::image: - { - GfxDrawSprite(rt, item.image, screenCoords); - break; - } - case Dropdown::ItemType::colour: - { - auto image = item.image; - if (highlightedIndex == i) - image = image.WithIndexOffset(1); - GfxDrawSprite(rt, image, screenCoords); - break; - } - case Dropdown::ItemType::separator: - break; - } + drawItem(rt, screenCoords, i); } } } @@ -434,8 +443,8 @@ namespace OpenRCT2::Ui::Windows * @param numColumns (bl) */ void WindowDropdownShowImage( - int32_t x, int32_t y, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, int32_t itemWidth, - int32_t itemHeight, int32_t numColumns) + const ScreenCoordsXY& screenPos, int32_t extray, ColourWithFlags colour, uint8_t flags, int32_t numItems, + int32_t itemWidth, int32_t itemHeight, int32_t numColumns) { gInputFlags.unset(InputFlag::dropdownStayOpen, InputFlag::dropdownMouseUp); if (flags & Dropdown::Flag::StayOpen || Config::Get().interface.touchEnhancements) @@ -449,7 +458,7 @@ namespace OpenRCT2::Ui::Windows auto* w = windowMgr->Create(WindowClass::dropdown, { itemWidth, itemHeight }, WindowFlag::stickToFront); if (w != nullptr) { - w->setImageItems({ x, y }, extray, colour, numItems, itemWidth, itemHeight, numColumns); + w->setImageItems(screenPos, extray, colour, numItems, itemWidth, itemHeight, numColumns); } } @@ -607,7 +616,7 @@ namespace OpenRCT2::Ui::Windows // Show dropdown auto squareSize = DropdownWindow::GetDefaultRowHeight(); WindowDropdownShowImage( - w->windowPos.x + widget->left, w->windowPos.y + widget->top, widget->height(), dropdownColour, + w->windowPos + ScreenCoordsXY{ widget->left, widget->top }, widget->height(), dropdownColour, Dropdown::Flag::StayOpen, numColours, squareSize, squareSize, DropdownGetAppropriateImageDropdownItemsPerRow(static_cast(numColours))); @@ -624,9 +633,6 @@ namespace OpenRCT2::Ui::Windows } } // namespace OpenRCT2::Ui::Windows -using namespace OpenRCT2::Ui::Windows; -using namespace OpenRCT2; - namespace OpenRCT2::Dropdown { static Item StringItem(ItemType _type, const utf8* string) diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index 6a539bb3ef..0ea4114b22 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -114,7 +114,7 @@ namespace OpenRCT2::Ui::Windows int16_t columnSplitOffset = width / 2; if (researchItem.type == Research::EntryType::ride - && !GetRideTypeDescriptor(researchItem.baseRideType).HasFlag(RtdFlag::listVehiclesSeparately)) + && !GetRideTypeDescriptor(researchItem.baseRideType).flags.has(RtdFlag::listVehiclesSeparately)) { const StringId rideTypeName = GetRideNaming(researchItem.baseRideType, GetRideEntryByIndex(researchItem.entryIndex)) .Name; @@ -421,7 +421,7 @@ namespace OpenRCT2::Ui::Windows auto ft = Formatter(); if (researchItem->type == Research::EntryType::ride - && !GetRideTypeDescriptor(researchItem->baseRideType).HasFlag(RtdFlag::listVehiclesSeparately)) + && !GetRideTypeDescriptor(researchItem->baseRideType).flags.has(RtdFlag::listVehiclesSeparately)) { drawString = STR_WINDOW_COLOUR_2_STRINGID_STRINGID; StringId rideTypeName = GetRideNaming(researchItem->baseRideType, GetRideEntryByIndex(researchItem->entryIndex)) diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 8f8abc98b1..ecae98d198 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -21,8 +21,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -524,7 +524,7 @@ namespace OpenRCT2::Ui::Windows // Track designs manager cannot select multiple, so only show selection filters if not in track designs // manager - if (!(gLegacyScene == LegacyScene::trackDesignsManager)) + if (gLegacyScene != LegacyScene::trackDesignsManager) { numSelectionItems = 3; gDropdown.items[DDIX_FILTER_SEPARATOR] = Dropdown::Separator(); @@ -546,7 +546,7 @@ namespace OpenRCT2::Ui::Windows } } - if (!(gLegacyScene == LegacyScene::trackDesignsManager)) + if (gLegacyScene != LegacyScene::trackDesignsManager) { gDropdown.items[DDIX_FILTER_SELECTED].setChecked(IsFilterActive(FILTER_SELECTED)); gDropdown.items[DDIX_FILTER_NONSELECTED].setChecked(IsFilterActive(FILTER_NONSELECTED)); @@ -743,7 +743,7 @@ namespace OpenRCT2::Ui::Windows if (screenCoords.y + kScrollableRowHeight >= rt.y && screenCoords.y <= rt.y + rt.height) { // Draw checkbox - if (!(gLegacyScene == LegacyScene::trackDesignsManager) && !(*listItem.flags & 0x20)) + if (gLegacyScene != LegacyScene::trackDesignsManager && !(*listItem.flags & 0x20)) Rectangle::fillInset( rt, { { 2, screenCoords.y }, { 11, screenCoords.y + 10 } }, colours[1], Rectangle::BorderStyle::inset, Rectangle::FillBrightness::dark, @@ -759,8 +759,7 @@ namespace OpenRCT2::Ui::Windows } // Draw checkmark - if (!(gLegacyScene == LegacyScene::trackDesignsManager) - && (*listItem.flags & ObjectSelectionFlags::Selected)) + if (gLegacyScene != LegacyScene::trackDesignsManager && (*listItem.flags & ObjectSelectionFlags::Selected)) { screenCoords.x = 2; auto darkness = highlighted ? TextDarkness::extraDark : TextDarkness::dark; @@ -1071,7 +1070,7 @@ namespace OpenRCT2::Ui::Windows getColourMap(colours[1].colour).darkest); // Draw number of selected items - if (!(gLegacyScene == LegacyScene::trackDesignsManager)) + if (gLegacyScene != LegacyScene::trackDesignsManager) { auto screenPos = windowPos + ScreenCoordsXY{ 3, height - 13 }; diff --git a/src/openrct2-ui/windows/EditorParkEntrance.cpp b/src/openrct2-ui/windows/EditorParkEntrance.cpp index 0a2d521d7a..903e3266fb 100644 --- a/src/openrct2-ui/windows/EditorParkEntrance.cpp +++ b/src/openrct2-ui/windows/EditorParkEntrance.cpp @@ -15,7 +15,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index fcf2e8256b..80a9b3ef67 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -19,8 +19,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include @@ -2287,7 +2288,7 @@ namespace OpenRCT2::Ui::Windows auto* currentRide = GetRide(_rideableRides[i]); if (currentRide != nullptr) { - currentRide->lifecycleFlags ^= RIDE_LIFECYCLE_INDESTRUCTIBLE; + currentRide->flags.flip(RideFlag::indestructible); } invalidate(); } @@ -2365,7 +2366,7 @@ namespace OpenRCT2::Ui::Windows auto* currentRide = GetRide(_rideableRides[i]); if (currentRide != nullptr) { - if (currentRide->lifecycleFlags & RIDE_LIFECYCLE_INDESTRUCTIBLE) + if (currentRide->flags.has(RideFlag::indestructible)) { auto darkness = stringId == STR_WINDOW_COLOUR_2_STRINGID ? TextDarkness::extraDark : TextDarkness::dark; DrawText( diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 77dec849f8..cf1bc42ad8 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -13,7 +13,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 87d52ec478..238e6331b7 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -24,8 +24,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include @@ -819,7 +820,7 @@ namespace OpenRCT2::Ui::Windows auto itemsPerRow = DropdownGetAppropriateImageDropdownItemsPerRow(numPathTypes); WindowDropdownShowImage( - windowPos.x + widget->left, windowPos.y + widget->top, widget->height(), colours[1], 0, numPathTypes, 47, 36, + windowPos + ScreenCoordsXY{ widget->left, widget->top }, widget->height(), colours[1], 0, numPathTypes, 47, 36, itemsPerRow); gDropdown.hasTooltips = true; @@ -855,7 +856,7 @@ namespace OpenRCT2::Ui::Windows auto itemsPerRow = DropdownGetAppropriateImageDropdownItemsPerRow(numRailingsTypes); WindowDropdownShowImage( - windowPos.x + widget->left, windowPos.y + widget->top, widget->height(), colours[1], 0, numRailingsTypes, 47, + windowPos + ScreenCoordsXY{ widget->left, widget->top }, widget->height(), colours[1], 0, numRailingsTypes, 47, 36, itemsPerRow); gDropdown.hasTooltips = true; @@ -1274,7 +1275,7 @@ namespace OpenRCT2::Ui::Windows } FootpathUpdateProvisional(); - if (_provisionalFootpath.tiles.size() == 0) + if (_provisionalFootpath.tiles.empty()) return; // Try and place path @@ -1946,7 +1947,7 @@ namespace OpenRCT2::Ui::Windows FootpathRemoveProvisional(); GameActions::Result res; - std::vector succesfulTiles{}; + std::vector successfulTiles{}; money64 cost = 0; for (const auto& tile : tiles) { @@ -1958,20 +1959,20 @@ namespace OpenRCT2::Ui::Windows // from glitching through the existing path. if (res.error == GameActions::Status::ok || res.error == GameActions::Status::itemAlreadyPlaced) { - succesfulTiles.emplace_back(tile); + successfulTiles.emplace_back(tile); cost += res.cost; } } - bool anySuccesful = succesfulTiles.size() > 0; - if (anySuccesful) + bool anySuccessful = (!successfulTiles.empty()); + if (anySuccessful) { _provisionalFootpath.surfaceIndex = type; _provisionalFootpath.railingsIndex = railingsType; _provisionalFootpath.positionA = footpathLocA; _provisionalFootpath.positionB = footpathLocB; _provisionalFootpath.startZ = startZ; - _provisionalFootpath.tiles = succesfulTiles; + _provisionalFootpath.tiles = successfulTiles; _provisionalFootpath.constructFlags = constructFlags; _provisionalFootpath.flags.set(ProvisionalPathFlag::placed); @@ -1987,26 +1988,26 @@ namespace OpenRCT2::Ui::Windows if (!isToolActive(WindowClass::scenery)) { - if (succesfulTiles.size() == 0) + if (successfulTiles.empty()) { // If we can't build this, don't show a virtual floor. VirtualFloorSetHeight(0); } else if ( - succesfulTiles[0].slope.type == FootpathSlopeType::flat - || succesfulTiles[0].position.z < _footpathConstructFromPosition.z) + successfulTiles[0].slope.type == FootpathSlopeType::flat + || successfulTiles[0].position.z < _footpathConstructFromPosition.z) { // Going either straight on, or down. - VirtualFloorSetHeight(succesfulTiles[0].position.z); + VirtualFloorSetHeight(successfulTiles[0].position.z); } else { // Going up in the world! - VirtualFloorSetHeight(succesfulTiles[0].position.z + kLandHeightStep); + VirtualFloorSetHeight(successfulTiles[0].position.z + kLandHeightStep); } } - return anySuccesful ? cost : kMoney64Undefined; + return anySuccessful ? cost : kMoney64Undefined; } /** diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index c8dbb2c6e3..cf0fbde9c9 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -19,9 +19,10 @@ #include #include #include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index e3351ef543..5a22c10307 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -194,7 +194,8 @@ namespace OpenRCT2::Ui::Windows if (guestRide != nullptr) { ft.Add( - guestRide->getRideTypeDescriptor().HasFlag(RtdFlag::describeAsInside) ? STR_IN_RIDE : STR_ON_RIDE); + guestRide->getRideTypeDescriptor().flags.has(RtdFlag::describeAsInside) ? STR_IN_RIDE + : STR_ON_RIDE); guestRide->formatNameTo(ft); _selectedFilter = GuestFilterType::Guests; diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index 419a8f7522..11a8bd20d5 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -71,7 +71,7 @@ namespace OpenRCT2::Ui::Windows std::unique_ptr _trackDesign; std::string _trackPath; std::string _trackName; - std::vector _trackDesignPreviewPixels; + TrackDesignPreviewBuffer _trackDesignPreviewPixels{}; public: void setupTrack(const utf8* path, std::unique_ptr trackDesign) @@ -79,7 +79,7 @@ namespace OpenRCT2::Ui::Windows _trackDesign = std::move(trackDesign); _trackPath = path; _trackName = GetNameFromTrackPath(path); - _trackDesignPreviewPixels.resize(4 * kTrackPreviewImageSize); + std::fill(_trackDesignPreviewPixels.begin(), _trackDesignPreviewPixels.end(), PaletteIndex::transparent); UpdatePreview(); invalidate(); @@ -97,8 +97,6 @@ namespace OpenRCT2::Ui::Windows { _trackPath.clear(); _trackName.clear(); - _trackDesignPreviewPixels.clear(); - _trackDesignPreviewPixels.shrink_to_fit(); _trackDesign = nullptr; } @@ -162,13 +160,14 @@ namespace OpenRCT2::Ui::Windows Rectangle::fill(rt, { screenPos, screenPos + ScreenCoordsXY{ 369, 216 } }, colour); G1Element g1temp = {}; - g1temp.offset = _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * kTrackPreviewImageSize); + g1temp.offset = reinterpret_cast( + _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * kTrackPreviewImageSize)); g1temp.width = 370; g1temp.height = 217; g1temp.flags = { G1Flag::hasTransparency }; - GfxSetG1Element(SPR_TEMP, &g1temp); - DrawingEngineInvalidateImage(SPR_TEMP); - GfxDrawSprite(rt, ImageId(SPR_TEMP), screenPos); + GfxSetG1Element(SPR_TEMP_INSTALL_TRACK, &g1temp); + DrawingEngineInvalidateImage(SPR_TEMP_INSTALL_TRACK); + GfxDrawSprite(rt, ImageId(SPR_TEMP_INSTALL_TRACK), screenPos); screenPos = windowPos + ScreenCoordsXY{ widget->midX(), widget->bottom - 12 }; @@ -281,7 +280,7 @@ namespace OpenRCT2::Ui::Windows screenPos.y += kListRowHeight; } - if (GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasGForces)) + if (GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasGForces)) { // Maximum positive vertical Gs { @@ -317,7 +316,7 @@ namespace OpenRCT2::Ui::Windows } } - if (GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasDrops)) + if (GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasDrops)) { auto ft = Formatter(); ft.Add(td.statistics.drops); @@ -361,7 +360,7 @@ namespace OpenRCT2::Ui::Windows private: void UpdatePreview() { - TrackDesignDrawPreview(*_trackDesign, _trackDesignPreviewPixels.data(), !gTrackDesignSceneryToggle); + TrackDesignDrawPreview(*_trackDesign, _trackDesignPreviewPixels, !gTrackDesignSceneryToggle); } void InstallTrackDesign() @@ -375,7 +374,8 @@ namespace OpenRCT2::Ui::Windows return; } - destPath = Path::Combine(destPath, _trackName + u8".td6"); + auto extension = trackDesignGetExtension(_trackDesign->version); + destPath = Path::Combine(destPath, _trackName + extension); if (File::Exists(destPath)) { diff --git a/src/openrct2-ui/windows/Land.cpp b/src/openrct2-ui/windows/Land.cpp index 91823eca34..8c22d54f3b 100644 --- a/src/openrct2-ui/windows/Land.cpp +++ b/src/openrct2-ui/windows/Land.cpp @@ -19,10 +19,11 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/LandRights.cpp b/src/openrct2-ui/windows/LandRights.cpp index caccc15458..609f29a7a6 100644 --- a/src/openrct2-ui/windows/LandRights.cpp +++ b/src/openrct2-ui/windows/LandRights.cpp @@ -18,8 +18,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 344bdd5ae2..4d74fa317f 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -577,7 +577,7 @@ namespace OpenRCT2::Ui::Windows } // Populate file list - const char* pattern = GetFilterPatternByType(type, isSave); + auto pattern = GetFilterPatternByType(type, isSave, _trackDesign); const auto path = GetDir(type); PopulateList(path, pattern); numListItems = static_cast(_listItems.size()); @@ -824,7 +824,7 @@ namespace OpenRCT2::Ui::Windows case WIDX_SYSTEM_BROWSER: { - u8string path = OpenSystemFileBrowser(isSave, type, _directory, _defaultPath); + u8string path = OpenSystemFileBrowser(isSave, type, _directory, _defaultPath, _trackDesign); if (!path.empty()) { Select(path.c_str(), action, type, _trackDesign); diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 3b4d734f3a..5507b08c00 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -19,9 +19,10 @@ #include #include #include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -587,9 +588,9 @@ namespace OpenRCT2::Ui::Windows g1temp.offset = reinterpret_cast(_mapImageData.data()); g1temp.width = getMiniMapWidth(); g1temp.height = getMiniMapWidth(); - GfxSetG1Element(SPR_TEMP, &g1temp); - DrawingEngineInvalidateImage(SPR_TEMP); - GfxDrawSprite(rt, ImageId(SPR_TEMP), screenOffset); + GfxSetG1Element(SPR_TEMP_MAP, &g1temp); + DrawingEngineInvalidateImage(SPR_TEMP_MAP); + GfxDrawSprite(rt, ImageId(SPR_TEMP_MAP), screenOffset); if (selectedTab == PAGE_PEEPS) { diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 65a8e4e2f5..16ae313c43 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -17,10 +17,11 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include +#include #include #include #include @@ -377,7 +378,7 @@ namespace OpenRCT2::Ui::Windows if (currentRide != nullptr && RideAreAllPossibleEntrancesAndExitsBuilt(*currentRide).Successful) { ToolCancel(); - if (!currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!currentRide->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { windowMgr->CloseByClass(WindowClass::rideConstruction); } diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index 8e834ed059..51ada6cd21 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/NewCampaign.cpp b/src/openrct2-ui/windows/NewCampaign.cpp index e15690e2ee..4708b8f2ec 100644 --- a/src/openrct2-ui/windows/NewCampaign.cpp +++ b/src/openrct2-ui/windows/NewCampaign.cpp @@ -13,7 +13,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -116,7 +117,7 @@ namespace OpenRCT2::Ui::Windows for (auto& curRide : RideManager(gameState)) { auto rideEntry = curRide.getRideEntry(); - if (rideEntry != nullptr) + if (rideEntry != nullptr && curRide.status == RideStatus::open) { for (const auto itemType : rideEntry->shop_item) { @@ -149,11 +150,11 @@ namespace OpenRCT2::Ui::Windows if (curRide.status == RideStatus::open) { const auto& rtd = curRide.getRideTypeDescriptor(); - if (rtd.HasFlag(RtdFlag::isShopOrFacility)) + if (rtd.flags.has(RtdFlag::isShopOrFacility)) continue; - if (rtd.HasFlag(RtdFlag::sellsFood)) + if (rtd.flags.has(RtdFlag::sellsFood)) continue; - if (rtd.HasFlag(RtdFlag::sellsDrinks)) + if (rtd.flags.has(RtdFlag::sellsDrinks)) continue; if (rtd.specialType == RtdSpecialType::toilet) continue; diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index 657651ca19..7898624223 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -613,7 +613,7 @@ namespace OpenRCT2::Ui::Windows if (item.Type < 0x80) { - if (GetRideTypeDescriptor(item.Type).HasFlag(RtdFlag::listVehiclesSeparately)) + if (GetRideTypeDescriptor(item.Type).flags.has(RtdFlag::listVehiclesSeparately)) { entryName = GetRideEntryName(item.EntryIndex); } @@ -628,7 +628,7 @@ namespace OpenRCT2::Ui::Windows void UpdateVehicleAvailability(ride_type_t rideType) { _vehicleAvailability.clear(); - if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::listVehiclesSeparately)) + if (GetRideTypeDescriptor(rideType).flags.has(RtdFlag::listVehiclesSeparately)) { return; } @@ -712,7 +712,7 @@ namespace OpenRCT2::Ui::Windows // Skip if the vehicle isn't the preferred vehicle for this generic track type if (!Config::Get().interface.listRideVehiclesSeparately - && !GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::listVehiclesSeparately) + && !GetRideTypeDescriptor(rideType).flags.has(RtdFlag::listVehiclesSeparately) && highestVehiclePriority > rideObj->GetEntry().BuildMenuPriority) { continue; @@ -727,7 +727,7 @@ namespace OpenRCT2::Ui::Windows // Determines how and where to draw a button for this ride type/vehicle. if (Config::Get().interface.listRideVehiclesSeparately - || GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::listVehiclesSeparately)) + || GetRideTypeDescriptor(rideType).flags.has(RtdFlag::listVehiclesSeparately)) { // Separate, draw apart allowDrawingOverLastButton = false; @@ -997,7 +997,7 @@ namespace OpenRCT2::Ui::Windows // StringId stringId = STR_NEW_RIDE_COST; - if (GetRideTypeDescriptor(item.Type).HasFlag(RtdFlag::hasTrack)) + if (GetRideTypeDescriptor(item.Type).flags.has(RtdFlag::hasTrack)) stringId = STR_NEW_RIDE_COST_FROM; ft = Formatter(); diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 3c51b0510c..2b0c645d00 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index 79ebafb634..c8652f8321 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -20,8 +20,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/PatrolArea.cpp b/src/openrct2-ui/windows/PatrolArea.cpp index 812715e84e..b45cd7e0f6 100644 --- a/src/openrct2-ui/windows/PatrolArea.cpp +++ b/src/openrct2-ui/windows/PatrolArea.cpp @@ -18,7 +18,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index fa0f72ec82..20274bccac 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -15,8 +15,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/RefurbishRidePrompt.cpp b/src/openrct2-ui/windows/RefurbishRidePrompt.cpp index 382e9e4cfc..c9a01ea82a 100644 --- a/src/openrct2-ui/windows/RefurbishRidePrompt.cpp +++ b/src/openrct2-ui/windows/RefurbishRidePrompt.cpp @@ -11,7 +11,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Research.cpp b/src/openrct2-ui/windows/Research.cpp index 0d396d719e..662309f55c 100644 --- a/src/openrct2-ui/windows/Research.cpp +++ b/src/openrct2-ui/windows/Research.cpp @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -384,7 +385,7 @@ namespace OpenRCT2::Ui::Windows else if (gameState.researchNextItem->type == Research::EntryType::ride) { const auto& rtd = GetRideTypeDescriptor(gameState.researchNextItem->baseRideType); - if (rtd.HasFlag(RtdFlag::listVehiclesSeparately)) + if (rtd.flags.has(RtdFlag::listVehiclesSeparately)) { ft.Add(gameState.researchNextItem->GetName()); } @@ -444,7 +445,7 @@ namespace OpenRCT2::Ui::Windows { lastDevelopmentFormat = STR_RESEARCH_RIDE_LABEL; const auto& rtd = GetRideTypeDescriptor(gameState.researchLastItem->baseRideType); - if (rtd.HasFlag(RtdFlag::listVehiclesSeparately)) + if (rtd.flags.has(RtdFlag::listVehiclesSeparately)) { ft.Add(gameState.researchLastItem->GetName()); } diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 2820373a55..b578a551cf 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -28,15 +28,16 @@ #include #include #include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -137,6 +138,8 @@ namespace OpenRCT2::Ui::Windows WIDX_OPEN_LIGHT, WIDX_RIDE_TYPE, WIDX_RIDE_TYPE_DROPDOWN, + WIDX_MAKE_INVISIBLE, + WIDX_MAKE_VISIBLE, WIDX_VEHICLE_TYPE = 14, WIDX_VEHICLE_TYPE_DROPDOWN, @@ -185,16 +188,18 @@ namespace OpenRCT2::Ui::Windows WIDX_RELIABILITY_BAR, WIDX_DOWN_TIME_BAR, - WIDX_TRACK_PREVIEW = 14, + WIDX_PRIMARY_PREVIEW = 14, WIDX_TRACK_COLOUR_SCHEME, WIDX_TRACK_COLOUR_SCHEME_DROPDOWN, WIDX_TRACK_MAIN_COLOUR, WIDX_TRACK_ADDITIONAL_COLOUR, WIDX_TRACK_SUPPORT_COLOUR, + WIDX_SELL_ITEM_RANDOM_COLOUR_CHECKBOX, WIDX_MAZE_STYLE, WIDX_MAZE_STYLE_DROPDOWN, WIDX_PAINT_INDIVIDUAL_AREA, - WIDX_ENTRANCE_PREVIEW, + WIDX_SECONDARY_PREVIEW, + WIDX_ENTRANCE_STYLE_LABEL, WIDX_ENTRANCE_STYLE, WIDX_ENTRANCE_STYLE_DROPDOWN, WIDX_VEHICLE_PREVIEW, @@ -205,7 +210,6 @@ namespace OpenRCT2::Ui::Windows WIDX_VEHICLE_BODY_COLOUR, WIDX_VEHICLE_TRIM_COLOUR, WIDX_VEHICLE_TERTIARY_COLOUR, - WIDX_SELL_ITEM_RANDOM_COLOUR_CHECKBOX, WIDX_RANDOMISE_VEHICLE_COLOURS, WIDX_PLAY_MUSIC = 14, @@ -277,7 +281,9 @@ namespace OpenRCT2::Ui::Windows makeWidget({296, 62}, { 14, 14}, WidgetType::imgBtn, WindowColour::secondary, ImageId(SPR_G2_RCT1_TEST_BUTTON_0), STR_TEST_RIDE_TIP ), makeWidget({296, 76}, { 14, 14}, WidgetType::imgBtn, WindowColour::secondary, ImageId(SPR_G2_RCT1_OPEN_BUTTON_0), STR_OPEN_RIDE_TIP ), makeWidget({ 3, 180}, {305, 12}, WidgetType::dropdownMenu, WindowColour::secondary, STR_ARG_6_STRINGID ), - makeWidget({297, 180}, { 11, 12}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH ) + makeWidget({297, 180}, { 11, 12}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH ), + makeWidget({ 3, 195}, {140, 12}, WidgetType::button, WindowColour::secondary, STR_MAKE_INVISIBLE, STR_MAKE_INVISIBLE_TIP ), + makeWidget({151, 195}, {140, 12}, WidgetType::button, WindowColour::secondary, STR_MAKE_VISIBLE, STR_MAKE_VISIBLE_TIP ) ); // 0x009ADDA8 @@ -334,12 +340,18 @@ namespace OpenRCT2::Ui::Windows makeWidget({ 79, 74}, { 12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_MAIN_COLOUR_TIP ), makeWidget({ 99, 74}, { 12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_ADDITIONAL_COLOUR_1_TIP ), makeWidget({119, 74}, { 12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_SUPPORT_STRUCTURE_COLOUR_TIP ), + makeWidget({100, 74}, {239, 12}, WidgetType::checkbox, WindowColour::secondary, STR_RANDOM_COLOUR ), + makeWidget({ 74, 49}, {239, 12}, WidgetType::dropdownMenu, WindowColour::secondary ), makeWidget({301, 50}, { 11, 10}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH ), + makeWidget({289, 68}, { 24, 24}, WidgetType::flatBtn, WindowColour::secondary, ImageId(SPR_PAINTBRUSH), STR_PAINT_INDIVIDUAL_AREA_TIP ), + makeWidget({245, 101}, { 68, 47}, WidgetType::spinner, WindowColour::secondary ), + makeWidget({ 3, 103}, { 97, 12}, WidgetType::label, WindowColour::secondary, STR_STATION_STYLE ), makeWidget({103, 103}, {139, 12}, WidgetType::dropdownMenu, WindowColour::secondary, kStringIdEmpty ), makeWidget({230, 104}, { 11, 10}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH, STR_SELECT_STYLE_OF_ENTRANCE_EXIT_STATION_TIP), + makeWidget({ 3, 157}, { 68, 47}, WidgetType::scroll, WindowColour::secondary, kStringIdEmpty ), makeWidget({ 74, 157}, {239, 12}, WidgetType::dropdownMenu, WindowColour::secondary, STR_ARG_6_STRINGID ), makeWidget({301, 158}, { 11, 10}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH, STR_SELECT_VEHICLE_COLOUR_SCHEME_TIP ), @@ -348,7 +360,6 @@ namespace OpenRCT2::Ui::Windows makeWidget({ 79, 190}, { 12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_MAIN_COLOUR_TIP ), makeWidget({ 99, 190}, { 12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_ADDITIONAL_COLOUR_1_TIP ), makeWidget({119, 190}, { 12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_ADDITIONAL_COLOUR_2_TIP ), - makeWidget({100, 74}, {239, 12}, WidgetType::checkbox, WindowColour::secondary, STR_RANDOM_COLOUR ), makeWidget({139, 190}, {110, 12}, WidgetType::button, WindowColour::secondary, STR_RANDOMISE_VEHICLE_COLOURS, STR_RANDOMISE_VEHICLE_COLOURS_TIP ) ); @@ -626,6 +637,7 @@ namespace OpenRCT2::Ui::Windows ride_type_t RideTypeId; StringId LabelId; u8string LabelString; + bool isDummy; }; // Used for sorting the vehicle type dropdown. @@ -1270,7 +1282,7 @@ namespace OpenRCT2::Ui::Windows if (rideEntry == nullptr) return; - const bool isHalfScale = rideEntry->flags & RIDE_ENTRY_FLAG_VEHICLE_TAB_SCALE_HALF; + const bool isHalfScale = rideEntry->flags.has(RideEntryFlag::tabIconIsHalfScale); auto screenCoords = ScreenCoordsXY{ widget.left + 1, widget.top + 1 }; int32_t clipWidth = widget.right - screenCoords.x; @@ -1361,26 +1373,26 @@ namespace OpenRCT2::Ui::Windows const auto& rtd = ride->getRideTypeDescriptor(); - if (!rtd.HasFlag(RtdFlag::hasDataLogging)) + if (!rtd.flags.has(RtdFlag::hasDataLogging)) disabledTabs |= (1uLL << WIDX_TAB_8); // 0x800 if (rtd.specialType == RtdSpecialType::miniGolf) disabledTabs |= (1uLL << WIDX_TAB_2 | 1uLL << WIDX_TAB_3 | 1uLL << WIDX_TAB_4); // 0xE0 - if (rtd.HasFlag(RtdFlag::noVehicles)) + if (rtd.flags.has(RtdFlag::noVehicles)) disabledTabs |= (1uLL << WIDX_TAB_2); // 0x20 - if (!rtd.HasFlag(RtdFlag::hasTrackColourMain) && !rtd.HasFlag(RtdFlag::hasTrackColourAdditional) - && !rtd.HasFlag(RtdFlag::hasTrackColourSupports) && !rtd.HasFlag(RtdFlag::hasVehicleColours) - && !rtd.HasFlag(RtdFlag::hasEntranceAndExit)) + if (!rtd.flags.hasAny( + RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, RtdFlag::hasTrackColourSupports, + RtdFlag::hasVehicleColours, RtdFlag::hasEntranceAndExit)) { disabledTabs |= (1uLL << WIDX_TAB_5); // 0x100 } - if (rtd.HasFlag(RtdFlag::isShopOrFacility)) + if (rtd.flags.has(RtdFlag::isShopOrFacility)) disabledTabs |= (1uLL << WIDX_TAB_3 | 1uLL << WIDX_TAB_4 | 1uLL << WIDX_TAB_7); // 0x4C0 - if (!rtd.HasFlag(RtdFlag::allowMusic)) + if (!rtd.flags.has(RtdFlag::allowMusic)) { disabledTabs |= (1uLL << WIDX_TAB_6); // 0x200 } @@ -1399,7 +1411,7 @@ namespace OpenRCT2::Ui::Windows disabledTabs |= 1uLL << WIDX_TAB_2 | 1uLL << WIDX_TAB_3 | 1uLL << WIDX_TAB_4 | 1uLL << WIDX_TAB_5 | 1uLL << WIDX_TAB_6 | 1uLL << WIDX_TAB_7 | 1uLL << WIDX_TAB_8 | 1uLL << WIDX_TAB_9 | 1uLL << WIDX_TAB_10; } - else if ((rideEntry->flags & RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB) != 0) + else if (rideEntry->flags.has(RideEntryFlag::disableColourTab)) { disabledTabs |= (1uLL << WIDX_TAB_5); } @@ -1513,8 +1525,7 @@ namespace OpenRCT2::Ui::Windows std::optional newFocus; - if (viewSelectionIndex >= 0 && viewSelectionIndex < ride->numTrains - && ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (viewSelectionIndex >= 0 && viewSelectionIndex < ride->numTrains && ride->flags.has(RideFlag::onTrack)) { auto vehId = ride->vehicles[viewSelectionIndex]; const auto* rideEntry = ride->getRideEntry(); @@ -1679,6 +1690,19 @@ namespace OpenRCT2::Ui::Windows } break; } + case WIDX_MAKE_INVISIBLE: + { + auto gameAction = GameActions::RideSetVisibilityAction( + rideId, GameActions::RideSetVisibilityType::invisible); + GameActions::Execute(&gameAction, getGameState()); + break; + } + case WIDX_MAKE_VISIBLE: + { + auto gameAction = GameActions::RideSetVisibilityAction(rideId, GameActions::RideSetVisibilityType::visible); + GameActions::Execute(&gameAction, getGameState()); + break; + } } } @@ -1706,7 +1730,7 @@ namespace OpenRCT2::Ui::Windows } if (getGameState().cheats.allowArbitraryRideTypeChanges) { - newMinHeight += 15; + newMinHeight += 30; } flags |= WindowFlag::resizable; @@ -1730,14 +1754,14 @@ namespace OpenRCT2::Ui::Windows bool TrainMustBeHidden(const Ride& ride, int32_t trainIndex) const { - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (!ride.flags.has(RideFlag::onTrack)) return true; const auto* rideEntry = ride.getRideEntry(); if (rideEntry == nullptr) return false; - if (!(rideEntry->flags & RIDE_ENTRY_FLAG_HIDE_EMPTY_TRAINS)) + if (!rideEntry->flags.has(RideEntryFlag::hideEmptyTrains)) return false; return GetNumPeepsInTrain(ride, trainIndex) == 0; @@ -1753,7 +1777,7 @@ namespace OpenRCT2::Ui::Windows const auto& rtd = ride->getRideTypeDescriptor(); int32_t numItems = 1; - if (!rtd.HasFlag(RtdFlag::noVehicles)) + if (!rtd.flags.has(RtdFlag::noVehicles)) { numItems += ride->numStations; numItems += ride->numTrains; @@ -1802,12 +1826,11 @@ namespace OpenRCT2::Ui::Windows { default: case RideStatus::closed: - if ((ride.lifecycleFlags & RIDE_LIFECYCLE_CRASHED) - || (ride.lifecycleFlags & RIDE_LIFECYCLE_HAS_STALLED_VEHICLE)) + if (ride.flags.hasAny(RideFlag::crashed, RideFlag::hasStalledVehicle)) { return RideStatus::closed; } - if (ride.supportsStatus(RideStatus::testing) && !(ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED)) + if (ride.supportsStatus(RideStatus::testing) && !ride.flags.has(RideFlag::tested)) { return RideStatus::testing; } @@ -1815,7 +1838,7 @@ namespace OpenRCT2::Ui::Windows case RideStatus::simulating: return RideStatus::testing; case RideStatus::testing: - return (ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED) ? RideStatus::open : RideStatus::closed; + return ride.flags.has(RideFlag::tested) ? RideStatus::open : RideStatus::closed; case RideStatus::open: return RideStatus::closed; } @@ -1898,10 +1921,11 @@ namespace OpenRCT2::Ui::Windows // Will return the actual name for most rides, but a special string "Unknown Ride ({INT32})" for unknown ones. // The placeholder will then be filled with the ID. auto name = GetRideTypeNameForDropdown(i); + bool isDummy = GetRideTypeDescriptor(i).flags.has(RtdFlag::isDummyType); auto ft = Formatter(); ft.Add(i); auto label = FormatStringIDLegacy(name, ft.Data()); - _rideDropdownData.push_back({ i, name, label }); + _rideDropdownData.push_back({ i, name, label, isDummy }); } std::sort(_rideDropdownData.begin(), _rideDropdownData.end(), [](auto& a, auto& b) { @@ -1919,9 +1943,13 @@ namespace OpenRCT2::Ui::Windows PopulateRideTypeDropdown(); + std::vector indicesToDisable{}; for (size_t i = 0; i < _rideDropdownData.size(); i++) { gDropdown.items[i] = Dropdown::MenuLabel(_rideDropdownData[i].LabelString); + + if (_rideDropdownData[i].isDummy) + indicesToDisable.push_back(i); } Widget* dropdownWidget = widget - 1; @@ -1943,6 +1971,10 @@ namespace OpenRCT2::Ui::Windows gDropdown.highlightedIndex = pos; gDropdown.defaultIndex = pos; gDropdown.items[pos].setChecked(true); + for (auto i : indicesToDisable) + { + gDropdown.items[i].setDisabled(true); + } } void ShowLocateDropdown(Widget* widget) @@ -1957,7 +1989,7 @@ namespace OpenRCT2::Ui::Windows WindowDropdownShowText( { windowPos.x + widget->left, windowPos.y + widget->top }, widget->height(), colours[1], 0, 2); gDropdown.defaultIndex = 0; - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack) || _viewIndex == 0 || _viewIndex > ride->numTrains) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack) || _viewIndex == 0 || _viewIndex > ride->numTrains) { // Disable if we're a flat ride, 'overall view' is selected or a station is selected gDropdown.items[1].setDisabled(true); @@ -2000,7 +2032,7 @@ namespace OpenRCT2::Ui::Windows const auto& rtd = ride.getRideTypeDescriptor(); if (gameState.cheats.showVehiclesFromOtherTrackTypes && !( - rtd.HasFlag(RtdFlag::isFlatRide) || rtd.specialType == RtdSpecialType::maze + rtd.flags.has(RtdFlag::isFlatRide) || rtd.specialType == RtdSpecialType::maze || rtd.specialType == RtdSpecialType::miniGolf)) { selectionShouldBeExpanded = true; @@ -2025,7 +2057,7 @@ namespace OpenRCT2::Ui::Windows for (; rideTypeIterator <= rideTypeIteratorMax; rideTypeIterator++) { const auto& rtdIterator = GetRideTypeDescriptor(rideTypeIterator); - if (selectionShouldBeExpanded && rtdIterator.HasFlag(RtdFlag::isFlatRide)) + if (selectionShouldBeExpanded && rtdIterator.flags.has(RtdFlag::isFlatRide)) continue; if (selectionShouldBeExpanded && (rtdIterator.specialType == RtdSpecialType::maze || rtd.specialType == RtdSpecialType::miniGolf)) @@ -2170,8 +2202,7 @@ namespace OpenRCT2::Ui::Windows auto ride = GetRide(rideId); if (ride != nullptr) { - if (dropdownIndex != 0 && dropdownIndex <= ride->numTrains - && !(ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (dropdownIndex != 0 && dropdownIndex <= ride->numTrains && !ride->flags.has(RideFlag::onTrack)) { dropdownIndex = ride->numTrains + 1; } @@ -2307,7 +2338,7 @@ namespace OpenRCT2::Ui::Windows const auto& gameState = getGameState(); disabledWidgets &= ~((1uLL << WIDX_DEMOLISH) | (1uLL << WIDX_CONSTRUCTION)); - if (ride->lifecycleFlags & (RIDE_LIFECYCLE_INDESTRUCTIBLE | RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + if (ride->flags.hasAny(RideFlag::indestructible, RideFlag::indestructibleTrack) && !gameState.cheats.makeAllDestructible) disabledWidgets |= (1uLL << WIDX_DEMOLISH); @@ -2345,7 +2376,7 @@ namespace OpenRCT2::Ui::Windows + widgetIsPressed(*this, WIDX_OPEN_LIGHT); widgets[WIDX_OPEN_LIGHT].image = ImageId(openLightImage); - const int32_t offset = gameState.cheats.allowArbitraryRideTypeChanges ? 15 : 0; + const int32_t offset = gameState.cheats.allowArbitraryRideTypeChanges ? 30 : 0; // Anchor main page specific widgets widgets[WIDX_VIEWPORT].right = width - 26; widgets[WIDX_VIEWPORT].bottom = height - (14 + offset); @@ -2356,23 +2387,25 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_VIEW_DROPDOWN].right = width - 61; widgets[WIDX_VIEW_DROPDOWN].left = width - 71; widgets[WIDX_RIDE_TYPE].right = width - 26; - widgets[WIDX_RIDE_TYPE].top = height - 17; - widgets[WIDX_RIDE_TYPE].bottom = height - 4; - widgets[WIDX_RIDE_TYPE_DROPDOWN].left = width - 37; - widgets[WIDX_RIDE_TYPE_DROPDOWN].right = width - 27; - widgets[WIDX_RIDE_TYPE_DROPDOWN].top = height - 16; - widgets[WIDX_RIDE_TYPE_DROPDOWN].bottom = height - 5; + widgets[WIDX_RIDE_TYPE].moveToY(height - 32); + widgets[WIDX_RIDE_TYPE_DROPDOWN].moveTo({ width - 37, height - 31 }); + widgets[WIDX_MAKE_INVISIBLE].moveToY(height - 17); + widgets[WIDX_MAKE_VISIBLE].moveToY(height - 17); if (!gameState.cheats.allowArbitraryRideTypeChanges) { widgets[WIDX_RIDE_TYPE].type = WidgetType::empty; widgets[WIDX_RIDE_TYPE_DROPDOWN].type = WidgetType::empty; + widgets[WIDX_MAKE_INVISIBLE].type = WidgetType::empty; + widgets[WIDX_MAKE_VISIBLE].type = WidgetType::empty; } else { widgets[WIDX_RIDE_TYPE].type = WidgetType::dropdownMenu; widgets[WIDX_RIDE_TYPE].text = ride->getRideTypeDescriptor().Naming.Name; widgets[WIDX_RIDE_TYPE_DROPDOWN].type = WidgetType::button; + widgets[WIDX_MAKE_INVISIBLE].type = WidgetType::button; + widgets[WIDX_MAKE_VISIBLE].type = WidgetType::button; } WindowAlignTabs(this, WIDX_TAB_1, WIDX_TAB_10); @@ -2439,7 +2472,7 @@ namespace OpenRCT2::Ui::Windows { ride->formatStatusTo(ft); stringId = STR_BLACK_STRING; - if ((ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) || (ride->lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) + if (ride->flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) { stringId = STR_RED_OUTLINED_STRING; } @@ -2478,7 +2511,7 @@ namespace OpenRCT2::Ui::Windows return kStringIdEmpty; auto stringId = VehicleStatusNames[EnumValue(vehicle->status)]; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::singleSession) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::singleSession) && vehicle->status <= Vehicle::Status::unloadingPassengers) { stringId = SingleSessionVehicleStatusNames[EnumValue(vehicle->status)]; @@ -2552,7 +2585,7 @@ namespace OpenRCT2::Ui::Windows return GetStatusOverallView(ft); if (ride != nullptr && _viewIndex <= ride->numTrains) return GetStatusVehicle(ft); - if (ride != nullptr && ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride != nullptr && ride->flags.has(RideFlag::brokenDown)) return GetStatusOverallView(ft); return GetStatusStation(ft); } @@ -2652,7 +2685,7 @@ namespace OpenRCT2::Ui::Windows ShowVehicleTypeDropdown(&widgets[widgetIndex]); break; case WIDX_VEHICLE_REVERSED_TRAINS_CHECKBOX: - ride->setReversedTrains(!ride->hasLifecycleFlag(RIDE_LIFECYCLE_REVERSED_TRAINS)); + ride->setReversedTrains(!ride->flags.has(RideFlag::reversedTrains)); break; case WIDX_VEHICLE_TRAINS_INCREASE: if (ride->numTrains < Limits::kMaxTrainsPerRide) @@ -2800,11 +2833,11 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_VEHICLE_CARS_PER_TRAIN_DECREASE].type = WidgetType::empty; } - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::allowReversedTrains) - || (gameState.cheats.disableTrainLengthLimit && !ride->getRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide))) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::allowReversedTrains) + || (gameState.cheats.disableTrainLengthLimit && !ride->getRideTypeDescriptor().flags.has(RtdFlag::isFlatRide))) { widgets[WIDX_VEHICLE_REVERSED_TRAINS_CHECKBOX].type = WidgetType::checkbox; - if (ride->hasLifecycleFlag(RIDE_LIFECYCLE_REVERSED_TRAINS)) + if (ride->flags.has(RideFlag::reversedTrains)) { pressedWidgets |= (1uLL << WIDX_VEHICLE_REVERSED_TRAINS_CHECKBOX); } @@ -2948,7 +2981,7 @@ namespace OpenRCT2::Ui::Windows int32_t startX = std::max(2, (widget->width() - 1 - ((ride->numTrains - 1) * 36)) / 2 - 25); int32_t startY = widget->height() - 5; - bool isReversed = ride->hasLifecycleFlag(RIDE_LIFECYCLE_REVERSED_TRAINS); + bool isReversed = ride->flags.has(RideFlag::reversedTrains); int32_t carIndex = (isReversed) ? ride->numCarsPerTrain - 1 : 0; const auto& firstCarEntry = rideEntry->Cars[RideEntryGetVehicleAtPosition( @@ -3013,7 +3046,8 @@ namespace OpenRCT2::Ui::Windows y -= (carEntry.spacing / 2) / 17432; } - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::layeredVehiclePreview)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::layeredVehiclePreview) + && (nextSpriteToDraw - trainCarImages) >= 2) { VehicleDrawInfo tmp = *(nextSpriteToDraw - 1); *(nextSpriteToDraw - 1) = *(nextSpriteToDraw - 2); @@ -3462,7 +3496,7 @@ namespace OpenRCT2::Ui::Windows // Sometimes, only one of the alternatives support lift hill pieces. Make sure to check both. const auto& rtd = ride->getRideTypeDescriptor(); - bool hasAlternativeType = rtd.HasFlag(RtdFlag::hasInvertedVariant); + bool hasAlternativeType = rtd.flags.has(RtdFlag::hasInvertedVariant); if (rtd.TrackPaintFunctions.Regular.SupportsTrackGroup(TrackGroup::liftHill) || (hasAlternativeType && rtd.InvertedTrackPaintFunctions.Regular.SupportsTrackGroup(TrackGroup::liftHill))) { @@ -3502,7 +3536,7 @@ namespace OpenRCT2::Ui::Windows } // Leave if another vehicle arrives at station - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation) && ride->numTrains > 1 && !ride->isBlockSectioned()) { widgets[WIDX_LEAVE_WHEN_ANOTHER_ARRIVES_CHECKBOX].type = WidgetType::checkbox; @@ -3518,7 +3552,7 @@ namespace OpenRCT2::Ui::Windows } // Synchronise with adjacent stations - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::canSynchroniseWithAdjacentStations)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::canSynchroniseWithAdjacentStations)) { widgets[WIDX_SYNCHRONISE_WITH_ADJACENT_STATIONS_CHECKBOX].type = WidgetType::checkbox; widgets[WIDX_SYNCHRONISE_WITH_ADJACENT_STATIONS_CHECKBOX].text = STR_SYNCHRONISE_WITH_ADJACENT_STATIONS; @@ -3534,7 +3568,7 @@ namespace OpenRCT2::Ui::Windows // Waiting widgets[WIDX_LOAD].text = VehicleLoadNames[(ride->departFlags & RIDE_DEPART_WAIT_FOR_LOAD_MASK)]; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasLoadOptions)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasLoadOptions)) { widgets[WIDX_LOAD_CHECKBOX].type = WidgetType::checkbox; widgets[WIDX_LOAD].type = WidgetType::dropdownMenu; @@ -3641,7 +3675,7 @@ namespace OpenRCT2::Ui::Windows format = STR_MAX_PEOPLE_ON_RIDE_VALUE; caption = STR_MAX_PEOPLE_ON_RIDE; tooltip = STR_MAX_PEOPLE_ON_RIDE_TIP; - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::noVehicles)) format = 0; break; } @@ -3820,7 +3854,7 @@ namespace OpenRCT2::Ui::Windows numItems = 1; int32_t breakdownReason = ride->breakdownReasonPending; - if (breakdownReason != BREAKDOWN_NONE && (ride->lifecycleFlags & RIDE_LIFECYCLE_BREAKDOWN_PENDING)) + if (breakdownReason != BREAKDOWN_NONE && ride->flags.has(RideFlag::breakdownPending)) { for (int32_t i = 0; i < 8; i++) { @@ -3843,7 +3877,7 @@ namespace OpenRCT2::Ui::Windows } } - if ((ride->lifecycleFlags & RIDE_LIFECYCLE_BREAKDOWN_PENDING) == 0) + if (!ride->flags.has(RideFlag::breakdownPending)) { gDropdown.items[0].setDisabled(true); } @@ -3878,7 +3912,7 @@ namespace OpenRCT2::Ui::Windows switch (ride->breakdownReasonPending) { case BREAKDOWN_SAFETY_CUT_OUT: - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (!ride->flags.has(RideFlag::onTrack)) break; for (int32_t i = 0; i < ride->numTrains; ++i) { @@ -3886,9 +3920,9 @@ namespace OpenRCT2::Ui::Windows vehicle != nullptr; vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) { - vehicle->ClearFlag( - VehicleFlags::CarIsBroken | VehicleFlags::StoppedBySafetyCutOut - | VehicleFlags::TrainIsBroken); + vehicle->flags.unset( + VehicleFlag::carIsBroken, VehicleFlag::stoppedBySafetyCutout, + VehicleFlag::trainIsBroken); } } break; @@ -3899,25 +3933,24 @@ namespace OpenRCT2::Ui::Windows vehicle = getGameState().entities.GetEntity(ride->vehicles[ride->brokenTrain]); if (vehicle != nullptr) { - vehicle->ClearFlag(VehicleFlags::CarIsBroken); + vehicle->flags.unset(VehicleFlag::carIsBroken); } break; case BREAKDOWN_VEHICLE_MALFUNCTION: vehicle = getGameState().entities.GetEntity(ride->vehicles[ride->brokenTrain]); if (vehicle != nullptr) { - vehicle->ClearFlag(VehicleFlags::TrainIsBroken); + vehicle->flags.unset(VehicleFlag::trainIsBroken); } break; } - ride->lifecycleFlags &= ~(RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN); + ride->flags.unset(RideFlag::breakdownPending, RideFlag::brokenDown); auto* windowMgr = GetWindowManager(); windowMgr->InvalidateByNumber(WindowClass::ride, number); break; } - if (ride->lifecycleFlags - & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + if (ride->flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::crashed)) { ContextShowError(STR_DEBUG_CANT_FORCE_BREAKDOWN, STR_DEBUG_RIDE_ALREADY_BROKEN, {}); } @@ -3995,8 +4028,7 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_FORCE_BREAKDOWN].type = WidgetType::empty; } - if (ride->getRideTypeDescriptor().AvailableBreakdowns == 0 - || !(ride->lifecycleFlags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)) + if (ride->getRideTypeDescriptor().AvailableBreakdowns == 0 || !ride->flags.has(RideFlag::everBeenOpened)) { disabledWidgets |= (1uLL << WIDX_REFURBISH_RIDE); widgets[WIDX_REFURBISH_RIDE].tooltip = STR_CANT_REFURBISH_NOT_NEEDED; @@ -4066,14 +4098,14 @@ namespace OpenRCT2::Ui::Windows if (ride->breakdownReason == BREAKDOWN_NONE) return; - stringId = (ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) ? STR_CURRENT_BREAKDOWN : STR_LAST_BREAKDOWN; + stringId = ride->flags.has(RideFlag::brokenDown) ? STR_CURRENT_BREAKDOWN : STR_LAST_BREAKDOWN; ft = Formatter(); ft.Add(RideBreakdownReasonNames[ride->breakdownReason]); DrawTextBasic(rt, screenCoords, stringId, ft); screenCoords.y += 12; // Mechanic status - if (ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride->flags.has(RideFlag::brokenDown)) { switch (ride->mechanicStatus) { @@ -4131,7 +4163,7 @@ namespace OpenRCT2::Ui::Windows { // Get station flags (shops don't have them) auto stationObjFlags = 0; - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) { auto stationObj = ride.getStationObject(); if (stationObj != nullptr) @@ -4144,12 +4176,12 @@ namespace OpenRCT2::Ui::Windows { case 0: return (stationObjFlags & StationObjectFlags::hasPrimaryColour) - || ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrackColourMain); + || ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrackColourMain); case 1: return (stationObjFlags & StationObjectFlags::hasSecondaryColour) - || ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrackColourAdditional); + || ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrackColourAdditional); case 2: - return ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrackColourSupports); + return ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrackColourSupports); default: return 0; } @@ -4210,7 +4242,7 @@ namespace OpenRCT2::Ui::Windows auto ride = GetRide(rideId); if (ride != nullptr) { - const bool currentlyEnabled = ride->hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS); + const bool currentlyEnabled = ride->flags.has(RideFlag::randomShopColours); auto rideSetAppearanceAction = GameActions::RideSetAppearanceAction( rideId, GameActions::RideSetAppearanceType::SellingItemColourIsRandom, currentlyEnabled ? 0 : 1, 0); GameActions::Execute(&rideSetAppearanceAction, gameState); @@ -4591,7 +4623,7 @@ namespace OpenRCT2::Ui::Windows } // Track, multiple colour schemes - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::supportsMultipleColourSchemes)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::supportsMultipleColourSchemes)) { widgets[WIDX_TRACK_COLOUR_SCHEME].type = WidgetType::dropdownMenu; widgets[WIDX_TRACK_COLOUR_SCHEME_DROPDOWN].type = WidgetType::button; @@ -4630,7 +4662,7 @@ namespace OpenRCT2::Ui::Windows if (ride->hasRecolourableShopItems()) { widgets[WIDX_SELL_ITEM_RANDOM_COLOUR_CHECKBOX].type = WidgetType::checkbox; - if (ride->hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS)) + if (ride->flags.has(RideFlag::randomShopColours)) { pressedWidgets |= (1uLL << WIDX_SELL_ITEM_RANDOM_COLOUR_CHECKBOX); } @@ -4656,16 +4688,17 @@ namespace OpenRCT2::Ui::Windows } // Track preview - if (rtd.HasFlag(RtdFlag::hasTrackColourMain) || rtd.HasFlag(RtdFlag::hasTrackColourAdditional) - || rtd.HasFlag(RtdFlag::hasTrackColourSupports)) - widgets[WIDX_TRACK_PREVIEW].type = WidgetType::spinner; + if (rtd.flags.hasAny( + RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, RtdFlag::hasTrackColourSupports)) + widgets[WIDX_PRIMARY_PREVIEW].type = WidgetType::spinner; else - widgets[WIDX_TRACK_PREVIEW].type = WidgetType::empty; + widgets[WIDX_PRIMARY_PREVIEW].type = WidgetType::empty; // Entrance style - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasEntranceAndExit)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasEntranceAndExit)) { - widgets[WIDX_ENTRANCE_PREVIEW].type = WidgetType::spinner; + widgets[WIDX_SECONDARY_PREVIEW].type = WidgetType::spinner; + widgets[WIDX_ENTRANCE_STYLE_LABEL].type = WidgetType::label; widgets[WIDX_ENTRANCE_STYLE].type = WidgetType::dropdownMenu; widgets[WIDX_ENTRANCE_STYLE_DROPDOWN].type = WidgetType::button; @@ -4679,14 +4712,14 @@ namespace OpenRCT2::Ui::Windows } else { - widgets[WIDX_ENTRANCE_PREVIEW].type = WidgetType::empty; + widgets[WIDX_SECONDARY_PREVIEW].type = WidgetType::empty; + widgets[WIDX_ENTRANCE_STYLE_LABEL].type = WidgetType::empty; widgets[WIDX_ENTRANCE_STYLE].type = WidgetType::empty; widgets[WIDX_ENTRANCE_STYLE_DROPDOWN].type = WidgetType::empty; } // Vehicle colours - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles) - && ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasVehicleColours)) + if (!rtd.flags.has(RtdFlag::noVehicles) && rtd.flags.has(RtdFlag::hasVehicleColours)) { if (ride->vehicleColourSettings == VehicleColourSettings::same) { @@ -4743,7 +4776,7 @@ namespace OpenRCT2::Ui::Windows } // Vehicle colour scheme type - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::vehicleIsIntegral) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::vehicleIsIntegral) && (ride->numCarsPerTrain | ride->numTrains) > 1) { widgets[WIDX_VEHICLE_COLOUR_SCHEME].type = WidgetType::dropdownMenu; @@ -4798,9 +4831,6 @@ namespace OpenRCT2::Ui::Windows void ColourOnDraw(RenderTarget& rt) { - // TODO: This should use lists and identified sprites - RenderTarget clippedRT; - auto ride = GetRide(rideId); if (ride == nullptr) return; @@ -4808,100 +4838,159 @@ namespace OpenRCT2::Ui::Windows drawWidgets(rt); drawTabImages(rt); + ColourOnDrawPrimaryPreview(rt, ride); + ColourOnDrawSecondaryPreview(rt, ride); + } + + void ColourOnDrawPrimaryPreview(RenderTarget& rt, const Ride* ride) + { // Track / shop item preview - const auto& trackPreviewWidget = widgets[WIDX_TRACK_PREVIEW]; - if (trackPreviewWidget.type != WidgetType::empty) - Rectangle::fill( - rt, - { { windowPos + ScreenCoordsXY{ trackPreviewWidget.left + 1, trackPreviewWidget.top + 1 } }, - { windowPos + ScreenCoordsXY{ trackPreviewWidget.right - 1, trackPreviewWidget.bottom - 1 } } }, - PaletteIndex::pi12); + const auto& widget = widgets[WIDX_PRIMARY_PREVIEW]; + if (widget.type == WidgetType::empty) + return; - auto trackColour = ride->trackColours[_rideColour]; + const auto clipScreenPos = windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 }; + const auto clipWidth = widget.width() - 2; + const auto clipHeight = widget.height() - 1; + + RenderTarget clippedRT; + if (!ClipRenderTarget(clippedRT, rt, clipScreenPos, clipWidth, clipHeight)) + return; + + GfxClear(clippedRT, PaletteIndex::pi12); - // auto rideEntry = ride->getRideEntry(); if (rideEntry == nullptr || rideEntry->shop_item[0] == ShopItem::none) { - auto screenCoords = windowPos + ScreenCoordsXY{ trackPreviewWidget.left, trackPreviewWidget.top }; - - // Track - const auto& rtd = ride->getRideTypeDescriptor(); - if (rtd.specialType == RtdSpecialType::maze) - { - GfxDrawSprite(rt, ImageId(MazeOptions[EnumValue(trackColour.supports)].sprite), screenCoords); - } - else - { - const auto& typeDescriptor = ride->getRideTypeDescriptor(); - int32_t spriteIndex = typeDescriptor.ColourPreview.Track; - if (spriteIndex != 0) - { - GfxDrawSprite(rt, ImageId(spriteIndex, trackColour.main, trackColour.additional), screenCoords); - } - - // Supports - spriteIndex = typeDescriptor.ColourPreview.Supports; - if (spriteIndex != 0) - { - GfxDrawSprite(rt, ImageId(spriteIndex, trackColour.supports), screenCoords); - } - } + ColourOnDrawTrackPreview(clippedRT, ride, widget); } else { - auto screenCoords = windowPos - + ScreenCoordsXY{ (trackPreviewWidget.left + trackPreviewWidget.right) / 2 - 8, - (trackPreviewWidget.bottom + trackPreviewWidget.top) / 2 - 6 }; + ColourOnDrawShopPreview(clippedRT, ride, widget); + } + } - ShopItem shopItem = rideEntry->shop_item[1] == ShopItem::none ? rideEntry->shop_item[0] - : rideEntry->shop_item[1]; - if (ride->hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS)) + void ColourOnDrawTrackPreview(RenderTarget& rt, const Ride* ride, const Widget& widget) + { + const auto screenCoords = ScreenCoordsXY{ 0, 0 }; + const auto trackColour = ride->trackColours[_rideColour]; + + const auto& rtd = ride->getRideTypeDescriptor(); + if (rtd.specialType == RtdSpecialType::maze) + { + // Maze style + GfxDrawSprite(rt, ImageId(MazeOptions[EnumValue(trackColour.supports)].sprite), screenCoords); + } + else + { + const auto& typeDescriptor = ride->getRideTypeDescriptor(); + + // Track + int32_t spriteIndex = typeDescriptor.ColourPreview.Track; + if (spriteIndex != 0) { - auto spriteColour = static_cast((getGameState().currentTicks / 32) % kColourNumTotal); - - GfxDrawSprite(rt, ImageId(GetShopItemDescriptor(shopItem).Image, spriteColour), screenCoords); + GfxDrawSprite(rt, ImageId(spriteIndex, trackColour.main, trackColour.additional), screenCoords); } - else + + // Supports + spriteIndex = typeDescriptor.ColourPreview.Supports; + if (spriteIndex != 0) { - GfxDrawSprite(rt, ImageId(GetShopItemDescriptor(shopItem).Image, ride->trackColours[0].main), screenCoords); + GfxDrawSprite(rt, ImageId(spriteIndex, trackColour.supports), screenCoords); } } + } - // Entrance preview - trackColour = ride->trackColours[0]; - const auto& entrancePreviewWidget = widgets[WIDX_ENTRANCE_PREVIEW]; - if (entrancePreviewWidget.type != WidgetType::empty) + void ColourOnDrawShopPreview(RenderTarget& rt, const Ride* ride, const Widget& widget) + { + const auto rideEntry = ride->getRideEntry(); + ShopItem shopItemIndex = rideEntry->shop_item[1] == ShopItem::none ? rideEntry->shop_item[0] + : rideEntry->shop_item[1]; + + const auto shopItem = GetShopItemDescriptor(shopItemIndex); + if (shopItem.IsRecolourable()) { - if (ClipRenderTarget( - clippedRT, rt, - windowPos + ScreenCoordsXY{ entrancePreviewWidget.left + 1, entrancePreviewWidget.top + 1 }, - entrancePreviewWidget.width() - 1, entrancePreviewWidget.height() - 1)) - { - GfxClear(clippedRT, PaletteIndex::pi12); + ColourOnDrawShopItemPreview(rt, ride, shopItem, widget); + } + else + { + ColourOnDrawShopBuildingPreview(rt, ride, widget); + } + } - auto stationObj = ride->getStationObject(); - if (stationObj != nullptr && stationObj->BaseImageId != kImageIndexUndefined) - { - auto imageId = ImageId(stationObj->BaseImageId, trackColour.main, trackColour.additional); + void ColourOnDrawShopItemPreview( + RenderTarget& rt, const Ride* ride, const ShopItemDescriptor& shopItem, const Widget& widget) + { + Colour spriteColour = ride->trackColours[0].main; + if (ride->flags.has(RideFlag::randomShopColours)) + spriteColour = Colour((getGameState().currentTicks / 32) % kColourNumNormal); - // Back - GfxDrawSprite(clippedRT, imageId, { 34, 20 }); + auto* image = GfxGetG1Element(shopItem.Image); + if (image == nullptr) + return; - // Front - GfxDrawSprite(clippedRT, imageId.WithIndexOffset(4), { 34, 20 }); + const auto screenCoords = ScreenCoordsXY{ (widget.width() - image->width) / 2, + (widget.height() - image->height) / 2 }; + GfxDrawSprite(rt, ImageId(shopItem.Image, spriteColour), screenCoords); + } - // Glass - if (stationObj->Flags & StationObjectFlags::isTransparent) - { - auto glassImageId = ImageId(stationObj->BaseImageId + 20).WithTransparency(trackColour.main); - GfxDrawSprite(clippedRT, glassImageId, { 34, 20 }); - } - } - } + void ColourOnDrawShopBuildingPreview(RenderTarget& rt, const Ride* ride, const Widget& widget) + { + const auto rideEntry = ride->getRideEntry(); + const ImageIndex previewImage = rideEntry->images_offset + 3 + 1; - auto labelPos = windowPos + ScreenCoordsXY{ 3, widgets[WIDX_ENTRANCE_STYLE].top }; - DrawTextEllipsised(rt, labelPos, 97, STR_STATION_STYLE, {}); + auto* image = GfxGetG1Element(previewImage); + if (image == nullptr) + return; + + const auto clipWidth = widget.width() - 2; + const auto clipHeight = widget.height() - 1; + + auto imageLocationX = (clipWidth / 2) - (image->width / 2) - image->xOffset; + auto imageLocationY = (clipHeight / 2) - (image->height / 2) - image->yOffset; + + GfxDrawSprite(rt, ImageId(previewImage, ride->trackColours[0].main), { imageLocationX, imageLocationY }); + } + + void ColourOnDrawSecondaryPreview(RenderTarget& rt, const Ride* ride) + { + const auto& widget = widgets[WIDX_SECONDARY_PREVIEW]; + if (widget.type == WidgetType::empty) + return; + + const auto clipScreenPos = windowPos + ScreenCoordsXY{ widget.left + 1, widget.top + 1 }; + RenderTarget clippedRT; + if (!ClipRenderTarget(clippedRT, rt, clipScreenPos, widget.width() - 1, widget.height() - 1)) + { + return; + } + + GfxClear(clippedRT, PaletteIndex::pi12); + + ColourOnDrawEntrancePreview(clippedRT, ride, widget); + } + + void ColourOnDrawEntrancePreview(RenderTarget& rt, const Ride* ride, const Widget& widget) + { + auto stationObj = ride->getStationObject(); + if (stationObj == nullptr && stationObj->entranceBackIndex == kImageIndexUndefined) + return; + + auto trackColour = ride->trackColours[0]; + + // Back + auto backImageId = ImageId(stationObj->entranceBackIndex, trackColour.main, trackColour.additional); + GfxDrawSprite(rt, backImageId, { 34, 20 }); + + // Front + auto frontImageId = ImageId(stationObj->entranceFrontIndex, trackColour.main, trackColour.additional); + GfxDrawSprite(rt, frontImageId, { 34, 20 }); + + // Glass + if (stationObj->Flags & StationObjectFlags::isTransparent) + { + auto glassImageId = ImageId(stationObj->entranceFrontGlassIndex).WithTransparency(trackColour.main); + GfxDrawSprite(rt, glassImageId, { 34, 20 }); } } @@ -4953,7 +5042,7 @@ namespace OpenRCT2::Ui::Windows auto ride = GetRide(rideId); if (ride != nullptr) { - int32_t activateMusic = (ride->lifecycleFlags & RIDE_LIFECYCLE_MUSIC) ? 0 : 1; + int32_t activateMusic = ride->flags.has(RideFlag::music) ? 0 : 1; SetOperatingSetting(rideId, GameActions::RideSetSetting::Music, activateMusic); ride->windowInvalidateFlags.set(RideInvalidateFlag::music); } @@ -4993,7 +5082,7 @@ namespace OpenRCT2::Ui::Windows return; // Expand the window when music is playing - auto isMusicActivated = (ride->lifecycleFlags & RIDE_LIFECYCLE_MUSIC) != 0; + auto isMusicActivated = ride->flags.has(RideFlag::music); auto standardHeight = widgets[WIDX_MUSIC_DROPDOWN].bottom + 6; auto newMinHeight = isMusicActivated ? standardHeight + 133 : standardHeight; auto newMaxHeight = isMusicActivated ? standardHeight + 369 : standardHeight; @@ -5053,7 +5142,7 @@ namespace OpenRCT2::Ui::Windows } if (getGameState().cheats.unlockOperatingLimits - || musicObj->SupportsRideType(ride->type, rtd.HasFlag(RtdFlag::requireExplicitListingInMusicObjects))) + || musicObj->SupportsRideType(ride->type, rtd.flags.has(RtdFlag::requireExplicitListingInMusicObjects))) { musicOrder.push_back(i); } @@ -5178,7 +5267,7 @@ namespace OpenRCT2::Ui::Windows } widgets[WIDX_MUSIC].text = musicName; - auto isMusicActivated = (ride->lifecycleFlags & RIDE_LIFECYCLE_MUSIC) != 0; + auto isMusicActivated = ride->flags.has(RideFlag::music); bool hasPreviewImage = musicObj != nullptr && musicObj->HasPreview(); widgetSetVisible(*this, WIDX_MUSIC_DATA, isMusicActivated); @@ -5221,7 +5310,7 @@ namespace OpenRCT2::Ui::Windows return; // Draw music data only when music is activated - auto isMusicActivated = (ride->lifecycleFlags & RIDE_LIFECYCLE_MUSIC) != 0; + auto isMusicActivated = ride->flags.has(RideFlag::music); if (!isMusicActivated) return; @@ -5256,7 +5345,7 @@ namespace OpenRCT2::Ui::Windows return; // only draw track listing when music is activated - auto isMusicActivated = (ride->lifecycleFlags & RIDE_LIFECYCLE_MUSIC) != 0; + auto isMusicActivated = ride->flags.has(RideFlag::music); if (!isMusicActivated) return; @@ -5458,7 +5547,7 @@ namespace OpenRCT2::Ui::Windows { windowPos.x + widgets[widgetIndex].left, windowPos.y + widgets[widgetIndex].top }, widgets[widgetIndex].height(), colours[1], Dropdown::Flag::StayOpen, 2); gDropdown.defaultIndex = 0; - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { // Disable saving without scenery if we're a flat ride gDropdown.items[0].setDisabled(true); @@ -5578,7 +5667,7 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_SAVE_TRACK_DESIGN].type = WidgetType::flatBtn; disabledWidgets |= (1uLL << WIDX_SAVE_TRACK_DESIGN); - if (ride->lifecycleFlags & RIDE_LIFECYCLE_TESTED) + if (ride->flags.has(RideFlag::tested)) { if (!ride->ratings.isNull()) { @@ -5618,7 +5707,7 @@ namespace OpenRCT2::Ui::Windows auto screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_PAGE_BACKGROUND].left + 4, widgets[WIDX_PAGE_BACKGROUND].top + 4 }; - if (ride->lifecycleFlags & RIDE_LIFECYCLE_TESTED) + if (ride->flags.has(RideFlag::tested)) { // Excitement StringId ratingName = GetRatingName(ride->ratings.excitement); @@ -5659,7 +5748,7 @@ namespace OpenRCT2::Ui::Windows rt, { screenCoords - ScreenCoordsXY{ 0, 6 }, screenCoords + ScreenCoordsXY{ 303, -5 } }, colours[1], Rectangle::BorderStyle::inset); - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_NO_RAW_STATS)) + if (!ride->flags.has(RideFlag::noRawStats)) { if (ride->getRideTypeDescriptor().specialType == RtdSpecialType::miniGolf) { @@ -5764,7 +5853,7 @@ namespace OpenRCT2::Ui::Windows screenCoords.y += kListRowHeight; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasGForces)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasGForces)) { // Max. positive vertical G's stringId = STR_MAX_POSITIVE_VERTICAL_G; @@ -5797,7 +5886,7 @@ namespace OpenRCT2::Ui::Windows screenCoords.y += kListRowHeight; } - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasDrops)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasDrops)) { ft = Formatter(); ft.Add(ride->numDrops); @@ -6004,7 +6093,7 @@ namespace OpenRCT2::Ui::Windows pressedWidgets |= (1LL << (WIDX_GRAPH_VELOCITY + listInformationType)); // Hide graph buttons that are not applicable - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasGForces)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasGForces)) { widgets[WIDX_GRAPH_VERTICAL].type = WidgetType::button; widgets[WIDX_GRAPH_LATERAL].type = WidgetType::button; @@ -6553,7 +6642,7 @@ namespace OpenRCT2::Ui::Windows // Get secondary item auto secondaryItem = ride->getRideTypeDescriptor().PhotoItem; - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)) + if (!ride->flags.has(RideFlag::onRidePhoto)) { if ((secondaryItem = rideEntry->shop_item[1]) != ShopItem::none) { @@ -6639,7 +6728,7 @@ namespace OpenRCT2::Ui::Windows // Secondary item profit / loss per item sold secondaryItem = ride->getRideTypeDescriptor().PhotoItem; - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)) + if (!ride->flags.has(RideFlag::onRidePhoto)) secondaryItem = rideEntry->shop_item[1]; if (secondaryItem != ShopItem::none) @@ -6780,7 +6869,7 @@ namespace OpenRCT2::Ui::Windows ride->formatNameTo(ft); widgets[WIDX_SHOW_GUESTS_THOUGHTS].type = WidgetType::flatBtn; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) { widgets[WIDX_SHOW_GUESTS_ON_RIDE].type = WidgetType::empty; widgets[WIDX_SHOW_GUESTS_QUEUING].type = WidgetType::empty; @@ -6881,8 +6970,8 @@ namespace OpenRCT2::Ui::Windows } // Secondary shop items sold / on-ride photos sold - shopItem = (ride->lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) ? ride->getRideTypeDescriptor().PhotoItem - : ride->getRideEntry()->shop_item[1]; + shopItem = ride->flags.has(RideFlag::onRidePhoto) ? ride->getRideTypeDescriptor().PhotoItem + : ride->getRideEntry()->shop_item[1]; if (shopItem != ShopItem::none) { ft = Formatter(); @@ -6978,7 +7067,7 @@ namespace OpenRCT2::Ui::Windows if (ride.type >= RIDE_TYPE_COUNT) return nullptr; - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::noVehicles)) return RideMainOpen(ride); auto* windowMgr = GetWindowManager(); diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 5f92487363..5e52708665 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -24,14 +24,15 @@ #include #include #include -#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -269,7 +270,7 @@ namespace OpenRCT2::Ui::Windows _currentTrackHasLiftHill = false; _currentTrackAlternative.clearAll(); - if (currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::startConstructionInverted)) + if (currentRide->getRideTypeDescriptor().flags.has(RtdFlag::startConstructionInverted)) _currentTrackAlternative.set(AlternativeTrackFlag::inverted); _previousTrackRollEnd = TrackRoll::none; @@ -447,7 +448,7 @@ namespace OpenRCT2::Ui::Windows newDisabledWidgets |= (1uLL << WIDX_SLOPE_DOWN) | (1uLL << WIDX_SLOPE_UP); } } - if (currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::upInclineRequiresLift) + if (currentRide->getRideTypeDescriptor().flags.has(RtdFlag::upInclineRequiresLift) && !getGameState().cheats.enableAllDrawableTrackPieces) { // Disable lift hill toggle and banking if current track piece is uphill @@ -932,7 +933,7 @@ namespace OpenRCT2::Ui::Windows if (_currentlySelectedTrack == TrackCurve::leftSmall || _currentlySelectedTrack == TrackCurve::rightSmall) { if (_currentTrackPitchEnd == TrackPitch::none && _previousTrackRollEnd != TrackRoll::none - && (!currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::upInclineRequiresLift) + && (!currentRide->getRideTypeDescriptor().flags.has(RtdFlag::upInclineRequiresLift) || getGameState().cheats.enableAllDrawableTrackPieces)) { newDisabledWidgets &= ~(1uLL << WIDX_SLOPE_UP); @@ -1743,7 +1744,7 @@ namespace OpenRCT2::Ui::Windows holdDownWidgets = (1u << WIDX_CONSTRUCT) | (1u << WIDX_DEMOLISH) | (1u << WIDX_NEXT_SECTION) | (1u << WIDX_PREVIOUS_SECTION); - if (rtd.HasFlag(RtdFlag::isShopOrFacility) || !currentRide->hasStation()) + if (rtd.flags.has(RtdFlag::isShopOrFacility) || !currentRide->hasStation()) { widgets[WIDX_ENTRANCE_EXIT_GROUPBOX].type = WidgetType::empty; widgets[WIDX_ENTRANCE].type = WidgetType::empty; @@ -1861,7 +1862,7 @@ namespace OpenRCT2::Ui::Windows } const auto& gameState = getGameState(); - if (currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::upInclineRequiresLift) + if (currentRide->getRideTypeDescriptor().flags.has(RtdFlag::upInclineRequiresLift) && (_currentTrackPitchEnd == TrackPitch::up25 || _currentTrackPitchEnd == TrackPitch::up60) && !gameState.cheats.enableAllDrawableTrackPieces) { @@ -1870,7 +1871,7 @@ namespace OpenRCT2::Ui::Windows if ((IsTrackEnabled(TrackGroup::liftHill) && !_currentlySelectedTrack.isTrackType) || (gameState.cheats.enableChainLiftOnAllTrack - && currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack))) + && currentRide->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack))) { widgets[WIDX_CHAIN_LIFT].type = WidgetType::flatBtn; } @@ -1996,7 +1997,7 @@ namespace OpenRCT2::Ui::Windows || _currentlySelectedTrack == TrackElemType::blockBrakes || _selectedTrackType > TrackElemType::highestAlias || _currentlySelectedTrack.trackType > TrackElemType::highestAlias; - bool rideHasSeatRotation = rtd.HasFlag(RtdFlag::hasSeatRotation); + bool rideHasSeatRotation = rtd.flags.has(RtdFlag::hasSeatRotation); if (!trackHasSpeedSetting) { @@ -2089,7 +2090,7 @@ namespace OpenRCT2::Ui::Windows widgets[WIDX_CONSTRUCT].type = WidgetType::empty; widgets[WIDX_DEMOLISH].type = WidgetType::flatBtn; widgets[WIDX_ROTATE].type = WidgetType::empty; - if (rtd.HasFlag(RtdFlag::cannotHaveGaps)) + if (rtd.flags.has(RtdFlag::cannotHaveGaps)) { widgets[WIDX_PREVIOUS_SECTION].type = WidgetType::empty; widgets[WIDX_NEXT_SECTION].type = WidgetType::empty; @@ -2473,7 +2474,7 @@ namespace OpenRCT2::Ui::Windows { // When flat rides are deleted, the window should be reset so the currentRide can be placed again. const auto& rtd = currentRide->getRideTypeDescriptor(); - if (rtd.HasFlag(RtdFlag::isFlatRide) && !rtd.HasFlag(RtdFlag::isShopOrFacility)) + if (rtd.flags.has(RtdFlag::isFlatRide) && !rtd.flags.has(RtdFlag::isShopOrFacility)) { RideInitialiseConstructionWindow(*currentRide); } @@ -2678,7 +2679,7 @@ namespace OpenRCT2::Ui::Windows if (currentRide != nullptr && RideAreAllPossibleEntrancesAndExitsBuilt(*currentRide).Successful) { ToolCancel(); - if (!currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!currentRide->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { windowMgr->CloseByClass(WindowClass::rideConstruction); } @@ -2837,7 +2838,7 @@ namespace OpenRCT2::Ui::Windows { RideTrackGroups disabledGroups{}; const auto& rtd = GetRideTypeDescriptor(rideType); - if (rtd.HasFlag(RtdFlag::hasTrack)) + if (rtd.flags.has(RtdFlag::hasTrack)) { // Set all pieces as “disabled”. When looping over the ride entries, // pieces will be re-enabled as soon as a single entry supports it. @@ -2846,7 +2847,7 @@ namespace OpenRCT2::Ui::Windows auto& objManager = GetContext()->GetObjectManager(); auto& rideEntries = objManager.GetAllRideEntries(rideType); // If there are no vehicles for this ride type, enable all the track pieces. - if (rideEntries.size() == 0) + if (rideEntries.empty()) { disabledGroups.reset(); } @@ -3492,7 +3493,7 @@ namespace OpenRCT2::Ui::Windows } if (_autoRotatingShop && _rideConstructionState == RideConstructionState::Place - && ride->getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + && ride->getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) { PathElement* pathsByDir[kNumOrthogonalDirections]; @@ -4787,7 +4788,7 @@ namespace OpenRCT2::Ui::Windows int16_t zBegin{}, zEnd{}; const auto& ted = GetTrackElementDescriptor(trackType); const TrackCoordinates& coords = ted.coordinates; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { zBegin = coords.zBegin; zEnd = coords.zEnd; diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index fe278f4104..4ef243052f 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -16,8 +16,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include @@ -552,7 +553,7 @@ namespace OpenRCT2::Ui::Windows const auto& rideManager = RideManager(gameState); auto allClosed = true; auto allOpen = false; - if (_rideList.size() > 0 && std::size(rideManager) != 0) + if (!_rideList.empty() && std::size(rideManager) != 0) { auto c = static_cast(page); allClosed = std::none_of(rideManager.begin(), rideManager.end(), [c](const Ride& rideRef) { @@ -674,8 +675,7 @@ namespace OpenRCT2::Ui::Windows ridePtr->formatStatusTo(ft); // Make test red and bold if broken down or crashed - if ((ridePtr->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) - || (ridePtr->lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) + if (ridePtr->flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) { format = STR_RED_OUTLINED_STRING; } diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 0e854fdc47..ef28d1488d 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -20,17 +20,18 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -825,7 +826,7 @@ namespace OpenRCT2::Ui::Windows } auto windowWidth = width; - if (_tabEntries.size() > 0) + if (!_tabEntries.empty()) { const auto lastTabIndex = GetMaxTabCountInARow() == kMaxTabsPerRow ? kMaxTabsPerRow - 1 : _tabEntries.size() - 1; @@ -916,7 +917,7 @@ namespace OpenRCT2::Ui::Windows auto sceneryObjectType = GetObjectTypeFromSceneryType(selectedSceneryEntry.SceneryType); auto& objManager = GetContext()->GetObjectManager(); auto sceneryObject = objManager.GetLoadedObject(sceneryObjectType, selectedSceneryEntry.EntryIndex); - if (sceneryObject != nullptr && sceneryObject->GetAuthors().size() > 0) + if (sceneryObject != nullptr && !sceneryObject->GetAuthors().empty()) { std::string authorsString; const auto& authors = sceneryObject->GetAuthors(); @@ -1007,7 +1008,7 @@ namespace OpenRCT2::Ui::Windows tabInfo.AddEntryToBack(sceneryEntry); } } - if (tabInfo.Entries.size() > 0) + if (!tabInfo.Entries.empty()) { _tabEntries.push_back(std::move(tabInfo)); } @@ -2343,7 +2344,8 @@ namespace OpenRCT2::Ui::Windows { WindowScenerySetSelectedItem( { SCENERY_TYPE_LARGE, entryIndex }, info.Element->AsLargeScenery()->GetPrimaryColour(), - info.Element->AsLargeScenery()->GetSecondaryColour(), std::nullopt, + info.Element->AsLargeScenery()->GetSecondaryColour(), + info.Element->AsLargeScenery()->GetTertiaryColour(), (GetCurrentRotation() + info.Element->GetDirection()) & 3); } break; diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index c9da344f35..4436b7bbd8 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -14,6 +14,7 @@ #include #include #include + #include #include #include #include diff --git a/src/openrct2-ui/windows/Sign.cpp b/src/openrct2-ui/windows/Sign.cpp index 14c077cc1e..470a886fe1 100644 --- a/src/openrct2-ui/windows/Sign.cpp +++ b/src/openrct2-ui/windows/Sign.cpp @@ -16,10 +16,11 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 4dac058b01..d29b20362b 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -18,11 +18,12 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/StaffFirePrompt.cpp b/src/openrct2-ui/windows/StaffFirePrompt.cpp index 9636b1a586..fc4bbdcb36 100644 --- a/src/openrct2-ui/windows/StaffFirePrompt.cpp +++ b/src/openrct2-ui/windows/StaffFirePrompt.cpp @@ -11,7 +11,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index bf77b03266..5222e8d99f 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -20,10 +20,11 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index c434a42b05..f3f4d4082b 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -19,7 +19,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -1848,6 +1849,7 @@ static uint64_t PageDisabledWidgets[] = { windowTileInspectorSelectedIndex = index; } invalidate(); + MapInvalidateTileFull(_toolMap); } void LoadTile(TileElement* elementToSelect) @@ -2150,10 +2152,10 @@ static uint64_t PageDisabledWidgets[] = { && windowTileInspectorSelectedIndex < windowTileInspectorElementCount - 1)); // Move Down button - setWidgetDisabledAndInvalidate(WIDX_BUTTON_MOVE_DOWN, !(windowTileInspectorSelectedIndex > 0)); + setWidgetDisabledAndInvalidate(WIDX_BUTTON_MOVE_DOWN, windowTileInspectorSelectedIndex <= 0); // Copy button - setWidgetDisabledAndInvalidate(WIDX_BUTTON_COPY, !(windowTileInspectorSelectedIndex >= 0)); + setWidgetDisabledAndInvalidate(WIDX_BUTTON_COPY, windowTileInspectorSelectedIndex < 0); // Paste button setWidgetDisabledAndInvalidate(WIDX_BUTTON_PASTE, !(_tileSelected && _elementCopied)); @@ -2362,7 +2364,7 @@ static uint64_t PageDisabledWidgets[] = { widgets[WIDX_ENTRANCE_BUTTON_MAKE_USABLE].bottom = GBBB(propertiesAnchor, 1); setWidgetDisabled( WIDX_ENTRANCE_BUTTON_MAKE_USABLE, - !(tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)); + tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_PARK_ENTRANCE); break; case TileElementType::Wall: diff --git a/src/openrct2-ui/windows/TitleMenu.cpp b/src/openrct2-ui/windows/TitleMenu.cpp index 39a1a51cf8..9d21e1ec54 100644 --- a/src/openrct2-ui/windows/TitleMenu.cpp +++ b/src/openrct2-ui/windows/TitleMenu.cpp @@ -18,7 +18,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 8d15a68c08..d4f40f335f 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -28,9 +28,10 @@ #include #include #include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/TrackDesignPlace.cpp b/src/openrct2-ui/windows/TrackDesignPlace.cpp index 64f8020e0e..8ffb6c43e4 100644 --- a/src/openrct2-ui/windows/TrackDesignPlace.cpp +++ b/src/openrct2-ui/windows/TrackDesignPlace.cpp @@ -19,7 +19,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -373,9 +374,9 @@ namespace OpenRCT2::Ui::Windows g1temp.offset = reinterpret_cast(_miniPreview.data()); g1temp.width = kTrackMiniPreviewSize.width; g1temp.height = kTrackMiniPreviewSize.height; - GfxSetG1Element(SPR_TEMP, &g1temp); - DrawingEngineInvalidateImage(SPR_TEMP); - GfxDrawSprite(clippedRT, ImageId(SPR_TEMP, this->colours[0].colour), { 0, 0 }); + GfxSetG1Element(SPR_TEMP_TRACK_PLACE, &g1temp); + DrawingEngineInvalidateImage(SPR_TEMP_TRACK_PLACE); + GfxDrawSprite(clippedRT, ImageId(SPR_TEMP_TRACK_PLACE, this->colours[0].colour), { 0, 0 }); } // Price diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index a35287a604..0d9e418052 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -83,7 +83,7 @@ namespace OpenRCT2::Ui::Windows std::vector _filteredTrackIds; uint16_t _loadedTrackDesignIndex; std::unique_ptr _loadedTrackDesign; - std::vector _trackDesignPreviewPixels; + TrackDesignPreviewBuffer _trackDesignPreviewPixels{}; bool _selectedItemIsBeingUpdated; bool _reloadTrackDesigns; @@ -123,7 +123,7 @@ namespace OpenRCT2::Ui::Windows void SelectFromList(int32_t listIndex) { Audio::Play(Audio::SoundId::click1, 0, this->windowPos.x + (this->width / 2)); - if (!(gLegacyScene == LegacyScene::trackDesignsManager)) + if (gLegacyScene != LegacyScene::trackDesignsManager) { if (listIndex == 0) { @@ -171,7 +171,7 @@ namespace OpenRCT2::Ui::Windows int32_t GetListItemFromPosition(const ScreenCoordsXY& screenCoords) { size_t maxItems = _filteredTrackIds.size(); - if (!(gLegacyScene == LegacyScene::trackDesignsManager)) + if (gLegacyScene != LegacyScene::trackDesignsManager) { // Extra item: custom design maxItems++; @@ -191,7 +191,7 @@ namespace OpenRCT2::Ui::Windows std::string entryName; if (item.Type < 0x80) { - if (GetRideTypeDescriptor(item.Type).HasFlag(RtdFlag::listVehiclesSeparately)) + if (GetRideTypeDescriptor(item.Type).flags.has(RtdFlag::listVehiclesSeparately)) { entryName = GetRideEntryName(item.EntryIndex); } @@ -206,7 +206,7 @@ namespace OpenRCT2::Ui::Windows _loadedTrackDesign = TrackDesignImport(path.c_str()); if (_loadedTrackDesign != nullptr) { - TrackDesignDrawPreview(*_loadedTrackDesign, _trackDesignPreviewPixels.data(), !gTrackDesignSceneryToggle); + TrackDesignDrawPreview(*_loadedTrackDesign, _trackDesignPreviewPixels, !gTrackDesignSceneryToggle); return true; } return false; @@ -231,14 +231,14 @@ namespace OpenRCT2::Ui::Windows _reloadTrackDesigns = false; // Start with first track highlighted selectedListItem = 0; - if (_trackDesigns.size() != 0 && !(gLegacyScene == LegacyScene::trackDesignsManager)) + if (!_trackDesigns.empty() && gLegacyScene != LegacyScene::trackDesignsManager) { selectedListItem = 1; } gTrackDesignSceneryToggle = false; WindowPushOthersRight(*this); _currentTrackPieceDirection = 2; - _trackDesignPreviewPixels.resize(4 * kTrackPreviewImageSize); + std::fill(_trackDesignPreviewPixels.begin(), _trackDesignPreviewPixels.end(), PaletteIndex::transparent); _loadedTrackDesign = nullptr; _loadedTrackDesignIndex = kTrackDesignIndexUnloaded; @@ -256,8 +256,6 @@ namespace OpenRCT2::Ui::Windows { // Dispose track design and preview _loadedTrackDesign = nullptr; - _trackDesignPreviewPixels.clear(); - _trackDesignPreviewPixels.shrink_to_fit(); // Dispose track list _trackDesigns.clear(); @@ -292,7 +290,7 @@ namespace OpenRCT2::Ui::Windows break; case WIDX_BACK: close(); - if (!(gLegacyScene == LegacyScene::trackDesignsManager)) + if (gLegacyScene != LegacyScene::trackDesignsManager) { ContextOpenWindow(WindowClass::constructRide); } @@ -329,7 +327,7 @@ namespace OpenRCT2::Ui::Windows ScreenSize onScrollGetSize(const int32_t scrollIndex) override { size_t numItems = _filteredTrackIds.size(); - if (!(gLegacyScene == LegacyScene::trackDesignsManager)) + if (gLegacyScene != LegacyScene::trackDesignsManager) { // Extra item: custom design numItems++; @@ -510,19 +508,20 @@ namespace OpenRCT2::Ui::Windows screenPos = windowPos + ScreenCoordsXY{ tdWidget.midX(), tdWidget.midY() }; G1Element g1temp = {}; - g1temp.offset = _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * kTrackPreviewImageSize); + g1temp.offset = reinterpret_cast( + _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * kTrackPreviewImageSize)); g1temp.width = 370; g1temp.height = 217; g1temp.flags = { G1Flag::hasTransparency }; - GfxSetG1Element(SPR_TEMP, &g1temp); - DrawingEngineInvalidateImage(SPR_TEMP); - GfxDrawSprite(rt, ImageId(SPR_TEMP), trackPreview); + GfxSetG1Element(SPR_TEMP_TRACK_LIST, &g1temp); + DrawingEngineInvalidateImage(SPR_TEMP_TRACK_LIST); + GfxDrawSprite(rt, ImageId(SPR_TEMP_TRACK_LIST), trackPreview); screenPos.y = windowPos.y + tdWidget.bottom - 12; // Warnings - if ((_loadedTrackDesign->gameStateData.hasFlag(TrackDesignGameStateFlag::VehicleUnavailable)) - && !(gLegacyScene == LegacyScene::trackDesignsManager)) + if (_loadedTrackDesign->gameStateData.hasFlag(TrackDesignGameStateFlag::VehicleUnavailable) + && gLegacyScene != LegacyScene::trackDesignsManager) { // Vehicle design not available DrawTextEllipsised(rt, screenPos, 368, STR_VEHICLE_DESIGN_UNAVAILABLE, {}, { TextAlignment::centre }); @@ -565,7 +564,7 @@ namespace OpenRCT2::Ui::Windows screenPos.y += kListRowHeight + 4; // Information for tracked rides. - if (GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasTrack)) + if (GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasTrack)) { const auto& rtd = GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex); if (rtd.specialType != RtdSpecialType::maze) @@ -601,7 +600,7 @@ namespace OpenRCT2::Ui::Windows screenPos.y += kListRowHeight; } - if (GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasGForces)) + if (GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasGForces)) { // Maximum positive vertical Gs ft = Formatter(); @@ -631,7 +630,7 @@ namespace OpenRCT2::Ui::Windows } } - if (GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasDrops)) + if (GetRideTypeDescriptor(_loadedTrackDesign->trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasDrops)) { // Drops ft = Formatter(); diff --git a/src/openrct2-ui/windows/Transparency.cpp b/src/openrct2-ui/windows/Transparency.cpp index a852430eb1..a5896d6339 100644 --- a/src/openrct2-ui/windows/Transparency.cpp +++ b/src/openrct2-ui/windows/Transparency.cpp @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/openrct2-ui/windows/Water.cpp b/src/openrct2-ui/windows/Water.cpp index 467fc47128..8adfcf69c1 100644 --- a/src/openrct2-ui/windows/Water.cpp +++ b/src/openrct2-ui/windows/Water.cpp @@ -16,8 +16,9 @@ #include #include #include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/openrct2/AssetPackManager.cpp b/src/openrct2/AssetPackManager.cpp index f1c90edb93..60ba18326f 100644 --- a/src/openrct2/AssetPackManager.cpp +++ b/src/openrct2/AssetPackManager.cpp @@ -153,7 +153,7 @@ namespace OpenRCT2 if (i == csl.size() || csl[i] == ',') { auto el = csl.substr(elStart, i - elStart); - if (el.size() != 0) + if (!el.empty()) func(el); elStart = i + 1; } @@ -204,9 +204,9 @@ namespace OpenRCT2 enabledList.push_back(','); } } - if (orderList.size() > 0) + if (!orderList.empty()) orderList.pop_back(); - if (enabledList.size() > 0) + if (!enabledList.empty()) enabledList.pop_back(); Config::Get().general.assetPackOrder = orderList; Config::Get().general.enabledAssetPacks = enabledList; diff --git a/src/openrct2/CMakeLists.txt b/src/openrct2/CMakeLists.txt index e74c6be4a7..e63299dc73 100644 --- a/src/openrct2/CMakeLists.txt +++ b/src/openrct2/CMakeLists.txt @@ -126,7 +126,6 @@ if (EMSCRIPTEN) set(SHARED_FLAGS "-fexceptions") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${USE_FLAGS} ${SHARED_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EMSCRIPTEN_LDFLAGS} --bind ${SHARED_FLAGS}") - find_package(SpeexDSP REQUIRED) elseif (MSVC) find_package(png 1.6 REQUIRED) find_package(zlib REQUIRED) diff --git a/src/openrct2/Cheats.cpp b/src/openrct2/Cheats.cpp index 24d4890328..2f6595a0a5 100644 --- a/src/openrct2/Cheats.cpp +++ b/src/openrct2/Cheats.cpp @@ -10,8 +10,9 @@ #include "Cheats.h" #include "GameState.h" -#include "actions/CheatSetAction.h" -#include "actions/ParkSetLoanAction.h" +#include "actions/GameActionRunner.h" +#include "actions/cheats/CheatSetAction.h" +#include "actions/park/ParkSetLoanAction.h" #include "core/DataSerialiser.h" #include "network/Network.h" #include "ride/Ride.h" diff --git a/src/openrct2/Context.cpp b/src/openrct2/Context.cpp index d2f915112b..5ddc791fa4 100644 --- a/src/openrct2/Context.cpp +++ b/src/openrct2/Context.cpp @@ -25,7 +25,7 @@ #include "PlatformEnvironment.h" #include "ReplayManager.h" #include "Version.h" -#include "actions/GameAction.h" +#include "actions/GameActionRunner.h" #include "audio/Audio.h" #include "audio/AudioContext.h" #include "config/Config.h" diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 16c695f49f..e7c2f5ea1d 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -16,9 +16,10 @@ #include "GameState.h" #include "OpenRCT2.h" #include "ParkImporter.h" -#include "actions/LandBuyRightsAction.h" -#include "actions/LandSetRightsAction.h" +#include "actions/GameActionRunner.h" #include "actions/ResultWithMessage.h" +#include "actions/park/LandBuyRightsAction.h" +#include "actions/park/LandSetRightsAction.h" #include "audio/Audio.h" #include "core/EnumUtils.hpp" #include "core/Path.hpp" diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 9cc0e26f31..47cfe8473b 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -89,7 +89,7 @@ static void SetupTrackManagerObjects() for (auto rideType : item->RideInfo.RideType) { - if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::hasTrack)) + if (GetRideTypeDescriptor(rideType).flags.has(RtdFlag::hasTrack)) { *selectionFlags &= ~ObjectSelectionFlags::Flag6; break; @@ -120,7 +120,7 @@ static void SetupTrackDesignerObjects() { if (rideType != kRideTypeNull) { - if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::showInTrackDesigner)) + if (GetRideTypeDescriptor(rideType).flags.has(RtdFlag::showInTrackDesigner)) { *selectionFlags &= ~ObjectSelectionFlags::Flag6; break; diff --git a/src/openrct2/EditorObjectSelectionSession.h b/src/openrct2/EditorObjectSelectionSession.h index 2acf3eb918..4a77a91896 100644 --- a/src/openrct2/EditorObjectSelectionSession.h +++ b/src/openrct2/EditorObjectSelectionSession.h @@ -49,7 +49,7 @@ void FinishObjectSelection(); ResultWithMessage WindowEditorObjectSelectionSelectObject( uint8_t isMasterObject, EditorInputFlags flags, const OpenRCT2::ObjectRepositoryItem* item); ResultWithMessage WindowEditorObjectSelectionSelectObject( - uint8_t isMasterObject, EditorInputFlags flags, const OpenRCT2::ObjectEntryDescriptor& entry); + uint8_t isMasterObject, EditorInputFlags flags, const OpenRCT2::ObjectEntryDescriptor& descriptor); /** * Removes all unused objects from the object selection. diff --git a/src/openrct2/FileClassifier.cpp b/src/openrct2/FileClassifier.cpp index a6696c7eb9..a2c5ca8c47 100644 --- a/src/openrct2/FileClassifier.cpp +++ b/src/openrct2/FileClassifier.cpp @@ -220,6 +220,8 @@ FileExtension GetFileExtensionType(u8string_view path) return FileExtension::SV6; if (String::iequals(extension, ".td6")) return FileExtension::TD6; + if (String::iequals(extension, ".td7")) + return FileExtension::TD6; if (String::iequals(extension, ".park")) return FileExtension::PARK; return FileExtension::Unknown; diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 0e4ae7897d..a904b64fe2 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -21,8 +21,9 @@ #include "ParkImporter.h" #include "PlatformEnvironment.h" #include "ReplayManager.h" -#include "actions/GameSetSpeedAction.h" -#include "actions/LoadOrQuitAction.h" +#include "actions/GameActionRunner.h" +#include "actions/general/GameSetSpeedAction.h" +#include "actions/general/LoadOrQuitAction.h" #include "audio/Audio.h" #include "config/Config.h" #include "core/Console.hpp" diff --git a/src/openrct2/Game.h b/src/openrct2/Game.h index 3971cc2e1a..efa45fbe76 100644 --- a/src/openrct2/Game.h +++ b/src/openrct2/Game.h @@ -35,97 +35,6 @@ namespace OpenRCT2 constexpr float kGameMaxTimeScale = 5.0f; } // namespace OpenRCT2 -struct ParkLoadResult; - -enum class GameCommand : int32_t -{ - SetRideAppearance, - SetLandHeight, - TogglePause, - PlaceTrack, - RemoveTrack, - LoadOrQuit, - CreateRide, - DemolishRide, - SetRideStatus, - SetRideVehicles, - SetRideName, - SetRideSetting, - PlaceRideEntranceOrExit, - RemoveRideEntranceOrExit, - RemoveScenery, - PlaceScenery, - SetWaterHeight, - PlacePath, - PlacePathLayout, - RemovePath, - ChangeSurfaceStyle, - SetRidePrice, - SetGuestName, - SetStaffName, - RaiseLand, - LowerLand, - EditLandSmooth, - RaiseWater, - LowerWater, - SetBrakesSpeed, - HireNewStaffMember, - SetStaffPatrol, - FireStaffMember, - SetStaffOrders, - SetParkName, - SetParkOpen, - BuyLandRights, - PlaceParkEntrance, - RemoveParkEntrance, - SetMazeTrack, - SetParkEntranceFee, - SetStaffColour, - PlaceWall, - RemoveWall, - PlaceLargeScenery, - RemoveLargeScenery, - SetCurrentLoan, - SetResearchFunding, - PlaceTrackDesign, - StartMarketingCampaign, - PlaceMazeDesign, - PlaceBanner, - RemoveBanner, - SetSceneryColour, - SetWallColour, - SetLargeSceneryColour, - SetBannerColour, - SetLandOwnership, - ClearScenery, - SetBannerName, - SetSignName, - SetBannerStyle, - SetSignStyle, - SetPlayerGroup, - ModifyGroups, - KickPlayer, - Cheat, - PickupGuest, - PickupStaff, - BalloonPress, - ModifyTile, - EditScenarioOptions, - PlacePeepSpawn, - SetColourScheme, - SetStaffCostume, - PlaceFootpathAddition, - RemoveFootpathAddition, - GuestSetFlags, - SetDate, - Custom, - ChangeMapSize, - FreezeRideRating, - SetGameSpeed, - SetRestrictedScenery, - Count, -}; - enum { GAME_PAUSED_NORMAL = 1 << 0, diff --git a/src/openrct2/GameState.cpp b/src/openrct2/GameState.cpp index 2b96819391..90c0beb3ae 100644 --- a/src/openrct2/GameState.cpp +++ b/src/openrct2/GameState.cpp @@ -14,7 +14,7 @@ #include "Input.h" #include "OpenRCT2.h" #include "ReplayManager.h" -#include "actions/GameAction.h" +#include "actions/GameActionRunner.h" #include "config/Config.h" #include "drawing/Drawing.h" #include "entity/EntityTweener.h" diff --git a/src/openrct2/GameStateSnapshots.cpp b/src/openrct2/GameStateSnapshots.cpp index 50ff237949..05fa8fae40 100644 --- a/src/openrct2/GameStateSnapshots.cpp +++ b/src/openrct2/GameStateSnapshots.cpp @@ -410,7 +410,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Vehicle, next_vehicle_on_ride); COMPARE_FIELD(Vehicle, var_44); COMPARE_FIELD(Vehicle, mass); - COMPARE_FIELD(Vehicle, Flags); + COMPARE_FIELD(Vehicle, flags.holder); COMPARE_FIELD(Vehicle, SwingSprite); COMPARE_FIELD(Vehicle, current_station); COMPARE_FIELD(Vehicle, SwingPosition); @@ -455,7 +455,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots COMPARE_FIELD(Vehicle, vertical_drop_countdown); COMPARE_FIELD(Vehicle, var_D3); COMPARE_FIELD(Vehicle, mini_golf_current_animation); - COMPARE_FIELD(Vehicle, mini_golf_flags); + COMPARE_FIELD(Vehicle, miniGolfFlags.holder); COMPARE_FIELD(Vehicle, ride_subtype); COMPARE_FIELD(Vehicle, seat_rotation); COMPARE_FIELD(Vehicle, target_seat_rotation); @@ -668,7 +668,7 @@ struct GameStateSnapshots final : public IGameStateSnapshots else { CompareSpriteData(spriteBase, spriteCmp, changeData); - if (changeData.diffs.size() == 0) + if (changeData.diffs.empty()) { changeData.changeType = GameStateSpriteChange::EQUAL; } diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index c9e5ce510f..7bc048efb0 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -17,12 +17,12 @@ #include "OpenRCT2.h" #include "ParkImporter.h" #include "PlatformEnvironment.h" -#include "actions/CheatSetAction.h" -#include "actions/FootpathPlaceAction.h" -#include "actions/GameAction.h" -#include "actions/RideEntranceExitPlaceAction.h" -#include "actions/TileModifyAction.h" -#include "actions/TrackPlaceAction.h" +#include "actions/GameActionRunner.h" +#include "actions/cheats/CheatSetAction.h" +#include "actions/footpath/FootpathPlaceAction.h" +#include "actions/general/TileModifyAction.h" +#include "actions/ride/RideEntranceExitPlaceAction.h" +#include "actions/track/TrackPlaceAction.h" #include "config/Config.h" #include "core/Compression.h" #include "core/DataSerialiser.h" diff --git a/src/openrct2/SpriteIds.h b/src/openrct2/SpriteIds.h index 58ec99299d..afd6abff2e 100644 --- a/src/openrct2/SpriteIds.h +++ b/src/openrct2/SpriteIds.h @@ -15,10 +15,21 @@ #include +// Number of temp sprite slots available for dynamic on-demand drawing +constexpr size_t kTempSpriteCount = 5; + enum : ImageIndex { // Used for on-demand drawing of dynamic memory - SPR_TEMP = 0x7FFFE, + // Each window that uses temporary sprites gets its own slot to avoid conflicts + // when multiple windows are open simultaneously (especially in OpenGL mode) + SPR_TEMP_BEGIN = 0x7FFFA, + SPR_TEMP_MAP = SPR_TEMP_BEGIN + 0, // Map.cpp minimap + SPR_TEMP_TRACK_LIST = SPR_TEMP_BEGIN + 1, // TrackList.cpp track design preview + SPR_TEMP_TRACK_PLACE = SPR_TEMP_BEGIN + 2, // TrackDesignPlace.cpp placement preview + SPR_TEMP_PARK_PREVIEW = SPR_TEMP_BEGIN + 3, // ParkPreview.cpp scenario/save preview + SPR_TEMP_INSTALL_TRACK = SPR_TEMP_BEGIN + 4, // InstallTrack.cpp track install preview + SPR_TEMP_END = SPR_TEMP_BEGIN + kTempSpriteCount, // Unused, listed for documentation purposes only SPR_G1_PALETTE_DEFAULT = 1532, @@ -916,20 +927,6 @@ enum : ImageIndex SPR_MENU_LOGO = 23212, SPR_CREDITS_LOGO_SMALL = 23213, SPR_CREDITS_CHRIS_SAWYER_SMALL = 23214, - SPR_INTRO_CHRIS_SAWYER_00 = 23215, - SPR_INTRO_CHRIS_SAWYER_10 = SPR_INTRO_CHRIS_SAWYER_00 + 1, - SPR_INTRO_LOGO_00 = 23218, - SPR_INTRO_LOGO_10 = SPR_INTRO_LOGO_00 + 1, - SPR_INTRO_LOGO_20 = SPR_INTRO_LOGO_00 + 2, - SPR_INTRO_LOGO_01 = SPR_INTRO_LOGO_00 + 3, - SPR_INTRO_LOGO_11 = SPR_INTRO_LOGO_00 + 4, - SPR_INTRO_LOGO_21 = SPR_INTRO_LOGO_00 + 5, - - SPR_INTRO_INFOGRAMES_00 = 23226, - SPR_INTRO_INFOGRAMES_10 = SPR_INTRO_INFOGRAMES_00 + 1, - SPR_INTRO_INFOGRAMES_01 = SPR_INTRO_INFOGRAMES_00 + 2, - SPR_INTRO_INFOGRAMES_11 = SPR_INTRO_INFOGRAMES_00 + 3, - SPR_CREDITS_INFOGRAMES = 23230, SPR_NEW_RIDE_MASK = 29013, diff --git a/src/openrct2/actions/GameAction.cpp b/src/openrct2/actions/GameAction.cpp index e8b1fc77b0..3eb5ac5d1c 100644 --- a/src/openrct2/actions/GameAction.cpp +++ b/src/openrct2/actions/GameAction.cpp @@ -7,469 +7,21 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "GameAction.h" +#include "GameAction.hpp" #include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../ReplayManager.h" #include "../core/Guard.hpp" -#include "../core/Memory.hpp" -#include "../core/MemoryStream.h" -#include "../entity/MoneyEffect.h" -#include "../localisation/Formatter.h" -#include "../network/Network.h" -#include "../platform/Platform.h" -#include "../profiling/Profiling.h" -#include "../scenario/Scenario.h" #include "../scripting/Duktape.hpp" #include "../scripting/HookEngine.h" #include "../scripting/ScriptEngine.h" -#include "../ui/WindowManager.h" #include "../world/Map.h" -#include "../world/Park.h" -#include "../world/Scenery.h" +#include "GameActionRegistry.h" +#include "GameActionRunner.h" #include namespace OpenRCT2::GameActions { - struct QueuedGameAction - { - uint32_t tick; - uint32_t uniqueId; - GameAction::Ptr action; - - explicit QueuedGameAction(uint32_t t, std::unique_ptr&& ga, uint32_t id) - : tick(t) - , uniqueId(id) - , action(std::move(ga)) - { - } - - bool operator<(const QueuedGameAction& comp) const - { - // First sort by tick - if (tick < comp.tick) - return true; - if (tick > comp.tick) - return false; - - // If the ticks are equal sort by commandIndex - return uniqueId < comp.uniqueId; - } - }; - - static std::multiset _actionQueue; - static uint32_t _nextUniqueId = 0; - static bool _suspended = false; - - void SuspendQueue() - { - _suspended = true; - } - - void ResumeQueue() - { - _suspended = false; - } - - void Enqueue(const GameAction* ga, uint32_t tick) - { - auto action = Clone(ga); - Enqueue(std::move(action), tick); - } - - void Enqueue(GameAction::Ptr&& ga, uint32_t tick) - { - if (ga->GetPlayer() == -1 && Network::GetMode() != Network::Mode::none) - { - // Server can directly invoke actions and will have no player id assigned - // as that normally happens when receiving them over network. - ga->SetPlayer(Network::GetCurrentPlayerId()); - } - _actionQueue.emplace(tick, std::move(ga), _nextUniqueId++); - } - - void ProcessQueue(GameState_t& gameState) - { - if (_suspended) - { - // Do nothing if suspended, this is usually the case between connect and map loads. - return; - } - - const uint32_t currentTick = gameState.currentTicks; - - while (_actionQueue.begin() != _actionQueue.end()) - { - // run all the game commands at the current tick - const QueuedGameAction& queued = *_actionQueue.begin(); - - if (Network::GetMode() == Network::Mode::client) - { - if (queued.tick < currentTick) - { - // This should never happen. - Guard::Assert( - false, - "Discarding game action %s (%u) from tick behind current tick, ID: %08X, Action Tick: %08X, Current " - "Tick: " - "%08X\n", - queued.action->GetName(), queued.action->GetType(), queued.uniqueId, queued.tick, currentTick); - } - else if (queued.tick > currentTick) - { - return; - } - } - - // Remove ghost scenery so it doesn't interfere with incoming network command - switch (queued.action->GetType()) - { - case GameCommand::PlaceWall: - case GameCommand::PlaceLargeScenery: - case GameCommand::PlaceBanner: - case GameCommand::PlaceScenery: - SceneryRemoveGhostToolPlacement(); - break; - default: - break; - } - - GameAction* action = queued.action.get(); - action->SetFlags(action->GetFlags().with(CommandFlag::networked)); - - Guard::Assert(action != nullptr); - - Result result = Execute(action, gameState); - if (result.error == Status::ok && Network::GetMode() == Network::Mode::server) - { - // Relay this action to all other clients. - Network::SendGameAction(action); - } - - _actionQueue.erase(_actionQueue.begin()); - } - } - - void ClearQueue() - { - _actionQueue.clear(); - } - - GameAction::Ptr Clone(const GameAction* action) - { - std::unique_ptr ga = Create(action->GetType()); - ga->SetCallback(action->GetCallback()); - - // Serialise action data into stream. - DataSerialiser dsOut(true); - action->Serialise(dsOut); - - // Serialise into new action. - IStream& stream = dsOut.GetStream(); - stream.SetPosition(0); - - DataSerialiser dsIn(false, stream); - ga->Serialise(dsIn); - - return ga; - } - - static bool CheckActionInPausedMode(const GameState_t& gameState, uint32_t actionFlags) - { - if (gGamePaused == 0) - return true; - if (gameState.cheats.buildInPauseMode) - return true; - if (actionFlags & Flags::AllowWhilePaused) - return true; - return false; - } - - static Result QueryInternal(const GameAction* action, GameState_t& gameState, bool topLevel) - { - Guard::ArgumentNotNull(action); - - uint16_t actionFlags = action->GetActionFlags(); - if (topLevel && !CheckActionInPausedMode(gameState, actionFlags)) - { - Result result = Result(); - - result.error = Status::gamePaused; - result.errorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; - result.errorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - - return result; - } - - auto result = action->Query(gameState); - - if (result.error == Status::ok) - { - if (!FinanceCheckAffordability(result.cost, action->GetFlags())) - { - result.error = Status::insufficientFunds; - result.errorTitle = STR_CANT_DO_THIS; - result.errorMessage = STR_NOT_ENOUGH_CASH_REQUIRES; - Formatter(result.errorMessageArgs.data()).Add(result.cost); - } - } - return result; - } - - Result Query(const GameAction* action, GameState_t& gameState) - { - return QueryInternal(action, gameState, true); - } - - Result QueryNested(const GameAction* action, GameState_t& gameState) - { - return QueryInternal(action, gameState, false); - } - - static const char* GetRealm() - { - if (Network::GetMode() == Network::Mode::client) - return "cl"; - if (Network::GetMode() == Network::Mode::server) - return "sv"; - return "sp"; - } - - struct ActionLogContext - { - MemoryStream output; - }; - - static void LogActionBegin(const GameState_t& gameState, ActionLogContext& ctx, const GameAction* action) - { - MemoryStream& output = ctx.output; - - char temp[128] = {}; - snprintf( - temp, sizeof(temp), "[%s] Tick: %u, GA: %s (%08X) (", GetRealm(), gameState.currentTicks, action->GetName(), - EnumValue(action->GetType())); - - output.Write(temp, strlen(temp)); - - DataSerialiser ds(true, ctx.output, true); // Logging mode. - - // Write all parameters into output as text. - action->Serialise(ds); - } - - static void LogActionFinish(ActionLogContext& ctx, const GameAction* action, const Result& result) - { - MemoryStream& output = ctx.output; - - char temp[128] = {}; - - if (result.error != Status::ok) - { - snprintf(temp, sizeof(temp), ") Failed, %u", static_cast(result.error)); - } - else - { - snprintf(temp, sizeof(temp), ") OK"); - } - - output.Write(temp, strlen(temp) + 1); - - const char* text = static_cast(output.GetData()); - LOG_VERBOSE("%s", text); - - Network::AppendServerLog(text); - } - - static Result ExecuteInternal(const GameAction* action, GameState_t& gameState, bool topLevel) - { - Guard::ArgumentNotNull(action); - - uint16_t actionFlags = action->GetActionFlags(); - auto flags = action->GetFlags(); - - // Some actions are not recorded in the replay. - const auto ignoreForReplays = (actionFlags & Flags::IgnoreForReplays) != 0; - - auto* replayManager = GetContext()->GetReplayManager(); - if (replayManager != nullptr && (replayManager->IsReplaying() || replayManager->IsNormalising())) - { - // We only accept replay commands as long the replay is active. - if (!flags.has(CommandFlag::replay) && !ignoreForReplays) - { - // TODO: Introduce proper error. - auto result = Result(); - result.error = Status::gamePaused; - result.errorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; - result.errorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; - - return result; - } - } - - Result result = QueryInternal(action, gameState, topLevel); -#ifdef ENABLE_SCRIPTING - if (result.error == Status::ok && ((Network::GetMode() == Network::Mode::none) || flags.has(CommandFlag::networked))) - { - auto& scriptEngine = GetContext()->GetScriptEngine(); - scriptEngine.RunGameActionHooks(*action, result, false); - // Script hooks may now have changed the game action result... - } -#endif - if (result.error == Status::ok) - { - if (topLevel) - { - // Networked games send actions to the server to be run - if (Network::GetMode() == Network::Mode::client) - { - // As a client we have to wait or send it first. - if (!(actionFlags & Flags::ClientOnly) && !flags.has(CommandFlag::networked)) - { - LOG_VERBOSE("[%s] GameAction::Execute %s (Out)", GetRealm(), action->GetName()); - Network::SendGameAction(action); - - return result; - } - } - else if (Network::GetMode() == Network::Mode::server || !gInUpdateCode) - { - // If player is the server it would execute right away as where clients execute the commands - // at the beginning of the frame, so we have to put them into the queue. - // This is also the case when its executed from the UI update. - if (!(actionFlags & Flags::ClientOnly) && !flags.has(CommandFlag::networked)) - { - LOG_VERBOSE("[%s] GameAction::Execute %s (Queue)", GetRealm(), action->GetName()); - Enqueue(action, gameState.currentTicks); - - return result; - } - } - } - - ActionLogContext logContext; - if (topLevel && !flags.has(CommandFlag::ghost)) - { - LogActionBegin(gameState, logContext, action); - } - - // Execute the action, changing the game state - result = action->Execute(gameState); -#ifdef ENABLE_SCRIPTING - if (result.error == Status::ok) - { - auto& scriptEngine = GetContext()->GetScriptEngine(); - scriptEngine.RunGameActionHooks(*action, result, true); - // Script hooks may now have changed the game action result... - } -#endif - if (topLevel && !flags.has(CommandFlag::ghost)) - { - LogActionFinish(logContext, action, result); - } - - // If not top level just give away the result. - if (!topLevel) - return result; - - // Update money balance - if (result.error == Status::ok && FinanceCheckMoneyRequired(flags) && result.cost != 0) - { - FinancePayment(result.cost, result.expenditure); - MoneyEffect::Create(result.cost, result.position); - } - - if (!(actionFlags & Flags::ClientOnly) && result.error == Status::ok) - { - if (Network::GetMode() != Network::Mode::none) - { - Network::PlayerId_t playerId = action->GetPlayer(); - - int32_t playerIndex = Network::GetPlayerIndex(playerId.id); - Guard::Assert( - playerIndex != -1, "Unable to find player %u for game action %u", playerId, action->GetType()); - - Network::SetPlayerLastAction(playerIndex, action->GetType()); - Network::IncrementPlayerNumCommands(playerIndex); - if (result.cost > 0) - { - Network::AddPlayerMoneySpent(playerIndex, result.cost); - } - - if (!result.position.IsNull()) - { - Network::SetPlayerLastActionCoord(playerIndex, result.position); - } - } - else - { - bool commandExecutes = !flags.hasAny(CommandFlag::ghost, CommandFlag::noSpend); - - bool recordAction = false; - if (replayManager != nullptr && !ignoreForReplays) - { - if (replayManager->IsRecording() && commandExecutes) - recordAction = true; - else if (replayManager->IsNormalising() && flags.has(CommandFlag::replay)) - recordAction = true; // In normalisation we only feed back actions issued by the replay manager. - } - if (recordAction) - { - replayManager->AddGameAction(gameState.currentTicks, action); - } - } - } - - // Allow autosave to commence - if (gLastAutoSaveUpdate == kAutosavePause) - { - gLastAutoSaveUpdate = Platform::GetTicks(); - } - } - - // Call callback for asynchronous events - auto cb = action->GetCallback(); - if (cb != nullptr) - { - cb(action, &result); - } - - // Only show errors when its not a ghost and not a preview and also top level action. - bool shouldShowError = !flags.has(CommandFlag::ghost) && !flags.has(CommandFlag::noSpend) && topLevel; - - // In network mode the error should be only shown to the issuer of the action. - if (Network::GetMode() != Network::Mode::none) - { - // If the action was never networked and query fails locally the player id is not assigned. - // So compare only if the action went into the queue otherwise show errors by default. - const bool isActionFromNetwork = action->GetFlags().has(CommandFlag::networked); - if (isActionFromNetwork && action->GetPlayer() != Network::GetCurrentPlayerId()) - { - shouldShowError = false; - } - } - - if (result.error != Status::ok && shouldShowError) - { - auto windowManager = Ui::GetWindowManager(); - windowManager->ShowError(result.getErrorTitle(), result.getErrorMessage()); - } - - return result; - } - - Result Execute(const GameAction* action, GameState_t& gameState) - { - return ExecuteInternal(action, gameState, true); - } - - Result ExecuteNested(const GameAction* action, GameState_t& gameState) - { - return ExecuteInternal(action, gameState, false); - } - const char* GameAction::GetName() const { return GameActions::GetName(_type); @@ -508,4 +60,38 @@ namespace OpenRCT2::GameActions #endif return true; } + + GameAction::Ptr Create(GameCommand id) + { + GameAction* result = nullptr; + + auto factory = getFactory(id); + if (factory.has_value()) + { + result = (*factory)(); + } + + Guard::ArgumentNotNull(result, "Attempting to create unregistered game action: %u", id); + return std::unique_ptr(result); + } + + GameAction::Ptr Clone(const GameAction* action) + { + std::unique_ptr ga = Create(action->GetType()); + ga->SetCallback(action->GetCallback()); + + // Serialise action data into stream. + DataSerialiser dsOut(true); + action->Serialise(dsOut); + + // Serialise into new action. + IStream& stream = dsOut.GetStream(); + stream.SetPosition(0); + + DataSerialiser dsIn(false, stream); + ga->Serialise(dsIn); + + return ga; + } + } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.hpp similarity index 62% rename from src/openrct2/actions/GameAction.h rename to src/openrct2/actions/GameAction.hpp index 3eb4f9c62c..c91e5c64a0 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.hpp @@ -9,10 +9,11 @@ #pragma once -#include "../Game.h" #include "../core/DataSerialiser.h" #include "../core/Identifier.hpp" +#include "GameActionParameterVisitor.h" #include "GameActionResult.h" +#include "GameCommand.h" #include #include @@ -39,76 +40,6 @@ namespace OpenRCT2::GameActions #pragma GCC diagnostic ignored "-Wsuggest-final-types" #endif - class GameActionParameterVisitor - { - public: - virtual ~GameActionParameterVisitor() = default; - - virtual void Visit(std::string_view name, bool& param) - { - } - - virtual void Visit(std::string_view name, int32_t& param) - { - } - - virtual void Visit(std::string_view name, std::string& param) - { - } - - void Visit(CoordsXY& param) - { - Visit("x", param.x); - Visit("y", param.y); - } - - void Visit(CoordsXYZ& param) - { - Visit("x", param.x); - Visit("y", param.y); - Visit("z", param.z); - } - - void Visit(CoordsXYZD& param) - { - Visit("x", param.x); - Visit("y", param.y); - Visit("z", param.z); - Visit("direction", param.direction); - } - - void Visit(MapRange& param) - { - Visit("x1", param.Point1.x); - Visit("y1", param.Point1.y); - Visit("x2", param.Point2.x); - Visit("y2", param.Point2.y); - } - - template - void Visit(std::string_view name, T& param) - { - static_assert(std::is_arithmetic_v || std::is_enum_v, "Not an arithmetic type"); - auto value = static_cast(param); - Visit(name, value); - param = static_cast(value); - } - - template - void Visit(std::string_view name, TIdentifier& param) - { - auto value = param.ToUnderlying(); - Visit(name, value); - param = TIdentifier::FromUnderlying(value); - } - - template - void Visit(std::string_view name, Network::NetworkObjectId& param) - { - Visit(name, param.id); - } - }; - class GameAction { public: @@ -245,11 +176,6 @@ namespace OpenRCT2::GameActions #pragma GCC diagnostic pop #endif - template - struct GameActionNameQuery - { - }; - template struct GameActionBase : GameAction { @@ -262,33 +188,7 @@ namespace OpenRCT2::GameActions } }; - using GameActionFactory = GameAction* (*)(); - - bool IsValidId(uint32_t id); - const char* GetName(GameCommand id); - - // Halts the queue processing until ResumeQueue is called, any calls to ProcessQueue - // will have no effect during suspension. It has no effect of actions that will not - // cross the network. - void SuspendQueue(); - - // Resumes queue processing. - void ResumeQueue(); - - void Enqueue(const GameAction* ga, uint32_t tick); - void Enqueue(GameAction::Ptr&& ga, uint32_t tick); - void ProcessQueue(GameState_t& gameState); - void ClearQueue(); - GameAction::Ptr Create(GameCommand id); GameAction::Ptr Clone(const GameAction* action); - // This should be used if a round trip is to be expected. - Result Query(const GameAction* action, GameState_t& gameState); - Result Execute(const GameAction* action, GameState_t& gameState); - - // This should be used from within game actions. - Result QueryNested(const GameAction* action, GameState_t& gameState); - Result ExecuteNested(const GameAction* action, GameState_t& gameState); - } // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameActionParameterVisitor.h b/src/openrct2/actions/GameActionParameterVisitor.h new file mode 100644 index 0000000000..2959a72904 --- /dev/null +++ b/src/openrct2/actions/GameActionParameterVisitor.h @@ -0,0 +1,102 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../core/Identifier.hpp" +#include "../network/NetworkTypes.h" +#include "../world/Location.hpp" + +#include +#include + +namespace OpenRCT2::GameActions +{ + // GCC 15.1 is overzealous with its 'final' warnings +#ifdef __WARN_SUGGEST_FINAL_METHODS__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsuggest-final-methods" + #pragma GCC diagnostic ignored "-Wsuggest-final-types" +#endif + + class GameActionParameterVisitor + { + public: + virtual ~GameActionParameterVisitor() = default; + + virtual void Visit(std::string_view name, bool& param) + { + } + + virtual void Visit(std::string_view name, int32_t& param) + { + } + + virtual void Visit(std::string_view name, std::string& param) + { + } + + void Visit(CoordsXY& param) + { + Visit("x", param.x); + Visit("y", param.y); + } + + void Visit(CoordsXYZ& param) + { + Visit("x", param.x); + Visit("y", param.y); + Visit("z", param.z); + } + + void Visit(CoordsXYZD& param) + { + Visit("x", param.x); + Visit("y", param.y); + Visit("z", param.z); + Visit("direction", param.direction); + } + + void Visit(MapRange& param) + { + Visit("x1", param.Point1.x); + Visit("y1", param.Point1.y); + Visit("x2", param.Point2.x); + Visit("y2", param.Point2.y); + } + + template + void Visit(std::string_view name, T& param) + { + static_assert(std::is_arithmetic_v || std::is_enum_v, "Not an arithmetic type"); + auto value = static_cast(param); + Visit(name, value); + param = static_cast(value); + } + + template + void Visit(std::string_view name, TIdentifier& param) + { + auto value = param.ToUnderlying(); + Visit(name, value); + param = TIdentifier::FromUnderlying(value); + } + + template + void Visit(std::string_view name, Network::NetworkObjectId& param) + { + Visit(name, param.id); + } + }; + +#ifdef __WARN_SUGGEST_FINAL_METHODS__ + #pragma GCC diagnostic pop +#endif + +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameActionRegistry.cpp b/src/openrct2/actions/GameActionRegistry.cpp index 9d8a2bd15c..34fc696c6c 100644 --- a/src/openrct2/actions/GameActionRegistry.cpp +++ b/src/openrct2/actions/GameActionRegistry.cpp @@ -7,91 +7,93 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include "GameActionRegistry.h" + #include "../core/Guard.hpp" -#include "BalloonPressAction.h" -#include "BannerPlaceAction.h" -#include "BannerRemoveAction.h" -#include "BannerSetColourAction.h" -#include "BannerSetNameAction.h" -#include "BannerSetStyleAction.h" -#include "CheatSetAction.h" -#include "ClearAction.h" -#include "CustomAction.h" -#include "FootpathAdditionPlaceAction.h" -#include "FootpathAdditionRemoveAction.h" -#include "FootpathLayoutPlaceAction.h" -#include "FootpathPlaceAction.h" -#include "FootpathRemoveAction.h" -#include "GameAction.h" -#include "GameSetSpeedAction.h" -#include "GuestSetFlagsAction.h" -#include "GuestSetNameAction.h" -#include "LandBuyRightsAction.h" -#include "LandLowerAction.h" -#include "LandRaiseAction.h" -#include "LandSetHeightAction.h" -#include "LandSetRightsAction.h" -#include "LandSmoothAction.h" -#include "LargeSceneryPlaceAction.h" -#include "LargeSceneryRemoveAction.h" -#include "LargeScenerySetColourAction.h" -#include "LoadOrQuitAction.h" -#include "MapChangeSizeAction.h" -#include "MazePlaceTrackAction.h" -#include "MazeSetTrackAction.h" -#include "NetworkModifyGroupAction.h" -#include "ParkEntrancePlaceAction.h" -#include "ParkEntranceRemoveAction.h" -#include "ParkMarketingAction.h" -#include "ParkSetDateAction.h" -#include "ParkSetEntranceFeeAction.h" -#include "ParkSetLoanAction.h" -#include "ParkSetNameAction.h" -#include "ParkSetParameterAction.h" -#include "ParkSetResearchFundingAction.h" -#include "PauseToggleAction.h" -#include "PeepPickupAction.h" -#include "PeepSpawnPlaceAction.h" -#include "PlayerKickAction.h" -#include "PlayerSetGroupAction.h" -#include "RideCreateAction.h" -#include "RideDemolishAction.h" -#include "RideEntranceExitPlaceAction.h" -#include "RideEntranceExitRemoveAction.h" -#include "RideFreezeRatingAction.h" -#include "RideSetAppearanceAction.h" -#include "RideSetColourSchemeAction.h" -#include "RideSetNameAction.h" -#include "RideSetPriceAction.h" -#include "RideSetSettingAction.h" -#include "RideSetStatusAction.h" -#include "RideSetVehicleAction.h" -#include "ScenarioSetSettingAction.h" -#include "ScenerySetRestrictedAction.h" -#include "SignSetNameAction.h" -#include "SignSetStyleAction.h" -#include "SmallSceneryPlaceAction.h" -#include "SmallSceneryRemoveAction.h" -#include "SmallScenerySetColourAction.h" -#include "StaffFireAction.h" -#include "StaffHireNewAction.h" -#include "StaffSetColourAction.h" -#include "StaffSetCostumeAction.h" -#include "StaffSetNameAction.h" -#include "StaffSetOrdersAction.h" -#include "StaffSetPatrolAreaAction.h" -#include "SurfaceSetStyleAction.h" -#include "TileModifyAction.h" -#include "TrackDesignAction.h" -#include "TrackPlaceAction.h" -#include "TrackRemoveAction.h" -#include "TrackSetBrakeSpeedAction.h" -#include "WallPlaceAction.h" -#include "WallRemoveAction.h" -#include "WallSetColourAction.h" -#include "WaterLowerAction.h" -#include "WaterRaiseAction.h" -#include "WaterSetHeightAction.h" +#include "cheats/CheatSetAction.h" +#include "footpath/FootpathAdditionPlaceAction.h" +#include "footpath/FootpathAdditionRemoveAction.h" +#include "footpath/FootpathLayoutPlaceAction.h" +#include "footpath/FootpathPlaceAction.h" +#include "footpath/FootpathRemoveAction.h" +#include "general/BalloonPressAction.h" +#include "general/CustomAction.h" +#include "general/GameSetSpeedAction.h" +#include "general/LoadOrQuitAction.h" +#include "general/MapChangeSizeAction.h" +#include "general/PauseToggleAction.h" +#include "general/ScenarioSetSettingAction.h" +#include "general/TileModifyAction.h" +#include "network/NetworkModifyGroupAction.h" +#include "network/PlayerKickAction.h" +#include "network/PlayerSetGroupAction.h" +#include "park/LandBuyRightsAction.h" +#include "park/LandSetRightsAction.h" +#include "park/ParkEntrancePlaceAction.h" +#include "park/ParkEntranceRemoveAction.h" +#include "park/ParkMarketingAction.h" +#include "park/ParkSetDateAction.h" +#include "park/ParkSetEntranceFeeAction.h" +#include "park/ParkSetLoanAction.h" +#include "park/ParkSetNameAction.h" +#include "park/ParkSetParameterAction.h" +#include "park/ParkSetResearchFundingAction.h" +#include "peep/GuestSetFlagsAction.h" +#include "peep/GuestSetNameAction.h" +#include "peep/PeepPickupAction.h" +#include "peep/PeepSpawnPlaceAction.h" +#include "peep/StaffFireAction.h" +#include "peep/StaffHireNewAction.h" +#include "peep/StaffSetColourAction.h" +#include "peep/StaffSetCostumeAction.h" +#include "peep/StaffSetNameAction.h" +#include "peep/StaffSetOrdersAction.h" +#include "peep/StaffSetPatrolAreaAction.h" +#include "ride/MazePlaceTrackAction.h" +#include "ride/MazeSetTrackAction.h" +#include "ride/RideCreateAction.h" +#include "ride/RideDemolishAction.h" +#include "ride/RideEntranceExitPlaceAction.h" +#include "ride/RideEntranceExitRemoveAction.h" +#include "ride/RideFreezeRatingAction.h" +#include "ride/RideSetAppearanceAction.h" +#include "ride/RideSetColourSchemeAction.h" +#include "ride/RideSetNameAction.h" +#include "ride/RideSetPriceAction.h" +#include "ride/RideSetSettingAction.h" +#include "ride/RideSetStatusAction.h" +#include "ride/RideSetVehicleAction.h" +#include "ride/RideSetVisibilityAction.h" +#include "scenery/BannerPlaceAction.h" +#include "scenery/BannerRemoveAction.h" +#include "scenery/BannerSetColourAction.h" +#include "scenery/BannerSetNameAction.h" +#include "scenery/BannerSetStyleAction.h" +#include "scenery/LargeSceneryPlaceAction.h" +#include "scenery/LargeSceneryRemoveAction.h" +#include "scenery/LargeScenerySetColourAction.h" +#include "scenery/ScenerySetRestrictedAction.h" +#include "scenery/SignSetNameAction.h" +#include "scenery/SignSetStyleAction.h" +#include "scenery/SmallSceneryPlaceAction.h" +#include "scenery/SmallSceneryRemoveAction.h" +#include "scenery/SmallScenerySetColourAction.h" +#include "scenery/WallPlaceAction.h" +#include "scenery/WallRemoveAction.h" +#include "scenery/WallSetColourAction.h" +#include "terraform/ClearAction.h" +#include "terraform/LandLowerAction.h" +#include "terraform/LandRaiseAction.h" +#include "terraform/LandSetHeightAction.h" +#include "terraform/LandSmoothAction.h" +#include "terraform/SurfaceSetStyleAction.h" +#include "terraform/WaterLowerAction.h" +#include "terraform/WaterRaiseAction.h" +#include "terraform/WaterSetHeightAction.h" +#include "track/TrackDesignAction.h" +#include "track/TrackPlaceAction.h" +#include "track/TrackRemoveAction.h" +#include "track/TrackSetBrakeSpeedAction.h" #include @@ -210,6 +212,7 @@ namespace OpenRCT2::GameActions REGISTER_ACTION(MapChangeSizeAction); REGISTER_ACTION(GameSetSpeedAction); REGISTER_ACTION(ScenerySetRestrictedAction); + REGISTER_ACTION(RideSetVisibilityAction); #ifdef ENABLE_SCRIPTING REGISTER_ACTION(CustomAction); #endif @@ -221,6 +224,16 @@ namespace OpenRCT2::GameActions static constexpr GameActionRegistry _registry = BuildRegistry(); + std::optional getFactory(GameCommand id) + { + const auto idx = static_cast(id); + if (idx < std::size(_registry)) + { + return _registry[idx].factory; + } + return std::nullopt; + } + const char* GetName(GameCommand id) { const auto idx = static_cast(id); @@ -229,23 +242,6 @@ namespace OpenRCT2::GameActions return _registry[idx].name; } - std::unique_ptr Create(GameCommand id) - { - const auto idx = static_cast(id); - - GameAction* result = nullptr; - if (idx < std::size(_registry)) - { - GameActionFactory factory = _registry[idx].factory; - if (factory != nullptr) - { - result = factory(); - } - } - Guard::ArgumentNotNull(result, "Attempting to create unregistered game action: %u", id); - return std::unique_ptr(result); - } - bool IsValidId(uint32_t id) { if (id < std::size(_registry)) diff --git a/src/openrct2/actions/GameActionRegistry.h b/src/openrct2/actions/GameActionRegistry.h new file mode 100644 index 0000000000..f620eb46c1 --- /dev/null +++ b/src/openrct2/actions/GameActionRegistry.h @@ -0,0 +1,30 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include +#include + +namespace OpenRCT2 +{ + enum class GameCommand : int32_t; +} + +namespace OpenRCT2::GameActions +{ + class GameAction; + + using GameActionFactory = GameAction* (*)(); + + std::optional getFactory(GameCommand command); + const char* GetName(GameCommand id); + bool IsValidId(uint32_t id); + +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameActionRunner.cpp b/src/openrct2/actions/GameActionRunner.cpp new file mode 100644 index 0000000000..1ac05000ac --- /dev/null +++ b/src/openrct2/actions/GameActionRunner.cpp @@ -0,0 +1,456 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "GameActionRunner.h" + +#include "../Context.h" +#include "../Diagnostic.h" +#include "../Game.h" +#include "../GameState.h" +#include "../ReplayManager.h" +#include "../core/Guard.hpp" +#include "../core/Memory.hpp" +#include "../core/MemoryStream.h" +#include "../entity/MoneyEffect.h" +#include "../localisation/Formatter.h" +#include "../network/Network.h" +#include "../platform/Platform.h" +#include "../profiling/Profiling.h" +#include "../scenario/Scenario.h" +#include "../scripting/Duktape.hpp" +#include "../scripting/HookEngine.h" +#include "../scripting/ScriptEngine.h" +#include "../ui/WindowManager.h" +#include "../world/Map.h" +#include "../world/Park.h" +#include "../world/Scenery.h" +#include "GameActionRegistry.h" + +#include + +namespace OpenRCT2::GameActions +{ + struct QueuedGameAction + { + uint32_t tick; + uint32_t uniqueId; + GameAction::Ptr action; + + explicit QueuedGameAction(uint32_t t, std::unique_ptr&& ga, uint32_t id) + : tick(t) + , uniqueId(id) + , action(std::move(ga)) + { + } + + bool operator<(const QueuedGameAction& comp) const + { + // First sort by tick + if (tick < comp.tick) + return true; + if (tick > comp.tick) + return false; + + // If the ticks are equal sort by commandIndex + return uniqueId < comp.uniqueId; + } + }; + + static std::multiset _actionQueue; + static uint32_t _nextUniqueId = 0; + static bool _suspended = false; + + void SuspendQueue() + { + _suspended = true; + } + + void ResumeQueue() + { + _suspended = false; + } + + void Enqueue(const GameAction* ga, uint32_t tick) + { + auto action = Clone(ga); + Enqueue(std::move(action), tick); + } + + void Enqueue(GameAction::Ptr&& ga, uint32_t tick) + { + if (ga->GetPlayer() == -1 && Network::GetMode() != Network::Mode::none) + { + // Server can directly invoke actions and will have no player id assigned + // as that normally happens when receiving them over network. + ga->SetPlayer(Network::GetCurrentPlayerId()); + } + _actionQueue.emplace(tick, std::move(ga), _nextUniqueId++); + } + + void ProcessQueue(GameState_t& gameState) + { + if (_suspended) + { + // Do nothing if suspended, this is usually the case between connect and map loads. + return; + } + + const uint32_t currentTick = gameState.currentTicks; + + while (_actionQueue.begin() != _actionQueue.end()) + { + // run all the game commands at the current tick + const QueuedGameAction& queued = *_actionQueue.begin(); + + if (Network::GetMode() == Network::Mode::client) + { + if (queued.tick < currentTick) + { + // This should never happen. + Guard::Assert( + false, + "Discarding game action %s (%u) from tick behind current tick, ID: %08X, Action Tick: %08X, Current " + "Tick: " + "%08X\n", + queued.action->GetName(), queued.action->GetType(), queued.uniqueId, queued.tick, currentTick); + } + else if (queued.tick > currentTick) + { + return; + } + } + + // Remove ghost scenery so it doesn't interfere with incoming network command + switch (queued.action->GetType()) + { + case GameCommand::PlaceWall: + case GameCommand::PlaceLargeScenery: + case GameCommand::PlaceBanner: + case GameCommand::PlaceScenery: + SceneryRemoveGhostToolPlacement(); + break; + default: + break; + } + + GameAction* action = queued.action.get(); + action->SetFlags(action->GetFlags().with(CommandFlag::networked)); + + Guard::Assert(action != nullptr); + + Result result = Execute(action, gameState); + if (result.error == Status::ok && Network::GetMode() == Network::Mode::server) + { + // Relay this action to all other clients. + Network::SendGameAction(action); + } + + _actionQueue.erase(_actionQueue.begin()); + } + } + + void ClearQueue() + { + _actionQueue.clear(); + } + + static bool CheckActionInPausedMode(const GameState_t& gameState, uint32_t actionFlags) + { + if (gGamePaused == 0) + return true; + if (gameState.cheats.buildInPauseMode) + return true; + if (actionFlags & Flags::AllowWhilePaused) + return true; + return false; + } + + static Result QueryInternal(const GameAction* action, GameState_t& gameState, bool topLevel) + { + Guard::ArgumentNotNull(action); + + uint16_t actionFlags = action->GetActionFlags(); + if (topLevel && !CheckActionInPausedMode(gameState, actionFlags)) + { + Result result = Result(); + + result.error = Status::gamePaused; + result.errorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; + result.errorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + + return result; + } + + auto result = action->Query(gameState); + + if (result.error == Status::ok) + { + if (!FinanceCheckAffordability(result.cost, action->GetFlags())) + { + result.error = Status::insufficientFunds; + result.errorTitle = STR_CANT_DO_THIS; + result.errorMessage = STR_NOT_ENOUGH_CASH_REQUIRES; + Formatter(result.errorMessageArgs.data()).Add(result.cost); + } + } + return result; + } + + Result Query(const GameAction* action, GameState_t& gameState) + { + return QueryInternal(action, gameState, true); + } + + Result QueryNested(const GameAction* action, GameState_t& gameState) + { + return QueryInternal(action, gameState, false); + } + + static const char* GetRealm() + { + if (Network::GetMode() == Network::Mode::client) + return "cl"; + if (Network::GetMode() == Network::Mode::server) + return "sv"; + return "sp"; + } + + struct ActionLogContext + { + MemoryStream output; + }; + + static void LogActionBegin(const GameState_t& gameState, ActionLogContext& ctx, const GameAction* action) + { + MemoryStream& output = ctx.output; + + char temp[128] = {}; + snprintf( + temp, sizeof(temp), "[%s] Tick: %u, GA: %s (%08X) (", GetRealm(), gameState.currentTicks, action->GetName(), + EnumValue(action->GetType())); + + output.Write(temp, strlen(temp)); + + DataSerialiser ds(true, ctx.output, true); // Logging mode. + + // Write all parameters into output as text. + action->Serialise(ds); + } + + static void LogActionFinish(ActionLogContext& ctx, const GameAction* action, const Result& result) + { + MemoryStream& output = ctx.output; + + char temp[128] = {}; + + if (result.error != Status::ok) + { + snprintf(temp, sizeof(temp), ") Failed, %u", static_cast(result.error)); + } + else + { + snprintf(temp, sizeof(temp), ") OK"); + } + + output.Write(temp, strlen(temp) + 1); + + const char* text = static_cast(output.GetData()); + LOG_VERBOSE("%s", text); + + Network::AppendServerLog(text); + } + + static Result ExecuteInternal(const GameAction* action, GameState_t& gameState, bool topLevel) + { + Guard::ArgumentNotNull(action); + + uint16_t actionFlags = action->GetActionFlags(); + auto flags = action->GetFlags(); + + // Some actions are not recorded in the replay. + const auto ignoreForReplays = (actionFlags & Flags::IgnoreForReplays) != 0; + + auto* replayManager = GetContext()->GetReplayManager(); + if (replayManager != nullptr && (replayManager->IsReplaying() || replayManager->IsNormalising())) + { + // We only accept replay commands as long the replay is active. + if (!flags.has(CommandFlag::replay) && !ignoreForReplays) + { + // TODO: Introduce proper error. + auto result = Result(); + result.error = Status::gamePaused; + result.errorTitle = STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE; + result.errorMessage = STR_CONSTRUCTION_NOT_POSSIBLE_WHILE_GAME_IS_PAUSED; + + return result; + } + } + + Result result = QueryInternal(action, gameState, topLevel); +#ifdef ENABLE_SCRIPTING + if (result.error == Status::ok && ((Network::GetMode() == Network::Mode::none) || flags.has(CommandFlag::networked))) + { + auto& scriptEngine = GetContext()->GetScriptEngine(); + scriptEngine.RunGameActionHooks(*action, result, false); + // Script hooks may now have changed the game action result... + } +#endif + if (result.error == Status::ok) + { + if (topLevel) + { + // Networked games send actions to the server to be run + if (Network::GetMode() == Network::Mode::client) + { + // As a client we have to wait or send it first. + if (!(actionFlags & Flags::ClientOnly) && !flags.has(CommandFlag::networked)) + { + LOG_VERBOSE("[%s] GameAction::Execute %s (Out)", GetRealm(), action->GetName()); + Network::SendGameAction(action); + + return result; + } + } + else if (Network::GetMode() == Network::Mode::server || !gInUpdateCode) + { + // If player is the server it would execute right away as where clients execute the commands + // at the beginning of the frame, so we have to put them into the queue. + // This is also the case when its executed from the UI update. + if (!(actionFlags & Flags::ClientOnly) && !flags.has(CommandFlag::networked)) + { + LOG_VERBOSE("[%s] GameAction::Execute %s (Queue)", GetRealm(), action->GetName()); + Enqueue(action, gameState.currentTicks); + + return result; + } + } + } + + ActionLogContext logContext; + if (topLevel && !flags.has(CommandFlag::ghost)) + { + LogActionBegin(gameState, logContext, action); + } + + // Execute the action, changing the game state + result = action->Execute(gameState); +#ifdef ENABLE_SCRIPTING + if (result.error == Status::ok) + { + auto& scriptEngine = GetContext()->GetScriptEngine(); + scriptEngine.RunGameActionHooks(*action, result, true); + // Script hooks may now have changed the game action result... + } +#endif + if (topLevel && !flags.has(CommandFlag::ghost)) + { + LogActionFinish(logContext, action, result); + } + + // If not top level just give away the result. + if (!topLevel) + return result; + + // Update money balance + if (result.error == Status::ok && FinanceCheckMoneyRequired(flags) && result.cost != 0) + { + FinancePayment(result.cost, result.expenditure); + MoneyEffect::Create(result.cost, result.position); + } + + if (!(actionFlags & Flags::ClientOnly) && result.error == Status::ok) + { + if (Network::GetMode() != Network::Mode::none) + { + Network::PlayerId_t playerId = action->GetPlayer(); + + int32_t playerIndex = Network::GetPlayerIndex(playerId.id); + Guard::Assert( + playerIndex != -1, "Unable to find player %u for game action %u", playerId, action->GetType()); + + Network::SetPlayerLastAction(playerIndex, action->GetType()); + Network::IncrementPlayerNumCommands(playerIndex); + if (result.cost > 0) + { + Network::AddPlayerMoneySpent(playerIndex, result.cost); + } + + if (!result.position.IsNull()) + { + Network::SetPlayerLastActionCoord(playerIndex, result.position); + } + } + else + { + bool commandExecutes = !flags.hasAny(CommandFlag::ghost, CommandFlag::noSpend); + + bool recordAction = false; + if (replayManager != nullptr && !ignoreForReplays) + { + if (replayManager->IsRecording() && commandExecutes) + recordAction = true; + else if (replayManager->IsNormalising() && flags.has(CommandFlag::replay)) + recordAction = true; // In normalisation we only feed back actions issued by the replay manager. + } + if (recordAction) + { + replayManager->AddGameAction(gameState.currentTicks, action); + } + } + } + + // Allow autosave to commence + if (gLastAutoSaveUpdate == kAutosavePause) + { + gLastAutoSaveUpdate = Platform::GetTicks(); + } + } + + // Call callback for asynchronous events + auto cb = action->GetCallback(); + if (cb != nullptr) + { + cb(action, &result); + } + + // Only show errors when its not a ghost and not a preview and also top level action. + bool shouldShowError = !flags.has(CommandFlag::ghost) && !flags.has(CommandFlag::noSpend) && topLevel; + + // In network mode the error should be only shown to the issuer of the action. + if (Network::GetMode() != Network::Mode::none) + { + // If the action was never networked and query fails locally the player id is not assigned. + // So compare only if the action went into the queue otherwise show errors by default. + const bool isActionFromNetwork = action->GetFlags().has(CommandFlag::networked); + if (isActionFromNetwork && action->GetPlayer() != Network::GetCurrentPlayerId()) + { + shouldShowError = false; + } + } + + if (result.error != Status::ok && shouldShowError) + { + auto windowManager = Ui::GetWindowManager(); + windowManager->ShowError(result.getErrorTitle(), result.getErrorMessage()); + } + + return result; + } + + Result Execute(const GameAction* action, GameState_t& gameState) + { + return ExecuteInternal(action, gameState, true); + } + + Result ExecuteNested(const GameAction* action, GameState_t& gameState) + { + return ExecuteInternal(action, gameState, false); + } + +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameActionRunner.h b/src/openrct2/actions/GameActionRunner.h new file mode 100644 index 0000000000..f742c2a187 --- /dev/null +++ b/src/openrct2/actions/GameActionRunner.h @@ -0,0 +1,41 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "GameAction.hpp" + +namespace OpenRCT2 +{ + struct GameState_t; +} + +namespace OpenRCT2::GameActions +{ + // Halts the queue processing until ResumeQueue is called, any calls to ProcessQueue + // will have no effect during suspension. It has no effect of actions that will not + // cross the network. + void SuspendQueue(); + + // Resumes queue processing. + void ResumeQueue(); + + void Enqueue(const GameAction* ga, uint32_t tick); + void Enqueue(GameAction::Ptr&& ga, uint32_t tick); + void ProcessQueue(GameState_t& gameState); + void ClearQueue(); + + // This should be used if a round trip is to be expected. + Result Query(const GameAction* action, GameState_t& gameState); + Result Execute(const GameAction* action, GameState_t& gameState); + + // This should be used from within game actions. + Result QueryNested(const GameAction* action, GameState_t& gameState); + Result ExecuteNested(const GameAction* action, GameState_t& gameState); +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/GameCommand.h b/src/openrct2/actions/GameCommand.h new file mode 100644 index 0000000000..9cab835b28 --- /dev/null +++ b/src/openrct2/actions/GameCommand.h @@ -0,0 +1,105 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +namespace OpenRCT2 +{ + enum class GameCommand : int32_t + { + SetRideAppearance, + SetLandHeight, + TogglePause, + PlaceTrack, + RemoveTrack, + LoadOrQuit, + CreateRide, + DemolishRide, + SetRideStatus, + SetRideVehicles, + SetRideName, + SetRideSetting, + PlaceRideEntranceOrExit, + RemoveRideEntranceOrExit, + RemoveScenery, + PlaceScenery, + SetWaterHeight, + PlacePath, + PlacePathLayout, + RemovePath, + ChangeSurfaceStyle, + SetRidePrice, + SetGuestName, + SetStaffName, + RaiseLand, + LowerLand, + EditLandSmooth, + RaiseWater, + LowerWater, + SetBrakesSpeed, + HireNewStaffMember, + SetStaffPatrol, + FireStaffMember, + SetStaffOrders, + SetParkName, + SetParkOpen, + BuyLandRights, + PlaceParkEntrance, + RemoveParkEntrance, + SetMazeTrack, + SetParkEntranceFee, + SetStaffColour, + PlaceWall, + RemoveWall, + PlaceLargeScenery, + RemoveLargeScenery, + SetCurrentLoan, + SetResearchFunding, + PlaceTrackDesign, + StartMarketingCampaign, + PlaceMazeDesign, + PlaceBanner, + RemoveBanner, + SetSceneryColour, + SetWallColour, + SetLargeSceneryColour, + SetBannerColour, + SetLandOwnership, + ClearScenery, + SetBannerName, + SetSignName, + SetBannerStyle, + SetSignStyle, + SetPlayerGroup, + ModifyGroups, + KickPlayer, + Cheat, + PickupGuest, + PickupStaff, + BalloonPress, + ModifyTile, + EditScenarioOptions, + PlacePeepSpawn, + SetColourScheme, + SetStaffCostume, + PlaceFootpathAddition, + RemoveFootpathAddition, + GuestSetFlags, + SetDate, + Custom, + ChangeMapSize, + FreezeRideRating, + SetGameSpeed, + SetRestrictedScenery, + setRideVisibility, + Count, + }; +} diff --git a/src/openrct2/actions/CheatSetAction.cpp b/src/openrct2/actions/cheats/CheatSetAction.cpp similarity index 95% rename from src/openrct2/actions/CheatSetAction.cpp rename to src/openrct2/actions/cheats/CheatSetAction.cpp index dffca5b040..abd3ab86ff 100644 --- a/src/openrct2/actions/CheatSetAction.cpp +++ b/src/openrct2/actions/cheats/CheatSetAction.cpp @@ -9,39 +9,40 @@ #include "CheatSetAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../config/Config.h" -#include "../core/EnumUtils.hpp" -#include "../core/Guard.hpp" -#include "../core/String.hpp" -#include "../drawing/Colour.h" -#include "../drawing/Drawing.h" -#include "../entity/Duck.h" -#include "../entity/EntityList.h" -#include "../entity/EntityRegistry.h" -#include "../entity/Staff.h" -#include "../localisation/StringIds.h" -#include "../network/Network.h" -#include "../object/PathAdditionEntry.h" -#include "../ride/Ride.h" -#include "../ride/RideManager.hpp" -#include "../ride/Vehicle.h" -#include "../scenario/Scenario.h" -#include "../scenario/ScenarioObjective.h" -#include "../ui/WindowManager.h" -#include "../util/Util.h" -#include "../windows/Intent.h" -#include "../world/Climate.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/tile_element/PathElement.h" -#include "../world/tile_element/SmallSceneryElement.h" -#include "../world/tile_element/SurfaceElement.h" -#include "ParkSetLoanAction.h" -#include "ParkSetParameterAction.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../actions/GameActionRunner.h" +#include "../../config/Config.h" +#include "../../core/EnumUtils.hpp" +#include "../../core/Guard.hpp" +#include "../../core/String.hpp" +#include "../../drawing/Colour.h" +#include "../../drawing/Drawing.h" +#include "../../entity/Duck.h" +#include "../../entity/EntityList.h" +#include "../../entity/EntityRegistry.h" +#include "../../entity/Staff.h" +#include "../../localisation/StringIds.h" +#include "../../network/Network.h" +#include "../../object/PathAdditionEntry.h" +#include "../../ride/Ride.h" +#include "../../ride/RideManager.hpp" +#include "../../ride/Vehicle.h" +#include "../../scenario/Scenario.h" +#include "../../scenario/ScenarioObjective.h" +#include "../../ui/WindowManager.h" +#include "../../util/Util.h" +#include "../../windows/Intent.h" +#include "../../world/Climate.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/tile_element/PathElement.h" +#include "../../world/tile_element/SmallSceneryElement.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../park/ParkSetLoanAction.h" +#include "../park/ParkSetParameterAction.h" namespace OpenRCT2::GameActions { @@ -521,7 +522,7 @@ namespace OpenRCT2::GameActions { for (auto& ride : RideManager(gameState)) { - if (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown)) { auto mechanic = RideGetAssignedMechanic(ride); @@ -558,7 +559,7 @@ namespace OpenRCT2::GameActions for (auto& ride : RideManager(gameState)) { // Reset crash status and history - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_CRASHED; + ride.flags.unset(RideFlag::crashed); ride.lastCrashType = RIDE_CRASH_TYPE_NONE; } auto* windowMgr = Ui::GetWindowManager(); diff --git a/src/openrct2/actions/CheatSetAction.h b/src/openrct2/actions/cheats/CheatSetAction.h similarity index 98% rename from src/openrct2/actions/CheatSetAction.h rename to src/openrct2/actions/cheats/CheatSetAction.h index 934ce956ba..b5a43ffabc 100644 --- a/src/openrct2/actions/CheatSetAction.h +++ b/src/openrct2/actions/cheats/CheatSetAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp b/src/openrct2/actions/footpath/FootpathAdditionPlaceAction.cpp similarity index 92% rename from src/openrct2/actions/FootpathAdditionPlaceAction.cpp rename to src/openrct2/actions/footpath/FootpathAdditionPlaceAction.cpp index 83d600758f..bcc79d3bca 100644 --- a/src/openrct2/actions/FootpathAdditionPlaceAction.cpp +++ b/src/openrct2/actions/footpath/FootpathAdditionPlaceAction.cpp @@ -9,21 +9,21 @@ #include "FootpathAdditionPlaceAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../object/ObjectEntryManager.h" -#include "../object/PathAdditionEntry.h" -#include "../world/Footpath.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/Scenery.h" -#include "../world/tile_element/PathElement.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../object/ObjectEntryManager.h" +#include "../../object/PathAdditionEntry.h" +#include "../../world/Footpath.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/Scenery.h" +#include "../../world/tile_element/PathElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathAdditionPlaceAction.h b/src/openrct2/actions/footpath/FootpathAdditionPlaceAction.h similarity index 97% rename from src/openrct2/actions/FootpathAdditionPlaceAction.h rename to src/openrct2/actions/footpath/FootpathAdditionPlaceAction.h index c5a40a033e..3254e1f339 100644 --- a/src/openrct2/actions/FootpathAdditionPlaceAction.h +++ b/src/openrct2/actions/footpath/FootpathAdditionPlaceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathAdditionRemoveAction.cpp b/src/openrct2/actions/footpath/FootpathAdditionRemoveAction.cpp similarity index 89% rename from src/openrct2/actions/FootpathAdditionRemoveAction.cpp rename to src/openrct2/actions/footpath/FootpathAdditionRemoveAction.cpp index e96b996943..d4f0f65c96 100644 --- a/src/openrct2/actions/FootpathAdditionRemoveAction.cpp +++ b/src/openrct2/actions/footpath/FootpathAdditionRemoveAction.cpp @@ -9,18 +9,18 @@ #include "FootpathAdditionRemoveAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../world/Footpath.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/tile_element/PathElement.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../world/Footpath.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/tile_element/PathElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathAdditionRemoveAction.h b/src/openrct2/actions/footpath/FootpathAdditionRemoveAction.h similarity index 97% rename from src/openrct2/actions/FootpathAdditionRemoveAction.h rename to src/openrct2/actions/footpath/FootpathAdditionRemoveAction.h index 8e7f02fc9a..0dde81cbc7 100644 --- a/src/openrct2/actions/FootpathAdditionRemoveAction.h +++ b/src/openrct2/actions/footpath/FootpathAdditionRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp b/src/openrct2/actions/footpath/FootpathLayoutPlaceAction.cpp similarity index 93% rename from src/openrct2/actions/FootpathLayoutPlaceAction.cpp rename to src/openrct2/actions/footpath/FootpathLayoutPlaceAction.cpp index ce53879f5b..40e371000d 100644 --- a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp +++ b/src/openrct2/actions/footpath/FootpathLayoutPlaceAction.cpp @@ -9,25 +9,25 @@ #include "FootpathLayoutPlaceAction.h" -#include "../Cheats.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/Guard.hpp" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/RideConstruction.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/MapLimits.h" -#include "../world/Park.h" -#include "../world/QuarterTile.h" -#include "../world/tile_element/EntranceElement.h" -#include "../world/tile_element/PathElement.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Cheats.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/Guard.hpp" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/RideConstruction.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/MapLimits.h" +#include "../../world/Park.h" +#include "../../world/QuarterTile.h" +#include "../../world/tile_element/EntranceElement.h" +#include "../../world/tile_element/PathElement.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathLayoutPlaceAction.h b/src/openrct2/actions/footpath/FootpathLayoutPlaceAction.h similarity index 96% rename from src/openrct2/actions/FootpathLayoutPlaceAction.h rename to src/openrct2/actions/footpath/FootpathLayoutPlaceAction.h index a90ce529b7..8de1af793d 100644 --- a/src/openrct2/actions/FootpathLayoutPlaceAction.h +++ b/src/openrct2/actions/footpath/FootpathLayoutPlaceAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../world/Footpath.h" -#include "GameAction.h" +#include "../../world/Footpath.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/footpath/FootpathPlaceAction.cpp similarity index 95% rename from src/openrct2/actions/FootpathPlaceAction.cpp rename to src/openrct2/actions/footpath/FootpathPlaceAction.cpp index 78f4f732a0..c470cd93cc 100644 --- a/src/openrct2/actions/FootpathPlaceAction.cpp +++ b/src/openrct2/actions/footpath/FootpathPlaceAction.cpp @@ -9,31 +9,31 @@ #include "FootpathPlaceAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/Guard.hpp" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../object/PathAdditionEntry.h" -#include "../ride/RideConstruction.h" -#include "../windows/Intent.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/QuarterTile.h" -#include "../world/Scenery.h" -#include "../world/TileElementsView.h" -#include "../world/Wall.h" -#include "../world/tile_element/EntranceElement.h" -#include "../world/tile_element/PathElement.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/Guard.hpp" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../object/PathAdditionEntry.h" +#include "../../ride/RideConstruction.h" +#include "../../windows/Intent.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/QuarterTile.h" +#include "../../world/Scenery.h" +#include "../../world/TileElementsView.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/EntranceElement.h" +#include "../../world/tile_element/PathElement.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" #include diff --git a/src/openrct2/actions/FootpathPlaceAction.h b/src/openrct2/actions/footpath/FootpathPlaceAction.h similarity index 97% rename from src/openrct2/actions/FootpathPlaceAction.h rename to src/openrct2/actions/footpath/FootpathPlaceAction.h index ed2fcb2a42..a854654ae9 100644 --- a/src/openrct2/actions/FootpathPlaceAction.h +++ b/src/openrct2/actions/footpath/FootpathPlaceAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../world/Footpath.h" -#include "GameAction.h" +#include "../../world/Footpath.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathRemoveAction.cpp b/src/openrct2/actions/footpath/FootpathRemoveAction.cpp similarity index 90% rename from src/openrct2/actions/FootpathRemoveAction.cpp rename to src/openrct2/actions/footpath/FootpathRemoveAction.cpp index a0924ee455..43b6fd0c06 100644 --- a/src/openrct2/actions/FootpathRemoveAction.cpp +++ b/src/openrct2/actions/footpath/FootpathRemoveAction.cpp @@ -9,20 +9,21 @@ #include "FootpathRemoveAction.h" -#include "../Cheats.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../world/Footpath.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/BannerElement.h" -#include "../world/tile_element/PathElement.h" -#include "BannerRemoveAction.h" +#include "../../Cheats.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../world/Footpath.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/BannerElement.h" +#include "../../world/tile_element/PathElement.h" +#include "../GameActionRunner.h" +#include "../scenery/BannerRemoveAction.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/FootpathRemoveAction.h b/src/openrct2/actions/footpath/FootpathRemoveAction.h similarity index 95% rename from src/openrct2/actions/FootpathRemoveAction.h rename to src/openrct2/actions/footpath/FootpathRemoveAction.h index c0284793fa..421701e80b 100644 --- a/src/openrct2/actions/FootpathRemoveAction.h +++ b/src/openrct2/actions/footpath/FootpathRemoveAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../management/Finance.h" -#include "GameAction.h" +#include "../../management/Finance.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BalloonPressAction.cpp b/src/openrct2/actions/general/BalloonPressAction.cpp similarity index 92% rename from src/openrct2/actions/BalloonPressAction.cpp rename to src/openrct2/actions/general/BalloonPressAction.cpp index 19c72338de..9f6bdca8fe 100644 --- a/src/openrct2/actions/BalloonPressAction.cpp +++ b/src/openrct2/actions/general/BalloonPressAction.cpp @@ -9,11 +9,11 @@ #include "BalloonPressAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../entity/Balloon.h" -#include "../entity/EntityRegistry.h" -#include "GameAction.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../entity/Balloon.h" +#include "../../entity/EntityRegistry.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BalloonPressAction.h b/src/openrct2/actions/general/BalloonPressAction.h similarity index 94% rename from src/openrct2/actions/BalloonPressAction.h rename to src/openrct2/actions/general/BalloonPressAction.h index 75928a472e..558c43f1a1 100644 --- a/src/openrct2/actions/BalloonPressAction.h +++ b/src/openrct2/actions/general/BalloonPressAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../Identifiers.h" -#include "GameAction.h" +#include "../../Identifiers.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/CustomAction.cpp b/src/openrct2/actions/general/CustomAction.cpp similarity index 95% rename from src/openrct2/actions/CustomAction.cpp rename to src/openrct2/actions/general/CustomAction.cpp index 90f70fff02..82a4c50c3b 100644 --- a/src/openrct2/actions/CustomAction.cpp +++ b/src/openrct2/actions/general/CustomAction.cpp @@ -8,10 +8,11 @@ *****************************************************************************/ #ifdef ENABLE_SCRIPTING + #include "CustomAction.h" - #include "../Context.h" - #include "../scripting/ScriptEngine.h" + #include "../../Context.h" + #include "../../scripting/ScriptEngine.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/CustomAction.h b/src/openrct2/actions/general/CustomAction.h similarity index 97% rename from src/openrct2/actions/CustomAction.h rename to src/openrct2/actions/general/CustomAction.h index 0ee60f159c..9521d4c464 100644 --- a/src/openrct2/actions/CustomAction.h +++ b/src/openrct2/actions/general/CustomAction.h @@ -11,7 +11,7 @@ #ifdef ENABLE_SCRIPTING - #include "GameAction.h" + #include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/GameSetSpeedAction.cpp b/src/openrct2/actions/general/GameSetSpeedAction.cpp similarity index 94% rename from src/openrct2/actions/GameSetSpeedAction.cpp rename to src/openrct2/actions/general/GameSetSpeedAction.cpp index f17ba9a0ed..e7a0c78f25 100644 --- a/src/openrct2/actions/GameSetSpeedAction.cpp +++ b/src/openrct2/actions/general/GameSetSpeedAction.cpp @@ -9,9 +9,10 @@ #include "GameSetSpeedAction.h" -#include "../Diagnostic.h" -#include "../config/Config.h" -#include "../ui/WindowManager.h" +#include "../../Diagnostic.h" +#include "../../Game.h" +#include "../../config/Config.h" +#include "../../ui/WindowManager.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/GameSetSpeedAction.h b/src/openrct2/actions/general/GameSetSpeedAction.h similarity index 97% rename from src/openrct2/actions/GameSetSpeedAction.h rename to src/openrct2/actions/general/GameSetSpeedAction.h index 89842556c2..25c6ecd3ee 100644 --- a/src/openrct2/actions/GameSetSpeedAction.h +++ b/src/openrct2/actions/general/GameSetSpeedAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LoadOrQuitAction.cpp b/src/openrct2/actions/general/LoadOrQuitAction.cpp similarity index 94% rename from src/openrct2/actions/LoadOrQuitAction.cpp rename to src/openrct2/actions/general/LoadOrQuitAction.cpp index 9adc39f1d6..ef4ed745ab 100644 --- a/src/openrct2/actions/LoadOrQuitAction.cpp +++ b/src/openrct2/actions/general/LoadOrQuitAction.cpp @@ -9,9 +9,10 @@ #include "LoadOrQuitAction.h" -#include "../Context.h" -#include "../OpenRCT2.h" -#include "../ui/WindowManager.h" +#include "../../Context.h" +#include "../../Game.h" +#include "../../OpenRCT2.h" +#include "../../ui/WindowManager.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LoadOrQuitAction.h b/src/openrct2/actions/general/LoadOrQuitAction.h similarity index 95% rename from src/openrct2/actions/LoadOrQuitAction.h rename to src/openrct2/actions/general/LoadOrQuitAction.h index e9d25553d1..f8edb6dff5 100644 --- a/src/openrct2/actions/LoadOrQuitAction.h +++ b/src/openrct2/actions/general/LoadOrQuitAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../interface/Window.h" -#include "GameAction.h" +#include "../../interface/Window.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/MapChangeSizeAction.cpp b/src/openrct2/actions/general/MapChangeSizeAction.cpp similarity index 92% rename from src/openrct2/actions/MapChangeSizeAction.cpp rename to src/openrct2/actions/general/MapChangeSizeAction.cpp index 503f836651..48dbd4c9e8 100644 --- a/src/openrct2/actions/MapChangeSizeAction.cpp +++ b/src/openrct2/actions/general/MapChangeSizeAction.cpp @@ -9,14 +9,14 @@ #include "MapChangeSizeAction.h" -#include "../Context.h" -#include "../GameState.h" -#include "../drawing/Drawing.h" -#include "../ui/UiContext.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" -#include "../world/Map.h" -#include "../world/Park.h" +#include "../../Context.h" +#include "../../GameState.h" +#include "../../drawing/Drawing.h" +#include "../../ui/UiContext.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" +#include "../../world/Map.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/MapChangeSizeAction.h b/src/openrct2/actions/general/MapChangeSizeAction.h similarity index 94% rename from src/openrct2/actions/MapChangeSizeAction.h rename to src/openrct2/actions/general/MapChangeSizeAction.h index dd3562155c..846d99c168 100644 --- a/src/openrct2/actions/MapChangeSizeAction.h +++ b/src/openrct2/actions/general/MapChangeSizeAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../world/Location.hpp" -#include "GameAction.h" +#include "../../world/Location.hpp" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PauseToggleAction.cpp b/src/openrct2/actions/general/PauseToggleAction.cpp similarity index 97% rename from src/openrct2/actions/PauseToggleAction.cpp rename to src/openrct2/actions/general/PauseToggleAction.cpp index c89d6738a9..16b80eb401 100644 --- a/src/openrct2/actions/PauseToggleAction.cpp +++ b/src/openrct2/actions/general/PauseToggleAction.cpp @@ -9,6 +9,8 @@ #include "PauseToggleAction.h" +#include "../../Game.h" + namespace OpenRCT2::GameActions { uint16_t PauseToggleAction::GetActionFlags() const diff --git a/src/openrct2/actions/PauseToggleAction.h b/src/openrct2/actions/general/PauseToggleAction.h similarity index 96% rename from src/openrct2/actions/PauseToggleAction.h rename to src/openrct2/actions/general/PauseToggleAction.h index 6d93c12b9c..5d8532a35b 100644 --- a/src/openrct2/actions/PauseToggleAction.h +++ b/src/openrct2/actions/general/PauseToggleAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ScenarioSetSettingAction.cpp b/src/openrct2/actions/general/ScenarioSetSettingAction.cpp similarity index 97% rename from src/openrct2/actions/ScenarioSetSettingAction.cpp rename to src/openrct2/actions/general/ScenarioSetSettingAction.cpp index a9c95b981a..448d915561 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.cpp +++ b/src/openrct2/actions/general/ScenarioSetSettingAction.cpp @@ -9,14 +9,14 @@ #include "ScenarioSetSettingAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../entity/Peep.h" -#include "../management/Finance.h" -#include "../scenario/Scenario.h" -#include "../ui/WindowManager.h" -#include "../world/Park.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../entity/Peep.h" +#include "../../management/Finance.h" +#include "../../scenario/Scenario.h" +#include "../../ui/WindowManager.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ScenarioSetSettingAction.h b/src/openrct2/actions/general/ScenarioSetSettingAction.h similarity index 98% rename from src/openrct2/actions/ScenarioSetSettingAction.h rename to src/openrct2/actions/general/ScenarioSetSettingAction.h index e7959aa779..fd4307d711 100644 --- a/src/openrct2/actions/ScenarioSetSettingAction.h +++ b/src/openrct2/actions/general/ScenarioSetSettingAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/TileModifyAction.cpp b/src/openrct2/actions/general/TileModifyAction.cpp similarity index 98% rename from src/openrct2/actions/TileModifyAction.cpp rename to src/openrct2/actions/general/TileModifyAction.cpp index 95a9646649..2f0df99ee4 100644 --- a/src/openrct2/actions/TileModifyAction.cpp +++ b/src/openrct2/actions/general/TileModifyAction.cpp @@ -9,11 +9,11 @@ #include "TileModifyAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../windows/Intent.h" -#include "../world/Map.h" -#include "../world/TileInspector.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../windows/Intent.h" +#include "../../world/Map.h" +#include "../../world/TileInspector.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/TileModifyAction.h b/src/openrct2/actions/general/TileModifyAction.h similarity index 98% rename from src/openrct2/actions/TileModifyAction.h rename to src/openrct2/actions/general/TileModifyAction.h index 1c0214353c..290583fc20 100644 --- a/src/openrct2/actions/TileModifyAction.h +++ b/src/openrct2/actions/general/TileModifyAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/NetworkModifyGroupAction.cpp b/src/openrct2/actions/network/NetworkModifyGroupAction.cpp similarity index 98% rename from src/openrct2/actions/NetworkModifyGroupAction.cpp rename to src/openrct2/actions/network/NetworkModifyGroupAction.cpp index b276dbe405..a3e77ee990 100644 --- a/src/openrct2/actions/NetworkModifyGroupAction.cpp +++ b/src/openrct2/actions/network/NetworkModifyGroupAction.cpp @@ -9,7 +9,7 @@ #include "NetworkModifyGroupAction.h" -#include "../network/Network.h" +#include "../../network/Network.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/NetworkModifyGroupAction.h b/src/openrct2/actions/network/NetworkModifyGroupAction.h similarity index 98% rename from src/openrct2/actions/NetworkModifyGroupAction.h rename to src/openrct2/actions/network/NetworkModifyGroupAction.h index ec74e01f02..099f72bda2 100644 --- a/src/openrct2/actions/NetworkModifyGroupAction.h +++ b/src/openrct2/actions/network/NetworkModifyGroupAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PlayerKickAction.cpp b/src/openrct2/actions/network/PlayerKickAction.cpp similarity index 97% rename from src/openrct2/actions/PlayerKickAction.cpp rename to src/openrct2/actions/network/PlayerKickAction.cpp index 33bebb40ee..a59695a279 100644 --- a/src/openrct2/actions/PlayerKickAction.cpp +++ b/src/openrct2/actions/network/PlayerKickAction.cpp @@ -9,7 +9,7 @@ #include "PlayerKickAction.h" -#include "../network/Network.h" +#include "../../network/Network.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PlayerKickAction.h b/src/openrct2/actions/network/PlayerKickAction.h similarity index 97% rename from src/openrct2/actions/PlayerKickAction.h rename to src/openrct2/actions/network/PlayerKickAction.h index 783550a696..2e638905fa 100644 --- a/src/openrct2/actions/PlayerKickAction.h +++ b/src/openrct2/actions/network/PlayerKickAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PlayerSetGroupAction.cpp b/src/openrct2/actions/network/PlayerSetGroupAction.cpp similarity index 97% rename from src/openrct2/actions/PlayerSetGroupAction.cpp rename to src/openrct2/actions/network/PlayerSetGroupAction.cpp index 731dbda09c..bee1b5565b 100644 --- a/src/openrct2/actions/PlayerSetGroupAction.cpp +++ b/src/openrct2/actions/network/PlayerSetGroupAction.cpp @@ -9,7 +9,7 @@ #include "PlayerSetGroupAction.h" -#include "../network/Network.h" +#include "../../network/Network.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PlayerSetGroupAction.h b/src/openrct2/actions/network/PlayerSetGroupAction.h similarity index 97% rename from src/openrct2/actions/PlayerSetGroupAction.h rename to src/openrct2/actions/network/PlayerSetGroupAction.h index bccbeca1b8..40706c86c9 100644 --- a/src/openrct2/actions/PlayerSetGroupAction.h +++ b/src/openrct2/actions/network/PlayerSetGroupAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandBuyRightsAction.cpp b/src/openrct2/actions/park/LandBuyRightsAction.cpp similarity index 92% rename from src/openrct2/actions/LandBuyRightsAction.cpp rename to src/openrct2/actions/park/LandBuyRightsAction.cpp index 568a9231d3..0c6afab905 100644 --- a/src/openrct2/actions/LandBuyRightsAction.cpp +++ b/src/openrct2/actions/park/LandBuyRightsAction.cpp @@ -9,21 +9,21 @@ #include "LandBuyRightsAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../actions/LandSetHeightAction.h" -#include "../audio/Audio.h" -#include "../core/EnumUtils.hpp" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/RideData.h" -#include "../windows/Intent.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/Scenery.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../actions/terraform/LandSetHeightAction.h" +#include "../../audio/Audio.h" +#include "../../core/EnumUtils.hpp" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/RideData.h" +#include "../../windows/Intent.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/Scenery.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandBuyRightsAction.h b/src/openrct2/actions/park/LandBuyRightsAction.h similarity index 98% rename from src/openrct2/actions/LandBuyRightsAction.h rename to src/openrct2/actions/park/LandBuyRightsAction.h index 60c4433bb0..0afc3646eb 100644 --- a/src/openrct2/actions/LandBuyRightsAction.h +++ b/src/openrct2/actions/park/LandBuyRightsAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandSetRightsAction.cpp b/src/openrct2/actions/park/LandSetRightsAction.cpp similarity index 93% rename from src/openrct2/actions/LandSetRightsAction.cpp rename to src/openrct2/actions/park/LandSetRightsAction.cpp index 1c197773be..5b1240778a 100644 --- a/src/openrct2/actions/LandSetRightsAction.cpp +++ b/src/openrct2/actions/park/LandSetRightsAction.cpp @@ -9,23 +9,23 @@ #include "LandSetRightsAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../actions/LandSetHeightAction.h" -#include "../audio/Audio.h" -#include "../core/Numerics.hpp" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/RideData.h" -#include "../windows/Intent.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/Scenery.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/EntranceElement.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../actions/terraform/LandSetHeightAction.h" +#include "../../audio/Audio.h" +#include "../../core/Numerics.hpp" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/RideData.h" +#include "../../windows/Intent.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/Scenery.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/EntranceElement.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandSetRightsAction.h b/src/openrct2/actions/park/LandSetRightsAction.h similarity index 98% rename from src/openrct2/actions/LandSetRightsAction.h rename to src/openrct2/actions/park/LandSetRightsAction.h index 46bbde6f42..82a7b28b97 100644 --- a/src/openrct2/actions/LandSetRightsAction.h +++ b/src/openrct2/actions/park/LandSetRightsAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkEntrancePlaceAction.cpp b/src/openrct2/actions/park/ParkEntrancePlaceAction.cpp similarity index 93% rename from src/openrct2/actions/ParkEntrancePlaceAction.cpp rename to src/openrct2/actions/park/ParkEntrancePlaceAction.cpp index 99b2649b31..aada999992 100644 --- a/src/openrct2/actions/ParkEntrancePlaceAction.cpp +++ b/src/openrct2/actions/park/ParkEntrancePlaceAction.cpp @@ -9,21 +9,21 @@ #include "ParkEntrancePlaceAction.h" -#include "../Cheats.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/Guard.hpp" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../world/ConstructionClearance.h" -#include "../world/Entrance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/MapAnimation.h" -#include "../world/Park.h" -#include "../world/tile_element/EntranceElement.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Cheats.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/Guard.hpp" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Entrance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/MapAnimation.h" +#include "../../world/Park.h" +#include "../../world/tile_element/EntranceElement.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkEntrancePlaceAction.h b/src/openrct2/actions/park/ParkEntrancePlaceAction.h similarity index 97% rename from src/openrct2/actions/ParkEntrancePlaceAction.h rename to src/openrct2/actions/park/ParkEntrancePlaceAction.h index 60164a22dc..38f03b5a77 100644 --- a/src/openrct2/actions/ParkEntrancePlaceAction.h +++ b/src/openrct2/actions/park/ParkEntrancePlaceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkEntranceRemoveAction.cpp b/src/openrct2/actions/park/ParkEntranceRemoveAction.cpp similarity index 92% rename from src/openrct2/actions/ParkEntranceRemoveAction.cpp rename to src/openrct2/actions/park/ParkEntranceRemoveAction.cpp index cb77ee87cb..ffc9995df3 100644 --- a/src/openrct2/actions/ParkEntranceRemoveAction.cpp +++ b/src/openrct2/actions/park/ParkEntranceRemoveAction.cpp @@ -9,14 +9,14 @@ #include "ParkEntranceRemoveAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../management/Finance.h" -#include "../world/Entrance.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/tile_element/EntranceElement.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../management/Finance.h" +#include "../../world/Entrance.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/tile_element/EntranceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkEntranceRemoveAction.h b/src/openrct2/actions/park/ParkEntranceRemoveAction.h similarity index 97% rename from src/openrct2/actions/ParkEntranceRemoveAction.h rename to src/openrct2/actions/park/ParkEntranceRemoveAction.h index e459a45f7e..13ead89c58 100644 --- a/src/openrct2/actions/ParkEntranceRemoveAction.h +++ b/src/openrct2/actions/park/ParkEntranceRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkMarketingAction.cpp b/src/openrct2/actions/park/ParkMarketingAction.cpp similarity index 91% rename from src/openrct2/actions/ParkMarketingAction.cpp rename to src/openrct2/actions/park/ParkMarketingAction.cpp index c3f5f10f0b..d9bef3221e 100644 --- a/src/openrct2/actions/ParkMarketingAction.cpp +++ b/src/openrct2/actions/park/ParkMarketingAction.cpp @@ -9,15 +9,15 @@ #include "ParkMarketingAction.h" -#include "../Context.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../management/Marketing.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" -#include "../world/Park.h" +#include "../../Context.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../management/Marketing.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" +#include "../../world/Park.h" #include diff --git a/src/openrct2/actions/ParkMarketingAction.h b/src/openrct2/actions/park/ParkMarketingAction.h similarity index 97% rename from src/openrct2/actions/ParkMarketingAction.h rename to src/openrct2/actions/park/ParkMarketingAction.h index 7e5aec1f06..aaecde851b 100644 --- a/src/openrct2/actions/ParkMarketingAction.h +++ b/src/openrct2/actions/park/ParkMarketingAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetDateAction.cpp b/src/openrct2/actions/park/ParkSetDateAction.cpp similarity index 88% rename from src/openrct2/actions/ParkSetDateAction.cpp rename to src/openrct2/actions/park/ParkSetDateAction.cpp index 8827905481..81c0103498 100644 --- a/src/openrct2/actions/ParkSetDateAction.cpp +++ b/src/openrct2/actions/park/ParkSetDateAction.cpp @@ -9,14 +9,14 @@ #include "ParkSetDateAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetDateAction.h b/src/openrct2/actions/park/ParkSetDateAction.h similarity index 97% rename from src/openrct2/actions/ParkSetDateAction.h rename to src/openrct2/actions/park/ParkSetDateAction.h index a42c8c870c..e82c350765 100644 --- a/src/openrct2/actions/ParkSetDateAction.h +++ b/src/openrct2/actions/park/ParkSetDateAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetEntranceFeeAction.cpp b/src/openrct2/actions/park/ParkSetEntranceFeeAction.cpp similarity index 90% rename from src/openrct2/actions/ParkSetEntranceFeeAction.cpp rename to src/openrct2/actions/park/ParkSetEntranceFeeAction.cpp index e15d39f642..eb288050cc 100644 --- a/src/openrct2/actions/ParkSetEntranceFeeAction.cpp +++ b/src/openrct2/actions/park/ParkSetEntranceFeeAction.cpp @@ -9,13 +9,13 @@ #include "ParkSetEntranceFeeAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../ui/WindowManager.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../ui/WindowManager.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetEntranceFeeAction.h b/src/openrct2/actions/park/ParkSetEntranceFeeAction.h similarity index 97% rename from src/openrct2/actions/ParkSetEntranceFeeAction.h rename to src/openrct2/actions/park/ParkSetEntranceFeeAction.h index 84ef9c79f4..74a8293f88 100644 --- a/src/openrct2/actions/ParkSetEntranceFeeAction.h +++ b/src/openrct2/actions/park/ParkSetEntranceFeeAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetLoanAction.cpp b/src/openrct2/actions/park/ParkSetLoanAction.cpp similarity index 90% rename from src/openrct2/actions/ParkSetLoanAction.cpp rename to src/openrct2/actions/park/ParkSetLoanAction.cpp index 8c7206c7c7..84c0af6d42 100644 --- a/src/openrct2/actions/ParkSetLoanAction.cpp +++ b/src/openrct2/actions/park/ParkSetLoanAction.cpp @@ -9,13 +9,13 @@ #include "ParkSetLoanAction.h" -#include "../Context.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" +#include "../../Context.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetLoanAction.h b/src/openrct2/actions/park/ParkSetLoanAction.h similarity index 97% rename from src/openrct2/actions/ParkSetLoanAction.h rename to src/openrct2/actions/park/ParkSetLoanAction.h index e2ed95511c..78ac9568ee 100644 --- a/src/openrct2/actions/ParkSetLoanAction.h +++ b/src/openrct2/actions/park/ParkSetLoanAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetNameAction.cpp b/src/openrct2/actions/park/ParkSetNameAction.cpp similarity index 84% rename from src/openrct2/actions/ParkSetNameAction.cpp rename to src/openrct2/actions/park/ParkSetNameAction.cpp index 1be9b72981..aa44b5c1f1 100644 --- a/src/openrct2/actions/ParkSetNameAction.cpp +++ b/src/openrct2/actions/park/ParkSetNameAction.cpp @@ -9,16 +9,16 @@ #include "ParkSetNameAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../management/Finance.h" -#include "../network/Network.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" -#include "../world/Park.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../management/Finance.h" +#include "../../network/Network.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetNameAction.h b/src/openrct2/actions/park/ParkSetNameAction.h similarity index 97% rename from src/openrct2/actions/ParkSetNameAction.h rename to src/openrct2/actions/park/ParkSetNameAction.h index 96b083d8c8..fb26873a3d 100644 --- a/src/openrct2/actions/ParkSetNameAction.h +++ b/src/openrct2/actions/park/ParkSetNameAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetParameterAction.cpp b/src/openrct2/actions/park/ParkSetParameterAction.cpp similarity index 93% rename from src/openrct2/actions/ParkSetParameterAction.cpp rename to src/openrct2/actions/park/ParkSetParameterAction.cpp index 3b1c74dec6..3a8664ed9e 100644 --- a/src/openrct2/actions/ParkSetParameterAction.cpp +++ b/src/openrct2/actions/park/ParkSetParameterAction.cpp @@ -9,12 +9,12 @@ #include "ParkSetParameterAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/EnumUtils.hpp" -#include "../ride/ShopItem.h" -#include "../ui/WindowManager.h" -#include "../world/Park.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/EnumUtils.hpp" +#include "../../ride/ShopItem.h" +#include "../../ui/WindowManager.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetParameterAction.h b/src/openrct2/actions/park/ParkSetParameterAction.h similarity index 98% rename from src/openrct2/actions/ParkSetParameterAction.h rename to src/openrct2/actions/park/ParkSetParameterAction.h index 6fca01c201..6facb2f043 100644 --- a/src/openrct2/actions/ParkSetParameterAction.h +++ b/src/openrct2/actions/park/ParkSetParameterAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.cpp b/src/openrct2/actions/park/ParkSetResearchFundingAction.cpp similarity index 88% rename from src/openrct2/actions/ParkSetResearchFundingAction.cpp rename to src/openrct2/actions/park/ParkSetResearchFundingAction.cpp index 666852afa5..c36afa7956 100644 --- a/src/openrct2/actions/ParkSetResearchFundingAction.cpp +++ b/src/openrct2/actions/park/ParkSetResearchFundingAction.cpp @@ -9,14 +9,14 @@ #include "ParkSetResearchFundingAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Research.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Research.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ParkSetResearchFundingAction.h b/src/openrct2/actions/park/ParkSetResearchFundingAction.h similarity index 97% rename from src/openrct2/actions/ParkSetResearchFundingAction.h rename to src/openrct2/actions/park/ParkSetResearchFundingAction.h index 587800ac43..8c1465a12c 100644 --- a/src/openrct2/actions/ParkSetResearchFundingAction.h +++ b/src/openrct2/actions/park/ParkSetResearchFundingAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/GuestSetFlagsAction.cpp b/src/openrct2/actions/peep/GuestSetFlagsAction.cpp similarity index 92% rename from src/openrct2/actions/GuestSetFlagsAction.cpp rename to src/openrct2/actions/peep/GuestSetFlagsAction.cpp index f3c921fa2a..1f6dc22069 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.cpp +++ b/src/openrct2/actions/peep/GuestSetFlagsAction.cpp @@ -9,11 +9,11 @@ #include "GuestSetFlagsAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../entity/EntityRegistry.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../entity/EntityRegistry.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/GuestSetFlagsAction.h b/src/openrct2/actions/peep/GuestSetFlagsAction.h similarity index 97% rename from src/openrct2/actions/GuestSetFlagsAction.h rename to src/openrct2/actions/peep/GuestSetFlagsAction.h index 1cda6807a3..73947bfd5e 100644 --- a/src/openrct2/actions/GuestSetFlagsAction.h +++ b/src/openrct2/actions/peep/GuestSetFlagsAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/GuestSetNameAction.cpp b/src/openrct2/actions/peep/GuestSetNameAction.cpp similarity index 89% rename from src/openrct2/actions/GuestSetNameAction.cpp rename to src/openrct2/actions/peep/GuestSetNameAction.cpp index a104edcf4d..d44c67f400 100644 --- a/src/openrct2/actions/GuestSetNameAction.cpp +++ b/src/openrct2/actions/peep/GuestSetNameAction.cpp @@ -9,16 +9,16 @@ #include "GuestSetNameAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../entity/EntityRegistry.h" -#include "../localisation/StringIds.h" -#include "../windows/Intent.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../entity/EntityRegistry.h" +#include "../../localisation/StringIds.h" +#include "../../windows/Intent.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/GuestSetNameAction.h b/src/openrct2/actions/peep/GuestSetNameAction.h similarity index 97% rename from src/openrct2/actions/GuestSetNameAction.h rename to src/openrct2/actions/peep/GuestSetNameAction.h index 9fb1f7581a..d48cc38a91 100644 --- a/src/openrct2/actions/GuestSetNameAction.h +++ b/src/openrct2/actions/peep/GuestSetNameAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PeepPickupAction.cpp b/src/openrct2/actions/peep/PeepPickupAction.cpp similarity index 96% rename from src/openrct2/actions/PeepPickupAction.cpp rename to src/openrct2/actions/peep/PeepPickupAction.cpp index f24e8f1291..e36616f419 100644 --- a/src/openrct2/actions/PeepPickupAction.cpp +++ b/src/openrct2/actions/peep/PeepPickupAction.cpp @@ -9,12 +9,13 @@ #include "PeepPickupAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../Input.h" -#include "../entity/EntityRegistry.h" -#include "../entity/Peep.h" -#include "../network/Network.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../Input.h" +#include "../../entity/EntityRegistry.h" +#include "../../entity/Peep.h" +#include "../../network/Network.h" +#include "../GameActionRunner.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PeepPickupAction.h b/src/openrct2/actions/peep/PeepPickupAction.h similarity index 96% rename from src/openrct2/actions/PeepPickupAction.h rename to src/openrct2/actions/peep/PeepPickupAction.h index b59054eb27..46f94394cd 100644 --- a/src/openrct2/actions/PeepPickupAction.h +++ b/src/openrct2/actions/peep/PeepPickupAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../Identifiers.h" -#include "GameAction.h" +#include "../../Identifiers.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PeepSpawnPlaceAction.cpp b/src/openrct2/actions/peep/PeepSpawnPlaceAction.cpp similarity index 93% rename from src/openrct2/actions/PeepSpawnPlaceAction.cpp rename to src/openrct2/actions/peep/PeepSpawnPlaceAction.cpp index 4dad0df46c..64d165babf 100644 --- a/src/openrct2/actions/PeepSpawnPlaceAction.cpp +++ b/src/openrct2/actions/peep/PeepSpawnPlaceAction.cpp @@ -9,16 +9,16 @@ #include "PeepSpawnPlaceAction.h" -#include "../Cheats.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Cheats.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/PeepSpawnPlaceAction.h b/src/openrct2/actions/peep/PeepSpawnPlaceAction.h similarity index 97% rename from src/openrct2/actions/PeepSpawnPlaceAction.h rename to src/openrct2/actions/peep/PeepSpawnPlaceAction.h index 274455beb0..5b2a9ff402 100644 --- a/src/openrct2/actions/PeepSpawnPlaceAction.h +++ b/src/openrct2/actions/peep/PeepSpawnPlaceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffFireAction.cpp b/src/openrct2/actions/peep/StaffFireAction.cpp similarity index 93% rename from src/openrct2/actions/StaffFireAction.cpp rename to src/openrct2/actions/peep/StaffFireAction.cpp index 0c06e4563d..2d7052ded7 100644 --- a/src/openrct2/actions/StaffFireAction.cpp +++ b/src/openrct2/actions/peep/StaffFireAction.cpp @@ -9,12 +9,12 @@ #include "StaffFireAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../drawing/Drawing.h" -#include "../entity/EntityRegistry.h" -#include "../entity/Staff.h" -#include "../ui/WindowManager.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../drawing/Drawing.h" +#include "../../entity/EntityRegistry.h" +#include "../../entity/Staff.h" +#include "../../ui/WindowManager.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffFireAction.h b/src/openrct2/actions/peep/StaffFireAction.h similarity index 97% rename from src/openrct2/actions/StaffFireAction.h rename to src/openrct2/actions/peep/StaffFireAction.h index 8c0841e92d..c0b226a35e 100644 --- a/src/openrct2/actions/StaffFireAction.h +++ b/src/openrct2/actions/peep/StaffFireAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffHireNewAction.cpp b/src/openrct2/actions/peep/StaffHireNewAction.cpp similarity index 94% rename from src/openrct2/actions/StaffHireNewAction.cpp rename to src/openrct2/actions/peep/StaffHireNewAction.cpp index 70699388cd..56b5481c73 100644 --- a/src/openrct2/actions/StaffHireNewAction.cpp +++ b/src/openrct2/actions/peep/StaffHireNewAction.cpp @@ -9,25 +9,25 @@ #include "StaffHireNewAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../entity/EntityList.h" -#include "../entity/EntityRegistry.h" -#include "../entity/Staff.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../object/ObjectManager.h" -#include "../object/PeepAnimationsObject.h" -#include "../ride/Ride.h" -#include "../scenario/Scenario.h" -#include "../ui/WindowManager.h" -#include "../world/Entrance.h" -#include "../world/Map.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../entity/EntityList.h" +#include "../../entity/EntityRegistry.h" +#include "../../entity/Staff.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../object/ObjectManager.h" +#include "../../object/PeepAnimationsObject.h" +#include "../../ride/Ride.h" +#include "../../scenario/Scenario.h" +#include "../../ui/WindowManager.h" +#include "../../world/Entrance.h" +#include "../../world/Map.h" +#include "../../world/Park.h" #include diff --git a/src/openrct2/actions/StaffHireNewAction.h b/src/openrct2/actions/peep/StaffHireNewAction.h similarity index 96% rename from src/openrct2/actions/StaffHireNewAction.h rename to src/openrct2/actions/peep/StaffHireNewAction.h index cd30b6ec18..51bc78a0b0 100644 --- a/src/openrct2/actions/StaffHireNewAction.h +++ b/src/openrct2/actions/peep/StaffHireNewAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../entity/Staff.h" -#include "GameAction.h" +#include "../../entity/Staff.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetColourAction.cpp b/src/openrct2/actions/peep/StaffSetColourAction.cpp similarity index 88% rename from src/openrct2/actions/StaffSetColourAction.cpp rename to src/openrct2/actions/peep/StaffSetColourAction.cpp index ead9c9af13..6b4661e4bf 100644 --- a/src/openrct2/actions/StaffSetColourAction.cpp +++ b/src/openrct2/actions/peep/StaffSetColourAction.cpp @@ -9,15 +9,15 @@ #include "StaffSetColourAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../entity/EntityList.h" -#include "../entity/Staff.h" -#include "../localisation/StringIds.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../entity/EntityList.h" +#include "../../entity/Staff.h" +#include "../../localisation/StringIds.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetColourAction.h b/src/openrct2/actions/peep/StaffSetColourAction.h similarity index 94% rename from src/openrct2/actions/StaffSetColourAction.h rename to src/openrct2/actions/peep/StaffSetColourAction.h index 37f4acf07a..e79ae54b1b 100644 --- a/src/openrct2/actions/StaffSetColourAction.h +++ b/src/openrct2/actions/peep/StaffSetColourAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../entity/Staff.h" -#include "GameAction.h" +#include "../../entity/Staff.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetCostumeAction.cpp b/src/openrct2/actions/peep/StaffSetCostumeAction.cpp similarity index 91% rename from src/openrct2/actions/StaffSetCostumeAction.cpp rename to src/openrct2/actions/peep/StaffSetCostumeAction.cpp index a2e622c406..92ded7142e 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.cpp +++ b/src/openrct2/actions/peep/StaffSetCostumeAction.cpp @@ -9,15 +9,15 @@ #include "StaffSetCostumeAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../entity/EntityRegistry.h" -#include "../localisation/StringIds.h" -#include "../object/ObjectManager.h" -#include "../object/PeepAnimationsObject.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../entity/EntityRegistry.h" +#include "../../localisation/StringIds.h" +#include "../../object/ObjectManager.h" +#include "../../object/PeepAnimationsObject.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetCostumeAction.h b/src/openrct2/actions/peep/StaffSetCostumeAction.h similarity index 95% rename from src/openrct2/actions/StaffSetCostumeAction.h rename to src/openrct2/actions/peep/StaffSetCostumeAction.h index e7e868b3b0..63d6e8b5ff 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.h +++ b/src/openrct2/actions/peep/StaffSetCostumeAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../entity/Staff.h" -#include "GameAction.h" +#include "../../entity/Staff.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetNameAction.cpp b/src/openrct2/actions/peep/StaffSetNameAction.cpp similarity index 88% rename from src/openrct2/actions/StaffSetNameAction.cpp rename to src/openrct2/actions/peep/StaffSetNameAction.cpp index 5818a07454..3a4ed66c43 100644 --- a/src/openrct2/actions/StaffSetNameAction.cpp +++ b/src/openrct2/actions/peep/StaffSetNameAction.cpp @@ -9,17 +9,17 @@ #include "StaffSetNameAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../entity/EntityRegistry.h" -#include "../entity/Staff.h" -#include "../localisation/StringIds.h" -#include "../windows/Intent.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../entity/EntityRegistry.h" +#include "../../entity/Staff.h" +#include "../../localisation/StringIds.h" +#include "../../windows/Intent.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetNameAction.h b/src/openrct2/actions/peep/StaffSetNameAction.h similarity index 97% rename from src/openrct2/actions/StaffSetNameAction.h rename to src/openrct2/actions/peep/StaffSetNameAction.h index 29dcf578ce..9fe73c2ad1 100644 --- a/src/openrct2/actions/StaffSetNameAction.h +++ b/src/openrct2/actions/peep/StaffSetNameAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetOrdersAction.cpp b/src/openrct2/actions/peep/StaffSetOrdersAction.cpp similarity index 91% rename from src/openrct2/actions/StaffSetOrdersAction.cpp rename to src/openrct2/actions/peep/StaffSetOrdersAction.cpp index c6c67ac034..e15cb47de9 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.cpp +++ b/src/openrct2/actions/peep/StaffSetOrdersAction.cpp @@ -9,14 +9,14 @@ #include "StaffSetOrdersAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../entity/EntityRegistry.h" -#include "../entity/Staff.h" -#include "../localisation/StringIds.h" -#include "../ui/WindowManager.h" -#include "../windows/Intent.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../entity/EntityRegistry.h" +#include "../../entity/Staff.h" +#include "../../localisation/StringIds.h" +#include "../../ui/WindowManager.h" +#include "../../windows/Intent.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetOrdersAction.h b/src/openrct2/actions/peep/StaffSetOrdersAction.h similarity index 97% rename from src/openrct2/actions/StaffSetOrdersAction.h rename to src/openrct2/actions/peep/StaffSetOrdersAction.h index a1538eea1c..1a999b07dc 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.h +++ b/src/openrct2/actions/peep/StaffSetOrdersAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp b/src/openrct2/actions/peep/StaffSetPatrolAreaAction.cpp similarity index 92% rename from src/openrct2/actions/StaffSetPatrolAreaAction.cpp rename to src/openrct2/actions/peep/StaffSetPatrolAreaAction.cpp index 6126d636ec..12c64b59fe 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.cpp +++ b/src/openrct2/actions/peep/StaffSetPatrolAreaAction.cpp @@ -9,14 +9,14 @@ #include "StaffSetPatrolAreaAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../drawing/Drawing.h" -#include "../entity/EntityRegistry.h" -#include "../entity/PatrolArea.h" -#include "../entity/Peep.h" -#include "../entity/Staff.h" -#include "../world/Map.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../drawing/Drawing.h" +#include "../../entity/EntityRegistry.h" +#include "../../entity/PatrolArea.h" +#include "../../entity/Peep.h" +#include "../../entity/Staff.h" +#include "../../world/Map.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.h b/src/openrct2/actions/peep/StaffSetPatrolAreaAction.h similarity index 97% rename from src/openrct2/actions/StaffSetPatrolAreaAction.h rename to src/openrct2/actions/peep/StaffSetPatrolAreaAction.h index 2c895cc532..828ab95245 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.h +++ b/src/openrct2/actions/peep/StaffSetPatrolAreaAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/MazePlaceTrackAction.cpp b/src/openrct2/actions/ride/MazePlaceTrackAction.cpp similarity index 92% rename from src/openrct2/actions/MazePlaceTrackAction.cpp rename to src/openrct2/actions/ride/MazePlaceTrackAction.cpp index cbe10d5cec..8e46b5ebf1 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.cpp +++ b/src/openrct2/actions/ride/MazePlaceTrackAction.cpp @@ -6,22 +6,23 @@ * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ + #include "MazePlaceTrackAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/Guard.hpp" -#include "../management/Finance.h" -#include "../ride/MazeCost.h" -#include "../ride/RideData.h" -#include "../ride/TrackData.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/Wall.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" -#include "../world/tile_element/TrackElement.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/Guard.hpp" +#include "../../management/Finance.h" +#include "../../ride/MazeCost.h" +#include "../../ride/RideData.h" +#include "../../ride/TrackData.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../../world/tile_element/TrackElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/MazePlaceTrackAction.h b/src/openrct2/actions/ride/MazePlaceTrackAction.h similarity index 97% rename from src/openrct2/actions/MazePlaceTrackAction.h rename to src/openrct2/actions/ride/MazePlaceTrackAction.h index f118d14e33..0b4d3af7c6 100644 --- a/src/openrct2/actions/MazePlaceTrackAction.h +++ b/src/openrct2/actions/ride/MazePlaceTrackAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/MazeSetTrackAction.cpp b/src/openrct2/actions/ride/MazeSetTrackAction.cpp similarity index 94% rename from src/openrct2/actions/MazeSetTrackAction.cpp rename to src/openrct2/actions/ride/MazeSetTrackAction.cpp index 2c9bc4e023..cdbecc8c45 100644 --- a/src/openrct2/actions/MazeSetTrackAction.cpp +++ b/src/openrct2/actions/ride/MazeSetTrackAction.cpp @@ -9,25 +9,25 @@ #include "MazeSetTrackAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/Guard.hpp" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/MazeCost.h" -#include "../ride/RideData.h" -#include "../ride/Track.h" -#include "../ride/TrackData.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/Wall.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" -#include "../world/tile_element/TrackElement.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/Guard.hpp" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/MazeCost.h" +#include "../../ride/RideData.h" +#include "../../ride/Track.h" +#include "../../ride/TrackData.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../../world/tile_element/TrackElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/MazeSetTrackAction.h b/src/openrct2/actions/ride/MazeSetTrackAction.h similarity index 97% rename from src/openrct2/actions/MazeSetTrackAction.h rename to src/openrct2/actions/ride/MazeSetTrackAction.h index a7db54aa18..deb818d185 100644 --- a/src/openrct2/actions/MazeSetTrackAction.h +++ b/src/openrct2/actions/ride/MazeSetTrackAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideCreateAction.cpp b/src/openrct2/actions/ride/RideCreateAction.cpp similarity index 92% rename from src/openrct2/actions/RideCreateAction.cpp rename to src/openrct2/actions/ride/RideCreateAction.cpp index dace05ba1f..9ee18e2f14 100644 --- a/src/openrct2/actions/RideCreateAction.cpp +++ b/src/openrct2/actions/ride/RideCreateAction.cpp @@ -9,22 +9,22 @@ #include "RideCreateAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/Memory.hpp" -#include "../core/MemoryStream.h" -#include "../localisation/Localisation.Date.h" -#include "../localisation/StringIds.h" -#include "../object/ObjectLimits.h" -#include "../object/ObjectManager.h" -#include "../ride/Ride.h" -#include "../ride/RideData.h" -#include "../ride/ShopItem.h" -#include "../ride/Station.h" -#include "../ui/WindowManager.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/Memory.hpp" +#include "../../core/MemoryStream.h" +#include "../../localisation/Localisation.Date.h" +#include "../../localisation/StringIds.h" +#include "../../object/ObjectLimits.h" +#include "../../object/ObjectManager.h" +#include "../../ride/Ride.h" +#include "../../ride/RideData.h" +#include "../../ride/ShopItem.h" +#include "../../ride/Station.h" +#include "../../ui/WindowManager.h" +#include "../../world/Park.h" #include @@ -186,15 +186,15 @@ namespace OpenRCT2::GameActions ride->departFlags = RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH | 3; const auto& rtd = ride->getRideTypeDescriptor(); - if (rtd.HasFlag(RtdFlag::allowMusic)) + if (rtd.flags.has(RtdFlag::allowMusic)) { auto& objManager = GetContext()->GetObjectManager(); ride->music = objManager.GetLoadedObjectEntryIndex(rtd.DefaultMusic); if (ride->music != kObjectEntryIndexNull) { - if (rtd.HasFlag(RtdFlag::hasMusicByDefault)) + if (rtd.flags.has(RtdFlag::hasMusicByDefault)) { - ride->lifecycleFlags |= RIDE_LIFECYCLE_MUSIC; + ride->flags.set(RideFlag::music); } } } @@ -262,7 +262,7 @@ namespace OpenRCT2::GameActions } // Set the on-ride photo price, whether the ride has one or not (except shops). - if (!rtd.HasFlag(RtdFlag::isShopOrFacility) && ShopItemHasCommonPrice(ShopItem::photo)) + if (!rtd.flags.has(RtdFlag::isShopOrFacility) && ShopItemHasCommonPrice(ShopItem::photo)) { auto price = ShopItemGetCommonPrice(ride, ShopItem::photo); if (price != kMoney64Undefined) @@ -288,7 +288,7 @@ namespace OpenRCT2::GameActions ride->profit = kMoney64Undefined; ride->entranceStyle = kObjectEntryIndexNull; - if (rtd.HasFlag(RtdFlag::hasEntranceAndExit)) + if (rtd.flags.has(RtdFlag::hasEntranceAndExit)) { ride->entranceStyle = _entranceObjectIndex; } diff --git a/src/openrct2/actions/RideCreateAction.h b/src/openrct2/actions/ride/RideCreateAction.h similarity index 98% rename from src/openrct2/actions/RideCreateAction.h rename to src/openrct2/actions/ride/RideCreateAction.h index 893294415a..68fa63751b 100644 --- a/src/openrct2/actions/RideCreateAction.h +++ b/src/openrct2/actions/ride/RideCreateAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideDemolishAction.cpp b/src/openrct2/actions/ride/RideDemolishAction.cpp similarity index 91% rename from src/openrct2/actions/RideDemolishAction.cpp rename to src/openrct2/actions/ride/RideDemolishAction.cpp index 68a1df124c..fe3404eb84 100644 --- a/src/openrct2/actions/RideDemolishAction.cpp +++ b/src/openrct2/actions/ride/RideDemolishAction.cpp @@ -9,26 +9,28 @@ #include "RideDemolishAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../drawing/ScrollingText.h" -#include "../entity/EntityList.h" -#include "../management/NewsItem.h" -#include "../peep/RideUseSystem.h" -#include "../ride/Ride.h" -#include "../ride/RideData.h" -#include "../ui/WindowManager.h" -#include "../world/Banner.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/TrackElement.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../Game.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../drawing/ScrollingText.h" +#include "../../entity/EntityList.h" +#include "../../management/NewsItem.h" +#include "../../peep/RideUseSystem.h" +#include "../../ride/Ride.h" +#include "../../ride/RideData.h" +#include "../../ui/WindowManager.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/TrackElement.h" +#include "../GameActionRunner.h" +#include "../track/TrackRemoveAction.h" #include "MazeSetTrackAction.h" -#include "TrackRemoveAction.h" namespace OpenRCT2::GameActions { @@ -65,7 +67,7 @@ namespace OpenRCT2::GameActions return Result(Status::invalidParameters, STR_CANT_DEMOLISH_RIDE, STR_ERR_RIDE_NOT_FOUND); } - if ((ride->lifecycleFlags & (RIDE_LIFECYCLE_INDESTRUCTIBLE | RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + if ((ride->flags.hasAny(RideFlag::indestructible, RideFlag::indestructibleTrack) && _modifyType == RideModifyType::demolish) && !gameState.cheats.makeAllDestructible) { @@ -88,8 +90,7 @@ namespace OpenRCT2::GameActions return Result(Status::disallowed, STR_CANT_REFURBISH_RIDE, STR_RIDE_NOT_YET_EMPTY); } - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_EVER_BEEN_OPENED) - || ride->getRideTypeDescriptor().AvailableBreakdowns == 0) + if (!ride->flags.has(RideFlag::everBeenOpened) || ride->getRideTypeDescriptor().AvailableBreakdowns == 0) { return Result(Status::disallowed, STR_CANT_REFURBISH_RIDE, STR_CANT_REFURBISH_NOT_NEEDED); } @@ -277,7 +278,7 @@ namespace OpenRCT2::GameActions ride.renew(); - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_EVER_BEEN_OPENED; + ride.flags.unset(RideFlag::everBeenOpened); ride.lastCrashType = RIDE_CRASH_TYPE_NONE; ride.windowInvalidateFlags.set(RideInvalidateFlag::maintenance, RideInvalidateFlag::customers); diff --git a/src/openrct2/actions/RideDemolishAction.h b/src/openrct2/actions/ride/RideDemolishAction.h similarity index 98% rename from src/openrct2/actions/RideDemolishAction.h rename to src/openrct2/actions/ride/RideDemolishAction.h index 6bacbd2d7e..e6931086cd 100644 --- a/src/openrct2/actions/RideDemolishAction.h +++ b/src/openrct2/actions/ride/RideDemolishAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp b/src/openrct2/actions/ride/RideEntranceExitPlaceAction.cpp similarity index 94% rename from src/openrct2/actions/RideEntranceExitPlaceAction.cpp rename to src/openrct2/actions/ride/RideEntranceExitPlaceAction.cpp index 2f9faddcb9..19c32f7b3e 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.cpp +++ b/src/openrct2/actions/ride/RideEntranceExitPlaceAction.cpp @@ -9,19 +9,20 @@ #include "RideEntranceExitPlaceAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../actions/RideEntranceExitRemoveAction.h" -#include "../core/Guard.hpp" -#include "../management/Finance.h" -#include "../ride/Ride.h" -#include "../ride/Station.h" -#include "../world/ConstructionClearance.h" -#include "../world/Map.h" -#include "../world/MapAnimation.h" -#include "../world/Wall.h" -#include "../world/tile_element/EntranceElement.h" -#include "../world/tile_element/Slope.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/Guard.hpp" +#include "../../management/Finance.h" +#include "../../ride/Ride.h" +#include "../../ride/Station.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Map.h" +#include "../../world/MapAnimation.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/EntranceElement.h" +#include "../../world/tile_element/Slope.h" +#include "../GameActionRunner.h" +#include "RideEntranceExitRemoveAction.h" namespace OpenRCT2::GameActions { @@ -79,7 +80,7 @@ namespace OpenRCT2::GameActions return Result(Status::notClosed, errorTitle, STR_MUST_BE_CLOSED_FIRST); } - if (ride->lifecycleFlags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + if (ride->flags.has(RideFlag::indestructibleTrack)) { return Result(Status::disallowed, errorTitle, STR_NOT_ALLOWED_TO_MODIFY_STATION); } diff --git a/src/openrct2/actions/RideEntranceExitPlaceAction.h b/src/openrct2/actions/ride/RideEntranceExitPlaceAction.h similarity index 95% rename from src/openrct2/actions/RideEntranceExitPlaceAction.h rename to src/openrct2/actions/ride/RideEntranceExitPlaceAction.h index 2e35c9acc3..07e0cb7bd2 100644 --- a/src/openrct2/actions/RideEntranceExitPlaceAction.h +++ b/src/openrct2/actions/ride/RideEntranceExitPlaceAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../world/Entrance.h" -#include "GameAction.h" +#include "../../world/Entrance.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp b/src/openrct2/actions/ride/RideEntranceExitRemoveAction.cpp similarity index 95% rename from src/openrct2/actions/RideEntranceExitRemoveAction.cpp rename to src/openrct2/actions/ride/RideEntranceExitRemoveAction.cpp index 4dc2335210..73f0ecd43b 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.cpp +++ b/src/openrct2/actions/ride/RideEntranceExitRemoveAction.cpp @@ -9,13 +9,13 @@ #include "RideEntranceExitRemoveAction.h" -#include "../Diagnostic.h" -#include "../ride/Ride.h" -#include "../ride/Station.h" -#include "../world/Entrance.h" -#include "../world/Map.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/EntranceElement.h" +#include "../../Diagnostic.h" +#include "../../ride/Ride.h" +#include "../../ride/Station.h" +#include "../../world/Entrance.h" +#include "../../world/Map.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/EntranceElement.h" namespace OpenRCT2::GameActions { @@ -81,7 +81,7 @@ namespace OpenRCT2::GameActions return Result(Status::invalidParameters, STR_MUST_BE_CLOSED_FIRST, kStringIdNone); } - if (ride->lifecycleFlags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + if (ride->flags.has(RideFlag::indestructibleTrack)) { return Result(Status::invalidParameters, STR_NOT_ALLOWED_TO_MODIFY_STATION, kStringIdNone); } diff --git a/src/openrct2/actions/RideEntranceExitRemoveAction.h b/src/openrct2/actions/ride/RideEntranceExitRemoveAction.h similarity index 97% rename from src/openrct2/actions/RideEntranceExitRemoveAction.h rename to src/openrct2/actions/ride/RideEntranceExitRemoveAction.h index ba118a1892..106abb074d 100644 --- a/src/openrct2/actions/RideEntranceExitRemoveAction.h +++ b/src/openrct2/actions/ride/RideEntranceExitRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideFreezeRatingAction.cpp b/src/openrct2/actions/ride/RideFreezeRatingAction.cpp similarity index 95% rename from src/openrct2/actions/RideFreezeRatingAction.cpp rename to src/openrct2/actions/ride/RideFreezeRatingAction.cpp index f7844e324b..41b802745d 100644 --- a/src/openrct2/actions/RideFreezeRatingAction.cpp +++ b/src/openrct2/actions/ride/RideFreezeRatingAction.cpp @@ -9,8 +9,8 @@ #include "RideFreezeRatingAction.h" -#include "../Diagnostic.h" -#include "../ui/WindowManager.h" +#include "../../Diagnostic.h" +#include "../../ui/WindowManager.h" namespace OpenRCT2::GameActions { @@ -69,7 +69,7 @@ namespace OpenRCT2::GameActions break; } - ride->lifecycleFlags |= RIDE_LIFECYCLE_FIXED_RATINGS; + ride->flags.set(RideFlag::fixedRatings); auto* windowMgr = Ui::GetWindowManager(); windowMgr->InvalidateByNumber(WindowClass::ride, _rideIndex.ToUnderlying()); diff --git a/src/openrct2/actions/RideFreezeRatingAction.h b/src/openrct2/actions/ride/RideFreezeRatingAction.h similarity index 97% rename from src/openrct2/actions/RideFreezeRatingAction.h rename to src/openrct2/actions/ride/RideFreezeRatingAction.h index 2e79429888..7e3bbbbfd0 100644 --- a/src/openrct2/actions/RideFreezeRatingAction.h +++ b/src/openrct2/actions/ride/RideFreezeRatingAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetAppearanceAction.cpp b/src/openrct2/actions/ride/RideSetAppearanceAction.cpp similarity index 93% rename from src/openrct2/actions/RideSetAppearanceAction.cpp rename to src/openrct2/actions/ride/RideSetAppearanceAction.cpp index 71b98728b5..0a56e6a4ac 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.cpp +++ b/src/openrct2/actions/ride/RideSetAppearanceAction.cpp @@ -9,16 +9,16 @@ #include "RideSetAppearanceAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../localisation/StringIds.h" -#include "../ride/Ride.h" -#include "../ui/WindowManager.h" -#include "../world/Map.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../localisation/StringIds.h" +#include "../../ride/Ride.h" +#include "../../ui/WindowManager.h" +#include "../../world/Map.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { @@ -139,7 +139,7 @@ namespace OpenRCT2::GameActions GfxInvalidateScreen(); break; case RideSetAppearanceType::SellingItemColourIsRandom: - ride->setLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS, static_cast(_value)); + ride->flags.set(RideFlag::randomShopColours, static_cast(_value)); break; } diff --git a/src/openrct2/actions/RideSetAppearanceAction.h b/src/openrct2/actions/ride/RideSetAppearanceAction.h similarity index 98% rename from src/openrct2/actions/RideSetAppearanceAction.h rename to src/openrct2/actions/ride/RideSetAppearanceAction.h index 8d6b06d878..a2a169aa79 100644 --- a/src/openrct2/actions/RideSetAppearanceAction.h +++ b/src/openrct2/actions/ride/RideSetAppearanceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetColourSchemeAction.cpp b/src/openrct2/actions/ride/RideSetColourSchemeAction.cpp similarity index 91% rename from src/openrct2/actions/RideSetColourSchemeAction.cpp rename to src/openrct2/actions/ride/RideSetColourSchemeAction.cpp index 31030b11ce..7f83a704ab 100644 --- a/src/openrct2/actions/RideSetColourSchemeAction.cpp +++ b/src/openrct2/actions/ride/RideSetColourSchemeAction.cpp @@ -9,14 +9,14 @@ #include "RideSetColourSchemeAction.h" -#include "../Cheats.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/Ride.h" -#include "../ride/RideConstruction.h" -#include "../world/Map.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/Ride.h" +#include "../../ride/RideConstruction.h" +#include "../../world/Map.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetColourSchemeAction.h b/src/openrct2/actions/ride/RideSetColourSchemeAction.h similarity index 97% rename from src/openrct2/actions/RideSetColourSchemeAction.h rename to src/openrct2/actions/ride/RideSetColourSchemeAction.h index cb59860b3e..f90ba2db35 100644 --- a/src/openrct2/actions/RideSetColourSchemeAction.h +++ b/src/openrct2/actions/ride/RideSetColourSchemeAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetNameAction.cpp b/src/openrct2/actions/ride/RideSetNameAction.cpp similarity index 88% rename from src/openrct2/actions/RideSetNameAction.cpp rename to src/openrct2/actions/ride/RideSetNameAction.cpp index 0e68b9a02e..9a99f01f2d 100644 --- a/src/openrct2/actions/RideSetNameAction.cpp +++ b/src/openrct2/actions/ride/RideSetNameAction.cpp @@ -9,17 +9,17 @@ #include "RideSetNameAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../drawing/ScrollingText.h" -#include "../localisation/StringIds.h" -#include "../ride/Ride.h" -#include "../ui/WindowManager.h" -#include "../world/Map.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../drawing/ScrollingText.h" +#include "../../localisation/StringIds.h" +#include "../../ride/Ride.h" +#include "../../ui/WindowManager.h" +#include "../../world/Map.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetNameAction.h b/src/openrct2/actions/ride/RideSetNameAction.h similarity index 97% rename from src/openrct2/actions/RideSetNameAction.h rename to src/openrct2/actions/ride/RideSetNameAction.h index b48a6e03f5..e67ab664ba 100644 --- a/src/openrct2/actions/RideSetNameAction.h +++ b/src/openrct2/actions/ride/RideSetNameAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetPriceAction.cpp b/src/openrct2/actions/ride/RideSetPriceAction.cpp similarity index 93% rename from src/openrct2/actions/RideSetPriceAction.cpp rename to src/openrct2/actions/ride/RideSetPriceAction.cpp index bbe3c3c8ea..65d566bff5 100644 --- a/src/openrct2/actions/RideSetPriceAction.cpp +++ b/src/openrct2/actions/ride/RideSetPriceAction.cpp @@ -9,18 +9,18 @@ #include "RideSetPriceAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/Ride.h" -#include "../ride/RideData.h" -#include "../ride/RideManager.hpp" -#include "../ride/ShopItem.h" -#include "../ui/WindowManager.h" -#include "../world/Map.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/Ride.h" +#include "../../ride/RideData.h" +#include "../../ride/RideManager.hpp" +#include "../../ride/ShopItem.h" +#include "../../ui/WindowManager.h" +#include "../../world/Map.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { @@ -138,7 +138,7 @@ namespace OpenRCT2::GameActions if (shopItem == ShopItem::none) { shopItem = ride->getRideTypeDescriptor().PhotoItem; - if ((ride->lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) == 0) + if (!ride->flags.has(RideFlag::onRidePhoto)) { ride->price[1] = _price; windowMgr->InvalidateByClass(WindowClass::ride); diff --git a/src/openrct2/actions/RideSetPriceAction.h b/src/openrct2/actions/ride/RideSetPriceAction.h similarity index 97% rename from src/openrct2/actions/RideSetPriceAction.h rename to src/openrct2/actions/ride/RideSetPriceAction.h index 12630228ff..2bf57383e4 100644 --- a/src/openrct2/actions/RideSetPriceAction.h +++ b/src/openrct2/actions/ride/RideSetPriceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetSettingAction.cpp b/src/openrct2/actions/ride/RideSetSettingAction.cpp similarity index 94% rename from src/openrct2/actions/RideSetSettingAction.cpp rename to src/openrct2/actions/ride/RideSetSettingAction.cpp index 6d3b0fdbe6..b91805d50c 100644 --- a/src/openrct2/actions/RideSetSettingAction.cpp +++ b/src/openrct2/actions/ride/RideSetSettingAction.cpp @@ -9,16 +9,16 @@ #include "RideSetSettingAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../drawing/Drawing.h" -#include "../object/MusicObject.h" -#include "../object/ObjectManager.h" -#include "../ride/Ride.h" -#include "../ride/RideData.h" -#include "../ui/WindowManager.h" -#include "../world/Map.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../drawing/Drawing.h" +#include "../../object/MusicObject.h" +#include "../../object/ObjectManager.h" +#include "../../ride/Ride.h" +#include "../../ride/RideData.h" +#include "../../ui/WindowManager.h" +#include "../../world/Map.h" namespace OpenRCT2::GameActions { @@ -60,7 +60,7 @@ namespace OpenRCT2::GameActions switch (_setting) { case RideSetSetting::Mode: - if (ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride->flags.has(RideFlag::brokenDown)) { return Result(Status::disallowed, STR_CANT_CHANGE_OPERATING_MODE, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); } @@ -127,7 +127,7 @@ namespace OpenRCT2::GameActions } break; case RideSetSetting::NumCircuits: - if (ride->lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT && _value > 1) + if (ride->flags.has(RideFlag::cableLift) && _value > 1) { return Result( Status::invalidParameters, STR_CANT_CHANGE_OPERATING_MODE, @@ -194,16 +194,16 @@ namespace OpenRCT2::GameActions if (_value == EnumValue(RideInspection::never)) { - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; + ride->flags.unset(RideFlag::dueInspection); } ride->inspectionInterval = static_cast(_value); break; case RideSetSetting::Music: - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_MUSIC; + ride->flags.unset(RideFlag::music); if (_value) { - ride->lifecycleFlags |= RIDE_LIFECYCLE_MUSIC; + ride->flags.set(RideFlag::music); } ride->windowInvalidateFlags.set(RideInvalidateFlag::music); break; @@ -297,7 +297,7 @@ namespace OpenRCT2::GameActions case RideMode::backwardRotation: return STR_CANT_CHANGE_NUMBER_OF_ROTATIONS; default: - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::noVehicles)) { return STR_CANT_CHANGE_THIS; } diff --git a/src/openrct2/actions/RideSetSettingAction.h b/src/openrct2/actions/ride/RideSetSettingAction.h similarity index 98% rename from src/openrct2/actions/RideSetSettingAction.h rename to src/openrct2/actions/ride/RideSetSettingAction.h index d971853fad..513feaf2fa 100644 --- a/src/openrct2/actions/RideSetSettingAction.h +++ b/src/openrct2/actions/ride/RideSetSettingAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetStatusAction.cpp b/src/openrct2/actions/ride/RideSetStatusAction.cpp similarity index 91% rename from src/openrct2/actions/RideSetStatusAction.cpp rename to src/openrct2/actions/ride/RideSetStatusAction.cpp index 2d37ec1418..795ac1aeba 100644 --- a/src/openrct2/actions/RideSetStatusAction.cpp +++ b/src/openrct2/actions/ride/RideSetStatusAction.cpp @@ -9,17 +9,17 @@ #include "RideSetStatusAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../core/MemoryStream.h" -#include "../localisation/Formatter.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/Ride.h" -#include "../ui/WindowManager.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "ResultWithMessage.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/Formatter.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/Ride.h" +#include "../../ui/WindowManager.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../ResultWithMessage.h" namespace OpenRCT2::GameActions { @@ -83,7 +83,7 @@ namespace OpenRCT2::GameActions ride->formatNameTo(ft); if (_status != ride->status) { - if (_status == RideStatus::simulating && (ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + if (_status == RideStatus::simulating && ride->flags.has(RideFlag::brokenDown)) { // Simulating will force clear the track, so make sure player can't cheat around a break down res.error = Status::disallowed; @@ -150,23 +150,23 @@ namespace OpenRCT2::GameActions case RideStatus::closed: if (ride->status == _status || ride->status == RideStatus::simulating) { - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + if (!ride->flags.has(RideFlag::brokenDown)) { - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_CRASHED; + ride->flags.unset(RideFlag::crashed); RideClearForConstruction(*ride); ride->removePeeps(); } } ride->status = RideStatus::closed; - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; + ride->flags.unset(RideFlag::passStationNoStopping); ride->raceWinner = EntityId::GetNull(); ride->windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); windowMgr->InvalidateByNumber(WindowClass::ride, _rideIndex.ToUnderlying()); break; case RideStatus::simulating: { - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_CRASHED; + ride->flags.unset(RideFlag::crashed); RideClearForConstruction(*ride); ride->removePeeps(); @@ -179,7 +179,7 @@ namespace OpenRCT2::GameActions } ride->status = _status; - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; + ride->flags.unset(RideFlag::passStationNoStopping); ride->raceWinner = EntityId::GetNull(); ride->currentIssues = 0; ride->lastIssueTime = 0; diff --git a/src/openrct2/actions/RideSetStatusAction.h b/src/openrct2/actions/ride/RideSetStatusAction.h similarity index 97% rename from src/openrct2/actions/RideSetStatusAction.h rename to src/openrct2/actions/ride/RideSetStatusAction.h index 1a6b490522..6c6767c581 100644 --- a/src/openrct2/actions/RideSetStatusAction.h +++ b/src/openrct2/actions/ride/RideSetStatusAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/RideSetVehicleAction.cpp b/src/openrct2/actions/ride/RideSetVehicleAction.cpp similarity index 91% rename from src/openrct2/actions/RideSetVehicleAction.cpp rename to src/openrct2/actions/ride/RideSetVehicleAction.cpp index bba6028979..33399a4585 100644 --- a/src/openrct2/actions/RideSetVehicleAction.cpp +++ b/src/openrct2/actions/ride/RideSetVehicleAction.cpp @@ -9,21 +9,21 @@ #include "RideSetVehicleAction.h" -#include "../Cheats.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/EnumUtils.hpp" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../localisation/StringIds.h" -#include "../management/Research.h" -#include "../object/ObjectManager.h" -#include "../ride/Ride.h" -#include "../ride/RideData.h" -#include "../ui/WindowManager.h" -#include "../world/Map.h" -#include "../world/Park.h" +#include "../../Cheats.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../core/EnumUtils.hpp" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../localisation/StringIds.h" +#include "../../management/Research.h" +#include "../../object/ObjectManager.h" +#include "../../ride/Ride.h" +#include "../../ride/RideData.h" +#include "../../ui/WindowManager.h" +#include "../../world/Map.h" +#include "../../world/Park.h" namespace OpenRCT2::GameActions { @@ -76,7 +76,7 @@ namespace OpenRCT2::GameActions return Result(Status::invalidParameters, errTitle, STR_ERR_RIDE_NOT_FOUND); } - if (ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride->flags.has(RideFlag::brokenDown)) { return Result(Status::broken, errTitle, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING); } @@ -194,7 +194,7 @@ namespace OpenRCT2::GameActions ride->removePeeps(); ride->vehicleChangeTimeout = 100; - ride->setLifecycleFlag(RIDE_LIFECYCLE_REVERSED_TRAINS, _value); + ride->flags.set(RideFlag::reversedTrains, static_cast(_value)); break; } @@ -230,7 +230,7 @@ namespace OpenRCT2::GameActions const auto& rtd = ride.getRideTypeDescriptor(); if (gameState.cheats.showVehiclesFromOtherTrackTypes && !( - ride.getRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide) || rtd.specialType == RtdSpecialType::maze + ride.getRideTypeDescriptor().flags.has(RtdFlag::isFlatRide) || rtd.specialType == RtdSpecialType::maze || rtd.specialType == RtdSpecialType::miniGolf)) { selectionShouldBeExpanded = true; @@ -249,7 +249,7 @@ namespace OpenRCT2::GameActions { if (selectionShouldBeExpanded) { - if (GetRideTypeDescriptor(rideTypeIterator).HasFlag(RtdFlag::isFlatRide)) + if (GetRideTypeDescriptor(rideTypeIterator).flags.has(RtdFlag::isFlatRide)) continue; const auto& rtd = GetRideTypeDescriptor(rideTypeIterator); diff --git a/src/openrct2/actions/RideSetVehicleAction.h b/src/openrct2/actions/ride/RideSetVehicleAction.h similarity index 98% rename from src/openrct2/actions/RideSetVehicleAction.h rename to src/openrct2/actions/ride/RideSetVehicleAction.h index be760513fd..1be1f2af0f 100644 --- a/src/openrct2/actions/RideSetVehicleAction.h +++ b/src/openrct2/actions/ride/RideSetVehicleAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ride/RideSetVisibilityAction.cpp b/src/openrct2/actions/ride/RideSetVisibilityAction.cpp new file mode 100644 index 0000000000..33303c52ea --- /dev/null +++ b/src/openrct2/actions/ride/RideSetVisibilityAction.cpp @@ -0,0 +1,74 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "RideSetVisibilityAction.h" + +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/TrackElement.h" +#include "../GameAction.hpp" + +namespace OpenRCT2::GameActions +{ + RideSetVisibilityAction::RideSetVisibilityAction(RideId rideIndex, RideSetVisibilityType visiblity) + : _rideIndex(rideIndex) + , _visibility(visiblity) + { + } + + void RideSetVisibilityAction::AcceptParameters(GameActionParameterVisitor& visitor) + { + visitor.Visit("ride", _rideIndex); + visitor.Visit("visiblity", _visibility); + } + + uint16_t RideSetVisibilityAction::GetActionFlags() const + { + return GameAction::GetActionFlags() | Flags::AllowWhilePaused; + } + + void RideSetVisibilityAction::Serialise(DataSerialiser& stream) + { + GameAction::Serialise(stream); + stream << DS_TAG(_rideIndex) << DS_TAG(_visibility); + } + + Result RideSetVisibilityAction::Query(GameState_t& gameState) const + { + if (EnumValue(_visibility) >= 2) + { + LOG_ERROR("Invalid visibility type %d", _visibility); + return Result(Status::invalidParameters, STR_CANT_CHANGE_THIS, STR_ERR_VALUE_OUT_OF_RANGE); + } + + return Result(); + } + + Result RideSetVisibilityAction::Execute(GameState_t& gameState) const + { + for (int32_t y = 1; y <= gameState.mapSize.y; y++) + { + for (int32_t x = 1; x <= gameState.mapSize.x; x++) + { + const TileCoordsXY tileCoords{ x, y }; + for (auto* trackElement : TileElementsView(tileCoords)) + { + if (trackElement->GetRideIndex() == _rideIndex) + { + trackElement->SetInvisible(_visibility == RideSetVisibilityType::invisible); + MapInvalidateTileFull(tileCoords.ToCoordsXY()); + } + } + } + } + + return Result(); + } +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/ride/RideSetVisibilityAction.h b/src/openrct2/actions/ride/RideSetVisibilityAction.h new file mode 100644 index 0000000000..714b3fe024 --- /dev/null +++ b/src/openrct2/actions/ride/RideSetVisibilityAction.h @@ -0,0 +1,40 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../GameAction.hpp" + +namespace OpenRCT2::GameActions +{ + enum class RideSetVisibilityType : uint8_t + { + invisible, + visible, + }; + + class RideSetVisibilityAction final : public GameActionBase + { + private: + RideId _rideIndex{ RideId::GetNull() }; + RideSetVisibilityType _visibility{}; + + public: + RideSetVisibilityAction() = default; + RideSetVisibilityAction(RideId rideIndex, RideSetVisibilityType visibility); + + void AcceptParameters(GameActionParameterVisitor& visitor) override; + + uint16_t GetActionFlags() const override; + + void Serialise(DataSerialiser& stream) override; + Result Query(GameState_t& gameState) const override; + Result Execute(GameState_t& gameState) const override; + }; +} // namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/BannerPlaceAction.cpp b/src/openrct2/actions/scenery/BannerPlaceAction.cpp similarity index 92% rename from src/openrct2/actions/BannerPlaceAction.cpp rename to src/openrct2/actions/scenery/BannerPlaceAction.cpp index 061382e1d0..37b99c3cd6 100644 --- a/src/openrct2/actions/BannerPlaceAction.cpp +++ b/src/openrct2/actions/scenery/BannerPlaceAction.cpp @@ -9,20 +9,20 @@ #include "BannerPlaceAction.h" -#include "../Diagnostic.h" -#include "../core/Guard.hpp" -#include "../management/Finance.h" -#include "../object/BannerSceneryEntry.h" -#include "../object/ObjectEntryManager.h" -#include "../world/Banner.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/MapAnimation.h" -#include "../world/Scenery.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/BannerElement.h" -#include "../world/tile_element/PathElement.h" -#include "GameAction.h" +#include "../../Diagnostic.h" +#include "../../core/Guard.hpp" +#include "../../management/Finance.h" +#include "../../object/BannerSceneryEntry.h" +#include "../../object/ObjectEntryManager.h" +#include "../../world/Banner.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/MapAnimation.h" +#include "../../world/Scenery.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/BannerElement.h" +#include "../../world/tile_element/PathElement.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BannerPlaceAction.h b/src/openrct2/actions/scenery/BannerPlaceAction.h similarity index 98% rename from src/openrct2/actions/BannerPlaceAction.h rename to src/openrct2/actions/scenery/BannerPlaceAction.h index 7847d4a189..5b011ed788 100644 --- a/src/openrct2/actions/BannerPlaceAction.h +++ b/src/openrct2/actions/scenery/BannerPlaceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::Drawing { diff --git a/src/openrct2/actions/BannerRemoveAction.cpp b/src/openrct2/actions/scenery/BannerRemoveAction.cpp similarity index 92% rename from src/openrct2/actions/BannerRemoveAction.cpp rename to src/openrct2/actions/scenery/BannerRemoveAction.cpp index 61a389a363..eeffc877f3 100644 --- a/src/openrct2/actions/BannerRemoveAction.cpp +++ b/src/openrct2/actions/scenery/BannerRemoveAction.cpp @@ -9,16 +9,16 @@ #include "BannerRemoveAction.h" -#include "../Diagnostic.h" -#include "../management/Finance.h" -#include "../object/BannerSceneryEntry.h" -#include "../object/ObjectEntryManager.h" -#include "../world/Banner.h" -#include "../world/Map.h" -#include "../world/Scenery.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/BannerElement.h" -#include "GameAction.h" +#include "../../Diagnostic.h" +#include "../../management/Finance.h" +#include "../../object/BannerSceneryEntry.h" +#include "../../object/ObjectEntryManager.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" +#include "../../world/Scenery.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/BannerElement.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BannerRemoveAction.h b/src/openrct2/actions/scenery/BannerRemoveAction.h similarity index 97% rename from src/openrct2/actions/BannerRemoveAction.h rename to src/openrct2/actions/scenery/BannerRemoveAction.h index d2063d321f..ba6176ee8c 100644 --- a/src/openrct2/actions/BannerRemoveAction.h +++ b/src/openrct2/actions/scenery/BannerRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BannerSetColourAction.cpp b/src/openrct2/actions/scenery/BannerSetColourAction.cpp similarity index 92% rename from src/openrct2/actions/BannerSetColourAction.cpp rename to src/openrct2/actions/scenery/BannerSetColourAction.cpp index 33c62fd37d..88823ab616 100644 --- a/src/openrct2/actions/BannerSetColourAction.cpp +++ b/src/openrct2/actions/scenery/BannerSetColourAction.cpp @@ -9,14 +9,14 @@ #include "BannerSetColourAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../management/Finance.h" -#include "../windows/Intent.h" -#include "../world/Banner.h" -#include "../world/Map.h" -#include "../world/tile_element/BannerElement.h" -#include "GameAction.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../management/Finance.h" +#include "../../windows/Intent.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" +#include "../../world/tile_element/BannerElement.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BannerSetColourAction.h b/src/openrct2/actions/scenery/BannerSetColourAction.h similarity index 97% rename from src/openrct2/actions/BannerSetColourAction.h rename to src/openrct2/actions/scenery/BannerSetColourAction.h index 34eff768c0..0079345f72 100644 --- a/src/openrct2/actions/BannerSetColourAction.h +++ b/src/openrct2/actions/scenery/BannerSetColourAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::Drawing { diff --git a/src/openrct2/actions/BannerSetNameAction.cpp b/src/openrct2/actions/scenery/BannerSetNameAction.cpp similarity index 88% rename from src/openrct2/actions/BannerSetNameAction.cpp rename to src/openrct2/actions/scenery/BannerSetNameAction.cpp index 28c2fff100..4cc2d4e4c7 100644 --- a/src/openrct2/actions/BannerSetNameAction.cpp +++ b/src/openrct2/actions/scenery/BannerSetNameAction.cpp @@ -9,17 +9,17 @@ #include "BannerSetNameAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../core/String.hpp" -#include "../drawing/Drawing.h" -#include "../drawing/ScrollingText.h" -#include "../localisation/StringIds.h" -#include "../windows/Intent.h" -#include "../world/Banner.h" -#include "../world/Map.h" -#include "../world/tile_element/BannerElement.h" -#include "GameAction.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../core/String.hpp" +#include "../../drawing/Drawing.h" +#include "../../drawing/ScrollingText.h" +#include "../../localisation/StringIds.h" +#include "../../windows/Intent.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" +#include "../../world/tile_element/BannerElement.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BannerSetNameAction.h b/src/openrct2/actions/scenery/BannerSetNameAction.h similarity index 97% rename from src/openrct2/actions/BannerSetNameAction.h rename to src/openrct2/actions/scenery/BannerSetNameAction.h index 38d9bbd35f..6339aa0c7b 100644 --- a/src/openrct2/actions/BannerSetNameAction.h +++ b/src/openrct2/actions/scenery/BannerSetNameAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BannerSetStyleAction.cpp b/src/openrct2/actions/scenery/BannerSetStyleAction.cpp similarity index 94% rename from src/openrct2/actions/BannerSetStyleAction.cpp rename to src/openrct2/actions/scenery/BannerSetStyleAction.cpp index bdfeb415f1..5606ad5aa3 100644 --- a/src/openrct2/actions/BannerSetStyleAction.cpp +++ b/src/openrct2/actions/scenery/BannerSetStyleAction.cpp @@ -9,17 +9,16 @@ #include "BannerSetStyleAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../drawing/Drawing.h" -#include "../drawing/ScrollingText.h" -#include "../localisation/StringIdType.h" -#include "../management/Finance.h" -#include "../windows/Intent.h" -#include "../world/Banner.h" -#include "../world/Map.h" -#include "../world/tile_element/BannerElement.h" -#include "GameAction.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../drawing/Drawing.h" +#include "../../drawing/ScrollingText.h" +#include "../../localisation/StringIdType.h" +#include "../../management/Finance.h" +#include "../../windows/Intent.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" +#include "../../world/tile_element/BannerElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/BannerSetStyleAction.h b/src/openrct2/actions/scenery/BannerSetStyleAction.h similarity index 98% rename from src/openrct2/actions/BannerSetStyleAction.h rename to src/openrct2/actions/scenery/BannerSetStyleAction.h index 7af76d3981..1a650a6ffb 100644 --- a/src/openrct2/actions/BannerSetStyleAction.h +++ b/src/openrct2/actions/scenery/BannerSetStyleAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/scenery/LargeSceneryPlaceAction.cpp similarity index 94% rename from src/openrct2/actions/LargeSceneryPlaceAction.cpp rename to src/openrct2/actions/scenery/LargeSceneryPlaceAction.cpp index be0c2ef032..e31f7b1678 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp +++ b/src/openrct2/actions/scenery/LargeSceneryPlaceAction.cpp @@ -9,26 +9,26 @@ #include "LargeSceneryPlaceAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/Guard.hpp" -#include "../management/Finance.h" -#include "../object/LargeSceneryEntry.h" -#include "../object/ObjectEntryManager.h" -#include "../object/ObjectLimits.h" -#include "../ride/Ride.h" -#include "../ride/RideConstruction.h" -#include "../world/Banner.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/MapAnimation.h" -#include "../world/QuarterTile.h" -#include "../world/Wall.h" -#include "../world/tile_element/LargeSceneryElement.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/Guard.hpp" +#include "../../management/Finance.h" +#include "../../object/LargeSceneryEntry.h" +#include "../../object/ObjectEntryManager.h" +#include "../../object/ObjectLimits.h" +#include "../../ride/Ride.h" +#include "../../ride/RideConstruction.h" +#include "../../world/Banner.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/MapAnimation.h" +#include "../../world/QuarterTile.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/LargeSceneryElement.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.h b/src/openrct2/actions/scenery/LargeSceneryPlaceAction.h similarity index 98% rename from src/openrct2/actions/LargeSceneryPlaceAction.h rename to src/openrct2/actions/scenery/LargeSceneryPlaceAction.h index f62c879173..915f8aca01 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.h +++ b/src/openrct2/actions/scenery/LargeSceneryPlaceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2 { diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.cpp b/src/openrct2/actions/scenery/LargeSceneryRemoveAction.cpp similarity index 94% rename from src/openrct2/actions/LargeSceneryRemoveAction.cpp rename to src/openrct2/actions/scenery/LargeSceneryRemoveAction.cpp index 15e577e66f..7ff1e4f572 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.cpp +++ b/src/openrct2/actions/scenery/LargeSceneryRemoveAction.cpp @@ -9,19 +9,19 @@ #include "LargeSceneryRemoveAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../object/LargeSceneryEntry.h" -#include "../ride/Ride.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/LargeSceneryElement.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../object/LargeSceneryEntry.h" +#include "../../ride/Ride.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/LargeSceneryElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LargeSceneryRemoveAction.h b/src/openrct2/actions/scenery/LargeSceneryRemoveAction.h similarity index 97% rename from src/openrct2/actions/LargeSceneryRemoveAction.h rename to src/openrct2/actions/scenery/LargeSceneryRemoveAction.h index 2c6ad2c9df..48da222d14 100644 --- a/src/openrct2/actions/LargeSceneryRemoveAction.h +++ b/src/openrct2/actions/scenery/LargeSceneryRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LargeScenerySetColourAction.cpp b/src/openrct2/actions/scenery/LargeScenerySetColourAction.cpp similarity index 95% rename from src/openrct2/actions/LargeScenerySetColourAction.cpp rename to src/openrct2/actions/scenery/LargeScenerySetColourAction.cpp index 5b72796811..d3c31b3102 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.cpp +++ b/src/openrct2/actions/scenery/LargeScenerySetColourAction.cpp @@ -9,14 +9,14 @@ #include "LargeScenerySetColourAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../management/Finance.h" -#include "../object/LargeSceneryEntry.h" -#include "../world/Map.h" -#include "../world/Scenery.h" -#include "../world/tile_element/LargeSceneryElement.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../management/Finance.h" +#include "../../object/LargeSceneryEntry.h" +#include "../../world/Map.h" +#include "../../world/Scenery.h" +#include "../../world/tile_element/LargeSceneryElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LargeScenerySetColourAction.h b/src/openrct2/actions/scenery/LargeScenerySetColourAction.h similarity index 98% rename from src/openrct2/actions/LargeScenerySetColourAction.h rename to src/openrct2/actions/scenery/LargeScenerySetColourAction.h index 98d9b8811a..7a32f36307 100644 --- a/src/openrct2/actions/LargeScenerySetColourAction.h +++ b/src/openrct2/actions/scenery/LargeScenerySetColourAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ScenerySetRestrictedAction.cpp b/src/openrct2/actions/scenery/ScenerySetRestrictedAction.cpp similarity index 96% rename from src/openrct2/actions/ScenerySetRestrictedAction.cpp rename to src/openrct2/actions/scenery/ScenerySetRestrictedAction.cpp index d9b7a5cb69..ac25d5f428 100644 --- a/src/openrct2/actions/ScenerySetRestrictedAction.cpp +++ b/src/openrct2/actions/scenery/ScenerySetRestrictedAction.cpp @@ -9,8 +9,8 @@ #include "ScenerySetRestrictedAction.h" -#include "../object/SceneryGroupObject.h" -#include "../world/Scenery.h" +#include "../../object/SceneryGroupObject.h" +#include "../../world/Scenery.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ScenerySetRestrictedAction.h b/src/openrct2/actions/scenery/ScenerySetRestrictedAction.h similarity index 97% rename from src/openrct2/actions/ScenerySetRestrictedAction.h rename to src/openrct2/actions/scenery/ScenerySetRestrictedAction.h index cf88c98037..bcc7d4cf2a 100644 --- a/src/openrct2/actions/ScenerySetRestrictedAction.h +++ b/src/openrct2/actions/scenery/ScenerySetRestrictedAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SignSetNameAction.cpp b/src/openrct2/actions/scenery/SignSetNameAction.cpp similarity index 93% rename from src/openrct2/actions/SignSetNameAction.cpp rename to src/openrct2/actions/scenery/SignSetNameAction.cpp index 8a9fd2bdd1..566f7edd58 100644 --- a/src/openrct2/actions/SignSetNameAction.cpp +++ b/src/openrct2/actions/scenery/SignSetNameAction.cpp @@ -9,14 +9,14 @@ #include "SignSetNameAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../drawing/Drawing.h" -#include "../drawing/ScrollingText.h" -#include "../localisation/StringIds.h" -#include "../ride/Ride.h" -#include "../world/Banner.h" -#include "../world/Map.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../drawing/Drawing.h" +#include "../../drawing/ScrollingText.h" +#include "../../localisation/StringIds.h" +#include "../../ride/Ride.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" #include diff --git a/src/openrct2/actions/SignSetNameAction.h b/src/openrct2/actions/scenery/SignSetNameAction.h similarity index 97% rename from src/openrct2/actions/SignSetNameAction.h rename to src/openrct2/actions/scenery/SignSetNameAction.h index 0f1374d681..3345904d60 100644 --- a/src/openrct2/actions/SignSetNameAction.h +++ b/src/openrct2/actions/scenery/SignSetNameAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SignSetStyleAction.cpp b/src/openrct2/actions/scenery/SignSetStyleAction.cpp similarity index 92% rename from src/openrct2/actions/SignSetStyleAction.cpp rename to src/openrct2/actions/scenery/SignSetStyleAction.cpp index 702ced6e9b..444a9bbd7c 100644 --- a/src/openrct2/actions/SignSetStyleAction.cpp +++ b/src/openrct2/actions/scenery/SignSetStyleAction.cpp @@ -9,17 +9,17 @@ #include "SignSetStyleAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../localisation/StringIds.h" -#include "../windows/Intent.h" -#include "../world/Banner.h" -#include "../world/Map.h" -#include "../world/Scenery.h" -#include "../world/tile_element/LargeSceneryElement.h" -#include "../world/tile_element/WallElement.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../localisation/StringIds.h" +#include "../../windows/Intent.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" +#include "../../world/Scenery.h" +#include "../../world/tile_element/LargeSceneryElement.h" +#include "../../world/tile_element/WallElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SignSetStyleAction.h b/src/openrct2/actions/scenery/SignSetStyleAction.h similarity index 97% rename from src/openrct2/actions/SignSetStyleAction.h rename to src/openrct2/actions/scenery/SignSetStyleAction.h index ae80ec6a10..6b9129b71a 100644 --- a/src/openrct2/actions/SignSetStyleAction.h +++ b/src/openrct2/actions/scenery/SignSetStyleAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/scenery/SmallSceneryPlaceAction.cpp similarity index 95% rename from src/openrct2/actions/SmallSceneryPlaceAction.cpp rename to src/openrct2/actions/scenery/SmallSceneryPlaceAction.cpp index a87cac7182..720c6d3e80 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp +++ b/src/openrct2/actions/scenery/SmallSceneryPlaceAction.cpp @@ -9,29 +9,29 @@ #include "SmallSceneryPlaceAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../object/ObjectEntryManager.h" -#include "../object/SmallSceneryEntry.h" -#include "../ride/Ride.h" -#include "../ride/TrackDesign.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/MapAnimation.h" -#include "../world/Park.h" -#include "../world/QuarterTile.h" -#include "../world/Scenery.h" -#include "../world/Wall.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SmallSceneryElement.h" -#include "../world/tile_element/SurfaceElement.h" -#include "GameAction.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../object/ObjectEntryManager.h" +#include "../../object/SmallSceneryEntry.h" +#include "../../ride/Ride.h" +#include "../../ride/TrackDesign.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/MapAnimation.h" +#include "../../world/Park.h" +#include "../../world/QuarterTile.h" +#include "../../world/Scenery.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SmallSceneryElement.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../GameAction.hpp" #include "SmallSceneryRemoveAction.h" namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.h b/src/openrct2/actions/scenery/SmallSceneryPlaceAction.h similarity index 98% rename from src/openrct2/actions/SmallSceneryPlaceAction.h rename to src/openrct2/actions/scenery/SmallSceneryPlaceAction.h index eceeb296fd..56d78e1f29 100644 --- a/src/openrct2/actions/SmallSceneryPlaceAction.h +++ b/src/openrct2/actions/scenery/SmallSceneryPlaceAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.cpp b/src/openrct2/actions/scenery/SmallSceneryRemoveAction.cpp similarity index 90% rename from src/openrct2/actions/SmallSceneryRemoveAction.cpp rename to src/openrct2/actions/scenery/SmallSceneryRemoveAction.cpp index d812907f36..97d3fc8c03 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.cpp +++ b/src/openrct2/actions/scenery/SmallSceneryRemoveAction.cpp @@ -9,21 +9,20 @@ #include "SmallSceneryRemoveAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../object/ObjectEntryManager.h" -#include "../object/SmallSceneryEntry.h" -#include "../ride/Ride.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/SmallSceneryElement.h" -#include "GameAction.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../object/ObjectEntryManager.h" +#include "../../object/SmallSceneryEntry.h" +#include "../../ride/Ride.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/SmallSceneryElement.h" #include "SmallSceneryPlaceAction.h" namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.h b/src/openrct2/actions/scenery/SmallSceneryRemoveAction.h similarity index 97% rename from src/openrct2/actions/SmallSceneryRemoveAction.h rename to src/openrct2/actions/scenery/SmallSceneryRemoveAction.h index 432dc704aa..b925d47d92 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.h +++ b/src/openrct2/actions/scenery/SmallSceneryRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SmallScenerySetColourAction.cpp b/src/openrct2/actions/scenery/SmallScenerySetColourAction.cpp similarity index 89% rename from src/openrct2/actions/SmallScenerySetColourAction.cpp rename to src/openrct2/actions/scenery/SmallScenerySetColourAction.cpp index 7be2ca5aa7..ef0a17c4f7 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.cpp +++ b/src/openrct2/actions/scenery/SmallScenerySetColourAction.cpp @@ -9,18 +9,18 @@ #include "SmallScenerySetColourAction.h" -#include "../Cheats.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/Ride.h" -#include "../ride/TrackDesign.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/tile_element/SmallSceneryElement.h" +#include "../../Cheats.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/Ride.h" +#include "../../ride/TrackDesign.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/tile_element/SmallSceneryElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SmallScenerySetColourAction.h b/src/openrct2/actions/scenery/SmallScenerySetColourAction.h similarity index 98% rename from src/openrct2/actions/SmallScenerySetColourAction.h rename to src/openrct2/actions/scenery/SmallScenerySetColourAction.h index 168c13d780..b3a7300340 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.h +++ b/src/openrct2/actions/scenery/SmallScenerySetColourAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WallPlaceAction.cpp b/src/openrct2/actions/scenery/WallPlaceAction.cpp similarity index 94% rename from src/openrct2/actions/WallPlaceAction.cpp rename to src/openrct2/actions/scenery/WallPlaceAction.cpp index 65b41a746c..80a558259e 100644 --- a/src/openrct2/actions/WallPlaceAction.cpp +++ b/src/openrct2/actions/scenery/WallPlaceAction.cpp @@ -9,28 +9,31 @@ #include "WallPlaceAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../management/Finance.h" -#include "../object/LargeSceneryEntry.h" -#include "../object/ObjectEntryManager.h" -#include "../object/SmallSceneryEntry.h" -#include "../object/WallSceneryEntry.h" -#include "../ride/Track.h" -#include "../ride/TrackDesign.h" -#include "../world/Banner.h" -#include "../world/ConstructionClearance.h" -#include "../world/Map.h" -#include "../world/MapAnimation.h" -#include "../world/Wall.h" -#include "../world/tile_element/LargeSceneryElement.h" -#include "../world/tile_element/PathElement.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SmallSceneryElement.h" -#include "../world/tile_element/SurfaceElement.h" -#include "../world/tile_element/TrackElement.h" -#include "../world/tile_element/WallElement.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../management/Finance.h" +#include "../../object/LargeSceneryEntry.h" +#include "../../object/ObjectEntryManager.h" +#include "../../object/SmallSceneryEntry.h" +#include "../../object/WallSceneryEntry.h" +#include "../../ride/RideData.h" +#include "../../ride/Track.h" +#include "../../ride/TrackData.h" +#include "../../ride/TrackDesign.h" +#include "../../world/Banner.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Map.h" +#include "../../world/MapAnimation.h" +#include "../../world/Scenery.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/LargeSceneryElement.h" +#include "../../world/tile_element/PathElement.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SmallSceneryElement.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../../world/tile_element/TrackElement.h" +#include "../../world/tile_element/WallElement.h" namespace OpenRCT2::GameActions { @@ -424,7 +427,7 @@ namespace OpenRCT2::GameActions return false; } - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::allowDoorsOnTrack)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::allowDoorsOnTrack)) { return false; } @@ -590,7 +593,7 @@ namespace OpenRCT2::GameActions bool WallPlaceAction::TrackIsAllowedWallEdges( ride_type_t rideType, TrackElemType trackType, uint8_t trackSequence, uint8_t direction) { - if (!GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::noWallsAroundTrack)) + if (!GetRideTypeDescriptor(rideType).flags.has(RtdFlag::noWallsAroundTrack)) { const auto& ted = GetTrackElementDescriptor(trackType); if (ted.sequences[trackSequence].allowedWallEdges & (1 << direction)) diff --git a/src/openrct2/actions/WallPlaceAction.h b/src/openrct2/actions/scenery/WallPlaceAction.h similarity index 93% rename from src/openrct2/actions/WallPlaceAction.h rename to src/openrct2/actions/scenery/WallPlaceAction.h index 5cb8bef738..7f2cd13b2d 100644 --- a/src/openrct2/actions/WallPlaceAction.h +++ b/src/openrct2/actions/scenery/WallPlaceAction.h @@ -9,11 +9,11 @@ #pragma once -#include "../ride/RideData.h" -#include "../ride/TrackData.h" -#include "../world/Banner.h" -#include "../world/Scenery.h" -#include "GameAction.h" +// #include "../../../ride/RideData.h" +// #include "../../../ride/TrackData.h" +// #include "../../../world/Banner.h" +// #include "../../../world/Scenery.h" +#include "../GameAction.hpp" namespace OpenRCT2 { diff --git a/src/openrct2/actions/WallRemoveAction.cpp b/src/openrct2/actions/scenery/WallRemoveAction.cpp similarity index 89% rename from src/openrct2/actions/WallRemoveAction.cpp rename to src/openrct2/actions/scenery/WallRemoveAction.cpp index 3003f0b580..56e99137a5 100644 --- a/src/openrct2/actions/WallRemoveAction.cpp +++ b/src/openrct2/actions/scenery/WallRemoveAction.cpp @@ -9,16 +9,16 @@ #include "WallRemoveAction.h" -#include "../Cheats.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../core/MemoryStream.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/TileElementsView.h" -#include "../world/tile_element/WallElement.h" +#include "../../Cheats.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../core/MemoryStream.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/TileElementsView.h" +#include "../../world/tile_element/WallElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WallRemoveAction.h b/src/openrct2/actions/scenery/WallRemoveAction.h similarity index 97% rename from src/openrct2/actions/WallRemoveAction.h rename to src/openrct2/actions/scenery/WallRemoveAction.h index 1a233da064..2948265b5c 100644 --- a/src/openrct2/actions/WallRemoveAction.h +++ b/src/openrct2/actions/scenery/WallRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WallSetColourAction.cpp b/src/openrct2/actions/scenery/WallSetColourAction.cpp similarity index 93% rename from src/openrct2/actions/WallSetColourAction.cpp rename to src/openrct2/actions/scenery/WallSetColourAction.cpp index 8c20a8c572..c4995b5e0d 100644 --- a/src/openrct2/actions/WallSetColourAction.cpp +++ b/src/openrct2/actions/scenery/WallSetColourAction.cpp @@ -9,17 +9,17 @@ #include "WallSetColourAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../management/Finance.h" -#include "../object/WallSceneryEntry.h" -#include "../ride/Track.h" -#include "../ride/TrackData.h" -#include "../world/Banner.h" -#include "../world/Map.h" -#include "../world/Scenery.h" -#include "../world/tile_element/WallElement.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../management/Finance.h" +#include "../../object/WallSceneryEntry.h" +#include "../../ride/Track.h" +#include "../../ride/TrackData.h" +#include "../../world/Banner.h" +#include "../../world/Map.h" +#include "../../world/Scenery.h" +#include "../../world/tile_element/WallElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WallSetColourAction.h b/src/openrct2/actions/scenery/WallSetColourAction.h similarity index 97% rename from src/openrct2/actions/WallSetColourAction.h rename to src/openrct2/actions/scenery/WallSetColourAction.h index 70c9e08969..42523c809f 100644 --- a/src/openrct2/actions/WallSetColourAction.h +++ b/src/openrct2/actions/scenery/WallSetColourAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ClearAction.cpp b/src/openrct2/actions/terraform/ClearAction.cpp similarity index 93% rename from src/openrct2/actions/ClearAction.cpp rename to src/openrct2/actions/terraform/ClearAction.cpp index 8bf6667bd6..1b2fe2bc92 100644 --- a/src/openrct2/actions/ClearAction.cpp +++ b/src/openrct2/actions/terraform/ClearAction.cpp @@ -9,21 +9,22 @@ #include "ClearAction.h" -#include "../Context.h" -#include "../GameState.h" -#include "../core/MemoryStream.h" -#include "../drawing/Drawing.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../world/Location.hpp" -#include "../world/Map.h" -#include "../world/tile_element/LargeSceneryElement.h" -#include "../world/tile_element/PathElement.h" -#include "../world/tile_element/SmallSceneryElement.h" -#include "FootpathRemoveAction.h" -#include "LargeSceneryRemoveAction.h" -#include "SmallSceneryRemoveAction.h" -#include "WallRemoveAction.h" +#include "../../Context.h" +#include "../../GameState.h" +#include "../../core/MemoryStream.h" +#include "../../drawing/Drawing.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../world/Location.hpp" +#include "../../world/Map.h" +#include "../../world/tile_element/LargeSceneryElement.h" +#include "../../world/tile_element/PathElement.h" +#include "../../world/tile_element/SmallSceneryElement.h" +#include "../GameActionRunner.h" +#include "../footpath/FootpathRemoveAction.h" +#include "../scenery/LargeSceneryRemoveAction.h" +#include "../scenery/SmallSceneryRemoveAction.h" +#include "../scenery/WallRemoveAction.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/ClearAction.h b/src/openrct2/actions/terraform/ClearAction.h similarity index 95% rename from src/openrct2/actions/ClearAction.h rename to src/openrct2/actions/terraform/ClearAction.h index d087b25157..15fd008266 100644 --- a/src/openrct2/actions/ClearAction.h +++ b/src/openrct2/actions/terraform/ClearAction.h @@ -9,9 +9,9 @@ #pragma once -#include "../OpenRCT2.h" -#include "../management/Finance.h" -#include "GameAction.h" +#include "../../OpenRCT2.h" +#include "../../management/Finance.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandLowerAction.cpp b/src/openrct2/actions/terraform/LandLowerAction.cpp similarity index 88% rename from src/openrct2/actions/LandLowerAction.cpp rename to src/openrct2/actions/terraform/LandLowerAction.cpp index c2fde776ee..601fdb6ff7 100644 --- a/src/openrct2/actions/LandLowerAction.cpp +++ b/src/openrct2/actions/terraform/LandLowerAction.cpp @@ -9,23 +9,24 @@ #include "LandLowerAction.h" -#include "../Context.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../actions/LandSetHeightAction.h" -#include "../audio/Audio.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/RideConstruction.h" -#include "../ride/RideData.h" -#include "../windows/Intent.h" -#include "../world/Map.h" -#include "../world/MapSelection.h" -#include "../world/Park.h" -#include "../world/Scenery.h" -#include "../world/SurfaceData.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Context.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../audio/Audio.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/RideConstruction.h" +#include "../../ride/RideData.h" +#include "../../windows/Intent.h" +#include "../../world/Map.h" +#include "../../world/MapSelection.h" +#include "../../world/Park.h" +#include "../../world/Scenery.h" +#include "../../world/SurfaceData.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../GameActionRunner.h" +#include "LandSetHeightAction.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandLowerAction.h b/src/openrct2/actions/terraform/LandLowerAction.h similarity index 97% rename from src/openrct2/actions/LandLowerAction.h rename to src/openrct2/actions/terraform/LandLowerAction.h index a9aba164be..45a9455a8e 100644 --- a/src/openrct2/actions/LandLowerAction.h +++ b/src/openrct2/actions/terraform/LandLowerAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" enum class MapSelectType : uint8_t; diff --git a/src/openrct2/actions/LandRaiseAction.cpp b/src/openrct2/actions/terraform/LandRaiseAction.cpp similarity index 88% rename from src/openrct2/actions/LandRaiseAction.cpp rename to src/openrct2/actions/terraform/LandRaiseAction.cpp index aa55d8d7ab..c47bb53c67 100644 --- a/src/openrct2/actions/LandRaiseAction.cpp +++ b/src/openrct2/actions/terraform/LandRaiseAction.cpp @@ -10,23 +10,24 @@ #include "LandRaiseAction.h" -#include "../Context.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../actions/LandSetHeightAction.h" -#include "../audio/Audio.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/RideConstruction.h" -#include "../ride/RideData.h" -#include "../windows/Intent.h" -#include "../world/Map.h" -#include "../world/MapSelection.h" -#include "../world/Park.h" -#include "../world/Scenery.h" -#include "../world/SurfaceData.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Context.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../audio/Audio.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/RideConstruction.h" +#include "../../ride/RideData.h" +#include "../../windows/Intent.h" +#include "../../world/Map.h" +#include "../../world/MapSelection.h" +#include "../../world/Park.h" +#include "../../world/Scenery.h" +#include "../../world/SurfaceData.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../GameActionRunner.h" +#include "LandSetHeightAction.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandRaiseAction.h b/src/openrct2/actions/terraform/LandRaiseAction.h similarity index 97% rename from src/openrct2/actions/LandRaiseAction.h rename to src/openrct2/actions/terraform/LandRaiseAction.h index 36b9ade0f2..3a476dc06f 100644 --- a/src/openrct2/actions/LandRaiseAction.h +++ b/src/openrct2/actions/terraform/LandRaiseAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" enum class MapSelectType : uint8_t; diff --git a/src/openrct2/actions/LandSetHeightAction.cpp b/src/openrct2/actions/terraform/LandSetHeightAction.cpp similarity index 93% rename from src/openrct2/actions/LandSetHeightAction.cpp rename to src/openrct2/actions/terraform/LandSetHeightAction.cpp index 24b23b2120..3376aac7bc 100644 --- a/src/openrct2/actions/LandSetHeightAction.cpp +++ b/src/openrct2/actions/terraform/LandSetHeightAction.cpp @@ -9,26 +9,26 @@ #include "LandSetHeightAction.h" -#include "../Context.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../object/SmallSceneryEntry.h" -#include "../ride/RideData.h" -#include "../windows/Intent.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/Scenery.h" -#include "../world/TileElementsView.h" -#include "../world/Wall.h" -#include "../world/tile_element/PathElement.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SmallSceneryElement.h" -#include "../world/tile_element/SurfaceElement.h" -#include "../world/tile_element/TrackElement.h" +#include "../../Context.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../object/SmallSceneryEntry.h" +#include "../../ride/RideData.h" +#include "../../windows/Intent.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/Scenery.h" +#include "../../world/TileElementsView.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/PathElement.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SmallSceneryElement.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../../world/tile_element/TrackElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandSetHeightAction.h b/src/openrct2/actions/terraform/LandSetHeightAction.h similarity index 98% rename from src/openrct2/actions/LandSetHeightAction.h rename to src/openrct2/actions/terraform/LandSetHeightAction.h index b6a0fe93c6..ae1e21abcf 100644 --- a/src/openrct2/actions/LandSetHeightAction.h +++ b/src/openrct2/actions/terraform/LandSetHeightAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/LandSmoothAction.cpp b/src/openrct2/actions/terraform/LandSmoothAction.cpp similarity index 97% rename from src/openrct2/actions/LandSmoothAction.cpp rename to src/openrct2/actions/terraform/LandSmoothAction.cpp index 07616351ee..707e4ee068 100644 --- a/src/openrct2/actions/LandSmoothAction.cpp +++ b/src/openrct2/actions/terraform/LandSmoothAction.cpp @@ -9,24 +9,25 @@ #include "LandSmoothAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../OpenRCT2.h" -#include "../actions/LandLowerAction.h" -#include "../actions/LandRaiseAction.h" -#include "../actions/LandSetHeightAction.h" -#include "../audio/Audio.h" -#include "../localisation/StringIds.h" -#include "../management/Finance.h" -#include "../ride/RideData.h" -#include "../windows/Intent.h" -#include "../world/Map.h" -#include "../world/MapSelection.h" -#include "../world/Park.h" -#include "../world/Scenery.h" -#include "../world/SurfaceData.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../OpenRCT2.h" +#include "../../audio/Audio.h" +#include "../../localisation/StringIds.h" +#include "../../management/Finance.h" +#include "../../ride/RideData.h" +#include "../../windows/Intent.h" +#include "../../world/Map.h" +#include "../../world/MapSelection.h" +#include "../../world/Park.h" +#include "../../world/Scenery.h" +#include "../../world/SurfaceData.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../GameActionRunner.h" +#include "LandLowerAction.h" +#include "LandRaiseAction.h" +#include "LandSetHeightAction.h" #include diff --git a/src/openrct2/actions/LandSmoothAction.h b/src/openrct2/actions/terraform/LandSmoothAction.h similarity index 98% rename from src/openrct2/actions/LandSmoothAction.h rename to src/openrct2/actions/terraform/LandSmoothAction.h index bedab19c47..04d28e6f14 100644 --- a/src/openrct2/actions/LandSmoothAction.h +++ b/src/openrct2/actions/terraform/LandSmoothAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" enum class MapSelectType : uint8_t; diff --git a/src/openrct2/actions/SurfaceSetStyleAction.cpp b/src/openrct2/actions/terraform/SurfaceSetStyleAction.cpp similarity index 94% rename from src/openrct2/actions/SurfaceSetStyleAction.cpp rename to src/openrct2/actions/terraform/SurfaceSetStyleAction.cpp index 072175d4a4..04f770f28e 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.cpp +++ b/src/openrct2/actions/terraform/SurfaceSetStyleAction.cpp @@ -9,18 +9,18 @@ #include "SurfaceSetStyleAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../management/Finance.h" -#include "../object/ObjectManager.h" -#include "../object/TerrainEdgeObject.h" -#include "../object/TerrainSurfaceObject.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../management/Finance.h" +#include "../../object/ObjectManager.h" +#include "../../object/TerrainEdgeObject.h" +#include "../../object/TerrainSurfaceObject.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/SurfaceSetStyleAction.h b/src/openrct2/actions/terraform/SurfaceSetStyleAction.h similarity index 97% rename from src/openrct2/actions/SurfaceSetStyleAction.h rename to src/openrct2/actions/terraform/SurfaceSetStyleAction.h index c47d961c18..f347f71410 100644 --- a/src/openrct2/actions/SurfaceSetStyleAction.h +++ b/src/openrct2/actions/terraform/SurfaceSetStyleAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WaterLowerAction.cpp b/src/openrct2/actions/terraform/WaterLowerAction.cpp similarity index 95% rename from src/openrct2/actions/WaterLowerAction.cpp rename to src/openrct2/actions/terraform/WaterLowerAction.cpp index 1d045872d7..067e1f9e39 100644 --- a/src/openrct2/actions/WaterLowerAction.cpp +++ b/src/openrct2/actions/terraform/WaterLowerAction.cpp @@ -9,12 +9,13 @@ #include "WaterLowerAction.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../audio/Audio.h" -#include "../ride/RideConstruction.h" -#include "../world/Map.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../audio/Audio.h" +#include "../../ride/RideConstruction.h" +#include "../../world/Map.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../GameActionRunner.h" #include "WaterSetHeightAction.h" namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/WaterLowerAction.h b/src/openrct2/actions/terraform/WaterLowerAction.h similarity index 97% rename from src/openrct2/actions/WaterLowerAction.h rename to src/openrct2/actions/terraform/WaterLowerAction.h index ca9642f0bf..4e8c689966 100644 --- a/src/openrct2/actions/WaterLowerAction.h +++ b/src/openrct2/actions/terraform/WaterLowerAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WaterRaiseAction.cpp b/src/openrct2/actions/terraform/WaterRaiseAction.cpp similarity index 96% rename from src/openrct2/actions/WaterRaiseAction.cpp rename to src/openrct2/actions/terraform/WaterRaiseAction.cpp index e118e02b94..bb427a2ec3 100644 --- a/src/openrct2/actions/WaterRaiseAction.cpp +++ b/src/openrct2/actions/terraform/WaterRaiseAction.cpp @@ -9,12 +9,13 @@ #include "WaterRaiseAction.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../audio/Audio.h" -#include "../ride/RideConstruction.h" -#include "../world/Map.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../audio/Audio.h" +#include "../../ride/RideConstruction.h" +#include "../../world/Map.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../GameActionRunner.h" #include "WaterSetHeightAction.h" namespace OpenRCT2::GameActions diff --git a/src/openrct2/actions/WaterRaiseAction.h b/src/openrct2/actions/terraform/WaterRaiseAction.h similarity index 97% rename from src/openrct2/actions/WaterRaiseAction.h rename to src/openrct2/actions/terraform/WaterRaiseAction.h index adc69bfaa3..d025316347 100644 --- a/src/openrct2/actions/WaterRaiseAction.h +++ b/src/openrct2/actions/terraform/WaterRaiseAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WaterSetHeightAction.cpp b/src/openrct2/actions/terraform/WaterSetHeightAction.cpp similarity index 93% rename from src/openrct2/actions/WaterSetHeightAction.cpp rename to src/openrct2/actions/terraform/WaterSetHeightAction.cpp index ffd0208ce6..a707195511 100644 --- a/src/openrct2/actions/WaterSetHeightAction.cpp +++ b/src/openrct2/actions/terraform/WaterSetHeightAction.cpp @@ -9,16 +9,16 @@ #include "WaterSetHeightAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../OpenRCT2.h" -#include "../management/Finance.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/Park.h" -#include "../world/Wall.h" -#include "../world/tile_element/SurfaceElement.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../OpenRCT2.h" +#include "../../management/Finance.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/Park.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/SurfaceElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/WaterSetHeightAction.h b/src/openrct2/actions/terraform/WaterSetHeightAction.h similarity index 97% rename from src/openrct2/actions/WaterSetHeightAction.h rename to src/openrct2/actions/terraform/WaterSetHeightAction.h index 3b9ebc843b..0534a9b1ba 100644 --- a/src/openrct2/actions/WaterSetHeightAction.h +++ b/src/openrct2/actions/terraform/WaterSetHeightAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/TrackDesignAction.cpp b/src/openrct2/actions/track/TrackDesignAction.cpp similarity index 94% rename from src/openrct2/actions/TrackDesignAction.cpp rename to src/openrct2/actions/track/TrackDesignAction.cpp index 289d0961bc..c979a7cb99 100644 --- a/src/openrct2/actions/TrackDesignAction.cpp +++ b/src/openrct2/actions/track/TrackDesignAction.cpp @@ -9,21 +9,22 @@ #include "TrackDesignAction.h" -#include "../Context.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../config/Config.h" -#include "../management/Finance.h" -#include "../management/Research.h" -#include "../object/ObjectManager.h" -#include "../object/ObjectRepository.h" -#include "../ride/RideConstruction.h" -#include "../ride/TrackDesign.h" -#include "RideCreateAction.h" -#include "RideDemolishAction.h" -#include "RideSetNameAction.h" -#include "RideSetSettingAction.h" -#include "RideSetVehicleAction.h" +#include "../../Context.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../config/Config.h" +#include "../../management/Finance.h" +#include "../../management/Research.h" +#include "../../object/ObjectManager.h" +#include "../../object/ObjectRepository.h" +#include "../../ride/RideConstruction.h" +#include "../../ride/TrackDesign.h" +#include "../GameActionRunner.h" +#include "../ride/RideCreateAction.h" +#include "../ride/RideDemolishAction.h" +#include "../ride/RideSetNameAction.h" +#include "../ride/RideSetSettingAction.h" +#include "../ride/RideSetVehicleAction.h" namespace OpenRCT2::GameActions { @@ -246,7 +247,7 @@ namespace OpenRCT2::GameActions auto numCircuits = std::max(1, _td.operation.numCircuits); SetOperatingSettingNested(ride->id, RideSetSetting::NumCircuits, numCircuits, flags); - ride->lifecycleFlags |= RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN; + ride->flags.set(RideFlag::notCustomDesign); ride->vehicleColourSettings = _td.appearance.vehicleColourSettings; ride->entranceStyle = objManager.GetLoadedObjectEntryIndex(_td.appearance.stationObjectIdentifier); diff --git a/src/openrct2/actions/TrackDesignAction.h b/src/openrct2/actions/track/TrackDesignAction.h similarity index 95% rename from src/openrct2/actions/TrackDesignAction.h rename to src/openrct2/actions/track/TrackDesignAction.h index 2b658d2486..9fa6670e92 100644 --- a/src/openrct2/actions/TrackDesignAction.h +++ b/src/openrct2/actions/track/TrackDesignAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../ride/TrackDesign.h" -#include "GameAction.h" +#include "../../ride/TrackDesign.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/track/TrackPlaceAction.cpp similarity index 94% rename from src/openrct2/actions/TrackPlaceAction.cpp rename to src/openrct2/actions/track/TrackPlaceAction.cpp index a954687033..a8e965d795 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/track/TrackPlaceAction.cpp @@ -9,27 +9,29 @@ #include "TrackPlaceAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../core/Money.hpp" -#include "../core/Numerics.hpp" -#include "../management/Finance.h" -#include "../ride/RideData.h" -#include "../ride/Track.h" -#include "../ride/TrackData.h" -#include "../ride/TrackDesign.h" -#include "../world/ConstructionClearance.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/MapAnimation.h" -#include "../world/QuarterTile.h" -#include "../world/Wall.h" -#include "../world/tile_element/PathElement.h" -#include "../world/tile_element/Slope.h" -#include "../world/tile_element/SurfaceElement.h" -#include "../world/tile_element/TrackElement.h" -#include "ResultWithMessage.h" -#include "RideSetSettingAction.h" +#include "../../Diagnostic.h" +#include "../../Game.h" +#include "../../GameState.h" +#include "../../core/Money.hpp" +#include "../../core/Numerics.hpp" +#include "../../management/Finance.h" +#include "../../ride/RideData.h" +#include "../../ride/Track.h" +#include "../../ride/TrackData.h" +#include "../../ride/TrackDesign.h" +#include "../../world/ConstructionClearance.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/MapAnimation.h" +#include "../../world/QuarterTile.h" +#include "../../world/Wall.h" +#include "../../world/tile_element/PathElement.h" +#include "../../world/tile_element/Slope.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../../world/tile_element/TrackElement.h" +#include "../GameActionRunner.h" +#include "../ResultWithMessage.h" +#include "../ride/RideSetSettingAction.h" namespace OpenRCT2::GameActions { @@ -128,7 +130,7 @@ namespace OpenRCT2::GameActions const auto& rtd = ride->getRideTypeDescriptor(); - if ((ride->lifecycleFlags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) && _trackType == TrackElemType::endStation) + if (ride->flags.has(RideFlag::indestructibleTrack) && _trackType == TrackElemType::endStation) { return Result( Status::disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_NOT_ALLOWED_TO_MODIFY_STATION); @@ -144,11 +146,11 @@ namespace OpenRCT2::GameActions } } - if (!rtd.HasFlag(RtdFlag::isFlatRide)) + if (!rtd.flags.has(RtdFlag::isFlatRide)) { if (_trackType == TrackElemType::onRidePhoto) { - if (ride->lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) + if (ride->flags.has(RideFlag::onRidePhoto)) { return Result( Status::disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, @@ -157,7 +159,7 @@ namespace OpenRCT2::GameActions } else if (_trackType == TrackElemType::cableLiftHill) { - if (ride->lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) + if (ride->flags.has(RideFlag::cableLiftHillComponentUsed)) { return Result( Status::disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, @@ -260,7 +262,7 @@ namespace OpenRCT2::GameActions return Result(Status::invalidParameters, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_TOO_HIGH); } - auto crossingMode = (rtd.HasFlag(RtdFlag::supportsLevelCrossings) && _trackType == TrackElemType::flat) + auto crossingMode = (rtd.flags.has(RtdFlag::supportsLevelCrossings) && _trackType == TrackElemType::flat) ? CreateCrossingMode::trackOverPath : CreateCrossingMode::none; // When placing from a track design, ignore track elements from the same ride to allow it to intersect itself. @@ -313,7 +315,7 @@ namespace OpenRCT2::GameActions Status::disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE, STR_RIDE_CANT_BUILD_THIS_UNDERWATER); } - if (rtd.HasFlag(RtdFlag::trackMustBeOnWater) && !_trackDesignDrawingPreview) + if (rtd.flags.has(RtdFlag::trackMustBeOnWater) && !_trackDesignDrawingPreview) { auto surfaceElement = MapGetSurfaceElementAt(mapLoc); if (surfaceElement == nullptr) @@ -373,7 +375,7 @@ namespace OpenRCT2::GameActions { uint16_t maxHeight; - if (rtd.HasFlag(RtdFlag::listVehiclesSeparately) && rideEntry->maxHeight != 0) + if (rtd.flags.has(RtdFlag::listVehiclesSeparately) && rideEntry->maxHeight != 0) { maxHeight = rideEntry->maxHeight; } @@ -466,7 +468,7 @@ namespace OpenRCT2::GameActions clearanceZ = floor2(clearanceZ, kCoordsZStep) + baseZ; const auto mapLocWithClearance = CoordsXYRangedZ(mapLoc, baseZ, clearanceZ); - auto crossingMode = (rtd.HasFlag(RtdFlag::supportsLevelCrossings) && _trackType == TrackElemType::flat) + auto crossingMode = (rtd.flags.has(RtdFlag::supportsLevelCrossings) && _trackType == TrackElemType::flat) ? CreateCrossingMode::trackOverPath : CreateCrossingMode::none; // When placing from a track design, ignore track elements from the same ride to allow it to intersect itself. @@ -494,7 +496,7 @@ namespace OpenRCT2::GameActions if (!GetFlags().has(CommandFlag::ghost) && !gameState.cheats.disableClearanceChecks) { FootpathRemoveLitter(mapLoc); - if (rtd.HasFlag(RtdFlag::noWallsAroundTrack)) + if (rtd.flags.has(RtdFlag::noWallsAroundTrack)) { WallRemoveAt(mapLocWithClearance); } @@ -595,7 +597,7 @@ namespace OpenRCT2::GameActions trackElement->SetBrakeBoosterSpeed(_brakeSpeed); } - if (rtd.HasFlag(RtdFlag::hasLandscapeDoors)) + if (rtd.flags.has(RtdFlag::hasLandscapeDoors)) { trackElement->SetDoorAState(kLandEdgeDoorFrameClosed); trackElement->SetDoorBState(kLandEdgeDoorFrameClosed); @@ -649,7 +651,7 @@ namespace OpenRCT2::GameActions auto* tileElement = trackElement->as(); - if (rtd.HasFlag(RtdFlag::trackMustBeOnWater)) + if (rtd.flags.has(RtdFlag::trackMustBeOnWater)) { auto* waterSurfaceElement = MapGetSurfaceElementAt(mapLoc); if (waterSurfaceElement != nullptr) @@ -672,11 +674,11 @@ namespace OpenRCT2::GameActions switch (_trackType) { case TrackElemType::onRidePhoto: - ride->lifecycleFlags |= RIDE_LIFECYCLE_ON_RIDE_PHOTO; + ride->flags.set(RideFlag::onRidePhoto); InvalidateTestResults(*ride); break; case TrackElemType::cableLiftHill: - ride->lifecycleFlags |= RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED; + ride->flags.set(RideFlag::cableLiftHillComponentUsed); ride->cableLiftLoc = originLocation; InvalidateTestResults(*ride); break; diff --git a/src/openrct2/actions/TrackPlaceAction.h b/src/openrct2/actions/track/TrackPlaceAction.h similarity index 96% rename from src/openrct2/actions/TrackPlaceAction.h rename to src/openrct2/actions/track/TrackPlaceAction.h index 8604c4d09b..61b6175698 100644 --- a/src/openrct2/actions/TrackPlaceAction.h +++ b/src/openrct2/actions/track/TrackPlaceAction.h @@ -9,8 +9,8 @@ #pragma once -#include "../ride/RideConstruction.h" -#include "GameAction.h" +#include "../../ride/RideConstruction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/TrackRemoveAction.cpp b/src/openrct2/actions/track/TrackRemoveAction.cpp similarity index 95% rename from src/openrct2/actions/TrackRemoveAction.cpp rename to src/openrct2/actions/track/TrackRemoveAction.cpp index 5a0f9f43bd..f0c9483871 100644 --- a/src/openrct2/actions/TrackRemoveAction.cpp +++ b/src/openrct2/actions/track/TrackRemoveAction.cpp @@ -9,19 +9,20 @@ #include "TrackRemoveAction.h" -#include "../Diagnostic.h" -#include "../GameState.h" -#include "../management/Finance.h" -#include "../ride/RideData.h" -#include "../ride/Track.h" -#include "../ride/TrackData.h" -#include "../ride/TrackDesign.h" -#include "../world/Footpath.h" -#include "../world/Map.h" -#include "../world/tile_element/SurfaceElement.h" -#include "../world/tile_element/TrackElement.h" -#include "ResultWithMessage.h" -#include "RideSetSettingAction.h" +#include "../../Diagnostic.h" +#include "../../GameState.h" +#include "../../management/Finance.h" +#include "../../ride/RideData.h" +#include "../../ride/Track.h" +#include "../../ride/TrackData.h" +#include "../../ride/TrackDesign.h" +#include "../../world/Footpath.h" +#include "../../world/Map.h" +#include "../../world/tile_element/SurfaceElement.h" +#include "../../world/tile_element/TrackElement.h" +#include "../GameActionRunner.h" +#include "../ResultWithMessage.h" +#include "../ride/RideSetSettingAction.h" namespace OpenRCT2::GameActions { @@ -239,7 +240,7 @@ namespace OpenRCT2::GameActions price *= ted.priceModifier; price >>= 16; price = supportCosts + price; - if (ride->lifecycleFlags & RIDE_LIFECYCLE_EVER_BEEN_OPENED) + if (ride->flags.has(RideFlag::everBeenOpened)) { // 70% modifier for opened rides price = (price * 45875) / 65536; @@ -417,7 +418,7 @@ namespace OpenRCT2::GameActions } } - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::trackMustBeOnWater)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::trackMustBeOnWater)) { surfaceElement->SetHasTrackThatNeedsWater(false); } @@ -441,10 +442,10 @@ namespace OpenRCT2::GameActions switch (trackType) { case TrackElemType::onRidePhoto: - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_ON_RIDE_PHOTO; + ride->flags.unset(RideFlag::onRidePhoto); break; case TrackElemType::cableLiftHill: - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED; + ride->flags.unset(RideFlag::cableLiftHillComponentUsed); break; case TrackElemType::blockBrakes: case TrackElemType::diagBlockBrakes: @@ -498,7 +499,7 @@ namespace OpenRCT2::GameActions price *= ted.priceModifier; price >>= 16; price = supportCosts + price; - if (ride->lifecycleFlags & RIDE_LIFECYCLE_EVER_BEEN_OPENED) + if (ride->flags.has(RideFlag::everBeenOpened)) { // 70% modifier for opened rides price = (price * 45875) / 65536; diff --git a/src/openrct2/actions/TrackRemoveAction.h b/src/openrct2/actions/track/TrackRemoveAction.h similarity index 97% rename from src/openrct2/actions/TrackRemoveAction.h rename to src/openrct2/actions/track/TrackRemoveAction.h index ffad32da2f..685aa106a5 100644 --- a/src/openrct2/actions/TrackRemoveAction.h +++ b/src/openrct2/actions/track/TrackRemoveAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/TrackSetBrakeSpeedAction.cpp b/src/openrct2/actions/track/TrackSetBrakeSpeedAction.cpp similarity index 93% rename from src/openrct2/actions/TrackSetBrakeSpeedAction.cpp rename to src/openrct2/actions/track/TrackSetBrakeSpeedAction.cpp index b971dd1011..09fc7393e6 100644 --- a/src/openrct2/actions/TrackSetBrakeSpeedAction.cpp +++ b/src/openrct2/actions/track/TrackSetBrakeSpeedAction.cpp @@ -9,11 +9,11 @@ #include "TrackSetBrakeSpeedAction.h" -#include "../Diagnostic.h" -#include "../management/Finance.h" -#include "../ride/RideConstruction.h" -#include "../world/Map.h" -#include "../world/tile_element/TrackElement.h" +#include "../../Diagnostic.h" +#include "../../management/Finance.h" +#include "../../ride/RideConstruction.h" +#include "../../world/Map.h" +#include "../../world/tile_element/TrackElement.h" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/actions/TrackSetBrakeSpeedAction.h b/src/openrct2/actions/track/TrackSetBrakeSpeedAction.h similarity index 97% rename from src/openrct2/actions/TrackSetBrakeSpeedAction.h rename to src/openrct2/actions/track/TrackSetBrakeSpeedAction.h index 65447a992a..98e57baa02 100644 --- a/src/openrct2/actions/TrackSetBrakeSpeedAction.h +++ b/src/openrct2/actions/track/TrackSetBrakeSpeedAction.h @@ -9,7 +9,7 @@ #pragma once -#include "GameAction.h" +#include "../GameAction.hpp" namespace OpenRCT2::GameActions { diff --git a/src/openrct2/command_line/ConvertCommand.cpp b/src/openrct2/command_line/ConvertCommand.cpp index f9bab18bb6..3ec6c967f5 100644 --- a/src/openrct2/command_line/ConvertCommand.cpp +++ b/src/openrct2/command_line/ConvertCommand.cpp @@ -186,7 +186,6 @@ namespace OpenRCT2 break; } - assert(false); - return nullptr; + throw std::invalid_argument(String::stdFormat("Unknown file type: %d", static_cast(fileType))); } } // namespace OpenRCT2 diff --git a/src/openrct2/command_line/ParkInfoCommands.cpp b/src/openrct2/command_line/ParkInfoCommands.cpp index faad51f252..e6ae881c66 100644 --- a/src/openrct2/command_line/ParkInfoCommands.cpp +++ b/src/openrct2/command_line/ParkInfoCommands.cpp @@ -124,7 +124,7 @@ namespace OpenRCT2 Console::WriteLine("ObjectType: %s, Number of Objects: %d", typeToName[EnumValue(objType)], list.size()); for (auto& obj : list) { - if (obj.Generation == ObjectGeneration::JSON && obj.Identifier.size() == 0) + if (obj.Generation == ObjectGeneration::JSON && obj.Identifier.empty()) { // Empty object slot don't output anything continue; diff --git a/src/openrct2/command_line/sprite/SpriteAppend.cpp b/src/openrct2/command_line/sprite/SpriteAppend.cpp index c7a2a2ca9d..76feafb325 100644 --- a/src/openrct2/command_line/sprite/SpriteAppend.cpp +++ b/src/openrct2/command_line/sprite/SpriteAppend.cpp @@ -50,7 +50,7 @@ namespace OpenRCT2::CommandLine::Sprite } } - constexpr uint8_t importFlags = EnumToFlag(ImportFlags::RLE); + constexpr ImportFlags importFlags = { ImportFlag::rle }; ImageImportMeta meta = { { xOffset, yOffset }, Palette::OpenRCT2, importFlags, spriteMode }; const auto image = SpriteImageLoad(imagePath, meta); if (!image.has_value()) diff --git a/src/openrct2/command_line/sprite/SpriteCommands.cpp b/src/openrct2/command_line/sprite/SpriteCommands.cpp index 2f4919d3ba..fc1012de5a 100644 --- a/src/openrct2/command_line/sprite/SpriteCommands.cpp +++ b/src/openrct2/command_line/sprite/SpriteCommands.cpp @@ -126,7 +126,7 @@ namespace OpenRCT2::CommandLine::Sprite bool SpriteImageExport(const G1Element& spriteElement, u8string_view outPath) { const size_t pixelBufferSize = static_cast(spriteElement.width) * spriteElement.height; - auto pixelBuffer = std::make_unique(pixelBufferSize); + auto pixelBuffer = std::make_unique(pixelBufferSize); auto pixels = pixelBuffer.get(); RenderTarget rt; @@ -142,7 +142,7 @@ namespace OpenRCT2::CommandLine::Sprite ImageId(), PaletteMap::GetDefault(), spriteElement, 0, 0, spriteElement.width, spriteElement.height, pixels); GfxSpriteToBuffer(rt, args); - auto const pixels8 = rt.bits; + auto const pixels8 = reinterpret_cast(rt.bits); auto const pixelsLen = rt.LineStride() * rt.WorldHeight(); try { diff --git a/src/openrct2/command_line/sprite/SpriteFile.cpp b/src/openrct2/command_line/sprite/SpriteFile.cpp index 144293b1dc..9aa78ac6b9 100644 --- a/src/openrct2/command_line/sprite/SpriteFile.cpp +++ b/src/openrct2/command_line/sprite/SpriteFile.cpp @@ -80,15 +80,13 @@ namespace OpenRCT2::CommandLine::Sprite // New image will have its data inserted after previous image uint8_t* newElementOffset = reinterpret_cast(static_cast(Header.totalSize)); Header.totalSize += static_cast(image.Buffer.size()); - Entries.reserve(Header.numEntries); { ScopedRelativeSpriteFile scopedRelative(*this); - Data.reserve(Header.totalSize); Entries.push_back(image.Element); Entries.back().offset = newElementOffset; const auto& buffer = image.Buffer; - std::copy(buffer.begin(), buffer.end(), std::back_inserter(Data)); + Data.insert(Data.end(), buffer.begin(), buffer.end()); } } diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index e06df18931..bc9345cf61 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -50,11 +50,6 @@ static constexpr bool kEnlargedUiDefault = true; #else static constexpr bool kEnlargedUiDefault = false; #endif -#ifdef __HAIKU__ // Multi-threading is unstable here -static constexpr bool kMultiThreadingDefault = false; -#else -static constexpr bool kMultiThreadingDefault = true; -#endif namespace OpenRCT2::Config { @@ -243,7 +238,7 @@ namespace OpenRCT2::Config // Always have multi-threading disabled in debug builds, this makes things slower. model->multiThreading = false; #else - model->multiThreading = reader->GetBoolean("multithreading", kMultiThreadingDefault); + model->multiThreading = reader->GetBoolean("multithreading", true); #endif // _DEBUG model->trapCursor = reader->GetBoolean("trap_cursor", false); model->autoOpenShops = reader->GetBoolean("auto_open_shops", false); diff --git a/src/openrct2/core/DataSerialiserTraits.h b/src/openrct2/core/DataSerialiserTraits.h index 67df65a161..bddf318870 100644 --- a/src/openrct2/core/DataSerialiserTraits.h +++ b/src/openrct2/core/DataSerialiserTraits.h @@ -178,7 +178,7 @@ struct DataSerializerTraitsT static void log(OpenRCT2::IStream* stream, const std::string& str) { stream->Write("\"", 1); - if (str.size() != 0) + if (!str.empty()) { stream->Write(str.data(), str.size()); } @@ -703,7 +703,7 @@ struct DataSerializerTraitsT static void log(OpenRCT2::IStream* stream, const TrackDesignTrackElement& val) { char msg[128] = {}; - snprintf(msg, sizeof(msg), "TrackDesignTrackElement(type = %d, flags = %d)", EnumValue(val.type), val.flags); + snprintf(msg, sizeof(msg), "TrackDesignTrackElement(type = %d, flags = %d)", EnumValue(val.type), val.flags.holder); stream->Write(msg, strlen(msg)); } }; diff --git a/src/openrct2/core/EnumUtils.hpp b/src/openrct2/core/EnumUtils.hpp index 8c1bc0e2b4..ab4b7c7786 100644 --- a/src/openrct2/core/EnumUtils.hpp +++ b/src/openrct2/core/EnumUtils.hpp @@ -30,10 +30,3 @@ constexpr auto EnumValue(TEnum enumerator) noexcept { return static_cast>(enumerator); } - -template -constexpr bool HasFlag(uint64_t holder, T v) -{ - static_assert(std::is_enum_v); - return (holder & EnumToFlag(v)) != 0; -} diff --git a/src/openrct2/core/Http.WinHttp.cpp b/src/openrct2/core/Http.WinHttp.cpp index 71e9d7f7dc..671841096f 100644 --- a/src/openrct2/core/Http.WinHttp.cpp +++ b/src/openrct2/core/Http.WinHttp.cpp @@ -90,7 +90,7 @@ namespace OpenRCT2::Http { // Ignore first header as that is the HTTP version which // we don't really count as a header. - if (index != 0 && wKey.size() != 0) + if (index != 0 && !wKey.empty()) { auto key = String::toUtf8(wKey); auto value = String::toUtf8(wValue); diff --git a/src/openrct2/core/String.cpp b/src/openrct2/core/String.cpp index d68e1e72d8..8136cd6988 100644 --- a/src/openrct2/core/String.cpp +++ b/src/openrct2/core/String.cpp @@ -38,7 +38,7 @@ #include "StringBuilder.h" #include "UTF8.h" -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) +#if defined(__unix__) || defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__)) #include #define _stricmp(x, y) strcasecmp((x), (y)) #endif @@ -721,13 +721,8 @@ namespace OpenRCT2::String return escaped.str(); } - /* Case insensitive logical compare, produces the same output as Notepad++ lexicographical sort */ - // Example: - // - Guest 10 - // - Guest 99 - // - Guest 100 - // - John v2.0 - // - John v2.1 + // Case insensitive natural sort (numbers compared numerically). + // Strings starting with digits sort before alphabetic strings. int32_t logicalCmp(const char* s1, const char* s2) { const auto isDigit = [](char c) { return std::isdigit(static_cast(c)); }; @@ -737,30 +732,9 @@ namespace OpenRCT2::String bool s1StartsDigit = isDigit(*s1); bool s2StartsDigit = isDigit(*s2); if (s1StartsDigit && !s2StartsDigit) - { - return -1; // s1 (starts with digit) comes before s2 - } + return -1; if (!s1StartsDigit && s2StartsDigit) - { - return 1; // s2 (starts with digit) comes before s1 - } - - // If both start with digits, compare lexicographically - if (s1StartsDigit && s2StartsDigit) - { - while (*s1 != '\0' && *s2 != '\0') - { - char c1 = toUpper(*s1); - char c2 = toUpper(*s2); - if (c1 != c2) - { - return c1 - c2; - } - s1++; - s2++; - } - return *s1 == '\0' ? (*s2 == '\0' ? 0 : -1) : 1; - } + return 1; while (*s1 != '\0' && *s2 != '\0') { diff --git a/src/openrct2/core/String.hpp b/src/openrct2/core/String.hpp index abc6ef2326..47ea43aa92 100644 --- a/src/openrct2/core/String.hpp +++ b/src/openrct2/core/String.hpp @@ -185,7 +185,7 @@ namespace OpenRCT2::String */ constexpr std::optional utf8GetCodePointSize(std::string_view v) { - if (v.size() >= 1 && !(v[0] & 0x80)) + if (!v.empty() && !(v[0] & 0x80)) { return { 1 }; } diff --git a/src/openrct2/drawing/AVX2Drawing.cpp b/src/openrct2/drawing/AVX2Drawing.cpp index a8eda8b118..64c5806061 100644 --- a/src/openrct2/drawing/AVX2Drawing.cpp +++ b/src/openrct2/drawing/AVX2Drawing.cpp @@ -9,14 +9,17 @@ #include "../core/Guard.hpp" #include "Drawing.h" +#include "PaletteIndex.h" + +using OpenRCT2::Drawing::PaletteIndex; #ifdef __AVX2__ #include void MaskAvx2( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) { if (width == 32) { @@ -48,8 +51,8 @@ void MaskAvx2( #endif void MaskAvx2( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) { OpenRCT2::Guard::Fail("AVX2 function called on a CPU that doesn't support AVX2"); } diff --git a/src/openrct2/drawing/Drawing.Sprite.BMP.cpp b/src/openrct2/drawing/Drawing.Sprite.BMP.cpp index 7f7fa2a0cf..12ee69f0de 100644 --- a/src/openrct2/drawing/Drawing.Sprite.BMP.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.BMP.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "Drawing.h" +#include "Drawing.Sprite.h" using namespace OpenRCT2; using namespace OpenRCT2::Drawing; diff --git a/src/openrct2/drawing/Drawing.Sprite.RLE.cpp b/src/openrct2/drawing/Drawing.Sprite.RLE.cpp index 7287d26484..a0b9c9436e 100644 --- a/src/openrct2/drawing/Drawing.Sprite.RLE.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.RLE.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "Drawing.h" +#include "Drawing.Sprite.h" #include #include diff --git a/src/openrct2/drawing/Drawing.Sprite.cpp b/src/openrct2/drawing/Drawing.Sprite.cpp index 3206aca73e..acfdbf29a6 100644 --- a/src/openrct2/drawing/Drawing.Sprite.cpp +++ b/src/openrct2/drawing/Drawing.Sprite.cpp @@ -7,7 +7,7 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "Drawing.h" +#include "Drawing.Sprite.h" #include "../Context.h" #include "../Diagnostic.h" @@ -22,6 +22,7 @@ #include "../platform/Platform.h" #include "../rct1/Csg.h" #include "../ui/UiContext.h" +#include "Drawing.h" #include "ScrollingText.h" #include @@ -391,15 +392,15 @@ static void ReadAndConvertGxDat(IStream* stream, size_t count, bool is_rctc, G1E } void MaskScalar( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) { for (int32_t yy = 0; yy < height; yy++) { for (int32_t xx = 0; xx < width; xx++) { - uint8_t colour = (*colourSrc) & (*maskSrc); - if (colour != 0) + auto colour = static_cast((*colourSrc) & (*maskSrc)); + if (colour != PaletteIndex::transparent) { *dst = colour; } @@ -416,7 +417,7 @@ void MaskScalar( static void MaskMagnify( const ZoomLevel zoom, int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, - uint8_t* RESTRICT dst, int32_t maskStride, int32_t colourStride, int32_t dstStride, int32_t srcX, int32_t srcY) + PaletteIndex* RESTRICT dst, int32_t maskStride, int32_t colourStride, int32_t dstStride, int32_t srcX, int32_t srcY) { for (int32_t y = 0; y < height; y++) { @@ -425,8 +426,8 @@ static void MaskMagnify( { auto srcMask = maskSrc + (maskStride * zoom.ApplyTo(srcY + y) + zoom.ApplyTo(srcX + x)); auto srcColour = colourSrc + (colourStride * zoom.ApplyTo(srcY + y) + zoom.ApplyTo(srcX + x)); - const uint8_t colour = (*srcColour) & (*srcMask); - if (colour != 0) + const auto colour = static_cast((*srcColour) & (*srcMask)); + if (colour != PaletteIndex::transparent) { *dst = colour; } @@ -444,7 +445,7 @@ static Gx _csg = {}; static G1Element _scrollingText[ScrollingText::kMaxEntries]{}; static bool _csgLoaded = false; -static G1Element _g1Temp = {}; +static G1Element _g1Temp[kTempSpriteCount] = {}; static std::vector _imageListElements; /** @@ -823,7 +824,7 @@ void FASTCALL GfxDrawSpritePaletteSetSoftware( const int32_t offsetY = rt.y - spriteTopLeft.y; const int32_t srcX = std::max(0, offsetX); const int32_t srcY = std::max(0, offsetY); - uint8_t* dst = rt.bits + std::max(0, -offsetX) + std::max(0, -offsetY) * rt.LineStride(); + PaletteIndex* dst = rt.bits + std::max(0, -offsetX) + std::max(0, -offsetY) * rt.LineStride(); DrawSpriteArgs args(imageId, paletteMap, *g1, srcX, srcY, width, height, dst); GfxSpriteToBuffer(rt, args); @@ -940,7 +941,7 @@ void FASTCALL GfxDrawSpritePaletteSetSoftware( dest_start_x = zoomLevel.ApplyInversedTo(dest_start_x); - uint8_t* dest_pointer = rt.bits; + PaletteIndex* dest_pointer = rt.bits; // Move the pointer to the start point of the destination dest_pointer += (zoomLevel.ApplyInversedTo(rt.WorldWidth()) + rt.pitch) * dest_start_y + dest_start_x; @@ -1007,7 +1008,7 @@ void FASTCALL GfxDrawSpriteRawMaskedSoftware( if (width < 0 || height < 0) return; - uint8_t* dst = rt.bits + (left - rt.x) + ((top - rt.y) * rt.LineStride()); + PaletteIndex* dst = rt.bits + (left - rt.x) + ((top - rt.y) * rt.LineStride()); int32_t skipX = left - offsetCoords.x; int32_t skipY = top - offsetCoords.y; if (zoom < ZoomLevel{ 0 }) @@ -1043,9 +1044,9 @@ const G1Element* GfxGetG1Element(ImageIndex image_id) return nullptr; } - if (offset == SPR_TEMP) + if (offset >= SPR_TEMP_BEGIN && offset < SPR_TEMP_END) { - return &_g1Temp; + return &_g1Temp[offset - SPR_TEMP_BEGIN]; } if (offset < SPR_RCTC_G1_END) @@ -1138,7 +1139,7 @@ const G1Palette* GfxGetG1Palette(ImageIndex imageId) void GfxSetG1Element(ImageIndex imageId, const G1Element* g1) { - bool isTemp = imageId == SPR_TEMP; + bool isTemp = (imageId >= SPR_TEMP_BEGIN && imageId < SPR_TEMP_END); bool isValid = (imageId >= SPR_IMAGE_LIST_BEGIN && imageId < SPR_IMAGE_LIST_END) || (imageId >= SPR_SCROLLING_TEXT_START && imageId < SPR_SCROLLING_TEXT_END); @@ -1152,7 +1153,7 @@ void GfxSetG1Element(ImageIndex imageId, const G1Element* g1) { if (isTemp) { - _g1Temp = *g1; + _g1Temp[imageId - SPR_TEMP_BEGIN] = *g1; } else if (isValid) { diff --git a/src/openrct2/drawing/Drawing.Sprite.h b/src/openrct2/drawing/Drawing.Sprite.h new file mode 100644 index 0000000000..597c42060b --- /dev/null +++ b/src/openrct2/drawing/Drawing.Sprite.h @@ -0,0 +1,184 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../core/CallingConventions.h" +#include "G1Element.h" +#include "ImageId.hpp" +#include "PaletteIndex.h" +#include "PaletteMap.h" +#include "RenderTarget.h" + +#include +#include +#include + +struct ScreenCoordsXY; + +namespace OpenRCT2 +{ + struct IPlatformEnvironment; +} // namespace OpenRCT2 + +using DrawBlendOp = uint8_t; + +constexpr DrawBlendOp kBlendNone = 0; + +/** + * Only supported by BITMAP. RLE images always encode transparency via the encoding. + * Pixel value of 0 represents transparent. + */ +constexpr DrawBlendOp kBlendTransparent = 1 << 0; + +/** + * Whether to use the pixel value from the source image. + * This is usually only unset for glass images where there the src is only a transparency mask. + */ +constexpr DrawBlendOp kBlendSrc = 1 << 1; + +/** + * Whether to use the pixel value of the destination image for blending. + * This is used for any image that filters the target image, e.g. glass or water. + */ +constexpr DrawBlendOp kBlendDst = 2 << 2; + +struct DrawSpriteArgs +{ + ImageId Image; + OpenRCT2::Drawing::PaletteMap PalMap; + const OpenRCT2::G1Element& SourceImage; + int32_t SrcX; + int32_t SrcY; + int32_t Width; + int32_t Height; + OpenRCT2::Drawing::PaletteIndex* DestinationBits; + + DrawSpriteArgs( + ImageId image, const OpenRCT2::Drawing::PaletteMap& palMap, const OpenRCT2::G1Element& sourceImage, int32_t srcX, + int32_t srcY, int32_t width, int32_t height, OpenRCT2::Drawing::PaletteIndex* destinationBits) + : Image(image) + , PalMap(palMap) + , SourceImage(sourceImage) + , SrcX(srcX) + , SrcY(srcY) + , Width(width) + , Height(height) + , DestinationBits(destinationBits) + { + } +}; + +template +bool FASTCALL BlitPixel( + const OpenRCT2::Drawing::PaletteIndex* src, OpenRCT2::Drawing::PaletteIndex* dst, + const OpenRCT2::Drawing::PaletteMap& paletteMap) +{ + if constexpr (TBlendOp & kBlendTransparent) + { + // Ignore transparent pixels + if (*src == OpenRCT2::Drawing::PaletteIndex::transparent) + { + return false; + } + } + + if constexpr (((TBlendOp & kBlendSrc) != 0) && ((TBlendOp & kBlendDst) != 0)) + { + auto pixel = paletteMap.Blend(*src, *dst); + if constexpr (TBlendOp & kBlendTransparent) + { + if (pixel == OpenRCT2::Drawing::PaletteIndex::transparent) + { + return false; + } + } + *dst = pixel; + return true; + } + else if constexpr ((TBlendOp & kBlendSrc) != 0) + { + auto pixel = paletteMap[EnumValue(*src)]; + if constexpr (TBlendOp & kBlendTransparent) + { + if (pixel == OpenRCT2::Drawing::PaletteIndex::transparent) + { + return false; + } + } + *dst = pixel; + return true; + } + else if constexpr ((TBlendOp & kBlendDst) != 0) + { + auto pixel = paletteMap[EnumValue(*dst)]; + if constexpr (TBlendOp & kBlendTransparent) + { + if (pixel == OpenRCT2::Drawing::PaletteIndex::transparent) + { + return false; + } + } + *dst = pixel; + return true; + } + else + { + *dst = *src; + return true; + } +} + +template +void FASTCALL + BlitPixels(const uint8_t* src, uint8_t* dst, const OpenRCT2::Drawing::PaletteMap& paletteMap, uint8_t zoom, size_t dstPitch) +{ + auto yDstSkip = dstPitch - zoom; + for (uint8_t yy = 0; yy < zoom; yy++) + { + for (uint8_t xx = 0; xx < zoom; xx++) + { + BlitPixel(src, dst, paletteMap); + dst++; + } + dst += yDstSkip; + } +} + +// sprite catalogues +bool GfxLoadG1(const OpenRCT2::IPlatformEnvironment& env); +void GfxLoadG2PalettesFontsTracks(); +bool GfxLoadCsg(); +void GfxUnloadG1(); +void GfxUnloadG2PalettesFontsTracks(); +void GfxUnloadCsg(); +const OpenRCT2::G1Element* GfxGetG1Element(ImageId imageId); +const OpenRCT2::G1Element* GfxGetG1Element(ImageIndex image_id); +const OpenRCT2::G1Palette* GfxGetG1Palette(ImageIndex imageId); +void GfxSetG1Element(ImageIndex imageId, const OpenRCT2::G1Element* g1); +std::optional GfxLoadGx(const std::vector& buffer); +bool IsCsgLoaded(); + +// sprite blitting +void FASTCALL GfxSpriteToBuffer(OpenRCT2::Drawing::RenderTarget& rt, const DrawSpriteArgs& args); +void FASTCALL GfxBmpSpriteToBuffer(OpenRCT2::Drawing::RenderTarget& rt, const DrawSpriteArgs& args); +void FASTCALL GfxRleSpriteToBuffer(OpenRCT2::Drawing::RenderTarget& rt, const DrawSpriteArgs& args); +void FASTCALL GfxDrawSpriteSoftware(OpenRCT2::Drawing::RenderTarget& rt, ImageId imageId, const ScreenCoordsXY& spriteCoords); +void FASTCALL GfxDrawSpritePaletteSetSoftware( + OpenRCT2::Drawing::RenderTarget& rt, ImageId imageId, const ScreenCoordsXY& coords, + const OpenRCT2::Drawing::PaletteMap& paletteMap); +void FASTCALL GfxDrawSpriteRawMaskedSoftware( + OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& scrCoords, ImageId maskImage, ImageId colourImage); + +// sprite data +size_t G1CalculateDataSize(const OpenRCT2::G1Element* g1); + +void MaskScalar( + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + OpenRCT2::Drawing::PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index eef5236087..2e8072fc8b 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -454,7 +454,7 @@ const TranslucentWindowPalette kTranslucentWindowPalettes[kColourNumTotal] = { ImageCatalogue ImageId::GetCatalogue() const { auto index = GetIndex(); - if (index == SPR_TEMP) + if (index >= SPR_TEMP_BEGIN && index < SPR_TEMP_END) { return ImageCatalogue::TEMPORARY; } @@ -499,8 +499,8 @@ static auto GetMaskFunction() static const auto MaskFunc = GetMaskFunction(); void MaskFn( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) { MaskFunc(width, height, maskSrc, colourSrc, dst, maskWrap, colourWrap, dstWrap); } diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index f42b43bacb..94867bf2e8 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -14,16 +14,17 @@ #include "../interface/ZoomLevel.h" #include "../world/Location.hpp" #include "ColourPalette.h" +#include "Drawing.Sprite.h" #include "FilterPaletteIds.h" #include "Font.h" #include "G1Element.h" #include "ImageId.hpp" +#include "PaletteMap.h" #include "RenderTarget.h" #include "Text.h" #include "TextColour.h" #include -#include #include #include #include @@ -44,30 +45,9 @@ namespace OpenRCT2::Drawing { struct IDrawingEngine; enum class FilterPaletteID : int32_t; + enum class PaletteIndex : uint8_t; } // namespace OpenRCT2::Drawing -using DrawBlendOp = uint8_t; - -constexpr DrawBlendOp kBlendNone = 0; - -/** - * Only supported by BITMAP. RLE images always encode transparency via the encoding. - * Pixel value of 0 represents transparent. - */ -constexpr DrawBlendOp kBlendTransparent = 1 << 0; - -/** - * Whether to use the pixel value from the source image. - * This is usually only unset for glass images where there the src is only a transparency mask. - */ -constexpr DrawBlendOp kBlendSrc = 1 << 1; - -/** - * Whether to use the pixel value of the destination image for blending. - * This is used for any image that filters the target image, e.g. glass or water. - */ -constexpr DrawBlendOp kBlendDst = 2 << 2; - namespace OpenRCT2::Drawing { struct TranslucentWindowPalette @@ -78,151 +58,6 @@ namespace OpenRCT2::Drawing }; } // namespace OpenRCT2::Drawing -/** - * Represents an 8-bit indexed map that maps from one palette index to another. - */ -struct PaletteMap -{ -private: - std::span _data{}; -#ifdef _DEBUG - // We only require those fields for the asserts in debug builds. - size_t _numMaps{}; - size_t _mapLength{}; -#endif - -public: - static PaletteMap GetDefault(); - - constexpr PaletteMap() = default; - - constexpr PaletteMap(OpenRCT2::Drawing::PaletteIndex* data, size_t numMaps, size_t mapLength) - : _data{ data, numMaps * mapLength } -#ifdef _DEBUG - , _numMaps(numMaps) - , _mapLength(mapLength) -#endif - { - } - - constexpr PaletteMap(std::span map) - : _data(map) -#ifdef _DEBUG - , _numMaps(1) - , _mapLength(map.size()) -#endif - { - } - - OpenRCT2::Drawing::PaletteIndex& operator[](size_t index); - OpenRCT2::Drawing::PaletteIndex operator[](size_t index) const; - - OpenRCT2::Drawing::PaletteIndex Blend(OpenRCT2::Drawing::PaletteIndex src, OpenRCT2::Drawing::PaletteIndex dst) const; - void Copy( - OpenRCT2::Drawing::PaletteIndex dstIndex, const PaletteMap& src, OpenRCT2::Drawing::PaletteIndex srcIndex, - size_t length); -}; - -struct DrawSpriteArgs -{ - ImageId Image; - PaletteMap PalMap; - const OpenRCT2::G1Element& SourceImage; - int32_t SrcX; - int32_t SrcY; - int32_t Width; - int32_t Height; - uint8_t* DestinationBits; - - DrawSpriteArgs( - ImageId image, const PaletteMap& palMap, const OpenRCT2::G1Element& sourceImage, int32_t srcX, int32_t srcY, - int32_t width, int32_t height, uint8_t* destinationBits) - : Image(image) - , PalMap(palMap) - , SourceImage(sourceImage) - , SrcX(srcX) - , SrcY(srcY) - , Width(width) - , Height(height) - , DestinationBits(destinationBits) - { - } -}; - -template -bool FASTCALL - BlitPixel(const OpenRCT2::Drawing::PaletteIndex* src, OpenRCT2::Drawing::PaletteIndex* dst, const PaletteMap& paletteMap) -{ - if constexpr (TBlendOp & kBlendTransparent) - { - // Ignore transparent pixels - if (*src == OpenRCT2::Drawing::PaletteIndex::transparent) - { - return false; - } - } - - if constexpr (((TBlendOp & kBlendSrc) != 0) && ((TBlendOp & kBlendDst) != 0)) - { - auto pixel = paletteMap.Blend(*src, *dst); - if constexpr (TBlendOp & kBlendTransparent) - { - if (pixel == OpenRCT2::Drawing::PaletteIndex::transparent) - { - return false; - } - } - *dst = pixel; - return true; - } - else if constexpr ((TBlendOp & kBlendSrc) != 0) - { - auto pixel = paletteMap[EnumValue(*src)]; - if constexpr (TBlendOp & kBlendTransparent) - { - if (pixel == OpenRCT2::Drawing::PaletteIndex::transparent) - { - return false; - } - } - *dst = pixel; - return true; - } - else if constexpr ((TBlendOp & kBlendDst) != 0) - { - auto pixel = paletteMap[EnumValue(*dst)]; - if constexpr (TBlendOp & kBlendTransparent) - { - if (pixel == OpenRCT2::Drawing::PaletteIndex::transparent) - { - return false; - } - } - *dst = pixel; - return true; - } - else - { - *dst = *src; - return true; - } -} - -template -void FASTCALL BlitPixels(const uint8_t* src, uint8_t* dst, const PaletteMap& paletteMap, uint8_t zoom, size_t dstPitch) -{ - auto yDstSkip = dstPitch - zoom; - for (uint8_t yy = 0; yy < zoom; yy++) - { - for (uint8_t xx = 0; xx < zoom; xx++) - { - BlitPixel(src, dst, paletteMap); - dst++; - } - dst += yDstSkip; - } -} - constexpr uint8_t kPaletteTotalOffsets = 192; extern OpenRCT2::Drawing::GamePalette gPalette; @@ -261,36 +96,15 @@ void GfxDrawDashedLine( OpenRCT2::Drawing::RenderTarget& rt, const ScreenLine& screenLine, int32_t dashedLineSegmentLength, OpenRCT2::Drawing::PaletteIndex colour); -// sprite catalogues -bool GfxLoadG1(const OpenRCT2::IPlatformEnvironment& env); -void GfxLoadG2PalettesFontsTracks(); -bool GfxLoadCsg(); -void GfxUnloadG1(); -void GfxUnloadG2PalettesFontsTracks(); -void GfxUnloadCsg(); -const OpenRCT2::G1Element* GfxGetG1Element(ImageId imageId); -const OpenRCT2::G1Element* GfxGetG1Element(ImageIndex image_id); -const OpenRCT2::G1Palette* GfxGetG1Palette(ImageIndex imageId); -void GfxSetG1Element(ImageIndex imageId, const OpenRCT2::G1Element* g1); -std::optional GfxLoadGx(const std::vector& buffer); -bool IsCsgLoaded(); - -// sprite blitting -void FASTCALL GfxSpriteToBuffer(OpenRCT2::Drawing::RenderTarget& rt, const DrawSpriteArgs& args); -void FASTCALL GfxBmpSpriteToBuffer(OpenRCT2::Drawing::RenderTarget& rt, const DrawSpriteArgs& args); -void FASTCALL GfxRleSpriteToBuffer(OpenRCT2::Drawing::RenderTarget& rt, const DrawSpriteArgs& args); +// sprite (NewDrawing.cpp functions that use the drawing engine) void FASTCALL GfxDrawSprite(OpenRCT2::Drawing::RenderTarget& rt, ImageId image_id, const ScreenCoordsXY& coords); void FASTCALL GfxDrawGlyph( - OpenRCT2::Drawing::RenderTarget& rt, ImageId image, const ScreenCoordsXY& coords, const PaletteMap& paletteMap); + OpenRCT2::Drawing::RenderTarget& rt, ImageId image, const ScreenCoordsXY& coords, + const OpenRCT2::Drawing::PaletteMap& paletteMap); void FASTCALL GfxDrawSpriteSolid( OpenRCT2::Drawing::RenderTarget& rt, ImageId image, const ScreenCoordsXY& coords, OpenRCT2::Drawing::PaletteIndex colour); void FASTCALL GfxDrawSpriteRawMasked( OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& coords, ImageId maskImage, ImageId colourImage); -void FASTCALL GfxDrawSpriteSoftware(OpenRCT2::Drawing::RenderTarget& rt, ImageId imageId, const ScreenCoordsXY& spriteCoords); -void FASTCALL GfxDrawSpritePaletteSetSoftware( - OpenRCT2::Drawing::RenderTarget& rt, ImageId imageId, const ScreenCoordsXY& coords, const PaletteMap& paletteMap); -void FASTCALL GfxDrawSpriteRawMaskedSoftware( - OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& scrCoords, ImageId maskImage, ImageId colourImage); // string void GfxDrawStringLeftCentred( @@ -315,24 +129,19 @@ void TTFDrawString( OpenRCT2::Drawing::RenderTarget& rt, const_utf8string text, ColourWithFlags colour, const ScreenCoordsXY& coords, bool noFormatting, FontStyle fontStyle, TextDarkness darkness); -size_t G1CalculateDataSize(const OpenRCT2::G1Element* g1); - -void MaskScalar( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); void MaskSse4_1( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + OpenRCT2::Drawing::PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); void MaskAvx2( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + OpenRCT2::Drawing::PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); void MaskFn( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + OpenRCT2::Drawing::PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap); std::optional GetPaletteG1Index(OpenRCT2::Drawing::FilterPaletteID paletteId); -std::optional GetPaletteMapForColour(OpenRCT2::Drawing::FilterPaletteID paletteId); +std::optional GetPaletteMapForColour(OpenRCT2::Drawing::FilterPaletteID paletteId); void UpdatePalette( std::span palette, OpenRCT2::Drawing::PaletteIndex startIndex, int32_t numColours); void UpdatePaletteEffects(); diff --git a/src/openrct2/drawing/IDrawingContext.h b/src/openrct2/drawing/IDrawingContext.h index 87f6af467f..e42ce4e6c8 100644 --- a/src/openrct2/drawing/IDrawingContext.h +++ b/src/openrct2/drawing/IDrawingContext.h @@ -14,12 +14,12 @@ #include "PaletteIndex.h" #include "TTF.h" -struct PaletteMap; struct TextDrawInfo; namespace OpenRCT2::Drawing { struct IDrawingEngine; + struct PaletteMap; struct RenderTarget; struct IDrawingContext diff --git a/src/openrct2/drawing/ImageImporter.cpp b/src/openrct2/drawing/ImageImporter.cpp index 1ef1f378f2..4905157e91 100644 --- a/src/openrct2/drawing/ImageImporter.cpp +++ b/src/openrct2/drawing/ImageImporter.cpp @@ -38,7 +38,7 @@ namespace OpenRCT2::Drawing { throw std::invalid_argument("Image is not paletted, it has bit depth of " + std::to_string(image.Depth)); } - const bool isRLE = HasFlag(meta.importFlags, ImportFlags::RLE); + const bool isRLE = meta.importFlags.has(ImportFlag::rle); auto pixels = GetPixels(image, meta); auto buffer = isRLE ? EncodeRLE(pixels.data(), meta.srcSize) : EncodeRaw(pixels.data(), meta.srcSize); @@ -50,7 +50,7 @@ namespace OpenRCT2::Drawing outElement.xOffset = meta.offset.x; outElement.yOffset = meta.offset.y; outElement.zoomedOffset = meta.zoomedOffset; - if (HasFlag(meta.importFlags, ImportFlags::NoDrawOnZoom)) + if (meta.importFlags.has(ImportFlag::noDrawOnZoom)) outElement.flags.set(G1Flag::noZoomDraw); ImageImportResult result; @@ -438,14 +438,14 @@ namespace OpenRCT2::Drawing auto yOffset = Json::GetNumber(input["y"]); auto keepPalette = Json::GetString(input["palette"]) == "keep"; auto palette = keepPalette ? Palette::KeepIndices : Palette::OpenRCT2; - uint8_t flags = 0; + ImportFlags flags = {}; auto raw = Json::GetString(input["format"]) == "raw"; if (!raw) - flags |= EnumToFlag(ImportFlags::RLE); + flags.set(ImportFlag::rle); if (Json::GetBoolean("noDrawOnZoom")) - flags |= EnumToFlag(ImportFlags::NoDrawOnZoom); + flags.set(ImportFlag::noDrawOnZoom); auto srcX = Json::GetNumber(input["srcX"]); auto srcY = Json::GetNumber(input["srcY"]); diff --git a/src/openrct2/drawing/ImageImporter.h b/src/openrct2/drawing/ImageImporter.h index 5285f4a951..2c8c6838c7 100644 --- a/src/openrct2/drawing/ImageImporter.h +++ b/src/openrct2/drawing/ImageImporter.h @@ -9,15 +9,12 @@ #pragma once -#include "../core/EnumUtils.hpp" +#include "../core/FlagHolder.hpp" #include "../core/Imaging.h" #include "../core/JsonFwd.hpp" #include "../drawing/G1Element.h" #include "../world/Location.hpp" -#include -#include - struct Image; namespace OpenRCT2::Drawing @@ -29,11 +26,12 @@ namespace OpenRCT2::Drawing Dithering, }; - enum class ImportFlags : uint8_t + enum class ImportFlag : uint8_t { - RLE, - NoDrawOnZoom, + rle, + noDrawOnZoom, }; + using ImportFlags = FlagHolder; enum class Palette : uint8_t { @@ -45,7 +43,7 @@ namespace OpenRCT2::Drawing { ScreenCoordsXY offset{}; Palette palette = Palette::OpenRCT2; - uint8_t importFlags = EnumToFlag(ImportFlags::RLE); + ImportFlags importFlags = { ImportFlag::rle }; ImportMode importMode = ImportMode::Default; ScreenCoordsXY srcOffset{}; ScreenSize srcSize{}; diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index 2d5a7e2c0d..9925588b72 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -1025,7 +1025,7 @@ namespace OpenRCT2::Drawing::LightFx } void RenderToTexture( - const Viewport& vp, void* dstPixels, uint32_t dstPitch, uint8_t* bits, uint32_t width, uint32_t height, + const Viewport& vp, void* dstPixels, uint32_t dstPitch, PaletteIndex* bits, uint32_t width, uint32_t height, const uint32_t* palette, const uint32_t* lightPalette) { UpdateViewportSettings(vp); @@ -1045,9 +1045,9 @@ namespace OpenRCT2::Drawing::LightFx uint32_t* dst = reinterpret_cast(reinterpret_cast(dstPixels) + dstOffset); for (uint32_t x = 0; x < width; x++) { - uint8_t* src = &bits[y * width + x]; - uint32_t darkColour = palette[*src]; - uint32_t lightColour = lightPalette[*src]; + PaletteIndex src = bits[y * width + x]; + uint32_t darkColour = palette[EnumValue(src)]; + uint32_t lightColour = lightPalette[EnumValue(src)]; uint8_t lightIntensity = lightBits[y * width + x]; uint32_t colour = 0; diff --git a/src/openrct2/drawing/LightFX.h b/src/openrct2/drawing/LightFX.h index de79fae558..4a6a9ff2db 100644 --- a/src/openrct2/drawing/LightFX.h +++ b/src/openrct2/drawing/LightFX.h @@ -26,7 +26,8 @@ namespace OpenRCT2 namespace OpenRCT2::Drawing { struct RenderTarget; -} + enum class PaletteIndex : uint8_t; +} // namespace OpenRCT2::Drawing namespace OpenRCT2::Drawing::LightFx { @@ -72,7 +73,7 @@ namespace OpenRCT2::Drawing::LightFx void ApplyPaletteFilter(uint8_t i, uint8_t* r, uint8_t* g, uint8_t* b); void RenderToTexture( - const Viewport& vp, void* dstPixels, uint32_t dstPitch, uint8_t* bits, uint32_t width, uint32_t height, + const Viewport& vp, void* dstPixels, uint32_t dstPitch, Drawing::PaletteIndex* bits, uint32_t width, uint32_t height, const uint32_t* palette, const uint32_t* lightPalette); } // namespace OpenRCT2::Drawing::LightFx diff --git a/src/openrct2/drawing/PaletteIndex.h b/src/openrct2/drawing/PaletteIndex.h index f944437b01..3c09e4470b 100644 --- a/src/openrct2/drawing/PaletteIndex.h +++ b/src/openrct2/drawing/PaletteIndex.h @@ -16,6 +16,7 @@ namespace OpenRCT2::Drawing enum class PaletteIndex : uint8_t { transparent = 0, + fontFill = 1, pi10 = 10, // Black (0-dark), Dark grey (0) pi11 = 11, // Black (middark) diff --git a/src/openrct2/drawing/PaletteMap.h b/src/openrct2/drawing/PaletteMap.h new file mode 100644 index 0000000000..78ee8ea9c3 --- /dev/null +++ b/src/openrct2/drawing/PaletteMap.h @@ -0,0 +1,61 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include +#include + +namespace OpenRCT2::Drawing +{ + enum class PaletteIndex : uint8_t; + + /** + * Represents an 8-bit indexed map that maps from one palette index to another. + */ + struct PaletteMap + { + private: + std::span _data{}; +#ifdef _DEBUG + // We only require those fields for the asserts in debug builds. + size_t _numMaps{}; + size_t _mapLength{}; +#endif + + public: + static PaletteMap GetDefault(); + + constexpr PaletteMap() = default; + + constexpr PaletteMap(PaletteIndex* data, size_t numMaps, size_t mapLength) + : _data{ data, numMaps * mapLength } +#ifdef _DEBUG + , _numMaps(numMaps) + , _mapLength(mapLength) +#endif + { + } + + constexpr PaletteMap(std::span map) + : _data(map) +#ifdef _DEBUG + , _numMaps(1) + , _mapLength(map.size()) +#endif + { + } + + PaletteIndex& operator[](size_t index); + PaletteIndex operator[](size_t index) const; + + PaletteIndex Blend(PaletteIndex src, PaletteIndex dst) const; + void Copy(PaletteIndex dstIndex, const PaletteMap& src, PaletteIndex srcIndex, size_t length); + }; +} // namespace OpenRCT2::Drawing diff --git a/src/openrct2/drawing/RenderTarget.cpp b/src/openrct2/drawing/RenderTarget.cpp index 04d943c052..ac104fee97 100644 --- a/src/openrct2/drawing/RenderTarget.cpp +++ b/src/openrct2/drawing/RenderTarget.cpp @@ -11,7 +11,7 @@ namespace OpenRCT2::Drawing { - uint8_t* RenderTarget::GetBitsOffset(const ScreenCoordsXY& pos) const + PaletteIndex* RenderTarget::GetBitsOffset(const ScreenCoordsXY& pos) const { return bits + pos.x + pos.y * LineStride(); } diff --git a/src/openrct2/drawing/RenderTarget.h b/src/openrct2/drawing/RenderTarget.h index 8a6bc1404e..92e01b9757 100644 --- a/src/openrct2/drawing/RenderTarget.h +++ b/src/openrct2/drawing/RenderTarget.h @@ -15,10 +15,11 @@ namespace OpenRCT2::Drawing { struct IDrawingEngine; + enum class PaletteIndex : uint8_t; struct RenderTarget { - uint8_t* bits{}; + PaletteIndex* bits{}; int32_t x{}; int32_t y{}; int32_t width{}; @@ -35,7 +36,7 @@ namespace OpenRCT2::Drawing IDrawingEngine* DrawingEngine{}; - uint8_t* GetBitsOffset(const ScreenCoordsXY& pos) const; + PaletteIndex* GetBitsOffset(const ScreenCoordsXY& pos) const; RenderTarget Crop(const ScreenCoordsXY& pos, const ScreenSize& size) const; [[nodiscard]] constexpr int32_t WorldX() const diff --git a/src/openrct2/drawing/SSE41Drawing.cpp b/src/openrct2/drawing/SSE41Drawing.cpp index 5b4de493b6..149dd6e98c 100644 --- a/src/openrct2/drawing/SSE41Drawing.cpp +++ b/src/openrct2/drawing/SSE41Drawing.cpp @@ -9,14 +9,17 @@ #include "../core/Guard.hpp" #include "Drawing.h" +#include "PaletteIndex.h" + +using OpenRCT2::Drawing::PaletteIndex; #ifdef __SSE4_1__ #include void MaskSse4_1( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) { if (width == 32) { @@ -62,8 +65,8 @@ void MaskSse4_1( #endif void MaskSse4_1( - int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, uint8_t* RESTRICT dst, - int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) + int32_t width, int32_t height, const uint8_t* RESTRICT maskSrc, const uint8_t* RESTRICT colourSrc, + PaletteIndex* RESTRICT dst, int32_t maskWrap, int32_t colourWrap, int32_t dstWrap) { OpenRCT2::Guard::Fail("SSE 4.1 function called on a CPU that doesn't support SSE 4.1"); } diff --git a/src/openrct2/drawing/ScrollingText.cpp b/src/openrct2/drawing/ScrollingText.cpp index 8f27f7bcfb..43a4b85a75 100644 --- a/src/openrct2/drawing/ScrollingText.cpp +++ b/src/openrct2/drawing/ScrollingText.cpp @@ -9,6 +9,7 @@ #include "ScrollingText.h" +#include "../GameState.h" #include "../SpriteIds.h" #include "../config/Config.h" #include "../core/CodepointView.hpp" @@ -31,8 +32,7 @@ namespace OpenRCT2::Drawing::ScrollingText { struct DrawScrollText { - StringId string_id; - uint8_t string_args[32]; + u8string string; PaletteIndex colour; uint16_t position; uint16_t mode; @@ -42,7 +42,7 @@ namespace OpenRCT2::Drawing::ScrollingText static DrawScrollText _drawScrollTextList[kMaxEntries]; static uint8_t _characterBitmaps[SPR_FONTS_GLYPH_COUNT][8]; - static uint32_t _drawSCrollNextIndex = 0; + static uint32_t _drawScrollNextIndex = 0; static std::mutex _mutex; static void setBitmapForSprite( @@ -52,15 +52,15 @@ namespace OpenRCT2::Drawing::ScrollingText static void initialiseCharacterBitmaps(uint32_t glyphStart, uint16_t count) { - uint8_t drawingSurface[64]; + PaletteIndex drawingSurface[64]; RenderTarget rt; - rt.bits = reinterpret_cast(&drawingSurface); + rt.bits = drawingSurface; rt.width = 8; rt.height = 8; for (int32_t i = 0; i < count; i++) { - std::fill_n(drawingSurface, sizeof(drawingSurface), 0x00); + std::fill_n(drawingSurface, sizeof(drawingSurface), PaletteIndex::transparent); GfxDrawSpriteSoftware(rt, ImageId(glyphStart + (EnumValue(FontStyle::tiny) * count) + i), { -1, 0 }); for (int32_t x = 0; x < 8; x++) @@ -69,8 +69,8 @@ namespace OpenRCT2::Drawing::ScrollingText for (int32_t y = 0; y < 8; y++) { val >>= 1; - uint8_t pixel = rt.bits[x + y * 8]; - if (pixel == 1) + PaletteIndex pixel = rt.bits[x + y * 8]; + if (pixel == PaletteIndex::fontFill) { val |= 0x80; } @@ -117,8 +117,7 @@ namespace OpenRCT2::Drawing::ScrollingText return _characterBitmaps[offset]; } - static int32_t getMatchingOrOldest( - StringId stringId, Formatter& ft, uint16_t scroll, uint16_t scrollingMode, PaletteIndex colour) + static int32_t getMatchingOrOldest(u8string_view string, uint16_t scroll, uint16_t scrollingMode, PaletteIndex colour) { uint32_t oldestId = 0xFFFFFFFF; int32_t scrollIndex = -1; @@ -132,29 +131,16 @@ namespace OpenRCT2::Drawing::ScrollingText } // If exact match return the matching index - if (scrollText->string_id == stringId - && std::memcmp(scrollText->string_args, ft.Buf(), sizeof(scrollText->string_args)) == 0 - && scrollText->colour == colour && scrollText->position == scroll && scrollText->mode == scrollingMode) + if (scrollText->string == string && scrollText->colour == colour && scrollText->position == scroll + && scrollText->mode == scrollingMode) { - scrollText->id = _drawSCrollNextIndex; + scrollText->id = _drawScrollNextIndex; return static_cast(i + SPR_SCROLLING_TEXT_START); } } return scrollIndex; } - static void format(utf8* dst, size_t size, DrawScrollText* scrollText) - { - if (Config::Get().general.upperCaseBanners) - { - FormatStringToUpper(dst, size, scrollText->string_id, scrollText->string_args); - } - else - { - FormatStringLegacy(dst, size, scrollText->string_id, scrollText->string_args); - } - } - extern bool TempForScrollText; consteval int16_t ScrollPos(const int16_t x, const int16_t y) @@ -1428,14 +1414,20 @@ static constexpr const int16_t* kScrollPositions[kMaxModes] = { { for (auto& scrollText : _drawScrollTextList) { - scrollText.string_id = 0; - std::memset(scrollText.string_args, 0, sizeof(scrollText.string_args)); + scrollText.string.clear(); } } - ImageId setup( - PaintSession& session, StringId stringId, Formatter& ft, uint16_t scroll, uint16_t scrollingMode, PaletteIndex colour) + ImageId setup(PaintSession& session, u8string_view string, uint16_t scrollingMode, PaletteIndex colour) { + u8string formattedString = FormatStringID(STR_BANNER_TEXT_FORMAT, string); + if (Config::Get().general.upperCaseBanners) + { + formattedString = String::toUpper(formattedString); + } + auto stringWidth = GfxGetStringWidth(formattedString, FontStyle::tiny); + auto scroll = stringWidth > 0 ? (getGameState().currentTicks / 2) % stringWidth : 0; + std::scoped_lock lock(_mutex); assert(scrollingMode < kMaxModes); @@ -1443,35 +1435,29 @@ static constexpr const int16_t* kScrollPositions[kMaxModes] = { if (session.rt.zoom_level > ZoomLevel{ 0 }) return ImageId(SPR_SCROLLING_TEXT_DEFAULT); - _drawSCrollNextIndex++; - ft.Rewind(); - uint32_t scrollIndex = getMatchingOrOldest(stringId, ft, scroll, scrollingMode, colour); + _drawScrollNextIndex++; + uint32_t scrollIndex = getMatchingOrOldest(formattedString, scroll, scrollingMode, colour); if (scrollIndex >= SPR_SCROLLING_TEXT_START) return ImageId(scrollIndex); // Setup scrolling text auto scrollText = &_drawScrollTextList[scrollIndex]; - scrollText->string_id = stringId; - std::memcpy(scrollText->string_args, ft.Buf(), sizeof(scrollText->string_args)); + scrollText->string = formattedString; scrollText->colour = colour; scrollText->position = scroll; scrollText->mode = scrollingMode; - scrollText->id = _drawSCrollNextIndex; - - // Create the string to draw - utf8 scrollString[256]; - format(scrollString, 256, scrollText); + scrollText->id = _drawScrollNextIndex; const int16_t* scrollingModePositions = kScrollPositions[scrollingMode]; std::fill_n(scrollText->bitmap, 320 * 8, PaletteIndex::transparent); if (LocalisationService_UseTrueTypeFont()) { - setBitmapForTTF(scrollString, scroll, scrollText->bitmap, scrollingModePositions, colour); + setBitmapForTTF(scrollText->string, scroll, scrollText->bitmap, scrollingModePositions, colour); } else { - setBitmapForSprite(scrollString, scroll, scrollText->bitmap, scrollingModePositions, colour); + setBitmapForSprite(scrollText->string, scroll, scrollText->bitmap, scrollingModePositions, colour); } uint32_t imageId = SPR_SCROLLING_TEXT_START + scrollIndex; diff --git a/src/openrct2/drawing/ScrollingText.h b/src/openrct2/drawing/ScrollingText.h index c15944c9bb..803d127da3 100644 --- a/src/openrct2/drawing/ScrollingText.h +++ b/src/openrct2/drawing/ScrollingText.h @@ -9,6 +9,8 @@ #pragma once +#include "../core/StringTypes.h" + #include struct ImageId; @@ -32,9 +34,10 @@ namespace OpenRCT2::Drawing::ScrollingText static auto constexpr kMaxLegacyEntries = 32; static auto constexpr kMaxEntries = 256; constexpr int8_t kMaxModes = 38; + constexpr auto kParkBannerColourPrefix = "{WHITE}"; + constexpr auto kRideBannerColourPrefix = "{YELLOW}"; void initialiseBitmaps(); void invalidate(); - ImageId setup( - PaintSession& session, StringId stringId, Formatter& ft, uint16_t scroll, uint16_t scrollingMode, PaletteIndex colour); + ImageId setup(PaintSession& session, u8string_view string, uint16_t scrollingMode, PaletteIndex colour); } // namespace OpenRCT2::Drawing::ScrollingText diff --git a/src/openrct2/drawing/X8DrawingEngine.cpp b/src/openrct2/drawing/X8DrawingEngine.cpp index db811c0273..3476565bc1 100644 --- a/src/openrct2/drawing/X8DrawingEngine.cpp +++ b/src/openrct2/drawing/X8DrawingEngine.cpp @@ -59,7 +59,7 @@ void X8WeatherDrawer::Draw( uint32_t pixelOffset = rt.LineStride() * y + x; uint8_t patternYPos = patternStartYOffset % patternYSpace; - uint8_t* screenBits = rt.bits; + PaletteIndex* screenBits = rt.bits; // Stores the colours of changed pixels WeatherPixel* newPixels = &_weatherPixels[_weatherPixelsCount]; @@ -78,8 +78,8 @@ void X8WeatherDrawer::Draw( auto patternPixel = pattern[patternYPos * 2 + 1]; for (; xPixelOffset < finalPixelOffset; xPixelOffset += patternXSpace) { - uint8_t current_pixel = screenBits[xPixelOffset]; - screenBits[xPixelOffset] = patternPixel; + PaletteIndex current_pixel = screenBits[xPixelOffset]; + screenBits[xPixelOffset] = static_cast(patternPixel); _weatherPixelsCount++; // Store colour and position @@ -99,7 +99,7 @@ void X8WeatherDrawer::Restore(RenderTarget& rt) if (_weatherPixelsCount > 0) { uint32_t numPixels = rt.LineStride() * rt.height; - uint8_t* bits = rt.bits; + PaletteIndex* bits = rt.bits; for (uint32_t i = 0; i < _weatherPixelsCount; i++) { WeatherPixel weatherPixel = _weatherPixels[i]; @@ -226,8 +226,8 @@ void X8DrawingEngine::CopyRect(int32_t x, int32_t y, int32_t width, int32_t heig height += tmargin + bmargin; int32_t stride = _mainRT.LineStride(); - uint8_t* to = _mainRT.bits + y * stride + x; - uint8_t* from = _mainRT.bits + (y - dy) * stride + x - dx; + PaletteIndex* to = _mainRT.bits + y * stride + x; + PaletteIndex* from = _mainRT.bits + (y - dy) * stride + x - dx; if (dy > 0) { @@ -279,10 +279,10 @@ RenderTarget* X8DrawingEngine::getRT() void X8DrawingEngine::ConfigureBits(uint32_t width, uint32_t height, uint32_t pitch) { size_t newBitsSize = pitch * height; - uint8_t* newBits = new uint8_t[newBitsSize]; + PaletteIndex* newBits = new PaletteIndex[newBitsSize]; if (_bits == nullptr) { - std::fill_n(newBits, newBitsSize, 0); + std::fill_n(newBits, newBitsSize, PaletteIndex::transparent); } else { @@ -292,8 +292,8 @@ void X8DrawingEngine::ConfigureBits(uint32_t width, uint32_t height, uint32_t pi } else { - uint8_t* src = _bits; - uint8_t* dst = newBits; + PaletteIndex* src = _bits; + PaletteIndex* dst = newBits; uint32_t minWidth = std::min(_width, width); uint32_t minHeight = std::min(_height, height); @@ -302,7 +302,7 @@ void X8DrawingEngine::ConfigureBits(uint32_t width, uint32_t height, uint32_t pi std::copy_n(src, minWidth, dst); if (pitch - minWidth > 0) { - std::fill_n(dst + minWidth, pitch - minWidth, 0); + std::fill_n(dst + minWidth, pitch - minWidth, PaletteIndex::transparent); } src += _pitch; dst += pitch; @@ -375,11 +375,11 @@ void X8DrawingContext::Clear(RenderTarget& rt, PaletteIndex paletteIndex) int32_t w = rt.width; int32_t h = rt.height; - uint8_t* ptr = rt.bits; + PaletteIndex* ptr = rt.bits; for (int32_t y = 0; y < h; y++) { - std::fill_n(ptr, w, EnumValue(paletteIndex)); + std::fill_n(ptr, w, paletteIndex); ptr += w + rt.pitch; } } @@ -437,10 +437,10 @@ void X8DrawingContext::FillRect( if (crossHatch) { // Cross hatching - uint8_t* dst = startY * rt.LineStride() + startX + rt.bits; + PaletteIndex* dst = startY * rt.LineStride() + startX + rt.bits; for (int32_t i = 0; i < height; i++) { - uint8_t* nextdst = dst + rt.LineStride(); + PaletteIndex* nextdst = dst + rt.LineStride(); uint32_t p = Numerics::ror32(crosskPattern, 1); p = (p & 0xFFFF0000) | width; @@ -450,7 +450,7 @@ void X8DrawingContext::FillRect( p = p ^ 0x80000000; if (p & 0x80000000) { - *dst = EnumValue(paletteIndex); + *dst = paletteIndex; } dst++; } @@ -460,10 +460,10 @@ void X8DrawingContext::FillRect( } else { - uint8_t* dst = startY * rt.LineStride() + startX + rt.bits; + PaletteIndex* dst = startY * rt.LineStride() + startX + rt.bits; for (int32_t i = 0; i < height; i++) { - std::fill_n(dst, width, EnumValue(paletteIndex)); + std::fill_n(dst, width, paletteIndex); dst += rt.LineStride(); } } diff --git a/src/openrct2/drawing/X8DrawingEngine.h b/src/openrct2/drawing/X8DrawingEngine.h index 89890cc487..dfb8d5116e 100644 --- a/src/openrct2/drawing/X8DrawingEngine.h +++ b/src/openrct2/drawing/X8DrawingEngine.h @@ -35,7 +35,7 @@ namespace OpenRCT2 struct WeatherPixel { uint32_t Position; - uint8_t Colour; + PaletteIndex Colour; }; static constexpr uint32_t kMaxWeatherPixels = 0xFFFE; @@ -64,7 +64,7 @@ namespace OpenRCT2 uint32_t _height = 0; uint32_t _pitch = 0; size_t _bitsSize = 0; - uint8_t* _bits = nullptr; + PaletteIndex* _bits = nullptr; RenderTarget _mainRT = {}; diff --git a/src/openrct2/entity/Balloon.cpp b/src/openrct2/entity/Balloon.cpp index 01277f75e7..a77a45d5a9 100644 --- a/src/openrct2/entity/Balloon.cpp +++ b/src/openrct2/entity/Balloon.cpp @@ -159,7 +159,7 @@ bool Balloon::Collides() const { const TrackElement* trackElement = tileElement->AsTrack(); const auto* ride = GetRide(trackElement->GetRideIndex()); - if (ride != nullptr && ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasRoofOverWholeRide)) + if (ride != nullptr && ride->getRideTypeDescriptor().flags.has(RtdFlag::hasRoofOverWholeRide)) { check_ceiling = true; } diff --git a/src/openrct2/entity/EntityRegistry.cpp b/src/openrct2/entity/EntityRegistry.cpp index 26b7696aaf..3887aefce9 100644 --- a/src/openrct2/entity/EntityRegistry.cpp +++ b/src/openrct2/entity/EntityRegistry.cpp @@ -296,7 +296,7 @@ namespace OpenRCT2 EntityBase* EntityRegistry::CreateEntity(EntityType type) { - if (_freeIdList.size() == 0) + if (_freeIdList.empty()) { // No free sprites. return nullptr; diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index e50610f79a..465b0b8c30 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -1030,7 +1030,7 @@ void Guest::Tick128UpdateGuest(uint32_t index) auto ride = GetRide(CurrentRide); if (ride != nullptr) { - PeepThoughtType thought_type = ride->getRideTypeDescriptor().HasFlag(RtdFlag::describeAsInside) + PeepThoughtType thought_type = ride->getRideTypeDescriptor().flags.has(RtdFlag::describeAsInside) ? PeepThoughtType::GetOut : PeepThoughtType::GetOff; @@ -1667,7 +1667,7 @@ static bool GuestDecideAndBuyItem(Guest& guest, Ride& ride, const ShopItem shopI // The peep has now decided to buy the item (or, specifically, has not been // dissuaded so far). guest.GiveItem(shopItem); - const auto hasRandomShopColour = ride.hasLifecycleFlag(RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS); + const auto hasRandomShopColour = ride.flags.has(RideFlag::randomShopColours); switch (shopItem) { @@ -1954,7 +1954,7 @@ static Ride* GuestFindBestRideToGoOn(Guest& guest) const auto rideIndex = ride.id.ToUnderlying(); if (rideConsideration.size() > rideIndex && rideConsideration[rideIndex]) { - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_QUEUE_FULL)) + if (!ride.flags.has(RideFlag::queueFull)) { if (guest.ShouldGoOnRide(ride, StationIndex::FromUnderlying(0), false, true) && RideHasRatings(ride)) { @@ -1980,11 +1980,11 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b // Indicates whether a peep is physically at the ride, or is just thinking about going on the ride. bool peepAtRide = !thinking; - if (ride.status == RideStatus::open && !(ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + if (ride.status == RideStatus::open && !ride.flags.has(RideFlag::brokenDown)) { // Peeps that are leaving the park will refuse to go on any rides, with the exception of free transport rides. assert(ride.type < std::size(kRideTypeDescriptors)); - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::isTransportRide) || ride.value == kRideValueUndefined + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::isTransportRide) || ride.value == kRideValueUndefined || RideGetPrice(ride) != 0) { if (PeepFlags & PEEP_FLAGS_LEAVING_PARK) @@ -1994,7 +1994,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b } } - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) { return GuestShouldGoToShop(*this, ride, peepAtRide); } @@ -2045,7 +2045,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b // Assuming the queue conditions are met, peeps will always go on free transport rides. // Ride ratings, recent crashes and weather will all be ignored. auto ridePrice = RideGetPrice(ride); - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::isTransportRide) || ride.value == kRideValueUndefined + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::isTransportRide) || ride.value == kRideValueUndefined || ridePrice != 0) { if (PreviousRide == ride.id) @@ -2183,7 +2183,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b // If the ride has not yet been rated and is capable of having g-forces, // there's a 90% chance that the peep will ignore it. - if (!RideHasRatings(ride) && ride.getRideTypeDescriptor().HasFlag(RtdFlag::checkGForces)) + if (!RideHasRatings(ride) && ride.getRideTypeDescriptor().flags.has(RtdFlag::checkGForces)) { if ((ScenarioRand() & 0xFFFF) > 0x1999u) { @@ -2254,7 +2254,7 @@ bool Guest::ShouldGoOnRide(Ride& ride, StationIndex entranceNum, bool atQueue, b GuestResetRideHeading(*this); } - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_QUEUE_FULL; + ride.flags.unset(RideFlag::queueFull); return true; } @@ -2410,7 +2410,7 @@ static bool GuestShouldRideWhileRaining(Guest& guest, const Ride& ride) } // Peeps with umbrellas will go on rides where they can use their umbrella on it (like the Maze) 50% of the time - if (guest.HasItem(ShopItem::umbrella) && ride.getRideTypeDescriptor().HasFlag(RtdFlag::guestsCanUseUmbrella) + if (guest.HasItem(ShopItem::umbrella) && ride.getRideTypeDescriptor().flags.has(RtdFlag::guestsCanUseUmbrella) && (ScenarioRand() & 2) == 0) { return true; @@ -2456,7 +2456,7 @@ static bool GuestHasVoucherForFreeRide(Guest& guest, const Ride& ride) */ static void GuestTriedToEnterFullQueue(Guest& guest, Ride& ride) { - ride.lifecycleFlags |= RIDE_LIFECYCLE_QUEUE_FULL; + ride.flags.set(RideFlag::queueFull); guest.PreviousRide = ride.id; guest.PreviousRideTimeOut = 0; // Change status "Heading to" to "Walking" if queue is full @@ -2493,7 +2493,7 @@ static void GuestRideIsTooIntense(Guest& guest, Ride& ride, bool peepAtRide) static Vehicle* PeepChooseCarFromRide(Guest& guest, const Ride& ride, std::span carArray) { uint8_t chosen_car = ScenarioRand(); - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasGForces) && ((chosen_car & 0xC) != 0xC)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::hasGForces) && ((chosen_car & 0xC) != 0xC)) { chosen_car = (ScenarioRand() & 1) ? 0 : static_cast(carArray.size()) - 1; } @@ -2590,7 +2590,7 @@ static bool FindVehicleToEnter( if (ride.mode == RideMode::dodgems || ride.mode == RideMode::race) { - if (ride.lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) + if (ride.flags.has(RideFlag::passStationNoStopping)) return false; for (int32_t i = 0; i < ride.numTrains; ++i) @@ -2903,7 +2903,7 @@ static void GuestUpdateRideNauseaGrowth(Guest& guest, const Ride& ride) static bool GuestShouldGoOnRideAgain(Guest& guest, const Ride& ride) { - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::guestsWillRideAgain)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::guestsWillRideAgain)) return false; if (!RideHasRatings(ride)) return false; @@ -3025,8 +3025,8 @@ static PeepThoughtType GuestAssessSurroundings(int16_t centre_x, int16_t centre_ if (ride == nullptr) break; - bool isPlayingMusic = ride->lifecycleFlags & RIDE_LIFECYCLE_MUSIC && ride->status != RideStatus::closed - && !(ride->lifecycleFlags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)); + bool isPlayingMusic = ride->flags.has(RideFlag::music) && ride->status != RideStatus::closed + && !ride->flags.hasAny(RideFlag::brokenDown, RideFlag::crashed); if (!isPlayingMusic) break; @@ -3249,7 +3249,7 @@ static void PeepHeadForNearestRide(Guest& guest, bool considerOnlyCloseRides, T { if (rideConsideration[ride.id.ToUnderlying()]) { - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_QUEUE_FULL)) + if (!ride.flags.has(RideFlag::queueFull)) { if (guest.ShouldGoOnRide(ride, StationIndex::FromUnderlying(0), false, true)) { @@ -3290,7 +3290,7 @@ static void PeepHeadForNearestRide(Guest& guest, bool considerOnlyCloseRides, T static void GuestHeadForNearestRideWithFlag(Guest& guest, bool considerOnlyCloseRides, RtdFlag rtdFlag) { PeepHeadForNearestRide( - guest, considerOnlyCloseRides, [rtdFlag](const Ride& ride) { return ride.getRideTypeDescriptor().HasFlag(rtdFlag); }); + guest, considerOnlyCloseRides, [rtdFlag](const Ride& ride) { return ride.getRideTypeDescriptor().flags.has(rtdFlag); }); } static void GuestHeadForNearestRideWithSpecialType(Guest& guest, bool considerOnlyCloseRides, RtdSpecialType specialType) @@ -3316,10 +3316,10 @@ static void GuestStopPurchaseThought(Guest& guest, ride_type_t rideType) auto thoughtType = PeepThoughtType::Hungry; const auto& rtd = GetRideTypeDescriptor(rideType); - if (!rtd.HasFlag(RtdFlag::sellsFood)) + if (!rtd.flags.has(RtdFlag::sellsFood)) { thoughtType = PeepThoughtType::Thirsty; - if (!rtd.HasFlag(RtdFlag::sellsDrinks)) + if (!rtd.flags.has(RtdFlag::sellsDrinks)) { thoughtType = PeepThoughtType::RunningOut; if (rtd.specialType != RtdSpecialType::cashMachine) @@ -3537,7 +3537,7 @@ void Guest::UpdateRideAtEntrance() sfl::static_vector carArray; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::noVehicles)) { if (ride->numRiders >= ride->operationOption) return; @@ -3554,7 +3554,7 @@ void Guest::UpdateRideAtEntrance() return; } - if (ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride->flags.has(RideFlag::brokenDown)) return; auto ridePrice = RideGetPrice(*ride); @@ -3564,7 +3564,7 @@ void Guest::UpdateRideAtEntrance() return; } - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::noVehicles)) { Vehicle* vehicle = PeepChooseCarFromRide(*this, *ride, carArray); PeepChooseSeatFromCar(this, *ride, vehicle); @@ -3763,7 +3763,7 @@ void Guest::UpdateRideAdvanceThroughEntrance() return; } - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::noVehicles)) { const auto& station = ride->getStation(CurrentRideStation); auto entranceLocation = station.Entrance.ToCoordsXYZD(); @@ -3824,7 +3824,7 @@ void Guest::UpdateRideAdvanceThroughEntrance() } auto destination = GetDestination(); - auto loadPositionWithReversal = (vehicle->HasFlag(VehicleFlags::CarIsReversed)) ? -load_position : load_position; + auto loadPositionWithReversal = (vehicle->flags.has(VehicleFlag::carIsReversed)) ? -load_position : load_position; switch (vehicle->Orientation / 8) { case 0: @@ -3942,7 +3942,7 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride& ride) ride.formatNameTo(ft); StringId msg_string; - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::describeAsInside)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::describeAsInside)) msg_string = STR_PEEP_TRACKING_PEEP_IS_IN_X; else msg_string = STR_PEEP_TRACKING_PEEP_IS_ON_X; @@ -4000,7 +4000,7 @@ void Guest::UpdateRideFreeVehicleCheck() if (ride == nullptr) return; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::noVehicles)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::noVehicles)) { if (ride->status != RideStatus::open || ride->vehicleChangeTimeout != 0 || (++RejoinQueueTimeout) == 0) { @@ -4031,7 +4031,7 @@ void Guest::UpdateRideFreeVehicleCheck() if (rideEntry->Cars[0].flags.has(CarEntryFlag::isMiniGolf)) { - vehicle->mini_golf_flags &= ~MiniGolfFlag::Flag5; + vehicle->miniGolfFlags.unset(MiniGolfFlag::flag5); for (size_t i = 0; i < ride->numTrains; ++i) { @@ -4046,7 +4046,7 @@ void Guest::UpdateRideFreeVehicleCheck() if (second_vehicle->num_peeps == 0) continue; - if (second_vehicle->mini_golf_flags & MiniGolfFlag::Flag5) + if (second_vehicle->miniGolfFlags.has(MiniGolfFlag::flag5)) continue; return; @@ -4082,7 +4082,7 @@ void Guest::UpdateRideFreeVehicleCheck() { return; } - if (ride->status == RideStatus::open && ++RejoinQueueTimeout != 0 && !currentTrain->HasFlag(VehicleFlags::ReadyToDepart)) + if (ride->status == RideStatus::open && ++RejoinQueueTimeout != 0 && !currentTrain->flags.has(VehicleFlag::readyToDepart)) { return; } @@ -4236,7 +4236,7 @@ void Guest::UpdateRideLeaveVehicle() platformLocation.direction = DirectionReverse(exitLocation.direction); - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::vehicleIsIntegral)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::vehicleIsIntegral)) { for (; vehicle != nullptr && !vehicle->IsHead(); vehicle = gameState.entities.GetEntity(vehicle->prev_vehicle_on_ride)) @@ -4485,7 +4485,7 @@ void Guest::UpdateRideInExit() MoveTo({ loc.value(), z }); } - if (ride->lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) + if (ride->flags.has(RideFlag::onRidePhoto)) { ShopItem secondaryItem = ride->getRideTypeDescriptor().PhotoItem; if (GuestDecideAndBuyItem(*this, *ride, secondaryItem, ride->price[1])) @@ -4809,7 +4809,7 @@ void Guest::UpdateRideOnSpiralSlide() return; case PeepSpiralSlideSubState::prepareToSlide: - if (ride->slideInUse || ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride->slideInUse || ride->flags.has(RideFlag::brokenDown)) return; ride->slideInUse = 1; @@ -6421,14 +6421,14 @@ static bool PeepShouldWatchRide(TileElement* tileElement) return true; } - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::interestingToLookAt)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::interestingToLookAt)) { if ((ScenarioRand() & 0xFFFF) > 0x3333) { return false; } } - else if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::slightlyInterestingToLookAt)) + else if (ride->getRideTypeDescriptor().flags.has(RtdFlag::slightlyInterestingToLookAt)) { if ((ScenarioRand() & 0xFFFF) > 0x1000) { @@ -6466,7 +6466,7 @@ bool Loc690FD0(Guest& guest, RideId* rideToView, uint8_t* rideSeatToView, TileEl else { *rideSeatToView = 0; - if (ride->status == RideStatus::open && !(ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + if (ride->status == RideStatus::open && !ride->flags.has(RideFlag::brokenDown)) { if (tileElement->GetClearanceZ() > guest.NextLoc.z + (8 * kCoordsZStep)) { diff --git a/src/openrct2/entity/Peep.cpp b/src/openrct2/entity/Peep.cpp index 38c3a475d6..bc1cf59ea6 100644 --- a/src/openrct2/entity/Peep.cpp +++ b/src/openrct2/entity/Peep.cpp @@ -17,7 +17,7 @@ #include "../Input.h" #include "../OpenRCT2.h" #include "../SpriteIds.h" -#include "../actions/GameAction.h" +#include "../actions/GameAction.hpp" #include "../audio/Audio.h" #include "../audio/AudioChannel.h" #include "../audio/AudioMixer.h" @@ -26,7 +26,6 @@ #include "../core/Guard.hpp" #include "../core/String.hpp" #include "../drawing/Drawing.h" -#include "../drawing/LightFX.h" #include "../entity/Balloon.h" #include "../entity/EntityList.h" #include "../entity/EntityRegistry.h" @@ -41,9 +40,7 @@ #include "../network/Network.h" #include "../object/ObjectManager.h" #include "../object/PeepAnimationsObject.h" -#include "../paint/Paint.h" #include "../peep/GuestPathfinding.h" -#include "../peep/PeepSpriteIds.h" #include "../profiling/Profiling.h" #include "../ride/Ride.h" #include "../ride/RideData.h" @@ -79,8 +76,6 @@ using namespace OpenRCT2; using namespace OpenRCT2::Audio; using namespace OpenRCT2::Drawing; -using OpenRCT2::Drawing::LightFx::LightType; - static uint8_t _backupAnimationImageIdOffset; static TileElement* _peepRideEntranceExitElement; @@ -998,7 +993,7 @@ void PeepProblemWarningsUpdate() break; } ride = GetRide(peep->GuestHeadingToRideId); - if (ride != nullptr && !ride->getRideTypeDescriptor().HasFlag(RtdFlag::sellsFood)) + if (ride != nullptr && !ride->getRideTypeDescriptor().flags.has(RtdFlag::sellsFood)) hungerCounter++; break; @@ -1009,7 +1004,7 @@ void PeepProblemWarningsUpdate() break; } ride = GetRide(peep->GuestHeadingToRideId); - if (ride != nullptr && !ride->getRideTypeDescriptor().HasFlag(RtdFlag::sellsDrinks)) + if (ride != nullptr && !ride->getRideTypeDescriptor().flags.has(RtdFlag::sellsDrinks)) thirstCounter++; break; @@ -1251,7 +1246,8 @@ void PeepApplause() { for (auto peep : EntityList()) { - if (peep->OutsideOfPark) + if (peep->OutsideOfPark || peep->PeepFlags & PEEP_FLAGS_POSITION_FROZEN + || peep->PeepFlags & PEEP_FLAGS_ANIMATION_FROZEN) continue; // Release balloon @@ -1303,7 +1299,8 @@ void Peep::FormatActionTo(Formatter& ft) const auto ride = GetRide(CurrentRide); if (ride != nullptr) { - ft.Add(ride->getRideTypeDescriptor().HasFlag(RtdFlag::describeAsInside) ? STR_IN_RIDE : STR_ON_RIDE); + ft.Add( + ride->getRideTypeDescriptor().flags.has(RtdFlag::describeAsInside) ? STR_IN_RIDE : STR_ON_RIDE); ride->formatNameTo(ft); } else @@ -2236,7 +2233,7 @@ static bool PeepInteractWithShop(Peep* peep, const CoordsXYE& coords) { RideId rideIndex = coords.element->AsTrack()->GetRideIndex(); auto ride = GetRide(rideIndex); - if (ride == nullptr || !ride->getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride == nullptr || !ride->getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) return false; auto* guest = peep->As(); @@ -2273,7 +2270,7 @@ static bool PeepInteractWithShop(Peep* peep, const CoordsXYE& coords) return true; } - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::guestsShouldGoInsideFacility)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::guestsShouldGoInsideFacility)) { guest->TimeLost = 0; if (!guest->ShouldGoOnRide(*ride, StationIndex::FromUnderlying(0), false, false)) @@ -2303,7 +2300,7 @@ static bool PeepInteractWithShop(Peep* peep, const CoordsXYE& coords) auto ft = Formatter(); guest->FormatNameTo(ft); ride->formatNameTo(ft); - StringId string_id = ride->getRideTypeDescriptor().HasFlag(RtdFlag::describeAsInside) + StringId string_id = ride->getRideTypeDescriptor().flags.has(RtdFlag::describeAsInside) ? STR_PEEP_TRACKING_PEEP_IS_IN_X : STR_PEEP_TRACKING_PEEP_IS_ON_X; if (Config::Get().notifications.guestUsedFacility) @@ -2741,111 +2738,6 @@ void Peep::Serialise(DataSerialiser& stream) stream << PeepFlags; } -void Peep::Paint(PaintSession& session, int32_t imageDirection) const -{ - PROFILED_FUNCTION(); - - if (LightFx::IsAvailable()) - { - if (Is()) - { - auto loc = GetLocation(); - switch (Orientation) - { - case 0: - loc.x -= 10; - break; - case 8: - loc.y += 10; - break; - case 16: - loc.x += 10; - break; - case 24: - loc.y -= 10; - break; - default: - return; - } - - LightFx::Add3DLight(*this, 0, loc, LightType::Spot1); - } - } - - if (session.rt.zoom_level > ZoomLevel{ 2 }) - { - return; - } - - PeepAnimationType actionAnimationGroup = AnimationType; - uint8_t imageOffset = AnimationImageIdOffset; - - if (Action == PeepActionType::idle) - { - actionAnimationGroup = NextAnimationType; - imageOffset = 0; - } - - auto& objManager = GetContext()->GetObjectManager(); - auto* animObj = objManager.GetLoadedObject(AnimationObjectIndex); - - uint32_t baseImageId = animObj->GetPeepAnimation(AnimationGroup, actionAnimationGroup).baseImage; - - // Offset frame onto the base image, using rotation except for the 'picked up' state - if (actionAnimationGroup != PeepAnimationType::hanging) - baseImageId += (imageDirection >> 3) + imageOffset * 4; - else - baseImageId += imageOffset; - - auto imageId = ImageId(baseImageId, TshirtColour, TrousersColour); - - // In the following 4 calls to PaintAddImageAsParent/PaintAddImageAsChild, we add 5 (instead of 3) to the - // bound_box_offset_z to make sure peeps are drawn on top of railways - auto bb = BoundBoxXYZ{ { 0, 0, z + 5 }, { 1, 1, 11 } }; - auto offset = CoordsXYZ{ 0, 0, z }; - PaintAddImageAsParent(session, imageId, { 0, 0, z }, bb); - - auto* guest = As(); - if (guest == nullptr) - return; - - // Can't display any accessories whilst drowning or clapping - if (Action == PeepActionType::drowning || Action == PeepActionType::clap) - return; - - // There are only 6 walking frames available for each item, - // as well as 1 sprite for sitting and 1 for standing still. - auto itemFrame = imageOffset % 6; - if (actionAnimationGroup == PeepAnimationType::watchRide) - itemFrame = 6; - else if (actionAnimationGroup == PeepAnimationType::sittingIdle) - itemFrame = 7; - - if (AnimationGroup == PeepAnimationGroup::hat) - { - auto itemOffset = kPeepSpriteHatItemStart; - imageId = ImageId(itemOffset + (imageDirection >> 3) + itemFrame * 4, guest->HatColour); - PaintAddImageAsChild(session, imageId, offset, bb); - return; - } - - if (AnimationGroup == PeepAnimationGroup::balloon) - { - auto itemOffset = kPeepSpriteBalloonItemStart; - imageId = ImageId(itemOffset + (imageDirection >> 3) + itemFrame * 4, guest->BalloonColour); - PaintAddImageAsChild(session, imageId, offset, bb); - return; - } - - if (AnimationGroup == PeepAnimationGroup::umbrella) - { - auto itemOffset = kPeepSpriteUmbrellaItemStart; - imageId = ImageId(itemOffset + (imageDirection >> 3) + itemFrame * 4, guest->UmbrellaColour); - PaintAddImageAsChild(session, imageId, offset, bb); - return; - } -} - /** * * rct2: 0x0069A98C diff --git a/src/openrct2/entity/Peep.h b/src/openrct2/entity/Peep.h index 6f588da48d..562d5cf2c4 100644 --- a/src/openrct2/entity/Peep.h +++ b/src/openrct2/entity/Peep.h @@ -28,8 +28,6 @@ constexpr uint8_t kPeepMaxEnergyTarget = 255; // Oddly, this differs from max en constexpr auto kPeepClearanceHeight = 4 * kCoordsZStep; -struct PaintSession; - namespace OpenRCT2 { class Formatter; @@ -421,7 +419,6 @@ public: // Peep [[nodiscard]] CoordsXY GetDestination() const; void Serialise(class DataSerialiser& stream); - void Paint(PaintSession& session, int32_t imageDirection) const; // TODO: Make these private again when done refactoring public: // Peep diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index adf67de0a0..ce6cad7ac8 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -12,7 +12,7 @@ #include "../Context.h" #include "../Diagnostic.h" #include "../GameState.h" -#include "../actions/StaffSetOrdersAction.h" +#include "../actions/peep/StaffSetOrdersAction.h" #include "../audio/Audio.h" #include "../core/DataSerialiser.h" #include "../entity/EntityList.h" @@ -1244,12 +1244,12 @@ void Staff::UpdateHeadingToInspect() if (ride->getStation(CurrentRideStation).Exit.IsNull()) { - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; + ride->flags.unset(RideFlag::dueInspection); SetState(PeepState::falling); return; } - if (ride->mechanicStatus != MechanicStatus::heading || !(ride->lifecycleFlags & RIDE_LIFECYCLE_DUE_INSPECTION)) + if (ride->mechanicStatus != MechanicStatus::heading || !ride->flags.has(RideFlag::dueInspection)) { SetState(PeepState::falling); return; @@ -1267,7 +1267,7 @@ void Staff::UpdateHeadingToInspect() MechanicTimeSinceCall++; if (MechanicTimeSinceCall > 2500) { - if (ride->lifecycleFlags & RIDE_LIFECYCLE_DUE_INSPECTION && ride->mechanicStatus == MechanicStatus::heading) + if (ride->flags.has(RideFlag::dueInspection) && ride->mechanicStatus == MechanicStatus::heading) { ride->mechanicStatus = MechanicStatus::calling; } @@ -1975,8 +1975,7 @@ void Staff::UpdateFixing(int32_t steps) bool progressToNextSubstate = true; bool firstRun = true; - if ((State == PeepState::inspecting) - && (ride->lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN))) + if ((State == PeepState::inspecting) && (ride->flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown))) { // Ride has broken down since Mechanic was called to inspect it. // Mechanic identifies the breakdown and switches to fixing it. @@ -2170,7 +2169,7 @@ bool Staff::UpdateFixingFixVehicle(bool firstRun, const Ride& ride) return true; } - vehicle->ClearFlag(VehicleFlags::CarIsBroken); + vehicle->flags.unset(VehicleFlag::carIsBroken); return false; } @@ -2211,7 +2210,7 @@ bool Staff::UpdateFixingFixVehicleMalfunction(bool firstRun, const Ride& ride) return true; } - vehicle->ClearFlag(VehicleFlags::TrainIsBroken); + vehicle->flags.unset(VehicleFlag::trainIsBroken); return false; } @@ -2234,8 +2233,8 @@ bool Staff::UpdateFixingMoveToStationEnd(bool firstRun, const Ride& ride) { if (!firstRun) { - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation) - || !ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation) + || !ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { return true; } @@ -2321,8 +2320,8 @@ bool Staff::UpdateFixingMoveToStationStart(bool firstRun, const Ride& ride) { if (!firstRun) { - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation) - || !ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation) + || !ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { return true; } @@ -2398,8 +2397,8 @@ bool Staff::UpdateFixingFixStationStart(bool firstRun, const Ride& ride) { if (!firstRun) { - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation) - || !ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation) + || !ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { return true; } @@ -2598,7 +2597,7 @@ void Staff::UpdateRideInspected(RideId rideIndex) auto ride = GetRide(rideIndex); if (ride != nullptr) { - ride->lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; + ride->flags.unset(RideFlag::dueInspection); ride->reliability += ((100 - ride->reliabilityPercentage) / 4) * (ScenarioRand() & 0xFF); ride->lastInspection = 0; ride->windowInvalidateFlags.set(RideInvalidateFlag::maintenance, RideInvalidateFlag::main, RideInvalidateFlag::list); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index d83015b612..c932d652e5 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -18,15 +18,16 @@ #include "../PlatformEnvironment.h" #include "../ReplayManager.h" #include "../Version.h" -#include "../actions/CheatSetAction.h" -#include "../actions/GameSetSpeedAction.h" -#include "../actions/ParkSetDateAction.h" -#include "../actions/ParkSetParameterAction.h" -#include "../actions/RideFreezeRatingAction.h" -#include "../actions/RideSetPriceAction.h" -#include "../actions/RideSetSettingAction.h" -#include "../actions/ScenarioSetSettingAction.h" -#include "../actions/StaffSetCostumeAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/cheats/CheatSetAction.h" +#include "../actions/general/GameSetSpeedAction.h" +#include "../actions/general/ScenarioSetSettingAction.h" +#include "../actions/park/ParkSetDateAction.h" +#include "../actions/park/ParkSetParameterAction.h" +#include "../actions/peep/StaffSetCostumeAction.h" +#include "../actions/ride/RideFreezeRatingAction.h" +#include "../actions/ride/RideSetPriceAction.h" +#include "../actions/ride/RideSetSettingAction.h" #include "../config/Config.h" #include "../core/Console.hpp" #include "../core/EnumUtils.hpp" @@ -1273,7 +1274,7 @@ static void ConsoleCommandForceDate([[maybe_unused]] InteractiveConsole& console int32_t year = 0; int32_t month = 0; int32_t day = 0; - if (argv.size() < 1 || argv.size() > 3) + if (argv.empty() || argv.size() > 3) { return; } @@ -1327,7 +1328,7 @@ static void ConsoleCommandForceDate([[maybe_unused]] InteractiveConsole& console static void ConsoleCommandLoadPark([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - if (argv.size() < 1) + if (argv.empty()) { console.WriteLine("Parameters required "); return; @@ -1362,7 +1363,7 @@ static void ConsoleCommandLoadPark([[maybe_unused]] InteractiveConsole& console, static void ConsoleCommandSavePark([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - if (argv.size() < 1) + if (argv.empty()) { SaveGameCmd(); } @@ -1398,7 +1399,7 @@ static void ConsoleCommandReplayStartRecord(InteractiveConsole& console, const a return; } - if (argv.size() < 1) + if (argv.empty()) { console.WriteFormatLine("Parameters required []"); return; @@ -1471,7 +1472,7 @@ static void ConsoleCommandReplayStart(InteractiveConsole& console, const argumen return; } - if (argv.size() < 1) + if (argv.empty()) { console.WriteFormatLine("Parameters required "); return; @@ -1556,7 +1557,7 @@ static void ConsoleCommandReplayNormalise(InteractiveConsole& console, const arg static void ConsoleCommandMpDesync(InteractiveConsole& console, const arguments_t& argv) { int32_t desyncType = 0; - if (argv.size() >= 1) + if (!argv.empty()) { desyncType = atoi(argv[0].c_str()); } @@ -1686,42 +1687,71 @@ static void ConsoleCommandAddNewsItem([[maybe_unused]] InteractiveConsole& conso static void ConsoleCommandProfilerReset([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - Profiling::ResetData(); + Profiling::resetData(); + console.WriteLine("Profiler data reset"); } + +static void ConsoleCommandProfilerStatus([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) +{ + const auto& data = Profiling::getData(); + console.WriteFormatLine("Profiler status: %s", Profiling::isEnabled() ? "ENABLED" : "DISABLED"); + console.WriteFormatLine("Registered functions: %zu", data.size()); + + if (!data.empty()) + { + uint64_t totalCalls = 0; + double totalTimeUs = 0.0; + size_t functionsWithData = 0; + + for (const auto& f : data) + { + auto calls = f->getCallCount(); + totalCalls += calls; + totalTimeUs += f->getTotalTime(); + if (calls > 0) + functionsWithData++; + } + + console.WriteFormatLine("Functions with data: %zu / %zu", functionsWithData, data.size()); + console.WriteFormatLine("Total recorded calls: %llu", static_cast(totalCalls)); + console.WriteFormatLine("Total recorded time: %.3f ms", totalTimeUs / 1000.0); + } +} + static void ConsoleCommandProfilerStart([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - if (!Profiling::IsEnabled()) + if (!Profiling::isEnabled()) console.WriteLine("Started profiler"); - Profiling::Enable(); + Profiling::enable(); } -static void ConsoleCommandProfilerExportCSV( - [[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) +static void ConsoleCommandProfilerExport([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - if (argv.size() < 1) + if (argv.empty()) { console.WriteLineError("Missing argument: "); + return; } - const auto& csvFilePath = argv[0]; - if (!Profiling::ExportCSV(csvFilePath)) + const auto& filePath = argv[0]; + if (!Profiling::exportData(filePath)) { - console.WriteFormatLine("Unable to export CSV file to %s", csvFilePath.c_str()); + console.WriteFormatLine("Unable to export profiler data to %s", filePath.c_str()); + return; } - console.WriteFormatLine("Wrote file CSV file: \"%s\"", csvFilePath.c_str()); + console.WriteFormatLine("Wrote profiler data: \"%s\"", filePath.c_str()); } static void ConsoleCommandProfilerStop([[maybe_unused]] InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) { - if (Profiling::IsEnabled()) + if (Profiling::isEnabled()) console.WriteLine("Stopped profiler"); - Profiling::Disable(); + Profiling::disable(); - // Export to CSV if argument is provided. - if (argv.size() >= 1) + if (!argv.empty()) { - return ConsoleCommandProfilerExportCSV(console, argv); + return ConsoleCommandProfilerExport(console, argv); } } @@ -1848,9 +1878,11 @@ static constexpr ConsoleCommand console_command_table[] = { "ConsoleCommandMpDesync [desync_type, 0 = Random t-shirt color on random guest, 1 = Remove random guest ]" }, { "profiler_reset", ConsoleCommandProfilerReset, "Resets the profiler data.", "profiler_reset" }, { "profiler_start", ConsoleCommandProfilerStart, "Starts the profiler.", "profiler_start" }, - { "profiler_stop", ConsoleCommandProfilerStop, "Stops the profiler.", "profiler_stop []" }, - { "profiler_exportcsv", ConsoleCommandProfilerExportCSV, "Exports the current profiler data.", - "profiler_exportcsv " }, + { "profiler_status", ConsoleCommandProfilerStatus, "Shows profiler status and statistics.", "profiler_status" }, + { "profiler_stop", ConsoleCommandProfilerStop, "Stops the profiler and optionally exports data.", + "profiler_stop []" }, + { "profiler_export", ConsoleCommandProfilerExport, "Exports profiler data (format from extension, default CSV).", + "profiler_export " }, }; static void ConsoleCommandWindows(InteractiveConsole& console, [[maybe_unused]] const arguments_t& argv) diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 092d909259..7b4d503e98 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -15,7 +15,7 @@ #include "../GameState.h" #include "../OpenRCT2.h" #include "../PlatformEnvironment.h" -#include "../actions/CheatSetAction.h" +#include "../actions/cheats/CheatSetAction.h" #include "../audio/Audio.h" #include "../config/Config.h" #include "../core/Console.hpp" @@ -55,7 +55,7 @@ uint8_t gScreenshotCountdown = 0; static bool WriteRTToFile(std::string_view path, const RenderTarget& rt, const GamePalette& palette) { - auto const pixels8 = rt.bits; + auto const pixels8 = reinterpret_cast(rt.bits); auto const pixelsLen = rt.LineStride() * rt.height; try { @@ -233,7 +233,7 @@ static RenderTarget CreateRT(const Viewport& viewport) RenderTarget rt; rt.width = viewport.width; rt.height = viewport.height; - rt.bits = new (std::nothrow) uint8_t[rt.width * rt.height]; + rt.bits = new (std::nothrow) PaletteIndex[rt.width * rt.height]; if (rt.bits == nullptr) { throw std::runtime_error("Giant screenshot failed, unable to allocate memory for image."); diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 9c32bfdc5c..00bb36bf7a 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -694,7 +694,7 @@ namespace OpenRCT2 || (peep.State == PeepState::leavingRide && peep.x == kLocationNull)) { auto ride = GetRide(peep.CurrentRide); - if (ride != nullptr && (ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (ride != nullptr && ride->flags.has(RideFlag::onTrack)) { auto train = getGameState().entities.GetEntity(ride->vehicles[peep.CurrentTrain]); if (train != nullptr) @@ -1381,7 +1381,7 @@ namespace OpenRCT2 break; auto ride = vehicle->GetRide(); - if (ride != nullptr && !ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (ride != nullptr && !ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { return (viewFlags & VIEWPORT_FLAG_INVISIBLE_RIDES) ? VisibilityKind::hidden : VisibilityKind::partial; diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 6e7a86c8a0..c4816bddb5 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -79,92 +79,97 @@ - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -386,18 +391,27 @@ - + + + + + + + + + + @@ -685,92 +699,94 @@ - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -956,6 +972,9 @@ + + + @@ -1107,7 +1126,19 @@ + + + + + + + + $(IntDir)ride\ + + + + diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index c02f22f875..a66fafdc54 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -187,7 +187,6 @@ enum : StringId STR_CANT_RAISE_WATER_LEVEL_HERE = 1167, STR_STRING = 1170, STR_RIDE_ENTRANCE_CLOSED = 1171, - STR_RIDE_ENTRANCE_NAME = 1172, STR_BANNER_SIGN_IN_THE_WAY = 1174, STR_CANT_BUILD_THIS_ON_SLOPED_FOOTPATH = 1175, STR_CANT_BUILD_FOOTPATH_HERE = 1176, @@ -581,7 +580,7 @@ enum : StringId STR_CANT_BUY_CONSTRUCTION_RIGHTS_HERE = 1728, STR_LAND_NOT_OWNED_BY_PARK = 1729, STR_BANNER_TEXT_CLOSED = 1730, - STR_BANNER_TEXT_FORMAT = 1731, + STR_BANNER_TEXT_FORMAT = 7022, // STR_1737 :{COMMA16} STR_CANT_CHANGE_NUMBER_OF_LAPS = 1738, STR_RACE_WON_BY_GUEST = 1739, @@ -602,7 +601,6 @@ enum : StringId STR_ONLY_ONE_CABLE_LIFT_HILL_PER_RIDE = 1774, // STR_OPTIONS_RIDE_MUSIC_OFF = 1775, // STR_OPTIONS_RIDE_MUSIC_ON = 1776, - STR_SCROLLING_SIGN_TEXT = 1778, // STR_STAFF_OPTION_COSTUME_PANDA = 1779, // STR_STAFF_OPTION_COSTUME_TIGER = 1780, // STR_STAFF_OPTION_COSTUME_ELEPHANT = 1781, diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index b8a8390f61..4ace4097d9 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -157,7 +157,7 @@ static bool AwardIsDeservedBestRollercoasters(GameState_t& gameState, [[maybe_un continue; } - if (ride.status != RideStatus::open || (ride.lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) + if (ride.status != RideStatus::open || ride.flags.has(RideFlag::crashed)) { continue; } @@ -300,7 +300,7 @@ static bool AwardIsDeservedBestFood(GameState_t& gameState, int32_t activeAwardT { if (ride.status != RideStatus::open) continue; - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::sellsFood)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::sellsFood)) continue; shops++; @@ -345,7 +345,7 @@ static bool AwardIsDeservedWorstFood(GameState_t& gameState, int32_t activeAward { if (ride.status != RideStatus::open) continue; - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::sellsFood)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::sellsFood)) continue; shops++; @@ -448,7 +448,7 @@ static bool AwardIsDeservedBestWaterRides(GameState_t& gameState, [[maybe_unused continue; } - if (ride.status != RideStatus::open || (ride.lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) + if (ride.status != RideStatus::open || ride.flags.has(RideFlag::crashed)) { continue; } @@ -473,13 +473,13 @@ static bool AwardIsDeservedBestCustomDesignedRides(GameState_t& gameState, int32 auto customDesignedRides = 0; for (const auto& ride : RideManager(gameState)) { - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) continue; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN) + if (ride.flags.has(RideFlag::notCustomDesign)) continue; if (ride.ratings.excitement < RideRating::make(5, 50)) continue; - if (ride.status != RideStatus::open || (ride.lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) + if (ride.status != RideStatus::open || ride.flags.has(RideFlag::crashed)) continue; customDesignedRides++; @@ -505,7 +505,7 @@ static bool AwardIsDeservedMostDazzlingRideColours(GameState_t& gameState, int32 auto colourfulRides = 0; for (const auto& ride : RideManager(gameState)) { - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) continue; countedRides++; @@ -555,7 +555,7 @@ static bool AwardIsDeservedBestGentleRides(GameState_t& gameState, [[maybe_unuse continue; } - if (ride.status != RideStatus::open || (ride.lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) + if (ride.status != RideStatus::open || ride.flags.has(RideFlag::crashed)) { continue; } diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index 30acf618ff..04bd9b3654 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -174,7 +174,7 @@ void FinancePayRideUpkeep() auto& gameState = getGameState(); for (auto& ride : RideManager(gameState)) { - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)) + if (!ride.flags.has(RideFlag::everBeenOpened)) { ride.renew(); } diff --git a/src/openrct2/management/Marketing.cpp b/src/openrct2/management/Marketing.cpp index 76bb1ea3b0..041e4c873b 100644 --- a/src/openrct2/management/Marketing.cpp +++ b/src/openrct2/management/Marketing.cpp @@ -201,10 +201,10 @@ bool MarketingIsCampaignTypeApplicable(int32_t campaignType) [[fallthrough]]; case ADVERTISING_CAMPAIGN_RIDE: - // Check if any rides exist + // Check if any rides exist and are open for (auto& ride : RideManager(gameState)) { - if (ride.isRide()) + if (ride.isRide() && ride.status == RideStatus::open) { return true; } @@ -216,7 +216,7 @@ bool MarketingIsCampaignTypeApplicable(int32_t campaignType) for (auto& ride : RideManager(gameState)) { auto rideEntry = ride.getRideEntry(); - if (rideEntry != nullptr) + if (rideEntry != nullptr && ride.status == RideStatus::open) { for (auto& item : rideEntry->shop_item) { diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index 4d0a19f36d..aba5cc2b4b 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -246,7 +246,7 @@ std::optional News::GetSubjectLocation(ItemType type, int32_t subject // Find which ride peep is on Ride* ride = GetRide(peep->CurrentRide); - if (ride == nullptr || !(ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (ride == nullptr || !ride->flags.has(RideFlag::onTrack)) { subjectLoc = std::nullopt; break; diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index c608ba27ce..d5700dc10f 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -15,7 +15,8 @@ #include "../Game.h" #include "../GameState.h" #include "../OpenRCT2.h" -#include "../actions/ParkSetResearchFundingAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/park/ParkSetResearchFundingAction.h" #include "../config/Config.h" #include "../core/BitSet.hpp" #include "../core/EnumUtils.hpp" @@ -250,7 +251,7 @@ void ResearchFinishItem(const ResearchItem& researchItem) // If a vehicle is the first to be invented for its ride type, show the ride type/group name. // Independently listed vehicles (like all flat rides and shops) should always be announced as such. - if (GetRideTypeDescriptor(base_ride_type).HasFlag(RtdFlag::listVehiclesSeparately) + if (GetRideTypeDescriptor(base_ride_type).flags.has(RtdFlag::listVehiclesSeparately) || researchItem.flags & RESEARCH_ENTRY_FLAG_FIRST_OF_TYPE) { RideNaming naming = GetRideNaming(base_ride_type, rideEntry); @@ -1043,7 +1044,7 @@ static void ResearchUpdateFirstOfType(ResearchItem* researchItem) researchItem->flags &= ~RESEARCH_ENTRY_FLAG_FIRST_OF_TYPE; const auto& rtd = GetRideTypeDescriptor(rideType); - if (rtd.HasFlag(RtdFlag::listVehiclesSeparately)) + if (rtd.flags.has(RtdFlag::listVehiclesSeparately)) { researchItem->flags |= RESEARCH_ENTRY_FLAG_FIRST_OF_TYPE; return; @@ -1077,7 +1078,7 @@ void ResearchDetermineFirstOfType() continue; const auto& rtd = GetRideTypeDescriptor(rideType); - if (rtd.HasFlag(RtdFlag::listVehiclesSeparately)) + if (rtd.flags.has(RtdFlag::listVehiclesSeparately)) continue; // The last research item will also be present in gameState.researchItemsInvented. diff --git a/src/openrct2/network/Network.h b/src/openrct2/network/Network.h index 68708eca7d..4496c7f41f 100644 --- a/src/openrct2/network/Network.h +++ b/src/openrct2/network/Network.h @@ -9,9 +9,10 @@ #pragma once -#include "../Game.h" +#include "../actions/GameCommand.h" #include "../core/JsonFwd.hpp" #include "../core/Money.hpp" +#include "../core/StringTypes.h" #include "../localisation/StringIds.h" #include "NetworkTypes.h" @@ -93,8 +94,8 @@ namespace OpenRCT2::Network [[nodiscard]] uint8_t GetDefaultGroup(); [[nodiscard]] int32_t GetNumActions(); [[nodiscard]] StringId GetActionNameStringID(uint32_t index); - [[nodiscard]] int32_t CanPerformAction(uint32_t groupindex, Permission index); - [[nodiscard]] int32_t CanPerformCommand(uint32_t groupindex, int32_t index); + [[nodiscard]] bool CanPerformAction(uint32_t groupindex, Permission index); + [[nodiscard]] bool CanPerformCommand(uint32_t groupindex, int32_t index); void SetPickupPeep(uint8_t playerid, Peep* peep); [[nodiscard]] Peep* GetPickupPeep(uint8_t playerid); void SetPickupPeepOldX(uint8_t playerid, int32_t x); diff --git a/src/openrct2/network/NetworkAction.h b/src/openrct2/network/NetworkAction.h index bafa4880aa..09aeb2f12f 100644 --- a/src/openrct2/network/NetworkAction.h +++ b/src/openrct2/network/NetworkAction.h @@ -9,7 +9,7 @@ #pragma once -#include "../Game.h" +#include "../actions/GameCommand.h" #include "../localisation/StringIdType.h" #include diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 39c128f1ee..ce7154ed2f 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -17,9 +17,10 @@ #include "../OpenRCT2.h" #include "../PlatformEnvironment.h" #include "../Version.h" -#include "../actions/LoadOrQuitAction.h" -#include "../actions/NetworkModifyGroupAction.h" -#include "../actions/PeepPickupAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/general/LoadOrQuitAction.h" +#include "../actions/network/NetworkModifyGroupAction.h" +#include "../actions/peep/PeepPickupAction.h" #include "../core/File.h" #include "../core/Guard.hpp" #include "../core/Json.hpp" @@ -47,7 +48,7 @@ // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -constexpr uint8_t kStreamVersion = 0; +constexpr uint8_t kStreamVersion = 2; const std::string kStreamID = std::string(kOpenRCT2Version) + "-" + std::to_string(kStreamVersion); @@ -67,7 +68,7 @@ static constexpr uint32_t kMaxPacketsPerTick = 100; #include "../Cheats.h" #include "../ParkImporter.h" #include "../Version.h" - #include "../actions/GameAction.h" + #include "../actions/GameAction.hpp" #include "../config/Config.h" #include "../core/Console.hpp" #include "../core/EnumUtils.hpp" @@ -790,7 +791,7 @@ namespace OpenRCT2::Network } } - if (colours.size() == 0 || (colours.size() == 1 && colours[0] == "{WHITE}")) + if (colours.empty() || (colours.size() == 1 && colours[0] == "{WHITE}")) { formatted += "{BABYBLUE}"; formatted += fromPlayer->Name; @@ -1677,7 +1678,7 @@ namespace OpenRCT2::Network { json_t jsonObj = { { "name", Config::Get().network.serverName }, - { "requiresPassword", _password.size() > 0 }, + { "requiresPassword", !_password.empty() }, { "version", GetVersion() }, { "players", GetNumVisiblePlayers() }, { "maxPlayers", Config::Get().network.maxplayers }, @@ -3826,18 +3827,20 @@ namespace OpenRCT2::Network return kStringIdNone; } - int32_t CanPerformAction(uint32_t groupindex, Permission index) + bool CanPerformAction(uint32_t groupindex, Permission index) { auto& network = GetContext()->GetNetwork(); - Guard::IndexInRange(groupindex, network.group_list); + if (groupindex >= network.group_list.size()) + return false; return network.group_list[groupindex]->CanPerformAction(index); } - int32_t CanPerformCommand(uint32_t groupindex, int32_t index) + bool CanPerformCommand(uint32_t groupindex, int32_t index) { auto& network = GetContext()->GetNetwork(); - Guard::IndexInRange(groupindex, network.group_list); + if (groupindex >= network.group_list.size()) + return false; return network.group_list[groupindex]->CanPerformCommand(static_cast(index)); // TODO } @@ -4268,13 +4271,13 @@ namespace OpenRCT2::Network { return -1; } - int32_t CanPerformAction(uint32_t groupindex, Permission index) + bool CanPerformAction(uint32_t groupindex, Permission index) { - return 0; + return false; } - int32_t CanPerformCommand(uint32_t groupindex, int32_t index) + bool CanPerformCommand(uint32_t groupindex, int32_t index) { - return 0; + return false; } void SetPickupPeep(uint8_t playerid, Peep* peep) { diff --git a/src/openrct2/network/NetworkBase.h b/src/openrct2/network/NetworkBase.h index 0abe11a2c7..c64885f4d1 100644 --- a/src/openrct2/network/NetworkBase.h +++ b/src/openrct2/network/NetworkBase.h @@ -1,7 +1,7 @@ #pragma once #include "../System.hpp" -#include "../actions/GameAction.h" +#include "../actions/GameAction.hpp" #include "../scenario/Scenario.h" #include "NetworkConnection.h" #include "NetworkGroup.h" diff --git a/src/openrct2/network/NetworkPlayer.h b/src/openrct2/network/NetworkPlayer.h index 6dfab45c3b..7111a4bf35 100644 --- a/src/openrct2/network/NetworkPlayer.h +++ b/src/openrct2/network/NetworkPlayer.h @@ -9,7 +9,7 @@ #pragma once -#include "../Game.h" +#include "../actions/GameCommand.h" #include "../core/Money.hpp" #include "../world/Location.hpp" diff --git a/src/openrct2/object/ImageTable.cpp b/src/openrct2/object/ImageTable.cpp index 6d2da3f877..05fa2c029a 100644 --- a/src/openrct2/object/ImageTable.cpp +++ b/src/openrct2/object/ImageTable.cpp @@ -244,7 +244,7 @@ namespace OpenRCT2 } } - if (range.size() > 0) + if (!range.empty()) { size_t placeHoldersAdded = 0; for (auto i : range) diff --git a/src/openrct2/object/MusicObject.cpp b/src/openrct2/object/MusicObject.cpp index 33867b4391..be6e469293 100644 --- a/src/openrct2/object/MusicObject.cpp +++ b/src/openrct2/object/MusicObject.cpp @@ -194,7 +194,7 @@ namespace OpenRCT2 bool MusicObject::SupportsRideType(ride_type_t rideType, bool onlyAllowIfExplicitlyListed) { - if (_rideTypes.size() == 0) + if (_rideTypes.empty()) { // Some rides, like the merry-go-round, need music objects to explicitly list them. return !onlyAllowIfExplicitlyListed; diff --git a/src/openrct2/object/Object.cpp b/src/openrct2/object/Object.cpp index c6fd69746f..5a56031c98 100644 --- a/src/openrct2/object/Object.cpp +++ b/src/openrct2/object/Object.cpp @@ -194,7 +194,7 @@ namespace OpenRCT2 ObjectSourceGame Object::GetFirstSourceGame() const { - if (_sourceGames.size() == 0) + if (_sourceGames.empty()) return ObjectSourceGame::custom; return _sourceGames[0]; @@ -423,7 +423,7 @@ namespace OpenRCT2 { LOG_WARNING("%i fields found in version string '%s', expected X.Y.Z", nums.size(), version); } - if (nums.size() == 0) + if (nums.empty()) { LOG_WARNING("No fields found in version string '%s', expected X.Y.Z", version); return std::make_tuple(0, 0, 0); diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index 1a6b4ca654..a10eceb962 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -160,7 +160,7 @@ namespace OpenRCT2 _shouldLoadImages = context->ShouldLoadImages(); stream->Seek(8, STREAM_SEEK_CURRENT); - _legacyType.flags = stream->ReadValue(); + _legacyType.flags.holder = stream->ReadValue(); for (auto& rideType : _legacyType.ride_type) { rideType = stream->ReadValue(); @@ -225,7 +225,7 @@ namespace OpenRCT2 if (_legacyType.ride_type[0] == RIDE_TYPE_FOOD_STALL || _legacyType.ride_type[0] == RIDE_TYPE_DRINK_STALL) { // In RCT2, no food or drink stall could be recoloured. - _legacyType.flags |= RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB; + _legacyType.flags.set(RideEntryFlag::disableColourTab); } } @@ -625,22 +625,22 @@ namespace OpenRCT2 auto swingMode = Json::GetNumber(properties["swingMode"]); if (swingMode == 1) { - _legacyType.flags |= RIDE_ENTRY_FLAG_INVERTER_SHIP_SWING_MODE; + _legacyType.flags.set(RideEntryFlag::inverterShipSwingMode); } else if (swingMode == 2) { - _legacyType.flags |= RIDE_ENTRY_FLAG_INVERTER_SHIP_SWING_MODE; - _legacyType.flags |= RIDE_ENTRY_FLAG_MAGIC_CARPET_SWING_MODE; + _legacyType.flags.set(RideEntryFlag::inverterShipSwingMode); + _legacyType.flags.set(RideEntryFlag::magicCarpetSwingMode); } auto rotationMode = Json::GetNumber(properties["rotationMode"]); if (rotationMode == 1) { - _legacyType.flags |= RIDE_ENTRY_FLAG_TWIST_ROTATION_TYPE; + _legacyType.flags.set(RideEntryFlag::hasTwistRotationType); } else if (rotationMode == 2) { - _legacyType.flags |= RIDE_ENTRY_FLAG_ENTERPRISE_ROTATION_TYPE; + _legacyType.flags.set(RideEntryFlag::hasEnterpriseRotationType); } auto ratingMultiplier = properties["ratingMultipler"]; @@ -653,23 +653,23 @@ namespace OpenRCT2 } _legacyType.BuildMenuPriority = Json::GetNumber(properties["buildMenuPriority"]); - _legacyType.flags |= Json::GetFlags( + _legacyType.flags |= Json::GetFlagHolder( properties, { - { "noInversions", RIDE_ENTRY_FLAG_NO_INVERSIONS }, - { "noBanking", RIDE_ENTRY_FLAG_NO_BANKED_TRACK }, - { "playDepartSound", RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND }, + { "noInversions", RideEntryFlag::noInversions }, + { "noBanking", RideEntryFlag::noBankedTrack }, + { "playDepartSound", RideEntryFlag::playDepartSound }, // Skipping "disallowWandering", no vehicle sets this flag. - { "playSplashSound", RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND }, - { "playSplashSoundSlide", RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE }, - { "hasShelter", RIDE_ENTRY_FLAG_COVERED_RIDE }, - { "limitAirTimeBonus", RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS }, - { "disableBreakdown", RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN }, + { "playSplashSound", RideEntryFlag::playSplashSound }, + { "playSplashSoundSlide", RideEntryFlag::playSplashSoundSlide }, + { "hasShelter", RideEntryFlag::isACoveredRide }, + { "limitAirTimeBonus", RideEntryFlag::limitAirTimeBonus }, + { "disableBreakdown", RideEntryFlag::cannotBreakDown }, // Skipping noDoorsOverTrack, moved to ride groups. - { "noCollisionCrashes", RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES }, - { "disablePainting", RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB }, - { "riderControlsSpeed", RIDE_ENTRY_FLAG_RIDER_CONTROLS_SPEED }, - { "hideEmptyTrains", RIDE_ENTRY_FLAG_HIDE_EMPTY_TRAINS }, + { "noCollisionCrashes", RideEntryFlag::disableCollisionCrashes }, + { "disablePainting", RideEntryFlag::disableColourTab }, + { "riderControlsSpeed", RideEntryFlag::riderControlsSpeed }, + { "hideEmptyTrains", RideEntryFlag::hideEmptyTrains }, }); } @@ -692,7 +692,7 @@ namespace OpenRCT2 float tabScale = Json::GetNumber(properties["tabScale"]); if (tabScale != 0 && tabScale <= 0.5f) { - _legacyType.flags |= RIDE_ENTRY_FLAG_VEHICLE_TAB_SCALE_HALF; + _legacyType.flags.set(RideEntryFlag::tabIconIsHalfScale); } json_t headCars = Json::AsArray(properties["headCars"]); @@ -874,8 +874,7 @@ namespace OpenRCT2 { "isGoKart", CarEntryFlag::isGoKart }, { "useDodgemCarPlacement", CarEntryFlag::useDodgemCarPlacement }, - // Obsolete flag, only used on Boat Hire. Remaining usages have not yet been updated as of 2022-07-11. - // TODO: Is this comment outdated? + // Obsolete flag, used only by older custom content and now superseded by the 'spriteGroups' property { "VEHICLE_ENTRY_FLAG_11", CarEntryFlag::use16RotationFrames }, }); if (Json::GetBoolean(jCar["hasBaseColour"], true)) @@ -966,7 +965,7 @@ namespace OpenRCT2 for (size_t index = 0; index < jCarColours.size(); index++) { auto config = ReadJsonColourConfiguration(jCarColours[index]); - if (config.size() >= 1) + if (!config.empty()) { list.list[index] = config[0]; list.count++; @@ -990,7 +989,7 @@ namespace OpenRCT2 VehicleColour carColour = {}; auto colours = Json::AsArray(jColours); - if (colours.size() >= 1) + if (!colours.empty()) { carColour.Body = Drawing::colourFromString(Json::GetString(colours[0])); carColour.Trim = carColour.Body; @@ -1011,7 +1010,7 @@ namespace OpenRCT2 bool RideObject::isRideTypeShopOrFacility(ride_type_t rideType) { - return GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::isShopOrFacility); + return GetRideTypeDescriptor(rideType).flags.has(RtdFlag::isShopOrFacility); } ride_type_t RideObject::ParseRideType(const std::string& s) diff --git a/src/openrct2/object/StationObject.cpp b/src/openrct2/object/StationObject.cpp index 977150959d..2d85f92ae9 100644 --- a/src/openrct2/object/StationObject.cpp +++ b/src/openrct2/object/StationObject.cpp @@ -24,16 +24,36 @@ namespace OpenRCT2 NameStringId = LanguageAllocateObjectString(GetName()); auto numImages = GetImageTable().GetCount(); - if (numImages != 0) - { - BaseImageId = LoadImages(); + if (numImages == 0) + return; - uint32_t shelterOffset = (Flags & StationObjectFlags::isTransparent) ? 32 : 16; - if (numImages > shelterOffset) - { - ShelterImageId = BaseImageId + shelterOffset; - } + baseImageIndex = LoadImages(); + + entranceBackIndex = baseImageIndex; + entranceFrontIndex = entranceBackIndex + 4; + + exitBackIndex = entranceBackIndex + 8; + exitFrontIndex = entranceBackIndex + 12; + + if (!(Flags & StationObjectFlags::isTransparent)) + { + if (numImages > 16) + shelterIndex = entranceBackIndex + 16; + + return; } + + entranceBackGlassIndex = entranceBackIndex + 16; + entranceFrontGlassIndex = entranceBackIndex + 20; + + exitBackGlassIndex = entranceBackIndex + 24; + exitFrontGlassIndex = entranceBackIndex + 28; + + if (numImages > 32) + shelterIndex = entranceBackIndex + 32; + + if (numImages > 44) + shelterGlassIndex = entranceBackIndex + 44; } void StationObject::Unload() @@ -42,8 +62,20 @@ namespace OpenRCT2 UnloadImages(); NameStringId = 0; - BaseImageId = kImageIndexUndefined; - ShelterImageId = kImageIndexUndefined; + baseImageIndex = kImageIndexUndefined; + + entranceBackIndex = kImageIndexUndefined; + entranceFrontIndex = kImageIndexUndefined; + exitBackIndex = kImageIndexUndefined; + exitFrontIndex = kImageIndexUndefined; + + entranceBackGlassIndex = kImageIndexUndefined; + entranceFrontGlassIndex = kImageIndexUndefined; + exitBackGlassIndex = kImageIndexUndefined; + exitFrontGlassIndex = kImageIndexUndefined; + + shelterIndex = kImageIndexUndefined; + shelterGlassIndex = kImageIndexUndefined; } void StationObject::DrawPreview(Drawing::RenderTarget& rt, int32_t width, int32_t height) const @@ -54,27 +86,22 @@ namespace OpenRCT2 auto colour1 = Drawing::Colour::bordeauxRed; auto tcolour0 = colour0; - auto imageId = ImageId(BaseImageId); - auto tImageId = ImageId(BaseImageId + 16).WithTransparency(tcolour0); - if (Flags & StationObjectFlags::hasPrimaryColour) - { - imageId = imageId.WithPrimary(colour0); - } - if (Flags & StationObjectFlags::hasSecondaryColour) - { - imageId = imageId.WithSecondary(colour1); - } - - GfxDrawSprite(rt, imageId, screenCoords); + // Draw back sprite + auto backImageId = ImageId(entranceBackIndex, colour0, colour1); + GfxDrawSprite(rt, backImageId, screenCoords); if (Flags & StationObjectFlags::isTransparent) { + auto tImageId = ImageId(entranceBackGlassIndex).WithTransparency(tcolour0); GfxDrawSprite(rt, tImageId, screenCoords); } - GfxDrawSprite(rt, imageId.WithIndexOffset(4), screenCoords); + // Draw front sprite + auto frontImageId = ImageId(entranceFrontIndex, colour0, colour1); + GfxDrawSprite(rt, frontImageId, screenCoords); if (Flags & StationObjectFlags::isTransparent) { - GfxDrawSprite(rt, tImageId.WithIndexOffset(4), screenCoords); + auto frontGlassImageId = ImageId(entranceFrontGlassIndex).WithTransparency(tcolour0); + GfxDrawSprite(rt, frontGlassImageId, screenCoords); } } diff --git a/src/openrct2/object/StationObject.h b/src/openrct2/object/StationObject.h index 2e24e8d288..ff78764180 100644 --- a/src/openrct2/object/StationObject.h +++ b/src/openrct2/object/StationObject.h @@ -20,17 +20,42 @@ namespace OpenRCT2 const uint32_t hasSecondaryColour = 1 << 1; const uint32_t isTransparent = 1 << 2; const uint32_t noPlatforms = 1 << 3; - const uint32_t hasShelter = (1 << 4); + const uint32_t hasShelter = 1 << 4; } // namespace StationObjectFlags + enum + { + SPR_STATION_COVER_OFFSET_NE_SW_BACK_0 = 0, + SPR_STATION_COVER_OFFSET_NE_SW_BACK_1, + SPR_STATION_COVER_OFFSET_NE_SW_FRONT, + SPR_STATION_COVER_OFFSET_SE_NW_BACK_0, + SPR_STATION_COVER_OFFSET_SE_NW_BACK_1, + SPR_STATION_COVER_OFFSET_SE_NW_FRONT, + SPR_STATION_COVER_OFFSET_TALL + }; + class StationObject final : public Object { public: static constexpr ObjectType kObjectType = ObjectType::station; StringId NameStringId{}; - ImageIndex BaseImageId = kImageIndexUndefined; - ImageIndex ShelterImageId = kImageIndexUndefined; + + ImageIndex baseImageIndex = kImageIndexUndefined; + + ImageIndex entranceBackIndex = kImageIndexUndefined; + ImageIndex entranceFrontIndex = kImageIndexUndefined; + ImageIndex exitBackIndex = kImageIndexUndefined; + ImageIndex exitFrontIndex = kImageIndexUndefined; + + ImageIndex entranceBackGlassIndex = kImageIndexUndefined; + ImageIndex entranceFrontGlassIndex = kImageIndexUndefined; + ImageIndex exitBackGlassIndex = kImageIndexUndefined; + ImageIndex exitFrontGlassIndex = kImageIndexUndefined; + + ImageIndex shelterIndex = kImageIndexUndefined; + ImageIndex shelterGlassIndex = kImageIndexUndefined; + uint32_t Flags{}; int32_t Height{}; uint8_t ScrollingMode{}; diff --git a/src/openrct2/openrct2_pch.h b/src/openrct2/openrct2_pch.h index 655dac226e..4c7a028820 100644 --- a/src/openrct2/openrct2_pch.h +++ b/src/openrct2/openrct2_pch.h @@ -2,7 +2,24 @@ // Include some expensive headers here to improve compilation speed +// Standard library headers that are frequently used and expensive to compile +#include +#include +#include +#include +#include +#include +#include + +// Core project headers with high compile cost and wide usage +#include "core/DataSerialiser.h" +#include "core/DataSerialiserTraits.h" #include "core/FileSystem.hpp" +#include "core/StringTypes.h" + +// Key project headers used across many files +#include "Context.h" +#include "GameState.h" #include "object/Object.h" #include "rct2/RCT2.h" #include "ride/Ride.h" diff --git a/src/openrct2/paint/Paint.Entity.cpp b/src/openrct2/paint/Paint.Entity.cpp index 74443ab21f..0c762aa3ed 100644 --- a/src/openrct2/paint/Paint.Entity.cpp +++ b/src/openrct2/paint/Paint.Entity.cpp @@ -28,6 +28,8 @@ #include "../world/Map.h" #include "../world/Park.h" #include "Paint.h" +#include "entity/Paint.Guest.h" +#include "entity/Paint.Staff.h" #include "vehicle/VehiclePaint.h" #include @@ -138,8 +140,10 @@ void EntityPaintSetup(PaintSession& session, const CoordsXY& pos) } break; case EntityType::guest: + PaintGuest(session, *entity->cast(), image_direction); + break; case EntityType::staff: - entity->cast()->Paint(session, image_direction); + PaintStaff(session, *entity->cast(), image_direction); break; case EntityType::steamParticle: entity->cast()->Paint(session, image_direction); diff --git a/src/openrct2/paint/entity/Paint.Guest.cpp b/src/openrct2/paint/entity/Paint.Guest.cpp new file mode 100644 index 0000000000..a1e62f23c7 --- /dev/null +++ b/src/openrct2/paint/entity/Paint.Guest.cpp @@ -0,0 +1,78 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Paint.Guest.h" + +#include "../../drawing/ImageId.hpp" +#include "../../entity/Guest.h" +#include "../../peep/PeepSpriteIds.h" +#include "../../profiling/Profiling.h" +#include "../../profiling/ProfilingMacros.hpp" +#include "../Paint.h" +#include "Paint.Peep.h" + +using namespace OpenRCT2; + +void PaintGuest(PaintSession& session, const Guest& guest, int32_t orientation) +{ + PROFILED_FUNCTION(); + + if (session.rt.zoom_level > ZoomLevel{ 2 }) + { + return; + } + + Direction direction = (orientation >> 3); + + auto baseImageData = PaintPeepGetBaseImageAndOffset(guest, direction); + auto imageId = ImageId(baseImageData.baseImageId, guest.TshirtColour, guest.TrousersColour); + + // In the following 4 calls to PaintAddImageAsParent/PaintAddImageAsChild, we add 5 (instead of 3) to the + // bound_box_offset_z to make sure peeps are drawn on top of railways + auto bb = kPaintPeepBoundBox(guest.z); + PaintAddImageAsParent(session, imageId, { 0, 0, guest.z }, bb); + + PaintGuestAccesories(session, guest, baseImageData.offset, baseImageData.actionAnimationGroup, direction); +} + +void PaintGuestAccesories( + PaintSession& session, const Guest& guest, uint8_t imageOffset, PeepAnimationType actionAnimationGroup, Direction direction) +{ + // Can't display any accessories whilst drowning, clapping, or throwing up + if (guest.Action == PeepActionType::drowning || guest.Action == PeepActionType::clap + || guest.Action == PeepActionType::throwUp) + return; + + // There are only 6 walking frames available for each item, + // as well as 1 sprite for sitting and 1 for standing still. + auto itemFrame = imageOffset % 6; + if (actionAnimationGroup == PeepAnimationType::watchRide) + itemFrame = 6; + else if (actionAnimationGroup == PeepAnimationType::sittingIdle) + itemFrame = 7; + + if (guest.AnimationGroup == PeepAnimationGroup::hat) + { + auto itemOffset = kPeepSpriteHatItemStart; + auto imageId = ImageId(itemOffset + direction + itemFrame * 4, guest.HatColour); + PaintAddImageAsChild(session, imageId, kPaintPeepOffset(guest.z), kPaintPeepBoundBox(guest.z)); + } + else if (guest.AnimationGroup == PeepAnimationGroup::balloon) + { + auto itemOffset = kPeepSpriteBalloonItemStart; + auto imageId = ImageId(itemOffset + direction + itemFrame * 4, guest.BalloonColour); + PaintAddImageAsChild(session, imageId, kPaintPeepOffset(guest.z), kPaintPeepBoundBox(guest.z)); + } + else if (guest.AnimationGroup == PeepAnimationGroup::umbrella) + { + auto itemOffset = kPeepSpriteUmbrellaItemStart; + auto imageId = ImageId(itemOffset + direction + itemFrame * 4, guest.UmbrellaColour); + PaintAddImageAsChild(session, imageId, kPaintPeepOffset(guest.z), kPaintPeepBoundBox(guest.z)); + } +} diff --git a/src/openrct2/paint/entity/Paint.Guest.h b/src/openrct2/paint/entity/Paint.Guest.h new file mode 100644 index 0000000000..45bc104d53 --- /dev/null +++ b/src/openrct2/paint/entity/Paint.Guest.h @@ -0,0 +1,23 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct BoundBoxXYZ; +struct Guest; +struct PaintSession; +enum class PeepAnimationType : uint8_t; +using Direction = uint8_t; + +void PaintGuest(PaintSession& session, const Guest& guest, int32_t orientation); +void PaintGuestAccesories( + PaintSession& session, const Guest& guest, uint8_t imageOffset, PeepAnimationType actionAnimationGroup, + Direction direction); diff --git a/src/openrct2/paint/entity/Paint.Peep.cpp b/src/openrct2/paint/entity/Paint.Peep.cpp new file mode 100644 index 0000000000..91e20e6ac7 --- /dev/null +++ b/src/openrct2/paint/entity/Paint.Peep.cpp @@ -0,0 +1,46 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Paint.Peep.h" + +#include "../../Context.h" +#include "../../entity/Peep.h" +#include "../../object/ObjectManager.h" +#include "../../object/PeepAnimationsObject.h" + +using namespace OpenRCT2; + +BaseImageAndOffset PaintPeepGetBaseImageAndOffset(const Peep& peep, Direction direction) +{ + PeepAnimationType actionAnimationGroup = peep.AnimationType; + uint8_t imageOffset = peep.AnimationImageIdOffset; + + if (peep.Action == PeepActionType::idle) + { + actionAnimationGroup = peep.NextAnimationType; + imageOffset = 0; + } + + auto& objManager = GetContext()->GetObjectManager(); + auto* animObj = objManager.GetLoadedObject(peep.AnimationObjectIndex); + + ImageIndex baseImageId = animObj->GetPeepAnimation(peep.AnimationGroup, actionAnimationGroup).baseImage; + + // Offset frame onto the base image, using rotation except for the 'picked up' state + if (actionAnimationGroup != PeepAnimationType::hanging) + baseImageId += direction + imageOffset * 4; + else + baseImageId += imageOffset; + + return { + .baseImageId = baseImageId, + .offset = imageOffset, + .actionAnimationGroup = actionAnimationGroup, + }; +} diff --git a/src/openrct2/paint/entity/Paint.Peep.h b/src/openrct2/paint/entity/Paint.Peep.h new file mode 100644 index 0000000000..ded61a261c --- /dev/null +++ b/src/openrct2/paint/entity/Paint.Peep.h @@ -0,0 +1,39 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include "../../drawing/ImageIndexType.h" +#include "../Boundbox.h" + +#include + +struct Peep; +using Direction = uint8_t; +enum class PeepAnimationType : uint8_t; + +constexpr BoundBoxXYZ kPaintPeepBoundBox(int32_t z) +{ + // In the calls to PaintAddImageAsParent/PaintAddImageAsChild, we add 5 (instead of 3) to the + // offset.z to make sure peeps are drawn on top of railways. + return BoundBoxXYZ{ { 0, 0, z + 5 }, { 1, 1, 11 } }; +} +constexpr CoordsXYZ kPaintPeepOffset(int32_t z) +{ + return CoordsXYZ{ 0, 0, z }; +} + +struct BaseImageAndOffset +{ + ImageIndex baseImageId; + uint8_t offset; + PeepAnimationType actionAnimationGroup; +}; + +BaseImageAndOffset PaintPeepGetBaseImageAndOffset(const Peep& peep, Direction direction); diff --git a/src/openrct2/paint/entity/Paint.Staff.cpp b/src/openrct2/paint/entity/Paint.Staff.cpp new file mode 100644 index 0000000000..408480fb36 --- /dev/null +++ b/src/openrct2/paint/entity/Paint.Staff.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Paint.Staff.h" + +#include "../../drawing/LightFX.h" +#include "../../entity/Staff.h" +#include "../../profiling/Profiling.h" +#include "../../profiling/ProfilingMacros.hpp" +#include "../Paint.h" +#include "Paint.Peep.h" + +namespace LightFx = OpenRCT2::Drawing::LightFx; + +void PaintStaff(PaintSession& session, const Staff& staff, int32_t orientation) +{ + PROFILED_FUNCTION(); + + if (session.rt.zoom_level > ZoomLevel{ 2 }) + { + return; + } + + PaintStaffLightingEffects(staff); + + Direction direction = (orientation >> 3); + auto baseImageData = PaintPeepGetBaseImageAndOffset(staff, direction); + auto imageId = ImageId(baseImageData.baseImageId, staff.TshirtColour); + + PaintAddImageAsParent(session, imageId, kPaintPeepOffset(staff.z), kPaintPeepBoundBox(staff.z)); +} + +void PaintStaffLightingEffects(const Staff& staff) +{ + if (!LightFx::IsAvailable()) + return; + + auto loc = staff.GetLocation(); + switch (staff.Orientation) + { + case 0: + loc.x -= 10; + break; + case 8: + loc.y += 10; + break; + case 16: + loc.x += 10; + break; + case 24: + loc.y -= 10; + break; + default: + return; + } + + LightFx::Add3DLight(staff, 0, loc, LightFx::LightType::Spot1); +} diff --git a/src/openrct2/paint/entity/Paint.Staff.h b/src/openrct2/paint/entity/Paint.Staff.h new file mode 100644 index 0000000000..b1efdb99ee --- /dev/null +++ b/src/openrct2/paint/entity/Paint.Staff.h @@ -0,0 +1,18 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; +struct Staff; + +void PaintStaff(PaintSession& session, const Staff& staff, int32_t orientation); +void PaintStaffLightingEffects(const Staff& staff); diff --git a/src/openrct2/paint/tile_element/Paint.Banner.cpp b/src/openrct2/paint/tile_element/Paint.Banner.cpp index d5ab51e25b..0665ff37aa 100644 --- a/src/openrct2/paint/tile_element/Paint.Banner.cpp +++ b/src/openrct2/paint/tile_element/Paint.Banner.cpp @@ -25,6 +25,7 @@ #include "../../world/Scenery.h" #include "../../world/TileInspector.h" #include "../../world/tile_element/BannerElement.h" +#include "Paint.Banner.h" #include "Paint.TileElement.h" using namespace OpenRCT2; @@ -32,7 +33,7 @@ using namespace OpenRCT2::Drawing; // kBannerBoundBoxes[rotation][0] is for the pole in the back // kBannerBoundBoxes[rotation][1] is for the pole and the banner in the front -constexpr CoordsXY kBannerBoundBoxes[][2] = { +const CoordsXY kBannerBoundBoxes[][2] = { { { 1, 2 }, { 1, 29 } }, { { 2, 32 }, { 29, 32 } }, { { 32, 2 }, { 32, 29 } }, @@ -56,22 +57,8 @@ static void PaintBannerScrollingText( return; } - auto ft = Formatter(); - banner.formatTextWithColourTo(ft); - - char text[256]; - if (Config::Get().general.upperCaseBanners) - { - FormatStringToUpper(text, sizeof(text), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - else - { - FormatStringLegacy(text, sizeof(text), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - - auto stringWidth = GfxGetStringWidth(text, FontStyle::tiny); - auto scroll = stringWidth > 0 ? (getGameState().currentTicks / 2) % stringWidth : 0; - auto imageId = ScrollingText::setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode, PaletteIndex::transparent); + auto bannerText = banner.getTextWithColour(); + auto imageId = ScrollingText::setup(session, bannerText, scrollingMode, PaletteIndex::transparent); PaintAddImageAsChild(session, imageId, { 0, 0, height + 22 }, { bbOffset, { 1, 1, 21 } }); } diff --git a/src/openrct2/paint/tile_element/Paint.Banner.h b/src/openrct2/paint/tile_element/Paint.Banner.h new file mode 100644 index 0000000000..f1cbd03be1 --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.Banner.h @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; + +namespace OpenRCT2 +{ + struct BannerElement; +} + +void PaintBanner(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::BannerElement& bannerElement); diff --git a/src/openrct2/paint/tile_element/Paint.Entrance.cpp b/src/openrct2/paint/tile_element/Paint.Entrance.cpp index b27f67a064..d9cb838c17 100644 --- a/src/openrct2/paint/tile_element/Paint.Entrance.cpp +++ b/src/openrct2/paint/tile_element/Paint.Entrance.cpp @@ -32,6 +32,7 @@ #include "../../world/TileInspector.h" #include "../../world/tile_element/EntranceElement.h" #include "../support/WoodenSupports.h" +#include "Paint.Entrance.h" #include "Paint.TileElement.h" #include "Segment.h" @@ -52,36 +53,22 @@ static void PaintRideEntranceExitScrollingText( if (entranceEl.GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT) return; - auto ride = GetRide(entranceEl.GetRideIndex()); + const auto* ride = GetRide(entranceEl.GetRideIndex()); if (ride == nullptr) return; - auto ft = Formatter(); - ft.Add(STR_RIDE_ENTRANCE_NAME); - if (ride->status == RideStatus::open && !(ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + u8string bannerText; + if (ride->status == RideStatus::open && !ride->flags.has(RideFlag::brokenDown)) { - ride->formatNameTo(ft); + bannerText = ScrollingText::kRideBannerColourPrefix + ride->getName(); } else { - ft.Add(STR_RIDE_ENTRANCE_CLOSED); + bannerText = LanguageGetString(STR_RIDE_ENTRANCE_CLOSED); } - char text[256]; - if (Config::Get().general.upperCaseBanners) - { - FormatStringToUpper(text, sizeof(text), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - else - { - FormatStringLegacy(text, sizeof(text), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - auto stringWidth = GfxGetStringWidth(text, FontStyle::tiny); - auto scroll = stringWidth > 0 ? (getGameState().currentTicks / 2) % stringWidth : 0; - PaintAddImageAsChild( - session, - ScrollingText::setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, stationObj.ScrollingMode, PaletteIndex::transparent), + session, ScrollingText::setup(session, bannerText, stationObj.ScrollingMode, PaletteIndex::transparent), { 0, 0, height + stationObj.Height }, { { 2, 2, height + stationObj.Height }, { 28, 28, 51 } }); } @@ -132,7 +119,7 @@ static void PaintRideEntranceExit(PaintSession& session, uint8_t direction, int3 } auto stationObj = ride->getStationObject(); - if (stationObj == nullptr || stationObj->BaseImageId == kImageIndexUndefined) + if (stationObj == nullptr || stationObj->baseImageIndex == kImageIndexUndefined) { return; } @@ -180,27 +167,30 @@ static void PaintRideEntranceExit(PaintSession& session, uint8_t direction, int3 auto isExit = entranceEl.GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT; // Back - ImageIndex imageIndex = isExit ? stationObj->BaseImageId + direction + 8 : stationObj->BaseImageId + direction; - ImageIndex glassImageIndex = isExit ? stationObj->BaseImageId + direction + 24 : stationObj->BaseImageId + direction + 16; + ImageIndex backImageIndex = (isExit ? stationObj->exitBackIndex : stationObj->entranceBackIndex) + direction; PaintAddImageAsParentRotated( - session, direction, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { { 2, 2, height }, { 28, 8, 30 } }); + session, direction, imageTemplate.WithIndex(backImageIndex), { 0, 0, height }, { { 2, 2, height }, { 28, 8, 30 } }); if (hasGlass) { + ImageIndex backGlassImageIndex = (isExit ? stationObj->exitBackGlassIndex : stationObj->entranceBackGlassIndex) + + direction; PaintAddImageAsChildRotated( - session, direction, glassImageTemplate.WithIndex(glassImageIndex), { 0, 0, height }, + session, direction, glassImageTemplate.WithIndex(backGlassImageIndex), { 0, 0, height }, { { 2, 2, height }, { 28, 8, 30 } }); } // Front const auto frontBoundBoxZ = isExit ? 1 : 17; - imageIndex += 4; + ImageIndex frontImageIndex = (isExit ? stationObj->exitFrontIndex : stationObj->entranceFrontIndex) + direction; PaintAddImageAsParent( - session, imageTemplate.WithIndex(imageIndex), { 0, 0, height }, { { 2, 2, height + 30 }, { 28, 28, frontBoundBoxZ } }); + session, imageTemplate.WithIndex(frontImageIndex), { 0, 0, height }, + { { 2, 2, height + 30 }, { 28, 28, frontBoundBoxZ } }); if (hasGlass) { - glassImageIndex += 4; + ImageIndex frontGlassImageIndex = (isExit ? stationObj->exitFrontGlassIndex : stationObj->entranceFrontGlassIndex) + + direction; PaintAddImageAsChild( - session, glassImageTemplate.WithIndex(glassImageIndex), { 0, 0, height }, + session, glassImageTemplate.WithIndex(frontGlassImageIndex), { 0, 0, height }, { { 2, 2, height + 30 }, { 28, 28, frontBoundBoxZ } }); } @@ -234,35 +224,19 @@ static void PaintParkEntranceScrollingText( if (scrollingMode == kScrollingModeNone) return; - auto ft = Formatter(); auto& gameState = getGameState(); + u8string bannerText; if (gameState.park.flags & PARK_FLAGS_PARK_OPEN) { const auto& park = gameState.park; - auto name = park.name.c_str(); - ft.Add(STR_STRING); - ft.Add(name); + bannerText = ScrollingText::kParkBannerColourPrefix + park.name; } else { - ft.Add(STR_BANNER_TEXT_CLOSED); - ft.Add(0); + bannerText = LanguageGetString(STR_BANNER_TEXT_CLOSED); } - char text[256]; - if (Config::Get().general.upperCaseBanners) - { - FormatStringToUpper(text, sizeof(text), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - else - { - FormatStringLegacy(text, sizeof(text), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - - auto stringWidth = GfxGetStringWidth(text, FontStyle::tiny); - auto scroll = stringWidth > 0 ? (gameState.currentTicks / 2) % stringWidth : 0; - auto imageIndex = ScrollingText::setup( - session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode + direction / 2, PaletteIndex::transparent); + auto imageIndex = ScrollingText::setup(session, bannerText, scrollingMode + direction / 2, PaletteIndex::transparent); auto textHeight = height + entrance.GetTextHeight(); PaintAddImageAsChild(session, imageIndex, { 0, 0, textHeight }, { { 2, 2, textHeight }, { 28, 28, 47 } }); } diff --git a/src/openrct2/paint/tile_element/Paint.Entrance.h b/src/openrct2/paint/tile_element/Paint.Entrance.h new file mode 100644 index 0000000000..9d3aab982b --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.Entrance.h @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; + +namespace OpenRCT2 +{ + struct EntranceElement; +} + +void PaintEntrance(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::EntranceElement& entranceElement); diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp index 49ecf3a80f..5e3d22b044 100644 --- a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp @@ -32,6 +32,7 @@ #include "../../world/tile_element/LargeSceneryElement.h" #include "../Boundbox.h" #include "../support/WoodenSupports.h" +#include "Paint.LargeScenery.h" #include "Paint.TileElement.h" #include "Segment.h" @@ -318,23 +319,9 @@ static void PaintLargeSceneryScrollingText( if (banner == nullptr) return; - auto ft = Formatter(); - banner->formatTextTo(ft); - - char text[256]; - if (Config::Get().general.upperCaseBanners) - { - FormatStringToUpper(text, sizeof(text), STR_SCROLLING_SIGN_TEXT, ft.Data()); - } - else - { - FormatStringLegacy(text, sizeof(text), STR_SCROLLING_SIGN_TEXT, ft.Data()); - } - + auto bannerText = banner->getText(); auto scrollMode = sceneryEntry.scrolling_mode + ((direction + 1) & 3); - auto stringWidth = GfxGetStringWidth(text, FontStyle::tiny); - auto scroll = stringWidth > 0 ? (getGameState().currentTicks / 2) % stringWidth : 0; - auto imageId = ScrollingText::setup(session, STR_SCROLLING_SIGN_TEXT, ft, scroll, scrollMode, textPaletteIndex); + auto imageId = ScrollingText::setup(session, bannerText, scrollMode, textPaletteIndex); PaintAddImageAsChild(session, imageId, { 0, 0, height + 25 }, { bbOffset, { 1, 1, 21 } }); } diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.h b/src/openrct2/paint/tile_element/Paint.LargeScenery.h new file mode 100644 index 0000000000..4ed8057213 --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.h @@ -0,0 +1,22 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; + +namespace OpenRCT2 +{ + struct LargeSceneryElement; +} + +void PaintLargeScenery( + PaintSession& session, uint8_t direction, uint16_t height, const OpenRCT2::LargeSceneryElement& tileElement); diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 8b84534b00..07d9fca9d4 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -155,35 +155,19 @@ static void PathPaintQueueBanner( uint16_t scrollingMode = railings.scrollingMode; scrollingMode += direction; - auto ft = Formatter(); - - if (ride->status == RideStatus::open && !(ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + u8string bannerText; + if (ride->status == RideStatus::open && !ride->flags.has(RideFlag::brokenDown)) { - ft.Add(STR_RIDE_ENTRANCE_NAME); - ride->formatNameTo(ft); + bannerText = ScrollingText::kRideBannerColourPrefix + ride->getName(); } else { - ft.Add(STR_RIDE_ENTRANCE_CLOSED); + bannerText = LanguageGetString(STR_RIDE_ENTRANCE_CLOSED); } - utf8 bannerBuffer[512]{}; - if (Config::Get().general.upperCaseBanners) - { - FormatStringToUpper(bannerBuffer, sizeof(bannerBuffer), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - else - { - FormatStringLegacy(bannerBuffer, sizeof(bannerBuffer), STR_BANNER_TEXT_FORMAT, ft.Data()); - } - - uint16_t stringWidth = GfxGetStringWidth(bannerBuffer, FontStyle::tiny); - uint16_t scroll = stringWidth > 0 ? (getGameState().currentTicks / 2) % stringWidth : 0; - PaintAddImageAsChild( - session, - ScrollingText::setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode, PaletteIndex::transparent), - { 0, 0, height + 7 }, { boundBoxOffsets, { 1, 1, 21 } }); + session, ScrollingText::setup(session, bannerText, scrollingMode, PaletteIndex::transparent), { 0, 0, height + 7 }, + { boundBoxOffsets, { 1, 1, 21 } }); } session.InteractionType = ViewportInteractionItem::footpath; diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp index b335d02feb..d14f24dc40 100644 --- a/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.cpp @@ -20,6 +20,7 @@ #include "../../world/TileInspector.h" #include "../../world/tile_element/SmallSceneryElement.h" #include "../support/WoodenSupports.h" +#include "Paint.SmallScenery.h" #include "Paint.TileElement.h" #include "Segment.h" diff --git a/src/openrct2/paint/tile_element/Paint.SmallScenery.h b/src/openrct2/paint/tile_element/Paint.SmallScenery.h new file mode 100644 index 0000000000..df8d5f6a6b --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.SmallScenery.h @@ -0,0 +1,22 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; + +namespace OpenRCT2 +{ + struct SmallSceneryElement; +} + +void PaintSmallScenery( + PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::SmallSceneryElement& sceneryElement); diff --git a/src/openrct2/paint/tile_element/Paint.Surface.h b/src/openrct2/paint/tile_element/Paint.Surface.h index dfc1bf890d..f7d425974c 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.h +++ b/src/openrct2/paint/tile_element/Paint.Surface.h @@ -12,8 +12,16 @@ #include "../../SpriteIds.h" #include "../../world/Location.hpp" +#include #include +struct PaintSession; + +namespace OpenRCT2 +{ + struct SurfaceElement; +} + namespace OpenRCT2::Drawing { enum class Colour : uint8_t; @@ -111,3 +119,5 @@ enum }; std::optional GetPatrolAreaTileColour(const CoordsXY& pos); + +void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, const OpenRCT2::SurfaceElement& tileElement); diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 3276dc6981..263f65bf54 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -30,8 +30,14 @@ #include "../Paint.SessionFlags.h" #include "../Paint.h" #include "../VirtualFloor.h" +#include "Paint.Banner.h" +#include "Paint.Entrance.h" +#include "Paint.LargeScenery.h" #include "Paint.Path.h" +#include "Paint.SmallScenery.h" #include "Paint.Surface.h" +#include "Paint.Track.h" +#include "Paint.Wall.h" #include "Segment.h" using namespace OpenRCT2; diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.h b/src/openrct2/paint/tile_element/Paint.TileElement.h index 90087d5e7f..2f7e721f47 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.h +++ b/src/openrct2/paint/tile_element/Paint.TileElement.h @@ -13,15 +13,8 @@ namespace OpenRCT2 { - struct BannerElement; - struct EntranceElement; - struct LargeSceneryElement; - struct PathElement; - struct SmallSceneryElement; - struct SurfaceElement; struct TrackElement; - struct WallElement; -} // namespace OpenRCT2 +} struct PaintSession; @@ -52,14 +45,4 @@ uint16_t PaintUtilRotateSegments(uint16_t segments, uint8_t rotation); void TileElementPaintSetup(PaintSession& session, const CoordsXY& mapCoords, bool isTrackPiecePreview = false); -void PaintEntrance(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::EntranceElement& entranceElement); -void PaintBanner(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::BannerElement& bannerElement); -void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, const OpenRCT2::SurfaceElement& tileElement); -void PaintSmallScenery( - PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::SmallSceneryElement& sceneryElement); -void PaintWall(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::WallElement& tileElement); -void PaintLargeScenery( - PaintSession& session, uint8_t direction, uint16_t height, const OpenRCT2::LargeSceneryElement& tileElement); -void PaintTrack(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::TrackElement& tileElement); - bool PaintShouldShowHeightMarkers(const PaintSession& session, uint32_t viewportFlag); diff --git a/src/openrct2/paint/tile_element/Paint.Track.h b/src/openrct2/paint/tile_element/Paint.Track.h new file mode 100644 index 0000000000..fc4fe9eb04 --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.Track.h @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; + +namespace OpenRCT2 +{ + struct TrackElement; +} + +void PaintTrack(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::TrackElement& tileElement); diff --git a/src/openrct2/paint/tile_element/Paint.Wall.cpp b/src/openrct2/paint/tile_element/Paint.Wall.cpp index abe010435e..2f6dda1b84 100644 --- a/src/openrct2/paint/tile_element/Paint.Wall.cpp +++ b/src/openrct2/paint/tile_element/Paint.Wall.cpp @@ -27,6 +27,7 @@ #include "../../world/TileInspector.h" #include "../../world/tile_element/WallElement.h" #include "Paint.TileElement.h" +#include "Paint.Wall.h" using namespace OpenRCT2; using namespace OpenRCT2::Drawing; @@ -175,21 +176,8 @@ static void PaintWallScrollingText( : wallElement.GetSecondaryColour(); auto textPaletteIndex = direction == 0 ? getColourMap(textColour).midDark : getColourMap(textColour).light; - auto ft = Formatter(); - banner->formatTextTo(ft); - char signString[256]; - if (Config::Get().general.upperCaseBanners) - { - FormatStringToUpper(signString, sizeof(signString), STR_SCROLLING_SIGN_TEXT, ft.Data()); - } - else - { - FormatStringLegacy(signString, sizeof(signString), STR_SCROLLING_SIGN_TEXT, ft.Data()); - } - - auto stringWidth = GfxGetStringWidth(signString, FontStyle::tiny); - auto scroll = stringWidth > 0 ? (getGameState().currentTicks / 2) % stringWidth : 0; - auto imageId = ScrollingText::setup(session, STR_SCROLLING_SIGN_TEXT, ft, scroll, scrollingMode, textPaletteIndex); + auto bannerText = banner->getText(); + auto imageId = ScrollingText::setup(session, bannerText, scrollingMode, textPaletteIndex); PaintAddImageAsChild(session, imageId, { 0, 0, height + 8 }, { boundsOffset, { 1, 1, 13 } }); } diff --git a/src/openrct2/paint/tile_element/Paint.Wall.h b/src/openrct2/paint/tile_element/Paint.Wall.h new file mode 100644 index 0000000000..7cf7ef020a --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.Wall.h @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; + +namespace OpenRCT2 +{ + struct WallElement; +} + +void PaintWall(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::WallElement& tileElement); diff --git a/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp b/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp index 05e26697bc..a68ebd68ea 100644 --- a/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp +++ b/src/openrct2/paint/track/coaster/WoodenRollerCoaster.cpp @@ -13505,7 +13505,7 @@ TrackPaintFunction GetTrackPaintFunctionWoodenAndClassicWoodenRC(TrackElemType t return WoodenRCTrack25DegDownLeftBanked; case TrackElemType::down25RightBanked: return WoodenRCTrack25DegDownRightBanked; - case TrackElemType::watersplash: + case TrackElemType::waterSplash: return WoodenRCTrackWaterSplash; case TrackElemType::leftEighthToDiag: return WoodenRCTrackLeftEighthToDiag; diff --git a/src/openrct2/paint/track/gentle/Circus.cpp b/src/openrct2/paint/track/gentle/Circus.cpp index ed016d2422..d2455c7ef6 100644 --- a/src/openrct2/paint/track/gentle/Circus.cpp +++ b/src/openrct2/paint/track/gentle/Circus.cpp @@ -31,7 +31,7 @@ static void PaintCircusTent( return; auto vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) + if (ride.flags.has(RideFlag::onTrack) && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::entity; session.CurrentlyDrawnEntity = vehicle; diff --git a/src/openrct2/paint/track/gentle/CrookedHouse.cpp b/src/openrct2/paint/track/gentle/CrookedHouse.cpp index 81a159cfe0..c576b42748 100644 --- a/src/openrct2/paint/track/gentle/CrookedHouse.cpp +++ b/src/openrct2/paint/track/gentle/CrookedHouse.cpp @@ -68,7 +68,7 @@ static void PaintCrookedHouseStructure( if (rideEntry == nullptr) return; - if (ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (ride->flags.has(RideFlag::onTrack)) { auto vehicle = getGameState().entities.GetEntity(ride->vehicles[0]); if (vehicle != nullptr) diff --git a/src/openrct2/paint/track/gentle/FerrisWheel.cpp b/src/openrct2/paint/track/gentle/FerrisWheel.cpp index f35e504be9..50c9ceadb6 100644 --- a/src/openrct2/paint/track/gentle/FerrisWheel.cpp +++ b/src/openrct2/paint/track/gentle/FerrisWheel.cpp @@ -71,7 +71,7 @@ static void PaintFerrisWheelStructure( return; auto vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) + if (ride.flags.has(RideFlag::onTrack) && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::entity; session.CurrentlyDrawnEntity = vehicle; diff --git a/src/openrct2/paint/track/gentle/HauntedHouse.cpp b/src/openrct2/paint/track/gentle/HauntedHouse.cpp index 5e9b2abdff..03949aeeb6 100644 --- a/src/openrct2/paint/track/gentle/HauntedHouse.cpp +++ b/src/openrct2/paint/track/gentle/HauntedHouse.cpp @@ -40,7 +40,7 @@ static void PaintHauntedHouseStructure( return; auto vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) + if (ride.flags.has(RideFlag::onTrack) && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::entity; session.CurrentlyDrawnEntity = vehicle; diff --git a/src/openrct2/paint/track/gentle/MerryGoRound.cpp b/src/openrct2/paint/track/gentle/MerryGoRound.cpp index e8c8de8c36..cfa4d946a1 100644 --- a/src/openrct2/paint/track/gentle/MerryGoRound.cpp +++ b/src/openrct2/paint/track/gentle/MerryGoRound.cpp @@ -36,7 +36,7 @@ static void PaintRiders( { if (session.rt.zoom_level > ZoomLevel{ 0 }) return; - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (!ride.flags.has(RideFlag::onTrack)) return; for (int32_t peep = 0; peep <= 14; peep += 2) @@ -66,12 +66,12 @@ static void PaintCarousel( return; auto vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) + if (ride.flags.has(RideFlag::onTrack) && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::entity; session.CurrentlyDrawnEntity = vehicle; - if (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown) && ride.breakdownReasonPending == BREAKDOWN_CONTROL_FAILURE && ride.breakdownSoundModifier >= 128) { height += kMerryGoRoundBreakdownVibration[(vehicle->current_time >> 1) & 7]; diff --git a/src/openrct2/paint/track/gentle/SpaceRings.cpp b/src/openrct2/paint/track/gentle/SpaceRings.cpp index 6fae6af96c..15e6661a8f 100644 --- a/src/openrct2/paint/track/gentle/SpaceRings.cpp +++ b/src/openrct2/paint/track/gentle/SpaceRings.cpp @@ -54,7 +54,7 @@ static void PaintSpaceRingsStructure( int32_t frameNum = direction; uint32_t baseImageId = rideEntry->Cars[0].base_image_id; auto vehicle = getGameState().entities.GetEntity(ride.vehicles[vehicleIndex]); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) + if (ride.flags.has(RideFlag::onTrack) && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::entity; session.CurrentlyDrawnEntity = vehicle; diff --git a/src/openrct2/paint/track/thrill/3dCinema.cpp b/src/openrct2/paint/track/thrill/3dCinema.cpp index a1363f4ada..7cc054fc5b 100644 --- a/src/openrct2/paint/track/thrill/3dCinema.cpp +++ b/src/openrct2/paint/track/thrill/3dCinema.cpp @@ -30,7 +30,7 @@ static void Paint3dCinemaDome( if (rideEntry == nullptr) return; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && !ride.vehicles[0].IsNull()) + if (ride.flags.has(RideFlag::onTrack) && !ride.vehicles[0].IsNull()) { session.InteractionType = ViewportInteractionItem::entity; session.CurrentlyDrawnEntity = getGameState().entities.GetEntity(ride.vehicles[0]); diff --git a/src/openrct2/paint/track/thrill/Enterprise.cpp b/src/openrct2/paint/track/thrill/Enterprise.cpp index 191e8574b2..f49cce1d85 100644 --- a/src/openrct2/paint/track/thrill/Enterprise.cpp +++ b/src/openrct2/paint/track/thrill/Enterprise.cpp @@ -56,7 +56,7 @@ static void PaintEnterpriseStructure( return; Vehicle* vehicle = nullptr; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (ride.flags.has(RideFlag::onTrack)) { vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); if (vehicle != nullptr) diff --git a/src/openrct2/paint/track/thrill/MagicCarpet.cpp b/src/openrct2/paint/track/thrill/MagicCarpet.cpp index c937e83836..28c3e2f1be 100644 --- a/src/openrct2/paint/track/thrill/MagicCarpet.cpp +++ b/src/openrct2/paint/track/thrill/MagicCarpet.cpp @@ -94,7 +94,7 @@ static ImageIndex GetMagicCarpetPendulumImage(Plane plane, Direction direction, static Vehicle* GetFirstVehicle(const Ride& ride) { - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (ride.flags.has(RideFlag::onTrack)) { return getGameState().entities.GetEntity(ride.vehicles[0]); } diff --git a/src/openrct2/paint/track/thrill/MotionSimulator.cpp b/src/openrct2/paint/track/thrill/MotionSimulator.cpp index 7540306dcf..0ec62bbe7b 100644 --- a/src/openrct2/paint/track/thrill/MotionSimulator.cpp +++ b/src/openrct2/paint/track/thrill/MotionSimulator.cpp @@ -46,7 +46,7 @@ static void PaintMotionSimulatorVehicle( CoordsXYZ offset(offsetX, offsetY, height + 2); Vehicle* vehicle = nullptr; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (ride.flags.has(RideFlag::onTrack)) { vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); if (vehicle != nullptr) diff --git a/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp b/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp index d1994e2042..ec40493bcd 100644 --- a/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp +++ b/src/openrct2/paint/track/thrill/SwingingInverterShip.cpp @@ -75,7 +75,7 @@ static void PaintSwingingInverterShipStructure( BoundBoxXYZ bb = { { boundBox.offset, height }, { boundBox.length, 127 } }; Vehicle* vehicle = nullptr; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (ride.flags.has(RideFlag::onTrack)) { vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); if (vehicle != nullptr) diff --git a/src/openrct2/paint/track/thrill/SwingingShip.cpp b/src/openrct2/paint/track/thrill/SwingingShip.cpp index 0df2182fdd..aefedfd8aa 100644 --- a/src/openrct2/paint/track/thrill/SwingingShip.cpp +++ b/src/openrct2/paint/track/thrill/SwingingShip.cpp @@ -67,7 +67,7 @@ static void PaintSwingingShipRiders( if (session.rt.zoom_level > ZoomLevel{ 1 }) return; - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (!ride.flags.has(RideFlag::onTrack)) return; int32_t peep = 0; @@ -96,7 +96,7 @@ static void PaintSwingingShipStructure( return; Vehicle* vehicle = nullptr; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && !ride.vehicles[0].IsNull()) + if (ride.flags.has(RideFlag::onTrack) && !ride.vehicles[0].IsNull()) { vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); session.InteractionType = ViewportInteractionItem::entity; diff --git a/src/openrct2/paint/track/thrill/TopSpin.cpp b/src/openrct2/paint/track/thrill/TopSpin.cpp index 948f837b70..bdd802a8ac 100644 --- a/src/openrct2/paint/track/thrill/TopSpin.cpp +++ b/src/openrct2/paint/track/thrill/TopSpin.cpp @@ -130,7 +130,7 @@ static void PaintTopSpinVehicle( uint8_t seatRotation = 0; uint8_t armRotation = 0; auto* vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) + if (ride.flags.has(RideFlag::onTrack) && vehicle != nullptr) { session.InteractionType = ViewportInteractionItem::entity; session.CurrentlyDrawnEntity = vehicle; diff --git a/src/openrct2/paint/track/thrill/Twist.cpp b/src/openrct2/paint/track/thrill/Twist.cpp index 78f2f9c50a..565cd6f105 100644 --- a/src/openrct2/paint/track/thrill/Twist.cpp +++ b/src/openrct2/paint/track/thrill/Twist.cpp @@ -38,7 +38,7 @@ static void PaintTwistStructure( height += 7; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && !ride.vehicles[0].IsNull()) + if (ride.flags.has(RideFlag::onTrack) && !ride.vehicles[0].IsNull()) { vehicle = getGameState().entities.GetEntity(ride.vehicles[0]); @@ -69,7 +69,7 @@ static void PaintTwistStructure( }; PaintAddImageAsParent(session, imageId, { xOffset, yOffset, height }, bb); - if (session.rt.zoom_level < ZoomLevel{ 1 } && ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK && vehicle != nullptr) + if (session.rt.zoom_level < ZoomLevel{ 1 } && ride.flags.has(RideFlag::onTrack) && vehicle != nullptr) { for (int32_t i = 0; i < vehicle->num_peeps; i += 2) { diff --git a/src/openrct2/paint/vehicle/VehiclePaint.cpp b/src/openrct2/paint/vehicle/VehiclePaint.cpp index eecd6d73b2..fdca50c055 100644 --- a/src/openrct2/paint/vehicle/VehiclePaint.cpp +++ b/src/openrct2/paint/vehicle/VehiclePaint.cpp @@ -1164,7 +1164,7 @@ static void VehicleSpritePaintRestraints( // Returns the opposite of the bank angle for reversed cars, normal bank angle otherwise static VehicleRoll GetPaintBankRotation(const Vehicle* vehicle) { - return (vehicle->HasFlag(VehicleFlags::CarIsReversed)) ? RollInvertTable[EnumValue(vehicle->roll)] : vehicle->roll; + return (vehicle->flags.has(VehicleFlag::carIsReversed)) ? RollInvertTable[EnumValue(vehicle->roll)] : vehicle->roll; } #pragma endregion @@ -1266,7 +1266,7 @@ static void VehiclePitchFlatBankedLeft67( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1288,7 +1288,7 @@ static void VehiclePitchFlatBankedLeft90( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1310,7 +1310,7 @@ static void VehiclePitchFlatBankedLeft112( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1332,7 +1332,7 @@ static void VehiclePitchFlatBankedLeft135( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1354,7 +1354,7 @@ static void VehiclePitchFlatBankedLeft157( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1376,7 +1376,7 @@ static void VehiclePitchFlatBankedRight67( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1398,7 +1398,7 @@ static void VehiclePitchFlatBankedRight90( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1420,7 +1420,7 @@ static void VehiclePitchFlatBankedRight112( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1442,7 +1442,7 @@ static void VehiclePitchFlatBankedRight135( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -1464,7 +1464,7 @@ static void VehiclePitchFlatBankedRight157( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -3395,7 +3395,7 @@ static void VehiclePitchDown75( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { if (vehicle->GetTrackType() != TrackElemType::down90ToDown60 && (vehicle->GetTrackType()) != TrackElemType::down60ToDown90) @@ -3421,7 +3421,7 @@ static void VehiclePitchDown90( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { if (vehicle->GetTrackType() != TrackElemType::down90 && (vehicle->GetTrackType()) != TrackElemType::down90ToDown60 && (vehicle->GetTrackType()) != TrackElemType::down60ToDown90) @@ -3451,7 +3451,7 @@ static void VehiclePitchDown105( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -3473,7 +3473,7 @@ static void VehiclePitchDown120( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -3495,7 +3495,7 @@ static void VehiclePitchDown135( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -3517,7 +3517,7 @@ static void VehiclePitchDown150( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -3539,7 +3539,7 @@ static void VehiclePitchDown165( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -3566,7 +3566,7 @@ void VehiclePitchCorkscrew( PaintSession& session, const Vehicle* vehicle, int32_t imageDirection, const int32_t z, const CarEntry* carEntry, uint32_t boundingBoxIndex) { - if (vehicle->HasFlag(VehicleFlags::CarIsInverted)) + if (vehicle->flags.has(VehicleFlag::carIsInverted)) { carEntry--; } @@ -4537,7 +4537,7 @@ static_assert(std::size(PaintFunctionsByPitch) == EnumValue(VehiclePitch::pitchC */ static void vehicle_visual_splash1_effect(PaintSession& session, const int32_t z, const Vehicle* vehicle) { - if (vehicle->GetTrackType() != TrackElemType::watersplash) + if (vehicle->GetTrackType() != TrackElemType::waterSplash) { return; } @@ -4697,7 +4697,7 @@ void VehicleVisualDefault( { if (vehicle->pitch < VehiclePitch::pitchCount) { - if (vehicle->HasFlag(VehicleFlags::CarIsReversed)) + if (vehicle->flags.has(VehicleFlag::carIsReversed)) { auto imagePitch = PitchInvertTable[EnumValue(vehicle->pitch)]; auto imageYaw = (imageDirection + (kBaseRotation / 2)) & (kBaseRotation - 1); @@ -4715,7 +4715,7 @@ void Vehicle::Paint(PaintSession& session, int32_t imageDirection) const { const CarEntry* carEntry; - if (HasFlag(VehicleFlags::Crashed)) + if (flags.has(VehicleFlag::crashed)) { PaintAddImageAsParent( session, ImageId(SPR_WATER_PARTICLES_DENSE_0 + animation_frame), { 0, 0, z }, { { 0, 0, z + 2 }, { 1, 1, 0 } }); @@ -4736,7 +4736,7 @@ void Vehicle::Paint(PaintSession& session, int32_t imageDirection) const } auto carEntryIndex = vehicle_type; - if (HasFlag(VehicleFlags::CarIsInverted)) + if (flags.has(VehicleFlag::carIsInverted)) { carEntryIndex++; zOffset += 16; diff --git a/src/openrct2/park/ParkFile.cpp b/src/openrct2/park/ParkFile.cpp index 772ba176ef..a92028abf9 100644 --- a/src/openrct2/park/ParkFile.cpp +++ b/src/openrct2/park/ParkFile.cpp @@ -13,6 +13,7 @@ #include "../Context.h" #include "../Diagnostic.h" #include "../Editor.h" +#include "../Game.h" #include "../GameState.h" #include "../OpenRCT2.h" #include "../ParkImporter.h" @@ -775,7 +776,7 @@ namespace OpenRCT2 static constexpr uint8_t DESCRIPTOR_DAT = 0; static constexpr uint8_t DESCRIPTOR_PARKOBJ = 1; - if (os.getMode() == OrcaStream::Mode::writing && ExportObjectsList.size() == 0) + if (os.getMode() == OrcaStream::Mode::writing && ExportObjectsList.empty()) { // Do not emit chunk if there are no packed objects return; @@ -1428,7 +1429,7 @@ namespace OpenRCT2 cs.readWrite(ride.mode); cs.readWrite(ride.status); cs.readWrite(ride.departFlags); - cs.readWrite(ride.lifecycleFlags); + cs.readWrite(ride.flags.holder); // Meta cs.readWrite(ride.customName); @@ -2188,7 +2189,7 @@ namespace OpenRCT2 { value = std::get<1>(*fr); } - else if (table.size() > 0) + else if (!table.empty()) { value = std::get<1>(table[0]); } @@ -2229,11 +2230,11 @@ namespace OpenRCT2 { uint16_t updateFlags = 0; cs.readWrite(updateFlags); - entity.Flags = updateFlags; + entity.flags.holder = updateFlags; } else { - cs.readWrite(entity.Flags); + cs.readWrite(entity.flags.holder); } cs.readWrite(entity.SwingSprite); cs.readWrite(entity.current_station); @@ -2293,7 +2294,7 @@ namespace OpenRCT2 cs.readWrite(entity.vertical_drop_countdown); cs.readWrite(entity.var_D3); cs.readWrite(entity.mini_golf_current_animation); - cs.readWrite(entity.mini_golf_flags); + cs.readWrite(entity.miniGolfFlags.holder); cs.readWrite(entity.ride_subtype); cs.readWrite(entity.colours.Tertiary); cs.readWrite(entity.seat_rotation); @@ -2304,7 +2305,7 @@ namespace OpenRCT2 cs.readWrite(isCrashedVehicle); if (isCrashedVehicle) { - entity.SetFlag(VehicleFlags::Crashed); + entity.flags.set(VehicleFlag::crashed); } } if (cs.getMode() == OrcaStream::Mode::reading && os.getHeader().targetVersion < kBlockBrakeImprovementsVersion) diff --git a/src/openrct2/park/ParkPreview.cpp b/src/openrct2/park/ParkPreview.cpp index 09c6aca88b..17e5a9eefb 100644 --- a/src/openrct2/park/ParkPreview.cpp +++ b/src/openrct2/park/ParkPreview.cpp @@ -231,7 +231,7 @@ namespace OpenRCT2 drawingEngine->BeginDraw(); Drawing::RenderTarget rt{ - .bits = reinterpret_cast(image.pixels), + .bits = image.pixels, .x = 0, .y = 0, .width = image.width, @@ -255,9 +255,9 @@ namespace OpenRCT2 g1temp.width = image.width; g1temp.height = image.height; - GfxSetG1Element(SPR_TEMP, &g1temp); - DrawingEngineInvalidateImage(SPR_TEMP); - GfxDrawSprite(rt, ImageId(SPR_TEMP), screenPos); + GfxSetG1Element(SPR_TEMP_PARK_PREVIEW, &g1temp); + DrawingEngineInvalidateImage(SPR_TEMP_PARK_PREVIEW); + GfxDrawSprite(rt, ImageId(SPR_TEMP_PARK_PREVIEW), screenPos); } } // namespace OpenRCT2 diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 3bd10a9b0a..a79f1dfbde 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -424,7 +424,7 @@ namespace OpenRCT2::PathFinding continue; RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); auto ride = GetRide(rideIndex); - if (ride != nullptr && ride->getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride != nullptr && ride->getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) { *outRideIndex = rideIndex; return PathSearchResult::ShopEntrance; @@ -793,7 +793,7 @@ namespace OpenRCT2::PathFinding * tile. */ rideIndex = tileElement->AsTrack()->GetRideIndex(); auto ride = GetRide(rideIndex); - if (ride == nullptr || !ride->getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride == nullptr || !ride->getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) continue; found = true; diff --git a/src/openrct2/peep/PeepAnimations.cpp b/src/openrct2/peep/PeepAnimations.cpp index df1d77e437..91d17f3c20 100644 --- a/src/openrct2/peep/PeepAnimations.cpp +++ b/src/openrct2/peep/PeepAnimations.cpp @@ -287,10 +287,10 @@ namespace OpenRCT2 constexpr uint8_t kCentreX = kWidth / 2; constexpr uint8_t kCentreY = kHeight / 2; - uint8_t bitmap[kHeight][kWidth] = { 0 }; + Drawing::PaletteIndex bitmap[kHeight][kWidth]{}; Drawing::RenderTarget rt = { - .bits = reinterpret_cast(bitmap), + .bits = reinterpret_cast(bitmap), .x = -(kWidth / 2), .y = -(kHeight / 2), .width = kWidth, @@ -310,7 +310,7 @@ namespace OpenRCT2 { for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[j][kCentreX - i] != 0) + if (bitmap[j][kCentreX - i] != Drawing::PaletteIndex::transparent) { spriteWidth = i; break; @@ -322,7 +322,7 @@ namespace OpenRCT2 for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[j][kCentreX + i] != 0) + if (bitmap[j][kCentreX + i] != Drawing::PaletteIndex::transparent) { spriteWidth = i; break; @@ -339,7 +339,7 @@ namespace OpenRCT2 { for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[kCentreY - i][j] != 0) + if (bitmap[kCentreY - i][j] != Drawing::PaletteIndex::transparent) { spriteHeightNegative = i; break; @@ -356,7 +356,7 @@ namespace OpenRCT2 { for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[kCentreY + i][j] != 0) + if (bitmap[kCentreY + i][j] != Drawing::PaletteIndex::transparent) { spriteHeightPositive = i; break; diff --git a/src/openrct2/platform/Crash.cpp b/src/openrct2/platform/Crash.cpp index bfec1d0ea4..a1cf035422 100644 --- a/src/openrct2/platform/Crash.cpp +++ b/src/openrct2/platform/Crash.cpp @@ -58,7 +58,7 @@ static const wchar_t* _wszArchitecture = WSZ(OPENRCT2_ARCHITECTURE); static std::map _uploadFiles; static std::mutex _uploadFilesMutex; - #define BACKTRACE_TOKEN "0ff94b99e7911919eaadfa9b44ab3d1cefe4862df849aa873c5185446525c2cc" + #define BACKTRACE_TOKEN "fa3fd3fe0a72f4064fe3bc1068bd2584d1959759d93a8ca219614d2599c43c1b" using namespace OpenRCT2; diff --git a/src/openrct2/platform/Platform.Common.cpp b/src/openrct2/platform/Platform.Common.cpp index 2eda1951ee..65c88ce133 100644 --- a/src/openrct2/platform/Platform.Common.cpp +++ b/src/openrct2/platform/Platform.Common.cpp @@ -26,7 +26,6 @@ #endif #include "../Context.h" -#include "../Game.h" #include "../core/CallingConventions.h" #include "../core/File.h" #include "../core/Path.hpp" @@ -38,8 +37,8 @@ #include #include #include +#include #include -#include #ifdef _WIN32 static constexpr std::array _prohibitedCharacters = { '<', '>', '*', '\\', ':', '|', '?', '"', '/' }; diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index f923cd8cd1..558d85aa46 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -347,6 +347,7 @@ namespace OpenRCT2::Platform SetUpFileAssociation(".sea", "RCTC Saved Game (.sea)", "Play", "\"%1\"", 0); SetUpFileAssociation(".td4", "RCT1 Track Design (.td4)", "Install", "\"%1\"", 0); SetUpFileAssociation(".td6", "RCT2 Track Design (.td6)", "Install", "\"%1\"", 0); + SetUpFileAssociation(".td7", "OpenRCT2 Track Design (.td7)", "Install", "\"%1\"", 0); // Refresh explorer SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr); @@ -478,6 +479,7 @@ namespace OpenRCT2::Platform RemoveFileAssociation(".sea"); RemoveFileAssociation(".td4"); RemoveFileAssociation(".td6"); + RemoveFileAssociation(".td7"); // Refresh explorer SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr); diff --git a/src/openrct2/profiling/Profiling.cpp b/src/openrct2/profiling/Profiling.cpp index 6f8591a7a7..82bcdce432 100644 --- a/src/openrct2/profiling/Profiling.cpp +++ b/src/openrct2/profiling/Profiling.cpp @@ -9,166 +9,290 @@ #include "Profiling.h" +#include "../core/Json.hpp" + +#include #include +#include #include #include #include -#include namespace OpenRCT2::Profiling { - inline static bool _enabled = false; + // Global enable flag, atomic for thread safety + static std::atomic _enabled{ false }; - void Enable() + void enable() { - _enabled = true; + _enabled.store(true, std::memory_order_release); } - void Disable() + void disable() { - _enabled = false; + _enabled.store(false, std::memory_order_release); } - bool IsEnabled() + bool isEnabled() { - return _enabled; + return _enabled.load(std::memory_order_acquire); } namespace Detail { using Clock = std::chrono::high_resolution_clock; - using Tp = Clock::time_point; + using TimePoint = Clock::time_point; - struct FunctionEntry + struct StackEntry { FunctionInternal* Parent; FunctionInternal* Func; - Tp EntryTime; - - FunctionEntry(FunctionInternal* parent, FunctionInternal* func, const Tp& entryTime) - : Parent(parent) - , Func(func) - , EntryTime(entryTime) - { - } + TimePoint EntryTime; }; - static thread_local std::stack _callStack; + static thread_local std::vector _callStack; + static std::vector _registry; + static std::mutex _registryMutex; - void FunctionEnter(Function& func) + std::vector& getRegistry() { - const auto entryTime = Clock::now(); - - auto& funcInternal = static_cast(func); - funcInternal.CallCount++; - - FunctionInternal* parent = nullptr; - - if (!_callStack.empty()) - parent = _callStack.top().Func; - - _callStack.emplace(parent, &funcInternal, entryTime); + return _registry; } - void FunctionExit(Function& func) + std::mutex& getRegistryMutex() + { + return _registryMutex; + } + + void registerFunction(FunctionInternal* func) + { + std::scoped_lock lock(_registryMutex); + _registry.push_back(func); + } + + void functionEnter(FunctionInternal& func) + { + const auto entryTime = Clock::now(); + func.CallCount.fetch_add(1, std::memory_order_relaxed); + + FunctionInternal* parent = nullptr; + if (!_callStack.empty()) + { + parent = _callStack.back().Func; + } + + _callStack.push_back({ parent, &func, entryTime }); + } + + bool FunctionInternal::tryAddParent(FunctionInternal* parent) + { + std::scoped_lock lock(Mutex); + if (std::find(Parents.begin(), Parents.end(), parent) == Parents.end()) + { + Parents.push_back(parent); + return true; + } + return false; + } + + bool FunctionInternal::tryAddChild(FunctionInternal* child) + { + std::scoped_lock lock(Mutex); + if (std::find(Children.begin(), Children.end(), child) == Children.end()) + { + Children.push_back(child); + return true; + } + return false; + } + + std::vector FunctionInternal::getTimeSamples() const + { + const size_t totalSamples = SampleIndex.load(std::memory_order_relaxed); + const size_t count = std::min(totalSamples, MaxSamplesSize); + std::vector result; + result.reserve(count); + + const size_t startIdx = (totalSamples > MaxSamplesSize) ? (totalSamples % MaxSamplesSize) : 0; + for (size_t i = 0; i < count; ++i) + { + const size_t idx = (startIdx + i) % MaxSamplesSize; + result.push_back(static_cast(Samples[idx].load(std::memory_order_relaxed)) / 1000.0); + } + return result; + } + + void functionExit(FunctionInternal& func) { const auto exitTime = Clock::now(); - assert(!_callStack.empty()); + assert(!_callStack.empty() && "FunctionExit called without matching FunctionEnter"); - auto& stackEntry = _callStack.top(); + const auto& entry = _callStack.back(); + assert(entry.Func == &func && "FunctionExit called for wrong function"); - const auto deltaTime = exitTime - stackEntry.EntryTime; + const auto elapsed = exitTime - entry.EntryTime; + const auto elapsedNs = static_cast(std::chrono::duration_cast(elapsed).count()); - // Elapsed microseconds. - const auto elapsedTimeUs = std::chrono::duration_cast(deltaTime).count() / 1000.0; + // All timing updates are lock free + func.TotalTimeNs.fetch_add(elapsedNs, std::memory_order_relaxed); + func.updateMin(elapsedNs); + func.updateMax(elapsedNs); - auto* funcData = stackEntry.Func; + const size_t idx = func.SampleIndex.fetch_add(1, std::memory_order_relaxed) % MaxSamplesSize; + func.Samples[idx].store(elapsedNs, std::memory_order_relaxed); - // We don't need a lock for this, we only have a fixed window. - const auto sampleEntryIdx = funcData->SampleIterator++ % funcData->Samples.size(); - funcData->Samples[sampleEntryIdx] = elapsedTimeUs; - - if (stackEntry.Parent) + // Only take locks when discovering new relationships + if (entry.Parent != nullptr) { - std::scoped_lock lock(stackEntry.Parent->Mutex); - stackEntry.Parent->Children.insert(funcData); + // If this is the same parent as last time, skip lock + FunctionInternal* lastParent = func.LastParent.load(std::memory_order_relaxed); + if (lastParent != entry.Parent) + { + // Potentially new relationship so take locks and check + if (func.tryAddParent(entry.Parent)) + { + entry.Parent->tryAddChild(&func); + } + func.LastParent.store(entry.Parent, std::memory_order_relaxed); + } } - // This requires locking. - { - std::scoped_lock lock(funcData->Mutex); - - if (stackEntry.Parent) - funcData->Parents.insert(stackEntry.Parent); - - if (funcData->MinTimeUs == 0.0) - funcData->MinTimeUs = elapsedTimeUs; - else - funcData->MinTimeUs = std::min(elapsedTimeUs, funcData->MinTimeUs); - - funcData->MaxTimeUs = std::max(elapsedTimeUs, funcData->MaxTimeUs); - funcData->TotalTimeUs += elapsedTimeUs; - } - - _callStack.pop(); - } - - std::vector& GetRegistry() - { - static std::vector Registry; - return Registry; + _callStack.pop_back(); } } // namespace Detail - const std::vector& GetData() + const std::vector& getData() { - return Detail::GetRegistry(); + // eturns reference to static vector. Safe because functions are only registered during static initialization. + return Detail::getRegistry(); } - void ResetData() + void resetData() { - for (auto* func : Detail::GetRegistry()) - { - auto* funcInternal = static_cast(func); + std::scoped_lock lock(Detail::getRegistryMutex()); - std::scoped_lock lock(funcInternal->Mutex); - funcInternal->CallCount = 0; - funcInternal->MinTimeUs = 0.0; - funcInternal->MaxTimeUs = 0.0; - funcInternal->SampleIterator = 0; - funcInternal->Children.clear(); - funcInternal->Parents.clear(); + for (auto* func : Detail::getRegistry()) + { + auto* internal = static_cast(func); + + internal->CallCount.store(0, std::memory_order_relaxed); + internal->TotalTimeNs.store(0, std::memory_order_relaxed); + internal->MinTimeNs.store(0, std::memory_order_relaxed); + internal->MaxTimeNs.store(0, std::memory_order_relaxed); + internal->SampleIndex.store(0, std::memory_order_relaxed); + internal->LastParent.store(nullptr, std::memory_order_relaxed); + + for (auto& sample : internal->Samples) + { + sample.store(0, std::memory_order_relaxed); + } + + { + std::scoped_lock funcLock(internal->Mutex); + internal->Parents.clear(); + internal->Children.clear(); + } } } - bool ExportCSV(const std::string& filePath) + namespace { - std::ofstream out(filePath); - if (!out.is_open()) - return false; - - out << "function_name;calls;min_microseconds;max_microseconds;average_microseconds\n"; - out << std::setprecision(12); - - const auto& data = GetData(); - for (auto* func : data) + bool writeCSV(const std::string& filePath) { - out << "\"" << func->GetName() << "\"" - << ";"; - out << func->GetCallCount() << ";"; - out << func->GetMinTime() << ";"; - out << func->GetMaxTime() << ";"; + std::ofstream out(filePath); + if (!out.is_open()) + return false; - double avg = 0.0; - if (func->GetCallCount() > 0) - avg = func->getTotalTime() / func->GetCallCount(); + out << std::setprecision(12); + out << "function_name,calls,min_microseconds,max_microseconds,average_microseconds,total_microseconds\n"; - out << avg << "\n"; + std::scoped_lock lock(Detail::getRegistryMutex()); + + for (const auto* func : Detail::getRegistry()) + { + out << "\"" << func->getName() << "\","; + out << func->getCallCount() << ","; + out << func->getMinTime() << ","; + out << func->getMaxTime() << ","; + out << func->getAverageTime() << ","; + out << func->getTotalTime() << "\n"; + } + + return true; } - return true; + bool writeJSON(const std::string& filePath) + { + std::scoped_lock lock(Detail::getRegistryMutex()); + const auto& registry = Detail::getRegistry(); + + json_t functions = json_t::array(); + + for (size_t i = 0; i < registry.size(); ++i) + { + const auto* func = registry[i]; + + json_t parentIndices = json_t::array(); + for (const auto* parent : func->getParents()) + { + auto it = std::find(registry.begin(), registry.end(), parent); + if (it != registry.end()) + parentIndices.push_back(std::distance(registry.begin(), it)); + } + + json_t childIndices = json_t::array(); + for (const auto* child : func->getChildren()) + { + auto it = std::find(registry.begin(), registry.end(), child); + if (it != registry.end()) + childIndices.push_back(std::distance(registry.begin(), it)); + } + + functions.push_back( + { + { "name", func->getName() }, + { "callCount", func->getCallCount() }, + { "minTime", func->getMinTime() }, + { "maxTime", func->getMaxTime() }, + { "avgTime", func->getAverageTime() }, + { "totalTime", func->getTotalTime() }, + { "parents", parentIndices }, + { "children", childIndices }, + }); + } + + json_t root = { { "functions", functions } }; + + try + { + Json::WriteToFile(filePath, root); + return true; + } + catch (...) + { + return false; + } + } + + bool hasExtension(const std::string& path, const std::string& ext) + { + if (path.size() < ext.size()) + return false; + + // Case insensitive extension comparison + auto pathEnd = path.substr(path.size() - ext.size()); + std::transform(pathEnd.begin(), pathEnd.end(), pathEnd.begin(), ::tolower); + return pathEnd == ext; + } + } // namespace + + bool exportData(const std::string& filePath) + { + if (hasExtension(filePath, ".json")) + return writeJSON(filePath); + return writeCSV(filePath); } } // namespace OpenRCT2::Profiling diff --git a/src/openrct2/profiling/Profiling.h b/src/openrct2/profiling/Profiling.h index ddc3718c15..1fe17d86e5 100644 --- a/src/openrct2/profiling/Profiling.h +++ b/src/openrct2/profiling/Profiling.h @@ -15,134 +15,140 @@ #include #include #include -#include #include namespace OpenRCT2::Profiling { - void Enable(); - void Disable(); - bool IsEnabled(); + void enable(); + void disable(); + bool isEnabled(); struct Function { virtual ~Function() = default; - // This returns the full function prototype not just the name. - virtual const char* GetName() const noexcept = 0; - - // Total calls made to the function. - virtual uint64_t GetCallCount() const noexcept = 0; - - // Returns a small window of the most recent times. - virtual std::vector GetTimeSamples() const = 0; - - // Returns all time accumulated in microseconds. + virtual const char* getName() const noexcept = 0; + virtual uint64_t getCallCount() const noexcept = 0; + virtual std::vector getTimeSamples() const = 0; virtual double getTotalTime() const = 0; + virtual double getMinTime() const = 0; + virtual double getMaxTime() const = 0; - // Returns the min. time in microseconds. - virtual double GetMinTime() const = 0; + double getAverageTime() const + { + const auto count = getCallCount(); + return count > 0 ? getTotalTime() / static_cast(count) : 0.0; + } - // Returns the max. time in microseconds. - virtual double GetMaxTime() const = 0; - - // Returns a list of all functions that called this function. - virtual std::vector GetParents() const = 0; - - // Returns a list of function this function is calling. - virtual std::vector GetChildren() const = 0; + virtual std::vector getParents() const = 0; + virtual std::vector getChildren() const = 0; }; namespace Detail { - static constexpr auto MaxSamplesSize = 1024; - static constexpr auto MaxNameSize = 250; + static constexpr size_t MaxSamplesSize = 1024; - std::vector& GetRegistry(); + struct FunctionInternal; + + std::vector& getRegistry(); + std::mutex& getRegistryMutex(); + void registerFunction(FunctionInternal* func); struct FunctionInternal : Function { FunctionInternal() { - GetRegistry().push_back(this); + registerFunction(this); } virtual ~FunctionInternal() = default; - // Functions marked MT require locking, this is per function basis. + // Mutex only for call graph access, not the hot path. mutable std::mutex Mutex; - std::array Name{}; + // Atomic and lock free + std::atomic CallCount{ 0 }; + std::atomic TotalTimeNs{ 0 }; + std::atomic MinTimeNs{ 0 }; + std::atomic MaxTimeNs{ 0 }; - // Call count of function. - std::atomic CallCount{}; + // Circular buffer for recent samples in nanoseconds + std::array, MaxSamplesSize> Samples{}; + std::atomic SampleIndex{ 0 }; - // Function times in microseconds. - std::array Samples{}; + // Call graph, protected by Mutex, but only accessed on new relationships + std::vector Parents; + std::vector Children; - // Used internally to write into Samples without a lock. - std::atomic SampleIterator{}; + // Fast path cache, skip lock if we just linked this parent + std::atomic LastParent{ nullptr }; - double MinTimeUs{}; - - double MaxTimeUs{}; - - double TotalTimeUs{}; - - // Functions that called us. - std::unordered_set Parents; - - // Functions that this function called. - std::unordered_set Children; - - uint64_t GetCallCount() const noexcept override + // Lock free min update + void updateMin(uint64_t value) { - return CallCount.load(); + uint64_t current = MinTimeNs.load(std::memory_order_relaxed); + while (current == 0 || value < current) + { + if (MinTimeNs.compare_exchange_weak(current, value, std::memory_order_relaxed)) + break; + } } - std::vector GetTimeSamples() const override + // Lock free max update + void updateMax(uint64_t value) { - const auto numSamples = std::min(SampleIterator.load(), Samples.size()); - return { Samples.begin(), Samples.begin() + numSamples }; + uint64_t current = MaxTimeNs.load(std::memory_order_relaxed); + while (value > current) + { + if (MaxTimeNs.compare_exchange_weak(current, value, std::memory_order_relaxed)) + break; + } } - std::vector GetParents() const override + bool tryAddParent(FunctionInternal* parent); + bool tryAddChild(FunctionInternal* child); + + uint64_t getCallCount() const noexcept override + { + return CallCount.load(std::memory_order_relaxed); + } + + std::vector getTimeSamples() const override; + + double getTotalTime() const override + { + return static_cast(TotalTimeNs.load(std::memory_order_relaxed)) / 1000.0; + } + + double getMinTime() const override + { + return static_cast(MinTimeNs.load(std::memory_order_relaxed)) / 1000.0; + } + + double getMaxTime() const override + { + return static_cast(MaxTimeNs.load(std::memory_order_relaxed)) / 1000.0; + } + + std::vector getParents() const override { std::scoped_lock lock(Mutex); return { Parents.begin(), Parents.end() }; } - std::vector GetChildren() const override + std::vector getChildren() const override { std::scoped_lock lock(Mutex); return { Children.begin(), Children.end() }; } - - double getTotalTime() const override - { - std::scoped_lock lock(Mutex); - return TotalTimeUs; - } - - double GetMinTime() const override - { - std::scoped_lock lock(Mutex); - return MinTimeUs; - } - - double GetMaxTime() const override - { - std::scoped_lock lock(Mutex); - return MaxTimeUs; - } }; template - struct FunctionWrapper : FunctionInternal + struct FunctionWrapper final : FunctionInternal { - const char* GetName() const noexcept override + const char* getName() const noexcept override { - return TName::Str(); + return TName::str(); } }; @@ -156,11 +162,12 @@ namespace OpenRCT2::Profiling static inline FunctionWrapper Data; }; - void FunctionEnter(Function& func); - void FunctionExit(Function& func); + void functionEnter(FunctionInternal& func); + void functionExit(FunctionInternal& func); } // namespace Detail + // RAII wrapper for automatic function timing template class ScopedProfiling { @@ -168,29 +175,33 @@ namespace OpenRCT2::Profiling T& _func; public: - ScopedProfiling(T& func) - : _enabled{ IsEnabled() } + explicit ScopedProfiling(T& func) + : _enabled(isEnabled()) , _func(func) { if (_enabled) { - Detail::FunctionEnter(_func); + Detail::functionEnter(_func); } } + ~ScopedProfiling() { - if (!_enabled) - return; - Detail::FunctionExit(_func); + if (_enabled) + { + Detail::functionExit(_func); + } } + + // Not copyable and not movable + ScopedProfiling(const ScopedProfiling&) = delete; + ScopedProfiling& operator=(const ScopedProfiling&) = delete; + ScopedProfiling(ScopedProfiling&&) = delete; + ScopedProfiling& operator=(ScopedProfiling&&) = delete; }; - // Clears all the current data of each function. - void ResetData(); - - // Returns all functions. - const std::vector& GetData(); - - bool ExportCSV(const std::string& filePath); + void resetData(); + const std::vector& getData(); + [[nodiscard]] bool exportData(const std::string& filePath); } // namespace OpenRCT2::Profiling diff --git a/src/openrct2/profiling/ProfilingMacros.hpp b/src/openrct2/profiling/ProfilingMacros.hpp index 3474bb00e6..c7f1f5695e 100644 --- a/src/openrct2/profiling/ProfilingMacros.hpp +++ b/src/openrct2/profiling/ProfilingMacros.hpp @@ -22,7 +22,7 @@ namespace OpenRCT2::Profiling static constexpr auto _profiling_func_name = func; \ struct Profiler_FunctionLiteral \ { \ - static constexpr const char* Str() \ + static constexpr const char* str() \ { \ return _profiling_func_name; \ } \ diff --git a/src/openrct2/rct1/RCT1.h b/src/openrct2/rct1/RCT1.h index e76bf989c8..b9ea0d573e 100644 --- a/src/openrct2/rct1/RCT1.h +++ b/src/openrct2/rct1/RCT1.h @@ -248,7 +248,7 @@ namespace OpenRCT2::RCT1 { RideType type; // 0x000 RCT1::VehicleType vehicleType; // 0x001 - uint16_t lifecycleFlags; // 0x002 + uint16_t flags; // 0x002 uint8_t operatingMode; // 0x004 VehicleColourSettings vehicleColourSettings; // 0x005 struct diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 02f2c7a19e..6012543b42 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -854,17 +854,15 @@ namespace OpenRCT2::RCT1 dst->status = static_cast(src->status); // Flags - dst->lifecycleFlags = src->lifecycleFlags; + dst->flags.holder = src->flags; // These flags were not in the base game if (_gameVersion == FILE_VERSION_RCT1) { - dst->lifecycleFlags &= ~RIDE_LIFECYCLE_MUSIC; - dst->lifecycleFlags &= ~RIDE_LIFECYCLE_INDESTRUCTIBLE; - dst->lifecycleFlags &= ~RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK; + dst->flags.unset(RideFlag::music, RideFlag::indestructible, RideFlag::indestructibleTrack); } if (VehicleTypeIsReversed(src->vehicleType)) { - dst->lifecycleFlags |= RIDE_LIFECYCLE_REVERSED_TRAINS; + dst->flags.set(RideFlag::reversedTrains); } // Station @@ -960,7 +958,7 @@ namespace OpenRCT2::RCT1 dst->liftHillSpeed = 5; dst->music = kObjectEntryIndexNull; - if (GetRideTypeDescriptor(dst->type).HasFlag(RtdFlag::allowMusic)) + if (GetRideTypeDescriptor(dst->type).flags.has(RtdFlag::allowMusic)) { if (_gameVersion == FILE_VERSION_RCT1) { @@ -978,7 +976,7 @@ namespace OpenRCT2::RCT1 if (src->departFlags & RCT1_RIDE_DEPART_PLAY_MUSIC) { dst->departFlags &= ~RCT1_RIDE_DEPART_PLAY_MUSIC; - dst->lifecycleFlags |= RIDE_LIFECYCLE_MUSIC; + dst->flags.set(RideFlag::music); } } } @@ -1127,7 +1125,7 @@ namespace OpenRCT2::RCT1 } dst->entranceStyle = kObjectEntryIndexNull; - if (dst->getRideTypeDescriptor().HasFlag(RtdFlag::hasEntranceAndExit)) + if (dst->getRideTypeDescriptor().flags.has(RtdFlag::hasEntranceAndExit)) { // Entrance styles were introduced with AA. They correspond directly with those in RCT2. if (_gameVersion == FILE_VERSION_RCT1) @@ -1245,6 +1243,9 @@ namespace OpenRCT2::RCT1 { for (int i = 0; i < Limits::kMaxEntities; i++) { + // Make sure the EntityIndex matches the array position to handle corrupted saves where duplicate or invalid + // indices would cause CreateEntityAt to fail + _s4.Entities[i].Unknown.EntityIndex = static_cast(i); ImportEntity(gameState, _s4.Entities[i].Unknown); } } @@ -1618,7 +1619,7 @@ namespace OpenRCT2::RCT1 } // Set last element flag in case the original last element was never added - if (tileElements.size() > 0) + if (!tileElements.empty()) { tileElements.back().SetLastForTile(true); } @@ -2896,12 +2897,12 @@ namespace OpenRCT2::RCT1 dst->track_progress = src->TrackProgress; dst->vertical_drop_countdown = src->VerticalDropCountdown; dst->sub_state = src->SubState; - dst->Flags = src->UpdateFlags; + dst->flags.holder = src->UpdateFlags; SetVehicleColours(dst, src); dst->mini_golf_current_animation = MiniGolfAnimation(src->MiniGolfCurrentAnimation); - dst->mini_golf_flags = src->MiniGolfFlags; + dst->miniGolfFlags.holder = src->MiniGolfFlags; dst->MoveTo({ src->x, src->y, src->z }); @@ -2909,13 +2910,13 @@ namespace OpenRCT2::RCT1 dst->next_free_seat = src->NextFreeSeat; if (src->Flags & RCT12_ENTITY_FLAGS_IS_CRASHED_VEHICLE_ENTITY) { - dst->SetFlag(VehicleFlags::Crashed); + dst->flags.set(VehicleFlag::crashed); } dst->BlockBrakeSpeed = kRCT2DefaultBlockBrakeSpeed; if (VehicleTypeIsReversed(rct1Ride.vehicleType)) { - dst->SetFlag(VehicleFlags::CarIsReversed); + dst->flags.set(VehicleFlag::carIsReversed); } } diff --git a/src/openrct2/rct1/T4Importer.cpp b/src/openrct2/rct1/T4Importer.cpp index 2647d9ec47..0fc903ddbc 100644 --- a/src/openrct2/rct1/T4Importer.cpp +++ b/src/openrct2/rct1/T4Importer.cpp @@ -27,6 +27,7 @@ using namespace OpenRCT2; using namespace OpenRCT2::SawyerCoding; using OpenRCT2::RCT12::TD46MazeElement; +using OpenRCT2::RCT12::TD46TrackElement; using OpenRCT2::RCT12::TD46Version; namespace OpenRCT2::RCT1 @@ -78,6 +79,7 @@ namespace OpenRCT2::RCT1 { throw IOException("Version number incorrect."); } + td->version = version; _stream.SetPosition(0); if (version == TD46Version::td4AA) @@ -89,6 +91,35 @@ namespace OpenRCT2::RCT1 } private: + void importMazeElements(TrackDesign& td) + { + TD46MazeElement t4MazeElement; + while (true) + { + _stream.Read(&t4MazeElement, sizeof(TD46MazeElement)); + if (t4MazeElement.all == 0) + { + break; + } + + importMazeElement(td, t4MazeElement); + } + } + + void importTrackElements(TrackDesign& td) + { + TD46TrackElement t4TrackElement{}; + for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) + { + _stream.SetPosition(_stream.GetPosition() - 1); + _stream.Read(&t4TrackElement, sizeof(TD46TrackElement)); + TrackDesignTrackElement trackElement{}; + trackElement.type = RCT1TrackTypeToOpenRCT2(t4TrackElement.type, td.trackAndVehicle.rtdIndex); + RCT12::convertFromTD46Flags(trackElement, t4TrackElement.flags, td.version); + td.trackElements.push_back(trackElement); + } + } + std::unique_ptr ImportAA() { std::unique_ptr td = std::make_unique(); @@ -247,30 +278,11 @@ namespace OpenRCT2::RCT1 const auto& rtd = GetRideTypeDescriptor(td->trackAndVehicle.rtdIndex); if (rtd.specialType == RtdSpecialType::maze) { - TD46MazeElement t4MazeElement; - while (true) - { - _stream.Read(&t4MazeElement, sizeof(TD46MazeElement)); - if (t4MazeElement.all == 0) - { - break; - } - - importMazeElement(*td, t4MazeElement); - } + importMazeElements(*td); } else { - TD46TrackElement t4TrackElement{}; - for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) - { - _stream.SetPosition(_stream.GetPosition() - 1); - _stream.Read(&t4TrackElement, sizeof(TD46TrackElement)); - TrackDesignTrackElement trackElement{}; - trackElement.type = RCT1TrackTypeToOpenRCT2(t4TrackElement.Type, td->trackAndVehicle.rtdIndex); - RCT12::convertFromTD46Flags(trackElement, t4TrackElement.Flags); - td->trackElements.push_back(trackElement); - } + importTrackElements(*td); } td->gameStateData.name = _name; diff --git a/src/openrct2/rct1/Tables.cpp b/src/openrct2/rct1/Tables.cpp index 5c77665b21..a878e271a7 100644 --- a/src/openrct2/rct1/Tables.cpp +++ b/src/openrct2/rct1/Tables.cpp @@ -1497,7 +1497,7 @@ namespace OpenRCT2::RCT1 TrackElemType RCT1TrackTypeToOpenRCT2(RCT12::TrackElemType origTrackType, ride_type_t rideType) { - if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::isFlatRide)) + if (GetRideTypeDescriptor(rideType).flags.has(RtdFlag::isFlatRide)) return RCT12FlatTrackTypeToOpenRCT2(origTrackType); return static_cast(origTrackType); diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index 4e7038840b..24e2a12306 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -170,7 +170,7 @@ namespace OpenRCT2::RCT12 onRidePhoto = 114, down25LeftBanked = 115, down25RightBanked = 116, - watersplash = 117, + waterSplash = 117, flatToUp60LongBase = 118, up60ToFlatLongBase = 119, whirlpool = 120, @@ -520,14 +520,6 @@ struct RCT12xy8 }; static_assert(sizeof(RCT12xy8) == 2); -/* Track Element entry size: 0x02 */ -struct TD46TrackElement -{ - OpenRCT2::RCT12::TrackElemType Type; // 0x00 - uint8_t Flags; // 0x01 -}; -static_assert(sizeof(TD46TrackElement) == 0x02); - struct RCT12Award { uint16_t Time; diff --git a/src/openrct2/rct12/ScenarioPatcher.cpp b/src/openrct2/rct12/ScenarioPatcher.cpp index 7db390ab73..5996a52ba8 100644 --- a/src/openrct2/rct12/ScenarioPatcher.cpp +++ b/src/openrct2/rct12/ScenarioPatcher.cpp @@ -12,8 +12,8 @@ #include "../Context.h" #include "../Game.h" #include "../PlatformEnvironment.h" -#include "../actions/FootpathPlaceAction.h" #include "../actions/GameActionResult.h" +#include "../actions/footpath/FootpathPlaceAction.h" #include "../core/File.h" #include "../core/Guard.hpp" #include "../core/Json.hpp" diff --git a/src/openrct2/rct12/TD46.cpp b/src/openrct2/rct12/TD46.cpp index 40296098ca..79cdc79d83 100644 --- a/src/openrct2/rct12/TD46.cpp +++ b/src/openrct2/rct12/TD46.cpp @@ -14,18 +14,28 @@ namespace OpenRCT2::RCT12 { - void convertFromTD46Flags(TrackDesignTrackElement& target, uint8_t flags) + namespace TD46Flags + { + constexpr uint8_t stationIdMask = 0b00000011; + constexpr uint8_t speedOrSeatRotationMask = 0b00001111; + constexpr uint8_t colourSchemeMask = 0b00110000; + constexpr uint8_t isInverted = 0b01000000; + constexpr uint8_t hasChain = 0b10000000; + } // namespace TD46Flags + + void convertFromTD46Flags(TrackDesignTrackElement& target, uint8_t flags, TD46Version version) { target.brakeBoosterSpeed = kRCT2DefaultBlockBrakeSpeed; if (::TrackTypeIsStation(target.type)) { - auto stationIndex = flags & EnumValue(TD46Flags::stationId); + auto stationIndex = flags & TD46Flags::stationIdMask; target.stationIndex = StationIndex::FromUnderlying(stationIndex); } else { - auto speedOrSeatRotation = flags & EnumValue(TD46Flags::speedOrSeatRotation); - if (::TrackTypeHasSpeedSetting(target.type) && target.type != OpenRCT2::TrackElemType::blockBrakes) + auto speedOrSeatRotation = flags & TD46Flags::speedOrSeatRotationMask; + if (::TrackTypeHasSpeedSetting(target.type) + && (target.type != OpenRCT2::TrackElemType::blockBrakes || version == TD46Version::td7)) { target.brakeBoosterSpeed = speedOrSeatRotation << 1; } @@ -35,21 +45,23 @@ namespace OpenRCT2::RCT12 } } - target.colourScheme = (flags & EnumValue(TD46Flags::colourScheme)) >> 4; - if (flags & EnumValue(TD46Flags::isInverted)) - target.SetFlag(TrackDesignTrackElementFlag::isInverted); - if (flags & EnumValue(TD46Flags::hasChain)) - target.SetFlag(TrackDesignTrackElementFlag::hasChain); + target.colourScheme = (flags & TD46Flags::colourSchemeMask) >> 4; + if (flags & TD46Flags::isInverted) + target.flags.set(TrackDesignTrackElementFlag::isInverted); + if (flags & TD46Flags::hasChain) + target.flags.set(TrackDesignTrackElementFlag::hasChain); } - uint8_t convertToTD46Flags(const TrackDesignTrackElement& source) + uint8_t convertToTD46Flags(const TrackDesignTrackElement& source, TD46Version version) { uint8_t trackFlags = 0; if (::TrackTypeIsStation(source.type)) { - trackFlags = (source.stationIndex.ToUnderlying() & EnumValue(TD46Flags::stationId)); + trackFlags = source.stationIndex.ToUnderlying() & TD46Flags::stationIdMask; } - else if (::TrackTypeHasSpeedSetting(source.type) && source.type != OpenRCT2::TrackElemType::blockBrakes) + else if ( + ::TrackTypeHasSpeedSetting(source.type) + && (source.type != OpenRCT2::TrackElemType::blockBrakes || version == TD46Version::td7)) { trackFlags = (source.brakeBoosterSpeed >> 1); } @@ -60,10 +72,10 @@ namespace OpenRCT2::RCT12 trackFlags |= source.colourScheme << 4; - if (source.HasFlag(TrackDesignTrackElementFlag::hasChain)) - trackFlags |= EnumValue(TD46Flags::hasChain); - if (source.HasFlag(TrackDesignTrackElementFlag::isInverted)) - trackFlags |= EnumValue(TD46Flags::isInverted); + if (source.flags.has(TrackDesignTrackElementFlag::hasChain)) + trackFlags |= TD46Flags::hasChain; + if (source.flags.has(TrackDesignTrackElementFlag::isInverted)) + trackFlags |= TD46Flags::isInverted; return trackFlags; } diff --git a/src/openrct2/rct12/TD46.h b/src/openrct2/rct12/TD46.h index 0fefb6ba6b..3e208dd21d 100644 --- a/src/openrct2/rct12/TD46.h +++ b/src/openrct2/rct12/TD46.h @@ -16,25 +16,33 @@ struct TrackDesign; struct TrackDesignTrackElement; +namespace OpenRCT2 +{ + enum class TrackElemType : uint16_t; + +#pragma pack(push, 1) + struct TD7TrackElement + { + TrackElemType type; // 0x00 + uint8_t flags; // 0x02 + }; +#pragma pack(pop) + static_assert(sizeof(TD7TrackElement) == 0x03); +} // namespace OpenRCT2 + namespace OpenRCT2::RCT12 { + enum class TrackElemType : uint8_t; + enum class TD46Version : uint8_t { td4, td4AA, td6, + td7, unknown }; - enum class TD46Flags : uint8_t - { - stationId = 0b00000011, - speedOrSeatRotation = 0b00001111, - colourScheme = 0b00110000, - isInverted = 0b01000000, - hasChain = 0b10000000, - }; - #pragma pack(push, 1) enum class TD46MazeElementType : uint8_t { @@ -75,9 +83,17 @@ namespace OpenRCT2::RCT12 } }; static_assert(sizeof(TD46MazeElement) == 0x04); + + /* Track Element entry size: 0x02 */ + struct TD46TrackElement + { + TrackElemType type; // 0x00 + uint8_t flags; // 0x01 + }; + static_assert(sizeof(TD46TrackElement) == 0x02); #pragma pack(pop) - void convertFromTD46Flags(TrackDesignTrackElement& target, uint8_t flags); - uint8_t convertToTD46Flags(const TrackDesignTrackElement& source); + void convertFromTD46Flags(TrackDesignTrackElement& target, uint8_t flags, TD46Version version); + uint8_t convertToTD46Flags(const TrackDesignTrackElement& source, TD46Version version); void importMazeElement(TrackDesign& td, const TD46MazeElement& td46MazeElement); } // namespace OpenRCT2::RCT12 diff --git a/src/openrct2/rct2/Limits.h b/src/openrct2/rct2/Limits.h index 54be1b3ce7..ece6f48b34 100644 --- a/src/openrct2/rct2/Limits.h +++ b/src/openrct2/rct2/Limits.h @@ -31,6 +31,8 @@ namespace OpenRCT2::RCT2::Limits constexpr uint16_t kMaxResearchItems = 500; constexpr uint16_t kTD6MaxTrackElements = 8192; + constexpr uint16_t kTD6MaxMazeElements = 2000; + constexpr uint16_t kTD6MaxSceneryElements = 1500; constexpr uint8_t kMaxSmallSceneryObjects = 252; constexpr uint8_t kMaxLargeSceneryObjects = 128; diff --git a/src/openrct2/rct2/RCT2.cpp b/src/openrct2/rct2/RCT2.cpp index bd0e9e6e6f..2592b4ec6a 100644 --- a/src/openrct2/rct2/RCT2.cpp +++ b/src/openrct2/rct2/RCT2.cpp @@ -39,7 +39,7 @@ namespace OpenRCT2::RCT2 return RIDE_TYPE_MONSTER_TRUCKS; return RIDE_TYPE_CAR_RIDE; case RIDE_TYPE_TWISTER_ROLLER_COASTER: - if (rideEntry.flags & RIDE_ENTRY_FLAG_NO_INVERSIONS) + if (rideEntry.flags.has(RideEntryFlag::noInversions)) return RIDE_TYPE_HYPER_TWISTER; return RIDE_TYPE_TWISTER_ROLLER_COASTER; case RIDE_TYPE_STEEL_WILD_MOUSE: diff --git a/src/openrct2/rct2/RCT2.h b/src/openrct2/rct2/RCT2.h index 42b70c81fc..9395501c13 100644 --- a/src/openrct2/rct2/RCT2.h +++ b/src/openrct2/rct2/RCT2.h @@ -287,7 +287,7 @@ namespace OpenRCT2::RCT2 uint8_t numBlockBrakes; // 0x1CC uint8_t liftHillSpeed; // 0x1CD uint16_t guestsFavourite; // 0x1CE - uint32_t lifecycleFlags; // 0x1D0 + uint32_t flags; // 0x1D0 Drawing::Colour vehicleColoursExtended[Limits::kMaxVehicleColours]; // 0x1D4 uint16_t totalAirTime; // 0x1F4 uint8_t currentTestStation; // 0x1F6 diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index 326063b20a..6690440c18 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -100,6 +100,12 @@ namespace OpenRCT2::RCT2 ParkLoadResult Load(const u8string& path, const bool skipObjectCheck) override { const auto extension = Path::GetExtension(path); + if (String::iequals(extension, ".sea")) + { + auto data = DecryptSea(fs::u8path(path)); + auto ms = MemoryStream(data.data(), data.size(), MemoryAccess::read); + return LoadFromStream(&ms, true, skipObjectCheck, path); + } if (String::iequals(extension, ".sc6")) { return LoadScenario(path, skipObjectCheck); @@ -161,9 +167,16 @@ namespace OpenRCT2::RCT2 // Read packed objects // TODO try to contain this more and not store objects until later - if (!skipObjectCheck) + for (uint16_t i = 0; i < _s6.Header.NumPackedObjects; i++) { - for (uint16_t i = 0; i < _s6.Header.NumPackedObjects; i++) + if (skipObjectCheck) + { + // When scanning, skip past packed object data to keep the stream + // position correct without importing objects into the repository. + stream->Seek(sizeof(RCTObjectEntry), STREAM_SEEK_CURRENT); + SawyerChunkReader(stream).SkipChunk(); + } + else { _objectRepository.ExportPackedObject(stream); } @@ -661,7 +674,7 @@ namespace OpenRCT2::RCT2 auto subtype = RCTEntryIndexToOpenRCT2EntryIndex(src->subtype); auto* rideEntry = GetRideEntryByIndex(subtype); // If the ride is tracked, we don’t need to check the vehicle any more. - if (!GetRideTypeDescriptor(src->type).HasFlag(RtdFlag::isFlatRide)) + if (!GetRideTypeDescriptor(src->type).flags.has(RtdFlag::isFlatRide)) { _isFlatRide[index] = false; continue; @@ -674,7 +687,7 @@ namespace OpenRCT2::RCT2 { originalRideType = rideEntry->GetFirstNonNullRideType(); } - const auto isFlatRide = GetRideTypeDescriptor(originalRideType).HasFlag(RtdFlag::isFlatRide); + const auto isFlatRide = GetRideTypeDescriptor(originalRideType).flags.has(RtdFlag::isFlatRide); _isFlatRide.set(static_cast(index), isFlatRide); } } @@ -968,7 +981,7 @@ namespace OpenRCT2::RCT2 } auto musicStyle = kObjectEntryIndexNull; - if (GetRideTypeDescriptor(dst->type).HasFlag(RtdFlag::allowMusic)) + if (GetRideTypeDescriptor(dst->type).flags.has(RtdFlag::allowMusic)) { musicStyle = src->music; } @@ -986,7 +999,7 @@ namespace OpenRCT2::RCT2 dst->numBlockBrakes = src->numBlockBrakes; dst->liftHillSpeed = src->liftHillSpeed; dst->guestsFavourite = src->guestsFavourite; - dst->lifecycleFlags = src->lifecycleFlags; + dst->flags.holder = src->flags; for (uint8_t i = 0; i < Limits::kMaxTrainsPerRide; i++) { @@ -1292,7 +1305,7 @@ namespace OpenRCT2::RCT2 } // Set last element flag in case the original last element was never added - if (tileElements.size() > 0) + if (!tileElements.empty()) { tileElements.back().SetLastForTile(true); } @@ -1651,6 +1664,9 @@ namespace OpenRCT2::RCT2 { for (int32_t i = 0; i < GetMaxEntities(); i++) { + // Make sure the EntityIndex matches the array position to handle corrupted saves where duplicate or invalid + // indices would cause CreateEntityAt to fail + _s6.Entities[i].Unknown.EntityIndex = static_cast(i); ImportEntity(gameState, _s6.Entities[i].Unknown); } } @@ -2023,7 +2039,7 @@ namespace OpenRCT2::RCT2 dst->next_vehicle_on_ride = EntityId::FromUnderlying(src->NextVehicleOnRide); dst->var_44 = src->Var44; dst->mass = src->Mass; - dst->Flags = src->UpdateFlags; + dst->flags.holder = src->UpdateFlags; dst->SwingSprite = src->SwingSprite; dst->current_station = StationIndex::FromUnderlying(src->CurrentStation); dst->current_time = src->CurrentTime; @@ -2068,13 +2084,13 @@ namespace OpenRCT2::RCT2 dst->vertical_drop_countdown = src->VerticalDropCountdown; dst->var_D3 = src->VarD3; dst->mini_golf_current_animation = MiniGolfAnimation(src->MiniGolfCurrentAnimation); - dst->mini_golf_flags = src->MiniGolfFlags; + dst->miniGolfFlags.holder = src->MiniGolfFlags; dst->ride_subtype = RCTEntryIndexToOpenRCT2EntryIndex(src->RideSubtype); dst->seat_rotation = src->SeatRotation; dst->target_seat_rotation = src->TargetSeatRotation; if (src->Flags & RCT12_ENTITY_FLAGS_IS_CRASHED_VEHICLE_ENTITY) { - dst->SetFlag(VehicleFlags::Crashed); + dst->flags.set(VehicleFlag::crashed); } dst->BlockBrakeSpeed = kRCT2DefaultBlockBrakeSpeed; } diff --git a/src/openrct2/rct2/T6Exporter.cpp b/src/openrct2/rct2/T6Exporter.cpp index 2f94e3d57e..6c3bede3cf 100644 --- a/src/openrct2/rct2/T6Exporter.cpp +++ b/src/openrct2/rct2/T6Exporter.cpp @@ -30,6 +30,7 @@ #include using OpenRCT2::RCT12::TD46MazeElementType; +using OpenRCT2::RCT12::TD46TrackElement; using OpenRCT2::SawyerCoding::SawyerChunkWriter; namespace OpenRCT2::RCT2 @@ -62,7 +63,8 @@ namespace OpenRCT2::RCT2 tempStream.WriteValue(0); tempStream.WriteValue(0); tempStream.WriteValue(static_cast(_trackDesign.operation.rideMode)); - tempStream.WriteValue(EnumValue(_trackDesign.appearance.vehicleColourSettings) | (2 << 2)); + tempStream.WriteValue( + EnumValue(_trackDesign.appearance.vehicleColourSettings) | (EnumValue(_trackDesign.version) << 2)); for (auto i = 0; i < Limits::kMaxVehicleColours; i++) { tempStream.WriteValue(_trackDesign.appearance.vehicleColours[i].Body); @@ -130,53 +132,92 @@ namespace OpenRCT2::RCT2 if (rtd.specialType == RtdSpecialType::maze) { - for (const auto& mazeElement : _trackDesign.mazeElements) - { - tempStream.WriteValue(mazeElement.location.x); - tempStream.WriteValue(mazeElement.location.y); - tempStream.WriteValue(mazeElement.mazeEntry); - } - - for (const auto& entranceElement : _trackDesign.entranceElements) - { - tempStream.WriteValue(entranceElement.location.x); - tempStream.WriteValue(entranceElement.location.y); - tempStream.WriteValue(entranceElement.location.direction); - tempStream.WriteValue( - EnumValue(entranceElement.isExit ? TD46MazeElementType::exit : TD46MazeElementType::entrance)); - } - - tempStream.WriteValue(0); + exportMazeElements(tempStream); } else { - for (const auto& trackElement : _trackDesign.trackElements) - { - auto trackType = OpenRCT2TrackTypeToRCT2(trackElement.type); - if (trackElement.type == TrackElemType::multiDimInvertedUp90ToFlatQuarterLoop) - { - trackType = RCT12::TrackElemType::invertedUp90ToFlatQuarterLoopAlias; - } - tempStream.WriteValue(static_cast(trackType)); - auto flags = RCT12::convertToTD46Flags(trackElement); - tempStream.WriteValue(flags); - } + if (_trackDesign.version == RCT12::TD46Version::td7) + exportTrackElementsTD7(tempStream); + else + exportTrackElements(tempStream); - tempStream.WriteValue(0xFF); - - for (const auto& entranceElement : _trackDesign.entranceElements) - { - tempStream.WriteValue( - entranceElement.location.z == -1 ? static_cast(0x80) : entranceElement.location.z); - tempStream.WriteValue(entranceElement.location.direction | (entranceElement.isExit << 7)); - auto xy = entranceElement.location.ToCoordsXY(); - tempStream.WriteValue(xy.x); - tempStream.WriteValue(xy.y); - } - - tempStream.WriteValue(0xFF); + exportEntranceElements(tempStream); } + exportSceneryElements(tempStream); + + SawyerChunkWriter sawyerCoding(stream); + sawyerCoding.WriteChunkTrack(tempStream.GetData(), tempStream.GetLength()); + return true; + } + + void T6Exporter::exportMazeElements(IStream& tempStream) const + { + for (const auto& mazeElement : _trackDesign.mazeElements) + { + tempStream.WriteValue(mazeElement.location.x); + tempStream.WriteValue(mazeElement.location.y); + tempStream.WriteValue(mazeElement.mazeEntry); + } + + for (const auto& entranceElement : _trackDesign.entranceElements) + { + tempStream.WriteValue(entranceElement.location.x); + tempStream.WriteValue(entranceElement.location.y); + tempStream.WriteValue(entranceElement.location.direction); + tempStream.WriteValue( + EnumValue(entranceElement.isExit ? TD46MazeElementType::exit : TD46MazeElementType::entrance)); + } + + tempStream.WriteValue(0); + } + + void T6Exporter::exportTrackElements(IStream& tempStream) const + { + for (const auto& trackElement : _trackDesign.trackElements) + { + auto trackType = OpenRCT2TrackTypeToRCT2(trackElement.type); + if (trackElement.type == TrackElemType::multiDimInvertedUp90ToFlatQuarterLoop) + { + trackType = RCT12::TrackElemType::invertedUp90ToFlatQuarterLoopAlias; + } + tempStream.WriteValue(static_cast(trackType)); + auto flags = RCT12::convertToTD46Flags(trackElement, _trackDesign.version); + tempStream.WriteValue(flags); + } + + tempStream.WriteValue(0xFF); + } + + void T6Exporter::exportTrackElementsTD7(IStream& tempStream) const + { + for (const auto& trackElement : _trackDesign.trackElements) + { + auto flags = RCT12::convertToTD46Flags(trackElement, _trackDesign.version); + TD7TrackElement element = { trackElement.type, flags }; + tempStream.WriteValue(element); + } + + tempStream.WriteValue(0xFFFF); + } + + void T6Exporter::exportEntranceElements(IStream& tempStream) const + { + for (const auto& entranceElement : _trackDesign.entranceElements) + { + tempStream.WriteValue( + entranceElement.location.z == -1 ? static_cast(0x80) : entranceElement.location.z); + tempStream.WriteValue(entranceElement.location.direction | (entranceElement.isExit << 7)); + auto xy = entranceElement.location.ToCoordsXY(); + tempStream.WriteValue(xy.x); + tempStream.WriteValue(xy.y); + } + + tempStream.WriteValue(0xFF); + } + + void T6Exporter::exportSceneryElements(IStream& tempStream) const + { for (const auto& sceneryElement : _trackDesign.sceneryElements) { auto flags = sceneryElement.flags; @@ -197,9 +238,5 @@ namespace OpenRCT2::RCT2 } tempStream.WriteValue(0xFF); - - SawyerChunkWriter sawyerCoding(stream); - sawyerCoding.WriteChunkTrack(tempStream.GetData(), tempStream.GetLength()); - return true; } } // namespace OpenRCT2::RCT2 diff --git a/src/openrct2/rct2/T6Exporter.h b/src/openrct2/rct2/T6Exporter.h index 1d8abeca47..18cdfe6fbf 100644 --- a/src/openrct2/rct2/T6Exporter.h +++ b/src/openrct2/rct2/T6Exporter.h @@ -33,5 +33,11 @@ namespace OpenRCT2::RCT2 private: const TrackDesign& _trackDesign; + + void exportMazeElements(IStream& tempStream) const; + void exportTrackElements(IStream& tempStream) const; + void exportTrackElementsTD7(IStream& tempStream) const; + void exportEntranceElements(IStream& tempStream) const; + void exportSceneryElements(IStream& tempStream) const; }; } // namespace OpenRCT2::RCT2 diff --git a/src/openrct2/rct2/T6Importer.cpp b/src/openrct2/rct2/T6Importer.cpp index 1bf8b8fae0..8f54ba4d79 100644 --- a/src/openrct2/rct2/T6Importer.cpp +++ b/src/openrct2/rct2/T6Importer.cpp @@ -29,6 +29,7 @@ using namespace OpenRCT2; using namespace OpenRCT2::SawyerCoding; using OpenRCT2::RCT12::TD46MazeElement; +using OpenRCT2::RCT12::TD46TrackElement; using OpenRCT2::RCT12::TD46Version; namespace OpenRCT2::RCT2 @@ -44,6 +45,99 @@ namespace OpenRCT2::RCT2 MemoryStream _stream; std::string _name; + void importMazeElements(TrackDesign& td) + { + TD46MazeElement t6MazeElement; + while (true) + { + _stream.Read(&t6MazeElement, sizeof(TD46MazeElement)); + if (t6MazeElement.all == 0) + { + break; + } + + importMazeElement(td, t6MazeElement); + } + } + + void importTrackElements(TrackDesign& td) + { + TD46TrackElement t6TrackElement{}; + for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) + { + _stream.SetPosition(_stream.GetPosition() - 1); + _stream.Read(&t6TrackElement, sizeof(TD46TrackElement)); + TrackDesignTrackElement trackElement{}; + + TrackElemType trackType; + if (t6TrackElement.type == RCT12::TrackElemType::invertedUp90ToFlatQuarterLoopAlias) + { + trackType = TrackElemType::multiDimInvertedUp90ToFlatQuarterLoop; + } + else + { + auto rideType = td.trackAndVehicle.rtdIndex; + const bool isFlatRide = GetRideTypeDescriptor(rideType).flags.has(RtdFlag::isFlatRide); + trackType = RCT2TrackTypeToOpenRCT2(t6TrackElement.type, rideType, isFlatRide); + } + + trackElement.type = trackType; + RCT12::convertFromTD46Flags(trackElement, t6TrackElement.flags, td.version); + td.trackElements.push_back(trackElement); + } + } + + void importTrackElementsTD7(TrackDesign& td) + { + TD7TrackElement t7TrackElement{}; + for (uint16_t endFlag = _stream.ReadValue(); endFlag != 0xFFFF; endFlag = _stream.ReadValue()) + { + _stream.SetPosition(_stream.GetPosition() - 2); + _stream.Read(&t7TrackElement, sizeof(TD7TrackElement)); + TrackDesignTrackElement trackElement{}; + trackElement.type = t7TrackElement.type; + RCT12::convertFromTD46Flags(trackElement, t7TrackElement.flags, td.version); + td.trackElements.push_back(trackElement); + } + } + + void importEntranceElements(TrackDesign& td) + { + TD6EntranceElement t6EntranceElement{}; + for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) + { + _stream.SetPosition(_stream.GetPosition() - 1); + _stream.Read(&t6EntranceElement, sizeof(TD6EntranceElement)); + TrackDesignEntranceElement entranceElement{}; + auto xy = CoordsXY(t6EntranceElement.x, t6EntranceElement.y); + auto z = (t6EntranceElement.z == -128) ? -1 : t6EntranceElement.z; + entranceElement.location = TileCoordsXYZD(TileCoordsXY(xy), z, t6EntranceElement.GetDirection()); + entranceElement.isExit = t6EntranceElement.IsExit(); + td.entranceElements.push_back(entranceElement); + } + } + + void importSceneryElements(TrackDesign& td) + { + for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) + { + _stream.SetPosition(_stream.GetPosition() - 1); + TD6SceneryElement t6SceneryElement{}; + _stream.Read(&t6SceneryElement, sizeof(TD6SceneryElement)); + TrackDesignSceneryElement sceneryElement{}; + sceneryElement.sceneryObject = ObjectEntryDescriptor(t6SceneryElement.SceneryObject); + TileCoordsXYZ tileCoords = { t6SceneryElement.x, t6SceneryElement.y, t6SceneryElement.z }; + sceneryElement.loc = tileCoords.ToCoordsXYZ(); + sceneryElement.flags = t6SceneryElement.Flags; + sceneryElement.primaryColour = t6SceneryElement.PrimaryColour; + sceneryElement.secondaryColour = t6SceneryElement.SecondaryColour; + if (t6SceneryElement.SceneryObject.GetType() == ObjectType::walls) + sceneryElement.tertiaryColour = t6SceneryElement.getTertiaryWallColour(); + + td.sceneryElements.push_back(std::move(sceneryElement)); + } + } + public: TD6Importer() { @@ -52,7 +146,7 @@ namespace OpenRCT2::RCT2 bool Load(const utf8* path) override { const auto extension = Path::GetExtension(path); - if (String::iequals(extension, ".td6")) + if (String::iequals(extension, ".td6") || String::iequals(extension, ".td7")) { _name = GetNameFromTrackPath(path); auto fs = FileStream(path, FileMode::open); @@ -126,12 +220,13 @@ namespace OpenRCT2::RCT2 td->operation.liftHillSpeed = td6.LiftHillSpeedNumCircuits & 0b00011111; td->operation.numCircuits = td6.LiftHillSpeedNumCircuits >> 5; - auto version = static_cast((td6.VersionAndColourScheme >> 2) & 3); - if (version != TD46Version::td6) + auto version = static_cast(td6.VersionAndColourScheme >> 2); + if (version != TD46Version::td6 && version != TD46Version::td7) { LOG_ERROR("Unsupported track design."); return nullptr; } + td->version = version; td->operation.operationSetting = std::min( td->operation.operationSetting, GetRideTypeDescriptor(td->trackAndVehicle.rtdIndex).OperatingSettings.MaxValue); @@ -139,75 +234,19 @@ namespace OpenRCT2::RCT2 const auto& rtd = GetRideTypeDescriptor(td->trackAndVehicle.rtdIndex); if (rtd.specialType == RtdSpecialType::maze) { - TD46MazeElement t6MazeElement; - while (true) - { - _stream.Read(&t6MazeElement, sizeof(TD46MazeElement)); - if (t6MazeElement.all == 0) - { - break; - } - - importMazeElement(*td, t6MazeElement); - } + importMazeElements(*td); } else { - TD46TrackElement t6TrackElement{}; - for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) - { - _stream.SetPosition(_stream.GetPosition() - 1); - _stream.Read(&t6TrackElement, sizeof(TD46TrackElement)); - TrackDesignTrackElement trackElement{}; + if (version == TD46Version::td7) + importTrackElementsTD7(*td); + else + importTrackElements(*td); - TrackElemType trackType; - if (t6TrackElement.Type == RCT12::TrackElemType::invertedUp90ToFlatQuarterLoopAlias) - { - trackType = TrackElemType::multiDimInvertedUp90ToFlatQuarterLoop; - } - else - { - auto rideType = td->trackAndVehicle.rtdIndex; - const bool isFlatRide = GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::isFlatRide); - trackType = RCT2TrackTypeToOpenRCT2(t6TrackElement.Type, rideType, isFlatRide); - } - - trackElement.type = trackType; - RCT12::convertFromTD46Flags(trackElement, t6TrackElement.Flags); - td->trackElements.push_back(trackElement); - } - - TD6EntranceElement t6EntranceElement{}; - for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) - { - _stream.SetPosition(_stream.GetPosition() - 1); - _stream.Read(&t6EntranceElement, sizeof(TD6EntranceElement)); - TrackDesignEntranceElement entranceElement{}; - auto xy = CoordsXY(t6EntranceElement.x, t6EntranceElement.y); - auto z = (t6EntranceElement.z == -128) ? -1 : t6EntranceElement.z; - entranceElement.location = TileCoordsXYZD(TileCoordsXY(xy), z, t6EntranceElement.GetDirection()); - entranceElement.isExit = t6EntranceElement.IsExit(); - td->entranceElements.push_back(entranceElement); - } + importEntranceElements(*td); } - for (uint8_t endFlag = _stream.ReadValue(); endFlag != 0xFF; endFlag = _stream.ReadValue()) - { - _stream.SetPosition(_stream.GetPosition() - 1); - TD6SceneryElement t6SceneryElement{}; - _stream.Read(&t6SceneryElement, sizeof(TD6SceneryElement)); - TrackDesignSceneryElement sceneryElement{}; - sceneryElement.sceneryObject = ObjectEntryDescriptor(t6SceneryElement.SceneryObject); - TileCoordsXYZ tileCoords = { t6SceneryElement.x, t6SceneryElement.y, t6SceneryElement.z }; - sceneryElement.loc = tileCoords.ToCoordsXYZ(); - sceneryElement.flags = t6SceneryElement.Flags; - sceneryElement.primaryColour = t6SceneryElement.PrimaryColour; - sceneryElement.secondaryColour = t6SceneryElement.SecondaryColour; - if (t6SceneryElement.SceneryObject.GetType() == ObjectType::walls) - sceneryElement.tertiaryColour = t6SceneryElement.getTertiaryWallColour(); - - td->sceneryElements.push_back(std::move(sceneryElement)); - } + importSceneryElements(*td); td->gameStateData.name = _name; diff --git a/src/openrct2/ride/CableLift.cpp b/src/openrct2/ride/CableLift.cpp index e952918ef2..da5b5cf6ee 100644 --- a/src/openrct2/ride/CableLift.cpp +++ b/src/openrct2/ride/CableLift.cpp @@ -78,7 +78,7 @@ Vehicle* CableLiftSegmentCreate( current->SetTrackType(TrackElemType::cableLiftHill); current->SetTrackDirection(current->Orientation >> 3); current->track_progress = 164; - current->Flags = VehicleFlags::CollisionDisabled; + current->flags = { VehicleFlag::collisionDisabled }; current->SetState(Vehicle::Status::movingToEndOfStation, 0); current->num_peeps = 0; current->next_free_seat = 0; @@ -211,7 +211,7 @@ void Vehicle::CableLiftUpdateTravelling() velocity = std::min(passengerVehicle->velocity, 439800); acceleration = 0; - if (passengerVehicle->HasFlag(VehicleFlags::TrainIsBroken)) + if (passengerVehicle->flags.has(VehicleFlag::trainIsBroken)) return; if (!(CableLiftUpdateTrackMotion() & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1)) diff --git a/src/openrct2/ride/CarEntry.cpp b/src/openrct2/ride/CarEntry.cpp index 99d1763f2f..fd8e706ba4 100644 --- a/src/openrct2/ride/CarEntry.cpp +++ b/src/openrct2/ride/CarEntry.cpp @@ -51,10 +51,10 @@ void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages) constexpr uint8_t kCentreX = kWidth / 2; constexpr uint8_t kCentreY = kHeight / 2; - uint8_t bitmap[kHeight][kWidth] = { 0 }; + OpenRCT2::Drawing::PaletteIndex bitmap[kHeight][kWidth]{}; OpenRCT2::Drawing::RenderTarget rt = { - .bits = reinterpret_cast(bitmap), + .bits = reinterpret_cast(bitmap), .x = -(kWidth / 2), .y = -(kHeight / 2), .width = kWidth, @@ -73,7 +73,7 @@ void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages) { for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[j][kCentreX - i] != 0) + if (bitmap[j][kCentreX - i] != OpenRCT2::Drawing::PaletteIndex::transparent) { spriteWidth = i; break; @@ -85,7 +85,7 @@ void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages) for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[j][kCentreX + i] != 0) + if (bitmap[j][kCentreX + i] != OpenRCT2::Drawing::PaletteIndex::transparent) { spriteWidth = i; break; @@ -102,7 +102,7 @@ void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages) { for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[kCentreY - i][j] != 0) + if (bitmap[kCentreY - i][j] != OpenRCT2::Drawing::PaletteIndex::transparent) { spriteHeightNegative = i; break; @@ -119,7 +119,7 @@ void CarEntrySetImageMaxSizes(CarEntry& carEntry, int32_t numImages) { for (int32_t j = 0; j < kWidth; j++) { - if (bitmap[kCentreY + i][j] != 0) + if (bitmap[kCentreY + i][j] != OpenRCT2::Drawing::PaletteIndex::transparent) { spriteHeightPositive = i; break; diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 12b7b99f20..ab6d94ad04 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -16,10 +16,11 @@ #include "../GameState.h" #include "../Input.h" #include "../OpenRCT2.h" +#include "../actions/GameActionRunner.h" #include "../actions/ResultWithMessage.h" -#include "../actions/RideSetSettingAction.h" -#include "../actions/RideSetStatusAction.h" -#include "../actions/RideSetVehicleAction.h" +#include "../actions/ride/RideSetSettingAction.h" +#include "../actions/ride/RideSetStatusAction.h" +#include "../actions/ride/RideSetVehicleAction.h" #include "../audio/Audio.h" #include "../config/Config.h" #include "../core/BitSet.hpp" @@ -310,7 +311,7 @@ size_t Ride::getNumPrices() const auto rideEntry = getRideEntry(); if (rideEntry != nullptr) { - if (lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) + if (flags.has(RideFlag::onRidePhoto)) { result++; } @@ -439,7 +440,7 @@ money64 Ride::calculateIncomePerHour() const priceMinusCost -= GetShopItemDescriptor(currentShopItem).Cost; } - currentShopItem = (lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) ? getRideTypeDescriptor().PhotoItem : entry->shop_item[1]; + currentShopItem = flags.has(RideFlag::onRidePhoto) ? getRideTypeDescriptor().PhotoItem : entry->shop_item[1]; if (currentShopItem != ShopItem::none) { @@ -837,17 +838,17 @@ bool Ride::findTrackGap(const CoordsXYE& input, CoordsXYE* output) const void Ride::formatStatusTo(Formatter& ft) const { - if (lifecycleFlags & RIDE_LIFECYCLE_CRASHED) + if (flags.has(RideFlag::crashed)) { ft.Add(STR_CRASHED); } - else if (lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + else if (flags.has(RideFlag::brokenDown)) { ft.Add(STR_BROKEN_DOWN); } else if (status == RideStatus::closed) { - if (!getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (!getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) { if (numRiders != 0) { @@ -872,7 +873,7 @@ void Ride::formatStatusTo(Formatter& ft) const { ft.Add(STR_TEST_RUN); } - else if (mode == RideMode::race && !(lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) && !raceWinner.IsNull()) + else if (mode == RideMode::race && !flags.has(RideFlag::passStationNoStopping) && !raceWinner.IsNull()) { auto peep = getGameState().entities.GetEntity(raceWinner); if (peep != nullptr) @@ -886,7 +887,7 @@ void Ride::formatStatusTo(Formatter& ft) const ft.Add(kStringIdNone); } } - else if (!getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + else if (!getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) { ft.Add(numRiders == 1 ? STR_PERSON_ON_RIDE : STR_PEOPLE_ON_RIDE); ft.Add(numRiders); @@ -915,7 +916,7 @@ int32_t Ride::getTotalTime() const bool Ride::canHaveMultipleCircuits() const { - if (!getRideTypeDescriptor().HasFlag(RtdFlag::allowMultipleCircuits)) + if (!getRideTypeDescriptor().flags.has(RtdFlag::allowMultipleCircuits)) return false; // Only allow circuit or launch modes @@ -942,9 +943,9 @@ bool Ride::supportsStatus(RideStatus s) const case RideStatus::open: return true; case RideStatus::simulating: - return (!rtd.HasFlag(RtdFlag::noTestMode) && rtd.HasFlag(RtdFlag::hasTrack)); + return (!rtd.flags.has(RtdFlag::noTestMode) && rtd.flags.has(RtdFlag::hasTrack)); case RideStatus::testing: - return !rtd.HasFlag(RtdFlag::noTestMode); + return !rtd.flags.has(RtdFlag::noTestMode); case RideStatus::count: // Meaningless but necessary to satisfy -Wswitch return false; } @@ -952,6 +953,12 @@ bool Ride::supportsStatus(RideStatus s) const return false; } +bool Ride::hasFailingBrakes() const +{ + return flags.has(RideFlag::brokenDown) && breakdownReasonPending == BREAKDOWN_BRAKES_FAILURE + && mechanicStatus != MechanicStatus::hasFixedStationBrakes; +} + #pragma region Initialisation functions /** @@ -1032,7 +1039,7 @@ void Ride::updateAll() std::unique_ptr Ride::saveToTrackDesign(TrackDesignState& tds) const { - if (!(lifecycleFlags & RIDE_LIFECYCLE_TESTED)) + if (!flags.has(RideFlag::tested)) { ContextShowError(STR_CANT_SAVE_TRACK_DESIGN, kStringIdNone, {}); return nullptr; @@ -1149,7 +1156,7 @@ void Ride::update() RideBreakdownUpdate(*this); // Various things include news messages - if (lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_DUE_INSPECTION)) + if (flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::dueInspection)) { // Breakdown updates originally were performed when (id == (gCurrentTicks / 2) & 0xFF) // with the increased MAX_RIDES the update is tied to the first byte of the id this allows @@ -1162,7 +1169,7 @@ void Ride::update() RideInspectionUpdate(*this); // If ride is simulating but crashed, reset the vehicles - if (status == RideStatus::simulating && (lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) + if (status == RideStatus::simulating && flags.has(RideFlag::crashed)) { // We require this to execute right away during the simulation, always ignore network and queue. auto gameAction = GameActions::RideSetStatusAction(id, RideStatus::simulating); @@ -1176,9 +1183,9 @@ void Ride::update() */ void updateChairlift(Ride& ride) { - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (!ride.flags.has(RideFlag::onTrack)) return; - if ((ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::crashed) && ride.breakdownReasonPending == 0) return; @@ -1339,7 +1346,7 @@ static void RideInspectionUpdate(Ride& ride) // An inspection interval of 0 minutes means the ride is set to never be inspected. if (inspectionIntervalMinutes == 0) { - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; + ride.flags.unset(RideFlag::dueInspection); return; } @@ -1349,13 +1356,11 @@ static void RideInspectionUpdate(Ride& ride) if (inspectionIntervalMinutes > ride.lastInspection) return; - if (ride.lifecycleFlags - & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_DUE_INSPECTION - | RIDE_LIFECYCLE_CRASHED)) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::dueInspection, RideFlag::crashed)) return; // Inspect the first station that has an exit - ride.lifecycleFlags |= RIDE_LIFECYCLE_DUE_INSPECTION; + ride.flags.set(RideFlag::dueInspection); ride.mechanicStatus = MechanicStatus::calling; auto stationIndex = RideGetFirstValidStationExit(ride); @@ -1399,7 +1404,7 @@ static void RideBreakdownUpdate(Ride& ride) if (gLegacyScene == LegacyScene::trackDesigner) return; - if (ride.lifecycleFlags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + if (ride.flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) ride.downtimeHistory[0]++; if (!(currentTicks & 8191)) @@ -1422,7 +1427,7 @@ static void RideBreakdownUpdate(Ride& ride) ride.windowInvalidateFlags.set(RideInvalidateFlag::maintenance); } - if (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::crashed)) return; if (ride.status == RideStatus::closed || ride.status == RideStatus::simulating) return; @@ -1522,7 +1527,7 @@ bool Ride::canBreakDown() const } const auto* entry = getRideEntry(); - return entry != nullptr && !(entry->flags & RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN); + return entry != nullptr && !entry->flags.has(RideEntryFlag::cannotBreakDown); } static void ChooseRandomTrainToBreakdownSafe(Ride& ride) @@ -1550,10 +1555,10 @@ void RidePrepareBreakdown(Ride& ride, int32_t breakdownReason) StationIndex i; Vehicle* vehicle; - if (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::crashed)) return; - ride.lifecycleFlags |= RIDE_LIFECYCLE_BREAKDOWN_PENDING; + ride.flags.set(RideFlag::breakdownPending); ride.breakdownReasonPending = breakdownReason; ride.breakdownSoundModifier = 0; @@ -1590,7 +1595,7 @@ void RidePrepareBreakdown(Ride& ride, int32_t breakdownReason) } if (vehicle != nullptr) { - vehicle->SetFlag(VehicleFlags::CarIsBroken); + vehicle->flags.set(VehicleFlag::carIsBroken); } } break; @@ -1603,7 +1608,7 @@ void RidePrepareBreakdown(Ride& ride, int32_t breakdownReason) vehicle = getGameState().entities.GetEntity(ride.vehicles[ride.brokenTrain]); if (vehicle != nullptr) { - vehicle->SetFlag(VehicleFlags::TrainIsBroken); + vehicle->flags.set(VehicleFlag::trainIsBroken); } break; case BREAKDOWN_BRAKES_FAILURE: @@ -1639,7 +1644,7 @@ void RideBreakdownAddNewsItem(const Ride& ride) static void RideBreakdownStatusUpdate(Ride& ride) { // Warn player if ride hasn't been fixed for ages - if (ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride.flags.has(RideFlag::brokenDown)) { ride.notFixedTimeout++; // When there has been a full 255 timeout ticks this @@ -1672,13 +1677,13 @@ static void RideMechanicStatusUpdate(Ride& ride, MechanicStatus mechanicStatus) // Turn a pending breakdown into a breakdown. if ((mechanicStatus == MechanicStatus::undefined || mechanicStatus == MechanicStatus::calling || mechanicStatus == MechanicStatus::heading) - && (ride.lifecycleFlags & RIDE_LIFECYCLE_BREAKDOWN_PENDING) && !(ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + && ride.flags.has(RideFlag::breakdownPending) && !ride.flags.has(RideFlag::brokenDown)) { auto breakdownReason = ride.breakdownReasonPending; if (breakdownReason == BREAKDOWN_SAFETY_CUT_OUT || breakdownReason == BREAKDOWN_BRAKES_FAILURE || breakdownReason == BREAKDOWN_CONTROL_FAILURE) { - ride.lifecycleFlags |= RIDE_LIFECYCLE_BROKEN_DOWN; + ride.flags.set(RideFlag::brokenDown); ride.windowInvalidateFlags.set(RideInvalidateFlag::maintenance, RideInvalidateFlag::list, RideInvalidateFlag::main); ride.breakdownReason = breakdownReason; RideBreakdownAddNewsItem(ride); @@ -1687,7 +1692,7 @@ static void RideMechanicStatusUpdate(Ride& ride, MechanicStatus mechanicStatus) switch (mechanicStatus) { case MechanicStatus::undefined: - if (ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride.flags.has(RideFlag::brokenDown)) { ride.mechanicStatus = MechanicStatus::calling; } @@ -1695,8 +1700,7 @@ static void RideMechanicStatusUpdate(Ride& ride, MechanicStatus mechanicStatus) case MechanicStatus::calling: if (ride.getRideTypeDescriptor().AvailableBreakdowns == 0) { - ride.lifecycleFlags &= ~( - RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_DUE_INSPECTION); + ride.flags.unset(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::dueInspection); break; } @@ -1705,7 +1709,7 @@ static void RideMechanicStatusUpdate(Ride& ride, MechanicStatus mechanicStatus) case MechanicStatus::heading: { auto mechanic = RideGetMechanic(ride); - bool rideNeedsRepair = (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)); + bool rideNeedsRepair = ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown); if (mechanic == nullptr || (mechanic->State != PeepState::headingToInspection && mechanic->State != PeepState::answering) || mechanic->CurrentRide != ride.id) @@ -1762,7 +1766,7 @@ static void RideCallMechanic(Ride& ride, Peep* mechanic, int32_t forInspection) */ static void RideCallClosestMechanic(Ride& ride) { - auto forInspection = (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)) == 0; + auto forInspection = !ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown); auto mechanic = RideFindClosestMechanic(ride, forInspection); if (mechanic != nullptr) RideCallMechanic(ride, mechanic, forInspection); @@ -1858,7 +1862,7 @@ Staff* RideGetMechanic(const Ride& ride) Staff* RideGetAssignedMechanic(const Ride& ride) { - if (ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride.flags.has(RideFlag::brokenDown)) { if (ride.mechanicStatus == MechanicStatus::heading || ride.mechanicStatus == MechanicStatus::fixing || ride.mechanicStatus == MechanicStatus::hasFixedStationBrakes) @@ -1883,7 +1887,7 @@ static int32_t RideMusicSampleRate(const Ride& ride) int32_t sampleRate = 22050; // Alter sample rate for a power cut effect - if (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown)) { sampleRate = ride.breakdownSoundModifier * 70; if (ride.breakdownReasonPending != BREAKDOWN_CONTROL_FAILURE) @@ -1901,7 +1905,7 @@ static int32_t RideMusicSampleRate(const Ride& ride) static bool RideMusicBreakdownEffect(Ride& ride) { // Oscillate parameters for a power cut effect when breaking down - if (ride.lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)) + if (ride.flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown)) { if (ride.breakdownReasonPending == BREAKDOWN_CONTROL_FAILURE) { @@ -1911,7 +1915,7 @@ static bool RideMusicBreakdownEffect(Ride& ride) } else { - if ((ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) || ride.breakdownReasonPending == BREAKDOWN_BRAKES_FAILURE + if (ride.flags.has(RideFlag::brokenDown) || ride.breakdownReasonPending == BREAKDOWN_BRAKES_FAILURE || ride.breakdownReasonPending == BREAKDOWN_CONTROL_FAILURE) { if (ride.breakdownSoundModifier != 255) @@ -1960,7 +1964,7 @@ void CircusMusicUpdate(Ride& ride) */ void DefaultMusicUpdate(Ride& ride) { - if (ride.status != RideStatus::open || !(ride.lifecycleFlags & RIDE_LIFECYCLE_MUSIC)) + if (ride.status != RideStatus::open || !ride.flags.has(RideFlag::music)) { ride.musicTuneId = kTuneIDNull; return; @@ -1996,7 +2000,7 @@ static void RideMusicUpdate(Ride& ride) { const auto& rtd = ride.getRideTypeDescriptor(); - if (!rtd.HasFlag(RtdFlag::hasMusicByDefault) && !rtd.HasFlag(RtdFlag::allowMusic)) + if (!rtd.flags.hasAny(RtdFlag::hasMusicByDefault, RtdFlag::allowMusic)) return; rtd.MusicUpdateFunction(ride); } @@ -2099,7 +2103,7 @@ void RideMeasurementsUpdate() for (auto& ride : RideManager(gameState)) { auto measurement = ride.measurement.get(); - if (measurement != nullptr && (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) && ride.status != RideStatus::simulating) + if (measurement != nullptr && ride.flags.has(RideFlag::onTrack) && ride.status != RideStatus::simulating) { if (measurement->flags.has(RideMeasurementFlag::running)) { @@ -2167,7 +2171,7 @@ std::pair Ride::getMeasurement() const auto& rtd = getRideTypeDescriptor(); // Check if ride type supports data logging - if (!rtd.HasFlag(RtdFlag::hasDataLogging)) + if (!rtd.flags.has(RtdFlag::hasDataLogging)) { return { nullptr, { STR_DATA_LOGGING_NOT_AVAILABLE_FOR_THIS_TYPE_OF_RIDE, {} } }; } @@ -2176,7 +2180,7 @@ std::pair Ride::getMeasurement() if (measurement == nullptr) { measurement = std::make_unique(); - if (rtd.HasFlag(RtdFlag::hasGForces)) + if (rtd.flags.has(RtdFlag::hasGForces)) { measurement->flags.set(RideMeasurementFlag::gForces); } @@ -2246,7 +2250,7 @@ int32_t RideGetUnusedPresetVehicleColour(ObjectEntryIndex subType) } // If all presets have been used, just go with a random preset - if (unused.size() == 0) + if (unused.empty()) return UtilRand() % colourPresets->count; // Choose a random preset from the list of unused presets @@ -2300,7 +2304,7 @@ void RideCheckAllReachable() if (ride.status != RideStatus::open || ride.connectedMessageThrottle != 0) continue; - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) RideShopConnected(ride); else RideEntranceExitConnected(ride); @@ -2610,7 +2614,7 @@ static ResultWithMessage RideModeCheckValidStationNumbers(const Ride& ride) } const auto& rtd = ride.getRideTypeDescriptor(); - if (rtd.HasFlag(RtdFlag::hasOneStation) && numStations > 1) + if (rtd.flags.has(RtdFlag::hasOneStation) && numStations > 1) return { false, STR_UNABLE_TO_OPERATE_WITH_MORE_THAN_ONE_STATION_IN_THIS_MODE }; return { true }; @@ -2627,7 +2631,7 @@ static StationIndexWithMessage RideModeCheckStationPresent(const Ride& ride) if (stationIndex.IsNull()) { const auto& rtd = ride.getRideTypeDescriptor(); - if (!rtd.HasFlag(RtdFlag::hasTrack)) + if (!rtd.flags.has(RtdFlag::hasTrack)) return { StationIndex::GetNull(), STR_NOT_YET_CONSTRUCTED }; if (rtd.specialType == RtdSpecialType::maze) @@ -2649,7 +2653,7 @@ static ResultWithMessage RideCheckForEntranceExit(RideId rideIndex) if (ride == nullptr) return { false }; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) return { true }; uint8_t entrance = 0; @@ -3200,7 +3204,7 @@ static void RideSetStartFinishPoints(RideId rideIndex, const CoordsXYE& startEle else if (rtd.specialType == RtdSpecialType::boatHire) RideSetBoatHireReturnPoint(*ride, startElement); - if (ride->isBlockSectioned() && !(ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (ride->isBlockSectioned() && !ride->flags.has(RideFlag::onTrack)) { RideOpenBlockBrakes(startElement); } @@ -3325,7 +3329,7 @@ static Vehicle* VehicleCreateCar( vehicle->SetTrackType(trackElement->GetTrackType()); vehicle->track_progress = 0; vehicle->SetState(Vehicle::Status::movingToEndOfStation); - vehicle->Flags = 0; + vehicle->flags.clearAll(); CoordsXY chosenLoc; auto numAttempts = 0; @@ -3366,7 +3370,7 @@ static Vehicle* VehicleCreateCar( subposition = VehicleTrackSubposition::MiniGolfStart9; vehicle->var_D3 = 0; vehicle->mini_golf_current_animation = MiniGolfAnimation::Walk; - vehicle->mini_golf_flags = 0; + vehicle->miniGolfFlags.clearAll(); } if (carEntry.flags.has(CarEntryFlag::isReverserCoasterBogie)) { @@ -3393,7 +3397,7 @@ static Vehicle* VehicleCreateCar( } else { - if (rtd.HasFlag(RtdFlag::vehicleIsIntegral)) + if (rtd.flags.has(RtdFlag::vehicleIsIntegral)) { if (rtd.StartTrackPiece != TrackElemType::flatTrack1x4B) { @@ -3424,20 +3428,20 @@ static Vehicle* VehicleCreateCar( { vehicle->track_progress = 15; } - vehicle->Flags = VehicleFlags::CollisionDisabled; + vehicle->flags = { VehicleFlag::collisionDisabled }; if (carEntry.flags.has(CarEntryFlag::hasInvertedSpriteSet)) { if (trackElement->IsInverted()) { - vehicle->SetFlag(VehicleFlags::CarIsInverted); + vehicle->flags.set(VehicleFlag::carIsInverted); } } vehicle->SetState(Vehicle::Status::movingToEndOfStation); - if (ride.hasLifecycleFlag(RIDE_LIFECYCLE_REVERSED_TRAINS)) + if (ride.flags.has(RideFlag::reversedTrains)) { vehicle->SubType = carIndex == (ride.numCarsPerTrain - 1) ? Vehicle::Type::head : Vehicle::Type::tail; - vehicle->SetFlag(VehicleFlags::CarIsReversed); + vehicle->flags.set(VehicleFlag::carIsReversed); } } @@ -3456,7 +3460,7 @@ static TrainReference VehicleCreateTrain( Ride& ride, const CoordsXYZ& trainPos, int32_t vehicleIndex, int32_t* remainingDistance, TrackElement* trackElement) { TrainReference train = { nullptr, nullptr }; - bool isReversed = ride.hasLifecycleFlag(RIDE_LIFECYCLE_REVERSED_TRAINS); + bool isReversed = ride.flags.has(RideFlag::reversedTrains); for (int32_t carIndex = 0; carIndex < ride.numCarsPerTrain; carIndex++) { @@ -3653,7 +3657,7 @@ ResultWithMessage Ride::createVehicles(const CoordsXYE& element, bool isApplying if (!VehicleCreateTrains(*this, vehiclePos, trackElement, numberOfTrains)) { // This flag is needed for Ride::removeVehicles() - lifecycleFlags |= RIDE_LIFECYCLE_ON_TRACK; + flags.set(RideFlag::onTrack); removeVehicles(); return { false, STR_UNABLE_TO_CREATE_ENOUGH_VEHICLES }; } @@ -3661,14 +3665,14 @@ ResultWithMessage Ride::createVehicles(const CoordsXYE& element, bool isApplying // Initialise station departs // 006DDDD0: - lifecycleFlags |= RIDE_LIFECYCLE_ON_TRACK; + flags.set(RideFlag::onTrack); for (int32_t i = 0; i < Limits::kMaxStationsPerRide; i++) { stations[i].Depart = (stations[i].Depart & kStationDepartFlag) | 1; } const auto& rtd = getRideTypeDescriptor(); - if (rtd.specialType != RtdSpecialType::spaceRings && !rtd.HasFlag(RtdFlag::vehicleIsIntegral)) + if (rtd.specialType != RtdSpecialType::spaceRings && !rtd.flags.has(RtdFlag::vehicleIsIntegral)) { if (isBlockSectioned() && !isSimulating) { @@ -3713,7 +3717,7 @@ void Ride::moveTrainsToBlockBrakes(const CoordsXYZ& firstBlockPosition, TrackEle // If the ride has a cable lift, we don't want to fetch the cable lift element and the block preceding it TrackElement* cableLiftTileElement = nullptr; TrackElement* cableLiftPreviousBlock = nullptr; - if (lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) + if (flags.has(RideFlag::cableLiftHillComponentUsed)) { cableLiftTileElement = MapGetTrackElementAt(cableLiftLoc); if (cableLiftTileElement != nullptr) @@ -3780,7 +3784,7 @@ void Ride::moveTrainsToBlockBrakes(const CoordsXYZ& firstBlockPosition, TrackEle } for (Vehicle* car = train; car != nullptr; car = getGameState().entities.GetEntity(car->next_vehicle_on_train)) { - car->ClearFlag(VehicleFlags::CollisionDisabled); + car->flags.unset(VehicleFlag::collisionDisabled); car->SetState(Vehicle::Status::travelling, car->sub_state); if ((car->GetTrackType()) == TrackElemType::endStation) { @@ -3952,7 +3956,7 @@ static ResultWithMessage RideCreateCableLift(RideId rideIndex, bool isApplying) head->prev_vehicle_on_ride = tail->Id; tail->next_vehicle_on_ride = head->Id; - ride->lifecycleFlags |= RIDE_LIFECYCLE_CABLE_LIFT; + ride->flags.set(RideFlag::cableLift); head->CableLiftUpdateTrackMotion(); return { true }; } @@ -4172,7 +4176,7 @@ ResultWithMessage Ride::open(bool isApplying) if (isApplying) { chainQueues(); - lifecycleFlags |= RIDE_LIFECYCLE_EVER_BEEN_OPENED; + flags.set(RideFlag::everBeenOpened); } CoordsXYE trackElement = {}; @@ -4326,7 +4330,7 @@ int32_t RideGetRandomColourPresetIndex(ride_type_t rideType) } // If all presets have been used, just go with a random preset - if (unused.size() == 0) + if (unused.empty()) return UtilRand() % colourPresets.count; // Choose a random preset from the list of unused presets @@ -4405,7 +4409,7 @@ void Ride::setNameToDefault() RideNaming GetRideNaming(const ride_type_t rideType, const RideObjectEntry* rideEntry) { const auto& rtd = GetRideTypeDescriptor(rideType); - if (rtd.HasFlag(RtdFlag::listVehiclesSeparately) && rideEntry != nullptr) + if (rtd.flags.has(RtdFlag::listVehiclesSeparately) && rideEntry != nullptr) { return rideEntry->naming; } @@ -4676,16 +4680,15 @@ void InvalidateTestResults(Ride& ride) { ride.measurement = {}; ride.ratings.setNull(); - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_TESTED; - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + ride.flags.unset(RideFlag::tested, RideFlag::testInProgress); + if (ride.flags.has(RideFlag::onTrack)) { for (int32_t i = 0; i < ride.numTrains; i++) { Vehicle* vehicle = getGameState().entities.GetEntity(ride.vehicles[i]); if (vehicle != nullptr) { - vehicle->ClearFlag(VehicleFlags::Testing); + vehicle->flags.unset(VehicleFlag::testing); } } } @@ -4703,21 +4706,17 @@ void InvalidateTestResults(Ride& ride) */ void RideFixBreakdown(Ride& ride, int32_t reliabilityIncreaseFactor) { - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_BREAKDOWN_PENDING; - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_BROKEN_DOWN; - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_DUE_INSPECTION; + ride.flags.unset(RideFlag::breakdownPending, RideFlag::brokenDown, RideFlag::dueInspection); ride.windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list, RideInvalidateFlag::maintenance); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (ride.flags.has(RideFlag::onTrack)) { for (int32_t i = 0; i < ride.numTrains; i++) { for (Vehicle* vehicle = getGameState().entities.GetEntity(ride.vehicles[i]); vehicle != nullptr; vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) { - vehicle->ClearFlag(VehicleFlags::StoppedBySafetyCutOut); - vehicle->ClearFlag(VehicleFlags::CarIsBroken); - vehicle->ClearFlag(VehicleFlags::TrainIsBroken); + vehicle->flags.unset(VehicleFlag::stoppedBySafetyCutout, VehicleFlag::carIsBroken, VehicleFlag::trainIsBroken); } } } @@ -4733,7 +4732,7 @@ void RideFixBreakdown(Ride& ride, int32_t reliabilityIncreaseFactor) void RideUpdateVehicleColours(const Ride& ride) { const auto& rtd = ride.getRideTypeDescriptor(); - if (rtd.specialType == RtdSpecialType::spaceRings || rtd.HasFlag(RtdFlag::vehicleIsIntegral)) + if (rtd.specialType == RtdSpecialType::spaceRings || rtd.flags.has(RtdFlag::vehicleIsIntegral)) { GfxInvalidateScreen(); } @@ -4755,7 +4754,7 @@ void RideUpdateVehicleColours(const Ride& ride) colours = ride.vehicleColours[i]; break; case VehicleColourSettings::perCar: - if (vehicle->HasFlag(VehicleFlags::CarIsReversed)) + if (vehicle->flags.has(VehicleFlag::carIsReversed)) { colours = ride.vehicleColours[std::min( (ride.numCarsPerTrain - 1) - carIndex, Limits::kMaxCarsPerTrain - 1)]; @@ -5191,7 +5190,7 @@ void Ride::updateMaxVehicles() } while (totalLength <= stationLength); if ((mode != RideMode::stationToStation && mode != RideMode::continuousCircuit) - || !rtd.HasFlag(RtdFlag::allowMoreVehiclesThanStationFits)) + || !rtd.flags.has(RtdFlag::allowMoreVehiclesThanStationFits)) { maxNumTrains = std::min(maxNumTrains, int32_t(Limits::kMaxTrainsPerRide)); } @@ -5557,7 +5556,7 @@ ObjectEntryIndex RideGetEntryIndex(ride_type_t rideType, ObjectEntryIndex rideSu { auto& objManager = GetContext()->GetObjectManager(); auto& rideEntries = objManager.GetAllRideEntries(rideType); - if (rideEntries.size() > 0) + if (!rideEntries.empty()) { subType = rideEntries[0]; for (auto rideEntryIndex : rideEntries) @@ -5574,7 +5573,7 @@ ObjectEntryIndex RideGetEntryIndex(ride_type_t rideType, ObjectEntryIndex rideSu continue; } - if (!GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::listVehiclesSeparately)) + if (!GetRideTypeDescriptor(rideType).flags.has(RtdFlag::listVehiclesSeparately)) { subType = rideEntryIndex; break; @@ -5844,19 +5843,6 @@ void Ride::updateRideTypeForAllPieces() } } -bool Ride::hasLifecycleFlag(uint32_t flag) const -{ - return (lifecycleFlags & flag) != 0; -} - -void Ride::setLifecycleFlag(uint32_t flag, bool on) -{ - if (on) - lifecycleFlags |= flag; - else - lifecycleFlags &= ~flag; -} - bool Ride::hasRecolourableShopItems() const { const auto rideEntry = getRideEntry(); @@ -5982,7 +5968,7 @@ ResultWithMessage Ride::changeStatusCheckTrackValidity(const CoordsXYE& trackEle { return { false, STR_UNKNOWN_RIDE }; } - if (rideEntry->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS) + if (rideEntry->flags.has(RideEntryFlag::noInversions)) { if (RideCheckTrackContainsInversions(trackElement, &problematicTrackElement)) { @@ -5990,7 +5976,7 @@ ResultWithMessage Ride::changeStatusCheckTrackValidity(const CoordsXYE& trackEle return { false, STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN }; } } - if (rideEntry->flags & RIDE_ENTRY_FLAG_NO_BANKED_TRACK) + if (rideEntry->flags.has(RideEntryFlag::noBankedTrack)) { if (RideCheckTrackContainsBanked(trackElement, &problematicTrackElement)) { @@ -6029,7 +6015,7 @@ ResultWithMessage Ride::changeStatusCreateVehicles(bool isApplying, const Coords RideSetStartFinishPoints(id, trackElement); const auto& rtd = getRideTypeDescriptor(); - if (!rtd.HasFlag(RtdFlag::noVehicles) && !(lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) + if (!rtd.flags.has(RtdFlag::noVehicles) && !flags.has(RideFlag::onTrack)) { const auto createVehicleResult = createVehicles(trackElement, isApplying, isSimulating); if (!createVehicleResult.Successful) @@ -6038,8 +6024,8 @@ ResultWithMessage Ride::changeStatusCreateVehicles(bool isApplying, const Coords } } - if (rtd.HasFlag(RtdFlag::allowCableLiftHill) && (lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) - && !(lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT)) + if (rtd.flags.has(RtdFlag::allowCableLiftHill) && flags.has(RideFlag::cableLiftHillComponentUsed) + && !flags.has(RideFlag::cableLift)) { const auto createCableLiftResult = RideCreateCableLift(id, isApplying); if (!createCableLiftResult.Successful) diff --git a/src/openrct2/ride/Ride.h b/src/openrct2/ride/Ride.h index 7e8ac9c2a3..ea679703d9 100644 --- a/src/openrct2/ride/Ride.h +++ b/src/openrct2/ride/Ride.h @@ -105,6 +105,34 @@ enum class RideTestingFlag : uint8_t }; using RideTestingFlags = FlagHolder; +enum class RideFlag : uint8_t +{ + onTrack, + tested, + testInProgress, + noRawStats, + passStationNoStopping, + onRidePhoto, + breakdownPending, + brokenDown, + dueInspection, + queueFull, + crashed, + hasStalledVehicle, + everBeenOpened, + music, + indestructible, + indestructibleTrack, + cableLiftHillComponentUsed, + cableLift, + notCustomDesign, // Used for the Award for Best Custom-designed Rides + sixFlagsDeprecated, // Not used anymore + fixedRatings, // When set, the ratings will not be updated (useful for hacked rides). + randomShopColours, + reversedTrains, +}; +using RideFlags = FlagHolder; + struct RideStation { static constexpr uint8_t kNoTrain = std::numeric_limits::max(); @@ -332,7 +360,7 @@ struct Ride uint8_t numBlockBrakes{}; uint8_t liftHillSpeed{}; uint32_t guestsFavourite{}; - uint32_t lifecycleFlags{}; + RideFlags flags{}; uint16_t totalAirTime{}; StationIndex currentTestStation{ StationIndex::GetNull() }; uint8_t numCircuits{}; @@ -408,6 +436,7 @@ public: bool isBlockSectioned() const; bool canHaveMultipleCircuits() const; bool supportsStatus(RideStatus s) const; + bool hasFailingBrakes() const; void stopGuestsQueuing(); void validateStations(); @@ -467,9 +496,6 @@ public: const OpenRCT2::StationObject* getStationObject() const; const OpenRCT2::MusicObject* getMusicObject() const; - bool hasLifecycleFlag(uint32_t flag) const; - void setLifecycleFlag(uint32_t flag, bool on); - bool hasRecolourableShopItems() const; bool hasStation() const; @@ -502,63 +528,6 @@ static_assert(sizeof(TrackBeginEnd) == 36); #pragma pack(pop) -// Constants used by the lifecycleFlags property at 0x1D0 -enum -{ - RIDE_LIFECYCLE_ON_TRACK = 1 << 0, - RIDE_LIFECYCLE_TESTED = 1 << 1, - RIDE_LIFECYCLE_TEST_IN_PROGRESS = 1 << 2, - RIDE_LIFECYCLE_NO_RAW_STATS = 1 << 3, - RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING = 1 << 4, - RIDE_LIFECYCLE_ON_RIDE_PHOTO = 1 << 5, - RIDE_LIFECYCLE_BREAKDOWN_PENDING = 1 << 6, - RIDE_LIFECYCLE_BROKEN_DOWN = 1 << 7, - RIDE_LIFECYCLE_DUE_INSPECTION = 1 << 8, - RIDE_LIFECYCLE_QUEUE_FULL = 1 << 9, - RIDE_LIFECYCLE_CRASHED = 1 << 10, - RIDE_LIFECYCLE_HAS_STALLED_VEHICLE = 1 << 11, - RIDE_LIFECYCLE_EVER_BEEN_OPENED = 1 << 12, - RIDE_LIFECYCLE_MUSIC = 1 << 13, - RIDE_LIFECYCLE_INDESTRUCTIBLE = 1 << 14, - RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK = 1 << 15, - RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED = 1 << 16, - RIDE_LIFECYCLE_CABLE_LIFT = 1 << 17, - RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN = 1 << 18, // Used for the Award for Best Custom-designed Rides - RIDE_LIFECYCLE_SIX_FLAGS_DEPRECATED = 1 << 19, // Not used anymore - RIDE_LIFECYCLE_FIXED_RATINGS = 1 << 20, // When set, the ratings will not be updated (useful for hacked rides). - RIDE_LIFECYCLE_RANDOM_SHOP_COLOURS = 1 << 21, - RIDE_LIFECYCLE_REVERSED_TRAINS = 1 << 22, -}; - -// Constants used by the ride_type->flags property at 0x008 -enum -{ - RIDE_ENTRY_FLAG_VEHICLE_TAB_SCALE_HALF = 1 << 0, - RIDE_ENTRY_FLAG_NO_INVERSIONS = 1 << 1, - RIDE_ENTRY_FLAG_NO_BANKED_TRACK = 1 << 2, - RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND = 1 << 3, - RIDE_ENTRY_FLAG_INVERTER_SHIP_SWING_MODE = 1 << 4, - RIDE_ENTRY_FLAG_TWIST_ROTATION_TYPE = 1 << 5, - RIDE_ENTRY_FLAG_ENTERPRISE_ROTATION_TYPE = 1 << 6, - RIDE_ENTRY_FLAG_DISABLE_WANDERING_DEPRECATED = 1 << 7, - RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND = 1 << 8, - RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE = 1 << 9, - RIDE_ENTRY_FLAG_COVERED_RIDE = 1 << 10, - RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS = 1 << 11, - RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME_DEPRECATED = 1 << 12, // Always set with SEPARATE_RIDE, and deprecated in favour of it. - RIDE_ENTRY_FLAG_SEPARATE_RIDE_DEPRECATED = 1 << 13, // Made redundant by ride groups - RIDE_ENTRY_FLAG_CANNOT_BREAK_DOWN = 1 << 14, - RIDE_ENTRY_DISABLE_LAST_OPERATING_MODE_DEPRECATED = 1 << 15, - RIDE_ENTRY_FLAG_DISABLE_DOOR_CONSTRUCTION_DEPRECATED = 1 << 16, - RIDE_ENTRY_DISABLE_FIRST_TWO_OPERATING_MODES_DEPRECATED = 1 << 17, - RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES = 1 << 18, - RIDE_ENTRY_FLAG_DISABLE_COLOUR_TAB = 1 << 19, - // Must be set with Inverter Ship swing mode as well. - RIDE_ENTRY_FLAG_MAGIC_CARPET_SWING_MODE = 1 << 20, - RIDE_ENTRY_FLAG_RIDER_CONTROLS_SPEED = 1 << 21, - RIDE_ENTRY_FLAG_HIDE_EMPTY_TRAINS = 1 << 22, -}; - enum { RIDE_TYPE_SPIRAL_ROLLER_COASTER = 0, diff --git a/src/openrct2/ride/RideConstruction.cpp b/src/openrct2/ride/RideConstruction.cpp index 7253d8ccba..4587fc1e6a 100644 --- a/src/openrct2/ride/RideConstruction.cpp +++ b/src/openrct2/ride/RideConstruction.cpp @@ -12,11 +12,12 @@ #include "../Context.h" #include "../GameState.h" #include "../Input.h" +#include "../actions/GameActionRunner.h" #include "../actions/ResultWithMessage.h" -#include "../actions/RideEntranceExitRemoveAction.h" -#include "../actions/RideSetSettingAction.h" -#include "../actions/RideSetStatusAction.h" -#include "../actions/TrackRemoveAction.h" +#include "../actions/ride/RideEntranceExitRemoveAction.h" +#include "../actions/ride/RideSetSettingAction.h" +#include "../actions/ride/RideSetStatusAction.h" +#include "../actions/track/TrackRemoveAction.h" #include "../entity/EntityList.h" #include "../entity/EntityRegistry.h" #include "../entity/Staff.h" @@ -100,7 +101,7 @@ static int32_t ride_check_if_construction_allowed(Ride& ride) ContextShowError(STR_INVALID_RIDE_TYPE, STR_CANT_EDIT_INVALID_RIDE_TYPE, ft); return 0; } - if (ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (ride.flags.has(RideFlag::brokenDown)) { ride.formatNameTo(ft); ContextShowError(STR_CANT_START_CONSTRUCTION_ON, STR_HAS_BROKEN_DOWN_AND_REQUIRES_FIXING, ft); @@ -153,9 +154,9 @@ void RideConstructionStart(Ride& ride) */ static void ride_remove_cable_lift(Ride& ride) { - if (ride.lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT) + if (ride.flags.has(RideFlag::cableLift)) { - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_CABLE_LIFT; + ride.flags.unset(RideFlag::cableLift); auto spriteIndex = ride.cableLift; do { @@ -177,10 +178,9 @@ static void ride_remove_cable_lift(Ride& ride) */ void Ride::removeVehicles() { - if (lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK) + if (flags.has(RideFlag::onTrack)) { - lifecycleFlags &= ~RIDE_LIFECYCLE_ON_TRACK; - lifecycleFlags &= ~(RIDE_LIFECYCLE_TEST_IN_PROGRESS | RIDE_LIFECYCLE_HAS_STALLED_VEHICLE); + flags.unset(RideFlag::onTrack, RideFlag::testInProgress, RideFlag::hasStalledVehicle); for (size_t i = 0; i <= Limits::kMaxTrainsPerRide; i++) { @@ -223,7 +223,7 @@ void RideClearForConstruction(Ride& ride) { ride.measurement = {}; - ride.lifecycleFlags &= ~(RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN); + ride.flags.unset(RideFlag::breakdownPending, RideFlag::brokenDown); ride.windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); // Open circuit rides will go directly into building mode (creating ghosts) where it would normally clear the stats, @@ -553,14 +553,14 @@ static void ride_construction_reset_current_piece() const auto& rtd = ride->getRideTypeDescriptor(); - if (rtd.HasFlag(RtdFlag::hasTrack) || ride->numStations == 0) + if (rtd.flags.has(RtdFlag::hasTrack) || ride->numStations == 0) { _currentlySelectedTrack = rtd.StartTrackPiece; _currentTrackPitchEnd = TrackPitch::none; _currentTrackRollEnd = TrackRoll::none; _currentTrackHasLiftHill = false; _currentTrackAlternative.clearAll(); - if (rtd.HasFlag(RtdFlag::startConstructionInverted)) + if (rtd.flags.has(RtdFlag::startConstructionInverted)) { _currentTrackAlternative.set(AlternativeTrackFlag::inverted); } @@ -608,7 +608,7 @@ void RideConstructionSetDefaultNextPiece() tileElement = trackBeginEnd.begin_element; trackType = tileElement->AsTrack()->GetTrackType(); - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { ride_construction_reset_current_piece(); return; @@ -616,7 +616,7 @@ void RideConstructionSetDefaultNextPiece() // Set whether track is covered _currentTrackAlternative.unset(AlternativeTrackFlag::inverted); - if (rtd.HasFlag(RtdFlag::hasInvertedVariant)) + if (rtd.flags.has(RtdFlag::hasInvertedVariant)) { if (tileElement->AsTrack()->IsInverted()) { @@ -632,7 +632,7 @@ void RideConstructionSetDefaultNextPiece() _currentlySelectedTrack = ted->curveChain.next; // Set track banking - if (rtd.HasFlag(RtdFlag::hasInvertedVariant)) + if (rtd.flags.has(RtdFlag::hasInvertedVariant)) { if (bank == TrackRoll::upsideDown) { @@ -675,7 +675,7 @@ void RideConstructionSetDefaultNextPiece() // Set whether track is covered _currentTrackAlternative.unset(AlternativeTrackFlag::inverted); - if (rtd.HasFlag(RtdFlag::hasInvertedVariant)) + if (rtd.flags.has(RtdFlag::hasInvertedVariant)) { if (tileElement->AsTrack()->IsInverted()) { @@ -691,7 +691,7 @@ void RideConstructionSetDefaultNextPiece() _currentlySelectedTrack = ted->curveChain.previous; // Set track banking - if (rtd.HasFlag(RtdFlag::hasInvertedVariant)) + if (rtd.flags.has(RtdFlag::hasInvertedVariant)) { if (bank == TrackRoll::upsideDown) { @@ -972,7 +972,7 @@ bool RideModify(const CoordsXYE& input) if (rideEntry == nullptr || !ride_check_if_construction_allowed(*ride)) return false; - if (ride->lifecycleFlags & RIDE_LIFECYCLE_INDESTRUCTIBLE && !getGameState().cheats.makeAllDestructible) + if (ride->flags.has(RideFlag::indestructible) && !getGameState().cheats.makeAllDestructible) { Formatter ft; ride->formatNameTo(ft); @@ -995,7 +995,7 @@ bool RideModify(const CoordsXYE& input) if (tileElement.element->GetType() != TileElementType::Track) return false; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::cannotHaveGaps)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::cannotHaveGaps)) { CoordsXYE endOfTrackElement{}; if (ride->findTrackGap(tileElement, &endOfTrackElement)) @@ -1027,7 +1027,7 @@ bool RideModify(const CoordsXYE& input) _rideConstructionNextArrowPulse = 0; gMapSelectFlags.unset(MapSelectFlag::enableArrow); - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) { WindowRideConstructionUpdateActiveElements(); return true; @@ -1088,7 +1088,7 @@ int32_t RideInitialiseConstructionWindow(Ride& ride) _currentTrackHasLiftHill = false; _currentTrackAlternative.clearAll(); - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::startConstructionInverted)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::startConstructionInverted)) _currentTrackAlternative.set(AlternativeTrackFlag::inverted); _previousTrackRollEnd = TrackRoll::none; @@ -1242,7 +1242,7 @@ void Ride::validateStations() // In the future this could look at the TED and see if the station has a sequence longer than 1 // tower ride, flat ride, shop - if (getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation)) + if (getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation)) { // if the track has multiple sequences, stop looking for the next one. specialTrack = true; @@ -1483,7 +1483,7 @@ bool RideSelectForwardsFromBack() */ ResultWithMessage RideAreAllPossibleEntrancesAndExitsBuilt(const Ride& ride) { - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) return { true }; for (auto& station : ride.getStations()) diff --git a/src/openrct2/ride/RideData.cpp b/src/openrct2/ride/RideData.cpp index cfdd9274a2..2e321bd7b7 100644 --- a/src/openrct2/ride/RideData.cpp +++ b/src/openrct2/ride/RideData.cpp @@ -361,11 +361,6 @@ constexpr RideTypeDescriptor kRideTypeDescriptors[RIDE_TYPE_COUNT] = { /* RIDE_TYPE_CLASSIC_WOODEN_TWISTER_ROLLER_COASTER */ ClassicWoodenTwisterRollerCoasterRTD, }; -bool RideTypeDescriptor::HasFlag(RtdFlag flag) const -{ - return ::HasFlag(Flags, flag); -} - bool RideTypeDescriptor::SupportsTrackGroup(const TrackGroup trackGroup) const { return TrackPaintFunctions.Regular.SupportsTrackGroup(trackGroup); diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index 5fac1c337b..fa3df41120 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -445,7 +445,10 @@ enum class RtdFlag : uint8_t runningSpeedAffectsReliability, poweredLaunchAffectsReliability, reverseInclineLaunchAffectsReliability, + + isDummyType, }; +using RtdFlags = FlagHolder; /** * Some rides are so different from others that they need some special code. @@ -469,16 +472,24 @@ enum class RtdSpecialType }; // Set on ride types that have a main colour, additional colour and support colour. -constexpr uint64_t kRtdFlagsHasThreeColours = EnumsToFlags( - RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, RtdFlag::hasTrackColourSupports); +constexpr RtdFlags kRtdFlagsHasThreeColours = { RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, + RtdFlag::hasTrackColourSupports }; // Set on _all_ roller coaster ride types, including the _ALT types used for constructing upside down. -constexpr uint64_t kRtdFlagsCommonCoaster = EnumsToFlags( - RtdFlag::hasGForces, RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, - RtdFlag::hasVehicleColours, RtdFlag::checkForStalling, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, - RtdFlag::allowMusic, RtdFlag::interestingToLookAt, RtdFlag::canSynchroniseWithAdjacentStations); +constexpr RtdFlags kRtdFlagsCommonCoaster = { RtdFlag::hasGForces, + RtdFlag::hasDataLogging, + RtdFlag::hasDrops, + RtdFlag::hasLoadOptions, + RtdFlag::guestsWillRideAgain, + RtdFlag::hasVehicleColours, + RtdFlag::checkForStalling, + RtdFlag::hasTrack, + RtdFlag::supportsMultipleColourSchemes, + RtdFlag::allowMusic, + RtdFlag::interestingToLookAt, + RtdFlag::canSynchroniseWithAdjacentStations }; // Set on all roller coaster ride types, excluding the _ALT types used for constructing upside down. -constexpr uint64_t kRtdFlagsCommonCoasterNonAlt = EnumsToFlags( - RtdFlag::showInTrackDesigner, RtdFlag::hasAirTime, RtdFlag::hasEntranceAndExit); +constexpr RtdFlags kRtdFlagsCommonCoasterNonAlt = { RtdFlag::showInTrackDesigner, RtdFlag::hasAirTime, + RtdFlag::hasEntranceAndExit }; struct RideTypeDescriptor { @@ -487,7 +498,7 @@ struct RideTypeDescriptor OpenRCT2::TrackElemType StartTrackPiece{}; TrackDrawerDescriptor TrackPaintFunctions{}; TrackDrawerDescriptor InvertedTrackPaintFunctions{}; - uint64_t Flags{}; + RtdFlags flags{}; /** rct2: 0x0097C8AC */ uint64_t RideModes{}; RideMode DefaultMode{}; @@ -549,7 +560,6 @@ struct RideTypeDescriptor UpdateRideApproachVehicleWaypointsFunction UpdateRideApproachVehicleWaypoints = UpdateRideApproachVehicleWaypointsDefault; RtdSpecialType specialType = RtdSpecialType::none; - bool HasFlag(RtdFlag flag) const; /** @deprecated */ bool SupportsTrackGroup(TrackGroup trackGroup) const; ResearchCategory GetResearchCategory() const; @@ -627,7 +637,7 @@ constexpr RideTypeDescriptor kDummyRTD = .StartTrackPiece = OpenRCT2::TrackElemType::endStation, .TrackPaintFunctions = {}, .InvertedTrackPaintFunctions = {}, - .Flags = 0, + .flags = { RtdFlag::isDummyType }, .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, .OperatingSettings = {}, diff --git a/src/openrct2/ride/RideEntry.h b/src/openrct2/ride/RideEntry.h index 0731667455..007f50de05 100644 --- a/src/openrct2/ride/RideEntry.h +++ b/src/openrct2/ride/RideEntry.h @@ -39,6 +39,37 @@ struct VehicleColourPresetList VehicleColour list[256]; }; +// Constants used by the ride_type->flags property at 0x008 +enum class RideEntryFlag : uint8_t +{ + tabIconIsHalfScale, + noInversions, + noBankedTrack, + playDepartSound, + inverterShipSwingMode, + hasTwistRotationType, + hasEnterpriseRotationType, + disableWanderingDeprecated, + playSplashSound, + playSplashSoundSlide, + isACoveredRide, + limitAirTimeBonus, + // Both flags below were made redundant by ride groups and deprecated in favour of it + separateRideNameDeprecated, + separateRideDeprecated, + cannotBreakDown, + disableLastOperatingModeDeprecated, + disableDoorConstructionDeprecated, + disableFirstTwoOperatingModesDeprecated, + disableCollisionCrashes, + disableColourTab, + // Must be set with Inverter Ship swing mode as well + magicCarpetSwingMode, + riderControlsSpeed, + hideEmptyTrains, +}; +using RideEntryFlags = FlagHolder; + /** * Ride type structure. */ @@ -47,7 +78,7 @@ struct RideObjectEntry RideNaming naming; // The first three images are previews. They correspond to the ride_type[] array. uint32_t images_offset; - uint32_t flags; + RideEntryFlags flags; ride_type_t ride_type[OpenRCT2::RCT2::ObjectLimits::kMaxRideTypesPerRideEntry]; uint8_t min_cars_in_train; uint8_t max_cars_in_train; diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 21bc8a4eac..460d59a16d 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -263,7 +263,7 @@ static bool ShouldSkipRatingCalculation(const Ride& ride) } // Skip rides that have a fixed rating. - if (ride.lifecycleFlags & RIDE_LIFECYCLE_FIXED_RATINGS) + if (ride.flags.has(RideFlag::fixedRatings)) { return true; } @@ -383,7 +383,7 @@ static void ride_ratings_update_state_2(RideRating::UpdateState& state) if (tileElement->AsTrack()->GetRideIndex() != ride->id) { // Only check that the track belongs to the same ride if ride does not have buildable track - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) continue; } @@ -488,7 +488,7 @@ static void ride_ratings_update_state_5(RideRating::UpdateState& state) if (tileElement->AsTrack()->GetRideIndex() != ride->id) { // Only check that the track belongs to the same ride if ride does not have buildable track - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) continue; } @@ -880,12 +880,11 @@ static void RideRatingsCalculate(RideRating::UpdateState& state, Ride& ride) switch (rrd.Type) { case RatingsCalculationType::Normal: - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED)) + if (!ride.flags.has(RideFlag::tested)) return; break; case RatingsCalculationType::FlatRide: - ride.lifecycleFlags |= RIDE_LIFECYCLE_TESTED; - ride.lifecycleFlags |= RIDE_LIFECYCLE_NO_RAW_STATS; + ride.flags.set(RideFlag::tested, RideFlag::noRawStats); break; case RatingsCalculationType::Stall: ride.upkeepCost = RideComputeUpkeep(state, ride); @@ -1071,7 +1070,7 @@ static void RideRatingsCalculate(RideRating::UpdateState& state, Ride& ride) #ifdef ENABLE_SCRIPTING // Only call the 'ride.ratings.calculate' API hook if testing of the ride is complete - if (ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED) + if (ride.flags.has(RideFlag::tested)) { auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); if (hookEngine.HasSubscriptions(HookType::rideRatingsCalculate)) @@ -1194,7 +1193,7 @@ static money64 RideComputeUpkeep(RideRating::UpdateState& state, const Ride& rid totalLength *= ride.getRideTypeDescriptor().UpkeepCosts.TrackLengthMultiplier; upkeep += static_cast(totalLength >> 10); - if (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO) + if (ride.flags.has(RideFlag::onRidePhoto)) { // The original code read from a table starting at 0x0097E3AE and // incrementing by 0x12 bytes between values. However, all of these @@ -1273,10 +1272,10 @@ static void RideRatingsApplyAdjustments(const Ride& ride, RideRating::Tuple& rat // Apply total air time #ifdef ORIGINAL_RATINGS - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasAirTime)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::hasAirTime)) { uint16_t totalAirTime = ride.totalAirTime; - if (rideEntry->flags & RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS) + if (rideEntry->flags.has(RideEntryFlag::limitAirTimeBonus)) { if (totalAirTime >= 96) { @@ -1292,10 +1291,10 @@ static void RideRatingsApplyAdjustments(const Ride& ride, RideRating::Tuple& rat } } #else - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasAirTime)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::hasAirTime)) { int32_t excitementModifier; - if (rideEntry->flags & RIDE_ENTRY_FLAG_LIMIT_AIRTIME_BONUS) + if (rideEntry->flags.has(RideEntryFlag::limitAirTimeBonus)) { // Limit airtime bonus for heartline twister coaster (see issues #2031 and #2064) excitementModifier = std::min(ride.totalAirTime, 96) / 8; @@ -1337,15 +1336,15 @@ static void SetUnreliabilityFactor(Ride& ride) { const auto& rtd = ride.getRideTypeDescriptor(); // Special unreliability for a few ride types - if (rtd.HasFlag(RtdFlag::reverseInclineLaunchAffectsReliability) && ride.mode == RideMode::reverseInclineLaunchedShuttle) + if (rtd.flags.has(RtdFlag::reverseInclineLaunchAffectsReliability) && ride.mode == RideMode::reverseInclineLaunchedShuttle) { ride.unreliabilityFactor += 10; } - else if (rtd.HasFlag(RtdFlag::poweredLaunchAffectsReliability) && ride.isPoweredLaunched()) + else if (rtd.flags.has(RtdFlag::poweredLaunchAffectsReliability) && ride.isPoweredLaunched()) { ride.unreliabilityFactor += 5; } - else if (rtd.HasFlag(RtdFlag::runningSpeedAffectsReliability)) + else if (rtd.flags.has(RtdFlag::runningSpeedAffectsReliability)) { ride.unreliabilityFactor += (ride.speed * 2); } @@ -1436,7 +1435,7 @@ static ShelteredEights GetNumOfShelteredEighths(const Ride& ride) { return { 0, 0 }; } - if (rideType->flags & RIDE_ENTRY_FLAG_COVERED_RIDE) + if (rideType->flags.has(RideEntryFlag::isACoveredRide)) numShelteredEighths = 7; return { trackShelteredEighths, numShelteredEighths }; @@ -1908,7 +1907,7 @@ static void RideRatingsApplyBonusOperationOption(RideRating::Tuple& ratings, con static void RideRatingsApplyBonusReversedTrains(RideRating::Tuple& ratings, const Ride& ride, RatingsModifier modifier) { - if (ride.hasLifecycleFlag(RIDE_LIFECYCLE_REVERSED_TRAINS)) + if (ride.flags.has(RideFlag::reversedTrains)) { RideRatingsAdd( ratings, ((ratings.excitement * modifier.excitement) >> 7), (ratings.intensity * modifier.intensity) >> 7, @@ -1950,7 +1949,7 @@ static void RideRatingsApplyBonusMazeSize(RideRating::Tuple& ratings, const Ride static void RideRatingsApplyBonusBoatHireNoCircuit(RideRating::Tuple& ratings, const Ride& ride, RatingsModifier modifier) { // Most likely checking if the ride has does not have a circuit - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED)) + if (!ride.flags.has(RideFlag::tested)) { RideRatingsAdd(ratings, modifier.excitement, modifier.intensity, modifier.nausea); } diff --git a/src/openrct2/ride/ShopItem.cpp b/src/openrct2/ride/ShopItem.cpp index 53499ce110..5ad42d7ace 100644 --- a/src/openrct2/ride/ShopItem.cpp +++ b/src/openrct2/ride/ShopItem.cpp @@ -55,10 +55,10 @@ constexpr ShopItemDescriptor ShopItems[EnumValue(ShopItem::count)] = { /* ShopItem::lemonade */ { 0.40_GBP, 1.10_GBP, 2.10_GBP, 1.00_GBP, 1.20_GBP, SPR_SHOP_ITEM_LEMONADE, { STR_SHOP_ITEM_PRICE_LABEL_LEMONADE, STR_SHOP_ITEM_SINGULAR_LEMONADE, STR_SHOP_ITEM_PLURAL_LEMONADE, STR_SHOP_ITEM_INDEFINITE_LEMONADE, STR_SHOP_ITEM_DISPLAY_LEMONADE }, SHOP_ITEM_FLAG_IS_DRINK, Litter::Type::emptyBottle, 115, ShopItem::emptyBottle, PeepThoughtType::LemonadeMuch, PeepThoughtType::Lemonade }, /* ShopItem::emptyBox */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, SPR_SHOP_ITEM_EMPTY_BOX, { STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOX, STR_SHOP_ITEM_SINGULAR_EMPTY_BOX, STR_SHOP_ITEM_PLURAL_EMPTY_BOX, STR_SHOP_ITEM_INDEFINITE_EMPTY_BOX, STR_SHOP_ITEM_DISPLAY_EMPTY_BOX }, SHOP_ITEM_FLAG_IS_CONTAINER, Litter::Type::emptyBox, 0, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, /* ShopItem::emptyBottle */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, SPR_SHOP_ITEM_EMPTY_BOTTLE, { STR_SHOP_ITEM_PRICE_LABEL_EMPTY_BOTTLE, STR_SHOP_ITEM_SINGULAR_EMPTY_BOTTLE, STR_SHOP_ITEM_PLURAL_EMPTY_BOTTLE, STR_SHOP_ITEM_INDEFINITE_EMPTY_BOTTLE, STR_SHOP_ITEM_DISPLAY_EMPTY_BOTTLE }, SHOP_ITEM_FLAG_IS_CONTAINER, Litter::Type::emptyBottle, 0, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, - /* 28 */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, - /* 29 */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, - /* 30 */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, - /* ShopItem::admission */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, + /* 28 */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, + /* 29 */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, + /* 30 */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, + /* ShopItem::admission */ { 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0.00_GBP, 0, { kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone, kStringIdNone }, 0, Litter::Type::vomit, 0xFF, ShopItem::none, PeepThoughtType::None, PeepThoughtType::None }, /* ShopItem::photo2 */ { 0.20_GBP, 3.00_GBP, 3.00_GBP, 3.00_GBP, 0.00_GBP, SPR_SHOP_ITEM_PHOTO2, { STR_SHOP_ITEM_PRICE_LABEL_ON_RIDE_PHOTO, STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO, STR_SHOP_ITEM_PLURAL_ON_RIDE_PHOTO, STR_SHOP_ITEM_INDEFINITE_ON_RIDE_PHOTO, STR_SHOP_ITEM_DISPLAY_ON_RIDE_PHOTO }, SHOP_ITEM_FLAG_IS_PHOTO | SHOP_ITEM_FLAG_IS_SOUVENIR, Litter::Type::rubbish, 0, ShopItem::none, PeepThoughtType::Photo2Much, PeepThoughtType::Photo2 }, /* ShopItem::photo3 */ { 0.20_GBP, 3.00_GBP, 3.00_GBP, 3.00_GBP, 0.00_GBP, SPR_SHOP_ITEM_PHOTO3, { STR_SHOP_ITEM_PRICE_LABEL_ON_RIDE_PHOTO, STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO, STR_SHOP_ITEM_PLURAL_ON_RIDE_PHOTO, STR_SHOP_ITEM_INDEFINITE_ON_RIDE_PHOTO, STR_SHOP_ITEM_DISPLAY_ON_RIDE_PHOTO }, SHOP_ITEM_FLAG_IS_PHOTO | SHOP_ITEM_FLAG_IS_SOUVENIR, Litter::Type::rubbish, 0, ShopItem::none, PeepThoughtType::Photo3Much, PeepThoughtType::Photo3 }, /* ShopItem::photo4 */ { 0.20_GBP, 3.00_GBP, 3.00_GBP, 3.00_GBP, 0.00_GBP, SPR_SHOP_ITEM_PHOTO4, { STR_SHOP_ITEM_PRICE_LABEL_ON_RIDE_PHOTO, STR_SHOP_ITEM_SINGULAR_ON_RIDE_PHOTO, STR_SHOP_ITEM_PLURAL_ON_RIDE_PHOTO, STR_SHOP_ITEM_INDEFINITE_ON_RIDE_PHOTO, STR_SHOP_ITEM_DISPLAY_ON_RIDE_PHOTO }, SHOP_ITEM_FLAG_IS_PHOTO | SHOP_ITEM_FLAG_IS_SOUVENIR, Litter::Type::rubbish, 0, ShopItem::none, PeepThoughtType::Photo4Much, PeepThoughtType::Photo4 }, @@ -136,7 +136,7 @@ money64 ShopItemGetCommonPrice(Ride* forRide, const ShopItem shopItem) { return ride.price[1]; } - if (GetShopItemDescriptor(shopItem).IsPhoto() && (ride.lifecycleFlags & RIDE_LIFECYCLE_ON_RIDE_PHOTO)) + if (GetShopItemDescriptor(shopItem).IsPhoto() && ride.flags.has(RideFlag::onRidePhoto)) { return ride.price[1]; } diff --git a/src/openrct2/ride/Station.cpp b/src/openrct2/ride/Station.cpp index 23f3f8861f..0ffaaffb2c 100644 --- a/src/openrct2/ride/Station.cpp +++ b/src/openrct2/ride/Station.cpp @@ -98,13 +98,13 @@ static void RideUpdateStationDodgems(Ride& ride, StationIndex stationIndex) // Change of station depart flag should really call invalidate_station_start // but since dodgems do not have station lights there is no point. - if (ride.status == RideStatus::closed || (ride.lifecycleFlags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) + if (ride.status == RideStatus::closed || ride.flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) { station.Depart &= ~kStationDepartFlag; return; } - if (ride.lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) + if (ride.flags.has(RideFlag::passStationNoStopping)) { int32_t dx = ride.timeLimit * 32; int32_t dh = (dx >> 8) & 0xFF; @@ -118,7 +118,7 @@ static void RideUpdateStationDodgems(Ride& ride, StationIndex stationIndex) continue; // End match - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; + ride.flags.unset(RideFlag::passStationNoStopping); station.Depart &= ~kStationDepartFlag; return; } @@ -143,7 +143,7 @@ static void RideUpdateStationDodgems(Ride& ride, StationIndex stationIndex) } // Begin the match - ride.lifecycleFlags |= RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; + ride.flags.set(RideFlag::passStationNoStopping); station.Depart |= kStationDepartFlag; ride.windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); } @@ -158,7 +158,7 @@ static void RideUpdateStationNormal(Ride& ride, StationIndex stationIndex) auto& station = ride.getStation(stationIndex); int32_t time = station.Depart & kStationDepartMask; const auto currentTicks = getGameState().currentTicks; - if ((ride.lifecycleFlags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) + if (ride.flags.hasAny(RideFlag::brokenDown, RideFlag::crashed) || (ride.status == RideStatus::closed && ride.numRiders == 0)) { if (time != 0 && time != 127 && !(currentTicks & 7)) @@ -192,7 +192,7 @@ static void RideUpdateStationNormal(Ride& ride, StationIndex stationIndex) static void RideUpdateStationRace(Ride& ride, StationIndex stationIndex) { auto& station = ride.getStation(stationIndex); - if (ride.status == RideStatus::closed || (ride.lifecycleFlags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))) + if (ride.status == RideStatus::closed || ride.flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) { if (station.Depart & kStationDepartFlag) { @@ -202,7 +202,7 @@ static void RideUpdateStationRace(Ride& ride, StationIndex stationIndex) return; } - if (ride.lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) + if (ride.flags.has(RideFlag::passStationNoStopping)) { int32_t numLaps = ride.numLaps; @@ -226,7 +226,7 @@ static void RideUpdateStationRace(Ride& ride, StationIndex stationIndex) } // Race is over - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; + ride.flags.unset(RideFlag::passStationNoStopping); if (station.Depart & kStationDepartFlag) { station.Depart &= ~kStationDepartFlag; @@ -261,7 +261,7 @@ static void RideUpdateStationRace(Ride& ride, StationIndex stationIndex) // Begin the race RideRaceInitVehicleSpeeds(ride); - ride.lifecycleFlags |= RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING; + ride.flags.set(RideFlag::passStationNoStopping); if (!(station.Depart & kStationDepartFlag)) { station.Depart |= kStationDepartFlag; @@ -285,7 +285,7 @@ static void RideRaceInitVehicleSpeeds(const Ride& ride) if (vehicle == nullptr) continue; - vehicle->ClearFlag(VehicleFlags::CurrentlyColliding); + vehicle->flags.unset(VehicleFlag::currentlyColliding); const auto* rideEntry = vehicle->GetRideEntry(); diff --git a/src/openrct2/ride/Track.cpp b/src/openrct2/ride/Track.cpp index 9c4733b1ec..27d4873a79 100644 --- a/src/openrct2/ride/Track.cpp +++ b/src/openrct2/ride/Track.cpp @@ -128,7 +128,7 @@ ResultWithMessage TrackAddStationElement(CoordsXYZD loc, RideId rideIndex, Comma CoordsXY stationFrontLoc = loc; int32_t stationLength = 1; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation)) { if (ride->numStations >= Limits::kMaxStationsPerRide) { @@ -280,7 +280,7 @@ ResultWithMessage TrackRemoveStationElement(const CoordsXYZD& loc, RideId rideIn int32_t stationLength = 0; int32_t ByteF441D1 = -1; - if (ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasSinglePieceStation)) + if (ride->getRideTypeDescriptor().flags.has(RtdFlag::hasSinglePieceStation)) { TileElement* tileElement = MapGetTrackElementAtWithDirectionFromRide(loc, rideIndex); if (tileElement != nullptr) @@ -590,7 +590,7 @@ TrackRoll TrackGetActualBank(TileElement* tileElement, TrackRoll bank) TrackRoll TrackGetActualBank2(ride_type_t rideType, bool isInverted, TrackRoll bank) { - if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::hasInvertedVariant)) + if (GetRideTypeDescriptor(rideType).flags.has(RtdFlag::hasInvertedVariant)) { if (isInverted) { diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index 8c377332ec..7c9becacab 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -388,7 +388,7 @@ namespace OpenRCT2 onRidePhoto = 114, down25LeftBanked = 115, down25RightBanked = 116, - watersplash = 117, + waterSplash = 117, flatToUp60LongBase = 118, up60ToFlatLongBase = 119, whirlpool = 120, diff --git a/src/openrct2/ride/TrackData.cpp b/src/openrct2/ride/TrackData.cpp index 458714dfd5..98477eb666 100644 --- a/src/openrct2/ride/TrackData.cpp +++ b/src/openrct2/ride/TrackData.cpp @@ -500,7 +500,7 @@ namespace OpenRCT2::TrackMetaData 32, // TrackElemType::onRidePhoto 33, // TrackElemType::down25LeftBanked 33, // TrackElemType::down25RightBanked - 128, // TrackElemType::watersplash + 128, // TrackElemType::waterSplash 165, // TrackElemType::flatToUp60LongBase 165, // TrackElemType::up60ToFlatLongBase 32, // TrackElemType::whirlpool @@ -1755,7 +1755,7 @@ namespace OpenRCT2::TrackMetaData 196608, // TrackElemType::onRidePhoto 83968, // TrackElemType::down25LeftBanked 83968, // TrackElemType::down25RightBanked - 393216, // TrackElemType::watersplash + 393216, // TrackElemType::waterSplash 376832, // TrackElemType::flatToUp60LongBase 376832, // TrackElemType::up60ToFlatLongBase 126976, // TrackElemType::whirlpool @@ -2110,7 +2110,7 @@ namespace OpenRCT2::TrackMetaData TrackElemType::onRidePhoto, TrackElemType::down25RightBanked, // TrackElemType::down25LeftBanked TrackElemType::down25LeftBanked, // TrackElemType::down25RightBanked - TrackElemType::watersplash, + TrackElemType::waterSplash, TrackElemType::flatToUp60LongBase, TrackElemType::up60ToFlatLongBase, TrackElemType::whirlpool, @@ -2465,7 +2465,7 @@ namespace OpenRCT2::TrackMetaData /* TrackElemType::onRidePhoto */ {}, /* TrackElemType::down25LeftBanked */ { TrackElementFlag::down, TrackElementFlag::startsAtHalfHeight, TrackElementFlag::banked }, /* TrackElemType::down25RightBanked */ { TrackElementFlag::down, TrackElementFlag::startsAtHalfHeight, TrackElementFlag::banked }, - /* TrackElemType::watersplash */ {}, + /* TrackElemType::waterSplash */ {}, /* TrackElemType::flatToUp60LongBase */ { TrackElementFlag::up }, /* TrackElemType::up60ToFlatLongBase */ { TrackElementFlag::up, TrackElementFlag::startsAtHalfHeight }, /* TrackElemType::whirlpool */ {}, @@ -2824,7 +2824,7 @@ namespace OpenRCT2::TrackMetaData { TrackGroup::onridePhoto, TrackPitch::none, TrackPitch::none, TrackRoll::none, TrackRoll::none, 0 }, // TrackElemType::onRidePhoto { TrackGroup::slopeRollBanking, TrackPitch::down25, TrackPitch::down25, TrackRoll::left, TrackRoll::left, 0 }, // TrackElemType::down25LeftBanked { TrackGroup::slopeRollBanking, TrackPitch::down25, TrackPitch::down25, TrackRoll::right, TrackRoll::right, 0 }, // TrackElemType::down25RightBanked - { TrackGroup::waterSplash, TrackPitch::none, TrackPitch::none, TrackRoll::none, TrackRoll::none, 0 }, // TrackElemType::watersplash + { TrackGroup::waterSplash, TrackPitch::none, TrackPitch::none, TrackRoll::none, TrackRoll::none, 0 }, // TrackElemType::waterSplash { TrackGroup::slopeSteepLong, TrackPitch::up60, TrackPitch::none, TrackRoll::none, TrackRoll::none, 0 }, // TrackElemType::flatToUp60LongBase { TrackGroup::slopeSteepLong, TrackPitch::none, TrackPitch::up60, TrackRoll::none, TrackRoll::none, 0 }, // TrackElemType::up60ToFlatLongBase { TrackGroup::whirlpool, TrackPitch::none, TrackPitch::none, TrackRoll::none, TrackRoll::none, 0 }, // TrackElemType::whirlpool @@ -3325,13 +3325,13 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::beginStation: case TrackElemType::middleStation: case TrackElemType::up25: - case TrackElemType::up60: // + case TrackElemType::up60: case TrackElemType::down25: - case TrackElemType::down60: // + case TrackElemType::down60: case TrackElemType::flatToLeftBank: case TrackElemType::flatToRightBank: case TrackElemType::leftBankToFlat: - case TrackElemType::rightBankToFlat: // + case TrackElemType::rightBankToFlat: case TrackElemType::leftBank: case TrackElemType::rightBank: case TrackElemType::towerBase: @@ -3391,8 +3391,8 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::leftQuarterTurn1TileDown90: case TrackElemType::rightQuarterTurn1TileDown90: return EvaluatorConst<0>; - case TrackElemType::flatToUp25: // - case TrackElemType::down25ToFlat: // + case TrackElemType::flatToUp25: + case TrackElemType::down25ToFlat: case TrackElemType::leftBankToUp25: case TrackElemType::rightBankToUp25: case TrackElemType::down25ToLeftBank: @@ -3436,8 +3436,8 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::diagDown25LeftBanked: case TrackElemType::diagDown25RightBanked: return EvaluatorConst<0>; - case TrackElemType::up25ToFlat: // - case TrackElemType::flatToDown25: // + case TrackElemType::up25ToFlat: + case TrackElemType::flatToDown25: case TrackElemType::up25ToLeftBank: case TrackElemType::up25ToRightBank: case TrackElemType::leftBankToDown25: @@ -3454,17 +3454,17 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::flatToLeftBankedDown25: case TrackElemType::flatToRightBankedDown25: return EvaluatorConst<0>; - case TrackElemType::up25ToUp60: // - case TrackElemType::down60ToDown25: // + case TrackElemType::up25ToUp60: + case TrackElemType::down60ToDown25: case TrackElemType::up25ToUp60Covered: case TrackElemType::down60ToDown25Covered: return EvaluatorConst<0>; - case TrackElemType::up60ToUp25: // - case TrackElemType::down25ToDown60: // + case TrackElemType::up60ToUp25: + case TrackElemType::down25ToDown60: case TrackElemType::up60ToUp25Covered: case TrackElemType::down25ToDown60Covered: return EvaluatorConst<0>; - case TrackElemType::leftQuarterTurn5Tiles: // + case TrackElemType::leftQuarterTurn5Tiles: case TrackElemType::leftQuarterTurn5TilesUp25: case TrackElemType::leftQuarterTurn5TilesDown25: case TrackElemType::leftTwistDownToUp: @@ -3476,7 +3476,7 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::leftFlyerTwistDown: case TrackElemType::leftHeartLineRoll: return EvaluatorConst<98>; - case TrackElemType::rightQuarterTurn5Tiles: // + case TrackElemType::rightQuarterTurn5Tiles: case TrackElemType::rightQuarterTurn5TilesUp25: case TrackElemType::rightQuarterTurn5TilesDown25: case TrackElemType::rightTwistDownToUp: @@ -3570,7 +3570,7 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::rightQuarterTurn1TileUp60: case TrackElemType::rightQuarterTurn1TileDown60: return EvaluatorConst<-88>; - case TrackElemType::watersplash: + case TrackElemType::waterSplash: return EvaluatorConst<0>; case TrackElemType::flatToUp60LongBase: case TrackElemType::down60ToFlatLongBase: @@ -3729,13 +3729,13 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::beginStation: case TrackElemType::middleStation: case TrackElemType::up25: - case TrackElemType::up60: // + case TrackElemType::up60: case TrackElemType::down25: - case TrackElemType::down60: // + case TrackElemType::down60: case TrackElemType::flatToLeftBank: case TrackElemType::flatToRightBank: case TrackElemType::leftBankToFlat: - case TrackElemType::rightBankToFlat: // + case TrackElemType::rightBankToFlat: case TrackElemType::leftBank: case TrackElemType::rightBank: case TrackElemType::towerBase: @@ -3815,8 +3815,8 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::diagDown25LeftBanked: case TrackElemType::diagDown25RightBanked: return EvaluatorConst<0>; - case TrackElemType::flatToUp25: // - case TrackElemType::down25ToFlat: // + case TrackElemType::flatToUp25: + case TrackElemType::down25ToFlat: case TrackElemType::leftBankToUp25: case TrackElemType::rightBankToUp25: case TrackElemType::down25ToLeftBank: @@ -3832,8 +3832,8 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::leftBankedDown25ToFlat: case TrackElemType::rightBankedDown25ToFlat: return EvaluatorConst<103>; - case TrackElemType::up25ToFlat: // - case TrackElemType::flatToDown25: // + case TrackElemType::up25ToFlat: + case TrackElemType::flatToDown25: case TrackElemType::up25ToLeftBank: case TrackElemType::up25ToRightBank: case TrackElemType::leftBankToDown25: @@ -3850,17 +3850,17 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::flatToLeftBankedDown25: case TrackElemType::flatToRightBankedDown25: return EvaluatorConst<-103>; - case TrackElemType::up25ToUp60: // - case TrackElemType::down60ToDown25: // + case TrackElemType::up25ToUp60: + case TrackElemType::down60ToDown25: case TrackElemType::up25ToUp60Covered: case TrackElemType::down60ToDown25Covered: return EvaluatorConst<82>; - case TrackElemType::up60ToUp25: // - case TrackElemType::down25ToDown60: // + case TrackElemType::up60ToUp25: + case TrackElemType::down25ToDown60: case TrackElemType::up60ToUp25Covered: case TrackElemType::down25ToDown60Covered: return EvaluatorConst<-82>; - case TrackElemType::leftQuarterTurn5Tiles: // + case TrackElemType::leftQuarterTurn5Tiles: case TrackElemType::leftQuarterTurn5TilesUp25: case TrackElemType::leftQuarterTurn5TilesDown25: case TrackElemType::leftTwistDownToUp: @@ -3872,7 +3872,7 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::leftFlyerTwistDown: case TrackElemType::leftHeartLineRoll: return EvaluatorConst<0>; - case TrackElemType::rightQuarterTurn5Tiles: // + case TrackElemType::rightQuarterTurn5Tiles: case TrackElemType::rightQuarterTurn5TilesUp25: case TrackElemType::rightQuarterTurn5TilesDown25: case TrackElemType::rightTwistDownToUp: @@ -3966,7 +3966,7 @@ namespace OpenRCT2::TrackMetaData case TrackElemType::rightQuarterTurn1TileUp60: case TrackElemType::rightQuarterTurn1TileDown60: return EvaluatorConst<0>; - case TrackElemType::watersplash: + case TrackElemType::waterSplash: return EvaluatorWaterSplash; case TrackElemType::flatToUp60LongBase: case TrackElemType::down60ToFlatLongBase: @@ -15389,7 +15389,7 @@ namespace OpenRCT2::TrackMetaData /* TrackElemType::onRidePhoto */ { 1, { kOnRidePhotoSeq0 } }, /* TrackElemType::down25LeftBanked */ { 1, { kDown25LeftBankedSeq0 } }, /* TrackElemType::down25RightBanked */ { 1, { kDown25RightBankedSeq0 } }, - /* TrackElemType::watersplash */ + /* TrackElemType::waterSplash */ { 5, { kWatersplashSeq0, kWatersplashSeq1, kWatersplashSeq2, kWatersplashSeq3, kWatersplashSeq4 } }, /* TrackElemType::flatToUp60LongBase */ { 4, { kFlatToUp60LongBaseSeq0, kFlatToUp60LongBaseSeq1, kFlatToUp60LongBaseSeq2, kFlatToUp60LongBaseSeq3 } }, diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index 54cc4becd6..063bedeecf 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -16,21 +16,22 @@ #include "../GameState.h" #include "../OpenRCT2.h" #include "../TrackImporter.h" -#include "../actions/FootpathLayoutPlaceAction.h" -#include "../actions/FootpathRemoveAction.h" -#include "../actions/LargeSceneryPlaceAction.h" -#include "../actions/LargeSceneryRemoveAction.h" -#include "../actions/MazePlaceTrackAction.h" +#include "../actions/GameActionRunner.h" #include "../actions/ResultWithMessage.h" -#include "../actions/RideCreateAction.h" -#include "../actions/RideDemolishAction.h" -#include "../actions/RideEntranceExitPlaceAction.h" -#include "../actions/SmallSceneryPlaceAction.h" -#include "../actions/SmallSceneryRemoveAction.h" -#include "../actions/TrackPlaceAction.h" -#include "../actions/TrackRemoveAction.h" -#include "../actions/WallPlaceAction.h" -#include "../actions/WallRemoveAction.h" +#include "../actions/footpath/FootpathLayoutPlaceAction.h" +#include "../actions/footpath/FootpathRemoveAction.h" +#include "../actions/ride/MazePlaceTrackAction.h" +#include "../actions/ride/RideCreateAction.h" +#include "../actions/ride/RideDemolishAction.h" +#include "../actions/ride/RideEntranceExitPlaceAction.h" +#include "../actions/scenery/LargeSceneryPlaceAction.h" +#include "../actions/scenery/LargeSceneryRemoveAction.h" +#include "../actions/scenery/SmallSceneryPlaceAction.h" +#include "../actions/scenery/SmallSceneryRemoveAction.h" +#include "../actions/scenery/WallPlaceAction.h" +#include "../actions/scenery/WallRemoveAction.h" +#include "../actions/track/TrackPlaceAction.h" +#include "../actions/track/TrackRemoveAction.h" #include "../audio/Audio.h" #include "../config/Config.h" #include "../core/DataSerialiser.h" @@ -53,6 +54,7 @@ #include "../object/ObjectRepository.h" #include "../object/SmallSceneryEntry.h" #include "../object/StationObject.h" +#include "../rct12/TD46.h" #include "../rct2/RCT2.h" #include "../ride/RideConstruction.h" #include "../sawyer_coding/SawyerCoding.h" @@ -192,8 +194,6 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; } - StringId warningMessage = kStringIdNone; - RideGetStartOfTrack(&trackElement); int32_t z = trackElement.element->GetBaseZ(); @@ -225,10 +225,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con { const auto& element = trackElement.element->AsTrack(); - // Remove this check for new track design format if (element->GetTrackType() > TrackElemType::highestAlias) { - return { false, STR_TRACK_ELEM_UNSUPPORTED_TD6 }; + version = RCT12::TD46Version::td7; } TrackDesignTrackElement track{}; @@ -238,18 +237,17 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con track.brakeBoosterSpeed = element->GetBrakeBoosterSpeed(); track.seatRotation = element->GetSeatRotation(); - // This warning will not apply to new track design format if (track.type == TrackElemType::blockBrakes && element->GetBrakeBoosterSpeed() != kRCT2DefaultBlockBrakeSpeed) { - warningMessage = STR_TRACK_DESIGN_BLOCK_BRAKE_SPEED_RESET; + version = RCT12::TD46Version::td7; } if (element->HasChain()) - track.SetFlag(TrackDesignTrackElementFlag::hasChain); + track.flags.set(TrackDesignTrackElementFlag::hasChain); - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasInvertedVariant) && element->IsInverted()) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::hasInvertedVariant) && element->IsInverted()) { - track.SetFlag(TrackDesignTrackElementFlag::isInverted); + track.flags.set(TrackDesignTrackElementFlag::isInverted); } trackElements.push_back(track); @@ -274,7 +272,7 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con if (trackElements.size() > RCT2::Limits::kTD6MaxTrackElements) { - return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; + version = RCT12::TD46Version::td7; } } while (trackElement.element != initialMap); @@ -355,7 +353,7 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con gMapSelectFlags.unset(MapSelectFlag::green); statistics.spaceRequired = TileCoordsXY(tds.previewMax - tds.previewMin) + TileCoordsXY{ 1, 1 }; - return { true, warningMessage }; + return { true, kStringIdNone }; } ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, const Ride& ride) @@ -394,9 +392,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons _saveDirection = tileElement->GetDirection(); mazeElements.push_back(maze); - if (mazeElements.size() >= 2000) + if (mazeElements.size() >= RCT2::Limits::kTD6MaxMazeElements) { - return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; + version = RCT12::TD46Version::td7; } } while (!(tileElement++)->IsLastForTile()); } @@ -501,6 +499,9 @@ CoordsXYE TrackDesign::MazeGetFirstElement(const Ride& ride) ResultWithMessage TrackDesign::CreateTrackDesignScenery(TrackDesignState& tds) { sceneryElements = _trackSavedTileElementsDesc; + if (sceneryElements.size() >= RCT2::Limits::kTD6MaxSceneryElements) + version = RCT12::TD46Version::td7; + // Run an element loop for (auto& scenery : sceneryElements) { @@ -1614,11 +1615,11 @@ static GameActions::Result TrackDesignPlaceRide( int16_t tempZ = newCoords.z - trackCoordinates->zBegin; SelectedLiftAndInverted liftHillAndAlternativeState{}; - if (track.HasFlag(TrackDesignTrackElementFlag::hasChain)) + if (track.flags.has(TrackDesignTrackElementFlag::hasChain)) { liftHillAndAlternativeState.set(LiftHillAndInverted::liftHill); } - if (track.HasFlag(TrackDesignTrackElementFlag::isInverted)) + if (track.flags.has(TrackDesignTrackElementFlag::isInverted)) { liftHillAndAlternativeState.set(LiftHillAndInverted::inverted); } @@ -1922,7 +1923,7 @@ static bool TrackDesignPlacePreview( // Flat rides need their vehicle colours loaded for display // in the preview window - if (!GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasTrack)) + if (!GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasTrack)) { for (size_t i = 0; i < std::size(ride->vehicleColours); i++) { @@ -2069,7 +2070,7 @@ bool TrackDesignSceneryElement::operator!=(const TrackDesignSceneryElement& rhs) * * rct2: 0x006D1EF0 */ -void TrackDesignDrawPreview(TrackDesign& td, uint8_t* pixels, bool placeScenery) +void TrackDesignDrawPreview(TrackDesign& td, TrackDesignPreviewBuffer& pixels, bool placeScenery) { StashMap(); TrackDesignPreviewClearMap(); @@ -2085,7 +2086,7 @@ void TrackDesignDrawPreview(TrackDesign& td, uint8_t* pixels, bool placeScenery) TrackDesignGameStateData updatedGameStateData = td.gameStateData; if (!TrackDesignPlacePreview(tds, td, &ride, updatedGameStateData, placeScenery)) { - std::fill_n(pixels, kTrackPreviewImageSize * 4, 0x00); + std::fill(std::begin(pixels), std::end(pixels), PaletteIndex::transparent); UnstashMap(); return; } @@ -2100,7 +2101,7 @@ void TrackDesignDrawPreview(TrackDesign& td, uint8_t* pixels, bool placeScenery) // Special case for flat rides - Z-axis info is irrelevant // and must be zeroed out lest the preview be off-centre - if (!GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).HasFlag(RtdFlag::hasTrack)) + if (!GetRideTypeDescriptor(td.trackAndVehicle.rtdIndex).flags.has(RtdFlag::hasTrack)) { centre.z = 0; size_z = 0; @@ -2138,7 +2139,7 @@ void TrackDesignDrawPreview(TrackDesign& td, uint8_t* pixels, bool placeScenery) rt.width = 370; rt.height = 217; rt.pitch = 0; - rt.bits = pixels; + rt.bits = pixels.data(); auto drawingEngine = std::make_unique(GetContext()->GetUiContext()); rt.DrawingEngine = drawingEngine.get(); @@ -2146,10 +2147,10 @@ void TrackDesignDrawPreview(TrackDesign& td, uint8_t* pixels, bool placeScenery) drawingEngine->BeginDraw(); const ScreenCoordsXY offset = { size_x / 2, size_y / 2 }; - for (uint8_t i = 0; i < 4; i++) + for (Direction direction = 0; direction < kNumOrthogonalDirections; direction++) { - view.viewPos = Translate3DTo2DWithZ(i, centre) - offset; - view.rotation = i; + view.viewPos = Translate3DTo2DWithZ(direction, centre) - offset; + view.rotation = direction; ViewportRender(rt, &view); rt.bits += kTrackPreviewImageSize; @@ -2212,3 +2213,21 @@ void TrackDesignGameStateData::setFlag(TrackDesignGameStateFlag flag, bool on) else flags &= ~EnumToFlag(flag); } + +u8string trackDesignGetExtension(RCT12::TD46Version version) +{ + switch (version) + { + case RCT12::TD46Version::td4: + case RCT12::TD46Version::td4AA: + return ".td4"; + case RCT12::TD46Version::td6: + return ".td6"; + case RCT12::TD46Version::td7: + return ".td7"; + case RCT12::TD46Version::unknown: + break; + } + + return ""; +} diff --git a/src/openrct2/ride/TrackDesign.h b/src/openrct2/ride/TrackDesign.h index 73837c2bb0..21caee9a5a 100644 --- a/src/openrct2/ride/TrackDesign.h +++ b/src/openrct2/ride/TrackDesign.h @@ -15,6 +15,7 @@ #include "../core/EnumUtils.hpp" #include "../drawing/Colour.h" #include "../object/Object.h" +#include "../rct12/TD46.h" #include "../ride/RideColour.h" #include "../ride/Track.h" #include "RideRatings.h" @@ -22,12 +23,21 @@ #include +namespace OpenRCT2::RCT12 +{ + enum class TD46Version : uint8_t; +} struct Ride; struct ResultWithMessage; enum class ViewportInteractionItem : uint8_t; constexpr uint32_t kTrackPreviewImageSize = 370 * 217; +namespace OpenRCT2::Drawing +{ + enum class PaletteIndex : uint8_t; +} + enum class TrackPlaceOperation : uint8_t { drawOutlines, @@ -95,34 +105,20 @@ struct TrackDesignSceneryElement enum class TrackDesignTrackElementFlag : uint8_t { - hasChain = (1 << 0), - isInverted = (1 << 1), - isCovered = (1 << 2), // Reserved + hasChain, + isInverted, + isCovered, // Reserved }; +using TrackDesignTrackElementFlags = FlagHolder; struct TrackDesignTrackElement { OpenRCT2::TrackElemType type = OpenRCT2::TrackElemType::flat; - uint8_t flags = 0; + TrackDesignTrackElementFlags flags = {}; uint8_t colourScheme = 0; ::StationIndex stationIndex = StationIndex::FromUnderlying(0); uint8_t brakeBoosterSpeed = 0; uint8_t seatRotation = 4; - - constexpr bool HasFlag(const TrackDesignTrackElementFlag flag) const - { - return flags & EnumValue(flag); - } - - constexpr void SetFlag(const TrackDesignTrackElementFlag flag) - { - flags |= EnumValue(flag); - } - - constexpr void ClearFlag(const TrackDesignTrackElementFlag flag) - { - flags &= ~EnumValue(flag); - } }; struct TrackDesignMazeElement @@ -214,6 +210,7 @@ struct TrackDesign std::vector sceneryElements; TrackDesignGameStateData gameStateData{}; + OpenRCT2::RCT12::TD46Version version = OpenRCT2::RCT12::TD46Version::td6; public: ResultWithMessage CreateTrackDesign(TrackDesignState& tds, const Ride& ride); @@ -249,7 +246,8 @@ int32_t TrackDesignGetZPlacement(const TrackDesign& td, Ride& ride, const Coords /////////////////////////////////////////////////////////////////////////////// // Track design preview /////////////////////////////////////////////////////////////////////////////// -void TrackDesignDrawPreview(TrackDesign& td, uint8_t* pixels, bool placeScenery); +using TrackDesignPreviewBuffer = std::array; +void TrackDesignDrawPreview(TrackDesign& td, TrackDesignPreviewBuffer& pixels, bool placeScenery); /////////////////////////////////////////////////////////////////////////////// // Track design saving @@ -264,4 +262,5 @@ void TrackDesignSaveSelectTileElement( bool TrackDesignAreEntranceAndExitPlaced(); extern std::vector _trackSavedTileElementsDesc; -extern std::vector _trackSavedTileElements; + +u8string trackDesignGetExtension(OpenRCT2::RCT12::TD46Version version); diff --git a/src/openrct2/ride/TrackDesignRepository.cpp b/src/openrct2/ride/TrackDesignRepository.cpp index 95d79f730e..2123fcce42 100644 --- a/src/openrct2/ride/TrackDesignRepository.cpp +++ b/src/openrct2/ride/TrackDesignRepository.cpp @@ -57,7 +57,7 @@ class TrackDesignFileIndex final : public FileIndex private: static constexpr uint32_t kMagicNumber = 0x58444954; // TIDX static constexpr uint16_t kVersion = 5; - static constexpr auto kPattern = "*.td4;*.td6"; + static constexpr auto kPattern = "*.td4;*.td6;*.td7"; public: explicit TrackDesignFileIndex(const IPlatformEnvironment& env) @@ -150,7 +150,7 @@ public: { const ObjectRepositoryItem* ori = repo.FindObjectLegacy(item.ObjectEntry.c_str()); - if (ori == nullptr || !GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::listVehiclesSeparately)) + if (ori == nullptr || !GetRideTypeDescriptor(rideType).flags.has(RtdFlag::listVehiclesSeparately)) entryIsNotSeparate = true; } @@ -184,7 +184,7 @@ public: { const ObjectRepositoryItem* ori = repo.FindObjectLegacy(item.ObjectEntry.c_str()); - if (ori == nullptr || !GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::listVehiclesSeparately)) + if (ori == nullptr || !GetRideTypeDescriptor(rideType).flags.has(RtdFlag::listVehiclesSeparately)) entryIsNotSeparate = true; } diff --git a/src/openrct2/ride/TrackDesignSave.cpp b/src/openrct2/ride/TrackDesignSave.cpp index 4b4b432411..34877ae0c0 100644 --- a/src/openrct2/ride/TrackDesignSave.cpp +++ b/src/openrct2/ride/TrackDesignSave.cpp @@ -46,13 +46,12 @@ using namespace OpenRCT2; -constexpr size_t TRACK_MAX_SAVED_TILE_ELEMENTS = 1500; constexpr int32_t TRACK_NEARBY_SCENERY_DISTANCE = 1; bool gTrackDesignSaveMode = false; RideId gTrackDesignSaveRideIndex = RideId::GetNull(); -std::vector _trackSavedTileElements; +static std::vector _trackSavedTileElements; std::vector _trackSavedTileElementsDesc; struct TrackDesignAddStatus @@ -181,14 +180,6 @@ static bool TrackDesignSaveCanAddTileElement(TileElement* tileElement) return false; } - // Get number of spare elements left - size_t spareSavedElements = TRACK_MAX_SAVED_TILE_ELEMENTS - _trackSavedTileElements.size(); - if (newElementCount > spareSavedElements) - { - // No more spare saved elements left - return false; - } - return true; } @@ -198,11 +189,8 @@ static bool TrackDesignSaveCanAddTileElement(TileElement* tileElement) */ static void TrackDesignSavePushTileElement(const CoordsXY& loc, TileElement* tileElement) { - if (_trackSavedTileElements.size() < TRACK_MAX_SAVED_TILE_ELEMENTS) - { - _trackSavedTileElements.push_back(tileElement); - MapInvalidateTileFull(loc); - } + _trackSavedTileElements.push_back(tileElement); + MapInvalidateTileFull(loc); } static bool TrackDesignSaveIsSupportedObject(const Object* obj) diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index 4147ae1a49..d1f1bbc34c 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -23,6 +23,7 @@ #include "../paint/support/MetalSupports.h" #include "../paint/support/WoodenSupports.h" #include "../paint/tile_element/Paint.TileElement.h" +#include "../paint/tile_element/Paint.Track.h" #include "../paint/tile_element/Segment.h" #include "../paint/track/Segment.h" #include "../paint/track/Support.h" @@ -84,17 +85,6 @@ static constexpr uint32_t trackSpritesGhostTrainSpinningTunnel[2][2][4] = { }, }; -enum -{ - SPR_STATION_COVER_OFFSET_NE_SW_BACK_0 = 0, - SPR_STATION_COVER_OFFSET_NE_SW_BACK_1, - SPR_STATION_COVER_OFFSET_NE_SW_FRONT, - SPR_STATION_COVER_OFFSET_SE_NW_BACK_0, - SPR_STATION_COVER_OFFSET_SE_NW_BACK_1, - SPR_STATION_COVER_OFFSET_SE_NW_FRONT, - SPR_STATION_COVER_OFFSET_TALL -}; - bool TrackPaintUtilHasFence( enum edge_t edge, const CoordsXY& position, const TrackElement& trackElement, const Ride& ride, uint8_t rotation) { @@ -669,8 +659,8 @@ bool TrackPaintUtilDrawStationCovers2( return false; } - auto baseImageIndex = stationObject->ShelterImageId; - if (baseImageIndex == kImageIndexUndefined) + auto shelterImageIndex = stationObject->shelterIndex; + if (shelterImageIndex == kImageIndexUndefined) return false; static constexpr int16_t heights[][2] = { @@ -707,10 +697,10 @@ bool TrackPaintUtilDrawStationCovers2( imageOffset += SPR_STATION_COVER_OFFSET_TALL; } - auto imageId = session.TrackColours.WithIndex(baseImageIndex + imageOffset); + auto imageId = session.TrackColours.WithIndex(shelterImageIndex + imageOffset); if (!session.TrackColours.IsRemap()) { - imageId = ImageId(baseImageIndex + imageOffset); + imageId = ImageId(shelterImageIndex + imageOffset); if (stationObject->Flags & StationObjectFlags::hasPrimaryColour) imageId = imageId.WithPrimary(session.TrackColours.GetPrimary()); if (stationObject->Flags & StationObjectFlags::hasSecondaryColour) @@ -722,7 +712,8 @@ bool TrackPaintUtilDrawStationCovers2( // Glass if (colour == TrackStationColour && (stationObject->Flags & StationObjectFlags::isTransparent)) { - imageId = ImageId(baseImageIndex + imageOffset + 12).WithTransparency(session.TrackColours.GetPrimary()); + auto shelterGlassImageIndex = stationObject->shelterGlassIndex; + imageId = ImageId(shelterGlassImageIndex + imageOffset).WithTransparency(session.TrackColours.GetPrimary()); PaintAddImageAsChild(session, imageId, offset, boundBox); } return true; @@ -736,6 +727,7 @@ bool TrackPaintUtilDrawNarrowStationPlatform( const auto* stationObj = ride.getStationObject(); if (stationObj != nullptr && stationObj->Flags & StationObjectFlags::noPlatforms) return false; + auto colour = GetStationColourScheme(session, trackElement); if (direction & 1) { @@ -2011,7 +2003,7 @@ void PaintTrack(PaintSession& session, Direction direction, int32_t height, cons const auto* originElement = ride->getOriginElement(StationIndex::FromUnderlying(0)); if (originElement != nullptr && originElement->GetTrackType() == TrackElemType::flatTrack1x1B) LightFx::AddKioskLights(session.MapPosition, height, zOffset); - else if (kRideTypeDescriptors[ride->type].HasFlag(RtdFlag::isShopOrFacility)) + else if (kRideTypeDescriptors[ride->type].flags.has(RtdFlag::isShopOrFacility)) LightFx::AddShopLights(session.MapPosition, trackElement.GetDirection(), height, zOffset); } @@ -2033,7 +2025,7 @@ void PaintTrack(PaintSession& session, Direction direction, int32_t height, cons } const auto& rtd = GetRideTypeDescriptor(trackElement.GetRideType()); - bool isInverted = trackElement.IsInverted() && rtd.HasFlag(RtdFlag::hasInvertedVariant); + bool isInverted = trackElement.IsInverted() && rtd.flags.has(RtdFlag::hasInvertedVariant); const auto trackDrawerEntry = getTrackDrawerEntry(rtd, isInverted, TrackElementIsCovered(trackType)); trackType = UncoverTrackElement(trackType); diff --git a/src/openrct2/ride/Vehicle.Animation.cpp b/src/openrct2/ride/Vehicle.Animation.cpp new file mode 100644 index 0000000000..94e4afecdf --- /dev/null +++ b/src/openrct2/ride/Vehicle.Animation.cpp @@ -0,0 +1,1104 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../GameState.h" +#include "../audio/Audio.h" +#include "../entity/Particle.h" +#include "../entity/Yaw.hpp" +#include "../math/Trigonometry.hpp" +#include "../world/Map.h" +#include "../world/tile_element/TileElement.h" +#include "../world/tile_element/TrackElement.h" +#include "Ride.h" +#include "RideData.h" +#include "RideEntry.h" +#include "Track.h" +#include "TrackData.h" +#include "VehicleData.h" + +#include + +using namespace OpenRCT2; +using namespace OpenRCT2::Audio; +using namespace OpenRCT2::TrackMetaData; + +constexpr int16_t kVehicleMaxSpinSpeed = 1536; +constexpr int16_t kVehicleMinSpinSpeed = -kVehicleMaxSpinSpeed; + +/** + * + * rct2: 0x006D9249 + */ +void Vehicle::UpdateSwinging() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + auto rideEntry = GetRideEntry(); + if (rideEntry == nullptr) + return; + + // SubState for this ride means swinging state + // 0 == first swing + // 3 == full swing + uint8_t swingState = sub_state; + if (rideEntry->flags.has(RideEntryFlag::inverterShipSwingMode)) + { + swingState += 4; + if (rideEntry->flags.has(RideEntryFlag::magicCarpetSwingMode)) + swingState += 4; + } + + const auto spriteMap = kSwingingTimeToSpriteMaps[swingState]; + int8_t spriteType = spriteMap[current_time + 1]; + + // 0x80 indicates that a complete swing has been + // completed and the next swing can start + if (spriteType != -128) + { + current_time++; + if (static_cast(spriteType) != flatRideAnimationFrame) + { + // Used to know which sprite to draw + flatRideAnimationFrame = static_cast(spriteType); + Invalidate(); + } + return; + } + + current_time = -1; + NumSwings++; + if (curRide->status != RideStatus::closed) + { + // It takes 3 swings to get into full swing + // ride->rotations already takes this into account + if (NumSwings + 3 < curRide->rotations) + { + // Go to the next swing state until we + // are at full swing. + if (sub_state != 3) + { + sub_state++; + } + UpdateSwinging(); + return; + } + } + + // To get to this part of the code the + // swing has to be in slowing down phase + if (sub_state == 0) + { + SetState(Status::arriving); + var_C0 = 0; + return; + } + // Go towards first swing state + sub_state--; + UpdateSwinging(); +} + +/** + * + * rct2: 0x006D9413 + */ +void Vehicle::UpdateFerrisWheelRotating() +{ + if (_vehicleBreakdown == 0) + return; + + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if ((ferris_wheel_var_1 -= 1) != 0) + return; + + int8_t curFerrisWheelVar0 = ferris_wheel_var_0; + + if (curFerrisWheelVar0 == 3) + { + ferris_wheel_var_0 = curFerrisWheelVar0; + ferris_wheel_var_1 = curFerrisWheelVar0; + } + else if (curFerrisWheelVar0 < 3) + { + if (curFerrisWheelVar0 != -8) + curFerrisWheelVar0--; + ferris_wheel_var_0 = curFerrisWheelVar0; + ferris_wheel_var_1 = -curFerrisWheelVar0; + } + else + { + curFerrisWheelVar0--; + ferris_wheel_var_0 = curFerrisWheelVar0; + ferris_wheel_var_1 = curFerrisWheelVar0; + } + + uint8_t rotation = flatRideAnimationFrame; + if (curRide->mode == RideMode::forwardRotation) + rotation++; + else + rotation--; + + rotation &= 0x7F; + flatRideAnimationFrame = rotation; + + if (rotation == sub_state) + NumRotations++; + + Invalidate(); + + uint8_t subState = sub_state; + if (curRide->mode == RideMode::forwardRotation) + subState++; + else + subState--; + subState &= 0x7F; + + if (subState == flatRideAnimationFrame) + { + bool shouldStop = true; + if (curRide->status != RideStatus::closed) + { + if (NumRotations < curRide->rotations) + shouldStop = false; + } + + if (shouldStop) + { + curFerrisWheelVar0 = ferris_wheel_var_0; + ferris_wheel_var_0 = -abs(curFerrisWheelVar0); + ferris_wheel_var_1 = abs(curFerrisWheelVar0); + } + } + + if (ferris_wheel_var_0 != -8) + return; + + subState = sub_state; + if (curRide->mode == RideMode::forwardRotation) + subState += 8; + else + subState -= 8; + subState &= 0x7F; + + if (subState != flatRideAnimationFrame) + return; + + SetState(Status::arriving); + var_C0 = 0; +} + +/** + * + * rct2: 0x006D94F2 + */ +void Vehicle::UpdateSimulatorOperating() +{ + if (_vehicleBreakdown == 0) + return; + + assert(current_time >= -1); + assert(current_time < MotionSimulatorTimeToSpriteMapCount); + uint8_t al = MotionSimulatorTimeToSpriteMap[current_time + 1]; + if (al != 0xFF) + { + current_time++; + if (al == flatRideAnimationFrame) + return; + flatRideAnimationFrame = al; + Invalidate(); + return; + } + + SetState(Status::arriving); + var_C0 = 0; +} + +void UpdateRotatingDefault(Vehicle& vehicle) +{ + vehicle.sub_state = 1; + vehicle.UpdateRotating(); +} + +void UpdateRotatingEnterprise(Vehicle& vehicle) +{ + if (vehicle.sub_state == 2) + { + vehicle.SetState(Vehicle::Status::arriving); + vehicle.var_C0 = 0; + return; + } + + UpdateRotatingDefault(vehicle); +} + +/** + * + * rct2: 0x006D92FF + */ +void Vehicle::UpdateRotating() +{ + if (_vehicleBreakdown == 0) + return; + + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + auto rideEntry = GetRideEntry(); + if (rideEntry == nullptr) + { + return; + } + + const uint8_t* timeToSpriteMap; + if (rideEntry->flags.has(RideEntryFlag::hasTwistRotationType)) + { + timeToSpriteMap = kTwistTimeToSpriteMaps[sub_state]; + } + else if (rideEntry->flags.has(RideEntryFlag::hasEnterpriseRotationType)) + { + timeToSpriteMap = kEnterpriseTimeToSpriteMaps[sub_state]; + } + else + { + timeToSpriteMap = kMerryGoRoundTimeToSpriteMaps[sub_state]; + } + + uint16_t time = current_time; + if (_vehicleBreakdown == BREAKDOWN_CONTROL_FAILURE) + { + time += (curRide->breakdownSoundModifier >> 6) + 1; + } + time++; + + uint8_t sprite = timeToSpriteMap[time]; + if (sprite != 0xFF) + { + current_time = time; + if (sprite == flatRideAnimationFrame) + return; + flatRideAnimationFrame = sprite; + Invalidate(); + return; + } + + current_time = -1; + NumRotations++; + if (_vehicleBreakdown != BREAKDOWN_CONTROL_FAILURE) + { + bool shouldStop = true; + if (curRide->status != RideStatus::closed) + { + sprite = NumRotations + 1; + if (curRide->getRideTypeDescriptor().specialType == RtdSpecialType::enterprise) + sprite += 9; + + if (sprite < curRide->rotations) + shouldStop = false; + } + + if (shouldStop) + { + if (sub_state == 2) + { + SetState(Status::arriving); + var_C0 = 0; + return; + } + sub_state++; + UpdateRotating(); + return; + } + } + + const auto& rtd = GetRideTypeDescriptor(curRide->type); + rtd.UpdateRotating(*this); +} + +/** + * + * rct2: 0x006D97CB + */ +void Vehicle::UpdateSpaceRingsOperating() +{ + if (_vehicleBreakdown == 0) + return; + + uint8_t spriteType = kSpaceRingsTimeToSpriteMap[current_time + 1]; + if (spriteType != 255) + { + current_time++; + if (spriteType != flatRideAnimationFrame) + { + flatRideAnimationFrame = spriteType; + Invalidate(); + } + } + else + { + SetState(Status::arriving); + var_C0 = 0; + } +} + +/** + * + * rct2: 0x006D9641 + */ +void Vehicle::UpdateHauntedHouseOperating() +{ + if (_vehicleBreakdown == 0) + return; + + if (flatRideAnimationFrame != 0) + { + if (getGameState().currentTicks & 1) + { + flatRideAnimationFrame++; + Invalidate(); + + if (flatRideAnimationFrame == 19) + flatRideAnimationFrame = 0; + } + } + + if (current_time + 1 > 1500) + { + SetState(Status::arriving); + var_C0 = 0; + return; + } + + current_time++; + switch (current_time) + { + case 45: + Play3D(SoundId::hauntedHouseScare, GetLocation()); + break; + case 75: + flatRideAnimationFrame = 1; + Invalidate(); + break; + case 400: + Play3D(SoundId::hauntedHouseScream1, GetLocation()); + break; + case 745: + Play3D(SoundId::hauntedHouseScare, GetLocation()); + break; + case 775: + flatRideAnimationFrame = 1; + Invalidate(); + break; + case 1100: + Play3D(SoundId::hauntedHouseScream2, GetLocation()); + break; + } +} + +/** + * + * rct2: 0x006d9781 + */ +void Vehicle::UpdateCrookedHouseOperating() +{ + if (_vehicleBreakdown == 0) + return; + + // Originally used an array of size 1 at 0x009A0AC4 and passed the sub state into it. + if (static_cast(current_time + 1) > 600) + { + SetState(Status::arriving); + var_C0 = 0; + return; + } + + current_time++; +} + +/** + * + * rct2: 0x006D9547 + */ +void Vehicle::UpdateTopSpinOperating() +{ + if (_vehicleBreakdown == 0) + return; + + const TopSpinTimeToSpriteMap* sprite_map = kTopSpinTimeToSpriteMaps[sub_state]; + uint8_t rotation = sprite_map[current_time + 1].arm_rotation; + if (rotation != 0xFF) + { + current_time = current_time + 1; + if (rotation != flatRideAnimationFrame) + { + flatRideAnimationFrame = rotation; + Invalidate(); + } + rotation = sprite_map[current_time].bank_rotation; + if (rotation != flatRideSecondaryAnimationFrame) + { + flatRideSecondaryAnimationFrame = rotation; + Invalidate(); + } + return; + } + + SetState(Status::arriving); + var_C0 = 0; +} + +/** + * + * rct2: 0x006D95AD + */ +void Vehicle::UpdateShowingFilm() +{ + if (_vehicleBreakdown == 0) + return; + + int32_t totalTime = kRideFilmLength[sub_state]; + int32_t currentTime = current_time + 1; + if (currentTime <= totalTime) + { + current_time = currentTime; + } + else + { + SetState(Status::arriving); + var_C0 = 0; + } +} + +/** + * + * rct2: 0x006D95F7 + */ +void Vehicle::UpdateDoingCircusShow() +{ + if (_vehicleBreakdown == 0) + return; + + int32_t currentTime = current_time + 1; + if (currentTime <= 5000) + { + current_time = currentTime; + } + else + { + SetState(Status::arriving); + var_C0 = 0; + } +} + +int32_t Vehicle::GetSwingAmount() const +{ + switch (GetTrackType()) + { + case TrackElemType::leftQuarterTurn5Tiles: + case TrackElemType::bankedLeftQuarterTurn5Tiles: + case TrackElemType::leftQuarterTurn5TilesUp25: + case TrackElemType::leftQuarterTurn5TilesDown25: + case TrackElemType::leftQuarterTurn5TilesCovered: + case TrackElemType::leftHalfBankedHelixUpLarge: + case TrackElemType::leftHalfBankedHelixDownLarge: + case TrackElemType::leftQuarterBankedHelixLargeUp: + case TrackElemType::leftQuarterBankedHelixLargeDown: + case TrackElemType::leftQuarterHelixLargeUp: + case TrackElemType::leftQuarterHelixLargeDown: + case TrackElemType::leftBankedQuarterTurn5TileUp25: + case TrackElemType::leftBankedQuarterTurn5TileDown25: + // Loc6D67E1 + return 14; + + case TrackElemType::rightQuarterTurn5Tiles: + case TrackElemType::bankedRightQuarterTurn5Tiles: + case TrackElemType::rightQuarterTurn5TilesUp25: + case TrackElemType::rightQuarterTurn5TilesDown25: + case TrackElemType::rightQuarterTurn5TilesCovered: + case TrackElemType::rightHalfBankedHelixUpLarge: + case TrackElemType::rightHalfBankedHelixDownLarge: + case TrackElemType::rightQuarterBankedHelixLargeUp: + case TrackElemType::rightQuarterBankedHelixLargeDown: + case TrackElemType::rightQuarterHelixLargeUp: + case TrackElemType::rightQuarterHelixLargeDown: + case TrackElemType::rightBankedQuarterTurn5TileUp25: + case TrackElemType::rightBankedQuarterTurn5TileDown25: + // Loc6D6804 + return -14; + + case TrackElemType::sBendLeft: + case TrackElemType::sBendLeftCovered: + // Loc6D67EF + if (track_progress < 48) + { + return 14; + } + return -15; + + case TrackElemType::sBendRight: + case TrackElemType::sBendRightCovered: + // Loc6D67CC + if (track_progress < 48) + { + return -14; + } + return 15; + + case TrackElemType::leftQuarterTurn3Tiles: + case TrackElemType::leftBankedQuarterTurn3Tiles: + case TrackElemType::leftQuarterTurn3TilesUp25: + case TrackElemType::leftQuarterTurn3TilesDown25: + case TrackElemType::leftQuarterTurn3TilesCovered: + case TrackElemType::leftHalfBankedHelixUpSmall: + case TrackElemType::leftHalfBankedHelixDownSmall: + case TrackElemType::leftBankToLeftQuarterTurn3TilesUp25: + case TrackElemType::leftQuarterTurn3TilesDown25ToLeftBank: + case TrackElemType::leftCurvedLiftHill: + case TrackElemType::leftBankedQuarterTurn3TileUp25: + case TrackElemType::leftBankedQuarterTurn3TileDown25: + // Loc6D67BE + return 13; + + case TrackElemType::rightQuarterTurn3Tiles: + case TrackElemType::rightBankedQuarterTurn3Tiles: + case TrackElemType::rightQuarterTurn3TilesUp25: + case TrackElemType::rightQuarterTurn3TilesDown25: + case TrackElemType::rightQuarterTurn3TilesCovered: + case TrackElemType::rightHalfBankedHelixUpSmall: + case TrackElemType::rightHalfBankedHelixDownSmall: + case TrackElemType::rightBankToRightQuarterTurn3TilesUp25: + case TrackElemType::rightQuarterTurn3TilesDown25ToRightBank: + case TrackElemType::rightCurvedLiftHill: + case TrackElemType::rightBankedQuarterTurn3TileUp25: + case TrackElemType::rightBankedQuarterTurn3TileDown25: + // Loc6D67B0 + return -13; + + case TrackElemType::leftQuarterTurn1Tile: + case TrackElemType::leftQuarterTurn1TileUp60: + case TrackElemType::leftQuarterTurn1TileDown60: + // Loc6D67A2 + return 12; + + case TrackElemType::rightQuarterTurn1Tile: + case TrackElemType::rightQuarterTurn1TileUp60: + case TrackElemType::rightQuarterTurn1TileDown60: + // Loc6D6794 + return -12; + + case TrackElemType::leftEighthToDiag: + case TrackElemType::leftEighthToOrthogonal: + case TrackElemType::leftEighthBankToDiag: + case TrackElemType::leftEighthBankToOrthogonal: + // Loc6D67D3 + return 15; + + case TrackElemType::rightEighthToDiag: + case TrackElemType::rightEighthToOrthogonal: + case TrackElemType::rightEighthBankToDiag: + case TrackElemType::rightEighthBankToOrthogonal: + // Loc6D67F6 + return -15; + default: + return 0; + } +} + +static uint8_t GetSwingSprite(int16_t swingPosition) +{ + if (swingPosition < -10010) + return 11; + if (swingPosition > 10010) + return 12; + + if (swingPosition < -8190) + return 9; + if (swingPosition > 8190) + return 10; + + if (swingPosition < -6370) + return 7; + if (swingPosition > 6370) + return 8; + + if (swingPosition < -4550) + return 5; + if (swingPosition > 4550) + return 6; + + if (swingPosition < -2730) + return 3; + if (swingPosition > 2730) + return 4; + + if (swingPosition < -910) + return 1; + if (swingPosition > 910) + return 2; + + return 0; +} + +/** + * + * rct2: 0x006D6776 + */ +void Vehicle::UpdateSwingingCar() +{ + int32_t dword_F64E08 = abs(_vehicleVelocityF64E08); + if (flags.has(VehicleFlag::carIsReversed)) + { + dword_F64E08 *= -1; + } + SwingSpeed += (-SwingPosition) >> 6; + int32_t swingAmount = GetSwingAmount(); + if (swingAmount < 0) + { + SwingSpeed -= dword_F64E08 >> (-swingAmount); + } + else if (swingAmount > 0) + { + SwingSpeed += dword_F64E08 >> swingAmount; + } + + auto carEntry = Entry(); + if (carEntry == nullptr) + { + return; + } + int16_t dx = 3185; + if (carEntry->flags.has(CarEntryFlag::useSuspendedSwing)) + { + dx = 5006; + } + if (carEntry->flags.has(CarEntryFlag::useWoodenWildMouseSwing)) + { + dx = 1820; + } + int16_t cx = -dx; + + if (carEntry->flags.has(CarEntryFlag::useSlideSwing)) + { + dx = 5370; + cx = -5370; + + auto trackType = GetTrackType(); + switch (trackType) + { + case TrackElemType::bankedLeftQuarterTurn5Tiles: + case TrackElemType::leftBank: + case TrackElemType::leftBankedQuarterTurn3Tiles: + dx = 10831; + cx = -819; + break; + case TrackElemType::bankedRightQuarterTurn5Tiles: + case TrackElemType::rightBank: + case TrackElemType::rightBankedQuarterTurn3Tiles: + dx = 819; + cx = -10831; + break; + default: + break; + } + + if (TrackTypeIsStation(trackType) || TrackTypeIsBrakes(trackType) || TrackTypeIsBlockBrakes(trackType)) + { + dx = 0; + cx = 0; + } + + if (flags.has(VehicleFlag::onLiftHill)) + { + dx = 0; + cx = 0; + } + } + + SwingPosition += SwingSpeed; + SwingSpeed -= SwingSpeed >> 5; + + if (SwingPosition > dx) + { + SwingPosition = dx; + SwingSpeed = 0; + } + if (SwingPosition < cx) + { + SwingPosition = cx; + SwingSpeed = 0; + } + + uint8_t swingSprite = GetSwingSprite(SwingPosition); + + if (swingSprite != SwingSprite) + { + SwingSprite = swingSprite; + Invalidate(); + } +} + +/** + * + * rct2: 0x006D661F + */ +void Vehicle::UpdateSpinningCar() +{ + if (flags.has(VehicleFlag::spinningIsLocked)) + { + spin_speed = 0; + return; + } + + auto carEntry = Entry(); + if (carEntry == nullptr) + { + return; + } + int32_t spinningInertia = carEntry->spinning_inertia; + auto trackType = GetTrackType(); + int32_t dword_F64E08 = _vehicleVelocityF64E08; + int32_t spinSpeed{}; + // An L spin adds to the spin speed, R does the opposite + // The number indicates how much right shift of the velocity will become spin + // The bigger the number the less change in spin. + + const auto& ted = GetTrackElementDescriptor(trackType); + switch (ted.spinFunction) + { + case SpinFunction::RC: + // On a rotation control track element + spinningInertia += 6; + spinSpeed = dword_F64E08 >> spinningInertia; + // Alternate the spin direction (roughly). Perhaps in future save a value to the track + if (Id.ToUnderlying() & 1) + { + spin_speed -= spinSpeed; + } + else + { + spin_speed += spinSpeed; + } + break; + case SpinFunction::R5: + // It looks like in the original there was going to be special code for whirlpool + // this has been removed and just uses R5 + spinningInertia += 5; + spin_speed -= dword_F64E08 >> spinningInertia; + break; + case SpinFunction::L5: + spinningInertia += 5; + spin_speed += dword_F64E08 >> spinningInertia; + break; + case SpinFunction::R7: + spinningInertia += 7; + spin_speed -= dword_F64E08 >> spinningInertia; + break; + case SpinFunction::L7: + spinningInertia += 7; + spin_speed += dword_F64E08 >> spinningInertia; + break; + case SpinFunction::RL: + // Right Left Curve Track Piece + if (track_progress < 48) + { + // R8 + spinningInertia += 8; + spin_speed -= dword_F64E08 >> spinningInertia; + break; + } + [[fallthrough]]; + case SpinFunction::L9: + spinningInertia += 9; + spin_speed += dword_F64E08 >> spinningInertia; + break; + case SpinFunction::L8: + spinningInertia += 8; + spin_speed += dword_F64E08 >> spinningInertia; + break; + case SpinFunction::SP: + // On rapids spin after fully on them + if (track_progress > 22) + { + // L5 + spinningInertia += 5; + spin_speed += dword_F64E08 >> spinningInertia; + } + break; + case SpinFunction::LR: + // Left Right Curve Track Piece + if (track_progress < 48) + { + // L8 + spinningInertia += 8; + spin_speed += dword_F64E08 >> spinningInertia; + break; + } + [[fallthrough]]; + case SpinFunction::R9: + spinningInertia += 9; + spin_speed -= dword_F64E08 >> spinningInertia; + break; + case SpinFunction::R8: + spinningInertia += 8; + spin_speed -= dword_F64E08 >> spinningInertia; + break; + case SpinFunction::None: + break; + } + + spinSpeed = std::clamp(spin_speed, kVehicleMinSpinSpeed, kVehicleMaxSpinSpeed); + spin_speed = spinSpeed; + spin_sprite += spinSpeed >> 8; + // Note this actually increases the spin speed if going right! + spin_speed -= spinSpeed >> carEntry->spinning_friction; + Invalidate(); +} + +void Vehicle::UpdateAnimationAnimalFlying() +{ + if (animationState > 0) + { + animationState--; + return; + } + + if (animation_frame == 0) + { + auto trackType = GetTrackType(); + TileElement* trackElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); + if (trackElement != nullptr && trackElement->AsTrack()->HasChain()) + { + // start flapping, bird + animation_frame = 1; + animationState = 5; + Invalidate(); + } + } + else + { + // continue flapping until reaching frame 0 + animation_frame = (animation_frame + 1) % 4; + Invalidate(); + } + // number of frames to skip before updating again + constexpr std::array frameWaitTimes = { 5, 3, 5, 3 }; + animationState = frameWaitTimes[animation_frame]; +} + +/** + * Get the frame of animation for the current animationState based on animation speed and animation frames + */ +static uint8_t GetTargetFrame(const CarEntry& carEntry, uint32_t animationState) +{ + if (carEntry.AnimationSpeed == 0) + return 0; + auto targetFrame = animationState / (carEntry.AnimationSpeed << 2); + // mask of 0xFF + targetFrame &= std::numeric_limits::max(); + // multiply by number of frames. After the bitshift 8, the range will be 0 to AnimationFrames - 1 + targetFrame *= carEntry.AnimationFrames; + return targetFrame >> std::numeric_limits::digits; +} + +/** + * Compute the position that steam should be spawned + */ +static constexpr CoordsXYZ ComputeSteamOffset(int32_t height, int32_t length, VehiclePitch pitch, uint8_t yaw) +{ + uint8_t trueYaw = Entity::Yaw::YawTo64(yaw); + auto offsets = Math::Trigonometry::PitchToDirectionVectorFromGeometry[EnumValue(pitch)]; + int32_t projectedRun = (offsets.x * length - offsets.y * height) / 256; + int32_t projectedHeight = (offsets.x * height + offsets.y * length) / 256; + return { Math::Trigonometry::ComputeXYVector(projectedRun, trueYaw), projectedHeight }; +} + +/** + * Decide based on current frame and number of frames if a steam particle should be generated on this frame + */ +static bool ShouldMakeSteam(uint8_t targetFrame, uint8_t animationFrames) +{ + if (animationFrames < 1) + return false; + // steam is produced twice per wheel revolution + return targetFrame == 0 || targetFrame == animationFrames / 2; +} + +/** + * Dummy function + */ +static void AnimateNone(Vehicle& vehicle, const CarEntry& carEntry) +{ + return; +} + +/** + * Animate the vehicle based on its speed + */ +static void AnimateSimpleVehicle(Vehicle& vehicle, const CarEntry& carEntry) +{ + vehicle.animationState += _vehicleVelocityF64E08; + uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState); + if (vehicle.animation_frame != targetFrame) + { + vehicle.animation_frame = targetFrame; + vehicle.Invalidate(); + } +} + +/** + * Animate the vehicle based on its speed plus add steam particles + */ +static void AnimateSteamLocomotive(Vehicle& vehicle, const CarEntry& carEntry) +{ + vehicle.animationState += _vehicleVelocityF64E08; + uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState); + if (vehicle.animation_frame != targetFrame) + { + vehicle.animation_frame = targetFrame; + if (ShouldMakeSteam(targetFrame, carEntry.AnimationFrames)) + { + auto curRide = vehicle.GetRide(); + if (curRide != nullptr) + { + if (!RideHasStationShelter(*curRide) + || (vehicle.status != Vehicle::Status::movingToEndOfStation && vehicle.status != Vehicle::Status::arriving)) + { + CoordsXYZ steamOffset = ComputeSteamOffset( + carEntry.SteamEffect.Vertical, carEntry.SteamEffect.Longitudinal, vehicle.pitch, vehicle.Orientation); + SteamParticle::Create(CoordsXYZ(vehicle.x, vehicle.y, vehicle.z) + steamOffset); + } + } + } + vehicle.Invalidate(); + } +} + +/** + * Animate the vehicle based on its speed. Specialized animation with exactly 2 frames due to how peep animation works. + */ +static void AnimateSwanBoat(Vehicle& vehicle, const CarEntry& carEntry) +{ + // The animation of swan boats places frames at 0 and 2 instead of 0 and 1 like Water Tricycles due to the second + // pair of peeps. The animation technically uses 4 frames, but ignores frames 1 and 3. + vehicle.animationState += _vehicleVelocityF64E08; + uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState) * 2; + if (vehicle.animation_frame != targetFrame) + { + vehicle.animation_frame = targetFrame; + vehicle.Invalidate(); + } +} + +/** + * Monorail Cycle animation only animates when a peep is present + */ +static void AnimateMonorailCycle(Vehicle& vehicle, const CarEntry& carEntry) +{ + if (vehicle.num_peeps != 0) + { + AnimateSimpleVehicle(vehicle, carEntry); + } +} + +/** + * Observation tower animates at a constant speed continuously + */ +static void AnimateObservationTower(Vehicle& vehicle, const CarEntry& carEntry) +{ + if (vehicle.animationState <= 0xCCCC) + { + vehicle.animationState += carEntry.AnimationSpeed; + } + else + { + vehicle.animationState = 0; + vehicle.animation_frame += 1; + vehicle.animation_frame %= carEntry.AnimationFrames; + vehicle.Invalidate(); + } +} +/** + * seatRotation value of 4 translates to animationFrame value of 0. This function makes that true for any number of animation + * frames + */ +static int16_t MultiDimensionTargetAngle(int16_t seatRotation, int16_t animationFrames) +{ + return ((seatRotation - 4) % animationFrames + animationFrames) % animationFrames; +} + +/** + * Multidimension targets a specific animation frame based on track + */ +static void AnimateMultiDimension(Vehicle& vehicle, const CarEntry& carEntry) +{ + if (vehicle.seat_rotation != vehicle.target_seat_rotation) + { + if (vehicle.animationState <= 0xCCCC) + { + vehicle.animationState += carEntry.AnimationSpeed; + } + else + { + vehicle.animationState = 0; + + if (vehicle.seat_rotation >= vehicle.target_seat_rotation) + vehicle.seat_rotation--; + else + vehicle.seat_rotation++; + + int16_t targetSeatRotation = MultiDimensionTargetAngle(vehicle.seat_rotation, carEntry.AnimationFrames); + if (targetSeatRotation != vehicle.animation_frame) + { + vehicle.animation_frame = targetSeatRotation; + vehicle.Invalidate(); + } + } + } +} + +/** + * Animal Flying animates only on chainlift and in an unusual way. Made by Spacek531 + */ +static void AnimateAnimalFlying(Vehicle& vehicle, const CarEntry& carEntry) +{ + vehicle.UpdateAnimationAnimalFlying(); + // makes animation play faster with vehicle speed + uint8_t targetFrame = abs(_vehicleVelocityF64E08) >> carEntry.AnimationSpeed; + vehicle.animationState = std::max(vehicle.animationState - targetFrame, 0u); +} + +using AnimateFunction = void (*)(Vehicle& vehicle, const CarEntry& carEntry); + +constexpr static const AnimateFunction AnimationFunctions[]{ + AnimateNone, AnimateSimpleVehicle, AnimateSteamLocomotive, AnimateSwanBoat, + AnimateMonorailCycle, AnimateMultiDimension, AnimateObservationTower, AnimateAnimalFlying, +}; +static_assert(std::size(AnimationFunctions) == EnumValue(CarEntryAnimation::Count)); + +/** + * + * rct2: 0x006D63D4 + */ +void Vehicle::UpdateAdditionalAnimation() +{ + auto carEntry = Entry(); + if (carEntry == nullptr) + { + return; + } + if (carEntry->AnimationFrames == 0 || carEntry->animation >= CarEntryAnimation::Count) + return; + AnimationFunctions[EnumValue(carEntry->animation)](*this, *carEntry); +} diff --git a/src/openrct2/ride/Vehicle.BoatHire.cpp b/src/openrct2/ride/Vehicle.BoatHire.cpp new file mode 100644 index 0000000000..f84b186692 --- /dev/null +++ b/src/openrct2/ride/Vehicle.BoatHire.cpp @@ -0,0 +1,489 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../scenario/Scenario.h" +#include "../world/Map.h" +#include "../world/tile_element/SurfaceElement.h" +#include "../world/tile_element/TileElement.h" +#include "../world/tile_element/TrackElement.h" +#include "Ride.h" +#include "VehicleGeometry.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::RideVehicle; + +static bool vehicle_boat_is_location_accessible(const CoordsXYZ& location); + +void Vehicle::UpdateTravellingBoatHireSetup() +{ + var_34 = Orientation; + TrackLocation.x = x; + TrackLocation.y = y; + TrackLocation = TrackLocation.ToTileStart(); + + CoordsXY location = CoordsXY(TrackLocation) + CoordsDirectionDelta[Orientation >> 3]; + + BoatLocation = location; + var_35 = 0; + // No longer on a track so reset to 0 for import/export + SetTrackDirection(0); + SetTrackType(TrackElemType::flat); + SetState(Status::travellingBoat); + remaining_distance += 27924; + + UpdateTravellingBoat(); +} + +/** + * + * rct2: 0x006D982F + */ +void Vehicle::UpdateDepartingBoatHire() +{ + lost_time_out = 0; + + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + auto& station = curRide->getStation(current_station); + station.Depart &= kStationDepartFlag; + uint8_t waitingTime = std::max(curRide->minWaitingTime, static_cast(3)); + waitingTime = std::min(waitingTime, static_cast(127)); + station.Depart |= waitingTime; + UpdateTravellingBoatHireSetup(); +} + +/** + * + * rct2: 0x006D845B + */ +void Vehicle::UpdateTravellingBoat() +{ + CheckIfMissing(); + UpdateMotionBoatHire(); +} + +void Vehicle::TryReconnectBoatToTrack(const CoordsXY& currentBoatLocation, const CoordsXY& trackCoords) +{ + remaining_distance = 0; + if (!UpdateMotionCollisionDetection({ currentBoatLocation, z }, nullptr)) + { + TrackLocation.x = trackCoords.x; + TrackLocation.y = trackCoords.y; + + auto curRide = GetRide(); + if (curRide != nullptr) + { + auto trackElement = MapGetTrackElementAt(TrackLocation); + if (trackElement != nullptr) + SetTrackType(trackElement->GetTrackType()); + + SetTrackDirection(curRide->boatHireReturnDirection); + BoatLocation.SetNull(); + } + + track_progress = 0; + SetState(Status::travelling, sub_state); + _vehicleCurPosition.x = currentBoatLocation.x; + _vehicleCurPosition.y = currentBoatLocation.y; + } +} + +/** + * + * rct2: 0x006DA717 + */ +void Vehicle::UpdateMotionBoatHire() +{ + _vehicleMotionTrackFlags = 0; + velocity += acceleration; + _vehicleVelocityF64E08 = velocity; + _vehicleVelocityF64E0C = (velocity >> 10) * 42; + + auto carEntry = Entry(); + if (carEntry == nullptr) + { + return; + } + if (carEntry->flags.hasAny(CarEntryFlag::hasVehicleAnimation, CarEntryFlag::hasRiderAnimation)) + { + UpdateAdditionalAnimation(); + } + + _vehicleUnkF64E10 = 1; + acceleration = 0; + remaining_distance += _vehicleVelocityF64E0C; + if (remaining_distance >= 0x368A) + { + sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; + _vehicleCurPosition = GetLocation(); + Invalidate(); + + for (;;) + { + // Loc6DA7A5 + var_35++; + auto loc = BoatLocation.ToTileCentre(); + CoordsXY loc2 = loc; + uint8_t bl; + + loc2.x -= x; + if (loc2.x >= 0) + { + loc2.y -= y; + if (loc2.y < 0) + { + // Loc6DA81A: + loc2.y = -loc2.y; + bl = 24; + if (loc2.y <= loc2.x * 4) + { + bl = 16; + if (loc2.x <= loc2.y * 4) + { + bl = 20; + } + } + } + else + { + bl = 8; + if (loc2.y <= loc2.x * 4) + { + bl = 16; + if (loc2.x <= loc2.y * 4) + { + bl = 12; + } + } + } + } + else + { + loc2.y -= y; + if (loc2.y < 0) + { + // Loc6DA83D: + loc2.x = -loc2.x; + loc2.y = -loc2.y; + bl = 24; + if (loc2.y <= loc2.x * 4) + { + bl = 0; + if (loc2.x <= loc2.y * 4) + { + bl = 28; + } + } + } + else + { + loc2.x = -loc2.x; + bl = 8; + if (loc2.y <= loc2.x * 4) + { + bl = 0; + if (loc2.x <= loc2.y * 4) + { + bl = 4; + } + } + } + } + + // Loc6DA861: + var_34 = bl; + loc2.x += loc2.y; + if (loc2.x <= 12) + { + UpdateBoatLocation(); + } + + if (!(var_35 & (1 << 0))) + { + uint8_t spriteDirection = Orientation; + if (spriteDirection != var_34) + { + uint8_t dl = (var_34 + 16 - spriteDirection) & 0x1E; + if (dl >= 16) + { + spriteDirection += 2; + if (dl > 24) + { + var_35--; + } + } + else + { + spriteDirection -= 2; + if (dl < 8) + { + var_35--; + } + } + + Orientation = spriteDirection & 0x1E; + } + } + + int32_t edi = (Orientation | (var_35 & 1)) & 0x1F; + loc2 = { x + Geometry::getFreeroamVehicleMovementData(edi).x, y + Geometry::getFreeroamVehicleMovementData(edi).y }; + if (UpdateMotionCollisionDetection({ loc2, z }, nullptr)) + { + remaining_distance = 0; + if (Orientation == var_34) + { + Orientation ^= (1 << 4); + UpdateBoatLocation(); + Orientation ^= (1 << 4); + } + break; + } + + auto flooredLocation = loc2.ToTileStart(); + if (flooredLocation != TrackLocation) + { + if (!vehicle_boat_is_location_accessible({ loc2, TrackLocation.z })) + { + // Loc6DA939: + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + bool do_Loc6DAA97 = false; + if (sub_state != BoatHireSubState::EnteringReturnPosition) + { + do_Loc6DAA97 = true; + } + else + { + auto flooredTileLoc = TileCoordsXY(flooredLocation); + if (curRide->boatHireReturnPosition != flooredTileLoc) + { + do_Loc6DAA97 = true; + } + } + + // Loc6DAA97: + if (do_Loc6DAA97) + { + remaining_distance = 0; + if (Orientation == var_34) + { + UpdateBoatLocation(); + } + break; + } + + if (!(curRide->boatHireReturnDirection & 1)) + { + uint16_t tilePart = loc2.y % kCoordsXYStep; + if (tilePart == kCoordsXYHalfTile) + { + TryReconnectBoatToTrack(loc2, flooredLocation); + break; + } + loc2 = _vehicleCurPosition; + if (tilePart <= kCoordsXYHalfTile) + { + loc2.y += 1; + } + else + { + loc2.y -= 1; + } + } + else + { + // Loc6DA9A2: + uint16_t tilePart = loc2.x % kCoordsXYStep; + if (tilePart == kCoordsXYHalfTile) + { + TryReconnectBoatToTrack(loc2, flooredLocation); + break; + } + loc2 = _vehicleCurPosition; + if (tilePart <= kCoordsXYHalfTile) + { + loc2.x += 1; + } + else + { + loc2.x -= 1; + } + } + + // Loc6DA9D1: + remaining_distance = 0; + if (!UpdateMotionCollisionDetection({ loc2, z }, nullptr)) + { + _vehicleCurPosition.x = loc2.x; + _vehicleCurPosition.y = loc2.y; + } + break; + } + TrackLocation = { flooredLocation, TrackLocation.z }; + } + + remaining_distance -= Geometry::getFreeroamVehicleMovementData(edi).distance; + _vehicleCurPosition.x = loc2.x; + _vehicleCurPosition.y = loc2.y; + if (remaining_distance < 0x368A) + { + break; + } + _vehicleUnkF64E10++; + } + + MoveTo(_vehicleCurPosition); + } + + // Loc6DAAC9: + { + int32_t edx = velocity >> 8; + edx = (edx * edx); + if (velocity < 0) + { + edx = -edx; + } + edx >>= 5; + + // Hack to fix people messing with boat hire + int32_t curMass = mass == 0 ? 1 : mass; + + int32_t eax = ((velocity >> 1) + edx) / curMass; + int32_t newAcceleration = -eax; + if (carEntry->flags.has(CarEntryFlag::isPowered)) + { + eax = speed << 14; + int32_t ebx = (speed * curMass) >> 2; + if (flags.has(VehicleFlag::poweredCarInReverse)) + { + eax = -eax; + } + eax -= velocity; + edx = powered_acceleration * 2; + if (ebx != 0) + { + newAcceleration += (eax * edx) / ebx; + } + } + acceleration = newAcceleration; + } + // eax = _vehicleMotionTrackFlags; + // ebx = _vehicleStationIndex; +} + +/** + * + * rct2: 0x006DA280 + */ +void Vehicle::UpdateBoatLocation() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + TileCoordsXY returnPosition = curRide->boatHireReturnPosition; + uint8_t returnDirection = curRide->boatHireReturnDirection & 3; + + CoordsXY location = CoordsXY{ x, y } + CoordsDirectionDelta[returnDirection]; + + if (location.ToTileStart() == returnPosition.ToCoordsXY()) + { + sub_state = BoatHireSubState::EnteringReturnPosition; + BoatLocation = location.ToTileStart(); + return; + } + + sub_state = BoatHireSubState::Normal; + uint8_t curDirection = ((Orientation + 19) >> 3) & 3; + uint8_t randDirection = ScenarioRand() & 3; + + if (lost_time_out > 1920) + { + if (ScenarioRand() & 1) + { + CoordsXY destLocation = (returnPosition.ToCoordsXY() - CoordsDirectionDelta[returnDirection]).ToTileCentre(); + + destLocation.x -= x; + destLocation.y -= y; + + if (abs(destLocation.x) <= abs(destLocation.y)) + { + randDirection = destLocation.y < 0 ? 3 : 1; + } + else + { + randDirection = destLocation.x < 0 ? 0 : 2; + } + } + } + + static constexpr int8_t rotations[] = { 0, 1, -1, 2 }; + for (auto rotation : rotations) + { + if (randDirection + rotation == curDirection) + { + continue; + } + + auto trackLocation = TrackLocation; + trackLocation += CoordsDirectionDelta[(randDirection + rotation) & 3]; + + if (!vehicle_boat_is_location_accessible(trackLocation)) + { + continue; + } + + BoatLocation = trackLocation.ToTileStart(); + return; + } + + CoordsXY trackLocation = TrackLocation; + trackLocation += CoordsDirectionDelta[curDirection & 3]; + BoatLocation = trackLocation.ToTileStart(); +} + +/** + * + * rct2: 0x006DA22A + */ +static bool vehicle_boat_is_location_accessible(const CoordsXYZ& location) +{ + TileElement* tileElement = MapGetFirstElementAt(location); + if (tileElement == nullptr) + return false; + do + { + if (tileElement->IsGhost()) + continue; + + if (tileElement->GetType() == TileElementType::Surface) + { + int32_t waterZ = tileElement->AsSurface()->GetWaterHeight(); + if (location.z != waterZ) + { + return false; + } + } + else + { + if (location.z > (tileElement->GetBaseZ() - (2 * kCoordsZStep)) + && location.z < tileElement->GetClearanceZ() + (2 * kCoordsZStep)) + { + return false; + } + } + } while (!(tileElement++)->IsLastForTile()); + return true; +} diff --git a/src/openrct2/ride/Vehicle.Collision.cpp b/src/openrct2/ride/Vehicle.Collision.cpp new file mode 100644 index 0000000000..e39cf0444b --- /dev/null +++ b/src/openrct2/ride/Vehicle.Collision.cpp @@ -0,0 +1,276 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../GameState.h" +#include "../entity/EntityList.h" +#include "../entity/EntityRegistry.h" +#include "../entity/Yaw.hpp" +#include "../math/Trigonometry.hpp" + +using namespace OpenRCT2; + +/** rct2: 0x009A37C4 */ +static constexpr CoordsXY kSurroundingTiles[] = { + { 0, 0 }, + { 0, +kCoordsXYStep }, + { +kCoordsXYStep, 0 }, + { 0, -kCoordsXYStep }, + { 0, -kCoordsXYStep }, + { -kCoordsXYStep, 0 }, + { -kCoordsXYStep, 0 }, + { 0, +kCoordsXYStep }, + { 0, +kCoordsXYStep }, +}; + +/** + * + * rct2: 0x006DB807 + */ +void Vehicle::UpdateReverserCarBogies() +{ + const auto moveInfo = GetMoveInfo(); + MoveTo({ TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, z }); +} + +/** + * Collision Detection + * rct2: 0x006DD078 + * @param vehicle (esi) + * @param x (ax) + * @param y (cx) + * @param z (dx) + * @param otherVehicleIndex (bp) + */ +bool Vehicle::UpdateMotionCollisionDetection(const CoordsXYZ& loc, EntityId* otherVehicleIndex) +{ + if (flags.has(VehicleFlag::collisionDisabled)) + return false; + + auto carEntry = Entry(); + if (carEntry == nullptr) + { + return false; + } + + if (!carEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) + { + CollisionDetectionTimer = 0; + + // If hacking boat hire rides you can end up here + if (otherVehicleIndex == nullptr) + return false; + + Vehicle* collideVehicle = getGameState().entities.GetEntity(*otherVehicleIndex); + if (collideVehicle == nullptr) + return false; + + if (this == collideVehicle) + return false; + + int32_t x_diff = abs(loc.x - collideVehicle->x); + if (x_diff > 0x7FFF) + return false; + + int32_t y_diff = abs(loc.y - collideVehicle->y); + if (y_diff > 0x7FFF) + return false; + + int32_t z_diff = abs(loc.z - collideVehicle->z); + if (x_diff + y_diff + z_diff > 0xFFFF) + return false; + + uint16_t ecx = std::min(var_44 + collideVehicle->var_44, 560); + ecx = ((ecx >> 1) * 30) >> 8; + + if (x_diff + y_diff + z_diff >= ecx) + return false; + + uint8_t direction = (Orientation - collideVehicle->Orientation + 7) & 0x1F; + return direction < 0xF; + } + + CoordsXY location = loc; + + bool mayCollide = false; + Vehicle* collideVehicle = nullptr; + for (auto xy_offset : kSurroundingTiles) + { + location += xy_offset; + + for (auto vehicle2 : EntityTileList(location)) + { + if (vehicle2 == this) + continue; + + int32_t z_diff = abs(vehicle2->z - loc.z); + + if (z_diff > 16) + continue; + + if (vehicle2->IsCableLift()) + continue; + + auto collideCarEntry = vehicle2->Entry(); + if (collideCarEntry == nullptr) + continue; + + if (!collideCarEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) + continue; + + uint32_t x_diff = abs(vehicle2->x - loc.x); + if (x_diff > 0x7FFF) + continue; + + uint32_t y_diff = abs(vehicle2->y - loc.y); + if (y_diff > 0x7FFF) + continue; + + VehicleTrackSubposition cl = std::min(TrackSubposition, vehicle2->TrackSubposition); + VehicleTrackSubposition ch = std::max(TrackSubposition, vehicle2->TrackSubposition); + if (cl != ch) + { + if (cl == VehicleTrackSubposition::GoKartsLeftLane && ch == VehicleTrackSubposition::GoKartsRightLane) + continue; + } + + uint32_t ecx = var_44 + vehicle2->var_44; + ecx = ((ecx >> 1) * 30) >> 8; + + if (x_diff + y_diff >= ecx) + continue; + + if (!collideCarEntry->flags.has(CarEntryFlag::isGoKart)) + { + collideVehicle = vehicle2; + mayCollide = true; + break; + } + + uint8_t direction = (Orientation - vehicle2->Orientation - 6) & 0x1F; + + if (direction < 0x14) + continue; + + const CoordsXY directionVector = Math::Trigonometry::YawToDirectionVector[Entity::Yaw::YawTo64(Orientation)]; + + const CoordsXY directionVectorToVehicle2 = { vehicle2->x - loc.x, vehicle2->y - loc.y }; + const int32_t directionVectorToVehicle2Length = (directionVectorToVehicle2.x * directionVectorToVehicle2.x) + + (directionVectorToVehicle2.y * directionVectorToVehicle2.y); + + const int32_t dotProduct = (directionVector.x * directionVectorToVehicle2.x) + + (directionVector.y * directionVectorToVehicle2.y); + + static constexpr int32_t threshold = []() consteval { + const constexpr float originalThreshold = 0.35f; + const constexpr float directionVectorLength = 256.0f; + const constexpr float thresholdLength = originalThreshold * directionVectorLength; + return static_cast(thresholdLength * thresholdLength); + }(); + static_assert(threshold == 8028); + + if (dotProduct > 0 && dotProduct * dotProduct > threshold * directionVectorToVehicle2Length) + { + collideVehicle = vehicle2; + mayCollide = true; + break; + } + } + if (mayCollide) + { + break; + } + } + + if (!mayCollide || collideVehicle == nullptr) + { + CollisionDetectionTimer = 0; + return false; + } + + if (collideVehicle->status == Status::travellingBoat && sub_state == BoatHireSubState::EnteringReturnPosition) + { + return false; + } + + CollisionDetectionTimer++; + if (CollisionDetectionTimer < 200) + { + flags.set(VehicleFlag::currentlyColliding); + if (otherVehicleIndex != nullptr) + *otherVehicleIndex = collideVehicle->Id; + return true; + } + + if (status == Status::movingToEndOfStation) + { + if (Orientation == 0) + { + if (x <= collideVehicle->x) + { + return false; + } + } + else if (Orientation == 8) + { + if (y >= collideVehicle->y) + { + return false; + } + } + else if (Orientation == 16) + { + if (x >= collideVehicle->x) + { + return false; + } + } + else if (Orientation == 24) + { + if (y <= collideVehicle->y) + { + return false; + } + } + } + + if ((collideVehicle->status == Status::travellingBoat) && (status != Status::arriving) && (status != Status::travelling)) + { + return false; + } + + flags.set(VehicleFlag::currentlyColliding); + if (otherVehicleIndex != nullptr) + *otherVehicleIndex = collideVehicle->Id; + return true; +} + +/** + * + * rct2: 0x006DB7D6 + */ +void Vehicle::ReverseReverserCar() +{ + Vehicle* previousVehicle = getGameState().entities.GetEntity(prev_vehicle_on_ride); + Vehicle* nextVehicle = getGameState().entities.GetEntity(next_vehicle_on_ride); + if (previousVehicle == nullptr || nextVehicle == nullptr) + { + return; + } + + track_progress = 168; + vehicle_type ^= 1; + + previousVehicle->track_progress = 86; + nextVehicle->track_progress = 158; + + nextVehicle->UpdateReverserCarBogies(); + previousVehicle->UpdateReverserCarBogies(); +} diff --git a/src/openrct2/ride/Vehicle.Crash.cpp b/src/openrct2/ride/Vehicle.Crash.cpp new file mode 100644 index 0000000000..257668f3c5 --- /dev/null +++ b/src/openrct2/ride/Vehicle.Crash.cpp @@ -0,0 +1,586 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../Context.h" +#include "../Diagnostic.h" +#include "../GameState.h" +#include "../actions/GameActionRunner.h" +#include "../actions/ride/RideSetStatusAction.h" +#include "../audio/Audio.h" +#include "../config/Config.h" +#include "../entity/EntityRegistry.h" +#include "../entity/Guest.h" +#include "../entity/Particle.h" +#include "../entity/Peep.h" +#include "../localisation/Formatter.h" +#include "../management/NewsItem.h" +#include "../scenario/Scenario.h" +#include "../scripting/HookEngine.h" +#include "../scripting/ScriptEngine.h" +#include "../windows/Intent.h" +#include "../world/Map.h" +#include "../world/tile_element/TileElement.h" +#include "Ride.h" +#include "VehicleGeometry.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::Audio; +using namespace OpenRCT2::RideVehicle; + +#ifdef ENABLE_SCRIPTING +/** + * Fires the "vehicle.crash" api hook + * @param vehicleId Entity id of the vehicle that just crashed + * @param crashId What the vehicle crashed into. Should be either "another_vehicle", "land", or "water" + */ +static void InvokeVehicleCrashHook(const EntityId vehicleId, const std::string_view crashId) +{ + auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); + if (hookEngine.HasSubscriptions(Scripting::HookType::vehicleCrash)) + { + auto ctx = GetContext()->GetScriptEngine().GetContext(); + + // Create event args object + auto obj = Scripting::DukObject(ctx); + obj.Set("id", vehicleId.ToUnderlying()); + obj.Set("crashIntoType", crashId); + + // Call the subscriptions + auto e = obj.Take(); + hookEngine.Call(Scripting::HookType::vehicleCrash, e, true); + } +} +#endif + +void Vehicle::SimulateCrash() const +{ + auto curRide = GetRide(); + if (curRide != nullptr) + { + curRide->flags.set(RideFlag::crashed); + } +} + +/** + * Setup function for a vehicle colliding with + * another vehicle. + * + * rct2: 0x006DA059 + */ +void Vehicle::UpdateCollisionSetup() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if (curRide->status == RideStatus::simulating) + { + SimulateCrash(); + return; + } + + SetState(Status::crashed, sub_state); + + if (!curRide->flags.has(RideFlag::crashed)) + { + auto frontVehicle = GetHead(); + auto trainIndex = ride_get_train_index_from_vehicle(*curRide, frontVehicle->Id); + if (!trainIndex.has_value()) + { + return; + } + + curRide->crash(trainIndex.value()); + + if (curRide->status != RideStatus::closed) + { + // We require this to execute right away during the simulation, always ignore network and queue. + auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); + GameActions::ExecuteNested(&gameAction, getGameState()); + } + } + + curRide->flags.set(RideFlag::crashed); + curRide->windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); + KillAllPassengersInTrain(); + + Vehicle* lastVehicle = this; + for (Vehicle* train = getGameState().entities.GetEntity(Id); train != nullptr; + train = getGameState().entities.GetEntity(train->next_vehicle_on_train)) + { + lastVehicle = train; + + train->sub_state = 2; + +#ifdef ENABLE_SCRIPTING + InvokeVehicleCrashHook(train->Id, "another_vehicle"); +#endif + const auto trainLoc = train->GetLocation(); + + Play3D(SoundId::crash, trainLoc); + + ExplosionCloud::Create(trainLoc); + + for (int32_t i = 0; i < 10; i++) + { + VehicleCrashParticle::Create(train->colours, trainLoc); + } + + train->flags.set(VehicleFlag::crashed); + train->animationState = ScenarioRand() & 0xFFFF; + + train->animation_frame = ScenarioRand() & 0x7; + train->SpriteData.Width = 13; + train->SpriteData.HeightMin = 45; + train->SpriteData.HeightMax = 5; + + train->MoveTo(trainLoc); + + train->SwingSpeed = 0; + } + + // Remove the current train from the ride linked list of trains + auto prevTrain = getGameState().entities.GetEntity(prev_vehicle_on_ride); + auto nextTrain = getGameState().entities.GetEntity(lastVehicle->next_vehicle_on_ride); + if (prevTrain == nullptr || nextTrain == nullptr) + { + LOG_ERROR("Corrupted vehicle list for ride!"); + } + else + { + prevTrain->next_vehicle_on_ride = lastVehicle->next_vehicle_on_ride; + nextTrain->prev_vehicle_on_ride = prev_vehicle_on_ride; + } + + velocity = 0; +} + +/** + * + * rct2: 0x006D9EFE + */ +void Vehicle::UpdateCrashSetup() +{ + auto curRide = GetRide(); + if (curRide != nullptr && curRide->status == RideStatus::simulating) + { + SimulateCrash(); + return; + } + SetState(Status::crashing, sub_state); + + if (NumPeepsUntilTrainTail() != 0) + { + Play3D(SoundId::hauntedHouseScream2, GetLocation()); + } + + int32_t edx = velocity >> 10; + + Vehicle* lastVehicle = this; + auto spriteId = Id; + for (Vehicle* trainVehicle; !spriteId.IsNull(); spriteId = trainVehicle->next_vehicle_on_train) + { + trainVehicle = getGameState().entities.GetEntity(spriteId); + if (trainVehicle == nullptr) + { + break; + } + lastVehicle = trainVehicle; + + trainVehicle->sub_state = 0; + auto crashDirection = Geometry::getCrashDirectionComponents(trainVehicle->Orientation); + int32_t trainX = crashDirection.x; + int32_t trainY = crashDirection.y; + + auto carLaunchDirection = Geometry::getPitchVector32(trainVehicle->pitch); + + auto trainZ = carLaunchDirection.y >> 23; + int32_t ecx = carLaunchDirection.x >> 15; + trainX *= ecx; + trainY *= ecx; + trainX >>= 16; + trainY >>= 16; + trainX *= edx; + trainY *= edx; + trainZ *= edx; + trainX >>= 8; + trainY >>= 8; + trainZ >>= 8; + + trainVehicle->crash_x = trainX; + trainVehicle->crash_y = trainY; + trainVehicle->crash_z = trainZ; + trainVehicle->crash_x += (ScenarioRand() & 0xF) - 8; + trainVehicle->crash_y += (ScenarioRand() & 0xF) - 8; + trainVehicle->crash_z += (ScenarioRand() & 0xF) - 8; + + trainVehicle->TrackLocation = { 0, 0, 0 }; + } + + // Remove the current train from the ride linked list of trains + auto prevTrain = getGameState().entities.GetEntity(prev_vehicle_on_ride); + auto nextTrain = getGameState().entities.GetEntity(lastVehicle->next_vehicle_on_ride); + if (prevTrain == nullptr || nextTrain == nullptr) + { + LOG_ERROR("Corrupted vehicle list for ride!"); + } + else + { + prevTrain->next_vehicle_on_ride = lastVehicle->next_vehicle_on_ride; + nextTrain->prev_vehicle_on_ride = prev_vehicle_on_ride; + } + velocity = 0; +} + +/** + * + * rct2: 0x0068B8BD + * @returns the map element that the vehicle will collide with or NULL if no collisions. + */ +static TileElement* vehicle_check_collision(const CoordsXYZ& vehiclePosition) +{ + TileElement* tileElement = MapGetFirstElementAt(vehiclePosition); + if (tileElement == nullptr) + { + return nullptr; + } + + uint8_t quadrant; + if ((vehiclePosition.x & 0x1F) >= 16) + { + quadrant = 1; + if ((vehiclePosition.y & 0x1F) < 16) + quadrant = 2; + } + else + { + quadrant = 4; + if ((vehiclePosition.y & 0x1F) >= 16) + quadrant = 8; + } + + do + { + if (vehiclePosition.z < tileElement->GetBaseZ()) + continue; + + if (vehiclePosition.z >= tileElement->GetClearanceZ()) + continue; + + if (tileElement->GetOccupiedQuadrants() & quadrant) + return tileElement; + } while (!(tileElement++)->IsLastForTile()); + + return nullptr; +} + +static void ride_train_crash(Ride& ride, uint16_t numFatalities) +{ + Formatter ft; + ft.Add(numFatalities); + + uint8_t crashType = numFatalities == 0 ? RIDE_CRASH_TYPE_NO_FATALITIES : RIDE_CRASH_TYPE_FATALITIES; + + if (crashType >= ride.lastCrashType) + ride.lastCrashType = crashType; + + if (numFatalities != 0) + { + if (Config::Get().notifications.rideCasualties) + { + ride.formatNameTo(ft); + News::AddItemToQueue( + News::ItemType::ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, + ride.id.ToUnderlying(), ft); + } + + // TODO: get park id from ride/vehicle + auto& park = getGameState().park; + if (park.ratingCasualtyPenalty < 500) + { + park.ratingCasualtyPenalty += 200; + } + } +} +/** + * + * rct2: 0x006DE6C6 + */ +void Vehicle::KillAllPassengersInTrain() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + ride_train_crash(*curRide, NumPeepsUntilTrainTail()); + + for (Vehicle* trainCar = getGameState().entities.GetEntity(Id); trainCar != nullptr; + trainCar = getGameState().entities.GetEntity(trainCar->next_vehicle_on_train)) + { + trainCar->KillPassengers(*curRide); + } +} + +void Vehicle::KillPassengers(const Ride& curRide) +{ + if (num_peeps != next_free_seat) + return; + + if (num_peeps == 0) + return; + + for (auto i = 0; i < num_peeps; i++) + { + auto* curPeep = getGameState().entities.GetEntity(peep[i]); + if (curPeep == nullptr) + continue; + + if (!curPeep->OutsideOfPark) + { + DecrementGuestsInPark(); + auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); + ContextBroadcastIntent(&intent); + } + PeepEntityRemove(curPeep); + } + + num_peeps = 0; + next_free_seat = 0; +} + +void Vehicle::CrashOnLand() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if (curRide->status == RideStatus::simulating) + { + SimulateCrash(); + return; + } + SetState(Status::crashed, sub_state); + +#ifdef ENABLE_SCRIPTING + InvokeVehicleCrashHook(Id, "land"); +#endif + + if (!curRide->flags.has(RideFlag::crashed)) + { + auto frontVehicle = GetHead(); + auto trainIndex = ride_get_train_index_from_vehicle(*curRide, frontVehicle->Id); + if (!trainIndex.has_value()) + { + return; + } + + curRide->crash(trainIndex.value()); + + if (curRide->status != RideStatus::closed) + { + // We require this to execute right away during the simulation, always ignore network and queue. + auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); + GameActions::ExecuteNested(&gameAction, getGameState()); + } + } + curRide->flags.set(RideFlag::crashed); + curRide->windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); + + if (IsHead()) + { + KillAllPassengersInTrain(); + } + + sub_state = 2; + + const auto curLoc = GetLocation(); + Play3D(SoundId::crash, curLoc); + + ExplosionCloud::Create(curLoc); + ExplosionFlare::Create(curLoc); + + uint8_t numParticles = std::min(SpriteData.Width, static_cast(7)); + + while (numParticles-- != 0) + VehicleCrashParticle::Create(colours, curLoc); + + flags.set(VehicleFlag::crashed); + animation_frame = 0; + animationState = 0; + SpriteData.Width = 13; + SpriteData.HeightMin = 45; + SpriteData.HeightMax = 5; + + MoveTo(curLoc); + + crash_z = 0; +} + +void Vehicle::CrashOnWater() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if (curRide->status == RideStatus::simulating) + { + SimulateCrash(); + return; + } + SetState(Status::crashed, sub_state); + +#ifdef ENABLE_SCRIPTING + InvokeVehicleCrashHook(Id, "water"); +#endif + + if (!curRide->flags.has(RideFlag::crashed)) + { + auto frontVehicle = GetHead(); + auto trainIndex = ride_get_train_index_from_vehicle(*curRide, frontVehicle->Id); + if (!trainIndex.has_value()) + { + return; + } + + curRide->crash(trainIndex.value()); + + if (curRide->status != RideStatus::closed) + { + // We require this to execute right away during the simulation, always ignore network and queue. + auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); + GameActions::ExecuteNested(&gameAction, getGameState()); + } + } + curRide->flags.set(RideFlag::crashed); + curRide->windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); + + if (IsHead()) + { + KillAllPassengersInTrain(); + } + + sub_state = 2; + + const auto curLoc = GetLocation(); + Play3D(SoundId::water1, curLoc); + + CrashSplashParticle::Create(curLoc); + CrashSplashParticle::Create(curLoc + CoordsXYZ{ -8, -9, 0 }); + CrashSplashParticle::Create(curLoc + CoordsXYZ{ 11, -9, 0 }); + CrashSplashParticle::Create(curLoc + CoordsXYZ{ 11, 8, 0 }); + CrashSplashParticle::Create(curLoc + CoordsXYZ{ -4, 8, 0 }); + + for (int32_t i = 0; i < 10; ++i) + VehicleCrashParticle::Create(colours, curLoc + CoordsXYZ{ -4, 8, 0 }); + + flags.set(VehicleFlag::crashed); + animation_frame = 0; + animationState = 0; + SpriteData.Width = 13; + SpriteData.HeightMin = 45; + SpriteData.HeightMax = 5; + + MoveTo(curLoc); + + crash_z = -1; +} + +/** + * + * rct2: 0x006D98CA + */ +void Vehicle::UpdateCrash() +{ + for (Vehicle* curVehicle = getGameState().entities.GetEntity(Id); curVehicle != nullptr; + curVehicle = getGameState().entities.GetEntity(curVehicle->next_vehicle_on_train)) + { + CoordsXYZ curPos = curVehicle->GetLocation(); + + if (curVehicle->sub_state > 1) + { + if (curVehicle->crash_z <= 96) + { + curVehicle->crash_z++; + if ((ScenarioRand() & 0xFFFF) <= 0x1555) + { + int32_t xOffset = (ScenarioRand() & 2) - 1; + int32_t yOffset = (ScenarioRand() & 2) - 1; + + ExplosionCloud::Create(curPos + CoordsXYZ{ xOffset, yOffset, 0 }); + } + } + if (curVehicle->animationState <= 0xe388) + { + curVehicle->animationState += 0x1c71; + } + else + { + curVehicle->animationState = 0; + curVehicle->animation_frame++; + if (curVehicle->animation_frame >= 8) + curVehicle->animation_frame = 0; + curVehicle->Invalidate(); + } + continue; + } + + TileElement* collideElement = vehicle_check_collision(curPos); + if (collideElement == nullptr) + { + curVehicle->sub_state = 1; + } + else if (curVehicle->sub_state == 1) + { + curVehicle->CrashOnLand(); + continue; + } + + int16_t height = TileElementHeight(curPos); + int16_t waterHeight = TileElementWaterHeight(curPos); + int16_t zDiff; + if (waterHeight != 0) + { + zDiff = curPos.z - waterHeight; + if (zDiff <= 0 && zDiff >= -20) + { + curVehicle->CrashOnWater(); + continue; + } + } + + zDiff = curPos.z - height; + if ((zDiff <= 0 && zDiff >= -20) || curPos.z < 16) + { + curVehicle->CrashOnLand(); + continue; + } + + curVehicle->Invalidate(); + + curPos.x += static_cast(curVehicle->crash_x >> 8); + curPos.y += static_cast(curVehicle->crash_y >> 8); + curPos.z += static_cast(curVehicle->crash_z >> 8); + curVehicle->TrackLocation = { (curVehicle->crash_x << 8), (curVehicle->crash_y << 8), (curVehicle->crash_z << 8) }; + + if (!MapIsLocationValid(curPos)) + { + curVehicle->CrashOnLand(); + continue; + } + + curVehicle->MoveTo(curPos); + + if (curVehicle->sub_state == 1) + { + curVehicle->crash_z -= 20; + } + } +} diff --git a/src/openrct2/ride/Vehicle.Dodgems.cpp b/src/openrct2/ride/Vehicle.Dodgems.cpp new file mode 100644 index 0000000000..642b580130 --- /dev/null +++ b/src/openrct2/ride/Vehicle.Dodgems.cpp @@ -0,0 +1,320 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../GameState.h" +#include "../core/Speed.hpp" +#include "../entity/EntityList.h" +#include "../entity/EntityRegistry.h" +#include "../scenario/Scenario.h" +#include "Ride.h" +#include "TrackData.h" +#include "VehicleGeometry.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::TrackMetaData; +using namespace OpenRCT2::RideVehicle; + +// External globals from Vehicle.cpp +extern uint32_t _vehicleMotionTrackFlags; +extern int32_t _vehicleVelocityF64E08; +extern int32_t _vehicleVelocityF64E0C; +extern int32_t _vehicleUnkF64E10; +extern CoordsXYZ _vehicleCurPosition; + +/** rct2: 0x009A37C4 */ +static constexpr CoordsXY kSurroundingTiles[] = { + { 0, 0 }, + { 0, +kCoordsXYStep }, + { +kCoordsXYStep, 0 }, + { 0, -kCoordsXYStep }, + { 0, -kCoordsXYStep }, + { -kCoordsXYStep, 0 }, + { -kCoordsXYStep, 0 }, + { 0, +kCoordsXYStep }, + { 0, +kCoordsXYStep }, +}; + +/** + * + * rct2: 0x006D91BF + */ +void Vehicle::UpdateDodgemsMode() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + const auto* rideEntry = GetRideEntry(); + if (rideEntry == nullptr) + { + return; + } + const auto& carEntry = rideEntry->Cars[vehicle_type]; + + // Mark the dodgem as in use. + if (carEntry.flags.has(CarEntryFlag::hasDodgemInUseLights) && animation_frame != 1) + { + animation_frame = 1; + Invalidate(); + } + + UpdateMotionDodgems(); + + // Update the length of time vehicle has been in dodgems mode + if (sub_state++ == 0xFF) + { + TimeActive++; + } + + if (curRide->flags.has(RideFlag::passStationNoStopping)) + return; + + // Mark the dodgem as not in use. + animation_frame = 0; + Invalidate(); + velocity = 0; + acceleration = 0; + SetState(Status::unloadingPassengers); +} + +/** + * + * rct2: 0x006DA44E + */ +int32_t Vehicle::UpdateMotionDodgems() +{ + _vehicleMotionTrackFlags = 0; + + auto curRide = GetRide(); + if (curRide == nullptr) + return _vehicleMotionTrackFlags; + + int32_t nextVelocity = velocity + acceleration; + if (curRide->flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown) + && curRide->breakdownReasonPending == BREAKDOWN_SAFETY_CUT_OUT) + { + nextVelocity = 0; + } + velocity = nextVelocity; + + _vehicleVelocityF64E08 = nextVelocity; + _vehicleVelocityF64E0C = (nextVelocity / 1024) * 42; + _vehicleUnkF64E10 = 1; + + acceleration = 0; + if (!curRide->flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown) + || curRide->breakdownReasonPending != BREAKDOWN_SAFETY_CUT_OUT) + { + if ((getGameState().currentTicks & 1) && var_34 != 0) + { + if (var_34 > 0) + { + var_34--; + Orientation += 2; + } + else + { + var_34++; + Orientation -= 2; + } + Orientation &= 0x1E; + Invalidate(); + } + else if ((ScenarioRand() & 0xFFFF) <= 2849) + { + if (var_35 & (1 << 6)) + Orientation -= 2; + else + Orientation += 2; + Orientation &= 0x1E; + Invalidate(); + } + } + + std::optional collideSprite; + if (DodgemsCollisionDirection != 0) + { + uint8_t oldCollisionDirection = DodgemsCollisionDirection & 0x1E; + DodgemsCollisionDirection = 0; + + CoordsXYZ location = { x, y, z }; + + location.x += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection).x; + location.y += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection).y; + location.x += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection + 1).x; + location.y += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection + 1).y; + + if (collideSprite = DodgemsCarWouldCollideAt(location); !collideSprite.has_value()) + { + MoveTo(location); + } + } + + remaining_distance += _vehicleVelocityF64E0C; + + if (remaining_distance >= 13962) + { + sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; + _vehicleCurPosition.x = x; + _vehicleCurPosition.y = y; + _vehicleCurPosition.z = z; + + while (true) + { + var_35++; + uint8_t direction = Orientation; + direction |= var_35 & 1; + + CoordsXY location = _vehicleCurPosition; + location.x += Geometry::getFreeroamVehicleMovementData(direction).x; + location.y += Geometry::getFreeroamVehicleMovementData(direction).y; + + if (collideSprite = DodgemsCarWouldCollideAt(location); collideSprite.has_value()) + { + break; + } + + remaining_distance -= Geometry::getFreeroamVehicleMovementData(direction).distance; + _vehicleCurPosition.x = location.x; + _vehicleCurPosition.y = location.y; + if (remaining_distance < 13962) + { + break; + } + _vehicleUnkF64E10++; + } + + if (remaining_distance >= 13962) + { + int32_t oldVelocity = velocity; + remaining_distance = 0; + velocity = 0; + uint8_t direction = Orientation | 1; + + Vehicle* collideVehicle = getGameState().entities.GetEntity(collideSprite.value()); + if (collideVehicle != nullptr) + { + var_34 = (ScenarioRand() & 1) ? 1 : -1; + + if (oldVelocity >= 2.0_mph) + { + collideVehicle->DodgemsCollisionDirection = direction; + DodgemsCollisionDirection = direction ^ (1 << 4); + } + } + else + { + var_34 = (ScenarioRand() & 1) ? 6 : -6; + + if (oldVelocity >= 2.0_mph) + { + DodgemsCollisionDirection = direction ^ (1 << 4); + } + } + } + + MoveTo(_vehicleCurPosition); + } + + int32_t eax = velocity / 2; + int32_t edx = velocity >> 8; + edx *= edx; + if (velocity < 0) + edx = -edx; + edx >>= 5; + eax += edx; + if (mass != 0) + { + eax /= mass; + } + const auto* rideEntry = GetRideEntry(); + const auto& carEntry = rideEntry->Cars[vehicle_type]; + + if (!carEntry.flags.has(CarEntryFlag::isPowered)) + { + acceleration = -eax; + return _vehicleMotionTrackFlags; + } + + int32_t momentum = (speed * mass) >> 2; + int32_t _eax = speed << 14; + if (flags.has(VehicleFlag::poweredCarInReverse)) + { + _eax = -_eax; + } + _eax -= velocity; + _eax *= powered_acceleration * 2; + if (momentum != 0) + _eax /= momentum; + + acceleration = _eax - eax; + return _vehicleMotionTrackFlags; +} + +/** + * + * rct2: 0x006DD365 + */ +static bool wouldCollideWithDodgemsTrackEdge( + const CoordsXY& coords, const CoordsXY& trackLocation, TrackElemType trackType, uint16_t dodgemsCarRadius) +{ + int16_t rideLeft = trackLocation.x + GetDodgemsTrackSize(trackType).left; + int16_t rideRight = trackLocation.x + GetDodgemsTrackSize(trackType).right; + int16_t rideTop = trackLocation.y + GetDodgemsTrackSize(trackType).top; + int16_t rideBottom = trackLocation.y + GetDodgemsTrackSize(trackType).bottom; + + return coords.x - dodgemsCarRadius < rideLeft || coords.y - dodgemsCarRadius < rideTop + || coords.x + dodgemsCarRadius > rideRight || coords.y + dodgemsCarRadius > rideBottom; +} + +std::optional Vehicle::DodgemsCarWouldCollideAt(const CoordsXY& coords) const +{ + auto trackType = GetTrackType(); + + if (wouldCollideWithDodgemsTrackEdge(coords, TrackLocation, trackType, (var_44 * 30) >> 9)) + { + return EntityId::GetNull(); + } + + auto location = coords; + + RideId rideIndex = ride; + for (auto xy_offset : kSurroundingTiles) + { + location += xy_offset; + + for (auto vehicle2 : EntityTileList(location)) + { + if (vehicle2 == this) + continue; + if (vehicle2->ride != rideIndex) + continue; + + int32_t distX = abs(coords.x - vehicle2->x); + if (distX > 32768) + continue; + + int32_t distY = abs(coords.y - vehicle2->y); + if (distY > 32768) + continue; + + int32_t ecx = (var_44 + vehicle2->var_44) / 2; + ecx *= 30; + ecx >>= 8; + if (std::max(distX, distY) < ecx) + { + return vehicle2->Id; + } + } + } + + return std::nullopt; +} diff --git a/src/openrct2/ride/Vehicle.MiniGolf.cpp b/src/openrct2/ride/Vehicle.MiniGolf.cpp new file mode 100644 index 0000000000..fb8dd34878 --- /dev/null +++ b/src/openrct2/ride/Vehicle.MiniGolf.cpp @@ -0,0 +1,754 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../Diagnostic.h" +#include "../GameState.h" +#include "../core/Speed.hpp" +#include "../entity/EntityRegistry.h" +#include "../entity/Guest.h" +#include "../paint/vehicle/Vehicle.MiniGolf.h" +#include "../scenario/Scenario.h" +#include "../world/Map.h" +#include "../world/tile_element/TileElement.h" +#include "../world/tile_element/TrackElement.h" +#include "Ride.h" +#include "RideData.h" +#include "Track.h" +#include "TrackData.h" +#include "VehicleGeometry.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::RideVehicle; +using namespace OpenRCT2::TrackMetaData; + +static PitchAndRoll PitchAndRollStart(bool useInvertedSprites, TileElement* tileElement) +{ + auto trackType = tileElement->AsTrack()->GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + return PitchAndRoll{ ted.definition.pitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) }; +} + +void RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const TrackElemType trackType) +{ + const auto& ted = GetTrackElementDescriptor(trackType); + if (ted.flags.has(TrackElementFlag::isGolfHole)) + { + if (ride.numHoles < Limits::kMaxGolfHoles) + ride.numHoles++; + } +} + +[[nodiscard]] Vehicle::UpdateMiniGolfSubroutineStatus Vehicle::UpdateTrackMotionMiniGolfFlagsStatus(const Ride& curRide) +{ + if (var_D3 != 0) + { + var_D3--; + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + + if (miniGolfFlags.has(MiniGolfFlag::flag2)) + { + uint8_t nextFrame = animation_frame + 1; + if (nextFrame < kMiniGolfPeepAnimationLengths[EnumValue(mini_golf_current_animation)]) + { + animation_frame = nextFrame; + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + miniGolfFlags.unset(MiniGolfFlag::flag2); + } + + if (miniGolfFlags.has(MiniGolfFlag::flag0)) + { + auto vehicleIdx = IsHead() ? next_vehicle_on_ride : prev_vehicle_on_ride; + Vehicle* vEDI = getGameState().entities.GetEntity(vehicleIdx); + if (vEDI == nullptr) + { + return UpdateMiniGolfSubroutineStatus::stop; + } + if (!vEDI->miniGolfFlags.has(MiniGolfFlag::flag0) || vEDI->miniGolfFlags.has(MiniGolfFlag::flag2)) + { + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + if (vEDI->var_D3 != 0) + { + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + vEDI->miniGolfFlags.unset(MiniGolfFlag::flag0); + miniGolfFlags.unset(MiniGolfFlag::flag0); + } + + if (miniGolfFlags.has(MiniGolfFlag::flag1)) + { + auto vehicleIdx = IsHead() ? next_vehicle_on_ride : prev_vehicle_on_ride; + Vehicle* vEDI = getGameState().entities.GetEntity(vehicleIdx); + if (vEDI == nullptr) + { + return UpdateMiniGolfSubroutineStatus::stop; + } + if (!vEDI->miniGolfFlags.has(MiniGolfFlag::flag1) || vEDI->miniGolfFlags.has(MiniGolfFlag::flag2)) + { + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + if (vEDI->var_D3 != 0) + { + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + vEDI->miniGolfFlags.unset(MiniGolfFlag::flag1); + miniGolfFlags.unset(MiniGolfFlag::flag1); + } + + if (miniGolfFlags.has(MiniGolfFlag::flag3)) + { + Vehicle* vEDI = this; + + for (;;) + { + vEDI = getGameState().entities.GetEntity(vEDI->prev_vehicle_on_ride); + if (vEDI == this || vEDI == nullptr) + { + break; + } + if (vEDI->IsHead()) + continue; + if (!vEDI->miniGolfFlags.has(MiniGolfFlag::flag4)) + continue; + if (vEDI->TrackLocation != TrackLocation) + continue; + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + + miniGolfFlags.set(MiniGolfFlag::flag4); + miniGolfFlags.unset(MiniGolfFlag::flag3); + } + + return UpdateMiniGolfSubroutineStatus::carryOn; +} + +[[nodiscard]] Vehicle::UpdateMiniGolfSubroutineStatus Vehicle::Loc6DC462(const Ride& curRide) +{ + while (true) + { + UpdateMiniGolfSubroutineStatus flagsStatus = UpdateMiniGolfSubroutineStatus::restart; + while (flagsStatus == UpdateMiniGolfSubroutineStatus::restart) + { + flagsStatus = UpdateTrackMotionMiniGolfFlagsStatus(curRide); + } + if (flagsStatus == UpdateMiniGolfSubroutineStatus::stop) + return UpdateMiniGolfSubroutineStatus::stop; + + uint16_t trackTotalProgress = GetTrackProgress(); + if (track_progress + 1 >= trackTotalProgress) + { + CoordsXYZ trackPos; + Direction direction; + auto* tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, GetTrackType(), 0); + CoordsXYE output; + int32_t outZ{}; + int32_t outDirection{}; + CoordsXYE input = { TrackLocation, tileElement }; + if (!TrackBlockGetNext(&input, &output, &outZ, &outDirection)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; + _vehicleVelocityF64E0C -= remaining_distance + 1; + remaining_distance = -1; + acceleration += Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::carryOn; + } + tileElement = output.element; + trackPos = { output.x, output.y, outZ }; + direction = outDirection; + + if (PitchAndRollStart(false, tileElement) != TrackPitchAndRollEnd(GetTrackType())) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; + _vehicleVelocityF64E0C -= remaining_distance + 1; + remaining_distance = -1; + if (remaining_distance >= 0) + { + Loc6DCDE4(curRide); + } + acceleration += Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::carryOn; + } + + TrackLocation = trackPos; + + if (!IsHead()) + { + Vehicle* prevVehicle = getGameState().entities.GetEntity(prev_vehicle_on_ride); + if (prevVehicle != nullptr) + { + TrackSubposition = prevVehicle->TrackSubposition; + } + if (TrackSubposition != VehicleTrackSubposition::MiniGolfStart9) + { + TrackSubposition = VehicleTrackSubposition{ static_cast( + static_cast(TrackSubposition) - 1u) }; + } + } + + flags.unset(VehicleFlag::onLiftHill); + SetTrackType(tileElement->AsTrack()->GetTrackType()); + SetTrackDirection(direction); + brake_speed = tileElement->AsTrack()->GetBrakeBoosterSpeed(); + track_progress = 0; + } + else + { + track_progress += 1; + } + + if (!IsHead()) + { + animation_frame++; + if (animation_frame >= 6) + { + animation_frame = 0; + } + } + const VehicleInfo* moveInfo; + for (;;) + { + moveInfo = GetMoveInfo(); + if (moveInfo->x != kLocationNull) + { + break; + } + switch (MiniGolfState(moveInfo->y)) + { + case MiniGolfState::Unk0: // Loc6DC7B4 + if (!IsHead()) + { + miniGolfFlags.set(MiniGolfFlag::flag3); + } + else + { + uint16_t rand16 = ScenarioRand() & 0xFFFF; + VehicleTrackSubposition nextTrackSubposition = VehicleTrackSubposition::MiniGolfBallPathC14; + if (rand16 <= 0xA000) + { + nextTrackSubposition = VehicleTrackSubposition::MiniGolfBallPathB12; + if (rand16 <= 0x900) + { + nextTrackSubposition = VehicleTrackSubposition::MiniGolfBallPathA10; + } + } + TrackSubposition = nextTrackSubposition; + } + track_progress++; + break; + case MiniGolfState::Unk1: // Loc6DC7ED + LOG_ERROR("Unused move info..."); + assert(false); + var_D3 = static_cast(moveInfo->z); + track_progress++; + break; + case MiniGolfState::Unk2: // Loc6DC800 + miniGolfFlags.set(MiniGolfFlag::flag0); + track_progress++; + break; + case MiniGolfState::Unk3: // Loc6DC810 + miniGolfFlags.set(MiniGolfFlag::flag1); + track_progress++; + break; + case MiniGolfState::Unk4: // Loc6DC820 + { + auto animation = MiniGolfAnimation(moveInfo->z); + // When the ride is closed occasionally the peep is removed + // but the vehicle is still on the track. This will prevent + // it from crashing in that situation. + auto* curPeep = getGameState().entities.TryGetEntity(peep[0]); + if (curPeep != nullptr) + { + if (animation == MiniGolfAnimation::SwingLeft) + { + if (curPeep->PeepId & 7) + { + animation = MiniGolfAnimation::Swing; + } + } + if (animation == MiniGolfAnimation::PuttLeft) + { + if (curPeep->PeepId & 7) + { + animation = MiniGolfAnimation::Putt; + } + } + } + mini_golf_current_animation = animation; + animation_frame = 0; + track_progress++; + break; + } + case MiniGolfState::Unk5: // Loc6DC87A + miniGolfFlags.set(MiniGolfFlag::flag2); + track_progress++; + break; + case MiniGolfState::Unk6: // Loc6DC88A + miniGolfFlags.unset(MiniGolfFlag::flag4); + miniGolfFlags.set(MiniGolfFlag::flag5); + track_progress++; + break; + default: + LOG_ERROR("Invalid move info..."); + assert(false); + break; + } + } + + // Loc6DC8A1 + CoordsXYZ trackPos = { TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, + TrackLocation.z + moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; + + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + _vehicleCurPosition = trackPos; + Orientation = moveInfo->yaw; + roll = moveInfo->roll; + pitch = moveInfo->pitch; + + if (this == _vehicleFrontVehicle) + { + if (_vehicleVelocityF64E08 >= 0) + { + auto otherVehicleIndex = prev_vehicle_on_ride; + UpdateMotionCollisionDetection(trackPos, &otherVehicleIndex); + } + } + if (remaining_distance < 0x368A) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + } +} + +[[nodiscard]] Vehicle::UpdateMiniGolfSubroutineStatus Vehicle::Loc6DCA9A(const Ride& curRide) +{ + while (true) + { + if (track_progress == 0) + { + auto tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, GetTrackType(), 0); + TrackBeginEnd trackBeginEnd; + if (!TrackBlockGetPrevious({ TrackLocation, tileElement }, &trackBeginEnd)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; + _vehicleVelocityF64E0C -= remaining_distance + 1; + remaining_distance = -1; + acceleration += Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + continue; + } + CoordsXYZ trackPos = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z }; + auto direction = trackBeginEnd.begin_direction; + tileElement = trackBeginEnd.begin_element; + + if (PitchAndRollStart(false, tileElement) != TrackPitchAndRollEnd(GetTrackType())) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; + _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + remaining_distance = 0x368A; + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + + TrackLocation = trackPos; + + if (flags.has(VehicleFlag::onLiftHill)) + { + flags.unset(VehicleFlag::onLiftHill); + if (next_vehicle_on_train.IsNull()) + { + if (_vehicleVelocityF64E08 < 0) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_8; + } + } + } + + SetTrackType(tileElement->AsTrack()->GetTrackType()); + SetTrackDirection(direction); + brake_speed = tileElement->AsTrack()->GetBrakeBoosterSpeed(); + + // There are two bytes before the move info list + track_progress = GetTrackProgress(); + } + else + { + track_progress -= 1; + } + + auto moveInfo = GetMoveInfo(); + CoordsXYZ trackPos = { TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, + TrackLocation.z + moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; + + remaining_distance -= 0x368A; + if (remaining_distance < 0) + { + remaining_distance = 0; + } + + _vehicleCurPosition = trackPos; + Orientation = moveInfo->yaw; + roll = moveInfo->roll; + pitch = moveInfo->pitch; + + if (this == _vehicleFrontVehicle) + { + if (_vehicleVelocityF64E08 >= 0) + { + auto otherVehicleIndex = EntityId::FromUnderlying(var_44); // Possibly wrong?. + if (UpdateMotionCollisionDetection(trackPos, &otherVehicleIndex)) + { + _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + remaining_distance = 0x368A; + { + Vehicle* vEBP = getGameState().entities.GetEntity(otherVehicleIndex); + if (vEBP == nullptr) + { + return UpdateMiniGolfSubroutineStatus::stop; + } + Vehicle* vEDI = gCurrentVehicle; + if (abs(vEDI->velocity - vEBP->velocity) > 14.0_mph) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION; + } + vEDI->velocity = vEBP->velocity >> 1; + vEBP->velocity = vEDI->velocity >> 1; + } + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; + acceleration = Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + return UpdateMiniGolfSubroutineStatus::restart; + } + } + } + + if (remaining_distance >= 0) + { + Loc6DCDE4(curRide); + return UpdateMiniGolfSubroutineStatus::stop; + } + acceleration += Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + } +} + +/** + * rct2: 0x006DC3A7 + * + * + */ + +void Vehicle::UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) +{ + _vehicleUnkF64E10 = 1; + acceleration = Geometry::getAccelerationFromPitch(pitch); + if (!flags.has(VehicleFlag::moveSingleCar)) + { + remaining_distance = _vehicleVelocityF64E0C + remaining_distance; + } + if (remaining_distance >= 0 && remaining_distance < 0x368A) + { + Loc6DCE02(curRide); + return; + } + sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; + _vehicleCurPosition.x = x; + _vehicleCurPosition.y = y; + _vehicleCurPosition.z = z; + Invalidate(); + bool skipLoc6DC462 = (remaining_distance < 0); + + while (true) + { + if (!skipLoc6DC462) + { + auto result1 = Loc6DC462(curRide); + if (result1 == UpdateMiniGolfSubroutineStatus::stop) + return; + } + skipLoc6DC462 = false; + auto result2 = Loc6DCA9A(curRide); + if (result2 == UpdateMiniGolfSubroutineStatus::stop) + return; + } +} + +void Vehicle::Loc6DCDE4(const Ride& curRide) +{ + MoveTo(_vehicleCurPosition); + + Loc6DCE02(curRide); +} + +void Vehicle::Loc6DCE02(const Ride& curRide) +{ + acceleration /= _vehicleUnkF64E10; + if (TrackSubposition == VehicleTrackSubposition::ChairliftGoingBack) + { + return; + } + + auto trackType = GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin)) + { + return; + } + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_3; + if (trackType != TrackElemType::endStation) + { + return; + } + if (this != gCurrentVehicle) + { + return; + } + if (_vehicleVelocityF64E08 < 0) + { + if (track_progress > 11) + { + return; + } + } + if (track_progress <= 8) + { + return; + } + + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; + + for (const auto& station : curRide.getStations()) + { + if (TrackLocation != station.Start) + { + continue; + } + if (TrackLocation.z != station.GetBaseZ()) + { + continue; + } + _vehicleStationIndex = curRide.getStationIndex(&station); + } +} + +static constexpr int32_t GetAccelerationDecrease2(const int32_t velocity, const int32_t totalMass) +{ + int32_t accelerationDecrease2 = velocity >> 8; + accelerationDecrease2 *= accelerationDecrease2; + if (velocity < 0) + { + accelerationDecrease2 = -accelerationDecrease2; + } + accelerationDecrease2 >>= 4; + // OpenRCT2: vehicles from different track types can have 0 mass. + if (totalMass != 0) + { + return accelerationDecrease2 / totalMass; + } + + return accelerationDecrease2; +} + +int32_t Vehicle::UpdateTrackMotionMiniGolfCalculateAcceleration(const CarEntry& carEntry) +{ + int32_t sumAcceleration = 0; + int32_t numVehicles = 0; + uint16_t totalMass = 0; + + for (Vehicle* vehicle = this; vehicle != nullptr; + vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) + { + numVehicles++; + totalMass += vehicle->mass; + sumAcceleration += vehicle->acceleration; + } + + int32_t newAcceleration = ((sumAcceleration / numVehicles) * 21) >> 9; + newAcceleration -= velocity >> 12; + newAcceleration -= GetAccelerationDecrease2(velocity, totalMass); + + { + int32_t poweredAcceleration = speed << 14; + int32_t quarterForce = (speed * totalMass) >> 2; + if (flags.has(VehicleFlag::poweredCarInReverse)) + { + poweredAcceleration = -poweredAcceleration; + } + poweredAcceleration -= velocity; + poweredAcceleration *= powered_acceleration << 1; + if (quarterForce != 0) + poweredAcceleration /= quarterForce; + + if (abs(velocity) > 1.0_mph) + { + newAcceleration = 0; + } + newAcceleration += poweredAcceleration; + } + + return newAcceleration; +} + +int32_t Vehicle::UpdateTrackMotionMiniGolf(int32_t* outStation) +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return 0; + + const auto* rideEntry = GetRideEntry(); + if (rideEntry == nullptr) + return 0; + + const auto* carEntry = Entry(); + + gCurrentVehicle = this; + _vehicleMotionTrackFlags = 0; + velocity += acceleration; + _vehicleVelocityF64E08 = velocity; + _vehicleVelocityF64E0C = (velocity >> 10) * 42; + _vehicleFrontVehicle = _vehicleVelocityF64E08 < 0 ? TrainTail() : this; + + for (Vehicle* vehicle = _vehicleFrontVehicle; vehicle != nullptr;) + { + vehicle->UpdateTrackMotionMiniGolfVehicle(*curRide, *rideEntry, carEntry); + if (vehicle->flags.has(VehicleFlag::onLiftHill)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL; + } + if (vehicle->flags.has(VehicleFlag::moveSingleCar)) + { + if (outStation != nullptr) + *outStation = _vehicleStationIndex.ToUnderlying(); + return _vehicleMotionTrackFlags; + } + if (_vehicleVelocityF64E08 >= 0) + { + vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train); + } + else + { + if (vehicle == gCurrentVehicle) + { + break; + } + vehicle = getGameState().entities.GetEntity(vehicle->prev_vehicle_on_ride); + } + } + + acceleration = UpdateTrackMotionMiniGolfCalculateAcceleration(*carEntry); + + if (outStation != nullptr) + *outStation = _vehicleStationIndex.ToUnderlying(); + return _vehicleMotionTrackFlags; +} diff --git a/src/openrct2/ride/Vehicle.SceneryDoors.cpp b/src/openrct2/ride/Vehicle.SceneryDoors.cpp new file mode 100644 index 0000000000..ea15a1cf94 --- /dev/null +++ b/src/openrct2/ride/Vehicle.SceneryDoors.cpp @@ -0,0 +1,219 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../audio/Audio.h" +#include "../core/EnumUtils.hpp" +#include "../world/Map.h" +#include "../world/MapAnimation.h" +#include "../world/tile_element/SurfaceElement.h" +#include "../world/tile_element/TileElement.h" +#include "../world/tile_element/TrackElement.h" +#include "../world/tile_element/WallElement.h" +#include "Ride.h" +#include "RideData.h" +#include "TrackData.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::Audio; +using namespace OpenRCT2::TrackMetaData; + +static constexpr SoundId kDoorOpenSoundIds[] = { + SoundId::null, // DoorSoundType::none + SoundId::doorOpen, // DoorSoundType::door + SoundId::portcullis, // DoorSoundType::portcullis +}; +static_assert(std::size(kDoorOpenSoundIds) == kDoorSoundTypeCount); + +static constexpr SoundId kDoorCloseSoundIds[] = { + SoundId::null, // DoorSoundType::none + SoundId::doorClose, // DoorSoundType::door + SoundId::portcullis, // DoorSoundType::portcullis +}; +static_assert(std::size(kDoorCloseSoundIds) == kDoorSoundTypeCount); + +/** + * + * rct2: 0x006DEDB1 + */ +static void play_scenery_door_open_sound(const CoordsXYZ& loc, WallElement* tileElement) +{ + auto* wallEntry = tileElement->GetEntry(); + if (wallEntry == nullptr) + return; + + auto doorSoundType = wallEntry->getDoorSoundType(); + if (doorSoundType == DoorSoundType::none) + return; + + auto soundId = kDoorOpenSoundIds[EnumValue(doorSoundType)]; + Play3D(soundId, loc); +} + +/** + * + * rct2: 0x006DED7A + */ +static void play_scenery_door_close_sound(const CoordsXYZ& loc, WallElement* tileElement) +{ + auto* wallEntry = tileElement->GetEntry(); + if (wallEntry == nullptr) + return; + + auto doorSoundType = wallEntry->getDoorSoundType(); + if (doorSoundType == DoorSoundType::none) + return; + + auto soundId = kDoorCloseSoundIds[EnumValue(doorSoundType)]; + Play3D(soundId, loc); +} + +template +static void AnimateSceneryDoor(const CoordsXYZD& doorLocation, const CoordsXYZ& trackLocation, bool isLastVehicle) +{ + auto door = MapGetWallElementAt(doorLocation); + if (door == nullptr) + { + return; + } + + if (!isLastVehicle && (door->GetAnimationFrame() == 0)) + { + door->SetAnimationIsBackwards(isBackwards); + door->SetAnimationFrame(1); + door->SetIsAnimating(true); + play_scenery_door_open_sound(trackLocation, door); + + MapAnimations::MarkTileForUpdate(TileCoordsXY(doorLocation)); + } + + if (isLastVehicle) + { + door->SetAnimationIsBackwards(isBackwards); + door->SetAnimationFrame(6); + door->SetIsAnimating(true); + play_scenery_door_close_sound(trackLocation, door); + + MapAnimations::MarkTileForUpdate(TileCoordsXY(doorLocation)); + } +} + +/** + * + * rct2: 0x006DEE93 + */ +void Vehicle::UpdateSceneryDoor() const +{ + auto trackType = GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + const auto& trackBlock = ted.sequences[ted.numSequences - 1].clearance; + const TrackCoordinates* trackCoordinates = &ted.coordinates; + auto wallCoords = CoordsXYZ{ x, y, TrackLocation.z - trackBlock.z + trackCoordinates->zEnd }.ToTileStart(); + int32_t direction = (GetTrackDirection() + trackCoordinates->rotationEnd) & 3; + + AnimateSceneryDoor({ wallCoords, static_cast(direction) }, TrackLocation, next_vehicle_on_train.IsNull()); +} + +template +static void AnimateLandscapeDoor( + const CoordsXYZ& doorLocation, TrackElement& trackElement, const bool isLastVehicle, const DoorSoundType doorSound, + const CoordsXYZ& soundLocation) +{ + const auto doorState = isBackwards ? trackElement.GetDoorAState() : trackElement.GetDoorBState(); + if (!isLastVehicle && doorState == kLandEdgeDoorFrameClosed) + { + if (isBackwards) + trackElement.SetDoorAState(kLandEdgeDoorFrameOpening); + else + trackElement.SetDoorBState(kLandEdgeDoorFrameOpening); + + MapAnimations::CreateTemporary(doorLocation, MapAnimations::TemporaryType::landEdgeDoor); + Play3D(kDoorOpenSoundIds[EnumValue(doorSound)], soundLocation); + } + + if (isLastVehicle) + { + if (isBackwards) + trackElement.SetDoorAState(kLandEdgeDoorFrameClosing); + else + trackElement.SetDoorBState(kLandEdgeDoorFrameClosing); + + MapAnimations::CreateTemporary(doorLocation, MapAnimations::TemporaryType::landEdgeDoor); + Play3D(kDoorCloseSoundIds[EnumValue(doorSound)], soundLocation); + } +} + +static const SurfaceElement* GetSurfaceElementAfterElement(const TileElement* tileElement) +{ + while (tileElement->GetType() != TileElementType::Surface) + { + if (tileElement->IsLastForTile()) + return nullptr; + tileElement++; + } + return tileElement->AsSurface(); +} + +void Vehicle::UpdateLandscapeDoors(const int32_t previousTrackHeight) const +{ + const auto* currentRide = GetRide(); + if (currentRide == nullptr || !currentRide->getRideTypeDescriptor().flags.has(RtdFlag::hasLandscapeDoors)) + { + return; + } + + const CoordsXYZ previousTrackLocation = CoordsXYZ(x, y, previousTrackHeight).ToTileStart(); + auto* const previousTrackElement = MapGetTrackElementAtBeforeSurfaceFromRide(previousTrackLocation, ride); + auto* const currentTrackElement = MapGetTrackElementAtBeforeSurfaceFromRide(TrackLocation, ride); + if (previousTrackElement != nullptr && currentTrackElement == nullptr) + { + const auto* const surfaceElement = GetSurfaceElementAfterElement(previousTrackElement); + if (surfaceElement != nullptr && surfaceElement->GetBaseZ() > previousTrackLocation.z) + { + const auto* const edgeObject = surfaceElement->GetEdgeObject(); + if (edgeObject != nullptr && edgeObject->HasDoors) + { + AnimateLandscapeDoor( + previousTrackLocation, *previousTrackElement->AsTrack(), next_vehicle_on_train.IsNull(), + edgeObject->doorSound, TrackLocation); + } + } + } + else if (previousTrackElement == nullptr && currentTrackElement != nullptr) + { + const auto* const surfaceElement = GetSurfaceElementAfterElement(currentTrackElement); + if (surfaceElement != nullptr && surfaceElement->GetBaseZ() > TrackLocation.z) + { + const auto* const edgeObject = surfaceElement->GetEdgeObject(); + if (edgeObject != nullptr && edgeObject->HasDoors) + { + AnimateLandscapeDoor( + TrackLocation, *currentTrackElement->AsTrack(), next_vehicle_on_train.IsNull(), edgeObject->doorSound, + previousTrackLocation); + } + } + } +} + +/** + * + * rct2: 0x006DEDE8 + */ +void Vehicle::UpdateSceneryDoorBackwards() const +{ + auto trackType = GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + const TrackCoordinates* trackCoordinates = &ted.coordinates; + auto wallCoords = CoordsXYZ{ TrackLocation, TrackLocation.z - ted.sequences[0].clearance.z + trackCoordinates->zBegin }; + int32_t direction = (GetTrackDirection() + trackCoordinates->rotationBegin) & 3; + direction = DirectionReverse(direction); + + AnimateSceneryDoor({ wallCoords, static_cast(direction) }, TrackLocation, next_vehicle_on_train.IsNull()); +} diff --git a/src/openrct2/ride/Vehicle.Sound.cpp b/src/openrct2/ride/Vehicle.Sound.cpp new file mode 100644 index 0000000000..4c37c729b4 --- /dev/null +++ b/src/openrct2/ride/Vehicle.Sound.cpp @@ -0,0 +1,304 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../GameState.h" +#include "../audio/Audio.h" +#include "../core/Speed.hpp" +#include "../entity/EntityRegistry.h" +#include "../scenario/Scenario.h" +#include "../ui/WindowManager.h" +#include "../windows/Intent.h" +#include "Ride.h" +#include "RideData.h" +#include "VehicleGeometry.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::Audio; +using namespace OpenRCT2::RideVehicle; + +static constexpr SoundId _screamSetMisc[] = { + SoundId::scream8, + SoundId::scream1, +}; +static constexpr SoundId _screamSetWooden[] = { + SoundId::scream3, SoundId::scream1, SoundId::scream5, SoundId::scream6, + SoundId::scream7, SoundId::scream2, SoundId::scream4, +}; +static constexpr SoundId _screamSetSteel[] = { + SoundId::scream1, + SoundId::scream6, +}; + +void VehicleSoundsUpdate() +{ + auto windowManager = Ui::GetWindowManager(); + windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_VEHICLE_SOUNDS)); +} + +/** + * + * rct2: 0x006D7AC0 + */ +static SoundIdVolume VehicleSoundFadeInOut( + SoundId currentSoundId, uint8_t currentVolume, SoundId targetSoundId, uint8_t targetVolume) +{ + if (currentSoundId != SoundId::null) + { + if (currentSoundId == targetSoundId) + { + currentVolume = std::min(currentVolume + 15, targetVolume); + return { currentSoundId, currentVolume }; + } + + currentVolume -= 9; + if (currentVolume >= 80) + return { currentSoundId, currentVolume }; + } + + // Begin sound at quarter volume + currentSoundId = targetSoundId; + currentVolume = targetVolume == 255 ? 255 : targetVolume / 4; + + return { currentSoundId, currentVolume }; +} + +void Vehicle::GetLiftHillSound(const Ride& curRide, SoundIdVolume& curSound) +{ + scream_sound_id = SoundId::null; + if (curRide.type < std::size(kRideTypeDescriptors)) + { + // Get lift hill sound + curSound.id = GetRideTypeDescriptor(curRide.type).LiftData.sound_id; + curSound.volume = 243; + if (!(sound2_flags & VEHICLE_SOUND2_FLAGS_LIFT_HILL)) + curSound.id = SoundId::null; + } +} + +/** + * + * rct2: 0x006D7888 + */ +void Vehicle::UpdateSound() +{ + // frictionVolume (bl) should be set before hand + SoundIdVolume frictionSound = { SoundId::null, 255 }; + // bh screamVolume should be set before hand + SoundIdVolume screamSound = { SoundId::null, 255 }; + + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + auto rideEntry = GetRideEntry(); + if (rideEntry == nullptr) + return; + + // Always use the head car's sound data (Some of the other vehicle subtypes have improperly set data) + auto soundCarIndex = (rideEntry->FrontCar == 0xff) ? rideEntry->DefaultCar : rideEntry->FrontCar; + const auto& carEntry = rideEntry->Cars[soundCarIndex]; + + int32_t ecx = abs(velocity) - 1.0_mph; + if (ecx >= 0) + { + frictionSound.id = carEntry.friction_sound_id; + ecx >>= 15; + frictionSound.volume = std::min(208 + (ecx & 0xFF), 255); + } + + const auto currentTicks = getGameState().currentTicks; + switch (carEntry.soundRange) + { + case SoundRange::steamWhistle: + screamSound.id = scream_sound_id; + if (!(currentTicks & 0x7F)) + { + if (velocity < 4.0_mph || scream_sound_id != SoundId::null) + { + GetLiftHillSound(*curRide, screamSound); + break; + } + + if ((ScenarioRand() & 0xFFFF) <= 0x5555) + { + scream_sound_id = SoundId::trainWhistle; + screamSound.volume = 255; + break; + } + } + if (screamSound.id == SoundId::noScream) + screamSound.id = SoundId::null; + screamSound.volume = 255; + break; + + case SoundRange::tramBell: + screamSound.id = scream_sound_id; + if (!(currentTicks & 0x7F)) + { + if (velocity < 4.0_mph || scream_sound_id != SoundId::null) + { + GetLiftHillSound(*curRide, screamSound); + break; + } + + if ((ScenarioRand() & 0xFFFF) <= 0x5555) + { + scream_sound_id = SoundId::tram; + screamSound.volume = 255; + break; + } + } + if (screamSound.id == SoundId::noScream) + screamSound.id = SoundId::null; + screamSound.volume = 255; + break; + + default: + if (carEntry.flags.has(CarEntryFlag::hasScreamingRiders)) + { + screamSound.id = UpdateScreamSound(); + if (screamSound.id == SoundId::noScream) + { + screamSound.id = SoundId::null; + break; + } + if (screamSound.id != SoundId::null) + { + break; + } + } + GetLiftHillSound(*curRide, screamSound); + } + + // Friction sound + auto soundIdVolume = VehicleSoundFadeInOut(sound1_id, sound1_volume, frictionSound.id, frictionSound.volume); + sound1_id = soundIdVolume.id; + sound1_volume = soundIdVolume.volume; + + // Scream sound + soundIdVolume = VehicleSoundFadeInOut(sound2_id, sound2_volume, screamSound.id, screamSound.volume); + sound2_id = soundIdVolume.id; + sound2_volume = soundIdVolume.volume; + + // Calculate Sound Vector (used for sound frequency calcs) + int32_t soundDirection = Geometry::getSoundDirectionFromOrientation(Orientation); + int32_t soundVector = ((velocity >> 14) * soundDirection) >> 14; + soundVector = std::clamp(soundVector, -127, 127); + + dopplerShift = soundVector & 0xFF; +} + +/** + * + * rct2: 0x006D796B + */ +SoundId Vehicle::UpdateScreamSound() +{ + int32_t totalNumPeeps = NumPeepsUntilTrainTail(); + if (totalNumPeeps == 0) + return SoundId::null; + + if (velocity < 0) + { + if (velocity > -2.75_mph) + return SoundId::null; + + for (Vehicle* vehicle2 = getGameState().entities.GetEntity(Id); vehicle2 != nullptr; + vehicle2 = getGameState().entities.GetEntity(vehicle2->next_vehicle_on_train)) + { + if (vehicle2->pitch < VehiclePitch::up12) + continue; + if (vehicle2->pitch <= VehiclePitch::up60) + return ProduceScreamSound(totalNumPeeps); + if (vehicle2->pitch < VehiclePitch::up75) + continue; + if (vehicle2->pitch <= VehiclePitch::up165) + return ProduceScreamSound(totalNumPeeps); + // up50 occurs on diagonal steep hills + // up8 and up16 occur on diagonal gentle hills + if (vehicle2->pitch == VehiclePitch::up50) + return ProduceScreamSound(totalNumPeeps); + } + return SoundId::null; + } + + if (velocity < 2.75_mph) + return SoundId::null; + + for (Vehicle* vehicle2 = getGameState().entities.GetEntity(Id); vehicle2 != nullptr; + vehicle2 = getGameState().entities.GetEntity(vehicle2->next_vehicle_on_train)) + { + if (vehicle2->pitch < VehiclePitch::down12) + continue; + if (vehicle2->pitch <= VehiclePitch::down60) + return ProduceScreamSound(totalNumPeeps); + if (vehicle2->pitch <= VehiclePitch::inverted) + continue; + if (vehicle2->pitch <= VehiclePitch::down165) + return ProduceScreamSound(totalNumPeeps); + // down50 occurs on diagonal steep drops + // down8 and down16 occur on diagonal gentle drops + if (vehicle2->pitch == VehiclePitch::down50) + return ProduceScreamSound(totalNumPeeps); + } + return SoundId::null; +} + +SoundId Vehicle::ProduceScreamSound(const int32_t totalNumPeeps) +{ + const auto* rideEntry = GetRideEntry(); + + const auto& carEntry = rideEntry->Cars[vehicle_type]; + + if (scream_sound_id == SoundId::null) + { + auto r = ScenarioRand(); + if (totalNumPeeps >= static_cast(r % 16)) + { + switch (carEntry.soundRange) + { + case SoundRange::screamsMisc: + scream_sound_id = _screamSetMisc[r % std::size(_screamSetMisc)]; + break; + case SoundRange::screamsWoodenRollerCoaster: + scream_sound_id = _screamSetWooden[r % std::size(_screamSetWooden)]; + break; + case SoundRange::screamSteelRollerCoaster: + scream_sound_id = _screamSetSteel[r % std::size(_screamSetSteel)]; + break; + default: + scream_sound_id = SoundId::noScream; + break; + } + } + else + { + scream_sound_id = SoundId::noScream; + } + } + return scream_sound_id; +} + +void Vehicle::Claxon() const +{ + const auto* rideEntry = GetRideEntry(); + switch (rideEntry->Cars[vehicle_type].soundRange) + { + case SoundRange::steamWhistle: + Play3D(SoundId::trainWhistle, { x, y, z }); + break; + case SoundRange::tramBell: + Play3D(SoundId::tram, { x, y, z }); + break; + default: + break; + } +} diff --git a/src/openrct2/ride/Vehicle.Station.cpp b/src/openrct2/ride/Vehicle.Station.cpp new file mode 100644 index 0000000000..b302f3a196 --- /dev/null +++ b/src/openrct2/ride/Vehicle.Station.cpp @@ -0,0 +1,1724 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../GameState.h" +#include "../audio/Audio.h" +#include "../config/Config.h" +#include "../core/Speed.hpp" +#include "../entity/EntityRegistry.h" +#include "../entity/Guest.h" +#include "../entity/Peep.h" +#include "../localisation/Formatter.h" +#include "../management/NewsItem.h" +#include "../world/Map.h" +#include "../world/tile_element/TileElement.h" +#include "../world/tile_element/TrackElement.h" +#include "Ride.h" +#include "RideData.h" +#include "Track.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::Audio; + +struct SynchronisedVehicle +{ + RideId ride_id; + StationIndex stationIndex; + EntityId vehicle_id; +}; + +constexpr int32_t SYNCHRONISED_VEHICLE_COUNT = 16; + +// Synchronised vehicle info +static SynchronisedVehicle _synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT] = {}; + +static SynchronisedVehicle* _lastSynchronisedVehicle = nullptr; + +/** + * Checks if a map position contains a synchronised ride station and adds the vehicle + * to synchronise to the vehicle synchronisation list. + * rct2: 0x006DE1A4 + */ +static bool try_add_synchronised_station(const CoordsXYZ& coords) +{ + // make sure we are in map bounds + if (!MapIsLocationValid(coords)) + { + return false; + } + + TileElement* tileElement = GetStationPlatform({ coords, coords.z + 2 * kCoordsZStep }); + if (tileElement == nullptr) + { + /* No station platform element found, + * so no station to synchronise */ + return false; + } + + auto rideIndex = tileElement->AsTrack()->GetRideIndex(); + auto ride = GetRide(rideIndex); + if (ride == nullptr || !(ride->departFlags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS)) + { + /* Ride is not set to synchronise with adjacent stations. */ + return false; + } + + /* From this point on, the ride of the map element is one that is set + * to sync with adjacent stations, so it will return true. + * Still to determine if a vehicle to sync can be identified. */ + + auto stationIndex = tileElement->AsTrack()->GetStationIndex(); + + SynchronisedVehicle* sv = _lastSynchronisedVehicle; + sv->ride_id = rideIndex; + sv->stationIndex = stationIndex; + sv->vehicle_id = EntityId::GetNull(); + _lastSynchronisedVehicle++; + + /* Ride vehicles are not on the track (e.g. ride is/was under + * construction), so just return; vehicle_id for this station + * is SPRITE_INDEX_NULL. */ + if (!ride->flags.has(RideFlag::onTrack)) + { + return true; + } + + /* Station is not ready to depart, so just return; + * vehicle_id for this station is SPRITE_INDEX_NULL. */ + if (!(ride->getStation(stationIndex).Depart & kStationDepartFlag)) + { + return true; + } + + // Look for a vehicle on this station waiting to depart. + for (int32_t i = 0; i < ride->numTrains; i++) + { + auto* vehicle = getGameState().entities.GetEntity(ride->vehicles[i]); + if (vehicle == nullptr) + { + continue; + } + + if (vehicle->status != Vehicle::Status::waitingToDepart) + { + continue; + } + if (vehicle->sub_state != 0) + { + continue; + } + if (!vehicle->flags.has(VehicleFlag::waitingOnAdjacentStation)) + { + continue; + } + if (vehicle->current_station != stationIndex) + { + continue; + } + + sv->vehicle_id = vehicle->Id; + return true; + } + + /* No vehicle found waiting to depart (with sync adjacent) at the + * station, so just return; vehicle_id for this station is + * SPRITE_INDEX_NULL. */ + return true; +} + +/** + * Checks whether a vehicle can depart a station when set to synchronise with adjacent stations. + * rct2: 0x006DE287 + * @param vehicle The vehicle waiting to depart. + * @returns true if the vehicle can depart (all adjacent trains are ready or broken down), otherwise false. + * + * Permits vehicles to depart in two ways: + * Returns true, permitting the vehicle in the param to depart immediately; + * The vehicle flag VehicleFlags::WaitingOnAdjacentStation is cleared for those + * vehicles that depart in sync with the vehicle in the param. + */ +static bool ride_station_can_depart_synchronised(const Ride& ride, StationIndex stationIndex) +{ + const auto& station = ride.getStation(stationIndex); + auto location = station.GetStart(); + + auto tileElement = MapGetTrackElementAt(location); + if (tileElement == nullptr) + { + return false; + } + + // Reset the list of synchronised vehicles to empty. + _lastSynchronisedVehicle = _synchronisedVehicles; + + /* Search for stations to sync in both directions from the current tile. + * We allow for some space between stations, and every time a station + * is found we allow for space between that and the next. + */ + + int32_t direction = tileElement->GetDirectionWithOffset(1); + constexpr uint8_t maxCheckDistance = kRideAdjacencyCheckDistance; + uint8_t spaceBetween = maxCheckDistance; + + while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) + { + location += CoordsXYZ{ CoordsDirectionDelta[direction], 0 }; + if (try_add_synchronised_station(location)) + { + spaceBetween = maxCheckDistance; + continue; + } + if (spaceBetween-- == 0) + { + break; + } + } + + // Other search direction. + location = station.GetStart(); + direction = DirectionReverse(direction) & 3; + spaceBetween = maxCheckDistance; + while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) + { + location += CoordsXYZ{ CoordsDirectionDelta[direction], 0 }; + if (try_add_synchronised_station(location)) + { + spaceBetween = maxCheckDistance; + continue; + } + if (spaceBetween-- == 0) + { + break; + } + } + + if (_lastSynchronisedVehicle == _synchronisedVehicles) + { + // No adjacent stations, allow depart + return true; + } + + for (SynchronisedVehicle* sv = _synchronisedVehicles; sv < _lastSynchronisedVehicle; sv++) + { + Ride* sv_ride = GetRide(sv->ride_id); + + if (!sv_ride->flags.has(RideFlag::brokenDown)) + { + if (sv_ride->status != RideStatus::closed) + { + if (sv_ride->isBlockSectioned()) + { + if (!(sv_ride->getStation(sv->stationIndex).Depart & kStationDepartFlag)) + { + sv = _synchronisedVehicles; + RideId rideId = RideId::GetNull(); + for (; sv < _lastSynchronisedVehicle; sv++) + { + if (rideId.IsNull()) + { + rideId = sv->ride_id; + } + if (rideId != sv->ride_id) + { + // Here the sync-ed stations are not all from the same ride. + return false; + } + } + + /* Here all the of sync-ed stations are from the same ride */ + auto curRide = GetRide(rideId); + if (curRide != nullptr) + { + for (int32_t i = 0; i < curRide->numTrains; i++) + { + Vehicle* v = getGameState().entities.GetEntity(curRide->vehicles[i]); + if (v == nullptr) + { + continue; + } + if (v->status != Vehicle::Status::waitingToDepart && v->velocity != 0) + { + // Here at least one vehicle on the ride is moving. + return false; + } + } + } + + // UNCERTAIN: is the return desired here, or rather continue on with the general checks? + return true; + } + } + // There is no vehicle waiting at this station to sync with. + if (sv->vehicle_id.IsNull()) + { + // Check conditions for departing without all stations being in sync. + if (_lastSynchronisedVehicle > &_synchronisedVehicles[1]) + { + // Sync condition: there are at least 3 stations to sync + return false; + } + RideId someRideIndex = _synchronisedVehicles[0].ride_id; + if (someRideIndex != ride.id) + { + // Sync condition: the first station to sync is a different ride + return false; + } + + int32_t numTrainsAtStation = 0; + int32_t numTravelingTrains = 0; + auto currentStation = sv->stationIndex; + for (int32_t i = 0; i < sv_ride->numTrains; i++) + { + auto* otherVehicle = getGameState().entities.GetEntity(sv_ride->vehicles[i]); + if (otherVehicle == nullptr) + { + continue; + } + if (otherVehicle->status != Vehicle::Status::travelling) + { + if (currentStation == otherVehicle->current_station) + { + if (otherVehicle->status == Vehicle::Status::waitingToDepart + || otherVehicle->status == Vehicle::Status::movingToEndOfStation) + { + numTrainsAtStation++; + } + } + } + else + { + numTravelingTrains++; + } + } + + int32_t totalTrains = numTrainsAtStation + numTravelingTrains; + if (totalTrains != sv_ride->numTrains || numTravelingTrains >= sv_ride->numTrains / 2) + { + // if (numArrivingTrains > 0 || numTravelingTrains >= sv_ride->numTrains / 2) { + /* Sync condition: If there are trains arriving at the + * station or half or more of the ride trains are + * travelling, this station must be sync-ed before the + * trains can depart! */ + return false; + } + + /* Sync exception - train is not arriving at the station + * and there are less than half the trains for the ride + * travelling. */ + } + } + } + } + + // At this point all vehicles in _snychronisedVehicles can depart. + for (SynchronisedVehicle* sv = _synchronisedVehicles; sv < _lastSynchronisedVehicle; sv++) + { + auto v = getGameState().entities.GetEntity(sv->vehicle_id); + if (v != nullptr) + { + v->flags.unset(VehicleFlag::waitingOnAdjacentStation); + } + } + + return true; +} + +bool Vehicle::CanDepartSynchronised() const +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return false; + return ride_station_can_depart_synchronised(*curRide, current_station); +} + +/** + * + * rct2: 0x006D7BCC + */ +void Vehicle::UpdateMovingToEndOfStation() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + int32_t curFlags = 0; + int32_t station = 0; + + switch (curRide->mode) + { + case RideMode::upwardLaunch: + case RideMode::rotatingLift: + case RideMode::downwardLaunch: + case RideMode::freefallDrop: + if (velocity >= -131940) + { + acceleration = -3298; + } + else + { + velocity -= velocity / 16; + acceleration = 0; + } + curFlags = UpdateTrackMotion(&station); + if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_5)) + break; + [[fallthrough]]; + case RideMode::dodgems: + case RideMode::swing: + case RideMode::rotation: + case RideMode::forwardRotation: + case RideMode::backwardRotation: + case RideMode::filmAvengingAviators: + case RideMode::filmThrillRiders: + case RideMode::beginners: + case RideMode::intense: + case RideMode::berserk: + case RideMode::mouseTails3DFilm: + case RideMode::stormChasers3DFilm: + case RideMode::spaceRaiders3DFilm: + case RideMode::spaceRings: + case RideMode::hauntedHouse: + case RideMode::crookedHouse: + case RideMode::circus: + current_station = StationIndex::FromUnderlying(0); + velocity = 0; + acceleration = 0; + SetState(Status::waitingForPassengers); + break; + default: + { + const auto* rideEntry = GetRideEntry(); + if (rideEntry == nullptr) + { + return; + } + + const auto& carEntry = rideEntry->Cars[vehicle_type]; + + if (!carEntry.flags.has(CarEntryFlag::isPowered)) + { + if (velocity <= 131940) + { + acceleration = 3298; + } + } + if (velocity > 131940) + { + velocity -= velocity / 16; + acceleration = 0; + } + + curFlags = UpdateTrackMotion(&station); + + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1) + { + velocity = 0; + acceleration = 0; + sub_state++; + + if (curRide->mode == RideMode::race && sub_state >= 40) + { + SetState(Status::waitingForPassengers); + break; + } + } + else + { + if (velocity > 98955) + { + sub_state = 0; + } + } + + if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION)) + break; + + current_station = StationIndex::FromUnderlying(station); + velocity = 0; + acceleration = 0; + SetState(Status::waitingForPassengers); + break; + } + } +} + +/** + * + * rct2: 0x006D7FB4 + */ +void Vehicle::TrainReadyToDepart(uint8_t num_peeps_on_train, uint8_t num_used_seats) +{ + if (num_peeps_on_train != num_used_seats) + return; + + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if (curRide->status == RideStatus::open && !curRide->flags.has(RideFlag::brokenDown) + && !flags.has(VehicleFlag::readyToDepart)) + { + return; + } + + if (!curRide->flags.has(RideFlag::brokenDown)) + { + const auto& rtd = curRide->getRideTypeDescriptor(); + // Original code did not check if the ride was a boat hire, causing empty boats to leave the platform when closing a + // Boat Hire with passengers on it. + if (curRide->status != RideStatus::closed || (curRide->numRiders != 0 && rtd.specialType != RtdSpecialType::boatHire)) + { + curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; + sub_state = 2; + return; + } + } + + if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) + { + uint8_t seat = ((-flatRideAnimationFrame) / 8) & 0xF; + if (!peep[seat].IsNull()) + { + curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; + SetState(Status::unloadingPassengers); + return; + } + + if (num_peeps == 0) + return; + + curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; + sub_state = 2; + return; + } + + if (num_peeps_on_train == 0) + return; + + curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; + SetState(Status::waitingForPassengers); +} + +/** + * + * rct2: 0x006D7DA1 + */ +void Vehicle::UpdateWaitingForPassengers() +{ + velocity = 0; + + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if (sub_state == 0) + { + if (!OpenRestraints()) + return; + + auto& station = curRide->getStation(current_station); + if (station.Entrance.IsNull()) + { + station.TrainAtStation = RideStation::kNoTrain; + sub_state = 2; + return; + } + + auto trainIndex = ride_get_train_index_from_vehicle(*curRide, Id); + if (!trainIndex.has_value()) + { + return; + } + + if (station.TrainAtStation != RideStation::kNoTrain) + return; + + station.TrainAtStation = trainIndex.value(); + sub_state = 1; + time_waiting = 0; + + Invalidate(); + return; + } + if (sub_state == 1) + { + if (time_waiting != 0xFFFF) + time_waiting++; + + flags.unset(VehicleFlag::readyToDepart); + + // 0xF64E31, 0xF64E32, 0xF64E33 + uint8_t num_peeps_on_train = 0, num_used_seats_on_train = 0, num_seats_on_train = 0; + + for (const Vehicle* trainCar = getGameState().entities.GetEntity(Id); trainCar != nullptr; + trainCar = getGameState().entities.GetEntity(trainCar->next_vehicle_on_train)) + { + num_peeps_on_train += trainCar->num_peeps; + num_used_seats_on_train += trainCar->next_free_seat; + num_seats_on_train += trainCar->num_seats; + } + + num_seats_on_train &= 0x7F; + + if (curRide->supportsStatus(RideStatus::testing)) + { + if (time_waiting < 20) + { + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + } + else + { + if (num_peeps_on_train == 0) + { + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + } + + if (curRide->getRideTypeDescriptor().flags.has(RtdFlag::hasLoadOptions)) + { + if (curRide->departFlags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH) + { + if (curRide->minWaitingTime * 32 > time_waiting) + { + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + } + if (curRide->departFlags & RIDE_DEPART_WAIT_FOR_MAXIMUM_LENGTH) + { + if (curRide->maxWaitingTime * 32 < time_waiting) + { + flags.set(VehicleFlag::readyToDepart); + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + } + } + + if (curRide->departFlags & RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES) + { + for (auto train_id : curRide->vehicles) + { + if (train_id == Id) + continue; + + Vehicle* train = getGameState().entities.GetEntity(train_id); + if (train == nullptr) + continue; + + if (train->status == Status::unloadingPassengers || train->status == Status::movingToEndOfStation) + { + if (train->current_station == current_station) + { + flags.set(VehicleFlag::readyToDepart); + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + } + } + } + + if (curRide->getRideTypeDescriptor().flags.has(RtdFlag::hasLoadOptions) + && curRide->departFlags & RIDE_DEPART_WAIT_FOR_LOAD) + { + if (num_peeps_on_train == num_seats_on_train) + { + flags.set(VehicleFlag::readyToDepart); + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + + // any load: load=4 , full: load=3 , 3/4s: load=2 , half: load=1 , quarter: load=0 + uint8_t load = curRide->departFlags & RIDE_DEPART_WAIT_FOR_LOAD_MASK; + + // We want to wait for ceiling((load+1)/4 * num_seats_on_train) peeps, the +3 below is used instead of + // ceil() to prevent issues on different cpus/platforms with floats. Note that vanilla RCT1/2 rounded + // down here; our change reflects the expected behaviour for waiting for a minimum load target (see #9987) + uint8_t peepTarget = ((load + 1) * num_seats_on_train + 3) / 4; + + if (load == 4) // take care of "any load" special case + peepTarget = 1; + + if (num_peeps_on_train >= peepTarget) + flags.set(VehicleFlag::readyToDepart); + + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + + flags.set(VehicleFlag::readyToDepart); + TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); + return; + } + + if (!CloseRestraints()) + return; + + velocity = 0; + flags.unset(VehicleFlag::waitingOnAdjacentStation); + + if (curRide->departFlags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS) + { + flags.set(VehicleFlag::waitingOnAdjacentStation); + } + + SetState(Status::waitingToDepart); +} + +/** + * + * rct2: 0x006D80BE + */ +void Vehicle::UpdateWaitingToDepart() +{ + auto* curRide = GetRide(); + if (curRide == nullptr) + return; + + const auto& currentStation = curRide->getStation(current_station); + + bool shouldBreak = false; + if (curRide->flags.has(RideFlag::brokenDown)) + { + switch (curRide->breakdownReasonPending) + { + case BREAKDOWN_RESTRAINTS_STUCK_CLOSED: + case BREAKDOWN_RESTRAINTS_STUCK_OPEN: + case BREAKDOWN_DOORS_STUCK_CLOSED: + case BREAKDOWN_DOORS_STUCK_OPEN: + break; + default: + shouldBreak = true; + break; + } + } + + bool skipCheck = false; + if (shouldBreak || curRide->status != RideStatus::open) + { + if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) + { + uint8_t seat = ((-flatRideAnimationFrame) >> 3) & 0xF; + if (peep[seat * 2].IsNull()) + { + if (num_peeps == 0) + { + skipCheck = true; + } + } + else + { + if (!currentStation.Exit.IsNull()) + { + SetState(Status::unloadingPassengers); + return; + } + } + } + else + { + for (const Vehicle* trainCar = getGameState().entities.GetEntity(Id); trainCar != nullptr; + trainCar = getGameState().entities.GetEntity(trainCar->next_vehicle_on_train)) + { + if (trainCar->num_peeps != 0) + { + if (!currentStation.Exit.IsNull()) + { + SetState(Status::unloadingPassengers); + return; + } + break; + } + } + } + } + + if (!skipCheck) + { + if (!(currentStation.Depart & kStationDepartFlag)) + return; + } + + if (curRide->getRideTypeDescriptor().flags.has(RtdFlag::canSynchroniseWithAdjacentStations)) + { + if (curRide->departFlags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS) + { + if (flags.has(VehicleFlag::waitingOnAdjacentStation)) + { + if (!CanDepartSynchronised()) + { + return; + } + } + } + } + + SetState(Status::departing); + + if (curRide->flags.has(RideFlag::cableLift)) + { + CoordsXYE track; + int32_t zUnused; + int32_t direction; + + uint8_t trackDirection = GetTrackDirection(); + if (TrackBlockGetNextFromZero(TrackLocation, *curRide, trackDirection, &track, &zUnused, &direction, false)) + { + if (track.element->AsTrack()->HasCableLift()) + { + SetState(Status::waitingForCableLift, sub_state); + } + } + } + + switch (curRide->mode) + { + case RideMode::dodgems: + // Dodgems mode uses sub_state and TimeActive to tell how long + // the vehicle has been ridden. + SetState(Status::travellingDodgems); + TimeActive = 0; + UpdateDodgemsMode(); + break; + case RideMode::swing: + SetState(Status::swinging); + NumSwings = 0; + current_time = -1; + UpdateSwinging(); + break; + case RideMode::rotation: + SetState(Status::rotating); + NumRotations = 0; + current_time = -1; + UpdateRotating(); + break; + case RideMode::filmAvengingAviators: + SetState(Status::simulatorOperating); + current_time = -1; + UpdateSimulatorOperating(); + break; + case RideMode::filmThrillRiders: + SetState(Status::simulatorOperating, 1); + current_time = -1; + UpdateSimulatorOperating(); + break; + case RideMode::beginners: + case RideMode::intense: + case RideMode::berserk: + SetState(Status::topSpinOperating, sub_state); + switch (curRide->mode) + { + case RideMode::beginners: + sub_state = 0; + break; + case RideMode::intense: + sub_state = 1; + break; + case RideMode::berserk: + sub_state = 2; + break; + default: + { + // This is workaround for multiple compilation errors of type "enumeration value 'RIDE_MODE_*' not handled + // in switch [-Werror=switch]" + } + } + current_time = -1; + flatRideAnimationFrame = 0; + flatRideSecondaryAnimationFrame = 0; + UpdateTopSpinOperating(); + break; + case RideMode::forwardRotation: + case RideMode::backwardRotation: + SetState(Status::ferrisWheelRotating, flatRideAnimationFrame); + NumRotations = 0; + ferris_wheel_var_0 = 8; + ferris_wheel_var_1 = 8; + UpdateFerrisWheelRotating(); + break; + case RideMode::mouseTails3DFilm: + case RideMode::stormChasers3DFilm: + case RideMode::spaceRaiders3DFilm: + SetState(Status::showingFilm, sub_state); + switch (curRide->mode) + { + case RideMode::mouseTails3DFilm: + sub_state = 0; + break; + case RideMode::stormChasers3DFilm: + sub_state = 1; + break; + case RideMode::spaceRaiders3DFilm: + sub_state = 2; + break; + default: + { + // This is workaround for multiple compilation errors of type "enumeration value 'RIDE_MODE_*' not handled + // in switch [-Werror=switch]" + } + } + current_time = -1; + UpdateShowingFilm(); + break; + case RideMode::circus: + SetState(Status::doingCircusShow); + current_time = -1; + UpdateDoingCircusShow(); + break; + case RideMode::spaceRings: + SetState(Status::spaceRingsOperating); + flatRideAnimationFrame = 0; + current_time = -1; + UpdateSpaceRingsOperating(); + break; + case RideMode::hauntedHouse: + SetState(Status::hauntedHouseOperating); + flatRideAnimationFrame = 0; + current_time = -1; + UpdateHauntedHouseOperating(); + break; + case RideMode::crookedHouse: + SetState(Status::crookedHouseOperating); + flatRideAnimationFrame = 0; + current_time = -1; + UpdateCrookedHouseOperating(); + break; + default: + SetState(status); + NumLaps = 0; + break; + } +} + +/** + * + * rct2: 0x006D9002 + */ +void Vehicle::UpdateUnloadingPassengers() +{ + if (sub_state == 0) + { + if (OpenRestraints()) + { + sub_state = 1; + } + } + + const auto* curRide = GetRide(); + if (curRide == nullptr) + return; + + const auto& currentStation = curRide->getStation(current_station); + + if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) + { + uint8_t seat = ((-flatRideAnimationFrame) >> 3) & 0xF; + if (restraints_position == 255 && !peep[seat * 2].IsNull()) + { + next_free_seat -= 2; + + auto firstGuest = getGameState().entities.GetEntity(peep[seat * 2]); + peep[seat * 2] = EntityId::GetNull(); + + if (firstGuest != nullptr) + { + firstGuest->SetState(PeepState::leavingRide); + firstGuest->RideSubState = PeepRideSubState::leaveVehicle; + } + + auto secondGuest = getGameState().entities.GetEntity(peep[seat * 2 + 1]); + peep[seat * 2 + 1] = EntityId::GetNull(); + + if (secondGuest != nullptr) + { + secondGuest->SetState(PeepState::leavingRide); + secondGuest->RideSubState = PeepRideSubState::leaveVehicle; + } + } + } + else + { + if (currentStation.Exit.IsNull()) + { + if (sub_state != 1) + return; + + if (!curRide->flags.has(RideFlag::tested) && flags.has(VehicleFlag::testing) + && curRide->currentTestSegment + 1 >= curRide->numStations) + { + UpdateTestFinish(); + } + SetState(Status::movingToEndOfStation); + return; + } + + for (Vehicle* train = getGameState().entities.GetEntity(Id); train != nullptr; + train = getGameState().entities.GetEntity(train->next_vehicle_on_train)) + { + if (train->restraints_position != 255) + continue; + + if (train->next_free_seat == 0) + continue; + + train->next_free_seat = 0; + for (uint8_t peepIndex = 0; peepIndex < train->num_peeps; peepIndex++) + { + Peep* curPeep = getGameState().entities.GetEntity(train->peep[peepIndex]); + if (curPeep != nullptr) + { + curPeep->SetState(PeepState::leavingRide); + curPeep->RideSubState = PeepRideSubState::leaveVehicle; + } + } + } + } + + if (sub_state != 1) + return; + + for (Vehicle* train = getGameState().entities.GetEntity(Id); train != nullptr; + train = getGameState().entities.GetEntity(train->next_vehicle_on_train)) + { + if (train->num_peeps != train->next_free_seat) + return; + } + + if (!curRide->flags.has(RideFlag::tested) && flags.has(VehicleFlag::testing) + && curRide->currentTestSegment + 1 >= curRide->numStations) + { + UpdateTestFinish(); + } + SetState(Status::movingToEndOfStation); +} + +/** + * + * rct2: 0x006D845B + */ +void Vehicle::UpdateDeparting() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + const auto* rideEntry = GetRideEntry(); + if (rideEntry == nullptr) + return; + + if (sub_state == 0) + { + if (flags.has(VehicleFlag::trainIsBroken)) + { + if (curRide->flags.has(RideFlag::brokenDown)) + return; + + curRide->flags.set(RideFlag::brokenDown); + RideBreakdownAddNewsItem(*curRide); + + curRide->windowInvalidateFlags.set( + RideInvalidateFlag::main, RideInvalidateFlag::list, RideInvalidateFlag::maintenance); + curRide->mechanicStatus = MechanicStatus::calling; + curRide->inspectionStation = current_station; + curRide->breakdownReason = curRide->breakdownReasonPending; + velocity = 0; + return; + } + + sub_state = 1; + PeepEasterEggHereWeAre(); + + if (rideEntry->flags.has(RideEntryFlag::playDepartSound)) + { + auto soundId = (rideEntry->Cars[0].soundRange == SoundRange::tramBell) ? SoundId::tram : SoundId::trainDeparting; + Play3D(soundId, GetLocation()); + } + + if (curRide->mode == RideMode::upwardLaunch || (curRide->mode == RideMode::downwardLaunch && NumLaunches > 1)) + { + Play3D(SoundId::rideLaunch2, GetLocation()); + } + + if (!curRide->flags.has(RideFlag::tested)) + { + if (flags.has(VehicleFlag::testing)) + { + if (curRide->currentTestSegment + 1 < curRide->numStations) + { + curRide->currentTestSegment++; + curRide->currentTestStation = current_station; + } + else + { + UpdateTestFinish(); + } + } + else if (!curRide->flags.has(RideFlag::testInProgress) && !IsGhost()) + { + TestReset(); + } + } + } + + const auto& carEntry = rideEntry->Cars[vehicle_type]; + const auto& rtd = curRide->getRideTypeDescriptor(); + switch (curRide->mode) + { + case RideMode::reverseInclineLaunchedShuttle: + if (velocity >= -131940) + acceleration = -3298; + break; + case RideMode::poweredLaunchPasstrough: + case RideMode::poweredLaunch: + case RideMode::poweredLaunchBlockSectioned: + case RideMode::limPoweredLaunch: + case RideMode::upwardLaunch: + if ((curRide->launchSpeed << 16) > velocity) + { + acceleration = curRide->launchSpeed << rtd.BoosterSettings.AccelerationFactor; + } + break; + case RideMode::downwardLaunch: + if (NumLaunches >= 1) + { + if ((14 << 16) > velocity) + acceleration = 14 << 12; + break; + } + [[fallthrough]]; + case RideMode::continuousCircuit: + case RideMode::continuousCircuitBlockSectioned: + case RideMode::rotatingLift: + case RideMode::freefallDrop: + case RideMode::boatHire: + if (carEntry.flags.has(CarEntryFlag::isPowered)) + break; + + if (velocity <= 131940) + acceleration = 3298; + break; + default: + { + // This is workaround for multiple compilation errors of type "enumeration value ‘RIDE_MODE_*' not handled + // in switch [-Werror=switch]" + } + } + + uint32_t curFlags = UpdateTrackMotion(nullptr); + + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_8) + { + if (curRide->mode == RideMode::reverseInclineLaunchedShuttle) + { + velocity = -velocity; + FinishDeparting(); + return; + } + } + + if (curFlags & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_5 | VEHICLE_UPDATE_MOTION_TRACK_FLAG_12)) + { + if (curRide->mode == RideMode::boatHire) + { + UpdateDepartingBoatHire(); + return; + } + if (curRide->mode == RideMode::reverseInclineLaunchedShuttle) + { + velocity = -velocity; + FinishDeparting(); + return; + } + if (curRide->mode == RideMode::shuttle) + { + flags.flip(VehicleFlag::poweredCarInReverse); + velocity = 0; + + // We have turned, so treat it like entering a new tile + UpdateCrossings(); + } + } + + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL) + { + sound2_flags |= VEHICLE_SOUND2_FLAGS_LIFT_HILL; + if (curRide->mode != RideMode::reverseInclineLaunchedShuttle) + { + int32_t curSpeed = curRide->liftHillSpeed * 31079; + if (velocity <= curSpeed) + { + acceleration = 15539; + if (velocity != 0) + { + if (_vehicleBreakdown == BREAKDOWN_SAFETY_CUT_OUT) + { + flags.set(VehicleFlag::stoppedBySafetyCutout); + flags.unset(VehicleFlag::collisionDisabled); + } + } + else + flags.unset(VehicleFlag::collisionDisabled); + } + } + else + { + int32_t curSpeed = curRide->liftHillSpeed * -31079; + if (velocity >= curSpeed) + { + acceleration = -15539; + if (velocity != 0) + { + if (_vehicleBreakdown == BREAKDOWN_SAFETY_CUT_OUT) + { + flags.set(VehicleFlag::stoppedBySafetyCutout); + flags.unset(VehicleFlag::collisionDisabled); + } + } + else + flags.unset(VehicleFlag::collisionDisabled); + } + } + } + + if (curRide->mode == RideMode::freefallDrop) + { + animation_frame++; + } + else + { + bool shouldLaunch = true; + if (curRide->mode == RideMode::downwardLaunch) + { + if (NumLaunches < 1) + shouldLaunch = false; + } + + if (shouldLaunch) + { + if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_3) || _vehicleStationIndex != current_station) + { + FinishDeparting(); + return; + } + + if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_5)) + return; + if (curRide->mode == RideMode::boatHire || curRide->mode == RideMode::rotatingLift + || curRide->mode == RideMode::shuttle) + return; + + UpdateCrashSetup(); + return; + } + } + + if (!CurrentTowerElementIsTop()) + { + if (curRide->mode == RideMode::freefallDrop) + Invalidate(); + return; + } + + FinishDeparting(); +} + +/** + * Part of UpdateDeparting + * Called after finishing departing sequence to enter + * traveling state. + * Vertical rides class the lift to the top of the tower + * as the departing sequence. After this point station + * boosters do not affect the ride. + * rct2: 0x006D8858 + */ +void Vehicle::FinishDeparting() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if (curRide->mode == RideMode::downwardLaunch) + { + if (NumLaunches >= 1 && (14 << 16) > velocity) + return; + + Play3D(SoundId::rideLaunch1, GetLocation()); + } + + if (curRide->mode == RideMode::upwardLaunch) + { + if ((curRide->launchSpeed << 16) > velocity) + return; + + Play3D(SoundId::rideLaunch1, GetLocation()); + } + + if (curRide->mode != RideMode::race && !curRide->isBlockSectioned()) + { + auto& currentStation = curRide->getStation(current_station); + currentStation.Depart &= kStationDepartFlag; + uint8_t waitingTime = 3; + if (curRide->departFlags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH) + { + waitingTime = std::max(curRide->minWaitingTime, static_cast(3)); + waitingTime = std::min(waitingTime, static_cast(127)); + } + + currentStation.Depart |= waitingTime; + } + lost_time_out = 0; + SetState(Status::travelling, 1); + if (velocity < 0) + sub_state = 0; +} + +/** + * + * rct2: 0x006DE5CB + */ +void Vehicle::CheckIfMissing() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + if (curRide->flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) + return; + + if (curRide->isBlockSectioned()) + return; + + if (!curRide->getRideTypeDescriptor().flags.has(RtdFlag::checkForStalling)) + return; + + lost_time_out++; + if (curRide->flags.has(RideFlag::hasStalledVehicle)) + return; + + uint16_t limit = curRide->type == RIDE_TYPE_BOAT_HIRE ? 15360 : 9600; + + if (lost_time_out <= limit) + return; + + curRide->flags.set(RideFlag::hasStalledVehicle); + + if (Config::Get().notifications.rideStalledVehicles) + { + Formatter ft; + ft.Add(GetRideComponentName(GetRideTypeDescriptor(curRide->type).NameConvention.vehicle).number); + + uint8_t vehicleIndex = 0; + for (; vehicleIndex < curRide->numTrains; ++vehicleIndex) + if (curRide->vehicles[vehicleIndex] == Id) + break; + + vehicleIndex++; + ft.Add(vehicleIndex); + curRide->formatNameTo(ft); + ft.Add(GetRideComponentName(GetRideTypeDescriptor(curRide->type).NameConvention.station).singular); + + News::AddItemToQueue(News::ItemType::ride, STR_NEWS_VEHICLE_HAS_STALLED, ride.ToUnderlying(), ft); + } +} + +/** + * + * rct2: 0x006D8937 + */ +void Vehicle::UpdateTravelling() +{ + CheckIfMissing(); + + auto curRide = GetRide(); + if (curRide == nullptr || (_vehicleBreakdown == 0 && curRide->mode == RideMode::rotatingLift)) + return; + + if (sub_state == 2) + { + velocity = 0; + acceleration = 0; + var_C0--; + if (var_C0 == 0) + sub_state = 0; + } + + if (curRide->mode == RideMode::freefallDrop && animation_frame != 0) + { + animation_frame++; + velocity = 0; + acceleration = 0; + Invalidate(); + return; + } + + uint32_t curFlags = UpdateTrackMotion(nullptr); + + bool skipCheck = false; + if (curFlags & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_8 | VEHICLE_UPDATE_MOTION_TRACK_FLAG_9) + && curRide->mode == RideMode::reverseInclineLaunchedShuttle && sub_state == 0) + { + sub_state = 1; + velocity = 0; + skipCheck = true; + } + + if (!skipCheck) + { + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_DERAILED) + { + UpdateCrashSetup(); + return; + } + + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION) + { + UpdateCollisionSetup(); + return; + } + + if (curFlags & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_5 | VEHICLE_UPDATE_MOTION_TRACK_FLAG_12)) + { + if (curRide->mode == RideMode::rotatingLift) + { + if (sub_state <= 1) + { + SetState(Status::arriving, 1); + var_C0 = 0; + return; + } + } + else if (curRide->mode == RideMode::boatHire) + { + UpdateTravellingBoatHireSetup(); + return; + } + if (curRide->mode == RideMode::shuttle) + { + flags.flip(VehicleFlag::poweredCarInReverse); + velocity = 0; + } + else + { + if (sub_state != 0) + { + UpdateCrashSetup(); + return; + } + sub_state = 1; + velocity = 0; + } + } + } + + if (curRide->mode == RideMode::rotatingLift && sub_state <= 1) + { + if (sub_state == 0) + { + if (velocity >= -131940) + acceleration = -3298; + velocity = std::max(velocity, -131940); + } + else + { + if (CurrentTowerElementIsTop()) + { + velocity = 0; + sub_state = 2; + var_C0 = 150; + } + else + { + if (velocity <= 131940) + acceleration = 3298; + } + } + } + + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL) + { + if (curRide->mode == RideMode::reverseInclineLaunchedShuttle) + { + if (sub_state == 0) + { + if (velocity != 0) + sound2_flags |= VEHICLE_SOUND2_FLAGS_LIFT_HILL; + + if (!flags.has(VehicleFlag::reverseInclineCompletedLap)) + { + if (velocity >= curRide->liftHillSpeed * -31079) + { + acceleration = -15539; + + if (_vehicleBreakdown == 0) + { + sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; + flags.set(VehicleFlag::stoppedBySafetyCutout); + } + } + } + } + } + else + { + sound2_flags |= VEHICLE_SOUND2_FLAGS_LIFT_HILL; + if (velocity <= curRide->liftHillSpeed * 31079) + { + acceleration = 15539; + if (velocity != 0) + { + if (_vehicleBreakdown == 0) + { + flags.set(VehicleFlag::stoppedBySafetyCutout); + sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; + } + } + else + { + sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; + } + } + } + } + + if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_3)) + return; + + if (curRide->mode == RideMode::reverseInclineLaunchedShuttle && velocity >= 0 + && !flags.has(VehicleFlag::reverseInclineCompletedLap)) + { + return; + } + + if (curRide->mode == RideMode::poweredLaunchPasstrough && velocity < 0) + return; + + SetState(Status::arriving); + current_station = _vehicleStationIndex; + var_C0 = 0; + if (velocity < 0) + sub_state = 1; +} + +void Vehicle::UpdateArrivingPassThroughStation(const Ride& curRide, const CarEntry& carEntry, bool stationBrakesWork) +{ + if (sub_state == 0) + { + if (curRide.mode == RideMode::race && curRide.flags.has(RideFlag::passStationNoStopping)) + { + return; + } + + if (velocity <= 131940) + { + acceleration = 3298; + return; + } + + int32_t velocity_diff = velocity; + if (velocity_diff >= 24.0_mph) + velocity_diff /= 8; + else + velocity_diff /= 16; + + if (!stationBrakesWork) + { + return; + } + + if (curRide.numCircuits != 1) + { + if (NumLaps + 1 < curRide.numCircuits) + { + return; + } + } + velocity -= velocity_diff; + acceleration = 0; + } + else + { + if (!carEntry.flags.has(CarEntryFlag::isPowered) && velocity >= -131940) + { + acceleration = -3298; + } + + if (velocity >= -131940) + { + return; + } + + int32_t velocity_diff = velocity; + if (velocity_diff < -24.0_mph) + velocity_diff /= 8; + else + velocity_diff /= 16; + + if (!stationBrakesWork) + { + return; + } + + if (NumLaps + 1 < curRide.numCircuits) + { + return; + } + + if (NumLaps + 1 != curRide.numCircuits) + { + velocity -= velocity_diff; + acceleration = 0; + return; + } + + if (GetRideTypeDescriptor(curRide.type).flags.has(RtdFlag::allowMultipleCircuits) && curRide.mode != RideMode::shuttle + && curRide.mode != RideMode::poweredLaunch) + { + flags.set(VehicleFlag::reverseInclineCompletedLap); + } + else + { + velocity -= velocity_diff; + acceleration = 0; + } + } +} + +/** + * + * rct2: 0x006D8C36 + */ +void Vehicle::UpdateArriving() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + uint32_t curFlags = 0; + + switch (curRide->mode) + { + case RideMode::swing: + case RideMode::rotation: + case RideMode::forwardRotation: + case RideMode::backwardRotation: + case RideMode::filmAvengingAviators: + case RideMode::filmThrillRiders: + case RideMode::beginners: + case RideMode::intense: + case RideMode::berserk: + case RideMode::mouseTails3DFilm: + case RideMode::stormChasers3DFilm: + case RideMode::spaceRaiders3DFilm: + case RideMode::circus: + case RideMode::spaceRings: + case RideMode::hauntedHouse: + case RideMode::crookedHouse: + flags.unset(VehicleFlag::reverseInclineCompletedLap); + velocity = 0; + acceleration = 0; + SetState(Status::unloadingPassengers); + return; + default: + { + // This is workaround for multiple compilation errors of type "enumeration value ‘RIDE_MODE_*' not handled + // in switch [-Werror=switch]" + } + } + + auto stationBrakesWork = !curRide->hasFailingBrakes(); + + const auto* rideEntry = GetRideEntry(); + const auto& carEntry = rideEntry->Cars[vehicle_type]; + + UpdateArrivingPassThroughStation(*curRide, carEntry, stationBrakesWork); + + curFlags = UpdateTrackMotion(nullptr); + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION && !stationBrakesWork) + { + UpdateCollisionSetup(); + return; + } + + if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION && !stationBrakesWork) + { + SetState(Status::departing, 1); + return; + } + + if (!(curFlags + & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION | VEHICLE_UPDATE_MOTION_TRACK_FLAG_1 + | VEHICLE_UPDATE_MOTION_TRACK_FLAG_5))) + { + if (velocity > 98955) + var_C0 = 0; + return; + } + + var_C0++; + if ((curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1) && carEntry.flags.has(CarEntryFlag::isGoKart) && (var_C0 < 40)) + { + return; + } + + auto trackElement = MapGetTrackElementAt(TrackLocation); + + if (trackElement == nullptr) + { + return; + } + + current_station = trackElement->GetStationIndex(); + NumLaps++; + + if (sub_state != 0) + { + if (NumLaps < curRide->numCircuits) + { + SetState(Status::departing, 1); + return; + } + + if (NumLaps == curRide->numCircuits && flags.has(VehicleFlag::reverseInclineCompletedLap)) + { + SetState(Status::departing, 1); + return; + } + } + + if (curRide->numCircuits != 1 && NumLaps < curRide->numCircuits) + { + SetState(Status::departing, 1); + return; + } + + if ((curRide->mode == RideMode::upwardLaunch || curRide->mode == RideMode::downwardLaunch) && NumLaunches < 2) + { + Play3D(SoundId::rideLaunch2, GetLocation()); + velocity = 0; + acceleration = 0; + SetState(Status::departing, 1); + return; + } + + if (curRide->mode == RideMode::race && curRide->flags.has(RideFlag::passStationNoStopping)) + { + SetState(Status::departing, 1); + return; + } + + flags.unset(VehicleFlag::reverseInclineCompletedLap); + velocity = 0; + acceleration = 0; + SetState(Status::unloadingPassengers); +} diff --git a/src/openrct2/ride/Vehicle.TrackMotion.cpp b/src/openrct2/ride/Vehicle.TrackMotion.cpp new file mode 100644 index 0000000000..3cb97e60c2 --- /dev/null +++ b/src/openrct2/ride/Vehicle.TrackMotion.cpp @@ -0,0 +1,1632 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Vehicle.h" + +#include "../Diagnostic.h" +#include "../GameState.h" +#include "../audio/Audio.h" +#include "../core/Speed.hpp" +#include "../entity/EntityRegistry.h" +#include "../entity/EntityTweener.h" +#include "../scenario/Scenario.h" +#include "../world/Map.h" +#include "../world/MapAnimation.h" +#include "../world/tile_element/TileElement.h" +#include "../world/tile_element/TrackElement.h" +#include "Ride.h" +#include "RideData.h" +#include "Track.h" +#include "TrackData.h" +#include "VehicleGeometry.h" + +using namespace OpenRCT2; +using namespace OpenRCT2::Audio; +using namespace OpenRCT2::TrackMetaData; +using namespace OpenRCT2::RideVehicle; + +// External globals from Vehicle.cpp +extern Vehicle* gCurrentVehicle; +extern uint8_t _vehicleBreakdown; +extern StationIndex _vehicleStationIndex; +extern uint32_t _vehicleMotionTrackFlags; +extern int32_t _vehicleVelocityF64E08; +extern int32_t _vehicleVelocityF64E0C; +extern int32_t _vehicleUnkF64E10; +extern uint8_t _vehicleF64E2C; +extern Vehicle* _vehicleFrontVehicle; +extern CoordsXYZ _vehicleCurPosition; + +// Constants +constexpr uint8_t kTrackSpeedShiftAmount = 16; +constexpr uint8_t kBoosterAccelerationShiftAmount = 16; +constexpr int16_t kVehicleMaxSpinSpeedWaterRide = 512; +constexpr int16_t kVehicleMinSpinSpeedWaterRide = -kVehicleMaxSpinSpeedWaterRide; + +/** + * + * rct2: 0x006DAB90 + */ +void Vehicle::UpdateTrackMotionUpStopCheck() const +{ + const auto* carEntry = Entry(); + if (carEntry == nullptr) + { + return; + } + + // No up stops (coaster types) + if (carEntry->flags.has(CarEntryFlag::hasNoUpstopWheels)) + { + if (!IsOnCoveredTrack()) + { + auto gForces = GetGForces(); + gForces.lateralG = std::abs(gForces.lateralG); + if (gForces.lateralG <= 150) + { + if (Geometry::getAccelerationFromPitch(pitch) < 0) + { + if (gForces.verticalG > -40) + { + return; + } + } + else if (gForces.verticalG > -80) + { + return; + } + } + + if (pitch != VehiclePitch::down60) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_DERAILED; + } + } + } + else if (carEntry->flags.has(CarEntryFlag::hasNoUpstopWheelsBobsleigh)) + { + // No up stops bobsleigh type + if (!IsOnCoveredTrack()) + { + auto gForces = GetGForces(); + + if (Geometry::getAccelerationFromPitch(pitch) < 0) + { + if (gForces.verticalG > -45) + { + return; + } + } + else + { + if (gForces.verticalG > -80) + { + return; + } + } + + if (pitch != VehiclePitch::down60 && pitch != VehiclePitch::down50) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_DERAILED; + } + } + } +} + +/** + * Modifies the train's velocity to match the block-brake fixed velocity. + * This function must be called when the car is running through a non-stopping + * state block-brake (precondition), which means that the block brake is acting + * merely as a velocity regulator, in a closed state. When the brake is open, it + * boosts the train to the speed limit + */ +void Vehicle::ApplyNonStopBlockBrake() +{ + if (velocity >= 0) + { + // If the vehicle is below the speed limit + if (velocity <= kBlockBrakeBaseSpeed) + { + // Boost it to the fixed block brake speed + velocity = kBlockBrakeBaseSpeed; + acceleration = 0; + } + else if (velocity > (brake_speed << kTrackSpeedShiftAmount) + kBlockBrakeSpeedOffset) + { + velocity -= velocity >> 4; + acceleration = 0; + } + } +} + +/** + * + * Modifies the train's velocity influenced by a block brake + */ +void Vehicle::ApplyStopBlockBrake() +{ + // Slow it down till completely stop the car + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE; + acceleration = 0; + // If the this is slow enough, stop it. If not, slow it down + if (velocity <= 2.0_mph) + { + velocity = 0; + } + else + { + velocity -= velocity >> 3; + } +} + +void Vehicle::ApplyCableLiftBlockBrake(bool brakeClosed) +{ + // If we are already on the cable lift, ignore the brake + if (status == Status::travellingCableLift) + return; + + // Slow down if travelling faster than 4mph + if (velocity > kBlockBrakeBaseSpeed) + { + velocity -= velocity >> 3; + acceleration = 0; + } + // Once moving slow enough, keep moving forward until lined up with the catch car + else if (track_progress <= 18) + { + velocity = kBlockBrakeBaseSpeed; + acceleration = 0; + } + // Once in position, stop, and wait for the catch car + if (velocity > 0 && track_progress >= 18) + { + velocity = 0; + acceleration = 0; + if (!brakeClosed) + SetState(Status::waitingForCableLift, sub_state); + else + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE; + } +} + +/** + * + * rct2: 0x006DAC43 + */ +void Vehicle::CheckAndApplyBlockSectionStopSite() +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return; + + auto carEntry = Entry(); + if (carEntry == nullptr) + return; + + // Is chair lift type + if (carEntry->flags.has(CarEntryFlag::isChairlift)) + { + velocity = _vehicleBreakdown == 0 ? 0 : curRide->speed << 16; + acceleration = 0; + } + + auto trackType = GetTrackType(); + + TileElement* trackElement = MapGetTrackElementAtOfType(TrackLocation, trackType); + + if (trackElement == nullptr) + { + return; + } + + switch (trackType) + { + case TrackElemType::blockBrakes: + // Check if this brake is the start of a cable lift + if (curRide->flags.has(RideFlag::cableLift)) + { + CoordsXYE track; + int32_t zUnused; + int32_t direction; + if (TrackBlockGetNextFromZero(TrackLocation, *curRide, GetTrackDirection(), &track, &zUnused, &direction, false) + && track.element != nullptr && track.element->AsTrack()->HasCableLift()) + { + ApplyCableLiftBlockBrake(curRide->isBlockSectioned() && trackElement->AsTrack()->IsBrakeClosed()); + break; + } + } + [[fallthrough]]; + case TrackElemType::diagBlockBrakes: + if (curRide->isBlockSectioned() && trackElement->AsTrack()->IsBrakeClosed()) + ApplyStopBlockBrake(); + else + ApplyNonStopBlockBrake(); + + break; + case TrackElemType::endStation: + if (trackElement->AsTrack()->IsBrakeClosed()) + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE; + + break; + case TrackElemType::up25ToFlat: + case TrackElemType::up60ToFlat: + case TrackElemType::cableLiftHill: + case TrackElemType::diagUp25ToFlat: + case TrackElemType::diagUp60ToFlat: + if (curRide->isBlockSectioned()) + { + if (trackType == TrackElemType::cableLiftHill || trackElement->AsTrack()->HasChain()) + { + if (trackElement->AsTrack()->IsBrakeClosed()) + { + ApplyStopBlockBrake(); + } + } + } + break; + default: + break; + } +} + +/** + * + * rct2: 0x006DADAE + */ +void Vehicle::UpdateVelocity() +{ + int32_t nextVelocity = acceleration + velocity; + if (flags.has(VehicleFlag::stoppedBySafetyCutout)) + { + nextVelocity = 0; + } + if (flags.has(VehicleFlag::stoppedOnHoldingBrake)) + { + if (vertical_drop_countdown > 0) + { + nextVelocity = 0; + acceleration = 0; + vertical_drop_countdown--; + } + } + velocity = nextVelocity; + + _vehicleVelocityF64E08 = nextVelocity; + _vehicleVelocityF64E0C = (nextVelocity >> 10) * 42; +} + +static void BlockBrakesOpenPreviousSection(const Ride& ride, const CoordsXYZ& vehicleTrackLocation, TileElement* tileElement) +{ + CoordsXYZ location = vehicleTrackLocation; + TrackElement* trackElement = TrackGetPreviousBlock(location, tileElement); + if (trackElement == nullptr) + return; + + SetBrakeClosedMultiTile(*trackElement, location, false); + MapInvalidateElement(location, reinterpret_cast(trackElement)); + + auto trackType = trackElement->GetTrackType(); + if (trackType == TrackElemType::endStation) + { + Play3D(SoundId::blockBrakeClose, location); + } + else if (TrackTypeIsBlockBrakes(trackType)) + { + Play3D(SoundId::blockBrakeClose, location); + BlockBrakeSetLinkedBrakesClosed(location, *trackElement, false); + } +} + +/** + * + * rct2: 0x006DB38B + */ +static PitchAndRoll PitchAndRollStart(bool useInvertedSprites, TileElement* tileElement) +{ + auto trackType = tileElement->AsTrack()->GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + return PitchAndRoll{ ted.definition.pitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) }; +} + +void Vehicle::UpdateGoKartAttemptSwitchLanes() +{ + uint16_t probability = 0x8000; + if (flags.has(VehicleFlag::currentlyColliding)) + { + flags.unset(VehicleFlag::currentlyColliding); + } + else + { + probability = 0x0A3D; + } + if ((ScenarioRand() & 0xFFFF) <= probability) + { + // This changes "riding left" to "moving to right lane" and "riding right" to "moving to left lane". + TrackSubposition = VehicleTrackSubposition{ static_cast(static_cast(TrackSubposition) + 2u) }; + } +} + +static void vehicle_update_play_water_splash_sound() +{ + if (_vehicleVelocityF64E08 <= kBlockBrakeBaseSpeed) + { + return; + } + + Play3D(SoundId::waterSplash, { _vehicleCurPosition.x, _vehicleCurPosition.y, _vehicleCurPosition.z }); +} + +/** + * + * rct2: 0x006DB59E + */ +void Vehicle::UpdateHandleWaterSplash() const +{ + const auto* rideEntry = GetRideEntry(); + auto trackType = GetTrackType(); + + if (!rideEntry->flags.has(RideEntryFlag::playSplashSound)) + { + if (rideEntry->flags.has(RideEntryFlag::playSplashSoundSlide)) + { + if (IsHead()) + { + if (IsOnCoveredTrack()) + { + Vehicle* nextVehicle = getGameState().entities.GetEntity(next_vehicle_on_ride); + if (nextVehicle == nullptr) + return; + + Vehicle* nextNextVehicle = getGameState().entities.GetEntity(nextVehicle->next_vehicle_on_ride); + if (nextNextVehicle == nullptr) + return; + if (!nextNextVehicle->IsOnCoveredTrack()) + { + if (track_progress == 4) + { + vehicle_update_play_water_splash_sound(); + } + } + } + } + } + } + else + { + if (trackType == TrackElemType::down25ToFlat) + { + if (track_progress == 12) + { + vehicle_update_play_water_splash_sound(); + } + } + } + if (IsHead()) + { + if (trackType == TrackElemType::waterSplash) + { + if (track_progress == 48) + { + vehicle_update_play_water_splash_sound(); + } + } + } +} + +/** + * + * rct2: 0x006DBF3E + */ +void Vehicle::Sub6DBF3E() +{ + const auto* carEntry = Entry(); + + acceleration /= _vehicleUnkF64E10; + if (TrackSubposition == VehicleTrackSubposition::ChairliftGoingBack) + { + return; + } + + auto trackType = GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin)) + { + return; + } + + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_3; + + TileElement* tileElement = nullptr; + if (MapIsLocationValid(TrackLocation)) + { + tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); + } + + if (tileElement == nullptr) + { + return; + } + + if (_vehicleStationIndex.IsNull()) + { + _vehicleStationIndex = tileElement->AsTrack()->GetStationIndex(); + } + + if (trackType == TrackElemType::towerBase && this == gCurrentVehicle) + { + if (track_progress > 3 && !flags.has(VehicleFlag::poweredCarInReverse)) + { + CoordsXYE output; + int32_t outputZ, outputDirection; + + CoordsXYE input = { TrackLocation, tileElement }; + if (!TrackBlockGetNext(&input, &output, &outputZ, &outputDirection)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_12; + } + } + + if (track_progress <= 3) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; + } + } + + if (trackType != TrackElemType::endStation || this != gCurrentVehicle) + { + return; + } + + uint16_t ax = track_progress; + if (_vehicleVelocityF64E08 < 0) + { + if (ax <= 22) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; + } + } + else + { + uint16_t cx = 17; + if (carEntry->flags.has(CarEntryFlag::isChairlift)) + { + cx = 6; + } + if (carEntry->flags.has(CarEntryFlag::isGoKart)) + { + // Determine the stop positions for the karts. If in left lane it's further along the track than the right lane. + // Since it's not possible to overtake when the race has ended, this does not check for overtake states (7 and + // 8). + cx = TrackSubposition == VehicleTrackSubposition::GoKartsRightLane ? 18 : 20; + } + + if (ax > cx) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; + } + } +} + +/** + * Determine whether to use block brake speed or brake speed. If block brake is closed or no block brake present, use the + * brake's speed; if block brake is open, use maximum of brake speed or block brake speed. + */ +uint8_t Vehicle::ChooseBrakeSpeed() const +{ + if (!TrackTypeIsBrakes(GetTrackType())) + return brake_speed; + auto trackElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, GetTrackType(), 0); + if (trackElement != nullptr) + { + if (trackElement->AsTrack()->IsBrakeClosed()) + return brake_speed; + else + return std::max(brake_speed, BlockBrakeSpeed); + } + return brake_speed; +} + +/** + * Populate the vehicle's brake_speed and BlockBrakeSpeed values. + */ +void Vehicle::PopulateBrakeSpeed(const CoordsXYZ& vehicleTrackLocation, TrackElement& brake) +{ + auto trackSpeed = brake.GetBrakeBoosterSpeed(); + brake_speed = trackSpeed; + if (!TrackTypeIsBrakes(brake.GetTrackType())) + { + BlockBrakeSpeed = trackSpeed; + return; + } + // As soon as feasible, encode block brake speed into track element so the lookforward can be skipped here. + + CoordsXYE output = CoordsXYE(vehicleTrackLocation.x, vehicleTrackLocation.y, reinterpret_cast(&brake)); + int32_t outputZ = vehicleTrackLocation.z; + uint16_t timeoutCount = 256; + do + { + if (TrackTypeIsBlockBrakes(output.element->AsTrack()->GetTrackType())) + { + BlockBrakeSpeed = output.element->AsTrack()->GetBrakeBoosterSpeed(); + return; + } + if (!TrackTypeIsBrakes(output.element->AsTrack()->GetTrackType())) + { + break; + } + timeoutCount--; + } while (TrackBlockGetNext(&output, &output, &outputZ, nullptr) && timeoutCount); + + // If block brake is not found, use the track's speed + BlockBrakeSpeed = trackSpeed; +} + +/** + * + * rct2: 0x006DB08C + */ +bool Vehicle::UpdateTrackMotionForwardsGetNewTrack( + TrackElemType trackType, const Ride& curRide, const RideObjectEntry& rideEntry) +{ + CoordsXYZD location = {}; + + auto pitchAndRollEnd = TrackPitchAndRollEnd(trackType); + TileElement* tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); + + if (tileElement == nullptr) + { + return false; + } + + if (trackType == TrackElemType::cableLiftHill && this == gCurrentVehicle) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_11; + } + + if (tileElement->AsTrack()->IsBlockStart()) + { + if (next_vehicle_on_train.IsNull()) + { + SetBrakeClosedMultiTile(*tileElement->AsTrack(), TrackLocation, true); + if (TrackTypeIsBlockBrakes(trackType) || trackType == TrackElemType::endStation) + { + if (!rideEntry.Cars[0].flags.has(CarEntryFlag::isPowered)) + { + Play3D(SoundId::blockBrakeRelease, TrackLocation); + } + } + MapInvalidateElement(TrackLocation, tileElement); + BlockBrakesOpenPreviousSection(curRide, TrackLocation, tileElement); + if (TrackTypeIsBlockBrakes(trackType)) + { + BlockBrakeSetLinkedBrakesClosed(TrackLocation, *tileElement->AsTrack(), true); + } + } + } + + // Change from original: this used to check if the vehicle allowed doors. + UpdateSceneryDoor(); + + bool isGoingBack = false; + switch (TrackSubposition) + { + case VehicleTrackSubposition::ChairliftGoingBack: + case VehicleTrackSubposition::ChairliftEndBullwheel: + TrackSubposition = VehicleTrackSubposition::ChairliftGoingBack; + isGoingBack = true; + break; + case VehicleTrackSubposition::ChairliftStartBullwheel: + TrackSubposition = VehicleTrackSubposition::ChairliftGoingOut; + break; + case VehicleTrackSubposition::GoKartsMovingToRightLane: + TrackSubposition = VehicleTrackSubposition::GoKartsRightLane; + break; + case VehicleTrackSubposition::GoKartsMovingToLeftLane: + TrackSubposition = VehicleTrackSubposition::GoKartsLeftLane; + break; + default: + break; + } + + if (isGoingBack) + { + TrackBeginEnd trackBeginEnd; + if (!TrackBlockGetPrevious({ TrackLocation, tileElement }, &trackBeginEnd)) + { + return false; + } + location.x = trackBeginEnd.begin_x; + location.y = trackBeginEnd.begin_y; + location.z = trackBeginEnd.begin_z; + location.direction = trackBeginEnd.begin_direction; + tileElement = trackBeginEnd.begin_element; + } + else + { + { + int32_t curZ, direction; + CoordsXYE xyElement = { TrackLocation, tileElement }; + if (!TrackBlockGetNext(&xyElement, &xyElement, &curZ, &direction)) + { + return false; + } + tileElement = xyElement.element; + location = { xyElement, curZ, static_cast(direction) }; + } + if (tileElement->AsTrack()->GetTrackType() == TrackElemType::leftReverser + || tileElement->AsTrack()->GetTrackType() == TrackElemType::rightReverser) + { + if (IsHead() && velocity <= 3.0_mph) + { + velocity = 0; + } + } + + if (PitchAndRollStart(flags.has(VehicleFlag::carIsInverted), tileElement) != pitchAndRollEnd) + { + return false; + } + + // Update VehicleFlags::CarIsInverted flag + const auto previousCarIsInverted = flags.has(VehicleFlag::carIsInverted); + flags.unset(VehicleFlag::carIsInverted); + { + auto rideType = ::GetRide(tileElement->AsTrack()->GetRideIndex())->type; + if (GetRideTypeDescriptor(rideType).flags.has(RtdFlag::hasInvertedVariant)) + { + if (tileElement->AsTrack()->IsInverted()) + { + flags.set(VehicleFlag::carIsInverted); + } + } + if (previousCarIsInverted != flags.has(VehicleFlag::carIsInverted)) + { + EntityTweener::Get().RemoveEntity(this); + } + } + } + + const int32_t previousTrackHeight = TrackLocation.z; + TrackLocation = location; + + // TODO check if getting the vehicle entry again is necessary + const auto* carEntry = Entry(); + if (carEntry == nullptr) + { + return false; + } + if (carEntry->flags.has(CarEntryFlag::isGoKart) && TrackSubposition < VehicleTrackSubposition::GoKartsMovingToRightLane) + { + trackType = tileElement->AsTrack()->GetTrackType(); + if (trackType == TrackElemType::flat || trackType == TrackElemType::leftQuarterTurn3Tiles + || trackType == TrackElemType::rightQuarterTurn3Tiles || trackType == TrackElemType::leftQuarterTurn5Tiles + || trackType == TrackElemType::rightQuarterTurn5Tiles || trackType == TrackElemType::leftEighthToDiag + || trackType == TrackElemType::rightEighthToDiag || trackType == TrackElemType::leftEighthToOrthogonal + || trackType == TrackElemType::rightEighthToOrthogonal || trackType == TrackElemType::diagFlat + || trackType == TrackElemType::sBendLeft || trackType == TrackElemType::sBendRight + || (curRide.flags.has(RideFlag::passStationNoStopping) && tileElement->AsTrack()->IsStation())) + { + UpdateGoKartAttemptSwitchLanes(); + } + } + + if (TrackSubposition >= VehicleTrackSubposition::ChairliftGoingOut + && TrackSubposition <= VehicleTrackSubposition::ChairliftStartBullwheel) + { + TileCoordsXYZ curLocation{ TrackLocation }; + + if (curLocation == curRide.chairliftBullwheelLocation[1]) + { + TrackSubposition = VehicleTrackSubposition::ChairliftEndBullwheel; + } + else if (curLocation == curRide.chairliftBullwheelLocation[0]) + { + TrackSubposition = VehicleTrackSubposition::ChairliftStartBullwheel; + } + } + + // Loc6DB500 + // Update VehicleFlags::OnLiftHill + flags.unset(VehicleFlag::onLiftHill); + if (tileElement->AsTrack()->HasChain()) + { + flags.set(VehicleFlag::onLiftHill); + } + + trackType = tileElement->AsTrack()->GetTrackType(); + if (trackType != TrackElemType::brakes) + { + target_seat_rotation = tileElement->AsTrack()->GetSeatRotation(); + } + SetTrackDirection(location.direction); + SetTrackType(trackType); + PopulateBrakeSpeed(TrackLocation, *tileElement->AsTrack()); + if (flags.has(VehicleFlag::stoppedOnHoldingBrake) && vertical_drop_countdown <= 0) + { + flags.unset(VehicleFlag::stoppedOnHoldingBrake); + } + if (trackType == TrackElemType::onRidePhoto) + { + tileElement->AsTrack()->SetPhotoTimeout(); + MapAnimations::CreateTemporary(TrackLocation, MapAnimations::TemporaryType::onRidePhoto); + } + if (trackType == TrackElemType::rotationControlToggle) + { + flags.flip(VehicleFlag::spinningIsLocked); + } + // Change from original: this used to check if the vehicle allowed doors. + UpdateSceneryDoorBackwards(); + UpdateLandscapeDoors(previousTrackHeight); + + return true; +} + +/** + * + * rct2: 0x006DAEB9 + */ +bool Vehicle::UpdateTrackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) +{ + EntityId otherVehicleIndex = EntityId::GetNull(); + while (true) + { + auto trackType = GetTrackType(); + if (trackType == TrackElemType::heartLineTransferUp || trackType == TrackElemType::heartLineTransferDown) + { + if (track_progress == 80) + { + vehicle_type ^= 1; + carEntry = Entry(); + } + if (_vehicleVelocityF64E08 >= 0x40000) + { + acceleration = -_vehicleVelocityF64E08 * 8; + } + else if (_vehicleVelocityF64E08 < 0x20000) + { + acceleration = 0x50000; + } + } + else if (TrackTypeIsBrakes(trackType)) + { + if (!curRide.hasFailingBrakes()) + { + auto brakeSpeed = ChooseBrakeSpeed() << kTrackSpeedShiftAmount; + + if ((brakeSpeed) < _vehicleVelocityF64E08) + { + acceleration = -_vehicleVelocityF64E08 * 16; + } + else if (!(getGameState().currentTicks & 0x0F)) + { + if (_vehicleF64E2C == 0) + { + _vehicleF64E2C++; + Play3D(SoundId::brakeRelease, { x, y, z }); + } + } + } + } + else if (TrackTypeIsBooster(trackType)) + { + auto boosterSpeed = GetUnifiedBoosterSpeed(curRide.type, brake_speed) << kTrackSpeedShiftAmount; + if (boosterSpeed > _vehicleVelocityF64E08) + { + acceleration = GetRideTypeDescriptor(curRide.type).LegacyBoosterSettings.BoosterAcceleration + << kBoosterAccelerationShiftAmount; + } + } + else if (rideEntry.flags.has(RideEntryFlag::riderControlsSpeed) && num_peeps > 0) + { + acceleration += CalculateRiderBraking(); + } + + if ((trackType == TrackElemType::flat && curRide.getRideTypeDescriptor().flags.has(RtdFlag::hasLsmBehaviourOnFlat)) + || (trackType == TrackElemType::poweredLift)) + { + acceleration = GetRideTypeDescriptor(curRide.type).LegacyBoosterSettings.PoweredLiftAcceleration + << kBoosterAccelerationShiftAmount; + } + if (trackType == TrackElemType::brakeForDrop) + { + if (IsHead()) + { + if (!flags.has(VehicleFlag::stoppedOnHoldingBrake)) + { + if (track_progress >= 8) + { + acceleration = -_vehicleVelocityF64E08 * 16; + if (track_progress >= 24) + { + flags.set(VehicleFlag::stoppedOnHoldingBrake); + vertical_drop_countdown = 90; + } + } + } + } + } + if (trackType == TrackElemType::logFlumeReverser) + { + if (track_progress != 16 || velocity < 4.0_mph) + { + if (track_progress == 32) + { + vehicle_type = carEntry->ReversedCarIndex; + carEntry = Entry(); + } + } + else + { + track_progress += 17; + } + } + + uint16_t newTrackProgress = track_progress + 1; + + // Track Total Progress is in the two bytes before the move info list + uint16_t trackTotalProgress = GetTrackProgress(); + if (newTrackProgress >= trackTotalProgress) + { + UpdateCrossings(); + + if (!UpdateTrackMotionForwardsGetNewTrack(trackType, curRide, rideEntry)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; + _vehicleVelocityF64E0C -= remaining_distance + 1; + remaining_distance = -1; + return false; + } + newTrackProgress = 0; + } + + track_progress = newTrackProgress; + UpdateHandleWaterSplash(); + + // Loc6DB706 + const auto moveInfo = GetMoveInfo(); + trackType = GetTrackType(); + { + auto nextVehiclePosition = TrackLocation + + CoordsXYZ{ moveInfo->x, moveInfo->y, + moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; + + bool useReverserDistance = TrackSubposition == VehicleTrackSubposition::ReverserRCFrontBogie + && (trackType == TrackElemType::leftReverser || trackType == TrackElemType::rightReverser) + && track_progress >= 30 && track_progress <= 66; + + // Loc6DB8A5 + remaining_distance -= Geometry::getTranslationDistance( + nextVehiclePosition - _vehicleCurPosition, useReverserDistance); + + if (TrackSubposition == VehicleTrackSubposition::ReverserRCRearBogie + && (trackType == TrackElemType::leftReverser || trackType == TrackElemType::rightReverser) + && track_progress == 96) + { + ReverseReverserCar(); + + const VehicleInfo* moveInfo2 = GetMoveInfo(); + nextVehiclePosition.x = x + moveInfo2->x; + nextVehiclePosition.y = y + moveInfo2->y; + } + + _vehicleCurPosition = nextVehiclePosition; + Orientation = moveInfo->yaw; + roll = moveInfo->roll; + pitch = moveInfo->pitch; + + if (carEntry->flags.has(CarEntryFlag::useWoodenWildMouseSwing) && moveInfo->pitch != VehiclePitch::flat) + { + SwingSprite = 0; + SwingPosition = 0; + SwingSpeed = 0; + } + + // this == frontVehicle + if (this == _vehicleFrontVehicle) + { + if (_vehicleVelocityF64E08 >= 0) + { + otherVehicleIndex = prev_vehicle_on_ride; + if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex)) + { + _vehicleVelocityF64E0C -= remaining_distance + 1; + remaining_distance = -1; + + // Might need to be bp rather than this, but hopefully not + auto otherVeh = getGameState().entities.GetEntity(otherVehicleIndex); + if (otherVeh == nullptr) + { + // This can never happen as prev_vehicle_on_ride will always be set to a vehicle + LOG_ERROR("Failed to get next vehicle during update!"); + return true; + } + auto head = otherVeh->TrainHead(); + + auto velocityDelta = abs(velocity - head->velocity); + if (!rideEntry.flags.has(RideEntryFlag::disableCollisionCrashes)) + { + if (velocityDelta > 14.0_mph) + { + if (!carEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION; + } + } + } + + if (carEntry->flags.has(CarEntryFlag::isGoKart)) + { + velocity -= velocity >> 2; + } + else + { + int32_t newHeadVelocity = velocity >> 1; + velocity = head->velocity >> 1; + head->velocity = newHeadVelocity; + } + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_1; + return false; + } + } + } + } + + // Loc6DB928 + if (remaining_distance < 0x368A) + { + return true; + } + + acceleration += Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + } +} + +static PitchAndRoll PitchAndRollEnd( + const Ride& curRide, bool useInvertedSprites, TrackElemType trackType, TileElement* tileElement) +{ + bool isInverted = useInvertedSprites ^ tileElement->AsTrack()->IsInverted(); + const auto& ted = GetTrackElementDescriptor(trackType); + return { ted.definition.pitchEnd, TrackGetActualBank2(curRide.type, isInverted, ted.definition.rollEnd) }; +} + +/** + * + * rct2: 0x006DBAA6 + */ +bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, uint16_t* progress) +{ + auto pitchAndRollStart = TrackPitchAndRollStart(trackType); + TileElement* tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); + + if (tileElement == nullptr) + return false; + + bool nextTileBackwards = true; + int32_t direction = 0; + // Loc6DBB08:; + auto trackPos = CoordsXYZ{ TrackLocation.x, TrackLocation.y, 0 }; + + switch (TrackSubposition) + { + case VehicleTrackSubposition::ChairliftEndBullwheel: + TrackSubposition = VehicleTrackSubposition::ChairliftGoingOut; + break; + case VehicleTrackSubposition::GoKartsMovingToRightLane: + TrackSubposition = VehicleTrackSubposition::GoKartsLeftLane; + break; + case VehicleTrackSubposition::GoKartsMovingToLeftLane: + TrackSubposition = VehicleTrackSubposition::GoKartsRightLane; + break; + case VehicleTrackSubposition::ChairliftGoingBack: + case VehicleTrackSubposition::ChairliftStartBullwheel: + TrackSubposition = VehicleTrackSubposition::ChairliftGoingBack; + nextTileBackwards = false; + break; + default: + break; + } + + if (nextTileBackwards) + { + // Loc6DBB7E:; + TrackBeginEnd trackBeginEnd; + if (!TrackBlockGetPrevious({ trackPos, tileElement }, &trackBeginEnd)) + { + return false; + } + tileElement = trackBeginEnd.begin_element; + + trackType = tileElement->AsTrack()->GetTrackType(); + if (trackType == TrackElemType::leftReverser || trackType == TrackElemType::rightReverser) + { + return false; + } + + if (PitchAndRollEnd(curRide, flags.has(VehicleFlag::carIsInverted), trackType, tileElement) != pitchAndRollStart) + { + return false; + } + + // Update VehicleFlags::CarIsInverted + const auto previousCarIsInverted = flags.has(VehicleFlag::carIsInverted); + flags.unset(VehicleFlag::carIsInverted); + if (GetRideTypeDescriptor(curRide.type).flags.has(RtdFlag::hasInvertedVariant)) + { + if (tileElement->AsTrack()->IsInverted()) + { + flags.set(VehicleFlag::carIsInverted); + } + if (previousCarIsInverted != flags.has(VehicleFlag::carIsInverted)) + { + EntityTweener::Get().RemoveEntity(this); + } + } + + trackPos = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z }; + direction = trackBeginEnd.begin_direction; + } + else + { + // Loc6DBB4F:; + CoordsXYE input; + CoordsXYE output; + int32_t outputZ{}; + + input.x = trackPos.x; + input.y = trackPos.y; + input.element = tileElement; + if (!TrackBlockGetNext(&input, &output, &outputZ, &direction)) + { + return false; + } + tileElement = output.element; + trackPos = { output, outputZ }; + } + + // Loc6DBC3B: + TrackLocation = trackPos; + + if (TrackSubposition >= VehicleTrackSubposition::ChairliftGoingOut + && TrackSubposition <= VehicleTrackSubposition::ChairliftStartBullwheel) + { + TileCoordsXYZ curLocation{ TrackLocation }; + + if (curLocation == curRide.chairliftBullwheelLocation[1]) + { + TrackSubposition = VehicleTrackSubposition::ChairliftEndBullwheel; + } + else if (curLocation == curRide.chairliftBullwheelLocation[0]) + { + TrackSubposition = VehicleTrackSubposition::ChairliftStartBullwheel; + } + } + + if (tileElement->AsTrack()->HasChain()) + { + if (_vehicleVelocityF64E08 < 0) + { + if (next_vehicle_on_train.IsNull()) + { + trackType = tileElement->AsTrack()->GetTrackType(); + const auto& ted = GetTrackElementDescriptor(trackType); + if (!ted.flags.has(TrackElementFlag::down)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_9; + } + } + flags.set(VehicleFlag::onLiftHill); + } + } + else + { + if (flags.has(VehicleFlag::onLiftHill)) + { + flags.unset(VehicleFlag::onLiftHill); + if (next_vehicle_on_train.IsNull()) + { + if (_vehicleVelocityF64E08 < 0) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_8; + } + } + } + } + + trackType = tileElement->AsTrack()->GetTrackType(); + if (trackType != TrackElemType::brakes) + { + target_seat_rotation = tileElement->AsTrack()->GetSeatRotation(); + } + direction &= 3; + SetTrackType(trackType); + SetTrackDirection(direction); + PopulateBrakeSpeed(TrackLocation, *tileElement->AsTrack()); + if (flags.has(VehicleFlag::stoppedOnHoldingBrake) && vertical_drop_countdown <= 0) + { + flags.unset(VehicleFlag::stoppedOnHoldingBrake); + } + // There are two bytes before the move info list + uint16_t trackTotalProgress = GetTrackProgress(); + *progress = trackTotalProgress - 1; + return true; +} + +/** + * + * rct2: 0x006DBA33 + */ +bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) +{ + EntityId otherVehicleIndex = EntityId::GetNull(); + + while (true) + { + auto trackType = GetTrackType(); + if (trackType == TrackElemType::flat && curRide.getRideTypeDescriptor().flags.has(RtdFlag::hasLsmBehaviourOnFlat)) + { + int32_t unkVelocity = _vehicleVelocityF64E08; + if (unkVelocity < -524288) + { + unkVelocity = abs(unkVelocity); + acceleration = unkVelocity * 2; + } + } + + if (TrackTypeIsBrakes(trackType)) + { + auto brakeSpeed = ChooseBrakeSpeed(); + + if (-(brakeSpeed << kTrackSpeedShiftAmount) > _vehicleVelocityF64E08) + { + acceleration = _vehicleVelocityF64E08 * -16; + } + } + + uint16_t newTrackProgress = track_progress - 1; + if (newTrackProgress == 0xFFFF) + { + UpdateCrossings(); + + if (!UpdateTrackMotionBackwardsGetNewTrack(trackType, curRide, &newTrackProgress)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; + _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + remaining_distance = 0x368A; + return false; + } + } + + // Loc6DBD42 + track_progress = newTrackProgress; + { + const VehicleInfo* moveInfo = GetMoveInfo(); + auto nextVehiclePosition = TrackLocation + + CoordsXYZ{ moveInfo->x, moveInfo->y, + moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; + + remaining_distance += Geometry::getTranslationDistance(nextVehiclePosition - _vehicleCurPosition, false); + + _vehicleCurPosition = nextVehiclePosition; + Orientation = moveInfo->yaw; + roll = moveInfo->roll; + pitch = moveInfo->pitch; + + if (carEntry->flags.has(CarEntryFlag::useWoodenWildMouseSwing) && pitch != VehiclePitch::flat) + { + SwingSprite = 0; + SwingPosition = 0; + SwingSpeed = 0; + } + + if (this == _vehicleFrontVehicle) + { + if (_vehicleVelocityF64E08 < 0) + { + otherVehicleIndex = next_vehicle_on_ride; + if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex)) + { + _vehicleVelocityF64E0C -= remaining_distance - 0x368A; + remaining_distance = 0x368A; + + Vehicle* v3 = getGameState().entities.GetEntity(otherVehicleIndex); + Vehicle* v4 = gCurrentVehicle; + if (v3 == nullptr) + { + return false; + } + + if (!rideEntry.flags.has(RideEntryFlag::disableCollisionCrashes)) + { + if (abs(v4->velocity - v3->velocity) > 14.0_mph) + { + if (!carEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION; + } + } + } + + if (carEntry->flags.has(CarEntryFlag::isGoKart)) + { + velocity -= velocity >> 2; + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; + } + else + { + int32_t v3Velocity = v3->velocity; + v3->velocity = v4->velocity >> 1; + v4->velocity = v3Velocity >> 1; + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; + } + + return false; + } + } + } + } + + // Loc6DBE3F + if (remaining_distance >= 0) + { + return true; + } + acceleration += Geometry::getAccelerationFromPitch(pitch); + _vehicleUnkF64E10++; + } +} + +static constexpr int32_t GetAccelerationDecrease2(const int32_t velocity, const int32_t totalMass) +{ + int32_t accelerationDecrease2 = velocity >> 8; + accelerationDecrease2 *= accelerationDecrease2; + if (velocity < 0) + { + accelerationDecrease2 = -accelerationDecrease2; + } + accelerationDecrease2 >>= 4; + // OpenRCT2: vehicles from different track types can have 0 mass. + if (totalMass != 0) + { + return accelerationDecrease2 / totalMass; + } + + return accelerationDecrease2; +} + +/** + * + * rct2: 0x006DC1E4 + */ +static uint8_t modified_speed(TrackElemType trackType, VehicleTrackSubposition trackSubposition, uint8_t speed) +{ + enum + { + FULL_SPEED, + THREE_QUARTER_SPEED, + HALF_SPEED + }; + + uint8_t speedModifier = FULL_SPEED; + + if (trackType == TrackElemType::leftQuarterTurn1Tile) + { + speedModifier = (trackSubposition == VehicleTrackSubposition::GoKartsLeftLane) ? HALF_SPEED : THREE_QUARTER_SPEED; + } + else if (trackType == TrackElemType::rightQuarterTurn1Tile) + { + speedModifier = (trackSubposition == VehicleTrackSubposition::GoKartsRightLane) ? HALF_SPEED : THREE_QUARTER_SPEED; + } + + switch (speedModifier) + { + case HALF_SPEED: + return speed >> 1; + case THREE_QUARTER_SPEED: + return speed - (speed >> 2); + } + return speed; +} + +int32_t Vehicle::UpdateTrackMotionPoweredRideAcceleration( + const CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration) +{ + if (carEntry->flags.has(CarEntryFlag::isPoweredRideWithUnrestrictedGravity)) + { + if (velocity > (speed * 0x4000)) + { + // Same code as none powered rides + if (curAcceleration <= 0 && curAcceleration >= -500 && velocity <= 0.5_mph) + { + return curAcceleration + 400; + } + return curAcceleration; + } + } + uint8_t modifiedSpeed = modified_speed(GetTrackType(), TrackSubposition, speed); + int32_t poweredAcceleration = modifiedSpeed << 14; + int32_t quarterForce = (modifiedSpeed * totalMass) >> 2; + if (flags.has(VehicleFlag::poweredCarInReverse)) + { + poweredAcceleration = -poweredAcceleration; + } + poweredAcceleration -= velocity; + poweredAcceleration *= powered_acceleration << 1; + if (quarterForce != 0) + { + poweredAcceleration /= quarterForce; + } + + if (carEntry->flags.has(CarEntryFlag::isLift)) + { + poweredAcceleration *= 4; + } + + if (carEntry->flags.has(CarEntryFlag::isWaterRide)) + { + if (poweredAcceleration < 0) + { + poweredAcceleration >>= 4; + } + + if (carEntry->flags.has(CarEntryFlag::hasSpinning)) + { + spin_speed = std::clamp(spin_speed, kVehicleMinSpinSpeedWaterRide, kVehicleMaxSpinSpeedWaterRide); + } + + if (pitch != VehiclePitch::flat) + { + if (poweredAcceleration < 0) + { + poweredAcceleration = 0; + } + + if (carEntry->flags.has(CarEntryFlag::hasSpinning)) + { + // If the vehicle is on the up slope kill the spin speedModifier + if (pitch == VehiclePitch::up25) + { + spin_speed = 0; + } + } + return curAcceleration + poweredAcceleration; + } + } + + if (std::abs(velocity) <= 1.0_mph) + { + return poweredAcceleration; + } + + return curAcceleration + poweredAcceleration; +} + +void Vehicle::UpdateTrackMotionPreUpdate( + Vehicle& car, const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) +{ + if (carEntry->flags.has(CarEntryFlag::hasSwinging)) + { + car.UpdateSwingingCar(); + } + if (carEntry->flags.has(CarEntryFlag::hasSpinning)) + { + car.UpdateSpinningCar(); + } + if (carEntry->flags.hasAny(CarEntryFlag::hasVehicleAnimation, CarEntryFlag::hasRiderAnimation)) + { + car.UpdateAdditionalAnimation(); + } + car.acceleration = Geometry::getAccelerationFromPitch(car.pitch); + _vehicleUnkF64E10 = 1; + + if (!car.flags.has(VehicleFlag::moveSingleCar)) + { + car.remaining_distance += _vehicleVelocityF64E0C; + } + + car.sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; + _vehicleCurPosition.x = car.x; + _vehicleCurPosition.y = car.y; + _vehicleCurPosition.z = car.z; + car.Invalidate(); + + while (true) + { + if (car.remaining_distance < 0) + { + // Backward loop + if (car.UpdateTrackMotionBackwards(carEntry, curRide, rideEntry)) + { + break; + } + + if (car.remaining_distance < 0x368A) + { + break; + } + car.acceleration += Geometry::getAccelerationFromPitch(car.pitch); + _vehicleUnkF64E10++; + continue; + } + if (car.remaining_distance < 0x368A) + { + // Location found + return; + } + if (car.UpdateTrackMotionForwards(carEntry, curRide, rideEntry)) + { + break; + } + + if (car.remaining_distance >= 0) + { + break; + } + car.acceleration = Geometry::getAccelerationFromPitch(car.pitch); + _vehicleUnkF64E10++; + } + // Loc6DBF20 + car.MoveTo(_vehicleCurPosition); +} + +/** + * + * rct2: 0x006DAB4C + */ +int32_t Vehicle::UpdateTrackMotion(int32_t* outStation) +{ + auto curRide = GetRide(); + if (curRide == nullptr) + return 0; + + const auto* rideEntry = GetRideEntry(); + const auto* carEntry = Entry(); + + if (carEntry == nullptr) + { + return 0; + } + + if (carEntry->flags.has(CarEntryFlag::isMiniGolf)) + { + return UpdateTrackMotionMiniGolf(outStation); + } + + _vehicleF64E2C = 0; + gCurrentVehicle = this; + _vehicleMotionTrackFlags = 0; + _vehicleStationIndex = StationIndex::GetNull(); + + UpdateTrackMotionUpStopCheck(); + CheckAndApplyBlockSectionStopSite(); + UpdateVelocity(); + + Vehicle* vehicle = this; + if (_vehicleVelocityF64E08 < 0 && !vehicle->flags.has(VehicleFlag::moveSingleCar)) + { + vehicle = vehicle->TrainTail(); + } + // This will be the front vehicle even when traveling + // backwards. + _vehicleFrontVehicle = vehicle; + + auto spriteId = vehicle->Id; + while (!spriteId.IsNull()) + { + Vehicle* car = getGameState().entities.GetEntity(spriteId); + if (car == nullptr) + { + break; + } + carEntry = car->Entry(); + if (carEntry != nullptr) + { + UpdateTrackMotionPreUpdate(*car, *curRide, *rideEntry, carEntry); + } + + car->Sub6DBF3E(); + + // Loc6DC0F7 + if (car->flags.has(VehicleFlag::onLiftHill)) + { + _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL; + } + if (car->flags.has(VehicleFlag::moveSingleCar)) + { + if (outStation != nullptr) + *outStation = _vehicleStationIndex.ToUnderlying(); + return _vehicleMotionTrackFlags; + } + if (_vehicleVelocityF64E08 >= 0) + { + spriteId = car->next_vehicle_on_train; + } + else + { + if (car == gCurrentVehicle) + { + break; + } + spriteId = car->prev_vehicle_on_ride; + } + } + // Loc6DC144 + vehicle = gCurrentVehicle; + + carEntry = vehicle->Entry(); + // eax + int32_t totalAcceleration = 0; + // ebp + int32_t totalMass = 0; + // ebx + int32_t numVehicles = 0; + + for (; vehicle != nullptr; vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) + { + numVehicles++; + totalMass += vehicle->mass; + totalAcceleration += vehicle->acceleration; + } + + vehicle = gCurrentVehicle; + int32_t newAcceleration = (totalAcceleration / numVehicles) * 21; + if (newAcceleration < 0) + { + newAcceleration += 511; + } + newAcceleration >>= 9; + + int32_t curAcceleration = newAcceleration; + curAcceleration -= vehicle->velocity / 4096; + curAcceleration -= GetAccelerationDecrease2(vehicle->velocity, totalMass); + + if (carEntry->flags.has(CarEntryFlag::isPowered)) + { + curAcceleration = vehicle->UpdateTrackMotionPoweredRideAcceleration(carEntry, totalMass, curAcceleration); + } + else if (curAcceleration <= 0 && curAcceleration >= -500) + { + // Probably moving slowly on a flat track piece, low rolling resistance and drag. + + if (vehicle->velocity <= 0.5_mph && vehicle->velocity >= 0) + { + // Vehicle is creeping forwards very slowly (less than ~2km/h), boost speed a bit. + curAcceleration += 400; + } + } + + if (vehicle->GetTrackType() == TrackElemType::waterSplash) + { + if (vehicle->track_progress >= 48 && vehicle->track_progress <= 128) + { + curAcceleration -= vehicle->velocity >> 6; + } + } + + if (rideEntry->flags.has(RideEntryFlag::playSplashSoundSlide)) + { + if (vehicle->IsHead()) + { + if (vehicle->IsOnCoveredTrack()) + { + if (vehicle->velocity > 2.0_mph) + { + curAcceleration -= vehicle->velocity >> 6; + } + } + } + } + + vehicle->acceleration = curAcceleration; + + // hook_setreturnregisters(®s); + if (outStation != nullptr) + *outStation = _vehicleStationIndex.ToUnderlying(); + return _vehicleMotionTrackFlags; +} diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 2362dcb090..4b62e1f1f3 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -14,7 +14,7 @@ #include "../Editor.h" #include "../GameState.h" #include "../OpenRCT2.h" -#include "../actions/RideSetStatusAction.h" +#include "../actions/ride/RideSetStatusAction.h" #include "../audio/Audio.h" #include "../config/Config.h" #include "../core/EnumUtils.hpp" @@ -64,21 +64,13 @@ using namespace OpenRCT2; using namespace OpenRCT2::Audio; using namespace OpenRCT2::TrackMetaData; using namespace OpenRCT2::RideVehicle; -static bool vehicle_boat_is_location_accessible(const CoordsXYZ& location); -constexpr int16_t kVehicleMaxSpinSpeed = 1536; -constexpr int16_t kVehicleMinSpinSpeed = -kVehicleMaxSpinSpeed; constexpr int16_t kVehicleMaxSpinSpeedForStopping = 700; -constexpr int16_t kVehicleMaxSpinSpeedWaterRide = 512; -constexpr int16_t kVehicleMinSpinSpeedWaterRide = -kVehicleMaxSpinSpeedWaterRide; constexpr int16_t kVehicleStoppingSpinSpeed = 600; -constexpr uint8_t kTrackSpeedShiftAmount = 16; -constexpr uint8_t kBoosterAccelerationShiftAmount = 16; - Vehicle* gCurrentVehicle; -static uint8_t _vehicleBreakdown; +uint8_t _vehicleBreakdown; StationIndex _vehicleStationIndex; uint32_t _vehicleMotionTrackFlags; int32_t _vehicleVelocityF64E08; @@ -88,77 +80,12 @@ uint8_t _vehicleF64E2C; Vehicle* _vehicleFrontVehicle; CoordsXYZ _vehicleCurPosition; -static constexpr SoundId _screamSetMisc[] = { - SoundId::scream8, - SoundId::scream1, -}; -static constexpr SoundId _screamSetWooden[] = { - SoundId::scream3, SoundId::scream1, SoundId::scream5, SoundId::scream6, - SoundId::scream7, SoundId::scream2, SoundId::scream4, -}; -static constexpr SoundId _screamSetSteel[] = { - SoundId::scream1, - SoundId::scream6, -}; - -/** rct2: 0x009A37C4 */ -static constexpr CoordsXY kSurroundingTiles[] = { - { 0, 0 }, - { 0, +kCoordsXYStep }, - { +kCoordsXYStep, 0 }, - { 0, -kCoordsXYStep }, - { 0, -kCoordsXYStep }, - { -kCoordsXYStep, 0 }, - { -kCoordsXYStep, 0 }, - { 0, +kCoordsXYStep }, - { 0, +kCoordsXYStep }, -}; - -static constexpr SoundId kDoorOpenSoundIds[] = { - SoundId::null, // DoorSoundType::none - SoundId::doorOpen, // DoorSoundType::door - SoundId::portcullis, // DoorSoundType::portcullis -}; -static_assert(std::size(kDoorOpenSoundIds) == kDoorSoundTypeCount); - -static constexpr SoundId kDoorCloseSoundIds[] = { - SoundId::null, // DoorSoundType::none - SoundId::doorClose, // DoorSoundType::door - SoundId::portcullis, // DoorSoundType::portcullis -}; -static_assert(std::size(kDoorCloseSoundIds) == kDoorSoundTypeCount); - template<> bool EntityBase::Is() const { return Type == EntityType::vehicle; } -#ifdef ENABLE_SCRIPTING -/** - * Fires the "vehicle.crash" api hook - * @param vehicleId Entity id of the vehicle that just crashed - * @param crashId What the vehicle crashed into. Should be either "another_vehicle", "land", or "water" - */ -static void InvokeVehicleCrashHook(const EntityId vehicleId, const std::string_view crashId) -{ - auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); - if (hookEngine.HasSubscriptions(Scripting::HookType::vehicleCrash)) - { - auto ctx = GetContext()->GetScriptEngine().GetContext(); - - // Create event args object - auto obj = Scripting::DukObject(ctx); - obj.Set("id", vehicleId.ToUnderlying()); - obj.Set("crashIntoType", crashId); - - // Call the subscriptions - auto e = obj.Take(); - hookEngine.Call(Scripting::HookType::vehicleCrash, e, true); - } -} -#endif - static bool vehicle_move_info_valid( VehicleTrackSubposition trackSubposition, TrackElemType type, uint8_t direction, int32_t offset) { @@ -259,9 +186,9 @@ void Vehicle::MoveRelativeDistance(int32_t distance) { remaining_distance += distance; - SetFlag(VehicleFlags::MoveSingleCar | VehicleFlags::CollisionDisabled); + flags.set(VehicleFlag::moveSingleCar, VehicleFlag::collisionDisabled); UpdateTrackMotion(nullptr); - ClearFlag(VehicleFlags::MoveSingleCar | VehicleFlags::CollisionDisabled); + flags.unset(VehicleFlag::moveSingleCar, VehicleFlag::collisionDisabled); } void Vehicle::UpdateTrackChange() @@ -287,12 +214,6 @@ Vehicle* TryGetVehicle(EntityId spriteIndex) return getGameState().entities.TryGetEntity(spriteIndex); } -void VehicleSoundsUpdate() -{ - auto windowManager = Ui::GetWindowManager(); - windowManager->BroadcastIntent(Intent(INTENT_ACTION_UPDATE_VEHICLE_SOUNDS)); -} - /** * * rct2: 0x006D4204 @@ -328,13 +249,13 @@ bool Vehicle::CloseRestraints() for (Vehicle* vehicle = getGameState().entities.GetEntity(Id); vehicle != nullptr; vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) { - if (vehicle->HasFlag(VehicleFlags::CarIsBroken) && vehicle->restraints_position != 0 + if (vehicle->flags.has(VehicleFlag::carIsBroken) && vehicle->restraints_position != 0 && (curRide->breakdownReasonPending == BREAKDOWN_RESTRAINTS_STUCK_OPEN || curRide->breakdownReasonPending == BREAKDOWN_DOORS_STUCK_OPEN)) { - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + if (!curRide->flags.has(RideFlag::brokenDown)) { - curRide->lifecycleFlags |= RIDE_LIFECYCLE_BROKEN_DOWN; + curRide->flags.set(RideFlag::brokenDown); RideBreakdownAddNewsItem(*curRide); @@ -444,13 +365,13 @@ bool Vehicle::OpenRestraints() continue; } - if (vehicle->HasFlag(VehicleFlags::CarIsBroken) && vehicle->restraints_position != 0xFF + if (vehicle->flags.has(VehicleFlag::carIsBroken) && vehicle->restraints_position != 0xFF && (curRide->breakdownReasonPending == BREAKDOWN_RESTRAINTS_STUCK_CLOSED || curRide->breakdownReasonPending == BREAKDOWN_DOORS_STUCK_CLOSED)) { - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + if (!curRide->flags.has(RideFlag::brokenDown)) { - curRide->lifecycleFlags |= RIDE_LIFECYCLE_BROKEN_DOWN; + curRide->flags.set(RideFlag::brokenDown); RideBreakdownAddNewsItem(*curRide); @@ -493,16 +414,6 @@ void RideUpdateMeasurementsSpecialElements_Default(Ride& ride, const TrackElemTy } } -void RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const TrackElemType trackType) -{ - const auto& ted = GetTrackElementDescriptor(trackType); - if (ted.flags.has(TrackElementFlag::isGolfHole)) - { - if (ride.numHoles < Limits::kMaxGolfHoles) - ride.numHoles++; - } -} - void RideUpdateMeasurementsSpecialElements_WaterCoaster(Ride& ride, const TrackElemType trackType) { if (trackType >= TrackElemType::flatCovered && trackType <= TrackElemType::rightQuarterTurn3TilesCovered) @@ -523,10 +434,9 @@ void Vehicle::UpdateMeasurements() if (status == Status::travellingBoat) { - curRide->lifecycleFlags |= RIDE_LIFECYCLE_TESTED; - curRide->lifecycleFlags |= RIDE_LIFECYCLE_NO_RAW_STATS; - curRide->lifecycleFlags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS; - ClearFlag(VehicleFlags::Testing); + curRide->flags.set(RideFlag::tested, RideFlag::noRawStats); + curRide->flags.unset(RideFlag::testInProgress); + flags.unset(VehicleFlag::testing); auto* windowMgr = Ui::GetWindowManager(); windowMgr->InvalidateByNumber(WindowClass::ride, ride.ToUnderlying()); @@ -565,7 +475,7 @@ void Vehicle::UpdateMeasurements() stationForTestSegment.SegmentLength = AddClamp(stationForTestSegment.SegmentLength, distance); } - if (curRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasGForces)) + if (curRide->getRideTypeDescriptor().flags.has(RtdFlag::hasGForces)) { auto gForces = GetGForces(); gForces.verticalG += curRide->previousVerticalG; @@ -601,7 +511,7 @@ void Vehicle::UpdateMeasurements() return; auto trackElemType = GetTrackType(); - if (trackElemType == TrackElemType::poweredLift || HasFlag(VehicleFlags::OnLiftHill)) + if (trackElemType == TrackElemType::poweredLift || flags.has(VehicleFlag::onLiftHill)) { if (!curRide->testingFlags.has(RideTestingFlag::poweredLift)) { @@ -635,7 +545,7 @@ void Vehicle::UpdateMeasurements() case TrackElemType::whirlpool: curRide->specialTrackElements.set(SpecialElement::whirlpool); break; - case TrackElemType::watersplash: + case TrackElemType::waterSplash: if (velocity >= 11.0_mph) { curRide->specialTrackElements.set(SpecialElement::splash); @@ -829,52 +739,6 @@ void Vehicle::UpdateMeasurements() curRide->shelteredLength = AddClamp(curRide->shelteredLength, distance); } -struct SoundIdVolume -{ - SoundId id; - uint8_t volume; -}; - -/** - * - * rct2: 0x006D7AC0 - */ -static SoundIdVolume VehicleSoundFadeInOut( - SoundId currentSoundId, uint8_t currentVolume, SoundId targetSoundId, uint8_t targetVolume) -{ - if (currentSoundId != SoundId::null) - { - if (currentSoundId == targetSoundId) - { - currentVolume = std::min(currentVolume + 15, targetVolume); - return { currentSoundId, currentVolume }; - } - - currentVolume -= 9; - if (currentVolume >= 80) - return { currentSoundId, currentVolume }; - } - - // Begin sound at quarter volume - currentSoundId = targetSoundId; - currentVolume = targetVolume == 255 ? 255 : targetVolume / 4; - - return { currentSoundId, currentVolume }; -} - -void Vehicle::GetLiftHillSound(const Ride& curRide, SoundIdVolume& curSound) -{ - scream_sound_id = SoundId::null; - if (curRide.type < std::size(kRideTypeDescriptors)) - { - // Get lift hill sound - curSound.id = GetRideTypeDescriptor(curRide.type).LiftData.sound_id; - curSound.volume = 243; - if (!(sound2_flags & VEHICLE_SOUND2_FLAGS_LIFT_HILL)) - curSound.id = SoundId::null; - } -} - /** * * rct2: 0x006D77F2 @@ -898,11 +762,11 @@ void Vehicle::Update() if (curRide->type >= RIDE_TYPE_COUNT) return; - if (HasFlag(VehicleFlags::Testing)) + if (flags.has(VehicleFlag::testing)) UpdateMeasurements(); _vehicleBreakdown = 255; - if (curRide->lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)) + if (curRide->flags.hasAny(RideFlag::breakdownPending, RideFlag::brokenDown)) { _vehicleBreakdown = curRide->breakdownReasonPending; auto carEntry = &rideEntry->Cars[vehicle_type]; @@ -910,7 +774,7 @@ void Vehicle::Update() { if (!carEntry->flags.has(CarEntryFlag::isWaterRide) || (pitch == VehiclePitch::up25 && velocity <= 2.0_mph)) { - SetFlag(VehicleFlags::StoppedBySafetyCutOut); + flags.set(VehicleFlag::stoppedBySafetyCutout); } } } @@ -991,175 +855,7 @@ void Vehicle::Update() UpdateSound(); } -/** - * - * rct2: 0x006D7BCC - */ -void Vehicle::UpdateMovingToEndOfStation() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - int32_t curFlags = 0; - int32_t station = 0; - - switch (curRide->mode) - { - case RideMode::upwardLaunch: - case RideMode::rotatingLift: - case RideMode::downwardLaunch: - case RideMode::freefallDrop: - if (velocity >= -131940) - { - acceleration = -3298; - } - else - { - velocity -= velocity / 16; - acceleration = 0; - } - curFlags = UpdateTrackMotion(&station); - if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_5)) - break; - [[fallthrough]]; - case RideMode::dodgems: - case RideMode::swing: - case RideMode::rotation: - case RideMode::forwardRotation: - case RideMode::backwardRotation: - case RideMode::filmAvengingAviators: - case RideMode::filmThrillRiders: - case RideMode::beginners: - case RideMode::intense: - case RideMode::berserk: - case RideMode::mouseTails3DFilm: - case RideMode::stormChasers3DFilm: - case RideMode::spaceRaiders3DFilm: - case RideMode::spaceRings: - case RideMode::hauntedHouse: - case RideMode::crookedHouse: - case RideMode::circus: - current_station = StationIndex::FromUnderlying(0); - velocity = 0; - acceleration = 0; - SetState(Status::waitingForPassengers); - break; - default: - { - const auto* rideEntry = GetRideEntry(); - if (rideEntry == nullptr) - { - return; - } - - const auto& carEntry = rideEntry->Cars[vehicle_type]; - - if (!carEntry.flags.has(CarEntryFlag::isPowered)) - { - if (velocity <= 131940) - { - acceleration = 3298; - } - } - if (velocity > 131940) - { - velocity -= velocity / 16; - acceleration = 0; - } - - curFlags = UpdateTrackMotion(&station); - - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1) - { - velocity = 0; - acceleration = 0; - sub_state++; - - if (curRide->mode == RideMode::race && sub_state >= 40) - { - SetState(Status::waitingForPassengers); - break; - } - } - else - { - if (velocity > 98955) - { - sub_state = 0; - } - } - - if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION)) - break; - - current_station = StationIndex::FromUnderlying(station); - velocity = 0; - acceleration = 0; - SetState(Status::waitingForPassengers); - break; - } - } -} - -/** - * - * rct2: 0x006D7FB4 - */ -void Vehicle::TrainReadyToDepart(uint8_t num_peeps_on_train, uint8_t num_used_seats) -{ - if (num_peeps_on_train != num_used_seats) - return; - - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if (curRide->status == RideStatus::open && !(curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) - && !HasFlag(VehicleFlags::ReadyToDepart)) - { - return; - } - - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) - { - const auto& rtd = curRide->getRideTypeDescriptor(); - // Original code did not check if the ride was a boat hire, causing empty boats to leave the platform when closing a - // Boat Hire with passengers on it. - if (curRide->status != RideStatus::closed || (curRide->numRiders != 0 && rtd.specialType != RtdSpecialType::boatHire)) - { - curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; - sub_state = 2; - return; - } - } - - if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) - { - uint8_t seat = ((-flatRideAnimationFrame) / 8) & 0xF; - if (!peep[seat].IsNull()) - { - curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; - SetState(Status::unloadingPassengers); - return; - } - - if (num_peeps == 0) - return; - - curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; - sub_state = 2; - return; - } - - if (num_peeps_on_train == 0) - return; - - curRide->getStation(current_station).TrainAtStation = RideStation::kNoTrain; - SetState(Status::waitingForPassengers); -} - -static std::optional ride_get_train_index_from_vehicle(const Ride& ride, EntityId spriteIndex) +std::optional ride_get_train_index_from_vehicle(const Ride& ride, EntityId spriteIndex) { uint32_t trainIndex = 0; while (ride.vehicles[trainIndex] != spriteIndex) @@ -1180,754 +876,6 @@ static std::optional ride_get_train_index_from_vehicle(const Ride& rid return { trainIndex }; } -/** - * - * rct2: 0x006D7DA1 - */ -void Vehicle::UpdateWaitingForPassengers() -{ - velocity = 0; - - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if (sub_state == 0) - { - if (!OpenRestraints()) - return; - - auto& station = curRide->getStation(current_station); - if (station.Entrance.IsNull()) - { - station.TrainAtStation = RideStation::kNoTrain; - sub_state = 2; - return; - } - - auto trainIndex = ride_get_train_index_from_vehicle(*curRide, Id); - if (!trainIndex.has_value()) - { - return; - } - - if (station.TrainAtStation != RideStation::kNoTrain) - return; - - station.TrainAtStation = trainIndex.value(); - sub_state = 1; - time_waiting = 0; - - Invalidate(); - return; - } - if (sub_state == 1) - { - if (time_waiting != 0xFFFF) - time_waiting++; - - ClearFlag(VehicleFlags::ReadyToDepart); - - // 0xF64E31, 0xF64E32, 0xF64E33 - uint8_t num_peeps_on_train = 0, num_used_seats_on_train = 0, num_seats_on_train = 0; - - for (const Vehicle* trainCar = getGameState().entities.GetEntity(Id); trainCar != nullptr; - trainCar = getGameState().entities.GetEntity(trainCar->next_vehicle_on_train)) - { - num_peeps_on_train += trainCar->num_peeps; - num_used_seats_on_train += trainCar->next_free_seat; - num_seats_on_train += trainCar->num_seats; - } - - num_seats_on_train &= 0x7F; - - if (curRide->supportsStatus(RideStatus::testing)) - { - if (time_waiting < 20) - { - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - } - else - { - if (num_peeps_on_train == 0) - { - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - } - - if (curRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasLoadOptions)) - { - if (curRide->departFlags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH) - { - if (curRide->minWaitingTime * 32 > time_waiting) - { - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - } - if (curRide->departFlags & RIDE_DEPART_WAIT_FOR_MAXIMUM_LENGTH) - { - if (curRide->maxWaitingTime * 32 < time_waiting) - { - SetFlag(VehicleFlags::ReadyToDepart); - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - } - } - - if (curRide->departFlags & RIDE_DEPART_LEAVE_WHEN_ANOTHER_ARRIVES) - { - for (auto train_id : curRide->vehicles) - { - if (train_id == Id) - continue; - - Vehicle* train = getGameState().entities.GetEntity(train_id); - if (train == nullptr) - continue; - - if (train->status == Status::unloadingPassengers || train->status == Status::movingToEndOfStation) - { - if (train->current_station == current_station) - { - SetFlag(VehicleFlags::ReadyToDepart); - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - } - } - } - - if (curRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasLoadOptions) - && curRide->departFlags & RIDE_DEPART_WAIT_FOR_LOAD) - { - if (num_peeps_on_train == num_seats_on_train) - { - SetFlag(VehicleFlags::ReadyToDepart); - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - - // any load: load=4 , full: load=3 , 3/4s: load=2 , half: load=1 , quarter: load=0 - uint8_t load = curRide->departFlags & RIDE_DEPART_WAIT_FOR_LOAD_MASK; - - // We want to wait for ceiling((load+1)/4 * num_seats_on_train) peeps, the +3 below is used instead of - // ceil() to prevent issues on different cpus/platforms with floats. Note that vanilla RCT1/2 rounded - // down here; our change reflects the expected behaviour for waiting for a minimum load target (see #9987) - uint8_t peepTarget = ((load + 1) * num_seats_on_train + 3) / 4; - - if (load == 4) // take care of "any load" special case - peepTarget = 1; - - if (num_peeps_on_train >= peepTarget) - SetFlag(VehicleFlags::ReadyToDepart); - - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - - SetFlag(VehicleFlags::ReadyToDepart); - TrainReadyToDepart(num_peeps_on_train, num_used_seats_on_train); - return; - } - - if (!CloseRestraints()) - return; - - velocity = 0; - ClearFlag(VehicleFlags::WaitingOnAdjacentStation); - - if (curRide->departFlags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS) - { - SetFlag(VehicleFlags::WaitingOnAdjacentStation); - } - - SetState(Status::waitingToDepart); -} - -/** - * - * rct2: 0x006D91BF - */ -void Vehicle::UpdateDodgemsMode() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - const auto* rideEntry = GetRideEntry(); - if (rideEntry == nullptr) - { - return; - } - const auto& carEntry = rideEntry->Cars[vehicle_type]; - - // Mark the dodgem as in use. - if (carEntry.flags.has(CarEntryFlag::hasDodgemInUseLights) && animation_frame != 1) - { - animation_frame = 1; - Invalidate(); - } - - UpdateMotionDodgems(); - - // Update the length of time vehicle has been in dodgems mode - if (sub_state++ == 0xFF) - { - TimeActive++; - } - - if (curRide->lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) - return; - - // Mark the dodgem as not in use. - animation_frame = 0; - Invalidate(); - velocity = 0; - acceleration = 0; - SetState(Status::unloadingPassengers); -} - -/** - * - * rct2: 0x006D80BE - */ -void Vehicle::UpdateWaitingToDepart() -{ - auto* curRide = GetRide(); - if (curRide == nullptr) - return; - - const auto& currentStation = curRide->getStation(current_station); - - bool shouldBreak = false; - if (curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) - { - switch (curRide->breakdownReasonPending) - { - case BREAKDOWN_RESTRAINTS_STUCK_CLOSED: - case BREAKDOWN_RESTRAINTS_STUCK_OPEN: - case BREAKDOWN_DOORS_STUCK_CLOSED: - case BREAKDOWN_DOORS_STUCK_OPEN: - break; - default: - shouldBreak = true; - break; - } - } - - bool skipCheck = false; - if (shouldBreak || curRide->status != RideStatus::open) - { - if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) - { - uint8_t seat = ((-flatRideAnimationFrame) >> 3) & 0xF; - if (peep[seat * 2].IsNull()) - { - if (num_peeps == 0) - { - skipCheck = true; - } - } - else - { - if (!currentStation.Exit.IsNull()) - { - SetState(Status::unloadingPassengers); - return; - } - } - } - else - { - for (const Vehicle* trainCar = getGameState().entities.GetEntity(Id); trainCar != nullptr; - trainCar = getGameState().entities.GetEntity(trainCar->next_vehicle_on_train)) - { - if (trainCar->num_peeps != 0) - { - if (!currentStation.Exit.IsNull()) - { - SetState(Status::unloadingPassengers); - return; - } - break; - } - } - } - } - - if (!skipCheck) - { - if (!(currentStation.Depart & kStationDepartFlag)) - return; - } - - if (curRide->getRideTypeDescriptor().HasFlag(RtdFlag::canSynchroniseWithAdjacentStations)) - { - if (curRide->departFlags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS) - { - if (HasFlag(VehicleFlags::WaitingOnAdjacentStation)) - { - if (!CanDepartSynchronised()) - { - return; - } - } - } - } - - SetState(Status::departing); - - if (curRide->lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT) - { - CoordsXYE track; - int32_t zUnused; - int32_t direction; - - uint8_t trackDirection = GetTrackDirection(); - if (TrackBlockGetNextFromZero(TrackLocation, *curRide, trackDirection, &track, &zUnused, &direction, false)) - { - if (track.element->AsTrack()->HasCableLift()) - { - SetState(Status::waitingForCableLift, sub_state); - } - } - } - - switch (curRide->mode) - { - case RideMode::dodgems: - // Dodgems mode uses sub_state and TimeActive to tell how long - // the vehicle has been ridden. - SetState(Status::travellingDodgems); - TimeActive = 0; - UpdateDodgemsMode(); - break; - case RideMode::swing: - SetState(Status::swinging); - NumSwings = 0; - current_time = -1; - UpdateSwinging(); - break; - case RideMode::rotation: - SetState(Status::rotating); - NumRotations = 0; - current_time = -1; - UpdateRotating(); - break; - case RideMode::filmAvengingAviators: - SetState(Status::simulatorOperating); - current_time = -1; - UpdateSimulatorOperating(); - break; - case RideMode::filmThrillRiders: - SetState(Status::simulatorOperating, 1); - current_time = -1; - UpdateSimulatorOperating(); - break; - case RideMode::beginners: - case RideMode::intense: - case RideMode::berserk: - SetState(Status::topSpinOperating, sub_state); - switch (curRide->mode) - { - case RideMode::beginners: - sub_state = 0; - break; - case RideMode::intense: - sub_state = 1; - break; - case RideMode::berserk: - sub_state = 2; - break; - default: - { - // This is workaround for multiple compilation errors of type "enumeration value ‘RIDE_MODE_*' not handled - // in switch [-Werror=switch]" - } - } - current_time = -1; - flatRideAnimationFrame = 0; - flatRideSecondaryAnimationFrame = 0; - UpdateTopSpinOperating(); - break; - case RideMode::forwardRotation: - case RideMode::backwardRotation: - SetState(Status::ferrisWheelRotating, flatRideAnimationFrame); - NumRotations = 0; - ferris_wheel_var_0 = 8; - ferris_wheel_var_1 = 8; - UpdateFerrisWheelRotating(); - break; - case RideMode::mouseTails3DFilm: - case RideMode::stormChasers3DFilm: - case RideMode::spaceRaiders3DFilm: - SetState(Status::showingFilm, sub_state); - switch (curRide->mode) - { - case RideMode::mouseTails3DFilm: - sub_state = 0; - break; - case RideMode::stormChasers3DFilm: - sub_state = 1; - break; - case RideMode::spaceRaiders3DFilm: - sub_state = 2; - break; - default: - { - // This is workaround for multiple compilation errors of type "enumeration value ‘RIDE_MODE_*' not handled - // in switch [-Werror=switch]" - } - } - current_time = -1; - UpdateShowingFilm(); - break; - case RideMode::circus: - SetState(Status::doingCircusShow); - current_time = -1; - UpdateDoingCircusShow(); - break; - case RideMode::spaceRings: - SetState(Status::spaceRingsOperating); - flatRideAnimationFrame = 0; - current_time = -1; - UpdateSpaceRingsOperating(); - break; - case RideMode::hauntedHouse: - SetState(Status::hauntedHouseOperating); - flatRideAnimationFrame = 0; - current_time = -1; - UpdateHauntedHouseOperating(); - break; - case RideMode::crookedHouse: - SetState(Status::crookedHouseOperating); - flatRideAnimationFrame = 0; - current_time = -1; - UpdateCrookedHouseOperating(); - break; - default: - SetState(status); - NumLaps = 0; - break; - } -} - -struct SynchronisedVehicle -{ - RideId ride_id; - StationIndex stationIndex; - EntityId vehicle_id; -}; - -constexpr int32_t SYNCHRONISED_VEHICLE_COUNT = 16; - -// Synchronised vehicle info -static SynchronisedVehicle _synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT] = {}; - -static SynchronisedVehicle* _lastSynchronisedVehicle = nullptr; - -/** - * Checks if a map position contains a synchronised ride station and adds the vehicle - * to synchronise to the vehicle synchronisation list. - * rct2: 0x006DE1A4 - */ -static bool try_add_synchronised_station(const CoordsXYZ& coords) -{ - // make sure we are in map bounds - if (!MapIsLocationValid(coords)) - { - return false; - } - - TileElement* tileElement = GetStationPlatform({ coords, coords.z + 2 * kCoordsZStep }); - if (tileElement == nullptr) - { - /* No station platform element found, - * so no station to synchronise */ - return false; - } - - auto rideIndex = tileElement->AsTrack()->GetRideIndex(); - auto ride = GetRide(rideIndex); - if (ride == nullptr || !(ride->departFlags & RIDE_DEPART_SYNCHRONISE_WITH_ADJACENT_STATIONS)) - { - /* Ride is not set to synchronise with adjacent stations. */ - return false; - } - - /* From this point on, the ride of the map element is one that is set - * to sync with adjacent stations, so it will return true. - * Still to determine if a vehicle to sync can be identified. */ - - auto stationIndex = tileElement->AsTrack()->GetStationIndex(); - - SynchronisedVehicle* sv = _lastSynchronisedVehicle; - sv->ride_id = rideIndex; - sv->stationIndex = stationIndex; - sv->vehicle_id = EntityId::GetNull(); - _lastSynchronisedVehicle++; - - /* Ride vehicles are not on the track (e.g. ride is/was under - * construction), so just return; vehicle_id for this station - * is SPRITE_INDEX_NULL. */ - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_ON_TRACK)) - { - return true; - } - - /* Station is not ready to depart, so just return; - * vehicle_id for this station is SPRITE_INDEX_NULL. */ - if (!(ride->getStation(stationIndex).Depart & kStationDepartFlag)) - { - return true; - } - - // Look for a vehicle on this station waiting to depart. - for (int32_t i = 0; i < ride->numTrains; i++) - { - auto* vehicle = getGameState().entities.GetEntity(ride->vehicles[i]); - if (vehicle == nullptr) - { - continue; - } - - if (vehicle->status != Vehicle::Status::waitingToDepart) - { - continue; - } - if (vehicle->sub_state != 0) - { - continue; - } - if (!vehicle->HasFlag(VehicleFlags::WaitingOnAdjacentStation)) - { - continue; - } - if (vehicle->current_station != stationIndex) - { - continue; - } - - sv->vehicle_id = vehicle->Id; - return true; - } - - /* No vehicle found waiting to depart (with sync adjacent) at the - * station, so just return; vehicle_id for this station is - * SPRITE_INDEX_NULL. */ - return true; -} - -/** - * Checks whether a vehicle can depart a station when set to synchronise with adjacent stations. - * rct2: 0x006DE287 - * @param vehicle The vehicle waiting to depart. - * @returns true if the vehicle can depart (all adjacent trains are ready or broken down), otherwise false. - * - * Permits vehicles to depart in two ways: - * Returns true, permitting the vehicle in the param to depart immediately; - * The vehicle flag VehicleFlags::WaitingOnAdjacentStation is cleared for those - * vehicles that depart in sync with the vehicle in the param. - */ -static bool ride_station_can_depart_synchronised(const Ride& ride, StationIndex stationIndex) -{ - const auto& station = ride.getStation(stationIndex); - auto location = station.GetStart(); - - auto tileElement = MapGetTrackElementAt(location); - if (tileElement == nullptr) - { - return false; - } - - // Reset the list of synchronised vehicles to empty. - _lastSynchronisedVehicle = _synchronisedVehicles; - - /* Search for stations to sync in both directions from the current tile. - * We allow for some space between stations, and every time a station - * is found we allow for space between that and the next. - */ - - int32_t direction = tileElement->GetDirectionWithOffset(1); - constexpr uint8_t maxCheckDistance = kRideAdjacencyCheckDistance; - uint8_t spaceBetween = maxCheckDistance; - - while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) - { - location += CoordsXYZ{ CoordsDirectionDelta[direction], 0 }; - if (try_add_synchronised_station(location)) - { - spaceBetween = maxCheckDistance; - continue; - } - if (spaceBetween-- == 0) - { - break; - } - } - - // Other search direction. - location = station.GetStart(); - direction = DirectionReverse(direction) & 3; - spaceBetween = maxCheckDistance; - while (_lastSynchronisedVehicle < &_synchronisedVehicles[SYNCHRONISED_VEHICLE_COUNT - 1]) - { - location += CoordsXYZ{ CoordsDirectionDelta[direction], 0 }; - if (try_add_synchronised_station(location)) - { - spaceBetween = maxCheckDistance; - continue; - } - if (spaceBetween-- == 0) - { - break; - } - } - - if (_lastSynchronisedVehicle == _synchronisedVehicles) - { - // No adjacent stations, allow depart - return true; - } - - for (SynchronisedVehicle* sv = _synchronisedVehicles; sv < _lastSynchronisedVehicle; sv++) - { - Ride* sv_ride = GetRide(sv->ride_id); - - if (!(sv_ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) - { - if (sv_ride->status != RideStatus::closed) - { - if (sv_ride->isBlockSectioned()) - { - if (!(sv_ride->getStation(sv->stationIndex).Depart & kStationDepartFlag)) - { - sv = _synchronisedVehicles; - RideId rideId = RideId::GetNull(); - for (; sv < _lastSynchronisedVehicle; sv++) - { - if (rideId.IsNull()) - { - rideId = sv->ride_id; - } - if (rideId != sv->ride_id) - { - // Here the sync-ed stations are not all from the same ride. - return false; - } - } - - /* Here all the of sync-ed stations are from the same ride */ - auto curRide = GetRide(rideId); - if (curRide != nullptr) - { - for (int32_t i = 0; i < curRide->numTrains; i++) - { - Vehicle* v = getGameState().entities.GetEntity(curRide->vehicles[i]); - if (v == nullptr) - { - continue; - } - if (v->status != Vehicle::Status::waitingToDepart && v->velocity != 0) - { - // Here at least one vehicle on the ride is moving. - return false; - } - } - } - - // UNCERTAIN: is the return desired here, or rather continue on with the general checks? - return true; - } - } - // There is no vehicle waiting at this station to sync with. - if (sv->vehicle_id.IsNull()) - { - // Check conditions for departing without all stations being in sync. - if (_lastSynchronisedVehicle > &_synchronisedVehicles[1]) - { - // Sync condition: there are at least 3 stations to sync - return false; - } - RideId someRideIndex = _synchronisedVehicles[0].ride_id; - if (someRideIndex != ride.id) - { - // Sync condition: the first station to sync is a different ride - return false; - } - - int32_t numTrainsAtStation = 0; - int32_t numTravelingTrains = 0; - auto currentStation = sv->stationIndex; - for (int32_t i = 0; i < sv_ride->numTrains; i++) - { - auto* otherVehicle = getGameState().entities.GetEntity(sv_ride->vehicles[i]); - if (otherVehicle == nullptr) - { - continue; - } - if (otherVehicle->status != Vehicle::Status::travelling) - { - if (currentStation == otherVehicle->current_station) - { - if (otherVehicle->status == Vehicle::Status::waitingToDepart - || otherVehicle->status == Vehicle::Status::movingToEndOfStation) - { - numTrainsAtStation++; - } - } - } - else - { - numTravelingTrains++; - } - } - - int32_t totalTrains = numTrainsAtStation + numTravelingTrains; - if (totalTrains != sv_ride->numTrains || numTravelingTrains >= sv_ride->numTrains / 2) - { - // if (numArrivingTrains > 0 || numTravelingTrains >= sv_ride->numTrains / 2) { - /* Sync condition: If there are trains arriving at the - * station or half or more of the ride trains are - * travelling, this station must be sync-ed before the - * trains can depart! */ - return false; - } - - /* Sync exception - train is not arriving at the station - * and there are less than half the trains for the ride - * travelling. */ - } - } - } - } - - // At this point all vehicles in _snychronisedVehicles can depart. - for (SynchronisedVehicle* sv = _synchronisedVehicles; sv < _lastSynchronisedVehicle; sv++) - { - auto v = getGameState().entities.GetEntity(sv->vehicle_id); - if (v != nullptr) - { - v->ClearFlag(VehicleFlags::WaitingOnAdjacentStation); - } - } - - return true; -} - -bool Vehicle::CanDepartSynchronised() const -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return false; - return ride_station_can_depart_synchronised(*curRide, current_station); -} - /** * * rct2: 0x006D9EB0 @@ -1954,8 +902,8 @@ void Vehicle::PeepEasterEggHereWeAre() const */ static void test_finish(Ride& ride) { - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_TEST_IN_PROGRESS; - ride.lifecycleFlags |= RIDE_LIFECYCLE_TESTED; + ride.flags.unset(RideFlag::testInProgress); + ride.flags.set(RideFlag::tested); ride.windowInvalidateFlags.set(RideInvalidateFlag::ratings); auto rideStations = ride.getStations(); @@ -1992,7 +940,7 @@ void Vehicle::UpdateTestFinish() if (curRide == nullptr) return; test_finish(*curRide); - ClearFlag(VehicleFlags::Testing); + flags.unset(VehicleFlag::testing); } /** @@ -2001,8 +949,8 @@ void Vehicle::UpdateTestFinish() */ static void test_reset(Ride& ride, StationIndex curStation) { - ride.lifecycleFlags |= RIDE_LIFECYCLE_TEST_IN_PROGRESS; - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_NO_RAW_STATS; + ride.flags.set(RideFlag::testInProgress); + ride.flags.unset(RideFlag::noRawStats); ride.maxSpeed = 0; ride.averageSpeed = 0; ride.currentTestSegment = 0; @@ -2042,7 +990,7 @@ static void test_reset(Ride& ride, StationIndex curStation) void Vehicle::TestReset() { - SetFlag(VehicleFlags::Testing); + flags.set(VehicleFlag::testing); auto curRide = GetRide(); if (curRide == nullptr) return; @@ -2080,1059 +1028,6 @@ bool Vehicle::CurrentTowerElementIsTop() return true; } -/** - * - * rct2: 0x006D986C - */ -void Vehicle::UpdateTravellingBoatHireSetup() -{ - var_34 = Orientation; - TrackLocation.x = x; - TrackLocation.y = y; - TrackLocation = TrackLocation.ToTileStart(); - - CoordsXY location = CoordsXY(TrackLocation) + CoordsDirectionDelta[Orientation >> 3]; - - BoatLocation = location; - var_35 = 0; - // No longer on a track so reset to 0 for import/export - SetTrackDirection(0); - SetTrackType(TrackElemType::flat); - SetState(Status::travellingBoat); - remaining_distance += 27924; - - UpdateTravellingBoat(); -} - -/** - * - * rct2: 0x006D982F - */ -void Vehicle::UpdateDepartingBoatHire() -{ - lost_time_out = 0; - - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - auto& station = curRide->getStation(current_station); - station.Depart &= kStationDepartFlag; - uint8_t waitingTime = std::max(curRide->minWaitingTime, static_cast(3)); - waitingTime = std::min(waitingTime, static_cast(127)); - station.Depart |= waitingTime; - UpdateTravellingBoatHireSetup(); -} - -/** - * - * rct2: 0x006D845B - */ -void Vehicle::UpdateDeparting() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - const auto* rideEntry = GetRideEntry(); - if (rideEntry == nullptr) - return; - - if (sub_state == 0) - { - if (HasFlag(VehicleFlags::TrainIsBroken)) - { - if (curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) - return; - - curRide->lifecycleFlags |= RIDE_LIFECYCLE_BROKEN_DOWN; - RideBreakdownAddNewsItem(*curRide); - - curRide->windowInvalidateFlags.set( - RideInvalidateFlag::main, RideInvalidateFlag::list, RideInvalidateFlag::maintenance); - curRide->mechanicStatus = MechanicStatus::calling; - curRide->inspectionStation = current_station; - curRide->breakdownReason = curRide->breakdownReasonPending; - velocity = 0; - return; - } - - sub_state = 1; - PeepEasterEggHereWeAre(); - - if (rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_DEPART_SOUND) - { - auto soundId = (rideEntry->Cars[0].soundRange == SoundRange::tramBell) ? SoundId::tram : SoundId::trainDeparting; - Play3D(soundId, GetLocation()); - } - - if (curRide->mode == RideMode::upwardLaunch || (curRide->mode == RideMode::downwardLaunch && NumLaunches > 1)) - { - Play3D(SoundId::rideLaunch2, GetLocation()); - } - - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_TESTED)) - { - if (HasFlag(VehicleFlags::Testing)) - { - if (curRide->currentTestSegment + 1 < curRide->numStations) - { - curRide->currentTestSegment++; - curRide->currentTestStation = current_station; - } - else - { - UpdateTestFinish(); - } - } - else if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_TEST_IN_PROGRESS) && !IsGhost()) - { - TestReset(); - } - } - } - - const auto& carEntry = rideEntry->Cars[vehicle_type]; - const auto& rtd = curRide->getRideTypeDescriptor(); - switch (curRide->mode) - { - case RideMode::reverseInclineLaunchedShuttle: - if (velocity >= -131940) - acceleration = -3298; - break; - case RideMode::poweredLaunchPasstrough: - case RideMode::poweredLaunch: - case RideMode::poweredLaunchBlockSectioned: - case RideMode::limPoweredLaunch: - case RideMode::upwardLaunch: - if ((curRide->launchSpeed << 16) > velocity) - { - acceleration = curRide->launchSpeed << rtd.BoosterSettings.AccelerationFactor; - } - break; - case RideMode::downwardLaunch: - if (NumLaunches >= 1) - { - if ((14 << 16) > velocity) - acceleration = 14 << 12; - break; - } - [[fallthrough]]; - case RideMode::continuousCircuit: - case RideMode::continuousCircuitBlockSectioned: - case RideMode::rotatingLift: - case RideMode::freefallDrop: - case RideMode::boatHire: - if (carEntry.flags.has(CarEntryFlag::isPowered)) - break; - - if (velocity <= 131940) - acceleration = 3298; - break; - default: - { - // This is workaround for multiple compilation errors of type "enumeration value ‘RIDE_MODE_*' not handled - // in switch [-Werror=switch]" - } - } - - uint32_t curFlags = UpdateTrackMotion(nullptr); - - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_8) - { - if (curRide->mode == RideMode::reverseInclineLaunchedShuttle) - { - velocity = -velocity; - FinishDeparting(); - return; - } - } - - if (curFlags & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_5 | VEHICLE_UPDATE_MOTION_TRACK_FLAG_12)) - { - if (curRide->mode == RideMode::boatHire) - { - UpdateDepartingBoatHire(); - return; - } - if (curRide->mode == RideMode::reverseInclineLaunchedShuttle) - { - velocity = -velocity; - FinishDeparting(); - return; - } - if (curRide->mode == RideMode::shuttle) - { - Flags ^= VehicleFlags::PoweredCarInReverse; - velocity = 0; - - // We have turned, so treat it like entering a new tile - UpdateCrossings(); - } - } - - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL) - { - sound2_flags |= VEHICLE_SOUND2_FLAGS_LIFT_HILL; - if (curRide->mode != RideMode::reverseInclineLaunchedShuttle) - { - int32_t curSpeed = curRide->liftHillSpeed * 31079; - if (velocity <= curSpeed) - { - acceleration = 15539; - if (velocity != 0) - { - if (_vehicleBreakdown == BREAKDOWN_SAFETY_CUT_OUT) - { - SetFlag(VehicleFlags::StoppedBySafetyCutOut); - ClearFlag(VehicleFlags::CollisionDisabled); - } - } - else - ClearFlag(VehicleFlags::CollisionDisabled); - } - } - else - { - int32_t curSpeed = curRide->liftHillSpeed * -31079; - if (velocity >= curSpeed) - { - acceleration = -15539; - if (velocity != 0) - { - if (_vehicleBreakdown == BREAKDOWN_SAFETY_CUT_OUT) - { - SetFlag(VehicleFlags::StoppedBySafetyCutOut); - ClearFlag(VehicleFlags::CollisionDisabled); - } - } - else - ClearFlag(VehicleFlags::CollisionDisabled); - } - } - } - - if (curRide->mode == RideMode::freefallDrop) - { - animation_frame++; - } - else - { - bool shouldLaunch = true; - if (curRide->mode == RideMode::downwardLaunch) - { - if (NumLaunches < 1) - shouldLaunch = false; - } - - if (shouldLaunch) - { - if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_3) || _vehicleStationIndex != current_station) - { - FinishDeparting(); - return; - } - - if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_5)) - return; - if (curRide->mode == RideMode::boatHire || curRide->mode == RideMode::rotatingLift - || curRide->mode == RideMode::shuttle) - return; - - UpdateCrashSetup(); - return; - } - } - - if (!CurrentTowerElementIsTop()) - { - if (curRide->mode == RideMode::freefallDrop) - Invalidate(); - return; - } - - FinishDeparting(); -} - -/** - * Part of UpdateDeparting - * Called after finishing departing sequence to enter - * traveling state. - * Vertical rides class the lift to the top of the tower - * as the departing sequence. After this point station - * boosters do not affect the ride. - * rct2: 0x006D8858 - */ -void Vehicle::FinishDeparting() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if (curRide->mode == RideMode::downwardLaunch) - { - if (NumLaunches >= 1 && (14 << 16) > velocity) - return; - - Play3D(SoundId::rideLaunch1, GetLocation()); - } - - if (curRide->mode == RideMode::upwardLaunch) - { - if ((curRide->launchSpeed << 16) > velocity) - return; - - Play3D(SoundId::rideLaunch1, GetLocation()); - } - - if (curRide->mode != RideMode::race && !curRide->isBlockSectioned()) - { - auto& currentStation = curRide->getStation(current_station); - currentStation.Depart &= kStationDepartFlag; - uint8_t waitingTime = 3; - if (curRide->departFlags & RIDE_DEPART_WAIT_FOR_MINIMUM_LENGTH) - { - waitingTime = std::max(curRide->minWaitingTime, static_cast(3)); - waitingTime = std::min(waitingTime, static_cast(127)); - } - - currentStation.Depart |= waitingTime; - } - lost_time_out = 0; - SetState(Status::travelling, 1); - if (velocity < 0) - sub_state = 0; -} - -/** - * - * rct2: 0x006DE5CB - */ -void Vehicle::CheckIfMissing() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if (curRide->lifecycleFlags & (RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED)) - return; - - if (curRide->isBlockSectioned()) - return; - - if (!curRide->getRideTypeDescriptor().HasFlag(RtdFlag::checkForStalling)) - return; - - lost_time_out++; - if (curRide->lifecycleFlags & RIDE_LIFECYCLE_HAS_STALLED_VEHICLE) - return; - - uint16_t limit = curRide->type == RIDE_TYPE_BOAT_HIRE ? 15360 : 9600; - - if (lost_time_out <= limit) - return; - - curRide->lifecycleFlags |= RIDE_LIFECYCLE_HAS_STALLED_VEHICLE; - - if (Config::Get().notifications.rideStalledVehicles) - { - Formatter ft; - ft.Add(GetRideComponentName(GetRideTypeDescriptor(curRide->type).NameConvention.vehicle).number); - - uint8_t vehicleIndex = 0; - for (; vehicleIndex < curRide->numTrains; ++vehicleIndex) - if (curRide->vehicles[vehicleIndex] == Id) - break; - - vehicleIndex++; - ft.Add(vehicleIndex); - curRide->formatNameTo(ft); - ft.Add(GetRideComponentName(GetRideTypeDescriptor(curRide->type).NameConvention.station).singular); - - News::AddItemToQueue(News::ItemType::ride, STR_NEWS_VEHICLE_HAS_STALLED, ride.ToUnderlying(), ft); - } -} - -void Vehicle::SimulateCrash() const -{ - auto curRide = GetRide(); - if (curRide != nullptr) - { - curRide->lifecycleFlags |= RIDE_LIFECYCLE_CRASHED; - } -} - -/** - * Setup function for a vehicle colliding with - * another vehicle. - * - * rct2: 0x006DA059 - */ -void Vehicle::UpdateCollisionSetup() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if (curRide->status == RideStatus::simulating) - { - SimulateCrash(); - return; - } - - SetState(Status::crashed, sub_state); - - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) - { - auto frontVehicle = GetHead(); - auto trainIndex = ride_get_train_index_from_vehicle(*curRide, frontVehicle->Id); - if (!trainIndex.has_value()) - { - return; - } - - curRide->crash(trainIndex.value()); - - if (curRide->status != RideStatus::closed) - { - // We require this to execute right away during the simulation, always ignore network and queue. - auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction, getGameState()); - } - } - - curRide->lifecycleFlags |= RIDE_LIFECYCLE_CRASHED; - curRide->windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); - KillAllPassengersInTrain(); - - Vehicle* lastVehicle = this; - for (Vehicle* train = getGameState().entities.GetEntity(Id); train != nullptr; - train = getGameState().entities.GetEntity(train->next_vehicle_on_train)) - { - lastVehicle = train; - - train->sub_state = 2; - -#ifdef ENABLE_SCRIPTING - InvokeVehicleCrashHook(train->Id, "another_vehicle"); -#endif - const auto trainLoc = train->GetLocation(); - - Play3D(SoundId::crash, trainLoc); - - ExplosionCloud::Create(trainLoc); - - for (int32_t i = 0; i < 10; i++) - { - VehicleCrashParticle::Create(train->colours, trainLoc); - } - - train->SetFlag(VehicleFlags::Crashed); - train->animationState = ScenarioRand() & 0xFFFF; - - train->animation_frame = ScenarioRand() & 0x7; - train->SpriteData.Width = 13; - train->SpriteData.HeightMin = 45; - train->SpriteData.HeightMax = 5; - - train->MoveTo(trainLoc); - - train->SwingSpeed = 0; - } - - // Remove the current train from the ride linked list of trains - auto prevTrain = getGameState().entities.GetEntity(prev_vehicle_on_ride); - auto nextTrain = getGameState().entities.GetEntity(lastVehicle->next_vehicle_on_ride); - if (prevTrain == nullptr || nextTrain == nullptr) - { - LOG_ERROR("Corrupted vehicle list for ride!"); - } - else - { - prevTrain->next_vehicle_on_ride = lastVehicle->next_vehicle_on_ride; - nextTrain->prev_vehicle_on_ride = prev_vehicle_on_ride; - } - - velocity = 0; -} - -/** - * - * rct2: 0x006D9EFE - */ -void Vehicle::UpdateCrashSetup() -{ - auto curRide = GetRide(); - if (curRide != nullptr && curRide->status == RideStatus::simulating) - { - SimulateCrash(); - return; - } - SetState(Status::crashing, sub_state); - - if (NumPeepsUntilTrainTail() != 0) - { - Play3D(SoundId::hauntedHouseScream2, GetLocation()); - } - - int32_t edx = velocity >> 10; - - Vehicle* lastVehicle = this; - auto spriteId = Id; - for (Vehicle* trainVehicle; !spriteId.IsNull(); spriteId = trainVehicle->next_vehicle_on_train) - { - trainVehicle = getGameState().entities.GetEntity(spriteId); - if (trainVehicle == nullptr) - { - break; - } - lastVehicle = trainVehicle; - - trainVehicle->sub_state = 0; - auto crashDirection = Geometry::getCrashDirectionComponents(trainVehicle->Orientation); - int32_t trainX = crashDirection.x; - int32_t trainY = crashDirection.y; - - auto carLaunchDirection = Geometry::getPitchVector32(trainVehicle->pitch); - - auto trainZ = carLaunchDirection.y >> 23; - int32_t ecx = carLaunchDirection.x >> 15; - trainX *= ecx; - trainY *= ecx; - trainX >>= 16; - trainY >>= 16; - trainX *= edx; - trainY *= edx; - trainZ *= edx; - trainX >>= 8; - trainY >>= 8; - trainZ >>= 8; - - trainVehicle->crash_x = trainX; - trainVehicle->crash_y = trainY; - trainVehicle->crash_z = trainZ; - trainVehicle->crash_x += (ScenarioRand() & 0xF) - 8; - trainVehicle->crash_y += (ScenarioRand() & 0xF) - 8; - trainVehicle->crash_z += (ScenarioRand() & 0xF) - 8; - - trainVehicle->TrackLocation = { 0, 0, 0 }; - } - - // Remove the current train from the ride linked list of trains - auto prevTrain = getGameState().entities.GetEntity(prev_vehicle_on_ride); - auto nextTrain = getGameState().entities.GetEntity(lastVehicle->next_vehicle_on_ride); - if (prevTrain == nullptr || nextTrain == nullptr) - { - LOG_ERROR("Corrupted vehicle list for ride!"); - } - else - { - prevTrain->next_vehicle_on_ride = lastVehicle->next_vehicle_on_ride; - nextTrain->prev_vehicle_on_ride = prev_vehicle_on_ride; - } - velocity = 0; -} - -/** - * - * rct2: 0x006D8937 - */ -void Vehicle::UpdateTravelling() -{ - CheckIfMissing(); - - auto curRide = GetRide(); - if (curRide == nullptr || (_vehicleBreakdown == 0 && curRide->mode == RideMode::rotatingLift)) - return; - - if (sub_state == 2) - { - velocity = 0; - acceleration = 0; - var_C0--; - if (var_C0 == 0) - sub_state = 0; - } - - if (curRide->mode == RideMode::freefallDrop && animation_frame != 0) - { - animation_frame++; - velocity = 0; - acceleration = 0; - Invalidate(); - return; - } - - uint32_t curFlags = UpdateTrackMotion(nullptr); - - bool skipCheck = false; - if (curFlags & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_8 | VEHICLE_UPDATE_MOTION_TRACK_FLAG_9) - && curRide->mode == RideMode::reverseInclineLaunchedShuttle && sub_state == 0) - { - sub_state = 1; - velocity = 0; - skipCheck = true; - } - - if (!skipCheck) - { - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_DERAILED) - { - UpdateCrashSetup(); - return; - } - - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION) - { - UpdateCollisionSetup(); - return; - } - - if (curFlags & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_5 | VEHICLE_UPDATE_MOTION_TRACK_FLAG_12)) - { - if (curRide->mode == RideMode::rotatingLift) - { - if (sub_state <= 1) - { - SetState(Status::arriving, 1); - var_C0 = 0; - return; - } - } - else if (curRide->mode == RideMode::boatHire) - { - UpdateTravellingBoatHireSetup(); - return; - } - if (curRide->mode == RideMode::shuttle) - { - Flags ^= VehicleFlags::PoweredCarInReverse; - velocity = 0; - } - else - { - if (sub_state != 0) - { - UpdateCrashSetup(); - return; - } - sub_state = 1; - velocity = 0; - } - } - } - - if (curRide->mode == RideMode::rotatingLift && sub_state <= 1) - { - if (sub_state == 0) - { - if (velocity >= -131940) - acceleration = -3298; - velocity = std::max(velocity, -131940); - } - else - { - if (CurrentTowerElementIsTop()) - { - velocity = 0; - sub_state = 2; - var_C0 = 150; - } - else - { - if (velocity <= 131940) - acceleration = 3298; - } - } - } - - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL) - { - if (curRide->mode == RideMode::reverseInclineLaunchedShuttle) - { - if (sub_state == 0) - { - if (velocity != 0) - sound2_flags |= VEHICLE_SOUND2_FLAGS_LIFT_HILL; - - if (!HasFlag(VehicleFlags::ReverseInclineCompletedLap)) - { - if (velocity >= curRide->liftHillSpeed * -31079) - { - acceleration = -15539; - - if (_vehicleBreakdown == 0) - { - sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; - SetFlag(VehicleFlags::StoppedBySafetyCutOut); - } - } - } - } - } - else - { - sound2_flags |= VEHICLE_SOUND2_FLAGS_LIFT_HILL; - if (velocity <= curRide->liftHillSpeed * 31079) - { - acceleration = 15539; - if (velocity != 0) - { - if (_vehicleBreakdown == 0) - { - SetFlag(VehicleFlags::StoppedBySafetyCutOut); - sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; - } - } - else - { - sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; - } - } - } - } - - if (!(curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_3)) - return; - - if (curRide->mode == RideMode::reverseInclineLaunchedShuttle && velocity >= 0 - && !HasFlag(VehicleFlags::ReverseInclineCompletedLap)) - { - return; - } - - if (curRide->mode == RideMode::poweredLaunchPasstrough && velocity < 0) - return; - - SetState(Status::arriving); - current_station = _vehicleStationIndex; - var_C0 = 0; - if (velocity < 0) - sub_state = 1; -} - -void Vehicle::UpdateArrivingPassThroughStation(const Ride& curRide, const CarEntry& carEntry, bool stationBrakesWork) -{ - if (sub_state == 0) - { - if (curRide.mode == RideMode::race && curRide.lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) - { - return; - } - - if (velocity <= 131940) - { - acceleration = 3298; - return; - } - - int32_t velocity_diff = velocity; - if (velocity_diff >= 24.0_mph) - velocity_diff /= 8; - else - velocity_diff /= 16; - - if (!stationBrakesWork) - { - return; - } - - if (curRide.numCircuits != 1) - { - if (NumLaps + 1 < curRide.numCircuits) - { - return; - } - } - velocity -= velocity_diff; - acceleration = 0; - } - else - { - if (!carEntry.flags.has(CarEntryFlag::isPowered) && velocity >= -131940) - { - acceleration = -3298; - } - - if (velocity >= -131940) - { - return; - } - - int32_t velocity_diff = velocity; - if (velocity_diff < -24.0_mph) - velocity_diff /= 8; - else - velocity_diff /= 16; - - if (!stationBrakesWork) - { - return; - } - - if (NumLaps + 1 < curRide.numCircuits) - { - return; - } - - if (NumLaps + 1 != curRide.numCircuits) - { - velocity -= velocity_diff; - acceleration = 0; - return; - } - - if (GetRideTypeDescriptor(curRide.type).HasFlag(RtdFlag::allowMultipleCircuits) && curRide.mode != RideMode::shuttle - && curRide.mode != RideMode::poweredLaunch) - { - SetFlag(VehicleFlags::ReverseInclineCompletedLap); - } - else - { - velocity -= velocity_diff; - acceleration = 0; - } - } -} - -/** - * - * rct2: 0x006D8C36 - */ -void Vehicle::UpdateArriving() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - bool stationBrakesWork = true; - uint32_t curFlags = 0; - - switch (curRide->mode) - { - case RideMode::swing: - case RideMode::rotation: - case RideMode::forwardRotation: - case RideMode::backwardRotation: - case RideMode::filmAvengingAviators: - case RideMode::filmThrillRiders: - case RideMode::beginners: - case RideMode::intense: - case RideMode::berserk: - case RideMode::mouseTails3DFilm: - case RideMode::stormChasers3DFilm: - case RideMode::spaceRaiders3DFilm: - case RideMode::circus: - case RideMode::spaceRings: - case RideMode::hauntedHouse: - case RideMode::crookedHouse: - ClearFlag(VehicleFlags::ReverseInclineCompletedLap); - velocity = 0; - acceleration = 0; - SetState(Status::unloadingPassengers); - return; - default: - { - // This is workaround for multiple compilation errors of type "enumeration value ‘RIDE_MODE_*' not handled - // in switch [-Werror=switch]" - } - } - - bool hasBrakesFailure = curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN - && curRide->breakdownReasonPending == BREAKDOWN_BRAKES_FAILURE; - if (hasBrakesFailure && curRide->inspectionStation == current_station - && curRide->mechanicStatus != MechanicStatus::hasFixedStationBrakes) - { - stationBrakesWork = false; - } - - const auto* rideEntry = GetRideEntry(); - const auto& carEntry = rideEntry->Cars[vehicle_type]; - - UpdateArrivingPassThroughStation(*curRide, carEntry, stationBrakesWork); - - curFlags = UpdateTrackMotion(nullptr); - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION && !stationBrakesWork) - { - UpdateCollisionSetup(); - return; - } - - if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION && !stationBrakesWork) - { - SetState(Status::departing, 1); - return; - } - - if (!(curFlags - & (VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION | VEHICLE_UPDATE_MOTION_TRACK_FLAG_1 - | VEHICLE_UPDATE_MOTION_TRACK_FLAG_5))) - { - if (velocity > 98955) - var_C0 = 0; - return; - } - - var_C0++; - if ((curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1) && carEntry.flags.has(CarEntryFlag::isGoKart) && (var_C0 < 40)) - { - return; - } - - auto trackElement = MapGetTrackElementAt(TrackLocation); - - if (trackElement == nullptr) - { - return; - } - - current_station = trackElement->GetStationIndex(); - NumLaps++; - - if (sub_state != 0) - { - if (NumLaps < curRide->numCircuits) - { - SetState(Status::departing, 1); - return; - } - - if (NumLaps == curRide->numCircuits && HasFlag(VehicleFlags::ReverseInclineCompletedLap)) - { - SetState(Status::departing, 1); - return; - } - } - - if (curRide->numCircuits != 1 && NumLaps < curRide->numCircuits) - { - SetState(Status::departing, 1); - return; - } - - if ((curRide->mode == RideMode::upwardLaunch || curRide->mode == RideMode::downwardLaunch) && NumLaunches < 2) - { - Play3D(SoundId::rideLaunch2, GetLocation()); - velocity = 0; - acceleration = 0; - SetState(Status::departing, 1); - return; - } - - if (curRide->mode == RideMode::race && curRide->lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) - { - SetState(Status::departing, 1); - return; - } - - ClearFlag(VehicleFlags::ReverseInclineCompletedLap); - velocity = 0; - acceleration = 0; - SetState(Status::unloadingPassengers); -} - -/** - * - * rct2: 0x006D9002 - */ -void Vehicle::UpdateUnloadingPassengers() -{ - if (sub_state == 0) - { - if (OpenRestraints()) - { - sub_state = 1; - } - } - - const auto* curRide = GetRide(); - if (curRide == nullptr) - return; - - const auto& currentStation = curRide->getStation(current_station); - - if (curRide->mode == RideMode::forwardRotation || curRide->mode == RideMode::backwardRotation) - { - uint8_t seat = ((-flatRideAnimationFrame) >> 3) & 0xF; - if (restraints_position == 255 && !peep[seat * 2].IsNull()) - { - next_free_seat -= 2; - - auto firstGuest = getGameState().entities.GetEntity(peep[seat * 2]); - peep[seat * 2] = EntityId::GetNull(); - - if (firstGuest != nullptr) - { - firstGuest->SetState(PeepState::leavingRide); - firstGuest->RideSubState = PeepRideSubState::leaveVehicle; - } - - auto secondGuest = getGameState().entities.GetEntity(peep[seat * 2 + 1]); - peep[seat * 2 + 1] = EntityId::GetNull(); - - if (secondGuest != nullptr) - { - secondGuest->SetState(PeepState::leavingRide); - secondGuest->RideSubState = PeepRideSubState::leaveVehicle; - } - } - } - else - { - if (currentStation.Exit.IsNull()) - { - if (sub_state != 1) - return; - - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_TESTED) && HasFlag(VehicleFlags::Testing) - && curRide->currentTestSegment + 1 >= curRide->numStations) - { - UpdateTestFinish(); - } - SetState(Status::movingToEndOfStation); - return; - } - - for (Vehicle* train = getGameState().entities.GetEntity(Id); train != nullptr; - train = getGameState().entities.GetEntity(train->next_vehicle_on_train)) - { - if (train->restraints_position != 255) - continue; - - if (train->next_free_seat == 0) - continue; - - train->next_free_seat = 0; - for (uint8_t peepIndex = 0; peepIndex < train->num_peeps; peepIndex++) - { - Peep* curPeep = getGameState().entities.GetEntity(train->peep[peepIndex]); - if (curPeep != nullptr) - { - curPeep->SetState(PeepState::leavingRide); - curPeep->RideSubState = PeepRideSubState::leaveVehicle; - } - } - } - } - - if (sub_state != 1) - return; - - for (Vehicle* train = getGameState().entities.GetEntity(Id); train != nullptr; - train = getGameState().entities.GetEntity(train->next_vehicle_on_train)) - { - if (train->num_peeps != train->next_free_seat) - return; - } - - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_TESTED) && HasFlag(VehicleFlags::Testing) - && curRide->currentTestSegment + 1 >= curRide->numStations) - { - UpdateTestFinish(); - } - SetState(Status::movingToEndOfStation); -} - /** * * rct2: 0x006D9CE9 @@ -3166,12 +1061,12 @@ void Vehicle::UpdateTravellingCableLift() if (sub_state == 0) { - if (HasFlag(VehicleFlags::TrainIsBroken)) + if (flags.has(VehicleFlag::trainIsBroken)) { - if (curRide->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) + if (curRide->flags.has(RideFlag::brokenDown)) return; - curRide->lifecycleFlags |= RIDE_LIFECYCLE_BROKEN_DOWN; + curRide->flags.set(RideFlag::brokenDown); RideBreakdownAddNewsItem(*curRide); curRide->windowInvalidateFlags.set( RideInvalidateFlag::main, RideInvalidateFlag::list, RideInvalidateFlag::maintenance); @@ -3185,9 +1080,9 @@ void Vehicle::UpdateTravellingCableLift() sub_state = 1; PeepEasterEggHereWeAre(); - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_TESTED)) + if (!curRide->flags.has(RideFlag::tested)) { - if (HasFlag(VehicleFlags::Testing)) + if (flags.has(VehicleFlag::testing)) { if (curRide->currentTestSegment + 1 < curRide->numStations) { @@ -3199,7 +1094,7 @@ void Vehicle::UpdateTravellingCableLift() UpdateTestFinish(); } } - else if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_TEST_IN_PROGRESS) && !IsGhost()) + else if (!curRide->flags.has(RideFlag::testInProgress) && !IsGhost()) { TestReset(); } @@ -3243,1449 +1138,6 @@ void Vehicle::UpdateTravellingCableLift() currentStation.Depart |= waitingTime; } -/** - * - * rct2: 0x006D9820 - */ -void Vehicle::UpdateTravellingBoat() -{ - CheckIfMissing(); - UpdateMotionBoatHire(); -} - -void Vehicle::TryReconnectBoatToTrack(const CoordsXY& currentBoatLocation, const CoordsXY& trackCoords) -{ - remaining_distance = 0; - if (!UpdateMotionCollisionDetection({ currentBoatLocation, z }, nullptr)) - { - TrackLocation.x = trackCoords.x; - TrackLocation.y = trackCoords.y; - - auto curRide = GetRide(); - if (curRide != nullptr) - { - auto trackElement = MapGetTrackElementAt(TrackLocation); - if (trackElement != nullptr) - SetTrackType(trackElement->GetTrackType()); - - SetTrackDirection(curRide->boatHireReturnDirection); - BoatLocation.SetNull(); - } - - track_progress = 0; - SetState(Status::travelling, sub_state); - _vehicleCurPosition.x = currentBoatLocation.x; - _vehicleCurPosition.y = currentBoatLocation.y; - } -} - -/** - * - * rct2: 0x006DA717 - */ -void Vehicle::UpdateMotionBoatHire() -{ - _vehicleMotionTrackFlags = 0; - velocity += acceleration; - _vehicleVelocityF64E08 = velocity; - _vehicleVelocityF64E0C = (velocity >> 10) * 42; - - auto carEntry = Entry(); - if (carEntry == nullptr) - { - return; - } - if (carEntry->flags.hasAny(CarEntryFlag::hasVehicleAnimation, CarEntryFlag::hasRiderAnimation)) - { - UpdateAdditionalAnimation(); - } - - _vehicleUnkF64E10 = 1; - acceleration = 0; - remaining_distance += _vehicleVelocityF64E0C; - if (remaining_distance >= 0x368A) - { - sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; - _vehicleCurPosition = GetLocation(); - Invalidate(); - - for (;;) - { - // Loc6DA7A5 - var_35++; - auto loc = BoatLocation.ToTileCentre(); - CoordsXY loc2 = loc; - uint8_t bl; - - loc2.x -= x; - if (loc2.x >= 0) - { - loc2.y -= y; - if (loc2.y < 0) - { - // Loc6DA81A: - loc2.y = -loc2.y; - bl = 24; - if (loc2.y <= loc2.x * 4) - { - bl = 16; - if (loc2.x <= loc2.y * 4) - { - bl = 20; - } - } - } - else - { - bl = 8; - if (loc2.y <= loc2.x * 4) - { - bl = 16; - if (loc2.x <= loc2.y * 4) - { - bl = 12; - } - } - } - } - else - { - loc2.y -= y; - if (loc2.y < 0) - { - // Loc6DA83D: - loc2.x = -loc2.x; - loc2.y = -loc2.y; - bl = 24; - if (loc2.y <= loc2.x * 4) - { - bl = 0; - if (loc2.x <= loc2.y * 4) - { - bl = 28; - } - } - } - else - { - loc2.x = -loc2.x; - bl = 8; - if (loc2.y <= loc2.x * 4) - { - bl = 0; - if (loc2.x <= loc2.y * 4) - { - bl = 4; - } - } - } - } - - // Loc6DA861: - var_34 = bl; - loc2.x += loc2.y; - if (loc2.x <= 12) - { - UpdateBoatLocation(); - } - - if (!(var_35 & (1 << 0))) - { - uint8_t spriteDirection = Orientation; - if (spriteDirection != var_34) - { - uint8_t dl = (var_34 + 16 - spriteDirection) & 0x1E; - if (dl >= 16) - { - spriteDirection += 2; - if (dl > 24) - { - var_35--; - } - } - else - { - spriteDirection -= 2; - if (dl < 8) - { - var_35--; - } - } - - Orientation = spriteDirection & 0x1E; - } - } - - int32_t edi = (Orientation | (var_35 & 1)) & 0x1F; - loc2 = { x + Geometry::getFreeroamVehicleMovementData(edi).x, y + Geometry::getFreeroamVehicleMovementData(edi).y }; - if (UpdateMotionCollisionDetection({ loc2, z }, nullptr)) - { - remaining_distance = 0; - if (Orientation == var_34) - { - Orientation ^= (1 << 4); - UpdateBoatLocation(); - Orientation ^= (1 << 4); - } - break; - } - - auto flooredLocation = loc2.ToTileStart(); - if (flooredLocation != TrackLocation) - { - if (!vehicle_boat_is_location_accessible({ loc2, TrackLocation.z })) - { - // Loc6DA939: - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - bool do_Loc6DAA97 = false; - if (sub_state != BoatHireSubState::EnteringReturnPosition) - { - do_Loc6DAA97 = true; - } - else - { - auto flooredTileLoc = TileCoordsXY(flooredLocation); - if (curRide->boatHireReturnPosition != flooredTileLoc) - { - do_Loc6DAA97 = true; - } - } - - // Loc6DAA97: - if (do_Loc6DAA97) - { - remaining_distance = 0; - if (Orientation == var_34) - { - UpdateBoatLocation(); - } - break; - } - - if (!(curRide->boatHireReturnDirection & 1)) - { - uint16_t tilePart = loc2.y % kCoordsXYStep; - if (tilePart == kCoordsXYHalfTile) - { - TryReconnectBoatToTrack(loc2, flooredLocation); - break; - } - loc2 = _vehicleCurPosition; - if (tilePart <= kCoordsXYHalfTile) - { - loc2.y += 1; - } - else - { - loc2.y -= 1; - } - } - else - { - // Loc6DA9A2: - uint16_t tilePart = loc2.x % kCoordsXYStep; - if (tilePart == kCoordsXYHalfTile) - { - TryReconnectBoatToTrack(loc2, flooredLocation); - break; - } - loc2 = _vehicleCurPosition; - if (tilePart <= kCoordsXYHalfTile) - { - loc2.x += 1; - } - else - { - loc2.x -= 1; - } - } - - // Loc6DA9D1: - remaining_distance = 0; - if (!UpdateMotionCollisionDetection({ loc2, z }, nullptr)) - { - _vehicleCurPosition.x = loc2.x; - _vehicleCurPosition.y = loc2.y; - } - break; - } - TrackLocation = { flooredLocation, TrackLocation.z }; - } - - remaining_distance -= Geometry::getFreeroamVehicleMovementData(edi).distance; - _vehicleCurPosition.x = loc2.x; - _vehicleCurPosition.y = loc2.y; - if (remaining_distance < 0x368A) - { - break; - } - _vehicleUnkF64E10++; - } - - MoveTo(_vehicleCurPosition); - } - - // Loc6DAAC9: - { - int32_t edx = velocity >> 8; - edx = (edx * edx); - if (velocity < 0) - { - edx = -edx; - } - edx >>= 5; - - // Hack to fix people messing with boat hire - int32_t curMass = mass == 0 ? 1 : mass; - - int32_t eax = ((velocity >> 1) + edx) / curMass; - int32_t newAcceleration = -eax; - if (carEntry->flags.has(CarEntryFlag::isPowered)) - { - eax = speed << 14; - int32_t ebx = (speed * curMass) >> 2; - if (HasFlag(VehicleFlags::PoweredCarInReverse)) - { - eax = -eax; - } - eax -= velocity; - edx = powered_acceleration * 2; - if (ebx != 0) - { - newAcceleration += (eax * edx) / ebx; - } - } - acceleration = newAcceleration; - } - // eax = _vehicleMotionTrackFlags; - // ebx = _vehicleStationIndex; -} - -/** - * - * rct2: 0x006DA280 - */ -void Vehicle::UpdateBoatLocation() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - TileCoordsXY returnPosition = curRide->boatHireReturnPosition; - uint8_t returnDirection = curRide->boatHireReturnDirection & 3; - - CoordsXY location = CoordsXY{ x, y } + CoordsDirectionDelta[returnDirection]; - - if (location.ToTileStart() == returnPosition.ToCoordsXY()) - { - sub_state = BoatHireSubState::EnteringReturnPosition; - BoatLocation = location.ToTileStart(); - return; - } - - sub_state = BoatHireSubState::Normal; - uint8_t curDirection = ((Orientation + 19) >> 3) & 3; - uint8_t randDirection = ScenarioRand() & 3; - - if (lost_time_out > 1920) - { - if (ScenarioRand() & 1) - { - CoordsXY destLocation = (returnPosition.ToCoordsXY() - CoordsDirectionDelta[returnDirection]).ToTileCentre(); - - destLocation.x -= x; - destLocation.y -= y; - - if (abs(destLocation.x) <= abs(destLocation.y)) - { - randDirection = destLocation.y < 0 ? 3 : 1; - } - else - { - randDirection = destLocation.x < 0 ? 0 : 2; - } - } - } - - static constexpr int8_t rotations[] = { 0, 1, -1, 2 }; - for (auto rotation : rotations) - { - if (randDirection + rotation == curDirection) - { - continue; - } - - auto trackLocation = TrackLocation; - trackLocation += CoordsDirectionDelta[(randDirection + rotation) & 3]; - - if (!vehicle_boat_is_location_accessible(trackLocation)) - { - continue; - } - - BoatLocation = trackLocation.ToTileStart(); - return; - } - - CoordsXY trackLocation = TrackLocation; - trackLocation += CoordsDirectionDelta[curDirection & 3]; - BoatLocation = trackLocation.ToTileStart(); -} - -/** - * - * rct2: 0x006DA22A - */ -static bool vehicle_boat_is_location_accessible(const CoordsXYZ& location) -{ - TileElement* tileElement = MapGetFirstElementAt(location); - if (tileElement == nullptr) - return false; - do - { - if (tileElement->IsGhost()) - continue; - - if (tileElement->GetType() == TileElementType::Surface) - { - int32_t waterZ = tileElement->AsSurface()->GetWaterHeight(); - if (location.z != waterZ) - { - return false; - } - } - else - { - if (location.z > (tileElement->GetBaseZ() - (2 * kCoordsZStep)) - && location.z < tileElement->GetClearanceZ() + (2 * kCoordsZStep)) - { - return false; - } - } - } while (!(tileElement++)->IsLastForTile()); - return true; -} - -/** - * - * rct2: 0x006D9249 - */ -void Vehicle::UpdateSwinging() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - auto rideEntry = GetRideEntry(); - if (rideEntry == nullptr) - return; - - // SubState for this ride means swinging state - // 0 == first swing - // 3 == full swing - uint8_t swingState = sub_state; - if (rideEntry->flags & RIDE_ENTRY_FLAG_INVERTER_SHIP_SWING_MODE) - { - swingState += 4; - if (rideEntry->flags & RIDE_ENTRY_FLAG_MAGIC_CARPET_SWING_MODE) - swingState += 4; - } - - const auto spriteMap = kSwingingTimeToSpriteMaps[swingState]; - int8_t spriteType = spriteMap[current_time + 1]; - - // 0x80 indicates that a complete swing has been - // completed and the next swing can start - if (spriteType != -128) - { - current_time++; - if (static_cast(spriteType) != flatRideAnimationFrame) - { - // Used to know which sprite to draw - flatRideAnimationFrame = static_cast(spriteType); - Invalidate(); - } - return; - } - - current_time = -1; - NumSwings++; - if (curRide->status != RideStatus::closed) - { - // It takes 3 swings to get into full swing - // ride->rotations already takes this into account - if (NumSwings + 3 < curRide->rotations) - { - // Go to the next swing state until we - // are at full swing. - if (sub_state != 3) - { - sub_state++; - } - UpdateSwinging(); - return; - } - } - - // To get to this part of the code the - // swing has to be in slowing down phase - if (sub_state == 0) - { - SetState(Status::arriving); - var_C0 = 0; - return; - } - // Go towards first swing state - sub_state--; - UpdateSwinging(); -} - -/** - * - * rct2: 0x006D9413 - */ -void Vehicle::UpdateFerrisWheelRotating() -{ - if (_vehicleBreakdown == 0) - return; - - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if ((ferris_wheel_var_1 -= 1) != 0) - return; - - int8_t curFerrisWheelVar0 = ferris_wheel_var_0; - - if (curFerrisWheelVar0 == 3) - { - ferris_wheel_var_0 = curFerrisWheelVar0; - ferris_wheel_var_1 = curFerrisWheelVar0; - } - else if (curFerrisWheelVar0 < 3) - { - if (curFerrisWheelVar0 != -8) - curFerrisWheelVar0--; - ferris_wheel_var_0 = curFerrisWheelVar0; - ferris_wheel_var_1 = -curFerrisWheelVar0; - } - else - { - curFerrisWheelVar0--; - ferris_wheel_var_0 = curFerrisWheelVar0; - ferris_wheel_var_1 = curFerrisWheelVar0; - } - - uint8_t rotation = flatRideAnimationFrame; - if (curRide->mode == RideMode::forwardRotation) - rotation++; - else - rotation--; - - rotation &= 0x7F; - flatRideAnimationFrame = rotation; - - if (rotation == sub_state) - NumRotations++; - - Invalidate(); - - uint8_t subState = sub_state; - if (curRide->mode == RideMode::forwardRotation) - subState++; - else - subState--; - subState &= 0x7F; - - if (subState == flatRideAnimationFrame) - { - bool shouldStop = true; - if (curRide->status != RideStatus::closed) - { - if (NumRotations < curRide->rotations) - shouldStop = false; - } - - if (shouldStop) - { - curFerrisWheelVar0 = ferris_wheel_var_0; - ferris_wheel_var_0 = -abs(curFerrisWheelVar0); - ferris_wheel_var_1 = abs(curFerrisWheelVar0); - } - } - - if (ferris_wheel_var_0 != -8) - return; - - subState = sub_state; - if (curRide->mode == RideMode::forwardRotation) - subState += 8; - else - subState -= 8; - subState &= 0x7F; - - if (subState != flatRideAnimationFrame) - return; - - SetState(Status::arriving); - var_C0 = 0; -} - -/** - * - * rct2: 0x006D94F2 - */ -void Vehicle::UpdateSimulatorOperating() -{ - if (_vehicleBreakdown == 0) - return; - - assert(current_time >= -1); - assert(current_time < MotionSimulatorTimeToSpriteMapCount); - uint8_t al = MotionSimulatorTimeToSpriteMap[current_time + 1]; - if (al != 0xFF) - { - current_time++; - if (al == flatRideAnimationFrame) - return; - flatRideAnimationFrame = al; - Invalidate(); - return; - } - - SetState(Status::arriving); - var_C0 = 0; -} - -void UpdateRotatingDefault(Vehicle& vehicle) -{ - vehicle.sub_state = 1; - vehicle.UpdateRotating(); -} - -void UpdateRotatingEnterprise(Vehicle& vehicle) -{ - if (vehicle.sub_state == 2) - { - vehicle.SetState(Vehicle::Status::arriving); - vehicle.var_C0 = 0; - return; - } - - UpdateRotatingDefault(vehicle); -} - -/** - * - * rct2: 0x006D92FF - */ -void Vehicle::UpdateRotating() -{ - if (_vehicleBreakdown == 0) - return; - - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - auto rideEntry = GetRideEntry(); - if (rideEntry == nullptr) - { - return; - } - - const uint8_t* timeToSpriteMap; - if (rideEntry->flags & RIDE_ENTRY_FLAG_TWIST_ROTATION_TYPE) - { - timeToSpriteMap = kTwistTimeToSpriteMaps[sub_state]; - } - else if (rideEntry->flags & RIDE_ENTRY_FLAG_ENTERPRISE_ROTATION_TYPE) - { - timeToSpriteMap = kEnterpriseTimeToSpriteMaps[sub_state]; - } - else - { - timeToSpriteMap = kMerryGoRoundTimeToSpriteMaps[sub_state]; - } - - uint16_t time = current_time; - if (_vehicleBreakdown == BREAKDOWN_CONTROL_FAILURE) - { - time += (curRide->breakdownSoundModifier >> 6) + 1; - } - time++; - - uint8_t sprite = timeToSpriteMap[time]; - if (sprite != 0xFF) - { - current_time = time; - if (sprite == flatRideAnimationFrame) - return; - flatRideAnimationFrame = sprite; - Invalidate(); - return; - } - - current_time = -1; - NumRotations++; - if (_vehicleBreakdown != BREAKDOWN_CONTROL_FAILURE) - { - bool shouldStop = true; - if (curRide->status != RideStatus::closed) - { - sprite = NumRotations + 1; - if (curRide->getRideTypeDescriptor().specialType == RtdSpecialType::enterprise) - sprite += 9; - - if (sprite < curRide->rotations) - shouldStop = false; - } - - if (shouldStop) - { - if (sub_state == 2) - { - SetState(Status::arriving); - var_C0 = 0; - return; - } - sub_state++; - UpdateRotating(); - return; - } - } - - const auto& rtd = GetRideTypeDescriptor(curRide->type); - rtd.UpdateRotating(*this); -} - -/** - * - * rct2: 0x006D97CB - */ -void Vehicle::UpdateSpaceRingsOperating() -{ - if (_vehicleBreakdown == 0) - return; - - uint8_t spriteType = kSpaceRingsTimeToSpriteMap[current_time + 1]; - if (spriteType != 255) - { - current_time++; - if (spriteType != flatRideAnimationFrame) - { - flatRideAnimationFrame = spriteType; - Invalidate(); - } - } - else - { - SetState(Status::arriving); - var_C0 = 0; - } -} - -/** - * - * rct2: 0x006D9641 - */ -void Vehicle::UpdateHauntedHouseOperating() -{ - if (_vehicleBreakdown == 0) - return; - - if (flatRideAnimationFrame != 0) - { - if (getGameState().currentTicks & 1) - { - flatRideAnimationFrame++; - Invalidate(); - - if (flatRideAnimationFrame == 19) - flatRideAnimationFrame = 0; - } - } - - if (current_time + 1 > 1500) - { - SetState(Status::arriving); - var_C0 = 0; - return; - } - - current_time++; - switch (current_time) - { - case 45: - Play3D(SoundId::hauntedHouseScare, GetLocation()); - break; - case 75: - flatRideAnimationFrame = 1; - Invalidate(); - break; - case 400: - Play3D(SoundId::hauntedHouseScream1, GetLocation()); - break; - case 745: - Play3D(SoundId::hauntedHouseScare, GetLocation()); - break; - case 775: - flatRideAnimationFrame = 1; - Invalidate(); - break; - case 1100: - Play3D(SoundId::hauntedHouseScream2, GetLocation()); - break; - } -} - -/** - * - * rct2: 0x006d9781 - */ -void Vehicle::UpdateCrookedHouseOperating() -{ - if (_vehicleBreakdown == 0) - return; - - // Originally used an array of size 1 at 0x009A0AC4 and passed the sub state into it. - if (static_cast(current_time + 1) > 600) - { - SetState(Status::arriving); - var_C0 = 0; - return; - } - - current_time++; -} - -/** - * - * rct2: 0x006D9547 - */ -void Vehicle::UpdateTopSpinOperating() -{ - if (_vehicleBreakdown == 0) - return; - - const TopSpinTimeToSpriteMap* sprite_map = kTopSpinTimeToSpriteMaps[sub_state]; - uint8_t rotation = sprite_map[current_time + 1].arm_rotation; - if (rotation != 0xFF) - { - current_time = current_time + 1; - if (rotation != flatRideAnimationFrame) - { - flatRideAnimationFrame = rotation; - Invalidate(); - } - rotation = sprite_map[current_time].bank_rotation; - if (rotation != flatRideSecondaryAnimationFrame) - { - flatRideSecondaryAnimationFrame = rotation; - Invalidate(); - } - return; - } - - SetState(Status::arriving); - var_C0 = 0; -} - -/** - * - * rct2: 0x006D95AD - */ -void Vehicle::UpdateShowingFilm() -{ - if (_vehicleBreakdown == 0) - return; - - int32_t totalTime = kRideFilmLength[sub_state]; - int32_t currentTime = current_time + 1; - if (currentTime <= totalTime) - { - current_time = currentTime; - } - else - { - SetState(Status::arriving); - var_C0 = 0; - } -} - -/** - * - * rct2: 0x006D95F7 - */ -void Vehicle::UpdateDoingCircusShow() -{ - if (_vehicleBreakdown == 0) - return; - - int32_t currentTime = current_time + 1; - if (currentTime <= 5000) - { - current_time = currentTime; - } - else - { - SetState(Status::arriving); - var_C0 = 0; - } -} - -/** - * - * rct2: 0x0068B8BD - * @returns the map element that the vehicle will collide with or NULL if no collisions. - */ -static TileElement* vehicle_check_collision(const CoordsXYZ& vehiclePosition) -{ - TileElement* tileElement = MapGetFirstElementAt(vehiclePosition); - if (tileElement == nullptr) - { - return nullptr; - } - - uint8_t quadrant; - if ((vehiclePosition.x & 0x1F) >= 16) - { - quadrant = 1; - if ((vehiclePosition.y & 0x1F) < 16) - quadrant = 2; - } - else - { - quadrant = 4; - if ((vehiclePosition.y & 0x1F) >= 16) - quadrant = 8; - } - - do - { - if (vehiclePosition.z < tileElement->GetBaseZ()) - continue; - - if (vehiclePosition.z >= tileElement->GetClearanceZ()) - continue; - - if (tileElement->GetOccupiedQuadrants() & quadrant) - return tileElement; - } while (!(tileElement++)->IsLastForTile()); - - return nullptr; -} - -static void ride_train_crash(Ride& ride, uint16_t numFatalities) -{ - Formatter ft; - ft.Add(numFatalities); - - uint8_t crashType = numFatalities == 0 ? RIDE_CRASH_TYPE_NO_FATALITIES : RIDE_CRASH_TYPE_FATALITIES; - - if (crashType >= ride.lastCrashType) - ride.lastCrashType = crashType; - - if (numFatalities != 0) - { - if (Config::Get().notifications.rideCasualties) - { - ride.formatNameTo(ft); - News::AddItemToQueue( - News::ItemType::ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, - ride.id.ToUnderlying(), ft); - } - - // TODO: get park id from ride/vehicle - auto& park = getGameState().park; - if (park.ratingCasualtyPenalty < 500) - { - park.ratingCasualtyPenalty += 200; - } - } -} -/** - * - * rct2: 0x006DE6C6 - */ -void Vehicle::KillAllPassengersInTrain() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - ride_train_crash(*curRide, NumPeepsUntilTrainTail()); - - for (Vehicle* trainCar = getGameState().entities.GetEntity(Id); trainCar != nullptr; - trainCar = getGameState().entities.GetEntity(trainCar->next_vehicle_on_train)) - { - trainCar->KillPassengers(*curRide); - } -} - -void Vehicle::KillPassengers(const Ride& curRide) -{ - if (num_peeps != next_free_seat) - return; - - if (num_peeps == 0) - return; - - for (auto i = 0; i < num_peeps; i++) - { - auto* curPeep = getGameState().entities.GetEntity(peep[i]); - if (curPeep == nullptr) - continue; - - if (!curPeep->OutsideOfPark) - { - DecrementGuestsInPark(); - auto intent = Intent(INTENT_ACTION_UPDATE_GUEST_COUNT); - ContextBroadcastIntent(&intent); - } - PeepEntityRemove(curPeep); - } - - num_peeps = 0; - next_free_seat = 0; -} - -void Vehicle::CrashOnLand() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if (curRide->status == RideStatus::simulating) - { - SimulateCrash(); - return; - } - SetState(Status::crashed, sub_state); - -#ifdef ENABLE_SCRIPTING - InvokeVehicleCrashHook(Id, "land"); -#endif - - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) - { - auto frontVehicle = GetHead(); - auto trainIndex = ride_get_train_index_from_vehicle(*curRide, frontVehicle->Id); - if (!trainIndex.has_value()) - { - return; - } - - curRide->crash(trainIndex.value()); - - if (curRide->status != RideStatus::closed) - { - // We require this to execute right away during the simulation, always ignore network and queue. - auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction, getGameState()); - } - } - curRide->lifecycleFlags |= RIDE_LIFECYCLE_CRASHED; - curRide->windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); - - if (IsHead()) - { - KillAllPassengersInTrain(); - } - - sub_state = 2; - - const auto curLoc = GetLocation(); - Play3D(SoundId::crash, curLoc); - - ExplosionCloud::Create(curLoc); - ExplosionFlare::Create(curLoc); - - uint8_t numParticles = std::min(SpriteData.Width, static_cast(7)); - - while (numParticles-- != 0) - VehicleCrashParticle::Create(colours, curLoc); - - SetFlag(VehicleFlags::Crashed); - animation_frame = 0; - animationState = 0; - SpriteData.Width = 13; - SpriteData.HeightMin = 45; - SpriteData.HeightMax = 5; - - MoveTo(curLoc); - - crash_z = 0; -} - -void Vehicle::CrashOnWater() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - if (curRide->status == RideStatus::simulating) - { - SimulateCrash(); - return; - } - SetState(Status::crashed, sub_state); - -#ifdef ENABLE_SCRIPTING - InvokeVehicleCrashHook(Id, "water"); -#endif - - if (!(curRide->lifecycleFlags & RIDE_LIFECYCLE_CRASHED)) - { - auto frontVehicle = GetHead(); - auto trainIndex = ride_get_train_index_from_vehicle(*curRide, frontVehicle->Id); - if (!trainIndex.has_value()) - { - return; - } - - curRide->crash(trainIndex.value()); - - if (curRide->status != RideStatus::closed) - { - // We require this to execute right away during the simulation, always ignore network and queue. - auto gameAction = GameActions::RideSetStatusAction(curRide->id, RideStatus::closed); - GameActions::ExecuteNested(&gameAction, getGameState()); - } - } - curRide->lifecycleFlags |= RIDE_LIFECYCLE_CRASHED; - curRide->windowInvalidateFlags.set(RideInvalidateFlag::main, RideInvalidateFlag::list); - - if (IsHead()) - { - KillAllPassengersInTrain(); - } - - sub_state = 2; - - const auto curLoc = GetLocation(); - Play3D(SoundId::water1, curLoc); - - CrashSplashParticle::Create(curLoc); - CrashSplashParticle::Create(curLoc + CoordsXYZ{ -8, -9, 0 }); - CrashSplashParticle::Create(curLoc + CoordsXYZ{ 11, -9, 0 }); - CrashSplashParticle::Create(curLoc + CoordsXYZ{ 11, 8, 0 }); - CrashSplashParticle::Create(curLoc + CoordsXYZ{ -4, 8, 0 }); - - for (int32_t i = 0; i < 10; ++i) - VehicleCrashParticle::Create(colours, curLoc + CoordsXYZ{ -4, 8, 0 }); - - SetFlag(VehicleFlags::Crashed); - animation_frame = 0; - animationState = 0; - SpriteData.Width = 13; - SpriteData.HeightMin = 45; - SpriteData.HeightMax = 5; - - MoveTo(curLoc); - - crash_z = -1; -} - -/** - * - * rct2: 0x006D98CA - */ -void Vehicle::UpdateCrash() -{ - for (Vehicle* curVehicle = getGameState().entities.GetEntity(Id); curVehicle != nullptr; - curVehicle = getGameState().entities.GetEntity(curVehicle->next_vehicle_on_train)) - { - CoordsXYZ curPos = curVehicle->GetLocation(); - - if (curVehicle->sub_state > 1) - { - if (curVehicle->crash_z <= 96) - { - curVehicle->crash_z++; - if ((ScenarioRand() & 0xFFFF) <= 0x1555) - { - int32_t xOffset = (ScenarioRand() & 2) - 1; - int32_t yOffset = (ScenarioRand() & 2) - 1; - - ExplosionCloud::Create(curPos + CoordsXYZ{ xOffset, yOffset, 0 }); - } - } - if (curVehicle->animationState <= 0xe388) - { - curVehicle->animationState += 0x1c71; - } - else - { - curVehicle->animationState = 0; - curVehicle->animation_frame++; - if (curVehicle->animation_frame >= 8) - curVehicle->animation_frame = 0; - curVehicle->Invalidate(); - } - continue; - } - - TileElement* collideElement = vehicle_check_collision(curPos); - if (collideElement == nullptr) - { - curVehicle->sub_state = 1; - } - else if (curVehicle->sub_state == 1) - { - curVehicle->CrashOnLand(); - continue; - } - - int16_t height = TileElementHeight(curPos); - int16_t waterHeight = TileElementWaterHeight(curPos); - int16_t zDiff; - if (waterHeight != 0) - { - zDiff = curPos.z - waterHeight; - if (zDiff <= 0 && zDiff >= -20) - { - curVehicle->CrashOnWater(); - continue; - } - } - - zDiff = curPos.z - height; - if ((zDiff <= 0 && zDiff >= -20) || curPos.z < 16) - { - curVehicle->CrashOnLand(); - continue; - } - - curVehicle->Invalidate(); - - curPos.x += static_cast(curVehicle->crash_x >> 8); - curPos.y += static_cast(curVehicle->crash_y >> 8); - curPos.z += static_cast(curVehicle->crash_z >> 8); - curVehicle->TrackLocation = { (curVehicle->crash_x << 8), (curVehicle->crash_y << 8), (curVehicle->crash_z << 8) }; - - if (!MapIsLocationValid(curPos)) - { - curVehicle->CrashOnLand(); - continue; - } - - curVehicle->MoveTo(curPos); - - if (curVehicle->sub_state == 1) - { - curVehicle->crash_z -= 20; - } - } -} -/** - * - * rct2: 0x006D7888 - */ -void Vehicle::UpdateSound() -{ - // frictionVolume (bl) should be set before hand - SoundIdVolume frictionSound = { SoundId::null, 255 }; - // bh screamVolume should be set before hand - SoundIdVolume screamSound = { SoundId::null, 255 }; - - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - auto rideEntry = GetRideEntry(); - if (rideEntry == nullptr) - return; - - // Always use the head car's sound data (Some of the other vehicle subtypes have improperly set data) - auto soundCarIndex = (rideEntry->FrontCar == 0xff) ? rideEntry->DefaultCar : rideEntry->FrontCar; - const auto& carEntry = rideEntry->Cars[soundCarIndex]; - - int32_t ecx = abs(velocity) - 1.0_mph; - if (ecx >= 0) - { - frictionSound.id = carEntry.friction_sound_id; - ecx >>= 15; - frictionSound.volume = std::min(208 + (ecx & 0xFF), 255); - } - - const auto currentTicks = getGameState().currentTicks; - switch (carEntry.soundRange) - { - case SoundRange::steamWhistle: - screamSound.id = scream_sound_id; - if (!(currentTicks & 0x7F)) - { - if (velocity < 4.0_mph || scream_sound_id != SoundId::null) - { - GetLiftHillSound(*curRide, screamSound); - break; - } - - if ((ScenarioRand() & 0xFFFF) <= 0x5555) - { - scream_sound_id = SoundId::trainWhistle; - screamSound.volume = 255; - break; - } - } - if (screamSound.id == SoundId::noScream) - screamSound.id = SoundId::null; - screamSound.volume = 255; - break; - - case SoundRange::tramBell: - screamSound.id = scream_sound_id; - if (!(currentTicks & 0x7F)) - { - if (velocity < 4.0_mph || scream_sound_id != SoundId::null) - { - GetLiftHillSound(*curRide, screamSound); - break; - } - - if ((ScenarioRand() & 0xFFFF) <= 0x5555) - { - scream_sound_id = SoundId::tram; - screamSound.volume = 255; - break; - } - } - if (screamSound.id == SoundId::noScream) - screamSound.id = SoundId::null; - screamSound.volume = 255; - break; - - default: - if (carEntry.flags.has(CarEntryFlag::hasScreamingRiders)) - { - screamSound.id = UpdateScreamSound(); - if (screamSound.id == SoundId::noScream) - { - screamSound.id = SoundId::null; - break; - } - if (screamSound.id != SoundId::null) - { - break; - } - } - GetLiftHillSound(*curRide, screamSound); - } - - // Friction sound - auto soundIdVolume = VehicleSoundFadeInOut(sound1_id, sound1_volume, frictionSound.id, frictionSound.volume); - sound1_id = soundIdVolume.id; - sound1_volume = soundIdVolume.volume; - - // Scream sound - soundIdVolume = VehicleSoundFadeInOut(sound2_id, sound2_volume, screamSound.id, screamSound.volume); - sound2_id = soundIdVolume.id; - sound2_volume = soundIdVolume.volume; - - // Calculate Sound Vector (used for sound frequency calcs) - int32_t soundDirection = Geometry::getSoundDirectionFromOrientation(Orientation); - int32_t soundVector = ((velocity >> 14) * soundDirection) >> 14; - soundVector = std::clamp(soundVector, -127, 127); - - dopplerShift = soundVector & 0xFF; -} - -/** - * - * rct2: 0x006D796B - */ -SoundId Vehicle::UpdateScreamSound() -{ - int32_t totalNumPeeps = NumPeepsUntilTrainTail(); - if (totalNumPeeps == 0) - return SoundId::null; - - if (velocity < 0) - { - if (velocity > -2.75_mph) - return SoundId::null; - - for (Vehicle* vehicle2 = getGameState().entities.GetEntity(Id); vehicle2 != nullptr; - vehicle2 = getGameState().entities.GetEntity(vehicle2->next_vehicle_on_train)) - { - if (vehicle2->pitch < VehiclePitch::up12) - continue; - if (vehicle2->pitch <= VehiclePitch::up60) - return ProduceScreamSound(totalNumPeeps); - if (vehicle2->pitch < VehiclePitch::up75) - continue; - if (vehicle2->pitch <= VehiclePitch::up165) - return ProduceScreamSound(totalNumPeeps); - // up50 occurs on diagonal steep hills - // up8 and up16 occur on diagonal gentle hills - if (vehicle2->pitch == VehiclePitch::up50) - return ProduceScreamSound(totalNumPeeps); - } - return SoundId::null; - } - - if (velocity < 2.75_mph) - return SoundId::null; - - for (Vehicle* vehicle2 = getGameState().entities.GetEntity(Id); vehicle2 != nullptr; - vehicle2 = getGameState().entities.GetEntity(vehicle2->next_vehicle_on_train)) - { - if (vehicle2->pitch < VehiclePitch::down12) - continue; - if (vehicle2->pitch <= VehiclePitch::down60) - return ProduceScreamSound(totalNumPeeps); - if (vehicle2->pitch <= VehiclePitch::inverted) - continue; - if (vehicle2->pitch <= VehiclePitch::down165) - return ProduceScreamSound(totalNumPeeps); - // down50 occurs on diagonal steep drops - // down8 and down16 occur on diagonal gentle drops - if (vehicle2->pitch == VehiclePitch::down50) - return ProduceScreamSound(totalNumPeeps); - } - return SoundId::null; -} - -SoundId Vehicle::ProduceScreamSound(const int32_t totalNumPeeps) -{ - const auto* rideEntry = GetRideEntry(); - - const auto& carEntry = rideEntry->Cars[vehicle_type]; - - if (scream_sound_id == SoundId::null) - { - auto r = ScenarioRand(); - if (totalNumPeeps >= static_cast(r % 16)) - { - switch (carEntry.soundRange) - { - case SoundRange::screamsMisc: - scream_sound_id = _screamSetMisc[r % std::size(_screamSetMisc)]; - break; - case SoundRange::screamsWoodenRollerCoaster: - scream_sound_id = _screamSetWooden[r % std::size(_screamSetWooden)]; - break; - case SoundRange::screamSteelRollerCoaster: - scream_sound_id = _screamSetSteel[r % std::size(_screamSetSteel)]; - break; - default: - scream_sound_id = SoundId::noScream; - break; - } - } - else - { - scream_sound_id = SoundId::noScream; - } - } - return scream_sound_id; -} - /** * * rct2: 0x006D73D0 @@ -4790,3543 +1242,11 @@ int32_t Vehicle::IsUsedInPairs() const return num_seats & kVehicleSeatPairFlag; } -/** - * - * rct2: 0x006DA44E - */ -int32_t Vehicle::UpdateMotionDodgems() -{ - _vehicleMotionTrackFlags = 0; - - auto curRide = GetRide(); - if (curRide == nullptr) - return _vehicleMotionTrackFlags; - - int32_t nextVelocity = velocity + acceleration; - if (curRide->lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN) - && curRide->breakdownReasonPending == BREAKDOWN_SAFETY_CUT_OUT) - { - nextVelocity = 0; - } - velocity = nextVelocity; - - _vehicleVelocityF64E08 = nextVelocity; - _vehicleVelocityF64E0C = (nextVelocity / 1024) * 42; - _vehicleUnkF64E10 = 1; - - acceleration = 0; - if (!(curRide->lifecycleFlags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN)) - || curRide->breakdownReasonPending != BREAKDOWN_SAFETY_CUT_OUT) - { - if ((getGameState().currentTicks & 1) && var_34 != 0) - { - if (var_34 > 0) - { - var_34--; - Orientation += 2; - } - else - { - var_34++; - Orientation -= 2; - } - Orientation &= 0x1E; - Invalidate(); - } - else if ((ScenarioRand() & 0xFFFF) <= 2849) - { - if (var_35 & (1 << 6)) - Orientation -= 2; - else - Orientation += 2; - Orientation &= 0x1E; - Invalidate(); - } - } - - std::optional collideSprite; - if (DodgemsCollisionDirection != 0) - { - uint8_t oldCollisionDirection = DodgemsCollisionDirection & 0x1E; - DodgemsCollisionDirection = 0; - - CoordsXYZ location = { x, y, z }; - - location.x += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection).x; - location.y += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection).y; - location.x += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection + 1).x; - location.y += Geometry::getFreeroamVehicleMovementData(oldCollisionDirection + 1).y; - - if (collideSprite = DodgemsCarWouldCollideAt(location); !collideSprite.has_value()) - { - MoveTo(location); - } - } - - remaining_distance += _vehicleVelocityF64E0C; - - if (remaining_distance >= 13962) - { - sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; - _vehicleCurPosition.x = x; - _vehicleCurPosition.y = y; - _vehicleCurPosition.z = z; - - while (true) - { - var_35++; - uint8_t direction = Orientation; - direction |= var_35 & 1; - - CoordsXY location = _vehicleCurPosition; - location.x += Geometry::getFreeroamVehicleMovementData(direction).x; - location.y += Geometry::getFreeroamVehicleMovementData(direction).y; - - if (collideSprite = DodgemsCarWouldCollideAt(location); collideSprite.has_value()) - { - break; - } - - remaining_distance -= Geometry::getFreeroamVehicleMovementData(direction).distance; - _vehicleCurPosition.x = location.x; - _vehicleCurPosition.y = location.y; - if (remaining_distance < 13962) - { - break; - } - _vehicleUnkF64E10++; - } - - if (remaining_distance >= 13962) - { - int32_t oldVelocity = velocity; - remaining_distance = 0; - velocity = 0; - uint8_t direction = Orientation | 1; - - Vehicle* collideVehicle = getGameState().entities.GetEntity(collideSprite.value()); - if (collideVehicle != nullptr) - { - var_34 = (ScenarioRand() & 1) ? 1 : -1; - - if (oldVelocity >= 2.0_mph) - { - collideVehicle->DodgemsCollisionDirection = direction; - DodgemsCollisionDirection = direction ^ (1 << 4); - } - } - else - { - var_34 = (ScenarioRand() & 1) ? 6 : -6; - - if (oldVelocity >= 2.0_mph) - { - DodgemsCollisionDirection = direction ^ (1 << 4); - } - } - } - - MoveTo(_vehicleCurPosition); - } - - int32_t eax = velocity / 2; - int32_t edx = velocity >> 8; - edx *= edx; - if (velocity < 0) - edx = -edx; - edx >>= 5; - eax += edx; - if (mass != 0) - { - eax /= mass; - } - const auto* rideEntry = GetRideEntry(); - const auto& carEntry = rideEntry->Cars[vehicle_type]; - - if (!carEntry.flags.has(CarEntryFlag::isPowered)) - { - acceleration = -eax; - return _vehicleMotionTrackFlags; - } - - int32_t momentum = (speed * mass) >> 2; - int32_t _eax = speed << 14; - if (HasFlag(VehicleFlags::PoweredCarInReverse)) - { - _eax = -_eax; - } - _eax -= velocity; - _eax *= powered_acceleration * 2; - if (momentum != 0) - _eax /= momentum; - - acceleration = _eax - eax; - return _vehicleMotionTrackFlags; -} - -/** - * - * rct2: 0x006DD365 - */ -static bool wouldCollideWithDodgemsTrackEdge( - const CoordsXY& coords, const CoordsXY& trackLocation, TrackElemType trackType, uint16_t dodgemsCarRadius) -{ - int16_t rideLeft = trackLocation.x + GetDodgemsTrackSize(trackType).left; - int16_t rideRight = trackLocation.x + GetDodgemsTrackSize(trackType).right; - int16_t rideTop = trackLocation.y + GetDodgemsTrackSize(trackType).top; - int16_t rideBottom = trackLocation.y + GetDodgemsTrackSize(trackType).bottom; - - return coords.x - dodgemsCarRadius < rideLeft || coords.y - dodgemsCarRadius < rideTop - || coords.x + dodgemsCarRadius > rideRight || coords.y + dodgemsCarRadius > rideBottom; -} - -std::optional Vehicle::DodgemsCarWouldCollideAt(const CoordsXY& coords) const -{ - auto trackType = GetTrackType(); - - if (wouldCollideWithDodgemsTrackEdge(coords, TrackLocation, trackType, (var_44 * 30) >> 9)) - { - return EntityId::GetNull(); - } - - auto location = coords; - - RideId rideIndex = ride; - for (auto xy_offset : kSurroundingTiles) - { - location += xy_offset; - - for (auto vehicle2 : EntityTileList(location)) - { - if (vehicle2 == this) - continue; - if (vehicle2->ride != rideIndex) - continue; - - int32_t distX = abs(coords.x - vehicle2->x); - if (distX > 32768) - continue; - - int32_t distY = abs(coords.y - vehicle2->y); - if (distY > 32768) - continue; - - int32_t ecx = (var_44 + vehicle2->var_44) / 2; - ecx *= 30; - ecx >>= 8; - if (std::max(distX, distY) < ecx) - { - return vehicle2->Id; - } - } - } - - return std::nullopt; -} - -/** - * - * rct2: 0x006DAB90 - */ -void Vehicle::UpdateTrackMotionUpStopCheck() const -{ - const auto* carEntry = Entry(); - if (carEntry == nullptr) - { - return; - } - - // No up stops (coaster types) - if (carEntry->flags.has(CarEntryFlag::hasNoUpstopWheels)) - { - if (!IsOnCoveredTrack()) - { - auto gForces = GetGForces(); - gForces.lateralG = std::abs(gForces.lateralG); - if (gForces.lateralG <= 150) - { - if (Geometry::getAccelerationFromPitch(pitch) < 0) - { - if (gForces.verticalG > -40) - { - return; - } - } - else if (gForces.verticalG > -80) - { - return; - } - } - - if (pitch != VehiclePitch::down60) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_DERAILED; - } - } - } - else if (carEntry->flags.has(CarEntryFlag::hasNoUpstopWheelsBobsleigh)) - { - // No up stops bobsleigh type - if (!IsOnCoveredTrack()) - { - auto gForces = GetGForces(); - - if (Geometry::getAccelerationFromPitch(pitch) < 0) - { - if (gForces.verticalG > -45) - { - return; - } - } - else - { - if (gForces.verticalG > -80) - { - return; - } - } - - if (pitch != VehiclePitch::down60 && pitch != VehiclePitch::down50) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_DERAILED; - } - } - } -} - -/** - * Modifies the train's velocity to match the block-brake fixed velocity. - * This function must be called when the car is running through a non-stopping - * state block-brake (precondition), which means that the block brake is acting - * merely as a velocity regulator, in a closed state. When the brake is open, it - * boosts the train to the speed limit - */ -void Vehicle::ApplyNonStopBlockBrake() -{ - if (velocity >= 0) - { - // If the vehicle is below the speed limit - if (velocity <= kBlockBrakeBaseSpeed) - { - // Boost it to the fixed block brake speed - velocity = kBlockBrakeBaseSpeed; - acceleration = 0; - } - else if (velocity > (brake_speed << kTrackSpeedShiftAmount) + kBlockBrakeSpeedOffset) - { - velocity -= velocity >> 4; - acceleration = 0; - } - } -} - -/** - * - * Modifies the train's velocity influenced by a block brake - */ -void Vehicle::ApplyStopBlockBrake() -{ - // Slow it down till completely stop the car - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE; - acceleration = 0; - // If the this is slow enough, stop it. If not, slow it down - if (velocity <= 2.0_mph) - { - velocity = 0; - } - else - { - velocity -= velocity >> 3; - } -} - -void Vehicle::ApplyCableLiftBlockBrake(bool brakeClosed) -{ - // If we are already on the cable lift, ignore the brake - if (status == Status::travellingCableLift) - return; - - // Slow down if travelling faster than 4mph - if (velocity > kBlockBrakeBaseSpeed) - { - velocity -= velocity >> 3; - acceleration = 0; - } - // Once moving slow enough, keep moving forward until lined up with the catch car - else if (track_progress <= 18) - { - velocity = kBlockBrakeBaseSpeed; - acceleration = 0; - } - // Once in position, stop, and wait for the catch car - if (velocity > 0 && track_progress >= 18) - { - velocity = 0; - acceleration = 0; - if (!brakeClosed) - SetState(Status::waitingForCableLift, sub_state); - else - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE; - } -} - -/** - * - * rct2: 0x006DAC43 - */ -void Vehicle::CheckAndApplyBlockSectionStopSite() -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return; - - auto carEntry = Entry(); - if (carEntry == nullptr) - return; - - // Is chair lift type - if (carEntry->flags.has(CarEntryFlag::isChairlift)) - { - velocity = _vehicleBreakdown == 0 ? 0 : curRide->speed << 16; - acceleration = 0; - } - - auto trackType = GetTrackType(); - - TileElement* trackElement = MapGetTrackElementAtOfType(TrackLocation, trackType); - - if (trackElement == nullptr) - { - return; - } - - switch (trackType) - { - case TrackElemType::blockBrakes: - // Check if this brake is the start of a cable lift - if (curRide->lifecycleFlags & RIDE_LIFECYCLE_CABLE_LIFT) - { - CoordsXYE track; - int32_t zUnused; - int32_t direction; - if (TrackBlockGetNextFromZero(TrackLocation, *curRide, GetTrackDirection(), &track, &zUnused, &direction, false) - && track.element != nullptr && track.element->AsTrack()->HasCableLift()) - { - ApplyCableLiftBlockBrake(curRide->isBlockSectioned() && trackElement->AsTrack()->IsBrakeClosed()); - break; - } - } - [[fallthrough]]; - case TrackElemType::diagBlockBrakes: - if (curRide->isBlockSectioned() && trackElement->AsTrack()->IsBrakeClosed()) - ApplyStopBlockBrake(); - else - ApplyNonStopBlockBrake(); - - break; - case TrackElemType::endStation: - if (trackElement->AsTrack()->IsBrakeClosed()) - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_BLOCK_BRAKE; - - break; - case TrackElemType::up25ToFlat: - case TrackElemType::up60ToFlat: - case TrackElemType::cableLiftHill: - case TrackElemType::diagUp25ToFlat: - case TrackElemType::diagUp60ToFlat: - if (curRide->isBlockSectioned()) - { - if (trackType == TrackElemType::cableLiftHill || trackElement->AsTrack()->HasChain()) - { - if (trackElement->AsTrack()->IsBrakeClosed()) - { - ApplyStopBlockBrake(); - } - } - } - break; - default: - break; - } -} - -/** - * - * rct2: 0x006DADAE - */ -void Vehicle::UpdateVelocity() -{ - int32_t nextVelocity = acceleration + velocity; - if (HasFlag(VehicleFlags::StoppedBySafetyCutOut)) - { - nextVelocity = 0; - } - if (HasFlag(VehicleFlags::StoppedOnHoldingBrake)) - { - if (vertical_drop_countdown > 0) - { - nextVelocity = 0; - acceleration = 0; - vertical_drop_countdown--; - } - } - velocity = nextVelocity; - - _vehicleVelocityF64E08 = nextVelocity; - _vehicleVelocityF64E0C = (nextVelocity >> 10) * 42; -} - -static void BlockBrakesOpenPreviousSection(const Ride& ride, const CoordsXYZ& vehicleTrackLocation, TileElement* tileElement) -{ - CoordsXYZ location = vehicleTrackLocation; - TrackElement* trackElement = TrackGetPreviousBlock(location, tileElement); - if (trackElement == nullptr) - return; - - SetBrakeClosedMultiTile(*trackElement, location, false); - MapInvalidateElement(location, reinterpret_cast(trackElement)); - - auto trackType = trackElement->GetTrackType(); - if (trackType == TrackElemType::endStation) - { - Play3D(SoundId::blockBrakeClose, location); - } - else if (TrackTypeIsBlockBrakes(trackType)) - { - Play3D(SoundId::blockBrakeClose, location); - BlockBrakeSetLinkedBrakesClosed(location, *trackElement, false); - } -} - -int32_t Vehicle::GetSwingAmount() const -{ - switch (GetTrackType()) - { - case TrackElemType::leftQuarterTurn5Tiles: - case TrackElemType::bankedLeftQuarterTurn5Tiles: - case TrackElemType::leftQuarterTurn5TilesUp25: - case TrackElemType::leftQuarterTurn5TilesDown25: - case TrackElemType::leftQuarterTurn5TilesCovered: - case TrackElemType::leftHalfBankedHelixUpLarge: - case TrackElemType::leftHalfBankedHelixDownLarge: - case TrackElemType::leftQuarterBankedHelixLargeUp: - case TrackElemType::leftQuarterBankedHelixLargeDown: - case TrackElemType::leftQuarterHelixLargeUp: - case TrackElemType::leftQuarterHelixLargeDown: - case TrackElemType::leftBankedQuarterTurn5TileUp25: - case TrackElemType::leftBankedQuarterTurn5TileDown25: - // Loc6D67E1 - return 14; - - case TrackElemType::rightQuarterTurn5Tiles: - case TrackElemType::bankedRightQuarterTurn5Tiles: - case TrackElemType::rightQuarterTurn5TilesUp25: - case TrackElemType::rightQuarterTurn5TilesDown25: - case TrackElemType::rightQuarterTurn5TilesCovered: - case TrackElemType::rightHalfBankedHelixUpLarge: - case TrackElemType::rightHalfBankedHelixDownLarge: - case TrackElemType::rightQuarterBankedHelixLargeUp: - case TrackElemType::rightQuarterBankedHelixLargeDown: - case TrackElemType::rightQuarterHelixLargeUp: - case TrackElemType::rightQuarterHelixLargeDown: - case TrackElemType::rightBankedQuarterTurn5TileUp25: - case TrackElemType::rightBankedQuarterTurn5TileDown25: - // Loc6D6804 - return -14; - - case TrackElemType::sBendLeft: - case TrackElemType::sBendLeftCovered: - // Loc6D67EF - if (track_progress < 48) - { - return 14; - } - return -15; - - case TrackElemType::sBendRight: - case TrackElemType::sBendRightCovered: - // Loc6D67CC - if (track_progress < 48) - { - return -14; - } - return 15; - - case TrackElemType::leftQuarterTurn3Tiles: - case TrackElemType::leftBankedQuarterTurn3Tiles: - case TrackElemType::leftQuarterTurn3TilesUp25: - case TrackElemType::leftQuarterTurn3TilesDown25: - case TrackElemType::leftQuarterTurn3TilesCovered: - case TrackElemType::leftHalfBankedHelixUpSmall: - case TrackElemType::leftHalfBankedHelixDownSmall: - case TrackElemType::leftBankToLeftQuarterTurn3TilesUp25: - case TrackElemType::leftQuarterTurn3TilesDown25ToLeftBank: - case TrackElemType::leftCurvedLiftHill: - case TrackElemType::leftBankedQuarterTurn3TileUp25: - case TrackElemType::leftBankedQuarterTurn3TileDown25: - // Loc6D67BE - return 13; - - case TrackElemType::rightQuarterTurn3Tiles: - case TrackElemType::rightBankedQuarterTurn3Tiles: - case TrackElemType::rightQuarterTurn3TilesUp25: - case TrackElemType::rightQuarterTurn3TilesDown25: - case TrackElemType::rightQuarterTurn3TilesCovered: - case TrackElemType::rightHalfBankedHelixUpSmall: - case TrackElemType::rightHalfBankedHelixDownSmall: - case TrackElemType::rightBankToRightQuarterTurn3TilesUp25: - case TrackElemType::rightQuarterTurn3TilesDown25ToRightBank: - case TrackElemType::rightCurvedLiftHill: - case TrackElemType::rightBankedQuarterTurn3TileUp25: - case TrackElemType::rightBankedQuarterTurn3TileDown25: - // Loc6D67B0 - return -13; - - case TrackElemType::leftQuarterTurn1Tile: - case TrackElemType::leftQuarterTurn1TileUp60: - case TrackElemType::leftQuarterTurn1TileDown60: - // Loc6D67A2 - return 12; - - case TrackElemType::rightQuarterTurn1Tile: - case TrackElemType::rightQuarterTurn1TileUp60: - case TrackElemType::rightQuarterTurn1TileDown60: - // Loc6D6794 - return -12; - - case TrackElemType::leftEighthToDiag: - case TrackElemType::leftEighthToOrthogonal: - case TrackElemType::leftEighthBankToDiag: - case TrackElemType::leftEighthBankToOrthogonal: - // Loc6D67D3 - return 15; - - case TrackElemType::rightEighthToDiag: - case TrackElemType::rightEighthToOrthogonal: - case TrackElemType::rightEighthBankToDiag: - case TrackElemType::rightEighthBankToOrthogonal: - // Loc6D67F6 - return -15; - default: - return 0; - } -} - -static uint8_t GetSwingSprite(int16_t swingPosition) -{ - if (swingPosition < -10010) - return 11; - if (swingPosition > 10010) - return 12; - - if (swingPosition < -8190) - return 9; - if (swingPosition > 8190) - return 10; - - if (swingPosition < -6370) - return 7; - if (swingPosition > 6370) - return 8; - - if (swingPosition < -4550) - return 5; - if (swingPosition > 4550) - return 6; - - if (swingPosition < -2730) - return 3; - if (swingPosition > 2730) - return 4; - - if (swingPosition < -910) - return 1; - if (swingPosition > 910) - return 2; - - return 0; -} - -/** - * - * rct2: 0x006D6776 - */ -void Vehicle::UpdateSwingingCar() -{ - int32_t dword_F64E08 = abs(_vehicleVelocityF64E08); - if (HasFlag(VehicleFlags::CarIsReversed)) - { - dword_F64E08 *= -1; - } - SwingSpeed += (-SwingPosition) >> 6; - int32_t swingAmount = GetSwingAmount(); - if (swingAmount < 0) - { - SwingSpeed -= dword_F64E08 >> (-swingAmount); - } - else if (swingAmount > 0) - { - SwingSpeed += dword_F64E08 >> swingAmount; - } - - auto carEntry = Entry(); - if (carEntry == nullptr) - { - return; - } - int16_t dx = 3185; - if (carEntry->flags.has(CarEntryFlag::useSuspendedSwing)) - { - dx = 5006; - } - if (carEntry->flags.has(CarEntryFlag::useWoodenWildMouseSwing)) - { - dx = 1820; - } - int16_t cx = -dx; - - if (carEntry->flags.has(CarEntryFlag::useSlideSwing)) - { - dx = 5370; - cx = -5370; - - auto trackType = GetTrackType(); - switch (trackType) - { - case TrackElemType::bankedLeftQuarterTurn5Tiles: - case TrackElemType::leftBank: - case TrackElemType::leftBankedQuarterTurn3Tiles: - dx = 10831; - cx = -819; - break; - case TrackElemType::bankedRightQuarterTurn5Tiles: - case TrackElemType::rightBank: - case TrackElemType::rightBankedQuarterTurn3Tiles: - dx = 819; - cx = -10831; - break; - default: - break; - } - - if (TrackTypeIsStation(trackType) || TrackTypeIsBrakes(trackType) || TrackTypeIsBlockBrakes(trackType)) - { - dx = 0; - cx = 0; - } - - if (HasFlag(VehicleFlags::OnLiftHill)) - { - dx = 0; - cx = 0; - } - } - - SwingPosition += SwingSpeed; - SwingSpeed -= SwingSpeed >> 5; - - if (SwingPosition > dx) - { - SwingPosition = dx; - SwingSpeed = 0; - } - if (SwingPosition < cx) - { - SwingPosition = cx; - SwingSpeed = 0; - } - - uint8_t swingSprite = GetSwingSprite(SwingPosition); - - if (swingSprite != SwingSprite) - { - SwingSprite = swingSprite; - Invalidate(); - } -} - -/** - * - * rct2: 0x006D661F - */ -void Vehicle::UpdateSpinningCar() -{ - if (HasFlag(VehicleFlags::SpinningIsLocked)) - { - spin_speed = 0; - return; - } - - auto carEntry = Entry(); - if (carEntry == nullptr) - { - return; - } - int32_t spinningInertia = carEntry->spinning_inertia; - auto trackType = GetTrackType(); - int32_t dword_F64E08 = _vehicleVelocityF64E08; - int32_t spinSpeed{}; - // An L spin adds to the spin speed, R does the opposite - // The number indicates how much right shift of the velocity will become spin - // The bigger the number the less change in spin. - - const auto& ted = GetTrackElementDescriptor(trackType); - switch (ted.spinFunction) - { - case SpinFunction::RC: - // On a rotation control track element - spinningInertia += 6; - spinSpeed = dword_F64E08 >> spinningInertia; - // Alternate the spin direction (roughly). Perhaps in future save a value to the track - if (Id.ToUnderlying() & 1) - { - spin_speed -= spinSpeed; - } - else - { - spin_speed += spinSpeed; - } - break; - case SpinFunction::R5: - // It looks like in the original there was going to be special code for whirlpool - // this has been removed and just uses R5 - spinningInertia += 5; - spin_speed -= dword_F64E08 >> spinningInertia; - break; - case SpinFunction::L5: - spinningInertia += 5; - spin_speed += dword_F64E08 >> spinningInertia; - break; - case SpinFunction::R7: - spinningInertia += 7; - spin_speed -= dword_F64E08 >> spinningInertia; - break; - case SpinFunction::L7: - spinningInertia += 7; - spin_speed += dword_F64E08 >> spinningInertia; - break; - case SpinFunction::RL: - // Right Left Curve Track Piece - if (track_progress < 48) - { - // R8 - spinningInertia += 8; - spin_speed -= dword_F64E08 >> spinningInertia; - break; - } - [[fallthrough]]; - case SpinFunction::L9: - spinningInertia += 9; - spin_speed += dword_F64E08 >> spinningInertia; - break; - case SpinFunction::L8: - spinningInertia += 8; - spin_speed += dword_F64E08 >> spinningInertia; - break; - case SpinFunction::SP: - // On rapids spin after fully on them - if (track_progress > 22) - { - // L5 - spinningInertia += 5; - spin_speed += dword_F64E08 >> spinningInertia; - } - break; - case SpinFunction::LR: - // Left Right Curve Track Piece - if (track_progress < 48) - { - // L8 - spinningInertia += 8; - spin_speed += dword_F64E08 >> spinningInertia; - break; - } - [[fallthrough]]; - case SpinFunction::R9: - spinningInertia += 9; - spin_speed -= dword_F64E08 >> spinningInertia; - break; - case SpinFunction::R8: - spinningInertia += 8; - spin_speed -= dword_F64E08 >> spinningInertia; - break; - case SpinFunction::None: - break; - } - - spinSpeed = std::clamp(spin_speed, kVehicleMinSpinSpeed, kVehicleMaxSpinSpeed); - spin_speed = spinSpeed; - spin_sprite += spinSpeed >> 8; - // Note this actually increases the spin speed if going right! - spin_speed -= spinSpeed >> carEntry->spinning_friction; - Invalidate(); -} - -void Vehicle::UpdateAnimationAnimalFlying() -{ - if (animationState > 0) - { - animationState--; - return; - } - - if (animation_frame == 0) - { - auto trackType = GetTrackType(); - TileElement* trackElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); - if (trackElement != nullptr && trackElement->AsTrack()->HasChain()) - { - // start flapping, bird - animation_frame = 1; - animationState = 5; - Invalidate(); - } - } - else - { - // continue flapping until reaching frame 0 - animation_frame = (animation_frame + 1) % 4; - Invalidate(); - } - // number of frames to skip before updating again - constexpr std::array frameWaitTimes = { 5, 3, 5, 3 }; - animationState = frameWaitTimes[animation_frame]; -} - -/** - * Get the frame of animation for the current animationState based on animation speed and animation frames - */ -static uint8_t GetTargetFrame(const CarEntry& carEntry, uint32_t animationState) -{ - if (carEntry.AnimationSpeed == 0) - return 0; - auto targetFrame = animationState / (carEntry.AnimationSpeed << 2); - // mask of 0xFF - targetFrame &= std::numeric_limits::max(); - // multiply by number of frames. After the bitshift 8, the range will be 0 to AnimationFrames - 1 - targetFrame *= carEntry.AnimationFrames; - return targetFrame >> std::numeric_limits::digits; -} - -/** - * Compute the position that steam should be spawned - */ -static constexpr CoordsXYZ ComputeSteamOffset(int32_t height, int32_t length, VehiclePitch pitch, uint8_t yaw) -{ - uint8_t trueYaw = Entity::Yaw::YawTo64(yaw); - auto offsets = Math::Trigonometry::PitchToDirectionVectorFromGeometry[EnumValue(pitch)]; - int32_t projectedRun = (offsets.x * length - offsets.y * height) / 256; - int32_t projectedHeight = (offsets.x * height + offsets.y * length) / 256; - return { Math::Trigonometry::ComputeXYVector(projectedRun, trueYaw), projectedHeight }; -} - -/** - * Decide based on current frame and number of frames if a steam particle should be generated on this frame - */ -static bool ShouldMakeSteam(uint8_t targetFrame, uint8_t animationFrames) -{ - if (animationFrames < 1) - return false; - // steam is produced twice per wheel revolution - return targetFrame == 0 || targetFrame == animationFrames / 2; -} - -/** - * Dummy function - */ -static void AnimateNone(Vehicle& vehicle, const CarEntry& carEntry) -{ - return; -} - -/** - * Animate the vehicle based on its speed - */ -static void AnimateSimpleVehicle(Vehicle& vehicle, const CarEntry& carEntry) -{ - vehicle.animationState += _vehicleVelocityF64E08; - uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState); - if (vehicle.animation_frame != targetFrame) - { - vehicle.animation_frame = targetFrame; - vehicle.Invalidate(); - } -} - -/** - * Animate the vehicle based on its speed plus add steam particles - */ -static void AnimateSteamLocomotive(Vehicle& vehicle, const CarEntry& carEntry) -{ - vehicle.animationState += _vehicleVelocityF64E08; - uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState); - if (vehicle.animation_frame != targetFrame) - { - vehicle.animation_frame = targetFrame; - if (ShouldMakeSteam(targetFrame, carEntry.AnimationFrames)) - { - auto curRide = vehicle.GetRide(); - if (curRide != nullptr) - { - if (!RideHasStationShelter(*curRide) - || (vehicle.status != Vehicle::Status::movingToEndOfStation && vehicle.status != Vehicle::Status::arriving)) - { - CoordsXYZ steamOffset = ComputeSteamOffset( - carEntry.SteamEffect.Vertical, carEntry.SteamEffect.Longitudinal, vehicle.pitch, vehicle.Orientation); - SteamParticle::Create(CoordsXYZ(vehicle.x, vehicle.y, vehicle.z) + steamOffset); - } - } - } - vehicle.Invalidate(); - } -} - -/** - * Animate the vehicle based on its speed. Specialized animation with exactly 2 frames due to how peep animation works. - */ -static void AnimateSwanBoat(Vehicle& vehicle, const CarEntry& carEntry) -{ - // The animation of swan boats places frames at 0 and 2 instead of 0 and 1 like Water Tricycles due to the second - // pair of peeps. The animation technically uses 4 frames, but ignores frames 1 and 3. - vehicle.animationState += _vehicleVelocityF64E08; - uint8_t targetFrame = GetTargetFrame(carEntry, vehicle.animationState) * 2; - if (vehicle.animation_frame != targetFrame) - { - vehicle.animation_frame = targetFrame; - vehicle.Invalidate(); - } -} - -/** - * Monorail Cycle animation only animates when a peep is present - */ -static void AnimateMonorailCycle(Vehicle& vehicle, const CarEntry& carEntry) -{ - if (vehicle.num_peeps != 0) - { - AnimateSimpleVehicle(vehicle, carEntry); - } -} - -/** - * Observation tower animates at a constant speed continuously - */ -static void AnimateObservationTower(Vehicle& vehicle, const CarEntry& carEntry) -{ - if (vehicle.animationState <= 0xCCCC) - { - vehicle.animationState += carEntry.AnimationSpeed; - } - else - { - vehicle.animationState = 0; - vehicle.animation_frame += 1; - vehicle.animation_frame %= carEntry.AnimationFrames; - vehicle.Invalidate(); - } -} -/** - * seatRotation value of 4 translates to animationFrame value of 0. This function makes that true for any number of animation - * frames - */ -static int16_t MultiDimensionTargetAngle(int16_t seatRotation, int16_t animationFrames) -{ - return ((seatRotation - 4) % animationFrames + animationFrames) % animationFrames; -} - -/** - * Multidimension targets a specific animation frame based on track - */ -static void AnimateMultiDimension(Vehicle& vehicle, const CarEntry& carEntry) -{ - if (vehicle.seat_rotation != vehicle.target_seat_rotation) - { - if (vehicle.animationState <= 0xCCCC) - { - vehicle.animationState += carEntry.AnimationSpeed; - } - else - { - vehicle.animationState = 0; - - if (vehicle.seat_rotation >= vehicle.target_seat_rotation) - vehicle.seat_rotation--; - else - vehicle.seat_rotation++; - - int16_t targetSeatRotation = MultiDimensionTargetAngle(vehicle.seat_rotation, carEntry.AnimationFrames); - if (targetSeatRotation != vehicle.animation_frame) - { - vehicle.animation_frame = targetSeatRotation; - vehicle.Invalidate(); - } - } - } -} - -/** - * Animal Flying animates only on chainlift and in an unusual way. Made by Spacek531 - */ -static void AnimateAnimalFlying(Vehicle& vehicle, const CarEntry& carEntry) -{ - vehicle.UpdateAnimationAnimalFlying(); - // makes animation play faster with vehicle speed - uint8_t targetFrame = abs(_vehicleVelocityF64E08) >> carEntry.AnimationSpeed; - vehicle.animationState = std::max(vehicle.animationState - targetFrame, 0u); -} - -using AnimateFunction = void (*)(Vehicle& vehicle, const CarEntry& carEntry); - -constexpr static const AnimateFunction AnimationFunctions[]{ - AnimateNone, AnimateSimpleVehicle, AnimateSteamLocomotive, AnimateSwanBoat, - AnimateMonorailCycle, AnimateMultiDimension, AnimateObservationTower, AnimateAnimalFlying, -}; -static_assert(std::size(AnimationFunctions) == EnumValue(CarEntryAnimation::Count)); - -/** - * - * rct2: 0x006D63D4 - */ -void Vehicle::UpdateAdditionalAnimation() -{ - auto carEntry = Entry(); - if (carEntry == nullptr) - { - return; - } - if (carEntry->AnimationFrames == 0 || carEntry->animation >= CarEntryAnimation::Count) - return; - AnimationFunctions[EnumValue(carEntry->animation)](*this, *carEntry); -} - -/** - * - * rct2: 0x006DEDB1 - */ -static void play_scenery_door_open_sound(const CoordsXYZ& loc, WallElement* tileElement) -{ - auto* wallEntry = tileElement->GetEntry(); - if (wallEntry == nullptr) - return; - - auto doorSoundType = wallEntry->getDoorSoundType(); - if (doorSoundType == DoorSoundType::none) - return; - - auto soundId = kDoorOpenSoundIds[EnumValue(doorSoundType)]; - Play3D(soundId, loc); -} - -/** - * - * rct2: 0x006DED7A - */ -static void play_scenery_door_close_sound(const CoordsXYZ& loc, WallElement* tileElement) -{ - auto* wallEntry = tileElement->GetEntry(); - if (wallEntry == nullptr) - return; - - auto doorSoundType = wallEntry->getDoorSoundType(); - if (doorSoundType == DoorSoundType::none) - return; - - auto soundId = kDoorCloseSoundIds[EnumValue(doorSoundType)]; - Play3D(soundId, loc); -} - -template -static void AnimateSceneryDoor(const CoordsXYZD& doorLocation, const CoordsXYZ& trackLocation, bool isLastVehicle) -{ - auto door = MapGetWallElementAt(doorLocation); - if (door == nullptr) - { - return; - } - - if (!isLastVehicle && (door->GetAnimationFrame() == 0)) - { - door->SetAnimationIsBackwards(isBackwards); - door->SetAnimationFrame(1); - door->SetIsAnimating(true); - play_scenery_door_open_sound(trackLocation, door); - - MapAnimations::MarkTileForUpdate(TileCoordsXY(doorLocation)); - } - - if (isLastVehicle) - { - door->SetAnimationIsBackwards(isBackwards); - door->SetAnimationFrame(6); - door->SetIsAnimating(true); - play_scenery_door_close_sound(trackLocation, door); - - MapAnimations::MarkTileForUpdate(TileCoordsXY(doorLocation)); - } -} - -/** - * - * rct2: 0x006DEE93 - */ -void Vehicle::UpdateSceneryDoor() const -{ - auto trackType = GetTrackType(); - const auto& ted = GetTrackElementDescriptor(trackType); - const auto& trackBlock = ted.sequences[ted.numSequences - 1].clearance; - const TrackCoordinates* trackCoordinates = &ted.coordinates; - auto wallCoords = CoordsXYZ{ x, y, TrackLocation.z - trackBlock.z + trackCoordinates->zEnd }.ToTileStart(); - int32_t direction = (GetTrackDirection() + trackCoordinates->rotationEnd) & 3; - - AnimateSceneryDoor({ wallCoords, static_cast(direction) }, TrackLocation, next_vehicle_on_train.IsNull()); -} - -template -static void AnimateLandscapeDoor( - const CoordsXYZ& doorLocation, TrackElement& trackElement, const bool isLastVehicle, const DoorSoundType doorSound, - const CoordsXYZ& soundLocation) -{ - const auto doorState = isBackwards ? trackElement.GetDoorAState() : trackElement.GetDoorBState(); - if (!isLastVehicle && doorState == kLandEdgeDoorFrameClosed) - { - if (isBackwards) - trackElement.SetDoorAState(kLandEdgeDoorFrameOpening); - else - trackElement.SetDoorBState(kLandEdgeDoorFrameOpening); - - MapAnimations::CreateTemporary(doorLocation, MapAnimations::TemporaryType::landEdgeDoor); - Play3D(kDoorOpenSoundIds[EnumValue(doorSound)], soundLocation); - } - - if (isLastVehicle) - { - if (isBackwards) - trackElement.SetDoorAState(kLandEdgeDoorFrameClosing); - else - trackElement.SetDoorBState(kLandEdgeDoorFrameClosing); - - MapAnimations::CreateTemporary(doorLocation, MapAnimations::TemporaryType::landEdgeDoor); - Play3D(kDoorCloseSoundIds[EnumValue(doorSound)], soundLocation); - } -} - -static const SurfaceElement* GetSurfaceElementAfterElement(const TileElement* tileElement) -{ - while (tileElement->GetType() != TileElementType::Surface) - { - if (tileElement->IsLastForTile()) - return nullptr; - tileElement++; - } - return tileElement->AsSurface(); -} - -void Vehicle::UpdateLandscapeDoors(const int32_t previousTrackHeight) const -{ - const auto* currentRide = GetRide(); - if (currentRide == nullptr || !currentRide->getRideTypeDescriptor().HasFlag(RtdFlag::hasLandscapeDoors)) - { - return; - } - - const CoordsXYZ previousTrackLocation = CoordsXYZ(x, y, previousTrackHeight).ToTileStart(); - auto* const previousTrackElement = MapGetTrackElementAtBeforeSurfaceFromRide(previousTrackLocation, ride); - auto* const currentTrackElement = MapGetTrackElementAtBeforeSurfaceFromRide(TrackLocation, ride); - if (previousTrackElement != nullptr && currentTrackElement == nullptr) - { - const auto* const surfaceElement = GetSurfaceElementAfterElement(previousTrackElement); - if (surfaceElement != nullptr && surfaceElement->GetBaseZ() > previousTrackLocation.z) - { - const auto* const edgeObject = surfaceElement->GetEdgeObject(); - if (edgeObject != nullptr && edgeObject->HasDoors) - { - AnimateLandscapeDoor( - previousTrackLocation, *previousTrackElement->AsTrack(), next_vehicle_on_train.IsNull(), - edgeObject->doorSound, TrackLocation); - } - } - } - else if (previousTrackElement == nullptr && currentTrackElement != nullptr) - { - const auto* const surfaceElement = GetSurfaceElementAfterElement(currentTrackElement); - if (surfaceElement != nullptr && surfaceElement->GetBaseZ() > TrackLocation.z) - { - const auto* const edgeObject = surfaceElement->GetEdgeObject(); - if (edgeObject != nullptr && edgeObject->HasDoors) - { - AnimateLandscapeDoor( - TrackLocation, *currentTrackElement->AsTrack(), next_vehicle_on_train.IsNull(), edgeObject->doorSound, - previousTrackLocation); - } - } - } -} - -/** - * - * rct2: 0x006DB38B - */ -static PitchAndRoll PitchAndRollStart(bool useInvertedSprites, TileElement* tileElement) -{ - auto trackType = tileElement->AsTrack()->GetTrackType(); - const auto& ted = GetTrackElementDescriptor(trackType); - return PitchAndRoll{ ted.definition.pitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) }; -} - -void Vehicle::UpdateGoKartAttemptSwitchLanes() -{ - uint16_t probability = 0x8000; - if (HasFlag(VehicleFlags::CurrentlyColliding)) - { - ClearFlag(VehicleFlags::CurrentlyColliding); - } - else - { - probability = 0x0A3D; - } - if ((ScenarioRand() & 0xFFFF) <= probability) - { - // This changes "riding left" to "moving to right lane" and "riding right" to "moving to left lane". - TrackSubposition = VehicleTrackSubposition{ static_cast(static_cast(TrackSubposition) + 2u) }; - } -} - -/** - * - * rct2: 0x006DEDE8 - */ -void Vehicle::UpdateSceneryDoorBackwards() const -{ - auto trackType = GetTrackType(); - const auto& ted = GetTrackElementDescriptor(trackType); - const TrackCoordinates* trackCoordinates = &ted.coordinates; - auto wallCoords = CoordsXYZ{ TrackLocation, TrackLocation.z - ted.sequences[0].clearance.z + trackCoordinates->zBegin }; - int32_t direction = (GetTrackDirection() + trackCoordinates->rotationBegin) & 3; - direction = DirectionReverse(direction); - - AnimateSceneryDoor({ wallCoords, static_cast(direction) }, TrackLocation, next_vehicle_on_train.IsNull()); -} - -static void vehicle_update_play_water_splash_sound() -{ - if (_vehicleVelocityF64E08 <= kBlockBrakeBaseSpeed) - { - return; - } - - Play3D(SoundId::waterSplash, { _vehicleCurPosition.x, _vehicleCurPosition.y, _vehicleCurPosition.z }); -} - -/** - * - * rct2: 0x006DB59E - */ -void Vehicle::UpdateHandleWaterSplash() const -{ - const auto* rideEntry = GetRideEntry(); - auto trackType = GetTrackType(); - - if (!(rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND)) - { - if (rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE) - { - if (IsHead()) - { - if (IsOnCoveredTrack()) - { - Vehicle* nextVehicle = getGameState().entities.GetEntity(next_vehicle_on_ride); - if (nextVehicle == nullptr) - return; - - Vehicle* nextNextVehicle = getGameState().entities.GetEntity(nextVehicle->next_vehicle_on_ride); - if (nextNextVehicle == nullptr) - return; - if (!nextNextVehicle->IsOnCoveredTrack()) - { - if (track_progress == 4) - { - vehicle_update_play_water_splash_sound(); - } - } - } - } - } - } - else - { - if (trackType == TrackElemType::down25ToFlat) - { - if (track_progress == 12) - { - vehicle_update_play_water_splash_sound(); - } - } - } - if (IsHead()) - { - if (trackType == TrackElemType::watersplash) - { - if (track_progress == 48) - { - vehicle_update_play_water_splash_sound(); - } - } - } -} - -/** - * - * rct2: 0x006DB807 - */ -void Vehicle::UpdateReverserCarBogies() -{ - const auto moveInfo = GetMoveInfo(); - MoveTo({ TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, z }); -} - bool Vehicle::IsCableLift() const { return ride_subtype == kObjectEntryIndexNull; } -/** - * Collision Detection - * rct2: 0x006DD078 - * @param vehicle (esi) - * @param x (ax) - * @param y (cx) - * @param z (dx) - * @param otherVehicleIndex (bp) - */ -bool Vehicle::UpdateMotionCollisionDetection(const CoordsXYZ& loc, EntityId* otherVehicleIndex) -{ - if (HasFlag(VehicleFlags::CollisionDisabled)) - return false; - - auto carEntry = Entry(); - if (carEntry == nullptr) - { - return false; - } - - if (!carEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) - { - CollisionDetectionTimer = 0; - - // If hacking boat hire rides you can end up here - if (otherVehicleIndex == nullptr) - return false; - - Vehicle* collideVehicle = getGameState().entities.GetEntity(*otherVehicleIndex); - if (collideVehicle == nullptr) - return false; - - if (this == collideVehicle) - return false; - - int32_t x_diff = abs(loc.x - collideVehicle->x); - if (x_diff > 0x7FFF) - return false; - - int32_t y_diff = abs(loc.y - collideVehicle->y); - if (y_diff > 0x7FFF) - return false; - - int32_t z_diff = abs(loc.z - collideVehicle->z); - if (x_diff + y_diff + z_diff > 0xFFFF) - return false; - - uint16_t ecx = std::min(var_44 + collideVehicle->var_44, 560); - ecx = ((ecx >> 1) * 30) >> 8; - - if (x_diff + y_diff + z_diff >= ecx) - return false; - - uint8_t direction = (Orientation - collideVehicle->Orientation + 7) & 0x1F; - return direction < 0xF; - } - - CoordsXY location = loc; - - bool mayCollide = false; - Vehicle* collideVehicle = nullptr; - for (auto xy_offset : kSurroundingTiles) - { - location += xy_offset; - - for (auto vehicle2 : EntityTileList(location)) - { - if (vehicle2 == this) - continue; - - int32_t z_diff = abs(vehicle2->z - loc.z); - - if (z_diff > 16) - continue; - - if (vehicle2->IsCableLift()) - continue; - - auto collideCarEntry = vehicle2->Entry(); - if (collideCarEntry == nullptr) - continue; - - if (!collideCarEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) - continue; - - uint32_t x_diff = abs(vehicle2->x - loc.x); - if (x_diff > 0x7FFF) - continue; - - uint32_t y_diff = abs(vehicle2->y - loc.y); - if (y_diff > 0x7FFF) - continue; - - VehicleTrackSubposition cl = std::min(TrackSubposition, vehicle2->TrackSubposition); - VehicleTrackSubposition ch = std::max(TrackSubposition, vehicle2->TrackSubposition); - if (cl != ch) - { - if (cl == VehicleTrackSubposition::GoKartsLeftLane && ch == VehicleTrackSubposition::GoKartsRightLane) - continue; - } - - uint32_t ecx = var_44 + vehicle2->var_44; - ecx = ((ecx >> 1) * 30) >> 8; - - if (x_diff + y_diff >= ecx) - continue; - - if (!collideCarEntry->flags.has(CarEntryFlag::isGoKart)) - { - collideVehicle = vehicle2; - mayCollide = true; - break; - } - - uint8_t direction = (Orientation - vehicle2->Orientation - 6) & 0x1F; - - if (direction < 0x14) - continue; - - const CoordsXY directionVector = Math::Trigonometry::YawToDirectionVector[Entity::Yaw::YawTo64(Orientation)]; - - const CoordsXY directionVectorToVehicle2 = { vehicle2->x - loc.x, vehicle2->y - loc.y }; - const int32_t directionVectorToVehicle2Length = (directionVectorToVehicle2.x * directionVectorToVehicle2.x) - + (directionVectorToVehicle2.y * directionVectorToVehicle2.y); - - const int32_t dotProduct = (directionVector.x * directionVectorToVehicle2.x) - + (directionVector.y * directionVectorToVehicle2.y); - - static constexpr int32_t threshold = []() consteval { - const constexpr float originalThreshold = 0.35f; - const constexpr float directionVectorLength = 256.0f; - const constexpr float thresholdLength = originalThreshold * directionVectorLength; - return static_cast(thresholdLength * thresholdLength); - }(); - static_assert(threshold == 8028); - - if (dotProduct > 0 && dotProduct * dotProduct > threshold * directionVectorToVehicle2Length) - { - collideVehicle = vehicle2; - mayCollide = true; - break; - } - } - if (mayCollide) - { - break; - } - } - - if (!mayCollide || collideVehicle == nullptr) - { - CollisionDetectionTimer = 0; - return false; - } - - if (collideVehicle->status == Status::travellingBoat && sub_state == BoatHireSubState::EnteringReturnPosition) - { - return false; - } - - CollisionDetectionTimer++; - if (CollisionDetectionTimer < 200) - { - SetFlag(VehicleFlags::CurrentlyColliding); - if (otherVehicleIndex != nullptr) - *otherVehicleIndex = collideVehicle->Id; - return true; - } - - if (status == Status::movingToEndOfStation) - { - if (Orientation == 0) - { - if (x <= collideVehicle->x) - { - return false; - } - } - else if (Orientation == 8) - { - if (y >= collideVehicle->y) - { - return false; - } - } - else if (Orientation == 16) - { - if (x >= collideVehicle->x) - { - return false; - } - } - else if (Orientation == 24) - { - if (y <= collideVehicle->y) - { - return false; - } - } - } - - if ((collideVehicle->status == Status::travellingBoat) && (status != Status::arriving) && (status != Status::travelling)) - { - return false; - } - - SetFlag(VehicleFlags::CurrentlyColliding); - if (otherVehicleIndex != nullptr) - *otherVehicleIndex = collideVehicle->Id; - return true; -} - -/** - * - * rct2: 0x006DB7D6 - */ -void Vehicle::ReverseReverserCar() -{ - Vehicle* previousVehicle = getGameState().entities.GetEntity(prev_vehicle_on_ride); - Vehicle* nextVehicle = getGameState().entities.GetEntity(next_vehicle_on_ride); - if (previousVehicle == nullptr || nextVehicle == nullptr) - { - return; - } - - track_progress = 168; - vehicle_type ^= 1; - - previousVehicle->track_progress = 86; - nextVehicle->track_progress = 158; - - nextVehicle->UpdateReverserCarBogies(); - previousVehicle->UpdateReverserCarBogies(); -} - -/** - * - * rct2: 0x006DBF3E - */ -void Vehicle::Sub6DBF3E() -{ - const auto* carEntry = Entry(); - - acceleration /= _vehicleUnkF64E10; - if (TrackSubposition == VehicleTrackSubposition::ChairliftGoingBack) - { - return; - } - - auto trackType = GetTrackType(); - const auto& ted = GetTrackElementDescriptor(trackType); - if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin)) - { - return; - } - - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_3; - - TileElement* tileElement = nullptr; - if (MapIsLocationValid(TrackLocation)) - { - tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); - } - - if (tileElement == nullptr) - { - return; - } - - if (_vehicleStationIndex.IsNull()) - { - _vehicleStationIndex = tileElement->AsTrack()->GetStationIndex(); - } - - if (trackType == TrackElemType::towerBase && this == gCurrentVehicle) - { - if (track_progress > 3 && !HasFlag(VehicleFlags::PoweredCarInReverse)) - { - CoordsXYE output; - int32_t outputZ, outputDirection; - - CoordsXYE input = { TrackLocation, tileElement }; - if (!TrackBlockGetNext(&input, &output, &outputZ, &outputDirection)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_12; - } - } - - if (track_progress <= 3) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; - } - } - - if (trackType != TrackElemType::endStation || this != gCurrentVehicle) - { - return; - } - - uint16_t ax = track_progress; - if (_vehicleVelocityF64E08 < 0) - { - if (ax <= 22) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; - } - } - else - { - uint16_t cx = 17; - if (carEntry->flags.has(CarEntryFlag::isChairlift)) - { - cx = 6; - } - if (carEntry->flags.has(CarEntryFlag::isGoKart)) - { - // Determine the stop positions for the karts. If in left lane it's further along the track than the right lane. - // Since it's not possible to overtake when the race has ended, this does not check for overtake states (7 and - // 8). - cx = TrackSubposition == VehicleTrackSubposition::GoKartsRightLane ? 18 : 20; - } - - if (ax > cx) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; - } - } -} - -/** - * Determine whether to use block brake speed or brake speed. If block brake is closed or no block brake present, use the - * brake's speed; if block brake is open, use maximum of brake speed or block brake speed. - */ -uint8_t Vehicle::ChooseBrakeSpeed() const -{ - if (!TrackTypeIsBrakes(GetTrackType())) - return brake_speed; - auto trackElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, GetTrackType(), 0); - if (trackElement != nullptr) - { - if (trackElement->AsTrack()->IsBrakeClosed()) - return brake_speed; - else - return std::max(brake_speed, BlockBrakeSpeed); - } - return brake_speed; -} - -/** - * Populate the vehicle's brake_speed and BlockBrakeSpeed values. - */ -void Vehicle::PopulateBrakeSpeed(const CoordsXYZ& vehicleTrackLocation, TrackElement& brake) -{ - auto trackSpeed = brake.GetBrakeBoosterSpeed(); - brake_speed = trackSpeed; - if (!TrackTypeIsBrakes(brake.GetTrackType())) - { - BlockBrakeSpeed = trackSpeed; - return; - } - // As soon as feasible, encode block brake speed into track element so the lookforward can be skipped here. - - CoordsXYE output = CoordsXYE(vehicleTrackLocation.x, vehicleTrackLocation.y, reinterpret_cast(&brake)); - int32_t outputZ = vehicleTrackLocation.z; - uint16_t timeoutCount = 256; - do - { - if (TrackTypeIsBlockBrakes(output.element->AsTrack()->GetTrackType())) - { - BlockBrakeSpeed = output.element->AsTrack()->GetBrakeBoosterSpeed(); - return; - } - if (!TrackTypeIsBrakes(output.element->AsTrack()->GetTrackType())) - { - break; - } - timeoutCount--; - } while (TrackBlockGetNext(&output, &output, &outputZ, nullptr) && timeoutCount); - - // If block brake is not found, use the track's speed - BlockBrakeSpeed = trackSpeed; -} - -/** - * - * rct2: 0x006DB08C - */ -bool Vehicle::UpdateTrackMotionForwardsGetNewTrack( - TrackElemType trackType, const Ride& curRide, const RideObjectEntry& rideEntry) -{ - CoordsXYZD location = {}; - - auto pitchAndRollEnd = TrackPitchAndRollEnd(trackType); - TileElement* tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); - - if (tileElement == nullptr) - { - return false; - } - - if (trackType == TrackElemType::cableLiftHill && this == gCurrentVehicle) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_11; - } - - if (tileElement->AsTrack()->IsBlockStart()) - { - if (next_vehicle_on_train.IsNull()) - { - SetBrakeClosedMultiTile(*tileElement->AsTrack(), TrackLocation, true); - if (TrackTypeIsBlockBrakes(trackType) || trackType == TrackElemType::endStation) - { - if (!rideEntry.Cars[0].flags.has(CarEntryFlag::isPowered)) - { - Play3D(SoundId::blockBrakeRelease, TrackLocation); - } - } - MapInvalidateElement(TrackLocation, tileElement); - BlockBrakesOpenPreviousSection(curRide, TrackLocation, tileElement); - if (TrackTypeIsBlockBrakes(trackType)) - { - BlockBrakeSetLinkedBrakesClosed(TrackLocation, *tileElement->AsTrack(), true); - } - } - } - - // Change from original: this used to check if the vehicle allowed doors. - UpdateSceneryDoor(); - - bool isGoingBack = false; - switch (TrackSubposition) - { - case VehicleTrackSubposition::ChairliftGoingBack: - case VehicleTrackSubposition::ChairliftEndBullwheel: - TrackSubposition = VehicleTrackSubposition::ChairliftGoingBack; - isGoingBack = true; - break; - case VehicleTrackSubposition::ChairliftStartBullwheel: - TrackSubposition = VehicleTrackSubposition::ChairliftGoingOut; - break; - case VehicleTrackSubposition::GoKartsMovingToRightLane: - TrackSubposition = VehicleTrackSubposition::GoKartsRightLane; - break; - case VehicleTrackSubposition::GoKartsMovingToLeftLane: - TrackSubposition = VehicleTrackSubposition::GoKartsLeftLane; - break; - default: - break; - } - - if (isGoingBack) - { - TrackBeginEnd trackBeginEnd; - if (!TrackBlockGetPrevious({ TrackLocation, tileElement }, &trackBeginEnd)) - { - return false; - } - location.x = trackBeginEnd.begin_x; - location.y = trackBeginEnd.begin_y; - location.z = trackBeginEnd.begin_z; - location.direction = trackBeginEnd.begin_direction; - tileElement = trackBeginEnd.begin_element; - } - else - { - { - int32_t curZ, direction; - CoordsXYE xyElement = { TrackLocation, tileElement }; - if (!TrackBlockGetNext(&xyElement, &xyElement, &curZ, &direction)) - { - return false; - } - tileElement = xyElement.element; - location = { xyElement, curZ, static_cast(direction) }; - } - if (tileElement->AsTrack()->GetTrackType() == TrackElemType::leftReverser - || tileElement->AsTrack()->GetTrackType() == TrackElemType::rightReverser) - { - if (IsHead() && velocity <= 3.0_mph) - { - velocity = 0; - } - } - - if (PitchAndRollStart(HasFlag(VehicleFlags::CarIsInverted), tileElement) != pitchAndRollEnd) - { - return false; - } - - // Update VehicleFlags::CarIsInverted flag - const auto previousCarIsInverted = HasFlag(VehicleFlags::CarIsInverted); - ClearFlag(VehicleFlags::CarIsInverted); - { - auto rideType = ::GetRide(tileElement->AsTrack()->GetRideIndex())->type; - if (GetRideTypeDescriptor(rideType).HasFlag(RtdFlag::hasInvertedVariant)) - { - if (tileElement->AsTrack()->IsInverted()) - { - SetFlag(VehicleFlags::CarIsInverted); - } - } - if (previousCarIsInverted != HasFlag(VehicleFlags::CarIsInverted)) - { - EntityTweener::Get().RemoveEntity(this); - } - } - } - - const int32_t previousTrackHeight = TrackLocation.z; - TrackLocation = location; - - // TODO check if getting the vehicle entry again is necessary - const auto* carEntry = Entry(); - if (carEntry == nullptr) - { - return false; - } - if (carEntry->flags.has(CarEntryFlag::isGoKart) && TrackSubposition < VehicleTrackSubposition::GoKartsMovingToRightLane) - { - trackType = tileElement->AsTrack()->GetTrackType(); - if (trackType == TrackElemType::flat || trackType == TrackElemType::leftQuarterTurn3Tiles - || trackType == TrackElemType::rightQuarterTurn3Tiles || trackType == TrackElemType::leftQuarterTurn5Tiles - || trackType == TrackElemType::rightQuarterTurn5Tiles || trackType == TrackElemType::leftEighthToDiag - || trackType == TrackElemType::rightEighthToDiag || trackType == TrackElemType::leftEighthToOrthogonal - || trackType == TrackElemType::rightEighthToOrthogonal || trackType == TrackElemType::diagFlat - || trackType == TrackElemType::sBendLeft || trackType == TrackElemType::sBendRight - || ((curRide.lifecycleFlags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING) && tileElement->AsTrack()->IsStation())) - { - UpdateGoKartAttemptSwitchLanes(); - } - } - - if (TrackSubposition >= VehicleTrackSubposition::ChairliftGoingOut - && TrackSubposition <= VehicleTrackSubposition::ChairliftStartBullwheel) - { - TileCoordsXYZ curLocation{ TrackLocation }; - - if (curLocation == curRide.chairliftBullwheelLocation[1]) - { - TrackSubposition = VehicleTrackSubposition::ChairliftEndBullwheel; - } - else if (curLocation == curRide.chairliftBullwheelLocation[0]) - { - TrackSubposition = VehicleTrackSubposition::ChairliftStartBullwheel; - } - } - - // Loc6DB500 - // Update VehicleFlags::OnLiftHill - ClearFlag(VehicleFlags::OnLiftHill); - if (tileElement->AsTrack()->HasChain()) - { - SetFlag(VehicleFlags::OnLiftHill); - } - - trackType = tileElement->AsTrack()->GetTrackType(); - if (trackType != TrackElemType::brakes) - { - target_seat_rotation = tileElement->AsTrack()->GetSeatRotation(); - } - SetTrackDirection(location.direction); - SetTrackType(trackType); - PopulateBrakeSpeed(TrackLocation, *tileElement->AsTrack()); - if (HasFlag(VehicleFlags::StoppedOnHoldingBrake) && vertical_drop_countdown <= 0) - { - ClearFlag(VehicleFlags::StoppedOnHoldingBrake); - } - if (trackType == TrackElemType::onRidePhoto) - { - tileElement->AsTrack()->SetPhotoTimeout(); - MapAnimations::CreateTemporary(TrackLocation, MapAnimations::TemporaryType::onRidePhoto); - } - if (trackType == TrackElemType::rotationControlToggle) - { - Flags ^= VehicleFlags::SpinningIsLocked; - } - // Change from original: this used to check if the vehicle allowed doors. - UpdateSceneryDoorBackwards(); - UpdateLandscapeDoors(previousTrackHeight); - - return true; -} - -/** - * - * rct2: 0x006DAEB9 - */ -bool Vehicle::UpdateTrackMotionForwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) -{ - EntityId otherVehicleIndex = EntityId::GetNull(); - while (true) - { - auto trackType = GetTrackType(); - if (trackType == TrackElemType::heartLineTransferUp || trackType == TrackElemType::heartLineTransferDown) - { - if (track_progress == 80) - { - vehicle_type ^= 1; - carEntry = Entry(); - } - if (_vehicleVelocityF64E08 >= 0x40000) - { - acceleration = -_vehicleVelocityF64E08 * 8; - } - else if (_vehicleVelocityF64E08 < 0x20000) - { - acceleration = 0x50000; - } - } - else if (TrackTypeIsBrakes(trackType)) - { - bool hasBrakesFailure = curRide.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN - && curRide.breakdownReasonPending == BREAKDOWN_BRAKES_FAILURE; - if (!hasBrakesFailure || curRide.mechanicStatus == MechanicStatus::hasFixedStationBrakes) - { - auto brakeSpeed = ChooseBrakeSpeed() << kTrackSpeedShiftAmount; - - if ((brakeSpeed) < _vehicleVelocityF64E08) - { - acceleration = -_vehicleVelocityF64E08 * 16; - } - else if (!(getGameState().currentTicks & 0x0F)) - { - if (_vehicleF64E2C == 0) - { - _vehicleF64E2C++; - Play3D(SoundId::brakeRelease, { x, y, z }); - } - } - } - } - else if (TrackTypeIsBooster(trackType)) - { - auto boosterSpeed = GetUnifiedBoosterSpeed(curRide.type, brake_speed) << kTrackSpeedShiftAmount; - if (boosterSpeed > _vehicleVelocityF64E08) - { - acceleration = GetRideTypeDescriptor(curRide.type).LegacyBoosterSettings.BoosterAcceleration - << kBoosterAccelerationShiftAmount; - } - } - else if (rideEntry.flags & RIDE_ENTRY_FLAG_RIDER_CONTROLS_SPEED && num_peeps > 0) - { - acceleration += CalculateRiderBraking(); - } - - if ((trackType == TrackElemType::flat && curRide.getRideTypeDescriptor().HasFlag(RtdFlag::hasLsmBehaviourOnFlat)) - || (trackType == TrackElemType::poweredLift)) - { - acceleration = GetRideTypeDescriptor(curRide.type).LegacyBoosterSettings.PoweredLiftAcceleration - << kBoosterAccelerationShiftAmount; - } - if (trackType == TrackElemType::brakeForDrop) - { - if (IsHead()) - { - if (!HasFlag(VehicleFlags::StoppedOnHoldingBrake)) - { - if (track_progress >= 8) - { - acceleration = -_vehicleVelocityF64E08 * 16; - if (track_progress >= 24) - { - SetFlag(VehicleFlags::StoppedOnHoldingBrake); - vertical_drop_countdown = 90; - } - } - } - } - } - if (trackType == TrackElemType::logFlumeReverser) - { - if (track_progress != 16 || velocity < 4.0_mph) - { - if (track_progress == 32) - { - vehicle_type = carEntry->ReversedCarIndex; - carEntry = Entry(); - } - } - else - { - track_progress += 17; - } - } - - uint16_t newTrackProgress = track_progress + 1; - - // Track Total Progress is in the two bytes before the move info list - uint16_t trackTotalProgress = GetTrackProgress(); - if (newTrackProgress >= trackTotalProgress) - { - UpdateCrossings(); - - if (!UpdateTrackMotionForwardsGetNewTrack(trackType, curRide, rideEntry)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; - remaining_distance = -1; - return false; - } - newTrackProgress = 0; - } - - track_progress = newTrackProgress; - UpdateHandleWaterSplash(); - - // Loc6DB706 - const auto moveInfo = GetMoveInfo(); - trackType = GetTrackType(); - { - auto nextVehiclePosition = TrackLocation - + CoordsXYZ{ moveInfo->x, moveInfo->y, - moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; - - bool useReverserDistance = TrackSubposition == VehicleTrackSubposition::ReverserRCFrontBogie - && (trackType == TrackElemType::leftReverser || trackType == TrackElemType::rightReverser) - && track_progress >= 30 && track_progress <= 66; - - // Loc6DB8A5 - remaining_distance -= Geometry::getTranslationDistance( - nextVehiclePosition - _vehicleCurPosition, useReverserDistance); - - if (TrackSubposition == VehicleTrackSubposition::ReverserRCRearBogie - && (trackType == TrackElemType::leftReverser || trackType == TrackElemType::rightReverser) - && track_progress == 96) - { - ReverseReverserCar(); - - const VehicleInfo* moveInfo2 = GetMoveInfo(); - nextVehiclePosition.x = x + moveInfo2->x; - nextVehiclePosition.y = y + moveInfo2->y; - } - - _vehicleCurPosition = nextVehiclePosition; - Orientation = moveInfo->yaw; - roll = moveInfo->roll; - pitch = moveInfo->pitch; - - if (carEntry->flags.has(CarEntryFlag::useWoodenWildMouseSwing) && moveInfo->pitch != VehiclePitch::flat) - { - SwingSprite = 0; - SwingPosition = 0; - SwingSpeed = 0; - } - - // this == frontVehicle - if (this == _vehicleFrontVehicle) - { - if (_vehicleVelocityF64E08 >= 0) - { - otherVehicleIndex = prev_vehicle_on_ride; - if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex)) - { - _vehicleVelocityF64E0C -= remaining_distance + 1; - remaining_distance = -1; - - // Might need to be bp rather than this, but hopefully not - auto otherVeh = getGameState().entities.GetEntity(otherVehicleIndex); - if (otherVeh == nullptr) - { - // This can never happen as prev_vehicle_on_ride will always be set to a vehicle - LOG_ERROR("Failed to get next vehicle during update!"); - return true; - } - auto head = otherVeh->TrainHead(); - - auto velocityDelta = abs(velocity - head->velocity); - if (!(rideEntry.flags & RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES)) - { - if (velocityDelta > 14.0_mph) - { - if (!carEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION; - } - } - } - - if (carEntry->flags.has(CarEntryFlag::isGoKart)) - { - velocity -= velocity >> 2; - } - else - { - int32_t newHeadVelocity = velocity >> 1; - velocity = head->velocity >> 1; - head->velocity = newHeadVelocity; - } - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_1; - return false; - } - } - } - } - - // Loc6DB928 - if (remaining_distance < 0x368A) - { - return true; - } - - acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - } -} - -static PitchAndRoll PitchAndRollEnd( - const Ride& curRide, bool useInvertedSprites, TrackElemType trackType, TileElement* tileElement) -{ - bool isInverted = useInvertedSprites ^ tileElement->AsTrack()->IsInverted(); - const auto& ted = GetTrackElementDescriptor(trackType); - return { ted.definition.pitchEnd, TrackGetActualBank2(curRide.type, isInverted, ted.definition.rollEnd) }; -} - -/** - * - * rct2: 0x006DBAA6 - */ -bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(TrackElemType trackType, const Ride& curRide, uint16_t* progress) -{ - auto pitchAndRollStart = TrackPitchAndRollStart(trackType); - TileElement* tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, trackType, 0); - - if (tileElement == nullptr) - return false; - - bool nextTileBackwards = true; - int32_t direction = 0; - // Loc6DBB08:; - auto trackPos = CoordsXYZ{ TrackLocation.x, TrackLocation.y, 0 }; - - switch (TrackSubposition) - { - case VehicleTrackSubposition::ChairliftEndBullwheel: - TrackSubposition = VehicleTrackSubposition::ChairliftGoingOut; - break; - case VehicleTrackSubposition::GoKartsMovingToRightLane: - TrackSubposition = VehicleTrackSubposition::GoKartsLeftLane; - break; - case VehicleTrackSubposition::GoKartsMovingToLeftLane: - TrackSubposition = VehicleTrackSubposition::GoKartsRightLane; - break; - case VehicleTrackSubposition::ChairliftGoingBack: - case VehicleTrackSubposition::ChairliftStartBullwheel: - TrackSubposition = VehicleTrackSubposition::ChairliftGoingBack; - nextTileBackwards = false; - break; - default: - break; - } - - if (nextTileBackwards) - { - // Loc6DBB7E:; - TrackBeginEnd trackBeginEnd; - if (!TrackBlockGetPrevious({ trackPos, tileElement }, &trackBeginEnd)) - { - return false; - } - tileElement = trackBeginEnd.begin_element; - - trackType = tileElement->AsTrack()->GetTrackType(); - if (trackType == TrackElemType::leftReverser || trackType == TrackElemType::rightReverser) - { - return false; - } - - if (PitchAndRollEnd(curRide, HasFlag(VehicleFlags::CarIsInverted), trackType, tileElement) != pitchAndRollStart) - { - return false; - } - - // Update VehicleFlags::CarIsInverted - const auto previousCarIsInverted = HasFlag(VehicleFlags::CarIsInverted); - ClearFlag(VehicleFlags::CarIsInverted); - if (GetRideTypeDescriptor(curRide.type).HasFlag(RtdFlag::hasInvertedVariant)) - { - if (tileElement->AsTrack()->IsInverted()) - { - SetFlag(VehicleFlags::CarIsInverted); - } - if (previousCarIsInverted != HasFlag(VehicleFlags::CarIsInverted)) - { - EntityTweener::Get().RemoveEntity(this); - } - } - - trackPos = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z }; - direction = trackBeginEnd.begin_direction; - } - else - { - // Loc6DBB4F:; - CoordsXYE input; - CoordsXYE output; - int32_t outputZ{}; - - input.x = trackPos.x; - input.y = trackPos.y; - input.element = tileElement; - if (!TrackBlockGetNext(&input, &output, &outputZ, &direction)) - { - return false; - } - tileElement = output.element; - trackPos = { output, outputZ }; - } - - // Loc6DBC3B: - TrackLocation = trackPos; - - if (TrackSubposition >= VehicleTrackSubposition::ChairliftGoingOut - && TrackSubposition <= VehicleTrackSubposition::ChairliftStartBullwheel) - { - TileCoordsXYZ curLocation{ TrackLocation }; - - if (curLocation == curRide.chairliftBullwheelLocation[1]) - { - TrackSubposition = VehicleTrackSubposition::ChairliftEndBullwheel; - } - else if (curLocation == curRide.chairliftBullwheelLocation[0]) - { - TrackSubposition = VehicleTrackSubposition::ChairliftStartBullwheel; - } - } - - if (tileElement->AsTrack()->HasChain()) - { - if (_vehicleVelocityF64E08 < 0) - { - if (next_vehicle_on_train.IsNull()) - { - trackType = tileElement->AsTrack()->GetTrackType(); - const auto& ted = GetTrackElementDescriptor(trackType); - if (!ted.flags.has(TrackElementFlag::down)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_9; - } - } - SetFlag(VehicleFlags::OnLiftHill); - } - } - else - { - if (HasFlag(VehicleFlags::OnLiftHill)) - { - ClearFlag(VehicleFlags::OnLiftHill); - if (next_vehicle_on_train.IsNull()) - { - if (_vehicleVelocityF64E08 < 0) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_8; - } - } - } - } - - trackType = tileElement->AsTrack()->GetTrackType(); - if (trackType != TrackElemType::brakes) - { - target_seat_rotation = tileElement->AsTrack()->GetSeatRotation(); - } - direction &= 3; - SetTrackType(trackType); - SetTrackDirection(direction); - PopulateBrakeSpeed(TrackLocation, *tileElement->AsTrack()); - if (HasFlag(VehicleFlags::StoppedOnHoldingBrake) && vertical_drop_countdown <= 0) - { - ClearFlag(VehicleFlags::StoppedOnHoldingBrake); - } - // There are two bytes before the move info list - uint16_t trackTotalProgress = GetTrackProgress(); - *progress = trackTotalProgress - 1; - return true; -} - -/** - * - * rct2: 0x006DBA33 - */ -bool Vehicle::UpdateTrackMotionBackwards(const CarEntry* carEntry, const Ride& curRide, const RideObjectEntry& rideEntry) -{ - EntityId otherVehicleIndex = EntityId::GetNull(); - - while (true) - { - auto trackType = GetTrackType(); - if (trackType == TrackElemType::flat && curRide.getRideTypeDescriptor().HasFlag(RtdFlag::hasLsmBehaviourOnFlat)) - { - int32_t unkVelocity = _vehicleVelocityF64E08; - if (unkVelocity < -524288) - { - unkVelocity = abs(unkVelocity); - acceleration = unkVelocity * 2; - } - } - - if (TrackTypeIsBrakes(trackType)) - { - auto brakeSpeed = ChooseBrakeSpeed(); - - if (-(brakeSpeed << kTrackSpeedShiftAmount) > _vehicleVelocityF64E08) - { - acceleration = _vehicleVelocityF64E08 * -16; - } - } - - uint16_t newTrackProgress = track_progress - 1; - if (newTrackProgress == 0xFFFF) - { - UpdateCrossings(); - - if (!UpdateTrackMotionBackwardsGetNewTrack(trackType, curRide, &newTrackProgress)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; - remaining_distance = 0x368A; - return false; - } - } - - // Loc6DBD42 - track_progress = newTrackProgress; - { - const VehicleInfo* moveInfo = GetMoveInfo(); - auto nextVehiclePosition = TrackLocation - + CoordsXYZ{ moveInfo->x, moveInfo->y, - moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; - - remaining_distance += Geometry::getTranslationDistance(nextVehiclePosition - _vehicleCurPosition, false); - - _vehicleCurPosition = nextVehiclePosition; - Orientation = moveInfo->yaw; - roll = moveInfo->roll; - pitch = moveInfo->pitch; - - if (carEntry->flags.has(CarEntryFlag::useWoodenWildMouseSwing) && pitch != VehiclePitch::flat) - { - SwingSprite = 0; - SwingPosition = 0; - SwingSpeed = 0; - } - - if (this == _vehicleFrontVehicle) - { - if (_vehicleVelocityF64E08 < 0) - { - otherVehicleIndex = next_vehicle_on_ride; - if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex)) - { - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; - remaining_distance = 0x368A; - - Vehicle* v3 = getGameState().entities.GetEntity(otherVehicleIndex); - Vehicle* v4 = gCurrentVehicle; - if (v3 == nullptr) - { - return false; - } - - if (!(rideEntry.flags & RIDE_ENTRY_FLAG_DISABLE_COLLISION_CRASHES)) - { - if (abs(v4->velocity - v3->velocity) > 14.0_mph) - { - if (!carEntry->flags.has(CarEntryFlag::useBoatHireCollisionDetection)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION; - } - } - } - - if (carEntry->flags.has(CarEntryFlag::isGoKart)) - { - velocity -= velocity >> 2; - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; - } - else - { - int32_t v3Velocity = v3->velocity; - v3->velocity = v4->velocity >> 1; - v4->velocity = v3Velocity >> 1; - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; - } - - return false; - } - } - } - } - - // Loc6DBE3F - if (remaining_distance >= 0) - { - return true; - } - acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - } -} - -[[nodiscard]] Vehicle::UpdateMiniGolfSubroutineStatus Vehicle::UpdateTrackMotionMiniGolfFlagsStatus(const Ride& curRide) -{ - if (var_D3 != 0) - { - var_D3--; - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - - if (mini_golf_flags & MiniGolfFlag::Flag2) - { - uint8_t nextFrame = animation_frame + 1; - if (nextFrame < kMiniGolfPeepAnimationLengths[EnumValue(mini_golf_current_animation)]) - { - animation_frame = nextFrame; - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - mini_golf_flags &= ~MiniGolfFlag::Flag2; - } - - if (mini_golf_flags & MiniGolfFlag::Flag0) - { - auto vehicleIdx = IsHead() ? next_vehicle_on_ride : prev_vehicle_on_ride; - Vehicle* vEDI = getGameState().entities.GetEntity(vehicleIdx); - if (vEDI == nullptr) - { - return UpdateMiniGolfSubroutineStatus::stop; - } - if (!(vEDI->mini_golf_flags & MiniGolfFlag::Flag0) || (vEDI->mini_golf_flags & MiniGolfFlag::Flag2)) - { - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - if (vEDI->var_D3 != 0) - { - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - vEDI->mini_golf_flags &= ~MiniGolfFlag::Flag0; - mini_golf_flags &= ~MiniGolfFlag::Flag0; - } - - if (mini_golf_flags & MiniGolfFlag::Flag1) - { - auto vehicleIdx = IsHead() ? next_vehicle_on_ride : prev_vehicle_on_ride; - Vehicle* vEDI = getGameState().entities.GetEntity(vehicleIdx); - if (vEDI == nullptr) - { - return UpdateMiniGolfSubroutineStatus::stop; - } - if (!(vEDI->mini_golf_flags & MiniGolfFlag::Flag1) || (vEDI->mini_golf_flags & MiniGolfFlag::Flag2)) - { - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - if (vEDI->var_D3 != 0) - { - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - vEDI->mini_golf_flags &= ~MiniGolfFlag::Flag1; - mini_golf_flags &= ~MiniGolfFlag::Flag1; - } - - if (mini_golf_flags & MiniGolfFlag::Flag3) - { - Vehicle* vEDI = this; - - for (;;) - { - vEDI = getGameState().entities.GetEntity(vEDI->prev_vehicle_on_ride); - if (vEDI == this || vEDI == nullptr) - { - break; - } - if (vEDI->IsHead()) - continue; - if (!(vEDI->mini_golf_flags & MiniGolfFlag::Flag4)) - continue; - if (vEDI->TrackLocation != TrackLocation) - continue; - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - - mini_golf_flags |= MiniGolfFlag::Flag4; - mini_golf_flags &= ~MiniGolfFlag::Flag3; - } - - return UpdateMiniGolfSubroutineStatus::carryOn; -} - -[[nodiscard]] Vehicle::UpdateMiniGolfSubroutineStatus Vehicle::Loc6DC462(const Ride& curRide) -{ - while (true) - { - UpdateMiniGolfSubroutineStatus flagsStatus = UpdateMiniGolfSubroutineStatus::restart; - while (flagsStatus == UpdateMiniGolfSubroutineStatus::restart) - { - flagsStatus = UpdateTrackMotionMiniGolfFlagsStatus(curRide); - } - if (flagsStatus == UpdateMiniGolfSubroutineStatus::stop) - return UpdateMiniGolfSubroutineStatus::stop; - - uint16_t trackTotalProgress = GetTrackProgress(); - if (track_progress + 1 >= trackTotalProgress) - { - CoordsXYZ trackPos; - Direction direction; - auto* tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, GetTrackType(), 0); - CoordsXYE output; - int32_t outZ{}; - int32_t outDirection{}; - CoordsXYE input = { TrackLocation, tileElement }; - if (!TrackBlockGetNext(&input, &output, &outZ, &outDirection)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; - remaining_distance = -1; - acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::carryOn; - } - tileElement = output.element; - trackPos = { output.x, output.y, outZ }; - direction = outDirection; - - if (PitchAndRollStart(false, tileElement) != TrackPitchAndRollEnd(GetTrackType())) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; - remaining_distance = -1; - if (remaining_distance >= 0) - { - Loc6DCDE4(curRide); - } - acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::carryOn; - } - - TrackLocation = trackPos; - - if (!IsHead()) - { - Vehicle* prevVehicle = getGameState().entities.GetEntity(prev_vehicle_on_ride); - if (prevVehicle != nullptr) - { - TrackSubposition = prevVehicle->TrackSubposition; - } - if (TrackSubposition != VehicleTrackSubposition::MiniGolfStart9) - { - TrackSubposition = VehicleTrackSubposition{ static_cast( - static_cast(TrackSubposition) - 1u) }; - } - } - - ClearFlag(VehicleFlags::OnLiftHill); - SetTrackType(tileElement->AsTrack()->GetTrackType()); - SetTrackDirection(direction); - brake_speed = tileElement->AsTrack()->GetBrakeBoosterSpeed(); - track_progress = 0; - } - else - { - track_progress += 1; - } - - if (!IsHead()) - { - animation_frame++; - if (animation_frame >= 6) - { - animation_frame = 0; - } - } - const VehicleInfo* moveInfo; - for (;;) - { - moveInfo = GetMoveInfo(); - if (moveInfo->x != kLocationNull) - { - break; - } - switch (MiniGolfState(moveInfo->y)) - { - case MiniGolfState::Unk0: // Loc6DC7B4 - if (!IsHead()) - { - mini_golf_flags |= MiniGolfFlag::Flag3; - } - else - { - uint16_t rand16 = ScenarioRand() & 0xFFFF; - VehicleTrackSubposition nextTrackSubposition = VehicleTrackSubposition::MiniGolfBallPathC14; - if (rand16 <= 0xA000) - { - nextTrackSubposition = VehicleTrackSubposition::MiniGolfBallPathB12; - if (rand16 <= 0x900) - { - nextTrackSubposition = VehicleTrackSubposition::MiniGolfBallPathA10; - } - } - TrackSubposition = nextTrackSubposition; - } - track_progress++; - break; - case MiniGolfState::Unk1: // Loc6DC7ED - LOG_ERROR("Unused move info..."); - assert(false); - var_D3 = static_cast(moveInfo->z); - track_progress++; - break; - case MiniGolfState::Unk2: // Loc6DC800 - mini_golf_flags |= MiniGolfFlag::Flag0; - track_progress++; - break; - case MiniGolfState::Unk3: // Loc6DC810 - mini_golf_flags |= MiniGolfFlag::Flag1; - track_progress++; - break; - case MiniGolfState::Unk4: // Loc6DC820 - { - auto animation = MiniGolfAnimation(moveInfo->z); - // When the ride is closed occasionally the peep is removed - // but the vehicle is still on the track. This will prevent - // it from crashing in that situation. - auto* curPeep = getGameState().entities.TryGetEntity(peep[0]); - if (curPeep != nullptr) - { - if (animation == MiniGolfAnimation::SwingLeft) - { - if (curPeep->PeepId & 7) - { - animation = MiniGolfAnimation::Swing; - } - } - if (animation == MiniGolfAnimation::PuttLeft) - { - if (curPeep->PeepId & 7) - { - animation = MiniGolfAnimation::Putt; - } - } - } - mini_golf_current_animation = animation; - animation_frame = 0; - track_progress++; - break; - } - case MiniGolfState::Unk5: // Loc6DC87A - mini_golf_flags |= MiniGolfFlag::Flag2; - track_progress++; - break; - case MiniGolfState::Unk6: // Loc6DC88A - mini_golf_flags &= ~MiniGolfFlag::Flag4; - mini_golf_flags |= MiniGolfFlag::Flag5; - track_progress++; - break; - default: - LOG_ERROR("Invalid move info..."); - assert(false); - break; - } - } - - // Loc6DC8A1 - CoordsXYZ trackPos = { TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, - TrackLocation.z + moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; - - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - _vehicleCurPosition = trackPos; - Orientation = moveInfo->yaw; - roll = moveInfo->roll; - pitch = moveInfo->pitch; - - if (this == _vehicleFrontVehicle) - { - if (_vehicleVelocityF64E08 >= 0) - { - auto otherVehicleIndex = prev_vehicle_on_ride; - UpdateMotionCollisionDetection(trackPos, &otherVehicleIndex); - } - } - if (remaining_distance < 0x368A) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - } -} - -[[nodiscard]] Vehicle::UpdateMiniGolfSubroutineStatus Vehicle::Loc6DCA9A(const Ride& curRide) -{ - while (true) - { - if (track_progress == 0) - { - auto tileElement = MapGetTrackElementAtOfTypeSeq(TrackLocation, GetTrackType(), 0); - TrackBeginEnd trackBeginEnd; - if (!TrackBlockGetPrevious({ TrackLocation, tileElement }, &trackBeginEnd)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance + 1; - remaining_distance = -1; - acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - continue; - } - CoordsXYZ trackPos = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z }; - auto direction = trackBeginEnd.begin_direction; - tileElement = trackBeginEnd.begin_element; - - if (PitchAndRollStart(false, tileElement) != TrackPitchAndRollEnd(GetTrackType())) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5; - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; - remaining_distance = 0x368A; - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - - TrackLocation = trackPos; - - if (HasFlag(VehicleFlags::OnLiftHill)) - { - ClearFlag(VehicleFlags::OnLiftHill); - if (next_vehicle_on_train.IsNull()) - { - if (_vehicleVelocityF64E08 < 0) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_8; - } - } - } - - SetTrackType(tileElement->AsTrack()->GetTrackType()); - SetTrackDirection(direction); - brake_speed = tileElement->AsTrack()->GetBrakeBoosterSpeed(); - - // There are two bytes before the move info list - track_progress = GetTrackProgress(); - } - else - { - track_progress -= 1; - } - - auto moveInfo = GetMoveInfo(); - CoordsXYZ trackPos = { TrackLocation.x + moveInfo->x, TrackLocation.y + moveInfo->y, - TrackLocation.z + moveInfo->z + GetRideTypeDescriptor(curRide.type).Heights.VehicleZOffset }; - - remaining_distance -= 0x368A; - if (remaining_distance < 0) - { - remaining_distance = 0; - } - - _vehicleCurPosition = trackPos; - Orientation = moveInfo->yaw; - roll = moveInfo->roll; - pitch = moveInfo->pitch; - - if (this == _vehicleFrontVehicle) - { - if (_vehicleVelocityF64E08 >= 0) - { - auto otherVehicleIndex = EntityId::FromUnderlying(var_44); // Possibly wrong?. - if (UpdateMotionCollisionDetection(trackPos, &otherVehicleIndex)) - { - _vehicleVelocityF64E0C -= remaining_distance - 0x368A; - remaining_distance = 0x368A; - { - Vehicle* vEBP = getGameState().entities.GetEntity(otherVehicleIndex); - if (vEBP == nullptr) - { - return UpdateMiniGolfSubroutineStatus::stop; - } - Vehicle* vEDI = gCurrentVehicle; - if (abs(vEDI->velocity - vEBP->velocity) > 14.0_mph) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION; - } - vEDI->velocity = vEBP->velocity >> 1; - vEBP->velocity = vEDI->velocity >> 1; - } - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_2; - acceleration = Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - return UpdateMiniGolfSubroutineStatus::restart; - } - } - } - - if (remaining_distance >= 0) - { - Loc6DCDE4(curRide); - return UpdateMiniGolfSubroutineStatus::stop; - } - acceleration += Geometry::getAccelerationFromPitch(pitch); - _vehicleUnkF64E10++; - } -} - -/** - * rct2: 0x006DC3A7 - * - * - */ - -void Vehicle::UpdateTrackMotionMiniGolfVehicle(const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) -{ - _vehicleUnkF64E10 = 1; - acceleration = Geometry::getAccelerationFromPitch(pitch); - if (!HasFlag(VehicleFlags::MoveSingleCar)) - { - remaining_distance = _vehicleVelocityF64E0C + remaining_distance; - } - if (remaining_distance >= 0 && remaining_distance < 0x368A) - { - Loc6DCE02(curRide); - return; - } - sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; - _vehicleCurPosition.x = x; - _vehicleCurPosition.y = y; - _vehicleCurPosition.z = z; - Invalidate(); - bool skipLoc6DC462 = (remaining_distance < 0); - - while (true) - { - if (!skipLoc6DC462) - { - auto result1 = Loc6DC462(curRide); - if (result1 == UpdateMiniGolfSubroutineStatus::stop) - return; - } - skipLoc6DC462 = false; - auto result2 = Loc6DCA9A(curRide); - if (result2 == UpdateMiniGolfSubroutineStatus::stop) - return; - } -} - -void Vehicle::Loc6DCDE4(const Ride& curRide) -{ - MoveTo(_vehicleCurPosition); - - Loc6DCE02(curRide); -} - -void Vehicle::Loc6DCE02(const Ride& curRide) -{ - acceleration /= _vehicleUnkF64E10; - if (TrackSubposition == VehicleTrackSubposition::ChairliftGoingBack) - { - return; - } - - auto trackType = GetTrackType(); - const auto& ted = GetTrackElementDescriptor(trackType); - if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin)) - { - return; - } - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_3; - if (trackType != TrackElemType::endStation) - { - return; - } - if (this != gCurrentVehicle) - { - return; - } - if (_vehicleVelocityF64E08 < 0) - { - if (track_progress > 11) - { - return; - } - } - if (track_progress <= 8) - { - return; - } - - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION; - - for (const auto& station : curRide.getStations()) - { - if (TrackLocation != station.Start) - { - continue; - } - if (TrackLocation.z != station.GetBaseZ()) - { - continue; - } - _vehicleStationIndex = curRide.getStationIndex(&station); - } -} - -static constexpr int32_t GetAccelerationDecrease2(const int32_t velocity, const int32_t totalMass) -{ - int32_t accelerationDecrease2 = velocity >> 8; - accelerationDecrease2 *= accelerationDecrease2; - if (velocity < 0) - { - accelerationDecrease2 = -accelerationDecrease2; - } - accelerationDecrease2 >>= 4; - // OpenRCT2: vehicles from different track types can have 0 mass. - if (totalMass != 0) - { - return accelerationDecrease2 / totalMass; - } - - return accelerationDecrease2; -} - -int32_t Vehicle::UpdateTrackMotionMiniGolfCalculateAcceleration(const CarEntry& carEntry) -{ - int32_t sumAcceleration = 0; - int32_t numVehicles = 0; - uint16_t totalMass = 0; - - for (Vehicle* vehicle = this; vehicle != nullptr; - vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) - { - numVehicles++; - totalMass += vehicle->mass; - sumAcceleration += vehicle->acceleration; - } - - int32_t newAcceleration = ((sumAcceleration / numVehicles) * 21) >> 9; - newAcceleration -= velocity >> 12; - newAcceleration -= GetAccelerationDecrease2(velocity, totalMass); - - { - int32_t poweredAcceleration = speed << 14; - int32_t quarterForce = (speed * totalMass) >> 2; - if (HasFlag(VehicleFlags::PoweredCarInReverse)) - { - poweredAcceleration = -poweredAcceleration; - } - poweredAcceleration -= velocity; - poweredAcceleration *= powered_acceleration << 1; - if (quarterForce != 0) - poweredAcceleration /= quarterForce; - - if (abs(velocity) > 1.0_mph) - { - newAcceleration = 0; - } - newAcceleration += poweredAcceleration; - } - - return newAcceleration; -} - -int32_t Vehicle::UpdateTrackMotionMiniGolf(int32_t* outStation) -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return 0; - - const auto* rideEntry = GetRideEntry(); - if (rideEntry == nullptr) - return 0; - - const auto* carEntry = Entry(); - - gCurrentVehicle = this; - _vehicleMotionTrackFlags = 0; - velocity += acceleration; - _vehicleVelocityF64E08 = velocity; - _vehicleVelocityF64E0C = (velocity >> 10) * 42; - _vehicleFrontVehicle = _vehicleVelocityF64E08 < 0 ? TrainTail() : this; - - for (Vehicle* vehicle = _vehicleFrontVehicle; vehicle != nullptr;) - { - vehicle->UpdateTrackMotionMiniGolfVehicle(*curRide, *rideEntry, carEntry); - if (vehicle->HasFlag(VehicleFlags::OnLiftHill)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL; - } - if (vehicle->HasFlag(VehicleFlags::MoveSingleCar)) - { - if (outStation != nullptr) - *outStation = _vehicleStationIndex.ToUnderlying(); - return _vehicleMotionTrackFlags; - } - if (_vehicleVelocityF64E08 >= 0) - { - vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train); - } - else - { - if (vehicle == gCurrentVehicle) - { - break; - } - vehicle = getGameState().entities.GetEntity(vehicle->prev_vehicle_on_ride); - } - } - - acceleration = UpdateTrackMotionMiniGolfCalculateAcceleration(*carEntry); - - if (outStation != nullptr) - *outStation = _vehicleStationIndex.ToUnderlying(); - return _vehicleMotionTrackFlags; -} - -/** - * - * rct2: 0x006DC1E4 - */ -static uint8_t modified_speed(TrackElemType trackType, VehicleTrackSubposition trackSubposition, uint8_t speed) -{ - enum - { - FULL_SPEED, - THREE_QUARTER_SPEED, - HALF_SPEED - }; - - uint8_t speedModifier = FULL_SPEED; - - if (trackType == TrackElemType::leftQuarterTurn1Tile) - { - speedModifier = (trackSubposition == VehicleTrackSubposition::GoKartsLeftLane) ? HALF_SPEED : THREE_QUARTER_SPEED; - } - else if (trackType == TrackElemType::rightQuarterTurn1Tile) - { - speedModifier = (trackSubposition == VehicleTrackSubposition::GoKartsRightLane) ? HALF_SPEED : THREE_QUARTER_SPEED; - } - - switch (speedModifier) - { - case HALF_SPEED: - return speed >> 1; - case THREE_QUARTER_SPEED: - return speed - (speed >> 2); - } - return speed; -} - -int32_t Vehicle::UpdateTrackMotionPoweredRideAcceleration( - const CarEntry* carEntry, uint32_t totalMass, const int32_t curAcceleration) -{ - if (carEntry->flags.has(CarEntryFlag::isPoweredRideWithUnrestrictedGravity)) - { - if (velocity > (speed * 0x4000)) - { - // Same code as none powered rides - if (curAcceleration <= 0 && curAcceleration >= -500 && velocity <= 0.5_mph) - { - return curAcceleration + 400; - } - return curAcceleration; - } - } - uint8_t modifiedSpeed = modified_speed(GetTrackType(), TrackSubposition, speed); - int32_t poweredAcceleration = modifiedSpeed << 14; - int32_t quarterForce = (modifiedSpeed * totalMass) >> 2; - if (HasFlag(VehicleFlags::PoweredCarInReverse)) - { - poweredAcceleration = -poweredAcceleration; - } - poweredAcceleration -= velocity; - poweredAcceleration *= powered_acceleration << 1; - if (quarterForce != 0) - { - poweredAcceleration /= quarterForce; - } - - if (carEntry->flags.has(CarEntryFlag::isLift)) - { - poweredAcceleration *= 4; - } - - if (carEntry->flags.has(CarEntryFlag::isWaterRide)) - { - if (poweredAcceleration < 0) - { - poweredAcceleration >>= 4; - } - - if (carEntry->flags.has(CarEntryFlag::hasSpinning)) - { - spin_speed = std::clamp(spin_speed, kVehicleMinSpinSpeedWaterRide, kVehicleMaxSpinSpeedWaterRide); - } - - if (pitch != VehiclePitch::flat) - { - if (poweredAcceleration < 0) - { - poweredAcceleration = 0; - } - - if (carEntry->flags.has(CarEntryFlag::hasSpinning)) - { - // If the vehicle is on the up slope kill the spin speedModifier - if (pitch == VehiclePitch::up25) - { - spin_speed = 0; - } - } - return curAcceleration + poweredAcceleration; - } - } - - if (std::abs(velocity) <= 1.0_mph) - { - return poweredAcceleration; - } - - return curAcceleration + poweredAcceleration; -} - -void Vehicle::UpdateTrackMotionPreUpdate( - Vehicle& car, const Ride& curRide, const RideObjectEntry& rideEntry, const CarEntry* carEntry) -{ - if (carEntry->flags.has(CarEntryFlag::hasSwinging)) - { - car.UpdateSwingingCar(); - } - if (carEntry->flags.has(CarEntryFlag::hasSpinning)) - { - car.UpdateSpinningCar(); - } - if (carEntry->flags.hasAny(CarEntryFlag::hasVehicleAnimation, CarEntryFlag::hasRiderAnimation)) - { - car.UpdateAdditionalAnimation(); - } - car.acceleration = Geometry::getAccelerationFromPitch(car.pitch); - _vehicleUnkF64E10 = 1; - - if (!car.HasFlag(VehicleFlags::MoveSingleCar)) - { - car.remaining_distance += _vehicleVelocityF64E0C; - } - - car.sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL; - _vehicleCurPosition.x = car.x; - _vehicleCurPosition.y = car.y; - _vehicleCurPosition.z = car.z; - car.Invalidate(); - - while (true) - { - if (car.remaining_distance < 0) - { - // Backward loop - if (car.UpdateTrackMotionBackwards(carEntry, curRide, rideEntry)) - { - break; - } - - if (car.remaining_distance < 0x368A) - { - break; - } - car.acceleration += Geometry::getAccelerationFromPitch(car.pitch); - _vehicleUnkF64E10++; - continue; - } - if (car.remaining_distance < 0x368A) - { - // Location found - return; - } - if (car.UpdateTrackMotionForwards(carEntry, curRide, rideEntry)) - { - break; - } - - if (car.remaining_distance >= 0) - { - break; - } - car.acceleration = Geometry::getAccelerationFromPitch(car.pitch); - _vehicleUnkF64E10++; - } - // Loc6DBF20 - car.MoveTo(_vehicleCurPosition); -} - -/** - * - * rct2: 0x006DAB4C - */ -int32_t Vehicle::UpdateTrackMotion(int32_t* outStation) -{ - auto curRide = GetRide(); - if (curRide == nullptr) - return 0; - - const auto* rideEntry = GetRideEntry(); - const auto* carEntry = Entry(); - - if (carEntry == nullptr) - { - return 0; - } - - if (carEntry->flags.has(CarEntryFlag::isMiniGolf)) - { - return UpdateTrackMotionMiniGolf(outStation); - } - - _vehicleF64E2C = 0; - gCurrentVehicle = this; - _vehicleMotionTrackFlags = 0; - _vehicleStationIndex = StationIndex::GetNull(); - - UpdateTrackMotionUpStopCheck(); - CheckAndApplyBlockSectionStopSite(); - UpdateVelocity(); - - Vehicle* vehicle = this; - if (_vehicleVelocityF64E08 < 0 && !vehicle->HasFlag(VehicleFlags::MoveSingleCar)) - { - vehicle = vehicle->TrainTail(); - } - // This will be the front vehicle even when traveling - // backwards. - _vehicleFrontVehicle = vehicle; - - auto spriteId = vehicle->Id; - while (!spriteId.IsNull()) - { - Vehicle* car = getGameState().entities.GetEntity(spriteId); - if (car == nullptr) - { - break; - } - carEntry = car->Entry(); - if (carEntry != nullptr) - { - UpdateTrackMotionPreUpdate(*car, *curRide, *rideEntry, carEntry); - } - - car->Sub6DBF3E(); - - // Loc6DC0F7 - if (car->HasFlag(VehicleFlags::OnLiftHill)) - { - _vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_ON_LIFT_HILL; - } - if (car->HasFlag(VehicleFlags::MoveSingleCar)) - { - if (outStation != nullptr) - *outStation = _vehicleStationIndex.ToUnderlying(); - return _vehicleMotionTrackFlags; - } - if (_vehicleVelocityF64E08 >= 0) - { - spriteId = car->next_vehicle_on_train; - } - else - { - if (car == gCurrentVehicle) - { - break; - } - spriteId = car->prev_vehicle_on_ride; - } - } - // Loc6DC144 - vehicle = gCurrentVehicle; - - carEntry = vehicle->Entry(); - // eax - int32_t totalAcceleration = 0; - // ebp - int32_t totalMass = 0; - // ebx - int32_t numVehicles = 0; - - for (; vehicle != nullptr; vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) - { - numVehicles++; - totalMass += vehicle->mass; - totalAcceleration += vehicle->acceleration; - } - - vehicle = gCurrentVehicle; - int32_t newAcceleration = (totalAcceleration / numVehicles) * 21; - if (newAcceleration < 0) - { - newAcceleration += 511; - } - newAcceleration >>= 9; - - int32_t curAcceleration = newAcceleration; - curAcceleration -= vehicle->velocity / 4096; - curAcceleration -= GetAccelerationDecrease2(vehicle->velocity, totalMass); - - if (carEntry->flags.has(CarEntryFlag::isPowered)) - { - curAcceleration = vehicle->UpdateTrackMotionPoweredRideAcceleration(carEntry, totalMass, curAcceleration); - } - else if (curAcceleration <= 0 && curAcceleration >= -500) - { - // Probably moving slowly on a flat track piece, low rolling resistance and drag. - - if (vehicle->velocity <= 0.5_mph && vehicle->velocity >= 0) - { - // Vehicle is creeping forwards very slowly (less than ~2km/h), boost speed a bit. - curAcceleration += 400; - } - } - - if (vehicle->GetTrackType() == TrackElemType::watersplash) - { - if (vehicle->track_progress >= 48 && vehicle->track_progress <= 128) - { - curAcceleration -= vehicle->velocity >> 6; - } - } - - if (rideEntry->flags & RIDE_ENTRY_FLAG_PLAY_SPLASH_SOUND_SLIDE) - { - if (vehicle->IsHead()) - { - if (vehicle->IsOnCoveredTrack()) - { - if (vehicle->velocity > 2.0_mph) - { - curAcceleration -= vehicle->velocity >> 6; - } - } - } - } - - vehicle->acceleration = curAcceleration; - - // hook_setreturnregisters(®s); - if (outStation != nullptr) - *outStation = _vehicleStationIndex.ToUnderlying(); - return _vehicleMotionTrackFlags; -} - const RideObjectEntry* Vehicle::GetRideEntry() const { return GetRideEntryByIndex(ride_subtype); @@ -8380,7 +1300,7 @@ void Vehicle::UpdateCrossings() const // Parks may have rides hacked into the path. // Limit path blocking to rides actually supporting level crossings to prevent peeps getting stuck everywhere. - if (!GetRideTypeDescriptor(curRide->type).HasFlag(RtdFlag::supportsLevelCrossings)) + if (!GetRideTypeDescriptor(curRide->type).flags.has(RtdFlag::supportsLevelCrossings)) { return; } @@ -8395,7 +1315,7 @@ void Vehicle::UpdateCrossings() const const Vehicle* frontVehicle{}; const Vehicle* backVehicle{}; - bool travellingForwards = !HasFlag(VehicleFlags::PoweredCarInReverse); + bool travellingForwards = !flags.has(VehicleFlag::poweredCarInReverse); if (travellingForwards) { @@ -8509,22 +1429,6 @@ void Vehicle::UpdateCrossings() const } } -void Vehicle::Claxon() const -{ - const auto* rideEntry = GetRideEntry(); - switch (rideEntry->Cars[vehicle_type].soundRange) - { - case SoundRange::steamWhistle: - Play3D(SoundId::trainWhistle, { x, y, z }); - break; - case SoundRange::tramBell: - Play3D(SoundId::tram, { x, y, z }); - break; - default: - break; - } -} - Vehicle* Vehicle::GetHead() { auto v = this; @@ -8574,7 +1478,7 @@ void Vehicle::EnableCollisionsForTrain() for (auto vehicle = this; vehicle != nullptr; vehicle = getGameState().entities.GetEntity(vehicle->next_vehicle_on_train)) { - vehicle->ClearFlag(VehicleFlags::CollisionDisabled); + vehicle->flags.unset(VehicleFlag::collisionDisabled); } } @@ -8598,7 +1502,7 @@ void Vehicle::Serialise(DataSerialiser& stream) stream << next_vehicle_on_ride; stream << var_44; stream << mass; - stream << Flags; + stream << flags.holder; stream << SwingSprite; stream << current_station; stream << SwingPosition; @@ -8633,7 +1537,7 @@ void Vehicle::Serialise(DataSerialiser& stream) stream << vertical_drop_countdown; stream << var_D3; stream << mini_golf_current_animation; - stream << mini_golf_flags; + stream << miniGolfFlags.holder; stream << ride_subtype; stream << seat_rotation; stream << target_seat_rotation; diff --git a/src/openrct2/ride/Vehicle.h b/src/openrct2/ride/Vehicle.h index 6d2a98960d..8af0d981b4 100644 --- a/src/openrct2/ride/Vehicle.h +++ b/src/openrct2/ride/Vehicle.h @@ -11,6 +11,7 @@ #include "../Identifiers.h" #include "../audio/Audio.h" +#include "../core/FlagHolder.hpp" #include "../entity/EntityBase.h" #include "../ride/RideTypes.h" #include "../world/Location.hpp" @@ -49,13 +50,56 @@ struct VehicleInfo } }; -struct SoundIdVolume; +struct SoundIdVolume +{ + OpenRCT2::Audio::SoundId id; + uint8_t volume; +}; static constexpr uint16_t kVehicleTrackDirectionMask = 0b0000000000000011; static constexpr uint16_t kVehicleTrackTypeMask = 0b1111111111111100; +enum class VehicleFlag : uint8_t +{ + onLiftHill, + collisionDisabled, + waitingOnAdjacentStation, + poweredCarInReverse, + readyToDepart, + testing, + // When go-karts are colliding, they have a higher chance of changing lanes + currentlyColliding, + // Used on vehicles when a safety cut-out stops them, such as RCs on a lift hill and powered rides + stoppedBySafetyCutout, + carIsBroken, + trainIsBroken, + stoppedOnHoldingBrake, + // Used on vehicles that can run inverted for extended periods of time, i.e. the Flying, Lay-down and Multi-Dimension trains + carIsInverted, + // Set when the vehicle travels backwards through the station for the first time + reverseInclineCompletedLap, + spinningIsLocked, // After passing a rotation toggle track piece this will enable + // OpenRCT2 Flag: Used to override UpdateMotion to move the position of an individual car on a train + moveSingleCar, + crashed, // Car displays as smoke plume + carIsReversed, // Car is displayed running backwards +}; +using VehicleFlags = FlagHolder; + enum class MiniGolfAnimation : uint8_t; +enum class MiniGolfFlag : uint8_t +{ + flag0, + flag1, + flag2, + flag3, + flag4, + flag5, // transitioning between hole +}; + +using MiniGolfFlags = FlagHolder; + struct Vehicle : EntityBase { static constexpr auto cEntityType = EntityType::vehicle; @@ -139,7 +183,7 @@ struct Vehicle : EntityBase uint16_t var_44; uint16_t mass; - uint32_t Flags; + VehicleFlags flags; uint8_t SwingSprite; StationIndex current_station; union @@ -210,7 +254,7 @@ struct Vehicle : EntityBase int8_t vertical_drop_countdown; uint8_t var_D3; MiniGolfAnimation mini_golf_current_animation; - uint8_t mini_golf_flags; + MiniGolfFlags miniGolfFlags; OpenRCT2::ObjectEntryIndex ride_subtype; uint8_t seat_rotation; uint8_t target_seat_rotation; @@ -267,18 +311,6 @@ struct Vehicle : EntityBase TrackTypeAndDirection &= ~kVehicleTrackDirectionMask; TrackTypeAndDirection |= trackDirection & kVehicleTrackDirectionMask; } - bool HasFlag(uint32_t flag) const - { - return (Flags & flag) != 0; - } - void ClearFlag(uint32_t flag) - { - Flags &= ~flag; - } - void SetFlag(uint32_t flag) - { - Flags |= flag; - } void ApplyMass(int16_t appliedMass); void Serialise(DataSerialiser& stream); void Paint(PaintSession& session, int32_t imageDirection) const; @@ -416,16 +448,6 @@ struct TrainReference Vehicle* tail; }; -namespace OpenRCT2::MiniGolfFlag -{ - constexpr uint8_t Flag0 = (1 << 0); - constexpr uint8_t Flag1 = (1 << 1); - constexpr uint8_t Flag2 = (1 << 2); - constexpr uint8_t Flag3 = (1 << 3); - constexpr uint8_t Flag4 = (1 << 4); - constexpr uint8_t Flag5 = (1 << 5); // transitioning between hole -} // namespace OpenRCT2::MiniGolfFlag - enum class MiniGolfState : int16_t { Unk0, @@ -456,32 +478,6 @@ enum BoatHireSubState : uint8_t EnteringReturnPosition, }; -namespace OpenRCT2::VehicleFlags -{ - constexpr uint32_t OnLiftHill = (1 << 0); - constexpr uint32_t CollisionDisabled = (1 << 1); - constexpr uint32_t WaitingOnAdjacentStation = (1 << 2); - constexpr uint32_t PoweredCarInReverse = (1 << 3); - constexpr uint32_t ReadyToDepart = (1 << 4); - constexpr uint32_t Testing = (1 << 5); - // When go-karts are colliding, they have a higher chance of changing lanes - constexpr uint32_t CurrentlyColliding = (1 << 6); - // Used on vehicles when a safety cut-out stops them, such as RCs on a lift hill and powered rides - constexpr uint32_t StoppedBySafetyCutOut = (1 << 7); - constexpr uint32_t CarIsBroken = (1 << 8); - constexpr uint32_t TrainIsBroken = (1 << 9); - constexpr uint32_t StoppedOnHoldingBrake = (1 << 10); - // Used on vehicles that can run inverted for extended periods of time, i.e. the Flying, Lay-down and Multi-Dimension trains - constexpr uint32_t CarIsInverted = (1 << 11); - // Set when the vehicle travels backwards through the station for the first time - constexpr uint32_t ReverseInclineCompletedLap = (1 << 12); - constexpr uint32_t SpinningIsLocked = (1 << 13); // After passing a rotation toggle track piece this will enable - // OpenRCT2 Flag: Used to override UpdateMotion to move the position of an individual car on a train - constexpr uint32_t MoveSingleCar = (1 << 14); - constexpr uint32_t Crashed = (1 << 15); // Car displays as smoke plume - constexpr uint32_t CarIsReversed = (1 << 16); // Car is displayed running backwards -} // namespace OpenRCT2::VehicleFlags - enum { VEHICLE_VISUAL_DEFAULT, @@ -554,6 +550,7 @@ constexpr uint8_t kVehicleSeatNumMask = 0x7F; Vehicle* TryGetVehicle(EntityId spriteIndex); void VehicleUpdateAll(); void VehicleSoundsUpdate(); +std::optional ride_get_train_index_from_vehicle(const Ride& ride, EntityId spriteIndex); uint16_t VehicleGetMoveInfoSize(VehicleTrackSubposition trackSubposition, OpenRCT2::TrackElemType type, uint8_t direction); void RideUpdateMeasurementsSpecialElements_Default(Ride& ride, OpenRCT2::TrackElemType trackType); @@ -561,6 +558,7 @@ void RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, OpenRCT2::TrackE void RideUpdateMeasurementsSpecialElements_WaterCoaster(Ride& ride, OpenRCT2::TrackElemType trackType); extern Vehicle* gCurrentVehicle; +extern uint8_t _vehicleBreakdown; extern StationIndex _vehicleStationIndex; extern uint32_t _vehicleMotionTrackFlags; extern int32_t _vehicleVelocityF64E08; diff --git a/src/openrct2/ride/rtd/coaster/AirPoweredVerticalCoaster.h b/src/openrct2/ride/rtd/coaster/AirPoweredVerticalCoaster.h index e9beaae453..dd4b4d4ed2 100644 --- a/src/openrct2/ride/rtd/coaster/AirPoweredVerticalCoaster.h +++ b/src/openrct2/ride/rtd/coaster/AirPoweredVerticalCoaster.h @@ -28,7 +28,7 @@ constexpr RideTypeDescriptor AirPoweredVerticalCoasterRTD = .extraTrackGroups = {TrackGroup::booster}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | EnumsToFlags(RtdFlag::checkGForces), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | RtdFlags(RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch), .DefaultMode = RideMode::poweredLaunchPasstrough, .OperatingSettings = { 30, 50 }, diff --git a/src/openrct2/ride/rtd/coaster/AlpineCoaster.h b/src/openrct2/ride/rtd/coaster/AlpineCoaster.h index 14de91692a..cc6573965b 100644 --- a/src/openrct2/ride/rtd/coaster/AlpineCoaster.h +++ b/src/openrct2/ride/rtd/coaster/AlpineCoaster.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor AlpineCoasterRTD = .extraTrackGroups = {TrackGroup::helixUpBankedHalf}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::checkForStalling, RtdFlag::hasTrack, RtdFlag::allowMusic, RtdFlag::interestingToLookAt, RtdFlag::supportsMultipleColourSchemes, @@ -35,6 +35,7 @@ constexpr RideTypeDescriptor AlpineCoasterRTD = RtdFlag::noTestMode, RtdFlag::allowMoreVehiclesThanStationFits, RtdFlag::upInclineRequiresLift), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .TrackSpeedSettings = { 10, 10 }, .Naming = { STR_RIDE_NAME_ALPINE_COASTER, STR_RIDE_DESCRIPTION_ALPINE_COASTER }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, @@ -55,7 +56,7 @@ constexpr RideTypeDescriptor AlpineCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_ALPINE_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_ALPINE_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "alpine_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 30), RideRating::make(2, 10), RideRating::make(1, 4) }, diff --git a/src/openrct2/ride/rtd/coaster/BobsleighCoaster.h b/src/openrct2/ride/rtd/coaster/BobsleighCoaster.h index 6d4855f684..4c17ee9c80 100644 --- a/src/openrct2/ride/rtd/coaster/BobsleighCoaster.h +++ b/src/openrct2/ride/rtd/coaster/BobsleighCoaster.h @@ -23,16 +23,17 @@ constexpr RideTypeDescriptor BobsleighCoasterRTD = .StartTrackPiece = TrackElemType::endStation, .TrackPaintFunctions = TrackDrawerDescriptor({ .trackStyle = TrackStyle::bobsleighCoaster, - .supportType = MetalSupportType::tubes, + .supportType = MetalSupportType::tubes, .enabledTrackGroups = {TrackGroup::straight, TrackGroup::stationEnd, TrackGroup::liftHill, TrackGroup::flatRollBanking, TrackGroup::slope, TrackGroup::sBend, TrackGroup::curveSmall, TrackGroup::curve,TrackGroup::helixDownBankedHalf, TrackGroup::helixUpBankedHalf, TrackGroup::brakes,TrackGroup::blockBrakes, TrackGroup::onridePhoto}, .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 7, 27 }, .Naming = { STR_RIDE_NAME_BOBSLEIGH_COASTER, STR_RIDE_DESCRIPTION_BOBSLEIGH_COASTER }, .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -55,7 +56,7 @@ constexpr RideTypeDescriptor BobsleighCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_BOBSLEIGH_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_BOBSLEIGH_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "bobsleigh_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 80), RideRating::make(3, 20), RideRating::make(2, 50) }, diff --git a/src/openrct2/ride/rtd/coaster/ClassicMiniRollerCoaster.h b/src/openrct2/ride/rtd/coaster/ClassicMiniRollerCoaster.h index 1b01fe94ec..81a70deed2 100644 --- a/src/openrct2/ride/rtd/coaster/ClassicMiniRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/ClassicMiniRollerCoaster.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor ClassicMiniRollerCoasterRTD = .extraTrackGroups = {TrackGroup::onridePhoto}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::allowDoorsOnTrack, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::allowDoorsOnTrack, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::reverseInclineLaunchedShuttle), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .BoosterSettings = { 17, 16 }, .LegacyBoosterSettings = { 17, 16, 1 }, .Naming = { STR_RIDE_NAME_CLASSIC_MINI_ROLLER_COASTER, STR_RIDE_DESCRIPTION_CLASSIC_MINI_COASTER }, @@ -58,7 +59,7 @@ constexpr RideTypeDescriptor ClassicMiniRollerCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_JUNIOR_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_JUNIOR_ROLLER_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "classic_mini_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 40), RideRating::make(2, 80), RideRating::make(1, 90) }, diff --git a/src/openrct2/ride/rtd/coaster/ClassicStandUpRollerCoaster.h b/src/openrct2/ride/rtd/coaster/ClassicStandUpRollerCoaster.h index 2eecdb264c..729bcd2b80 100644 --- a/src/openrct2/ride/rtd/coaster/ClassicStandUpRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/ClassicStandUpRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor ClassicStandUpRollerCoasterRTD = .extraTrackGroups = {TrackGroup::slopeVertical, TrackGroup::slopeCurveSteep, TrackGroup::curveVertical, TrackGroup::quarterLoop, TrackGroup::barrelRoll, TrackGroup::zeroGRoll, TrackGroup::zeroGRollLarge}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::reverseInclineLaunchedShuttle, RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/ClassicWoodenRollerCoaster.h b/src/openrct2/ride/rtd/coaster/ClassicWoodenRollerCoaster.h index 7f90cbd071..7e887df816 100644 --- a/src/openrct2/ride/rtd/coaster/ClassicWoodenRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/ClassicWoodenRollerCoaster.h @@ -19,70 +19,71 @@ namespace OpenRCT2 { constexpr RideTypeDescriptor ClassicWoodenRollerCoasterRTD = { - .Category = RideCategory::rollerCoaster, - .StartTrackPiece = TrackElemType::endStation, - .TrackPaintFunctions = TrackDrawerDescriptor({ - .trackStyle = TrackStyle::classicWoodenRollerCoaster, - .supportType = WoodenSupportType::truss, - .enabledTrackGroups = { TrackGroup::flat, TrackGroup::straight, TrackGroup::stationEnd, TrackGroup::liftHill, TrackGroup::flatRollBanking, TrackGroup::verticalLoop, TrackGroup::slope, TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::slopeCurve, TrackGroup::sBend, TrackGroup::curveSmall, TrackGroup::curve, TrackGroup::curveLarge, TrackGroup::brakes, TrackGroup::onridePhoto, TrackGroup::waterSplash, TrackGroup::blockBrakes, TrackGroup::diagBrakes, TrackGroup::diagBlockBrakes, TrackGroup::slopeSteepLong, TrackGroup::halfLoopMedium, TrackGroup::halfLoopLarge, TrackGroup::diagSlope, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown }, - .extraTrackGroups = {TrackGroup::booster, TrackGroup::slopeCurveSteep}, - }), - .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, - RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), - .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), - .DefaultMode = RideMode::continuousCircuit, - .BoosterSettings = { 0, 68 }, - .LegacyBoosterSettings = { 0, 68 }, - .Naming = { STR_RIDE_NAME_CLASSIC_WOODEN_ROLLER_COASTER, STR_RIDE_DESCRIPTION_CLASSIC_WOODEN_ROLLER_COASTER }, - .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, - .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), - .Heights = { 24, 24, 8, 11, }, - .MaxMass = 19, - .LiftData = { Audio::SoundId::liftWood, 3, 5 }, - .RatingsMultipliers = { 52, 33, 4 }, - .UpkeepCosts = { 40, 20, 80, 10, 3, 10 }, - .BuildCosts = {37.50_GBP, 3.50_GBP, 50, }, - .DefaultPrices = { 20, 20 }, - .DefaultMusic = kMusicObjectWildWest, - .PhotoItem = ShopItem::photo3, - .BonusValue = 105, - .ColourPresets = TRACK_COLOUR_PRESETS( - { Drawing::Colour::saturatedBrown, Drawing::Colour::saturatedBrown, Drawing::Colour::saturatedBrown}, - { Drawing::Colour::white, Drawing::Colour::lightBrown, Drawing::Colour::white }, - { Drawing::Colour::lightBrown, Drawing::Colour::black, Drawing::Colour::lightBrown }, - ), - .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_CLASSIC_WOODEN_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_CLASSIC_WOODEN_ROLLER_COASTER_SUPPORTS }, - .ColourKey = RideColourKey::Ride, - .Name = "classic_wooden_rc", - .RatingsData = - { - RatingsCalculationType::Normal, - { RideRating::make(2, 80), RideRating::make(2, 60), RideRating::make(2, 00) }, - 19, - kDynamicRideShelterRating, - false, + .Category = RideCategory::rollerCoaster, + .StartTrackPiece = TrackElemType::endStation, + .TrackPaintFunctions = TrackDrawerDescriptor({ + .trackStyle = TrackStyle::classicWoodenRollerCoaster, + .supportType = WoodenSupportType::truss, + .enabledTrackGroups = { TrackGroup::flat, TrackGroup::straight, TrackGroup::stationEnd, TrackGroup::liftHill, TrackGroup::flatRollBanking, TrackGroup::verticalLoop, TrackGroup::slope, TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::slopeCurve, TrackGroup::sBend, TrackGroup::curveSmall, TrackGroup::curve, TrackGroup::curveLarge, TrackGroup::brakes, TrackGroup::onridePhoto, TrackGroup::waterSplash, TrackGroup::blockBrakes, TrackGroup::diagBrakes, TrackGroup::diagBlockBrakes, TrackGroup::slopeSteepLong, TrackGroup::halfLoopMedium, TrackGroup::halfLoopLarge, TrackGroup::diagSlope, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown }, + .extraTrackGroups = {TrackGroup::booster, TrackGroup::slopeCurveSteep}, + }), + .InvertedTrackPaintFunctions = {}, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), + .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), + .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 7, 27 }, + .BoosterSettings = { 0, 68 }, + .LegacyBoosterSettings = { 0, 68 }, + .Naming = { STR_RIDE_NAME_CLASSIC_WOODEN_ROLLER_COASTER, STR_RIDE_DESCRIPTION_CLASSIC_WOODEN_ROLLER_COASTER }, + .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, + .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), + .Heights = { 24, 24, 8, 11, }, + .MaxMass = 19, + .LiftData = { Audio::SoundId::liftWood, 3, 5 }, + .RatingsMultipliers = { 52, 33, 4 }, + .UpkeepCosts = { 40, 20, 80, 10, 3, 10 }, + .BuildCosts = {37.50_GBP, 3.50_GBP, 50, }, + .DefaultPrices = { 20, 20 }, + .DefaultMusic = kMusicObjectWildWest, + .PhotoItem = ShopItem::photo3, + .BonusValue = 105, + .ColourPresets = TRACK_COLOUR_PRESETS( + { Drawing::Colour::saturatedBrown, Drawing::Colour::saturatedBrown, Drawing::Colour::saturatedBrown}, + { Drawing::Colour::white, Drawing::Colour::lightBrown, Drawing::Colour::white }, + { Drawing::Colour::lightBrown, Drawing::Colour::black, Drawing::Colour::lightBrown }, + ), + .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_CLASSIC_WOODEN_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_CLASSIC_WOODEN_ROLLER_COASTER_SUPPORTS }, + .ColourKey = RideColourKey::Ride, + .Name = "classic_wooden_rc", + .RatingsData = { - { RatingsModifierType::BonusLength, 6000, 873, 0, 0 }, - { RatingsModifierType::BonusSynchronisation, 0, RideRating::make(0, 40), RideRating::make(0, 05), 0 }, - { RatingsModifierType::BonusTrainLength, 0, 187245, 0, 0 }, - { RatingsModifierType::BonusMaxSpeed, 0, 44281, 88562, 35424 }, - { RatingsModifierType::BonusAverageSpeed, 0, 364088, 655360, 0 }, - { RatingsModifierType::BonusDuration, 150, 26214, 0, 0 }, - { RatingsModifierType::BonusGForces, 0, 40960, 34555, 49648 }, - { RatingsModifierType::BonusTurns, 0, 26749, 43458, 45749 }, - { RatingsModifierType::BonusDrops, 0, 40777, 46811, 49152 }, - { RatingsModifierType::BonusSheltered, 0, 16705, 30583, 35108 }, - { RatingsModifierType::BonusReversedTrains, 0, 2, 12, 22 }, - { RatingsModifierType::BonusProximity, 0, 22367, 0, 0 }, - { RatingsModifierType::BonusScenery, 0, 11155, 0, 0 }, - { RatingsModifierType::RequirementDropHeight, 12, 2, 1, 2 }, - { RatingsModifierType::RequirementMaxSpeed, 0xA0000, 2, 1, 2 }, - { RatingsModifierType::RequirementNegativeGs, MakeFixed16_2dp(0, 10), 2, 1, 2 }, - { RatingsModifierType::RequirementLength, 0x1720000, 2, 1, 2 }, - { RatingsModifierType::RequirementNumDrops, 2, 2, 1, 2 }, - { RatingsModifierType::PenaltyLateralGs, 0, 40960, 34555, 49648 }, + RatingsCalculationType::Normal, + { RideRating::make(2, 80), RideRating::make(2, 60), RideRating::make(2, 00) }, + 19, + kDynamicRideShelterRating, + false, + { + { RatingsModifierType::BonusLength, 6000, 873, 0, 0 }, + { RatingsModifierType::BonusSynchronisation, 0, RideRating::make(0, 40), RideRating::make(0, 05), 0 }, + { RatingsModifierType::BonusTrainLength, 0, 187245, 0, 0 }, + { RatingsModifierType::BonusMaxSpeed, 0, 44281, 88562, 35424 }, + { RatingsModifierType::BonusAverageSpeed, 0, 364088, 655360, 0 }, + { RatingsModifierType::BonusDuration, 150, 26214, 0, 0 }, + { RatingsModifierType::BonusGForces, 0, 40960, 34555, 49648 }, + { RatingsModifierType::BonusTurns, 0, 26749, 43458, 45749 }, + { RatingsModifierType::BonusDrops, 0, 40777, 46811, 49152 }, + { RatingsModifierType::BonusSheltered, 0, 16705, 30583, 35108 }, + { RatingsModifierType::BonusReversedTrains, 0, 2, 12, 22 }, + { RatingsModifierType::BonusProximity, 0, 22367, 0, 0 }, + { RatingsModifierType::BonusScenery, 0, 11155, 0, 0 }, + { RatingsModifierType::RequirementDropHeight, 12, 2, 1, 2 }, + { RatingsModifierType::RequirementMaxSpeed, 0xA0000, 2, 1, 2 }, + { RatingsModifierType::RequirementNegativeGs, MakeFixed16_2dp(0, 10), 2, 1, 2 }, + { RatingsModifierType::RequirementLength, 0x1720000, 2, 1, 2 }, + { RatingsModifierType::RequirementNumDrops, 2, 2, 1, 2 }, + { RatingsModifierType::PenaltyLateralGs, 0, 40960, 34555, 49648 }, }, }, }; diff --git a/src/openrct2/ride/rtd/coaster/ClassicWoodenTwisterRollerCoaster.h b/src/openrct2/ride/rtd/coaster/ClassicWoodenTwisterRollerCoaster.h index 3cee2a7259..2e84e98bfc 100644 --- a/src/openrct2/ride/rtd/coaster/ClassicWoodenTwisterRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/ClassicWoodenTwisterRollerCoaster.h @@ -19,73 +19,74 @@ namespace OpenRCT2 { constexpr RideTypeDescriptor ClassicWoodenTwisterRollerCoasterRTD = { - .Category = RideCategory::rollerCoaster, - .StartTrackPiece = TrackElemType::endStation, - .TrackPaintFunctions = TrackDrawerDescriptor({ - .trackStyle = TrackStyle::classicWoodenTwisterRollerCoaster, - .supportType = WoodenSupportType::truss, - .enabledTrackGroups = { TrackGroup::flat, TrackGroup::straight, TrackGroup::stationEnd, TrackGroup::liftHill, TrackGroup::flatRollBanking, TrackGroup::slope, TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::slopeCurve, TrackGroup::sBend, TrackGroup::curveSmall, TrackGroup::curve, TrackGroup::curveLarge, TrackGroup::brakes, TrackGroup::onridePhoto, TrackGroup::blockBrakes, TrackGroup::diagBrakes, TrackGroup::diagBlockBrakes, TrackGroup::slopeSteepLong, TrackGroup::helixDownBankedHalf, TrackGroup::helixUpBankedHalf, TrackGroup::slopeCurveSteep, TrackGroup::slopeCurveBanked, TrackGroup::diagSlope, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown }, - .extraTrackGroups = { TrackGroup::verticalLoop, TrackGroup::waterSplash, TrackGroup::booster, TrackGroup::halfLoopMedium, TrackGroup::halfLoopLarge }, - }), - .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, - RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), - .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), - .DefaultMode = RideMode::continuousCircuit, - .BoosterSettings = { 0, 68 }, - .LegacyBoosterSettings = { 0, 68 }, - .Naming = { STR_RIDE_NAME_CLASSIC_WOODEN_TWISTER_ROLLER_COASTER, STR_RIDE_DESCRIPTION_CLASSIC_WOODEN_TWISTER_ROLLER_COASTER }, - .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, - .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), - .Heights = { 24, 24, 8, 11, }, - .MaxMass = 19, - .LiftData = { Audio::SoundId::liftWood, 3, 5 }, - .RatingsMultipliers = { 52, 33, 4 }, - .UpkeepCosts = { 40, 20, 80, 10, 3, 10 }, - .BuildCosts = {37.50_GBP, 3.50_GBP, 50, }, - .DefaultPrices = { 20, 20 }, - .DefaultMusic = kMusicObjectWildWest, - .PhotoItem = ShopItem::photo3, - .BonusValue = 105, - .ColourPresets = TRACK_COLOUR_PRESETS( - { Drawing::Colour::bordeauxRed, Drawing::Colour::black, Drawing::Colour::white }, - { Drawing::Colour::brightRed, Drawing::Colour::black, Drawing::Colour::grey }, - { Drawing::Colour::yellow, Drawing::Colour::darkBrown, Drawing::Colour::darkBrown }, - { Drawing::Colour::darkWater, Drawing::Colour::bordeauxRed, Drawing::Colour::white }, - { Drawing::Colour::lightBlue, Drawing::Colour::black, Drawing::Colour::black }, - ), - .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_WOODEN_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_WOODEN_ROLLER_COASTER_SUPPORTS }, - .ColourKey = RideColourKey::Ride, - .Name = "classic_wooden_twister_rc", - .RatingsData = - { - RatingsCalculationType::Normal, - { RideRating::make(3, 20), RideRating::make(2, 60), RideRating::make(2, 00) }, - 19, - kDynamicRideShelterRating, - false, + .Category = RideCategory::rollerCoaster, + .StartTrackPiece = TrackElemType::endStation, + .TrackPaintFunctions = TrackDrawerDescriptor({ + .trackStyle = TrackStyle::classicWoodenTwisterRollerCoaster, + .supportType = WoodenSupportType::truss, + .enabledTrackGroups = { TrackGroup::flat, TrackGroup::straight, TrackGroup::stationEnd, TrackGroup::liftHill, TrackGroup::flatRollBanking, TrackGroup::slope, TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::slopeCurve, TrackGroup::sBend, TrackGroup::curveSmall, TrackGroup::curve, TrackGroup::curveLarge, TrackGroup::brakes, TrackGroup::onridePhoto, TrackGroup::blockBrakes, TrackGroup::diagBrakes, TrackGroup::diagBlockBrakes, TrackGroup::slopeSteepLong, TrackGroup::helixDownBankedHalf, TrackGroup::helixUpBankedHalf, TrackGroup::slopeCurveSteep, TrackGroup::slopeCurveBanked, TrackGroup::diagSlope, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown }, + .extraTrackGroups = { TrackGroup::verticalLoop, TrackGroup::waterSplash, TrackGroup::booster, TrackGroup::halfLoopMedium, TrackGroup::halfLoopLarge }, + }), + .InvertedTrackPaintFunctions = {}, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), + .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), + .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 7, 27 }, + .BoosterSettings = { 0, 68 }, + .LegacyBoosterSettings = { 0, 68 }, + .Naming = { STR_RIDE_NAME_CLASSIC_WOODEN_TWISTER_ROLLER_COASTER, STR_RIDE_DESCRIPTION_CLASSIC_WOODEN_TWISTER_ROLLER_COASTER }, + .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, + .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), + .Heights = { 24, 24, 8, 11, }, + .MaxMass = 19, + .LiftData = { Audio::SoundId::liftWood, 3, 5 }, + .RatingsMultipliers = { 52, 33, 4 }, + .UpkeepCosts = { 40, 20, 80, 10, 3, 10 }, + .BuildCosts = {37.50_GBP, 3.50_GBP, 50, }, + .DefaultPrices = { 20, 20 }, + .DefaultMusic = kMusicObjectWildWest, + .PhotoItem = ShopItem::photo3, + .BonusValue = 105, + .ColourPresets = TRACK_COLOUR_PRESETS( + { Drawing::Colour::bordeauxRed, Drawing::Colour::black, Drawing::Colour::white }, + { Drawing::Colour::brightRed, Drawing::Colour::black, Drawing::Colour::grey }, + { Drawing::Colour::yellow, Drawing::Colour::darkBrown, Drawing::Colour::darkBrown }, + { Drawing::Colour::darkWater, Drawing::Colour::bordeauxRed, Drawing::Colour::white }, + { Drawing::Colour::lightBlue, Drawing::Colour::black, Drawing::Colour::black }, + ), + .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_WOODEN_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_WOODEN_ROLLER_COASTER_SUPPORTS }, + .ColourKey = RideColourKey::Ride, + .Name = "classic_wooden_twister_rc", + .RatingsData = { - { RatingsModifierType::BonusLength, 6000, 873, 0, 0 }, - { RatingsModifierType::BonusSynchronisation, 0, RideRating::make(0, 40), RideRating::make(0, 05), 0 }, - { RatingsModifierType::BonusTrainLength, 0, 187245, 0, 0 }, - { RatingsModifierType::BonusMaxSpeed, 0, 44281, 88562, 35424 }, - { RatingsModifierType::BonusAverageSpeed, 0, 364088, 655360, 0 }, - { RatingsModifierType::BonusDuration, 150, 26214, 0, 0 }, - { RatingsModifierType::BonusGForces, 0, 40960, 34555, 49648 }, - { RatingsModifierType::BonusTurns, 0, 26749, 43458, 45749 }, - { RatingsModifierType::BonusDrops, 0, 40777, 46811, 49152 }, - { RatingsModifierType::BonusSheltered, 0, 16705, 30583, 35108 }, - { RatingsModifierType::BonusReversedTrains, 0, 2, 12, 22 }, - { RatingsModifierType::BonusProximity, 0, 22367, 0, 0 }, - { RatingsModifierType::BonusScenery, 0, 11155, 0, 0 }, - { RatingsModifierType::RequirementDropHeight, 12, 2, 2, 2 }, - { RatingsModifierType::RequirementMaxSpeed, 0xA0000, 2, 2, 2 }, - { RatingsModifierType::RequirementNegativeGs, MakeFixed16_2dp(0, 10), 2, 2, 2 }, - { RatingsModifierType::RequirementLength, 0x1720000, 2, 2, 2 }, - { RatingsModifierType::RequirementNumDrops, 2, 2, 2, 2 }, - { RatingsModifierType::PenaltyLateralGs, 0, 40960, 34555, 49648 }, - }, + RatingsCalculationType::Normal, + { RideRating::make(3, 20), RideRating::make(2, 60), RideRating::make(2, 00) }, + 19, + kDynamicRideShelterRating, + false, + { + { RatingsModifierType::BonusLength, 6000, 873, 0, 0 }, + { RatingsModifierType::BonusSynchronisation, 0, RideRating::make(0, 40), RideRating::make(0, 05), 0 }, + { RatingsModifierType::BonusTrainLength, 0, 187245, 0, 0 }, + { RatingsModifierType::BonusMaxSpeed, 0, 44281, 88562, 35424 }, + { RatingsModifierType::BonusAverageSpeed, 0, 364088, 655360, 0 }, + { RatingsModifierType::BonusDuration, 150, 26214, 0, 0 }, + { RatingsModifierType::BonusGForces, 0, 40960, 34555, 49648 }, + { RatingsModifierType::BonusTurns, 0, 26749, 43458, 45749 }, + { RatingsModifierType::BonusDrops, 0, 40777, 46811, 49152 }, + { RatingsModifierType::BonusSheltered, 0, 16705, 30583, 35108 }, + { RatingsModifierType::BonusReversedTrains, 0, 2, 12, 22 }, + { RatingsModifierType::BonusProximity, 0, 22367, 0, 0 }, + { RatingsModifierType::BonusScenery, 0, 11155, 0, 0 }, + { RatingsModifierType::RequirementDropHeight, 12, 2, 2, 2 }, + { RatingsModifierType::RequirementMaxSpeed, 0xA0000, 2, 2, 2 }, + { RatingsModifierType::RequirementNegativeGs, MakeFixed16_2dp(0, 10), 2, 2, 2 }, + { RatingsModifierType::RequirementLength, 0x1720000, 2, 2, 2 }, + { RatingsModifierType::RequirementNumDrops, 2, 2, 2, 2 }, + { RatingsModifierType::PenaltyLateralGs, 0, 40960, 34555, 49648 }, + }, }, }; } // namespace OpenRCT2 diff --git a/src/openrct2/ride/rtd/coaster/CompactInvertedCoaster.h b/src/openrct2/ride/rtd/coaster/CompactInvertedCoaster.h index cc82b3dcff..44701573fa 100644 --- a/src/openrct2/ride/rtd/coaster/CompactInvertedCoaster.h +++ b/src/openrct2/ride/rtd/coaster/CompactInvertedCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor CompactInvertedCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::isSuspended, RtdFlag::reverseInclineLaunchAffectsReliability), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::reverseInclineLaunchedShuttle), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/CorkscrewRollerCoaster.h b/src/openrct2/ride/rtd/coaster/CorkscrewRollerCoaster.h index 4754309074..c757916758 100644 --- a/src/openrct2/ride/rtd/coaster/CorkscrewRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/CorkscrewRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor CorkscrewRollerCoasterRTD = .extraTrackGroups = {TrackGroup::twist, TrackGroup::slopeVertical, TrackGroup::curveVertical, TrackGroup::quarterLoop, TrackGroup::barrelRoll, TrackGroup::zeroGRoll, TrackGroup::zeroGRollLarge, TrackGroup::diveLoop}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch, RideMode::reverseInclineLaunchedShuttle), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/FlyingRollerCoaster.h b/src/openrct2/ride/rtd/coaster/FlyingRollerCoaster.h index 2b22a4f8fa..815b4da96f 100644 --- a/src/openrct2/ride/rtd/coaster/FlyingRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/FlyingRollerCoaster.h @@ -34,8 +34,8 @@ constexpr RideTypeDescriptor FlyingRollerCoasterRTD = .enabledTrackGroups = { TrackGroup::straight, TrackGroup::stationEnd, TrackGroup::liftHill, TrackGroup::flatRollBanking, TrackGroup::slope, TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::slopeCurve, TrackGroup::slopeCurveSteep, TrackGroup::sBend, TrackGroup::curveSmall, TrackGroup::curve, TrackGroup::curveLarge, TrackGroup::helixDownBankedQuarter, TrackGroup::helixUpBankedQuarter, TrackGroup::brakes, TrackGroup::onridePhoto, TrackGroup::blockBrakes, TrackGroup::slopeRollBanking, TrackGroup::inlineTwistInverted, TrackGroup::flyingHalfLoopInvertedDown, TrackGroup::quarterLoopInvertedDown, TrackGroup::flyingLargeHalfLoopInvertedDown, TrackGroup::booster, TrackGroup::diagBrakes, TrackGroup::diagBlockBrakes, TrackGroup::diagSlope, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown }, .extraTrackGroups = {TrackGroup::flyingLargeHalfLoopInvertedUp, TrackGroup::flyingHalfLoopInvertedUp}, }), - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasInvertedVariant, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasInvertedVariant, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::startConstructionInverted), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, @@ -110,8 +110,8 @@ constexpr RideTypeDescriptor FlyingRollerCoasterAltRTD = .enabledTrackGroups = { }, .extraTrackGroups = { }, }), - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::startConstructionInverted), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::startConstructionInverted, RtdFlag::isDummyType), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, .OperatingSettings = { 10, 27 }, diff --git a/src/openrct2/ride/rtd/coaster/GigaCoaster.h b/src/openrct2/ride/rtd/coaster/GigaCoaster.h index efffe1503f..85ad90925f 100644 --- a/src/openrct2/ride/rtd/coaster/GigaCoaster.h +++ b/src/openrct2/ride/rtd/coaster/GigaCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor GigaCoasterRTD = .extraTrackGroups = {TrackGroup::barrelRoll, TrackGroup::quarterLoop, TrackGroup::halfLoop, TrackGroup::halfLoopMedium, TrackGroup::halfLoopLarge, TrackGroup::verticalLoop, TrackGroup::corkscrew, TrackGroup::corkscrewLarge, TrackGroup::zeroGRoll, TrackGroup::zeroGRollLarge, TrackGroup::booster, TrackGroup::diagBooster, TrackGroup::diveLoop, TrackGroup::poweredLift}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowCableLiftHill, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/HeartlineTwisterCoaster.h b/src/openrct2/ride/rtd/coaster/HeartlineTwisterCoaster.h index 262230dab7..b9b505f3f8 100644 --- a/src/openrct2/ride/rtd/coaster/HeartlineTwisterCoaster.h +++ b/src/openrct2/ride/rtd/coaster/HeartlineTwisterCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor HeartlineTwisterCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/HybridCoaster.h b/src/openrct2/ride/rtd/coaster/HybridCoaster.h index 41b853cd8b..66a5362e5c 100644 --- a/src/openrct2/ride/rtd/coaster/HybridCoaster.h +++ b/src/openrct2/ride/rtd/coaster/HybridCoaster.h @@ -27,12 +27,13 @@ constexpr RideTypeDescriptor HybridCoasterRTD = .extraTrackGroups = {TrackGroup::booster}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, - RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, + RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 10, 27 }, .BoosterSettings = { 15, 52 }, .LegacyBoosterSettings = { 15, 52 }, .Naming = { STR_RIDE_NAME_HYBRID_COASTER, STR_RIDE_DESCRIPTION_HYBRID_COASTER }, @@ -61,7 +62,7 @@ constexpr RideTypeDescriptor HybridCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_HYBRID_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_HYBRID_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "hybrid_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(3, 80), RideRating::make(1, 00), RideRating::make(0, 45) }, diff --git a/src/openrct2/ride/rtd/coaster/HyperTwister.h b/src/openrct2/ride/rtd/coaster/HyperTwister.h index 187df8a956..911cdced70 100644 --- a/src/openrct2/ride/rtd/coaster/HyperTwister.h +++ b/src/openrct2/ride/rtd/coaster/HyperTwister.h @@ -29,8 +29,8 @@ constexpr RideTypeDescriptor HyperTwisterRTD = .extraTrackGroups = { TrackGroup::liftHillSteep, TrackGroup::brakeForDrop, TrackGroup::booster, TrackGroup::poweredLift, TrackGroup::verticalLoop, TrackGroup::halfLoop, TrackGroup::corkscrew, TrackGroup::barrelRoll, TrackGroup::halfLoopLarge, TrackGroup::quarterLoop, TrackGroup::twist, TrackGroup::corkscrewLarge, TrackGroup::halfLoopMedium, TrackGroup::zeroGRoll, TrackGroup::zeroGRollLarge, TrackGroup::diveLoop }, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/Hypercoaster.h b/src/openrct2/ride/rtd/coaster/Hypercoaster.h index 7ef91297dc..3d5d8da551 100644 --- a/src/openrct2/ride/rtd/coaster/Hypercoaster.h +++ b/src/openrct2/ride/rtd/coaster/Hypercoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor HypercoasterRTD = .extraTrackGroups = { TrackGroup::verticalLoop, TrackGroup::halfLoop, TrackGroup::corkscrew, TrackGroup::booster, TrackGroup::corkscrewLarge, TrackGroup::halfLoopMedium, TrackGroup::halfLoopLarge, TrackGroup::twist, TrackGroup::slopeVertical, TrackGroup::curveVertical, TrackGroup::quarterLoop, TrackGroup::barrelRoll, TrackGroup::zeroGRoll, TrackGroup::zeroGRollLarge, TrackGroup::diveLoop }, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch, RideMode::reverseInclineLaunchedShuttle), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/InvertedHairpinCoaster.h b/src/openrct2/ride/rtd/coaster/InvertedHairpinCoaster.h index 4285677a74..a1ba3ad677 100644 --- a/src/openrct2/ride/rtd/coaster/InvertedHairpinCoaster.h +++ b/src/openrct2/ride/rtd/coaster/InvertedHairpinCoaster.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor InvertedHairpinCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::isSuspended), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_INVERTED_HAIRPIN_COASTER, STR_RIDE_DESCRIPTION_INVERTED_HAIRPIN_COASTER }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -54,7 +55,7 @@ constexpr RideTypeDescriptor InvertedHairpinCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_INVERTED_HAIRPIN_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_INVERTED_HAIRPIN_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "inverted_hairpin_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(3, 00), RideRating::make(2, 65), RideRating::make(2, 25) }, diff --git a/src/openrct2/ride/rtd/coaster/InvertedImpulseCoaster.h b/src/openrct2/ride/rtd/coaster/InvertedImpulseCoaster.h index de25a3ea3a..19a447799d 100644 --- a/src/openrct2/ride/rtd/coaster/InvertedImpulseCoaster.h +++ b/src/openrct2/ride/rtd/coaster/InvertedImpulseCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor InvertedImpulseCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::isSuspended, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch), .DefaultMode = RideMode::poweredLaunchPasstrough, diff --git a/src/openrct2/ride/rtd/coaster/InvertedRollerCoaster.h b/src/openrct2/ride/rtd/coaster/InvertedRollerCoaster.h index b1a98f5375..67a3888af6 100644 --- a/src/openrct2/ride/rtd/coaster/InvertedRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/InvertedRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor InvertedRollerCoasterRTD = .extraTrackGroups = {TrackGroup::booster}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::isSuspended, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/JuniorRollerCoaster.h b/src/openrct2/ride/rtd/coaster/JuniorRollerCoaster.h index 8429d4c280..9a9d17132d 100644 --- a/src/openrct2/ride/rtd/coaster/JuniorRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/JuniorRollerCoaster.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor JuniorRollerCoasterRTD = .extraTrackGroups = { TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::onridePhoto, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown }, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::allowDoorsOnTrack, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::allowDoorsOnTrack, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .TrackSpeedSettings = { 30, 15 }, .BoosterSettings = { 17, 16 }, .LegacyBoosterSettings = { 17, 16, 1 }, @@ -59,7 +60,7 @@ constexpr RideTypeDescriptor JuniorRollerCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_JUNIOR_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_JUNIOR_ROLLER_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "junior_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 40), RideRating::make(2, 50), RideRating::make(1, 80) }, diff --git a/src/openrct2/ride/rtd/coaster/LIMLaunchedRollerCoaster.h b/src/openrct2/ride/rtd/coaster/LIMLaunchedRollerCoaster.h index fba302c215..1d7085089a 100644 --- a/src/openrct2/ride/rtd/coaster/LIMLaunchedRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/LIMLaunchedRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor LIMLaunchedRollerCoasterRTD = .extraTrackGroups = {TrackGroup::flatToSteepSlope}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch, RideMode::poweredLaunchBlockSectioned), .DefaultMode = RideMode::poweredLaunch, diff --git a/src/openrct2/ride/rtd/coaster/LSMLaunchedRollerCoaster.h b/src/openrct2/ride/rtd/coaster/LSMLaunchedRollerCoaster.h index abb1b835ca..c8845f6919 100644 --- a/src/openrct2/ride/rtd/coaster/LSMLaunchedRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/LSMLaunchedRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor LSMLaunchedRollerCoasterRTD = .extraTrackGroups = {TrackGroup::liftHill, TrackGroup::liftHillCable}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowCableLiftHill, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::poweredLaunch, RideMode::poweredLaunchBlockSectioned), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/LayDownRollerCoaster.h b/src/openrct2/ride/rtd/coaster/LayDownRollerCoaster.h index bc0e23a2d1..b5722ff3bc 100644 --- a/src/openrct2/ride/rtd/coaster/LayDownRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/LayDownRollerCoaster.h @@ -37,8 +37,8 @@ constexpr RideTypeDescriptor LayDownRollerCoasterRTD = .extraTrackGroups = { TrackGroup::flyingHalfLoopInvertedUp, TrackGroup::stationEnd, TrackGroup::liftHill }, } ), - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasInvertedVariant, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasInvertedVariant, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, @@ -109,8 +109,8 @@ constexpr RideTypeDescriptor LayDownRollerCoasterAltRTD = .enabledTrackGroups = { }, .extraTrackGroups = { }, }), - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::isDummyType), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, .OperatingSettings = { 10, 27 }, diff --git a/src/openrct2/ride/rtd/coaster/LoopingRollerCoaster.h b/src/openrct2/ride/rtd/coaster/LoopingRollerCoaster.h index f70d5dd166..1495f88714 100644 --- a/src/openrct2/ride/rtd/coaster/LoopingRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/LoopingRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor LoopingRollerCoasterRTD = .extraTrackGroups = {TrackGroup::slopeVertical, TrackGroup::twist, TrackGroup::corkscrew, TrackGroup::curveVertical, TrackGroup::quarterLoop, TrackGroup::flatToSteepSlope, TrackGroup::barrelRoll, TrackGroup::halfLoop, TrackGroup::halfLoopMedium, TrackGroup::halfLoopLarge,TrackGroup::corkscrewLarge, TrackGroup::zeroGRoll, TrackGroup::zeroGRollLarge}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains, RtdFlag::poweredLaunchAffectsReliability), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::reverseInclineLaunchedShuttle, RideMode::poweredLaunchPasstrough, RideMode::poweredLaunch), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/MineRide.h b/src/openrct2/ride/rtd/coaster/MineRide.h index 8393a9306b..1b3c99bfbe 100644 --- a/src/openrct2/ride/rtd/coaster/MineRide.h +++ b/src/openrct2/ride/rtd/coaster/MineRide.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor MineRideRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 7, 27 }, .Naming = { STR_RIDE_NAME_MINE_RIDE, STR_RIDE_DESCRIPTION_MINE_RIDE }, .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -53,7 +54,7 @@ constexpr RideTypeDescriptor MineRideRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MINE_RIDE_TRACK, SPR_RIDE_DESIGN_PREVIEW_MINE_RIDE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "mine_ride", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 75), RideRating::make(1, 00), RideRating::make(1, 80) }, diff --git a/src/openrct2/ride/rtd/coaster/MineTrainCoaster.h b/src/openrct2/ride/rtd/coaster/MineTrainCoaster.h index 1387fe5356..4bae44a8c8 100644 --- a/src/openrct2/ride/rtd/coaster/MineTrainCoaster.h +++ b/src/openrct2/ride/rtd/coaster/MineTrainCoaster.h @@ -29,11 +29,12 @@ constexpr RideTypeDescriptor MineTrainCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 7, 27 }, .Naming = { STR_RIDE_NAME_MINE_TRAIN_COASTER, STR_RIDE_DESCRIPTION_MINE_TRAIN_COASTER }, .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -54,7 +55,7 @@ constexpr RideTypeDescriptor MineTrainCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MINE_TRAIN_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_MINE_TRAIN_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "mine_train_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 90), RideRating::make(2, 30), RideRating::make(2, 10) }, diff --git a/src/openrct2/ride/rtd/coaster/MiniRollerCoaster.h b/src/openrct2/ride/rtd/coaster/MiniRollerCoaster.h index 9a7b11b403..8325581c21 100644 --- a/src/openrct2/ride/rtd/coaster/MiniRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/MiniRollerCoaster.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor MiniRollerCoasterRTD = .extraTrackGroups = {TrackGroup::booster, TrackGroup::liftHillCurved}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .BoosterSettings = { 0, 68 }, .LegacyBoosterSettings = { 0, 68, 4 }, .Naming = { STR_RIDE_NAME_MINI_ROLLER_COASTER, STR_RIDE_DESCRIPTION_MINI_ROLLER_COASTER }, @@ -56,7 +57,7 @@ constexpr RideTypeDescriptor MiniRollerCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MINI_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_MINI_ROLLER_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "mini_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 55), RideRating::make(2, 40), RideRating::make(1, 85) }, diff --git a/src/openrct2/ride/rtd/coaster/MiniSuspendedCoaster.h b/src/openrct2/ride/rtd/coaster/MiniSuspendedCoaster.h index 80c7ad1042..835176c1c9 100644 --- a/src/openrct2/ride/rtd/coaster/MiniSuspendedCoaster.h +++ b/src/openrct2/ride/rtd/coaster/MiniSuspendedCoaster.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor MiniSuspendedCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, + .flags = kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::isSuspended), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_MINI_SUSPENDED_COASTER, STR_RIDE_DESCRIPTION_MINI_SUSPENDED_COASTER }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -53,7 +54,7 @@ constexpr RideTypeDescriptor MiniSuspendedCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MINI_SUSPENDED_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_MINI_SUSPENDED_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "mini_suspended_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 80), RideRating::make(2, 50), RideRating::make(2, 70) }, diff --git a/src/openrct2/ride/rtd/coaster/MultiDimensionRollerCoaster.h b/src/openrct2/ride/rtd/coaster/MultiDimensionRollerCoaster.h index 75df694ac5..9bac3c5f90 100644 --- a/src/openrct2/ride/rtd/coaster/MultiDimensionRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/MultiDimensionRollerCoaster.h @@ -33,8 +33,8 @@ constexpr RideTypeDescriptor MultiDimensionRollerCoasterRTD = .enabledTrackGroups = {TrackGroup::straight, TrackGroup::flatRollBanking, TrackGroup::slope, TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::sBend, TrackGroup::curveSmall, TrackGroup::curve, TrackGroup::curveLarge, TrackGroup::brakes, TrackGroup::onridePhoto, TrackGroup::slopeVertical, TrackGroup::blockBrakes, TrackGroup::inlineTwistInverted, TrackGroup::quarterLoopInvertedUp, TrackGroup::quarterLoopInvertedDown, TrackGroup::diagBrakes, TrackGroup::diagBlockBrakes, TrackGroup::diagSlope, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown}, .extraTrackGroups = {}, }), - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasInvertedVariant, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasInvertedVariant, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::hasSeatRotation, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), @@ -109,8 +109,8 @@ constexpr RideTypeDescriptor MultiDimensionRollerCoasterAltRTD = .enabledTrackGroups = { }, .extraTrackGroups = { }, }), - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasSeatRotation), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasSeatRotation, RtdFlag::isDummyType), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, .OperatingSettings = { 10, 27 }, diff --git a/src/openrct2/ride/rtd/coaster/ReverseFreefallCoaster.h b/src/openrct2/ride/rtd/coaster/ReverseFreefallCoaster.h index d891f96325..6e4105ba95 100644 --- a/src/openrct2/ride/rtd/coaster/ReverseFreefallCoaster.h +++ b/src/openrct2/ride/rtd/coaster/ReverseFreefallCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor ReverseFreefallCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt - | EnumsToFlags(RtdFlag::allowReversedTrains, RtdFlag::hasLsmBehaviourOnFlat), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt + | RtdFlags(RtdFlag::allowReversedTrains, RtdFlag::hasLsmBehaviourOnFlat), .RideModes = EnumsToFlags(RideMode::limPoweredLaunch), .DefaultMode = RideMode::limPoweredLaunch, .OperatingSettings = { 7, 30 }, diff --git a/src/openrct2/ride/rtd/coaster/ReverserRollerCoaster.h b/src/openrct2/ride/rtd/coaster/ReverserRollerCoaster.h index fa54cd637a..d7ca3c56d5 100644 --- a/src/openrct2/ride/rtd/coaster/ReverserRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/ReverserRollerCoaster.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor ReverserRollerCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::layeredVehiclePreview), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_REVERSER_ROLLER_COASTER, STR_RIDE_DESCRIPTION_REVERSER_ROLLER_COASTER }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -53,7 +54,7 @@ constexpr RideTypeDescriptor ReverserRollerCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_REVERSER_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_REVERSER_ROLLER_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "reverser_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 40), RideRating::make(1, 80), RideRating::make(1, 70) }, diff --git a/src/openrct2/ride/rtd/coaster/SideFrictionRollerCoaster.h b/src/openrct2/ride/rtd/coaster/SideFrictionRollerCoaster.h index e1c84ea813..b89ee2bdbc 100644 --- a/src/openrct2/ride/rtd/coaster/SideFrictionRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/SideFrictionRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor SideFrictionRollerCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/SingleRailRollerCoaster.h b/src/openrct2/ride/rtd/coaster/SingleRailRollerCoaster.h index 60367cfece..6b18fbdb33 100644 --- a/src/openrct2/ride/rtd/coaster/SingleRailRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/SingleRailRollerCoaster.h @@ -27,11 +27,12 @@ constexpr RideTypeDescriptor SingleRailRollerCoasterRTD = .extraTrackGroups = {TrackGroup::slopeSteepLong, TrackGroup::diagSlopeSteepLong}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt| - EnumsToFlags(RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt| + RtdFlags(RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 7, 27 }, .BoosterSettings = { 15, 52 }, .LegacyBoosterSettings = { 15, 52 }, .Naming = { STR_RIDE_NAME_SINGLE_RAIL_ROLLER_COASTER, STR_RIDE_DESCRIPTION_SINGLE_RAIL_ROLLER_COASTER }, @@ -55,7 +56,7 @@ constexpr RideTypeDescriptor SingleRailRollerCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_SINGLE_RAIL_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_SINGLE_RAIL_ROLLER_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "single_rail_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(3, 50), RideRating::make(0, 60), RideRating::make(0, 40) }, diff --git a/src/openrct2/ride/rtd/coaster/SpinningWildMouse.h b/src/openrct2/ride/rtd/coaster/SpinningWildMouse.h index 5c136120f6..992247118c 100644 --- a/src/openrct2/ride/rtd/coaster/SpinningWildMouse.h +++ b/src/openrct2/ride/rtd/coaster/SpinningWildMouse.h @@ -28,10 +28,11 @@ constexpr RideTypeDescriptor SpinningWildMouseRTD = .extraTrackGroups = {TrackGroup::liftHillSteep, TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::slopeCurve}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_SPINNING_WILD_MOUSE, STR_RIDE_DESCRIPTION_SPINNING_WILD_MOUSE }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -54,7 +55,7 @@ constexpr RideTypeDescriptor SpinningWildMouseRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_WILD_MOUSE_TRACK, SPR_RIDE_DESIGN_PREVIEW_WILD_MOUSE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "spinning_wild_mouse", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 80), RideRating::make(2, 50), RideRating::make(2, 10) }, diff --git a/src/openrct2/ride/rtd/coaster/SpiralRollerCoaster.h b/src/openrct2/ride/rtd/coaster/SpiralRollerCoaster.h index a36b985216..ba4a871ecb 100644 --- a/src/openrct2/ride/rtd/coaster/SpiralRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/SpiralRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor SpiralRollerCoasterRTD = .extraTrackGroups = {TrackGroup::booster, TrackGroup::liftHill}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/StandUpRollerCoaster.h b/src/openrct2/ride/rtd/coaster/StandUpRollerCoaster.h index 69d68d0bca..4a64ba0dee 100644 --- a/src/openrct2/ride/rtd/coaster/StandUpRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/StandUpRollerCoaster.h @@ -28,8 +28,8 @@ constexpr RideTypeDescriptor StandUpRollerCoasterRTD = .extraTrackGroups = {TrackGroup::slopeVertical, TrackGroup::slopeCurveSteep, TrackGroup::curveVertical, TrackGroup::quarterLoop, TrackGroup::barrelRoll, TrackGroup::zeroGRoll, TrackGroup::zeroGRollLarge}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/SteelWildMouse.h b/src/openrct2/ride/rtd/coaster/SteelWildMouse.h index b11acaf6c2..e6e3183e09 100644 --- a/src/openrct2/ride/rtd/coaster/SteelWildMouse.h +++ b/src/openrct2/ride/rtd/coaster/SteelWildMouse.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor SteelWildMouseRTD = .extraTrackGroups = {TrackGroup::rotationControlToggle}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::allowDoorsOnTrack, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::allowDoorsOnTrack, RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_WILD_MOUSE, STR_RIDE_DESCRIPTION_WILD_MOUSE }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -55,7 +56,7 @@ constexpr RideTypeDescriptor SteelWildMouseRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_WILD_MOUSE_TRACK, SPR_RIDE_DESIGN_PREVIEW_WILD_MOUSE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "steel_wild_mouse", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 80), RideRating::make(2, 50), RideRating::make(2, 10) }, diff --git a/src/openrct2/ride/rtd/coaster/Steeplechase.h b/src/openrct2/ride/rtd/coaster/Steeplechase.h index c7f71df5aa..c460db8324 100644 --- a/src/openrct2/ride/rtd/coaster/Steeplechase.h +++ b/src/openrct2/ride/rtd/coaster/Steeplechase.h @@ -28,10 +28,11 @@ constexpr RideTypeDescriptor SteeplechaseRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_STEEPLECHASE, STR_RIDE_DESCRIPTION_STEEPLECHASE }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -57,7 +58,7 @@ constexpr RideTypeDescriptor SteeplechaseRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_STEEPLECHASE_TRACK, SPR_RIDE_DESIGN_PREVIEW_STEEPLECHASE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "steeplechase", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 70), RideRating::make(2, 40), RideRating::make(1, 80) }, diff --git a/src/openrct2/ride/rtd/coaster/SuspendedSwingingCoaster.h b/src/openrct2/ride/rtd/coaster/SuspendedSwingingCoaster.h index 8d16ea9281..6df427d074 100644 --- a/src/openrct2/ride/rtd/coaster/SuspendedSwingingCoaster.h +++ b/src/openrct2/ride/rtd/coaster/SuspendedSwingingCoaster.h @@ -28,10 +28,11 @@ constexpr RideTypeDescriptor SuspendedSwingingCoasterRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::isSuspended), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::isSuspended), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 10, 27 }, .Naming = { STR_RIDE_NAME_SUSPENDED_SWINGING_COASTER, STR_RIDE_DESCRIPTION_SUSPENDED_SWINGING_COASTER }, .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_RESTRAINTS_STUCK_CLOSED) | (1 << BREAKDOWN_RESTRAINTS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -54,7 +55,7 @@ constexpr RideTypeDescriptor SuspendedSwingingCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_SUSPENDED_SWINGING_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_SUSPENDED_SWINGING_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "suspended_swinging_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(3, 30), RideRating::make(2, 90), RideRating::make(3, 50) }, diff --git a/src/openrct2/ride/rtd/coaster/TwisterRollerCoaster.h b/src/openrct2/ride/rtd/coaster/TwisterRollerCoaster.h index c29cf1059e..1c19a3d738 100644 --- a/src/openrct2/ride/rtd/coaster/TwisterRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/TwisterRollerCoaster.h @@ -29,8 +29,8 @@ constexpr RideTypeDescriptor TwisterRollerCoasterRTD = .extraTrackGroups = {TrackGroup::liftHillSteep, TrackGroup::brakeForDrop}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, diff --git a/src/openrct2/ride/rtd/coaster/VerticalDropCoaster.h b/src/openrct2/ride/rtd/coaster/VerticalDropCoaster.h index 93ad3ca52a..105cf0ad08 100644 --- a/src/openrct2/ride/rtd/coaster/VerticalDropCoaster.h +++ b/src/openrct2/ride/rtd/coaster/VerticalDropCoaster.h @@ -29,8 +29,8 @@ constexpr RideTypeDescriptor VerticalDropCoasterRTD = .extraTrackGroups = {TrackGroup::halfLoop, TrackGroup::barrelRoll, TrackGroup::poweredLift, TrackGroup::halfLoopLarge, TrackGroup::quarterLoop, TrackGroup::booster, TrackGroup::twist, TrackGroup::slopeSteepLong, TrackGroup::diagSlopeSteepLong}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, .OperatingSettings = { 10, 27 }, diff --git a/src/openrct2/ride/rtd/coaster/VirginiaReel.h b/src/openrct2/ride/rtd/coaster/VirginiaReel.h index 749f9948e2..d00d758411 100644 --- a/src/openrct2/ride/rtd/coaster/VirginiaReel.h +++ b/src/openrct2/ride/rtd/coaster/VirginiaReel.h @@ -28,10 +28,11 @@ constexpr RideTypeDescriptor VirginiaReelRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_VIRGINIA_REEL, STR_RIDE_DESCRIPTION_VIRGINIA_REEL }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -53,7 +54,7 @@ constexpr RideTypeDescriptor VirginiaReelRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_VIRGINIA_REEL_TRACK, SPR_RIDE_DESIGN_PREVIEW_VIRGINIA_REEL_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "virginia_reel", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 10), RideRating::make(1, 90), RideRating::make(3, 70) }, diff --git a/src/openrct2/ride/rtd/coaster/WaterCoaster.h b/src/openrct2/ride/rtd/coaster/WaterCoaster.h index a5777cfc66..b6f5073ae1 100644 --- a/src/openrct2/ride/rtd/coaster/WaterCoaster.h +++ b/src/openrct2/ride/rtd/coaster/WaterCoaster.h @@ -42,10 +42,11 @@ constexpr RideTypeDescriptor WaterCoasterRTD = } ), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasCoveredPieces, RtdFlag::checkGForces), + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasCoveredPieces, RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .TrackSpeedSettings = { 30, 15 }, .BoosterSettings = { 17, 16 }, .LegacyBoosterSettings = { 17, 16, 1 }, @@ -71,7 +72,7 @@ constexpr RideTypeDescriptor WaterCoasterRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_WATER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_WATER_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "water_coaster", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 70), RideRating::make(2, 80), RideRating::make(2, 10) }, diff --git a/src/openrct2/ride/rtd/coaster/WoodenRollerCoaster.h b/src/openrct2/ride/rtd/coaster/WoodenRollerCoaster.h index 2b6d6f72f0..45cef51cec 100644 --- a/src/openrct2/ride/rtd/coaster/WoodenRollerCoaster.h +++ b/src/openrct2/ride/rtd/coaster/WoodenRollerCoaster.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor WoodenRollerCoasterRTD = .extraTrackGroups = {TrackGroup::booster}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, + .flags = kRtdFlagsHasThreeColours | kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::checkGForces, RtdFlag::allowMultipleCircuits, RtdFlag::allowReversedTrains), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::continuousCircuitBlockSectioned, RideMode::reverseInclineLaunchedShuttle), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 7, 27 }, .BoosterSettings = { 0, 68 }, .LegacyBoosterSettings = { 0, 68 }, .Naming = { STR_RIDE_NAME_WOODEN_ROLLER_COASTER, STR_RIDE_DESCRIPTION_WOODEN_ROLLER_COASTER }, @@ -55,13 +56,13 @@ constexpr RideTypeDescriptor WoodenRollerCoasterRTD = { Drawing::Colour::darkWater, Drawing::Colour::bordeauxRed, Drawing::Colour::white }, { Drawing::Colour::lightBlue, Drawing::Colour::black, Drawing::Colour::black }, { Drawing::Colour::lightBlue, Drawing::Colour::black, Drawing::Colour::darkBrown }, - { Drawing::Colour::tan, Drawing::Colour::sepia, Drawing::Colour::lightBrown }, // Generic GCI + { Drawing::Colour::tan, Drawing::Colour::sepia, Drawing::Colour::lightBrown }, // Generic GCI { Drawing::Colour::sepia, Drawing::Colour::umber, Drawing::Colour::grey }, // The Voyage /* Change supports to "minetrain" if possible in the future. */ ), .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_WOODEN_ROLLER_COASTER_TRACK, SPR_RIDE_DESIGN_PREVIEW_WOODEN_ROLLER_COASTER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "wooden_rc", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(3, 20), RideRating::make(2, 60), RideRating::make(2, 00) }, diff --git a/src/openrct2/ride/rtd/coaster/WoodenWildMouse.h b/src/openrct2/ride/rtd/coaster/WoodenWildMouse.h index 179f412f7c..0d333b9bce 100644 --- a/src/openrct2/ride/rtd/coaster/WoodenWildMouse.h +++ b/src/openrct2/ride/rtd/coaster/WoodenWildMouse.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor WoodenWildMouseRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | - EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, + .flags = kRtdFlagsCommonCoaster | kRtdFlagsCommonCoasterNonAlt | + RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::allowDoorsOnTrack, RtdFlag::checkGForces), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_WOODEN_WILD_MOUSE, STR_RIDE_DESCRIPTION_WOODEN_WILD_MOUSE }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -54,7 +55,7 @@ constexpr RideTypeDescriptor WoodenWildMouseRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_WOODEN_WILD_MOUSE_TRACK, SPR_RIDE_DESIGN_PREVIEW_WOODEN_WILD_MOUSE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "wooden_wild_mouse", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 90), RideRating::make(2, 90), RideRating::make(2, 10) }, diff --git a/src/openrct2/ride/rtd/gentle/CarRide.h b/src/openrct2/ride/rtd/gentle/CarRide.h index 2cb6cd58e2..256cac0b30 100644 --- a/src/openrct2/ride/rtd/gentle/CarRide.h +++ b/src/openrct2/ride/rtd/gentle/CarRide.h @@ -29,14 +29,15 @@ constexpr RideTypeDescriptor CarRideRTD = .extraTrackGroups = {TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::rapids}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::canSynchroniseWithAdjacentStations, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowDoorsOnTrack, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, - RtdFlag::allowMoreVehiclesThanStationFits, RtdFlag::showInTrackDesigner, + RtdFlag::allowMoreVehiclesThanStationFits, RtdFlag::showInTrackDesigner, RtdFlag::slightlyInterestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_CAR_RIDE, STR_RIDE_DESCRIPTION_CAR_RIDE }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -64,7 +65,7 @@ constexpr RideTypeDescriptor CarRideRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_CAR_RIDE_TRACK, SPR_RIDE_DESIGN_PREVIEW_CAR_RIDE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "car_ride", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 00), RideRating::make(0, 50), RideRating::make(0, 00) }, diff --git a/src/openrct2/ride/rtd/gentle/Circus.h b/src/openrct2/ride/rtd/gentle/Circus.h index bf30065a53..7b3329450a 100644 --- a/src/openrct2/ride/rtd/gentle/Circus.h +++ b/src/openrct2/ride/rtd/gentle/Circus.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor CircusRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::describeAsInside, RtdFlag::hasVehicleColours, RtdFlag::hasMusicByDefault, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, @@ -51,7 +51,7 @@ constexpr RideTypeDescriptor CircusRTD = .ColourPreview = { 0, 0 }, .ColourKey = RideColourKey::Ride, .Name = "circus", - .RatingsData = + .RatingsData = { RatingsCalculationType::FlatRide, { RideRating::make(2, 10), RideRating::make(0, 30), RideRating::make(0, 0) }, diff --git a/src/openrct2/ride/rtd/gentle/CrookedHouse.h b/src/openrct2/ride/rtd/gentle/CrookedHouse.h index ab8ce0c8ef..e1b5e73e26 100644 --- a/src/openrct2/ride/rtd/gentle/CrookedHouse.h +++ b/src/openrct2/ride/rtd/gentle/CrookedHouse.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor CrookedHouseRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::describeAsInside, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/gentle/Dodgems.h b/src/openrct2/ride/rtd/gentle/Dodgems.h index 21160e99fc..ba054ca7d1 100644 --- a/src/openrct2/ride/rtd/gentle/Dodgems.h +++ b/src/openrct2/ride/rtd/gentle/Dodgems.h @@ -28,7 +28,7 @@ constexpr RideTypeDescriptor DodgemsRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::hasMusicByDefault, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, diff --git a/src/openrct2/ride/rtd/gentle/FerrisWheel.h b/src/openrct2/ride/rtd/gentle/FerrisWheel.h index 690eb24323..78cffdbd04 100644 --- a/src/openrct2/ride/rtd/gentle/FerrisWheel.h +++ b/src/openrct2/ride/rtd/gentle/FerrisWheel.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor FerrisWheelRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasSinglePieceStation, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/gentle/FlyingSaucers.h b/src/openrct2/ride/rtd/gentle/FlyingSaucers.h index cc8b83d6db..fb69ae067d 100644 --- a/src/openrct2/ride/rtd/gentle/FlyingSaucers.h +++ b/src/openrct2/ride/rtd/gentle/FlyingSaucers.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor FlyingSaucersRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::hasMusicByDefault, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, diff --git a/src/openrct2/ride/rtd/gentle/GhostTrain.h b/src/openrct2/ride/rtd/gentle/GhostTrain.h index 3bab5c0a34..84b5508fcf 100644 --- a/src/openrct2/ride/rtd/gentle/GhostTrain.h +++ b/src/openrct2/ride/rtd/gentle/GhostTrain.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor GhostTrainRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::canSynchroniseWithAdjacentStations, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasGForces, RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowDoorsOnTrack, @@ -38,6 +38,7 @@ constexpr RideTypeDescriptor GhostTrainRTD = RtdFlag::hasLandscapeDoors), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_GHOST_TRAIN, STR_RIDE_DESCRIPTION_GHOST_TRAIN }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -60,7 +61,7 @@ constexpr RideTypeDescriptor GhostTrainRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_GHOST_TRAIN_TRACK, SPR_RIDE_DESIGN_PREVIEW_GHOST_TRAIN_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "ghost_train", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 00), RideRating::make(0, 20), RideRating::make(0, 03) }, diff --git a/src/openrct2/ride/rtd/gentle/HauntedHouse.h b/src/openrct2/ride/rtd/gentle/HauntedHouse.h index e0d129412b..46e26c917d 100644 --- a/src/openrct2/ride/rtd/gentle/HauntedHouse.h +++ b/src/openrct2/ride/rtd/gentle/HauntedHouse.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor HauntedHouseRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::describeAsInside, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/gentle/Maze.h b/src/openrct2/ride/rtd/gentle/Maze.h index f3061ba3bf..372e919f75 100644 --- a/src/openrct2/ride/rtd/gentle/Maze.h +++ b/src/openrct2/ride/rtd/gentle/Maze.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor MazeRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourSupports, RtdFlag::hasSinglePieceStation, RtdFlag::noTestMode, RtdFlag::noVehicles, + .flags = RtdFlags(RtdFlag::hasTrackColourSupports, RtdFlag::hasSinglePieceStation, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::noWallsAroundTrack, RtdFlag::describeAsInside, RtdFlag::hasTrack, RtdFlag::hasEntranceAndExit, RtdFlag::guestsCanUseUmbrella), .RideModes = EnumsToFlags(RideMode::maze), diff --git a/src/openrct2/ride/rtd/gentle/MerryGoRound.h b/src/openrct2/ride/rtd/gentle/MerryGoRound.h index 4a06bfe36e..b448602ed3 100644 --- a/src/openrct2/ride/rtd/gentle/MerryGoRound.h +++ b/src/openrct2/ride/rtd/gentle/MerryGoRound.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor MerryGoRoundRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::hasMusicByDefault, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/gentle/MiniGolf.h b/src/openrct2/ride/rtd/gentle/MiniGolf.h index ce7b9662d8..54f404a574 100644 --- a/src/openrct2/ride/rtd/gentle/MiniGolf.h +++ b/src/openrct2/ride/rtd/gentle/MiniGolf.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor MiniGolfRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::noTestMode, RtdFlag::hasTrack, RtdFlag::hasOneStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::noTestMode, RtdFlag::hasTrack, RtdFlag::hasOneStation, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::slightlyInterestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), diff --git a/src/openrct2/ride/rtd/gentle/MiniHelicopters.h b/src/openrct2/ride/rtd/gentle/MiniHelicopters.h index c64d697ad6..eef4be2bd7 100644 --- a/src/openrct2/ride/rtd/gentle/MiniHelicopters.h +++ b/src/openrct2/ride/rtd/gentle/MiniHelicopters.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor MiniHelicoptersRTD = .extraTrackGroups = {TrackGroup::spinningTunnel}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::canSynchroniseWithAdjacentStations, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowDoorsOnTrack, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, @@ -37,6 +37,7 @@ constexpr RideTypeDescriptor MiniHelicoptersRTD = RtdFlag::slightlyInterestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_MINI_HELICOPTERS, STR_RIDE_DESCRIPTION_MINI_HELICOPTERS }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -60,7 +61,7 @@ constexpr RideTypeDescriptor MiniHelicoptersRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MINI_HELICOPTERS_TRACK, SPR_RIDE_DESIGN_PREVIEW_MINI_HELICOPTERS_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "mini_helicopters", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 60), RideRating::make(0, 40), RideRating::make(0, 00) }, diff --git a/src/openrct2/ride/rtd/gentle/MonorailCycles.h b/src/openrct2/ride/rtd/gentle/MonorailCycles.h index 3b4bf91b74..eaa0ac308c 100644 --- a/src/openrct2/ride/rtd/gentle/MonorailCycles.h +++ b/src/openrct2/ride/rtd/gentle/MonorailCycles.h @@ -29,13 +29,14 @@ constexpr RideTypeDescriptor MonorailCyclesRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::canSynchroniseWithAdjacentStations, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::noTestMode, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::slightlyInterestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_MONORAIL_CYCLES, STR_RIDE_DESCRIPTION_MONORAIL_CYCLES }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -56,7 +57,7 @@ constexpr RideTypeDescriptor MonorailCyclesRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MONORAIL_CYCLES_TRACK, SPR_RIDE_DESIGN_PREVIEW_MONORAIL_CYCLES_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "monorail_cycles", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 40), RideRating::make(0, 20), RideRating::make(0, 00) }, diff --git a/src/openrct2/ride/rtd/gentle/MonsterTrucks.h b/src/openrct2/ride/rtd/gentle/MonsterTrucks.h index 65d5511a9d..310b0c7b62 100644 --- a/src/openrct2/ride/rtd/gentle/MonsterTrucks.h +++ b/src/openrct2/ride/rtd/gentle/MonsterTrucks.h @@ -29,14 +29,15 @@ constexpr RideTypeDescriptor MonsterTrucksRTD = .extraTrackGroups = {TrackGroup::spinningTunnel}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::canSynchroniseWithAdjacentStations, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, - RtdFlag::allowMoreVehiclesThanStationFits, RtdFlag::showInTrackDesigner, + RtdFlag::allowMoreVehiclesThanStationFits, RtdFlag::showInTrackDesigner, RtdFlag::slightlyInterestingToLookAt), .RideModes = (1uLL << static_cast(RideMode::continuousCircuit)), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_MONSTER_TRUCKS, STR_RIDE_DESCRIPTION_MONSTER_TRUCKS }, .NameConvention = { RideComponentType::Car, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -59,7 +60,7 @@ constexpr RideTypeDescriptor MonsterTrucksRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_CAR_RIDE_TRACK, SPR_RIDE_DESIGN_PREVIEW_CAR_RIDE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "monster_trucks", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 00), RideRating::make(0, 50), RideRating::make(0, 00) }, diff --git a/src/openrct2/ride/rtd/gentle/ObservationTower.h b/src/openrct2/ride/rtd/gentle/ObservationTower.h index 8d4436bb80..2567d898ec 100644 --- a/src/openrct2/ride/rtd/gentle/ObservationTower.h +++ b/src/openrct2/ride/rtd/gentle/ObservationTower.h @@ -28,12 +28,13 @@ constexpr RideTypeDescriptor ObservationTowerRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::noWallsAroundTrack, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::showInTrackDesigner, RtdFlag::slightlyInterestingToLookAt), .RideModes = EnumsToFlags(RideMode::rotatingLift), .DefaultMode = RideMode::rotatingLift, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_OBSERVATION_TOWER, STR_RIDE_DESCRIPTION_OBSERVATION_TOWER }, .NameConvention = { RideComponentType::Cabin, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -55,7 +56,7 @@ constexpr RideTypeDescriptor ObservationTowerRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_OBSERVATION_TOWER_TRACK, SPR_RIDE_DESIGN_PREVIEW_OBSERVATION_TOWER_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "observation_tower", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 50), RideRating::make(0, 00), RideRating::make(0, 10) }, diff --git a/src/openrct2/ride/rtd/gentle/SpaceRings.h b/src/openrct2/ride/rtd/gentle/SpaceRings.h index 379e94a4e1..d5033fa99c 100644 --- a/src/openrct2/ride/rtd/gentle/SpaceRings.h +++ b/src/openrct2/ride/rtd/gentle/SpaceRings.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor SpaceRingsRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, RtdFlag::slightlyInterestingToLookAt, RtdFlag::listVehiclesSeparately), diff --git a/src/openrct2/ride/rtd/gentle/SpiralSlide.h b/src/openrct2/ride/rtd/gentle/SpiralSlide.h index 5b4f16e22e..84cd1e1fd2 100644 --- a/src/openrct2/ride/rtd/gentle/SpiralSlide.h +++ b/src/openrct2/ride/rtd/gentle/SpiralSlide.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor SpiralSlideRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::interestingToLookAt, diff --git a/src/openrct2/ride/rtd/shops/CashMachine.h b/src/openrct2/ride/rtd/shops/CashMachine.h index d9c06b9d06..041678e6da 100644 --- a/src/openrct2/ride/rtd/shops/CashMachine.h +++ b/src/openrct2/ride/rtd/shops/CashMachine.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor CashMachineRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::isShopOrFacility, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::listVehiclesSeparately), .RideModes = EnumsToFlags(RideMode::shopStall), diff --git a/src/openrct2/ride/rtd/shops/DrinkStall.h b/src/openrct2/ride/rtd/shops/DrinkStall.h index c4a625789d..3e0861fb56 100644 --- a/src/openrct2/ride/rtd/shops/DrinkStall.h +++ b/src/openrct2/ride/rtd/shops/DrinkStall.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor DrinkStallRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::isShopOrFacility, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::sellsDrinks, RtdFlag::listVehiclesSeparately, RtdFlag::hasTrackColourMain), diff --git a/src/openrct2/ride/rtd/shops/FirstAid.h b/src/openrct2/ride/rtd/shops/FirstAid.h index d6d4b5a462..47bd84e511 100644 --- a/src/openrct2/ride/rtd/shops/FirstAid.h +++ b/src/openrct2/ride/rtd/shops/FirstAid.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor FirstAidRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::isShopOrFacility, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::guestsShouldGoInsideFacility, RtdFlag::describeAsInside, RtdFlag::listVehiclesSeparately), diff --git a/src/openrct2/ride/rtd/shops/FoodStall.h b/src/openrct2/ride/rtd/shops/FoodStall.h index fc289df187..bdcc3652c3 100644 --- a/src/openrct2/ride/rtd/shops/FoodStall.h +++ b/src/openrct2/ride/rtd/shops/FoodStall.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor FoodStallRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::isShopOrFacility, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::sellsFood, RtdFlag::listVehiclesSeparately, RtdFlag::hasTrackColourMain), diff --git a/src/openrct2/ride/rtd/shops/InformationKiosk.h b/src/openrct2/ride/rtd/shops/InformationKiosk.h index bb9fee1ac1..f1418b547d 100644 --- a/src/openrct2/ride/rtd/shops/InformationKiosk.h +++ b/src/openrct2/ride/rtd/shops/InformationKiosk.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor InformationKioskRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasSinglePieceStation, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::isShopOrFacility, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::listVehiclesSeparately), diff --git a/src/openrct2/ride/rtd/shops/Shop.h b/src/openrct2/ride/rtd/shops/Shop.h index fa2f29f0e2..ab20f4b732 100644 --- a/src/openrct2/ride/rtd/shops/Shop.h +++ b/src/openrct2/ride/rtd/shops/Shop.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor ShopRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasSinglePieceStation, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::isShopOrFacility, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::listVehiclesSeparately), diff --git a/src/openrct2/ride/rtd/shops/Toilets.h b/src/openrct2/ride/rtd/shops/Toilets.h index fe7b493596..431a23355b 100644 --- a/src/openrct2/ride/rtd/shops/Toilets.h +++ b/src/openrct2/ride/rtd/shops/Toilets.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor ToiletsRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::noTestMode, RtdFlag::noVehicles, RtdFlag::isShopOrFacility, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::guestsShouldGoInsideFacility, RtdFlag::describeAsInside, RtdFlag::listVehiclesSeparately), diff --git a/src/openrct2/ride/rtd/thrill/3DCinema.h b/src/openrct2/ride/rtd/thrill/3DCinema.h index e17835a535..476f357379 100644 --- a/src/openrct2/ride/rtd/thrill/3DCinema.h +++ b/src/openrct2/ride/rtd/thrill/3DCinema.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor CinemaRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::describeAsInside, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/thrill/Enterprise.h b/src/openrct2/ride/rtd/thrill/Enterprise.h index b7cd66f214..0fa57814e0 100644 --- a/src/openrct2/ride/rtd/thrill/Enterprise.h +++ b/src/openrct2/ride/rtd/thrill/Enterprise.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor EnterpriseRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/thrill/GoKarts.h b/src/openrct2/ride/rtd/thrill/GoKarts.h index bb6d0317b5..7ddb8044cc 100644 --- a/src/openrct2/ride/rtd/thrill/GoKarts.h +++ b/src/openrct2/ride/rtd/thrill/GoKarts.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor GoKartsRTD = .extraTrackGroups = {TrackGroup::slopeSteepUp, TrackGroup::slopeSteepDown, TrackGroup::slopeSteepLong, TrackGroup::diagSlopeSteepUp, TrackGroup::diagSlopeSteepDown}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::noTestMode, RtdFlag::hasOneStation, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::noTestMode, RtdFlag::hasOneStation, RtdFlag::noWallsAroundTrack, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::interestingToLookAt), .RideModes = EnumsToFlags(RideMode::race, RideMode::continuousCircuit), diff --git a/src/openrct2/ride/rtd/thrill/LaunchedFreefall.h b/src/openrct2/ride/rtd/thrill/LaunchedFreefall.h index bc0b5c5f09..c5e40f1d42 100644 --- a/src/openrct2/ride/rtd/thrill/LaunchedFreefall.h +++ b/src/openrct2/ride/rtd/thrill/LaunchedFreefall.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor LaunchedFreefallRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::noWallsAroundTrack, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::showInTrackDesigner, RtdFlag::interestingToLookAt), diff --git a/src/openrct2/ride/rtd/thrill/MagicCarpet.h b/src/openrct2/ride/rtd/thrill/MagicCarpet.h index 64c49e2ea1..3226d7a867 100644 --- a/src/openrct2/ride/rtd/thrill/MagicCarpet.h +++ b/src/openrct2/ride/rtd/thrill/MagicCarpet.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor MagicCarpetRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/thrill/MotionSimulator.h b/src/openrct2/ride/rtd/thrill/MotionSimulator.h index 306fc74cc5..0e74af730a 100644 --- a/src/openrct2/ride/rtd/thrill/MotionSimulator.h +++ b/src/openrct2/ride/rtd/thrill/MotionSimulator.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor MotionSimulatorRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/thrill/RotoDrop.h b/src/openrct2/ride/rtd/thrill/RotoDrop.h index f2de33cd07..5479780680 100644 --- a/src/openrct2/ride/rtd/thrill/RotoDrop.h +++ b/src/openrct2/ride/rtd/thrill/RotoDrop.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor RotoDropRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::noWallsAroundTrack, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, diff --git a/src/openrct2/ride/rtd/thrill/SwingingInverterShip.h b/src/openrct2/ride/rtd/thrill/SwingingInverterShip.h index 09df3c70ae..23f551ad90 100644 --- a/src/openrct2/ride/rtd/thrill/SwingingInverterShip.h +++ b/src/openrct2/ride/rtd/thrill/SwingingInverterShip.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor SwingingInverterShipRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/thrill/SwingingShip.h b/src/openrct2/ride/rtd/thrill/SwingingShip.h index 60002672f8..843a03f03e 100644 --- a/src/openrct2/ride/rtd/thrill/SwingingShip.h +++ b/src/openrct2/ride/rtd/thrill/SwingingShip.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor SwingingShipRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, diff --git a/src/openrct2/ride/rtd/thrill/TopSpin.h b/src/openrct2/ride/rtd/thrill/TopSpin.h index f249e2f1fc..44f22cf067 100644 --- a/src/openrct2/ride/rtd/thrill/TopSpin.h +++ b/src/openrct2/ride/rtd/thrill/TopSpin.h @@ -27,7 +27,7 @@ constexpr RideTypeDescriptor TopSpinRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasSinglePieceStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, diff --git a/src/openrct2/ride/rtd/thrill/Twist.h b/src/openrct2/ride/rtd/thrill/Twist.h index b99ca41675..366d183f4a 100644 --- a/src/openrct2/ride/rtd/thrill/Twist.h +++ b/src/openrct2/ride/rtd/thrill/Twist.h @@ -26,7 +26,7 @@ constexpr RideTypeDescriptor TwistRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, + .flags = RtdFlags(RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::vehicleIsIntegral, RtdFlag::noWallsAroundTrack, RtdFlag::isFlatRide, RtdFlag::hasVehicleColours, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::singleSession, RtdFlag::interestingToLookAt, RtdFlag::listVehiclesSeparately), diff --git a/src/openrct2/ride/rtd/transport/Chairlift.h b/src/openrct2/ride/rtd/transport/Chairlift.h index 0520c67380..6f066163de 100644 --- a/src/openrct2/ride/rtd/transport/Chairlift.h +++ b/src/openrct2/ride/rtd/transport/Chairlift.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor ChairliftRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::canSynchroniseWithAdjacentStations, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasLoadOptions, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::allowMoreVehiclesThanStationFits, RtdFlag::isTransportRide, RtdFlag::showInTrackDesigner, diff --git a/src/openrct2/ride/rtd/transport/Lift.h b/src/openrct2/ride/rtd/transport/Lift.h index 90008d3240..d231bacd1d 100644 --- a/src/openrct2/ride/rtd/transport/Lift.h +++ b/src/openrct2/ride/rtd/transport/Lift.h @@ -27,12 +27,13 @@ constexpr RideTypeDescriptor LiftRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::hasSinglePieceStation, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::hasSinglePieceStation, RtdFlag::cannotHaveGaps, RtdFlag::hasLoadOptions, RtdFlag::noWallsAroundTrack, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::allowExtraTowerBases, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::isTransportRide, RtdFlag::showInTrackDesigner), .RideModes = EnumsToFlags(RideMode::shuttle), .DefaultMode = RideMode::shuttle, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_LIFT, STR_RIDE_DESCRIPTION_LIFT }, .NameConvention = { RideComponentType::Cabin, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_DOORS_STUCK_CLOSED) | (1 << BREAKDOWN_DOORS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -54,7 +55,7 @@ constexpr RideTypeDescriptor LiftRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_LIFT_TRACK, 0 }, .ColourKey = RideColourKey::Ride, .Name = "lift", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 11), RideRating::make(0, 35), RideRating::make(0, 30) }, diff --git a/src/openrct2/ride/rtd/transport/MiniatureRailway.h b/src/openrct2/ride/rtd/transport/MiniatureRailway.h index 8290a2f997..315c4730d7 100644 --- a/src/openrct2/ride/rtd/transport/MiniatureRailway.h +++ b/src/openrct2/ride/rtd/transport/MiniatureRailway.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor MiniatureRailwayRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::canSynchroniseWithAdjacentStations, + .flags = RtdFlags(RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::allowMoreVehiclesThanStationFits, @@ -37,6 +37,7 @@ constexpr RideTypeDescriptor MiniatureRailwayRTD = RtdFlag::supportsLevelCrossings), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::shuttle), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_MINIATURE_RAILWAY, STR_RIDE_DESCRIPTION_MINIATURE_RAILWAY }, .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -57,7 +58,7 @@ constexpr RideTypeDescriptor MiniatureRailwayRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MINIATURE_RAILWAY_TRACK, SPR_RIDE_DESIGN_PREVIEW_MINIATURE_RAILWAY_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "miniature_railway", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 50), RideRating::make(0, 00), RideRating::make(0, 00) }, diff --git a/src/openrct2/ride/rtd/transport/Monorail.h b/src/openrct2/ride/rtd/transport/Monorail.h index aab8905c29..4754f7af6e 100644 --- a/src/openrct2/ride/rtd/transport/Monorail.h +++ b/src/openrct2/ride/rtd/transport/Monorail.h @@ -28,7 +28,7 @@ constexpr RideTypeDescriptor MonorailRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, RtdFlag::canSynchroniseWithAdjacentStations, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourAdditional, RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, @@ -36,6 +36,7 @@ constexpr RideTypeDescriptor MonorailRTD = RtdFlag::allowMultipleCircuits, RtdFlag::isTransportRide, RtdFlag::showInTrackDesigner), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::shuttle), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_MONORAIL, STR_RIDE_DESCRIPTION_MONORAIL }, .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_DOORS_STUCK_CLOSED) | (1 << BREAKDOWN_DOORS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -59,7 +60,7 @@ constexpr RideTypeDescriptor MonorailRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_MONORAIL_TRACK, SPR_RIDE_DESIGN_PREVIEW_MONORAIL_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "monorail", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 00), RideRating::make(0, 00), RideRating::make(0, 00) }, diff --git a/src/openrct2/ride/rtd/transport/SuspendedMonorail.h b/src/openrct2/ride/rtd/transport/SuspendedMonorail.h index fd2ca67fdd..d1f3cbe892 100644 --- a/src/openrct2/ride/rtd/transport/SuspendedMonorail.h +++ b/src/openrct2/ride/rtd/transport/SuspendedMonorail.h @@ -28,7 +28,7 @@ constexpr RideTypeDescriptor SuspendedMonorailRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::canSynchroniseWithAdjacentStations, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, @@ -37,6 +37,7 @@ constexpr RideTypeDescriptor SuspendedMonorailRTD = RtdFlag::isSuspended), .RideModes = EnumsToFlags(RideMode::continuousCircuit, RideMode::shuttle), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_SUSPENDED_MONORAIL, STR_RIDE_DESCRIPTION_SUSPENDED_MONORAIL }, .NameConvention = { RideComponentType::Train, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_DOORS_STUCK_CLOSED) | (1 << BREAKDOWN_DOORS_STUCK_OPEN) | (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -58,7 +59,7 @@ constexpr RideTypeDescriptor SuspendedMonorailRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_SUSPENDED_MONORAIL_TRACK, SPR_RIDE_DESIGN_PREVIEW_SUSPENDED_MONORAIL_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "suspended_monorail", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 15), RideRating::make(0, 23), RideRating::make(0, 8) }, diff --git a/src/openrct2/ride/rtd/water/BoatHire.h b/src/openrct2/ride/rtd/water/BoatHire.h index 5de0a4f85a..d0904db445 100644 --- a/src/openrct2/ride/rtd/water/BoatHire.h +++ b/src/openrct2/ride/rtd/water/BoatHire.h @@ -28,11 +28,12 @@ constexpr RideTypeDescriptor BoatHireRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::trackMustBeOnWater, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::trackMustBeOnWater, RtdFlag::noTestMode, RtdFlag::hasLoadOptions, RtdFlag::hasVehicleColours, RtdFlag::checkForStalling, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit), .RideModes = EnumsToFlags(RideMode::boatHire), .DefaultMode = RideMode::boatHire, + .OperatingSettings = { 5, 18 }, .Naming = { STR_RIDE_NAME_BOAT_HIRE, STR_RIDE_DESCRIPTION_BOAT_HIRE }, .NameConvention = { RideComponentType::Boat, RideComponentType::DockingPlatform, RideComponentType::DockingPlatform }, .AvailableBreakdowns = (1 << BREAKDOWN_VEHICLE_MALFUNCTION), @@ -61,7 +62,7 @@ constexpr RideTypeDescriptor BoatHireRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_BOAT_HIRE_TRACK, SPR_RIDE_DESIGN_PREVIEW_BOAT_HIRE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "boat_hire", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 90), RideRating::make(0, 80), RideRating::make(0, 90) }, diff --git a/src/openrct2/ride/rtd/water/DinghySlide.h b/src/openrct2/ride/rtd/water/DinghySlide.h index 3a12e2e5f5..0b8b2b43d9 100644 --- a/src/openrct2/ride/rtd/water/DinghySlide.h +++ b/src/openrct2/ride/rtd/water/DinghySlide.h @@ -30,7 +30,7 @@ constexpr RideTypeDescriptor DinghySlideRTD = .extraTrackGroups = {}, .icon = SPR_RIDE_CONSTRUCTION_U_SHAPED_TRACK, .tooltip = STR_RIDE_CONSTRUCTION_U_SHAPED_OPEN_TRACK_TIP, - }, + }, { .trackStyle = TrackStyle::dinghySlideCovered, .supportType = MetalSupportType::tubes, @@ -41,15 +41,16 @@ constexpr RideTypeDescriptor DinghySlideRTD = } ), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, - RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasGForces, - RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasCoveredPieces, - RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, - RtdFlag::checkForStalling, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, - RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::hasAirTime, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasGForces, + RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasCoveredPieces, + RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, + RtdFlag::checkForStalling, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, + RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, RtdFlag::hasAirTime, RtdFlag::showInTrackDesigner, RtdFlag::interestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_DINGHY_SLIDE, STR_RIDE_DESCRIPTION_DINGHY_SLIDE }, .NameConvention = { RideComponentType::Boat, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT), @@ -71,7 +72,7 @@ constexpr RideTypeDescriptor DinghySlideRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_DINGHY_SLIDE_TRACK, SPR_RIDE_DESIGN_PREVIEW_DINGHY_SLIDE_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "dinghy_slide", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(2, 70), RideRating::make(2, 00), RideRating::make(1, 50) }, diff --git a/src/openrct2/ride/rtd/water/LogFlume.h b/src/openrct2/ride/rtd/water/LogFlume.h index 2459144c1b..b9cddaee99 100644 --- a/src/openrct2/ride/rtd/water/LogFlume.h +++ b/src/openrct2/ride/rtd/water/LogFlume.h @@ -28,7 +28,7 @@ constexpr RideTypeDescriptor LogFlumeRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::hasEntranceAndExit, @@ -36,6 +36,7 @@ constexpr RideTypeDescriptor LogFlumeRTD = RtdFlag::interestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_LOG_FLUME, STR_RIDE_DESCRIPTION_LOG_FLUME }, .NameConvention = { RideComponentType::Boat, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -56,7 +57,7 @@ constexpr RideTypeDescriptor LogFlumeRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_LOG_FLUME_TRACK, SPR_RIDE_DESIGN_PREVIEW_LOG_FLUME_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "log_flume", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 50), RideRating::make(0, 55), RideRating::make(0, 30) }, diff --git a/src/openrct2/ride/rtd/water/RiverRafts.h b/src/openrct2/ride/rtd/water/RiverRafts.h index a6050c1a86..55acb0ea45 100644 --- a/src/openrct2/ride/rtd/water/RiverRafts.h +++ b/src/openrct2/ride/rtd/water/RiverRafts.h @@ -28,7 +28,7 @@ constexpr RideTypeDescriptor RiverRaftsRTD = .extraTrackGroups = {TrackGroup::slope, TrackGroup::slopeSteepDown, TrackGroup::onridePhoto}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, @@ -36,6 +36,7 @@ constexpr RideTypeDescriptor RiverRaftsRTD = RtdFlag::showInTrackDesigner, RtdFlag::slightlyInterestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_RIVER_RAFTS, STR_RIDE_DESCRIPTION_RIVER_RAFTS }, .NameConvention = { RideComponentType::Boat, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT), @@ -55,7 +56,7 @@ constexpr RideTypeDescriptor RiverRaftsRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_RIVER_RAFTS_TRACK, SPR_RIDE_DESIGN_PREVIEW_RIVER_RAFTS_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "river_rafts", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 45), RideRating::make(0, 25), RideRating::make(0, 34) }, diff --git a/src/openrct2/ride/rtd/water/RiverRapids.h b/src/openrct2/ride/rtd/water/RiverRapids.h index 3a0cae0929..4ecbc12656 100644 --- a/src/openrct2/ride/rtd/water/RiverRapids.h +++ b/src/openrct2/ride/rtd/water/RiverRapids.h @@ -28,7 +28,7 @@ constexpr RideTypeDescriptor RiverRapidsRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = EnumsToFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, + .flags = RtdFlags(RtdFlag::hasTrackColourMain, RtdFlag::hasTrackColourSupports, RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasLoadOptions, RtdFlag::noWallsAroundTrack, RtdFlag::guestsWillRideAgain, @@ -37,6 +37,7 @@ constexpr RideTypeDescriptor RiverRapidsRTD = RtdFlag::hasAirTime, RtdFlag::showInTrackDesigner, RtdFlag::interestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_RIVER_RAPIDS, STR_RIDE_DESCRIPTION_RIVER_RAPIDS }, .NameConvention = { RideComponentType::Boat, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -56,7 +57,7 @@ constexpr RideTypeDescriptor RiverRapidsRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_RIVER_RAPIDS_TRACK, SPR_RIDE_DESIGN_PREVIEW_RIVER_RAPIDS_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "river_rapids", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 20), RideRating::make(0, 70), RideRating::make(0, 50) }, diff --git a/src/openrct2/ride/rtd/water/SplashBoats.h b/src/openrct2/ride/rtd/water/SplashBoats.h index efd9e80b5e..77b33a98f0 100644 --- a/src/openrct2/ride/rtd/water/SplashBoats.h +++ b/src/openrct2/ride/rtd/water/SplashBoats.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor SplashBoatsRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::canSynchroniseWithAdjacentStations, RtdFlag::hasDataLogging, RtdFlag::hasDrops, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, @@ -37,6 +37,7 @@ constexpr RideTypeDescriptor SplashBoatsRTD = RtdFlag::showInTrackDesigner, RtdFlag::slightlyInterestingToLookAt), .RideModes = EnumsToFlags(RideMode::continuousCircuit), .DefaultMode = RideMode::continuousCircuit, + .OperatingSettings = { 5, 27 }, .Naming = { STR_RIDE_NAME_SPLASH_BOATS, STR_RIDE_DESCRIPTION_SPLASH_BOATS }, .NameConvention = { RideComponentType::Boat, RideComponentType::Track, RideComponentType::Station }, .AvailableBreakdowns = (1 << BREAKDOWN_SAFETY_CUT_OUT) | (1 << BREAKDOWN_BRAKES_FAILURE), @@ -57,7 +58,7 @@ constexpr RideTypeDescriptor SplashBoatsRTD = .ColourPreview = { SPR_RIDE_DESIGN_PREVIEW_SPLASH_BOATS_TRACK, SPR_RIDE_DESIGN_PREVIEW_SPLASH_BOATS_SUPPORTS }, .ColourKey = RideColourKey::Ride, .Name = "splash_boats", - .RatingsData = + .RatingsData = { RatingsCalculationType::Normal, { RideRating::make(1, 46), RideRating::make(0, 35), RideRating::make(0, 30) }, diff --git a/src/openrct2/ride/rtd/water/SubmarineRide.h b/src/openrct2/ride/rtd/water/SubmarineRide.h index 0e7423bc3a..51b03d01e1 100644 --- a/src/openrct2/ride/rtd/water/SubmarineRide.h +++ b/src/openrct2/ride/rtd/water/SubmarineRide.h @@ -29,7 +29,7 @@ constexpr RideTypeDescriptor SubmarineRideRTD = .extraTrackGroups = {}, }), .InvertedTrackPaintFunctions = {}, - .Flags = kRtdFlagsHasThreeColours | EnumsToFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, + .flags = kRtdFlagsHasThreeColours | RtdFlags(RtdFlag::hasLeaveWhenAnotherVehicleArrivesAtStation, RtdFlag::trackMustBeOnWater, RtdFlag::hasLoadOptions, RtdFlag::guestsWillRideAgain, RtdFlag::hasVehicleColours, RtdFlag::hasTrack, RtdFlag::supportsMultipleColourSchemes, RtdFlag::allowMusic, RtdFlag::checkGForces, RtdFlag::hasEntranceAndExit, diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index a38c3e076b..86eb89d904 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -539,12 +539,12 @@ static ResultWithMessage ScenarioPrepareRidesForSave(GameState_t& gameState) // If there are more than 5 roller coasters, only mark the first five. if (isFiveCoasterObjective && (RideEntryHasCategory(*rideEntry, RideCategory::rollerCoaster) && rcs < 5)) { - ride.lifecycleFlags |= RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK; + ride.flags.set(RideFlag::indestructibleTrack); rcs++; } else { - ride.lifecycleFlags &= ~RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK; + ride.flags.unset(RideFlag::indestructibleTrack); } } } @@ -568,7 +568,7 @@ static ResultWithMessage ScenarioPrepareRidesForSave(GameState_t& gameState) auto ride = GetRide(it.element->AsTrack()->GetRideIndex()); // In the previous step, this flag was set on the first five roller coasters. - if (ride != nullptr && ride->lifecycleFlags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + if (ride != nullptr && ride->flags.has(RideFlag::indestructibleTrack)) { markTrackAsIndestructible = true; } diff --git a/src/openrct2/scenario/ScenarioObjective.cpp b/src/openrct2/scenario/ScenarioObjective.cpp index effe182550..31804dc8a6 100644 --- a/src/openrct2/scenario/ScenarioObjective.cpp +++ b/src/openrct2/scenario/ScenarioObjective.cpp @@ -212,7 +212,7 @@ namespace OpenRCT2::Scenario auto rideEntry = ride.getRideEntry(); if (rideEntry != nullptr) { - if ((ride.lifecycleFlags & RIDE_LIFECYCLE_INDESTRUCTIBLE_TRACK) + if (ride.flags.has(RideFlag::indestructibleTrack) && RideEntryHasCategory(*rideEntry, RideCategory::rollerCoaster)) { rcs++; diff --git a/src/openrct2/scenes/intro/IntroScene.cpp b/src/openrct2/scenes/intro/IntroScene.cpp index 04d5de25ff..9cfcc19e03 100644 --- a/src/openrct2/scenes/intro/IntroScene.cpp +++ b/src/openrct2/scenes/intro/IntroScene.cpp @@ -19,7 +19,7 @@ #include "../../drawing/Drawing.h" #include "../../drawing/Rectangle.h" -#include +#include using OpenRCT2::Audio::SoundId; using namespace OpenRCT2::Drawing; @@ -30,40 +30,98 @@ namespace OpenRCT2 static constexpr PaletteIndex kBackgroundColourLogo = PaletteIndex::primaryRemap2; static constexpr PaletteIndex kBorderColourPublisher = PaletteIndex::pi129; + static constexpr ImageIndex kSpriteChrisSawyerLogo00 = 23215; + static constexpr ImageIndex kSpriteChrisSawyerLogo10 = kSpriteChrisSawyerLogo00 + 1; static constexpr ImageIndex kPaletteChrisSawyerLogo = 23217; + + static constexpr ImageIndex kSpriteRCT2Logo00 = 23218; + static constexpr ImageIndex kSpriteRCT2Logo10 = kSpriteRCT2Logo00 + 1; + static constexpr ImageIndex kSpriteRCT2Logo20 = kSpriteRCT2Logo00 + 2; + static constexpr ImageIndex kSpriteRCT2Logo01 = kSpriteRCT2Logo00 + 3; + static constexpr ImageIndex kSpriteRCT2Logo11 = kSpriteRCT2Logo00 + 4; + static constexpr ImageIndex kSpriteRCT2Logo21 = kSpriteRCT2Logo00 + 5; static constexpr ImageIndex kPaletteRCT2Logo = 23224; - static IntroState _introState; + static constexpr ImageIndex kSpriteInfogramesLogo00 = 23226; + static constexpr ImageIndex kSpriteInfogramesLogo10 = kSpriteInfogramesLogo00 + 1; + static constexpr ImageIndex kSpriteInfogramesLogo01 = kSpriteInfogramesLogo00 + 2; + static constexpr ImageIndex kSpriteInfogramesLogo11 = kSpriteInfogramesLogo00 + 3; - // Used mainly for timing but also for Y coordinate and fading. - static int32_t _introStateCounter; + // Including the white box around it + constexpr int32_t kInfogramesLogoWidth = 541; + constexpr int32_t kInfogramesLogoHeight = 426; + constexpr int32_t kInfogramesLogoPadding = 19; + constexpr int32_t kInfogramesLogoOffscreen = kInfogramesLogoHeight + 154; - static std::shared_ptr _soundChannel = nullptr; - static bool _chainLiftFinished; + static std::weak_ptr introSceneImplementation; + + class IntroSceneImpl + { + public: + bool IntroIsPlaying(); + void IntroDraw(Drawing::RenderTarget& rt); + void Load(); + void Stop(); + void Tick(IContext& sceneContext); + + private: + void ScreenIntroProcessMouseInput(); + void ScreenIntroProcessKeyboardInput(); + void ScreenIntroSkipPart(); + void ScreenIntroDrawLogo(RenderTarget& rt); + + private: + enum class IntroState : uint8_t + { + None, + PublisherBegin, + PublisherScroll, + DeveloperBegin, + DeveloperScroll, + LogoFadeIn, + LogoWait, + LogoFadeOut, + Clear = 254, + Finish = 255, + }; + + IntroState _introState; + + // Used mainly for timing but also for Y coordinate and fading. + int32_t _introStateCounter; + + std::shared_ptr _soundChannel = nullptr; + bool _chainLiftFinished; + }; bool IntroIsPlaying() + { + if (auto impl = introSceneImplementation.lock()) + { + return impl->IntroIsPlaying(); + } + + return false; + } + + bool IntroSceneImpl::IntroIsPlaying() { return _introState != IntroState::None; } - void IntroScene::Load() + void IntroSceneImpl::Load() { _introState = IntroState::PublisherBegin; } - void IntroScene::Stop() + void IntroSceneImpl::Stop() { _introState = IntroState::None; LoadPalette(); } - static void ScreenIntroProcessMouseInput(); - static void ScreenIntroProcessKeyboardInput(); - static void ScreenIntroSkipPart(); - static void ScreenIntroDrawLogo(RenderTarget& rt); - // rct2: 0x0068E966 - void IntroScene::Tick() + void IntroSceneImpl::Tick(IContext& sceneContext) { ScreenIntroProcessMouseInput(); ScreenIntroProcessKeyboardInput(); @@ -74,7 +132,7 @@ namespace OpenRCT2 LoadPalette(); // Set the Y for the Infogrames logo - _introStateCounter = -580; + _introStateCounter = -kInfogramesLogoOffscreen; // Play the chain lift sound _soundChannel = Audio::CreateAudioChannel(SoundId::liftBM, true); @@ -85,8 +143,8 @@ namespace OpenRCT2 // Move the Infogrames logo down _introStateCounter += 5; - // Check if logo is off the screen...ish - if (_introStateCounter > ContextGetHeight() - 120) + // Check if logo is off the screen + if (_introStateCounter > ContextGetHeight()) { _introStateCounter = -116; _introState = IntroState::DeveloperBegin; @@ -181,8 +239,7 @@ namespace OpenRCT2 break; case IntroState::Finish: { - auto& context = GetContext(); - context.SetActiveScene(context.GetTitleScene()); + sceneContext.SetActiveScene(sceneContext.GetTitleScene()); break; } default: @@ -191,6 +248,14 @@ namespace OpenRCT2 } void IntroDraw(RenderTarget& rt) + { + if (auto impl = introSceneImplementation.lock()) + { + impl->IntroDraw(rt); + } + } + + void IntroSceneImpl::IntroDraw(RenderTarget& rt) { int32_t screenWidth = ContextGetWidth(); @@ -200,22 +265,22 @@ namespace OpenRCT2 GfxClear(rt, kBackgroundColourDark); break; case IntroState::PublisherScroll: + { GfxClear(rt, kBackgroundColourDark); // Draw a white rectangle for the logo background (gives a bit of white margin) - Rectangle::fill( - rt, - { { (screenWidth / 2) - 320 + 50, _introStateCounter + 50 }, - { (screenWidth / 2) - 320 + 50 + 540, _introStateCounter + 50 + 425 } }, - kBorderColourPublisher); + const auto leftTop = ScreenCoordsXY((screenWidth - kInfogramesLogoWidth) / 2, _introStateCounter + 50); + const auto rightBottom = leftTop + ScreenSize(kInfogramesLogoWidth - 1, kInfogramesLogoHeight - 1); + Rectangle::fill(rt, { leftTop, rightBottom }, kBorderColourPublisher); // Draw Infogrames logo - GfxDrawSprite(rt, ImageId(SPR_INTRO_INFOGRAMES_00), { (screenWidth / 2) - 320 + 69, _introStateCounter + 69 }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_INFOGRAMES_10), { (screenWidth / 2) - 320 + 319, _introStateCounter + 69 }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_INFOGRAMES_01), { (screenWidth / 2) - 320 + 69, _introStateCounter + 319 }); - GfxDrawSprite( - rt, ImageId(SPR_INTRO_INFOGRAMES_11), { (screenWidth / 2) - 320 + 319, _introStateCounter + 319 }); + auto leftTopLogo = leftTop + ScreenCoordsXY(kInfogramesLogoPadding, kInfogramesLogoPadding); + GfxDrawSprite(rt, ImageId(kSpriteInfogramesLogo00), leftTopLogo); + GfxDrawSprite(rt, ImageId(kSpriteInfogramesLogo10), leftTopLogo + ScreenCoordsXY(250, 0)); + GfxDrawSprite(rt, ImageId(kSpriteInfogramesLogo01), leftTopLogo + ScreenCoordsXY(0, 250)); + GfxDrawSprite(rt, ImageId(kSpriteInfogramesLogo11), leftTopLogo + ScreenCoordsXY(250, 250)); break; + } case IntroState::DeveloperBegin: GfxClear(rt, kBackgroundColourDark); GfxTransposePalette(kPaletteChrisSawyerLogo, 255); @@ -224,8 +289,8 @@ namespace OpenRCT2 GfxClear(rt, kBackgroundColourDark); // Draw Chris Sawyer logo - GfxDrawSprite(rt, ImageId(SPR_INTRO_CHRIS_SAWYER_00), { (screenWidth / 2) - 320 + 70, _introStateCounter }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_CHRIS_SAWYER_10), { (screenWidth / 2) - 320 + 320, _introStateCounter }); + GfxDrawSprite(rt, ImageId(kSpriteChrisSawyerLogo00), { (screenWidth / 2) - 320 + 70, _introStateCounter }); + GfxDrawSprite(rt, ImageId(kSpriteChrisSawyerLogo10), { (screenWidth / 2) - 320 + 320, _introStateCounter }); break; case IntroState::LogoFadeIn: if (_introStateCounter <= 0xFF00) @@ -264,7 +329,7 @@ namespace OpenRCT2 } } - static void ScreenIntroProcessMouseInput() + void IntroSceneImpl::ScreenIntroProcessMouseInput() { if (ContextGetCursorState()->any & CURSOR_DOWN) { @@ -276,7 +341,7 @@ namespace OpenRCT2 * * rct2: 0x006E3AEC */ - static void ScreenIntroProcessKeyboardInput() + void IntroSceneImpl::ScreenIntroProcessKeyboardInput() { const uint8_t* keys = ContextGetKeysState(); for (int i = 0; i < 256; i++) @@ -289,7 +354,7 @@ namespace OpenRCT2 } } - static void ScreenIntroSkipPart() + void IntroSceneImpl::ScreenIntroSkipPart() { switch (_introState) { @@ -301,25 +366,48 @@ namespace OpenRCT2 } } - static void ScreenIntroDrawLogo(RenderTarget& rt) + void IntroSceneImpl::ScreenIntroDrawLogo(RenderTarget& rt) { int32_t screenWidth = ContextGetWidth(); int32_t imageWidth = 640; int32_t imageX = (screenWidth - imageWidth) / 2; - DrawingEngineInvalidateImage(SPR_INTRO_LOGO_00); - DrawingEngineInvalidateImage(SPR_INTRO_LOGO_10); - DrawingEngineInvalidateImage(SPR_INTRO_LOGO_20); - DrawingEngineInvalidateImage(SPR_INTRO_LOGO_01); - DrawingEngineInvalidateImage(SPR_INTRO_LOGO_11); - DrawingEngineInvalidateImage(SPR_INTRO_LOGO_21); + DrawingEngineInvalidateImage(kSpriteRCT2Logo00); + DrawingEngineInvalidateImage(kSpriteRCT2Logo10); + DrawingEngineInvalidateImage(kSpriteRCT2Logo20); + DrawingEngineInvalidateImage(kSpriteRCT2Logo01); + DrawingEngineInvalidateImage(kSpriteRCT2Logo11); + DrawingEngineInvalidateImage(kSpriteRCT2Logo21); GfxClear(rt, kBackgroundColourLogo); - GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_00), { imageX + 0, 0 }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_10), { imageX + 220, 0 }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_20), { imageX + 440, 0 }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_01), { imageX + 0, 240 }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_11), { imageX + 220, 240 }); - GfxDrawSprite(rt, ImageId(SPR_INTRO_LOGO_21), { imageX + 440, 240 }); + GfxDrawSprite(rt, ImageId(kSpriteRCT2Logo00), { imageX + 0, 0 }); + GfxDrawSprite(rt, ImageId(kSpriteRCT2Logo10), { imageX + 220, 0 }); + GfxDrawSprite(rt, ImageId(kSpriteRCT2Logo20), { imageX + 440, 0 }); + GfxDrawSprite(rt, ImageId(kSpriteRCT2Logo01), { imageX + 0, 240 }); + GfxDrawSprite(rt, ImageId(kSpriteRCT2Logo11), { imageX + 220, 240 }); + GfxDrawSprite(rt, ImageId(kSpriteRCT2Logo21), { imageX + 440, 240 }); + } + + IntroScene::IntroScene(IContext& context) + : Scene(context) + , _impl(std::make_shared()) + { + introSceneImplementation = _impl; + } + + void IntroScene::Load() + { + _impl->Load(); + } + + void IntroScene::Stop() + { + _impl->Stop(); + } + + void IntroScene::Tick() + { + auto& sceneContext = GetContext(); + _impl->Tick(sceneContext); } } // namespace OpenRCT2 diff --git a/src/openrct2/scenes/intro/IntroScene.h b/src/openrct2/scenes/intro/IntroScene.h index 579a0cfa9f..e3cbbfdc9d 100644 --- a/src/openrct2/scenes/intro/IntroScene.h +++ b/src/openrct2/scenes/intro/IntroScene.h @@ -11,7 +11,7 @@ #include "../Scene.h" -#include +#include namespace OpenRCT2::Drawing { @@ -20,31 +20,23 @@ namespace OpenRCT2::Drawing namespace OpenRCT2 { - enum class IntroState : uint8_t - { - None, - PublisherBegin, - PublisherScroll, - DeveloperBegin, - DeveloperScroll, - LogoFadeIn, - LogoWait, - LogoFadeOut, - Clear = 254, - Finish = 255, - }; + class IntroSceneImpl; class IntroScene final : public Scene { public: using Scene::Scene; + IntroScene(IContext& context); + void Load() override; void Tick() override; void Stop() override; + + private: + std::shared_ptr _impl; }; bool IntroIsPlaying(); - void IntroUpdate(); void IntroDraw(Drawing::RenderTarget& rt); } // namespace OpenRCT2 diff --git a/src/openrct2/scenes/preloader/PreloaderScene.cpp b/src/openrct2/scenes/preloader/PreloaderScene.cpp index 9ad1315bdd..4b2a09724b 100644 --- a/src/openrct2/scenes/preloader/PreloaderScene.cpp +++ b/src/openrct2/scenes/preloader/PreloaderScene.cpp @@ -49,14 +49,19 @@ void PreloaderScene::Tick() { gInUpdateCode = true; - ContextHandleInput(); + // Avoid race condition with background jobs modifying gWindowList. + const bool jobsRunning = _jobs.IsBusy(); - auto* windowMgr = Ui::GetWindowManager(); - windowMgr->InvalidateAll(); + if (!jobsRunning) + { + ContextHandleInput(); + auto* windowMgr = Ui::GetWindowManager(); + windowMgr->InvalidateAll(); + } gInUpdateCode = false; - if (!_jobs.IsBusy()) + if (!jobsRunning) { // Make sure the job is fully completed. _jobs.Join(); diff --git a/src/openrct2/scripting/ScriptEngine.cpp b/src/openrct2/scripting/ScriptEngine.cpp index b4820c1391..941d4ff811 100644 --- a/src/openrct2/scripting/ScriptEngine.cpp +++ b/src/openrct2/scripting/ScriptEngine.cpp @@ -12,13 +12,13 @@ #include "ScriptEngine.h" #include "../PlatformEnvironment.h" - #include "../actions/BannerPlaceAction.h" - #include "../actions/CustomAction.h" - #include "../actions/GameAction.h" - #include "../actions/LargeSceneryPlaceAction.h" - #include "../actions/RideCreateAction.h" - #include "../actions/StaffHireNewAction.h" - #include "../actions/WallPlaceAction.h" + #include "../actions/GameAction.hpp" + #include "../actions/general/CustomAction.h" + #include "../actions/peep/StaffHireNewAction.h" + #include "../actions/ride/RideCreateAction.h" + #include "../actions/scenery/BannerPlaceAction.h" + #include "../actions/scenery/LargeSceneryPlaceAction.h" + #include "../actions/scenery/WallPlaceAction.h" #include "../config/Config.h" #include "../core/EnumMap.hpp" #include "../core/File.h" @@ -959,7 +959,7 @@ void ScriptEngine::CheckAndStartPlugins() void ScriptEngine::ProcessREPL() { - while (_evalQueue.size() > 0) + while (!_evalQueue.empty()) { auto item = std::move(_evalQueue.front()); _evalQueue.pop(); diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index 9fb59772d9..2157f3ed3a 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -11,7 +11,7 @@ #ifdef ENABLE_SCRIPTING - #include "../actions/CustomAction.h" + #include "../actions/general/CustomAction.h" #include "../core/FileWatcher.h" #include "../management/Finance.h" #include "../world/Location.hpp" diff --git a/src/openrct2/scripting/bindings/entity/ScGuest.cpp b/src/openrct2/scripting/bindings/entity/ScGuest.cpp index cfee81f942..b28a6f6d65 100644 --- a/src/openrct2/scripting/bindings/entity/ScGuest.cpp +++ b/src/openrct2/scripting/bindings/entity/ScGuest.cpp @@ -893,7 +893,7 @@ namespace OpenRCT2::Scripting auto* peep = GetGuest(); if (peep == nullptr) { - return nullptr; + return ""; } auto& availableGuestAnimations = getAnimationsByPeepType(AnimationPeepType::guest); diff --git a/src/openrct2/scripting/bindings/entity/ScStaff.cpp b/src/openrct2/scripting/bindings/entity/ScStaff.cpp index 00a1c392c5..62ab02012f 100644 --- a/src/openrct2/scripting/bindings/entity/ScStaff.cpp +++ b/src/openrct2/scripting/bindings/entity/ScStaff.cpp @@ -314,7 +314,7 @@ namespace OpenRCT2::Scripting auto* peep = GetStaff(); if (peep == nullptr) { - return nullptr; + return ""; } auto& animationGroups = animationsByStaffType(peep->AssignedStaffType); diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp index 632b550016..0d710ce997 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.cpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.cpp @@ -79,10 +79,10 @@ namespace OpenRCT2::Scripting dukglue_register_property(ctx, &ScVehicle::velocity_get, &ScVehicle::velocity_set, "velocity"); dukglue_register_property(ctx, &ScVehicle::bankRotation_get, &ScVehicle::bankRotation_set, "bankRotation"); dukglue_register_property( - ctx, &ScVehicle::flag_get, &ScVehicle::flag_set, + ctx, &ScVehicle::flag_get, &ScVehicle::flag_set, "isReversed"); dukglue_register_property( - ctx, &ScVehicle::flag_get, &ScVehicle::flag_set, "isCrashed"); + ctx, &ScVehicle::flag_get, &ScVehicle::flag_set, "isCrashed"); dukglue_register_property(ctx, &ScVehicle::colours_get, &ScVehicle::colours_set, "colours"); dukglue_register_property(ctx, &ScVehicle::trackLocation_get, nullptr, "trackLocation"); dukglue_register_property(ctx, &ScVehicle::trackProgress_get, nullptr, "trackProgress"); @@ -350,14 +350,14 @@ namespace OpenRCT2::Scripting } } - template + template bool ScVehicle::flag_get() const { auto vehicle = GetVehicle(); - return vehicle != nullptr ? vehicle->HasFlag(flag) : false; + return vehicle != nullptr ? vehicle->flags.has(static_cast(flag)) : false; } - template + template void ScVehicle::flag_set(bool value) { ThrowIfGameStateNotMutable(); @@ -366,11 +366,11 @@ namespace OpenRCT2::Scripting { if (value) { - vehicle->SetFlag(flag); + vehicle->flags.set(static_cast(flag)); } else { - vehicle->ClearFlag(flag); + vehicle->flags.unset(static_cast(flag)); } vehicle->Invalidate(); } diff --git a/src/openrct2/scripting/bindings/entity/ScVehicle.hpp b/src/openrct2/scripting/bindings/entity/ScVehicle.hpp index f2fca357d7..4f34791d5c 100644 --- a/src/openrct2/scripting/bindings/entity/ScVehicle.hpp +++ b/src/openrct2/scripting/bindings/entity/ScVehicle.hpp @@ -68,9 +68,9 @@ namespace OpenRCT2::Scripting uint8_t bankRotation_get() const; void bankRotation_set(uint8_t value); - template + template bool flag_get() const; - template + template void flag_set(bool value); DukValue colours_get() const; diff --git a/src/openrct2/scripting/bindings/game/ScContext.hpp b/src/openrct2/scripting/bindings/game/ScContext.hpp index 1e4f9a2e1f..7cba5b534c 100644 --- a/src/openrct2/scripting/bindings/game/ScContext.hpp +++ b/src/openrct2/scripting/bindings/game/ScContext.hpp @@ -11,8 +11,9 @@ #ifdef ENABLE_SCRIPTING + #include "../../../Game.h" #include "../../../OpenRCT2.h" - #include "../../../actions/GameAction.h" + #include "../../../actions/GameActionRunner.h" #include "../../../interface/Screenshot.h" #include "../../../localisation/Formatting.h" #include "../../../object/ObjectManager.h" diff --git a/src/openrct2/scripting/bindings/game/ScProfiler.hpp b/src/openrct2/scripting/bindings/game/ScProfiler.hpp index 932eee34fb..a2833ff68d 100644 --- a/src/openrct2/scripting/bindings/game/ScProfiler.hpp +++ b/src/openrct2/scripting/bindings/game/ScProfiler.hpp @@ -30,19 +30,20 @@ namespace OpenRCT2::Scripting private: DukValue getData() { - const auto& data = Profiling::GetData(); + const auto& data = Profiling::getData(); duk_push_array(_ctx); duk_uarridx_t index = 0; for (const auto& f : data) { DukObject obj(_ctx); - obj.Set("name", f->GetName()); - obj.Set("callCount", f->GetCallCount()); - obj.Set("minTime", f->GetMinTime()); - obj.Set("maxTime", f->GetMaxTime()); + obj.Set("name", f->getName()); + obj.Set("callCount", f->getCallCount()); + obj.Set("minTime", f->getMinTime()); + obj.Set("maxTime", f->getMaxTime()); obj.Set("totalTime", f->getTotalTime()); - obj.Set("parents", GetFunctionIndexArray(data, f->GetParents())); - obj.Set("children", GetFunctionIndexArray(data, f->GetChildren())); + obj.Set("averageTime", f->getAverageTime()); + obj.Set("parents", GetFunctionIndexArray(data, f->getParents())); + obj.Set("children", GetFunctionIndexArray(data, f->getChildren())); obj.Take().push(); duk_put_prop_index(_ctx, /* duk stack index */ -2, index); index++; @@ -71,22 +72,22 @@ namespace OpenRCT2::Scripting void start() { - Profiling::Enable(); + Profiling::enable(); } void stop() { - Profiling::Disable(); + Profiling::disable(); } void reset() { - Profiling::ResetData(); + Profiling::resetData(); } bool enabled_get() const { - return Profiling::IsEnabled(); + return Profiling::isEnabled(); } public: diff --git a/src/openrct2/scripting/bindings/network/ScNetwork.cpp b/src/openrct2/scripting/bindings/network/ScNetwork.cpp index 67d18a44c4..27e06d808c 100644 --- a/src/openrct2/scripting/bindings/network/ScNetwork.cpp +++ b/src/openrct2/scripting/bindings/network/ScNetwork.cpp @@ -13,8 +13,9 @@ #include "../../../Context.h" #include "../../../GameState.h" - #include "../../../actions/NetworkModifyGroupAction.h" - #include "../../../actions/PlayerKickAction.h" + #include "../../../actions/GameActionRunner.h" + #include "../../../actions/network/NetworkModifyGroupAction.h" + #include "../../../actions/network/PlayerKickAction.h" #include "../../../network/Network.h" #include "../../../network/NetworkAction.h" diff --git a/src/openrct2/scripting/bindings/network/ScPlayer.cpp b/src/openrct2/scripting/bindings/network/ScPlayer.cpp index 0765274742..d74d00006c 100644 --- a/src/openrct2/scripting/bindings/network/ScPlayer.cpp +++ b/src/openrct2/scripting/bindings/network/ScPlayer.cpp @@ -13,7 +13,8 @@ #include "../../../Context.h" #include "../../../GameState.h" - #include "../../../actions/PlayerSetGroupAction.h" + #include "../../../actions/GameActionRunner.h" + #include "../../../actions/network/PlayerSetGroupAction.h" #include "../../../network/Network.h" #include "../../../network/NetworkAction.h" diff --git a/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp b/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp index b08cb20ef8..67aa257e0e 100644 --- a/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp +++ b/src/openrct2/scripting/bindings/network/ScPlayerGroup.cpp @@ -13,8 +13,9 @@ #include "../../../Context.h" #include "../../../GameState.h" - #include "../../../actions/NetworkModifyGroupAction.h" - #include "../../../actions/PlayerSetGroupAction.h" + #include "../../../actions/GameActionRunner.h" + #include "../../../actions/network/NetworkModifyGroupAction.h" + #include "../../../actions/network/PlayerSetGroupAction.h" #include "../../../core/String.hpp" #include "../../../network/Network.h" #include "../../../network/NetworkAction.h" diff --git a/src/openrct2/scripting/bindings/object/ScObject.hpp b/src/openrct2/scripting/bindings/object/ScObject.hpp index 89b45ae65e..7b596c070c 100644 --- a/src/openrct2/scripting/bindings/object/ScObject.hpp +++ b/src/openrct2/scripting/bindings/object/ScObject.hpp @@ -565,7 +565,7 @@ namespace OpenRCT2::Scripting auto rideEntry = GetEntry(); if (rideEntry != nullptr) { - return rideEntry->flags; + return rideEntry->flags.holder; } return 0; } diff --git a/src/openrct2/scripting/bindings/ride/ScRide.cpp b/src/openrct2/scripting/bindings/ride/ScRide.cpp index 05b157ace3..6ff59761d0 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.cpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.cpp @@ -116,19 +116,19 @@ namespace OpenRCT2::Scripting return ""; } - uint32_t ScRide::lifecycleFlags_get() const + uint32_t ScRide::flags_get() const { auto ride = GetRide(); - return ride != nullptr ? ride->lifecycleFlags : 0; + return ride != nullptr ? ride->flags.holder : 0; } - void ScRide::lifecycleFlags_set(uint32_t value) + void ScRide::flags_set(uint32_t value) { ThrowIfGameStateNotMutable(); auto ride = GetRide(); if (ride != nullptr) { - ride->lifecycleFlags = value; + ride->flags.holder = value; } } @@ -530,7 +530,7 @@ namespace OpenRCT2::Scripting if (ride != nullptr) { - if (!(ride->lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN)) + if (!ride->flags.has(RideFlag::brokenDown)) { return "none"; } @@ -656,7 +656,8 @@ namespace OpenRCT2::Scripting dukglue_register_property(ctx, &ScRide::classification_get, nullptr, "classification"); dukglue_register_property(ctx, &ScRide::name_get, &ScRide::name_set, "name"); dukglue_register_property(ctx, &ScRide::status_get, nullptr, "status"); - dukglue_register_property(ctx, &ScRide::lifecycleFlags_get, &ScRide::lifecycleFlags_set, "lifecycleFlags"); + dukglue_register_property(ctx, &ScRide::flags_get, &ScRide::flags_set, "lifecycleFlags"); + dukglue_register_property(ctx, &ScRide::flags_get, &ScRide::flags_set, "flags"); dukglue_register_property(ctx, &ScRide::mode_get, &ScRide::mode_set, "mode"); dukglue_register_property(ctx, &ScRide::departFlags_get, &ScRide::departFlags_set, "departFlags"); dukglue_register_property(ctx, &ScRide::minimumWaitingTime_get, &ScRide::minimumWaitingTime_set, "minimumWaitingTime"); diff --git a/src/openrct2/scripting/bindings/ride/ScRide.hpp b/src/openrct2/scripting/bindings/ride/ScRide.hpp index 279e47cdb4..f6fb42474a 100644 --- a/src/openrct2/scripting/bindings/ride/ScRide.hpp +++ b/src/openrct2/scripting/bindings/ride/ScRide.hpp @@ -84,9 +84,9 @@ namespace OpenRCT2::Scripting std::string status_get() const; - uint32_t lifecycleFlags_get() const; + uint32_t flags_get() const; - void lifecycleFlags_set(uint32_t value); + void flags_set(uint32_t value); uint8_t mode_get() const; diff --git a/src/openrct2/world/Banner.cpp b/src/openrct2/world/Banner.cpp index 48df60e225..f7cb9b4518 100644 --- a/src/openrct2/world/Banner.cpp +++ b/src/openrct2/world/Banner.cpp @@ -43,6 +43,13 @@ using namespace OpenRCT2; +std::string Banner::getTextWithColour() const +{ + Formatter ft; + formatTextWithColourTo(ft); + return FormatStringIDLegacy(STR_STRINGID, ft.Data()); +} + std::string Banner::getText() const { Formatter ft; @@ -110,7 +117,7 @@ static RideId BannerGetRideIndexAt(const CoordsXYZ& bannerCoords) RideId rideIndex = tileElement->AsTrack()->GetRideIndex(); auto ride = GetRide(rideIndex); - if (ride == nullptr || ride->getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride == nullptr || ride->getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) continue; if ((tileElement->GetClearanceZ()) + (4 * kCoordsZStep) <= bannerCoords.z) @@ -233,7 +240,7 @@ RideId BannerGetClosestRideIndex(const CoordsXYZ& mapPos) auto& gameState = getGameState(); for (auto& ride : RideManager(gameState)) { - if (ride.getRideTypeDescriptor().HasFlag(RtdFlag::isShopOrFacility)) + if (ride.getRideTypeDescriptor().flags.has(RtdFlag::isShopOrFacility)) continue; auto rideCoords = ride.overallView; @@ -464,7 +471,7 @@ void DeleteBanner(BannerIndex id) void TrimBanners() { auto& gameState = getGameState(); - if (gameState.banners.size() > 0) + if (!gameState.banners.empty()) { auto lastBannerId = gameState.banners.size() - 1; while (lastBannerId != std::numeric_limits::max() && gameState.banners[lastBannerId].isNull()) diff --git a/src/openrct2/world/Banner.h b/src/openrct2/world/Banner.h index 2270d28bbd..479bca0360 100644 --- a/src/openrct2/world/Banner.h +++ b/src/openrct2/world/Banner.h @@ -58,6 +58,7 @@ struct Banner return type == kBannerNull; } + std::string getTextWithColour() const; std::string getText() const; void formatTextWithColourTo(OpenRCT2::Formatter&) const; void formatTextTo(OpenRCT2::Formatter&) const; diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp index 6917e2b76e..d2842f235d 100644 --- a/src/openrct2/world/ConstructionClearance.cpp +++ b/src/openrct2/world/ConstructionClearance.cpp @@ -161,7 +161,7 @@ static bool MapLoc68BABCShouldContinue( && tileElement->AsTrack()->GetTrackType() == TrackElemType::flat) { auto ride = GetRide(tileElement->AsTrack()->GetRideIndex()); - if (ride != nullptr && ride->getRideTypeDescriptor().HasFlag(RtdFlag::supportsLevelCrossings)) + if (ride != nullptr && ride->getRideTypeDescriptor().flags.has(RtdFlag::supportsLevelCrossings)) { return true; } diff --git a/src/openrct2/world/Entrance.cpp b/src/openrct2/world/Entrance.cpp index 1ad4c93fb5..bf53c8491a 100644 --- a/src/openrct2/world/Entrance.cpp +++ b/src/openrct2/world/Entrance.cpp @@ -14,9 +14,10 @@ #include "../Game.h" #include "../GameState.h" #include "../OpenRCT2.h" -#include "../actions/ParkEntranceRemoveAction.h" -#include "../actions/RideEntranceExitPlaceAction.h" -#include "../actions/RideEntranceExitRemoveAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/park/ParkEntranceRemoveAction.h" +#include "../actions/ride/RideEntranceExitPlaceAction.h" +#include "../actions/ride/RideEntranceExitRemoveAction.h" #include "../localisation/StringIds.h" #include "../management/Finance.h" #include "../network/Network.h" diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 097c75179e..519e4ebb31 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -14,9 +14,10 @@ #include "../GameState.h" #include "../Identifiers.h" #include "../OpenRCT2.h" -#include "../actions/FootpathPlaceAction.h" -#include "../actions/FootpathRemoveAction.h" -#include "../actions/LandSetRightsAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/footpath/FootpathPlaceAction.h" +#include "../actions/footpath/FootpathRemoveAction.h" +#include "../actions/park/LandSetRightsAction.h" #include "../core/Guard.hpp" #include "../entity/EntityList.h" #include "../entity/EntityRegistry.h" @@ -588,7 +589,7 @@ static void Loc6A6D7E( continue; } - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::isFlatRide)) { continue; } @@ -674,7 +675,7 @@ static void Loc6A6C85( return; } - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::isFlatRide)) { return; } @@ -1097,7 +1098,7 @@ static int32_t FootpathIsConnectedToMapEdgeHelper(CoordsXYZ footpathPos, int32_t // Loads the next tile to visit into our variables auto LoadNextTileElement = [&tiles, &numPendingTiles](TileState& t_currentTile) -> void { // Do not continue if there are no tiles in the list - if (tiles.size() == 0) + if (tiles.empty()) return; // Find the next unprocessed tile @@ -1685,7 +1686,7 @@ bool TileElementWantsPathConnectionTowards(const TileCoordsXYZD& coords, const T if (ride == nullptr) continue; - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::isFlatRide)) break; const auto trackType = tileElement->AsTrack()->GetTrackType(); @@ -1736,7 +1737,7 @@ void FootpathRemoveEdgesAt(const CoordsXY& footpathPos, TileElement* tileElement if (ride == nullptr) return; - if (!ride->getRideTypeDescriptor().HasFlag(RtdFlag::isFlatRide)) + if (!ride->getRideTypeDescriptor().flags.has(RtdFlag::isFlatRide)) return; } @@ -1864,7 +1865,7 @@ bool PathElement::IsLevelCrossing(const CoordsXY& coords) const return false; } - return ride->getRideTypeDescriptor().HasFlag(RtdFlag::supportsLevelCrossings); + return ride->getRideTypeDescriptor().flags.has(RtdFlag::supportsLevelCrossings); } bool FootpathIsZAndDirectionValid(const PathElement& pathElement, int32_t currentZ, int32_t currentDirection) diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index d605fa58d6..94dad74f34 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -16,10 +16,11 @@ #include "../GameState.h" #include "../Input.h" #include "../OpenRCT2.h" -#include "../actions/BannerRemoveAction.h" -#include "../actions/LargeSceneryRemoveAction.h" -#include "../actions/ParkEntranceRemoveAction.h" -#include "../actions/WallRemoveAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/park/ParkEntranceRemoveAction.h" +#include "../actions/scenery/BannerRemoveAction.h" +#include "../actions/scenery/LargeSceneryRemoveAction.h" +#include "../actions/scenery/WallRemoveAction.h" #include "../audio/Audio.h" #include "../core/EnumUtils.hpp" #include "../core/Guard.hpp" diff --git a/src/openrct2/world/Park.cpp b/src/openrct2/world/Park.cpp index aeb136d212..cf1036f2f1 100644 --- a/src/openrct2/world/Park.cpp +++ b/src/openrct2/world/Park.cpp @@ -15,7 +15,8 @@ #include "../Game.h" #include "../GameState.h" #include "../OpenRCT2.h" -#include "../actions/ParkSetParameterAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/park/ParkSetParameterAction.h" #include "../core/Memory.hpp" #include "../core/String.hpp" #include "../entity/EntityList.h" @@ -85,9 +86,7 @@ namespace OpenRCT2::Park { if (ride.status != RideStatus::open) continue; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) - continue; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_CRASHED) + if (ride.flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) continue; // Add ride value @@ -116,9 +115,7 @@ namespace OpenRCT2::Park { if (ride.status != RideStatus::open) continue; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_BROKEN_DOWN) - continue; - if (ride.lifecycleFlags & RIDE_LIFECYCLE_CRASHED) + if (ride.flags.hasAny(RideFlag::brokenDown, RideFlag::crashed)) continue; // Add guest score for ride type @@ -127,11 +124,11 @@ namespace OpenRCT2::Park // If difficult guest generation, extra guests are available for good rides if (park.flags & PARK_FLAGS_DIFFICULT_GUEST_GENERATION) { - if (!(ride.lifecycleFlags & RIDE_LIFECYCLE_TESTED)) + if (!ride.flags.has(RideFlag::tested)) continue; - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasTrack)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::hasTrack)) continue; - if (!ride.getRideTypeDescriptor().HasFlag(RtdFlag::hasDataLogging)) + if (!ride.getRideTypeDescriptor().flags.has(RtdFlag::hasDataLogging)) continue; if (ride.getStation().SegmentLength < (600 << 16)) continue; @@ -185,8 +182,8 @@ namespace OpenRCT2::Park } } - // Reduces chance for any more than 7000 guests - if (numGuests > 7000) + // Reduces chance for any more than 52000 guests + if (numGuests > 52000) { probability /= 4; } diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 4186c60f23..bca7b96133 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -14,11 +14,12 @@ #include "../Game.h" #include "../GameState.h" #include "../OpenRCT2.h" -#include "../actions/BannerRemoveAction.h" -#include "../actions/FootpathAdditionRemoveAction.h" -#include "../actions/LargeSceneryRemoveAction.h" -#include "../actions/SmallSceneryRemoveAction.h" -#include "../actions/WallRemoveAction.h" +#include "../actions/GameActionRunner.h" +#include "../actions/footpath/FootpathAdditionRemoveAction.h" +#include "../actions/scenery/BannerRemoveAction.h" +#include "../actions/scenery/LargeSceneryRemoveAction.h" +#include "../actions/scenery/SmallSceneryRemoveAction.h" +#include "../actions/scenery/WallRemoveAction.h" #include "../core/CodepointView.hpp" #include "../entity/Fountain.h" #include "../network/Network.h" diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 6875c5f6a7..fac17d1a88 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -10,7 +10,7 @@ #include "TileInspector.h" #include "../Diagnostic.h" -#include "../actions/GameAction.h" +#include "../actions/GameAction.hpp" #include "../core/Guard.hpp" #include "../object/LargeSceneryEntry.h" #include "../ride/Station.h" @@ -769,6 +769,8 @@ namespace OpenRCT2::TileInspector nextTrackElement->BaseHeight += offset; nextTrackElement->ClearanceHeight += offset; + + MapInvalidateTileFull(elem); } } @@ -853,6 +855,8 @@ namespace OpenRCT2::TileInspector { nextTrackElement->AsTrack()->SetHasChain(setChain); } + + MapInvalidateTileFull(elem); } } diff --git a/src/openrct2/world/tile_element/TrackElement.cpp b/src/openrct2/world/tile_element/TrackElement.cpp index a8e18a66cd..5332846102 100644 --- a/src/openrct2/world/tile_element/TrackElement.cpp +++ b/src/openrct2/world/tile_element/TrackElement.cpp @@ -64,7 +64,7 @@ namespace OpenRCT2 uint8_t TrackElement::GetSeatRotation() const { const auto* ride = GetRide(GetRideIndex()); - if (ride != nullptr && ride->getRideTypeDescriptor().HasFlag(RtdFlag::hasLandscapeDoors)) + if (ride != nullptr && ride->getRideTypeDescriptor().flags.has(RtdFlag::hasLandscapeDoors)) return kDefaultSeatRotation; return URide.ColourScheme >> 4; diff --git a/src/openrct2/world/tile_element/TrackElement.h b/src/openrct2/world/tile_element/TrackElement.h index 9ca386ca3a..25d75bf6e4 100644 --- a/src/openrct2/world/tile_element/TrackElement.h +++ b/src/openrct2/world/tile_element/TrackElement.h @@ -83,7 +83,7 @@ namespace OpenRCT2 public: TrackElemType GetTrackType() const; - void SetTrackType(TrackElemType newEntryIndex); + void SetTrackType(TrackElemType newType); ride_type_t GetRideType() const; void SetRideType(ride_type_t rideType); diff --git a/test/tests/CMakeLists.txt b/test/tests/CMakeLists.txt index 707bdf0434..483a54d1a5 100644 --- a/test/tests/CMakeLists.txt +++ b/test/tests/CMakeLists.txt @@ -26,6 +26,7 @@ set(test_files "${CMAKE_CURRENT_SOURCE_DIR}/PlayTests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ReplayTests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/RideRatings.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/EntityImportTests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/S6ImportExportTests.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/SawyerCodingTest.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ScenarioPatcherTests.cpp" diff --git a/test/tests/CircularBuffer.cpp b/test/tests/CircularBuffer.cpp index 166fbfde70..9cd06ec91b 100644 --- a/test/tests/CircularBuffer.cpp +++ b/test/tests/CircularBuffer.cpp @@ -6,9 +6,9 @@ * * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ +#include #include #include -#include #include // CircularBuffer capacity. diff --git a/test/tests/EntityImportTests.cpp b/test/tests/EntityImportTests.cpp new file mode 100644 index 0000000000..fabdbabc35 --- /dev/null +++ b/test/tests/EntityImportTests.cpp @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "TestData.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace OpenRCT2; + +class EntityImportTests : public testing::Test +{ +protected: + std::unique_ptr context; + + void SetUp() override + { + gOpenRCT2Headless = true; + gOpenRCT2NoGraphics = true; + context = CreateContext(); + ASSERT_NE(context, nullptr); + ASSERT_TRUE(context->Initialise()); + } + + void TearDown() override + { + context.reset(); + } +}; + +// This here tests that CreateEntityAt returns nullptr when trying to create an entity at an index that's already occupied. +// This behavior is what caused crashes before, corrupted saves had duplicate EntityIndex values that caused CreateEntityAt to +// return nullptr, which was then dereferenced. +TEST_F(EntityImportTests, CreateEntityAtDuplicateIndexReturnsNull) +{ + auto& gameState = getGameState(); + gameState.entities.ResetAllEntities(); + + // Create an entity at index 100 + auto* entity1 = gameState.entities.CreateEntityAt(EntityId::FromUnderlying(100)); + ASSERT_NE(entity1, nullptr); + EXPECT_EQ(entity1->Id.ToUnderlying(), 100u); + + // Try to create another entity at the same index, which should return nullptr + auto* entity2 = gameState.entities.CreateEntityAt(EntityId::FromUnderlying(100)); + EXPECT_EQ(entity2, nullptr); +} + +// This test verifies that corrupted S6 files with duplicate EntityIndex values can be loaded without crashing. +TEST_F(EntityImportTests, S6ImportCorruptedDuplicateEntityIndicesDoesNotCrash) +{ + std::string testParkPath = TestData::GetParkPath("corrupted_duplicate_entity_indices.sv6"); + auto fs = FileStream(testParkPath, FileMode::open); + + auto& objManager = context->GetObjectManager(); + auto importer = ParkImporter::CreateS6(context->GetObjectRepository()); + auto loadResult = importer->LoadFromStream(&fs, false); + objManager.LoadObjects(loadResult.RequiredObjects); + + MapAnimations::ClearAll(); + auto& gameState = getGameState(); + + // This should not crash because the code should sanitize EntityIndex values before CreateEntityAt is called + EXPECT_NO_THROW(importer->Import(gameState)); +} diff --git a/test/tests/Pathfinding.cpp b/test/tests/Pathfinding.cpp index 4c81ae4060..f2da960d27 100644 --- a/test/tests/Pathfinding.cpp +++ b/test/tests/Pathfinding.cpp @@ -104,7 +104,7 @@ protected: // elapsed. Each step, check that the tile they are standing on is not marked as forbidden in the test data // (red neon ground type). int step = 0; - while (!(*pos == goal) && step < expectedSteps) + while (*pos != goal && step < expectedSteps) { peep->PerformNextAction(); ++step; diff --git a/test/tests/PlayTests.cpp b/test/tests/PlayTests.cpp index 330d2e2f23..433f1fb821 100644 --- a/test/tests/PlayTests.cpp +++ b/test/tests/PlayTests.cpp @@ -16,10 +16,11 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/test/tests/S6ImportExportTests.cpp b/test/tests/S6ImportExportTests.cpp index 774edce680..3b2f2b1369 100644 --- a/test/tests/S6ImportExportTests.cpp +++ b/test/tests/S6ImportExportTests.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include using namespace OpenRCT2; diff --git a/test/tests/StringTest.cpp b/test/tests/StringTest.cpp index 7a30610fd9..e97f86020c 100644 --- a/test/tests/StringTest.cpp +++ b/test/tests/StringTest.cpp @@ -255,10 +255,12 @@ TEST_F(CodepointViewTest, CodepointView_iterate) TEST_F(StringTest, LogicalCompare) { + // Strings starting with digits come first, sorted numerically + // Then alphabetic strings sorted case-insensitively std::vector expected = { - "1001 Troubles", "3D Cinema 1", "Aerial Cycles", "Batflyer", "bpb", - "bpb.sv6", "Drive-by", "foo", "foobar", "Guest 10", - "Guest 99", "Guest 100", "John v2.0", "John v2.1", "River of the Damned", + "3D Cinema 1", "1001 Troubles", "Aerial Cycles", "Batflyer", "bpb", + "bpb.sv6", "Drive-by", "foo", "foobar", "Guest 10", + "Guest 99", "Guest 100", "John v2.0", "John v2.1", "River of the Damned", "Terror-dactyl", }; diff --git a/test/tests/testdata/parks/corrupted_duplicate_entity_indices.sv6 b/test/tests/testdata/parks/corrupted_duplicate_entity_indices.sv6 new file mode 100644 index 0000000000..46e72a87da Binary files /dev/null and b/test/tests/testdata/parks/corrupted_duplicate_entity_indices.sv6 differ diff --git a/test/tests/tests.vcxproj b/test/tests/tests.vcxproj index c79eab00b2..b327d8798c 100644 --- a/test/tests/tests.vcxproj +++ b/test/tests/tests.vcxproj @@ -59,6 +59,9 @@ GTEST_LANG_CXX11;%(PreprocessorDefinitions) + Use + tests_pch.h + tests_pch.h libopenrct2.lib;%(AdditionalDependencies) @@ -76,6 +79,7 @@ + @@ -95,12 +99,16 @@ + + + Create + @@ -118,4 +126,5 @@ - \ No newline at end of file + + diff --git a/test/tests/tests_pch.cpp b/test/tests/tests_pch.cpp new file mode 100644 index 0000000000..f59bda8635 --- /dev/null +++ b/test/tests/tests_pch.cpp @@ -0,0 +1,2 @@ +// Empty file for MSVC's PCH +// Do not include the header file - it is set up with MSVC solution diff --git a/test/tests/tests_pch.h b/test/tests/tests_pch.h new file mode 100644 index 0000000000..9df68d8660 --- /dev/null +++ b/test/tests/tests_pch.h @@ -0,0 +1,11 @@ +#pragma once + +// Precompiled header for tests project + +// GTest headers +#include + +// Standard library headers +#include +#include +#include