MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / GetEffectivePlayerName

Method GetEffectivePlayerName

Sources/Jazz2/PreferencesCache.cpp:909–932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

907 }
908
909 String PreferencesCache::GetEffectivePlayerName()
910 {
911 // Discord display name has the highest priority, then the player name set in the preferences, and finally the system username
912
913 String playerName;
914#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)
915 if (PreferencesCache::EnableDiscordIntegration && UI::DiscordRpcClient::Get().IsSupported()) {
916 playerName = UI::DiscordRpcClient::Get().GetUserDisplayName();
917 }
918#endif
919 if (playerName.empty()) {
920 playerName = PreferencesCache::PlayerName;
921 if (playerName.empty()) {
922 playerName = theApplication().GetUserName();
923 if (playerName.empty()) {
924 // Fallback to "Player XXXX" using the last 4 hex digits of the unique player ID
925 playerName = format("Player {:.2x}{:.2x}",
926 PreferencesCache::UniquePlayerID[14], PreferencesCache::UniquePlayerID[15]);
927 }
928 }
929 }
930
931 return playerName;
932 }
933
934 EpisodeContinuationState* PreferencesCache::GetEpisodeEnd(StringView episodeName, bool createIfNotFound)
935 {

Callers

nothing calls this directly

Calls 5

formatFunction · 0.85
GetUserDisplayNameMethod · 0.80
IsSupportedMethod · 0.45
emptyMethod · 0.45
GetUserNameMethod · 0.45

Tested by

no test coverage detected