Skip to content

Commit

Permalink
Xcode 15b6 / Steamworks 1.57 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfairh committed Aug 15, 2023
1 parent f57e115 commit e638a67
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 13 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on:
push:
branches: [main]
pull_request:
branches: ['*']

jobs:
macos:
name: build
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.app/Contents/Developer

steps:
- name: Checkout steamworks SDK
uses: actions/checkout@v3
with:
repository: johnfairh/steamworks-swift-sdk
path: steamworks-sdk

- name: Checkout spacewar
uses: actions/checkout@v3
with:
path: spacewar

- name: Build
run: |
cd steamworks-sdk && make install && cd ..
cd spacewar && swift build
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/johnfairh/steamworks-swift",
"state" : {
"revision" : "d65d442139b042ce1172de95b915e9974c7d7fa7",
"version" : "0.3.0"
"revision" : "a127c38e25b1222d945c77a358638c4eea882e0e",
"version" : "0.4.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
}
},
{
"identity" : "tmlengines",
"kind" : "remoteSourceControl",
"location" : "https://github.com/johnfairh/TMLEngines",
"state" : {
"revision" : "51a2ff3056ff60d3ebc6df1f3d8504d02b7c8ef3",
"version" : "1.3.0"
"revision" : "6ba327419697ce9e150f6c782a59fa7b4ea89124",
"version" : "1.3.1"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/johnfairh/steamworks-swift",
from: "0.3.0"),
from: "0.4.0"),
.package(url: "https://github.com/johnfairh/TMLEngines",
from: "1.2.0")
],
Expand Down
2 changes: 1 addition & 1 deletion Sources/SpaceWar/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Dispatch
struct SpaceWarApp: App {
init() {
// Some nonsense to simulate a library that probably doesn't exist
Steamworks_InstallCEGHooks(initCEG: Steamworks_InitCEGLibrary, termCEG: Steamworks_TermCEGLibrary)
SteamAPI.installCEGHooks(initCEG: Steamworks_InitCEGLibrary, termCEG: Steamworks_TermCEGLibrary)

#if SWIFT_PACKAGE
// Some nonsense to make the app work properly when built outside of Xcode.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SpaceWar/Controller.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ final class Controller {
// MARK: Effects

/// Set the LED color on the controller, if supported by controller
func setColor(_ color: Color2D, flags: SteamControllerLEDFlag) {
func setColor(_ color: Color2D, flags: SteamInputLEDFlag) {
let channels = color.integerChannels
steam.input.setLEDColor(handle: activeControllerHandle,
colorR: UInt8(channels.r),
Expand Down
20 changes: 16 additions & 4 deletions Sources/SpaceWar/SpaceWarClientConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ final class SpaceWarClientConnection {
private(set) var connectionError: String?
/// The net connection for the current connection/attempted connection, or nil if none
private(set) var netConnection: HSteamNetConnection?
/// The Steam ID of the game server, or nil if not connected/don't know yet
/// The server steam ID we've been asked to connect to
private(set) var serverSteamIDFromBrowser: SteamID?
/// The actual Steam ID of the game server, or nil if not connected/don't know yet
private(set) var serverSteamID: SteamID?
/// The name of the server, if known
private(set) var serverName: String?
Expand All @@ -102,8 +104,9 @@ final class SpaceWarClientConnection {
precondition(state == .notConnected || state == .pingingServer, "Server connection already busy: \(state)")
OutputDebugString("ClientConnection \(state) -> connectingP2P")
state = .connectingP2P
serverSteamID = steamID

serverSteamIDFromBrowser = steamID // save this, what we connected to
serverSteamID = steamID // for now, may overwrite in a response

if !FAKE_NET_USE {
let identity = SteamNetworkingIdentity(steamID)
netConnection = steam.networkingSockets.connectP2P(identityRemote: identity, remoteVirtualPort: 0, options: [])
Expand Down Expand Up @@ -308,7 +311,16 @@ final class SpaceWarClientConnection {
// this lets our friends connect to this game via their friends list
updateRichPresence()

let authStatus = steam.user.getAuthSessionTicket()
// if the server Steam ID was aquired from another source ( m_steamIDGameServerFromBrowser )
// then use it as the identity
// if it only came from the server itself, then use the IP address
let identity: SteamNetworkingIdentity
if serverSteamID == serverSteamIDFromBrowser {
identity = .init(serverSteamID!)
} else {
identity = .init(SteamNetworkingIPAddr(ipv4: serverIP!, port: serverPort!))
}
let authStatus = steam.user.getAuthSessionTicket(steamNetworkingIdentity: identity)
if authStatus.ticketSize < 1 {
OutputDebugString("Warning: Looks like GetAuthSessionTicket didn't give us a good ticket")
}
Expand Down

0 comments on commit e638a67

Please sign in to comment.