v1.5.7.0 (Summer Update)

This commit is contained in:
Regalis11
2024-06-18 16:49:51 +03:00
parent 4a63dacbce
commit 230d1b6e78
263 changed files with 7792 additions and 2845 deletions
@@ -1,4 +1,5 @@
using System;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,6 +9,8 @@ namespace Barotrauma.Networking
{
public bool VoiceEnabled = true;
public VoipServerDecoder VoipServerDecoder;
public UInt16 LastRecvClientListUpdate
= NetIdUtils.GetIdOlderThan(GameMain.Server.LastClientListUpdateID);
@@ -15,7 +18,7 @@ namespace Barotrauma.Networking
= NetIdUtils.GetIdOlderThan(GameMain.Server.ServerSettings.LastUpdateIdForFlag[ServerSettings.NetFlags.Properties]);
public UInt16 LastRecvServerSettingsUpdate
= NetIdUtils.GetIdOlderThan(GameMain.Server.ServerSettings.LastUpdateIdForFlag[ServerSettings.NetFlags.Properties]);
public UInt16 LastRecvLobbyUpdate
= NetIdUtils.GetIdOlderThan(GameMain.NetLobbyScreen.LastUpdateID);
@@ -129,6 +132,7 @@ namespace Barotrauma.Networking
JobPreferences = new List<JobVariant>();
VoipQueue = new VoipQueue(SessionId, true, true);
VoipServerDecoder = new VoipServerDecoder(VoipQueue, this);
GameMain.Server.VoipServer.RegisterQueue(VoipQueue);
//initialize to infinity, gets set to a proper value when initializing midround syncing
@@ -277,5 +281,47 @@ namespace Barotrauma.Networking
{
return Permissions.HasFlag(permission);
}
public bool TryTakeOverBot(Character botCharacter)
{
if (GameMain.Server == null)
{
DebugConsole.ThrowError($"TryTakeOverBot: Client {Name} requested to take over a bot but GameMain.Server is null!");
return false;
}
if (GameMain.NetworkMember is not { ServerSettings.RespawnMode: RespawnMode.Permadeath })
{
DebugConsole.ThrowError($"Client {Name} requested to take over a bot but Permadeath is not enabled!");
GameMain.Server.SendConsoleMessage($"Permadeath mode is not enabled, cannot take over a bot.", this, Color.Red);
return false;
}
if (CharacterInfo == null)
{
DebugConsole.ThrowError($"Permadeath: Client {Name} requested to take over a bot, but they don't seem to have a character at all yet.");
GameMain.Server.SendConsoleMessage($"Permadeath: Taking over a bot requires having a character that died first.", this, Color.Red);
return false;
}
if (CharacterInfo is not { PermanentlyDead: true })
{
DebugConsole.ThrowError($"Permadeath: Client {Name} requested to take over a bot, but their character has not been permanently killed.");
GameMain.Server.SendConsoleMessage($"Permadeath: Could not take over the bot, previous character not permanently killed.", this, Color.Red);
return false;
}
if (!botCharacter.IsBot)
{
DebugConsole.ThrowError($"Permadeath: {Name} requested to take over a bot character, but the target character is not a bot!");
GameMain.Server.SendConsoleMessage($"Permadeath: Could not take over the target character because it is not a bot.", this, Color.Red);
return false;
}
// Now that the old permanently killed character will be replaced, we can fully discard it
if (GameMain.GameSession?.Campaign is MultiPlayerCampaign mpCampaign)
{
mpCampaign.DiscardClientCharacterData(this);
}
GameMain.Server.SetClientCharacter(this, botCharacter);
SpectateOnly = false;
return true;
}
}
}