Merge pull request #419 from liyunfan1223/fix-trigger

Fix triggers bug
This commit is contained in:
Yunfan Li
2024-08-01 11:41:02 +08:00
committed by GitHub

View File

@@ -470,7 +470,7 @@ bool Engine::HasStrategy(std::string const name)
void Engine::ProcessTriggers(bool minimal)
{
// std::unordered_map<Trigger*, Event> fires;
std::unordered_map<Trigger*, Event> fires;
for (std::vector<TriggerNode*>::iterator i = triggers.begin(); i != triggers.end(); i++)
{
TriggerNode* node = *i;
@@ -486,7 +486,10 @@ void Engine::ProcessTriggers(bool minimal)
if (!trigger)
continue;
if (fires.find(trigger) != fires.end())
continue;
if (testMode || trigger->needCheck())
{
if (minimal && node->getFirstRelevance() < 100)
@@ -500,22 +503,21 @@ void Engine::ProcessTriggers(bool minimal)
if (!event)
continue;
// fires[trigger] = event;
fires[trigger] = event;
LogAction("T:%s", trigger->getName().c_str());
MultiplyAndPush(node->getHandlers(), 0.0f, false, event, "trigger");
}
}
// for (std::vector<TriggerNode*>::iterator i = triggers.begin(); i != triggers.end(); i++)
// {
// TriggerNode* node = *i;
// Trigger* trigger = node->getTrigger();
// if (fires.find(trigger) == fires.end())
// continue;
for (std::vector<TriggerNode*>::iterator i = triggers.begin(); i != triggers.end(); i++)
{
TriggerNode* node = *i;
Trigger* trigger = node->getTrigger();
if (fires.find(trigger) == fires.end())
continue;
// Event event = fires[trigger];
// }
Event event = fires[trigger];
MultiplyAndPush(node->getHandlers(), 0.0f, false, event, "trigger");
}
for (std::vector<TriggerNode*>::iterator i = triggers.begin(); i != triggers.end(); i++)
{