Compare commits

..

2 Commits

Author SHA1 Message Date
e42e7b46b5 Add ability to set custom spawn location 2026-10-15 23:53:45 +03:00
dc15ec21a4 add cJSON as submodule 2026-10-11 18:52:21 +03:00
9 changed files with 150 additions and 59 deletions

6
.gitignore vendored
View File

@@ -1,11 +1,9 @@
/build/ /build/
# Inputs that stay local: the game's assets, the Rivers release, the # Inputs that stay local: the game's assets, the Rivers release, and
# test world and its server config, and the cJSON checkout the build # the test world and its server config.
# compiles from.
/assets/ /assets/
/serverconfig.json /serverconfig.json
/cJSON/
*.zip *.zip
*.vcdbs *.vcdbs
*.vcdbs-* *.vcdbs-*

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "cJSON"]
path = cJSON
url = https://github.com/DaveGamble/cJSON.git

View File

@@ -227,9 +227,14 @@ Modules. Each is a Sex module; the =vsmv= CLI and the GUI share them.
- =ui=: Nuklear + SDL3 SDL_Renderer. Tiles are SDL textures under the - =ui=: Nuklear + SDL3 SDL_Renderer. Tiles are SDL textures under the
Nuklear panels. Nuklear panels.
Coordinates are shown like the in-game HUD, relative to the map centre Coordinates are shown as the game shows them, relative to the world's
=((MapSizeX+32)/2, (MapSizeZ+32)/2)=, with absolute coordinates available spawn (=DefaultSpawnPosition=, which =GuiDialogWorldMap= subtracts):
too. The viewer opens at spawn. =SaveGame.DefaultSpawn= when the world has one (game data field 40, a
=PlayerSpawnPos= {1: x, 2: y, 3: z, 7: remaining uses}; this save's is
1023719, 142, 12553), or =serverconfig.json='s =DefaultSpawn=, else
the map's middle. A spawn of one's own can be set over it, by clicking
the map after /Set spawn/ or with =--spawn X Z=. Absolute
coordinates are shown too. The viewer opens at the spawn.
* Phases * Phases
Each phase ends with a check against the save. A mismatch means stop, Each phase ends with a check against the save. A mismatch means stop,

View File

@@ -12,41 +12,18 @@ and where the caves run.
[[file:doc/screenshot.png]] [[file:doc/screenshot.png]]
It covers Vintage Story 1.22.7 with the Rivers 5.0.3 mod. The It covers Vintage Story 1.22.7 with the Rivers 5.0.3 mod. The
generator is a port of the game's own, written in [[https://git.kotobank.ch/alex-eg/sex][Sex]]. It is checked generator is a port of the game's own, written in [[https://git.kotobank.ch/alex-eg/sex][Sex]].
against a real save, and matches it:
| What | Matches |
|-------------------------------------------+-----------------------------------------|
| Region maps: landform, climate, province, ocean, upheaval, strata | every pixel of 118 regions |
| Story structure locations | all 6 |
| Rivers' distance to the nearest river | 100% of 6.5 million columns |
| Terrain height | 98.2% of 11.7 million columns |
| Rock at the surface | all but 14 of 11.7 million columns |
| Rock below the surface | 99.91% of 1.38 billion blocks; see below |
| Caves | 96.1% of 18.5 million carved blocks; see below |
| Ore maps, 31 minerals | every pixel of 118 regions |
| Prospecting pick readings | 38 of 42 in the game's category; see Limits |
All but 0.02% of the other heights come from two passes that run after
the strata are laid: caves that open the surface, and the raise of dry
seabeds. Neither changes which rock is where. Below the surface, all
but 0.0011% of the other rock comes from later passes too: lava in deep
caves turns the rock around it to basalt, and cave walls and
underground structures are built of granite. Where the caves differ,
it is nearly all what later passes put in them, or air the structures
and the block layers make; 0.28% is not explained.
=Plan.org= has the details.
** Building ** Building
You need: You need:
- the Sex compiler, expected at =~/dev/sex/sexc= (or set =SEXC=); - the Sex compiler;
- a C compiler; - a C compiler;
- SDL3 (=brew install sdl3=); - SDL3;
- SQLite3; - SQLite3;
- zstd (=brew install zstd=); - zstd;
- a checkout of [[https://github.com/DaveGamble/cJSON][cJSON]] in =./cJSON=.
Nuklear and stb_image_write are vendored in =third_party/=. Nuklear and stb_image_write are vendored in =third_party/=.
сJSON is a submodule, so use =git submodule update --init= before building.
#+begin_src sh #+begin_src sh
make make
@@ -70,8 +47,9 @@ WORLD is where the seed and settings come from:
real size; real size;
- or a =serverconfig.json=: the seed as typed and the world config. - or a =serverconfig.json=: the seed as typed and the world config.
Without WORLD it opens =./serverconfig.json=. It starts at spawn, in the Without WORLD it opens =./serverconfig.json=. It starts at the world's
middle of the map. spawn: the one the save or config names, else the middle of the map,
as in the game.
Options: Options:
@@ -92,6 +70,7 @@ Options:
| =--find-cave= | find the nearest cave entrance on start | | =--find-cave= | find the nearest cave entrance on start |
| =--find-hot-spring= | find the nearest hot spring on start | | =--find-hot-spring= | find the nearest hot spring 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 |
| =--spawn X Z= | count coordinates from block X, Z instead of the world's spawn |
| =--screenshot FILE.png= | wait until everything is drawn, save the window, quit | | =--screenshot FILE.png= | wait until everything is drawn, save the window, quit |
| =--mouse X Y= | place the cursor, for screenshots | | =--mouse X Y= | place the cursor, for screenshots |
@@ -130,9 +109,13 @@ when nothing is left to compute, the viewer sleeps.
- Change any setting (seed, sizes, landcover, scales, climate...) - Change any setting (seed, sizes, landcover, scales, climate...)
and press /Apply/ to generate that world instead. The seed can be and press /Apply/ to generate that world instead. The seed can be
any text, as typed into the game. any text, as typed into the game.
- /Go to spawn/ goes back to the centre of the map. - /Go to spawn/ goes back to the spawn.
- /Set spawn/, then a click on the map, sets the spawn that
coordinates count from there, as the game counts them from the
world's; Escape or the button again gives up. It starts as the
world's spawn; /World's spawn/ goes back to it.
- *Info*: what is under the cursor: - *Info*: what is under the cursor:
- coordinates, absolute and from the map centre, and the region; - coordinates, absolute and from the spawn, and the region;
- landform and geologic province; - landform and geologic province;
- climate: temperature at sea level, rain, geologic activity; - climate: temperature at sea level, rain, geologic activity;
- ocean and upheaval values; - ocean and upheaval values;
@@ -156,7 +139,8 @@ when nothing is left to compute, the viewer sleeps.
- *Overlays*: any of Landform, Climate, Geologic province, Upheaval, - *Overlays*: any of Landform, Climate, Geologic province, Upheaval,
Rock strata thickness (pick the stratum below it), Rock and Rock strata thickness (pick the stratum below it), Rock and
Minerals. Drawn over the base at the /Overlay opacity/. Minerals. Drawn over the base at the /Overlay opacity/.
- /Story locations/ marks spawn and the story structures. - /Story locations/ marks the spawn, the world's spawn if the one set
differs, and the story structures.
- /Rock under cursor/ turns the cursor label on and off. - /Rock under cursor/ turns the cursor label on and off.
- *Rocks*: finding rock. - *Rocks*: finding rock.
- Choose where to look: at the /Surface/, at a /Depth below - Choose where to look: at the /Surface/, at a /Depth below

1
cJSON Submodule

Submodule cJSON added at 6d9f2443ab

View File

@@ -35,7 +35,10 @@
(block-codes (* * char)) (block-count int) (block-codes (* * char)) (block-count int)
(stories [story-location MAX-STORIES]) (story-count int) (stories [story-location MAX-STORIES]) (story-count int)
;; every player's stored pick readings ;; every player's stored pick readings
(pick-readings (* pick-reading)) (pick-reading-count int))) (pick-readings (* pick-reading)) (pick-reading-count int)
;; SaveGame.DefaultSpawn, when the world has one: where the game counts
;; its coordinates from
(has-spawn bool) (spawn-x i32) (spawn-y i32) (spawn-z i32)))
;;; Map regions and map chunks share one key: x in the low 27 bits, ;;; Map regions and map chunks share one key: x in the low 27 bits,
;;; z above them. ;;; z above them.
@@ -233,6 +236,17 @@
(== f 3) (= (. s size-z) (.int32 (& r))) (== f 3) (= (. s size-z) (.int32 (& r)))
(== f 7) (= (. s seed) (.int32 (& r))) (== f 7) (= (. s seed) (.int32 (& r)))
(== f 31) (read-tree-attribute s (.bytes (& r))) (== f 31) (read-tree-attribute s (.bytes (& r)))
;; DefaultSpawn, a PlayerSpawnPos: {1: x, 2: y, 3: z, ...}
(== f 40)
(do
(var spawn pb (.bytes (& r)))
(var g u32)
(= (. s has-spawn) true)
(while (> (= g (.field (& spawn) (& wire))) 0)
(if (== g 1) (= (. s spawn-x) (.int32 (& spawn)))
(== g 2) (= (. s spawn-y) (.int32 (& spawn)))
(== g 3) (= (. s spawn-z) (.int32 (& spawn)))
(.skip (& spawn) wire))))
(== f 11) (== f 11)
(do (do
(var entry pb (.bytes (& r))) (var entry pb (.bytes (& r)))

View File

@@ -8,8 +8,10 @@
(import save) (import save)
(pub import worldgen) (pub import worldgen)
;;; Settings plus the seed as the user would type it. ;;; Settings plus the seed as the user would type it, and the world's
(pub record world-source ((settings world-settings) (seed-text [char 128]))) ;;; spawn if it names one; the game's default is the map's middle.
(pub record world-source
((settings world-settings) (seed-text [char 128]) (has-spawn bool) (spawn-x int) (spawn-z int)))
(fn ends-with ((s (* const char)) (suffix (* const char))) bool (fn ends-with ((s (* const char)) (suffix (* const char))) bool
(var n size-t (strlen s)) (var n size-t (strlen s))
@@ -28,6 +30,9 @@
(= (. out settings size-y) (. s size-y)) (= (. out settings size-y) (. s size-y))
(= (. out settings size-z) (. s size-z)) (= (. out settings size-z) (. s size-z))
(snprintf (. out seed-text) (sizeof (. out seed-text)) "%d" (. s seed)) (snprintf (. out seed-text) (sizeof (. out seed-text)) "%d" (. s seed))
(= (. out has-spawn) (. s has-spawn))
(= (. out spawn-x) (. s spawn-x))
(= (. out spawn-z) (. s spawn-z))
(save/close s) (save/close s)
(return true)) (return true))
@@ -48,6 +53,14 @@
(var map-size-y (* cJSON) (cJSON-GetObjectItem world "MapSizeY")) (var map-size-y (* cJSON) (cJSON-GetObjectItem world "MapSizeY"))
(if (cJSON-IsNumber map-size-y) (if (cJSON-IsNumber map-size-y)
(= (. out settings size-y) (cast (cJSON-GetNumberValue map-size-y) int))) (= (. out settings size-y) (cast (cJSON-GetNumberValue map-size-y) int)))
;; DefaultSpawn: a PlayerSpawnPos, null unless set
(var spawn (* cJSON) (cJSON-GetObjectItem json "DefaultSpawn"))
(if (&& (cJSON-IsObject spawn) (cJSON-IsNumber (cJSON-GetObjectItem spawn "x"))
(cJSON-IsNumber (cJSON-GetObjectItem spawn "z")))
(do
(= (. out has-spawn) true)
(= (. out spawn-x) (cast (cJSON-GetNumberValue (cJSON-GetObjectItem spawn "x")) int))
(= (. out spawn-z) (cast (cJSON-GetNumberValue (cJSON-GetObjectItem spawn "z")) int))))
(var config (* cJSON) (cJSON-GetObjectItem world "WorldConfiguration")) (var config (* cJSON) (cJSON-GetObjectItem world "WorldConfiguration"))
(for (var item (* cJSON) (if config (. config child) NULL)) item (= item (. item next)) (for (var item (* cJSON) (if config (. config child) NULL)) item (= item (. item next))
(var text [char 64]) (var text [char 64])
@@ -63,6 +76,7 @@
(pub fn world-source/load ((path (* const char)) (out (* world-source))) bool (pub fn world-source/load ((path (* const char)) (out (* world-source))) bool
(= (. out settings) (world-settings/defaults)) (= (. out settings) (world-settings/defaults))
(snprintf (. out seed-text) (sizeof (. out seed-text)) "0") (snprintf (. out seed-text) (sizeof (. out seed-text)) "0")
(= (. out has-spawn) false)
(if (ends-with path ".vcdbs") (if (ends-with path ".vcdbs")
(return (from-save path out))) (return (from-save path out)))
(return (from-server-config path out))) (return (from-server-config path out)))

View File

@@ -5,7 +5,7 @@
;;; [--base ocean|rivers|height] [--overlay NAME]... [--opacity F] ;;; [--base ocean|rivers|height] [--overlay NAME]... [--opacity F]
;;; [--rock-depth N | --rock-y Y | --rock-any] [--highlight ROCK]... [--find] ;;; [--rock-depth N | --rock-y Y | --rock-any] [--highlight ROCK]... [--find]
;;; [--mineral CODE] [--min-reading NAME] [--find-mineral] [--find-cave] ;;; [--mineral CODE] [--min-reading NAME] [--find-mineral] [--find-cave]
;;; [--find-hot-spring] ;;; [--find-hot-spring] [--spawn X Z]
;;; [--probe X Z] [--mouse X Y] ;;; [--probe X Z] [--mouse X Y]
;;; [--screenshot FILE.png] [WORLD.vcdbs | serverconfig.json] ;;; [--screenshot FILE.png] [WORLD.vcdbs | serverconfig.json]
;;; ;;;
@@ -151,6 +151,11 @@
(find-spring-requested bool) (find-spring-requested bool)
(probe-caves (* caves)) (probe-caves (* caves))
(search-kind int) (search-kind int)
;; where coordinates count from: the world's spawn unless set, and one
;; given on the command line
(spawn-x int) (spawn-z int) (spawn-arg bool) (arg-spawn-x int) (arg-spawn-z int)
;; the next click on the map sets the spawn instead of probing
(picking-spawn bool)
(show-stories bool) (show-cursor-rock bool) (show-stories bool) (show-cursor-rock bool)
;; what is under the cursor, from the hover worker; and a terrain ;; what is under the cursor, from the hover worker; and a terrain
;; generator of the main thread's own, for probes ;; generator of the main thread's own, for probes
@@ -239,9 +244,23 @@
(var r SDL-FRect (map-rect a)) (var r SDL-FRect (map-rect a))
(return (&& (>= x (. r x)) (< x (+ (. r x) (. r w))) (>= y (. r y)) (< y (+ (. r y) (. r h)))))) (return (&& (>= x (. r x)) (< x (+ (. r x) (. r w))) (>= y (. r y)) (< y (+ (. r y) (. r h))))))
;;; The world's own spawn: the one its save or server config names,
;;; else the map's middle, the game's default.
(fn world-spawn ((a (* app)) (x (* int)) (z (* int))) void
(if (. a source has-spawn)
(do
(= (* x) (. a source spawn-x))
(= (* z) (. a source spawn-z)))
(do
(= (* x) (/ (. a source settings size-x) 2))
(= (* z) (/ (. a source settings size-z) 2)))))
(fn reset-spawn ((a (* app))) void
(world-spawn a (& (. a spawn-x)) (& (. a spawn-z))))
(fn go-to-spawn ((a (* app))) void (fn go-to-spawn ((a (* app))) void
(= (. a center-x) (/ (. a source settings size-x) 2.0)) (= (. a center-x) (+ (. a spawn-x) 0.5))
(= (. a center-z) (/ (. a source settings size-z) 2.0))) (= (. a center-z) (+ (. a spawn-z) 0.5)))
;;; Applying settings ---------------------------------------------- ;;; Applying settings ----------------------------------------------
@@ -382,6 +401,7 @@
(if (world-source/load (. a world-path) (& source)) (if (world-source/load (. a world-path) (& source))
(do (do
(apply a source) (apply a source)
(reset-spawn a)
(go-to-spawn a)) (go-to-spawn a))
(snprintf (. a status) (sizeof (. a status)) "cannot load %s" (. a world-path)))) (snprintf (. a status) (sizeof (. a status)) "cannot load %s" (. a world-path))))
@@ -531,12 +551,23 @@
(var g (* worldgen) (. a g)) (var g (* worldgen) (. a g))
(SDL-SetRenderDrawColor r 255 255 255 255) (SDL-SetRenderDrawColor r 255 255 255 255)
(var stories int (. g story-count)) (var stories int (. g story-count))
(if (! (. a show-stories)) (= stories -1)) (if (! (. a show-stories)) (= stories -2))
(for (var i int -1) (< i stories) (++ i) ;; the spawn, the world's own if the one set differs, then the stories
(var x double (/ (. a source settings size-x) 2.0)) (var wx int)
(var z double (/ (. a source settings size-z) 2.0)) (var wz int)
(world-spawn a (& wx) (& wz))
(for (var i int -2) (< i stories) (++ i)
(var x double (+ (. a spawn-x) 0.5))
(var z double (+ (. a spawn-z) 0.5))
(var name (* const char) "spawn") (var name (* const char) "spawn")
(if (>= i 0) (if (== i -1)
(do
(if (&& (== wx (. a spawn-x)) (== wz (. a spawn-z)))
(continue))
(= x (+ wx 0.5))
(= z (+ wz 0.5))
(= name "world spawn"))
(>= i 0)
(do (do
(= x (. [(. g stories) i] x)) (= x (. [(. g stories) i] x))
(= z (. [(. g stories) i] z)) (= z (. [(. g stories) i] z))
@@ -636,6 +667,19 @@
(apply a source))) (apply a source)))
(if (nk-button-label ctx "Go to spawn") (if (nk-button-label ctx "Go to spawn")
(go-to-spawn a)) (go-to-spawn a))
;; the spawn coordinates count from, by default the world's: set
;; by a click on the map
(nk-layout-row-dynamic ctx 26 2)
(if (nk-button-label ctx (if (. a picking-spawn) "Click the map" "Set spawn"))
(= (. a picking-spawn) (! (. a picking-spawn))))
(var wx int)
(var wz int)
(world-spawn a (& wx) (& wz))
(var moved bool (|| (!= wx (. a spawn-x)) (!= wz (. a spawn-z))))
(if (! moved) (nk-widget-disable-begin ctx))
(if (nk-button-label ctx "World's spawn")
(reset-spawn a))
(if (! moved) (nk-widget-disable-end ctx))
(nk-tree-pop ctx)))) (nk-tree-pop ctx))))
;;; The rock layer's mode, its depth or Y, and the legend: clicking rocks ;;; The rock layer's mode, its depth or Y, and the legend: clicking rocks
@@ -989,10 +1033,8 @@
(if (nk-tree-push ctx NK-TREE-TAB "Probe" NK-MAXIMIZED) (if (nk-tree-push ctx NK-TREE-TAB "Probe" NK-MAXIMIZED)
(do (do
(nk-layout-row-dynamic ctx 18 1) (nk-layout-row-dynamic ctx 18 1)
(var s (* world-settings) (& (. a source settings)))
(nk-labelf ctx NK-TEXT-LEFT "x %d z %d" (. p x) (. p z)) (nk-labelf ctx NK-TEXT-LEFT "x %d z %d" (. p x) (. p z))
(nk-labelf ctx NK-TEXT-LEFT "from centre %d, %d" (- (. p x) (/ (. s size-x) 2)) (nk-labelf ctx NK-TEXT-LEFT "from spawn %d, %d" (- (. p x) (. a spawn-x)) (- (. p z) (. a spawn-z)))
(- (. p z) (/ (. s size-z) 2)))
(nk-labelf ctx NK-TEXT-LEFT "surface at y %d" (. p height)) (nk-labelf ctx NK-TEXT-LEFT "surface at y %d" (. p height))
(nk-layout-row-dynamic ctx 22 3) (nk-layout-row-dynamic ctx 22 3)
(if (nk-button-label ctx "Go to") (if (nk-button-label ctx "Go to")
@@ -1089,7 +1131,6 @@
(fn draw-info ((a (* app))) void (fn draw-info ((a (* app))) void
(var ctx (* struct nk-context) (. a ctx)) (var ctx (* struct nk-context) (. a ctx))
(var s (* world-settings) (& (. a source settings)))
(var bx int) (var bx int)
(var bz int) (var bz int)
(var inside bool (cursor-block a (& bx) (& bz))) (var inside bool (cursor-block a (& bx) (& bz)))
@@ -1098,7 +1139,7 @@
(do (do
(nk-layout-row-dynamic ctx 18 1) (nk-layout-row-dynamic ctx 18 1)
(nk-labelf ctx NK-TEXT-LEFT "x %d z %d" bx bz) (nk-labelf ctx NK-TEXT-LEFT "x %d z %d" bx bz)
(nk-labelf ctx NK-TEXT-LEFT "from centre %d, %d" (- bx (/ (. s size-x) 2)) (- bz (/ (. s size-z) 2))) (nk-labelf ctx NK-TEXT-LEFT "from spawn %d, %d" (- bx (. a spawn-x)) (- bz (. a spawn-z)))
(nk-labelf ctx NK-TEXT-LEFT "region %d, %d zoom %.3g blocks/pt" (/ bx REGION) (/ bz REGION) (nk-labelf ctx NK-TEXT-LEFT "region %d, %d zoom %.3g blocks/pt" (/ bx REGION) (/ bz REGION)
(. a zoom)) (. a zoom))
(if (&& inside (. r valid)) (if (&& inside (. r valid))
@@ -1216,7 +1257,8 @@
(fn draw-cursor-rock ((a (* app))) void (fn draw-cursor-rock ((a (* app))) void
(var bx int) (var bx int)
(var bz int) (var bz int)
(if (|| (! (. a show-cursor-rock)) (. a dragging) (! (cursor-block a (& bx) (& bz)))) (if (|| (&& (! (. a show-cursor-rock)) (! (. a picking-spawn))) (. a dragging)
(! (cursor-block a (& bx) (& bz))))
(return)) (return))
(var r (* hover-result) (& (. a hover))) (var r (* hover-result) (& (. a hover)))
(var text [char 64]) (var text [char 64])
@@ -1248,6 +1290,12 @@
(+= used (snprintf (+ caves used) (- (sizeof caves) used) "%s %d-%d%s" (if (> i 0) "," "") (+= used (snprintf (+ caves used) (- (sizeof caves) used) "%s %d-%d%s" (if (> i 0) "," "")
[(. r cave-tops) i] [(. r cave-bottoms) i] [(. r cave-tops) i] [(. r cave-bottoms) i]
(if [(. r cave-lava) i] " lava" ""))))))) (if [(. r cave-lava) i] " lava" "")))))))
;; or, while the next click sets the spawn, only that
(if (. a picking-spawn)
(do
(snprintf text (sizeof text) "click to set the spawn here")
(= [reading 0] 0)
(= [caves 0] 0)))
(var lines int (+ 1 (if [reading 0] 1 0) (if [caves 0] 1 0))) (var lines int (+ 1 (if [reading 0] 1 0) (if [caves 0] 1 0)))
(var height float (+ 12 (* 18 lines))) (var height float (+ 12 (* 18 lines)))
;; 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
@@ -1307,11 +1355,21 @@
(var bx int (cast (floor (to-world-x a (. event button x))) int)) (var bx int (cast (floor (to-world-x a (. event button x))) int))
(var bz int (cast (floor (to-world-z a (. event button y))) int)) (var bz int (cast (floor (to-world-z a (. event button y))) int))
(var pin int (pin-at a (. event button x) (. event button y))) (var pin int (pin-at a (. event button x) (. event button y)))
(if (>= pin 0) (var on-world bool (&& (>= bx 0) (>= bz 0) (< bx (. a source settings size-x))
(< bz (. a source settings size-z))))
(if (&& (. a picking-spawn) on-world)
(do
(= (. a spawn-x) bx)
(= (. a spawn-z) bz)
(= (. a picking-spawn) false))
(>= pin 0)
(probe-at a [(. a pins) (* pin 2)] [(. a pins) (+ (* pin 2) 1)]) (probe-at a [(. a pins) (* pin 2)] [(. a pins) (+ (* pin 2) 1)])
(&& (>= bx 0) (>= bz 0) (< bx (. a source settings size-x)) (< bz (. a source settings size-z))) on-world
(probe-at a bx bz)))) (probe-at a bx bz))))
(= (. a dragging) false)) (= (. a dragging) false))
;; Escape gives up setting the spawn
(&& (== type SDL-EVENT-KEY-DOWN) (== (. event key key) SDLK-ESCAPE))
(= (. a picking-spawn) false)
(&& (== type SDL-EVENT-MOUSE-WHEEL) (! (. a ui-hovered))) (&& (== type SDL-EVENT-MOUSE-WHEEL) (! (. a ui-hovered)))
(zoom-at a (pow 1.25 (- (. event wheel y))))) (zoom-at a (pow 1.25 (- (. event wheel y)))))
(nk-sdl-handle-event (. a ctx) event) (nk-sdl-handle-event (. a ctx) event)
@@ -1375,6 +1433,12 @@
(= (. a mouse-x) (cast (atof [argv (+ i 1)]) float)) (= (. a mouse-x) (cast (atof [argv (+ i 1)]) float))
(= (. a mouse-y) (cast (atof [argv (+ i 2)]) float)) (= (. a mouse-y) (cast (atof [argv (+ i 2)]) float))
(+= i 2)) (+= i 2))
(&& (== (strcmp [argv i] "--spawn") 0) (< (+ i 2) argc))
(do
(= (. a spawn-arg) true)
(= (. a arg-spawn-x) (atoi [argv (+ i 1)]))
(= (. a arg-spawn-z) (atoi [argv (+ i 2)]))
(+= i 2))
(&& (== (strcmp [argv i] "--probe") 0) (< (+ i 2) argc)) (&& (== (strcmp [argv i] "--probe") 0) (< (+ i 2) argc))
(do (do
(= (. a probe-x) (atoi [argv (+ i 1)])) (= (. a probe-x) (atoi [argv (+ i 1)]))
@@ -1432,6 +1496,11 @@
(do (do
(fprintf stderr "%s\n" (. a status)) (fprintf stderr "%s\n" (. a status))
(return 1))) (return 1)))
(reset-spawn a)
(if (. a spawn-arg)
(do
(= (. a spawn-x) (. a arg-spawn-x))
(= (. a spawn-z) (. a arg-spawn-z))))
(go-to-spawn a) (go-to-spawn a)
(if (|| (. a probe-x) (. a probe-z)) (if (|| (. a probe-x) (. a probe-z))
(probe-at a (. a probe-x) (. a probe-z))) (probe-at a (. a probe-x) (. a probe-z)))

View File

@@ -28,6 +28,9 @@
(return 1)) (return 1))
(printf "seed %d\n" (. s seed)) (printf "seed %d\n" (. s seed))
(printf "size %d x %d x %d\n" (. s size-x) (. s size-y) (. s size-z)) (printf "size %d x %d x %d\n" (. s size-x) (. s size-y) (. s size-z))
(if (. s has-spawn)
(printf "spawn %d %d %d\n" (. s spawn-x) (. s spawn-y) (. s spawn-z))
(printf "spawn the map's middle\n"))
(printf "block ids %d\n" (. s block-count)) (printf "block ids %d\n" (. s block-count))
(printf "world config, %d values:\n" (. s config-count)) (printf "world config, %d values:\n" (. s config-count))
(for (var i int 0) (< i (. s config-count)) (++ i) (for (var i int 0) (< i (. s config-count)) (++ i)