diff --git a/CMakeLists.txt b/CMakeLists.txt index b36bdb29..541b4266 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ endif() # Our output dir set(CMAKE_BINARY_DIR ${PROJECT_BINARY_DIR}) +#set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) # unfortunately, forces all libraries to be built in series, which will slow down the build process # TODO make this not have to override the build type directories set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}) @@ -90,6 +91,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +find_package(MariaDB) + # Create a /resServer directory make_directory(${CMAKE_BINARY_DIR}/resServer) @@ -179,7 +182,7 @@ file(ARCHIVE_EXTRACT INPUT ${PROJECT_BINARY_DIR}/navmeshes.zip DESTINATION ${PRO file(REMOVE ${PROJECT_BINARY_DIR}/navmeshes.zip) # Copy vanity files on first build -set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml") +set(VANITY_FILES "CREDITS.md" "INFO.md" "TESTAMENT.md" "root.xml" "dev-tribute.xml" "atm.xml" "demo.xml") foreach(file ${VANITY_FILES}) configure_file("${CMAKE_SOURCE_DIR}/vanity/${file}" "${CMAKE_BINARY_DIR}/vanity/${file}" COPYONLY) @@ -202,39 +205,19 @@ foreach(file ${SQL_FILES}) configure_file(${CMAKE_SOURCE_DIR}/migrations/cdserver/${file} ${PROJECT_BINARY_DIR}/migrations/cdserver/${file}) endforeach() +# Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux) +if (APPLE) + include_directories("/usr/local/include/") +endif() + +# Load all of our third party directories +add_subdirectory(thirdparty) + # Create our list of include directories set(INCLUDED_DIRECTORIES - "dCommon" - "dCommon/dClient" - "dCommon/dEnums" - - "dChatFilter" - - "dGame" - "dGame/dBehaviors" - "dGame/dComponents" - "dGame/dGameMessages" - "dGame/dInventory" - "dGame/dMission" - "dGame/dEntity" - "dGame/dPropertyBehaviors" - "dGame/dPropertyBehaviors/ControlBehaviorMessages" - "dGame/dUtilities" - "dPhysics" "dNavigation" - "dNavigation/dTerrain" - - "dZoneManager" - - "dDatabase" - "dDatabase/CDClientDatabase" - "dDatabase/CDClientDatabase/CDClientTables" - "dDatabase/GameDatabase" - "dDatabase/GameDatabase/ITables" - "dDatabase/GameDatabase/MySQL" - "dDatabase/GameDatabase/MySQL/Tables" "dNet" @@ -254,6 +237,7 @@ set(INCLUDED_DIRECTORIES ) # Add system specfic includes for Apple, Windows and Other Unix OS' (including Linux) +# TODO: Should probably not do this. if(APPLE) include_directories("/usr/local/include/") endif() @@ -263,30 +247,10 @@ foreach(dir ${INCLUDED_DIRECTORIES}) include_directories(${PROJECT_SOURCE_DIR}/${dir}) endforeach() -if(NOT WIN32) - include_directories("${PROJECT_SOURCE_DIR}/thirdparty/libbcrypt/include/bcrypt") -endif() - -include_directories("${PROJECT_SOURCE_DIR}/thirdparty/libbcrypt/include") - # Add linking directories: -link_directories(${PROJECT_BINARY_DIR}) - -# Load all of our third party directories -add_subdirectory(thirdparty) if (UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") endif() -# Glob together all headers that need to be precompiled -file( - GLOB HEADERS_DDATABASE - LIST_DIRECTORIES false - ${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase/*.h - ${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase/CDClientTables/*.h - ${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase/ITables/*.h - ${PROJECT_SOURCE_DIR}/thirdparty/SQLite/*.h -) - file( GLOB HEADERS_DZONEMANAGER LIST_DIRECTORIES false @@ -321,7 +285,7 @@ add_subdirectory(dPhysics) add_subdirectory(dServer) # Create a list of common libraries shared between all binaries -set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "mariadbConnCpp" "magic_enum" "MD5") +set(COMMON_LIBRARIES "dCommon" "dDatabase" "dNet" "raknet" "MariaDB::ConnCpp" "magic_enum") # Add platform specific common libraries if(UNIX) @@ -343,12 +307,6 @@ target_precompile_headers( ${HEADERS_DZONEMANAGER} ) -# Need to specify to use the CXX compiler language here or else we get errors including . -target_precompile_headers( - dDatabase PRIVATE - "$<$:${HEADERS_DDATABASE}>" -) - target_precompile_headers( dCommon PRIVATE ${HEADERS_DCOMMON} diff --git a/Dockerfile b/Dockerfile index c1316a60..efb82b42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,8 +23,7 @@ RUN --mount=type=cache,id=build-apt-cache,target=/var/cache/apt \ rm -rf /var/lib/apt/lists/* # Grab libraries and load them -COPY --from=build /app/build/mariadbcpp/src/mariadb_connector_cpp-build/libmariadbcpp.so /usr/local/lib/ -COPY --from=build /app/build/mariadbcpp/src/mariadb_connector_cpp-build/libmariadb/libmariadb/libmariadb.so.3 /usr/local/lib +COPY --from=build /app/build/mariadbcpp/libmariadbcpp.so /usr/local/lib/ RUN ldconfig # Server bins diff --git a/cmake/FindGoogleTest.cmake b/cmake/FindGoogleTest.cmake new file mode 100644 index 00000000..69d16247 --- /dev/null +++ b/cmake/FindGoogleTest.cmake @@ -0,0 +1,17 @@ +include(FetchContent) + +message(STATUS "Fetching gtest...") + +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.12.1 +) + +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +FetchContent_MakeAvailable(GoogleTest) + +message(STATUS "gtest fetched and is now ready.") +set(GoogleTest_FOUND TRUE) diff --git a/thirdparty/CMakeMariaDBLists.txt b/cmake/FindMariaDB.cmake similarity index 58% rename from thirdparty/CMakeMariaDBLists.txt rename to cmake/FindMariaDB.cmake index d7a17f28..f42ac47b 100644 --- a/thirdparty/CMakeMariaDBLists.txt +++ b/cmake/FindMariaDB.cmake @@ -23,14 +23,14 @@ if(WIN32 AND NOT MARIADB_BUILD_SOURCE) set(MARIADB_CONNECTOR_CPP_MSI "mariadb-connector-cpp-${MARIADB_CONNECTOR_CPP_VERSION}-win64.msi") if(NOT EXISTS "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_C_MSI}" ) - message("Downloading mariadb connector/c") + message(STATUS "Downloading mariadb connector/c") file(DOWNLOAD https://dlm.mariadb.com/${MARIADB_CONNECTOR_C_BUCKET}/Connectors/c/connector-c-${MARIADB_CONNECTOR_C_VERSION}/${MARIADB_CONNECTOR_C_MSI} "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_C_MSI}" EXPECTED_HASH MD5=${MARIADB_CONNECTOR_C_MD5}) endif() if(NOT EXISTS "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_CPP_MSI}" ) - message("Downloading mariadb connector/c++") + message(STATUS "Downloading mariadb connector/c++") file(DOWNLOAD https://dlm.mariadb.com/${MARIADB_CONNECTOR_CPP_BUCKET}/Connectors/cpp/connector-cpp-${MARIADB_CONNECTOR_CPP_VERSION}/${MARIADB_CONNECTOR_CPP_MSI} "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_CPP_MSI}" EXPECTED_HASH MD5=${MARIADB_CONNECTOR_CPP_MD5}) @@ -43,27 +43,28 @@ if(WIN32 AND NOT MARIADB_BUILD_SOURCE) file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_C_MSI}" MSI_DIR) execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR}) endif() + set(MARIADBC_SHARED_LIBRARY_LOCATION "${MARIADB_C_CONNECTOR_DIR}/lib/libmariadb.dll") if(NOT EXISTS "${MARIADB_CPP_CONNECTOR_DIR}") file(TO_NATIVE_PATH "${MARIADB_MSI_DIR}/${MARIADB_CONNECTOR_CPP_MSI}" MSI_DIR) execute_process(COMMAND msiexec /a ${MSI_DIR} /qn TARGETDIR=${MSIEXEC_TARGETDIR}) endif() - set(MARIADB_SHARED_LIBRARY_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll") + set(MARIADBCPP_SHARED_LIBRARY_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll") set(MARIADB_IMPLIB_LOCATION "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.lib") set(MARIADB_INCLUDE_DIR "${MARIADB_CPP_CONNECTOR_DIR}/include/mariadb") add_custom_target(mariadb_connector_cpp) add_custom_command(TARGET mariadb_connector_cpp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${MARIADB_CPP_CONNECTOR_DIR}/mariadbcpp.dll" - "${MARIADB_C_CONNECTOR_DIR}/lib/libmariadb.dll" + "${MARIADBCPP_SHARED_LIBRARY_LOCATION}" + "${MARIADBC_SHARED_LIBRARY_LOCATION}" "${PROJECT_BINARY_DIR}") # MariaDB uses plugins that the database needs to load, the prebuilt binaries by default will try to find the libraries in system directories, # so set this define and the servers will set the MARIADB_PLUGIN_DIR environment variable to the appropriate directory. # Plugin directory is determined at dll load time (this will happen before main()) so we need to delay the dll load so that we can set the environment variable - add_link_options(/DELAYLOAD:${MARIADB_SHARED_LIBRARY_LOCATION}) + add_link_options(/DELAYLOAD:${MARIADBCPP_SHARED_LIBRARY_LOCATION}) add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${MARIADB_CPP_CONNECTOR_DIR}/plugin") else() # Build from source @@ -85,77 +86,61 @@ else() # Build from source -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0) endif() + set(MARIADBCPP_INSTALL_DIR ${PROJECT_BINARY_DIR}/prefix) + set(MARIADBCPP_LIBRARY_DIR ${PROJECT_BINARY_DIR}/mariadbcpp) + set(MARIADBCPP_PLUGIN_DIR ${MARIADBCPP_LIBRARY_DIR}/plugin) + set(MARIADBCPP_SOURCE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp) + set(MARIADB_INCLUDE_DIR "${MARIADBCPP_SOURCE_DIR}/include") ExternalProject_Add(mariadb_connector_cpp - SOURCE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp - CMAKE_ARGS -Wno-dev - -DCMAKE_BUILD_RPATH_USE_ORIGIN=${CMAKE_BUILD_RPATH_USE_ORIGIN} - -DCMAKE_INSTALL_PREFIX=./mariadbcpp # Points the connector to the correct plugin directory - -DINSTALL_PLUGINDIR=plugin - ${MARIADB_EXTRA_CMAKE_ARGS} - PREFIX "${PROJECT_BINARY_DIR}/mariadbcpp" - BUILD_COMMAND cmake --build . --config RelWithDebInfo -j${MARIADB_CONNECTOR_COMPILE_JOBS} - INSTALL_COMMAND "") - - ExternalProject_Get_Property(mariadb_connector_cpp BINARY_DIR) + PREFIX "${PROJECT_BINARY_DIR}/thirdparty/mariadb-connector-cpp" + SOURCE_DIR ${MARIADBCPP_SOURCE_DIR} + INSTALL_DIR ${MARIADBCPP_INSTALL_DIR} + CMAKE_ARGS -Wno-dev + -DWITH_UNIT_TESTS=OFF + -DMARIADB_LINK_DYNAMIC=OFF + -DCMAKE_BUILD_RPATH_USE_ORIGIN=${CMAKE_BUILD_RPATH_USE_ORIGIN} + -DCMAKE_INSTALL_PREFIX= + -DINSTALL_LIBDIR=${MARIADBCPP_LIBRARY_DIR} + -DINSTALL_PLUGINDIR=${MARIADBCPP_PLUGIN_DIR} + ${MARIADB_EXTRA_CMAKE_ARGS} + BUILD_ALWAYS true + ) if(WIN32) set(MARIADB_SHARED_LIBRARY_NAME mariadbcpp.dll) set(MARIADB_PLUGIN_SUFFIX .dll) - set(MARIADB_IMPLIB_LOCATION "${BINARY_DIR}/RelWithDebInfo/mariadbcpp.lib") + set(MARIADB_IMPLIB_LOCATION "${MARIADBCPP_LIBRARY_DIR}/mariadbcpp.lib") # When built from source windows only seems to check same folder as exe instead specified folder, so use # environment variable to force it add_link_options(/DELAYLOAD:mariadbcpp.dll) - add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${PROJECT_BINARY_DIR}/mariadbcpp/plugin") + add_compile_definitions(MARIADB_PLUGIN_DIR_OVERRIDE="${MARIADBCPP_PLUGIN_DIR}") else() set(MARIADB_SHARED_LIBRARY_NAME libmariadbcpp${CMAKE_SHARED_LIBRARY_SUFFIX}) - set(MARIADB_PLUGIN_SUFFIX .so) + set(MARIADB_PLUGIN_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() - get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) - if(isMultiConfig) - set(MARIADB_SHARED_LIBRARY_LOCATION "${BINARY_DIR}/RelWithDebInfo/${MARIADB_SHARED_LIBRARY_NAME}") - set(MARIADB_SHARED_LIBRARY_COPY_LOCATION "${PROJECT_BINARY_DIR}/$") - set(MARIADB_PLUGINS_LOCATION "${BINARY_DIR}/libmariadb/RelWithDebInfo") - else() - set(MARIADB_SHARED_LIBRARY_LOCATION "${BINARY_DIR}/${MARIADB_SHARED_LIBRARY_NAME}") - set(MARIADB_SHARED_LIBRARY_COPY_LOCATION "${PROJECT_BINARY_DIR}") - set(MARIADB_PLUGINS_LOCATION "${BINARY_DIR}/libmariadb") + set(MARIADBCPP_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/${MARIADB_SHARED_LIBRARY_NAME}") + if(WIN32) + set(MARIADBC_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/libmariadb.lib") endif() - - set(MARIADB_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/include/") - - add_custom_command(TARGET mariadb_connector_cpp POST_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory - ${BINARY_DIR}/mariadbcpp/plugin - ${MARIADB_SHARED_LIBRARY_COPY_LOCATION} - - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${MARIADB_SHARED_LIBRARY_LOCATION} - ${MARIADB_SHARED_LIBRARY_COPY_LOCATION} - - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${MARIADB_PLUGINS_LOCATION}/caching_sha2_password${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/client_ed25519${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/dialog${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/mysql_clear_password${MARIADB_PLUGIN_SUFFIX} - ${MARIADB_PLUGINS_LOCATION}/sha256_password${MARIADB_PLUGIN_SUFFIX} - ${BINARY_DIR}/mariadbcpp/plugin) -endif() - -# Remove the CMakeLists.txt file from the tests folder for the maria-db-connector so we dont compile the tests. -if(EXISTS "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/test/CMakeLists.txt") - file(REMOVE "${CMAKE_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/test/CMakeLists.txt") endif() # Create mariadb connector library object -add_library(mariadbConnCpp SHARED IMPORTED GLOBAL) -set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_LOCATION ${MARIADB_SHARED_LIBRARY_LOCATION}) +add_library(MariaDB::ConnCpp SHARED IMPORTED GLOBAL) +add_dependencies(MariaDB::ConnCpp mariadb_connector_cpp) +set_target_properties(MariaDB::ConnCpp PROPERTIES + IMPORTED_LOCATION "${MARIADBCPP_SHARED_LIBRARY_LOCATION}") if(WIN32) - set_property(TARGET mariadbConnCpp PROPERTY IMPORTED_IMPLIB ${MARIADB_IMPLIB_LOCATION}) + set_target_properties(MariaDB::ConnCpp PROPERTIES + IMPORTED_IMPLIB "${MARIADB_IMPLIB_LOCATION}") +elseif(APPLE) + set_target_properties(MariaDB::ConnCpp PROPERTIES + IMPORTED_SONAME "libmariadbcpp") endif() # Add directories to include lists -target_include_directories(mariadbConnCpp INTERFACE ${MARIADB_INCLUDE_DIR}) -add_dependencies(mariadbConnCpp mariadb_connector_cpp) +target_include_directories(MariaDB::ConnCpp INTERFACE ${MARIADB_INCLUDE_DIR}) + +set(MariaDB_FOUND TRUE) diff --git a/dChatServer/CMakeLists.txt b/dChatServer/CMakeLists.txt index cc4cee1f..c7eea041 100644 --- a/dChatServer/CMakeLists.txt +++ b/dChatServer/CMakeLists.txt @@ -5,10 +5,12 @@ set(DCHATSERVER_SOURCES ) add_executable(ChatServer "ChatServer.cpp") -add_library(dChatServer ${DCHATSERVER_SOURCES}) -target_include_directories(dChatServer PRIVATE ${PROJECT_SOURCE_DIR}/dServer) +target_include_directories(ChatServer PRIVATE "${PROJECT_SOURCE_DIR}/dChatFilter") add_compile_definitions(ChatServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") +add_library(dChatServer ${DCHATSERVER_SOURCES}) +target_include_directories(dChatServer PRIVATE "${PROJECT_SOURCE_DIR}/dServer") + target_link_libraries(dChatServer ${COMMON_LIBRARIES} dChatFilter) target_link_libraries(ChatServer ${COMMON_LIBRARIES} dChatFilter dChatServer dServer) diff --git a/dChatServer/ChatServer.cpp b/dChatServer/ChatServer.cpp index 9ba70026..84104726 100644 --- a/dChatServer/ChatServer.cpp +++ b/dChatServer/ChatServer.cpp @@ -101,7 +101,7 @@ int main(int argc, char** argv) { //It's safe to pass 'localhost' here, as the IP is only used as the external IP. std::string ourIP = "localhost"; const uint32_t maxClients = GeneralUtils::TryParse(Game::config->GetValue("max_clients")).value_or(999); - const uint32_t ourPort = GeneralUtils::TryParse(Game::config->GetValue("chat_server_port")).value_or(1501); + const uint32_t ourPort = GeneralUtils::TryParse(Game::config->GetValue("chat_server_port")).value_or(2005); const auto externalIPString = Game::config->GetValue("external_ip"); if (!externalIPString.empty()) ourIP = externalIPString; diff --git a/dCommon/CMakeLists.txt b/dCommon/CMakeLists.txt index c5fff63a..d020ff72 100644 --- a/dCommon/CMakeLists.txt +++ b/dCommon/CMakeLists.txt @@ -30,11 +30,15 @@ foreach(file ${DCOMMON_DCLIENT_SOURCES}) set(DCOMMON_SOURCES ${DCOMMON_SOURCES} "dClient/${file}") endforeach() -include_directories(${PROJECT_SOURCE_DIR}/dCommon/) - add_library(dCommon STATIC ${DCOMMON_SOURCES}) - -target_link_libraries(dCommon bcrypt dDatabase tinyxml2) +target_include_directories(dCommon + PUBLIC "." "dClient" "dEnums" + PRIVATE + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase/ITables" + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase" + "${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/include" +) if (UNIX) find_package(ZLIB REQUIRED) @@ -65,4 +69,6 @@ else () ) endif () -target_link_libraries(dCommon ZLIB::ZLIB) +target_link_libraries(dCommon + PRIVATE ZLIB::ZLIB bcrypt tinyxml2 + INTERFACE dDatabase) diff --git a/dCommon/PositionUpdate.h b/dCommon/PositionUpdate.h index 4d591a97..f28c682d 100644 --- a/dCommon/PositionUpdate.h +++ b/dCommon/PositionUpdate.h @@ -6,28 +6,14 @@ struct RemoteInputInfo { - RemoteInputInfo() { - m_RemoteInputX = 0; - m_RemoteInputY = 0; - m_IsPowersliding = false; - m_IsModified = false; - } - - void operator=(const RemoteInputInfo& other) { - m_RemoteInputX = other.m_RemoteInputX; - m_RemoteInputY = other.m_RemoteInputY; - m_IsPowersliding = other.m_IsPowersliding; - m_IsModified = other.m_IsModified; - } - bool operator==(const RemoteInputInfo& other) { return m_RemoteInputX == other.m_RemoteInputX && m_RemoteInputY == other.m_RemoteInputY && m_IsPowersliding == other.m_IsPowersliding && m_IsModified == other.m_IsModified; } - float m_RemoteInputX; - float m_RemoteInputY; - bool m_IsPowersliding; - bool m_IsModified; + float m_RemoteInputX = 0; + float m_RemoteInputY = 0; + bool m_IsPowersliding = false; + bool m_IsModified = false; }; struct LocalSpaceInfo { diff --git a/dDatabase/CDClientDatabase/CMakeLists.txt b/dDatabase/CDClientDatabase/CMakeLists.txt index 2645c215..13d59ffb 100644 --- a/dDatabase/CDClientDatabase/CMakeLists.txt +++ b/dDatabase/CDClientDatabase/CMakeLists.txt @@ -9,4 +9,28 @@ foreach(file ${DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES}) set(DDATABASE_CDCLIENTDATABASE_SOURCES ${DDATABASE_CDCLIENTDATABASE_SOURCES} "CDClientTables/${file}") endforeach() -set(DDATABASE_CDCLIENTDATABASE_SOURCES ${DDATABASE_CDCLIENTDATABASE_SOURCES} PARENT_SCOPE) +add_library(dDatabaseCDClient STATIC ${DDATABASE_CDCLIENTDATABASE_SOURCES}) +target_include_directories(dDatabaseCDClient PUBLIC "." + "CDClientTables" + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" +) +target_link_libraries(dDatabaseCDClient PRIVATE sqlite3) + +if (${CDCLIENT_CACHE_ALL}) + add_compile_definitions(dDatabaseCDClient PRIVATE CDCLIENT_CACHE_ALL=${CDCLIENT_CACHE_ALL}) +endif() + +file( + GLOB HEADERS_DDATABASE_CDCLIENT + LIST_DIRECTORIES false + ${PROJECT_SOURCE_DIR}/thirdparty/SQLite/*.h + CDClientTables/*.h + *.h +) + +# Need to specify to use the CXX compiler language here or else we get errors including . +target_precompile_headers( + dDatabaseCDClient PRIVATE + "$<$:${HEADERS_DDATABASE_CDCLIENT}>" +) diff --git a/dDatabase/CMakeLists.txt b/dDatabase/CMakeLists.txt index f0fe54b4..004bdc14 100644 --- a/dDatabase/CMakeLists.txt +++ b/dDatabase/CMakeLists.txt @@ -1,20 +1,7 @@ -set(DDATABASE_SOURCES) - add_subdirectory(CDClientDatabase) - -foreach(file ${DDATABASE_CDCLIENTDATABASE_SOURCES}) - set(DDATABASE_SOURCES ${DDATABASE_SOURCES} "CDClientDatabase/${file}") -endforeach() - add_subdirectory(GameDatabase) -foreach(file ${DDATABASE_GAMEDATABASE_SOURCES}) - set(DDATABASE_SOURCES ${DDATABASE_SOURCES} "GameDatabase/${file}") -endforeach() - -add_library(dDatabase STATIC ${DDATABASE_SOURCES}) -target_link_libraries(dDatabase sqlite3 mariadbConnCpp) - -if (${CDCLIENT_CACHE_ALL}) - add_compile_definitions(dDatabase CDCLIENT_CACHE_ALL=${CDCLIENT_CACHE_ALL}) -endif() +add_library(dDatabase STATIC "MigrationRunner.cpp") +target_include_directories(dDatabase PUBLIC ".") +target_link_libraries(dDatabase + PUBLIC dDatabaseCDClient dDatabaseGame) diff --git a/dDatabase/GameDatabase/CMakeLists.txt b/dDatabase/GameDatabase/CMakeLists.txt index c32007bb..09ca7251 100644 --- a/dDatabase/GameDatabase/CMakeLists.txt +++ b/dDatabase/GameDatabase/CMakeLists.txt @@ -1,6 +1,5 @@ set(DDATABASE_GAMEDATABASE_SOURCES "Database.cpp" - "MigrationRunner.cpp" ) add_subdirectory(MySQL) @@ -9,4 +8,25 @@ foreach(file ${DDATABSE_DATABSES_MYSQL_SOURCES}) set(DDATABASE_GAMEDATABASE_SOURCES ${DDATABASE_GAMEDATABASE_SOURCES} "MySQL/${file}") endforeach() -set(DDATABASE_GAMEDATABASE_SOURCES ${DDATABASE_GAMEDATABASE_SOURCES} PARENT_SCOPE) +add_library(dDatabaseGame STATIC ${DDATABASE_GAMEDATABASE_SOURCES}) +target_include_directories(dDatabaseGame PUBLIC "." + "ITables" PRIVATE "MySQL" + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" +) +target_link_libraries(dDatabaseGame + PUBLIC MariaDB::ConnCpp + INTERFACE dCommon) + +# Glob together all headers that need to be precompiled +file( + GLOB HEADERS_DDATABASE_GAME + LIST_DIRECTORIES false + ITables/*.h +) + +# Need to specify to use the CXX compiler language here or else we get errors including . +target_precompile_headers( + dDatabaseGame PRIVATE + "$<$:${HEADERS_DDATABASE_GAME}>" +) diff --git a/dDatabase/GameDatabase/ITables/IAccounts.h b/dDatabase/GameDatabase/ITables/IAccounts.h index 1b1f85a7..3f27dda6 100644 --- a/dDatabase/GameDatabase/ITables/IAccounts.h +++ b/dDatabase/GameDatabase/ITables/IAccounts.h @@ -3,6 +3,7 @@ #include #include +#include #include enum class eGameMasterLevel : uint8_t; diff --git a/dDatabase/GameDatabase/MigrationRunner.cpp b/dDatabase/MigrationRunner.cpp similarity index 100% rename from dDatabase/GameDatabase/MigrationRunner.cpp rename to dDatabase/MigrationRunner.cpp diff --git a/dDatabase/GameDatabase/MigrationRunner.h b/dDatabase/MigrationRunner.h similarity index 100% rename from dDatabase/GameDatabase/MigrationRunner.h rename to dDatabase/MigrationRunner.h diff --git a/dGame/CMakeLists.txt b/dGame/CMakeLists.txt index 627f163a..26eb859a 100644 --- a/dGame/CMakeLists.txt +++ b/dGame/CMakeLists.txt @@ -13,11 +13,25 @@ include_directories( ${PROJECT_SOURCE_DIR}/dGame ) -add_library(dGameBase ${DGAME_SOURCES}) +add_library(dGameBase OBJECT ${DGAME_SOURCES}) target_precompile_headers(dGameBase PRIVATE ${HEADERS_DGAME}) -target_link_libraries(dGameBase - PUBLIC dDatabase dPhysics - INTERFACE dComponents dEntity) +target_include_directories(dGameBase PUBLIC "." "dEntity" + PRIVATE "dComponents" "dGameMessages" "dBehaviors" "dMission" "dUtilities" "dInventory" + $ + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" + "${PROJECT_SOURCE_DIR}/dCommon/dClient" + # dDatabase + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase/CDClientTables" + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase/ITables" + "${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/include" + # dPhysics + "${PROJECT_SOURCE_DIR}/thirdparty/recastnavigation/Recast/Include" + "${PROJECT_SOURCE_DIR}/thirdparty/recastnavigation/Detour/Include" + "${PROJECT_SOURCE_DIR}/dZoneManager" +) add_subdirectory(dBehaviors) add_subdirectory(dComponents) @@ -28,7 +42,26 @@ add_subdirectory(dMission) add_subdirectory(dPropertyBehaviors) add_subdirectory(dUtilities) -add_library(dGame INTERFACE) -target_link_libraries(dGame INTERFACE - dGameBase dBehaviors dComponents dEntity dGameMessages dInventory dMission dPropertyBehaviors dUtilities dScripts +add_library(dGame STATIC + $ + $ + $ + $ + $ + $ + $ + $ + $ +) +target_link_libraries(dGame INTERFACE dNet) +target_include_directories(dGame INTERFACE + $ + $ + $ + $ + $ + $ + $ + $ + $ ) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 55b2b85f..9af811bc 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -841,11 +841,9 @@ bool Entity::HasComponent(const eReplicaComponentType componentId) const { std::vector Entity::GetScriptComponents() { std::vector comps; - for (std::pair p : m_Components) { - if (p.first == eReplicaComponentType::SCRIPT) { - comps.push_back(static_cast(p.second)); - } - } + + auto* scriptComponent = GetComponent(); + if (scriptComponent) comps.push_back(scriptComponent); return comps; } @@ -2126,9 +2124,7 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) { havokVehiclePhysicsComponent->SetIsOnGround(update.onGround); havokVehiclePhysicsComponent->SetIsOnRail(update.onRail); havokVehiclePhysicsComponent->SetVelocity(update.velocity); - havokVehiclePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO); havokVehiclePhysicsComponent->SetAngularVelocity(update.angularVelocity); - havokVehiclePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO); havokVehiclePhysicsComponent->SetRemoteInputInfo(update.remoteInputInfo); } else { // Need to get the mount's controllable physics @@ -2139,9 +2135,7 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) { possessedControllablePhysicsComponent->SetIsOnGround(update.onGround); possessedControllablePhysicsComponent->SetIsOnRail(update.onRail); possessedControllablePhysicsComponent->SetVelocity(update.velocity); - possessedControllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO); possessedControllablePhysicsComponent->SetAngularVelocity(update.angularVelocity); - possessedControllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO); } Game::entityManager->SerializeEntity(possassableEntity); } @@ -2163,9 +2157,7 @@ void Entity::ProcessPositionUpdate(PositionUpdate& update) { controllablePhysicsComponent->SetIsOnGround(update.onGround); controllablePhysicsComponent->SetIsOnRail(update.onRail); controllablePhysicsComponent->SetVelocity(update.velocity); - controllablePhysicsComponent->SetDirtyVelocity(update.velocity != NiPoint3Constant::ZERO); controllablePhysicsComponent->SetAngularVelocity(update.angularVelocity); - controllablePhysicsComponent->SetDirtyAngularVelocity(update.angularVelocity != NiPoint3Constant::ZERO); auto* ghostComponent = GetComponent(); if (ghostComponent) ghostComponent->SetGhostReferencePoint(update.position); @@ -2197,9 +2189,3 @@ void Entity::SetRespawnRot(const NiQuaternion& rotation) { auto* characterComponent = GetComponent(); if (characterComponent) characterComponent->SetRespawnRot(rotation); } - -void Entity::SetScale(const float scale) { - if (scale == m_Scale) return; - m_Scale = scale; - Game::entityManager->SerializeEntity(this); -} \ No newline at end of file diff --git a/dGame/Entity.h b/dGame/Entity.h index 711e0b63..a2d4d132 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -295,7 +295,8 @@ public: void ProcessPositionUpdate(PositionUpdate& update); - void SetScale(const float scale); + // Scale will only be communicated to the client when the construction packet is sent + void SetScale(const float scale) { m_Scale = scale; }; protected: LWOOBJID m_ObjectID; diff --git a/dGame/dBehaviors/CMakeLists.txt b/dGame/dBehaviors/CMakeLists.txt index c8cb0be0..f00ba7e2 100644 --- a/dGame/dBehaviors/CMakeLists.txt +++ b/dGame/dBehaviors/CMakeLists.txt @@ -21,7 +21,6 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp" "DamageReductionBehavior.cpp" "DarkInspirationBehavior.cpp" "DurationBehavior.cpp" - "EmptyBehavior.cpp" "EndBehavior.cpp" "FallSpeedBehavior.cpp" "ForceMovementBehavior.cpp" @@ -56,7 +55,15 @@ set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp" "VentureVisionBehavior.cpp" "VerifyBehavior.cpp") -add_library(dBehaviors STATIC ${DGAME_DBEHAVIORS_SOURCES}) -target_link_libraries(dBehaviors PUBLIC dPhysics) -target_include_directories(dBehaviors PUBLIC ".") +add_library(dBehaviors OBJECT ${DGAME_DBEHAVIORS_SOURCES}) +target_link_libraries(dBehaviors PUBLIC dDatabaseCDClient dPhysics) +target_include_directories(dBehaviors PUBLIC "." + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # via BehaviorContext.h + PRIVATE + "${PROJECT_SOURCE_DIR}/dGame/dComponents" # direct BuffComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # Preconditions.h via QuickBuildComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager.h, Spawner.h + "${PROJECT_SOURCE_DIR}/dGame/dInventory" # via CharacterComponent.h + "${PROJECT_SOURCE_DIR}/dZoneManager" # via BasicAttackBehavior.cpp +) target_precompile_headers(dBehaviors REUSE_FROM dGameBase) diff --git a/dGame/dBehaviors/EmptyBehavior.cpp b/dGame/dBehaviors/EmptyBehavior.cpp deleted file mode 100644 index 8828f5de..00000000 --- a/dGame/dBehaviors/EmptyBehavior.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "EmptyBehavior.h" - diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index 21fe9207..9c58a0ea 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -50,9 +50,32 @@ set(DGAME_DCOMPONENTS_SOURCES "MiniGameControlComponent.cpp" ) -add_library(dComponents STATIC ${DGAME_DCOMPONENTS_SOURCES}) -target_include_directories(dComponents PRIVATE ${PROJECT_SOURCE_DIR}/dScripts/02_server/Map/General) # PetDigServer.h +add_library(dComponents OBJECT ${DGAME_DCOMPONENTS_SOURCES}) +target_include_directories(dComponents PUBLIC "." + "${PROJECT_SOURCE_DIR}/dGame/dPropertyBehaviors" # via ModelComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dPropertyBehaviors/ControlBehaviorMessages" + "${PROJECT_SOURCE_DIR}/dGame/dMission" # via MissionComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # via InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dInventory" # via InventoryComponent.h + PRIVATE + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase/CDClientTables" + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase/ITables" + "${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/include" + # dPhysics (via dpWorld.h) + "${PROJECT_SOURCE_DIR}/thirdparty/recastnavigation/Recast/Include" + "${PROJECT_SOURCE_DIR}/thirdparty/recastnavigation/Detour/Include" + + "${PROJECT_SOURCE_DIR}/dScripts/02_server/Map/General" # PetDigServer.h + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # direct + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # direct Loot.h + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager/Spawner.h + "${PROJECT_SOURCE_DIR}/dZoneManager" # via BouncerComponent.cpp, ActivityComponent.cpp + "${PROJECT_SOURCE_DIR}/dChatFilter" # via PetComponent.cpp +) target_precompile_headers(dComponents REUSE_FROM dGameBase) -target_link_libraries(dComponents - PUBLIC dPhysics dDatabase - INTERFACE dUtilities dCommon dBehaviors dChatFilter dMission dInventory) + +target_link_libraries(dComponents INTERFACE dBehaviors) diff --git a/dGame/dComponents/CharacterComponent.h b/dGame/dComponents/CharacterComponent.h index 797347ed..aa5c2e29 100644 --- a/dGame/dComponents/CharacterComponent.h +++ b/dGame/dComponents/CharacterComponent.h @@ -5,7 +5,6 @@ #include "RakNetTypes.h" #include "Character.h" #include "Component.h" -#include "Item.h" #include #include "CDMissionsTable.h" #include "tinyxml2.h" @@ -15,6 +14,8 @@ enum class eGameActivity : uint32_t; +class Item; + /** * The statistics that can be achieved per zone */ diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index daa14ac3..99b51af8 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -21,8 +21,6 @@ ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Phy m_InJetpackMode = false; m_IsOnGround = true; m_IsOnRail = false; - m_DirtyVelocity = true; - m_DirtyAngularVelocity = true; m_dpEntity = nullptr; m_Static = false; m_SpeedMultiplier = 1; @@ -135,26 +133,28 @@ void ControllablePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bo outBitStream.Write(m_IsOnGround); outBitStream.Write(m_IsOnRail); - outBitStream.Write(m_DirtyVelocity); - if (m_DirtyVelocity) { + bool isNotZero = m_Velocity != NiPoint3Constant::ZERO; + outBitStream.Write(isNotZero); + if (isNotZero) { outBitStream.Write(m_Velocity.x); outBitStream.Write(m_Velocity.y); outBitStream.Write(m_Velocity.z); } - outBitStream.Write(m_DirtyAngularVelocity); - if (m_DirtyAngularVelocity) { + isNotZero = m_AngularVelocity != NiPoint3Constant::ZERO; + outBitStream.Write(isNotZero); + if (isNotZero) { outBitStream.Write(m_AngularVelocity.x); outBitStream.Write(m_AngularVelocity.y); outBitStream.Write(m_AngularVelocity.z); } outBitStream.Write0(); - } - - if (!bIsInitialUpdate) { - outBitStream.Write(m_IsTeleporting); - m_IsTeleporting = false; + if (!bIsInitialUpdate) { + m_DirtyPosition = false; + outBitStream.Write(m_IsTeleporting); + m_IsTeleporting = false; + } } } @@ -211,33 +211,29 @@ void ControllablePhysicsComponent::SetRotation(const NiQuaternion& rot) { } void ControllablePhysicsComponent::SetVelocity(const NiPoint3& vel) { - if (m_Static) { - return; - } + if (m_Static || m_Velocity == vel) return; m_Velocity = vel; m_DirtyPosition = true; - m_DirtyVelocity = true; if (m_dpEntity) m_dpEntity->SetVelocity(vel); } void ControllablePhysicsComponent::SetAngularVelocity(const NiPoint3& vel) { - if (m_Static) { - return; - } + if (m_Static || m_AngularVelocity == vel) return; m_AngularVelocity = vel; m_DirtyPosition = true; - m_DirtyAngularVelocity = true; } void ControllablePhysicsComponent::SetIsOnGround(bool val) { + if (m_IsOnGround == val) return; m_DirtyPosition = true; m_IsOnGround = val; } void ControllablePhysicsComponent::SetIsOnRail(bool val) { + if (m_IsOnRail == val) return; m_DirtyPosition = true; m_IsOnRail = val; } @@ -245,15 +241,6 @@ void ControllablePhysicsComponent::SetIsOnRail(bool val) { void ControllablePhysicsComponent::SetDirtyPosition(bool val) { m_DirtyPosition = val; } - -void ControllablePhysicsComponent::SetDirtyVelocity(bool val) { - m_DirtyVelocity = val; -} - -void ControllablePhysicsComponent::SetDirtyAngularVelocity(bool val) { - m_DirtyAngularVelocity = val; -} - void ControllablePhysicsComponent::AddPickupRadiusScale(float value) { m_ActivePickupRadiusScales.push_back(value); if (value > m_PickupRadius) { @@ -309,7 +296,7 @@ void ControllablePhysicsComponent::RemoveSpeedboost(float value) { Game::entityManager->SerializeEntity(m_Parent); } -void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims){ +void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bool specialAnims) { if (m_IsInBubble) { LOG("Already in bubble"); return; @@ -321,7 +308,7 @@ void ControllablePhysicsComponent::ActivateBubbleBuff(eBubbleType bubbleType, bo Game::entityManager->SerializeEntity(m_Parent); } -void ControllablePhysicsComponent::DeactivateBubbleBuff(){ +void ControllablePhysicsComponent::DeactivateBubbleBuff() { m_DirtyBubble = true; m_IsInBubble = false; Game::entityManager->SerializeEntity(m_Parent); @@ -336,9 +323,9 @@ void ControllablePhysicsComponent::SetStunImmunity( const bool bImmuneToStunJump, const bool bImmuneToStunMove, const bool bImmuneToStunTurn, - const bool bImmuneToStunUseItem){ + const bool bImmuneToStunUseItem) { - if (state == eStateChangeType::POP){ + if (state == eStateChangeType::POP) { if (bImmuneToStunAttack && m_ImmuneToStunAttackCount > 0) m_ImmuneToStunAttackCount -= 1; if (bImmuneToStunEquip && m_ImmuneToStunEquipCount > 0) m_ImmuneToStunEquipCount -= 1; if (bImmuneToStunInteract && m_ImmuneToStunInteractCount > 0) m_ImmuneToStunInteractCount -= 1; diff --git a/dGame/dComponents/ControllablePhysicsComponent.h b/dGame/dComponents/ControllablePhysicsComponent.h index 313f80de..a0cc6aef 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.h +++ b/dGame/dComponents/ControllablePhysicsComponent.h @@ -104,18 +104,6 @@ public: */ void SetDirtyPosition(bool val); - /** - * Mark the velocity as dirty, forcing a serializtion update next tick - * @param val whether or not the velocity is dirty - */ - void SetDirtyVelocity(bool val); - - /** - * Mark the angular velocity as dirty, forcing a serialization update next tick - * @param val whether or not the angular velocity is dirty - */ - void SetDirtyAngularVelocity(bool val); - /** * Sets whether or not the entity is currently wearing a jetpack * @param val whether or not the entity is currently wearing a jetpack @@ -310,21 +298,11 @@ private: */ dpEntity* m_dpEntity; - /** - * Whether or not the velocity is dirty, forcing a serialization of the velocity - */ - bool m_DirtyVelocity; - /** * The current velocity of the entity */ NiPoint3 m_Velocity; - /** - * Whether or not the angular velocity is dirty, forcing a serialization - */ - bool m_DirtyAngularVelocity; - /** * The current angular velocity of the entity */ diff --git a/dGame/dComponents/HavokVehiclePhysicsComponent.cpp b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp index 464cb357..635830cc 100644 --- a/dGame/dComponents/HavokVehiclePhysicsComponent.cpp +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp @@ -7,8 +7,6 @@ HavokVehiclePhysicsComponent::HavokVehiclePhysicsComponent(Entity* parent) : Phy m_IsOnGround = true; m_IsOnRail = false; m_DirtyPosition = true; - m_DirtyVelocity = true; - m_DirtyAngularVelocity = true; m_EndBehavior = GeneralUtils::GenerateRandomNumber(0, 7); } @@ -37,17 +35,9 @@ void HavokVehiclePhysicsComponent::SetIsOnRail(bool val) { } void HavokVehiclePhysicsComponent::SetRemoteInputInfo(const RemoteInputInfo& remoteInputInfo) { - if (m_RemoteInputInfo == remoteInputInfo) return; + if (remoteInputInfo == m_RemoteInputInfo) return; this->m_RemoteInputInfo = remoteInputInfo; - m_DirtyRemoteInput = true; -} - -void HavokVehiclePhysicsComponent::SetDirtyVelocity(bool val) { - m_DirtyVelocity = val; -} - -void HavokVehiclePhysicsComponent::SetDirtyAngularVelocity(bool val) { - m_DirtyAngularVelocity = val; + m_DirtyPosition = true; } void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { @@ -67,34 +57,32 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bo outBitStream.Write(m_IsOnGround); outBitStream.Write(m_IsOnRail); - outBitStream.Write(bIsInitialUpdate || m_DirtyVelocity); - - if (bIsInitialUpdate || m_DirtyVelocity) { + bool isNotZero = m_Velocity != NiPoint3Constant::ZERO; + outBitStream.Write(isNotZero); + if (isNotZero) { outBitStream.Write(m_Velocity.x); outBitStream.Write(m_Velocity.y); outBitStream.Write(m_Velocity.z); - m_DirtyVelocity = false; } - outBitStream.Write(bIsInitialUpdate || m_DirtyAngularVelocity); - - if (bIsInitialUpdate || m_DirtyAngularVelocity) { + isNotZero = m_AngularVelocity != NiPoint3Constant::ZERO; + outBitStream.Write(isNotZero); + if (isNotZero) { outBitStream.Write(m_AngularVelocity.x); outBitStream.Write(m_AngularVelocity.y); outBitStream.Write(m_AngularVelocity.z); - m_DirtyAngularVelocity = false; } outBitStream.Write0(); // local_space_info. TODO: Implement this - outBitStream.Write(m_DirtyRemoteInput || bIsInitialUpdate); // remote_input_info - if (m_DirtyRemoteInput || bIsInitialUpdate) { - outBitStream.Write(m_RemoteInputInfo.m_RemoteInputX); - outBitStream.Write(m_RemoteInputInfo.m_RemoteInputY); - outBitStream.Write(m_RemoteInputInfo.m_IsPowersliding); - outBitStream.Write(m_RemoteInputInfo.m_IsModified); - m_DirtyRemoteInput = false; - } + // This structure only has this bool flag set to false if a ptr to the peVehicle is null, which we don't have + // therefore, this will always be 1, even if all the values in the structure are 0. + outBitStream.Write1(); // has remote_input_info + outBitStream.Write(m_RemoteInputInfo.m_RemoteInputX); + outBitStream.Write(m_RemoteInputInfo.m_RemoteInputY); + outBitStream.Write(m_RemoteInputInfo.m_IsPowersliding); + outBitStream.Write(m_RemoteInputInfo.m_IsModified); + outBitStream.Write(125.0f); // remote_input_ping TODO: Figure out how this should be calculated as it seems to be constant through the whole race. @@ -110,12 +98,3 @@ void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bo outBitStream.Write0(); } - -void HavokVehiclePhysicsComponent::Update(float deltaTime) { - if (m_SoftUpdate > 5) { - Game::entityManager->SerializeEntity(m_Parent); - m_SoftUpdate = 0; - } else { - m_SoftUpdate += deltaTime; - } -} diff --git a/dGame/dComponents/HavokVehiclePhysicsComponent.h b/dGame/dComponents/HavokVehiclePhysicsComponent.h index 94c14ec6..83eb82fe 100644 --- a/dGame/dComponents/HavokVehiclePhysicsComponent.h +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.h @@ -17,8 +17,6 @@ public: void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; - void Update(float deltaTime) override; - /** * Sets the velocity * @param vel the new velocity @@ -67,22 +65,16 @@ public: */ const bool GetIsOnRail() const { return m_IsOnRail; } - void SetDirtyPosition(bool val); - void SetDirtyVelocity(bool val); - void SetDirtyAngularVelocity(bool val); void SetRemoteInputInfo(const RemoteInputInfo&); private: - bool m_DirtyVelocity; NiPoint3 m_Velocity; - - bool m_DirtyAngularVelocity; NiPoint3 m_AngularVelocity; + bool m_IsOnGround; bool m_IsOnRail; float m_SoftUpdate = 0; uint32_t m_EndBehavior; RemoteInputInfo m_RemoteInputInfo; - bool m_DirtyRemoteInput; }; diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 4bcf78c0..77e90983 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -162,7 +162,7 @@ void MovingPlatformComponent::StartPathing() { const auto& nextWaypoint = m_Path->pathWaypoints[subComponent->mNextWaypointIndex]; subComponent->mPosition = currentWaypoint.position; - subComponent->mSpeed = currentWaypoint.movingPlatform.speed; + subComponent->mSpeed = currentWaypoint.speed; subComponent->mWaitTime = currentWaypoint.movingPlatform.wait; targetPosition = nextWaypoint.position; @@ -213,7 +213,7 @@ void MovingPlatformComponent::ContinuePathing() { const auto& nextWaypoint = m_Path->pathWaypoints[subComponent->mNextWaypointIndex]; subComponent->mPosition = currentWaypoint.position; - subComponent->mSpeed = currentWaypoint.movingPlatform.speed; + subComponent->mSpeed = currentWaypoint.speed; subComponent->mWaitTime = currentWaypoint.movingPlatform.wait; // + 2; pathSize = m_Path->pathWaypoints.size() - 1; diff --git a/dGame/dComponents/VendorComponent.cpp b/dGame/dComponents/VendorComponent.cpp index 8a26399c..abe11ea5 100644 --- a/dGame/dComponents/VendorComponent.cpp +++ b/dGame/dComponents/VendorComponent.cpp @@ -40,9 +40,19 @@ void VendorComponent::RefreshInventory(bool isCreation) { SetHasMultiCostItems(false); m_Inventory.clear(); - // Custom code for Max vanity NPC and Mr.Ree cameras - if(isCreation && m_Parent->GetLOT() == 9749 && Game::server->GetZoneID() == 1201) { - SetupMaxCustomVendor(); + // Custom code for Vanity Vendor Invetory Override + if(m_Parent->HasVar(u"vendorInvOverride")) { + std::vector items = GeneralUtils::SplitString(m_Parent->GetVarAsString(u"vendorInvOverride"), ','); + uint32_t sortPriority = -1; + for (auto& itemString : items) { + itemString.erase(remove_if(itemString.begin(), itemString.end(), isspace), itemString.end()); + auto item = GeneralUtils::TryParse(itemString); + if (!item) continue; + if (SetupItem(item.value())) { + sortPriority++; + m_Inventory.push_back(SoldItem(item.value(), sortPriority)); + } + } return; } @@ -52,24 +62,12 @@ void VendorComponent::RefreshInventory(bool isCreation) { if (lootMatrices.empty()) return; auto* lootTableTable = CDClientManager::GetTable(); - auto* itemComponentTable = CDClientManager::GetTable(); - auto* compRegistryTable = CDClientManager::GetTable(); for (const auto& lootMatrix : lootMatrices) { auto vendorItems = lootTableTable->GetTable(lootMatrix.LootTableIndex); if (lootMatrix.maxToDrop == 0 || lootMatrix.minToDrop == 0) { for (const auto& item : vendorItems) { - if (!m_HasStandardCostItems || !m_HasMultiCostItems) { - auto itemComponentID = compRegistryTable->GetByIDAndType(item.itemid, eReplicaComponentType::ITEM, -1); - if (itemComponentID == -1) { - LOG("Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT()); - continue; - } - auto itemComponent = itemComponentTable->GetItemComponentByID(itemComponentID); - if (!m_HasStandardCostItems && itemComponent.baseValue != -1) SetHasStandardCostItems(true); - if (!m_HasMultiCostItems && !itemComponent.currencyCosts.empty()) SetHasMultiCostItems(true); - } - m_Inventory.push_back(SoldItem(item.itemid, item.sortPriority)); + if (SetupItem(item.itemid)) m_Inventory.push_back(SoldItem(item.itemid, item.sortPriority)); } } else { auto randomCount = GeneralUtils::GenerateRandomNumber(lootMatrix.minToDrop, lootMatrix.maxToDrop); @@ -79,17 +77,7 @@ void VendorComponent::RefreshInventory(bool isCreation) { auto randomItemIndex = GeneralUtils::GenerateRandomNumber(0, vendorItems.size() - 1); const auto& randomItem = vendorItems.at(randomItemIndex); vendorItems.erase(vendorItems.begin() + randomItemIndex); - if (!m_HasStandardCostItems || !m_HasMultiCostItems) { - auto itemComponentID = compRegistryTable->GetByIDAndType(randomItem.itemid, eReplicaComponentType::ITEM, -1); - if (itemComponentID == -1) { - LOG("Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT()); - continue; - } - auto itemComponent = itemComponentTable->GetItemComponentByID(itemComponentID); - if (!m_HasStandardCostItems && itemComponent.baseValue != -1) SetHasStandardCostItems(true); - if (!m_HasMultiCostItems && !itemComponent.currencyCosts.empty()) SetHasMultiCostItems(true); - } - m_Inventory.push_back(SoldItem(randomItem.itemid, randomItem.sortPriority)); + if (SetupItem(randomItem.itemid)) m_Inventory.push_back(SoldItem(randomItem.itemid, randomItem.sortPriority)); } } } @@ -126,15 +114,6 @@ bool VendorComponent::SellsItem(const LOT item) const { }) > 0; } - -void VendorComponent::SetupMaxCustomVendor(){ - SetHasStandardCostItems(true); - m_Inventory.push_back(SoldItem(11909, 0)); // Top hat w frog - m_Inventory.push_back(SoldItem(7785, 0)); // Flash bulb - m_Inventory.push_back(SoldItem(12764, 0)); // Big fountain soda - m_Inventory.push_back(SoldItem(12241, 0)); // Hot cocoa (from fb) -} - void VendorComponent::HandleMrReeCameras(){ if (m_Parent->GetLOT() == 13569) { SetHasStandardCostItems(true); @@ -211,5 +190,25 @@ void VendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { character->SetCoins(character->GetCoins() - (coinCost), eLootSourceType::VENDOR); inventoryComponent->AddItem(lot, count, eLootSourceType::VENDOR); GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS); +} + +bool VendorComponent::SetupItem(LOT item) { + + auto* itemComponentTable = CDClientManager::GetTable(); + auto* compRegistryTable = CDClientManager::GetTable(); + + auto itemComponentID = compRegistryTable->GetByIDAndType(item, eReplicaComponentType::ITEM, -1); + if (itemComponentID == -1) { + LOG("Attempted to add item %i with ItemComponent ID -1 to vendor %i inventory. Not adding item!", itemComponentID, m_Parent->GetLOT()); + return false; + } + + if (!m_HasStandardCostItems || !m_HasMultiCostItems) { + auto itemComponent = itemComponentTable->GetItemComponentByID(itemComponentID); + if (!m_HasStandardCostItems && itemComponent.baseValue != -1) SetHasStandardCostItems(true); + if (!m_HasMultiCostItems && !itemComponent.currencyCosts.empty()) SetHasMultiCostItems(true); + } + + return true; +} -} \ No newline at end of file diff --git a/dGame/dComponents/VendorComponent.h b/dGame/dComponents/VendorComponent.h index 2abd3536..b5e9f5d0 100644 --- a/dGame/dComponents/VendorComponent.h +++ b/dGame/dComponents/VendorComponent.h @@ -50,8 +50,8 @@ public: void Buy(Entity* buyer, LOT lot, uint32_t count); private: - void SetupMaxCustomVendor(); void HandleMrReeCameras(); + bool SetupItem(LOT item); float m_BuyScalar = 0.0f; float m_SellScalar = 0.0f; float m_RefreshTimeSeconds = 0.0f; diff --git a/dGame/dEntity/CMakeLists.txt b/dGame/dEntity/CMakeLists.txt index d7d96e14..2a418fb9 100644 --- a/dGame/dEntity/CMakeLists.txt +++ b/dGame/dEntity/CMakeLists.txt @@ -2,6 +2,6 @@ set(DGAME_DENTITY_SOURCES "EntityCallbackTimer.cpp" "EntityTimer.cpp") -add_library(dEntity STATIC ${DGAME_DENTITY_SOURCES}) +add_library(dEntity OBJECT ${DGAME_DENTITY_SOURCES}) target_include_directories(dEntity PUBLIC ".") target_precompile_headers(dEntity REUSE_FROM dGameBase) diff --git a/dGame/dGameMessages/CMakeLists.txt b/dGame/dGameMessages/CMakeLists.txt index 7373633c..0f28dea4 100644 --- a/dGame/dGameMessages/CMakeLists.txt +++ b/dGame/dGameMessages/CMakeLists.txt @@ -4,6 +4,20 @@ set(DGAME_DGAMEMESSAGES_SOURCES "PropertyDataMessage.cpp" "PropertySelectQueryProperty.cpp") -add_library(dGameMessages STATIC ${DGAME_DGAMEMESSAGES_SOURCES}) -target_link_libraries(dGameMessages PUBLIC dDatabase) +add_library(dGameMessages OBJECT ${DGAME_DGAMEMESSAGES_SOURCES}) +target_link_libraries(dGameMessages + PUBLIC dDatabase + INTERFACE dGameBase # TradingManager +) +target_include_directories(dGameMessages PUBLIC "." + PRIVATE + "${PROJECT_SOURCE_DIR}/dGame/dComponents" # direct MissionComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # direct SlashCommandHandler.h + "${PROJECT_SOURCE_DIR}/dGame/dPropertyBehaviors" # direct ControlBehaviors.h + "${PROJECT_SOURCE_DIR}/dGame/dMission" # via MissionComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # via InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dInventory" # via InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager/Spawner.h + "${PROJECT_SOURCE_DIR}/dZoneManager" # via GameMessages.cpp, GameMessageHandler.cpp +) target_precompile_headers(dGameMessages REUSE_FROM dGameBase) diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 9a4ddf15..768f1809 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -324,8 +324,8 @@ void GameMessages::SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& s bitStream.Write(entity->GetObjectID()); bitStream.Write(eGameMessageType::PLAY_ND_AUDIO_EMITTER); - bitStream.Write0(); - bitStream.Write0(); + bitStream.Write0(); // callback message data {lwoobjid} + bitStream.Write0(); // audio emitterid {uint32_t} uint32_t length = audioGUID.size(); bitStream.Write(length); @@ -333,9 +333,9 @@ void GameMessages::SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& s bitStream.Write(audioGUID[k]); } - bitStream.Write(0); - bitStream.Write0(); - bitStream.Write0(); + bitStream.Write(0); // size of NDAudioMetaEventName (then print the string like the guid) + bitStream.Write0(); // result {bool} + bitStream.Write0(); // m_TargetObjectIDForNDAudioCallbackMessages {lwoobjid} SEND_PACKET_BROADCAST; } diff --git a/dGame/dInventory/CMakeLists.txt b/dGame/dInventory/CMakeLists.txt index bc741efe..b45b27bf 100644 --- a/dGame/dInventory/CMakeLists.txt +++ b/dGame/dInventory/CMakeLists.txt @@ -5,11 +5,32 @@ set(DGAME_DINVENTORY_SOURCES "ItemSet.cpp" "ItemSetPassiveAbility.cpp") +add_library(dInventory OBJECT ${DGAME_DINVENTORY_SOURCES}) +target_include_directories(dInventory PUBLIC "." + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # Item.h uses Preconditions.h + "${PROJECT_SOURCE_DIR}/dCommon/eEnums" # Item.h uses dCommonVars.h + PRIVATE + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" + "${PROJECT_SOURCE_DIR}/dCommon/dClient" # Item.cpp uses AssetManager + + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase/CDClientTables" + + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # direct + "${PROJECT_SOURCE_DIR}/dGame/dComponents" # direct InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # via InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager/Spawner.h + "${PROJECT_SOURCE_DIR}/dGame/dMission" # via MissionComponent.h + "${PROJECT_SOURCE_DIR}/dZoneManager" # via Item.cpp +) +target_precompile_headers(dInventory REUSE_FROM dGameBase) # Workaround for compiler bug where the optimized code could result in a memcpy of 0 bytes, even though that isnt possible. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97185 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set_source_files_properties("Item.cpp" PROPERTIES COMPILE_FLAGS "-Wno-stringop-overflow") endif() - -add_library(dInventory STATIC ${DGAME_DINVENTORY_SOURCES}) -target_precompile_headers(dInventory REUSE_FROM dGameBase) +# INTERFACE link w/o dependency +#set_property(TARGET dInventory APPEND PROPERTY INTERFACE_LINK_LIBRARIES +# dNet dDatabaseCDClient +#) diff --git a/dGame/dMission/CMakeLists.txt b/dGame/dMission/CMakeLists.txt index 4e4bdec2..51f74c37 100644 --- a/dGame/dMission/CMakeLists.txt +++ b/dGame/dMission/CMakeLists.txt @@ -3,6 +3,16 @@ set(DGAME_DMISSION_SOURCES "MissionPrerequisites.cpp" "MissionTask.cpp") -add_library(dMission STATIC ${DGAME_DMISSION_SOURCES}) +add_library(dMission OBJECT ${DGAME_DMISSION_SOURCES}) target_link_libraries(dMission PUBLIC dDatabase) +target_include_directories(dMission PUBLIC "." + PRIVATE + "${PROJECT_SOURCE_DIR}/dGame/dComponents" + "${PROJECT_SOURCE_DIR}/dGame/dInventory" # via CharacterComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # via CharacterComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # via LevelProgressionComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager/Spawner.h + "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # via InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dZoneManager" # via Mission.cpp, MissionTask.cpp +) target_precompile_headers(dMission REUSE_FROM dGameBase) diff --git a/dGame/dPropertyBehaviors/CMakeLists.txt b/dGame/dPropertyBehaviors/CMakeLists.txt index 47c8ff23..3e03ba1d 100644 --- a/dGame/dPropertyBehaviors/CMakeLists.txt +++ b/dGame/dPropertyBehaviors/CMakeLists.txt @@ -12,5 +12,15 @@ foreach(file ${DGAME_DPROPERTYBEHAVIORS_CONTROLBEHAVIORMESSAGES}) set(DGAME_DPROPERTYBEHAVIORS_SOURCES ${DGAME_DPROPERTYBEHAVIORS_SOURCES} "ControlBehaviorMessages/${file}") endforeach() -add_library(dPropertyBehaviors STATIC ${DGAME_DPROPERTYBEHAVIORS_SOURCES}) +add_library(dPropertyBehaviors OBJECT ${DGAME_DPROPERTYBEHAVIORS_SOURCES}) +target_link_libraries(dPropertyBehaviors PRIVATE dDatabaseCDClient) +target_include_directories(dPropertyBehaviors PUBLIC "." "ControlBehaviorMessages" + PRIVATE + "${PROJECT_SOURCE_DIR}/dCommon/dClient" # ControlBehaviors.cpp uses AssetManager + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # ObjectIdManager.h + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # GameMessages.h + "${PROJECT_SOURCE_DIR}/dGame/dComponents" # ModelComponent.h +) target_precompile_headers(dPropertyBehaviors REUSE_FROM dGameBase) + +target_link_libraries(dPropertyBehaviors INTERFACE dComponents) diff --git a/dGame/dUtilities/CMakeLists.txt b/dGame/dUtilities/CMakeLists.txt index 055cc706..1e54b59b 100644 --- a/dGame/dUtilities/CMakeLists.txt +++ b/dGame/dUtilities/CMakeLists.txt @@ -8,8 +8,18 @@ set(DGAME_DUTILITIES_SOURCES "BrickDatabase.cpp" "SlashCommandHandler.cpp" "VanityUtilities.cpp") -add_library(dUtilities STATIC ${DGAME_DUTILITIES_SOURCES}) +add_library(dUtilities OBJECT ${DGAME_DUTILITIES_SOURCES}) target_precompile_headers(dUtilities REUSE_FROM dGameBase) +target_include_directories(dUtilities PUBLIC "." + PRIVATE + "${PROJECT_SOURCE_DIR}/dGame/dComponents" + "${PROJECT_SOURCE_DIR}/dGame/dInventory" # transitive via PossessableComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" + "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # transitive via InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dMission" # transitive via MissionComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # transitive via dZoneManager/Spawner.h + "${PROJECT_SOURCE_DIR}/dZoneManager" # Mail.cpp +) target_link_libraries(dUtilities PUBLIC dDatabase dPhysics INTERFACE dZoneManager) diff --git a/dGame/dUtilities/Loot.h b/dGame/dUtilities/Loot.h index dacd3dcd..ac4d5233 100644 --- a/dGame/dUtilities/Loot.h +++ b/dGame/dUtilities/Loot.h @@ -1,6 +1,7 @@ #pragma once #include "dCommonVars.h" +#include "eLootSourceType.h" #include class Entity; diff --git a/dGame/dUtilities/VanityUtilities.cpp b/dGame/dUtilities/VanityUtilities.cpp index 3e93f830..0324ee1b 100644 --- a/dGame/dUtilities/VanityUtilities.cpp +++ b/dGame/dUtilities/VanityUtilities.cpp @@ -22,9 +22,18 @@ #include -std::vector VanityUtilities::m_Objects = {}; -std::set VanityUtilities::m_LoadedFiles = {}; +namespace { + std::vector objects; + std::set loadedFiles; +} + +void SetupNPCTalk(Entity* npc); +void NPCTalk(Entity* npc); +void ParseXml(const std::string& file); +LWOOBJID SpawnSpawner(const VanityObject& object, const VanityObjectLocation& location); +Entity* SpawnObject(const VanityObject& object, const VanityObjectLocation& location); +VanityObject* GetObject(const std::string& name); void VanityUtilities::SpawnVanity() { const uint32_t zoneID = Game::server->GetZoneID(); @@ -36,21 +45,19 @@ void VanityUtilities::SpawnVanity() { info.pos = { 259.5f, 246.4f, -705.2f }; info.rot = { 0.0f, 0.0f, 1.0f, 0.0f }; info.spawnerID = Game::entityManager->GetZoneControlEntity()->GetObjectID(); - - info.settings = { new LDFData(u"hasCustomText", true), - new LDFData(u"customText", ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/TESTAMENT.md").string())) }; + info.settings = { + new LDFData(u"hasCustomText", true), + new LDFData(u"customText", ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/TESTAMENT.md").string())) + }; auto* entity = Game::entityManager->CreateEntity(info); - Game::entityManager->ConstructEntity(entity); } } - if (Game::config->GetValue("disable_vanity") == "1") { - return; - } + if (Game::config->GetValue("disable_vanity") == "1") return; - for (const auto& npc : m_Objects) { + for (const auto& npc : objects) { if (npc.m_ID == LWOOBJID_EMPTY) continue; if (npc.m_LOT == 176){ Game::zoneManager->RemoveSpawner(npc.m_ID); @@ -61,13 +68,13 @@ void VanityUtilities::SpawnVanity() { } } - m_Objects.clear(); - m_LoadedFiles.clear(); + objects.clear(); + loadedFiles.clear(); - ParseXML((BinaryPathFinder::GetBinaryDir() / "vanity/root.xml").string()); + ParseXml((BinaryPathFinder::GetBinaryDir() / "vanity/root.xml").string()); // Loop through all objects - for (auto& object : m_Objects) { + for (auto& object : objects) { if (object.m_Locations.find(Game::server->GetZoneID()) == object.m_Locations.end()) continue; const std::vector& locations = object.m_Locations.at(Game::server->GetZoneID()); @@ -79,12 +86,6 @@ void VanityUtilities::SpawnVanity() { float rate = GeneralUtils::GenerateRandomNumber(0, 1); if (location.m_Chance < rate) continue; - if (object.m_Config.empty()) { - object.m_Config = { - new LDFData>(u"syncLDF", { u"custom_script_client" }), - new LDFData(u"custom_script_client", u"scripts\\ai\\SPEC\\MISSION_MINIGAME_CLIENT.lua") - }; - } if (object.m_LOT == 176){ object.m_ID = SpawnSpawner(object, location); } else { @@ -94,20 +95,13 @@ void VanityUtilities::SpawnVanity() { object.m_ID = objectEntity->GetObjectID(); if (!object.m_Phrases.empty()){ objectEntity->SetVar>(u"chats", object.m_Phrases); - - auto* scriptComponent = objectEntity->GetComponent(); - - if (scriptComponent && !object.m_Script.empty()) { - scriptComponent->SetScript(object.m_Script); - scriptComponent->SetSerialized(false); - } SetupNPCTalk(objectEntity); } } } } -LWOOBJID VanityUtilities::SpawnSpawner(const VanityObject& object, const VanityObjectLocation& location) { +LWOOBJID SpawnSpawner(const VanityObject& object, const VanityObjectLocation& location) { SceneObject obj; obj.lot = object.m_LOT; // guratantee we have no collisions @@ -121,7 +115,7 @@ LWOOBJID VanityUtilities::SpawnSpawner(const VanityObject& object, const VanityO return obj.id; } -Entity* VanityUtilities::SpawnObject(const VanityObject& object, const VanityObjectLocation& location) { +Entity* SpawnObject(const VanityObject& object, const VanityObjectLocation& location) { EntityInfo info; info.lot = object.m_LOT; info.pos = location.m_Position; @@ -131,18 +125,16 @@ Entity* VanityUtilities::SpawnObject(const VanityObject& object, const VanityObj info.settings = object.m_Config; auto* entity = Game::entityManager->CreateEntity(info); - entity->SetVar(u"npcName", object.m_Name); + if (!object.m_Name.empty()) entity->SetVar(u"npcName", object.m_Name); if (entity->GetVar(u"noGhosting")) entity->SetIsGhostingCandidate(false); auto* inventoryComponent = entity->GetComponent(); - if (inventoryComponent && !object.m_Equipment.empty()) { inventoryComponent->SetNPCItems(object.m_Equipment); } auto* destroyableComponent = entity->GetComponent(); - - if (destroyableComponent != nullptr) { + if (destroyableComponent) { destroyableComponent->SetIsGMImmune(true); destroyableComponent->SetMaxHealth(0); destroyableComponent->SetHealth(0); @@ -153,12 +145,12 @@ Entity* VanityUtilities::SpawnObject(const VanityObject& object, const VanityObj return entity; } -void VanityUtilities::ParseXML(const std::string& file) { - if (m_LoadedFiles.contains(file)){ +void ParseXml(const std::string& file) { + if (loadedFiles.contains(file)){ LOG("Trying to load vanity file %s twice!!!", file.c_str()); return; } - m_LoadedFiles.insert(file); + loadedFiles.insert(file); // Read the entire file std::ifstream xmlFile(file); std::string xml((std::istreambuf_iterator(xmlFile)), std::istreambuf_iterator()); @@ -176,24 +168,26 @@ void VanityUtilities::ParseXML(const std::string& file) { if (enabled != "1") { continue; } - ParseXML((BinaryPathFinder::GetBinaryDir() / "vanity" / filename).string()); + ParseXml((BinaryPathFinder::GetBinaryDir() / "vanity" / filename).string()); } } // Read the objects - auto* objects = doc.FirstChildElement("objects"); - - if (objects) { - for (auto* object = objects->FirstChildElement("object"); object != nullptr; object = object->NextSiblingElement("object")) { + auto* objectsElement = doc.FirstChildElement("objects"); + const uint32_t currentZoneID = Game::server->GetZoneID(); + if (objectsElement) { + for (auto* object = objectsElement->FirstChildElement("object"); object != nullptr; object = object->NextSiblingElement("object")) { + // for use later when adding to the vector of VanityObjects + bool useLocationsAsRandomSpawnPoint = false; // Get the NPC name auto* name = object->Attribute("name"); if (!name) name = ""; // Get the NPC lot - auto* lot = object->Attribute("lot"); + auto lot = GeneralUtils::TryParse(object->Attribute("lot")).value_or(LOT_NULL); - if (lot == nullptr) { + if (lot == LOT_NULL) { LOG("Failed to parse object lot"); continue; } @@ -211,17 +205,17 @@ void VanityUtilities::ParseXML(const std::string& file) { std::vector splitEquipment = GeneralUtils::SplitString(equipmentString, ','); for (auto& item : splitEquipment) { - inventory.push_back(std::stoi(item)); + // remove spaces for tryParse to work + item.erase(remove_if(item.begin(), item.end(), isspace), item.end()); + auto itemInt = GeneralUtils::TryParse(item); + if (itemInt) inventory.push_back(itemInt.value()); } } } - // Get the phrases auto* phrases = object->FirstChildElement("phrases"); - std::vector phraseList = {}; - if (phrases) { for (auto* phrase = phrases->FirstChildElement("phrase"); phrase != nullptr; phrase = phrase->NextSiblingElement("phrase")) { @@ -235,41 +229,34 @@ void VanityUtilities::ParseXML(const std::string& file) { } } - // Get the script - auto* scriptElement = object->FirstChildElement("script"); - - std::string scriptName = ""; - - if (scriptElement != nullptr) { - auto* scriptNameAttribute = scriptElement->Attribute("name"); - if (scriptNameAttribute) scriptName = scriptNameAttribute; - } - auto* configElement = object->FirstChildElement("config"); std::vector keys = {}; - std::vector config = {}; if(configElement) { for (auto* key = configElement->FirstChildElement("key"); key != nullptr; key = key->NextSiblingElement("key")) { // Get the config data - auto* data = key->Attribute("data"); + auto* data = key->GetText(); if (!data) continue; LDFBaseData* configData = LDFBaseData::DataFromString(data); + if (configData->GetKey() == u"useLocationsAsRandomSpawnPoint" && configData->GetValueType() == eLDFType::LDF_TYPE_BOOLEAN){ + useLocationsAsRandomSpawnPoint = static_cast(configData); + continue; + } keys.push_back(configData->GetKey()); config.push_back(configData); } } if (!keys.empty()) config.push_back(new LDFData>(u"syncLDF", keys)); - VanityObject objectData; - objectData.m_Name = name; - objectData.m_LOT = std::stoi(lot); - objectData.m_Equipment = inventory; - objectData.m_Phrases = phraseList; - objectData.m_Script = scriptName; - objectData.m_Config = config; + VanityObject objectData { + .m_Name = name, + .m_LOT = lot, + .m_Equipment = inventory, + .m_Phrases = phraseList, + .m_Config = config + }; // Get the locations auto* locations = object->FirstChildElement("locations"); @@ -283,64 +270,67 @@ void VanityUtilities::ParseXML(const std::string& file) { location = location->NextSiblingElement("location")) { // Get the location data - auto* zoneID = location->Attribute("zone"); - auto* x = location->Attribute("x"); - auto* y = location->Attribute("y"); - auto* z = location->Attribute("z"); - auto* rw = location->Attribute("rw"); - auto* rx = location->Attribute("rx"); - auto* ry = location->Attribute("ry"); - auto* rz = location->Attribute("rz"); + auto zoneID = GeneralUtils::TryParse(location->Attribute("zone")); + auto x = GeneralUtils::TryParse(location->Attribute("x")); + auto y = GeneralUtils::TryParse(location->Attribute("y")); + auto z = GeneralUtils::TryParse(location->Attribute("z")); + auto rw = GeneralUtils::TryParse(location->Attribute("rw")); + auto rx = GeneralUtils::TryParse(location->Attribute("rx")); + auto ry = GeneralUtils::TryParse(location->Attribute("ry")); + auto rz = GeneralUtils::TryParse(location->Attribute("rz")); - if (zoneID == nullptr || x == nullptr || y == nullptr || z == nullptr || rw == nullptr || rx == nullptr || ry == nullptr - || rz == nullptr) { + if (!zoneID || !x || !y || !z || !rw || !rx || !ry || !rz) { LOG("Failed to parse NPC location data"); continue; } - VanityObjectLocation locationData; - locationData.m_Position = { std::stof(x), std::stof(y), std::stof(z) }; - locationData.m_Rotation = { std::stof(rw), std::stof(rx), std::stof(ry), std::stof(rz) }; - locationData.m_Chance = 1.0f; + if (zoneID.value() != currentZoneID) { + LOG_DEBUG("Skipping location because it is in %i and not the current zone (%i)", zoneID.value(), currentZoneID); + continue; + } + + VanityObjectLocation locationData { + .m_Position = { x.value(), y.value(), z.value() }, + .m_Rotation = { rw.value(), rx.value(), ry.value(), rz.value() }, + }; if (location->Attribute("chance")) { - locationData.m_Chance = std::stof(location->Attribute("chance")); + locationData.m_Chance = GeneralUtils::TryParse(location->Attribute("chance")).value_or(1.0f); } if (location->Attribute("scale")) { - locationData.m_Scale = std::stof(location->Attribute("scale")); + locationData.m_Scale = GeneralUtils::TryParse(location->Attribute("scale")).value_or(1.0f); } - - const auto& it = objectData.m_Locations.find(std::stoi(zoneID)); + const auto& it = objectData.m_Locations.find(zoneID.value()); if (it != objectData.m_Locations.end()) { it->second.push_back(locationData); } else { std::vector locations; locations.push_back(locationData); - objectData.m_Locations.insert(std::make_pair(std::stoi(zoneID), locations)); + objectData.m_Locations.insert(std::make_pair(zoneID.value(), locations)); } - if (!(std::find(keys.begin(), keys.end(), u"teleport") != keys.end())) { - m_Objects.push_back(objectData); + if (!useLocationsAsRandomSpawnPoint) { + objects.push_back(objectData); objectData.m_Locations.clear(); } } - if (std::find(keys.begin(), keys.end(), u"teleport") != keys.end()) { - m_Objects.push_back(objectData); - } + + if (useLocationsAsRandomSpawnPoint && !objectData.m_Locations.empty()) { + objects.push_back(objectData); + } } } } VanityObject* VanityUtilities::GetObject(const std::string& name) { - for (size_t i = 0; i < m_Objects.size(); i++) { - if (m_Objects[i].m_Name == name) { - return &m_Objects[i]; + for (size_t i = 0; i < objects.size(); i++) { + if (objects[i].m_Name == name) { + return &objects[i]; } } - return nullptr; } @@ -350,7 +340,7 @@ std::string VanityUtilities::ParseMarkdown(const std::string& file) { // Read the file into a string std::ifstream t(file); std::stringstream output; - // If the file does not exist, return an empty string. + // If the file does not exist, return a useful error. if (!t.good()) { output << "File "; output << file.substr(file.rfind("/") + 1); @@ -408,13 +398,13 @@ std::string VanityUtilities::ParseMarkdown(const std::string& file) { return output.str(); } -void VanityUtilities::SetupNPCTalk(Entity* npc) { +void SetupNPCTalk(Entity* npc) { npc->AddCallbackTimer(15.0f, [npc]() { NPCTalk(npc); }); npc->SetProximityRadius(20.0f, "talk"); } -void VanityUtilities::NPCTalk(Entity* npc) { +void NPCTalk(Entity* npc) { auto* proximityMonitorComponent = npc->GetComponent(); if (!proximityMonitorComponent->GetProximityObjects("talk").empty()) { diff --git a/dGame/dUtilities/VanityUtilities.h b/dGame/dUtilities/VanityUtilities.h index 49bd23ab..a1d00501 100644 --- a/dGame/dUtilities/VanityUtilities.h +++ b/dGame/dUtilities/VanityUtilities.h @@ -5,58 +5,30 @@ #include #include -struct VanityObjectLocation -{ +struct VanityObjectLocation { float m_Chance = 1.0f; NiPoint3 m_Position; NiQuaternion m_Rotation; float m_Scale = 1.0f; }; -struct VanityObject -{ +struct VanityObject { LWOOBJID m_ID = LWOOBJID_EMPTY; std::string m_Name; - LOT m_LOT; + LOT m_LOT = LOT_NULL; std::vector m_Equipment; std::vector m_Phrases; - std::string m_Script; std::map> m_Locations; std::vector m_Config; }; -class VanityUtilities -{ -public: - static void SpawnVanity(); +namespace VanityUtilities { + void SpawnVanity(); - static Entity* SpawnObject( - const VanityObject& object, - const VanityObjectLocation& location - ); + VanityObject* GetObject(const std::string& name); - static LWOOBJID SpawnSpawner( - const VanityObject& object, - const VanityObjectLocation& location - ); - - static std::string ParseMarkdown( + std::string ParseMarkdown( const std::string& file ); - - static void ParseXML( - const std::string& file - ); - - static VanityObject* GetObject(const std::string& name); - -private: - static void SetupNPCTalk(Entity* npc); - - static void NPCTalk(Entity* npc); - - static std::vector m_Objects; - - static std::set m_LoadedFiles; }; diff --git a/dMasterServer/CMakeLists.txt b/dMasterServer/CMakeLists.txt index 32a7b1ec..260e4f16 100644 --- a/dMasterServer/CMakeLists.txt +++ b/dMasterServer/CMakeLists.txt @@ -7,10 +7,13 @@ set(DMASTERSERVER_SOURCES add_library(dMasterServer ${DMASTERSERVER_SOURCES}) add_executable(MasterServer "MasterServer.cpp") add_compile_definitions(MasterServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") +target_include_directories(dMasterServer PUBLIC "." + "${PROJECT_SOURCE_DIR}/dZoneManager" # InstanceManager.h uses dZMCommon.h + ${PROJECT_SOURCE_DIR}/dServer/ # BinaryPathFinder.h +) target_link_libraries(dMasterServer ${COMMON_LIBRARIES}) -target_link_libraries(MasterServer ${COMMON_LIBRARIES} dMasterServer dServer) -target_include_directories(dMasterServer PRIVATE ${PROJECT_SOURCE_DIR}/dServer) +target_link_libraries(MasterServer ${COMMON_LIBRARIES} bcrypt dMasterServer dServer) if(WIN32) add_dependencies(MasterServer WorldServer AuthServer ChatServer) diff --git a/dNavigation/CMakeLists.txt b/dNavigation/CMakeLists.txt index 4c03d24b..e2a1c6ef 100644 --- a/dNavigation/CMakeLists.txt +++ b/dNavigation/CMakeLists.txt @@ -6,5 +6,12 @@ foreach(file ${DNAVIGATIONS_DTERRAIN_SOURCES}) set(DNAVIGATION_SOURCES ${DNAVIGATION_SOURCES} "dTerrain/${file}") endforeach() -add_library(dNavigation STATIC ${DNAVIGATION_SOURCES}) -target_link_libraries(dNavigation Detour Recast) +add_library(dNavigation OBJECT ${DNAVIGATION_SOURCES}) +target_include_directories(dNavigation PUBLIC "." + PRIVATE + "${PROJECT_SOURCE_DIR}/dZoneManager" + "${PROJECT_SOURCE_DIR}/dGame" + "${PROJECT_SOURCE_DIR}/dGame/dEntity" + "${PROJECT_SOURCE_DIR}/dNavigation/dTerrain" # via dNavMesh.cpp +) +target_link_libraries(dNavigation PRIVATE Detour Recast dCommon) diff --git a/dNet/AuthPackets.cpp b/dNet/AuthPackets.cpp index 2ba33ab5..dce7e8e9 100644 --- a/dNet/AuthPackets.cpp +++ b/dNet/AuthPackets.cpp @@ -8,7 +8,7 @@ #include "ZoneInstanceManager.h" #include "MD5.h" #include "GeneralUtils.h" -#include "ClientVersion.h" +#include "dClient/ClientVersion.h" #include diff --git a/dNet/CMakeLists.txt b/dNet/CMakeLists.txt index 68de8eb1..15cdda42 100644 --- a/dNet/CMakeLists.txt +++ b/dNet/CMakeLists.txt @@ -8,5 +8,24 @@ set(DNET_SOURCES "AuthPackets.cpp" "ZoneInstanceManager.cpp") add_library(dNet STATIC ${DNET_SOURCES}) +target_link_libraries(dNet PRIVATE bcrypt MD5) +target_include_directories(dNet PRIVATE + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" -target_link_libraries(dNet PUBLIC dCommon) + "${PROJECT_SOURCE_DIR}/dZoneManager" + + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/CDClientDatabase/CDClientTables" + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase" + "${PROJECT_SOURCE_DIR}/dDatabase/GameDatabase/ITables" + "${PROJECT_SOURCE_DIR}/thirdparty/mariadb-connector-cpp/include" + + "${PROJECT_SOURCE_DIR}/dGame" # UserManager.h + "${PROJECT_SOURCE_DIR}/dGame/dComponents" + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # GameMessages.h + "${PROJECT_SOURCE_DIR}/dGame/dInventory" # via PossessableComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # via Item.h + "${PROJECT_SOURCE_DIR}/dScripts" # transitive through components +) diff --git a/dPhysics/CMakeLists.txt b/dPhysics/CMakeLists.txt index 340e4c3c..65588b4b 100644 --- a/dPhysics/CMakeLists.txt +++ b/dPhysics/CMakeLists.txt @@ -7,6 +7,10 @@ set(DPHYSICS_SOURCES "dpCollisionChecks.cpp" "dpWorld.cpp") add_library(dPhysics STATIC ${DPHYSICS_SOURCES}) +target_include_directories(dPhysics PUBLIC "." + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" +) target_link_libraries(dPhysics PUBLIC Recast Detour - INTERFACE dNavigation) + INTERFACE dNavigation dCommon) diff --git a/dScripts/02_server/CMakeLists.txt b/dScripts/02_server/CMakeLists.txt index 51eb24c8..8114b226 100644 --- a/dScripts/02_server/CMakeLists.txt +++ b/dScripts/02_server/CMakeLists.txt @@ -30,15 +30,28 @@ endforeach() add_subdirectory(Pets) -add_library(dScriptsServer STATIC ${DSCRIPTS_SOURCES_02_SERVER}) -target_include_directories(dScriptsServer PUBLIC "." +add_library(dScriptsServerBase OBJECT ${DSCRIPTS_SOURCES_02_SERVER}) +target_include_directories(dScriptsServerBase PUBLIC "." "DLU" "Equipment" "Minigame" "Minigame/General" "Objects" - "Pets") +) +target_precompile_headers(dScriptsServerBase REUSE_FROM dScriptsBase) + +add_library(dScriptsServer INTERFACE) +target_sources(dScriptsServer INTERFACE + $ + $ + $ +) target_link_libraries(dScriptsServer INTERFACE - dScriptsServerEnemy - dScriptsServerMap) -target_precompile_headers(dScriptsServer REUSE_FROM dScriptsBase) + dScriptsServerMap +) +target_include_directories(dScriptsServer INTERFACE + $ + $ + $ + $ +) diff --git a/dScripts/02_server/DLU/DLUVanityTeleportingObject.cpp b/dScripts/02_server/DLU/DLUVanityTeleportingObject.cpp index 8aff1995..60d2d715 100644 --- a/dScripts/02_server/DLU/DLUVanityTeleportingObject.cpp +++ b/dScripts/02_server/DLU/DLUVanityTeleportingObject.cpp @@ -5,20 +5,17 @@ #include "RenderComponent.h" void DLUVanityTeleportingObject::OnStartup(Entity* self) { - if (!self->HasVar(u"npcName") || !self->HasVar(u"teleport")) return; - m_Object = VanityUtilities::GetObject(self->GetVarAsString(u"npcName")); + if (!self->HasVar(u"npcName")) return; + m_Object = VanityUtilities::GetObject(self->GetVarAsString(u"npcName")); if (!m_Object) return; if (self->HasVar(u"teleportInterval")) m_TeleportInterval = self->GetVar(u"teleportInterval"); - if (self->GetVar(u"teleport")) { - self->AddTimer("setupTeleport", m_TeleportInterval); - } + self->AddTimer("setupTeleport", m_TeleportInterval); } void DLUVanityTeleportingObject::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "setupTeleport") { - RenderComponent::PlayAnimation(self, u"interact"); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam"); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings"); @@ -40,7 +37,6 @@ void DLUVanityTeleportingObject::OnTimerDone(Entity* self, std::string timerName self->SetPosition(newLocation.m_Position); self->SetRotation(newLocation.m_Rotation); - self->SetScale(newLocation.m_Scale); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportBeam", "teleportBeam"); GameMessages::SendPlayFXEffect(self->GetObjectID(), 6478, u"teleportRings", "teleportRings"); self->AddTimer("stopFX", 2.0f); diff --git a/dScripts/02_server/Enemy/CMakeLists.txt b/dScripts/02_server/Enemy/CMakeLists.txt index 62f61772..3c39721c 100644 --- a/dScripts/02_server/Enemy/CMakeLists.txt +++ b/dScripts/02_server/Enemy/CMakeLists.txt @@ -42,7 +42,7 @@ foreach(file ${DSCRIPTS_SOURCES_02_SERVER_ENEMY_WAVES}) set(DSCRIPTS_SOURCES_02_SERVER_ENEMY ${DSCRIPTS_SOURCES_02_SERVER_ENEMY} "Waves/${file}") endforeach() -add_library(dScriptsServerEnemy STATIC ${DSCRIPTS_SOURCES_02_SERVER_ENEMY}) +add_library(dScriptsServerEnemy OBJECT ${DSCRIPTS_SOURCES_02_SERVER_ENEMY}) target_link_libraries(dScriptsServerEnemy dScriptsBase) target_include_directories(dScriptsServerEnemy PUBLIC "." "AG" diff --git a/dScripts/02_server/Map/AG/CMakeLists.txt b/dScripts/02_server/Map/AG/CMakeLists.txt index a8315398..e13fd26a 100644 --- a/dScripts/02_server/Map/AG/CMakeLists.txt +++ b/dScripts/02_server/Map/AG/CMakeLists.txt @@ -14,6 +14,6 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AG "NpcCowboyServer.cpp" "NpcPirateServer.cpp") -add_library(dScriptsServerMapAG ${DSCRIPTS_SOURCES_02_SERVER_MAP_AG}) +add_library(dScriptsServerMapAG OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_AG}) target_include_directories(dScriptsServerMapAG PUBLIC ".") target_precompile_headers(dScriptsServerMapAG REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/AG_Spider_Queen/CMakeLists.txt b/dScripts/02_server/Map/AG_Spider_Queen/CMakeLists.txt index 65019afe..30d09deb 100644 --- a/dScripts/02_server/Map/AG_Spider_Queen/CMakeLists.txt +++ b/dScripts/02_server/Map/AG_Spider_Queen/CMakeLists.txt @@ -2,7 +2,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AG_SPIDER_QUEEN "ZoneAgSpiderQueen.cpp" "SpiderBossTreasureChestServer.cpp") -add_library(dScriptsServerMapAGSpiderQueen ${DSCRIPTS_SOURCES_02_SERVER_MAP_AG_SPIDER_QUEEN}) +add_library(dScriptsServerMapAGSpiderQueen OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_AG_SPIDER_QUEEN}) target_include_directories(dScriptsServerMapAGSpiderQueen PUBLIC ".") target_link_libraries(dScriptsServerMapAGSpiderQueen dScriptsServerMapProperty) target_precompile_headers(dScriptsServerMapAGSpiderQueen REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/AM/CMakeLists.txt b/dScripts/02_server/Map/AM/CMakeLists.txt index 177b3c45..81a37548 100644 --- a/dScripts/02_server/Map/AM/CMakeLists.txt +++ b/dScripts/02_server/Map/AM/CMakeLists.txt @@ -15,8 +15,10 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_AM "AmSkullkinDrillStand.cpp" "AmSkullkinTower.cpp" "AmBlueX.cpp" - "AmTeapotServer.cpp") + "AmTeapotServer.cpp" + "WanderingVendor.cpp" + ) -add_library(dScriptsServerMapAM ${DSCRIPTS_SOURCES_02_SERVER_MAP_AM}) +add_library(dScriptsServerMapAM OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_AM}) target_include_directories(dScriptsServerMapAM PUBLIC ".") target_precompile_headers(dScriptsServerMapAM REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/AM/WanderingVendor.cpp b/dScripts/02_server/Map/AM/WanderingVendor.cpp new file mode 100644 index 00000000..ae49aa94 --- /dev/null +++ b/dScripts/02_server/Map/AM/WanderingVendor.cpp @@ -0,0 +1,33 @@ +#include "WanderingVendor.h" +#include "MovementAIComponent.h" +#include "ProximityMonitorComponent.h" + +void WanderingVendor::OnStartup(Entity* self) { + auto movementAIComponent = self->GetComponent(); + if (!movementAIComponent) return; + // movementAIComponent->Resume(); + self->SetProximityRadius(10, "playermonitor"); +} + +void WanderingVendor::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { + if (status == "ENTER" && entering->IsPlayer()) { + auto movementAIComponent = self->GetComponent(); + if (!movementAIComponent) return; + // movementAIComponent->Pause(); + self->CancelTimer("startWalking"); + } else if (status == "LEAVE") { + auto* proximityMonitorComponent = self->GetComponent(); + if (!proximityMonitorComponent) self->AddComponent(); + + const auto proxObjs = proximityMonitorComponent->GetProximityObjects("playermonitor"); + if (proxObjs.empty()) self->AddTimer("startWalking", 1.5); + } +} + +void WanderingVendor::OnTimerDone(Entity* self, std::string timerName) { + if (timerName == "startWalking") { + auto movementAIComponent = self->GetComponent(); + if (!movementAIComponent) return; + // movementAIComponent->Resume(); + } +} diff --git a/dScripts/02_server/Map/AM/WanderingVendor.h b/dScripts/02_server/Map/AM/WanderingVendor.h new file mode 100644 index 00000000..e0cb1645 --- /dev/null +++ b/dScripts/02_server/Map/AM/WanderingVendor.h @@ -0,0 +1,13 @@ +#ifndef __WANDERINGVENDOR__H__ +#define __WANDERINGVENDOR__H__ + +#include "CppScripts.h" + +class WanderingVendor : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; + void OnTimerDone(Entity* self, std::string timerName) override; +}; + +#endif //!__WANDERINGVENDOR__H__ diff --git a/dScripts/02_server/Map/CMakeLists.txt b/dScripts/02_server/Map/CMakeLists.txt index a5fb5b03..33bd9bd4 100644 --- a/dScripts/02_server/Map/CMakeLists.txt +++ b/dScripts/02_server/Map/CMakeLists.txt @@ -13,17 +13,33 @@ add_subdirectory(SS) add_subdirectory(VE) add_library(dScriptsServerMap INTERFACE) -target_link_libraries(dScriptsServerMap INTERFACE - dScriptsServerMapAG - dScriptsServerMapAGSpiderQueen - dScriptsServerMapAM - dScriptsServerMapFV - dScriptsServerMapGeneral - dScriptsServerMapGF - dScriptsServerMapNJHub - dScriptsServerMapNS - dScriptsServerMapNT - dScriptsServerMapPR - dScriptsServerMapProperty - dScriptsServerMapSS - dScriptsServerMapVE) +target_sources(dScriptsServerMap INTERFACE + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ +) +target_include_directories(dScriptsServerMap INTERFACE + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ +) diff --git a/dScripts/02_server/Map/FV/CMakeLists.txt b/dScripts/02_server/Map/FV/CMakeLists.txt index 6f774c98..9746a5dd 100644 --- a/dScripts/02_server/Map/FV/CMakeLists.txt +++ b/dScripts/02_server/Map/FV/CMakeLists.txt @@ -11,6 +11,6 @@ foreach(file ${DSCRIPTS_SOURCES_02_SERVER_MAP_FV_RACING}) set(DSCRIPTS_SOURCES_02_SERVER_MAP_FV ${DSCRIPTS_SOURCES_02_SERVER_MAP_FV} "Racing/${file}") endforeach() -add_library(dScriptsServerMapFV ${DSCRIPTS_SOURCES_02_SERVER_MAP_FV}) +add_library(dScriptsServerMapFV OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_FV}) target_include_directories(dScriptsServerMapFV PUBLIC "." "Racing") target_precompile_headers(dScriptsServerMapFV REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/GF/CMakeLists.txt b/dScripts/02_server/Map/GF/CMakeLists.txt index 45ec871a..c6a95300 100644 --- a/dScripts/02_server/Map/GF/CMakeLists.txt +++ b/dScripts/02_server/Map/GF/CMakeLists.txt @@ -4,6 +4,6 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GF "MastTeleport.cpp" "SpawnLionServer.cpp") -add_library(dScriptsServerMapGF ${DSCRIPTS_SOURCES_02_SERVER_MAP_GF}) +add_library(dScriptsServerMapGF OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_GF}) target_include_directories(dScriptsServerMapGF PUBLIC ".") target_precompile_headers(dScriptsServerMapGF REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/General/CMakeLists.txt b/dScripts/02_server/Map/General/CMakeLists.txt index 4fe5aae8..3379e5b0 100644 --- a/dScripts/02_server/Map/General/CMakeLists.txt +++ b/dScripts/02_server/Map/General/CMakeLists.txt @@ -27,6 +27,6 @@ foreach(file ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL_NINJAGO}) set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL} "Ninjago/${file}") endforeach() -add_library(dScriptsServerMapGeneral ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL}) +add_library(dScriptsServerMapGeneral OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL}) target_include_directories(dScriptsServerMapGeneral PUBLIC "." "Ninjago") target_precompile_headers(dScriptsServerMapGeneral REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp b/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp index 9a1a4908..dd0a86d9 100644 --- a/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp +++ b/dScripts/02_server/Map/General/StoryBoxInteractServer.cpp @@ -6,7 +6,7 @@ #include "Entity.h" void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) { - if (self->GetVar(u"hasCustomText")) { + if (self->HasVar(u"customText")) { const auto& customText = self->GetVar(u"customText"); { @@ -29,15 +29,19 @@ void StoryBoxInteractServer::OnUse(Entity* self, Entity* user) { return; } + if (!self->HasVar(u"storyText") || !self->HasVar(u"altFlagID")) return; const auto storyText = self->GetVarAsString(u"storyText"); + if (storyText.length() > 2) { + auto storyValue = GeneralUtils::TryParse(storyText.substr(storyText.length() - 2)); + if(!storyValue) return; + int32_t boxFlag = self->GetVar(u"altFlagID"); + if (boxFlag <= 0) { + boxFlag = (10000 + Game::server->GetZoneID() + storyValue.value()); + } - int32_t boxFlag = self->GetVar(u"altFlagID"); - if (boxFlag <= 0) { - boxFlag = (10000 + Game::server->GetZoneID() + std::stoi(storyText.substr(storyText.length() - 2))); - } - - if (user->GetCharacter()->GetPlayerFlag(boxFlag) == false) { - user->GetCharacter()->SetPlayerFlag(boxFlag, true); - GameMessages::SendFireEventClientSide(self->GetObjectID(), user->GetSystemAddress(), u"achieve", LWOOBJID_EMPTY, 0, -1, LWOOBJID_EMPTY); + if (user->GetCharacter()->GetPlayerFlag(boxFlag) == false) { + user->GetCharacter()->SetPlayerFlag(boxFlag, true); + GameMessages::SendFireEventClientSide(self->GetObjectID(), user->GetSystemAddress(), u"achieve", LWOOBJID_EMPTY, 0, -1, LWOOBJID_EMPTY); + } } } diff --git a/dScripts/02_server/Map/NS/CMakeLists.txt b/dScripts/02_server/Map/NS/CMakeLists.txt index 4927f0c8..6be99dab 100644 --- a/dScripts/02_server/Map/NS/CMakeLists.txt +++ b/dScripts/02_server/Map/NS/CMakeLists.txt @@ -10,6 +10,6 @@ foreach(file ${DSCRIPTS_SOURCES_02_SERVER_MAP_NS_WAVES}) set(DSCRIPTS_SOURCES_02_SERVER_MAP_NS ${DSCRIPTS_SOURCES_02_SERVER_MAP_NS} "Waves/${file}") endforeach() -add_library(dScriptsServerMapNS ${DSCRIPTS_SOURCES_02_SERVER_MAP_NS}) +add_library(dScriptsServerMapNS OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_NS}) target_include_directories(dScriptsServerMapNS PUBLIC "." "Waves") target_precompile_headers(dScriptsServerMapNS REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/NT/CMakeLists.txt b/dScripts/02_server/Map/NT/CMakeLists.txt index 49c6a5ae..5ab3307c 100644 --- a/dScripts/02_server/Map/NT/CMakeLists.txt +++ b/dScripts/02_server/Map/NT/CMakeLists.txt @@ -27,6 +27,6 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_NT "NtBcSubmitServer.cpp" "NtNaomiBreadcrumbServer.cpp") -add_library(dScriptsServerMapNT ${DSCRIPTS_SOURCES_02_SERVER_MAP_NT}) +add_library(dScriptsServerMapNT OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_NT}) target_include_directories(dScriptsServerMapNT PUBLIC ".") target_precompile_headers(dScriptsServerMapNT REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/PR/CMakeLists.txt b/dScripts/02_server/Map/PR/CMakeLists.txt index 13b3fd35..8de0e71d 100644 --- a/dScripts/02_server/Map/PR/CMakeLists.txt +++ b/dScripts/02_server/Map/PR/CMakeLists.txt @@ -3,6 +3,6 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_PR "PrSeagullFly.cpp" "SpawnGryphonServer.cpp") -add_library(dScriptsServerMapPR ${DSCRIPTS_SOURCES_02_SERVER_MAP_PR}) +add_library(dScriptsServerMapPR OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_PR}) target_include_directories(dScriptsServerMapPR PUBLIC ".") target_precompile_headers(dScriptsServerMapPR REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/Property/CMakeLists.txt b/dScripts/02_server/Map/Property/CMakeLists.txt index 52b91d0b..b4085cfb 100644 --- a/dScripts/02_server/Map/Property/CMakeLists.txt +++ b/dScripts/02_server/Map/Property/CMakeLists.txt @@ -19,7 +19,7 @@ foreach(file ${DSCRIPTS_SOURCES_02_SERVER_MAP_PROPERTY_NS_MED}) set(DSCRIPTS_SOURCES_02_SERVER_MAP_PROPERTY ${DSCRIPTS_SOURCES_02_SERVER_MAP_PROPERTY} "NS_Med/${file}") endforeach() -add_library(dScriptsServerMapProperty ${DSCRIPTS_SOURCES_02_SERVER_MAP_PROPERTY}) +add_library(dScriptsServerMapProperty OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_PROPERTY}) target_precompile_headers(dScriptsServerMapProperty REUSE_FROM dScriptsBase) target_include_directories(dScriptsServerMapProperty PUBLIC "." "AG_Med" diff --git a/dScripts/02_server/Map/SS/CMakeLists.txt b/dScripts/02_server/Map/SS/CMakeLists.txt index ed6a7596..894d4ece 100644 --- a/dScripts/02_server/Map/SS/CMakeLists.txt +++ b/dScripts/02_server/Map/SS/CMakeLists.txt @@ -1,6 +1,6 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_SS "SsModularBuildServer.cpp") -add_library(dScriptsServerMapSS ${DSCRIPTS_SOURCES_02_SERVER_MAP_SS}) +add_library(dScriptsServerMapSS OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_SS}) target_include_directories(dScriptsServerMapSS PUBLIC ".") target_precompile_headers(dScriptsServerMapSS REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/VE/CMakeLists.txt b/dScripts/02_server/Map/VE/CMakeLists.txt index 2dbcaaff..8be55c9f 100644 --- a/dScripts/02_server/Map/VE/CMakeLists.txt +++ b/dScripts/02_server/Map/VE/CMakeLists.txt @@ -3,6 +3,6 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_VE "VeEpsilonServer.cpp" "VeBricksampleServer.cpp") -add_library(dScriptsServerMapVE ${DSCRIPTS_SOURCES_02_SERVER_MAP_VE}) +add_library(dScriptsServerMapVE OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_VE}) target_include_directories(dScriptsServerMapVE PUBLIC ".") target_precompile_headers(dScriptsServerMapVE REUSE_FROM dScriptsBase) diff --git a/dScripts/02_server/Map/njhub/CMakeLists.txt b/dScripts/02_server/Map/njhub/CMakeLists.txt index 0f287ce3..94d99867 100644 --- a/dScripts/02_server/Map/njhub/CMakeLists.txt +++ b/dScripts/02_server/Map/njhub/CMakeLists.txt @@ -28,7 +28,7 @@ foreach(file ${DSCRIPTS_SOURCES_02_SERVER_MAP_NJHUB_BOSS_INSTANCE}) set(DSCRIPTS_SOURCES_02_SERVER_MAP_NJHUB ${DSCRIPTS_SOURCES_02_SERVER_MAP_NJHUB} "boss_instance/${file}") endforeach() -add_library(dScriptsServerMapNJHub ${DSCRIPTS_SOURCES_02_SERVER_MAP_NJHUB}) +add_library(dScriptsServerMapNJHub OBJECT ${DSCRIPTS_SOURCES_02_SERVER_MAP_NJHUB}) target_include_directories(dScriptsServerMapNJHub PUBLIC "." "boss_instance") target_link_libraries(dScriptsServerMapNJHub dScriptsServerPets diff --git a/dScripts/02_server/Pets/CMakeLists.txt b/dScripts/02_server/Pets/CMakeLists.txt index 79123ebe..aa1d0e3f 100644 --- a/dScripts/02_server/Pets/CMakeLists.txt +++ b/dScripts/02_server/Pets/CMakeLists.txt @@ -3,7 +3,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_PETS "PetFromObjectServer.cpp" "DamagingPets.cpp") -add_library(dScriptsServerPets STATIC ${DSCRIPTS_SOURCES_02_SERVER_PETS}) +add_library(dScriptsServerPets OBJECT ${DSCRIPTS_SOURCES_02_SERVER_PETS}) target_include_directories(dScriptsServerPets PUBLIC ".") target_precompile_headers(dScriptsServerPets REUSE_FROM dScriptsBase) diff --git a/dScripts/CMakeLists.txt b/dScripts/CMakeLists.txt index b3fb7d44..d5290f33 100644 --- a/dScripts/CMakeLists.txt +++ b/dScripts/CMakeLists.txt @@ -17,18 +17,22 @@ set(DSCRIPTS_SOURCES link_libraries(dDatabase dPhysics) -add_library(dScriptsBase STATIC ${DSCRIPTS_SOURCES}) -target_include_directories(dScriptsBase PUBLIC .) -target_link_libraries(dScriptsBase - INTERFACE dGameBase) +add_library(dScriptsBase OBJECT ${DSCRIPTS_SOURCES}) +target_link_libraries(dScriptsBase INTERFACE dGameBase dComponents) target_precompile_headers(dScriptsBase PRIVATE ${HEADERS_DGAME}) include_directories( - ${PROJECT_SOURCE_DIR}/dScripts - ${PROJECT_SOURCE_DIR}/dGame + "${PROJECT_SOURCE_DIR}/dScripts" + "${PROJECT_SOURCE_DIR}/dGame" + "${PROJECT_SOURCE_DIR}/dGame/dComponents" # e.g. ScriptedActivityComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" # e.g. direct ActivityManager + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" # e.g. direct ActivityManager + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # via dZoneManager.h + "${PROJECT_SOURCE_DIR}/dGame/dMission" # via MissionComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" # viaInventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dInventory" # via InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dZoneManager" ) -link_libraries(dScriptsBase) -# dComponents add_subdirectory(02_server) add_subdirectory(ai) @@ -37,14 +41,22 @@ add_subdirectory(EquipmentScripts) add_subdirectory(EquipmentTriggers) add_subdirectory(zone) -add_library(dScripts STATIC "CppScripts.cpp") +add_library(dScripts STATIC + $ + $ + $ + $ + $ + "CppScripts.cpp" +) +target_link_libraries(dScripts PRIVATE dScriptsAI dScriptsServer) +target_include_directories(dScripts PRIVATE + $ + $ + $ + $ + $ + $ + $ +) target_precompile_headers(dScripts REUSE_FROM dScriptsBase) -target_include_directories(dScripts PUBLIC ".") -target_link_libraries(dScripts - dScriptsBase - dScriptsServer - dScriptsAI - dScriptsClient - dScriptsEquipmentScripts - dScriptsEquipmentTriggers - dScriptsZone) diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 7cb853e6..1b66b447 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -240,6 +240,7 @@ #include "AmDarklingDragon.h" #include "AmBlueX.h" #include "AmTeapotServer.h" +#include "WanderingVendor.h" // NJ Scripts #include "NjGarmadonCelebration.h" @@ -317,6 +318,8 @@ #include "WildNinjaSensei.h" #include "WildNinjaBricks.h" #include "VisToggleNotifierServer.h" +#include "LupGenericInteract.h" +#include "WblRobotCitizen.h" namespace { InvalidScript* invalidToReturn = new InvalidScript(); @@ -547,7 +550,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr //PR: else if (scriptName == "scripts\\client\\ai\\PR\\L_PR_WHISTLE.lua") script = new PrWhistle(); - else if (scriptName == "scripts\\02_server\\Map\\PR\\L_PR_SEAGULL_FLY.lua") + if (scriptName == "scripts\\02_server\\Map\\PR\\L_PR_SEAGULL_FLY.lua") script = new PrSeagullFly(); else if (scriptName == "scripts\\ai\\PETS\\L_HYDRANT_SMASHABLE.lua") script = new HydrantSmashable(); @@ -642,6 +645,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new MailBoxServer(); else if (scriptName == "scripts\\ai\\ACT\\L_ACT_MINE.lua") script = new ActMine(); + else if (scriptName == "scripts\\02_server\\Map\\AM\\L_WANDERING_VENDOR.lua") + script = new WanderingVendor(); //Racing: else if (scriptName == "scripts\\ai\\RACING\\OBJECTS\\RACE_IMAGINE_CRATE_SERVER.lua") @@ -726,7 +731,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new NTNaomiDirtServer(); //AM: - else if (scriptName == "scripts\\02_server\\Map\\AM\\L_AM_CONSOLE_TELEPORT_SERVER.lua") + if (scriptName == "scripts\\02_server\\Map\\AM\\L_AM_CONSOLE_TELEPORT_SERVER.lua") script = new AmConsoleTeleportServer(); else if (scriptName == "scripts\\02_server\\Map\\AM\\L_RANDOM_SPAWNER_FIN.lua") script = new RandomSpawnerFin(); @@ -806,7 +811,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new Lieutenant(); else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_RAIN_OF_ARROWS.lua") script = new RainOfArrows(); - else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_CAVE_PRISON_CAGE.lua") + if (scriptName == "scripts\\02_server\\Map\\njhub\\L_CAVE_PRISON_CAGE.lua") script = new CavePrisonCage(); else if (scriptName == "scripts\\02_server\\Map\\njhub\\boss_instance\\L_MONASTERY_BOSS_INSTANCE_SERVER.lua") script = new NjMonastryBossInstance(); @@ -938,6 +943,10 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new WildNinjaStudent(); else if (scriptName == "scripts\\ai\\WILD\\L_WILD_NINJA_SENSEI.lua") script = new WildNinjaSensei(); + else if (scriptName == "scripts\\ai\\WILD\\L_LUP_generic_interact.lua") + script = new LupGenericInteract(); + else if (scriptName.rfind("scripts\\zone\\LUPs\\RobotCity Intro\\WBL_RCIntro_RobotCitizen", 0) == 0) + script = new WblRobotCitizen(); // handle invalid script reporting if the path is greater than zero and it's not an ignored script // information not really needed for sys admins but is for developers diff --git a/dScripts/EquipmentScripts/CMakeLists.txt b/dScripts/EquipmentScripts/CMakeLists.txt index 08966e08..60f31503 100644 --- a/dScripts/EquipmentScripts/CMakeLists.txt +++ b/dScripts/EquipmentScripts/CMakeLists.txt @@ -8,6 +8,6 @@ set(DSCRIPTS_SOURCES_EQUIPMENTSCRIPTS "FireFirstSkillonStartup.cpp" "StunImmunity.cpp") -add_library(dScriptsEquipmentScripts STATIC ${DSCRIPTS_SOURCES_EQUIPMENTSCRIPTS}) +add_library(dScriptsEquipmentScripts OBJECT ${DSCRIPTS_SOURCES_EQUIPMENTSCRIPTS}) target_include_directories(dScriptsEquipmentScripts PUBLIC ".") target_precompile_headers(dScriptsEquipmentScripts REUSE_FROM dScriptsBase) diff --git a/dScripts/EquipmentTriggers/CMakeLists.txt b/dScripts/EquipmentTriggers/CMakeLists.txt index cb6e81a8..af0a1425 100644 --- a/dScripts/EquipmentTriggers/CMakeLists.txt +++ b/dScripts/EquipmentTriggers/CMakeLists.txt @@ -1,6 +1,6 @@ set(DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS "CoilBackpackBase.cpp") -add_library(dScriptsEquipmentTriggers STATIC ${DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS}) +add_library(dScriptsEquipmentTriggers OBJECT ${DSCRIPTS_SOURCES_EQUIPMENTTRIGGERSSCRIPTS}) target_include_directories(dScriptsEquipmentTriggers PUBLIC ".") target_precompile_headers(dScriptsEquipmentTriggers REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/ACT/CMakeLists.txt b/dScripts/ai/ACT/CMakeLists.txt index 5071afa0..680c5e4c 100644 --- a/dScripts/ai/ACT/CMakeLists.txt +++ b/dScripts/ai/ACT/CMakeLists.txt @@ -9,6 +9,6 @@ foreach(file ${DSCRIPTS_SOURCES_AI_ACT_FOOTRACE}) set(DSCRIPTS_SOURCES_AI_ACT ${DSCRIPTS_SOURCES_AI_ACT} "FootRace/${file}") endforeach() -add_library(dScriptsAiAct STATIC ${DSCRIPTS_SOURCES_AI_ACT}) +add_library(dScriptsAiAct OBJECT ${DSCRIPTS_SOURCES_AI_ACT}) target_include_directories(dScriptsAiAct PUBLIC "." "FootRace") target_precompile_headers(dScriptsAiAct REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/AG/CMakeLists.txt b/dScripts/ai/AG/CMakeLists.txt index e031e386..e74aac78 100644 --- a/dScripts/ai/AG/CMakeLists.txt +++ b/dScripts/ai/AG/CMakeLists.txt @@ -16,6 +16,6 @@ set(DSCRIPTS_SOURCES_AI_AG "AgStagePlatforms.cpp" "AgQbWall.cpp") -add_library(dScriptsAiAG STATIC ${DSCRIPTS_SOURCES_AI_AG}) +add_library(dScriptsAiAG OBJECT ${DSCRIPTS_SOURCES_AI_AG}) target_include_directories(dScriptsAiAG PUBLIC ".") target_precompile_headers(dScriptsAiAG REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/CMakeLists.txt b/dScripts/ai/CMakeLists.txt index 7e94cd34..354bda21 100644 --- a/dScripts/ai/CMakeLists.txt +++ b/dScripts/ai/CMakeLists.txt @@ -15,18 +15,34 @@ add_subdirectory(SPEC) add_subdirectory(WILD) add_library(dScriptsAI INTERFACE) -target_link_libraries(dScriptsAI INTERFACE - dScriptsAiAct - dScriptsAiAG - dScriptsAiFV - dScriptsAiGeneral - dScriptsAiGF - dScriptsAiMinigame - dScriptsAiNP - dScriptsAiNS - dScriptsAiPets - dScriptsAiProperty - dScriptsAiRacing - dScriptsAiSpec - dScriptsAiWild +target_sources(dScriptsAI INTERFACE + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ +) + +target_include_directories(dScriptsAI INTERFACE + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ + $ ) diff --git a/dScripts/ai/FV/CMakeLists.txt b/dScripts/ai/FV/CMakeLists.txt index 55c68a27..535a02a6 100644 --- a/dScripts/ai/FV/CMakeLists.txt +++ b/dScripts/ai/FV/CMakeLists.txt @@ -18,7 +18,7 @@ set(DSCRIPTS_SOURCES_AI_FV "FvMaelstromGeyser.cpp" "TriggerGas.cpp") -add_library(dScriptsAiFV STATIC ${DSCRIPTS_SOURCES_AI_FV}) +add_library(dScriptsAiFV OBJECT ${DSCRIPTS_SOURCES_AI_FV}) target_include_directories(dScriptsAiFV PUBLIC ".") target_precompile_headers(dScriptsAiFV REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/GENERAL/CMakeLists.txt b/dScripts/ai/GENERAL/CMakeLists.txt index 9b7f2a2a..77441b4a 100644 --- a/dScripts/ai/GENERAL/CMakeLists.txt +++ b/dScripts/ai/GENERAL/CMakeLists.txt @@ -2,7 +2,7 @@ set(DSCRIPTS_SOURCES_AI_GENERAL "InstanceExitTransferPlayerToLastNonInstance.cpp" "LegoDieRoll.cpp") -add_library(dScriptsAiGeneral STATIC ${DSCRIPTS_SOURCES_AI_GENERAL}) +add_library(dScriptsAiGeneral OBJECT ${DSCRIPTS_SOURCES_AI_GENERAL}) target_include_directories(dScriptsAiGeneral PUBLIC ".") target_precompile_headers(dScriptsAiGeneral REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/GF/CMakeLists.txt b/dScripts/ai/GF/CMakeLists.txt index 7a7a1723..d28b04f1 100644 --- a/dScripts/ai/GF/CMakeLists.txt +++ b/dScripts/ai/GF/CMakeLists.txt @@ -12,6 +12,6 @@ set(DSCRIPTS_SOURCES_AI_GF "PirateRep.cpp" "GfParrotCrash.cpp") -add_library(dScriptsAiGF STATIC ${DSCRIPTS_SOURCES_AI_GF}) +add_library(dScriptsAiGF OBJECT ${DSCRIPTS_SOURCES_AI_GF}) target_include_directories(dScriptsAiGF PUBLIC ".") target_precompile_headers(dScriptsAiGF REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/MINIGAME/CMakeLists.txt b/dScripts/ai/MINIGAME/CMakeLists.txt index 0e07d526..5598110b 100644 --- a/dScripts/ai/MINIGAME/CMakeLists.txt +++ b/dScripts/ai/MINIGAME/CMakeLists.txt @@ -12,6 +12,6 @@ foreach(file ${DSCRIPTS_SOURCES_AI_MINIGAME_OBJECTS}) set(DSCRIPTS_SOURCES_AI_MINIGAME ${DSCRIPTS_SOURCES_AI_MINIGAME} "Objects/${file}") endforeach() -add_library(dScriptsAiMinigame STATIC ${DSCRIPTS_SOURCES_AI_MINIGAME}) +add_library(dScriptsAiMinigame OBJECT ${DSCRIPTS_SOURCES_AI_MINIGAME}) target_include_directories(dScriptsAiMinigame PUBLIC "." "Objects" "SG_GF" "SG_GF/SERVER") target_precompile_headers(dScriptsAiMinigame REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/NP/CMakeLists.txt b/dScripts/ai/NP/CMakeLists.txt index 9f3f6a65..b71bd1f8 100644 --- a/dScripts/ai/NP/CMakeLists.txt +++ b/dScripts/ai/NP/CMakeLists.txt @@ -1,6 +1,6 @@ set(DSCRIPTS_SOURCES_AI_NP "NpcNpSpacemanBob.cpp") -add_library(dScriptsAiNP STATIC ${DSCRIPTS_SOURCES_AI_NP}) +add_library(dScriptsAiNP OBJECT ${DSCRIPTS_SOURCES_AI_NP}) target_include_directories(dScriptsAiNP PUBLIC ".") target_precompile_headers(dScriptsAiNP REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/NS/CMakeLists.txt b/dScripts/ai/NS/CMakeLists.txt index 0f0aa0c7..750ee67a 100644 --- a/dScripts/ai/NS/CMakeLists.txt +++ b/dScripts/ai/NS/CMakeLists.txt @@ -21,7 +21,7 @@ foreach(file ${DSCRIPTS_SOURCES_AI_NS_WH}) set(DSCRIPTS_SOURCES_AI_NS ${DSCRIPTS_SOURCES_AI_NS} "WH/${file}") endforeach() -add_library(dScriptsAiNS STATIC ${DSCRIPTS_SOURCES_AI_NS}) +add_library(dScriptsAiNS OBJECT ${DSCRIPTS_SOURCES_AI_NS}) target_include_directories(dScriptsAiNS PUBLIC "." "NS_PP_01" "WH" PRIVATE ${PROJECT_SOURCE_DIR}/dScripts/02_server/Map/NS) # NsConcertChoiceBuildManager.h diff --git a/dScripts/ai/PETS/CMakeLists.txt b/dScripts/ai/PETS/CMakeLists.txt index 8bd8630c..b7ae2033 100644 --- a/dScripts/ai/PETS/CMakeLists.txt +++ b/dScripts/ai/PETS/CMakeLists.txt @@ -1,6 +1,6 @@ set(DSCRIPTS_SOURCES_AI_PETS "HydrantSmashable.cpp") -add_library(dScriptsAiPets STATIC ${DSCRIPTS_SOURCES_AI_PETS}) +add_library(dScriptsAiPets OBJECT ${DSCRIPTS_SOURCES_AI_PETS}) target_include_directories(dScriptsAiPets PUBLIC "." "NS_PP_01" "WH") target_precompile_headers(dScriptsAiPets REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/PROPERTY/CMakeLists.txt b/dScripts/ai/PROPERTY/CMakeLists.txt index a31b9257..07c528f7 100644 --- a/dScripts/ai/PROPERTY/CMakeLists.txt +++ b/dScripts/ai/PROPERTY/CMakeLists.txt @@ -8,6 +8,6 @@ foreach(file ${DSCRIPTS_SOURCES_AI_PROPERTY_AG}) set(DSCRIPTS_SOURCES_AI_PROPERTY ${DSCRIPTS_SOURCES_AI_PROPERTY} "AG/${file}") endforeach() -add_library(dScriptsAiProperty STATIC ${DSCRIPTS_SOURCES_AI_PROPERTY}) +add_library(dScriptsAiProperty OBJECT ${DSCRIPTS_SOURCES_AI_PROPERTY}) target_include_directories(dScriptsAiProperty PUBLIC "." "AG") target_precompile_headers(dScriptsAiProperty REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/RACING/CMakeLists.txt b/dScripts/ai/RACING/CMakeLists.txt index b7343c61..a803b051 100644 --- a/dScripts/ai/RACING/CMakeLists.txt +++ b/dScripts/ai/RACING/CMakeLists.txt @@ -6,6 +6,6 @@ foreach(file ${DSCRIPTS_SOURCES_AI_RACING_OBJECTS}) set(DSCRIPTS_SOURCES_AI_RACING ${DSCRIPTS_SOURCES_AI_RACING} "OBJECTS/${file}") endforeach() -add_library(dScriptsAiRacing STATIC ${DSCRIPTS_SOURCES_AI_RACING}) +add_library(dScriptsAiRacing OBJECT ${DSCRIPTS_SOURCES_AI_RACING}) target_include_directories(dScriptsAiRacing PUBLIC "." "OBJECTS") target_precompile_headers(dScriptsAiRacing REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/SPEC/CMakeLists.txt b/dScripts/ai/SPEC/CMakeLists.txt index c60372ac..29a781eb 100644 --- a/dScripts/ai/SPEC/CMakeLists.txt +++ b/dScripts/ai/SPEC/CMakeLists.txt @@ -3,6 +3,6 @@ set(DSCRIPTS_SOURCES_AI_SPEC "SpecialPowerupSpawner.cpp" "SpecialSpeedBuffSpawner.cpp") -add_library(dScriptsAiSpec STATIC ${DSCRIPTS_SOURCES_AI_SPEC}) +add_library(dScriptsAiSpec OBJECT ${DSCRIPTS_SOURCES_AI_SPEC}) target_include_directories(dScriptsAiSpec PUBLIC ".") target_precompile_headers(dScriptsAiSpec REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/WILD/CMakeLists.txt b/dScripts/ai/WILD/CMakeLists.txt index 418ffb5f..5d4f43c3 100644 --- a/dScripts/ai/WILD/CMakeLists.txt +++ b/dScripts/ai/WILD/CMakeLists.txt @@ -1,5 +1,6 @@ set(DSCRIPTS_SOURCES_AI_WILD "AllCrateChicken.cpp" + "LupGenericInteract.cpp" "WildAmbients.cpp" "WildAmbientCrab.cpp" "WildAndScared.cpp" @@ -9,6 +10,6 @@ set(DSCRIPTS_SOURCES_AI_WILD "WildNinjaSensei.cpp" "WildPants.cpp") -add_library(dScriptsAiWild STATIC ${DSCRIPTS_SOURCES_AI_WILD}) +add_library(dScriptsAiWild OBJECT ${DSCRIPTS_SOURCES_AI_WILD}) target_include_directories(dScriptsAiWild PUBLIC ".") target_precompile_headers(dScriptsAiWild REUSE_FROM dScriptsBase) diff --git a/dScripts/ai/WILD/LupGenericInteract.cpp b/dScripts/ai/WILD/LupGenericInteract.cpp new file mode 100644 index 00000000..95eb7a96 --- /dev/null +++ b/dScripts/ai/WILD/LupGenericInteract.cpp @@ -0,0 +1,6 @@ +#include "LupGenericInteract.h" +#include "GameMessages.h" + +void LupGenericInteract::OnUse(Entity* self, Entity* user) { + GameMessages::SendPlayAnimation(self, u"interact"); +} diff --git a/dScripts/ai/WILD/LupGenericInteract.h b/dScripts/ai/WILD/LupGenericInteract.h new file mode 100644 index 00000000..68949bbf --- /dev/null +++ b/dScripts/ai/WILD/LupGenericInteract.h @@ -0,0 +1,12 @@ +#ifndef __LUCGENERICINTERACT__H__ +#define __LUCGENERICINTERACT__H__ + +#include "CppScripts.h" + +class LupGenericInteract : public CppScripts::Script { +public: + void OnUse(Entity* self, Entity* user) override; +}; + +#endif //!__LUCGENERICINTERACT__H__ + diff --git a/dScripts/client/CMakeLists.txt b/dScripts/client/CMakeLists.txt index b3ad08fb..f6760006 100644 --- a/dScripts/client/CMakeLists.txt +++ b/dScripts/client/CMakeLists.txt @@ -6,6 +6,6 @@ foreach(file ${DSCRIPTS_SOURCES_CLIENT_AI}) set(DSCRIPTS_SOURCES_CLIENT ${DSCRIPTS_SOURCES_CLIENT} "ai/${file}") endforeach() -add_library(dScriptsClient STATIC ${DSCRIPTS_SOURCES_CLIENT}) +add_library(dScriptsClient OBJECT ${DSCRIPTS_SOURCES_CLIENT}) target_include_directories(dScriptsClient PUBLIC "." "ai" "ai/PR") target_precompile_headers(dScriptsClient REUSE_FROM dScriptsBase) diff --git a/dScripts/zone/CMakeLists.txt b/dScripts/zone/CMakeLists.txt index 93ea70ca..fe919cd4 100644 --- a/dScripts/zone/CMakeLists.txt +++ b/dScripts/zone/CMakeLists.txt @@ -18,10 +18,11 @@ foreach(file ${DSCRIPTS_SOURCES_ZONE_PROPERTY}) set(DSCRIPTS_SOURCES_ZONE ${DSCRIPTS_SOURCES_ZONE} "PROPERTY/${file}") endforeach() -add_library(dScriptsZone STATIC ${DSCRIPTS_SOURCES_ZONE}) +add_library(dScriptsZone OBJECT ${DSCRIPTS_SOURCES_ZONE}) target_include_directories(dScriptsZone PUBLIC "." "AG" "LUPs" + "LUPs/RobotCity_Intro" "PROPERTY" "PROPERTY/FV" "PROPERTY/GF" diff --git a/dScripts/zone/LUPs/CMakeLists.txt b/dScripts/zone/LUPs/CMakeLists.txt index b3b55ad6..7ce84fcc 100644 --- a/dScripts/zone/LUPs/CMakeLists.txt +++ b/dScripts/zone/LUPs/CMakeLists.txt @@ -1,3 +1,11 @@ -set(DSCRIPTS_SOURCES_ZONE_LUPS +set(DSCRIPTS_SOURCES_ZONE_LUPS "WblGenericZone.cpp" - PARENT_SCOPE) +) + +add_subdirectory(RobotCity_Intro) + +foreach(file ${DSCRIPTS_SOURCES_ZONE_LUPS_ROBOTCITYINTRO}) + set(DSCRIPTS_SOURCES_ZONE_LUPS ${DSCRIPTS_SOURCES_ZONE_LUPS} "RobotCity_Intro/${file}") +endforeach() + +set(DSCRIPTS_SOURCES_ZONE_LUPS ${DSCRIPTS_SOURCES_ZONE_LUPS} PARENT_SCOPE) diff --git a/dScripts/zone/LUPs/RobotCity_Intro/CMakeLists.txt b/dScripts/zone/LUPs/RobotCity_Intro/CMakeLists.txt new file mode 100644 index 00000000..fae8793b --- /dev/null +++ b/dScripts/zone/LUPs/RobotCity_Intro/CMakeLists.txt @@ -0,0 +1,3 @@ +set(DSCRIPTS_SOURCES_ZONE_LUPS_ROBOTCITYINTRO + "WblRobotCitizen.cpp" + PARENT_SCOPE) diff --git a/dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.cpp b/dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.cpp new file mode 100644 index 00000000..93bf2576 --- /dev/null +++ b/dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.cpp @@ -0,0 +1,24 @@ +#include "WblRobotCitizen.h" +#include "MovementAIComponent.h" +#include "RenderComponent.h" + +void WblRobotCitizen::OnStartup(Entity* self) { + auto movementAIComponent = self->GetComponent(); + if (!movementAIComponent) return; + // movementAIComponent->Resume(); +} + +void WblRobotCitizen::OnUse(Entity* self, Entity* user) { + // auto movementAIComponent = self->GetComponent(); + // if (!movementAIComponent) movementAIComponent->Pause(); + auto face = NiQuaternion::LookAt(self->GetPosition(), user->GetPosition()); + self->SetRotation(face); + auto timer = RenderComponent::PlayAnimation(self, "wave"); + self->AddTimer("animation time", timer); +} + +void WblRobotCitizen::OnTimerDone(Entity* self, std::string timerName) { + auto movementAIComponent = self->GetComponent(); + if (!movementAIComponent) return; + // movementAIComponent->Resume(); +} diff --git a/dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.h b/dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.h new file mode 100644 index 00000000..2f720764 --- /dev/null +++ b/dScripts/zone/LUPs/RobotCity_Intro/WblRobotCitizen.h @@ -0,0 +1,13 @@ +#ifndef __WBLROBOTCITIZEN__H__ +#define __WBLROBOTCITIZEN__H__ + +#include "CppScripts.h" + +class WblRobotCitizen : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnUse(Entity* self, Entity* user) override; + void OnTimerDone(Entity* self, std::string timerName) override; +}; + +#endif //!__WBLROBOTCITIZEN__H__ diff --git a/dServer/CMakeLists.txt b/dServer/CMakeLists.txt index 356e55b7..ca4e6198 100644 --- a/dServer/CMakeLists.txt +++ b/dServer/CMakeLists.txt @@ -4,3 +4,7 @@ set(DSERVER_SOURCES add_library(dServer STATIC ${DSERVER_SOURCES}) target_include_directories(dServer PUBLIC ".") + +target_include_directories(dServer PRIVATE + "${PROJECT_SOURCE_DIR}/dCommon/" # BinaryPathFinder.h +) diff --git a/dWorldServer/CMakeLists.txt b/dWorldServer/CMakeLists.txt index 41cba0e2..62a3767a 100644 --- a/dWorldServer/CMakeLists.txt +++ b/dWorldServer/CMakeLists.txt @@ -2,11 +2,22 @@ set(DWORLDSERVER_SOURCES "PerformanceManager.cpp" ) -add_library(dWorldServer ${DWORLDSERVER_SOURCES}) +add_library(dWorldServer OBJECT ${DWORLDSERVER_SOURCES}) +target_link_libraries(dWorldServer PUBLIC dGameBase dCommon) + add_executable(WorldServer "WorldServer.cpp") +target_include_directories(WorldServer PRIVATE "${PROJECT_SOURCE_DIR}/dChatFilter") add_compile_definitions(WorldServer PRIVATE PROJECT_VERSION="\"${PROJECT_VERSION}\"") -target_link_libraries(dWorldServer ${COMMON_LIBRARIES}) -target_link_libraries(WorldServer ${COMMON_LIBRARIES} dChatFilter dGame dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dNavigation dServer) -target_include_directories(WorldServer PRIVATE ${PROJECT_SOURCE_DIR}/dServer) +target_include_directories(WorldServer PRIVATE + "${PROJECT_SOURCE_DIR}/dServer" # BinaryPathFinder.h +) +target_link_libraries(WorldServer ${COMMON_LIBRARIES} + dScripts + dGameBase + dComponents + dUtilities + dGameMessages + dInventory + dGame dChatFilter dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dNavigation dServer) diff --git a/dZoneManager/CMakeLists.txt b/dZoneManager/CMakeLists.txt index e7382367..544a01d9 100644 --- a/dZoneManager/CMakeLists.txt +++ b/dZoneManager/CMakeLists.txt @@ -3,7 +3,20 @@ set(DZONEMANAGER_SOURCES "dZoneManager.cpp" "Spawner.cpp" "Zone.cpp") -add_library(dZoneManager STATIC ${DZONEMANAGER_SOURCES}) +add_library(dZoneManager OBJECT ${DZONEMANAGER_SOURCES}) target_link_libraries(dZoneManager - PUBLIC dPhysics - INTERFACE dWorldServer) + PRIVATE dDatabaseCDClient + PUBLIC dPhysics) + +#set_property(TARGET dZoneManager APPEND PROPERTY INTERFACE_LINK_LIBRARIES dWorldServer) + +target_include_directories(dZoneManager PUBLIC "." + "${PROJECT_SOURCE_DIR}/dGame" # Entity.h + "${PROJECT_SOURCE_DIR}/dGame/dEntity" # EntityInfo.h + PRIVATE + "${PROJECT_SOURCE_DIR}/dGame/dComponents" #InventoryComponent.h + "${PROJECT_SOURCE_DIR}/dGame/dInventory" #InventoryComponent.h (transitive) + "${PROJECT_SOURCE_DIR}/dGame/dBehaviors" #BehaviorSlot.h + "${PROJECT_SOURCE_DIR}/dGame/dGameMessages" #GameMessages.h + "${PROJECT_SOURCE_DIR}/dGame/dUtilities" #VanityUtilities.h +) diff --git a/dZoneManager/Zone.cpp b/dZoneManager/Zone.cpp index 42ce1215..38c3a1ee 100644 --- a/dZoneManager/Zone.cpp +++ b/dZoneManager/Zone.cpp @@ -419,7 +419,7 @@ void Zone::LoadPath(std::istream& file) { if (path.pathType == PathType::MovingPlatform) { BinaryIO::BinaryRead(file, waypoint.movingPlatform.lockPlayer); - BinaryIO::BinaryRead(file, waypoint.movingPlatform.speed); + BinaryIO::BinaryRead(file, waypoint.speed); BinaryIO::BinaryRead(file, waypoint.movingPlatform.wait); if (path.pathVersion >= 13) { BinaryIO::ReadString(file, waypoint.movingPlatform.departSound, BinaryIO::ReadType::WideString); @@ -438,7 +438,7 @@ void Zone::LoadPath(std::istream& file) { BinaryIO::BinaryRead(file, waypoint.racing.planeHeight); BinaryIO::BinaryRead(file, waypoint.racing.shortestDistanceToEnd); } else if (path.pathType == PathType::Rail) { - if (path.pathVersion > 16) BinaryIO::BinaryRead(file, waypoint.rail.speed); + if (path.pathVersion > 16) BinaryIO::BinaryRead(file, waypoint.speed); } // object LDF configs diff --git a/dZoneManager/Zone.h b/dZoneManager/Zone.h index a62a81ed..2f394510 100644 --- a/dZoneManager/Zone.h +++ b/dZoneManager/Zone.h @@ -40,7 +40,6 @@ struct SceneTransition { struct MovingPlatformPathWaypoint { uint8_t lockPlayer; - float speed; float wait; std::string departSound; std::string arriveSound; @@ -62,17 +61,13 @@ struct RacingPathWaypoint { float shortestDistanceToEnd; }; -struct RailPathWaypoint { - float speed; -}; - struct PathWaypoint { NiPoint3 position; NiQuaternion rotation; // not included in all, but it's more convenient here MovingPlatformPathWaypoint movingPlatform; CameraPathWaypoint camera; RacingPathWaypoint racing; - RailPathWaypoint rail; + float speed; std::vector config; }; diff --git a/docs/Vanity.md b/docs/Vanity.md new file mode 100644 index 00000000..ac2c4263 --- /dev/null +++ b/docs/Vanity.md @@ -0,0 +1,170 @@ +# DLU Vanity System + +Darkflame Universe Vanity System is a method of defined objects to be spawned serverside and communicated to the client without modifying the game's assets. + +You can check out the different `xml` files in `vanity/` and use `vanity/demo.xml` to follow along with this tutorial and documentation of thew various features, cabapilities, and limitations of this system. + +## `vanity/root.xml` +`root.xml` is the only file the server will load in by default. + +To load other files, you can do so like this: +```xml + + + + + +``` + +`name` is the name of the file relative to the vanity folder. +Ex: you have a folder like `vanity/events/` with a file called `halloween.xml` in it, you will include it as such: + +`` + +`enabled` tells if that file should be loaded. +files will only be loaded in, if `enabled="1"` + +There cannot be multiple `` per xml file, only the first one will be read, but you can have as many `` in it as you wish. + +## `vanity/demo.xml` + +This demo file covers most of the features of defining objects to spawn server side and will go over them one by one. + +The minimun data needed to define and ojbect to spawn is as follows: +```xml + + + + + + + +``` + + * `lot` the LEGO Object Template to be spawned + + * `` must have `zone`, `x`, `y`, `z` `rw`, `rx`, `ry`, and `rz` and one `location` must in exist in `locations` for it to be spawned + +Everything else is is optional. + +* LEGO Name Value (LNV) configs can control almost all functionality of the objects in the game, they are defined like `name=type:value`. types can be found in `dCommon/LDFFromat.h` + +```xml + + bool=7:1 + +``` + +### Story Plaque with custom text + +lot 8193 is the story plaque that is used in game to give the game lore to the player. + +DLU Vanity has the capability to provide custom text to it via a LNV config + +From `demo.xml` +```xml + + + customText=13:This story plaque has custom text that is defined by DLU's vanity system. Check out <font color="#000000" >vanity/demo.xml</font> to see how this works! + + + + + +``` + + * The `customText` config must be a type of `13` (wstring) + * HTML like formatting can be used for font color, but `<` must be reaplaced withh `>`, and `>` replaced with `<` + +### Object with multiple locations and scale + +```xml + + + + + + +``` +#### Multiple locations +Multiple location elements can be defined for an object. +For every location that object will spawn: +This will spawn two trees, one at each specified location. + +#### Scale +Each location can specify a `scale` which defaults to `1`. The object will be scaled by this attribute in the location when defined. + +### Object with multiple random locations and chance + +```xml + + + useLocationsAsRandomSpawnPoint=7:1 + + + + + + + +``` +#### Random Spawn Point +If the LNV config `useLocationsAsRandomSpawnPoint=7:1` is defined and is set to `1`, instead of spawning the object at every location, it will randomly choose between all locations in the current zone to spawn one instance of the object. +If a location is not in the current zone, it will not be considered. + +#### Chance +Each location can specify a `chance` attribute. This defines a chance from, `0` to `1` that the object will spawn, with `0` being never spawn, and `1` being always spawn. A `chance="0.8"` will have an 80% chance for the object to spawn at that location. + +`useLocationsAsRandomSpawnPoint` and `chance` are independent of each other and be used separately + +### Custom vendor with custom name and gear + +```xml + + 7630, 1727, 7453, 7521 + + vendorInvOverride=0:1727,7292,16553,2243,14535,14538,14531,6730 + + + + + +``` +#### Custom vendor + +For a custom vendor to work, you must use a LOT that already has a vendor compoenet attached to it. + +Without an LNV keys, it will give it's normal inventory +You muse define `vendorInvOverride=0:` and then a list of LOTs that the vendor will sell. This will override all items the vendor was selling and use the list of LOTs provided. + +LOTs must have an item component in order to be sold by a vendor. + +#### Custom Name + +The `name` attribute will give or override the name displayed for an object, if it displays one. +Using a ` - ` will allow you to define a title that will display under their name on their nametag (formally called a billboard). + +#### Custom Gear + +The `equipment` element is a lis of comma separated lots that will defind the geat an object will attempt to equip. + +LOTs must have an inventory component in order to equipe custom gear. + +### Creating Spawners +```xml + + + ... + spawntemplate=1:2295 + ... + + + + + + +``` + +LOT `167` is a spawner. The spawner config in the `demo.xml` was copied from an existing object via lcdr's luzviewer. + +The main config to care about is `spawntemplate` as that controls what the spawner spawns. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9ba75a2f..e8765191 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,20 +1,19 @@ -message (STATUS "Testing is enabled. Fetching gtest...") +message (STATUS "Testing is enabled.") enable_testing() -include(FetchContent) -FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.12.1 -) - -# For Windows: Prevent overriding the parent project's compiler/linker settings -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - -FetchContent_MakeAvailable(GoogleTest) +find_package(GoogleTest REQUIRED) include(GoogleTest) -message(STATUS "gtest fetched and is now ready.") +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) + +if(APPLE) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True) + set(CMAKE_BUILD_WITH_INSTALL_RPATH True) + set(CMAKE_INSTALL_RPATH "@executable_path") +endif() + +add_custom_target(conncpp_tests + ${CMAKE_COMMAND} -E copy $ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) # Add the subdirectories add_subdirectory(dCommonTests) diff --git a/tests/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index be23d866..cf0a03ed 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -17,6 +17,19 @@ list(APPEND DCOMMONTEST_SOURCES ${DENUMS_TESTS}) # Set our executable add_executable(dCommonTests ${DCOMMONTEST_SOURCES}) +add_dependencies(dCommonTests conncpp_tests) + +# Apple needs some special linkage for the mariadb connector for tests. +if(APPLE) +add_custom_command(TARGET dCommonTests POST_BUILD + COMMAND otool ARGS -l dCommonTests + COMMAND otool ARGS -L dCommonTests + COMMAND ls + COMMAND otool ARGS -D libmariadbcpp.dylib + COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dCommonTests + COMMAND otool ARGS -L dCommonTests + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +endif() # Link needed libraries target_link_libraries(dCommonTests ${COMMON_LIBRARIES} GTest::gtest_main) diff --git a/tests/dGameTests/CMakeLists.txt b/tests/dGameTests/CMakeLists.txt index b1fdaa07..58f213e0 100644 --- a/tests/dGameTests/CMakeLists.txt +++ b/tests/dGameTests/CMakeLists.txt @@ -12,8 +12,18 @@ file(COPY ${GAMEMESSAGE_TESTBITSTREAMS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) # Add the executable. Remember to add all tests above this! add_executable(dGameTests ${DGAMETEST_SOURCES}) +add_dependencies(dGameTests conncpp_tests) -target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main dGame dZoneManager dPhysics Detour Recast tinyxml2 dWorldServer dChatFilter dNavigation) +# Apple needs some special linkage for the mariadb connector for tests. +if(APPLE) +add_custom_command(TARGET dGameTests POST_BUILD + COMMAND install_name_tool ARGS -change libmariadbcpp.dylib @rpath/libmariadbcpp.dylib dGameTests + COMMAND otool ARGS -L dGameTests + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +endif() + +target_link_libraries(dGameTests ${COMMON_LIBRARIES} GTest::gtest_main + dGame dScripts dPhysics Detour Recast tinyxml2 dWorldServer dZoneManager dChatFilter dNavigation) # Discover the tests gtest_discover_tests(dGameTests) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 40c81544..41135a80 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -19,7 +19,11 @@ add_library(bcrypt ${SOURCES_LIBBCRYPT}) # Because we are not using the libbcrypt CMakeLists.txt, we need to include these headers for the library to use. # fortunately they are only needed for building the libbcrypt directory and nothing else, so these are marked private. -target_include_directories(bcrypt PRIVATE "libbcrypt/include") +if(NOT WIN32) + target_include_directories(bcrypt PRIVATE "libbcrypt/include/bcrypt") +endif() + +target_include_directories(bcrypt INTERFACE "libbcrypt/include") target_include_directories(bcrypt PRIVATE "libbcrypt/src") # Source code for sqlite @@ -28,9 +32,6 @@ add_subdirectory(SQLite) # Source code for magic_enum add_subdirectory(magic_enum) -# MariaDB C++ Connector -include(CMakeMariaDBLists.txt) - # Create our third party library objects add_subdirectory(raknet) diff --git a/thirdparty/mariadb-connector-cpp b/thirdparty/mariadb-connector-cpp index 8641b145..ef087399 160000 --- a/thirdparty/mariadb-connector-cpp +++ b/thirdparty/mariadb-connector-cpp @@ -1 +1 @@ -Subproject commit 8641b1453ae3ce5a70f78248a1f7fc20a048cb88 +Subproject commit ef0873998b3f94a4f76a485fb90b14866fbb99d4 diff --git a/vanity/atm.xml b/vanity/atm.xml index 96ed1a2b..863498ed 100644 --- a/vanity/atm.xml +++ b/vanity/atm.xml @@ -1,23 +1,40 @@ - - - - - - - - - - - - - - - - - - - - - + + + + CheckPrecondition=0:168 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vanity/demo.xml b/vanity/demo.xml new file mode 100644 index 00000000..31c80d8c --- /dev/null +++ b/vanity/demo.xml @@ -0,0 +1,143 @@ + + + + + + customText=13:This story plaque has custom text that is defined by DLU's vanity system. Check out <font color="#000000" >vanity/demo.xml</font> to see how this works! + + + + + + + + + + + + + + + + + + 7630, 1727, 7453, 7521 + + vendorInvOverride=0:1727,7292,16553,2243,14535,14538,14531,6730 + + + + + + + + + + useLocationsAsRandomSpawnPoint=7:1 + + + + + + + + + + + + CheckPrecondition=0: + SmashableDoesNotCutNavmesh=7:0 + add_to_navmesh=7:1 + aggroRadius=3:15 + camGradSnap=7:0 + camPrefersToFadeObject=7:1 + carver_only=7:0 + create_physics=7:1 + currency=5:0 + custom_config_names=0: + explode_factor=3:1 + fxpriority=1:0 + gravFactor=3:1 + grpNameQBShowBricks=0: + ignoreCameraCollision=7:0 + interaction_distance=3:16 + is_smashable=7:1 + loadOnClientOnly=7:0 + loadSrvrOnly=7:0 + max_to_spawn=1:-1 + navmesh_carver=7:0 + no_auto_spawn=7:1 + no_timed_spawn=7:1 + override_faction=7:0 + radius=3:0 + renderAnimLODSkew=3:1 + renderCullingGroup=5:0 + renderOffscreenAnimEnabled=7:0 + respawn=3:20 + sceneIDOverride=1:255 + sceneIDOverrideEnabled=7:0 + sceneLayerIDOverride=5:0 + set_faction=13:4 + smashable_loot_matrix=1:486 + smashable_loot_matrix_set=7:0 + softtetherRadius=3:15 + spawner_active_on_load=7:1 + spawntemplate=1:12379 + startsQBActivator=7:0 + template=1:-1 + tetherRadius=3:15 + usetetherdb=7:0 + usewanderdb=7:0 + wanderRadius=3:15 + + + + + + + + + + + CheckPrecondition=0: + SmashableDoesNotCutNavmesh=7:0 + add_to_navmesh=7:1 + bounding_radius_override=3:0 + camGradSnap=7:0 + camPrefersToFadeObject=7:1 + carver_only=7:0 + create_physics=7:1 + custom_config_names=0: + explode_factor=3:1 + friction=3:1.5 + fxpriority=1:0 + gravFactor=3:1 + grpNameQBShowBricks=0: + ignoreCameraCollision=7:0 + interaction_distance=3:16 + is_smashable=7:1 + loadOnClientOnly=7:0 + max_to_spawn=1:-1 + navmesh_carver=7:0 + no_auto_spawn=7:1 + no_timed_spawn=7:1 + override_faction=7:0 + radius=3:0 + renderCullingGroup=5:0 + respawn=5:20000 + sceneIDOverride=1:255 + sceneIDOverrideEnabled=7:0 + sceneLayerIDOverride=5:0 + set_faction=13:6 + smashable_loot_matrix=1:227 + smashable_loot_matrix_set=7:0 + spawner_active_on_load=7:1 + spawntemplate=1:2295 + startsQBActivator=7:0 + template=1:-1 + + + + + + diff --git a/vanity/dev-tribute.xml b/vanity/dev-tribute.xml index d20e31a6..a3d4e7eb 100644 --- a/vanity/dev-tribute.xml +++ b/vanity/dev-tribute.xml @@ -1,378 +1,439 @@ - - 6802, 2519, 2623, 14806 - - Sorry for the mess. - To future endeavours! - What could imagination bring to light? - Vroom vroom... - Take care to preserve the universe. - Builders of the world, unite! - Everything is awesome! - I hope my behaviors are behaving themselves. - - - - - - - 12947, 12949, 12962, 12963 - - I hope quickbulds are still working! - Be careful crossing the gap! - Have The Maelstrom stopped going invisible? - - - - - - - 9950, 9944, 14102, 14092 - - Hello Explorer! It's great to see you made it! - Have you heard about Darkflame? - I've traveled across this entire system, but nothing beats the view here. - - - - - - - - - cmerw[acowipaejio;fawjioefasdl;kfjm; - I, for one, welcome our new robot overlords. - zxnpoasdfiopwemsadf'kawpfo[ekasdf;'s - *teleports behind you* - -