Skip to content

Commit

Permalink
add class
Browse files Browse the repository at this point in the history
  • Loading branch information
Kitzunu committed Mar 2, 2025
1 parent a8b0b56 commit 2b36dce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DROP TABLE IF EXISTS `mail_server_template_conditions`;
CREATE TABLE `mail_server_template_conditions` (
`id` INT UNSIGNED AUTO_INCREMENT,
`templateID` INT UNSIGNED NOT NULL,
`conditionType` ENUM('Level', 'PlayTime', 'Quest', 'Achievement', 'Reputation', 'Faction', 'Race') NOT NULL,
`conditionType` ENUM('Level', 'PlayTime', 'Quest', 'Achievement', 'Reputation', 'Faction', 'Race', 'Class') NOT NULL,
`conditionValue` INT UNSIGNED NOT NULL,
`conditionState` INT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
Expand Down
10 changes: 9 additions & 1 deletion src/server/game/Mails/ServerMailMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ void ServerMailMgr::LoadMailServerTemplatesConditions()
(conditionType != ServerMailConditionType::Quest ||
conditionType != ServerMailConditionType::Reputation ||
conditionType != ServerMailConditionType::Faction ||
conditionType != ServerMailConditionType::Race))
conditionType != ServerMailConditionType::Race ||
conditionType != ServerMailConditionType::Class))
LOG_WARN("sql.sql", "Table `mail_server_template_conditions` has conditionState value ({}) for conditionType ({}) which does not use conditionState.", conditionState, conditionTypeStr);

switch (conditionType)
Expand Down Expand Up @@ -265,6 +266,13 @@ void ServerMailMgr::LoadMailServerTemplatesConditions()
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);
continue;
}
break;
default:
break;
}
Expand Down
3 changes: 3 additions & 0 deletions src/server/game/Mails/ServerMailMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum class ServerMailConditionType : uint8
Reputation = 5, ///< Requires the player to have earned reputation with a specific faction.
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.
};

/**
Expand Down Expand Up @@ -95,6 +96,8 @@ struct ServerMailCondition
return player->GetTeamId() == value;
case ServerMailConditionType::Race:
return (player->getRaceMask() & value) != 0;
case ServerMailConditionType::Class:
return (player->getClassMask() & value) != 0;
default:
LOG_ERROR("server.mail", "Unknown server mail condition type '{}'", static_cast<uint32>(type));
return false;
Expand Down

0 comments on commit 2b36dce

Please sign in to comment.