diff --git a/src/rivers.sex b/src/rivers.sex index a87fdfb..2ae61f2 100644 --- a/src/rivers.sex +++ b/src/rivers.sex @@ -151,11 +151,7 @@ (var dy double (- (. end y) (. start y))) (var v double (+ (* (- (. p x) (. start x)) dx) (* (- (. p y) (. start y)) dy))) (/= v (+ (* dx dx) (* dy dy))) - ;; TODO sex#59: clamp inside the cast once a conditional operand - ;; keeps its parentheses. - (if (< v 0) (= v 0)) - (if (> v 1) (= v 1)) - (return (cast v float))) + (return (cast (if (< v 0) 0 (if (> v 1) 1 v)) float))) (fn distance-to-line ((p vec2) (s vec2) (e vec2)) double (if (<= (+ (* (- (. s x) (. e x)) (- (. p x) (. e x))) (* (- (. s y) (. e y)) (- (. p y) (. e y)))) 0) diff --git a/src/terra.sex b/src/terra.sex index f15b01b..9fe21b2 100644 --- a/src/terra.sex +++ b/src/terra.sex @@ -672,11 +672,9 @@ (var oct-a [double 64]) (var oct-t [double 64]) (for (var k int 0) (< k 4) (++ k) - ;; TODO sex#59: put the (if ...)s in the sums below once a - ;; conditional operand keeps its parentheses. - (var ox float (if (& k 1) pixel 0)) - (var oz float (if (& k 2) pixel 0)) - (landform-weights/at (& (. t weights)) (+ base-x ox) (+ base-z oz) w n) + (landform-weights/at (& (. t weights)) + (+ base-x (if (& k 1) pixel 0)) (+ base-z (if (& k 2) pixel 0)) + w n) (interpolated-octaves t w (+ oct-a (* k 16)) (+ oct-t (* k 16)))) (var delta float (/ (cast 1 float) (cast 32 float))) diff --git a/src/tiles.sex b/src/tiles.sex index bb1d912..16d464a 100644 --- a/src/tiles.sex +++ b/src/tiles.sex @@ -222,12 +222,9 @@ ;;; Terrain height, shaded: water by depth under sea level, land by ;;; height, lit from the north-west. (fn height-colour ((h int) (west int) (north int) (sea int) (size-y int)) u32 - ;; TODO sex#59: clamp the depth inline once a conditional operand - ;; keeps its parentheses. (var depth int (- sea h)) - (if (> depth 40) (= depth 40)) (if (< h sea) - (return (lerp-colour 0x61A9D8 0x121B63 (/ (* depth 255) 40)))) + (return (lerp-colour 0x61A9D8 0x121B63 (/ (* (if (> depth 40) 40 depth) 255) 40)))) (var t int (/ (* (- h sea) 255) (- size-y sea))) (var base u32 (if (< t 32) (lerp-colour 0x558A38 0x7EA23A (* t 8)) (if (< t 96) (lerp-colour 0x7EA23A 0x976953 (/ (* (- t 32) 255) 64)) diff --git a/src/verify.sex b/src/verify.sex index 4afd23a..c867586 100644 --- a/src/verify.sex +++ b/src/verify.sex @@ -342,19 +342,9 @@ (if (== d 0) (++ matched)) (if (!= d 0) (do - ;; TODO sex#59: sum two (if ...)s once a conditional - ;; operand keeps its parentheses. - (var cls int 0) - (if (< d 0) (+= cls 2)) - (if (>= got (. t sea-level)) (+= cls 1)) - (++ [by-class cls]))) + (++ [by-class (+ (if (< d 0) 2 0) (if (>= got (. t sea-level)) 1 0))]))) ;; -4..+4, the ends counting everything beyond - ;; TODO sex#59: clamp inline once a conditional operand keeps its - ;; parentheses. - (var clamped int d) - (if (< clamped -4) (= clamped -4)) - (if (> clamped 4) (= clamped 4)) - (var bucket int (+ clamped 4)) + (var bucket int (+ (if (< d -4) -4 (if (> d 4) 4 d)) 4)) (++ [by-delta bucket]) (var colour u32 (grey (/ (* got 255) (. g settings size-y)))) (if (> d 0) (= colour 16719904)) diff --git a/src/worldgen.sex b/src/worldgen.sex index 01200d1..1d7fb57 100644 --- a/src/worldgen.sex +++ b/src/worldgen.sex @@ -165,10 +165,7 @@ (= [map (+ start (* i stride))] (cast [tmp i] i32)))) (fn box-blur ((map (* i32)) (w int) (h int) (range int)) void - ;; 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)))) + (var tmp (* u32) (malloc (* (if (> w h) w h) (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) @@ -817,8 +814,7 @@ (= 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. + ;; drawn here, before the distances, as GenStoryStructures draws it (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))))