Skip to content

Commit

Permalink
Improve tele command (#2797)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stoabrogga authored Oct 19, 2024
1 parent 4e811af commit 84d3b47
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/game/ObjectMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10078,13 +10078,23 @@ GameTele const* ObjectMgr::GetGameTele(std::string const& name) const
// converting string that we try to find to lower case
wstrToLower(wname);

// Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
// if no GameTele location is found use the shortest one which contains wnameLow as substring
GameTele const* alt = nullptr;
std::wstring::size_type size = -1;
for (const auto& itr : m_GameTeleMap)
{
if (itr.second.wnameLow == wname)
return &itr.second;
else if (alt == nullptr && itr.second.wnameLow.find(wname) != std::wstring::npos)
alt = &itr.second;
else if (itr.second.wnameLow.find(wname) != std::wstring::npos)
{
std::wstring::size_type newSize = itr.second.wnameLow.size();
if (size == -1 || newSize < size)
{
alt = &itr.second;
size = newSize;
}
}
}

return alt;
}
Expand Down

0 comments on commit 84d3b47

Please sign in to comment.