Sync sub selection

This commit is contained in:
juanjp600
2016-09-05 17:15:41 -03:00
parent e232f1d2f1
commit a02931054a
2 changed files with 40 additions and 30 deletions
+33 -27
View File
@@ -529,34 +529,40 @@ namespace Barotrauma.Networking
case ServerNetObject.SYNC_IDS:
bool lobbyUpdated = inc.ReadBoolean();
inc.ReadPadBits();
if (lobbyUpdated)
{
GameMain.NetLobbyScreen.LastUpdateID = inc.ReadUInt32();
GameMain.NetLobbyScreen.ServerName = inc.ReadString();
GameMain.NetLobbyScreen.ServerMessage = inc.ReadString();
UInt16 subListCount = inc.ReadUInt16();
if (subListCount > 0)
{
List<Submarine> submarines = new List<Submarine>();
for (int i = 0; i < subListCount; i++)
{
string subName = inc.ReadString();
string subHash = inc.ReadString();
var matchingSub = Submarine.SavedSubmarines.Find(s => s.Name == subName);
if (matchingSub != null)
{
submarines.Add(matchingSub);
}
else
{
submarines.Add(new Submarine(Path.Combine(Submarine.SavePath, subName), subHash, false));
}
}
if (lobbyUpdated)
{
GameMain.NetLobbyScreen.LastUpdateID = inc.ReadUInt32();
GameMain.NetLobbyScreen.ServerName = inc.ReadString();
GameMain.NetLobbyScreen.ServerMessage = inc.ReadString();
UInt16 subListCount = inc.ReadUInt16();
if (subListCount > 0)
{
List<Submarine> submarines = new List<Submarine>();
for (int i = 0; i < subListCount; i++)
{
string subName = inc.ReadString();
string subHash = inc.ReadString();
var matchingSub = Submarine.SavedSubmarines.Find(s => s.Name == subName);
if (matchingSub != null)
{
submarines.Add(matchingSub);
}
else
{
submarines.Add(new Submarine(Path.Combine(Submarine.SavePath, subName), subHash, false));
}
}
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.SubList, submarines);
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.ShuttleList.ListBox, submarines);
}
GameMain.NetLobbyScreen.UpdateSubList(GameMain.NetLobbyScreen.ShuttleList.ListBox, submarines);
}
string selectSubName = inc.ReadString();
string selectSubHash = inc.ReadString();
GameMain.NetLobbyScreen.TrySelectSub(selectSubName, selectSubHash, GameMain.NetLobbyScreen.SubList);
string selectShuttleName = inc.ReadString();
string selectShuttleHash = inc.ReadString();
GameMain.NetLobbyScreen.TrySelectSub(selectShuttleName, selectShuttleHash, GameMain.NetLobbyScreen.ShuttleList.ListBox);
}
lastRecvChatMsgID = inc.ReadUInt32();
break;
+7 -3
View File
@@ -622,9 +622,9 @@ namespace Barotrauma.Networking
outmsg.Write(GameMain.NetLobbyScreen.LastUpdateID);
outmsg.Write(GameMain.NetLobbyScreen.GetServerName());
outmsg.Write(GameMain.NetLobbyScreen.ServerMessage);
var subList = GameMain.NetLobbyScreen.GetSubList();
if (c.lastRecvLobbyUpdate < 1)
{
var subList = GameMain.NetLobbyScreen.GetSubList();
outmsg.Write((UInt16)subList.Count);
for (int i = 0; i < subList.Count; i++)
{
@@ -636,6 +636,10 @@ namespace Barotrauma.Networking
{
outmsg.Write((UInt16)0);
}
outmsg.Write((GameMain.NetLobbyScreen.SubList.SelectedData as Submarine).Name);
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).MD5Hash.ToString());
}
else
{
@@ -812,8 +816,8 @@ namespace Barotrauma.Networking
if (ban)
{
DisconnectClient(client, client.name + " has been banned from the server", "You have been banned from the server");
string ip = client.Connection.RemoteEndPoint.Address.ToString();
if (range) { ip = banList.ToRange(ip); }
string ip = client.Connection.RemoteEndPoint.Address.ToString();
if (range) { ip = banList.ToRange(ip); }
banList.BanPlayer(client.name, ip);
}
else