diff --git a/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.Designer.cs b/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.Designer.cs index 691fed8d9ca..3e7b22c9b4c 100644 --- a/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.Designer.cs +++ b/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.Designer.cs @@ -1630,7 +1630,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ConnectionLogId"); @@ -1687,7 +1687,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("last_seen_hwid__type"); + .HasColumnName("last_seen_hwid_type"); b1.HasKey("PlayerId"); @@ -1774,7 +1774,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerBanId"); @@ -1851,7 +1851,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerRoleBanId"); diff --git a/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.cs b/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.cs index 7dcba9dda9d..029a62460ba 100644 --- a/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.cs +++ b/Content.Server.Database/Migrations/Postgres/20241222203147_UpstreamMerge.cs @@ -12,26 +12,6 @@ protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("DROP TABLE IF EXISTS ProileLoadouts;"); - migrationBuilder.RenameColumn( - name: "hwid_type", - table: "server_role_ban", - newName: "hwid__type"); - - migrationBuilder.RenameColumn( - name: "hwid_type", - table: "server_ban", - newName: "hwid__type"); - - migrationBuilder.RenameColumn( - name: "last_seen_hwid_type", - table: "player", - newName: "last_seen_hwid__type"); - - migrationBuilder.RenameColumn( - name: "hwid_type", - table: "connection_log", - newName: "hwid__type"); - migrationBuilder.AddForeignKey( name: "FK_loadout_profile_profile_id", table: "loadout", @@ -48,26 +28,6 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "FK_loadout_profile_profile_id", table: "loadout"); - migrationBuilder.RenameColumn( - name: "hwid__type", - table: "server_role_ban", - newName: "hwid_type"); - - migrationBuilder.RenameColumn( - name: "hwid__type", - table: "server_ban", - newName: "hwid_type"); - - migrationBuilder.RenameColumn( - name: "last_seen_hwid__type", - table: "player", - newName: "last_seen_hwid_type"); - - migrationBuilder.RenameColumn( - name: "hwid__type", - table: "connection_log", - newName: "hwid_type"); - migrationBuilder.CreateTable( name: "ProfileLoadout", columns: table => new diff --git a/Content.Server.Database/Migrations/Postgres/PostgresServerDbContextModelSnapshot.cs b/Content.Server.Database/Migrations/Postgres/PostgresServerDbContextModelSnapshot.cs index 09767111da3..c39fb6872be 100644 --- a/Content.Server.Database/Migrations/Postgres/PostgresServerDbContextModelSnapshot.cs +++ b/Content.Server.Database/Migrations/Postgres/PostgresServerDbContextModelSnapshot.cs @@ -1627,7 +1627,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ConnectionLogId"); @@ -1684,7 +1684,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("last_seen_hwid__type"); + .HasColumnName("last_seen_hwid_type"); b1.HasKey("PlayerId"); @@ -1771,7 +1771,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerBanId"); @@ -1848,7 +1848,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("integer") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerRoleBanId"); diff --git a/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.Designer.cs b/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.Designer.cs index 30ea446c29e..8b6c0048392 100644 --- a/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.Designer.cs +++ b/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.Designer.cs @@ -1557,7 +1557,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ConnectionLogId"); @@ -1614,7 +1614,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("last_seen_hwid__type"); + .HasColumnName("last_seen_hwid_type"); b1.HasKey("PlayerId"); @@ -1701,7 +1701,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerBanId"); @@ -1778,7 +1778,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerRoleBanId"); diff --git a/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.cs b/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.cs index f46ab47b408..8b5d3573763 100644 --- a/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.cs +++ b/Content.Server.Database/Migrations/Sqlite/20241222203134_UpstreamMerge.cs @@ -12,26 +12,6 @@ protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("DROP TABLE IF EXISTS ProileLoadouts;"); - migrationBuilder.RenameColumn( - name: "hwid_type", - table: "server_role_ban", - newName: "hwid__type"); - - migrationBuilder.RenameColumn( - name: "hwid_type", - table: "server_ban", - newName: "hwid__type"); - - migrationBuilder.RenameColumn( - name: "last_seen_hwid_type", - table: "player", - newName: "last_seen_hwid__type"); - - migrationBuilder.RenameColumn( - name: "hwid_type", - table: "connection_log", - newName: "hwid__type"); - migrationBuilder.AddForeignKey( name: "FK_loadout_profile_profile_id", table: "loadout", @@ -48,26 +28,6 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "FK_loadout_profile_profile_id", table: "loadout"); - migrationBuilder.RenameColumn( - name: "hwid__type", - table: "server_role_ban", - newName: "hwid_type"); - - migrationBuilder.RenameColumn( - name: "hwid__type", - table: "server_ban", - newName: "hwid_type"); - - migrationBuilder.RenameColumn( - name: "last_seen_hwid__type", - table: "player", - newName: "last_seen_hwid_type"); - - migrationBuilder.RenameColumn( - name: "hwid__type", - table: "connection_log", - newName: "hwid_type"); - migrationBuilder.CreateTable( name: "ProfileLoadout", columns: table => new diff --git a/Content.Server.Database/Migrations/Sqlite/SqliteServerDbContextModelSnapshot.cs b/Content.Server.Database/Migrations/Sqlite/SqliteServerDbContextModelSnapshot.cs index 514c0007eed..3b2b680ddf5 100644 --- a/Content.Server.Database/Migrations/Sqlite/SqliteServerDbContextModelSnapshot.cs +++ b/Content.Server.Database/Migrations/Sqlite/SqliteServerDbContextModelSnapshot.cs @@ -1554,7 +1554,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ConnectionLogId"); @@ -1611,7 +1611,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("last_seen_hwid__type"); + .HasColumnName("last_seen_hwid_type"); b1.HasKey("PlayerId"); @@ -1698,7 +1698,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerBanId"); @@ -1775,7 +1775,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("INTEGER") .HasDefaultValue(0) - .HasColumnName("hwid__type"); + .HasColumnName("hwid_type"); b1.HasKey("ServerRoleBanId"); diff --git a/Content.Server.Database/SnakeCaseNaming.cs b/Content.Server.Database/SnakeCaseNaming.cs index 27ce392cd50..3a67ffb9cd1 100644 --- a/Content.Server.Database/SnakeCaseNaming.cs +++ b/Content.Server.Database/SnakeCaseNaming.cs @@ -82,7 +82,7 @@ public ConventionSet ModifyConventions(ConventionSet conventionSet) } } - public class SnakeCaseConvention : + public partial class SnakeCaseConvention : IEntityTypeAddedConvention, IEntityTypeAnnotationChangedConvention, IPropertyAddedConvention, @@ -99,22 +99,27 @@ public SnakeCaseConvention() {} public static string RewriteName(string name) { - var regex = new Regex("[A-Z]+", RegexOptions.Compiled); - return regex.Replace( - name, - (Match match) => { - if (match.Index == 0 && (match.Value == "FK" || match.Value == "PK" || match.Value == "IX")) { - return match.Value; + return UpperCaseLocator() + .Replace( + name, + (Match match) => { + if (match.Index == 0 && (match.Value == "FK" || match.Value == "PK" || match.Value == "IX")) { + return match.Value; + } + if (match.Value == "HWI") + return (match.Index == 0 ? "" : "_") + "hwi"; + if (match.Index == 0) + return match.Value.ToLower(); + if (match.Length > 1) + return $"_{match.Value[..^1].ToLower()}_{match.Value[^1..^0].ToLower()}"; + + // Do not add a _ if there is already one before this. This happens with owned entities. + if (name[match.Index - 1] == '_') + return match.Value.ToLower(); + + return "_" + match.Value.ToLower(); } - if (match.Value == "HWI") - return (match.Index == 0 ? "" : "_") + "hwi"; - if (match.Index == 0) - return match.Value.ToLower(); - if (match.Length > 1) - return $"_{match.Value[..^1].ToLower()}_{match.Value[^1..^0].ToLower()}"; - return "_" + match.Value.ToLower(); - } - ); + ); } public virtual void ProcessEntityTypeAdded( @@ -332,5 +337,8 @@ private static void RewriteColumnName(IConventionPropertyBuilder propertyBuilder } } } + + [GeneratedRegex("[A-Z]+", RegexOptions.Compiled)] + private static partial Regex UpperCaseLocator(); } } diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 05fce8cd048..8308a1c1ec4 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -580,18 +580,13 @@ private void ResettingCleanup() _playerGameStatuses.Clear(); _sawmill.Error($"Resetting cleanup with {_playerManager.Sessions.Length} players"); foreach (var session in _playerManager.Sessions) - { _playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay; - } } public bool DelayStart(TimeSpan time) { if (_runLevel != GameRunLevel.PreRoundLobby) - { return false; - } - _roundStartTime += time; RaiseNetworkEvent(new TickerLobbyCountdownEvent(_roundStartTime, Paused));