- Fixed clients using character directories to count the number of disallowed monsters, which made it possible for them to disallow incorrect monsters.

- Fixed MonsterEvent checking if the name of the character directory contains the name of the disallowed character directory, which could for example cause them to disallow "someMonsterAlt" if "someMonster" is disallowed.
This commit is contained in:
Joonas Rikkonen
2018-02-26 16:53:22 +02:00
parent 7f740c2f67
commit 1c68d5a4d7
2 changed files with 11 additions and 5 deletions

View File

@@ -701,15 +701,16 @@ namespace Barotrauma.Networking
//monster spawn settings
if (monsterEnabled == null)
{
List<string> monsterNames1 = Directory.GetDirectories("Content/Characters").ToList();
List<string> 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<string, bool>();
foreach (string s in monsterNames1)
{
monsterEnabled.Add(s, true);
if (!monsterEnabled.ContainsKey(s)) monsterEnabled.Add(s, true);
}
}

View File

@@ -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<string> 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);
}
}
}