Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit 2163996

Browse files
committed
メンバ変数の初期化
1 parent 97de64d commit 2163996

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

TvTestRPC/TvTestRPC.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class CMyPlugin : public TVTest::CTVTestPlugin
1111
{
12-
DiscordEventHandlers handlers;
12+
DiscordEventHandlers handlers{};
1313
static LRESULT CALLBACK EventCallback(UINT Event, LPARAM lParam1, LPARAM lParam2, void* pClientData);
1414
static INT_PTR CALLBACK SettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, void* pClientData);
1515
bool ShowDialog(HWND hwndOwner);
@@ -52,7 +52,6 @@ class CMyPlugin : public TVTest::CTVTestPlugin
5252
}
5353
};
5454

55-
5655
bool CMyPlugin::InitSettings() {
5756
::GetModuleFileName(g_hinstDLL, m_szIniFileName, MAX_PATH);
5857
::PathRenameExtension(m_szIniFileName, TEXT(".ini"));
@@ -69,6 +68,8 @@ void CMyPlugin::InitDiscord()
6968

7069
void CMyPlugin::UpdateState()
7170
{
71+
DiscordRichPresence discordPresence;
72+
memset(&discordPresence, 0, sizeof(discordPresence));
7273
TVTest::ProgramInfo Info;
7374
Info.Size = sizeof(Info);
7475
wchar_t eventName[128];
@@ -82,13 +83,13 @@ void CMyPlugin::UpdateState()
8283
Info.MaxEventExtText = sizeof(eventExtText) / sizeof(eventExtText[0]);
8384
std::string channelName;
8485
std::string eventNamed;
85-
time_t start;
86-
time_t end;
8786

8887
if (m_pApp->GetCurrentProgramInfo(&Info)) {
8988
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;
9293
}
9394
if (!conf_mode) {
9495
TVTest::ServiceInfo Service;
@@ -104,12 +105,8 @@ void CMyPlugin::UpdateState()
104105
channelName = wide_to_utf8(ChannelInfo.szChannelName);
105106
}
106107
}
107-
DiscordRichPresence discordPresence;
108-
memset(&discordPresence, 0, sizeof(discordPresence));
109108
discordPresence.details = channelName.c_str();
110109
discordPresence.state = eventNamed.c_str();
111-
discordPresence.startTimestamp = start;
112-
discordPresence.endTimestamp = end;
113110
discordPresence.largeImageKey = "tvtest";
114111
discordPresence.partyId = "";
115112
discordPresence.partySize = 0;
@@ -119,6 +116,7 @@ void CMyPlugin::UpdateState()
119116
discordPresence.spectateSecret = "";
120117
discordPresence.instance = 0;
121118
Discord_UpdatePresence(&discordPresence);
119+
122120
}
123121

124122

0 commit comments

Comments
 (0)