Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@
<Control HorizontalExpand="True"/>
<Button Name="PlaytimePerksButton" Pressed="True" ToggleMode="True" Text="{Loc 'humanoid-profile-editor-enable'}" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Callsign -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-callsign'}" />
<Control HorizontalExpand="True"/>
<LineEdit Name="CallsignEdit" HorizontalAlignment="Right" MinWidth="100" />
</BoxContainer>
<!-- Synthetic Name -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-synthetic-name'}" />
<Control HorizontalExpand="True"/>
<LineEdit Name="SyntheticNameEdit" HorizontalAlignment="Right" MinWidth="100" />
</BoxContainer>
<!-- Xeno Prefix -->
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-xeno-prefix'}" />
Expand Down
28 changes: 28 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ public HumanoidProfileEditor(

NameEdit.OnTextChanged += args => { SetName(args.Text); };
NameEdit.IsValid = args => args.Length <= _maxNameLength;
CallsignEdit.OnTextChanged += args => { SetCallsign(args.Text); };
CallsignEdit.IsValid = args => args.Length <= _maxNameLength;
SyntheticNameEdit.OnTextChanged += args => { SetSyntheticName(args.Text); };
SyntheticNameEdit.IsValid = args => args.Length <= _maxNameLength;
NameRandomize.OnPressed += args => RandomizeName();
RandomizeEverythingButton.OnPressed += args => { RandomizeEverything(); };
WarningLabel.SetMarkup($"[color=red]{Loc.GetString("humanoid-profile-editor-naming-rules-warning")}[/color]");
Expand Down Expand Up @@ -922,6 +926,8 @@ public void SetProfile(HumanoidCharacterProfile? profile, int? slot)
JobOverride = null;

UpdateNameEdit();
UpdateCallsignEdit();
UpdateSyntheticNameEdit();
UpdateFlavorTextEdit();
UpdateSexControls();
UpdateGenderControls();
Expand Down Expand Up @@ -1435,6 +1441,18 @@ private void SetName(string newName)
_entManager.System<MetaDataSystem>().SetEntityName(PreviewDummy, newName);
}

private void SetCallsign(string callsign)
{
Profile = Profile?.WithCallsign(callsign);
SetDirty();
}

private void SetSyntheticName(string syntheticName)
{
Profile = Profile?.WithSyntheticName(syntheticName);
SetDirty();
}

private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
{
Profile = Profile?.WithSpawnPriorityPreference(newSpawnPriority);
Expand Down Expand Up @@ -1599,6 +1617,16 @@ private void UpdateNameEdit()
NameEdit.Text = Profile?.Name ?? "";
}

private void UpdateCallsignEdit()
{
CallsignEdit.Text = Profile?.Callsign ?? "";
}

private void UpdateSyntheticNameEdit()
{
SyntheticNameEdit.Text = Profile?.SyntheticName ?? "";
}

private void UpdateFlavorTextEdit()
{
if (_flavorTextEdit != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Infrastructure;

#nullable disable

namespace Content.Server.Database.Migrations.Postgres
{
/// <inheritdoc />
[DbContext(typeof(PostgresServerDbContext))]
[Migration("20260510120000_CallsignSyntheticName")]
public partial class CallsignSyntheticName : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "callsign",
table: "profile",
type: "text",
nullable: false,
defaultValue: "");

migrationBuilder.AddColumn<string>(
name: "synthetic_name",
table: "profile",
type: "text",
nullable: false,
defaultValue: "");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "callsign",
table: "profile");

migrationBuilder.DropColumn(
name: "synthetic_name",
table: "profile");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("text")
.HasColumnName("char_name");

b.Property<string>("Callsign")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("")
.HasColumnName("callsign");

b.Property<string>("EyeColor")
.IsRequired()
.HasColumnType("text")
Expand Down Expand Up @@ -925,6 +932,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("text")
.HasColumnName("species");

b.Property<string>("SyntheticName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("text")
.HasDefaultValue("")
.HasColumnName("synthetic_name");

b.Property<string>("XenoPostfix")
.IsRequired()
.ValueGeneratedOnAdd()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Infrastructure;

#nullable disable

namespace Content.Server.Database.Migrations.Sqlite
{
/// <inheritdoc />
[DbContext(typeof(SqliteServerDbContext))]
[Migration("20260510120000_CallsignSyntheticName")]
public partial class CallsignSyntheticName : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "callsign",
table: "profile",
type: "TEXT",
nullable: false,
defaultValue: "");

migrationBuilder.AddColumn<string>(
name: "synthetic_name",
table: "profile",
type: "TEXT",
nullable: false,
defaultValue: "");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "callsign",
table: "profile");

migrationBuilder.DropColumn(
name: "synthetic_name",
table: "profile");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("TEXT")
.HasColumnName("char_name");

b.Property<string>("Callsign")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue("")
.HasColumnName("callsign");

b.Property<string>("EyeColor")
.IsRequired()
.HasColumnType("TEXT")
Expand Down Expand Up @@ -876,6 +883,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("TEXT")
.HasColumnName("species");

b.Property<string>("SyntheticName")
.IsRequired()
.ValueGeneratedOnAdd()
.HasColumnType("TEXT")
.HasDefaultValue("")
.HasColumnName("synthetic_name");

b.Property<string>("XenoPostfix")
.IsRequired()
.ValueGeneratedOnAdd()
Expand Down
10 changes: 10 additions & 0 deletions Content.Server.Database/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.Property(p => p.XenoPostfix)
.HasDefaultValue(string.Empty);

modelBuilder.Entity<Profile>()
.Property(p => p.Callsign)
.HasDefaultValue(string.Empty);

modelBuilder.Entity<Profile>()
.Property(p => p.SyntheticName)
.HasDefaultValue(string.Empty);

modelBuilder.Entity<Antag>()
.HasIndex(p => new {HumanoidProfileId = p.ProfileId, p.AntagName})
.IsUnique();
Expand Down Expand Up @@ -584,6 +592,8 @@ public class Profile
public string EyeColor { get; set; } = null!;
public string SkinColor { get; set; } = null!;
public int SpawnPriority { get; set; } = 0;
public string Callsign { get; set; } = string.Empty;
public string SyntheticName { get; set; } = string.Empty;
public List<Job> Jobs { get; } = new();
public List<Antag> Antags { get; } = new();
public List<Trait> Traits { get; } = new();
Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Database/ServerDbBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ private static HumanoidCharacterProfile ConvertProfiles(Profile profile)
profile.XenoPrefix,
profile.XenoPostfix,
allegiance,
origin
origin,
profile.Callsign,
profile.SyntheticName
);
}

Expand All @@ -336,6 +338,8 @@ private static Profile ConvertProfiles(HumanoidCharacterProfile humanoid, int sl
var markings = JsonSerializer.SerializeToDocument(markingStrings);

profile.CharacterName = humanoid.Name;
profile.Callsign = humanoid.Callsign;
profile.SyntheticName = humanoid.SyntheticName;
profile.FlavorText = humanoid.FlavorText;
profile.Species = humanoid.Species;
profile.Age = humanoid.Age;
Expand Down
10 changes: 5 additions & 5 deletions Content.Server/GameTicking/GameTicker.Spawning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ private void SpawnPlayer(ICommonSession player,

DebugTools.AssertNotNull(data);

var newMind = _mind.CreateMind(data!.UserId, character.Name);
_mind.SetUserId(newMind, data.UserId);

var jobPrototype = _prototypeManager.Index<JobPrototype>(jobId);
var characterSpawnName = character.GetSpawnName(jobPrototype);
var newMind = _mind.CreateMind(data!.UserId, characterSpawnName);
_mind.SetUserId(newMind, data.UserId);

_playTimeTrackings.PlayerRolesChanged(player);

Expand Down Expand Up @@ -523,13 +523,13 @@ private void SpawnPlayer(ICommonSession player,
{
_adminLogger.Add(LogType.LateJoin,
LogImpact.Medium,
$"Player {player.Name} late joined as {character.Name:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
$"Player {player.Name} late joined as {characterSpawnName:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
}
else
{
_adminLogger.Add(LogType.RoundStartJoin,
LogImpact.Medium,
$"Player {player.Name} joined as {character.Name:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
$"Player {player.Name} joined as {characterSpawnName:characterName} on station {Name(station):stationName} with {ToPrettyString(mob):entity} as a {jobName:jobName}.");
}

// Make sure they're aware of extended access.
Expand Down
11 changes: 10 additions & 1 deletion Content.Server/Station/Systems/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public EntityUid SpawnPlayerMob(
_prototypeManager.TryIndex(job ?? string.Empty, out var prototype, false);
// Get the original job prototype for access/faction/ID
_prototypeManager.TryIndex(originalJob ?? string.Empty, out var originalPrototype, false);
var namePrototype = originalPrototype ?? prototype;
RoleLoadout? loadout = null;

// Need to get the loadout up-front to handle names if we use an entity spawn override.
Expand Down Expand Up @@ -213,8 +214,9 @@ public EntityUid SpawnPlayerMob(

if (profile != null)
{
var spawnName = profile.GetSpawnName(namePrototype);
_humanoidSystem.LoadProfile(entity.Value, profile);
_metaSystem.SetEntityName(entity.Value, profile.Name);
_metaSystem.SetEntityName(entity.Value, spawnName);

if (profile.FlavorText != "" && _configurationManager.GetCVar(CCVars.FlavorText))
{
Expand All @@ -233,6 +235,13 @@ public EntityUid SpawnPlayerMob(
EquipStartingGear(entity.Value, startingGear, raiseEvent: false);
}

if (profile != null)
{
var spawnName = profile.GetSpawnName(namePrototype);
if (spawnName != profile.Name)
_metaSystem.SetEntityName(entity.Value, spawnName);
}

if (!Equals(job, originalJob) && originalPrototype?.StartingGear != null)
{
var origGear = _prototypeManager.Index<StartingGearPrototype>(originalPrototype.StartingGear);
Expand Down
Loading
Loading