Files
DarkflameServer/dChatServer/ChatPacketHandler.h
Aaron Kimbrell e2d6c4124b feat(chat): answer the client's minimum chat mode requests
Before private (7), team (8) and local team (10) chat the client asks
the chat server for the minimum chat mode of the channel
(LWOChatComponent::RequestMinimumChatMode; it answers every other
channel itself) and hands the answer to its chat UI. DLU never
answered. Live answered chat mode 0 with the requested channel (74 of
74 team answers in the captures: 53 05 00 39 00 00 00 00 00 08).

The chat server now answers with the lowest chat mode among who reads
the channel (the sender and their online teammates, or the sender and
the recipient), using the GM level as the chat mode as DLU does
everywhere else; the private answer also echoes the recipient's name
and GM level (0 when offline). Inferred: the minimum for GMs (no live
GM sample) and the answer when the recipient is offline.

Check: type in team chat and whisper another player: the messages send
as before and the chat box shows no error; do the same with a GM in
the team.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 03:50:02 -05:00

43 lines
2.7 KiB
C++

#pragma once
#include "dCommonVars.h"
#include "dNetCommon.h"
#include "BitStream.h"
#include "ChatPackets.h"
#include "ClientPackets.h"
#include "WorldRoutePacket.h"
#include "eChatChannel.h"
#include "eChatMessageResponseCode.h"
struct PlayerData;
struct LUBitStream;
enum class eAddFriendResponseType : uint8_t;
namespace ChatPacketHandler {
// Sends msg to the world server `world`, which passes it on to the client of `target`
void SendRouted(const LWOOBJID target, const SystemAddress& world, const LUBitStream& msg, const bool broadcast = false);
// Reads a player's friends from the database into their data, noting which are online; nothing is sent
void LoadFriends(PlayerData& player);
void HandleFriendlistRequest(const ChatPackets::GetFriendsList& request, const SystemAddress& sysAddr);
void HandleFriendRequest(const ChatPackets::AddFriendRequest& request, const SystemAddress& sysAddr);
void HandleFriendResponse(const ChatPackets::AddFriendResponse& response, const SystemAddress& sysAddr);
void HandleRemoveFriend(const ChatPackets::RemoveFriend& request, const SystemAddress& sysAddr);
void HandleGMLevelUpdate(const ChatPackets::GMLevelUpdate& update, const SystemAddress& sysAddr);
void HandleRequestMinimumChatMode(const ChatPackets::RequestMinimumChatMode& request, const SystemAddress& sysAddr);
void HandleRequestMinimumChatModePrivate(const ChatPackets::RequestMinimumChatModePrivate& request, const SystemAddress& sysAddr);
void HandleWho(const ChatPackets::FindPlayerRequest& request, const SystemAddress& sysAddr);
void HandleShowAll(const ChatPackets::ShowAllRequest& request, const SystemAddress& sysAddr);
void HandleChatMessage(const ChatPackets::GeneralChatMessage& chatMessage, const SystemAddress& sysAddr);
void HandlePrivateChatMessage(const ChatPackets::PrivateChatMessage& chatMessage, const SystemAddress& sysAddr);
void OnAchievementNotify(ChatPackets::AchievementNotify& notify, const SystemAddress& sysAddr);
//FriendData is the player we're SENDING this stuff to. Player is the friend that changed state.
void SendFriendUpdate(const PlayerData& friendData, const PlayerData& playerData, uint8_t notifyType, uint8_t isBestFriend);
void SendPrivateChatMessage(const PlayerData& sender, const PlayerData& receiver, const PlayerData& routeTo, const LUWString& message, const eChatChannel channel, const eChatMessageResponseCode responseCode);
void SendFriendRequest(const PlayerData& receiver, const PlayerData& sender);
void SendFriendResponse(const PlayerData& receiver, const PlayerData& sender, eAddFriendResponseType responseCode, uint8_t isBestFriendsAlready = 0U, uint8_t isBestFriendRequest = 0U);
void SendRemoveFriend(const PlayerData& receiver, std::string& personToRemove, bool isSuccessful);
};