Skip to main content
Verticopolis engineGitHub

Module frame

Module frame 

Source
Expand description

The flat frame: everything a renderer reads each frame, as one Vec<f64> (frame_view), and the new log messages (log_since).

Read the frame by slot name, never by bare index: header names the header slots, person, unit, transport and car the slots of each record, and FRAME_HEADER, PERSON_FIXED, UNIT_RECORD, TRANSPORT_FIXED and CAR_RECORD the widths. frame_view says what each value means. The JavaScript binding hands over the same frame as one Float64Array.

crate::view is the newer read path: it sends only the rooms that changed since the last frame, plus a structural snapshot for the floors and shafts. Both read the same simulation.

use verticopolis_engine::clock::GameMode;
use verticopolis_engine::frame::{frame_view, header, FRAME_LAYOUT_VERSION};
use verticopolis_engine::sim::{Simulation, STARTING_MONEY};

let sim = Simulation::new_game(1, GameMode::Classic);
let frame = frame_view(&sim);
assert_eq!(frame[header::MONEY], STARTING_MONEY);
assert_eq!(frame[header::PEOPLE], 0.0);

Modules§

car
The slots of one car in a transport record, counted from the car’s start.
header
The header slots of the frame view by name, so a native decoder reads v[header::MONEY] instead of a bare index. A group of values starts at its named slot: EXPLOSION_FX is seq, floor, x; THIEF_FX is seq, caught, floor; TREASURE_FX is seq, floor, x; EVENT_COUNTS is fires, firesGutRooms, bombs. frame_view describes each value.
person
The fixed slots of a person record by name, counted from the record’s start. The route follows them: FLOOR_COUNT floors, then SHAFT_COUNT shafts.
transport
The slots of a transport record by name: ID and CARS, then CARS car records of CAR_RECORD slots, each laid out as car.
unit
The slots of a unit record by name.

Constants§

CAR_RECORD
Slots of each car in a transport record.
FRAME_HEADER
Fixed header slots of the frame view, before the three variable sections.
FRAME_LAYOUT_VERSION
The version of the frame’s layout, also in crate::identity::identity. It goes up when a slot moves, a record’s width changes, or a slot or code changes meaning, so a decoder can refuse a layout it was not written for.
PERSON_FIXED
Fixed slots of a person record, before its route (floors then shafts).
TRANSPORT_FIXED
Slots of a transport record before its cars.
UNIT_RECORD
Slots of a unit record.
UNKNOWN_ROUTINE
The routine code for a routine this layout has no code for yet. A decoder should refuse a frame that carries it: the engine has gained a routine the decoder does not know.

Functions§

frame_view
The frame: every value a renderer reads between two structural reads, flat, so it crosses to another language as one array of numbers.
log_since
The log messages numbered after seq, oldest first, as JSON. The newest message’s number is the frame’s header::LOG_SEQ, so a host passes the last number it showed and gets only the new ones.