From f555ba8c254311b6db9170a778a849420db0e56b Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Fri, 9 Jun 2023 01:28:01 -0700 Subject: [PATCH] Rename from GetOwningEntity to GetParentEntity --- dGame/dBehaviors/BasicAttackBehavior.cpp | 2 +- dGame/dComponents/BuffComponent.cpp | 18 ++++++------- dGame/dComponents/BuffComponent.h | 2 +- dGame/dComponents/Component.h | 2 +- dGame/dComponents/DestroyableComponent.cpp | 2 +- dGame/dComponents/InventoryComponent.cpp | 18 ++++++------- dGame/dComponents/PetComponent.cpp | 6 ++--- dGame/dGameMessages/GameMessages.cpp | 2 +- dGame/dInventory/Inventory.cpp | 2 +- dGame/dInventory/Item.cpp | 26 +++++++++---------- dGame/dInventory/Item.h | 2 +- dGame/dInventory/ItemSet.cpp | 12 ++++----- dGame/dMission/Mission.cpp | 2 +- dGame/dPropertyBehaviors/ControlBehaviors.cpp | 10 +++---- 14 files changed, 53 insertions(+), 53 deletions(-) diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index 08d468ef..5e0b3953 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -162,7 +162,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet } auto* destroyableComponent = targetEntity->GetComponent(); - if (!destroyableComponent || !destroyableComponent->GetOwningEntity()) { + if (!destroyableComponent || !destroyableComponent->GetParentEntity()) { Game::logger->Log("BasicAttackBehavior", "No destroyable component on %llu", branch.target); return; } diff --git a/dGame/dComponents/BuffComponent.cpp b/dGame/dComponents/BuffComponent.cpp index e121eb55..28dbd18a 100644 --- a/dGame/dComponents/BuffComponent.cpp +++ b/dGame/dComponents/BuffComponent.cpp @@ -149,7 +149,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { if (parameter.name == "max_health") { const auto maxHealth = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto* destroyable = this->GetParentEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -157,7 +157,7 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { } else if (parameter.name == "max_armor") { const auto maxArmor = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto* destroyable = this->GetParentEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -165,13 +165,13 @@ void BuffComponent::ApplyBuffEffect(int32_t id) { } else if (parameter.name == "max_imagination") { const auto maxImagination = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto* destroyable = this->GetParentEntity()->GetComponent(); if (destroyable == nullptr) return; destroyable->SetMaxImagination(destroyable->GetMaxImagination() + maxImagination); } else if (parameter.name == "speed") { - auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); + auto* controllablePhysicsComponent = this->GetParentEntity()->GetComponent(); if (!controllablePhysicsComponent) return; const auto speed = parameter.value; controllablePhysicsComponent->AddSpeedboost(speed); @@ -185,7 +185,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { if (parameter.name == "max_health") { const auto maxHealth = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto* destroyable = this->GetParentEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -193,7 +193,7 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { } else if (parameter.name == "max_armor") { const auto maxArmor = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto* destroyable = this->GetParentEntity()->GetComponent(); if (destroyable == nullptr) return; @@ -201,13 +201,13 @@ void BuffComponent::RemoveBuffEffect(int32_t id) { } else if (parameter.name == "max_imagination") { const auto maxImagination = parameter.value; - auto* destroyable = this->GetOwningEntity()->GetComponent(); + auto* destroyable = this->GetParentEntity()->GetComponent(); if (destroyable == nullptr) return; destroyable->SetMaxImagination(destroyable->GetMaxImagination() - maxImagination); } else if (parameter.name == "speed") { - auto* controllablePhysicsComponent = this->GetOwningEntity()->GetComponent(); + auto* controllablePhysicsComponent = this->GetParentEntity()->GetComponent(); if (!controllablePhysicsComponent) return; const auto speed = parameter.value; controllablePhysicsComponent->RemoveSpeedboost(speed); @@ -233,7 +233,7 @@ void BuffComponent::ReApplyBuffs() { } } -Entity* BuffComponent::GetOwningEntity() const { +Entity* BuffComponent::GetParentEntity() const { return m_OwningEntity; } diff --git a/dGame/dComponents/BuffComponent.h b/dGame/dComponents/BuffComponent.h index 8e47261e..bbd8d785 100644 --- a/dGame/dComponents/BuffComponent.h +++ b/dGame/dComponents/BuffComponent.h @@ -48,7 +48,7 @@ public: ~BuffComponent(); - Entity* GetOwningEntity() const; + Entity* GetParentEntity() const; void LoadFromXml(tinyxml2::XMLDocument* doc) override; diff --git a/dGame/dComponents/Component.h b/dGame/dComponents/Component.h index c9690811..facf84c3 100644 --- a/dGame/dComponents/Component.h +++ b/dGame/dComponents/Component.h @@ -20,7 +20,7 @@ public: * Gets the owner of this component * @return the owner of this component */ - Entity* GetOwningEntity() const { return m_OwningEntity; }; + Entity* GetParentEntity() const { return m_OwningEntity; }; /** * Event called when this component is being used, e.g. when some entity interacted with it diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 1cc38e0b..f89be499 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -872,7 +872,7 @@ void DestroyableComponent::SetStatusImmunity( } void DestroyableComponent::FixStats() { - auto* entity = GetOwningEntity(); + auto* entity = GetParentEntity(); if (entity == nullptr) return; diff --git a/dGame/dComponents/InventoryComponent.cpp b/dGame/dComponents/InventoryComponent.cpp index bf72d14d..915f55fc 100644 --- a/dGame/dComponents/InventoryComponent.cpp +++ b/dGame/dComponents/InventoryComponent.cpp @@ -261,7 +261,7 @@ void InventoryComponent::AddItem( } if (slot == -1) { - auto* player = dynamic_cast(GetOwningEntity()); + auto* player = dynamic_cast(GetParentEntity()); if (player == nullptr) { return; @@ -687,7 +687,7 @@ void InventoryComponent::UpdateXml(tinyxml2::XMLDocument* document) { itemElement->SetAttribute("sk", item->GetSubKey()); // Begin custom xml - itemElement->SetAttribute("parent", item->GetOwningEntity()); + itemElement->SetAttribute("parent", item->GetParentEntity()); // End custom xml for (auto* data : item->GetConfig()) { @@ -913,7 +913,7 @@ void InventoryComponent::UnEquipItem(Item* item) { // Trigger property event if (PropertyManagementComponent::Instance() != nullptr && item->GetCount() > 0 && Inventory::FindInventoryTypeForLot(item->GetLot()) == MODELS) { - PropertyManagementComponent::Instance()->GetOwningEntity()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity); + PropertyManagementComponent::Instance()->GetParentEntity()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity); dZoneManager::Instance()->GetZoneControlObject()->OnZonePropertyModelRemovedWhileEquipped(m_OwningEntity); } } @@ -1356,7 +1356,7 @@ std::vector InventoryComponent::FindBuffs(Item* item, bool castOnEquip } // If item is not a proxy, add its buff to the added buffs. - if (item->GetOwningEntity() == LWOOBJID_EMPTY) buffs.push_back(static_cast(entry.behaviorID)); + if (item->GetParentEntity() == LWOOBJID_EMPTY) buffs.push_back(static_cast(entry.behaviorID)); } } @@ -1442,7 +1442,7 @@ std::vector InventoryComponent::FindProxies(const LWOOBJID parent) { for (const auto& pair : inventory->GetItems()) { auto* item = pair.second; - if (item->GetOwningEntity() == parent) { + if (item->GetParentEntity() == parent) { proxies.push_back(item); } } @@ -1479,7 +1479,7 @@ bool InventoryComponent::IsParentValid(Item* root) { for (const auto& candidate : items) { auto* item = candidate.second; - if (item->GetOwningEntity() == id) { + if (item->GetParentEntity() == id) { return true; } } @@ -1497,7 +1497,7 @@ void InventoryComponent::CheckProxyIntegrity() { for (const auto& candidate : items) { auto* item = candidate.second; - const auto parent = item->GetOwningEntity(); + const auto parent = item->GetParentEntity(); if (parent == LWOOBJID_EMPTY) { continue; @@ -1526,7 +1526,7 @@ void InventoryComponent::CheckProxyIntegrity() { { auto* item = candidate.second; - const auto parent = item->GetOwningEntity(); + const auto parent = item->GetParentEntity(); if (parent != LWOOBJID_EMPTY) { @@ -1555,7 +1555,7 @@ void InventoryComponent::CheckProxyIntegrity() { } void InventoryComponent::PurgeProxies(Item* item) { - const auto root = item->GetOwningEntity(); + const auto root = item->GetParentEntity(); if (root != LWOOBJID_EMPTY) { item = FindItemById(root); diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index fa0e6046..21af7525 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -846,7 +846,7 @@ void PetComponent::Activate(Item* item, bool registerPet, bool fromTaming) { inventoryComponent->DespawnPet(); - m_Owner = inventoryComponent->GetOwningEntity()->GetObjectID(); + m_Owner = inventoryComponent->GetParentEntity()->GetObjectID(); auto* owner = GetOwner(); @@ -910,7 +910,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { auto playerInventoryComponent = playerInventory->GetComponent(); if (!playerInventoryComponent) return; - auto playerEntity = playerInventoryComponent->GetOwningEntity(); + auto playerEntity = playerInventoryComponent->GetParentEntity(); if (!playerEntity) return; auto* playerDestroyableComponent = playerEntity->GetComponent(); @@ -929,7 +929,7 @@ void PetComponent::AddDrainImaginationTimer(Item* item, bool fromTaming) { // If we are out of imagination despawn the pet. if (playerDestroyableComponent->GetImagination() == 0) { this->Deactivate(); - auto playerEntity = playerDestroyableComponent->GetOwningEntity(); + auto playerEntity = playerDestroyableComponent->GetParentEntity(); if (!playerEntity) return; GameMessages::SendUseItemRequirementsResponse(playerEntity->GetObjectID(), playerEntity->GetSystemAddress(), eUseItemResponse::NoImaginationForPet); diff --git a/dGame/dGameMessages/GameMessages.cpp b/dGame/dGameMessages/GameMessages.cpp index 9403c5b3..40960e8f 100644 --- a/dGame/dGameMessages/GameMessages.cpp +++ b/dGame/dGameMessages/GameMessages.cpp @@ -1985,7 +1985,7 @@ void GameMessages::SendOpenPropertyManagment(const LWOOBJID objectId, const Syst CBITSTREAM; CMSGHEADER; - bitStream.Write(PropertyManagementComponent::Instance()->GetOwningEntity()->GetObjectID()); + bitStream.Write(PropertyManagementComponent::Instance()->GetParentEntity()->GetObjectID()); bitStream.Write(eGameMessageType::OPEN_PROPERTY_MANAGEMENT); if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST; diff --git a/dGame/dInventory/Inventory.cpp b/dGame/dInventory/Inventory.cpp index a528ea57..6cf2e1f0 100644 --- a/dGame/dInventory/Inventory.cpp +++ b/dGame/dInventory/Inventory.cpp @@ -76,7 +76,7 @@ void Inventory::SetSize(const uint32_t value) { size = value; - GameMessages::SendSetInventorySize(component->GetOwningEntity(), type, static_cast(size)); + GameMessages::SendSetInventorySize(component->GetParentEntity(), type, static_cast(size)); } int32_t Inventory::FindEmptySlot() { diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index c47cf520..ea6dfa05 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -92,7 +92,7 @@ Item::Item( inventory->AddManagedItem(this); - auto entity = inventory->GetComponent()->GetOwningEntity(); + auto entity = inventory->GetComponent()->GetParentEntity(); GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, static_cast(this->count), subKey, lootSourceType); if (isModMoveAndEquip) { @@ -100,7 +100,7 @@ Item::Item( Game::logger->Log("Item", "Move and equipped (%i) from (%i)", this->lot, this->inventory->GetType()); - EntityManager::Instance()->SerializeEntity(inventory->GetComponent()->GetOwningEntity()); + EntityManager::Instance()->SerializeEntity(inventory->GetComponent()->GetParentEntity()); } } @@ -136,7 +136,7 @@ Inventory* Item::GetInventory() const { return inventory; } -LWOOBJID Item::GetOwningEntity() const { +LWOOBJID Item::GetParentEntity() const { return parent; } @@ -166,7 +166,7 @@ void Item::SetCount(const uint32_t value, const bool silent, const bool disassem } if (!silent) { - auto entity = inventory->GetComponent()->GetOwningEntity(); + auto entity = inventory->GetComponent()->GetParentEntity(); if (value > count) { GameMessages::SendAddItemToInventoryClientSync(entity, entity->GetSystemAddress(), this, id, showFlyingLoot, delta, LWOOBJID_EMPTY, lootSourceType); @@ -262,7 +262,7 @@ bool Item::Consume() { Game::logger->LogDebug("Item", "Consumed LOT (%i) itemID (%llu). Success=(%d)", lot, id, success); - GameMessages::SendUseItemResult(inventory->GetComponent()->GetOwningEntity(), lot, success); + GameMessages::SendUseItemResult(inventory->GetComponent()->GetParentEntity(), lot, success); if (success) { inventory->GetComponent()->RemoveItem(lot, 1); @@ -284,7 +284,7 @@ void Item::UseNonEquip(Item* item) { return; } - auto* playerEntity = playerInventoryComponent->GetOwningEntity(); + auto* playerEntity = playerInventoryComponent->GetParentEntity(); if (!playerEntity) { Game::logger->LogDebug("Item", "no player entity attached to inventory? item id is %llu", this->GetId()); return; @@ -314,8 +314,8 @@ void Item::UseNonEquip(Item* item) { auto success = !packages.empty(); if (success) { - if (this->GetPreconditionExpression()->Check(playerInventoryComponent->GetOwningEntity())) { - auto* entityParent = playerInventoryComponent->GetOwningEntity(); + if (this->GetPreconditionExpression()->Check(playerInventoryComponent->GetParentEntity())) { + auto* entityParent = playerInventoryComponent->GetParentEntity(); // Roll the loot for all the packages then see if it all fits. If it fits, give it to the player, otherwise don't. std::unordered_map rolledLoot{}; for (auto& pack : packages) { @@ -331,15 +331,15 @@ void Item::UseNonEquip(Item* item) { } } if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) { - LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetOwningEntity(), rolledLoot, eLootSourceType::CONSUMPTION); + LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParentEntity(), rolledLoot, eLootSourceType::CONSUMPTION); item->SetCount(item->GetCount() - 1); } else { success = false; } } else { GameMessages::SendUseItemRequirementsResponse( - playerInventoryComponent->GetOwningEntity()->GetObjectID(), - playerInventoryComponent->GetOwningEntity()->GetSystemAddress(), + playerInventoryComponent->GetParentEntity()->GetObjectID(), + playerInventoryComponent->GetParentEntity()->GetSystemAddress(), eUseItemResponse::FailedPrecondition ); success = false; @@ -347,7 +347,7 @@ void Item::UseNonEquip(Item* item) { } } Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot); - GameMessages::SendUseItemResult(playerInventoryComponent->GetOwningEntity(), thisLot, success); + GameMessages::SendUseItemResult(playerInventoryComponent->GetParentEntity(), thisLot, success); } } @@ -360,7 +360,7 @@ void Item::Disassemble(const eInventoryType inventoryType) { if (GetInventory()) { auto inventoryComponent = GetInventory()->GetComponent(); if (inventoryComponent) { - auto entity = inventoryComponent->GetOwningEntity(); + auto entity = inventoryComponent->GetParentEntity(); if (entity) entity->SetVar(u"currentModifiedBuild", modStr); } } diff --git a/dGame/dInventory/Item.h b/dGame/dInventory/Item.h index 0bd28f81..722aee49 100644 --- a/dGame/dInventory/Item.h +++ b/dGame/dInventory/Item.h @@ -150,7 +150,7 @@ public: * Returns the parent of this item, e.g. for proxy items * @return the parent of this item */ - LWOOBJID GetOwningEntity() const; + LWOOBJID GetParentEntity() const; /** * Sets the subkey for this item, e.g. for pets diff --git a/dGame/dInventory/ItemSet.cpp b/dGame/dInventory/ItemSet.cpp index d29aba8e..245ede35 100644 --- a/dGame/dInventory/ItemSet.cpp +++ b/dGame/dInventory/ItemSet.cpp @@ -15,7 +15,7 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) { this->m_ID = id; this->m_InventoryComponent = inventoryComponent; - this->m_PassiveAbilities = ItemSetPassiveAbility::FindAbilities(id, m_InventoryComponent->GetOwningEntity(), this); + this->m_PassiveAbilities = ItemSetPassiveAbility::FindAbilities(id, m_InventoryComponent->GetParentEntity(), this); auto query = CDClientDatabase::CreatePreppedStmt( "SELECT skillSetWith2, skillSetWith3, skillSetWith4, skillSetWith5, skillSetWith6, itemIDs FROM ItemSets WHERE setID = ?;"); @@ -125,8 +125,8 @@ void ItemSet::OnEquip(const LOT lot) { return; } - auto* skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); - auto* missionComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); + auto* skillComponent = m_InventoryComponent->GetParentEntity()->GetComponent(); + auto* missionComponent = m_InventoryComponent->GetParentEntity()->GetComponent(); for (const auto skill : skillSet) { auto* skillTable = CDClientManager::Instance().GetTable(); @@ -135,7 +135,7 @@ void ItemSet::OnEquip(const LOT lot) { missionComponent->Progress(eMissionTaskType::USE_SKILL, skill); - skillComponent->HandleUnmanaged(behaviorId, m_InventoryComponent->GetOwningEntity()->GetObjectID()); + skillComponent->HandleUnmanaged(behaviorId, m_InventoryComponent->GetParentEntity()->GetObjectID()); } } @@ -158,14 +158,14 @@ void ItemSet::OnUnEquip(const LOT lot) { return; } - const auto* skillComponent = m_InventoryComponent->GetOwningEntity()->GetComponent(); + const auto* skillComponent = m_InventoryComponent->GetParentEntity()->GetComponent(); for (const auto skill : skillSet) { auto* skillTable = CDClientManager::Instance().GetTable(); const auto behaviorId = skillTable->GetSkillByID(skill).behaviorID; - skillComponent->HandleUnCast(behaviorId, m_InventoryComponent->GetOwningEntity()->GetObjectID()); + skillComponent->HandleUnCast(behaviorId, m_InventoryComponent->GetParentEntity()->GetObjectID()); } } diff --git a/dGame/dMission/Mission.cpp b/dGame/dMission/Mission.cpp index 07cbd629..7d84d958 100644 --- a/dGame/dMission/Mission.cpp +++ b/dGame/dMission/Mission.cpp @@ -204,7 +204,7 @@ bool Mission::IsValidMission(const uint32_t missionId, CDMissions& info) { } Entity* Mission::GetAssociate() const { - return m_MissionComponent->GetOwningEntity(); + return m_MissionComponent->GetParentEntity(); } User* Mission::GetUser() const { diff --git a/dGame/dPropertyBehaviors/ControlBehaviors.cpp b/dGame/dPropertyBehaviors/ControlBehaviors.cpp index 7e4be3e9..52c09746 100644 --- a/dGame/dPropertyBehaviors/ControlBehaviors.cpp +++ b/dGame/dPropertyBehaviors/ControlBehaviors.cpp @@ -47,11 +47,11 @@ void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelBehaviorCompone // args.InsertValue("behaviorID", behaviorIDString); // AMFStringValue* objectIDAsString = new AMFStringValue(); - // objectIDAsString->SetValue(std::to_string(modelComponent->GetOwningEntity()->GetObjectID())); + // objectIDAsString->SetValue(std::to_string(modelComponent->GetParentEntity()->GetObjectID())); // args.InsertValue("objectID", objectIDAsString); // GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorID", &args); - // ControlBehaviors::SendBehaviorListToClient(modelComponent->GetOwningEntity(), sysAddr, modelOwner); + // ControlBehaviors::SendBehaviorListToClient(modelComponent->GetParentEntity(), sysAddr, modelOwner); // }); // } } @@ -74,7 +74,7 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste */ behaviorsToSerialize.Insert("behaviors"); - behaviorsToSerialize.Insert("objectID", std::to_string(modelComponent->GetOwningEntity()->GetObjectID())); + behaviorsToSerialize.Insert("objectID", std::to_string(modelComponent->GetParentEntity()->GetObjectID())); GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize); } @@ -197,7 +197,7 @@ void ControlBehaviors::SendBehaviorBlocksToClient(ModelBehaviorComponent* modelC // uiArray->InsertValue("x", xPosition); // thisStrip->InsertValue("ui", uiArray); - // targetObjectID = modelComponent->GetOwningEntity()->GetObjectID(); + // targetObjectID = modelComponent->GetParentEntity()->GetObjectID(); // behaviorID = modelBehavior->GetBehaviorID(); // AMFArrayValue* stripSerialize = new AMFArrayValue(); @@ -276,7 +276,7 @@ void ControlBehaviors::MoveToInventory(ModelBehaviorComponent* modelComponent, c MoveToInventoryMessage moveToInventoryMessage(arguments); - SendBehaviorListToClient(modelComponent->GetOwningEntity(), sysAddr, modelOwner); + SendBehaviorListToClient(modelComponent->GetParentEntity(), sysAddr, modelOwner); } void ControlBehaviors::ProcessCommand(Entity* modelEntity, const SystemAddress& sysAddr, AMFArrayValue* arguments, std::string command, Entity* modelOwner) {