Commit graph

6 commits

Author SHA1 Message Date
Frederic Jung
dd6e4f4f8a
Fix CodeQL code-scanning alerts
- Values pasted into eval'd or inline-script code go through lit() (scripts/lib/js-literal.js), which escapes <, >, /, U+2028 and U+2029 after JSON.stringify
- build test and i18n-check read script tags with a DOM parser or a plain search, not HTML regexes
- mcp.js parses the Authorization header without a backtracking regex
2026-11-05 21:24:26 +01:00
Frederic Jung
7f4fdf6043
WebGL map: join each line's segments, and draw a link being dragged out under the cities
A see-through line on the card was one round-ended quad per segment, so
where two met it was blended twice: the selected tube's halo showed a
darker blob at every point, and the cables a notch at every corner. Each
segment now knows its neighbours' directions and keeps only its side of
the corner's bisector, as the 2D canvas strokes a path once.

The link being dragged out was painted on the overlay, above the cities
and their labels; it now goes to the card, under them, as in 2D, and its
price label is a picture like the others.

Auto after Always 2D, when the browser will not give the context back,
gives the card up instead of waiting for it all session. Firefox reads
the card's name from RENDERER, without the extension it warns about.
2026-11-05 11:15:05 +01:00
Antoine
3482142ae5
WebGL map: simplify the coastlines for the zoom
On the card the land was most of a frame's work (the stencil fills twice, the sand, the
edge), and it scales with vertices, not pixels. The land is now built per zoom level
(powers of 2) with each coastline simplified (Douglas-Peucker) so that no point moves
more than 0.25 px at the level's zoom; zooming in takes the finer level at once, zooming
out keeps it until the zoom is 10 % under it. COAST, onLand() and the 2D map are
unchanged.
2026-11-04 22:37:14 +01:00
Antoine
39941c257e
WebGL map: keep the 2D map where WebGL is drawn by the processor
With the perf benchmark now waiting for the surface the map was drawn on,
headless Chromium showed what WebGL costs without a graphics card: its
SwiftShader renderer spends about 8 µs per instance, so the coastlines alone
(29k segments, twice) took about 480 ms and a big map 1.4 s a frame, where the
2D canvas takes 46 ms. Players get the same with a blocked driver, a virtual
machine or Mesa's llvmpipe. glInit() now reads the renderer first and keeps
the 2D map on SwiftShader, llvmpipe, softpipe, lavapipe, WARP or any
"software" renderer; GLX.soft lets the GPU benchmark measure them anyway.
2026-11-04 22:37:13 +01:00
Antoine
8491b1a8f6
WebGL map: keep every sprite, the attack ring, an empty title map and a 2D fallback
- A sprite or disc drawn as the queue grows was written into the old array and
  lost: the record is now taken before the array is read.
- A city's picture without an attack shared its cache key with step 0 of a
  DDoS ring (always, with animations off): no attack is now phase -1, and
  cityStatic() reads only what the key holds.
- Back at the title (or on a damaged save), drawFrame() returned before hiding
  the card's layers, so the last network stayed behind the title: the layers
  are now shown or hidden on entry.
- An error from the card (frame start, tube upload, atlas, sprite flush) now
  gives WebGL up and draws the same frame in 2D, once; the 2D context, the
  sprite queue and GLS.frame are reset whatever fails. Other errors still
  reach tickErr() and leave WebGL on.
- Selecting a tube no longer rebuilds and uploads every tube, packet and
  point (about 230 KB on the big-network fixture): its halo is its own small
  buffer.
2026-11-04 22:37:12 +01:00
Antoine
cf9ab5e774
Draw the map with WebGL2 by default, with the 2D canvas as fallback
- Sea, land, waves, clouds, cables, tubes and packets are drawn by the
  graphics card; the land is geometry built once, so panning and zooming
  repaint nothing.
- Cities, labels and markers are painted once into a sprite atlas and drawn
  in one call (with drawImage in 2D, which speeds up the 2D map too).
- Settings > Map drawing: Auto or Always 2D, per device. Browsers without
  WebGL2, a lost context and puzzles keep the 2D map.
- npm run bench:gpu compares 2D and WebGL in a real browser on a real GPU;
  ?fps shows a frame meter.
2026-11-04 22:37:12 +01:00