From 49880155a05e2b1d0a9d4579f4c56f2ae2c24d75 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Fri, 31 Mar 2023 22:34:38 -0500 Subject: [PATCH] address feedback --- dGame/dBehaviors/AreaOfEffectBehavior.cpp | 2 +- dGame/dBehaviors/AreaOfEffectBehavior.h | 13 +++++-------- dGame/dBehaviors/BehaviorContext.cpp | 8 ++++---- dGame/dBehaviors/BehaviorContext.h | 4 ++-- dGame/dBehaviors/TacArcBehavior.h | 11 +++++------ dGame/dUtilities/SlashCommandHandler.cpp | 2 -- docs/Commands.md | 10 +++++----- 7 files changed, 22 insertions(+), 28 deletions(-) diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.cpp b/dGame/dBehaviors/AreaOfEffectBehavior.cpp index 17201413c..a4c3caf34 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.cpp +++ b/dGame/dBehaviors/AreaOfEffectBehavior.cpp @@ -66,7 +66,7 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream if (this->m_useTargetPosition) { if (branch.target == LWOOBJID_EMPTY) return; auto branchTarget = EntityManager::Instance()->GetEntity(branch.target); - reference = branchTarget->GetPosition(); + if (branchTarget) reference = branchTarget->GetPosition(); } reference += this->m_offset; diff --git a/dGame/dBehaviors/AreaOfEffectBehavior.h b/dGame/dBehaviors/AreaOfEffectBehavior.h index 797924419..f0fbb18d3 100644 --- a/dGame/dBehaviors/AreaOfEffectBehavior.h +++ b/dGame/dBehaviors/AreaOfEffectBehavior.h @@ -5,6 +5,11 @@ class AreaOfEffectBehavior final : public Behavior { public: + explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} + void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Load() override; +private: Behavior* m_action; uint32_t m_maxTargets; float m_radius; @@ -18,12 +23,4 @@ class AreaOfEffectBehavior final : public Behavior bool m_targetEnemy; bool m_targetFriend; bool m_targetTeam; - - explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {} - - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - - void Load() override; }; diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index 0d799833d..25062fdae 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -290,7 +290,7 @@ void BehaviorContext::Reset() { this->scheduledUpdates.clear(); } -void BehaviorContext::FilterTargets(std::vector& targets, std::forward_list ignoreFactionList, std::forward_list includeFactionList, bool targetSelf, bool targetEnemy, bool targetFriend, bool targetTeam) const { +void BehaviorContext::FilterTargets(std::vector& targets, std::forward_list& ignoreFactionList, std::forward_list& includeFactionList, bool targetSelf, bool targetEnemy, bool targetFriend, bool targetTeam) const { // if we aren't targeting anything, then clear the targets vector if (!targetSelf && !targetEnemy && !targetFriend && !targetTeam && ignoreFactionList.empty() && includeFactionList.empty()) { @@ -368,11 +368,11 @@ bool BehaviorContext::CheckTargetingRequirements(const Entity* target) const { // if the target is a nullptr, then it's not valid if (!target) return false; - // only target quickbuilds in the are completed + // ignore entities that don't have destroyable components auto* targetDestroyableComponent = target->GetComponent(); if (!targetDestroyableComponent) return false; - // only target quickbuilds in the are completed + // ignore quickbuilds that aren't completed auto* targetQuickbuildComponent = target->GetComponent(); if (targetQuickbuildComponent && targetQuickbuildComponent->GetState() != REBUILD_COMPLETED) return false; @@ -380,7 +380,7 @@ bool BehaviorContext::CheckTargetingRequirements(const Entity* target) const { } // returns true if any of the object factions are in the faction list -bool BehaviorContext::CheckFactionList(std::forward_list factionList, std::vector objectsFactions) const { +bool BehaviorContext::CheckFactionList(std::forward_list& factionList, std::vector& objectsFactions) const { if (factionList.empty() || objectsFactions.empty()) return false; for (auto faction : factionList){ if(std::find(objectsFactions.begin(), objectsFactions.end(), faction) != objectsFactions.end()) return true; diff --git a/dGame/dBehaviors/BehaviorContext.h b/dGame/dBehaviors/BehaviorContext.h index f42f23684..b8088e8eb 100644 --- a/dGame/dBehaviors/BehaviorContext.h +++ b/dGame/dBehaviors/BehaviorContext.h @@ -105,11 +105,11 @@ struct BehaviorContext void Reset(); - void FilterTargets(std::vector& targetsReference, std::forward_list ignoreFaction = {}, std::forward_list includeFaction = {}, const bool targetSelf = false, const bool targetEnemy = true, const bool targetFriend = false, const bool targetTeam = false) const; + void FilterTargets(std::vector& targetsReference, std::forward_list& ignoreFaction, std::forward_list& includeFaction, const bool targetSelf = false, const bool targetEnemy = true, const bool targetFriend = false, const bool targetTeam = false) const; bool CheckTargetingRequirements(const Entity* target) const; - bool CheckFactionList(std::forward_list factionList, std::vector objectsFactions) const; + bool CheckFactionList(std::forward_list& factionList, std::vector& objectsFactions) const; explicit BehaviorContext(LWOOBJID originator, bool calculation = false); diff --git a/dGame/dBehaviors/TacArcBehavior.h b/dGame/dBehaviors/TacArcBehavior.h index 47b40e529..d93452727 100644 --- a/dGame/dBehaviors/TacArcBehavior.h +++ b/dGame/dBehaviors/TacArcBehavior.h @@ -6,6 +6,11 @@ class TacArcBehavior final : public Behavior { public: + explicit TacArcBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {} + void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; + void Load() override; +private: float m_maxRange; float m_height; float m_distanceWeight; @@ -29,16 +34,10 @@ class TacArcBehavior final : public Behavior { float m_nearHeight; float m_nearWidth; - std::forward_list m_ignoreFactionList {}; std::forward_list m_includeFactionList {}; bool m_targetSelf; bool m_targetEnemy; bool m_targetFriend; bool m_targetTeam; - - explicit TacArcBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {} - void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override; - void Load() override; }; diff --git a/dGame/dUtilities/SlashCommandHandler.cpp b/dGame/dUtilities/SlashCommandHandler.cpp index b3f0444d7..1aa9e6c49 100644 --- a/dGame/dUtilities/SlashCommandHandler.cpp +++ b/dGame/dUtilities/SlashCommandHandler.cpp @@ -1899,12 +1899,10 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit ChatPackets::SendSystemMessage(sysAddr, u"Error getting slot."); return; } else { - Game::logger->Log("SlashCommandHandler", "Got slot %i", slot); if (!GeneralUtils::TryParse(args[1], skillId)) { ChatPackets::SendSystemMessage(sysAddr, u"Error getting skill."); return; } else { - Game::logger->Log("SlashCommandHandler", "Got skill %i", skillId); if(inventoryComponent->SetSkill(slot, skillId)) ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot successfully"); else ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot failed"); } diff --git a/docs/Commands.md b/docs/Commands.md index cba311ea7..a68430437 100644 --- a/docs/Commands.md +++ b/docs/Commands.md @@ -107,10 +107,10 @@ These commands are primarily for development and testing. The usage of many of t |crash|`/crash`|Crashes the server.|9| |rollloot|`/rollloot `|Rolls loot matrix.|9| |castskill|`/castskill `|Casts the skill as the player|9| -|setskillslot|`/setskillslot `||9| -|setfaction|`/setfaction `|Clears the users current factions and sets it|9| -|addfaction|`/addfaction `|Add the faction to the users list of factions|9| -|getfactions|`/getfactions`|Shows the player's factions|9| +|setskillslot|`/setskillslot `||8| +|setfaction|`/setfaction `|Clears the users current factions and sets it|8| +|addfaction|`/addfaction `|Add the faction to the users list of factions|8| +|getfactions|`/getfactions`|Shows the player's factions|8| ## Detailed `/inspect` Usage @@ -125,7 +125,7 @@ Finds the closest entity with the given component or LDF variable (ignoring play * `-s`: Prints the entity's settings and spawner ID. * `-p`: Prints the entity's position * `-f`: If the entity has a destroyable component, prints whether the entity is smashable and its friendly and enemy faction IDs; if `faction` is specified, adds that faction to the entity. -* `-cf`: check if the faction of this entity is your enenmy or friend +* `-cf`: check if the entity is enemy or friend * `-t`: If the entity has a phantom physics component, prints the effect type, direction, directional multiplier, and whether the effect is active; in any case, if the entity has a trigger, prints the trigger ID. ## Game Master Levels