Pryaxis / TShock

☕️⚡️TShock provides Terraria servers with server-side characters, anti-cheat, and community management tools.
GNU General Public License v3.0
2.41k stars 377 forks source link

Buffs/Debuffs Vanish #1452

Open Kirbyarm opened 7 years ago

Kirbyarm commented 7 years ago

Hey Team,

I can't figure out any way to prevent this from happening, and thought I'd mention it here to inquire if a fix or config option could be implemented to address it.

It's pretty straightforward of an issue. TShock removes all my buffs whenever I disconnect, even if it's a crash. So say I had 3 minutes left on my obsidian skin potion, I'd crash while in lava, log back in still inside the lava and get melted to death. Or just randomly, if I'm farming mobs and have a battle potion effect active, re-logging will remove the buff. I'd very much appreciate if it remembered all my buffs like in single player.

We have SSC enabled, but this even affects the admins who have the ssc bypass permission.

Is this intentional? Is the team aware of this? Is there any sort of workaround?

Thank you for your time.

ivanbiljan commented 7 years ago

Confirmed issue, happens only with SSC enabled though.

ivanbiljan commented 7 years ago

I'm just going to assume that this is the issue for now.

Marcus101RR commented 7 years ago

I don't think Buffs were ever saved on a player who leaves and then rejoins, I assume he is expecting that it functions similar to Single Player...

ivanbiljan commented 7 years ago

The final conclusion is that this is not an actual issue but a request.

Ijwu commented 7 years ago

If it deviates from vanilla Terraria it could be argued that it is an issue. Do we store buffs anywhere in our SSC DB? Should/can we?

Marcus101RR commented 7 years ago
  1. No you guys do not store buffs in the database, mainly because RestoreCharacter simply sets them to 0 so people don't come into a server with 9h buffs, or stacked buffs.
  2. Probably a wasted effort, since hacking buffs on the client side is untraceable/undetectable. Which means people can just use modified clients to give them stacks of ironskin or other buffs that isn't even checked as a cheating infraction.
Ijwu commented 7 years ago

@Marcus101RR If you're using SSC, you can't possibly enable buffs then enter the server and keep those buffs. If SSC properly tracked buffs it'd clear your pre-login buffs then restore your old buffs on the server.

I don't think it's a wasted effort. MarioE seems to be doing a good job of tracking item hacking and we can likely apply that principle to buffs as well.

ivanbiljan commented 7 years ago

I'm up for (re)storing buffs & debuffs in that case, unless someone can think of a reason why we shouldn't do this.

Victorsueca commented 7 years ago

I ACK that buffs/debuffs should be stored, it's the vanilla behaviour and if not stored players could exploit it to remove debuffs. I think the real question here would be: Should time run even when the player is not logged in? What is the vanilla behaviour in that sense?

Marcus101RR commented 7 years ago

The way vanilla works is the same with all aspects, your character is frozen/limbo status. So any progress is halted. That includes the time of the buffs. They continue to countdown once you start your world again. Even so, I my own personal buff "tool" that allows me to bypass buffs that negatively affect you and alter on login. That being said, I think it would be a wasted effort, but one of the developers have assured me they can add an anti-cheat of some sort. Though I think that's not going to be enough, a proper anti cheat will never exist in tshock. So even after the fact, I can still see people exploiting this regardless of it being stored or not.

I do however, wish they would merge Users and tsCharacters into one table, not sure why it is separate from them.

On Sat, Jul 15, 2017 at 8:47 AM, Victorsueca notifications@github.com wrote:

I ACK that buffs/debuffs should be stored, it's the vanilla behaviour and if not stored players could exploit it to remove debuffs. I think the real question here would be: Should time run even when the player is not logged in? What is the vanilla behaviour in that sense?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Pryaxis/TShock/issues/1452#issuecomment-315531770, or mute the thread https://github.com/notifications/unsubscribe-auth/AH9S5WFQ-_tHJcdSJIbi81_gvLG5ZCq0ks5sOLTvgaJpZM4NkBDX .

Victorsueca commented 7 years ago

If the server manages potion effects it doesn't matter if you remove them with a tool, the server will just load from database and put your buffs/debuffs back on place. Same as with your inventory.

ivanbiljan commented 7 years ago

@Victorsueca is right. I did the actual implementation and was getting ready to PR this but stumbled on some issues. In order to correctly re-apply the player's buffs we should store the buff's time in the database. The issue with this is that reading the buff's time from Player.buffTime[] will always return 60, meaning we always get 1 second buffs on the server's side.

case 50:
            int number23 = (int) this.reader.ReadByte();
            if (Main.netMode == 2)
              number23 = this.whoAmI;
            else if (number23 == Main.myPlayer && !Main.ServerSideCharacter)
              break;
            Player player13 = Main.player[number23];
            for (int index1 = 0; index1 < 22; ++index1)
            {
              player13.buffType[index1] = (int) this.reader.ReadByte()
>>>>>>>>>>>>>player13.buffTime[index1] = player13.buffType[index1] <= 0 ? 0 : 60;
            }
            if (Main.netMode != 2)
              break;
            NetMessage.SendData(50, -1, this.whoAmI, (NetworkText) null, number23, 0.0f, 0.0f, 0.0f, 0, 0, 0);
            break;

I don't see a good way of implementing this as of now, if anyone has any ideas you should post them here.

hakusaro commented 6 years ago

@ivanbiljan it's been suggested to me that we could always establish timers for buff adding and removal to sync them properly. Still, a request for network fix is in (but may not happen).

QuiCM commented 6 years ago

Blocked due to request for network fix - I don't believe we should be responsible for tracking a client's buffs manually, and should instead wait for Terraria to support this properly (...and I'm sure once upon a time it did, but apparently not anymore)