Made game compilable
Networking functionality is fully disabled now. I think it's time to start rewriting everything. OH BOY
This commit is contained in:
@@ -67,8 +67,5 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//protected Structure lastStructurePicked;
|
//protected Structure lastStructurePicked;
|
||||||
|
|
||||||
public virtual void FillNetworkData(NetBuffer message) { }
|
|
||||||
public virtual void ReadNetworkData(NetIncomingMessage message) { }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,6 @@ namespace Barotrauma
|
|||||||
if (spawnedCharacter != null && GameMain.Server != null)
|
if (spawnedCharacter != null && GameMain.Server != null)
|
||||||
{
|
{
|
||||||
spawnedCharacter.SpawnedMidRound = true;
|
spawnedCharacter.SpawnedMidRound = true;
|
||||||
GameMain.Server.SendCharacterSpawnMessage(spawnedCharacter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -321,7 +320,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GameMain.Server.KickClient(client, true);
|
//GameMain.Server.KickClient(client, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "startclient":
|
case "startclient":
|
||||||
|
|||||||
@@ -351,6 +351,13 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool waitForKeyHit = true;
|
static bool waitForKeyHit = true;
|
||||||
|
public static CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
|
||||||
|
{
|
||||||
|
waitForKeyHit = waitKeyHit;
|
||||||
|
titleScreenOpen = true;
|
||||||
|
TitleScreen.LoadState = null;
|
||||||
|
return CoroutineManager.StartCoroutine(TitleScreen.DoLoading(loader));
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnExiting(object sender, EventArgs args)
|
protected override void OnExiting(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -235,8 +235,8 @@ namespace Barotrauma
|
|||||||
Items[index] = null;
|
Items[index] = null;
|
||||||
|
|
||||||
//swapping the items failed -> move them back to where they were
|
//swapping the items failed -> move them back to where they were
|
||||||
TryPutItem(item, currentIndex, false, false);
|
TryPutItem(item, currentIndex, false);
|
||||||
TryPutItem(existingItem, index, false, false);
|
TryPutItem(existingItem, index, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (doubleClickedItem.ParentInventory != this)
|
if (doubleClickedItem.ParentInventory != this)
|
||||||
{
|
{
|
||||||
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
|
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -296,24 +296,24 @@ namespace Barotrauma
|
|||||||
var selectedContainer = character.SelectedConstruction.GetComponent<ItemContainer>();
|
var selectedContainer = character.SelectedConstruction.GetComponent<ItemContainer>();
|
||||||
if (selectedContainer != null && selectedContainer.Inventory != null)
|
if (selectedContainer != null && selectedContainer.Inventory != null)
|
||||||
{
|
{
|
||||||
selectedContainer.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
|
selectedContainer.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null)
|
else if (character.SelectedCharacter != null && character.SelectedCharacter.Inventory != null)
|
||||||
{
|
{
|
||||||
character.SelectedCharacter.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots, true);
|
character.SelectedCharacter.Inventory.TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots);
|
||||||
}
|
}
|
||||||
else //doubleclicked and no other inventory is selected
|
else //doubleclicked and no other inventory is selected
|
||||||
{
|
{
|
||||||
//not equipped -> attempt to equip
|
//not equipped -> attempt to equip
|
||||||
if (IsInLimbSlot(doubleClickedItem, InvSlotType.Any))
|
if (IsInLimbSlot(doubleClickedItem, InvSlotType.Any))
|
||||||
{
|
{
|
||||||
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots.FindAll(i => i != InvSlotType.Any), true);
|
TryPutItem(doubleClickedItem, doubleClickedItem.AllowedSlots.FindAll(i => i != InvSlotType.Any));
|
||||||
}
|
}
|
||||||
//equipped -> attempt to unequip
|
//equipped -> attempt to unequip
|
||||||
else if (doubleClickedItem.AllowedSlots.Contains(InvSlotType.Any))
|
else if (doubleClickedItem.AllowedSlots.Contains(InvSlotType.Any))
|
||||||
{
|
{
|
||||||
TryPutItem(doubleClickedItem, new List<InvSlotType>() { InvSlotType.Any }, true);
|
TryPutItem(doubleClickedItem, new List<InvSlotType>() { InvSlotType.Any });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (removeItem)
|
if (removeItem)
|
||||||
{
|
{
|
||||||
item.Drop(null, false);
|
item.Drop(null);
|
||||||
if (item.ParentInventory != null) item.ParentInventory.RemoveItem(item);
|
if (item.ParentInventory != null) item.ParentInventory.RemoveItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
protected virtual void DropItem(Item item)
|
protected virtual void DropItem(Item item)
|
||||||
{
|
{
|
||||||
item.Drop(null, false);
|
item.Drop(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//public void DropItem(int i)
|
//public void DropItem(int i)
|
||||||
@@ -276,7 +276,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
//selectedSlot = slotIndex;
|
//selectedSlot = slotIndex;
|
||||||
TryPutItem(draggingItem, slotIndex, true, true);
|
TryPutItem(draggingItem, slotIndex, true);
|
||||||
draggingItem = null;
|
draggingItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameMain.Server != null) GameMain.Server.SendItemSpawnMessage(items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddToSpawnedList(Item item)
|
public void AddToSpawnedList(Item item)
|
||||||
@@ -134,7 +133,6 @@ namespace Barotrauma
|
|||||||
items.Add(item);
|
items.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameMain.Server != null) GameMain.Server.SendItemRemoveMessage(items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
|
|||||||
@@ -112,49 +112,5 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void WriteNetworkMessage(NetOutgoingMessage msg)
|
|
||||||
{
|
|
||||||
msg.WriteRangedInteger(0, Enum.GetValues(typeof(ChatMessageType)).Length, (byte)Type);
|
|
||||||
if (GameMain.Server != null)
|
|
||||||
{
|
|
||||||
msg.Write(Sender == null ? (ushort)0 : Sender.ID);
|
|
||||||
msg.Write(SenderName);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.Write(Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ChatMessage ReadNetworkMessage(NetBuffer msg)
|
|
||||||
{
|
|
||||||
ChatMessageType type = (ChatMessageType)msg.ReadRangedInteger(0, Enum.GetValues(typeof(ChatMessageType)).Length);
|
|
||||||
string senderName="";
|
|
||||||
Character character = null;
|
|
||||||
if (GameMain.Server == null)
|
|
||||||
{
|
|
||||||
ushort senderId = msg.ReadUInt16();
|
|
||||||
character = Entity.FindEntityByID(senderId) as Character;
|
|
||||||
senderName = msg.ReadString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NetIncomingMessage inc = msg as NetIncomingMessage;
|
|
||||||
if (inc == null) return null;
|
|
||||||
Client sender = GameMain.Server.ConnectedClients.Find(x => x.Connection == inc.SenderConnection);
|
|
||||||
if (sender == null) return null;
|
|
||||||
character = sender.Character;
|
|
||||||
if (character != null)
|
|
||||||
{
|
|
||||||
senderName = character.Name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
senderName = sender.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
string text = msg.ReadString();
|
|
||||||
|
|
||||||
return new ChatMessage(senderName, text, type, character);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -469,29 +469,6 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
base.Draw(spriteBatch);
|
base.Draw(spriteBatch);
|
||||||
|
|
||||||
if (fileStreamReceiver != null &&
|
|
||||||
(fileStreamReceiver.Status == FileTransferStatus.Receiving || fileStreamReceiver.Status == FileTransferStatus.NotStarted))
|
|
||||||
{
|
|
||||||
Vector2 pos = new Vector2(GameMain.GraphicsWidth / 2 - 130, GameMain.NetLobbyScreen.InfoFrame.Rect.Y / 2 - 15);
|
|
||||||
|
|
||||||
GUI.DrawString(spriteBatch,
|
|
||||||
pos,
|
|
||||||
"Downloading " + fileStreamReceiver.FileName,
|
|
||||||
Color.White, null, 0, GUI.SmallFont);
|
|
||||||
|
|
||||||
|
|
||||||
GUI.DrawProgressBar(spriteBatch, new Vector2(pos.X, -pos.Y - 12), new Vector2(200, 15), fileStreamReceiver.Progress, Color.Green);
|
|
||||||
|
|
||||||
GUI.DrawString(spriteBatch, pos + new Vector2(5,12),
|
|
||||||
MathUtils.GetBytesReadable((long)fileStreamReceiver.Received) + " / " + MathUtils.GetBytesReadable((long)fileStreamReceiver.FileSize),
|
|
||||||
Color.White, null, 0, GUI.SmallFont);
|
|
||||||
|
|
||||||
if (GUI.DrawButton(spriteBatch, new Rectangle((int)pos.X + 210, (int)pos.Y+12, 65, 15), "Cancel", new Color(0.47f, 0.13f, 0.15f, 0.08f)))
|
|
||||||
{
|
|
||||||
CancelFileTransfer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GameMain.DebugDraw) return;
|
if (!GameMain.DebugDraw) return;
|
||||||
|
|
||||||
int width = 200, height = 300;
|
int width = 200, height = 300;
|
||||||
|
|||||||
@@ -446,6 +446,47 @@ namespace Barotrauma.Networking
|
|||||||
sparseUpdateTimer = DateTime.Now + sparseUpdateInterval;
|
sparseUpdateTimer = DateTime.Now + sparseUpdateInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool StartGameClicked(GUIButton button, object obj)
|
||||||
|
{
|
||||||
|
Submarine selectedSub = null;
|
||||||
|
Submarine selectedShuttle = GameMain.NetLobbyScreen.SelectedShuttle;
|
||||||
|
|
||||||
|
if (Voting.AllowSubVoting)
|
||||||
|
{
|
||||||
|
selectedSub = Voting.HighestVoted<Submarine>(VoteType.Sub, connectedClients);
|
||||||
|
if (selectedSub == null) selectedSub = GameMain.NetLobbyScreen.SelectedSub;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selectedSub = GameMain.NetLobbyScreen.SelectedSub;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedSub == null)
|
||||||
|
{
|
||||||
|
GameMain.NetLobbyScreen.SubList.Flash();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedShuttle == null)
|
||||||
|
{
|
||||||
|
GameMain.NetLobbyScreen.ShuttleList.Flash();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameModePreset selectedMode = Voting.HighestVoted<GameModePreset>(VoteType.Mode, connectedClients);
|
||||||
|
if (selectedMode == null) selectedMode = GameMain.NetLobbyScreen.SelectedMode;
|
||||||
|
|
||||||
|
if (selectedMode == null)
|
||||||
|
{
|
||||||
|
GameMain.NetLobbyScreen.ModeList.Flash();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//CoroutineManager.StartCoroutine(WaitForPlayersReady(selectedSub, selectedShuttle, selectedMode), "WaitForPlayersReady");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void EndGame()
|
public void EndGame()
|
||||||
{
|
{
|
||||||
if (!gameStarted) return;
|
if (!gameStarted) return;
|
||||||
@@ -622,22 +663,7 @@ namespace Barotrauma.Networking
|
|||||||
if (server.Connections.Count == 0) return;
|
if (server.Connections.Count == 0) return;
|
||||||
|
|
||||||
var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount > connectedClients.Count * KickVoteRequiredRatio);
|
var clientsToKick = connectedClients.FindAll(c => c.KickVoteCount > connectedClients.Count * KickVoteRequiredRatio);
|
||||||
clientsToKick.ForEach(c => KickClient(c));
|
//clientsToKick.ForEach(c => KickClient(c));
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
NetOutgoingMessage msg = server.CreateMessage();
|
|
||||||
msg.Write((byte)PacketTypes.VoteStatus);
|
|
||||||
Voting.WriteData(msg, connectedClients);
|
|
||||||
|
|
||||||
server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableUnordered, 0);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
#if DEBUG
|
|
||||||
DebugConsole.ThrowError("Failed to update vote status", e);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,22 +676,11 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (server.Connections.Count == 0) return true;
|
if (server.Connections.Count == 0) return true;
|
||||||
|
|
||||||
NetOutgoingMessage msg = server.CreateMessage();
|
|
||||||
msg.Write((byte)PacketTypes.UpdateNetLobby);
|
|
||||||
GameMain.NetLobbyScreen.WriteData(msg);
|
|
||||||
|
|
||||||
server.SendMessage(msg, server.Connections, NetDeliveryMethod.ReliableUnordered, 0);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateClientPermissions(Client client)
|
public void UpdateClientPermissions(Client client)
|
||||||
{
|
{
|
||||||
var msg = server.CreateMessage();
|
|
||||||
msg.Write((byte)PacketTypes.Permissions);
|
|
||||||
msg.Write((int)client.Permissions);
|
|
||||||
|
|
||||||
server.SendMessage(msg, client.Connection, NetDeliveryMethod.ReliableUnordered);
|
|
||||||
|
|
||||||
clientPermissions.RemoveAll(cp => cp.IP == client.Connection.RemoteEndPoint.Address.ToString());
|
clientPermissions.RemoveAll(cp => cp.IP == client.Connection.RemoteEndPoint.Address.ToString());
|
||||||
|
|
||||||
@@ -703,100 +718,6 @@ namespace Barotrauma.Networking
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadChatMessage(NetIncomingMessage inc)
|
|
||||||
{
|
|
||||||
Client sender = connectedClients.Find(x => x.Connection == inc.SenderConnection);
|
|
||||||
ChatMessage message = ChatMessage.ReadNetworkMessage(inc);
|
|
||||||
if (message == null) return;
|
|
||||||
|
|
||||||
List<Client> recipients = new List<Client>();
|
|
||||||
|
|
||||||
foreach (Client c in connectedClients)
|
|
||||||
{
|
|
||||||
if (!sender.inGame && c.inGame) continue; //people in lobby can't talk to people ingame
|
|
||||||
switch (message.Type)
|
|
||||||
{
|
|
||||||
case ChatMessageType.Dead:
|
|
||||||
if (c.Character != null && !c.Character.IsDead) continue;
|
|
||||||
break;
|
|
||||||
case ChatMessageType.Default:
|
|
||||||
if (message.Sender != null && c.Character != null && message.Sender != c.Character)
|
|
||||||
{
|
|
||||||
if (Vector2.Distance(message.Sender.WorldPosition, c.Character.WorldPosition) > ChatMessage.SpeakRange) continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ChatMessageType.Radio:
|
|
||||||
if (message.Sender == null) return;
|
|
||||||
var radio = message.Sender.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
|
||||||
if (radio == null) message.Type = ChatMessageType.Default;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
recipients.Add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
//SPAM FILTER
|
|
||||||
if (sender.ChatSpamTimer > 0.0f)
|
|
||||||
{
|
|
||||||
//player has already been spamming, stop again
|
|
||||||
ChatMessage denyMsg = ChatMessage.Create("", "You have been blocked by the spam filter. Try again after 10 seconds.", ChatMessageType.Server, null);
|
|
||||||
sender.ChatSpamTimer = 10.0f;
|
|
||||||
SendChatMessage(denyMsg, sender);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float similarity = 0;
|
|
||||||
similarity += sender.ChatSpamSpeed * 0.05f; //the faster messages are being sent, the faster the filter will block
|
|
||||||
for (int i = 0; i < sender.ChatMessages.Count; i++)
|
|
||||||
{
|
|
||||||
float closeFactor = 1.0f / (20.0f - i);
|
|
||||||
|
|
||||||
int levenshteinDist = ToolBox.LevenshteinDistance(message.Text, sender.ChatMessages[i]);
|
|
||||||
similarity += Math.Max((message.Text.Length - levenshteinDist) / message.Text.Length * closeFactor, 0.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (similarity > 5.0f)
|
|
||||||
{
|
|
||||||
sender.ChatSpamCount++;
|
|
||||||
|
|
||||||
if (sender.ChatSpamCount > 3)
|
|
||||||
{
|
|
||||||
//kick for spamming too much
|
|
||||||
KickClient(sender, false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ChatMessage denyMsg = ChatMessage.Create("", "You have been blocked by the spam filter. Try again after 10 seconds.", ChatMessageType.Server, null);
|
|
||||||
sender.ChatSpamTimer = 10.0f;
|
|
||||||
SendChatMessage(denyMsg, sender);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.ChatMessages.Add(message.Text);
|
|
||||||
if (sender.ChatMessages.Count > 20)
|
|
||||||
{
|
|
||||||
sender.ChatMessages.RemoveAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sender.inGame || (Screen.Selected == GameMain.NetLobbyScreen))
|
|
||||||
{
|
|
||||||
AddChatMessage(message);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GameServer.Log(message.TextWithSender, message.Color);
|
|
||||||
}
|
|
||||||
sender.ChatSpamSpeed += 5.0f;
|
|
||||||
|
|
||||||
foreach (Client c in recipients)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SendChatMessage(string message, ChatMessageType? type = null)
|
public override void SendChatMessage(string message, ChatMessageType? type = null)
|
||||||
{
|
{
|
||||||
List<Client> recipients = new List<Client>();
|
List<Client> recipients = new List<Client>();
|
||||||
@@ -944,39 +865,6 @@ namespace Barotrauma.Networking
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendCharacterSpawnMessage(Character character, List<NetConnection> recipients = null)
|
|
||||||
{
|
|
||||||
if (recipients != null && !recipients.Any()) return;
|
|
||||||
|
|
||||||
NetOutgoingMessage message = server.CreateMessage();
|
|
||||||
message.Write((byte)PacketTypes.NewCharacter);
|
|
||||||
|
|
||||||
WriteCharacterData(message, character.Name, character);
|
|
||||||
|
|
||||||
SendMessage(message, NetDeliveryMethod.ReliableUnordered, recipients);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendItemSpawnMessage(List<Item> items, List<NetConnection> recipients = null)
|
|
||||||
{
|
|
||||||
if (items == null || !items.Any()) return;
|
|
||||||
|
|
||||||
NetOutgoingMessage message = server.CreateMessage();
|
|
||||||
message.Write((byte)PacketTypes.NewItem);
|
|
||||||
|
|
||||||
|
|
||||||
SendMessage(message, NetDeliveryMethod.ReliableOrdered, recipients);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SendItemRemoveMessage(List<Item> items, List<NetConnection> recipients = null)
|
|
||||||
{
|
|
||||||
if (items == null || !items.Any()) return;
|
|
||||||
|
|
||||||
NetOutgoingMessage message = server.CreateMessage();
|
|
||||||
message.Write((byte)PacketTypes.RemoveItem);
|
|
||||||
|
|
||||||
SendMessage(message, NetDeliveryMethod.ReliableOrdered, recipients);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AssignJobs(List<Client> unassigned)
|
public void AssignJobs(List<Client> unassigned)
|
||||||
{
|
{
|
||||||
unassigned = new List<Client>(unassigned);
|
unassigned = new List<Client>(unassigned);
|
||||||
@@ -1088,35 +976,7 @@ namespace Barotrauma.Networking
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendRandomData()
|
public void SendRandomData()
|
||||||
{
|
{
|
||||||
NetOutgoingMessage msg = server.CreateMessage();
|
//NO DON'T DO THIS WHY
|
||||||
switch (Rand.Int(5))
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
msg.Write((byte)PacketTypes.NetworkEvent);
|
|
||||||
msg.Write((byte)Rand.Int(Enum.GetNames(typeof(NetworkEventType)).Length));
|
|
||||||
msg.Write((ushort)Rand.Int(MapEntity.mapEntityList.Count));
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
msg.Write((byte)PacketTypes.NetworkEvent);
|
|
||||||
msg.Write((byte)NetworkEventType.ComponentUpdate);
|
|
||||||
msg.Write((int)Item.ItemList[Rand.Int(Item.ItemList.Count)].ID);
|
|
||||||
msg.Write(Rand.Int(8));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
msg.Write((byte)Enum.GetNames(typeof(PacketTypes)).Length);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
msg.Write((byte)PacketTypes.UpdateNetLobby);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bitCount = Rand.Int(100);
|
|
||||||
for (int i = 0; i < bitCount; i++)
|
|
||||||
{
|
|
||||||
msg.Write(Rand.Int(2) == 0);
|
|
||||||
}
|
|
||||||
SendMessage(msg, (Rand.Int(2) == 0) ? NetDeliveryMethod.ReliableOrdered : NetDeliveryMethod.Unreliable);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Disconnect()
|
public override void Disconnect()
|
||||||
@@ -1138,11 +998,6 @@ namespace Barotrauma.Networking
|
|||||||
log.Save();
|
log.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Client client in connectedClients)
|
|
||||||
{
|
|
||||||
if (client.FileStreamSender != null) client.FileStreamSender.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
server.Shutdown("The server has been shut down");
|
server.Shutdown("The server has been shut down");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -630,7 +630,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
|
var item = new Item(screwdriverPrefab, Vector2.Zero, null);
|
||||||
|
|
||||||
dummyCharacter.Inventory.TryPutItem(item, new List<InvSlotType>() {InvSlotType.RightHand}, false);
|
dummyCharacter.Inventory.TryPutItem(item, new List<InvSlotType>() {InvSlotType.RightHand});
|
||||||
|
|
||||||
wiringToolPanel = CreateWiringPanel();
|
wiringToolPanel = CreateWiringPanel();
|
||||||
}
|
}
|
||||||
@@ -720,7 +720,7 @@ namespace Barotrauma
|
|||||||
existingWire.Remove();
|
existingWire.Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
dummyCharacter.Inventory.TryPutItem(wire, slotIndex, false, false);
|
dummyCharacter.Inventory.TryPutItem(wire, slotIndex, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -1144,7 +1144,7 @@ namespace Barotrauma
|
|||||||
public bool TrySelectSub(string subName, string md5Hash, GUIListBox subList)
|
public bool TrySelectSub(string subName, string md5Hash, GUIListBox subList)
|
||||||
{
|
{
|
||||||
//already downloading the selected sub file
|
//already downloading the selected sub file
|
||||||
if (GameMain.Client.ActiveFileTransferName == subName+".sub") return false;
|
//if (GameMain.Client.ActiveFileTransferName == subName+".sub") return false;
|
||||||
|
|
||||||
var matchingListSub = subList.children.Find(c => c.UserData != null && (c.UserData as Submarine).Name == subName) as GUITextBlock;
|
var matchingListSub = subList.children.Find(c => c.UserData != null && (c.UserData as Submarine).Name == subName) as GUITextBlock;
|
||||||
if (matchingListSub != null)
|
if (matchingListSub != null)
|
||||||
@@ -1173,9 +1173,9 @@ namespace Barotrauma
|
|||||||
+ "Server's MD5 hash: " + md5Hash + ". ";
|
+ "Server's MD5 hash: " + md5Hash + ". ";
|
||||||
}
|
}
|
||||||
|
|
||||||
string downloadMsg = string.IsNullOrEmpty(GameMain.Client.ActiveFileTransferName) ?
|
/*string downloadMsg = string.IsNullOrEmpty(GameMain.Client.ActiveFileTransferName) ?
|
||||||
"Do you want to download the file from the server host?" :
|
"Do you want to download the file from the server host?" :
|
||||||
"Do you want to download the file and cancel downloading ''" + GameMain.Client.ActiveFileTransferName + "''?";
|
"Do you want to download the file and cancel downloading ''" + GameMain.Client.ActiveFileTransferName + "''?";*/
|
||||||
|
|
||||||
if (GUIMessageBox.MessageBoxes.Count>0)
|
if (GUIMessageBox.MessageBoxes.Count>0)
|
||||||
{
|
{
|
||||||
@@ -1186,7 +1186,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var requestFileBox = new GUIMessageBox("Submarine not found!", errorMsg+downloadMsg, new string[] { "Yes", "No" }, 400, 300);
|
/*var requestFileBox = new GUIMessageBox("Submarine not found!", errorMsg+downloadMsg, new string[] { "Yes", "No" }, 400, 300);
|
||||||
requestFileBox.Buttons[0].UserData = subName;
|
requestFileBox.Buttons[0].UserData = subName;
|
||||||
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
|
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
|
||||||
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
|
requestFileBox.Buttons[0].OnClicked += (GUIButton button, object userdata) =>
|
||||||
@@ -1194,7 +1194,7 @@ namespace Barotrauma
|
|||||||
GameMain.Client.RequestFile(userdata.ToString(), FileTransferMessageType.Submarine);
|
GameMain.Client.RequestFile(userdata.ToString(), FileTransferMessageType.Submarine);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;
|
requestFileBox.Buttons[1].OnClicked += requestFileBox.Close;*/
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user