From 29f7c4f81341b63408bbe37f1774d5fe33f65da8 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Tue, 21 May 2024 17:46:26 +0800 Subject: [PATCH] Add hot reloading support for collision code --- CMakeLists.txt | 18 +++++++++++++++--- src/external/TeeworldsBotLib | 2 +- src/game/server/entities/character.cpp | 8 +++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61826a163c9..f4efbf0867a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2621,8 +2621,7 @@ if(SERVER) ) # twbl start - set(TWBL_ROOT src/external/TeeworldsBotLib) - add_subdirectory(${TWBL_ROOT}) + set(TWBL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src/external/TeeworldsBotLib) include_directories(${TWBL_ROOT}/src) FILE(GLOB TWBL_SRC ${TWBL_ROOT}/src/shared/*.cpp @@ -2631,8 +2630,21 @@ if(SERVER) ${TWBL_ROOT}/src/bots/*.h ) - add_library(twbl_bottick SHARED ${TWBL_SRC}) + add_library(twbl_bottick_lite SHARED ${TWBL_SRC}) + target_compile_options(twbl_bottick_lite PRIVATE -std=gnu++17) + set(SERVER_SRC ${SERVER_SRC} ${TWBL_SRC}) + add_library(twbl_bottick SHARED + ${GAME_SHARED} + ${TWBL_SRC} + ${GAME_GENERATED_SHARED}) + + target_compile_options(twbl_bottick PRIVATE -std=gnu++17) + target_compile_definitions(twbl_bottick PRIVATE TWBL_SHARED_OBJECT=1) + + target_include_directories(twbl_bottick PRIVATE src) + target_include_directories(twbl_bottick PRIVATE ${PROJECT_BINARY_DIR}/src) + add_cxx_compiler_flag_if_supported(OUR_FLAGS_LINK -rdynamic) # twbl end # Target diff --git a/src/external/TeeworldsBotLib b/src/external/TeeworldsBotLib index 3a68dfafd0d..8869ec6c51a 160000 --- a/src/external/TeeworldsBotLib +++ b/src/external/TeeworldsBotLib @@ -1 +1 @@ -Subproject commit 3a68dfafd0da75fce0c5974a2afe6e6664b57792 +Subproject commit 8869ec6c51a8464b84e235827461856a298938bf diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index d2920001a0d..f66f2eded29 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -770,11 +770,17 @@ void CCharacter::Tick() if(pHandle) { BotTick(&State, &Bot); - dlclose(pHandle); + int Err = TWBL::UnloadTick(pHandle); + if(Err) + { + dbg_msg("twbl", "failed to close err=%d", Err); + } } else Twbl_SampleTick(&State, &Bot); + BotTick = nullptr; + m_SavedInput.m_Direction = Bot.m_Direction; if(g_Config.m_SvNoWeakHook)