From 216399696962cafbe5f5450daf4fc7a2b9331a62 Mon Sep 17 00:00:00 2001 From: noriokun4649 Date: Sun, 1 Nov 2020 06:18:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=90=E5=A4=89=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E5=88=9D=E6=9C=9F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TvTestRPC/TvTestRPC.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/TvTestRPC/TvTestRPC.cpp b/TvTestRPC/TvTestRPC.cpp index d4b931f..3803691 100644 --- a/TvTestRPC/TvTestRPC.cpp +++ b/TvTestRPC/TvTestRPC.cpp @@ -9,7 +9,7 @@ class CMyPlugin : public TVTest::CTVTestPlugin { - DiscordEventHandlers handlers; + DiscordEventHandlers handlers{}; static LRESULT CALLBACK EventCallback(UINT Event, LPARAM lParam1, LPARAM lParam2, void* pClientData); static INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, void* pClientData); bool ShowDialog(HWND hwndOwner); @@ -52,7 +52,6 @@ class CMyPlugin : public TVTest::CTVTestPlugin } }; - bool CMyPlugin::InitSettings() { ::GetModuleFileName(g_hinstDLL, m_szIniFileName, MAX_PATH); ::PathRenameExtension(m_szIniFileName, TEXT(".ini")); @@ -69,6 +68,8 @@ void CMyPlugin::InitDiscord() void CMyPlugin::UpdateState() { + DiscordRichPresence discordPresence; + memset(&discordPresence, 0, sizeof(discordPresence)); TVTest::ProgramInfo Info; Info.Size = sizeof(Info); wchar_t eventName[128]; @@ -82,13 +83,13 @@ void CMyPlugin::UpdateState() Info.MaxEventExtText = sizeof(eventExtText) / sizeof(eventExtText[0]); std::string channelName; std::string eventNamed; - time_t start; - time_t end; if (m_pApp->GetCurrentProgramInfo(&Info)) { eventNamed = wide_to_utf8(Info.pszEventName); - end = SystemTime2Timet(Info.StartTime) + Info.Duration; - start = SystemTime2Timet(Info.StartTime); + time_t start = SystemTime2Timet(Info.StartTime); + time_t end = SystemTime2Timet(Info.StartTime) + Info.Duration; + discordPresence.startTimestamp = start; + discordPresence.endTimestamp = end; } if (!conf_mode) { TVTest::ServiceInfo Service; @@ -104,12 +105,8 @@ void CMyPlugin::UpdateState() channelName = wide_to_utf8(ChannelInfo.szChannelName); } } - DiscordRichPresence discordPresence; - memset(&discordPresence, 0, sizeof(discordPresence)); discordPresence.details = channelName.c_str(); discordPresence.state = eventNamed.c_str(); - discordPresence.startTimestamp = start; - discordPresence.endTimestamp = end; discordPresence.largeImageKey = "tvtest"; discordPresence.partyId = ""; discordPresence.partySize = 0; @@ -119,6 +116,7 @@ void CMyPlugin::UpdateState() discordPresence.spectateSecret = ""; discordPresence.instance = 0; Discord_UpdatePresence(&discordPresence); + }