Fixed lobby chat

This commit is contained in:
juanjp600
2016-09-08 09:41:08 -03:00
parent 7c9ae5134c
commit 1b85dc3646
3 changed files with 26 additions and 19 deletions
+5 -2
View File
@@ -57,8 +57,11 @@ namespace Barotrauma.Networking
TextWithSender = string.IsNullOrWhiteSpace(senderName) ? text : senderName + ": " + text; TextWithSender = string.IsNullOrWhiteSpace(senderName) ? text : senderName + ": " + text;
LastID++; if (GameMain.Server != null)
netStateID = LastID; {
LastID++;
netStateID = LastID;
}
} }
public static ChatMessage Create(string senderName, string text, ChatMessageType type, Character sender) public static ChatMessage Create(string senderName, string text, ChatMessageType type, Character sender)
@@ -36,6 +36,7 @@ namespace Barotrauma.Networking
private string saltedPw; private string saltedPw;
private UInt32 lastSentChatMsgID = 0; //last message this client has successfully sent private UInt32 lastSentChatMsgID = 0; //last message this client has successfully sent
private UInt32 lastQueueChatMsgID = 0; //last message added to the queue
private List<ChatMessage> chatMsgQueue = new List<ChatMessage>(); private List<ChatMessage> chatMsgQueue = new List<ChatMessage>();
public byte ID public byte ID
@@ -617,6 +618,9 @@ namespace Barotrauma.Networking
gameStarted && myCharacter != null ? myCharacter.Name : name, gameStarted && myCharacter != null ? myCharacter.Name : name,
message, (ChatMessageType)type, gameStarted ? myCharacter : null); message, (ChatMessageType)type, gameStarted ? myCharacter : null);
lastQueueChatMsgID++;
chatMessage.netStateID = lastQueueChatMsgID;
chatMsgQueue.Add(chatMessage); chatMsgQueue.Add(chatMessage);
} }
+17 -17
View File
@@ -623,23 +623,23 @@ namespace Barotrauma.Networking
{ {
outmsg.Write((UInt16)0); outmsg.Write((UInt16)0);
} }
outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).Name); outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).Name);
outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).MD5Hash.ToString()); outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).MD5Hash.ToString());
outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).Name); outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).Name);
outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).MD5Hash.ToString()); outmsg.Write((GameMain.NetLobbyScreen.ShuttleList.SelectedData as Submarine).MD5Hash.ToString());
outmsg.WriteRangedInteger(0, 2, (int)TraitorsEnabled); outmsg.WriteRangedInteger(0, 2, (int)TraitorsEnabled);
outmsg.WriteRangedInteger(0, Mission.MissionTypes.Count - 1, (GameMain.NetLobbyScreen.MissionTypeIndex)); outmsg.WriteRangedInteger(0, Mission.MissionTypes.Count - 1, (GameMain.NetLobbyScreen.MissionTypeIndex));
outmsg.Write((byte)GameMain.NetLobbyScreen.ModeList.SelectedIndex); outmsg.Write((byte)GameMain.NetLobbyScreen.ModeList.SelectedIndex);
outmsg.Write(GameMain.NetLobbyScreen.LevelSeed); outmsg.Write(GameMain.NetLobbyScreen.LevelSeed);
outmsg.Write(AutoRestart); outmsg.Write(AutoRestart);
if (autoRestart) if (autoRestart)
{ {
outmsg.Write(AutoRestartTimer); outmsg.Write(AutoRestartTimer);
} }
} }
else else
{ {