diff --git a/CMakeLists.txt b/CMakeLists.txt index ca84e834..541b4266 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ endif() # Our output dir set(CMAKE_BINARY_DIR ${PROJECT_BINARY_DIR}) -#set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) # unfortunately, serializes everything +#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}) @@ -215,12 +215,9 @@ add_subdirectory(thirdparty) # Create our list of include directories set(INCLUDED_DIRECTORIES - "dChatFilter" - "dPhysics" "dNavigation" - "dNavigation/dTerrain" "dNet" @@ -240,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() @@ -250,7 +248,6 @@ foreach(dir ${INCLUDED_DIRECTORIES}) endforeach() # Add linking directories: -# link_directories(${PROJECT_BINARY_DIR}) if (UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") endif() diff --git a/cmake/FindMariaDB.cmake b/cmake/FindMariaDB.cmake index dc51f150..f42ac47b 100644 --- a/cmake/FindMariaDB.cmake +++ 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}) @@ -87,7 +87,6 @@ else() # Build from source endif() set(MARIADBCPP_INSTALL_DIR ${PROJECT_BINARY_DIR}/prefix) - message("MariaDB C/C++ install prefix: " ${MARIADBCPP_INSTALL_DIR}) 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) @@ -124,14 +123,10 @@ else() # Build from source set(MARIADBCPP_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/${MARIADB_SHARED_LIBRARY_NAME}") if(WIN32) set(MARIADBC_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/libmariadb.lib") - #elseif(UNIX) - # set(MARIADBC_SHARED_LIBRARY_LOCATION "${MARIADBCPP_LIBRARY_DIR}/libmariadb.so.3") endif() endif() # Create mariadb connector library object -message("libmariadb: ${MARIADBC_SHARED_LIBRARY_LOCATION}") -message("libmariadbcpp: ${MARIADBCPP_SHARED_LIBRARY_LOCATION}") add_library(MariaDB::ConnCpp SHARED IMPORTED GLOBAL) add_dependencies(MariaDB::ConnCpp mariadb_connector_cpp) set_target_properties(MariaDB::ConnCpp PROPERTIES 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/dGame/CMakeLists.txt b/dGame/CMakeLists.txt index 1a59390f..0ad5e471 100644 --- a/dGame/CMakeLists.txt +++ b/dGame/CMakeLists.txt @@ -64,4 +64,16 @@ target_include_directories(dGame INTERFACE $ $ $ -) \ No newline at end of file +) +target_link_libraries(dGame INTERFACE dNet) +target_include_directories(dGame INTERFACE + $ + $ + $ + $ + $ + $ + $ + $ + $ +) diff --git a/dGame/dComponents/CMakeLists.txt b/dGame/dComponents/CMakeLists.txt index e67d6d26..c60e135f 100644 --- a/dGame/dComponents/CMakeLists.txt +++ b/dGame/dComponents/CMakeLists.txt @@ -75,13 +75,8 @@ target_include_directories(dComponents PUBLIC "." "${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) -# INTERFACE link w/o dependency -#set_property(TARGET dComponents APPEND PROPERTY INTERFACE_LINK_LIBRARIES -# dUtilities dCommon dBehaviors dChatFilter dMission dInventory -# dPhysics -#) - -target_link_libraries(dComponents INTERFACE dBehaviors) \ No newline at end of file +target_link_libraries(dComponents INTERFACE dBehaviors) diff --git a/dNavigation/CMakeLists.txt b/dNavigation/CMakeLists.txt index c2a53ca2..e2a1c6ef 100644 --- a/dNavigation/CMakeLists.txt +++ b/dNavigation/CMakeLists.txt @@ -12,5 +12,6 @@ target_include_directories(dNavigation PUBLIC "." "${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/CMakeLists.txt b/dNet/CMakeLists.txt index 000363be..15cdda42 100644 --- a/dNet/CMakeLists.txt +++ b/dNet/CMakeLists.txt @@ -10,26 +10,22 @@ set(DNET_SOURCES "AuthPackets.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 + "${PROJECT_SOURCE_DIR}/dCommon" + "${PROJECT_SOURCE_DIR}/dCommon/dEnums" - ${PROJECT_SOURCE_DIR}/dZoneManager + "${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}/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 + "${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 ) - -#set_property(TARGET dNet APPEND PROPERTY INTERFACE_LINK_LIBRARIES -# dCommon dDatabase -#) 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/dServer/CMakeLists.txt b/dServer/CMakeLists.txt index f0952eb7..ca4e6198 100644 --- a/dServer/CMakeLists.txt +++ b/dServer/CMakeLists.txt @@ -6,5 +6,5 @@ add_library(dServer STATIC ${DSERVER_SOURCES}) target_include_directories(dServer PUBLIC ".") target_include_directories(dServer PRIVATE - ${PROJECT_SOURCE_DIR}/dCommon/ # BinaryPathFinder.h + "${PROJECT_SOURCE_DIR}/dCommon/" # BinaryPathFinder.h ) diff --git a/dWorldServer/CMakeLists.txt b/dWorldServer/CMakeLists.txt index 1239a3c1..62a3767a 100644 --- a/dWorldServer/CMakeLists.txt +++ b/dWorldServer/CMakeLists.txt @@ -6,10 +6,11 @@ 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_include_directories(WorldServer PRIVATE - ${PROJECT_SOURCE_DIR}/dServer/ # BinaryPathFinder.h + "${PROJECT_SOURCE_DIR}/dServer" # BinaryPathFinder.h ) target_link_libraries(WorldServer ${COMMON_LIBRARIES} diff --git a/dZoneManager/CMakeLists.txt b/dZoneManager/CMakeLists.txt index ba860e0f..544a01d9 100644 --- a/dZoneManager/CMakeLists.txt +++ b/dZoneManager/CMakeLists.txt @@ -11,12 +11,12 @@ target_link_libraries(dZoneManager #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 + "${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 -) \ No newline at end of file + "${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/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/dCommonTests/CMakeLists.txt b/tests/dCommonTests/CMakeLists.txt index 2fe0e309..cf0a03ed 100644 --- a/tests/dCommonTests/CMakeLists.txt +++ b/tests/dCommonTests/CMakeLists.txt @@ -19,6 +19,7 @@ list(APPEND DCOMMONTEST_SOURCES ${DENUMS_TESTS}) 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 diff --git a/tests/dGameTests/CMakeLists.txt b/tests/dGameTests/CMakeLists.txt index 5bf4c81f..58f213e0 100644 --- a/tests/dGameTests/CMakeLists.txt +++ b/tests/dGameTests/CMakeLists.txt @@ -14,6 +14,7 @@ file(COPY ${GAMEMESSAGE_TESTBITSTREAMS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) add_executable(dGameTests ${DGAMETEST_SOURCES}) add_dependencies(dGameTests conncpp_tests) +# 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 diff --git a/vanity/demo.xml b/vanity/demo.xml index 9e891dbe..31c80d8c 100644 --- a/vanity/demo.xml +++ b/vanity/demo.xml @@ -1,4 +1,15 @@ + + + + + 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! + + + + + +