Files
rijads 1ce01d4481 Import the game files from a browser on first start
When /app0/rct2/Data/g1.dat is missing, the title shows a screen with an address and a QR code
and receives the RollerCoaster Tycoon 2 folder from a PC or phone: src/port/upload.c (the DOOM
port's server, keeping subfolders now) stores each file below the game's own folders (Data,
ObjData, Scenarios, Tracks, Landscapes; every part a plain name) and takes a ZIP file of the
folder, which the screen unpacks with libzip. The screen draws with SDL and fonts rendered from
DejaVu Sans at build time (tools/make-font.py), since OpenRCT2 cannot draw before the game files
are there; it starts the game once they are complete.

tools/send.py sends a folder or a ZIP file the way the page does. Console test plans can point
the game at another folder (game) and remove test folders (remove); test/console-import.cfg
imports into /app0/rct2-import. On the console the screen worked and received the Data folder
before the PS5 went to rest; the transfer ran at 2.2 MB/s, so the server now asks for a 1 MiB
receive buffer and writes whole 256 KiB chunks.
2026-10-05 00:14:45 +02:00

19 lines
789 B
Python

#!/usr/bin/env python3
"""Writes a C header that holds a file's bytes as a static array: embed-file.py <file> <name> <header>.
The header is left alone when it would not change, so nothing that includes it is rebuilt."""
import sys
from pathlib import Path
source, name, header = sys.argv[1:]
data = Path(source).read_bytes()
lines = [f"/* Generated from {Path(source).name} by tools/embed-file.py. */",
f"static const unsigned char {name}[] = {{"]
for i in range(0, len(data), 20):
lines.append(" " + ", ".join(str(b) for b in data[i:i + 20]) + ",")
lines.append("};")
text = "\n".join(lines) + "\n"
target = Path(header)
if not target.exists() or target.read_text() != text:
target.parent.mkdir(parents=True, exist_ok=True)
target.write_text(text, newline="\n")