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

RetroAchievements - Fixed Leaderboard Scored message format #12030

Merged

Conversation

LillyJadeKatrin
Copy link
Contributor

Refactored the message displayed when a leaderboard is submitted to so that it properly generates and uses a FormattedValue.

@AdmiralCurtiss
Copy link
Contributor

AdmiralCurtiss commented Jul 3, 2023

Is this guaranteed to return a nullterminated string? I'm not seeing anything indicating that in the documentation. In fact, by that I would expect:

FormattedValue value;
int length = rc_runtime_format_lboard_value(value.data(), FORMAT_SIZE, runtime_event->value, m_game_data.leaderboards[ix].format);
std::string_view str(value.data(), std::min(value.size(), static_cast<size_t>(length)));
OSD::AddMessage(fmt::format("Scored {} on leaderboard: {}", str, m_game_data.leaderboards[ix].title),

@LillyJadeKatrin
Copy link
Contributor Author

Under the hood, every call to both rc_runtime_format_lboard_value and rc_runtime_format_achievement_measured calls sprintf on a string literal, which to my understanding should always nullterminate.

@LillyJadeKatrin
Copy link
Contributor Author

Also, the maximum returned size of a formatted string can be 21 characters, and I was recommended to use 24 as a nice round number, so there's space allocated for the terminator.

Source/Core/Core/AchievementManager.h Outdated Show resolved Hide resolved
Source/Core/Core/AchievementManager.cpp Outdated Show resolved Hide resolved
Source/Core/Core/AchievementManager.cpp Outdated Show resolved Hide resolved
@LillyJadeKatrin LillyJadeKatrin force-pushed the retroachievements-bugfix-3 branch 2 times, most recently from 9dcaeeb to b6a61ae Compare July 5, 2023 03:10
Refactored the message displayed when a leaderboard is submitted to so that it properly generates and uses a FormattedValue.
@AdmiralCurtiss AdmiralCurtiss merged commit 357db03 into dolphin-emu:master Aug 28, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants