diff --git a/Barotrauma/BarotraumaClient/Source/Camera.cs b/Barotrauma/BarotraumaClient/Source/Camera.cs index aac342e7f..4fa02a0ed 100644 --- a/Barotrauma/BarotraumaClient/Source/Camera.cs +++ b/Barotrauma/BarotraumaClient/Source/Camera.cs @@ -264,7 +264,7 @@ namespace Barotrauma } } - if (allowZoom) + if (allowZoom && GUI.MouseOn == null) { Vector2 mouseInWorld = ScreenToWorld(PlayerInput.MousePosition); Vector2 diffViewCenter; diff --git a/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs b/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs index 163db3f82..020cab90b 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/LoadingScreen.cs @@ -201,8 +201,15 @@ namespace Barotrauma #if !(LINUX || OSX) private void DrawSplashScreen(SpriteBatch spriteBatch) { + bool vsync = GameMain.Config.VSyncEnabled; if (videoPlayer == null) { + // Enforce the vsync so that the video player doesn't eat all the vram + if (!GameMain.Config.VSyncEnabled) + { + GameMain.Config.VSyncEnabled = true; + GameMain.Instance.ApplyGraphicsSettings(); + } videoPlayer = new VideoPlayer(); videoPlayer.Play(splashScreenVideo); videoPlayer.Volume = GameMain.Config.SoundVolume; @@ -218,6 +225,12 @@ namespace Barotrauma splashScreenVideo.Dispose(); splashScreenVideo = null; + // If the vsync was enforced, restore the user preference + if (GameMain.Config.VSyncEnabled != vsync) + { + GameMain.Config.VSyncEnabled = vsync; + GameMain.Instance.ApplyGraphicsSettings(); + } } else { @@ -232,7 +245,6 @@ namespace Barotrauma videoPlayer.Stop(); } } - } } #endif diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index e3e003f2f..74185da13 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -106,7 +106,7 @@ namespace Barotrauma characterListBox = new GUIListBox(new RectTransform(new Point(100, (int)(crewArea.Rect.Height - scrollButtonSize.Y * 1.6f)), crewArea.RectTransform, Anchor.CenterLeft), false, Color.Transparent, null) { - Spacing = (int)(3 * GUI.Scale), + //Spacing = (int)(3 * GUI.Scale), ScrollBarEnabled = false, ScrollBarVisible = false, CanBeFocused = false diff --git a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs index 7f1948ff5..b493fbf92 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Components/Machines/Sonar.cs @@ -455,14 +455,14 @@ namespace Barotrauma.Items.Components foreach (Submarine sub in Submarine.Loaded) { - if (!sub.OnSonar) continue; + if (!sub.ShowSonarMarker) { continue; } if (UseTransducers ? connectedTransducers.Any(t => sub == t.Transducer.Item.Submarine || sub.DockedTo.Contains(t.Transducer.Item.Submarine)) : (sub == item.Submarine || sub.DockedTo.Contains(item.Submarine))) { continue; } - if (sub.WorldPosition.Y > Level.Loaded.Size.Y) continue; + if (sub.WorldPosition.Y > Level.Loaded.Size.Y) { continue; } DrawMarker(spriteBatch, sub.Name, sub.WorldPosition - transducerCenter, displayScale, center, (rect.Width * 0.45f)); } diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 64cd2f6eb..1e8762123 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -1173,6 +1173,15 @@ namespace Barotrauma.Networking ConnectedClients.RemoveAt(i); } } + //remove clients that aren't present anymore + for (int i = ConnectedClients.Count - 1; i >= 0; i--) + { + if (!currentClients.Contains(ConnectedClients[i])) + { + GameMain.NetLobbyScreen.RemovePlayer(ConnectedClients[i].Name); + ConnectedClients.RemoveAt(i); + } + } Voting.AllowSubVoting = allowSubVoting; Voting.AllowModeVoting = allowModeVoting; diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameServer.cs index 9bb8cf42b..2f87c7689 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameServer.cs @@ -237,6 +237,7 @@ namespace Barotrauma.Networking public bool StartGameClicked(GUIButton button, object obj) { + if (initiatedStartGame || gameStarted) { return false; } return StartGame(); } } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs index 9373f21f7..2731c054c 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CharacterEditorScreen.cs @@ -417,7 +417,7 @@ namespace Barotrauma GameMain.World.Step((float)deltaTime); } // Camera - Cam.MoveCamera((float)deltaTime, allowMove: false, allowZoom: GUI.MouseOn == null); + Cam.MoveCamera((float)deltaTime, allowMove: false); bool movementInput = PlayerInput.KeyDown(InputType.Up) || PlayerInput.KeyDown(InputType.Down) || PlayerInput.KeyDown(InputType.Left) || PlayerInput.KeyDown(InputType.Right); // 0.2f, because we want to allow the user to pan when the character is floating in the water without actively moving if (!isFreezed && (character.AnimController.Collider.LinearVelocity.LengthSquared() > 0.2f || movementInput)) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs index 4a189ed9a..792ba1d17 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/LevelEditorScreen.cs @@ -474,7 +474,7 @@ namespace Barotrauma pointerLightSource.Position = cam.ScreenToWorld(PlayerInput.MousePosition); pointerLightSource.Enabled = cursorLightEnabled.Selected; pointerLightSource.IsBackground = true; - cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null); + cam.MoveCamera((float)deltaTime); cam.UpdateTransform(); Level.Loaded?.Update((float)deltaTime, cam); diff --git a/Barotrauma/BarotraumaClient/Source/Screens/ParticleEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/ParticleEditorScreen.cs index e935c6103..c725d0f6e 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/ParticleEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/ParticleEditorScreen.cs @@ -238,7 +238,7 @@ namespace Barotrauma public override void Update(double deltaTime) { - cam.MoveCamera((float)deltaTime, true, GUI.MouseOn == null); + cam.MoveCamera((float)deltaTime, true); if (selectedPrefab != null) { diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index 634a7526a..90d467adc 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -1937,7 +1937,7 @@ namespace Barotrauma hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull); saveAssemblyFrame.Visible = MapEntity.SelectedList.Count > 0; - cam.MoveCamera((float)deltaTime, true, GUI.MouseOn == null); + cam.MoveCamera((float)deltaTime, true); if (PlayerInput.MidButtonHeld()) { Vector2 moveSpeed = PlayerInput.MouseSpeed * (float)deltaTime * 100.0f / cam.Zoom; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index 78eebbcb6..11b7aea79 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1781,19 +1781,47 @@ namespace Barotrauma if (GameMain.Server != null) { //disable AI characters that are far away from all clients and the host's character and not controlled by anyone - c.Enabled = - c == controlled || - c.IsRemotePlayer || - CharacterList.Any(c2 => - c != c2 && - (c2.IsRemotePlayer || c2 == GameMain.Server.Character) && - Vector2.DistanceSquared(c2.WorldPosition, c.WorldPosition) < NetConfig.CharacterIgnoreDistanceSqr); + if (c == controlled || c.IsRemotePlayer) + { + c.Enabled = true; + } + else + { + float distSqr = float.MaxValue; + foreach (Character otherCharacter in CharacterList) + { + if (otherCharacter == c) { continue; } + if (!otherCharacter.IsRemotePlayer && otherCharacter != GameMain.NetworkMember.Character) { continue; } + distSqr = Math.Min(distSqr, Vector2.DistanceSquared(otherCharacter.WorldPosition, c.WorldPosition)); + } + + if (distSqr > NetConfig.DisableCharacterDistSqr) + { + c.Enabled = false; + } + else if (distSqr < NetConfig.EnableCharacterDistSqr) + { + c.Enabled = true; + } + } } else if (Submarine.MainSub != null) { //disable AI characters that are far away from the sub and the controlled character - c.Enabled = Vector2.DistanceSquared(Submarine.MainSub.WorldPosition, c.WorldPosition) < NetConfig.CharacterIgnoreDistanceSqr || - (controlled != null && Vector2.DistanceSquared(controlled.WorldPosition, c.WorldPosition) < NetConfig.CharacterIgnoreDistanceSqr); + float distSqr = Vector2.DistanceSquared(Submarine.MainSub.WorldPosition, c.WorldPosition); + if (Controlled != null) + { + distSqr = Math.Min(distSqr, Vector2.DistanceSquared(controlled.WorldPosition, c.WorldPosition)); + } + + if (distSqr > NetConfig.DisableCharacterDistSqr) + { + c.Enabled = false; + } + else if ( distSqr < NetConfig.EnableCharacterDistSqr) + { + c.Enabled = true; + } } } } diff --git a/Barotrauma/BarotraumaShared/Source/ContentPackage.cs b/Barotrauma/BarotraumaShared/Source/ContentPackage.cs index d5be0f314..d857507ef 100644 --- a/Barotrauma/BarotraumaShared/Source/ContentPackage.cs +++ b/Barotrauma/BarotraumaShared/Source/ContentPackage.cs @@ -195,9 +195,9 @@ namespace Barotrauma return true; } - //content package compatibility checks were added in 0.9 - //0.9 is not compatible with older content packages - if (GameVersion < new Version(0, 9)) + //content package compatibility checks were added in 0.8.9.1 + //v0.8.9.1 is not compatible with older content packages + if (GameVersion < new Version(0, 8, 9, 1)) { return false; } diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index 21ef0b7b8..a588a14c0 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -2388,6 +2388,18 @@ namespace Barotrauma character.ReloadHead(id, hairIndex, beardIndex, moustacheIndex, faceAttachmentIndex); } })); + + commands.Add(new Command("money", "", args => + { + if (args.Length == 0) { return; } + if (GameMain.GameSession.GameMode is CampaignMode campaign) + { + if (int.TryParse(args[0], out int money)) + { + campaign.Money += money; + } + } + }, isCheat: true)); #endif InitProjectSpecific(); diff --git a/Barotrauma/BarotraumaShared/Source/Events/Missions/CombatMission.cs b/Barotrauma/BarotraumaShared/Source/Events/Missions/CombatMission.cs index b74d6576f..506c931e2 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/Missions/CombatMission.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/Missions/CombatMission.cs @@ -178,7 +178,7 @@ namespace Barotrauma foreach (Submarine submarine in Submarine.Loaded) { //hide all subs from sonar to make sneak attacks possible - submarine.OnSonar = false; + submarine.ShowSonarMarker = false; } } diff --git a/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs b/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs index 8105184c7..77d83ced2 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/Missions/MonsterMission.cs @@ -25,8 +25,7 @@ namespace Barotrauma public override void Start(Level level) { - Vector2 spawnPos; - Level.Loaded.TryGetInterestingPosition(true, Level.PositionType.MainPath, Level.Loaded.Size.X * 0.3f, out spawnPos); + Level.Loaded.TryGetInterestingPosition(true, Level.PositionType.MainPath, Level.Loaded.Size.X * 0.3f, out Vector2 spawnPos); monster = Character.Create(monsterFile, spawnPos, ToolBox.RandomSeed(8), null, GameMain.Client != null, true, false); monster.Enabled = false; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs index 991b28baf..3651ebd2b 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/Level.cs @@ -1360,27 +1360,51 @@ namespace Barotrauma return false; } - var matchingPositions = positionsOfInterest.FindAll(p => positionType.HasFlag(p.PositionType)); - - if (minDistFromSubs > 0.0f) - { - foreach (Submarine sub in Submarine.Loaded) - { - matchingPositions.RemoveAll(p => Vector2.DistanceSquared(p.Position.ToVector2(), sub.WorldPosition) < minDistFromSubs * minDistFromSubs); - } - } - - if (!matchingPositions.Any()) + List suitablePositions = positionsOfInterest.FindAll(p => positionType.HasFlag(p.PositionType)); + if (!suitablePositions.Any()) { + string errorMsg = "Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace; + GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:PositionTypeNotFound", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); #if DEBUG - DebugConsole.ThrowError("Could not find a suitable position of interest. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + "\n" + Environment.StackTrace); + DebugConsole.ThrowError(errorMsg); #endif - position = positionsOfInterest[Rand.Int(positionsOfInterest.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position; return false; } - position = matchingPositions[Rand.Int(matchingPositions.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position; + List farEnoughPositions = new List(suitablePositions); + if (minDistFromSubs > 0.0f) + { + foreach (Submarine sub in Submarine.Loaded) + { + if (sub.IsOutpost) { continue; } + farEnoughPositions.RemoveAll(p => Vector2.DistanceSquared(p.Position.ToVector2(), sub.WorldPosition) < minDistFromSubs * minDistFromSubs); + } + } + if (!farEnoughPositions.Any()) + { + string errorMsg = "Could not find a position of interest far enough from the submarines. (PositionType: " + positionType + ", minDistFromSubs: " + minDistFromSubs + ")\n" + Environment.StackTrace; + GameAnalyticsManager.AddErrorEventOnce("Level.TryGetInterestingPosition:TooCloseToSubs", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); +#if DEBUG + DebugConsole.ThrowError(errorMsg); +#endif + float maxDist = 0.0f; + position = suitablePositions.First().Position; + foreach (InterestingPosition pos in suitablePositions) + { + float dist = Submarine.Loaded.Sum(s => + Submarine.MainSubs.Contains(s) ? Vector2.DistanceSquared(s.WorldPosition, pos.Position.ToVector2()) : 0.0f); + if (dist > maxDist) + { + position = pos.Position; + maxDist = dist; + } + } + + return false; + } + + position = farEnoughPositions[Rand.Int(farEnoughPositions.Count, (useSyncedRand ? Rand.RandSync.Server : Rand.RandSync.Unsynced))].Position; return true; } diff --git a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs index 20c896c68..4c070061f 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Submarine.cs @@ -109,7 +109,7 @@ namespace Barotrauma set { name = value; } } - public bool OnSonar = true; + public bool ShowSonarMarker = true; public string Description { @@ -388,6 +388,7 @@ namespace Barotrauma public void MakeOutpost() { IsOutpost = true; + ShowSonarMarker = false; PhysicsBody.FarseerBody.IsStatic = true; foreach (MapEntity me in MapEntity.mapEntityList) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index 04600dd21..312c182cb 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -1081,7 +1081,7 @@ namespace Barotrauma.Networking if (!character.Enabled) continue; if (c.Character != null && Vector2.DistanceSquared(character.WorldPosition, c.Character.WorldPosition) >= - NetConfig.CharacterIgnoreDistanceSqr) + NetConfig.DisableCharacterDistSqr) { continue; } @@ -1325,6 +1325,7 @@ namespace Barotrauma.Networking return false; } + initiatedStartGame = true; CoroutineManager.StartCoroutine(InitiateStartGame(selectedSub, selectedShuttle, usingShuttle, selectedMode), "InitiateStartGame"); return true; diff --git a/Barotrauma/BarotraumaShared/Source/Networking/NetConfig.cs b/Barotrauma/BarotraumaShared/Source/Networking/NetConfig.cs index 8328c9f0a..7d1e21946 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/NetConfig.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/NetConfig.cs @@ -9,10 +9,14 @@ public static string MasterServerUrl = GameMain.Config.MasterServerUrl; - //if a Character is further than this from the sub, the server will ignore it + //if a Character is further than this from the sub and the players, the server will disable it //(in display units) - public const float CharacterIgnoreDistance = 20000.0f; - public const float CharacterIgnoreDistanceSqr = CharacterIgnoreDistance * CharacterIgnoreDistance; + public const float DisableCharacterDist = 22000.0f; + public const float DisableCharacterDistSqr = DisableCharacterDist * DisableCharacterDist; + + //the character needs to get this close to be re-enabled + public const float EnableCharacterDist = 20000.0f; + public const float EnableCharacterDistSqr = EnableCharacterDist * EnableCharacterDist; //how much the physics body of an item has to move until the server //send a position update to clients (in sim units) diff --git a/Barotrauma/BarotraumaShared/Submarines/Orca.sub b/Barotrauma/BarotraumaShared/Submarines/Orca.sub index 47a340b6f..31b4db621 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Orca.sub and b/Barotrauma/BarotraumaShared/Submarines/Orca.sub differ diff --git a/Barotrauma/BarotraumaShared/Submarines/Typhon.sub b/Barotrauma/BarotraumaShared/Submarines/Typhon.sub index 44d8c5e94..8d4c9f11a 100644 Binary files a/Barotrauma/BarotraumaShared/Submarines/Typhon.sub and b/Barotrauma/BarotraumaShared/Submarines/Typhon.sub differ diff --git a/Barotrauma/BarotraumaShared/config.xml b/Barotrauma/BarotraumaShared/config.xml index 2d7fdea96..4d124bec2 100644 --- a/Barotrauma/BarotraumaShared/config.xml +++ b/Barotrauma/BarotraumaShared/config.xml @@ -34,7 +34,7 @@ Run="LeftShift" Crouch="LeftControl" Chat="Tab" - RadioChat="OemTilde" + RadioChat="T" CrewOrders="C" Ragdoll="Space" Health="H"