Rocket Foundry dedicated server
===============================

Hosts a multiplayer world without playing in it. Players join it from the
game with the room code the server prints. No game install, graphics card
or display is needed.

Start a new world and open a room:

    ./RocketFoundry.Server --save "My World" --new --room

The server prints "Room code: XXXXXX". Players open MULTIPLAYER, JOIN,
and enter that code. Run the same command later without --new to host the
saved world again: --new always starts over, keeping a copy of the old
world in saves-backup/ in the data root. Use --create instead to host the
saved world and only create it the first time.

If a server update can no longer resume the exact multiplayer session a
world was saved with, the server hosts the saved world without it and says
so. A world it cannot read at all is replaced by a new one. Either way the
original save is kept in saves-backup/.

Options:

    --save NAME        world to host (required)
    --create           create the world if it does not exist yet
    --new              start a new world (an existing one goes to saves-backup/)
    --room             open a room players can join with a code
    --port N           also accept direct connections on this port (default 8801)
    --name NAME        host name shown to players (default Server)
    --data-root PATH   where saves live (default ~/rocketfoundry-server)
    --allow-teleport   players may teleport
    --allow-drills     players may drill into terrain
    --allow-bombs      players may detonate bombs
    --no-takeover      players may not take over craft others left behind
    --cheat NAME       turn a cheat on for every player (repeatable); NAME is
                       fuel, oxygen, indestructible, nogravity, noheat or noscorch
    --everyone-cohost  every player who joins becomes a co-host

Check a machine before hosting on it:

    ./RocketFoundry.Server --connection-test

It measures the network, the relay, direct connections and the hosting speed,
prints a report and exits (exit code 1 when a step fails). Add --json for a
machine-readable report and --show-addresses to keep IP addresses in it.

Rules you leave out keep whatever the world was saved with. The
matching --no-teleport, --no-drills, --no-bombs, --allow-takeover and
--no-everyone-cohost turn a saved rule back, and --no-cheat NAME turns a
saved cheat off.

Players need the same game version as the server. Download a new server
with every game update.

Time warp
---------
The server always runs at real time, so one player's warp never slows or
speeds up anyone else. A player who warps goes out of sync: their craft run
on their own machine and the others see them as see-through ghosts. They
press SYNC to bring their craft back to the server's time, keeping their
orbit around the body they are near. A player who disconnects while out of
sync is synced automatically.

Co-hosts
--------

Nobody plays on the server itself, so the first player ever to join it
becomes its owner: a co-host who can kick, freeze, set the rules, clear
debris and name other co-hosts from the pause menu. The owner stays a
co-host every time they come back, recognised by their community identity
(or by name if they joined without one). Co-hosts are kept in
multiplayer_cohosts.json in the data root; delete it to pick a new owner.
With --everyone-cohost (saved with the world) every player who joins is
a co-host for that visit; a co-host can switch it from the pause menu.

While the server runs, type:

    players            who is connected
    cohost NAME        make a connected player a co-host
    uncohost NAME      take it back (the owner stays)
    cohosts            list co-hosts
    teleport on|off    let players teleport
    drills on|off      let players use drills
    bombs on|off       let players use bombs
    cheats             show which cheats are on
    cheat NAME on|off  switch a cheat for every player
    everyone-cohost on|off  make every joining player a co-host
    say TEXT           send a chat line to everyone as the server
    kick NAME / ban NAME / unban NAME / bans
    save / stop

Keeping it running
------------------

In a terminal session that survives logout:

    tmux new -s rocketfoundry './RocketFoundry.Server --save "My World" --create --room'

Or as a systemd service (edit the paths and user):

    [Unit]
    Description=Rocket Foundry dedicated server
    After=network-online.target

    [Service]
    User=YOUR_USER
    WorkingDirectory=/home/YOUR_USER/RocketFoundry-Server-linux-x64
    ExecStart=/home/YOUR_USER/RocketFoundry-Server-linux-x64/RocketFoundry.Server --save "My World" --create --room
    Restart=on-failure

    [Install]
    WantedBy=multi-user.target

Stop the server with Ctrl-C (or systemctl stop). It saves the world before
it exits.

If the server runs into a bug it keeps the world running, prints the details
here and shows players a "Server error, please report it" message. Please send
those details with your report.

If the world's simulation stops for good (it could not recover from an error),
the server prints "WORLD STOPPED", tells the players, and about 10 seconds
later exits with code 3 without overwriting the last good save. Run it under
systemd (Restart=on-failure) or a restart loop so it comes back from that save
on its own.

Each start keeps a copy of the world in saves-backup/ named
"<world>.start-<time>.json" (not when the world is unchanged since the last
one). The newest 10 are kept, plus the last one of each day for a week. Copies
of a world that was reset or replaced by --new are never deleted.
