From 1634a4b3caf6cd481b47983f0d996d3bc1783737 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Fri, 4 Dec 2026 20:33:21 +0100 Subject: [PATCH] Make browser build playable and serve it from Ceph S3 --- .gitignore | 7 +++ CMakeLists.txt | 4 ++ deploy/README.md | 57 +++++++++++++++++++ deploy/bucket-policy.json | 12 ++++ deploy/publish.sh | 40 ++++++++++++++ deploy/route.yaml | 64 ++++++++++++++++++++++ deploy/s3-user.yaml | 10 ++++ emscripten/deps.js | 7 ++- rosebud/docker/Dockerfile | 2 + rosebud/docker/build-depends.sh | 14 ++++- rosebud/serve.py | 1 + rosebud/static/changelog.txt | 32 +++++++++++ rosebud/static/index.html | 3 +- rosebud/static/index.js | 13 +++-- rosebud/static/jszip.min.js | 13 +++++ scripts/build-emscripten | 4 +- scripts/patch-browser-title-sequence.py | 38 +++++++++++++ src/openrct2-ui/windows/ScenarioSelect.cpp | 6 ++ src/openrct2-ui/windows/TitleMenu.cpp | 3 + src/openrct2/Context.cpp | 8 +++ src/openrct2/core/JobPool.cpp | 4 +- start-web.sh | 4 ++ 22 files changed, 332 insertions(+), 14 deletions(-) create mode 100644 deploy/README.md create mode 100644 deploy/bucket-policy.json create mode 100755 deploy/publish.sh create mode 100644 deploy/route.yaml create mode 100644 deploy/s3-user.yaml create mode 100644 rosebud/static/changelog.txt create mode 100644 rosebud/static/jszip.min.js create mode 100644 scripts/patch-browser-title-sequence.py create mode 100755 start-web.sh diff --git a/.gitignore b/.gitignore index 87961bb4b4..94a55af9d3 100644 --- a/.gitignore +++ b/.gitignore @@ -327,3 +327,10 @@ discord-rpc # CMake cmake-build-*/ + +# Local browser bundles and purchased game data +assets.zip +assets-*.zip +rct2-content.zip +web-assets/ +web-assets-v0431/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a79fe8893d..521b04ba9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,6 +344,10 @@ else () # Compiler flags set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 0–3.") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstrict-aliasing -Werror -Wundef -Wmissing-declarations -Winit-self -Wall -Wextra -Wshadow") + if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "16") + OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") + endif () set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas -Wno-missing-braces -Wno-comment -Wnonnull -Wno-unused-parameter -Wno-attributes") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}") diff --git a/deploy/README.md b/deploy/README.md new file mode 100644 index 0000000000..ce6e1026c7 --- /dev/null +++ b/deploy/README.md @@ -0,0 +1,57 @@ +# OpenRCT2 browser deployment + +This deployment serves the locally built browser files from the homelab Ceph +object gateway. Traefik supplies HTTPS and the response headers needed by the +WebAssembly thread build. There is no game container or CI pipeline. + +## Rebuild on the laptop + +The Emscripten build uses the fork's pinned build container and the browser +page in `rosebud/static`: + +```sh +./rosebud/docker/clone-deps.sh +podman build -t openrct2-emscripten-local -f rosebud/docker/Dockerfile rosebud/docker +podman run --rm -v "$PWD:/src" -w /src localhost/openrct2-emscripten-local:latest bash ./scripts/build-emscripten +``` + +Bundle the matching installed OpenRCT2 assets and your Steam RCT2 files. Run +these commands from the repository root: + +```sh +repo_root="$PWD" +steam_rct2="$HOME/.steam/steam/steamapps/common/Rollercoaster Tycoon 2" +rm -f build/www/assets.zip build/www/rct2-content.zip +(cd /usr/share/openrct2 && zip -qr "$repo_root/build/www/assets.zip" assetpack fonts.dat g2.dat language object palettes.dat scenario_patches sequence shaders tracks.dat) +python3 scripts/patch-browser-title-sequence.py +(cd "$steam_rct2" && zip -qr "$repo_root/build/www/rct2-content.zip" Data ObjData Scenarios Tracks 'Saved Games') +``` + +The title sequence patch keeps the title park from cycling into a blocking +park load in this browser build. The `build/www` directory is the upload source. + +## Deploy + +1. Build the browser game locally. Put the purchased RCT2 game resources in + `build/www/rct2-content.zip`; `assets.zip` and the engine files must also be + present in `build/www/`. +2. With the homelab Kubernetes context selected, create the dedicated S3 user: + `kubectl apply -f deploy/s3-user.yaml`. Wait for it to be ready and for + `rook-ceph-object-user-my-store-openrct2-publisher` to appear in `rook-ceph`. +3. Run `./deploy/publish.sh` from the repository. It reads the Rook-generated + credentials into environment variables for `rclone`, creates the + `openrct2-web` bucket, dry-runs and performs `rclone sync`, and applies a + public-read policy. It does not write credentials into the repository or + rclone configuration. +4. Apply the route with `kubectl apply -f deploy/route.yaml`. ExternalDNS + creates the `rct.brunner.ninja` DNS record. Open + `https://rct.brunner.ninja/` in Brave. + +The public-read policy grants only object reads, so a browser can download the +game files but cannot list or change the bucket. `rct2-content.zip` includes +assets from the purchased game and is publicly downloadable at this address. +Do not commit it, `assets.zip`, or generated `build/` and `dist/` folders. + +For a later update, rebuild locally and rerun `deploy/publish.sh` before +reapplying the route only if its configuration changed. `rclone sync` deletes +objects that no longer appear in `build/www/`; review its dry run output. diff --git a/deploy/bucket-policy.json b/deploy/bucket-policy.json new file mode 100644 index 0000000000..bc823b0c79 --- /dev/null +++ b/deploy/bucket-policy.json @@ -0,0 +1,12 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "ReadGameFiles", + "Effect": "Allow", + "Principal": "*", + "Action": "s3:GetObject", + "Resource": "arn:aws:s3:::openrct2-web/*" + } + ] +} diff --git a/deploy/publish.sh b/deploy/publish.sh new file mode 100755 index 0000000000..2496589e65 --- /dev/null +++ b/deploy/publish.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "$0")/.." && pwd)" +site_dir="$repo_root/build/www" +bucket="openrct2-web" +endpoint="https://s3.brunner.ninja" +secret="rook-ceph-object-user-my-store-openrct2-publisher" + +if [[ ! -s "$site_dir/index.html" || ! -s "$site_dir/rct2-content.zip" || ! -s "$site_dir/assets.zip" ]]; then + echo "Missing browser build or game resources in $site_dir" >&2 + exit 1 +fi + +if [[ "$(kubectl config current-context)" != "kubernetes-admin@kubernetes" ]]; then + echo "Expected homelab Kubernetes context" >&2 + exit 1 +fi + +export RCLONE_CONFIG_RCT_TYPE=s3 +export RCLONE_CONFIG_RCT_PROVIDER=Ceph +export RCLONE_CONFIG_RCT_ENV_AUTH=false +export RCLONE_CONFIG_RCT_ENDPOINT="$endpoint" +export RCLONE_CONFIG_RCT_ACCESS_KEY_ID +export RCLONE_CONFIG_RCT_SECRET_ACCESS_KEY +RCLONE_CONFIG_RCT_ACCESS_KEY_ID="$(kubectl -n rook-ceph get secret "$secret" -o go-template='{{index .data "AccessKey"}}' | base64 -d)" +RCLONE_CONFIG_RCT_SECRET_ACCESS_KEY="$(kubectl -n rook-ceph get secret "$secret" -o go-template='{{index .data "SecretKey"}}' | base64 -d)" + +export AWS_ACCESS_KEY_ID="$RCLONE_CONFIG_RCT_ACCESS_KEY_ID" +export AWS_SECRET_ACCESS_KEY="$RCLONE_CONFIG_RCT_SECRET_ACCESS_KEY" +export AWS_DEFAULT_REGION=us-east-1 + +rclone mkdir "rct:$bucket" +rclone sync --dry-run "$site_dir/" "rct:$bucket/" +rclone sync --progress "$site_dir/" "rct:$bucket/" +aws --endpoint-url "$endpoint" s3api put-bucket-policy \ + --bucket "$bucket" \ + --policy "file://$repo_root/deploy/bucket-policy.json" + +echo "Published $(rclone lsf "rct:$bucket/" | wc -l) top-level files to $bucket" diff --git a/deploy/route.yaml b/deploy/route.yaml new file mode 100644 index 0000000000..ae903898ef --- /dev/null +++ b/deploy/route.yaml @@ -0,0 +1,64 @@ +apiVersion: traefik.io/v1alpha1 +kind: Middleware +metadata: + name: openrct2-index + namespace: rook-ceph +spec: + replacePath: + path: /openrct2-web/index.html +--- +apiVersion: traefik.io/v1alpha1 +kind: Middleware +metadata: + name: openrct2-files + namespace: rook-ceph +spec: + addPrefix: + prefix: /openrct2-web +--- +apiVersion: traefik.io/v1alpha1 +kind: Middleware +metadata: + name: openrct2-browser-headers + namespace: rook-ceph +spec: + headers: + customResponseHeaders: + Cross-Origin-Opener-Policy: same-origin + Cross-Origin-Embedder-Policy: require-corp + Cross-Origin-Resource-Policy: cross-origin + Cache-Control: no-cache +--- +apiVersion: traefik.io/v1alpha1 +kind: IngressRoute +metadata: + name: openrct2 + namespace: rook-ceph + annotations: + external-dns.brunner.ninja/enabled: "true" + external-dns.kubernetes.io/target: brunner.ninja +spec: + entryPoints: + - websecure + routes: + - kind: Rule + match: Host(`rct.brunner.ninja`) && Path(`/`) + priority: 100 + middlewares: + - name: openrct2-index + - name: openrct2-browser-headers + services: + - name: rook-ceph-rgw-my-store + port: 80 + passHostHeader: false + - kind: Rule + match: Host(`rct.brunner.ninja`) && PathPrefix(`/`) + priority: 10 + middlewares: + - name: openrct2-files + - name: openrct2-browser-headers + services: + - name: rook-ceph-rgw-my-store + port: 80 + passHostHeader: false + tls: {} diff --git a/deploy/s3-user.yaml b/deploy/s3-user.yaml new file mode 100644 index 0000000000..a7a5ebbbbf --- /dev/null +++ b/deploy/s3-user.yaml @@ -0,0 +1,10 @@ +apiVersion: ceph.rook.io/v1 +kind: CephObjectStoreUser +metadata: + name: openrct2-publisher + namespace: rook-ceph + labels: + app.kubernetes.io/name: openrct2-web +spec: + store: my-store + displayName: OpenRCT2 web publisher diff --git a/emscripten/deps.js b/emscripten/deps.js index cc5a6691b5..d625f823bc 100644 --- a/emscripten/deps.js +++ b/emscripten/deps.js @@ -258,8 +258,11 @@ var EmscriptenDeps = { GetLocaleCurrencyCode: () => { // There is no way to get this directly from javascript! Assume based off of user country const localeToCurrencyMap = {AD:"EUR",AE:"AED",AF:"AFN",AG:"XCD",AI:"XCD",AL:"ALL",AM:"AMD",AN:"ANG",AO:"AOA",AQ:"USD",AR:"ARS",AS:"USD",AT:"EUR",AU:"AUD",AW:"AWG",AX:"EUR",AZ:"AZN",BA:"BAM",BB:"BBD",BD:"BDT",BE:"EUR",BF:"XOF",BG:"BGN",BH:"BHD",BI:"BIF",BJ:"XOF",BL:"EUR",BM:"BMD",BN:"BND",BO:"BOB",BQ:"USD",BR:"BRL",BS:"BSD",BT:"BTN",BV:"NOK",BW:"BWP",BY:"BYN",BZ:"BZD",CA:"CAD",CC:"AUD",CD:"CDF",CF:"XAF",CG:"XAF",CH:"CHF",CI:"XOF",CK:"NZD",CL:"CLP",CM:"XAF",CN:"CNY",CO:"COP",CR:"CRC",CU:"CUP",CV:"CVE",CW:"ANG",CX:"AUD",CY:"EUR",CZ:"CZK",DE:"EUR",DJ:"DJF",DK:"DKK",DM:"XCD",DO:"DOP",DZ:"DZD",EC:"USD",EE:"EUR",EG:"EGP",EH:"MAD",ER:"ERN",ES:"EUR",ET:"ETB",FI:"EUR",FJ:"FJD",FK:"FKP",FM:"USD",FO:"DKK",FR:"EUR",GA:"XAF",GB:"GBP",GD:"XCD",GE:"GEL",GF:"EUR",GG:"GBP",GH:"GHS",GI:"GIP",GL:"DKK",GM:"GMD",GN:"GNF",GP:"EUR",GQ:"XAF",GR:"EUR",GS:"FKP",GT:"GTQ",GU:"USD",GW:"XOF",GY:"GYD",HK:"HKD",HM:"AUD",HN:"HNL",HR:"EUR",HT:"HTG",HU:"HUF",ID:"IDR",IE:"EUR",IL:"ILS",IM:"GBP",IN:"INR",IO:"USD",IQ:"IQD",IR:"IRR",IS:"ISK",IT:"EUR",JE:"GBP",JM:"JMD",JO:"JOD",JP:"JPY",KE:"KES",KG:"KGS",KH:"KHR",KI:"AUD",KM:"KMF",KN:"XCD",KP:"KPW",KR:"KRW",KW:"KWD",KY:"KYD",KZ:"KZT",LA:"LAK",LB:"LBP",LC:"XCD",LI:"CHF",LK:"LKR",LR:"LRD",LS:"LSL",LT:"EUR",LU:"EUR",LV:"EUR",LY:"LYD",MA:"MAD",MC:"EUR",MD:"MDL",ME:"EUR",MF:"EUR",MG:"MGA",MH:"USD",MK:"MKD",ML:"XOF",MM:"MMK",MN:"MNT",MO:"MOP",MP:"USD",MQ:"EUR",MR:"MRU",MS:"XCD",MT:"EUR",MU:"MUR",MV:"MVR",MW:"MWK",MX:"MXN",MY:"MYR",MZ:"MZN",NA:"NAD",NC:"XPF",NE:"XOF",NF:"AUD",NG:"NGN",NI:"NIO",NL:"EUR",NO:"NOK",NP:"NPR",NR:"AUD",NU:"NZD",NZ:"NZD",OM:"OMR",PA:"PAB",PE:"PEN",PF:"XPF",PG:"PGK",PH:"PHP",PK:"PKR",PL:"PLN",PM:"EUR",PN:"NZD",PR:"USD",PS:"ILS",PT:"EUR",PW:"USD",PY:"PYG",QA:"QAR",RE:"EUR",RO:"RON",RS:"RSD",RU:"RUB",RW:"RWF",SA:"SAR",SB:"SBD",SC:"SCR",SD:"SDG",SE:"SEK",SG:"SGD",SH:"SHP",SI:"EUR",SJ:"NOK",SK:"EUR",SL:"SLE",SM:"EUR",SN:"XOF",SO:"SOS",SR:"SRD",SS:"SSP",ST:"STN",SV:"USD",SX:"ANG",SY:"SYP",SZ:"SZL",TC:"USD",TD:"XAF",TF:"EUR",TG:"XOF",TH:"THB",TJ:"TJS",TK:"NZD",TL:"USD",TM:"TMT",TN:"TND",TO:"TOP",TR:"TRY",TT:"TTD",TV:"AUD",TW:"TWD",TZ:"TZS",UA:"UAH",UG:"UGX",UM:"USD",US:"USD",UY:"UYU",UZ:"UZS",VA:"EUR",VC:"XCD",VE:"VED",VG:"USD",VI:"USD",VN:"VND",VU:"VUV",WF:"XPF",WS:"WST",XK:"EUR",YE:"YER",YT:"EUR",ZA:"ZAR",ZM:"ZMW",ZW:"ZWG"}; - const country = Intl.DateTimeFormat().resolvedOptions().locale.split("-").pop(); - const code = localeToCurrencyMap[country]; + const locale = Intl.DateTimeFormat().resolvedOptions().locale; + const country = new Intl.Locale(locale).region; + // Language-only locales (such as "en") have no country, so the lookup + // must always supply a valid string to Emscripten's UTF-8 conversion. + const code = localeToCurrencyMap[country] || "USD"; return stringToNewUTF8(code); } }; diff --git a/rosebud/docker/Dockerfile b/rosebud/docker/Dockerfile index 64c6593dd8..5f2827f4ef 100644 --- a/rosebud/docker/Dockerfile +++ b/rosebud/docker/Dockerfile @@ -7,6 +7,8 @@ RUN dnf update -y && dnf install -y \ bzip2-devel \ ccache \ cmake \ + diffutils \ + gcc-c++ \ git \ json-devel \ libicu-devel \ diff --git a/rosebud/docker/build-depends.sh b/rosebud/docker/build-depends.sh index 280476fa92..9791c08220 100644 --- a/rosebud/docker/build-depends.sh +++ b/rosebud/docker/build-depends.sh @@ -10,12 +10,20 @@ cd $START_DIR cd speexdsp emmake ./autogen.sh -emmake ./configure --enable-shared --disable-neon +emmake ./configure --host=wasm32-unknown-emscripten --enable-shared --disable-neon emmake make -j$(nproc) cd $START_DIR +mkdir -p icu-native +cd icu-native +../icu/icu4c/source/configure --enable-release --disable-tests --disable-samples --disable-extras --disable-layoutex +make -j"$(nproc)" +cd $START_DIR + cd icu/icu4c/source ac_cv_namespace_ok=yes icu_cv_host_frag=mh-linux emmake ./configure \ + --host=wasm32-unknown-emscripten \ + --with-cross-build=/ext/icu-native \ --enable-release \ --enable-shared \ --disable-icu-config \ @@ -25,7 +33,9 @@ ac_cv_namespace_ok=yes icu_cv_host_frag=mh-linux emmake ./configure \ --disable-tools \ --disable-tests \ --disable-samples -emmake make -j$(nproc) +mkdir -p lib +emmake make -C stubdata -j"$(nproc)" +emmake make -C common -j"$(nproc)" cd $START_DIR cd zlib diff --git a/rosebud/serve.py b/rosebud/serve.py index f8a4fd2ef4..0d32408407 100644 --- a/rosebud/serve.py +++ b/rosebud/serve.py @@ -12,6 +12,7 @@ class CrossOriginIsolatedHandler(SimpleHTTPRequestHandler): self.send_header("Cross-Origin-Opener-Policy", "same-origin") self.send_header("Cross-Origin-Embedder-Policy", "require-corp") self.send_header("Cross-Origin-Resource-Policy", "cross-origin") + self.send_header("Cache-Control", "no-cache") super().end_headers() diff --git a/rosebud/static/changelog.txt b/rosebud/static/changelog.txt new file mode 100644 index 0000000000..d7493f7a9f --- /dev/null +++ b/rosebud/static/changelog.txt @@ -0,0 +1,32 @@ +0.4.31 (2026-02-01) +------------------------------------------------------------------------ +- Feature: [#25844] The sprite builder now also supports adding JSON-based palettes. +- Improved: [#3788] Self-intersecting track designs can now be placed. +- Improved: [#25719] The weather change dropdown now shows icons next to the weather types for easier selection. +- Improved: [#25765] The ‘View options’ and ‘Special track elements’ dropdowns no longer need click-and-hold. +- Improved: [#25858] macOS now supports the onboarding menu. +- Improved: [#25882] Maze construction now auto-removes trees. +- Improved: [objects#421] The vehicle tab of some rides now shows more of the vehicle. +- Change: [#25018] Add upkeep cost to booster pieces. +- Fix: [#4643, #25167] Many metal supports draw with a filled in top when they didn’t in vanilla, causing some slight misalignment and glitching. +- Fix: [#15009] Landscaping tools do not display estimates when the game is paused (original bug). +- Fix: [#18441] Replacing footpaths sometimes results in a spurious “Footpath in the way” error (original bug). +- Fix: [#20620] In-game console caret does not update when pasting. +- Fix: [#20652] Twister Roller Coaster design ‘u(0241)’ has no preview and cannot be built (bug in track design). +- Fix: [#23859] Wrong banner text displayed after loading a different park. +- Fix: [#25221] When trying to cancel game file discovery, the prompt reappears. +- Fix: [#25703, #25889] Crash when scanning scenarios with packed objects in parallel. +- Fix: [#25739] Game freezes when a tab in the New Ride window contains more than 384 items. +- Fix: [#25745] Crash when a player connection is aborted early. +- Fix: [#25775] Network download sizes are in bytes instead of the listed kibibytes. +- Fix: [#25799] The animated options tab icon of the news window does not always redraw. +- Fix: [#25850] Guests do not have their happiness penalised by low energy, high hunger, high thirst, high toilet. +- Fix: [#25850] Ride nausea generation is different compared to vanilla. +- Fix: [#25854] When a guest is at 0 happiness or energy, the game draws too big of a bar in the guest stats window. +- Fix: [#25862] Diagonal and inclined brakes are not counted when calculating upkeep cost. +- Fix: [#25873] Repainting a banner in OpenRCT2-specific colours results in an error message. +- Fix: [#25879] Guest window viewport doesn’t follow vehicle when they board a ride. +- Fix: [#25908] Crash from use-after-free in banner text formatting during multithreaded rendering. +- Fix: [objects#419] Alignment of RCT2 red, yellow and green queue previews is off. +- Fix: [objects#424] Jet Aeroplane decor has a hole in it. +- Fix: [objects#425] Capacity of ‘Blob from outer space ride’ is incorrectly listed. diff --git a/rosebud/static/index.html b/rosebud/static/index.html index 948c937426..228b288245 100644 --- a/rosebud/static/index.html +++ b/rosebud/static/index.html @@ -2,8 +2,9 @@ OpenRCT2 + - +