From ea10cd69eb981efd5399a204bbf4b3d210932117 Mon Sep 17 00:00:00 2001 From: Pagani Walter Date: Sun, 7 Apr 2024 17:16:57 -0300 Subject: [PATCH 1/2] chore. Compatibility with the latest version --- .git_commit_template.txt | 49 ----- .gitattributes | 10 +- .github/ISSUE_TEMPLATE/bug_report.yml | 72 +++++++ .github/ISSUE_TEMPLATE/feature_request.yml | 33 +++ README.md | 39 ++-- {sql/auth => conf}/.gitkeep | 0 conf/conf.sh.dist | 13 -- {sql/characters => data}/.gitkeep | 0 .../world => data/sql/db-characters}/.gitkeep | 0 .../db-characters/2024_04_07_guildhouse.sql | 0 data/sql/db-world/.gitkeep | 0 .../2024_04_07_00_creatures_objects.sql | 0 .../2024_04_07_01_guildhouse_spawns.sql | 0 include.sh | 9 - setup_git_commit_template.sh | 4 - sql/README.md | 24 --- src/loader.cpp | 3 +- src/mod_guildhouse.cpp | 192 +++++++++--------- src/mod_guildhouse_butler.cpp | 49 +++-- 19 files changed, 252 insertions(+), 245 deletions(-) delete mode 100644 .git_commit_template.txt create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml rename {sql/auth => conf}/.gitkeep (100%) delete mode 100644 conf/conf.sh.dist rename {sql/characters => data}/.gitkeep (100%) rename {sql/world => data/sql/db-characters}/.gitkeep (100%) rename sql/characters/guildhouse.sql => data/sql/db-characters/2024_04_07_guildhouse.sql (100%) create mode 100644 data/sql/db-world/.gitkeep rename sql/world/creatures_objects.sql => data/sql/db-world/2024_04_07_00_creatures_objects.sql (100%) rename sql/world/guildhouse_spawns.sql => data/sql/db-world/2024_04_07_01_guildhouse_spawns.sql (100%) delete mode 100644 setup_git_commit_template.sh delete mode 100644 sql/README.md diff --git a/.git_commit_template.txt b/.git_commit_template.txt deleted file mode 100644 index 708b551..0000000 --- a/.git_commit_template.txt +++ /dev/null @@ -1,49 +0,0 @@ -### TITLE -## Type(Scope/Subscope): Commit ultra short explanation -## |---- Write below the examples with a maximum of 50 characters ----| -## Example 1: fix(DB/SAI): Missing spell to NPC Hogger -## Example 2: fix(CORE/Raid): Phase 2 of Ragnaros -## Example 3: feat(CORE/Commands): New GM command to do something - - -### DESCRIPTION -## Explain why this change is being made, what does it fix etc... -## |---- Write below the examples with a maximum of 72 characters per lines ----| -## Example: Hogger (id: 492) was not charging player when being engaged. - - -## Provide links to any issue, commit, pull request or other resource -## Example 1: Closes issue #23 -## Example 2: Ported from other project's commit (link) -## Example 3: References taken from wowpedia / wowhead / wowwiki / https://wowgaming.altervista.org/aowow/ - - - -## ======================================================= -## EXTRA INFOS -## ======================================================= -## "Type" can be: -## feat (new feature) -## fix (bug fix) -## refactor (refactoring production code) -## style (formatting, missing semi colons, etc; no code change) -## docs (changes to documentation) -## test (adding or refactoring tests; no production code change) -## chore (updating bash scripts, git files etc; no production code change) -## -------------------- -## Remember to -## Capitalize the subject line -## Use the imperative mood in the subject line -## Do not end the subject line with a period -## Separate subject from body with a blank line -## Use the body to explain what and why rather than how -## Can use multiple lines with "-" for bullet points in body -## -------------------- -## More info here https://www.conventionalcommits.org/en/v1.0.0-beta.2/ -## ======================================================= -## "Scope" can be: -## CORE (core related, c++) -## DB (database related, sql) -## ======================================================= -## "Subscope" is optional and depends on the nature of the commit. -## ======================================================= diff --git a/.gitattributes b/.gitattributes index 7ef9001..a20e449 100644 --- a/.gitattributes +++ b/.gitattributes @@ -32,16 +32,16 @@ ## For documentation # Documents -*.doc diff=astextplain -*.DOC diff=astextplain +*.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 +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain ## DOCUMENTATION *.markdown text 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/README.md b/README.md index 7cb365d..9894d03 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 -- Latest build status with azerothcore: [![Build Status](https://travis-ci.org/azerothcore/mod-guildhouse.svg?branch=master)](https://travis-ci.org/azerothcore/mod-guildhouse) -# Guild House Module +- Latest build status with azerothcore: + +[![Build Status](https://travis-ci.org/azerothcore/mod-guildhouse.svg)](https://travis-ci.org/azerothcore/mod-guildhouse) + +# Guild House Module ## Important notes @@ -10,19 +13,20 @@ You have to use at least AzerothCore commit [77f1363](https://github.com/azeroth ## Description This is a phased guild house system for AzerothCore, it allows players from the same guild to visit their guild house. + All guilds will get their own phasing system and then the guild master can purchase NPC creatures and other stuff to complete the Guild House. ### Purchasables -* Class Trainers (all available in Wrath) -* Primary Profession Trainers (all available in Wrath) -* Secondary Profession Trainers (all available in Wrath) -* Vendors: Reagents Vendor, Food & Drink, Trade Goods, Ammo & Repair Vendor, and Poisons Vendor -* Portals to Neutral, Horde and Alliance cities -* Spirit Healer -* Guild Bank and Personal Bank access -* Auctioneer/Neutral Auctioneer -* Stable Master +- Class Trainers (all available in Wrath) +- Primary Profession Trainers (all available in Wrath) +- Secondary Profession Trainers (all available in Wrath) +- Vendors: Reagents Vendor, Food & Drink, Trade Goods, Ammo & Repair Vendor, and Poisons Vendor +- Portals to Neutral, Horde and Alliance cities +- Spirit Healer +- Guild Bank and Personal Bank access +- Auctioneer/Neutral Auctioneer +- Stable Master ## How to use ingame @@ -36,8 +40,7 @@ All guilds will get their own phasing system and then the guild master can purch ``` 1) Place the module under the `modules` directory of your AzerothCore source. -2) Import the SQL files manually to the right Database (auth, world or characters) -3) Re-run cmake and launch a clean build of AzerothCore. +2) Re-run cmake and launch a clean build of AzerothCore. ``` ## Edit module configuration (optional) @@ -46,10 +49,10 @@ If you need to change the module configuration, go to your server configuration ## Credits -* [Talamortis](https://github.com/talamortis) (Original author of the module) -* [Rochet2](https://github.com/Rochet2/): Thanks for the help with the phasing situation & General support -* [rbedfordpro](https://github.com/rbedfordpro) & [WiZZy](https://github.com/wizzymore) -* [Nelnamara - Porkserver](https://github.com/Porkserver) & [SoulSeekkor](https://github.com/SoulSeekkor) 2022 rework, crash fixes and new additions -* [Bogir](https://github.com/Bogir) For being amazing and forever helpful +- [Talamortis](https://github.com/talamortis) (Original author of the module) +- [Rochet2](https://github.com/Rochet2/): Thanks for the help with the phasing situation & General support +- [rbedfordpro](https://github.com/rbedfordpro) & [WiZZy](https://github.com/wizzymore) +- [Nelnamara - Porkserver](https://github.com/Porkserver) & [SoulSeekkor](https://github.com/SoulSeekkor) 2022 rework, crash fixes and new additions +- [Bogir](https://github.com/Bogir) For being amazing and forever helpful AzerothCore: [repository](https://github.com/azerothcore) - [website](http://azerothcore.org/) - [discord chat community](https://discord.gg/64FH6Y8) diff --git a/sql/auth/.gitkeep b/conf/.gitkeep similarity index 100% rename from sql/auth/.gitkeep rename to conf/.gitkeep diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist deleted file mode 100644 index b902971..0000000 --- a/conf/conf.sh.dist +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# -# CUSTOM -# - -DB_CHARACTERS_CUSTOM_PATHS+=( - $MOD_GUILDHOUSE_ROOT"/sql/characters/" -) - -DB_WORLD_CUSTOM_PATHS+=( - $MOD_GUILDHOUSE_ROOT"/sql/world/" -) diff --git a/sql/characters/.gitkeep b/data/.gitkeep similarity index 100% rename from sql/characters/.gitkeep rename to data/.gitkeep diff --git a/sql/world/.gitkeep b/data/sql/db-characters/.gitkeep similarity index 100% rename from sql/world/.gitkeep rename to data/sql/db-characters/.gitkeep diff --git a/sql/characters/guildhouse.sql b/data/sql/db-characters/2024_04_07_guildhouse.sql similarity index 100% rename from sql/characters/guildhouse.sql rename to data/sql/db-characters/2024_04_07_guildhouse.sql diff --git a/data/sql/db-world/.gitkeep b/data/sql/db-world/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/sql/world/creatures_objects.sql b/data/sql/db-world/2024_04_07_00_creatures_objects.sql similarity index 100% rename from sql/world/creatures_objects.sql rename to data/sql/db-world/2024_04_07_00_creatures_objects.sql diff --git a/sql/world/guildhouse_spawns.sql b/data/sql/db-world/2024_04_07_01_guildhouse_spawns.sql similarity index 100% rename from sql/world/guildhouse_spawns.sql rename to data/sql/db-world/2024_04_07_01_guildhouse_spawns.sql diff --git a/include.sh b/include.sh index 6cbfe00..e69de29 100644 --- a/include.sh +++ b/include.sh @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -MOD_GUILDHOUSE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )" - -source $MOD_GUILDHOUSE_ROOT"/conf/conf.sh.dist" - -if [ -f $MOD_GUILDHOUSE_ROOT"/conf/conf.sh" ]; then - source $MOD_GUILDHOUSE_ROOT"/conf/conf.sh" -fi diff --git a/setup_git_commit_template.sh b/setup_git_commit_template.sh deleted file mode 100644 index 7b52062..0000000 --- a/setup_git_commit_template.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -## Set a local git commit template -git config --local commit.template ".git_commit_template.txt" ; diff --git a/sql/README.md b/sql/README.md deleted file mode 100644 index 3afd348..0000000 --- a/sql/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# BEST PRACTICES - -## Create a new table - -**Example:** -``` -CREATE TABLE IF NOT EXISTS `table`( - `id` int(11) unsigned NOT NULL, - `active` BOOLEAN DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -``` - -**Boolean datatype in mysql:** -Use "TinyInt(1)"" or "Boolean" (this is the same thing) - -"bit(1)" can also work, but it may require a syntax like b'(0) and b'(1) when inserting (not sure). - -If there are multiple booleans in the same table, bit(1) is better, otherwise it's the same result. - - -## Resources - -https://www.w3schools.com/sql/sql_datatypes.asp diff --git a/src/loader.cpp b/src/loader.cpp index 335badd..fd8b0ac 100755 --- a/src/loader.cpp +++ b/src/loader.cpp @@ -1,7 +1,8 @@ void AddGuildHouseScripts(); void AddGuildHouseButlerScripts(); -void Addmod_guildhouseScripts() { +void Addmod_guildhouseScripts() +{ AddGuildHouseScripts(); AddGuildHouseButlerScripts(); } diff --git a/src/mod_guildhouse.cpp b/src/mod_guildhouse.cpp index aaa5c19..ca24509 100644 --- a/src/mod_guildhouse.cpp +++ b/src/mod_guildhouse.cpp @@ -33,17 +33,17 @@ class GuildHelper : public GuildScript public: GuildHelper() : GuildScript("GuildHelper") {} - void OnCreate(Guild *, Player *leader, const std::string &) + void OnCreate(Guild* /*guild*/, Player* leader, const std::string& /*name*/) { ChatHandler(leader->GetSession()).PSendSysMessage("You now own a guild. You can purchase a Guild House!"); } - uint32 GetGuildPhase(Guild *guild) + uint32 GetGuildPhase(Guild* guild) { return guild->GetId() + 10; } - void OnDisband(Guild *guild) + void OnDisband(Guild* guild) { if (RemoveGuildHouse(guild)) @@ -56,29 +56,28 @@ class GuildHelper : public GuildScript } } - bool RemoveGuildHouse(Guild *guild) + bool RemoveGuildHouse(Guild* guild) { - uint32 guildPhase = GetGuildPhase(guild); QueryResult CreatureResult; QueryResult GameobjResult; // Lets find all of the gameobjects to be removed - GameobjResult = WorldDatabase.Query("SELECT `guid` FROM `gameobject` WHERE `map` = 1 AND `phaseMask` = '{}'", guildPhase); + GameobjResult = WorldDatabase.Query("SELECT `guid` FROM `gameobject` WHERE `map`=1 AND `phaseMask`={}", guildPhase); // Lets find all of the creatures to be removed - CreatureResult = WorldDatabase.Query("SELECT `guid` FROM `creature` WHERE `map` = 1 AND `phaseMask` = '{}'", guildPhase); + CreatureResult = WorldDatabase.Query("SELECT `guid` FROM `creature` WHERE `map`=1 AND `phaseMask`={}", guildPhase); - Map *map = sMapMgr->FindMap(1, 0); + Map* map = sMapMgr->FindMap(1, 0); // Remove creatures from the deleted guild house map if (CreatureResult) { do { - Field *fields = CreatureResult->Fetch(); + Field* fields = CreatureResult->Fetch(); uint32 lowguid = fields[0].Get(); - if (CreatureData const *cr_data = sObjectMgr->GetCreatureData(lowguid)) + if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid)) { - if (Creature *creature = map->GetCreature(ObjectGuid::Create(cr_data->id1, lowguid))) + if (Creature* creature = map->GetCreature(ObjectGuid::Create(cr_data->id1, lowguid))) { creature->CombatStop(); creature->DeleteFromDB(); @@ -95,9 +94,9 @@ class GuildHelper : public GuildScript { Field *fields = GameobjResult->Fetch(); uint32 lowguid = fields[0].Get(); - if (GameObjectData const *go_data = sObjectMgr->GetGameObjectData(lowguid)) + if (GameObjectData const* go_data = sObjectMgr->GetGameObjectData(lowguid)) { - if (GameObject *gobject = map->GetGameObject(ObjectGuid::Create(go_data->id, lowguid))) + if (GameObject* gobject = map->GetGameObject(ObjectGuid::Create(go_data->id, lowguid))) { gobject->SetRespawnTime(0); gobject->Delete(); @@ -111,7 +110,7 @@ class GuildHelper : public GuildScript } // Delete actual guild_house data from characters database - CharacterDatabase.Query("DELETE FROM `guild_house` WHERE `guild` = '{}'", guild->GetId()); + CharacterDatabase.Query("DELETE FROM `guild_house` WHERE `guild`={}", guild->GetId()); return true; } @@ -121,27 +120,24 @@ class GuildHouseSeller : public CreatureScript { public: - GuildHouseSeller() : CreatureScript("GuildHouseSeller") - { - } + GuildHouseSeller() : CreatureScript("GuildHouseSeller") {} struct GuildHouseSellerAI : public ScriptedAI { - GuildHouseSellerAI(Creature *creature) : ScriptedAI(creature) {} + GuildHouseSellerAI(Creature* creature) : ScriptedAI(creature) {} - void UpdateAI(uint32 /* diff */) override + void UpdateAI(uint32 /*diff*/) override { me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); } }; - CreatureAI * - GetAI(Creature *creature) const override + CreatureAI * GetAI(Creature* creature) const override { return new GuildHouseSellerAI(creature); } - bool OnGossipHello(Player *player, Creature *creature) override + bool OnGossipHello(Player* player, Creature* creature) override { if (!player->GetGuild()) { @@ -158,8 +154,8 @@ class GuildHouseSeller : public CreatureScript AddGossipItemFor(player, GOSSIP_ICON_TABARD, "Teleport to Guild House", GOSSIP_SENDER_MAIN, 1); // Only show "Sell" option if they have a guild house & have permission to sell it - Guild *guild = sGuildMgr->GetGuildById(player->GetGuildId()); - Guild::Member const *memberMe = guild->GetMember(player->GetGUID()); + Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()); + Guild::Member const* memberMe = guild->GetMember(player->GetGUID()); if (memberMe->IsRankNotLower(sConfigMgr->GetOption("GuildHouseSellRank", 0))) { AddGossipItemFor(player, GOSSIP_ICON_TABARD, "Sell Guild House!", GOSSIP_SENDER_MAIN, 3, "Are you sure you want to sell your Guild House?", 0, false); @@ -179,7 +175,7 @@ class GuildHouseSeller : public CreatureScript return true; } - bool OnGossipSelect(Player *player, Creature *m_creature, uint32, uint32 action) override + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override { uint32 map; float posX; @@ -200,11 +196,11 @@ class GuildHouseSeller : public CreatureScript CloseGossipMenuFor(player); break; case 4: // --- MORE TO COME --- - BuyGuildHouse(player->GetGuild(), player, m_creature); + BuyGuildHouse(player->GetGuild(), player, creature); break; case 3: // sell back guild house { - QueryResult has_gh = CharacterDatabase.Query("SELECT id, `guild` FROM `guild_house` WHERE guild = {}", player->GetGuildId()); + QueryResult has_gh = CharacterDatabase.Query("SELECT id, `guild` FROM `guild_house` WHERE guild={}", player->GetGuildId()); if (!has_gh) { ChatHandler(player->GetSession()).PSendSysMessage("Your guild does not own a Guild House!"); @@ -229,10 +225,10 @@ class GuildHouseSeller : public CreatureScript break; } case 2: // buy guild house - BuyGuildHouse(player->GetGuild(), player, m_creature); + BuyGuildHouse(player->GetGuild(), player, creature); break; case 1: // teleport to guild house - TeleportGuildHouse(player->GetGuild(), player, m_creature); + TeleportGuildHouse(player->GetGuild(), player, creature); break; } @@ -255,12 +251,12 @@ class GuildHouseSeller : public CreatureScript return true; } - uint32 GetGuildPhase(Player *player) + uint32 GetGuildPhase(Player* player) { return player->GetGuildId() + 10; } - bool RemoveGuildHouse(Player *player) + bool RemoveGuildHouse(Player* player) { uint32 guildPhase = GetGuildPhase(player); @@ -277,11 +273,11 @@ class GuildHouseSeller : public CreatureScript { do { - Field *fields = CreatureResult->Fetch(); + Field* fields = CreatureResult->Fetch(); uint32 lowguid = fields[0].Get(); - if (CreatureData const *cr_data = sObjectMgr->GetCreatureData(lowguid)) + if (CreatureData const* cr_data = sObjectMgr->GetCreatureData(lowguid)) { - if (Creature *creature = map->GetCreature(ObjectGuid::Create(cr_data->id1, lowguid))) + if (Creature* creature = map->GetCreature(ObjectGuid::Create(cr_data->id1, lowguid))) { creature->CombatStop(); creature->DeleteFromDB(); @@ -296,11 +292,11 @@ class GuildHouseSeller : public CreatureScript { do { - Field *fields = GameobjResult->Fetch(); + Field* fields = GameobjResult->Fetch(); uint32 lowguid = fields[0].Get(); - if (GameObjectData const *go_data = sObjectMgr->GetGameObjectData(lowguid)) + if (GameObjectData const* go_data = sObjectMgr->GetGameObjectData(lowguid)) { - if (GameObject *gobject = map->GetGameObject(ObjectGuid::Create(go_data->id, lowguid))) + if (GameObject* gobject = map->GetGameObject(ObjectGuid::Create(go_data->id, lowguid))) { gobject->SetRespawnTime(0); gobject->Delete(); @@ -314,12 +310,12 @@ class GuildHouseSeller : public CreatureScript } // Delete actual guild_house data from characters database - CharacterDatabase.Query("DELETE FROM `guild_house` WHERE `guild` = '{}'", player->GetGuildId()); + CharacterDatabase.Query("DELETE FROM `guild_house` WHERE `guild`={}", player->GetGuildId()); return true; } - void SpawnStarterPortal(Player *player) + void SpawnStarterPortal(Player* player) { uint32 entry = 0; @@ -328,7 +324,7 @@ class GuildHouseSeller : public CreatureScript float posZ; float ori; - Map *map = sMapMgr->FindMap(1, 0); + Map* map = sMapMgr->FindMap(1, 0); if (player->GetTeamId() == TEAM_ALLIANCE) { @@ -347,7 +343,7 @@ class GuildHouseSeller : public CreatureScript return; } - QueryResult result = WorldDatabase.Query("SELECT `posX`, `posY`, `posZ`, `orientation` FROM `guild_house_spawns` WHERE `entry` = {}", entry); + QueryResult result = WorldDatabase.Query("SELECT `posX`, `posY`, `posZ`, `orientation` FROM `guild_house_spawns` WHERE `entry`={}", entry); if (!result) { @@ -357,7 +353,7 @@ class GuildHouseSeller : public CreatureScript do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); posX = fields[0].Get(); posY = fields[1].Get(); posZ = fields[2].Get(); @@ -372,7 +368,7 @@ class GuildHouseSeller : public CreatureScript return; } - const GameObjectTemplate *objectInfo = sObjectMgr->GetGameObjectTemplate(objectId); + const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId); if (!objectInfo) { @@ -386,7 +382,7 @@ class GuildHouseSeller : public CreatureScript return; } - GameObject *object = sObjectMgr->IsGameObjectStaticTransport(objectInfo->entry) ? new StaticTransport() : new GameObject(); + GameObject* object = sObjectMgr->IsGameObjectStaticTransport(objectInfo->entry) ? new StaticTransport() : new GameObject(); ObjectGuid::LowType guidLow = player->GetMap()->GenerateLowGuid(); if (!object->Create(guidLow, objectInfo->entry, map, GetGuildPhase(player), posX, posY, posZ, ori, G3D::Quat(), 0, GO_STATE_READY)) @@ -416,7 +412,7 @@ class GuildHouseSeller : public CreatureScript CloseGossipMenuFor(player); } - void SpawnButlerNPC(Player *player) + void SpawnButlerNPC(Player* player) { uint32 entry = 500031; float posX = 16202.185547f; @@ -424,7 +420,7 @@ class GuildHouseSeller : public CreatureScript float posZ = 21.160221f; float ori = 6.195375f; - Map *map = sMapMgr->FindMap(1, 0); + Map* map = sMapMgr->FindMap(1, 0); Creature *creature = new Creature(); if (!creature->Create(map->GenerateLowGuid(), map, player->GetPhaseMaskForSpawn(), entry, 0, posX, posY, posZ, ori)) @@ -448,9 +444,9 @@ class GuildHouseSeller : public CreatureScript return; } - bool BuyGuildHouse(Guild *guild, Player *player, Creature *creature) + bool BuyGuildHouse(Guild* guild, Player* player, Creature* creature) { - QueryResult result = CharacterDatabase.Query("SELECT `id`, `guild` FROM guild_house WHERE `guild` = {}", guild->GetId()); + QueryResult result = CharacterDatabase.Query("SELECT `id`, `guild` FROM `guild_house` WHERE `guild`={}", guild->GetId()); if (result) { @@ -467,10 +463,10 @@ class GuildHouseSeller : public CreatureScript return true; } - void TeleportGuildHouse(Guild *guild, Player *player, Creature *creature) + void TeleportGuildHouse(Guild* guild, Player* player, Creature* creature) { - GuildData *guildData = player->CustomData.GetDefault("phase"); - QueryResult result = CharacterDatabase.Query("SELECT `phase`, `map`,`positionX`, `positionY`, `positionZ`, `orientation` FROM guild_house WHERE `guild` = {}", guild->GetId()); + GuildData* guildData = player->CustomData.GetDefault("phase"); + QueryResult result = CharacterDatabase.Query("SELECT `phase`, `map`,`positionX`, `positionY`, `positionZ`, `orientation` FROM `guild_house` WHERE `guild`={}", guild->GetId()); if (!result) { @@ -492,7 +488,7 @@ class GuildHouseSeller : public CreatureScript do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); guildData->phase = fields[0].Get(); uint32 map = fields[1].Get(); guildData->posX = fields[2].Get(); @@ -511,12 +507,12 @@ class GuildHousePlayerScript : public PlayerScript public: GuildHousePlayerScript() : PlayerScript("GuildHousePlayerScript") {} - void OnLogin(Player *player) + void OnLogin(Player* player) { CheckPlayer(player); } - void OnUpdateZone(Player *player, uint32 newZone, uint32 /*newArea*/) + void OnUpdateZone(Player* player, uint32 newZone, uint32 /*newArea*/) { if (newZone == 876) CheckPlayer(player); @@ -524,26 +520,26 @@ class GuildHousePlayerScript : public PlayerScript player->SetPhaseMask(GetNormalPhase(player), true); } - bool OnBeforeTeleport(Player *player, uint32 mapid, float x, float y, float z, float orientation, uint32 options, Unit *target) - { - (void)mapid; - (void)x; - (void)y; - (void)z; - (void)orientation; - (void)options; - (void)target; + bool OnBeforeTeleport(Player* player, uint32 mapid, float x, float y, float z, float orientation, uint32 options, Unit* target) + { + (void)mapid; + (void)x; + (void)y; + (void)z; + (void)orientation; + (void)options; + (void)target; if (player->GetZoneId() == 876 && player->GetAreaId() == 876) // GM Island - { - // Remove the rested state when teleporting from the guild house - player->RemoveRestState(); - } - - return true; - } - - uint32 GetNormalPhase(Player *player) const + { + // Remove the rested state when teleporting from the guild house + player->RemoveRestState(); + } + + return true; + } + + uint32 GetNormalPhase(Player* player) const { if (player->IsGameMaster()) return PHASEMASK_ANYWHERE; @@ -555,9 +551,9 @@ class GuildHousePlayerScript : public PlayerScript return phase; } - void CheckPlayer(Player *player) + void CheckPlayer(Player* player) { - GuildData *guildData = player->CustomData.GetDefault("phase"); + GuildData* guildData = player->CustomData.GetDefault("phase"); QueryResult result = CharacterDatabase.Query("SELECT `id`, `guild`, `phase`, `map`,`positionX`, `positionY`, `positionZ`, `orientation` FROM guild_house WHERE `guild` = {}", player->GetGuildId()); if (result) @@ -580,9 +576,9 @@ class GuildHousePlayerScript : public PlayerScript if (player->GetZoneId() == 876 && player->GetAreaId() == 876) // GM Island { - // Set the guild house as a rested area - player->SetRestState(0); - + // Set the guild house as a rested area + player->SetRestState(0); + // If player is not in a guild he doesnt have a guild house teleport away // TODO: What if they are in a guild, but somehow are in the wrong phaseMask and seeing someone else's area? @@ -592,13 +588,14 @@ class GuildHousePlayerScript : public PlayerScript teleportToDefault(player); return; } + player->SetPhaseMask(guildData->phase, true); } else player->SetPhaseMask(GetNormalPhase(player), true); } - void teleportToDefault(Player *player) + void teleportToDefault(Player* player) { if (player->GetTeamId() == TEAM_ALLIANCE) player->TeleportTo(0, -8833.379883f, 628.627991f, 94.006599f, 1.0f); @@ -617,28 +614,30 @@ class GuildHouseCommand : public CommandScript ChatCommandTable GetCommands() const override { static ChatCommandTable GuildHouseCommandTable = - { - {"teleport", HandleGuildHouseTeleCommand, SEC_PLAYER, Console::Yes}, - {"butler", HandleSpawnButlerCommand, SEC_PLAYER, Console::Yes}, - }; + { + {"teleport", HandleGuildHouseTeleCommand, SEC_PLAYER, Console::Yes}, + {"butler", HandleSpawnButlerCommand, SEC_PLAYER, Console::Yes}, + }; static ChatCommandTable GuildHouseCommandBaseTable = - { - {"guildhouse", GuildHouseCommandTable}, - {"gh", GuildHouseCommandTable}}; + { + {"guildhouse", GuildHouseCommandTable}, + {"gh", GuildHouseCommandTable} + }; return GuildHouseCommandBaseTable; } - static uint32 GetGuildPhase(Player *player) + static uint32 GetGuildPhase(Player* player) { return player->GetGuildId() + 10; } - static bool HandleSpawnButlerCommand(ChatHandler *handler) + static bool HandleSpawnButlerCommand(ChatHandler* handler) { - Player *player = handler->GetSession()->GetPlayer(); - Map *map = player->GetMap(); + Player* player = handler->GetSession()->GetPlayer(); + Map* map = player->GetMap(); + if (!player->GetGuild() || (player->GetGuild()->GetLeaderGUID() != player->GetGUID())) { handler->SendSysMessage("You must be the Guild Master of a guild to use this command!"); @@ -665,7 +664,7 @@ class GuildHouseCommand : public CommandScript float posZ = 21.160221f; float ori = 6.195375f; - Creature *creature = new Creature(); + Creature* creature = new Creature(); if (!creature->Create(map->GenerateLowGuid(), map, GetGuildPhase(player), 500031, 0, posX, posY, posZ, ori)) { handler->SendSysMessage("You already have the Guild House Butler!"); @@ -691,9 +690,9 @@ class GuildHouseCommand : public CommandScript return true; } - static bool HandleGuildHouseTeleCommand(ChatHandler *handler) + static bool HandleGuildHouseTeleCommand(ChatHandler* handler) { - Player *player = handler->GetSession()->GetPlayer(); + Player* player = handler->GetSession()->GetPlayer(); if (!player) return false; @@ -705,8 +704,8 @@ class GuildHouseCommand : public CommandScript return false; } - GuildData *guildData = player->CustomData.GetDefault("phase"); - QueryResult result = CharacterDatabase.Query("SELECT `id`, `guild`, `phase`, `map`,`positionX`, `positionY`, `positionZ`, `orientation` FROM guild_house WHERE `guild` = {}", player->GetGuildId()); + GuildData* guildData = player->CustomData.GetDefault("phase"); + QueryResult result = CharacterDatabase.Query("SELECT `id`, `guild`, `phase`, `map`,`positionX`, `positionY`, `positionZ`, `orientation` FROM `guild_house` WHERE `guild`={}", player->GetGuildId()); if (!result) { @@ -717,8 +716,7 @@ class GuildHouseCommand : public CommandScript do { - - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); // uint32 id = fields[0].Get(); // fix for travis // uint32 guild = fields[1].Get(); // fix for travis guildData->phase = fields[2].Get(); @@ -741,7 +739,7 @@ class GuildHouseGlobal : public GlobalScript public: GuildHouseGlobal() : GlobalScript("GuildHouseGlobal") {} - void OnBeforeWorldObjectSetPhaseMask(WorldObject const *worldObject, uint32 & /*oldPhaseMask*/, uint32 & /*newPhaseMask*/, bool &useCombinedPhases, bool & /*update*/) override + void OnBeforeWorldObjectSetPhaseMask(WorldObject const* worldObject, uint32 & /*oldPhaseMask*/, uint32 & /*newPhaseMask*/, bool &useCombinedPhases, bool & /*update*/) override { if (worldObject->GetZoneId() == 876) useCombinedPhases = false; diff --git a/src/mod_guildhouse_butler.cpp b/src/mod_guildhouse_butler.cpp index daa8d44..a205753 100644 --- a/src/mod_guildhouse_butler.cpp +++ b/src/mod_guildhouse_butler.cpp @@ -24,27 +24,26 @@ class GuildHouseSpawner : public CreatureScript struct GuildHouseSpawnerAI : public ScriptedAI { - GuildHouseSpawnerAI(Creature *creature) : ScriptedAI(creature) {} + GuildHouseSpawnerAI(Creature* creature) : ScriptedAI(creature) {} - void UpdateAI(uint32 /* diff */) override + void UpdateAI(uint32 /*diff*/) override { me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP); } }; - CreatureAI * - GetAI(Creature *creature) const override + CreatureAI* GetAI(Creature *creature) const override { return new GuildHouseSpawnerAI(creature); } - bool OnGossipHello(Player *player, Creature *creature) override + bool OnGossipHello(Player* player, Creature* creature) override { - if (player->GetGuild()) { - Guild *guild = sGuildMgr->GetGuildById(player->GetGuildId()); - Guild::Member const *memberMe = guild->GetMember(player->GetGUID()); + Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()); + Guild::Member const* memberMe = guild->GetMember(player->GetGUID()); + if (!memberMe->IsRankNotLower(GuildHouseBuyRank)) { ChatHandler(player->GetSession()).PSendSysMessage("You are not authorized to make Guild House purchases."); @@ -74,7 +73,7 @@ class GuildHouseSpawner : public CreatureScript return true; } - bool OnGossipSelect(Player *player, Creature *m_creature, uint32, uint32 action) override + bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override { switch (action) @@ -92,7 +91,7 @@ class GuildHouseSpawner : public CreatureScript AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Warlock", GOSSIP_SENDER_MAIN, 26331, "Spawn Warlock Trainer?", GuildHouseTrainer, false); AddGossipItemFor(player, GOSSIP_ICON_TRAINER, "Warrior", GOSSIP_SENDER_MAIN, 26332, "Spawn Warrior Trainer?", GuildHouseTrainer, false); AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Go Back!", GOSSIP_SENDER_MAIN, 9); - SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, m_creature->GetGUID()); + SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); break; case 3: // Vendors ClearGossipMenuFor(player); @@ -103,7 +102,7 @@ class GuildHouseSpawner : public CreatureScript AddGossipItemFor(player, GOSSIP_ICON_TALK, "Ammo & Repair Vendor", GOSSIP_SENDER_MAIN, 29493, "Spawn Ammo & Repair Vendor?", GuildHouseVendor, false); AddGossipItemFor(player, GOSSIP_ICON_TALK, "Poisons Vendor", GOSSIP_SENDER_MAIN, 2622, "Spawn Poisons Vendor?", GuildHouseVendor, false); AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Go Back!", GOSSIP_SENDER_MAIN, 9); - SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, m_creature->GetGUID()); + SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); break; case 4: // Objects & Portals ClearGossipMenuFor(player); @@ -132,7 +131,7 @@ class GuildHouseSpawner : public CreatureScript AddGossipItemFor(player, GOSSIP_ICON_TAXI, "Portal: Dalaran", GOSSIP_SENDER_MAIN, 500009, "Add Dalaran Portal?", GuildHousePortal, false); AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Go Back!", GOSSIP_SENDER_MAIN, 9); - SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, m_creature->GetGUID()); + SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); break; case 6: // Auctioneer { @@ -172,7 +171,7 @@ class GuildHouseSpawner : public CreatureScript } AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Go Back!", GOSSIP_SENDER_MAIN, 9); - SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, m_creature->GetGUID()); + SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); break; case 8: // Secondary Profession Trainers ClearGossipMenuFor(player); @@ -180,10 +179,10 @@ class GuildHouseSpawner : public CreatureScript AddGossipItemFor(player, GOSSIP_ICON_MONEY_BAG, "Fishing Trainer", GOSSIP_SENDER_MAIN, 2834, "Spawn Fishing Trainer?", GuildHouseProf, false); AddGossipItemFor(player, GOSSIP_ICON_MONEY_BAG, "Cooking Trainer", GOSSIP_SENDER_MAIN, 19185, "Spawn Cooking Trainer?", GuildHouseProf, false); AddGossipItemFor(player, GOSSIP_ICON_CHAT, "Go Back!", GOSSIP_SENDER_MAIN, 9); - SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, m_creature->GetGUID()); + SendGossipMenuFor(player, DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); break; case 9: // Go back! - OnGossipHello(player, m_creature); + OnGossipHello(player, creature); break; case 10: // PVP toggle break; @@ -271,12 +270,12 @@ class GuildHouseSpawner : public CreatureScript return true; } - uint32 GetGuildPhase(Player *player) + uint32 GetGuildPhase(Player* player) { return player->GetGuildId() + 10; } - void SpawnNPC(uint32 entry, Player *player) + void SpawnNPC(uint32 entry, Player* player) { if (player->FindNearestCreature(entry, VISIBILITY_RANGE, true)) { @@ -290,14 +289,14 @@ class GuildHouseSpawner : public CreatureScript float posZ; float ori; - QueryResult result = WorldDatabase.Query("SELECT `posX`, `posY`, `posZ`, `orientation` FROM `guild_house_spawns` WHERE `entry` = {}", entry); + QueryResult result = WorldDatabase.Query("SELECT `posX`, `posY`, `posZ`, `orientation` FROM `guild_house_spawns` WHERE `entry`={}", entry); if (!result) return; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); posX = fields[0].Get(); posY = fields[1].Get(); posZ = fields[2].Get(); @@ -305,7 +304,7 @@ class GuildHouseSpawner : public CreatureScript } while (result->NextRow()); - Creature *creature = new Creature(); + Creature* creature = new Creature(); if (!creature->Create(player->GetMap()->GenerateLowGuid(), player->GetMap(), GetGuildPhase(player), entry, 0, posX, posY, posZ, ori)) { @@ -329,7 +328,7 @@ class GuildHouseSpawner : public CreatureScript CloseGossipMenuFor(player); } - void SpawnObject(uint32 entry, Player *player) + void SpawnObject(uint32 entry, Player* player) { if (player->FindNearestGameObject(entry, VISIBLE_RANGE)) { @@ -343,14 +342,14 @@ class GuildHouseSpawner : public CreatureScript float posZ; float ori; - QueryResult result = WorldDatabase.Query("SELECT `posX`, `posY`, `posZ`, `orientation` FROM `guild_house_spawns` WHERE `entry` = {}", entry); + QueryResult result = WorldDatabase.Query("SELECT `posX`, `posY`, `posZ`, `orientation` FROM `guild_house_spawns` WHERE `entry`={}", entry); if (!result) return; do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); posX = fields[0].Get(); posY = fields[1].Get(); posZ = fields[2].Get(); @@ -362,7 +361,7 @@ class GuildHouseSpawner : public CreatureScript if (!objectId) return; - const GameObjectTemplate *objectInfo = sObjectMgr->GetGameObjectTemplate(objectId); + const GameObjectTemplate* objectInfo = sObjectMgr->GetGameObjectTemplate(objectId); if (!objectInfo) return; @@ -370,7 +369,7 @@ class GuildHouseSpawner : public CreatureScript if (objectInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(objectInfo->displayId)) return; - GameObject *object = sObjectMgr->IsGameObjectStaticTransport(objectInfo->entry) ? new StaticTransport() : new GameObject(); + GameObject* object = sObjectMgr->IsGameObjectStaticTransport(objectInfo->entry) ? new StaticTransport() : new GameObject(); ObjectGuid::LowType guidLow = player->GetMap()->GenerateLowGuid(); if (!object->Create(guidLow, objectInfo->entry, player->GetMap(), GetGuildPhase(player), posX, posY, posZ, ori, G3D::Quat(), 0, GO_STATE_READY)) From fef167b017545e7de1e7ab2e71ba18d720264662 Mon Sep 17 00:00:00 2001 From: Pagani Walter Date: Sun, 7 Apr 2024 18:23:05 -0300 Subject: [PATCH 2/2] add pull request --- pull_request_template.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pull_request_template.md diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..21c9245 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,25 @@ + + +## Changes Proposed: +- +- + +## Issues Addressed: + +- Closes + +## SOURCE: + + +## Tests Performed: + +- +- + + +## How to Test the Changes: + + +1. +2. +3.