0xDocs 0x.limo

Docs / Steamworks compatibility

Steamworks compatibility

Partly live

How games built with the Steamworks SDK run on 0x unmodified through sg-steamclient, a drop-in steamclient library backed by the 0x platform.

Games built with the Steamworks SDK can run on 0x without changing the game or its libsteam_api. 0x provides sg-steamclient, a drop-in replacement for the steamclient library that libsteam_api loads at start-up. Every Steamworks call the game makes lands in sg-steamclient, which serves it from the 0x platform (accounts, ownership, stats, achievements, leaderboards, cloud saves, Workshop, inventory, lobbies, game servers, networking) at https://api.0x.limo.

Not in the 0x app download yet

sg-steamclient is built and tested (see what is tested), but the 0x app download (version 0.1.0, Linux and Windows) does not ship it yet, and the app does not yet start Steamworks games for you. This section documents how the layer works and what it supports, so you can plan a release. The step-by-step guide shows the process layout the app will set up.

#How it works

A Steamworks game never talks to a Steam service itself. Its copy of libsteam_api:

  1. loads the client library from a fixed place: ~/.steam/sdk64/steamclient.so on Linux (a dedicated server first tries a steamclient.so next to its binary), or the steamclient64.dll the Steam client registers on Windows;
  2. asks it for ISteamClient (CreateInterface("SteamClient0NN"));
  3. fetches every other interface through ISteamClient::GetISteamGenericInterface;
  4. pumps callbacks through three plain C exports.

sg-steamclient implements that boundary. It exports the same entry points (CreateInterface, Steam_BGetCallback, Steam_FreeLastCallback, Steam_GetAPICallResult, Steam_IsKnownInterface, Steam_NotifyMissingInterface, Steam_ReleaseThreadLocalMemory) and constructs 249 interface versions: the 31 current ones and 218 historical ones, so games built against SDK generations from 0.99 up to the current release find the exact versions they were compiled against. See the interface list.

#What happens at SteamAPI_Init

StepWhat sg-steamclient does
Version checklibsteam_api asks Steam_IsKnownInterface for every interface version the game was compiled against. Each of the 249 versions answers yes; an unknown one fails init cleanly with k_ESteamAPIInitResult_VersionMismatch, as on Steam.
App IDThe client must know the app ID before the game says it. sg-steamclient reads SteamAppId from the environment, then steam_appid.txt in the working directory, the same sources a developer uses. libsteam_api then reads it back with ISteamUtils::GetAppID().
Sign-inConnectToGlobalUser loads the session: the signed-in 0x account (/v1/me), the app's schema and your ownership of it, your stats, and a cloud sync-down. The token comes from the 0x app (see environment); the game never handles it.
Stats readyUserStatsReceived_t is posted after the session loads, as current Steam clients do.
CallbacksCallbacks and call results are queued and delivered from SteamAPI_RunCallbacks, converted to the struct layout of the SDK the game was built with.
ShutdownWrites (stats, cloud saves) go through one ordered worker thread; shutdown waits up to 10 seconds so they are flushed before the process exits.

Your 0x account appears to the game as a 64-bit SteamID, and your display name as the persona name.

#App IDs

Each game on 0x has a numeric app ID. sg-steamclient uses it for ownership, stats, cloud saves, lobbies and everything else that is per game. The process that starts your game sets SteamAppId to your 0x app ID. The environment variable wins over a steam_appid.txt you ship for local testing. SteamAPI_RestartAppIfNecessary returns false when SteamAppId or steam_appid.txt is present, so the game does not try to relaunch itself through a Steam client.

#Platforms

PlatformLibraryStatus
Linux x86_64steamclient.so (64-bit)Built and tested with real games
Windows games under Proton or Winethe Linux steamclient.so, reached through Proton's bridgeTested with real games
Windows x86_64, nativesteamclient64.dll from the same source: MSVC vtable order, Windows struct packing and callback layoutsTested with one real game; newer
32-bit Windows (steamclient.dll), macOS—Not built

#In this section