Please help me translate this Python code fragment to implement Steam Achievements

For other topics related to the FreeBASIC project or its community.
Landeel
Posts: 695
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Please help me translate this Python code fragment to implement Steam Achievements

Postby Landeel » Apr 30, 2019 16:05

Greetings,

I'm trying to implement Steam Achievements in my game without any lib but steamapi itself.

I have found this code in Python that supposedly does what I need: https://shiz.me/junk/renpy/steam.py

Code: Select all

# Simple Ren'Py Steam achievement integration.
# (C) 2013-2015 Shiz, badly coded and under no warranty whatsoever.
#
# Grab the Steamworks v1.33a SDK (or whatever the latest version is), extract it, and create the 'game/libs' directory in your Ren'Py game folder.
# Then copy the following files from the SDK:
#   redistributable_bin/steam_api.dll            -> game/libs/steam_api.dll
#   redistributable_bin/osx32/libsteam_api.dylib -> game/libs/libsteam_api.dylib
#   redistributable_bin/linux32/libsteam_api.so  -> game/libs/libsteam_api.so
#   redistributable_bin/linux64/libsteam_api.so  -> game/libs/libsteam_api_64.so
# Then save this file as 'game/steam.py'.
# In your game init code:
#   init python:
#       import steam
#       if steam.loaded:
#           steam.init()
# and when you want to unlock an achievement:
#   $ steam.unlock_achievement('name')
#
import renpy.exports as renpy
import sys
import os.path as path
import ctypes

# Attempt to load the Steam library.
steam = None
loaded = False

try:
    if sys.platform.startswith('win'):
        so = 'steam_api.dll'
    elif sys.platform.startswith('darwin'):
        so = 'libsteam_api.dylib'
    elif sys.platform.startswith('linux'):
        if sys.maxsize > 2**32:
            so = 'libsteam_api_64.so'
        else:
            so = 'libsteam_api.so'
    else:
        raise EnvironmentError('Unsupported operating system')
    steam = ctypes.CDLL(path.join(renpy.config.gamedir, 'libs', so))
except Exception as e:
    if renpy.config.developer:
        raise
    renpy.log('Not loading Steam library: {}'.format(e))
else:
    loaded = True
    # Steam wrappers.
    SteamAPI_Init = steam.SteamAPI_Init
    SteamAPI_Shutdown = steam.SteamAPI_Shutdown
    SteamUserStats = steam.SteamUserStats
    SteamUserStats.restype = ctypes.c_void_p
    SteamUserStats_SetAchievement = steam.SteamAPI_ISteamUserStats_SetAchievement
    SteamUserStats_SetAchievement.argtypes = [ ctypes.c_void_p, ctypes.c_char_p ]
    SteamUserStats_StoreStats = steam.SteamAPI_ISteamUserStats_StoreStats
    SteamUserStats_StoreStats.argtypes = [ ctypes.c_void_p ]

def init():
    """ Initialize Steam library. May restart program if Steam deems necessary, and loads individual components. """
    # Initialize library.
    try:
        if not SteamAPI_Init():
            raise RuntimeError('Could not initialize Steam library. (SteamAPI_Init() failed)')
    except Exception as e:
        global loaded
        loaded = False
        if renpy.config.developer:
            raise
        renpy.log('Steam initialization failed: {}'.format(e))

def shutdown():
    """ Shut down Steam library. Should be run on exit. """
    # Shut down library.
    global loaded
    if loaded:
        SteamAPI_Shutdown()
        loaded = False

def get_stats():
    """ Get user stats. """
    if loaded:
        return SteamUserStats()

def unlock_achievement(name):
    if loaded:
        stats = get_stats()
        SteamUserStats_SetAchievement(stats, name)
        SteamUserStats_StoreStats(stats)


I'm trying to translate it to fb, but I'm having trouble with this part specifically:

Code: Select all

SteamUserStats = steam.SteamUserStats
SteamUserStats.restype = ctypes.c_void_p


Dylibsymbol won't find "SteamUserStats". How does this work? How to translate this to FreeBASIC?

Thanks in advance.
Tourist Trap
Posts: 2762
Joined: Jun 02, 2015 16:24

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby Tourist Trap » Apr 30, 2019 19:08

Landeel wrote:

Code: Select all

SteamUserStats = steam.SteamUserStats
SteamUserStats.restype = ctypes.c_void_p


Dylibsymbol won't find "SteamUserStats". How does this work? How to translate this to FreeBASIC?

Thanks in advance.

Hi Landeel, before some Python afficionado comes to rescue. It seems to me that this is here a kind of type alias. Like "type ... as". Or maybe it works like "using *namespace*".... Because I don't see why a variable would be named so exactly as what seems to be its type at 1st line. And for the other, it really sounds like a type name, embedded in a kind of namespace. To me at least!
badidea
Posts: 1545
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby badidea » Apr 30, 2019 19:37

I found this website https://partner.steamgames.com/doc/api/ISteamUserStats and decided: Too complex for me.
Last edited by badidea on Apr 30, 2019 20:29, edited 1 time in total.
Landeel
Posts: 695
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby Landeel » Apr 30, 2019 19:54

badidea wrote:I found this website https://partner.steamgames.com/doc/api/ISteamUserStats and decided: To complex for me.


Yeah, that's where I went first. Then stopped when trying to replicate the classes.
It seems this method would require a wrapper library written in C++.

But if someone could make this work directly in Python, it's probably possible in FreeBASIC too.
Landeel
Posts: 695
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby Landeel » Apr 30, 2019 19:57

Tourist Trap wrote:Hi Landeel, before some Python afficionado comes to rescue. It seems to me that this is here a kind of type alias. Like "type ... as". Or maybe it works like "using *namespace*".... Because I don't see why a variable would be named so exactly as what seems to be its type at 1st line. And for the other, it really sounds like a type name, embedded in a kind of namespace. To me at least!


Yeah, I don't know much about Python but had that impression too. Shouldn't dylibsymbol find it?
caseih
Posts: 1379
Joined: Feb 26, 2007 5:32

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby caseih » May 01, 2019 14:06

That's very odd that dylibsymbol can't find that symbol. Your read of the Python code is correct. Did you try running the python code on the same machine as your FB version? Does it run at all or does it also give an error trying to find that symbol? Is there a utility somewhere that can open and DLL and dump out all the symbols to verify that it's actually there?
marcov
Posts: 2770
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby marcov » May 01, 2019 14:53

Look how the symbols look like using "nm"? Maybe pyhton mangles them.
Landeel
Posts: 695
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby Landeel » May 01, 2019 23:04

marcov wrote:Look how the symbols look like using "nm"? Maybe pyhton mangles them.


This is what I get from nm: https://jpst.it/1I1wC

Doesn't look like it's there, at least, not with that name.

The Steam documentation says it's a "global accessor function", whatever this is.
https://partner.steamgames.com/doc/api/ISteamUserStats
marcov
Posts: 2770
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby marcov » May 02, 2019 8:49

It might be something like a property, which is not exported in a dll because it only refers other functions, typically getters and setters . One might be:

SteamAPI_ISteamClient_GetISteamUserStats
paul doe
Posts: 922
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby paul doe » May 02, 2019 9:58

Landeel wrote:...
The Steam documentation says it's a "global accessor function", whatever this is.
https://partner.steamgames.com/doc/api/ISteamUserStats

It's a public property, as marcov says. Unfortunately, the API for SteamWorks is in VC++ (ISteamUserStats is an interface), so wrapping it for FreeBasic won't be as easy as you might think. There are some C wrappers available, though:

https://github.com/rlabrecque/CSteamworks
https://github.com/addictgamer/steamworks-c-wrapper

So you can start from there. Also, I've found this:
http://rosalilastudio.com/steamworks-api-exploration/

Which discusses how to implement it. Here are some other useful links:
https://discourse.libsdl.org/t/steamworks-api-not-working-with-mingw/23789
https://www.reddit.com/r/gamedev/comments/74svhb/steamworks_sdk_with_mingw/

So, perhaps your best bet is to go with the C wrappers approach. When/if I have a little spare time, I'll do some tests and report (since this is also useful to me as well). Good luck! ;)
Landeel
Posts: 695
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby Landeel » May 02, 2019 12:19

paul doe wrote:So, perhaps your best bet is to go with the C wrappers approach. When/if I have a little spare time, I'll do some tests and report (since this is also useful to me as well). Good luck! ;)


Hey,

I have the basic stuff already. Tested and working.

Code: Select all

screen 14

   #define steam_appid 480 ' replace for your appid
   #define steam_dev ' will ignore the existence of steam_appid.txt
   '#define steam_restart ' will force restart if the game was not lauched by steam

   dim shared as any ptr libsteam_api
   dim shared as integer steam_failed=0
   dim shared SteamAPI_RestartAppIfNecessary as function cdecl(byval unOwnAppID as uinteger<32>) as boolean 'S_API bool S_CALLTYPE SteamAPI_RestartAppIfNecessary( uint32 unOwnAppID );
   dim shared SteamAPI_Init as function cdecl() as boolean 'S_API bool S_CALLTYPE SteamAPI_Init();
   dim shared SteamAPI_IsSteamRunning as function cdecl() as boolean
   dim shared SteamAPI_Shutdown as sub cdecl() 'S_API void S_CALLTYPE SteamAPI_Shutdown();
   

   #ifndef steam_dev
      'quit if steam_appid.txt exists
      if dir(exepath()+"/steam_appid.txt")<>"" then
         'if steam_appid.txt exists
         steam_failed=1
      end if
   #endif

   #ifdef __FB_WIN32__
      libsteam_api=dylibload(exepath+"/dll/steam_api.dll")
   #else
      #ifdef __FB_64BIT__
         libsteam_api=dylibload(exepath+"/lib64/libsteam_api.so")
      #else
         libsteam_api=dylibload(exepath+"/lib32/libsteam_api.so")
      #endif
   #endif

   if libsteam_api then
      print "STEAM : libsteam_api loaded :",libsteam_api
   else
      print "STEAM : could not load libsteam_api"
      sleep
      end
   end if

   SteamAPI_RestartAppIfNecessary=DyLibSymbol(libsteam_api,"SteamAPI_RestartAppIfNecessary")
   SteamAPI_Init=DyLibSymbol(libsteam_api,"SteamAPI_Init")
   SteamAPI_IsSteamRunning=DyLibSymbol(libsteam_api,"SteamAPI_IsSteamRunning")
   SteamAPI_Shutdown=DyLibSymbol(libsteam_api,"SteamAPI_Shutdown")

   #ifdef steam_restart
      if SteamAPI_RestartAppIfNecessary(steam_appid) then
         'restart game with steam
         print "STEAM : SteamAPI_RestartAppIfNecessary(steam_appid)=true"
         sleep
         end
      end if
   #endif
   
   if SteamAPI_Init() then
      print "STEAM : Init ok."
   else
      'SteamAPI_Init() failed
      print "STEAM : SteamAPI_Init()=false"
      steam_failed=1
   end if

   if SteamAPI_IsSteamRunning() then
      print "STEAM : running."
   else
      'Steam is not running
      print "STEAM : NOT running."
      steam_failed=1
   end if

   
   print "Press esc to quit"
   do
      sleep 1,1
   loop until multikey(1)

   'close steam api
   SteamAPI_Shutdown()
   dylibfree libsteam_api : libsteam_api=0


But I really wanted Achievements...

"CSteamworks" looks interesting. I'll take a look, thanks.
dodicat
Posts: 5938
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby dodicat » May 02, 2019 13:31

The steam_api.dll is OK with the functions in it.(steam_api.def)
Here are my results with steam_api.dll 32 bits.
(some prints are commented out, they stop the full run)

test code:

Code: Select all


'get steam_api.dll
#inclib "steam_api"

 declare function GetHSteamPipe cdecl alias $"GetHSteamPipe" as boolean
 declare function GetHSteamUser cdecl alias $"GetHSteamUser" as boolean
 declare function SteamAPI_GetHSteamPipe cdecl alias $"SteamAPI_GetHSteamPipe" as boolean
 declare function SteamAPI_GetHSteamUser cdecl alias $"SteamAPI_GetHSteamUser" as boolean
 declare function SteamAPI_GetSteamInstallPath cdecl alias $"SteamAPI_GetSteamInstallPath" as boolean
 declare function SteamAPI_Init cdecl alias $"SteamAPI_Init" as boolean
 declare function SteamAPI_InitSafe cdecl alias $"SteamAPI_InitSafe" as boolean
 declare function SteamAPI_IsSteamRunning cdecl alias $"SteamAPI_IsSteamRunning" as boolean
 declare function SteamAPI_RegisterCallResult cdecl alias $"SteamAPI_RegisterCallResult" as boolean
 declare function SteamAPI_RegisterCallback cdecl alias $"SteamAPI_RegisterCallback" as boolean
 declare function SteamAPI_RestartAppIfNecessary cdecl alias $"SteamAPI_RestartAppIfNecessary" as boolean
 declare function SteamAPI_RunCallbacks cdecl alias $"SteamAPI_RunCallbacks" as boolean
 declare function SteamAPI_SetMiniDumpComment cdecl alias $"SteamAPI_SetMiniDumpComment" as boolean
 declare function SteamAPI_SetTryCatchCallbacks cdecl alias $"SteamAPI_SetTryCatchCallbacks" as boolean
 declare function SteamAPI_Shutdown cdecl alias $"SteamAPI_Shutdown" as boolean
 declare function SteamAPI_UnregisterCallResult cdecl alias $"SteamAPI_UnregisterCallResult" as boolean
 declare function SteamAPI_UnregisterCallback cdecl alias $"SteamAPI_UnregisterCallback" as boolean
 declare function SteamAPI_WriteMiniDump cdecl alias $"SteamAPI_WriteMiniDump" as boolean
 declare function SteamApps cdecl alias $"SteamApps" as boolean
 declare function SteamClient cdecl alias $"SteamClient" as boolean
 declare function SteamContentServer cdecl alias $"SteamContentServer" as boolean
 declare function SteamContentServerUtils cdecl alias $"SteamContentServerUtils" as boolean
 declare function SteamContentServer_Init cdecl alias $"SteamContentServer_Init" as boolean
 declare function SteamContentServer_RunCallbacks cdecl alias $"SteamContentServer_RunCallbacks" as boolean
 declare function SteamContentServer_Shutdown cdecl alias $"SteamContentServer_Shutdown" as boolean
 declare function SteamFriends cdecl alias $"SteamFriends" as boolean
 declare function SteamGameServer cdecl alias $"SteamGameServer" as boolean
 declare function SteamGameServerApps cdecl alias $"SteamGameServerApps" as boolean
 declare function SteamGameServerNetworking cdecl alias $"SteamGameServerNetworking" as boolean
 declare function SteamGameServerStats cdecl alias $"SteamGameServerStats" as boolean
 declare function SteamGameServerUtils cdecl alias $"SteamGameServerUtils" as boolean
 declare function SteamGameServer_BSecure cdecl alias $"SteamGameServer_BSecure" as boolean
 declare function SteamGameServer_GetHSteamPipe cdecl alias $"SteamGameServer_GetHSteamPipe" as boolean
 declare function SteamGameServer_GetHSteamUser cdecl alias $"SteamGameServer_GetHSteamUser" as boolean
 declare function SteamGameServer_GetIPCCallCount cdecl alias $"SteamGameServer_GetIPCCallCount" as boolean
 declare function SteamGameServer_GetSteamID cdecl alias $"SteamGameServer_GetSteamID" as boolean
 declare function SteamGameServer_Init cdecl alias $"SteamGameServer_Init" as boolean
 declare function SteamGameServer_InitSafe cdecl alias $"SteamGameServer_InitSafe" as boolean
 declare function SteamGameServer_RunCallbacks cdecl alias $"SteamGameServer_RunCallbacks" as boolean
 declare function SteamGameServer_Shutdown cdecl alias $"SteamGameServer_Shutdown" as boolean
 declare function SteamMasterServerUpdater cdecl alias $"SteamMasterServerUpdater" as boolean
 declare function SteamMatchmaking cdecl alias $"SteamMatchmaking" as boolean
 declare function SteamMatchmakingServers cdecl alias $"SteamMatchmakingServers" as boolean
 declare function SteamNetworking cdecl alias $"SteamNetworking" as boolean
 declare function SteamRemoteStorage cdecl alias $"SteamRemoteStorage" as boolean
 declare function SteamUser cdecl alias $"SteamUser" as boolean
 declare function SteamUserStats cdecl alias $"SteamUserStats" as boolean
 declare function SteamUtils cdecl alias $"SteamUtils" as boolean
 declare function Steam_GetHSteamUserCurrent cdecl alias $"Steam_GetHSteamUserCurrent" as boolean
 declare function Steam_RegisterInterfaceFuncs cdecl alias $"Steam_RegisterInterfaceFuncs" as boolean
 declare function Steam_RunCallbacks cdecl alias $"Steam_RunCallbacks" as boolean
 ''g_pSteamClientGameServer DATA  'also in the .def file
 
 #macro _print(s)
     print #s;tab(40);s
 #endmacro

_print(GetHSteamPipe)
_print( GetHSteamPipe)
_print( GetHSteamUser)
_print( SteamAPI_GetHSteamPipe)
_print( SteamAPI_GetHSteamUser)
_print( SteamAPI_GetSteamInstallPath)
_print( SteamAPI_Init)
_print( SteamAPI_InitSafe)
_print( SteamAPI_IsSteamRunning)
_print( SteamAPI_RegisterCallResult)
'_print( SteamAPI_RegisterCallback
_print( SteamAPI_RestartAppIfNecessary)
_print( SteamAPI_RunCallbacks)
'_print( SteamAPI_SetMiniDumpComment
_print( SteamAPI_SetTryCatchCallbacks)
_print( SteamAPI_Shutdown)
_print( SteamAPI_UnregisterCallResult)
'_print( SteamAPI_UnregisterCallback
'_print( SteamAPI_WriteMiniDump
_print( SteamApps)
_print( SteamClient)
_print( SteamContentServer)
_print( SteamContentServerUtils)
_print( SteamContentServer_Init)
_print( SteamContentServer_RunCallbacks)
_print( SteamContentServer_Shutdown)
_print( SteamFriends)
_print( SteamGameServer)
_print( SteamGameServerApps)
_print( SteamGameServerNetworking)
_print( SteamGameServerStats)
_print( SteamGameServerUtils)
_print( SteamGameServer_BSecure)
_print( SteamGameServer_GetHSteamPipe)
_print( SteamGameServer_GetHSteamUser)
_print( SteamGameServer_GetIPCCallCount)
_print( SteamGameServer_GetSteamID)
_print( SteamGameServer_Init)
_print( SteamGameServer_InitSafe)
_print( SteamGameServer_RunCallbacks)
_print( SteamGameServer_Shutdown)
_print( SteamMasterServerUpdater)
_print( SteamMatchmaking)
_print( SteamMatchmakingServers)
_print( SteamNetworking)
_print( SteamRemoteStorage)
_print( SteamUser)
_print( SteamUserStats)
_print( SteamUtils)
_print( Steam_GetHSteamUserCurrent)
_print( Steam_RegisterInterfaceFuncs)
_print( Steam_RunCallbacks)
print "done"

 

 


my results:

Code: Select all

GetHSteamPipe                          false
GetHSteamPipe                          false
GetHSteamUser                          false
SteamAPI_GetHSteamPipe                 false
SteamAPI_GetHSteamUser                 false
SteamAPI_GetSteamInstallPath           true
SteamAPI_Init                          false
SteamAPI_InitSafe                      false
SteamAPI_IsSteamRunning                false
SteamAPI_RegisterCallResult            true
SteamAPI_RestartAppIfNecessary         false
SteamAPI_RunCallbacks                  false
SteamAPI_SetTryCatchCallbacks          false
SteamAPI_Shutdown                      false
SteamAPI_UnregisterCallResult          true
SteamApps                              false
SteamClient                            false
SteamContentServer                     false
SteamContentServerUtils                false
SteamContentServer_Init                false
SteamContentServer_RunCallbacks        true
SteamContentServer_Shutdown            true
SteamFriends                           false
SteamGameServer                        false
SteamGameServerApps                    false
SteamGameServerNetworking              false
SteamGameServerStats                   false
SteamGameServerUtils                   false
SteamGameServer_BSecure                false
SteamGameServer_GetHSteamPipe          false
SteamGameServer_GetHSteamUser          false
SteamGameServer_GetIPCCallCount        false
SteamGameServer_GetSteamID             true
SteamGameServer_Init                   false
SteamGameServer_InitSafe               false
SteamGameServer_RunCallbacks           true
SteamGameServer_Shutdown               true
SteamMasterServerUpdater               false
SteamMatchmaking                       false
SteamMatchmakingServers                false
SteamNetworking                        false
SteamRemoteStorage                     false
SteamUser                              false
SteamUserStats                         false
SteamUtils                             false
Steam_GetHSteamUserCurrent             false
Steam_RegisterInterfaceFuncs           true
Steam_RunCallbacks                     true
done
Press any key to continue . . .


Sorry I cannot test your python code(unable to install python due to registry errors Win 10)
dodicat
Posts: 5938
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby dodicat » May 02, 2019 13:31

The steam_api.dll is OK with the functions in it.(steam_api.def)
Here are my results with steam_api.dll 32 bits.
(some prints are commented out, they stop the full run)

test code:

Code: Select all


'get steam_api.dll
#inclib "steam_api"

 declare function GetHSteamPipe cdecl alias $"GetHSteamPipe" as boolean
 declare function GetHSteamUser cdecl alias $"GetHSteamUser" as boolean
 declare function SteamAPI_GetHSteamPipe cdecl alias $"SteamAPI_GetHSteamPipe" as boolean
 declare function SteamAPI_GetHSteamUser cdecl alias $"SteamAPI_GetHSteamUser" as boolean
 declare function SteamAPI_GetSteamInstallPath cdecl alias $"SteamAPI_GetSteamInstallPath" as boolean
 declare function SteamAPI_Init cdecl alias $"SteamAPI_Init" as boolean
 declare function SteamAPI_InitSafe cdecl alias $"SteamAPI_InitSafe" as boolean
 declare function SteamAPI_IsSteamRunning cdecl alias $"SteamAPI_IsSteamRunning" as boolean
 declare function SteamAPI_RegisterCallResult cdecl alias $"SteamAPI_RegisterCallResult" as boolean
 declare function SteamAPI_RegisterCallback cdecl alias $"SteamAPI_RegisterCallback" as boolean
 declare function SteamAPI_RestartAppIfNecessary cdecl alias $"SteamAPI_RestartAppIfNecessary" as boolean
 declare function SteamAPI_RunCallbacks cdecl alias $"SteamAPI_RunCallbacks" as boolean
 declare function SteamAPI_SetMiniDumpComment cdecl alias $"SteamAPI_SetMiniDumpComment" as boolean
 declare function SteamAPI_SetTryCatchCallbacks cdecl alias $"SteamAPI_SetTryCatchCallbacks" as boolean
 declare function SteamAPI_Shutdown cdecl alias $"SteamAPI_Shutdown" as boolean
 declare function SteamAPI_UnregisterCallResult cdecl alias $"SteamAPI_UnregisterCallResult" as boolean
 declare function SteamAPI_UnregisterCallback cdecl alias $"SteamAPI_UnregisterCallback" as boolean
 declare function SteamAPI_WriteMiniDump cdecl alias $"SteamAPI_WriteMiniDump" as boolean
 declare function SteamApps cdecl alias $"SteamApps" as boolean
 declare function SteamClient cdecl alias $"SteamClient" as boolean
 declare function SteamContentServer cdecl alias $"SteamContentServer" as boolean
 declare function SteamContentServerUtils cdecl alias $"SteamContentServerUtils" as boolean
 declare function SteamContentServer_Init cdecl alias $"SteamContentServer_Init" as boolean
 declare function SteamContentServer_RunCallbacks cdecl alias $"SteamContentServer_RunCallbacks" as boolean
 declare function SteamContentServer_Shutdown cdecl alias $"SteamContentServer_Shutdown" as boolean
 declare function SteamFriends cdecl alias $"SteamFriends" as boolean
 declare function SteamGameServer cdecl alias $"SteamGameServer" as boolean
 declare function SteamGameServerApps cdecl alias $"SteamGameServerApps" as boolean
 declare function SteamGameServerNetworking cdecl alias $"SteamGameServerNetworking" as boolean
 declare function SteamGameServerStats cdecl alias $"SteamGameServerStats" as boolean
 declare function SteamGameServerUtils cdecl alias $"SteamGameServerUtils" as boolean
 declare function SteamGameServer_BSecure cdecl alias $"SteamGameServer_BSecure" as boolean
 declare function SteamGameServer_GetHSteamPipe cdecl alias $"SteamGameServer_GetHSteamPipe" as boolean
 declare function SteamGameServer_GetHSteamUser cdecl alias $"SteamGameServer_GetHSteamUser" as boolean
 declare function SteamGameServer_GetIPCCallCount cdecl alias $"SteamGameServer_GetIPCCallCount" as boolean
 declare function SteamGameServer_GetSteamID cdecl alias $"SteamGameServer_GetSteamID" as boolean
 declare function SteamGameServer_Init cdecl alias $"SteamGameServer_Init" as boolean
 declare function SteamGameServer_InitSafe cdecl alias $"SteamGameServer_InitSafe" as boolean
 declare function SteamGameServer_RunCallbacks cdecl alias $"SteamGameServer_RunCallbacks" as boolean
 declare function SteamGameServer_Shutdown cdecl alias $"SteamGameServer_Shutdown" as boolean
 declare function SteamMasterServerUpdater cdecl alias $"SteamMasterServerUpdater" as boolean
 declare function SteamMatchmaking cdecl alias $"SteamMatchmaking" as boolean
 declare function SteamMatchmakingServers cdecl alias $"SteamMatchmakingServers" as boolean
 declare function SteamNetworking cdecl alias $"SteamNetworking" as boolean
 declare function SteamRemoteStorage cdecl alias $"SteamRemoteStorage" as boolean
 declare function SteamUser cdecl alias $"SteamUser" as boolean
 declare function SteamUserStats cdecl alias $"SteamUserStats" as boolean
 declare function SteamUtils cdecl alias $"SteamUtils" as boolean
 declare function Steam_GetHSteamUserCurrent cdecl alias $"Steam_GetHSteamUserCurrent" as boolean
 declare function Steam_RegisterInterfaceFuncs cdecl alias $"Steam_RegisterInterfaceFuncs" as boolean
 declare function Steam_RunCallbacks cdecl alias $"Steam_RunCallbacks" as boolean
 ''g_pSteamClientGameServer DATA  'also in the .def file
 
 #macro _print(s)
     print #s;tab(40);s
 #endmacro

_print(GetHSteamPipe)
_print( GetHSteamPipe)
_print( GetHSteamUser)
_print( SteamAPI_GetHSteamPipe)
_print( SteamAPI_GetHSteamUser)
_print( SteamAPI_GetSteamInstallPath)
_print( SteamAPI_Init)
_print( SteamAPI_InitSafe)
_print( SteamAPI_IsSteamRunning)
_print( SteamAPI_RegisterCallResult)
'_print( SteamAPI_RegisterCallback
_print( SteamAPI_RestartAppIfNecessary)
_print( SteamAPI_RunCallbacks)
'_print( SteamAPI_SetMiniDumpComment
_print( SteamAPI_SetTryCatchCallbacks)
_print( SteamAPI_Shutdown)
_print( SteamAPI_UnregisterCallResult)
'_print( SteamAPI_UnregisterCallback
'_print( SteamAPI_WriteMiniDump
_print( SteamApps)
_print( SteamClient)
_print( SteamContentServer)
_print( SteamContentServerUtils)
_print( SteamContentServer_Init)
_print( SteamContentServer_RunCallbacks)
_print( SteamContentServer_Shutdown)
_print( SteamFriends)
_print( SteamGameServer)
_print( SteamGameServerApps)
_print( SteamGameServerNetworking)
_print( SteamGameServerStats)
_print( SteamGameServerUtils)
_print( SteamGameServer_BSecure)
_print( SteamGameServer_GetHSteamPipe)
_print( SteamGameServer_GetHSteamUser)
_print( SteamGameServer_GetIPCCallCount)
_print( SteamGameServer_GetSteamID)
_print( SteamGameServer_Init)
_print( SteamGameServer_InitSafe)
_print( SteamGameServer_RunCallbacks)
_print( SteamGameServer_Shutdown)
_print( SteamMasterServerUpdater)
_print( SteamMatchmaking)
_print( SteamMatchmakingServers)
_print( SteamNetworking)
_print( SteamRemoteStorage)
_print( SteamUser)
_print( SteamUserStats)
_print( SteamUtils)
_print( Steam_GetHSteamUserCurrent)
_print( Steam_RegisterInterfaceFuncs)
_print( Steam_RunCallbacks)
print "done"

 

 


my results:

Code: Select all

GetHSteamPipe                          false
GetHSteamPipe                          false
GetHSteamUser                          false
SteamAPI_GetHSteamPipe                 false
SteamAPI_GetHSteamUser                 false
SteamAPI_GetSteamInstallPath           true
SteamAPI_Init                          false
SteamAPI_InitSafe                      false
SteamAPI_IsSteamRunning                false
SteamAPI_RegisterCallResult            true
SteamAPI_RestartAppIfNecessary         false
SteamAPI_RunCallbacks                  false
SteamAPI_SetTryCatchCallbacks          false
SteamAPI_Shutdown                      false
SteamAPI_UnregisterCallResult          true
SteamApps                              false
SteamClient                            false
SteamContentServer                     false
SteamContentServerUtils                false
SteamContentServer_Init                false
SteamContentServer_RunCallbacks        true
SteamContentServer_Shutdown            true
SteamFriends                           false
SteamGameServer                        false
SteamGameServerApps                    false
SteamGameServerNetworking              false
SteamGameServerStats                   false
SteamGameServerUtils                   false
SteamGameServer_BSecure                false
SteamGameServer_GetHSteamPipe          false
SteamGameServer_GetHSteamUser          false
SteamGameServer_GetIPCCallCount        false
SteamGameServer_GetSteamID             true
SteamGameServer_Init                   false
SteamGameServer_InitSafe               false
SteamGameServer_RunCallbacks           true
SteamGameServer_Shutdown               true
SteamMasterServerUpdater               false
SteamMatchmaking                       false
SteamMatchmakingServers                false
SteamNetworking                        false
SteamRemoteStorage                     false
SteamUser                              false
SteamUserStats                         false
SteamUtils                             false
Steam_GetHSteamUserCurrent             false
Steam_RegisterInterfaceFuncs           true
Steam_RunCallbacks                     true
done
Press any key to continue . . .


Sorry I cannot test your python code(unable to install python due to registry errors Win 10)
Landeel
Posts: 695
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby Landeel » May 03, 2019 13:57

cannot find -lsteam_api

Hey dodicat, how do you compile that? Don't you need a "steam_api.a"?
Landeel
Posts: 695
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Re: Please help me translate this Python code fragment to implement Steam Achievements

Postby Landeel » May 03, 2019 14:00

steamapi-test.o:fake:(.text+0x2f6): undefined reference to `SteamApps'
steamapi-test.o:fake:(.text+0x352): undefined reference to `SteamContentServer'
steamapi-test.o:fake:(.text+0x380): undefined reference to `SteamContentServerUtils'
steamapi-test.o:fake:(.text+0x3ae): undefined reference to `SteamContentServer_Init'
steamapi-test.o:fake:(.text+0x3dc): undefined reference to `SteamContentServer_RunCallbacks'
steamapi-test.o:fake:(.text+0x40a): undefined reference to `SteamContentServer_Shutdown'
steamapi-test.o:fake:(.text+0x438): undefined reference to `SteamFriends'
steamapi-test.o:fake:(.text+0x466): undefined reference to `SteamGameServer'
steamapi-test.o:fake:(.text+0x494): undefined reference to `SteamGameServerApps'
steamapi-test.o:fake:(.text+0x4c2): undefined reference to `SteamGameServerNetworking'
steamapi-test.o:fake:(.text+0x4f0): undefined reference to `SteamGameServerStats'
steamapi-test.o:fake:(.text+0x51e): undefined reference to `SteamGameServerUtils'
steamapi-test.o:fake:(.text+0x632): undefined reference to `SteamGameServer_Init'
steamapi-test.o:fake:(.text+0x6ea): undefined reference to `SteamMasterServerUpdater'
steamapi-test.o:fake:(.text+0x718): undefined reference to `SteamMatchmaking'
steamapi-test.o:fake:(.text+0x746): undefined reference to `SteamMatchmakingServers'
steamapi-test.o:fake:(.text+0x774): undefined reference to `SteamNetworking'
steamapi-test.o:fake:(.text+0x7a2): undefined reference to `SteamRemoteStorage'
steamapi-test.o:fake:(.text+0x7d0): undefined reference to `SteamUser'
steamapi-test.o:fake:(.text+0x7fe): undefined reference to `SteamUserStats'
steamapi-test.o:fake:(.text+0x82c): undefined reference to `SteamUtils'


Hm, this is what I get if I put the dll in the same folder and try to cross-compile for Windows.
Maybe you're using a different version of the library?

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest