Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix level and condition check for yell #3690

Merged
6 commits merged into from
Oct 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/XML/groups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<flag ignoreweaponcheck="1" />
<flag cannotbemuted="1" />
<flag isalwayspremium="1" />
<flag ignoreyellcheck="1" />
</flags>
</group>
<group id="5" name="community manager" access="1" maxdepotitems="0" maxvipentries="200">
Expand Down Expand Up @@ -95,6 +96,7 @@
<flag ignoreweaponcheck="1" />
<flag cannotbemuted="1" />
<flag isalwayspremium="1" />
<flag ignoreyellcheck="1" />
</flags>
</group>
<group id="6" name="god" access="1" maxdepotitems="0" maxvipentries="200">
Expand Down Expand Up @@ -136,6 +138,7 @@
<flag ignoreweaponcheck="1" />
<flag cannotbemuted="1" />
<flag isalwayspremium="1" />
<flag ignoreyellcheck="1" />
</flags>
</group>
</groups>
1 change: 1 addition & 0 deletions src/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ enum PlayerFlags : uint64_t {
PlayerFlag_IgnoreWeaponCheck = static_cast<uint64_t>(1) << 35,
PlayerFlag_CannotBeMuted = static_cast<uint64_t>(1) << 36,
PlayerFlag_IsAlwaysPremium = static_cast<uint64_t>(1) << 37,
PlayerFlag_IgnoreYellCheck = static_cast<uint64_t>(1) << 38,
};

enum ReloadTypes_t : uint8_t {
Expand Down
22 changes: 10 additions & 12 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3523,22 +3523,20 @@ bool Game::playerYell(Player* player, const std::string& text)
return false;
}

uint32_t minimumLevel = g_config.getNumber(ConfigManager::YELL_MINIMUM_LEVEL);
if (player->getLevel() < minimumLevel) {
if (g_config.getBoolean(ConfigManager::YELL_ALLOW_PREMIUM)) {
if (player->isPremium()) {
internalCreatureSay(player, TALKTYPE_YELL, asUpperCaseString(text), false);
return true;
if (!player->isAccessPlayer() && !player->hasFlag(PlayerFlag_IgnoreYellCheck)) {
uint32_t minimumLevel = g_config.getNumber(ConfigManager::YELL_MINIMUM_LEVEL);
if (player->getLevel() < minimumLevel) {
if (g_config.getBoolean(ConfigManager::YELL_ALLOW_PREMIUM)) {
if (!player->isPremium()) {
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not yell unless you have reached level {:d} or have a premium account.", minimumLevel));
return false;
}
} else {
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not yell unless you have reached level {:d} or have a premium account.", minimumLevel));
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not yell unless you have reached level {:d}.", minimumLevel));
return false;
}
} else {
player->sendTextMessage(MESSAGE_STATUS_SMALL, fmt::format("You may not yell unless you have reached level {:d}.", minimumLevel));
}
return false;
}

if (player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER) {
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_YELLTICKS, 30000, 0);
player->addCondition(condition);
}
Expand Down
3 changes: 2 additions & 1 deletion src/groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const std::unordered_map<std::string, PlayerFlags> ParsePlayerFlagMap = {
{"ignorespellcheck", PlayerFlag_IgnoreSpellCheck},
{"ignoreweaponcheck", PlayerFlag_IgnoreWeaponCheck},
{"cannotbemuted", PlayerFlag_CannotBeMuted},
{"isalwayspremium", PlayerFlag_IsAlwaysPremium}
{"isalwayspremium", PlayerFlag_IsAlwaysPremium},
{"ignoreyellcheck", PlayerFlag_IgnoreYellCheck}
};

bool Groups::load()
Expand Down
1 change: 1 addition & 0 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ void LuaScriptInterface::registerFunctions()
registerEnum(PlayerFlag_IgnoreWeaponCheck)
registerEnum(PlayerFlag_CannotBeMuted)
registerEnum(PlayerFlag_IsAlwaysPremium)
registerEnum(PlayerFlag_IgnoreYellCheck)

registerEnum(PLAYERSEX_FEMALE)
registerEnum(PLAYERSEX_MALE)
Expand Down