p2sr / SourceAutoRecord

Speedrun plugin for Source engine games.
MIT License
89 stars 27 forks source link

Discord RPC thumbnails don't load #189

Closed ThisAMJ closed 3 months ago

ThisAMJ commented 12 months ago

The feat/discord-rich-presence branch functions fine, but on most maps the thumbnail image does not load. I believe this to be because DiscordRichPresence's largeImageKey property has a max length of 32 bytes. Maybe using the readable map name (also already defined in the file) would work better?

https://github.com/p2sr/SourceAutoRecord/blob/28fd118776c5f38a246f2c0f6fdfdcf9d522230e/src/Features/DiscordRichPresence.cpp#L243

https://github.com/p2sr/SourceAutoRecord/blob/28fd118776c5f38a246f2c0f6fdfdcf9d522230e/lib/discord-rpc/include/discord-rpc/discord_rpc.h#L31

NeKzor commented 9 months ago

I've tested this feature and found the real problem: Since the mapName variable gets asigned to rp.largeImageKey it also requires the same lifetime as rp but if you look closely both variables are not in the same scope. https://github.com/p2sr/SourceAutoRecord/blob/28fd118776c5f38a246f2c0f6fdfdcf9d522230e/src/Features/DiscordRichPresence.cpp#L241-L252

I've also tested sar_discord_rpc_app_id which does not work because you are calling the wrong ctor. The variable has to be declared as a string but right now it will be interpreted as a boolean value if you try to change it in-game. https://github.com/p2sr/SourceAutoRecord/blob/28fd118776c5f38a246f2c0f6fdfdcf9d522230e/src/Features/DiscordRichPresence.cpp#L147

I also suggest not updating the presence state when the session is not running. It will look much nicer if you don't see the loading transition since it happens so fast anyway. https://github.com/p2sr/SourceAutoRecord/blob/28fd118776c5f38a246f2c0f6fdfdcf9d522230e/src/Features/DiscordRichPresence.cpp#L190-L195

ThisAMJ commented 9 months ago

@Krzyhau your code SUCKS! /j

ThisAMJ commented 7 months ago

Fixed by 6b56a49e22b7e673e3c7ce768c2dde846e37ae5a

Loading state still there for now.