Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop

This commit is contained in:
EvilFactory
2025-04-10 10:37:09 -03:00
296 changed files with 8420 additions and 2945 deletions
@@ -225,15 +225,17 @@ namespace Barotrauma.Networking
public static string ApplyDistanceEffect(string text, float garbleAmount)
{
if (garbleAmount < 0.3f) return text;
if (garbleAmount >= 1.0f) return "";
if (garbleAmount < 0.3f) { return text; }
if (garbleAmount >= 1.0f) { return ""; }
int startIndex = Math.Max(text.IndexOf(':') + 1, 1);
string textWithoutColorTags = RichString.Rich(text).SanitizedValue;
int startIndex = Math.Max(textWithoutColorTags.IndexOf(':') + 1, 1);
StringBuilder sb = new StringBuilder(text.Length);
for (int i = 0; i < text.Length; i++)
for (int i = 0; i < textWithoutColorTags.Length; i++)
{
sb.Append((i > startIndex && Rand.Range(0.0f, 1.0f) < garbleAmount) ? '-' : text[i]);
sb.Append((i > startIndex && Rand.Range(0.0f, 1.0f) < garbleAmount) ? '-' : textWithoutColorTags[i]);
}
return sb.ToString();
@@ -83,10 +83,16 @@ namespace Barotrauma.Networking
XDocument doc = XMLExtensions.TryLoadXml(file);
if (doc == null) { return; }
List.Clear();
foreach (XElement element in doc.Root.Elements())
{
List.Add(new PermissionPreset(element));
var newPermissionPreset = new PermissionPreset(element);
var existingPreset = List.FirstOrDefault(p => p.Identifier == newPermissionPreset.Identifier);
if (existingPreset != null)
{
List.Remove(existingPreset);
DebugConsole.AddWarning($"The permission preset file {file} contains a permission preset that conflicts with another preset. Overriding the previous preset...");
}
List.Add(newPermissionPreset);
}
}
@@ -74,7 +74,7 @@ namespace Barotrauma
{
return null;
}
spawnedItem = new Item(Prefab, Vector2.Zero, null);
spawnedItem = new Item(Prefab, Inventory.Owner.Position, Inventory.Owner.Submarine);
//this needs to be done before attempting to put the item in the inventory,
//because the quality and condition may affect whether it can go in the inventory (into an existing stack)
SetItemProperties(spawnedItem);
@@ -93,7 +93,6 @@ namespace Barotrauma
}
}
}
spawnedItem.SetTransform(FarseerPhysics.ConvertUnits.ToSimUnits(Inventory.Owner?.WorldPosition ?? Vector2.Zero), spawnedItem.body?.Rotation ?? 0.0f, findNewHull: false);
}
}
else
@@ -27,6 +27,8 @@ namespace Barotrauma.Networking
RESPONSE_STARTGAME, //tell the server whether you're ready to start
SERVER_COMMAND, //tell the server to end a round or kick/ban someone (special permissions required)
ENDROUND_SELF, //the client wants to end the round for themselves only and return to the lobby
EVENTMANAGER_RESPONSE,
REQUEST_STARTGAMEFINALIZE, //tell the server you're ready to finalize round initialization
@@ -43,6 +45,7 @@ namespace Barotrauma.Networking
READY_CHECK,
READY_TO_SPAWN,
TAKEOVERBOT,
TOGGLE_RESERVE_BENCH,
REQUEST_BACKUP_INDICES, // client wants a list of available backups for a save file
LUA_NET_MESSAGE
@@ -109,6 +109,15 @@ namespace Barotrauma.Networking
teamSpecificStates = new Dictionary<CharacterTeamType, TeamSpecificState>();
int teamCount = GameMain.GameSession?.GameMode is PvPMode ? 2 : 1;
if (Level.Loaded == null)
{
throw new InvalidOperationException("Attempted to instantiate a respawn manager before a level was loaded.");
}
bool shouldLoadShuttle =
shuttleInfo != null &&
!Level.Loaded.ShouldSpawnCrewInsideOutpost();
respawnShuttles.Clear();
List<WifiComponent> wifiComponents = new List<WifiComponent>();
for (int i = 0; i < teamCount; i++)
@@ -116,7 +125,7 @@ namespace Barotrauma.Networking
var teamId = i == 0 ? CharacterTeamType.Team1 : CharacterTeamType.Team2;
teamSpecificStates.Add(teamId, new TeamSpecificState(teamId));
if (shuttleInfo != null && networkMember.ServerSettings is not { RespawnMode: RespawnMode.Permadeath })
if (shouldLoadShuttle)
{
shuttleDoors.Add(teamId, new List<Door>());
shuttleSteering.Add(teamId, new List<Steering>());
@@ -179,7 +188,7 @@ namespace Barotrauma.Networking
{
foreach (Wire wire in connection.Wires)
{
if (wire != null) wire.Locked = true;
if (wire != null) { wire.Locked = true; }
}
}
}
@@ -286,6 +295,15 @@ namespace Barotrauma.Networking
return null;
}
private void SetShuttleBodyType(CharacterTeamType team, BodyType bodyType)
{
var shuttle = GetShuttle(team);
if (shuttle != null)
{
shuttle.PhysicsBody.BodyType = bodyType;
}
}
private void ResetShuttle(TeamSpecificState teamSpecificState)
{
teamSpecificState.ReturnTime = DateTime.Now + new TimeSpan(0, 0, 0, 0, milliseconds: (int)(maxTransportTime * 1000));
@@ -384,12 +402,13 @@ namespace Barotrauma.Networking
shuttle.SetPosition(new Vector2(
teamSpecificState.TeamID == CharacterTeamType.Team1 ? Level.Loaded.StartPosition.X : Level.Loaded.EndPosition.X,
Level.Loaded.Size.Y + shuttle.Borders.Height));
shuttle.Velocity = Vector2.Zero;
shuttle.Velocity = Vector2.Zero;
foreach (var characterPosition in characterPositions)
{
characterPosition.Key.TeleportTo(characterPosition.Value);
}
SetShuttleBodyType(teamSpecificState.TeamID, BodyType.Static);
}
public static float GetReducedSkill(CharacterInfo characterInfo, Skill skill, float skillLossPercentage, float? currentSkillLevel = null)
@@ -69,6 +69,7 @@ namespace Barotrauma.Networking
}
public static readonly string PermissionPresetFile = "Data" + Path.DirectorySeparatorChar + "permissionpresets.xml";
public static readonly string PermissionPresetFileCustom = "Data" + Path.DirectorySeparatorChar + "permissionpresets_player.xml";
public string Name
{
@@ -285,7 +286,9 @@ namespace Barotrauma.Networking
HiddenSubs = new HashSet<string>();
PermissionPreset.List.Clear();
PermissionPreset.LoadAll(PermissionPresetFile);
PermissionPreset.LoadAll(PermissionPresetFileCustom);
InitProjSpecific();
ServerName = serverName;
@@ -615,6 +618,19 @@ namespace Barotrauma.Networking
}
}
private bool allowAFK;
[Serialize(true, IsPropertySaveable.Yes)]
public bool AllowAFK
{
get { return allowAFK; }
private set
{
if (allowAFK == value) { return; }
allowAFK = value;
ServerDetailsChanged = true;
}
}
[Serialize(true, IsPropertySaveable.Yes)]
public bool SaveServerLogs
{
@@ -996,7 +1012,7 @@ namespace Barotrauma.Networking
public float KillDisconnectedTime
{
get;
private set;
set;
}
/// <summary>