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:
@@ -80,6 +80,8 @@
|
||||
;;; NoiseGeoProvince plus MapLayerGeoProvince: a weighted random
|
||||
;;; province per 64x64 cell of province-map pixels, sampled through a
|
||||
;;; wobble so the cells don't show.
|
||||
;; TODO sex#50: write MAX-PROVINCES once constants in array types are
|
||||
;; kebab-converted.
|
||||
(pub record province-layer
|
||||
((rng lcg) (weights [int MAX_PROVINCES]) (count int) (weight-sum int)
|
||||
(codes [* char MAX_PROVINCES]) (colours [u32 MAX_PROVINCES])
|
||||
@@ -165,7 +167,10 @@
|
||||
(= [map (+ start (* i stride))] (cast [tmp i] i32))))
|
||||
|
||||
(fn box-blur ((map (* i32)) (w int) (h int) (range int)) void
|
||||
(var tmp (* u32) (malloc (* (if (> w h) w h) (sizeof u32))))
|
||||
;; TODO sex#59: inline the longer side once a conditional operand
|
||||
;; keeps its parentheses.
|
||||
(var longest int (if (> w h) w h))
|
||||
(var tmp (* u32) (malloc (* longest (sizeof u32))))
|
||||
(for (var y int 0) (< y h) (++ y)
|
||||
(blur-line map (* y w) 1 w range tmp))
|
||||
(for (var x int 0) (< x w) (++ x)
|
||||
@@ -385,6 +390,8 @@
|
||||
(= (. l octave-threshold-count) 11)))
|
||||
(= (. l first-mutation) -1))
|
||||
|
||||
;; TODO sex#50: write MAX-LANDFORMS once constants in array types are
|
||||
;; kebab-converted.
|
||||
(pub record landform-table ((all [landform MAX_LANDFORMS]) (count int) (variant-count int)))
|
||||
|
||||
(pub fn terrain-octave-count ((size-y int)) int
|
||||
@@ -445,6 +452,8 @@
|
||||
(return (|| (!= (- rain clamped-rain) 0) (!= (- t clamped-temp) 0))))
|
||||
|
||||
;;; MapLayerLandforms over NoiseLandforms.
|
||||
;; TODO sex#50: write MAX-LANDFORMS once constants in array types are
|
||||
;; kebab-converted.
|
||||
(pub record landform-layer
|
||||
((rng lcg) (table (* const landform-table)) (climate climate-noise) (scale float)
|
||||
(weights [double MAX_LANDFORMS])
|
||||
@@ -715,6 +724,8 @@
|
||||
|
||||
;;; MapLayerCustomPerlin per stratum of rockstrata.json: how thick
|
||||
;;; that stratum may be, in blocks, per 16 blocks of region.
|
||||
;; TODO sex#50: write MAX-STRATA once constants in array types are
|
||||
;; kebab-converted.
|
||||
(pub record strata-layer
|
||||
((count int) (noises [* simplex-sum MAX_STRATA]) (thresholds [* double MAX_STRATA])
|
||||
(codes [* char MAX_STRATA])))
|
||||
@@ -733,6 +744,8 @@
|
||||
(memset (& l) 0 (sizeof l))
|
||||
(var variants (* cJSON) (cJSON-GetObjectItem rockstrata "variants"))
|
||||
(for (var v (* cJSON) (. variants child)) (&& v (< (. l count) MAX-STRATA)) (= v (. v next))
|
||||
;; TODO sex#50: write MAX-OCTAVES once constants in array types
|
||||
;; are kebab-converted.
|
||||
(var amplitudes [double MAX_OCTAVES])
|
||||
(var frequencies [double MAX_OCTAVES])
|
||||
(var th (* double) (calloc MAX-OCTAVES (sizeof double)))
|
||||
@@ -814,6 +827,8 @@
|
||||
(= base-z (. parent z))
|
||||
(= dir-x (. parent dir-x)))
|
||||
(continue))
|
||||
;; TODO sex#59: put the (if ...) in the product below once a
|
||||
;; conditional operand keeps its parentheses.
|
||||
(var dir-z int (if (> (.next-float (& rng)) 0.5) -1 1))
|
||||
(var dist-x int (+ min-x (.next-int (& rng) (- (+ max-x 1) min-x))))
|
||||
(var dist-z int (+ min-z (.next-int (& rng) (- (+ max-z 1) min-z))))
|
||||
|
||||
Reference in New Issue
Block a user