mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
chore: cleanup LU(W)string writing (#1188)
* chore: cleanup LU(W)string writing and add methods for reading remove redunent "packet" from packet reading helpers move write header to bitstreamutils since it's not packet related add tests for reading/writing LU(W)Strings * remove un-needed function defintions in header * make reading and writing more efficient * p p * quotes * remove unneeded default --------- Co-authored-by: David Markowitz <39972741+EmosewaMC@users.noreply.github.com>
This commit is contained in:
@@ -8,19 +8,20 @@
|
||||
#include "BitStream.h"
|
||||
#include "Game.h"
|
||||
#include "PacketUtils.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;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE);
|
||||
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()));
|
||||
PacketUtils::WriteWString(bitStream, senderName, 33);
|
||||
bitStream.Write(LUWString(senderName));
|
||||
|
||||
bitStream.Write(playerObjectID);
|
||||
bitStream.Write(static_cast<uint16_t>(0));
|
||||
@@ -36,13 +37,13 @@ void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel
|
||||
|
||||
void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16string& message, const bool broadcast) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GENERAL_CHAT_MESSAGE);
|
||||
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()));
|
||||
PacketUtils::WriteWString(bitStream, "", 33);
|
||||
bitStream.Write(LUWString("", 33));
|
||||
|
||||
bitStream.Write(static_cast<uint64_t>(0));
|
||||
bitStream.Write(static_cast<uint16_t>(0));
|
||||
@@ -68,7 +69,7 @@ void ChatPackets::SendMessageFail(const SystemAddress& sysAddr) {
|
||||
//0x01 - "Upgrade to a full LEGO Universe Membership to chat with other players."
|
||||
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::SEND_CANNED_TEXT);
|
||||
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;
|
||||
|
Reference in New Issue
Block a user