From c3743877df009afac6337c720255d82c5271a862 Mon Sep 17 00:00:00 2001 From: jadebenn Date: Mon, 26 Feb 2024 08:09:45 -0600 Subject: [PATCH] chore: Change EchoStartSkill to use BitStream reference (#1472) --- dGame/dComponents/SkillComponent.cpp | 2 +- dGame/dGameMessages/EchoStartSkill.h | 76 +++++++++++----------- dGame/dGameMessages/GameMessageHandler.cpp | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index e84c3eb1..5fc917a3 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -305,7 +305,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG); message.Write(this->m_Parent->GetObjectID()); - start.Serialize(&message); + start.Serialize(message); Game::server->Send(&message, UNASSIGNED_SYSTEM_ADDRESS, true); } diff --git a/dGame/dGameMessages/EchoStartSkill.h b/dGame/dGameMessages/EchoStartSkill.h index 389a81e0..dfb79021 100644 --- a/dGame/dGameMessages/EchoStartSkill.h +++ b/dGame/dGameMessages/EchoStartSkill.h @@ -32,85 +32,85 @@ public: uiSkillHandle = _uiSkillHandle; } - EchoStartSkill(RakNet::BitStream* stream) : EchoStartSkill() { + EchoStartSkill(RakNet::BitStream& stream) : EchoStartSkill() { Deserialize(stream); } ~EchoStartSkill() { } - void Serialize(RakNet::BitStream* stream) { - stream->Write(eGameMessageType::ECHO_START_SKILL); + void Serialize(RakNet::BitStream& stream) { + stream.Write(eGameMessageType::ECHO_START_SKILL); - stream->Write(bUsedMouse); + stream.Write(bUsedMouse); - stream->Write(fCasterLatency != 0.0f); - if (fCasterLatency != 0.0f) stream->Write(fCasterLatency); + stream.Write(fCasterLatency != 0.0f); + if (fCasterLatency != 0.0f) stream.Write(fCasterLatency); - stream->Write(iCastType != 0); - if (iCastType != 0) stream->Write(iCastType); + stream.Write(iCastType != 0); + if (iCastType != 0) stream.Write(iCastType); - stream->Write(lastClickedPosit != NiPoint3Constant::ZERO); - if (lastClickedPosit != NiPoint3Constant::ZERO) stream->Write(lastClickedPosit); + stream.Write(lastClickedPosit != NiPoint3Constant::ZERO); + if (lastClickedPosit != NiPoint3Constant::ZERO) stream.Write(lastClickedPosit); - stream->Write(optionalOriginatorID); + stream.Write(optionalOriginatorID); - stream->Write(optionalTargetID != LWOOBJID_EMPTY); - if (optionalTargetID != LWOOBJID_EMPTY) stream->Write(optionalTargetID); + stream.Write(optionalTargetID != LWOOBJID_EMPTY); + if (optionalTargetID != LWOOBJID_EMPTY) stream.Write(optionalTargetID); - stream->Write(originatorRot != NiQuaternionConstant::IDENTITY); - if (originatorRot != NiQuaternionConstant::IDENTITY) stream->Write(originatorRot); + stream.Write(originatorRot != NiQuaternionConstant::IDENTITY); + if (originatorRot != NiQuaternionConstant::IDENTITY) stream.Write(originatorRot); uint32_t sBitStreamLength = sBitStream.length(); - stream->Write(sBitStreamLength); + stream.Write(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { - stream->Write(sBitStream[k]); + stream.Write(sBitStream[k]); } - stream->Write(skillID); + stream.Write(skillID); - stream->Write(uiSkillHandle != 0); - if (uiSkillHandle != 0) stream->Write(uiSkillHandle); + stream.Write(uiSkillHandle != 0); + if (uiSkillHandle != 0) stream.Write(uiSkillHandle); } - bool Deserialize(RakNet::BitStream* stream) { - stream->Read(bUsedMouse); + bool Deserialize(RakNet::BitStream& stream) { + stream.Read(bUsedMouse); bool fCasterLatencyIsDefault{}; - stream->Read(fCasterLatencyIsDefault); - if (fCasterLatencyIsDefault != 0) stream->Read(fCasterLatency); + stream.Read(fCasterLatencyIsDefault); + if (fCasterLatencyIsDefault != 0) stream.Read(fCasterLatency); bool iCastTypeIsDefault{}; - stream->Read(iCastTypeIsDefault); - if (iCastTypeIsDefault != 0) stream->Read(iCastType); + stream.Read(iCastTypeIsDefault); + if (iCastTypeIsDefault != 0) stream.Read(iCastType); bool lastClickedPositIsDefault{}; - stream->Read(lastClickedPositIsDefault); - if (lastClickedPositIsDefault != 0) stream->Read(lastClickedPosit); + stream.Read(lastClickedPositIsDefault); + if (lastClickedPositIsDefault != 0) stream.Read(lastClickedPosit); - stream->Read(optionalOriginatorID); + stream.Read(optionalOriginatorID); bool optionalTargetIDIsDefault{}; - stream->Read(optionalTargetIDIsDefault); - if (optionalTargetIDIsDefault != 0) stream->Read(optionalTargetID); + stream.Read(optionalTargetIDIsDefault); + if (optionalTargetIDIsDefault != 0) stream.Read(optionalTargetID); bool originatorRotIsDefault{}; - stream->Read(originatorRotIsDefault); - if (originatorRotIsDefault != 0) stream->Read(originatorRot); + stream.Read(originatorRotIsDefault); + if (originatorRotIsDefault != 0) stream.Read(originatorRot); uint32_t sBitStreamLength{}; - stream->Read(sBitStreamLength); + stream.Read(sBitStreamLength); for (uint32_t k = 0; k < sBitStreamLength; k++) { unsigned char character; - stream->Read(character); + stream.Read(character); sBitStream.push_back(character); } - stream->Read(skillID); + stream.Read(skillID); bool uiSkillHandleIsDefault{}; - stream->Read(uiSkillHandleIsDefault); - if (uiSkillHandleIsDefault != 0) stream->Read(uiSkillHandle); + stream.Read(uiSkillHandleIsDefault); + if (uiSkillHandleIsDefault != 0) stream.Read(uiSkillHandle); return true; } diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 2cd205d1..68f293fc 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -327,7 +327,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System echoStartSkill.sBitStream = startSkill.sBitStream; echoStartSkill.skillID = startSkill.skillID; echoStartSkill.uiSkillHandle = startSkill.uiSkillHandle; - echoStartSkill.Serialize(&bitStreamLocal); + echoStartSkill.Serialize(bitStreamLocal); Game::server->Send(&bitStreamLocal, entity->GetSystemAddress(), true); }