On a save with 2,700 lines on screen, Firefox spent about 95% of each
frame painting, and the dotted line on lit fiber (~160 ms) and the link
labels (~55 ms) were half of it, in a tangle where neither can be read.
draw() now counts the lines it would paint (linesOnScreen(), same box and
margin as its own culling, boxes cached on the geometry) and above
MAP_BUSY = 1000 leaves out both. They come back as soon as fewer lines
show, zooming in for instance. The selected link keeps its label.
Firefox Developer Edition headless, 1600x900 at DPR 2, player save, median
of 3x9 frames: save view 414 -> 214 ms, pan 472 -> 238, zoom 0.6 269 -> 181,
New York zoom 2 213 -> 107, selected link 412 -> 201. Under the threshold
pixels are identical (canvas SHA-1): zoom 3.2 and 6 on the player save, six
views of the big-network fixture.
S.usedNames only answers "was this name used?", but every offer pushed its
name again, also once all names were taken: a 5,500-day save holds 560,345
entries for 129 names, 11.8 of its 22.4 million characters. Names are now
added once (useName), and sanitize() drops duplicates from older saves.
Player save, 30 days from load, against main: routing and the whole state
except usedNames identical, usedNames identical as a set; save 22.4 -> 10.6
million characters, first save in Firefox 95 -> 55 ms, JSON.stringify 68 ->
42 ms. Still over Firefox's quota on this save.
A late-game save of ~22 million characters is over Firefox's localStorage
quota, so every save failed, yet the game rebuilt it with JSON.stringify(S)
every 5 seconds, every 10 days and after every action: ~95 ms each in
headless Firefox, 300-570 ms in a player's browser, all thrown away.
After a failed save the autosave now waits 1 minute before trying again,
then 2, 4, at most 5. A save that works resets this, so normal games still
save every time. Leaving the page, exporting, reloading for an update or a
language and a new game (a new S) still try at once.
Player save in Firefox: first save 95 ms as before, the next autosaves 0 ms.
draw() asked dfCap() three to five times per fiber link and per frame (width,
colour, label, up or down), each time over all its channels: on a save with
3,140 dark fibers of 18 channels on average that was about half of draw()'s
JavaScript. dfCap() now keeps its answers in DFC while one frame is drawn
(cleared in a finally, so a failed frame keeps nothing), and the link label is
built once per line instead of once per world copy. Links entirely above or
below the screen are skipped like those left or right of it already were.
Player save (202 POPs, 3,142 links), jsdom: draw() 40 -> 25 ms; perf-bench
"Map at three zoom levels" 89.7 -> 47.1 ms. Canvas call log identical at
every zoom without the vertical skip; Firefox pixels identical (SHA-1 of the
canvas) in 7 views. Firefox still spends ~95% of the frame painting.
compute(), the daily mood check and new alien-wave/fiber-pair offers asked
S.links.find() or S.biz.filter() once per customer or per link. On a save
with 2,950 links and 18,000 customers (16,000 alien waves) that was ~150 ms
per compute, ~250 ms more per day, and ~650 ms when a wave offer spawned.
linkIds() and fiberUse() build the lookups in one pass; fiberOk, bizSf,
soldSlots, freeCh and pairFree take them optionally, and give the same
answers as before (first link with the id wins, sums in S.biz order).
Player save (202 POPs, 2,958 links, 17,967 customers), median of 15:
compute 323 -> 124 ms, dayTick 545 -> 133 ms, after 356 -> 149 ms.
Big-network fixture: unchanged. Routing results identical to main.
tr('pnis.delivery_2_to_6_weeks') instead of tr('Delivery: 2 to 6 weeks'): the
English lives once, in src/i18n/en.js (inlined into the page at build, so no
extra request), and it/pt/fr map the same labels. Changing English wording no
longer renames a key in every dictionary.
- 2,899 labels, made from where each text is used and its first words; short
shared words are common.*
- plurals are one label with {one, other}: trn('label', n)
- static markup: data-i18n="label", data-i18n-aria-label, data-i18n-title
- saves from 1.33 and older stored English text in a few places; tr() still
resolves it
- i18n-check: undefined/unused labels, markup drift, plural shape; i18n-add.js
works on labels and --rename updates src/ too
- the old-branch port tool gives old English-keyed code and dictionaries the
same labels
- ACT is split by area into game/90-actions/*.js (const ACT in the first file,
Object.assign in the rest)
- CITY_LL, CITY_NUDGE and LANDS_LL have one entry per line; the id-keyed ones
are sorted
- site/i18n/*.js are sorted, one entry per line; i18n-check enforces it and
--fix (npm run i18n:fix) restores it; scripts/i18n-add.js adds, removes
and renames entries in place
- scripts/legacy/port-branch.js moves a branch's site/index.html edits into
src/ during a merge with main
- perf workflow and PR template build the base page with scripts/lib/page.js
site/index.html (900 KB of HTML, CSS and JS in one file) becomes src/: a shell
(src/index.html), styles/ and game/, concatenated in path order by
scripts/lib/page.js. The assembled page is byte-identical to the old file, so
load time and in-game performance are unchanged.
- scripts/build.js replaces build.sh (same env vars, same output)
- npm run dev: a zero-dependency dev server that assembles on every request
- tests assemble the page in memory; npm test runs every tests/*.test.js
- perf-bench takes --base-ref to build a git ref's page
- scripts/legacy/split-index-html.js is the splitter, kept for older branches