diff --git a/.github/workflows/core_build.yml b/.github/workflows/core_build.yml index d54fd10319..90ede0c88c 100644 --- a/.github/workflows/core_build.yml +++ b/.github/workflows/core_build.yml @@ -26,7 +26,7 @@ jobs: modules: without extra_logs: false - os: ubuntu-20.04 - compiler: clang8 + compiler: clang9 modules: without extra_logs: false - os: ubuntu-18.04 diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index 652687bcc4..74542b3d27 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -3,8 +3,7 @@ on: push: branches: - 'master' - pull_request_review: - types: [submitted] + pull_request: jobs: docker-build-n-deploy: diff --git a/.github/workflows/macos_build.yml b/.github/workflows/macos_build.yml index 0c79f51694..032a865a34 100644 --- a/.github/workflows/macos_build.yml +++ b/.github/workflows/macos_build.yml @@ -3,8 +3,7 @@ on: push: branches: - 'master' - pull_request_review: - types: [submitted] + pull_request: jobs: macos-build: diff --git a/.github/workflows/windows_build.yml b/.github/workflows/windows_build.yml index 018c942f64..f7e98035dc 100644 --- a/.github/workflows/windows_build.yml +++ b/.github/workflows/windows_build.yml @@ -3,8 +3,7 @@ on: push: branches: - 'master' - pull_request_review: - types: [submitted] + pull_request: jobs: windows-build: diff --git a/apps/ci/ci-conf.sh b/apps/ci/ci-conf.sh index b853f50a8f..0d06410dc3 100644 --- a/apps/ci/ci-conf.sh +++ b/apps/ci/ci-conf.sh @@ -53,12 +53,6 @@ case $COMPILER in echo "CCOMPILERCXX=\"clang++-6.0\"" >> ./conf/config.sh ;; - "clang8" ) - time sudo apt-get install -y clang-8 - echo "CCOMPILERC=\"clang-8\"" >> ./conf/config.sh - echo "CCOMPILERCXX=\"clang++-8\"" >> ./conf/config.sh - ;; - "clang9" ) time sudo apt-get install -y clang-9 echo "CCOMPILERC=\"clang-9\"" >> ./conf/config.sh diff --git a/apps/ci/ci-install.sh b/apps/ci/ci-install.sh index 14d3395e87..cc0681533c 100644 --- a/apps/ci/ci-install.sh +++ b/apps/ci/ci-install.sh @@ -58,12 +58,6 @@ case $COMPILER in echo "CCOMPILERCXX=\"clang++-6.0\"" >> ./conf/config.sh ;; - "clang8" ) - time sudo apt-get install -y clang-8 - echo "CCOMPILERC=\"clang-8\"" >> ./conf/config.sh - echo "CCOMPILERCXX=\"clang++-8\"" >> ./conf/config.sh - ;; - "clang9" ) time sudo apt-get install -y clang-9 echo "CCOMPILERC=\"clang-9\"" >> ./conf/config.sh diff --git a/apps/compiler/includes/functions.sh b/apps/compiler/includes/functions.sh index dcbcc8db26..7c5ea483a1 100644 --- a/apps/compiler/includes/functions.sh +++ b/apps/compiler/includes/functions.sh @@ -102,10 +102,6 @@ function comp_compile() { fi runHooks "ON_AFTER_BUILD" - - # set worldserver SUID bit - sudo chown root:root "$AC_BINPATH_FULL/worldserver" - sudo chmod u+s "$AC_BINPATH_FULL/worldserver" } function comp_build() { diff --git a/apps/config-merger/README.md b/apps/config-merger/README.md deleted file mode 100644 index 4a5301e8fb..0000000000 --- a/apps/config-merger/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# ==== 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 authserver.conf.dist) - -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. -If you add your custom patch configs below "# Custom" they will be copied exactly as they are. - -Your new config will be found under $basedir/session_id/newconfig.conf.merge - -If you do not run a PHP server on your machiene you can read this guide on ["How to execute PHP code using command line?"](https://www.geeksforgeeks.org/how-to-execute-php-code-using-command-line/) on geeksforgeeks.org. - -``` -php -S localhost:port -t E:\Azerothcore-wotlk\apps\config-merger\ -``` - -Change port to an available port to use. i.e 8000 - -Then go to your browser and type: - -``` -localhost:8000/index.php -``` diff --git a/apps/config-merger/index.php b/apps/config-merger/index.php deleted file mode 100644 index 8754d29954..0000000000 --- a/apps/config-merger/index.php +++ /dev/null @@ -1,44 +0,0 @@ - - -
-Dist File (.conf.dist) -
- -
-
-Current Conf File (.conf) -
- -
-
-Windows - -UNIX/Linux -
-
- -
-
-If you have any custom settings, such as from patches, -
-make sure they are at the bottom of the file following -
-this block (add it if it's not there) -
-############################################################################### -
-# Custom -
-############################################################################### -
-
- -
diff --git a/apps/config-merger/merge.php b/apps/config-merger/merge.php deleted file mode 100644 index 17417e1a2b..0000000000 --- a/apps/config-merger/merge.php +++ /dev/null @@ -1,179 +0,0 @@ - $v) - { - if (array_key_exists($k, $array1)) - { - $array1[$k] = $v; - unset($array2[$k]); - } - } - $in_file1 = fopen($upload1,"r"); - $line = trim(fgets($in_file1)); - while (!feof($in_file1)) - { - if (substr($line,0,1) != '#' && substr($line,0,1) != '') - { - $array = array(); - while (substr($line,0,1) != '#' && substr($line,0,1) != '') - { - list($key, $val) = explode("=",$line); - $key = trim($key); - $val = trim($val); - $array[$key] = $val; - $line = trim(fgets($in_file1)); - } - foreach($array as $k => $v) - { - if (array_key_exists($k, $array1)) - fwrite($out_file, $k."=".$array1[$k].$eol); - else - continue; - } - unset($array); - if (!feof($in_file1)) - fwrite($out_file, $line.$eol); - } - else - fwrite($out_file, $line.$eol); - $line = trim(fgets($in_file1)); - } - if ($custom_found) - { - fwrite($out_file, $eol); - fwrite($out_file, "###############################################################################".$eol); - fwrite($out_file, "# Custom".$eol); - $line = trim(fgets($in_file2)); - while (!feof($in_file2)) - { - fwrite($out_file, $line.$eol); - $line = trim(fgets($in_file2)); - } - } - $first = true; - foreach($array2 as $k => $v) - { - if ($first) - { - fwrite($out_file, $eol); - fwrite($out_file, "###############################################################################".$eol); - fwrite($out_file, "# The Following values were removed from the config.".$eol); - $first = false; - } - fwrite($out_file, "# ".$k."=".$v.$eol); - } - - if (strpos($upload1, "worldserver") !== false) - { - file_put_contents($newconfig, str_replace("]=","]",file_get_contents($newconfig))); - } - else if (strpos($upload1, "authserver") !== false) - { - file_put_contents($newconfig, str_replace("]=","]",file_get_contents($newconfig))); - } - - unset($array1); - unset($array2); - fclose($in_file1); - fclose($in_file2); - fclose($out_file); - unlink($upload1); - unlink($upload2); - - echo "Process done"; - echo "
Click here to retrieve your merged conf"; - } -} -else -{ - echo "An error has occurred"; -} -?> diff --git a/apps/docker/Dockerfile b/apps/docker/Dockerfile index 94af95c391..ad8b6873b4 100644 --- a/apps/docker/Dockerfile +++ b/apps/docker/Dockerfile @@ -28,7 +28,7 @@ ENV DEBIAN_FRONTEND=noninteractive # since it's not cacheable by docker RUN apt-get update && apt-get install -y gdb gdbserver git dos2unix lsb-core sudo curl unzip \ make cmake clang libmysqlclient-dev libace-dev \ - build-essential libtool cmake-data openssl libgoogle-perftools-dev google-perftools \ + build-essential libtool cmake-data openssl libgoogle-perftools-dev \ libssl-dev libmysql++-dev libreadline6-dev zlib1g-dev libbz2-dev mysql-client \ libncurses5-dev ccache \ && rm -rf /var/lib/apt/lists/* @@ -106,8 +106,7 @@ RUN addgroup --gid $GROUP_ID acore && \ echo 'acore ALL=(ALL:ALL) NOPASSWD: ALL' >> /etc/sudoers # install the required dependencies to run the server -RUN apt-get update && apt-get install -y dos2unix gdb gdbserver google-perftools libgoogle-perftools-dev net-tools \ - tzdata libmysqlclient-dev libace-dev mysql-client curl unzip && rm -rf /var/lib/apt/lists/* ; +RUN apt-get update && apt-get install -y dos2unix gdb gdbserver net-tools tzdata libmysqlclient-dev libace-dev mysql-client curl unzip && rm -rf /var/lib/apt/lists/* ; # change timezone in container RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata diff --git a/apps/docker/docker-cmd.ts b/apps/docker/docker-cmd.ts index 45a05e5a91..512f1eb00c 100644 --- a/apps/docker/docker-cmd.ts +++ b/apps/docker/docker-cmd.ts @@ -108,10 +108,7 @@ shellCommandFactory( shellCommandFactory( "dev:shell [args...]", "Open an interactive shell within the dev server", - [ - "docker-compose up -d ac-dev-server", - "docker-compose exec ac-dev-server bash", - ], + ["docker-compose run --rm ac-dev-server bash"], env, ); diff --git a/apps/installer/includes/os_configs/ubuntu.sh b/apps/installer/includes/os_configs/ubuntu.sh index c57a453d2c..45955eec60 100644 --- a/apps/installer/includes/os_configs/ubuntu.sh +++ b/apps/installer/includes/os_configs/ubuntu.sh @@ -8,7 +8,7 @@ UBUNTU_VERSION=$(lsb_release -sr); sudo apt-get update -y # shared deps -sudo apt-get -y install make cmake clang curl unzip libmysqlclient-dev libace-dev ccache google-perftools +sudo apt-get -y install make cmake clang curl unzip libmysqlclient-dev libace-dev ccache if [[ $CONTINUOUS_INTEGRATION || $DOCKER ]]; then sudo apt-get -y install build-essential libtool cmake-data openssl libgoogle-perftools-dev \ diff --git a/bin/acore-restarter b/bin/acore-restarter new file mode 100755 index 0000000000..fa072f9926 --- /dev/null +++ b/bin/acore-restarter @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +CUR_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$CUR_PATH/../apps/startup-scripts/simple-restarter" diff --git a/conf/dist/config.sh b/conf/dist/config.sh index 93f04861fc..38730109f0 100644 --- a/conf/dist/config.sh +++ b/conf/dist/config.sh @@ -88,47 +88,6 @@ CCUSTOMOPTIONS=${CCUSTOMOPTIONS:-''} AC_CCACHE=${AC_CCACHE:-false} export CCACHE_DIR=${CCACHE_DIR:-"$AC_PATH_VAR/ccache"} -############################################## -# -# GOOGLE PERF TOOLS -# -# Repository: https://github.com/gperftools/gperftools#readme -# Documentation: https://gperftools.github.io/gperftools/ -# -# Install (Ubuntu): -# sudo apt-get install google-perftools libgoogle-perftools-dev -# Note: dependencies above are already installed in docker -# -# Usage: -# 1. To enable the gperftools you need to compile with the -DWITH_PERFTOOLS=ON compiler flag. You can use CCUSTOMOPTIONS above to set it for the dashboard compiler -# 2. Configure the variable below accordingly to your needs -# 3. run the worldserver with the "./acore.sh run-worldserver" -# 4. run "killall -12 worldserver" This command will start the monitoring process. Run "killall -12 worldserver" again to stop the process when you want -# 5. At this time you will have the .prof file ready in the folder configured below. -# Run "google-pprof --callgrind " This will generate a callgrind file that can be read with -# QCacheGrind, KCacheGrind and any other compatible tools -# -############################################## - -# files used by gperftools to store monitored information -export CPUPROFILE=${CPUPROFILE:-"$BINPATH/logs/worldserver-cpu.prof"} -# heap profile is disabled by default. Uncomment this line to enable it -# export HEAPPROFILE=${HEAPPROFILE:-"$BINPATH/logs/worldserver-heap.prof"} - -# signal to send to the kill command to start/stop the profiling process. kill -12 -export CPUPROFILESIGNAL=${CPUPROFILESIGNAL:-12} - -# How many interrupts/second the cpu-profiler samples. -#export CPUPROFILE_FREQUENCY=${CPUPROFILESIGNAL:-100} - -# If set to any value (including 0 or the empty string), use ITIMER_REAL instead of ITIMER_PROF to gather profiles. -# In general, ITIMER_REAL is not as accurate as ITIMER_PROF, and also interacts badly with use of alarm(), -# so prefer ITIMER_PROF unless you have a reason prefer ITIMER_REAL. -#export CPUPROFILE_REALTIME=${CPUPROFILE_REALTIME} - -# Other values for HEAPCHECK: minimal, normal (equivalent to "1"), strict, draconian -#export HEAPCHECK=${HEAPCHECK:-normal} - ############################################## # diff --git a/data/sql/updates/db_auth/2021_05_13_00.sql b/data/sql/updates/db_auth/2021_05_13_00.sql deleted file mode 100644 index 6cd2978b8e..0000000000 --- a/data/sql/updates/db_auth/2021_05_13_00.sql +++ /dev/null @@ -1,322 +0,0 @@ --- DB update 2021_03_23_00 -> 2021_05_13_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_auth' AND COLUMN_NAME = '2021_03_23_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_auth CHANGE COLUMN 2021_03_23_00 2021_05_13_00 bit; -SELECT sql_rev INTO OK FROM version_db_auth WHERE sql_rev = '1620079951672711500'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - --- - -START TRANSACTION; -- we're messing with the accounts table here, let's play it safe - -INSERT INTO `version_db_auth` (`sql_rev`) VALUES ('1620079951672711500'); - -DROP TABLE IF EXISTS `secret_digest`; -CREATE TABLE `secret_digest` ( - `id` INT UNSIGNED NOT NULL, - `digest` VARCHAR(100) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB; - --- ============================================== -- --- BASE32 CONVERSION STARTS HERE -- --- (there is another banner like this at the end, -- --- so you know how far down you need to skip) -- --- ============================================== -- - -CREATE TEMPORARY TABLE `_temp_base32_lookup1` -( - `c` char(1) not null, - `v` tinyint unsigned not null, - primary key (`c`) -); -INSERT INTO `_temp_base32_lookup1` (`c`,`v`) VALUES -('A',00),('B',01),('C',02),('D',03),('E',04),('F',05),('G',06),('H',07), -('I',08),('J',09),('K',10),('L',11),('M',12),('N',13),('O',14),('P',15), -('Q',16),('R',17),('S',18),('T',19),('U',20),('V',21),('W',22),('X',23), -('Y',24),('Z',25),('2',26),('3',27),('4',28),('5',29),('6',30),('7',31); - -CREATE TEMPORARY TABLE `_temp_base32_lookup2` LIKE `_temp_base32_lookup1`; -INSERT INTO `_temp_base32_lookup2` SELECT * FROM `_temp_base32_lookup1`; - -CREATE TEMPORARY TABLE `_temp_base32_lookup3` LIKE `_temp_base32_lookup1`; -INSERT INTO `_temp_base32_lookup3` SELECT * FROM `_temp_base32_lookup1`; - -CREATE TEMPORARY TABLE `_temp_base32_lookup4` LIKE `_temp_base32_lookup1`; -INSERT INTO `_temp_base32_lookup4` SELECT * FROM `_temp_base32_lookup1`; - -CREATE TEMPORARY TABLE `_temp_base32_lookup5` LIKE `_temp_base32_lookup1`; -INSERT INTO `_temp_base32_lookup5` SELECT * FROM `_temp_base32_lookup1`; - -CREATE TEMPORARY TABLE `_temp_base32_lookup6` LIKE `_temp_base32_lookup1`; -INSERT INTO `_temp_base32_lookup6` SELECT * FROM `_temp_base32_lookup1`; - -CREATE TEMPORARY TABLE `_temp_base32_lookup7` LIKE `_temp_base32_lookup1`; -INSERT INTO `_temp_base32_lookup7` SELECT * FROM `_temp_base32_lookup1`; - -CREATE TEMPORARY TABLE `_temp_base32_lookup8` LIKE `_temp_base32_lookup1`; -INSERT INTO `_temp_base32_lookup8` SELECT * FROM `_temp_base32_lookup1`; - -CREATE TEMPORARY TABLE `_temp_totp_conversion` -( - `original_key` varchar(100) not null default '', - `remaining_key` varchar(100) not null default '', - `totp_secret` varbinary(128) default null, - primary key(`original_key`), - index (`remaining_key`) -); - -INSERT INTO `_temp_totp_conversion` (`original_key`) SELECT DISTINCT `token_key` FROM `account`; -UPDATE `_temp_totp_conversion` SET `remaining_key`=TRIM(TRAILING '=' FROM `original_key`),`totp_secret`='' WHERE `original_key`!=''; - --- 8 base32 chars = 5 bytes --- ...so after 12 iterations we're done --- mysql doesn't let us do loops, so we have to do this manually (....mysql) -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 2 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 3 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 4 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 5 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 6 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 7 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 8 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 9 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 10 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 11 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- iteration 12 -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -LEFT JOIN `_temp_base32_lookup8` look8 ON look8.`c`=SUBSTR(`remaining_key`,8,1) -SET `remaining_key`=SUBSTR(`remaining_key`,9),`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 35) | (look2.`v` << 30) | (look3.`v` << 25) | (look4.`v` << 20) | (look5.`v` << 15) | (look6.`v` << 10) | (look7.`v` << 5) | (look8.`v`)),10,16),10,'0'))) -WHERE LENGTH(`remaining_key`) >= 8; - --- ok, now the only things left are trailing partial bytes --- if the trailing block had 1 byte , we have xxxxx xxx00 (strlen = 2) --- if the trailing block had 2 bytes, we have xxxxx xxxyy yyyyy y0000 (strlen = 4) --- if the trailing block had 3 bytes, we have xxxxx xxxyy yyyyy yzzzz zzzz0 (strlen = 5) --- if the trailing block had 4 bytes, we have xxxxx xxxyy yyyyy yzzzz zzzzw wwwww ww000 (strlen = 7) - --- 1 byte case -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -SET `remaining_key`='',`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 3) | (look2.`v` >> 2)),10,16),2,'0'))) -WHERE LENGTH(`remaining_key`)=2; --- 2 byte case -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -SET `remaining_key`='',`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 11) | (look2.`v` << 6) | (look3.`v` << 1) | (look4.`v` >> 4)),10,16),4,'0'))) -WHERE LENGTH(`remaining_key`)=4; --- 3 byte case -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -SET `remaining_key`='',`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 19) | (look2.`v` << 14) | (look3.`v` << 9) | (look4.`v` << 4) | (look5.`v` >> 1)),10,16),6,'0'))) -WHERE LENGTH(`remaining_key`)=5; --- 4 byte case -UPDATE `_temp_totp_conversion` -LEFT JOIN `_temp_base32_lookup1` look1 ON look1.`c`=SUBSTR(`remaining_key`,1,1) -LEFT JOIN `_temp_base32_lookup2` look2 ON look2.`c`=SUBSTR(`remaining_key`,2,1) -LEFT JOIN `_temp_base32_lookup3` look3 ON look3.`c`=SUBSTR(`remaining_key`,3,1) -LEFT JOIN `_temp_base32_lookup4` look4 ON look4.`c`=SUBSTR(`remaining_key`,4,1) -LEFT JOIN `_temp_base32_lookup5` look5 ON look5.`c`=SUBSTR(`remaining_key`,5,1) -LEFT JOIN `_temp_base32_lookup6` look6 ON look6.`c`=SUBSTR(`remaining_key`,6,1) -LEFT JOIN `_temp_base32_lookup7` look7 ON look7.`c`=SUBSTR(`remaining_key`,7,1) -SET `remaining_key`='',`totp_secret`=CONCAT(`totp_secret`, - UNHEX(LPAD(CONV(((look1.`v` << 27) | (look2.`v` << 22) | (look3.`v` << 17) | (look4.`v` << 12) | (look5.`v` << 7) | (look6.`v` << 2) | (look7.`v` >> 3)),10,16),8,'0'))) -WHERE LENGTH(`remaining_key`)=7; - --- assert that we actually converted everything properly -SET @mode := @@session.sql_mode; -SET SESSION sql_mode='STRICT_TRANS_TABLES'; -CREATE TEMPORARY TABLE `_temp_assert_check` (`v` char(1)); -INSERT INTO `_temp_assert_check` SELECT CONV(MAX(LENGTH(`remaining_key`)+1),10,2) FROM `_temp_totp_conversion`; -SET SESSION sql_mode=@mode; - --- =================================================== -- --- BASE32 CONVERSION ENDS HERE -- --- (this is the other banner i promised you, so you -- --- can stop skipping the unnecessarily complex stuff) -- --- =================================================== -- - -ALTER TABLE `account` ADD COLUMN `totp_secret` VARBINARY(128) DEFAULT NULL AFTER `session_key`; -UPDATE `account` a LEFT JOIN `_temp_totp_conversion` c ON a.`token_key`=c.`original_key` SET a.`totp_secret`=c.`totp_secret`; -ALTER TABLE `account` DROP COLUMN `token_key`; - -COMMIT; -- safety gloves off - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_08_00.sql b/data/sql/updates/db_world/2021_05_08_00.sql deleted file mode 100644 index 25b96daf65..0000000000 --- a/data/sql/updates/db_world/2021_05_08_00.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DB update 2021_05_07_03 -> 2021_05_08_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_07_03'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_07_03 2021_05_08_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1619824902615694400'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1619824902615694400'); - -UPDATE `conditions` SET `comment` = 'Manual: Heavy Frostweave Bandage - Require Skill 129 Level 390 to drop' WHERE `ConditionTypeOrReference` = 7 AND `SourceGroup` IN (26550, 26553, 26554, 26555, 26668, 26669, 26687, 26693, 26861, 27633, 27635, 27871, 27960, 27969, 28022, 28023, 28026, 28035, 28036, 28080, 28081, 28101, 28108, 28123, 28124, 28158, 28188, 28255, 28257, 28268, 28373, 28388, 28402, 28403, 28412, 28414, 28417, 28418, 28465, 28494, 28495, 28504, 28538, 28565, 28575, 28578, 28579, 28586, 28587, 28600, 28602, 28641, 28802, 28861, 28916, 28923, 28988, 29123, 29129, 29133, 29211, 29235, 29236, 29237, 29266, 29304, 29305, 29306, 29312, 29313, 29314, 29315, 29316, 29323, 29329, 29331, 29338, 29370, 29404, 29407, 29409, 29413, 29449, 29450, 29451, 29554, 29586, 29622, 29623, 29646, 29652, 29654, 29656, 29697, 29699, 29717, 29719, 29720, 29792, 29793, 29819, 29820, 29822, 29826, 29832, 29834, 29843, 29880, 29932, 30037, 30202, 30204, 30205, 30250, 30333, 30453, 30510, 30529, 30530, 30532, 30540, 30660, 30666, 30667, 30668, 30680, 30681, 30682, 30687, 30689, 30695, 30701, 30748, 30774, 30788, 30807, 30810, 30856, 30860, 30863, 30865, 30892, 30893, 30894, 30920, 30921, 30951, 30998, 31134, 31140, 31150, 31152, 31231, 31258, 31349, 31350, 31360, 31362, 31368, 31370, 31402, 31403, 31456, 31463, 31464, 31465, 31469, 31506, 31507, 31508, 31509, 31510, 31511, 31512, 31533, 31536, 31537, 31538, 31610, 31611, 31612, 31674, 31718, 31738, 31746, 31754, 31779, 31847, 32191, 32255, 32259, 32276, 32278, 32289, 32353, 32507) AND `SourceEntry` = 39152; -UPDATE `conditions` SET `comment` = 'A Guide to Northern Cloth Scavenging - Require Skill 197 Level 325 to drop' WHERE `ConditionTypeOrReference` = 7 AND `SourceGroup` IN (25026, 25316, 26268, 26280, 26529, 26530, 26532, 26630, 26631, 26632, 26668, 26687, 26693, 26723, 26731, 26763, 26861, 27206, 27284, 27357, 27483, 28586, 28587, 28684, 28921, 28923, 29120, 29266, 29304, 29305, 29306, 29308, 29309, 29310, 29311, 29312, 29313, 29314, 29315, 29316, 29932, 30510, 30529, 30530, 30532, 30540, 30748, 30774, 30788, 30807, 30810, 31134, 31211, 31212, 31215, 31349, 31350, 31360, 31362, 31368, 31370, 31456, 31463, 31464, 31465, 31469, 31506, 31507, 31508, 31509, 31510, 31511, 31512, 31533, 31536, 31537, 31538, 31610, 31611, 31612, 31674, 32313) AND `SourceEntry` = 43876; - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_09_00.sql b/data/sql/updates/db_world/2021_05_09_00.sql deleted file mode 100644 index addb2cd46c..0000000000 --- a/data/sql/updates/db_world/2021_05_09_00.sql +++ /dev/null @@ -1,99 +0,0 @@ --- DB update 2021_05_08_00 -> 2021_05_09_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_08_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_08_00 2021_05_09_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620115611701757811'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620115611701757811'); - -SET -@ROUGHSTONE = 2835, -@COPPERORE = 2770, -@COARSESTONE = 2836, -@TINORE = 2771, -@HEAVYSTONE = 2838, -@IRONORE = 2772, -@SOLIDSTONE = 7912, -@MITHRILORE = 3858, -@DENSESTONE = 12365, -@SOULDARITE = 19774, -@THORIUMORE = 10620; - --- Copper Vein -UPDATE `gameobject_loot_template` SET `MaxCount`= 6 WHERE FIND_IN_SET (`Entry`,'1502,1735,2626,18092') AND `Item` = @ROUGHSTONE; -- Rough Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'1502,1735,2626,18092') AND `Item` = @ROUGHSTONE; -- Rough Stone -UPDATE `gameobject_loot_template` SET `Chance`= 50 WHERE FIND_IN_SET (`Entry`,'1502,1735,2626,18092') AND `Item` = @ROUGHSTONE; -- Rough Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'1502,1735,2626,18092') AND `Item` = @COPPERORE; -- Copper Ore -UPDATE `gameobject_loot_template` SET `MaxCount`= 4 WHERE FIND_IN_SET (`Entry`,'1502,1735,2626,18092') AND `Item` = @COPPERORE; -- Copper Ore - --- Tin Vein -UPDATE `gameobject_loot_template` SET `MaxCount`= 6 WHERE FIND_IN_SET (`Entry`,'1503,1736,2627,18093') AND `Item` = @COARSESTONE; -- Coarse Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'1503,1736,2627,18093') AND `Item` = @COARSESTONE; -- Coarse Stone -UPDATE `gameobject_loot_template` SET `Chance`= 50 WHERE FIND_IN_SET (`Entry`,'1503,1736,2627,18093') AND `Item` = @COARSESTONE; -- Coarse Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'1503,1736,2627,18093') AND `Item` = @TINORE; -- Tin Ore -UPDATE `gameobject_loot_template` SET `MaxCount`= 4 WHERE FIND_IN_SET (`Entry`,'1503,1736,2627,18093') AND `Item` = @TINORE; -- Tin Ore - --- Iron Deposit -UPDATE `gameobject_loot_template` SET `Chance`= 50 WHERE `Entry` = 1505 AND `Item` = @HEAVYSTONE; -- Heavy Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE `Entry` = 1505 AND `Item` = @HEAVYSTONE; -- Heavy Stone -UPDATE `gameobject_loot_template` SET `MaxCount`= 5 WHERE `Entry` = 1505 AND `Item` = @HEAVYSTONE; -- Heavy Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE `Entry` = 1505 AND `Item` = @IRONORE; -- Iron Ore -UPDATE `gameobject_loot_template` SET `MaxCount`= 4 WHERE `Entry` = 1505 AND `Item` = @IRONORE; -- Iron Ore -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE `Entry` = 1505 AND `Item` = @HEAVYSTONE; -- Heavy Stone - --- Mithril Deposit -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'1742,13961') AND `Item` = @MITHRILORE; -- Mithril Ore -UPDATE `gameobject_loot_template` SET `MaxCount`= 4 WHERE FIND_IN_SET (`Entry`,'1742,13961') AND `Item` = @MITHRILORE; -- Mithril Ore -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'1742,13961') AND `Item` = @SOLIDSTONE; -- Solid Stone -UPDATE `gameobject_loot_template` SET `MaxCount`= 8 WHERE FIND_IN_SET (`Entry`,'1742,13961') AND `Item` = @SOLIDSTONE; -- Solid Stone -UPDATE `gameobject_loot_template` SET `Chance`= 50 WHERE FIND_IN_SET (`Entry`,'1742,13961') AND `Item` = @SOLIDSTONE; -- Solid Stone - --- Hakkari Thorium Vein -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE `Entry` = 17241 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE `Entry` = 17241 AND `Item` = 1; -- Reference Tables -UPDATE `gameobject_loot_template` SET `Chance`= 50 WHERE `Entry` = 17241 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE `Entry` = 17241 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MaxCount`= 7 WHERE `Entry` = 17241 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE `Entry` = 17241 AND `Item` = @SOULDARITE; -- Souldarite -UPDATE `gameobject_loot_template` SET `MaxCount`= 2 WHERE `Entry` = 17241 AND `Item` = @SOULDARITE; -- Souldarite -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE `Entry` = 17241 AND `Item` = @THORIUMORE; -- Thorium Ore -UPDATE `gameobject_loot_template` SET `MaxCount`= 5 WHERE `Entry` = 17241 AND `Item` = @THORIUMORE; -- Thorium Ore - --- Small Thorium Veins -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE FIND_IN_SET (`Entry`,'9597,13960') AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE Entry = 13960 AND `Item` = 11513; -- Tainted Vitriol -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE FIND_IN_SET (`Entry`,'9597,13960') AND `Item` = 1; -- Reference Tables -UPDATE `gameobject_loot_template` SET `Chance`= 50 WHERE FIND_IN_SET (`Entry`,'9597,13960') AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'9597,13960') AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MaxCount`= 5 WHERE FIND_IN_SET (`Entry`,'9597,13960') AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE FIND_IN_SET (`Entry`,'9597,13960') AND `Item` = @THORIUMORE; -- Thorium Ore -UPDATE `gameobject_loot_template` SET `MaxCount`= 3 WHERE FIND_IN_SET (`Entry`,'9597,13960') AND `Item` = @THORIUMORE; -- Thorium Ore - --- Rich Thorium Vein -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE `Entry` = 12883 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `GroupId`= 1 WHERE `Entry` = 12883 AND `Item` = 1; -- Reference Tables -UPDATE `gameobject_loot_template` SET `Chance`= 50 WHERE `Entry` = 12883 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE `Entry` = 12883 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MaxCount`= 7 WHERE `Entry` = 12883 AND `Item` = @DENSESTONE; -- Dense Stone -UPDATE `gameobject_loot_template` SET `MinCount`= 1 WHERE `Entry` = 12883 AND `Item` = @THORIUMORE; -- Thorium Ore -UPDATE `gameobject_loot_template` SET `MaxCount`= 5 WHERE `Entry` = 12883 AND `Item` = @THORIUMORE; -- Thorium Ore - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_09_01.sql b/data/sql/updates/db_world/2021_05_09_01.sql deleted file mode 100644 index ed1daf6a0d..0000000000 --- a/data/sql/updates/db_world/2021_05_09_01.sql +++ /dev/null @@ -1,28 +0,0 @@ --- DB update 2021_05_09_00 -> 2021_05_09_01 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_09_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_09_00 2021_05_09_01 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620304598558845500'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620304598558845500'); - -UPDATE `creature_template` SET `faction` = 35 WHERE (`entry` = 11627); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_09_02.sql b/data/sql/updates/db_world/2021_05_09_02.sql deleted file mode 100644 index 0347b39f82..0000000000 --- a/data/sql/updates/db_world/2021_05_09_02.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DB update 2021_05_09_01 -> 2021_05_09_02 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_09_01'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_09_01 2021_05_09_02 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620325277913162400'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620325277913162400'); - -UPDATE `gameobject` SET `position_x`=1366.00, `position_y`=-318.00, `position_z`=3.727 WHERE `guid`=3440; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_09_03.sql b/data/sql/updates/db_world/2021_05_09_03.sql deleted file mode 100644 index 659575b38e..0000000000 --- a/data/sql/updates/db_world/2021_05_09_03.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DB update 2021_05_09_02 -> 2021_05_09_03 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_09_02'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_09_02 2021_05_09_03 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620326903465396700'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620326903465396700'); - -UPDATE `creature_model_info` SET `CombatReach`=8 WHERE `DisplayID`=24165; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_09_04.sql b/data/sql/updates/db_world/2021_05_09_04.sql deleted file mode 100644 index 511e983735..0000000000 --- a/data/sql/updates/db_world/2021_05_09_04.sql +++ /dev/null @@ -1,100 +0,0 @@ --- DB update 2021_05_09_03 -> 2021_05_09_04 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_09_03'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_09_03 2021_05_09_04 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620365613702531200'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620365613702531200'); - --- Galen Goodward SAI (Source: https://www.youtube.com/watch?v=57_CgmmO-hI & https://www.youtube.com/watch?v=Uxvm_uQvQhQ) -SET @ID := 5391; -UPDATE `creature_template` SET `AIName` = "SmartAI", `ScriptName` = "" WHERE `entry` = @ID; -DELETE FROM `smart_scripts` WHERE `entryorguid` = @ID AND `source_type` = 0; -INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`event_param5`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_param4`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES -(@ID,0,0,0,11,0,100,0,0,0,0,0,0,22,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Respawn - Set Event Phase 1"), -(@ID,0,1,0,4,0,100,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Aggro - Say Line 0"), -(@ID,0,2,0,19,0,100,0,1393,0,0,0,0,80,@ID*100+0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Quest 'Galen's Escape' Taken - Run Script"), - -(@ID,0,3,0,40,0,100,0,1,0,0,0,0,54,3000,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Waypoint 1 Reached - Pause Waypoint"), - -(@ID,0,4,5,40,0,100,0,21,0,0,0,0,59,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Waypoint 21 Reached - Set Run On"), -(@ID,0,5,6,61,0,100,0,0,0,0,0,0,66,0,0,0,0,0,0,12,1,0,0,0,0,0,0,0,"Galen Goodward - On Link - Set Orientation Stored Target"), -(@ID,0,6,7,61,0,100,0,0,0,0,0,0,1,3,0,0,0,0,0,12,1,0,0,0,0,0,0,0,"Galen Goodward - On Link - Say Line 3"), -(@ID,0,7,8,61,0,100,0,0,0,0,0,0,1,4,0,0,0,0,0,12,1,0,0,0,0,0,0,0,"Galen Goodward - On Link - Say Line 4"), -(@ID,0,8,9,61,0,100,0,0,0,0,0,0,1,5,0,0,0,0,0,12,1,0,0,0,0,0,0,0,"Galen Goodward - On Link - Say Line 5"), -(@ID,0,9,0,61,0,100,0,0,0,0,0,0,15,1393,0,0,0,0,0,12,1,0,0,0,0,0,0,0,"Galen Goodward - On Link - Quest Credit 'Galen's Escape'"), - -(@ID,0,10,0,40,0,100,0,22,0,0,0,0,41,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Waypoint 22 Reached - Despawn (0)"), - -(@ID,0,11,0,38,1,100,0,0,1,60000,60000,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Data Set 0 1 - Say Line 1 (Phase 1)"), -(@ID,0,12,0,6,0,100,0,0,0,0,0,0,6,1393,0,0,0,0,0,12,1,0,0,0,0,0,0,0,"Galen Goodward - On Death - Fail Quest 'Galen's Escape'"); - --- Actionlist SAI -DELETE FROM `smart_scripts` WHERE `entryorguid` = @ID*100+0 AND `source_type` = 9; -INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`event_param5`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_param4`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES -(@ID*100+0,9,0,0,0,0,100,0,0,0,0,0,0,64,1,0,0,0,0,0,16,0,0,0,0,0,0,0,0,"Galen Goodward - On Script - Store Targetlist"), -(@ID*100+0,9,1,0,0,0,100,0,0,0,0,0,0,22,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Script - Set Event Phase 0"), -(@ID*100+0,9,2,0,0,0,100,0,0,0,0,0,0,83,2,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Script - Remove NPC Flag Questgiver"), -(@ID*100+0,9,3,0,0,0,100,0,0,0,0,0,0,2,250,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Script - Set Faction 250"), -(@ID*100+0,9,4,0,0,0,100,0,0,0,0,0,0,19,256,0,0,0,0,0,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Script - Remove Flags Immune To Players"), -(@ID*100+0,9,5,0,0,0,100,0,0,0,0,0,0,1,2,0,0,0,0,0,12,1,0,0,0,0,0,0,0,"Galen Goodward - On Script - Say Line 2"), -(@ID*100+0,9,6,0,0,0,100,0,3000,3000,0,0,0,9,0,0,0,0,0,0,20,37118,0,0,0,0,0,0,0,"Galen Goodward - On Script - Activate Closest Gameobject 'Galen's Cage'"), -(@ID*100+0,9,7,0,0,0,100,0,0,0,0,0,0,53,0,5391,0,0,0,2,1,0,0,0,0,0,0,0,0,"Galen Goodward - On Script - Start Waypoint"); - -DELETE FROM `creature_text` WHERE `CreatureID` = @ID; -INSERT INTO `creature_text` (`CreatureID`,`GroupID`,`ID`,`Text`,`Type`,`Language`,`Probability`,`Emote`,`Duration`,`Sound`,`BroadcastTextId`,`TextRange`,`comment`) VALUES -(@ID,0,0,"Look out! The $n attacks!",12,0,100,0,0,0,1628,0,"Galen Goodward"), -(@ID,0,1,"Help! I'm under attack!",12,0,100,0,0,0,1629,0,"Galen Goodward"), -(@ID,0,2,"Help! The beast is on me!",12,0,100,0,0,0,1630,0,"Galen Goodward"), -(@ID,1,0,"I'm glad you're here! Because I need your help!!",12,0,100,0,0,0,1631,0,"Galen Goodward"), -(@ID,1,1,"Help! Please, you must help me!",12,0,100,0,0,0,7124,0,"Galen Goodward"), -(@ID,2,0,"Let us leave this place.",12,0,100,0,0,0,1854,0,"Galen Goodward"), -(@ID,3,0,"Thank you, $n. I will remember you always. You can find my strongbox in my camp, north of Stonard.",12,0,100,0,0,0,1855,0,"Galen Goodward"), -(@ID,4,0,"%s whispers to $n the secret to opening his strongbox.",16,0,100,0,0,0,2076,0,"Galen Goodward"), -(@ID,5,0,"%s disappears into the swamp.",16,0,100,0,0,0,1856,0,"Galen Goodward"); - -DELETE FROM `script_waypoint` WHERE `entry` = 5391; -DELETE FROM `waypoints` WHERE `entry` = 5391; -INSERT INTO `waypoints` (`entry`,`pointid`,`position_x`,`position_y`,`position_z`,`point_comment`) VALUES -(5391,1,-9901.12,-3727.29,22.11,"Galen Goodward"), -(5391,2,-9909.27,-3727.81,23.25,"Galen Goodward"), -(5391,3,-9935.25,-3729.02,22.11,"Galen Goodward"), -(5391,4,-9945.83,-3719.34,21.68,"Galen Goodward"), -(5391,5,-9963.41,-3710.18,21.71,"Galen Goodward"), -(5391,6,-9972.75,-3690.13,21.68,"Galen Goodward"), -(5391,7,-9989.7,-3669.67,21.67,"Galen Goodward"), -(5391,8,-9989.21,-3647.76,23,"Galen Goodward"), -(5391,9,-9992.27,-3633.74,21.67,"Galen Goodward"), -(5391,10,-10002.3,-3611.67,22.26,"Galen Goodward"), -(5391,11,-9999.25,-3586.33,21.85,"Galen Goodward"), -(5391,12,-10006.5,-3571.99,21.67,"Galen Goodward"), -(5391,13,-10014.3,-3545.24,21.67,"Galen Goodward"), -(5391,14,-10018.9,-3525.03,21.68,"Galen Goodward"), -(5391,15,-10030.2,-3514.77,21.67,"Galen Goodward"), -(5391,16,-10045.1,-3501.49,21.67,"Galen Goodward"), -(5391,17,-10052.9,-3479.13,21.67,"Galen Goodward"), -(5391,18,-10060.7,-3460.31,21.67,"Galen Goodward"), -(5391,19,-10074.7,-3436.85,20.97,"Galen Goodward"), -(5391,20,-10074.7,-3436.85,20.97,"Galen Goodward"), -(5391,21,-10072.9,-3408.92,20.43,"Galen Goodward"), -(5391,22,-10108,-3406.05,22.06,"Galen Goodward"); - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_09_05.sql b/data/sql/updates/db_world/2021_05_09_05.sql deleted file mode 100644 index 165ae5c2ca..0000000000 --- a/data/sql/updates/db_world/2021_05_09_05.sql +++ /dev/null @@ -1,34 +0,0 @@ --- DB update 2021_05_09_04 -> 2021_05_09_05 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_09_04'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_09_04 2021_05_09_05 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620375361639873000'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620375361639873000'); - --- Remove quest mutual exclusivity -UPDATE `quest_template_addon` SET `ExclusiveGroup` = 0 WHERE (`ID` IN (990,10752)); - --- Remove Cataclysm gossip for Sentinel Selarin -UPDATE `creature_template` SET `gossip_menu_id` = 0, `npcflag` = 2 WHERE (`entry` = 3694); -DELETE FROM `gossip_menu` WHERE `MenuID` = 10268 AND `TextID` = 14259; -DELETE FROM `npc_text` WHERE `id` = 14259; - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_10_00.sql b/data/sql/updates/db_world/2021_05_10_00.sql deleted file mode 100644 index c272d106e9..0000000000 --- a/data/sql/updates/db_world/2021_05_10_00.sql +++ /dev/null @@ -1,30 +0,0 @@ --- DB update 2021_05_09_05 -> 2021_05_10_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_09_05'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_09_05 2021_05_10_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620411738725445836'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620411738725445836'); - -UPDATE `gameobject` SET `spawntimesecs`= 7200 WHERE FIND_IN_SET (`id`,'2855,2857,4096,4149,153453,153454,153451,153468'); -UPDATE `gameobject` SET `spawntimesecs`= 36000 WHERE FIND_IN_SET (`id`,'153464,153469'); - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_10_01.sql b/data/sql/updates/db_world/2021_05_10_01.sql deleted file mode 100644 index c4642700fe..0000000000 --- a/data/sql/updates/db_world/2021_05_10_01.sql +++ /dev/null @@ -1,37 +0,0 @@ --- DB update 2021_05_10_00 -> 2021_05_10_01 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_10_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_10_00 2021_05_10_01 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620379730673714800'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620379730673714800'); - --- Adjust z-position of Feero Ironhand WP 29 -UPDATE `waypoints` SET `position_z`=10.25865 WHERE `entry`=4484 AND `pointid`=29; - --- Adjust Feero Ironhand AI -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 4484; - -DELETE FROM `smart_scripts` WHERE (`entryorguid` = 4484) AND (`source_type` = 0) AND (`id` IN (28, 29)); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(4484, 0, 28, 0, 10, 0, 100, 0, 1, 0, 0, 0, 0, 20, 1, 0, 0, 0, 0, 0, 9, 0, 0, 10, 0, 0, 0, 0, 0, 'Feero Ironhand - On OOC LOS - Auto attack'), -(4484, 0, 29, 0, 26, 0, 100, 0, 1, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 9, 0, 0, 10, 0, 0, 0, 0, 0, 'Feero Ironhand - On IC LOS - Auto attack'); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_10_02.sql b/data/sql/updates/db_world/2021_05_10_02.sql deleted file mode 100644 index 65db3757a0..0000000000 --- a/data/sql/updates/db_world/2021_05_10_02.sql +++ /dev/null @@ -1,28 +0,0 @@ --- DB update 2021_05_10_01 -> 2021_05_10_02 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_10_01'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_10_01 2021_05_10_02 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620406670675031700'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620406670675031700'); - -UPDATE `quest_template_addon` SET `SpecialFlags` = 2 WHERE (`ID` = 4770); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_10_03.sql b/data/sql/updates/db_world/2021_05_10_03.sql deleted file mode 100644 index f98324107c..0000000000 --- a/data/sql/updates/db_world/2021_05_10_03.sql +++ /dev/null @@ -1,33 +0,0 @@ --- DB update 2021_05_10_02 -> 2021_05_10_03 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_10_02'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_10_02 2021_05_10_03 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620498329028793558'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620498329028793558'); - --- Missing Reference Tables in STV -UPDATE `creature_loot_template` SET `Reference` = 24723, `Comment` = 'Ana''thek the Cruel - (ReferenceTable)' WHERE `Entry`= 1059 AND `Item` = 24723; -UPDATE `creature_loot_template` SET `Reference` = 24722, `Comment` = 'Gan''zulah - (ReferenceTable)' WHERE `Entry`= 1061 AND `Item` = 24722; -UPDATE `creature_loot_template` SET `Reference` = 24723, `Comment` = 'Nezzliok the Dire - (ReferenceTable)' WHERE `Entry`= 1062 AND `Item` = 24723; -UPDATE `creature_loot_template` SET `Reference` = 24736, `Comment` = 'Nezzliok the Dire - (ReferenceTable)' WHERE `Entry`= 1062 AND `Item` = 24736; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_10_04.sql b/data/sql/updates/db_world/2021_05_10_04.sql deleted file mode 100644 index a9d02e9259..0000000000 --- a/data/sql/updates/db_world/2021_05_10_04.sql +++ /dev/null @@ -1,37 +0,0 @@ --- DB update 2021_05_10_03 -> 2021_05_10_04 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_10_03'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_10_03 2021_05_10_04 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620463648528240165'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620463648528240165'); - -UPDATE `gameobject` SET `spawntimesecs`= 2700 WHERE FIND_IN_SET (`id`,'324,150082,176643,123848'); -- Small Thorium -UPDATE `gameobject` SET `spawntimesecs`= 2700 WHERE FIND_IN_SET (`id`,'175404,177388'); -- Rich Thorium -UPDATE `gameobject` SET `spawntimesecs`= 604800 WHERE FIND_IN_SET (`id`,'175404') AND `map` = 429; -- Rich Thorium in Uldaman - -UPDATE `gameobject` SET `spawntimesecs`= 1800 WHERE FIND_IN_SET (`id`,'2040,150079,176645,123310'); -- Mithril -UPDATE `gameobject` SET `spawntimesecs`= 604800 WHERE FIND_IN_SET (`id`,'2040') AND `map` = 349; -- Mithril Mauradon - -UPDATE `gameobject` SET `spawntimesecs`= 2700 WHERE FIND_IN_SET (`id`,'2047,150081,181108,123309'); -- Truesilver -UPDATE `gameobject` SET `spawntimesecs`= 604800 WHERE FIND_IN_SET (`id`,'2040') AND `map` = 349; -- Truesilver Mauradon - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_10_05.sql b/data/sql/updates/db_world/2021_05_10_05.sql deleted file mode 100644 index 7377330864..0000000000 --- a/data/sql/updates/db_world/2021_05_10_05.sql +++ /dev/null @@ -1,41 +0,0 @@ --- DB update 2021_05_10_04 -> 2021_05_10_05 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_10_04'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_10_04 2021_05_10_05 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620531160911239800'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620531160911239800'); - --- Mosh'Ogg Warmonger Entry 709 -- -UPDATE `creature` SET `spawntimesecs` = 300 WHERE `guid` IN (277, 278, 821, 842, 844, 845, 847, 849, 851, 856, 1265, 1289, 1290, 1299, 1306); - --- Mosh'Ogg Mauler Entry 678 -- -UPDATE `creature` SET `spawntimesecs` = 300 WHERE `guid` IN (524, 629, 755, 853, 854, 1050, 1077); - --- Mosh'Ogg Shaman Entry 679 -- -UPDATE `creature` SET `spawntimesecs` = 300 WHERE `guid` IN (273, 274, 275, 276, 525, 624, 625, 627, 855); - --- Mosh'Ogg Lord Entry 680 -- -UPDATE `creature` SET `spawntimesecs` = 300 WHERE `guid` IN (521, 522, 526, 761); - --- Mosh'Ogg Spellcrafter Entry 710 -- -UPDATE `creature` SET `spawntimesecs` = 300 WHERE `guid` IN (527, 528, 623, 626, 628, 762, 1093); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_11_00.sql b/data/sql/updates/db_world/2021_05_11_00.sql deleted file mode 100644 index 42d4f19224..0000000000 --- a/data/sql/updates/db_world/2021_05_11_00.sql +++ /dev/null @@ -1,87 +0,0 @@ --- DB update 2021_05_10_05 -> 2021_05_11_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_10_05'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_10_05 2021_05_11_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620381001027478900'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620381001027478900'); - -SET @NPC := 89532; -SET @PATH := @NPC * 10; -UPDATE `creature` SET `wander_distance`=0,`MovementType`=2 WHERE `guid`=@NPC; -DELETE FROM `creature_addon` WHERE `guid`=@NPC; -INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (@NPC,@PATH,0,0,1,0, ''); -DELETE FROM `waypoint_data` WHERE `id`=@PATH; -INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`, `delay`) VALUES -(@PATH, 1, -10642.8, 1016.66, 31.5651, 0), -(@PATH, 2, -10620.2, 1000.85, 32.9944, 0), -(@PATH, 3, -10594, 987.937, 36.8771, 0), -(@PATH, 4, -10564.6, 975.733, 40.6344, 0), -(@PATH, 5, -10532.9, 961.984, 40.8852, 0), -(@PATH, 6, -10500.2, 952.64, 39.4598, 0), -(@PATH, 7, -10466.9, 953.813, 35.8982, 0), -(@PATH, 8, -10433.2, 981.964, 34.7575, 0), -(@PATH, 9, -10410.5, 994.716, 32.1643, 0), -(@PATH, 10, -10400.4, 992.543, 31.5791, 0), -(@PATH, 11, -10386.8, 984.074, 31.5979, 0), -(@PATH, 12, -10367.4, 980.618, 31.4729, 0), -(@PATH, 13, -10333.5, 978.783, 31.2549, 0), -(@PATH, 14, -10300.2, 965.637, 31.253, 0), -(@PATH, 15, -10285.6, 964.09, 31.1856, 0), -(@PATH, 16, -10273.9, 970.693, 31.1856, 0), -(@PATH, 17, -10267.6, 983.352, 31.3106, 0), -(@PATH, 18, -10260.9, 989.903, 31.3775, 0), -(@PATH, 19, -10234, 996.264, 31.4918, 0), -(@PATH, 20, -10215.9, 994.502, 32.5031, 0), -(@PATH, 21, -10200.1, 989.352, 32.9333, 0), -(@PATH, 22, -10190, 984.9, 33.7804, 0), -(@PATH, 23, -10166.8, 986.717, 34.0541, 0), -(@PATH, 24, -10133.5, 990.649, 36.0486, 0), -(@PATH, 25, -10116.7, 990.127, 38.2197, 0), -(@PATH, 26, -10100.2, 999.191, 37.4609, 0), -(@PATH, 27, -10116.7, 990.127, 38.2197, 0), -(@PATH, 28, -10133.5, 990.649, 36.0486, 0), -(@PATH, 29, -10166.8, 986.717, 34.0541, 0), -(@PATH, 30, -10190, 984.9, 33.7804, 0), -(@PATH, 31, -10200.1, 989.352, 32.9333, 0), -(@PATH, 32, -10215.9, 994.502, 32.5031, 0), -(@PATH, 33, -10234, 996.264, 31.4918, 0), -(@PATH, 34, -10260.9, 989.903, 31.3775, 0), -(@PATH, 35, -10267.6, 983.352, 31.3106, 0), -(@PATH, 36, -10273.9, 970.693, 31.1856, 0), -(@PATH, 37, -10285.6, 964.09, 31.1856, 0), -(@PATH, 38, -10300.2, 965.637, 31.253, 0), -(@PATH, 39, -10333.5, 978.783, 31.2549, 0), -(@PATH, 40, -10367.4, 980.618, 31.4729, 0), -(@PATH, 41, -10386.8, 984.074, 31.5979, 0), -(@PATH, 42, -10400.4, 992.543, 31.5791, 0), -(@PATH, 43, -10410.5, 994.716, 32.1643, 0), -(@PATH, 44, -10433.2, 981.964, 34.7575, 0), -(@PATH, 45, -10466.9, 953.813, 35.8982, 0), -(@PATH, 46, -10500.2, 952.64, 39.4598, 0), -(@PATH, 47, -10532.9, 961.984, 40.8852, 0), -(@PATH, 48, -10564.6, 975.733, 40.6344, 0), -(@PATH, 49, -10594, 987.937, 36.8771, 0), -(@PATH, 50, -10620.2, 1000.85, 32.9944, 0), -(@PATH, 51, -10642.8, 1016.66, 31.5651, 0), -(@PATH, 52, -10647.5, 1012.37, 31.7765, 0); - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_11_01.sql b/data/sql/updates/db_world/2021_05_11_01.sql deleted file mode 100644 index 3c68b49eff..0000000000 --- a/data/sql/updates/db_world/2021_05_11_01.sql +++ /dev/null @@ -1,94 +0,0 @@ --- DB update 2021_05_11_00 -> 2021_05_11_01 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_11_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_11_00 2021_05_11_01 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1618834215629926428'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1618834215629926428'); - --- Dusty rug SAI: -SET @DUSTY_RUG_ENTRY := 1728; -UPDATE `gameobject_template` SET `AIName` = 'SmartGameObjectAI' WHERE `entry` = @DUSTY_RUG_ENTRY; - -DELETE FROM `smart_scripts` WHERE (`source_type` = 1 AND `entryorguid` = @DUSTY_RUG_ENTRY); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(@DUSTY_RUG_ENTRY, 1, 0, 0, 20, 0, 100, 0, 524, 0, 0, 0, 0, 50, 1729, 40, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0.437117, -942.794, 61.9384, -2.54818, 'Dusty Rug - On Quest \'Elixir of Agony\' Finished - Summon Gameobject \'Tainted Keg\''); - - --- Tainted keg SAI: -SET @TAINTED_KEG_ENTRY := 1729; -UPDATE `gameobject_template` SET `AIName` = 'SmartGameObjectAI' WHERE `entry` = @TAINTED_KEG_ENTRY; - -DELETE FROM `smart_scripts` WHERE (`source_type` = 1 AND `entryorguid` = @TAINTED_KEG_ENTRY); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(@TAINTED_KEG_ENTRY, 1, 0, 1, 63, 0, 100, 0, 0, 0, 0, 0, 0, 67, 1, 12000, 12000, 0, 0, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg - On Just Created - Create Timed Event'), -(@TAINTED_KEG_ENTRY, 1, 1, 2, 61, 0, 100, 0, 0, 0, 0, 0, 0, 45, 1, 1, 0, 0, 0, 0, 10, 15892, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg - On Just Created - Set Data 1 1'), -(@TAINTED_KEG_ENTRY, 1, 2, 3, 61, 0, 100, 0, 1, 0, 0, 0, 0, 45, 1, 2, 0, 0, 0, 0, 10, 15893, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg - On Just Created - Set Data 1 2'), -(@TAINTED_KEG_ENTRY, 1, 3, 0, 61, 0, 100, 0, 2, 0, 0, 0, 0, 45, 1, 3, 0, 0, 0, 0, 10, 15891, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg - On Just Created - Set Data 1 3'), -(@TAINTED_KEG_ENTRY, 1, 4, 0, 59, 0, 100, 0, 1, 0, 0, 0, 0, 50, 1730, 25, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0.437117, -942.794, 62.93, -2.54818, 'Tainted Keg - On Timed Event 1 Triggered - Summon Gameobject \'Tainted Keg Smoke\''); - - --- Delete Tainted keg spawn location: -DELETE FROM `gameobject` WHERE `id` = @TAINTED_KEG_ENTRY; - - --- Tainted keg smoke SAI: -SET @TAINTED_KEG_SMOKE_ENTRY := 1730; -UPDATE `gameobject_template` SET `AIName` = 'SmartGameObjectAI' WHERE `entry` = @TAINTED_KEG_SMOKE_ENTRY; - -DELETE FROM `smart_scripts` WHERE (`source_type` = 1 AND `entryorguid` = @TAINTED_KEG_SMOKE_ENTRY); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(@TAINTED_KEG_SMOKE_ENTRY, 1, 0, 1, 63, 0, 100, 0, 0, 0, 0, 0, 0, 67, 1, 7000, 7000, 0, 0, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg Smoke - On Just Created - Create Timed Event'), -(@TAINTED_KEG_SMOKE_ENTRY, 1, 1, 2, 61, 0, 100, 0, 0, 0, 0, 0, 0, 67, 2, 4000, 4000, 0, 0, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg Smoke - On Just Created - Create Timed Event'), -(@TAINTED_KEG_SMOKE_ENTRY, 1, 2, 0, 61, 0, 100, 0, 1, 0, 0, 0, 0, 67, 3, 2000, 2000, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg Smoke - On Just Created - Create Timed Event'), -(@TAINTED_KEG_SMOKE_ENTRY, 1, 3, 0, 59, 0, 100, 0, 1, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 10, 15892, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg Smoke - On Timed Event 1 Triggered - Kill Target'), -(@TAINTED_KEG_SMOKE_ENTRY, 1, 4, 0, 59, 0, 100, 0, 2, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 10, 15893, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg Smoke - On Timed Event 2 Triggered - Kill Target'), -(@TAINTED_KEG_SMOKE_ENTRY, 1, 5, 0, 59, 0, 100, 0, 3, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 10, 15891, 0, 0, 0, 0, 0, 0, 0, 'Tainted Keg Smoke - On Timed Event 3 Triggered - Kill Target'); - - --- Captured Farmer waypoints: -DELETE FROM `waypoints` WHERE `entry` IN (1589100, 1589200, 1589300); -INSERT INTO `waypoints` (`entry`,`pointid`,`position_x`,`position_y`,`position_z`) VALUES -(1589100, 1, 0.350253, -946.004, 61.9387), -(1589100, 2, 2.42399, -942.742, 61.9396), -(1589200, 1, -7.60962, -943.344, 61.9371), -(1589200, 2, -1.75652, -941.321, 61.9381), -(1589300, 1, 0.299552, -938.505, 61.935), -(1589300, 2, 0.826452, -941.134, 61.9409); - - --- Captured Farmer SAI: -SET @CAPTURED_FARMER_ENTRY := 2284; -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = @CAPTURED_FARMER_ENTRY; - -DELETE FROM `smart_scripts` WHERE (`source_type` = 0 AND `entryorguid` = @CAPTURED_FARMER_ENTRY); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `event_param5`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_param4`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(@CAPTURED_FARMER_ENTRY, 0, 0, 0, 38, 0, 100, 1, 1, 1, 0, 0, 0, 67, 1, 5000, 5000, 0, 0, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Captured Farmer - On Data Set 1 1 - Create Timed Event (No Repeat)'), -(@CAPTURED_FARMER_ENTRY, 0, 1, 2, 59, 0, 100, 0, 1, 0, 0, 0, 0, 53, 0, 1589200, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Captured Farmer - On Timed Event 1 Triggered - Start Waypoint'), -(@CAPTURED_FARMER_ENTRY, 0, 2, 0, 61, 0, 100, 0, 1, 0, 0, 0, 0, 1, 0, 4000, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Captured Farmer - On Timed Event 1 Triggered - Say Line 0'), -(@CAPTURED_FARMER_ENTRY, 0, 3, 0, 40, 0, 100, 0, 2, 1589200, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 5.62476, 'Captured Farmer - On Waypoint 2 Reached - Set Orientation 5.62476'), -(@CAPTURED_FARMER_ENTRY, 0, 4, 5, 38, 0, 100, 1, 1, 2, 0, 0, 0, 53, 0, 1589300, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Captured Farmer - On Data Set 1 2 - Start Waypoint (No Repeat)'), -(@CAPTURED_FARMER_ENTRY, 0, 5, 0, 61, 0, 100, 1, 4, 0, 0, 0, 0, 67, 2, 7000, 7000, 0, 0, 100, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Captured Farmer - On Data Set 1 2 - Create Timed Event (No Repeat)'), -(@CAPTURED_FARMER_ENTRY, 0, 6, 0, 40, 0, 100, 0, 2, 1589300, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 4.63309, 'Captured Farmer - On Waypoint 2 Reached - Set Orientation 4.63309'), -(@CAPTURED_FARMER_ENTRY, 0, 7, 0, 59, 0, 100, 0, 2, 0, 0, 0, 0, 1, 1, 4000, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Captured Farmer - On Timed Event 2 Triggered - Say Line 1'), -(@CAPTURED_FARMER_ENTRY, 0, 8, 0, 38, 0, 100, 1, 1, 3, 0, 0, 0, 53, 0, 1589100, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 'Captured Farmer - On Data Set 1 3 - Start Waypoint (No Repeat)'), -(@CAPTURED_FARMER_ENTRY, 0, 9, 0, 40, 0, 100, 0, 2, 1589100, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 2.82591, 'Captured Farmer - On Waypoint 2 Reached - Set Orientation 2.82591'); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_12_00.sql b/data/sql/updates/db_world/2021_05_12_00.sql deleted file mode 100644 index f8bb33204d..0000000000 --- a/data/sql/updates/db_world/2021_05_12_00.sql +++ /dev/null @@ -1,31 +0,0 @@ --- DB update 2021_05_11_01 -> 2021_05_12_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_11_01'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_11_01 2021_05_12_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620674399849229322'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620674399849229322'); -UPDATE `item_template` SET `minMoneyLoot`=50, `maxMoneyLoot`=100 WHERE `entry`=20708; -- Tightly Sealed Trunk -UPDATE `item_template` SET `minMoneyLoot`=100, `maxMoneyLoot`=200 WHERE `entry` IN ( -21113, -- Watertight Trunk -21150, -- Iron Bound Trunk -21228); -- Mithril Bound Trunk - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_13_00.sql b/data/sql/updates/db_world/2021_05_13_00.sql deleted file mode 100644 index 04e67beace..0000000000 --- a/data/sql/updates/db_world/2021_05_13_00.sql +++ /dev/null @@ -1,57 +0,0 @@ --- DB update 2021_05_12_00 -> 2021_05_13_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_12_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_12_00 2021_05_13_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620079973240388200'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620079973240388200'); - --- -DELETE FROM `command` WHERE `name` LIKE 'account 2fa%'; -DELETE FROM `command` WHERE `name`='account set 2fa'; -INSERT INTO `command` (`name`, `security`, `help`) VALUES -('account 2fa', 0, 'Syntax: .account 2fa '), -('account 2fa setup', 0, 'Syntax: .account 2fa setup -Sets up two-factor authentication for this account.'), -('account 2fa remove', 0, 'Syntax: .account 2fa remove -Disables two-factor authentication for this account, if enabled.'), -('account set 2fa', 0, 'Syntax: .account set 2fa -Provide a base32 encoded secret to setup two-factor authentication for the account. -Specify \'off\' to disable two-factor authentication for the account.'); - -DELETE FROM `acore_string` WHERE `entry` BETWEEN 87 AND 95; -DELETE FROM `acore_string` WHERE `entry` BETWEEN 188 AND 190; -INSERT INTO `acore_string` (`entry`,`content_default`) VALUES -(87, "UNKNOWN_ERROR"), -(88, "Two-factor authentication commands are not properly setup."), -(89, "Two-factor authentication is already enabled for this account."), -(90, "Invalid two-factor authentication token specified."), -(91, "In order to complete setup, you'll need to set up the device you'll be using as your second factor. -Your 2FA key: %s -Once you have set up your device, confirm by running .account 2fa setup with the generated token."), -(92, "Two-factor authentication has been successfully set up."), -(93, "Two-factor authentication is not enabled for this account."), -(94, "To remove two-factor authentication, please specify a fresh two-factor token from your authentication device."), -(95, "Two-factor authentication has been successfully disabled."), -(188, "The provided two-factor authentication secret is too long."), -(189, "The provided two-factor authentication secret is not valid."), -(190, "Successfully enabled two-factor authentication for '%s' with the specified secret."); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_13_01.sql b/data/sql/updates/db_world/2021_05_13_01.sql deleted file mode 100644 index 15a545bd95..0000000000 --- a/data/sql/updates/db_world/2021_05_13_01.sql +++ /dev/null @@ -1,77 +0,0 @@ --- DB update 2021_05_13_00 -> 2021_05_13_01 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_13_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_13_00 2021_05_13_01 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620440802474191100'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620440802474191100'); - --- Dalinda Malem -DELETE FROM `creature_text` WHERE `CreatureID`=5644; -INSERT INTO `creature_text` (`CreatureID`, `GroupID`, `ID`, `Text`, `Type`, `Language`, `Probability`, `Emote`, `Duration`, `Sound`, `BroadcastTextId`, `TextRange`, `comment`) VALUES -(5644,0,0,"Elune be with us! Let's make haste from this evil fortress.",12,7,100,0,0,0,2143,0,"Dalinda Malem"), -(5644,1,0,"I will hurry back to Vahlarriel. Finish off those that you can--I should be fine on my own from here.",12,7,100,0,0,0,2144,0,"Dalinda Malem"); - -UPDATE `creature_addon` SET `bytes1`=0 WHERE `guid`=26987; - -UPDATE `creature_template` SET `AIName`="SmartAI", `ScriptName`="" WHERE `entry`=5644; -DELETE FROM `smart_scripts` WHERE `entryorguid`=5644 AND `source_type`=0; -DELETE FROM `smart_scripts` WHERE `entryorguid` IN (564400,564401) AND `source_type`=9; -INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`event_param5`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES -(5644,0,0,0,11,0,100,0,0,0,0,0,0,90,8,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Respawn - Set Flag Standstate 'Kneel'"), -(5644,0,1,2,19,0,100,0,1440,0,0,0,0,64,1,0,0,0,0,0,7,0,0,0,0,0,0,0,"Dalinda Malem - On Quest 'Return to Vahlarriel' Taken - Store Targetlist"), -(5644,0,2,3,61,0,100,0,0,0,0,0,0,83,2,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Quest 'Return to Vahlarriel' Taken - Remove Npc Flag Questgiver"), -(5644,0,3,4,61,0,100,0,0,0,0,0,0,80,564400,2,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Quest 'Return to Vahlarriel' Taken - Run Script"), -(5644,0,4,5,61,0,100,0,0,0,0,0,0,2,113,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Quest 'Return to Vahlarriel' Taken - Set Faction 113"), -(5644,0,5,0,61,0,100,0,0,0,0,0,0,19,512,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Quest 'Return to Vahlarriel' Taken - Remove Unit Flag 'Immune to NPC'"), -(5644,0,6,0,6,0,100,0,0,0,0,0,0,6,1440,0,0,0,0,0,12,1,0,0,0,0,0,0,"Dalinda Malem - On Just Died - Fail Quest 'Return to Vahlarriel'"), -(5644,0,7,0,40,0,100,0,15,5644,0,0,0,80,564401,2,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Waypoint 15 Reached - Run Script"), -(5644,0,8,0,40,0,100,0,16,5644,0,0,0,41,1000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Waypoint 16 Reached - Despawn"), -(5644,0,9,0,11,0,100,0,0,0,0,0,0,18,512,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Respawn - Add Unit Flag 'Immune to NPC'"), -(564400,9,0,0,0,0,100,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Script - Say Line 0"), -(564400,9,1,0,0,0,100,0,0,0,0,0,0,91,8,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Script - Remove Flag Standstate 'Kneel'"), -(564400,9,2,0,0,0,100,0,5000,5000,0,0,0,53,0,5644,0,0,0,2,1,0,0,0,0,0,0,0,"Dalinda Malem - On Script - Start Waypoint"), -(564401,9,0,0,0,0,100,0,0,0,0,0,0,54,8000,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Script - Pause Waypoint"), -(564401,9,1,0,0,0,100,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Script - Say Line 1"), -(564401,9,2,0,0,0,100,0,0,0,0,0,0,15,1440,0,0,0,0,0,12,1,0,0,0,0,0,0,"Dalinda Malem - On Script - Complete Quest 'Return to Vahlarriel'"), -(564401,9,3,0,0,0,100,0,0,0,0,0,0,59,1,0,0,0,0,0,1,0,0,0,0,0,0,0,"Dalinda Malem - On Script - Set Run On"); - -DELETE FROM `script_waypoint` WHERE `entry`=5644; -DELETE FROM `waypoints` WHERE `entry`=5644; -INSERT INTO `waypoints` (`entry`,`pointid`,`position_x`,`position_y`,`position_z`,`point_comment`) VALUES -(5644,1,-339.679,1752.04,139.482,""), -(5644,2,-328.957,1734.95,139.327,""), -(5644,3,-350.747,1731.12,139.338,""), -(5644,4,-365.064,1739.04,139.376,""), -(5644,5,-371.105,1746.03,139.374,""), -(5644,6,-383.141,1738.62,138.93,""), -(5644,7,-390.445,1733.98,136.353,""), -(5644,8,-401.368,1726.77,131.071,""), -(5644,9,-416.016,1721.19,129.807,""), -(5644,10,-437.139,1709.82,126.342,""), -(5644,11,-459.862,1687.92,116.059,""), -(5644,12,-460.686,1679.55,111.976,""), -(5644,13,-461.485,1670.94,109.033,""), -(5644,14,-468.53,1645.51,102.811,""), -(5644,15,-474.529,1615.97,97.228,""), -(5644,16,-474.329,1590.01,94.4982,""); - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_13_02.sql b/data/sql/updates/db_world/2021_05_13_02.sql deleted file mode 100644 index 708b1fc2db..0000000000 --- a/data/sql/updates/db_world/2021_05_13_02.sql +++ /dev/null @@ -1,40 +0,0 @@ --- DB update 2021_05_13_01 -> 2021_05_13_02 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_13_01'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_13_01 2021_05_13_02 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620437148392158200'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620437148392158200'); - -UPDATE `creature_template` SET `AIName`='SmartAI' WHERE `entry`=23941; -DELETE FROM `smart_scripts` WHERE `entryorguid`= 23941 AND `source_type`= 0; -DELETE FROM `smart_scripts` WHERE `entryorguid`= 2394100 AND `source_type`= 9; -INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES -(23941,0,0,0,2,0,100,1,0,15,0,0,11,42660,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - Between 0-15% Health - Cast 'Gavis Greyshield Credit' (No Repeat)"), -(23941,0,1,2,2,0,100,1,0,15,0,0,80,2394100,2,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - Between 0-15% Health - Run Script (No Repeat)"), -(23941,0,2,3,61,0,100,1,0,0,0,0,2,35,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - Between 0-15% Health - Set Faction 35"), -(23941,0,3,4,61,0,100,1,0,0,0,0,24,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - Between 0-15% Health - Evade"), -(23941,0,4,0,61,0,100,1,0,0,0,0,103,1,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - Between 0-15% Health - Set Root On"), -(2394100,9,0,0,0,0,100,0,1000,1000,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - On Script - Say Line 0"), -(2394100,9,1,0,0,0,100,0,4000,4000,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - On Script - Say Line 1"), -(2394100,9,2,0,0,0,100,0,10000,10000,0,0,41,0,0,0,0,0,0,1,0,0,0,0,0,0,0,"Gavis Greyshield - On Script - Despawn"); - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_13_03.sql b/data/sql/updates/db_world/2021_05_13_03.sql deleted file mode 100644 index ae4da60932..0000000000 --- a/data/sql/updates/db_world/2021_05_13_03.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DB update 2021_05_13_02 -> 2021_05_13_03 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_13_02'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_13_02 2021_05_13_03 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620614142868981300'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620614142868981300'); - -UPDATE `gameobject` SET `spawntimesecs`=3600 WHERE `id`=180685; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_13_04.sql b/data/sql/updates/db_world/2021_05_13_04.sql deleted file mode 100644 index 03a5f43a8f..0000000000 --- a/data/sql/updates/db_world/2021_05_13_04.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DB update 2021_05_13_03 -> 2021_05_13_04 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_13_03'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_13_03 2021_05_13_04 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620614979222366200'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620614979222366200'); - -UPDATE `gameobject` SET `state`=1 WHERE `guid`=120186; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_14_00.sql b/data/sql/updates/db_world/2021_05_14_00.sql deleted file mode 100644 index 979def9db1..0000000000 --- a/data/sql/updates/db_world/2021_05_14_00.sql +++ /dev/null @@ -1,41 +0,0 @@ --- DB update 2021_05_13_04 -> 2021_05_14_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_13_04'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_13_04 2021_05_14_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620425644910599900'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620425644910599900'); - --- Delete WP path info for minions -DELETE FROM `creature_addon` WHERE `guid` IN (6973, 6975, 6974 ,6989 ,7210); - --- Create group -SET @leader:=7209; -DELETE FROM `creature_formations` WHERE `leaderGUID`=@leader; -INSERT INTO `creature_formations` (`leaderGUID`, `memberGUID`, `dist`, `angle`, `groupAI`, `point_1`, `point_2`) VALUES -(@leader, @leader, 5, 0, 2, 0, 0), -- core -(@leader, 6973, 8, 90, 2, 0, 0), -(@leader, 6975, 14, 140, 2, 0, 0), -(@leader, 6974, 16, 210, 2, 0, 0), -(@leader, 6989, 12, 260, 2, 0, 0), -(@leader, 7210, 10, 320, 2, 0, 0); - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_14_01.sql b/data/sql/updates/db_world/2021_05_14_01.sql deleted file mode 100644 index 20912c0ae1..0000000000 --- a/data/sql/updates/db_world/2021_05_14_01.sql +++ /dev/null @@ -1,34 +0,0 @@ --- DB update 2021_05_14_00 -> 2021_05_14_01 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_14_00'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_14_00 2021_05_14_01 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620435208642994700'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620435208642994700'); - --- es.classic.wowhead.com/npc=6910/revelosh -UPDATE `creature_loot_template` SET `Chance`=41 WHERE `Entry`=6910 AND `Item`=7741; -UPDATE `creature_loot_template` SET `Chance`=23 WHERE `Entry`=6910 AND `Item` IN (9387,9389); -UPDATE `creature_loot_template` SET `Chance`=21 WHERE `Entry`=6910 AND `Item` IN (9390,9388); -UPDATE `creature_loot_template` SET `Chance`=13 WHERE `Entry`=6910 AND `Item`=4306; -UPDATE `creature_loot_template` SET `Chance`=2 WHERE `Entry`=6910 AND `Item`=3771; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_14_02.sql b/data/sql/updates/db_world/2021_05_14_02.sql deleted file mode 100644 index b6ca8f7565..0000000000 --- a/data/sql/updates/db_world/2021_05_14_02.sql +++ /dev/null @@ -1,30 +0,0 @@ --- DB update 2021_05_14_01 -> 2021_05_14_02 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_14_01'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_14_01 2021_05_14_02 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620439642282070000'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620439642282070000'); - -DELETE FROM `creature_loot_template` WHERE `Entry`=7768; -UPDATE `creature_template` SET `lootid`=0 WHERE `entry`=7768; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_14_03.sql b/data/sql/updates/db_world/2021_05_14_03.sql deleted file mode 100644 index 9a3d6cf7c3..0000000000 --- a/data/sql/updates/db_world/2021_05_14_03.sql +++ /dev/null @@ -1,34 +0,0 @@ --- DB update 2021_05_14_02 -> 2021_05_14_03 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_14_02'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_14_02 2021_05_14_03 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620477325004735900'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620477325004735900'); - -SET @ENTRY := 4362; -UPDATE `creature_template` SET `AIName`="SmartAI" WHERE `entry`=@ENTRY; -DELETE FROM `smart_scripts` WHERE `entryorguid`=@ENTRY AND `source_type`=0; -INSERT INTO `smart_scripts` (`entryorguid`,`source_type`,`id`,`link`,`event_type`,`event_phase_mask`,`event_chance`,`event_flags`,`event_param1`,`event_param2`,`event_param3`,`event_param4`,`action_type`,`action_param1`,`action_param2`,`action_param3`,`action_param4`,`action_param5`,`action_param6`,`target_type`,`target_param1`,`target_param2`,`target_param3`,`target_x`,`target_y`,`target_z`,`target_o`,`comment`) VALUES -(@ENTRY,0,0,0,2,0,100,1,0,15,0,0,25,1,0,0,0,0,0,1,0,0,0,0,0,0,0,"Mirefin Coastrunner - Between 0-15% Health - Flee For Assist (No Repeat)"), -(@ENTRY,0,1,0,0,0,100,0,2000,4500,12000,13000,11,37998,0,0,0,0,0,2,0,0,0,0,0,0,0,"Mirefin Coastrunner - In Combat - Cast 'Piercing Strike'"); - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_14_04.sql b/data/sql/updates/db_world/2021_05_14_04.sql deleted file mode 100644 index f3f476b5b5..0000000000 --- a/data/sql/updates/db_world/2021_05_14_04.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DB update 2021_05_14_03 -> 2021_05_14_04 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_14_03'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_14_03 2021_05_14_04 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620586666463013100'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620586666463013100'); - --- Imp - Felhunter - Voidwalker - Succubus -- -UPDATE `creature_template` SET `InhabitType` = 3 WHERE `entry` IN (416, 417, 1860, 1863); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_14_05.sql b/data/sql/updates/db_world/2021_05_14_05.sql deleted file mode 100644 index 7852a237b8..0000000000 --- a/data/sql/updates/db_world/2021_05_14_05.sql +++ /dev/null @@ -1,29 +0,0 @@ --- DB update 2021_05_14_04 -> 2021_05_14_05 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_14_04'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_14_04 2021_05_14_05 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620613702128937000'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620613702128937000'); - -DELETE FROM `smart_scripts` WHERE `entryorguid`=4543 AND `source_type`=0 AND `id`=7 AND `link`=0; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_14_06.sql b/data/sql/updates/db_world/2021_05_14_06.sql deleted file mode 100644 index 5134e14586..0000000000 --- a/data/sql/updates/db_world/2021_05_14_06.sql +++ /dev/null @@ -1,32 +0,0 @@ --- DB update 2021_05_14_05 -> 2021_05_14_06 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_14_05'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_14_05 2021_05_14_06 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1620616751102617000'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1620616751102617000'); - --- Remove path -UPDATE `creature_addon` SET `path_id`=0 WHERE `guid`=11198; --- Make npc walk around -UPDATE `creature` SET `MovementType`=1 WHERE `guid`=11198; - - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/data/sql/updates/db_world/2021_05_15_00.sql b/data/sql/updates/db_world/2021_05_15_00.sql deleted file mode 100644 index 7a1d7d0c8d..0000000000 --- a/data/sql/updates/db_world/2021_05_15_00.sql +++ /dev/null @@ -1,220 +0,0 @@ --- DB update 2021_05_14_06 -> 2021_05_15_00 -DROP PROCEDURE IF EXISTS `updateDb`; -DELIMITER // -CREATE PROCEDURE updateDb () -proc:BEGIN DECLARE OK VARCHAR(100) DEFAULT 'FALSE'; -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'version_db_world' AND COLUMN_NAME = '2021_05_14_06'; -IF @COLEXISTS = 0 THEN LEAVE proc; END IF; -START TRANSACTION; -ALTER TABLE version_db_world CHANGE COLUMN 2021_05_14_06 2021_05_15_00 bit; -SELECT sql_rev INTO OK FROM version_db_world WHERE sql_rev = '1616252753401265600'; IF OK <> 'FALSE' THEN LEAVE proc; END IF; --- --- START UPDATING QUERIES --- - -INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1616252753401265600'); -/* - * Zone: Netherstorm - * Update by Knindza | -*/ - -/* SMARTSCRIPT */ -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20480; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20480); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20480, 0, 0, 0, 2, 0, 100, 1, 50, 90, 10, 40, 11, 36141, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Kirin\'Var Ghost - Between 50-90% Health - Cast \'36141\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20512; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20512); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20512, 0, 0, 0, 2, 0, 100, 1, 20, 80, 0, 0, 11, 36153, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Tormented Soul - Between 20-80% Health - Cast \'36153\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 21065; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 21065); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(21065, 0, 0, 0, 4, 0, 100, 0, 0, 0, 0, 0, 11, 11980, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Tormented Citizen - On Aggro - Cast \'11980\''), -(21065, 0, 1, 0, 0, 0, 100, 0, 1700, 2700, 6200, 8400, 11, 9613, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Tormented Citizen - In Combat - Cast \'9613\''), -(21065, 0, 2, 0, 2, 0, 100, 1, 10, 30, 0, 0, 11, 36153, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Tormented Citizen - Between 10-30% Health - Cast \'36153\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 19686; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 19686); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(19686, 0, 0, 0, 2, 0, 100, 1, 2, 5, 0, 0, 11, 1604, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Nether Anomaly - Between 2-5% Health - Cast \'1604\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 19653; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 19653); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(19653, 0, 0, 0, 2, 0, 100, 1, 2, 5, 0, 0, 11, 1604, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Glacius - Between 2-5% Health - Cast \'1604\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 19731; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 19731); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(19731, 0, 0, 0, 0, 0, 100, 1, 1500, 2000, 0, 0, 75, 33731, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Nether Beast - In Combat - Add Aura \'33731\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20404; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20404); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20404, 0, 0, 0, 0, 0, 100, 0, 2100, 3400, 6900, 9400, 11, 35147, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Warp-Gate Engineer - In Combat - Cast \'35147\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20773; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20773); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20773, 0, 0, 0, 2, 0, 100, 1, 20, 80, 0, 0, 11, 25640, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Barbscale Crocolisk - Between 20-80% Health - Cast \'25640\' (No Repeat)'), -(20773, 0, 1, 0, 2, 0, 100, 1, 2, 5, 0, 0, 11, 3604, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Barbscale Crocolisk - Between 2-5% Health - Cast \'3604\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20611; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20611); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20611, 0, 0, 0, 0, 0, 100, 0, 2500, 4000, 8500, 9500, 11, 32914, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Shimmerwing Moth - In Combat - Cast \'32914\''), -(20611, 0, 1, 0, 2, 0, 100, 1, 10, 30, 0, 0, 11, 36592, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Shimmerwing Moth - Between 10-30% Health - Cast \'36592\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20854; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20854); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20854, 0, 0, 0, 0, 0, 100, 0, 1700, 2500, 6700, 8500, 11, 15284, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Gladiator - In Combat - Cast \'15284\''), -(20854, 0, 1, 0, 2, 0, 100, 1, 10, 30, 0, 0, 11, 16856, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Gladiator - Between 10-30% Health - Cast \'16856\' (No Repeat)'), -(20854, 0, 2, 0, 2, 0, 100, 1, 2, 5, 0, 0, 11, 9080, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Gladiator - Between 2-5% Health - Cast \'9080\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20453; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20453); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20453, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 36500, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Shocktrooper - On Aggro - Cast \'36500\' (No Repeat)'), -(20453, 0, 1, 0, 0, 0, 100, 0, 2300, 3500, 12300, 14500, 11, 31553, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Shocktrooper - In Combat - Cast \'31553\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20452; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20452); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20452, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 32920, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Assassin - On Aggro - Cast \'32920\' (No Repeat)'), -(20452, 0, 1, 0, 0, 0, 100, 0, 2700, 3400, 6800, 9200, 11, 7159, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Assassin - In Combat - Cast \'7159\''), -(20452, 0, 2, 0, 2, 0, 100, 1, 20, 80, 0, 0, 11, 34802, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Assassin - Between 20-80% Health - Cast \'34802\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20456; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20456); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20456, 0, 0, 0, 0, 0, 100, 0, 1700, 2400, 5200, 6800, 11, 9532, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Researcher - In Combat - Cast \'9532\''), -(20456, 0, 1, 0, 2, 0, 100, 1, 20, 80, 0, 0, 11, 36508, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Researcher - Between 20-80% Health - Cast \'36508\' (No Repeat)'), -(20456, 0, 2, 0, 2, 0, 100, 1, 10, 30, 0, 0, 11, 36506, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Researcher - Between 10-30% Health - Cast \'36506\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20474; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20474); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20474, 0, 0, 0, 54, 0, 100, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Nexus-Stalker - On Just Summoned - Say Line 0'), -(20474, 0, 1, 0, 1, 0, 100, 1, 1000, 1500, 0, 0, 11, 36515, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Nexus-Stalker - Out of Combat - Cast \'36515\' (No Repeat)'), -(20474, 0, 2, 0, 0, 0, 100, 0, 2500, 5000, 10000, 12500, 11, 36517, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Nexus-Stalker - In Combat - Cast \'36517\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20779; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20779); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20779, 0, 0, 0, 0, 0, 100, 0, 5000, 10000, 15000, 25000, 11, 35556, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Congealed Void Horror - In Combat - Cast \'35556\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20458; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20458); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20458, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 36513, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Archon - On Aggro - Cast \'36513\' (No Repeat)'), -(20458, 0, 1, 0, 0, 0, 100, 0, 1700, 2300, 9200, 12300, 11, 35924, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Archon - In Combat - Cast \'35924\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20459; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20459); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20459, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 36509, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Overlord - On Aggro - Cast \'36509\' (No Repeat)'), -(20459, 0, 1, 0, 2, 0, 100, 1, 70, 95, 0, 0, 11, 32064, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Overlord - Between 70-95% Health - Cast \'32064\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20340; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20340); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20340, 0, 0, 0, 0, 0, 100, 0, 2700, 4400, 7200, 9800, 11, 36471, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Fleshfiend - In Combat - Cast \'36471\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 23008; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 23008); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(23008, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 36513, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Jailor - On Aggro - Cast \'36513\' (No Repeat)'), -(23008, 0, 1, 0, 0, 0, 100, 0, 1700, 2300, 9200, 12300, 11, 35924, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Jailor - In Combat - Cast \'35924\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 22822; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 22822); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(22822, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 36513, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ethereum Nullifier - On Aggro - Cast \'36513\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20931; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20931); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20931, 0, 0, 0, 0, 0, 100, 0, 2500, 4000, 17500, 20000, 11, 35321, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Tyrantus - In Combat - Cast \'35321\''), -(20931, 0, 1, 0, 2, 0, 100, 1, 10, 30, 0, 0, 11, 36629, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Tyrantus - Between 10-30% Health - Cast \'36629\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20634; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20634); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20634, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 37359, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Scythetooth Raptor - On Aggro - Cast \'37359\' (No Repeat)'), -(20634, 0, 1, 0, 2, 0, 100, 1, 20, 80, 0, 0, 11, 8599, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Scythetooth Raptor - Between 20-80% Health - Cast \'8599\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 21135; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 21135); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(21135, 0, 0, 0, 2, 0, 100, 1, 20, 80, 0, 0, 11, 32008, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Fel Imp - Between 20-80% Health - Cast \'32008\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20928; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20928); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20928, 0, 0, 0, 0, 0, 100, 0, 1000, 1000, 7000, 9000, 11, 37179, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ironspine Forgelord - In Combat - Cast \'37179\''), -(20928, 0, 1, 0, 0, 0, 100, 0, 4000, 4000, 5000, 5000, 11, 36251, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Ironspine Forgelord - In Combat - Cast \'36251\''), -(20928, 0, 2, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 33962, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ironspine Forgelord - On Aggro - Cast \'33962\' (No Repeat)'), -(20928, 0, 3, 0, 38, 0, 100, 0, 0, 1, 0, 0, 86, 38982, 0, 23, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ironspine Forgelord - On Data Set 0 1 - Cross Cast \'38982\''), -(20928, 0, 4, 0, 38, 0, 100, 0, 0, 2, 0, 0, 86, 38983, 0, 23, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ironspine Forgelord - On Data Set 0 2 - Cross Cast \'38983\''), -(20928, 0, 5, 0, 38, 0, 100, 0, 0, 3, 0, 0, 86, 38984, 0, 23, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Ironspine Forgelord - On Data Set 0 3 - Cross Cast \'38984\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 21923; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 21923); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(21923, 0, 0, 0, 0, 0, 100, 0, 2400, 3200, 8600, 9800, 11, 15496, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Terrorguard Protector - In Combat - Cast \'15496\''), -(21923, 0, 1, 0, 2, 0, 100, 1, 10, 50, 0, 0, 11, 37488, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Terrorguard Protector - Between 10-50% Health - Cast \'37488\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 18858; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 18858); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(18858, 0, 0, 0, 0, 0, 100, 0, 2500, 5000, 10000, 15000, 11, 3391, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Wrathbringer - In Combat - Cast \'3391\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20516; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20516); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20516, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 36577, 32, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Warp Monstrosity - On Aggro - Cast \'36577\' (No Repeat)'), -(20516, 0, 1, 0, 0, 0, 100, 0, 1700, 2300, 6800, 8100, 11, 13901, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Warp Monstrosity - In Combat - Cast \'13901\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20929; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20929); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20929, 0, 0, 0, 0, 0, 100, 0, 2300, 4100, 7400, 9200, 11, 15496, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Wrath Lord - In Combat - Cast \'15496\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20930; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20930); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20930, 0, 0, 0, 4, 0, 100, 1, 0, 0, 0, 0, 11, 36541, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Hatecryer - On Aggro - Cast \'36541\' (No Repeat)'), -(20930, 0, 1, 0, 0, 0, 100, 0, 2100, 3500, 9100, 12500, 11, 34017, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Hatecryer - In Combat - Cast \'34017\''); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 20685; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 20685); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(20685, 0, 0, 0, 0, 0, 100, 0, 2000, 2500, 12500, 15000, 11, 35491, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Overseer Azarad - In Combat - Cast \'35491\''), -(20685, 0, 1, 0, 2, 0, 100, 1, 10, 30, 0, 0, 11, 35492, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Overseer Azarad - Between 10-30% Health - Cast \'35492\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 21267; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 21267); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(21267, 0, 0, 0, 2, 0, 100, 1, 20, 80, 0, 0, 11, 36484, 32, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Mana Beast - Between 20-80% Health - Cast \'36484\' (No Repeat)'); - -UPDATE `creature_template` SET `AIName` = 'SmartAI' WHERE `entry` = 21089; -DELETE FROM `smart_scripts` WHERE (source_type = 0 AND entryorguid = 21089); -INSERT INTO `smart_scripts` (`entryorguid`, `source_type`, `id`, `link`, `event_type`, `event_phase_mask`, `event_chance`, `event_flags`, `event_param1`, `event_param2`, `event_param3`, `event_param4`, `action_type`, `action_param1`, `action_param2`, `action_param3`, `action_param4`, `action_param5`, `action_param6`, `target_type`, `target_param1`, `target_param2`, `target_param3`, `target_x`, `target_y`, `target_z`, `target_o`, `comment`) VALUES -(21089, 0, 0, 0, 0, 0, 100, 0, 3700, 5500, 9800, 13600, 11, 35871, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 'Sunfury Blood Knight - In Combat - Cast \'35871\''), -(21089, 0, 1, 0, 2, 0, 100, 1, 40, 80, 0, 0, 11, 36476, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Sunfury Blood Knight - Between 40-80% Health - Cast \'36476\' (No Repeat)'), -(21089, 0, 2, 0, 2, 0, 100, 1, 10, 30, 0, 0, 11, 8599, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 'Sunfury Blood Knight - Between 10-30% Health - Cast \'8599\' (No Repeat)'); - --- --- END UPDATING QUERIES --- -COMMIT; -END // -DELIMITER ; -CALL updateDb(); -DROP PROCEDURE IF EXISTS `updateDb`; diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 3c30d4661e..cf1c310459 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -27,7 +27,6 @@ if(SERVERS OR TOOLS) add_subdirectory(SFMT) add_subdirectory(utf8cpp) add_subdirectory(openssl) - add_subdirectory(argon2) endif() if(SERVERS) @@ -35,7 +34,6 @@ if(SERVERS) add_subdirectory(readline) add_subdirectory(jemalloc) add_subdirectory(gsoap) - add_subdirectory(gperftools) endif() if(TOOLS) diff --git a/deps/PackageList.txt b/deps/PackageList.txt index b7d0a6ca5a..3b519c719d 100644 --- a/deps/PackageList.txt +++ b/deps/PackageList.txt @@ -4,10 +4,6 @@ ACE (ADAPTIVE Communication Environment) http://www.cs.wustl.edu/~schmidt/ACE.html Version: 6.1.4 -argon2 - https://github.com/P-H-C/phc-winner-argon2 - Version: 62358ba - bzip2 (a freely available, patent free, high-quality data compressor) http://www.bzip.org/ Version: 1.0.6 diff --git a/deps/argon2/CMakeLists.txt b/deps/argon2/CMakeLists.txt deleted file mode 100644 index f133367f1c..0000000000 --- a/deps/argon2/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# This file is part of the WarheadCore Project. See AUTHORS file for Copyright information -# -# This file is free software; as a special exception the author gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -file(GLOB_RECURSE sources *.c) - -if(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") - list(REMOVE_ITEM sources - ${CMAKE_CURRENT_SOURCE_DIR}/argon2/opt.c) -else() - list(REMOVE_ITEM sources - ${CMAKE_CURRENT_SOURCE_DIR}/argon2/ref.c) -endif() - -add_library(argon2 STATIC - ${sources}) - -target_compile_definitions(argon2 - PRIVATE - -DARGON2_NO_THREADS) - -set_target_properties(argon2 PROPERTIES LINKER_LANGUAGE CXX) - -target_include_directories(argon2 - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}) - -target_link_libraries(argon2 - PRIVATE - acore-dependency-interface) - -set_target_properties(argon2 - PROPERTIES - FOLDER - "deps") diff --git a/deps/argon2/LICENSE b/deps/argon2/LICENSE deleted file mode 100644 index fa611f7ac8..0000000000 --- a/deps/argon2/LICENSE +++ /dev/null @@ -1,314 +0,0 @@ -Argon2 reference source code package - reference C implementations - -Copyright 2015 -Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - -You may use this work under the terms of a Creative Commons CC0 1.0 -License/Waiver or the Apache Public License 2.0, at your option. The terms of -these licenses can be found at: - -- CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 -- Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - -The terms of the licenses are reproduced below. - --------------------------------------------------------------------------------- - -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. - --------------------------------------------------------------------------------- - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. diff --git a/deps/argon2/argon2/argon2.c b/deps/argon2/argon2/argon2.c deleted file mode 100644 index 795b429e71..0000000000 --- a/deps/argon2/argon2/argon2.c +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include - -#include "argon2.h" -#include "encoding.h" -#include "core.h" - -const char *argon2_type2string(argon2_type type, int uppercase) { - switch (type) { - case Argon2_d: - return uppercase ? "Argon2d" : "argon2d"; - case Argon2_i: - return uppercase ? "Argon2i" : "argon2i"; - case Argon2_id: - return uppercase ? "Argon2id" : "argon2id"; - } - - return NULL; -} - -int argon2_ctx(argon2_context *context, argon2_type type) { - /* 1. Validate all inputs */ - int result = validate_inputs(context); - uint32_t memory_blocks, segment_length; - argon2_instance_t instance; - - if (ARGON2_OK != result) { - return result; - } - - if (Argon2_d != type && Argon2_i != type && Argon2_id != type) { - return ARGON2_INCORRECT_TYPE; - } - - /* 2. Align memory size */ - /* Minimum memory_blocks = 8L blocks, where L is the number of lanes */ - memory_blocks = context->m_cost; - - if (memory_blocks < 2 * ARGON2_SYNC_POINTS * context->lanes) { - memory_blocks = 2 * ARGON2_SYNC_POINTS * context->lanes; - } - - segment_length = memory_blocks / (context->lanes * ARGON2_SYNC_POINTS); - /* Ensure that all segments have equal length */ - memory_blocks = segment_length * (context->lanes * ARGON2_SYNC_POINTS); - - instance.version = context->version; - instance.memory = NULL; - instance.passes = context->t_cost; - instance.memory_blocks = memory_blocks; - instance.segment_length = segment_length; - instance.lane_length = segment_length * ARGON2_SYNC_POINTS; - instance.lanes = context->lanes; - instance.threads = context->threads; - instance.type = type; - - if (instance.threads > instance.lanes) { - instance.threads = instance.lanes; - } - - /* 3. Initialization: Hashing inputs, allocating memory, filling first - * blocks - */ - result = initialize(&instance, context); - - if (ARGON2_OK != result) { - return result; - } - - /* 4. Filling memory */ - result = fill_memory_blocks(&instance); - - if (ARGON2_OK != result) { - return result; - } - /* 5. Finalization */ - finalize(context, &instance); - - return ARGON2_OK; -} - -int argon2_hash(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, const size_t saltlen, - void *hash, const size_t hashlen, char *encoded, - const size_t encodedlen, argon2_type type, - const uint32_t version){ - - argon2_context context; - int result; - uint8_t *out; - - if (pwdlen > ARGON2_MAX_PWD_LENGTH) { - return ARGON2_PWD_TOO_LONG; - } - - if (saltlen > ARGON2_MAX_SALT_LENGTH) { - return ARGON2_SALT_TOO_LONG; - } - - if (hashlen > ARGON2_MAX_OUTLEN) { - return ARGON2_OUTPUT_TOO_LONG; - } - - if (hashlen < ARGON2_MIN_OUTLEN) { - return ARGON2_OUTPUT_TOO_SHORT; - } - - out = malloc(hashlen); - if (!out) { - return ARGON2_MEMORY_ALLOCATION_ERROR; - } - - context.out = (uint8_t *)out; - context.outlen = (uint32_t)hashlen; - context.pwd = CONST_CAST(uint8_t *)pwd; - context.pwdlen = (uint32_t)pwdlen; - context.salt = CONST_CAST(uint8_t *)salt; - context.saltlen = (uint32_t)saltlen; - context.secret = NULL; - context.secretlen = 0; - context.ad = NULL; - context.adlen = 0; - context.t_cost = t_cost; - context.m_cost = m_cost; - context.lanes = parallelism; - context.threads = parallelism; - context.allocate_cbk = NULL; - context.free_cbk = NULL; - context.flags = ARGON2_DEFAULT_FLAGS; - context.version = version; - - result = argon2_ctx(&context, type); - - if (result != ARGON2_OK) { - clear_internal_memory(out, hashlen); - free(out); - return result; - } - - /* if raw hash requested, write it */ - if (hash) { - memcpy(hash, out, hashlen); - } - - /* if encoding requested, write it */ - if (encoded && encodedlen) { - if (encode_string(encoded, encodedlen, &context, type) != ARGON2_OK) { - clear_internal_memory(out, hashlen); /* wipe buffers if error */ - clear_internal_memory(encoded, encodedlen); - free(out); - return ARGON2_ENCODING_FAIL; - } - } - clear_internal_memory(out, hashlen); - free(out); - - return ARGON2_OK; -} - -int argon2i_hash_encoded(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, const size_t hashlen, - char *encoded, const size_t encodedlen) { - - return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, - NULL, hashlen, encoded, encodedlen, Argon2_i, - ARGON2_VERSION_NUMBER); -} - -int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, void *hash, const size_t hashlen) { - - return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, - hash, hashlen, NULL, 0, Argon2_i, ARGON2_VERSION_NUMBER); -} - -int argon2d_hash_encoded(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, const size_t hashlen, - char *encoded, const size_t encodedlen) { - - return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, - NULL, hashlen, encoded, encodedlen, Argon2_d, - ARGON2_VERSION_NUMBER); -} - -int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, void *hash, const size_t hashlen) { - - return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, - hash, hashlen, NULL, 0, Argon2_d, ARGON2_VERSION_NUMBER); -} - -int argon2id_hash_encoded(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, const size_t hashlen, - char *encoded, const size_t encodedlen) { - - return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, - NULL, hashlen, encoded, encodedlen, Argon2_id, - ARGON2_VERSION_NUMBER); -} - -int argon2id_hash_raw(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, void *hash, const size_t hashlen) { - return argon2_hash(t_cost, m_cost, parallelism, pwd, pwdlen, salt, saltlen, - hash, hashlen, NULL, 0, Argon2_id, - ARGON2_VERSION_NUMBER); -} - -static int argon2_compare(const uint8_t *b1, const uint8_t *b2, size_t len) { - size_t i; - uint8_t d = 0U; - - for (i = 0U; i < len; i++) { - d |= b1[i] ^ b2[i]; - } - return (int)((1 & ((d - 1) >> 8)) - 1); -} - -int argon2_verify(const char *encoded, const void *pwd, const size_t pwdlen, - argon2_type type) { - - argon2_context ctx; - uint8_t *desired_result = NULL; - - int ret = ARGON2_OK; - - size_t encoded_len; - uint32_t max_field_len; - - if (pwdlen > ARGON2_MAX_PWD_LENGTH) { - return ARGON2_PWD_TOO_LONG; - } - - if (encoded == NULL) { - return ARGON2_DECODING_FAIL; - } - - encoded_len = strlen(encoded); - if (encoded_len > UINT32_MAX) { - return ARGON2_DECODING_FAIL; - } - - /* No field can be longer than the encoded length */ - max_field_len = (uint32_t)encoded_len; - - ctx.saltlen = max_field_len; - ctx.outlen = max_field_len; - - ctx.salt = malloc(ctx.saltlen); - ctx.out = malloc(ctx.outlen); - if (!ctx.salt || !ctx.out) { - ret = ARGON2_MEMORY_ALLOCATION_ERROR; - goto fail; - } - - ctx.pwd = (uint8_t *)pwd; - ctx.pwdlen = (uint32_t)pwdlen; - - ret = decode_string(&ctx, encoded, type); - if (ret != ARGON2_OK) { - goto fail; - } - - /* Set aside the desired result, and get a new buffer. */ - desired_result = ctx.out; - ctx.out = malloc(ctx.outlen); - if (!ctx.out) { - ret = ARGON2_MEMORY_ALLOCATION_ERROR; - goto fail; - } - - ret = argon2_verify_ctx(&ctx, (char *)desired_result, type); - if (ret != ARGON2_OK) { - goto fail; - } - -fail: - free(ctx.salt); - free(ctx.out); - free(desired_result); - - return ret; -} - -int argon2i_verify(const char *encoded, const void *pwd, const size_t pwdlen) { - - return argon2_verify(encoded, pwd, pwdlen, Argon2_i); -} - -int argon2d_verify(const char *encoded, const void *pwd, const size_t pwdlen) { - - return argon2_verify(encoded, pwd, pwdlen, Argon2_d); -} - -int argon2id_verify(const char *encoded, const void *pwd, const size_t pwdlen) { - - return argon2_verify(encoded, pwd, pwdlen, Argon2_id); -} - -int argon2d_ctx(argon2_context *context) { - return argon2_ctx(context, Argon2_d); -} - -int argon2i_ctx(argon2_context *context) { - return argon2_ctx(context, Argon2_i); -} - -int argon2id_ctx(argon2_context *context) { - return argon2_ctx(context, Argon2_id); -} - -int argon2_verify_ctx(argon2_context *context, const char *hash, - argon2_type type) { - int ret = argon2_ctx(context, type); - if (ret != ARGON2_OK) { - return ret; - } - - if (argon2_compare((uint8_t *)hash, context->out, context->outlen)) { - return ARGON2_VERIFY_MISMATCH; - } - - return ARGON2_OK; -} - -int argon2d_verify_ctx(argon2_context *context, const char *hash) { - return argon2_verify_ctx(context, hash, Argon2_d); -} - -int argon2i_verify_ctx(argon2_context *context, const char *hash) { - return argon2_verify_ctx(context, hash, Argon2_i); -} - -int argon2id_verify_ctx(argon2_context *context, const char *hash) { - return argon2_verify_ctx(context, hash, Argon2_id); -} - -const char *argon2_error_message(int error_code) { - switch (error_code) { - case ARGON2_OK: - return "OK"; - case ARGON2_OUTPUT_PTR_NULL: - return "Output pointer is NULL"; - case ARGON2_OUTPUT_TOO_SHORT: - return "Output is too short"; - case ARGON2_OUTPUT_TOO_LONG: - return "Output is too long"; - case ARGON2_PWD_TOO_SHORT: - return "Password is too short"; - case ARGON2_PWD_TOO_LONG: - return "Password is too long"; - case ARGON2_SALT_TOO_SHORT: - return "Salt is too short"; - case ARGON2_SALT_TOO_LONG: - return "Salt is too long"; - case ARGON2_AD_TOO_SHORT: - return "Associated data is too short"; - case ARGON2_AD_TOO_LONG: - return "Associated data is too long"; - case ARGON2_SECRET_TOO_SHORT: - return "Secret is too short"; - case ARGON2_SECRET_TOO_LONG: - return "Secret is too long"; - case ARGON2_TIME_TOO_SMALL: - return "Time cost is too small"; - case ARGON2_TIME_TOO_LARGE: - return "Time cost is too large"; - case ARGON2_MEMORY_TOO_LITTLE: - return "Memory cost is too small"; - case ARGON2_MEMORY_TOO_MUCH: - return "Memory cost is too large"; - case ARGON2_LANES_TOO_FEW: - return "Too few lanes"; - case ARGON2_LANES_TOO_MANY: - return "Too many lanes"; - case ARGON2_PWD_PTR_MISMATCH: - return "Password pointer is NULL, but password length is not 0"; - case ARGON2_SALT_PTR_MISMATCH: - return "Salt pointer is NULL, but salt length is not 0"; - case ARGON2_SECRET_PTR_MISMATCH: - return "Secret pointer is NULL, but secret length is not 0"; - case ARGON2_AD_PTR_MISMATCH: - return "Associated data pointer is NULL, but ad length is not 0"; - case ARGON2_MEMORY_ALLOCATION_ERROR: - return "Memory allocation error"; - case ARGON2_FREE_MEMORY_CBK_NULL: - return "The free memory callback is NULL"; - case ARGON2_ALLOCATE_MEMORY_CBK_NULL: - return "The allocate memory callback is NULL"; - case ARGON2_INCORRECT_PARAMETER: - return "Argon2_Context context is NULL"; - case ARGON2_INCORRECT_TYPE: - return "There is no such version of Argon2"; - case ARGON2_OUT_PTR_MISMATCH: - return "Output pointer mismatch"; - case ARGON2_THREADS_TOO_FEW: - return "Not enough threads"; - case ARGON2_THREADS_TOO_MANY: - return "Too many threads"; - case ARGON2_MISSING_ARGS: - return "Missing arguments"; - case ARGON2_ENCODING_FAIL: - return "Encoding failed"; - case ARGON2_DECODING_FAIL: - return "Decoding failed"; - case ARGON2_THREAD_FAIL: - return "Threading failure"; - case ARGON2_DECODING_LENGTH_FAIL: - return "Some of encoded parameters are too long or too short"; - case ARGON2_VERIFY_MISMATCH: - return "The password does not match the supplied hash"; - default: - return "Unknown error code"; - } -} - -size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, uint32_t parallelism, - uint32_t saltlen, uint32_t hashlen, argon2_type type) { - return strlen("$$v=$m=,t=,p=$$") + strlen(argon2_type2string(type, 0)) + - numlen(t_cost) + numlen(m_cost) + numlen(parallelism) + - b64len(saltlen) + b64len(hashlen) + numlen(ARGON2_VERSION_NUMBER) + 1; -} diff --git a/deps/argon2/argon2/argon2.h b/deps/argon2/argon2/argon2.h deleted file mode 100644 index fc8682c2db..0000000000 --- a/deps/argon2/argon2/argon2.h +++ /dev/null @@ -1,437 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef ARGON2_H -#define ARGON2_H - -#include -#include -#include - -#if defined(__cplusplus) -extern "C" { -#endif - -/* Symbols visibility control */ -#ifdef A2_VISCTL -#define ARGON2_PUBLIC __attribute__((visibility("default"))) -#define ARGON2_LOCAL __attribute__ ((visibility ("hidden"))) -#elif _MSC_VER -#define ARGON2_PUBLIC __declspec(dllexport) -#define ARGON2_LOCAL -#else -#define ARGON2_PUBLIC -#define ARGON2_LOCAL -#endif - -/* - * Argon2 input parameter restrictions - */ - -/* Minimum and maximum number of lanes (degree of parallelism) */ -#define ARGON2_MIN_LANES UINT32_C(1) -#define ARGON2_MAX_LANES UINT32_C(0xFFFFFF) - -/* Minimum and maximum number of threads */ -#define ARGON2_MIN_THREADS UINT32_C(1) -#define ARGON2_MAX_THREADS UINT32_C(0xFFFFFF) - -/* Number of synchronization points between lanes per pass */ -#define ARGON2_SYNC_POINTS UINT32_C(4) - -/* Minimum and maximum digest size in bytes */ -#define ARGON2_MIN_OUTLEN UINT32_C(4) -#define ARGON2_MAX_OUTLEN UINT32_C(0xFFFFFFFF) - -/* Minimum and maximum number of memory blocks (each of BLOCK_SIZE bytes) */ -#define ARGON2_MIN_MEMORY (2 * ARGON2_SYNC_POINTS) /* 2 blocks per slice */ - -#define ARGON2_MIN(a, b) ((a) < (b) ? (a) : (b)) -/* Max memory size is addressing-space/2, topping at 2^32 blocks (4 TB) */ -#define ARGON2_MAX_MEMORY_BITS \ - ARGON2_MIN(UINT32_C(32), (sizeof(void *) * CHAR_BIT - 10 - 1)) -#define ARGON2_MAX_MEMORY \ - ARGON2_MIN(UINT32_C(0xFFFFFFFF), UINT64_C(1) << ARGON2_MAX_MEMORY_BITS) - -/* Minimum and maximum number of passes */ -#define ARGON2_MIN_TIME UINT32_C(1) -#define ARGON2_MAX_TIME UINT32_C(0xFFFFFFFF) - -/* Minimum and maximum password length in bytes */ -#define ARGON2_MIN_PWD_LENGTH UINT32_C(0) -#define ARGON2_MAX_PWD_LENGTH UINT32_C(0xFFFFFFFF) - -/* Minimum and maximum associated data length in bytes */ -#define ARGON2_MIN_AD_LENGTH UINT32_C(0) -#define ARGON2_MAX_AD_LENGTH UINT32_C(0xFFFFFFFF) - -/* Minimum and maximum salt length in bytes */ -#define ARGON2_MIN_SALT_LENGTH UINT32_C(8) -#define ARGON2_MAX_SALT_LENGTH UINT32_C(0xFFFFFFFF) - -/* Minimum and maximum key length in bytes */ -#define ARGON2_MIN_SECRET UINT32_C(0) -#define ARGON2_MAX_SECRET UINT32_C(0xFFFFFFFF) - -/* Flags to determine which fields are securely wiped (default = no wipe). */ -#define ARGON2_DEFAULT_FLAGS UINT32_C(0) -#define ARGON2_FLAG_CLEAR_PASSWORD (UINT32_C(1) << 0) -#define ARGON2_FLAG_CLEAR_SECRET (UINT32_C(1) << 1) - -/* Global flag to determine if we are wiping internal memory buffers. This flag - * is defined in core.c and defaults to 1 (wipe internal memory). */ -extern int FLAG_clear_internal_memory; - -/* Error codes */ -typedef enum Argon2_ErrorCodes { - ARGON2_OK = 0, - - ARGON2_OUTPUT_PTR_NULL = -1, - - ARGON2_OUTPUT_TOO_SHORT = -2, - ARGON2_OUTPUT_TOO_LONG = -3, - - ARGON2_PWD_TOO_SHORT = -4, - ARGON2_PWD_TOO_LONG = -5, - - ARGON2_SALT_TOO_SHORT = -6, - ARGON2_SALT_TOO_LONG = -7, - - ARGON2_AD_TOO_SHORT = -8, - ARGON2_AD_TOO_LONG = -9, - - ARGON2_SECRET_TOO_SHORT = -10, - ARGON2_SECRET_TOO_LONG = -11, - - ARGON2_TIME_TOO_SMALL = -12, - ARGON2_TIME_TOO_LARGE = -13, - - ARGON2_MEMORY_TOO_LITTLE = -14, - ARGON2_MEMORY_TOO_MUCH = -15, - - ARGON2_LANES_TOO_FEW = -16, - ARGON2_LANES_TOO_MANY = -17, - - ARGON2_PWD_PTR_MISMATCH = -18, /* NULL ptr with non-zero length */ - ARGON2_SALT_PTR_MISMATCH = -19, /* NULL ptr with non-zero length */ - ARGON2_SECRET_PTR_MISMATCH = -20, /* NULL ptr with non-zero length */ - ARGON2_AD_PTR_MISMATCH = -21, /* NULL ptr with non-zero length */ - - ARGON2_MEMORY_ALLOCATION_ERROR = -22, - - ARGON2_FREE_MEMORY_CBK_NULL = -23, - ARGON2_ALLOCATE_MEMORY_CBK_NULL = -24, - - ARGON2_INCORRECT_PARAMETER = -25, - ARGON2_INCORRECT_TYPE = -26, - - ARGON2_OUT_PTR_MISMATCH = -27, - - ARGON2_THREADS_TOO_FEW = -28, - ARGON2_THREADS_TOO_MANY = -29, - - ARGON2_MISSING_ARGS = -30, - - ARGON2_ENCODING_FAIL = -31, - - ARGON2_DECODING_FAIL = -32, - - ARGON2_THREAD_FAIL = -33, - - ARGON2_DECODING_LENGTH_FAIL = -34, - - ARGON2_VERIFY_MISMATCH = -35 -} argon2_error_codes; - -/* Memory allocator types --- for external allocation */ -typedef int (*allocate_fptr)(uint8_t **memory, size_t bytes_to_allocate); -typedef void (*deallocate_fptr)(uint8_t *memory, size_t bytes_to_allocate); - -/* Argon2 external data structures */ - -/* - ***** - * Context: structure to hold Argon2 inputs: - * output array and its length, - * password and its length, - * salt and its length, - * secret and its length, - * associated data and its length, - * number of passes, amount of used memory (in KBytes, can be rounded up a bit) - * number of parallel threads that will be run. - * All the parameters above affect the output hash value. - * Additionally, two function pointers can be provided to allocate and - * deallocate the memory (if NULL, memory will be allocated internally). - * Also, three flags indicate whether to erase password, secret as soon as they - * are pre-hashed (and thus not needed anymore), and the entire memory - ***** - * Simplest situation: you have output array out[8], password is stored in - * pwd[32], salt is stored in salt[16], you do not have keys nor associated - * data. You need to spend 1 GB of RAM and you run 5 passes of Argon2d with - * 4 parallel lanes. - * You want to erase the password, but you're OK with last pass not being - * erased. You want to use the default memory allocator. - * Then you initialize: - Argon2_Context(out,8,pwd,32,salt,16,NULL,0,NULL,0,5,1<<20,4,4,NULL,NULL,true,false,false,false) - */ -typedef struct Argon2_Context { - uint8_t *out; /* output array */ - uint32_t outlen; /* digest length */ - - uint8_t *pwd; /* password array */ - uint32_t pwdlen; /* password length */ - - uint8_t *salt; /* salt array */ - uint32_t saltlen; /* salt length */ - - uint8_t *secret; /* key array */ - uint32_t secretlen; /* key length */ - - uint8_t *ad; /* associated data array */ - uint32_t adlen; /* associated data length */ - - uint32_t t_cost; /* number of passes */ - uint32_t m_cost; /* amount of memory requested (KB) */ - uint32_t lanes; /* number of lanes */ - uint32_t threads; /* maximum number of threads */ - - uint32_t version; /* version number */ - - allocate_fptr allocate_cbk; /* pointer to memory allocator */ - deallocate_fptr free_cbk; /* pointer to memory deallocator */ - - uint32_t flags; /* array of bool options */ -} argon2_context; - -/* Argon2 primitive type */ -typedef enum Argon2_type { - Argon2_d = 0, - Argon2_i = 1, - Argon2_id = 2 -} argon2_type; - -/* Version of the algorithm */ -typedef enum Argon2_version { - ARGON2_VERSION_10 = 0x10, - ARGON2_VERSION_13 = 0x13, - ARGON2_VERSION_NUMBER = ARGON2_VERSION_13 -} argon2_version; - -/* - * Function that gives the string representation of an argon2_type. - * @param type The argon2_type that we want the string for - * @param uppercase Whether the string should have the first letter uppercase - * @return NULL if invalid type, otherwise the string representation. - */ -ARGON2_PUBLIC const char *argon2_type2string(argon2_type type, int uppercase); - -/* - * Function that performs memory-hard hashing with certain degree of parallelism - * @param context Pointer to the Argon2 internal structure - * @return Error code if smth is wrong, ARGON2_OK otherwise - */ -ARGON2_PUBLIC int argon2_ctx(argon2_context *context, argon2_type type); - -/** - * Hashes a password with Argon2i, producing an encoded hash - * @param t_cost Number of iterations - * @param m_cost Sets memory usage to m_cost kibibytes - * @param parallelism Number of threads and compute lanes - * @param pwd Pointer to password - * @param pwdlen Password size in bytes - * @param salt Pointer to salt - * @param saltlen Salt size in bytes - * @param hashlen Desired length of the hash in bytes - * @param encoded Buffer where to write the encoded hash - * @param encodedlen Size of the buffer (thus max size of the encoded hash) - * @pre Different parallelism levels will give different results - * @pre Returns ARGON2_OK if successful - */ -ARGON2_PUBLIC int argon2i_hash_encoded(const uint32_t t_cost, - const uint32_t m_cost, - const uint32_t parallelism, - const void *pwd, const size_t pwdlen, - const void *salt, const size_t saltlen, - const size_t hashlen, char *encoded, - const size_t encodedlen); - -/** - * Hashes a password with Argon2i, producing a raw hash at @hash - * @param t_cost Number of iterations - * @param m_cost Sets memory usage to m_cost kibibytes - * @param parallelism Number of threads and compute lanes - * @param pwd Pointer to password - * @param pwdlen Password size in bytes - * @param salt Pointer to salt - * @param saltlen Salt size in bytes - * @param hash Buffer where to write the raw hash - updated by the function - * @param hashlen Desired length of the hash in bytes - * @pre Different parallelism levels will give different results - * @pre Returns ARGON2_OK if successful - */ -ARGON2_PUBLIC int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, void *hash, - const size_t hashlen); - -ARGON2_PUBLIC int argon2d_hash_encoded(const uint32_t t_cost, - const uint32_t m_cost, - const uint32_t parallelism, - const void *pwd, const size_t pwdlen, - const void *salt, const size_t saltlen, - const size_t hashlen, char *encoded, - const size_t encodedlen); - -ARGON2_PUBLIC int argon2d_hash_raw(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, void *hash, - const size_t hashlen); - -ARGON2_PUBLIC int argon2id_hash_encoded(const uint32_t t_cost, - const uint32_t m_cost, - const uint32_t parallelism, - const void *pwd, const size_t pwdlen, - const void *salt, const size_t saltlen, - const size_t hashlen, char *encoded, - const size_t encodedlen); - -ARGON2_PUBLIC int argon2id_hash_raw(const uint32_t t_cost, - const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, void *hash, - const size_t hashlen); - -/* generic function underlying the above ones */ -ARGON2_PUBLIC int argon2_hash(const uint32_t t_cost, const uint32_t m_cost, - const uint32_t parallelism, const void *pwd, - const size_t pwdlen, const void *salt, - const size_t saltlen, void *hash, - const size_t hashlen, char *encoded, - const size_t encodedlen, argon2_type type, - const uint32_t version); - -/** - * Verifies a password against an encoded string - * Encoded string is restricted as in validate_inputs() - * @param encoded String encoding parameters, salt, hash - * @param pwd Pointer to password - * @pre Returns ARGON2_OK if successful - */ -ARGON2_PUBLIC int argon2i_verify(const char *encoded, const void *pwd, - const size_t pwdlen); - -ARGON2_PUBLIC int argon2d_verify(const char *encoded, const void *pwd, - const size_t pwdlen); - -ARGON2_PUBLIC int argon2id_verify(const char *encoded, const void *pwd, - const size_t pwdlen); - -/* generic function underlying the above ones */ -ARGON2_PUBLIC int argon2_verify(const char *encoded, const void *pwd, - const size_t pwdlen, argon2_type type); - -/** - * Argon2d: Version of Argon2 that picks memory blocks depending - * on the password and salt. Only for side-channel-free - * environment!! - ***** - * @param context Pointer to current Argon2 context - * @return Zero if successful, a non zero error code otherwise - */ -ARGON2_PUBLIC int argon2d_ctx(argon2_context *context); - -/** - * Argon2i: Version of Argon2 that picks memory blocks - * independent on the password and salt. Good for side-channels, - * but worse w.r.t. tradeoff attacks if only one pass is used. - ***** - * @param context Pointer to current Argon2 context - * @return Zero if successful, a non zero error code otherwise - */ -ARGON2_PUBLIC int argon2i_ctx(argon2_context *context); - -/** - * Argon2id: Version of Argon2 where the first half-pass over memory is - * password-independent, the rest are password-dependent (on the password and - * salt). OK against side channels (they reduce to 1/2-pass Argon2i), and - * better with w.r.t. tradeoff attacks (similar to Argon2d). - ***** - * @param context Pointer to current Argon2 context - * @return Zero if successful, a non zero error code otherwise - */ -ARGON2_PUBLIC int argon2id_ctx(argon2_context *context); - -/** - * Verify if a given password is correct for Argon2d hashing - * @param context Pointer to current Argon2 context - * @param hash The password hash to verify. The length of the hash is - * specified by the context outlen member - * @return Zero if successful, a non zero error code otherwise - */ -ARGON2_PUBLIC int argon2d_verify_ctx(argon2_context *context, const char *hash); - -/** - * Verify if a given password is correct for Argon2i hashing - * @param context Pointer to current Argon2 context - * @param hash The password hash to verify. The length of the hash is - * specified by the context outlen member - * @return Zero if successful, a non zero error code otherwise - */ -ARGON2_PUBLIC int argon2i_verify_ctx(argon2_context *context, const char *hash); - -/** - * Verify if a given password is correct for Argon2id hashing - * @param context Pointer to current Argon2 context - * @param hash The password hash to verify. The length of the hash is - * specified by the context outlen member - * @return Zero if successful, a non zero error code otherwise - */ -ARGON2_PUBLIC int argon2id_verify_ctx(argon2_context *context, - const char *hash); - -/* generic function underlying the above ones */ -ARGON2_PUBLIC int argon2_verify_ctx(argon2_context *context, const char *hash, - argon2_type type); - -/** - * Get the associated error message for given error code - * @return The error message associated with the given error code - */ -ARGON2_PUBLIC const char *argon2_error_message(int error_code); - -/** - * Returns the encoded hash length for the given input parameters - * @param t_cost Number of iterations - * @param m_cost Memory usage in kibibytes - * @param parallelism Number of threads; used to compute lanes - * @param saltlen Salt size in bytes - * @param hashlen Hash size in bytes - * @param type The argon2_type that we want the encoded length for - * @return The encoded hash length in bytes - */ -ARGON2_PUBLIC size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, - uint32_t parallelism, uint32_t saltlen, - uint32_t hashlen, argon2_type type); - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/deps/argon2/argon2/blake2/blake2-impl.h b/deps/argon2/argon2/blake2/blake2-impl.h deleted file mode 100644 index 241f0beb3b..0000000000 --- a/deps/argon2/argon2/blake2/blake2-impl.h +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef PORTABLE_BLAKE2_IMPL_H -#define PORTABLE_BLAKE2_IMPL_H - -#include -#include - -#if defined(_MSC_VER) -#define BLAKE2_INLINE __inline -#elif defined(__GNUC__) || defined(__clang__) -#define BLAKE2_INLINE __inline__ -#else -#define BLAKE2_INLINE -#endif - -/* Argon2 Team - Begin Code */ -/* - Not an exhaustive list, but should cover the majority of modern platforms - Additionally, the code will always be correct---this is only a performance - tweak. -*/ -#if (defined(__BYTE_ORDER__) && \ - (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) || \ - defined(__LITTLE_ENDIAN__) || defined(__ARMEL__) || defined(__MIPSEL__) || \ - defined(__AARCH64EL__) || defined(__amd64__) || defined(__i386__) || \ - defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || \ - defined(_M_ARM) -#define NATIVE_LITTLE_ENDIAN -#endif -/* Argon2 Team - End Code */ - -static BLAKE2_INLINE uint32_t load32(const void *src) { -#if defined(NATIVE_LITTLE_ENDIAN) - uint32_t w; - memcpy(&w, src, sizeof w); - return w; -#else - const uint8_t *p = (const uint8_t *)src; - uint32_t w = *p++; - w |= (uint32_t)(*p++) << 8; - w |= (uint32_t)(*p++) << 16; - w |= (uint32_t)(*p++) << 24; - return w; -#endif -} - -static BLAKE2_INLINE uint64_t load64(const void *src) { -#if defined(NATIVE_LITTLE_ENDIAN) - uint64_t w; - memcpy(&w, src, sizeof w); - return w; -#else - const uint8_t *p = (const uint8_t *)src; - uint64_t w = *p++; - w |= (uint64_t)(*p++) << 8; - w |= (uint64_t)(*p++) << 16; - w |= (uint64_t)(*p++) << 24; - w |= (uint64_t)(*p++) << 32; - w |= (uint64_t)(*p++) << 40; - w |= (uint64_t)(*p++) << 48; - w |= (uint64_t)(*p++) << 56; - return w; -#endif -} - -static BLAKE2_INLINE void store32(void *dst, uint32_t w) { -#if defined(NATIVE_LITTLE_ENDIAN) - memcpy(dst, &w, sizeof w); -#else - uint8_t *p = (uint8_t *)dst; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; -#endif -} - -static BLAKE2_INLINE void store64(void *dst, uint64_t w) { -#if defined(NATIVE_LITTLE_ENDIAN) - memcpy(dst, &w, sizeof w); -#else - uint8_t *p = (uint8_t *)dst; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; -#endif -} - -static BLAKE2_INLINE uint64_t load48(const void *src) { - const uint8_t *p = (const uint8_t *)src; - uint64_t w = *p++; - w |= (uint64_t)(*p++) << 8; - w |= (uint64_t)(*p++) << 16; - w |= (uint64_t)(*p++) << 24; - w |= (uint64_t)(*p++) << 32; - w |= (uint64_t)(*p++) << 40; - return w; -} - -static BLAKE2_INLINE void store48(void *dst, uint64_t w) { - uint8_t *p = (uint8_t *)dst; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; - w >>= 8; - *p++ = (uint8_t)w; -} - -static BLAKE2_INLINE uint32_t rotr32(const uint32_t w, const unsigned c) { - return (w >> c) | (w << (32 - c)); -} - -static BLAKE2_INLINE uint64_t rotr64(const uint64_t w, const unsigned c) { - return (w >> c) | (w << (64 - c)); -} - -void clear_internal_memory(void *v, size_t n); - -#endif diff --git a/deps/argon2/argon2/blake2/blake2.h b/deps/argon2/argon2/blake2/blake2.h deleted file mode 100644 index 9f97e1c1b3..0000000000 --- a/deps/argon2/argon2/blake2/blake2.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef PORTABLE_BLAKE2_H -#define PORTABLE_BLAKE2_H - -#include "../argon2.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -enum blake2b_constant { - BLAKE2B_BLOCKBYTES = 128, - BLAKE2B_OUTBYTES = 64, - BLAKE2B_KEYBYTES = 64, - BLAKE2B_SALTBYTES = 16, - BLAKE2B_PERSONALBYTES = 16 -}; - -#pragma pack(push, 1) -typedef struct __blake2b_param { - uint8_t digest_length; /* 1 */ - uint8_t key_length; /* 2 */ - uint8_t fanout; /* 3 */ - uint8_t depth; /* 4 */ - uint32_t leaf_length; /* 8 */ - uint64_t node_offset; /* 16 */ - uint8_t node_depth; /* 17 */ - uint8_t inner_length; /* 18 */ - uint8_t reserved[14]; /* 32 */ - uint8_t salt[BLAKE2B_SALTBYTES]; /* 48 */ - uint8_t personal[BLAKE2B_PERSONALBYTES]; /* 64 */ -} blake2b_param; -#pragma pack(pop) - -typedef struct __blake2b_state { - uint64_t h[8]; - uint64_t t[2]; - uint64_t f[2]; - uint8_t buf[BLAKE2B_BLOCKBYTES]; - unsigned buflen; - unsigned outlen; - uint8_t last_node; -} blake2b_state; - -/* Ensure param structs have not been wrongly padded */ -/* Poor man's static_assert */ -enum { - blake2_size_check_0 = 1 / !!(CHAR_BIT == 8), - blake2_size_check_2 = - 1 / !!(sizeof(blake2b_param) == sizeof(uint64_t) * CHAR_BIT) -}; - -/* Streaming API */ -ARGON2_LOCAL int blake2b_init(blake2b_state *S, size_t outlen); -ARGON2_LOCAL int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, - size_t keylen); -ARGON2_LOCAL int blake2b_init_param(blake2b_state *S, const blake2b_param *P); -ARGON2_LOCAL int blake2b_update(blake2b_state *S, const void *in, size_t inlen); -ARGON2_LOCAL int blake2b_final(blake2b_state *S, void *out, size_t outlen); - -/* Simple API */ -ARGON2_LOCAL int blake2b(void *out, size_t outlen, const void *in, size_t inlen, - const void *key, size_t keylen); - -/* Argon2 Team - Begin Code */ -ARGON2_LOCAL int blake2b_long(void *out, size_t outlen, const void *in, size_t inlen); -/* Argon2 Team - End Code */ - -#if defined(__cplusplus) -} -#endif - -#endif diff --git a/deps/argon2/argon2/blake2/blake2b.c b/deps/argon2/argon2/blake2/blake2b.c deleted file mode 100644 index ca05df598d..0000000000 --- a/deps/argon2/argon2/blake2/blake2b.c +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include - -#include "blake2.h" -#include "blake2-impl.h" - -static const uint64_t blake2b_IV[8] = { - UINT64_C(0x6a09e667f3bcc908), UINT64_C(0xbb67ae8584caa73b), - UINT64_C(0x3c6ef372fe94f82b), UINT64_C(0xa54ff53a5f1d36f1), - UINT64_C(0x510e527fade682d1), UINT64_C(0x9b05688c2b3e6c1f), - UINT64_C(0x1f83d9abfb41bd6b), UINT64_C(0x5be0cd19137e2179)}; - -static const unsigned int blake2b_sigma[12][16] = { - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3}, - {11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4}, - {7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8}, - {9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13}, - {2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9}, - {12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11}, - {13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10}, - {6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5}, - {10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3}, -}; - -static BLAKE2_INLINE void blake2b_set_lastnode(blake2b_state *S) { - S->f[1] = (uint64_t)-1; -} - -static BLAKE2_INLINE void blake2b_set_lastblock(blake2b_state *S) { - if (S->last_node) { - blake2b_set_lastnode(S); - } - S->f[0] = (uint64_t)-1; -} - -static BLAKE2_INLINE void blake2b_increment_counter(blake2b_state *S, - uint64_t inc) { - S->t[0] += inc; - S->t[1] += (S->t[0] < inc); -} - -static BLAKE2_INLINE void blake2b_invalidate_state(blake2b_state *S) { - clear_internal_memory(S, sizeof(*S)); /* wipe */ - blake2b_set_lastblock(S); /* invalidate for further use */ -} - -static BLAKE2_INLINE void blake2b_init0(blake2b_state *S) { - memset(S, 0, sizeof(*S)); - memcpy(S->h, blake2b_IV, sizeof(S->h)); -} - -int blake2b_init_param(blake2b_state *S, const blake2b_param *P) { - const unsigned char *p = (const unsigned char *)P; - unsigned int i; - - if (NULL == P || NULL == S) { - return -1; - } - - blake2b_init0(S); - /* IV XOR Parameter Block */ - for (i = 0; i < 8; ++i) { - S->h[i] ^= load64(&p[i * sizeof(S->h[i])]); - } - S->outlen = P->digest_length; - return 0; -} - -/* Sequential blake2b initialization */ -int blake2b_init(blake2b_state *S, size_t outlen) { - blake2b_param P; - - if (S == NULL) { - return -1; - } - - if ((outlen == 0) || (outlen > BLAKE2B_OUTBYTES)) { - blake2b_invalidate_state(S); - return -1; - } - - /* Setup Parameter Block for unkeyed BLAKE2 */ - P.digest_length = (uint8_t)outlen; - P.key_length = 0; - P.fanout = 1; - P.depth = 1; - P.leaf_length = 0; - P.node_offset = 0; - P.node_depth = 0; - P.inner_length = 0; - memset(P.reserved, 0, sizeof(P.reserved)); - memset(P.salt, 0, sizeof(P.salt)); - memset(P.personal, 0, sizeof(P.personal)); - - return blake2b_init_param(S, &P); -} - -int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, - size_t keylen) { - blake2b_param P; - - if (S == NULL) { - return -1; - } - - if ((outlen == 0) || (outlen > BLAKE2B_OUTBYTES)) { - blake2b_invalidate_state(S); - return -1; - } - - if ((key == 0) || (keylen == 0) || (keylen > BLAKE2B_KEYBYTES)) { - blake2b_invalidate_state(S); - return -1; - } - - /* Setup Parameter Block for keyed BLAKE2 */ - P.digest_length = (uint8_t)outlen; - P.key_length = (uint8_t)keylen; - P.fanout = 1; - P.depth = 1; - P.leaf_length = 0; - P.node_offset = 0; - P.node_depth = 0; - P.inner_length = 0; - memset(P.reserved, 0, sizeof(P.reserved)); - memset(P.salt, 0, sizeof(P.salt)); - memset(P.personal, 0, sizeof(P.personal)); - - if (blake2b_init_param(S, &P) < 0) { - blake2b_invalidate_state(S); - return -1; - } - - { - uint8_t block[BLAKE2B_BLOCKBYTES]; - memset(block, 0, BLAKE2B_BLOCKBYTES); - memcpy(block, key, keylen); - blake2b_update(S, block, BLAKE2B_BLOCKBYTES); - /* Burn the key from stack */ - clear_internal_memory(block, BLAKE2B_BLOCKBYTES); - } - return 0; -} - -static void blake2b_compress(blake2b_state *S, const uint8_t *block) { - uint64_t m[16]; - uint64_t v[16]; - unsigned int i, r; - - for (i = 0; i < 16; ++i) { - m[i] = load64(block + i * sizeof(m[i])); - } - - for (i = 0; i < 8; ++i) { - v[i] = S->h[i]; - } - - v[8] = blake2b_IV[0]; - v[9] = blake2b_IV[1]; - v[10] = blake2b_IV[2]; - v[11] = blake2b_IV[3]; - v[12] = blake2b_IV[4] ^ S->t[0]; - v[13] = blake2b_IV[5] ^ S->t[1]; - v[14] = blake2b_IV[6] ^ S->f[0]; - v[15] = blake2b_IV[7] ^ S->f[1]; - -#define G(r, i, a, b, c, d) \ - do { \ - a = a + b + m[blake2b_sigma[r][2 * i + 0]]; \ - d = rotr64(d ^ a, 32); \ - c = c + d; \ - b = rotr64(b ^ c, 24); \ - a = a + b + m[blake2b_sigma[r][2 * i + 1]]; \ - d = rotr64(d ^ a, 16); \ - c = c + d; \ - b = rotr64(b ^ c, 63); \ - } while ((void)0, 0) - -#define ROUND(r) \ - do { \ - G(r, 0, v[0], v[4], v[8], v[12]); \ - G(r, 1, v[1], v[5], v[9], v[13]); \ - G(r, 2, v[2], v[6], v[10], v[14]); \ - G(r, 3, v[3], v[7], v[11], v[15]); \ - G(r, 4, v[0], v[5], v[10], v[15]); \ - G(r, 5, v[1], v[6], v[11], v[12]); \ - G(r, 6, v[2], v[7], v[8], v[13]); \ - G(r, 7, v[3], v[4], v[9], v[14]); \ - } while ((void)0, 0) - - for (r = 0; r < 12; ++r) { - ROUND(r); - } - - for (i = 0; i < 8; ++i) { - S->h[i] = S->h[i] ^ v[i] ^ v[i + 8]; - } - -#undef G -#undef ROUND -} - -int blake2b_update(blake2b_state *S, const void *in, size_t inlen) { - const uint8_t *pin = (const uint8_t *)in; - - if (inlen == 0) { - return 0; - } - - /* Sanity check */ - if (S == NULL || in == NULL) { - return -1; - } - - /* Is this a reused state? */ - if (S->f[0] != 0) { - return -1; - } - - if (S->buflen + inlen > BLAKE2B_BLOCKBYTES) { - /* Complete current block */ - size_t left = S->buflen; - size_t fill = BLAKE2B_BLOCKBYTES - left; - memcpy(&S->buf[left], pin, fill); - blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); - blake2b_compress(S, S->buf); - S->buflen = 0; - inlen -= fill; - pin += fill; - /* Avoid buffer copies when possible */ - while (inlen > BLAKE2B_BLOCKBYTES) { - blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); - blake2b_compress(S, pin); - inlen -= BLAKE2B_BLOCKBYTES; - pin += BLAKE2B_BLOCKBYTES; - } - } - memcpy(&S->buf[S->buflen], pin, inlen); - S->buflen += (unsigned int)inlen; - return 0; -} - -int blake2b_final(blake2b_state *S, void *out, size_t outlen) { - uint8_t buffer[BLAKE2B_OUTBYTES] = {0}; - unsigned int i; - - /* Sanity checks */ - if (S == NULL || out == NULL || outlen < S->outlen) { - return -1; - } - - /* Is this a reused state? */ - if (S->f[0] != 0) { - return -1; - } - - blake2b_increment_counter(S, S->buflen); - blake2b_set_lastblock(S); - memset(&S->buf[S->buflen], 0, BLAKE2B_BLOCKBYTES - S->buflen); /* Padding */ - blake2b_compress(S, S->buf); - - for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */ - store64(buffer + sizeof(S->h[i]) * i, S->h[i]); - } - - memcpy(out, buffer, S->outlen); - clear_internal_memory(buffer, sizeof(buffer)); - clear_internal_memory(S->buf, sizeof(S->buf)); - clear_internal_memory(S->h, sizeof(S->h)); - return 0; -} - -int blake2b(void *out, size_t outlen, const void *in, size_t inlen, - const void *key, size_t keylen) { - blake2b_state S; - int ret = -1; - - /* Verify parameters */ - if (NULL == in && inlen > 0) { - goto fail; - } - - if (NULL == out || outlen == 0 || outlen > BLAKE2B_OUTBYTES) { - goto fail; - } - - if ((NULL == key && keylen > 0) || keylen > BLAKE2B_KEYBYTES) { - goto fail; - } - - if (keylen > 0) { - if (blake2b_init_key(&S, outlen, key, keylen) < 0) { - goto fail; - } - } else { - if (blake2b_init(&S, outlen) < 0) { - goto fail; - } - } - - if (blake2b_update(&S, in, inlen) < 0) { - goto fail; - } - ret = blake2b_final(&S, out, outlen); - -fail: - clear_internal_memory(&S, sizeof(S)); - return ret; -} - -/* Argon2 Team - Begin Code */ -int blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) { - uint8_t *out = (uint8_t *)pout; - blake2b_state blake_state; - uint8_t outlen_bytes[sizeof(uint32_t)] = {0}; - int ret = -1; - - if (outlen > UINT32_MAX) { - goto fail; - } - - /* Ensure little-endian byte order! */ - store32(outlen_bytes, (uint32_t)outlen); - -#define TRY(statement) \ - do { \ - ret = statement; \ - if (ret < 0) { \ - goto fail; \ - } \ - } while ((void)0, 0) - - if (outlen <= BLAKE2B_OUTBYTES) { - TRY(blake2b_init(&blake_state, outlen)); - TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); - TRY(blake2b_update(&blake_state, in, inlen)); - TRY(blake2b_final(&blake_state, out, outlen)); - } else { - uint32_t toproduce; - uint8_t out_buffer[BLAKE2B_OUTBYTES]; - uint8_t in_buffer[BLAKE2B_OUTBYTES]; - TRY(blake2b_init(&blake_state, BLAKE2B_OUTBYTES)); - TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); - TRY(blake2b_update(&blake_state, in, inlen)); - TRY(blake2b_final(&blake_state, out_buffer, BLAKE2B_OUTBYTES)); - memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); - out += BLAKE2B_OUTBYTES / 2; - toproduce = (uint32_t)outlen - BLAKE2B_OUTBYTES / 2; - - while (toproduce > BLAKE2B_OUTBYTES) { - memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); - TRY(blake2b(out_buffer, BLAKE2B_OUTBYTES, in_buffer, - BLAKE2B_OUTBYTES, NULL, 0)); - memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); - out += BLAKE2B_OUTBYTES / 2; - toproduce -= BLAKE2B_OUTBYTES / 2; - } - - memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); - TRY(blake2b(out_buffer, toproduce, in_buffer, BLAKE2B_OUTBYTES, NULL, - 0)); - memcpy(out, out_buffer, toproduce); - } -fail: - clear_internal_memory(&blake_state, sizeof(blake_state)); - return ret; -#undef TRY -} -/* Argon2 Team - End Code */ diff --git a/deps/argon2/argon2/blake2/blamka-round-opt.h b/deps/argon2/argon2/blake2/blamka-round-opt.h deleted file mode 100644 index 2c8942e316..0000000000 --- a/deps/argon2/argon2/blake2/blamka-round-opt.h +++ /dev/null @@ -1,471 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef BLAKE_ROUND_MKA_OPT_H -#define BLAKE_ROUND_MKA_OPT_H - -#include "blake2-impl.h" - -#include -#if defined(__SSSE3__) -#include /* for _mm_shuffle_epi8 and _mm_alignr_epi8 */ -#endif - -#if defined(__XOP__) && (defined(__GNUC__) || defined(__clang__)) -#include -#endif - -#if !defined(__AVX512F__) -#if !defined(__AVX2__) -#if !defined(__XOP__) -#if defined(__SSSE3__) -#define r16 \ - (_mm_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9)) -#define r24 \ - (_mm_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10)) -#define _mm_roti_epi64(x, c) \ - (-(c) == 32) \ - ? _mm_shuffle_epi32((x), _MM_SHUFFLE(2, 3, 0, 1)) \ - : (-(c) == 24) \ - ? _mm_shuffle_epi8((x), r24) \ - : (-(c) == 16) \ - ? _mm_shuffle_epi8((x), r16) \ - : (-(c) == 63) \ - ? _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ - _mm_add_epi64((x), (x))) \ - : _mm_xor_si128(_mm_srli_epi64((x), -(c)), \ - _mm_slli_epi64((x), 64 - (-(c)))) -#else /* defined(__SSE2__) */ -#define _mm_roti_epi64(r, c) \ - _mm_xor_si128(_mm_srli_epi64((r), -(c)), _mm_slli_epi64((r), 64 - (-(c)))) -#endif -#else -#endif - -static BLAKE2_INLINE __m128i fBlaMka(__m128i x, __m128i y) { - const __m128i z = _mm_mul_epu32(x, y); - return _mm_add_epi64(_mm_add_epi64(x, y), _mm_add_epi64(z, z)); -} - -#define G1(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - A0 = fBlaMka(A0, B0); \ - A1 = fBlaMka(A1, B1); \ - \ - D0 = _mm_xor_si128(D0, A0); \ - D1 = _mm_xor_si128(D1, A1); \ - \ - D0 = _mm_roti_epi64(D0, -32); \ - D1 = _mm_roti_epi64(D1, -32); \ - \ - C0 = fBlaMka(C0, D0); \ - C1 = fBlaMka(C1, D1); \ - \ - B0 = _mm_xor_si128(B0, C0); \ - B1 = _mm_xor_si128(B1, C1); \ - \ - B0 = _mm_roti_epi64(B0, -24); \ - B1 = _mm_roti_epi64(B1, -24); \ - } while ((void)0, 0) - -#define G2(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - A0 = fBlaMka(A0, B0); \ - A1 = fBlaMka(A1, B1); \ - \ - D0 = _mm_xor_si128(D0, A0); \ - D1 = _mm_xor_si128(D1, A1); \ - \ - D0 = _mm_roti_epi64(D0, -16); \ - D1 = _mm_roti_epi64(D1, -16); \ - \ - C0 = fBlaMka(C0, D0); \ - C1 = fBlaMka(C1, D1); \ - \ - B0 = _mm_xor_si128(B0, C0); \ - B1 = _mm_xor_si128(B1, C1); \ - \ - B0 = _mm_roti_epi64(B0, -63); \ - B1 = _mm_roti_epi64(B1, -63); \ - } while ((void)0, 0) - -#if defined(__SSSE3__) -#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0 = _mm_alignr_epi8(B1, B0, 8); \ - __m128i t1 = _mm_alignr_epi8(B0, B1, 8); \ - B0 = t0; \ - B1 = t1; \ - \ - t0 = C0; \ - C0 = C1; \ - C1 = t0; \ - \ - t0 = _mm_alignr_epi8(D1, D0, 8); \ - t1 = _mm_alignr_epi8(D0, D1, 8); \ - D0 = t1; \ - D1 = t0; \ - } while ((void)0, 0) - -#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0 = _mm_alignr_epi8(B0, B1, 8); \ - __m128i t1 = _mm_alignr_epi8(B1, B0, 8); \ - B0 = t0; \ - B1 = t1; \ - \ - t0 = C0; \ - C0 = C1; \ - C1 = t0; \ - \ - t0 = _mm_alignr_epi8(D0, D1, 8); \ - t1 = _mm_alignr_epi8(D1, D0, 8); \ - D0 = t1; \ - D1 = t0; \ - } while ((void)0, 0) -#else /* SSE2 */ -#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0 = D0; \ - __m128i t1 = B0; \ - D0 = C0; \ - C0 = C1; \ - C1 = D0; \ - D0 = _mm_unpackhi_epi64(D1, _mm_unpacklo_epi64(t0, t0)); \ - D1 = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(D1, D1)); \ - B0 = _mm_unpackhi_epi64(B0, _mm_unpacklo_epi64(B1, B1)); \ - B1 = _mm_unpackhi_epi64(B1, _mm_unpacklo_epi64(t1, t1)); \ - } while ((void)0, 0) - -#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - __m128i t0, t1; \ - t0 = C0; \ - C0 = C1; \ - C1 = t0; \ - t0 = B0; \ - t1 = D0; \ - B0 = _mm_unpackhi_epi64(B1, _mm_unpacklo_epi64(B0, B0)); \ - B1 = _mm_unpackhi_epi64(t0, _mm_unpacklo_epi64(B1, B1)); \ - D0 = _mm_unpackhi_epi64(D0, _mm_unpacklo_epi64(D1, D1)); \ - D1 = _mm_unpackhi_epi64(D1, _mm_unpacklo_epi64(t1, t1)); \ - } while ((void)0, 0) -#endif - -#define BLAKE2_ROUND(A0, A1, B0, B1, C0, C1, D0, D1) \ - do { \ - G1(A0, B0, C0, D0, A1, B1, C1, D1); \ - G2(A0, B0, C0, D0, A1, B1, C1, D1); \ - \ - DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ - \ - G1(A0, B0, C0, D0, A1, B1, C1, D1); \ - G2(A0, B0, C0, D0, A1, B1, C1, D1); \ - \ - UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ - } while ((void)0, 0) -#else /* __AVX2__ */ - -#include - -#define rotr32(x) _mm256_shuffle_epi32(x, _MM_SHUFFLE(2, 3, 0, 1)) -#define rotr24(x) _mm256_shuffle_epi8(x, _mm256_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10, 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10)) -#define rotr16(x) _mm256_shuffle_epi8(x, _mm256_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9, 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9)) -#define rotr63(x) _mm256_xor_si256(_mm256_srli_epi64((x), 63), _mm256_add_epi64((x), (x))) - -#define G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - do { \ - __m256i ml = _mm256_mul_epu32(A0, B0); \ - ml = _mm256_add_epi64(ml, ml); \ - A0 = _mm256_add_epi64(A0, _mm256_add_epi64(B0, ml)); \ - D0 = _mm256_xor_si256(D0, A0); \ - D0 = rotr32(D0); \ - \ - ml = _mm256_mul_epu32(C0, D0); \ - ml = _mm256_add_epi64(ml, ml); \ - C0 = _mm256_add_epi64(C0, _mm256_add_epi64(D0, ml)); \ - \ - B0 = _mm256_xor_si256(B0, C0); \ - B0 = rotr24(B0); \ - \ - ml = _mm256_mul_epu32(A1, B1); \ - ml = _mm256_add_epi64(ml, ml); \ - A1 = _mm256_add_epi64(A1, _mm256_add_epi64(B1, ml)); \ - D1 = _mm256_xor_si256(D1, A1); \ - D1 = rotr32(D1); \ - \ - ml = _mm256_mul_epu32(C1, D1); \ - ml = _mm256_add_epi64(ml, ml); \ - C1 = _mm256_add_epi64(C1, _mm256_add_epi64(D1, ml)); \ - \ - B1 = _mm256_xor_si256(B1, C1); \ - B1 = rotr24(B1); \ - } while((void)0, 0); - -#define G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - do { \ - __m256i ml = _mm256_mul_epu32(A0, B0); \ - ml = _mm256_add_epi64(ml, ml); \ - A0 = _mm256_add_epi64(A0, _mm256_add_epi64(B0, ml)); \ - D0 = _mm256_xor_si256(D0, A0); \ - D0 = rotr16(D0); \ - \ - ml = _mm256_mul_epu32(C0, D0); \ - ml = _mm256_add_epi64(ml, ml); \ - C0 = _mm256_add_epi64(C0, _mm256_add_epi64(D0, ml)); \ - B0 = _mm256_xor_si256(B0, C0); \ - B0 = rotr63(B0); \ - \ - ml = _mm256_mul_epu32(A1, B1); \ - ml = _mm256_add_epi64(ml, ml); \ - A1 = _mm256_add_epi64(A1, _mm256_add_epi64(B1, ml)); \ - D1 = _mm256_xor_si256(D1, A1); \ - D1 = rotr16(D1); \ - \ - ml = _mm256_mul_epu32(C1, D1); \ - ml = _mm256_add_epi64(ml, ml); \ - C1 = _mm256_add_epi64(C1, _mm256_add_epi64(D1, ml)); \ - B1 = _mm256_xor_si256(B1, C1); \ - B1 = rotr63(B1); \ - } while((void)0, 0); - -#define DIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - B0 = _mm256_permute4x64_epi64(B0, _MM_SHUFFLE(0, 3, 2, 1)); \ - C0 = _mm256_permute4x64_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ - D0 = _mm256_permute4x64_epi64(D0, _MM_SHUFFLE(2, 1, 0, 3)); \ - \ - B1 = _mm256_permute4x64_epi64(B1, _MM_SHUFFLE(0, 3, 2, 1)); \ - C1 = _mm256_permute4x64_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ - D1 = _mm256_permute4x64_epi64(D1, _MM_SHUFFLE(2, 1, 0, 3)); \ - } while((void)0, 0); - -#define DIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ - do { \ - __m256i tmp1 = _mm256_blend_epi32(B0, B1, 0xCC); \ - __m256i tmp2 = _mm256_blend_epi32(B0, B1, 0x33); \ - B1 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ - B0 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ - \ - tmp1 = C0; \ - C0 = C1; \ - C1 = tmp1; \ - \ - tmp1 = _mm256_blend_epi32(D0, D1, 0xCC); \ - tmp2 = _mm256_blend_epi32(D0, D1, 0x33); \ - D0 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ - D1 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ - } while(0); - -#define UNDIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - B0 = _mm256_permute4x64_epi64(B0, _MM_SHUFFLE(2, 1, 0, 3)); \ - C0 = _mm256_permute4x64_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ - D0 = _mm256_permute4x64_epi64(D0, _MM_SHUFFLE(0, 3, 2, 1)); \ - \ - B1 = _mm256_permute4x64_epi64(B1, _MM_SHUFFLE(2, 1, 0, 3)); \ - C1 = _mm256_permute4x64_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ - D1 = _mm256_permute4x64_epi64(D1, _MM_SHUFFLE(0, 3, 2, 1)); \ - } while((void)0, 0); - -#define UNDIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ - do { \ - __m256i tmp1 = _mm256_blend_epi32(B0, B1, 0xCC); \ - __m256i tmp2 = _mm256_blend_epi32(B0, B1, 0x33); \ - B0 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ - B1 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ - \ - tmp1 = C0; \ - C0 = C1; \ - C1 = tmp1; \ - \ - tmp1 = _mm256_blend_epi32(D0, D1, 0x33); \ - tmp2 = _mm256_blend_epi32(D0, D1, 0xCC); \ - D0 = _mm256_permute4x64_epi64(tmp1, _MM_SHUFFLE(2,3,0,1)); \ - D1 = _mm256_permute4x64_epi64(tmp2, _MM_SHUFFLE(2,3,0,1)); \ - } while((void)0, 0); - -#define BLAKE2_ROUND_1(A0, A1, B0, B1, C0, C1, D0, D1) \ - do{ \ - G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - \ - DIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ - \ - G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - \ - UNDIAGONALIZE_1(A0, B0, C0, D0, A1, B1, C1, D1) \ - } while((void)0, 0); - -#define BLAKE2_ROUND_2(A0, A1, B0, B1, C0, C1, D0, D1) \ - do{ \ - G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - \ - DIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ - \ - G1_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - G2_AVX2(A0, A1, B0, B1, C0, C1, D0, D1) \ - \ - UNDIAGONALIZE_2(A0, A1, B0, B1, C0, C1, D0, D1) \ - } while((void)0, 0); - -#endif /* __AVX2__ */ - -#else /* __AVX512F__ */ - -#include - -#define ror64(x, n) _mm512_ror_epi64((x), (n)) - -static __m512i muladd(__m512i x, __m512i y) -{ - __m512i z = _mm512_mul_epu32(x, y); - return _mm512_add_epi64(_mm512_add_epi64(x, y), _mm512_add_epi64(z, z)); -} - -#define G1(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - A0 = muladd(A0, B0); \ - A1 = muladd(A1, B1); \ -\ - D0 = _mm512_xor_si512(D0, A0); \ - D1 = _mm512_xor_si512(D1, A1); \ -\ - D0 = ror64(D0, 32); \ - D1 = ror64(D1, 32); \ -\ - C0 = muladd(C0, D0); \ - C1 = muladd(C1, D1); \ -\ - B0 = _mm512_xor_si512(B0, C0); \ - B1 = _mm512_xor_si512(B1, C1); \ -\ - B0 = ror64(B0, 24); \ - B1 = ror64(B1, 24); \ - } while ((void)0, 0) - -#define G2(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - A0 = muladd(A0, B0); \ - A1 = muladd(A1, B1); \ -\ - D0 = _mm512_xor_si512(D0, A0); \ - D1 = _mm512_xor_si512(D1, A1); \ -\ - D0 = ror64(D0, 16); \ - D1 = ror64(D1, 16); \ -\ - C0 = muladd(C0, D0); \ - C1 = muladd(C1, D1); \ -\ - B0 = _mm512_xor_si512(B0, C0); \ - B1 = _mm512_xor_si512(B1, C1); \ -\ - B0 = ror64(B0, 63); \ - B1 = ror64(B1, 63); \ - } while ((void)0, 0) - -#define DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - B0 = _mm512_permutex_epi64(B0, _MM_SHUFFLE(0, 3, 2, 1)); \ - B1 = _mm512_permutex_epi64(B1, _MM_SHUFFLE(0, 3, 2, 1)); \ -\ - C0 = _mm512_permutex_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ - C1 = _mm512_permutex_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ -\ - D0 = _mm512_permutex_epi64(D0, _MM_SHUFFLE(2, 1, 0, 3)); \ - D1 = _mm512_permutex_epi64(D1, _MM_SHUFFLE(2, 1, 0, 3)); \ - } while ((void)0, 0) - -#define UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - B0 = _mm512_permutex_epi64(B0, _MM_SHUFFLE(2, 1, 0, 3)); \ - B1 = _mm512_permutex_epi64(B1, _MM_SHUFFLE(2, 1, 0, 3)); \ -\ - C0 = _mm512_permutex_epi64(C0, _MM_SHUFFLE(1, 0, 3, 2)); \ - C1 = _mm512_permutex_epi64(C1, _MM_SHUFFLE(1, 0, 3, 2)); \ -\ - D0 = _mm512_permutex_epi64(D0, _MM_SHUFFLE(0, 3, 2, 1)); \ - D1 = _mm512_permutex_epi64(D1, _MM_SHUFFLE(0, 3, 2, 1)); \ - } while ((void)0, 0) - -#define BLAKE2_ROUND(A0, B0, C0, D0, A1, B1, C1, D1) \ - do { \ - G1(A0, B0, C0, D0, A1, B1, C1, D1); \ - G2(A0, B0, C0, D0, A1, B1, C1, D1); \ -\ - DIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ -\ - G1(A0, B0, C0, D0, A1, B1, C1, D1); \ - G2(A0, B0, C0, D0, A1, B1, C1, D1); \ -\ - UNDIAGONALIZE(A0, B0, C0, D0, A1, B1, C1, D1); \ - } while ((void)0, 0) - -#define SWAP_HALVES(A0, A1) \ - do { \ - __m512i t0, t1; \ - t0 = _mm512_shuffle_i64x2(A0, A1, _MM_SHUFFLE(1, 0, 1, 0)); \ - t1 = _mm512_shuffle_i64x2(A0, A1, _MM_SHUFFLE(3, 2, 3, 2)); \ - A0 = t0; \ - A1 = t1; \ - } while((void)0, 0) - -#define SWAP_QUARTERS(A0, A1) \ - do { \ - SWAP_HALVES(A0, A1); \ - A0 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A0); \ - A1 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A1); \ - } while((void)0, 0) - -#define UNSWAP_QUARTERS(A0, A1) \ - do { \ - A0 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A0); \ - A1 = _mm512_permutexvar_epi64(_mm512_setr_epi64(0, 1, 4, 5, 2, 3, 6, 7), A1); \ - SWAP_HALVES(A0, A1); \ - } while((void)0, 0) - -#define BLAKE2_ROUND_1(A0, C0, B0, D0, A1, C1, B1, D1) \ - do { \ - SWAP_HALVES(A0, B0); \ - SWAP_HALVES(C0, D0); \ - SWAP_HALVES(A1, B1); \ - SWAP_HALVES(C1, D1); \ - BLAKE2_ROUND(A0, B0, C0, D0, A1, B1, C1, D1); \ - SWAP_HALVES(A0, B0); \ - SWAP_HALVES(C0, D0); \ - SWAP_HALVES(A1, B1); \ - SWAP_HALVES(C1, D1); \ - } while ((void)0, 0) - -#define BLAKE2_ROUND_2(A0, A1, B0, B1, C0, C1, D0, D1) \ - do { \ - SWAP_QUARTERS(A0, A1); \ - SWAP_QUARTERS(B0, B1); \ - SWAP_QUARTERS(C0, C1); \ - SWAP_QUARTERS(D0, D1); \ - BLAKE2_ROUND(A0, B0, C0, D0, A1, B1, C1, D1); \ - UNSWAP_QUARTERS(A0, A1); \ - UNSWAP_QUARTERS(B0, B1); \ - UNSWAP_QUARTERS(C0, C1); \ - UNSWAP_QUARTERS(D0, D1); \ - } while ((void)0, 0) - -#endif /* __AVX512F__ */ -#endif /* BLAKE_ROUND_MKA_OPT_H */ diff --git a/deps/argon2/argon2/blake2/blamka-round-ref.h b/deps/argon2/argon2/blake2/blamka-round-ref.h deleted file mode 100644 index b8f2cf4713..0000000000 --- a/deps/argon2/argon2/blake2/blamka-round-ref.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef BLAKE_ROUND_MKA_H -#define BLAKE_ROUND_MKA_H - -#include "blake2.h" -#include "blake2-impl.h" - -/* designed by the Lyra PHC team */ -static BLAKE2_INLINE uint64_t fBlaMka(uint64_t x, uint64_t y) { - const uint64_t m = UINT64_C(0xFFFFFFFF); - const uint64_t xy = (x & m) * (y & m); - return x + y + 2 * xy; -} - -#define G(a, b, c, d) \ - do { \ - a = fBlaMka(a, b); \ - d = rotr64(d ^ a, 32); \ - c = fBlaMka(c, d); \ - b = rotr64(b ^ c, 24); \ - a = fBlaMka(a, b); \ - d = rotr64(d ^ a, 16); \ - c = fBlaMka(c, d); \ - b = rotr64(b ^ c, 63); \ - } while ((void)0, 0) - -#define BLAKE2_ROUND_NOMSG(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, \ - v12, v13, v14, v15) \ - do { \ - G(v0, v4, v8, v12); \ - G(v1, v5, v9, v13); \ - G(v2, v6, v10, v14); \ - G(v3, v7, v11, v15); \ - G(v0, v5, v10, v15); \ - G(v1, v6, v11, v12); \ - G(v2, v7, v8, v13); \ - G(v3, v4, v9, v14); \ - } while ((void)0, 0) - -#endif diff --git a/deps/argon2/argon2/core.c b/deps/argon2/argon2/core.c deleted file mode 100644 index 65f0537694..0000000000 --- a/deps/argon2/argon2/core.c +++ /dev/null @@ -1,648 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -/*For memory wiping*/ -#ifdef _MSC_VER -#include -#include /* For SecureZeroMemory */ -#endif -#if defined __STDC_LIB_EXT1__ -#define __STDC_WANT_LIB_EXT1__ 1 -#endif -#define VC_GE_2005(version) (version >= 1400) - -/* for explicit_bzero() on glibc */ -#define _DEFAULT_SOURCE - -#include -#include -#include - -#include "core.h" -#include "thread.h" -#include "blake2/blake2.h" -#include "blake2/blake2-impl.h" - -#ifdef GENKAT -#include "genkat.h" -#endif - -#if defined(__clang__) -#if __has_attribute(optnone) -#define NOT_OPTIMIZED __attribute__((optnone)) -#endif -#elif defined(__GNUC__) -#define GCC_VERSION \ - (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) -#if GCC_VERSION >= 40400 -#define NOT_OPTIMIZED __attribute__((optimize("O0"))) -#endif -#endif -#ifndef NOT_OPTIMIZED -#define NOT_OPTIMIZED -#endif - -/***************Instance and Position constructors**********/ -void init_block_value(block *b, uint8_t in) { memset(b->v, in, sizeof(b->v)); } - -void copy_block(block *dst, const block *src) { - memcpy(dst->v, src->v, sizeof(uint64_t) * ARGON2_QWORDS_IN_BLOCK); -} - -void xor_block(block *dst, const block *src) { - int i; - for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { - dst->v[i] ^= src->v[i]; - } -} - -static void load_block(block *dst, const void *input) { - unsigned i; - for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { - dst->v[i] = load64((const uint8_t *)input + i * sizeof(dst->v[i])); - } -} - -static void store_block(void *output, const block *src) { - unsigned i; - for (i = 0; i < ARGON2_QWORDS_IN_BLOCK; ++i) { - store64((uint8_t *)output + i * sizeof(src->v[i]), src->v[i]); - } -} - -/***************Memory functions*****************/ - -int allocate_memory(const argon2_context *context, uint8_t **memory, - size_t num, size_t size) { - size_t memory_size = num*size; - if (memory == NULL) { - return ARGON2_MEMORY_ALLOCATION_ERROR; - } - - /* 1. Check for multiplication overflow */ - if (size != 0 && memory_size / size != num) { - return ARGON2_MEMORY_ALLOCATION_ERROR; - } - - /* 2. Try to allocate with appropriate allocator */ - if (context->allocate_cbk) { - (context->allocate_cbk)(memory, memory_size); - } else { - *memory = malloc(memory_size); - } - - if (*memory == NULL) { - return ARGON2_MEMORY_ALLOCATION_ERROR; - } - - return ARGON2_OK; -} - -void free_memory(const argon2_context *context, uint8_t *memory, - size_t num, size_t size) { - size_t memory_size = num*size; - clear_internal_memory(memory, memory_size); - if (context->free_cbk) { - (context->free_cbk)(memory, memory_size); - } else { - free(memory); - } -} - -#if defined(__OpenBSD__) -#define HAVE_EXPLICIT_BZERO 1 -#elif defined(__GLIBC__) && defined(__GLIBC_PREREQ) -#if __GLIBC_PREREQ(2,25) -#define HAVE_EXPLICIT_BZERO 1 -#endif -#endif - -void NOT_OPTIMIZED secure_wipe_memory(void *v, size_t n) { -#if defined(_MSC_VER) && VC_GE_2005(_MSC_VER) - SecureZeroMemory(v, n); -#elif defined memset_s - memset_s(v, n, 0, n); -#elif defined(HAVE_EXPLICIT_BZERO) - explicit_bzero(v, n); -#else - static void *(*const volatile memset_sec)(void *, int, size_t) = &memset; - memset_sec(v, 0, n); -#endif -} - -/* Memory clear flag defaults to true. */ -int FLAG_clear_internal_memory = 1; -void clear_internal_memory(void *v, size_t n) { - if (FLAG_clear_internal_memory && v) { - secure_wipe_memory(v, n); - } -} - -void finalize(const argon2_context *context, argon2_instance_t *instance) { - if (context != NULL && instance != NULL) { - block blockhash; - uint32_t l; - - copy_block(&blockhash, instance->memory + instance->lane_length - 1); - - /* XOR the last blocks */ - for (l = 1; l < instance->lanes; ++l) { - uint32_t last_block_in_lane = - l * instance->lane_length + (instance->lane_length - 1); - xor_block(&blockhash, instance->memory + last_block_in_lane); - } - - /* Hash the result */ - { - uint8_t blockhash_bytes[ARGON2_BLOCK_SIZE]; - store_block(blockhash_bytes, &blockhash); - blake2b_long(context->out, context->outlen, blockhash_bytes, - ARGON2_BLOCK_SIZE); - /* clear blockhash and blockhash_bytes */ - clear_internal_memory(blockhash.v, ARGON2_BLOCK_SIZE); - clear_internal_memory(blockhash_bytes, ARGON2_BLOCK_SIZE); - } - -#ifdef GENKAT - print_tag(context->out, context->outlen); -#endif - - free_memory(context, (uint8_t *)instance->memory, - instance->memory_blocks, sizeof(block)); - } -} - -uint32_t index_alpha(const argon2_instance_t *instance, - const argon2_position_t *position, uint32_t pseudo_rand, - int same_lane) { - /* - * Pass 0: - * This lane : all already finished segments plus already constructed - * blocks in this segment - * Other lanes : all already finished segments - * Pass 1+: - * This lane : (SYNC_POINTS - 1) last segments plus already constructed - * blocks in this segment - * Other lanes : (SYNC_POINTS - 1) last segments - */ - uint32_t reference_area_size; - uint64_t relative_position; - uint32_t start_position, absolute_position; - - if (0 == position->pass) { - /* First pass */ - if (0 == position->slice) { - /* First slice */ - reference_area_size = - position->index - 1; /* all but the previous */ - } else { - if (same_lane) { - /* The same lane => add current segment */ - reference_area_size = - position->slice * instance->segment_length + - position->index - 1; - } else { - reference_area_size = - position->slice * instance->segment_length + - ((position->index == 0) ? (-1) : 0); - } - } - } else { - /* Second pass */ - if (same_lane) { - reference_area_size = instance->lane_length - - instance->segment_length + position->index - - 1; - } else { - reference_area_size = instance->lane_length - - instance->segment_length + - ((position->index == 0) ? (-1) : 0); - } - } - - /* 1.2.4. Mapping pseudo_rand to 0.. and produce - * relative position */ - relative_position = pseudo_rand; - relative_position = relative_position * relative_position >> 32; - relative_position = reference_area_size - 1 - - (reference_area_size * relative_position >> 32); - - /* 1.2.5 Computing starting position */ - start_position = 0; - - if (0 != position->pass) { - start_position = (position->slice == ARGON2_SYNC_POINTS - 1) - ? 0 - : (position->slice + 1) * instance->segment_length; - } - - /* 1.2.6. Computing absolute position */ - absolute_position = (start_position + relative_position) % - instance->lane_length; /* absolute position */ - return absolute_position; -} - -/* Single-threaded version for p=1 case */ -static int fill_memory_blocks_st(argon2_instance_t *instance) { - uint32_t r, s, l; - - for (r = 0; r < instance->passes; ++r) { - for (s = 0; s < ARGON2_SYNC_POINTS; ++s) { - for (l = 0; l < instance->lanes; ++l) { - argon2_position_t position = {r, l, (uint8_t)s, 0}; - fill_segment(instance, position); - } - } -#ifdef GENKAT - internal_kat(instance, r); /* Print all memory blocks */ -#endif - } - return ARGON2_OK; -} - -#if !defined(ARGON2_NO_THREADS) - -#ifdef _WIN32 -static unsigned __stdcall fill_segment_thr(void *thread_data) -#else -static void *fill_segment_thr(void *thread_data) -#endif -{ - argon2_thread_data *my_data = thread_data; - fill_segment(my_data->instance_ptr, my_data->pos); - argon2_thread_exit(); - return 0; -} - -/* Multi-threaded version for p > 1 case */ -static int fill_memory_blocks_mt(argon2_instance_t *instance) { - uint32_t r, s; - argon2_thread_handle_t *thread = NULL; - argon2_thread_data *thr_data = NULL; - int rc = ARGON2_OK; - - /* 1. Allocating space for threads */ - thread = calloc(instance->lanes, sizeof(argon2_thread_handle_t)); - if (thread == NULL) { - rc = ARGON2_MEMORY_ALLOCATION_ERROR; - goto fail; - } - - thr_data = calloc(instance->lanes, sizeof(argon2_thread_data)); - if (thr_data == NULL) { - rc = ARGON2_MEMORY_ALLOCATION_ERROR; - goto fail; - } - - for (r = 0; r < instance->passes; ++r) { - for (s = 0; s < ARGON2_SYNC_POINTS; ++s) { - uint32_t l, ll; - - /* 2. Calling threads */ - for (l = 0; l < instance->lanes; ++l) { - argon2_position_t position; - - /* 2.1 Join a thread if limit is exceeded */ - if (l >= instance->threads) { - if (argon2_thread_join(thread[l - instance->threads])) { - rc = ARGON2_THREAD_FAIL; - goto fail; - } - } - - /* 2.2 Create thread */ - position.pass = r; - position.lane = l; - position.slice = (uint8_t)s; - position.index = 0; - thr_data[l].instance_ptr = - instance; /* preparing the thread input */ - memcpy(&(thr_data[l].pos), &position, - sizeof(argon2_position_t)); - if (argon2_thread_create(&thread[l], &fill_segment_thr, - (void *)&thr_data[l])) { - /* Wait for already running threads */ - for (ll = 0; ll < l; ++ll) - argon2_thread_join(thread[ll]); - rc = ARGON2_THREAD_FAIL; - goto fail; - } - - /* fill_segment(instance, position); */ - /*Non-thread equivalent of the lines above */ - } - - /* 3. Joining remaining threads */ - for (l = instance->lanes - instance->threads; l < instance->lanes; - ++l) { - if (argon2_thread_join(thread[l])) { - rc = ARGON2_THREAD_FAIL; - goto fail; - } - } - } - -#ifdef GENKAT - internal_kat(instance, r); /* Print all memory blocks */ -#endif - } - -fail: - if (thread != NULL) { - free(thread); - } - if (thr_data != NULL) { - free(thr_data); - } - return rc; -} - -#endif /* ARGON2_NO_THREADS */ - -int fill_memory_blocks(argon2_instance_t *instance) { - if (instance == NULL || instance->lanes == 0) { - return ARGON2_INCORRECT_PARAMETER; - } -#if defined(ARGON2_NO_THREADS) - return fill_memory_blocks_st(instance); -#else - return instance->threads == 1 ? - fill_memory_blocks_st(instance) : fill_memory_blocks_mt(instance); -#endif -} - -int validate_inputs(const argon2_context *context) { - if (NULL == context) { - return ARGON2_INCORRECT_PARAMETER; - } - - if (NULL == context->out) { - return ARGON2_OUTPUT_PTR_NULL; - } - - /* Validate output length */ - if (ARGON2_MIN_OUTLEN > context->outlen) { - return ARGON2_OUTPUT_TOO_SHORT; - } - - if (ARGON2_MAX_OUTLEN < context->outlen) { - return ARGON2_OUTPUT_TOO_LONG; - } - - /* Validate password (required param) */ - if (NULL == context->pwd) { - if (0 != context->pwdlen) { - return ARGON2_PWD_PTR_MISMATCH; - } - } - - if (ARGON2_MIN_PWD_LENGTH > context->pwdlen) { - return ARGON2_PWD_TOO_SHORT; - } - - if (ARGON2_MAX_PWD_LENGTH < context->pwdlen) { - return ARGON2_PWD_TOO_LONG; - } - - /* Validate salt (required param) */ - if (NULL == context->salt) { - if (0 != context->saltlen) { - return ARGON2_SALT_PTR_MISMATCH; - } - } - - if (ARGON2_MIN_SALT_LENGTH > context->saltlen) { - return ARGON2_SALT_TOO_SHORT; - } - - if (ARGON2_MAX_SALT_LENGTH < context->saltlen) { - return ARGON2_SALT_TOO_LONG; - } - - /* Validate secret (optional param) */ - if (NULL == context->secret) { - if (0 != context->secretlen) { - return ARGON2_SECRET_PTR_MISMATCH; - } - } else { - if (ARGON2_MIN_SECRET > context->secretlen) { - return ARGON2_SECRET_TOO_SHORT; - } - if (ARGON2_MAX_SECRET < context->secretlen) { - return ARGON2_SECRET_TOO_LONG; - } - } - - /* Validate associated data (optional param) */ - if (NULL == context->ad) { - if (0 != context->adlen) { - return ARGON2_AD_PTR_MISMATCH; - } - } else { - if (ARGON2_MIN_AD_LENGTH > context->adlen) { - return ARGON2_AD_TOO_SHORT; - } - if (ARGON2_MAX_AD_LENGTH < context->adlen) { - return ARGON2_AD_TOO_LONG; - } - } - - /* Validate memory cost */ - if (ARGON2_MIN_MEMORY > context->m_cost) { - return ARGON2_MEMORY_TOO_LITTLE; - } - - if (ARGON2_MAX_MEMORY < context->m_cost) { - return ARGON2_MEMORY_TOO_MUCH; - } - - if (context->m_cost < 8 * context->lanes) { - return ARGON2_MEMORY_TOO_LITTLE; - } - - /* Validate time cost */ - if (ARGON2_MIN_TIME > context->t_cost) { - return ARGON2_TIME_TOO_SMALL; - } - - if (ARGON2_MAX_TIME < context->t_cost) { - return ARGON2_TIME_TOO_LARGE; - } - - /* Validate lanes */ - if (ARGON2_MIN_LANES > context->lanes) { - return ARGON2_LANES_TOO_FEW; - } - - if (ARGON2_MAX_LANES < context->lanes) { - return ARGON2_LANES_TOO_MANY; - } - - /* Validate threads */ - if (ARGON2_MIN_THREADS > context->threads) { - return ARGON2_THREADS_TOO_FEW; - } - - if (ARGON2_MAX_THREADS < context->threads) { - return ARGON2_THREADS_TOO_MANY; - } - - if (NULL != context->allocate_cbk && NULL == context->free_cbk) { - return ARGON2_FREE_MEMORY_CBK_NULL; - } - - if (NULL == context->allocate_cbk && NULL != context->free_cbk) { - return ARGON2_ALLOCATE_MEMORY_CBK_NULL; - } - - return ARGON2_OK; -} - -void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance) { - uint32_t l; - /* Make the first and second block in each lane as G(H0||0||i) or - G(H0||1||i) */ - uint8_t blockhash_bytes[ARGON2_BLOCK_SIZE]; - for (l = 0; l < instance->lanes; ++l) { - - store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 0); - store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH + 4, l); - blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, - ARGON2_PREHASH_SEED_LENGTH); - load_block(&instance->memory[l * instance->lane_length + 0], - blockhash_bytes); - - store32(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, 1); - blake2b_long(blockhash_bytes, ARGON2_BLOCK_SIZE, blockhash, - ARGON2_PREHASH_SEED_LENGTH); - load_block(&instance->memory[l * instance->lane_length + 1], - blockhash_bytes); - } - clear_internal_memory(blockhash_bytes, ARGON2_BLOCK_SIZE); -} - -void initial_hash(uint8_t *blockhash, argon2_context *context, - argon2_type type) { - blake2b_state BlakeHash; - uint8_t value[sizeof(uint32_t)]; - - if (NULL == context || NULL == blockhash) { - return; - } - - blake2b_init(&BlakeHash, ARGON2_PREHASH_DIGEST_LENGTH); - - store32(&value, context->lanes); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - store32(&value, context->outlen); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - store32(&value, context->m_cost); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - store32(&value, context->t_cost); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - store32(&value, context->version); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - store32(&value, (uint32_t)type); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - store32(&value, context->pwdlen); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - if (context->pwd != NULL) { - blake2b_update(&BlakeHash, (const uint8_t *)context->pwd, - context->pwdlen); - - if (context->flags & ARGON2_FLAG_CLEAR_PASSWORD) { - secure_wipe_memory(context->pwd, context->pwdlen); - context->pwdlen = 0; - } - } - - store32(&value, context->saltlen); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - if (context->salt != NULL) { - blake2b_update(&BlakeHash, (const uint8_t *)context->salt, - context->saltlen); - } - - store32(&value, context->secretlen); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - if (context->secret != NULL) { - blake2b_update(&BlakeHash, (const uint8_t *)context->secret, - context->secretlen); - - if (context->flags & ARGON2_FLAG_CLEAR_SECRET) { - secure_wipe_memory(context->secret, context->secretlen); - context->secretlen = 0; - } - } - - store32(&value, context->adlen); - blake2b_update(&BlakeHash, (const uint8_t *)&value, sizeof(value)); - - if (context->ad != NULL) { - blake2b_update(&BlakeHash, (const uint8_t *)context->ad, - context->adlen); - } - - blake2b_final(&BlakeHash, blockhash, ARGON2_PREHASH_DIGEST_LENGTH); -} - -int initialize(argon2_instance_t *instance, argon2_context *context) { - uint8_t blockhash[ARGON2_PREHASH_SEED_LENGTH]; - int result = ARGON2_OK; - - if (instance == NULL || context == NULL) - return ARGON2_INCORRECT_PARAMETER; - instance->context_ptr = context; - - /* 1. Memory allocation */ - result = allocate_memory(context, (uint8_t **)&(instance->memory), - instance->memory_blocks, sizeof(block)); - if (result != ARGON2_OK) { - return result; - } - - /* 2. Initial hashing */ - /* H_0 + 8 extra bytes to produce the first blocks */ - /* uint8_t blockhash[ARGON2_PREHASH_SEED_LENGTH]; */ - /* Hashing all inputs */ - initial_hash(blockhash, context, instance->type); - /* Zeroing 8 extra bytes */ - clear_internal_memory(blockhash + ARGON2_PREHASH_DIGEST_LENGTH, - ARGON2_PREHASH_SEED_LENGTH - - ARGON2_PREHASH_DIGEST_LENGTH); - -#ifdef GENKAT - initial_kat(blockhash, context, instance->type); -#endif - - /* 3. Creating first blocks, we always have at least two blocks in a slice - */ - fill_first_blocks(blockhash, instance); - /* Clearing the hash */ - clear_internal_memory(blockhash, ARGON2_PREHASH_SEED_LENGTH); - - return ARGON2_OK; -} diff --git a/deps/argon2/argon2/core.h b/deps/argon2/argon2/core.h deleted file mode 100644 index 78000ba9ed..0000000000 --- a/deps/argon2/argon2/core.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef ARGON2_CORE_H -#define ARGON2_CORE_H - -#include "argon2.h" - -#define CONST_CAST(x) (x)(uintptr_t) - -/**********************Argon2 internal constants*******************************/ - -enum argon2_core_constants { - /* Memory block size in bytes */ - ARGON2_BLOCK_SIZE = 1024, - ARGON2_QWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 8, - ARGON2_OWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 16, - ARGON2_HWORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 32, - ARGON2_512BIT_WORDS_IN_BLOCK = ARGON2_BLOCK_SIZE / 64, - - /* Number of pseudo-random values generated by one call to Blake in Argon2i - to - generate reference block positions */ - ARGON2_ADDRESSES_IN_BLOCK = 128, - - /* Pre-hashing digest length and its extension*/ - ARGON2_PREHASH_DIGEST_LENGTH = 64, - ARGON2_PREHASH_SEED_LENGTH = 72 -}; - -/*************************Argon2 internal data types***********************/ - -/* - * Structure for the (1KB) memory block implemented as 128 64-bit words. - * Memory blocks can be copied, XORed. Internal words can be accessed by [] (no - * bounds checking). - */ -typedef struct block_ { uint64_t v[ARGON2_QWORDS_IN_BLOCK]; } block; - -/*****************Functions that work with the block******************/ - -/* Initialize each byte of the block with @in */ -void init_block_value(block *b, uint8_t in); - -/* Copy block @src to block @dst */ -void copy_block(block *dst, const block *src); - -/* XOR @src onto @dst bytewise */ -void xor_block(block *dst, const block *src); - -/* - * Argon2 instance: memory pointer, number of passes, amount of memory, type, - * and derived values. - * Used to evaluate the number and location of blocks to construct in each - * thread - */ -typedef struct Argon2_instance_t { - block *memory; /* Memory pointer */ - uint32_t version; - uint32_t passes; /* Number of passes */ - uint32_t memory_blocks; /* Number of blocks in memory */ - uint32_t segment_length; - uint32_t lane_length; - uint32_t lanes; - uint32_t threads; - argon2_type type; - int print_internals; /* whether to print the memory blocks */ - argon2_context *context_ptr; /* points back to original context */ -} argon2_instance_t; - -/* - * Argon2 position: where we construct the block right now. Used to distribute - * work between threads. - */ -typedef struct Argon2_position_t { - uint32_t pass; - uint32_t lane; - uint8_t slice; - uint32_t index; -} argon2_position_t; - -/*Struct that holds the inputs for thread handling FillSegment*/ -typedef struct Argon2_thread_data { - argon2_instance_t *instance_ptr; - argon2_position_t pos; -} argon2_thread_data; - -/*************************Argon2 core functions********************************/ - -/* Allocates memory to the given pointer, uses the appropriate allocator as - * specified in the context. Total allocated memory is num*size. - * @param context argon2_context which specifies the allocator - * @param memory pointer to the pointer to the memory - * @param size the size in bytes for each element to be allocated - * @param num the number of elements to be allocated - * @return ARGON2_OK if @memory is a valid pointer and memory is allocated - */ -int allocate_memory(const argon2_context *context, uint8_t **memory, - size_t num, size_t size); - -/* - * Frees memory at the given pointer, uses the appropriate deallocator as - * specified in the context. Also cleans the memory using clear_internal_memory. - * @param context argon2_context which specifies the deallocator - * @param memory pointer to buffer to be freed - * @param size the size in bytes for each element to be deallocated - * @param num the number of elements to be deallocated - */ -void free_memory(const argon2_context *context, uint8_t *memory, - size_t num, size_t size); - -/* Function that securely cleans the memory. This ignores any flags set - * regarding clearing memory. Usually one just calls clear_internal_memory. - * @param mem Pointer to the memory - * @param s Memory size in bytes - */ -void secure_wipe_memory(void *v, size_t n); - -/* Function that securely clears the memory if FLAG_clear_internal_memory is - * set. If the flag isn't set, this function does nothing. - * @param mem Pointer to the memory - * @param s Memory size in bytes - */ -void clear_internal_memory(void *v, size_t n); - -/* - * Computes absolute position of reference block in the lane following a skewed - * distribution and using a pseudo-random value as input - * @param instance Pointer to the current instance - * @param position Pointer to the current position - * @param pseudo_rand 32-bit pseudo-random value used to determine the position - * @param same_lane Indicates if the block will be taken from the current lane. - * If so we can reference the current segment - * @pre All pointers must be valid - */ -uint32_t index_alpha(const argon2_instance_t *instance, - const argon2_position_t *position, uint32_t pseudo_rand, - int same_lane); - -/* - * Function that validates all inputs against predefined restrictions and return - * an error code - * @param context Pointer to current Argon2 context - * @return ARGON2_OK if everything is all right, otherwise one of error codes - * (all defined in - */ -int validate_inputs(const argon2_context *context); - -/* - * Hashes all the inputs into @a blockhash[PREHASH_DIGEST_LENGTH], clears - * password and secret if needed - * @param context Pointer to the Argon2 internal structure containing memory - * pointer, and parameters for time and space requirements. - * @param blockhash Buffer for pre-hashing digest - * @param type Argon2 type - * @pre @a blockhash must have at least @a PREHASH_DIGEST_LENGTH bytes - * allocated - */ -void initial_hash(uint8_t *blockhash, argon2_context *context, - argon2_type type); - -/* - * Function creates first 2 blocks per lane - * @param instance Pointer to the current instance - * @param blockhash Pointer to the pre-hashing digest - * @pre blockhash must point to @a PREHASH_SEED_LENGTH allocated values - */ -void fill_first_blocks(uint8_t *blockhash, const argon2_instance_t *instance); - -/* - * Function allocates memory, hashes the inputs with Blake, and creates first - * two blocks. Returns the pointer to the main memory with 2 blocks per lane - * initialized - * @param context Pointer to the Argon2 internal structure containing memory - * pointer, and parameters for time and space requirements. - * @param instance Current Argon2 instance - * @return Zero if successful, -1 if memory failed to allocate. @context->state - * will be modified if successful. - */ -int initialize(argon2_instance_t *instance, argon2_context *context); - -/* - * XORing the last block of each lane, hashing it, making the tag. Deallocates - * the memory. - * @param context Pointer to current Argon2 context (use only the out parameters - * from it) - * @param instance Pointer to current instance of Argon2 - * @pre instance->state must point to necessary amount of memory - * @pre context->out must point to outlen bytes of memory - * @pre if context->free_cbk is not NULL, it should point to a function that - * deallocates memory - */ -void finalize(const argon2_context *context, argon2_instance_t *instance); - -/* - * Function that fills the segment using previous segments also from other - * threads - * @param context current context - * @param instance Pointer to the current instance - * @param position Current position - * @pre all block pointers must be valid - */ -void fill_segment(const argon2_instance_t *instance, - argon2_position_t position); - -/* - * Function that fills the entire memory t_cost times based on the first two - * blocks in each lane - * @param instance Pointer to the current instance - * @return ARGON2_OK if successful, @context->state - */ -int fill_memory_blocks(argon2_instance_t *instance); - -#endif diff --git a/deps/argon2/argon2/encoding.c b/deps/argon2/argon2/encoding.c deleted file mode 100644 index 12cfda4d05..0000000000 --- a/deps/argon2/argon2/encoding.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include -#include -#include "encoding.h" -#include "core.h" - -/* - * Example code for a decoder and encoder of "hash strings", with Argon2 - * parameters. - * - * This code comprises three sections: - * - * -- The first section contains generic Base64 encoding and decoding - * functions. It is conceptually applicable to any hash function - * implementation that uses Base64 to encode and decode parameters, - * salts and outputs. It could be made into a library, provided that - * the relevant functions are made public (non-static) and be given - * reasonable names to avoid collisions with other functions. - * - * -- The second section is specific to Argon2. It encodes and decodes - * the parameters, salts and outputs. It does not compute the hash - * itself. - * - * The code was originally written by Thomas Pornin , - * to whom comments and remarks may be sent. It is released under what - * should amount to Public Domain or its closest equivalent; the - * following mantra is supposed to incarnate that fact with all the - * proper legal rituals: - * - * --------------------------------------------------------------------- - * This file is provided under the terms of Creative Commons CC0 1.0 - * Public Domain Dedication. To the extent possible under law, the - * author (Thomas Pornin) has waived all copyright and related or - * neighboring rights to this file. This work is published from: Canada. - * --------------------------------------------------------------------- - * - * Copyright (c) 2015 Thomas Pornin - */ - -/* ==================================================================== */ -/* - * Common code; could be shared between different hash functions. - * - * Note: the Base64 functions below assume that uppercase letters (resp. - * lowercase letters) have consecutive numerical codes, that fit on 8 - * bits. All modern systems use ASCII-compatible charsets, where these - * properties are true. If you are stuck with a dinosaur of a system - * that still defaults to EBCDIC then you already have much bigger - * interoperability issues to deal with. - */ - -/* - * Some macros for constant-time comparisons. These work over values in - * the 0..255 range. Returned value is 0x00 on "false", 0xFF on "true". - */ -#define EQ(x, y) ((((0U - ((unsigned)(x) ^ (unsigned)(y))) >> 8) & 0xFF) ^ 0xFF) -#define GT(x, y) ((((unsigned)(y) - (unsigned)(x)) >> 8) & 0xFF) -#define GE(x, y) (GT(y, x) ^ 0xFF) -#define LT(x, y) GT(y, x) -#define LE(x, y) GE(y, x) - -/* - * Convert value x (0..63) to corresponding Base64 character. - */ -static int b64_byte_to_char(unsigned x) { - return (LT(x, 26) & (x + 'A')) | - (GE(x, 26) & LT(x, 52) & (x + ('a' - 26))) | - (GE(x, 52) & LT(x, 62) & (x + ('0' - 52))) | (EQ(x, 62) & '+') | - (EQ(x, 63) & '/'); -} - -/* - * Convert character c to the corresponding 6-bit value. If character c - * is not a Base64 character, then 0xFF (255) is returned. - */ -static unsigned b64_char_to_byte(int c) { - unsigned x; - - x = (GE(c, 'A') & LE(c, 'Z') & (c - 'A')) | - (GE(c, 'a') & LE(c, 'z') & (c - ('a' - 26))) | - (GE(c, '0') & LE(c, '9') & (c - ('0' - 52))) | (EQ(c, '+') & 62) | - (EQ(c, '/') & 63); - return x | (EQ(x, 0) & (EQ(c, 'A') ^ 0xFF)); -} - -/* - * Convert some bytes to Base64. 'dst_len' is the length (in characters) - * of the output buffer 'dst'; if that buffer is not large enough to - * receive the result (including the terminating 0), then (size_t)-1 - * is returned. Otherwise, the zero-terminated Base64 string is written - * in the buffer, and the output length (counted WITHOUT the terminating - * zero) is returned. - */ -static size_t to_base64(char *dst, size_t dst_len, const void *src, - size_t src_len) { - size_t olen; - const unsigned char *buf; - unsigned acc, acc_len; - - olen = (src_len / 3) << 2; - switch (src_len % 3) { - case 2: - olen++; - /* fall through */ - case 1: - olen += 2; - break; - } - if (dst_len <= olen) { - return (size_t)-1; - } - acc = 0; - acc_len = 0; - buf = (const unsigned char *)src; - while (src_len-- > 0) { - acc = (acc << 8) + (*buf++); - acc_len += 8; - while (acc_len >= 6) { - acc_len -= 6; - *dst++ = (char)b64_byte_to_char((acc >> acc_len) & 0x3F); - } - } - if (acc_len > 0) { - *dst++ = (char)b64_byte_to_char((acc << (6 - acc_len)) & 0x3F); - } - *dst++ = 0; - return olen; -} - -/* - * Decode Base64 chars into bytes. The '*dst_len' value must initially - * contain the length of the output buffer '*dst'; when the decoding - * ends, the actual number of decoded bytes is written back in - * '*dst_len'. - * - * Decoding stops when a non-Base64 character is encountered, or when - * the output buffer capacity is exceeded. If an error occurred (output - * buffer is too small, invalid last characters leading to unprocessed - * buffered bits), then NULL is returned; otherwise, the returned value - * points to the first non-Base64 character in the source stream, which - * may be the terminating zero. - */ -static const char *from_base64(void *dst, size_t *dst_len, const char *src) { - size_t len; - unsigned char *buf; - unsigned acc, acc_len; - - buf = (unsigned char *)dst; - len = 0; - acc = 0; - acc_len = 0; - for (;;) { - unsigned d; - - d = b64_char_to_byte(*src); - if (d == 0xFF) { - break; - } - src++; - acc = (acc << 6) + d; - acc_len += 6; - if (acc_len >= 8) { - acc_len -= 8; - if ((len++) >= *dst_len) { - return NULL; - } - *buf++ = (acc >> acc_len) & 0xFF; - } - } - - /* - * If the input length is equal to 1 modulo 4 (which is - * invalid), then there will remain 6 unprocessed bits; - * otherwise, only 0, 2 or 4 bits are buffered. The buffered - * bits must also all be zero. - */ - if (acc_len > 4 || (acc & (((unsigned)1 << acc_len) - 1)) != 0) { - return NULL; - } - *dst_len = len; - return src; -} - -/* - * Decode decimal integer from 'str'; the value is written in '*v'. - * Returned value is a pointer to the next non-decimal character in the - * string. If there is no digit at all, or the value encoding is not - * minimal (extra leading zeros), or the value does not fit in an - * 'unsigned long', then NULL is returned. - */ -static const char *decode_decimal(const char *str, unsigned long *v) { - const char *orig; - unsigned long acc; - - acc = 0; - for (orig = str;; str++) { - int c; - - c = *str; - if (c < '0' || c > '9') { - break; - } - c -= '0'; - if (acc > (ULONG_MAX / 10)) { - return NULL; - } - acc *= 10; - if ((unsigned long)c > (ULONG_MAX - acc)) { - return NULL; - } - acc += (unsigned long)c; - } - if (str == orig || (*orig == '0' && str != (orig + 1))) { - return NULL; - } - *v = acc; - return str; -} - -/* ==================================================================== */ -/* - * Code specific to Argon2. - * - * The code below applies the following format: - * - * $argon2[$v=]$m=,t=,p=$$ - * - * where is either 'd', 'id', or 'i', is a decimal integer (positive, - * fits in an 'unsigned long'), and is Base64-encoded data (no '=' padding - * characters, no newline or whitespace). - * - * The last two binary chunks (encoded in Base64) are, in that order, - * the salt and the output. Both are required. The binary salt length and the - * output length must be in the allowed ranges defined in argon2.h. - * - * The ctx struct must contain buffers large enough to hold the salt and pwd - * when it is fed into decode_string. - */ - -int decode_string(argon2_context *ctx, const char *str, argon2_type type) { - -/* check for prefix */ -#define CC(prefix) \ - do { \ - size_t cc_len = strlen(prefix); \ - if (strncmp(str, prefix, cc_len) != 0) { \ - return ARGON2_DECODING_FAIL; \ - } \ - str += cc_len; \ - } while ((void)0, 0) - -/* optional prefix checking with supplied code */ -#define CC_opt(prefix, code) \ - do { \ - size_t cc_len = strlen(prefix); \ - if (strncmp(str, prefix, cc_len) == 0) { \ - str += cc_len; \ - { code; } \ - } \ - } while ((void)0, 0) - -/* Decoding prefix into decimal */ -#define DECIMAL(x) \ - do { \ - unsigned long dec_x; \ - str = decode_decimal(str, &dec_x); \ - if (str == NULL) { \ - return ARGON2_DECODING_FAIL; \ - } \ - (x) = dec_x; \ - } while ((void)0, 0) - - -/* Decoding prefix into uint32_t decimal */ -#define DECIMAL_U32(x) \ - do { \ - unsigned long dec_x; \ - str = decode_decimal(str, &dec_x); \ - if (str == NULL || dec_x > UINT32_MAX) { \ - return ARGON2_DECODING_FAIL; \ - } \ - (x) = (uint32_t)dec_x; \ - } while ((void)0, 0) - - -/* Decoding base64 into a binary buffer */ -#define BIN(buf, max_len, len) \ - do { \ - size_t bin_len = (max_len); \ - str = from_base64(buf, &bin_len, str); \ - if (str == NULL || bin_len > UINT32_MAX) { \ - return ARGON2_DECODING_FAIL; \ - } \ - (len) = (uint32_t)bin_len; \ - } while ((void)0, 0) - - size_t maxsaltlen = ctx->saltlen; - size_t maxoutlen = ctx->outlen; - int validation_result; - const char* type_string; - - /* We should start with the argon2_type we are using */ - type_string = argon2_type2string(type, 0); - if (!type_string) { - return ARGON2_INCORRECT_TYPE; - } - - CC("$"); - CC(type_string); - - /* Reading the version number if the default is suppressed */ - ctx->version = ARGON2_VERSION_10; - CC_opt("$v=", DECIMAL_U32(ctx->version)); - - CC("$m="); - DECIMAL_U32(ctx->m_cost); - CC(",t="); - DECIMAL_U32(ctx->t_cost); - CC(",p="); - DECIMAL_U32(ctx->lanes); - ctx->threads = ctx->lanes; - - CC("$"); - BIN(ctx->salt, maxsaltlen, ctx->saltlen); - CC("$"); - BIN(ctx->out, maxoutlen, ctx->outlen); - - /* The rest of the fields get the default values */ - ctx->secret = NULL; - ctx->secretlen = 0; - ctx->ad = NULL; - ctx->adlen = 0; - ctx->allocate_cbk = NULL; - ctx->free_cbk = NULL; - ctx->flags = ARGON2_DEFAULT_FLAGS; - - /* On return, must have valid context */ - validation_result = validate_inputs(ctx); - if (validation_result != ARGON2_OK) { - return validation_result; - } - - /* Can't have any additional characters */ - if (*str == 0) { - return ARGON2_OK; - } else { - return ARGON2_DECODING_FAIL; - } -#undef CC -#undef CC_opt -#undef DECIMAL -#undef BIN -} - -int encode_string(char *dst, size_t dst_len, argon2_context *ctx, - argon2_type type) { -#define SS(str) \ - do { \ - size_t pp_len = strlen(str); \ - if (pp_len >= dst_len) { \ - return ARGON2_ENCODING_FAIL; \ - } \ - memcpy(dst, str, pp_len + 1); \ - dst += pp_len; \ - dst_len -= pp_len; \ - } while ((void)0, 0) - -#define SX(x) \ - do { \ - char tmp[30]; \ - sprintf(tmp, "%lu", (unsigned long)(x)); \ - SS(tmp); \ - } while ((void)0, 0) - -#define SB(buf, len) \ - do { \ - size_t sb_len = to_base64(dst, dst_len, buf, len); \ - if (sb_len == (size_t)-1) { \ - return ARGON2_ENCODING_FAIL; \ - } \ - dst += sb_len; \ - dst_len -= sb_len; \ - } while ((void)0, 0) - - const char* type_string = argon2_type2string(type, 0); - int validation_result = validate_inputs(ctx); - - if (!type_string) { - return ARGON2_ENCODING_FAIL; - } - - if (validation_result != ARGON2_OK) { - return validation_result; - } - - - SS("$"); - SS(type_string); - - SS("$v="); - SX(ctx->version); - - SS("$m="); - SX(ctx->m_cost); - SS(",t="); - SX(ctx->t_cost); - SS(",p="); - SX(ctx->lanes); - - SS("$"); - SB(ctx->salt, ctx->saltlen); - - SS("$"); - SB(ctx->out, ctx->outlen); - return ARGON2_OK; - -#undef SS -#undef SX -#undef SB -} - -size_t b64len(uint32_t len) { - size_t olen = ((size_t)len / 3) << 2; - - switch (len % 3) { - case 2: - olen++; - /* fall through */ - case 1: - olen += 2; - break; - } - - return olen; -} - -size_t numlen(uint32_t num) { - size_t len = 1; - while (num >= 10) { - ++len; - num = num / 10; - } - return len; -} - diff --git a/deps/argon2/argon2/encoding.h b/deps/argon2/argon2/encoding.h deleted file mode 100644 index 7e83ec9285..0000000000 --- a/deps/argon2/argon2/encoding.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef ENCODING_H -#define ENCODING_H -#include "argon2.h" - -#define ARGON2_MAX_DECODED_LANES UINT32_C(255) -#define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8) -#define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12) - -/* -* encode an Argon2 hash string into the provided buffer. 'dst_len' -* contains the size, in characters, of the 'dst' buffer; if 'dst_len' -* is less than the number of required characters (including the -* terminating 0), then this function returns ARGON2_ENCODING_ERROR. -* -* on success, ARGON2_OK is returned. -*/ -int encode_string(char *dst, size_t dst_len, argon2_context *ctx, - argon2_type type); - -/* -* Decodes an Argon2 hash string into the provided structure 'ctx'. -* The only fields that must be set prior to this call are ctx.saltlen and -* ctx.outlen (which must be the maximal salt and out length values that are -* allowed), ctx.salt and ctx.out (which must be buffers of the specified -* length), and ctx.pwd and ctx.pwdlen which must hold a valid password. -* -* Invalid input string causes an error. On success, the ctx is valid and all -* fields have been initialized. -* -* Returned value is ARGON2_OK on success, other ARGON2_ codes on error. -*/ -int decode_string(argon2_context *ctx, const char *str, argon2_type type); - -/* Returns the length of the encoded byte stream with length len */ -size_t b64len(uint32_t len); - -/* Returns the length of the encoded number num */ -size_t numlen(uint32_t num); - -#endif diff --git a/deps/argon2/argon2/opt.c b/deps/argon2/argon2/opt.c deleted file mode 100644 index f6c20528e4..0000000000 --- a/deps/argon2/argon2/opt.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include - -#include "argon2.h" -#include "core.h" - -#include "blake2/blake2.h" -#include "blake2/blamka-round-opt.h" - -/* - * Function fills a new memory block and optionally XORs the old block over the new one. - * Memory must be initialized. - * @param state Pointer to the just produced block. Content will be updated(!) - * @param ref_block Pointer to the reference block - * @param next_block Pointer to the block to be XORed over. May coincide with @ref_block - * @param with_xor Whether to XOR into the new block (1) or just overwrite (0) - * @pre all block pointers must be valid - */ -#if defined(__AVX512F__) -static void fill_block(__m512i *state, const block *ref_block, - block *next_block, int with_xor) { - __m512i block_XY[ARGON2_512BIT_WORDS_IN_BLOCK]; - unsigned int i; - - if (with_xor) { - for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { - state[i] = _mm512_xor_si512( - state[i], _mm512_loadu_si512((const __m512i *)ref_block->v + i)); - block_XY[i] = _mm512_xor_si512( - state[i], _mm512_loadu_si512((const __m512i *)next_block->v + i)); - } - } else { - for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { - block_XY[i] = state[i] = _mm512_xor_si512( - state[i], _mm512_loadu_si512((const __m512i *)ref_block->v + i)); - } - } - - for (i = 0; i < 2; ++i) { - BLAKE2_ROUND_1( - state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], state[8 * i + 3], - state[8 * i + 4], state[8 * i + 5], state[8 * i + 6], state[8 * i + 7]); - } - - for (i = 0; i < 2; ++i) { - BLAKE2_ROUND_2( - state[2 * 0 + i], state[2 * 1 + i], state[2 * 2 + i], state[2 * 3 + i], - state[2 * 4 + i], state[2 * 5 + i], state[2 * 6 + i], state[2 * 7 + i]); - } - - for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { - state[i] = _mm512_xor_si512(state[i], block_XY[i]); - _mm512_storeu_si512((__m512i *)next_block->v + i, state[i]); - } -} -#elif defined(__AVX2__) -static void fill_block(__m256i *state, const block *ref_block, - block *next_block, int with_xor) { - __m256i block_XY[ARGON2_HWORDS_IN_BLOCK]; - unsigned int i; - - if (with_xor) { - for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { - state[i] = _mm256_xor_si256( - state[i], _mm256_loadu_si256((const __m256i *)ref_block->v + i)); - block_XY[i] = _mm256_xor_si256( - state[i], _mm256_loadu_si256((const __m256i *)next_block->v + i)); - } - } else { - for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { - block_XY[i] = state[i] = _mm256_xor_si256( - state[i], _mm256_loadu_si256((const __m256i *)ref_block->v + i)); - } - } - - for (i = 0; i < 4; ++i) { - BLAKE2_ROUND_1(state[8 * i + 0], state[8 * i + 4], state[8 * i + 1], state[8 * i + 5], - state[8 * i + 2], state[8 * i + 6], state[8 * i + 3], state[8 * i + 7]); - } - - for (i = 0; i < 4; ++i) { - BLAKE2_ROUND_2(state[ 0 + i], state[ 4 + i], state[ 8 + i], state[12 + i], - state[16 + i], state[20 + i], state[24 + i], state[28 + i]); - } - - for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { - state[i] = _mm256_xor_si256(state[i], block_XY[i]); - _mm256_storeu_si256((__m256i *)next_block->v + i, state[i]); - } -} -#else -static void fill_block(__m128i *state, const block *ref_block, - block *next_block, int with_xor) { - __m128i block_XY[ARGON2_OWORDS_IN_BLOCK]; - unsigned int i; - - if (with_xor) { - for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { - state[i] = _mm_xor_si128( - state[i], _mm_loadu_si128((const __m128i *)ref_block->v + i)); - block_XY[i] = _mm_xor_si128( - state[i], _mm_loadu_si128((const __m128i *)next_block->v + i)); - } - } else { - for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { - block_XY[i] = state[i] = _mm_xor_si128( - state[i], _mm_loadu_si128((const __m128i *)ref_block->v + i)); - } - } - - for (i = 0; i < 8; ++i) { - BLAKE2_ROUND(state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], - state[8 * i + 3], state[8 * i + 4], state[8 * i + 5], - state[8 * i + 6], state[8 * i + 7]); - } - - for (i = 0; i < 8; ++i) { - BLAKE2_ROUND(state[8 * 0 + i], state[8 * 1 + i], state[8 * 2 + i], - state[8 * 3 + i], state[8 * 4 + i], state[8 * 5 + i], - state[8 * 6 + i], state[8 * 7 + i]); - } - - for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { - state[i] = _mm_xor_si128(state[i], block_XY[i]); - _mm_storeu_si128((__m128i *)next_block->v + i, state[i]); - } -} -#endif - -static void next_addresses(block *address_block, block *input_block) { - /*Temporary zero-initialized blocks*/ -#if defined(__AVX512F__) - __m512i zero_block[ARGON2_512BIT_WORDS_IN_BLOCK]; - __m512i zero2_block[ARGON2_512BIT_WORDS_IN_BLOCK]; -#elif defined(__AVX2__) - __m256i zero_block[ARGON2_HWORDS_IN_BLOCK]; - __m256i zero2_block[ARGON2_HWORDS_IN_BLOCK]; -#else - __m128i zero_block[ARGON2_OWORDS_IN_BLOCK]; - __m128i zero2_block[ARGON2_OWORDS_IN_BLOCK]; -#endif - - memset(zero_block, 0, sizeof(zero_block)); - memset(zero2_block, 0, sizeof(zero2_block)); - - /*Increasing index counter*/ - input_block->v[6]++; - - /*First iteration of G*/ - fill_block(zero_block, input_block, address_block, 0); - - /*Second iteration of G*/ - fill_block(zero2_block, address_block, address_block, 0); -} - -void fill_segment(const argon2_instance_t *instance, - argon2_position_t position) { - block *ref_block = NULL, *curr_block = NULL; - block address_block, input_block; - uint64_t pseudo_rand, ref_index, ref_lane; - uint32_t prev_offset, curr_offset; - uint32_t starting_index, i; -#if defined(__AVX512F__) - __m512i state[ARGON2_512BIT_WORDS_IN_BLOCK]; -#elif defined(__AVX2__) - __m256i state[ARGON2_HWORDS_IN_BLOCK]; -#else - __m128i state[ARGON2_OWORDS_IN_BLOCK]; -#endif - int data_independent_addressing; - - if (instance == NULL) { - return; - } - - data_independent_addressing = - (instance->type == Argon2_i) || - (instance->type == Argon2_id && (position.pass == 0) && - (position.slice < ARGON2_SYNC_POINTS / 2)); - - if (data_independent_addressing) { - init_block_value(&input_block, 0); - - input_block.v[0] = position.pass; - input_block.v[1] = position.lane; - input_block.v[2] = position.slice; - input_block.v[3] = instance->memory_blocks; - input_block.v[4] = instance->passes; - input_block.v[5] = instance->type; - } - - starting_index = 0; - - if ((0 == position.pass) && (0 == position.slice)) { - starting_index = 2; /* we have already generated the first two blocks */ - - /* Don't forget to generate the first block of addresses: */ - if (data_independent_addressing) { - next_addresses(&address_block, &input_block); - } - } - - /* Offset of the current block */ - curr_offset = position.lane * instance->lane_length + - position.slice * instance->segment_length + starting_index; - - if (0 == curr_offset % instance->lane_length) { - /* Last block in this lane */ - prev_offset = curr_offset + instance->lane_length - 1; - } else { - /* Previous block */ - prev_offset = curr_offset - 1; - } - - memcpy(state, ((instance->memory + prev_offset)->v), ARGON2_BLOCK_SIZE); - - for (i = starting_index; i < instance->segment_length; - ++i, ++curr_offset, ++prev_offset) { - /*1.1 Rotating prev_offset if needed */ - if (curr_offset % instance->lane_length == 1) { - prev_offset = curr_offset - 1; - } - - /* 1.2 Computing the index of the reference block */ - /* 1.2.1 Taking pseudo-random value from the previous block */ - if (data_independent_addressing) { - if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) { - next_addresses(&address_block, &input_block); - } - pseudo_rand = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK]; - } else { - pseudo_rand = instance->memory[prev_offset].v[0]; - } - - /* 1.2.2 Computing the lane of the reference block */ - ref_lane = ((pseudo_rand >> 32)) % instance->lanes; - - if ((position.pass == 0) && (position.slice == 0)) { - /* Can not reference other lanes yet */ - ref_lane = position.lane; - } - - /* 1.2.3 Computing the number of possible reference block within the - * lane. - */ - position.index = i; - ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF, - ref_lane == position.lane); - - /* 2 Creating a new block */ - ref_block = - instance->memory + instance->lane_length * ref_lane + ref_index; - curr_block = instance->memory + curr_offset; - if (ARGON2_VERSION_10 == instance->version) { - /* version 1.2.1 and earlier: overwrite, not XOR */ - fill_block(state, ref_block, curr_block, 0); - } else { - if(0 == position.pass) { - fill_block(state, ref_block, curr_block, 0); - } else { - fill_block(state, ref_block, curr_block, 1); - } - } - } -} diff --git a/deps/argon2/argon2/ref.c b/deps/argon2/argon2/ref.c deleted file mode 100644 index ad1cf461f9..0000000000 --- a/deps/argon2/argon2/ref.c +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include - -#include "argon2.h" -#include "core.h" - -#include "blake2/blamka-round-ref.h" -#include "blake2/blake2-impl.h" -#include "blake2/blake2.h" - - -/* - * Function fills a new memory block and optionally XORs the old block over the new one. - * @next_block must be initialized. - * @param prev_block Pointer to the previous block - * @param ref_block Pointer to the reference block - * @param next_block Pointer to the block to be constructed - * @param with_xor Whether to XOR into the new block (1) or just overwrite (0) - * @pre all block pointers must be valid - */ -static void fill_block(const block *prev_block, const block *ref_block, - block *next_block, int with_xor) { - block blockR, block_tmp; - unsigned i; - - copy_block(&blockR, ref_block); - xor_block(&blockR, prev_block); - copy_block(&block_tmp, &blockR); - /* Now blockR = ref_block + prev_block and block_tmp = ref_block + prev_block */ - if (with_xor) { - /* Saving the next block contents for XOR over: */ - xor_block(&block_tmp, next_block); - /* Now blockR = ref_block + prev_block and - block_tmp = ref_block + prev_block + next_block */ - } - - /* Apply Blake2 on columns of 64-bit words: (0,1,...,15) , then - (16,17,..31)... finally (112,113,...127) */ - for (i = 0; i < 8; ++i) { - BLAKE2_ROUND_NOMSG( - blockR.v[16 * i], blockR.v[16 * i + 1], blockR.v[16 * i + 2], - blockR.v[16 * i + 3], blockR.v[16 * i + 4], blockR.v[16 * i + 5], - blockR.v[16 * i + 6], blockR.v[16 * i + 7], blockR.v[16 * i + 8], - blockR.v[16 * i + 9], blockR.v[16 * i + 10], blockR.v[16 * i + 11], - blockR.v[16 * i + 12], blockR.v[16 * i + 13], blockR.v[16 * i + 14], - blockR.v[16 * i + 15]); - } - - /* Apply Blake2 on rows of 64-bit words: (0,1,16,17,...112,113), then - (2,3,18,19,...,114,115).. finally (14,15,30,31,...,126,127) */ - for (i = 0; i < 8; i++) { - BLAKE2_ROUND_NOMSG( - blockR.v[2 * i], blockR.v[2 * i + 1], blockR.v[2 * i + 16], - blockR.v[2 * i + 17], blockR.v[2 * i + 32], blockR.v[2 * i + 33], - blockR.v[2 * i + 48], blockR.v[2 * i + 49], blockR.v[2 * i + 64], - blockR.v[2 * i + 65], blockR.v[2 * i + 80], blockR.v[2 * i + 81], - blockR.v[2 * i + 96], blockR.v[2 * i + 97], blockR.v[2 * i + 112], - blockR.v[2 * i + 113]); - } - - copy_block(next_block, &block_tmp); - xor_block(next_block, &blockR); -} - -static void next_addresses(block *address_block, block *input_block, - const block *zero_block) { - input_block->v[6]++; - fill_block(zero_block, input_block, address_block, 0); - fill_block(zero_block, address_block, address_block, 0); -} - -void fill_segment(const argon2_instance_t *instance, - argon2_position_t position) { - block *ref_block = NULL, *curr_block = NULL; - block address_block, input_block, zero_block; - uint64_t pseudo_rand, ref_index, ref_lane; - uint32_t prev_offset, curr_offset; - uint32_t starting_index; - uint32_t i; - int data_independent_addressing; - - if (instance == NULL) { - return; - } - - data_independent_addressing = - (instance->type == Argon2_i) || - (instance->type == Argon2_id && (position.pass == 0) && - (position.slice < ARGON2_SYNC_POINTS / 2)); - - if (data_independent_addressing) { - init_block_value(&zero_block, 0); - init_block_value(&input_block, 0); - - input_block.v[0] = position.pass; - input_block.v[1] = position.lane; - input_block.v[2] = position.slice; - input_block.v[3] = instance->memory_blocks; - input_block.v[4] = instance->passes; - input_block.v[5] = instance->type; - } - - starting_index = 0; - - if ((0 == position.pass) && (0 == position.slice)) { - starting_index = 2; /* we have already generated the first two blocks */ - - /* Don't forget to generate the first block of addresses: */ - if (data_independent_addressing) { - next_addresses(&address_block, &input_block, &zero_block); - } - } - - /* Offset of the current block */ - curr_offset = position.lane * instance->lane_length + - position.slice * instance->segment_length + starting_index; - - if (0 == curr_offset % instance->lane_length) { - /* Last block in this lane */ - prev_offset = curr_offset + instance->lane_length - 1; - } else { - /* Previous block */ - prev_offset = curr_offset - 1; - } - - for (i = starting_index; i < instance->segment_length; - ++i, ++curr_offset, ++prev_offset) { - /*1.1 Rotating prev_offset if needed */ - if (curr_offset % instance->lane_length == 1) { - prev_offset = curr_offset - 1; - } - - /* 1.2 Computing the index of the reference block */ - /* 1.2.1 Taking pseudo-random value from the previous block */ - if (data_independent_addressing) { - if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) { - next_addresses(&address_block, &input_block, &zero_block); - } - pseudo_rand = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK]; - } else { - pseudo_rand = instance->memory[prev_offset].v[0]; - } - - /* 1.2.2 Computing the lane of the reference block */ - ref_lane = ((pseudo_rand >> 32)) % instance->lanes; - - if ((position.pass == 0) && (position.slice == 0)) { - /* Can not reference other lanes yet */ - ref_lane = position.lane; - } - - /* 1.2.3 Computing the number of possible reference block within the - * lane. - */ - position.index = i; - ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF, - ref_lane == position.lane); - - /* 2 Creating a new block */ - ref_block = - instance->memory + instance->lane_length * ref_lane + ref_index; - curr_block = instance->memory + curr_offset; - if (ARGON2_VERSION_10 == instance->version) { - /* version 1.2.1 and earlier: overwrite, not XOR */ - fill_block(instance->memory + prev_offset, ref_block, curr_block, 0); - } else { - if(0 == position.pass) { - fill_block(instance->memory + prev_offset, ref_block, - curr_block, 0); - } else { - fill_block(instance->memory + prev_offset, ref_block, - curr_block, 1); - } - } - } -} diff --git a/deps/argon2/argon2/thread.c b/deps/argon2/argon2/thread.c deleted file mode 100644 index e099a00d21..0000000000 --- a/deps/argon2/argon2/thread.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#if !defined(ARGON2_NO_THREADS) - -#include "thread.h" -#if defined(_WIN32) -#include -#endif - -int argon2_thread_create(argon2_thread_handle_t *handle, - argon2_thread_func_t func, void *args) { - if (NULL == handle || func == NULL) { - return -1; - } -#if defined(_WIN32) - *handle = _beginthreadex(NULL, 0, func, args, 0, NULL); - return *handle != 0 ? 0 : -1; -#else - return pthread_create(handle, NULL, func, args); -#endif -} - -int argon2_thread_join(argon2_thread_handle_t handle) { -#if defined(_WIN32) - if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) { - return CloseHandle((HANDLE)handle) != 0 ? 0 : -1; - } - return -1; -#else - return pthread_join(handle, NULL); -#endif -} - -void argon2_thread_exit(void) { -#if defined(_WIN32) - _endthreadex(0); -#else - pthread_exit(NULL); -#endif -} - -#endif /* ARGON2_NO_THREADS */ diff --git a/deps/argon2/argon2/thread.h b/deps/argon2/argon2/thread.h deleted file mode 100644 index 49d88367b4..0000000000 --- a/deps/argon2/argon2/thread.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef ARGON2_THREAD_H -#define ARGON2_THREAD_H - -#if !defined(ARGON2_NO_THREADS) - -/* - Here we implement an abstraction layer for the simpĺe requirements - of the Argon2 code. We only require 3 primitives---thread creation, - joining, and termination---so full emulation of the pthreads API - is unwarranted. Currently we wrap pthreads and Win32 threads. - - The API defines 2 types: the function pointer type, - argon2_thread_func_t, - and the type of the thread handle---argon2_thread_handle_t. -*/ -#if defined(_WIN32) -#include -typedef unsigned(__stdcall *argon2_thread_func_t)(void *); -typedef uintptr_t argon2_thread_handle_t; -#else -#include -typedef void *(*argon2_thread_func_t)(void *); -typedef pthread_t argon2_thread_handle_t; -#endif - -/* Creates a thread - * @param handle pointer to a thread handle, which is the output of this - * function. Must not be NULL. - * @param func A function pointer for the thread's entry point. Must not be - * NULL. - * @param args Pointer that is passed as an argument to @func. May be NULL. - * @return 0 if @handle and @func are valid pointers and a thread is successfully - * created. - */ -int argon2_thread_create(argon2_thread_handle_t *handle, - argon2_thread_func_t func, void *args); - -/* Waits for a thread to terminate - * @param handle Handle to a thread created with argon2_thread_create. - * @return 0 if @handle is a valid handle, and joining completed successfully. -*/ -int argon2_thread_join(argon2_thread_handle_t handle); - -/* Terminate the current thread. Must be run inside a thread created by - * argon2_thread_create. -*/ -void argon2_thread_exit(void); - -#endif /* ARGON2_NO_THREADS */ -#endif diff --git a/deps/gperftools/CMakeLists.txt b/deps/gperftools/CMakeLists.txt deleted file mode 100644 index f69cfe5b09..0000000000 --- a/deps/gperftools/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# -# Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 -# - -add_library(gperftools INTERFACE) - -target_link_libraries(gperftools - INTERFACE - ${GPERFTOOLS_LIBRARIES}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index c719eab0e3..ebd34fe98f 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -52,7 +52,6 @@ target_link_libraries(common PUBLIC acore-core-interface ace - argon2 g3dlib Detour sfmt diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp index a7aa1ccb78..777d59bedd 100644 --- a/src/common/Configuration/Config.cpp +++ b/src/common/Configuration/Config.cpp @@ -20,39 +20,6 @@ namespace std::unordered_map _configOptions; std::mutex _configLock; - // Check system configs like *server.conf* - bool IsAppConfig(std::string_view fileName) - { - size_t found = fileName.find_first_of("authserver.conf"); - if (found != std::string::npos) - { - return true; - } - - found = fileName.find_first_of("worldserver.conf"); - if (found != std::string::npos) - { - return true; - } - - return false; - } - - template - inline void PrintError(std::string_view filename, Format&& fmt, Args&& ... args) - { - std::string message = acore::StringFormat(std::forward(fmt), std::forward(args)...); - - if (IsAppConfig(filename)) - { - printf("%s\n", message.c_str()); - } - else - { - LOG_ERROR("server.loading", "%s", message.c_str()); - } - } - void AddKey(std::string const& optionName, std::string const& optionKey, bool replace = true) { auto const& itr = _configOptions.find(optionName); @@ -75,25 +42,10 @@ namespace std::ifstream in(file); if (in.fail()) - { throw ConfigException(acore::StringFormat("Config::LoadFile: Failed open file '%s'", file.c_str())); - } uint32 count = 0; uint32 lineNumber = 0; - std::unordered_map fileConfigs; - - auto IsDuplicateOption = [&](std::string const& confOption) - { - auto const& itr = fileConfigs.find(confOption); - if (itr != fileConfigs.end()) - { - PrintError(file, "> Config::LoadFile: Dublicate key name '%s' in config file '%s'", std::string(confOption).c_str(), file.c_str()); - return true; - } - - return false; - }; while (in.good()) { @@ -101,65 +53,38 @@ namespace std::string line; std::getline(in, line); - // read line error - if (!in.good() && !in.eof()) - { - throw ConfigException(acore::StringFormat("> Config::LoadFile: Failure to read line number %u in file '%s'", lineNumber, file.c_str())); - } - - // remove whitespace in line - line = acore::String::Trim(line, in.getloc()); - if (line.empty()) - { continue; - } + + line = acore::String::Trim(line, in.getloc()); // comments if (line[0] == '#' || line[0] == '[') - { continue; - } size_t found = line.find_first_of('#'); if (found != std::string::npos) - { line = line.substr(0, found); - } auto const equal_pos = line.find('='); if (equal_pos == std::string::npos || equal_pos == line.length()) { - PrintError(file, "> Config::LoadFile: Failure to read line number %u in file '%s'. Skip this line", lineNumber, file.c_str()); - continue; + ABORT_MSG("> Config::LoadFile: Failure to read line number %u. Don't use only whitespace lines", lineNumber); } auto entry = acore::String::Trim(line.substr(0, equal_pos), in.getloc()); - auto value = acore::String::Trim(line.substr(equal_pos + 1, std::string::npos), in.getloc()); + auto value = acore::String::Trim(line.substr(equal_pos + 1), in.getloc()); value.erase(std::remove(value.begin(), value.end(), '"'), value.end()); - // Skip if 2+ same options in one config file - if (IsDuplicateOption(entry)) - { - continue; - } + AddKey(entry, value); - // Add to temp container - fileConfigs.emplace(entry, value); count++; } - // No lines read if (!count) throw ConfigException(acore::StringFormat("Config::LoadFile: Empty file '%s'", file.c_str())); - - // Add correct keys if file load without errors - for (auto const& [entry, key] : fileConfigs) - { - AddKey(entry, key); - } } bool LoadFile(std::string const& file) @@ -171,7 +96,7 @@ namespace } catch (const std::exception& e) { - PrintError(file, "> %s", e.what()); + LOG_ERROR("server", "> Config: %s", e.what()); } return false; diff --git a/src/common/Containers.h b/src/common/Containers.h index 7a6674063a..5eaa4d1be3 100644 --- a/src/common/Containers.h +++ b/src/common/Containers.h @@ -64,63 +64,33 @@ namespace acore namespace Containers { - // replace with std::size in C++17 - template - constexpr inline std::size_t Size(C const& container) + template + void RandomResizeList(std::list& list, uint32 size) { - return container.size(); - } + size_t list_size = list.size(); - template - constexpr inline std::size_t Size(T const(&)[size]) noexcept - { - return size; - } - - // resizes to have at most elements - // if it has more than elements, the elements to keep are selected randomly - template - void RandomResize(C& container, std::size_t requestedSize) - { - static_assert(std::is_base_of::iterator_category>::value, "Invalid container passed to acore::Containers::RandomResize"); - if (Size(container) <= requestedSize) + while (list_size > size) { - return; + typename std::list::iterator itr = list.begin(); + std::advance(itr, urand(0, list_size - 1)); + list.erase(itr); + --list_size; } - - auto keepIt = std::begin(container), curIt = std::begin(container); - uint32 elementsToKeep = requestedSize, elementsToProcess = Size(container); - while (elementsToProcess) - { - // this element has chance (elementsToKeep / elementsToProcess) of being kept - if (urand(1, elementsToProcess) <= elementsToKeep) - { - if (keepIt != curIt) - *keepIt = std::move(*curIt); - ++keepIt; - --elementsToKeep; - } - - ++curIt; - --elementsToProcess; - } - - container.erase(keepIt, std::end(container)); } - template - void RandomResize(C& container, Predicate&& predicate, std::size_t requestedSize) + template + void RandomResizeList(std::list& list, Predicate& predicate, uint32 size) { //! First use predicate filter - C containerCopy; - std::copy_if(std::begin(container), std::end(container), std::inserter(containerCopy, std::end(containerCopy)), predicate); + std::list listCopy; + for (typename std::list::iterator itr = list.begin(); itr != list.end(); ++itr) + if (predicate(*itr)) + listCopy.push_back(*itr); - if (requestedSize) - { - RandomResize(containerCopy, requestedSize); - } + if (size) + RandomResizeList(listCopy, size); - container = std::move(containerCopy); + list = listCopy; } /* Select a random element from a container. Note: make sure you explicitly empty check the container */ diff --git a/src/common/Cryptography/AES.cpp b/src/common/Cryptography/AES.cpp deleted file mode 100644 index 4614342320..0000000000 --- a/src/common/Cryptography/AES.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#include "AES.h" -#include "Errors.h" -#include - -acore::Crypto::AES::AES(bool encrypting) : _ctx(EVP_CIPHER_CTX_new()), _encrypting(encrypting) -{ - EVP_CIPHER_CTX_init(_ctx); - int status = EVP_CipherInit_ex(_ctx, EVP_aes_128_gcm(), nullptr, nullptr, nullptr, _encrypting ? 1 : 0); - ASSERT(status); -} - -acore::Crypto::AES::~AES() -{ - EVP_CIPHER_CTX_free(_ctx); -} - -void acore::Crypto::AES::Init(Key const& key) -{ - int status = EVP_CipherInit_ex(_ctx, nullptr, nullptr, key.data(), nullptr, -1); - ASSERT(status); -} - -bool acore::Crypto::AES::Process(IV const& iv, uint8* data, size_t length, Tag& tag) -{ - ASSERT(length <= static_cast(std::numeric_limits::max())); - int len = static_cast(length); - if (!EVP_CipherInit_ex(_ctx, nullptr, nullptr, nullptr, iv.data(), -1)) - return false; - - int outLen; - if (!EVP_CipherUpdate(_ctx, data, &outLen, data, len)) - return false; - - len -= outLen; - - if (!_encrypting && !EVP_CIPHER_CTX_ctrl(_ctx, EVP_CTRL_GCM_SET_TAG, sizeof(tag), tag)) - return false; - - if (!EVP_CipherFinal_ex(_ctx, data + outLen, &outLen)) - return false; - - ASSERT(len == outLen); - - if (_encrypting && !EVP_CIPHER_CTX_ctrl(_ctx, EVP_CTRL_GCM_GET_TAG, sizeof(tag), tag)) - return false; - - return true; -} diff --git a/src/common/Cryptography/AES.h b/src/common/Cryptography/AES.h deleted file mode 100644 index 13fd42fd7c..0000000000 --- a/src/common/Cryptography/AES.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#ifndef Warhead_AES_h__ -#define Warhead_AES_h__ - -#include "Define.h" -#include -#include - -namespace acore::Crypto -{ - class AC_COMMON_API AES - { - public: - static constexpr size_t IV_SIZE_BYTES = 12; - static constexpr size_t KEY_SIZE_BYTES = 16; - static constexpr size_t TAG_SIZE_BYTES = 12; - - using IV = std::array; - using Key = std::array; - using Tag = uint8[TAG_SIZE_BYTES]; - - AES(bool encrypting); - ~AES(); - - void Init(Key const& key); - - bool Process(IV const& iv, uint8* data, size_t length, Tag& tag); - - private: - EVP_CIPHER_CTX* _ctx; - bool _encrypting; - }; -} - -#endif // Warhead_AES_h__ diff --git a/src/common/Cryptography/ARC4.h b/src/common/Cryptography/ARC4.h index f5add88553..4ed8876e02 100644 --- a/src/common/Cryptography/ARC4.h +++ b/src/common/Cryptography/ARC4.h @@ -8,6 +8,7 @@ #define _AUTH_SARC4_H #include "Define.h" + #include #include @@ -15,19 +16,19 @@ namespace acore::Crypto { class ARC4 { - public: - ARC4(); - ~ARC4(); + public: + ARC4(); + ~ARC4(); - void Init(uint8 const* seed, size_t len); - template - void Init(Container const& c) { Init(std::data(c), std::size(c)); } + void Init(uint8 const* seed, size_t len); + template + void Init(Container const& c) { Init(std::data(c), std::size(c)); } - void UpdateData(uint8* data, size_t len); - template - void UpdateData(Container& c) { UpdateData(std::data(c), std::size(c)); } - private: - EVP_CIPHER_CTX* _ctx; + void UpdateData(uint8* data, size_t len); + template + void UpdateData(Container& c) { UpdateData(std::data(c), std::size(c)); } + private: + EVP_CIPHER_CTX* _ctx; }; } diff --git a/src/common/Cryptography/Argon2.cpp b/src/common/Cryptography/Argon2.cpp deleted file mode 100644 index 4e9e2d6ae9..0000000000 --- a/src/common/Cryptography/Argon2.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#include "Argon2.h" -#include - -/*static*/ Optional acore::Crypto::Argon2::Hash(std::string const& password, BigNumber const& salt, uint32 nIterations, uint32 kibMemoryCost) -{ - char buf[ENCODED_HASH_LEN]; - std::vector saltBytes = salt.ToByteVector(); - int status = argon2id_hash_encoded( - nIterations, - kibMemoryCost, - PARALLELISM, - password.c_str(), password.length(), - saltBytes.data(), saltBytes.size(), - HASH_LEN, buf, ENCODED_HASH_LEN - ); - - if (status == ARGON2_OK) - return std::string(buf); - - return {}; -} - -/*static*/ bool acore::Crypto::Argon2::Verify(std::string const& password, std::string const& hash) -{ - int status = argon2id_verify(hash.c_str(), password.c_str(), password.length()); - return (status == ARGON2_OK); -} diff --git a/src/common/Cryptography/Argon2.h b/src/common/Cryptography/Argon2.h deleted file mode 100644 index 73be1d5ffc..0000000000 --- a/src/common/Cryptography/Argon2.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#ifndef WARHEAD_ARGON2_H -#define WARHEAD_ARGON2_H - -#include "BigNumber.h" -#include "Define.h" -#include "Optional.h" -#include - -namespace acore::Crypto -{ - struct AC_COMMON_API Argon2 - { - static constexpr uint32 HASH_LEN = 16; // 128 bits, in bytes - static constexpr uint32 ENCODED_HASH_LEN = 100; // in chars - static constexpr uint32 DEFAULT_ITERATIONS = 10; // determined by dice roll, guaranteed to be secure (not really) - static constexpr uint32 DEFAULT_MEMORY_COST = (1u << 17); // 2^17 kibibytes is 2^7 mebibytes is ~100MB - static constexpr uint32 PARALLELISM = 1; // we don't support threaded hashing - - static Optional Hash(std::string const& password, BigNumber const& salt, uint32 nIterations = DEFAULT_ITERATIONS, uint32 kibMemoryCost = DEFAULT_MEMORY_COST); - static bool Verify(std::string const& password, std::string const& hash); - }; -} - -#endif diff --git a/src/common/Cryptography/Authentication/AuthDefines.h b/src/common/Cryptography/AuthDefines.h similarity index 100% rename from src/common/Cryptography/Authentication/AuthDefines.h rename to src/common/Cryptography/AuthDefines.h diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp index bc954192ca..5bc634f83f 100644 --- a/src/common/Cryptography/BigNumber.cpp +++ b/src/common/Cryptography/BigNumber.cpp @@ -1,22 +1,23 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. - * Copyright (C) 2021+ WarheadCore + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2008-2016 TrinityCore + * Copyright (C) 2005-2009 MaNGOS */ #include "Cryptography/BigNumber.h" -#include "Errors.h" #include -#include +#include #include -#include BigNumber::BigNumber() : _bn(BN_new()) -{ } +{ +} BigNumber::BigNumber(BigNumber const& bn) : _bn(BN_dup(bn.BN())) -{ } +{ +} BigNumber::~BigNumber() { @@ -63,10 +64,9 @@ void BigNumber::SetBinary(uint8 const* bytes, int32 len, bool littleEndian) BN_bin2bn(bytes, len, _bn); } -bool BigNumber::SetHexStr(char const* str) +void BigNumber::SetHexStr(char const* str) { - int n = BN_hex2bn(&_bn, str); - return (n > 0); + BN_hex2bn(&_bn, str); } void BigNumber::SetRand(int32 numbits) @@ -83,19 +83,19 @@ BigNumber& BigNumber::operator=(BigNumber const& bn) return *this; } -BigNumber& BigNumber::operator+=(BigNumber const& bn) +BigNumber BigNumber::operator+=(BigNumber const& bn) { BN_add(_bn, _bn, bn._bn); return *this; } -BigNumber& BigNumber::operator-=(BigNumber const& bn) +BigNumber BigNumber::operator-=(BigNumber const& bn) { BN_sub(_bn, _bn, bn._bn); return *this; } -BigNumber& BigNumber::operator*=(BigNumber const& bn) +BigNumber BigNumber::operator*=(BigNumber const& bn) { BN_CTX* bnctx; @@ -106,7 +106,7 @@ BigNumber& BigNumber::operator*=(BigNumber const& bn) return *this; } -BigNumber& BigNumber::operator/=(BigNumber const& bn) +BigNumber BigNumber::operator/=(BigNumber const& bn) { BN_CTX* bnctx; @@ -117,7 +117,7 @@ BigNumber& BigNumber::operator/=(BigNumber const& bn) return *this; } -BigNumber& BigNumber::operator%=(BigNumber const& bn) +BigNumber BigNumber::operator%=(BigNumber const& bn) { BN_CTX* bnctx; @@ -128,17 +128,6 @@ BigNumber& BigNumber::operator%=(BigNumber const& bn) return *this; } -BigNumber& BigNumber::operator<<=(int n) -{ - BN_lshift(_bn, _bn, n); - return *this; -} - -int BigNumber::CompareTo(BigNumber const& bn) const -{ - return BN_cmp(_bn, bn._bn); -} - BigNumber BigNumber::Exp(BigNumber const& bn) const { BigNumber ret; @@ -168,21 +157,16 @@ int32 BigNumber::GetNumBytes() const return BN_num_bytes(_bn); } -uint32 BigNumber::AsDword() const +uint32 BigNumber::AsDword() { return (uint32)BN_get_word(_bn); } -bool BigNumber::IsZero() const +bool BigNumber::isZero() const { return BN_is_zero(_bn); } -bool BigNumber::IsNegative() const -{ - return BN_is_negative(_bn); -} - void BigNumber::GetBytes(uint8* buf, size_t bufsize, bool littleEndian) const { #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x10100000L @@ -217,18 +201,12 @@ std::vector BigNumber::ToByteVector(int32 minSize, bool littleEndian) con return v; } -std::string BigNumber::AsHexStr() const +char* BigNumber::AsHexStr() const { - char* ch = BN_bn2hex(_bn); - std::string ret = ch; - OPENSSL_free(ch); - return ret; + return BN_bn2hex(_bn); } -std::string BigNumber::AsDecStr() const +char* BigNumber::AsDecStr() const { - char* ch = BN_bn2dec(_bn); - std::string ret = ch; - OPENSSL_free(ch); - return ret; + return BN_bn2dec(_bn); } diff --git a/src/common/Cryptography/BigNumber.h b/src/common/Cryptography/BigNumber.h index 50bd42a366..d2fbd7b781 100644 --- a/src/common/Cryptography/BigNumber.h +++ b/src/common/Cryptography/BigNumber.h @@ -1,12 +1,14 @@ /* - * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. - * Copyright (C) 2021+ WarheadCore + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2008-2016 TrinityCore + * Copyright (C) 2005-2009 MaNGOS */ #ifndef _AUTH_BIGNUMBER_H #define _AUTH_BIGNUMBER_H #include "Define.h" +#include "Errors.h" #include #include #include @@ -14,7 +16,7 @@ struct bignum_st; -class AC_COMMON_API BigNumber +class BigNumber { public: BigNumber(); @@ -22,8 +24,7 @@ public: BigNumber(uint32 v) : BigNumber() { SetDword(v); } BigNumber(int32 v) : BigNumber() { SetDword(v); } BigNumber(std::string const& v) : BigNumber() { SetHexStr(v); } - - template + template BigNumber(std::array const& v, bool littleEndian = true) : BigNumber() { SetBinary(v.data(), Size, littleEndian); } ~BigNumber(); @@ -32,68 +33,51 @@ public: void SetDword(uint32); void SetQword(uint64); void SetBinary(uint8 const* bytes, int32 len, bool littleEndian = true); - - template + template auto SetBinary(Container const& c, bool littleEndian = true) -> std::enable_if_t>> { SetBinary(std::data(c), std::size(c), littleEndian); } - - bool SetHexStr(char const* str); - bool SetHexStr(std::string const& str) { return SetHexStr(str.c_str()); } + void SetHexStr(char const* str); + void SetHexStr(std::string const& str) { SetHexStr(str.c_str()); } void SetRand(int32 numbits); BigNumber& operator=(BigNumber const& bn); - BigNumber& operator+=(BigNumber const& bn); + BigNumber operator+=(BigNumber const& bn); BigNumber operator+(BigNumber const& bn) const { BigNumber t(*this); return t += bn; } - BigNumber& operator-=(BigNumber const& bn); + BigNumber operator-=(BigNumber const& bn); BigNumber operator-(BigNumber const& bn) const { BigNumber t(*this); return t -= bn; } - BigNumber& operator*=(BigNumber const& bn); + BigNumber operator*=(BigNumber const& bn); BigNumber operator*(BigNumber const& bn) const { BigNumber t(*this); return t *= bn; } - BigNumber& operator/=(BigNumber const& bn); + BigNumber operator/=(BigNumber const& bn); BigNumber operator/(BigNumber const& bn) const { BigNumber t(*this); return t /= bn; } - BigNumber& operator%=(BigNumber const& bn); + BigNumber operator%=(BigNumber const& bn); BigNumber operator%(BigNumber const& bn) const { BigNumber t(*this); return t %= bn; } - BigNumber& operator<<=(int n); - BigNumber operator<<(int n) const - { - BigNumber t(*this); - return t <<= n; - } - - int CompareTo(BigNumber const& bn) const; - bool operator<=(BigNumber const& bn) const { return (CompareTo(bn) <= 0); } - bool operator==(BigNumber const& bn) const { return (CompareTo(bn) == 0); } - bool operator>=(BigNumber const& bn) const { return (CompareTo(bn) >= 0); } - bool operator<(BigNumber const& bn) const { return (CompareTo(bn) < 0); } - bool operator>(BigNumber const& bn) const { return (CompareTo(bn) > 0); } - - bool IsZero() const; - bool IsNegative() const; + [[nodiscard]] bool isZero() const; BigNumber ModExp(BigNumber const& bn1, BigNumber const& bn2) const; BigNumber Exp(BigNumber const&) const; @@ -103,12 +87,12 @@ public: struct bignum_st* BN() { return _bn; } struct bignum_st const* BN() const { return _bn; } - uint32 AsDword() const; + uint32 AsDword(); void GetBytes(uint8* buf, size_t bufsize, bool littleEndian = true) const; std::vector ToByteVector(int32 minSize = 0, bool littleEndian = true) const; - template + template std::array ToByteArray(bool littleEndian = true) const { std::array buf; @@ -116,11 +100,10 @@ public: return buf; } - std::string AsHexStr() const; - std::string AsDecStr() const; + [[nodiscard]] char* AsHexStr() const; + [[nodiscard]] char* AsDecStr() const; private: struct bignum_st* _bn; - }; #endif diff --git a/src/common/Cryptography/Authentication/SRP6.cpp b/src/common/Cryptography/SRP6.cpp similarity index 99% rename from src/common/Cryptography/Authentication/SRP6.cpp rename to src/common/Cryptography/SRP6.cpp index d66e3aa963..ee7f1a98f2 100644 --- a/src/common/Cryptography/Authentication/SRP6.cpp +++ b/src/common/Cryptography/SRP6.cpp @@ -75,7 +75,7 @@ std::optional SRP6::VerifyChallengeResponse(EphemeralKey const& A, S _used = true; BigNumber const _A(A); - if ((_A % _N).IsZero()) + if ((_A % _N).isZero()) return std::nullopt; BigNumber const u(SHA1::GetDigestOf(A, B)); diff --git a/src/common/Cryptography/Authentication/SRP6.h b/src/common/Cryptography/SRP6.h similarity index 100% rename from src/common/Cryptography/Authentication/SRP6.h rename to src/common/Cryptography/SRP6.h diff --git a/src/common/Cryptography/TOTP.cpp b/src/common/Cryptography/TOTP.cpp deleted file mode 100644 index 87546a0eb8..0000000000 --- a/src/common/Cryptography/TOTP.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#include "TOTP.h" -#include -#include -#include - -constexpr std::size_t acore::Crypto::TOTP::RECOMMENDED_SECRET_LENGTH; -static constexpr uint32 TOTP_INTERVAL = 30; -static constexpr uint32 HMAC_RESULT_SIZE = 20; - -/*static*/ uint32 acore::Crypto::TOTP::GenerateToken(Secret const& secret, time_t timestamp) -{ - timestamp /= TOTP_INTERVAL; - unsigned char challenge[8]; - - for (int i = 8; i--; timestamp >>= 8) - challenge[i] = timestamp; - - unsigned char digest[HMAC_RESULT_SIZE]; - uint32 digestSize = HMAC_RESULT_SIZE; - HMAC(EVP_sha1(), secret.data(), secret.size(), challenge, 8, digest, &digestSize); - - uint32 offset = digest[19] & 0xF; - uint32 truncated = (digest[offset] << 24) | (digest[offset + 1] << 16) | (digest[offset + 2] << 8) | (digest[offset + 3]); - truncated &= 0x7FFFFFFF; - - return (truncated % 1000000); -} - -/*static*/ bool acore::Crypto::TOTP::ValidateToken(Secret const& secret, uint32 token) -{ - time_t now = time(nullptr); - return ( - (token == GenerateToken(secret, now - TOTP_INTERVAL)) || - (token == GenerateToken(secret, now)) || - (token == GenerateToken(secret, now + TOTP_INTERVAL)) - ); -} diff --git a/src/common/Cryptography/TOTP.h b/src/common/Cryptography/TOTP.h deleted file mode 100644 index ee14a6d8ac..0000000000 --- a/src/common/Cryptography/TOTP.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#ifndef WARHEAD_TOTP_H -#define WARHEAD_TOTP_H - -#include "Define.h" -#include -#include - -namespace acore::Crypto -{ - struct AC_COMMON_API TOTP - { - static constexpr size_t RECOMMENDED_SECRET_LENGTH = 20; - using Secret = std::vector; - - static uint32 GenerateToken(Secret const& key, time_t timestamp); - static bool ValidateToken(Secret const& key, uint32 token); - }; -} - -#endif diff --git a/src/common/Encoding/Base32.cpp b/src/common/Encoding/Base32.cpp deleted file mode 100644 index 9eaab724dc..0000000000 --- a/src/common/Encoding/Base32.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#include "Base32.h" -#include "BaseEncoding.h" -#include "Errors.h" - -struct B32Impl -{ - static constexpr std::size_t BITS_PER_CHAR = 5; - - static constexpr char PADDING = '='; - static constexpr char Encode(uint8 v) - { - ASSERT(v < 0x20); - if (v < 26) return 'A'+v; - else return '2' + (v-26); - } - - static constexpr uint8 DECODE_ERROR = 0xff; - static constexpr uint8 Decode(uint8 v) - { - if (v == '0') return Decode('O'); - if (v == '1') return Decode('l'); - if (v == '8') return Decode('B'); - if (('A' <= v) && (v <= 'Z')) return (v-'A'); - if (('a' <= v) && (v <= 'z')) return (v-'a'); - if (('2' <= v) && (v <= '7')) return (v-'2')+26; - return DECODE_ERROR; - } -}; - -/*static*/ std::string acore::Encoding::Base32::Encode(std::vector const& data) -{ - return acore::Impl::GenericBaseEncoding::Encode(data); -} - -/*static*/ Optional> acore::Encoding::Base32::Decode(std::string const& data) -{ - return acore::Impl::GenericBaseEncoding::Decode(data); -} diff --git a/src/common/Encoding/Base32.h b/src/common/Encoding/Base32.h deleted file mode 100644 index d6d1e86d2a..0000000000 --- a/src/common/Encoding/Base32.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#ifndef WARHEAD_BASE32_H -#define WARHEAD_BASE32_H - -#include "Define.h" -#include "Optional.h" -#include -#include - -namespace acore::Encoding -{ - struct AC_COMMON_API Base32 - { - static std::string Encode(std::vector const& data); - static Optional> Decode(std::string const& data); - }; -} - -#endif diff --git a/src/common/Encoding/Base64.cpp b/src/common/Encoding/Base64.cpp deleted file mode 100644 index 14f1476528..0000000000 --- a/src/common/Encoding/Base64.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#include "Base64.h" -#include "BaseEncoding.h" -#include "Errors.h" - -struct B64Impl -{ - static constexpr std::size_t BITS_PER_CHAR = 6; - - static constexpr char PADDING = '='; - static constexpr char Encode(uint8 v) - { - ASSERT(v < 0x40); - if (v < 26) return 'A' + v; - if (v < 52) return 'a' + (v - 26); - if (v < 62) return '0' + (v - 52); - if (v == 62) return '+'; - else return '/'; - } - - static constexpr uint8 DECODE_ERROR = 0xff; - static constexpr uint8 Decode(uint8 v) - { - if (('A' <= v) && (v <= 'Z')) return (v - 'A'); - if (('a' <= v) && (v <= 'z')) return (v - 'a') + 26; - if (('0' <= v) && (v <= '9')) return (v - '0') + 52; - if (v == '+') return 62; - if (v == '/') return 63; - return DECODE_ERROR; - } -}; - -/*static*/ std::string acore::Encoding::Base64::Encode(std::vector const& data) -{ - return acore::Impl::GenericBaseEncoding::Encode(data); -} - -/*static*/ Optional> acore::Encoding::Base64::Decode(std::string const& data) -{ - return acore::Impl::GenericBaseEncoding::Decode(data); -} diff --git a/src/common/Encoding/Base64.h b/src/common/Encoding/Base64.h deleted file mode 100644 index 64bba5f5e0..0000000000 --- a/src/common/Encoding/Base64.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#ifndef WARHEAD_BASE64_H -#define WARHEAD_BASE64_H - -#include "Define.h" -#include "Optional.h" -#include -#include - -namespace acore::Encoding -{ - struct AC_COMMON_API Base64 - { - static std::string Encode(std::vector const& data); - static Optional> Decode(std::string const& data); - }; -} - -#endif diff --git a/src/common/Encoding/BaseEncoding.h b/src/common/Encoding/BaseEncoding.h deleted file mode 100644 index e02ccfd613..0000000000 --- a/src/common/Encoding/BaseEncoding.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#ifndef WARHEAD_BASE_ENCODING_HPP -#define WARHEAD_BASE_ENCODING_HPP - -#include "Define.h" -#include "Optional.h" -#include -#include -#include - -namespace acore::Impl -{ - template - struct GenericBaseEncoding - { - static constexpr std::size_t BITS_PER_CHAR = Encoding::BITS_PER_CHAR; - static constexpr std::size_t PAD_TO = std::lcm(8u, BITS_PER_CHAR); - - static_assert(BITS_PER_CHAR < 8, "Encoding parameters are invalid"); - - static constexpr uint8 DECODE_ERROR = Encoding::DECODE_ERROR; - static constexpr char PADDING = Encoding::PADDING; - - static constexpr std::size_t EncodedSize(std::size_t size) - { - size *= 8; // bits in input - if (size % PAD_TO) // pad to boundary - size += (PAD_TO - (size % PAD_TO)); - return (size / BITS_PER_CHAR); - } - - static constexpr std::size_t DecodedSize(std::size_t size) - { - size *= BITS_PER_CHAR; // bits in input - if (size % PAD_TO) // pad to boundary - size += (PAD_TO - (size % PAD_TO)); - return (size / 8); - } - - static std::string Encode(std::vector const& data) - { - auto it = data.begin(), end = data.end(); - if (it == end) - return ""; - - std::string s; - s.reserve(EncodedSize(data.size())); - - uint8 bitsLeft = 8; // in current byte - do - { - uint8 thisC = 0; - if (bitsLeft >= BITS_PER_CHAR) - { - bitsLeft -= BITS_PER_CHAR; - thisC = ((*it >> bitsLeft) & ((1 << BITS_PER_CHAR)-1)); - if (!bitsLeft) - { - ++it; - bitsLeft = 8; - } - } - else - { - thisC = (*it & ((1 << bitsLeft) - 1)) << (BITS_PER_CHAR - bitsLeft); - bitsLeft += (8 - BITS_PER_CHAR); - if ((++it) != end) - thisC |= (*it >> bitsLeft); - } - s.append(1, Encoding::Encode(thisC)); - } while (it != end); - - while (bitsLeft != 8) - { - if (bitsLeft > BITS_PER_CHAR) - bitsLeft -= BITS_PER_CHAR; - else - bitsLeft += (8 - BITS_PER_CHAR); - s.append(1, PADDING); - } - - return s; - } - - static Optional> Decode(std::string const& data) - { - auto it = data.begin(), end = data.end(); - if (it == end) - return std::vector(); - - std::vector v; - v.reserve(DecodedSize(data.size())); - - uint8 currentByte = 0; - uint8 bitsLeft = 8; // in current byte - while ((it != end) && (*it != PADDING)) - { - uint8 cur = Encoding::Decode(*(it++)); - if (cur == DECODE_ERROR) - return {}; - - if (bitsLeft > BITS_PER_CHAR) - { - bitsLeft -= BITS_PER_CHAR; - currentByte |= (cur << bitsLeft); - } - else - { - bitsLeft = BITS_PER_CHAR - bitsLeft; // in encoded char - currentByte |= (cur >> bitsLeft); - v.push_back(currentByte); - currentByte = (cur & ((1 << bitsLeft) - 1)); - bitsLeft = 8 - bitsLeft; // in byte again - currentByte <<= bitsLeft; - } - } - - if (currentByte) - return {}; // decode error, trailing non-zero bits - - // process padding - while ((it != end) && (*it == PADDING) && (bitsLeft != 8)) - { - if (bitsLeft > BITS_PER_CHAR) - bitsLeft -= BITS_PER_CHAR; - else - bitsLeft += (8 - BITS_PER_CHAR); - ++it; - } - - // ok, all padding should be consumed, and we should be at end of string - if (it == end) - return v; - - // anything else is an error - return {}; - } - }; -} - -#endif diff --git a/src/common/Utilities/MathUtil.h b/src/common/Utilities/MathUtil.h index 4164159aa3..62943822a7 100644 --- a/src/common/Utilities/MathUtil.h +++ b/src/common/Utilities/MathUtil.h @@ -28,6 +28,7 @@ inline T standard_deviation(Container&& c) return std::sqrt(accum / (size - 1)); } + template ()))>::type> inline T mean(Container&& c) { diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp index 0b457b662d..bebe54bedb 100644 --- a/src/server/authserver/Main.cpp +++ b/src/server/authserver/Main.cpp @@ -24,8 +24,6 @@ #include "RealmList.h" #include "RealmAcceptor.h" #include "DatabaseLoader.h" -#include "SecretMgr.h" -#include "SharedDefines.h" #include #include #include @@ -59,8 +57,6 @@ void usage(const char* prog) /// Launch the auth server extern int main(int argc, char** argv) { - acore::Impl::CurrentServerProcessHolder::_type = SERVER_PROCESS_AUTHSERVER; - // Command line parsing to get the configuration file name std::string configFile = sConfigMgr->GetConfigPath() + std::string(_ACORE_REALM_CONFIG); int count = 1; @@ -128,8 +124,6 @@ extern int main(int argc, char** argv) if (!StartDB()) return 1; - sSecretMgr->Initialize(); - // Get the list of realms for the server sRealmList->Initialize(sConfigMgr->GetOption("RealmsStateUpdateDelay", 20)); if (sRealmList->size() == 0) diff --git a/src/server/authserver/Server/AuthSocket.cpp b/src/server/authserver/Server/AuthSocket.cpp index a00127cb1f..3670972e27 100644 --- a/src/server/authserver/Server/AuthSocket.cpp +++ b/src/server/authserver/Server/AuthSocket.cpp @@ -4,23 +4,21 @@ * Copyright (C) 2005-2009 MaNGOS */ -#include "AES.h" +#include +#include + #include "Common.h" -#include "CryptoGenerics.h" #include "CryptoRandom.h" #include "CryptoHash.h" -#include "DatabaseEnv.h" +#include "Database/DatabaseEnv.h" #include "ByteBuffer.h" -#include "Config.h" +#include "Configuration/Config.h" #include "Log.h" #include "RealmList.h" #include "AuthSocket.h" #include "AuthCodes.h" -#include "SecretMgr.h" #include "TOTP.h" -#include -#include -#include +#include "openssl/crypto.h" #define ChunkSize 2048 @@ -373,7 +371,6 @@ bool AuthSocket::_HandleLogonChallenge() std::string const& ip_address = socket().getRemoteAddress(); PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED); stmt->setString(0, ip_address); - PreparedQueryResult result = LoginDatabase.Query(stmt); if (result) { @@ -441,26 +438,6 @@ bool AuthSocket::_HandleLogonChallenge() } } - uint8 securityFlags = 0; - _totpSecret = fields[7].GetBinary(); - - // Check if a TOTP token is needed - if (!_totpSecret || !_totpSecret.value().empty()) - { - securityFlags = 4; - - if (auto const& secret = sSecretMgr->GetSecret(SECRET_TOTP_MASTER_KEY)) - { - bool success = acore::Crypto::AEDecrypt(*_totpSecret, *secret); - if (!success) - { - pkt << uint8(WOW_FAIL_DB_BUSY); - LOG_ERROR("server.authserver", "[AuthChallenge] Account '%s' has invalid ciphertext for TOTP token key stored", _login.c_str()); - locked = true; - } - } - } - if (!locked) { //set expired bans to inactive @@ -469,19 +446,18 @@ bool AuthSocket::_HandleLogonChallenge() // If the account is banned, reject the logon attempt stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED); stmt->setUInt32(0, fields[0].GetUInt32()); - PreparedQueryResult banresult = LoginDatabase.Query(stmt); if (banresult) { if ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32()) { pkt << uint8(WOW_FAIL_BANNED); - LOG_DEBUG("network", "'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str()); + LOG_DEBUG("network", "'%s:%d' [AuthChallenge] Banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ()); } else { pkt << uint8(WOW_FAIL_SUSPENDED); - LOG_DEBUG("network", "'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str()); + LOG_DEBUG("network", "'%s:%d' [AuthChallenge] Temporarily banned account %s tried to login!", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str ()); } } else @@ -505,6 +481,12 @@ bool AuthSocket::_HandleLogonChallenge() pkt.append(_srp6->N); pkt.append(_srp6->s); pkt.append(unk3.ToByteArray<16>()); + uint8 securityFlags = 0; + + // Check if token is used + _tokenKey = fields[7].GetString(); + if (!_tokenKey.empty()) + securityFlags = 4; pkt << uint8(securityFlags); // security flags (0x0...0x04) @@ -533,9 +515,9 @@ bool AuthSocket::_HandleLogonChallenge() for (int i = 0; i < 4; ++i) _localizationName[i] = ch->country[4 - i - 1]; - LOG_DEBUG("network", "'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", - socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str(), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName)); - +#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) + LOG_DEBUG("network", "'%s:%d' [AuthChallenge] account %s is using '%c%c%c%c' locale (%u)", socket().getRemoteAddress().c_str(), socket().getRemotePort(), _login.c_str (), ch->country[3], ch->country[2], ch->country[1], ch->country[0], GetLocaleByName(_localizationName) ); +#endif ///- All good, await client's proof _status = STATUS_LOGON_PROOF; } @@ -595,24 +577,23 @@ bool AuthSocket::_HandleLogonProof() acore::Crypto::SHA1::Digest M2 = acore::Crypto::SRP6::GetSessionVerifier(lp.A, lp.clientM, _sessionKey); // Check auth token - bool tokenSuccess = false; - bool sentToken = (lp.securityFlags & 0x04); - - if (sentToken && _totpSecret) + if ((lp.securityFlags & 0x04) || !_tokenKey.empty()) { uint8 size; socket().recv((char*)&size, 1); char* token = new char[size + 1]; token[size] = '\0'; socket().recv(token, size); + unsigned int validToken = TOTP::GenerateToken(_tokenKey.c_str()); unsigned int incomingToken = atoi(token); delete[] token; - - tokenSuccess = acore::Crypto::TOTP::ValidateToken(*_totpSecret, incomingToken); - memset(_totpSecret->data(), 0, _totpSecret->size()); + if (validToken != incomingToken) + { + char data[] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 }; + socket().send(data, sizeof(data)); + return false; + } } - else if (!sentToken && !_totpSecret) - tokenSuccess = true; if (_expversion & POST_BC_EXP_FLAG) // 2.x and 3.x clients { @@ -635,12 +616,6 @@ bool AuthSocket::_HandleLogonProof() socket().send((char*)&proof, sizeof(proof)); } - if (!tokenSuccess) - { - char data[4] = { AUTH_LOGON_PROOF, WOW_FAIL_UNKNOWN_ACCOUNT, 3, 0 }; - socket().send(data, sizeof(data)); - } - ///- Set _status to authed! _status = STATUS_AUTHED; } diff --git a/src/server/authserver/Server/AuthSocket.h b/src/server/authserver/Server/AuthSocket.h index 26913aac91..cab5e49d1d 100644 --- a/src/server/authserver/Server/AuthSocket.h +++ b/src/server/authserver/Server/AuthSocket.h @@ -9,7 +9,6 @@ #include "Common.h" #include "CryptoHash.h" -#include "Optional.h" #include "RealmSocket.h" #include "SRP6.h" @@ -66,7 +65,7 @@ private: eStatus _status; std::string _login; - Optional> _totpSecret; + std::string _tokenKey; // Since GetLocaleByName() is _NOT_ bijective, we have to store the locale as a string. Otherwise we can't differ // between enUS and enGB, which is important for the patch system diff --git a/src/server/authserver/Server/TOTP.cpp b/src/server/authserver/Server/TOTP.cpp new file mode 100644 index 0000000000..6caab89ed3 --- /dev/null +++ b/src/server/authserver/Server/TOTP.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2008-2013 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +#include "TOTP.h" +#include + +int base32_decode(const char* encoded, char* result, int bufSize) +{ + // Base32 implementation + // Copyright 2010 Google Inc. + // Author: Markus Gutschke + // Licensed under the Apache License, Version 2.0 + int buffer = 0; + int bitsLeft = 0; + int count = 0; + for (const char* ptr = encoded; count < bufSize && *ptr; ++ptr) + { + char ch = *ptr; + if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' || ch == '-') + continue; + buffer <<= 5; + // Deal with commonly mistyped characters + if (ch == '0') + ch = 'O'; + else if (ch == '1') + ch = 'L'; + else if (ch == '8') + ch = 'B'; + // Look up one base32 digit + if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) + ch = (ch & 0x1F) - 1; + else if (ch >= '2' && ch <= '7') + ch -= '2' - 26; + else + return -1; + buffer |= ch; + bitsLeft += 5; + if (bitsLeft >= 8) + { + result[count++] = buffer >> (bitsLeft - 8); + bitsLeft -= 8; + } + } + if (count < bufSize) + result[count] = '\000'; + return count; +} + +#define HMAC_RES_SIZE 20 + +namespace TOTP +{ + unsigned int GenerateToken(const char* b32key) + { + size_t keySize = strlen(b32key); + int bufsize = (keySize + 7) / 8 * 5; + char* encoded = new char[bufsize]; + memset(encoded, 0, bufsize); + unsigned int hmacResSize = HMAC_RES_SIZE; + unsigned char hmacRes[HMAC_RES_SIZE]; + unsigned long timestamp = time(nullptr) / 30; + unsigned char challenge[8]; + for (int i = 8; i--; timestamp >>= 8) + challenge[i] = timestamp; + base32_decode(b32key, encoded, bufsize); + HMAC(EVP_sha1(), encoded, bufsize, challenge, 8, hmacRes, &hmacResSize); + unsigned int offset = hmacRes[19] & 0xF; + unsigned int truncHash = (hmacRes[offset] << 24) | (hmacRes[offset + 1] << 16 ) | (hmacRes[offset + 2] << 8) | (hmacRes[offset + 3]); + truncHash &= 0x7FFFFFFF; + delete[] encoded; + return truncHash % 1000000; + } +} diff --git a/src/server/authserver/Server/TOTP.h b/src/server/authserver/Server/TOTP.h new file mode 100644 index 0000000000..e70c4c3ab1 --- /dev/null +++ b/src/server/authserver/Server/TOTP.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2008-2013 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +#ifndef _TOTP_H +#define _TOTP_H +#include "openssl/hmac.h" +#include "openssl/evp.h" +namespace TOTP +{ + unsigned int GenerateToken(const char* b32key); +} +#endif diff --git a/src/server/authserver/authserver.conf.dist b/src/server/authserver/authserver.conf.dist index 9e2a2c4925..cfb5833c9b 100644 --- a/src/server/authserver/authserver.conf.dist +++ b/src/server/authserver/authserver.conf.dist @@ -9,8 +9,6 @@ # EXAMPLE CONFIG # AUTH SERVER SETTINGS # MYSQL SETTINGS -# CRYPTOGRAPHY -# LOGGING SYSTEM SETTINGS # ################################################################################################### @@ -152,18 +150,6 @@ WrongPass.Logging = 0 LoginDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_auth" -# -# Database.Reconnect.Seconds -# Database.Reconnect.Attempts -# -# Description: How many seconds between every reconnection attempt -# and how many attempts will be performed in total -# Default: 20 attempts every 15 seconds -# - -Database.Reconnect.Seconds = 15 -Database.Reconnect.Attempts = 20 - # # LoginDatabase.WorkerThreads # Description: The amount of worker threads spawned to handle asynchronous (delayed) MySQL @@ -183,24 +169,6 @@ LoginDatabase.SynchThreads = 1 # ################################################################################################### -################################################################################################### -# CRYPTOGRAPHY -# -# TOTPMasterSecret -# Description: The master key used to encrypt TOTP secrets for database storage. -# If you want to change this, uncomment TOTPOldMasterSecret, then copy -# your old secret there and startup authserver once. Afterwards, you can re- -# comment that line and get rid of your old secret. -# -# Default: - (Store TOTP secrets unencrypted) -# Example: 000102030405060708090A0B0C0D0E0F - -TOTPMasterSecret = -# TOTPOldMasterSecret = - -# -################################################################################################### - ################################################################################################### # # LOGGING SYSTEM SETTINGS @@ -288,7 +256,7 @@ Appender.Auth=2,5,0,Auth.log,w # (Using spaces as separator). # -Logger.root=4,Console Auth +Logger.root=5,Console Auth # -################################################################################################### +################################################################################################### \ No newline at end of file diff --git a/src/server/database/Database/DatabaseLoader.cpp b/src/server/database/Database/DatabaseLoader.cpp index e7cc640ed6..300ad292f4 100644 --- a/src/server/database/Database/DatabaseLoader.cpp +++ b/src/server/database/Database/DatabaseLoader.cpp @@ -39,18 +39,26 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool& pool, std::st // Try reconnect if (error == CR_CONNECTION_ERROR) { - uint8 const ATTEMPTS = sConfigMgr->GetOption("Database.Reconnect.Attempts", 20); - Seconds RECONNECT_SECONDS = Seconds(sConfigMgr->GetOption("Database.Reconnect.Seconds", 15)); - uint8 count = 0; + // Possible improvement for future: make ATTEMPTS and SECONDS configurable values + uint32 const ATTEMPTS = 5; + Seconds durationSecs = 5s; + uint32 count = 1; - while (count < ATTEMPTS) + auto sleepThread = [&]() + { + LOG_INFO("sql.driver", "> Retrying after %u seconds", static_cast(durationSecs.count())); + std::this_thread::sleep_for(durationSecs); + }; + + sleepThread(); + + do { - LOG_INFO("sql.driver", "> Retrying after %u seconds", static_cast(RECONNECT_SECONDS.count())); - std::this_thread::sleep_for(RECONNECT_SECONDS); error = pool.Open(); if (error == CR_CONNECTION_ERROR) { + sleepThread(); count++; } else @@ -58,7 +66,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool& pool, std::st break; } - } + } while (count < ATTEMPTS); } // If the error wasn't handled quit diff --git a/src/server/database/Database/Implementation/CharacterDatabase.cpp b/src/server/database/Database/Implementation/CharacterDatabase.cpp index 8409b32162..c8e0591e5b 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/database/Database/Implementation/CharacterDatabase.cpp @@ -205,7 +205,6 @@ void CharacterDatabaseConnection::DoPrepareStatements() // Chat channel handling PrepareStatement(CHAR_INS_CHANNEL, "INSERT INTO channels(channelId, name, team, announce, lastUsed) VALUES (?, ?, ?, ?, UNIX_TIMESTAMP())", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHANNEL, "UPDATE channels SET announce = ?, password = ?, lastUsed = UNIX_TIMESTAMP() WHERE channelId = ?", CONNECTION_ASYNC); - PrepareStatement(CHAR_DEL_CHANNEL, "DELETE FROM channels WHERE name = ? AND team = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_UPD_CHANNEL_USAGE, "UPDATE channels SET lastUsed = UNIX_TIMESTAMP() WHERE channelId = ?", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_OLD_CHANNELS, "DELETE FROM channels WHERE lastUsed + ? < UNIX_TIMESTAMP()", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_OLD_CHANNELS_BANS, "DELETE cb.* FROM channels_bans cb LEFT JOIN channels cn ON cb.channelId=cn.channelId WHERE cn.channelId IS NULL OR cb.banTime <= UNIX_TIMESTAMP()", CONNECTION_ASYNC); diff --git a/src/server/database/Database/Implementation/CharacterDatabase.h b/src/server/database/Database/Implementation/CharacterDatabase.h index ebf4a09098..4e22362dd3 100644 --- a/src/server/database/Database/Implementation/CharacterDatabase.h +++ b/src/server/database/Database/Implementation/CharacterDatabase.h @@ -184,7 +184,6 @@ enum CharacterDatabaseStatements CHAR_INS_CHANNEL, CHAR_UPD_CHANNEL, - CHAR_DEL_CHANNEL, CHAR_UPD_CHANNEL_USAGE, CHAR_DEL_OLD_CHANNELS, CHAR_DEL_OLD_CHANNELS_BANS, diff --git a/src/server/database/Database/Implementation/LoginDatabase.cpp b/src/server/database/Database/Implementation/LoginDatabase.cpp index f9d43bcf9c..cac4680b21 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.cpp +++ b/src/server/database/Database/Implementation/LoginDatabase.cpp @@ -26,7 +26,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_SEL_SESSIONKEY, "SELECT a.session_key, a.id, aa.gmlevel FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_UPD_LOGON, "UPDATE account SET salt = ?, verifier = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_LOGONPROOF, "UPDATE account SET session_key = ?, last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE username = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_SEL_LOGONCHALLENGE, "SELECT a.id, a.locked, a.lock_country, a.last_ip, aa.gmlevel, a.salt, a.verifier, a.totp_secret FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = ?", CONNECTION_SYNCH); + PrepareStatement(LOGIN_SEL_LOGONCHALLENGE, "SELECT a.id, a.locked, a.lock_country, a.last_ip, aa.gmlevel, a.salt, a.verifier, a.token_key FROM account a LEFT JOIN account_access aa ON (a.id = aa.id) WHERE a.username = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_LOGON_COUNTRY, "SELECT country FROM ip2nation WHERE ip < ? ORDER BY ip DESC LIMIT 0,1", CONNECTION_SYNCH); PrepareStatement(LOGIN_UPD_FAILEDLOGINS, "UPDATE account SET failed_logins = failed_logins + 1 WHERE username = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_FAILEDLOGINS, "SELECT id, failed_logins FROM account WHERE username = ?", CONNECTION_SYNCH); @@ -96,12 +96,4 @@ void LoginDatabaseConnection::DoPrepareStatements() // DB logging PrepareStatement(LOGIN_INS_LOG, "INSERT INTO logs (time, realm, type, level, string) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC); - - // TOTP - PrepareStatement(LOGIN_SEL_SECRET_DIGEST, "SELECT digest FROM secret_digest WHERE id = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_INS_SECRET_DIGEST, "INSERT INTO secret_digest (id, digest) VALUES (?,?)", CONNECTION_ASYNC); - PrepareStatement(LOGIN_DEL_SECRET_DIGEST, "DELETE FROM secret_digest WHERE id = ?", CONNECTION_ASYNC); - - PrepareStatement(LOGIN_SEL_ACCOUNT_TOTP_SECRET, "SELECT totp_secret FROM account WHERE id = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET, "UPDATE account SET totp_secret = ? WHERE id = ?", CONNECTION_ASYNC); } diff --git a/src/server/database/Database/Implementation/LoginDatabase.h b/src/server/database/Database/Implementation/LoginDatabase.h index c9409f5320..6f1cc61c2d 100644 --- a/src/server/database/Database/Implementation/LoginDatabase.h +++ b/src/server/database/Database/Implementation/LoginDatabase.h @@ -113,13 +113,6 @@ enum LoginDatabaseStatements LOGIN_INS_LOG, - LOGIN_SEL_SECRET_DIGEST, - LOGIN_INS_SECRET_DIGEST, - LOGIN_DEL_SECRET_DIGEST, - - LOGIN_SEL_ACCOUNT_TOTP_SECRET, - LOGIN_UPD_ACCOUNT_TOTP_SECRET, - MAX_LOGINDATABASE_STATEMENTS }; diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index c9f975b73e..a6e81dd920 100644 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -76,6 +76,7 @@ void TotemAI::UpdateAI(uint32 /*diff*/) me->VisitNearbyObject(max_range, checker); } + if (!victim && me->GetCharmerOrOwnerOrSelf()->IsInCombat()) { victim = me->GetCharmerOrOwnerOrSelf()->GetVictim(); diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index 7cb3bda61d..fe3b5cbba2 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -261,7 +261,7 @@ public: targetList.reverse(); if (targetType == SELECT_TARGET_RANDOM) - acore::Containers::RandomResize(targetList, maxTargets); + acore::Containers::RandomResizeList(targetList, maxTargets); else targetList.resize(maxTargets); } diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index a0f619bc46..245234ce6d 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -107,7 +107,7 @@ public: // We need to use a copy of SummonList here, otherwise original SummonList would be modified StorageType listCopy = storage_; - acore::Containers::RandomResize(listCopy, predicate, max); + acore::Containers::RandomResizeList(listCopy, predicate, max); for (StorageType::iterator i = listCopy.begin(); i != listCopy.end(); ++i) { Creature* summon = ObjectAccessor::GetCreature(*me, *i); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 6743862d8c..5de738de34 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -734,7 +734,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000); if (e.action.cast.targetsLimit > 0 && targets->size() > e.action.cast.targetsLimit) - acore::Containers::RandomResize(*targets, e.action.cast.targetsLimit); + acore::Containers::RandomResizeList(*targets, e.action.cast.targetsLimit); for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { @@ -793,7 +793,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u break; if (e.action.cast.targetsLimit > 0 && targets->size() > e.action.cast.targetsLimit) - acore::Containers::RandomResize(*targets, e.action.cast.targetsLimit); + acore::Containers::RandomResizeList(*targets, e.action.cast.targetsLimit); for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { @@ -3680,7 +3680,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* l->push_back(*itr); if (e.target.playerRange.maxCount > 0) - acore::Containers::RandomResize(*l, e.target.playerRange.maxCount); + acore::Containers::RandomResizeList(*l, e.target.playerRange.maxCount); } delete units; @@ -3800,7 +3800,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* l->push_back(*itr); if (e.target.o > 0) - acore::Containers::RandomResize(*l, e.target.o); + acore::Containers::RandomResizeList(*l, e.target.o); delete units; break; @@ -3842,7 +3842,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* } if (e.target.roleSelection.resize > 0) - acore::Containers::RandomResize(*l, e.target.roleSelection.resize); + acore::Containers::RandomResizeList(*l, e.target.roleSelection.resize); delete units; break; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 8cca8d5bba..126d13df32 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -128,12 +128,6 @@ void SmartAIMgr::LoadSmartAIFromDB() SmartScriptHolder temp; temp.entryOrGuid = fields[0].GetInt32(); - if (!temp.entryOrGuid) - { - LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: invalid entryorguid (0), skipped loading."); - continue; - } - SmartScriptType source_type = (SmartScriptType)fields[1].GetUInt8(); if (source_type >= SMART_SCRIPT_TYPE_MAX) { diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 80343324f1..60fddefdec 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -2943,20 +2943,24 @@ void AchievementGlobalMgr::LoadRewardLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string Subject = fields[2].GetString(); + std::string Text = fields[3].GetString(); + if (m_achievementRewards.find(ID) == m_achievementRewards.end()) { LOG_ERROR("sql.sql", "Table `achievement_reward_locale` (Entry: %u) has locale strings for non-existing achievement reward.", ID); continue; } - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + AchievementRewardLocale& data = m_achievementRewardLocales[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - AchievementRewardLocale& data = m_achievementRewardLocales[ID]; - ObjectMgr::AddLocaleString(fields[2].GetString(), locale, data.Subject); - ObjectMgr::AddLocaleString(fields[3].GetString(), locale, data.Text); + ObjectMgr::AddLocaleString(Subject, locale, data.Subject); + ObjectMgr::AddLocaleString(Text, locale, data.Text); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %lu Achievement Reward Locale strings in %u ms", (unsigned long)m_achievementRewardLocales.size(), GetMSTimeDiffToNow(oldMSTime)); diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 041b69a845..3fa26943df 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -142,7 +142,7 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, SQLTransaction& .SendMailTo(trans, MailReceiver(bidder, auction->bidder.GetCounter()), auction, MAIL_CHECK_MASK_COPIED); } else - sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans); + sAuctionMgr->RemoveAItem(auction->item_guid, true); } void AuctionHouseMgr::SendAuctionSalePendingMail(AuctionEntry* auction, SQLTransaction& trans, bool sendMail) @@ -229,7 +229,7 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction, SQLTransacti .SendMailTo(trans, MailReceiver(owner, auction->owner.GetCounter()), auction, MAIL_CHECK_MASK_COPIED, 0); } else - sAuctionMgr->RemoveAItem(auction->item_guid, true, &trans); + sAuctionMgr->RemoveAItem(auction->item_guid, true); } //this function sends mail to old bidder @@ -377,7 +377,7 @@ void AuctionHouseMgr::AddAItem(Item* it) mAitems[it->GetGUID()] = it; } -bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB, SQLTransaction* trans /*= nullptr*/) +bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB) { ItemMap::iterator i = mAitems.find(itemGuid); if (i == mAitems.end()) @@ -385,9 +385,10 @@ bool AuctionHouseMgr::RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB, SQLTra if (deleteFromDB) { - ASSERT(trans); + SQLTransaction trans = CharacterDatabase.BeginTransaction(); i->second->FSetState(ITEM_REMOVED); - i->second->SaveToDB(*trans); + i->second->SaveToDB(trans); + CharacterDatabase.CommitTransaction(trans); } mAitems.erase(i); @@ -783,7 +784,7 @@ std::string AuctionEntry::BuildAuctionMailBody(ObjectGuid guid, uint32 bid, uint { std::ostringstream strm; strm.width(16); - strm << std::right << std::hex << guid.GetRawValue(); + strm << guid.ToString(); strm << std::dec << ':' << bid << ':' << buyout; strm << ':' << deposit << ':' << cut; return strm.str(); diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index 8a8f6392c0..22f43d2d82 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -173,7 +173,7 @@ public: void LoadAuctions(); void AddAItem(Item* it); - bool RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB = false, SQLTransaction* trans = nullptr); + bool RemoveAItem(ObjectGuid itemGuid, bool deleteFromDB = false); void Update(); diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index f92b5baded..f23a908207 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -461,8 +461,10 @@ void Battlefield::BroadcastPacketToWar(WorldPacket& data) const void Battlefield::SendWarningToAllInZone(uint32 entry) { - if (Creature* stalker = GetCreature(StalkerGuid)) - sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); + if (Map* map = sMapMgr->CreateBaseMap(m_MapId)) + if (Unit* unit = map->GetCreature(StalkerGuid)) + if (Creature* stalker = unit->ToCreature()) + sCreatureTextMgr->SendChat(stalker, (uint8)entry, nullptr, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE); } void Battlefield::SendWarningToPlayer(Player* player, uint32 entry) @@ -812,7 +814,6 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl // Set creature in world map->AddToMap(creature); - creature->setActive(true); return creature; } @@ -821,7 +822,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o) { // Get map object - Map* map = sMapMgr->CreateBaseMap(m_MapId); + Map* map = sMapMgr->CreateBaseMap(571); // *vomits* if (!map) return 0; diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 40b2295fd7..678f4011e7 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -952,7 +952,7 @@ uint32 BattlegroundQueue::GetPlayersCountInGroupsQueue(BattlegroundBracketId bra bool BattlegroundQueue::IsAllQueuesEmpty(BattlegroundBracketId bracket_id) { - uint8 queueEmptyCount = 0; + uint32 queueEmptyCount = 0; for (uint8 i = 0; i < BG_QUEUE_MAX; i++) if (m_QueuedGroups[bracket_id][i].empty()) @@ -964,9 +964,7 @@ bool BattlegroundQueue::IsAllQueuesEmpty(BattlegroundBracketId bracket_id) void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry) { if (!sScriptMgr->CanSendMessageBGQueue(this, leader, bg, bracketEntry)) - { return; - } BattlegroundBracketId bracketId = bracketEntry->GetBracketId(); char const* bgName = bg->GetName(); @@ -976,7 +974,7 @@ void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvP uint32 q_max_level = std::min(bracketEntry->maxLevel, (uint32)80); uint32 qHorde = GetPlayersCountInGroupsQueue(bracketId, BG_QUEUE_NORMAL_HORDE); uint32 qAlliance = GetPlayersCountInGroupsQueue(bracketId, BG_QUEUE_NORMAL_ALLIANCE); - auto qTotal = qHorde + qAlliance; + uint32 leftPlayers = MaxPlayers - qHorde - qAlliance; // Show queue status to player only (when joining battleground queue or Arena and arena world announcer is disabled) if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY) || (bg->isArena() && !sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))) @@ -989,28 +987,15 @@ void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvP auto searchGUID = BGSpamProtection.find(leader->GetGUID()); if (searchGUID == BGSpamProtection.end()) - { BGSpamProtection[leader->GetGUID()] = 0; // Leader GUID not found, initialize with 0 - } // Skip if spam time < 30 secs (default) if (sWorld->GetGameTime() - BGSpamProtection[leader->GetGUID()] < sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_SPAM_DELAY)) - { return; - } - // When limited, it announces only if there are at least CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS in queue - auto limitQueueMinLevel = sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_LEVEL); - if (limitQueueMinLevel != 0 && q_min_level >= limitQueueMinLevel) - { - // limit only RBG for 80, WSG for lower levels - auto bgTypeToLimit = q_min_level == 80 ? BATTLEGROUND_RB : BATTLEGROUND_WS; - - if (bg->GetBgTypeID() == bgTypeToLimit && qTotal < sWorld->getIntConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS)) - { - return; - } - } + // If left players > 1 - skip announce + if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMITED_ENABLE) && leftPlayers != 1) + return; BGSpamProtection[leader->GetGUID()] = sWorld->GetGameTime(); sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers); diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index c97f93535d..5b7590333c 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -69,8 +69,8 @@ public: bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo* ginfo); void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo); uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo) const; - [[nodiscard]] uint32 GetPlayersCountInGroupsQueue(BattlegroundBracketId bracketId, BattlegroundQueueGroupTypes bgqueue); - [[nodiscard]] bool IsAllQueuesEmpty(BattlegroundBracketId bracket_id); + uint32 GetPlayersCountInGroupsQueue(BattlegroundBracketId bracketId, BattlegroundQueueGroupTypes bgqueue); + bool IsAllQueuesEmpty(BattlegroundBracketId bracket_id); void SendMessageBGQueue(Player* leader, Battleground* bg, PvPDifficultyEntry const* bracketEntry); void SendMessageArenaQueue(GroupQueueInfo* ginfo, bool IsJoin); diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 82cec3778a..0e3ba0518b 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -39,42 +39,28 @@ void ChannelMgr::LoadChannels() uint32 count = 0; // 0 1 2 3 4 5 - QueryResult result = CharacterDatabase.PQuery("SELECT channelId, name, team, announce, ownership, password FROM channels ORDER BY channelId ASC"); + QueryResult result = CharacterDatabase.PQuery("SELECT channelId, name, team, announce, ownership, password FROM channels WHERE team = %u ORDER BY channelId ASC", _teamId); if (!result) { - LOG_INFO("server", ">> Loaded 0 channels. DB table `channels` is empty."); + LOG_INFO("server", ">> Loaded 0 channels for %s", _teamId == TEAM_ALLIANCE ? "Alliance" : "Horde"); return; } - std::vector> toDelete; do { Field* fields = result->Fetch(); + if (!fields) + break; uint32 channelDBId = fields[0].GetUInt32(); std::string channelName = fields[1].GetString(); - TeamId team = TeamId(fields[2].GetUInt32()); std::string password = fields[5].GetString(); - std::wstring channelWName; - if (!Utf8toWStr(channelName, channelWName)) - { - LOG_ERROR("server", "Failed to load channel '%s' from database - invalid utf8 sequence? Deleted.", channelName.c_str()); - toDelete.push_back({ channelName, team }); - continue; - } + Utf8toWStr(channelName, channelWName); - ChannelMgr* mgr = forTeam(team); - if (!mgr) - { - LOG_ERROR("server", "Failed to load custom chat channel '%s' from database - invalid team %u. Deleted.", channelName.c_str(), team); - toDelete.push_back({ channelName, team }); - continue; - } - - Channel* newChannel = new Channel(channelName, 0, channelDBId, team, fields[3].GetUInt8(), fields[4].GetUInt8()); + Channel* newChannel = new Channel(channelName, 0, channelDBId, TeamId(fields[2].GetUInt32()), fields[3].GetUInt8(), fields[4].GetUInt8()); newChannel->SetPassword(password); - mgr->channels[channelWName] = newChannel; + channels[channelWName] = newChannel; if (QueryResult banResult = CharacterDatabase.PQuery("SELECT playerGUID, banTime FROM channels_bans WHERE channelId = %u", channelDBId)) { @@ -92,15 +78,7 @@ void ChannelMgr::LoadChannels() ++count; } while (result->NextRow()); - for (auto pair : toDelete) - { - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL); - stmt->setString(0, pair.first); - stmt->setUInt32(1, pair.second); - CharacterDatabase.Execute(stmt); - } - - LOG_INFO("server", ">> Loaded %u channels in %ums", count, GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server", ">> Loaded %u channels for %s in %ums", count, _teamId == TEAM_ALLIANCE ? "Alliance" : "Horde", GetMSTimeDiffToNow(oldMSTime)); LOG_INFO("server", " "); } diff --git a/src/server/game/Chat/Channels/ChannelMgr.h b/src/server/game/Chat/Channels/ChannelMgr.h index accda78829..790e7f4a96 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.h +++ b/src/server/game/Chat/Channels/ChannelMgr.h @@ -29,7 +29,7 @@ public: Channel* GetJoinChannel(std::string const& name, uint32 channel_id); Channel* GetChannel(std::string const& name, Player* p, bool pkt = true); - static void LoadChannels(); + void LoadChannels(); static void LoadChannelRights(); static const ChannelRights& GetChannelRightsFor(const std::string& name); diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 6673e5e5da..d40716982e 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -454,22 +454,13 @@ bool Creature::UpdateEntry(uint32 Entry, const CreatureData* data, bool changele SetAttackTime(RANGED_ATTACK, cInfo->RangeAttackTime); uint32 previousHealth = GetHealth(); - uint32 previousMaxHealth = GetMaxHealth(); uint32 previousPlayerDamageReq = m_PlayerDamageReq; SelectLevel(changelevel); if (previousHealth > 0) { SetHealth(previousHealth); - - if (previousMaxHealth && previousMaxHealth > GetMaxHealth()) - { - m_PlayerDamageReq = (uint32)(previousPlayerDamageReq * GetMaxHealth() / previousMaxHealth); - } - else - { - m_PlayerDamageReq = previousPlayerDamageReq; - } + m_PlayerDamageReq = previousPlayerDamageReq; } SetMeleeDamageSchool(SpellSchools(cInfo->dmgschool)); diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 44d5db6adb..3adfa1e8fb 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -3019,7 +3019,7 @@ ObjectGuid WorldObject::GetTransGUID() const float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/, float distanceToSearch/* = DEFAULT_HEIGHT_SEARCH*/) const { if (z != MAX_HEIGHT) - z += std::max(GetCollisionHeight(), Z_OFFSET_FIND_HEIGHT); + z += Z_OFFSET_FIND_HEIGHT; return GetMap()->GetHeight(GetPhaseMask(), x, y, z, vmap, distanceToSearch); } @@ -3028,7 +3028,7 @@ float WorldObject::GetMapWaterOrGroundLevel(float x, float y, float z, float* gr { return GetMap()->GetWaterOrGroundLevel(GetPhaseMask(), x, y, z, ground, isType(TYPEMASK_UNIT) ? !static_cast(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false, - std::max(GetCollisionHeight(), Z_OFFSET_FIND_HEIGHT)); + GetCollisionHeight()); } float WorldObject::GetFloorZ() const @@ -3036,5 +3036,5 @@ float WorldObject::GetFloorZ() const if (!IsInWorld()) return m_staticFloorZ; - return std::max(m_staticFloorZ, GetMap()->GetGameObjectFloor(GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ() + std::max(GetCollisionHeight(), Z_OFFSET_FIND_HEIGHT))); + return std::max(m_staticFloorZ, GetMap()->GetGameObjectFloor(GetPhaseMask(), GetPositionX(), GetPositionY(), GetPositionZ() + Z_OFFSET_FIND_HEIGHT)); } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 6e1d21f2fd..992b0d8af7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -449,12 +449,11 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/) // 1. Initialize internal variables to default values. // 2. In case when player is in group, initialize variables necessary for group calculations: // 2.1. _count - number of alive group members within reward distance; -// 2.2. _aliveSumLevel - sum of levels of alive group members within reward distance; -// 2.3. _sumLevel - sum of levels of group members within reward distance; -// 2.4. _maxLevel - maximum level of alive group member within reward distance; -// 2.5. _maxNotGrayMember - maximum level of alive group member within reward distance, +// 2.2. _sumLevel - sum of levels of alive group members within reward distance; +// 2.3. _maxLevel - maximum level of alive group member within reward distance; +// 2.4. _maxNotGrayMember - maximum level of alive group member within reward distance, // for whom victim is not gray; -// 2.6. _isFullXP - flag identifying that for all group members victim is not gray, +// 2.5. _isFullXP - flag identifying that for all group members victim is not gray, // so 100% XP will be rewarded (50% otherwise). // 3. Reward killer (and group, if necessary). // 3.1. If killer is in group, reward group. @@ -480,7 +479,7 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/) KillRewarder::KillRewarder(Player* killer, Unit* victim, bool isBattleGround) : // 1. Initialize internal variables to default values. _killer(killer), _victim(victim), _group(killer->GetGroup()), - _groupRate(1.0f), _maxNotGrayMember(nullptr), _count(0), _aliveSumLevel(0), _sumLevel(0), _xp(0), + _groupRate(1.0f), _maxNotGrayMember(nullptr), _count(0), _sumLevel(0), _xp(0), _isFullXP(false), _maxLevel(0), _isBattleGround(isBattleGround), _isPvP(false) { // mark the credit as pvp if victim is player @@ -500,32 +499,23 @@ inline void KillRewarder::_InitGroupData() // 2. In case when player is in group, initialize variables necessary for group calculations: for (GroupReference* itr = _group->GetFirstMember(); itr != nullptr; itr = itr->next()) if (Player* member = itr->GetSource()) - if ((_killer == member || member->IsAtGroupRewardDistance(_victim))) + if ((_killer == member || member->IsAtGroupRewardDistance(_victim)) && member->IsAlive()) { const uint8 lvl = member->getLevel(); - if (member->IsAlive()) - { - // 2.1. _count - number of alive group members within reward distance; - ++_count; - // 2.2. _aliveSumLevel - sum of levels of alive group members within reward distance; - _aliveSumLevel += lvl; - // 2.3. _maxLevel - maximum level of alive group member within reward distance; - if (_maxLevel < lvl) - { - _maxLevel = lvl; - } - // 2.4. _maxNotGrayMember - maximum level of alive group member within reward distance, - // for whom victim is not gray; - uint32 grayLevel = acore::XP::GetGrayLevel(lvl); - if (_victim->getLevel() > grayLevel && (!_maxNotGrayMember || _maxNotGrayMember->getLevel() < lvl)) - { - _maxNotGrayMember = member; - } - } - // 2.5. _sumLevel - sum of levels of group members within reward distance; + // 2.1. _count - number of alive group members within reward distance; + ++_count; + // 2.2. _sumLevel - sum of levels of alive group members within reward distance; _sumLevel += lvl; + // 2.3. _maxLevel - maximum level of alive group member within reward distance; + if (_maxLevel < lvl) + _maxLevel = lvl; + // 2.4. _maxNotGrayMember - maximum level of alive group member within reward distance, + // for whom victim is not gray; + uint32 grayLevel = acore::XP::GetGrayLevel(lvl); + if (_victim->getLevel() > grayLevel && (!_maxNotGrayMember || _maxNotGrayMember->getLevel() < lvl)) + _maxNotGrayMember = member; } - // 2.6. _isFullXP - flag identifying that for all group members victim is not gray, + // 2.5. _isFullXP - flag identifying that for all group members victim is not gray, // so 100% XP will be rewarded (50% otherwise). _isFullXP = _maxNotGrayMember && (_maxLevel == _maxNotGrayMember->getLevel()); } @@ -621,19 +611,16 @@ void KillRewarder::_RewardPlayer(Player* player, bool isDungeon) // Give reputation and kill credit only in PvE. if (!_isPvP || _isBattleGround) { - float xpRate = _group ? _groupRate * float(player->getLevel()) / _aliveSumLevel : /*Personal rate is 100%.*/ 1.0f; // Group rate depends on the sum of levels. - float reputationRate = _group ? _groupRate * float(player->getLevel()) / _sumLevel : /*Personal rate is 100%.*/ 1.0f; // Group rate depends on the sum of levels. - sScriptMgr->OnRewardKillRewarder(player, isDungeon, xpRate); // Personal rate is 100%. + float rate = _group ? _groupRate * float(player->getLevel()) / _sumLevel : /*Personal rate is 100%.*/ 1.0f; // Group rate depends on summary level. + sScriptMgr->OnRewardKillRewarder(player, isDungeon, rate); // Personal rate is 100%. if (_xp) - { // 4.2. Give XP. - _RewardXP(player, xpRate); - } + _RewardXP(player, rate); if (!_isBattleGround) { // If killer is in dungeon then all members receive full reputation at kill. - _RewardReputation(player, isDungeon ? 1.0f : reputationRate); + _RewardReputation(player, isDungeon ? 1.0f : rate); _RewardKillCredit(player); } } @@ -19253,6 +19240,7 @@ void Player::_LoadMailedItems(Mail* mail) } Item* item = NewItemOrBag(proto); + if (!item->LoadFromDB(itemGuid, ObjectGuid::Create(fields[13].GetUInt32()), fields, itemTemplate)) { LOG_ERROR("server", "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, itemGuid); @@ -19318,13 +19306,6 @@ void Player::_LoadMail() itr = GetMailBegin(); } - // Delete mailed items aswell - // Created again below in Player::_LoadMailedItems - for (ItemMap::iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter) - delete iter->second; - - mMitems.clear(); - //Now load the new ones m_mailCache.clear(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 9c53884b84..d7d3559e32 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1074,7 +1074,6 @@ private: float _groupRate; Player* _maxNotGrayMember; uint32 _count; - uint32 _aliveSumLevel; uint32 _sumLevel; uint32 _xp; bool _isFullXP; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index a3aa876ec3..bf2cd2a5d1 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -9816,12 +9816,6 @@ bool Unit::Attack(Unit* victim, bool meleeAttack) return false; } - // creatures should not try to attack the player during polymorph - if (creature && creature->IsPolymorphed()) - { - return false; - } - //if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED)) // pussywizard: wtf? why having this flag prevents from entering combat? it should just prevent melee attack // return false; @@ -12688,11 +12682,11 @@ void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, if (spellId == 0 && std::find_if(m_spellImmune[op].begin(), m_spellImmune[op].end(), spellIdImmunityPredicate(type)) != m_spellImmune[op].end()) return; - SpellImmune immune; - immune.spellId = spellId; - immune.type = type; - immune.blockType = blockType; - m_spellImmune[op].push_back(std::move(immune)); + SpellImmune Immune; + Immune.spellId = spellId; + Immune.type = type; + Immune.blockType = blockType; + m_spellImmune[op].push_back(Immune); } else { diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 769812d5c1..4f61395fbd 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -342,14 +342,12 @@ enum SpellImmuneBlockType struct SpellImmune { - SpellImmune() : spellId(0), type(IMMUNITY_EFFECT), blockType(SPELL_BLOCK_TYPE_ALL) { } - uint32 spellId; - uint32 type; - uint32 blockType; + uint32 type : 16; + uint32 blockType : 16; }; -typedef std::vector SpellImmuneList; +typedef std::list SpellImmuneList; enum UnitModifierType { diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 55e595859d..477c5e091e 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -361,14 +361,14 @@ ObjectMgr* ObjectMgr::instance() return &instance; } -void ObjectMgr::AddLocaleString(std::string&& s, LocaleConstant locale, StringVector& data) +void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data) { if (!s.empty()) { if (data.size() <= size_t(locale)) data.resize(locale + 1); - data[locale] = std::move(s); + data[locale] = s; } } @@ -387,15 +387,18 @@ void ObjectMgr::LoadCreatureLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string Name = fields[2].GetString(); + std::string Title = fields[3].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + CreatureLocale& data = _creatureLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - CreatureLocale& data = _creatureLocaleStore[ID]; - AddLocaleString(fields[2].GetString(), locale, data.Name); - AddLocaleString(fields[3].GetString(), locale, data.Title); + AddLocaleString(Name, locale, data.Name); + AddLocaleString(Title, locale, data.Title); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %lu Creature Locale strings in %u ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); @@ -417,16 +420,20 @@ void ObjectMgr::LoadGossipMenuItemsLocales() { Field* fields = result->Fetch(); - uint16 MenuID = fields[0].GetUInt16(); - uint16 OptionID = fields[1].GetUInt16(); + uint16 MenuID = fields[0].GetUInt16(); + uint16 OptionID = fields[1].GetUInt16(); + std::string LocaleName = fields[2].GetString(); - LocaleConstant locale = GetLocaleByName(fields[2].GetString()); + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; + std::string OptionText = fields[3].GetString(); + std::string BoxText = fields[4].GetString(); + GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(MenuID, OptionID)]; - AddLocaleString(fields[3].GetString(), locale, data.OptionText); - AddLocaleString(fields[4].GetString(), locale, data.BoxText); + AddLocaleString(OptionText, locale, data.OptionText); + AddLocaleString(BoxText, locale, data.BoxText); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Gossip Menu Option Locale strings in %u ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); @@ -448,14 +455,16 @@ void ObjectMgr::LoadPointOfInterestLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string Name = fields[2].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + PointOfInterestLocale& data = _pointOfInterestLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - PointOfInterestLocale& data = _pointOfInterestLocaleStore[ID]; - AddLocaleString(fields[2].GetString(), locale, data.Name); + AddLocaleString(Name, locale, data.Name); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Points Of Interest Locale strings in %u ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); @@ -2371,15 +2380,18 @@ void ObjectMgr::LoadItemLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string Name = fields[2].GetString(); + std::string Description = fields[3].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + ItemLocale& data = _itemLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - ItemLocale& data = _itemLocaleStore[ID]; - AddLocaleString(fields[2].GetString(), locale, data.Name); - AddLocaleString(fields[3].GetString(), locale, data.Description); + AddLocaleString(Name, locale, data.Name); + AddLocaleString(Description, locale, data.Description); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Item Locale strings in %u ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); @@ -2994,14 +3006,16 @@ void ObjectMgr::LoadItemSetNameLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string Name = fields[2].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + ItemSetNameLocale& data = _itemSetNameLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - ItemSetNameLocale& data = _itemSetNameLocaleStore[ID]; - AddLocaleString(fields[2].GetString(), locale, data.Name); + AddLocaleString(Name, locale, data.Name); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Item Set Name Locale strings in %u ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); @@ -4723,13 +4737,14 @@ void ObjectMgr::LoadQuestLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + QuestLocale& data = _questLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - QuestLocale& data = _questLocaleStore[ID]; AddLocaleString(fields[2].GetString(), locale, data.Title); AddLocaleString(fields[3].GetString(), locale, data.Details); AddLocaleString(fields[4].GetString(), locale, data.Objectives); @@ -5347,14 +5362,14 @@ void ObjectMgr::LoadPageTextLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string Text = fields[2].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); - if (locale == LOCALE_enUS) - continue; + PageTextLocale& data = _pageTextLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); - PageTextLocale& data = _pageTextLocaleStore[ID]; - AddLocaleString(fields[2].GetString(), locale, data.Text); + AddLocaleString(Text, locale, data.Text); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Page Text Locale strings in %u ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); @@ -5598,13 +5613,14 @@ void ObjectMgr::LoadNpcTextLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + NpcTextLocale& data = _npcTextLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - NpcTextLocale& data = _npcTextLocaleStore[ID]; for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { AddLocaleString(fields[2 + i * 2].GetString(), locale, data.Text_0[i]); @@ -6482,15 +6498,18 @@ void ObjectMgr::LoadGameObjectLocales() { Field* fields = result->Fetch(); - uint32 ID = fields[0].GetUInt32(); + uint32 ID = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string Name = fields[2].GetString(); + std::string CastBarCaption = fields[3].GetString(); - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + GameObjectLocale& data = _gameObjectLocaleStore[ID]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - GameObjectLocale& data = _gameObjectLocaleStore[ID]; - AddLocaleString(fields[2].GetString(), locale, data.Name); - AddLocaleString(fields[3].GetString(), locale, data.CastBarCaption); + AddLocaleString(Name, locale, data.Name); + AddLocaleString(CastBarCaption, locale, data.CastBarCaption); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Gameobject Locale strings in %u ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); @@ -8781,7 +8800,10 @@ void ObjectMgr::LoadBroadcastTextLocales() { Field* fields = result->Fetch(); - uint32 id = fields[0].GetUInt32(); + uint32 id = fields[0].GetUInt32(); + std::string LocaleName = fields[1].GetString(); + std::string MaleText = fields[2].GetString(); + std::string FemaleText = fields[3].GetString(); BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id); if (bct == _broadcastTextStore.end()) @@ -8790,12 +8812,12 @@ void ObjectMgr::LoadBroadcastTextLocales() continue; } - LocaleConstant locale = GetLocaleByName(fields[1].GetString()); + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - AddLocaleString(fields[2].GetString(), locale, bct->second.MaleText); - AddLocaleString(fields[3].GetString(), locale, bct->second.FemaleText); + AddLocaleString(MaleText, locale, bct->second.MaleText); + AddLocaleString(FemaleText, locale, bct->second.FemaleText); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Broadcast Text Locales in %u ms", uint32(_broadcastTextStore.size()), GetMSTimeDiffToNow(oldMSTime)); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 44cfcae1e0..68db40ae55 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -1326,7 +1326,7 @@ public: return _gossipMenuItemsStore.equal_range(uiMenuId); } - static void AddLocaleString(std::string&& s, LocaleConstant locale, StringVector& data); + static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data); static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value) { if (data.size() > size_t(loc_idx) && !data[loc_idx].empty()) diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index c3848f9620..1ec4644d49 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -34,8 +34,8 @@ private: const uint32 m_savedMana; public: - LoadPetFromDBQueryHolder(uint32 petNumber, bool current, uint32 diffTime, std::string&& actionBar, uint32 health, uint32 mana) - : m_petNumber(petNumber), m_current(current), m_diffTime(diffTime), m_actionBar(std::move(actionBar)), + LoadPetFromDBQueryHolder(uint32 petNumber, bool current, uint32 diffTime, std::string actionBar, uint32 health, uint32 mana) + : m_petNumber(petNumber), m_current(current), m_diffTime(diffTime), m_actionBar(actionBar), m_savedHealth(health), m_savedMana(mana) { } uint32 GetPetNumber() const { return m_petNumber; } @@ -129,14 +129,8 @@ uint8 WorldSession::HandleLoadPetFromDBFirstCallback(PreparedQueryResult result, Map* map = owner->GetMap(); ObjectGuid::LowType guid = map->GenerateLowGuid(); Pet* pet = new Pet(owner, pet_type); - if (!pet->Create(guid, map, owner->GetPhaseMask(), petentry, pet_number)) - { - delete pet; - return PET_LOAD_ERROR; - } - LoadPetFromDBQueryHolder* holder = new LoadPetFromDBQueryHolder(pet_number, current, uint32(time(nullptr) - fields[14].GetUInt32()), fields[13].GetString(), savedhealth, savedmana); - if (!holder->Initialize()) + if (!pet->Create(guid, map, owner->GetPhaseMask(), petentry, pet_number) || !holder->Initialize()) { delete pet; delete holder; diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 10f9b76e45..8f98c6b627 100644 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -17,6 +17,7 @@ #include #include + enum RollType { ROLL_PASS = 0, diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 80428a3ee2..faea05c80a 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -94,17 +94,7 @@ enum AcoreStrings LANG_RBAC_PERM_REVOKED_NOT_IN_LIST = 79, LANG_PVPSTATS = 80, LANG_PVPSTATS_DISABLED = 81, - // Free 82 - 86 - - LANG_UNKNOWN_ERROR = 87, - LANG_2FA_COMMANDS_NOT_SETUP = 88, - LANG_2FA_ALREADY_SETUP = 89, - LANG_2FA_INVALID_TOKEN = 90, - LANG_2FA_SECRET_SUGGESTION = 91, - LANG_2FA_SETUP_COMPLETE = 92, - LANG_2FA_NOT_SETUP = 93, - LANG_2FA_REMOVE_NEED_TOKEN = 94, - LANG_2FA_REMOVE_COMPLETE = 95, + // Free 82 - 95 LANG_GUILD_RENAME_ALREADY_EXISTS = 96, LANG_GUILD_RENAME_DONE = 97, @@ -201,11 +191,7 @@ enum AcoreStrings LANG_GRID_POSITION = 178, // 179-185 used in other client versions LANG_TRANSPORT_POSITION = 186, - // 187 - LANG_2FA_SECRET_TOO_LONG = 188, - LANG_2FA_SECRET_INVALID = 189, - LANG_2FA_SECRET_SET_COMPLETE = 190, - // free 191 - 199 + // Room for more level 1 187-199 not used // level 2 chat LANG_NO_SELECTION = 200, diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp index c57fec1418..83ab790005 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.cpp @@ -17,14 +17,6 @@ template void PointMovementGenerator::DoInitialize(T* unit) { - if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) - { - // the next line is to ensure that a new spline is created in DoUpdate() once the unit is no longer rooted/stunned - // todo: rename this flag to something more appropriate since it is set to true even without speed change now. - i_recalculateSpeed = true; - return; - } - if (!unit->IsStopped()) unit->StopMoving(); diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h index a64c241be8..b768b48916 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h @@ -10,7 +10,7 @@ #define RANDOM_POINTS_NUMBER 12 #define RANDOM_LINKS_COUNT 7 -#define MIN_WANDER_DISTANCE_GROUND 1.0f +#define MIN_WANDER_DISTANCE_GROUND 6.0f #define MIN_WANDER_DISTANCE_AIR 10.0f #define MAX_PATH_LENGHT_FACTOR 1.85f diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 9a55fab0b3..e088885305 100644 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -130,7 +130,7 @@ bool ChaseMovementGenerator::DoUpdate(T* owner, uint32 time_diff) } if (!i_path || moveToward != _movingTowards) - i_path = std::make_unique(owner); + i_path = new PathGenerator(owner); float x, y, z; bool shortenPath; @@ -188,7 +188,6 @@ bool ChaseMovementGenerator::DoUpdate(T* owner, uint32 time_diff) template<> void ChaseMovementGenerator::DoInitialize(Player* owner) { - i_path = nullptr; _lastTargetPosition.reset(); owner->AddUnitState(UNIT_STATE_CHASE); } @@ -196,7 +195,6 @@ void ChaseMovementGenerator::DoInitialize(Player* owner) template<> void ChaseMovementGenerator::DoInitialize(Creature* owner) { - i_path = nullptr; _lastTargetPosition.reset(); owner->SetWalk(false); owner->AddUnitState(UNIT_STATE_CHASE); @@ -307,7 +305,7 @@ bool FollowMovementGenerator::DoUpdate(T* owner, uint32 time_diff) return true; if (!i_path) - i_path = std::make_unique(owner); + i_path = new PathGenerator(owner); float x, y, z; // select angle @@ -378,7 +376,6 @@ void FollowMovementGenerator::_updateSpeed(Creature* owner) template void FollowMovementGenerator::DoInitialize(T* owner) { - i_path = nullptr; _lastTargetPosition.reset(); owner->AddUnitState(UNIT_STATE_FOLLOW); _updateSpeed(owner); diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h index 8266fc1c3f..13b64ea707 100644 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.h @@ -29,7 +29,7 @@ class ChaseMovementGenerator : public MovementGeneratorMedium range = {}, std::optional angle = {}) : TargetedMovementGeneratorBase(target), i_path(nullptr), i_recheckDistance(0), i_recalculateTravel(true), _range(range), _angle(angle) {} - ~ChaseMovementGenerator() { } + ~ChaseMovementGenerator() { delete i_path; } MovementGeneratorType GetMovementGeneratorType() { return CHASE_MOTION_TYPE; } @@ -48,7 +48,7 @@ public: bool HasLostTarget(Unit* unit) const { return unit->GetVictim() != this->GetTarget(); } private: - std::unique_ptr i_path; + PathGenerator* i_path; TimeTrackerSmall i_recheckDistance; bool i_recalculateTravel; @@ -65,7 +65,7 @@ class FollowMovementGenerator : public MovementGeneratorMedium i_path; + PathGenerator* i_path; TimeTrackerSmall i_recheckDistance; bool i_recalculateTravel; diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index ed2dbdad0f..193a5de289 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -141,6 +141,34 @@ bool PoolGroup::CheckPool() const return true; } +template +PoolObject* PoolGroup::RollOne(ActivePoolData& spawns, uint32 triggerFrom) +{ + if (!ExplicitlyChanced.empty()) + { + float roll = (float)rand_chance(); + + for (uint32 i = 0; i < ExplicitlyChanced.size(); ++i) + { + roll -= ExplicitlyChanced[i].chance; + // Triggering object is marked as spawned at this time and can be also rolled (respawn case) + // so this need explicit check for this case + if (roll < 0 && (ExplicitlyChanced[i].guid == triggerFrom || !spawns.IsActiveObject(ExplicitlyChanced[i].guid))) + return &ExplicitlyChanced[i]; + } + } + if (!EqualChanced.empty()) + { + int32 index = irand(0, EqualChanced.size() - 1); + // Triggering object is marked as spawned at this time and can be also rolled (respawn case) + // so this need explicit check for this case + if (EqualChanced[index].guid == triggerFrom || !spawns.IsActiveObject(EqualChanced[index].guid)) + return &EqualChanced[index]; + } + + return nullptr; +} + // Main method to despawn a creature or gameobject in a pool // If no guid is passed, the pool is just removed (event end case) // If guid is filled, cache will be used and no removal will occur, it just fill the cache @@ -293,70 +321,40 @@ void PoolGroup::RemoveOneRelation(uint32 child_pool_id) template void PoolGroup::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom) { + uint32 lastDespawned = 0; int count = limit - spawns.GetActiveObjectCount(poolId); // If triggered from some object respawn this object is still marked as spawned // and also counted into m_SpawnedPoolAmount so we need increase count to be // spawned by 1 if (triggerFrom) - { ++count; - } - if (count > 0) + // This will try to spawn the rest of pool, not guaranteed + for (int i = 0; i < count; ++i) { - PoolObjectList rolledObjects; - rolledObjects.reserve(count); + PoolObject* obj = RollOne(spawns, triggerFrom); + if (!obj) + continue; + if (obj->guid == lastDespawned) + continue; - // roll objects to be spawned - if (!ExplicitlyChanced.empty()) + if (obj->guid == triggerFrom) { - float roll = (float)rand_chance(); - - for (PoolObject& obj : ExplicitlyChanced) - { - roll -= obj.chance; - - // Triggering object is marked as spawned at this time and can be also rolled (respawn case) - // so this need explicit check for this case - if (roll < 0 && (/*obj.guid == triggerFrom ||*/ !spawns.IsActiveObject(obj.guid))) - { - rolledObjects.push_back(obj); - break; - } - } + ReSpawn1Object(obj); + triggerFrom = 0; + continue; } + spawns.ActivateObject(obj->guid, poolId); + Spawn1Object(obj); - if (!EqualChanced.empty() && rolledObjects.empty()) + if (triggerFrom) { - std::copy_if(EqualChanced.begin(), EqualChanced.end(), std::back_inserter(rolledObjects), [/*triggerFrom, */&spawns](PoolObject const& object) - { - return /*object.guid == triggerFrom ||*/ !spawns.IsActiveObject(object.guid); - }); - - acore::Containers::RandomResize(rolledObjects, count); + // One spawn one despawn no count increase + DespawnObject(spawns, triggerFrom); + lastDespawned = triggerFrom; + triggerFrom = 0; } - - // try to spawn rolled objects - for (PoolObject& obj : rolledObjects) - { - if (obj.guid == triggerFrom) - { - ReSpawn1Object(&obj); - triggerFrom = 0; - } - else - { - spawns.ActivateObject(obj.guid, poolId); - Spawn1Object(&obj); - } - } - } - - // One spawn one despawn no count increase - if (triggerFrom) - { - DespawnObject(spawns, triggerFrom); } } diff --git a/src/server/game/Pools/PoolMgr.h b/src/server/game/Pools/PoolMgr.h index c4b1af00b8..1d25eaa928 100644 --- a/src/server/game/Pools/PoolMgr.h +++ b/src/server/game/Pools/PoolMgr.h @@ -64,6 +64,7 @@ public: bool isEmpty() const { return ExplicitlyChanced.empty() && EqualChanced.empty(); } void AddEntry(PoolObject& poolitem, uint32 maxentries); bool CheckPool() const; + PoolObject* RollOne(ActivePoolData& spawns, uint32 triggerFrom); void DespawnObject(ActivePoolData& spawns, ObjectGuid::LowType guid = 0); void Despawn1Object(ObjectGuid::LowType guid); void SpawnObject(ActivePoolData& spawns, uint32 limit, uint32 triggerFrom); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 4bd0c37939..3e715fc0fa 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -1308,9 +1308,6 @@ void WorldSession::ProcessQueryCallbackPet() Player* player = GetPlayer(); if (!player) { - SQLQueryHolder* param; - _loadPetFromDBSecondCallback.get(param); - delete param; _loadPetFromDBSecondCallback.cancel(); } else if (!player->IsInWorld()) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4023451755..995d957418 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1197,7 +1197,7 @@ void Spell::SelectImplicitConeTargets(SpellEffIndex effIndex, SpellImplicitTarge if ((*j)->IsAffectedOnSpell(m_spellInfo)) maxTargets += (*j)->GetAmount(); - acore::Containers::RandomResize(targets, maxTargets); + acore::Containers::RandomResizeList(targets, maxTargets); } for (std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr) @@ -1280,7 +1280,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge if ((*j)->IsAffectedOnSpell(m_spellInfo)) maxTargets += (*j)->GetAmount(); - acore::Containers::RandomResize(targets, maxTargets); + acore::Containers::RandomResizeList(targets, maxTargets); } for (std::list::iterator itr = targets.begin(); itr != targets.end(); ++itr) diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 4ea1113072..6cc206a01e 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -2061,7 +2061,6 @@ AuraStateType SpellInfo::LoadAuraState() const case 9806: // Phantom Strike case 35325: // Glowing Blood case 16498: // Faerie Fire - case 6950: return AURA_STATE_FAERIE_FIRE; default: break; diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 7714dbeb20..4c7d877dcf 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -174,13 +174,15 @@ void CreatureTextMgr::LoadCreatureTextLocales() uint32 CreatureId = fields[0].GetUInt32(); uint32 GroupId = fields[1].GetUInt8(); uint32 ID = fields[2].GetUInt8(); + std::string LocaleName = fields[3].GetString(); + std::string Text = fields[4].GetString(); - LocaleConstant locale = GetLocaleByName(fields[3].GetString()); + CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(CreatureId, GroupId, ID)]; + LocaleConstant locale = GetLocaleByName(LocaleName); if (locale == LOCALE_enUS) continue; - CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(CreatureId, GroupId, ID)]; - ObjectMgr::AddLocaleString(fields[4].GetString(), locale, data.Text); + ObjectMgr::AddLocaleString(Text, locale, data.Text); } while (result->NextRow()); LOG_INFO("server", ">> Loaded %u Creature Text Locale in %u ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime)); diff --git a/src/server/game/World/IWorld.h b/src/server/game/World/IWorld.h index 294103c9cd..224403bb06 100644 --- a/src/server/game/World/IWorld.h +++ b/src/server/game/World/IWorld.h @@ -107,6 +107,7 @@ enum WorldBoolConfigs CONFIG_BATTLEGROUND_DISABLE_READY_CHECK_IN_BG, CONFIG_BATTLEGROUND_CAST_DESERTER, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, + CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMITED_ENABLE, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY, CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE, CONFIG_BATTLEGROUND_TRACK_DESERTERS, @@ -283,8 +284,6 @@ enum WorldIntConfigs CONFIG_BATTLEGROUND_INVITATION_TYPE, CONFIG_BATTLEGROUND_PLAYER_RESPAWN, CONFIG_BATTLEGROUND_BUFF_RESPAWN, - CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_LEVEL, - CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS, CONFIG_ARENA_MAX_RATING_DIFFERENCE, CONFIG_ARENA_RATING_DISCARD_TIMER, CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 7f58cea994..a05c534110 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1114,22 +1114,21 @@ void World::LoadConfigSettings(bool reload) m_float_configs[CONFIG_LISTEN_RANGE_TEXTEMOTE] = sConfigMgr->GetOption("ListenRange.TextEmote", 25.0f); m_float_configs[CONFIG_LISTEN_RANGE_YELL] = sConfigMgr->GetOption("ListenRange.Yell", 300.0f); - m_bool_configs[CONFIG_BATTLEGROUND_DISABLE_QUEST_SHARE_IN_BG] = sConfigMgr->GetOption("Battleground.DisableQuestShareInBG", false); - m_bool_configs[CONFIG_BATTLEGROUND_DISABLE_READY_CHECK_IN_BG] = sConfigMgr->GetOption("Battleground.DisableReadyCheckInBG", false); - m_bool_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfigMgr->GetOption("Battleground.CastDeserter", true); - m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.Enable", false); - m_int_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_LEVEL] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.Limit.MinLevel", 0); - m_int_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMIT_MIN_PLAYERS] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.Limit.MinPlayers", 3); - m_int_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_SPAM_DELAY] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.SpamProtection.Delay", 30); - m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.PlayerOnly", false); - m_bool_configs[CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE] = sConfigMgr->GetOption("Battleground.StoreStatistics.Enable", false); - m_bool_configs[CONFIG_BATTLEGROUND_TRACK_DESERTERS] = sConfigMgr->GetOption("Battleground.TrackDeserters.Enable", false); - m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfigMgr->GetOption ("Battleground.PrematureFinishTimer", 5 * MINUTE * IN_MILLISECONDS); - m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = sConfigMgr->GetOption("Battleground.InvitationType", 0); - m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = sConfigMgr->GetOption ("Battleground.PremadeGroupWaitForMatch", 30 * MINUTE * IN_MILLISECONDS); - m_bool_configs[CONFIG_BG_XP_FOR_KILL] = sConfigMgr->GetOption("Battleground.GiveXPForKills", false); - m_int_configs[CONFIG_BATTLEGROUND_REPORT_AFK_TIMER] = sConfigMgr->GetOption("Battleground.ReportAFK.Timer", 4); - m_int_configs[CONFIG_BATTLEGROUND_REPORT_AFK] = sConfigMgr->GetOption("Battleground.ReportAFK", 3); + m_bool_configs[CONFIG_BATTLEGROUND_DISABLE_QUEST_SHARE_IN_BG] = sConfigMgr->GetOption("Battleground.DisableQuestShareInBG", false); + m_bool_configs[CONFIG_BATTLEGROUND_DISABLE_READY_CHECK_IN_BG] = sConfigMgr->GetOption("Battleground.DisableReadyCheckInBG", false); + m_bool_configs[CONFIG_BATTLEGROUND_CAST_DESERTER] = sConfigMgr->GetOption("Battleground.CastDeserter", true); + m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.Enable", false); + m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_LIMITED_ENABLE] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.Limited.Enable", false); + m_int_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_SPAM_DELAY] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.SpamProtection.Delay", 30); + m_bool_configs[CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY] = sConfigMgr->GetOption("Battleground.QueueAnnouncer.PlayerOnly", false); + m_bool_configs[CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE] = sConfigMgr->GetOption("Battleground.StoreStatistics.Enable", false); + m_bool_configs[CONFIG_BATTLEGROUND_TRACK_DESERTERS] = sConfigMgr->GetOption("Battleground.TrackDeserters.Enable", false); + m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfigMgr->GetOption ("Battleground.PrematureFinishTimer", 5 * MINUTE * IN_MILLISECONDS); + m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = sConfigMgr->GetOption("Battleground.InvitationType", 0); + m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = sConfigMgr->GetOption ("Battleground.PremadeGroupWaitForMatch", 30 * MINUTE * IN_MILLISECONDS); + m_bool_configs[CONFIG_BG_XP_FOR_KILL] = sConfigMgr->GetOption("Battleground.GiveXPForKills", false); + m_int_configs[CONFIG_BATTLEGROUND_REPORT_AFK_TIMER] = sConfigMgr->GetOption("Battleground.ReportAFK.Timer", 4); + m_int_configs[CONFIG_BATTLEGROUND_REPORT_AFK] = sConfigMgr->GetOption("Battleground.ReportAFK", 3); if (m_int_configs[CONFIG_BATTLEGROUND_REPORT_AFK] < 1) { LOG_ERROR("server", "Battleground.ReportAFK (%d) must be >0. Using 3 instead.", m_int_configs[CONFIG_BATTLEGROUND_REPORT_AFK]); @@ -2040,7 +2039,10 @@ void World::SetInitialWorldSettings() ChannelMgr::LoadChannelRights(); LOG_INFO("server", "Load Channels..."); - ChannelMgr::LoadChannels(); + ChannelMgr* mgr = ChannelMgr::forTeam(TEAM_ALLIANCE); + mgr->LoadChannels(); + mgr = ChannelMgr::forTeam(TEAM_HORDE); + mgr->LoadChannels(); #ifdef ELUNA ///- Run eluna scripts. @@ -3455,3 +3457,4 @@ void World::RemoveOldCorpses() { m_timers[WUPDATE_CORPSES].SetCurrent(m_timers[WUPDATE_CORPSES].GetInterval()); } + diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index be57b08554..bb0fc5c4b5 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -12,18 +12,10 @@ Category: commandscripts EndScriptData */ #include "AccountMgr.h" -#include "AES.h" -#include "Base32.h" #include "Chat.h" -#include "CryptoGenerics.h" #include "Language.h" #include "Player.h" #include "ScriptMgr.h" -#include "SecretMgr.h" -#include "StringConvert.h" -#include "TOTP.h" -#include -#include class account_commandscript : public CommandScript { @@ -34,197 +26,33 @@ public: { static std::vector accountSetCommandTable = { - { "addon", SEC_GAMEMASTER, true, &HandleAccountSetAddonCommand, "" }, - { "gmlevel", SEC_CONSOLE, true, &HandleAccountSetGmLevelCommand, "" }, - { "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "" }, - { "2fa", SEC_PLAYER, true, &HandleAccountSet2FACommand, "" } + { "addon", SEC_GAMEMASTER, true, &HandleAccountSetAddonCommand, "" }, + { "gmlevel", SEC_CONSOLE, true, &HandleAccountSetGmLevelCommand, "" }, + { "password", SEC_CONSOLE, true, &HandleAccountSetPasswordCommand, "" } }; - static std::vector accountLockCommandTable { - { "country", SEC_PLAYER, true, &HandleAccountLockCountryCommand, "" }, - { "ip", SEC_PLAYER, true, &HandleAccountLockIpCommand, "" } + { "country", SEC_PLAYER, true, &HandleAccountLockCountryCommand, "" }, + { "ip", SEC_PLAYER, true, &HandleAccountLockIpCommand, "" } }; - - static std::vector account2faCommandTable - { - { "setup", SEC_PLAYER, false, &HandleAccount2FASetupCommand, "" }, - { "remove", SEC_PLAYER, false, &HandleAccount2FARemoveCommand, "" }, - }; - static std::vector accountCommandTable = { - { "2fa", SEC_PLAYER, true, nullptr, "", account2faCommandTable }, - { "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "" }, - { "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "" }, - { "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "" }, - { "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "" }, - { "lock", SEC_PLAYER, false, nullptr, "", accountLockCommandTable }, - { "set", SEC_ADMINISTRATOR, true, nullptr, "", accountSetCommandTable }, - { "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "" }, - { "", SEC_PLAYER, false, &HandleAccountCommand, "" } + { "addon", SEC_MODERATOR, false, &HandleAccountAddonCommand, "" }, + { "create", SEC_CONSOLE, true, &HandleAccountCreateCommand, "" }, + { "delete", SEC_CONSOLE, true, &HandleAccountDeleteCommand, "" }, + { "onlinelist", SEC_CONSOLE, true, &HandleAccountOnlineListCommand, "" }, + { "lock", SEC_PLAYER, false, nullptr, "", accountLockCommandTable }, + { "set", SEC_ADMINISTRATOR, true, nullptr, "", accountSetCommandTable }, + { "password", SEC_PLAYER, false, &HandleAccountPasswordCommand, "" }, + { "", SEC_PLAYER, false, &HandleAccountCommand, "" } }; - static std::vector commandTable = { { "account", SEC_PLAYER, true, nullptr, "", accountCommandTable } }; - return commandTable; } - static bool HandleAccount2FASetupCommand(ChatHandler* handler, char const* args) - { - if (!*args) - { - handler->SendSysMessage(LANG_CMD_SYNTAX); - handler->SetSentErrorMessage(true); - return false; - } - - auto token = acore::StringTo(args); - - auto const& masterKey = sSecretMgr->GetSecret(SECRET_TOTP_MASTER_KEY); - if (!masterKey.IsAvailable()) - { - handler->SendSysMessage(LANG_2FA_COMMANDS_NOT_SETUP); - handler->SetSentErrorMessage(true); - return false; - } - - uint32 const accountId = handler->GetSession()->GetAccountId(); - - { // check if 2FA already enabled - auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_TOTP_SECRET); - stmt->setUInt32(0, accountId); - PreparedQueryResult result = LoginDatabase.Query(stmt); - - if (!result) - { - LOG_ERROR("misc", "Account %u not found in login database when processing .account 2fa setup command.", accountId); - handler->SendSysMessage(LANG_UNKNOWN_ERROR); - handler->SetSentErrorMessage(true); - return false; - } - - if (!result->Fetch()->IsNull()) - { - handler->SendSysMessage(LANG_2FA_ALREADY_SETUP); - handler->SetSentErrorMessage(true); - return false; - } - } - - // store random suggested secrets - static std::unordered_map suggestions; - auto pair = suggestions.emplace(std::piecewise_construct, std::make_tuple(accountId), std::make_tuple(acore::Crypto::TOTP::RECOMMENDED_SECRET_LENGTH)); // std::vector 1-argument size_t constructor invokes resize - - if (pair.second) // no suggestion yet, generate random secret - acore::Crypto::GetRandomBytes(pair.first->second); - - if (!pair.second && token) // suggestion already existed and token specified - validate - { - if (acore::Crypto::TOTP::ValidateToken(pair.first->second, *token)) - { - if (masterKey) - acore::Crypto::AEEncryptWithRandomIV(pair.first->second, *masterKey); - - auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setBinary(0, pair.first->second); - stmt->setUInt32(1, accountId); - LoginDatabase.Execute(stmt); - - suggestions.erase(pair.first); - handler->SendSysMessage(LANG_2FA_SETUP_COMPLETE); - return true; - } - else - handler->SendSysMessage(LANG_2FA_INVALID_TOKEN); - } - - // new suggestion, or no token specified, output TOTP parameters - handler->PSendSysMessage(LANG_2FA_SECRET_SUGGESTION, acore::Encoding::Base32::Encode(pair.first->second).c_str()); - handler->SetSentErrorMessage(true); - return false; - } - - static bool HandleAccount2FARemoveCommand(ChatHandler* handler, char const* args) - { - if (!*args) - { - handler->SendSysMessage(LANG_CMD_SYNTAX); - handler->SetSentErrorMessage(true); - return false; - } - - auto token = acore::StringTo(args); - - auto const& masterKey = sSecretMgr->GetSecret(SECRET_TOTP_MASTER_KEY); - if (!masterKey.IsAvailable()) - { - handler->SendSysMessage(LANG_2FA_COMMANDS_NOT_SETUP); - handler->SetSentErrorMessage(true); - return false; - } - - uint32 const accountId = handler->GetSession()->GetAccountId(); - acore::Crypto::TOTP::Secret secret; - { // get current TOTP secret - auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_TOTP_SECRET); - stmt->setUInt32(0, accountId); - PreparedQueryResult result = LoginDatabase.Query(stmt); - - if (!result) - { - LOG_ERROR("misc", "Account %u not found in login database when processing .account 2fa setup command.", accountId); - handler->SendSysMessage(LANG_UNKNOWN_ERROR); - handler->SetSentErrorMessage(true); - return false; - } - - Field* field = result->Fetch(); - if (field->IsNull()) - { // 2FA not enabled - handler->SendSysMessage(LANG_2FA_NOT_SETUP); - handler->SetSentErrorMessage(true); - return false; - } - - secret = field->GetBinary(); - } - - if (token) - { - if (masterKey) - { - bool success = acore::Crypto::AEDecrypt(secret, *masterKey); - if (!success) - { - LOG_ERROR("misc", "Account %u has invalid ciphertext in TOTP token.", accountId); - handler->SendSysMessage(LANG_UNKNOWN_ERROR); - handler->SetSentErrorMessage(true); - return false; - } - } - - if (acore::Crypto::TOTP::ValidateToken(secret, *token)) - { - auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setNull(0); - stmt->setUInt32(1, accountId); - LoginDatabase.Execute(stmt); - handler->SendSysMessage(LANG_2FA_REMOVE_COMPLETE); - return true; - } - else - handler->SendSysMessage(LANG_2FA_INVALID_TOKEN); - } - - handler->SendSysMessage(LANG_2FA_REMOVE_NEED_TOKEN); - handler->SetSentErrorMessage(true); - return false; - } - static bool HandleAccountAddonCommand(ChatHandler* handler, char const* args) { if (!*args) @@ -557,91 +385,6 @@ public: return true; } - static bool HandleAccountSet2FACommand(ChatHandler* handler, char const* args) - { - if (!*args) - { - handler->SendSysMessage(LANG_CMD_SYNTAX); - handler->SetSentErrorMessage(true); - return false; - } - - char* _account = strtok((char*)args, " "); - char* _secret = strtok(nullptr, " "); - - if (!_account || !_secret) - { - handler->SendSysMessage(LANG_CMD_SYNTAX); - handler->SetSentErrorMessage(true); - return false; - } - - std::string accountName = _account; - std::string secret = _secret; - - if (!Utf8ToUpperOnlyLatin(accountName)) - { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); - handler->SetSentErrorMessage(true); - return false; - } - - uint32 targetAccountId = AccountMgr::GetId(accountName); - if (!targetAccountId) - { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); - handler->SetSentErrorMessage(true); - return false; - } - - if (handler->HasLowerSecurityAccount(nullptr, targetAccountId, true)) - return false; - - if (secret == "off") - { - auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setNull(0); - stmt->setUInt32(1, targetAccountId); - LoginDatabase.Execute(stmt); - handler->PSendSysMessage(LANG_2FA_REMOVE_COMPLETE); - return true; - } - - auto const& masterKey = sSecretMgr->GetSecret(SECRET_TOTP_MASTER_KEY); - if (!masterKey.IsAvailable()) - { - handler->SendSysMessage(LANG_2FA_COMMANDS_NOT_SETUP); - handler->SetSentErrorMessage(true); - return false; - } - - Optional> decoded = acore::Encoding::Base32::Decode(secret); - if (!decoded) - { - handler->SendSysMessage(LANG_2FA_SECRET_INVALID); - handler->SetSentErrorMessage(true); - return false; - } - - if (128 < (decoded->size() + acore::Crypto::AES::IV_SIZE_BYTES + acore::Crypto::AES::TAG_SIZE_BYTES)) - { - handler->SendSysMessage(LANG_2FA_SECRET_TOO_LONG); - handler->SetSentErrorMessage(true); - return false; - } - - if (masterKey) - acore::Crypto::AEEncryptWithRandomIV(*decoded, *masterKey); - - auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setBinary(0, *decoded); - stmt->setUInt32(1, targetAccountId); - LoginDatabase.Execute(stmt); - - handler->PSendSysMessage(LANG_2FA_SECRET_SET_COMPLETE, accountName.c_str()); - return true; - } - static bool HandleAccountCommand(ChatHandler* handler, char const* /*args*/) { AccountTypes gmLevel = handler->GetSession()->GetSecurity(); diff --git a/src/server/scripts/EasternKingdoms/CMakeLists.txt b/src/server/scripts/EasternKingdoms/CMakeLists.txt index 46e66ec197..6c25f9fc03 100644 --- a/src/server/scripts/EasternKingdoms/CMakeLists.txt +++ b/src/server/scripts/EasternKingdoms/CMakeLists.txt @@ -111,6 +111,7 @@ set(scripts_STAT_SRCS ${AC_SCRIPTS_DIR}/EasternKingdoms/MagistersTerrace/boss_vexallus.cpp ${AC_SCRIPTS_DIR}/EasternKingdoms/Uldaman/uldaman.h ${AC_SCRIPTS_DIR}/EasternKingdoms/Uldaman/instance_uldaman.cpp + ${AC_SCRIPTS_DIR}/EasternKingdoms/zone_swamp_of_sorrows.cpp ${AC_SCRIPTS_DIR}/EasternKingdoms/SunwellPlateau/boss_eredar_twins.cpp ${AC_SCRIPTS_DIR}/EasternKingdoms/SunwellPlateau/boss_kiljaeden.cpp ${AC_SCRIPTS_DIR}/EasternKingdoms/SunwellPlateau/sunwell_plateau.h diff --git a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp index 5ae91604fe..fb2084f4db 100644 --- a/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp +++ b/src/server/scripts/EasternKingdoms/MagistersTerrace/boss_priestess_delrissa.cpp @@ -104,7 +104,7 @@ public: std::list helpersList; for (uint8 i = 0; i < MAX_HELPERS_COUNT; ++i) helpersList.push_back(helpersEntries[i]); - acore::Containers::RandomResize(helpersList, MAX_ACTIVE_HELPERS); + acore::Containers::RandomResizeList(helpersList, MAX_ACTIVE_HELPERS); uint8 j = 0; for (std::list::const_iterator itr = helpersList.begin(); itr != helpersList.end(); ++itr, ++j) diff --git a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp index 04b12a8ce5..b03dc057a5 100644 --- a/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp +++ b/src/server/scripts/EasternKingdoms/Scholomance/instance_scholomance.cpp @@ -629,6 +629,7 @@ public: } }; + void AddSC_instance_scholomance() { new instance_scholomance(); diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp index cdde5b4de6..85c0675bc9 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_kalecgos.cpp @@ -626,7 +626,7 @@ public: void FilterTargets(std::list& targets) { targets.remove_if(SpectralBlastCheck(GetCaster()->GetVictim())); - acore::Containers::RandomResize(targets, 1); + acore::Containers::RandomResizeList(targets, 1); } void HandleDummy(SpellEffIndex effIndex) diff --git a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp index e546908860..43d9271a57 100644 --- a/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp +++ b/src/server/scripts/EasternKingdoms/SunwellPlateau/boss_muru.cpp @@ -394,7 +394,7 @@ public: void FilterTargets(std::list& targets) { - acore::Containers::RandomResize(targets, GetCaster()->GetAI()->GetData(DATA_NEGATIVE_ENERGY_TARGETS)); + acore::Containers::RandomResizeList(targets, GetCaster()->GetAI()->GetData(DATA_NEGATIVE_ENERGY_TARGETS)); } void HandleScriptEffect(SpellEffIndex effIndex) diff --git a/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp b/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp new file mode 100644 index 0000000000..410885da30 --- /dev/null +++ b/src/server/scripts/EasternKingdoms/zone_swamp_of_sorrows.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version. + * Copyright (C) 2008-2016 TrinityCore + * Copyright (C) 2005-2009 MaNGOS + */ + +#include "Player.h" +#include "ScriptedCreature.h" +#include "ScriptedEscortAI.h" +#include "ScriptMgr.h" + +/*###### +## npc_galen_goodward +######*/ + +enum Galen +{ + QUEST_GALENS_ESCAPE = 1393, + GO_GALENS_CAGE = 37118, + SAY_PERIODIC = 0, + SAY_QUEST_ACCEPTED = 1, + SAY_ATTACKED = 2, + SAY_QUEST_COMPLETE = 3, + EMOTE_WHISPER = 4, + EMOTE_DISAPPEAR = 5 +}; + +class npc_galen_goodward : public CreatureScript +{ +public: + npc_galen_goodward() : CreatureScript("npc_galen_goodward") { } + + struct npc_galen_goodwardAI : public npc_escortAI + { + npc_galen_goodwardAI(Creature* creature) : npc_escortAI(creature) + { + galensCageGUID.Clear(); + Reset(); + } + + void Reset() override + { + periodicSay = 6000; + } + + void EnterCombat(Unit* who) override + { + if (HasEscortState(STATE_ESCORT_ESCORTING)) + Talk(SAY_ATTACKED, who); + } + + void sQuestAccept(Player* player, Quest const* quest) override + { + if (quest->GetQuestId() == QUEST_GALENS_ESCAPE) + { + Talk(SAY_QUEST_ACCEPTED, player); + npc_escortAI::Start(false, false, player->GetGUID(), quest); + } + } + + void WaypointStart(uint32 uiPointId) override + { + switch (uiPointId) + { + case 0: + { + GameObject* cage = nullptr; + if (galensCageGUID) + cage = me->GetMap()->GetGameObject(galensCageGUID); + else + cage = GetClosestGameObjectWithEntry(me, GO_GALENS_CAGE, INTERACTION_DISTANCE); + if (cage) + { + cage->UseDoorOrButton(); + galensCageGUID = cage->GetGUID(); + } + break; + } + case 21: + Talk(EMOTE_DISAPPEAR); + break; + } + } + + void WaypointReached(uint32 waypointId) override + { + switch (waypointId) + { + case 0: + if (GameObject* cage = me->GetMap()->GetGameObject(galensCageGUID)) + cage->ResetDoorOrButton(); + break; + case 20: + if (Player* player = GetPlayerForEscort()) + { + me->SetFacingToObject(player); + Talk(SAY_QUEST_COMPLETE, player); + Talk(EMOTE_WHISPER, player); + player->GroupEventHappens(QUEST_GALENS_ESCAPE, me); + } + SetRun(true); + break; + } + } + + void UpdateAI(uint32 diff) override + { + npc_escortAI::UpdateAI(diff); + + if (HasEscortState(STATE_ESCORT_NONE)) + return; + + if (periodicSay < diff) + { + if (!HasEscortState(STATE_ESCORT_ESCORTING)) + Talk(SAY_PERIODIC); + periodicSay = 15000; + } + else + periodicSay -= diff; + + DoMeleeAttackIfReady(); + } + + private: + ObjectGuid galensCageGUID; + uint32 periodicSay; + }; + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_galen_goodwardAI(creature); + } +}; + +void AddSC_swamp_of_sorrows() +{ + new npc_galen_goodward(); +} diff --git a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp index cca91fb309..bf6f900682 100644 --- a/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp +++ b/src/server/scripts/Kalimdor/RuinsOfAhnQiraj/boss_moam.cpp @@ -137,7 +137,7 @@ public: targetList.push_back((*itr)->getTarget()); } - acore::Containers::RandomResize(targetList, 5); + acore::Containers::RandomResizeList(targetList, 5); for (std::list::iterator itr = targetList.begin(); itr != targetList.end(); ++itr) DoCast(*itr, SPELL_DRAIN_MANA); diff --git a/src/server/scripts/Kalimdor/zone_desolace.cpp b/src/server/scripts/Kalimdor/zone_desolace.cpp index d1f2a2129a..f5cbd1c372 100644 --- a/src/server/scripts/Kalimdor/zone_desolace.cpp +++ b/src/server/scripts/Kalimdor/zone_desolace.cpp @@ -13,6 +13,7 @@ EndScriptData */ /* ContentData npc_aged_dying_ancient_kodo +npc_dalinda_malem go_demon_portal EndContentData */ @@ -446,7 +447,6 @@ public: { me->SetHomePosition(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetOrientation()); me->GetMotionMaster()->Clear(); - me->GetMotionMaster()->MoveIdle(); DoCast(me, SPELL_KODO_KOMBO_GOSSIP, true); if (Creature* smeed = who->ToCreature()) @@ -495,6 +495,81 @@ public: } }; +/*###### +## npc_dalinda_malem. Quest 1440 +######*/ + +enum Dalinda +{ + QUEST_RETURN_TO_VAHLARRIEL = 1440 +}; + +class npc_dalinda : public CreatureScript +{ +public: + npc_dalinda() : CreatureScript("npc_dalinda") { } + + struct npc_dalindaAI : public npc_escortAI + { + npc_dalindaAI(Creature* creature) : npc_escortAI(creature) { } + + void Reset() override { } + + void EnterCombat(Unit* /*who*/) override { } + + void JustDied(Unit* /*killer*/) override + { + if (Player* player = GetPlayerForEscort()) + player->FailQuest(QUEST_RETURN_TO_VAHLARRIEL); + return; + } + + void WaypointReached(uint32 waypointId) override + { + Player* player = GetPlayerForEscort(); + + switch (waypointId) + { + case 1: + me->SetStandState(UNIT_STAND_STATE_STAND); + break; + case 15: + if (player) + player->GroupEventHappens(QUEST_RETURN_TO_VAHLARRIEL, me); + break; + } + } + + void UpdateAI(uint32 diff) override + { + npc_escortAI::UpdateAI(diff); + + if (!UpdateVictim()) + return; + + DoMeleeAttackIfReady(); + } + }; + + bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest) override + { + if (quest->GetQuestId() == QUEST_RETURN_TO_VAHLARRIEL) + { + if (npc_escortAI* escortAI = CAST_AI(npc_dalinda::npc_dalindaAI, creature->AI())) + { + escortAI->Start(true, false, player->GetGUID()); + creature->setFaction(113); + } + } + return true; + } + + CreatureAI* GetAI(Creature* creature) const override + { + return new npc_dalindaAI(creature); + } +}; + /*###### ## go_demon_portal ######*/ @@ -529,5 +604,6 @@ void AddSC_desolace() // Theirs new npc_aged_dying_ancient_kodo(); + new npc_dalinda(); new go_demon_portal(); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp index 1783525cb4..7784d3eca3 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_blood_queen_lana_thel.cpp @@ -420,7 +420,7 @@ public: if (Player* p = itr->GetSource()) if (p->IsAlive() && p != me->GetVictim() && p->GetGUID() != _offtankGUID && !p->IsGameMaster() && p->GetDistance(me) < 100.0f && !p->HasAura(SPELL_UNCONTROLLABLE_FRENZY)) myList.push_back(p); - acore::Containers::RandomResize(myList, Is25ManRaid() ? 3 : 2); + acore::Containers::RandomResizeList(myList, Is25ManRaid() ? 3 : 2); if (myList.size() > 1) { Talk(SAY_PACT_OF_THE_DARKFALLEN); @@ -446,7 +446,7 @@ public: if (!myList.empty()) { - acore::Containers::RandomResize(myList, 1); + acore::Containers::RandomResizeList(myList, 1); Player* target = myList.front(); Talk(EMOTE_SWARMING_SHADOWS, target); Talk(SAY_SWARMING_SHADOWS); @@ -468,7 +468,7 @@ public: if (p->IsAlive() && p != me->GetVictim() && p->GetGUID() != _offtankGUID && !p->IsGameMaster() && !p->HasAura(SPELL_PACT_OF_THE_DARKFALLEN) && !p->HasAura(SPELL_UNCONTROLLABLE_FRENZY)) myList.push_back(p); - acore::Containers::RandomResize(myList, uint32(Is25ManRaid() ? 4 : 2)); + acore::Containers::RandomResizeList(myList, uint32(Is25ManRaid() ? 4 : 2)); for (std::list::iterator itr = myList.begin(); itr != myList.end(); ++itr) me->CastSpell(*itr, SPELL_TWILIGHT_BLOODBOLT, false); me->CastSpell(me, SPELL_TWILIGHT_BLOODBOLT_TARGET, false); @@ -723,7 +723,7 @@ public: { uint32 targetCount = (targets.size() + 2) / 3; targets.remove_if(BloodboltHitCheck(static_cast(GetCaster()->GetAI()))); - acore::Containers::RandomResize(targets, targetCount); + acore::Containers::RandomResizeList(targets, targetCount); // mark targets now, effect hook has missile travel time delay (might cast next in that time) for (std::list::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) GetCaster()->GetAI()->SetGUID((*itr)->GetGUID(), GUID_BLOODBOLT); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp index 0217c75c09..1cea287066 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_deathbringer_saurfang.cpp @@ -1315,7 +1315,7 @@ public: targets.push_back(target); } else - acore::Containers::RandomResize(targets, 3); + acore::Containers::RandomResizeList(targets, 3); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp index 3608986a8e..bbc6fc4b0c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_icecrown_gunship_battle.cpp @@ -2208,7 +2208,7 @@ public: void SelectTarget(std::list& targets) { targets.remove_if(IgbExplosionCheck(GetCaster())); - acore::Containers::RandomResize(targets, 1); + acore::Containers::RandomResizeList(targets, 1); } void Register() override diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index d5340ab1c5..a9b243871c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -1257,7 +1257,7 @@ public: } targets.remove_if(acore::UnitAuraCheck(true, sSpellMgr->GetSpellIdForDifficulty(SPELL_UNBOUND_PLAGUE, GetCaster()))); - acore::Containers::RandomResize(targets, 1); + acore::Containers::RandomResizeList(targets, 1); } void HandleScript(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 97c9eb3ba9..20934c45fc 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -908,10 +908,10 @@ public: uint32 maxSize = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 3 : 1); healList.remove_if(UnchainedMagicTargetSelector(false)); if (healList.size() > maxSize) - acore::Containers::RandomResize(healList, maxSize); + acore::Containers::RandomResizeList(healList, maxSize); dpsList.remove_if(UnchainedMagicTargetSelector(true)); if (dpsList.size() > maxSize) - acore::Containers::RandomResize(dpsList, maxSize); + acore::Containers::RandomResizeList(dpsList, maxSize); unitList.splice(unitList.begin(), healList); unitList.splice(unitList.begin(), dpsList); } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp index 9a96c94a9a..8089eb328c 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_valithria_dreamwalker.cpp @@ -1368,7 +1368,7 @@ public: return; summoners = list_copy; } - acore::Containers::RandomResize(summoners, 2); + acore::Containers::RandomResizeList(summoners, 2); for (uint32 i = 0; i < 3; ++i) caster->CastSpell(summoners.front(), SPELL_SUMMON_SUPPRESSER, true); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp index 0df32853e5..f0f9ab7ab5 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/icecrown_citadel.cpp @@ -2159,7 +2159,7 @@ public: void RemoveAliveTarget(std::list& targets) { targets.remove_if(AliveCheck()); - acore::Containers::RandomResize(targets, 2); + acore::Containers::RandomResizeList(targets, 2); } void Land(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp b/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp index 7cf66ae070..5eb0cddc5b 100644 --- a/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp +++ b/src/server/scripts/Northrend/Ulduar/HallsOfStone/instance_halls_of_stone.cpp @@ -55,10 +55,8 @@ public: { for (uint8 i = 0; i < MAX_ENCOUNTER; ++i) { - if (Encounter[i] == IN_PROGRESS && i != BRANN_BRONZEBEARD) - { + if (Encounter[i] == IN_PROGRESS) return true; - } } return false; } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index 045ead2340..897b4a37fc 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp @@ -426,7 +426,7 @@ public: targets.push_back(itr->GetSource()); targets.remove_if(acore::ObjectTypeIdCheck(TYPEID_PLAYER, false)); targets.remove_if(acore::UnitAuraCheck(true, SPELL_FLASH_FREEZE_TRAPPED_PLAYER)); - acore::Containers::RandomResize(targets, (RAID_MODE(2,3))); + acore::Containers::RandomResizeList(targets, (RAID_MODE(2,3))); for (std::list::const_iterator itr = targets.begin(); itr != targets.end(); ++itr) { float prevZ = (*itr)->GetPositionZ(); @@ -1273,7 +1273,7 @@ public: { targets.remove_if(acore::ObjectTypeIdCheck(TYPEID_PLAYER, false)); targets.remove_if(acore::UnitAuraCheck(true, SPELL_FLASH_FREEZE_TRAPPED_PLAYER)); - acore::Containers::RandomResize(targets, 1); + acore::Containers::RandomResizeList(targets, 1); } void Register() override diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index 4aded7794b..a0e6d482d2 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -1193,7 +1193,7 @@ public: void FilterTargets(std::list& targets) { targets.remove_if(GhoulTargetCheck(GetSpellInfo()->Id == 70790)); - acore::Containers::RandomResize(targets, 2); + acore::Containers::RandomResizeList(targets, 2); } void HandleScript(SpellEffIndex effIndex) diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp index 3dc0087233..88ef475155 100644 --- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp +++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_morogrim_tidewalker.cpp @@ -199,7 +199,7 @@ public: void FilterTargets(std::list& unitList) { - acore::Containers::RandomResize(unitList, 1); + acore::Containers::RandomResizeList(unitList, 1); } void HandleDummy(SpellEffIndex effIndex) diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp index 311fb14c99..99803b2cd3 100644 --- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp +++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/instance_shattered_halls.cpp @@ -241,7 +241,7 @@ public: void FilterTargets(std::list& unitList) { - acore::Containers::RandomResize(unitList, 1); + acore::Containers::RandomResizeList(unitList, 1); } void HandleScriptEffect(SpellEffIndex effIndex) diff --git a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp index deb43a992c..9607ca670a 100644 --- a/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp +++ b/src/server/scripts/Outland/TempestKeep/Eye/boss_kaelthas.cpp @@ -993,7 +993,7 @@ public: targetList.push_back(target); } - acore::Containers::RandomResize(targetList, 5); + acore::Containers::RandomResizeList(targetList, 5); for (std::list::const_iterator itr = targetList.begin(); itr != targetList.end(); ++itr) GetCaster()->CastSpell(*itr, SPELL_NETHER_BEAM_DAMAGE, true); } diff --git a/src/server/scripts/ScriptLoader.cpp b/src/server/scripts/ScriptLoader.cpp index fefd532456..95e4ea0b5d 100644 --- a/src/server/scripts/ScriptLoader.cpp +++ b/src/server/scripts/ScriptLoader.cpp @@ -217,7 +217,7 @@ void AddSC_redridge_mountains(); void AddSC_silverpine_forest(); void AddSC_stormwind_city(); void AddSC_stranglethorn_vale(); -//void AddSC_swamp_of_sorrows(); +void AddSC_swamp_of_sorrows(); void AddSC_tirisfal_glades(); void AddSC_undercity(); void AddSC_western_plaguelands(); @@ -807,7 +807,7 @@ void AddEasternKingdomsScripts() AddSC_silverpine_forest(); AddSC_stormwind_city(); AddSC_stranglethorn_vale(); - //AddSC_swamp_of_sorrows(); + AddSC_swamp_of_sorrows(); AddSC_tirisfal_glades(); AddSC_undercity(); AddSC_western_plaguelands(); diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index be9925ad5a..be31c06a2f 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -1050,7 +1050,7 @@ public: void FilterTargets(std::list& targets) { - acore::Containers::RandomResize(targets, 2); + acore::Containers::RandomResizeList(targets, 2); } void HandleDummy(SpellEffIndex /*effIndex*/) diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 6fbc21f233..96c7ab0eca 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -768,7 +768,7 @@ public: void FilterTargets(std::list& targets) { targets.remove(GetCaster()); - acore::Containers::RandomResize(targets, _count); + acore::Containers::RandomResizeList(targets, _count); } void Register() override diff --git a/src/server/scripts/Spells/spell_paladin.cpp b/src/server/scripts/Spells/spell_paladin.cpp index 3b2f352bea..04249cc738 100644 --- a/src/server/scripts/Spells/spell_paladin.cpp +++ b/src/server/scripts/Spells/spell_paladin.cpp @@ -652,7 +652,7 @@ public: void CountTargets(std::list& targetList) { - acore::Containers::RandomResize(targetList, GetSpellValue()->MaxAffectedTargets); + acore::Containers::RandomResizeList(targetList, GetSpellValue()->MaxAffectedTargets); _targetCount = targetList.size(); } diff --git a/src/server/scripts/World/npc_innkeeper.cpp b/src/server/scripts/World/npc_innkeeper.cpp index c37922fe1a..0fd8f47b24 100644 --- a/src/server/scripts/World/npc_innkeeper.cpp +++ b/src/server/scripts/World/npc_innkeeper.cpp @@ -12,8 +12,6 @@ enum eTrickOrTreatSpells SPELL_TREAT = 24715, SPELL_TRICKED_OR_TREATED = 24755, HALLOWEEN_EVENTID = 12, - GOSSIP_MENU = 9733, - GOSSIP_MENU_EVENT = 342 }; class npc_innkeeper : public CreatureScript @@ -24,24 +22,16 @@ public: bool OnGossipHello(Player* player, Creature* creature) override { if (IsEventActive(HALLOWEEN_EVENTID) && !player->HasAura(SPELL_TRICKED_OR_TREATED)) - { - AddGossipItemFor(player, GOSSIP_MENU_EVENT, 0, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + HALLOWEEN_EVENTID); - } + AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Trick or Treat!", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + HALLOWEEN_EVENTID); if (creature->IsQuestGiver()) - { player->PrepareQuestMenu(creature->GetGUID()); - } if (creature->IsVendor()) - { - AddGossipItemFor(player, GOSSIP_MENU, 2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); - } + AddGossipItemFor(player, GOSSIP_ICON_VENDOR, GOSSIP_TEXT_BROWSE_GOODS, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_TRADE); if (creature->IsInnkeeper()) - { - AddGossipItemFor(player, GOSSIP_MENU, 1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INN); - } + AddGossipItemFor(player, GOSSIP_ICON_INTERACT_1, "Make this inn my home.", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INN); player->TalkedToCreature(creature->GetEntry(), creature->GetGUID()); SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID()); diff --git a/src/server/shared/Secrets/SecretMgr.cpp b/src/server/shared/Secrets/SecretMgr.cpp deleted file mode 100644 index 29785af01f..0000000000 --- a/src/server/shared/Secrets/SecretMgr.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#include "SecretMgr.h" -#include "AES.h" -#include "Argon2.h" -#include "Config.h" -#include "CryptoGenerics.h" -#include "DatabaseEnv.h" -#include "Errors.h" -#include "Log.h" -#include "SharedDefines.h" -#include -#include - -#define SECRET_FLAG_FOR(key, val, server) server ## _ ## key = (val ## ull << (16*SERVER_PROCESS_ ## server)) -#define SECRET_FLAG(key, val) SECRET_FLAG_ ## key = val, SECRET_FLAG_FOR(key, val, AUTHSERVER), SECRET_FLAG_FOR(key, val, WORLDSERVER) -enum SecretFlags : uint64 -{ - SECRET_FLAG(DEFER_LOAD, 0x1) -}; -#undef SECRET_FLAG_FOR -#undef SECRET_FLAG - -struct SecretInfo -{ - char const* configKey; - char const* oldKey; - int bits; - ServerProcessTypes owner; - uint64 _flags; - uint16 flags() const { return static_cast(_flags >> (16*THIS_SERVER_PROCESS)); } -}; - -static constexpr SecretInfo secret_info[NUM_SECRETS] = -{ - { "TOTPMasterSecret", "TOTPOldMasterSecret", 128, SERVER_PROCESS_AUTHSERVER, WORLDSERVER_DEFER_LOAD } -}; - -/*static*/ SecretMgr* SecretMgr::instance() -{ - static SecretMgr instance; - return &instance; -} - -static Optional GetHexFromConfig(char const* configKey, int bits) -{ - ASSERT(bits > 0); - std::string str = sConfigMgr->GetOption(configKey, ""); - if (str.empty()) - return {}; - - BigNumber secret; - if (!secret.SetHexStr(str.c_str())) - { - LOG_FATAL("server.loading", "Invalid value for '%s' - specify a hexadecimal integer of up to %d bits with no prefix.", configKey, bits); - ABORT(); - } - - BigNumber threshold(2); - threshold <<= bits; - if (!((BigNumber(0) <= secret) && (secret < threshold))) - { - LOG_ERROR("server.loading", "Value for '%s' is out of bounds (should be an integer of up to %d bits with no prefix). Truncated to %d bits.", configKey, bits, bits); - secret %= threshold; - } - ASSERT(((BigNumber(0) <= secret) && (secret < threshold))); - - return secret; -} - -void SecretMgr::Initialize() -{ - for (uint32 i = 0; i < NUM_SECRETS; ++i) - { - if (secret_info[i].flags() & SECRET_FLAG_DEFER_LOAD) - continue; - std::unique_lock lock(_secrets[i].lock); - AttemptLoad(Secrets(i), LogLevel::LOG_LEVEL_FATAL, lock); - if (!_secrets[i].IsAvailable()) - ABORT(); // load failed - } -} - -SecretMgr::Secret const& SecretMgr::GetSecret(Secrets i) -{ - std::unique_lock lock(_secrets[i].lock); - - if (_secrets[i].state == Secret::NOT_LOADED_YET) - AttemptLoad(i, LogLevel::LOG_LEVEL_ERROR, lock); - return _secrets[i]; -} - -void SecretMgr::AttemptLoad(Secrets i, LogLevel errorLevel, std::unique_lock const&) -{ - auto const& info = secret_info[i]; - - Optional oldDigest; - { - auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_SECRET_DIGEST); - stmt->setUInt32(0, i); - PreparedQueryResult result = LoginDatabase.Query(stmt); - if (result) - oldDigest = result->Fetch()->GetString(); - } - - Optional currentValue = GetHexFromConfig(info.configKey, info.bits); - - // verify digest - if ( - ((!oldDigest) != (!currentValue)) || // there is an old digest, but no current secret (or vice versa) - (oldDigest && !acore::Crypto::Argon2::Verify(currentValue->AsHexStr(), *oldDigest)) // there is an old digest, and the current secret does not match it - ) - { - if (info.owner != THIS_SERVER_PROCESS) - { - if (currentValue) - LOG_MESSAGE_BODY("server.loading", errorLevel, "Invalid value for '%s' specified - this is not actually the secret being used in your auth DB.", info.configKey); - else - LOG_MESSAGE_BODY("server.loading", errorLevel, "No value for '%s' specified - please specify the secret currently being used in your auth DB.", info.configKey); - _secrets[i].state = Secret::LOAD_FAILED; - return; - } - - Optional oldSecret; - if (oldDigest && info.oldKey) // there is an old digest, so there might be an old secret (if possible) - { - oldSecret = GetHexFromConfig(info.oldKey, info.bits); - if (oldSecret && !acore::Crypto::Argon2::Verify(oldSecret->AsHexStr(), *oldDigest)) - { - LOG_MESSAGE_BODY("server.loading", errorLevel, "Invalid value for '%s' specified - this is not actually the secret previously used in your auth DB.", info.oldKey); - _secrets[i].state = Secret::LOAD_FAILED; - return; - } - } - - // attempt to transition us to the new key, if possible - Optional error = AttemptTransition(Secrets(i), currentValue, oldSecret, !!oldDigest); - if (error) - { - LOG_MESSAGE_BODY("server.loading", errorLevel, "Your value of '%s' changed, but we cannot transition your database to the new value:\n%s", info.configKey, error->c_str()); - _secrets[i].state = Secret::LOAD_FAILED; - return; - } - - LOG_INFO("server.loading", "Successfully transitioned database to new '%s' value.", info.configKey); - } - - if (currentValue) - { - _secrets[i].state = Secret::PRESENT; - _secrets[i].value = *currentValue; - } - else - _secrets[i].state = Secret::NOT_PRESENT; -} - -Optional SecretMgr::AttemptTransition(Secrets i, Optional const& newSecret, Optional const& oldSecret, bool hadOldSecret) const -{ - auto trans = LoginDatabase.BeginTransaction(); - - switch (i) - { - case SECRET_TOTP_MASTER_KEY: - { - QueryResult result = LoginDatabase.Query("SELECT id, totp_secret FROM account"); - if (result) do - { - Field* fields = result->Fetch(); - if (fields[1].IsNull()) - continue; - - uint32 id = fields[0].GetUInt32(); - std::vector totpSecret = fields[1].GetBinary(); - - if (hadOldSecret) - { - if (!oldSecret) - return acore::StringFormat("Cannot decrypt old TOTP tokens - add config key '%s' to authserver.conf!", secret_info[i].oldKey); - - bool success = acore::Crypto::AEDecrypt(totpSecret, oldSecret->ToByteArray()); - if (!success) - return acore::StringFormat("Cannot decrypt old TOTP tokens - value of '%s' is incorrect for some users!", secret_info[i].oldKey); - } - - if (newSecret) - acore::Crypto::AEEncryptWithRandomIV(totpSecret, newSecret->ToByteArray()); - - auto* updateStmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - updateStmt->setBinary(0, totpSecret); - updateStmt->setUInt32(1, id); - trans->Append(updateStmt); - } while (result->NextRow()); - - break; - } - default: - return std::string("Unknown secret index - huh?"); - } - - if (hadOldSecret) - { - auto* deleteStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_SECRET_DIGEST); - deleteStmt->setUInt32(0, i); - trans->Append(deleteStmt); - } - - if (newSecret) - { - BigNumber salt; - salt.SetRand(128); - Optional hash = acore::Crypto::Argon2::Hash(newSecret->AsHexStr(), salt); - if (!hash) - return std::string("Failed to hash new secret"); - - auto* insertStmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_SECRET_DIGEST); - insertStmt->setUInt32(0, i); - insertStmt->setString(1, *hash); - trans->Append(insertStmt); - } - - LoginDatabase.CommitTransaction(trans); - return {}; -} diff --git a/src/server/shared/Secrets/SecretMgr.h b/src/server/shared/Secrets/SecretMgr.h deleted file mode 100644 index e380092bfd..0000000000 --- a/src/server/shared/Secrets/SecretMgr.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#ifndef __WARHEAD_SECRETMGR_H__ -#define __WARHEAD_SECRETMGR_H__ - -#include "BigNumber.h" -#include "Common.h" -#include "Optional.h" -#include "Log.h" -#include -#include -#include - -enum Secrets : uint32 -{ - SECRET_TOTP_MASTER_KEY = 0, - - // only add new indices right above this line - NUM_SECRETS -}; - -class AC_SHARED_API SecretMgr -{ -private: - SecretMgr() {} - ~SecretMgr() {} - -public: - SecretMgr(SecretMgr const&) = delete; - static SecretMgr* instance(); - - struct Secret - { - public: - explicit operator bool() const { return (state == PRESENT); } - BigNumber const& operator*() const { return value; } - BigNumber const* operator->() const { return &value; } - bool IsAvailable() const { return (state != NOT_LOADED_YET) && (state != LOAD_FAILED); } - - private: - std::mutex lock; - enum { NOT_LOADED_YET, LOAD_FAILED, NOT_PRESENT, PRESENT } state = NOT_LOADED_YET; - BigNumber value; - - friend class SecretMgr; - }; - - void Initialize(); - Secret const& GetSecret(Secrets i); - -private: - void AttemptLoad(Secrets i, LogLevel errorLevel, std::unique_lock const&); - Optional AttemptTransition(Secrets i, Optional const& newSecret, Optional const& oldSecret, bool hadOldSecret) const; - - std::array _secrets; -}; - -#define sSecretMgr SecretMgr::instance() - -#endif diff --git a/src/server/shared/SharedDefines.cpp b/src/server/shared/SharedDefines.cpp deleted file mode 100644 index d8556bf1a4..0000000000 --- a/src/server/shared/SharedDefines.cpp +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (C) 2016+ AzerothCore , released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 - * Copyright (C) 2021+ WarheadCore - */ - -#include "SharedDefines.h" - -ServerProcessTypes acore::Impl::CurrentServerProcessHolder::_type = NUM_SERVER_PROCESS_TYPES; diff --git a/src/server/shared/SharedDefines.h b/src/server/shared/SharedDefines.h index 76f7d40d70..fd3bb43ed9 100644 --- a/src/server/shared/SharedDefines.h +++ b/src/server/shared/SharedDefines.h @@ -12,7 +12,7 @@ #include float const GROUND_HEIGHT_TOLERANCE = 0.05f; // Extra tolerance to z position to check if it is in air or on ground. -constexpr float Z_OFFSET_FIND_HEIGHT = 2.0f; +constexpr float Z_OFFSET_FIND_HEIGHT = 0.5f; enum SpellEffIndex { @@ -3567,23 +3567,4 @@ enum PartyResult ERR_PARTY_LFG_TELEPORT_IN_COMBAT = 30 }; -enum ServerProcessTypes -{ - SERVER_PROCESS_AUTHSERVER = 0, - SERVER_PROCESS_WORLDSERVER = 1, - - NUM_SERVER_PROCESS_TYPES -}; - -namespace acore::Impl -{ - struct AC_SHARED_API CurrentServerProcessHolder - { - static ServerProcessTypes type() { return _type; } - static ServerProcessTypes _type; - }; -} - -#define THIS_SERVER_PROCESS (acore::Impl::CurrentServerProcessHolder::type()) - #endif diff --git a/src/server/worldserver/CMakeLists.txt b/src/server/worldserver/CMakeLists.txt index 604c591965..6cd093486f 100644 --- a/src/server/worldserver/CMakeLists.txt +++ b/src/server/worldserver/CMakeLists.txt @@ -61,7 +61,7 @@ target_link_libraries(worldserver scripts gsoap readline - gperftools) + ${GPERFTOOLS_LIBRARIES}) set_target_properties(worldserver PROPERTIES diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 1fddd68467..f29598a8cb 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -15,7 +15,6 @@ #include "Database/DatabaseEnv.h" #include "Log.h" #include "Master.h" -#include "SharedDefines.h" #include #include #include @@ -57,8 +56,6 @@ void usage(const char* prog) /// Launch the Trinity server extern int main(int argc, char** argv) { - acore::Impl::CurrentServerProcessHolder::_type = SERVER_PROCESS_WORLDSERVER; - ///- Command line parsing to get the configuration file name std::string configFile = sConfigMgr->GetConfigPath() + std::string(_ACORE_CORE_CONFIG); int c = 1; diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp index 7fe941aaa1..5156d38925 100644 --- a/src/server/worldserver/Master.cpp +++ b/src/server/worldserver/Master.cpp @@ -30,7 +30,6 @@ #include "WorldSocket.h" #include "WorldSocketMgr.h" #include "DatabaseLoader.h" -#include "SecretMgr.h" #include #ifdef _WIN32 @@ -137,7 +136,6 @@ int Master::Run() sConfigMgr->LoadModulesConfigs(); ///- Initialize the World - sSecretMgr->Initialize(); sWorld->SetInitialWorldSettings(); sScriptMgr->OnStartup(); diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 76fb9428c8..bf74feac16 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -11,7 +11,6 @@ # PERFORMANCE SETTINGS # SERVER LOGGING # SERVER SETTINGS -# CRYPTOGRAPHY # WARDEN SETTINGS # PLAYER INTERACTION # CREATURE SETTINGS @@ -96,18 +95,6 @@ LoginDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_auth" WorldDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_world" CharacterDatabaseInfo = "127.0.0.1;3306;acore;acore;acore_characters" -# -# Database.Reconnect.Seconds -# Database.Reconnect.Attempts -# -# Description: How many seconds between every reconnection attempt -# and how many attempts will be performed in total -# Default: 20 attempts every 15 seconds -# - -Database.Reconnect.Seconds = 15 -Database.Reconnect.Attempts = 20 - # # LoginDatabase.WorkerThreads # WorldDatabase.WorkerThreads @@ -1216,25 +1203,6 @@ IsPreloadedContinentTransport.Enabled = 0 # ################################################################################################### -################################################################################################### -# CRYPTOGRAPHY -# -# TOTPMasterSecret -# Description: The key used by authserver to decrypt TOTP secrets from database storage. -# You only need to set this here if you plan to use the in-game 2FA -# management commands (.account 2fa), otherwise this can be left blank. -# -# The server will auto-detect if this does not match your authserver setting, -# in which case any commands reliant on the secret will be disabled. -# -# Default: -# - -TOTPMasterSecret = - -# -################################################################################################### - ################################################################################################### # WARDEN SETTINGS # @@ -2396,24 +2364,12 @@ Battleground.CastDeserter = 1 Battleground.QueueAnnouncer.Enable = 0 # -# Battleground.QueueAnnouncer.Limit.MinLevel -# Description: Limit the QueueAnnouncer starting from a certain level. -# When limited, it announces only if there are at least MinPlayers queued (see below) -# At 80 it only limits RBG, at lower level only limits Warsong Gulch. -# Default: 0 - (Disabled, no limits) -# 10 - (Enabled for all, because BGs start at 10) -# 20 - (Enabled for 20 and higher) -# 80 - (Enabled only for 80) +# Battleground.QueueAnnouncer.Limited.Enable +# Description: Show announce only if left players in queue = 1 +# Default: 0 - (Disabled) +# 1 - (Enabled) -Battleground.QueueAnnouncer.Limit.MinLevel = 0 - -# -# Battleground.QueueAnnouncer.Limit.MinPlayers -# Description: When the Battleground.QueueAnnouncer.Limit.MinLevel limit is enabled (not 0) -# only show when at least MinPlayers are queued. -# Default: 3 - (Show only when 3 or more players are queued) - -Battleground.QueueAnnouncer.Limit.MinPlayers = 3 +Battleground.QueueAnnouncer.Limited.Enable = 0 # # Battleground.QueueAnnouncer.SpamProtection.Delay @@ -3456,7 +3412,7 @@ Logger.server=4,Console Server Logger.commands.gm=4,Console GM Logger.scripts.hotswap=4,Console Server Logger.sql.sql=2,Console DBErrors -Logger.sql=4,Console Server +Logger.sql.updates=4,Console Server Logger.mmaps=4,Server #Logger.achievement=4,Console Server