Build 0.20.0.0
This commit is contained in:
@@ -70,7 +70,7 @@ namespace Barotrauma
|
||||
msg.WriteByte((byte)Job.Variant);
|
||||
foreach (SkillPrefab skillPrefab in Job.Prefab.Skills.OrderBy(s => s.Identifier))
|
||||
{
|
||||
msg.WriteSingle(Job.GetSkill(skillPrefab.Identifier).Level);
|
||||
msg.WriteSingle(Job.GetSkill(skillPrefab.Identifier)?.Level ?? 0.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -219,9 +219,9 @@ namespace Barotrauma
|
||||
else if (NetIdUtils.Difference(networkUpdateID, LastNetworkUpdateID) > 500)
|
||||
{
|
||||
#if DEBUG || UNSTABLE
|
||||
DebugConsole.AddWarning($"Large disrepancy between a client character's network update ID server-side and client-side (client: {networkUpdateID}, server: {LastNetworkUpdateID}). Resetting the ID.");
|
||||
DebugConsole.AddWarning($"Large discrepancy between a client character's network update ID server-side and client-side (client: {networkUpdateID}, server: {LastNetworkUpdateID}). Resetting the ID.");
|
||||
#endif
|
||||
LastNetworkUpdateID = networkUpdateID;
|
||||
LastNetworkUpdateID = LastProcessedID = networkUpdateID;
|
||||
}
|
||||
if (memInput.Count > 60)
|
||||
{
|
||||
@@ -549,7 +549,7 @@ namespace Barotrauma
|
||||
msg.WriteByte((byte)statType);
|
||||
foreach (var savedStatValue in Info.SavedStatValues[statType])
|
||||
{
|
||||
msg.WriteString(savedStatValue.StatIdentifier);
|
||||
msg.WriteIdentifier(savedStatValue.StatIdentifier);
|
||||
msg.WriteSingle(savedStatValue.StatValue);
|
||||
msg.WriteBoolean(savedStatValue.RemoveOnDeath);
|
||||
}
|
||||
|
||||
@@ -1408,6 +1408,21 @@ namespace Barotrauma
|
||||
GameMain.Server.PrintSenderTransters();
|
||||
}));
|
||||
|
||||
|
||||
AssignOnExecute("resetcharacternetstate", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) { return; }
|
||||
|
||||
if (args.Length < 1)
|
||||
{
|
||||
ThrowError("Invalid parameters. The command should be formatted as \"resetcharacternetstate [character]\". If the names consist of multiple words, you should surround them with quotation marks.");
|
||||
return;
|
||||
}
|
||||
|
||||
var character = FindMatchingCharacter(args.Skip(1).ToArray(), false);
|
||||
character?.ResetNetState();
|
||||
});
|
||||
|
||||
commands.Add(new Command("eventdata", "", (string[] args) =>
|
||||
{
|
||||
if (args.Length == 0) { return; }
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Barotrauma
|
||||
XDocument doc = XMLExtensions.TryLoadXml(ServerSettings.SettingsFile);
|
||||
if (doc?.Root == null)
|
||||
{
|
||||
DebugConsole.ThrowError("File \"" + ServerSettings.SettingsFile + "\" not found. Starting the server with default settings.");
|
||||
DebugConsole.AddWarning("File \"" + ServerSettings.SettingsFile + "\" not found. Starting the server with default settings.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -16,16 +16,15 @@ namespace Barotrauma
|
||||
/// <summary>
|
||||
/// There is a client-side implementation of the method in <see cref="CampaignMode"/>
|
||||
/// </summary>
|
||||
public bool AllowedToManageCampaign(Client client, ClientPermissions permissions)
|
||||
public static bool AllowedToManageCampaign(Client client, ClientPermissions permissions)
|
||||
{
|
||||
//allow managing the campaign if the client has permissions, is the owner, or the only client in the server,
|
||||
//or if no-one has management permissions
|
||||
return
|
||||
client.HasPermission(permissions) ||
|
||||
client.HasPermission(ClientPermissions.ManageCampaign) ||
|
||||
GameMain.Server.ConnectedClients.Count == 1 ||
|
||||
IsOwner(client) ||
|
||||
GameMain.Server.ConnectedClients.None(c => c.InGame && (IsOwner(c) || c.HasPermission(permissions)));
|
||||
AnyOneAllowedToManageCampaign(permissions);
|
||||
}
|
||||
|
||||
public bool AllowedToManageWallets(Client client)
|
||||
|
||||
+3
-2
@@ -347,6 +347,8 @@ namespace Barotrauma
|
||||
(GameMain.GameSession?.GameMode as MultiPlayerCampaign)?.SaveExperiencePoints(c);
|
||||
}
|
||||
}
|
||||
// Event history must be registered before ending the round or it will be cleared
|
||||
GameMain.GameSession.EventManager.RegisterEventHistory();
|
||||
}
|
||||
|
||||
GameMain.GameSession.EndRound("", traitorResults, transitionType);
|
||||
@@ -360,7 +362,6 @@ namespace Barotrauma
|
||||
LeaveUnconnectedSubs(leavingSub);
|
||||
NextLevel = newLevel;
|
||||
GameMain.GameSession.SubmarineInfo = new SubmarineInfo(GameMain.GameSession.Submarine);
|
||||
GameMain.GameSession.EventManager.RegisterEventHistory();
|
||||
SaveUtil.SaveGame(GameMain.GameSession.SavePath);
|
||||
}
|
||||
else
|
||||
@@ -1019,7 +1020,7 @@ namespace Barotrauma
|
||||
UpgradeManager.PurchaseUpgrade(prefab, category, client: sender);
|
||||
|
||||
// unstable logging
|
||||
int price = prefab.Price.GetBuyprice(UpgradeManager.GetUpgradeLevel(prefab, category), Map?.CurrentLocation);
|
||||
int price = prefab.Price.GetBuyPrice(UpgradeManager.GetUpgradeLevel(prefab, category), Map?.CurrentLocation);
|
||||
int level = UpgradeManager.GetUpgradeLevel(prefab, category);
|
||||
GameServer.Log($"SERVER: Purchased level {level} {category.Identifier}.{prefab.Identifier} for {price}", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
var allowOutpostAutoDocking = (AllowOutpostAutoDocking)msg.ReadByte();
|
||||
if (outpostAutoDockingPromptShown &&
|
||||
(GameMain.GameSession?.Campaign?.AllowedToManageCampaign(c, ClientPermissions.ManageMap) ?? false))
|
||||
CampaignMode.AllowedToManageCampaign(c, ClientPermissions.ManageMap))
|
||||
{
|
||||
this.allowOutpostAutoDocking = allowOutpostAutoDocking;
|
||||
}
|
||||
|
||||
@@ -106,6 +106,14 @@ namespace Barotrauma
|
||||
$"Failed to write a ChangeProperty network event for the item \"{Name}\" ({e.Message})");
|
||||
}
|
||||
break;
|
||||
case SetItemStatEventData setItemStatEventData:
|
||||
msg.WriteByte((byte)setItemStatEventData.Stats.Count);
|
||||
foreach (var (key, value) in setItemStatEventData.Stats)
|
||||
{
|
||||
msg.WriteNetSerializableStruct(key);
|
||||
msg.WriteSingle(value);
|
||||
}
|
||||
break;
|
||||
case UpgradeEventData upgradeEventData:
|
||||
var upgrade = upgradeEventData.Upgrade;
|
||||
var upgradeTargets = upgrade.TargetComponents;
|
||||
|
||||
@@ -152,7 +152,9 @@ namespace Barotrauma.Networking
|
||||
public bool IsBanned(AccountId accountId, out string reason)
|
||||
{
|
||||
RemoveExpired();
|
||||
var bannedPlayer = bannedPlayers.Find(bp => bp.AddressOrAccountId.TryGet(out AccountId id) && accountId.Equals(id));
|
||||
var bannedPlayer =
|
||||
bannedPlayers.Find(bp => bp.AddressOrAccountId.TryGet(out AccountId id) && accountId.Equals(id)) ??
|
||||
bannedPlayers.Find(bp => bp.AddressOrAccountId.TryGet(out Address adr) && adr is SteamP2PAddress steamAdr && steamAdr.SteamId.Equals(accountId));
|
||||
reason = bannedPlayer?.Reason ?? string.Empty;
|
||||
return bannedPlayer != null;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Barotrauma.Networking
|
||||
public float ChatSpamTimer;
|
||||
public int ChatSpamCount;
|
||||
|
||||
public string RejectedName;
|
||||
|
||||
public int RoundsSincePlayedAsTraitor;
|
||||
|
||||
public float KickAFKTimer;
|
||||
@@ -69,6 +71,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
public DateTime JoinTime;
|
||||
|
||||
public static readonly TimeSpan NameChangeCoolDown = new TimeSpan(hours: 0, minutes: 0, seconds: 30);
|
||||
public DateTime LastNameChangeTime;
|
||||
|
||||
private CharacterInfo characterInfo;
|
||||
public CharacterInfo CharacterInfo
|
||||
{
|
||||
|
||||
@@ -486,9 +486,18 @@ namespace Barotrauma.Networking
|
||||
// -> something wen't wrong during startup, re-enable start button and reset AutoRestartTimer
|
||||
if (startGameCoroutine != null && !CoroutineManager.IsCoroutineRunning(startGameCoroutine))
|
||||
{
|
||||
if (ServerSettings.AutoRestart) ServerSettings.AutoRestartTimer = Math.Max(ServerSettings.AutoRestartInterval, 5.0f);
|
||||
//GameMain.NetLobbyScreen.StartButtonEnabled = true;
|
||||
if (ServerSettings.AutoRestart) { ServerSettings.AutoRestartTimer = Math.Max(ServerSettings.AutoRestartInterval, 5.0f); }
|
||||
|
||||
if (startGameCoroutine.Exception != null && OwnerConnection != null)
|
||||
{
|
||||
SendConsoleMessage(
|
||||
startGameCoroutine.Exception.Message + '\n' +
|
||||
(startGameCoroutine.Exception.StackTrace?.CleanupStackTrace() ?? "null"),
|
||||
connectedClients.Find(c => c.Connection == OwnerConnection),
|
||||
Color.Red);
|
||||
}
|
||||
|
||||
EndGame();
|
||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||
|
||||
startGameCoroutine = null;
|
||||
@@ -1377,9 +1386,9 @@ namespace Barotrauma.Networking
|
||||
bool end = inc.ReadBoolean();
|
||||
if (end)
|
||||
{
|
||||
if (mpCampaign == null ||
|
||||
mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageRound) ||
|
||||
mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign))
|
||||
if (mpCampaign == null ||
|
||||
CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageRound) ||
|
||||
CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign))
|
||||
{
|
||||
bool save = inc.ReadBoolean();
|
||||
if (GameStarted)
|
||||
@@ -1409,7 +1418,7 @@ namespace Barotrauma.Networking
|
||||
SendDirectChatMessage("Cannot continue the campaign from the previous save (round already running).", sender, ChatMessageType.Error);
|
||||
break;
|
||||
}
|
||||
else if (mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageMap))
|
||||
else if (CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageMap))
|
||||
{
|
||||
MultiPlayerCampaign.LoadCampaign(GameMain.GameSession.SavePath);
|
||||
}
|
||||
@@ -1420,7 +1429,7 @@ namespace Barotrauma.Networking
|
||||
Log("Client \"" + ClientLogName(sender) + "\" started the round.", ServerLog.MessageType.ServerMessage);
|
||||
StartGame();
|
||||
}
|
||||
else if (mpCampaign != null && (mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || mpCampaign.AllowedToManageCampaign(sender, ClientPermissions.ManageMap)))
|
||||
else if (mpCampaign != null && (CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageCampaign) || CampaignMode.AllowedToManageCampaign(sender, ClientPermissions.ManageMap)))
|
||||
{
|
||||
var availableTransition = mpCampaign.GetAvailableTransition(out _, out _);
|
||||
//don't force location if we've teleported
|
||||
@@ -1991,7 +2000,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
//and assume the message was received, so we don't have to keep resending
|
||||
//these large initial messages until the client acknowledges receiving them
|
||||
c.LastRecvLobbyUpdate++;
|
||||
c.LastRecvLobbyUpdate = GameMain.NetLobbyScreen.LastUpdateID;
|
||||
|
||||
}
|
||||
else
|
||||
@@ -2010,7 +2019,7 @@ namespace Barotrauma.Networking
|
||||
c.ChatMsgQueue.RemoveAll(cMsg => !NetIdUtils.IdMoreRecent(cMsg.NetStateID, c.LastRecvChatMsgID));
|
||||
for (int i = 0; i < c.ChatMsgQueue.Count && i < ChatMessage.MaxMessagesPerPacket; i++)
|
||||
{
|
||||
if (outmsg.LengthBytes + c.ChatMsgQueue[i].EstimateLengthBytesServer(c) > MsgConstants.MTU - 5)
|
||||
if (outmsg.LengthBytes + c.ChatMsgQueue[i].EstimateLengthBytesServer(c) > MsgConstants.MTU - 5 && i > 0)
|
||||
{
|
||||
//not enough room in this packet
|
||||
return;
|
||||
@@ -2589,26 +2598,24 @@ namespace Barotrauma.Networking
|
||||
|
||||
public void EndGame(CampaignMode.TransitionType transitionType = CampaignMode.TransitionType.None, bool wasSaved = false)
|
||||
{
|
||||
if (!GameStarted)
|
||||
if (GameStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
Log("Ending the round...\n" + Environment.StackTrace.CleanupStackTrace(), ServerLog.MessageType.ServerMessage);
|
||||
|
||||
if (GameSettings.CurrentConfig.VerboseLogging)
|
||||
{
|
||||
Log("Ending the round...\n" + Environment.StackTrace.CleanupStackTrace(), ServerLog.MessageType.ServerMessage);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Ending the round...", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log("Ending the round...", ServerLog.MessageType.ServerMessage);
|
||||
}
|
||||
}
|
||||
|
||||
string endMessage = TextManager.FormatServerMessage("RoundSummaryRoundHasEnded");
|
||||
var traitorResults = TraitorManager?.GetEndResults() ?? new List<TraitorMissionResult>();
|
||||
|
||||
List<Mission> missions = GameMain.GameSession.Missions.ToList();
|
||||
if (GameMain.GameSession.IsRunning)
|
||||
if (GameMain.GameSession is { IsRunning: true })
|
||||
{
|
||||
GameMain.GameSession.EndRound(endMessage, traitorResults);
|
||||
}
|
||||
@@ -2634,7 +2641,10 @@ namespace Barotrauma.Networking
|
||||
c.PositionUpdateLastSent.Clear();
|
||||
}
|
||||
|
||||
KarmaManager.OnRoundEnded();
|
||||
if (GameStarted)
|
||||
{
|
||||
KarmaManager.OnRoundEnded();
|
||||
}
|
||||
|
||||
RespawnManager = null;
|
||||
GameStarted = false;
|
||||
@@ -2703,9 +2713,24 @@ namespace Barotrauma.Networking
|
||||
CharacterTeamType newTeam = (CharacterTeamType)inc.ReadByte();
|
||||
|
||||
if (c == null || string.IsNullOrEmpty(newName) || !NetIdUtils.IdMoreRecent(nameId, c.NameId)) { return false; }
|
||||
|
||||
var timeSinceNameChange = DateTime.Now - c.LastNameChangeTime;
|
||||
if (timeSinceNameChange < Client.NameChangeCoolDown)
|
||||
{
|
||||
//only send once per second at most to prevent using this for spamming
|
||||
if (timeSinceNameChange.TotalSeconds > 1)
|
||||
{
|
||||
var coolDownRemaining = Client.NameChangeCoolDown - timeSinceNameChange;
|
||||
SendDirectChatMessage($"ServerMessage.NameChangeFailedCooldownActive~[seconds]={(int)coolDownRemaining.TotalSeconds}", c);
|
||||
}
|
||||
c.NameId = nameId;
|
||||
c.RejectedName = newName;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!newJob.IsEmpty)
|
||||
{
|
||||
if (!JobPrefab.Prefabs.TryGet(newJob, out JobPrefab newJobPrefab) || newJobPrefab.HiddenJob)
|
||||
if (!JobPrefab.Prefabs.TryGet(newJob, out JobPrefab newJobPrefab) || newJobPrefab.HiddenJob)
|
||||
{
|
||||
newJob = Identifier.Empty;
|
||||
}
|
||||
@@ -2721,26 +2746,25 @@ namespace Barotrauma.Networking
|
||||
public bool TryChangeClientName(Client c, string newName)
|
||||
{
|
||||
newName = Client.SanitizeName(newName);
|
||||
//update client list even if the name cannot be changed to the one sent by the client,
|
||||
//so the client will be informed what their actual name is
|
||||
LastClientListUpdateID++;
|
||||
|
||||
if (newName == c.Name || string.IsNullOrEmpty(newName)) { return false; }
|
||||
|
||||
if (IsNameValid(c, newName))
|
||||
if (newName != c.Name && !string.IsNullOrEmpty(newName) && IsNameValid(c, newName))
|
||||
{
|
||||
c.LastNameChangeTime = DateTime.Now;
|
||||
string oldName = c.Name;
|
||||
c.Name = newName;
|
||||
c.RejectedName = string.Empty;
|
||||
SendChatMessage($"ServerMessage.NameChangeSuccessful~[oldname]={oldName}~[newname]={newName}", ChatMessageType.Server);
|
||||
LastClientListUpdateID++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//update client list even if the name cannot be changed to the one sent by the client,
|
||||
//so the client will be informed what their actual name is
|
||||
LastClientListUpdateID++;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool IsNameValid(Client c, string newName)
|
||||
{
|
||||
newName = Client.SanitizeName(newName);
|
||||
|
||||
+2
-1
@@ -168,9 +168,10 @@ namespace Barotrauma.Networking
|
||||
if (!bufferedEvent.Character.IsIncapacitated &&
|
||||
NetIdUtils.IdMoreRecent(bufferedEvent.CharacterStateID, bufferedEvent.Character.LastProcessedID))
|
||||
{
|
||||
DebugConsole.Log($"Delaying reading entity event sent by a client until the character state has been processed. Event's character state: {bufferedEvent.CharacterStateID}, last processed character state: {bufferedEvent.Character.LastProcessedID}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
ReadEvent(bufferedEvent.Data, bufferedEvent.TargetEntity, bufferedEvent.Sender);
|
||||
|
||||
+3
-1
@@ -250,7 +250,9 @@ namespace Barotrauma.Networking
|
||||
structToSend = new ServerPeerContentPackageOrderPacket
|
||||
{
|
||||
ServerName = GameMain.Server.ServerName,
|
||||
ContentPackages = ContentPackageManager.EnabledPackages.All.Where(cp => cp.HasMultiplayerSyncedContent || cp.Files.All(f => f is SubmarineFile))
|
||||
ContentPackages = ContentPackageManager.EnabledPackages.All
|
||||
.Where(cp => cp.Files.Any())
|
||||
.Where(cp => cp.HasMultiplayerSyncedContent || cp.Files.All(f => f is SubmarineFile))
|
||||
.Select(contentPackage => new ServerContentPackage(contentPackage, timeNow))
|
||||
.ToImmutableArray()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user