diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs index b993f7deb..b8c7f8fee 100644 --- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs @@ -962,8 +962,6 @@ namespace Barotrauma } } } - element.Value = lines[i]; - i++; } }, isCheat: false)); #endif diff --git a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs index f09171b13..326df08c3 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs @@ -332,8 +332,7 @@ namespace Barotrauma.Networking } } - //too many events for one packet - if (eventsToSync.Count > 200) + if (client.NeedsMidRoundSync) { msg.Write((byte)ServerNetObject.ENTITY_EVENT_INITIAL); msg.Write(client.UnreceivedEntityEventCount); @@ -341,8 +340,7 @@ namespace Barotrauma.Networking Write(msg, eventsToSync, out sentEvents, client); } - - foreach (NetEntityEvent entityEvent in sentEvents) + else { msg.Write((byte)ServerNetObject.ENTITY_EVENT); Write(msg, eventsToSync, out sentEvents, client); @@ -353,7 +351,6 @@ namespace Barotrauma.Networking (entityEvent as ServerEntityEvent).Sent = true; client.EntityEventLastSent[entityEvent.ID] = NetTime.Now; } - sentEvents = eventsToSync; } /// diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index 984bab42f..2bdd86696 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -806,7 +806,6 @@ namespace Barotrauma if (closestBody.UserData is Structure wall && wall.Submarine != null) { int sectionIndex = wall.FindSectionIndex(ConvertUnits.ToDisplayUnits(Submarine.LastPickedPosition)); - int passableHoleCount = GetMinimumPassableHoleCount(); float sectionDamage = wall.SectionDamage(sectionIndex); for (int i = sectionIndex - 2; i <= sectionIndex + 2; i++) @@ -1127,7 +1126,7 @@ namespace Barotrauma valueModifier = isOutdoor ? 1 : 0; valueModifier *= isOpen ? 5 : 1; } - for (int i = 0; i < s.Sections.Length; i++) + else { valueModifier = isOutdoor ? 0 : 1; valueModifier *= isOpen ? 0 : 1; diff --git a/Barotrauma/BarotraumaShared/Source/Events/Missions/Mission.cs b/Barotrauma/BarotraumaShared/Source/Events/Missions/Mission.cs index ec5391666..d82b66631 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/Missions/Mission.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/Missions/Mission.cs @@ -103,12 +103,6 @@ namespace Barotrauma if (missionType == MissionType.Random) { allowedMissions.AddRange(MissionPrefab.List); -#if SERVER - if (GameMain.Server != null) - { - allowedMissions.RemoveAll(mission => !GameMain.Server.ServerSettings.AllowedRandomMissionTypes.Contains(mission.type)); - } -#endif } else if (missionType == MissionType.None) { @@ -125,8 +119,8 @@ namespace Barotrauma allowedMissions.RemoveAll(m => !m.IsAllowed(locations[0], locations[1])); } - float probabilitySum = allowedMissions.Sum(m => m.Commonness); - float randomNumber = (float)rand.NextDouble() * probabilitySum; + int probabilitySum = allowedMissions.Sum(m => m.Commonness); + int randomNumber = rand.NextInt32() % probabilitySum; foreach (MissionPrefab missionPrefab in allowedMissions) { if (randomNumber <= missionPrefab.Commonness) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Item.cs b/Barotrauma/BarotraumaShared/Source/Items/Item.cs index 0403cef91..32cb6f3be 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Item.cs @@ -1286,11 +1286,7 @@ namespace Barotrauma LastSentSignalRecipients.Clear(); if (connections == null) return; - public List GetConnectedComponentsRecursive(Connection c) where T : ItemComponent - { - List connectedComponents = new List(); - List alreadySearched = new List() { this }; - GetConnectedComponentsRecursive(c, alreadySearched, connectedComponents); + stepsTaken++; if (!connections.TryGetValue(connectionName, out Connection c)) return; diff --git a/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs b/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs index f507b0796..e397d485f 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Map/Location.cs @@ -33,7 +33,7 @@ namespace Barotrauma get { CheckMissionCompleted(); - + for (int i = availableMissions.Count; i < Connections.Count * 2; i++) { int seed = (ToolBox.StringToInt(BaseName) + MissionsCompleted * 10 + i) % int.MaxValue; @@ -47,7 +47,7 @@ namespace Barotrauma if (availableMissions.Any(m => m.Prefab == mission.Prefab)) { continue; } if (GameSettings.VerboseLogging && mission != null) { - DebugConsole.NewMessage("Generated a new mission for a location connection (seed: " + seed.ToString("X") + ", type: " + mission.Name + ")", Color.White); + DebugConsole.NewMessage("Generated a new mission for a location (location: " + Name + ", seed: " + seed.ToString("X") + ", missions completed: " + MissionsCompleted + ", type: " + mission.Name + ")", Color.White); } availableMissions.Add(mission); } @@ -100,7 +100,16 @@ namespace Barotrauma public void ChangeType(LocationType newType) { - if (newType == Type) return; + if (newType == Type) { return; } + + //clear missions from this and adjacent locations (they may be invalid now) + availableMissions.Clear(); + foreach (LocationConnection connection in Connections) + { + connection.OtherLocation(this)?.availableMissions.Clear(); + } + + DebugConsole.Log("Location " + baseName + " changed it's type from " + Type + " to " + newType); Type = newType; Name = Type.NameFormats[nameFormatIndex % Type.NameFormats.Count].Replace("[name]", baseName); @@ -112,6 +121,7 @@ namespace Barotrauma { if (mission.Completed) { + DebugConsole.Log("Mission \"" + mission.Name + "\" completed in \"" + Name + "\"."); MissionsCompleted++; } }