From 38eb441ca14037b626339f17fd40bdc870f9fc84 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 21 Dec 2022 00:26:17 -0800 Subject: [PATCH] Correct Projectile behavior bitStream reads (#907) --- dGame/dBehaviors/BehaviorBranchContext.h | 2 ++ dGame/dBehaviors/BehaviorContext.cpp | 1 + dGame/dBehaviors/ProjectileAttackBehavior.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dGame/dBehaviors/BehaviorBranchContext.h b/dGame/dBehaviors/BehaviorBranchContext.h index 5b2ec595..2e56cd35 100644 --- a/dGame/dBehaviors/BehaviorBranchContext.h +++ b/dGame/dBehaviors/BehaviorBranchContext.h @@ -15,6 +15,8 @@ struct BehaviorBranchContext uint32_t start = 0; + bool isSync = false; + BehaviorBranchContext(); BehaviorBranchContext(LWOOBJID target, float duration = 0, const NiPoint3& referencePosition = NiPoint3(0, 0, 0)); diff --git a/dGame/dBehaviors/BehaviorContext.cpp b/dGame/dBehaviors/BehaviorContext.cpp index c2f0c88e..ebed10ba 100644 --- a/dGame/dBehaviors/BehaviorContext.cpp +++ b/dGame/dBehaviors/BehaviorContext.cpp @@ -51,6 +51,7 @@ void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* beha entry.handle = syncId; entry.behavior = behavior; entry.branchContext = branchContext; + entry.branchContext.isSync = true; entry.ignoreInterrupts = ignoreInterrupts; this->syncEntries.push_back(entry); diff --git a/dGame/dBehaviors/ProjectileAttackBehavior.cpp b/dGame/dBehaviors/ProjectileAttackBehavior.cpp index 2b38db8f..3ce6c415 100644 --- a/dGame/dBehaviors/ProjectileAttackBehavior.cpp +++ b/dGame/dBehaviors/ProjectileAttackBehavior.cpp @@ -31,7 +31,7 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea return; } - if (m_ProjectileType == 1) { + if (m_useMouseposit && !branch.isSync) { NiPoint3 targetPosition = NiPoint3::ZERO; if (!bitStream->Read(targetPosition)) { Game::logger->Log("ProjectileAttackBehavior", "Unable to read targetPosition from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());