RelayTracker fixes

This commit is contained in:
Phillip Stephens 2016-07-25 10:58:47 -07:00
parent 9b62191975
commit ef63498c61
4 changed files with 30 additions and 28 deletions

View File

@ -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 ; i<relayCount ; ++i)
{
const CWorld::CRelay& relay = world->GetRelay(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 ; i<relayCount ; ++i)
{
const CWorld::CRelay& relay = world->GetRelay(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());

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;