Skip to content

Commit

Permalink
fix: lua getNumber overflow with "MoveEvent::EquipItem" function (#3136)
Browse files Browse the repository at this point in the history
Fixed overflow with "MoveEvent::EquipItem" and added imbuement shrine to canary temple
  • Loading branch information
dudantas authored Nov 20, 2024
1 parent 1765018 commit 729387b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions data-canary/scripts/actions/objects/imbuement_shrine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ function imbuement.onUse(player, item, fromPosition, target, toPosition, isHotke
return true
end

imbuement:position({ x = 1943, y = 1340, z = 7 }, 25061)

imbuement:id(25060, 25061, 25103, 25104, 25202, 25174, 25175, 25182, 25183)
imbuement:register()
3 changes: 2 additions & 1 deletion data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder,
end

-- Reward System
if toPosition.x == CONTAINER_POSITION then
local containerThing = tile and tile:getItemByType(ITEM_TYPE_CONTAINER)
if containerThing and toPosition.x == CONTAINER_POSITION then
local containerId = toPosition.y - 64
local container = self:getContainerById(containerId)
if not container then
Expand Down
4 changes: 2 additions & 2 deletions src/lua/functions/lua_functions_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Lua {
static void setCreatureMetatable(lua_State* L, int32_t index, const std::shared_ptr<Creature> &creature);

template <typename T>
static T getNumber(lua_State* L, int32_t arg) {
static T getNumber(lua_State* L, int32_t arg, std::source_location location = std::source_location::current()) {
auto number = lua_tonumber(L, arg);

if constexpr (std::is_enum_v<T>) {
Expand All @@ -73,7 +73,7 @@ class Lua {
if constexpr (std::is_integral_v<T>) {
if constexpr (std::is_unsigned_v<T>) {
if (number < 0) {
g_logger().debug("[{}] overflow, setting to default unsigned value (0)", __FUNCTION__);
g_logger().debug("[{}] overflow, setting to default unsigned value (0), called line: {}:{}, in {}", __FUNCTION__, location.line(), location.column(), location.function_name());
return T(0);
}
}
Expand Down

0 comments on commit 729387b

Please sign in to comment.