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
Working Game IDs for Elf/Dol files #9461
Conversation
|
Whoopsie - many of the non windows builds seem to be failing because of "error: no type named 'string' in namespace 'std'". Someone with more experience willing to tell me what I am doing wrong? Edit: A quick google search revealed I am probably just missing |
|
Still not passing. I am unable to get my linux development environment in good order at the moment because Qt's servers are down. As soon as I can get qt5.9 installed I should be able to fix this. |
|
I think you just need to Please also try to fix the lint errors. The changed indentation makes the changeset rather hard to review. |
|
Thanks! And sorry about that - my vim configuration fixes indentation to it's liking upon saving. I will try to fix. Also, if anyone needs qt while their servers are down you can also find it here https://www.mirrorservice.org/sites/download.qt-project.org/official_releases/qt/5.9/5.9.0/ |
|
Fixed the formatting differences with |
|
Interestingly this doesn't seem to work when games are launched via Edit: Could it possibly be that I have to set Edit: I found the problem! The issue is that in the case of dolphin launching games from the game list, the |
|
I've mentioned this before in the related forum thread, but I'll mention it again here so that everyone else can see: Personally I think it would make sense to just set the game ID to the file name (including the extension), not a hash of it. It makes it easier for users to know what to name game INIs, it means you can see a meaningful name for the executable in the title bar of the emulation window instead of some random numbers, and it makes it clearer to people that this isn't a real game ID. I'm assuming the reason why you decided to go with a game ID that always is 16 characters is to match how Dolphin currently works for real games, but there's really nothing in Dolphin's code that requires game IDs to be a specific length. Collisions with real game IDs won't be a problem as long as the extension is included. While I would prefer not using hashes, if everyone else wants to use hashes then I'm fine with going with that. |
|
Agreed that it would be nicer to have meaningful names for users and also be more straightforward for user INI naming. |
|
Also, I would suggest updating the version number here so that users don't have to purge the cache manually:
|
|
I guess my issue with the direct approach is that then you get files with two extensions ".elf.ini" and ".elf.txt" which I find ugly/misleading (quite a different situation from .rar.zip where it actually makes sense). This is the kind of thing which to me seems likely to cause problems for someone in the future. But you guys are the experts - if that's what you'd prefer I can definitely do it. As for the other suggested changes I'll get right on those. |
|
Well, if it wasn't for the problem of conflicts between ELF/DOL "game IDs" and real game IDs, we could skip the extension... Maybe it would be fine to assume that if someone intentionally names their DOL file RSBE01 or something, they know what they're doing? I do agree that extensions like .elf.txt look a little weird (but they don't cause any problems). |
|
Another possibility is to add a small hash at the end, to make it readable but also unique. Or even just something like "gameid(filename)". Alternatively, I could just change the logic that displays the game_id in the emulation window and make it display the file name instead for elf's and dol's, and keep the hash. I don't think it's really that much more trouble to go into properties and copy the game id than it is to go to the file and copy its name. I actually think a really nice feature would be to give the right click menu a "copy game id to clipboard" option, maybe I'll look into that when this is done. Edit: Actually the window header is a non issue, at least for "launcher" elf files, it just shows the information for the default iso. |
|
Years ago, for GameTDB we came up with our own game IDs for homebrew, and made covers for them. Here is a full list of them. The thing is that not all the homebrew are in there, it's not perfect by any means and they would mostly have to be hard-coded to use them. I just thought I'd mention this, I wouldn't expect these to actually be used by Dolphin because they're a mess. |
|
If we exclude the extension, then I suppose anyone who would want to use those game IDs could do so by naming the file after the game ID. Though I don't expect these game IDs to be popular. |
|
I went with file_name.elf --> ID(file_name) |
|
So that a game ini for SSB Project M.elf would be ID(SSB Project M).ini |
|
Let me know if there is anything else I should do. |
|
Last one I hope - sorry about that I missed a format change last time. |
|
Okay everything is passing again. |
|
That's not a problem, you can call Core code from UICommon (but not vice versa) so you can just call SConfig::MakeGameID.
Changing it to std::string_view avoids an unnecessary allocation + copy in most cases. Furthermore, not requiring the string to be null terminated is an argument in favour of using std::string_view rather than std::string :) You may see std::string used in situations where std::string_view would make more sense; that's because the latter is a pretty new addition to the C++ standard library (C++17) and we haven't fully updated those legacy usages yet.
Oh right, because the extension is removed... Maybe |
|
Okay fair enough! The only issue with string_view is because string is used elsewhere I will probably have to do some conversions at some point. |
|
But I will make the changes |
|
You can pass a std::string to a function that takes a std::string_view without explicit conversions. Only the opposite operation (getting a std::string out of a string view) requires a manual conversion. |
|
So the output of MakeGameID is passed to SetGameRunningMetadata, which I am not going to mess with and which expects a |
|
We're not saying you should return
It's no more expensive than what's happening in the current code. |
|
Won't I then need to do the conversion inside the function? Or is specifying that it returns a string enough to tell it to do the conversion (which, while no more expensive, I believe is also no less expensive, the double copying is just happening in a different place) |
|
Sorry to bug about this. I'm learning as I go here. |
I believe you have to manually convert to
Yes, the gain of using |
|
I just did find out lol, the plus operator indeed does not work for string view. so I pass in as string view and convert to string literally immediately? I hope you see what I mean that this sounds a little funky, but I'll take your word(s) for it. |
|
You should do it after the |
|
Okay! Thanks, that makes more sense. |
Source/Core/Core/ConfigManager.h
Outdated
| @@ -4,10 +4,12 @@ | |||
|
|
|||
| #pragma once | |||
|
|
|||
| #include <algorithm> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure I use it in line 854 when I do std::replace(executable_path.begin(), executable_path.end(), BACKSLASH, FORWARDSLASH);
See: https://www.cplusplus.com/reference/algorithm/replace/
The replace line is necessary so that the game ids we are using work both when launching directly from dolphin and when using the command line (assuming the naive windows user passes in a path to their elf file which uses backslashes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the answer is no, this should be removed from the header since std::replace is only used in the .cpp.
|
Changes LGTM after the extraneous include is removed and after squashing all the commits (with an interactive rebase for example). |
|
Done. |
|
All checks passing. |
|
Any reason not to merge? Changes were approved 10 days ago. |
|
I'll merge this later today if there are no more objections. |
I've added game IDs for ELF and DOL files. This allows the user to set custom game configurations for ELF files and DOL files, as well as to load custom textures at a per elf/dol level. This is extremely useful if you have, for example, multiple mods of Super Smash Bros Brawl. At a technical level, all I'm doing is hashing the file name of the elf and using that as the game ID (thus collisions are possible but exceedingly unlikely). The user may need to do View->Purge Game List Cache before the the new title IDs appear for their old ELFs and DOLS.
For a discussion of reasoning for this pull request see here.