Cleanup (removing unused variables & other redundancies, rethrowing exceptions instead of wrapping them in a new exception instance)

This commit is contained in:
Regalis
2017-05-20 15:35:13 +03:00
parent 89bd2b1a98
commit e3b595b9e0
40 changed files with 54 additions and 138 deletions
+1 -2
View File
@@ -1,5 +1,4 @@
using Barotrauma.Items.Components;
using Lidgren.Network;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using System;
using System.Text;
+1 -3
View File
@@ -28,11 +28,9 @@ namespace Barotrauma.Networking
public Character Character;
public CharacterInfo characterInfo;
public NetConnection Connection { get; set; }
public string version;
public bool inGame;
public UInt16 lastRecvGeneralUpdate = 0;
public bool hasLobbyData = false;
public UInt16 lastSentChatMsgID = 0; //last msg this client said
public UInt16 lastRecvChatMsgID = 0; //last msg this client knows about
+1 -5
View File
@@ -1094,8 +1094,7 @@ namespace Barotrauma.Networking
for (int i = 0; i < fileReceiver.ActiveTransfers.Count; i++)
{
var transfer = fileReceiver.ActiveTransfers[i];
GameMain.NetLobbyScreen.SubList.children.Find(c => c is GUITextBlock && ((GUITextBlock)c).Text == transfer.FileName);
GUI.DrawString(spriteBatch,
pos,
ToolBox.LimitString("Downloading " + transfer.FileName, GUI.SmallFont, 200),
@@ -1221,9 +1220,6 @@ namespace Barotrauma.Networking
if (votedClient == null) return false;
votedClient.AddKickVote(new Client(name, ID));
if (votedClient == null) return false;
Vote(VoteType.Kick, votedClient);
button.Enabled = false;
@@ -9,12 +9,12 @@ using System.Xml.Linq;
namespace Barotrauma.Networking
{
enum SelectionMode : int
enum SelectionMode
{
Manual = 0, Random = 1, Vote = 2
}
enum YesNoMaybe : int
enum YesNoMaybe
{
No = 0, Maybe = 1, Yes = 2
}
@@ -156,7 +156,7 @@ namespace Barotrauma.Networking
//kick everyone that hasn't received it yet, this is way too old
List<Client> toKick = inGameClients.FindAll(c => NetIdUtils.IdMoreRecent((UInt16)(lastSentToAll + 1), c.lastRecvEntityEventID));
if (toKick != null) toKick.ForEach(c => server.DisconnectClient(c, "", "You have been disconnected because of excessive desync"));
toKick.ForEach(c => server.DisconnectClient(c, "", "You have been disconnected because of excessive desync"));
}
if (events.Count > 0)
@@ -164,12 +164,12 @@ namespace Barotrauma.Networking
//the client is waiting for an event that we don't have anymore
//(the ID they're expecting is smaller than the ID of the first event in our list)
List<Client> toKick = inGameClients.FindAll(c => NetIdUtils.IdMoreRecent(events[0].ID, (UInt16)(c.lastRecvEntityEventID+1)));
if (toKick != null) toKick.ForEach(c => server.DisconnectClient(c, "", "You have been disconnected because of excessive desync"));
toKick.ForEach(c => server.DisconnectClient(c, "", "You have been disconnected because of excessive desync"));
}
}
var timedOutClients = clients.FindAll(c => c.inGame && c.NeedsMidRoundSync && Timing.TotalTime > c.MidRoundSyncTimeOut);
if (timedOutClients != null) timedOutClients.ForEach(c => GameMain.Server.DisconnectClient(c, "", "You have been disconnected because syncing your client with the server took too long."));
timedOutClients.ForEach(c => GameMain.Server.DisconnectClient(c, "", "You have been disconnected because syncing your client with the server took too long."));
bufferedEvents.RemoveAll(b => b.IsProcessed);
}
@@ -392,12 +392,8 @@ namespace Barotrauma.Networking
{
var server = networkMember as GameServer;
if (server == null) return;
List<Item> spawnedItems = new List<Item>();
List<Character> spawnedCharacters = new List<Character>();
var clients = GetClientsToRespawn();
foreach (Client c in clients)
{
if (c.characterInfo == null) c.characterInfo = new CharacterInfo(Character.HumanConfigFile, c.name);