From 81ce57622c3166830b23eae534dacc6b008c659d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 28 Mar 2018 16:34:30 +0300 Subject: common protocol instance management code went into template --- protocols/MinecraftDynmap/src/main.cpp | 31 +------------------------------ protocols/MinecraftDynmap/src/proto.h | 6 ++++++ 2 files changed, 7 insertions(+), 30 deletions(-) (limited to 'protocols/MinecraftDynmap/src') diff --git a/protocols/MinecraftDynmap/src/main.cpp b/protocols/MinecraftDynmap/src/main.cpp index 525a037711..3c39f05077 100644 --- a/protocols/MinecraftDynmap/src/main.cpp +++ b/protocols/MinecraftDynmap/src/main.cpp @@ -22,6 +22,7 @@ along with this program. If not, see . #include "stdafx.h" +CMPlugin g_plugin; CLIST_INTERFACE* pcli; int hLangpack; @@ -44,12 +45,6 @@ PLUGININFOEX pluginInfo = { ///////////////////////////////////////////////////////////////////////////// // Protocol instances -static int compare_protos(const MinecraftDynmapProto *p1, const MinecraftDynmapProto *p2) -{ - return wcscmp(p1->m_tszUserName, p2->m_tszUserName); -} - -OBJLIST g_Instances(1, compare_protos); DWORD WINAPI DllMain(HINSTANCE hInstance,DWORD,LPVOID) { @@ -114,27 +109,3 @@ extern "C" int __declspec(dllexport) Unload(void) return 0; } -///////////////////////////////////////////////////////////////////////////////////////// - -static PROTO_INTERFACE* protoInit(const char *proto_name, const wchar_t *username) -{ - MinecraftDynmapProto *proto = new MinecraftDynmapProto(proto_name, username); - g_Instances.insert(proto); - return proto; -} - -static int protoUninit(PROTO_INTERFACE* proto) -{ - g_Instances.remove((MinecraftDynmapProto*)proto); - return EXIT_SUCCESS; -} - -struct CMPlugin : public CMPluginBase -{ - CMPlugin() : - CMPluginBase("MinecraftDynmap") - { - RegisterProtocol(PROTOTYPE_PROTOCOL, protoInit, protoUninit); - } -} - g_plugin; diff --git a/protocols/MinecraftDynmap/src/proto.h b/protocols/MinecraftDynmap/src/proto.h index 15327988f5..15be7bac17 100644 --- a/protocols/MinecraftDynmap/src/proto.h +++ b/protocols/MinecraftDynmap/src/proto.h @@ -129,5 +129,11 @@ public: std::string m_timestamp; int m_interval; int m_updateRate; +}; +struct CMPlugin : public ACCPROTOPLUGIN +{ + CMPlugin() : + ACCPROTOPLUGIN("MinecraftDynmap") + {} }; -- cgit v1.2.3