summaryrefslogtreecommitdiff
path: root/protocols/MinecraftDynmap/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-09-17 16:37:24 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-09-17 16:37:24 +0000
commite5d58fc3bbbce2773b7c6c3f8b7da6faa66b672e (patch)
tree6432409a59b53d8098ac38aa1d3072ae2e5f9e4b /protocols/MinecraftDynmap/src
parent17e345e621254103a98bbc7e662a2829b7aa3ce6 (diff)
chats: more functions, less structures
git-svn-id: http://svn.miranda-ng.org/main/trunk@17309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MinecraftDynmap/src')
-rw-r--r--protocols/MinecraftDynmap/src/chat.cpp50
-rw-r--r--protocols/MinecraftDynmap/src/proto.cpp6
2 files changed, 19 insertions, 37 deletions
diff --git a/protocols/MinecraftDynmap/src/chat.cpp b/protocols/MinecraftDynmap/src/chat.cpp
index c4e4fd0b87..a2aa6f0e6b 100644
--- a/protocols/MinecraftDynmap/src/chat.cpp
+++ b/protocols/MinecraftDynmap/src/chat.cpp
@@ -31,7 +31,7 @@ void MinecraftDynmapProto::UpdateChat(const char *name, const char *message, con
ptrW tname(mir_a2u_cp(name, CP_UTF8));
GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_MESSAGE };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.time = timestamp;
gce.ptszText = tmessage;
@@ -47,7 +47,7 @@ void MinecraftDynmapProto::UpdateChat(const char *name, const char *message, con
gce.ptszNick = tname;
gce.ptszUID = gce.ptszNick;
- Chat_Event(0, &gce);
+ Chat_Event(&gce);
}
int MinecraftDynmapProto::OnChatEvent(WPARAM, LPARAM lParam)
@@ -91,7 +91,7 @@ void MinecraftDynmapProto::AddChatContact(const char *name)
ptrW tname(mir_a2u_cp(name, CP_UTF8));
GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_JOIN };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.time = DWORD(time(0));
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = tname;
@@ -103,7 +103,7 @@ void MinecraftDynmapProto::AddChatContact(const char *name)
else
gce.ptszStatus = L"Normal";
- Chat_Event(0,&gce);
+ Chat_Event(&gce);
}
void MinecraftDynmapProto::DeleteChatContact(const char *name)
@@ -111,14 +111,14 @@ void MinecraftDynmapProto::DeleteChatContact(const char *name)
ptrW tname(mir_a2u_cp(name, CP_UTF8));
GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_PART };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = tname;
gce.ptszUID = gce.ptszNick;
gce.time = DWORD(time(0));
gce.bIsMe = (m_nick == name);
- Chat_Event(0,&gce);
+ Chat_Event(&gce);
}
INT_PTR MinecraftDynmapProto::OnJoinChat(WPARAM,LPARAM suppress)
@@ -126,7 +126,7 @@ INT_PTR MinecraftDynmapProto::OnJoinChat(WPARAM,LPARAM suppress)
ptrW tszTitle(mir_a2u_cp(m_title.c_str(), CP_UTF8));
// Create the group chat session
- GCSESSION gcw = {sizeof(gcw)};
+ GCSESSION gcw = {};
gcw.iType = GCW_PRIVMESS;
gcw.ptszID = m_tszUserName;
gcw.ptszName = tszTitle;
@@ -138,13 +138,13 @@ INT_PTR MinecraftDynmapProto::OnJoinChat(WPARAM,LPARAM suppress)
// Create a group
GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_ADDGROUP };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.ptszStatus = L"Admin";
- Chat_Event(NULL, &gce);
+ Chat_Event(&gce);
gce.ptszStatus = L"Normal";
- Chat_Event(NULL, &gce);
+ Chat_Event(&gce);
// Note: Initialization will finish up in SetChatStatus, called separately
if (!suppress)
@@ -158,31 +158,22 @@ void MinecraftDynmapProto::SetTopic(const char *topic)
ptrW ttopic(mir_a2u_cp(topic, CP_UTF8));
GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_TOPIC };
- GCEVENT gce = { sizeof(gce), &gcd };
+ GCEVENT gce = { &gcd };
gce.time = ::time(NULL);
gce.ptszText = ttopic;
- Chat_Event(0, &gce);
+ Chat_Event( &gce);
}
INT_PTR MinecraftDynmapProto::OnLeaveChat(WPARAM,LPARAM)
{
- GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.time = ::time(NULL);
-
- Chat_Event(SESSION_OFFLINE, &gce);
- Chat_Event(SESSION_TERMINATE,&gce);
-
+ Chat_Control(m_szModuleName, m_tszUserName, SESSION_OFFLINE);
+ Chat_Terminate(m_szModuleName, m_tszUserName);
return 0;
}
void MinecraftDynmapProto::SetChatStatus(int status)
{
- GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.time = ::time(NULL);
-
if (status == ID_STATUS_ONLINE)
{
// Load actual name from database
@@ -196,20 +187,15 @@ void MinecraftDynmapProto::SetChatStatus(int status)
// Add self contact
AddChatContact(m_nick.c_str());
- Chat_Event(SESSION_INITDONE,&gce);
- Chat_Event(SESSION_ONLINE, &gce);
- }
- else
- {
- Chat_Event(SESSION_OFFLINE,&gce);
+ Chat_Control(m_szModuleName, m_tszUserName, SESSION_INITDONE);
+ Chat_Control(m_szModuleName, m_tszUserName, SESSION_ONLINE);
}
+ else Chat_Control(m_szModuleName, m_tszUserName, SESSION_OFFLINE);
}
void MinecraftDynmapProto::ClearChat()
{
- GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- Chat_Event(WINDOW_CLEARLOG, &gce);
+ Chat_Control(m_szModuleName, m_tszUserName, WINDOW_CLEARLOG);
}
// TODO: Could this be done better?
diff --git a/protocols/MinecraftDynmap/src/proto.cpp b/protocols/MinecraftDynmap/src/proto.cpp
index 9fb913869b..48c3cdfa80 100644
--- a/protocols/MinecraftDynmap/src/proto.cpp
+++ b/protocols/MinecraftDynmap/src/proto.cpp
@@ -160,15 +160,11 @@ INT_PTR MinecraftDynmapProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
int MinecraftDynmapProto::OnModulesLoaded(WPARAM, LPARAM)
{
// Register group chat
- GCREGISTER gcr = {sizeof(gcr)};
- gcr.dwFlags = 0;
+ GCREGISTER gcr = {};
gcr.pszModule = m_szModuleName;
gcr.ptszDispName = m_tszUserName;
gcr.iMaxText = MINECRAFTDYNMAP_MESSAGE_LIMIT;
- gcr.nColors = 0;
- gcr.pColors = NULL;
Chat_Register(&gcr);
-
return 0;
}