Table of Contents

Class HostWorlds

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll

Starts and restarts a hosted world on a game client at its menu, with cli_start_host_world. The host is the server of its world (Server true, not dedicated) and has a local player.

public static class HostWorlds
Inheritance
object
HostWorlds

Methods

Restart(GameActor, ClientRunPlan, string, TimeSpan, CancellationToken, bool)

Leaves the hosted world (the host saves it on the way out), re-pins the client at its menu and starts the same world again (Start(GameActor, ClientRunPlan, string, TimeSpan, CancellationToken, bool)): the host's restart. Confirm a save first (Save(string, TimeSpan)) when the check is about persistence.

public static SessionState Restart(GameActor host, ClientRunPlan plan, string worldName, TimeSpan timeout, CancellationToken cancellation = default, bool protectPlayer = true)

Parameters

host GameActor
plan ClientRunPlan
worldName string
timeout TimeSpan
cancellation CancellationToken
protectPlayer bool

Returns

SessionState

Start(GameActor, ClientRunPlan, string, TimeSpan, CancellationToken, bool)

From the client's idle main menu: turns devcommands on (ValheimCLI refuses its save and leave, mutating extension commands, without them), selects the plan's character (cli_select_character), then starts worldName once with cli_start_host_world <name> --public false --crossplay true|false and requires the reply to confirm the world, open=true, public=False, the planned crossplay flag and backend, and no password. The command only starts the world, so this re-pins the client at once with its menu pins, waits for the plan's world UID to be ready (a missing fixture would be created fresh, with another UID, and fail here), verifies the world pins, then waits for the host's player and protects it unless protectPlayer is false (WaitForWorld(string, TimeSpan, CancellationToken, bool)). When the world loads between two reads, the strict menu pins refuse it ("loaded but not listed"); the exact world pins are then checked at once, and a world with another UID fails as the wrong world rather than as a load failure. The whole start is bounded by timeout.

public static SessionState Start(GameActor host, ClientRunPlan plan, string worldName, TimeSpan timeout, CancellationToken cancellation = default, bool protectPlayer = true)

Parameters

host GameActor
plan ClientRunPlan
worldName string
timeout TimeSpan
cancellation CancellationToken
protectPlayer bool

Returns

SessionState