aboutsummaryrefslogtreecommitdiffstats
path: root/notes.txt
blob: 1af54ec9777b368944baea5884587936159d84b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
MAP DATA

Source: OpenStreetMap extract of Belgium from Geofabrik (ODbL, credit "(c) OpenStreetMap contributors")
  https://download.geofabrik.de/europe/belgium/belgium-261119.osm.pbf
  saved as assets/raw/belgium.osm.pbf (668 MB, not in git)
  note: the "belgium-latest" link was broken (404), so we use a dated file

Tool: GDAL (ogr2ogr), installed with micromamba, no sudo:
  micromamba create -n gis -c conda-forge gdal
  The scripts use micromamba when it is on the PATH, else the system GDAL (apt install gdal-bin).

tools/extract_map.sh
  pulls 6 layers out of the .pbf into assets/geojson/
    border.geojson     Belgium outline (1 polygon)
    rivers.geojson     waterway=river, keeps name
    roads.geojson.gz   highway = motorway, trunk, primary, secondary, tertiary and their _link ramps. Keeps
                       name, highway and ref (OSM road number, "E40;A10"; not an OSM driver column, so it is
                       read from the other_tags hstore with -dialect SQLite and hstore_get_value). 40 MB plain,
                       so git keeps it gzipped (4.1 MB, gzip -9 -n, #71); the bake inflates it with
                       core:compress/deflate.
    cities.geojson     place=city (15 points)
    areas.geojson.gz   land use polygons (multipolygons layer), keeps landuse, natural, leisure:
                       city = landuse residential / commercial / industrial / retail, park = landuse forest,
                       natural wood, leisure park, farmland = landuse farmland / farmyard / orchard / vineyard,
                       marsh = natural wetland, beach = natural beach / sand, water = natural water. The
                       Geofabrik extract has no sea polygon (the coast is only a line), so the sea is not an
                       area: draw it as the background west of the coast or leave it. Simplified 0.001 deg,
                       only polygons over 0.00005 square degrees (~0.4 km2) before simplifying:
                       6.6 MB plain, 1.5 MB gzipped (all 707k polygons at 0.0005 deg would be 180 MB).
    road_graph.geojson.gz  motorway, trunk, primary, secondary and their ramps, NOT simplified, 6 decimals
                       (~10 cm), keeps highway, oneway, junction (both from other_tags). Unsimplified so
                       ways that share an OSM node share the exact coordinate (the junctions). 35 MB plain,
                       5.0 MB gzipped. With tertiary it would be 61 MB / 9.2 MB.
  simplifies border, rivers and roads (0.0005 deg), 5 decimal coordinates
  2026-11-21: GDAL 3.13.3 (conda-forge), run on a laptop because the cloud sessions can not reach geofabrik.
  2026-11-21: roads, areas and road_graph again with GDAL 3.8.4 (Ubuntu apt) in a cloud session that could read
    the same belgium-261119.osm.pbf (sha256 7fb02759...5d7). GDAL 3.8 writes a way that simplifies below the
    tolerance as a Point (5 roads) and a too small polygon as a line or a collection (24 areas); the bake
    skips both. Each ogr2ogr pass over the pbf takes 2-3 minutes (4 cores).
  Road ways in the extract (simplified points / full points), #67:
    motorway 7768 (16322 / 37007)    motorway_link 7405 (15813 / 50319)
    trunk 8612 (17766 / 43913)       trunk_link 2781 (5684 / 16534)
    primary 39821 (80804 / 202075)   primary_link 1317 (2641 / 6788)
    secondary 46421 (96935 / 316274) secondary_link 954 (1922 / 5400)
    tertiary 77127 (162674 / 581283) tertiary_link 584 (1170 / 3104)
  takes a few minutes (most of it on the border)

tools/bake_map/  (odin run tools/bake_map, from repo root)
  reads the geojson files and heights.i16.gz, writes assets/belgium.bin (MAP_VERSION 4, 13.9 MB), ~9 s
  projection: equirectangular, km, origin top-left (lon 2.38, lat 51.56), y down
  Deterministic: CI bakes again and diffs. Maps are only looked up, never iterated; everything that is sorted
  has a full key or a stable sort over the input order.
  Lines: road kind from the highway tag, a _link counts as its road; tertiary stays in (#72). Lines are
  clipped to 0..MAP_W_KM x 0..MAP_H_KM (#73, one tertiary point at the German border was at x = 286.27).
  Empty geometries (ways with missing nodes) are skipped. Lines of one kind, name and ref that meet end to
  end where no third such line touches are joined into one (OSM starts a new way at every tag change).
  Before names: 195894 -> 56385 lines; with name and ref in the key 61780 lines, 287665 points. Then sorted
  by kind, so bigger roads are drawn on top. 15 cities, 15 hubs.
  Names: road and river name + road ref as offsets into one blob of 0-terminated strings (each string once,
    in order of first use): 322 KB. The border and the cities have no line name.
  Name index (for map_nearest_name): 10 km cells (29 x 24), per cell the runs of consecutive segments of a
    labelled line (name, or a motorway with a ref) whose bounding box touches the cell. 196039 segment hits
    -> 54114 runs, 650 KB. Baked so the game does not rebuild it after every hot reload.
  Areas: outer ring only, holes are dropped (a clearing in a forest is drawn as forest; lakes are their own
    Water polygons and drawn last, so they still show). Polygons under AREA_MIN_KM2 = 0.5 km2 (after
    simplifying) are dropped. Ear clipping in map space (O(n^2), forced cut when a self-crossing ring has no
    ear), then every triangle is clipped to the map rectangle (Sutherland-Hodgman, fan). Ring area and
    triangle area are printed and agree (10262.6 km2), so no forced cut went wrong.
    Measured (polygons kept / triangle bytes) by minimum area: all 45.7k / 7.6 MB, 0.1 km2 33.0k / 6.7 MB,
    0.2 km2 15.7k / 4.9 MB, 0.5 km2 5.3k / 3.0 MB, 1 km2 2.3k / 2.0 MB, 2 km2 1.0k / 1.3 MB.
    Kept: 5328 polygons, 125384 triangles, 3.07 MB. Area by kind at 0.5 km2: park 6374 km2, city 1818,
    farmland 1768, water 192, marsh 114, beach 1. OSM Belgium maps only part of its farmland.
  Buildings: not in belgium.bin. 7644305 building polygons in the extract (ogrinfo count, 95 s). Even at 4
    corners = 2 triangles = 48 bytes each that is ~367 MB. Only the city centres are baked, see BUILDINGS DATA.
  Heights + hillshade: see ELEVATION DATA.
  Road graph (bake_roads): a coordinate used by two ways, twice by one way, or a way end is a node; a way
    that leaves the map is cut at its last point inside (a dead end). Then stretches of the same kind and
    one-way rule that meet at a node with exactly two stretch ends are joined (OSM splits ways at every tag
    change): 115079 ways -> 43107 stretches between 29228 nodes. One-way: oneway=yes/true/1 forward,
    -1/reverse backward, no/alternating/reversible both ways, untagged motorway, motorway_link and
    roundabouts (junction roundabout / circular / turbo_roundabout) forward. Geometry between two nodes is
    simplified with Douglas-Peucker at ROAD_SIMPLIFY_KM = 20 m, length_km is measured before simplifying.
    50691 edges (35523 one-way), 151305 points (606338 before simplifying), 31423 km of directed edges.
    Bytes: nodes 468 KB, edges 1419 KB, points 1210 KB = 3.1 MB. From the node nearest Brussels 28393 of
    29228 nodes can be reached; the rest are cut ends at the border and one-way stubs. 649 nodes have no
    edge out (the end of a one-way road at the border or a dead end).
    Tertiary left out: with it 51141 nodes, 100618 edges, 319410 points = 6.2 MB.
  Block sizes in belgium.bin: lines 1236 KB, points 2301 KB, names 323 KB, name index 652 KB, areas 3073 KB,
    heights 2169 KB, hillshade 1085 KB, road graph 3097 KB, cities + hubs 1 KB.

belgium.bin format (version 4, all little endian, 4-byte aligned). Blocks follow each other in this order.
  header      magic "DRFT", version, line_count, point_count, city_count, hub_count, names_size,
              name_cell_count, name_run_count, area_count, area_point_count, height_w, height_h,
              road_node_count, road_edge_count, road_point_count (16 x u32)
  lines       start, count, kind, name, ref (5 x u32). kind = Map_Kind (0 border, 1 river, 2 tertiary ..
              6 motorway), name / ref = offset into names, 0 = none
  points      x, y (2 x f32, km)
  cities      pos (2 x f32), name (32 bytes, 0-terminated)
  hubs        pos (2 x f32), name (32 bytes, 0-terminated). For now one hub per city, same position.
              max MAX_HUBS = 32 (bake fails above that). Tower top = ground + HUB_TOWER_M (58 m, spec).
  names       names_size bytes of 0-terminated UTF-8, offset 0 = "", zero padded to 4 bytes
  name_cells  NAME_GRID_W x NAME_GRID_H + 1 u32: runs of cell c are name_runs[cells[c]:cells[c + 1]]
  name_runs   line, start, count (3 x u32): segments start ..< start + count of that line
  areas       start, count, kind (3 x u32): triangles area_points[start:][:count], kind = Area_Kind
              (0 city, 1 park, 2 farmland, 3 marsh, 4 beach, 5 water), sorted by kind
  area_points x, y (2 x f32, km), 3 per triangle
  heights     height_w x height_h i16, m (1144 x 948), row-major, y down, cell centres
  hillshade   height_w x height_h u8, same grid
  road_nodes  pos (2 x f32), first, count (2 x u32): road_edges[first:][:count] leave this node
  road_edges  from, to, start, count (4 x u32), length_km (f32), kind, oneway (2 x u32): road_points
              [start:][:count] from -> to; two-way roads have one edge per direction, oneway = 1 otherwise
  road_points x, y (2 x f32, km)

BUILDINGS DATA
tools/extract_buildings.sh (from anywhere): ogr2ogr per city (box of 1 km around the cities.geojson point,
  4 at a time, ~2.5 min each) -> assets/raw/buildings/<city index>.geojson (not in git), columns height and
  levels from other_tags.
tools/bake_buildings/ (odin run tools/bake_buildings, from repo root) -> assets/buildings.bin.gz, format in the
  tool. Outer ring only, centre within 1 km of the city point, Douglas-Peucker 1.5 m, at most 32 corners,
  at least 60 m2. Height: OSM height, else levels x 3.2 + 1.5 m, else 7..12 m by a hash. Vertices as i16
  deltas in 0.5 m, byte planes for gzip. 2026-11-21: 70582 buildings in 15 cities (52114 too small or too
  complex, 26997 outside the circle), 1.69 MB, 896 KB gzipped: under the 1 MB check. A wider radius or all of
  a city needs another budget (#76).

tools/bake_car/ (odin run tools/bake_car, after tools/download_car.sh) -> assets/car.bin.gz (format in the
  tool): the outside of Car Concept (no interior, engine, wipers, plate, textures), i16 positions, octahedral
  normals, material class; wheels as their own parts for the fold animation.

WEATHER DATA

Source: Open-Meteo forecast API v1 (CC BY 4.0, free for non-commercial use, no key)
  https://api.open-meteo.com/v1/forecast
  one request for all 63 grid points: latitude=..&longitude=.. (comma lists),
  hourly=wind_speed_{975,950,925}hPa,wind_direction_{975,950,925}hPa,wind_speed_10m,wind_gusts_10m,cloud_cover,
  forecast_hours=9&wind_speed_unit=ms&timezone=GMT&timeformat=unixtime
  hour 0 = the current UTC hour. Open-Meteo counts every location as one call (10000 / day free),
  so 63 points refreshed every 15 min = ~6000 / day. A finer grid needs a slower refresh.
Grid: 9 x 7 points every 40 km from the map origin (lon 2.38, lat 51.56), covers the 285 x 229 km map.
  lat = 51.56 - y / 111.32, lon = 2.38 + x / (111.32 cos 50.5), same projection as the bake tool.
Gust index: Open-Meteo has gusts only at 10 m. index = clamp((gust_10m - wind_10m) / 10 m/s, 0, 1)
  x (1.08 - LAYER_ALT / 1600), the height factor from the spec. Cloud = cloud_cover % / 100 (total cover).
Validation (reject the whole response, keep the old snapshot): 63 locations, 9 values per series, no null,
  wind speeds and gusts 0..100 m/s, directions 0..360, cloud 0..100 %, times 2020..2100 on whole hours,
  hour h = start + h x 3600 in every cell. The range test also rejects NaN and +-Inf.
  Checked by feeding edited responses (null, out of range, shifted time, short series, 62 locations, Inf, html).
Measured (2026-11-21, macOS arm64): one fetch ~400 ms, ~1.2 MB scratch (json values).

ELEVATION DATA

Source: Copernicus DEM GLO-90 (3 arc seconds, ~90 m), public release on AWS Open Data, tiles Last-Modified 2022-05-09
  https://copernicus-dem-90m.s3.amazonaws.com/Copernicus_DSM_COG_30_N<lat>_00_E<lon>_00_DEM/<same name>.tif
  license: free and open (Copernicus DEM licence), attribution required:
  "(c) DLR e.V. 2010-2014 and (c) Airbus Defence and Space GmbH 2014-2018 provided under COPERNICUS
  by the European Union and ESA; all rights reserved"
tools/download_dem.sh (from anywhere): 15 tiles N49..N51 x E002..E006 (named after their south-west corner,
  map spans lat 49.43..51.56, lon 2.38..6.42) into assets/raw/dem/ (60 MB, not in git), skips tiles it has,
  treats 404 as a sea tile, then checks every file against tools/dem_tiles.sha256 (pins the exact data,
  the bucket has no versioned paths). All 15 exist, none is sea only. ~7 s on a fast line.
Tiles: float32 GeoTIFF (COG), heights in m above EGM2008, AREA_OR_POINT=Point. 1200 x 1200 below 50 N,
  800 x 1200 from 50 N (longitude spacing doubles to 4.5 arc seconds). A surface model: buildings and
  forest are in the heights. Checked: coast tile N51 E002 -5.7..41 m, Ardennes N50 E005 max 668 m.
tools/warp_dem.sh (from anywhere, after download_dem.sh): gdalbuildvrt over the 15 tiles, gdalwarp to
  +proj=eqc +lat_ts=50.5 +lat_0=51.56 +lon_0=2.38 +R=6378166.175, -te 0 -237000 286000 0 -tr 250 250,
  -r average, Int16, EHdr (raw little endian), then gzip -9 -n into assets/geojson/heights.i16.gz.
  R = 111320 m x 180 / pi, so 1 degree is exactly the 111.32 km of the bake projection (R = 6378137 would
  put the far map corner 1.3 m off); lat_0 = 51.56 makes the map top northing 0, y down = -northing.
  Pixels are areas: cell (i, j) covers i * 0.25 .. (i + 1) * 0.25 km, its value sits at the centre.
  average, not max: the height of the whole cell. A peak inside a cell is lower than in the tiles (the
  route keeps 75 m above the cell's highest sample, see route.odin).
  2026-11-21, GDAL 3.8.4: 1.5 s. Result 1144 x 948 = 2169024 bytes (sha256 c3b1c1a3...a5e8bf8f4), gzipped
  986871 bytes (sha256 d8c68107...49dbf2d4). -97..704 m, mean 138 m. The sea is 0 m in the tiles; no
  no-data pixels (every tile exists). Below 0: polders (a few m) and open pit quarries (-97 m at
  Gaurain-Ramecroix near Tournai, -86 m at Lessines). Highest cell (704 m) is in the Eifel at the map's east
  edge, outside Belgium. Spot checks at the hubs (city centres, surface model): Oostende 6, Antwerpen 11,
  Gent 15, Brussels 30, Liege 71, Namur 90, Charleroi 134 m.
  Bake (bake_heights): checks the size and -500..3000 m, writes the heights block and a hillshade block:
  Horn's 3 x 3 gradient (like gdaldem hillshade), edge cells repeat their neighbour, light from azimuth 315
  (north-west), 45 degrees up, vertical exaggeration HILLSHADE_Z = 4 (the 250 m cells smooth the Ardennes
  valleys; 1 is almost flat grey, 4 shows the valleys and leaves Flanders near 128). Value = 128 x lit /
  sin(45) up to flat, 128 + 127 x (lit - flat) / (1 - flat) above: 128 flat, 255 facing the light, 0 at 90
  degrees or more away.

FONT

Three families from the design ("Typografie"), static TTFs copied unchanged into assets/fonts, each with its
license (SIL OFL 1.1) next to it. Raw downloads in assets/raw/fonts (not in git). Embedded with #load (~1 MB).
  Roboto v3.016 (googlefonts/roboto-3-classic release, zip sha256 1653dbe1...e334f), web/static/:
    Roboto-Regular a6ec0ffa...fe523690, Roboto-Medium 71f5e045...f22b462d, Roboto-Bold 07ee011e...cdee3772,
    license Roboto-OFL.txt
  Figtree v2.0.3 (github.com/erikdkennedy/figtree, tag v2.0.3, fonts/ttf/): Medium e605259d...28c8b3fd,
    SemiBold a63306f1...075eb574, Bold 2a33fa55...e26c563e, ExtraBold 31990321...80f4234b,
    Italic 5983a032...06599439, license Figtree-OFL.txt
  Roboto Mono v3.001 (github.com/googlefonts/RobotoMono, tag v3.001, fonts/ttf/): Regular af0bff75...1be17cb4,
    Bold 3ecf35e5...aa95c4db (no static SemiBold exists, Font.Mono_600 uses Bold), license RobotoMono-OFL.txt
  Material Symbols Rounded (Apache 2.0, license MaterialSymbolsRounded-LICENSE.txt), 2026-11-21: a subset from
    the Google Fonts css2 API (family Material Symbols Rounded, FILL 1, wght 500, opsz 24, icon_names = the 38
    icons of ui.odin ICON_CODEPOINTS), file MaterialSymbolsRounded-Filled.ttf, 12756 bytes, sha256 f6fc79a3...
    1ed1f092fc5e (full f6fc79a366be9647afa5f24e0a624388430573edc1ffccbea1277ed1f092fc5e). The full font is 3.7 MB,
    over the 1 MB check. The subset keeps the legacy codepoints for a few icons (schedule 0xe8b5, location_on
    0xe0c8, warning 0xe002), see ICON_CODEPOINTS. Tower and Logo are drawn with shapes, they are not icons.

CODE LAYOUT
source/game/      package game, all game code, builds as build/game.so (debug) or into the exe (release)
  game.odin       World struct, exported procs, fixed 60 Hz timestep, drawing
                  Time always runs at real speed (Lars, 2026-11-21: the 1x / 5x / 15x / 40x sim speed and keys 1..4
                  are gone, the speed shows in km/h). The frame time (capped at 0.25 s) goes into the accumulator,
                  every step has dt = 1 / 60.
                  w.font: Roboto rasterized by raylib on the first frame (needs a window, so never in headless),
                  FONT_PX 14, codepoints 32..255. Falls back to the raylib font with a log line if loading fails.
                  Unloaded in game_shutdown. The profiler overlay still uses the raylib font.
                  "(c) OpenStreetMap contributors" (with a real copyright sign) bottom right on a white box,
                  required by the ODbL wherever the map is shown.
                  Camera: w.view (View) = pan (km from the map centre to the screen centre) + zoom (log2 relative
                  to the fitted view, ZOOM_MIN -1 .. ZOOM_MAX 7). Zero = the whole map fitted to 95% of the window.
                  Each frame it becomes a Camera2D, zoom = px per km. Pan is clamped so the screen centre stays on
                  the map. Two modes, key M toggles, w.drive_mode (zero = map mode):
                  Map mode: the camera reads w.controls, throttle / turn pan (600 px/s), climb zooms (2 per s) around
                  the screen centre. So WASD and the left stick pan, R/F and right stick Y zoom. Mouse (camera only,
                  not in Controls): left drag pans, wheel zooms (0.25 per notch) around the cursor. The ship does not
                  step and nothing is recorded.
                  Drive mode: Controls go to ship_step and the replay record, the camera sits on the ship, only the
                  wheel zooms. The ship is drawn as an 8 px red triangle pointing along its heading in both modes.
                  Start: game_init puts the ship on the Brussels tower (hub named "Bruxelles - Brussel", looked up
                  by name since hub ids follow the bake order), alt = height_at + HUB_TOWER_M, heading north.
                  Only on a fresh World, a hot reload keeps the ship where it is. Missing hub: log line, map corner.
                  Colors (render.odin): every drawn color comes from Palette = the design token table
                  (docs/drift-design.pdf "Kleuren": surface, surface_2, surface_3, text, text_2, line, accent,
                  accent_strong, green, banner, banner_2, red, warning, reroute, arrived, sheet, chip, bubble,
                  bubble_text, pill), the light values in PALETTE. Light only (Lars, 2026-11-21: "alleen light mode,
                  doe de dark mode overal weg"): no night palette, no T key, no theme button, the loading screen and
                  the street view are light too. palette(w) -> ^Palette returns w.palette, a copy of PALETTE made at
                  the start of every frame: no pointer into this library's constants, so hot reload is safe. Map line
                  colors go to the line shader as a uniform. The profiler overlay keeps its own fixed colors.
                  Map colors (same Palette, design "Kaart" table): land, city, park, farmland, marsh, beach, water,
                  roof, wall, motorway / main_road / street / track with their _casing, route / alt_route with their
                  _casing, sky, horizon. Used now: land (clear color), water (rivers), motorway; the border has no
                  design color and uses text_2. Wind trails use text: the design names a speed ramp (white < 6 m/s,
                  mint < 10, yellow < 14, coral above) without values, open question.
                  Line meshes (Line_Meshes in render.odin, built inline in game_update): map lines and wind trails
                  are meshes drawn by one shader (LINE_VS, GLSL 330), built on the first frame (needs the window,
                  never in headless). Each segment is 6 vertices (2 triangles, no index buffer: raylib indices are
                  u16). Every vertex carries both ends (vertexPosition = A, vertexNormal.xy = B); the shader picks
                  the corner from gl_VertexID % 6 and pushes it along the screen space normal, so lines are 1 px at
                  every zoom. vertexColor.r = index into a uniform color array (Map_Kind colors, then WIND_COLOR),
                  vertexColor.a scales the alpha. The CPU arrays live in the frame arena; after UploadMesh the mesh
                  pointers are set to nil, so UnloadMesh only frees GPU buffers. Rebuilt after a hot reload (the
                  shader may have changed), unloaded in game_shutdown.
                  Map: static, 225885 segments, 1355310 vertices, 36.2 MB on the GPU, one DrawMesh (was 25493 /
                  4.1 MB before the road classes of #67). Under Xvfb (software GL, CPU) a frame went 13 -> 48 ms;
                  still to measure on a real GPU (budget 4 ms). "3 detail levels + 10 km cells" cuts it.
                  Wind: dynamic mesh, rewritten every frame with 3 UpdateMeshBuffer calls, one DrawMesh.
                  Measured 2026-11-21 (Asahi M2, 800 x 450, debug): map draw 8.6 ms with DrawLineStrip -> 0.55 ms
                  with the mesh. The first frame takes ~34 ms (mesh build).
                  Wind particles (Wind_Particles in render.odin, w.wind): WIND_PARTICLES 600, SoA arrays x, y, vx, vy,
                  age in World. Drawing only, never read by the simulation, so frame time is used. Spread over the
                  visible part of the map, respawned there when they leave the view or Belgium (WIND_SPAWN_TRIES 8
                  picks to land inside) or reach WIND_LIFE_S 3 s; alpha x belgium_fade, so nothing shows abroad. The
                  first frame (seeded = false) gives them random ages. Seeded LCG (wind_rand), same picture every
                  run. Velocity = wind_at of layer 0 (until the layer toggles) at the forecast hour of w.tick,
                  shown at WIND_PX_PER_MS 4 px/s per m/s at every zoom. Trail = 0.4 s of travel, fades in and out
                  (sin of age), not drawn under WIND_CALM_MS 0.5. No snapshot = calm = no particles.
                  Measured (same machine, draw ms, map + wind + labels): debug 1.8, -o:speed 0.7. With 1500
                  particles: DrawLineV per particle cost 0.5 ms (-o:speed); the mesh writes cost ~3.4 ms in debug,
                  so the count went down to 600, which still shows the wind clearly.
                  Labels (Label in render.odin): after EndMode2D, each city goes through GetWorldToScreen2D into a
                  flat [dynamic]Label in the frame arena: dot, text rect (LABEL_GAP_PX 2 px bigger on every side),
                  text. Cities with dot and text off screen are dropped. A label whose rect overlaps an earlier shown
                  one keeps only its dot. Earlier = first in the bake: there is no population to rank by yet. Then one
                  pass draws dots (3 px) and texts (default font, LABEL_PX 10). Pixel size stays the same at every
                  zoom. The default font covers Latin-1, "Liege" with e grave draws correctly. 15 cities: O(n^2)
                  overlap test, fine until there are hundreds of labels.
  ui.odin         Fonts: Font enum (Figtree 500/600/700/800 + italic 400, Roboto 400/500/700, Mono 400/600),
                  font_get rasterizes each (font, px) pair on first use (codepoints 32..255, up to 64 pairs in
                  w.fonts), fonts_unload in game_shutdown. ui_text(w, pos, text, font, px, color) draws at the
                  top-left pos, ui_text_size measures. Font.Icons is the Material Symbols subset (see FONT),
                  ui_icon(w, icon, centre, px, color) draws one Icon.
                  Immediate mode UI, our own (raygui needs a system library on Linux, it is not in the build).
                  A widget is a proc call that draws itself and returns what happened this frame; only w.ui (focus,
                  last frame's blocks and popup, toast, toggle animations) is kept. ui_begin once per frame.
                  ui_widget(w, r) -> (id, hot, fired): ids count up per frame, Tab / Shift-Tab move the focus,
                  Enter / Space fire the focused widget, hit areas grow to 44 px. ui_block(w, r) marks UI that keeps
                  the mouse off the map next frame (ui_mouse_captured), w.ui.popup takes the clicks inside it.
                  Kit: ui_card, ui_round_button, ui_pill_button, ui_chip, ui_toggle, ui_segment, ui_stat_chip,
                  ui_input, ui_zoom_pill, ui_tile, ui_toast (1.6 s), ui_focus_ring, round_rect.
  camera.odin     (Dario) Cam in World: pose {pan, zoom, yaw, tilt}, a perspective Camera3D over the ground plane
                  (world = x km, y km, -alt km, FOV 45). Modes Free / Chase / Preview, glides with ease-out.
                  cam_to_screen(w, pos) is how everything projects; cam_ground_at(w, px) is the inverse on z = 0.
                  cam_fit (0.8 s), cam_chase (53 deg tilt behind the ship, 1.2 s dive), cam_preview (flies the
                  route in 9 s with route_sample), cam_recentre, cam_overview, cam_north, cam_zoom_by (0.6 s glide).
  nav.odin        (Lars, simulation, no raylib) plan_routes -> w.routes, summaries (time, km, net kWh, wind, tag,
                  why), maneuvers (spec "Extractie", road names from map_nearest_name), nav_start / nav_update
                  (path index window, banner, Then, ETA, warning, reroute after 190 m off for 1.2 s),
                  gust_report (260 m zone 700 m ahead + reroute), nav_autopilot -> Controls.
  nav_ui.odin     (Lars) route strips, time bubbles, start ring + destination pin, banner + Then, road sign,
                  pill under the ship (layer, or the road name while driving), warning pill, sheet,
                  carpool_draw_partner.
  pilot_ui.odin   (Dario) button column, speed circle, Re-centre, self-fly + Exit / Done,
                  3 x 3 control pad + key card. No sound button (speech is NOT DOING).
  plan_ui.odin    (Andrei) plan panel (cards A and B, hub search, departure list, route rows, wind note,
                  Preview / Start), hub menu on the map, map buttons, layers panel + legend, layers_draw_ground.
  labels.odin     (nasr) river names and motorway shields: places picked once along the lines (labels_build),
                  projected and culled against each other and the hub names every frame.
  road.odin       (Lars, simulation, no raylib) the airship as a flying car on the road graph (#67, #68 B):
                  road_try_land (descending at the lowest flying height within ROAD_LAND_KM = 1 km of a road; the
                  Brussels tower is 660 m from the nearest graph road), road_step (edge + km along it, one-way
                  respected, turn input picks the edge at a junction, climb takes off), road_nearest_edge, road_at.
                  Transition (Lars, 2026-11-21): landing slides onto the road and turns to it over ROAD_ALIGN_S 2.5 s
                  while sinking ROAD_DESCENT_MS 4 m/s (ship.landing, road_landing_step); take-off climbs at least
                  ROAD_LIFT_MS 10 m/s to the lowest flying height (ship.lifting). On the road ROAD_MAX_SPEED 35 m/s
                  (126 km/h), accel 1.2 / brake 1.6 m/s^2; in the air SHIP_MAX_SPEED 70 m/s (252 km/h, Lars: "sneller
                  vliegen"), accel 3 / brake 4, climb 12 m/s. All our values, not from the spec.
  carpool.odin    (Andrei) carpool_offer_make (energy = net kWh with the current snapshot, its hash in the offer),
                  carpool_verify (recompute with the same snapshot, VERIFY_TOLERANCE 1 %), carpool_match (weather
                  cell + forecast hour filter, then four router runs for the detour), carpool_split (passenger:
                  seats / (seats + 1) of the shared leg + the whole detour), carpool_reputation (one review per
                  side of an accepted trip), carpool_frame (live position once a second, partner on the map).
  globe.odin      (nasr) 3D Earth globe backdrop around Belgium: #load embeds assets/world.bin (968 KB,
                  Natural Earth 50m land mask 2048x1024 1-bit + 1815 coastline/border lines + 1127 world
                  cities, baked by tools/bake_world after tools/download_world.sh). Sphere radius 6371 km
                  tangent to Belgium's centre (MAP_W_KM/2, MAP_H_KM/2, z=0), so Belgium's flat map and
                  simulation stay untouched on top. Night/day ocean + land + 15-deg graticule + Fresnel limb
                  atmosphere shader, coastlines/borders via LINE_VS, world city labels when zoom < -0.8.
                  Camera (camera.odin): ZOOM_MIN -6.2 orbits the globe via Cam_Pose.globe_rot (lon/lat rad).
  map.odin        same structs as the bake tool (keep in sync). #load embeds belgium.bin,
                  load_map() slices it, no parsing. Re-pointed in game_hot_reloaded.
                  Hubs are copied into a fixed array w.m.hubs[:w.m.hub_count], hub id = index.
                  load_map validates: every block fits the file and the file ends after the last, every
                  start / count / index points inside its block, kinds in range, names start and end with 0,
                  road adjacency lists only edges of their node, every coordinate finite (x - x == 0).
                  Bad data gives ok = false and an empty Map. Cost: ~2.4 ms per call (bench load_map,
                  profile; was ~0.2 us without checks), at startup and after every hot reload.
                  Map: lines, points, cities, hubs, names, name_cells / name_runs (name index), areas /
                  area_points, heights, hillshade, road_nodes / road_edges / road_points. Constants:
                  MAP_W_KM / MAP_H_KM, NAME_CELL_KM (10), HEIGHT_W / HEIGHT_H (1144 x 948), HEIGHT_CELL_KM.
                  Every string and slice points into the #load data: valid until the next reload, so World
                  keeps offsets and indices, never the strings.
                  map_name(m, offset) -> string: a names offset (Map_Line.name / .ref), "" for 0 or bad.
                  map_nearest_name(w, pos, radius_km) -> (name, kind, ok): the closest labelled line within
                  the radius, ranked by distance x NAME_KIND_WEIGHT (motorway 0.6, trunk 0.7, primary and
                  river 0.8, secondary 0.9, tertiary 1): a motorway at 1.6 km beats a tertiary road at 1 km.
                  The name, or for a motorway without one the first part of its ref ("E40"). Visits the index
                  cells nearest first and stops when no line in the next cell can win. NaN pos or radius <= 0
                  gives ok = false. Measured (-o:speed, cloud box, 4096 random points, min of 5 runs per
                  point): avg ~4 us at 2..20 km, worst point 30-47 us (city centre cells hold up to 3961
                  segments).
  terrain.odin    height_at(w, x, y) -> ground height in m: bilinear between the 250 m cell centres of
                  w.m.heights (sample (i, j) at ((i + 0.5) * 0.25, (j + 0.5) * 0.25) km). Outside the map the
                  edge value holds (like wind_at), NaN x or y and a map without heights give 0. No allocation.
                  Measured (profile build, cloud box): bench avg ~50 ns (4096 random points over the 2.2 MB
                  grid after a route ran, so mostly cache misses), ~10-18 ns warm, 1.69M calls in grid order
                  14 ms (the route's terrain set, built on first use and after a reload: +~14 ms).
                  Belgium mask (nasr, 2026-11-21, "limit everything to Belgium"): w.belgium [HEIGHT_W * HEIGHT_H]u8
                  on the same 250 m cells, built by belgium_build in game_hot_reloaded from the 36 Border rings of
                  belgium.bin (even-odd scanline fill, the sea zone counts as Belgium), then two chamfer passes:
                  0 outside, else the depth into Belgium in cells, capped at BELGIUM_DEPTH 12 (BELGIUM_FADE_KM 3).
                  514933 cells inside = 32183 km2. ~6 ms (-o:speed) at startup and after every reload. No border
                  rings = Belgium everywhere. belgium_inside(w, x, y) -> bool (cell lookup, outside the map and
                  NaN false), belgium_fade(w, x, y) -> 0..1 (bilinear like height_at). Users:
                    wind particles, clouds, gust / solar ground layers: alpha x belgium_fade (replaced map_edge_fade)
                    camera (Free mode): after cam_clamp_pan the point under the screen centre must be inside, else
                      keep the axis that stays inside, else pull the pan toward the map centre (inside Belgium)
                    ship_step: a step from inside to outside keeps the axis that stays inside (slides along the
                      border); a ship already outside moves freely
                    route terrain set: a 1 km cell whose centre is outside is closed on every layer
  weather.odin    wind_at(w, x, y, layer, hour) -> [2]f32 m/s, direction the wind blows toward, x east, y south
                  gust_at(w, x, y, layer, hour) -> 0..1, cloud_at(w, x, y, hour) -> 0..1. Bilinear on the 40 km grid
                  from w.weather, no allocation. Outside the grid the edge value holds, layer and hour are
                  clamped (hours after 8 keep hour 8). Until a snapshot is loaded w.weather is zero: calm, clear.
                  3 layers = 975 / 950 / 925 hPa ~ LAYER_ALT 300 / 550 / 800 m, hours 0..8 from snapshot start
                  Weather struct: start (unix s), wind [hour][layer][cell][2]f32, gust [hour][layer][cell] 0..1,
                  cloud [hour][cell] 0..1. Fixed size 22.7 KB, zero = calm and clear.
  net.odin        fetch_weather(out, scratch, cancel) -> ok: blocking Open-Meteo request with curl (15 s timeout,
                  max 1 MB, aborts within ~1 s when cancel is set), converts the json into a Weather.
                  Writes out only if every value is valid.
                  Snapshot cycle (state in w.fetch, zero = fetch on the first update):
                    game_init -> weather_load_snapshot(w, path): reads cache/weather.snap, checks size, magic, version,
                      sha256 and weather_valid. Bad or missing file: weather_load_fallback uses the snapshot
                      embedded with #load (assets/weather_fallback.snap, fetched on Lars's Mac 2026-11-21, 22736
                      bytes, sha256 7761b8c7...aaa3690), its old fetched_at makes the first poll fetch right away.
                    game_update -> weather_poll: every frame, starts a thread when now >= next (15 min after
                      the snapshot was fetched, 5 min after a failure). The thread fetches, hashes and writes
                      the file (temp + rename), all allocation in w.fetch.mem. When is_done, the frame loop
                      copies the 22.7 KB Weather into w.weather. No network or disk IO in the frame loop.
                    game_before_reload / game_shutdown -> weather_stop: cancel + join (measured 5-14 ms),
                      because the thread runs code from the library that is about to be unloaded.
                  cache/weather.snap: Snapshot_Header (magic "DRWS", version 1, fetched_at unix s,
                  sha256 of the Weather bytes) + raw Weather, 22736 bytes. w.weather_hash = that sha256.
                  Identity: game_init -> identity_load_or_create. cache/identity.key holds the 32 byte ed25519
                    seed (owner-only permissions). Missing: generate from the system entropy source and save.
                    Present but wrong size or invalid: logged and left alone (it is the user's reputation),
                    w.identity stays zero and network features stay off. w.identity_pub = public key,
                    logged as the first 8 bytes in hex. Moves to the user data folder with the release item.
                  Carpool messages: Message is 208 bytes, fixed size, little endian, no implicit padding
                    (#assert). Header: magic "DRMS", version 2, kind (Offer / Request / Accept / Review),
                    time (unix s, set by the author), author (ed25519 public key). Body is a raw union:
                      Offer   from_hub, to_hub, seats 1..8, mode, depart, arrive, weather snapshot hash, energy_kwh
                      Request offer id, from_hub, to_hub, seats 1..8, passenger x25519 public key (not zero)
                      Accept  offer id, request id, driver x25519 public key (not zero)
                      Review  subject public key, accept id, stars 1..5
                    sig = ed25519 over bytes 0..143. Message id = sha256 of all 208 bytes. Version 2 since the
                    trip key exchange; node hello version 2 too, so old nodes are refused.
                    msg_sign(w, m) fills magic, version, author, sig (start from a zeroed Message).
                    msg_read(bytes) -> (m, why) for anything from outside: msg_check (size, header, field
                    ranges) then the signature. why is "" or a constant reason, the caller logs it (network
                    threads have no World). msg_check alone is for the store file.
                    Measured (macOS arm64, -o:speed): sign ~33 us, read + verify ~44 us.
                  Message store: w.store (Store, ~0.9 MB in World) holds up to STORE_MAX = 4096 messages and
                    their ids, unordered, removal moves the last one into the hole. Bounded so one key cannot
                    fill a node: STORE_PER_AUTHOR = 64, an author over it loses its oldest message (by time).
                    Expiry: an offer at its depart time, the rest 30 days after their time. Times more than
                    1 h ahead are refused (they would never expire). Full store: drop expired, then the one
                    that expires first, or refuse m (.Full) when m itself expires first.
                    store_add(s, m, now) -> Added / Duplicate / Expired / Future / Full, memory only, m must
                    have passed msg_read. Every access takes s.lock (sync.Mutex, zero is unlocked): the
                    network thread writes, the frame loop reads.
                    cache/messages.log: messages back to back, append-only while running (store_append).
                    store_load(s, path, now, scratch) at start: header + field check per message (no
                    signatures: only verified messages are ever written), then store_rewrite writes it again without
                    expired / dropped ones (temp file + rename). Also rewritten when it reaches 2 x STORE_MAX
                    messages. A size that is not a multiple of 208 (killed mid-append, or a v1 file) moves to
                    messages.log.bad and the store starts empty; peers send the messages again.
                    Load of a full file ~12 ms (linear dedupe, 4k x 4k id compares), so it runs on the
                    network thread, not in game_init.
                  Peer to peer node: every game is one, there is no server. w.node (Net_Node) holds the peers,
                    the threads and per-thread buffers (2 x 128 KB id lists). node_poll(w) each frame starts it
                    after start and after every reload, node_stop(w) in game_before_reload / game_shutdown.
                    Two threads, blocking with timeouts (5 s per send / recv):
                      serve: listens on NODE_PORT 7419 (w.node.port overrides it, 0 = default), non-blocking
                        accept every 50 ms so it can stop, one connection at a time, max 30 s each.
                      sync: loads the store first (store_load), then every SYNC_S = 30 s per peer: asks the
                        peer's ids since T, gets the missing ones (64 per request, each through msg_read and
                        checked to be one it asked for), pushes ours it does not list.
                        T = 0 (all) once an hour per peer, otherwise the last good sync - 10 min.
                        A failed sync backs off: 30 s x 2^fails, max 32 min.
                    Protocol, one TCP connection, the dialer asks until it closes:
                      both: hello = magic "DRNP" u32le, version u8, listen port u16le (0 = not listening),
                        node id [8]u8 (random per run)
                      'I' since i64le -> count u32le + ids;  'G' count + ids -> count + messages;
                      'P' count + messages -> added u32le;  'N' -> count u8 + peers (family u8, address
                      [16]u8, port u16le). Counts above STORE_MAX / SYNC_BATCH / MAX_PEERS close it.
                    net_dial (dial_posix.odin / dial_windows.odin): net.dial_tcp has no connect timeout (a
                    dead address blocks ~75 s), so non-blocking connect + poll, 5 s max, checks the stop flag
                    every 100 ms. Stop while dialing a dead peer: ~10 ms.
                    Store writes from both threads: s.file_lock around appends and rewrites.
                    Peer list (max 32): seeds from SEED_NODES (in code, empty until there is a public node)
                    and cache/seeds.txt (one "host:port" or "host" per line, # comments, resolved on the
                    sync thread). Learned: every 'N' answer (peers that synced in the last 24 h) and every
                    node that dials us (its address + the listen port from its hello). Learned peers are
                    saved to cache/peers.txt (text) and read back at start. A learned peer that fails 8
                    syncs in a row (~5 h with the back off) is forgotten, seeds stay. A full list drops the
                    learned peer that failed most, never one that works. A hello with our own node id
                    means we dialed ourselves (our address came back through others): dropped, and that
                    address is never added again this run.
                    LAN discovery: the sync thread broadcasts its hello (the same 15 bytes, hello_make /
                    hello_read) over UDP to 255.255.255.255 port NODE_PORT every LAN_S = 5 s, only while
                    listening. Hellos it hears there (right size, magic, version, not our node id, port
                    not 0) add the sender's address + that port as a learned peer, at most LAN_READS per
                    round. The UDP port is always NODE_PORT, also with --port, so nodes on other TCP ports
                    hear each other. Reuse_Address lets a second node on the same machine bind it (Linux,
                    Windows; on macOS the second one logs "lan discovery off" and only dials). Broadcasts
                    stop at the router and some Wi-Fi blocks them between clients: there seeds.txt or a
                    public node is still needed. Firewalls must allow UDP and TCP 7419.
                    Seen on office Wi-Fi (2026-11-21, Linux + Windows on one /16): unicast UDP and TCP
                    went through, both 255.255.255.255 and the subnet broadcast were dropped. One side
                    with the other in seeds.txt is enough: sync, presence and live packets go both ways
                    over the dialer's connection. Windows on a "Public" network blocks inbound for the
                    game by default, so there the Windows side has to be the one with the seed.
                    Own devices on any network: Tailscale. Put the other device's full MagicDNS name in
                    seeds.txt (nijeveen.tail142ce3.ts.net, not the short name: our resolver skips the
                    search domain). Tailscale counts as Private on Windows, so its firewall lets it in.
                    Clocks: other cars are dropped when their time is more than PRESENCE_TTL_S old or
                    PRESENCE_FUTURE_S ahead. A Windows PC with w32time stopped was 104.6 s ahead: the
                    nodes synced, but neither side showed the other car until its clock was synced.
                    Tested (Linux): two headless nodes on 7421 / 7422 without seeds plus a game on 7419
                    all knew each other within 10 s.
                    Measured (localhost): two nodes with 120 + 80 messages both end with 200 in one sync.
                    Three nodes where B and C only know A: after one round each knows the other two.
                  Weather between peers: Snapshot = Snapshot_Header + Weather, the exact file / wire bytes.
                    snapshot_check(bytes) -> (^Snapshot, why): size, magic, version, sha256, weather_valid.
                    The one check for disk (weather_load_snapshot, cache/snaps) and network.
                    cache/snaps/<sha256 hex>.snap, max SNAP_KEEP = 32 (~730 KB): the node's own snapshot
                    (fetch thread after every fetch, cache/weather.snap at start) and every snapshot a live
                    offer in the store names (offer.weather). After each sync the node asks that peer
                    ('W' + sha256) for up to 4 it does not have; a peer that lacks one answers 0 and it
                    does not count. Kept only when snapshot_check passes and the hash is the one asked
                    for. Full: drop the oldest (fetched_at) that no live offer names, else the oldest.
                    Names are written from the hash digit by digit, never from peer text. Files that fail
                    the check at start are deleted. snap_read(sha256, out) for the game: a passenger
                    recomputes an offer's route with the driver's weather (matching / verify items).
                    Weather still only reaches the simulation through a file and snapshot_check.
                  Trip and live position (w.trip, one trip at a time, zero = none, frame loop only):
                    trip_keypair(w) -> x25519 public key, fresh per trip, goes into the signed Request
                      (passenger) or Accept (driver), so the key exchange is authenticated by ed25519.
                    trip_start(w, request, accept, driver): checks accept answers that request and offer and
                      that this user is the author of its side, x25519 shared secret (all zero = low order
                      point, refused), key = HKDF-SHA256(salt accept id, ikm shared, info "drift live position
                      v1"), wipes the private half. Trip id = accept id. trip_end(w) wipes it.
                    Live_Packet (88 bytes): trip id, seq, from_driver, Live_Position (x, y km, alt m, time)
                      encrypted with ChaCha20-Poly1305, header bytes as aad. Nonce = seq + direction byte, so
                      both directions share the key but never a nonce. live_seal / live_open; open drops the
                      own direction, seq <= last accepted (replay) and anything that does not verify.
                    Game side: live_send(w, pos) seals and leaves the packet in w.node.live_out, live_poll(w)
                      opens the newest one the node thread found. No network in the frame loop.
                    Through peers (node_live, sync thread, every 1 s while live_out is set): the packet goes
                      to this node's own table and to up to 8 peers that synced in the last minute ('L'),
                      and each is asked for the other direction's latest ('M'); the highest seq wins. Not
                      gossiped: it reaches the other side through any node both talk to. Nodes keep the
                      latest packet per trip and direction, 1024 slots, 60 s, memory only, never on disk,
                      and cannot read them. A node cannot tell garbage with a higher seq from a real packet,
                      so someone who knows a trip id can spoil it at one node; the receiver asks every node
                      it reaches and only keeps what verifies.
                    Tested: two processes, offer -> request -> accept through sync, both started the same
                      trip, positions both ways every second (heard 19 of 24, only the newest is kept).
                      The 21 checks from #25 (replay, flipped ciphertext, changed seq, own direction, guessed
                      key, low order point, a third user claiming the passenger role) pass on the node table.
                  Headless node: drift --headless --node [--port <n>] (debug host and release exe). game_init,
                    then node_poll, no window and no frame loop, runs until killed. Same store, sync, peer
                    files and cache/ as the game, so run it in its own directory. Exits 1 when it cannot
                    listen (a node nobody can reach helps nobody). "[node] 120 messages, 3 peers,
                    2 reachable" every 5 min. Killed mid-append the store file can end in a partial
                    message: the next start moves it to messages.log.bad and starts empty, peers resend.
                  The same format is used by headless --snapshot, test/data and bench. Logs go to stderr.
  debug.odin      tools for finding bugs. Profiler: prof_begin() / prof_end(w, block, tick) store the last ms of
                  Update, Draw, Route, Weather_Load in w.prof, compiled out in release (PROFILING =
                  DRIFT_DEBUG || DRIFT_PROFILE). Overlay drawn in game_update, F3 toggles: frame ms with
                  update / draw split, worst of the last 120 frames, route and weather load ms, perm / route
                  arena used / reserved, frame arena use, 120 frame graph (yellow line = 4 ms budget, red bars
                  over it). Frame ms excludes EndDrawing (vsync wait) and the overlay itself.
                  Headless: ./build/drift --headless --snapshot <file> --inputs <file> runs without a window,
                  prints the result to stdout (deterministic text, no timings) and timings / errors to stderr,
                  exit code 0 or 1. game_headless (exported, called by host and release main) reads the inputs,
                  headless_run(w, snapshot_path, inputs, out) loads the snapshot (weather_load_snapshot, the
                  cache/weather.snap format) and does the work and is what test/ calls.
                  Inputs: one command per line, # comment. "route <from hub> <to hub> <mode> <hour>",
                  hub = index into w.m.hubs, mode fastest / greenest / calmest, hour 0..8.
                  "no_fly <x km> <y km> <radius km> <ceiling m>" fills the next free slot of w.no_fly.
                  "gust <x km> <y km> <radius km>" fills the next free slot of w.gust_zones.
                  "plan <from> <to> <hour>" prints the three summaries and their maneuvers (nav.odin).
                  "fly <mode> <max s> [gust after s]" flies the autopilot at 1x, prints new maneuvers, reroutes and
                  the arrival. "drive <x> <y> <s> <turn>" lands on the nearest road and drives (road.odin).
                  "free <x km> <y km> <height m> <heading deg> <throttle> <turn> <climb> <s>" puts the car at rest
                  there and flies the street view's free flight (ship_free_step) with fixed controls, "free_on
                  <throttle> <turn> <climb> <s>" flies on; each prints the end position, height above the ground,
                  speed, wall hits and the steps the car's centre was inside a footprint (must be 0).
                  test/ run_free_flight uses it on a real Brussels building found in the collision data: full
                  throttle into a wall stops 2.2 m from it, never inside; down onto the roof it hovers 0.9 m over it
                  and stays; full throttle in open country reaches 70 m/s (252 km/h); across the wind of
                  windy.snap at 300 m it drifts 0.8-1.05 x wind x 20 s; the same inputs twice give the same flight to
                  the bit. Checked that it fails without walls (125 m through) and without roofs (0.9 m above the
                  ground).
                  Output per route: "route 6 -> 11 fastest hour 0: 2 points, 104.812 km", then x y alt per point.
                  --dump appends the state dump after the result.
                  Scripted run: ./build/drift --script <file> (debug host and release exe, exported game_script)
                  opens the real window and runs the game frame by frame from a text file, for visual checks with
                  screenshots. Every frame is exactly SIM_DT and steps the simulation once (frame_time(w)), keys
                  and the street view's mouse look come only from the script (key_down / key_pressed /
                  mouse_delta / mouse_wheel in input.odin, real input is ignored), no weather fetch, no network
                  node, weather from "snapshot <file>" or the embedded fallback, the cursor is not locked, 60 fps
                  like the game (unlimited fps tore the window and looked like flicker). Commands: ship <frame> <x km> <y km> <height m>
                  <heading deg>, down / up / press <frame> <raylib key name>, mouse <frame> <dx> <dy>,
                  wheel <frame> <notches>, shot <frame> <png> (LoadImageFromScreen + ExportImage after the frame
                  is drawn: TakeScreenshot drops the directory), quit <frame>. frame_ms <ms> ... repeats uneven frame
                  times instead of SIM_DT (a frame then steps 0, 1 or 2 times, as on a real screen). flicker <from>
                  <to> <max %> counts the pixels that jump away and back between three frames (A-B-A, > 60 summed
                  over r, g, b), which smooth motion never does, and logs FAILED above max %.
                  test/data/street_flicker.txt flies fast with uneven frames (max 0.1 %): 0.054 % over the roofs,
                  0.008 % in a street (2026-11-21); without the render interpolation 0.96 % and 0.44 %. The loading screen covers frames
                  0..~80. The window stays 1440 x 900: SetWindowSize on a macOS Retina screen leaves raylib
                  drawing into a quarter of the framebuffer. Shots go to build/shots/ (not in git), the
                  standard scripts are test/data/street_*.txt.
                  Log: logf(w, system, format, args) prints "[route t=1234] message" to stderr, t = w.tick.
                  No allocation (1 KB stack buffer, longer messages are cut). Code without a World
                  (fetch thread, argument parsing) prints "[system] message" with fmt.eprint.
                  State dump: dump_world(w, out) writes tick, build, map counts, hubs, weather start / sha256 /
                  fetched_at, a weather line per hour
                  (max wind per layer, max gust, mean cloud), no-fly zones, gust zones, blocked nodes per layer
                  and arena used / reserved. No timings, so two dumps
                  of the same run are identical. F5 in the app prints it to stdout, --dump in headless mode.
                  Windows release is -subsystem:windows and has no console: use the debug or profile exe there.
  ship.odin       Controls struct: throttle, turn, climb, each -1..1, zero = neutral. Filled by input, read by the
                  camera in map mode (game.odin), by ship_step in drive mode.
                  Ship: pos (km, map space), alt (m), heading (rad clockwise from north), speed (m/s), turn_rate (rad/s).
                  ship_step(w, controls, dt) runs once per fixed 60 Hz step in game_update on w.ship, reads only the
                  ship, the controls and height_at. Limits: speed follows max(throttle, 0) * 35 m/s with +1.2 / -1.6
                  m/s^2, turn rate follows turn * 0.6 rad/s with a 0.5 s time constant, climb 5 m/s, altitude clamped
                  to height_at + 28 m .. 900 m. Wind: ground velocity = heading * speed + wind_at of the layer nearest
                  to the altitude, hour = tick / (60 * 3600). Battery comes later.
                  Ship.warnings: bit_set of Terrain (less than 60 m above the ground) and No_Fly (inside a w.no_fly
                  circle below its ceiling), rebuilt every step. The UI only reads it.
                  Ship.docked / dock_hub: set when within 30 m horizontally and 25 m vertically of a hub's tower top
                  (ground + HUB_TOWER_M), first hub in index order, rebuilt every step.
                  Replay: every step the controls are packed to Control_Step ([3]i8, 3 bytes) and the ship steps with the
                  unpacked value, so the recording reproduces the path exactly. w.replay.steps is 60 * 3600 steps (1 h,
                  648 KB) from the perm arena, w.replay.count says how many are filled, recording stops when full.
                  Bench (profile build, 2026-11-21, Windows, height_at still a stub): ship_step min 59 / avg 65 / max 319 ns
                  against the 1 us budget. It is ~2 sin/cos, wind_at (8 ns), 15 hub distances and 8 zone checks. The tower
                  height_at is only called for a hub that is within 30 m horizontally, not for all 15, because the real
                  height_at will cost more than the stub.
  input.odin      read_controls() -> Controls, called once per frame into w.controls. W/S throttle, A/D turn (right = +),
                  R/F climb up / down (arrows = W/A/S/D, PgUp / PgDn = R / F), gamepad 0: left stick throttle + turn, right stick Y climb. Keyboard and stick
                  add up, clamped to -1..1. Deadzone 0.15, rescaled so the stick still reaches 1.
  airship.odin    The flying car (Lars, 2026-11-21: "iets realistisch in 3d"): assets/car.bin.gz from tools/bake_car
                  (Car Concept, Khronos glTF sample, CC BY 4.0 Eric Chadwick, credited bottom right, assets/car-LICENSE.txt),
                  unpacked once in game_init (airship_build) into body parts + 4 wheels, lit by CAR_VS / CAR_FS (paint,
                  glass, metal, lights, matte by material class). Drawn through an orthographic Camera3D, CAR_PX 110 px
                  long at every zoom, with a soft shadow. Car_Anim eases fly (wheels fold flat with a cyan glow disc in the
                  air, roll on the road), bank with turn_rate, pitch with the climb, a slow bob. others_draw draws the
                  other cars (presence.odin) 80 px, tinted, orange in a traffic jam.
  presence.odin   (author andrei) other cars on the map, peer-to-peer (Lars: "geen relay service, gossiping"): every
                  PRESENCE_S 2 s the game signs its position (Presence, 136 bytes, ed25519 identity) and the node swaps
                  the fresh positions it knows with up to 8 recently synced peers (op 'Q'), so they spread over several
                  hops. Checked (magic, on the map, time within 20 s back / 30 s ahead, signature), newest per author,
                  256 slots, copied into w.others every 0.25 s and moved on along heading x speed when drawn.
  traffic         (route.odin, ship.odin) traffic jams (Lars: "file ook"): every other flying car counts for the
                  grid nodes within TRAFFIC_RADIUS_KM 1 km in its own layer (traffic_build, per route). From
                  TRAFFIC_MIN_CARS 4 a node costs 1 + 0.5 per car over the minimum, at most 4x, in A*, line_cost and
                  evaluate, so routes go round a jam (test case traffic). The ship slows by the same factor among the
                  cars on its own way (road, or the same layer) and shows the Jam warning. Our values.
  buildings.odin  3D buildings (Lars: "ik wil 3d gebouwen"): assets/buildings.bin.gz (tools/bake_buildings, see
                  BUILDINGS DATA), one mesh per city of walls + flat roof lit from the north-west, roof / wall colors
                  from the palette. Heights 1.6x real and lowered towards the edge of the 1 km circle; they grow out
                  of the ground between zoom 3.5 and 5 (height_scale uniform). Cities beyond 6 km + the view are skipped.
                  A city mesh holds its points relative to the city origin.
  tiles.odin      Tile_Cache: square tiles around the camera, each its own mesh (towns, nature, street roads), at most
                  2 built per frame, nearest first. Placement {axes, origin} says where a draw puts map meshes (the
                  map: identity; the street view: metres, y up, around the street origin); meshes keep their points
                  relative to an anchor (tile corner, city origin) and place_at(place, anchor) takes anchor - origin
                  in f64. With km points (~150) x 1000 in f32 the street view's 3D buildings z-fought: 1.7 % of the
                  pixels jumped colour between two frames of a 0.1 px pan from the tower, now 0.09 % (edges only).
  nature.odin     tree clumps (six-sided crowns, 25-50 m wide, 10-24 m high) placed by a hash in the park / wood
                  triangles within 14 km of the camera, 70 per km2, rebuilt after 4 km; the buildings' shader.
  clouds.odin     clouds from the forecast cover (cloud_at): a puff spot per 1.6 km cell, clumped by value noise,
                  cloudy where the noise is under 0.1 + 0.9 x cover, 650-1100 m up, drifting with the top layer
                  wind. Soft sprites in screen space (far first) with a ground shadow, fading in from zoom 2 to 3.5
                  and out when one fills the screen. Our values.
  render pose     (ship.odin Ship_Pose, game.odin) w.pose is where the ship is drawn: between w.pose_prev (the state
                  before the last fixed step) and now by accum / SIM_DT, in f64 km with pos_frac. The street view,
                  the car, its animation and the map's chase camera read it. Drawing the raw state jumped 0, 1 or 2
                  steps per frame with uneven frame times while the cameras eased per frame: buildings and roads
                  shook (Lars: "het flikkert"). A jump of > 200 m or no stepping (plan screen) draws the state as is.
  street.odin     (Lars) the street view (Lars, 2026-11-21: "een 3d game waar je tussen huizen kan vliegen, zoals
                  gta in third person, zo realistisch mogelijk"). V on the navigation screen (or the plan screen, which
                  goes to free flight first) switches it on, V or Esc back to the map; the cursor is locked while on.
                  Street space: metres, x east, y up, z south, around w.street.origin (km, snapped to 0.25 km so the
                  f32 values stay small). street_place puts the map meshes (km, y south, z down) there (tiles.odin). The
                  ground is flat: the car is drawn at alt - height_at, like the buildings stand on the map. Clip
                  planes 0.25 / 4000 m (rlgl.SetClipPlanes, restored after): raylib's own 0.05 m near plane made
                  one depth step ~0.3 m deep at 500 m. The camera keeps 0.6 m from walls. Haze closes at 3.5 km.
                  Camera: chase behind the car (8.5 m, wheel 4..40 m), mouse / right stick looks around and swings
                  back after 1.6 s, never inside a wall (collide_car along the line), FOV 62 + 10 at top speed, a
                  short shake after a hit. Draws: sky gradient, land quad, land use with natural colors (ground
                  shader remaps the palette colors), road ribbons per 1 km tile at real width with lane markings,
                  buildings at real height (height_scale 1 / BUILDINGS_HEIGHT_X), towns, trees, the cars at real size
                  (car_draw_street: no bob, no glow) with a contact shadow, then a HUD (speed, height, heading).
                  Ground layers: land, land use, rivers, roads and markings all lie on y = 0. The depth buffer cannot
                  order them: the street_transform meshes (km x 1000 minus ~150 km in f32) got a depth off by 1.6e-6
                  .. 2.6e-6 NDC against the land quad at 280 m (measured), 6-10x the old 2.5e-7 layer bias, so land
                  use and roads lost the depth test at random and only bits of road showed (the old KNOWN BUG,
                  found with --script and a magenta background). Nothing stands below the ground and the camera is
                  always above it, so the ground shader writes the far depth minus 2e-7 per layer (gl_FragDepth):
                  later layers win, ties go to the draw order, everything 3D drawn after is nearer.
                  Data gap: belgium.bin has roads down to tertiary only and no land use in most of the old centres,
                  so between the real buildings of Brussels the residential streets and squares are bare land.
  collide.odin    (Lars, simulation, no raylib) collide_car(w, pos, hag, radius_m) -> (push m, roof m): the car as a
                  circle against the building footprints the street view draws. Real buildings from BUILDINGS_DATA
                  with a 100 m cell list per city (2.4 km square), generated town buildings made again from the City
                  triangles around the point (town_lot, shared with towns.odin) with a 1 km cell list. Built on first
                  use from the perm arena. 2026-11-21: 70582 buildings, 99243 cell entries, 76009 triangle entries.
  free flight     (ship.odin) ship_free_step, used in the street view when nobody else flies (not the autopilot):
                  velocity with momentum, thrust 8 m/s^2, quadratic drag to 70 m/s, sideways grip 2.4/s against the
                  air (crabs in a crosswind), turn 1.4 rad/s hovering .. 0.55 at top speed, altitude hold (climbs
                  settle at ~12 m/s), wind of the car's layer weaker below 80 m, gust index as smooth turbulence,
                  hovers 0.9 m over the ground or a roof, pushed out of walls losing the speed into them. pos_frac
                  keeps the part of the position below the f32 resolution of pos. Leaving the street view hands the
                  forward speed back to ship_step. Not recorded in the replay yet (the free flag is not a control).
  route.odin      route(w, from, to, mode, hour) -> (path, ok). Points are [3]f32 (x km, y km, alt m).
                  ok = false means no safe route with this wind. Hub positions: w.m.hubs.
                  from.z / to.z are the tower tops (headless: height_at + HUB_TOWER_M).
                  Path lives in w.route_mem until the next call: the smoothed path below, from the tower top
                  + 6 m at from to the tower top + 6 m at to. A* never enters a blocked node (see below).
                  ok = false also when from or to has no free node within 5 cells (outside the grid,
                  inside a no-fly zone): grid_free_node_near picks the closest free cell centre, lowest free
                  layer first (spec), the altitude of the end point is not used.
                  Grid: 286 x 237 cells of 1 km x 3 layers (LAYER_ALT) = 203,346 nodes, covers every point
                  in belgium.bin (x 0.6..285.2, y 1.0..236.5 km). node = layer * 286 * 237 + y * 286 + x,
                  each layer a contiguous row-major plane. grid_node_at(pos) snaps to the cell under x, y
                  and the closest layer, grid_node_pos(n) gives the cell centre, grid_neighbor(n, d) steps
                  one entry of GRID_DIRS (8 horizontal directions, up, down) and fails past the edge.
                  w.grid holds the search state as fixed arrays in World (no arena, allocated with World):
                  visit stamp, cost, parent, heap slot and heap item per node. A node's cost and parent only
                  count when visit[n] == grid.search, so a route starts with search += 1, not a 4.9 MB clear.
                  Cost per mode (spec), per edge inside the A* loop:
                    fastest  18 m/s  seconds          dt                                vertical 0.2 x climb m / 3
                    calmest  13 m/s  seconds          dt x (1 + 7 g^2)                  vertical 0.2 x climb m / 3
                    greenest 11 m/s  kWh   (P(v, g) - S(c)) dt / 3600 + 0.25 g^2 km   vertical climb_kwh + 0.02
                  dt = km x 1000 / ground speed, g = gust index, c = cloud cover. Wind, gust and cloud = mean of
                  the two node centres.
                  Energy model (spec), in route.odin, also for the ship and the metrics: BATTERY_KWH 180,
                  BATTERY_START 0.86 (a ship leaves with 154.8 kWh), power_kw(v, g) = 3 + 0.0085 v^3 + 6 g,
                  solar_kw(c) = 9 x 0.75 x (1 - 0.78 c) (6.75 kW clear, 1.49 kW overcast), climb_kwh(m) =
                  0.12 kWh per 100 m up, 0.04 per 100 m down (a 250 m layer change: 0.30 / 0.10 kWh).
                  P(11, 0) = 14.3 kW is above the strongest sun, so greenest edges never cost less than zero.
                  Calm and clear at 11 m/s: 0.19 kWh per km, overcast 0.32.
                  Ground speed (spec), ground_speed(v, wind, dir): tailwind + sqrt(v^2 - crosswind^2) along the
                  edge. Blocked when the crosswind is stronger than v (no retry, as the spec reads). Under
                  2.5 m/s the edge is flown at v + 6 m/s (that v also goes into P for greenest), still under
                  1.5 m/s it is blocked. NaN wind blocks the edge.
                  Wind cache: grid.wind / grid.gust hold wind_at / gust_at at every node centre for one hour
                  (12 B x 203k = 2.4 MB in World), grid.cloud cloud_at at every cell centre (one layer, 4 B x 68k
                  = 271 KB), rebuilt when the hour or that hour's forecast changes (compared to a 2.5 KB copy,
                  so a new snapshot is picked up without a flag). Zero is a calm, clear hour 0. The three modes
                  and every route in the same hour share it. Build ~2.6 ms -o:speed (406k bilinear samples).
                  Estimate (grid_estimate, Estimate built per route): per grid direction k, rate[k] = the mode's
                  cost per km with the strongest tailwind along k anywhere in the hour (max over the 189 weather
                  grid points of wind . k), the calmest gust and (greenest) the clearest sky; bilinear sampling
                  never leaves the range of the grid points, so no edge in direction k is cheaper. When the wind
                  can push the ground speed under 2.5 m/s (wind_max > v - 2.5) rate[k] also takes the cost at v + 6
                  with ground speed at most min(v + 6 + tail_k, 2.5 + sqrt((v + 6)^2 - v^2)), whichever is lower. The cheapest way to cover a displacement with
                  such moves is a small LP; any y with y . k <= rate[k] for all k gives the lower bound
                  y . displacement (duality). Estimate.y holds the best such y per 45 degree sector (the edge of
                  the cost polygon there, found by trying all 28 direction pairs) and the estimate is the max of
                  the 8 dot products + layer changes x cheapest climb. Consistent (each y alone never overestimates
                  an edge), so an expanded node is never reopened. Rates stay positive (power >= 3 kW + 0.0085 v^3 >
                  the 6.75 kW solar maximum at every airspeed), so the LP has a valid y in every sector. With a wind field that has one main direction
                  it follows the wind (windy.snap: 4x fewer expanded nodes than one strongest-wind rate for all
                  directions); with random wind per cell every direction has a strong tailwind somewhere, there
                  it gains ~8 %.
                  The loop precomputes the node index step, unit vector and length per direction, so it does no
                  division per neighbour (the outer ring is always blocked, so no bounds check for x / y). Edge
                  costs go through flight_cost (ground speed rules, solar) and mode_climb_cost (signed climb).
                  Weighted x 1.001 to break the many near-ties of an open grid (at most 0.1 % above the cheapest).
                  Checked: cost equals a plain Dijkstra (estimate 0) within 1e-6 on 126 routes x 3 modes, windy
                  and random wind snapshots. Again with ground speed: same found / not found and cost within
                  3.2e-6 relative (f32 sums in another order) on 4455 routes: all hub pairs x 3 modes x hours
                  0 / 4 / 8 on windy.snap and headwind.snap (1607 found), 405 on random wind up to 35 m/s.
                  Again with the energy model: 540 routes (180 random hub pairs x 3 modes, calm and clear plus
                  5 snapshots with random wind up to 36 m/s, gust and cloud 0..1): all found by both, A* at
                  most 0.0003 % above Dijkstra.
                  Path cleanup (spec, in this order, in route() once A* reaches the goal):
                    1. string pulling: from each kept node jump to the farthest of the next 14 nodes (PULL_WINDOW)
                       in the same layer whose straight line is free and costs at most 0.4 % (PULL_TOLERANCE)
                       more than the A* path between them (g.cost difference). line_cost(g, a, b, mode) walks
                       the cells the line crosses (Amanatides-Woo), each piece costs as an edge (flight_cost,
                       shared with the A* loop) with the weather of its cell; a blocked cell or a blocked piece
                       makes the line not free. A line through a cell corner does not enter the cells beside
                       it, the same as a diagonal A* step. Never across a layer change.
                    2. towers: first and last point at the tower top + 6 m (TOWER_ABOVE_M), with a ramp point
                       halfway between the tower and the first (last) node, at that node's altitude (nasr, #45).
                    3. Chaikin x3 (points at 1/4 and 3/4 of every segment, the towers stay), then resampled every
                       RESAMPLE_KM of horizontal distance, the last point is the end tower. 250 m, not the spec's
                       20 m (a 5 km map): the heightmap spacing, so the clearance sees every height cell (nasr, #46).
                       20 m gave ~10.7k points per route and test files over the 1 MB limit.
                    4. slope limit 0.24 (SLOPE_MAX): a forward pass caps the climb, a backward pass the descent,
                       both only lower points and leave the towers, then z >= height_at + 40 m
                       (TERRAIN_CLEARANCE_M).
                  Oostende -> Liege (213 km): 189 A* nodes -> ~15 kept -> 856 points, route arena 2 -> 14 KB.
                  Chaikin cuts corners of the pulled lines, so the smooth path can clip blocked cells: on
                  2700 routes with random zones 3 points were inside a zone, at most 36 m deep (a zone blocks
                  every cell it overlaps, so the cell margin absorbs most of it). Tower legs (hub -> first node,
                  up to 5 cells) are not checked against blocked cells, as in the spec: a hub inside a zone
                  (Mechelen in no_fly.txt) is still reached by its tower leg.
                  Checked (2700 routes: all modes, calm / windy / headwind / cloudy, random zones): ends on the
                  tower tops + 6, chord between points <= 250 m, every slope <= 0.24, every point >= ground + 40.
                  line_cost against a 0.1 m step integration on 19k random lines: cost within 2.1e-6, the free
                  test agreed except one line through a cell corner (the brute force counts the corner).
                  Measured (cloud box, -o:speed): cleanup adds ~0.05 ms to Oostende -> Liege (calm route 0.038 ->
                  0.088 ms), with the height_at stub; estimate ~0.05 ms (~250 lines of ~8 cells x ~20 ns + 856
                  points). Bench route avg 8.6 -> 8.0 ms, three modes 23.0 -> 22.0 ms (noise, A* dominates).
                  Open set: binary min-heap on f in grid.heap (fixed array, 8 B x 203k) with grid.slot
                  (index in the heap, HEAP_CLOSED once expanded) for decrease-key. No allocation during
                  the search, the path is the only allocation (route arena). Search state 28 B x 203k = 5.7 MB.
                  Scan order (for the A* scan animation): grid.expanded[:grid.expanded_len] holds the nodes in
                  the order the last route expanded (popped) them, start first, goal last on success. Fixed
                  array of 203k Node (813 KB) in World: a node is never reopened, so it always fits. Reset to
                  0 at the start of every route, so a route that fails before A* (no free end node, separate
                  regions) leaves an empty scan, and one that fails during A* holds every node it searched.
                  Valid until the next route call. The renderer only reads it, the router does no extra work
                  beyond one store per expanded node. The state dump prints expanded_len.
                  Blocked nodes (spec): highest ground in the cell + 75 m above the layer, the outer ring of
                  cells, or a no-fly zone below its ceiling. w.no_fly: [8]No_Fly_Zone (centre km, radius km,
                  ceiling m), radius 0 = unused slot, zero = no zones. A zone blocks every cell it overlaps,
                  not only the cells whose centre it covers. grid_blocked(g, n) reads one bit.
                  Two bitsets of 25 KB in w.grid: terrain (edge + ground, 25 height_at samples per cell every
                  250 m = the heightmap spacing, 1.7M calls) and blocked = terrain + zones. route() builds terrain
                  on first use and after a hot reload, and rebuilds blocked when w.no_fly differs from the zones
                  it was built with. Nothing in it depends on the forecast hour, so changing hour costs nothing.
                  Gust zones (spec "Gust melden"): w.gust_zones: [4]Gust_Zone (centre km, radius km), radius 0 =
                  unused slot. Reported in flight, they block like a no-fly zone without a ceiling (every layer):
                  the spec gives a reported zone no altitude limit. route() rebuilds blocked and the regions when
                  w.gust_zones differs from grid.blocked_gusts, so the next route call is the reroute around them.
                  Not built yet: the report action (where the zone goes, see todo) and clearing zones.
                  Measured (cloud box, -o:speed): route right after a new gust zone avg 5.5-6.6 ms, max 13 ms,
                  almost all of it the region flood fill (bench "route after gust", route budget 10 ms).
                  Checked against a brute force over all 203k nodes with random no-fly + gust zones (40 rounds).
                  A* skips blocked neighbours. With blocked also the free regions are labelled (flood fill over
                  the A* steps, grid.region per node, the open heap is the stack): start and goal in different
                  regions fail at once. Without it a walled-in hub expanded every reachable node (33 ms -o:speed).
                  Measured (cloud box, -o:speed / debug): terrain + regions on first use 4 / 120 ms with the
                  height_at stub, zones + regions after a zone change 4 / 42 ms, cached route unchanged
                  (bench three modes avg 22 -> 26 us, mostly the two 11 x 11 free node searches).
                  Checked against a brute force over all 203k nodes (zones overlapping, at the grid edge,
                  partly outside, smaller than a cell, NaN / Inf zones ignored), a whole-grid closest free node,
                  and 135 routes with random zones against a Dijkstra on the blocked grid (same cost within 0.1 %).
                  Measured before the wind costs (cloud box, -o:speed): 2025 routes between all city pairs
                  x 3 x 3 layers, avg 14 us, worst 0.19 ms; corner to corner expands 286 nodes.
                  With wind costs (bench, random wind up to 21 m/s, 4-core cloud box, profile): route avg 6.2 ms
                  incl. the cache build when the hour changes (max 23 ms), three modes avg 14.8 ms (max 89 ms).
                  The estimate assumes the strongest wind as tailwind everywhere, so strong wind means a weak
                  estimate: ~19k expanded nodes per route, ~320 ns each. Without the cache: three modes 33 ms.
                  With ground speed (same box, 3 runs each, A = before / B = after): route avg 5.7-6.2 /
                  6.3-6.8 ms, three modes 14.2-14.9 / 17.0-18.6 ms. The crosswind makes edges dearer than the
                  pure tailwind estimate, so 7-9 % more nodes are visited (fastest 15.3k -> 16.4k, calmest
                  33.7k -> 36.1k, greenest 25.8k -> 28.1k on random wind up to 21 m/s), plus a sqrt per edge.
                  With the energy model (4-core cloud box, profile, 2 runs each, before / after): route avg
                  7.7-8.0 / 8.0-8.2 ms, three modes 20.7-21.5 / 22.2-22.5 ms, within the noise of this box.
                  The cloud cache adds 68k cloud_at calls (~0.7 ms) when the hour changes.
                  Per-direction estimate and loop precompute (Lars, measured on the cost model before ground speed
                  and energy): route avg 6.2 -> 5.3 ms, three modes 14.8 -> 11 ms. With random wind per weather
                  cell the estimate stays weak: the worst routes expand up to 70k of 203k nodes. A 4-ary heap
                  measured no faster. Open: #66 (may the bench use a smooth wind field).
Units everywhere: horizontal km (map space, y down), altitude m, speed m/s, energy kWh.
test/main.odin    the one test program: odin run test -out:build/test (from the repo root, the hook and CI run it).
                  Each case = snapshot + inputs through game.headless_run, output compared line by line to the
                  .expected file. On a mismatch it prints the first differing line and writes the full output
                  to build/test_<name>.txt. Expected files change only with the owner's approval.
  test/data/      snapshots in the cache/weather.snap format (valid sha256, fetched_at 1795176600).
                  calm.snap: zero wind / gust / cloud, start 1795176000. nan_wind.snap: same with
                  wind[3][1][20].x = NaN, must be rejected by weather_valid. routes.txt: one route per mode, hours 0 / 4 / 8,
                  a route to the same hub. calm_routes.expected: smoothed paths (path cleanup).
                  windy.snap: same start, every hour: 300 m wind (-4, 0), 550 m calm, 800 m (12, 0) m/s; gust 0.1,
                  0.8 on 800 m at weather grid columns x > 120 km; cloud 0.3. windy_routes.txt: 6 -> 10 in each
                  mode and 10 -> 6 fastest. Expected: fastest stays on 800 m, calmest leaves it at x 136 km,
                  greenest at x 149 km on the grid (both where the gust ramp makes 550 m cheaper; the smoothed
                  path starts down at x 131 / 144 km), westbound stays on 300 m.
                  no_fly.txt: Brussels inside an 8 km zone (no route from or to it), a 3 km zone on the
                  Mechelen - Leuven line (goes around), Antwerpen under a 400 m zone (leaves from layer 1),
                  Mechelen in a 2 km zone (ends at the closest free node outside it).
                  Greenest flies its east steps on 800 m (23 m/s ground speed) and its diagonals on calm 550 m:
                  a diagonal on 800 m makes only 15.5 m/s because of the crosswind.
                  headwind.snap: same start, every layer (-15.54, 0) m/s in hours 0..7, (-20, 0) in hour 8; gust
                  0.1, cloud 0.3. 15.54 makes every ground speed rule decide a route (table in
                  headwind_routes.txt): fastest only goes east on the retry, calmest needs the retry and has no
                  south steps, greenest zigzags on the diagonals (east stays under 1.5 m/s), hour 8 greenest has
                  no safe route. Dropping the retry, the 1.5 floor or the crosswind each changes the output.
                  cloudy.snap: same start, calm, no gust; hours 0..7 cloud 1 on the weather points x 80..200 km,
                  y 80..120 km, 0 elsewhere, hour 8 cloud 1 everywhere. cloudy_routes.txt: greenest Oostende ->
                  Liege flies north of the clouds (222.1 km smoothed instead of 213.6 km), fastest and
                  greenest in uniform overcast take the shortest path. Without the solar term all match.
                  scan_order (code, no .expected): grid.expanded after routes between all 15 x 15 hubs on
                  calm.snap: starts at the start node, ends at the goal, no node twice, none blocked, every path
                  node in it; the same route twice gives the same scan; a route that fails before A* leaves 0.
                  gust.txt: a 260 m gust zone on the Mechelen - Leuven line (goes around it, stays at 300 m),
                  a 3 km gust zone over Antwerpen (start moves out of it, every layer is closed), a no-fly
                  and a gust zone in the same route.
                  Snapshots were written byte by byte from the format above. Add a real fetched snapshot
                  (copy a cache/weather.snap), the synthetic ones have uniform wind per layer.
bench/main.odin   odin run bench -o:speed -debug -define:DRIFT_PROFILE=true -out:build/bench, before every merge.
                  200 rounds; wind_at / gust_at / cloud_at / height_at over 4096 fixed-seed points per round,
                  route, three modes, route after a new gust zone (blocked + regions rebuilt), snapshot load,
                  load_map one call per round. Prints min / avg / max per call and arena usage, exits 1 when
                  an average is over a budget (route and route after gust 10 ms, three modes 30 ms, snapshot
                  load 5 ms). Not run by the hook or CI: CI machines are too noisy for timings.
  measured 2026-11-21, Linux on Apple M2 (Asahi), profile config, timer resolution ~42 ns:
                  wind_at / gust_at / cloud_at ~3.6 ns per call (~10-15 cycles: two float divides, clamps,
                  4 loads from L1, ~20 flops; estimate 3-5 ns). An earlier run on the branch gave ~10 ns,
                  probably an efficiency core: pin the bench to one core type before comparing numbers.
                  route (stub + grid snap) ~0.3 us. Snapshot load ~23 us: read 22.7 KB from the page cache,
                  sha256 (~10-15 us at ~2 GB/s), validation, copy; budget 5 ms. load_map ~0.2 us.
source/host/      debug host: loads build/game.so (game.dll on Windows), checks its mtime every frame, copies it to
                  build/game_N.so and loads the copy, unloads the old one after. Compares memory_size,
                  refuses a reload if World changed (restart needed). Calls game_before_reload on the old
                  library right before unloading it (stops the weather thread). Run from the repo root.
source/release/   release main: calls the game package directly, one static exe

World memory
  World is bootstrapped inside its own perm arena (virtual memory), so it survives reloads.
  Arenas: perm (World, map, long lived), route_mem (reset per route), frame (temp_allocator, reset per frame).
  w.weather is a fixed-size Weather inside World (22.7 KB), so it needs no weather arena.
  game_update sets context.allocator = perm and context.temp_allocator = frame.

DESIGN INTERFACES (built on lars/all-todos; from docs/drift-design.pdf, the todo items under "design")
The look and feel is docs/drift-design.pdf (Dutch): screens, sizes, colors, fonts, motion. Only the look:
names, values and logic come from the code on main. Place, road and river names are the real ones in
belgium.bin (never the doc's examples), wind layers are LAYER_ALT, zoom is ZOOM_MIN / MAX, and doc features
on the NOT DOING list in todo.txt (shadows, touch / mobile layout, speech) are not built. 3D buildings,
nature and clouds came off that list on 2026-11-21 (Lars).
Each person owns their own files, so the parts do not touch the same lines. The owner adds the World
field (one line) and the call in the game.odin draw list (one line) in the PR that builds it.
A signature below changes only with the owner's PR that also updates this section.

Files and owners
  render.odin, ui.odin, map.odin, terrain.odin   nasr    tokens, fonts, icons, ui kit, map, labels
  route.odin, nav.odin (simulation), nav_ui.odin  Lars    routes, maneuvers, nav state, route + banner + sheet
  ship.odin, input.odin, airship.odin,            Dario   ship, keys, airship model, camera,
    camera.odin, pilot_ui.odin                            flying buttons, control pad
  weather.odin, net.odin, plan_ui.odin            Andrei  weather, network, plan screen, layers panel, legend
  presence.odin                                   Andrei  other cars by gossip (network)
  buildings.odin, nature.odin, clouds.odin        nasr    3D buildings, trees, clouds (map rendering)
  street.odin, collide.odin                       Lars    street view, building collision
  (owners of the 2026-11-21 files are our guess from the split above, to confirm in the PR)

World fields (zero = the design default: plan screen, nothing chosen)
  screen: Screen                       nasr    Screen :: enum u8 {Plan, Navigate}
  plan:   Plan                         Andrei  from, to: int (hub id), has_from, has_to: bool, mode: Route_Mode,
                                               hour: int (0..8), layers: Layers
  routes: [Route_Mode]Planned_Route    Lars    filled by plan_routes, path in route_mem
  nav:    Nav                          Lars
  cam:    Cam                          Dario   replaces View
  airship: Airship                     Dario   mesh handles, rebuilt in game_hot_reloaded

Base (nasr)
  palette(w) -> ^Palette               token fields as in the design: surface, surface_2, surface_3, text, text_2,
                                       line, accent, accent_strong, green, banner, banner_2, red, warning,
                                       reroute, arrived, sheet, chip, bubble, bubble_text, pill + map colors
  Font :: enum u8 {Figtree_500, Figtree_600, Figtree_700, Figtree_800, Figtree_Italic_400, Roboto_400,
                   Roboto_500, Roboto_700, Mono_400, Mono_600, Icons}
  Icon :: enum u8                      the icon table of the design (leaf, bolt, waves, tower, ...) + maneuvers
  ui_text(w, pos: [2]f32, text: string, font: Font, px: f32, color: rl.Color)
  ui_icon(w, icon: Icon, centre: [2]f32, px: f32, color: rl.Color)
  ui_card(w, r: rl.Rectangle)                                       18 px corners + shadow
  ui_round_button(w, r, icon: Icon, on: bool) -> bool               48 px map, 64 px nav
  ui_pill_button(w, r, text: string, kind: Pill_Kind, icon := .Close, has_icon := false) -> bool
  ui_chip(w, r, icon: Icon, top, bottom: string, on: bool) -> bool
  ui_toggle(w, r, on: ^bool) -> bool
  ui_segment(w, r, labels: []string, sel: ^int) -> bool
  ui_stat_chip(w, r, label, value: string, meter: f32)              meter < 0 = no meter
  ui_toast(w, text: string)                                         shown 1.6 s, state in World
  All return true on the frame they are clicked. Hit area at least 44 x 44 px.

Camera (Dario)
  cam_to_screen(w, pos: [3]f32) -> (px: [2]f32, visible: bool)     everyone projects through this
  cam_fit(w, lo, hi: [2]f32, screen: rl.Rectangle)                 km box into a screen rect, 0.8 s ease-out
  cam_chase(w)   cam_overview(w)   cam_preview(w, mode: Route_Mode)   cam_recentre(w)

Routes and navigation (Lars)
  plan_routes(w, from, to: int, hour: int)                          all three modes into w.routes
  Planned_Route :: struct {path: [][3]f32, ok: bool, sum: Route_Summary, maneuvers: []Maneuver,
                           times, dist: []f32}                     all in w.plan_mem until the next plan
  Route_Summary :: struct {minutes, km, kmh, net_kwh, wind_ms: f32, tag: Route_Tag, why: [64]u8}
  route_sample(w, mode: Route_Mode, t: f32) -> (pos: [3]f32, heading: f32)   t 0..1 along the path
  Maneuver :: struct {kind: Maneuver_Kind, path_index: int, s_km: f32, text: [48]u8, sub: [48]u8, road: [64]u8}
  Maneuver_Kind :: enum u8 {Straight, Slight_Left, Slight_Right, Left, Right, Sharp_Left, Sharp_Right,
                            Climb, Descend, Depart, Arrive}
  Nav :: struct {mode: Route_Mode, next: int (maneuver index), next_m: f32, then_visible: bool,
                 eta_s, remaining_km, used_kwh: f32, banner: Banner_State, warning: [48]u8, manual: bool}
  Banner_State :: enum u8 {Flying, Rerouting, Arrived}
  nav_start(w, mode: Route_Mode)   nav_stop(w)   nav_set_manual(w, on: bool)   gust_report(w) -> bool
  nav_sheet_rect(w) -> rl.Rectangle                                 Dario places Exit, self-fly, speed from it

Plan screen and weather (Andrei)
  plan_panel_rect(w) -> rl.Rectangle                                for cam_fit (routes go right of it)
  Layers :: struct {hide_wind, hide_gusts, hide_no_fly, hide_solar, terrain: bool, wind_layer: int}
                                                                    terrain = the "3D terrain" map type (hillshade)
  layers_draw_ground(w)                                             gust coloring + no-fly hatching
  wind_note(w, mode: Route_Mode, out: []u8) -> string               one sentence about the wind on the route

Draw order (game.odin, nasr keeps the list; the design's "Tekenvolgorde")
  1 map fills: land use areas, hillshade (nasr)  2 layers_draw_ground (Andrei)  3 road casings, fills, wind
  (nasr)  4 buildings (nasr, not baked: #76)
  5 routes (Lars)  6 airship shadow + airship (Dario)  7 labels (nasr), bubbles, road sign, pill (Lars)
  8 screen UI: Plan -> plan_ui (Andrei); Navigate -> nav_ui (Lars) + pilot_ui (Dario); layers panel (Andrei);
    toasts last (nasr)
Fonts and icons (nasr, #64): Figtree, Roboto Mono and Material Symbols Rounded are allowed. Each goes in assets/
  with its license file next to it, embedded like Roboto (#47). Pin the release, record URL, date and sha256 here.

BUILD
compile.sh [debug|profile|release] [extra odin flags], build.sh wraps it with build-notify
  Linux and macOS. macOS has bash 3.2 and BSD tools: raylib is copied only when newer with [ -nt ]
  (no cp -u), the build time comes from perl Time::HiRes (no date %N), no mold, game.dylib + libraylib.620.dylib,
  rpath @loader_path (the dylib's install name is @rpath/libraylib.620.dylib).
compile.bat same modes on Windows (no mold, raylib.dll copied to build\, random pdb name per build
  so a loaded pdb never blocks the next build, host not rebuilt while drift.exe runs,
  release uses -subsystem:windows). format.bat / check.bat run the .sh versions with Git for Windows sh.
  all modes: -vet -vet-cast -strict-style -warnings-as-errors, -linker:mold on Linux, prints build time
  debug:   host + game.so, -debug -o:none -use-separate-modules (~900 ms for both, 2026-11-21 after
           profiler / headless / log / dump: 874-917 ms, main before them 767-875 ms; limit 2 s)
           game.so uses raylib as a shared lib (RAYLIB_SHARED), copied to build/, rpath $ORIGIN,
           so raylib state survives reloads. Outputs are written to a temp name, then moved.
  profile: source/release, -debug -o:speed, single exe (~2 s)
  release: source/release, -o:speed -disable-assert, single exe (~1.7 s)
  ASAN=1 adds -sanitize:address
  build flags in code: DRIFT_DEBUG / DRIFT_PROFILE (#config in game.odin), set with -define by compile.sh / .bat
           (debug game.so: DRIFT_DEBUG, profile: DRIFT_PROFILE, release: neither). Odin rejects a -define
           nobody reads, so the host gets none. BUILD_MODE is printed at startup ("[game] build: debug").
release exe links raylib statically, map is embedded, only depends on libc, libm and X11

PROJECT SETUP
ols.json, odinfmt.json   Odin language server + formatter (tabs, 110 columns)
.editorconfig            tabs, LF, final newline
.gitattributes           LF everywhere, *.bin / *.pbf / *.pdf binary, geojson marked generated
.githooks/pre-commit     format check (if odinfmt installed) + check.sh + debug build (compile.bat on Windows) + test/.
                         enable: git config core.hooksPath .githooks
.github/workflows/ci.yml job build: ubuntu 24.04, Odin dev-2026-11a, odinfmt check, check.sh,
                         debug + release build, bake reproduces belgium.bin, test/
                         job build-windows: windows 2022, compile.bat debug + release
.github/CODEOWNERS       system files owned by their person + @nasrlol, protected files by @nasrlol
check.sh                 allowed imports, no raylib in sim files, banned file names, one test file,
                         max 1 MB per file (assets excepted)
AGENTS.md                entry point for agents and new people, points to rules / notes / todo
format.sh                formats all tracked .odin files with odinfmt, --check only reports (hook + CI).
                         new files must be git added first

WINDOWS SMOKE TEST (2026-11-21, Windows 11, Odin dev-2026-11a, VS Build Tools 2022)
compile.bat debug: ~1.8 s. build\drift.exe starts from the repo root, loads the map, fetches weather.
compile.bat release: ~3.8 s, the exe starts.
Broken: compile.bat debug while drift.exe runs stops at "copy /y raylib.dll build\" ("The process cannot access
  the file because it is being used by another process", raylib.dll is loaded by the running exe), so game.dll
  is never rebuilt and no reload happens. Fix for the compile.bat owner: copy raylib.dll only when drift.exe
  is not running (move the tasklist check above the copy). "[host] reloaded game" was not reached, unverified.