diff --git a/Subsurface/Source/Characters/AI/EnemyAIController.cs b/Subsurface/Source/Characters/AI/EnemyAIController.cs index 961b32e40..bc2238579 100644 --- a/Subsurface/Source/Characters/AI/EnemyAIController.cs +++ b/Subsurface/Source/Characters/AI/EnemyAIController.cs @@ -30,9 +30,7 @@ namespace Barotrauma private float updateTargetsTimer; private float raycastTimer; - - private Vector2 prevPosition; - + //a timer for attacks such as biting that last for a specific amount of time //the duration is determined by the attackDuration of the attacking limb private float attackTimer; diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjective.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjective.cs index d749eb214..86cafe575 100644 --- a/Subsurface/Source/Characters/AI/Objectives/AIObjective.cs +++ b/Subsurface/Source/Characters/AI/Objectives/AIObjective.cs @@ -48,7 +48,6 @@ namespace Barotrauma /// makes the character act according to the objective, or according to any subobjectives that /// need to be completed before this one /// - /// the character who's trying to achieve the objective public void TryComplete(float deltaTime) { subObjectives.RemoveAll(s => s.IsCompleted() || !s.CanBeCompleted); diff --git a/Subsurface/Source/Characters/AICharacter.cs b/Subsurface/Source/Characters/AICharacter.cs index 03541a015..d4fcb7ca6 100644 --- a/Subsurface/Source/Characters/AICharacter.cs +++ b/Subsurface/Source/Characters/AICharacter.cs @@ -5,8 +5,6 @@ namespace Barotrauma { class AICharacter : Character { - const float AttackBackPriority = 1.0f; - private AIController aiController; public override AIController AIController diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index 23fc613b0..a659da71e 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -857,7 +857,7 @@ namespace Barotrauma headInWater = false; inWater = false; - if (inWater = currentHull.Volume > currentHull.FullVolume * 0.95f) + if (currentHull.Volume > currentHull.FullVolume * 0.95f) { inWater = true; } @@ -1435,8 +1435,6 @@ namespace Barotrauma public Vector2 GetColliderBottom() { - float halfHeight = Collider.height * 0.5f + Collider.radius; - float offset = 0.0f; if (!character.IsUnconscious && !character.IsDead && character.Stun <= 0.0f) diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index c7f64f6d2..215946baa 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -37,9 +37,7 @@ namespace Barotrauma } } } - - public List SpawnItems = new List(); - + private bool enabled = true; public bool Enabled { diff --git a/Subsurface/Source/Characters/CharacterNetworking.cs b/Subsurface/Source/Characters/CharacterNetworking.cs index ab974530f..43884d168 100644 --- a/Subsurface/Source/Characters/CharacterNetworking.cs +++ b/Subsurface/Source/Characters/CharacterNetworking.cs @@ -70,7 +70,6 @@ namespace Barotrauma public InputNetFlags states; //keys pressed/other boolean states at this step public UInt16 intAim; //aim angle, represented as an unsigned short where 0=0º, 65535=just a bit under 360º public UInt16 interact; //id of the entity being interacted with - public AnimController.Animation? animation; public UInt16 networkUpdateID; } diff --git a/Subsurface/Source/Characters/Jobs/Job.cs b/Subsurface/Source/Characters/Jobs/Job.cs index 3848eddcd..1f975bf72 100644 --- a/Subsurface/Source/Characters/Jobs/Job.cs +++ b/Subsurface/Source/Characters/Jobs/Job.cs @@ -131,9 +131,7 @@ namespace Barotrauma item.AddTag(s); } } - - character.SpawnItems.Add(item); - + if (parentItem != null) parentItem.Combine(item); foreach (XElement childItemElement in itemElement.Elements()) @@ -142,7 +140,7 @@ namespace Barotrauma } } - public virtual XElement Save(XElement parentElement) + public XElement Save(XElement parentElement) { XElement jobElement = new XElement("job"); diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs index 9116143dd..341415835 100644 --- a/Subsurface/Source/Characters/Limb.cs +++ b/Subsurface/Source/Characters/Limb.cs @@ -48,13 +48,7 @@ namespace Barotrauma public readonly LimbType type; public readonly bool ignoreCollisions; - - //private readonly float maxHealth; - //private float damage; - //private float bleeding; - - public readonly float impactTolerance; - + private float damage, burnt; private readonly Vector2 armorSector; diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs index 8fcfff3f1..03510d168 100644 --- a/Subsurface/Source/DebugConsole.cs +++ b/Subsurface/Source/DebugConsole.cs @@ -367,7 +367,7 @@ namespace Barotrauma } else if (spawnInventory != null) { - Item.Spawner.AddToSpawnQueue(itemPrefab, (Inventory)spawnInventory); + Item.Spawner.AddToSpawnQueue(itemPrefab, spawnInventory); } break; diff --git a/Subsurface/Source/Fonts/ScalableFont.cs b/Subsurface/Source/Fonts/ScalableFont.cs index 8dcb64f73..4a061bd56 100644 --- a/Subsurface/Source/Fonts/ScalableFont.cs +++ b/Subsurface/Source/Fonts/ScalableFont.cs @@ -114,7 +114,7 @@ namespace Barotrauma face.LoadGlyph(face.GetCharIndex(baseChar), LoadFlags.Default, LoadTarget.Normal); baseHeight = face.Glyph.Metrics.Height.ToInt32(); //lineHeight = baseHeight; - for (int i = 0; i < charRanges.Count(); i += 2) + for (int i = 0; i < charRanges.Length; i += 2) { uint start = charRanges[i]; uint end = charRanges[i + 1]; @@ -139,7 +139,7 @@ namespace Barotrauma face.Glyph.RenderGlyph(RenderMode.Normal); byte[] bitmap = face.Glyph.Bitmap.BufferData; int glyphWidth = face.Glyph.Bitmap.Width; - int glyphHeight = bitmap.Count() / glyphWidth; + int glyphHeight = bitmap.Length / glyphWidth; //if (glyphHeight>lineHeight) lineHeight=glyphHeight; diff --git a/Subsurface/Source/GUI/ComponentStyle.cs b/Subsurface/Source/GUI/ComponentStyle.cs index 57f11faf2..9e5040057 100644 --- a/Subsurface/Source/GUI/ComponentStyle.cs +++ b/Subsurface/Source/GUI/ComponentStyle.cs @@ -59,9 +59,7 @@ namespace Barotrauma public readonly Color OutlineColor; public readonly Dictionary> Sprites; - - public readonly bool TileSprites; - + public Dictionary ChildStyles; public GUIComponentStyle(XElement element) diff --git a/Subsurface/Source/GUI/GUIComponent.cs b/Subsurface/Source/GUI/GUIComponent.cs index 77cd79f21..62fdeb449 100644 --- a/Subsurface/Source/GUI/GUIComponent.cs +++ b/Subsurface/Source/GUI/GUIComponent.cs @@ -40,7 +40,7 @@ namespace Barotrauma catch (Exception e) { DebugConsole.NewMessage("Error in AddToGUIUPdateList! GUIComponent runtime type: "+this.GetType().ToString()+"; children count: "+children.Count.ToString(),Color.Red); - throw e; + throw; } } @@ -427,7 +427,7 @@ namespace Barotrauma catch (Exception e) { DebugConsole.NewMessage("Error in Update! GUIComponent runtime type: " + this.GetType().ToString() + "; children count: " + children.Count.ToString(), Color.Red); - throw e; + throw; } } diff --git a/Subsurface/Source/GUI/GUIListBox.cs b/Subsurface/Source/GUI/GUIListBox.cs index ed9b57158..9ce554c0d 100644 --- a/Subsurface/Source/GUI/GUIListBox.cs +++ b/Subsurface/Source/GUI/GUIListBox.cs @@ -261,7 +261,7 @@ namespace Barotrauma catch (Exception e) { DebugConsole.NewMessage("Error in AddToGUIUpdateList! GUIComponent runtime type: " + this.GetType().ToString() + "; children count: " + children.Count.ToString(), Color.Red); - throw e; + throw; } if (scrollBarEnabled && !scrollBarHidden) scrollBar.AddToGUIUpdateList(); diff --git a/Subsurface/Source/GameSession/CargoManager.cs b/Subsurface/Source/GameSession/CargoManager.cs index c6292c27a..600e91c5f 100644 --- a/Subsurface/Source/GameSession/CargoManager.cs +++ b/Subsurface/Source/GameSession/CargoManager.cs @@ -41,7 +41,7 @@ namespace Barotrauma Rand.Range(cargoRoom.Rect.X + 20, cargoRoom.Rect.Right - 20), cargoRoom.Rect.Y - cargoRoom.Rect.Height + prefab.Size.Y/2); - new Item(prefab as ItemPrefab, position, wp.Submarine); + new Item(prefab, position, wp.Submarine); } purchasedItems.Clear(); diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index 7da8026cd..79b825f85 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -161,9 +161,9 @@ namespace Barotrauma public void StartShift(string levelSeed, bool loadSecondSub = false) { - Level level = Level.CreateRandom(levelSeed); + Level randomLevel = Level.CreateRandom(levelSeed); - StartShift(level,true,loadSecondSub); + StartShift(randomLevel, true, loadSecondSub); } public void StartShift(Level level, bool reloadSub = true, bool loadSecondSub = false) diff --git a/Subsurface/Source/GameSession/HireManager.cs b/Subsurface/Source/GameSession/HireManager.cs index 60043908b..166523957 100644 --- a/Subsurface/Source/GameSession/HireManager.cs +++ b/Subsurface/Source/GameSession/HireManager.cs @@ -6,7 +6,7 @@ namespace Barotrauma { public List availableCharacters; - const int MaxAvailableCharacters = 10; + public const int MaxAvailableCharacters = 10; public HireManager() { diff --git a/Subsurface/Source/Items/Components/DockingPort.cs b/Subsurface/Source/Items/Components/DockingPort.cs index d728398b1..4af54f726 100644 --- a/Subsurface/Source/Items/Components/DockingPort.cs +++ b/Subsurface/Source/Items/Components/DockingPort.cs @@ -714,7 +714,6 @@ namespace Barotrauma.Items.Components if (gap != null) { gap.Remove(); - gap.linkedTo.Remove(hull); continue; } diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs index 8998491d6..173b37f4c 100644 --- a/Subsurface/Source/Items/Components/Door.cs +++ b/Subsurface/Source/Items/Components/Door.cs @@ -33,9 +33,7 @@ namespace Barotrauma.Items.Components private bool isHorizontal; private bool isStuck; - - private float lastReceivedMessage; - + private bool? predictedState; private float resetPredictionTimer; diff --git a/Subsurface/Source/Items/Components/Machines/Controller.cs b/Subsurface/Source/Items/Components/Machines/Controller.cs index 63df851a2..82c4cb9d4 100644 --- a/Subsurface/Source/Items/Components/Machines/Controller.cs +++ b/Subsurface/Source/Items/Components/Machines/Controller.cs @@ -95,8 +95,6 @@ namespace Barotrauma.Items.Components if (userPos != Vector2.Zero) { - float torsoX = character.Position.X; - Vector2 diff = (item.WorldPosition + userPos) - character.WorldPosition; if (character.AnimController.InWater) diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index d8110f3a7..361d80136 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -148,9 +148,7 @@ namespace Barotrauma.Items.Components radarBlips[i].FadeTimer -= (float)Timing.Step * 0.5f; if (radarBlips[i].FadeTimer <= 0.0f) radarBlips.RemoveAt(i); } - - float radius = (GuiFrame.Rect.Height / 2 - 30); - + if (IsActive) { float pingRadius = displayRadius * pingState; diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 9375c2342..e1881f842 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -262,13 +262,7 @@ namespace Barotrauma { get { return prefab.ConfigFile; } } - - public bool Removed - { - get; - private set; - } - + //which type of inventory slots (head, torso, any, etc) the item can be placed in public List AllowedSlots { @@ -278,16 +272,7 @@ namespace Barotrauma return (p==null) ? new List() { InvSlotType.Any } : p.AllowedSlots; } } - - public int Capacity - { - get - { - ItemContainer c = GetComponent(); - return (c == null) ? 0 : c.Capacity; - } - } - + public List Connections { get @@ -570,11 +555,11 @@ namespace Barotrauma { if (parentInventory.Owner is Character) { - CurrentHull = (parentInventory.Owner as Character).AnimController.CurrentHull; + CurrentHull = ((Character)parentInventory.Owner).AnimController.CurrentHull; } else if (parentInventory.Owner is Item) { - CurrentHull = (parentInventory.Owner as Item).CurrentHull; + CurrentHull = ((Item)parentInventory.Owner).CurrentHull; } Submarine = parentInventory.Owner.Submarine; @@ -2306,9 +2291,7 @@ namespace Barotrauma public override void ShallowRemove() { base.ShallowRemove(); - - Removed = true; - + foreach (ItemComponent ic in components) { ic.ShallowRemove(); @@ -2325,9 +2308,7 @@ namespace Barotrauma public override void Remove() { base.Remove(); - - Removed = true; - + if (parentInventory != null) { parentInventory.RemoveItem(this); diff --git a/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs b/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs index ea7879324..62f81759b 100644 --- a/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs +++ b/Subsurface/Source/Map/Levels/Ruins/RuinGenerator.cs @@ -1,13 +1,8 @@ -using FarseerPhysics.Common; -using FarseerPhysics.Common.PolygonManipulation; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Voronoi2; namespace Barotrauma.RuinGeneration diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs index ab3296206..3d455da6c 100644 --- a/Subsurface/Source/Map/Lights/ConvexHull.cs +++ b/Subsurface/Source/Map/Lights/ConvexHull.cs @@ -239,15 +239,15 @@ namespace Barotrauma.Lights private void CalculateDimensions() { - float? minX = null, minY = null, maxX = null, maxY = null; + float minX = vertices[0].Pos.X, minY = vertices[0].Pos.Y, maxX = vertices[0].Pos.X, maxY = vertices[0].Pos.Y; - for (int i = 0; i < vertices.Length; i++) + for (int i = 1; i < vertices.Length; i++) { - if (minX == null || vertices[i].Pos.X < minX) minX = vertices[i].Pos.X; - if (minY == null || vertices[i].Pos.Y < minY) minY = vertices[i].Pos.Y; + if (vertices[i].Pos.X < minX) minX = vertices[i].Pos.X; + if (vertices[i].Pos.Y < minY) minY = vertices[i].Pos.Y; - if (maxX == null || vertices[i].Pos.X > maxX) maxX = vertices[i].Pos.X; - if (maxY == null || vertices[i].Pos.Y > minY) maxY = vertices[i].Pos.Y; + if (vertices[i].Pos.X > maxX) maxX = vertices[i].Pos.X; + if (vertices[i].Pos.Y > minY) maxY = vertices[i].Pos.Y; } boundingBox = new Rectangle((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY)); diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index ba8212110..44355c81b 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -40,8 +40,8 @@ namespace Barotrauma.Lights private Texture2D visionCircle; - private Dictionary hullAmbientLights = new Dictionary(); - private Dictionary smoothedHullAmbientLights = new Dictionary(); + private Dictionary hullAmbientLights; + private Dictionary smoothedHullAmbientLights; private float ambientLightUpdateTimer; @@ -133,10 +133,7 @@ namespace Barotrauma.Lights public void UpdateLightMap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Effect blur) { if (!LightingEnabled) return; - - Matrix shadowTransform = cam.ShaderTransform - * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; - + graphics.SetRenderTarget(lightMap); Rectangle viewRect = cam.WorldView; @@ -337,20 +334,12 @@ namespace Barotrauma.Lights return hullAmbientLight; } - - private void ClearAlphaToOne(GraphicsDevice graphics, SpriteBatch spriteBatch) - { - spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.WriteToAlpha); - spriteBatch.Draw(alphaClearTexture, new Rectangle(0, 0,graphics.Viewport.Width, graphics.Viewport.Height), Color.White); - spriteBatch.End(); - } - + public void DrawLightMap(SpriteBatch spriteBatch, Effect effect) { if (!LightingEnabled) return; spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative, null, null, null, effect); - //effect.CurrentTechnique.Passes[0].Apply(); spriteBatch.Draw(lightMap, Vector2.Zero, Color.White); spriteBatch.End(); } diff --git a/Subsurface/Source/Map/Map/Location.cs b/Subsurface/Source/Map/Map/Location.cs index 6b40a79b2..5b3b193c2 100644 --- a/Subsurface/Source/Map/Map/Location.cs +++ b/Subsurface/Source/Map/Map/Location.cs @@ -49,7 +49,7 @@ namespace Barotrauma if (type.HasHireableCharacters) { hireManager = new HireManager(); - hireManager.GenerateCharacters(this, 10); + hireManager.GenerateCharacters(this, HireManager.MaxAvailableCharacters); } Connections = new List(); @@ -62,9 +62,9 @@ namespace Barotrauma private string RandomName(LocationType type) { - string name = ToolBox.GetRandomLine("Content/Map/locationNames.txt"); + string randomName = ToolBox.GetRandomLine("Content/Map/locationNames.txt"); int nameFormatIndex = Rand.Int(type.NameFormats.Count, false); - return type.NameFormats[nameFormatIndex].Replace("[name]", name); + return type.NameFormats[nameFormatIndex].Replace("[name]", randomName); } } } diff --git a/Subsurface/Source/Map/MapEntity.cs b/Subsurface/Source/Map/MapEntity.cs index ac79a56b6..35a834d5f 100644 --- a/Subsurface/Source/Map/MapEntity.cs +++ b/Subsurface/Source/Map/MapEntity.cs @@ -362,9 +362,7 @@ namespace Barotrauma linkedTo.Clear(); } } - - static Dictionary timeElapsed = new Dictionary(); - + /// /// Call Update() on every object in Entity.list /// diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index 34fc80488..39eaa4e99 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -872,7 +872,7 @@ namespace Barotrauma public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime) { - for (int i = 0; i < sections.Count(); i++) + for (int i = 0; i < sections.Length; i++) { float damage = msg.ReadRangedSingle(0.0f, 1.0f, 8) * Health; diff --git a/Subsurface/Source/Networking/ChatMessage.cs b/Subsurface/Source/Networking/ChatMessage.cs index c640dfa93..c2ef0099d 100644 --- a/Subsurface/Source/Networking/ChatMessage.cs +++ b/Subsurface/Source/Networking/ChatMessage.cs @@ -1,5 +1,4 @@ -using Barotrauma.Items.Components; -using Lidgren.Network; +using Lidgren.Network; using Microsoft.Xna.Framework; using System; using System.Text; diff --git a/Subsurface/Source/Networking/Client.cs b/Subsurface/Source/Networking/Client.cs index faf46853a..bec8eb339 100644 --- a/Subsurface/Source/Networking/Client.cs +++ b/Subsurface/Source/Networking/Client.cs @@ -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 diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index e2df17800..f5d7ee667 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -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; diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index b2ae0e810..375b337ca 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -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 } diff --git a/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs b/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs index 08614b3e2..01bc37199 100644 --- a/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs +++ b/Subsurface/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs @@ -156,7 +156,7 @@ namespace Barotrauma.Networking //kick everyone that hasn't received it yet, this is way too old List 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 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); } diff --git a/Subsurface/Source/Networking/RespawnManager.cs b/Subsurface/Source/Networking/RespawnManager.cs index c5220b685..cfeeecf75 100644 --- a/Subsurface/Source/Networking/RespawnManager.cs +++ b/Subsurface/Source/Networking/RespawnManager.cs @@ -392,12 +392,8 @@ namespace Barotrauma.Networking { var server = networkMember as GameServer; if (server == null) return; - - List spawnedItems = new List(); - List spawnedCharacters = new List(); - + var clients = GetClientsToRespawn(); - foreach (Client c in clients) { if (c.characterInfo == null) c.characterInfo = new CharacterInfo(Character.HumanConfigFile, c.name); diff --git a/Subsurface/Source/Physics/PhysicsBody.cs b/Subsurface/Source/Physics/PhysicsBody.cs index 70458ab67..c69cda269 100644 --- a/Subsurface/Source/Physics/PhysicsBody.cs +++ b/Subsurface/Source/Physics/PhysicsBody.cs @@ -78,8 +78,7 @@ namespace Barotrauma private Vector2 drawPosition; private float drawRotation; - - private float lastNetworkUpdateTime; + public Vector2 LastSentPosition { get; diff --git a/Subsurface/Source/Screens/EditCharacterScreen.cs b/Subsurface/Source/Screens/EditCharacterScreen.cs index 1b213b23b..5c70fbd7b 100644 --- a/Subsurface/Source/Screens/EditCharacterScreen.cs +++ b/Subsurface/Source/Screens/EditCharacterScreen.cs @@ -95,7 +95,6 @@ namespace Barotrauma /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// - /// Provides a snapshot of timing values. public override void Update(double deltaTime) { cam.MoveCamera((float)deltaTime); @@ -113,7 +112,6 @@ namespace Barotrauma /// /// This is called when the game should draw itself. /// - /// Provides a snapshot of timing values. public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) { //cam.UpdateTransform(); diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index 194202f30..fe7a802e6 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -960,7 +960,6 @@ namespace Barotrauma /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// - /// Provides a snapshot of timing values. public override void Update(double deltaTime) { if (tutorial != null) tutorial.Update((float)deltaTime); @@ -1085,7 +1084,6 @@ namespace Barotrauma /// /// This is called when the game should draw itself. /// - /// Provides a snapshot of timing values. public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch) { cam.UpdateTransform(); diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 51773d304..29cfc59ef 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -110,7 +110,6 @@ namespace Barotrauma /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// - /// Provides a snapshot of timing values. public override void Update(double deltaTime) { diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index 2ed1c12ee..556de2f26 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -1120,10 +1120,9 @@ namespace Barotrauma //} GameModePreset modePreset = obj as GameModePreset; - missionTypeBlock.Visible = modePreset.Name == "Mission"; - if (modePreset == null) return false; + missionTypeBlock.Visible = modePreset.Name == "Mission"; lastUpdateID++; return true; diff --git a/Subsurface/Source/Sounds/SoundManager.cs b/Subsurface/Source/Sounds/SoundManager.cs index 4b1202da9..b8d93dfcb 100644 --- a/Subsurface/Source/Sounds/SoundManager.cs +++ b/Subsurface/Source/Sounds/SoundManager.cs @@ -48,7 +48,7 @@ namespace Barotrauma.Sounds catch (DllNotFoundException e) { Program.CrashMessageBox("OpenAL32.dll not found"); - throw e; + throw; } for (int i = 0 ; i < DefaultSourceCount; i++) diff --git a/Subsurface/Source/Utils/SaveUtil.cs b/Subsurface/Source/Utils/SaveUtil.cs index 83c39e761..d7a9a7bcd 100644 --- a/Subsurface/Source/Utils/SaveUtil.cs +++ b/Subsurface/Source/Utils/SaveUtil.cs @@ -22,9 +22,7 @@ namespace Barotrauma fileName = Path.Combine(SaveFolder, fileName); string tempPath = Path.Combine(SaveFolder, "temp"); - - DirectoryInfo dir = new DirectoryInfo(tempPath); - + Directory.CreateDirectory(tempPath); try {