This commit is contained in:
2016-02-10 01:16:38 +01:00
parent 5cea3bed3a
commit d931660c56
13 changed files with 181 additions and 100 deletions
+1 -2
View File
@@ -54,7 +54,7 @@ bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
return false;
}
bool EntityWrapper::Valid()
bool EntityWrapper::Valid() const
{
if (this->World == nullptr) {
return false;
@@ -65,7 +65,6 @@ bool EntityWrapper::Valid()
}
if (!this->World->ValidEntity(this->ID)) {
this->ID = EntityID_Invalid;
return false;
}
+8 -6
View File
@@ -10,10 +10,9 @@ BaseEventRelay::~BaseEventRelay()
void EventBroker::Unsubscribe(BaseEventRelay& relay) // ?
{
auto identifier = std::make_tuple(relay.m_EventID, relay.m_ContextTypeName, relay.m_EventTypeName);
relay.m_Broker = nullptr;
if (m_IsProcessing) {
m_RelaysToUnsubscribe.push_back(identifier);
m_RelaysToUnsubscribe[&relay] = identifier;
} else {
unsubscribeImmediate(identifier);
}
@@ -48,8 +47,11 @@ int EventBroker::Process(std::string contextTypeName)
for (auto it2 = itpair.first; it2 != itpair.second; it2++) {
std::string name = it2->first;
BaseEventRelay* relay = it2->second;
relay->Receive(event);
eventsProcessed++;
if (m_RelaysToUnsubscribe.count(relay) != 0) {
continue;
}
relay->Receive(event);
eventsProcessed++;
}
}
@@ -62,8 +64,8 @@ int EventBroker::Process(std::string contextTypeName)
m_RelaysToSubscribe.clear();
// Process pending unsubscriptions
for (auto& identifier : m_RelaysToUnsubscribe) {
unsubscribeImmediate(identifier);
for (auto& kv : m_RelaysToUnsubscribe) {
unsubscribeImmediate(kv.second);
}
m_RelaysToUnsubscribe.clear();