yl_speak_up: on server join, I get every other player's detached inventory for NPCs #6235
Labels
No Label
1. kind/balancing
1. kind/breaking
1. kind/bug
1. kind/construction
1. kind/documentation
1. kind/enhancement
1. kind/griefing
1. kind/invalid
1. kind/meme
1. kind/node limit
1. kind/other
1. kind/protocol
2. prio/controversial
2. prio/critical
2. prio/elevated
2. prio/good first issue
2. prio/interesting
2. prio/low
3. source/art
3. source/client
3. source/engine
3. source/ingame
3. source/integration
3. source/lag
3. source/license
3. source/mod upstream
3. source/unknown
3. source/website
4. step/approved
4. step/at work
4. step/blocked
4. step/discussion
4. step/help wanted
4. step/needs confirmation
4. step/partially fixed
4. step/question
4. step/ready to deploy
4. step/ready to QA test
4. step/want approval
5. result/cannot reproduce
5. result/duplicate
5. result/fixed
5. result/maybe
5. result/wontfix
ugh/petz
ugh/QA main
ugh/QA NOK
ugh/QA OK
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: your-land/bugtracker#6235
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Detached inventories should be sent only to players they belong to, and ideally only on demand.
there's a way to restrict sending detached inventory actions to a single player:
https://github.com/minetest/minetest/blob/master/doc/lua_api.md?plain=1#L6243-L6247
however, there's no way to say that some small set of players should have access. is it correct to limit NPC inventories this way?
Should be possible to just not send it until player is accessing NPC that contains it?
Or I'm missing something?
When I'm joining main, I get 368 detached inventories, obviously most of those players are not online and don't own NPCs
i'm not really sure what the relationship between the detached inventory and the NPC is though - the NPC is owned by a particular player, but i think the inventory is NPC-specific, and anyone who has admin-access needs to have access to the NPC's inventory as well. and we can't use e.g. my FakeInventory from futil because you can't make that show up in a formspec. but maybe the inventory could normally be stored in a FakeInventory (or serialized inventory) and only reify when someone actually interacts with the NPC? but that's not a great solution either, because there's no reliable signal when a formspec is closed, and things get complicated if multiple people try to interact with the NPC at the same time.
how many node inventories do you get? there's tons of those around spawn. 368 is a lot, but not absurd for a one-time send.
c7f9fc81c3/api/api_trade_inv.lua (L207)
It's this one, it's an inventory of a specific player, and number of inventories will just keep growing as players join, until next server restart.
Fix is: send it only to player that it it belongs to, and remove when player leaves?
oh! yeah that's definitely what should be happening. it might even be better implemented as a player inventory.
Really sounds like an error. I ought to limit at least the detached player inventory to the player himself. That inv is needed for giving items to the NPC, getting items, setting up trades etc.
It also ought to be removed when the player leaves.
The other detached inventory is that of the NPC. It gets created when the NPC gets talked to - and then cached. Removing that again is more difficult due to the reasons flux pointed out. I might be able to check if someone is still talking to the NPC and clean unused inventories up occasionally. Will have to check that out.
Thanks for discovering these errors!
I'd like to point towards similar problems of "inventory exchange" for yl_trade and other mods that require detached inventories.
Was this not already once solved in smartshops?
There's a problem of "where" to store the data.
In my collectible_chest mod I have some client-side warnings because I create detached inv and then send the formspec with it on the same step, but either packers arrive out of order, or client processes them differently, but sometimes it prints a warning that inv does not exist, but then it appears inside the formspec just fine...
the use of detached inventories in smartshop was temporary, but it happened every time the shops loaded. it was part of the logic that controls the shop's color and updates the infotext. the big problem was that every action on the detached inventory was sent to every client, even if the detached inventory was destroyed before anyone could actually interact with it. it got replaced with the fake inventory instead. that's not applicable here, because the NPCs actually need to have an inventory that players can interact with.
the player inventory is stored properly in a database table and not as a serialized blob, i'm don't think this is applicable.
you can hide metadata from clients, but not node inventories, so far as i know. i've tried.
This was 100% the case with sqlite backend for me - because I turned on async option for sqlite and lag spike was gone.
There was also a patch that does same for postgresql, but it was not merged. Still want to see if there's a difference for postgres too.
I mean, you can just serialize whatever into a block and then generate detached inv to show it. What I was trying to say is that the data will be available when the block is loaded - so it makes sense to store it in a block.
Sure, you can't make private an inventory that you want to be processes client-side...
i think alias tried that, but we didn't notice anything different
should be fixed here:
691301019b...db2abf76fe
Unfortunately we can't use the latest version of NPCs due to the z fighting issue on the capes: your-land/bugtracker#6238
Actual bug is this one, and I think it may be fixed now?
#6171
QA
Back to testing ... whosti: could you wireshark the testserver and say whether it's solved?
This is all detached inventories I get on join to test:
9 packets total
someone should disable that "whosit" mod 😜
i don't know what the other mods are, but
whosittrash_review
should certainly be using a player inventory instead of a detached one.What's the difference between trash and unified_trash and trash_review?
I also don't see why bags need a detached inventory, its not that anyone else would interact with them
Same goes for armour?
I suggest we continue this here:
#6313
i don't see any more NPC inventories (or at least not tons of them)