一个开启ssc后刷物品的问题
开启ssc后 玩家在单人游戏中,随便选一个物品,好的不要放下来,直接点设置返回主菜单 进入多人游戏,进入tshock开的服务器,你会发现选的物品直接出现在玩家的背包里 经过我测试,inventory根本获取不到这个物品,但是实实在在存在,然后重复进出,这个物品也会重复获取 现在我解决的办法只有,记录退出时记录背包,进入后用额外适配的插件加载背包
这个问题不仅仅是选取物品,通过向导的制作也可以带进来。
尝试修复:https://tr.monika.love/resources/171/
I think it's related to #2948. The ServerLeave event doesn't fire so the user inventory is not saved at exit.
I'm having trouble understanding translations of this one if anyone can help (@sgkoishi, @ACaiCat?)
I'm having trouble understanding translations of this one if anyone can help (@sgkoishi,@ACaiCat?)
Acknowledged and reproduced issue.
Reproduction goes as follows :
Context
Remote server :
- SSC: enabled
- Login before join: enabled
- Known player and account created
Steps
- Load a singleplayer world with a character, which is bound to a SSC on a remote server.
- Grab in your hand the most overpowered item you can fathom (SDMG or Zenith, for good measure).
- With the item still in hand, head for Settings and exit to main menu. (does not work on multiplayer instances)
- Connect to said SSC-enabled server.
- You're now holding that contraband item, ready to nuke the server's balance.
- Disconnect at your convenience, after stashing your illicit item, or giving it to your battle buddy.
- (Optional) Rinse and repeat steps 4 to 6 to piss off server admins and provide the entire server with Zeniths and SDMGs.
This is how a random character can dupe Zeniths in the span of 5 reconnects.
Workaround
Such an exploit can be warded entirely by setting "DisableLoginBeforeJoin": true. Server admins are advised to apply this change, pending a future fix.
I think it's related to #2948. The ServerLeave event doesn't fire so the user inventory is not saved at exit.
Tested a few minutes ago, OnServerLeave does fire here locally, but is completely ineffective at resolving the issue.
After some tests, seems like the item is not detected in-hand, while sending to the server.
I might be wrong (especially given I'm still familiarizing myself w/ TShock's internals).
Broke point on OnGreetPlayer, the item is effectively in the client's hand, but undetected on the server, despite the SSC takeover. If anything, we'd need some event after greeting, or a few ticks after the player has fully loaded, to check whether any unwanted modifications were made.
I don't know if that's possible, hence any feedback on this matter would be sorely appreciated. Would @hakusaro have any thoughts on this?
few ticks after the player has fully loaded
There should be a hook suitable timing wise
I didn’t validate anything else yet
Most likely during a random Update the client decides to move the item from the hand to the inventory and then sends it to the server. Find a timing that works against latency is always a hard problem 😿
The mentioned fix is a simple Task.Delay(1000).
The OnServerLeave stuff is unrelated: it was probably some random unhandled exceptions got messed up by MonoMod.
Why not just add a random task to do this?