Skip to content

Commit

Permalink
latest Steam API doesn't seem to have Init(), it has InitSafe() inste…
Browse files Browse the repository at this point in the history
…ad (hajimehoshi#6)

Latest Steam API doesn't seem to have Init(), it has InitSafe() instead. So call the new function, and still fallback to the old if that is unavailable or fails.
  • Loading branch information
corfe83 authored Oct 28, 2023
1 parent 103842c commit 85388dd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"os"
)

const version = "155"
const version = "158a"

func main() {
if err := run(); err != nil {
Expand Down
Binary file modified libsteam_api.dylib
Binary file not shown.
Binary file modified libsteam_api.so
Binary file not shown.
Binary file modified libsteam_api64.so
Binary file not shown.
1 change: 1 addition & 0 deletions steamworks.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type ISteamFriends interface {
const (
flatAPI_RestartAppIfNecessary = "SteamAPI_RestartAppIfNecessary"
flatAPI_Init = "SteamAPI_Init"
flatAPI_InitSafe = "SteamAPI_InitSafe"
flatAPI_RunCallbacks = "SteamAPI_RunCallbacks"

flatAPI_SteamApps = "SteamAPI_SteamApps_v008"
Expand Down
8 changes: 6 additions & 2 deletions steamworks_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,13 @@ func RestartAppIfNecessary(appID uint32) bool {
}

func Init() bool {
v, err := theLib.call(funcType_Bool, flatAPI_Init)
v, err := theLib.call(funcType_Bool, flatAPI_InitSafe)
if err != nil {
panic(err)
// If InitSafe() doesn't work for some reason, fallback to Init()
v, err = theLib.call(funcType_Bool, flatAPI_Init)
if err != nil {
panic(err)
}
}
return byte(v) != 0
}
Expand Down
8 changes: 6 additions & 2 deletions steamworks_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ func RestartAppIfNecessary(appID uint32) bool {
}

func Init() bool {
v, err := theDLL.call(flatAPI_Init)
v, err := theDLL.call(flatAPI_InitSafe)
if err != nil {
panic(err)
// If InitSafe() doesn't work for some reason, fallback to Init()
v, err = theDLL.call(flatAPI_Init)
if err != nil {
panic(err)
}
}
return byte(v) != 0
}
Expand Down

0 comments on commit 85388dd

Please sign in to comment.