fix four conditional operands sexc emitted without parentheses, and mark every Sex workaround with a TODO

A conditional as an operand loses its parentheses (sex#59): box-blur
allocated a quarter of its buffer, deep water got the shallow colour,
and verify's delta histogram wrote out of bounds into the height
classes. Plan.org quoted the corrupted count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 21:01:59 +03:00
parent 39b0e74f2b
commit c14c154303
22 changed files with 156 additions and 5 deletions

View File

@@ -17,6 +17,8 @@
(pub define CHUNK-AREA 1024)
(pub define MAX-STORIES 32)
;; TODO sex#50: write CHUNK-AREA once constants in array types are
;; kebab-converted.
(pub record chunk-maps
((terrain-height [u16 CHUNK_AREA]) (rain-height [u16 CHUNK_AREA])
(top-rock [i32 CHUNK_AREA]) (river-distance [u16 CHUNK_AREA])
@@ -28,6 +30,8 @@
((db (* sqlite3)) (seed i32) (size-x i32) (size-y i32) (size-z i32)
(config-keys (* * char)) (config-values (* * char)) (config-count int)
(block-codes (* * char)) (block-count int)
;; TODO sex#50: write MAX-STORIES once constants in array types are
;; kebab-converted.
(stories [story-location MAX_STORIES]) (story-count int)))
;;; Map regions and map chunks share one key: x in the low 27 bits,
@@ -73,6 +77,8 @@
(switch type
(case 1 (snprintf value 64 "%d" (cast (read-le (& r) 4) i32)) (break))
(case 2 (snprintf value 64 "%lld" (cast (read-le (& r) 8) i64)) (break))
;; TODO sex#51: drop the (do ...) around case bodies once each
;; case gets its own scope.
(case 3
(do
(var bits u64 (read-le (& r) 8))
@@ -120,6 +126,8 @@
(if (> id max-id) (= max-id id)))
(.skip (& entry) wire))))
(= (. s block-count) (+ max-id 1))
;; TODO sex#52: write (sizeof (* char)) once sizeof takes a pointer
;; type.
(= (. s block-codes) (calloc (+ max-id 1) (sizeof [(. s block-codes) 0])))
(while (> (.field (& r) (& wire)) 0)
(var entry pb (.bytes (& r)))