mirror of https://github.com/AxioDL/metaforce.git
RelayTracker fixes
This commit is contained in:
parent
9b62191975
commit
ef63498c61
|
@ -47,11 +47,11 @@ void CRelayTracker::SendMsgs(const TAreaId& areaId, CStateManager& stateMgr)
|
||||||
const CWorld* world = stateMgr.GetWorld();
|
const CWorld* world = stateMgr.GetWorld();
|
||||||
u32 relayCount = world->GetRelayCount();
|
u32 relayCount = world->GetRelayCount();
|
||||||
|
|
||||||
bool hasInactiveRelays = false;
|
bool hasActiveRelays = false;
|
||||||
for (u32 i=0 ; i<relayCount ; ++i)
|
for (u32 i=0 ; i<relayCount ; ++i)
|
||||||
{
|
{
|
||||||
const CWorld::CRelay& relay = world->GetRelay(i);
|
const CWorld::CRelay& relay = world->GetRelay(i);
|
||||||
if (((relay.GetRelayId() >> 16) & 0x3FF) != areaId)
|
if (((relay.GetTargetId() >> 16) & 0x3FF) != areaId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!HasRelay(relay.GetRelayId()))
|
if (!HasRelay(relay.GetRelayId()))
|
||||||
|
@ -59,20 +59,20 @@ void CRelayTracker::SendMsgs(const TAreaId& areaId, CStateManager& stateMgr)
|
||||||
|
|
||||||
stateMgr.SendScriptMsg(kInvalidUniqueId, relay.GetTargetId(), EScriptObjectMessage(relay.GetMessage()),
|
stateMgr.SendScriptMsg(kInvalidUniqueId, relay.GetTargetId(), EScriptObjectMessage(relay.GetMessage()),
|
||||||
EScriptObjectState::Any);
|
EScriptObjectState::Any);
|
||||||
if (!relay.GetActive())
|
if (relay.GetActive())
|
||||||
hasInactiveRelays = true;
|
hasActiveRelays = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasInactiveRelays)
|
if (!hasActiveRelays)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (u32 i=0 ; i<relayCount ; ++i)
|
for (u32 i=0 ; i<relayCount ; ++i)
|
||||||
{
|
{
|
||||||
const CWorld::CRelay& relay = world->GetRelay(i);
|
const CWorld::CRelay& relay = world->GetRelay(i);
|
||||||
if (((relay.GetRelayId() >> 16) & 0x3FF) != areaId)
|
if (((relay.GetTargetId() >> 16) & 0x3FF) != areaId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!HasRelay(relay.GetRelayId()) || relay.GetActive())
|
if (!HasRelay(relay.GetRelayId()) || !relay.GetActive())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RemoveRelay(relay.GetRelayId());
|
RemoveRelay(relay.GetRelayId());
|
||||||
|
|
|
@ -46,68 +46,70 @@ enum class EMaterialTypes
|
||||||
class CMaterialList
|
class CMaterialList
|
||||||
{
|
{
|
||||||
friend class CMaterialFilter;
|
friend class CMaterialFilter;
|
||||||
u64 x0_ = 0;
|
u64 x0_list = 0;
|
||||||
public:
|
public:
|
||||||
CMaterialList() = default;
|
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(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5, EMaterialTypes t6)
|
||||||
: CMaterialList(t1, t2, t3, t4, t5)
|
: 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(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, EMaterialTypes t5)
|
||||||
: CMaterialList(t1, t2, t3, t4)
|
: CMaterialList(t1, t2, t3, t4)
|
||||||
{ x0_ = 1ull << u64(t5); }
|
{ x0_list = 1ull << u64(t5); }
|
||||||
|
|
||||||
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4)
|
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4)
|
||||||
: CMaterialList(t1, t2, t3)
|
: CMaterialList(t1, t2, t3)
|
||||||
{ x0_ = 1ull << u64(t4); }
|
{ x0_list = 1ull << u64(t4); }
|
||||||
|
|
||||||
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3)
|
CMaterialList(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3)
|
||||||
: CMaterialList(t1, t2)
|
: CMaterialList(t1, t2)
|
||||||
{ x0_ = 1ull << u64(t3); }
|
{ x0_list = 1ull << u64(t3); }
|
||||||
|
|
||||||
CMaterialList(EMaterialTypes t1, EMaterialTypes t2)
|
CMaterialList(EMaterialTypes t1, EMaterialTypes t2)
|
||||||
: CMaterialList(t1)
|
: CMaterialList(t1)
|
||||||
{ x0_ = 1ull << u64(t2); }
|
{ x0_list = 1ull << u64(t2); }
|
||||||
|
|
||||||
CMaterialList(EMaterialTypes t1)
|
CMaterialList(EMaterialTypes t1)
|
||||||
: x0_(1ull << u64(t1))
|
: x0_list(1ull << u64(t1))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 BitPosition(u64 flag)
|
static u32 BitPosition(u64 flag)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < 63; ++i)
|
u32 high = *((u32*)(&flag)[0]);
|
||||||
if ((flag & (1ull << i)) != 0)
|
u32 low = *((u32*)(&flag)[1]);
|
||||||
return i;
|
for (u32 i = 0; i < 8; ++i)
|
||||||
|
{
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Add(EMaterialTypes type)
|
void Add(EMaterialTypes type)
|
||||||
{
|
{
|
||||||
x0_ |= (1ull << u64(type));
|
x0_list |= (1ull << u64(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(EMaterialTypes type)
|
void Remove(EMaterialTypes type)
|
||||||
{
|
{
|
||||||
x0_ &= ~(1ull << u64(type));
|
x0_list &= ~(1ull << u64(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Remove(const CMaterialList& other)
|
void Remove(const CMaterialList& other)
|
||||||
{
|
{
|
||||||
x0_ &= ~(other.x0_);
|
x0_list &= ~(other.x0_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasMaterial(EMaterialTypes type)
|
bool HasMaterial(EMaterialTypes type)
|
||||||
{
|
{
|
||||||
return (x0_ & (1ull << u64(type))) != 0;
|
return (x0_list & (1ull << u64(type))) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SharesMaterials(const CMaterialList& other)
|
bool SharesMaterials(const CMaterialList& other)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < 64; i++)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace urde
|
||||||
CScriptMemoryRelay::CScriptMemoryRelay(TUniqueId uid, const std::string& name, const CEntityInfo& info, bool b1, bool b2, bool b3)
|
CScriptMemoryRelay::CScriptMemoryRelay(TUniqueId uid, const std::string& name, const CEntityInfo& info, bool b1, bool b2, bool b3)
|
||||||
: CEntity(uid, info, true, name),
|
: CEntity(uid, info, true, name),
|
||||||
x34_24_(b1),
|
x34_24_(b1),
|
||||||
x34_25_(b2),
|
x34_25_skipSendNone(b2),
|
||||||
x34_26_ignoreMessages(b3)
|
x34_26_ignoreMessages(b3)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,9 @@ void CScriptMemoryRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId obj
|
||||||
else if (msg == EScriptObjectMessage::Activate)
|
else if (msg == EScriptObjectMessage::Activate)
|
||||||
{
|
{
|
||||||
stateMgr.GetRelayTracker()->AddRelay(xc_editorId);
|
stateMgr.GetRelayTracker()->AddRelay(xc_editorId);
|
||||||
if (x34_25_)
|
if (!x34_25_skipSendNone)
|
||||||
return;
|
SendScriptMsgs(EScriptObjectState::Active, stateMgr, EScriptObjectMessage::None);
|
||||||
SendScriptMsgs(EScriptObjectState::Active, stateMgr, EScriptObjectMessage::None);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class CScriptMemoryRelay : public CEntity
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
bool x34_24_;
|
bool x34_24_;
|
||||||
bool x34_25_;
|
bool x34_25_skipSendNone;
|
||||||
bool x34_26_ignoreMessages;
|
bool x34_26_ignoreMessages;
|
||||||
};
|
};
|
||||||
u8 dummy = 0;
|
u8 dummy = 0;
|
||||||
|
|
Loading…
Reference in New Issue