mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 02:50:29 +00:00
feat(Core/ServerMail): Add AccountFlags condition to server mail temp… (#22549)
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
--
|
||||
ALTER TABLE `mail_server_template_conditions`
|
||||
CHANGE COLUMN `conditionType` `conditionType` ENUM('Level','PlayTime','Quest','Achievement','Reputation','Faction','Race','Class','AccountFlags') NOT NULL COLLATE 'utf8mb4_unicode_ci' AFTER `templateID`;
|
||||
@@ -100,6 +100,19 @@ enum AccountFlag
|
||||
// ACCOUNT_FLAG_S2_RESTRICTED = 0xFFFFFFFF, // NYI UNK
|
||||
};
|
||||
|
||||
constexpr uint32 ACCOUNT_FLAGS_ALL =
|
||||
ACCOUNT_FLAG_GM | ACCOUNT_FLAG_NOKICK | ACCOUNT_FLAG_COLLECTOR |
|
||||
ACCOUNT_FLAG_TRIAL | ACCOUNT_FLAG_CANCELLED | ACCOUNT_FLAG_IGR |
|
||||
ACCOUNT_FLAG_WHOLESALER | ACCOUNT_FLAG_PRIVILEGED | ACCOUNT_FLAG_EU_FORBID_ELV |
|
||||
ACCOUNT_FLAG_EU_FORBID_BILLING | ACCOUNT_FLAG_RESTRICTED | ACCOUNT_FLAG_REFERRAL |
|
||||
ACCOUNT_FLAG_BLIZZARD | ACCOUNT_FLAG_RECURRING_BILLING | ACCOUNT_FLAG_NOELECTUP |
|
||||
ACCOUNT_FLAG_KR_CERTIFICATE | ACCOUNT_FLAG_EXPANSION_COLLECTOR | ACCOUNT_FLAG_DISABLE_VOICE |
|
||||
ACCOUNT_FLAG_DISABLE_VOICE_SPEAK | ACCOUNT_FLAG_REFERRAL_RESURRECT | ACCOUNT_FLAG_EU_FORBID_CC |
|
||||
ACCOUNT_FLAG_OPENBETA_DELL | ACCOUNT_FLAG_PROPASS | ACCOUNT_FLAG_PROPASS_LOCK |
|
||||
ACCOUNT_FLAG_PENDING_UPGRADE | ACCOUNT_FLAG_RETAIL_FROM_TRIAL | ACCOUNT_FLAG_EXPANSION2_COLLECTOR |
|
||||
ACCOUNT_FLAG_OVERMIND_LINKED | ACCOUNT_FLAG_DEMOS | ACCOUNT_FLAG_DEATH_KNIGHT_OK |
|
||||
ACCOUNT_FLAG_S2_REQUIRE_IGR | ACCOUNT_FLAG_S2_TRIAL;
|
||||
|
||||
enum LocaleConstant
|
||||
{
|
||||
LOCALE_enUS = 0,
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
*/
|
||||
|
||||
#include "ServerMailMgr.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "AchievementMgr.h"
|
||||
#include "Common.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Item.h"
|
||||
#include "Log.h"
|
||||
@@ -240,21 +242,28 @@ void ServerMailMgr::LoadMailServerTemplatesConditions()
|
||||
case ServerMailConditionType::Faction:
|
||||
if (conditionValue < TEAM_ALLIANCE || conditionValue > TEAM_HORDE)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `mail_server_template_conditions` has conditionType 'Faction' with invalid conditionValue ({}) for templateID {}, skipped.", conditionState, templateID);
|
||||
LOG_ERROR("sql.sql", "Table `mail_server_template_conditions` has conditionType 'Faction' with invalid conditionValue ({}) for templateID {}, skipped.", conditionValue, templateID);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case ServerMailConditionType::Race:
|
||||
if (conditionValue & ~RACEMASK_ALL_PLAYABLE)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `mail_server_template_conditions` has conditionType 'Race' with invalid conditionValue ({}) for templateID {}, skipped.", conditionState, templateID);
|
||||
LOG_ERROR("sql.sql", "Table `mail_server_template_conditions` has conditionType 'Race' with invalid conditionValue ({}) for templateID {}, skipped.", conditionValue, templateID);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case ServerMailConditionType::Class:
|
||||
if (conditionValue & ~CLASSMASK_ALL_PLAYABLE)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `mail_server_template_conditions` has conditionType 'Class' with invalid conditionValue ({}) for templateID {}, skipped.", conditionState, templateID);
|
||||
LOG_ERROR("sql.sql", "Table `mail_server_template_conditions` has conditionType 'Class' with invalid conditionValue ({}) for templateID {}, skipped.", conditionValue, templateID);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case ServerMailConditionType::AccountFlags:
|
||||
if ((conditionValue & ~ACCOUNT_FLAGS_ALL) != 0)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `mail_server_template_conditions` has conditionType 'AccountFlags' with invalid conditionValue ({}) for templateID {}, skipped.", conditionValue, templateID);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
@@ -344,6 +353,8 @@ bool ServerMailCondition::CheckCondition(Player* player) const
|
||||
return (player->getRaceMask() & value) != 0;
|
||||
case ServerMailConditionType::Class:
|
||||
return (player->getClassMask() & value) != 0;
|
||||
case ServerMailConditionType::AccountFlags:
|
||||
return player->GetSession()->HasAccountFlag(value);
|
||||
default:
|
||||
[[unlikely]] LOG_ERROR("server.mail", "Unknown server mail condition type '{}'", static_cast<uint32>(type));
|
||||
return false;
|
||||
|
||||
@@ -53,6 +53,7 @@ enum class ServerMailConditionType : uint8
|
||||
Faction = 6, ///< Requires the player to be a part of a specific faction. Horde/Alliance.
|
||||
Race = 7, ///< Requires the player to be a specific race.
|
||||
Class = 8, ///< Requires the player to be a specific class.
|
||||
AccountFlags = 9, ///< Requires the player to have a specific AccountFlag (bit)
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,8 @@ constexpr std::pair<std::string_view, ServerMailConditionType> ServerMailConditi
|
||||
{ "Reputation", ServerMailConditionType::Reputation },
|
||||
{ "Faction", ServerMailConditionType::Faction },
|
||||
{ "Race", ServerMailConditionType::Race },
|
||||
{ "Class", ServerMailConditionType::Class }
|
||||
{ "Class", ServerMailConditionType::Class },
|
||||
{ "AccountFlags", ServerMailConditionType::AccountFlags }
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user