read the save, the seed and the worldgen assets

The engine's save classes are closed, so the protobuf field numbers
were read off the data and matched to the map sizes TerraGenConfig
gives. vsmv dump renders what the save stored, as the reference the
generator will be diffed against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 17:56:14 +03:00
parent d72ae437ae
commit 90b5d50fa5
12 changed files with 2807 additions and 51 deletions

View File

@@ -1,7 +1,85 @@
#+TITLE: Sex field notes
Language bugs and friction met while building vs-map-viewer, against
sexc at ~/dev/sex. Newest first.
sexc at ~/dev/sex. Newest first. Unless said otherwise, sexc dfafe8b.
* =#line= splits a ternary in a call argument
=(if c a b)= in expression position becomes =c ? a : b=. Inside a
multi-line call, though, the statement anchor lands between the
ternary's parts, and the C doesn't compile:
#+begin_src scheme
(.set (& river) x y (if (== d 0) 4219071 (grey (- 255 d))))
#+end_src
#+begin_example
dump.sex:128:1: error: expected expression
128 | , grey(255 - d));
#+end_example
=-C= output, without the directives, is fine. Worked around with a
variable.
* A typedef of a function pointer type crashes the compiler
#+begin_src scheme
(typedef colour-fn (fn ((i32)) u32))
#+end_src
#+begin_example
Error: (cdr) bad argument type: u32
#+end_example
No location. The same type written inline in a parameter list works.
* =sizeof= of a pointer type reads as a dereference
=(sizeof (* char))= becomes =sizeof(*char)=. There's no way to spell
the type; =(sizeof x)= on an expression works.
* =case= bodies share one scope
A =case= body isn't braced, so =(var bits u64 ...)= in one case and
=(var bits u32 ...)= in the next is a C redefinition. Clang also warns
"label followed by a declaration is a C23 extension". Wrapping each
body in =(do ...)= works around it; the writer could do that itself.
* Constants in array types aren't kebab-converted
=(var xs [u16 CHUNK-AREA])= and record fields like
=(terrain-height [u16 CHUNK-AREA])= emit =CHUNK-AREA= literally, while
=CHUNK-AREA= in an expression becomes =CHUNK_AREA=. Writing
=CHUNK_AREA= in the type works around it.
* =?= is not mangled in names
=(fn ident-start? ...)= emits =ident_start?=, which isn't C. Lisp
predicates want =?=; =-= is mangled to =_=, so =?= could become =_p=.
* Relative =SEX_MODULE_PATH= entries resolve from the root
=SEX_MODULE_PATH=src sexc ...= searches =/src/=. An absolute path works.
* No hex literals
=0x80= reaches C as =|0x80|= (the Scheme printer escaping a symbol
that looks numeric), and =#x80= is rejected by the reader:
"Unsupported # syntax: #\x". Masks and code points have to be written
in decimal, which hurts in bit-twiddling code: =(& c 224)= instead of
=(& c 0xE0)=.
* Explicit enum values emit raw names
#+begin_src scheme
(pub enum wire ((wire-varint 0) (wire-fixed64 1)))
#+end_src
emits =wire-varint = 0, ...=, neither kebab-converted nor accepted by
C. Plain =(enum name (a b c))= works; explicit values need =define=s.
* Member access inside a compound literal ignores the operand's type
With =self= a =(* pb)=, =#(pb : (. self p) (. self p) true)= emits
=self.p=, not =self->p=. The same =(. self p)= outside a literal is
right. Bound to a local first, it works.
* Methods can only call methods above them
Inside one =ops= block, calling a method defined further down fails
with =no such method on pb len=. C needs prototypes, so this is
consistent, but the block could declare its methods before their
bodies.
* =-o -= crashes instead of meaning stdout
=--help= says -C output defaults to stdout without =-o=; passing =-o -=
explicitly dies in getopt-long's argument handling.
* A malformed =for= crashes the compiler
sexc dfafe8b. Writing the C-style grouped header