Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/mechanics/track.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ Testing -> Closed if train crashes, stalls > N s, or exceeds time budget -> show
Open: continue refining max values from real runs with slow decay of stale test data; recompute ratings every ~N ticks
```

### 2.8 Editing from a selected piece

What public sources describe:
- The construction window has next/previous track segment arrows that step the highlighted (selected) piece through the placed track, and right-clicking a placed segment selects it. The bulldozer removes the piece just built at the end, or the highlighted piece when one in the middle is selected. [S] (RCT2 manual p.38, https://archive.org/details/rct_2_manual)
- A ride must be closed before its track can be worked on. [S] (RCT2 manual pp.38-39)
- Deleting pieces from the middle leaves separate track sections that have to be joined up again before the ride can open; an incomplete circuit cannot be opened. [S, S] (https://forums.openrct2.org/topic/582-starting-a-new-track-section, https://forums.openrct2.org/topic/3504-forcing-a-ride-open-non-complete-circuit)
- After deleting pieces the construction arrow moves to a remaining open end rather than staying at the deleted spot. [S] (https://www.openrct2.io/download/changelog)
- Deleting a station in the middle of a platform can leave one platform that behaves as two stations. [S] (https://forums.openrct2.org/topic/5355-guests-never-leave-rollercoastersingle-station-seen-as-two-stations)

What OpenCoaster does (our own design inspired by the above; **[I]**):
- A ride's track is one or more open sections or a single closed ring. Any piece can be demolished; removing a middle piece splits its section, or opens a closed circuit at that point. A placement may continue any section's last piece and lead into any section's first piece, joining sections. The ride only counts as a complete circuit when all of its track forms one ring with a station.
- The construction window keeps a selected piece (editor state only, never saved). Previous piece / Next piece step along the track, clicking rails in the build tool selects that piece, and the ride window offers Edit from this piece when it was opened from a rail. Build piece continues from the selection's open end; Build before this piece extends a section backward from its first piece. Demolish removes the selected piece, and the selection moves to its neighbour, preferring the previous one.
- Track can only change on a ride that is closed with its trains home and empty: not while open or testing, while a train is loading, running or unloading, or while riders are aboard. The edit is refused rather than force-closing the ride.
- After a demolition, an entrance or exit with no station tile beside it any more is detached from the ride; the ride needs a new one before it can open.
- Difference from the original: removing a piece gives no per-piece refund. Demolishing the whole ride refunds the pieces that remain.

---

## 3. Data model proposal
Expand Down Expand Up @@ -262,6 +278,11 @@ Sources:
- https://rctv1.rctspace.com/test/info/tips2.html
- https://tid.rctspace.com/TD4viewer.html
- https://rct.fandom.com/wiki/Inverted_Hairpin_Coaster
- https://archive.org/details/rct_2_manual (pp.38-39, track editing)
- https://forums.openrct2.org/topic/582-starting-a-new-track-section
- https://forums.openrct2.org/topic/3504-forcing-a-ride-open-non-complete-circuit
- https://www.openrct2.io/download/changelog
- https://forums.openrct2.org/topic/5355-guests-never-leave-rollercoastersingle-station-seen-as-two-stations

### Tunnel portals: what the original game does and what we do

Expand Down
1 change: 1 addition & 0 deletions e2e/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Path: @/e2e
- [observation-tower-height.spec.ts](observation-tower-height.spec.ts) builds towers of chosen height through the placement controls (helpers in [support/tower.ts](support/tower.ts)), checks section prices, edits a closed tower's height from its window, and samples a test run for one climb, one descent and a steady cabin speed. [observation-tower-proof.spec.ts](observation-tower-proof.spec.ts) runs only when `TOWER_PROOF_DIR` is set and writes the PR proof (screenshots in every rotation for WebGL2 and Canvas2D, a phone check, a 1x video, timing JSON).
- [flat-ride-footprints.spec.ts](flat-ride-footprints.spec.ts) builds all ride types through the UI on a flat street site and checks the placement ghost, allowed entrance ring, entrance and exit placement, open state, and footprint visibility in all four camera rotations. Swinging Ship, Ferris Wheel and Top Spin also exercise every ride orientation. Only the Merry-Go-Round waits for guests to ride and captures the served state; this keeps the full footprint matrix while avoiding repeated long guest simulations. Forced Canvas2D checks representative 3x3 square (Twist), elongated (Swinging Ship), and single-tile/tall-art (Observation Tower) footprints. The spec settles screenshots and guest-serving checks with simulation-tick polling and rendered-state assertions instead of fixed delays. A Pixel 8 case checks the Rotate ride button clears the HUD. Set `FOOTPRINT_SHOTS_DIR` to write the JPEG sheets (committed under docs/playtest/assets/footprints) instead of the test output folder.
- [track-heights.spec.ts](track-heights.spec.ts) imports a flat owned park and, through the construction window only, builds a Steel Looping Coaster whose station end and far side sit one land level apart, checking the `Track end at height N` line through each half-level step of the climb and descent, and closes the circuit. Set `TRACK_HEIGHTS_PROOF_DIR` to write screenshots of the circuit in each rotation.
- [track-edit-selection.spec.ts](track-edit-selection.spec.ts) runs on desktop and emulated Pixel 8 under both WebGL2 and Canvas2D, importing a save from [support/track-edit-park.ts](support/track-edit-park.ts) (a closed tested circuit, plus an unfinished coaster crossed by another ride's overpass). It opens a ride window from a clicked rail and uses Edit from this piece, steps with Previous/Next piece, demolishes a middle piece and rebuilds it to close, test and reopen the circuit, checks an open ride refuses edits, selects stacked rails of two rides by click or tap, builds before a section's first piece, returns to Track end, and checks the selection outline sits over the clicked piece.
- [art-review.spec.ts](art-review.spec.ts) compares default-zoom facility renders against the same scene without the facility, requiring a minimum visible-pixel area in both backends, and captures a populated context scene in all rotations. It also builds completed coaster and transport rides through the simulation's `createCoaster` and `placeTrack` command path, then renders their snapshots with the production Canvas2D and WebGL2 renderers. It verifies that each placed track piece resolves to generated art with opaque pixels and that the rendered canvas has no red fallback marker; optional capture output includes inventory sheets and per-ride images. The fixture imports [sprite-pages.ts](../src/render/sprite-pages.ts) by its canonical module URL so lazy page loads are visible to the renderer's shared sprite store.
- [p1-ui-fidelity.spec.ts](p1-ui-fidelity.spec.ts) requires the desktop canvas to use WebGL2, checks populated ride windows avoid status bar and pointer overlap, validates compact coaster controls, builds while paused, checks the 2× construction cap and ride preview, verifies saved desktop window placement, and exercises ownership UI. The ride-access Pixel 8 scenario checks the construction controls fit the mobile viewport and uses touch to build.
- [ride-breakdown-proof.spec.ts](ride-breakdown-proof.spec.ts) captures both a forced breakdown with a mechanic en route and a separate naturally rolled breakdown. The natural seeded scene in [support/breakdown-scene.ts](support/breakdown-scene.ts) advances until reliability has fallen and rolling downtime is nonzero; its Maintenance screenshot documents those live values.
Expand Down
73 changes: 73 additions & 0 deletions e2e/support/track-edit-park.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { TRACK_STEPS_PER_LEVEL } from '../../src/sim/core/constants';
import type { Simulation } from '../../src/sim/core/simulation';
import { RideType } from '../../src/sim/rides/ride-types';
import {
GROUND,
buildCircuit,
connectStation,
createCoaster,
flatOwnedSim,
run,
} from '../../src/sim/rides/coaster-fixtures';
import { pieceByName } from '../../src/sim/track/catalog';
import { getConstructionCursor } from '../../src/sim/track/construction';
import { PieceMode } from '../../src/sim/track/track-types';
import { serialize } from '../../src/save/save';

/** Unfinished coaster: station then straights running +x from this tile at ground level. */
export const UNFINISHED_START = { x: 8, y: 36 };
export const UNFINISHED_PIECES = ['station', 'flat', 'flat', 'flat', 'flat', 'flat', 'flat'];
/** Overpass: straights running +y across the unfinished coaster's fourth piece, four levels up. */
export const OVERPASS_START = { x: 11, y: 33 };
export const OVERPASS_LEVELS = 4;

function line(
sim: Simulation,
rideId: number,
names: readonly string[],
start: { x: number; y: number },
level: number,
dir: number,
): void {
for (const name of names) {
const cursor = getConstructionCursor(sim.world, rideId);
sim.enqueue({
type: 'placeTrack',
rideId,
pieceType: pieceByName(name)!.id,
x: cursor.hasTrack ? cursor.x : start.x,
y: cursor.hasTrack ? cursor.y : start.y,
z: cursor.hasTrack ? cursor.z : level * TRACK_STEPS_PER_LEVEL,
dir: cursor.hasTrack ? cursor.dir : dir,
mode: PieceMode.Normal,
});
sim.step();
}
}

/**
* A paused-friendly park for track editing: a tested, closed coaster with its entrance and exit
* (ride 1), an unfinished coaster (ride 2), and a second unfinished coaster passing over ride 2's
* track four levels up (ride 3).
*/
export function trackEditPark(): Uint8Array {
const sim = flatOwnedSim(1);
const circuit = createCoaster(sim, RideType.WoodenCoaster);
buildCircuit(sim, circuit);
connectStation(sim, circuit);
sim.enqueue({ type: 'setRideStatus', rideId: circuit, status: 'test' });
run(sim, 8000);
const unfinished = createCoaster(sim, RideType.WoodenCoaster, 4, 40);
line(sim, unfinished, UNFINISHED_PIECES, UNFINISHED_START, GROUND, 0);
const overpass = createCoaster(sim, RideType.WoodenCoaster, 4, 44);
line(
sim,
overpass,
['flat', 'flat', 'flat', 'flat', 'flat', 'flat'],
OVERPASS_START,
GROUND + OVERPASS_LEVELS,
1,
);
run(sim, 10);
return serialize(sim.world);
}
Loading
Loading