Unstable v0.19.3.0

This commit is contained in:
Juan Pablo Arce
2022-09-02 15:10:56 -03:00
parent 28789616bd
commit 3f2c843247
336 changed files with 7152 additions and 7739 deletions
@@ -254,7 +254,7 @@ namespace Barotrauma
break;
case VoteType.Kick:
byte kickedClientID = inc.ReadByte();
if ((DateTime.Now - sender.JoinTime).TotalSeconds > GameMain.Server.ServerSettings.DisallowKickVoteTime)
if ((DateTime.Now - sender.JoinTime).TotalSeconds < GameMain.Server.ServerSettings.DisallowKickVoteTime)
{
GameMain.Server.SendDirectChatMessage($"ServerMessage.kickvotedisallowed", sender);
}
@@ -328,66 +328,66 @@ namespace Barotrauma
{
if (GameMain.Server == null) { return; }
msg.Write(GameMain.Server.ServerSettings.AllowSubVoting);
msg.WriteBoolean(GameMain.Server.ServerSettings.AllowSubVoting);
if (GameMain.Server.ServerSettings.AllowSubVoting)
{
IReadOnlyDictionary<SubmarineInfo, int> voteList = GetVoteCounts<SubmarineInfo>(VoteType.Sub, GameMain.Server.ConnectedClients);
msg.Write((byte)voteList.Count);
msg.WriteByte((byte)voteList.Count);
foreach (KeyValuePair<SubmarineInfo, int> vote in voteList)
{
msg.Write((byte)vote.Value);
msg.Write(vote.Key.Name);
msg.WriteByte((byte)vote.Value);
msg.WriteString(vote.Key.Name);
}
}
msg.Write(GameMain.Server.ServerSettings.AllowModeVoting);
msg.WriteBoolean(GameMain.Server.ServerSettings.AllowModeVoting);
if (GameMain.Server.ServerSettings.AllowModeVoting)
{
IReadOnlyDictionary<GameModePreset, int> voteList = GetVoteCounts<GameModePreset>(VoteType.Mode, GameMain.Server.ConnectedClients);
msg.Write((byte)voteList.Count);
msg.WriteByte((byte)voteList.Count);
foreach (KeyValuePair<GameModePreset, int> vote in voteList)
{
msg.Write((byte)vote.Value);
msg.Write(vote.Key.Identifier);
msg.WriteByte((byte)vote.Value);
msg.WriteIdentifier(vote.Key.Identifier);
}
}
msg.Write(GameMain.Server.ServerSettings.AllowEndVoting);
msg.WriteBoolean(GameMain.Server.ServerSettings.AllowEndVoting);
if (GameMain.Server.ServerSettings.AllowEndVoting)
{
msg.Write((byte)GameMain.Server.ConnectedClients.Count(c => c.HasSpawned && c.GetVote<bool>(VoteType.EndRound)));
msg.Write((byte)GameMain.Server.ConnectedClients.Count(c => c.HasSpawned));
msg.WriteByte((byte)GameMain.Server.ConnectedClients.Count(c => c.HasSpawned && c.GetVote<bool>(VoteType.EndRound)));
msg.WriteByte((byte)GameMain.Server.ConnectedClients.Count(c => c.HasSpawned));
}
msg.Write(GameMain.Server.ServerSettings.AllowVoteKick);
msg.WriteBoolean(GameMain.Server.ServerSettings.AllowVoteKick);
msg.Write((byte)(ActiveVote?.State ?? VoteState.None));
msg.WriteByte((byte)(ActiveVote?.State ?? VoteState.None));
if (ActiveVote != null)
{
msg.Write((byte)ActiveVote.VoteType);
msg.WriteByte((byte)ActiveVote.VoteType);
if (ActiveVote.State != VoteState.None && ActiveVote.VoteType != VoteType.Unknown)
{
var eligibleClients = GameMain.Server.ConnectedClients.Where(c => c.InGame && c != ActiveVote.VoteStarter);
var yesClients = eligibleClients.Where(c => c.GetVote<int>(ActiveVote.VoteType) == 2);
msg.Write((byte)yesClients.Count());
msg.WriteByte((byte)yesClients.Count());
foreach (Client c in yesClients)
{
msg.Write(c.SessionId);
msg.WriteByte(c.SessionId);
}
var noClients = eligibleClients.Where(c => c.GetVote<int>(ActiveVote.VoteType) == 1);
msg.Write((byte)noClients.Count());
msg.WriteByte((byte)noClients.Count());
foreach (Client c in noClients)
{
msg.Write(c.SessionId);
msg.WriteByte(c.SessionId);
}
msg.Write((byte)eligibleClients.Count());
msg.WriteByte((byte)eligibleClients.Count());
switch (ActiveVote.State)
{
case VoteState.Started:
msg.Write(ActiveVote.VoteStarter.SessionId);
msg.Write((byte)GameMain.Server.ServerSettings.VoteTimeout);
msg.WriteByte(ActiveVote.VoteStarter.SessionId);
msg.WriteByte((byte)GameMain.Server.ServerSettings.VoteTimeout);
switch (ActiveVote.VoteType)
{
@@ -395,14 +395,14 @@ namespace Barotrauma
case VoteType.PurchaseAndSwitchSub:
case VoteType.SwitchSub:
SubmarineVote vote = ActiveVote as SubmarineVote;
msg.Write(vote.Sub.Name);
msg.Write(vote.TransferItems);
msg.WriteString(vote.Sub.Name);
msg.WriteBoolean(vote.TransferItems);
break;
case VoteType.TransferMoney:
var transferVote = (ActiveVote as TransferVote);
msg.Write(transferVote.From?.SessionId ?? 0);
msg.Write(transferVote.To?.SessionId ?? 0);
msg.Write(transferVote.TransferAmount);
msg.WriteByte(transferVote.From?.SessionId ?? 0);
msg.WriteByte(transferVote.To?.SessionId ?? 0);
msg.WriteInt32(transferVote.TransferAmount);
break;
}
@@ -412,16 +412,16 @@ namespace Barotrauma
break;
case VoteState.Passed:
case VoteState.Failed:
msg.Write(ActiveVote.State == VoteState.Passed);
msg.WriteBoolean(ActiveVote.State == VoteState.Passed);
switch (ActiveVote.VoteType)
{
case VoteType.PurchaseSub:
case VoteType.PurchaseAndSwitchSub:
case VoteType.SwitchSub:
var subVote = ActiveVote as SubmarineVote;
msg.Write(subVote.Sub.Name);
msg.Write(subVote.TransferItems);
msg.Write((short)subVote.DeliveryFee);
msg.WriteString(subVote.Sub.Name);
msg.WriteBoolean(subVote.TransferItems);
msg.WriteInt16((short)subVote.DeliveryFee);
break;
}
break;
@@ -430,10 +430,10 @@ namespace Barotrauma
}
var readyClients = GameMain.Server.ConnectedClients.Where(c => c.GetVote<bool>(VoteType.StartRound));
msg.Write((byte)readyClients.Count());
msg.WriteByte((byte)readyClients.Count());
foreach (Client c in readyClients)
{
msg.Write(c.SessionId);
msg.WriteByte(c.SessionId);
}
msg.WritePadBits();