#include "CRelayTracker.hpp" #include "CStateManager.hpp" #include "CSaveWorld.hpp" #include "World/CWorld.hpp" #include namespace urde { CRelayTracker::CRelayTracker(CBitStreamReader& in, const CSaveWorld& saveworld) { u32 relayCount = saveworld.GetRelayCount(); if (saveworld.GetRelayCount()) { std::vector relayStates(saveworld.GetRelayCount()); for (u32 i=0 ; iGetRelayCount(); bool hasActiveRelays = false; for (u32 i=0 ; iGetRelay(i); if (((relay.GetTargetId() >> 16) & 0x3FF) != areaId) continue; if (!HasRelay(relay.GetRelayId())) continue; stateMgr.SendScriptMsg(kInvalidUniqueId, relay.GetTargetId(), EScriptObjectMessage(relay.GetMessage()), EScriptObjectState::Any); if (relay.GetActive()) hasActiveRelays = true; } if (!hasActiveRelays) return; for (u32 i=0 ; iGetRelay(i); if (((relay.GetTargetId() >> 16) & 0x3FF) != areaId) continue; if (!HasRelay(relay.GetRelayId()) || !relay.GetActive()) continue; RemoveRelay(relay.GetRelayId()); } } void CRelayTracker::PutTo(CBitStreamWriter& out, const CSaveWorld& saveworld) { u32 relayCount = saveworld.GetRelayCount(); std::vector relays(relayCount); for (const TEditorId& id : x0_relayStates) relays[saveworld.GetRelayIndex(id)] = true; for (u32 i=0 ; i