Core: Easy module conf creation & reload (#931)

* Change the read method of the config of the module.Developers can now easily read the config file in cmake.

e.g. AC_ADD_CONFIG_FILE("${CMAKE_CURRENT_LIST_DIR}/conf/my_first_module.conf.dist")

* Update Master.h

* Update cs_reload.cpp

Command: `.reload config` can now reload the config file of all modules #981
This commit is contained in:
ayase
2018-07-20 03:50:30 +08:00
committed by Barbz
parent 8b1f2ece8a
commit d29a1a3300
6 changed files with 85 additions and 0 deletions

View File

@@ -213,4 +213,31 @@ if( USE_COREPCH )
add_cxx_pch(worldserver ${worldserver_PCH_HDR} ${worldserver_PCH_SRC})
endif()
# handle config file
CU_GET_GLOBAL("MODULE_CONFIG_FILE_LIST")
FOREACH(configFile ${MODULE_CONFIG_FILE_LIST})
if( WIN32 )
if ( MSVC )
add_custom_command(TARGET worldserver
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${configFile}" ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
)
elseif ( MINGW )
add_custom_command(TARGET worldserver
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${configFile}" ${CMAKE_BINARY_DIR}/bin/
)
endif()
endif()
install(FILES "${configFile}" DESTINATION ${CONF_DIR})
ENDFOREACH()
CU_GET_GLOBAL("MODULE_CONFIG_FILE_LIST")
FOREACH(configFile ${MODULE_CONFIG_FILE_LIST})
get_filename_component(file_name ${configFile} NAME_WE)
set(CONFIG_LIST ${CONFIG_LIST}${file_name},)
ENDFOREACH()
add_definitions(-DCONFIG_FILE_LIST="\\"${CONFIG_LIST}\\"")
# end handle config file
CU_RUN_HOOK("AFTER_WORLDSERVER_CMAKE")

View File

@@ -153,6 +153,9 @@ int Master::Run()
// set server offline (not connectable)
LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = (flag & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID);
//set module config file list
sWorld->SetConfigFileList(CONFIG_FILE_LIST);
///- Initialize the World
sWorld->SetInitialWorldSettings();