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

[Chat Above Heads] Tags only works for client, not for receivers... #1157

Closed Marcus101RR closed 7 years ago

Marcus101RR commented 8 years ago

As you can see,

The person typing on their own screen can see the text color fine, however, those who are receiving the text see the full code...

Using the Chat Above Heads feature. Hopefully this can be changed in the future?

image

AxisKriel commented 8 years ago

Don't use ChatAboveHeads.

Edit: Seriously though, I don't think that's something we can fix on our end seeing as ChatAboveHeads is a vanilla feature and it doesn't seem to send the same packets as regular chat does. This is probably an issue with how the client parses ChatAboveHeads.

White made https://tshock.co/xf/index.php?resources/localized-chat.123/ quite interesting plugin that can work in a similar way to ChatAboveHeads but doesn't have all the incompatibility issues.

QuiCM commented 8 years ago

It does appear to be the case that the client is wrongly parsing some text, but I have not yet debugged anything to find out why. Given that personal text is displayed fine, this should be fixable

Marcus101RR commented 8 years ago

My thoughts were that this: NetMessage.SendData((int)PacketTypes.ChatText, -1, args.Who, text, args.Who, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B); NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, name, args.Who, 0, 0, 0, 0);

Handles the Chat Above Heads...

Meanwhile, this handles the sending to others and the player himself?

                string msg = String.Format("<{0}> {1}",
                    String.Format(Config.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix),
                    text);

                tsplr.SendMessage(msg, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);

                TSPlayer.Server.SendMessage(msg, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
QuiCM commented 8 years ago

Correct

Marcus101RR commented 8 years ago

So here is my analysis: tsplr.SendMessage(msg, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B); This causes you to see your own message, with successful tags while ChatAboveHeads.

TSPlayer.Server.SendMessage(msg, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B); This I believe, is what sends the chat message on the console, and possibly also the message itself to others on the server. Since I Peeked the Definition, it seems to use the Chat packet...

This is where it all goes wrong. Maybe use TShock's chat sending instead?

Marcus101RR commented 8 years ago

UPDATE: I have come to the conclusion, that it is infact: NetMessage.SendData((int)PacketTypes.ChatText, -1, args.Who, text, args.Who, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);

this cannot be modified, at least not from my stand point. This is what causes everyone to see the screwed up prefixes...

Bingo: The issue is within Terraria really, not TShock: [c/ffffff:[n:Marcus101RR]] <-- Terraria would need an update to handle multiple brackets.

ivanbiljan commented 8 years ago

Duplicate of #1104. We've already come to the conclusion why this is happening but let's just make it clear one more time: The reason the sender parses text properly is that the ChatText packet is handled differently. TSPlayer.SendMessage methods pass in 255 as the ID of the player that sent the packet, this results in a blank line which then allows us to modify text as we want. As we can see in code Marcus posted above, we pass in the player's whoAmI as the ID of the player that sent the packet, which breaks chat tags. Ofcourse, if we don't pass in the player's whoAmI the chat doesn't show above the player's head. I don't see a way to work around this as of now, we can continue the discussion in Slack if needed.

hakusaro commented 7 years ago

Closing because this issue duplicates #1104.