minetest-smartshop/util.lua:12: invalid option '%'' to 'format' #5962

Closed
opened 2024-01-12 13:47:30 +00:00 by AliasAlreadyTaken · 29 comments
2024-01-12 13:38:03: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '' in callback on_playerReceiveFields(): ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: invalid option '%'' to 'format'
2024-01-12 13:38:03: ERROR[Main]: stack traceback:
2024-01-12 13:38:03: ERROR[Main]: 	[C]: in function 'format'
2024-01-12 13:38:03: ERROR[Main]: 	....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: in function 'error'
2024-01-12 13:38:03: ERROR[Main]: 	....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:77: in function 'check_player_add'
2024-01-12 13:38:03: ERROR[Main]: 	...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:153: in function 'do_purchase'
2024-01-12 13:38:03: ERROR[Main]: 	...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:68: in function 'try_purchase'
2024-01-12 13:38:03: ERROR[Main]: 	...t_live/bin/../mods/minetest-smartshop/api/shop_class.lua:536: in function 'receive_fields'
2024-01-12 13:38:03: ERROR[Main]: 	...est_live/bin/../mods/minetest-smartshop/api/formspec.lua:48: in function 'func'
2024-01-12 13:38:03: ERROR[Main]: 	...inetest_live/bin/../builtin/profiler/instrumentation.lua:108: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:101>
2024-01-12 13:38:03: ERROR[Main]: 	.../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:446: in function <.../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:432>

``` 2024-01-12 13:38:03: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '' in callback on_playerReceiveFields(): ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: invalid option '%'' to 'format' 2024-01-12 13:38:03: ERROR[Main]: stack traceback: 2024-01-12 13:38:03: ERROR[Main]: [C]: in function 'format' 2024-01-12 13:38:03: ERROR[Main]: ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: in function 'error' 2024-01-12 13:38:03: ERROR[Main]: ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:77: in function 'check_player_add' 2024-01-12 13:38:03: ERROR[Main]: ...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:153: in function 'do_purchase' 2024-01-12 13:38:03: ERROR[Main]: ...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:68: in function 'try_purchase' 2024-01-12 13:38:03: ERROR[Main]: ...t_live/bin/../mods/minetest-smartshop/api/shop_class.lua:536: in function 'receive_fields' 2024-01-12 13:38:03: ERROR[Main]: ...est_live/bin/../mods/minetest-smartshop/api/formspec.lua:48: in function 'func' 2024-01-12 13:38:03: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:108: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:101> 2024-01-12 13:38:03: ERROR[Main]: .../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:446: in function <.../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:432> ```
AliasAlreadyTaken added the
1. kind/bug
2. prio/critical
labels 2024-01-12 13:47:39 +00:00

This was triggered in the main from attempting to buy canned carrots from BluOXide's haven shop. It occured twice, both time I was trying to purchase canned carrots.

This was triggered in the main from attempting to buy canned carrots from BluOXide's haven shop. It occured twice, both time I was trying to purchase canned carrots.
Author
Owner
	util.error(
		"ERROR: %s lost %q on add using %'s shop @ %s",
		player_name,
		remainder:to_string(),
		shop:get_owner(),
		shop:get_pos_as_string()
	)

The only thing I see odd is %'s in Line 78, but this is not the only occurrence.

```lua util.error( "ERROR: %s lost %q on add using %'s shop @ %s", player_name, remainder:to_string(), shop:get_owner(), shop:get_pos_as_string() ) ``` The only thing I see odd is `%'s` in Line 78, but this is not the only occurrence.
Author
Owner

We couldn't reproduce on the testserver though

We couldn't reproduce on the testserver though
Member

Looks like player was buying a stack while having space in the inventory for less than a stack.
Shop should just log the leftover amount, but there's a typo in the format string.

Basically every %'s should become %s's.

Looks like player was buying a stack while having space in the inventory for less than a stack. Shop should just log the leftover amount, but there's a typo in the format string. Basically every `%'s` should become `%s's`.
flux added the
3. source/mod upstream
4. step/at work
labels 2024-01-12 17:34:28 +00:00
Member

fixed the crash: 9e586ae4f7

it's worrying that it even gets to that point though, it's supposed to run a full simulation of the exchange using fake inventories before attempting to actually transfer the items. i'll look into it a bit further.

fixed the crash: https://github.com/fluxionary/minetest-smartshop/commit/9e586ae4f7981a06e40f119cd3d829b2bd73b317 it's worrying that it even gets to that point though, it's supposed to run a full simulation of the exchange using fake inventories before attempting to actually transfer the items. i'll look into it a bit further.
flux added the
4. step/ready to QA test
label 2024-01-12 17:39:56 +00:00
AliasAlreadyTaken added this to the 1.1.123 milestone 2024-01-12 17:48:38 +00:00
Member

Looks like player was buying a stack while having space in the inventory for less than a stack.

i can't replicate the issue locally with a full inventory, or with an almost full inventory with a partial stack of the full stack that's being bought.

@AliasAlreadyTaken is it possible to get the logs from your-land/log_yl_main#105 and your-land/log_yl_main#106 before the crash happened? the spam of entities unloading makes it hard to tell if there's other relevant context.

added some more logging as well 299d9af92f

> Looks like player was buying a stack while having space in the inventory for less than a stack. i can't replicate the issue locally with a full inventory, or with an almost full inventory with a partial stack of the full stack that's being bought. @AliasAlreadyTaken is it possible to get the logs from https://gitea.your-land.de/your-land/log_yl_main/issues/105 and https://gitea.your-land.de/your-land/log_yl_main/issues/106 before the crash happened? the spam of entities unloading makes it hard to tell if there's other relevant context. added some more logging as well https://github.com/fluxionary/minetest-smartshop/commit/299d9af92f40822c02a83a1c5ae5351f2d6f38fc
Member

@AliasAlreadyTaken is it possible to get the logs from your-land/log_yl_main#105 and your-land/log_yl_main#106 before the crash happened? the spam of entities unloading makes it hard to tell if there's other relevant context.

I suggest that logs that go on gitea should be filtered from deactivated and probably some other messages. Those lines only push useful context out of the posted log.

> @AliasAlreadyTaken is it possible to get the logs from https://gitea.your-land.de/your-land/log_yl_main/issues/105 and https://gitea.your-land.de/your-land/log_yl_main/issues/106 before the crash happened? the spam of entities unloading makes it hard to tell if there's other relevant context. I suggest that logs that go on gitea should be filtered from `deactivated` and probably some other messages. Those lines only push useful context out of the posted log.
Author
Owner

I assume that's the thing we're looking for:

2024-01-12 13:37:52: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""}
2024-01-12 13:37:52: ACTION[Main]: Server: Shutting down

2024-01-12 13:39:59: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""}
2024-01-12 13:39:59: ACTION[Main]: Server: Shutting down

I assume that's the thing we're looking for: 2024-01-12 13:37:52: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""} 2024-01-12 13:37:52: ACTION[Main]: Server: Shutting down 2024-01-12 13:39:59: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""} 2024-01-12 13:39:59: ACTION[Main]: Server: Shutting down
Member

I assume that's the thing we're looking for:

2024-01-12 13:37:52: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""}
2024-01-12 13:37:52: ACTION[Main]: Server: Shutting down

2024-01-12 13:39:59: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""}
2024-01-12 13:39:59: ACTION[Main]: Server: Shutting down

if that's all that's there, it's not super helpful, but thanks :)

> I assume that's the thing we're looking for: > > 2024-01-12 13:37:52: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""} > 2024-01-12 13:37:52: ACTION[Main]: Server: Shutting down > > 2024-01-12 13:39:59: ACTION[Server]: [yl_commons] formspec "smartshop:form": DragonWrangler1 submitted {"buy3a":""} > 2024-01-12 13:39:59: ACTION[Main]: Server: Shutting down > if that's all that's there, it's not super helpful, but thanks :)
Author
Owner
2024-01-17 17:11:38: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'smartshop' in callback on_playerReceiveFields(): ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: invalid option '%'' to 'format'
2024-01-17 17:11:38: ERROR[Main]: stack traceback:
2024-01-17 17:11:38: ERROR[Main]: [C]: in function 'format'
2024-01-17 17:11:38: ERROR[Main]: ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: in function 'error'
2024-01-17 17:11:38: ERROR[Main]: ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:77: in function 'check_player_add'
2024-01-17 17:11:38: ERROR[Main]: ...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:153: in function 'do_purchase'
2024-01-17 17:11:38: ERROR[Main]: ...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:68: in function 'try_purchase'
2024-01-17 17:11:38: ERROR[Main]: ...t_live/bin/../mods/minetest-smartshop/api/shop_class.lua:536: in function 'receive_fields'
2024-01-17 17:11:38: ERROR[Main]: ...est_live/bin/../mods/minetest-smartshop/api/formspec.lua:48: in function 'func'
2024-01-17 17:11:38: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:108: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:101>
2024-01-17 17:11:38: ERROR[Main]: .../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:446: in function <.../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:432>

I dumbfixed it by replacing the %'s with %s's.

``` 2024-01-17 17:11:38: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'smartshop' in callback on_playerReceiveFields(): ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: invalid option '%'' to 'format' 2024-01-17 17:11:38: ERROR[Main]: stack traceback: 2024-01-17 17:11:38: ERROR[Main]: [C]: in function 'format' 2024-01-17 17:11:38: ERROR[Main]: ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:12: in function 'error' 2024-01-17 17:11:38: ERROR[Main]: ....0/Minetest_live/bin/../mods/minetest-smartshop/util.lua:77: in function 'check_player_add' 2024-01-17 17:11:38: ERROR[Main]: ...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:153: in function 'do_purchase' 2024-01-17 17:11:38: ERROR[Main]: ...in/../mods/minetest-smartshop/api/purchase_mechanics.lua:68: in function 'try_purchase' 2024-01-17 17:11:38: ERROR[Main]: ...t_live/bin/../mods/minetest-smartshop/api/shop_class.lua:536: in function 'receive_fields' 2024-01-17 17:11:38: ERROR[Main]: ...est_live/bin/../mods/minetest-smartshop/api/formspec.lua:48: in function 'func' 2024-01-17 17:11:38: ERROR[Main]: ...inetest_live/bin/../builtin/profiler/instrumentation.lua:108: in function <...inetest_live/bin/../builtin/profiler/instrumentation.lua:101> 2024-01-17 17:11:38: ERROR[Main]: .../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:446: in function <.../mt/5.7.0/Minetest_live/bin/../builtin/game/register.lua:432> ``` I dumbfixed it by replacing the `%'s` with `%s's`.
Author
Owner

QA

Looks like it's fixed, I can't reproduce it.

QA Looks like it's fixed, I can't reproduce it.
AliasAlreadyTaken added the
ugh/QA main
label 2024-01-28 12:30:23 +00:00
Member

Looks like it's fixed, I can't reproduce it.

i still want to know if there's error/warning level messages from the smartshop. i tried to make sure those never happened, but this bug means that there's something i'm not accounting for.

> Looks like it's fixed, I can't reproduce it. i still want to know if there's error/warning level messages from the smartshop. i tried to make sure those never happened, but this bug means that there's something i'm not accounting for.

It was triggered by having a full inv, but having the payment for an item in my inv and it trying to exchange them

It was triggered by having a full inv, but having the payment for an item in my inv and it trying to exchange them
Author
Owner

It was triggered by having a full inv, but having the payment for an item in my inv and it trying to exchange them

This is a case I tried with the bugfix

> It was triggered by having a full inv, but having the payment for an item in my inv and it trying to exchange them This is a case I tried with the bugfix
Member

For some weird reason it's not as trivial to trigger, I was not able to repro it even once locally.
@DragonWrangler : do you remember exactly how much payment you had, if you already had some of the carrots in your inv, etc?
Maybe you can try reproduce it it locally too?

For some weird reason it's not as trivial to trigger, I was not able to repro it even once locally. @DragonWrangler : do you remember exactly how much payment you had, if you already had some of the carrots in your inv, etc? Maybe you can try reproduce it it locally too?

whosit I had gold split up into two groups on group had a bit over 20(not sure quite how much more) and the other had 2 gold. I already had carrots in my inv, but only a few. All I did was click on the carrots icon, the server crashed, when I reloaded some of my gold from the large stack was missing, I tried again and the same thing happened.

edit: I'll try to reproduce it.

whosit I had gold split up into two groups on group had a bit over 20(not sure quite how much more) and the other had 2 gold. I already had carrots in my inv, but only a few. All I did was click on the carrots icon, the server crashed, when I reloaded some of my gold from the large stack was missing, I tried again and the same thing happened. edit: I'll try to reproduce it.

I was able to replicate it in a private server on a previous version
edit: this was replicated on a previous version. Testing the newest one now.

Tested the newest version and I can't replicate it

I was able to replicate it in a private server on a previous version edit: this was replicated on a previous version. Testing the newest one now. Tested the newest version and I can't replicate it
Member

Current version should not crash, but it should log errors.
Can you provide the errors from the log?
And also, can you please describe actual steps, so we could reproduce it too?

Current version should not crash, but it should log errors. Can you provide the errors from the log? And also, can you please describe actual steps, so we could reproduce it too?

for the newest version there was no error, not even in the log. Here is the log error for the older Version:

ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'smartshop' in callback on_playerReceiveFields(): /home/../.minetest/mods/smartshop/util.lua:12: invalid option '%'' to 'format'
ERROR[Main]: stack traceback:
ERROR[Main]: [C]: in function 'format'
ERROR[Main]: /home/../.minetest/mods/smartshop/util.lua:12: in function 'error'
ERROR[Main]: /home/../.minetest/mods/smartshop/util.lua:77: in function 'check_player_add'
ERROR[Main]: .../.minetest/mods/smartshop/api/purchase_mechanics.lua:153: in function 'do_purchase'
ERROR[Main]: .../.minetest/mods/smartshop/api/purchase_mechanics.lua:68: in function 'try_purchase'
ERROR[Main]: /home/../.minetest/mods/smartshop/api/shop_class.lua:536: in function 'receive_fields'
ERROR[Main]: /home/../.minetest/mods/smartshop/api/formspec.lua:48: in function </home/../.minetest/mods/smartshop/api/formspec.lua:40>
ERROR[Main]: /usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12>

to reproduce,first make a smartshop selling a stack of canned carrots for 2 gold each, then put items in your inv, fill every spot except 3, it doesn't matter what item, then put one canned carrot in one slot, and a stack of gold in the other. then put 2 gold ingots in the last remaining slot. After that purchase and it should crash.

for the newest version there was no error, not even in the log. Here is the log error for the older Version: >ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'smartshop' in callback on_playerReceiveFields(): /home/../.minetest/mods/smartshop/util.lua:12: invalid option '%'' to 'format' ERROR[Main]: stack traceback: ERROR[Main]: [C]: in function 'format' ERROR[Main]: /home/../.minetest/mods/smartshop/util.lua:12: in function 'error' ERROR[Main]: /home/../.minetest/mods/smartshop/util.lua:77: in function 'check_player_add' ERROR[Main]: .../.minetest/mods/smartshop/api/purchase_mechanics.lua:153: in function 'do_purchase' ERROR[Main]: .../.minetest/mods/smartshop/api/purchase_mechanics.lua:68: in function 'try_purchase' ERROR[Main]: /home/../.minetest/mods/smartshop/api/shop_class.lua:536: in function 'receive_fields' ERROR[Main]: /home/../.minetest/mods/smartshop/api/formspec.lua:48: in function </home/../.minetest/mods/smartshop/api/formspec.lua:40> ERROR[Main]: /usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12> to reproduce,first make a smartshop selling a stack of canned carrots for 2 gold each, then put items in your inv, fill every spot except 3, it doesn't matter what item, then put one canned carrot in one slot, and a stack of gold in the other. then put 2 gold ingots in the last remaining slot. After that purchase and it should crash.

Huh. So after a bit more testing, when I try it on the newest version it doesn't crash, however. If you try buying a stack of canned carrots and you already have some in your inv, but you have no other free slots, it will fill up the slot, but won't give you an error saying not enough room, so anything you don't have room for disappears

edit: it'll even do that if you have no room in your inv. The seller gets paid, but you don't receive items
2nd edit: I just tried it on the testserver and I can't reproduce it
3rd edit: I just reproduced it, have 2 different stacks of payment in your inv, also I got a message in my chat when trying to purchase telling me what was in my bags and inv, it said:

ERROR: DragonWrangler1 lost "canned_food:canned_potato 99" on add using BLuOXide's shop (2086,17,1144) (shop inv={
give1 = {
ItemStack("farming:baked_potato 99")
},
pay1 = {
ItemStack("default:gold_ingot")
},
give3 = {
ItemStack("canned_food:canned_carrot 99")
},
pay3 = {
ItemStack("default:gold_ingot 2")
},
give4 = {
ItemStack("farming:potato 99")
},
pay4 = {
ItemStack("default:gold_ingot")
},
main = {
ItemStack("farming:potato 99"),
ItemStack("canned_food:canned_potato 99"),
ItemStack("canned_food:canned_potato 99"),
ItemStack("canned_food:canned_potato 99"),
ItemStack("farming:potato 99"),
ItemStack("canned_food:canned_potato 99"),
ItemStack("canned_food:canned_potato 99"),
ItemStack("farming:potato 99"),
ItemStack("farming:potato 99"),
ItemStack("farming:potato 99"),
ItemStack("farming:potato 99"),
ItemStack("default:gold_ingot 12"),
ItemStack("canned_food:canned_potato 99"),
ItemStack(""),
ItemStack("farming:potato 99"),
ItemStack("farming:potato 99"),
ItemStack("farming:baked_potato 99"),
ItemStack("farming:baked_potato 99"),
ItemStack("farming:baked_potato 99"),
ItemStack("farming:baked_potato 99"),
ItemStack(""),
ItemStack(""),
ItemStack("farming:baked_potato 99"),
ItemStack("farming:baked_potato 99"),
ItemStack("farming:baked_potato 99"),
ItemStack("canned_food:canned_potato 99"),
ItemStack(""),
ItemStack("farming:baked_potato 99"),
ItemStack(""),
ItemStack(""),
ItemStack(""),
ItemStack(""),
},
pay2 = {
ItemStack("default:gold_ingot 3")
},
give2 = {
ItemStack("canned_food:canned_potato 99")
}
}) (player_inv={
craft = {
ItemStack(""),
ItemStack(""),
ItemStack(""),
ItemStack(""),
]
ItemStack(""),
ItemStack(""),
ItemStack(""),
ItemStack("moreblocks:slab_pine_wood_1 51"),
ItemStack("default:chest 3")
},
hand = {
ItemStack("skinsdb:charactermagem1png")
},
craftresult = {
ItemStack("")
},
main = {
ItemStack("moreores:enchante_sword_mithril_sharp 1 716"),
ItemStack("canned_food:canned_carrot 75"),
ItemStack("mobs:pick_lava 1 290"),
ItemStack("ethereal:golden_apple 87"),
ItemStack("mobs:lasso 1 2057"),
ItemStack("moreores:enchanted_pick_mithril_fast 1 2427"),
ItemStack("orbs_of_time:orb_dawn"),
ItemStack("anvil:anvil 2"),
ItemStack("anvil:hammer 1 7100"),
ItemStack("replacer:replacer 1 0 "),
ItemStack("anvil:hammer"),
ItemStack("fireflies:bug_net 1 24320"),
ItemStack("mobs:shears"),
ItemStack("default:gold_ingot 2"),
ItemStack("ethereal:shovel_crystal 1 7702"),
ItemStack("vines:shears 1 320"),
ItemStack("moreores:shovel_mithril 1 8784"),
ItemStack("moreblocks:stair_junglewood 3"),
ItemStack("map:mapping_kit"),
ItemStack("binoculars:binoculars"),
ItemStack("screwdriver:screwdriver 1 62584"),
ItemStack("default:gold_ingot 6"),
ItemStack("moreores:axe_mithril 1 3978"),
ItemStack("default:pine_wood 65"),
ItemStack("mobs:net 1 107"),
ItemStack("vessels:glass_bottle 99"),
ItemStack("doors:trapdoor 8"),
ItemStack("beds:fancy_bed_bottom 2"),
ItemStack("default:junglewood 5"),
ItemStack("wool:white 87"),
ItemStack("default:bookshelf"),
ItemStack("vessels:glass_bottle 5"),
},
craftpreview = {
ItemStack("")
}
})

I left out it's list of my bags' inv due to how long it might be to copy, but I can include that if you'd like

Huh. So after a bit more testing, when I try it on the newest version it doesn't crash, however. If you try buying a stack of canned carrots and you already have some in your inv, but you have no other free slots, it will fill up the slot, but won't give you an error saying not enough room, so anything you don't have room for disappears edit: it'll even do that if you have no room in your inv. The seller gets paid, but you don't receive items 2nd edit: I just tried it on the testserver and I can't reproduce it 3rd edit: I just reproduced it, have 2 different stacks of payment in your inv, also I got a message in my chat when trying to purchase telling me what was in my bags and inv, it said: ERROR: DragonWrangler1 lost "canned_food:canned_potato 99" on add using BLuOXide's shop (2086,17,1144) (shop inv={ give1 = { ItemStack("farming:baked_potato 99") }, pay1 = { ItemStack("default:gold_ingot") }, give3 = { ItemStack("canned_food:canned_carrot 99") }, pay3 = { ItemStack("default:gold_ingot 2") }, give4 = { ItemStack("farming:potato 99") }, pay4 = { ItemStack("default:gold_ingot") }, main = { ItemStack("farming:potato 99"), ItemStack("canned_food:canned_potato 99"), ItemStack("canned_food:canned_potato 99"), ItemStack("canned_food:canned_potato 99"), ItemStack("farming:potato 99"), ItemStack("canned_food:canned_potato 99"), ItemStack("canned_food:canned_potato 99"), ItemStack("farming:potato 99"), ItemStack("farming:potato 99"), ItemStack("farming:potato 99"), ItemStack("farming:potato 99"), ItemStack("default:gold_ingot 12"), ItemStack("canned_food:canned_potato 99"), ItemStack(""), ItemStack("farming:potato 99"), ItemStack("farming:potato 99"), ItemStack("farming:baked_potato 99"), ItemStack("farming:baked_potato 99"), ItemStack("farming:baked_potato 99"), ItemStack("farming:baked_potato 99"), ItemStack(""), ItemStack(""), ItemStack("farming:baked_potato 99"), ItemStack("farming:baked_potato 99"), ItemStack("farming:baked_potato 99"), ItemStack("canned_food:canned_potato 99"), ItemStack(""), ItemStack("farming:baked_potato 99"), ItemStack(""), ItemStack(""), ItemStack(""), ItemStack(""), }, pay2 = { ItemStack("default:gold_ingot 3") }, give2 = { ItemStack("canned_food:canned_potato 99") } }) (player_inv={ craft = { ItemStack(""), ItemStack(""), ItemStack(""), ItemStack(""), ] ItemStack(""), ItemStack(""), ItemStack(""), ItemStack("moreblocks:slab_pine_wood_1 51"), ItemStack("default:chest 3") }, hand = { ItemStack("skinsdb:charactermagem1png") }, craftresult = { ItemStack("") }, main = { ItemStack("moreores:enchante_sword_mithril_sharp 1 716"), ItemStack("canned_food:canned_carrot 75"), ItemStack("mobs:pick_lava 1 290"), ItemStack("ethereal:golden_apple 87"), ItemStack("mobs:lasso 1 2057"), ItemStack("moreores:enchanted_pick_mithril_fast 1 2427"), ItemStack("orbs_of_time:orb_dawn"), ItemStack("anvil:anvil 2"), ItemStack("anvil:hammer 1 7100"), ItemStack("replacer:replacer 1 0 <metadate size=4>"), ItemStack("anvil:hammer"), ItemStack("fireflies:bug_net 1 24320"), ItemStack("mobs:shears"), ItemStack("default:gold_ingot 2"), ItemStack("ethereal:shovel_crystal 1 7702"), ItemStack("vines:shears 1 320"), ItemStack("moreores:shovel_mithril 1 8784"), ItemStack("moreblocks:stair_junglewood 3"), ItemStack("map:mapping_kit"), ItemStack("binoculars:binoculars"), ItemStack("screwdriver:screwdriver 1 62584"), ItemStack("default:gold_ingot 6"), ItemStack("moreores:axe_mithril 1 3978"), ItemStack("default:pine_wood 65"), ItemStack("mobs:net 1 107"), ItemStack("vessels:glass_bottle 99"), ItemStack("doors:trapdoor 8"), ItemStack("beds:fancy_bed_bottom 2"), ItemStack("default:junglewood 5"), ItemStack("wool:white 87"), ItemStack("default:bookshelf"), ItemStack("vessels:glass_bottle 5"), }, craftpreview = { ItemStack("") } }) I left out it's list of my bags' inv due to how long it might be to copy, but I can include that if you'd like
Member

gold split up into two groups

this is a very good clue

but won't give you an error saying not enough room, so anything you don't have room for disappears

it should log it as an error. do you not see that in your logs?

EDIT: oh i see you did post the log

> gold split up into two groups this is a very good clue > but won't give you an error saying not enough room, so anything you don't have room for disappears it *should* log it as an error. do you not see that in your logs? EDIT: oh i see you did post the log
Member

to reproduce,first make a smartshop selling a stack of canned carrots for 2 gold each, then put items in your inv, fill every spot except 3, it doesn't matter what item, then put one canned carrot in one slot, and a stack of gold in the other. then put 2 gold ingots in the last remaining slot. After that purchase and it should crash.

here's my setup:

image

i get the message "[smartshop] Cannot exchange: No room in your inventory"

> to reproduce,first make a smartshop selling a stack of canned carrots for 2 gold each, then put items in your inv, fill every spot except 3, it doesn't matter what item, then put one canned carrot in one slot, and a stack of gold in the other. then put 2 gold ingots in the last remaining slot. After that purchase and it should crash. here's my setup: ![image](/attachments/71278ef8-ce5a-4dd2-b170-a38d840b0f2f) i get the message "[smartshop] Cannot exchange: No room in your inventory"

try having less than one stack of gold in that one slot, I can reproduce it on test still

try having less than one stack of gold in that one slot, I can reproduce it on test still
Member

try having less than one stack of gold in that one slot, I can reproduce it on test still

verified that if i've got 2 non-full stacks of payment, and everything else is random crap, i can replicate the issue. blech.

> try having less than one stack of gold in that one slot, I can reproduce it on test still verified that if i've got 2 non-full stacks of payment, and everything else is random crap, i can replicate the issue. blech.
flux added this to the flux's TODO list project 2024-02-02 05:24:50 +00:00
flux self-assigned this 2024-02-02 05:24:55 +00:00
flux removed the
4. step/ready to QA test
label 2024-02-02 05:25:01 +00:00
Member

image
Just for the record, this setup works for me.
During "simulated exchange", futil.FakeInventory() takes item from the first stack and now there's space for the purchased items.
But when actual exchange happens, real inventory removes items from the last stack, and there's no room for purchased item.

![image](/attachments/2367b9ca-9672-4471-b52d-bd2eaf357167) Just for the record, this setup works for me. During "simulated exchange", `futil.FakeInventory()` takes item from the first stack and now there's space for the purchased items. But when actual exchange happens, real inventory removes items from the last stack, and there's no room for purchased item.
Member

fixed in futil: 199191fac3

i also added some additional tests to the smartshop, but those aren't meaningful on a real server.

fixed in futil: https://github.com/fluxionary/minetest-futil/commit/199191fac3dfa2d6abcfc90ce638c766912f2e06 i also added some additional tests to the smartshop, but those aren't meaningful on a real server.
flux added
4. step/ready to QA test
and removed
4. step/at work
labels 2024-02-08 20:52:15 +00:00
Member

removeItem() in cpp:
eb52a149a0/src/inventory.cpp (L714C16-L714C23)

	std::vector<ItemStack> m_items;
...
ItemStack InventoryList::removeItem(const ItemStack &item)
..
   for (auto i = m_items.rbegin(); i != m_items.rend(); ++i) {

still not clear to me why it's backwards...

`removeItem()` in cpp: https://github.com/minetest/minetest/blob/eb52a149a09dd8811d5defc4fe85af5bcc84dba7/src/inventory.cpp#L714C16-L714C23 ```cpp std::vector<ItemStack> m_items; ... ItemStack InventoryList::removeItem(const ItemStack &item) .. for (auto i = m_items.rbegin(); i != m_items.rend(); ++i) { ``` still not clear to me why it's backwards...
Member

still not clear to me why it's backwards...

that's ... interesting. i'm about to call it a night, but it seems worth digging in to. it's c++, that code itself doesn't mean that the iteration order isn't backwards, but it's worth understanding.

> still not clear to me why it's backwards... that's ... interesting. i'm about to call it a night, but it seems worth digging in to. it's c++, that code itself doesn't mean that the iteration order isn't backwards, but it's worth understanding.
flux added
5. result/fixed
and removed
4. step/ready to QA test
labels 2024-03-29 22:00:47 +00:00
flux removed this from the flux's TODO list project 2024-03-29 22:00:50 +00:00
flux removed their assignment 2024-03-29 22:00:53 +00:00
Member

i guess this never went through QA for some reason, but it's live.

i guess this never went through QA for some reason, but it's live.
flux closed this issue 2024-03-29 22:01:21 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#5962
No description provided.