diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..eb64e2f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +tab_width = 4 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 80 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7ef9001 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,105 @@ +## AUTO-DETECT +## Handle line endings automatically for files detected as +## text and leave all files detected as binary untouched. +## This will handle all files NOT defined below. +* text=auto eol=lf + +# Text +*.conf text +*.conf.dist text +*.cmake text + +## Scripts +*.sh text +*.fish text +*.lua text + +## SQL +*.sql text + +## C++ +*.c text +*.cc text +*.cxx text +*.cpp text +*.c++ text +*.hpp text +*.h text +*.h++ text +*.hh text + + +## For documentation + +# Documents +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +## DOCUMENTATION +*.markdown text +*.md text +*.mdwn text +*.mdown text +*.mkd text +*.mkdn text +*.mdtxt text +*.mdtext text +*.txt text +AUTHORS text +CHANGELOG text +CHANGES text +CONTRIBUTING text +COPYING text +copyright text +*COPYRIGHT* text +INSTALL text +license text +LICENSE text +NEWS text +readme text +*README* text +TODO text + +## GRAPHICS +*.ai binary +*.bmp binary +*.eps binary +*.gif binary +*.ico binary +*.jng binary +*.jp2 binary +*.jpg binary +*.jpeg binary +*.jpx binary +*.jxr binary +*.pdf binary +*.png binary +*.psb binary +*.psd binary +*.svg text +*.svgz binary +*.tif binary +*.tiff binary +*.wbmp binary +*.webp binary + + +## ARCHIVES +*.7z binary +*.gz binary +*.jar binary +*.rar binary +*.tar binary +*.zip binary + +## EXECUTABLES +*.exe binary +*.pyc binary diff --git a/.github/README.md b/.github/README.md index 875c57c..2882584 100644 --- a/.github/README.md +++ b/.github/README.md @@ -4,7 +4,9 @@ ## Anticheat Module -- Latest build status with AzerothCore: [![Build Status](https://github.com/azerothcore/mod-anticheat/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-anticheat) +- Latest build status with AzerothCore: + +[![Build Status](https://github.com/azerothcore/mod-anticheat/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-anticheat) This is a port of the PassiveAnticheat Script from lordpsyan's repo to [AzerothCore](http://www.azerothcore.org) diff --git a/.github/workflows/core_codestyle.yml b/.github/workflows/core_codestyle.yml new file mode 100644 index 0000000..3f9a73e --- /dev/null +++ b/.github/workflows/core_codestyle.yml @@ -0,0 +1,19 @@ +name: Codestyle Checks +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + check-codestyle: + strategy: + fail-fast: false + + runs-on: ubuntu-latest + name: Check Codestyling + steps: + - uses: actions/checkout@v2 + + - name: Check Codestyling + run: source ./apps/ci/ci-codestyle.sh diff --git a/LICENSE b/LICENSE index 2779f82..d0882e0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 AzerothCore +Copyright (c) 2023 AzerothCore Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/apps/.gitkeep b/apps/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/apps/ci/.gitkeep b/apps/ci/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/apps/ci/ci-codestyle.sh b/apps/ci/ci-codestyle.sh new file mode 100644 index 0000000..c96a31d --- /dev/null +++ b/apps/ci/ci-codestyle.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +echo "Codestyle check script:" +echo + +declare -A singleLineRegexChecks=( + ["LOG_.+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above" + ["[[:blank:]]$"]="Remove whitespace at the end of the lines above" + ["\t"]="Replace tabs with 4 spaces in the lines above" +) + +for check in ${!singleLineRegexChecks[@]}; do + echo " Checking RegEx: '${check}'" + + if grep -P -r -I -n ${check} src; then + echo + echo "${singleLineRegexChecks[$check]}" + exit 1 + fi +done + +declare -A multiLineRegexChecks=( + ["LOG_[^;]+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above" + ["\n\n\n"]="Multiple blank lines detected, keep only one. Check the files above" +) + +for check in ${!multiLineRegexChecks[@]}; do + echo " Checking RegEx: '${check}'" + + if grep -Pzo -r -I ${check} src; then + echo + echo + echo "${multiLineRegexChecks[$check]}" + exit 1 + fi +done + +echo +echo "Everything looks good" diff --git a/conf/.gitkeep b/conf/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist deleted file mode 100644 index 57d26f1..0000000 --- a/conf/conf.sh.dist +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -## CUSTOM SQL - Important file used by the db_assembler.sh -## Keep only the required variables (base sql files or updates, depending on the DB) - - -## BASE SQL - -DB_CHARACTERS_CUSTOM_PATHS+=( - "$MOD_ANTICHEAT_ROOT/sql/characters/base/" -) - diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/data/sql/db-characters/base/charactersdb_anticheat.sql b/data/sql/db-characters/base/charactersdb_anticheat.sql new file mode 100644 index 0000000..b495d10 --- /dev/null +++ b/data/sql/db-characters/base/charactersdb_anticheat.sql @@ -0,0 +1,47 @@ +DROP TABLE IF EXISTS `daily_players_reports`; +CREATE TABLE IF NOT EXISTS `daily_players_reports` ( + `guid` int(10) unsigned NOT NULL DEFAULT '0', + `creation_time` int(10) unsigned NOT NULL DEFAULT '0', + `average` float NOT NULL DEFAULT '0', + `total_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `speed_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `fly_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `jump_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `waterwalk_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `teleportplane_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `climb_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `teleport_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `ignorecontrol_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `zaxis_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `antiswim_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `gravity_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `antiknockback_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `no_fall_damage_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `op_ack_hack_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `counter_measures_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`guid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +DROP TABLE IF EXISTS `players_reports_status`; +CREATE TABLE IF NOT EXISTS `players_reports_status` ( + `guid` int(10) unsigned NOT NULL DEFAULT '0', + `creation_time` int(10) unsigned NOT NULL DEFAULT '0', + `average` float NOT NULL DEFAULT '0', + `total_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `speed_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `fly_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `jump_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `waterwalk_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `teleportplane_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `climb_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `teleport_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `ignorecontrol_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `zaxis_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `antiswim_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `gravity_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `antiknockback_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `no_fall_damage_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `op_ack_hack_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `counter_measures_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`guid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/data/sql/db-characters/updates/.gitkeep b/data/sql/db-characters/updates/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/data/sql/db_world/base/Acore_strings.sql b/data/sql/db-world/base/Acore_strings.sql similarity index 100% rename from data/sql/db_world/base/Acore_strings.sql rename to data/sql/db-world/base/Acore_strings.sql diff --git a/data/sql/db_world/updates/AC_2022_08_15_00.sql b/data/sql/db-world/updates/AC_2022_08_15_00.sql similarity index 100% rename from data/sql/db_world/updates/AC_2022_08_15_00.sql rename to data/sql/db-world/updates/AC_2022_08_15_00.sql diff --git a/data/sql/db_world/updates/AC_2022_12_18_00.sql b/data/sql/db-world/updates/AC_2022_12_18_00.sql similarity index 100% rename from data/sql/db_world/updates/AC_2022_12_18_00.sql rename to data/sql/db-world/updates/AC_2022_12_18_00.sql diff --git a/data/sql/db_world/updates/AC_2023_03_09_00.sql b/data/sql/db-world/updates/AC_2023_03_09_00.sql similarity index 100% rename from data/sql/db_world/updates/AC_2023_03_09_00.sql rename to data/sql/db-world/updates/AC_2023_03_09_00.sql diff --git a/data/sql/db_world/updates/AC_2023_06_22_00.sql b/data/sql/db-world/updates/AC_2023_06_22_00.sql similarity index 100% rename from data/sql/db_world/updates/AC_2023_06_22_00.sql rename to data/sql/db-world/updates/AC_2023_06_22_00.sql diff --git a/data/sql/db_characters/base/charactersdb_anticheat.sql b/data/sql/db_characters/base/charactersdb_anticheat.sql deleted file mode 100644 index 4e7dbe0..0000000 --- a/data/sql/db_characters/base/charactersdb_anticheat.sql +++ /dev/null @@ -1,43 +0,0 @@ -DROP TABLE IF EXISTS `daily_players_reports`; -CREATE TABLE IF NOT EXISTS `daily_players_reports` ( - `guid` int unsigned NOT NULL DEFAULT 0, - `creation_time` int unsigned NOT NULL DEFAULT 0, - `average` float NOT NULL DEFAULT 0, - `total_reports` bigint unsigned NOT NULL DEFAULT 0, - `speed_reports` bigint unsigned NOT NULL DEFAULT 0, - `fly_reports` bigint unsigned NOT NULL DEFAULT 0, - `jump_reports` bigint unsigned NOT NULL DEFAULT 0, - `waterwalk_reports` bigint unsigned NOT NULL DEFAULT 0, - `teleportplane_reports` bigint unsigned NOT NULL DEFAULT 0, - `climb_reports` bigint unsigned NOT NULL DEFAULT 0, - `teleport_reports` bigint unsigned NOT NULL DEFAULT 0, - `ignorecontrol_reports` bigint unsigned NOT NULL DEFAULT 0, - `zaxis_reports` bigint unsigned NOT NULL DEFAULT 0, - `antiswim_reports` bigint unsigned NOT NULL DEFAULT 0, - `gravity_reports` bigint unsigned NOT NULL DEFAULT 0, - `antiknockback_reports` bigint unsigned NOT NULL DEFAULT 0, - `no_fall_damage_reports` bigint unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; - -DROP TABLE IF EXISTS `players_reports_status`; -CREATE TABLE IF NOT EXISTS `players_reports_status` ( - `guid` int unsigned NOT NULL DEFAULT 0, - `creation_time` int unsigned NOT NULL DEFAULT 0, - `average` float NOT NULL DEFAULT 0, - `total_reports` bigint unsigned NOT NULL DEFAULT 0, - `speed_reports` bigint unsigned NOT NULL DEFAULT 0, - `fly_reports` bigint unsigned NOT NULL DEFAULT 0, - `jump_reports` bigint unsigned NOT NULL DEFAULT 0, - `waterwalk_reports` bigint unsigned NOT NULL DEFAULT 0, - `teleportplane_reports` bigint unsigned NOT NULL DEFAULT 0, - `climb_reports` bigint unsigned NOT NULL DEFAULT 0, - `teleport_reports` bigint unsigned NOT NULL DEFAULT 0, - `ignorecontrol_reports` bigint unsigned NOT NULL DEFAULT 0, - `zaxis_reports` bigint unsigned NOT NULL DEFAULT 0, - `antiswim_reports` bigint unsigned NOT NULL DEFAULT 0, - `gravity_reports` bigint unsigned NOT NULL DEFAULT 0, - `antiknockback_reports` bigint unsigned NOT NULL DEFAULT 0, - `no_fall_damage_reports` bigint unsigned NOT NULL DEFAULT 0, - PRIMARY KEY (`guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/data/sql/db_characters/updates/AC_2022_08_12_00.sql b/data/sql/db_characters/updates/AC_2022_08_12_00.sql deleted file mode 100644 index 49df904..0000000 --- a/data/sql/db_characters/updates/AC_2022_08_12_00.sql +++ /dev/null @@ -1,38 +0,0 @@ --- run on character db - -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; -DELIMITER // -CREATE PROCEDURE updatemodanticheatdb() -proc:BEGIN -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'daily_players_reports' AND COLUMN_NAME = 'no_fall_damage_reports'; -IF @COLEXISTS = 1 THEN LEAVE proc; END IF; -START TRANSACTION; - -ALTER TABLE `daily_players_reports` - ADD COLUMN `no_fall_damage_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `antiknockback_reports`; - -END // -DELIMITER ; - -CALL updatemodanticheatdb(); - -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; -DELIMITER // -CREATE PROCEDURE updatemodanticheatdb() -proc:BEGIN -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'players_reports_status' AND COLUMN_NAME = 'no_fall_damage_reports'; -IF @COLEXISTS = 1 THEN LEAVE proc; END IF; -START TRANSACTION; - -ALTER TABLE `players_reports_status` - ADD COLUMN `no_fall_damage_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `antiknockback_reports`; - -END // -DELIMITER ; - -CALL updatemodanticheatdb(); -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; diff --git a/data/sql/db_characters/updates/AC_2022_08_21_00.sql b/data/sql/db_characters/updates/AC_2022_08_21_00.sql deleted file mode 100644 index 7778ae4..0000000 --- a/data/sql/db_characters/updates/AC_2022_08_21_00.sql +++ /dev/null @@ -1,38 +0,0 @@ --- run on Characters DB - -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; -DELIMITER // -CREATE PROCEDURE updatemodanticheatdb() -proc:BEGIN -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'daily_players_reports' AND COLUMN_NAME = 'op_ack_hack_reports'; -IF @COLEXISTS = 1 THEN LEAVE proc; END IF; -START TRANSACTION; - -ALTER TABLE `daily_players_reports` - ADD COLUMN `op_ack_hack_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `no_fall_damage_reports`; - -END // -DELIMITER ; - -CALL updatemodanticheatdb(); - -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; -DELIMITER // -CREATE PROCEDURE updatemodanticheatdb() -proc:BEGIN -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'players_reports_status' AND COLUMN_NAME = 'op_ack_hack_reports'; -IF @COLEXISTS = 1 THEN LEAVE proc; END IF; -START TRANSACTION; - -ALTER TABLE `players_reports_status` - ADD COLUMN `op_ack_hack_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `no_fall_damage_reports`; - -END // -DELIMITER ; - -CALL updatemodanticheatdb(); -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; diff --git a/data/sql/db_characters/updates/AC_2023_04_05_00.sql b/data/sql/db_characters/updates/AC_2023_04_05_00.sql deleted file mode 100644 index 90f8bf8..0000000 --- a/data/sql/db_characters/updates/AC_2023_04_05_00.sql +++ /dev/null @@ -1,38 +0,0 @@ --- run on Characters DB - -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; -DELIMITER // -CREATE PROCEDURE updatemodanticheatdb() -proc:BEGIN -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'daily_players_reports' AND COLUMN_NAME = 'counter_measures_reports'; -IF @COLEXISTS = 1 THEN LEAVE proc; END IF; -START TRANSACTION; - -ALTER TABLE `daily_players_reports` - ADD COLUMN `counter_measures_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `op_ack_hack_reports`; - -END // -DELIMITER ; - -CALL updatemodanticheatdb(); - -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; -DELIMITER // -CREATE PROCEDURE updatemodanticheatdb() -proc:BEGIN -SELECT COUNT(*) INTO @COLEXISTS -FROM information_schema.COLUMNS -WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'players_reports_status' AND COLUMN_NAME = 'counter_measures_reports'; -IF @COLEXISTS = 1 THEN LEAVE proc; END IF; -START TRANSACTION; - -ALTER TABLE `players_reports_status` - ADD COLUMN `counter_measures_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `op_ack_hack_reports`; - -END // -DELIMITER ; - -CALL updatemodanticheatdb(); -DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; diff --git a/include.sh b/include.sh index 87ab1bf..e69de29 100644 --- a/include.sh +++ b/include.sh @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -## GETS THE CURRENT MODULE ROOT DIRECTORY -MOD_ANTICHEAT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )" - -source "$MOD_ANTICHEAT_ROOT/conf/conf.sh.dist" - -if [ -f "$MOD_ANTICHEAT_ROOT/conf/conf.sh" ]; then - source "$MOD_ANTICHEAT_ROOT/conf/conf.sh" -fi