From ef63498c610224a9027d471e056d3c4ed774f306 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Mon, 25 Jul 2016 10:58:47 -0700 Subject: [PATCH] RelayTracker fixes --- Runtime/CRelayTracker.cpp | 14 ++++++------ Runtime/Collision/CMaterialList.hpp | 34 +++++++++++++++------------- Runtime/World/CScriptMemoryRelay.cpp | 8 +++---- Runtime/World/CScriptMemoryRelay.hpp | 2 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Runtime/CRelayTracker.cpp b/Runtime/CRelayTracker.cpp index 6b3384cc3..7e9845c5f 100644 --- a/Runtime/CRelayTracker.cpp +++ b/Runtime/CRelayTracker.cpp @@ -47,11 +47,11 @@ void CRelayTracker::SendMsgs(const TAreaId& areaId, CStateManager& stateMgr) const CWorld* world = stateMgr.GetWorld(); u32 relayCount = world->GetRelayCount(); - bool hasInactiveRelays = false; + bool hasActiveRelays = false; for (u32 i=0 ; iGetRelay(i); - if (((relay.GetRelayId() >> 16) & 0x3FF) != areaId) + if (((relay.GetTargetId() >> 16) & 0x3FF) != areaId) continue; if (!HasRelay(relay.GetRelayId())) @@ -59,20 +59,20 @@ void CRelayTracker::SendMsgs(const TAreaId& areaId, CStateManager& stateMgr) stateMgr.SendScriptMsg(kInvalidUniqueId, relay.GetTargetId(), EScriptObjectMessage(relay.GetMessage()), EScriptObjectState::Any); - if (!relay.GetActive()) - hasInactiveRelays = true; + if (relay.GetActive()) + hasActiveRelays = true; } - if (!hasInactiveRelays) + if (!hasActiveRelays) return; for (u32 i=0 ; iGetRelay(i); - if (((relay.GetRelayId() >> 16) & 0x3FF) != areaId) + if (((relay.GetTargetId() >> 16) & 0x3FF) != areaId) continue; - if (!HasRelay(relay.GetRelayId()) || relay.GetActive()) + if (!HasRelay(relay.GetRelayId()) || !relay.GetActive()) continue; RemoveRelay(relay.GetRelayId()); diff --git a/Runtime/Collision/CMaterialList.hpp b/Runtime/Collision/CMaterialList.hpp index a71df5818..fe7ee1dfe 100644 --- a/Runtime/Collision/CMaterialList.hpp +++ b/Runtime/Collision/CMaterialList.hpp @@ -46,68 +46,70 @@ enum class EMaterialTypes class CMaterialList { friend class CMaterialFilter; - u64 x0_ = 0; + u64 x0_list = 0; public: CMaterialList() = default; - CMaterialList(u64 flags) : x0_(flags) {} + CMaterialList(u64 flags) : x0_list(flags) {} CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5, EMaterialTypes t6) : CMaterialList(t1, t2, t3, t4, t5) - { x0_ = 1ull << u64(t6); } + { x0_list = 1ull << u64(t6); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5) : CMaterialList(t1, t2, t3, t4) - { x0_ = 1ull << u64(t5); } + { x0_list = 1ull << u64(t5); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4) : CMaterialList(t1, t2, t3) - { x0_ = 1ull << u64(t4); } + { x0_list = 1ull << u64(t4); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3) : CMaterialList(t1, t2) - { x0_ = 1ull << u64(t3); } + { x0_list = 1ull << u64(t3); } CMaterialList(EMaterialTypes t1, EMaterialTypes t2) : CMaterialList(t1) - { x0_ = 1ull << u64(t2); } + { x0_list = 1ull << u64(t2); } CMaterialList(EMaterialTypes t1) - : x0_(1ull << u64(t1)) + : x0_list(1ull << u64(t1)) { } static u32 BitPosition(u64 flag) { - for (u32 i = 0; i < 63; ++i) - if ((flag & (1ull << i)) != 0) - return i; + u32 high = *((u32*)(&flag)[0]); + u32 low = *((u32*)(&flag)[1]); + for (u32 i = 0; i < 8; ++i) + { + } return -1; } void Add(EMaterialTypes type) { - x0_ |= (1ull << u64(type)); + x0_list |= (1ull << u64(type)); } void Remove(EMaterialTypes type) { - x0_ &= ~(1ull << u64(type)); + x0_list &= ~(1ull << u64(type)); } void Remove(const CMaterialList& other) { - x0_ &= ~(other.x0_); + x0_list &= ~(other.x0_list); } bool HasMaterial(EMaterialTypes type) { - return (x0_ & (1ull << u64(type))) != 0; + return (x0_list & (1ull << u64(type))) != 0; } bool SharesMaterials(const CMaterialList& other) { for (u32 i = 0; i < 64; i++) { - if ((x0_ & (1ull << i)) != 0 && (other.x0_ & (1ull << i)) != 0) + if ((x0_list & (1ull << i)) != 0 && (other.x0_list & (1ull << i)) != 0) return true; } diff --git a/Runtime/World/CScriptMemoryRelay.cpp b/Runtime/World/CScriptMemoryRelay.cpp index ccd18d78a..30123140f 100644 --- a/Runtime/World/CScriptMemoryRelay.cpp +++ b/Runtime/World/CScriptMemoryRelay.cpp @@ -8,7 +8,7 @@ namespace urde CScriptMemoryRelay::CScriptMemoryRelay(TUniqueId uid, const std::string& name, const CEntityInfo& info, bool b1, bool b2, bool b3) : CEntity(uid, info, true, name), x34_24_(b1), - x34_25_(b2), + x34_25_skipSendNone(b2), x34_26_ignoreMessages(b3) { } @@ -26,9 +26,9 @@ void CScriptMemoryRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj else if (msg == EScriptObjectMessage::Activate) { stateMgr.GetRelayTracker()->AddRelay(xc_editorId); - if (x34_25_) - return; - SendScriptMsgs(EScriptObjectState::Active, stateMgr, EScriptObjectMessage::None); + if (!x34_25_skipSendNone) + SendScriptMsgs(EScriptObjectState::Active, stateMgr, EScriptObjectMessage::None); + return; } diff --git a/Runtime/World/CScriptMemoryRelay.hpp b/Runtime/World/CScriptMemoryRelay.hpp index 8a37ced30..3de65ce6d 100644 --- a/Runtime/World/CScriptMemoryRelay.hpp +++ b/Runtime/World/CScriptMemoryRelay.hpp @@ -12,7 +12,7 @@ class CScriptMemoryRelay : public CEntity struct { bool x34_24_; - bool x34_25_; + bool x34_25_skipSendNone; bool x34_26_ignoreMessages; }; u8 dummy = 0;