Offline decoder of Trainz .gse (GameScript Encrypted) scripts back into
.gs sources. Supported games: TRS2006 … TS12 SP1 (trainz-build
2.5–3.7), plus the newer games that write single containers with
version 2: Trainz: A New Era (3.9–4.5), TRS19 (4.6–5.0) and TRS22 /
Trainz Plus (5.1+). No Trainz installation is needed: the decoder is
fully offline.
The name refers to a railway pointsman: the adaptive Huffman decoder walks the binary tree, flipping the switch on every bit, and after every symbol the tree rearranges its nodes by itself.
| mode | stream | support |
|---|---|---|
0x00 |
no compression | 100% |
0x01–0x06 |
LZ with flag-words (window 0) | 100% |
0x11–0x16, 0x21–0x26 |
16-bit dist/len tokens (windows 1–2, levels 1–6) | 100% |
0x18/0x19, 0x28/0x29 |
LZ + adaptive FGK Huffman (windows 1–2, levels 7–9) | 100% |
Both storage forms are accepted: .gse (a CFIL container with blocks,
or a single container with version 1 or 2, plus XOR32) and a raw
.gs/CDP blob ([srclen][mode][stream], auto-detected).
flowchart LR
A[".gse"] --> B["CFIL or single container<br/>version · QWORD len · payload"]
B --> D["XOR32<br/>with a fixed key"]
D --> E["srclen · mode · stream"]
E --> F{"mode"}
F -->|"06"| G["LZ flag-words"]
F -->|"19/29"| H["LZ + FGK adaptive Huffman<br/>2 models, LSB-first bits"]
F -->|"00"| I["no decompression"]
G --> J[".gs"]
H --> J
I --> J
The version bump is container-only: Trainz: A New Era and later write version 2, while KEY32, the modes and the length tables are unchanged (spec §2.1).
The details are in docs/en/GSE_FORMAT_SPEC.md.
Go 1.26+, standard library only:
go build -o bin\pointsman.exe .\cmd\pointsman # Windows
go build -o bin/pointsman ./cmd/pointsman # Linux / macOS
pointsman [-lang en|ru|de] <command> [arguments]
Examples:
$ pointsman decode probe.gse
OK [huffman win=2 lvl=9 shift=14]: 48216 B → probe.gs
$ # exact output name; -f overwrites an existing file
$ pointsman decode probe.gse -o out/probe.gs -f
$ # every .gse under the directory, recursively
$ pointsman batch C:\games\trainz\scripts -o decoded
$ pointsman info probe.gse
file: probe.gse
format: CFIL container + XOR32
mode: huffman win=2 lvl=9 shift=14
source length: 48216
result: OK, 48216 B
$ # message language: en, ru, de
$ pointsman -lang ru info probe.gseContract:
- decoded text is written to a file: by default the input path with a
.gssuffix (foo.gse→foo.gs);-osets an exact name or a directory; an existing result is not overwritten without-f; - command flags are accepted before and after positional arguments;
--ends flags; the global-langgoes before the command name; - status lines (
OK [mode]: N B → path, batch summaries,FAIL: reason) go to stderr; stdout stays clean, except the text output ofinfo,versionandhelp; - exit codes: 0 — success, 1 — decode failure, 2 — usage error;
- message language: en by default,
-langor thePOINTSMAN_LANGenvironment variable.
Full help: pointsman help; per command: pointsman help decode.
The decoder is verified against the corpus (see
docs/en/QA.md): byte-exact matches with the
.gs sources of the synthetic files, coverage of all mode families
(0x00, 0x0x, 0x1x, 0x2x) and of both container forms (CFIL and
single containers with versions 1 and 2), and load runs with zero
failures. The regression runs with go test ./... — the corpus
lives in the repository.
The format was reverse-engineered from Kernel_7c.dll; the full
specification is in docs/en/GSE_FORMAT_SPEC.md.
| path | content |
|---|---|
cmd/pointsman/ |
CLI entry point |
internal/cli/ |
commands: decode, batch, info, version, help |
internal/i18n/ |
messages: en (canonical), ru, de |
internal/gse/ |
decoder: CFIL and single containers, XOR32, LZ-06, FGK Huffman |
testdata/ |
regression corpus: synthetic files and mode probes |
docs/ |
format spec, QA, FAQ, overview |
| document | content |
|---|---|
| docs/en/GSE_FORMAT_SPEC.md | full format specification |
| docs/en/QA.md | regression corpus, verification, test pair generation, environment rules |
| docs/en/FAQ.md | reverse engineering notes |
Distributed under the MIT license — see LICENSE.