- Odin 60.9%
- Lua 39.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| zevent | ||
| CustomEventAPI.md | ||
| NativeAddonAPI.md | ||
| README.md | ||
| ToS.md | ||
Integrating a launcher with Zantetsuken
This guide is for authors of server launchers: programs that sign a player in and start the game. A launcher can:
- sign the player in, for example with a Discord session token, so the client skips its login form and can go straight into the world;
- supply settings: DAT overlays, graphics settings and addons to load;
- receive the settings in effect when the client closes, to store and pass back on the next launch.
All of this goes through one JSON document, the handoff, that the launcher gives the client at start. Secrets in it never touch the command line or disk.
Contents:
- Quick start
- The handoff document
- Delivering the handoff
- Signing in
- Settings
- The exit report
- The control pipe
- Server requirements
- Examples
- Silent install
- Reference
1. Quick start
Start zantetsuken.exe with stdin redirected, write this JSON, close stdin:
{
"v": 1,
"auth": "jwt",
"token": "<session token from your sign-in>",
"lobby_ip": "play.example.net",
"char_name": "Chiisana"
}
The client signs in with the token, loads the character list and enters the world as Chiisana. There are no screens to click through.
To also manage settings, add a settings block and say where the exit report
should go:
{
"v": 1, "auth": "jwt", "token": "...", "lobby_ip": "play.example.net",
"settings": {
"overlays": ["C:/MyServer/DATs/Music"],
"graphics": {"render_scale": 125, "shadows": 3},
"addons": ["targetinfo"],
"kitsuke": true
},
"report": "stdout"
}
When the player quits, the client writes one line to stdout starting
ZAN_REPORT , followed by the settings then in effect. Save that line and
send its settings back on the next launch.
2. The handoff document
The handoff is one JSON object, UTF-8. Unknown keys are ignored, so new optional keys can be added without breaking older launchers.
| Key | Type | Purpose |
|---|---|---|
v |
int | Schema version: 1. |
auth |
string | Sign-in mode: jwt, standard, session or direct. See 4. Optional when token is present (then jwt). |
token / access_token |
string | Session token (jwt mode). |
lobby_ip |
string | Login service host (name or IP). |
char_name / char_id |
string / int | Character to enter the world as. Optional. |
settings |
object | Overlays, graphics and addons. See 5. Optional. |
report |
string | Exit report channel: stdout, pipe or file:<path>. See 6. Optional. |
control |
string | pipe:<name>: a channel your launcher keeps serving. See 7. Optional. |
loader, loader_version, client_version |
string | Login-protocol profile override for servers that pin a loader or client version. Omit unless needed. |
The full list of keys is in the Reference.
3. Delivering the handoff
The client checks these three channels in order and uses the first that delivers a document. With none, it shows its own login form.
3.1 stdin (recommended)
Spawn the client with stdin redirected to a pipe, write the JSON, then close stdin. The client reads until end-of-file, so the handle must be closed or the client waits for it.
3.2 Named pipe: --handoff-pipe <name>
Use this when your launcher can't redirect stdin. Serve the document on a pipe, then start the client with only the pipe name on its command line:
zantetsuken.exe --handoff-pipe mylauncher_9f2c41
The client connects and sends {"v":1,"req":"auth"}\n. Reply with the
handoff on one line ending in \n. The pipe protocol is described in
7. Start serving before starting the client. If the
handoff has no control key, this pipe also becomes the control pipe.
3.3 Environment variable ZAN_HANDOFF
Set ZAN_HANDOFF in the child's environment to the JSON. The client deletes
it from its own environment once read. Other processes running as the same
user can read a process's environment, so prefer stdin or a pipe.
Process notes
- Executable:
zantetsuken.exeon Windows,zantetsukenon Linux. - Working directory: any. An installed copy (
zantetsuken.exewithassets/andshaders/beside it) switches to its own folder at start. - Console: the Windows build is a GUI application with no console window. Redirected stdin and stdout still work.
- Lifetime: your launcher may exit once the client has read the handoff.
Stay running only if you use
report: "stdout"(you must keep reading the pipe),report: "pipe", or token refresh.
4. Signing in
auth |
Required fields | Behaviour |
|---|---|---|
jwt |
token, lobby_ip |
Presents the token to the login service (see 8). For Discord and other web sign-ins. |
standard |
username, password, lobby_ip (+otp) |
Classic username/password login. |
session |
account_id, session_hash (16 bytes), lobby_ip |
Your launcher already completed the auth step. |
direct |
map_ip, map_port, char_id, char_name, zone, session_key (20 bytes) |
Your launcher ran the whole lobby; the client connects straight to the map server. |
Byte fields are JSON arrays of numbers (0–255), not strings.
Instant login
With char_name (case-insensitive) or char_id set, the client enters the
world as that character without showing character select. If the account has
no such character, character select is shown instead.
When sign-in fails
If the server rejects a token and you have a control pipe, the client asks it once for a new token and retries. Otherwise, or if the retry fails, it shows: "The server rejected the launcher's session token (expired?). Sign in again from your launcher."
5. Settings
All of settings is optional. Include only the parts your launcher manages;
for the rest, the client keeps the player's own settings.
"settings": {
"overlays": [
"C:/MyServer/DATs/Music",
{"path": "C:/MyServer/DATs/HD-Textures", "enabled": false}
],
"graphics": {"render_scale": 125, "aa": 3, "shadows": 3, "fullscreen": 1},
"addons": ["targetinfo", "distance"],
"kitsuke": true
}
5.1 overlays: DAT overlays
DAT overlays are folders that shadow files of the FINAL FANTASY XI install (custom maps, music, textures, a server's ROM edits).
- An overlay folder has the install's layout:
ROM/…,ROM2/…,sound/…and so on, orVTABLE.DAT/FTABLE.DATat its top. - Entries are a path string (enabled) or
{"path", "enabled"}. - List order is priority. The first enabled overlay that contains a file serves it.
- The list becomes this server's overlay list (
lobby_ip, ormap_ipindirectmode). It is applied before any game data is read, and the client also saves it as that server's list inUSER/dat_overlays.json. - Folders found in
<install>/overlays/are added after yours, disabled.
5.2 graphics: graphics settings
Any subset of these keys. Omitted keys keep the player's values. Values are clamped to the ranges shown.
| Key | Values | Default |
|---|---|---|
render_scale |
50–200 (% of the window; above 100 supersamples) | 100 |
aa |
0 Off · 1 FXAA · 2 MSAA 2x · 3 MSAA 4x · 4 MSAA 8x | 3 |
aniso |
0 Trilinear · 1 2x · 2 4x · 3 8x · 4 16x | 4 |
shadows |
0 Off · 1 Low · 2 Medium · 3 High · 4 Ultra | 2 |
indoor_shadows |
0/1: scenery shadows in indoor zones | 0 |
bump |
0–500 (% bump-map strength; 100 = retail) | 100 |
ao |
0 Off · 1 Low · 2 Medium · 3 High (ambient occlusion) | 2 |
ao_strength |
0–300 (%) | 100 |
sharpen |
0–100 (%) | 0 |
surface |
0–100 (% fine surface detail) | 50 |
sheen |
0–200 (% specular on bump-mapped surfaces) | 0 |
bloom |
0–200 (%) | 0 |
fade_in |
0/1: characters dissolve in | 1 |
fx_lights |
0/1: light-column effects light their surroundings | 1 |
water |
0 Simple · 1 Enhanced · 2 Reflections | 2 |
tex_lod |
0 Sharpest · 1 Sharper · 2 Default · 3 Softer | 2 |
brightness / contrast |
50–150 (%) | 100 |
saturation |
0–200 (%) | 100 |
draw_dist |
0 Auto · 1 100 · 2 150 · 3 250 · 4 400 yalms | 0 |
fps_cap |
0 Unlimited · 1 30 · 2 60 · 3 90 · 4 120 · 5 144 · 6 165 · 7 240 | 0 |
fullscreen |
0 Windowed · 1 Borderless fullscreen | 0 |
vis_lists |
0 Off · 1 Retail visibility lists | 0 |
fx_bright, zfx_bright, burst_bright, glow_bright, light_bright |
0–200 (% brightness of spell effects, zone effects, magic-burst flare, lamp glow, effect lighting) | 100 |
These keys are the same as in the client's USER/graphics.json and in the
exit report. Your values apply for this session. They are written to the
player's graphics.json only if the player saves the Graphics page in Game
Config.
5.3 addons and kitsuke: addons
addonsis the list of addons to load when the player enters the world. It replaces the player's saved autoload list for this session.[]loads none.- Each name is an addon folder in the player's addon home,
%USERPROFILE%\Games\Zantetsuken\addons(~/Games/Zantetsuken/addonson Linux). Addons shipped with the client are copied there on first run. To ship your own, copy its folder there before starting the client. kitsuke(bool) turns the built-in Kitsuke gear swapper on or off.- Addon settings live in the addon home's
config/folder, which is the addon's own business.
6. The exit report
Set report and, when the player closes the client, it sends the settings in
effect at that moment. The player may have changed them in Game Config or the
Addons window during play.
{
"v": 1,
"event": "exit",
"server": "play.example.net",
"settings": {
"overlays": [{"path": "C:/MyServer/DATs/Music", "enabled": true}],
"graphics": {"render_scale": 125, "aa": 3, "aniso": 4, "shadows": 3, "...": "every key"},
"addons": ["targetinfo"],
"kitsuke": true
}
}
settingshas the same shape as the handoff's, so you can pass it straight back next launch.graphicsalways lists every key.serveris the server whose overlay list is active (""= the default list).addonsis what was loaded at exit, excluding built-ins.
Channels
report |
Delivery |
|---|---|
"stdout" |
One line on the client's stdout: ZAN_REPORT <json>\n. Spawn with stdout redirected and keep reading it to the end. Other lines may be log output; ignore them. |
"pipe" |
Sent over your control pipe (requires control): {"v":1,"req":"report","report":<json>}\n. Reply with any line, e.g. {}\n. |
"file:<path>" |
Written to <path> (to <path>.tmp first, then renamed), so the file is never half-written. Read it after the client process exits. |
The report is sent on a normal close: window close or /shutdown.
A crash or a killed process sends nothing, so keep your last known
settings.
7. The control pipe
A launcher that stays running can serve a control pipe and name it in the
handoff: "control": "pipe:<name>". The same pipe serves --handoff-pipe.
- Windows: named pipe
\\.\pipe\<name>. - Linux / macOS: Unix domain stream socket. The path is
<name>if it contains a/, otherwise$XDG_RUNTIME_DIR/<name>, falling back to/tmp/<name>. Create it with mode0600.
Protocol. One request per connection. The client connects and writes one
JSON line; you reply with one JSON line ending in \n; the connection
closes.
| Request | Reply |
|---|---|
{"v":1,"req":"auth"} |
A handoff document. Used for the initial handoff via --handoff-pipe, and for token refresh, where {"v":1,"token":"<new>"} is enough because the other fields carry over. |
{"v":1,"req":"report","report":{...}} |
Any line ({}). The exit report, when report is "pipe". |
Use a fresh random name per launch, and serve before starting the client.
8. Server requirements
jwt sign-in needs the server's login service to accept a token. The client
connects with TLS to port 54231 and sends:
{"command": 53, "access_token": "<token>", "version": [2, 1, 0]}
On success the server answers {"result": 1, "account_id": <id>, "session_hash": [16 bytes]}.
Any other result is a failure; 20 means a bad token. Everything after
sign-in (character list, character select, map connection) is standard
LandSandBoat on ports 54230 and 54001.
Stock LandSandBoat doesn't have command 53; SanctumXI implements it. Other
servers need that addition, or the launcher can use session or direct
mode.
The login host must resolve to the server itself. A Cloudflare-proxied name only forwards web ports, so the game ports time out.
9. Examples
C#: sign in, settings, exit report over stdout
var psi = new ProcessStartInfo(@"C:\Games\Zantetsuken\zantetsuken.exe") {
UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true,
};
using var p = Process.Start(psi)!;
p.StandardInput.Write(JsonSerializer.Serialize(new {
v = 1, auth = "jwt", token = sessionToken, lobby_ip = "play.example.net",
char_name = character, settings = savedSettings, report = "stdout",
}));
p.StandardInput.Close(); // EOF: the client starts
string? line;
while ((line = p.StandardOutput.ReadLine()) != null)
if (line.StartsWith("ZAN_REPORT "))
savedSettings = JsonDocument.Parse(line[11..]).RootElement.GetProperty("settings");
p.WaitForExit();
Node / Electron: exit report to a file
const { spawn } = require("child_process");
const reportPath = path.join(app.getPath("userData"), "zan_report.json");
const child = spawn(exe, [], { stdio: ["pipe", "ignore", "ignore"] });
child.stdin.end(JSON.stringify({
v: 1, auth: "jwt", token, lobby_ip: "play.example.net",
settings: saved, report: "file:" + reportPath,
}));
child.on("exit", () => {
const rep = JSON.parse(fs.readFileSync(reportPath, "utf8"));
saved = rep.settings;
});
Python: minimal
import json, subprocess
p = subprocess.Popen([exe], stdin=subprocess.PIPE)
p.stdin.write(json.dumps({"v": 1, "auth": "jwt", "token": token,
"lobby_ip": "play.example.net"}).encode())
p.stdin.close()
A complete pipe server with no third-party packages (Windows ctypes, POSIX
socket) is in tools/mock_launcher/launcher.py: copy serve() and
respond().
10. Silent install
A launcher can install and update the client itself, with no windows and no
questions, using the Windows setup file ZantetsukenSetup-<version>.exe. The
setup installs per user and never asks for administrator rights (it runs as
the invoking user), so a launcher can run it directly.
10.1 Command line
ZantetsukenSetup-<version>.exe /S "/D=<install folder>" "/FFXI=<FINAL FANTASY XI folder>"
["/OVERLAY=<folder>"]... ["/SERVER=<lobby host>"]
[/DESKTOP] [/NOREG] [/MATERIALS]
ZantetsukenSetup-<version>.exe /VERSION
| Switch | Meaning |
|---|---|
/S |
Silent: no wizard, no message boxes. Required for everything below except /VERSION. |
/D=<folder> |
Install folder. Default: the folder of the existing install (the InstallLocation it registered), else %LOCALAPPDATA%\Programs\Zantetsuken. |
/FFXI=<folder> |
The FINAL FANTASY XI folder (it must hold VTABLE.DAT and ROM\). Default: the folder the existing install uses, else PlayOnline's registry entry (US, EU, JP), else the stock Program Files (x86) path. |
/OVERLAY=<folder> |
A DAT overlay pack, or a folder of packs, to add (see 11.5). Repeat for several. |
/SERVER=<lobby host> |
Put this run's /OVERLAY packs into that server's overlay list instead of the default list. Use exactly the host you send as lobby_ip. |
/DESKTOP |
Also create a desktop shortcut. |
/NOREG |
No Start-menu shortcuts and no Apps & features entry (a launcher-managed install). |
/MATERIALS |
Also download and install the HQ Materials pack, switched on (see 11.7). Pass it on every install and update: nothing is downloaded when the newest pack is already installed. |
/VERSION |
Print the version this setup file installs to stdout, and exit. Installs nothing. |
Quote any switch whose value has spaces as a whole: "/D=C:\Games\Zantetsuken".
The setup is a GUI-subsystem program. Start it hidden, wait for it to exit,
and check its exit code. To read its messages, redirect stderr (lines start
[setup]).
Don't run it from an MSYS or Git-Bash shell without MSYS_NO_PATHCONV=1.
Those shells rewrite /S-style arguments into paths, and the wizard opens
instead.
10.2 Exit codes
| Code | Meaning |
|---|---|
0 |
Installed or updated. |
1 |
Failed: the FINAL FANTASY XI folder wasn't found, or a file couldn't be written. The reason is on stderr. |
2 |
The setup file is damaged or incomplete: download it again. |
3 |
Zantetsuken is running from the install folder. Nothing was changed: close the client and run the setup again. |
4 |
The client was installed or updated, but the HQ Materials (/MATERIALS) could not be downloaded or installed. The reason is on stderr. The client is ready to start; run the setup again later to retry. |
10.3 What the setup writes
In the install folder:
- the client and its files,
uninstall.exe, andinstall_manifest.txt(every file the setup installed); USER\install.json:{"ffxi": "<FINAL FANTASY XI folder>", "version": "<version>"}. The client reads the FINAL FANTASY XI folder from here;USER\dat_overlays.json, only when/OVERLAYis given (see 11.5);overlays\HQ Materials\, only when/MATERIALSis given (see 11.7).
Unless /NOREG is given, the setup also creates:
- Start-menu shortcuts (Zantetsuken, Uninstall);
- an Apps & features entry under
HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\Zantetsuken(DisplayVersion,InstallLocation,UninstallString).
The setup never touches the player's data:
USER\(settings, HUD layouts, logs) andoverlays\in the install folder;- the addons, Kitsuke profiles and macros under
Games\Zantetsukenin the player's home folder.
10.4 Updating
Run the newer setup with the same /D, or with none: it finds the existing
install. The client must not be running. If it is, the setup exits with 3
and changes nothing.
The setup:
- replaces every file it ships;
- removes files an older version installed that this version no longer ships
(it compares
install_manifest.txt; nothing underUSER\oroverlays\is ever removed); - keeps the FINAL FANTASY XI folder unless you pass a new
/FFXI; - keeps every overlay list as it was, adding only the packs this run's
/OVERLAYswitches name; - updates
USER\install.jsonand the registry version.
To decide whether to update, compare the installed version with the setup's:
- Installed:
"version"in<install>\USER\install.json, orDisplayVersionin the registry key above (not written with/NOREG). An install made by an earlier setup has no"version"; treat it as out of date. - Available:
ZantetsukenSetup-<version>.exe /VERSION(stdout), or the version in the file name.
A typical launcher update step:
if installed_version != available_version:
make sure zantetsuken.exe is not running (ask the player to quit)
run ZantetsukenSetup.exe /S "/D=<install>" /NOREG [/MATERIALS] (hidden, wait)
exit 3 -> client still running: tell the player, retry later
exit 0 or 4 -> start the client as usual (section 1)
10.5 DAT overlays
There are three ways to give the client a server's DAT overlays. For overlays your server requires, use the handoff.
-
The handoff, every launch (recommended).
settings.overlays(5.1) sets this server's list before any game data is read, and the client saves it. Keep your packs in your launcher's own folder and send their paths each launch:- the setup never needs to know about them;
- updates never touch them;
- your list can change without a reinstall.
-
At install, with
/OVERLAY. Each/OVERLAY=<folder>is either a pack or a folder of packs:- A pack mirrors the FINAL FANTASY XI folder:
ROM\,ROM2\… orsound\inside. - In a folder of packs (like XIPivot's
DATsfolder), every subfolder that is a pack is added.
How new packs are merged into the list:
- Packs already listed keep their place and on/off state.
- New packs go to the top of the list, in the order given. The first new pack is enabled; the rest are added disabled.
- Without
/SERVER, they go into the default list. Offline play and the title screen use that list, and it seeds each server's list the first time the player signs in to that server. - With
/SERVER=<lobby host>, they go into that server's list only, so they never follow the player onto another server.
- A pack mirrors the FINAL FANTASY XI folder:
-
Dropped folders. The client finds pack folders placed in
<install>\overlays\when it starts and adds them to the end of the list, disabled. The player turns them on in Game Config > DAT Overlays.
List order is priority: the first enabled overlay that contains a file serves it. The setup doesn't copy overlay folders; the client reads them where they are, so they must stay there.
10.6 Examples
Install for a launcher, with the server's packs in its own list:
ZantetsukenSetup-20261103.exe /S "/D=C:\Users\Ann\AppData\Local\MyServer\Zantetsuken" ^
"/FFXI=D:\Games\FINAL FANTASY XI" "/OVERLAY=C:\Users\Ann\AppData\Local\MyServer\DATs" ^
/SERVER=play.example.net /NOREG
C#: update, then check the result:
var psi = new ProcessStartInfo(setupPath, $"/S \"/D={installDir}\" /NOREG") {
UseShellExecute = false, CreateNoWindow = true, RedirectStandardError = true };
using var p = Process.Start(psi)!;
string log = p.StandardError.ReadToEnd();
p.WaitForExit();
switch (p.ExitCode) {
case 0: break; // up to date: launch
case 3: ShowMessage("Close Zantetsuken first."); break;
default: ShowMessage("Update failed:\n" + log); break;
}
Silent uninstall (the player's USER\ folder is kept):
"<install>\uninstall.exe" /uninstall "<install>" /S
10.7 HQ Materials
The HQ Materials are an optional pack of high-detail replacement surfaces for
the game world. They are a large download (about 170 MB), so they are
published apart from the client: as ZantetsukenMaterialsSetup-<version>.exe
on this repository's releases, under a tag that starts with PBR. The file is
published in parts of at most 90 MB (….exe.001, ….exe.002, …); joined in
order they are the setup file (copy /b X.exe.001+X.exe.002 X.exe).
With the client setup. Add /MATERIALS to the silent install
(11.1). After installing the client, the setup:
- reads this repository's release list and takes the newest release whose tag
starts with
PBRand that carries aZantetsukenMaterialsSetup-*.exe, whole or in parts; - compares that file's name (without a part number) with
<install>\overlays\HQ Materials\version.txt. If they match, the pack is current and nothing is downloaded; - otherwise downloads the file to
%TEMP%(the parts in order, joined into one file), runs it silently against the install folder, and deletes it.
A failure in any of these steps leaves the client installed and ends with
exit code 4. The wizard has the same option as a check box on its last page.
On its own. A launcher that would rather download the pack itself, or a player updating only the materials, runs the materials setup directly:
ZantetsukenMaterialsSetup-<version>.exe /S "/D=<Zantetsuken install folder>"
ZantetsukenMaterialsSetup-<version>.exe /REMOVE /S "/D=<Zantetsuken install folder>"
ZantetsukenMaterialsSetup-<version>.exe /VERSION
| Switch | Meaning |
|---|---|
/S |
Silent: no windows. Without it the setup finds Zantetsuken, asks to confirm and shows progress. |
/D=<folder> |
The Zantetsuken install folder (it must hold zantetsuken.exe). Default: the registered install. |
/REMOVE |
Take the pack out again. |
/VERSION |
Print the pack version to stdout, and exit. |
Exit codes: 0 done, 1 failed (reason on stderr, lines start [materials]),
2 damaged setup file. The client may be running; it picks the pack up at its
next start.
What it writes. Everything goes into <install>\overlays\HQ Materials\,
a DAT overlay folder like any other (11.5):
- the pack (
zan_materials\...); version.txt: the release file the pack came from;materials_manifest.txt: every file written, so an update removes what a newer pack no longer ships;zan_overlay.json:{"enabled": true}.
Switched on automatically. The client adds folders it finds in
<install>\overlays\ to the end of the active overlay list. A folder with a
zan_overlay.json holding "enabled": true is added switched on; any other is
added switched off. This happens once, when the folder is first seen for a
list, so a player who turns the materials off in Game Config > DAT Overlays
keeps them off through later updates. It also holds when your launcher sends
its own settings.overlays (5.1): the materials
are appended after your list. To control them yourself, include the folder in
your list with the enabled you want.
The client setup's uninstaller leaves overlays\ in place; use /REMOVE to
take the materials out.
11. Reference
All handoff keys
| Key | Type | Mode / use |
|---|---|---|
v |
int | always (1) |
auth |
string | jwt · standard · session · direct |
token, access_token |
string | jwt |
username, password, otp |
string | standard |
account_id |
int | session |
session_hash |
16 numbers | session |
lobby_ip |
string | jwt, standard, session |
map_ip, map_port, zone |
string, int, int | direct |
session_key |
20 numbers | direct |
char_id, char_name |
int, string | direct (required); others (instant login) |
settings |
object | overlays, graphics, addons, kitsuke |
report |
string | stdout · pipe · file:<path> |
control |
string | pipe:<name> |
loader, loader_version, client_version |
string | login-protocol profile override |
Security
- Secrets (tokens, passwords, keys) never go on the command line; only the pipe name may.
- Use a random pipe name per launch. On Linux and macOS, create the socket
0600. - Don't write a handoff to disk. The exit report holds no secrets.
- Zantetsuken never logs the token.