lutris / lutris

Lutris desktop client
https://lutris.net
GNU General Public License v3.0
7.7k stars 676 forks source link

EA App integration not finding installed games when installed in a custom directory #5160

Open Sajito opened 9 months ago

Sajito commented 9 months ago

Sorry for not strictly following the issue template. The issue template file in this repo seems to be broken right now, so it's not auto-generated.

Bug description

The title says it all. When games are installed in another directory than the default path, then the integration won't recognize them as installed automatically. After checking the code, that's obviously because the integration is only looking into the Program Files/EA Games directory on the mapped C: drive.

How to reproduce

  1. Install EA App
  2. Install games from within EA App to a custom directory
  3. Refresh the game list in Lutris
  4. Installed games are not detected

Expected behavior

Lutris should have detected the installed games.

Possible solution

Since the EA App does not store game state information in a metafile, at least not in plain text, I started digging around. From checking the integration, I understand, that we don't need the actual path to the installed game. All we need is it's contentID. Eventually I started digging around in the registry and found this key HKEY_LOCAL_MACHINE\Software\Wow6432Node\Origin Games. From what I can see, this key is parent to keys of installed games. Luckily the key name for each game is the contentID. At this time I have 3 games installed through EA App. Star Wars Jedi: Survivor, Mass Effect Andromeda and Mass Effect Legendary Edition. All of them are listed under that registry key, with their contentID. So one could check for that key and use the keys listed in there to detect installed games? Though I have not tested yet, if the keys are removed when uninstalling a game.

I wanted to submit a patch, but I've not figured out yet how to trigger a command in the correct wine prefix from the code. If someone could give me a hint here, I'm able to provide a patch.

strycore commented 9 months ago

The problem with those registry keys is that they also list some DLCs with no easy way to differentiate them with actual games. In the registry, I have several entries for Battlefield: Hardline's and The Sims 3 DLCs.

Even weirder, there's a Battlefield DLC listed at the root of the registry key:

image

trigger a command in the correct wine prefix from the code

You probably want lutris.runners.commands.wine.wineexec. We also have code to read from the registry in prefix.py.

Sajito commented 9 months ago

Thank you for the hints. I just checked, if the registry keys get cleaned up, when uninstalling a game. Unfortunately that's not the case. So that registry key is not as helpful as I thought. I will have a look, if there's at least a way, to find the configured default install location.

strycore commented 9 months ago

You could extract the location of your games from another registry key: image

So you could read the keys in EA Games, get the root games dir from the "Install Dir" and use that with our current game detection.

Sajito commented 9 months ago

The registry key I started with was my best bet. The key from your screenshot does not even exist in my registry: grafik

In the ea app prefix, I found the directory C:/users/<user>/AppData/Local/Electronic Arts/EA Desktop/. This directory contains .ini files, seemingly on a per user basis. The file name schema is user_<number>.ini. I assume <number> to be a profile id or a hash or something. That file contains the key user.downloadinplacedir, which at least contains the default installation directory defined in the app.

Maybe it's easier to followed the description from erri120 and your comment (https://github.com/erri120/erri120.github.io/issues/45#issuecomment-1595915665) on how to decrypt the install state file. With all the information available, it doesn't seem to be too hard to implement the decryption routine. I'm not too familiar with python and from what I saw lutris.runners.commands.wine.wineexec does not provide a way to wait for a result. Will have a deeper look, maybe this weekend, on how I can run commands and wait for their result. The volume serial number can be obtained by running vol C: in the wine prefix, everything else can be obtained by wmic.

gardotd426 commented 9 months ago

I'm confused, I have one EA App install that is running 4 different games installed in different directories NOT in that prefix (not in any prefix, just installed into their installdir), and all using their own wineprefixes. It works fine.

EA App's wineprefix is ~/nvme/EA/app, Dead Space Remake is installed in ~/nvme/EA/Dead\ Space\ (2023)/ and it's wine prefix is ~/nvme/EA/deadspace. Jedi Survivor is in ~/nvme/EA/JediSurvivor, prefix is ~/nvme/EA/jedi. I could go on, you get the idea. As long as the locations of the game installs are added as drives to the wineprefix through winecfg, and you go to install a game where it already exists, it just verifies it and that's it.

Sajito commented 9 months ago

It's not about actually installing the games, it's about finding the already installed games.

For example: Install the EA App in any prefix. Open the EA App and install any game to a non-standard download location. Now go to lutris and let it refresh the ea app games, through it's integration. It won't recognize the already installed games. Sure one can click on all the installed games and trigger the installation script, which in that case would only start the game, but it's not the same behavior as with other integrations.

strycore commented 9 months ago

I generally use symlinks to have both a large number of games installed and some games running at optimal speeds from a NVMe drive.

The example below is for Epic Games but the same can be done with EA App

image

Games are installed in their default location but stored in whichever drive makes the most sense.

It should also be noted that Lutris will eventually be able to manage moving games to fast storage ( #4118 )

gardotd426 commented 9 months ago

It's not about actually installing the games, it's about finding the already installed games.

For example: Install the EA App in any prefix. Open the EA App and install any game to a non-standard download location. Now go to lutris and let it refresh the ea app games, through it's integration. It won't recognize the already installed games. Sure one can click on all the installed games and trigger the installation script, which in that case would only start the game, but it's not the same behavior as with other integrations.

Not at all, you can 100% not reinstall the game and just add your already-installed one:

Screenshot_20231211_193202

You right-click on the game and click "Locate Installed Game" and just fill out the info and have the wineprefix set to your EA App prefix, and then for EA App, do Wine Configurations and add a new drive with the path to the Game's folder (obviously make it one directory above the game folder so it can see the game folder). Then when you go to "Download" the game in EA App, and it asks you where, you browse, select that drive, and then proceed. You'll see that it just verifies the files and never downloads anything (assuming there are no updates for the game or anything.

I've done this several times, And in the middle of typing that last paragraph I went ahead and did it for Battlefield 4, too. It didn't download a single file and is now ready to go from the ONE EA App, AND appears in your Lutris library under the EA App games:

Screenshot_20231211_200011

Not a single one of those games is installed in a Wine prefix at all, except BF4 which is in its old pre-EA App Origin prefix, and yet here it is showing up and ready to play through EA App from this one EA App using this one prefix. And you don't even have to launch the game through the EA App manually at all once you're set up, you can have the executable in Lutris set to the game executable to the actual game's exe, and it'll open (and instantly minimize) EA App and launch the game for you.

Maybe I'm confused about what you're actually complaining about, but as far as I can tell there is no issue, you just right-click on the game and click locate installed, fill out the config info and then add the path to wherever the game folder is added as a drive letter to the EA App prefix.

EDIT: literally just works: Screenshot_20231211_201139

Sajito commented 9 months ago

Maybe I'm confused about what you're actually complaining about, but as far as I can tell there is no issue, you just right-click on the game and click locate installed, fill out the config info and then add the path to wherever the game folder is added as a drive letter to the EA App prefix.

It's simple to reproduce.

  1. Delete the ea app prefix entirely.
  2. Reinstall ea app
  3. Start ea app
  4. Install any game to the default location from within the ea app
  5. Install any other game to another location from within the ea app
  6. Close ea app
  7. Use the refresh button next to ea app in lutris

You'll see that lutris is able to automatically recognize the game you installed in the default location, but not the one that was installed to a custom location. Again, it's not about having to redownload or reinstall anything, that's not the case. It's simply about lutris not being able to automatically recognize the games, that are installed through ea app to a custom directory.

@strycore I know this is only a minor issue, as it's only relevant when the prefix for the ea app has to be recreated for any reason. Still I think this is a useful feature, that works for most launchers. I have a working example, which decrypts the IS file and uses it to locate installed games, but unfortunately I can't finish it for general usage, because there is one value needed for the decryption key, which I can't reproduce for some reason. (https://github.com/erri120/GameFinder/issues/71#issuecomment-1847941447)

strycore commented 8 months ago

@Sajito if you do get the decryption working, that would be a pretty cool thing to have.

While this is being worked on, I would recommend symlinking the game folder in the default EA Games folder. That will solve the problem of the game not being detected.