show what the prospecting pick reads, and find it
The ore maps GenDeposits makes are ported and match the save's for all 31 minerals in every stored region. With them and the strata, a column reads as the pick's density mode would read it: a Minerals overlay colours the map by reading, the probe lists every mineral the pick finds, and Find nearest looks for a mineral read at least so high. Readings run slightly high: the pick's column already holds the ore of its chunk's deposits, which are not generated yet. The check against the 13 readings stored in the save asserts exactly that direction. Silver, gold and peridot are read from ore inside other deposits, so they wait for the deposits themselves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,8 +22,10 @@
|
||||
(import rivers)
|
||||
(import terra)
|
||||
(import strata)
|
||||
(import ores)
|
||||
|
||||
(pub record hover-query ((x int) (z int) (mode int) (value int)))
|
||||
;;; MINERAL is the mineral whose reading is wanted, or -1.
|
||||
(pub record hover-query ((x int) (z int) (mode int) (value int) (mineral int)))
|
||||
|
||||
(pub record hover-result
|
||||
((valid bool) (query hover-query)
|
||||
@@ -34,7 +36,9 @@
|
||||
;; block, or -3 when the column has none of it.
|
||||
(rock int) (rock-y int) (surface-rock 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
|
||||
(mineral mineral-reading)))
|
||||
|
||||
(pub record hover-worker
|
||||
((lock pthread-mutex-t) (wake pthread-cond-t) (thread pthread-t) (quit bool)
|
||||
@@ -49,8 +53,10 @@
|
||||
|
||||
;;; The worker's generators and the region and plate it has at hand.
|
||||
(record kit
|
||||
((g (* worldgen)) (tr (* terra)) (rocks (* strata)) (generation int)
|
||||
((g (* worldgen)) (tr (* terra)) (rocks (* strata)) (minerals (* ores)) (generation int)
|
||||
(rx int) (rz int) (maps [int-map 5]) (has-region bool)
|
||||
;; the ore map last asked for: its mineral and region
|
||||
(ore-map int-map) (ore-mineral int) (ore-rx int) (ore-rz int)
|
||||
(plate (* river-plate)) (segments (* int)) (sampler river-sampler)
|
||||
(column (* u8))))
|
||||
|
||||
@@ -61,6 +67,8 @@
|
||||
(for (var i int 0) (< i 5) (++ i)
|
||||
(free (. [(. k maps) i] data))))
|
||||
(if (. k plate) (river-plate/free (. k plate)))
|
||||
(free (. k ore-map data))
|
||||
(if (. k minerals) (ores/free (. k minerals)))
|
||||
(if (. k rocks) (strata/free (. k rocks)))
|
||||
(if (. k tr) (terra/free (. k tr)))
|
||||
(if (. k g) (worldgen/free (. k g)))
|
||||
@@ -110,6 +118,17 @@
|
||||
(= (. r sea-level) (. (. k tr) sea-level))
|
||||
(strata/column (. k rocks) (/ x 32) (/ z 32) (% x 32) (% z 32) h (. k column))
|
||||
(= (. r surface-rock) [(. k column) h])
|
||||
(if (&& (. k minerals) (>= (. q mineral) 0) (< (. q mineral) (. (. k minerals) count)))
|
||||
(do
|
||||
(if (|| (! (. k ore-map data)) (!= (. k ore-mineral) (. q mineral)) (!= (. k ore-rx) rx)
|
||||
(!= (. k ore-rz) rz))
|
||||
(do
|
||||
(free (. k ore-map data))
|
||||
(ores/map (. k minerals) (. q mineral) rx rz (& (. k ore-map)))
|
||||
(= (. k ore-mineral) (. q mineral))
|
||||
(= (. k ore-rx) rx)
|
||||
(= (. k ore-rz) rz)))
|
||||
(= (. r mineral) (ores/reading (. k minerals) (. q mineral) (& (. k ore-map)) x z (. k column) h))))
|
||||
(if (== (. q mode) 3)
|
||||
(do
|
||||
(= (. r rock) -3)
|
||||
@@ -156,6 +175,7 @@
|
||||
(do
|
||||
(= (. k tr) (terra/make (. k g) (. w rivers)))
|
||||
(= (. k rocks) (strata/make (. k g) (. w assets-dir)))
|
||||
(= (. k minerals) (ores/make settings (. w assets-dir) (. k rocks)))
|
||||
(= (. k sampler) (river-sampler/make (& (. w rivers)) (. settings size-y)))
|
||||
(= (. k column) (malloc (+ (. settings size-y) 1)))))
|
||||
(= (. k generation) generation)))
|
||||
@@ -193,7 +213,8 @@
|
||||
(pub fn hover-worker/ask ((w (* hover-worker)) (q hover-query)) void
|
||||
(pthread-mutex-lock (& (. w lock)))
|
||||
(if (|| (!= (. w query x) (. q x)) (!= (. w query z) (. q z)) (!= (. w query mode) (. q mode))
|
||||
(!= (. w query value) (. q value)) (! (. w result valid)))
|
||||
(!= (. w query value) (. q value)) (!= (. w query mineral) (. q mineral))
|
||||
(! (. w result valid)))
|
||||
(do
|
||||
(= (. w query) q)
|
||||
(= (. w pending) true)
|
||||
|
||||
Reference in New Issue
Block a user