Skip to content

Commit

Permalink
* Crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 10, 2025
1 parent 2485b41 commit c8539a0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/lua/creature/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,13 @@ uint32_t MoveEvent::fireAddRemItem(const std::shared_ptr<Item> &item, const std:
if (isLoadedScriptId()) {
return executeAddRemItem(item, fromTile, pos);
} else {
if (!moveFunction) {
g_logger().error("[MoveEvent::fireAddRemItem - Item {} item on position: {}] "
"Move function is nullptr.",
item->getName(), pos.toString());
return 0;
}

return moveFunction(item, fromTile, pos);
}
}
Expand Down Expand Up @@ -848,6 +855,13 @@ uint32_t MoveEvent::fireAddRemItem(const std::shared_ptr<Item> &item, const Posi
if (isLoadedScriptId()) {
return executeAddRemItem(item, pos);
} else {
if (!moveFunction) {
g_logger().error("[MoveEvent::fireAddRemItem - Item {} item on position: {}] "
"Move function is nullptr.",
item->getName(), pos.toString());
return 0;
}

return moveFunction(item, nullptr, pos);
}
}
Expand All @@ -857,9 +871,9 @@ bool MoveEvent::executeAddRemItem(const std::shared_ptr<Item> &item, const Posit
// onRemoveItem(moveitem, pos)
if (!LuaScriptInterface::reserveScriptEnv()) {
g_logger().error("[MoveEvent::executeAddRemItem - "
"Item {} item on tile x: {} y: {} z: {}] "
"Item {} item on position: {}] "
"Call stack overflow. Too many lua script calls being nested.",
item->getName(), pos.getX(), pos.getY(), pos.getZ());
item->getName(), pos.toString());
return false;
}

Expand Down

0 comments on commit c8539a0

Please sign in to comment.