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