refactor(Core/ServerMail): Refactor to Dedicated Manager Class with Multi-Item & Condition Support (#21590)

1. Core Cleanup
    - Move all ServerMail logic from `ObjectMgr` into a new dedicated `ServerMailMgr` class
    - Move faction logic for money from SendServerMail into the script
2. Separation of items into a new table
    - Create a new `mail_server_template_items` table
    - Allows to send multiple items in one mail
    - Separate items per faction Alliance/Horde
3. Separation of conditions into a new table
    - Create a new `mail_server_template_conditions` table
    - Allows to use multiple conditions for one mail
    - Available condition types
        - Minimum playtime (playerLevel >= condition)
        - Minimum playtime (playerPlayTime >= condition)
        - Rewarded quest
        - Earned achievement
        - Earned reputation (playerReputation >= conditionState)
        - Faction
        - Race
        - Class
4. Updated ServerMail loading
    - Move item and condition loading to their own functions
        - LoadMailServerTemplateItems()
        - LoadMailServerTemplateConditions()
5. Reworked eligibility check
    - Player needs to pass all conditions to be eligible for the mail
    - All players are automatically eligible if no conditions exist for a server mail template.
6. Updated foreign keys
    - For table `mail_server_character`, `mail_server_template_conditions`, `mail_server_template_items` foreign key with on delete cascade is added for automatic removal of entries if mail_server_template.id is deleted.
7. Database changes
    - See the PR
This commit is contained in:
Kitzunu
2025-03-09 09:18:01 +01:00
committed by GitHub
parent 061044b710
commit 231096132c
9 changed files with 666 additions and 155 deletions
-17
View File
@@ -210,21 +210,4 @@ struct Mail
[[nodiscard]] bool IsReturnedMail() const { return checked & MAIL_CHECK_MASK_RETURNED; }
};
struct ServerMail
{
ServerMail() = default;
uint32 id{ 0 };
uint8 reqLevel{ 0 };
uint32 reqPlayTime{ 0 };
uint32 moneyA{ 0 };
uint32 moneyH{ 0 };
uint32 itemA{ 0 };
uint32 itemCountA{ 0 };
uint32 itemH{ 0 };
uint32 itemCountH{ 0 };
std::string subject;
std::string body;
uint8 active{ 0 };
};
#endif