# 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.
  - Uses `server_settings.json` `StartupMap` as the dedicated baseline/reset map. It can bootstrap to that map if native launch context is missing, but normal dedicated launch should still provide `+game <game> <map>`.
  - 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 and map voting 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 rely on native s&box discovery fields for game, map, and server name; rich operator config belongs in `server_settings.json`, not Steam tags.
  - P2P/listen hosts may publish tiny compatibility metadata when native lobby fields are insufficient.
- `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 active defaults to `server_settings.json`, logs a dedicated-server warning, and uses those defaults immediately.
  - Invalid config logs an error and falls back to scene/prefab defaults for settings that could not be loaded.
- `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, and load detailed dedicated-server configuration from `ServerSettingsStore`.

See `dedicated-server-settings.md` for the full operator-facing config reference.
