Allow specifying steam_appid at build time

This commit is contained in:
Struma 2020-03-02 04:44:10 -05:00 committed by Roza
parent 88abd71dfb
commit ce21a5b23c
2 changed files with 10 additions and 1 deletions

View file

@ -165,11 +165,16 @@ if steamworks == true
if build_static == true
la = '-static-libgcc -static-libstdc++'
endif
shim_args = ['-DGAME_LAUNCH_NAME="' + exe_name + '"']
if get_option('steam_appid') != ''
shim_args += '-DSTEAM_APPID=' + get_option('steam_appid')
endif
executable(meson.project_name(),
sources: files('steamshim/steamshim_parent.cpp'),
dependencies: steamlib,
include_directories: (steamworks_path + '/public'),
cpp_args: '-DGAME_LAUNCH_NAME="' + exe_name + '"',
cpp_args: shim_args,
link_args: la.split(),
install: (host_system != 'windows'))
endif

View file

@ -593,11 +593,15 @@ static bool setEnvironmentVars(PipeType pipeChildRead, PipeType pipeChildWrite)
static bool initSteamworks(PipeType fd)
{
#ifndef STEAM_APPID
// this can fail for many reasons:
// - you forgot a steam_appid.txt in the current working directory.
// - you don't have Steam running
// - you don't own the game listed in steam_appid.txt
if (!SteamAPI_Init())
#else
if (SteamAPI_RestartAppIfNecessary(STEAM_APPID))
#endif
return 0;
GSteamStats = SteamUserStats();