Better fix
This commit is contained in:
parent
e373f75fca
commit
a406368471
@ -31,15 +31,17 @@ 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)
|
||||||
{
|
{
|
||||||
@ -47,12 +49,12 @@ namespace scripting::lua
|
|||||||
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
|
||||||
{
|
{
|
||||||
|
@ -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_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user