Better fix
This commit is contained in:
parent
e373f75fca
commit
a406368471
@ -31,28 +31,30 @@ namespace scripting::lua
|
|||||||
this->merge_callbacks();
|
this->merge_callbacks();
|
||||||
this->handle_endon_conditions(event);
|
this->handle_endon_conditions(event);
|
||||||
|
|
||||||
for (auto i = tasks.begin(); i != tasks.end();)
|
auto size = tasks.size();
|
||||||
|
for (auto i = 0; i < tasks.size();)
|
||||||
{
|
{
|
||||||
if (i->event != event.name || i->entity != event.entity)
|
const auto task = tasks[i];
|
||||||
|
if (task.event != event.name || task.entity != event.entity)
|
||||||
{
|
{
|
||||||
++i;
|
++i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!i->is_deleted)
|
if (!task.is_deleted)
|
||||||
{
|
{
|
||||||
if(!has_built_arguments)
|
if (!has_built_arguments)
|
||||||
{
|
{
|
||||||
has_built_arguments = true;
|
has_built_arguments = true;
|
||||||
arguments = this->build_arguments(event);
|
arguments = this->build_arguments(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_error(i->callback(sol::as_args(arguments)));
|
handle_error(task.callback(sol::as_args(arguments)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i->is_volatile || i->is_deleted)
|
if (task.is_volatile || task.is_deleted)
|
||||||
{
|
{
|
||||||
i = tasks.erase(i);
|
tasks.erase(tasks.begin() + i);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -144,11 +146,11 @@ namespace scripting::lua
|
|||||||
{
|
{
|
||||||
auto deleter = [&](task_list& tasks)
|
auto deleter = [&](task_list& tasks)
|
||||||
{
|
{
|
||||||
for(auto& task : tasks)
|
for (auto& task : tasks)
|
||||||
{
|
{
|
||||||
for(auto& condition : task.endon_conditions)
|
for (auto& condition : task.endon_conditions)
|
||||||
{
|
{
|
||||||
if(condition.first == event.entity && condition.second == event.name)
|
if (condition.first == event.entity && condition.second == event.name)
|
||||||
{
|
{
|
||||||
task.is_deleted = true;
|
task.is_deleted = true;
|
||||||
break;
|
break;
|
||||||
|
@ -43,7 +43,7 @@ namespace scripting::lua
|
|||||||
sol::state& state_;
|
sol::state& state_;
|
||||||
std::atomic_int64_t current_listener_id_ = 0;
|
std::atomic_int64_t current_listener_id_ = 0;
|
||||||
|
|
||||||
using task_list = std::list<event_listener>;
|
using task_list = std::vector<event_listener>;
|
||||||
utils::concurrency::container<task_list> new_callbacks_;
|
utils::concurrency::container<task_list> new_callbacks_;
|
||||||
utils::concurrency::container<task_list, std::recursive_mutex> callbacks_;
|
utils::concurrency::container<task_list, std::recursive_mutex> callbacks_;
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ namespace scripting::lua
|
|||||||
{
|
{
|
||||||
auto deleter = [&](task_list& tasks)
|
auto deleter = [&](task_list& tasks)
|
||||||
{
|
{
|
||||||
for(auto& task : tasks)
|
for (auto& task : tasks)
|
||||||
{
|
{
|
||||||
for(auto& condition : task.endon_conditions)
|
for (auto& condition : task.endon_conditions)
|
||||||
{
|
{
|
||||||
if(condition.first == event.entity && condition.second == event.name)
|
if (condition.first == event.entity && condition.second == event.name)
|
||||||
{
|
{
|
||||||
task.is_deleted = true;
|
task.is_deleted = true;
|
||||||
break;
|
break;
|
||||||
@ -122,9 +122,9 @@ namespace scripting::lua
|
|||||||
{
|
{
|
||||||
auto merger = [&](task_list& tasks)
|
auto merger = [&](task_list& tasks)
|
||||||
{
|
{
|
||||||
for(auto& task : tasks)
|
for (auto& task : tasks)
|
||||||
{
|
{
|
||||||
if(task.id == handle.id)
|
if (task.id == handle.id)
|
||||||
{
|
{
|
||||||
task.endon_conditions.emplace_back(entity, event);
|
task.endon_conditions.emplace_back(entity, event);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user