show silver, gold and peridot by their ore maps
The pick reads them from ore inside quartz and olivine deposits, which are not placed yet, so for them the Minerals list shows the ore map instead, marked as such: the overlay, Find nearest and the cursor work on its value in sevenths, and the probe lists them on a line of their own. Their maps already match the save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
16
Plan.org
16
Plan.org
@@ -626,10 +626,15 @@ Viewer:
|
|||||||
- *Minerals overlay.* Tiles keep =64 + category= per sample and share
|
- *Minerals overlay.* Tiles keep =64 + category= per sample and share
|
||||||
the rock palette, so they cost one more palette range, not a new
|
the rock palette, so they cost one more palette range, not a new
|
||||||
tile kind.
|
tile kind.
|
||||||
- *Minerals panel.* Picks the mineral from a list of the readable ones.
|
- *Minerals panel.* Picks the mineral from a list: the readable ones,
|
||||||
Its legend gives each category's share of the view. Find nearest
|
then silver, gold and peridot as "(ore map)". Its legend gives each
|
||||||
takes a least category (decent by default) and runs as search mode
|
category's share of the view. Find nearest takes a least category
|
||||||
4.
|
(decent by default) and runs as search mode 4.
|
||||||
|
- *Ore map only.* For the three the pick can't read, the overlay,
|
||||||
|
Find nearest and the cursor use the ore map's value in sevenths
|
||||||
|
(=ores/map-category=). Those tiles need neither heights nor strata.
|
||||||
|
The legend says it isn't a reading, and the Probe lists their ore
|
||||||
|
maps on a line of their own.
|
||||||
- *Cursor and Info.* A second label line gives the reading under the
|
- *Cursor and Info.* A second label line gives the reading under the
|
||||||
cursor while the Minerals overlay is on.
|
cursor while the Minerals overlay is on.
|
||||||
- *Probe.* Lists the pick's full reading for the column, highest first,
|
- *Probe.* Lists the pick's full reading for the column, highest first,
|
||||||
@@ -693,9 +698,6 @@ column holds the ore of its own chunk's deposits. It also reads silver
|
|||||||
and gold (children of quartz) and peridot (a child of olivine), whose
|
and gold (children of quartz) and peridot (a child of olivine), whose
|
||||||
host is their parent's ore. Checking needs the chunk blocks decoded.
|
host is their parent's ore. Checking needs the chunk blocks decoded.
|
||||||
|
|
||||||
*Meanwhile, cheap:* the gold and silver ore maps already match the
|
|
||||||
save. They could go in the Minerals list as "ore map only", marked as
|
|
||||||
not a pick reading.
|
|
||||||
|
|
||||||
* Risks
|
* Risks
|
||||||
- *Bit-exactness* of the noise and the Rivers trigonometry. The
|
- *Bit-exactness* of the noise and the Rivers trigonometry. The
|
||||||
|
|||||||
12
Readme.org
12
Readme.org
@@ -78,7 +78,7 @@ Options:
|
|||||||
| =--highlight ROCK= | highlight a rock, e.g. =chalk=; repeatable |
|
| =--highlight ROCK= | highlight a rock, e.g. =chalk=; repeatable |
|
||||||
| =--find= | find the nearest highlighted rock on start |
|
| =--find= | find the nearest highlighted rock on start |
|
||||||
| =--mineral CODE= | show a mineral's readings, e.g. =nativecopper= |
|
| =--mineral CODE= | show a mineral's readings, e.g. =nativecopper= |
|
||||||
| =--min-reading NAME= | Find nearest's least reading for minerals, e.g. =high= or =very-poor=; default =decent= |
|
| =--min-reading NAME= | Find nearest's least reading for minerals, e.g. =high= or =very-poor=, or an ore map band, e.g. =86-100%=; default =decent= |
|
||||||
| =--find-mineral= | find the nearest such reading on start |
|
| =--find-mineral= | find the nearest such reading on start |
|
||||||
| =--probe X Z= | probe the column at block X, Z on start |
|
| =--probe X Z= | probe the column at block X, Z on start |
|
||||||
| =--screenshot FILE.png= | wait until everything is drawn, save the window, quit |
|
| =--screenshot FILE.png= | wait until everything is drawn, save the window, quit |
|
||||||
@@ -170,6 +170,9 @@ when nothing is left to compute, the viewer sleeps.
|
|||||||
are.
|
are.
|
||||||
- /Find nearest/ looks for the nearest column that reads at least
|
- /Find nearest/ looks for the nearest column that reads at least
|
||||||
/Find at least/, as Rocks' /Find nearest/ does.
|
/Find at least/, as Rocks' /Find nearest/ does.
|
||||||
|
- Silver, gold and peridot are listed as /(ore map)/. For them the
|
||||||
|
overlay shows the mineral's ore map, how common it is there, in
|
||||||
|
bands of sevenths, and Find nearest looks for a band.
|
||||||
|
|
||||||
** vsmv
|
** vsmv
|
||||||
The command-line side, mostly for checking the generator against a
|
The command-line side, mostly for checking the generator against a
|
||||||
@@ -199,9 +202,10 @@ pick readings players took in the save, if there are any.
|
|||||||
move one across a category edge. The game's column already holds the ore of the
|
move one across a category edge. The game's column already holds the ore of the
|
||||||
deposits generated in its chunk, and those deposits are not
|
deposits generated in its chunk, and those deposits are not
|
||||||
generated here.
|
generated here.
|
||||||
- Silver, gold and peridot are left out of Minerals. The game reads
|
- The pick can't be reproduced for silver, gold and peridot. The game
|
||||||
them from ore inside other deposits (quartz and olivine),
|
reads them from ore inside other deposits (quartz and olivine),
|
||||||
which needs the deposits themselves.
|
which needs the deposits themselves. Minerals shows their ore maps
|
||||||
|
instead.
|
||||||
|
|
||||||
** Notes
|
** Notes
|
||||||
- =Plan.org= is the design and how each part was checked.
|
- =Plan.org= is the design and how each part was checked.
|
||||||
|
|||||||
@@ -29,8 +29,8 @@
|
|||||||
(rock int) (rock-y int) (surface-rock int)
|
(rock int) (rock-y int) (surface-rock int)
|
||||||
(landform int) (province int) (climate int) (ocean int) (upheaval int)
|
(landform int) (province int) (climate int) (ocean int) (upheaval int)
|
||||||
(river-distance double) (bank double)
|
(river-distance double) (bank double)
|
||||||
;; the pick's reading of the query's mineral
|
;; the pick's reading of the query's mineral, and its ore map's value
|
||||||
(mineral mineral-reading)))
|
(mineral mineral-reading) (mineral-map double)))
|
||||||
|
|
||||||
(pub record hover-worker
|
(pub record hover-worker
|
||||||
((lock pthread-mutex-t) (wake pthread-cond-t) (thread pthread-t) (quit bool)
|
((lock pthread-mutex-t) (wake pthread-cond-t) (thread pthread-t) (quit bool)
|
||||||
@@ -120,7 +120,8 @@
|
|||||||
(= (. k ore-mineral) (. q mineral))
|
(= (. k ore-mineral) (. q mineral))
|
||||||
(= (. k ore-rx) rx)
|
(= (. k ore-rx) rx)
|
||||||
(= (. k ore-rz) rz)))
|
(= (. k ore-rz) rz)))
|
||||||
(= (. r mineral) (ores/reading (. k minerals) (. q mineral) (& (. k ore-map)) x z (. k column) h))))
|
(= (. r mineral) (ores/reading (. k minerals) (. q mineral) (& (. k ore-map)) x z (. k column) h))
|
||||||
|
(= (. r mineral-map) (ores/map-factor (& (. k ore-map)) x z))))
|
||||||
(if (== (. q mode) 3)
|
(if (== (. q mode) 3)
|
||||||
(do
|
(do
|
||||||
(= (. r rock) -3)
|
(= (. r rock) -3)
|
||||||
|
|||||||
28
src/ores.sex
28
src/ores.sex
@@ -17,7 +17,8 @@
|
|||||||
;;; where the game may already have put ore in some of it. And a
|
;;; where the game may already have put ore in some of it. And a
|
||||||
;;; child deposit (silver, gold, and peridot, whose reading comes from
|
;;; child deposit (silver, gold, and peridot, whose reading comes from
|
||||||
;;; the peridot inside olivine) is hosted by its parent's ore, so it
|
;;; the peridot inside olivine) is hosted by its parent's ore, so it
|
||||||
;;; can't be read at all without the deposits.
|
;;; can't be read at all without the deposits. For those, only the
|
||||||
|
;;; ore map is shown.
|
||||||
|
|
||||||
(include stdio.h stdlib.h string.h math.h dirent.h)
|
(include stdio.h stdlib.h string.h math.h dirent.h)
|
||||||
(import cs)
|
(import cs)
|
||||||
@@ -463,8 +464,9 @@
|
|||||||
|
|
||||||
;;; Readings ---------------------------------------------------------
|
;;; Readings ---------------------------------------------------------
|
||||||
|
|
||||||
;;; IntDataMap2D.GetUnpaddedColorLerped, the low byte only.
|
;;; The ore map's value at column (x, z), 0 to 1: the low byte of
|
||||||
(fn ore-factor ((map (* const int-map)) (x int) (z int)) double
|
;;; IntDataMap2D.GetUnpaddedColorLerped over 255.
|
||||||
|
(pub fn ores/map-factor ((map (* const int-map)) (x int) (z int)) double
|
||||||
(var inner int (- (. map size) (. map pad-tl) (. map pad-br)))
|
(var inner int (- (. map size) (. map pad-tl) (. map pad-br)))
|
||||||
(var px float (* (/ (cast (% x 512) float) (cast 512 float)) (cast inner float)))
|
(var px float (* (/ (cast (% x 512) float) (cast 512 float)) (cast inner float)))
|
||||||
(var pz float (* (/ (cast (% z 512) float) (cast 512 float)) (cast inner float)))
|
(var pz float (* (/ (cast (% z 512) float) (cast 512 float)) (cast inner float)))
|
||||||
@@ -515,7 +517,7 @@
|
|||||||
(if (&& (< rock 32) (!= (& (. m bearing) (<< (cast 1 u32) rock)) 0))
|
(if (&& (< rock 32) (!= (& (. m bearing) (<< (cast 1 u32) rock)) 0))
|
||||||
(++ q)))
|
(++ q)))
|
||||||
(var rock-factor double (/ (cast q double) height))
|
(var rock-factor double (/ (cast q double) height))
|
||||||
(= (. r total) (* (ore-factor map x z) rock-factor))
|
(= (. r total) (* (ores/map-factor map x z) rock-factor))
|
||||||
(var blocks int (* height 1024))
|
(var blocks int (* height 1024))
|
||||||
(= (. r ppt) (* (/ (* (. r total) (. m abs-avg)) blocks) 1000))
|
(= (. r ppt) (* (/ (* (. r total) (. m abs-avg)) blocks) 1000))
|
||||||
(return r))
|
(return r))
|
||||||
@@ -530,3 +532,21 @@
|
|||||||
(var k double (* total (cast 7.5 float)))
|
(var k double (* total (cast 7.5 float)))
|
||||||
(if (> k 5) (= k 5))
|
(if (> k 5) (= k 5))
|
||||||
(return (+ 2 (cast k int))))
|
(return (+ 2 (cast k int))))
|
||||||
|
|
||||||
|
;;; A band of the ore map's value, for a mineral the pick can't read:
|
||||||
|
;;; 0 where it is 0, then 1 to 7 by sevenths.
|
||||||
|
(pub fn ores/map-category ((factor double)) int
|
||||||
|
(if (<= factor 0)
|
||||||
|
(return 0))
|
||||||
|
(var k int (cast (* factor 7) int))
|
||||||
|
(if (> k 6) (= k 6))
|
||||||
|
(return (+ 1 k)))
|
||||||
|
|
||||||
|
;;; What the Minerals overlay shows for mineral I at a column, 0 to
|
||||||
|
;;; READING-CATEGORIES - 1: the pick's reading where it can read the
|
||||||
|
;;; mineral, else the ore map's band.
|
||||||
|
(pub fn ores/category-at ((o (* const ores)) (i int) (map (* const int-map)) (x int) (z int)
|
||||||
|
(column (* const u8)) (height int)) int
|
||||||
|
(if (. [(. o minerals) i] readable)
|
||||||
|
(return (ores/category (. (ores/reading o i map x z column height) total))))
|
||||||
|
(return (ores/map-category (ores/map-factor map x z))))
|
||||||
|
|||||||
@@ -72,7 +72,8 @@
|
|||||||
;;; Whether column (x, z), with the strata in the scanner's column,
|
;;; Whether column (x, z), with the strata in the scanner's column,
|
||||||
;;; holds what is searched for: a rock where the mode looks, at any
|
;;; holds what is searched for: a rock where the mode looks, at any
|
||||||
;;; depth (mode 3) anywhere from y = 1 to the surface; or a reading of
|
;;; depth (mode 3) anywhere from y = 1 to the surface; or a reading of
|
||||||
;;; the mineral of at least the mask's category.
|
;;; the mineral, or its ore map's band where the pick can't read it, of
|
||||||
|
;;; at least the mask's category.
|
||||||
(fn column-matches ((s (* const search)) (sc (* scanner)) (x int) (z int) (height int)) bool
|
(fn column-matches ((s (* const search)) (sc (* scanner)) (x int) (z int) (height int)) bool
|
||||||
(var column (* const u8) (. sc column))
|
(var column (* const u8) (. sc column))
|
||||||
(if (== (. s mode) SEARCH-MINERAL)
|
(if (== (. s mode) SEARCH-MINERAL)
|
||||||
@@ -85,9 +86,9 @@
|
|||||||
(ores/map (. sc minerals) (. s value) rx rz (& (. sc ore-map)))
|
(ores/map (. sc minerals) (. s value) rx rz (& (. sc ore-map)))
|
||||||
(= (. sc ore-rx) rx)
|
(= (. sc ore-rx) rx)
|
||||||
(= (. sc ore-rz) rz)))
|
(= (. sc ore-rz) rz)))
|
||||||
(var r mineral-reading (ores/reading (. sc minerals) (. s value) (& (. sc ore-map)) x z
|
(return (>= (ores/category-at (. sc minerals) (. s value) (& (. sc ore-map)) x z column
|
||||||
column height))
|
height)
|
||||||
(return (>= (ores/category (. r total)) (cast (. s mask) int)))))
|
(cast (. s mask) int)))))
|
||||||
(if (!= (. s mode) 3)
|
(if (!= (. s mode) 3)
|
||||||
(return (matches s (rock-at column height (. s mode) (. s value)))))
|
(return (matches s (rock-at column height (. s mode) (. s value)))))
|
||||||
(for (var y int 1) (<= y height) (++ y)
|
(for (var y int 1) (<= y height) (++ y)
|
||||||
|
|||||||
@@ -303,7 +303,8 @@
|
|||||||
(return out))
|
(return out))
|
||||||
|
|
||||||
;;; The mineral tile: per sample, MINERAL-VALUE-BASE plus the category
|
;;; The mineral tile: per sample, MINERAL-VALUE-BASE plus the category
|
||||||
;;; of the pick's reading there.
|
;;; of the pick's reading there, or of the ore map where the pick can't
|
||||||
|
;;; read the mineral; that needs neither heights nor strata.
|
||||||
(fn render-minerals ((tr (* terra)) (rocks (* strata)) (o (* ores)) (k tile-key) (size (* int)))
|
(fn render-minerals ((tr (* terra)) (rocks (* strata)) (o (* ores)) (k tile-key) (size (* int)))
|
||||||
(* u8)
|
(* u8)
|
||||||
(var res int (. k stratum))
|
(var res int (. k stratum))
|
||||||
@@ -313,6 +314,7 @@
|
|||||||
(var out (* u8) (malloc (* res res)))
|
(var out (* u8) (malloc (* res res)))
|
||||||
(var heights [u16 1024])
|
(var heights [u16 1024])
|
||||||
(var column (* u8) (malloc (+ (. tr size-y) 1)))
|
(var column (* u8) (malloc (+ (. tr size-y) 1)))
|
||||||
|
(var readable bool (. [(. o minerals) (. k param)] readable))
|
||||||
(var per-chunk int (/ 32 step))
|
(var per-chunk int (/ 32 step))
|
||||||
(if (< per-chunk 1) (= per-chunk 1))
|
(if (< per-chunk 1) (= per-chunk 1))
|
||||||
(for (var cz int 0) (< cz 16) (++ cz)
|
(for (var cz int 0) (< cz 16) (++ cz)
|
||||||
@@ -321,17 +323,21 @@
|
|||||||
(continue))
|
(continue))
|
||||||
(var chunk-x int (+ (* (. k rx) 16) cx))
|
(var chunk-x int (+ (* (. k rx) 16) cx))
|
||||||
(var chunk-z int (+ (* (. k rz) 16) cz))
|
(var chunk-z int (+ (* (. k rz) 16) cz))
|
||||||
(terra/chunk-heights tr chunk-x chunk-z (if (> step 32) 32 step) heights)
|
(if readable
|
||||||
|
(terra/chunk-heights tr chunk-x chunk-z (if (> step 32) 32 step) heights))
|
||||||
(for (var dz int 0) (< dz per-chunk) (++ dz)
|
(for (var dz int 0) (< dz per-chunk) (++ dz)
|
||||||
(for (var dx int 0) (< dx per-chunk) (++ dx)
|
(for (var dx int 0) (< dx per-chunk) (++ dx)
|
||||||
(var lx int (* dx step))
|
(var lx int (* dx step))
|
||||||
(var lz int (* dz step))
|
(var lz int (* dz step))
|
||||||
(var h int [heights (+ (* lz 32) lx)])
|
(var h int 0)
|
||||||
(strata/column rocks chunk-x chunk-z lx lz h column)
|
(if readable
|
||||||
(var r mineral-reading (ores/reading o (. k param) (& map) (+ (* chunk-x 32) lx)
|
(do
|
||||||
(+ (* chunk-z 32) lz) column h))
|
(= h [heights (+ (* lz 32) lx)])
|
||||||
|
(strata/column rocks chunk-x chunk-z lx lz h column)))
|
||||||
|
(var c int (ores/category-at o (. k param) (& map) (+ (* chunk-x 32) lx)
|
||||||
|
(+ (* chunk-z 32) lz) column h))
|
||||||
(= [out (+ (* (+ (/ (* cz 32) step) dz) res) (/ (* cx 32) step) dx)]
|
(= [out (+ (* (+ (/ (* cz 32) step) dz) res) (/ (* cx 32) step) dx)]
|
||||||
(cast (+ MINERAL-VALUE-BASE (ores/category (. r total))) u8))))))
|
(cast (+ MINERAL-VALUE-BASE c) u8))))))
|
||||||
(free column)
|
(free column)
|
||||||
(free (. map data))
|
(free (. map data))
|
||||||
(= (* size) res)
|
(= (* size) res)
|
||||||
|
|||||||
112
src/viewer.sex
112
src/viewer.sex
@@ -70,27 +70,37 @@
|
|||||||
#("none" "miniscule" "very poor" "poor" "decent" "high" "very high" "ultra high"))
|
#("none" "miniscule" "very poor" "poor" "decent" "high" "very high" "ultra high"))
|
||||||
(var reading-colours [u32 8]
|
(var reading-colours [u32 8]
|
||||||
#(0x000000 0x5A6E7A 0x3B6FB6 0x2BA3A3 0x7BC043 0xF3C623 0xF37735 0xD11141))
|
#(0x000000 0x5A6E7A 0x3B6FB6 0x2BA3A3 0x7BC043 0xF3C623 0xF37735 0xD11141))
|
||||||
|
;;; The same numbering for a mineral the pick can't read, whose ore map
|
||||||
|
;;; is shown instead: its value in sevenths (ores/map-category).
|
||||||
|
(var map-band-names [(* const char) 8]
|
||||||
|
#("none" "0-14%" "14-29%" "29-43%" "43-57%" "57-71%" "71-86%" "86-100%"))
|
||||||
;;; Find nearest's least reading, unless set: decent.
|
;;; Find nearest's least reading, unless set: decent.
|
||||||
(define DEFAULT-MIN-READING 4)
|
(define DEFAULT-MIN-READING 4)
|
||||||
|
|
||||||
;;; The category NAME names, with a hyphen for a space ("very-high"),
|
;;; The category NAME names, a reading with a hyphen for a space
|
||||||
;;; from miniscule up; the default for a name it doesn't know.
|
;;; ("very-high") or an ore map band ("43-57%"), from the lowest up; the
|
||||||
|
;;; default for a name it doesn't know.
|
||||||
(fn reading-named ((name (* const char))) int
|
(fn reading-named ((name (* const char))) int
|
||||||
(for (var c int 1) (< c 8) (++ c)
|
(for (var c int 1) (< c 8) (++ c)
|
||||||
(var hyphenated [char 16])
|
(var hyphenated [char 16])
|
||||||
(snprintf hyphenated (sizeof hyphenated) "%s" [reading-names c])
|
(snprintf hyphenated (sizeof hyphenated) "%s" [reading-names c])
|
||||||
(for (var p (* char) hyphenated) (* p) (++ p)
|
(for (var p (* char) hyphenated) (* p) (++ p)
|
||||||
(if (== (* p) #\space) (= (* p) #\-)))
|
(if (== (* p) #\space) (= (* p) #\-)))
|
||||||
(if (== (strcmp hyphenated name) 0)
|
(if (|| (== (strcmp hyphenated name) 0) (== (strcmp [map-band-names c] name) 0))
|
||||||
(return c)))
|
(return c)))
|
||||||
(return DEFAULT-MIN-READING))
|
(return DEFAULT-MIN-READING))
|
||||||
|
|
||||||
|
;;; A mineral's name in the panel's list.
|
||||||
|
(record item-label ((text [char 40])))
|
||||||
|
|
||||||
;;; The strata of the column clicked last: top down, as (rock, top y,
|
;;; The strata of the column clicked last: top down, as (rock, top y,
|
||||||
;;; bottom y) runs; and the pick's readings there, highest first.
|
;;; bottom y) runs; the pick's readings there, highest first; and the
|
||||||
|
;;; ore maps of the minerals the pick can't read.
|
||||||
(record probe ((valid bool) (x int) (z int) (height int) (count int)
|
(record probe ((valid bool) (x int) (z int) (height int) (count int)
|
||||||
(rocks [int 64]) (tops [int 64]) (bottoms [int 64])
|
(rocks [int 64]) (tops [int 64]) (bottoms [int 64])
|
||||||
(reading-count int) (reading-minerals [int MAX-MINERALS])
|
(reading-count int) (reading-minerals [int MAX-MINERALS])
|
||||||
(readings [mineral-reading MAX-MINERALS])))
|
(readings [mineral-reading MAX-MINERALS])
|
||||||
|
(map-count int) (map-minerals [int MAX-MINERALS]) (map-factors [double MAX-MINERALS])))
|
||||||
|
|
||||||
(record app
|
(record app
|
||||||
((window (* SDL-Window)) (renderer (* SDL-Renderer)) (ctx (* struct nk-context))
|
((window (* SDL-Window)) (renderer (* SDL-Renderer)) (ctx (* struct nk-context))
|
||||||
@@ -107,9 +117,10 @@
|
|||||||
(coverage [i64 256]) (coverage-total i64)
|
(coverage [i64 256]) (coverage-total i64)
|
||||||
(pins [int 64]) (pin-count int)
|
(pins [int 64]) (pin-count int)
|
||||||
(search (* search)) (searching bool) (search-status [char 160]) (find-requested bool)
|
(search (* search)) (searching bool) (search-status [char 160]) (find-requested bool)
|
||||||
;; minerals: the one shown, the readable ones for the panel's list,
|
;; minerals: the one shown, the panel's list of them, its share of
|
||||||
;; its share of the view per category, and what Find nearest wants
|
;; the view per category, and what Find nearest wants
|
||||||
(minerals (* ores)) (mineral int) (mineral-code (* const char))
|
(minerals (* ores)) (mineral int) (mineral-code (* const char))
|
||||||
|
(mineral-labels [item-label MAX-MINERALS])
|
||||||
(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-item-count int)
|
||||||
(mineral-coverage [i64 256]) (mineral-coverage-total i64)
|
(mineral-coverage [i64 256]) (mineral-coverage-total i64)
|
||||||
@@ -271,16 +282,24 @@
|
|||||||
(if (. a minerals)
|
(if (. a minerals)
|
||||||
(ores/free (. a minerals)))
|
(ores/free (. a minerals)))
|
||||||
(= (. a minerals) o)
|
(= (. a minerals) o)
|
||||||
;; the panel's list: nothing, then every mineral the pick can read
|
;; the panel's list: nothing, then every mineral the pick can read,
|
||||||
|
;; then the ones shown by their ore map
|
||||||
(= [(. a mineral-items) 0] "(none)")
|
(= [(. a mineral-items) 0] "(none)")
|
||||||
(= [(. a mineral-ids) 0] -1)
|
(= [(. a mineral-ids) 0] -1)
|
||||||
(= (. a mineral-item-count) 1)
|
(= (. a mineral-item-count) 1)
|
||||||
(for (var i int 0) (< i (. o count)) (++ i)
|
(for (var pass int 0) (< pass 2) (++ pass)
|
||||||
(if (. [(. o minerals) i] readable)
|
(for (var i int 0) (< i (. o count)) (++ i)
|
||||||
(do
|
(var m (* mineral) (& [(. o minerals) i]))
|
||||||
(= [(. a mineral-items) (. a mineral-item-count)] (. [(. o minerals) i] code))
|
(if (!= (. m readable) (== pass 0))
|
||||||
(= [(. a mineral-ids) (. a mineral-item-count)] i)
|
(continue))
|
||||||
(++ (. a mineral-item-count)))))
|
(var n int (. a mineral-item-count))
|
||||||
|
(var label (* char) (. [(. a mineral-labels) n] text))
|
||||||
|
(if (. m readable)
|
||||||
|
(snprintf label 40 "%s" (. m code))
|
||||||
|
(snprintf label 40 "%s (ore map)" (. m code)))
|
||||||
|
(= [(. a mineral-items) n] label)
|
||||||
|
(= [(. a mineral-ids) n] i)
|
||||||
|
(++ (. a mineral-item-count))))
|
||||||
(= (. a mineral-code) (if (>= (. a mineral) 0) (. [(. o minerals) (. a mineral)] code) NULL)))
|
(= (. a mineral-code) (if (>= (. a mineral) 0) (. [(. o minerals) (. a mineral)] code) NULL)))
|
||||||
|
|
||||||
;;; Makes SOURCE the world shown: a fresh generator for the panels,
|
;;; Makes SOURCE the world shown: a fresh generator for the panels,
|
||||||
@@ -694,8 +713,25 @@
|
|||||||
(draw-rock-controls a)
|
(draw-rock-controls a)
|
||||||
(nk-tree-pop ctx))))
|
(nk-tree-pop ctx))))
|
||||||
|
|
||||||
|
;;; The names of the mineral shown's categories: the pick's readings, or
|
||||||
|
;;; its ore map's bands where the pick can't read it.
|
||||||
|
(fn category-names ((a (* app))) (* * const char)
|
||||||
|
(if (&& (>= (. a mineral) 0) (! (. [(. (. a minerals) minerals) (. a mineral)] readable)))
|
||||||
|
(return map-band-names))
|
||||||
|
(return reading-names))
|
||||||
|
|
||||||
|
;;; What the cursor label and Info say of the mineral shown at the
|
||||||
|
;;; cursor, into TEXT.
|
||||||
|
(fn mineral-at-cursor ((a (* app)) (r (* const hover-result)) (text (* char)) (size size-t)) void
|
||||||
|
(var m (* mineral) (& [(. (. a minerals) minerals) (. r query mineral)]))
|
||||||
|
(if (. m readable)
|
||||||
|
(snprintf text size "%s %s, %.2f ppt" (. m code)
|
||||||
|
[reading-names (ores/category (. r mineral total))] (. r mineral ppt))
|
||||||
|
(snprintf text size "%s ore map %.0f%%" (. m code) (* 100 (. r mineral-map)))))
|
||||||
|
|
||||||
;;; The mineral shown, the legend of the pick's readings with each one's
|
;;; The mineral shown, the legend of the pick's readings with each one's
|
||||||
;;; share of the view, and Find nearest for a reading at least so high.
|
;;; share of the view, and Find nearest for a reading at least so high.
|
||||||
|
;;; A mineral the pick can't read is shown by its ore map, in bands.
|
||||||
(fn draw-mineral-controls ((a (* app))) void
|
(fn draw-mineral-controls ((a (* app))) void
|
||||||
(var ctx (* struct nk-context) (. a ctx))
|
(var ctx (* struct nk-context) (. a ctx))
|
||||||
(var current int 0)
|
(var current int 0)
|
||||||
@@ -708,12 +744,18 @@
|
|||||||
(if (!= chosen current)
|
(if (!= chosen current)
|
||||||
(do
|
(do
|
||||||
(= (. a mineral) [(. a mineral-ids) chosen])
|
(= (. a mineral) [(. a mineral-ids) chosen])
|
||||||
(= (. a mineral-code) (if (>= (. a mineral) 0) [(. a mineral-items) chosen] NULL))))
|
(= (. a mineral-code)
|
||||||
|
(if (>= (. a mineral) 0) (. [(. (. a minerals) minerals) (. a mineral)] code) NULL))))
|
||||||
(if (< (. a mineral) 0)
|
(if (< (. a mineral) 0)
|
||||||
(do
|
(do
|
||||||
(nk-layout-row-dynamic ctx 34 1)
|
(nk-layout-row-dynamic ctx 34 1)
|
||||||
(nk-label-wrap ctx "Choose a mineral to see what the prospecting pick reads")
|
(nk-label-wrap ctx "Choose a mineral to see what the prospecting pick reads")
|
||||||
(return)))
|
(return)))
|
||||||
|
(var names (* * const char) (category-names a))
|
||||||
|
(if (! (. [(. (. a minerals) minerals) (. a mineral)] readable))
|
||||||
|
(do
|
||||||
|
(nk-layout-row-dynamic ctx 50 1)
|
||||||
|
(nk-label-wrap ctx "The pick reads this from ore inside other deposits; this is its ore map, how common it is here")))
|
||||||
(nk-layout-row-dynamic ctx 8 1)
|
(nk-layout-row-dynamic ctx 8 1)
|
||||||
(nk-spacing ctx 1)
|
(nk-spacing ctx 1)
|
||||||
(var shown bool (&& (> (. a mineral-coverage-total) 0)
|
(var shown bool (&& (> (. a mineral-coverage-total) 0)
|
||||||
@@ -727,15 +769,15 @@
|
|||||||
(nk-button-color ctx (nk-rgb (cast (& (>> colour 16) 255) int) (cast (& (>> colour 8) 255) int)
|
(nk-button-color ctx (nk-rgb (cast (& (>> colour 16) 255) int) (cast (& (>> colour 8) 255) int)
|
||||||
(cast (& colour 255) int)))
|
(cast (& colour 255) int)))
|
||||||
(if shown
|
(if shown
|
||||||
(nk-labelf ctx NK-TEXT-LEFT "%-13s %5.1f%%" [reading-names c]
|
(nk-labelf ctx NK-TEXT-LEFT "%-13s %5.1f%%" [names c]
|
||||||
(/ (* 100.0 [(. a mineral-coverage) (+ MINERAL-VALUE-BASE c)])
|
(/ (* 100.0 [(. a mineral-coverage) (+ MINERAL-VALUE-BASE c)])
|
||||||
(. a mineral-coverage-total)))
|
(. a mineral-coverage-total)))
|
||||||
(nk-label ctx [reading-names c] NK-TEXT-LEFT)))
|
(nk-label ctx [names c] NK-TEXT-LEFT)))
|
||||||
(nk-layout-row-dynamic ctx 22 2)
|
(nk-layout-row-dynamic ctx 22 2)
|
||||||
(nk-label ctx "Find at least" NK-TEXT-LEFT)
|
(nk-label ctx "Find at least" NK-TEXT-LEFT)
|
||||||
;; from miniscule up
|
;; from miniscule up
|
||||||
(= (. a min-reading)
|
(= (. a min-reading)
|
||||||
(+ 1 (nk-combo ctx (+ reading-names 1) (- READING-CATEGORIES 1) (- (. a min-reading) 1) 20
|
(+ 1 (nk-combo ctx (+ names 1) (- READING-CATEGORIES 1) (- (. a min-reading) 1) 20
|
||||||
(nk-vec2 140 200))))
|
(nk-vec2 140 200))))
|
||||||
(nk-layout-row-dynamic ctx 24 1)
|
(nk-layout-row-dynamic ctx 24 1)
|
||||||
(if (&& (. a searching) (. a searching-mineral))
|
(if (&& (. a searching) (. a searching-mineral))
|
||||||
@@ -810,13 +852,21 @@
|
|||||||
;; what the pick reads here: every mineral it can, highest first
|
;; what the pick reads here: every mineral it can, highest first
|
||||||
(var o (* ores) (. a minerals))
|
(var o (* ores) (. a minerals))
|
||||||
(= (. p reading-count) 0)
|
(= (. p reading-count) 0)
|
||||||
|
(= (. p map-count) 0)
|
||||||
(for (var i int 0) (< i (. o count)) (++ i)
|
(for (var i int 0) (< i (. o count)) (++ i)
|
||||||
(if (! (. [(. o minerals) i] readable))
|
|
||||||
(continue))
|
|
||||||
(var m int-map)
|
(var m int-map)
|
||||||
(ores/map o i (/ x 512) (/ z 512) (& m))
|
(ores/map o i (/ x 512) (/ z 512) (& m))
|
||||||
(var r mineral-reading (ores/reading o i (& m) x z (. a column) h))
|
(var r mineral-reading (ores/reading o i (& m) x z (. a column) h))
|
||||||
|
(var factor double (ores/map-factor (& m) x z))
|
||||||
(free (. m data))
|
(free (. m data))
|
||||||
|
(if (! (. [(. o minerals) i] readable))
|
||||||
|
(do
|
||||||
|
(if (> factor 0)
|
||||||
|
(do
|
||||||
|
(= [(. p map-minerals) (. p map-count)] i)
|
||||||
|
(= [(. p map-factors) (. p map-count)] factor)
|
||||||
|
(++ (. p map-count))))
|
||||||
|
(continue)))
|
||||||
(if (== (ores/category (. r total)) 0)
|
(if (== (ores/category (. r total)) 0)
|
||||||
(continue))
|
(continue))
|
||||||
(var n int (. p reading-count))
|
(var n int (. p reading-count))
|
||||||
@@ -882,6 +932,17 @@
|
|||||||
(nk-label-wrap ctx text))
|
(nk-label-wrap ctx text))
|
||||||
(== shown 0)
|
(== shown 0)
|
||||||
(nk-label ctx "nothing" NK-TEXT-LEFT))
|
(nk-label ctx "nothing" NK-TEXT-LEFT))
|
||||||
|
(if (> (. p map-count) 0)
|
||||||
|
(do
|
||||||
|
(var maps [char 300])
|
||||||
|
(var used int (snprintf maps (sizeof maps) "ore maps, not read by the pick:"))
|
||||||
|
(for (var i int 0) (&& (< i (. p map-count)) (< used (cast (sizeof maps) int))) (++ i)
|
||||||
|
(+= used (snprintf (+ maps used) (- (sizeof maps) used) "%s %s %.0f%%"
|
||||||
|
(if (> i 0) "," "")
|
||||||
|
(. [(. (. a minerals) minerals) [(. p map-minerals) i]] code)
|
||||||
|
(* 100 [(. p map-factors) i]))))
|
||||||
|
(nk-layout-row-dynamic ctx 34 1)
|
||||||
|
(nk-label-wrap ctx maps)))
|
||||||
(nk-tree-pop ctx))))
|
(nk-tree-pop ctx))))
|
||||||
|
|
||||||
;;; The block under the cursor; false when the cursor is not on the
|
;;; The block under the cursor; false when the cursor is not on the
|
||||||
@@ -939,9 +1000,10 @@
|
|||||||
(nk-labelf ctx NK-TEXT-LEFT "terrain height %d (sea level %d)" (. r height) (. r sea-level))
|
(nk-labelf ctx NK-TEXT-LEFT "terrain height %d (sea level %d)" (. r height) (. r sea-level))
|
||||||
(nk-labelf ctx NK-TEXT-LEFT "surface rock %s" (rock-name a (. r surface-rock)))
|
(nk-labelf ctx NK-TEXT-LEFT "surface rock %s" (rock-name a (. r surface-rock)))
|
||||||
(if (>= (. r query mineral) 0)
|
(if (>= (. r query mineral) 0)
|
||||||
(nk-labelf ctx NK-TEXT-LEFT "%s %s, %.2f ppt"
|
(do
|
||||||
(. [(. (. a minerals) minerals) (. r query mineral)] code)
|
(var text [char 96])
|
||||||
[reading-names (ores/category (. r mineral total))] (. r mineral ppt)))))
|
(mineral-at-cursor a r text (sizeof text))
|
||||||
|
(nk-label ctx text NK-TEXT-LEFT)))))
|
||||||
(nk-labelf ctx NK-TEXT-LEFT "%d tiles pending" (. a pending))
|
(nk-labelf ctx NK-TEXT-LEFT "%d tiles pending" (. a pending))
|
||||||
(nk-label ctx (. a status) NK-TEXT-LEFT)
|
(nk-label ctx (. a status) NK-TEXT-LEFT)
|
||||||
(nk-tree-pop ctx))))
|
(nk-tree-pop ctx))))
|
||||||
@@ -1039,9 +1101,7 @@
|
|||||||
(var reading [char 96])
|
(var reading [char 96])
|
||||||
(= [reading 0] 0)
|
(= [reading 0] 0)
|
||||||
(if (&& (. r valid) (>= (. r query mineral) 0))
|
(if (&& (. r valid) (>= (. r query mineral) 0))
|
||||||
(snprintf reading (sizeof reading) "%s %s, %.2f ppt"
|
(mineral-at-cursor a r reading (sizeof reading)))
|
||||||
(. [(. (. a minerals) minerals) (. r query mineral)] code)
|
|
||||||
[reading-names (ores/category (. r mineral total))] (. r mineral ppt)))
|
|
||||||
(var height float (if [reading 0] 50 30))
|
(var height float (if [reading 0] 50 30))
|
||||||
;; beside the cursor, not under it, so it never takes the map's input
|
;; beside the cursor, not under it, so it never takes the map's input
|
||||||
(var ctx (* struct nk-context) (. a ctx))
|
(var ctx (* struct nk-context) (. a ctx))
|
||||||
|
|||||||
Reference in New Issue
Block a user