51{
54
55
56 QueryResult result =
CharacterDatabase.Query(
"SELECT channelId, name, team, announce, ownership, password FROM channels ORDER BY channelId ASC");
57 if (!result)
58 {
59 LOG_WARN(
"server.loading",
">> Loaded 0 channels. DB table `channels` is empty.");
60 return;
61 }
62
63 std::vector<std::pair<std::string, uint32>> toDelete;
64 do
65 {
66 Field* fields = result->Fetch();
67
69 std::string channelName = fields[1].
Get<std::string>();
71 std::string password = fields[5].
Get<std::string>();
72
73 std::wstring channelWName;
75 {
76 LOG_ERROR(
"server.loading",
"Failed to load channel '{}' from database - invalid utf8 sequence? Deleted.", channelName);
77 toDelete.emplace_back(channelName, team);
78 continue;
79 }
80
82 if (!mgr)
83 {
84 LOG_ERROR(
"server.loading",
"Failed to load custom chat channel '{}' from database - invalid team {}. Deleted.", channelName, team);
85 toDelete.emplace_back(channelName, team);
86 continue;
87 }
88
89 Channel* newChannel =
new Channel(channelName, 0, channelDBId, team, fields[3].Get<uint8>(), fields[4].Get<uint8>());
91 mgr->
channels[channelWName] = newChannel;
92
94 {
95 do
96 {
97 Field* banFields = banResult->Fetch();
98 if (!banFields)
99 break;
100 newChannel->
AddBan(ObjectGuid::Create<HighGuid::Player>(banFields[0].Get<uint32>()), banFields[1].Get<uint32>());
101 } while (banResult->NextRow());
102 }
103
106 ++count;
107 } while (result->NextRow());
108
109 for (auto& pair : toDelete)
110 {
115 }
116
119}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
TeamId
Definition: SharedDefines.h:759
@ CHAR_DEL_CHANNEL
Definition: CharacterDatabase.h:185
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
void SetPassword(std::string const &npassword)
Definition: Channel.h:186
void AddBan(ObjectGuid guid, uint32 time)
Definition: Channel.h:196
static uint32 _channelIdMax
Definition: ChannelMgr.h:48
static ChannelMgr * forTeam(TeamId teamId)
Definition: ChannelMgr.cpp:33