mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #253 from lioncash/const4
CRelayTracker: Make HasRelay() a const member function
This commit is contained in:
commit
9e05819f05
|
@ -23,18 +23,24 @@ CRelayTracker::CRelayTracker(CBitStreamReader& in, const CSaveWorld& saveworld)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRelayTracker::HasRelay(TEditorId id) {
|
bool CRelayTracker::HasRelay(TEditorId id) const {
|
||||||
return std::find(x0_relayStates.begin(), x0_relayStates.end(), id) != x0_relayStates.end();
|
return std::find(x0_relayStates.cbegin(), x0_relayStates.cend(), id) != x0_relayStates.cend();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRelayTracker::AddRelay(TEditorId id) {
|
void CRelayTracker::AddRelay(TEditorId id) {
|
||||||
if (std::find(x0_relayStates.begin(), x0_relayStates.end(), id) == x0_relayStates.end())
|
if (HasRelay(id)) {
|
||||||
x0_relayStates.push_back(id);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x0_relayStates.push_back(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRelayTracker::RemoveRelay(TEditorId id) {
|
void CRelayTracker::RemoveRelay(TEditorId id) {
|
||||||
if (std::find(x0_relayStates.begin(), x0_relayStates.end(), id) != x0_relayStates.end())
|
if (!HasRelay(id)) {
|
||||||
x0_relayStates.erase(std::remove(x0_relayStates.begin(), x0_relayStates.end(), id), x0_relayStates.end());
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
x0_relayStates.erase(std::remove(x0_relayStates.begin(), x0_relayStates.end(), id), x0_relayStates.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRelayTracker::SendMsgs(TAreaId areaId, CStateManager& stateMgr) {
|
void CRelayTracker::SendMsgs(TAreaId areaId, CStateManager& stateMgr) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
CRelayTracker() = default;
|
CRelayTracker() = default;
|
||||||
CRelayTracker(CBitStreamReader&, const CSaveWorld&);
|
CRelayTracker(CBitStreamReader&, const CSaveWorld&);
|
||||||
|
|
||||||
bool HasRelay(TEditorId);
|
bool HasRelay(TEditorId) const;
|
||||||
void AddRelay(TEditorId);
|
void AddRelay(TEditorId);
|
||||||
void RemoveRelay(TEditorId);
|
void RemoveRelay(TEditorId);
|
||||||
void SendMsgs(TAreaId, CStateManager&);
|
void SendMsgs(TAreaId, CStateManager&);
|
||||||
|
|
Loading…
Reference in New Issue