Closed Marcus101RR closed 7 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.
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
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);
Correct
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?
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.
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.
Closing because this issue duplicates #1104.
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?