From f38c39343e46b96fd88e2975c0dff475e3016014 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sun, 8 Dec 2024 14:05:31 +0100 Subject: [PATCH] update and move ngcft1 plug to sub --- external/CMakeLists.txt | 1 + external/solanaceae_ngc_ft1 | 2 +- external/solanaceae_zox | 2 +- plugins/CMakeLists.txt | 18 --------- plugins/plugin_ngcft1.cpp | 81 ------------------------------------- 5 files changed, 3 insertions(+), 101 deletions(-) delete mode 100644 plugins/plugin_ngcft1.cpp diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 2956e1e..768554a 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -29,6 +29,7 @@ add_subdirectory(./solanaceae_tox_upnp) set(SOLANACEAE_TOX_P2PRNG_BUILD_PLUGINS ON CACHE BOOL "") add_subdirectory(./solanaceae_tox_p2prng) +set(SOLANACEAE_NGCFT1_BUILD_PLUGINS ON CACHE BOOL "") set(SOLANACEAE_NGCFT1_SHA1_BUILD_TESTING ${SOLANACEAE_ECOSYSTEM_BUILD_TESTING} CACHE BOOL "") set(SOLANACEAE_NGCHS2_BUILD_TESTING ${SOLANACEAE_ECOSYSTEM_BUILD_TESTING} CACHE BOOL "") add_subdirectory(./solanaceae_ngc_ft1) diff --git a/external/solanaceae_ngc_ft1 b/external/solanaceae_ngc_ft1 index ba809ed..7bbaa9b 160000 --- a/external/solanaceae_ngc_ft1 +++ b/external/solanaceae_ngc_ft1 @@ -1 +1 @@ -Subproject commit ba809eda431156c87ef0869980bdd7a9a38a69ab +Subproject commit 7bbaa9b929b523fbcb9bff95d0eab2049aaaee6c diff --git a/external/solanaceae_zox b/external/solanaceae_zox index 013fb45..09f9c01 160000 --- a/external/solanaceae_zox +++ b/external/solanaceae_zox @@ -1 +1 @@ -Subproject commit 013fb45cf9d30c91578538d63a1bdd8e77cbeab8 +Subproject commit 09f9c01e682acda734ce9a93db96fc96ff2455c4 diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 5db1b81..6d04e1f 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,23 +1,5 @@ cmake_minimum_required(VERSION 3.9 FATAL_ERROR) -add_library(plugin_ngcft1 MODULE - ./plugin_ngcft1.cpp -) -set_target_properties(plugin_ngcft1 PROPERTIES - C_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN ON # do we need this? -) -target_compile_definitions(plugin_ngcft1 PUBLIC ENTT_API_IMPORT) - -target_link_libraries(plugin_ngcft1 PUBLIC - solanaceae_plugin - solanaceae_ngcext - solanaceae_ngcft1 - solanaceae_sha1_ngcft1 -) - -######################################## - add_library(plugin_transfer_auto_accept MODULE ./plugin_transfer_auto_accept.cpp ./transfer_auto_accept.hpp diff --git a/plugins/plugin_ngcft1.cpp b/plugins/plugin_ngcft1.cpp deleted file mode 100644 index 4d1446c..0000000 --- a/plugins/plugin_ngcft1.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include - -#include -#include -#include - -#include -#include - -#include -#include - -static std::unique_ptr g_ngcextep = nullptr; -// TODO: make sep plug -static std::unique_ptr g_ngcft1 = nullptr; -static std::unique_ptr g_sha1_ngcft1 = nullptr; - -constexpr const char* plugin_name = "NGCEXT"; - -extern "C" { - -SOLANA_PLUGIN_EXPORT const char* solana_plugin_get_name(void) { - return plugin_name; -} - -SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_get_version(void) { - return SOLANA_PLUGIN_VERSION; -} - -SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api) { - std::cout << "PLUGIN " << plugin_name << " START()\n"; - - if (solana_api == nullptr) { - return 1; - } - - try { - auto* os = PLUG_RESOLVE_INSTANCE(ObjectStore2); - auto* tox_i = PLUG_RESOLVE_INSTANCE(ToxI); - auto* tox_event_provider_i = PLUG_RESOLVE_INSTANCE(ToxEventProviderI); - auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1"); - auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModelI); - auto* tcm = PLUG_RESOLVE_INSTANCE(ToxContactModel2); - - // static store, could be anywhere tho - // construct with fetched dependencies - g_ngcextep = std::make_unique(*tox_i, *tox_event_provider_i); - g_ngcft1 = std::make_unique(*tox_i, *tox_event_provider_i, *g_ngcextep.get()); - g_sha1_ngcft1 = std::make_unique(*os, *cr, *rmm, *g_ngcft1.get(), *tcm, *tox_event_provider_i, *g_ngcextep.get()); - - // register types - PLUG_PROVIDE_INSTANCE(NGCEXTEventProviderI, plugin_name, g_ngcextep.get()); - - PLUG_PROVIDE_INSTANCE(NGCFT1EventProviderI, plugin_name, g_ngcft1.get()); - PLUG_PROVIDE_INSTANCE(NGCFT1, plugin_name, g_ngcft1.get()); - - PLUG_PROVIDE_INSTANCE(SHA1_NGCFT1, plugin_name, g_sha1_ngcft1.get()); - } catch (const ResolveException& e) { - std::cerr << "PLUGIN " << plugin_name << " " << e.what << "\n"; - return 2; - } - - return 0; -} - -SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) { - std::cout << "PLUGIN " << plugin_name << " STOP()\n"; - - g_sha1_ngcft1.reset(); - g_ngcft1.reset(); - g_ngcextep.reset(); -} - -SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float delta) { - const float ft_interval = g_ngcft1->iterate(delta); - const float sha_interval = g_sha1_ngcft1->iterate(delta); - return std::min(ft_interval, sha_interval); -} - -} // extern C -