2021-12-05 17:54:36 +00:00
|
|
|
/*
|
|
|
|
* Darkflame Universe
|
|
|
|
* Copyright 2018
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ChatPackets.h"
|
|
|
|
#include "RakNetTypes.h"
|
|
|
|
#include "BitStream.h"
|
|
|
|
#include "Game.h"
|
2023-09-21 01:06:28 +00:00
|
|
|
#include "BitStreamUtils.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "dServer.h"
|
2023-05-03 21:38:32 +00:00
|
|
|
#include "eConnectionType.h"
|
2024-11-18 00:39:44 +00:00
|
|
|
#include "MessageType/Chat.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2024-04-18 02:47:28 +00:00
|
|
|
void ShowAllRequest::Serialize(RakNet::BitStream& bitStream) {
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, MessageType::Chat::SHOW_ALL);
|
2024-04-18 02:47:28 +00:00
|
|
|
bitStream.Write(this->requestor);
|
|
|
|
bitStream.Write(this->displayZoneData);
|
|
|
|
bitStream.Write(this->displayIndividualPlayers);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowAllRequest::Deserialize(RakNet::BitStream& inStream) {
|
|
|
|
inStream.Read(this->requestor);
|
|
|
|
inStream.Read(this->displayZoneData);
|
|
|
|
inStream.Read(this->displayIndividualPlayers);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FindPlayerRequest::Serialize(RakNet::BitStream& bitStream) {
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, MessageType::Chat::WHO);
|
2024-04-18 02:47:28 +00:00
|
|
|
bitStream.Write(this->requestor);
|
|
|
|
bitStream.Write(this->playerName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FindPlayerRequest::Deserialize(RakNet::BitStream& inStream) {
|
|
|
|
inStream.Read(this->requestor);
|
|
|
|
inStream.Read(this->playerName);
|
|
|
|
}
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel, const std::string& senderName, LWOOBJID playerObjectID, bool senderMythran, const std::u16string& message) {
|
|
|
|
CBITSTREAM;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, MessageType::Chat::GENERAL_CHAT_MESSAGE);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint64_t>(0);
|
2021-12-05 17:54:36 +00:00
|
|
|
bitStream.Write(chatChannel);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint32_t>(message.size());
|
2023-09-21 01:06:28 +00:00
|
|
|
bitStream.Write(LUWString(senderName));
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
bitStream.Write(playerObjectID);
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint16_t>(0);
|
|
|
|
bitStream.Write<char>(0);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
for (uint32_t i = 0; i < message.size(); ++i) {
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint16_t>(message[i]);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint16_t>(0);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
SEND_PACKET_BROADCAST;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16string& message, const bool broadcast) {
|
|
|
|
CBITSTREAM;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, MessageType::Chat::GENERAL_CHAT_MESSAGE);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint64_t>(0);
|
|
|
|
bitStream.Write<char>(4);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint32_t>(message.size());
|
2023-09-21 01:06:28 +00:00
|
|
|
bitStream.Write(LUWString("", 33));
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint64_t>(0);
|
|
|
|
bitStream.Write<uint16_t>(0);
|
|
|
|
bitStream.Write<char>(0);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
for (uint32_t i = 0; i < message.size(); ++i) {
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint16_t>(message[i]);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-12-28 04:18:20 +00:00
|
|
|
bitStream.Write<uint16_t>(0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
//This is so Wincent's announcement works:
|
|
|
|
if (sysAddr != UNASSIGNED_SYSTEM_ADDRESS) {
|
|
|
|
SEND_PACKET;
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
SEND_PACKET_BROADCAST;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatPackets::SendMessageFail(const SystemAddress& sysAddr) {
|
|
|
|
//0x00 - "Chat is currently disabled."
|
|
|
|
//0x01 - "Upgrade to a full LEGO Universe Membership to chat with other players."
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
CBITSTREAM;
|
2024-11-18 00:39:44 +00:00
|
|
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, MessageType::Client::SEND_CANNED_TEXT);
|
2021-12-05 17:54:36 +00:00
|
|
|
bitStream.Write<uint8_t>(0); //response type, options above ^
|
|
|
|
//docs say there's a wstring here-- no idea what it's for, or if it's even needed so leaving it as is for now.
|
|
|
|
SEND_PACKET;
|
|
|
|
}
|