chore: Make serialize actually virtual (#1156)

* Make serialize actually virtual

* fix serialize and make update virutal

* Update VendorComponent.h

* Remove flag var

* Update SoundTriggerComponent.h

---------

Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
This commit is contained in:
David Markowitz 2023-08-10 14:33:15 -07:00 committed by GitHub
parent cefdfc696a
commit 2cc13c6499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
69 changed files with 113 additions and 141 deletions

View File

@ -1020,62 +1020,60 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
*/ */
bool destroyableSerialized = false; bool destroyableSerialized = false;
bool bIsInitialUpdate = false; bool bIsInitialUpdate = packetType == eReplicaPacketType::CONSTRUCTION;
if (packetType == eReplicaPacketType::CONSTRUCTION) bIsInitialUpdate = true;
unsigned int flags = 0;
PossessableComponent* possessableComponent; PossessableComponent* possessableComponent;
if (TryGetComponent(eReplicaComponentType::POSSESSABLE, possessableComponent)) { if (TryGetComponent(eReplicaComponentType::POSSESSABLE, possessableComponent)) {
possessableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); possessableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ModuleAssemblyComponent* moduleAssemblyComponent; ModuleAssemblyComponent* moduleAssemblyComponent;
if (TryGetComponent(eReplicaComponentType::MODULE_ASSEMBLY, moduleAssemblyComponent)) { if (TryGetComponent(eReplicaComponentType::MODULE_ASSEMBLY, moduleAssemblyComponent)) {
moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate, flags); moduleAssemblyComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ControllablePhysicsComponent* controllablePhysicsComponent; ControllablePhysicsComponent* controllablePhysicsComponent;
if (TryGetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS, controllablePhysicsComponent)) {
controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); controllablePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SimplePhysicsComponent* simplePhysicsComponent; SimplePhysicsComponent* simplePhysicsComponent;
if (TryGetComponent(eReplicaComponentType::SIMPLE_PHYSICS, simplePhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::SIMPLE_PHYSICS, simplePhysicsComponent)) {
simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); simplePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysics; RigidbodyPhantomPhysicsComponent* rigidbodyPhantomPhysics;
if (TryGetComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, rigidbodyPhantomPhysics)) { if (TryGetComponent(eReplicaComponentType::RIGID_BODY_PHANTOM_PHYSICS, rigidbodyPhantomPhysics)) {
rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate, flags); rigidbodyPhantomPhysics->Serialize(outBitStream, bIsInitialUpdate);
} }
VehiclePhysicsComponent* vehiclePhysicsComponent; VehiclePhysicsComponent* vehiclePhysicsComponent;
if (TryGetComponent(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::VEHICLE_PHYSICS, vehiclePhysicsComponent)) {
vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); vehiclePhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
PhantomPhysicsComponent* phantomPhysicsComponent; PhantomPhysicsComponent* phantomPhysicsComponent;
if (TryGetComponent(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysicsComponent)) { if (TryGetComponent(eReplicaComponentType::PHANTOM_PHYSICS, phantomPhysicsComponent)) {
phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate, flags); phantomPhysicsComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SoundTriggerComponent* soundTriggerComponent; SoundTriggerComponent* soundTriggerComponent;
if (TryGetComponent(eReplicaComponentType::SOUND_TRIGGER, soundTriggerComponent)) { if (TryGetComponent(eReplicaComponentType::SOUND_TRIGGER, soundTriggerComponent)) {
soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); soundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RacingSoundTriggerComponent* racingSoundTriggerComponent; RacingSoundTriggerComponent* racingSoundTriggerComponent;
if (TryGetComponent(eReplicaComponentType::RACING_SOUND_TRIGGER, racingSoundTriggerComponent)) { if (TryGetComponent(eReplicaComponentType::RACING_SOUND_TRIGGER, racingSoundTriggerComponent)) {
racingSoundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); racingSoundTriggerComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
BuffComponent* buffComponent; BuffComponent* buffComponent;
if (TryGetComponent(eReplicaComponentType::BUFF, buffComponent)) { if (TryGetComponent(eReplicaComponentType::BUFF, buffComponent)) {
buffComponent->Serialize(outBitStream, bIsInitialUpdate, flags); buffComponent->Serialize(outBitStream, bIsInitialUpdate);
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
destroyableSerialized = true; destroyableSerialized = true;
} }
@ -1083,7 +1081,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
if (HasComponent(eReplicaComponentType::COLLECTIBLE)) { if (HasComponent(eReplicaComponentType::COLLECTIBLE)) {
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
destroyableSerialized = true; destroyableSerialized = true;
outBitStream->Write(m_CollectibleID); // Collectable component outBitStream->Write(m_CollectibleID); // Collectable component
@ -1091,7 +1089,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
PetComponent* petComponent; PetComponent* petComponent;
if (TryGetComponent(eReplicaComponentType::PET, petComponent)) { if (TryGetComponent(eReplicaComponentType::PET, petComponent)) {
petComponent->Serialize(outBitStream, bIsInitialUpdate, flags); petComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
CharacterComponent* characterComponent; CharacterComponent* characterComponent;
@ -1099,7 +1097,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
PossessorComponent* possessorComponent; PossessorComponent* possessorComponent;
if (TryGetComponent(eReplicaComponentType::POSSESSOR, possessorComponent)) { if (TryGetComponent(eReplicaComponentType::POSSESSOR, possessorComponent)) {
possessorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); possessorComponent->Serialize(outBitStream, bIsInitialUpdate);
} else { } else {
// Should never happen, but just to be safe // Should never happen, but just to be safe
outBitStream->Write0(); outBitStream->Write0();
@ -1107,7 +1105,7 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
LevelProgressionComponent* levelProgressionComponent; LevelProgressionComponent* levelProgressionComponent;
if (TryGetComponent(eReplicaComponentType::LEVEL_PROGRESSION, levelProgressionComponent)) { if (TryGetComponent(eReplicaComponentType::LEVEL_PROGRESSION, levelProgressionComponent)) {
levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate, flags); levelProgressionComponent->Serialize(outBitStream, bIsInitialUpdate);
} else { } else {
// Should never happen, but just to be safe // Should never happen, but just to be safe
outBitStream->Write0(); outBitStream->Write0();
@ -1115,13 +1113,13 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
PlayerForcedMovementComponent* playerForcedMovementComponent; PlayerForcedMovementComponent* playerForcedMovementComponent;
if (TryGetComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, playerForcedMovementComponent)) { if (TryGetComponent(eReplicaComponentType::PLAYER_FORCED_MOVEMENT, playerForcedMovementComponent)) {
playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate, flags); playerForcedMovementComponent->Serialize(outBitStream, bIsInitialUpdate);
} else { } else {
// Should never happen, but just to be safe // Should never happen, but just to be safe
outBitStream->Write0(); outBitStream->Write0();
} }
characterComponent->Serialize(outBitStream, bIsInitialUpdate, flags); characterComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
if (HasComponent(eReplicaComponentType::ITEM)) { if (HasComponent(eReplicaComponentType::ITEM)) {
@ -1130,93 +1128,93 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
InventoryComponent* inventoryComponent; InventoryComponent* inventoryComponent;
if (TryGetComponent(eReplicaComponentType::INVENTORY, inventoryComponent)) { if (TryGetComponent(eReplicaComponentType::INVENTORY, inventoryComponent)) {
inventoryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); inventoryComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ScriptComponent* scriptComponent; ScriptComponent* scriptComponent;
if (TryGetComponent(eReplicaComponentType::SCRIPT, scriptComponent)) { if (TryGetComponent(eReplicaComponentType::SCRIPT, scriptComponent)) {
scriptComponent->Serialize(outBitStream, bIsInitialUpdate, flags); scriptComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SkillComponent* skillComponent; SkillComponent* skillComponent;
if (TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) { if (TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) {
skillComponent->Serialize(outBitStream, bIsInitialUpdate, flags); skillComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
BaseCombatAIComponent* baseCombatAiComponent; BaseCombatAIComponent* baseCombatAiComponent;
if (TryGetComponent(eReplicaComponentType::BASE_COMBAT_AI, baseCombatAiComponent)) { if (TryGetComponent(eReplicaComponentType::BASE_COMBAT_AI, baseCombatAiComponent)) {
baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate, flags); baseCombatAiComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RebuildComponent* rebuildComponent; RebuildComponent* rebuildComponent;
if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) { if (TryGetComponent(eReplicaComponentType::QUICK_BUILD, rebuildComponent)) {
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
destroyableSerialized = true; destroyableSerialized = true;
rebuildComponent->Serialize(outBitStream, bIsInitialUpdate, flags); rebuildComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
MovingPlatformComponent* movingPlatformComponent; MovingPlatformComponent* movingPlatformComponent;
if (TryGetComponent(eReplicaComponentType::MOVING_PLATFORM, movingPlatformComponent)) { if (TryGetComponent(eReplicaComponentType::MOVING_PLATFORM, movingPlatformComponent)) {
movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate, flags); movingPlatformComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
SwitchComponent* switchComponent; SwitchComponent* switchComponent;
if (TryGetComponent(eReplicaComponentType::SWITCH, switchComponent)) { if (TryGetComponent(eReplicaComponentType::SWITCH, switchComponent)) {
switchComponent->Serialize(outBitStream, bIsInitialUpdate, flags); switchComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
VendorComponent* vendorComponent; VendorComponent* vendorComponent;
if (TryGetComponent(eReplicaComponentType::VENDOR, vendorComponent)) { if (TryGetComponent(eReplicaComponentType::VENDOR, vendorComponent)) {
vendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); vendorComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
DonationVendorComponent* donationVendorComponent; DonationVendorComponent* donationVendorComponent;
if (TryGetComponent(eReplicaComponentType::DONATION_VENDOR, donationVendorComponent)) { if (TryGetComponent(eReplicaComponentType::DONATION_VENDOR, donationVendorComponent)) {
donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate, flags); donationVendorComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
BouncerComponent* bouncerComponent; BouncerComponent* bouncerComponent;
if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) { if (TryGetComponent(eReplicaComponentType::BOUNCER, bouncerComponent)) {
bouncerComponent->Serialize(outBitStream, bIsInitialUpdate, flags); bouncerComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ScriptedActivityComponent* scriptedActivityComponent; ScriptedActivityComponent* scriptedActivityComponent;
if (TryGetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY, scriptedActivityComponent)) { if (TryGetComponent(eReplicaComponentType::SCRIPTED_ACTIVITY, scriptedActivityComponent)) {
scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate, flags); scriptedActivityComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ShootingGalleryComponent* shootingGalleryComponent; ShootingGalleryComponent* shootingGalleryComponent;
if (TryGetComponent(eReplicaComponentType::SHOOTING_GALLERY, shootingGalleryComponent)) { if (TryGetComponent(eReplicaComponentType::SHOOTING_GALLERY, shootingGalleryComponent)) {
shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate, flags); shootingGalleryComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RacingControlComponent* racingControlComponent; RacingControlComponent* racingControlComponent;
if (TryGetComponent(eReplicaComponentType::RACING_CONTROL, racingControlComponent)) { if (TryGetComponent(eReplicaComponentType::RACING_CONTROL, racingControlComponent)) {
racingControlComponent->Serialize(outBitStream, bIsInitialUpdate, flags); racingControlComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
LUPExhibitComponent* lupExhibitComponent; LUPExhibitComponent* lupExhibitComponent;
if (TryGetComponent(eReplicaComponentType::LUP_EXHIBIT, lupExhibitComponent)) { if (TryGetComponent(eReplicaComponentType::LUP_EXHIBIT, lupExhibitComponent)) {
lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate, flags); lupExhibitComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
ModelComponent* modelComponent; ModelComponent* modelComponent;
if (TryGetComponent(eReplicaComponentType::MODEL, modelComponent)) { if (TryGetComponent(eReplicaComponentType::MODEL, modelComponent)) {
modelComponent->Serialize(outBitStream, bIsInitialUpdate, flags); modelComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
RenderComponent* renderComponent; RenderComponent* renderComponent;
if (TryGetComponent(eReplicaComponentType::RENDER, renderComponent)) { if (TryGetComponent(eReplicaComponentType::RENDER, renderComponent)) {
renderComponent->Serialize(outBitStream, bIsInitialUpdate, flags); renderComponent->Serialize(outBitStream, bIsInitialUpdate);
} }
if (modelComponent) { if (modelComponent) {
DestroyableComponent* destroyableComponent; DestroyableComponent* destroyableComponent;
if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) { if (TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent) && !destroyableSerialized) {
destroyableComponent->Serialize(outBitStream, bIsInitialUpdate, flags); destroyableComponent->Serialize(outBitStream, bIsInitialUpdate);
destroyableSerialized = true; destroyableSerialized = true;
} }
} }
@ -1231,10 +1229,6 @@ void Entity::WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType
outBitStream->Write0(); outBitStream->Write0();
} }
void Entity::ResetFlags() {
// Unused
}
void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) { void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) {
//This function should only ever be called from within Character, meaning doc should always exist when this is called. //This function should only ever be called from within Character, meaning doc should always exist when this is called.
//Naturally, we don't include any non-player components in this update function. //Naturally, we don't include any non-player components in this update function.

View File

@ -174,7 +174,6 @@ public:
void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType); void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
void ResetFlags();
void UpdateXMLDoc(tinyxml2::XMLDocument* doc); void UpdateXMLDoc(tinyxml2::XMLDocument* doc);
void Update(float deltaTime); void Update(float deltaTime);

View File

@ -583,12 +583,6 @@ bool EntityManager::GetGhostingEnabled() const {
return m_GhostingEnabled; return m_GhostingEnabled;
} }
void EntityManager::ResetFlags() {
for (const auto& e : m_Entities) {
e.second->ResetFlags();
}
}
void EntityManager::ScheduleForKill(Entity* entity) { void EntityManager::ScheduleForKill(Entity* entity) {
// Deactivate switches if they die // Deactivate switches if they die
if (!entity) if (!entity)

View File

@ -59,8 +59,6 @@ public:
Entity* GetGhostCandidate(int32_t id); Entity* GetGhostCandidate(int32_t id);
bool GetGhostingEnabled() const; bool GetGhostingEnabled() const;
void ResetFlags();
void ScheduleForKill(Entity* entity); void ScheduleForKill(Entity* entity);
void ScheduleForDeletion(LWOOBJID entity); void ScheduleForDeletion(LWOOBJID entity);

View File

@ -520,7 +520,7 @@ bool BaseCombatAIComponent::IsMech() {
} }
void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void BaseCombatAIComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate); outBitStream->Write(m_DirtyStateOrTarget || bIsInitialUpdate);
if (m_DirtyStateOrTarget || bIsInitialUpdate) { if (m_DirtyStateOrTarget || bIsInitialUpdate) {
outBitStream->Write(uint32_t(m_State)); outBitStream->Write(uint32_t(m_State));

View File

@ -53,7 +53,7 @@ public:
~BaseCombatAIComponent() override; ~BaseCombatAIComponent() override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Get the current behavioral state of the enemy * Get the current behavioral state of the enemy

View File

@ -22,7 +22,7 @@ BouncerComponent::BouncerComponent(Entity* parent) : Component(parent) {
BouncerComponent::~BouncerComponent() { BouncerComponent::~BouncerComponent() {
} }
void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void BouncerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_PetEnabled); outBitStream->Write(m_PetEnabled);
if (m_PetEnabled) { if (m_PetEnabled) {
outBitStream->Write(m_PetBouncerEnabled); outBitStream->Write(m_PetBouncerEnabled);

View File

@ -17,7 +17,7 @@ public:
BouncerComponent(Entity* parentEntity); BouncerComponent(Entity* parentEntity);
~BouncerComponent() override; ~BouncerComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
Entity* GetParentEntity() const; Entity* GetParentEntity() const;

View File

@ -20,7 +20,7 @@ BuffComponent::BuffComponent(Entity* parent) : Component(parent) {
BuffComponent::~BuffComponent() { BuffComponent::~BuffComponent() {
} }
void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void BuffComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (!bIsInitialUpdate) return; if (!bIsInitialUpdate) return;
if (m_Buffs.empty()) { if (m_Buffs.empty()) {
outBitStream->Write0(); outBitStream->Write0();

View File

@ -54,7 +54,7 @@ public:
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override; void Update(float deltaTime) override;

View File

@ -70,7 +70,7 @@ bool CharacterComponent::LandingAnimDisabled(int zoneID) {
CharacterComponent::~CharacterComponent() { CharacterComponent::~CharacterComponent() {
} }
void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void CharacterComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write0(); outBitStream->Write0();

View File

@ -70,7 +70,7 @@ public:
void LoadFromXml(tinyxml2::XMLDocument* doc) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Updates the rocket configuration using a LOT string separated by commas * Updates the rocket configuration using a LOT string separated by commas

View File

@ -28,3 +28,7 @@ void Component::UpdateXml(tinyxml2::XMLDocument* doc) {
void Component::LoadFromXml(tinyxml2::XMLDocument* doc) { void Component::LoadFromXml(tinyxml2::XMLDocument* doc) {
} }
void Component::Serialize(RakNet::BitStream* outBitStream, bool isConstruction) {
}

View File

@ -43,6 +43,8 @@ public:
*/ */
virtual void LoadFromXml(tinyxml2::XMLDocument* doc); virtual void LoadFromXml(tinyxml2::XMLDocument* doc);
virtual void Serialize(RakNet::BitStream* outBitStream, bool isConstruction);
protected: protected:
/** /**

View File

@ -74,7 +74,7 @@ void ControllablePhysicsComponent::Update(float deltaTime) {
} }
void ControllablePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { 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. //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. //This is because new clients will still need to receive the position.
//if (bIsInitialUpdate) m_DirtyPosition = true; //if (bIsInitialUpdate) m_DirtyPosition = true;
@ -181,12 +181,6 @@ void ControllablePhysicsComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
m_DirtyPosition = true; m_DirtyPosition = true;
} }
void ControllablePhysicsComponent::ResetFlags() {
m_DirtyAngularVelocity = false;
m_DirtyPosition = false;
m_DirtyVelocity = false;
}
void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) { void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) {
tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char"); tinyxml2::XMLElement* character = doc->FirstChildElement("obj")->FirstChildElement("char");
if (!character) { if (!character) {

View File

@ -27,9 +27,8 @@ public:
~ControllablePhysicsComponent() override; ~ControllablePhysicsComponent() override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void LoadFromXml(tinyxml2::XMLDocument* doc) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void ResetFlags();
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;
/** /**

View File

@ -119,7 +119,7 @@ void DestroyableComponent::Reinitialize(LOT templateID) {
} }
} }
void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) { void DestroyableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write1(); // always write these on construction outBitStream->Write1(); // always write these on construction
outBitStream->Write(m_ImmuneToBasicAttackCount); outBitStream->Write(m_ImmuneToBasicAttackCount);

View File

@ -24,7 +24,7 @@ public:
DestroyableComponent(Entity* parentEntity); DestroyableComponent(Entity* parentEntity);
~DestroyableComponent() override; ~DestroyableComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void LoadFromXml(tinyxml2::XMLDocument* doc) override; void LoadFromXml(tinyxml2::XMLDocument* doc) override;
void UpdateXml(tinyxml2::XMLDocument* doc) override; void UpdateXml(tinyxml2::XMLDocument* doc) override;

View File

@ -38,8 +38,8 @@ void DonationVendorComponent::SubmitDonation(uint32_t count) {
m_DirtyDonationVendor = true; m_DirtyDonationVendor = true;
} }
void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void DonationVendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
VendorComponent::Serialize(outBitStream, bIsInitialUpdate, flags); VendorComponent::Serialize(outBitStream, bIsInitialUpdate);
outBitStream->Write(bIsInitialUpdate || m_DirtyDonationVendor); outBitStream->Write(bIsInitialUpdate || m_DirtyDonationVendor);
if (bIsInitialUpdate || m_DirtyDonationVendor) { if (bIsInitialUpdate || m_DirtyDonationVendor) {
outBitStream->Write(m_PercentComplete); outBitStream->Write(m_PercentComplete);

View File

@ -10,7 +10,7 @@ class DonationVendorComponent final : public VendorComponent {
public: public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR; inline static const eReplicaComponentType ComponentType = eReplicaComponentType::DONATION_VENDOR;
DonationVendorComponent(Entity* parent); DonationVendorComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
uint32_t GetActivityID() {return m_ActivityId;}; uint32_t GetActivityID() {return m_ActivityId;};
void SubmitDonation(uint32_t count); void SubmitDonation(uint32_t count);

View File

@ -712,7 +712,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) {
} }
} }
void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate, unsigned& flags) { void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool bIsInitialUpdate) {
if (bIsInitialUpdate || m_Dirty) { if (bIsInitialUpdate || m_Dirty) {
outBitStream->Write(true); outBitStream->Write(true);
@ -770,10 +770,6 @@ void InventoryComponent::Serialize(RakNet::BitStream* outBitStream, const bool b
outBitStream->Write(false); outBitStream->Write(false);
} }
void InventoryComponent::ResetFlags() {
m_Dirty = false;
}
void InventoryComponent::Update(float deltaTime) { void InventoryComponent::Update(float deltaTime) {
for (auto* set : m_Itemsets) { for (auto* set : m_Itemsets) {
set->Update(deltaTime); set->Update(deltaTime);

View File

@ -42,10 +42,9 @@ public:
explicit InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document = nullptr); explicit InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document = nullptr);
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void LoadXml(tinyxml2::XMLDocument* document); void LoadXml(tinyxml2::XMLDocument* document);
void UpdateXml(tinyxml2::XMLDocument* document) override; void UpdateXml(tinyxml2::XMLDocument* document) override;
void ResetFlags();
/** /**
* Returns an inventory of the specified type, if it exists * Returns an inventory of the specified type, if it exists

View File

@ -38,7 +38,7 @@ void LUPExhibitComponent::NextExhibit() {
Game::entityManager->SerializeEntity(m_Parent); Game::entityManager->SerializeEntity(m_Parent);
} }
void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags) { void LUPExhibitComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write1(); // Dirty flag? outBitStream->Write1(); // Dirty flag?
outBitStream->Write(m_Exhibit); outBitStream->Write(m_Exhibit);
} }

View File

@ -16,7 +16,7 @@ public:
LUPExhibitComponent(Entity* parent); LUPExhibitComponent(Entity* parent);
~LUPExhibitComponent(); ~LUPExhibitComponent();
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, uint32_t& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* After the timer runs out, this changes the currently exhibited LOT to the next one * After the timer runs out, this changes the currently exhibited LOT to the next one

View File

@ -37,7 +37,7 @@ void LevelProgressionComponent::LoadFromXml(tinyxml2::XMLDocument* doc) {
m_CharacterVersion = static_cast<eCharacterVersion>(characterVersion); m_CharacterVersion = static_cast<eCharacterVersion>(characterVersion);
} }
void LevelProgressionComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void LevelProgressionComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(bIsInitialUpdate || m_DirtyLevelInfo); outBitStream->Write(bIsInitialUpdate || m_DirtyLevelInfo);
if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream->Write(m_Level); if (bIsInitialUpdate || m_DirtyLevelInfo) outBitStream->Write(m_Level);
m_DirtyLevelInfo = false; m_DirtyLevelInfo = false;

View File

@ -21,7 +21,7 @@ public:
*/ */
LevelProgressionComponent(Entity* parent); LevelProgressionComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Save data from this componennt to character XML * Save data from this componennt to character XML

View File

@ -8,7 +8,7 @@ ModelComponent::ModelComponent(Entity* parent) : Component(parent) {
m_userModelID = m_Parent->GetVarAs<LWOOBJID>(u"userModelID"); m_userModelID = m_Parent->GetVarAs<LWOOBJID>(u"userModelID");
} }
void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void ModelComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
// ItemComponent Serialization. Pets do not get this serialization. // ItemComponent Serialization. Pets do not get this serialization.
if (!m_Parent->HasComponent(eReplicaComponentType::PET)) { if (!m_Parent->HasComponent(eReplicaComponentType::PET)) {
outBitStream->Write1(); outBitStream->Write1();

View File

@ -17,7 +17,7 @@ public:
ModelComponent(Entity* parent); ModelComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Returns the original position of the model * Returns the original position of the model

View File

@ -46,7 +46,7 @@ const std::u16string& ModuleAssemblyComponent::GetAssemblyPartsLOTs() const {
return m_AssemblyPartsLOTs; return m_AssemblyPartsLOTs;
} }
void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void ModuleAssemblyComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write1(); outBitStream->Write1();

View File

@ -17,7 +17,7 @@ public:
ModuleAssemblyComponent(Entity* parent); ModuleAssemblyComponent(Entity* parent);
~ModuleAssemblyComponent() override; ~ModuleAssemblyComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
/** /**

View File

@ -32,7 +32,7 @@ MoverSubComponent::MoverSubComponent(const NiPoint3& startPos) {
MoverSubComponent::~MoverSubComponent() = default; MoverSubComponent::~MoverSubComponent() = default;
void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const { void MoverSubComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write<bool>(true); outBitStream->Write<bool>(true);
outBitStream->Write<uint32_t>(static_cast<uint32_t>(mState)); outBitStream->Write<uint32_t>(static_cast<uint32_t>(mState));
@ -71,7 +71,7 @@ MovingPlatformComponent::~MovingPlatformComponent() {
delete static_cast<MoverSubComponent*>(m_MoverSubComponent); delete static_cast<MoverSubComponent*>(m_MoverSubComponent);
} }
void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
// Here we don't serialize the moving platform to let the client simulate the movement // Here we don't serialize the moving platform to let the client simulate the movement
if (!m_Serialize) { if (!m_Serialize) {
@ -112,7 +112,7 @@ void MovingPlatformComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) { if (m_MoverSubComponentType == eMoverSubComponentType::simpleMover) {
// TODO // TODO
} else { } else {
mover->Serialize(outBitStream, bIsInitialUpdate, flags); mover->Serialize(outBitStream, bIsInitialUpdate);
} }
} }
} }

View File

@ -38,7 +38,7 @@ public:
MoverSubComponent(const NiPoint3& startPos); MoverSubComponent(const NiPoint3& startPos);
~MoverSubComponent(); ~MoverSubComponent();
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const; void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate);
/** /**
* The state the platform is currently in * The state the platform is currently in
@ -111,7 +111,7 @@ public:
MovingPlatformComponent(Entity* parent, const std::string& pathName); MovingPlatformComponent(Entity* parent, const std::string& pathName);
~MovingPlatformComponent() override; ~MovingPlatformComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Stops all pathing, called when an entity starts a quick build associated with this platform * Stops all pathing, called when an entity starts a quick build associated with this platform

View File

@ -107,7 +107,7 @@ PetComponent::PetComponent(Entity* parent, uint32_t componentId): Component(pare
result.finalize(); result.finalize();
} }
void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void PetComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
const bool tamed = m_Owner != LWOOBJID_EMPTY; const bool tamed = m_Owner != LWOOBJID_EMPTY;
outBitStream->Write1(); // Always serialize as dirty for now outBitStream->Write1(); // Always serialize as dirty for now

View File

@ -26,7 +26,7 @@ public:
explicit PetComponent(Entity* parentEntity, uint32_t componentId); explicit PetComponent(Entity* parentEntity, uint32_t componentId);
~PetComponent() override; ~PetComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
/** /**

View File

@ -306,7 +306,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
m_HasCreatedPhysics = true; m_HasCreatedPhysics = true;
} }
void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_PositionInfoDirty || bIsInitialUpdate); outBitStream->Write(m_PositionInfoDirty || bIsInitialUpdate);
if (m_PositionInfoDirty || bIsInitialUpdate) { if (m_PositionInfoDirty || bIsInitialUpdate) {
outBitStream->Write(m_Position.x); outBitStream->Write(m_Position.x);
@ -348,11 +348,6 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
} }
} }
void PhantomPhysicsComponent::ResetFlags() {
m_EffectInfoDirty = false;
m_PositionInfoDirty = false;
}
void PhantomPhysicsComponent::Update(float deltaTime) { void PhantomPhysicsComponent::Update(float deltaTime) {
if (!m_dpEntity) return; if (!m_dpEntity) return;

View File

@ -32,8 +32,7 @@ public:
PhantomPhysicsComponent(Entity* parent); PhantomPhysicsComponent(Entity* parent);
~PhantomPhysicsComponent() override; ~PhantomPhysicsComponent() override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void ResetFlags();
/** /**
* Creates the physics shape for this entity based on LDF data * Creates the physics shape for this entity based on LDF data

View File

@ -6,7 +6,7 @@ PlayerForcedMovementComponent::PlayerForcedMovementComponent(Entity* parent) : C
PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {} PlayerForcedMovementComponent::~PlayerForcedMovementComponent() {}
void PlayerForcedMovementComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void PlayerForcedMovementComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyInfo || bIsInitialUpdate); outBitStream->Write(m_DirtyInfo || bIsInitialUpdate);
if (m_DirtyInfo || bIsInitialUpdate) { if (m_DirtyInfo || bIsInitialUpdate) {
outBitStream->Write(m_PlayerOnRail); outBitStream->Write(m_PlayerOnRail);

View File

@ -19,7 +19,7 @@ public:
PlayerForcedMovementComponent(Entity* parent); PlayerForcedMovementComponent(Entity* parent);
~PlayerForcedMovementComponent() override; ~PlayerForcedMovementComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* @brief Set the Player On Rail object * @brief Set the Player On Rail object

View File

@ -27,7 +27,7 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId)
result.finalize(); result.finalize();
} }
void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate); outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate);
if (m_DirtyPossessable || bIsInitialUpdate) { if (m_DirtyPossessable || bIsInitialUpdate) {
m_DirtyPossessable = false; // reset flag m_DirtyPossessable = false; // reset flag

View File

@ -18,7 +18,7 @@ public:
PossessableComponent(Entity* parentEntity, uint32_t componentId); PossessableComponent(Entity* parentEntity, uint32_t componentId);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* @brief mounts the Entity * @brief mounts the Entity

View File

@ -26,7 +26,7 @@ PossessorComponent::~PossessorComponent() {
} }
} }
void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void PossessorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_DirtyPossesor || bIsInitialUpdate); outBitStream->Write(m_DirtyPossesor || bIsInitialUpdate);
if (m_DirtyPossesor || bIsInitialUpdate) { if (m_DirtyPossesor || bIsInitialUpdate) {
m_DirtyPossesor = false; m_DirtyPossesor = false;

View File

@ -23,7 +23,7 @@ public:
PossessorComponent(Entity* parent); PossessorComponent(Entity* parent);
~PossessorComponent() override; ~PossessorComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* @brief Mounts the entity * @brief Mounts the entity

View File

@ -424,9 +424,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity* player, int32_t bu
} }
} }
void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, void RacingControlComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
bool bIsInitialUpdate,
unsigned int& flags) {
// BEGIN Scripted Activity // BEGIN Scripted Activity
outBitStream->Write1(); outBitStream->Write1();

View File

@ -110,8 +110,8 @@ public:
RacingControlComponent(Entity* parentEntity); RacingControlComponent(Entity* parentEntity);
~RacingControlComponent(); ~RacingControlComponent();
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime); void Update(float deltaTime) override;
/** /**
* Invoked when a player loads into the zone. * Invoked when a player loads into the zone.

View File

@ -57,7 +57,7 @@ RebuildComponent::~RebuildComponent() {
DespawnActivator(); DespawnActivator();
} }
void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) { if (m_Parent->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write(false); outBitStream->Write(false);

View File

@ -27,7 +27,7 @@ public:
RebuildComponent(Entity* entity); RebuildComponent(Entity* entity);
~RebuildComponent() override; ~RebuildComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
/** /**

View File

@ -54,7 +54,7 @@ RenderComponent::~RenderComponent() {
m_Effects.clear(); m_Effects.clear();
} }
void RenderComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void RenderComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (!bIsInitialUpdate) return; if (!bIsInitialUpdate) return;
outBitStream->Write<uint32_t>(m_Effects.size()); outBitStream->Write<uint32_t>(m_Effects.size());

View File

@ -61,7 +61,7 @@ public:
RenderComponent(Entity* entity, int32_t componentId = -1); RenderComponent(Entity* entity, int32_t componentId = -1);
~RenderComponent() override; ~RenderComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
/** /**

View File

@ -15,7 +15,7 @@ RigidbodyPhantomPhysicsComponent::RigidbodyPhantomPhysicsComponent(Entity* paren
RigidbodyPhantomPhysicsComponent::~RigidbodyPhantomPhysicsComponent() { RigidbodyPhantomPhysicsComponent::~RigidbodyPhantomPhysicsComponent() {
} }
void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void RigidbodyPhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_IsDirty || bIsInitialUpdate); outBitStream->Write(m_IsDirty || bIsInitialUpdate);
if (m_IsDirty || bIsInitialUpdate) { if (m_IsDirty || bIsInitialUpdate) {
outBitStream->Write(m_Position.x); outBitStream->Write(m_Position.x);

View File

@ -24,7 +24,7 @@ public:
RigidbodyPhantomPhysicsComponent(Entity* parent); RigidbodyPhantomPhysicsComponent(Entity* parent);
~RigidbodyPhantomPhysicsComponent() override; ~RigidbodyPhantomPhysicsComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Returns the position of this entity * Returns the position of this entity

View File

@ -82,7 +82,7 @@ ScriptedActivityComponent::ScriptedActivityComponent(Entity* parent, int activit
ScriptedActivityComponent::~ScriptedActivityComponent() ScriptedActivityComponent::~ScriptedActivityComponent()
= default; = default;
void ScriptedActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const { void ScriptedActivityComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(true); outBitStream->Write(true);
outBitStream->Write<uint32_t>(m_ActivityPlayers.size()); outBitStream->Write<uint32_t>(m_ActivityPlayers.size());

View File

@ -162,7 +162,7 @@ public:
~ScriptedActivityComponent() override; ~ScriptedActivityComponent() override;
void Update(float deltaTime) override; void Update(float deltaTime) override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) const; 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 * Makes some entity join the minigame, if it's a lobbied one, the entity will be placed in the lobby

View File

@ -17,7 +17,7 @@ void ShootingGalleryComponent::SetDynamicParams(const DynamicShootingGalleryPara
Game::entityManager->SerializeEntity(m_Parent); Game::entityManager->SerializeEntity(m_Parent);
} }
void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const { void ShootingGalleryComponent::Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) {
// Start ScriptedActivityComponent // Start ScriptedActivityComponent
outBitStream->Write<bool>(true); outBitStream->Write<bool>(true);
if (m_CurrentPlayerID == LWOOBJID_EMPTY) { if (m_CurrentPlayerID == LWOOBJID_EMPTY) {

View File

@ -77,7 +77,7 @@ public:
explicit ShootingGalleryComponent(Entity* parent); explicit ShootingGalleryComponent(Entity* parent);
~ShootingGalleryComponent(); ~ShootingGalleryComponent();
void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate, uint32_t& flags) const; void Serialize(RakNet::BitStream* outBitStream, bool isInitialUpdate) override;
/** /**
* Returns the static params for the shooting gallery * Returns the static params for the shooting gallery

View File

@ -33,7 +33,7 @@ SimplePhysicsComponent::SimplePhysicsComponent(uint32_t componentID, Entity* par
SimplePhysicsComponent::~SimplePhysicsComponent() { SimplePhysicsComponent::~SimplePhysicsComponent() {
} }
void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void SimplePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
outBitStream->Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT); outBitStream->Write(m_ClimbableType != eClimbableType::CLIMBABLE_TYPE_NOT);
outBitStream->Write(m_ClimbableType); outBitStream->Write(m_ClimbableType);

View File

@ -33,7 +33,7 @@ public:
SimplePhysicsComponent(uint32_t componentID, Entity* parent); SimplePhysicsComponent(uint32_t componentID, Entity* parent);
~SimplePhysicsComponent() override; ~SimplePhysicsComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Returns the position of this entity * Returns the position of this entity

View File

@ -485,7 +485,7 @@ SkillComponent::~SkillComponent() {
Reset(); Reset();
} }
void SkillComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void SkillComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) outBitStream->Write0(); if (bIsInitialUpdate) outBitStream->Write0();
} }

View File

@ -64,7 +64,7 @@ public:
explicit SkillComponent(Entity* parent); explicit SkillComponent(Entity* parent);
~SkillComponent() override; ~SkillComponent() override;
static void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Computes skill updates. Invokes CalculateUpdate. * Computes skill updates. Invokes CalculateUpdate.

View File

@ -55,7 +55,7 @@ SoundTriggerComponent::SoundTriggerComponent(Entity* parent) : Component(parent)
if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName)); if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName));
} }
void SoundTriggerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void SoundTriggerComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(this->m_Dirty || bIsInitialUpdate); outBitStream->Write(this->m_Dirty || bIsInitialUpdate);
if (this->m_Dirty || bIsInitialUpdate) { if (this->m_Dirty || bIsInitialUpdate) {
outBitStream->Write<uint8_t>(this->m_MusicCues.size()); outBitStream->Write<uint8_t>(this->m_MusicCues.size());

View File

@ -59,9 +59,8 @@ struct MixerProgram{
class SoundTriggerComponent : public Component { class SoundTriggerComponent : public Component {
public: public:
static const eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER; static const eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER;
explicit SoundTriggerComponent(Entity* parent); explicit SoundTriggerComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void ActivateMusicCue(const std::string& name, float bordemTime = -1.0); void ActivateMusicCue(const std::string& name, float bordemTime = -1.0);
void DeactivateMusicCue(const std::string& name); void DeactivateMusicCue(const std::string& name);

View File

@ -21,7 +21,7 @@ SwitchComponent::~SwitchComponent() {
} }
} }
void SwitchComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void SwitchComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(m_Active); outBitStream->Write(m_Active);
} }

View File

@ -25,7 +25,7 @@ public:
Entity* GetParentEntity() const; Entity* GetParentEntity() const;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Sets whether the switch is on or off. * Sets whether the switch is on or off.

View File

@ -72,7 +72,7 @@ void VehiclePhysicsComponent::SetDirtyAngularVelocity(bool val) {
m_DirtyAngularVelocity = val; m_DirtyAngularVelocity = val;
} }
void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void VehiclePhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(bIsInitialUpdate || m_DirtyPosition); outBitStream->Write(bIsInitialUpdate || m_DirtyPosition);
if (bIsInitialUpdate || m_DirtyPosition) { if (bIsInitialUpdate || m_DirtyPosition) {

View File

@ -33,7 +33,7 @@ public:
VehiclePhysicsComponent(Entity* parentEntity); VehiclePhysicsComponent(Entity* parentEntity);
~VehiclePhysicsComponent() override; ~VehiclePhysicsComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void Update(float deltaTime) override; void Update(float deltaTime) override;

View File

@ -16,7 +16,7 @@ VendorComponent::VendorComponent(Entity* parent) : Component(parent) {
RefreshInventory(true); RefreshInventory(true);
} }
void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void VendorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
outBitStream->Write(bIsInitialUpdate || m_DirtyVendor); outBitStream->Write(bIsInitialUpdate || m_DirtyVendor);
if (bIsInitialUpdate || m_DirtyVendor) { if (bIsInitialUpdate || m_DirtyVendor) {
outBitStream->Write(m_HasStandardCostItems); outBitStream->Write(m_HasStandardCostItems);

View File

@ -22,7 +22,9 @@ class VendorComponent : public Component {
public: public:
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR; inline static const eReplicaComponentType ComponentType = eReplicaComponentType::VENDOR;
VendorComponent(Entity* parent); VendorComponent(Entity* parent);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
void OnUse(Entity* originator) override; void OnUse(Entity* originator) override;
void RefreshInventory(bool isCreation = false); void RefreshInventory(bool isCreation = false);
void SetupConstants(); void SetupConstants();

View File

@ -17,7 +17,7 @@ ScriptComponent::~ScriptComponent() {
} }
void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { void ScriptComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) {
if (bIsInitialUpdate) { if (bIsInitialUpdate) {
const auto& networkSettings = m_Parent->GetNetworkSettings(); const auto& networkSettings = m_Parent->GetNetworkSettings();
auto hasNetworkSettings = !networkSettings.empty(); auto hasNetworkSettings = !networkSettings.empty();

View File

@ -24,7 +24,7 @@ public:
ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false); ScriptComponent(Entity* parent, std::string scriptName, bool serialized, bool client = false);
~ScriptComponent() override; ~ScriptComponent() override;
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
/** /**
* Returns the script that's attached to this entity * Returns the script that's attached to this entity

View File

@ -41,7 +41,7 @@ protected:
* Test Construction of a DestroyableComponent * Test Construction of a DestroyableComponent
*/ */
TEST_F(DestroyableTest, DestroyableComponentSerializeConstructionTest) { TEST_F(DestroyableTest, DestroyableComponentSerializeConstructionTest) {
destroyableComponent->Serialize(&bitStream, true, flags); destroyableComponent->Serialize(&bitStream, true);
// Assert that the full number of bits are present // Assert that the full number of bits are present
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 748); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 748);
{ {
@ -171,7 +171,7 @@ TEST_F(DestroyableTest, DestroyableComponentSerializeTest) {
destroyableComponent->SetMaxHealth(1233.0f); destroyableComponent->SetMaxHealth(1233.0f);
// Now we test a serialization for correctness. // Now we test a serialization for correctness.
destroyableComponent->Serialize(&bitStream, false, flags); destroyableComponent->Serialize(&bitStream, false);
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 422); ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 422);
{ {
// Now read in the full serialized BitStream // Now read in the full serialized BitStream