mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 21:47:24 +00:00
76 lines
2.3 KiB
C++
76 lines
2.3 KiB
C++
/*
|
|
* Darkflame Universe
|
|
* Copyright 2018
|
|
*/
|
|
|
|
#include "ChatPackets.h"
|
|
#include "RakNetTypes.h"
|
|
#include "BitStream.h"
|
|
#include "Game.h"
|
|
#include "BitstreamUtils.h"
|
|
#include "dServer.h"
|
|
#include "eConnectionType.h"
|
|
#include "eChatMessageType.h"
|
|
|
|
void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel, const std::string& senderName, LWOOBJID playerObjectID, bool senderMythran, const std::u16string& message) {
|
|
CBITSTREAM;
|
|
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE);
|
|
|
|
bitStream.Write(static_cast<uint64_t>(0));
|
|
bitStream.Write(chatChannel);
|
|
|
|
bitStream.Write(static_cast<uint32_t>(message.size()));
|
|
bitStream.Write(LUWString(senderName));
|
|
|
|
bitStream.Write(playerObjectID);
|
|
bitStream.Write(static_cast<uint16_t>(0));
|
|
bitStream.Write(static_cast<char>(0));
|
|
|
|
for (uint32_t i = 0; i < message.size(); ++i) {
|
|
bitStream.Write(static_cast<uint16_t>(message[i]));
|
|
}
|
|
bitStream.Write(static_cast<uint16_t>(0));
|
|
|
|
SEND_PACKET_BROADCAST;
|
|
}
|
|
|
|
void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16string& message, const bool broadcast) {
|
|
CBITSTREAM;
|
|
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE);
|
|
|
|
bitStream.Write(static_cast<uint64_t>(0));
|
|
bitStream.Write(static_cast<char>(4));
|
|
|
|
bitStream.Write(static_cast<uint32_t>(message.size()));
|
|
bitStream.Write(LUWString(""));
|
|
|
|
bitStream.Write(static_cast<uint64_t>(0));
|
|
bitStream.Write(static_cast<uint16_t>(0));
|
|
bitStream.Write(static_cast<char>(0));
|
|
|
|
for (uint32_t i = 0; i < message.size(); ++i) {
|
|
bitStream.Write(static_cast<uint16_t>(message[i]));
|
|
}
|
|
|
|
bitStream.Write(static_cast<uint16_t>(0));
|
|
|
|
//This is so Wincent's announcement works:
|
|
if (sysAddr != UNASSIGNED_SYSTEM_ADDRESS) {
|
|
SEND_PACKET;
|
|
return;
|
|
}
|
|
|
|
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."
|
|
|
|
CBITSTREAM;
|
|
BitstreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::SEND_CANNED_TEXT);
|
|
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;
|
|
}
|