update to new plugin api and make use of it

This commit is contained in:
Green Sky 2024-01-13 18:10:14 +01:00
parent 08256285f6
commit 647018e7c3
No known key found for this signature in database
4 changed files with 8 additions and 5 deletions

View File

@ -13,7 +13,7 @@ else()
endif() endif()
message("II SOLANACEAE_SDBOT_WEBUI_STANDALONE " ${SOLANACEAE_SDBOT_WEBUI_STANDALONE}) message("II SOLANACEAE_SDBOT_WEBUI_STANDALONE " ${SOLANACEAE_SDBOT_WEBUI_STANDALONE})
option(SOLANACEAE_SDBOT_WEBUI_BUILD_PLUGINS "Build the toxic_games plugins" ${SOLANACEAE_SDBOT_WEBUI_STANDALONE}) option(SOLANACEAE_SDBOT_WEBUI_BUILD_PLUGINS "Build the SDBot-webui plugin" ${SOLANACEAE_SDBOT_WEBUI_STANDALONE})
if (SOLANACEAE_SDBOT_WEBUI_STANDALONE) if (SOLANACEAE_SDBOT_WEBUI_STANDALONE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)

View File

@ -68,10 +68,10 @@ SOLANA_PLUGIN_EXPORT void solana_plugin_stop(void) {
g_sdbot.reset(); g_sdbot.reset();
} }
SOLANA_PLUGIN_EXPORT void solana_plugin_tick(float delta) { SOLANA_PLUGIN_EXPORT float solana_plugin_tick(float delta) {
(void)delta; (void)delta;
//std::cout << "PLUGIN SDB TICK()\n"; //std::cout << "PLUGIN SDB TICK()\n";
g_sdbot->iterate(); return g_sdbot->iterate();
} }
} // extern C } // extern C

View File

@ -41,7 +41,7 @@ SDBot::SDBot(
SDBot::~SDBot(void) { SDBot::~SDBot(void) {
} }
void SDBot::iterate(void) { float SDBot::iterate(void) {
if (static_cast<bool>(_con) && _con->outstanding()) { if (static_cast<bool>(_con) && _con->outstanding()) {
_con->pump(); _con->pump();
} else if (!_prompt_queue.empty()) { // dequeue new task } else if (!_prompt_queue.empty()) { // dequeue new task
@ -109,6 +109,9 @@ void SDBot::iterate(void) {
_prompt_queue.pop(); _prompt_queue.pop();
} }
// if active web connection, 5ms
return static_cast<bool>(_con) ? 0.005f : 1.f;
} }
bool SDBot::onEvent(const Message::Events::MessageConstruct& e) { bool SDBot::onEvent(const Message::Events::MessageConstruct& e) {

View File

@ -41,7 +41,7 @@ class SDBot : public RegistryMessageModelEventI {
); );
~SDBot(void); ~SDBot(void);
void iterate(void); float iterate(void);
public: // conf public: // conf
bool use_webp_for_friends = true; bool use_webp_for_friends = true;