Skip to content

Commit

Permalink
* Fixed some features not being disabled when deactivated in `config.…
Browse files Browse the repository at this point in the history
…lua`: `!chain`, `!emote`, and `!spellwords`.
  • Loading branch information
jprzimba committed Jan 28, 2025
1 parent bffc457 commit cb4d6a6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions data/scripts/talkactions/player/chain_system.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ function feature.onSay(player, words, param)
end

if param == "on" then
player:setFeature(Features.ChainSystem, 1)
player:setFeature(Features.ChainSystem, true)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Chain System is now enabled.")
elseif param == "off" then
player:setFeature(Features.ChainSystem, 0)
player:setFeature(Features.ChainSystem, false)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Chain System is now disabled.")
end
return true
Expand Down
4 changes: 2 additions & 2 deletions data/scripts/talkactions/player/emote_spell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ function emoteSpell.onSay(player, words, param)
end

if param == "on" then
player:setFeature(Features.EmoteSpells, 1)
player:setFeature(Features.EmoteSpells, true)
player:sendTextMessage(MESSAGE_LOOK, "You have activated emote spells.")
elseif param == "off" then
player:setFeature(Features.EmoteSpells, 0)
player:setFeature(Features.EmoteSpells, false)
player:sendTextMessage(MESSAGE_LOOK, "You have deactivated emote spells.")
end
return true
Expand Down
4 changes: 2 additions & 2 deletions data/scripts/talkactions/player/spell_name_instead_words.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ function featrue.onSay(player, words, param)
end

if param == "on" then
player:setFeature(Features.SpellNameInsteadOfWords, 1)
player:setFeature(Features.SpellNameInsteadOfWords, true)
player:sendTextMessage(MESSAGE_LOOK, "You have activated spell name instead of words.")
elseif param == "off" then
player:setFeature(Features.SpellNameInsteadOfWords, 0)
player:setFeature(Features.SpellNameInsteadOfWords, false)
player:sendTextMessage(MESSAGE_LOOK, "You have deactivated spell name instead of words.")
end
return true
Expand Down
1 change: 1 addition & 0 deletions markdowns/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

- Fixed Stealth Ring being destroyed in certain cases, based on [Stealth Ring](https://tibia.fandom.com/wiki/Stealth_Ring). ([Tryller](https://github.com/jprzimba))
- Fixed an issue where store items could not be moved to the store inbox after being unwrapped. ([TheGlitchLab](https://github.com/TheGlitchLab))
- Fixed some features not being disabled when deactivated in `config.lua`: `!chain`, `!emote`, and `!spellwords`. ([Tryller](https://github.com/jprzimba))


## Version 4.1.2
Expand Down
22 changes: 13 additions & 9 deletions src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5186,19 +5186,21 @@ bool Player::checkAutoLoot(bool isBoss) const {

bool Player::checkChainSystem() const {
if (!g_configManager().getBoolean(TOGGLE_CHAIN_SYSTEM)) {
kv()->scoped("features")->set("chainSystem", false);
return false;
}

if (g_configManager().getBoolean(VIP_SYSTEM_ENABLED) && g_configManager().getBoolean(CHAIN_SYSTEM_VIP_ONLY) && !isVip()) {
kv()->scoped("features")->set("chainSystem", false);
return false;
}

auto featureKV = kv()->scoped("features")->get("chainSystem");
if (featureKV.has_value()) {
auto value = featureKV->getNumber();
if (value == 1) {
auto value = featureKV->get<bool>();
if (value) {
return true;
} else if (value == 0) {
} else {
return false;
}
}
Expand All @@ -5208,15 +5210,16 @@ bool Player::checkChainSystem() const {

bool Player::checkEmoteSpells() const {
if (!g_configManager().getBoolean(EMOTE_SPELLS)) {
kv()->scoped("features")->set("emoteSpells", false);
return false;
}

auto featureKV = kv()->scoped("features")->get("emoteSpells");
if (featureKV.has_value()) {
auto value = featureKV->getNumber();
if (value == 1) {
auto value = featureKV->get<bool>();
if (value) {
return true;
} else if (value == 0) {
} else {
return false;
}
}
Expand All @@ -5226,15 +5229,16 @@ bool Player::checkEmoteSpells() const {

bool Player::checkSpellNameInsteadOfWords() const {
if (!g_configManager().getBoolean(SPELL_NAME_INSTEAD_WORDS)) {
kv()->scoped("features")->set("spellNameInsteadOfWords", false);
return false;
}

auto featureKV = kv()->scoped("features")->get("spellNameInsteadOfWords");
if (featureKV.has_value()) {
auto value = featureKV->getNumber();
if (value == 1) {
auto value = featureKV->get<bool>();
if (value) {
return true;
} else if (value == 0) {
} else {
return false;
}
}
Expand Down

0 comments on commit cb4d6a6

Please sign in to comment.