Server limits chatmessage length and the number of chatmessages written in one packet

This commit is contained in:
Regalis
2017-05-08 19:06:05 +03:00
parent 152a92e600
commit 7dad837733
6 changed files with 47 additions and 16 deletions

View File

@@ -841,11 +841,13 @@ namespace Barotrauma.Networking
outmsg.Write(c.lastSentEntityEventID);
c.chatMsgQueue.RemoveAll(cMsg => !NetIdUtils.IdMoreRecent(cMsg.NetStateID, c.lastRecvChatMsgID));
foreach (ChatMessage cMsg in c.chatMsgQueue)
int maxChatMsgsPerPacket = 50;
for (int i = 0; i < c.chatMsgQueue.Count && i < maxChatMsgsPerPacket; i++)
{
cMsg.ServerWrite(outmsg, c);
}
c.chatMsgQueue[i].ServerWrite(outmsg, c);
}
//don't send position updates to characters who are still midround syncing
//characters or items spawned mid-round don't necessarily exist at the client's end yet
if (!c.NeedsMidRoundSync)