Skip to main content
Verticopolis engine

Module save_floor_runs

Module save_floor_runs 

Source
Expand description

Floor tiles written as runs (save version 11).

Most of a built tower’s units are plain floor tiles: a large Modern tower lists about 19,000 of them, each one {"id":43,"kind":"floor","floor":2,"x":167}, and they were about 70% of its save. From version 11 the writer folds a row of them into the first tile’s entry with a run count: {"id":43,"kind":"floor","floor":2,"x":167,"run":60} stands for 60 tiles on floor 2, at x 167 to 226, with ids 43 to 102.

A run only takes tiles that sit next to each other in the unit list, one tile to the right and one id up from the tile before, and whose save entry holds nothing but id, kind, floor and x. So unfolding a run in place gives back exactly the list a version 10 writer would have written, in the same order, with the same ids. The loader unfolds it (load::floor_runs).

Constants§

FLOOR_RUN_KEY
The key on a run’s first floor tile: how many tiles the run holds.
FLOOR_RUN_SAVE_VERSION
The save version that first writes floor runs. A build from before it would read a run as its first tile alone, so it refuses the save instead.