Networking bugfixes & optimization

This commit is contained in:
Regalis
2015-08-18 18:13:40 +03:00
parent bc4ea098f7
commit 00c64f0b20
35 changed files with 320 additions and 188 deletions
+8 -48
View File
@@ -23,8 +23,6 @@ namespace Subsurface
private GUITextBox textBox, seedBox;
//GUIFrame previewPlayer;
private GUIScrollBar durationBar;
private GUIFrame playerFrame;
@@ -36,6 +34,11 @@ namespace Subsurface
private GUITextBox serverMessage;
public GUIListBox SubList
{
get { return subList; }
}
public Submarine SelectedMap
{
get { return subList.SelectedData as Submarine; }
@@ -275,7 +278,7 @@ namespace Subsurface
modeList.OnSelected += Game1.Server.UpdateNetLobby;
durationBar.OnMoved = Game1.Server.UpdateNetLobby;
if (subList.CountChildren > 0) subList.Select(0);
if (subList.CountChildren > 0) subList.Select(-1);
if (GameModePreset.list.Count > 0) modeList.Select(0);
}
else if (playerFrame.children.Count==0)
@@ -443,6 +446,7 @@ namespace Subsurface
((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black*0.1f, color,
Alignment.Left, GUI.style, null, true);
msg.Font = GUI.SmallFont;
msg.CanBeFocused = false;
msg.Padding = new Vector4(20, 0, 0, 0);
chatBox.AddChild(msg);
@@ -658,57 +662,13 @@ namespace Subsurface
return;
}
TrySelectMap(mapName, md5Hash);
if (!string.IsNullOrWhiteSpace(mapName)) TrySelectMap(mapName, md5Hash);
modeList.Select(modeIndex);
durationBar.BarScroll = durationScroll;
LevelSeed = levelSeed;
//try
//{
// int playerCount = msg.ReadInt32();
// for (int i = 0; i < playerCount; i++)
// {
// int clientID = msg.ReadInt32();
// string jobName = msg.ReadString();
// Client client = null;
// GUITextBlock textBlock = null;
// foreach (GUIComponent child in playerList.children)
// {
// Client tempClient = child.UserData as Client;
// if (tempClient == null || tempClient.ID != clientID) continue;
// client = tempClient;
// textBlock = child as GUITextBlock;
// break;
// }
// if (client == null) continue;
// client.assignedJob = JobPrefab.List.Find(jp => jp.Name == jobName);
// textBlock.Text = client.name + ((client.assignedJob==null) ? "" : " (" + client.assignedJob.Name + ")");
// if (client.assignedJob==null || jobName != client.assignedJob.Name)
// {
// if (clientID == Game1.Client.ID)
// {
// Game1.Client.CharacterInfo.Job = new Job(client.assignedJob);
// Game1.Client.CharacterInfo.Name = client.name;
// UpdatePreviewPlayer(Game1.Client.CharacterInfo);
// }
// }
// }
//}
//catch
//{
// return;
//}
}
}