TShock icon indicating copy to clipboard operation
TShock copied to clipboard

一个开启ssc后刷物品的问题

Open Niguangz opened this issue 9 months ago • 9 comments

开启ssc后 玩家在单人游戏中,随便选一个物品,好的不要放下来,直接点设置返回主菜单 进入多人游戏,进入tshock开的服务器,你会发现选的物品直接出现在玩家的背包里 经过我测试,inventory根本获取不到这个物品,但是实实在在存在,然后重复进出,这个物品也会重复获取 现在我解决的办法只有,记录退出时记录背包,进入后用额外适配的插件加载背包

这个问题不仅仅是选取物品,通过向导的制作也可以带进来。

Niguangz avatar Apr 02 '25 18:04 Niguangz

尝试修复:https://tr.monika.love/resources/171/

Niguangz avatar Apr 03 '25 16:04 Niguangz

I think it's related to #2948. The ServerLeave event doesn't fire so the user inventory is not saved at exit.

jbiosca78 avatar Apr 17 '25 11:04 jbiosca78

I'm having trouble understanding translations of this one if anyone can help (@sgkoishi, @ACaiCat?)

hakusaro avatar May 05 '25 14:05 hakusaro

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

  1. Load a singleplayer world with a character, which is bound to a SSC on a remote server.
  2. Grab in your hand the most overpowered item you can fathom (SDMG or Zenith, for good measure).
  3. With the item still in hand, head for Settings and exit to main menu. (does not work on multiplayer instances)
  4. Connect to said SSC-enabled server.
  5. You're now holding that contraband item, ready to nuke the server's balance.
  6. Disconnect at your convenience, after stashing your illicit item, or giving it to your battle buddy.
  7. (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. Image

Workaround

Such an exploit can be warded entirely by setting "DisableLoginBeforeJoin": true. Server admins are advised to apply this change, pending a future fix.

SakuraIsayeki avatar May 05 '25 18:05 SakuraIsayeki

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. Image

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?

SakuraIsayeki avatar May 05 '25 19:05 SakuraIsayeki

few ticks after the player has fully loaded

There should be a hook suitable timing wise

hakusaro avatar May 05 '25 19:05 hakusaro

I didn’t validate anything else yet

hakusaro avatar May 05 '25 19:05 hakusaro

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.

sgkoishi avatar May 05 '25 19:05 sgkoishi

Why not just add a random task to do this?

hakusaro avatar May 06 '25 04:05 hakusaro