Skip to content

Commit

Permalink
Add hot reloading support for collision code
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed May 26, 2024
1 parent d42fd36 commit 29f7c4f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/game/server/entities/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 29f7c4f

Please sign in to comment.