Networking bugfixes & optimization
This commit is contained in:
@@ -428,7 +428,7 @@ namespace Subsurface
|
||||
|
||||
private bool StartShift(GUIButton button, object selection)
|
||||
{
|
||||
Game1.GameSession.StartShift(TimeSpan.Zero, selectedLevel);
|
||||
Game1.GameSession.StartShift(TimeSpan.Zero, selectedLevel, false);
|
||||
Game1.GameScreen.Select();
|
||||
|
||||
return true;
|
||||
|
||||
@@ -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;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,11 +51,6 @@ namespace Subsurface
|
||||
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server IP:", GUI.style, menu);
|
||||
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), GUI.style, menu);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int middleX = (int)(width * 0.4f);
|
||||
|
||||
serverList = new GUIListBox(new Rectangle(middleX,60,0,(int)(height*0.7f)), GUI.style, menu);
|
||||
@@ -80,6 +75,10 @@ namespace Subsurface
|
||||
|
||||
joinButton = new GUIButton(new Rectangle(0,0,150,30), "Join", Alignment.BottomRight, GUI.style, menu);
|
||||
joinButton.OnClicked = JoinServer;
|
||||
|
||||
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, GUI.style, menu);
|
||||
button.UserData = 0;
|
||||
button.OnClicked = Game1.MainMenuScreen.SelectTab;
|
||||
|
||||
|
||||
refreshDisableTimer = DateTime.Now;
|
||||
@@ -286,7 +285,7 @@ namespace Subsurface
|
||||
{
|
||||
string selectedPassword = "";
|
||||
|
||||
if ((serverList.Selected.GetChild("password") as GUITickBox).Selected)
|
||||
if (serverList.Selected!=null && (serverList.Selected.GetChild("password") as GUITickBox).Selected)
|
||||
{
|
||||
var msgBox = new GUIMessageBox("Password required", "");
|
||||
var passwordBox = new GUITextBox(new Rectangle(0,0,150,20), Alignment.BottomCenter, GUI.style, msgBox);
|
||||
|
||||
Reference in New Issue
Block a user