From d8eec349a56974cdc9bdcfd226275c43d1df2f91 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 25 Dec 2023 19:41:37 +0100 Subject: [PATCH] Updated register_types.h --- .../network_synchronizer/register_types.cpp | 42 +++++++++++-------- modules/network_synchronizer/register_types.h | 11 ++++- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/modules/network_synchronizer/register_types.cpp b/modules/network_synchronizer/register_types.cpp index 9273b9bd2..cb4fd8efd 100644 --- a/modules/network_synchronizer/register_types.cpp +++ b/modules/network_synchronizer/register_types.cpp @@ -36,31 +36,37 @@ #include "core/engine.h" #include "data_buffer.h" +#include "input_network_encoder.h" #include "networked_controller.h" #include "scene_diff.h" #include "scene_synchronizer.h" #include "scene_synchronizer_debugger.h" -#include "input_network_encoder.h" -void register_network_synchronizer_types() { - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); +void register_network_synchronizer_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) { + ClassDB::register_class(); + memnew(SceneSynchronizerDebugger); + Engine::get_singleton()->add_singleton(Engine::Singleton("SceneSynchronizerDebugger", SceneSynchronizerDebugger::singleton())); - memnew(SceneSynchronizerDebugger); - Engine::get_singleton()->add_singleton(Engine::Singleton("SceneSynchronizerDebugger", SceneSynchronizerDebugger::singleton())); + GLOBAL_DEF("NetworkSynchronizer/debug_server_speedup", false); + GLOBAL_DEF("NetworkSynchronizer/debug_doll_speedup", false); + GLOBAL_DEF("NetworkSynchronizer/log_debug_warnings_and_messages", true); + GLOBAL_DEF("NetworkSynchronizer/debugger/dump_enabled", false); + GLOBAL_DEF("NetworkSynchronizer/debugger/dump_classes", Array()); + GLOBAL_DEF("NetworkSynchronizer/debugger/log_debug_fps_warnings", true); + } - GLOBAL_DEF("NetworkSynchronizer/debug_server_speedup", false); - GLOBAL_DEF("NetworkSynchronizer/debug_doll_speedup", false); - GLOBAL_DEF("NetworkSynchronizer/log_debug_warnings_and_messages", true); - GLOBAL_DEF("NetworkSynchronizer/debugger/dump_enabled", false); - GLOBAL_DEF("NetworkSynchronizer/debugger/dump_classes", Array()); - GLOBAL_DEF("NetworkSynchronizer/debugger/log_debug_fps_warnings", true); + if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) { + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + } } -void unregister_network_synchronizer_types() { - memdelete(SceneSynchronizerDebugger::singleton()); +void unregister_network_synchronizer_types(ModuleRegistrationLevel p_level) { + if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) { + memdelete(SceneSynchronizerDebugger::singleton()); + } } diff --git a/modules/network_synchronizer/register_types.h b/modules/network_synchronizer/register_types.h index 5fdca264f..9c590a175 100644 --- a/modules/network_synchronizer/register_types.h +++ b/modules/network_synchronizer/register_types.h @@ -1,3 +1,6 @@ +#ifndef REGISTER_NETWORK_SYNCHRONIZER_TYPES_H +#define REGISTER_NETWORK_SYNCHRONIZER_TYPES_H + /*************************************************************************/ /* register_types.h */ /*************************************************************************/ @@ -32,5 +35,9 @@ @author AndreaCatania */ -void register_network_synchronizer_types(); -void unregister_network_synchronizer_types(); +#include "modules/register_module_types.h" + +void register_network_synchronizer_types(ModuleRegistrationLevel p_level); +void unregister_network_synchronizer_types(ModuleRegistrationLevel p_level); + +#endif