Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix argument count when launched with Steam on Linux #562

Merged
merged 1 commit into from
Aug 29, 2023
Merged

Fix argument count when launched with Steam on Linux #562

merged 1 commit into from
Aug 29, 2023

Conversation

zeroepoch
Copy link
Contributor

Description

Resolves a recent change (I think) with how Steam on Linux launches applications. I believe the extra -- arguments are messing up the argument counts for the relaunch. Using the following change I was able to get the game working. Basically added 2 extra arguments and shifted the last argument by 2.

if [ "$2" = "SteamLaunch" ]; then
    "$1" "$2" "$3" "$4" "$5" "$6" "$0" "$7"
    exit
fi

Motivation and Context

I had to resolve this issue locally in order to even launch the game on Steam. The changes I made to the game properties in Steam were following this link. This PR resolves issue #559.

How Has This Been Tested?

I tested this change using the game Ultimate Chicken Horse on Steam on a laptop running Fedora 37.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@zeroepoch
Copy link
Contributor Author

Any update on this? Is anyone else seeing the same issue with Steam games?

@Ecconia
Copy link

Ecconia commented Jun 11, 2023

Yeah I also had this issue on Linux when launching the BepInEx via Steam.
And your suggested fix works!
It also only makes sense given the current arguments that Steams provides via %command%.
Thanks for it.

For completeness sake, arguments in ./run_bepinex.sh %command% are:
0: ./run_bepinex.sh 1: [...]/reaper 2: SteamLaunch 3: AppId=1234 4: -- 5: [..]/steam-launch-wrapper 6: -- 7: [..]/Game_Executable_By_Steam

Copy link
Member

@ManlyMarco ManlyMarco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the user has an old version of Steam for whatever reason? Can it be made to work on both old and new version of the arguments? Also a comment explaining the arguments would be nice.

@zeroepoch
Copy link
Contributor Author

What happens if the user has an old version of Steam for whatever reason? Can it be made to work on both old and new version of the arguments? Also a comment explaining the arguments would be nice.

I don't think it will work with an older version of Steam. Since Steam is constantly being updated I don't know if you can go back to an older version.

@ManlyMarco
Copy link
Member

ManlyMarco commented Jul 27, 2023

I don't think it will work with an older version of Steam. Since Steam is constantly being updated I don't know if you can go back to an older version.

You can stay without updating in offline mode indefinitely as long as the game doesn't have network features or secondary DRM. Since you can also use BepInEx fully offline I think breaking backwards compatibility is not ideal.

If you have an old physical release with the full game files if I recall correctly you can install the Steam build from the disc and the game and it will work fine until you connect to the internet. This is not really relevant in this case though since I don't think there's any Unity games released in this format that we could support.

It looks like you could detect how many arguments you have gotten and branch based on that?

@zeroepoch
Copy link
Contributor Author

It looks like you could detect how many arguments you have gotten and branch based on that?

I think that should be the case since the last argument $7 should be non-empty in the newer case. TBH I don't have this setup anymore to test. Some friends and I were trying to get a game working together and since I spent an hour debugging this issue, and I didn't see anyone else report it, I didn't want the fix to be lost or the effort repeated by others.

@Mantas-2155X
Copy link

Can confirm this PR allows native Linux games to start again

@ManlyMarco ManlyMarco merged commit b72a599 into BepInEx:v5-lts Aug 29, 2023
@zeroepoch zeroepoch deleted the v5-lts-steam-launcher branch August 30, 2023 00:09
@@ -32,7 +32,7 @@ export DOORSTOP_CORLIB_OVERRIDE_PATH=""
# Special case: program is launched via Steam
# In that case rerun the script via their bootstrapper to ensure Steam overlay works
if [ "$2" = "SteamLaunch" ]; then
"$1" "$2" "$3" "$4" "$0" "$5"
"$1" "$2" "$3" "$4" "$5" "$6" "$0" "$7"
Copy link
Contributor

@astiob astiob Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ManlyMarco I don’t have a Linux Steam to test this on, but if you just want to forward all arguments—that is, assuming that there aren’t additional arguments that Steam passes in but you want to drop—then this should be compatible with old and new versions alike:

count=0
until [ $((count+=1)) -ge $# ]; do
    set -- "$@" "$1"
    shift
done
set -- "$@" "$0" "$1"
shift
"$@"

(Thanks to https://stackoverflow.com/a/62227833/865331 for a cross-platform implementation.)

Also, rather than "$@"; exit in this line and the line after it, you may want to exec "$@".

Want me to submit a pull request?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want me to submit a pull request?

Yes, please do, that would be great. It'll have to be applied to the master branch as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the version on master passes the remaining arguments through, as though they can be non-empty. This originates in #391 without any apparent explanation. If extra arguments are really possible, then this should rather parse the command line, find the steam-launch-wrapper [--] and insert BepInEx after that, and it probably needs to preserve the extra arguments in v5, too. Alternatively, I guess it can just count the same fixed 5 arguments but avoid counting any instances of --.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants