Skip to content

Commit

Permalink
dump inventories to log if there's an error in the exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
fluxionary committed Jan 12, 2024
1 parent 9e586ae commit 299d9af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
4 changes: 4 additions & 0 deletions api/inv_class.lua
Expand Up @@ -84,6 +84,10 @@ function inv_class:remove_item(stack, match_meta)
return removed
end

function inv_class:get_lists()
return self.inv:get_lists()
end

--------------------

function inv_class:get_tmp_inv()
Expand Down
25 changes: 18 additions & 7 deletions util.lua
Expand Up @@ -43,7 +43,13 @@ function util.check_shop_add_remainder(shop, remainder)
local owner = shop:get_owner()
local pos_as_string = shop:get_pos_as_string()

util.error("ERROR: %s's smartshop @ %s lost %q while adding", owner, pos_as_string, remainder:to_string())
util.error(
"ERROR: %s's smartshop @ %s lost %q while adding (shop inv=%s)",
owner,
pos_as_string,
remainder:to_string(),
dump(shop:get_lists())
)

return true
end
Expand All @@ -57,11 +63,12 @@ function util.check_shop_remove_remainder(shop, remainder, expected)
local pos_as_string = shop:get_pos_as_string()

util.error(
"ERROR: %s's smartshop @ %s lost %q of %q while removing",
"ERROR: %s's smartshop @ %s lost %q of %q while removing (shop inv=%s)",
owner,
pos_as_string,
remainder:to_string(),
expected:to_string()
expected:to_string(),
dump(shop:get_lists())
)

return true
Expand All @@ -75,11 +82,13 @@ function util.check_player_add_remainder(player_inv, shop, remainder)
local player_name = player_inv.name

util.error(
"ERROR: %s lost %q on add using %s's shop @ %s",
"ERROR: %s lost %q on add using %s's shop @ %s (shop inv=%s) (player_inv=%s)",
player_name,
remainder:to_string(),
shop:get_owner(),
shop:get_pos_as_string()
shop:get_pos_as_string(),
dump(shop:get_lists()),
dump(player_inv:get_lists())
)

return true
Expand All @@ -93,12 +102,14 @@ function util.check_player_remove_remainder(player_inv, shop, remainder, expecte
local player_name = player_inv.name

util.error(
"ERROR: %s lost %q of %q on remove from %s's shop @ %s",
"ERROR: %s lost %q of %q on remove from %s's shop @ %s (shop inv=%s) (player_inv=%s)",
player_name,
remainder:to_string(),
expected:to_string(),
shop:get_owner(),
shop:get_pos_as_string()
shop:get_pos_as_string(),
dump(shop:get_lists()),
dump(player_inv:get_lists())
)

return true
Expand Down

0 comments on commit 299d9af

Please sign in to comment.