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
Split out code for serializing/deserializing cheat lines #10011
Split out code for serializing/deserializing cheat lines #10011
Conversation
4a1864d
to
2239331
Compare
2239331
to
11c2538
Compare
366d6c5
to
aa78fc7
Compare
Source/Core/Core/GeckoCodeConfig.cpp
Outdated
|
|
||
| bool DeserializeLine(const std::string& line, GeckoCode::Code* out) | ||
| { | ||
| std::vector<std::string> pieces = SplitString(line, ' '); |
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.
I'm not sure if this is ever really a problem in practice, but this function has quite different behavior compared to the old ss >> std::hex >> new_code.address >> new_code.data; code. Leading whitespace was previously okay but is now a failure, and any non-space whitespace anywhere near the code parts also no longer works.
If you're okay with breaking behavior anyway I would just go ahead and make this function return std::optional<GeckoCode::Code>. The other code above can just construct its own GeckoCode::Code with just the original_line set in the failure case.
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.
Hmm... I hadn't thought about that change in behavior. I think it should be fine for INI files (and having Gecko INI parsing be consistent with AR INI parsing is nice), but I'm unsure if the stuff we download from geckocodes.org might contain odd whitespace. However, we're not actually calling this from the geckocodes.org downloading function, so it should be fine.
Good point about how the code above could handle getting an optional. I've made it do that.
aa78fc7
to
ceecd4f
Compare
ceecd4f
to
b90008a
Compare
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.
Looks good to me now. Untested though.
Some refactoring to prepare for my upcoming Android cheats PR. I figured it would make sense to submit this as a separate PR, since C++-heavy and Java-heavy PRs tend to get reviewed by different people.