From 77348980400bcd7d594afb23950c687a137efe1f Mon Sep 17 00:00:00 2001 From: luis Date: Fri, 9 Oct 2026 20:20:40 -0300 Subject: [PATCH] rework --- contrib/Docker/Dockerfile | 9 + contrib/Docker/README.md | 80 + contrib/check_codestyle.sh | 38 + contrib/check_updates.sh | 46 + contrib/cleanup/tab2spaces.sh | 2 + contrib/cleanup/whitespace.sh | 2 + contrib/conf_merge/README | 13 + contrib/conf_merge/confdiffmerge.php | 169 ++ contrib/conf_merge/index.php | 40 + contrib/conf_merge/merge.php | 159 + contrib/conf_merge/tc-conf-merger.pl | 43 + contrib/debugger/README | 13 + contrib/debugger/crashreport.gdb | 38 + contrib/enumutils_describe.py | 167 ++ contrib/extractor.bat | 106 + contrib/extractor.sh | 184 ++ contrib/grafana/1_General.json | 1319 ++++++++ contrib/grafana/2_Maps.json | 691 +++++ contrib/grafana/3_Network.json | 280 ++ contrib/grafana/4_Performance_profiling.json | 1677 +++++++++++ contrib/grafana/all_in_one_dashboard.json | 1484 +++++++++ contrib/merge_updates_unix.sh | 3 + contrib/merge_updates_windows.bat | 2 + contrib/protoc-bnet/BnetCodeGenerator.cpp | 68 + contrib/protoc-bnet/BnetCodeGenerator.h | 24 + contrib/protoc-bnet/BnetFileGenerator.cpp | 696 +++++ contrib/protoc-bnet/BnetFileGenerator.h | 109 + contrib/protoc-bnet/BnetServiceGenerator.cpp | 389 +++ contrib/protoc-bnet/BnetServiceGenerator.h | 88 + contrib/protoc-bnet/CMakeLists.txt | 30 + contrib/protoc-bnet/config.h | 31 + contrib/protoc-bnet/generate_sources.bat | 6 + .../google/protobuf/compiler/cpp/cpp_enum.cc | 288 ++ .../google/protobuf/compiler/cpp/cpp_enum.h | 103 + .../protobuf/compiler/cpp/cpp_enum_field.cc | 434 +++ .../protobuf/compiler/cpp/cpp_enum_field.h | 122 + .../protobuf/compiler/cpp/cpp_extension.cc | 210 ++ .../protobuf/compiler/cpp/cpp_extension.h | 86 + .../google/protobuf/compiler/cpp/cpp_field.cc | 166 ++ .../google/protobuf/compiler/cpp/cpp_field.h | 185 ++ .../protobuf/compiler/cpp/cpp_helpers.cc | 494 +++ .../protobuf/compiler/cpp/cpp_helpers.h | 206 ++ .../protobuf/compiler/cpp/cpp_message.cc | 2643 +++++++++++++++++ .../protobuf/compiler/cpp/cpp_message.h | 175 ++ .../compiler/cpp/cpp_message_field.cc | 375 +++ .../protobuf/compiler/cpp/cpp_message_field.h | 121 + .../protobuf/compiler/cpp/cpp_options.h | 58 + .../compiler/cpp/cpp_primitive_field.cc | 453 +++ .../compiler/cpp/cpp_primitive_field.h | 123 + .../protobuf/compiler/cpp/cpp_string_field.cc | 642 ++++ .../protobuf/compiler/cpp/cpp_string_field.h | 127 + .../protoc-bnet/google/protobuf/stubs/hash.h | 232 ++ .../google/protobuf/stubs/strutil.cc | 1279 ++++++++ .../google/protobuf/stubs/strutil.h | 562 ++++ .../google/protobuf/stubs/substitute.cc | 134 + .../google/protobuf/stubs/substitute.h | 170 ++ contrib/protoc-bnet/main.cpp | 8 + contrib/protoc-bnet/method_options.pb.cc | 186 ++ contrib/protoc-bnet/method_options.pb.h | 156 + contrib/protoc-bnet/service_options.pb.cc | 315 ++ contrib/protoc-bnet/service_options.pb.h | 505 ++++ contrib/valgrind/helgrind.supp | 144 + docs/housing/roleplaycore-port.md | 45 - tests/CMakeLists.txt | 11 +- tests/game/BotMovementConfig.cpp | 202 -- tests/game/BotMovementIntegration.cpp | 435 --- tests/game/MajorFactionPackets.cpp | 87 - 67 files changed, 18709 insertions(+), 779 deletions(-) create mode 100644 contrib/Docker/Dockerfile create mode 100644 contrib/Docker/README.md create mode 100644 contrib/check_codestyle.sh create mode 100644 contrib/check_updates.sh create mode 100644 contrib/cleanup/tab2spaces.sh create mode 100644 contrib/cleanup/whitespace.sh create mode 100644 contrib/conf_merge/README create mode 100644 contrib/conf_merge/confdiffmerge.php create mode 100644 contrib/conf_merge/index.php create mode 100644 contrib/conf_merge/merge.php create mode 100644 contrib/conf_merge/tc-conf-merger.pl create mode 100644 contrib/debugger/README create mode 100644 contrib/debugger/crashreport.gdb create mode 100644 contrib/enumutils_describe.py create mode 100644 contrib/extractor.bat create mode 100644 contrib/extractor.sh create mode 100644 contrib/grafana/1_General.json create mode 100644 contrib/grafana/2_Maps.json create mode 100644 contrib/grafana/3_Network.json create mode 100644 contrib/grafana/4_Performance_profiling.json create mode 100644 contrib/grafana/all_in_one_dashboard.json create mode 100644 contrib/merge_updates_unix.sh create mode 100644 contrib/merge_updates_windows.bat create mode 100644 contrib/protoc-bnet/BnetCodeGenerator.cpp create mode 100644 contrib/protoc-bnet/BnetCodeGenerator.h create mode 100644 contrib/protoc-bnet/BnetFileGenerator.cpp create mode 100644 contrib/protoc-bnet/BnetFileGenerator.h create mode 100644 contrib/protoc-bnet/BnetServiceGenerator.cpp create mode 100644 contrib/protoc-bnet/BnetServiceGenerator.h create mode 100644 contrib/protoc-bnet/CMakeLists.txt create mode 100644 contrib/protoc-bnet/config.h create mode 100644 contrib/protoc-bnet/generate_sources.bat create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum_field.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_enum_field.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_extension.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_extension.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_field.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_field.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_helpers.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_helpers.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_message.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_message.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_message_field.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_message_field.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_options.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_primitive_field.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_primitive_field.h create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_string_field.cc create mode 100644 contrib/protoc-bnet/google/protobuf/compiler/cpp/cpp_string_field.h create mode 100644 contrib/protoc-bnet/google/protobuf/stubs/hash.h create mode 100644 contrib/protoc-bnet/google/protobuf/stubs/strutil.cc create mode 100644 contrib/protoc-bnet/google/protobuf/stubs/strutil.h create mode 100644 contrib/protoc-bnet/google/protobuf/stubs/substitute.cc create mode 100644 contrib/protoc-bnet/google/protobuf/stubs/substitute.h create mode 100644 contrib/protoc-bnet/main.cpp create mode 100644 contrib/protoc-bnet/method_options.pb.cc create mode 100644 contrib/protoc-bnet/method_options.pb.h create mode 100644 contrib/protoc-bnet/service_options.pb.cc create mode 100644 contrib/protoc-bnet/service_options.pb.h create mode 100644 contrib/valgrind/helgrind.supp delete mode 100644 docs/housing/roleplaycore-port.md delete mode 100644 tests/game/BotMovementConfig.cpp delete mode 100644 tests/game/BotMovementIntegration.cpp delete mode 100644 tests/game/MajorFactionPackets.cpp diff --git a/contrib/Docker/Dockerfile b/contrib/Docker/Dockerfile new file mode 100644 index 00000000..b70ef76d --- /dev/null +++ b/contrib/Docker/Dockerfile @@ -0,0 +1,9 @@ +FROM trinitycore/circle-ci:debian-13-runner + +#Setup +WORKDIR /home/circleci +COPY README.md / +COPY --chown=circleci:circleci sql /home/circleci/project/sql +COPY bin /usr/local/bin/ +COPY lib /usr/local/lib/ +ENTRYPOINT [ "echo", "Check the README.md file for instructions"] diff --git a/contrib/Docker/README.md b/contrib/Docker/README.md new file mode 100644 index 00000000..dc5dfe03 --- /dev/null +++ b/contrib/Docker/README.md @@ -0,0 +1,80 @@ +# Docker + +The Circle CI Linux pch job uses the Dockerfile contained in the same folder as this README to create an image with the binaries built for Linux, and stores that in the job artifacts. For the 3.3.5 and master branches, it also pushes the images to https://hub.docker.com/r/trinitycore/trinitycore . + +The instructions below expect a basic knowledge of how to configure TrinityCore and how to use Docker. + +## Load the Docker image +For the 3.3.5 and master branches, it's possible to pull the images from DockerHub. +- For latest 3.3.5, use the following command: + ``` + docker pull trinitycore/trinitycore:3.3.5 + ``` +- For latest master, use the following command: + ``` + docker pull trinitycore/trinitycore:master + ``` +- For a specific 3.3.5 or master commit, use the following command, replacing "commit_hash" with the hash of the commit: + ``` + docker pull trinitycore/trinitycore:commit_hash + ``` + +For Pull Requests or branches other than 3.3.5 or master, follow the steps below to load the image from Circle CI: +1. Click the green tick ✔ next to each commit. +1. Scroll to "ci/circleci: pch" and click "Details". +1. Log in to Circle CI if necessary. You may have to repeat the previous steps after logging in, to reach the correct page. +1. Click the "Artifacts" tab in the Circle CI website. +1. Download the docker.tar.gz archive containing the docker image. +1. Load the image into your Docker host, using the following command: + ``` + docker load -i docker.tar.gz + ``` + +## Start bnetserver/worldserver from Docker +1. Copy the .conf files from the TrinityCore GitHub repository to a local folder which will be passed on as a mapped volume to Docker. +1. Set the MySQL host in the .conf files to use the UNIX socket of MySQL, i.e.: `".;/var/run/mysqld/mysqld.sock;username;password;database"` +1. Set the "DataDir" config in worldserver.conf to `"/trinity/data"` +1. Start bnetserver or worldserver as desired, mapping the required volumes: + +- bnetserver + ``` + docker run --entrypoint=bnetserver -it --volume=/host/path/to/configs:/home/circleci/project/bin/check_install/etc --volume=/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock -p=1119:1119 -p 8081:8081 "image name" + ``` + +- worldserver + ``` + docker run --entrypoint=worldserver -it --volume=/host/path/to/configs:/home/circleci/project/bin/check_install/etc --volume=/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock --volume=/path/to/data/directory:/trinity/data -p=8085:8085 -p 8086:8086 "image name" + ``` + +Change the ports and other parameters as needed. Consult Docker documentation for additional details about possible configuration settings. + +## Content + +The image contains: +- bnetserver +- mapextractor +- mmaps_generator +- vmap4asembler +- vmap4extractor +- worldserver +- README.md + +You can explore the image using +``` +docker run --entrypoint=/bin/bash -it "image name" +``` + +Note that the WORKDIR is set to /home/circleci and all logs will be saved to that folder by default. You can export the logs from the container with +``` +docker cp "container name":/home/circleci/name.log name.log +``` + +For more instructions, please check the official docker documentation. + +## Limitations: + +- Database connection: The instructions provided expect MySQL to run on the host machine. Change `docker run` parameters and .conf settings to fit your scenario. +- To import TDB using the autoupdater: + 1. Download the TDB sql file from GitHub. + 1. Map it with `--volume=/path/to/TDB_full_name.sql:/home/circleci/TDB_full_name.sql` added to the commands specified in the main steps above. + 1. Run the container. diff --git a/contrib/check_codestyle.sh b/contrib/check_codestyle.sh new file mode 100644 index 00000000..d3544e05 --- /dev/null +++ b/contrib/check_codestyle.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +echo "Codestyle check script:" +echo + +declare -A singleLineRegexChecks=( + ["TC_LOG_.+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above" + ["[[:blank:]]$"]="Remove whitespace at the end of the lines above" + ["\t"]="Replace tabs with 4 spaces in the lines above" +) +for check in ${!singleLineRegexChecks[@]}; do + echo " Checking RegEx: '${check}'" + + if grep -P -r -I -n ${check} src; then + echo + echo "${singleLineRegexChecks[$check]}" + exit 1 + fi +done + +declare -A multiLineRegexChecks=( + ["TC_LOG_[^;]+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above" + ["\r?\n\r?\n\r?\n"]="Multiple blank lines detected, keep only one. Check the files above" +) +for check in ${!multiLineRegexChecks[@]}; do + echo " Checking RegEx: '${check}'" + + if grep -Pzo -r -I ${check} src; then + echo + echo + echo "${multiLineRegexChecks[$check]}" + exit 1 + fi +done + +echo +echo "Everything looks good" diff --git a/contrib/check_updates.sh b/contrib/check_updates.sh new file mode 100644 index 00000000..4376b9a6 --- /dev/null +++ b/contrib/check_updates.sh @@ -0,0 +1,46 @@ +#!/bin/sh +name=$1 +branch=$2 +database=$3 +host=$4 + +echo "Database Updater check script:" +echo " Checking database '${name}' for missing filenames in tables..." +echo + +# Select all entries which are in the updates table +entries=$(mysql -uroot ${database} -h ${host} -e "SELECT name FROM updates" | grep ".sql") + +cd sql/updates/${name}/${branch} + +error=0 +updates=0 + +for file in *.sql +do + # Check if the given update is in the `updates` table. + if echo "${entries}" | grep -q "^${file}"; then + # File is ok + updates=$((updates+1)) + else + # The update isn't listed in the updates table of the given database. + echo "- \"sql/updates/${name}/${file}\" is missing in the '${name}'.'updates' table." + error=1 + fi +done + +if [ ${error} -ne 0 ] + then + echo + echo "Fatal error:" + echo " The Database Updater is broken for the '${name}' database," + echo " because the applied update is missing in the '${name}'.'updates' table." + echo + echo "How to fix:" + echo " Insert the missing names of the already applied sql updates" + echo " to the 'updates' table of the '${name}' base dump ('sql/base/${name}_database.sql')." + exit 1 + else + echo " Everything is OK, finished checking ${updates} updates." + exit 0 +fi diff --git a/contrib/cleanup/tab2spaces.sh b/contrib/cleanup/tab2spaces.sh new file mode 100644 index 00000000..27871860 --- /dev/null +++ b/contrib/cleanup/tab2spaces.sh @@ -0,0 +1,2 @@ +#!/bin/bash +perl -wpi -e "s/\t/ /g" $1 diff --git a/contrib/cleanup/whitespace.sh b/contrib/cleanup/whitespace.sh new file mode 100644 index 00000000..e3139d0c --- /dev/null +++ b/contrib/cleanup/whitespace.sh @@ -0,0 +1,2 @@ +#!/bin/bash +perl -wpi -e "s/ +$//g" $1 diff --git a/contrib/conf_merge/README b/contrib/conf_merge/README new file mode 100644 index 00000000..9e6b1e15 --- /dev/null +++ b/contrib/conf_merge/README @@ -0,0 +1,13 @@ +==== PHP merger (index.php + merge.php) ==== + +This is a PHP script for merging a new .dist file with your existing .conf file (worldserver.conf.dist and bnetserver.conf.dist) +It should also work with mangos dist/conf files as well. + +It uses sessions so it is multi user safe, it adds any options that are removed to the bottom of the file, +commented out, just in case it removes something it shouldn't, +and, if you add all of your custom patch configs below "# Custom" they will be copied exactly as they are. + +==== Perl merger (tc-conf-merger.pl) ==== + +Perl based command line merger script. This script feeds a .conf.dist file with variables that exist in an old .conf file, +comments and custom options are ignored. diff --git a/contrib/conf_merge/confdiffmerge.php b/contrib/conf_merge/confdiffmerge.php new file mode 100644 index 00000000..7bcaef50 --- /dev/null +++ b/contrib/conf_merge/confdiffmerge.php @@ -0,0 +1,169 @@ + + + + + <world/auth>server.conf diff + + + + + +
+
+

Paste the new configuration file

+ +
+

Paste the old configuration file

+ + +
+ +
+"); + + define('EOL', "\n\n"); + $settingsData = array(); + + // Process them + $newFile = explode(EOL, $_POST['leftFile']); + $oldFile = explode(EOL, $_POST['rightFile']); + + for ($i = 0, $o = count($oldFile); $i < $o; ++$i) + { + $oldFile[$i] = explode(PHP_EOL, $oldFile[$i]); + for ($j = 0, $p = count($oldFile[$i]); $j < $p; ++$j) + { + $currentLine = $oldFile[$i][$j]; + if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false) + if (strlen($data[1]) != 0) + $settingsData[$data[1]]["oldValue"] = str_replace('"', '', trim($data[2])); + } + } + + for ($i = 0, $o = count($newFile); $i < $o; ++$i) + { + $newFile[$i] = explode(PHP_EOL, $newFile[$i]); + for ($j = 0, $p = count($newFile[$i]); $j < $p; ++$j) + { + $currentLine = $newFile[$i][$j]; + if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false) + if (strlen($data[1]) != 0) + $settingsData[$data[1]]["newValue"] = str_replace('"', '', trim($data[2])); + } + } + + printIndent("

Please select values you want to keep. Note the script will default to new values, unless said new value does not exist.
You also can take advantage of this form and edit fields.

", 1); + printIndent('
', 1); + + foreach ($settingsData as $itemName => &$values) + { + $displayOld = isset($values['oldValue']) ? $values['oldValue'] : "Value missing"; + $displayNew = isset($values['newValue']) ? $values['newValue'] : "Value missing"; + + if ($displayOld == $displayNew) + continue; + + $line = '

'; + $line .= ''; + $line .= ' '; + $line .= ''; + $line .= '

'; + printIndent($line, 2); + } + printIndent('', 2); + printIndent('', 2); + printIndent('', 2); + printIndent('
', 1); +} +else if ($_POST['step'] == 1) +{ + $errors = array(); + + $confFile = $_POST['file']; + + foreach ($_POST['optionSelector'] as $valueName => &$keyName) + { + $definiteValueIndex = -1; + foreach ($_POST['nameCross'] as $index => &$key) + { + if ($key == $valueName) + { + $definiteValueIndex = $index; + break; + } + } + + if ($definiteValueIndex == -1) + { + // TODO: Handle custom values that get lost + continue; + } + + $newStr = $_POST[$keyName][$definiteValueIndex]; + $oldStr = $_POST[$keyName == "oldValue" ? "newValue" : "oldValue"][$definiteValueIndex]; + if (!ctype_digit($newStr)) + $newStr = '"' . $newStr . '"'; + if (!ctype_digit($oldStr)) + $oldStr = '"' . $oldStr . '"'; + + $newValueString = $valueName . " = " . $newStr; + $oldValueString = $valueName . " = " . $oldStr; + $confFile = str_replace($oldValueString, $newValueString, $confFile); + } + echo "

Here is your new configuration file:

"; + echo '
'; + + if (!empty($errors)) + { + echo "

The following errors happened during processing: