# Host Network Lifecycle

This note documents the high-level split between dedicated-server lifecycle code and P2P/listen-host recovery code.

## Ownership

- `Code/Game/Host/Network/GameNetworkManager.cs`
  - Core connection flow: lobby creation, connection acceptance, active joins, disconnect cleanup, and network membership diagnostics.
- `Code/Game/Host/Network/GameNetworkManager.Dedicated.cs`
  - Dedicated-server-only lifecycle behavior.
  - Starts the configured `server_settings.json` `StartupMap` through the normal map-change pipeline when the native launch map is empty.
  - Owns the empty-server baseline reset controlled by `t.dedicated.empty_reset` and `t.dedicated.empty_reset.delay`.
  - Resets to `ServerLaunchContext.BootMapIdent`, not the mutable `LaunchArguments.Map` value used during live map travel.
  - This path is hard-gated by `Application.IsDedicatedServer`.
- `Code/Game/Host/Session/ServerLaunchContext.cs`
  - Captures immutable boot game/map identity and tracks the currently active map.
  - Keeps dedicated empty reset, map voting, and native map advertisement from confusing the boot baseline with the latest map switch.
- `Code/Game/Host/Session/ServerAdvertisedMetadata.cs`
  - Owns the small advertised metadata surface TTT still touches.
  - Dedicated servers update native `mapident` after a map is joinable; rich operator config belongs in `server_settings.json`, not Steam tags.
  - P2P/listen hosts may publish the compact `ttt` settings payload because they do not have the dedicated-server JSON config path.
- `Code/Game/Host/Session/ServerSettingsStore.cs`
  - Dedicated-server operator settings loaded from `FileSystem.Data/server_settings.json`.
  - Use this for configuration that can grow over time, such as lobby settings, long map lists, and bootstrap admin Steam IDs.
  - Missing config writes `server_settings.example.json`, logs a dedicated-server warning, and keeps scene defaults until an active `server_settings.json` exists.
  - Set `t.dedicated.require_server_settings 1` to fail closed instead.
  - Run `ttt_write_server_settings_example` from the server console to regenerate the example template.
- `Code/Game/Host/Recovery/GameMode.P2PHostRecovery.cs`
  - P2P/listen-host migration recovery.
  - Handles `OnBecameHost` and host-departure recovery after the lobby host changes.
  - This path explicitly ignores dedicated servers.
- `Code/Game/Round/Transitions/TransitionOrchestrator.cs`
  - Shared transition coordination.
  - Dedicated and P2P code may ask it to complete or cancel map-switch context, but the decision to run a lifecycle path stays in the host lifecycle owner above.

## Rule of Thumb

Dedicated servers have a stable server host and should not run P2P host migration recovery. P2P/listen hosts should not run dedicated empty-server baseline reset logic.

Keep those decisions close to the owning lifecycle file. Use `GameUtils` for executing map changes, not for deciding why a host lifecycle path should run.

Steam advertised metadata is a discovery surface, not the source of truth for all settings. Keep it compact enough for the Steam tag limit, let native fields carry server name/map identity where possible, and load detailed dedicated-server configuration from `ServerSettingsStore`.

See `dedicated-server-settings.md` for the full operator-facing config reference.
