diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs index 3b9816f0a..6ea6cfbad 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameClient.cs @@ -701,15 +701,16 @@ namespace Barotrauma.Networking //monster spawn settings if (monsterEnabled == null) { - List monsterNames1 = Directory.GetDirectories("Content/Characters").ToList(); + List monsterNames1 = GameMain.Config.SelectedContentPackage.GetFilesOfType(ContentType.Character); for (int i = 0; i < monsterNames1.Count; i++) { - monsterNames1[i] = monsterNames1[i].Replace("Content/Characters", "").Replace("/", "").Replace("\\", ""); + monsterNames1[i] = Path.GetFileName(Path.GetDirectoryName(monsterNames1[i])); } + monsterEnabled = new Dictionary(); foreach (string s in monsterNames1) { - monsterEnabled.Add(s, true); + if (!monsterEnabled.ContainsKey(s)) monsterEnabled.Add(s, true); } } diff --git a/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs b/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs index 2fd6a7078..217512107 100644 --- a/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs +++ b/Barotrauma/BarotraumaShared/Source/Events/MonsterEvent.cs @@ -1,6 +1,7 @@ using Microsoft.Xna.Framework; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Xml.Linq; @@ -61,7 +62,8 @@ namespace Barotrauma if (GameMain.NetworkMember != null) { List monsterNames = GameMain.NetworkMember.monsterEnabled.Keys.ToList(); - string tryKey = monsterNames.Find(s => characterFile.ToLower().Contains(s.ToLower())); + string characterName = Path.GetFileName(Path.GetDirectoryName(characterFile)).ToLower(); + string tryKey = monsterNames.Find(s => characterName == s.ToLower()); if (!string.IsNullOrWhiteSpace(tryKey)) { if (!GameMain.NetworkMember.monsterEnabled[tryKey]) disallowed = true; //spawn was disallowed by host @@ -76,7 +78,10 @@ namespace Barotrauma monsters = SpawnMonsters(Rand.Range(minAmount, maxAmount, Rand.RandSync.Server), false); if (GameSettings.VerboseLogging) { - DebugConsole.NewMessage("Initialized MonsterEvent (" + monsters[0]?.SpeciesName + " x" + monsters.Length + ")", Color.White); + if (monsters != null) + { + DebugConsole.NewMessage("Initialized MonsterEvent (" + monsters[0]?.SpeciesName + " x" + monsters.Length + ")", Color.White); + } } }