generate the region maps as the game does
Every map in all 118 stored regions matches the save to the pixel, so the port is checked against ground truth rather than eyeballed. Getting there meant reproducing .NET quirks the output depends on: LCGRandom reseeding from its previous seed, Dictionary slot order in NaturalShape, and C#'s left-to-right evaluation of RNG draws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,50 @@
|
||||
Language bugs and friction met while building vs-map-viewer, against
|
||||
sexc at ~/dev/sex. Newest first. Unless said otherwise, sexc dfafe8b.
|
||||
|
||||
* A conditional expression as an operand loses its parentheses
|
||||
#+begin_src scheme
|
||||
(/ (* 100.0 matched) (if (> compared 0) compared 1))
|
||||
#+end_src
|
||||
emits =(100.0 * matched) / (compared > 0) ? compared : 1=, which C
|
||||
parses as =((100.0 * matched) / (compared > 0)) ? compared : 1=.
|
||||
Clang only warns (-Wparentheses). This one computes wrong values
|
||||
silently, so it is the most dangerous entry here. Bound to a variable
|
||||
first, it's right.
|
||||
|
||||
* An import doesn't bring the types its interface needs
|
||||
Module =save= takes a =(* region-maps)= from module =maps=. Importing
|
||||
=save= pastes its prototypes but not =region-maps=, so every importer
|
||||
has to import =maps= itself, and before =save=:
|
||||
|
||||
#+begin_example
|
||||
save.sex:284:52: error: unknown type name 'region_maps'
|
||||
#+end_example
|
||||
|
||||
=vsmv.sex= now imports eight modules in dependency order to use three.
|
||||
Imports are at least idempotent (a diamond works).
|
||||
|
||||
* A pub record with a field of a private record type
|
||||
=(pub record natural-shape (... (slots (* shape-cell)) ...))= with
|
||||
=shape-cell= not =pub= compiles in its own module, and in the importer
|
||||
fails with =unknown type name 'shape_cell'=. Either an error at the
|
||||
definition or exporting the type would do.
|
||||
|
||||
* =[(* T) N]= fields break in importers
|
||||
A pub record field =(noises [(* simplex-sum) 32])= compiles in its own
|
||||
module but not when pasted into an importer:
|
||||
=Error: pointer chains are written flat, as (* * T), not nested:
|
||||
((* simplex-sum) MAX_STRATA)=. The message points at the wrong thing;
|
||||
=[* simplex-sum MAX_STRATA]= works, while a local
|
||||
=(var names [(* const char) 6])= is fine either way.
|
||||
|
||||
* =define= bodies are pasted raw
|
||||
=(define K (/ (cast 255 float) (cast 60 float)))= emits
|
||||
=#define K cast(255, float) / cast(60, float)=: not translated, and
|
||||
not parenthesized. With =(define D (/ -1.0 6.0))=, =(* x D)= becomes
|
||||
=x * -1.0 / 6.0=. That's =(x * -1.0) / 6.0=, which rounds differently
|
||||
from multiplying by the folded constant. Bit-exact code needs literal
|
||||
values or typed =var=s.
|
||||
|
||||
* =#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
|
||||
@@ -16,8 +60,8 @@ 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.
|
||||
=-C= output, without the directives, is fine. The build now passes
|
||||
=--line-directives=toplevel= to every Sex unit.
|
||||
|
||||
* A typedef of a function pointer type crashes the compiler
|
||||
#+begin_src scheme
|
||||
|
||||
Reference in New Issue
Block a user