![]() |
AzerothCore 3.3.5a
OpenSource WoW Emulator
|
#include "ServerMailMgr.h"
Public Member Functions | |
void | LoadMailServerTemplates () |
Loads all server mail templates from the database into memory. | |
void | LoadMailServerTemplatesItems () |
Loads all items associated with server mail templates. | |
void | LoadMailServerTemplatesConditions () |
Loads all conditions associated with server mail templates. | |
ServerMailConditionType | GetServerMailConditionType (std::string_view conditionTypeStr) const |
Convert DB value of conditionType to ServerMailConditionType. | |
bool | ConditionTypeUsesConditionState (ServerMailConditionType type) const |
Check if ConditionType should use ConditionState. | |
void | SendServerMail (Player *player, uint32 id, uint32 money, std::vector< ServerMailItems > const &items, std::vector< ServerMailCondition > const &conditions, std::string const &subject, std::string const &body) const |
Sends a server mail to a player if the template is active and the player is eligible. | |
ServerMailContainer const & | GetAllServerMailStore () const |
Retrieves the entire server mail store. | |
Static Public Member Functions | |
static ServerMailMgr * | instance () |
Private Member Functions | |
ServerMailMgr ()=default | |
~ServerMailMgr ()=default | |
Private Attributes | |
ServerMailContainer | _serverMailStore |
|
privatedefault |
|
privatedefault |
bool ServerMailMgr::ConditionTypeUsesConditionState | ( | ServerMailConditionType | type | ) | const |
Check if ConditionType should use ConditionState.
References Quest, and Reputation.
Referenced by LoadMailServerTemplatesConditions().
|
inline |
Retrieves the entire server mail store.
This function returns a constant reference to the internal _serverMailStore
container, which holds all server mail data.
ServerMailContainer
containing all stored server mail. References _serverMailStore.
ServerMailConditionType ServerMailMgr::GetServerMailConditionType | ( | std::string_view | conditionTypeStr | ) | const |
Convert DB value of conditionType to ServerMailConditionType.
Lookup the corresponding SeverMailConditionType enum for the provided string by DB. If the string is not found we return internal default value ServerMailConditionType::Invalid
conditionTypeStr | string value from DB of conditionType |
References Invalid, and ServerMailConditionTypePairs.
Referenced by LoadMailServerTemplatesConditions().
|
static |
void ServerMailMgr::LoadMailServerTemplates | ( | ) |
Loads all server mail templates from the database into memory.
Queries the mail_server_template
table and loads all rows into memory. This method is intended to be called during server startup.
References _serverMailStore, CharacterDatabase, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), ServerMail::id, LoadMailServerTemplatesConditions(), LoadMailServerTemplatesItems(), LOG_ERROR, LOG_INFO, and MAX_MONEY_AMOUNT.
void ServerMailMgr::LoadMailServerTemplatesConditions | ( | ) |
Loads all conditions associated with server mail templates.
Queries the mail_server_template_conditions
table and loads all conditions into memory, linking them to their corresponding templates by template ID. This method is intended to be called during server startup.
References _serverMailStore, Achievement, CharacterDatabase, Class, CLASSMASK_ALL_PLAYABLE, ConditionTypeUsesConditionState(), CONFIG_MAX_PLAYER_LEVEL, Faction, Field::Get(), GetServerMailConditionType(), Invalid, Level, LOG_ERROR, LOG_WARN, MAX_QUEST_STATUS, Quest, Race, RACEMASK_ALL_PLAYABLE, REP_EXALTED, Reputation, sAchievementStore, sFactionStore, sObjectMgr, ServerMailCondition::state, sWorld, TEAM_HORDE, ServerMailCondition::type, and ServerMailCondition::value.
Referenced by LoadMailServerTemplates().
void ServerMailMgr::LoadMailServerTemplatesItems | ( | ) |
Loads all items associated with server mail templates.
Queries the mail_server_template_items
table and loads all items into memory, linking them to their corresponding templates by template ID. This method is intended to be called during server startup.
References _serverMailStore, CharacterDatabase, Field::Get(), ServerMailItems::item, ServerMailItems::itemCount, LOG_ERROR, LOG_WARN, ItemTemplate::MaxCount, sObjectMgr, and ItemTemplate::Stackable.
Referenced by LoadMailServerTemplates().
void ServerMailMgr::SendServerMail | ( | Player * | player, |
uint32 | id, | ||
uint32 | money, | ||
std::vector< ServerMailItems > const & | items, | ||
std::vector< ServerMailCondition > const & | conditions, | ||
std::string const & | subject, | ||
std::string const & | body | ||
) | const |
Sends a server mail to a player if the template is active and the player is eligible.
This method handles the creation of the mail, adding money and items, and saving the mail to the database. It also records that the player received the mail to prevent duplicate delivery.
player | The recipient player. |
id | The template ID. |
money | Money reward. |
items | List of items to include in the mail. |
conditions | List of the conditions for the mail. |
subject | Mail subject. |
body | Mail body. |
active | Whether the mail template is active. |
References MailDraft::AddItem(), MailDraft::AddMoney(), CHAR_REP_MAIL_SERVER_CHARACTER, CharacterDatabase, Item::CreateItem(), ObjectGuid::GetCounter(), Object::GetGUID(), MAIL_NORMAL, MAIL_STATIONERY_GM, MailDraft::SendMailTo(), and PreparedStatementBase::SetData().
|
private |