Add chat channels, chat settings, and fix missing chat text

Fix WotLK chat parser not stripping null terminators from messages,
fix channel message local echo missing channelName, expand default
channels to General/Trade/LocalDefense/LookingForGroup with
configurable auto-join, add Classic packet format for join/leave
channel, display channel index prefix in chat, and add Chat settings
tab with timestamps, font size, and auto-join toggles.
This commit is contained in:
Kelsi 2026-02-14 18:27:59 -08:00
parent bdedab7c1b
commit c2467cf2fc
8 changed files with 197 additions and 7 deletions

View file

@ -3912,6 +3912,10 @@ void GameHandler::sendChatMessage(ChatType type, const std::string& message, con
echo.type = type;
}
if (type == ChatType::CHANNEL) {
echo.channelName = target;
}
addLocalChatMessage(echo);
}
@ -4075,14 +4079,16 @@ void GameHandler::handleTextEmote(network::Packet& packet) {
void GameHandler::joinChannel(const std::string& channelName, const std::string& password) {
if (state != WorldState::IN_WORLD || !socket) return;
auto packet = JoinChannelPacket::build(channelName, password);
auto packet = packetParsers_ ? packetParsers_->buildJoinChannel(channelName, password)
: JoinChannelPacket::build(channelName, password);
socket->send(packet);
LOG_INFO("Requesting to join channel: ", channelName);
}
void GameHandler::leaveChannel(const std::string& channelName) {
if (state != WorldState::IN_WORLD || !socket) return;
auto packet = LeaveChannelPacket::build(channelName);
auto packet = packetParsers_ ? packetParsers_->buildLeaveChannel(channelName)
: LeaveChannelPacket::build(channelName);
socket->send(packet);
LOG_INFO("Requesting to leave channel: ", channelName);
}
@ -4092,6 +4098,13 @@ std::string GameHandler::getChannelByIndex(int index) const {
return joinedChannels_[index - 1];
}
int GameHandler::getChannelIndex(const std::string& channelName) const {
for (int i = 0; i < static_cast<int>(joinedChannels_.size()); ++i) {
if (joinedChannels_[i] == channelName) return i + 1; // 1-based
}
return 0;
}
void GameHandler::handleChannelNotify(network::Packet& packet) {
ChannelNotifyData data;
if (!ChannelNotifyParser::parse(packet, data)) {
@ -4135,8 +4148,10 @@ void GameHandler::handleChannelNotify(network::Packet& packet) {
}
void GameHandler::autoJoinDefaultChannels() {
joinChannel("General");
joinChannel("Trade");
if (chatAutoJoin.general) joinChannel("General");
if (chatAutoJoin.trade) joinChannel("Trade");
if (chatAutoJoin.localDefense) joinChannel("LocalDefense");
if (chatAutoJoin.lfg) joinChannel("LookingForGroup");
}
void GameHandler::setTarget(uint64_t guid) {