v0.14.6.0

This commit is contained in:
Joonas Rikkonen
2021-06-17 17:54:52 +03:00
parent 3f324b14e8
commit c27e2ea5ab
348 changed files with 13156 additions and 4266 deletions
@@ -1,5 +1,7 @@
using Barotrauma.Networking;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma
{
@@ -15,9 +17,45 @@ namespace Barotrauma
private static readonly Dictionary<Client, ConversationAction> lastActiveAction = new Dictionary<Client, ConversationAction>();
private readonly HashSet<Client> targetClients = new HashSet<Client>();
private readonly Dictionary<Client, DateTime> ignoredClients = new Dictionary<Client, DateTime>();
public IEnumerable<Client> TargetClients
{
get { return targetClients; }
get
{
UpdateIgnoredClients();
return targetClients.Where(c => !ignoredClients.ContainsKey(c));
}
}
private void UpdateIgnoredClients()
{
if (ignoredClients.Any())
{
HashSet<Client> clientsToRemove = null;
foreach (var k in ignoredClients.Keys)
{
if (ignoredClients[k] < DateTime.Now)
{
clientsToRemove ??= new HashSet<Client>();
clientsToRemove.Add(k);
}
}
if (!(clientsToRemove is null))
{
foreach (var k in clientsToRemove)
{
ignoredClients.Remove(k);
}
}
}
}
public void IgnoreClient(Client c, float seconds)
{
if (!ignoredClients.ContainsKey(c)) { ignoredClients.Add(c, DateTime.Now); }
ignoredClients[c] = DateTime.Now + TimeSpan.FromSeconds(seconds);
Reset();
}
private bool IsBlockedByAnotherConversation(IEnumerable<Entity> targets)
@@ -28,7 +28,14 @@ namespace Barotrauma
continue;
}
convAction.SelectedOption = selectedOption;
if (selectedOption == byte.MaxValue)
{
convAction.IgnoreClient(sender, 3f);
}
else
{
convAction.SelectedOption = selectedOption;
}
return;
}
}
@@ -1,16 +1,20 @@
using Barotrauma.Networking;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma
{
partial class AbandonedOutpostMission : Mission
{
private readonly List<Item> spawnedItems = new List<Item>();
public override void ServerWriteInitial(IWriteMessage msg, Client c)
{
if (characters.Count == 0)
msg.Write((ushort)spawnedItems.Count);
foreach (Item item in spawnedItems)
{
throw new InvalidOperationException("Server attempted to write AbandonedOutpostMission data when no characters had been spawned.");
item.WriteSpawnData(msg, item.ID, Entity.NullEntityID, 0);
}
msg.Write((byte)characters.Count);
@@ -22,7 +26,7 @@ namespace Barotrauma
msg.Write((ushort)characterItems[character].Count());
foreach (Item item in characterItems[character])
{
item.WriteSpawnData(msg, item.ID, item.ParentInventory.Owner?.ID ?? Entity.NullEntityID, 0);
item.WriteSpawnData(msg, item.ID, item.ParentInventory?.Owner?.ID ?? Entity.NullEntityID, 0);
}
}
}
@@ -21,7 +21,7 @@ namespace Barotrauma
}
}
public override void Update(float deltaTime)
protected override void UpdateMissionSpecific(float deltaTime)
{
if (!initialized)
{
@@ -0,0 +1,30 @@
using Barotrauma.Networking;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma
{
partial class EscortMission : Mission
{
public override void ServerWriteInitial(IWriteMessage msg, Client c)
{
if (characters.Count == 0)
{
throw new InvalidOperationException("Server attempted to write escort mission data when no characters had been spawned.");
}
msg.Write((byte)characters.Count);
foreach (Character character in characters)
{
character.WriteSpawnData(msg, character.ID, restrictMessageSize: false);
msg.Write(terroristCharacters.Contains(character));
msg.Write((ushort)characterItems[character].Count());
foreach (Item item in characterItems[character])
{
item.WriteSpawnData(msg, item.ID, item.ParentInventory?.Owner?.ID ?? Entity.NullEntityID, 0);
}
}
}
}
}
@@ -6,10 +6,12 @@ namespace Barotrauma
{
partial void ShowMessageProjSpecific(int missionState)
{
if (missionState >= Headers.Count && missionState >= Messages.Count) return;
int messageIndex = missionState - 1;
if (messageIndex >= Headers.Count && messageIndex >= Messages.Count) { return; }
if (messageIndex < 0) { return; }
string header = missionState < Headers.Count ? Headers[missionState] : "";
string message = missionState < Messages.Count ? Messages[missionState] : "";
string header = messageIndex < Headers.Count ? Headers[messageIndex] : "";
string message = messageIndex < Messages.Count ? Messages[messageIndex] : "";
GameServer.Log(TextManager.Get("MissionInfo") + ": " + header + " - " + message, ServerLog.MessageType.ServerMessage);
}
@@ -1,19 +0,0 @@
using Barotrauma.Networking;
using System.Collections.Generic;
namespace Barotrauma
{
partial class OutpostDestroyMission : AbandonedOutpostMission
{
private readonly List<Item> spawnedItems = new List<Item>();
public override void ServerWriteInitial(IWriteMessage msg, Client c)
{
base.ServerWriteInitial(msg, c);
msg.Write((ushort)spawnedItems.Count);
foreach (Item item in spawnedItems)
{
item.WriteSpawnData(msg, item.ID, Entity.NullEntityID, 0);
}
}
}
}
@@ -0,0 +1,30 @@
using Barotrauma.Networking;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Barotrauma
{
partial class PirateMission : Mission
{
public override void ServerWriteInitial(IWriteMessage msg, Client c)
{
// duplicate code from escortmission, should possibly be combined, though additional loot items might be added so maybe not
if (characters.Count == 0)
{
throw new InvalidOperationException("Server attempted to write escort mission data when no characters had been spawned.");
}
msg.Write((byte)characters.Count);
foreach (Character character in characters)
{
character.WriteSpawnData(msg, character.ID, restrictMessageSize: false);
msg.Write((ushort)characterItems[character].Count());
foreach (Item item in characterItems[character])
{
item.WriteSpawnData(msg, item.ID, item.ParentInventory?.Owner?.ID ?? Entity.NullEntityID, 0);
}
}
}
}
}