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:
2026-10-10 11:59:20 +03:00
parent d3a53acbdb
commit 53950a465c
7 changed files with 149 additions and 55 deletions

View File

@@ -17,7 +17,8 @@
;;; where the game may already have put ore in some of it. And a
;;; child deposit (silver, gold, and peridot, whose reading comes from
;;; 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)
(import cs)
@@ -463,8 +464,9 @@
;;; Readings ---------------------------------------------------------
;;; IntDataMap2D.GetUnpaddedColorLerped, the low byte only.
(fn ore-factor ((map (* const int-map)) (x int) (z int)) double
;;; The ore map's value at column (x, z), 0 to 1: the low byte of
;;; 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 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)))
@@ -515,7 +517,7 @@
(if (&& (< rock 32) (!= (& (. m bearing) (<< (cast 1 u32) rock)) 0))
(++ q)))
(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))
(= (. r ppt) (* (/ (* (. r total) (. m abs-avg)) blocks) 1000))
(return r))
@@ -530,3 +532,21 @@
(var k double (* total (cast 7.5 float)))
(if (> k 5) (= k 5))
(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))))