mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +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:
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "GameMessageHandler.h"
|
||||
#include "MissionComponent.h"
|
||||
#include "PacketUtils.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "dServer.h"
|
||||
#include "../thirdparty/raknet/Source/RakNetworkFactory.h"
|
||||
#include <future>
|
||||
@@ -315,7 +315,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
if (success) {
|
||||
//Broadcast our startSkill:
|
||||
RakNet::BitStream bitStreamLocal;
|
||||
PacketUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
BitStreamUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
bitStreamLocal.Write(entity->GetObjectID());
|
||||
|
||||
EchoStartSkill echoStartSkill;
|
||||
@@ -337,7 +337,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
|
||||
|
||||
case eGameMessageType::SYNC_SKILL: {
|
||||
RakNet::BitStream bitStreamLocal;
|
||||
PacketUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
BitStreamUtils::WriteHeader(bitStreamLocal, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
|
||||
bitStreamLocal.Write(entity->GetObjectID());
|
||||
//bitStreamLocal.Write((unsigned short)eGameMessageType::ECHO_SYNC_SKILL);
|
||||
//bitStreamLocal.Write(inStream);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include "User.h"
|
||||
#include "Entity.h"
|
||||
#include "PacketUtils.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "BitStream.h"
|
||||
#include "Game.h"
|
||||
#include "SlashCommandHandler.h"
|
||||
@@ -173,7 +174,7 @@ void GameMessages::SendPlayAnimation(Entity* entity, const std::u16string& anima
|
||||
bitStream.Write(eGameMessageType::PLAY_ANIMATION);
|
||||
|
||||
bitStream.Write(animationIDLength);
|
||||
PacketUtils::WriteWString(bitStream, animationName, animationIDLength);
|
||||
bitStream.Write(LUWString(animationName, animationIDLength));
|
||||
|
||||
bitStream.Write(bExpectAnimToExist);
|
||||
|
||||
@@ -326,13 +327,6 @@ void GameMessages::SendPlayNDAudioEmitter(Entity* entity, const SystemAddress& s
|
||||
bitStream.Write(static_cast<char>(audioGUID[k]));
|
||||
}
|
||||
|
||||
//PacketUtils::WriteString(bitStream, audioGUID, audioGUID.size());
|
||||
|
||||
//bitStream.Write(uint32_t(audioGUID.size()));
|
||||
//for (char character : audioGUID) {
|
||||
// bitStream.Write(character);
|
||||
//}
|
||||
|
||||
bitStream.Write(uint32_t(0));
|
||||
bitStream.Write0();
|
||||
bitStream.Write0();
|
||||
@@ -2181,7 +2175,7 @@ void GameMessages::HandleUnUseModel(RakNet::BitStream* inStream, Entity* entity,
|
||||
|
||||
if (unknown) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_SAVE_RESPONSE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_SAVE_RESPONSE);
|
||||
bitStream.Write<LWOOBJID>(LWOOBJID_EMPTY); //always zero so that a check on the client passes
|
||||
bitStream.Write(eBlueprintSaveResponseType::PlacementFailed); // Sending a non-zero error code here prevents the client from deleting its in progress build for some reason?
|
||||
bitStream.Write<uint32_t>(0);
|
||||
@@ -2433,7 +2427,7 @@ void GameMessages::HandleBBBLoadItemRequest(RakNet::BitStream* inStream, Entity*
|
||||
|
||||
void GameMessages::SendBlueprintLoadItemResponse(const SystemAddress& sysAddr, bool success, LWOOBJID oldItemId, LWOOBJID newItemId) {
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_LOAD_RESPONSE_ITEMID);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_LOAD_RESPONSE_ITEMID);
|
||||
bitStream.Write(static_cast<uint8_t>(success));
|
||||
bitStream.Write<LWOOBJID>(oldItemId);
|
||||
bitStream.Write<LWOOBJID>(newItemId);
|
||||
@@ -2681,7 +2675,7 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
|
||||
|
||||
//Tell the client their model is saved: (this causes us to actually pop out of our current state):
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_SAVE_RESPONSE);
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CLIENT, eClientMessageType::BLUEPRINT_SAVE_RESPONSE);
|
||||
bitStream.Write(localId);
|
||||
bitStream.Write(eBlueprintSaveResponseType::EverythingWorked);
|
||||
bitStream.Write<uint32_t>(1);
|
||||
|
Reference in New Issue
Block a user