From 5be9146662d8e120813dc476b3e2f9336b0d7f13 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Mon, 12 Jun 2023 04:00:44 -0700 Subject: [PATCH] Specify auto ptr --- dGame/Entity.cpp | 70 +++++++++++----------- dGame/Entity.tcc | 2 +- dGame/dComponents/DestroyableComponent.cpp | 2 +- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index 57367616..d319eb7b 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -593,7 +593,7 @@ std::vector Entity::GetScriptComponents() { void Entity::Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) { if (notificationName == "HitOrHealResult" || notificationName == "Hit") { - auto destroyableComponent = GetComponent(); + auto* destroyableComponent = GetComponent(); if (!destroyableComponent) return; destroyableComponent->Subscribe(scriptObjId, scriptToAdd); } @@ -601,7 +601,7 @@ void Entity::Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptTo void Entity::Unsubscribe(const LWOOBJID& scriptObjId, const std::string& notificationName) { if (notificationName == "HitOrHealResult" || notificationName == "Hit") { - auto destroyableComponent = GetComponent(); + auto* destroyableComponent = GetComponent(); if (!destroyableComponent) return; destroyableComponent->Unsubscribe(scriptObjId); } @@ -627,7 +627,7 @@ void Entity::SetGMLevel(eGameMasterLevel value) { } } - auto character = GetComponent(); + auto* character = GetComponent(); if (character) character->SetGMLevel(value); GameMessages::SendGMLevelBroadcast(m_ObjectID, value); @@ -699,7 +699,7 @@ void Entity::WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacke outBitStream->Write0(); //No ldf data } - auto triggerComponent = GetComponent(); + auto* triggerComponent = GetComponent(); if (triggerComponent) { // has trigger component, check to see if we have events to handle auto* trigger = triggerComponent->GetTrigger(); @@ -841,7 +841,7 @@ void Entity::OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxN script->OnProximityUpdate(this, other, proxName, status); } - auto rocketComp = GetComponent(); + auto* rocketComp = GetComponent(); if (!rocketComp) return; rocketComp->OnProximityUpdate(other, proxName, status); @@ -859,7 +859,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { callback(other); } - auto switchComp = GetComponent(); + auto* switchComp = GetComponent(); if (switchComp) { switchComp->EntityEnter(other); } @@ -878,7 +878,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { } if (!other->GetIsDead()) { - auto combat = GetComponent(); + auto* combat = GetComponent(); if (combat != nullptr) { const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity); @@ -904,7 +904,7 @@ void Entity::OnCollisionLeavePhantom(const LWOOBJID otherEntity) { TriggerEvent(eTriggerEventType::EXIT, other); - auto switchComp = GetComponent(); + auto* switchComp = GetComponent(); if (switchComp) { switchComp->EntityLeave(other); } @@ -1047,12 +1047,12 @@ void Entity::RequestActivityExit(Entity* sender, const LWOOBJID& player, const b void Entity::Smash(const LWOOBJID source, const eKillType killType, const std::u16string& deathType) { if (!m_PlayerIsReadyForUpdates) return; - auto destroyableComponent = GetComponent(); + auto* destroyableComponent = GetComponent(); if (destroyableComponent == nullptr) { Kill(EntityManager::Instance()->GetEntity(source)); return; } - auto possessorComponent = GetComponent(); + auto* possessorComponent = GetComponent(); if (possessorComponent) { if (possessorComponent->GetPossessable() != LWOOBJID_EMPTY) { auto* mount = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable()); @@ -1109,7 +1109,7 @@ void Entity::Kill(Entity* murderer) { } // Track a player being smashed - auto characterComponent = GetComponent(); + auto* characterComponent = GetComponent(); if (characterComponent != nullptr) { characterComponent->UpdatePlayerStatistic(TimesSmashed); } @@ -1132,14 +1132,14 @@ void Entity::AddCollisionPhantomCallback(const std::function& callback) const { - auto quickBuildComponent = GetComponent(); + auto* quickBuildComponent = GetComponent(); if (quickBuildComponent != nullptr) { quickBuildComponent->AddRebuildCompleteCallback(callback); } } bool Entity::GetIsDead() const { - auto dest = GetComponent(); + auto* dest = GetComponent(); if (dest && dest->GetArmor() == 0 && dest->GetHealth() == 0) return true; return false; @@ -1153,7 +1153,7 @@ void Entity::AddLootItem(const Loot::Info& info) { void Entity::PickupItem(const LWOOBJID& objectID) { if (!IsPlayer()) return; - auto inv = GetComponent(); + auto* inv = GetComponent(); if (!inv) return; CDObjectsTable* objectsTable = CDClientManager::Instance().GetTable(); @@ -1162,7 +1162,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { for (const auto& p : droppedLoot) { if (p.first == objectID) { - auto characterComponent = GetComponent(); + auto* characterComponent = GetComponent(); if (characterComponent != nullptr) { characterComponent->TrackLOTCollection(p.second.lot); } @@ -1177,7 +1177,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) { SkillComponent::HandleUnmanaged(behaviorData.behaviorID, GetObjectID()); - auto missionComponent = GetComponent(); + auto* missionComponent = GetComponent(); if (missionComponent != nullptr) { missionComponent->Progress(eMissionTaskType::POWERUP, skill.skillID); @@ -1302,7 +1302,7 @@ bool Entity::IsPlayer() const { } void Entity::TriggerEvent(eTriggerEventType event, Entity* optionalTarget) { - auto triggerComponent = GetComponent(); + auto* triggerComponent = GetComponent(); if (triggerComponent) triggerComponent->TriggerEvent(event, optionalTarget); } @@ -1339,7 +1339,7 @@ void Entity::SetObservers(int8_t value) { } void Entity::Sleep() { - auto baseCombatAIComponent = GetComponent(); + auto* baseCombatAIComponent = GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->Sleep(); @@ -1347,7 +1347,7 @@ void Entity::Sleep() { } void Entity::Wake() { - auto baseCombatAIComponent = GetComponent(); + auto* baseCombatAIComponent = GetComponent(); if (baseCombatAIComponent != nullptr) { baseCombatAIComponent->Wake(); @@ -1366,19 +1366,19 @@ const NiPoint3& Entity::GetPosition() const { return controllable->GetPosition(); } - auto phantom = GetComponent(); + auto* phantom = GetComponent(); if (phantom != nullptr) { return phantom->GetPosition(); } - auto simple = GetComponent(); + auto* simple = GetComponent(); if (simple != nullptr) { return simple->GetPosition(); } - auto vehicle = GetComponent(); + auto* vehicle = GetComponent(); if (vehicle != nullptr) { return vehicle->GetPosition(); @@ -1388,25 +1388,25 @@ const NiPoint3& Entity::GetPosition() const { } const NiQuaternion& Entity::GetRotation() const { - auto controllable = GetComponent(); + auto* controllable = GetComponent(); if (controllable != nullptr) { return controllable->GetRotation(); } - auto phantom = GetComponent(); + auto* phantom = GetComponent(); if (phantom != nullptr) { return phantom->GetRotation(); } - auto simple = GetComponent(); + auto* simple = GetComponent(); if (simple != nullptr) { return simple->GetRotation(); } - auto vehicle = GetComponent(); + auto* vehicle = GetComponent(); if (vehicle != nullptr) { return vehicle->GetRotation(); @@ -1416,25 +1416,25 @@ const NiQuaternion& Entity::GetRotation() const { } void Entity::SetPosition(const NiPoint3& position) { - auto controllable = GetComponent(); + auto* controllable = GetComponent(); if (controllable != nullptr) { controllable->SetPosition(position); } - auto phantom = GetComponent(); + auto* phantom = GetComponent(); if (phantom != nullptr) { phantom->SetPosition(position); } - auto simple = GetComponent(); + auto* simple = GetComponent(); if (simple != nullptr) { simple->SetPosition(position); } - auto vehicle = GetComponent(); + auto* vehicle = GetComponent(); if (vehicle != nullptr) { vehicle->SetPosition(position); @@ -1444,25 +1444,25 @@ void Entity::SetPosition(const NiPoint3& position) { } void Entity::SetRotation(const NiQuaternion& rotation) { - auto controllable = GetComponent(); + auto* controllable = GetComponent(); if (controllable != nullptr) { controllable->SetRotation(rotation); } - auto phantom = GetComponent(); + auto* phantom = GetComponent(); if (phantom != nullptr) { phantom->SetRotation(rotation); } - auto simple = GetComponent(); + auto* simple = GetComponent(); if (simple != nullptr) { simple->SetRotation(rotation); } - auto vehicle = GetComponent(); + auto* vehicle = GetComponent(); if (vehicle != nullptr) { vehicle->SetRotation(rotation); @@ -1573,7 +1573,7 @@ void Entity::AddToGroups(const std::string& group) { } void Entity::RetroactiveVaultSize() { - auto inventoryComponent = GetComponent(); + auto* inventoryComponent = GetComponent(); if (!inventoryComponent) return; auto itemsVault = inventoryComponent->GetInventory(eInventoryType::VAULT_ITEMS); diff --git a/dGame/Entity.tcc b/dGame/Entity.tcc index 0fdd94bb..a5a2b8bf 100644 --- a/dGame/Entity.tcc +++ b/dGame/Entity.tcc @@ -13,7 +13,7 @@ Cmpt* Entity::GetComponent() const { template Cmpt* Entity::AddComponent(ConstructorValues...arguments) { - auto component = GetComponent(); + auto* component = GetComponent(); if (component) return dynamic_cast(component); auto& insertedComponent = m_Components.insert_or_assign(Cmpt::ComponentType, diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 3be0ce0c..ccd35797 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -732,7 +732,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType auto* team = TeamManager::Instance()->GetTeam(owner->GetObjectID()); - const auto isEnemy = m_ParentEntity->GetComponent() != nullptr; + const auto* isEnemy = m_ParentEntity->GetComponent() != nullptr; auto* inventoryComponent = owner->GetComponent();