fix(Script/Commands): tele add should only check exact match (#20785)

* fix(Script/Commands): tele add should only check exact match

* closes https://github.com/azerothcore/azerothcore-wotlk/issues/20268

* better describe the variable
This commit is contained in:
Kitzunu
2024-12-01 00:06:26 +01:00
committed by GitHub
parent fc9e730974
commit 5e4f6ac576
3 changed files with 4 additions and 4 deletions

View File

@@ -8945,7 +8945,7 @@ void ObjectMgr::LoadGameTele()
LOG_INFO("server.loading", " ");
}
GameTele const* ObjectMgr::GetGameTele(std::string_view name) const
GameTele const* ObjectMgr::GetGameTele(std::string_view name, bool exactSearch) const
{
// explicit name case
std::wstring wname;
@@ -8961,7 +8961,7 @@ GameTele const* ObjectMgr::GetGameTele(std::string_view name) const
{
if (itr->second.wnameLow == wname)
return &itr->second;
else if (!alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
else if (!exactSearch && !alt && itr->second.wnameLow.find(wname) != std::wstring::npos)
alt = &itr->second;
}

View File

@@ -1347,7 +1347,7 @@ public:
if (itr == _gameTeleStore.end()) return nullptr;
return &itr->second;
}
[[nodiscard]] GameTele const* GetGameTele(std::string_view name) const;
[[nodiscard]] GameTele const* GetGameTele(std::string_view name, bool exactSearch = false) const;
[[nodiscard]] GameTeleContainer const& GetGameTeleMap() const { return _gameTeleStore; }
bool AddGameTele(GameTele& data);
bool DeleteGameTele(std::string_view name);

View File

@@ -72,7 +72,7 @@ public:
if (!player)
return false;
if (sObjectMgr->GetGameTele(name))
if (sObjectMgr->GetGameTele(name, true))
{
handler->SendErrorMessage(LANG_COMMAND_TP_ALREADYEXIST);
return false;