diff options
-rw-r--r-- | data/sql/updates/pending_db_characters/rev_1753373508738396400.sql | 3 | ||||
-rw-r--r-- | src/common/Common.h | 13 | ||||
-rw-r--r-- | src/server/game/Mails/ServerMailMgr.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Mails/ServerMailMgr.h | 4 |
4 files changed, 33 insertions, 4 deletions
diff --git a/data/sql/updates/pending_db_characters/rev_1753373508738396400.sql b/data/sql/updates/pending_db_characters/rev_1753373508738396400.sql new file mode 100644 index 0000000000..1c4dfcb49e --- /dev/null +++ b/data/sql/updates/pending_db_characters/rev_1753373508738396400.sql @@ -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`; diff --git a/src/common/Common.h b/src/common/Common.h index 8a28414c01..c8cd5e7892 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -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, diff --git a/src/server/game/Mails/ServerMailMgr.cpp b/src/server/game/Mails/ServerMailMgr.cpp index d11595066a..8ed35ffc17 100644 --- a/src/server/game/Mails/ServerMailMgr.cpp +++ b/src/server/game/Mails/ServerMailMgr.cpp @@ -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; diff --git a/src/server/game/Mails/ServerMailMgr.h b/src/server/game/Mails/ServerMailMgr.h index 9cf70a8050..12eee5113d 100644 --- a/src/server/game/Mails/ServerMailMgr.h +++ b/src/server/game/Mails/ServerMailMgr.h @@ -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 } }; /** |