From fd76f92ad6f1974451cb4c1df41786681d052e0b Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Fri, 22 Sep 2023 23:34:51 -0300 Subject: [PATCH] feat: config.lua option for enable/disable mount in protection zone (#1599) Option in config to enable mounts in protection zone. toggleMountInProtectionZone = true/false --- config.lua.dist | 1 + src/config/config_definitions.hpp | 1 + src/config/configmanager.cpp | 2 ++ src/creatures/players/player.cpp | 4 ++-- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config.lua.dist b/config.lua.dist index c6b37bb9a03..5d69ecd6fef 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -327,6 +327,7 @@ resetSessionsOnStartup = false -- Misc. -- NOTE: experienceDisplayRates: set to false to ignore exp rate or true to include exp rate allowChangeOutfit = true +toggleMountInProtectionZone = false freePremium = false kickIdlePlayerAfterMinutes = 15 maxMessageBuffer = 4 diff --git a/src/config/config_definitions.hpp b/src/config/config_definitions.hpp index 98f72a90be1..020e8579664 100644 --- a/src/config/config_definitions.hpp +++ b/src/config/config_definitions.hpp @@ -88,6 +88,7 @@ enum booleanConfig_t { VIP_STAY_ONLINE, REWARD_CHEST_COLLECT_ENABLED, + TOGGLE_MOUNT_IN_PZ, LAST_BOOLEAN_CONFIG }; diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index 6f04e53201b..7776bb519c2 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -389,6 +389,8 @@ bool ConfigManager::load() { boolean[REWARD_CHEST_COLLECT_ENABLED] = getGlobalBoolean(L, "rewardChestCollectEnabled", true); integer[REWARD_CHEST_MAX_COLLECT_ITEMS] = getGlobalNumber(L, "rewardChestMaxCollectItems", 200); + boolean[TOGGLE_MOUNT_IN_PZ] = getGlobalBoolean(L, "toggleMountInProtectionZone", false); + loaded = true; lua_close(L); return true; diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 354c368ef1f..fef64c1217e 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -1650,7 +1650,7 @@ void Player::onChangeZone(ZoneType_t zone) { onAttackedCreatureDisappear(false); } - if (!group->access && isMounted()) { + if (!g_configManager().getBoolean(TOGGLE_MOUNT_IN_PZ) && !group->access && isMounted()) { dismount(); g_game().internalCreatureChangeOutfit(getPlayer(), defaultOutfit); wasMounted = true; @@ -5599,7 +5599,7 @@ bool Player::toggleMount(bool mount) { } auto tile = getTile(); - if (!group->access && tile && tile->hasFlag(TILESTATE_PROTECTIONZONE)) { + if (!g_configManager().getBoolean(TOGGLE_MOUNT_IN_PZ) && !group->access && tile && tile->hasFlag(TILESTATE_PROTECTIONZONE)) { sendCancelMessage(RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE); return false; }