Build 0.21.1.0

This commit is contained in:
Markus Isberg
2023-01-13 18:10:35 +02:00
parent 2f7205fb4b
commit 697ec52120
155 changed files with 2423 additions and 1237 deletions
@@ -197,7 +197,7 @@ namespace Barotrauma.Networking
public T GetVote<T>(VoteType voteType)
{
return (votes[(int)voteType] is T) ? (T)votes[(int)voteType] : default(T);
return (votes[(int)voteType] is T t) ? t : default;
}
public void SetVote(VoteType voteType, object value)
@@ -34,7 +34,7 @@
interface IServerPositionSync : IServerSerializable
{
#if SERVER
void ServerWritePosition(IWriteMessage msg, Client c);
void ServerWritePosition(ReadWriteMessage tempBuffer, Client c);
#endif
#if CLIENT
void ClientReadPosition(IReadMessage msg, float sendingTime);
@@ -99,6 +99,19 @@ namespace Barotrauma.Networking
EntityEventInitial
}
[NetworkSerialize]
readonly record struct EntityPositionHeader(
bool IsItem,
UInt32 PrefabUintIdentifier,
UInt16 EntityId) : INetSerializableStruct
{
public static EntityPositionHeader FromEntity(Entity entity)
=> new (
IsItem: entity is Item,
PrefabUintIdentifier: entity is MapEntity me ? me.Prefab.UintIdentifier : 0,
EntityId: entity.ID);
}
enum TraitorMessageType
{
Server,
@@ -171,6 +171,8 @@ namespace Barotrauma.Networking
public bool ShouldCreateAnalyticsEvent
=> DisconnectReason is not (
DisconnectReason.Disconnected
or DisconnectReason.ServerShutdown
or DisconnectReason.ServerFull
or DisconnectReason.Banned
or DisconnectReason.Kicked
or DisconnectReason.TooManyFailedLogins
@@ -1093,7 +1093,7 @@ namespace Barotrauma.Networking
for (int i = 0; i < count; i++)
{
int index = msg.ReadUInt16();
if (index < 0 || index >= subList.Count) { continue; }
if (index >= subList.Count) { continue; }
string submarineName = subList[index].Name;
HiddenSubs.Add(submarineName);
}
@@ -8,7 +8,7 @@ namespace Barotrauma
{
public enum VoteState { None = 0, Started = 1, Running = 2, Passed = 3, Failed = 4 };
private IReadOnlyDictionary<T, int> GetVoteCounts<T>(VoteType voteType, IEnumerable<Client> voters)
private static IReadOnlyDictionary<T, int> GetVoteCounts<T>(VoteType voteType, IEnumerable<Client> voters)
{
Dictionary<T, int> voteList = new Dictionary<T, int>();
@@ -29,7 +29,7 @@ namespace Barotrauma
return voteList;
}
public T HighestVoted<T>(VoteType voteType, List<Client> voters)
public static T HighestVoted<T>(VoteType voteType, IEnumerable<Client> voters)
{
if (voteType == VoteType.Sub && !GameMain.NetworkMember.ServerSettings.AllowSubVoting) { return default; }
if (voteType == VoteType.Mode && !GameMain.NetworkMember.ServerSettings.AllowModeVoting) { return default; }