9
9
10
10
class CMyPlugin : public TVTest ::CTVTestPlugin
11
11
{
12
- DiscordEventHandlers handlers;
12
+ DiscordEventHandlers handlers{} ;
13
13
static LRESULT CALLBACK EventCallback (UINT Event, LPARAM lParam1, LPARAM lParam2, void * pClientData);
14
14
static INT_PTR CALLBACK SettingsDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, void * pClientData);
15
15
bool ShowDialog (HWND hwndOwner);
@@ -52,7 +52,6 @@ class CMyPlugin : public TVTest::CTVTestPlugin
52
52
}
53
53
};
54
54
55
-
56
55
bool CMyPlugin::InitSettings () {
57
56
::GetModuleFileName (g_hinstDLL, m_szIniFileName, MAX_PATH);
58
57
::PathRenameExtension (m_szIniFileName, TEXT(" .ini" ));
@@ -69,6 +68,8 @@ void CMyPlugin::InitDiscord()
69
68
70
69
void CMyPlugin::UpdateState ()
71
70
{
71
+ DiscordRichPresence discordPresence;
72
+ memset (&discordPresence, 0 , sizeof (discordPresence));
72
73
TVTest::ProgramInfo Info;
73
74
Info.Size = sizeof (Info);
74
75
wchar_t eventName[128 ];
@@ -82,13 +83,13 @@ void CMyPlugin::UpdateState()
82
83
Info.MaxEventExtText = sizeof (eventExtText) / sizeof (eventExtText[0 ]);
83
84
std::string channelName;
84
85
std::string eventNamed;
85
- time_t start;
86
- time_t end;
87
86
88
87
if (m_pApp->GetCurrentProgramInfo (&Info)) {
89
88
eventNamed = wide_to_utf8 (Info.pszEventName );
90
- end = SystemTime2Timet (Info.StartTime ) + Info.Duration ;
91
- start = SystemTime2Timet (Info.StartTime );
89
+ time_t start = SystemTime2Timet (Info.StartTime );
90
+ time_t end = SystemTime2Timet (Info.StartTime ) + Info.Duration ;
91
+ discordPresence.startTimestamp = start;
92
+ discordPresence.endTimestamp = end;
92
93
}
93
94
if (!conf_mode) {
94
95
TVTest::ServiceInfo Service;
@@ -104,12 +105,8 @@ void CMyPlugin::UpdateState()
104
105
channelName = wide_to_utf8 (ChannelInfo.szChannelName );
105
106
}
106
107
}
107
- DiscordRichPresence discordPresence;
108
- memset (&discordPresence, 0 , sizeof (discordPresence));
109
108
discordPresence.details = channelName.c_str ();
110
109
discordPresence.state = eventNamed.c_str ();
111
- discordPresence.startTimestamp = start;
112
- discordPresence.endTimestamp = end;
113
110
discordPresence.largeImageKey = " tvtest" ;
114
111
discordPresence.partyId = " " ;
115
112
discordPresence.partySize = 0 ;
@@ -119,6 +116,7 @@ void CMyPlugin::UpdateState()
119
116
discordPresence.spectateSecret = " " ;
120
117
discordPresence.instance = 0 ;
121
118
Discord_UpdatePresence (&discordPresence);
119
+
122
120
}
123
121
124
122
0 commit comments