mirror of
https://github.com/mangosfour/server.git
synced 2025-12-11 16:37:03 +00:00
(Author: Olion17) Server-owned world channel
Case-insensitive channel name comparison for "world". commit 43860fb on cabfever's repo
This commit is contained in:
parent
2b4c4fc530
commit
598dacfa1c
3 changed files with 41 additions and 1 deletions
|
|
@ -1035,6 +1035,45 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static ChatChannelsEntry worldCh = { 26, 4, "world" };
|
||||
|
||||
ChatChannelsEntry const* GetChannelEntryFor(const std::string& name)
|
||||
{
|
||||
// not sorted, numbering index from 0
|
||||
for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i)
|
||||
{
|
||||
ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(i);
|
||||
if (ch)
|
||||
{
|
||||
// need to remove %s from entryName if it exists before we match
|
||||
std::string entryName(ch->pattern[0]);
|
||||
std::size_t removeString = entryName.find("%s");
|
||||
|
||||
if (removeString != std::string::npos)
|
||||
entryName.replace(removeString, 2, "");
|
||||
|
||||
if (name.find(entryName) != std::string::npos)
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
|
||||
bool compare = true; // hack for world channel, TODO smth!
|
||||
std::string world = "world";
|
||||
for (uint8 i = 0; i < name.length(); ++i)
|
||||
{
|
||||
if (tolower(name[i]) != world[i])
|
||||
{
|
||||
compare = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (compare)
|
||||
return &worldCh;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
|
||||
{
|
||||
if (requiredTotemCategoryId == 0)
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ enum ContentLevels
|
|||
ContentLevels GetContentLevelsForMapAndZone(uint32 mapId, uint32 zoneId);
|
||||
|
||||
ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id);
|
||||
ChatChannelsEntry const* GetChannelEntryFor(const std::string& name);
|
||||
|
||||
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId);
|
||||
|
||||
|
|
|
|||
|
|
@ -673,7 +673,7 @@ struct ChatChannelsEntry
|
|||
uint32 ChannelID; // 0 m_ID
|
||||
uint32 flags; // 1 m_flags
|
||||
//uint32 // 2 m_factionGroup
|
||||
DBCString pattern; // 3 m_name_lang
|
||||
char* pattern[16]; // 3 m_name_lang
|
||||
//char* name; // 4 m_shortcut_lang
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue