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

Pass updated game paths in plugin events after drive changes, or remove auto-path detection feature #3872

Open
darklinkpower opened this issue Nov 21, 2024 · 1 comment
Labels

Comments

@darklinkpower
Copy link
Contributor

Bug Description

  • Playnite's game controller currently looks for the specified paths during game start and if not found, it looks if the same path exist in other drives and if it does, it uses that to launch the game
  • Game and Play Action objects passed to plugins have the original invalid game paths, rather than the replaced ones. This results in issues in plugins when they rely on these paths to work properly

I became aware of this issue after a user encountered it with a plugin I develop, as detailed in this issue: [PlayState] Game not suspending. The problem arose because the plugin received an invalid path through the OnGameStarted event arguments, even though Playnite had resolved and used a different path to launch the game.

In my opinion there are two potential solutions to address this:

  1. Remove the ExistsOnAnyDrive functionality: In my view, resolving missing paths only at game launch leads to an inconsistent state where the game remains registered with an invalid path. This not only causes issues for plugins, as seen in the PlayState example, but could also introduce problems within Playnite itself. Instead, users should be notified if a game’s path is invalid, with an option to either update the path manually or maybe, Playnite should handle this itself automatically in the background.

  2. Pass updated paths in plugin arguments: If Playnite continues to resolve paths at launch, the Game and SourceAction objects passed to plugins should reflect the actual paths Playnite used to start the game, not the original (and now invalid) ones. This would ensure plugins receive the correct data and avoid inconsistencies that would result in breaking functionality that rely on these paths.

To Reproduce

  1. Configure a game action with a set path
  2. Move the game to another drive with the same structure
  3. Launch the game. Playnite will still launch it despite the current paths being invalid, thanks to its *ExistsOnAnyDrive (
    var newPath = "";
    switch (pathType)
    {
    case FileSystemItem.File:
    exists = FileSystem.FileExistsOnAnyDrive(sourcePath, out newPath);
    break;
    case FileSystemItem.Directory:
    exists = FileSystem.DirectoryExistsOnAnyDrive(sourcePath, out newPath);
    break;
    default:
    throw new NotSupportedException();
    }
    if (exists && !string.Equals(newPath, sourcePath, StringComparison.OrdinalIgnoreCase))
    {
    logger.Warn($"Replaced missing {changeProp} with new one:\n{{0}}\n{{1}}".Format(sourcePath, newPath));
    return newPath;
    ) functionality
  4. Passed objects to plugins will have the original, invalid paths that are different to the ones used to start the game.

Diagnostics ID

Logs provided by user in linked issue

Screenshots

No response

@JosefNemec
Copy link
Owner

JosefNemec commented Nov 21, 2024

This is how it's going to work in P11:

  • there won't be any ExistsOnAnyDrive or similar stuff like that during run time
  • there will be an option (not sure yet if opt-in or opt-out) that will check install paths on library update and "fix" them permanently in the library if drive letter has changed

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

No branches or pull requests

2 participants