Rise
The Vieneo Province
Loading...
Searching...
No Matches
SteamPresencePayload.cpp
Go to the documentation of this file.
2
3#include <cstring>
4
5namespace
6{
7 std::string PresenceText(const char* text)
8 {
9 std::string result = text ? text : "";
10 // Steam permits 255 UTF-8 bytes plus the terminating null. Keep a complete
11 // code point at the boundary, including when composing both status fields.
12 constexpr size_t maxBytes = 255;
13 if (result.size() > maxBytes)
14 {
15 size_t end = maxBytes;
16 while (end > 0 && (static_cast<unsigned char>(result[end]) & 0xc0) == 0x80)
17 --end;
18 result.resize(end);
19 }
20 return result;
21 }
22}
23
24RiseSteam::PresencePayload RiseSteam::BuildPresence(const char* details, const char* state, const char* screen)
25{
27 payload.details = PresenceText(details);
28 payload.state = PresenceText(state);
29 payload.display = payload.state.empty() ? "#Rise_Details" :
30 (payload.details.empty() ? "#Rise_State" : "#Rise_DetailsAndState");
31
32 if (screen)
33 {
34 if (std::strcmp(screen, "splash") == 0) payload.display = "#Rise_Starting";
35 else if (std::strcmp(screen, "login") == 0) payload.display = "#Rise_Login";
36 else if (std::strcmp(screen, "loading") == 0) payload.display = "#Rise_Loading";
37 else if (std::strcmp(screen, "immigration") == 0) payload.display = "#Rise_Immigration";
38 }
39
40 if (payload.details.empty() && payload.state.empty())
41 {
42 payload.details = "Playing Rise";
43 payload.display = "#Rise_Playing";
44 }
45 payload.status = payload.details;
46 if (!payload.details.empty() && !payload.state.empty())
47 payload.status += " - ";
48 payload.status += payload.state;
49 payload.status = PresenceText(payload.status.c_str());
50 return payload;
51}
float payload
Definition globals.cpp:92
PresencePayload BuildPresence(const char *details, const char *state, const char *screen=nullptr)