diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index ab51a584..55b2b85f 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -899,34 +899,34 @@ void Entity::SetGMLevel(eGameMasterLevel value) { } } -void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) { +void Entity::WriteBaseReplicaData(RakNet::BitStream& outBitStream, eReplicaPacketType packetType) { if (packetType == eReplicaPacketType::CONSTRUCTION) { - outBitStream->Write(m_ObjectID); - outBitStream->Write(m_TemplateID); + outBitStream.Write(m_ObjectID); + outBitStream.Write(m_TemplateID); if (IsPlayer()) { std::string name = m_Character != nullptr ? m_Character->GetName() : "Invalid"; - outBitStream->Write(uint8_t(name.size())); + outBitStream.Write(uint8_t(name.size())); for (size_t i = 0; i < name.size(); ++i) { - outBitStream->Write(name[i]); + outBitStream.Write(name[i]); } } else { const auto& name = GetVar(u"npcName"); - outBitStream->Write(uint8_t(name.size())); + outBitStream.Write(uint8_t(name.size())); for (size_t i = 0; i < name.size(); ++i) { - outBitStream->Write(name[i]); + outBitStream.Write(name[i]); } } - outBitStream->Write(0); //Time since created on server + outBitStream.Write(0); //Time since created on server const auto& syncLDF = GetVar>(u"syncLDF"); // Only sync for models. if (m_Settings.size() > 0 && (GetComponent() && !GetComponent())) { - outBitStream->Write1(); //ldf data + outBitStream.Write1(); //ldf data RakNet::BitStream settingStream; int32_t numberOfValidKeys = m_Settings.size(); @@ -947,9 +947,9 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke } } - outBitStream->Write(settingStream.GetNumberOfBytesUsed() + 1); - outBitStream->Write(0); //no compression used - outBitStream->Write(settingStream); + outBitStream.Write(settingStream.GetNumberOfBytesUsed() + 1); + outBitStream.Write(0); //no compression used + outBitStream.Write(settingStream); } else if (!syncLDF.empty()) { std::vector ldfData; @@ -957,7 +957,7 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke ldfData.push_back(GetVarData(data)); } - outBitStream->Write1(); //ldf data + outBitStream.Write1(); //ldf data RakNet::BitStream settingStream; settingStream.Write(ldfData.size()); @@ -967,69 +967,69 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke } } - outBitStream->Write(settingStream.GetNumberOfBytesUsed() + 1); - outBitStream->Write(0); //no compression used - outBitStream->Write(settingStream); + outBitStream.Write(settingStream.GetNumberOfBytesUsed() + 1); + outBitStream.Write(0); //no compression used + outBitStream.Write(settingStream); } else { - outBitStream->Write0(); //No ldf data + outBitStream.Write0(); //No ldf data } TriggerComponent* triggerComponent; if (TryGetComponent(eReplicaComponentType::TRIGGER, triggerComponent)) { // has trigger component, check to see if we have events to handle auto* trigger = triggerComponent->GetTrigger(); - outBitStream->Write(trigger && trigger->events.size() > 0); + outBitStream.Write(trigger && trigger->events.size() > 0); } else { // no trigger componenet, so definitely no triggers - outBitStream->Write0(); + outBitStream.Write0(); } if (m_ParentEntity != nullptr || m_SpawnerID != 0) { - outBitStream->Write1(); - if (m_ParentEntity != nullptr) outBitStream->Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), static_cast(eObjectBits::CLIENT))); - else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream->Write(m_SpawnerID); - else outBitStream->Write(GeneralUtils::SetBit(m_SpawnerID, static_cast(eObjectBits::CLIENT))); - } else outBitStream->Write0(); + outBitStream.Write1(); + if (m_ParentEntity != nullptr) outBitStream.Write(GeneralUtils::SetBit(m_ParentEntity->GetObjectID(), static_cast(eObjectBits::CLIENT))); + else if (m_Spawner != nullptr && m_Spawner->m_Info.isNetwork) outBitStream.Write(m_SpawnerID); + else outBitStream.Write(GeneralUtils::SetBit(m_SpawnerID, static_cast(eObjectBits::CLIENT))); + } else outBitStream.Write0(); - outBitStream->Write(m_HasSpawnerNodeID); - if (m_HasSpawnerNodeID) outBitStream->Write(m_SpawnerNodeID); + outBitStream.Write(m_HasSpawnerNodeID); + if (m_HasSpawnerNodeID) outBitStream.Write(m_SpawnerNodeID); - //outBitStream->Write0(); //Spawner node id + //outBitStream.Write0(); //Spawner node id - if (m_Scale == 1.0f || m_Scale == 0.0f) outBitStream->Write0(); + if (m_Scale == 1.0f || m_Scale == 0.0f) outBitStream.Write0(); else { - outBitStream->Write1(); - outBitStream->Write(m_Scale); + outBitStream.Write1(); + outBitStream.Write(m_Scale); } - outBitStream->Write0(); //ObjectWorldState + outBitStream.Write0(); //ObjectWorldState if (m_GMLevel != eGameMasterLevel::CIVILIAN) { - outBitStream->Write1(); - outBitStream->Write(m_GMLevel); - } else outBitStream->Write0(); //No GM Level + outBitStream.Write1(); + outBitStream.Write(m_GMLevel); + } else outBitStream.Write0(); //No GM Level } // Only serialize parent / child info should the info be dirty (changed) or if this is the construction of the entity. - outBitStream->Write(m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION); + outBitStream.Write(m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION); if (m_IsParentChildDirty || packetType == eReplicaPacketType::CONSTRUCTION) { m_IsParentChildDirty = false; - outBitStream->Write(m_ParentEntity != nullptr); + outBitStream.Write(m_ParentEntity != nullptr); if (m_ParentEntity) { - outBitStream->Write(m_ParentEntity->GetObjectID()); - outBitStream->Write0(); + outBitStream.Write(m_ParentEntity->GetObjectID()); + outBitStream.Write0(); } - outBitStream->Write(m_ChildEntities.size() > 0); + outBitStream.Write(m_ChildEntities.size() > 0); if (m_ChildEntities.size() > 0) { - outBitStream->Write(m_ChildEntities.size()); + outBitStream.Write(m_ChildEntities.size()); for (Entity* child : m_ChildEntities) { - outBitStream->Write(child->GetObjectID()); + outBitStream.Write(child->GetObjectID()); } } } } -void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType) { +void Entity::WriteComponents(RakNet::BitStream& outBitStream, eReplicaPacketType packetType) { /** * This has to be done in a specific order. @@ -1117,7 +1117,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType possessorComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe - outBitStream->Write0(); + outBitStream.Write0(); } LevelProgressionComponent* levelProgressionComponent; @@ -1125,7 +1125,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe - outBitStream->Write0(); + outBitStream.Write0(); } PlayerForcedMovementComponent* playerForcedMovementComponent; @@ -1133,7 +1133,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate); } else { // Should never happen, but just to be safe - outBitStream->Write0(); + outBitStream.Write0(); } characterComponent->Serialize(outBitStream, bIsInitialUpdate); @@ -1250,7 +1250,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType // BBB Component, unused currently // Need to to write0 so that is serialized correctly // TODO: Implement BBB Component - outBitStream->Write0(); + outBitStream.Write0(); } void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) { diff --git a/dGame/Entity.h b/dGame/Entity.h index 7d5e24c9..711e0b63 100644 --- a/dGame/Entity.h +++ b/dGame/Entity.h @@ -171,8 +171,8 @@ public: std::unordered_map& GetComponents() { return m_Components; } // TODO: Remove - void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); - void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); + void WriteBaseReplicaData(RakNet::BitStream& outBitStream, eReplicaPacketType packetType); + void WriteComponents(RakNet::BitStream& outBitStream, eReplicaPacketType packetType); void UpdateXMLDoc(tinyxml2::XMLDocument* doc); void Update(float deltaTime); diff --git a/dGame/EntityManager.cpp b/dGame/EntityManager.cpp index 78e85a8f..4d648bbd 100644 --- a/dGame/EntityManager.cpp +++ b/dGame/EntityManager.cpp @@ -178,8 +178,8 @@ void EntityManager::SerializeEntities() { stream.Write(ID_REPLICA_MANAGER_SERIALIZE); stream.Write(entity->GetNetworkId()); - entity->WriteBaseReplicaData(&stream, eReplicaPacketType::SERIALIZATION); - entity->WriteComponents(&stream, eReplicaPacketType::SERIALIZATION); + entity->WriteBaseReplicaData(stream, eReplicaPacketType::SERIALIZATION); + entity->WriteComponents(stream, eReplicaPacketType::SERIALIZATION); if (entity->GetIsGhostingCandidate()) { for (auto* player : PlayerManager::GetAllPlayers()) { @@ -359,8 +359,8 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr stream.Write(true); stream.Write(entity->GetNetworkId()); - entity->WriteBaseReplicaData(&stream, eReplicaPacketType::CONSTRUCTION); - entity->WriteComponents(&stream, eReplicaPacketType::CONSTRUCTION); + entity->WriteBaseReplicaData(stream, eReplicaPacketType::CONSTRUCTION); + entity->WriteComponents(stream, eReplicaPacketType::CONSTRUCTION); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) { if (skipChecks) { diff --git a/dGame/dBehaviors/AirMovementBehavior.cpp b/dGame/dBehaviors/AirMovementBehavior.cpp index 8a3f894c..46d18680 100644 --- a/dGame/dBehaviors/AirMovementBehavior.cpp +++ b/dGame/dBehaviors/AirMovementBehavior.cpp @@ -5,35 +5,35 @@ #include "Game.h" #include "Logger.h" -void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t handle{}; - if (!bitStream->Read(handle)) { - LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(handle)) { + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } context->RegisterSyncBehavior(handle, this, branch, this->m_Timeout); } -void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto handle = context->GetUniqueSkillId(); - bitStream->Write(handle); + bitStream.Write(handle); } -void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t behaviorId{}; - if (!bitStream->Read(behaviorId)) { - LOG("Unable to read behaviorId from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(behaviorId)) { + LOG("Unable to read behaviorId from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } LWOOBJID target{}; - if (!bitStream->Read(target)) { - LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(target)) { + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } diff --git a/dGame/dBehaviors/AirMovementBehavior.h b/dGame/dBehaviors/AirMovementBehavior.h index 9d51ef03..0edb1a76 100644 --- a/dGame/dBehaviors/AirMovementBehavior.h +++ b/dGame/dBehaviors/AirMovementBehavior.h @@ -6,11 +6,11 @@ class AirMovementBehavior final : public Behavior public: explicit AirMovementBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/AndBehavior.cpp b/dGame/dBehaviors/AndBehavior.cpp index 57493248..ad986e37 100644 --- a/dGame/dBehaviors/AndBehavior.cpp +++ b/dGame/dBehaviors/AndBehavior.cpp @@ -3,13 +3,13 @@ #include "Game.h" #include "Logger.h" -void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { for (auto* behavior : this->m_behaviors) { behavior->Handle(context, bitStream, branch); } } -void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { for (auto* behavior : this->m_behaviors) { behavior->Calculate(context, bitStream, branch); } diff --git a/dGame/dBehaviors/AndBehavior.h b/dGame/dBehaviors/AndBehavior.h index 0ef7c0fd..76bd3956 100644 --- a/dGame/dBehaviors/AndBehavior.h +++ b/dGame/dBehaviors/AndBehavior.h @@ -15,9 +15,9 @@ public: explicit AndBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/ApplyBuffBehavior.cpp b/dGame/dBehaviors/ApplyBuffBehavior.cpp index 26b3da84..9ee48375 100644 --- a/dGame/dBehaviors/ApplyBuffBehavior.cpp +++ b/dGame/dBehaviors/ApplyBuffBehavior.cpp @@ -5,7 +5,7 @@ #include "BuffComponent.h" -void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target); if (entity == nullptr) return; @@ -30,7 +30,7 @@ void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext b buffComponent->RemoveBuff(m_BuffId); } -void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ApplyBuffBehavior.h b/dGame/dBehaviors/ApplyBuffBehavior.h index e01a238e..4acc6550 100644 --- a/dGame/dBehaviors/ApplyBuffBehavior.h +++ b/dGame/dBehaviors/ApplyBuffBehavior.h @@ -24,11 +24,11 @@ public: explicit ApplyBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.cpp b/dGame/dBehaviors/AreaOfEffectBehavior.cpp index 2a7e9754..ce41785f 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.cpp +++ b/dGame/dBehaviors/AreaOfEffectBehavior.cpp @@ -12,11 +12,11 @@ #include "Game.h" #include "Logger.h" -void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t targetCount{}; - if (!bitStream->Read(targetCount)) { - LOG("Unable to read targetCount from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(targetCount)) { + LOG("Unable to read targetCount from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } @@ -40,7 +40,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b for (auto i = 0u; i < targetCount; ++i) { LWOOBJID target{}; - if (!bitStream->Read(target)) { + if (!bitStream.Read(target)) { LOG("failed to read in target %i from bitStream, aborting target Handle!", i); }; targets.push_back(target); @@ -54,7 +54,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b PlayFx(u"cast", context->originator); } -void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* caster = Game::entityManager->GetEntity(context->caster); if (!caster) return; @@ -83,7 +83,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream // resize if we have more than max targets allows if (targets.size() > this->m_maxTargets) targets.resize(this->m_maxTargets); - bitStream->Write(targets.size()); + bitStream.Write(targets.size()); if (targets.size() == 0) { PlayFx(u"miss", context->originator); @@ -92,7 +92,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream context->foundTarget = true; // write all the targets to the bitstream for (auto* target : targets) { - bitStream->Write(target->GetObjectID()); + bitStream.Write(target->GetObjectID()); } // then cast all the actions diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.h b/dGame/dBehaviors/AreaOfEffectBehavior.h index f0fbb18d..5ce20003 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.h +++ b/dGame/dBehaviors/AreaOfEffectBehavior.h @@ -6,8 +6,8 @@ class AreaOfEffectBehavior final : public Behavior { public: explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: Behavior* m_action; diff --git a/dGame/dBehaviors/AttackDelayBehavior.cpp b/dGame/dBehaviors/AttackDelayBehavior.cpp index 1bf1048a..105a1327 100644 --- a/dGame/dBehaviors/AttackDelayBehavior.cpp +++ b/dGame/dBehaviors/AttackDelayBehavior.cpp @@ -4,11 +4,11 @@ #include "Game.h" #include "Logger.h" -void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t handle{}; - if (!bitStream->Read(handle)) { - LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(handle)) { + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -17,10 +17,10 @@ void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi } } -void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { const auto handle = context->GetUniqueSkillId(); - bitStream->Write(handle); + bitStream.Write(handle); context->foundTarget = true; @@ -31,11 +31,11 @@ void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* } } -void AttackDelayBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { this->m_action->Handle(context, bitStream, branch); } -void AttackDelayBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void AttackDelayBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { PlayFx(u"cast", context->originator); this->m_action->Calculate(context, bitStream, branch); diff --git a/dGame/dBehaviors/AttackDelayBehavior.h b/dGame/dBehaviors/AttackDelayBehavior.h index 64271ba5..173b0a0d 100644 --- a/dGame/dBehaviors/AttackDelayBehavior.h +++ b/dGame/dBehaviors/AttackDelayBehavior.h @@ -19,13 +19,13 @@ public: explicit AttackDelayBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index 914e67a5..3d45d9a7 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -9,7 +9,7 @@ #include "BehaviorContext.h" #include "eBasicAttackSuccessTypes.h" -void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (context->unmanaged) { auto* entity = Game::entityManager->GetEntity(branch.target); @@ -30,22 +30,22 @@ void BasicAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi return; } - bitStream->AlignReadToByteBoundary(); + bitStream.AlignReadToByteBoundary(); uint16_t allocatedBits{}; - if (!bitStream->Read(allocatedBits) || allocatedBits == 0) { + if (!bitStream.Read(allocatedBits) || allocatedBits == 0) { LOG_DEBUG("No allocated bits"); return; } LOG_DEBUG("Number of allocated bits %i", allocatedBits); - const auto baseAddress = bitStream->GetReadOffset(); + const auto baseAddress = bitStream.GetReadOffset(); DoHandleBehavior(context, bitStream, branch); - bitStream->SetReadOffset(baseAddress + allocatedBits); + bitStream.SetReadOffset(baseAddress + allocatedBits); } -void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* targetEntity = Game::entityManager->GetEntity(branch.target); if (!targetEntity) { LOG("Target targetEntity %llu not found.", branch.target); @@ -62,7 +62,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit bool isImmune{}; bool isSuccess{}; - if (!bitStream->Read(isBlocked)) { + if (!bitStream.Read(isBlocked)) { LOG("Unable to read isBlocked"); return; } @@ -74,7 +74,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit return; } - if (!bitStream->Read(isImmune)) { + if (!bitStream.Read(isImmune)) { LOG("Unable to read isImmune"); return; } @@ -85,20 +85,20 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit return; } - if (!bitStream->Read(isSuccess)) { + if (!bitStream.Read(isSuccess)) { LOG("failed to read success from bitstream"); return; } if (isSuccess) { uint32_t armorDamageDealt{}; - if (!bitStream->Read(armorDamageDealt)) { + if (!bitStream.Read(armorDamageDealt)) { LOG("Unable to read armorDamageDealt"); return; } uint32_t healthDamageDealt{}; - if (!bitStream->Read(healthDamageDealt)) { + if (!bitStream.Read(healthDamageDealt)) { LOG("Unable to read healthDamageDealt"); return; } @@ -111,7 +111,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } bool died{}; - if (!bitStream->Read(died)) { + if (!bitStream.Read(died)) { LOG("Unable to read died"); return; } @@ -122,7 +122,7 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } uint8_t successState{}; - if (!bitStream->Read(successState)) { + if (!bitStream.Read(successState)) { LOG("Unable to read success state"); return; } @@ -144,26 +144,26 @@ void BasicAttackBehavior::DoHandleBehavior(BehaviorContext* context, RakNet::Bit } } -void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { - bitStream->AlignWriteToByteBoundary(); +void BasicAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { + bitStream.AlignWriteToByteBoundary(); - const auto allocatedAddress = bitStream->GetWriteOffset(); + const auto allocatedAddress = bitStream.GetWriteOffset(); - bitStream->Write(0); + bitStream.Write(0); - const auto startAddress = bitStream->GetWriteOffset(); + const auto startAddress = bitStream.GetWriteOffset(); DoBehaviorCalculation(context, bitStream, branch); - const auto endAddress = bitStream->GetWriteOffset(); + const auto endAddress = bitStream.GetWriteOffset(); const uint16_t allocate = endAddress - startAddress; - bitStream->SetWriteOffset(allocatedAddress); - bitStream->Write(allocate); - bitStream->SetWriteOffset(startAddress + allocate); + bitStream.SetWriteOffset(allocatedAddress); + bitStream.Write(allocate); + bitStream.SetWriteOffset(startAddress + allocate); } -void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* targetEntity = Game::entityManager->GetEntity(branch.target); if (!targetEntity) { LOG("Target entity %llu is null!", branch.target); @@ -178,7 +178,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet const bool isBlocking = destroyableComponent->GetAttacksToBlock() > 0; - bitStream->Write(isBlocking); + bitStream.Write(isBlocking); if (isBlocking) { destroyableComponent->SetAttacksToBlock(destroyableComponent->GetAttacksToBlock() - 1); @@ -188,7 +188,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet } const bool isImmune = destroyableComponent->IsImmune() || destroyableComponent->IsCooldownImmune(); - bitStream->Write(isImmune); + bitStream.Write(isImmune); if (isImmune) { LOG_DEBUG("Target targetEntity %llu is immune!", branch.target); @@ -210,7 +210,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet const uint32_t healthDamageDealt = previousHealth - destroyableComponent->GetHealth(); isSuccess = armorDamageDealt > 0 || healthDamageDealt > 0 || (armorDamageDealt + healthDamageDealt) > 0; - bitStream->Write(isSuccess); + bitStream.Write(isSuccess); //Handle player damage cooldown if (isSuccess && targetEntity->IsPlayer() && !this->m_DontApplyImmune) { @@ -225,12 +225,12 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet successState = this->m_OnFailArmor->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY ? eBasicAttackSuccessTypes::FAILIMMUNE : eBasicAttackSuccessTypes::FAILARMOR; } - bitStream->Write(armorDamageDealt); - bitStream->Write(healthDamageDealt); - bitStream->Write(targetEntity->GetIsDead()); + bitStream.Write(armorDamageDealt); + bitStream.Write(healthDamageDealt); + bitStream.Write(targetEntity->GetIsDead()); } - bitStream->Write(successState); + bitStream.Write(successState); switch (static_cast(successState)) { case eBasicAttackSuccessTypes::SUCCESS: diff --git a/dGame/dBehaviors/BasicAttackBehavior.h b/dGame/dBehaviors/BasicAttackBehavior.h index 6525c343..3cde23fd 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.h +++ b/dGame/dBehaviors/BasicAttackBehavior.h @@ -12,7 +12,7 @@ public: * is then offset to after the allocated bits for this stream. * */ - void DoHandleBehavior(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + void DoHandleBehavior(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); /** * @brief Handles a client initialized Basic Attack Behavior cast to be deserialized and verified on the server. @@ -22,14 +22,14 @@ public: * and will fail gracefully if an overread is detected. * @param branch The context of this specific branch of the Skill Behavior. Changes based on which branch you are going down. */ - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; /** * @brief Writes a 16bit short to the bitStream and when the actual behavior calculation finishes with all of its branches, the number * of bits used is then written to where the 16bit short initially was. * */ - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; /** * @brief Calculates a server initialized Basic Attack Behavior cast to be serialized to the client @@ -38,7 +38,7 @@ public: * @param bitStream The bitStream to serialize to. * @param branch The context of this specific branch of the Skill Behavior. Changes based on which branch you are going down. */ - void DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + void DoBehaviorCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); /** * @brief Loads this Behaviors parameters from the database. For this behavior specifically: diff --git a/dGame/dBehaviors/Behavior.cpp b/dGame/dBehaviors/Behavior.cpp index 64bb03f5..36607a66 100644 --- a/dGame/dBehaviors/Behavior.cpp +++ b/dGame/dBehaviors/Behavior.cpp @@ -487,10 +487,10 @@ std::map Behavior::GetParameterNames() const { void Behavior::Load() { } -void Behavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } -void Behavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } void Behavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) { @@ -502,10 +502,10 @@ void Behavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWO void Behavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) { } -void Behavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } -void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } Behavior::~Behavior() { diff --git a/dGame/dBehaviors/Behavior.h b/dGame/dBehaviors/Behavior.h index ca1c23e5..af7fd206 100644 --- a/dGame/dBehaviors/Behavior.h +++ b/dGame/dBehaviors/Behavior.h @@ -68,9 +68,9 @@ public: virtual void Load(); // Player side - virtual void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); - virtual void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); virtual void UnCast(BehaviorContext* context, BehaviorBranchContext branch); @@ -79,9 +79,9 @@ public: virtual void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second); // Npc side - virtual void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); - virtual void SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch); + virtual void SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch); /* * Creations/destruction diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index 1357f54b..5ca335b1 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -105,7 +105,7 @@ void BehaviorContext::ExecuteUpdates() { this->scheduledUpdates.clear(); } -void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bitStream) { +void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bitStream) { BehaviorSyncEntry entry; auto found = false; @@ -246,7 +246,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime) { RakNet::BitStream bitStream{}; // Calculate sync - entry.behavior->SyncCalculation(this, &bitStream, entry.branchContext); + entry.behavior->SyncCalculation(this, bitStream, entry.branchContext); if (!clientInitalized) { echo.sBitStream.assign(reinterpret_cast(bitStream.GetData()), bitStream.GetNumberOfBytesUsed()); diff --git a/dGame/dBehaviors/BehaviorContext.h b/dGame/dBehaviors/BehaviorContext.h index 333dc9a8..3e6c0b1d 100644 --- a/dGame/dBehaviors/BehaviorContext.h +++ b/dGame/dBehaviors/BehaviorContext.h @@ -93,7 +93,7 @@ struct BehaviorContext void ExecuteUpdates(); - void SyncBehavior(uint32_t syncId, RakNet::BitStream* bitStream); + void SyncBehavior(uint32_t syncId, RakNet::BitStream& bitStream); void Update(float deltaTime); diff --git a/dGame/dBehaviors/BlockBehavior.cpp b/dGame/dBehaviors/BlockBehavior.cpp index 88c6bb0b..0d3e164b 100644 --- a/dGame/dBehaviors/BlockBehavior.cpp +++ b/dGame/dBehaviors/BlockBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto target = context->originator; auto* entity = Game::entityManager->GetEntity(target); @@ -33,7 +33,7 @@ void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea } } -void BlockBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BlockBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/BlockBehavior.h b/dGame/dBehaviors/BlockBehavior.h index e0d639ed..9f4d696d 100644 --- a/dGame/dBehaviors/BlockBehavior.h +++ b/dGame/dBehaviors/BlockBehavior.h @@ -13,9 +13,9 @@ public: explicit BlockBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/BuffBehavior.cpp b/dGame/dBehaviors/BuffBehavior.cpp index 7ac8b352..e20bf820 100644 --- a/dGame/dBehaviors/BuffBehavior.cpp +++ b/dGame/dBehaviors/BuffBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator; auto* entity = Game::entityManager->GetEntity(target); diff --git a/dGame/dBehaviors/BuffBehavior.h b/dGame/dBehaviors/BuffBehavior.h index b7c805b3..d057758a 100644 --- a/dGame/dBehaviors/BuffBehavior.h +++ b/dGame/dBehaviors/BuffBehavior.h @@ -16,7 +16,7 @@ public: explicit BuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/CarBoostBehavior.cpp b/dGame/dBehaviors/CarBoostBehavior.cpp index eb22cb09..fdbcba71 100644 --- a/dGame/dBehaviors/CarBoostBehavior.cpp +++ b/dGame/dBehaviors/CarBoostBehavior.cpp @@ -8,7 +8,7 @@ #include "Logger.h" #include "PossessableComponent.h" -void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { GameMessages::SendVehicleAddPassiveBoostAction(branch.target, UNASSIGNED_SYSTEM_ADDRESS); auto* entity = Game::entityManager->GetEntity(context->originator); diff --git a/dGame/dBehaviors/CarBoostBehavior.h b/dGame/dBehaviors/CarBoostBehavior.h index 3f4265b9..5e629421 100644 --- a/dGame/dBehaviors/CarBoostBehavior.h +++ b/dGame/dBehaviors/CarBoostBehavior.h @@ -17,7 +17,7 @@ public: explicit CarBoostBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ChainBehavior.cpp b/dGame/dBehaviors/ChainBehavior.cpp index 4a20c151..feb27988 100644 --- a/dGame/dBehaviors/ChainBehavior.cpp +++ b/dGame/dBehaviors/ChainBehavior.cpp @@ -3,11 +3,11 @@ #include "Game.h" #include "Logger.h" -void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t chainIndex{}; - if (!bitStream->Read(chainIndex)) { - LOG("Unable to read chainIndex from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(chainIndex)) { + LOG("Unable to read chainIndex from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } @@ -16,12 +16,12 @@ void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea if (chainIndex < this->m_behaviors.size()) { this->m_behaviors.at(chainIndex)->Handle(context, bitStream, branch); } else { - LOG("chainIndex out of bounds, aborting handle of chain %i bits unread %i", chainIndex, bitStream->GetNumberOfUnreadBits()); + LOG("chainIndex out of bounds, aborting handle of chain %i bits unread %i", chainIndex, bitStream.GetNumberOfUnreadBits()); } } -void ChainBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { - bitStream->Write(1); +void ChainBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { + bitStream.Write(1); this->m_behaviors.at(0)->Calculate(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ChainBehavior.h b/dGame/dBehaviors/ChainBehavior.h index c31d5358..174326df 100644 --- a/dGame/dBehaviors/ChainBehavior.h +++ b/dGame/dBehaviors/ChainBehavior.h @@ -16,9 +16,9 @@ public: explicit ChainBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp b/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp index 06a79fa7..b7c6b80a 100644 --- a/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp +++ b/dGame/dBehaviors/ChangeIdleFlagsBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator; if (!target) return; @@ -16,7 +16,7 @@ void ChangeIdleFlagsBehavior::Handle(BehaviorContext* context, RakNet::BitStream } } -void ChangeIdleFlagsBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChangeIdleFlagsBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ChangeIdleFlagsBehavior.h b/dGame/dBehaviors/ChangeIdleFlagsBehavior.h index 91f802f4..e40af3cc 100644 --- a/dGame/dBehaviors/ChangeIdleFlagsBehavior.h +++ b/dGame/dBehaviors/ChangeIdleFlagsBehavior.h @@ -11,8 +11,8 @@ public: */ explicit ChangeIdleFlagsBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void Load() override; diff --git a/dGame/dBehaviors/ChangeOrientationBehavior.cpp b/dGame/dBehaviors/ChangeOrientationBehavior.cpp index 445c76df..f8a34fb8 100644 --- a/dGame/dBehaviors/ChangeOrientationBehavior.cpp +++ b/dGame/dBehaviors/ChangeOrientationBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" #include "EntityManager.h" -void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Entity* sourceEntity; if (this->m_orientCaster) sourceEntity = Game::entityManager->GetEntity(context->originator); else sourceEntity = Game::entityManager->GetEntity(branch.target); diff --git a/dGame/dBehaviors/ChangeOrientationBehavior.h b/dGame/dBehaviors/ChangeOrientationBehavior.h index 22c92bb8..62c47d5c 100644 --- a/dGame/dBehaviors/ChangeOrientationBehavior.h +++ b/dGame/dBehaviors/ChangeOrientationBehavior.h @@ -5,7 +5,7 @@ class ChangeOrientationBehavior final : public Behavior { public: explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: bool m_orientCaster; diff --git a/dGame/dBehaviors/ChargeUpBehavior.cpp b/dGame/dBehaviors/ChargeUpBehavior.cpp index cf737e19..dd6293db 100644 --- a/dGame/dBehaviors/ChargeUpBehavior.cpp +++ b/dGame/dBehaviors/ChargeUpBehavior.cpp @@ -4,10 +4,10 @@ #include "Game.h" #include "Logger.h" -void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t handle{}; - if (!bitStream->Read(handle)) { + if (!bitStream.Read(handle)) { LOG("Unable to read handle from bitStream, aborting Handle! variable_type"); return; }; @@ -15,10 +15,10 @@ void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt context->RegisterSyncBehavior(handle, this, branch, this->m_MaxDuration); } -void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } -void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { this->m_action->Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ChargeUpBehavior.h b/dGame/dBehaviors/ChargeUpBehavior.h index ceb40f6c..2ded1eb6 100644 --- a/dGame/dBehaviors/ChargeUpBehavior.h +++ b/dGame/dBehaviors/ChargeUpBehavior.h @@ -6,11 +6,11 @@ class ChargeUpBehavior final : public Behavior public: explicit ChargeUpBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/ClearTargetBehavior.cpp b/dGame/dBehaviors/ClearTargetBehavior.cpp index ec0c0db6..40ae9b01 100644 --- a/dGame/dBehaviors/ClearTargetBehavior.cpp +++ b/dGame/dBehaviors/ClearTargetBehavior.cpp @@ -3,13 +3,13 @@ #include "BehaviorContext.h" -void ClearTargetBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ClearTargetBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.target = LWOOBJID_EMPTY; this->m_action->Handle(context, bitStream, branch); } -void ClearTargetBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ClearTargetBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.target = LWOOBJID_EMPTY; this->m_action->Calculate(context, bitStream, branch); diff --git a/dGame/dBehaviors/ClearTargetBehavior.h b/dGame/dBehaviors/ClearTargetBehavior.h index 0ed57fb4..d950c8f5 100644 --- a/dGame/dBehaviors/ClearTargetBehavior.h +++ b/dGame/dBehaviors/ClearTargetBehavior.h @@ -14,9 +14,9 @@ public: explicit ClearTargetBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ConsumeItemBehavior.cpp b/dGame/dBehaviors/ConsumeItemBehavior.cpp index c3b76fcb..440a641b 100644 --- a/dGame/dBehaviors/ConsumeItemBehavior.cpp +++ b/dGame/dBehaviors/ConsumeItemBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorBranchContext.h" #include "InventoryComponent.h" -void ConsumeItemBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ConsumeItemBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto action_to_cast = m_ActionNotConsumed; if (this->m_ConsumeLOT != -1) { auto caster = Game::entityManager->GetEntity(context->caster); @@ -19,7 +19,7 @@ void ConsumeItemBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi if(action_to_cast) action_to_cast->Handle(context, bitStream, branch); } -void ConsumeItemBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ConsumeItemBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ConsumeItemBehavior.h b/dGame/dBehaviors/ConsumeItemBehavior.h index f3eeb330..c2fe357c 100644 --- a/dGame/dBehaviors/ConsumeItemBehavior.h +++ b/dGame/dBehaviors/ConsumeItemBehavior.h @@ -5,8 +5,8 @@ class ConsumeItemBehavior final : public Behavior { public: explicit ConsumeItemBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp index 880550e3..f657c8fd 100644 --- a/dGame/dBehaviors/DamageAbsorptionBehavior.cpp +++ b/dGame/dBehaviors/DamageAbsorptionBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -29,7 +29,7 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea context->RegisterTimerBehavior(this, branch, target->GetObjectID()); } -void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/DamageAbsorptionBehavior.h b/dGame/dBehaviors/DamageAbsorptionBehavior.h index 1b865e87..6e26bda1 100644 --- a/dGame/dBehaviors/DamageAbsorptionBehavior.h +++ b/dGame/dBehaviors/DamageAbsorptionBehavior.h @@ -13,9 +13,9 @@ public: explicit DamageAbsorptionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/DamageReductionBehavior.cpp b/dGame/dBehaviors/DamageReductionBehavior.cpp index bf32360e..62b70a52 100644 --- a/dGame/dBehaviors/DamageReductionBehavior.cpp +++ b/dGame/dBehaviors/DamageReductionBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" #include "DestroyableComponent.h" -void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -27,7 +27,7 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream context->RegisterTimerBehavior(this, branch, target->GetObjectID()); } -void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/DamageReductionBehavior.h b/dGame/dBehaviors/DamageReductionBehavior.h index bddd31fb..7a9aa4f5 100644 --- a/dGame/dBehaviors/DamageReductionBehavior.h +++ b/dGame/dBehaviors/DamageReductionBehavior.h @@ -13,9 +13,9 @@ public: explicit DamageReductionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/DarkInspirationBehavior.cpp b/dGame/dBehaviors/DarkInspirationBehavior.cpp index 27a7c634..367f9d5a 100644 --- a/dGame/dBehaviors/DarkInspirationBehavior.cpp +++ b/dGame/dBehaviors/DarkInspirationBehavior.cpp @@ -6,7 +6,7 @@ #include "EntityManager.h" #include "BehaviorContext.h" -void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -25,7 +25,7 @@ void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream } } -void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { diff --git a/dGame/dBehaviors/DarkInspirationBehavior.h b/dGame/dBehaviors/DarkInspirationBehavior.h index f8298742..5fe02c5e 100644 --- a/dGame/dBehaviors/DarkInspirationBehavior.h +++ b/dGame/dBehaviors/DarkInspirationBehavior.h @@ -11,9 +11,9 @@ public: explicit DarkInspirationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/DurationBehavior.cpp b/dGame/dBehaviors/DurationBehavior.cpp index c0bc5585..3544dc52 100644 --- a/dGame/dBehaviors/DurationBehavior.cpp +++ b/dGame/dBehaviors/DurationBehavior.cpp @@ -2,13 +2,13 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" -void DurationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DurationBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.duration = this->m_duration; this->m_action->Handle(context, bitStream, branch); } -void DurationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void DurationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { branch.duration = this->m_duration; this->m_action->Calculate(context, bitStream, branch); diff --git a/dGame/dBehaviors/DurationBehavior.h b/dGame/dBehaviors/DurationBehavior.h index 164754b1..5ea6abb9 100644 --- a/dGame/dBehaviors/DurationBehavior.h +++ b/dGame/dBehaviors/DurationBehavior.h @@ -11,9 +11,9 @@ public: explicit DurationBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: diff --git a/dGame/dBehaviors/EndBehavior.cpp b/dGame/dBehaviors/EndBehavior.cpp index c67f3215..804a31b7 100644 --- a/dGame/dBehaviors/EndBehavior.cpp +++ b/dGame/dBehaviors/EndBehavior.cpp @@ -3,11 +3,11 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void EndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void EndBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->InvokeEnd(this->m_startBehavior); } -void EndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void EndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->InvokeEnd(this->m_startBehavior); } diff --git a/dGame/dBehaviors/EndBehavior.h b/dGame/dBehaviors/EndBehavior.h index e1c06068..26a6f2d5 100644 --- a/dGame/dBehaviors/EndBehavior.h +++ b/dGame/dBehaviors/EndBehavior.h @@ -13,9 +13,9 @@ public: explicit EndBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/FallSpeedBehavior.cpp b/dGame/dBehaviors/FallSpeedBehavior.cpp index dfbdec2a..9a376cec 100644 --- a/dGame/dBehaviors/FallSpeedBehavior.cpp +++ b/dGame/dBehaviors/FallSpeedBehavior.cpp @@ -5,7 +5,7 @@ #include "BehaviorBranchContext.h" -void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { // make sure required parameter has non-default value if (m_PercentSlowed == 0.0f) return; auto* target = Game::entityManager->GetEntity(branch.target); @@ -23,7 +23,7 @@ void FallSpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS } } -void FallSpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void FallSpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/FallSpeedBehavior.h b/dGame/dBehaviors/FallSpeedBehavior.h index 01f0143f..f53c17e2 100644 --- a/dGame/dBehaviors/FallSpeedBehavior.h +++ b/dGame/dBehaviors/FallSpeedBehavior.h @@ -6,8 +6,8 @@ class FallSpeedBehavior final : public Behavior public: explicit FallSpeedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/ForceMovementBehavior.cpp b/dGame/dBehaviors/ForceMovementBehavior.cpp index 2ba3f2e1..83c6fabc 100644 --- a/dGame/dBehaviors/ForceMovementBehavior.cpp +++ b/dGame/dBehaviors/ForceMovementBehavior.cpp @@ -6,29 +6,29 @@ #include "Game.h" #include "Logger.h" -void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { return; } uint32_t handle{}; - if (!bitStream->Read(handle)) { - LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(handle)) { + LOG("Unable to read handle from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; } context->RegisterSyncBehavior(handle, this, branch, this->m_Duration); } -void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { uint32_t next{}; - if (!bitStream->Read(next)) { - LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(next)) { + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } LWOOBJID target{}; - if (!bitStream->Read(target)) { - LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(target)) { + LOG("Unable to read target from bitStream, aborting Sync! %i", bitStream.GetNumberOfUnreadBits()); return; } @@ -37,7 +37,7 @@ void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bi behavior->Handle(context, bitStream, branch); } -void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (this->m_hitAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitEnemyAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_hitFactionAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { return; } @@ -56,7 +56,7 @@ void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStrea } const auto skillHandle = context->GetUniqueSkillId(); - bitStream->Write(skillHandle); + bitStream.Write(skillHandle); context->SyncCalculation(skillHandle, this->m_Duration, this, branch); } @@ -71,7 +71,7 @@ void ForceMovementBehavior::Load() { this->m_Yaw = GetFloat("yaw"); } -void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ForceMovementBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* casterEntity = Game::entityManager->GetEntity(context->caster); if (casterEntity != nullptr) { auto* controllablePhysicsComponent = casterEntity->GetComponent(); diff --git a/dGame/dBehaviors/ForceMovementBehavior.h b/dGame/dBehaviors/ForceMovementBehavior.h index 8d5fd9f4..ffcea0f4 100644 --- a/dGame/dBehaviors/ForceMovementBehavior.h +++ b/dGame/dBehaviors/ForceMovementBehavior.h @@ -22,13 +22,13 @@ public: explicit ForceMovementBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void SyncCalculation(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Sync(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; diff --git a/dGame/dBehaviors/HealBehavior.cpp b/dGame/dBehaviors/HealBehavior.cpp index 3eb4928c..e2553671 100644 --- a/dGame/dBehaviors/HealBehavior.cpp +++ b/dGame/dBehaviors/HealBehavior.cpp @@ -7,7 +7,7 @@ #include "eReplicaComponentType.h" -void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { @@ -28,7 +28,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea } -void HealBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void HealBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/HealBehavior.h b/dGame/dBehaviors/HealBehavior.h index e967135a..9ce678a4 100644 --- a/dGame/dBehaviors/HealBehavior.h +++ b/dGame/dBehaviors/HealBehavior.h @@ -13,9 +13,9 @@ public: explicit HealBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ImaginationBehavior.cpp b/dGame/dBehaviors/ImaginationBehavior.cpp index c57fd0c7..be426e44 100644 --- a/dGame/dBehaviors/ImaginationBehavior.cpp +++ b/dGame/dBehaviors/ImaginationBehavior.cpp @@ -6,7 +6,7 @@ #include "Logger.h" -void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { @@ -23,7 +23,7 @@ void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi } -void ImaginationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void ImaginationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/ImaginationBehavior.h b/dGame/dBehaviors/ImaginationBehavior.h index a35c2ddd..ccebccc2 100644 --- a/dGame/dBehaviors/ImaginationBehavior.h +++ b/dGame/dBehaviors/ImaginationBehavior.h @@ -13,9 +13,9 @@ public: explicit ImaginationBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ImmunityBehavior.cpp b/dGame/dBehaviors/ImmunityBehavior.cpp index 9824c479..77d43834 100644 --- a/dGame/dBehaviors/ImmunityBehavior.cpp +++ b/dGame/dBehaviors/ImmunityBehavior.cpp @@ -9,7 +9,7 @@ #include "ControllablePhysicsComponent.h" #include "eStateChangeType.h" -void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (!target) { @@ -51,7 +51,7 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt context->RegisterTimerBehavior(this, branch, target->GetObjectID()); } -void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/ImmunityBehavior.h b/dGame/dBehaviors/ImmunityBehavior.h index 02cc0fae..d2f28b95 100644 --- a/dGame/dBehaviors/ImmunityBehavior.h +++ b/dGame/dBehaviors/ImmunityBehavior.h @@ -11,9 +11,9 @@ public: explicit ImmunityBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/InterruptBehavior.cpp b/dGame/dBehaviors/InterruptBehavior.cpp index bd3f0c4a..0b23c34d 100644 --- a/dGame/dBehaviors/InterruptBehavior.cpp +++ b/dGame/dBehaviors/InterruptBehavior.cpp @@ -7,12 +7,12 @@ #include "SkillComponent.h" -void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (branch.target != context->originator) { bool unknown = false; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -22,8 +22,8 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS if (!this->m_interruptBlock) { bool unknown = false; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -34,8 +34,8 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS { bool unknown = false; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } @@ -54,16 +54,16 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS } -void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (branch.target != context->originator) { - bitStream->Write(false); + bitStream.Write(false); } if (!this->m_interruptBlock) { - bitStream->Write(false); + bitStream.Write(false); } - bitStream->Write(false); + bitStream.Write(false); if (branch.target == context->originator) return; diff --git a/dGame/dBehaviors/InterruptBehavior.h b/dGame/dBehaviors/InterruptBehavior.h index 9ba272c7..440bc559 100644 --- a/dGame/dBehaviors/InterruptBehavior.h +++ b/dGame/dBehaviors/InterruptBehavior.h @@ -15,9 +15,9 @@ public: explicit InterruptBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/JetPackBehavior.cpp b/dGame/dBehaviors/JetPackBehavior.cpp index 7fcd78b0..8cfb87da 100644 --- a/dGame/dBehaviors/JetPackBehavior.cpp +++ b/dGame/dBehaviors/JetPackBehavior.cpp @@ -5,7 +5,7 @@ #include "Character.h" -void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void JetPackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); GameMessages::SendSetJetPackMode(entity, true, this->m_BypassChecks, this->m_EnableHover, this->m_effectId, this->m_Airspeed, this->m_MaxAirspeed, this->m_VerticalVelocity, this->m_WarningEffectID); @@ -33,7 +33,7 @@ void JetPackBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext bra } } -void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void JetPackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/JetPackBehavior.h b/dGame/dBehaviors/JetPackBehavior.h index 0cc6c399..bc82d5d2 100644 --- a/dGame/dBehaviors/JetPackBehavior.h +++ b/dGame/dBehaviors/JetPackBehavior.h @@ -18,11 +18,11 @@ public: explicit JetPackBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/KnockbackBehavior.cpp b/dGame/dBehaviors/KnockbackBehavior.cpp index d0f86597..4d7bf2ea 100644 --- a/dGame/dBehaviors/KnockbackBehavior.cpp +++ b/dGame/dBehaviors/KnockbackBehavior.cpp @@ -9,16 +9,16 @@ #include "Game.h" #include "Logger.h" -void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { bool unknown{}; - if (!bitStream->Read(unknown)) { - LOG("Unable to read unknown from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(unknown)) { + LOG("Unable to read unknown from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } -void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { bool blocked = false; auto* target = Game::entityManager->GetEntity(branch.target); @@ -31,7 +31,7 @@ void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b } } - bitStream->Write(blocked); + bitStream.Write(blocked); } void KnockbackBehavior::Load() { diff --git a/dGame/dBehaviors/KnockbackBehavior.h b/dGame/dBehaviors/KnockbackBehavior.h index c952bb41..89777a6d 100644 --- a/dGame/dBehaviors/KnockbackBehavior.h +++ b/dGame/dBehaviors/KnockbackBehavior.h @@ -17,9 +17,9 @@ public: explicit KnockbackBehavior(const uint32_t behaviorID) : Behavior(behaviorID) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/LootBuffBehavior.cpp b/dGame/dBehaviors/LootBuffBehavior.cpp index c7a6b36a..65b73422 100644 --- a/dGame/dBehaviors/LootBuffBehavior.cpp +++ b/dGame/dBehaviors/LootBuffBehavior.cpp @@ -1,6 +1,6 @@ #include "LootBuffBehavior.h" -void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto target = Game::entityManager->GetEntity(context->caster); if (!target) return; @@ -14,7 +14,7 @@ void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt } -void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/LootBuffBehavior.h b/dGame/dBehaviors/LootBuffBehavior.h index b6f700ca..dba82d75 100644 --- a/dGame/dBehaviors/LootBuffBehavior.h +++ b/dGame/dBehaviors/LootBuffBehavior.h @@ -20,9 +20,9 @@ public: explicit LootBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/MovementSwitchBehavior.cpp b/dGame/dBehaviors/MovementSwitchBehavior.cpp index cddeeea9..cc2d7b34 100644 --- a/dGame/dBehaviors/MovementSwitchBehavior.cpp +++ b/dGame/dBehaviors/MovementSwitchBehavior.cpp @@ -3,9 +3,9 @@ #include "Game.h" #include "Logger.h" -void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { uint32_t movementType{}; - if (!bitStream->Read(movementType)) { + if (!bitStream.Read(movementType)) { if (this->m_groundAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_jumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && this->m_fallingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY && @@ -15,7 +15,7 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* this->m_movingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) { return; } - LOG("Unable to read movementType from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + LOG("Unable to read movementType from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; diff --git a/dGame/dBehaviors/MovementSwitchBehavior.h b/dGame/dBehaviors/MovementSwitchBehavior.h index e6ff96f6..75b13b54 100644 --- a/dGame/dBehaviors/MovementSwitchBehavior.h +++ b/dGame/dBehaviors/MovementSwitchBehavior.h @@ -36,7 +36,7 @@ public: explicit MovementSwitchBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/NpcCombatSkillBehavior.cpp b/dGame/dBehaviors/NpcCombatSkillBehavior.cpp index 5a8d03cf..69a6ea9d 100644 --- a/dGame/dBehaviors/NpcCombatSkillBehavior.cpp +++ b/dGame/dBehaviors/NpcCombatSkillBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" -void NpcCombatSkillBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void NpcCombatSkillBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { context->skillTime = this->m_npcSkillTime; for (auto* behavior : this->m_behaviors) { diff --git a/dGame/dBehaviors/NpcCombatSkillBehavior.h b/dGame/dBehaviors/NpcCombatSkillBehavior.h index 19ff3483..07826f48 100644 --- a/dGame/dBehaviors/NpcCombatSkillBehavior.h +++ b/dGame/dBehaviors/NpcCombatSkillBehavior.h @@ -15,7 +15,7 @@ public: explicit NpcCombatSkillBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/OverTimeBehavior.cpp b/dGame/dBehaviors/OverTimeBehavior.cpp index f66a5253..5a42993f 100644 --- a/dGame/dBehaviors/OverTimeBehavior.cpp +++ b/dGame/dBehaviors/OverTimeBehavior.cpp @@ -11,7 +11,7 @@ #include "CDSkillBehaviorTable.h" -void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto originator = context->originator; auto* entity = Game::entityManager->GetEntity(originator); @@ -33,7 +33,7 @@ void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt } } -void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } diff --git a/dGame/dBehaviors/OverTimeBehavior.h b/dGame/dBehaviors/OverTimeBehavior.h index 73a07865..78d9388b 100644 --- a/dGame/dBehaviors/OverTimeBehavior.h +++ b/dGame/dBehaviors/OverTimeBehavior.h @@ -16,9 +16,9 @@ public: explicit OverTimeBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/PlayEffectBehavior.cpp b/dGame/dBehaviors/PlayEffectBehavior.cpp index acd606a9..451c52de 100644 --- a/dGame/dBehaviors/PlayEffectBehavior.cpp +++ b/dGame/dBehaviors/PlayEffectBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { // On managed behaviors this is handled by the client if (!context->unmanaged) return; @@ -13,7 +13,7 @@ void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit PlayFx(u"", target); } -void PlayEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PlayEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto& target = branch.target == LWOOBJID_EMPTY ? context->originator : branch.target; //PlayFx(u"", target); diff --git a/dGame/dBehaviors/PlayEffectBehavior.h b/dGame/dBehaviors/PlayEffectBehavior.h index 5ef49161..c112579b 100644 --- a/dGame/dBehaviors/PlayEffectBehavior.h +++ b/dGame/dBehaviors/PlayEffectBehavior.h @@ -10,9 +10,9 @@ public: explicit PlayEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.cpp b/dGame/dBehaviors/ProjectileAttackBehavior.cpp index 504afc69..3e5118f7 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.cpp +++ b/dGame/dBehaviors/ProjectileAttackBehavior.cpp @@ -8,11 +8,11 @@ #include "ObjectIDManager.h" #include "eObjectBits.h" -void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { LWOOBJID target{}; - if (!bitStream->Read(target)) { - LOG("Unable to read target from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(target)) { + LOG("Unable to read target from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -34,8 +34,8 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea if (m_useMouseposit && !branch.isSync) { NiPoint3 targetPosition = NiPoint3Constant::ZERO; - if (!bitStream->Read(targetPosition)) { - LOG("Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(targetPosition)) { + LOG("Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } @@ -45,8 +45,8 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea for (auto i = 0u; i < this->m_projectileCount; ++i) { LWOOBJID projectileId{}; - if (!bitStream->Read(projectileId)) { - LOG("Unable to read projectileId from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(projectileId)) { + LOG("Unable to read projectileId from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -58,8 +58,8 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea } } -void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { - bitStream->Write(branch.target); +void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { + bitStream.Write(branch.target); auto* entity = Game::entityManager->GetEntity(context->originator); @@ -110,7 +110,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt GeneralUtils::SetBit(id, eObjectBits::SPAWNED); - bitStream->Write(id); + bitStream.Write(id); auto eulerAngles = rotation.GetEulerAngles(); diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.h b/dGame/dBehaviors/ProjectileAttackBehavior.h index b307e66c..fee3a5c2 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.h +++ b/dGame/dBehaviors/ProjectileAttackBehavior.h @@ -32,9 +32,9 @@ public: explicit ProjectileAttackBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/PropertyTeleportBehavior.cpp b/dGame/dBehaviors/PropertyTeleportBehavior.cpp index 939568f6..7e9ecee0 100644 --- a/dGame/dBehaviors/PropertyTeleportBehavior.cpp +++ b/dGame/dBehaviors/PropertyTeleportBehavior.cpp @@ -11,7 +11,7 @@ #include "ZoneInstanceManager.h" #include "dZoneManager.h" -void PropertyTeleportBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PropertyTeleportBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* caster = Game::entityManager->GetEntity(context->caster); if (!caster) return; diff --git a/dGame/dBehaviors/PropertyTeleportBehavior.h b/dGame/dBehaviors/PropertyTeleportBehavior.h index 74eed03b..7dbec84c 100644 --- a/dGame/dBehaviors/PropertyTeleportBehavior.h +++ b/dGame/dBehaviors/PropertyTeleportBehavior.h @@ -11,7 +11,7 @@ public: explicit PropertyTeleportBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; diff --git a/dGame/dBehaviors/PullToPointBehavior.cpp b/dGame/dBehaviors/PullToPointBehavior.cpp index e18443f7..f776298f 100644 --- a/dGame/dBehaviors/PullToPointBehavior.cpp +++ b/dGame/dBehaviors/PullToPointBehavior.cpp @@ -5,7 +5,7 @@ #include "EntityManager.h" #include "MovementAIComponent.h" -void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(context->originator); auto* target = Game::entityManager->GetEntity(branch.target); @@ -25,7 +25,7 @@ void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi movement->PullToPoint(position); } -void PullToPointBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void PullToPointBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/PullToPointBehavior.h b/dGame/dBehaviors/PullToPointBehavior.h index d448ad8d..83c8a944 100644 --- a/dGame/dBehaviors/PullToPointBehavior.h +++ b/dGame/dBehaviors/PullToPointBehavior.h @@ -12,9 +12,9 @@ public: explicit PullToPointBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/RemoveBuffBehavior.cpp b/dGame/dBehaviors/RemoveBuffBehavior.cpp index c6d2c9c9..ec2c15d4 100644 --- a/dGame/dBehaviors/RemoveBuffBehavior.cpp +++ b/dGame/dBehaviors/RemoveBuffBehavior.cpp @@ -5,7 +5,7 @@ #include "EntityManager.h" #include "BuffComponent.h" -void RemoveBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void RemoveBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(context->caster); if (!entity) return; diff --git a/dGame/dBehaviors/RemoveBuffBehavior.h b/dGame/dBehaviors/RemoveBuffBehavior.h index f2d8547b..5e08ea7f 100644 --- a/dGame/dBehaviors/RemoveBuffBehavior.h +++ b/dGame/dBehaviors/RemoveBuffBehavior.h @@ -12,7 +12,7 @@ public: explicit RemoveBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; diff --git a/dGame/dBehaviors/RepairBehavior.cpp b/dGame/dBehaviors/RepairBehavior.cpp index d0ce3fe8..95b8ed89 100644 --- a/dGame/dBehaviors/RepairBehavior.cpp +++ b/dGame/dBehaviors/RepairBehavior.cpp @@ -7,7 +7,7 @@ #include "Game.h" #include "eReplicaComponentType.h" -void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); if (entity == nullptr) { @@ -27,7 +27,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str destroyable->Repair(this->m_armor); } -void RepairBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) { +void RepairBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, const BehaviorBranchContext branch) { Handle(context, bit_stream, branch); } diff --git a/dGame/dBehaviors/RepairBehavior.h b/dGame/dBehaviors/RepairBehavior.h index 8d2f14e4..61b96543 100644 --- a/dGame/dBehaviors/RepairBehavior.h +++ b/dGame/dBehaviors/RepairBehavior.h @@ -13,9 +13,9 @@ public: explicit RepairBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SkillCastFailedBehavior.cpp b/dGame/dBehaviors/SkillCastFailedBehavior.cpp index a663e709..a9babe61 100644 --- a/dGame/dBehaviors/SkillCastFailedBehavior.cpp +++ b/dGame/dBehaviors/SkillCastFailedBehavior.cpp @@ -3,11 +3,11 @@ #include "BehaviorContext.h" #include "BehaviorBranchContext.h" -void SkillCastFailedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SkillCastFailedBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->failed = true; } -void SkillCastFailedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SkillCastFailedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { context->failed = true; } diff --git a/dGame/dBehaviors/SkillCastFailedBehavior.h b/dGame/dBehaviors/SkillCastFailedBehavior.h index 5359cb42..5ccb12b2 100644 --- a/dGame/dBehaviors/SkillCastFailedBehavior.h +++ b/dGame/dBehaviors/SkillCastFailedBehavior.h @@ -11,9 +11,9 @@ public: explicit SkillCastFailedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SkillEventBehavior.cpp b/dGame/dBehaviors/SkillEventBehavior.cpp index 4205c28b..e007fbe2 100644 --- a/dGame/dBehaviors/SkillEventBehavior.cpp +++ b/dGame/dBehaviors/SkillEventBehavior.cpp @@ -4,7 +4,7 @@ #include "EntityManager.h" #include "CppScripts.h" -void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); auto* caster = Game::entityManager->GetEntity(context->originator); @@ -16,7 +16,7 @@ void SkillEventBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit } void -SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +SkillEventBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); auto* caster = Game::entityManager->GetEntity(context->originator); diff --git a/dGame/dBehaviors/SkillEventBehavior.h b/dGame/dBehaviors/SkillEventBehavior.h index 540f6d4a..6a334d90 100644 --- a/dGame/dBehaviors/SkillEventBehavior.h +++ b/dGame/dBehaviors/SkillEventBehavior.h @@ -9,7 +9,7 @@ public: explicit SkillEventBehavior(const uint32_t behaviorID) : Behavior(behaviorID) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; }; diff --git a/dGame/dBehaviors/SpawnBehavior.cpp b/dGame/dBehaviors/SpawnBehavior.cpp index dd45fb1b..e033d368 100644 --- a/dGame/dBehaviors/SpawnBehavior.cpp +++ b/dGame/dBehaviors/SpawnBehavior.cpp @@ -11,7 +11,7 @@ #include "EntityInfo.h" #include "eReplicaComponentType.h" -void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* origin = Game::entityManager->GetEntity(context->originator); if (origin == nullptr) { @@ -74,7 +74,7 @@ void SpawnBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea }); } -void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpawnBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/SpawnBehavior.h b/dGame/dBehaviors/SpawnBehavior.h index 875e0a2b..fad57604 100644 --- a/dGame/dBehaviors/SpawnBehavior.h +++ b/dGame/dBehaviors/SpawnBehavior.h @@ -13,9 +13,9 @@ public: explicit SpawnBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) override; diff --git a/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp b/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp index 514ae27a..a76ce980 100644 --- a/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp +++ b/dGame/dBehaviors/SpawnQuickbuildBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorBranchContext.h" #include "BehaviorContext.h" -void SpawnQuickbuildBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpawnQuickbuildBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { } void SpawnQuickbuildBehavior::Load() { diff --git a/dGame/dBehaviors/SpawnQuickbuildBehavior.h b/dGame/dBehaviors/SpawnQuickbuildBehavior.h index 653c60e8..a5700cc5 100644 --- a/dGame/dBehaviors/SpawnQuickbuildBehavior.h +++ b/dGame/dBehaviors/SpawnQuickbuildBehavior.h @@ -11,7 +11,7 @@ public: explicit SpawnQuickbuildBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SpeedBehavior.cpp b/dGame/dBehaviors/SpeedBehavior.cpp index f21fda7e..c9c99bed 100644 --- a/dGame/dBehaviors/SpeedBehavior.cpp +++ b/dGame/dBehaviors/SpeedBehavior.cpp @@ -6,7 +6,7 @@ #include "Logger.h" -void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { if (m_AffectsCaster) branch.target = context->caster; auto* target = Game::entityManager->GetEntity(branch.target); @@ -25,7 +25,7 @@ void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea } } -void SpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { Handle(context, bitStream, branch); } diff --git a/dGame/dBehaviors/SpeedBehavior.h b/dGame/dBehaviors/SpeedBehavior.h index 88b85820..f122fde7 100644 --- a/dGame/dBehaviors/SpeedBehavior.h +++ b/dGame/dBehaviors/SpeedBehavior.h @@ -11,9 +11,9 @@ public: explicit SpeedBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/StartBehavior.cpp b/dGame/dBehaviors/StartBehavior.cpp index 2bcaf325..cb23e31f 100644 --- a/dGame/dBehaviors/StartBehavior.cpp +++ b/dGame/dBehaviors/StartBehavior.cpp @@ -1,13 +1,13 @@ #include "StartBehavior.h" #include "BehaviorBranchContext.h" -void StartBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void StartBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.start = this->m_behaviorId; this->m_action->Handle(context, bit_stream, branch); } -void StartBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void StartBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.start = this->m_behaviorId; this->m_action->Calculate(context, bit_stream, branch); diff --git a/dGame/dBehaviors/StartBehavior.h b/dGame/dBehaviors/StartBehavior.h index 384fe64a..7d708d0a 100644 --- a/dGame/dBehaviors/StartBehavior.h +++ b/dGame/dBehaviors/StartBehavior.h @@ -13,9 +13,9 @@ public: explicit StartBehavior(const uint32_t behaviorID) : Behavior(behaviorID) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/StunBehavior.cpp b/dGame/dBehaviors/StunBehavior.cpp index 02144f69..bec6f409 100644 --- a/dGame/dBehaviors/StunBehavior.cpp +++ b/dGame/dBehaviors/StunBehavior.cpp @@ -10,14 +10,14 @@ #include "eReplicaComponentType.h" -void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { if (this->m_stunCaster || branch.target == context->originator) { return; } bool blocked{}; - if (!bitStream->Read(blocked)) { - LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(blocked)) { + LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -42,7 +42,7 @@ void StunBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream combatAiComponent->Stun(branch.duration); } -void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { if (this->m_stunCaster || branch.target == context->originator) { auto* self = Game::entityManager->GetEntity(context->originator); @@ -79,7 +79,7 @@ void StunBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStr } } - bitStream->Write(blocked); + bitStream.Write(blocked); if (target == nullptr) { LOG("Failed to find target (%llu)!", branch.target); diff --git a/dGame/dBehaviors/StunBehavior.h b/dGame/dBehaviors/StunBehavior.h index f4851b47..18ca31f4 100644 --- a/dGame/dBehaviors/StunBehavior.h +++ b/dGame/dBehaviors/StunBehavior.h @@ -12,9 +12,9 @@ public: explicit StunBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SwitchBehavior.cpp b/dGame/dBehaviors/SwitchBehavior.cpp index db04650d..88f2d85a 100644 --- a/dGame/dBehaviors/SwitchBehavior.cpp +++ b/dGame/dBehaviors/SwitchBehavior.cpp @@ -6,12 +6,12 @@ #include "BehaviorContext.h" #include "BuffComponent.h" -void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) { +void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) { auto state = true; if (this->m_imagination > 0 || !this->m_isEnemyFaction) { - if (!bitStream->Read(state)) { - LOG("Unable to read state from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(state)) { + LOG("Unable to read state from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; } @@ -37,7 +37,7 @@ void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre } } -void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto state = true; if (this->m_imagination > 0 || !this->m_isEnemyFaction) { @@ -53,7 +53,7 @@ void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS } } - bitStream->Write(state); + bitStream.Write(state); } if (state) { diff --git a/dGame/dBehaviors/SwitchBehavior.h b/dGame/dBehaviors/SwitchBehavior.h index 5e40d659..b7fcb653 100644 --- a/dGame/dBehaviors/SwitchBehavior.h +++ b/dGame/dBehaviors/SwitchBehavior.h @@ -21,9 +21,9 @@ public: explicit SwitchBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/SwitchMultipleBehavior.cpp b/dGame/dBehaviors/SwitchMultipleBehavior.cpp index faaa0d23..92c9a8de 100644 --- a/dGame/dBehaviors/SwitchMultipleBehavior.cpp +++ b/dGame/dBehaviors/SwitchMultipleBehavior.cpp @@ -9,11 +9,11 @@ #include "EntityManager.h" -void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { float value{}; - if (!bitStream->Read(value)) { - LOG("Unable to read value from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(value)) { + LOG("Unable to read value from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -32,7 +32,7 @@ void SwitchMultipleBehavior::Handle(BehaviorContext* context, RakNet::BitStream* behavior->Handle(context, bitStream, branch); } -void SwitchMultipleBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void SwitchMultipleBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { // TODO } diff --git a/dGame/dBehaviors/SwitchMultipleBehavior.h b/dGame/dBehaviors/SwitchMultipleBehavior.h index 1e3dfe64..9f9754b8 100644 --- a/dGame/dBehaviors/SwitchMultipleBehavior.h +++ b/dGame/dBehaviors/SwitchMultipleBehavior.h @@ -15,9 +15,9 @@ public: explicit SwitchMultipleBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/TacArcBehavior.cpp b/dGame/dBehaviors/TacArcBehavior.cpp index 0cea8213..cb3430c8 100644 --- a/dGame/dBehaviors/TacArcBehavior.cpp +++ b/dGame/dBehaviors/TacArcBehavior.cpp @@ -11,7 +11,7 @@ #include -void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { std::vector targets = {}; if (this->m_usePickedTarget && branch.target != LWOOBJID_EMPTY) { @@ -28,16 +28,16 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre } bool hasTargets = false; - if (!bitStream->Read(hasTargets)) { - LOG("Unable to read hasTargets from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(hasTargets)) { + LOG("Unable to read hasTargets from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; if (this->m_checkEnv) { bool blocked = false; - if (!bitStream->Read(blocked)) { - LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(blocked)) { + LOG("Unable to read blocked from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -49,8 +49,8 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre if (hasTargets) { uint32_t count = 0; - if (!bitStream->Read(count)) { - LOG("Unable to read count from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(count)) { + LOG("Unable to read count from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -62,8 +62,8 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre for (auto i = 0u; i < count; i++) { LWOOBJID id{}; - if (!bitStream->Read(id)) { - LOG("Unable to read id from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits()); + if (!bitStream.Read(id)) { + LOG("Unable to read id from bitStream, aborting Handle! %i", bitStream.GetNumberOfUnreadBits()); return; }; @@ -82,7 +82,7 @@ void TacArcBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStre } else this->m_missAction->Handle(context, bitStream, branch); } -void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* self = Game::entityManager->GetEntity(context->originator); if (self == nullptr) { LOG("Invalid self for (%llu)!", context->originator); @@ -155,11 +155,11 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS }); const auto hit = !targets.empty(); - bitStream->Write(hit); + bitStream.Write(hit); if (this->m_checkEnv) { const auto blocked = false; // TODO - bitStream->Write(blocked); + bitStream.Write(blocked); } if (hit) { @@ -168,9 +168,9 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS context->foundTarget = true; // We want to continue with this behavior const auto count = static_cast(targets.size()); - bitStream->Write(count); + bitStream.Write(count); for (auto* target : targets) { - bitStream->Write(target->GetObjectID()); + bitStream.Write(target->GetObjectID()); } for (auto* target : targets) { diff --git a/dGame/dBehaviors/TacArcBehavior.h b/dGame/dBehaviors/TacArcBehavior.h index d9345272..b331e6fc 100644 --- a/dGame/dBehaviors/TacArcBehavior.h +++ b/dGame/dBehaviors/TacArcBehavior.h @@ -7,8 +7,8 @@ class TacArcBehavior final : public Behavior { public: explicit TacArcBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; private: float m_maxRange; diff --git a/dGame/dBehaviors/TargetCasterBehavior.cpp b/dGame/dBehaviors/TargetCasterBehavior.cpp index ff9cfc03..1e2f82f0 100644 --- a/dGame/dBehaviors/TargetCasterBehavior.cpp +++ b/dGame/dBehaviors/TargetCasterBehavior.cpp @@ -3,7 +3,7 @@ #include "BehaviorContext.h" -void TargetCasterBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void TargetCasterBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.target = context->caster; this->m_action->Handle(context, bit_stream, branch); @@ -13,7 +13,7 @@ void TargetCasterBehavior::UnCast(BehaviorContext* context, BehaviorBranchContex this->m_action->UnCast(context, branch); } -void TargetCasterBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) { +void TargetCasterBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) { branch.target = context->caster; this->m_action->Calculate(context, bit_stream, branch); diff --git a/dGame/dBehaviors/TargetCasterBehavior.h b/dGame/dBehaviors/TargetCasterBehavior.h index 387d2732..2713a1ce 100644 --- a/dGame/dBehaviors/TargetCasterBehavior.h +++ b/dGame/dBehaviors/TargetCasterBehavior.h @@ -13,11 +13,11 @@ public: explicit TargetCasterBehavior(const uint32_t behavior_id) : Behavior(behavior_id) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bit_stream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/TauntBehavior.cpp b/dGame/dBehaviors/TauntBehavior.cpp index 2e9f2168..43117ee3 100644 --- a/dGame/dBehaviors/TauntBehavior.cpp +++ b/dGame/dBehaviors/TauntBehavior.cpp @@ -6,7 +6,7 @@ #include "Logger.h" -void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { @@ -22,7 +22,7 @@ void TauntBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea } } -void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void TauntBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* target = Game::entityManager->GetEntity(branch.target); if (target == nullptr) { diff --git a/dGame/dBehaviors/TauntBehavior.h b/dGame/dBehaviors/TauntBehavior.h index 3ae7db9d..b5b3196e 100644 --- a/dGame/dBehaviors/TauntBehavior.h +++ b/dGame/dBehaviors/TauntBehavior.h @@ -14,9 +14,9 @@ public: explicit TauntBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dBehaviors/VentureVisionBehavior.cpp b/dGame/dBehaviors/VentureVisionBehavior.cpp index 397bdebf..3aa3aac7 100644 --- a/dGame/dBehaviors/VentureVisionBehavior.cpp +++ b/dGame/dBehaviors/VentureVisionBehavior.cpp @@ -3,7 +3,7 @@ #include "CharacterComponent.h" #include "BehaviorContext.h" -void VentureVisionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void VentureVisionBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { const auto targetEntity = Game::entityManager->GetEntity(branch.target); diff --git a/dGame/dBehaviors/VentureVisionBehavior.h b/dGame/dBehaviors/VentureVisionBehavior.h index 72758949..ee89dae9 100644 --- a/dGame/dBehaviors/VentureVisionBehavior.h +++ b/dGame/dBehaviors/VentureVisionBehavior.h @@ -28,7 +28,7 @@ public: explicit VentureVisionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void UnCast(BehaviorContext* context, BehaviorBranchContext branch) override; diff --git a/dGame/dBehaviors/VerifyBehavior.cpp b/dGame/dBehaviors/VerifyBehavior.cpp index 2056f146..c7ede52f 100644 --- a/dGame/dBehaviors/VerifyBehavior.cpp +++ b/dGame/dBehaviors/VerifyBehavior.cpp @@ -7,7 +7,7 @@ #include "Logger.h" -void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) { +void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) { auto* entity = Game::entityManager->GetEntity(branch.target); auto success = true; @@ -33,12 +33,12 @@ void VerifyBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS } if (branch.target != LWOOBJID_EMPTY && branch.target != context->originator) { - bitStream->Write(success); + bitStream.Write(success); if (success) { - bitStream->Write(1); - bitStream->Write0(); - bitStream->Write0(); + bitStream.Write(1); + bitStream.Write0(); + bitStream.Write0(); } } diff --git a/dGame/dBehaviors/VerifyBehavior.h b/dGame/dBehaviors/VerifyBehavior.h index a91ff7cf..ed32111d 100644 --- a/dGame/dBehaviors/VerifyBehavior.h +++ b/dGame/dBehaviors/VerifyBehavior.h @@ -19,7 +19,7 @@ public: explicit VerifyBehavior(const uint32_t behaviorId) : Behavior(behaviorId) { } - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) override; void Load() override; }; diff --git a/dGame/dComponents/ActivityComponent.cpp b/dGame/dComponents/ActivityComponent.cpp index 49ca4faf..ce82abe0 100644 --- a/dGame/dComponents/ActivityComponent.cpp +++ b/dGame/dComponents/ActivityComponent.cpp @@ -90,15 +90,15 @@ void ActivityComponent::LoadActivityData(const int32_t activityId) { } } -void ActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyActivityInfo); +void ActivityComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyActivityInfo); if (m_DirtyActivityInfo) { - outBitStream->Write(m_ActivityPlayers.size()); + outBitStream.Write(m_ActivityPlayers.size()); if (!m_ActivityPlayers.empty()) { for (const auto& activityPlayer : m_ActivityPlayers) { - outBitStream->Write(activityPlayer->playerID); + outBitStream.Write(activityPlayer->playerID); for (const auto& activityValue : activityPlayer->values) { - outBitStream->Write(activityValue); + outBitStream.Write(activityValue); } } } diff --git a/dGame/dComponents/ActivityComponent.h b/dGame/dComponents/ActivityComponent.h index de63b343..296c6ccc 100644 --- a/dGame/dComponents/ActivityComponent.h +++ b/dGame/dComponents/ActivityComponent.h @@ -155,7 +155,7 @@ public: void LoadActivityData(const int32_t activityId); void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Makes some entity join the minigame, if it's a lobbied one, the entity will be placed in the lobby diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index 17183409..d40cf73e 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -520,11 +520,11 @@ bool BaseCombatAIComponent::IsMech() { } -void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate); +void BaseCombatAIComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyStateOrTarget || bIsInitialUpdate); if (m_DirtyStateOrTarget || bIsInitialUpdate) { - outBitStream->Write(m_State); - outBitStream->Write(m_Target); + outBitStream.Write(m_State); + outBitStream.Write(m_Target); m_DirtyStateOrTarget = false; } } diff --git a/dGame/dComponents/BaseCombatAIComponent.h b/dGame/dComponents/BaseCombatAIComponent.h index f00910e7..89985d64 100644 --- a/dGame/dComponents/BaseCombatAIComponent.h +++ b/dGame/dComponents/BaseCombatAIComponent.h @@ -53,7 +53,7 @@ public: ~BaseCombatAIComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Get the current behavioral state of the enemy diff --git a/dGame/dComponents/BouncerComponent.cpp b/dGame/dComponents/BouncerComponent.cpp index 78ee3637..d1c63bf4 100644 --- a/dGame/dComponents/BouncerComponent.cpp +++ b/dGame/dComponents/BouncerComponent.cpp @@ -22,10 +22,10 @@ BouncerComponent::BouncerComponent(Entity* parent) : Component(parent) { BouncerComponent::~BouncerComponent() { } -void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_PetEnabled); +void BouncerComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_PetEnabled); if (m_PetEnabled) { - outBitStream->Write(m_PetBouncerEnabled); + outBitStream.Write(m_PetBouncerEnabled); } } diff --git a/dGame/dComponents/BouncerComponent.h b/dGame/dComponents/BouncerComponent.h index b41881c6..441ba58e 100644 --- a/dGame/dComponents/BouncerComponent.h +++ b/dGame/dComponents/BouncerComponent.h @@ -17,7 +17,7 @@ public: BouncerComponent(Entity* parentEntity); ~BouncerComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; Entity* GetParentEntity() const; diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index 4122a800..8b76e423 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -32,24 +32,24 @@ BuffComponent::BuffComponent(Entity* parent) : Component(parent) { BuffComponent::~BuffComponent() { } -void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void BuffComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (!bIsInitialUpdate) return; - outBitStream->Write(!m_Buffs.empty()); + outBitStream.Write(!m_Buffs.empty()); if (!m_Buffs.empty()) { - outBitStream->Write(m_Buffs.size()); + outBitStream.Write(m_Buffs.size()); for (const auto& [id, buff] : m_Buffs) { - outBitStream->Write(id); - outBitStream->Write(buff.time != 0.0f); - if (buff.time != 0.0f) outBitStream->Write(buff.time * 1000.0f); - outBitStream->Write(buff.cancelOnDeath); - outBitStream->Write(buff.cancelOnZone); - outBitStream->Write(buff.cancelOnDamaged); - outBitStream->Write(buff.cancelOnRemoveBuff); - outBitStream->Write(buff.cancelOnUi); - outBitStream->Write(buff.cancelOnLogout); - outBitStream->Write(buff.cancelOnUnequip); - outBitStream->Write0(); // Cancel on Damage Absorb Ran Out. Generally false from what I can tell + outBitStream.Write(id); + outBitStream.Write(buff.time != 0.0f); + if (buff.time != 0.0f) outBitStream.Write(buff.time * 1000.0f); + outBitStream.Write(buff.cancelOnDeath); + outBitStream.Write(buff.cancelOnZone); + outBitStream.Write(buff.cancelOnDamaged); + outBitStream.Write(buff.cancelOnRemoveBuff); + outBitStream.Write(buff.cancelOnUi); + outBitStream.Write(buff.cancelOnLogout); + outBitStream.Write(buff.cancelOnUnequip); + outBitStream.Write0(); // Cancel on Damage Absorb Ran Out. Generally false from what I can tell auto* team = TeamManager::Instance()->GetTeam(buff.source); bool addedByTeammate = false; @@ -57,15 +57,15 @@ void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUp addedByTeammate = std::count(team->members.begin(), team->members.end(), m_Parent->GetObjectID()) > 0; } - outBitStream->Write(addedByTeammate); // Added by teammate. If source is in the same team as the target, this is true. Otherwise, false. - outBitStream->Write(buff.applyOnTeammates); - if (addedByTeammate) outBitStream->Write(buff.source); + outBitStream.Write(addedByTeammate); // Added by teammate. If source is in the same team as the target, this is true. Otherwise, false. + outBitStream.Write(buff.applyOnTeammates); + if (addedByTeammate) outBitStream.Write(buff.source); - outBitStream->Write(buff.refCount); + outBitStream.Write(buff.refCount); } } - outBitStream->Write0(); // something to do with immunity buffs? + outBitStream.Write0(); // something to do with immunity buffs? } void BuffComponent::Update(float deltaTime) { diff --git a/dGame/dComponents/BuffComponent.h b/dGame/dComponents/BuffComponent.h index f509faa2..df3c6a78 100644 --- a/dGame/dComponents/BuffComponent.h +++ b/dGame/dComponents/BuffComponent.h @@ -61,7 +61,7 @@ public: void UpdateXml(tinyxml2::XMLDocument* doc) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; diff --git a/dGame/dComponents/CharacterComponent.cpp b/dGame/dComponents/CharacterComponent.cpp index e4e2ba4b..3eafd924 100644 --- a/dGame/dComponents/CharacterComponent.cpp +++ b/dGame/dComponents/CharacterComponent.cpp @@ -78,94 +78,94 @@ bool CharacterComponent::LandingAnimDisabled(int zoneID) { CharacterComponent::~CharacterComponent() { } -void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void CharacterComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write(m_ClaimCodes[0] != 0); - if (m_ClaimCodes[0] != 0) outBitStream->Write(m_ClaimCodes[0]); - outBitStream->Write(m_ClaimCodes[1] != 0); - if (m_ClaimCodes[1] != 0) outBitStream->Write(m_ClaimCodes[1]); - outBitStream->Write(m_ClaimCodes[2] != 0); - if (m_ClaimCodes[2] != 0) outBitStream->Write(m_ClaimCodes[2]); - outBitStream->Write(m_ClaimCodes[3] != 0); - if (m_ClaimCodes[3] != 0) outBitStream->Write(m_ClaimCodes[3]); + outBitStream.Write(m_ClaimCodes[0] != 0); + if (m_ClaimCodes[0] != 0) outBitStream.Write(m_ClaimCodes[0]); + outBitStream.Write(m_ClaimCodes[1] != 0); + if (m_ClaimCodes[1] != 0) outBitStream.Write(m_ClaimCodes[1]); + outBitStream.Write(m_ClaimCodes[2] != 0); + if (m_ClaimCodes[2] != 0) outBitStream.Write(m_ClaimCodes[2]); + outBitStream.Write(m_ClaimCodes[3] != 0); + if (m_ClaimCodes[3] != 0) outBitStream.Write(m_ClaimCodes[3]); - outBitStream->Write(m_Character->GetHairColor()); - outBitStream->Write(m_Character->GetHairStyle()); - outBitStream->Write(0); //Default "head" - outBitStream->Write(m_Character->GetShirtColor()); - outBitStream->Write(m_Character->GetPantsColor()); - outBitStream->Write(m_Character->GetShirtStyle()); - outBitStream->Write(0); //Default "head color" - outBitStream->Write(m_Character->GetEyebrows()); - outBitStream->Write(m_Character->GetEyes()); - outBitStream->Write(m_Character->GetMouth()); - outBitStream->Write(0); //AccountID, trying out if 0 works. - outBitStream->Write(m_Character->GetLastLogin()); //Last login - outBitStream->Write(0); //"prop mod last display time" - outBitStream->Write(m_Uscore); //u-score - outBitStream->Write0(); //Not free-to-play (disabled in DLU) + outBitStream.Write(m_Character->GetHairColor()); + outBitStream.Write(m_Character->GetHairStyle()); + outBitStream.Write(0); //Default "head" + outBitStream.Write(m_Character->GetShirtColor()); + outBitStream.Write(m_Character->GetPantsColor()); + outBitStream.Write(m_Character->GetShirtStyle()); + outBitStream.Write(0); //Default "head color" + outBitStream.Write(m_Character->GetEyebrows()); + outBitStream.Write(m_Character->GetEyes()); + outBitStream.Write(m_Character->GetMouth()); + outBitStream.Write(0); //AccountID, trying out if 0 works. + outBitStream.Write(m_Character->GetLastLogin()); //Last login + outBitStream.Write(0); //"prop mod last display time" + outBitStream.Write(m_Uscore); //u-score + outBitStream.Write0(); //Not free-to-play (disabled in DLU) //Stats: - outBitStream->Write(m_CurrencyCollected); - outBitStream->Write(m_BricksCollected); - outBitStream->Write(m_SmashablesSmashed); - outBitStream->Write(m_QuickBuildsCompleted); - outBitStream->Write(m_EnemiesSmashed); - outBitStream->Write(m_RocketsUsed); - outBitStream->Write(m_MissionsCompleted); - outBitStream->Write(m_PetsTamed); - outBitStream->Write(m_ImaginationPowerUpsCollected); - outBitStream->Write(m_LifePowerUpsCollected); - outBitStream->Write(m_ArmorPowerUpsCollected); - outBitStream->Write(m_MetersTraveled); - outBitStream->Write(m_TimesSmashed); - outBitStream->Write(m_TotalDamageTaken); - outBitStream->Write(m_TotalDamageHealed); - outBitStream->Write(m_TotalArmorRepaired); - outBitStream->Write(m_TotalImaginationRestored); - outBitStream->Write(m_TotalImaginationUsed); - outBitStream->Write(m_DistanceDriven); - outBitStream->Write(m_TimeAirborneInCar); - outBitStream->Write(m_RacingImaginationPowerUpsCollected); - outBitStream->Write(m_RacingImaginationCratesSmashed); - outBitStream->Write(m_RacingCarBoostsActivated); - outBitStream->Write(m_RacingTimesWrecked); - outBitStream->Write(m_RacingSmashablesSmashed); - outBitStream->Write(m_RacesFinished); - outBitStream->Write(m_FirstPlaceRaceFinishes); + outBitStream.Write(m_CurrencyCollected); + outBitStream.Write(m_BricksCollected); + outBitStream.Write(m_SmashablesSmashed); + outBitStream.Write(m_QuickBuildsCompleted); + outBitStream.Write(m_EnemiesSmashed); + outBitStream.Write(m_RocketsUsed); + outBitStream.Write(m_MissionsCompleted); + outBitStream.Write(m_PetsTamed); + outBitStream.Write(m_ImaginationPowerUpsCollected); + outBitStream.Write(m_LifePowerUpsCollected); + outBitStream.Write(m_ArmorPowerUpsCollected); + outBitStream.Write(m_MetersTraveled); + outBitStream.Write(m_TimesSmashed); + outBitStream.Write(m_TotalDamageTaken); + outBitStream.Write(m_TotalDamageHealed); + outBitStream.Write(m_TotalArmorRepaired); + outBitStream.Write(m_TotalImaginationRestored); + outBitStream.Write(m_TotalImaginationUsed); + outBitStream.Write(m_DistanceDriven); + outBitStream.Write(m_TimeAirborneInCar); + outBitStream.Write(m_RacingImaginationPowerUpsCollected); + outBitStream.Write(m_RacingImaginationCratesSmashed); + outBitStream.Write(m_RacingCarBoostsActivated); + outBitStream.Write(m_RacingTimesWrecked); + outBitStream.Write(m_RacingSmashablesSmashed); + outBitStream.Write(m_RacesFinished); + outBitStream.Write(m_FirstPlaceRaceFinishes); - outBitStream->Write0(); - outBitStream->Write(m_IsLanding); + outBitStream.Write0(); + outBitStream.Write(m_IsLanding); if (m_IsLanding) { - outBitStream->Write(m_LastRocketConfig.size()); + outBitStream.Write(m_LastRocketConfig.size()); for (uint16_t character : m_LastRocketConfig) { - outBitStream->Write(character); + outBitStream.Write(character); } } } - outBitStream->Write(m_DirtyGMInfo); + outBitStream.Write(m_DirtyGMInfo); if (m_DirtyGMInfo) { - outBitStream->Write(m_PvpEnabled); - outBitStream->Write(m_IsGM); - outBitStream->Write(m_GMLevel); - outBitStream->Write(m_EditorEnabled); - outBitStream->Write(m_EditorLevel); + outBitStream.Write(m_PvpEnabled); + outBitStream.Write(m_IsGM); + outBitStream.Write(m_GMLevel); + outBitStream.Write(m_EditorEnabled); + outBitStream.Write(m_EditorLevel); } - outBitStream->Write(m_DirtyCurrentActivity); - if (m_DirtyCurrentActivity) outBitStream->Write(m_CurrentActivity); + outBitStream.Write(m_DirtyCurrentActivity); + if (m_DirtyCurrentActivity) outBitStream.Write(m_CurrentActivity); - outBitStream->Write(m_DirtySocialInfo); + outBitStream.Write(m_DirtySocialInfo); if (m_DirtySocialInfo) { - outBitStream->Write(m_GuildID); - outBitStream->Write(m_GuildName.size()); + outBitStream.Write(m_GuildID); + outBitStream.Write(m_GuildName.size()); if (!m_GuildName.empty()) - outBitStream->WriteBits(reinterpret_cast(m_GuildName.c_str()), static_cast(m_GuildName.size()) * sizeof(wchar_t) * 8); + outBitStream.WriteBits(reinterpret_cast(m_GuildName.c_str()), static_cast(m_GuildName.size()) * sizeof(wchar_t) * 8); - outBitStream->Write(m_IsLEGOClubMember); - outBitStream->Write(m_CountryCode); + outBitStream.Write(m_IsLEGOClubMember); + outBitStream.Write(m_CountryCode); } } diff --git a/dGame/dComponents/CharacterComponent.h b/dGame/dComponents/CharacterComponent.h index 01c26f9a..797347ed 100644 --- a/dGame/dComponents/CharacterComponent.h +++ b/dGame/dComponents/CharacterComponent.h @@ -72,7 +72,7 @@ public: void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Updates the rocket configuration using a LOT string separated by commas diff --git a/dGame/dComponents/CollectibleComponent.cpp b/dGame/dComponents/CollectibleComponent.cpp index 99fcc681..f6ba25b2 100644 --- a/dGame/dComponents/CollectibleComponent.cpp +++ b/dGame/dComponents/CollectibleComponent.cpp @@ -1,5 +1,5 @@ #include "CollectibleComponent.h" -void CollectibleComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write(GetCollectibleId()); +void CollectibleComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write(GetCollectibleId()); } diff --git a/dGame/dComponents/CollectibleComponent.h b/dGame/dComponents/CollectibleComponent.h index 10a23293..5ecfb97e 100644 --- a/dGame/dComponents/CollectibleComponent.h +++ b/dGame/dComponents/CollectibleComponent.h @@ -10,7 +10,7 @@ public: CollectibleComponent(Entity* parentEntity, int32_t collectibleId) : Component(parentEntity), m_CollectibleId(collectibleId) {} int16_t GetCollectibleId() const { return m_CollectibleId; } - void Serialize(RakNet::BitStream* outBitStream, bool isConstruction) override; + void Serialize(RakNet::BitStream& outBitStream, bool isConstruction) override; private: int16_t m_CollectibleId = 0; }; diff --git a/dGame/dComponents/Component.cpp b/dGame/dComponents/Component.cpp index 1136456c..705c44a7 100644 --- a/dGame/dComponents/Component.cpp +++ b/dGame/dComponents/Component.cpp @@ -29,6 +29,6 @@ void Component::LoadFromXml(tinyxml2::XMLDocument* doc) { } -void Component::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { +void Component::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { } diff --git a/dGame/dComponents/Component.h b/dGame/dComponents/Component.h index 70f30f76..062924f7 100644 --- a/dGame/dComponents/Component.h +++ b/dGame/dComponents/Component.h @@ -42,7 +42,7 @@ public: */ virtual void LoadFromXml(tinyxml2::XMLDocument* doc); - virtual void Serialize(RakNet::BitStream* outBitStream, bool isConstruction); + virtual void Serialize(RakNet::BitStream& outBitStream, bool isConstruction); protected: diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index be5227a0..daa14ac3 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -71,89 +71,89 @@ void ControllablePhysicsComponent::Update(float deltaTime) { } -void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ControllablePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { //If this is a creation, then we assume the position is dirty, even when it isn't. //This is because new clients will still need to receive the position. //if (bIsInitialUpdate) m_DirtyPosition = true; if (bIsInitialUpdate) { - outBitStream->Write(m_InJetpackMode); + outBitStream.Write(m_InJetpackMode); if (m_InJetpackMode) { - outBitStream->Write(m_JetpackEffectID); - outBitStream->Write(m_JetpackFlying); - outBitStream->Write(m_JetpackBypassChecks); + outBitStream.Write(m_JetpackEffectID); + outBitStream.Write(m_JetpackFlying); + outBitStream.Write(m_JetpackBypassChecks); } - outBitStream->Write1(); // always write these on construction - outBitStream->Write(m_ImmuneToStunMoveCount); - outBitStream->Write(m_ImmuneToStunJumpCount); - outBitStream->Write(m_ImmuneToStunTurnCount); - outBitStream->Write(m_ImmuneToStunAttackCount); - outBitStream->Write(m_ImmuneToStunUseItemCount); - outBitStream->Write(m_ImmuneToStunEquipCount); - outBitStream->Write(m_ImmuneToStunInteractCount); + outBitStream.Write1(); // always write these on construction + outBitStream.Write(m_ImmuneToStunMoveCount); + outBitStream.Write(m_ImmuneToStunJumpCount); + outBitStream.Write(m_ImmuneToStunTurnCount); + outBitStream.Write(m_ImmuneToStunAttackCount); + outBitStream.Write(m_ImmuneToStunUseItemCount); + outBitStream.Write(m_ImmuneToStunEquipCount); + outBitStream.Write(m_ImmuneToStunInteractCount); } if (m_IgnoreMultipliers) m_DirtyCheats = false; - outBitStream->Write(m_DirtyCheats); + outBitStream.Write(m_DirtyCheats); if (m_DirtyCheats) { - outBitStream->Write(m_GravityScale); - outBitStream->Write(m_SpeedMultiplier); + outBitStream.Write(m_GravityScale); + outBitStream.Write(m_SpeedMultiplier); m_DirtyCheats = false; } - outBitStream->Write(m_DirtyEquippedItemInfo); + outBitStream.Write(m_DirtyEquippedItemInfo); if (m_DirtyEquippedItemInfo) { - outBitStream->Write(m_PickupRadius); - outBitStream->Write(m_InJetpackMode); + outBitStream.Write(m_PickupRadius); + outBitStream.Write(m_InJetpackMode); m_DirtyEquippedItemInfo = false; } - outBitStream->Write(m_DirtyBubble); + outBitStream.Write(m_DirtyBubble); if (m_DirtyBubble) { - outBitStream->Write(m_IsInBubble); + outBitStream.Write(m_IsInBubble); if (m_IsInBubble) { - outBitStream->Write(m_BubbleType); - outBitStream->Write(m_SpecialAnims); + outBitStream.Write(m_BubbleType); + outBitStream.Write(m_SpecialAnims); } m_DirtyBubble = false; } - outBitStream->Write(m_DirtyPosition || bIsInitialUpdate); + outBitStream.Write(m_DirtyPosition || bIsInitialUpdate); if (m_DirtyPosition || bIsInitialUpdate) { - outBitStream->Write(m_Position.x); - outBitStream->Write(m_Position.y); - outBitStream->Write(m_Position.z); + outBitStream.Write(m_Position.x); + outBitStream.Write(m_Position.y); + outBitStream.Write(m_Position.z); - outBitStream->Write(m_Rotation.x); - outBitStream->Write(m_Rotation.y); - outBitStream->Write(m_Rotation.z); - outBitStream->Write(m_Rotation.w); + outBitStream.Write(m_Rotation.x); + outBitStream.Write(m_Rotation.y); + outBitStream.Write(m_Rotation.z); + outBitStream.Write(m_Rotation.w); - outBitStream->Write(m_IsOnGround); - outBitStream->Write(m_IsOnRail); + outBitStream.Write(m_IsOnGround); + outBitStream.Write(m_IsOnRail); - outBitStream->Write(m_DirtyVelocity); + outBitStream.Write(m_DirtyVelocity); if (m_DirtyVelocity) { - outBitStream->Write(m_Velocity.x); - outBitStream->Write(m_Velocity.y); - outBitStream->Write(m_Velocity.z); + outBitStream.Write(m_Velocity.x); + outBitStream.Write(m_Velocity.y); + outBitStream.Write(m_Velocity.z); } - outBitStream->Write(m_DirtyAngularVelocity); + outBitStream.Write(m_DirtyAngularVelocity); if (m_DirtyAngularVelocity) { - outBitStream->Write(m_AngularVelocity.x); - outBitStream->Write(m_AngularVelocity.y); - outBitStream->Write(m_AngularVelocity.z); + outBitStream.Write(m_AngularVelocity.x); + outBitStream.Write(m_AngularVelocity.y); + outBitStream.Write(m_AngularVelocity.z); } - outBitStream->Write0(); + outBitStream.Write0(); } if (!bIsInitialUpdate) { - outBitStream->Write(m_IsTeleporting); + outBitStream.Write(m_IsTeleporting); m_IsTeleporting = false; } } diff --git a/dGame/dComponents/ControllablePhysicsComponent.h b/dGame/dComponents/ControllablePhysicsComponent.h index e850cfeb..313f80de 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.h +++ b/dGame/dComponents/ControllablePhysicsComponent.h @@ -27,7 +27,7 @@ public: ~ControllablePhysicsComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 68271f26..39643baf 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -122,61 +122,61 @@ void DestroyableComponent::Reinitialize(LOT templateID) { } } -void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void DestroyableComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write1(); // always write these on construction - outBitStream->Write(m_ImmuneToBasicAttackCount); - outBitStream->Write(m_ImmuneToDamageOverTimeCount); - outBitStream->Write(m_ImmuneToKnockbackCount); - outBitStream->Write(m_ImmuneToInterruptCount); - outBitStream->Write(m_ImmuneToSpeedCount); - outBitStream->Write(m_ImmuneToImaginationGainCount); - outBitStream->Write(m_ImmuneToImaginationLossCount); - outBitStream->Write(m_ImmuneToQuickbuildInterruptCount); - outBitStream->Write(m_ImmuneToPullToPointCount); + outBitStream.Write1(); // always write these on construction + outBitStream.Write(m_ImmuneToBasicAttackCount); + outBitStream.Write(m_ImmuneToDamageOverTimeCount); + outBitStream.Write(m_ImmuneToKnockbackCount); + outBitStream.Write(m_ImmuneToInterruptCount); + outBitStream.Write(m_ImmuneToSpeedCount); + outBitStream.Write(m_ImmuneToImaginationGainCount); + outBitStream.Write(m_ImmuneToImaginationLossCount); + outBitStream.Write(m_ImmuneToQuickbuildInterruptCount); + outBitStream.Write(m_ImmuneToPullToPointCount); } - outBitStream->Write(m_DirtyHealth || bIsInitialUpdate); + outBitStream.Write(m_DirtyHealth || bIsInitialUpdate); if (m_DirtyHealth || bIsInitialUpdate) { - outBitStream->Write(m_iHealth); - outBitStream->Write(m_fMaxHealth); - outBitStream->Write(m_iArmor); - outBitStream->Write(m_fMaxArmor); - outBitStream->Write(m_iImagination); - outBitStream->Write(m_fMaxImagination); + outBitStream.Write(m_iHealth); + outBitStream.Write(m_fMaxHealth); + outBitStream.Write(m_iArmor); + outBitStream.Write(m_fMaxArmor); + outBitStream.Write(m_iImagination); + outBitStream.Write(m_fMaxImagination); - outBitStream->Write(m_DamageToAbsorb); - outBitStream->Write(IsImmune()); - outBitStream->Write(m_IsGMImmune); - outBitStream->Write(m_IsShielded); + outBitStream.Write(m_DamageToAbsorb); + outBitStream.Write(IsImmune()); + outBitStream.Write(m_IsGMImmune); + outBitStream.Write(m_IsShielded); - outBitStream->Write(m_fMaxHealth); - outBitStream->Write(m_fMaxArmor); - outBitStream->Write(m_fMaxImagination); + outBitStream.Write(m_fMaxHealth); + outBitStream.Write(m_fMaxArmor); + outBitStream.Write(m_fMaxImagination); - outBitStream->Write(m_FactionIDs.size()); + outBitStream.Write(m_FactionIDs.size()); for (size_t i = 0; i < m_FactionIDs.size(); ++i) { - outBitStream->Write(m_FactionIDs[i]); + outBitStream.Write(m_FactionIDs[i]); } - outBitStream->Write(m_IsSmashable); + outBitStream.Write(m_IsSmashable); if (bIsInitialUpdate) { - outBitStream->Write(m_IsDead); - outBitStream->Write(m_IsSmashed); + outBitStream.Write(m_IsDead); + outBitStream.Write(m_IsSmashed); if (m_IsSmashable) { - outBitStream->Write(m_IsModuleAssembly); - outBitStream->Write(m_ExplodeFactor != 1.0f); - if (m_ExplodeFactor != 1.0f) outBitStream->Write(m_ExplodeFactor); + outBitStream.Write(m_IsModuleAssembly); + outBitStream.Write(m_ExplodeFactor != 1.0f); + if (m_ExplodeFactor != 1.0f) outBitStream.Write(m_ExplodeFactor); } } m_DirtyHealth = false; } - outBitStream->Write(m_DirtyThreatList || bIsInitialUpdate); + outBitStream.Write(m_DirtyThreatList || bIsInitialUpdate); if (m_DirtyThreatList || bIsInitialUpdate) { - outBitStream->Write(m_HasThreats); + outBitStream.Write(m_HasThreats); m_DirtyThreatList = false; } } diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index 1f45b43e..85a4f941 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -25,7 +25,7 @@ public: ~DestroyableComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/DonationVendorComponent.cpp b/dGame/dComponents/DonationVendorComponent.cpp index 6abc959a..7fb06a90 100644 --- a/dGame/dComponents/DonationVendorComponent.cpp +++ b/dGame/dComponents/DonationVendorComponent.cpp @@ -36,13 +36,13 @@ void DonationVendorComponent::SubmitDonation(uint32_t count) { m_DirtyDonationVendor = true; } -void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void DonationVendorComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { VendorComponent::Serialize(outBitStream, bIsInitialUpdate); - outBitStream->Write(bIsInitialUpdate || m_DirtyDonationVendor); + outBitStream.Write(bIsInitialUpdate || m_DirtyDonationVendor); if (bIsInitialUpdate || m_DirtyDonationVendor) { - outBitStream->Write(m_PercentComplete); - outBitStream->Write(m_TotalDonated); - outBitStream->Write(m_TotalRemaining); + outBitStream.Write(m_PercentComplete); + outBitStream.Write(m_TotalDonated); + outBitStream.Write(m_TotalRemaining); if (!bIsInitialUpdate) m_DirtyDonationVendor = false; } } diff --git a/dGame/dComponents/DonationVendorComponent.h b/dGame/dComponents/DonationVendorComponent.h index 7eb60849..af1eb829 100644 --- a/dGame/dComponents/DonationVendorComponent.h +++ b/dGame/dComponents/DonationVendorComponent.h @@ -10,7 +10,7 @@ class DonationVendorComponent final : public VendorComponent { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR; DonationVendorComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; uint32_t GetActivityID() {return m_ActivityId;}; void SubmitDonation(uint32_t count); diff --git a/dGame/dComponents/HavokVehiclePhysicsComponent.cpp b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp index 8c8e14fe..464cb357 100644 --- a/dGame/dComponents/HavokVehiclePhysicsComponent.cpp +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.cpp @@ -50,65 +50,65 @@ void HavokVehiclePhysicsComponent::SetDirtyAngularVelocity(bool val) { m_DirtyAngularVelocity = val; } -void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyPosition); +void HavokVehiclePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyPosition); if (bIsInitialUpdate || m_DirtyPosition) { m_DirtyPosition = false; - outBitStream->Write(m_Position.x); - outBitStream->Write(m_Position.y); - outBitStream->Write(m_Position.z); + outBitStream.Write(m_Position.x); + outBitStream.Write(m_Position.y); + outBitStream.Write(m_Position.z); - outBitStream->Write(m_Rotation.x); - outBitStream->Write(m_Rotation.y); - outBitStream->Write(m_Rotation.z); - outBitStream->Write(m_Rotation.w); + outBitStream.Write(m_Rotation.x); + outBitStream.Write(m_Rotation.y); + outBitStream.Write(m_Rotation.z); + outBitStream.Write(m_Rotation.w); - outBitStream->Write(m_IsOnGround); - outBitStream->Write(m_IsOnRail); + outBitStream.Write(m_IsOnGround); + outBitStream.Write(m_IsOnRail); - outBitStream->Write(bIsInitialUpdate || m_DirtyVelocity); + outBitStream.Write(bIsInitialUpdate || m_DirtyVelocity); if (bIsInitialUpdate || m_DirtyVelocity) { - outBitStream->Write(m_Velocity.x); - outBitStream->Write(m_Velocity.y); - outBitStream->Write(m_Velocity.z); + outBitStream.Write(m_Velocity.x); + outBitStream.Write(m_Velocity.y); + outBitStream.Write(m_Velocity.z); m_DirtyVelocity = false; } - outBitStream->Write(bIsInitialUpdate || m_DirtyAngularVelocity); + outBitStream.Write(bIsInitialUpdate || m_DirtyAngularVelocity); if (bIsInitialUpdate || m_DirtyAngularVelocity) { - outBitStream->Write(m_AngularVelocity.x); - outBitStream->Write(m_AngularVelocity.y); - outBitStream->Write(m_AngularVelocity.z); + outBitStream.Write(m_AngularVelocity.x); + outBitStream.Write(m_AngularVelocity.y); + outBitStream.Write(m_AngularVelocity.z); m_DirtyAngularVelocity = false; } - outBitStream->Write0(); // local_space_info. TODO: Implement this + outBitStream.Write0(); // local_space_info. TODO: Implement this - outBitStream->Write(m_DirtyRemoteInput || bIsInitialUpdate); // remote_input_info + outBitStream.Write(m_DirtyRemoteInput || bIsInitialUpdate); // remote_input_info if (m_DirtyRemoteInput || bIsInitialUpdate) { - outBitStream->Write(m_RemoteInputInfo.m_RemoteInputX); - outBitStream->Write(m_RemoteInputInfo.m_RemoteInputY); - outBitStream->Write(m_RemoteInputInfo.m_IsPowersliding); - outBitStream->Write(m_RemoteInputInfo.m_IsModified); + outBitStream.Write(m_RemoteInputInfo.m_RemoteInputX); + outBitStream.Write(m_RemoteInputInfo.m_RemoteInputY); + outBitStream.Write(m_RemoteInputInfo.m_IsPowersliding); + outBitStream.Write(m_RemoteInputInfo.m_IsModified); m_DirtyRemoteInput = false; } - outBitStream->Write(125.0f); // remote_input_ping TODO: Figure out how this should be calculated as it seems to be constant through the whole race. + outBitStream.Write(125.0f); // remote_input_ping TODO: Figure out how this should be calculated as it seems to be constant through the whole race. if (!bIsInitialUpdate) { - outBitStream->Write0(); + outBitStream.Write0(); } } if (bIsInitialUpdate) { - outBitStream->Write(m_EndBehavior); - outBitStream->Write1(); // is input locked? + outBitStream.Write(m_EndBehavior); + outBitStream.Write1(); // is input locked? } - outBitStream->Write0(); + outBitStream.Write0(); } void HavokVehiclePhysicsComponent::Update(float deltaTime) { diff --git a/dGame/dComponents/HavokVehiclePhysicsComponent.h b/dGame/dComponents/HavokVehiclePhysicsComponent.h index 85a0e279..94c14ec6 100644 --- a/dGame/dComponents/HavokVehiclePhysicsComponent.h +++ b/dGame/dComponents/HavokVehiclePhysicsComponent.h @@ -15,7 +15,7 @@ public: HavokVehiclePhysicsComponent(Entity* parentEntity); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index 0f2c3322..161d7b91 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -694,11 +694,11 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { } } -void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate) { +void InventoryComponent::Serialize(RakNet::BitStream& outBitStream, const bool bIsInitialUpdate) { if (bIsInitialUpdate || m_Dirty) { - outBitStream->Write(true); + outBitStream.Write(true); - outBitStream->Write(m_Equipped.size()); + outBitStream.Write(m_Equipped.size()); for (const auto& pair : m_Equipped) { const auto item = pair.second; @@ -707,21 +707,21 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b AddItemSkills(item.lot); } - outBitStream->Write(item.id); - outBitStream->Write(item.lot); + outBitStream.Write(item.id); + outBitStream.Write(item.lot); - outBitStream->Write0(); + outBitStream.Write0(); - outBitStream->Write(item.count > 0); - if (item.count > 0) outBitStream->Write(item.count); + outBitStream.Write(item.count > 0); + if (item.count > 0) outBitStream.Write(item.count); - outBitStream->Write(item.slot != 0); - if (item.slot != 0) outBitStream->Write(item.slot); + outBitStream.Write(item.slot != 0); + if (item.slot != 0) outBitStream.Write(item.slot); - outBitStream->Write0(); + outBitStream.Write0(); bool flag = !item.config.empty(); - outBitStream->Write(flag); + outBitStream.Write(flag); if (flag) { RakNet::BitStream ldfStream; ldfStream.Write(item.config.size()); // Key count @@ -736,20 +736,20 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b data->WriteToPacket(ldfStream); } } - outBitStream->Write(ldfStream.GetNumberOfBytesUsed() + 1); - outBitStream->Write(0); // Don't compress - outBitStream->Write(ldfStream); + outBitStream.Write(ldfStream.GetNumberOfBytesUsed() + 1); + outBitStream.Write(0); // Don't compress + outBitStream.Write(ldfStream); } - outBitStream->Write1(); + outBitStream.Write1(); } m_Dirty = false; } else { - outBitStream->Write(false); + outBitStream.Write(false); } - outBitStream->Write(false); + outBitStream.Write(false); } void InventoryComponent::Update(float deltaTime) { diff --git a/dGame/dComponents/InventoryComponent.h b/dGame/dComponents/InventoryComponent.h index e47e6a59..8f58a523 100644 --- a/dGame/dComponents/InventoryComponent.h +++ b/dGame/dComponents/InventoryComponent.h @@ -41,7 +41,7 @@ public: explicit InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document = nullptr); void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void LoadXml(tinyxml2::XMLDocument* document); void UpdateXml(tinyxml2::XMLDocument* document) override; diff --git a/dGame/dComponents/ItemComponent.cpp b/dGame/dComponents/ItemComponent.cpp index dc413b17..799cd935 100644 --- a/dGame/dComponents/ItemComponent.cpp +++ b/dGame/dComponents/ItemComponent.cpp @@ -1,5 +1,5 @@ #include "ItemComponent.h" -void ItemComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write0(); +void ItemComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write0(); } diff --git a/dGame/dComponents/ItemComponent.h b/dGame/dComponents/ItemComponent.h index 875ef0a5..1a02ad11 100644 --- a/dGame/dComponents/ItemComponent.h +++ b/dGame/dComponents/ItemComponent.h @@ -10,7 +10,7 @@ public: ItemComponent(Entity* entity) : Component(entity) {} - void Serialize(RakNet::BitStream* bitStream, bool isConstruction) override; + void Serialize(RakNet::BitStream& bitStream, bool isConstruction) override; }; #endif //!__ITEMCOMPONENT__H__ diff --git a/dGame/dComponents/LUPExhibitComponent.cpp b/dGame/dComponents/LUPExhibitComponent.cpp index a312617d..00a8cf03 100644 --- a/dGame/dComponents/LUPExhibitComponent.cpp +++ b/dGame/dComponents/LUPExhibitComponent.cpp @@ -15,10 +15,10 @@ void LUPExhibitComponent::NextLUPExhibit() { Game::entityManager->SerializeEntity(m_Parent); } -void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyLUPExhibit); +void LUPExhibitComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyLUPExhibit); if (m_DirtyLUPExhibit) { - outBitStream->Write(m_LUPExhibits[m_LUPExhibitIndex % m_LUPExhibits.size()]); + outBitStream.Write(m_LUPExhibits[m_LUPExhibitIndex % m_LUPExhibits.size()]); if (!bIsInitialUpdate) m_DirtyLUPExhibit = false; } } diff --git a/dGame/dComponents/LUPExhibitComponent.h b/dGame/dComponents/LUPExhibitComponent.h index e6653868..8fd6d7ee 100644 --- a/dGame/dComponents/LUPExhibitComponent.h +++ b/dGame/dComponents/LUPExhibitComponent.h @@ -18,7 +18,7 @@ public: LUPExhibitComponent(Entity* parent) : Component(parent) {}; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void NextLUPExhibit(); private: float m_UpdateTimer = 0.0f; diff --git a/dGame/dComponents/LevelProgressionComponent.cpp b/dGame/dComponents/LevelProgressionComponent.cpp index d271f97b..2d3d5144 100644 --- a/dGame/dComponents/LevelProgressionComponent.cpp +++ b/dGame/dComponents/LevelProgressionComponent.cpp @@ -37,9 +37,9 @@ void LevelProgressionComponent::LoadFromXml(tinyxml2::XMLDocument* doc) { m_CharacterVersion = static_cast(characterVersion); } -void LevelProgressionComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyLevelInfo); - if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream->Write(m_Level); +void LevelProgressionComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyLevelInfo); + if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream.Write(m_Level); m_DirtyLevelInfo = false; } diff --git a/dGame/dComponents/LevelProgressionComponent.h b/dGame/dComponents/LevelProgressionComponent.h index 6083738c..a27039f3 100644 --- a/dGame/dComponents/LevelProgressionComponent.h +++ b/dGame/dComponents/LevelProgressionComponent.h @@ -21,7 +21,7 @@ public: */ LevelProgressionComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Save data from this componennt to character XML diff --git a/dGame/dComponents/MiniGameControlComponent.cpp b/dGame/dComponents/MiniGameControlComponent.cpp index fdd56a2c..088ee354 100644 --- a/dGame/dComponents/MiniGameControlComponent.cpp +++ b/dGame/dComponents/MiniGameControlComponent.cpp @@ -1,5 +1,5 @@ #include "MiniGameControlComponent.h" -void MiniGameControlComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write(0x40000000); +void MiniGameControlComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write(0x40000000); } diff --git a/dGame/dComponents/MiniGameControlComponent.h b/dGame/dComponents/MiniGameControlComponent.h index e2581b2d..2cd9ac6a 100644 --- a/dGame/dComponents/MiniGameControlComponent.h +++ b/dGame/dComponents/MiniGameControlComponent.h @@ -9,7 +9,7 @@ public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::MINI_GAME_CONTROL; MiniGameControlComponent(Entity* parent) : Component(parent) {} - void Serialize(RakNet::BitStream* outBitStream, bool isConstruction); + void Serialize(RakNet::BitStream& outBitStream, bool isConstruction); }; #endif //!__MINIGAMECONTROLCOMPONENT__H__ diff --git a/dGame/dComponents/MinigameComponent.cpp b/dGame/dComponents/MinigameComponent.cpp index 6bcb985e..2174cd8a 100644 --- a/dGame/dComponents/MinigameComponent.cpp +++ b/dGame/dComponents/MinigameComponent.cpp @@ -1,5 +1,5 @@ #include "MinigameComponent.h" -void MinigameComponent::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) { - outBitStream->Write(0x40000000); +void MinigameComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { + outBitStream.Write(0x40000000); } diff --git a/dGame/dComponents/MissionComponent.h b/dGame/dComponents/MissionComponent.h index 42c4df08..866f1650 100644 --- a/dGame/dComponents/MissionComponent.h +++ b/dGame/dComponents/MissionComponent.h @@ -30,7 +30,7 @@ public: explicit MissionComponent(Entity* parent); ~MissionComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate, unsigned int& flags); void LoadFromXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 3f8858c0..75f2a019 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -14,26 +14,26 @@ ModelComponent::ModelComponent(Entity* parent) : Component(parent) { m_userModelID = m_Parent->GetVarAs(u"userModelID"); } -void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ModelComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { // ItemComponent Serialization. Pets do not get this serialization. if (!m_Parent->HasComponent(eReplicaComponentType::PET)) { - outBitStream->Write1(); - outBitStream->Write(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID()); - outBitStream->Write(0); - outBitStream->Write0(); + outBitStream.Write1(); + outBitStream.Write(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_Parent->GetObjectID()); + outBitStream.Write(0); + outBitStream.Write0(); } //actual model component: - outBitStream->Write1(); // Yes we are writing model info - outBitStream->Write0(); // Is pickable - outBitStream->Write(2); // Physics type - outBitStream->Write(m_OriginalPosition); // Original position - outBitStream->Write(m_OriginalRotation); // Original rotation + outBitStream.Write1(); // Yes we are writing model info + outBitStream.Write0(); // Is pickable + outBitStream.Write(2); // Physics type + outBitStream.Write(m_OriginalPosition); // Original position + outBitStream.Write(m_OriginalRotation); // Original rotation - outBitStream->Write1(); // We are writing behavior info - outBitStream->Write(0); // Number of behaviors - outBitStream->Write1(); // Is this model paused - if (bIsInitialUpdate) outBitStream->Write0(); // We are not writing model editing info + outBitStream.Write1(); // We are writing behavior info + outBitStream.Write(0); // Number of behaviors + outBitStream.Write1(); // Is this model paused + if (bIsInitialUpdate) outBitStream.Write0(); // We are not writing model editing info } void ModelComponent::UpdatePendingBehaviorId(const int32_t newId) { diff --git a/dGame/dComponents/ModelComponent.h b/dGame/dComponents/ModelComponent.h index 0d720d04..9d2a4e3f 100644 --- a/dGame/dComponents/ModelComponent.h +++ b/dGame/dComponents/ModelComponent.h @@ -28,7 +28,7 @@ public: ModelComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Returns the original position of the model diff --git a/dGame/dComponents/ModuleAssemblyComponent.cpp b/dGame/dComponents/ModuleAssemblyComponent.cpp index 5b7042df..e217d9b7 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.cpp +++ b/dGame/dComponents/ModuleAssemblyComponent.cpp @@ -46,20 +46,20 @@ const std::u16string& ModuleAssemblyComponent::GetAssemblyPartsLOTs() const { return m_AssemblyPartsLOTs; } -void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ModuleAssemblyComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_SubKey != LWOOBJID_EMPTY); + outBitStream.Write(m_SubKey != LWOOBJID_EMPTY); if (m_SubKey != LWOOBJID_EMPTY) { - outBitStream->Write(m_SubKey); + outBitStream.Write(m_SubKey); } - outBitStream->Write(m_UseOptionalParts); + outBitStream.Write(m_UseOptionalParts); - outBitStream->Write(m_AssemblyPartsLOTs.size()); + outBitStream.Write(m_AssemblyPartsLOTs.size()); for (char16_t character : m_AssemblyPartsLOTs) { - outBitStream->Write(character); + outBitStream.Write(character); } } } diff --git a/dGame/dComponents/ModuleAssemblyComponent.h b/dGame/dComponents/ModuleAssemblyComponent.h index 47e7baa6..7e050ec7 100644 --- a/dGame/dComponents/ModuleAssemblyComponent.h +++ b/dGame/dComponents/ModuleAssemblyComponent.h @@ -17,7 +17,7 @@ public: ModuleAssemblyComponent(Entity* parent); ~ModuleAssemblyComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 366bebd3..4bcf78c0 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -32,25 +32,25 @@ MoverSubComponent::MoverSubComponent(const NiPoint3& startPos) { MoverSubComponent::~MoverSubComponent() = default; -void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(true); +void MoverSubComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(true); - outBitStream->Write(mState); - outBitStream->Write(mDesiredWaypointIndex); - outBitStream->Write(mShouldStopAtDesiredWaypoint); - outBitStream->Write(mInReverse); + outBitStream.Write(mState); + outBitStream.Write(mDesiredWaypointIndex); + outBitStream.Write(mShouldStopAtDesiredWaypoint); + outBitStream.Write(mInReverse); - outBitStream->Write(mPercentBetweenPoints); + outBitStream.Write(mPercentBetweenPoints); - outBitStream->Write(mPosition.x); - outBitStream->Write(mPosition.y); - outBitStream->Write(mPosition.z); + outBitStream.Write(mPosition.x); + outBitStream.Write(mPosition.y); + outBitStream.Write(mPosition.z); - outBitStream->Write(mCurrentWaypointIndex); - outBitStream->Write(mNextWaypointIndex); + outBitStream.Write(mCurrentWaypointIndex); + outBitStream.Write(mNextWaypointIndex); - outBitStream->Write(mIdleTimeElapsed); - outBitStream->Write(0.0f); // Move time elapsed + outBitStream.Write(mIdleTimeElapsed); + outBitStream.Write(0.0f); // Move time elapsed } //------------- MovingPlatformComponent below -------------- @@ -71,43 +71,43 @@ MovingPlatformComponent::~MovingPlatformComponent() { delete static_cast(m_MoverSubComponent); } -void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void MovingPlatformComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { // Here we don't serialize the moving platform to let the client simulate the movement if (!m_Serialize) { - outBitStream->Write(false); - outBitStream->Write(false); + outBitStream.Write(false); + outBitStream.Write(false); return; } - outBitStream->Write(true); + outBitStream.Write(true); auto hasPath = !m_PathingStopped && !m_PathName.empty(); - outBitStream->Write(hasPath); + outBitStream.Write(hasPath); if (hasPath) { // Is on rail - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_PathName.size()); + outBitStream.Write(m_PathName.size()); for (const auto& c : m_PathName) { - outBitStream->Write(c); + outBitStream.Write(c); } // Starting point - outBitStream->Write(0); + outBitStream.Write(0); // Reverse - outBitStream->Write(false); + outBitStream.Write(false); } const auto hasPlatform = m_MoverSubComponent != nullptr; - outBitStream->Write(hasPlatform); + outBitStream.Write(hasPlatform); if (hasPlatform) { auto* mover = static_cast(m_MoverSubComponent); - outBitStream->Write(m_MoverSubComponentType); + outBitStream.Write(m_MoverSubComponentType); if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) { // TODO diff --git a/dGame/dComponents/MovingPlatformComponent.h b/dGame/dComponents/MovingPlatformComponent.h index cf47b9c3..c4fbf308 100644 --- a/dGame/dComponents/MovingPlatformComponent.h +++ b/dGame/dComponents/MovingPlatformComponent.h @@ -38,7 +38,7 @@ public: MoverSubComponent(const NiPoint3& startPos); ~MoverSubComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate); + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate); /** * The state the platform is currently in @@ -111,7 +111,7 @@ public: MovingPlatformComponent(Entity* parent, const std::string& pathName); ~MovingPlatformComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Stops all pathing, called when an entity starts a quick build associated with this platform diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index 1af65b4e..a016eb36 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -96,42 +96,42 @@ PetComponent::PetComponent(Entity* parentEntity, uint32_t componentId) : Compone } } -void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void PetComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { const bool tamed = m_Owner != LWOOBJID_EMPTY; - outBitStream->Write1(); // Always serialize as dirty for now + outBitStream.Write1(); // Always serialize as dirty for now - outBitStream->Write(m_Status); - outBitStream->Write(tamed ? m_Ability : ePetAbilityType::Invalid); // Something with the overhead icon? + outBitStream.Write(m_Status); + outBitStream.Write(tamed ? m_Ability : ePetAbilityType::Invalid); // Something with the overhead icon? const bool interacting = m_Interaction != LWOOBJID_EMPTY; - outBitStream->Write(interacting); + outBitStream.Write(interacting); if (interacting) { - outBitStream->Write(m_Interaction); + outBitStream.Write(m_Interaction); } - outBitStream->Write(tamed); + outBitStream.Write(tamed); if (tamed) { - outBitStream->Write(m_Owner); + outBitStream.Write(m_Owner); } if (bIsInitialUpdate) { - outBitStream->Write(tamed); + outBitStream.Write(tamed); if (tamed) { - outBitStream->Write(m_ModerationStatus); + outBitStream.Write(m_ModerationStatus); const auto nameData = GeneralUtils::UTF8ToUTF16(m_Name); const auto ownerNameData = GeneralUtils::UTF8ToUTF16(m_OwnerName); - outBitStream->Write(nameData.size()); + outBitStream.Write(nameData.size()); for (const auto c : nameData) { - outBitStream->Write(c); + outBitStream.Write(c); } - outBitStream->Write(ownerNameData.size()); + outBitStream.Write(ownerNameData.size()); for (const auto c : ownerNameData) { - outBitStream->Write(c); + outBitStream.Write(c); } } } diff --git a/dGame/dComponents/PetComponent.h b/dGame/dComponents/PetComponent.h index 6d13bea9..0254c5f5 100644 --- a/dGame/dComponents/PetComponent.h +++ b/dGame/dComponents/PetComponent.h @@ -21,7 +21,7 @@ public: explicit PetComponent(Entity* parentEntity, uint32_t componentId); ~PetComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index 592c2a6b..276184b1 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -264,30 +264,30 @@ void PhantomPhysicsComponent::CreatePhysics() { m_HasCreatedPhysics = true; } -void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void PhantomPhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate); - outBitStream->Write(m_EffectInfoDirty || bIsInitialUpdate); + outBitStream.Write(m_EffectInfoDirty || bIsInitialUpdate); if (m_EffectInfoDirty || bIsInitialUpdate) { - outBitStream->Write(m_IsPhysicsEffectActive); + outBitStream.Write(m_IsPhysicsEffectActive); if (m_IsPhysicsEffectActive) { - outBitStream->Write(m_EffectType); - outBitStream->Write(m_DirectionalMultiplier); + outBitStream.Write(m_EffectType); + outBitStream.Write(m_DirectionalMultiplier); // forgive me father for i have sinned - outBitStream->Write0(); - //outBitStream->Write(m_MinMax); + outBitStream.Write0(); + //outBitStream.Write(m_MinMax); //if (m_MinMax) { - //outBitStream->Write(m_Min); - //outBitStream->Write(m_Max); + //outBitStream.Write(m_Min); + //outBitStream.Write(m_Max); //} - outBitStream->Write(m_IsDirectional); + outBitStream.Write(m_IsDirectional); if (m_IsDirectional) { - outBitStream->Write(m_Direction.x); - outBitStream->Write(m_Direction.y); - outBitStream->Write(m_Direction.z); + outBitStream.Write(m_Direction.x); + outBitStream.Write(m_Direction.y); + outBitStream.Write(m_Direction.z); } } diff --git a/dGame/dComponents/PhantomPhysicsComponent.h b/dGame/dComponents/PhantomPhysicsComponent.h index 2ea9e979..1aae9527 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.h +++ b/dGame/dComponents/PhantomPhysicsComponent.h @@ -32,7 +32,7 @@ public: PhantomPhysicsComponent(Entity* parent); ~PhantomPhysicsComponent() override; void Update(float deltaTime) override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Creates the physics shape for this entity based on LDF data diff --git a/dGame/dComponents/PhysicsComponent.cpp b/dGame/dComponents/PhysicsComponent.cpp index ea57735f..3a84c4ce 100644 --- a/dGame/dComponents/PhysicsComponent.cpp +++ b/dGame/dComponents/PhysicsComponent.cpp @@ -6,16 +6,16 @@ PhysicsComponent::PhysicsComponent(Entity* parent) : Component(parent) { m_DirtyPosition = false; } -void PhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyPosition); +void PhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyPosition); if (bIsInitialUpdate || m_DirtyPosition) { - outBitStream->Write(m_Position.x); - outBitStream->Write(m_Position.y); - outBitStream->Write(m_Position.z); - outBitStream->Write(m_Rotation.x); - outBitStream->Write(m_Rotation.y); - outBitStream->Write(m_Rotation.z); - outBitStream->Write(m_Rotation.w); + outBitStream.Write(m_Position.x); + outBitStream.Write(m_Position.y); + outBitStream.Write(m_Position.z); + outBitStream.Write(m_Rotation.x); + outBitStream.Write(m_Rotation.y); + outBitStream.Write(m_Rotation.z); + outBitStream.Write(m_Rotation.w); if (!bIsInitialUpdate) m_DirtyPosition = false; } } diff --git a/dGame/dComponents/PhysicsComponent.h b/dGame/dComponents/PhysicsComponent.h index c1a7f34a..71f52e54 100644 --- a/dGame/dComponents/PhysicsComponent.h +++ b/dGame/dComponents/PhysicsComponent.h @@ -14,7 +14,7 @@ public: PhysicsComponent(Entity* parent); virtual ~PhysicsComponent() = default; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; const NiPoint3& GetPosition() const { return m_Position; } virtual void SetPosition(const NiPoint3& pos) { if (m_Position == pos) return; m_Position = pos; m_DirtyPosition = true; } diff --git a/dGame/dComponents/PlayerForcedMovementComponent.cpp b/dGame/dComponents/PlayerForcedMovementComponent.cpp index d511ad78..0aea882c 100644 --- a/dGame/dComponents/PlayerForcedMovementComponent.cpp +++ b/dGame/dComponents/PlayerForcedMovementComponent.cpp @@ -6,11 +6,11 @@ PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : C PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {} -void PlayerForcedMovementComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyInfo || bIsInitialUpdate); +void PlayerForcedMovementComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyInfo || bIsInitialUpdate); if (m_DirtyInfo || bIsInitialUpdate) { - outBitStream->Write(m_PlayerOnRail); - outBitStream->Write(m_ShowBillboard); + outBitStream.Write(m_PlayerOnRail); + outBitStream.Write(m_ShowBillboard); } m_DirtyInfo = false; } diff --git a/dGame/dComponents/PlayerForcedMovementComponent.h b/dGame/dComponents/PlayerForcedMovementComponent.h index e5aca37d..f184ede2 100644 --- a/dGame/dComponents/PlayerForcedMovementComponent.h +++ b/dGame/dComponents/PlayerForcedMovementComponent.h @@ -19,7 +19,7 @@ public: PlayerForcedMovementComponent(Entity* parent); ~PlayerForcedMovementComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * @brief Set the Player On Rail object diff --git a/dGame/dComponents/PossessableComponent.cpp b/dGame/dComponents/PossessableComponent.cpp index 509b1a07..ae5b05b3 100644 --- a/dGame/dComponents/PossessableComponent.cpp +++ b/dGame/dComponents/PossessableComponent.cpp @@ -27,17 +27,17 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) result.finalize(); } -void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate); +void PossessableComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyPossessable || bIsInitialUpdate); if (m_DirtyPossessable || bIsInitialUpdate) { m_DirtyPossessable = false; // reset flag - outBitStream->Write(m_Possessor != LWOOBJID_EMPTY); - if (m_Possessor != LWOOBJID_EMPTY) outBitStream->Write(m_Possessor); + outBitStream.Write(m_Possessor != LWOOBJID_EMPTY); + if (m_Possessor != LWOOBJID_EMPTY) outBitStream.Write(m_Possessor); - outBitStream->Write(m_AnimationFlag != eAnimationFlags::IDLE_NONE); - if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream->Write(m_AnimationFlag); + outBitStream.Write(m_AnimationFlag != eAnimationFlags::IDLE_NONE); + if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream.Write(m_AnimationFlag); - outBitStream->Write(m_ImmediatelyDepossess); + outBitStream.Write(m_ImmediatelyDepossess); m_ImmediatelyDepossess = false; // reset flag } } diff --git a/dGame/dComponents/PossessableComponent.h b/dGame/dComponents/PossessableComponent.h index 3b075d33..6f1968a5 100644 --- a/dGame/dComponents/PossessableComponent.h +++ b/dGame/dComponents/PossessableComponent.h @@ -18,7 +18,7 @@ public: PossessableComponent(Entity* parentEntity, uint32_t componentId); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * @brief mounts the Entity diff --git a/dGame/dComponents/PossessorComponent.cpp b/dGame/dComponents/PossessorComponent.cpp index 0cb64956..46ccbffb 100644 --- a/dGame/dComponents/PossessorComponent.cpp +++ b/dGame/dComponents/PossessorComponent.cpp @@ -26,15 +26,15 @@ PossessorComponent::~PossessorComponent() { } } -void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_DirtyPossesor || bIsInitialUpdate); +void PossessorComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_DirtyPossesor || bIsInitialUpdate); if (m_DirtyPossesor || bIsInitialUpdate) { m_DirtyPossesor = false; - outBitStream->Write(m_Possessable != LWOOBJID_EMPTY); + outBitStream.Write(m_Possessable != LWOOBJID_EMPTY); if (m_Possessable != LWOOBJID_EMPTY) { - outBitStream->Write(m_Possessable); + outBitStream.Write(m_Possessable); } - outBitStream->Write(m_PossessableType); + outBitStream.Write(m_PossessableType); } } diff --git a/dGame/dComponents/PossessorComponent.h b/dGame/dComponents/PossessorComponent.h index e1aba048..3fa6153d 100644 --- a/dGame/dComponents/PossessorComponent.h +++ b/dGame/dComponents/PossessorComponent.h @@ -23,7 +23,7 @@ public: PossessorComponent(Entity* parent); ~PossessorComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * @brief Mounts the entity diff --git a/dGame/dComponents/QuickBuildComponent.cpp b/dGame/dComponents/QuickBuildComponent.cpp index 6cef87d3..c8ca4407 100644 --- a/dGame/dComponents/QuickBuildComponent.cpp +++ b/dGame/dComponents/QuickBuildComponent.cpp @@ -55,55 +55,55 @@ QuickBuildComponent::~QuickBuildComponent() { DespawnActivator(); } -void QuickBuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void QuickBuildComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) { if (bIsInitialUpdate) { - outBitStream->Write(false); + outBitStream.Write(false); } - outBitStream->Write(false); + outBitStream.Write(false); - outBitStream->Write(false); + outBitStream.Write(false); } // If build state is completed and we've already serialized once in the completed state, // don't serializing this component anymore as this will cause the build to jump again. // If state changes, serialization will begin again. if (!m_StateDirty && m_State == eQuickBuildState::COMPLETED) { - outBitStream->Write0(); - outBitStream->Write0(); + outBitStream.Write0(); + outBitStream.Write0(); return; } // BEGIN Scripted Activity - outBitStream->Write1(); + outBitStream.Write1(); Entity* builder = GetBuilder(); if (builder) { - outBitStream->Write(1); - outBitStream->Write(builder->GetObjectID()); + outBitStream.Write(1); + outBitStream.Write(builder->GetObjectID()); for (int i = 0; i < 10; i++) { - outBitStream->Write(0.0f); + outBitStream.Write(0.0f); } } else { - outBitStream->Write(0); + outBitStream.Write(0); } // END Scripted Activity - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_State); + outBitStream.Write(m_State); - outBitStream->Write(m_ShowResetEffect); - outBitStream->Write(m_Activator != nullptr); + outBitStream.Write(m_ShowResetEffect); + outBitStream.Write(m_Activator != nullptr); - outBitStream->Write(m_Timer); - outBitStream->Write(m_TimerIncomplete); + outBitStream.Write(m_Timer); + outBitStream.Write(m_TimerIncomplete); if (bIsInitialUpdate) { - outBitStream->Write(false); - outBitStream->Write(m_ActivatorPosition); - outBitStream->Write(m_RepositionPlayer); + outBitStream.Write(false); + outBitStream.Write(m_ActivatorPosition); + outBitStream.Write(m_RepositionPlayer); } m_StateDirty = false; } diff --git a/dGame/dComponents/QuickBuildComponent.h b/dGame/dComponents/QuickBuildComponent.h index 556264a8..1cab8660 100644 --- a/dGame/dComponents/QuickBuildComponent.h +++ b/dGame/dComponents/QuickBuildComponent.h @@ -27,7 +27,7 @@ public: QuickBuildComponent(Entity* const entity); ~QuickBuildComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index f3772aad..d7e01f94 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -433,83 +433,83 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu } } -void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void RacingControlComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { // BEGIN Scripted Activity - outBitStream->Write1(); + outBitStream.Write1(); - outBitStream->Write(m_RacingPlayers.size()); + outBitStream.Write(m_RacingPlayers.size()); for (const auto& player : m_RacingPlayers) { - outBitStream->Write(player.playerID); + outBitStream.Write(player.playerID); - outBitStream->Write(player.data[0]); - if (player.finished != 0) outBitStream->Write(player.raceTime); - else outBitStream->Write(player.data[1]); - if (player.finished != 0) outBitStream->Write(player.bestLapTime); - else outBitStream->Write(player.data[2]); - if (player.finished == 1) outBitStream->Write(1.0f); - else outBitStream->Write(player.data[3]); - outBitStream->Write(player.data[4]); - outBitStream->Write(player.data[5]); - outBitStream->Write(player.data[6]); - outBitStream->Write(player.data[7]); - outBitStream->Write(player.data[8]); - outBitStream->Write(player.data[9]); + outBitStream.Write(player.data[0]); + if (player.finished != 0) outBitStream.Write(player.raceTime); + else outBitStream.Write(player.data[1]); + if (player.finished != 0) outBitStream.Write(player.bestLapTime); + else outBitStream.Write(player.data[2]); + if (player.finished == 1) outBitStream.Write(1.0f); + else outBitStream.Write(player.data[3]); + outBitStream.Write(player.data[4]); + outBitStream.Write(player.data[5]); + outBitStream.Write(player.data[6]); + outBitStream.Write(player.data[7]); + outBitStream.Write(player.data[8]); + outBitStream.Write(player.data[9]); } // END Scripted Activity - outBitStream->Write1(); - outBitStream->Write(m_RacingPlayers.size()); + outBitStream.Write1(); + outBitStream.Write(m_RacingPlayers.size()); - outBitStream->Write(!m_AllPlayersReady); + outBitStream.Write(!m_AllPlayersReady); if (!m_AllPlayersReady) { int32_t numReady = 0; for (const auto& player : m_RacingPlayers) { - outBitStream->Write1(); // Has more player data - outBitStream->Write(player.playerID); - outBitStream->Write(player.vehicleID); - outBitStream->Write(player.playerIndex); - outBitStream->Write(player.playerLoaded); + outBitStream.Write1(); // Has more player data + outBitStream.Write(player.playerID); + outBitStream.Write(player.vehicleID); + outBitStream.Write(player.playerIndex); + outBitStream.Write(player.playerLoaded); if (player.playerLoaded) numReady++; } - outBitStream->Write0(); // No more data + outBitStream.Write0(); // No more data if (numReady == m_RacingPlayers.size()) m_AllPlayersReady = true; } - outBitStream->Write(!m_RacingPlayers.empty()); + outBitStream.Write(!m_RacingPlayers.empty()); if (!m_RacingPlayers.empty()) { for (const auto& player : m_RacingPlayers) { if (player.finished == 0) continue; - outBitStream->Write1(); // Has more date + outBitStream.Write1(); // Has more date - outBitStream->Write(player.playerID); - outBitStream->Write(player.finished); + outBitStream.Write(player.playerID); + outBitStream.Write(player.finished); } - outBitStream->Write0(); // No more data + outBitStream.Write0(); // No more data } - outBitStream->Write(bIsInitialUpdate); + outBitStream.Write(bIsInitialUpdate); if (bIsInitialUpdate) { - outBitStream->Write(m_RemainingLaps); - outBitStream->Write(m_PathName.size()); + outBitStream.Write(m_RemainingLaps); + outBitStream.Write(m_PathName.size()); for (const auto character : m_PathName) { - outBitStream->Write(character); + outBitStream.Write(character); } } - outBitStream->Write(!m_RacingPlayers.empty()); + outBitStream.Write(!m_RacingPlayers.empty()); if (!m_RacingPlayers.empty()) { for (const auto& player : m_RacingPlayers) { if (player.finished == 0) continue; - outBitStream->Write1(); // Has more data - outBitStream->Write(player.playerID); - outBitStream->Write(player.bestLapTime); - outBitStream->Write(player.raceTime); + outBitStream.Write1(); // Has more data + outBitStream.Write(player.playerID); + outBitStream.Write(player.bestLapTime); + outBitStream.Write(player.raceTime); } - outBitStream->Write0(); // No more data + outBitStream.Write0(); // No more data } } diff --git a/dGame/dComponents/RacingControlComponent.h b/dGame/dComponents/RacingControlComponent.h index 4a7d387f..790459e3 100644 --- a/dGame/dComponents/RacingControlComponent.h +++ b/dGame/dComponents/RacingControlComponent.h @@ -110,7 +110,7 @@ public: RacingControlComponent(Entity* parentEntity); ~RacingControlComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RenderComponent.cpp b/dGame/dComponents/RenderComponent.cpp index 118e4847..2067ef2a 100644 --- a/dGame/dComponents/RenderComponent.cpp +++ b/dGame/dComponents/RenderComponent.cpp @@ -45,25 +45,25 @@ RenderComponent::RenderComponent(Entity* const parentEntity, const int32_t compo result.finalize(); } -void RenderComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void RenderComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (!bIsInitialUpdate) return; - outBitStream->Write(m_Effects.size()); + outBitStream.Write(m_Effects.size()); for (auto& eff : m_Effects) { - outBitStream->Write(eff.name.size()); + outBitStream.Write(eff.name.size()); // if there is no name, then we don't write anything else if (eff.name.empty()) continue; - for (const auto& value : eff.name) outBitStream->Write(value); + for (const auto& value : eff.name) outBitStream.Write(value); - outBitStream->Write(eff.effectID); + outBitStream.Write(eff.effectID); - outBitStream->Write(eff.type.size()); - for (const auto& value : eff.type) outBitStream->Write(value); + outBitStream.Write(eff.type.size()); + for (const auto& value : eff.type) outBitStream.Write(value); - outBitStream->Write(eff.priority); - outBitStream->Write(eff.secondary); + outBitStream.Write(eff.priority); + outBitStream.Write(eff.secondary); } } diff --git a/dGame/dComponents/RenderComponent.h b/dGame/dComponents/RenderComponent.h index 87b210d7..e2bbcff5 100644 --- a/dGame/dComponents/RenderComponent.h +++ b/dGame/dComponents/RenderComponent.h @@ -65,7 +65,7 @@ public: RenderComponent(Entity* const parentEntity, const int32_t componentId = -1); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void Update(float deltaTime) override; /** diff --git a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp index 414ce2e8..30faa688 100644 --- a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp +++ b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.cpp @@ -11,6 +11,6 @@ RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* paren m_Rotation = m_Parent->GetDefaultRotation(); } -void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate); } diff --git a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h index 082dd1e7..09820f8e 100644 --- a/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h +++ b/dGame/dComponents/RigidbodyPhantomPhysicsComponent.h @@ -23,7 +23,7 @@ public: RigidbodyPhantomPhysicsComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; }; #endif // __RIGIDBODYPHANTOMPHYSICS_H__ diff --git a/dGame/dComponents/ShootingGalleryComponent.cpp b/dGame/dComponents/ShootingGalleryComponent.cpp index 45cd9342..20665a01 100644 --- a/dGame/dComponents/ShootingGalleryComponent.cpp +++ b/dGame/dComponents/ShootingGalleryComponent.cpp @@ -17,50 +17,50 @@ void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryPara Game::entityManager->SerializeEntity(m_Parent); } -void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) { +void ShootingGalleryComponent::Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) { // Start ScriptedActivityComponent - outBitStream->Write(true); + outBitStream.Write(true); if (m_CurrentPlayerID == LWOOBJID_EMPTY) { - outBitStream->Write(0); + outBitStream.Write(0); } else { - outBitStream->Write(1); - outBitStream->Write(m_CurrentPlayerID); + outBitStream.Write(1); + outBitStream.Write(m_CurrentPlayerID); for (size_t i = 0; i < 10; i++) { - outBitStream->Write(0.0f); + outBitStream.Write(0.0f); } } // End ScriptedActivityComponent if (isInitialUpdate) { - outBitStream->Write(m_StaticParams.cameraPosition.GetX()); - outBitStream->Write(m_StaticParams.cameraPosition.GetY()); - outBitStream->Write(m_StaticParams.cameraPosition.GetZ()); + outBitStream.Write(m_StaticParams.cameraPosition.GetX()); + outBitStream.Write(m_StaticParams.cameraPosition.GetY()); + outBitStream.Write(m_StaticParams.cameraPosition.GetZ()); - outBitStream->Write(m_StaticParams.cameraLookatPosition.GetX()); - outBitStream->Write(m_StaticParams.cameraLookatPosition.GetY()); - outBitStream->Write(m_StaticParams.cameraLookatPosition.GetZ()); + outBitStream.Write(m_StaticParams.cameraLookatPosition.GetX()); + outBitStream.Write(m_StaticParams.cameraLookatPosition.GetY()); + outBitStream.Write(m_StaticParams.cameraLookatPosition.GetZ()); } - outBitStream->Write(m_Dirty || isInitialUpdate); + outBitStream.Write(m_Dirty || isInitialUpdate); if (m_Dirty || isInitialUpdate) { - outBitStream->Write(m_DynamicParams.cannonVelocity); - outBitStream->Write(m_DynamicParams.cannonRefireRate); - outBitStream->Write(m_DynamicParams.cannonMinDistance); + outBitStream.Write(m_DynamicParams.cannonVelocity); + outBitStream.Write(m_DynamicParams.cannonRefireRate); + outBitStream.Write(m_DynamicParams.cannonMinDistance); - outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetX()); - outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetY()); - outBitStream->Write(m_DynamicParams.cameraBarrelOffset.GetZ()); + outBitStream.Write(m_DynamicParams.cameraBarrelOffset.GetX()); + outBitStream.Write(m_DynamicParams.cameraBarrelOffset.GetY()); + outBitStream.Write(m_DynamicParams.cameraBarrelOffset.GetZ()); - outBitStream->Write(m_DynamicParams.cannonAngle); + outBitStream.Write(m_DynamicParams.cannonAngle); - outBitStream->Write(m_DynamicParams.facing.GetX()); - outBitStream->Write(m_DynamicParams.facing.GetY()); - outBitStream->Write(m_DynamicParams.facing.GetZ()); + outBitStream.Write(m_DynamicParams.facing.GetX()); + outBitStream.Write(m_DynamicParams.facing.GetY()); + outBitStream.Write(m_DynamicParams.facing.GetZ()); - outBitStream->Write(m_CurrentPlayerID); - outBitStream->Write(m_DynamicParams.cannonTimeout); - outBitStream->Write(m_DynamicParams.cannonFOV); + outBitStream.Write(m_CurrentPlayerID); + outBitStream.Write(m_DynamicParams.cannonTimeout); + outBitStream.Write(m_DynamicParams.cannonFOV); if (!isInitialUpdate) m_Dirty = false; } } diff --git a/dGame/dComponents/ShootingGalleryComponent.h b/dGame/dComponents/ShootingGalleryComponent.h index c4b8fea2..9382d87e 100644 --- a/dGame/dComponents/ShootingGalleryComponent.h +++ b/dGame/dComponents/ShootingGalleryComponent.h @@ -77,7 +77,7 @@ public: explicit ShootingGalleryComponent(Entity* parent); ~ShootingGalleryComponent(); - void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool isInitialUpdate) override; /** * Returns the static params for the shooting gallery diff --git a/dGame/dComponents/SimplePhysicsComponent.cpp b/dGame/dComponents/SimplePhysicsComponent.cpp index 3d8165dd..3b52395e 100644 --- a/dGame/dComponents/SimplePhysicsComponent.cpp +++ b/dGame/dComponents/SimplePhysicsComponent.cpp @@ -32,26 +32,26 @@ SimplePhysicsComponent::SimplePhysicsComponent(Entity* parent, uint32_t componen SimplePhysicsComponent::~SimplePhysicsComponent() { } -void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void SimplePhysicsComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { - outBitStream->Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT); - outBitStream->Write(m_ClimbableType); + outBitStream.Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT); + outBitStream.Write(m_ClimbableType); } - outBitStream->Write(m_DirtyVelocity || bIsInitialUpdate); + outBitStream.Write(m_DirtyVelocity || bIsInitialUpdate); if (m_DirtyVelocity || bIsInitialUpdate) { - outBitStream->Write(m_Velocity); - outBitStream->Write(m_AngularVelocity); + outBitStream.Write(m_Velocity); + outBitStream.Write(m_AngularVelocity); m_DirtyVelocity = false; } // Physics motion state if (m_PhysicsMotionState != 0) { - outBitStream->Write1(); - outBitStream->Write(m_PhysicsMotionState); + outBitStream.Write1(); + outBitStream.Write(m_PhysicsMotionState); } else { - outBitStream->Write0(); + outBitStream.Write0(); } PhysicsComponent::Serialize(outBitStream, bIsInitialUpdate); } diff --git a/dGame/dComponents/SimplePhysicsComponent.h b/dGame/dComponents/SimplePhysicsComponent.h index 8f92dd95..c6ef52a0 100644 --- a/dGame/dComponents/SimplePhysicsComponent.h +++ b/dGame/dComponents/SimplePhysicsComponent.h @@ -33,7 +33,7 @@ public: SimplePhysicsComponent(Entity* parent, uint32_t componentID); ~SimplePhysicsComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Returns the velocity of this entity diff --git a/dGame/dComponents/SkillComponent.cpp b/dGame/dComponents/SkillComponent.cpp index d74bb75b..329246f4 100644 --- a/dGame/dComponents/SkillComponent.cpp +++ b/dGame/dComponents/SkillComponent.cpp @@ -31,7 +31,7 @@ ProjectileSyncEntry::ProjectileSyncEntry() { std::unordered_map SkillComponent::m_skillBehaviorCache = {}; -bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream* bitStream, const LWOOBJID target, uint32_t skillID) { +bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t skillUid, RakNet::BitStream& bitStream, const LWOOBJID target, uint32_t skillID) { auto* context = new BehaviorContext(this->m_Parent->GetObjectID()); context->caster = m_Parent->GetObjectID(); @@ -51,7 +51,7 @@ bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t s return !context->failed; } -void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syncId, RakNet::BitStream* bitStream) { +void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syncId, RakNet::BitStream& bitStream) { const auto index = this->m_managedBehaviors.find(skillUid); if (index == this->m_managedBehaviors.end()) { @@ -66,7 +66,7 @@ void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syn } -void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::BitStream* bitStream, const LWOOBJID target) { +void SkillComponent::SyncPlayerProjectile(const LWOOBJID projectileId, RakNet::BitStream& bitStream, const LWOOBJID target) { auto index = -1; for (auto i = 0u; i < this->m_managedProjectiles.size(); ++i) { @@ -266,7 +266,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(const uint32_t skillId, c context->foundTarget = target != LWOOBJID_EMPTY || ignoreTarget || clientInitalized; - behavior->Calculate(context, &bitStream, { target, 0 }); + behavior->Calculate(context, bitStream, { target, 0 }); for (auto* script : CppScripts::GetEntityScripts(m_Parent)) { script->OnSkillCast(m_Parent, skillId); @@ -423,7 +423,7 @@ void SkillComponent::SyncProjectileCalculation(const ProjectileSyncEntry& entry) RakNet::BitStream bitStream{}; - behavior->Calculate(entry.context, &bitStream, entry.branchContext); + behavior->Calculate(entry.context, bitStream, entry.branchContext); DoClientProjectileImpact projectileImpact; @@ -453,7 +453,7 @@ void SkillComponent::HandleUnmanaged(const uint32_t behaviorId, const LWOOBJID t RakNet::BitStream bitStream{}; - behavior->Handle(&context, &bitStream, { target }); + behavior->Handle(&context, bitStream, { target }); } void SkillComponent::HandleUnCast(const uint32_t behaviorId, const LWOOBJID target) { @@ -474,8 +474,8 @@ SkillComponent::~SkillComponent() { Reset(); } -void SkillComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - if (bIsInitialUpdate) outBitStream->Write0(); +void SkillComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + if (bIsInitialUpdate) outBitStream.Write0(); } /// diff --git a/dGame/dComponents/SkillComponent.h b/dGame/dComponents/SkillComponent.h index 530c2a25..2acae5d7 100644 --- a/dGame/dComponents/SkillComponent.h +++ b/dGame/dComponents/SkillComponent.h @@ -64,7 +64,7 @@ public: explicit SkillComponent(Entity* parent); ~SkillComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Computes skill updates. Invokes CalculateUpdate. @@ -93,7 +93,7 @@ public: * @param bitStream the bitSteam given by the client to determine the behavior path * @param target the explicit target of the skill */ - bool CastPlayerSkill(uint32_t behaviorId, uint32_t skillUid, RakNet::BitStream* bitStream, LWOOBJID target, uint32_t skillID = 0); + bool CastPlayerSkill(uint32_t behaviorId, uint32_t skillUid, RakNet::BitStream& bitStream, LWOOBJID target, uint32_t skillID = 0); /** * Continues a player skill. Should only be called when the server receives a sync message from the client. @@ -101,7 +101,7 @@ public: * @param syncId the unique sync ID of the skill given by the client * @param bitStream the bitSteam given by the client to determine the behavior path */ - void SyncPlayerSkill(uint32_t skillUid, uint32_t syncId, RakNet::BitStream* bitStream); + void SyncPlayerSkill(uint32_t skillUid, uint32_t syncId, RakNet::BitStream& bitStream); /** * Continues a player projectile calculation. Should only be called when the server receives a projectile sync message from the client. @@ -109,7 +109,7 @@ public: * @param bitStream the bitSteam given by the client to determine the behavior path * @param target the explicit target of the target */ - void SyncPlayerProjectile(LWOOBJID projectileId, RakNet::BitStream* bitStream, LWOOBJID target); + void SyncPlayerProjectile(LWOOBJID projectileId, RakNet::BitStream& bitStream, LWOOBJID target); /** * Registers a player projectile. Should only be called when the server is computing a player projectile. diff --git a/dGame/dComponents/SoundTriggerComponent.cpp b/dGame/dComponents/SoundTriggerComponent.cpp index 34d2441c..878ce848 100644 --- a/dGame/dComponents/SoundTriggerComponent.cpp +++ b/dGame/dComponents/SoundTriggerComponent.cpp @@ -2,28 +2,28 @@ #include "Game.h" #include "Logger.h" -void MusicCue::Serialize(RakNet::BitStream* outBitStream){ - outBitStream->Write(name.size()); - outBitStream->Write(name.c_str(), name.size()); - outBitStream->Write(result); - outBitStream->Write(boredomTime); +void MusicCue::Serialize(RakNet::BitStream& outBitStream){ + outBitStream.Write(name.size()); + outBitStream.Write(name.c_str(), name.size()); + outBitStream.Write(result); + outBitStream.Write(boredomTime); } -void MusicParameter::Serialize(RakNet::BitStream* outBitStream){ - outBitStream->Write(name.size()); - outBitStream->Write(name.c_str(), name.size()); - outBitStream->Write(value); +void MusicParameter::Serialize(RakNet::BitStream& outBitStream){ + outBitStream.Write(name.size()); + outBitStream.Write(name.c_str(), name.size()); + outBitStream.Write(value); } -void GUIDResults::Serialize(RakNet::BitStream* outBitStream){ +void GUIDResults::Serialize(RakNet::BitStream& outBitStream){ guid.Serialize(outBitStream); - outBitStream->Write(result); + outBitStream.Write(result); } -void MixerProgram::Serialize(RakNet::BitStream* outBitStream){ - outBitStream->Write(name.size()); - outBitStream->Write(name.c_str(), name.size()); - outBitStream->Write(result); +void MixerProgram::Serialize(RakNet::BitStream& outBitStream){ + outBitStream.Write(name.size()); + outBitStream.Write(name.c_str(), name.size()); + outBitStream.Write(result); } SoundTriggerComponent::SoundTriggerComponent(Entity* parent) : Component(parent) { @@ -55,30 +55,30 @@ SoundTriggerComponent::SoundTriggerComponent(Entity* parent) : Component(parent) if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName)); } -void SoundTriggerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(this->m_Dirty || bIsInitialUpdate); +void SoundTriggerComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(this->m_Dirty || bIsInitialUpdate); if (this->m_Dirty || bIsInitialUpdate) { - outBitStream->Write(this->m_MusicCues.size()); + outBitStream.Write(this->m_MusicCues.size()); for (auto& musicCue : this->m_MusicCues) { musicCue.Serialize(outBitStream); } - outBitStream->Write(this->m_MusicParameters.size()); + outBitStream.Write(this->m_MusicParameters.size()); for (auto& musicParam : this->m_MusicParameters) { musicParam.Serialize(outBitStream); } - outBitStream->Write(this->m_2DAmbientSounds.size()); + outBitStream.Write(this->m_2DAmbientSounds.size()); for (auto twoDAmbientSound : this->m_2DAmbientSounds) { twoDAmbientSound.Serialize(outBitStream); } - outBitStream->Write(this->m_3DAmbientSounds.size()); + outBitStream.Write(this->m_3DAmbientSounds.size()); for (auto threeDAmbientSound : this->m_3DAmbientSounds) { threeDAmbientSound.Serialize(outBitStream); } - outBitStream->Write(this->m_MixerPrograms.size()); + outBitStream.Write(this->m_MixerPrograms.size()); for (auto& mixerProgram : this->m_MixerPrograms) { mixerProgram.Serialize(outBitStream); } diff --git a/dGame/dComponents/SoundTriggerComponent.h b/dGame/dComponents/SoundTriggerComponent.h index 48366017..2851aff1 100644 --- a/dGame/dComponents/SoundTriggerComponent.h +++ b/dGame/dComponents/SoundTriggerComponent.h @@ -17,7 +17,7 @@ struct MusicCue { this->boredomTime = boredomTime; }; - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; struct MusicParameter { @@ -29,7 +29,7 @@ struct MusicParameter { this->value = value; } - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; struct GUIDResults{ @@ -41,7 +41,7 @@ struct GUIDResults{ this->result = result; } - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; struct MixerProgram { @@ -53,7 +53,7 @@ struct MixerProgram { this->result = result; } - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); }; @@ -61,7 +61,7 @@ class SoundTriggerComponent : public Component { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER; explicit SoundTriggerComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void ActivateMusicCue(const std::string& name, float bordemTime = -1.0); void DeactivateMusicCue(const std::string& name); diff --git a/dGame/dComponents/SwitchComponent.cpp b/dGame/dComponents/SwitchComponent.cpp index 25f18a4d..e6ad6d00 100644 --- a/dGame/dComponents/SwitchComponent.cpp +++ b/dGame/dComponents/SwitchComponent.cpp @@ -21,8 +21,8 @@ SwitchComponent::~SwitchComponent() { } } -void SwitchComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(m_Active); +void SwitchComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(m_Active); } void SwitchComponent::SetActive(bool active) { diff --git a/dGame/dComponents/SwitchComponent.h b/dGame/dComponents/SwitchComponent.h index f732a8c1..862e5719 100644 --- a/dGame/dComponents/SwitchComponent.h +++ b/dGame/dComponents/SwitchComponent.h @@ -25,7 +25,7 @@ public: Entity* GetParentEntity() const; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Sets whether the switch is on or off. diff --git a/dGame/dComponents/VendorComponent.cpp b/dGame/dComponents/VendorComponent.cpp index 9e9428f7..8a26399c 100644 --- a/dGame/dComponents/VendorComponent.cpp +++ b/dGame/dComponents/VendorComponent.cpp @@ -21,11 +21,11 @@ VendorComponent::VendorComponent(Entity* parent) : Component(parent) { RefreshInventory(true); } -void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { - outBitStream->Write(bIsInitialUpdate || m_DirtyVendor); +void VendorComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { + outBitStream.Write(bIsInitialUpdate || m_DirtyVendor); if (bIsInitialUpdate || m_DirtyVendor) { - outBitStream->Write(m_HasStandardCostItems); - outBitStream->Write(m_HasMultiCostItems); + outBitStream.Write(m_HasStandardCostItems); + outBitStream.Write(m_HasMultiCostItems); if (!bIsInitialUpdate) m_DirtyVendor = false; } } diff --git a/dGame/dComponents/VendorComponent.h b/dGame/dComponents/VendorComponent.h index 9025148b..2abd3536 100644 --- a/dGame/dComponents/VendorComponent.h +++ b/dGame/dComponents/VendorComponent.h @@ -23,7 +23,7 @@ public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR; VendorComponent(Entity* parent); - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void OnUse(Entity* originator) override; void RefreshInventory(bool isCreation = false); diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 70b06293..3aab4b3d 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -271,7 +271,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System if (skill_component != nullptr) { auto bs = RakNet::BitStream(reinterpret_cast(&message.sBitStream[0]), message.sBitStream.size(), false); - skill_component->SyncPlayerProjectile(message.i64LocalID, &bs, message.i64TargetID); + skill_component->SyncPlayerProjectile(message.i64LocalID, bs, message.i64TargetID); } break; @@ -298,7 +298,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System auto* skillComponent = entity->GetComponent(); - success = skillComponent->CastPlayerSkill(behaviorId, startSkill.uiSkillHandle, &bs, startSkill.optionalTargetID, startSkill.skillID); + success = skillComponent->CastPlayerSkill(behaviorId, startSkill.uiSkillHandle, bs, startSkill.optionalTargetID, startSkill.skillID); if (success && entity->GetCharacter()) { DestroyableComponent* destComp = entity->GetComponent(); @@ -353,7 +353,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System auto* skillComponent = entity->GetComponent(); - skillComponent->SyncPlayerSkill(sync.uiSkillHandle, sync.uiBehaviorHandle, &bs); + skillComponent->SyncPlayerSkill(sync.uiSkillHandle, sync.uiBehaviorHandle, bs); } EchoSyncSkill echo = EchoSyncSkill(); diff --git a/dGame/dUtilities/GUID.cpp b/dGame/dUtilities/GUID.cpp index 50ac8b03..ac4042a0 100644 --- a/dGame/dUtilities/GUID.cpp +++ b/dGame/dUtilities/GUID.cpp @@ -13,12 +13,12 @@ GUID::GUID(const std::string& guid) { &this->data4[4], &this->data4[5], &this->data4[6], &this->data4[7]); } -void GUID::Serialize(RakNet::BitStream* outBitStream) { - outBitStream->Write(GetData1()); - outBitStream->Write(GetData2()); - outBitStream->Write(GetData3()); +void GUID::Serialize(RakNet::BitStream& outBitStream) { + outBitStream.Write(GetData1()); + outBitStream.Write(GetData2()); + outBitStream.Write(GetData3()); for (const auto& guidSubPart : GetData4()) { - outBitStream->Write(guidSubPart); + outBitStream.Write(guidSubPart); } } diff --git a/dGame/dUtilities/GUID.h b/dGame/dUtilities/GUID.h index 38e57a6a..ce6d40c1 100644 --- a/dGame/dUtilities/GUID.h +++ b/dGame/dUtilities/GUID.h @@ -7,7 +7,7 @@ class GUID { public: explicit GUID(); explicit GUID(const std::string& guid); - void Serialize(RakNet::BitStream* outBitStream); + void Serialize(RakNet::BitStream& outBitStream); uint32_t GetData1() const { return data1; diff --git a/dScripts/ScriptComponent.cpp b/dScripts/ScriptComponent.cpp index be696dc6..57e6e832 100644 --- a/dScripts/ScriptComponent.cpp +++ b/dScripts/ScriptComponent.cpp @@ -17,11 +17,11 @@ ScriptComponent::~ScriptComponent() { } -void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) { +void ScriptComponent::Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) { if (bIsInitialUpdate) { const auto& networkSettings = m_Parent->GetNetworkSettings(); auto hasNetworkSettings = !networkSettings.empty(); - outBitStream->Write(hasNetworkSettings); + outBitStream.Write(hasNetworkSettings); if (hasNetworkSettings) { @@ -35,8 +35,8 @@ void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial } // Finally write everything to the stream - outBitStream->Write(ldfData.GetNumberOfBytesUsed()); - outBitStream->Write(ldfData); + outBitStream.Write(ldfData.GetNumberOfBytesUsed()); + outBitStream.Write(ldfData); } } } diff --git a/dScripts/ScriptComponent.h b/dScripts/ScriptComponent.h index a28c9419..a1371109 100644 --- a/dScripts/ScriptComponent.h +++ b/dScripts/ScriptComponent.h @@ -24,7 +24,7 @@ public: ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false); ~ScriptComponent() override; - void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override; + void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; /** * Returns the script that's attached to this entity diff --git a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp index ff37f154..d14004ee 100644 --- a/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/DestroyableComponentTests.cpp @@ -48,7 +48,7 @@ TEST_F(DestroyableTest, PlacementNewAddComponentTest) { * Test Construction of a DestroyableComponent */ TEST_F(DestroyableTest, DestroyableComponentSerializeConstructionTest) { - destroyableComponent->Serialize(&bitStream, true); + destroyableComponent->Serialize(bitStream, true); // Assert that the full number of bits are present ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 748); { @@ -178,7 +178,7 @@ TEST_F(DestroyableTest, DestroyableComponentSerializeTest) { destroyableComponent->SetMaxHealth(1233.0f); // Now we test a serialization for correctness. - destroyableComponent->Serialize(&bitStream, false); + destroyableComponent->Serialize(bitStream, false); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 422); { // Now read in the full serialized BitStream diff --git a/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp b/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp index 896dcf5a..0116dfcc 100644 --- a/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/SimplePhysicsComponentTests.cpp @@ -30,7 +30,7 @@ protected: }; TEST_F(SimplePhysicsTest, SimplePhysicsSerializeTest) { - simplePhysicsComponent->Serialize(&bitStream, false); + simplePhysicsComponent->Serialize(bitStream, false); constexpr uint32_t sizeOfStream = 3 + BYTES_TO_BITS(3 * sizeof(NiPoint3)) + BYTES_TO_BITS(1 * sizeof(NiQuaternion)) + 1 * BYTES_TO_BITS(sizeof(uint32_t)); ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), sizeOfStream); @@ -77,7 +77,7 @@ TEST_F(SimplePhysicsTest, SimplePhysicsSerializeTest) { } TEST_F(SimplePhysicsTest, SimplePhysicsConstructionTest) { - simplePhysicsComponent->Serialize(&bitStream, true); + simplePhysicsComponent->Serialize(bitStream, true); constexpr uint32_t sizeOfStream = 4 + BYTES_TO_BITS(1 * sizeof(int32_t)) + BYTES_TO_BITS(3 * sizeof(NiPoint3)) + BYTES_TO_BITS(1 * sizeof(NiQuaternion)) + 1 * BYTES_TO_BITS(sizeof(uint32_t)); ASSERT_EQ(bitStream.GetNumberOfBitsUsed(), sizeOfStream);