Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ target_include_directories(SteamAPIBridge PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/in
set_target_properties(SteamAPIBridge PROPERTIES DEBUG_POSTFIX "")
if(MSVC)
target_compile_definitions(SteamAPIBridge PRIVATE STEAMAPIBRIDGE_EXPORTS WIN32_LEAN_AND_MEAN NOMINMAX _CRT_SECURE_NO_WARNINGS)
target_compile_options(SteamAPIBridge PRIVATE /W4 /permissive- /Zi)
# The bridge catches exceptions at the C boundary, also when a parent project drops /EHsc from its flags.
target_compile_options(SteamAPIBridge PRIVATE /W4 /permissive- /Zi /EHsc)
target_link_options(SteamAPIBridge PRIVATE /DEBUG)
else()
target_compile_definitions(SteamAPIBridge PRIVATE STEAMAPIBRIDGE_EXPORTS)
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,17 @@ only uses the game server functions.
are bridge handles; a session's shutdown destroys the ports it still holds. Received
datagrams are copied out and released inside the bridge; one that does not fit, or does
not come from an IP address, is dropped and described.
* Server browsing (client, MatchMakingServers003): Internet, LAN, friends, favorites,
history and spectator server lists with key/value filters, server details, refresh and
cancellation, and ping and player queries. List requests are bridge handles and queries
bridge numbers; their answers reach the callback given to the request, copied out of
`gameserveritem_t`. A request released, or a query cancelled, from a callback answers no
more at once, and Steam releases or cancels it after the dispatcher returns. Client
shutdown releases and cancels the rest. Favorites and history (MatchMaking009): count,
add and remove. Friends018: a friend's persona name and game; Apps009: VAC ban status.
* Events: ClientGameServerDeny, GameServerChangeRequested and GameOverlayActivated
reach the client callback during `SteamBridge_HostRunCallbacks`; SteamServersConnected,
reach the client callback during `SteamBridge_HostRunCallbacks`, and FavoritesListChanged
and PersonaStateChange the separate matchmaking callback; SteamServersConnected,
SteamServerConnectFailure, GSPolicyResponse, GSClientApprove/Deny/Kick and
SteamNetworkingFakeIPResult reach the server callback during
`SteamBridge_ServerRunCallbacks`. Fields are copied out of
Expand Down Expand Up @@ -137,7 +146,10 @@ capture/decoding and non-OK voice results, client and game server event translat
and dispatcher separation, deferred shutdown from callbacks, game server setters and
authentication, packets, dedicated (server-only) sessions, and FakeIP ports: datagram
send results, delivery and dropping, cleanup, session-owned port destruction, the game
server's FakeIP request and result event, and diagnostics forwarding. On Windows it also
server's FakeIP request and result event, diagnostics forwarding, and server browsing:
list kinds and filters, details, refresh and cancellation calls, list, ping and player
answers, deferred release and cancellation from callbacks, release and cancellation at
shutdown, favorites, friends, VAC status and the matchmaking events. On Windows it also
covers plugin mode: absent/uninitialized Steam, legacy (x86) and intermediate-modern
exports, exact-version availability and retry, SteamID/screenshots, cookie/certificate
forwarding, stream events, context isolation, cancellation and reentrant destruction.
Expand Down
149 changes: 149 additions & 0 deletions include/SteamAPIBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,155 @@ extern "C"
// values). The callback may run on any thread; NULL stops forwarding.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_NetworkingSetDebugOutput(int32_t level, SteamBridgeNetworkingDebugCallback callback);

// Server browsing (ISteamMatchmakingServers), host mode with an initialized client. IPv4
// addresses and ports are in host byte order, as Steam reports them. A list request or a
// server query answers through its callback, synchronously during SteamBridge_HostRunCallbacks;
// Steam may also answer before the call that started it returns. Shutting the client down
// releases the remaining requests and queries and invalidates their handles.
typedef struct SteamBridgeServerList* SteamBridgeServerListHandle;
enum
{
SB_SERVER_LIST_INTERNET = 0,
SB_SERVER_LIST_LAN = 1,
SB_SERVER_LIST_FRIENDS = 2,
SB_SERVER_LIST_FAVORITES = 3,
SB_SERVER_LIST_HISTORY = 4,
SB_SERVER_LIST_SPECTATOR = 5
};
enum
{
SB_SERVERS_LIST_RESPONDED = 1,
SB_SERVERS_LIST_FAILED = 2,
SB_SERVERS_LIST_COMPLETE = 3,
SB_SERVERS_PING_RESPONDED = 4,
SB_SERVERS_PING_FAILED = 5,
SB_SERVERS_PLAYER = 6,
SB_SERVERS_PLAYERS_FAILED = 7,
SB_SERVERS_PLAYERS_COMPLETE = 8
};
// The string sizes of Steam's gameserveritem_t, and the player name capacity.
enum
{
SB_SERVER_NAME_BYTES = 64,
SB_SERVER_GAME_DIR_BYTES = 32,
SB_SERVER_MAP_BYTES = 32,
SB_SERVER_DESCRIPTION_BYTES = 64,
SB_SERVER_TAGS_BYTES = 128,
SB_SERVER_PLAYER_BYTES = 128
};
// A copy of Steam's gameserveritem_t. players includes bots; timeLastPlayed is the Unix time
// of the last visit for favorite and history servers.
typedef struct SteamBridgeServerItem
{
uint32_t ip;
uint16_t queryPort;
uint16_t connectionPort;
int32_t ping;
uint32_t hadSuccessfulResponse;
uint32_t doNotRefresh;
uint32_t appID;
int32_t players;
int32_t maxPlayers;
int32_t botPlayers;
uint32_t password;
uint32_t secure;
uint32_t timeLastPlayed;
int32_t serverVersion;
uint64_t steamID;
char name[SB_SERVER_NAME_BYTES];
char gameDir[SB_SERVER_GAME_DIR_BYTES];
char map[SB_SERVER_MAP_BYTES];
char description[SB_SERVER_DESCRIPTION_BYTES];
char tags[SB_SERVER_TAGS_BYTES];
} SteamBridgeServerItem;
// kind is an SB_SERVERS_* value. List events set request and index, and SB_SERVERS_LIST_COMPLETE
// sets response (EMatchMakingServerResponse). Server query events set query; SB_SERVERS_PING_RESPONDED
// sets server, and SB_SERVERS_PLAYER sets player, score and seconds (time on the server).
typedef struct SteamBridgeServersEvent
{
uint32_t kind;
SteamBridgeServerListHandle request;
uint32_t query;
int32_t index;
int32_t response;
int32_t score;
float seconds;
char player[SB_SERVER_PLAYER_BYTES];
SteamBridgeServerItem server;
} SteamBridgeServersEvent;
typedef void(STEAMBRIDGE_CALL* SteamBridgeServersCallback)(void*, const SteamBridgeServersEvent*);
// A MatchMakingKeyValuePair_t filter; the strings are copied, truncated to 255 bytes.
typedef struct SteamBridgeServerFilter
{
const char* key;
const char* value;
} SteamBridgeServerFilter;

// kind is an SB_SERVER_LIST_* value; LAN lists ignore filters. The request answers until it is released.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersRequestList(int32_t kind, uint32_t appID, const SteamBridgeServerFilter* filters, uint32_t filterCount, SteamBridgeServersCallback callback, void* user, SteamBridgeServerListHandle* request);
// Stops the request's events at once. Called from a callback, Steam releases it after the dispatcher returns.
STEAMBRIDGE_API void STEAMBRIDGE_CALL SteamBridge_ServersReleaseRequest(SteamBridgeServerListHandle request);
// SB_FAILED: Steam has no server at index.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersGetDetails(SteamBridgeServerListHandle request, int32_t index, SteamBridgeServerItem* server);
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersCancelQuery(SteamBridgeServerListHandle request);
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersRefreshQuery(SteamBridgeServerListHandle request);
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersRefreshServer(SteamBridgeServerListHandle request, int32_t index);
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersIsRefreshing(SteamBridgeServerListHandle request, uint32_t* refreshing);
// Server queries. *query identifies the query in its events and is never zero. A ping ends with
// SB_SERVERS_PING_RESPONDED or SB_SERVERS_PING_FAILED, a player query with
// SB_SERVERS_PLAYERS_COMPLETE or SB_SERVERS_PLAYERS_FAILED after its SB_SERVERS_PLAYER events.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersPing(uint32_t ip, uint16_t port, SteamBridgeServersCallback callback, void* user, uint32_t* query);
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_ServersPlayerDetails(uint32_t ip, uint16_t port, SteamBridgeServersCallback callback, void* user, uint32_t* query);
// Stops the query's events at once; ignores a query that has ended. Called from a callback,
// Steam cancels it after the dispatcher returns.
STEAMBRIDGE_API void STEAMBRIDGE_CALL SteamBridge_ServersCancelServerQuery(uint32_t query);

// Favorite and history servers (ISteamMatchmaking). flags are Steam k_unFavoriteFlag* values;
// lastPlayed is a Unix time.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_MatchmakingGetFavoriteCount(uint32_t* count);
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_MatchmakingAddFavorite(uint32_t appID, uint32_t ip, uint16_t connectionPort, uint16_t queryPort, uint32_t flags, uint32_t lastPlayed);
// SB_FAILED: no such entry.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_MatchmakingRemoveFavorite(uint32_t appID, uint32_t ip, uint16_t connectionPort, uint16_t queryPort, uint32_t flags);
enum
{
SB_MATCHMAKING_FAVORITES_CHANGED = 1,
SB_MATCHMAKING_PERSONA_CHANGE = 2
};
// The favorites fields copy FavoritesListChanged_t (an ip of zero means the whole list changed);
// steamID and changeFlags (EPersonaChange) copy PersonaStateChange_t.
typedef struct SteamBridgeMatchmakingEvent
{
uint32_t kind;
uint32_t ip;
uint32_t queryPort;
uint32_t connectionPort;
uint32_t appID;
uint32_t flags;
uint32_t add;
uint32_t accountID;
uint64_t steamID;
int32_t changeFlags;
} SteamBridgeMatchmakingEvent;
typedef void(STEAMBRIDGE_CALL* SteamBridgeMatchmakingCallback)(void*, const SteamBridgeMatchmakingEvent*);
// A separate slot from the client callback, so another module of the host can own it; events
// arrive synchronously during SteamBridge_HostRunCallbacks.
STEAMBRIDGE_API void STEAMBRIDGE_CALL SteamBridge_HostSetMatchmakingCallback(SteamBridgeMatchmakingCallback callback, void* user);

// Friends (ISteamFriends) and VAC status. gameID is Steam's CGameID.
typedef struct SteamBridgeFriendGame
{
uint64_t gameID;
uint32_t ip;
uint16_t gamePort;
uint16_t queryPort;
uint64_t lobbySteamID;
} SteamBridgeFriendGame;
// Copies the friend's persona name, truncated and NUL-terminated.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_FriendsGetPersonaName(uint64_t steamID, char* name, uint32_t capacity);
// SB_FAILED: the friend is not in a game.
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_FriendsGetGamePlayed(uint64_t steamID, SteamBridgeFriendGame* game);
STEAMBRIDGE_API SteamBridgeStatus STEAMBRIDGE_CALL SteamBridge_AppsIsVACBanned(uint32_t* banned);

#ifdef __cplusplus
}
#endif
Loading
Loading