Skip to content

[Linux] Missing default Steam locations & Heroic Games Launcher compatibility for LegitimacyCheck() #255

Description

@theLeaxx

Overview

I was trying to run BeamMP on native Linux BeamNG, when I first encountered the "The game directory was not found." error. I tried running it with no-launch argument, and manually launch the game. It worked at first, but as soon as I joined any modded server it would break - no mods would load, the game would randomly crash, and typing any message in the chat would result in an instant kick for "Reason: No reason".

I then downloaded the public source code for the Launcher, and tried finding what exactly throws this error. After a short while I linked it to LegitimacyCheck(), in BeamNG.cpp, this specific section:

elif defined(__linux__)
    struct passwd* pw = getpwuid(getuid());
    std::filesystem::path homeDir = pw->pw_dir;

    // Right now only steam is supported
    std::vector<std::filesystem::path> steamappsCommonPaths = {
        ".steam/root/steamapps", // default
        ".steam/steam/steamapps", // Legacy Steam installations
        ".var/app/com.valvesoftware.Steam/.steam/root/steamapps", // flatpak
        "snap/steam/common/.local/share/Steam/steamapps" // snap
    };
// ...

I quickly noticed that, from memory, my Steam installation is in nowhere of these common paths. I created a symlink so it would act like it is in one of those directories, and the problem disappeared.

Solution for missing default Steam locations

This is very easy to implement, but this specific implementation could theoretically not fix the error entirely, as I'm not certain of ALL the available steam paths.
Notice: I used AI to find more common directories;

The solution is just, well, adding more paths in!
Here are some common paths:

std::vector<std::filesystem::path> steamappsCommonPaths = {
    ".local/share/Steam/steamapps", // this was the real Steam location in my case
    ".steam/root/steamapps", 
    ".steam/steam/steamapps",
    ".var/app/com.valvesoftware.Steam/.steam/root/steamapps",
    ".var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps",
    ".var/app/com.valvesoftware.Steam/data/Steam/steamapps",
    "snap/steam/common/.local/share/Steam/steamapps",
    ".snap/data/steam/common/.local/share/Steam/steamapps",
    "Steam/steamapps"
};

Heroic Games Launcher support

While the vast majority of users have BeamNG on Steam, I'm sure that some of them do have it on Epic Games Launcher instead - therefore while not a priority, it should be taken into consideration in the near future

Other info:

OS: Fedora Linux 44

Similar issues:

#251

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions