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

Split out code for serializing/deserializing cheat lines #10011

Merged
merged 2 commits into from Sep 8, 2021

Conversation

JosJuice
Copy link
Member

@JosJuice JosJuice commented Aug 9, 2021

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.

Source/Core/Core/GeckoCodeConfig.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PatchEngine.cpp Outdated Show resolved Hide resolved
Source/Core/Core/GeckoCodeConfig.cpp Outdated Show resolved Hide resolved
Source/Core/Core/GeckoCodeConfig.cpp Outdated Show resolved Hide resolved
@JosJuice JosJuice force-pushed the android-cheats-preparation branch 3 times, most recently from 366d6c5 to aa78fc7 Compare August 13, 2021 17:55

bool DeserializeLine(const std::string& line, GeckoCode::Code* out)
{
std::vector<std::string> pieces = SplitString(line, ' ');
Copy link
Contributor

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.

Copy link
Member Author

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.

Source/Core/Core/PatchEngine.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@AdmiralCurtiss AdmiralCurtiss left a 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.

@JosJuice JosJuice merged commit 52304df into dolphin-emu:master Sep 8, 2021
11 checks passed
@JosJuice JosJuice deleted the android-cheats-preparation branch September 8, 2021 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants