Skip to content

Commit

Permalink
Update creature.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mehah committed Nov 7, 2024
1 parent 4ae6bdf commit 2925d8d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2004,13 +2004,15 @@ void Creature::sendAsyncTasks() {

void Creature::safeCall(std::function<void(void)> &&action) const {
if (g_dispatcher().context().isAsync()) {
g_dispatcher().addEvent([weak_self = std::weak_ptr<const SharedObject>(shared_from_this()), action = std::move(action)] {
if (weak_self.lock()) {
action();
g_dispatcher().addEvent([weak_self = std::weak_ptr<const Creature>(static_self_cast<Creature>()), action = std::move(action)] {
if (const auto self = weak_self.lock()) {
if (!self->isInternalRemoved) {
action();
}
}
},
g_dispatcher().context().getName());
} else {
} else if (!isInternalRemoved) {
action();
}
}

0 comments on commit 2925d8d

Please sign in to comment.