From fe113f9494f194a10681aa4c63cd1de7567ab2b8 Mon Sep 17 00:00:00 2001 From: Walter Pagani Date: Wed, 2 Aug 2023 07:36:57 -0300 Subject: [PATCH] feat. upgrade module (#27) * feat. upgrade module * upgrade misc. * add apps folder * codestyle * fix sql build --- .editorconfig | 8 ++ .gitattributes | 105 ++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.yml | 72 ++++++++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 33 ++++++ .github/workflows/core-build.yml | 2 - .github/workflows/core_codestyle.yml | 19 ++++ .gitignore | 2 +- README.md | 7 +- apps/.gitkeep | 0 apps/ci/.gitkeep | 0 apps/ci/ci-codestyle.sh | 40 +++++++ cmake_install.cmake | 1 - conf/.gitkeep | 0 conf/premium.conf.dist | 16 ++- data/.gitkeep | 0 .../base/mod_character_premium.sql | 0 .../db-world/base/mod_premium_item_9017.sql | 2 +- pull_request_template.md | 24 ++++ src/premium.cpp | 4 +- 19 files changed, 324 insertions(+), 11 deletions(-) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/workflows/core_codestyle.yml create mode 100644 apps/.gitkeep create mode 100644 apps/ci/.gitkeep create mode 100644 apps/ci/ci-codestyle.sh create mode 100644 conf/.gitkeep create mode 100644 data/.gitkeep rename sql/character_premium.sql => data/sql/db-characters/base/mod_character_premium.sql (100%) rename sql/example_item_9017.sql => data/sql/db-world/base/mod_premium_item_9017.sql (80%) create mode 100644 pull_request_template.md 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/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..5610d2b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,72 @@ +name: Bug report +description: Create a bug report to help us improve. +title: "Bug: " +body: + - type: textarea + id: current + attributes: + label: Current Behaviour + description: | + Description of the problem or issue here. + Include entries of affected creatures / items / quests / spells etc. + If this is a crash, post the crashlog (upload to https://gist.github.com/) and include the link here. + Never upload files! Use GIST for text and YouTube for videos! + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behaviour + description: | + Tell us what should happen instead. + validations: + required: true + - type: textarea + id: reproduce + attributes: + label: Steps to reproduce the problem + description: | + What does someone else need to do to encounter the same bug? + placeholder: | + 1. Step 1 + 2. Step 2 + 3. Step 3 + validations: + required: true + - type: textarea + id: extra + attributes: + label: Extra Notes + description: | + Do you have any extra notes that can help solve the issue that does not fit any other field? + placeholder: | + None + validations: + required: false + - type: textarea + id: commit + attributes: + label: AC rev. hash/commit + description: | + Copy the result of the `.server debug` command (if you need to run it from the client get a prat addon) + validations: + required: true + - type: input + id: os + attributes: + label: Operating system + description: | + The Operating System the Server is running on. + i.e. Windows 11 x64, Debian 10 x64, macOS 12, Ubuntu 20.04 + validations: + required: true + - type: textarea + id: custom + attributes: + label: Custom changes or Modules + description: | + List which custom changes or modules you have applied, i.e. Eluna module, etc. + placeholder: | + None + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..58f79dd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,33 @@ +name: Feature request +description: Suggest an idea for this project +title: "Feature: " +body: + - type: markdown + attributes: + value: | + Thank you for taking your time to fill out a feature request. Remember to fill out all fields including the title above. + An issue that is not properly filled out will be closed. + - type: textarea + id: description + attributes: + label: Describe your feature request or suggestion in detail + description: | + A clear and concise description of what you want to happen. + validations: + required: true + - type: textarea + id: solution + attributes: + label: Describe a possible solution to your feature or suggestion in detail + description: | + A clear and concise description of any alternative solutions or features you've considered. + validations: + required: false + - type: textarea + id: additional + attributes: + label: Additional context + description: | + Add any other context or screenshots about the feature request here. + validations: + required: false diff --git a/.github/workflows/core-build.yml b/.github/workflows/core-build.yml index 921c9eb..1eec897 100644 --- a/.github/workflows/core-build.yml +++ b/.github/workflows/core-build.yml @@ -1,8 +1,6 @@ name: core-build on: push: - branches: - - 'master' pull_request: jobs: 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/.gitignore b/.gitignore index d011fdd..c6e1299 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ .mailmap *.orig *.rej -*~ +*.*~ .hg/ *.kdev* .DS_Store diff --git a/README.md b/README.md index 552b75a..2af4a1b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore + ## Premium Account -- Latest Premium Account build status with azerothcore: [![Build Status](https://github.com/azerothcore/mod-premium/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-premium) +- Latest Premium Account build status with azerothcore: + +[![Build Status](https://github.com/azerothcore/mod-premium/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-premium) This is a module for [AzerothCore](http://www.azerothcore.org) that adds Premium account features to players. @@ -52,10 +55,8 @@ assign the script to an item such as hearthstone using the script name 'premium_ If you need to change the module configuration, go to your server configuration folder (e.g. **etc**), copy `premium.conf.dist` to `premium.conf` and edit it as you prefer. - ## Test the module There is a SQL query so you can create an item and test it quickly. ![item screenshot](/screenshots/item.png?raw=true "item screenshot") - 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/cmake_install.cmake b/cmake_install.cmake index 0a3915d..d90fb14 100644 --- a/cmake_install.cmake +++ b/cmake_install.cmake @@ -26,4 +26,3 @@ if(NOT CMAKE_INSTALL_COMPONENT) set(CMAKE_INSTALL_COMPONENT) endif() endif() - diff --git a/conf/.gitkeep b/conf/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/conf/premium.conf.dist b/conf/premium.conf.dist index 40f8db4..cea4966 100644 --- a/conf/premium.conf.dist +++ b/conf/premium.conf.dist @@ -6,24 +6,28 @@ # Description: Enable PremiumAccount for players # Default: 1 - (Enabled) # 0 - (Disabled) + PremiumAccount = 1 # Morph # Description: Enable Morph & demorph option for players # Default: 1 - (Enabled) # 0 - (Disabled) + Morph = 1 # Mount # Description: Allow Players to use mount # Default: 1 - (Enabled) # 0 - (Disabled) + Mount = 1 # Class Trainers # Description: Allows players to spawn class trainers # Default: 1 - (Enabled) # 0 - (Disabled) + Trainers = 1 ################################################################################################################# @@ -31,33 +35,43 @@ Trainers = 1 # Description: This enables the submenu for the below # Default: 1 - (Enabled) # 0 - (Disabled) + PlayerInteraction = 1 + # # Bank # Description: Allow Players to use mobile bank # Default: 1 - (Enabled) # 0 - (Disabled) + Bank = 1 + # # Auction # Description: Allow Players to use mobile Auction # Default: 1 - (Enabled) # 0 - (Disabled) + Auction = 1 + # Vendor # Description: Allow Players to use vendor # Default: 1 - (Enabled) # 0 - (Disabled) + Vendor = 1 + # # Mail Box # Description: Allow Players Access ingame Mail # Default: 1 - (Enabled) # 0 - (Disabled) + MailBox = 1 ################################################################################################################## # Premium.NpcDuration # Description: Time (in seconds) before despawn of summoned NPC # Default: 60 - (Seconds) -Premium.NpcDuration = 60 \ No newline at end of file + +Premium.NpcDuration = 60 diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sql/character_premium.sql b/data/sql/db-characters/base/mod_character_premium.sql similarity index 100% rename from sql/character_premium.sql rename to data/sql/db-characters/base/mod_character_premium.sql diff --git a/sql/example_item_9017.sql b/data/sql/db-world/base/mod_premium_item_9017.sql similarity index 80% rename from sql/example_item_9017.sql rename to data/sql/db-world/base/mod_premium_item_9017.sql index 93fb942..d7532ca 100644 --- a/sql/example_item_9017.sql +++ b/data/sql/db-world/base/mod_premium_item_9017.sql @@ -1,4 +1,4 @@ -- Replace an unused item (so no worries) by this one with the premium account script + description + item quality -- Try the item with: .add 9017 -REPLACE INTO `item_template` (`entry`, `class`, `subclass`, `SoundOverrideSubclass`, `name`, `displayid`, `Quality`, `Flags`, `FlagsExtra`, `BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1`, `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus`, `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `duration`, `ItemLimitCategory`, `HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`, `flagsCustom`, `VerifiedBuild`) VALUES (9017, 15, 4, -1, 'Book of Powers', 1143, 7, 0, 0, 1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54406, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 'Premium Account Magic!\r\nUse with caution!\r\n\r\nAllowed by Brann Bronzebeard!', 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 'premium_account', 0, 0, 0, 0, 0, 12340); +REPLACE INTO `item_template` (`entry`, `class`, `subclass`, `SoundOverrideSubclass`, `name`, `displayid`, `Quality`, `Flags`, `FlagsExtra`, `BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1`, `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus`, `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `duration`, `ItemLimitCategory`, `HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`, `flagsCustom`, `VerifiedBuild`) VALUES (9017, 9, 0, -1, 'Book of Powers', 1143, 7, 0, 0, 1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54406, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 'Premium Account Magic!\r\nUse with caution!\r\n\r\nAllowed by Brann Bronzebeard!', 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 'premium_account', 0, 0, 0, 0, 0, 12340); diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..cd1624c --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,24 @@ + + +## Changes Proposed: +- +- + +## Issues Addressed: + +- Closes + +## SOURCE: + + +## Tests Performed: + +- +- + +## How to Test the Changes: + + +1. +2. +3. diff --git a/src/premium.cpp b/src/premium.cpp index 23d6943..bf937df 100644 --- a/src/premium.cpp +++ b/src/premium.cpp @@ -277,9 +277,9 @@ public: case 4: player->SetDisplayId(10137); break; // Human Male 'Orb of Deception' case 5: player->SetDisplayId(10138); break; // Human Female 'Orb of Deception' case 6: player->SetDisplayId(10139); break; // Orc Male 'Orb of Deception' - case 7: player->SetDisplayId(10140); break; // Orc Female 'Orb of Deception' + case 7: player->SetDisplayId(10140); break; // Orc Female 'Orb of Deception' case 8: player->SetDisplayId(10141); break; // Dwarf Male 'Orb of Deception' - case 9: player->SetDisplayId(10142); break; // Dwarf Female 'Orb of Deception' + case 9: player->SetDisplayId(10142); break; // Dwarf Female 'Orb of Deception' case 10: player->SetDisplayId(10143); break; // NightElf Male 'Orb of Deception' case 11: player->SetDisplayId(10144); break; // NightElf Female 'Orb of Deception' case 12: player->SetDisplayId(10145); break; // Undead Female 'Orb of Deception'