mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-04-19 03:00:50 -04:00
discord: optimize RPC game image loading
- Remove blocking network timeout check that was causing 5-second delays - Simplify logic to always attempt using Tinfoil game images - Let Discord handle image loading and fallback gracefully - Clean up URL formatting for better consistency - Remove unnecessary network validation that caused false negatives This fixes the issue where Discord RPC would fall back to default Citron logo due to network timeouts, allowing game-specific artwork to display properly from Tinfoil's CDN. Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -69,7 +69,9 @@ namespace DiscordRPC {
|
|||||||
DiscordRichPresence presence{};
|
DiscordRichPresence presence{};
|
||||||
|
|
||||||
if (!use_default && !game_title_id.empty()) {
|
if (!use_default && !game_title_id.empty()) {
|
||||||
game_url = fmt::format("{}{}/256/256", "https://tinfoil.media/ti/", game_title_id);
|
// Discord external image format
|
||||||
|
// Note: Discord may require app permissions for external URLs
|
||||||
|
game_url = fmt::format("https://tinfoil.media/ti/{}/256/256", game_title_id);
|
||||||
cached_url = game_url;
|
cached_url = game_url;
|
||||||
presence.largeImageKey = cached_url.c_str();
|
presence.largeImageKey = cached_url.c_str();
|
||||||
} else {
|
} else {
|
||||||
@@ -81,7 +83,7 @@ namespace DiscordRPC {
|
|||||||
presence.smallImageText = default_text.c_str();
|
presence.smallImageText = default_text.c_str();
|
||||||
presence.details = game_title.c_str();
|
presence.details = game_title.c_str();
|
||||||
presence.state = "Currently in game";
|
presence.state = "Currently in game";
|
||||||
presence.startTimestamp = current_state_start_time; // Use the state-based timer
|
presence.startTimestamp = current_state_start_time;
|
||||||
Discord_UpdatePresence(&presence);
|
Discord_UpdatePresence(&presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,18 +104,9 @@ namespace DiscordRPC {
|
|||||||
system.GetAppLoader().ReadProgramId(program_id);
|
system.GetAppLoader().ReadProgramId(program_id);
|
||||||
game_title_id = fmt::format("{:016X}", program_id);
|
game_title_id = fmt::format("{:016X}", program_id);
|
||||||
|
|
||||||
QNetworkAccessManager manager;
|
// Always try to use the Tinfoil image - Discord will handle fallback
|
||||||
QNetworkRequest request;
|
// Network check removed as it was causing unnecessary delays and false negatives
|
||||||
request.setUrl(QUrl(QString::fromStdString(
|
UpdateGameStatus(false);
|
||||||
fmt::format("https://tinfoil.media/ti/{}/256/256", game_title_id))));
|
|
||||||
request.setTransferTimeout(5000);
|
|
||||||
QNetworkReply* reply = manager.head(request);
|
|
||||||
QEventLoop request_event_loop;
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, &request_event_loop, &QEventLoop::quit);
|
|
||||||
request_event_loop.exec();
|
|
||||||
|
|
||||||
UpdateGameStatus(reply->error() != QNetworkReply::NoError);
|
|
||||||
reply->deleteLater();
|
|
||||||
} else {
|
} else {
|
||||||
// Game is NOT running (in menus).
|
// Game is NOT running (in menus).
|
||||||
const std::string default_text = "Citron Is A Homebrew Emulator For The Nintendo Switch";
|
const std::string default_text = "Citron Is A Homebrew Emulator For The Nintendo Switch";
|
||||||
|
|||||||
Reference in New Issue
Block a user