diff --git a/src/game/Server/DBCStores.cpp b/src/game/Server/DBCStores.cpp index 589a7304f..e4f5b9dde 100644 --- a/src/game/Server/DBCStores.cpp +++ b/src/game/Server/DBCStores.cpp @@ -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) diff --git a/src/game/Server/DBCStores.h b/src/game/Server/DBCStores.h index 2dc34e493..4f547f0e2 100644 --- a/src/game/Server/DBCStores.h +++ b/src/game/Server/DBCStores.h @@ -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); diff --git a/src/game/Server/DBCStructure.h b/src/game/Server/DBCStructure.h index e0e41629d..2237d3a2b 100644 --- a/src/game/Server/DBCStructure.h +++ b/src/game/Server/DBCStructure.h @@ -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 };