diff --git a/src/dump.sex b/src/dump.sex index 6ba068c..d9762cd 100644 --- a/src/dump.sex +++ b/src/dump.sex @@ -51,9 +51,7 @@ (var province image (image/make w h)) (var ocean image (image/make w h)) (var upheaval image (image/make w h)) - ;; TODO sex#50: write MAX-STRATA once constants in array types are - ;; kebab-converted. - (var strata [image MAX_STRATA]) + (var strata [image MAX-STRATA]) (var strata-count int 0) (var m region-maps) diff --git a/src/maps.sex b/src/maps.sex index b952105..854bb46 100644 --- a/src/maps.sex +++ b/src/maps.sex @@ -10,11 +10,9 @@ ;;; (size - pad-tl - pad-br) square. (pub record int-map ((data (* i32)) (size i32) (pad-tl i32) (pad-br i32))) -;; TODO sex#50: write MAX-STRATA once constants in array types are -;; kebab-converted. (pub record region-maps ((landform int-map) (climate int-map) (geoprov int-map) (upheaval int-map) - (ocean int-map) (strata [int-map MAX_STRATA]) (strata-count int))) + (ocean int-map) (strata [int-map MAX-STRATA]) (strata-count int))) (pub fn region-maps/free ((m (* region-maps))) void (free (. m landform data)) diff --git a/src/noise.sex b/src/noise.sex index 430380d..dfda6ef 100644 --- a/src/noise.sex +++ b/src/noise.sex @@ -250,12 +250,10 @@ ;;; NormalizedSimplexNoise. Octave i samples at frequencies[i] and is ;;; weighted so the sum stays in a known range before tanh. -;; TODO sex#50: write MAX-OCTAVES once constants in array types are -;; kebab-converted. (pub record simplex-noise - ((count int) (frequencies [double MAX_OCTAVES]) (amplitudes [double MAX_OCTAVES]) - (scaled-2d [double MAX_OCTAVES]) (scaled-3d [double MAX_OCTAVES]) - (octaves [simplex-octave MAX_OCTAVES]))) + ((count int) (frequencies [double MAX-OCTAVES]) (amplitudes [double MAX-OCTAVES]) + (scaled-2d [double MAX-OCTAVES]) (scaled-3d [double MAX-OCTAVES]) + (octaves [simplex-octave MAX-OCTAVES]))) (ops simplex-noise (pub fn make ((amplitudes (* const double)) (frequencies (* const double)) (count int) @@ -280,10 +278,8 @@ ;; PERSISTENCE^i. (pub fn octaves ((count int) (base-frequency double) (persistence double) (seed i64)) (* simplex-noise) - ;; TODO sex#50: write MAX-OCTAVES once constants in array types are - ;; kebab-converted. - (var frequencies [double MAX_OCTAVES]) - (var amplitudes [double MAX_OCTAVES]) + (var frequencies [double MAX-OCTAVES]) + (var amplitudes [double MAX-OCTAVES]) (for (var i int 0) (< i count) (++ i) (= [frequencies i] (* (pow 2 i) base-frequency)) (= [amplitudes i] (pow persistence i))) @@ -307,11 +303,9 @@ ;;; SimplexNoise: plain octave sums, no normalising and no tanh. The ;;; rock strata thickness maps and the strata distortion use it. -;; TODO sex#50: write MAX-OCTAVES once constants in array types are -;; kebab-converted. (pub record simplex-sum - ((count int) (frequencies [double MAX_OCTAVES]) (amplitudes [double MAX_OCTAVES]) - (octaves [simplex-octave MAX_OCTAVES]))) + ((count int) (frequencies [double MAX-OCTAVES]) (amplitudes [double MAX-OCTAVES]) + (octaves [simplex-octave MAX-OCTAVES]))) (ops simplex-sum (pub fn make ((amplitudes (* const double)) (frequencies (* const double)) (count int) diff --git a/src/ores.sex b/src/ores.sex index 2369268..c99253d 100644 --- a/src/ores.sex +++ b/src/ores.sex @@ -78,10 +78,8 @@ ;; the reading (readable bool) (place int) (y natfloat) (abs-avg double) (bearing u32))) -;; TODO sex#50: write MAX-MINERALS once constants in array types are -;; kebab-converted. (pub record ores - ((minerals [mineral MAX_MINERALS]) (count int) (granite int) (sea-level int))) + ((minerals [mineral MAX-MINERALS]) (count int) (granite int) (sea-level int))) ;;; The reading at one column: TotalFactor and PartsPerThousand. (pub record mineral-reading ((total double) (ppt double))) @@ -321,7 +319,7 @@ (= (. o sea-level) (cast (* 0.4313725490196078 (. settings size-y)) int)) (var root [char 1024]) (snprintf root (sizeof root) "%s/survival/worldgen/deposits" assets-dir) - (var paths [* char MAX_DEPOSIT_FILES]) + (var paths [* char MAX-DEPOSIT-FILES]) (var n int 0) (list-files root "" paths (& n)) (qsort paths n (sizeof [paths 0]) by-name) diff --git a/src/save.sex b/src/save.sex index c4c98c8..6f2a36d 100644 --- a/src/save.sex +++ b/src/save.sex @@ -17,11 +17,9 @@ (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]) + ((terrain-height [u16 CHUNK-AREA]) (rain-height [u16 CHUNK-AREA]) + (top-rock [i32 CHUNK-AREA]) (river-distance [u16 CHUNK-AREA]) (has-river-distance bool))) (pub record story-location ((code [char 64]) (x i32) (y i32) (z i32))) @@ -34,9 +32,7 @@ ((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) + (stories [story-location MAX-STORIES]) (story-count int) ;; every player's stored pick readings (pick-readings (* pick-reading)) (pick-reading-count int))) diff --git a/src/tiles.sex b/src/tiles.sex index 6a04878..5641e77 100644 --- a/src/tiles.sex +++ b/src/tiles.sex @@ -72,11 +72,9 @@ (pub record tiles ((lock pthread-mutex-t) (wake pthread-cond-t) - ;; TODO sex#50: write MAX-TILES once constants in array types are - ;; kebab-converted. - (slots [tile MAX_TILES]) (index cell-map) - (queue [int MAX_TILES]) (queue-len int) (queue-pos int) - (free-slots [int MAX_TILES]) (free-count int) + (slots [tile MAX-TILES]) (index cell-map) + (queue [int MAX-TILES]) (queue-len int) (queue-pos int) + (free-slots [int MAX-TILES]) (free-count int) (settings world-settings) (rivers river-config) (assets-dir [char 1024]) (generation int) ;; TODO sex#60: size with MAX-WORKERS once arrays of a header type ;; take a symbolic size. diff --git a/src/verify.sex b/src/verify.sex index 54a29bb..4afd23a 100644 --- a/src/verify.sex +++ b/src/verify.sex @@ -127,10 +127,8 @@ (var e extent (save/extent s "mapregion")) (var cell int 32) (var diff image (image/make (* (+ (- (. e x1) (. e x0)) 1) cell) (* (+ (- (. e z1) (. e z0)) 1) cell))) - ;; TODO sex#50: write MAX-MINERALS once constants in array types are - ;; kebab-converted. - (var codes [* char MAX_MINERALS]) - (var want [int-map MAX_MINERALS]) + (var codes [* char MAX-MINERALS]) + (var want [int-map MAX-MINERALS]) (var t tally) (memset (& t) 0 (sizeof t)) (var unknown int 0) diff --git a/src/viewer.sex b/src/viewer.sex index c004c21..1167e67 100644 --- a/src/viewer.sex +++ b/src/viewer.sex @@ -98,12 +98,10 @@ ;;; The strata of the column clicked last: top down, as (rock, top y, ;;; bottom y) runs; and the pick's readings there, highest first. -;; TODO sex#50: write MAX-MINERALS once constants in array types are -;; kebab-converted. (record probe ((valid bool) (x int) (z int) (height int) (count int) (rocks [int 64]) (tops [int 64]) (bottoms [int 64]) - (reading-count int) (reading-minerals [int MAX_MINERALS]) - (readings [mineral-reading MAX_MINERALS]))) + (reading-count int) (reading-minerals [int MAX-MINERALS]) + (readings [mineral-reading MAX-MINERALS]))) (record app ((window (* SDL-Window)) (renderer (* SDL-Renderer)) (ctx (* struct nk-context)) @@ -123,9 +121,7 @@ ;; minerals: the one shown, the readable ones for the panel's list, ;; its share of the view per category, and what Find nearest wants (minerals (* ores)) (mineral int) (mineral-code (* const char)) - ;; TODO sex#50: write MAX-MINERALS once constants in array types - ;; are kebab-converted. - (mineral-items [* const char MAX_MINERALS]) (mineral-ids [int MAX_MINERALS]) + (mineral-items [* const char MAX-MINERALS]) (mineral-ids [int MAX-MINERALS]) (mineral-item-count int) (mineral-coverage [i64 256]) (mineral-coverage-total i64) (min-reading int) (find-mineral-requested bool) (searching-mineral bool) diff --git a/src/worldgen.sex b/src/worldgen.sex index adb9ab2..01200d1 100644 --- a/src/worldgen.sex +++ b/src/worldgen.sex @@ -80,11 +80,9 @@ ;;; 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]) + ((rng lcg) (weights [int MAX-PROVINCES]) (count int) (weight-sum int) + (codes [* char MAX-PROVINCES]) (colours [u32 MAX-PROVINCES]) (wobble-x (* simplex-noise)) (wobble-z (* simplex-noise)))) (define GEOPROV-MAP-SCALE 64) @@ -390,9 +388,7 @@ (= (. 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 record landform-table ((all [landform MAX-LANDFORMS]) (count int) (variant-count int))) (pub fn terrain-octave-count ((size-y int)) int (return (+ 9 (/ (- size-y 256) 128)))) @@ -452,11 +448,9 @@ (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]) + (weights [double MAX-LANDFORMS]) (wobble-x (* simplex-noise)) (wobble-z (* simplex-noise)))) (define LANDFORM-MAP-SCALE 16) @@ -724,11 +718,9 @@ ;;; 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]))) + ((count int) (noises [* simplex-sum MAX-STRATA]) (thresholds [* double MAX-STRATA]) + (codes [* char MAX-STRATA]))) (fn json-doubles ((o (* cJSON)) (key (* const char)) (out (* double)) (max int)) int (var arr (* cJSON) (cJSON-GetObjectItem o key)) @@ -744,10 +736,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 amplitudes [double MAX-OCTAVES]) + (var frequencies [double MAX-OCTAVES]) (var th (* double) (calloc MAX-OCTAVES (sizeof double))) (var n int (json-doubles v "amplitudes" amplitudes MAX-OCTAVES)) (json-doubles v "frequencies" frequencies MAX-OCTAVES) @@ -981,7 +971,7 @@ ((settings world-settings) (provinces province-layer) (landform-table landform-table) (landforms landform-layer) (oceans ocean-layer) (upheaval upheaval-layer) (climate climate-layer) (strata strata-layer) - (stories [story MAX_STORY_LOCATIONS]) (story-count int) + (stories [story MAX-STORY-LOCATIONS]) (story-count int) (story-wobble-x (* simplex-noise)) (story-wobble-z (* simplex-noise)))) (pub fn worldgen/make ((settings world-settings) (assets-dir (* const char))) (* worldgen)