Skip to content

Commit

Permalink
Yeeeeeeeeeeeah.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyyapril committed Dec 25, 2024
1 parent 82c3f2e commit f2cbb27
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 117 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasColumnName("hwid__type");
.HasColumnName("hwid_type");

b1.HasKey("ConnectionLogId");

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -1771,7 +1771,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasColumnName("hwid__type");
.HasColumnName("hwid_type");

b1.HasKey("ServerBanId");

Expand Down Expand Up @@ -1848,7 +1848,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasColumnName("hwid__type");
.HasColumnName("hwid_type");

b1.HasKey("ServerRoleBanId");

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0)
.HasColumnName("hwid__type");
.HasColumnName("hwid_type");

b1.HasKey("ConnectionLogId");

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -1698,7 +1698,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0)
.HasColumnName("hwid__type");
.HasColumnName("hwid_type");

b1.HasKey("ServerBanId");

Expand Down Expand Up @@ -1775,7 +1775,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasDefaultValue(0)
.HasColumnName("hwid__type");
.HasColumnName("hwid_type");

b1.HasKey("ServerRoleBanId");

Expand Down
40 changes: 24 additions & 16 deletions Content.Server.Database/SnakeCaseNaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public ConventionSet ModifyConventions(ConventionSet conventionSet)
}
}

public class SnakeCaseConvention :
public partial class SnakeCaseConvention :
IEntityTypeAddedConvention,
IEntityTypeAnnotationChangedConvention,
IPropertyAddedConvention,
Expand All @@ -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(
Expand Down Expand Up @@ -332,5 +337,8 @@ private static void RewriteColumnName(IConventionPropertyBuilder propertyBuilder
}
}
}

[GeneratedRegex("[A-Z]+", RegexOptions.Compiled)]
private static partial Regex UpperCaseLocator();
}
}
5 changes: 0 additions & 5 deletions Content.Server/GameTicking/GameTicker.RoundFlow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit f2cbb27

Please sign in to comment.